@rainbow-robotics/preview-host 1.3.3 → 1.3.4
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.BmOv5ESV.js → AmrCapabilityControl.D38iC0Zw.js} +1 -1
- package/dist/assets/{RbLocalizationProvider.C3gW8lxk.js → RbLocalizationProvider.jfeE2R7t.js} +117 -117
- package/dist/assets/{__federation_expose_App.CYisAOz9.js → __federation_expose_App.B2iHOiPY.js} +267 -267
- package/dist/assets/__federation_fn_import.DdkEuT6t.js +2 -2
- package/dist/assets/{cssMode.DEflnK5F.js → cssMode.Dq7ZuLbx.js} +1 -1
- package/dist/assets/{freemarker2.CKB5TzX-.js → freemarker2.DeCrO8Tw.js} +1 -1
- package/dist/assets/{handlebars.Ct0JMO7R.js → handlebars.BJo6sX5U.js} +1 -1
- package/dist/assets/{html.COB_HeO4.js → html.DEzw9UNC.js} +1 -1
- package/dist/assets/{htmlMode.ghLonDVf.js → htmlMode.CuH3aVu0.js} +1 -1
- package/dist/assets/{index.Cjt1UVow.js → index.C6hi38PU.js} +1 -1
- package/dist/assets/{index.wTmKiFB1.js → index.C9Au0enJ.js} +2 -2
- package/dist/assets/{index.B5GKO2or.js → index.DTNhJc5Q.js} +1 -1
- package/dist/assets/{javascript.BUmotu1G.js → javascript.u92KX2Gs.js} +1 -1
- package/dist/assets/{jsonMode.DWjWVpop.js → jsonMode.BmjRvi7M.js} +1 -1
- package/dist/assets/{liquid.BxeqPJme.js → liquid.BRk54JSg.js} +1 -1
- package/dist/assets/{lspLanguageFeatures.CzsUmTRV.js → lspLanguageFeatures.BPTvpyTA.js} +1 -1
- package/dist/assets/{mdx.CzsF8DRi.js → mdx.DHINycUh.js} +1 -1
- package/dist/assets/{python.BjSwpNhY.js → python.Cc6koa8Q.js} +1 -1
- package/dist/assets/{razor.R7GRJmjt.js → razor.bfNhEEiK.js} +1 -1
- package/dist/assets/remoteEntry.js +1 -1
- package/dist/assets/{tsMode.BsXeeJyq.js → tsMode.DlZeconQ.js} +1 -1
- package/dist/assets/{typescript.B_6AkgJt.js → typescript.C6NUdio7.js} +1 -1
- package/dist/assets/{useFileDownload.BeZDjmAJ.js → useFileDownload.kL1LfKPq.js} +244 -244
- package/dist/assets/{xml.DhAjCeV_.js → xml.r7ccUASk.js} +1 -1
- package/dist/assets/{yaml.BSub4inJ.js → yaml.CdZ5CKAU.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{c as wu,
|
|
1
|
+
import{c as wu,fa as Su,cV as Fg,gk as Ug,gl as cc,gm as Ov,gn as Mu,go as Mf,gp as Fv,gq as Bg,gr as Ef,gs as Uv,gt as Bv,G as zv,j as p,x as on,cH as Bn,gu as Hv,dg as Gv,gv as Vv,gw as Wv,S as jv,cw as Ar,H as E,cx as en,U as me,c1 as j,gx as ya,gy as Eu,eM as zg,aX as qn,eF as Pa,bY as un,fI as Xv,fL as Hg,cy as qv,bj as Zv,a$ as We,ff as Yv,fl as Gg,ev as Vg,cD as vi,cY as Wg,av as ji,cZ as jg,eV as Kv,cO as Xg,cW as Sc,bJ as xa,eS as _h,eZ as qg,bR as Tu,bS as Hi,bP as Au,bH as Zg,fE as $v,dk as Qv,fF as Jv,dl as Cu,fA as ey,fB as ty,cE as Pu,eO as Ru,gz as Tf,d5 as ny,aW as _r,bs as dc,V as es,gf as Yg,X as ha,d8 as iy,d9 as sy,_ as ry,bF as cn,en as ay,gA as oy,gB as ly,gC as cy,gD as dy,gE as hy,aZ as Af,bQ as js,de as wr,gh as Kg,gi as Nu,gj as $g,e_ as Du,a9 as Lu,gF as Qg,cT as As,ag as Cs,ab as Ut,fx as Jg,fy as eb,cQ as uy,ey as fy,af as py,e$ as Cf}from"./RbLocalizationProvider.jfeE2R7t.js";import{importShared as wt}from"./__federation_fn_import.DdkEuT6t.js";import{g as my}from"./index.P6snMalu.js";import{c as Mc}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.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const gy=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],
|
|
6
|
+
*/const gy=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],gN=wu("chevron-down",gy);/**
|
|
7
7
|
* @license lucide-react v0.486.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
@@ -22,11 +22,11 @@ import{c as wu,f9 as Su,cV as Fg,gj as Ug,gk as cc,gl as Ov,gm as Mu,gn as Mf,go
|
|
|
22
22
|
* LICENSE.md file in the root directory of this source tree.
|
|
23
23
|
*
|
|
24
24
|
* @license MIT
|
|
25
|
-
*/const Un=await wt("react"),_y=await wt("react-dom");function hc(){return hc=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},hc.apply(this,arguments)}function tb(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s<n.length;s++)i=n[s],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}function wy(r){return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}function Sy(r,e){return r.button===0&&(!e||e==="_self")&&!wy(r)}function wh(r){return r===void 0&&(r=""),new URLSearchParams(typeof r=="string"||Array.isArray(r)||r instanceof URLSearchParams?r:Object.keys(r).reduce((e,t)=>{let n=r[t];return e.concat(Array.isArray(n)?n.map(i=>[t,i]):[[t,n]])},[]))}function My(r,e){let t=wh(r);return e&&e.forEach((n,i)=>{t.has(i)||e.getAll(i).forEach(s=>{t.append(i,s)})}),t}const Ey=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Ty=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],Ay="6";try{window.__reactRouterVersion=Ay}catch{}const Cy=Un.createContext({isTransitioning:!1}),Py="startTransition";Un[Py];const Ry="flushSync";_y[Ry];const Ny="useId";Un[Ny];const Dy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ly=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Iy=Un.forwardRef(function(e,t){let{onClick:n,relative:i,reloadDocument:s,replace:a,state:o,target:l,to:c,preventScrollReset:d,viewTransition:h}=e,u=tb(e,Ey),{basename:f}=Un.useContext(Ug),m,v=!1;if(typeof c=="string"&&Ly.test(c)&&(m=c,Dy))try{let w=new URL(window.location.href),_=c.startsWith("//")?new URL(w.protocol+c):new URL(c),R=cc(_.pathname,f);_.origin===w.origin&&R!=null?c=R+_.search+_.hash:v=!0}catch{}let g=Ov(c,{relative:i}),b=Oy(c,{replace:a,state:o,target:l,preventScrollReset:d,relative:i,viewTransition:h});function y(w){n&&n(w),w.defaultPrevented||b(w)}return Un.createElement("a",hc({},u,{href:m||g,onClick:v||s?n:y,ref:t,target:l}))}),
|
|
25
|
+
*/const Un=await wt("react"),_y=await wt("react-dom");function hc(){return hc=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},hc.apply(this,arguments)}function tb(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s<n.length;s++)i=n[s],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}function wy(r){return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}function Sy(r,e){return r.button===0&&(!e||e==="_self")&&!wy(r)}function wh(r){return r===void 0&&(r=""),new URLSearchParams(typeof r=="string"||Array.isArray(r)||r instanceof URLSearchParams?r:Object.keys(r).reduce((e,t)=>{let n=r[t];return e.concat(Array.isArray(n)?n.map(i=>[t,i]):[[t,n]])},[]))}function My(r,e){let t=wh(r);return e&&e.forEach((n,i)=>{t.has(i)||e.getAll(i).forEach(s=>{t.append(i,s)})}),t}const Ey=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Ty=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],Ay="6";try{window.__reactRouterVersion=Ay}catch{}const Cy=Un.createContext({isTransitioning:!1}),Py="startTransition";Un[Py];const Ry="flushSync";_y[Ry];const Ny="useId";Un[Ny];const Dy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ly=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Iy=Un.forwardRef(function(e,t){let{onClick:n,relative:i,reloadDocument:s,replace:a,state:o,target:l,to:c,preventScrollReset:d,viewTransition:h}=e,u=tb(e,Ey),{basename:f}=Un.useContext(Ug),m,v=!1;if(typeof c=="string"&&Ly.test(c)&&(m=c,Dy))try{let w=new URL(window.location.href),_=c.startsWith("//")?new URL(w.protocol+c):new URL(c),R=cc(_.pathname,f);_.origin===w.origin&&R!=null?c=R+_.search+_.hash:v=!0}catch{}let g=Ov(c,{relative:i}),b=Oy(c,{replace:a,state:o,target:l,preventScrollReset:d,relative:i,viewTransition:h});function y(w){n&&n(w),w.defaultPrevented||b(w)}return Un.createElement("a",hc({},u,{href:m||g,onClick:v||s?n:y,ref:t,target:l}))}),bN=Un.forwardRef(function(e,t){let{"aria-current":n="page",caseSensitive:i=!1,className:s="",end:a=!1,style:o,to:l,viewTransition:c,children:d}=e,h=tb(e,Ty),u=Mu(l,{relative:h.relative}),f=Su(),m=Un.useContext(Fv),{navigator:v,basename:g}=Un.useContext(Ug),b=m!=null&&Uy(u)&&c===!0,y=v.encodeLocation?v.encodeLocation(u).pathname:u.pathname,w=f.pathname,_=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;i||(w=w.toLowerCase(),_=_?_.toLowerCase():null,y=y.toLowerCase()),_&&g&&(_=cc(_,g)||_);const R=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let T=w===y||!a&&w.startsWith(y)&&w.charAt(R)==="/",P=_!=null&&(_===y||!a&&_.startsWith(y)&&_.charAt(y.length)==="/"),M={isActive:T,isPending:P,isTransitioning:b},x=T?n:void 0,S;typeof s=="function"?S=s(M):S=[s,T?"active":null,P?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let C=typeof o=="function"?o(M):o;return Un.createElement(Iy,hc({},h,{"aria-current":x,className:S,ref:t,style:C,to:l,viewTransition:c}),typeof d=="function"?d(M):d)});var Sh;(function(r){r.UseScrollRestoration="useScrollRestoration",r.UseSubmit="useSubmit",r.UseSubmitFetcher="useSubmitFetcher",r.UseFetcher="useFetcher",r.useViewTransitionState="useViewTransitionState"})(Sh||(Sh={}));var Pf;(function(r){r.UseFetcher="useFetcher",r.UseFetchers="useFetchers",r.UseScrollRestoration="useScrollRestoration"})(Pf||(Pf={}));function ky(r){let e=Un.useContext(Uv);return e||Bg(!1),e}function Oy(r,e){let{target:t,replace:n,state:i,preventScrollReset:s,relative:a,viewTransition:o}=e===void 0?{}:e,l=Fg(),c=Su(),d=Mu(r,{relative:a});return Un.useCallback(h=>{if(Sy(h,t)){h.preventDefault();let u=n!==void 0?n:Mf(c)===Mf(d);l(r,{replace:u,state:i,preventScrollReset:s,relative:a,viewTransition:o})}},[c,l,d,n,i,t,r,s,a,o])}function Fy(r){let e=Un.useRef(wh(r)),t=Un.useRef(!1),n=Su(),i=Un.useMemo(()=>My(n.search,t.current?null:e.current),[n.search]),s=Fg(),a=Un.useCallback((o,l)=>{const c=wh(typeof o=="function"?o(i):o);t.current=!0,s("?"+c,l)},[s,i]);return[i,a]}function Uy(r,e){e===void 0&&(e={});let t=Un.useContext(Cy);t==null&&Bg(!1);let{basename:n}=ky(Sh.useViewTransitionState),i=Mu(r,{relative:e.relative});if(!t.isTransitioning)return!1;let s=cc(t.currentLocation.pathname,n)||t.currentLocation.pathname,a=cc(t.nextLocation.pathname,n)||t.nextLocation.pathname;return Ef(i.pathname,a)!=null||Ef(i.pathname,s)!=null}class By{_toastList={top:[],"top-left":[],"top-right":[],bottom:[],"bottom-left":[],"bottom-right":[]};_defaultOptions;observeFunction=null;set toastList(e){const t={...e};this._toastList=t,this.observeFunction?.(t)}get toastList(){return this._toastList}setDefaultOptions(e){this._defaultOptions={...this._defaultOptions,...e}}checkDuplicateToast(e){return this.toastList[e.position].some(t=>t.title===e.title&&t.content===e.content&&t.type===e.type)}deleteToast(e,t){const n=this.toastList[t].filter(i=>i.id!==e);this.toastList={...this.toastList,[t]:n}}resetToastList(){this.toastList={top:[],"top-left":[],"top-right":[],bottom:[],"bottom-left":[],"bottom-right":[]}}openToast({title:e,content:t,type:n,position:i,duration:s}){const a=i||this._defaultOptions.position,o=s||this._defaultOptions.duration,l={id:Bv(),title:e,content:t,type:n,position:a,duration:o};this.checkDuplicateToast(l)||(this.toastList={...this.toastList,[a]:[...this.toastList[a],l]})}observe({observeFunction:e}){this.observeFunction=e}unobserve(){this.observeFunction=null}}const Rf=new By,vN=["red","gray","blue","green","orange","yellow"],yN=["sm","md","lg"],zy=zv("shrink-0 rounded-full",{variants:{size:{sm:"size-1.5",md:"size-2",lg:"size-3"},color:{red:"bg-fg-danger",gray:"bg-fg-subtle",blue:"bg-fg-information",green:"bg-fg-success",orange:"bg-fg-warning",yellow:"bg-fg-caution"}},defaultVariants:{size:"md",color:"green"}}),Hy={red:"var(--color-fg-danger)",gray:"var(--color-fg-subtle)",blue:"var(--color-fg-information)",green:"var(--color-fg-success)",orange:"var(--color-fg-warning)",yellow:"var(--color-fg-caution)"};function gi({className:r,color:e="green",size:t="md"}){const n=Hy[e];return p("div",{"data-slot":"light",className:on(zy({color:e,size:t}),r),style:{boxShadow:`0 0 6px ${n}, 0 0 10px color-mix(in srgb, ${n} 50%, transparent)`}})}/**
|
|
26
26
|
* @license
|
|
27
27
|
* Copyright 2010-2025 Three.js Authors
|
|
28
28
|
* SPDX-License-Identifier: MIT
|
|
29
|
-
*/const vr="174",yr={ROTATE:0,DOLLY:1,PAN:2},Xs={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Gy=0,Nf=1,Vy=2,nb=1,Wy=2,gs=3,xi=0,ci=1,sn=2,Xi=0,ua=1,Mh=2,Df=3,Lf=4,jy=5,pr=100,Xy=101,qy=102,Zy=103,Yy=104,Ky=200,$y=201,Qy=202,Jy=203,Eh=204,Th=205,e0=206,t0=207,n0=208,i0=209,s0=210,r0=211,a0=212,o0=213,l0=214,Ah=0,Ch=1,Ph=2,_a=3,Rh=4,Nh=5,Dh=6,Lh=7,Ec=0,c0=1,d0=2,Ys=0,ib=1,sb=2,rb=3,ab=4,ob=5,lb=6,cb=7,If="attached",h0="detached",db=300,wa=301,Sa=302,uc=303,Ih=304,Tc=306,Pi=1e3,li=1001,fc=1002,Sn=1003,hb=1004,oo=1005,bn=1006,ec=1007,Gi=1008,ws=1009,ub=1010,fb=1011,yo=1012,Iu=1013,Sr=1014,Vi=1015,Ti=1016,ku=1017,Ou=1018,Ma=1020,pb=35902,mb=1021,gb=1022,Zn=1023,bb=1024,vb=1025,fa=1026,Ea=1027,Fu=1028,Uu=1029,yb=1030,Bu=1031,zu=1033,tc=33776,nc=33777,ic=33778,sc=33779,kh=35840,Oh=35841,Fh=35842,Uh=35843,Bh=36196,zh=37492,Hh=37496,Gh=37808,Vh=37809,Wh=37810,jh=37811,Xh=37812,qh=37813,Zh=37814,Yh=37815,Kh=37816,$h=37817,Qh=37818,Jh=37819,eu=37820,tu=37821,rc=36492,nu=36494,iu=36495,xb=36283,su=36284,ru=36285,au=36286,xo=2300,_o=2301,Vc=2302,kf=2400,Of=2401,Ff=2402,u0=2500,f0=0,_b=1,ou=2,p0=3200,wb=3201,Ac=0,m0=1,Ws="",gt="srgb",Kn="srgb-linear",pc="linear",Ht="srgb",kr=7680,fN=7681,pN=517,Uf=519,g0=512,b0=513,v0=514,Sb=515,y0=516,x0=517,_0=518,w0=519,lu=35044,Bf=35048,zf="300 es",ys=2e3,mc=2001;class Cr{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 Hn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Hf=1234567;const pa=Math.PI/180,Ta=180/Math.PI;function Ni(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Hn[r&255]+Hn[r>>8&255]+Hn[r>>16&255]+Hn[r>>24&255]+"-"+Hn[e&255]+Hn[e>>8&255]+"-"+Hn[e>>16&15|64]+Hn[e>>24&255]+"-"+Hn[t&63|128]+Hn[t>>8&255]+"-"+Hn[t>>16&255]+Hn[t>>24&255]+Hn[n&255]+Hn[n>>8&255]+Hn[n>>16&255]+Hn[n>>24&255]).toLowerCase()}function yt(r,e,t){return Math.max(e,Math.min(t,r))}function Hu(r,e){return(r%e+e)%e}function S0(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function M0(r,e,t){return r!==e?(t-r)/(e-r):0}function fo(r,e,t){return(1-t)*r+t*e}function E0(r,e,t,n){return fo(r,e,1-Math.exp(-t*n))}function T0(r,e=1){return e-Math.abs(Hu(r,e*2)-e)}function A0(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function C0(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function P0(r,e){return r+Math.floor(Math.random()*(e-r+1))}function R0(r,e){return r+Math.random()*(e-r)}function N0(r){return r*(.5-Math.random())}function D0(r){r!==void 0&&(Hf=r);let e=Hf+=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 L0(r){return r*pa}function I0(r){return r*Ta}function k0(r){return(r&r-1)===0&&r!==0}function O0(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function F0(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function U0(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 zi(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:pa,RAD2DEG:Ta,generateUUID:Ni,clamp:yt,euclideanModulo:Hu,mapLinear:S0,inverseLerp:M0,lerp:fo,damp:E0,pingpong:T0,smoothstep:A0,smootherstep:C0,randInt:P0,randFloat:R0,randFloatSpread:N0,seededRandom:D0,degToRad:L0,radToDeg:I0,isPowerOfTwo:k0,ceilPowerOfTwo:O0,floorPowerOfTwo:F0,setQuaternionFromProperEuler:U0,normalize:Gt,denormalize:zi};class ge{constructor(e=0,t=0){ge.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],v=i[0],g=i[3],b=i[6],y=i[1],w=i[4],_=i[7],R=i[2],T=i[5],P=i[8];return s[0]=a*v+o*y+l*R,s[3]=a*g+o*w+l*T,s[6]=a*b+o*_+l*P,s[1]=c*v+d*y+h*R,s[4]=c*g+d*w+h*T,s[7]=c*b+d*_+h*P,s[2]=u*v+f*y+m*R,s[5]=u*g+f*w+m*T,s[8]=u*b+f*_+m*P,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 v=1/m;return e[0]=h*v,e[1]=(i*c-d*n)*v,e[2]=(o*n-i*a)*v,e[3]=u*v,e[4]=(d*t-i*l)*v,e[5]=(i*s-o*t)*v,e[6]=f*v,e[7]=(n*l-c*t)*v,e[8]=(a*t-n*s)*v,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(Wc.makeScale(e,t)),this}rotate(e){return this.premultiply(Wc.makeRotation(-e)),this}translate(e,t){return this.premultiply(Wc.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 Wc=new xt;function Mb(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function wo(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function B0(){const r=wo("canvas");return r.style.display="block",r}const Gf={};function hr(r){r in Gf||(Gf[r]=!0,console.warn(r))}function z0(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 H0(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 G0(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 Vf=new xt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Wf=new xt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function V0(){const r={enabled:!0,workingColorSpace:Kn,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Ht&&(i.r=_s(i.r),i.g=_s(i.g),i.b=_s(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=ma(i.r),i.g=ma(i.g),i.b=ma(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===Ws?pc: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({[Kn]:{primaries:e,whitePoint:n,transfer:pc,toXYZ:Vf,fromXYZ:Wf,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:gt},outputColorSpaceConfig:{drawingBufferColorSpace:gt}},[gt]:{primaries:e,whitePoint:n,transfer:Ht,toXYZ:Vf,fromXYZ:Wf,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:gt}}}),r}const dt=V0();function _s(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function ma(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Or;class W0{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Or===void 0&&(Or=wo("canvas")),Or.width=e.width,Or.height=e.height;const n=Or.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Or}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=wo("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]=_s(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(_s(t[n]/255)*255):t[n]=_s(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 j0=0;class Gu{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:j0++}),this.uuid=Ni(),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(jc(i[a].image)):s.push(jc(i[a]))}else s=jc(i);n.url=s}return t||(e.images[this.uuid]=n),n}}function jc(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?W0.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 X0=0;class Bt extends Cr{constructor(e=Bt.DEFAULT_IMAGE,t=Bt.DEFAULT_MAPPING,n=li,i=li,s=bn,a=Gi,o=Zn,l=ws,c=Bt.DEFAULT_ANISOTROPY,d=Ws){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:X0++}),this.uuid=Ni(),this.name="",this.source=new Gu(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 ge(0,0),this.repeat=new ge(1,1),this.center=new ge(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!==db)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Pi:e.x=e.x-Math.floor(e.x);break;case li:e.x=e.x<0?0:1;break;case fc: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 Pi:e.y=e.y-Math.floor(e.y);break;case li:e.y=e.y<0?0:1;break;case fc: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++}}Bt.DEFAULT_IMAGE=null;Bt.DEFAULT_MAPPING=db;Bt.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],v=l[2],g=l[6],b=l[10];if(Math.abs(d-u)<.01&&Math.abs(h-v)<.01&&Math.abs(m-g)<.01){if(Math.abs(d+u)<.1&&Math.abs(h+v)<.1&&Math.abs(m+g)<.1&&Math.abs(c+f+b-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(c+1)/2,_=(f+1)/2,R=(b+1)/2,T=(d+u)/4,P=(h+v)/4,M=(m+g)/4;return w>_&&w>R?w<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(w),i=T/n,s=P/n):_>R?_<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(_),n=T/i,s=M/i):R<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(R),n=P/s,i=M/s),this.set(n,i,s,t),this}let y=Math.sqrt((g-m)*(g-m)+(h-v)*(h-v)+(u-d)*(u-d));return Math.abs(y)<.001&&(y=1),this.x=(g-m)/y,this.y=(h-v)/y,this.z=(u-d)/y,this.w=Math.acos((c+f+b-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 q0 extends Cr{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 Bt(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 Gu(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 ti extends q0{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Eb extends Bt{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=li,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Z0 extends Bt{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=li,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Dt{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],v=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]=v;return}if(h!==v||l!==u||c!==f||d!==m){let g=1-o;const b=l*u+c*f+d*m+h*v,y=b>=0?1:-1,w=1-b*b;if(w>Number.EPSILON){const R=Math.sqrt(w),T=Math.atan2(R,b*y);g=Math.sin(g*T)/R,o=Math.sin(o*T)/R}const _=o*y;if(l=l*g+u*_,c=c*g+f*_,d=d*g+m*_,h=h*g+v*_,g===1-o){const R=1/Math.sqrt(l*l+c*c+d*d+h*h);l*=R,c*=R,d*=R,h*=R}}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 L{constructor(e=0,t=0,n=0){L.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(jf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(jf.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 Xc.copy(this).projectOnVector(e),this.sub(Xc)}reflect(e){return this.sub(Xc.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 Xc=new L,jf=new Dt;class ln{constructor(e=new L(1/0,1/0,1/0),t=new L(-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(Ii.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ii.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=Ii.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,Ii):Ii.fromBufferAttribute(s,a),Ii.applyMatrix4(e.matrixWorld),this.expandByPoint(Ii);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Wo.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Wo.copy(n.boundingBox)),Wo.applyMatrix4(e.matrixWorld),this.union(Wo)}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,Ii),Ii.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(Ha),jo.subVectors(this.max,Ha),Fr.subVectors(e.a,Ha),Ur.subVectors(e.b,Ha),Br.subVectors(e.c,Ha),Ps.subVectors(Ur,Fr),Rs.subVectors(Br,Ur),tr.subVectors(Fr,Br);let t=[0,-Ps.z,Ps.y,0,-Rs.z,Rs.y,0,-tr.z,tr.y,Ps.z,0,-Ps.x,Rs.z,0,-Rs.x,tr.z,0,-tr.x,-Ps.y,Ps.x,0,-Rs.y,Rs.x,0,-tr.y,tr.x,0];return!qc(t,Fr,Ur,Br,jo)||(t=[1,0,0,0,1,0,0,0,1],!qc(t,Fr,Ur,Br,jo))?!1:(Xo.crossVectors(Ps,Rs),t=[Xo.x,Xo.y,Xo.z],qc(t,Fr,Ur,Br,jo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ii).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ii).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:(ls[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ls[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ls[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ls[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ls[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ls[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ls[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ls[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ls),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 ls=[new L,new L,new L,new L,new L,new L,new L,new L],Ii=new L,Wo=new ln,Fr=new L,Ur=new L,Br=new L,Ps=new L,Rs=new L,tr=new L,Ha=new L,jo=new L,Xo=new L,nr=new L;function qc(r,e,t,n,i){for(let s=0,a=r.length-3;s<=a;s+=3){nr.fromArray(r,s);const o=i.x*Math.abs(nr.x)+i.y*Math.abs(nr.y)+i.z*Math.abs(nr.z),l=e.dot(nr),c=t.dot(nr),d=n.dot(nr);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>o)return!1}return!0}const Y0=new ln,Ga=new L,Zc=new L;class ni{constructor(e=new L,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):Y0.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;Ga.subVectors(e,this.center);const t=Ga.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Ga,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):(Zc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ga.copy(e.center).add(Zc)),this.expandByPoint(Ga.copy(e.center).sub(Zc))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const cs=new L,Yc=new L,qo=new L,Ns=new L,Kc=new L,Zo=new L,$c=new L;class Ra{constructor(e=new L,t=new L(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,cs)),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=cs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(cs.copy(this.origin).addScaledVector(this.direction,t),cs.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Yc.copy(e).add(t).multiplyScalar(.5),qo.copy(t).sub(e).normalize(),Ns.copy(this.origin).sub(Yc);const s=e.distanceTo(t)*.5,a=-this.direction.dot(qo),o=Ns.dot(this.direction),l=-Ns.dot(qo),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 v=1/d;h*=v,u*=v,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(Yc).addScaledVector(qo,u),f}intersectSphere(e,t){cs.subVectors(e.center,this.origin);const n=cs.dot(this.direction),i=cs.dot(cs)-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,cs)!==null}intersectTriangle(e,t,n,i,s){Kc.subVectors(t,e),Zo.subVectors(n,e),$c.crossVectors(Kc,Zo);let a=this.direction.dot($c),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(Zo.crossVectors(Ns,Zo));if(l<0)return null;const c=o*this.direction.dot(Kc.cross(Ns));if(c<0||l+c>a)return null;const d=-o*Ns.dot($c);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 ke{constructor(e,t,n,i,s,a,o,l,c,d,h,u,f,m,v,g){ke.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,v,g)}set(e,t,n,i,s,a,o,l,c,d,h,u,f,m,v,g){const b=this.elements;return b[0]=e,b[4]=t,b[8]=n,b[12]=i,b[1]=s,b[5]=a,b[9]=o,b[13]=l,b[2]=c,b[6]=d,b[10]=h,b[14]=u,b[3]=f,b[7]=m,b[11]=v,b[15]=g,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 ke().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/zr.setFromMatrixColumn(e,0).length(),s=1/zr.setFromMatrixColumn(e,1).length(),a=1/zr.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,v=o*h;t[0]=l*d,t[4]=-l*h,t[8]=c,t[1]=f+m*c,t[5]=u-v*c,t[9]=-o*l,t[2]=v-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,v=c*h;t[0]=u+v*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]=v+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*d,f=l*h,m=c*d,v=c*h;t[0]=u-v*o,t[4]=-a*h,t[8]=m+f*o,t[1]=f+m*o,t[5]=a*d,t[9]=v-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,v=o*h;t[0]=l*d,t[4]=m*c-f,t[8]=u*c+v,t[1]=l*h,t[5]=v*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,v=o*c;t[0]=l*d,t[4]=v-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-v*h}else if(e.order==="XZY"){const u=a*l,f=a*c,m=o*l,v=o*c;t[0]=l*d,t[4]=-h,t[8]=c*d,t[1]=u*h+v,t[5]=a*d,t[9]=f*h-m,t[2]=m*h-f,t[6]=o*d,t[10]=v*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(K0,e,$0)}lookAt(e,t,n){const i=this.elements;return hi.subVectors(e,t),hi.lengthSq()===0&&(hi.z=1),hi.normalize(),Ds.crossVectors(n,hi),Ds.lengthSq()===0&&(Math.abs(n.z)===1?hi.x+=1e-4:hi.z+=1e-4,hi.normalize(),Ds.crossVectors(n,hi)),Ds.normalize(),Yo.crossVectors(hi,Ds),i[0]=Ds.x,i[4]=Yo.x,i[8]=hi.x,i[1]=Ds.y,i[5]=Yo.y,i[9]=hi.y,i[2]=Ds.z,i[6]=Yo.z,i[10]=hi.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],v=n[6],g=n[10],b=n[14],y=n[3],w=n[7],_=n[11],R=n[15],T=i[0],P=i[4],M=i[8],x=i[12],S=i[1],C=i[5],k=i[9],I=i[13],G=i[2],q=i[6],O=i[10],W=i[14],Z=i[3],K=i[7],oe=i[11],te=i[15];return s[0]=a*T+o*S+l*G+c*Z,s[4]=a*P+o*C+l*q+c*K,s[8]=a*M+o*k+l*O+c*oe,s[12]=a*x+o*I+l*W+c*te,s[1]=d*T+h*S+u*G+f*Z,s[5]=d*P+h*C+u*q+f*K,s[9]=d*M+h*k+u*O+f*oe,s[13]=d*x+h*I+u*W+f*te,s[2]=m*T+v*S+g*G+b*Z,s[6]=m*P+v*C+g*q+b*K,s[10]=m*M+v*k+g*O+b*oe,s[14]=m*x+v*I+g*W+b*te,s[3]=y*T+w*S+_*G+R*Z,s[7]=y*P+w*C+_*q+R*K,s[11]=y*M+w*k+_*O+R*oe,s[15]=y*x+w*I+_*W+R*te,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],v=e[7],g=e[11],b=e[15];return m*(+s*l*h-i*c*h-s*o*u+n*c*u+i*o*f-n*l*f)+v*(+t*l*f-t*c*u+s*a*u-i*a*f+i*c*d-s*l*d)+g*(+t*c*h-t*o*f-s*a*h+n*a*f+s*o*d-n*c*d)+b*(-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],v=e[13],g=e[14],b=e[15],y=h*g*c-v*u*c+v*l*f-o*g*f-h*l*b+o*u*b,w=m*u*c-d*g*c-m*l*f+a*g*f+d*l*b-a*u*b,_=d*v*c-m*h*c+m*o*f-a*v*f-d*o*b+a*h*b,R=m*h*l-d*v*l-m*o*u+a*v*u+d*o*g-a*h*g,T=t*y+n*w+i*_+s*R;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/T;return e[0]=y*P,e[1]=(v*u*s-h*g*s-v*i*f+n*g*f+h*i*b-n*u*b)*P,e[2]=(o*g*s-v*l*s+v*i*c-n*g*c-o*i*b+n*l*b)*P,e[3]=(h*l*s-o*u*s-h*i*c+n*u*c+o*i*f-n*l*f)*P,e[4]=w*P,e[5]=(d*g*s-m*u*s+m*i*f-t*g*f-d*i*b+t*u*b)*P,e[6]=(m*l*s-a*g*s-m*i*c+t*g*c+a*i*b-t*l*b)*P,e[7]=(a*u*s-d*l*s+d*i*c-t*u*c-a*i*f+t*l*f)*P,e[8]=_*P,e[9]=(m*h*s-d*v*s-m*n*f+t*v*f+d*n*b-t*h*b)*P,e[10]=(a*v*s-m*o*s+m*n*c-t*v*c-a*n*b+t*o*b)*P,e[11]=(d*o*s-a*h*s-d*n*c+t*h*c+a*n*f-t*o*f)*P,e[12]=R*P,e[13]=(d*v*i-m*h*i+m*n*u-t*v*u-d*n*g+t*h*g)*P,e[14]=(m*o*i-a*v*i-m*n*l+t*v*l+a*n*g-t*o*g)*P,e[15]=(a*h*i-d*o*i+d*n*l-t*h*l-a*n*u+t*o*u)*P,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,v=a*d,g=a*h,b=o*h,y=l*c,w=l*d,_=l*h,R=n.x,T=n.y,P=n.z;return i[0]=(1-(v+b))*R,i[1]=(f+_)*R,i[2]=(m-w)*R,i[3]=0,i[4]=(f-_)*T,i[5]=(1-(u+b))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(m+w)*P,i[9]=(g-y)*P,i[10]=(1-(u+v))*P,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=zr.set(i[0],i[1],i[2]).length();const a=zr.set(i[4],i[5],i[6]).length(),o=zr.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],ki.copy(this);const c=1/s,d=1/a,h=1/o;return ki.elements[0]*=c,ki.elements[1]*=c,ki.elements[2]*=c,ki.elements[4]*=d,ki.elements[5]*=d,ki.elements[6]*=d,ki.elements[8]*=h,ki.elements[9]*=h,ki.elements[10]*=h,t.setFromRotationMatrix(ki),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=ys){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===ys)f=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===mc)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=ys){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,v;if(o===ys)m=(a+s)*h,v=-2*h;else if(o===mc)m=s*h,v=-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]=v,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 zr=new L,ki=new ke,K0=new L(0,0,0),$0=new L(1,1,1),Ds=new L,Yo=new L,hi=new L,Xf=new ke,qf=new Dt;class dn{constructor(e=0,t=0,n=0,i=dn.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 Xf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Xf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return qf.setFromEuler(this),this.setFromQuaternion(qf,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}}dn.DEFAULT_ORDER="XYZ";class Vu{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 Q0=0;const Zf=new L,Hr=new Dt,ds=new ke,Ko=new L,Va=new L,J0=new L,ex=new Dt,Yf=new L(1,0,0),Kf=new L(0,1,0),$f=new L(0,0,1),Qf={type:"added"},tx={type:"removed"},Gr={type:"childadded",child:null},Qc={type:"childremoved",child:null};class Pt extends Cr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Q0++}),this.uuid=Ni(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pt.DEFAULT_UP.clone();const e=new L,t=new dn,n=new Dt,i=new L(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 ke},normalMatrix:{value:new xt}}),this.matrix=new ke,this.matrixWorld=new ke,this.matrixAutoUpdate=Pt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Vu,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 Hr.setFromAxisAngle(e,t),this.quaternion.multiply(Hr),this}rotateOnWorldAxis(e,t){return Hr.setFromAxisAngle(e,t),this.quaternion.premultiply(Hr),this}rotateX(e){return this.rotateOnAxis(Yf,e)}rotateY(e){return this.rotateOnAxis(Kf,e)}rotateZ(e){return this.rotateOnAxis($f,e)}translateOnAxis(e,t){return Zf.copy(e).applyQuaternion(this.quaternion),this.position.add(Zf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Yf,e)}translateY(e){return this.translateOnAxis(Kf,e)}translateZ(e){return this.translateOnAxis($f,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ds.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ko.copy(e):Ko.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Va.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ds.lookAt(Va,Ko,this.up):ds.lookAt(Ko,Va,this.up),this.quaternion.setFromRotationMatrix(ds),i&&(ds.extractRotation(i.matrixWorld),Hr.setFromRotationMatrix(ds),this.quaternion.premultiply(Hr.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(Qf),Gr.child=e,this.dispatchEvent(Gr),Gr.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(tx),Qc.child=e,this.dispatchEvent(Qc),Qc.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),ds.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ds.multiply(e.parent.matrixWorld)),e.applyMatrix4(ds),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Qf),Gr.child=e,this.dispatchEvent(Gr),Gr.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(Va,e,J0),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Va,ex,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 L(0,1,0);Pt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Oi=new L,hs=new L,Jc=new L,us=new L,Vr=new L,Wr=new L,Jf=new L,ed=new L,td=new L,nd=new L,id=new _t,sd=new _t,rd=new _t;class bi{constructor(e=new L,t=new L,n=new L){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Oi.subVectors(e,t),i.cross(Oi);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){Oi.subVectors(i,t),hs.subVectors(n,t),Jc.subVectors(e,t);const a=Oi.dot(Oi),o=Oi.dot(hs),l=Oi.dot(Jc),c=hs.dot(hs),d=hs.dot(Jc),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,us)===null?!1:us.x>=0&&us.y>=0&&us.x+us.y<=1}static getInterpolation(e,t,n,i,s,a,o,l){return this.getBarycoord(e,t,n,i,us)===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,us.x),l.addScaledVector(a,us.y),l.addScaledVector(o,us.z),l)}static getInterpolatedAttribute(e,t,n,i,s,a){return id.setScalar(0),sd.setScalar(0),rd.setScalar(0),id.fromBufferAttribute(e,t),sd.fromBufferAttribute(e,n),rd.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(id,s.x),a.addScaledVector(sd,s.y),a.addScaledVector(rd,s.z),a}static isFrontFacing(e,t,n,i){return Oi.subVectors(n,t),hs.subVectors(e,t),Oi.cross(hs).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 Oi.subVectors(this.c,this.b),hs.subVectors(this.a,this.b),Oi.cross(hs).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return bi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return bi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return bi.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return bi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return bi.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;Vr.subVectors(i,n),Wr.subVectors(s,n),ed.subVectors(e,n);const l=Vr.dot(ed),c=Wr.dot(ed);if(l<=0&&c<=0)return t.copy(n);td.subVectors(e,i);const d=Vr.dot(td),h=Wr.dot(td);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(Vr,a);nd.subVectors(e,s);const f=Vr.dot(nd),m=Wr.dot(nd);if(m>=0&&f<=m)return t.copy(s);const v=f*c-l*m;if(v<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(n).addScaledVector(Wr,o);const g=d*m-f*h;if(g<=0&&h-d>=0&&f-m>=0)return Jf.subVectors(s,i),o=(h-d)/(h-d+(f-m)),t.copy(i).addScaledVector(Jf,o);const b=1/(g+v+u);return a=v*b,o=u*b,t.copy(n).addScaledVector(Vr,a).addScaledVector(Wr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Tb={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},$o={h:0,s:0,l:0};function ad(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 Le{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,dt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=dt.workingColorSpace){return this.r=e,this.g=t,this.b=n,dt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=dt.workingColorSpace){if(e=Hu(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=ad(a,s,e+1/3),this.g=ad(a,s,e),this.b=ad(a,s,e-1/3)}return dt.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=Tb[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=_s(e.r),this.g=_s(e.g),this.b=_s(e.b),this}copyLinearToSRGB(e){return this.r=ma(e.r),this.g=ma(e.g),this.b=ma(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=gt){return dt.fromWorkingColorSpace(Gn.copy(this),e),Math.round(yt(Gn.r*255,0,255))*65536+Math.round(yt(Gn.g*255,0,255))*256+Math.round(yt(Gn.b*255,0,255))}getHexString(e=gt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=dt.workingColorSpace){dt.fromWorkingColorSpace(Gn.copy(this),t);const n=Gn.r,i=Gn.g,s=Gn.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=dt.workingColorSpace){return dt.fromWorkingColorSpace(Gn.copy(this),t),e.r=Gn.r,e.g=Gn.g,e.b=Gn.b,e}getStyle(e=gt){dt.fromWorkingColorSpace(Gn.copy(this),e);const t=Gn.r,n=Gn.g,i=Gn.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($o);const n=fo(Ls.h,$o.h,t),i=fo(Ls.s,$o.s,t),s=fo(Ls.l,$o.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 Gn=new Le;Le.NAMES=Tb;let nx=0;class yi extends Cr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:nx++}),this.uuid=Ni(),this.name="",this.type="Material",this.blending=ua,this.side=xi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Eh,this.blendDst=Th,this.blendEquation=pr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Le(0,0,0),this.blendAlpha=0,this.depthFunc=_a,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Uf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=kr,this.stencilZFail=kr,this.stencilZPass=kr,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!==ua&&(n.blending=this.blending),this.side!==xi&&(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!==Eh&&(n.blendSrc=this.blendSrc),this.blendDst!==Th&&(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!==_a&&(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!==Uf&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==kr&&(n.stencilFail=this.stencilFail),this.stencilZFail!==kr&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==kr&&(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 yi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Le(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 dn,this.combine=Ec,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 mn=new L,Qo=new ge;let ix=0;class vn{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:ix++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=lu,this.updateRanges=[],this.gpuType=Vi,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++)Qo.fromBufferAttribute(this,t),Qo.applyMatrix3(e),this.setXY(t,Qo.x,Qo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)mn.fromBufferAttribute(this,t),mn.applyMatrix3(e),this.setXYZ(t,mn.x,mn.y,mn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)mn.fromBufferAttribute(this,t),mn.applyMatrix4(e),this.setXYZ(t,mn.x,mn.y,mn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)mn.fromBufferAttribute(this,t),mn.applyNormalMatrix(e),this.setXYZ(t,mn.x,mn.y,mn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)mn.fromBufferAttribute(this,t),mn.transformDirection(e),this.setXYZ(t,mn.x,mn.y,mn.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=zi(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=zi(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=zi(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=zi(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=zi(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!==lu&&(e.usage=this.usage),e}}class Wu extends vn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class ju extends vn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Fe extends vn{constructor(e,t,n){super(new Float32Array(e),t,n)}}let sx=0;const _i=new ke,od=new Pt,jr=new L,ui=new ln,Wa=new ln,Cn=new L;class mt extends Cr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:sx++}),this.uuid=Ni(),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(Mb(e)?ju:Wu)(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 _i.makeRotationFromQuaternion(e),this.applyMatrix4(_i),this}rotateX(e){return _i.makeRotationX(e),this.applyMatrix4(_i),this}rotateY(e){return _i.makeRotationY(e),this.applyMatrix4(_i),this}rotateZ(e){return _i.makeRotationZ(e),this.applyMatrix4(_i),this}translate(e,t,n){return _i.makeTranslation(e,t,n),this.applyMatrix4(_i),this}scale(e,t,n){return _i.makeScale(e,t,n),this.applyMatrix4(_i),this}lookAt(e){return od.lookAt(e),od.updateMatrix(),this.applyMatrix4(od.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(jr).negate(),this.translate(jr.x,jr.y,jr.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 Fe(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 ln);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 L(-1/0,-1/0,-1/0),new L(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];ui.setFromBufferAttribute(s),this.morphTargetsRelative?(Cn.addVectors(this.boundingBox.min,ui.min),this.boundingBox.expandByPoint(Cn),Cn.addVectors(this.boundingBox.max,ui.max),this.boundingBox.expandByPoint(Cn)):(this.boundingBox.expandByPoint(ui.min),this.boundingBox.expandByPoint(ui.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 ni);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 L,1/0);return}if(e){const n=this.boundingSphere.center;if(ui.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Wa.setFromBufferAttribute(o),this.morphTargetsRelative?(Cn.addVectors(ui.min,Wa.min),ui.expandByPoint(Cn),Cn.addVectors(ui.max,Wa.max),ui.expandByPoint(Cn)):(ui.expandByPoint(Wa.min),ui.expandByPoint(Wa.max))}ui.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&&(jr.fromBufferAttribute(e,c),Cn.add(jr)),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 vn(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let M=0;M<n.count;M++)o[M]=new L,l[M]=new L;const c=new L,d=new L,h=new L,u=new ge,f=new ge,m=new ge,v=new L,g=new L;function b(M,x,S){c.fromBufferAttribute(n,M),d.fromBufferAttribute(n,x),h.fromBufferAttribute(n,S),u.fromBufferAttribute(s,M),f.fromBufferAttribute(s,x),m.fromBufferAttribute(s,S),d.sub(c),h.sub(c),f.sub(u),m.sub(u);const C=1/(f.x*m.y-m.x*f.y);isFinite(C)&&(v.copy(d).multiplyScalar(m.y).addScaledVector(h,-f.y).multiplyScalar(C),g.copy(h).multiplyScalar(f.x).addScaledVector(d,-m.x).multiplyScalar(C),o[M].add(v),o[x].add(v),o[S].add(v),l[M].add(g),l[x].add(g),l[S].add(g))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let M=0,x=y.length;M<x;++M){const S=y[M],C=S.start,k=S.count;for(let I=C,G=C+k;I<G;I+=3)b(e.getX(I+0),e.getX(I+1),e.getX(I+2))}const w=new L,_=new L,R=new L,T=new L;function P(M){R.fromBufferAttribute(i,M),T.copy(R);const x=o[M];w.copy(x),w.sub(R.multiplyScalar(R.dot(x))).normalize(),_.crossVectors(T,x);const C=_.dot(l[M])<0?-1:1;a.setXYZW(M,w.x,w.y,w.z,C)}for(let M=0,x=y.length;M<x;++M){const S=y[M],C=S.start,k=S.count;for(let I=C,G=C+k;I<G;I+=3)P(e.getX(I+0)),P(e.getX(I+1)),P(e.getX(I+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 vn(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 L,s=new L,a=new L,o=new L,l=new L,c=new L,d=new L,h=new L;if(e)for(let u=0,f=e.count;u<f;u+=3){const m=e.getX(u+0),v=e.getX(u+1),g=e.getX(u+2);i.fromBufferAttribute(t,m),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,g),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),o.fromBufferAttribute(n,m),l.fromBufferAttribute(n,v),c.fromBufferAttribute(n,g),o.add(d),l.add(d),c.add(d),n.setXYZ(m,o.x,o.y,o.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(g,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 v=0,g=l.length;v<g;v++){o.isInterleavedBufferAttribute?f=l[v]*o.data.stride+o.offset:f=l[v]*d;for(let b=0;b<d;b++)u[m++]=c[f++]}return new vn(u,d,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new mt,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 ep=new ke,ir=new Ra,Jo=new ni,tp=new L,el=new L,tl=new L,nl=new L,ld=new L,il=new L,np=new L,sl=new L;class Ae extends Pt{constructor(e=new mt,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){il.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const d=o[l],h=s[l];d!==0&&(ld.fromBufferAttribute(h,e),a?il.addScaledVector(ld,d):il.addScaledVector(ld.sub(t),d))}t.add(il)}return t}raycast(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Jo.copy(n.boundingSphere),Jo.applyMatrix4(s),ir.copy(e.ray).recast(e.near),!(Jo.containsPoint(ir.origin)===!1&&(ir.intersectSphere(Jo,tp)===null||ir.origin.distanceToSquared(tp)>(e.far-e.near)**2))&&(ep.copy(s).invert(),ir.copy(e.ray).applyMatrix4(ep),!(n.boundingBox!==null&&ir.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ir)))}_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,v=u.length;m<v;m++){const g=u[m],b=a[g.materialIndex],y=Math.max(g.start,f.start),w=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let _=y,R=w;_<R;_+=3){const T=o.getX(_),P=o.getX(_+1),M=o.getX(_+2);i=rl(this,b,e,n,c,d,h,T,P,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const m=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let g=m,b=v;g<b;g+=3){const y=o.getX(g),w=o.getX(g+1),_=o.getX(g+2);i=rl(this,a,e,n,c,d,h,y,w,_),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,v=u.length;m<v;m++){const g=u[m],b=a[g.materialIndex],y=Math.max(g.start,f.start),w=Math.min(l.count,Math.min(g.start+g.count,f.start+f.count));for(let _=y,R=w;_<R;_+=3){const T=_,P=_+1,M=_+2;i=rl(this,b,e,n,c,d,h,T,P,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const m=Math.max(0,f.start),v=Math.min(l.count,f.start+f.count);for(let g=m,b=v;g<b;g+=3){const y=g,w=g+1,_=g+2;i=rl(this,a,e,n,c,d,h,y,w,_),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}}}function rx(r,e,t,n,i,s,a,o){let l;if(e.side===ci?l=n.intersectTriangle(a,s,i,!0,o):l=n.intersectTriangle(i,s,a,e.side===xi,o),l===null)return null;sl.copy(o),sl.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(sl);return c<t.near||c>t.far?null:{distance:c,point:sl.clone(),object:r}}function rl(r,e,t,n,i,s,a,o,l,c){r.getVertexPosition(o,el),r.getVertexPosition(l,tl),r.getVertexPosition(c,nl);const d=rx(r,e,t,n,el,tl,nl,np);if(d){const h=new L;bi.getBarycoord(np,el,tl,nl,h),i&&(d.uv=bi.getInterpolatedAttribute(i,o,l,c,h,new ge)),s&&(d.uv1=bi.getInterpolatedAttribute(s,o,l,c,h,new ge)),a&&(d.normal=bi.getInterpolatedAttribute(a,o,l,c,h,new L),d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new L,materialIndex:0};bi.getNormal(el,tl,nl,u.normal),d.face=u,d.barycoord=h}return d}class Kt extends mt{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 Fe(c,3)),this.setAttribute("normal",new Fe(d,3)),this.setAttribute("uv",new Fe(h,2));function m(v,g,b,y,w,_,R,T,P,M,x){const S=_/P,C=R/M,k=_/2,I=R/2,G=T/2,q=P+1,O=M+1;let W=0,Z=0;const K=new L;for(let oe=0;oe<O;oe++){const te=oe*C-I;for(let ve=0;ve<q;ve++){const ce=ve*S-k;K[v]=ce*y,K[g]=te*w,K[b]=G,c.push(K.x,K.y,K.z),K[v]=0,K[g]=0,K[b]=T>0?1:-1,d.push(K.x,K.y,K.z),h.push(ve/P),h.push(1-oe/M),W+=1}}for(let oe=0;oe<M;oe++)for(let te=0;te<P;te++){const ve=u+te+q*oe,ce=u+te+q*(oe+1),Q=u+(te+1)+q*(oe+1),re=u+(te+1)+q*oe;l.push(ve,ce,re),l.push(ce,Q,re),Z+=6}o.addGroup(f,Z,x),f+=Z,u+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kt(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Aa(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 Jn(r){const e={};for(let t=0;t<r.length;t++){const n=Aa(r[t]);for(const i in n)e[i]=n[i]}return e}function ax(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function Ab(r){const e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:dt.workingColorSpace}const Na={clone:Aa,merge:Jn};var ox=`void main() {
|
|
29
|
+
*/const vr="174",yr={ROTATE:0,DOLLY:1,PAN:2},Xs={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Gy=0,Nf=1,Vy=2,nb=1,Wy=2,gs=3,xi=0,ci=1,sn=2,Xi=0,ua=1,Mh=2,Df=3,Lf=4,jy=5,pr=100,Xy=101,qy=102,Zy=103,Yy=104,Ky=200,$y=201,Qy=202,Jy=203,Eh=204,Th=205,e0=206,t0=207,n0=208,i0=209,s0=210,r0=211,a0=212,o0=213,l0=214,Ah=0,Ch=1,Ph=2,_a=3,Rh=4,Nh=5,Dh=6,Lh=7,Ec=0,c0=1,d0=2,Ys=0,ib=1,sb=2,rb=3,ab=4,ob=5,lb=6,cb=7,If="attached",h0="detached",db=300,wa=301,Sa=302,uc=303,Ih=304,Tc=306,Pi=1e3,li=1001,fc=1002,Sn=1003,hb=1004,oo=1005,bn=1006,ec=1007,Gi=1008,ws=1009,ub=1010,fb=1011,yo=1012,Iu=1013,Sr=1014,Vi=1015,Ti=1016,ku=1017,Ou=1018,Ma=1020,pb=35902,mb=1021,gb=1022,Zn=1023,bb=1024,vb=1025,fa=1026,Ea=1027,Fu=1028,Uu=1029,yb=1030,Bu=1031,zu=1033,tc=33776,nc=33777,ic=33778,sc=33779,kh=35840,Oh=35841,Fh=35842,Uh=35843,Bh=36196,zh=37492,Hh=37496,Gh=37808,Vh=37809,Wh=37810,jh=37811,Xh=37812,qh=37813,Zh=37814,Yh=37815,Kh=37816,$h=37817,Qh=37818,Jh=37819,eu=37820,tu=37821,rc=36492,nu=36494,iu=36495,xb=36283,su=36284,ru=36285,au=36286,xo=2300,_o=2301,Vc=2302,kf=2400,Of=2401,Ff=2402,u0=2500,f0=0,_b=1,ou=2,p0=3200,wb=3201,Ac=0,m0=1,Ws="",gt="srgb",Kn="srgb-linear",pc="linear",Ht="srgb",kr=7680,xN=7681,_N=517,Uf=519,g0=512,b0=513,v0=514,Sb=515,y0=516,x0=517,_0=518,w0=519,lu=35044,Bf=35048,zf="300 es",ys=2e3,mc=2001;class Cr{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 Hn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Hf=1234567;const pa=Math.PI/180,Ta=180/Math.PI;function Ni(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Hn[r&255]+Hn[r>>8&255]+Hn[r>>16&255]+Hn[r>>24&255]+"-"+Hn[e&255]+Hn[e>>8&255]+"-"+Hn[e>>16&15|64]+Hn[e>>24&255]+"-"+Hn[t&63|128]+Hn[t>>8&255]+"-"+Hn[t>>16&255]+Hn[t>>24&255]+Hn[n&255]+Hn[n>>8&255]+Hn[n>>16&255]+Hn[n>>24&255]).toLowerCase()}function yt(r,e,t){return Math.max(e,Math.min(t,r))}function Hu(r,e){return(r%e+e)%e}function S0(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function M0(r,e,t){return r!==e?(t-r)/(e-r):0}function fo(r,e,t){return(1-t)*r+t*e}function E0(r,e,t,n){return fo(r,e,1-Math.exp(-t*n))}function T0(r,e=1){return e-Math.abs(Hu(r,e*2)-e)}function A0(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function C0(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function P0(r,e){return r+Math.floor(Math.random()*(e-r+1))}function R0(r,e){return r+Math.random()*(e-r)}function N0(r){return r*(.5-Math.random())}function D0(r){r!==void 0&&(Hf=r);let e=Hf+=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 L0(r){return r*pa}function I0(r){return r*Ta}function k0(r){return(r&r-1)===0&&r!==0}function O0(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function F0(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function U0(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 zi(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:pa,RAD2DEG:Ta,generateUUID:Ni,clamp:yt,euclideanModulo:Hu,mapLinear:S0,inverseLerp:M0,lerp:fo,damp:E0,pingpong:T0,smoothstep:A0,smootherstep:C0,randInt:P0,randFloat:R0,randFloatSpread:N0,seededRandom:D0,degToRad:L0,radToDeg:I0,isPowerOfTwo:k0,ceilPowerOfTwo:O0,floorPowerOfTwo:F0,setQuaternionFromProperEuler:U0,normalize:Gt,denormalize:zi};class ge{constructor(e=0,t=0){ge.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],v=i[0],g=i[3],b=i[6],y=i[1],w=i[4],_=i[7],R=i[2],T=i[5],P=i[8];return s[0]=a*v+o*y+l*R,s[3]=a*g+o*w+l*T,s[6]=a*b+o*_+l*P,s[1]=c*v+d*y+h*R,s[4]=c*g+d*w+h*T,s[7]=c*b+d*_+h*P,s[2]=u*v+f*y+m*R,s[5]=u*g+f*w+m*T,s[8]=u*b+f*_+m*P,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 v=1/m;return e[0]=h*v,e[1]=(i*c-d*n)*v,e[2]=(o*n-i*a)*v,e[3]=u*v,e[4]=(d*t-i*l)*v,e[5]=(i*s-o*t)*v,e[6]=f*v,e[7]=(n*l-c*t)*v,e[8]=(a*t-n*s)*v,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(Wc.makeScale(e,t)),this}rotate(e){return this.premultiply(Wc.makeRotation(-e)),this}translate(e,t){return this.premultiply(Wc.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 Wc=new xt;function Mb(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function wo(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function B0(){const r=wo("canvas");return r.style.display="block",r}const Gf={};function hr(r){r in Gf||(Gf[r]=!0,console.warn(r))}function z0(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 H0(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 G0(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 Vf=new xt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Wf=new xt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function V0(){const r={enabled:!0,workingColorSpace:Kn,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Ht&&(i.r=_s(i.r),i.g=_s(i.g),i.b=_s(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=ma(i.r),i.g=ma(i.g),i.b=ma(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===Ws?pc: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({[Kn]:{primaries:e,whitePoint:n,transfer:pc,toXYZ:Vf,fromXYZ:Wf,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:gt},outputColorSpaceConfig:{drawingBufferColorSpace:gt}},[gt]:{primaries:e,whitePoint:n,transfer:Ht,toXYZ:Vf,fromXYZ:Wf,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:gt}}}),r}const dt=V0();function _s(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function ma(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Or;class W0{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Or===void 0&&(Or=wo("canvas")),Or.width=e.width,Or.height=e.height;const n=Or.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Or}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=wo("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]=_s(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(_s(t[n]/255)*255):t[n]=_s(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 j0=0;class Gu{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:j0++}),this.uuid=Ni(),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(jc(i[a].image)):s.push(jc(i[a]))}else s=jc(i);n.url=s}return t||(e.images[this.uuid]=n),n}}function jc(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?W0.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 X0=0;class Bt extends Cr{constructor(e=Bt.DEFAULT_IMAGE,t=Bt.DEFAULT_MAPPING,n=li,i=li,s=bn,a=Gi,o=Zn,l=ws,c=Bt.DEFAULT_ANISOTROPY,d=Ws){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:X0++}),this.uuid=Ni(),this.name="",this.source=new Gu(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 ge(0,0),this.repeat=new ge(1,1),this.center=new ge(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!==db)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Pi:e.x=e.x-Math.floor(e.x);break;case li:e.x=e.x<0?0:1;break;case fc: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 Pi:e.y=e.y-Math.floor(e.y);break;case li:e.y=e.y<0?0:1;break;case fc: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++}}Bt.DEFAULT_IMAGE=null;Bt.DEFAULT_MAPPING=db;Bt.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],v=l[2],g=l[6],b=l[10];if(Math.abs(d-u)<.01&&Math.abs(h-v)<.01&&Math.abs(m-g)<.01){if(Math.abs(d+u)<.1&&Math.abs(h+v)<.1&&Math.abs(m+g)<.1&&Math.abs(c+f+b-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(c+1)/2,_=(f+1)/2,R=(b+1)/2,T=(d+u)/4,P=(h+v)/4,M=(m+g)/4;return w>_&&w>R?w<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(w),i=T/n,s=P/n):_>R?_<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(_),n=T/i,s=M/i):R<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(R),n=P/s,i=M/s),this.set(n,i,s,t),this}let y=Math.sqrt((g-m)*(g-m)+(h-v)*(h-v)+(u-d)*(u-d));return Math.abs(y)<.001&&(y=1),this.x=(g-m)/y,this.y=(h-v)/y,this.z=(u-d)/y,this.w=Math.acos((c+f+b-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 q0 extends Cr{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 Bt(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 Gu(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 ti extends q0{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Eb extends Bt{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=li,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Z0 extends Bt{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=li,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Dt{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],v=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]=v;return}if(h!==v||l!==u||c!==f||d!==m){let g=1-o;const b=l*u+c*f+d*m+h*v,y=b>=0?1:-1,w=1-b*b;if(w>Number.EPSILON){const R=Math.sqrt(w),T=Math.atan2(R,b*y);g=Math.sin(g*T)/R,o=Math.sin(o*T)/R}const _=o*y;if(l=l*g+u*_,c=c*g+f*_,d=d*g+m*_,h=h*g+v*_,g===1-o){const R=1/Math.sqrt(l*l+c*c+d*d+h*h);l*=R,c*=R,d*=R,h*=R}}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 L{constructor(e=0,t=0,n=0){L.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(jf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(jf.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 Xc.copy(this).projectOnVector(e),this.sub(Xc)}reflect(e){return this.sub(Xc.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 Xc=new L,jf=new Dt;class ln{constructor(e=new L(1/0,1/0,1/0),t=new L(-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(Ii.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ii.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=Ii.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,Ii):Ii.fromBufferAttribute(s,a),Ii.applyMatrix4(e.matrixWorld),this.expandByPoint(Ii);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Wo.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Wo.copy(n.boundingBox)),Wo.applyMatrix4(e.matrixWorld),this.union(Wo)}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,Ii),Ii.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(Ha),jo.subVectors(this.max,Ha),Fr.subVectors(e.a,Ha),Ur.subVectors(e.b,Ha),Br.subVectors(e.c,Ha),Ps.subVectors(Ur,Fr),Rs.subVectors(Br,Ur),tr.subVectors(Fr,Br);let t=[0,-Ps.z,Ps.y,0,-Rs.z,Rs.y,0,-tr.z,tr.y,Ps.z,0,-Ps.x,Rs.z,0,-Rs.x,tr.z,0,-tr.x,-Ps.y,Ps.x,0,-Rs.y,Rs.x,0,-tr.y,tr.x,0];return!qc(t,Fr,Ur,Br,jo)||(t=[1,0,0,0,1,0,0,0,1],!qc(t,Fr,Ur,Br,jo))?!1:(Xo.crossVectors(Ps,Rs),t=[Xo.x,Xo.y,Xo.z],qc(t,Fr,Ur,Br,jo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ii).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ii).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:(ls[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ls[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ls[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ls[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ls[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ls[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ls[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ls[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ls),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 ls=[new L,new L,new L,new L,new L,new L,new L,new L],Ii=new L,Wo=new ln,Fr=new L,Ur=new L,Br=new L,Ps=new L,Rs=new L,tr=new L,Ha=new L,jo=new L,Xo=new L,nr=new L;function qc(r,e,t,n,i){for(let s=0,a=r.length-3;s<=a;s+=3){nr.fromArray(r,s);const o=i.x*Math.abs(nr.x)+i.y*Math.abs(nr.y)+i.z*Math.abs(nr.z),l=e.dot(nr),c=t.dot(nr),d=n.dot(nr);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>o)return!1}return!0}const Y0=new ln,Ga=new L,Zc=new L;class ni{constructor(e=new L,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):Y0.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;Ga.subVectors(e,this.center);const t=Ga.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Ga,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):(Zc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ga.copy(e.center).add(Zc)),this.expandByPoint(Ga.copy(e.center).sub(Zc))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const cs=new L,Yc=new L,qo=new L,Ns=new L,Kc=new L,Zo=new L,$c=new L;class Ra{constructor(e=new L,t=new L(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,cs)),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=cs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(cs.copy(this.origin).addScaledVector(this.direction,t),cs.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Yc.copy(e).add(t).multiplyScalar(.5),qo.copy(t).sub(e).normalize(),Ns.copy(this.origin).sub(Yc);const s=e.distanceTo(t)*.5,a=-this.direction.dot(qo),o=Ns.dot(this.direction),l=-Ns.dot(qo),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 v=1/d;h*=v,u*=v,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(Yc).addScaledVector(qo,u),f}intersectSphere(e,t){cs.subVectors(e.center,this.origin);const n=cs.dot(this.direction),i=cs.dot(cs)-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,cs)!==null}intersectTriangle(e,t,n,i,s){Kc.subVectors(t,e),Zo.subVectors(n,e),$c.crossVectors(Kc,Zo);let a=this.direction.dot($c),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(Zo.crossVectors(Ns,Zo));if(l<0)return null;const c=o*this.direction.dot(Kc.cross(Ns));if(c<0||l+c>a)return null;const d=-o*Ns.dot($c);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 ke{constructor(e,t,n,i,s,a,o,l,c,d,h,u,f,m,v,g){ke.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,v,g)}set(e,t,n,i,s,a,o,l,c,d,h,u,f,m,v,g){const b=this.elements;return b[0]=e,b[4]=t,b[8]=n,b[12]=i,b[1]=s,b[5]=a,b[9]=o,b[13]=l,b[2]=c,b[6]=d,b[10]=h,b[14]=u,b[3]=f,b[7]=m,b[11]=v,b[15]=g,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 ke().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/zr.setFromMatrixColumn(e,0).length(),s=1/zr.setFromMatrixColumn(e,1).length(),a=1/zr.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,v=o*h;t[0]=l*d,t[4]=-l*h,t[8]=c,t[1]=f+m*c,t[5]=u-v*c,t[9]=-o*l,t[2]=v-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,v=c*h;t[0]=u+v*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]=v+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*d,f=l*h,m=c*d,v=c*h;t[0]=u-v*o,t[4]=-a*h,t[8]=m+f*o,t[1]=f+m*o,t[5]=a*d,t[9]=v-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,v=o*h;t[0]=l*d,t[4]=m*c-f,t[8]=u*c+v,t[1]=l*h,t[5]=v*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,v=o*c;t[0]=l*d,t[4]=v-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-v*h}else if(e.order==="XZY"){const u=a*l,f=a*c,m=o*l,v=o*c;t[0]=l*d,t[4]=-h,t[8]=c*d,t[1]=u*h+v,t[5]=a*d,t[9]=f*h-m,t[2]=m*h-f,t[6]=o*d,t[10]=v*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(K0,e,$0)}lookAt(e,t,n){const i=this.elements;return hi.subVectors(e,t),hi.lengthSq()===0&&(hi.z=1),hi.normalize(),Ds.crossVectors(n,hi),Ds.lengthSq()===0&&(Math.abs(n.z)===1?hi.x+=1e-4:hi.z+=1e-4,hi.normalize(),Ds.crossVectors(n,hi)),Ds.normalize(),Yo.crossVectors(hi,Ds),i[0]=Ds.x,i[4]=Yo.x,i[8]=hi.x,i[1]=Ds.y,i[5]=Yo.y,i[9]=hi.y,i[2]=Ds.z,i[6]=Yo.z,i[10]=hi.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],v=n[6],g=n[10],b=n[14],y=n[3],w=n[7],_=n[11],R=n[15],T=i[0],P=i[4],M=i[8],x=i[12],S=i[1],C=i[5],k=i[9],I=i[13],G=i[2],q=i[6],O=i[10],W=i[14],Z=i[3],K=i[7],oe=i[11],te=i[15];return s[0]=a*T+o*S+l*G+c*Z,s[4]=a*P+o*C+l*q+c*K,s[8]=a*M+o*k+l*O+c*oe,s[12]=a*x+o*I+l*W+c*te,s[1]=d*T+h*S+u*G+f*Z,s[5]=d*P+h*C+u*q+f*K,s[9]=d*M+h*k+u*O+f*oe,s[13]=d*x+h*I+u*W+f*te,s[2]=m*T+v*S+g*G+b*Z,s[6]=m*P+v*C+g*q+b*K,s[10]=m*M+v*k+g*O+b*oe,s[14]=m*x+v*I+g*W+b*te,s[3]=y*T+w*S+_*G+R*Z,s[7]=y*P+w*C+_*q+R*K,s[11]=y*M+w*k+_*O+R*oe,s[15]=y*x+w*I+_*W+R*te,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],v=e[7],g=e[11],b=e[15];return m*(+s*l*h-i*c*h-s*o*u+n*c*u+i*o*f-n*l*f)+v*(+t*l*f-t*c*u+s*a*u-i*a*f+i*c*d-s*l*d)+g*(+t*c*h-t*o*f-s*a*h+n*a*f+s*o*d-n*c*d)+b*(-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],v=e[13],g=e[14],b=e[15],y=h*g*c-v*u*c+v*l*f-o*g*f-h*l*b+o*u*b,w=m*u*c-d*g*c-m*l*f+a*g*f+d*l*b-a*u*b,_=d*v*c-m*h*c+m*o*f-a*v*f-d*o*b+a*h*b,R=m*h*l-d*v*l-m*o*u+a*v*u+d*o*g-a*h*g,T=t*y+n*w+i*_+s*R;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/T;return e[0]=y*P,e[1]=(v*u*s-h*g*s-v*i*f+n*g*f+h*i*b-n*u*b)*P,e[2]=(o*g*s-v*l*s+v*i*c-n*g*c-o*i*b+n*l*b)*P,e[3]=(h*l*s-o*u*s-h*i*c+n*u*c+o*i*f-n*l*f)*P,e[4]=w*P,e[5]=(d*g*s-m*u*s+m*i*f-t*g*f-d*i*b+t*u*b)*P,e[6]=(m*l*s-a*g*s-m*i*c+t*g*c+a*i*b-t*l*b)*P,e[7]=(a*u*s-d*l*s+d*i*c-t*u*c-a*i*f+t*l*f)*P,e[8]=_*P,e[9]=(m*h*s-d*v*s-m*n*f+t*v*f+d*n*b-t*h*b)*P,e[10]=(a*v*s-m*o*s+m*n*c-t*v*c-a*n*b+t*o*b)*P,e[11]=(d*o*s-a*h*s-d*n*c+t*h*c+a*n*f-t*o*f)*P,e[12]=R*P,e[13]=(d*v*i-m*h*i+m*n*u-t*v*u-d*n*g+t*h*g)*P,e[14]=(m*o*i-a*v*i-m*n*l+t*v*l+a*n*g-t*o*g)*P,e[15]=(a*h*i-d*o*i+d*n*l-t*h*l-a*n*u+t*o*u)*P,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,v=a*d,g=a*h,b=o*h,y=l*c,w=l*d,_=l*h,R=n.x,T=n.y,P=n.z;return i[0]=(1-(v+b))*R,i[1]=(f+_)*R,i[2]=(m-w)*R,i[3]=0,i[4]=(f-_)*T,i[5]=(1-(u+b))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(m+w)*P,i[9]=(g-y)*P,i[10]=(1-(u+v))*P,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=zr.set(i[0],i[1],i[2]).length();const a=zr.set(i[4],i[5],i[6]).length(),o=zr.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],ki.copy(this);const c=1/s,d=1/a,h=1/o;return ki.elements[0]*=c,ki.elements[1]*=c,ki.elements[2]*=c,ki.elements[4]*=d,ki.elements[5]*=d,ki.elements[6]*=d,ki.elements[8]*=h,ki.elements[9]*=h,ki.elements[10]*=h,t.setFromRotationMatrix(ki),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=ys){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===ys)f=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===mc)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=ys){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,v;if(o===ys)m=(a+s)*h,v=-2*h;else if(o===mc)m=s*h,v=-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]=v,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 zr=new L,ki=new ke,K0=new L(0,0,0),$0=new L(1,1,1),Ds=new L,Yo=new L,hi=new L,Xf=new ke,qf=new Dt;class dn{constructor(e=0,t=0,n=0,i=dn.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 Xf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Xf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return qf.setFromEuler(this),this.setFromQuaternion(qf,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}}dn.DEFAULT_ORDER="XYZ";class Vu{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 Q0=0;const Zf=new L,Hr=new Dt,ds=new ke,Ko=new L,Va=new L,J0=new L,ex=new Dt,Yf=new L(1,0,0),Kf=new L(0,1,0),$f=new L(0,0,1),Qf={type:"added"},tx={type:"removed"},Gr={type:"childadded",child:null},Qc={type:"childremoved",child:null};class Pt extends Cr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Q0++}),this.uuid=Ni(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pt.DEFAULT_UP.clone();const e=new L,t=new dn,n=new Dt,i=new L(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 ke},normalMatrix:{value:new xt}}),this.matrix=new ke,this.matrixWorld=new ke,this.matrixAutoUpdate=Pt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Vu,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 Hr.setFromAxisAngle(e,t),this.quaternion.multiply(Hr),this}rotateOnWorldAxis(e,t){return Hr.setFromAxisAngle(e,t),this.quaternion.premultiply(Hr),this}rotateX(e){return this.rotateOnAxis(Yf,e)}rotateY(e){return this.rotateOnAxis(Kf,e)}rotateZ(e){return this.rotateOnAxis($f,e)}translateOnAxis(e,t){return Zf.copy(e).applyQuaternion(this.quaternion),this.position.add(Zf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Yf,e)}translateY(e){return this.translateOnAxis(Kf,e)}translateZ(e){return this.translateOnAxis($f,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ds.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ko.copy(e):Ko.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Va.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ds.lookAt(Va,Ko,this.up):ds.lookAt(Ko,Va,this.up),this.quaternion.setFromRotationMatrix(ds),i&&(ds.extractRotation(i.matrixWorld),Hr.setFromRotationMatrix(ds),this.quaternion.premultiply(Hr.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(Qf),Gr.child=e,this.dispatchEvent(Gr),Gr.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(tx),Qc.child=e,this.dispatchEvent(Qc),Qc.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),ds.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ds.multiply(e.parent.matrixWorld)),e.applyMatrix4(ds),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Qf),Gr.child=e,this.dispatchEvent(Gr),Gr.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(Va,e,J0),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Va,ex,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 L(0,1,0);Pt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Oi=new L,hs=new L,Jc=new L,us=new L,Vr=new L,Wr=new L,Jf=new L,ed=new L,td=new L,nd=new L,id=new _t,sd=new _t,rd=new _t;class bi{constructor(e=new L,t=new L,n=new L){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Oi.subVectors(e,t),i.cross(Oi);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){Oi.subVectors(i,t),hs.subVectors(n,t),Jc.subVectors(e,t);const a=Oi.dot(Oi),o=Oi.dot(hs),l=Oi.dot(Jc),c=hs.dot(hs),d=hs.dot(Jc),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,us)===null?!1:us.x>=0&&us.y>=0&&us.x+us.y<=1}static getInterpolation(e,t,n,i,s,a,o,l){return this.getBarycoord(e,t,n,i,us)===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,us.x),l.addScaledVector(a,us.y),l.addScaledVector(o,us.z),l)}static getInterpolatedAttribute(e,t,n,i,s,a){return id.setScalar(0),sd.setScalar(0),rd.setScalar(0),id.fromBufferAttribute(e,t),sd.fromBufferAttribute(e,n),rd.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(id,s.x),a.addScaledVector(sd,s.y),a.addScaledVector(rd,s.z),a}static isFrontFacing(e,t,n,i){return Oi.subVectors(n,t),hs.subVectors(e,t),Oi.cross(hs).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 Oi.subVectors(this.c,this.b),hs.subVectors(this.a,this.b),Oi.cross(hs).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return bi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return bi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return bi.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return bi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return bi.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;Vr.subVectors(i,n),Wr.subVectors(s,n),ed.subVectors(e,n);const l=Vr.dot(ed),c=Wr.dot(ed);if(l<=0&&c<=0)return t.copy(n);td.subVectors(e,i);const d=Vr.dot(td),h=Wr.dot(td);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(Vr,a);nd.subVectors(e,s);const f=Vr.dot(nd),m=Wr.dot(nd);if(m>=0&&f<=m)return t.copy(s);const v=f*c-l*m;if(v<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(n).addScaledVector(Wr,o);const g=d*m-f*h;if(g<=0&&h-d>=0&&f-m>=0)return Jf.subVectors(s,i),o=(h-d)/(h-d+(f-m)),t.copy(i).addScaledVector(Jf,o);const b=1/(g+v+u);return a=v*b,o=u*b,t.copy(n).addScaledVector(Vr,a).addScaledVector(Wr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Tb={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},$o={h:0,s:0,l:0};function ad(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 Le{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,dt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=dt.workingColorSpace){return this.r=e,this.g=t,this.b=n,dt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=dt.workingColorSpace){if(e=Hu(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=ad(a,s,e+1/3),this.g=ad(a,s,e),this.b=ad(a,s,e-1/3)}return dt.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=Tb[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=_s(e.r),this.g=_s(e.g),this.b=_s(e.b),this}copyLinearToSRGB(e){return this.r=ma(e.r),this.g=ma(e.g),this.b=ma(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=gt){return dt.fromWorkingColorSpace(Gn.copy(this),e),Math.round(yt(Gn.r*255,0,255))*65536+Math.round(yt(Gn.g*255,0,255))*256+Math.round(yt(Gn.b*255,0,255))}getHexString(e=gt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=dt.workingColorSpace){dt.fromWorkingColorSpace(Gn.copy(this),t);const n=Gn.r,i=Gn.g,s=Gn.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=dt.workingColorSpace){return dt.fromWorkingColorSpace(Gn.copy(this),t),e.r=Gn.r,e.g=Gn.g,e.b=Gn.b,e}getStyle(e=gt){dt.fromWorkingColorSpace(Gn.copy(this),e);const t=Gn.r,n=Gn.g,i=Gn.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($o);const n=fo(Ls.h,$o.h,t),i=fo(Ls.s,$o.s,t),s=fo(Ls.l,$o.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 Gn=new Le;Le.NAMES=Tb;let nx=0;class yi extends Cr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:nx++}),this.uuid=Ni(),this.name="",this.type="Material",this.blending=ua,this.side=xi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Eh,this.blendDst=Th,this.blendEquation=pr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Le(0,0,0),this.blendAlpha=0,this.depthFunc=_a,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Uf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=kr,this.stencilZFail=kr,this.stencilZPass=kr,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!==ua&&(n.blending=this.blending),this.side!==xi&&(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!==Eh&&(n.blendSrc=this.blendSrc),this.blendDst!==Th&&(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!==_a&&(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!==Uf&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==kr&&(n.stencilFail=this.stencilFail),this.stencilZFail!==kr&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==kr&&(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 yi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Le(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 dn,this.combine=Ec,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 mn=new L,Qo=new ge;let ix=0;class vn{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:ix++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=lu,this.updateRanges=[],this.gpuType=Vi,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++)Qo.fromBufferAttribute(this,t),Qo.applyMatrix3(e),this.setXY(t,Qo.x,Qo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)mn.fromBufferAttribute(this,t),mn.applyMatrix3(e),this.setXYZ(t,mn.x,mn.y,mn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)mn.fromBufferAttribute(this,t),mn.applyMatrix4(e),this.setXYZ(t,mn.x,mn.y,mn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)mn.fromBufferAttribute(this,t),mn.applyNormalMatrix(e),this.setXYZ(t,mn.x,mn.y,mn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)mn.fromBufferAttribute(this,t),mn.transformDirection(e),this.setXYZ(t,mn.x,mn.y,mn.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=zi(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=zi(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=zi(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=zi(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=zi(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!==lu&&(e.usage=this.usage),e}}class Wu extends vn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class ju extends vn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Fe extends vn{constructor(e,t,n){super(new Float32Array(e),t,n)}}let sx=0;const _i=new ke,od=new Pt,jr=new L,ui=new ln,Wa=new ln,Cn=new L;class mt extends Cr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:sx++}),this.uuid=Ni(),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(Mb(e)?ju:Wu)(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 _i.makeRotationFromQuaternion(e),this.applyMatrix4(_i),this}rotateX(e){return _i.makeRotationX(e),this.applyMatrix4(_i),this}rotateY(e){return _i.makeRotationY(e),this.applyMatrix4(_i),this}rotateZ(e){return _i.makeRotationZ(e),this.applyMatrix4(_i),this}translate(e,t,n){return _i.makeTranslation(e,t,n),this.applyMatrix4(_i),this}scale(e,t,n){return _i.makeScale(e,t,n),this.applyMatrix4(_i),this}lookAt(e){return od.lookAt(e),od.updateMatrix(),this.applyMatrix4(od.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(jr).negate(),this.translate(jr.x,jr.y,jr.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 Fe(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 ln);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 L(-1/0,-1/0,-1/0),new L(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];ui.setFromBufferAttribute(s),this.morphTargetsRelative?(Cn.addVectors(this.boundingBox.min,ui.min),this.boundingBox.expandByPoint(Cn),Cn.addVectors(this.boundingBox.max,ui.max),this.boundingBox.expandByPoint(Cn)):(this.boundingBox.expandByPoint(ui.min),this.boundingBox.expandByPoint(ui.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 ni);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 L,1/0);return}if(e){const n=this.boundingSphere.center;if(ui.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Wa.setFromBufferAttribute(o),this.morphTargetsRelative?(Cn.addVectors(ui.min,Wa.min),ui.expandByPoint(Cn),Cn.addVectors(ui.max,Wa.max),ui.expandByPoint(Cn)):(ui.expandByPoint(Wa.min),ui.expandByPoint(Wa.max))}ui.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&&(jr.fromBufferAttribute(e,c),Cn.add(jr)),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 vn(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let M=0;M<n.count;M++)o[M]=new L,l[M]=new L;const c=new L,d=new L,h=new L,u=new ge,f=new ge,m=new ge,v=new L,g=new L;function b(M,x,S){c.fromBufferAttribute(n,M),d.fromBufferAttribute(n,x),h.fromBufferAttribute(n,S),u.fromBufferAttribute(s,M),f.fromBufferAttribute(s,x),m.fromBufferAttribute(s,S),d.sub(c),h.sub(c),f.sub(u),m.sub(u);const C=1/(f.x*m.y-m.x*f.y);isFinite(C)&&(v.copy(d).multiplyScalar(m.y).addScaledVector(h,-f.y).multiplyScalar(C),g.copy(h).multiplyScalar(f.x).addScaledVector(d,-m.x).multiplyScalar(C),o[M].add(v),o[x].add(v),o[S].add(v),l[M].add(g),l[x].add(g),l[S].add(g))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let M=0,x=y.length;M<x;++M){const S=y[M],C=S.start,k=S.count;for(let I=C,G=C+k;I<G;I+=3)b(e.getX(I+0),e.getX(I+1),e.getX(I+2))}const w=new L,_=new L,R=new L,T=new L;function P(M){R.fromBufferAttribute(i,M),T.copy(R);const x=o[M];w.copy(x),w.sub(R.multiplyScalar(R.dot(x))).normalize(),_.crossVectors(T,x);const C=_.dot(l[M])<0?-1:1;a.setXYZW(M,w.x,w.y,w.z,C)}for(let M=0,x=y.length;M<x;++M){const S=y[M],C=S.start,k=S.count;for(let I=C,G=C+k;I<G;I+=3)P(e.getX(I+0)),P(e.getX(I+1)),P(e.getX(I+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 vn(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 L,s=new L,a=new L,o=new L,l=new L,c=new L,d=new L,h=new L;if(e)for(let u=0,f=e.count;u<f;u+=3){const m=e.getX(u+0),v=e.getX(u+1),g=e.getX(u+2);i.fromBufferAttribute(t,m),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,g),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),o.fromBufferAttribute(n,m),l.fromBufferAttribute(n,v),c.fromBufferAttribute(n,g),o.add(d),l.add(d),c.add(d),n.setXYZ(m,o.x,o.y,o.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(g,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 v=0,g=l.length;v<g;v++){o.isInterleavedBufferAttribute?f=l[v]*o.data.stride+o.offset:f=l[v]*d;for(let b=0;b<d;b++)u[m++]=c[f++]}return new vn(u,d,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new mt,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 ep=new ke,ir=new Ra,Jo=new ni,tp=new L,el=new L,tl=new L,nl=new L,ld=new L,il=new L,np=new L,sl=new L;class Ae extends Pt{constructor(e=new mt,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){il.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const d=o[l],h=s[l];d!==0&&(ld.fromBufferAttribute(h,e),a?il.addScaledVector(ld,d):il.addScaledVector(ld.sub(t),d))}t.add(il)}return t}raycast(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Jo.copy(n.boundingSphere),Jo.applyMatrix4(s),ir.copy(e.ray).recast(e.near),!(Jo.containsPoint(ir.origin)===!1&&(ir.intersectSphere(Jo,tp)===null||ir.origin.distanceToSquared(tp)>(e.far-e.near)**2))&&(ep.copy(s).invert(),ir.copy(e.ray).applyMatrix4(ep),!(n.boundingBox!==null&&ir.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ir)))}_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,v=u.length;m<v;m++){const g=u[m],b=a[g.materialIndex],y=Math.max(g.start,f.start),w=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let _=y,R=w;_<R;_+=3){const T=o.getX(_),P=o.getX(_+1),M=o.getX(_+2);i=rl(this,b,e,n,c,d,h,T,P,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const m=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let g=m,b=v;g<b;g+=3){const y=o.getX(g),w=o.getX(g+1),_=o.getX(g+2);i=rl(this,a,e,n,c,d,h,y,w,_),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,v=u.length;m<v;m++){const g=u[m],b=a[g.materialIndex],y=Math.max(g.start,f.start),w=Math.min(l.count,Math.min(g.start+g.count,f.start+f.count));for(let _=y,R=w;_<R;_+=3){const T=_,P=_+1,M=_+2;i=rl(this,b,e,n,c,d,h,T,P,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const m=Math.max(0,f.start),v=Math.min(l.count,f.start+f.count);for(let g=m,b=v;g<b;g+=3){const y=g,w=g+1,_=g+2;i=rl(this,a,e,n,c,d,h,y,w,_),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}}}function rx(r,e,t,n,i,s,a,o){let l;if(e.side===ci?l=n.intersectTriangle(a,s,i,!0,o):l=n.intersectTriangle(i,s,a,e.side===xi,o),l===null)return null;sl.copy(o),sl.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(sl);return c<t.near||c>t.far?null:{distance:c,point:sl.clone(),object:r}}function rl(r,e,t,n,i,s,a,o,l,c){r.getVertexPosition(o,el),r.getVertexPosition(l,tl),r.getVertexPosition(c,nl);const d=rx(r,e,t,n,el,tl,nl,np);if(d){const h=new L;bi.getBarycoord(np,el,tl,nl,h),i&&(d.uv=bi.getInterpolatedAttribute(i,o,l,c,h,new ge)),s&&(d.uv1=bi.getInterpolatedAttribute(s,o,l,c,h,new ge)),a&&(d.normal=bi.getInterpolatedAttribute(a,o,l,c,h,new L),d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new L,materialIndex:0};bi.getNormal(el,tl,nl,u.normal),d.face=u,d.barycoord=h}return d}class Kt extends mt{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 Fe(c,3)),this.setAttribute("normal",new Fe(d,3)),this.setAttribute("uv",new Fe(h,2));function m(v,g,b,y,w,_,R,T,P,M,x){const S=_/P,C=R/M,k=_/2,I=R/2,G=T/2,q=P+1,O=M+1;let W=0,Z=0;const K=new L;for(let oe=0;oe<O;oe++){const te=oe*C-I;for(let ve=0;ve<q;ve++){const ce=ve*S-k;K[v]=ce*y,K[g]=te*w,K[b]=G,c.push(K.x,K.y,K.z),K[v]=0,K[g]=0,K[b]=T>0?1:-1,d.push(K.x,K.y,K.z),h.push(ve/P),h.push(1-oe/M),W+=1}}for(let oe=0;oe<M;oe++)for(let te=0;te<P;te++){const ve=u+te+q*oe,ce=u+te+q*(oe+1),Q=u+(te+1)+q*(oe+1),re=u+(te+1)+q*oe;l.push(ve,ce,re),l.push(ce,Q,re),Z+=6}o.addGroup(f,Z,x),f+=Z,u+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kt(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Aa(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 Jn(r){const e={};for(let t=0;t<r.length;t++){const n=Aa(r[t]);for(const i in n)e[i]=n[i]}return e}function ax(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function Ab(r){const e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:dt.workingColorSpace}const Na={clone:Aa,merge:Jn};var ox=`void main() {
|
|
30
30
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
31
31
|
}`,lx=`void main() {
|
|
32
32
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
@@ -65,7 +65,7 @@ import{c as wu,f9 as Su,cV as Fg,gj as Ug,gk as cc,gl as Ov,gm as Mu,gn as Mf,go
|
|
|
65
65
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
66
66
|
|
|
67
67
|
}
|
|
68
|
-
`},i=new Kt(5,5,5),s=new wn({name:"CubemapFromEquirect",uniforms:Aa(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:ci,blending:Xi});s.uniforms.tEquirect.value=t;const a=new Ae(i,s),o=t.minFilter;return t.minFilter===Gi&&(t.minFilter=bn),new cx(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(s)}}class Vt extends Pt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const hx={type:"move"};class cd{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Vt,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Vt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Vt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const g=t.getJointPose(v,n),b=this._getHandJoint(c,v);g!==null&&(b.matrix.fromArray(g.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=g.radius),b.visible=g!==null}const d=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],u=d.position.distanceTo(h.position),f=.02,m=.005;c.inputState.pinching&&u>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(hx)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Vt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class cu extends Pt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new dn,this.environmentIntensity=1,this.environmentRotation=new dn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Xu{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=lu,this.updateRanges=[],this.version=0,this.uuid=Ni()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ni()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ni()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Qn=new L;class Wi{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Qn.fromBufferAttribute(this,t),Qn.applyMatrix4(e),this.setXYZ(t,Qn.x,Qn.y,Qn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Qn.fromBufferAttribute(this,t),Qn.applyNormalMatrix(e),this.setXYZ(t,Qn.x,Qn.y,Qn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Qn.fromBufferAttribute(this,t),Qn.transformDirection(e),this.setXYZ(t,Qn.x,Qn.y,Qn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=zi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Gt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Gt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Gt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Gt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Gt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=zi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=zi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=zi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=zi(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Gt(t,this.array),n=Gt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Gt(t,this.array),n=Gt(n,this.array),i=Gt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Gt(t,this.array),n=Gt(n,this.array),i=Gt(i,this.array),s=Gt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new vn(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Wi(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class ux extends yi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Le(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Zr;const ja=new L,Yr=new L,Kr=new L,$r=new ge,Xa=new ge,Rb=new ke,al=new L,qa=new L,ol=new L,rp=new ge,dd=new ge,ap=new ge;class mN extends Pt{constructor(e=new ux){if(super(),this.isSprite=!0,this.type="Sprite",Zr===void 0){Zr=new mt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Xu(t,5);Zr.setIndex([0,1,2,0,2,3]),Zr.setAttribute("position",new Wi(n,3,0,!1)),Zr.setAttribute("uv",new Wi(n,2,3,!1))}this.geometry=Zr,this.material=e,this.center=new ge(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Yr.setFromMatrixScale(this.matrixWorld),Rb.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Kr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Yr.multiplyScalar(-Kr.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const a=this.center;ll(al.set(-.5,-.5,0),Kr,a,Yr,i,s),ll(qa.set(.5,-.5,0),Kr,a,Yr,i,s),ll(ol.set(.5,.5,0),Kr,a,Yr,i,s),rp.set(0,0),dd.set(1,0),ap.set(1,1);let o=e.ray.intersectTriangle(al,qa,ol,!1,ja);if(o===null&&(ll(qa.set(-.5,.5,0),Kr,a,Yr,i,s),dd.set(0,1),o=e.ray.intersectTriangle(al,ol,qa,!1,ja),o===null))return;const l=e.ray.origin.distanceTo(ja);l<e.near||l>e.far||t.push({distance:l,point:ja.clone(),uv:bi.getInterpolation(ja,al,qa,ol,rp,dd,ap,new ge),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ll(r,e,t,n,i,s){$r.subVectors(r,t).addScalar(.5).multiply(n),i!==void 0?(Xa.x=s*$r.x-i*$r.y,Xa.y=i*$r.x+s*$r.y):Xa.copy($r),r.copy(e),r.x+=Xa.x,r.y+=Xa.y,r.applyMatrix4(Rb)}const op=new L,lp=new _t,cp=new _t,fx=new L,dp=new ke,cl=new L,hd=new ni,hp=new ke,ud=new Ra;class qu extends Ae{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=If,this.bindMatrix=new ke,this.bindMatrixInverse=new ke,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ln),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,cl),this.boundingBox.expandByPoint(cl)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ni),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,cl),this.boundingSphere.expandByPoint(cl)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),hd.copy(this.boundingSphere),hd.applyMatrix4(i),e.ray.intersectsSphere(hd)!==!1&&(hp.copy(i).invert(),ud.copy(e.ray).applyMatrix4(hp),!(this.boundingBox!==null&&ud.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ud)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new _t,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===If?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===h0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;lp.fromBufferAttribute(i.attributes.skinIndex,e),cp.fromBufferAttribute(i.attributes.skinWeight,e),op.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=cp.getComponent(s);if(a!==0){const o=lp.getComponent(s);dp.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(fx.copy(op).applyMatrix4(dp),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class So extends Pt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Zu extends Bt{constructor(e=null,t=1,n=1,i,s,a,o,l,c=Sn,d=Sn,h,u){super(null,a,o,l,c,d,i,s,h,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const up=new ke,px=new ke;class Po{constructor(e=[],t=[]){this.uuid=Ni(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new ke)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new ke;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:px;up.multiplyMatrices(o,t[s]),up.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Po(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Zu(t,e,e,Zn,Vi);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const s=e.bones[n];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new So),this.bones.push(a),this.boneInverses.push(new ke().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class du extends vn{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Qr=new ke,fp=new ke,dl=[],pp=new ln,mx=new ke,Za=new Ae,Ya=new ni;class gx extends Ae{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new du(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,mx)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ln),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Qr),pp.copy(e.boundingBox).applyMatrix4(Qr),this.boundingBox.union(pp)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ni),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Qr),Ya.copy(e.boundingSphere).applyMatrix4(Qr),this.boundingSphere.union(Ya)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,s=n.length+1,a=e*s+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Za.geometry=this.geometry,Za.material=this.material,Za.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ya.copy(this.boundingSphere),Ya.applyMatrix4(n),e.ray.intersectsSphere(Ya)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,Qr),fp.multiplyMatrices(n,Qr),Za.matrixWorld=fp,Za.raycast(e,dl);for(let a=0,o=dl.length;a<o;a++){const l=dl[a];l.instanceId=s,l.object=this,t.push(l)}dl.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new du(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Zu(new Float32Array(i*this.count),i,this.count,Fu,Vi));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<n.length;c++)a+=n[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=i*e;s[l]=o,s.set(n,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const fd=new L,bx=new L,vx=new xt;class Vs{constructor(e=new L(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=fd.subVectors(n,t).cross(bx.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(fd),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||vx.getNormalMatrix(e),i=this.coplanarPoint(fd).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const sr=new ni,hl=new L;class Cc{constructor(e=new Vs,t=new Vs,n=new Vs,i=new Vs,s=new Vs,a=new Vs){this.planes=[e,t,n,i,s,a]}set(e,t,n,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ys){const n=this.planes,i=e.elements,s=i[0],a=i[1],o=i[2],l=i[3],c=i[4],d=i[5],h=i[6],u=i[7],f=i[8],m=i[9],v=i[10],g=i[11],b=i[12],y=i[13],w=i[14],_=i[15];if(n[0].setComponents(l-s,u-c,g-f,_-b).normalize(),n[1].setComponents(l+s,u+c,g+f,_+b).normalize(),n[2].setComponents(l+a,u+d,g+m,_+y).normalize(),n[3].setComponents(l-a,u-d,g-m,_-y).normalize(),n[4].setComponents(l-o,u-h,g-v,_-w).normalize(),t===ys)n[5].setComponents(l+o,u+h,g+v,_+w).normalize();else if(t===mc)n[5].setComponents(o,h,v,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),sr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),sr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(sr)}intersectsSprite(e){return sr.center.set(0,0,0),sr.radius=.7071067811865476,sr.applyMatrix4(e.matrixWorld),this.intersectsSphere(sr)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(hl.x=i.normal.x>0?e.max.x:e.min.x,hl.y=i.normal.y>0?e.max.y:e.min.y,hl.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(hl)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Yn extends yi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Le(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const gc=new L,bc=new L,mp=new ke,Ka=new Ra,ul=new ni,pd=new L,gp=new L;class Wn extends Pt{constructor(e=new mt,t=new Yn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)gc.fromBufferAttribute(t,i-1),bc.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=gc.distanceTo(bc);e.setAttribute("lineDistance",new Fe(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ul.copy(n.boundingSphere),ul.applyMatrix4(i),ul.radius+=s,e.ray.intersectsSphere(ul)===!1)return;mp.copy(i).invert(),Ka.copy(e.ray).applyMatrix4(mp);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,d=n.index,u=n.attributes.position;if(d!==null){const f=Math.max(0,a.start),m=Math.min(d.count,a.start+a.count);for(let v=f,g=m-1;v<g;v+=c){const b=d.getX(v),y=d.getX(v+1),w=fl(this,e,Ka,l,b,y,v);w&&t.push(w)}if(this.isLineLoop){const v=d.getX(m-1),g=d.getX(f),b=fl(this,e,Ka,l,v,g,m-1);b&&t.push(b)}}else{const f=Math.max(0,a.start),m=Math.min(u.count,a.start+a.count);for(let v=f,g=m-1;v<g;v+=c){const b=fl(this,e,Ka,l,v,v+1,v);b&&t.push(b)}if(this.isLineLoop){const v=fl(this,e,Ka,l,m-1,f,m-1);v&&t.push(v)}}}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}}}}}function fl(r,e,t,n,i,s,a){const o=r.geometry.attributes.position;if(gc.fromBufferAttribute(o,i),bc.fromBufferAttribute(o,s),t.distanceSqToSegment(gc,bc,pd,gp)>n)return;pd.applyMatrix4(r.matrixWorld);const c=e.ray.origin.distanceTo(pd);if(!(c<e.near||c>e.far))return{distance:c,point:gp.clone().applyMatrix4(r.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:r}}const bp=new L,vp=new L;class Pr extends Wn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)bp.fromBufferAttribute(t,i),vp.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+bp.distanceTo(vp);e.setAttribute("lineDistance",new Fe(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Nb extends Wn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class aa extends yi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Le(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const yp=new ke,hu=new Ra,pl=new ni,ml=new L;class lo extends Pt{constructor(e=new mt,t=new aa){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),pl.copy(n.boundingSphere),pl.applyMatrix4(i),pl.radius+=s,e.ray.intersectsSphere(pl)===!1)return;yp.copy(i).invert(),hu.copy(e.ray).applyMatrix4(yp);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,h=n.attributes.position;if(c!==null){const u=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let m=u,v=f;m<v;m++){const g=c.getX(m);ml.fromBufferAttribute(h,g),xp(ml,g,l,i,e,t,this)}}else{const u=Math.max(0,a.start),f=Math.min(h.count,a.start+a.count);for(let m=u,v=f;m<v;m++)ml.fromBufferAttribute(h,m),xp(ml,m,l,i,e,t,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}}}}}function xp(r,e,t,n,i,s,a){const o=hu.distanceSqToPoint(r);if(o<t){const l=new L;hu.closestPointToPoint(r,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class gN extends Bt{constructor(e,t,n,i,s,a,o,l,c){super(e,t,n,i,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Db extends Bt{constructor(e,t,n,i,s,a,o,l,c,d=fa){if(d!==fa&&d!==Ea)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&d===fa&&(n=Sr),n===void 0&&d===Ea&&(n=Ma),super(null,i,s,a,o,l,d,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:Sn,this.minFilter=l!==void 0?l:Sn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Gu(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Zi{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let i=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),c=n[i]-a,c<0)o=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(s-1);const d=n[i],u=n[i+1]-d,f=(a-d)/u;return(i+f)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const a=this.getPoint(i),o=this.getPoint(s),l=t||(a.isVector2?new ge:new L);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new L,i=[],s=[],a=[],o=new L,l=new ke;for(let f=0;f<=e;f++){const m=f/e;i[f]=this.getTangentAt(m,new L)}s[0]=new L,a[0]=new L;let c=Number.MAX_VALUE;const d=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);d<=c&&(c=d,n.set(1,0,0)),h<=c&&(c=h,n.set(0,1,0)),u<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),a[0].crossVectors(i[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(i[f-1],i[f]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(yt(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(o,m))}a[f].crossVectors(i[f],s[f])}if(t===!0){let f=Math.acos(yt(s[0].dot(s[e]),-1,1));f/=e,i[0].dot(o.crossVectors(s[0],s[e]))>0&&(f=-f);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),a[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Yu extends Zi{constructor(e=0,t=0,n=1,i=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new ge){const n=t,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(a?s=0:s=i),this.aClockwise===!0&&!a&&(s===i?s=-i:s=s-i);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const d=Math.cos(this.aRotation),h=Math.sin(this.aRotation),u=l-this.aX,f=c-this.aY;l=u*d-f*h+this.aX,c=u*h+f*d+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class yx extends Yu{constructor(e,t,n,i,s,a){super(e,t,n,n,i,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Ku(){let r=0,e=0,t=0,n=0;function i(s,a,o,l){r=s,e=o,t=-3*s+3*a-2*o-l,n=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){i(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,d,h){let u=(a-s)/c-(o-s)/(c+d)+(o-a)/d,f=(o-a)/d-(l-a)/(d+h)+(l-o)/h;u*=d,f*=d,i(a,o,u,f)},calc:function(s){const a=s*s,o=a*s;return r+e*s+t*a+n*o}}}const gl=new L,md=new Ku,gd=new Ku,bd=new Ku;class xx extends Zi{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new L){const n=t,i=this.points,s=i.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,d;this.closed||o>0?c=i[(o-1)%s]:(gl.subVectors(i[0],i[1]).add(i[0]),c=gl);const h=i[o%s],u=i[(o+1)%s];if(this.closed||o+2<s?d=i[(o+2)%s]:(gl.subVectors(i[s-1],i[s-2]).add(i[s-1]),d=gl),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(h),f),v=Math.pow(h.distanceToSquared(u),f),g=Math.pow(u.distanceToSquared(d),f);v<1e-4&&(v=1),m<1e-4&&(m=v),g<1e-4&&(g=v),md.initNonuniformCatmullRom(c.x,h.x,u.x,d.x,m,v,g),gd.initNonuniformCatmullRom(c.y,h.y,u.y,d.y,m,v,g),bd.initNonuniformCatmullRom(c.z,h.z,u.z,d.z,m,v,g)}else this.curveType==="catmullrom"&&(md.initCatmullRom(c.x,h.x,u.x,d.x,this.tension),gd.initCatmullRom(c.y,h.y,u.y,d.y,this.tension),bd.initCatmullRom(c.z,h.z,u.z,d.z,this.tension));return n.set(md.calc(l),gd.calc(l),bd.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new L().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function _p(r,e,t,n,i){const s=(n-e)*.5,a=(i-t)*.5,o=r*r,l=r*o;return(2*t-2*n+s+a)*l+(-3*t+3*n-2*s-a)*o+s*r+t}function _x(r,e){const t=1-r;return t*t*e}function wx(r,e){return 2*(1-r)*r*e}function Sx(r,e){return r*r*e}function po(r,e,t,n){return _x(r,e)+wx(r,t)+Sx(r,n)}function Mx(r,e){const t=1-r;return t*t*t*e}function Ex(r,e){const t=1-r;return 3*t*t*r*e}function Tx(r,e){return 3*(1-r)*r*r*e}function Ax(r,e){return r*r*r*e}function mo(r,e,t,n,i){return Mx(r,e)+Ex(r,t)+Tx(r,n)+Ax(r,i)}class Lb extends Zi{constructor(e=new ge,t=new ge,n=new ge,i=new ge){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new ge){const n=t,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(mo(e,i.x,s.x,a.x,o.x),mo(e,i.y,s.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Cx extends Zi{constructor(e=new L,t=new L,n=new L,i=new L){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new L){const n=t,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(mo(e,i.x,s.x,a.x,o.x),mo(e,i.y,s.y,a.y,o.y),mo(e,i.z,s.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Ib extends Zi{constructor(e=new ge,t=new ge){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ge){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ge){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Px extends Zi{constructor(e=new L,t=new L){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new L){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new L){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class kb extends Zi{constructor(e=new ge,t=new ge,n=new ge){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new ge){const n=t,i=this.v0,s=this.v1,a=this.v2;return n.set(po(e,i.x,s.x,a.x),po(e,i.y,s.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Rx extends Zi{constructor(e=new L,t=new L,n=new L){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new L){const n=t,i=this.v0,s=this.v1,a=this.v2;return n.set(po(e,i.x,s.x,a.x),po(e,i.y,s.y,a.y),po(e,i.z,s.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Ob extends Zi{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ge){const n=t,i=this.points,s=(i.length-1)*e,a=Math.floor(s),o=s-a,l=i[a===0?a:a-1],c=i[a],d=i[a>i.length-2?i.length-1:a+1],h=i[a>i.length-3?i.length-1:a+2];return n.set(_p(o,l.x,c.x,d.x,h.x),_p(o,l.y,c.y,d.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new ge().fromArray(i))}return this}}var wp=Object.freeze({__proto__:null,ArcCurve:yx,CatmullRomCurve3:xx,CubicBezierCurve:Lb,CubicBezierCurve3:Cx,EllipseCurve:Yu,LineCurve:Ib,LineCurve3:Px,QuadraticBezierCurve:kb,QuadraticBezierCurve3:Rx,SplineCurve:Ob});class Nx extends Zi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new wp[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const a=i[s]-n,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const a=s[i],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const d=l[c];n&&n.equals(d)||(t.push(d),n=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new wp[i.type]().fromJSON(i))}return this}}class uu extends Nx{constructor(e){super(),this.type="Path",this.currentPoint=new ge,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new Ib(this.currentPoint.clone(),new ge(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const s=new kb(this.currentPoint.clone(),new ge(e,t),new ge(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,a){const o=new Lb(this.currentPoint.clone(),new ge(e,t),new ge(n,i),new ge(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Ob(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,n,i,s,a),this}absarc(e,t,n,i,s,a){return this.absellipse(e,t,n,n,i,s,a),this}ellipse(e,t,n,i,s,a,o,l){const c=this.currentPoint.x,d=this.currentPoint.y;return this.absellipse(e+c,t+d,n,i,s,a,o,l),this}absellipse(e,t,n,i,s,a,o,l){const c=new Yu(e,t,n,i,s,a,o,l);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const d=c.getPoint(1);return this.currentPoint.copy(d),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class $u extends mt{constructor(e=[new ge(0,-.5),new ge(.5,0),new ge(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=yt(i,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],d=1/t,h=new L,u=new ge,f=new L,m=new L,v=new L;let g=0,b=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,b=e[y+1].y-e[y].y,f.x=b*1,f.y=-g,f.z=b*0,v.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case e.length-1:l.push(v.x,v.y,v.z);break;default:g=e[y+1].x-e[y].x,b=e[y+1].y-e[y].y,f.x=b*1,f.y=-g,f.z=b*0,m.copy(f),f.x+=v.x,f.y+=v.y,f.z+=v.z,f.normalize(),l.push(f.x,f.y,f.z),v.copy(m)}for(let y=0;y<=t;y++){const w=n+y*d*i,_=Math.sin(w),R=Math.cos(w);for(let T=0;T<=e.length-1;T++){h.x=e[T].x*_,h.y=e[T].y,h.z=e[T].x*R,a.push(h.x,h.y,h.z),u.x=y/t,u.y=T/(e.length-1),o.push(u.x,u.y);const P=l[3*T+0]*_,M=l[3*T+1],x=l[3*T+0]*R;c.push(P,M,x)}}for(let y=0;y<t;y++)for(let w=0;w<e.length-1;w++){const _=w+y*e.length,R=_,T=_+e.length,P=_+e.length+1,M=_+1;s.push(R,T,M),s.push(P,M,T)}this.setIndex(s),this.setAttribute("position",new Fe(a,3)),this.setAttribute("uv",new Fe(o,2)),this.setAttribute("normal",new Fe(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $u(e.points,e.segments,e.phiStart,e.phiLength)}}class Fb extends $u{constructor(e=1,t=1,n=4,i=8){const s=new uu;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new Fb(e.radius,e.length,e.capSegments,e.radialSegments)}}class Pc extends mt{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new L,d=new ge;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let h=0,u=3;h<=t;h++,u+=3){const f=n+h/t*i;c.x=e*Math.cos(f),c.y=e*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),d.x=(a[u]/e+1)/2,d.y=(a[u+1]/e+1)/2,l.push(d.x,d.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new Fe(a,3)),this.setAttribute("normal",new Fe(o,3)),this.setAttribute("uv",new Fe(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pc(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Pn extends mt{constructor(e=1,t=1,n=1,i=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),s=Math.floor(s);const d=[],h=[],u=[],f=[];let m=0;const v=[],g=n/2;let b=0;y(),a===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(d),this.setAttribute("position",new Fe(h,3)),this.setAttribute("normal",new Fe(u,3)),this.setAttribute("uv",new Fe(f,2));function y(){const _=new L,R=new L;let T=0;const P=(t-e)/n;for(let M=0;M<=s;M++){const x=[],S=M/s,C=S*(t-e)+e;for(let k=0;k<=i;k++){const I=k/i,G=I*l+o,q=Math.sin(G),O=Math.cos(G);R.x=C*q,R.y=-S*n+g,R.z=C*O,h.push(R.x,R.y,R.z),_.set(q,P,O).normalize(),u.push(_.x,_.y,_.z),f.push(I,1-S),x.push(m++)}v.push(x)}for(let M=0;M<i;M++)for(let x=0;x<s;x++){const S=v[x][M],C=v[x+1][M],k=v[x+1][M+1],I=v[x][M+1];(e>0||x!==0)&&(d.push(S,C,I),T+=3),(t>0||x!==s-1)&&(d.push(C,k,I),T+=3)}c.addGroup(b,T,0),b+=T}function w(_){const R=m,T=new ge,P=new L;let M=0;const x=_===!0?e:t,S=_===!0?1:-1;for(let k=1;k<=i;k++)h.push(0,g*S,0),u.push(0,S,0),f.push(.5,.5),m++;const C=m;for(let k=0;k<=i;k++){const G=k/i*l+o,q=Math.cos(G),O=Math.sin(G);P.x=x*O,P.y=g*S,P.z=x*q,h.push(P.x,P.y,P.z),u.push(0,S,0),T.x=q*.5+.5,T.y=O*.5*S+.5,f.push(T.x,T.y),m++}for(let k=0;k<i;k++){const I=R+k,G=C+k;_===!0?d.push(G,G+1,I):d.push(G+1,G,I),M+=3}c.addGroup(b,M,_===!0?1:2),b+=M}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pn(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Qu extends mt{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const s=[],a=[];o(i),c(n),d(),this.setAttribute("position",new Fe(s,3)),this.setAttribute("normal",new Fe(s.slice(),3)),this.setAttribute("uv",new Fe(a,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function o(y){const w=new L,_=new L,R=new L;for(let T=0;T<t.length;T+=3)f(t[T+0],w),f(t[T+1],_),f(t[T+2],R),l(w,_,R,y)}function l(y,w,_,R){const T=R+1,P=[];for(let M=0;M<=T;M++){P[M]=[];const x=y.clone().lerp(_,M/T),S=w.clone().lerp(_,M/T),C=T-M;for(let k=0;k<=C;k++)k===0&&M===T?P[M][k]=x:P[M][k]=x.clone().lerp(S,k/C)}for(let M=0;M<T;M++)for(let x=0;x<2*(T-M)-1;x++){const S=Math.floor(x/2);x%2===0?(u(P[M][S+1]),u(P[M+1][S]),u(P[M][S])):(u(P[M][S+1]),u(P[M+1][S+1]),u(P[M+1][S]))}}function c(y){const w=new L;for(let _=0;_<s.length;_+=3)w.x=s[_+0],w.y=s[_+1],w.z=s[_+2],w.normalize().multiplyScalar(y),s[_+0]=w.x,s[_+1]=w.y,s[_+2]=w.z}function d(){const y=new L;for(let w=0;w<s.length;w+=3){y.x=s[w+0],y.y=s[w+1],y.z=s[w+2];const _=g(y)/2/Math.PI+.5,R=b(y)/Math.PI+.5;a.push(_,1-R)}m(),h()}function h(){for(let y=0;y<a.length;y+=6){const w=a[y+0],_=a[y+2],R=a[y+4],T=Math.max(w,_,R),P=Math.min(w,_,R);T>.9&&P<.1&&(w<.2&&(a[y+0]+=1),_<.2&&(a[y+2]+=1),R<.2&&(a[y+4]+=1))}}function u(y){s.push(y.x,y.y,y.z)}function f(y,w){const _=y*3;w.x=e[_+0],w.y=e[_+1],w.z=e[_+2]}function m(){const y=new L,w=new L,_=new L,R=new L,T=new ge,P=new ge,M=new ge;for(let x=0,S=0;x<s.length;x+=9,S+=6){y.set(s[x+0],s[x+1],s[x+2]),w.set(s[x+3],s[x+4],s[x+5]),_.set(s[x+6],s[x+7],s[x+8]),T.set(a[S+0],a[S+1]),P.set(a[S+2],a[S+3]),M.set(a[S+4],a[S+5]),R.copy(y).add(w).add(_).divideScalar(3);const C=g(R);v(T,S+0,y,C),v(P,S+2,w,C),v(M,S+4,_,C)}}function v(y,w,_,R){R<0&&y.x===1&&(a[w]=y.x-1),_.x===0&&_.z===0&&(a[w]=R/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function b(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qu(e.vertices,e.indices,e.radius,e.details)}}const bl=new L,vl=new L,vd=new L,yl=new bi;class Rc extends mt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),s=Math.cos(pa*t),a=e.getIndex(),o=e.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],d=["a","b","c"],h=new Array(3),u={},f=[];for(let m=0;m<l;m+=3){a?(c[0]=a.getX(m),c[1]=a.getX(m+1),c[2]=a.getX(m+2)):(c[0]=m,c[1]=m+1,c[2]=m+2);const{a:v,b:g,c:b}=yl;if(v.fromBufferAttribute(o,c[0]),g.fromBufferAttribute(o,c[1]),b.fromBufferAttribute(o,c[2]),yl.getNormal(vd),h[0]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,h[1]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,h[2]=`${Math.round(b.x*i)},${Math.round(b.y*i)},${Math.round(b.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let y=0;y<3;y++){const w=(y+1)%3,_=h[y],R=h[w],T=yl[d[y]],P=yl[d[w]],M=`${_}_${R}`,x=`${R}_${_}`;x in u&&u[x]?(vd.dot(u[x].normal)<=s&&(f.push(T.x,T.y,T.z),f.push(P.x,P.y,P.z)),u[x]=null):M in u||(u[M]={index0:c[y],index1:c[w],normal:vd.clone()})}}for(const m in u)if(u[m]){const{index0:v,index1:g}=u[m];bl.fromBufferAttribute(o,v),vl.fromBufferAttribute(o,g),f.push(bl.x,bl.y,bl.z),f.push(vl.x,vl.y,vl.z)}this.setAttribute("position",new Fe(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Ub extends uu{constructor(e){super(e),this.uuid=Ni(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new uu().fromJSON(i))}return this}}class Dx{static triangulate(e,t,n=2){const i=t&&t.length,s=i?t[0]*n:e.length;let a=Bb(e,0,s,n,!0);const o=[];if(!a||a.next===a.prev)return o;let l,c,d,h,u,f,m;if(i&&(a=Fx(e,t,a,n)),e.length>80*n){l=d=e[0],c=h=e[1];for(let v=n;v<s;v+=n)u=e[v],f=e[v+1],u<l&&(l=u),f<c&&(c=f),u>d&&(d=u),f>h&&(h=f);m=Math.max(d-l,h-c),m=m!==0?32767/m:0}return Mo(a,o,n,l,c,m,0),o}}function Bb(r,e,t,n,i){let s,a;if(i===Zx(r,e,t,n)>0)for(s=e;s<t;s+=n)a=Sp(s,r[s],r[s+1],a);else for(s=t-n;s>=e;s-=n)a=Sp(s,r[s],r[s+1],a);return a&&Nc(a,a.next)&&(To(a),a=a.next),a}function Mr(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(Nc(t,t.next)||rn(t.prev,t,t.next)===0)){if(To(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Mo(r,e,t,n,i,s,a){if(!r)return;!a&&s&&Gx(r,n,i,s);let o=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?Ix(r,n,i,s):Lx(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(c.i/t|0),To(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=kx(Mr(r),e,t),Mo(r,e,t,n,i,s,2)):a===2&&Ox(r,e,t,n,i,s):Mo(Mr(r),e,t,n,i,s,1);break}}}function Lx(r){const e=r.prev,t=r,n=r.next;if(rn(e,t,n)>=0)return!1;const i=e.x,s=t.x,a=n.x,o=e.y,l=t.y,c=n.y,d=i<s?i<a?i:a:s<a?s:a,h=o<l?o<c?o:c:l<c?l:c,u=i>s?i>a?i:a:s>a?s:a,f=o>l?o>c?o:c:l>c?l:c;let m=n.next;for(;m!==e;){if(m.x>=d&&m.x<=u&&m.y>=h&&m.y<=f&&oa(i,o,s,l,a,c,m.x,m.y)&&rn(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Ix(r,e,t,n){const i=r.prev,s=r,a=r.next;if(rn(i,s,a)>=0)return!1;const o=i.x,l=s.x,c=a.x,d=i.y,h=s.y,u=a.y,f=o<l?o<c?o:c:l<c?l:c,m=d<h?d<u?d:u:h<u?h:u,v=o>l?o>c?o:c:l>c?l:c,g=d>h?d>u?d:u:h>u?h:u,b=fu(f,m,e,t,n),y=fu(v,g,e,t,n);let w=r.prevZ,_=r.nextZ;for(;w&&w.z>=b&&_&&_.z<=y;){if(w.x>=f&&w.x<=v&&w.y>=m&&w.y<=g&&w!==i&&w!==a&&oa(o,d,l,h,c,u,w.x,w.y)&&rn(w.prev,w,w.next)>=0||(w=w.prevZ,_.x>=f&&_.x<=v&&_.y>=m&&_.y<=g&&_!==i&&_!==a&&oa(o,d,l,h,c,u,_.x,_.y)&&rn(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;w&&w.z>=b;){if(w.x>=f&&w.x<=v&&w.y>=m&&w.y<=g&&w!==i&&w!==a&&oa(o,d,l,h,c,u,w.x,w.y)&&rn(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;_&&_.z<=y;){if(_.x>=f&&_.x<=v&&_.y>=m&&_.y<=g&&_!==i&&_!==a&&oa(o,d,l,h,c,u,_.x,_.y)&&rn(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function kx(r,e,t){let n=r;do{const i=n.prev,s=n.next.next;!Nc(i,s)&&zb(i,n,n.next,s)&&Eo(i,s)&&Eo(s,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),To(n),To(n.next),n=r=s),n=n.next}while(n!==r);return Mr(n)}function Ox(r,e,t,n,i,s){let a=r;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&jx(a,o)){let l=Hb(a,o);a=Mr(a,a.next),l=Mr(l,l.next),Mo(a,e,t,n,i,s,0),Mo(l,e,t,n,i,s,0);return}o=o.next}a=a.next}while(a!==r)}function Fx(r,e,t,n){const i=[];let s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*n,l=s<a-1?e[s+1]*n:r.length,c=Bb(r,o,l,n,!1),c===c.next&&(c.steiner=!0),i.push(Wx(c));for(i.sort(Ux),s=0;s<i.length;s++)t=Bx(i[s],t);return t}function Ux(r,e){return r.x-e.x}function Bx(r,e){const t=zx(r,e);if(!t)return e;const n=Hb(t,r);return Mr(n,n.next),Mr(t,t.next)}function zx(r,e){let t=e,n=-1/0,i;const s=r.x,a=r.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const u=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(u<=s&&u>n&&(n=u,i=t.x<t.next.x?t:t.next,u===s))return i}t=t.next}while(t!==e);if(!i)return null;const o=i,l=i.x,c=i.y;let d=1/0,h;t=i;do s>=t.x&&t.x>=l&&s!==t.x&&oa(a<c?s:n,a,l,c,a<c?n:s,a,t.x,t.y)&&(h=Math.abs(a-t.y)/(s-t.x),Eo(t,r)&&(h<d||h===d&&(t.x>i.x||t.x===i.x&&Hx(i,t)))&&(i=t,d=h)),t=t.next;while(t!==o);return i}function Hx(r,e){return rn(r.prev,r,e.prev)<0&&rn(e.next,r,r.next)<0}function Gx(r,e,t,n){let i=r;do i.z===0&&(i.z=fu(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,Vx(i)}function Vx(r){let e,t,n,i,s,a,o,l,c=1;do{for(t=r,r=null,s=null,a=0;t;){for(a++,n=t,o=0,e=0;e<c&&(o++,n=n.nextZ,!!n);e++);for(l=c;o>0||l>0&&n;)o!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,o--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(a>1);return r}function fu(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function Wx(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function oa(r,e,t,n,i,s,a,o){return(i-a)*(e-o)>=(r-a)*(s-o)&&(r-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(i-a)*(n-o)}function jx(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!Xx(r,e)&&(Eo(r,e)&&Eo(e,r)&&qx(r,e)&&(rn(r.prev,r,e.prev)||rn(r,e.prev,e))||Nc(r,e)&&rn(r.prev,r,r.next)>0&&rn(e.prev,e,e.next)>0)}function rn(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function Nc(r,e){return r.x===e.x&&r.y===e.y}function zb(r,e,t,n){const i=_l(rn(r,e,t)),s=_l(rn(r,e,n)),a=_l(rn(t,n,r)),o=_l(rn(t,n,e));return!!(i!==s&&a!==o||i===0&&xl(r,t,e)||s===0&&xl(r,n,e)||a===0&&xl(t,r,n)||o===0&&xl(t,e,n))}function xl(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function _l(r){return r>0?1:r<0?-1:0}function Xx(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&zb(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Eo(r,e){return rn(r.prev,r,r.next)<0?rn(r,e,r.next)>=0&&rn(r,r.prev,e)>=0:rn(r,e,r.prev)<0||rn(r,r.next,e)<0}function qx(r,e){let t=r,n=!1;const i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function Hb(r,e){const t=new pu(r.i,r.x,r.y),n=new pu(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Sp(r,e,t,n){const i=new pu(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function To(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function pu(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Zx(r,e,t,n){let i=0;for(let s=e,a=t-n;s<t;s+=n)i+=(r[a]-r[s])*(r[s+1]+r[a+1]),a=s;return i}class ga{static area(e){const t=e.length;let n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return ga.area(e)<0}static triangulateShape(e,t){const n=[],i=[],s=[];Mp(e),Ep(n,e);let a=e.length;t.forEach(Mp);for(let l=0;l<t.length;l++)i.push(a),a+=t[l].length,Ep(n,t[l]);const o=Dx.triangulate(n,i);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function Mp(r){const e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function Ep(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}class la extends Qu{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new la(e.radius,e.detail)}}class Qs extends mt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(i),c=o+1,d=l+1,h=e/o,u=t/l,f=[],m=[],v=[],g=[];for(let b=0;b<d;b++){const y=b*u-a;for(let w=0;w<c;w++){const _=w*h-s;m.push(_,-y,0),v.push(0,0,1),g.push(w/o),g.push(1-b/l)}}for(let b=0;b<l;b++)for(let y=0;y<o;y++){const w=y+c*b,_=y+c*(b+1),R=y+1+c*(b+1),T=y+1+c*b;f.push(w,_,T),f.push(_,R,T)}this.setIndex(f),this.setAttribute("position",new Fe(m,3)),this.setAttribute("normal",new Fe(v,3)),this.setAttribute("uv",new Fe(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qs(e.width,e.height,e.widthSegments,e.heightSegments)}}class Ju extends mt{constructor(e=.5,t=1,n=32,i=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:a},n=Math.max(3,n),i=Math.max(1,i);const o=[],l=[],c=[],d=[];let h=e;const u=(t-e)/i,f=new L,m=new ge;for(let v=0;v<=i;v++){for(let g=0;g<=n;g++){const b=s+g/n*a;f.x=h*Math.cos(b),f.y=h*Math.sin(b),l.push(f.x,f.y,f.z),c.push(0,0,1),m.x=(f.x/t+1)/2,m.y=(f.y/t+1)/2,d.push(m.x,m.y)}h+=u}for(let v=0;v<i;v++){const g=v*(n+1);for(let b=0;b<n;b++){const y=b+g,w=y,_=y+n+1,R=y+n+2,T=y+1;o.push(w,_,T),o.push(_,R,T)}}this.setIndex(o),this.setAttribute("position",new Fe(l,3)),this.setAttribute("normal",new Fe(c,3)),this.setAttribute("uv",new Fe(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ju(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class ef extends mt{constructor(e=new Ub([new ge(0,.5),new ge(-.5,-.5),new ge(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let d=0;d<e.length;d++)c(e[d]),this.addGroup(o,l,d),o+=l,l=0;this.setIndex(n),this.setAttribute("position",new Fe(i,3)),this.setAttribute("normal",new Fe(s,3)),this.setAttribute("uv",new Fe(a,2));function c(d){const h=i.length/3,u=d.extractPoints(t);let f=u.shape;const m=u.holes;ga.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,b=m.length;g<b;g++){const y=m[g];ga.isClockWise(y)===!0&&(m[g]=y.reverse())}const v=ga.triangulateShape(f,m);for(let g=0,b=m.length;g<b;g++){const y=m[g];f=f.concat(y)}for(let g=0,b=f.length;g<b;g++){const y=f[g];i.push(y.x,y.y,0),s.push(0,0,1),a.push(y.x,y.y)}for(let g=0,b=v.length;g<b;g++){const y=v[g],w=y[0]+h,_=y[1]+h,R=y[2]+h;n.push(w,_,R),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return Yx(t,e)}static fromJSON(e,t){const n=[];for(let i=0,s=e.shapes.length;i<s;i++){const a=t[e.shapes[i]];n.push(a)}return new ef(n,e.curveSegments)}}function Yx(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,n=r.length;t<n;t++){const i=r[t];e.shapes.push(i.uuid)}else e.shapes.push(r.uuid);return e}class Da extends mt{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const d=[],h=new L,u=new L,f=[],m=[],v=[],g=[];for(let b=0;b<=n;b++){const y=[],w=b/n;let _=0;b===0&&a===0?_=.5/t:b===n&&l===Math.PI&&(_=-.5/t);for(let R=0;R<=t;R++){const T=R/t;h.x=-e*Math.cos(i+T*s)*Math.sin(a+w*o),h.y=e*Math.cos(a+w*o),h.z=e*Math.sin(i+T*s)*Math.sin(a+w*o),m.push(h.x,h.y,h.z),u.copy(h).normalize(),v.push(u.x,u.y,u.z),g.push(T+_,1-w),y.push(c++)}d.push(y)}for(let b=0;b<n;b++)for(let y=0;y<t;y++){const w=d[b][y+1],_=d[b][y],R=d[b+1][y],T=d[b+1][y+1];(b!==0||a>0)&&f.push(w,_,T),(b!==n-1||l<Math.PI)&&f.push(_,R,T)}this.setIndex(f),this.setAttribute("position",new Fe(m,3)),this.setAttribute("normal",new Fe(v,3)),this.setAttribute("uv",new Fe(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Da(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class mr extends mt{constructor(e=1,t=.4,n=12,i=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:s},n=Math.floor(n),i=Math.floor(i);const a=[],o=[],l=[],c=[],d=new L,h=new L,u=new L;for(let f=0;f<=n;f++)for(let m=0;m<=i;m++){const v=m/i*s,g=f/n*Math.PI*2;h.x=(e+t*Math.cos(g))*Math.cos(v),h.y=(e+t*Math.cos(g))*Math.sin(v),h.z=t*Math.sin(g),o.push(h.x,h.y,h.z),d.x=e*Math.cos(v),d.y=e*Math.sin(v),u.subVectors(h,d).normalize(),l.push(u.x,u.y,u.z),c.push(m/i),c.push(f/n)}for(let f=1;f<=n;f++)for(let m=1;m<=i;m++){const v=(i+1)*f+m-1,g=(i+1)*(f-1)+m-1,b=(i+1)*(f-1)+m,y=(i+1)*f+m;a.push(v,g,y),a.push(g,b,y)}this.setIndex(a),this.setAttribute("position",new Fe(o,3)),this.setAttribute("normal",new Fe(l,3)),this.setAttribute("uv",new Fe(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mr(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Kx extends mt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new L,s=new L;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,d=l.length;c<d;++c){const h=l[c],u=h.start,f=h.count;for(let m=u,v=u+f;m<v;m+=3)for(let g=0;g<3;g++){const b=o.getX(m+g),y=o.getX(m+(g+1)%3);i.fromBufferAttribute(a,b),s.fromBufferAttribute(a,y),Tp(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const d=3*o+c,h=3*o+(c+1)%3;i.fromBufferAttribute(a,d),s.fromBufferAttribute(a,h),Tp(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Fe(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Tp(r,e,t){const n=`${r.x},${r.y},${r.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${r.x},${r.y},${r.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}class $x extends wn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Dc extends yi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Le(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Le(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ac,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class is extends Dc{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ge(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return yt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Le(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Le(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Le(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Ri extends yi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Le(16777215),this.specular=new Le(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Le(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ac,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dn,this.combine=Ec,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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.flatShading=e.flatShading,this.fog=e.fog,this}}class On extends yi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Le(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Le(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ac,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dn,this.combine=Ec,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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.flatShading=e.flatShading,this.fog=e.fog,this}}class Gb extends yi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=p0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Qx extends yi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function wl(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function Jx(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function e_(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function Ap(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let l=0;l!==e;++l)i[a++]=r[o+l]}return i}function Vb(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push(...a)),s=r[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=r[i++];while(s!==void 0)}class Ro{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let a;t:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=i,i=t[++n],e<i)break e}a=t.length;break t}if(!(e>=s)){const o=t[1];e<o&&(n=2,s=o);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break e}a=n,n=0;break t}break n}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let a=0;a!==i;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class t_ extends Ro{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:kf,endingEnd:kf}}intervalChanged_(e,t,n){const i=this.parameterPositions;let s=e-2,a=e+1,o=i[s],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case Of:s=e,o=2*t-n;break;case Ff:s=i.length-2,o=t+i[s]-i[s+1];break;default:s=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Of:a=e,l=2*n-t;break;case Ff:a=1,l=n+i[1]-i[0];break;default:a=e-1,l=t}const c=(n-t)*.5,d=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=s*d,this._offsetNext=a*d}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,d=this._offsetPrev,h=this._offsetNext,u=this._weightPrev,f=this._weightNext,m=(n-t)/(i-t),v=m*m,g=v*m,b=-u*g+2*u*v-u*m,y=(1+u)*g+(-1.5-2*u)*v+(-.5+u)*m+1,w=(-1-f)*g+(1.5+f)*v+.5*m,_=f*g-f*v;for(let R=0;R!==o;++R)s[R]=b*a[d+R]+y*a[c+R]+w*a[l+R]+_*a[h+R];return s}}class n_ extends Ro{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,d=(n-t)/(i-t),h=1-d;for(let u=0;u!==o;++u)s[u]=a[c+u]*h+a[l+u]*d;return s}}class i_ extends Ro{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class ss{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=wl(t,this.TimeBufferType),this.values=wl(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:wl(e.times,Array),values:wl(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new i_(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new n_(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new t_(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case xo:t=this.InterpolantFactoryMethodDiscrete;break;case _o:t=this.InterpolantFactoryMethodLinear;break;case Vc:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return xo;case this.InterpolantFactoryMethodLinear:return _o;case this.InterpolantFactoryMethodSmooth:return Vc}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let s=0,a=i-1;for(;s!==i&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&Jx(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Vc,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],d=e[o+1];if(c!==d&&(o!==1||c!==e[0]))if(i)l=!0;else{const h=o*n,u=h-n,f=h+n;for(let m=0;m!==n;++m){const v=t[h+m];if(v!==t[u+m]||v!==t[f+m]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*n,u=a*n;for(let f=0;f!==n;++f)t[u+f]=t[h+f]}++a}}if(s>0){e[a]=e[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}ss.prototype.TimeBufferType=Float32Array;ss.prototype.ValueBufferType=Float32Array;ss.prototype.DefaultInterpolation=_o;class La extends ss{constructor(e,t,n){super(e,t,n)}}La.prototype.ValueTypeName="bool";La.prototype.ValueBufferType=Array;La.prototype.DefaultInterpolation=xo;La.prototype.InterpolantFactoryMethodLinear=void 0;La.prototype.InterpolantFactoryMethodSmooth=void 0;class Wb extends ss{}Wb.prototype.ValueTypeName="color";class Er extends ss{}Er.prototype.ValueTypeName="number";class s_ extends Ro{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let d=c+o;c!==d;c+=4)Dt.slerpFlat(s,0,a,c-o,a,c,l);return s}}class Ss extends ss{InterpolantFactoryMethodLinear(e){return new s_(this.times,this.values,this.getValueSize(),e)}}Ss.prototype.ValueTypeName="quaternion";Ss.prototype.InterpolantFactoryMethodSmooth=void 0;class Ia extends ss{constructor(e,t,n){super(e,t,n)}}Ia.prototype.ValueTypeName="string";Ia.prototype.ValueBufferType=Array;Ia.prototype.DefaultInterpolation=xo;Ia.prototype.InterpolantFactoryMethodLinear=void 0;Ia.prototype.InterpolantFactoryMethodSmooth=void 0;class Ms extends ss{}Ms.prototype.ValueTypeName="vector";class vc{constructor(e="",t=-1,n=[],i=u0){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Ni(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(a_(n[a]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(ss.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const d=e_(l);l=Ap(l,1,d),c=Ap(c,1,d),!i&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new Er(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],d=c.name.match(s);if(d&&d.length>1){const h=d[1];let u=i[h];u||(i[h]=u=[]),u.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,u,f,m,v){if(f.length!==0){const g=[],b=[];Vb(f,g,b,m),g.length!==0&&v.push(new h(u,g,b))}},i=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const u=c[h].keys;if(!(!u||u.length===0))if(u[0].morphTargets){const f={};let m;for(m=0;m<u.length;m++)if(u[m].morphTargets)for(let v=0;v<u[m].morphTargets.length;v++)f[u[m].morphTargets[v]]=-1;for(const v in f){const g=[],b=[];for(let y=0;y!==u[m].morphTargets.length;++y){const w=u[m];g.push(w.time),b.push(w.morphTarget===v?1:0)}i.push(new Er(".morphTargetInfluence["+v+"]",g,b))}l=f.length*a}else{const f=".bones["+t[h].name+"]";n(Ms,f+".position",u,"pos",i),n(Ss,f+".quaternion",u,"rot",i),n(Ms,f+".scale",u,"scl",i)}}return i.length===0?null:new this(s,l,i,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function r_(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Er;case"vector":case"vector2":case"vector3":case"vector4":return Ms;case"color":return Wb;case"quaternion":return Ss;case"bool":case"boolean":return La;case"string":return Ia}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function a_(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=r_(r.type);if(r.times===void 0){const t=[],n=[];Vb(r.keys,t,n,"value"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const qs={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class Lc{constructor(e,t,n){const i=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(d){o++,s===!1&&i.onStart!==void 0&&i.onStart(d,a,o),s=!0},this.itemEnd=function(d){a++,i.onProgress!==void 0&&i.onProgress(d,a,o),a===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(d){i.onError!==void 0&&i.onError(d)},this.resolveURL=function(d){return l?l(d):d},this.setURLModifier=function(d){return l=d,this},this.addHandler=function(d,h){return c.push(d,h),this},this.removeHandler=function(d){const h=c.indexOf(d);return h!==-1&&c.splice(h,2),this},this.getHandler=function(d){for(let h=0,u=c.length;h<u;h+=2){const f=c[h],m=c[h+1];if(f.global&&(f.lastIndex=0),f.test(d))return m}return null}}}const jb=new Lc;class di{constructor(e){this.manager=e!==void 0?e:jb,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}di.DEFAULT_MATERIAL_NAME="__DEFAULT";const fs={};class o_ extends Error{constructor(e,t){super(e),this.response=t}}class $s extends di{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=qs.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(fs[e]!==void 0){fs[e].push({onLoad:t,onProgress:n,onError:i});return}fs[e]=[],fs[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const d=fs[e],h=c.body.getReader(),u=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=u?parseInt(u):0,m=f!==0;let v=0;const g=new ReadableStream({start(b){y();function y(){h.read().then(({done:w,value:_})=>{if(w)b.close();else{v+=_.byteLength;const R=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:f});for(let T=0,P=d.length;T<P;T++){const M=d[T];M.onProgress&&M.onProgress(R)}b.enqueue(_),y()}},w=>{b.error(w)})}}});return new Response(g)}else throw new o_(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(d=>new DOMParser().parseFromString(d,o));case"json":return c.json();default:if(o===void 0)return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),u=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(u);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{qs.add(e,c);const d=fs[e];delete fs[e];for(let h=0,u=d.length;h<u;h++){const f=d[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{const d=fs[e];if(d===void 0)throw this.manager.itemError(e),c;delete fs[e];for(let h=0,u=d.length;h<u;h++){const f=d[h];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class l_ extends di{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=qs.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=wo("img");function l(){d(),qs.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){d(),i&&i(h),s.manager.itemError(e),s.manager.itemEnd(e)}function d(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class c_ extends di{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new Zu,o=new $s(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(d){if(i!==void 0)i(d);else{console.error(d);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:li,a.wrapT=c.wrapT!==void 0?c.wrapT:li,a.magFilter=c.magFilter!==void 0?c.magFilter:bn,a.minFilter=c.minFilter!==void 0?c.minFilter:bn,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=Gi),c.mipmapCount===1&&(a.minFilter=bn),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},n,i),a}}class No extends di{constructor(e){super(e)}load(e,t,n,i){const s=new Bt,a=new l_(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class Do extends Pt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Le(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class Cp extends Do{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Le(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const yd=new ke,Pp=new L,Rp=new L;class tf{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ge(512,512),this.map=null,this.mapPass=null,this.matrix=new ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Cc,this._frameExtents=new ge(1,1),this._viewportCount=1,this._viewports=[new _t(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Pp.setFromMatrixPosition(e.matrixWorld),t.position.copy(Pp),Rp.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Rp),t.updateMatrixWorld(),yd.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yd),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(yd)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class d_ extends tf{constructor(){super(new gn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=Ta*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class nf extends Do{constructor(e,t,n=0,i=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new d_}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Np=new ke,$a=new L,xd=new L;class h_ extends tf{constructor(){super(new gn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ge(4,2),this._viewportCount=6,this._viewports=[new _t(2,1,1,1),new _t(0,1,1,1),new _t(3,1,1,1),new _t(1,1,1,1),new _t(3,0,1,1),new _t(1,0,1,1)],this._cubeDirections=[new L(1,0,0),new L(-1,0,0),new L(0,0,1),new L(0,0,-1),new L(0,1,0),new L(0,-1,0)],this._cubeUps=[new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,0,1),new L(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),$a.setFromMatrixPosition(e.matrixWorld),n.position.copy($a),xd.copy(n.position),xd.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(xd),n.updateMatrixWorld(),i.makeTranslation(-$a.x,-$a.y,-$a.z),Np.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Np)}}class yc extends Do{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new h_}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Lo extends Cb{constructor(e=-1,t=1,n=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class u_ extends tf{constructor(){super(new Lo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ic extends Do{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.shadow=new u_}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Xb extends Do{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ks{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class f_ extends mt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class p_ extends di{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=qs.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{i&&i(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return qs.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){i&&i(c),qs.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});qs.add(e,l),s.manager.itemStart(e)}}class m_ extends gn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e,this.index=0}}class sf{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Dp(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=Dp();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Dp(){return performance.now()}const rf="\\[\\]\\.:\\/",g_=new RegExp("["+rf+"]","g"),af="[^"+rf+"]",b_="[^"+rf.replace("\\.","")+"]",v_=/((?:WC+[\/:])*)/.source.replace("WC",af),y_=/(WCOD+)?/.source.replace("WCOD",b_),x_=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",af),__=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",af),w_=new RegExp("^"+v_+y_+x_+__+"$"),S_=["material","materials","bones","map"];class M_{constructor(e,t,n){const i=n||Nt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Nt{constructor(e,t,n){this.path=t,this.parsedPath=n||Nt.parseTrackName(t),this.node=Nt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Nt.Composite(e,t,n):new Nt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(g_,"")}static parseTrackName(e){const t=w_.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);S_.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let s=t.propertyIndex;if(e||(e=Nt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let d=0;d<e.length;d++)if(e[d].name===c){c=d;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[i];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Nt.Composite=M_;Nt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Nt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Nt.prototype.GetterByBindingType=[Nt.prototype._getValue_direct,Nt.prototype._getValue_array,Nt.prototype._getValue_arrayElement,Nt.prototype._getValue_toArray];Nt.prototype.SetterByBindingTypeAndVersioning=[[Nt.prototype._setValue_direct,Nt.prototype._setValue_direct_setNeedsUpdate,Nt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Nt.prototype._setValue_array,Nt.prototype._setValue_array_setNeedsUpdate,Nt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Nt.prototype._setValue_arrayElement,Nt.prototype._setValue_arrayElement_setNeedsUpdate,Nt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Nt.prototype._setValue_fromArray,Nt.prototype._setValue_fromArray_setNeedsUpdate,Nt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class mu extends Xu{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}const Lp=new ke;class of{constructor(e,t,n=0,i=1/0){this.ray=new Ra(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Vu,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Lp.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Lp),this}intersectObject(e,t=!0,n=[]){return gu(e,this,n,t),n.sort(Ip),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)gu(e[i],this,n,t);return n.sort(Ip),n}}function Ip(r,e){return r.distance-e.distance}function gu(r,e,t,n){let i=!0;if(r.layers.test(e.layers)&&r.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const s=r.children;for(let a=0,o=s.length;a<o;a++)gu(s[a],e,t,!0)}}class kp{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=yt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(yt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const Op=new ge;class br{constructor(e=new ge(1/0,1/0),t=new ge(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Op.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Op).distanceTo(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}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 Fp=new L,Sl=new L;class E_{constructor(e=new L,t=new L){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Fp.subVectors(e,this.start),Sl.subVectors(this.end,this.start);const n=Sl.dot(Sl);let s=Sl.dot(Fp)/n;return t&&(s=yt(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Up=new L;let Ml,_d;class T_ extends Pt{constructor(e=new L(0,0,1),t=new L(0,0,0),n=1,i=16776960,s=n*.2,a=s*.2){super(),this.type="ArrowHelper",Ml===void 0&&(Ml=new mt,Ml.setAttribute("position",new Fe([0,0,0,0,1,0],3)),_d=new Pn(0,.5,1,5,1),_d.translate(0,-.5,0)),this.position.copy(t),this.line=new Wn(Ml,new Yn({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ae(_d,new jt({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Up.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Up,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class ka extends Pr{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new mt;i.setAttribute("position",new Fe(t,3)),i.setAttribute("color",new Fe(n,3));const s=new Yn({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){const i=new Le,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class qb extends Cr{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}function Bp(r,e,t,n){const i=A_(n);switch(t){case mb:return r*e;case bb:return r*e;case vb:return r*e*2;case Fu:return r*e/i.components*i.byteLength;case Uu:return r*e/i.components*i.byteLength;case yb:return r*e*2/i.components*i.byteLength;case Bu:return r*e*2/i.components*i.byteLength;case gb:return r*e*3/i.components*i.byteLength;case Zn:return r*e*4/i.components*i.byteLength;case zu:return r*e*4/i.components*i.byteLength;case tc:case nc:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case ic:case sc:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Oh:case Uh:return Math.max(r,16)*Math.max(e,8)/4;case kh:case Fh:return Math.max(r,8)*Math.max(e,8)/2;case Bh:case zh:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Hh:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Gh:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Vh:return Math.floor((r+4)/5)*Math.floor((e+3)/4)*16;case Wh:return Math.floor((r+4)/5)*Math.floor((e+4)/5)*16;case jh:return Math.floor((r+5)/6)*Math.floor((e+4)/5)*16;case Xh:return Math.floor((r+5)/6)*Math.floor((e+5)/6)*16;case qh:return Math.floor((r+7)/8)*Math.floor((e+4)/5)*16;case Zh:return Math.floor((r+7)/8)*Math.floor((e+5)/6)*16;case Yh:return Math.floor((r+7)/8)*Math.floor((e+7)/8)*16;case Kh:return Math.floor((r+9)/10)*Math.floor((e+4)/5)*16;case $h:return Math.floor((r+9)/10)*Math.floor((e+5)/6)*16;case Qh:return Math.floor((r+9)/10)*Math.floor((e+7)/8)*16;case Jh:return Math.floor((r+9)/10)*Math.floor((e+9)/10)*16;case eu:return Math.floor((r+11)/12)*Math.floor((e+9)/10)*16;case tu:return Math.floor((r+11)/12)*Math.floor((e+11)/12)*16;case rc:case nu:case iu:return Math.ceil(r/4)*Math.ceil(e/4)*16;case xb:case su:return Math.ceil(r/4)*Math.ceil(e/4)*8;case ru:case au:return Math.ceil(r/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function A_(r){switch(r){case ws:case ub:return{byteLength:1,components:1};case yo:case fb:case Ti:return{byteLength:2,components:1};case ku:case Ou:return{byteLength:2,components:4};case Sr:case Iu:case Vi:return{byteLength:4,components:1};case pb:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:vr}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=vr);/**
|
|
68
|
+
`},i=new Kt(5,5,5),s=new wn({name:"CubemapFromEquirect",uniforms:Aa(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:ci,blending:Xi});s.uniforms.tEquirect.value=t;const a=new Ae(i,s),o=t.minFilter;return t.minFilter===Gi&&(t.minFilter=bn),new cx(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(s)}}class Vt extends Pt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const hx={type:"move"};class cd{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Vt,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Vt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Vt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const g=t.getJointPose(v,n),b=this._getHandJoint(c,v);g!==null&&(b.matrix.fromArray(g.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=g.radius),b.visible=g!==null}const d=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],u=d.position.distanceTo(h.position),f=.02,m=.005;c.inputState.pinching&&u>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(hx)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Vt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class cu extends Pt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new dn,this.environmentIntensity=1,this.environmentRotation=new dn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Xu{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=lu,this.updateRanges=[],this.version=0,this.uuid=Ni()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ni()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ni()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Qn=new L;class Wi{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Qn.fromBufferAttribute(this,t),Qn.applyMatrix4(e),this.setXYZ(t,Qn.x,Qn.y,Qn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Qn.fromBufferAttribute(this,t),Qn.applyNormalMatrix(e),this.setXYZ(t,Qn.x,Qn.y,Qn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Qn.fromBufferAttribute(this,t),Qn.transformDirection(e),this.setXYZ(t,Qn.x,Qn.y,Qn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=zi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Gt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Gt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Gt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Gt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Gt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=zi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=zi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=zi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=zi(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Gt(t,this.array),n=Gt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Gt(t,this.array),n=Gt(n,this.array),i=Gt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Gt(t,this.array),n=Gt(n,this.array),i=Gt(i,this.array),s=Gt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new vn(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Wi(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class ux extends yi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Le(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Zr;const ja=new L,Yr=new L,Kr=new L,$r=new ge,Xa=new ge,Rb=new ke,al=new L,qa=new L,ol=new L,rp=new ge,dd=new ge,ap=new ge;class wN extends Pt{constructor(e=new ux){if(super(),this.isSprite=!0,this.type="Sprite",Zr===void 0){Zr=new mt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Xu(t,5);Zr.setIndex([0,1,2,0,2,3]),Zr.setAttribute("position",new Wi(n,3,0,!1)),Zr.setAttribute("uv",new Wi(n,2,3,!1))}this.geometry=Zr,this.material=e,this.center=new ge(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Yr.setFromMatrixScale(this.matrixWorld),Rb.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Kr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Yr.multiplyScalar(-Kr.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const a=this.center;ll(al.set(-.5,-.5,0),Kr,a,Yr,i,s),ll(qa.set(.5,-.5,0),Kr,a,Yr,i,s),ll(ol.set(.5,.5,0),Kr,a,Yr,i,s),rp.set(0,0),dd.set(1,0),ap.set(1,1);let o=e.ray.intersectTriangle(al,qa,ol,!1,ja);if(o===null&&(ll(qa.set(-.5,.5,0),Kr,a,Yr,i,s),dd.set(0,1),o=e.ray.intersectTriangle(al,ol,qa,!1,ja),o===null))return;const l=e.ray.origin.distanceTo(ja);l<e.near||l>e.far||t.push({distance:l,point:ja.clone(),uv:bi.getInterpolation(ja,al,qa,ol,rp,dd,ap,new ge),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ll(r,e,t,n,i,s){$r.subVectors(r,t).addScalar(.5).multiply(n),i!==void 0?(Xa.x=s*$r.x-i*$r.y,Xa.y=i*$r.x+s*$r.y):Xa.copy($r),r.copy(e),r.x+=Xa.x,r.y+=Xa.y,r.applyMatrix4(Rb)}const op=new L,lp=new _t,cp=new _t,fx=new L,dp=new ke,cl=new L,hd=new ni,hp=new ke,ud=new Ra;class qu extends Ae{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=If,this.bindMatrix=new ke,this.bindMatrixInverse=new ke,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ln),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,cl),this.boundingBox.expandByPoint(cl)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ni),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,cl),this.boundingSphere.expandByPoint(cl)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),hd.copy(this.boundingSphere),hd.applyMatrix4(i),e.ray.intersectsSphere(hd)!==!1&&(hp.copy(i).invert(),ud.copy(e.ray).applyMatrix4(hp),!(this.boundingBox!==null&&ud.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ud)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new _t,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===If?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===h0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;lp.fromBufferAttribute(i.attributes.skinIndex,e),cp.fromBufferAttribute(i.attributes.skinWeight,e),op.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=cp.getComponent(s);if(a!==0){const o=lp.getComponent(s);dp.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(fx.copy(op).applyMatrix4(dp),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class So extends Pt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Zu extends Bt{constructor(e=null,t=1,n=1,i,s,a,o,l,c=Sn,d=Sn,h,u){super(null,a,o,l,c,d,i,s,h,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const up=new ke,px=new ke;class Po{constructor(e=[],t=[]){this.uuid=Ni(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new ke)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new ke;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:px;up.multiplyMatrices(o,t[s]),up.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Po(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Zu(t,e,e,Zn,Vi);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const s=e.bones[n];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new So),this.bones.push(a),this.boneInverses.push(new ke().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class du extends vn{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Qr=new ke,fp=new ke,dl=[],pp=new ln,mx=new ke,Za=new Ae,Ya=new ni;class gx extends Ae{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new du(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,mx)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ln),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Qr),pp.copy(e.boundingBox).applyMatrix4(Qr),this.boundingBox.union(pp)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ni),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Qr),Ya.copy(e.boundingSphere).applyMatrix4(Qr),this.boundingSphere.union(Ya)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,s=n.length+1,a=e*s+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Za.geometry=this.geometry,Za.material=this.material,Za.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ya.copy(this.boundingSphere),Ya.applyMatrix4(n),e.ray.intersectsSphere(Ya)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,Qr),fp.multiplyMatrices(n,Qr),Za.matrixWorld=fp,Za.raycast(e,dl);for(let a=0,o=dl.length;a<o;a++){const l=dl[a];l.instanceId=s,l.object=this,t.push(l)}dl.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new du(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Zu(new Float32Array(i*this.count),i,this.count,Fu,Vi));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<n.length;c++)a+=n[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=i*e;s[l]=o,s.set(n,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const fd=new L,bx=new L,vx=new xt;class Vs{constructor(e=new L(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=fd.subVectors(n,t).cross(bx.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(fd),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||vx.getNormalMatrix(e),i=this.coplanarPoint(fd).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const sr=new ni,hl=new L;class Cc{constructor(e=new Vs,t=new Vs,n=new Vs,i=new Vs,s=new Vs,a=new Vs){this.planes=[e,t,n,i,s,a]}set(e,t,n,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ys){const n=this.planes,i=e.elements,s=i[0],a=i[1],o=i[2],l=i[3],c=i[4],d=i[5],h=i[6],u=i[7],f=i[8],m=i[9],v=i[10],g=i[11],b=i[12],y=i[13],w=i[14],_=i[15];if(n[0].setComponents(l-s,u-c,g-f,_-b).normalize(),n[1].setComponents(l+s,u+c,g+f,_+b).normalize(),n[2].setComponents(l+a,u+d,g+m,_+y).normalize(),n[3].setComponents(l-a,u-d,g-m,_-y).normalize(),n[4].setComponents(l-o,u-h,g-v,_-w).normalize(),t===ys)n[5].setComponents(l+o,u+h,g+v,_+w).normalize();else if(t===mc)n[5].setComponents(o,h,v,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),sr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),sr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(sr)}intersectsSprite(e){return sr.center.set(0,0,0),sr.radius=.7071067811865476,sr.applyMatrix4(e.matrixWorld),this.intersectsSphere(sr)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(hl.x=i.normal.x>0?e.max.x:e.min.x,hl.y=i.normal.y>0?e.max.y:e.min.y,hl.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(hl)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Yn extends yi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Le(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const gc=new L,bc=new L,mp=new ke,Ka=new Ra,ul=new ni,pd=new L,gp=new L;class Wn extends Pt{constructor(e=new mt,t=new Yn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)gc.fromBufferAttribute(t,i-1),bc.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=gc.distanceTo(bc);e.setAttribute("lineDistance",new Fe(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ul.copy(n.boundingSphere),ul.applyMatrix4(i),ul.radius+=s,e.ray.intersectsSphere(ul)===!1)return;mp.copy(i).invert(),Ka.copy(e.ray).applyMatrix4(mp);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,d=n.index,u=n.attributes.position;if(d!==null){const f=Math.max(0,a.start),m=Math.min(d.count,a.start+a.count);for(let v=f,g=m-1;v<g;v+=c){const b=d.getX(v),y=d.getX(v+1),w=fl(this,e,Ka,l,b,y,v);w&&t.push(w)}if(this.isLineLoop){const v=d.getX(m-1),g=d.getX(f),b=fl(this,e,Ka,l,v,g,m-1);b&&t.push(b)}}else{const f=Math.max(0,a.start),m=Math.min(u.count,a.start+a.count);for(let v=f,g=m-1;v<g;v+=c){const b=fl(this,e,Ka,l,v,v+1,v);b&&t.push(b)}if(this.isLineLoop){const v=fl(this,e,Ka,l,m-1,f,m-1);v&&t.push(v)}}}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}}}}}function fl(r,e,t,n,i,s,a){const o=r.geometry.attributes.position;if(gc.fromBufferAttribute(o,i),bc.fromBufferAttribute(o,s),t.distanceSqToSegment(gc,bc,pd,gp)>n)return;pd.applyMatrix4(r.matrixWorld);const c=e.ray.origin.distanceTo(pd);if(!(c<e.near||c>e.far))return{distance:c,point:gp.clone().applyMatrix4(r.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:r}}const bp=new L,vp=new L;class Pr extends Wn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)bp.fromBufferAttribute(t,i),vp.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+bp.distanceTo(vp);e.setAttribute("lineDistance",new Fe(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Nb extends Wn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class aa extends yi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Le(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const yp=new ke,hu=new Ra,pl=new ni,ml=new L;class lo extends Pt{constructor(e=new mt,t=new aa){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),pl.copy(n.boundingSphere),pl.applyMatrix4(i),pl.radius+=s,e.ray.intersectsSphere(pl)===!1)return;yp.copy(i).invert(),hu.copy(e.ray).applyMatrix4(yp);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,h=n.attributes.position;if(c!==null){const u=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let m=u,v=f;m<v;m++){const g=c.getX(m);ml.fromBufferAttribute(h,g),xp(ml,g,l,i,e,t,this)}}else{const u=Math.max(0,a.start),f=Math.min(h.count,a.start+a.count);for(let m=u,v=f;m<v;m++)ml.fromBufferAttribute(h,m),xp(ml,m,l,i,e,t,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}}}}}function xp(r,e,t,n,i,s,a){const o=hu.distanceSqToPoint(r);if(o<t){const l=new L;hu.closestPointToPoint(r,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class SN extends Bt{constructor(e,t,n,i,s,a,o,l,c){super(e,t,n,i,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Db extends Bt{constructor(e,t,n,i,s,a,o,l,c,d=fa){if(d!==fa&&d!==Ea)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&d===fa&&(n=Sr),n===void 0&&d===Ea&&(n=Ma),super(null,i,s,a,o,l,d,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:Sn,this.minFilter=l!==void 0?l:Sn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Gu(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Zi{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let i=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),c=n[i]-a,c<0)o=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(s-1);const d=n[i],u=n[i+1]-d,f=(a-d)/u;return(i+f)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const a=this.getPoint(i),o=this.getPoint(s),l=t||(a.isVector2?new ge:new L);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new L,i=[],s=[],a=[],o=new L,l=new ke;for(let f=0;f<=e;f++){const m=f/e;i[f]=this.getTangentAt(m,new L)}s[0]=new L,a[0]=new L;let c=Number.MAX_VALUE;const d=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);d<=c&&(c=d,n.set(1,0,0)),h<=c&&(c=h,n.set(0,1,0)),u<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),a[0].crossVectors(i[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(i[f-1],i[f]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(yt(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(o,m))}a[f].crossVectors(i[f],s[f])}if(t===!0){let f=Math.acos(yt(s[0].dot(s[e]),-1,1));f/=e,i[0].dot(o.crossVectors(s[0],s[e]))>0&&(f=-f);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),a[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Yu extends Zi{constructor(e=0,t=0,n=1,i=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new ge){const n=t,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(a?s=0:s=i),this.aClockwise===!0&&!a&&(s===i?s=-i:s=s-i);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const d=Math.cos(this.aRotation),h=Math.sin(this.aRotation),u=l-this.aX,f=c-this.aY;l=u*d-f*h+this.aX,c=u*h+f*d+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class yx extends Yu{constructor(e,t,n,i,s,a){super(e,t,n,n,i,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Ku(){let r=0,e=0,t=0,n=0;function i(s,a,o,l){r=s,e=o,t=-3*s+3*a-2*o-l,n=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){i(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,d,h){let u=(a-s)/c-(o-s)/(c+d)+(o-a)/d,f=(o-a)/d-(l-a)/(d+h)+(l-o)/h;u*=d,f*=d,i(a,o,u,f)},calc:function(s){const a=s*s,o=a*s;return r+e*s+t*a+n*o}}}const gl=new L,md=new Ku,gd=new Ku,bd=new Ku;class xx extends Zi{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new L){const n=t,i=this.points,s=i.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,d;this.closed||o>0?c=i[(o-1)%s]:(gl.subVectors(i[0],i[1]).add(i[0]),c=gl);const h=i[o%s],u=i[(o+1)%s];if(this.closed||o+2<s?d=i[(o+2)%s]:(gl.subVectors(i[s-1],i[s-2]).add(i[s-1]),d=gl),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(h),f),v=Math.pow(h.distanceToSquared(u),f),g=Math.pow(u.distanceToSquared(d),f);v<1e-4&&(v=1),m<1e-4&&(m=v),g<1e-4&&(g=v),md.initNonuniformCatmullRom(c.x,h.x,u.x,d.x,m,v,g),gd.initNonuniformCatmullRom(c.y,h.y,u.y,d.y,m,v,g),bd.initNonuniformCatmullRom(c.z,h.z,u.z,d.z,m,v,g)}else this.curveType==="catmullrom"&&(md.initCatmullRom(c.x,h.x,u.x,d.x,this.tension),gd.initCatmullRom(c.y,h.y,u.y,d.y,this.tension),bd.initCatmullRom(c.z,h.z,u.z,d.z,this.tension));return n.set(md.calc(l),gd.calc(l),bd.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new L().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function _p(r,e,t,n,i){const s=(n-e)*.5,a=(i-t)*.5,o=r*r,l=r*o;return(2*t-2*n+s+a)*l+(-3*t+3*n-2*s-a)*o+s*r+t}function _x(r,e){const t=1-r;return t*t*e}function wx(r,e){return 2*(1-r)*r*e}function Sx(r,e){return r*r*e}function po(r,e,t,n){return _x(r,e)+wx(r,t)+Sx(r,n)}function Mx(r,e){const t=1-r;return t*t*t*e}function Ex(r,e){const t=1-r;return 3*t*t*r*e}function Tx(r,e){return 3*(1-r)*r*r*e}function Ax(r,e){return r*r*r*e}function mo(r,e,t,n,i){return Mx(r,e)+Ex(r,t)+Tx(r,n)+Ax(r,i)}class Lb extends Zi{constructor(e=new ge,t=new ge,n=new ge,i=new ge){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new ge){const n=t,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(mo(e,i.x,s.x,a.x,o.x),mo(e,i.y,s.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Cx extends Zi{constructor(e=new L,t=new L,n=new L,i=new L){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new L){const n=t,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(mo(e,i.x,s.x,a.x,o.x),mo(e,i.y,s.y,a.y,o.y),mo(e,i.z,s.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Ib extends Zi{constructor(e=new ge,t=new ge){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ge){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ge){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Px extends Zi{constructor(e=new L,t=new L){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new L){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new L){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class kb extends Zi{constructor(e=new ge,t=new ge,n=new ge){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new ge){const n=t,i=this.v0,s=this.v1,a=this.v2;return n.set(po(e,i.x,s.x,a.x),po(e,i.y,s.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Rx extends Zi{constructor(e=new L,t=new L,n=new L){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new L){const n=t,i=this.v0,s=this.v1,a=this.v2;return n.set(po(e,i.x,s.x,a.x),po(e,i.y,s.y,a.y),po(e,i.z,s.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Ob extends Zi{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ge){const n=t,i=this.points,s=(i.length-1)*e,a=Math.floor(s),o=s-a,l=i[a===0?a:a-1],c=i[a],d=i[a>i.length-2?i.length-1:a+1],h=i[a>i.length-3?i.length-1:a+2];return n.set(_p(o,l.x,c.x,d.x,h.x),_p(o,l.y,c.y,d.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new ge().fromArray(i))}return this}}var wp=Object.freeze({__proto__:null,ArcCurve:yx,CatmullRomCurve3:xx,CubicBezierCurve:Lb,CubicBezierCurve3:Cx,EllipseCurve:Yu,LineCurve:Ib,LineCurve3:Px,QuadraticBezierCurve:kb,QuadraticBezierCurve3:Rx,SplineCurve:Ob});class Nx extends Zi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new wp[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const a=i[s]-n,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const a=s[i],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const d=l[c];n&&n.equals(d)||(t.push(d),n=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new wp[i.type]().fromJSON(i))}return this}}class uu extends Nx{constructor(e){super(),this.type="Path",this.currentPoint=new ge,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new Ib(this.currentPoint.clone(),new ge(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const s=new kb(this.currentPoint.clone(),new ge(e,t),new ge(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,a){const o=new Lb(this.currentPoint.clone(),new ge(e,t),new ge(n,i),new ge(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Ob(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,n,i,s,a),this}absarc(e,t,n,i,s,a){return this.absellipse(e,t,n,n,i,s,a),this}ellipse(e,t,n,i,s,a,o,l){const c=this.currentPoint.x,d=this.currentPoint.y;return this.absellipse(e+c,t+d,n,i,s,a,o,l),this}absellipse(e,t,n,i,s,a,o,l){const c=new Yu(e,t,n,i,s,a,o,l);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const d=c.getPoint(1);return this.currentPoint.copy(d),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class $u extends mt{constructor(e=[new ge(0,-.5),new ge(.5,0),new ge(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=yt(i,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],d=1/t,h=new L,u=new ge,f=new L,m=new L,v=new L;let g=0,b=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,b=e[y+1].y-e[y].y,f.x=b*1,f.y=-g,f.z=b*0,v.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case e.length-1:l.push(v.x,v.y,v.z);break;default:g=e[y+1].x-e[y].x,b=e[y+1].y-e[y].y,f.x=b*1,f.y=-g,f.z=b*0,m.copy(f),f.x+=v.x,f.y+=v.y,f.z+=v.z,f.normalize(),l.push(f.x,f.y,f.z),v.copy(m)}for(let y=0;y<=t;y++){const w=n+y*d*i,_=Math.sin(w),R=Math.cos(w);for(let T=0;T<=e.length-1;T++){h.x=e[T].x*_,h.y=e[T].y,h.z=e[T].x*R,a.push(h.x,h.y,h.z),u.x=y/t,u.y=T/(e.length-1),o.push(u.x,u.y);const P=l[3*T+0]*_,M=l[3*T+1],x=l[3*T+0]*R;c.push(P,M,x)}}for(let y=0;y<t;y++)for(let w=0;w<e.length-1;w++){const _=w+y*e.length,R=_,T=_+e.length,P=_+e.length+1,M=_+1;s.push(R,T,M),s.push(P,M,T)}this.setIndex(s),this.setAttribute("position",new Fe(a,3)),this.setAttribute("uv",new Fe(o,2)),this.setAttribute("normal",new Fe(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $u(e.points,e.segments,e.phiStart,e.phiLength)}}class Fb extends $u{constructor(e=1,t=1,n=4,i=8){const s=new uu;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new Fb(e.radius,e.length,e.capSegments,e.radialSegments)}}class Pc extends mt{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new L,d=new ge;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let h=0,u=3;h<=t;h++,u+=3){const f=n+h/t*i;c.x=e*Math.cos(f),c.y=e*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),d.x=(a[u]/e+1)/2,d.y=(a[u+1]/e+1)/2,l.push(d.x,d.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new Fe(a,3)),this.setAttribute("normal",new Fe(o,3)),this.setAttribute("uv",new Fe(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pc(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Pn extends mt{constructor(e=1,t=1,n=1,i=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),s=Math.floor(s);const d=[],h=[],u=[],f=[];let m=0;const v=[],g=n/2;let b=0;y(),a===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(d),this.setAttribute("position",new Fe(h,3)),this.setAttribute("normal",new Fe(u,3)),this.setAttribute("uv",new Fe(f,2));function y(){const _=new L,R=new L;let T=0;const P=(t-e)/n;for(let M=0;M<=s;M++){const x=[],S=M/s,C=S*(t-e)+e;for(let k=0;k<=i;k++){const I=k/i,G=I*l+o,q=Math.sin(G),O=Math.cos(G);R.x=C*q,R.y=-S*n+g,R.z=C*O,h.push(R.x,R.y,R.z),_.set(q,P,O).normalize(),u.push(_.x,_.y,_.z),f.push(I,1-S),x.push(m++)}v.push(x)}for(let M=0;M<i;M++)for(let x=0;x<s;x++){const S=v[x][M],C=v[x+1][M],k=v[x+1][M+1],I=v[x][M+1];(e>0||x!==0)&&(d.push(S,C,I),T+=3),(t>0||x!==s-1)&&(d.push(C,k,I),T+=3)}c.addGroup(b,T,0),b+=T}function w(_){const R=m,T=new ge,P=new L;let M=0;const x=_===!0?e:t,S=_===!0?1:-1;for(let k=1;k<=i;k++)h.push(0,g*S,0),u.push(0,S,0),f.push(.5,.5),m++;const C=m;for(let k=0;k<=i;k++){const G=k/i*l+o,q=Math.cos(G),O=Math.sin(G);P.x=x*O,P.y=g*S,P.z=x*q,h.push(P.x,P.y,P.z),u.push(0,S,0),T.x=q*.5+.5,T.y=O*.5*S+.5,f.push(T.x,T.y),m++}for(let k=0;k<i;k++){const I=R+k,G=C+k;_===!0?d.push(G,G+1,I):d.push(G+1,G,I),M+=3}c.addGroup(b,M,_===!0?1:2),b+=M}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pn(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Qu extends mt{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const s=[],a=[];o(i),c(n),d(),this.setAttribute("position",new Fe(s,3)),this.setAttribute("normal",new Fe(s.slice(),3)),this.setAttribute("uv",new Fe(a,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function o(y){const w=new L,_=new L,R=new L;for(let T=0;T<t.length;T+=3)f(t[T+0],w),f(t[T+1],_),f(t[T+2],R),l(w,_,R,y)}function l(y,w,_,R){const T=R+1,P=[];for(let M=0;M<=T;M++){P[M]=[];const x=y.clone().lerp(_,M/T),S=w.clone().lerp(_,M/T),C=T-M;for(let k=0;k<=C;k++)k===0&&M===T?P[M][k]=x:P[M][k]=x.clone().lerp(S,k/C)}for(let M=0;M<T;M++)for(let x=0;x<2*(T-M)-1;x++){const S=Math.floor(x/2);x%2===0?(u(P[M][S+1]),u(P[M+1][S]),u(P[M][S])):(u(P[M][S+1]),u(P[M+1][S+1]),u(P[M+1][S]))}}function c(y){const w=new L;for(let _=0;_<s.length;_+=3)w.x=s[_+0],w.y=s[_+1],w.z=s[_+2],w.normalize().multiplyScalar(y),s[_+0]=w.x,s[_+1]=w.y,s[_+2]=w.z}function d(){const y=new L;for(let w=0;w<s.length;w+=3){y.x=s[w+0],y.y=s[w+1],y.z=s[w+2];const _=g(y)/2/Math.PI+.5,R=b(y)/Math.PI+.5;a.push(_,1-R)}m(),h()}function h(){for(let y=0;y<a.length;y+=6){const w=a[y+0],_=a[y+2],R=a[y+4],T=Math.max(w,_,R),P=Math.min(w,_,R);T>.9&&P<.1&&(w<.2&&(a[y+0]+=1),_<.2&&(a[y+2]+=1),R<.2&&(a[y+4]+=1))}}function u(y){s.push(y.x,y.y,y.z)}function f(y,w){const _=y*3;w.x=e[_+0],w.y=e[_+1],w.z=e[_+2]}function m(){const y=new L,w=new L,_=new L,R=new L,T=new ge,P=new ge,M=new ge;for(let x=0,S=0;x<s.length;x+=9,S+=6){y.set(s[x+0],s[x+1],s[x+2]),w.set(s[x+3],s[x+4],s[x+5]),_.set(s[x+6],s[x+7],s[x+8]),T.set(a[S+0],a[S+1]),P.set(a[S+2],a[S+3]),M.set(a[S+4],a[S+5]),R.copy(y).add(w).add(_).divideScalar(3);const C=g(R);v(T,S+0,y,C),v(P,S+2,w,C),v(M,S+4,_,C)}}function v(y,w,_,R){R<0&&y.x===1&&(a[w]=y.x-1),_.x===0&&_.z===0&&(a[w]=R/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function b(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qu(e.vertices,e.indices,e.radius,e.details)}}const bl=new L,vl=new L,vd=new L,yl=new bi;class Rc extends mt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),s=Math.cos(pa*t),a=e.getIndex(),o=e.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],d=["a","b","c"],h=new Array(3),u={},f=[];for(let m=0;m<l;m+=3){a?(c[0]=a.getX(m),c[1]=a.getX(m+1),c[2]=a.getX(m+2)):(c[0]=m,c[1]=m+1,c[2]=m+2);const{a:v,b:g,c:b}=yl;if(v.fromBufferAttribute(o,c[0]),g.fromBufferAttribute(o,c[1]),b.fromBufferAttribute(o,c[2]),yl.getNormal(vd),h[0]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,h[1]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,h[2]=`${Math.round(b.x*i)},${Math.round(b.y*i)},${Math.round(b.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let y=0;y<3;y++){const w=(y+1)%3,_=h[y],R=h[w],T=yl[d[y]],P=yl[d[w]],M=`${_}_${R}`,x=`${R}_${_}`;x in u&&u[x]?(vd.dot(u[x].normal)<=s&&(f.push(T.x,T.y,T.z),f.push(P.x,P.y,P.z)),u[x]=null):M in u||(u[M]={index0:c[y],index1:c[w],normal:vd.clone()})}}for(const m in u)if(u[m]){const{index0:v,index1:g}=u[m];bl.fromBufferAttribute(o,v),vl.fromBufferAttribute(o,g),f.push(bl.x,bl.y,bl.z),f.push(vl.x,vl.y,vl.z)}this.setAttribute("position",new Fe(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Ub extends uu{constructor(e){super(e),this.uuid=Ni(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new uu().fromJSON(i))}return this}}class Dx{static triangulate(e,t,n=2){const i=t&&t.length,s=i?t[0]*n:e.length;let a=Bb(e,0,s,n,!0);const o=[];if(!a||a.next===a.prev)return o;let l,c,d,h,u,f,m;if(i&&(a=Fx(e,t,a,n)),e.length>80*n){l=d=e[0],c=h=e[1];for(let v=n;v<s;v+=n)u=e[v],f=e[v+1],u<l&&(l=u),f<c&&(c=f),u>d&&(d=u),f>h&&(h=f);m=Math.max(d-l,h-c),m=m!==0?32767/m:0}return Mo(a,o,n,l,c,m,0),o}}function Bb(r,e,t,n,i){let s,a;if(i===Zx(r,e,t,n)>0)for(s=e;s<t;s+=n)a=Sp(s,r[s],r[s+1],a);else for(s=t-n;s>=e;s-=n)a=Sp(s,r[s],r[s+1],a);return a&&Nc(a,a.next)&&(To(a),a=a.next),a}function Mr(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(Nc(t,t.next)||rn(t.prev,t,t.next)===0)){if(To(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Mo(r,e,t,n,i,s,a){if(!r)return;!a&&s&&Gx(r,n,i,s);let o=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?Ix(r,n,i,s):Lx(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(c.i/t|0),To(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=kx(Mr(r),e,t),Mo(r,e,t,n,i,s,2)):a===2&&Ox(r,e,t,n,i,s):Mo(Mr(r),e,t,n,i,s,1);break}}}function Lx(r){const e=r.prev,t=r,n=r.next;if(rn(e,t,n)>=0)return!1;const i=e.x,s=t.x,a=n.x,o=e.y,l=t.y,c=n.y,d=i<s?i<a?i:a:s<a?s:a,h=o<l?o<c?o:c:l<c?l:c,u=i>s?i>a?i:a:s>a?s:a,f=o>l?o>c?o:c:l>c?l:c;let m=n.next;for(;m!==e;){if(m.x>=d&&m.x<=u&&m.y>=h&&m.y<=f&&oa(i,o,s,l,a,c,m.x,m.y)&&rn(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Ix(r,e,t,n){const i=r.prev,s=r,a=r.next;if(rn(i,s,a)>=0)return!1;const o=i.x,l=s.x,c=a.x,d=i.y,h=s.y,u=a.y,f=o<l?o<c?o:c:l<c?l:c,m=d<h?d<u?d:u:h<u?h:u,v=o>l?o>c?o:c:l>c?l:c,g=d>h?d>u?d:u:h>u?h:u,b=fu(f,m,e,t,n),y=fu(v,g,e,t,n);let w=r.prevZ,_=r.nextZ;for(;w&&w.z>=b&&_&&_.z<=y;){if(w.x>=f&&w.x<=v&&w.y>=m&&w.y<=g&&w!==i&&w!==a&&oa(o,d,l,h,c,u,w.x,w.y)&&rn(w.prev,w,w.next)>=0||(w=w.prevZ,_.x>=f&&_.x<=v&&_.y>=m&&_.y<=g&&_!==i&&_!==a&&oa(o,d,l,h,c,u,_.x,_.y)&&rn(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;w&&w.z>=b;){if(w.x>=f&&w.x<=v&&w.y>=m&&w.y<=g&&w!==i&&w!==a&&oa(o,d,l,h,c,u,w.x,w.y)&&rn(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;_&&_.z<=y;){if(_.x>=f&&_.x<=v&&_.y>=m&&_.y<=g&&_!==i&&_!==a&&oa(o,d,l,h,c,u,_.x,_.y)&&rn(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function kx(r,e,t){let n=r;do{const i=n.prev,s=n.next.next;!Nc(i,s)&&zb(i,n,n.next,s)&&Eo(i,s)&&Eo(s,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),To(n),To(n.next),n=r=s),n=n.next}while(n!==r);return Mr(n)}function Ox(r,e,t,n,i,s){let a=r;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&jx(a,o)){let l=Hb(a,o);a=Mr(a,a.next),l=Mr(l,l.next),Mo(a,e,t,n,i,s,0),Mo(l,e,t,n,i,s,0);return}o=o.next}a=a.next}while(a!==r)}function Fx(r,e,t,n){const i=[];let s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*n,l=s<a-1?e[s+1]*n:r.length,c=Bb(r,o,l,n,!1),c===c.next&&(c.steiner=!0),i.push(Wx(c));for(i.sort(Ux),s=0;s<i.length;s++)t=Bx(i[s],t);return t}function Ux(r,e){return r.x-e.x}function Bx(r,e){const t=zx(r,e);if(!t)return e;const n=Hb(t,r);return Mr(n,n.next),Mr(t,t.next)}function zx(r,e){let t=e,n=-1/0,i;const s=r.x,a=r.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const u=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(u<=s&&u>n&&(n=u,i=t.x<t.next.x?t:t.next,u===s))return i}t=t.next}while(t!==e);if(!i)return null;const o=i,l=i.x,c=i.y;let d=1/0,h;t=i;do s>=t.x&&t.x>=l&&s!==t.x&&oa(a<c?s:n,a,l,c,a<c?n:s,a,t.x,t.y)&&(h=Math.abs(a-t.y)/(s-t.x),Eo(t,r)&&(h<d||h===d&&(t.x>i.x||t.x===i.x&&Hx(i,t)))&&(i=t,d=h)),t=t.next;while(t!==o);return i}function Hx(r,e){return rn(r.prev,r,e.prev)<0&&rn(e.next,r,r.next)<0}function Gx(r,e,t,n){let i=r;do i.z===0&&(i.z=fu(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,Vx(i)}function Vx(r){let e,t,n,i,s,a,o,l,c=1;do{for(t=r,r=null,s=null,a=0;t;){for(a++,n=t,o=0,e=0;e<c&&(o++,n=n.nextZ,!!n);e++);for(l=c;o>0||l>0&&n;)o!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,o--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(a>1);return r}function fu(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function Wx(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function oa(r,e,t,n,i,s,a,o){return(i-a)*(e-o)>=(r-a)*(s-o)&&(r-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(i-a)*(n-o)}function jx(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!Xx(r,e)&&(Eo(r,e)&&Eo(e,r)&&qx(r,e)&&(rn(r.prev,r,e.prev)||rn(r,e.prev,e))||Nc(r,e)&&rn(r.prev,r,r.next)>0&&rn(e.prev,e,e.next)>0)}function rn(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function Nc(r,e){return r.x===e.x&&r.y===e.y}function zb(r,e,t,n){const i=_l(rn(r,e,t)),s=_l(rn(r,e,n)),a=_l(rn(t,n,r)),o=_l(rn(t,n,e));return!!(i!==s&&a!==o||i===0&&xl(r,t,e)||s===0&&xl(r,n,e)||a===0&&xl(t,r,n)||o===0&&xl(t,e,n))}function xl(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function _l(r){return r>0?1:r<0?-1:0}function Xx(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&zb(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Eo(r,e){return rn(r.prev,r,r.next)<0?rn(r,e,r.next)>=0&&rn(r,r.prev,e)>=0:rn(r,e,r.prev)<0||rn(r,r.next,e)<0}function qx(r,e){let t=r,n=!1;const i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function Hb(r,e){const t=new pu(r.i,r.x,r.y),n=new pu(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Sp(r,e,t,n){const i=new pu(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function To(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function pu(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Zx(r,e,t,n){let i=0;for(let s=e,a=t-n;s<t;s+=n)i+=(r[a]-r[s])*(r[s+1]+r[a+1]),a=s;return i}class ga{static area(e){const t=e.length;let n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return ga.area(e)<0}static triangulateShape(e,t){const n=[],i=[],s=[];Mp(e),Ep(n,e);let a=e.length;t.forEach(Mp);for(let l=0;l<t.length;l++)i.push(a),a+=t[l].length,Ep(n,t[l]);const o=Dx.triangulate(n,i);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function Mp(r){const e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function Ep(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}class la extends Qu{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new la(e.radius,e.detail)}}class Qs extends mt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(i),c=o+1,d=l+1,h=e/o,u=t/l,f=[],m=[],v=[],g=[];for(let b=0;b<d;b++){const y=b*u-a;for(let w=0;w<c;w++){const _=w*h-s;m.push(_,-y,0),v.push(0,0,1),g.push(w/o),g.push(1-b/l)}}for(let b=0;b<l;b++)for(let y=0;y<o;y++){const w=y+c*b,_=y+c*(b+1),R=y+1+c*(b+1),T=y+1+c*b;f.push(w,_,T),f.push(_,R,T)}this.setIndex(f),this.setAttribute("position",new Fe(m,3)),this.setAttribute("normal",new Fe(v,3)),this.setAttribute("uv",new Fe(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qs(e.width,e.height,e.widthSegments,e.heightSegments)}}class Ju extends mt{constructor(e=.5,t=1,n=32,i=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:a},n=Math.max(3,n),i=Math.max(1,i);const o=[],l=[],c=[],d=[];let h=e;const u=(t-e)/i,f=new L,m=new ge;for(let v=0;v<=i;v++){for(let g=0;g<=n;g++){const b=s+g/n*a;f.x=h*Math.cos(b),f.y=h*Math.sin(b),l.push(f.x,f.y,f.z),c.push(0,0,1),m.x=(f.x/t+1)/2,m.y=(f.y/t+1)/2,d.push(m.x,m.y)}h+=u}for(let v=0;v<i;v++){const g=v*(n+1);for(let b=0;b<n;b++){const y=b+g,w=y,_=y+n+1,R=y+n+2,T=y+1;o.push(w,_,T),o.push(_,R,T)}}this.setIndex(o),this.setAttribute("position",new Fe(l,3)),this.setAttribute("normal",new Fe(c,3)),this.setAttribute("uv",new Fe(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ju(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class ef extends mt{constructor(e=new Ub([new ge(0,.5),new ge(-.5,-.5),new ge(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let d=0;d<e.length;d++)c(e[d]),this.addGroup(o,l,d),o+=l,l=0;this.setIndex(n),this.setAttribute("position",new Fe(i,3)),this.setAttribute("normal",new Fe(s,3)),this.setAttribute("uv",new Fe(a,2));function c(d){const h=i.length/3,u=d.extractPoints(t);let f=u.shape;const m=u.holes;ga.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,b=m.length;g<b;g++){const y=m[g];ga.isClockWise(y)===!0&&(m[g]=y.reverse())}const v=ga.triangulateShape(f,m);for(let g=0,b=m.length;g<b;g++){const y=m[g];f=f.concat(y)}for(let g=0,b=f.length;g<b;g++){const y=f[g];i.push(y.x,y.y,0),s.push(0,0,1),a.push(y.x,y.y)}for(let g=0,b=v.length;g<b;g++){const y=v[g],w=y[0]+h,_=y[1]+h,R=y[2]+h;n.push(w,_,R),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return Yx(t,e)}static fromJSON(e,t){const n=[];for(let i=0,s=e.shapes.length;i<s;i++){const a=t[e.shapes[i]];n.push(a)}return new ef(n,e.curveSegments)}}function Yx(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,n=r.length;t<n;t++){const i=r[t];e.shapes.push(i.uuid)}else e.shapes.push(r.uuid);return e}class Da extends mt{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const d=[],h=new L,u=new L,f=[],m=[],v=[],g=[];for(let b=0;b<=n;b++){const y=[],w=b/n;let _=0;b===0&&a===0?_=.5/t:b===n&&l===Math.PI&&(_=-.5/t);for(let R=0;R<=t;R++){const T=R/t;h.x=-e*Math.cos(i+T*s)*Math.sin(a+w*o),h.y=e*Math.cos(a+w*o),h.z=e*Math.sin(i+T*s)*Math.sin(a+w*o),m.push(h.x,h.y,h.z),u.copy(h).normalize(),v.push(u.x,u.y,u.z),g.push(T+_,1-w),y.push(c++)}d.push(y)}for(let b=0;b<n;b++)for(let y=0;y<t;y++){const w=d[b][y+1],_=d[b][y],R=d[b+1][y],T=d[b+1][y+1];(b!==0||a>0)&&f.push(w,_,T),(b!==n-1||l<Math.PI)&&f.push(_,R,T)}this.setIndex(f),this.setAttribute("position",new Fe(m,3)),this.setAttribute("normal",new Fe(v,3)),this.setAttribute("uv",new Fe(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Da(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class mr extends mt{constructor(e=1,t=.4,n=12,i=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:s},n=Math.floor(n),i=Math.floor(i);const a=[],o=[],l=[],c=[],d=new L,h=new L,u=new L;for(let f=0;f<=n;f++)for(let m=0;m<=i;m++){const v=m/i*s,g=f/n*Math.PI*2;h.x=(e+t*Math.cos(g))*Math.cos(v),h.y=(e+t*Math.cos(g))*Math.sin(v),h.z=t*Math.sin(g),o.push(h.x,h.y,h.z),d.x=e*Math.cos(v),d.y=e*Math.sin(v),u.subVectors(h,d).normalize(),l.push(u.x,u.y,u.z),c.push(m/i),c.push(f/n)}for(let f=1;f<=n;f++)for(let m=1;m<=i;m++){const v=(i+1)*f+m-1,g=(i+1)*(f-1)+m-1,b=(i+1)*(f-1)+m,y=(i+1)*f+m;a.push(v,g,y),a.push(g,b,y)}this.setIndex(a),this.setAttribute("position",new Fe(o,3)),this.setAttribute("normal",new Fe(l,3)),this.setAttribute("uv",new Fe(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mr(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Kx extends mt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new L,s=new L;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,d=l.length;c<d;++c){const h=l[c],u=h.start,f=h.count;for(let m=u,v=u+f;m<v;m+=3)for(let g=0;g<3;g++){const b=o.getX(m+g),y=o.getX(m+(g+1)%3);i.fromBufferAttribute(a,b),s.fromBufferAttribute(a,y),Tp(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const d=3*o+c,h=3*o+(c+1)%3;i.fromBufferAttribute(a,d),s.fromBufferAttribute(a,h),Tp(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Fe(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Tp(r,e,t){const n=`${r.x},${r.y},${r.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${r.x},${r.y},${r.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}class $x extends wn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Dc extends yi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Le(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Le(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ac,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class is extends Dc{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ge(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return yt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Le(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Le(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Le(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Ri extends yi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Le(16777215),this.specular=new Le(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Le(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ac,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dn,this.combine=Ec,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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.flatShading=e.flatShading,this.fog=e.fog,this}}class On extends yi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Le(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Le(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ac,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dn,this.combine=Ec,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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.flatShading=e.flatShading,this.fog=e.fog,this}}class Gb extends yi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=p0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Qx extends yi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function wl(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function Jx(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function e_(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function Ap(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let l=0;l!==e;++l)i[a++]=r[o+l]}return i}function Vb(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push(...a)),s=r[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=r[i++];while(s!==void 0)}class Ro{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let a;t:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=i,i=t[++n],e<i)break e}a=t.length;break t}if(!(e>=s)){const o=t[1];e<o&&(n=2,s=o);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break e}a=n,n=0;break t}break n}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let a=0;a!==i;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class t_ extends Ro{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:kf,endingEnd:kf}}intervalChanged_(e,t,n){const i=this.parameterPositions;let s=e-2,a=e+1,o=i[s],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case Of:s=e,o=2*t-n;break;case Ff:s=i.length-2,o=t+i[s]-i[s+1];break;default:s=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Of:a=e,l=2*n-t;break;case Ff:a=1,l=n+i[1]-i[0];break;default:a=e-1,l=t}const c=(n-t)*.5,d=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=s*d,this._offsetNext=a*d}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,d=this._offsetPrev,h=this._offsetNext,u=this._weightPrev,f=this._weightNext,m=(n-t)/(i-t),v=m*m,g=v*m,b=-u*g+2*u*v-u*m,y=(1+u)*g+(-1.5-2*u)*v+(-.5+u)*m+1,w=(-1-f)*g+(1.5+f)*v+.5*m,_=f*g-f*v;for(let R=0;R!==o;++R)s[R]=b*a[d+R]+y*a[c+R]+w*a[l+R]+_*a[h+R];return s}}class n_ extends Ro{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,d=(n-t)/(i-t),h=1-d;for(let u=0;u!==o;++u)s[u]=a[c+u]*h+a[l+u]*d;return s}}class i_ extends Ro{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class ss{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=wl(t,this.TimeBufferType),this.values=wl(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:wl(e.times,Array),values:wl(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new i_(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new n_(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new t_(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case xo:t=this.InterpolantFactoryMethodDiscrete;break;case _o:t=this.InterpolantFactoryMethodLinear;break;case Vc:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return xo;case this.InterpolantFactoryMethodLinear:return _o;case this.InterpolantFactoryMethodSmooth:return Vc}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let s=0,a=i-1;for(;s!==i&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&Jx(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Vc,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],d=e[o+1];if(c!==d&&(o!==1||c!==e[0]))if(i)l=!0;else{const h=o*n,u=h-n,f=h+n;for(let m=0;m!==n;++m){const v=t[h+m];if(v!==t[u+m]||v!==t[f+m]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*n,u=a*n;for(let f=0;f!==n;++f)t[u+f]=t[h+f]}++a}}if(s>0){e[a]=e[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}ss.prototype.TimeBufferType=Float32Array;ss.prototype.ValueBufferType=Float32Array;ss.prototype.DefaultInterpolation=_o;class La extends ss{constructor(e,t,n){super(e,t,n)}}La.prototype.ValueTypeName="bool";La.prototype.ValueBufferType=Array;La.prototype.DefaultInterpolation=xo;La.prototype.InterpolantFactoryMethodLinear=void 0;La.prototype.InterpolantFactoryMethodSmooth=void 0;class Wb extends ss{}Wb.prototype.ValueTypeName="color";class Er extends ss{}Er.prototype.ValueTypeName="number";class s_ extends Ro{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let d=c+o;c!==d;c+=4)Dt.slerpFlat(s,0,a,c-o,a,c,l);return s}}class Ss extends ss{InterpolantFactoryMethodLinear(e){return new s_(this.times,this.values,this.getValueSize(),e)}}Ss.prototype.ValueTypeName="quaternion";Ss.prototype.InterpolantFactoryMethodSmooth=void 0;class Ia extends ss{constructor(e,t,n){super(e,t,n)}}Ia.prototype.ValueTypeName="string";Ia.prototype.ValueBufferType=Array;Ia.prototype.DefaultInterpolation=xo;Ia.prototype.InterpolantFactoryMethodLinear=void 0;Ia.prototype.InterpolantFactoryMethodSmooth=void 0;class Ms extends ss{}Ms.prototype.ValueTypeName="vector";class vc{constructor(e="",t=-1,n=[],i=u0){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Ni(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(a_(n[a]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(ss.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const d=e_(l);l=Ap(l,1,d),c=Ap(c,1,d),!i&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new Er(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],d=c.name.match(s);if(d&&d.length>1){const h=d[1];let u=i[h];u||(i[h]=u=[]),u.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,u,f,m,v){if(f.length!==0){const g=[],b=[];Vb(f,g,b,m),g.length!==0&&v.push(new h(u,g,b))}},i=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const u=c[h].keys;if(!(!u||u.length===0))if(u[0].morphTargets){const f={};let m;for(m=0;m<u.length;m++)if(u[m].morphTargets)for(let v=0;v<u[m].morphTargets.length;v++)f[u[m].morphTargets[v]]=-1;for(const v in f){const g=[],b=[];for(let y=0;y!==u[m].morphTargets.length;++y){const w=u[m];g.push(w.time),b.push(w.morphTarget===v?1:0)}i.push(new Er(".morphTargetInfluence["+v+"]",g,b))}l=f.length*a}else{const f=".bones["+t[h].name+"]";n(Ms,f+".position",u,"pos",i),n(Ss,f+".quaternion",u,"rot",i),n(Ms,f+".scale",u,"scl",i)}}return i.length===0?null:new this(s,l,i,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function r_(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Er;case"vector":case"vector2":case"vector3":case"vector4":return Ms;case"color":return Wb;case"quaternion":return Ss;case"bool":case"boolean":return La;case"string":return Ia}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function a_(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=r_(r.type);if(r.times===void 0){const t=[],n=[];Vb(r.keys,t,n,"value"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const qs={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class Lc{constructor(e,t,n){const i=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(d){o++,s===!1&&i.onStart!==void 0&&i.onStart(d,a,o),s=!0},this.itemEnd=function(d){a++,i.onProgress!==void 0&&i.onProgress(d,a,o),a===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(d){i.onError!==void 0&&i.onError(d)},this.resolveURL=function(d){return l?l(d):d},this.setURLModifier=function(d){return l=d,this},this.addHandler=function(d,h){return c.push(d,h),this},this.removeHandler=function(d){const h=c.indexOf(d);return h!==-1&&c.splice(h,2),this},this.getHandler=function(d){for(let h=0,u=c.length;h<u;h+=2){const f=c[h],m=c[h+1];if(f.global&&(f.lastIndex=0),f.test(d))return m}return null}}}const jb=new Lc;class di{constructor(e){this.manager=e!==void 0?e:jb,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}di.DEFAULT_MATERIAL_NAME="__DEFAULT";const fs={};class o_ extends Error{constructor(e,t){super(e),this.response=t}}class $s extends di{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=qs.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(fs[e]!==void 0){fs[e].push({onLoad:t,onProgress:n,onError:i});return}fs[e]=[],fs[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const d=fs[e],h=c.body.getReader(),u=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=u?parseInt(u):0,m=f!==0;let v=0;const g=new ReadableStream({start(b){y();function y(){h.read().then(({done:w,value:_})=>{if(w)b.close();else{v+=_.byteLength;const R=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:f});for(let T=0,P=d.length;T<P;T++){const M=d[T];M.onProgress&&M.onProgress(R)}b.enqueue(_),y()}},w=>{b.error(w)})}}});return new Response(g)}else throw new o_(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(d=>new DOMParser().parseFromString(d,o));case"json":return c.json();default:if(o===void 0)return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),u=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(u);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{qs.add(e,c);const d=fs[e];delete fs[e];for(let h=0,u=d.length;h<u;h++){const f=d[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{const d=fs[e];if(d===void 0)throw this.manager.itemError(e),c;delete fs[e];for(let h=0,u=d.length;h<u;h++){const f=d[h];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class l_ extends di{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=qs.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=wo("img");function l(){d(),qs.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){d(),i&&i(h),s.manager.itemError(e),s.manager.itemEnd(e)}function d(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class c_ extends di{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new Zu,o=new $s(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(d){if(i!==void 0)i(d);else{console.error(d);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:li,a.wrapT=c.wrapT!==void 0?c.wrapT:li,a.magFilter=c.magFilter!==void 0?c.magFilter:bn,a.minFilter=c.minFilter!==void 0?c.minFilter:bn,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=Gi),c.mipmapCount===1&&(a.minFilter=bn),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},n,i),a}}class No extends di{constructor(e){super(e)}load(e,t,n,i){const s=new Bt,a=new l_(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class Do extends Pt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Le(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class Cp extends Do{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Le(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const yd=new ke,Pp=new L,Rp=new L;class tf{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ge(512,512),this.map=null,this.mapPass=null,this.matrix=new ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Cc,this._frameExtents=new ge(1,1),this._viewportCount=1,this._viewports=[new _t(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Pp.setFromMatrixPosition(e.matrixWorld),t.position.copy(Pp),Rp.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Rp),t.updateMatrixWorld(),yd.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yd),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(yd)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class d_ extends tf{constructor(){super(new gn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=Ta*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class nf extends Do{constructor(e,t,n=0,i=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new d_}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Np=new ke,$a=new L,xd=new L;class h_ extends tf{constructor(){super(new gn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ge(4,2),this._viewportCount=6,this._viewports=[new _t(2,1,1,1),new _t(0,1,1,1),new _t(3,1,1,1),new _t(1,1,1,1),new _t(3,0,1,1),new _t(1,0,1,1)],this._cubeDirections=[new L(1,0,0),new L(-1,0,0),new L(0,0,1),new L(0,0,-1),new L(0,1,0),new L(0,-1,0)],this._cubeUps=[new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,0,1),new L(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),$a.setFromMatrixPosition(e.matrixWorld),n.position.copy($a),xd.copy(n.position),xd.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(xd),n.updateMatrixWorld(),i.makeTranslation(-$a.x,-$a.y,-$a.z),Np.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Np)}}class yc extends Do{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new h_}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Lo extends Cb{constructor(e=-1,t=1,n=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class u_ extends tf{constructor(){super(new Lo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ic extends Do{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.shadow=new u_}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Xb extends Do{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ks{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class f_ extends mt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class p_ extends di{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=qs.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{i&&i(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return qs.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){i&&i(c),qs.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});qs.add(e,l),s.manager.itemStart(e)}}class m_ extends gn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e,this.index=0}}class sf{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Dp(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=Dp();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Dp(){return performance.now()}const rf="\\[\\]\\.:\\/",g_=new RegExp("["+rf+"]","g"),af="[^"+rf+"]",b_="[^"+rf.replace("\\.","")+"]",v_=/((?:WC+[\/:])*)/.source.replace("WC",af),y_=/(WCOD+)?/.source.replace("WCOD",b_),x_=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",af),__=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",af),w_=new RegExp("^"+v_+y_+x_+__+"$"),S_=["material","materials","bones","map"];class M_{constructor(e,t,n){const i=n||Nt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Nt{constructor(e,t,n){this.path=t,this.parsedPath=n||Nt.parseTrackName(t),this.node=Nt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Nt.Composite(e,t,n):new Nt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(g_,"")}static parseTrackName(e){const t=w_.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);S_.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let s=t.propertyIndex;if(e||(e=Nt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let d=0;d<e.length;d++)if(e[d].name===c){c=d;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[i];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Nt.Composite=M_;Nt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Nt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Nt.prototype.GetterByBindingType=[Nt.prototype._getValue_direct,Nt.prototype._getValue_array,Nt.prototype._getValue_arrayElement,Nt.prototype._getValue_toArray];Nt.prototype.SetterByBindingTypeAndVersioning=[[Nt.prototype._setValue_direct,Nt.prototype._setValue_direct_setNeedsUpdate,Nt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Nt.prototype._setValue_array,Nt.prototype._setValue_array_setNeedsUpdate,Nt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Nt.prototype._setValue_arrayElement,Nt.prototype._setValue_arrayElement_setNeedsUpdate,Nt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Nt.prototype._setValue_fromArray,Nt.prototype._setValue_fromArray_setNeedsUpdate,Nt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class mu extends Xu{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}const Lp=new ke;class of{constructor(e,t,n=0,i=1/0){this.ray=new Ra(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Vu,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Lp.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Lp),this}intersectObject(e,t=!0,n=[]){return gu(e,this,n,t),n.sort(Ip),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)gu(e[i],this,n,t);return n.sort(Ip),n}}function Ip(r,e){return r.distance-e.distance}function gu(r,e,t,n){let i=!0;if(r.layers.test(e.layers)&&r.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const s=r.children;for(let a=0,o=s.length;a<o;a++)gu(s[a],e,t,!0)}}class kp{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=yt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(yt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const Op=new ge;class br{constructor(e=new ge(1/0,1/0),t=new ge(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Op.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Op).distanceTo(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}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 Fp=new L,Sl=new L;class E_{constructor(e=new L,t=new L){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Fp.subVectors(e,this.start),Sl.subVectors(this.end,this.start);const n=Sl.dot(Sl);let s=Sl.dot(Fp)/n;return t&&(s=yt(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Up=new L;let Ml,_d;class T_ extends Pt{constructor(e=new L(0,0,1),t=new L(0,0,0),n=1,i=16776960,s=n*.2,a=s*.2){super(),this.type="ArrowHelper",Ml===void 0&&(Ml=new mt,Ml.setAttribute("position",new Fe([0,0,0,0,1,0],3)),_d=new Pn(0,.5,1,5,1),_d.translate(0,-.5,0)),this.position.copy(t),this.line=new Wn(Ml,new Yn({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ae(_d,new jt({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Up.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Up,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class ka extends Pr{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new mt;i.setAttribute("position",new Fe(t,3)),i.setAttribute("color",new Fe(n,3));const s=new Yn({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){const i=new Le,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class qb extends Cr{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}function Bp(r,e,t,n){const i=A_(n);switch(t){case mb:return r*e;case bb:return r*e;case vb:return r*e*2;case Fu:return r*e/i.components*i.byteLength;case Uu:return r*e/i.components*i.byteLength;case yb:return r*e*2/i.components*i.byteLength;case Bu:return r*e*2/i.components*i.byteLength;case gb:return r*e*3/i.components*i.byteLength;case Zn:return r*e*4/i.components*i.byteLength;case zu:return r*e*4/i.components*i.byteLength;case tc:case nc:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case ic:case sc:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Oh:case Uh:return Math.max(r,16)*Math.max(e,8)/4;case kh:case Fh:return Math.max(r,8)*Math.max(e,8)/2;case Bh:case zh:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Hh:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Gh:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Vh:return Math.floor((r+4)/5)*Math.floor((e+3)/4)*16;case Wh:return Math.floor((r+4)/5)*Math.floor((e+4)/5)*16;case jh:return Math.floor((r+5)/6)*Math.floor((e+4)/5)*16;case Xh:return Math.floor((r+5)/6)*Math.floor((e+5)/6)*16;case qh:return Math.floor((r+7)/8)*Math.floor((e+4)/5)*16;case Zh:return Math.floor((r+7)/8)*Math.floor((e+5)/6)*16;case Yh:return Math.floor((r+7)/8)*Math.floor((e+7)/8)*16;case Kh:return Math.floor((r+9)/10)*Math.floor((e+4)/5)*16;case $h:return Math.floor((r+9)/10)*Math.floor((e+5)/6)*16;case Qh:return Math.floor((r+9)/10)*Math.floor((e+7)/8)*16;case Jh:return Math.floor((r+9)/10)*Math.floor((e+9)/10)*16;case eu:return Math.floor((r+11)/12)*Math.floor((e+9)/10)*16;case tu:return Math.floor((r+11)/12)*Math.floor((e+11)/12)*16;case rc:case nu:case iu:return Math.ceil(r/4)*Math.ceil(e/4)*16;case xb:case su:return Math.ceil(r/4)*Math.ceil(e/4)*8;case ru:case au:return Math.ceil(r/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function A_(r){switch(r){case ws:case ub:return{byteLength:1,components:1};case yo:case fb:case Ti:return{byteLength:2,components:1};case ku:case Ou:return{byteLength:2,components:4};case Sr:case Iu:case Vi:return{byteLength:4,components:1};case pb:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:vr}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=vr);/**
|
|
69
69
|
* @license
|
|
70
70
|
* Copyright 2010-2025 Three.js Authors
|
|
71
71
|
* SPDX-License-Identifier: MIT
|
|
@@ -4222,234 +4222,7 @@ void main() {
|
|
|
4222
4222
|
`,z.push(...F.childNodes))}return N.trim()}if(e.length===0)return{scene:new cu};const si=new DOMParser().parseFromString(e,"application/xml"),Zt=n(si,"COLLADA")[0],Nn=si.getElementsByTagName("parsererror")[0];if(Nn!==void 0){const D=n(Nn,"div")[0];let N;return D?N=D.textContent:N=kt(Nn),console.error(`THREE.ColladaLoader: Failed to parse collada file.
|
|
4223
4223
|
`,N),null}const er=Zt.getAttribute("version");console.debug("THREE.ColladaLoader: File version",er);const Xt=d(n(Zt,"asset")[0]),$n=new No(this.manager);$n.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);let zn;Tm&&(zn=new Tm(this.manager),zn.setPath(this.resourcePath||t));const pn=new Le,xn=[];let Lr={},as=0;const ct={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};f(Zt,"library_animations","animation",g),f(Zt,"library_animation_clips","animation_clip",O),f(Zt,"library_controllers","controller",K),f(Zt,"library_images","image",J),f(Zt,"library_effects","effect",Te),f(Zt,"library_materials","material",$),f(Zt,"library_cameras","camera",ze),f(Zt,"library_lights","light",Oe),f(Zt,"library_geometries","geometry",Ve),f(Zt,"library_nodes","node",he),f(Zt,"library_visual_scenes","visual_scene",It),f(Zt,"library_kinematics_models","kinematics_model",Li),f(Zt,"library_physics_models","physics_model",Dr),f(Zt,"scene","instance_kinematics_scene",Fc),m(ct.animations,w),m(ct.clips,W),m(ct.controllers,ce),m(ct.images,ne),m(ct.effects,Y),m(ct.materials,Ie),m(ct.cameras,Qe),m(ct.lights,Lt),m(ct.geometries,Yt),m(ct.visualScenes,tn),yn(),Hc();const Vo=ot(n(Zt,"scene")[0]);return Vo.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."),Vo.rotation.set(-Math.PI/2,0,0)),Vo.scale.multiplyScalar(Xt.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),xn},kinematics:Lr,library:ct,scene:Vo}}}const Am=new L,ST=new dn,Il=new ke,Os=new ke,kl=new Dt,Ol=new L(1,1,1),Fl=new L;class Oc 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 MT extends Oc{constructor(...e){super(...e),this.isURDFCollider=!0,this.type="URDFCollider"}}class ET extends Oc{constructor(...e){super(...e),this.isURDFVisual=!0,this.type="URDFVisual"}}class nv extends Oc{constructor(...e){super(...e),this.isURDFLink=!0,this.type="URDFLink"}}class iv extends Oc{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 L(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 L(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),Am.copy(this.axis).applyEuler(this.rotation),this.position.addScaledVector(Am,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,Ol),kl.setFromEuler(ST.set(this.jointValue[3],this.jointValue[4],this.jointValue[5],"XYZ")),Fl.set(this.jointValue[0],this.jointValue[1],this.jointValue[2]),Il.compose(Fl,kl,Ol),Os.premultiply(Il),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,Ol),kl.setFromAxisAngle(this.axis,this.jointValue[2]),Fl.set(this.jointValue[0],this.jointValue[1],0),Il.compose(Fl,kl,Ol),Os.premultiply(Il),this.position.setFromMatrixPosition(Os),this.rotation.setFromRotationMatrix(Os),this.matrixWorldNeedsUpdate=!0,!0)}return t}}class Cm extends iv{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 TT extends nv{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 Ld=new Dt,Pm=new dn;function ta(r){return r?r.trim().split(/\s+/g).map(e=>parseFloat(e)):[0,0,0]}function Rm(r,e,t=!1){t||r.rotation.set(0,0,0),Pm.set(e[0],e[1],e[2],"ZYX"),Ld.setFromEuler(Pm),Ld.multiply(r.quaternion),r.quaternion.copy(Ld)}class cf{constructor(e){this.manager=e||jb,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=Ks.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[w,_]=y.replace(/^package:\/\//,"").split(/\/(.+)/);if(typeof n=="string")return n.endsWith(w)?n+"/"+_:n+"/"+w+"/"+_;if(n instanceof Function)return n(w)+"/"+_;if(typeof n=="object")return w in n?n[w]+"/"+_:(console.error(`URDFLoader : ${w} not found in provided package list.`),null)}function u(y){let w;y instanceof Document?w=[...y.children]:y instanceof Element?w=[y]:w=[...new DOMParser().parseFromString(y,"text/xml").children];const _=w.filter(R=>R.nodeName==="robot").pop();return f(_)}function f(y){const w=[...y.children],_=w.filter(C=>C.nodeName.toLowerCase()==="link"),R=w.filter(C=>C.nodeName.toLowerCase()==="joint"),T=w.filter(C=>C.nodeName.toLowerCase()==="material"),P=new TT;P.robotName=y.getAttribute("name"),P.urdfRobotNode=y,T.forEach(C=>{const k=C.getAttribute("name");d[k]=g(C)});const M={},x={};_.forEach(C=>{const k=C.getAttribute("name"),I=y.querySelector(`child[link="${k}"]`)===null;l[k]=v(C,M,x,I?P:null)}),R.forEach(C=>{const k=C.getAttribute("name");c[k]=m(C)}),P.joints=c,P.links=l,P.colliders=x,P.visual=M;const S=Object.values(c);return S.forEach(C=>{C instanceof Cm&&c[C.mimicJoint].mimicJoints.push(C)}),S.forEach(C=>{const k=new Set,I=G=>{if(k.has(G))throw new Error("URDFLoader: Detected an infinite loop of mimic joints.");k.add(G),G.mimicJoints.forEach(q=>{I(q)})};I(C)}),P.frames={...x,...M,...l,...c},P}function m(y){const w=[...y.children],_=y.getAttribute("type");let R;const T=w.find(k=>k.nodeName.toLowerCase()==="mimic");T?(R=new Cm,R.mimicJoint=T.getAttribute("joint"),R.multiplier=parseFloat(T.getAttribute("multiplier")||1),R.offset=parseFloat(T.getAttribute("offset")||0)):R=new iv,R.urdfNode=y,R.name=y.getAttribute("name"),R.urdfName=R.name,R.jointType=_;let P=null,M=null,x=[0,0,0],S=[0,0,0];w.forEach(k=>{const I=k.nodeName.toLowerCase();I==="origin"?(x=ta(k.getAttribute("xyz")),S=ta(k.getAttribute("rpy"))):I==="child"?M=l[k.getAttribute("link")]:I==="parent"?P=l[k.getAttribute("link")]:I==="limit"&&(R.limit.lower=parseFloat(k.getAttribute("lower")||R.limit.lower),R.limit.upper=parseFloat(k.getAttribute("upper")||R.limit.upper))}),P.add(R),R.add(M),Rm(R,S),R.position.set(x[0],x[1],x[2]);const C=w.filter(k=>k.nodeName.toLowerCase()==="axis")[0];if(C){const k=C.getAttribute("xyz").split(/\s+/g).map(I=>parseFloat(I));R.axis=new L(k[0],k[1],k[2]),R.axis.normalize()}return R}function v(y,w,_,R=null){R===null&&(R=new nv);const T=[...y.children];return R.name=y.getAttribute("name"),R.urdfName=R.name,R.urdfNode=y,s&&T.filter(M=>M.nodeName.toLowerCase()==="visual").forEach(M=>{const x=b(M,d);if(R.add(x),M.hasAttribute("name")){const S=M.getAttribute("name");x.name=S,x.urdfName=S,w[S]=x}}),a&&T.filter(M=>M.nodeName.toLowerCase()==="collision").forEach(M=>{const x=b(M);if(R.add(x),M.hasAttribute("name")){const S=M.getAttribute("name");x.name=S,x.urdfName=S,_[S]=x}}),R}function g(y){const w=[...y.children],_=new Ri;return _.name=y.getAttribute("name")||"",w.forEach(R=>{const T=R.nodeName.toLowerCase();if(T==="color"){const P=R.getAttribute("rgba").split(/\s/g).map(M=>parseFloat(M));_.color.setRGB(P[0],P[1],P[2]),_.opacity=P[3],_.transparent=P[3]<1,_.depthWrite=!_.transparent}else if(T==="texture"){const P=R.getAttribute("filename");if(P){const M=new No(o),x=h(P);_.map=M.load(x),_.map.colorSpace=gt}}}),_}function b(y,w={}){const _=y.nodeName.toLowerCase()==="collision",R=[...y.children];let T=null;const P=R.filter(x=>x.nodeName.toLowerCase()==="material")[0];if(P){const x=P.getAttribute("name");x&&x in w?T=w[x]:T=g(P)}else T=new Ri;const M=_?new MT:new ET;return M.urdfNode=y,R.forEach(x=>{const S=x.nodeName.toLowerCase();if(S==="geometry"){const C=x.children[0].nodeName.toLowerCase();if(C==="mesh"){const k=x.children[0].getAttribute("filename"),I=h(k);if(I!==null){const G=x.children[0].getAttribute("scale");if(G){const q=ta(G);M.scale.set(q[0],q[1],q[2])}i(I,o,(q,O)=>{O?console.error("URDFLoader: Error loading mesh.",O):q&&(q instanceof Ae&&(q.material=T),q.position.set(0,0,0),q.quaternion.identity(),M.add(q))})}}else if(C==="box"){const k=new Ae;k.geometry=new Kt(1,1,1),k.material=T;const I=ta(x.children[0].getAttribute("size"));k.scale.set(I[0],I[1],I[2]),M.add(k)}else if(C==="sphere"){const k=new Ae;k.geometry=new Da(1,30,30),k.material=T;const I=parseFloat(x.children[0].getAttribute("radius"))||0;k.scale.set(I,I,I),M.add(k)}else if(C==="cylinder"){const k=new Ae;k.geometry=new Pn(1,1,1,30),k.material=T;const I=parseFloat(x.children[0].getAttribute("radius"))||0,G=parseFloat(x.children[0].getAttribute("length"))||0;k.scale.set(I,G,I),k.rotation.set(Math.PI/2,0,0),M.add(k)}}else if(S==="origin"){const C=ta(x.getAttribute("xyz")),k=ta(x.getAttribute("rpy"));M.position.set(C[0],C[1],C[2]),M.rotation.set(0,0,0),Rm(M,k)}}),M}return u(e)}defaultMeshLoader(e,t,n){/\.stl$/i.test(e)?new ev(t).load(e,s=>{const a=new Ae(s,new Ri);n(a)}):/\.dae$/i.test(e)?new tv(t).load(e,s=>n(s.scene)):console.warn(`URDFLoader: Could not load model at ${e}.
|
|
4224
4224
|
No loader available`)}}const Id=new WeakMap;class Io extends di{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 $s(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=Kn,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(Id.has(e)){const l=Id.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)}),Id.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new mt;e.index&&t.setIndex(new vn(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 vn(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 Le;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i),dt.toWorkingColorSpace(n,gt),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new $s(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=AT.toString(),a=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
4225
|
-
`);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 AT(){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(v=>v.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 v={index:null,attributes:[]};for(const g in d){const b=self[h[g]];let y,w;if(c.useUniqueIDs)w=d[g],y=o.GetAttributeByUniqueId(u,w);else{if(w=o.GetAttributeId(u,a[d[g]]),w===-1)continue;y=o.GetAttribute(u,w)}const _=i(a,o,u,g,b,y);g==="color"&&(_.vertexColorSpace=c.vertexColorSpace),v.attributes.push(_)}return m===a.TRIANGULAR_MESH&&(v.index=n(a,o,u)),a.destroy(u),v}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,v=m*d.BYTES_PER_ELEMENT,g=s(a,d),b=a._malloc(v);o.GetAttributeDataArrayForAllPoints(l,h,g,v,b);const y=new d(a.HEAPF32.buffer,b,m).slice();return a._free(b),{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 Nm(r,e){if(e===f0)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===ou||e===_b){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===ou)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 Rr extends di{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new DT(t)}),this.register(function(t){return new LT(t)}),this.register(function(t){return new GT(t)}),this.register(function(t){return new VT(t)}),this.register(function(t){return new WT(t)}),this.register(function(t){return new kT(t)}),this.register(function(t){return new OT(t)}),this.register(function(t){return new FT(t)}),this.register(function(t){return new UT(t)}),this.register(function(t){return new NT(t)}),this.register(function(t){return new BT(t)}),this.register(function(t){return new IT(t)}),this.register(function(t){return new HT(t)}),this.register(function(t){return new zT(t)}),this.register(function(t){return new PT(t)}),this.register(function(t){return new jT(t)}),this.register(function(t){return new XT(t)})}load(e,t,n,i){const s=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=Ks.extractUrlBase(e);a=Ks.resolveURL(c,this.path)}else a=Ks.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 $s(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))===sv){try{a[Ct.KHR_BINARY_GLTF]=new qT(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 aA(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 RT;break;case Ct.KHR_DRACO_MESH_COMPRESSION:a[h]=new ZT(s,this.dracoLoader);break;case Ct.KHR_TEXTURE_TRANSFORM:a[h]=new YT;break;case Ct.KHR_MESH_QUANTIZATION:a[h]=new KT;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 CT(){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 PT{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 Le(16777215);l.color!==void 0&&d.setRGB(l.color[0],l.color[1],l.color[2],Kn);const h=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new Ic(d),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new yc(d),c.distance=h;break;case"spot":c=new nf(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),bs(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 RT{constructor(){this.name=Ct.KHR_MATERIALS_UNLIT}getMaterialType(){return jt}extendParams(e,t,n){const i=[];e.color=new Le(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],Kn),e.opacity=a[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,gt))}return Promise.all(i)}}class NT{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 DT{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:is}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 ge(o,o)}return Promise.all(s)}}class LT{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:is}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 IT{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:is}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 kT{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:is}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 Le(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],Kn)}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 OT{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:is}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 FT{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:is}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 Le().setRGB(o[0],o[1],o[2],Kn),Promise.all(s)}}class UT{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:is}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 BT{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:is}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 Le().setRGB(o[0],o[1],o[2],Kn),a.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,gt)),Promise.all(s)}}class zT{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:is}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 HT{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:is}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 GT{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 VT{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 WT{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 jT{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 XT{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!==Ei.TRIANGLES&&c.mode!==Ei.TRIANGLE_STRIP&&c.mode!==Ei.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 v=new ke,g=new L,b=new Dt,y=new L(1,1,1),w=new gx(m.geometry,m.material,u);for(let _=0;_<u;_++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,_),l.ROTATION&&b.fromBufferAttribute(l.ROTATION,_),l.SCALE&&y.fromBufferAttribute(l.SCALE,_),w.setMatrixAt(_,v.compose(g,b,y));for(const _ in l)if(_==="_COLOR_0"){const R=l[_];w.instanceColor=new du(R.array,R.itemSize,R.normalized)}else _!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&m.geometry.setAttribute(_,l[_]);Pt.prototype.copy.call(w,m),this.parser.assignFinalMaterial(w),f.push(w)}return d.isGroup?(d.clear(),d.add(...f),d):f[0]}))}}const sv="glTF",eo=12,Dm={JSON:1313821514,BIN:5130562};class qT{constructor(e){this.name=Ct.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,eo),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!==sv)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-eo,s=new DataView(e,eo);let a=0;for(;a<i;){const o=s.getUint32(a,!0);a+=4;const l=s.getUint32(a,!0);if(a+=4,l===Dm.JSON){const c=new Uint8Array(e,eo+a,o);this.content=n.decode(c)}else if(l===Dm.BIN){const c=eo+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class ZT{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=vu[d]||d.toLowerCase();o[h]=a[d]}for(const d in e.attributes){const h=vu[d]||d.toLowerCase();if(a[d]!==void 0){const u=n.accessors[e.attributes[d]],f=va[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 v=f.attributes[m],g=l[m];g!==void 0&&(v.normalized=g)}h(f)},o,c,Kn,u)})})}}class YT{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 KT{constructor(){this.name=Ct.KHR_MESH_QUANTIZATION}}class rv extends Ro{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,v=m-c,g=-2*f+3*u,b=f-u,y=1-g,w=b-u+h;for(let _=0;_!==o;_++){const R=a[v+_+o],T=a[v+_+l]*d,P=a[m+_+o],M=a[m+_]*d;s[_]=y*R+w*T+g*P+b*M}return s}}const $T=new Dt;class QT extends rv{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return $T.fromArray(s).normalize().toArray(s),s}}const Ei={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},va={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Lm={9728:Sn,9729:bn,9984:hb,9985:ec,9986:oo,9987:Gi},Im={33071:li,33648:fc,10497:Pi},kd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},vu={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"},JT={CUBICSPLINE:void 0,LINEAR:_o,STEP:xo},Od={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function eA(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new Dc({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:xi})),r.DefaultMaterial}function lr(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 bs(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 tA(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 nA(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 iA(r){let e;const t=r.extensions&&r.extensions[Ct.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Fd(t.attributes):e=r.indices+":"+Fd(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+Fd(r.targets[n]);return e}function Fd(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 yu(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 sA(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 rA=new ke;class aA{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new CT,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 No(this.options.manager):this.textureLoader=new p_(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new $s(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 lr(s,o,i),bs(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(Ks.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=kd[i.type],o=va[i.componentType],l=i.normalized===!0,c=new o(i.count*a);return Promise.resolve(new vn(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=kd[i.type],c=va[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 v,g;if(f&&f!==h){const b=Math.floor(u/f),y="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+b+":"+i.count;let w=t.cache.get(y);w||(v=new c(o,b*f,i.count*f/d),w=new Xu(v,f/d),t.cache.add(y,w)),g=new Wi(w,l,u%f/d,m)}else o===null?v=new c(i.count*l):v=new c(o,u,i.count*l),g=new vn(v,l,m);if(i.sparse!==void 0){const b=kd.SCALAR,y=va[i.sparse.indices.componentType],w=i.sparse.indices.byteOffset||0,_=i.sparse.values.byteOffset||0,R=new y(a[1],w,i.sparse.count*b),T=new c(a[2],_,i.sparse.count*l);o!==null&&(g=new vn(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let P=0,M=R.length;P<M;P++){const x=R[P];if(g.setX(x,T[P*l]),l>=2&&g.setY(x,T[P*l+1]),l>=3&&g.setZ(x,T[P*l+2]),l>=4&&g.setW(x,T[P*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}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=Lm[u.magFilter]||bn,d.minFilter=Lm[u.minFilter]||Gi,d.wrapS=Im[u.wrapS]||Pi,d.wrapT=Im[u.wrapT]||Pi,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(v){const g=new Bt(v);g.needsUpdate=!0,u(g)}),t.load(Ks.resolveURL(h,s.path),m,void 0,f)})}).then(function(h){return c===!0&&o.revokeObjectURL(l),bs(h,a),h.userData.mimeType=a.mimeType||sA(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 aa,yi.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 Yn,yi.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 Dc}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 Le(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const u=h.baseColorFactor;o.color.setRGB(u[0],u[1],u[2],Kn),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=sn);const d=s.alphaMode||Od.OPAQUE;if(d===Od.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,d===Od.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 ge(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 Le().setRGB(h[0],h[1],h[2],Kn)}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),bs(h,s),t.associations.set(h,{materials:e}),s.extensions&&lr(i,h,s),h})}createUniqueName(e){const t=Nt.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 km(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],d=iA(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=km(new mt,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?eA(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 v=d[f],g=a[f];let b;const y=c[f];if(g.mode===Ei.TRIANGLES||g.mode===Ei.TRIANGLE_STRIP||g.mode===Ei.TRIANGLE_FAN||g.mode===void 0)b=s.isSkinnedMesh===!0?new qu(v,y):new Ae(v,y),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),g.mode===Ei.TRIANGLE_STRIP?b.geometry=Nm(b.geometry,_b):g.mode===Ei.TRIANGLE_FAN&&(b.geometry=Nm(b.geometry,ou));else if(g.mode===Ei.LINES)b=new Pr(v,y);else if(g.mode===Ei.LINE_STRIP)b=new Wn(v,y);else if(g.mode===Ei.LINE_LOOP)b=new Nb(v,y);else if(g.mode===Ei.POINTS)b=new lo(v,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(b.geometry.morphAttributes).length>0&&nA(b,s),b.name=t.createUniqueName(s.name||"mesh_"+e),bs(b,s),g.extensions&&lr(i,b,g),t.assignFinalMaterial(b),h.push(b)}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&&lr(i,h[0],s),h[0];const u=new Vt;s.extensions&&lr(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 Lo(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),bs(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 ke;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 Po(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],v=f.target,g=v.node,b=i.parameters!==void 0?i.parameters[m.input]:m.input,y=i.parameters!==void 0?i.parameters[m.output]:m.output;v.node!==void 0&&(a.push(this.getDependency("node",g)),o.push(this.getDependency("accessor",b)),l.push(this.getDependency("accessor",y)),c.push(m),d.push(v))}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],v=h[3],g=h[4],b=[];for(let y=0,w=u.length;y<w;y++){const _=u[y],R=f[y],T=m[y],P=v[y],M=g[y];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const x=n._createAnimationTracks(_,R,T,P,M);if(x)for(let S=0;S<x.length;S++)b.push(x[S])}return new vc(s,void 0,b)})}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,rA)});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 So: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),bs(d,s),s.extensions&&lr(n,d,s),s.matrix!==void 0){const h=new ke;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)),bs(s,n),n.extensions&&lr(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 yi||u instanceof Bt)&&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=Er;break;case Fs.rotation:c=Ss;break;case Fs.position:case Fs.scale:c=Ms;break;default:switch(n.itemSize){case 1:c=Er;break;case 2:case 3:default:c=Ms;break}break}const d=i.interpolation!==void 0?JT[i.interpolation]:_o,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=yu(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 Ss?QT:rv;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function oA(r,e,t){const n=e.attributes,i=new ln;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 L(l[0],l[1],l[2]),new L(c[0],c[1],c[2])),o.normalized){const d=yu(va[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 L,l=new L;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 v=yu(va[u.componentType]);l.multiplyScalar(v)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}r.boundingBox=i;const a=new ni;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=a}function km(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=vu[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 dt.workingColorSpace!==Kn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${dt.workingColorSpace}" not supported.`),bs(r,e),oA(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?tA(r,e.targets,t):r})}var lA=(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(b){s=b.instance,s.exports.__wasm_call_ctors()});function o(b){for(var y=new Uint8Array(b.length),w=0;w<b.length;++w){var _=b.charCodeAt(w);y[w]=_>96?_-97:_>64?_-39:_+4}for(var R=0,w=0;w<b.length;++w)y[R++]=y[w]<60?n[y[w]]:(y[w]-60)*64+y[++w];return y.buffer.slice(0,R)}function l(b,y,w,_,R,T){var P=s.exports.sbrk,M=w+3&-4,x=P(M*_),S=P(R.length),C=new Uint8Array(s.exports.memory.buffer);C.set(R,S);var k=b(x,w,_,S,R.length);if(k==0&&T&&T(x,M,_),y.set(C.subarray(x,x+w*_)),P(x-P(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(b){var y={object:new Worker(b),pending:0,requests:{}};return y.object.onmessage=function(w){var _=w.data;y.pending-=_.count,y.requests[_.id][_.action](_.value),delete y.requests[_.id]},y}function m(b){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()+g.toString(),w=new Blob([y],{type:"text/javascript"}),_=URL.createObjectURL(w),R=0;R<b;++R)h[R]=f(_);URL.revokeObjectURL(_)}function v(b,y,w,_,R){for(var T=h[0],P=1;P<h.length;++P)h[P].pending<T.pending&&(T=h[P]);return new Promise(function(M,x){var S=new Uint8Array(w),C=u++;T.pending+=b,T.requests[C]={resolve:M,reject:x},T.object.postMessage({id:C,count:b,size:y,source:S,mode:_,filter:R},[S.buffer])})}function g(b){a.then(function(){var y=b.data;try{var w=new Uint8Array(y.count*y.size);l(s.exports[y.mode],w,y.count,y.size,y.source,s.exports[y.filter]),self.postMessage({id:y.id,count:y.count,action:"resolve",value:w},[w.buffer])}catch(_){self.postMessage({id:y.id,count:y.count,action:"reject",value:_})}})}return{ready:a,supported:!0,useWorkers:function(b){m(b)},decodeVertexBuffer:function(b,y,w,_,R){l(s.exports.meshopt_decodeVertexBuffer,b,y,w,_,s.exports[c[R]])},decodeIndexBuffer:function(b,y,w,_){l(s.exports.meshopt_decodeIndexBuffer,b,y,w,_)},decodeIndexSequence:function(b,y,w,_){l(s.exports.meshopt_decodeIndexSequence,b,y,w,_)},decodeGltfBuffer:function(b,y,w,_,R,T){l(s.exports[d[R]],b,y,w,_,s.exports[c[T]])},decodeGltfBufferAsync:function(b,y,w,_,R){return h.length>0?v(b,y,w,d[_],c[R]):a.then(function(){var T=new Uint8Array(b*y);return l(s.exports[d[_]],T,b,y,w,s.exports[c[R]]),T})}}})();let Ul=null;const cA=["/gaia/"],Om=r=>{const e=new On;return"color"in r&&r.color instanceof Le&&e.color.copy(r.color),"map"in r&&r.map instanceof Bt&&(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},dA=r=>{r.traverse(e=>{e instanceof Ae&&(Array.isArray(e.material)?e.material=e.material.map(Om):e.material=Om(e.material))})},hA=r=>{const e=r.toLowerCase();return cA.some(t=>e.includes(t))},uA=()=>(Ul||(Ul=new Io,Ul.setDecoderPath(Bn("/draco/"))),Ul),av=(r,e,t)=>{if(/\.(gltf|glb)(\?|#|$)/i.test(r)){const n=new Rr(e);n.setDRACOLoader(uA()),n.setMeshoptDecoder(lA),n.load(r,i=>{const s=i.scene??new Vt;hA(r)&&dA(s),t(s)},void 0,i=>{console.warn("GLTF load error:",r,i),t(new Vt)});return}if(/\.stl(\?|#|$)/i.test(r)){new ev(e).load(r,i=>{const s=new Ae(i,new Dc({color:8421504}));t(s)},void 0,i=>{console.warn("STL load error:",r,i),t(new Vt)});return}if(/\.dae(\?|#|$)/i.test(r)){new tv(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)},Fm={type:"change"},df={type:"start"},ov={type:"end"},Bl=new Ra,Um=new Vs,fA=Math.cos(70*bt.DEG2RAD),_n=new L,ai=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},Ud=1e-6;class pA extends qb{constructor(e,t=null){super(e,t),this.state=Wt.NONE,this.enabled=!0,this.target=new L,this.cursor=new L,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:yr.ROTATE,MIDDLE:yr.DOLLY,RIGHT:yr.PAN},this.touches={ONE:Xs.ROTATE,TWO:Xs.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new L,this._lastQuaternion=new Dt,this._lastTargetPosition=new L,this._quat=new Dt().setFromUnitVectors(e.up,new L(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new kp,this._sphericalDelta=new kp,this._scale=1,this._panOffset=new L,this._rotateStart=new ge,this._rotateEnd=new ge,this._rotateDelta=new ge,this._panStart=new ge,this._panEnd=new ge,this._panDelta=new ge,this._dollyStart=new ge,this._dollyEnd=new ge,this._dollyDelta=new ge,this._dollyDirection=new L,this._mouse=new ge,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=gA.bind(this),this._onPointerDown=mA.bind(this),this._onPointerUp=bA.bind(this),this._onContextMenu=MA.bind(this),this._onMouseWheel=xA.bind(this),this._onKeyDown=_A.bind(this),this._onTouchStart=wA.bind(this),this._onTouchMove=SA.bind(this),this._onMouseDown=vA.bind(this),this._onMouseMove=yA.bind(this),this._interceptControlDown=EA.bind(this),this._interceptControlUp=TA.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(Fm),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+=ai:n>Math.PI&&(n-=ai),i<-Math.PI?i+=ai:i>Math.PI&&(i-=ai),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 L(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 L(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):(Bl.origin.copy(this.object.position),Bl.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Bl.direction))<fA?this.object.lookAt(this.target):(Um.setFromNormalAndCoplanarPoint(this.object.up,this.target),Bl.intersectPlane(Um,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)>Ud||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ud||this._lastTargetPosition.distanceToSquared(this.target)>Ud?(this.dispatchEvent(Fm),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ai/60*this.autoRotateSpeed*e:ai/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(ai*this._rotateDelta.x/t.clientHeight),this._rotateUp(ai*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(ai*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(-ai*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(ai*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(-ai*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(ai*this._rotateDelta.x/t.clientHeight),this._rotateUp(ai*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 ge,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 mA(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 gA(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function bA(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(ov),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 vA(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 yr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=Wt.DOLLY;break;case yr.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 yr.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(df)}function yA(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 xA(r){this.enabled===!1||this.enableZoom===!1||this.state!==Wt.NONE||(r.preventDefault(),this.dispatchEvent(df),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(ov))}function _A(r){this.enabled!==!1&&this._handleKeyDown(r)}function wA(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case Xs.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=Wt.TOUCH_ROTATE;break;case Xs.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 Xs.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=Wt.TOUCH_DOLLY_PAN;break;case Xs.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(df)}function SA(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 MA(r){this.enabled!==!1&&r.preventDefault()}function EA(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function TA(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function lv(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 AA(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 CA(r,e,t,n){const i=lv(r,n,e),s=AA(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 PA(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],v=l[h-f];o[h][f]=m+v;const g=o[f][h-1]/o[h][f];o[f][h]=u+m*g,u=v*g}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 v=0;v<=t;++v)m[v]=s.slice(0);m[0][0]=1;for(let v=1;v<=n;++v){let g=0;const b=h-v,y=t-v;h>=v&&(m[f][0]=m[u][0]/o[y+1][b],g=m[f][0]*o[b][y]);const w=b>=-1?1:-b,_=h-1<=y?v-1:t-h;for(let T=w;T<=_;++T)m[f][T]=(m[u][T]-m[u][T-1])/o[y+1][b+T],g+=m[f][T]*o[b+T][y];h<=y&&(m[f][v]=-m[u][v-1]/o[y+1][h],g+=m[f][v]*o[h][y]),a[v][h]=g;const R=u;u=f,f=R}}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 RA(r,e,t,n,i){const s=i<r?i:r,a=[],o=lv(r,n,e),l=PA(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 NA(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 DA(r){const e=r.length,t=[],n=[];for(let s=0;s<e;++s){const a=r[s];t[s]=new L(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(NA(s,o)*n[o]));i[s]=a.divideScalar(n[0])}return i}function LA(r,e,t,n,i){const s=RA(r,e,t,n,i);return DA(s)}class IA extends Zi{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 L){const n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=CA(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 L){const n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=LA(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}}class Fa{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const kA=new Lo(-1,1,1,-1,0,1);class OA extends mt{constructor(){super(),this.setAttribute("position",new Fe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Fe([0,2,0,0,2,0],2))}}const FA=new OA;class hf{constructor(e){this._mesh=new Ae(FA,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,kA)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}/*!
|
|
4226
|
-
fflate - fast JavaScript compression/decompression
|
|
4227
|
-
<https://101arrowz.github.io/fflate>
|
|
4228
|
-
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
4229
|
-
version 0.8.2
|
|
4230
|
-
*/var Ci=Uint8Array,da=Uint16Array,UA=Int32Array,cv=new Ci([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]),dv=new Ci([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]),BA=new Ci([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),hv=function(r,e){for(var t=new da(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new UA(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}},uv=hv(cv,2),fv=uv.b,zA=uv.r;fv[28]=258,zA[258]=28;var HA=hv(dv,0),GA=HA.b,xu=new da(32768);for(var $t=0;$t<32768;++$t){var Us=($t&43690)>>1|($t&21845)<<1;Us=(Us&52428)>>2|(Us&13107)<<2,Us=(Us&61680)>>4|(Us&3855)<<4,xu[$t]=((Us&65280)>>8|(Us&255)<<8)>>1}var bo=(function(r,e,t){for(var n=r.length,i=0,s=new da(e);i<n;++i)r[i]&&++s[r[i]-1];var a=new da(e);for(i=1;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;var o;if(t){o=new da(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[xu[h]>>l]=c}else for(o=new da(n),i=0;i<n;++i)r[i]&&(o[i]=xu[a[r[i]-1]++]>>15-r[i]);return o}),ko=new Ci(288);for(var $t=0;$t<144;++$t)ko[$t]=8;for(var $t=144;$t<256;++$t)ko[$t]=9;for(var $t=256;$t<280;++$t)ko[$t]=7;for(var $t=280;$t<288;++$t)ko[$t]=8;var pv=new Ci(32);for(var $t=0;$t<32;++$t)pv[$t]=5;var VA=bo(ko,9,1),WA=bo(pv,5,1),Bd=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},Fi=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},zd=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},jA=function(r){return(r+7)/8|0},XA=function(r,e,t){return(t==null||t>r.length)&&(t=r.length),new Ci(r.subarray(e,t))},qA=["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"],Bi=function(r,e,t){var n=new Error(e||qA[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,Bi),!t)throw n;return n},ZA=function(r,e,t,n){var i=r.length,s=0;if(!i||e.f&&!e.l)return t||new Ci(0);var a=!t,o=a||e.i!=2,l=e.i;a&&(t=new Ci(i*3));var c=function(fe){var be=t.length;if(fe>be){var Ce=new Ci(Math.max(be*2,fe));Ce.set(t),t=Ce}},d=e.f||0,h=e.p||0,u=e.b||0,f=e.l,m=e.d,v=e.m,g=e.n,b=i*8;do{if(!f){d=Fi(r,h,1);var y=Fi(r,h+1,3);if(h+=3,y)if(y==1)f=VA,m=WA,v=9,g=5;else if(y==2){var T=Fi(r,h,31)+257,P=Fi(r,h+10,15)+4,M=T+Fi(r,h+5,31)+1;h+=14;for(var x=new Ci(M),S=new Ci(19),C=0;C<P;++C)S[BA[C]]=Fi(r,h+C*3,7);h+=P*3;for(var k=Bd(S),I=(1<<k)-1,G=bo(S,k,1),C=0;C<M;){var q=G[Fi(r,h,I)];h+=q&15;var w=q>>4;if(w<16)x[C++]=w;else{var O=0,W=0;for(w==16?(W=3+Fi(r,h,3),h+=2,O=x[C-1]):w==17?(W=3+Fi(r,h,7),h+=3):w==18&&(W=11+Fi(r,h,127),h+=7);W--;)x[C++]=O}}var Z=x.subarray(0,T),K=x.subarray(T);v=Bd(Z),g=Bd(K),f=bo(Z,v,1),m=bo(K,g,1)}else Bi(1);else{var w=jA(h)+4,_=r[w-4]|r[w-3]<<8,R=w+_;if(R>i){l&&Bi(0);break}o&&c(u+_),t.set(r.subarray(w,R),u),e.b=u+=_,e.p=h=R*8,e.f=d;continue}if(h>b){l&&Bi(0);break}}o&&c(u+131072);for(var oe=(1<<v)-1,te=(1<<g)-1,ve=h;;ve=h){var O=f[zd(r,h)&oe],ce=O>>4;if(h+=O&15,h>b){l&&Bi(0);break}if(O||Bi(2),ce<256)t[u++]=ce;else if(ce==256){ve=h,f=null;break}else{var Q=ce-254;if(ce>264){var C=ce-257,re=cv[C];Q=Fi(r,h,(1<<re)-1)+fv[C],h+=re}var J=m[zd(r,h)&te],ne=J>>4;J||Bi(3),h+=J&15;var K=GA[ne];if(ne>3){var re=dv[ne];K+=zd(r,h)&(1<<re)-1,h+=re}if(h>b){l&&Bi(0);break}o&&c(u+131072);var ue=u+Q;if(u<K){var Te=s-K,_e=Math.min(K,ue);for(Te+u<0&&Bi(3);u<_e;++u)t[u]=n[Te+u]}for(;u<ue;++u)t[u]=t[u-K]}}e.l=f,e.p=ve,e.b=u,e.f=d,f&&(d=1,e.m=v,e.d=m,e.n=g)}while(!d);return u!=t.length&&a?XA(t,0,u):t.subarray(0,u)},YA=new Ci(0),KA=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&Bi(6,"invalid zlib data"),(r[1]>>5&1)==1&&Bi(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function $A(r,e){return ZA(r.subarray(KA(r),-4),{i:2},e,e)}var QA=typeof TextDecoder<"u"&&new TextDecoder,JA=0;try{QA.decode(YA,{stream:!0}),JA=1}catch{}let Tt,fn,ei;class e1 extends di{constructor(e){super(e)}load(e,t,n,i){const s=this,a=s.path===""?Ks.extractUrlBase(e):s.path,o=new $s(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(a1(e))Tt=new r1().parse(e);else{const i=bv(e);if(!o1(i))throw new Error("THREE.FBXLoader: Unknown format.");if(zm(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+zm(i));Tt=new s1().parse(i)}const n=new No(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new t1(n,this.manager).parse(Tt)}}class t1{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){fn=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),s=new n1().parse(i);return this.parseScene(i,s,n),ei}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?Pi:li,n.wrapT=o===0?Pi:li,"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 Bt;const a=s.path;a||s.setPath(this.textureLoader.path);const o=fn.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),!fn.has(n))return null;const a=this.parseParameters(e,t,n);let o;switch(s.toLowerCase()){case"phong":o=new Ri;break;case"lambert":o=new On;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),o=new Ri;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=dt.toWorkingColorSpace(new Le().fromArray(e.Diffuse.value),gt):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=dt.toWorkingColorSpace(new Le().fromArray(e.DiffuseColor.value),gt)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=dt.toWorkingColorSpace(new Le().fromArray(e.Emissive.value),gt):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=dt.toWorkingColorSpace(new Le().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=dt.toWorkingColorSpace(new Le().fromArray(e.Specular.value),gt):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=dt.toWorkingColorSpace(new Le().fromArray(e.SpecularColor.value),gt));const s=this;return fn.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=uc,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=fn.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=fn.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 ke().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=fn.get(parseInt(s.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,n.push(o)}return n}parseScene(e,t,n){ei=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),fn.get(l.ID).parents.forEach(function(h){const u=i.get(h.ID);u!==void 0&&u.add(l)}),l.parent===null&&ei.add(l)}),this.bindSkeleton(e.skeletons,t,i),this.addGlobalSceneSettings(),ei.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=gv(l.userData.transformData);l.applyMatrix4(c),l.updateWorldMatrix()}});const o=new i1().parse();ei.children.length===1&&ei.children[0].isGroup&&(ei.children[0].animations=o,ei=ei.children[0]),ei.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=fn.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 So;break;case"Null":default:d=new Vt;break}d.name=l.attrName?Nt.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 So,s.matrixWorld.copy(c.transformLink),s.name=i?Nt.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=dt.toWorkingColorSpace(new Le().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 yc(s,a,o,l);break;case 1:t=new Ic(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 nf(s,a,o,c,d,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new yc(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 Ri({name:di.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 Ri;o.push(c)}}return s.FBX_Deformer?(i=new qu(s,a),i.normalizeSkinWeights()):i=new Ae(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 Yn({name:di.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new Wn(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Co(t.RotationOrder.value):n.eulerOrder=Co(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&&fn.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),ei.add(e.target)):e.lookAt(new L().fromArray(a))}}})}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const s in e){const a=e[s];fn.get(parseInt(a.ID)).parents.forEach(function(l){if(t.has(l.ID)){const c=l.ID;fn.get(c).parents.forEach(function(h){n.has(h.ID)&&n.get(h.ID).bind(new Po(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 ke().fromArray(s.Matrix.a)}):e[i.Node]=new ke().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 Le().setRGB(t,n,i,gt);ei.add(new Xb(s,1))}}"UnitScaleFactor"in Tt.GlobalSettings&&(ei.userData.unitScaleFactor=Tt.GlobalSettings.UnitScaleFactor.value)}}}class n1{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=fn.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=Co(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=gv(c);return this.genGeometry(t,o,s,d)}genGeometry(e,t,n,i){const s=new mt;e.attrName&&(s.name=e.attrName);const a=this.parseGeoNode(e,t),o=this.genBuffers(a),l=new Fe(o.vertex,3);if(l.applyMatrix4(i),s.setAttribute("position",l),o.colors.length>0&&s.setAttribute("color",new Fe(o.colors,3)),t&&(s.setAttribute("skinIndex",new Wu(o.weightsIndices,4)),s.setAttribute("skinWeight",new Fe(o.vertexWeights,4)),s.FBX_Deformer=t),o.normal.length>0){const c=new xt().getNormalMatrix(i),d=new Fe(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 Fe(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 v,g=!1;f<0&&(f=f^-1,g=!0);let b=[],y=[];if(a.push(f*3,f*3+1,f*3+2),e.color){const w=zl(m,n,f,e.color);l.push(w[0],w[1],w[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(w){y.push(w.weight),b.push(w.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 w=[0,0,0,0],_=[0,0,0,0];y.forEach(function(R,T){let P=R,M=b[T];_.forEach(function(x,S,C){if(P>x){C[S]=P,P=x;const k=w[S];w[S]=M,M=k}})}),b=w,y=_}for(;y.length<4;)y.push(0),b.push(0);for(let w=0;w<4;++w)d.push(y[w]),h.push(b[w])}if(e.normal){const w=zl(m,n,f,e.normal);o.push(w[0],w[1],w[2])}e.material&&e.material.mappingType!=="AllSame"&&(v=zl(m,n,f,e.material)[0],v<0&&(u.negativeMaterialIndices=!0,v=0)),e.uv&&e.uv.forEach(function(w,_){const R=zl(m,n,f,w);c[_]===void 0&&(c[_]=[]),c[_].push(R[0]),c[_].push(R[1])}),i++,g&&(u.genFace(t,e,a,v,o,l,c,d,h,i),n++,i=0,a=[],o=[],l=[],c=[],d=[],h=[])}),t}getNormalNewell(e){const t=new L(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 L(0,1,0):new L(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 ge(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 b=0;b<n.length;b+=3)u.push(new L(f[n[b]],f[n[b+1]],f[n[b+2]]));const{tangent:m,bitangent:v}=this.getNormalTangentAndBitangent(u),g=[];for(const b of u)g.push(this.flattenVertex(b,m,v));h=ga.triangulateShape(g,[])}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(v,g){e.uvs[g]===void 0&&(e.uvs[g]=[]),e.uvs[g].push(o[g][u*2]),e.uvs[g].push(o[g][u*2+1]),e.uvs[g].push(o[g][f*2]),e.uvs[g].push(o[g][f*2+1]),e.uvs[g].push(o[g][m*2]),e.uvs[g].push(o[g][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 v=0;v<c.length;v++){const g=c[v]*3;h[g]=l[v*3],h[g+1]=l[v*3+1],h[g+2]=l[v*3+2]}const u={vertexIndices:o,vertexPositions:h,baseVertexPositions:a},f=this.genBuffers(u),m=new Fe(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 Le;a<i.length;a+=4)o.fromArray(i,a),dt.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 mt;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 IA(n,i,s,o,l).getPoints(s.length*12);return new mt().setFromPoints(d)}}class i1{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(l1),values:t[n].KeyValueFloat.a},s=fn.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=fn.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=fn.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?Nt.sanitizeNodeName(u.attrName):"",ID:u.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ei.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 ke),"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=fn.get(l.ID).parents.filter(function(b){return b.relationship!==void 0})[0].ID,u=fn.get(h).parents[0].ID,f=fn.get(u).parents[0].ID,m=fn.get(f).parents[0].ID,v=Tt.Objects.Model[m],g={modelName:v.attrName?Nt.sanitizeNodeName(v.attrName):"",morphName:Tt.Objects.Deformer[h].attrName};s[c]=g}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=fn.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 vc(e.name,-1,t)}generateTracks(e){const t=[];let n=new L,i=new L;if(e.transform&&e.transform.decompose(n,new Dt,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 Ms(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=Co(0);n!==void 0&&(n=n.map(bt.degToRad),n.push(l),n=new dn().fromArray(n),n=new Dt().setFromEuler(n)),i!==void 0&&(i=i.map(bt.degToRad),i.push(l),i=new dn().fromArray(i),i=new Dt().setFromEuler(i).invert());const c=new Dt,d=new dn,h=[];if(!o||!a)return new Ss(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 Dt().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 Ss(e+".quaternion",a,h)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(s){return s/100}),i=ei.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Er(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 v=Math.max(...f)/180,g=new dn(...c,i),b=new dn(...h,i),y=new Dt().setFromEuler(g),w=new Dt().setFromEuler(b);y.dot(w)&&w.set(-w.x,-w.y,-w.z,-w.w);const _=e.times[o-1],R=e.times[o]-_,T=new Dt,P=new dn;for(let M=0;M<1;M+=1/v)T.copy(y.clone().slerp(w.clone(),M)),s.push(_+M*R),P.setFromQuaternion(T,i),a.push(P.x),a.push(P.y),a.push(P.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 s1{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 mv,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],d1(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=Gd(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Gd(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=Gd(c);break}this.getPrevNode()[s]={type:a,type2:o,flag:l,value:c},this.setCurrentProp(this.getPrevNode(),s)}}class r1{parse(e){const t=new Bm(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 mv;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=$A(new Uint8Array(e.getArrayBuffer(a))),l=new Bm(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 Bm{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 mv{add(e,t){this[e]=t}}function a1(r){const e="Kaydara FBX Binary \0";return r.byteLength>=e.length&&e===bv(r,0,e.length)}function o1(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 zm(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 l1(r){return r/46186158e3}const c1=[];function zl(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 h1(c1,n.buffer,s,a)}const Hd=new dn,na=new L;function gv(r){const e=new ke,t=new ke,n=new ke,i=new ke,s=new ke,a=new ke,o=new ke,l=new ke,c=new ke,d=new ke,h=new ke,u=new ke,f=r.inheritType?r.inheritType:0;r.translation&&e.setPosition(na.fromArray(r.translation));const m=Co(0);if(r.preRotation){const C=r.preRotation.map(bt.degToRad);C.push(m),t.makeRotationFromEuler(Hd.fromArray(C))}if(r.rotation){const C=r.rotation.map(bt.degToRad);C.push(r.eulerOrder||m),n.makeRotationFromEuler(Hd.fromArray(C))}if(r.postRotation){const C=r.postRotation.map(bt.degToRad);C.push(m),i.makeRotationFromEuler(Hd.fromArray(C)),i.invert()}r.scale&&s.scale(na.fromArray(r.scale)),r.scalingOffset&&o.setPosition(na.fromArray(r.scalingOffset)),r.scalingPivot&&a.setPosition(na.fromArray(r.scalingPivot)),r.rotationOffset&&l.setPosition(na.fromArray(r.rotationOffset)),r.rotationPivot&&c.setPosition(na.fromArray(r.rotationPivot)),r.parentMatrixWorld&&(h.copy(r.parentMatrix),d.copy(r.parentMatrixWorld));const v=t.clone().multiply(n).multiply(i),g=new ke;g.extractRotation(d);const b=new ke;b.copyPosition(d);const y=b.clone().invert().multiply(d),w=g.clone().invert().multiply(y),_=s,R=new ke;if(f===0)R.copy(g).multiply(v).multiply(w).multiply(_);else if(f===1)R.copy(g).multiply(w).multiply(v).multiply(_);else{const k=new ke().scale(new L().setFromMatrixScale(h)).clone().invert(),I=w.clone().multiply(k);R.copy(g).multiply(v).multiply(I).multiply(_)}const T=c.clone().invert(),P=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(P);const x=new ke().copyPosition(M),S=d.clone().multiply(x);return u.copyPosition(S),M=u.clone().multiply(R),M.premultiply(d.invert()),M}function Co(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 Gd(r){return r.split(",").map(function(t){return parseFloat(t)})}function bv(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=r.byteLength),new TextDecoder().decode(new Uint8Array(r,e,t))}function d1(r,e){for(let t=0,n=r.length,i=e.length;t<i;t++,n++)r[n]=e[t]}function h1(r,e,t,n){for(let i=t,s=0;i<n;i++,s++)r[s]=e[i];return r}const vv={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
4231
|
-
|
|
4232
|
-
varying vec2 vUv;
|
|
4233
|
-
|
|
4234
|
-
void main() {
|
|
4235
|
-
|
|
4236
|
-
vUv = uv;
|
|
4237
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4238
|
-
|
|
4239
|
-
}`,fragmentShader:`
|
|
4240
|
-
|
|
4241
|
-
uniform float opacity;
|
|
4242
|
-
|
|
4243
|
-
uniform sampler2D tDiffuse;
|
|
4244
|
-
|
|
4245
|
-
varying vec2 vUv;
|
|
4246
|
-
|
|
4247
|
-
void main() {
|
|
4248
|
-
|
|
4249
|
-
vec4 texel = texture2D( tDiffuse, vUv );
|
|
4250
|
-
gl_FragColor = opacity * texel;
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
}`};class u1 extends Fa{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof wn?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Na.clone(e.uniforms),this.material=new wn({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new hf(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(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 Hm extends Fa{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const i=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),s.buffers.stencil.setFunc(i.ALWAYS,a,4294967295),s.buffers.stencil.setClear(o),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(i.EQUAL,1,4294967295),s.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),s.buffers.stencil.setLocked(!0)}}class f1 extends Fa{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class p1{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new ge);this._width=n.width,this._height=n.height,t=new ti(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Ti}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new u1(vv),this.copyPass.material.blending=Xi,this.clock=new sf}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let i=0,s=this.passes.length;i<s;i++){const a=this.passes[i];if(a.enabled!==!1){if(a.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),a.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),a.needsSwap){if(n){const o=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),l.setFunc(o.EQUAL,1,4294967295)}this.swapBuffers()}Hm!==void 0&&(a instanceof Hm?n=!0:a instanceof f1&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new ge);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(n,i),this.renderTarget2.setSize(n,i);for(let s=0;s<this.passes.length;s++)this.passes[s].setSize(n,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class xs extends Fa{constructor(e,t,n,i){super(),this.renderScene=t,this.renderCamera=n,this.selectedObjects=i!==void 0?i:[],this.visibleEdgeColor=new Le(1,1,1),this.hiddenEdgeColor=new Le(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,this._visibilityCache=new Map,this._selectionCache=new Set,this.resolution=e!==void 0?new ge(e.x,e.y):new ge(256,256);const s=Math.round(this.resolution.x/this.downSampleRatio),a=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new ti(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new Gb,this.depthMaterial.side=sn,this.depthMaterial.depthPacking=wb,this.depthMaterial.blending=Xi,this.prepareMaskMaterial=this.getPrepareMaskMaterial(),this.prepareMaskMaterial.side=sn,this.prepareMaskMaterial.fragmentShader=d(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetDepthBuffer=new ti(this.resolution.x,this.resolution.y,{type:Ti}),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new ti(s,a,{type:Ti}),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new ti(s,a,{type:Ti}),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new ti(Math.round(s/2),Math.round(a/2),{type:Ti}),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new ti(s,a,{type:Ti}),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new ti(Math.round(s/2),Math.round(a/2),{type:Ti}),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;const o=4,l=4;this.separableBlurMaterial1=this.getSeparableBlurMaterial(o),this.separableBlurMaterial1.uniforms.texSize.value.set(s,a),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeparableBlurMaterial(l),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(s/2),Math.round(a/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=l,this.overlayMaterial=this.getOverlayMaterial();const c=vv;this.copyUniforms=Na.clone(c.uniforms),this.materialCopy=new wn({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:Xi,depthTest:!1,depthWrite:!1}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new Le,this.oldClearAlpha=1,this.fsQuad=new hf(null),this.tempPulseColor1=new Le,this.tempPulseColor2=new Le,this.textureMatrix=new ke;function d(h,u){const f=u.isPerspectiveCamera?"perspective":"orthographic";return h.replace(/DEPTH_TO_VIEW_Z/g,f+"DepthToViewZ")}}dispose(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),this.depthMaterial.dispose(),this.prepareMaskMaterial.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){this.renderTargetMaskBuffer.setSize(e,t),this.renderTargetDepthBuffer.setSize(e,t);let n=Math.round(e/this.downSampleRatio),i=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(n,i),this.renderTargetBlurBuffer1.setSize(n,i),this.renderTargetEdgeBuffer1.setSize(n,i),this.separableBlurMaterial1.uniforms.texSize.value.set(n,i),n=Math.round(n/2),i=Math.round(i/2),this.renderTargetBlurBuffer2.setSize(n,i),this.renderTargetEdgeBuffer2.setSize(n,i),this.separableBlurMaterial2.uniforms.texSize.value.set(n,i)}updateSelectionCache(){const e=this._selectionCache;function t(n){n.isMesh&&e.add(n)}e.clear();for(let n=0;n<this.selectedObjects.length;n++)this.selectedObjects[n].traverse(t)}changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;for(const n of this._selectionCache)e===!0?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e)}changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,n=this._selectionCache;function i(s){if(s.isMesh||s.isSprite){if(!n.has(s)){const a=s.visible;(e===!1||t.get(s)===!0)&&(s.visible=e),t.set(s,a)}}else(s.isPoints||s.isLine)&&(e===!0?s.visible=t.get(s):(t.set(s,s.visible),s.visible=e))}this.renderScene.traverse(i)}updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,n,i,s){if(this.selectedObjects.length>0){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const a=e.autoClear;e.autoClear=!1,s&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this.updateSelectionCache(),this.changeVisibilityOfSelectedObjects(!1);const o=this.renderScene.background,l=this.renderScene.overrideMaterial;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this.updateTextureMatrix(),this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this._selectionCache.clear(),this.renderScene.background=o,this.renderScene.overrideMaterial=l,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const c=.625+Math.cos(performance.now()*.01/this.pulsePeriod)*.75/2;this.tempPulseColor1.multiplyScalar(c),this.tempPulseColor2.multiplyScalar(c)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=xs.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=xs.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=xs.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=xs.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,s&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=a}this.renderToScreen&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}getPrepareMaskMaterial(){return new wn({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new ge(.5,.5)},textureMatrix:{value:null}},vertexShader:`#include <morphtarget_pars_vertex>
|
|
4254
|
-
#include <skinning_pars_vertex>
|
|
4255
|
-
|
|
4256
|
-
varying vec4 projTexCoord;
|
|
4257
|
-
varying vec4 vPosition;
|
|
4258
|
-
uniform mat4 textureMatrix;
|
|
4259
|
-
|
|
4260
|
-
void main() {
|
|
4261
|
-
|
|
4262
|
-
#include <skinbase_vertex>
|
|
4263
|
-
#include <begin_vertex>
|
|
4264
|
-
#include <morphtarget_vertex>
|
|
4265
|
-
#include <skinning_vertex>
|
|
4266
|
-
#include <project_vertex>
|
|
4267
|
-
|
|
4268
|
-
vPosition = mvPosition;
|
|
4269
|
-
|
|
4270
|
-
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
4271
|
-
|
|
4272
|
-
#ifdef USE_INSTANCING
|
|
4273
|
-
|
|
4274
|
-
worldPosition = instanceMatrix * worldPosition;
|
|
4275
|
-
|
|
4276
|
-
#endif
|
|
4277
|
-
|
|
4278
|
-
worldPosition = modelMatrix * worldPosition;
|
|
4279
|
-
|
|
4280
|
-
projTexCoord = textureMatrix * worldPosition;
|
|
4281
|
-
|
|
4282
|
-
}`,fragmentShader:`#include <packing>
|
|
4283
|
-
varying vec4 vPosition;
|
|
4284
|
-
varying vec4 projTexCoord;
|
|
4285
|
-
uniform sampler2D depthTexture;
|
|
4286
|
-
uniform vec2 cameraNearFar;
|
|
4287
|
-
|
|
4288
|
-
void main() {
|
|
4289
|
-
|
|
4290
|
-
float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));
|
|
4291
|
-
float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );
|
|
4292
|
-
float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;
|
|
4293
|
-
gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);
|
|
4294
|
-
|
|
4295
|
-
}`})}getEdgeDetectionMaterial(){return new wn({uniforms:{maskTexture:{value:null},texSize:{value:new ge(.5,.5)},visibleEdgeColor:{value:new L(1,1,1)},hiddenEdgeColor:{value:new L(1,1,1)}},vertexShader:`varying vec2 vUv;
|
|
4296
|
-
|
|
4297
|
-
void main() {
|
|
4298
|
-
vUv = uv;
|
|
4299
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4300
|
-
}`,fragmentShader:`varying vec2 vUv;
|
|
4301
|
-
|
|
4302
|
-
uniform sampler2D maskTexture;
|
|
4303
|
-
uniform vec2 texSize;
|
|
4304
|
-
uniform vec3 visibleEdgeColor;
|
|
4305
|
-
uniform vec3 hiddenEdgeColor;
|
|
4306
|
-
|
|
4307
|
-
void main() {
|
|
4308
|
-
vec2 invSize = 1.0 / texSize;
|
|
4309
|
-
vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);
|
|
4310
|
-
vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);
|
|
4311
|
-
vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);
|
|
4312
|
-
vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);
|
|
4313
|
-
vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);
|
|
4314
|
-
float diff1 = (c1.r - c2.r)*0.5;
|
|
4315
|
-
float diff2 = (c3.r - c4.r)*0.5;
|
|
4316
|
-
float d = length( vec2(diff1, diff2) );
|
|
4317
|
-
float a1 = min(c1.g, c2.g);
|
|
4318
|
-
float a2 = min(c3.g, c4.g);
|
|
4319
|
-
float visibilityFactor = min(a1, a2);
|
|
4320
|
-
vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;
|
|
4321
|
-
gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);
|
|
4322
|
-
}`})}getSeparableBlurMaterial(e){return new wn({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new ge(.5,.5)},direction:{value:new ge(.5,.5)},kernelRadius:{value:1}},vertexShader:`varying vec2 vUv;
|
|
4323
|
-
|
|
4324
|
-
void main() {
|
|
4325
|
-
vUv = uv;
|
|
4326
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4327
|
-
}`,fragmentShader:`#include <common>
|
|
4328
|
-
varying vec2 vUv;
|
|
4329
|
-
uniform sampler2D colorTexture;
|
|
4330
|
-
uniform vec2 texSize;
|
|
4331
|
-
uniform vec2 direction;
|
|
4332
|
-
uniform float kernelRadius;
|
|
4333
|
-
|
|
4334
|
-
float gaussianPdf(in float x, in float sigma) {
|
|
4335
|
-
return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
|
|
4336
|
-
}
|
|
4337
|
-
|
|
4338
|
-
void main() {
|
|
4339
|
-
vec2 invSize = 1.0 / texSize;
|
|
4340
|
-
float sigma = kernelRadius/2.0;
|
|
4341
|
-
float weightSum = gaussianPdf(0.0, sigma);
|
|
4342
|
-
vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;
|
|
4343
|
-
vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);
|
|
4344
|
-
vec2 uvOffset = delta;
|
|
4345
|
-
for( int i = 1; i <= MAX_RADIUS; i ++ ) {
|
|
4346
|
-
float x = kernelRadius * float(i) / float(MAX_RADIUS);
|
|
4347
|
-
float w = gaussianPdf(x, sigma);
|
|
4348
|
-
vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);
|
|
4349
|
-
vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);
|
|
4350
|
-
diffuseSum += ((sample1 + sample2) * w);
|
|
4351
|
-
weightSum += (2.0 * w);
|
|
4352
|
-
uvOffset += delta;
|
|
4353
|
-
}
|
|
4354
|
-
gl_FragColor = diffuseSum/weightSum;
|
|
4355
|
-
}`})}getOverlayMaterial(){return new wn({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:`varying vec2 vUv;
|
|
4356
|
-
|
|
4357
|
-
void main() {
|
|
4358
|
-
vUv = uv;
|
|
4359
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4360
|
-
}`,fragmentShader:`varying vec2 vUv;
|
|
4361
|
-
|
|
4362
|
-
uniform sampler2D maskTexture;
|
|
4363
|
-
uniform sampler2D edgeTexture1;
|
|
4364
|
-
uniform sampler2D edgeTexture2;
|
|
4365
|
-
uniform sampler2D patternTexture;
|
|
4366
|
-
uniform float edgeStrength;
|
|
4367
|
-
uniform float edgeGlow;
|
|
4368
|
-
uniform bool usePatternTexture;
|
|
4369
|
-
|
|
4370
|
-
void main() {
|
|
4371
|
-
vec4 edgeValue1 = texture2D(edgeTexture1, vUv);
|
|
4372
|
-
vec4 edgeValue2 = texture2D(edgeTexture2, vUv);
|
|
4373
|
-
vec4 maskColor = texture2D(maskTexture, vUv);
|
|
4374
|
-
vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);
|
|
4375
|
-
float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;
|
|
4376
|
-
vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;
|
|
4377
|
-
vec4 finalColor = edgeStrength * maskColor.r * edgeValue;
|
|
4378
|
-
if(usePatternTexture)
|
|
4379
|
-
finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);
|
|
4380
|
-
gl_FragColor = finalColor;
|
|
4381
|
-
}`,blending:Mh,depthTest:!1,depthWrite:!1,transparent:!0})}}xs.BlurDirectionX=new ge(1,0);xs.BlurDirectionY=new ge(0,1);const m1={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
|
4382
|
-
precision highp float;
|
|
4383
|
-
|
|
4384
|
-
uniform mat4 modelViewMatrix;
|
|
4385
|
-
uniform mat4 projectionMatrix;
|
|
4386
|
-
|
|
4387
|
-
attribute vec3 position;
|
|
4388
|
-
attribute vec2 uv;
|
|
4389
|
-
|
|
4390
|
-
varying vec2 vUv;
|
|
4391
|
-
|
|
4392
|
-
void main() {
|
|
4393
|
-
|
|
4394
|
-
vUv = uv;
|
|
4395
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4396
|
-
|
|
4397
|
-
}`,fragmentShader:`
|
|
4398
|
-
|
|
4399
|
-
precision highp float;
|
|
4400
|
-
|
|
4401
|
-
uniform sampler2D tDiffuse;
|
|
4402
|
-
|
|
4403
|
-
#include <tonemapping_pars_fragment>
|
|
4404
|
-
#include <colorspace_pars_fragment>
|
|
4405
|
-
|
|
4406
|
-
varying vec2 vUv;
|
|
4407
|
-
|
|
4408
|
-
void main() {
|
|
4409
|
-
|
|
4410
|
-
gl_FragColor = texture2D( tDiffuse, vUv );
|
|
4411
|
-
|
|
4412
|
-
// tone mapping
|
|
4413
|
-
|
|
4414
|
-
#ifdef LINEAR_TONE_MAPPING
|
|
4415
|
-
|
|
4416
|
-
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
|
|
4417
|
-
|
|
4418
|
-
#elif defined( REINHARD_TONE_MAPPING )
|
|
4419
|
-
|
|
4420
|
-
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
|
|
4421
|
-
|
|
4422
|
-
#elif defined( CINEON_TONE_MAPPING )
|
|
4423
|
-
|
|
4424
|
-
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
|
|
4425
|
-
|
|
4426
|
-
#elif defined( ACES_FILMIC_TONE_MAPPING )
|
|
4427
|
-
|
|
4428
|
-
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
|
|
4429
|
-
|
|
4430
|
-
#elif defined( AGX_TONE_MAPPING )
|
|
4431
|
-
|
|
4432
|
-
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
|
|
4433
|
-
|
|
4434
|
-
#elif defined( NEUTRAL_TONE_MAPPING )
|
|
4435
|
-
|
|
4436
|
-
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
|
|
4437
|
-
|
|
4438
|
-
#elif defined( CUSTOM_TONE_MAPPING )
|
|
4439
|
-
|
|
4440
|
-
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
|
|
4441
|
-
|
|
4442
|
-
#endif
|
|
4443
|
-
|
|
4444
|
-
// color space
|
|
4445
|
-
|
|
4446
|
-
#ifdef SRGB_TRANSFER
|
|
4447
|
-
|
|
4448
|
-
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4449
|
-
|
|
4450
|
-
#endif
|
|
4451
|
-
|
|
4452
|
-
}`};class g1 extends Fa{constructor(){super();const e=m1;this.uniforms=Na.clone(e.uniforms),this.material=new $x({name:e.name,uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader}),this.fsQuad=new hf(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={},dt.getTransfer(this._outputColorSpace)===Ht&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===ib?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===sb?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===rb?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===ab?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===lb?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===cb?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===ob&&(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 b1 extends Fa{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 Le}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}}const v1=`
|
|
4225
|
+
`);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 AT(){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(v=>v.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 v={index:null,attributes:[]};for(const g in d){const b=self[h[g]];let y,w;if(c.useUniqueIDs)w=d[g],y=o.GetAttributeByUniqueId(u,w);else{if(w=o.GetAttributeId(u,a[d[g]]),w===-1)continue;y=o.GetAttribute(u,w)}const _=i(a,o,u,g,b,y);g==="color"&&(_.vertexColorSpace=c.vertexColorSpace),v.attributes.push(_)}return m===a.TRIANGULAR_MESH&&(v.index=n(a,o,u)),a.destroy(u),v}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,v=m*d.BYTES_PER_ELEMENT,g=s(a,d),b=a._malloc(v);o.GetAttributeDataArrayForAllPoints(l,h,g,v,b);const y=new d(a.HEAPF32.buffer,b,m).slice();return a._free(b),{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 Nm(r,e){if(e===f0)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===ou||e===_b){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===ou)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 Rr extends di{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new DT(t)}),this.register(function(t){return new LT(t)}),this.register(function(t){return new GT(t)}),this.register(function(t){return new VT(t)}),this.register(function(t){return new WT(t)}),this.register(function(t){return new kT(t)}),this.register(function(t){return new OT(t)}),this.register(function(t){return new FT(t)}),this.register(function(t){return new UT(t)}),this.register(function(t){return new NT(t)}),this.register(function(t){return new BT(t)}),this.register(function(t){return new IT(t)}),this.register(function(t){return new HT(t)}),this.register(function(t){return new zT(t)}),this.register(function(t){return new PT(t)}),this.register(function(t){return new jT(t)}),this.register(function(t){return new XT(t)})}load(e,t,n,i){const s=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=Ks.extractUrlBase(e);a=Ks.resolveURL(c,this.path)}else a=Ks.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 $s(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))===sv){try{a[Ct.KHR_BINARY_GLTF]=new qT(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 aA(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 RT;break;case Ct.KHR_DRACO_MESH_COMPRESSION:a[h]=new ZT(s,this.dracoLoader);break;case Ct.KHR_TEXTURE_TRANSFORM:a[h]=new YT;break;case Ct.KHR_MESH_QUANTIZATION:a[h]=new KT;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 CT(){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 PT{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 Le(16777215);l.color!==void 0&&d.setRGB(l.color[0],l.color[1],l.color[2],Kn);const h=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new Ic(d),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new yc(d),c.distance=h;break;case"spot":c=new nf(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),bs(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 RT{constructor(){this.name=Ct.KHR_MATERIALS_UNLIT}getMaterialType(){return jt}extendParams(e,t,n){const i=[];e.color=new Le(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],Kn),e.opacity=a[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,gt))}return Promise.all(i)}}class NT{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 DT{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:is}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 ge(o,o)}return Promise.all(s)}}class LT{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:is}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 IT{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:is}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 kT{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:is}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 Le(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],Kn)}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 OT{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:is}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 FT{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:is}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 Le().setRGB(o[0],o[1],o[2],Kn),Promise.all(s)}}class UT{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:is}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 BT{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:is}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 Le().setRGB(o[0],o[1],o[2],Kn),a.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,gt)),Promise.all(s)}}class zT{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:is}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 HT{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:is}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 GT{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 VT{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 WT{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 jT{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 XT{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!==Ei.TRIANGLES&&c.mode!==Ei.TRIANGLE_STRIP&&c.mode!==Ei.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 v=new ke,g=new L,b=new Dt,y=new L(1,1,1),w=new gx(m.geometry,m.material,u);for(let _=0;_<u;_++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,_),l.ROTATION&&b.fromBufferAttribute(l.ROTATION,_),l.SCALE&&y.fromBufferAttribute(l.SCALE,_),w.setMatrixAt(_,v.compose(g,b,y));for(const _ in l)if(_==="_COLOR_0"){const R=l[_];w.instanceColor=new du(R.array,R.itemSize,R.normalized)}else _!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&m.geometry.setAttribute(_,l[_]);Pt.prototype.copy.call(w,m),this.parser.assignFinalMaterial(w),f.push(w)}return d.isGroup?(d.clear(),d.add(...f),d):f[0]}))}}const sv="glTF",eo=12,Dm={JSON:1313821514,BIN:5130562};class qT{constructor(e){this.name=Ct.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,eo),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!==sv)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-eo,s=new DataView(e,eo);let a=0;for(;a<i;){const o=s.getUint32(a,!0);a+=4;const l=s.getUint32(a,!0);if(a+=4,l===Dm.JSON){const c=new Uint8Array(e,eo+a,o);this.content=n.decode(c)}else if(l===Dm.BIN){const c=eo+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class ZT{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=vu[d]||d.toLowerCase();o[h]=a[d]}for(const d in e.attributes){const h=vu[d]||d.toLowerCase();if(a[d]!==void 0){const u=n.accessors[e.attributes[d]],f=va[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 v=f.attributes[m],g=l[m];g!==void 0&&(v.normalized=g)}h(f)},o,c,Kn,u)})})}}class YT{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 KT{constructor(){this.name=Ct.KHR_MESH_QUANTIZATION}}class rv extends Ro{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,v=m-c,g=-2*f+3*u,b=f-u,y=1-g,w=b-u+h;for(let _=0;_!==o;_++){const R=a[v+_+o],T=a[v+_+l]*d,P=a[m+_+o],M=a[m+_]*d;s[_]=y*R+w*T+g*P+b*M}return s}}const $T=new Dt;class QT extends rv{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return $T.fromArray(s).normalize().toArray(s),s}}const Ei={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},va={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Lm={9728:Sn,9729:bn,9984:hb,9985:ec,9986:oo,9987:Gi},Im={33071:li,33648:fc,10497:Pi},kd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},vu={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"},JT={CUBICSPLINE:void 0,LINEAR:_o,STEP:xo},Od={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function eA(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new Dc({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:xi})),r.DefaultMaterial}function lr(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 bs(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 tA(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 nA(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 iA(r){let e;const t=r.extensions&&r.extensions[Ct.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Fd(t.attributes):e=r.indices+":"+Fd(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+Fd(r.targets[n]);return e}function Fd(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 yu(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 sA(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 rA=new ke;class aA{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new CT,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 No(this.options.manager):this.textureLoader=new p_(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new $s(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 lr(s,o,i),bs(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(Ks.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=kd[i.type],o=va[i.componentType],l=i.normalized===!0,c=new o(i.count*a);return Promise.resolve(new vn(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=kd[i.type],c=va[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 v,g;if(f&&f!==h){const b=Math.floor(u/f),y="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+b+":"+i.count;let w=t.cache.get(y);w||(v=new c(o,b*f,i.count*f/d),w=new Xu(v,f/d),t.cache.add(y,w)),g=new Wi(w,l,u%f/d,m)}else o===null?v=new c(i.count*l):v=new c(o,u,i.count*l),g=new vn(v,l,m);if(i.sparse!==void 0){const b=kd.SCALAR,y=va[i.sparse.indices.componentType],w=i.sparse.indices.byteOffset||0,_=i.sparse.values.byteOffset||0,R=new y(a[1],w,i.sparse.count*b),T=new c(a[2],_,i.sparse.count*l);o!==null&&(g=new vn(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let P=0,M=R.length;P<M;P++){const x=R[P];if(g.setX(x,T[P*l]),l>=2&&g.setY(x,T[P*l+1]),l>=3&&g.setZ(x,T[P*l+2]),l>=4&&g.setW(x,T[P*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}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=Lm[u.magFilter]||bn,d.minFilter=Lm[u.minFilter]||Gi,d.wrapS=Im[u.wrapS]||Pi,d.wrapT=Im[u.wrapT]||Pi,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(v){const g=new Bt(v);g.needsUpdate=!0,u(g)}),t.load(Ks.resolveURL(h,s.path),m,void 0,f)})}).then(function(h){return c===!0&&o.revokeObjectURL(l),bs(h,a),h.userData.mimeType=a.mimeType||sA(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 aa,yi.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 Yn,yi.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 Dc}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 Le(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const u=h.baseColorFactor;o.color.setRGB(u[0],u[1],u[2],Kn),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=sn);const d=s.alphaMode||Od.OPAQUE;if(d===Od.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,d===Od.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 ge(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 Le().setRGB(h[0],h[1],h[2],Kn)}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),bs(h,s),t.associations.set(h,{materials:e}),s.extensions&&lr(i,h,s),h})}createUniqueName(e){const t=Nt.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 km(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],d=iA(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=km(new mt,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?eA(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 v=d[f],g=a[f];let b;const y=c[f];if(g.mode===Ei.TRIANGLES||g.mode===Ei.TRIANGLE_STRIP||g.mode===Ei.TRIANGLE_FAN||g.mode===void 0)b=s.isSkinnedMesh===!0?new qu(v,y):new Ae(v,y),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),g.mode===Ei.TRIANGLE_STRIP?b.geometry=Nm(b.geometry,_b):g.mode===Ei.TRIANGLE_FAN&&(b.geometry=Nm(b.geometry,ou));else if(g.mode===Ei.LINES)b=new Pr(v,y);else if(g.mode===Ei.LINE_STRIP)b=new Wn(v,y);else if(g.mode===Ei.LINE_LOOP)b=new Nb(v,y);else if(g.mode===Ei.POINTS)b=new lo(v,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(b.geometry.morphAttributes).length>0&&nA(b,s),b.name=t.createUniqueName(s.name||"mesh_"+e),bs(b,s),g.extensions&&lr(i,b,g),t.assignFinalMaterial(b),h.push(b)}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&&lr(i,h[0],s),h[0];const u=new Vt;s.extensions&&lr(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 Lo(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),bs(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 ke;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 Po(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],v=f.target,g=v.node,b=i.parameters!==void 0?i.parameters[m.input]:m.input,y=i.parameters!==void 0?i.parameters[m.output]:m.output;v.node!==void 0&&(a.push(this.getDependency("node",g)),o.push(this.getDependency("accessor",b)),l.push(this.getDependency("accessor",y)),c.push(m),d.push(v))}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],v=h[3],g=h[4],b=[];for(let y=0,w=u.length;y<w;y++){const _=u[y],R=f[y],T=m[y],P=v[y],M=g[y];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const x=n._createAnimationTracks(_,R,T,P,M);if(x)for(let S=0;S<x.length;S++)b.push(x[S])}return new vc(s,void 0,b)})}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,rA)});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 So: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),bs(d,s),s.extensions&&lr(n,d,s),s.matrix!==void 0){const h=new ke;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)),bs(s,n),n.extensions&&lr(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 yi||u instanceof Bt)&&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=Er;break;case Fs.rotation:c=Ss;break;case Fs.position:case Fs.scale:c=Ms;break;default:switch(n.itemSize){case 1:c=Er;break;case 2:case 3:default:c=Ms;break}break}const d=i.interpolation!==void 0?JT[i.interpolation]:_o,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=yu(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 Ss?QT:rv;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function oA(r,e,t){const n=e.attributes,i=new ln;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 L(l[0],l[1],l[2]),new L(c[0],c[1],c[2])),o.normalized){const d=yu(va[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 L,l=new L;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 v=yu(va[u.componentType]);l.multiplyScalar(v)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}r.boundingBox=i;const a=new ni;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=a}function km(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=vu[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 dt.workingColorSpace!==Kn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${dt.workingColorSpace}" not supported.`),bs(r,e),oA(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?tA(r,e.targets,t):r})}var lA=(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(b){s=b.instance,s.exports.__wasm_call_ctors()});function o(b){for(var y=new Uint8Array(b.length),w=0;w<b.length;++w){var _=b.charCodeAt(w);y[w]=_>96?_-97:_>64?_-39:_+4}for(var R=0,w=0;w<b.length;++w)y[R++]=y[w]<60?n[y[w]]:(y[w]-60)*64+y[++w];return y.buffer.slice(0,R)}function l(b,y,w,_,R,T){var P=s.exports.sbrk,M=w+3&-4,x=P(M*_),S=P(R.length),C=new Uint8Array(s.exports.memory.buffer);C.set(R,S);var k=b(x,w,_,S,R.length);if(k==0&&T&&T(x,M,_),y.set(C.subarray(x,x+w*_)),P(x-P(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(b){var y={object:new Worker(b),pending:0,requests:{}};return y.object.onmessage=function(w){var _=w.data;y.pending-=_.count,y.requests[_.id][_.action](_.value),delete y.requests[_.id]},y}function m(b){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()+g.toString(),w=new Blob([y],{type:"text/javascript"}),_=URL.createObjectURL(w),R=0;R<b;++R)h[R]=f(_);URL.revokeObjectURL(_)}function v(b,y,w,_,R){for(var T=h[0],P=1;P<h.length;++P)h[P].pending<T.pending&&(T=h[P]);return new Promise(function(M,x){var S=new Uint8Array(w),C=u++;T.pending+=b,T.requests[C]={resolve:M,reject:x},T.object.postMessage({id:C,count:b,size:y,source:S,mode:_,filter:R},[S.buffer])})}function g(b){a.then(function(){var y=b.data;try{var w=new Uint8Array(y.count*y.size);l(s.exports[y.mode],w,y.count,y.size,y.source,s.exports[y.filter]),self.postMessage({id:y.id,count:y.count,action:"resolve",value:w},[w.buffer])}catch(_){self.postMessage({id:y.id,count:y.count,action:"reject",value:_})}})}return{ready:a,supported:!0,useWorkers:function(b){m(b)},decodeVertexBuffer:function(b,y,w,_,R){l(s.exports.meshopt_decodeVertexBuffer,b,y,w,_,s.exports[c[R]])},decodeIndexBuffer:function(b,y,w,_){l(s.exports.meshopt_decodeIndexBuffer,b,y,w,_)},decodeIndexSequence:function(b,y,w,_){l(s.exports.meshopt_decodeIndexSequence,b,y,w,_)},decodeGltfBuffer:function(b,y,w,_,R,T){l(s.exports[d[R]],b,y,w,_,s.exports[c[T]])},decodeGltfBufferAsync:function(b,y,w,_,R){return h.length>0?v(b,y,w,d[_],c[R]):a.then(function(){var T=new Uint8Array(b*y);return l(s.exports[d[_]],T,b,y,w,s.exports[c[R]]),T})}}})();let Ul=null;const cA=["/gaia/"],Om=r=>{const e=new On;return"color"in r&&r.color instanceof Le&&e.color.copy(r.color),"map"in r&&r.map instanceof Bt&&(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},dA=r=>{r.traverse(e=>{e instanceof Ae&&(Array.isArray(e.material)?e.material=e.material.map(Om):e.material=Om(e.material))})},hA=r=>{const e=r.toLowerCase();return cA.some(t=>e.includes(t))},uA=()=>(Ul||(Ul=new Io,Ul.setDecoderPath(Bn("/draco/"))),Ul),av=(r,e,t)=>{if(/\.(gltf|glb)(\?|#|$)/i.test(r)){const n=new Rr(e);n.setDRACOLoader(uA()),n.setMeshoptDecoder(lA),n.load(r,i=>{const s=i.scene??new Vt;hA(r)&&dA(s),t(s)},void 0,i=>{console.warn("GLTF load error:",r,i),t(new Vt)});return}if(/\.stl(\?|#|$)/i.test(r)){new ev(e).load(r,i=>{const s=new Ae(i,new Dc({color:8421504}));t(s)},void 0,i=>{console.warn("STL load error:",r,i),t(new Vt)});return}if(/\.dae(\?|#|$)/i.test(r)){new tv(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)},Fm={type:"change"},df={type:"start"},ov={type:"end"},Bl=new Ra,Um=new Vs,fA=Math.cos(70*bt.DEG2RAD),_n=new L,ai=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},Ud=1e-6;class pA extends qb{constructor(e,t=null){super(e,t),this.state=Wt.NONE,this.enabled=!0,this.target=new L,this.cursor=new L,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:yr.ROTATE,MIDDLE:yr.DOLLY,RIGHT:yr.PAN},this.touches={ONE:Xs.ROTATE,TWO:Xs.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new L,this._lastQuaternion=new Dt,this._lastTargetPosition=new L,this._quat=new Dt().setFromUnitVectors(e.up,new L(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new kp,this._sphericalDelta=new kp,this._scale=1,this._panOffset=new L,this._rotateStart=new ge,this._rotateEnd=new ge,this._rotateDelta=new ge,this._panStart=new ge,this._panEnd=new ge,this._panDelta=new ge,this._dollyStart=new ge,this._dollyEnd=new ge,this._dollyDelta=new ge,this._dollyDirection=new L,this._mouse=new ge,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=gA.bind(this),this._onPointerDown=mA.bind(this),this._onPointerUp=bA.bind(this),this._onContextMenu=MA.bind(this),this._onMouseWheel=xA.bind(this),this._onKeyDown=_A.bind(this),this._onTouchStart=wA.bind(this),this._onTouchMove=SA.bind(this),this._onMouseDown=vA.bind(this),this._onMouseMove=yA.bind(this),this._interceptControlDown=EA.bind(this),this._interceptControlUp=TA.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(Fm),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+=ai:n>Math.PI&&(n-=ai),i<-Math.PI?i+=ai:i>Math.PI&&(i-=ai),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 L(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 L(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):(Bl.origin.copy(this.object.position),Bl.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Bl.direction))<fA?this.object.lookAt(this.target):(Um.setFromNormalAndCoplanarPoint(this.object.up,this.target),Bl.intersectPlane(Um,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)>Ud||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ud||this._lastTargetPosition.distanceToSquared(this.target)>Ud?(this.dispatchEvent(Fm),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ai/60*this.autoRotateSpeed*e:ai/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(ai*this._rotateDelta.x/t.clientHeight),this._rotateUp(ai*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(ai*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(-ai*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(ai*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(-ai*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(ai*this._rotateDelta.x/t.clientHeight),this._rotateUp(ai*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 ge,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 mA(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 gA(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function bA(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(ov),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 vA(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 yr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=Wt.DOLLY;break;case yr.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 yr.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(df)}function yA(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 xA(r){this.enabled===!1||this.enableZoom===!1||this.state!==Wt.NONE||(r.preventDefault(),this.dispatchEvent(df),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(ov))}function _A(r){this.enabled!==!1&&this._handleKeyDown(r)}function wA(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case Xs.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=Wt.TOUCH_ROTATE;break;case Xs.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 Xs.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=Wt.TOUCH_DOLLY_PAN;break;case Xs.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(df)}function SA(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 MA(r){this.enabled!==!1&&r.preventDefault()}function EA(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function TA(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const AA=`
|
|
4453
4226
|
varying vec3 worldPosition;
|
|
4454
4227
|
|
|
4455
4228
|
uniform float uDistance;
|
|
@@ -4461,7 +4234,7 @@ version 0.8.2
|
|
|
4461
4234
|
worldPosition = pos;
|
|
4462
4235
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
|
|
4463
4236
|
}
|
|
4464
|
-
`,
|
|
4237
|
+
`,CA=`
|
|
4465
4238
|
varying vec3 worldPosition;
|
|
4466
4239
|
|
|
4467
4240
|
uniform float uSize1;
|
|
@@ -4603,15 +4376,20 @@ version 0.8.2
|
|
|
4603
4376
|
finalAlpha
|
|
4604
4377
|
);
|
|
4605
4378
|
}
|
|
4606
|
-
`;class x1 extends Ae{constructor({size1:e=10,size2:t=100,color:n=16777215,fineColor:i,coarseColor:s,xAxisColor:a,yAxisColor:o,distance:l=2e3,showAxes:c=!0}={}){const d=new Le(i??n),h=new Le(s??n),u=new Le(a??h),f=new Le(o??h),m=new Qs(2,2,1,1),v=new wn({side:sn,transparent:!0,depthWrite:!1,toneMapped:!1,uniforms:{uSize1:{value:e},uSize2:{value:t},uFineColor:{value:d},uCoarseColor:{value:h},uXAxisColor:{value:u},uYAxisColor:{value:f},uDistance:{value:l},uShowAxes:{value:c?1:0}},vertexShader:v1,fragmentShader:y1});super(m,v),this.frustumCulled=!1,this.name="maniBgGrid"}setColors(e,t){this.material.uniforms.uFineColor.value.set(e),this.material.uniforms.uCoarseColor.value.set(t)}setAxisColors(e,t){this.material.uniforms.uXAxisColor.value.set(e),this.material.uniforms.uYAxisColor.value.set(t)}setSizes(e,t){this.material.uniforms.uSize1.value=e,this.material.uniforms.uSize2.value=t}}function _1(r){return{all:r=r||new Map,on:function(e,t){var n=r.get(e);n?n.push(t):r.set(e,[t])},off:function(e,t){var n=r.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):r.set(e,[]))},emit:function(e,t){var n=r.get(e);n&&n.slice().map(function(i){i(t)}),(n=r.get("*"))&&n.slice().map(function(i){i(e,t)})}}}const w1=Math.PI/180;function Vd(r){return r*w1}const bN={EDIT:"EDIT",PLAY:"PLAY"},S1="0.0.1",vN="editor-camera-position",Ca=new gn(50,1,.01,1e3);Ca.up.set(0,0,1);Ca.name="Camera";Ca.position.set(-7.5,0,10);Ca.lookAt(new L);const ps={GOAL:"GOAL",ROUTE:"ROUTE",ALIGN:"ALIGN"},Gm={NO_ENTRY:15680580,IGNORE_LIDAR_2D:15381256,IGNORE_LIDAR_3D:2278750},Es={RBQ:{id:"RBQ",label:"RBQ",dimensions:{lengthX:.75,widthY:.42,heightZ:.9},modelUrl:"/rbq/rbq10.urdf",version:"1.0.0"},RBQ10:{id:"RBQ10",label:"RBQ-10",dimensions:{lengthX:.85,widthY:.5,heightZ:1.05},modelUrl:"/RBQ10/RBQ10.urdf",version:"1.1.0"},S100:{id:"S100",label:"S100",dimensions:{lengthX:.68,widthY:.51,heightZ:.19975},modelUrl:"/s100/meshes/s100.glb",version:"1.0.0"},D400:{id:"D400",label:"D400",dimensions:{lengthX:1.1044,widthY:.7484,heightZ:.537},modelUrl:"",version:"1.0.0"},SEM:{id:"SEM",label:"SEM",dimensions:{lengthX:1.1044,widthY:.7484,heightZ:.537},modelUrl:"",version:"1.0.0"},SEC:{id:"SEC",label:"SEC",dimensions:{lengthX:1.1044,widthY:.7484,heightZ:.537},modelUrl:"",version:"1.0.0"},QD:{id:"QD",label:"QD",dimensions:{lengthX:.75,widthY:.75,heightZ:.39},modelUrl:"/rby2c/meshes/visual/mobile.glb",version:"1.0.0"},GAIA:{id:"GAIA",label:"GAIA",dimensions:{lengthX:.75,widthY:.75,heightZ:.39},modelUrl:"/gaia/meshes/GAIA.glb",version:"1.0.0"}},Rn={MAP_POINTS:0,MAPPING_POINTS:1,LIDAR_POINTS:2,ARROW_HELPER:10,ARROW_ORIGIN:11,ARROW_HELPER_SELECTED:20,ARROW_ORIGIN_SELECTED:21,ARROW_HELPER_FOCUSED:30,ARROW_ORIGIN_FOCUSED:31,PATH:40,ROBOT:999},M1=new L(0,1,0),Wd=1e-6,E1=.2,T1=.3,A1=.75,Hl=65535,yv=16766282,C1=yv,Vm=1,P1=.35,R1=1,N1=1,D1=1.8,L1=.25;class I1 extends Vt{shaft;head;reverseBar;hitArea;shaftGeometry;shaftMaterial;headGeometry;headMaterial;reverseBarGeometry;reverseBarMaterial;hitAreaGeometry;hitAreaMaterial;visualState="default";direction=new L(0,1,0);length=1;lineWidth=.02;constructor(){super(),this.shaftGeometry=new Zs,this.shaftMaterial=this.createMaterial(Hl,this.lineWidth),this.shaft=new go(this.shaftGeometry,this.shaftMaterial),this.headGeometry=new Zs,this.headMaterial=this.createMaterial(Hl,this.lineWidth),this.head=new go(this.headGeometry,this.headMaterial),this.reverseBarGeometry=new Zs,this.reverseBarMaterial=this.createMaterial(Hl,.07),this.reverseBar=new go(this.reverseBarGeometry,this.reverseBarMaterial),this.hitAreaGeometry=new Qs(1,1),this.hitAreaMaterial=new jt({transparent:!0,opacity:0,depthWrite:!1}),this.hitArea=new Ae(this.hitAreaGeometry,this.hitAreaMaterial),this.shaft.name="shaft",this.head.name="head",this.reverseBar.name="reverse-bar",this.hitArea.name="hit-area",this.renderOrder=Rn.ARROW_HELPER,this.shaft.renderOrder=Rn.ARROW_HELPER,this.head.renderOrder=Rn.ARROW_HELPER,this.reverseBar.renderOrder=Rn.ARROW_HELPER,this.userData.objectType="topology-link",this.userData.helperType="ArrowHelper2",this.shaft.userData.arrowOwner=this,this.head.userData.arrowOwner=this,this.reverseBar.userData.arrowOwner=this,this.hitArea.userData.arrowOwner=this,this.shaft.userData.objectType="topology-link-part",this.head.userData.objectType="topology-link-part",this.reverseBar.userData.objectType="topology-link-part",this.hitArea.userData.objectType="topology-link-hit-area",this.add(this.hitArea),this.add(this.shaft),this.add(this.head),this.add(this.reverseBar)}dispose(){this.shaftGeometry.dispose(),this.headGeometry.dispose(),this.reverseBarGeometry.dispose(),this.hitAreaGeometry.dispose(),this.shaftMaterial.dispose(),this.headMaterial.dispose(),this.reverseBarMaterial.dispose(),this.hitAreaMaterial.dispose()}applySpec(e){return this.setDirection(e.dir),this.setOrigin(e.origin),this.setLength(e.length),this.head.visible=e.showHead,this.reverseBar.visible=e.showHead&&e.showReverseBar,this}setColor(e){return this.shaftMaterial.color.set(e),this.headMaterial.color.set(e),this.reverseBarMaterial.color.set(e),this}setOpacity(e){this.shaftMaterial.opacity=e,this.headMaterial.opacity=e,this.reverseBarMaterial.opacity=e;const t=this.visualState!=="default";return this.shaftMaterial.depthWrite=!t,this.headMaterial.depthWrite=!t,this.reverseBarMaterial.depthWrite=!t,this}setVisualState(e){this.visualState=e,this.applyDisplayColor();const t=e==="focused"?Rn.ARROW_HELPER_FOCUSED:e==="selected"?Rn.ARROW_HELPER_SELECTED:Rn.ARROW_HELPER;return this.renderOrder=t,this.shaft.renderOrder=t,this.head.renderOrder=t,this.reverseBar.renderOrder=t,this.setMaterialLineWidths(),this}setDirection(e){return e.lengthSq()<=Wd?this:(this.direction.copy(e).normalize(),this.quaternion.setFromUnitVectors(M1,this.direction),this)}setLength(e){if(this.length=Math.max(0,e),this.length<=Wd)return this.visible=!1,this;this.visible=!0;const t=Math.min(this.length*.6,Math.min(this.length*E1,T1)),n=Math.max(0,this.length-t),i=Math.max(this.lineWidth,t*A1),s=Math.max(this.lineWidth*2,i*.7),a=n+.03;return this.shaftGeometry.setPositions([0,0,0,0,n,0]),this.headGeometry.setPositions([-i/2,n-t,0,0,n,0,i/2,n-t,0]),this.reverseBarGeometry.setPositions([-s/2,a,0,s/2,a,0]),this.shaft.computeLineDistances(),this.head.computeLineDistances(),this.reverseBar.computeLineDistances(),this.hitArea.position.set(0,this.length/2,0),this.hitArea.scale.set(L1,this.length,1),this}setLineWidth(e){return this.lineWidth=Math.max(e,Wd),this.setMaterialLineWidths(),this}setOrigin(e){return this.position.copy(e),this}update(e,t,n){return this.setOrigin(t).setDirection(e).setLength(n)}createMaterial(e,t){return new Ao({color:e,linewidth:t,worldUnits:!0,dashed:!1,transparent:!0,opacity:Vm})}setMaterialLineWidths(){const e=this.visualState==="focused"?this.lineWidth*D1:this.visualState==="selected"?this.lineWidth*N1:this.lineWidth;this.shaftMaterial.linewidth=e,this.headMaterial.linewidth=e,this.reverseBarMaterial.linewidth=e}applyDisplayColor(){if(this.visualState==="focused"){this.setColor(yv),this.setOpacity(R1);return}if(this.visualState==="selected"){this.setColor(C1),this.setOpacity(P1);return}this.setColor(Hl),this.setOpacity(Vm)}}const k1=.38,O1=.75,Wm=16734751;class F1{editor;enabled;radius;selectedPoints=new Set;deletedPoints=[];indicatorGroup=null;constructor(e){this.editor=e}deregisterEventListeners(){const e=this.editor.eventHandler.eventBus;e.off("viewport:initialized",this.handleViewportInitialized),e.off("ui:eraser-toggle-requested",this.handleEraserToggle),e.off("eraser:radius-changed",this.handleRadiusChanged),e.off("eraser:intersections-detected",this.handleIntersectionsDetected),e.off("ui:unselect-points-requested",this.handleUnselectPoints),e.off("ui:points-delete-requested",this.handleDeletePoints),e.off("ui:map-points-erase-history-clear-requested",this.handleClearEraseHistory),e.off("ui:map-points-update-requested",this.handleMapPointsUpdate),e.off("ui:map-points-restore-requested",this.handleRestorePoints)}dispose(){this.deregisterEventListeners(),this.disposeIndicator()}registerEventListeners(){const e=this.editor.eventHandler.eventBus;e.on("viewport:initialized",this.handleViewportInitialized),e.on("ui:eraser-toggle-requested",this.handleEraserToggle),e.on("eraser:radius-changed",this.handleRadiusChanged),e.on("eraser:intersections-detected",this.handleIntersectionsDetected),e.on("ui:unselect-points-requested",this.handleUnselectPoints),e.on("ui:points-delete-requested",this.handleDeletePoints),e.on("ui:map-points-erase-history-clear-requested",this.handleClearEraseHistory),e.on("ui:map-points-update-requested",this.handleMapPointsUpdate),e.on("ui:map-points-restore-requested",this.handleRestorePoints)}selectPoints(e,t=16753920){const n=this.selectedPoints.size;for(const i of e)typeof i.index=="number"&&!this.selectedPoints.has(i.index)&&this.selectedPoints.add(i.index);this.selectedPoints.size&&this.highlightPoints(t),this.selectedPoints.size!==n&&this.emitSelectionChanged()}unselectPoints(e=3800852){this.selectedPoints.size&&(this.highlightPoints(e),this.selectedPoints.clear(),this.emitSelectionChanged())}deletePoints(){if(this.selectedPoints.size===0)return;const t=this.editor.pointsManager.mapPoints.geometry.getAttribute("position"),n=this.editor.pointsManager.mapPointsData,i=[],s=[];for(let a=0,o=t.count;a<o;a++){const l=[...n[a]??[]];l[0]=t.getX(a),l[1]=t.getY(a),l[2]=t.getZ(a),this.selectedPoints.has(a)?s.push(l):i.push(l)}this.deletedPoints.push(...s),this.editor.pointsManager.updateMapPoints(i),this.selectedPoints.clear(),this.emitSelectionChanged()}restorePoints(){if(!this.deletedPoints.length)return;const e=this.editor.pointsManager.mapPointsData,t=this.deletedPoints,n=new Array(e.length+this.deletedPoints.length);for(let i=0;i<e.length;i++)n[i]=e[i];for(let i=0;i<t.length;i++)n[e.length+i]=t[i];this.editor.pointsManager.updateMapPoints(n),this.clearEraseHistory()}hideIndicator(){this.indicatorGroup?.visible&&(this.indicatorGroup.visible=!1)}updateIndicator(e){this.indicatorGroup&&(this.indicatorGroup.position.set(e.x,e.y,0),this.indicatorGroup.visible=!0)}createIndicator=()=>{if(this.indicatorGroup||!this.editor.sceneHelpers)return;const e=new Pc(1,64),t=new jt({color:Wm,transparent:!0,opacity:k1,depthWrite:!1,depthTest:!1,side:sn}),n=new Ju(.96,1,64),i=new jt({color:Wm,transparent:!0,opacity:O1,depthWrite:!1,depthTest:!1,side:sn}),s=this.editor.selector.pointsThreshold,a=new Vt;a.name="eraserIndicator",a.scale.set(s,s,1),a.visible=!1;const o=new Ae(e,t);o.name="eraserIndicatorFill";const l=new Ae(n,i);l.name="eraserIndicatorOutline",a.add(o,l),this.editor.sceneHelpers.add(a),this.indicatorGroup=a};disposeIndicator=()=>{this.indicatorGroup&&(this.editor.sceneHelpers?.remove(this.indicatorGroup),this.indicatorGroup.traverse(e=>{if(e instanceof Ae){if(e.geometry.dispose(),Array.isArray(e.material)){e.material.forEach(t=>t.dispose());return}e.material.dispose()}}),this.indicatorGroup=null)};clearEraseHistory=()=>{this.deletedPoints=[]};emitSelectionChanged=()=>{this.editor.eventHandler.eventBus.emit("eraser:selection-changed",{selectedCount:this.selectedPoints.size})};invalidateEraseHistory=()=>{this.deletedPoints.length&&(this.clearEraseHistory(),this.selectedPoints.clear(),this.emitSelectionChanged(),this.editor.eventHandler.eventBus.emit("eraser:history-invalidated"))};handleEraserToggle=e=>{this.enabled=e,e||(this.hideIndicator(),this.unselectPoints())};handleClearEraseHistory=()=>{this.clearEraseHistory()};handleIntersectionsDetected=e=>{this.selectPoints(e)};handleMapPointsUpdate=()=>{this.invalidateEraseHistory()};handleUnselectPoints=()=>{this.unselectPoints()};handleDeletePoints=()=>{this.deletePoints()};handleRadiusChanged=e=>{e<=0||(this.radius=e,this.indicatorGroup?.scale.set(e,e,1))};handleViewportInitialized=()=>{this.createIndicator()};highlightPoints=e=>{const n=this.editor.pointsManager.mapPoints.geometry.getAttribute("color"),[i,s,a]=this.toRGBArray(e);for(const o of this.selectedPoints)n.setXYZ(o,i,s,a);n.needsUpdate=!0};toRGBArray(e){const t=new Le(e);return[t.r,t.g,t.b]}handleRestorePoints=()=>{this.restorePoints()}}class U1{editor;eventBus;constructor(e){this.editor=e,this.eventBus=_1()}registerEventListeners(){}registerCanvasEventListeners(){this.getCanvas()}deregisterEventListeners(){}deregisterCanvasEventListeners(){this.getCanvas()}dispose(){this.deregisterEventListeners(),this.deregisterCanvasEventListeners()}handleCanvasMouseDown=()=>{const e=this.getCanvas();e&&e.focus()};getCanvas(){return this.editor.viewport?.renderer?.domElement??null}}class jm{link(e,t,n,i){for(let s=0;s<t.length-1;s++)xv(e,t[s],t[s+1],n,i)}}class B1{link(e,t,n,i){for(let s=0;s<t.length-1;s++)for(let a=s+1;a<t.length;a++)xv(e,t[s],t[a],n,i)}}class z1{constructor(e,t,n){this.nodeManager=e,this.eventBus=t,this.getSelectedObjects=n}strategy=new jm;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}Rf.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 jm:new B1),this.execute(e,n,i)};handleUnlinkNodes=()=>{const e=this.getSelectedObjects();if(e.length<2){Rf.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 xv(r,e,t,n,i){r.linkNodes(e,t,i),n&&r.linkNodes(t,e,i)}const Xm={name:"",type:"NO_ENTRY"},H1=.2,qm=.05,G1=.35,V1=1,W1=.85,j1=1,jd=.95,Xd=.75,X1=.16,Zm=1,Ym=1.2,Km=1.45,q1=.2,Z1=.35,qd=new Le(16777215),Y1=10,K1=30;class $1{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={...Xm};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={...Xm},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:H1}),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 Da(i),a=new jt({color:e,transparent:t,opacity:n,depthWrite:!t});return new Ae(s,a)}createLine({color:e,transparent:t,opacity:n}){const i=new mt,s=new Yn({color:e,transparent:t,opacity:n});return new Wn(i,s)}createLineLoop({color:e,transparent:t,opacity:n}){const i=new mt,s=new Yn({color:e,transparent:t,opacity:n});return new Nb(i,s)}disposeObject(e){if(e.removeFromParent(),e instanceof Ae){e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose();return}e instanceof Wn&&(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 mt().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 Le(e),n=t.clone().lerp(qd,q1),i=t.clone().lerp(qd,Z1);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?Km:this.draftHoveredVertexIndex===s?Ym:Zm;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:jd:Xd}}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"?jd:Xd,radius:X1});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?Km:this.draftHoveredVertexIndex===t?Ym:Zm),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 Gm[e]??Gm.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"?jd:Xd)}),[this.previewLine,this.closingLine,this.draftOutlineLine].forEach(t=>{t?.material instanceof Yn&&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)}createCommittedZoneHitMesh(e){const t=new Ub(e.polygon.map(a=>new ge(a.x,a.y))),n=new ef(t),i=new jt({color:this.getZoneColor(e.type),transparent:!0,opacity:qm,side:sn,depthWrite:!1}),s=new Ae(n,i);return s.name=`topology-zone-hit-${e.id}`,s.position.z=-.001,s.userData={...s.userData,zoneId:e.id,topologyObjectType:"zone",objectType:"topology-zone-hit-area"},s}getHighlightedZoneColor(e){return new Le(this.getZoneColor(e)).lerp(qd,.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 Le(s);e.lineLoop.material instanceof Yn&&(e.lineLoop.material.color.copy(a),e.lineLoop.material.transparent=!0,e.lineLoop.material.opacity=n?j1:t?V1:W1),e.hitMesh.material instanceof jt&&(e.hitMesh.material.color.setHex(s),e.hitMesh.material.opacity=n?G1:t?0:qm)}disposeCommittedZone(e){this.zoneSelectableBridge.unregisterSelectableZone(e.hitMesh),this.disposeObject(e.hitMesh),this.disposeObject(e.lineLoop),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;n.name=`topology-zone-${e.id}`,n.userData={...n.userData,zoneId:e.id,zoneType:e.type,topologyObjectType:"zone",keep:!0};const i=this.createLineLoop({color:this.getZoneColor(e.type),transparent:!1,opacity:1});i.renderOrder=K1,i.name=`topology-zone-outline-${e.id}`,i.userData={...i.userData,zoneId:e.id,topologyObjectType:"zone"},i.geometry.setFromPoints(e.polygon.map(o=>new L(o.x,o.y,0)));const s=this.createCommittedZoneHitMesh(e);s.renderOrder=Y1,s.userData={...s.userData,zoneOwner:n},n.add(s),n.add(i),this.getScene().add(n),this.zoneSelectableBridge.registerSelectableZone(s);const a={group:n,lineLoop:i,hitMesh:s};this.hiddenCommittedZoneIds.has(e.id)&&(n.visible=!1),this.applyCommittedZoneHighlight(a,this.selectedZoneIds.has(e.id),this.focusedZoneId===e.id),this.committedZoneObjects.set(e.id,a)}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 L(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 _v=.012,Q1=.012,J1=.35,wv=new Pc(_v,24);wv.translate(0,0,Q1);class eC{constructor(e){this.editor=e,this.linkModule=new z1(this,this.editor.eventHandler.eventBus,()=>this.editor.selectionManager.getSelectedObjects()),this.zoneModule=new $1(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={[ps.GOAL]:"GOAL",[ps.ROUTE]:"ROUTE",[ps.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 On({color:12186288,side:sn}),ROUTE:new On({color:1573017,side:sn}),ALIGN:new On({color:16727988,side:sn}),MARKER:new On({color:16727988,side:sn})};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==="QD"?t:"PP"}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-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("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-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("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 ba&&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)})),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:Vd(a(o.rx)),ry:Vd(a(o.ry)),rz:Vd(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=`
|
|
4379
|
+
`;class PA extends Ae{constructor({size1:e=10,size2:t=100,color:n=16777215,fineColor:i,coarseColor:s,xAxisColor:a,yAxisColor:o,distance:l=2e3,showAxes:c=!0}={}){const d=new Le(i??n),h=new Le(s??n),u=new Le(a??h),f=new Le(o??h),m=new Qs(2,2,1,1),v=new wn({side:sn,transparent:!0,depthWrite:!1,toneMapped:!1,uniforms:{uSize1:{value:e},uSize2:{value:t},uFineColor:{value:d},uCoarseColor:{value:h},uXAxisColor:{value:u},uYAxisColor:{value:f},uDistance:{value:l},uShowAxes:{value:c?1:0}},vertexShader:AA,fragmentShader:CA});super(m,v),this.frustumCulled=!1,this.name="maniBgGrid"}setColors(e,t){this.material.uniforms.uFineColor.value.set(e),this.material.uniforms.uCoarseColor.value.set(t)}setAxisColors(e,t){this.material.uniforms.uXAxisColor.value.set(e),this.material.uniforms.uYAxisColor.value.set(t)}setSizes(e,t){this.material.uniforms.uSize1.value=e,this.material.uniforms.uSize2.value=t}}function RA(r,e="Viewport"){const t=r.parentElement;if(!t)throw new Error(`[${e}] Canvas container element not found`);if(!(t instanceof HTMLDivElement))throw new Error(`[${e}] Canvas container must be a div element`);return t}function NA(r){r.setClearColor(0,0);const e=typeof window<"u"?window.devicePixelRatio:1;r.setPixelRatio(e),r.outputColorSpace=gt}const DA="absolute top-0 left-0 w-full h-full z-10 pointer-events-none";function LA(r,e){const t=new wT,n=r.clientWidth,i=r.clientHeight;return t.setSize(n,i),t.domElement.className=DA,r.appendChild(t.domElement),t}function IA(r){const e=r?.domElement;e?.parentNode&&e.parentNode.removeChild(e)}function kA(r,e){const t=new ResizeObserver(n=>{for(const i of n){const{width:s,height:a}=i.contentRect;e(Math.floor(s),Math.floor(a))}});return t.observe(r),t}function OA({camera:r,renderer:e,width:t,height:n,css2DRenderer:i,canvas:s,updateStyle:a=!0}){return t<=0||n<=0?!1:(s&&a&&(s.style.width=`${t}px`,s.style.height=`${n}px`),r.aspect=t/n,r.updateProjectionMatrix(),e.setSize(t,n,!1),i&&i.setSize(t,n),!0)}function FA(r){return{all:r=r||new Map,on:function(e,t){var n=r.get(e);n?n.push(t):r.set(e,[t])},off:function(e,t){var n=r.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):r.set(e,[]))},emit:function(e,t){var n=r.get(e);n&&n.slice().map(function(i){i(t)}),(n=r.get("*"))&&n.slice().map(function(i){i(e,t)})}}}const UA=Math.PI/180;function Bd(r){return r*UA}const MN={EDIT:"EDIT",PLAY:"PLAY"},BA="0.0.1",EN="editor-camera-position",Ca=new gn(50,1,.01,1e3);Ca.up.set(0,0,1);Ca.name="Camera";Ca.position.set(-7.5,0,10);Ca.lookAt(new L);const ps={GOAL:"GOAL",ROUTE:"ROUTE",ALIGN:"ALIGN"},Bm={NO_ENTRY:15680580,IGNORE_LIDAR_2D:15381256,IGNORE_LIDAR_3D:2278750},Es={RBQ:{id:"RBQ",label:"RBQ",dimensions:{lengthX:.75,widthY:.42,heightZ:.9},modelUrl:"/rbq/rbq10.urdf",version:"1.0.0"},RBQ10:{id:"RBQ10",label:"RBQ-10",dimensions:{lengthX:.85,widthY:.5,heightZ:1.05},modelUrl:"/RBQ10/RBQ10.urdf",version:"1.1.0"},S100:{id:"S100",label:"S100",dimensions:{lengthX:.68,widthY:.51,heightZ:.19975},modelUrl:"/s100/meshes/s100.glb",version:"1.0.0"},D400:{id:"D400",label:"D400",dimensions:{lengthX:1.1044,widthY:.7484,heightZ:.537},modelUrl:"",version:"1.0.0"},SEM:{id:"SEM",label:"SEM",dimensions:{lengthX:1.1044,widthY:.7484,heightZ:.537},modelUrl:"",version:"1.0.0"},SEC:{id:"SEC",label:"SEC",dimensions:{lengthX:1.1044,widthY:.7484,heightZ:.537},modelUrl:"",version:"1.0.0"},QD:{id:"QD",label:"QD",dimensions:{lengthX:.75,widthY:.75,heightZ:.39},modelUrl:"/rby2c/meshes/visual/mobile.glb",version:"1.0.0"},GAIA:{id:"GAIA",label:"GAIA",dimensions:{lengthX:.75,widthY:.75,heightZ:.39},modelUrl:"/gaia/meshes/GAIA.glb",version:"1.0.0"}},Rn={MAP_POINTS:0,MAPPING_POINTS:1,LIDAR_POINTS:2,ARROW_HELPER:10,ARROW_ORIGIN:11,ARROW_HELPER_SELECTED:20,ARROW_ORIGIN_SELECTED:21,ARROW_HELPER_FOCUSED:30,ARROW_ORIGIN_FOCUSED:31,PATH:40,ROBOT:999},zA=new L(0,1,0),zd=1e-6,HA=.2,GA=.3,VA=.75,zl=65535,lv=16766282,WA=lv,zm=1,jA=.35,XA=1,qA=1,ZA=1.8,YA=.25;class KA extends Vt{shaft;head;reverseBar;hitArea;shaftGeometry;shaftMaterial;headGeometry;headMaterial;reverseBarGeometry;reverseBarMaterial;hitAreaGeometry;hitAreaMaterial;visualState="default";direction=new L(0,1,0);length=1;lineWidth=.02;constructor(){super(),this.shaftGeometry=new Zs,this.shaftMaterial=this.createMaterial(zl,this.lineWidth),this.shaft=new go(this.shaftGeometry,this.shaftMaterial),this.headGeometry=new Zs,this.headMaterial=this.createMaterial(zl,this.lineWidth),this.head=new go(this.headGeometry,this.headMaterial),this.reverseBarGeometry=new Zs,this.reverseBarMaterial=this.createMaterial(zl,.07),this.reverseBar=new go(this.reverseBarGeometry,this.reverseBarMaterial),this.hitAreaGeometry=new Qs(1,1),this.hitAreaMaterial=new jt({transparent:!0,opacity:0,depthWrite:!1}),this.hitArea=new Ae(this.hitAreaGeometry,this.hitAreaMaterial),this.shaft.name="shaft",this.head.name="head",this.reverseBar.name="reverse-bar",this.hitArea.name="hit-area",this.renderOrder=Rn.ARROW_HELPER,this.shaft.renderOrder=Rn.ARROW_HELPER,this.head.renderOrder=Rn.ARROW_HELPER,this.reverseBar.renderOrder=Rn.ARROW_HELPER,this.userData.objectType="topology-link",this.userData.helperType="ArrowHelper2",this.shaft.userData.arrowOwner=this,this.head.userData.arrowOwner=this,this.reverseBar.userData.arrowOwner=this,this.hitArea.userData.arrowOwner=this,this.shaft.userData.objectType="topology-link-part",this.head.userData.objectType="topology-link-part",this.reverseBar.userData.objectType="topology-link-part",this.hitArea.userData.objectType="topology-link-hit-area",this.add(this.hitArea),this.add(this.shaft),this.add(this.head),this.add(this.reverseBar)}dispose(){this.shaftGeometry.dispose(),this.headGeometry.dispose(),this.reverseBarGeometry.dispose(),this.hitAreaGeometry.dispose(),this.shaftMaterial.dispose(),this.headMaterial.dispose(),this.reverseBarMaterial.dispose(),this.hitAreaMaterial.dispose()}applySpec(e){return this.setDirection(e.dir),this.setOrigin(e.origin),this.setLength(e.length),this.head.visible=e.showHead,this.reverseBar.visible=e.showHead&&e.showReverseBar,this}setColor(e){return this.shaftMaterial.color.set(e),this.headMaterial.color.set(e),this.reverseBarMaterial.color.set(e),this}setOpacity(e){this.shaftMaterial.opacity=e,this.headMaterial.opacity=e,this.reverseBarMaterial.opacity=e;const t=this.visualState!=="default";return this.shaftMaterial.depthWrite=!t,this.headMaterial.depthWrite=!t,this.reverseBarMaterial.depthWrite=!t,this}setVisualState(e){this.visualState=e,this.applyDisplayColor();const t=e==="focused"?Rn.ARROW_HELPER_FOCUSED:e==="selected"?Rn.ARROW_HELPER_SELECTED:Rn.ARROW_HELPER;return this.renderOrder=t,this.shaft.renderOrder=t,this.head.renderOrder=t,this.reverseBar.renderOrder=t,this.setMaterialLineWidths(),this}setDirection(e){return e.lengthSq()<=zd?this:(this.direction.copy(e).normalize(),this.quaternion.setFromUnitVectors(zA,this.direction),this)}setLength(e){if(this.length=Math.max(0,e),this.length<=zd)return this.visible=!1,this;this.visible=!0;const t=Math.min(this.length*.6,Math.min(this.length*HA,GA)),n=Math.max(0,this.length-t),i=Math.max(this.lineWidth,t*VA),s=Math.max(this.lineWidth*2,i*.7),a=n+.03;return this.shaftGeometry.setPositions([0,0,0,0,n,0]),this.headGeometry.setPositions([-i/2,n-t,0,0,n,0,i/2,n-t,0]),this.reverseBarGeometry.setPositions([-s/2,a,0,s/2,a,0]),this.shaft.computeLineDistances(),this.head.computeLineDistances(),this.reverseBar.computeLineDistances(),this.hitArea.position.set(0,this.length/2,0),this.hitArea.scale.set(YA,this.length,1),this}setLineWidth(e){return this.lineWidth=Math.max(e,zd),this.setMaterialLineWidths(),this}setOrigin(e){return this.position.copy(e),this}update(e,t,n){return this.setOrigin(t).setDirection(e).setLength(n)}createMaterial(e,t){return new Ao({color:e,linewidth:t,worldUnits:!0,dashed:!1,transparent:!0,opacity:zm})}setMaterialLineWidths(){const e=this.visualState==="focused"?this.lineWidth*ZA:this.visualState==="selected"?this.lineWidth*qA:this.lineWidth;this.shaftMaterial.linewidth=e,this.headMaterial.linewidth=e,this.reverseBarMaterial.linewidth=e}applyDisplayColor(){if(this.visualState==="focused"){this.setColor(lv),this.setOpacity(XA);return}if(this.visualState==="selected"){this.setColor(WA),this.setOpacity(jA);return}this.setColor(zl),this.setOpacity(zm)}}const $A=.38,QA=.75,Hm=16734751;class JA{editor;enabled;radius;selectedPoints=new Set;deletedPoints=[];indicatorGroup=null;constructor(e){this.editor=e}deregisterEventListeners(){const e=this.editor.eventHandler.eventBus;e.off("viewport:initialized",this.handleViewportInitialized),e.off("ui:eraser-toggle-requested",this.handleEraserToggle),e.off("eraser:radius-changed",this.handleRadiusChanged),e.off("eraser:intersections-detected",this.handleIntersectionsDetected),e.off("ui:unselect-points-requested",this.handleUnselectPoints),e.off("ui:points-delete-requested",this.handleDeletePoints),e.off("ui:map-points-erase-history-clear-requested",this.handleClearEraseHistory),e.off("ui:map-points-update-requested",this.handleMapPointsUpdate),e.off("ui:map-points-restore-requested",this.handleRestorePoints)}dispose(){this.deregisterEventListeners(),this.disposeIndicator()}registerEventListeners(){const e=this.editor.eventHandler.eventBus;e.on("viewport:initialized",this.handleViewportInitialized),e.on("ui:eraser-toggle-requested",this.handleEraserToggle),e.on("eraser:radius-changed",this.handleRadiusChanged),e.on("eraser:intersections-detected",this.handleIntersectionsDetected),e.on("ui:unselect-points-requested",this.handleUnselectPoints),e.on("ui:points-delete-requested",this.handleDeletePoints),e.on("ui:map-points-erase-history-clear-requested",this.handleClearEraseHistory),e.on("ui:map-points-update-requested",this.handleMapPointsUpdate),e.on("ui:map-points-restore-requested",this.handleRestorePoints)}selectPoints(e,t=16753920){const n=this.selectedPoints.size;for(const i of e)typeof i.index=="number"&&!this.selectedPoints.has(i.index)&&this.selectedPoints.add(i.index);this.selectedPoints.size&&this.highlightPoints(t),this.selectedPoints.size!==n&&this.emitSelectionChanged()}unselectPoints(e=3800852){this.selectedPoints.size&&(this.highlightPoints(e),this.selectedPoints.clear(),this.emitSelectionChanged())}deletePoints(){if(this.selectedPoints.size===0)return;const t=this.editor.pointsManager.mapPoints.geometry.getAttribute("position"),n=this.editor.pointsManager.mapPointsData,i=[],s=[];for(let a=0,o=t.count;a<o;a++){const l=[...n[a]??[]];l[0]=t.getX(a),l[1]=t.getY(a),l[2]=t.getZ(a),this.selectedPoints.has(a)?s.push(l):i.push(l)}this.deletedPoints.push(...s),this.editor.pointsManager.updateMapPoints(i),this.selectedPoints.clear(),this.emitSelectionChanged()}restorePoints(){if(!this.deletedPoints.length)return;const e=this.editor.pointsManager.mapPointsData,t=this.deletedPoints,n=new Array(e.length+this.deletedPoints.length);for(let i=0;i<e.length;i++)n[i]=e[i];for(let i=0;i<t.length;i++)n[e.length+i]=t[i];this.editor.pointsManager.updateMapPoints(n),this.clearEraseHistory()}hideIndicator(){this.indicatorGroup?.visible&&(this.indicatorGroup.visible=!1)}updateIndicator(e){this.indicatorGroup&&(this.indicatorGroup.position.set(e.x,e.y,0),this.indicatorGroup.visible=!0)}createIndicator=()=>{if(this.indicatorGroup||!this.editor.sceneHelpers)return;const e=new Pc(1,64),t=new jt({color:Hm,transparent:!0,opacity:$A,depthWrite:!1,depthTest:!1,side:sn}),n=new Ju(.96,1,64),i=new jt({color:Hm,transparent:!0,opacity:QA,depthWrite:!1,depthTest:!1,side:sn}),s=this.editor.selector.pointsThreshold,a=new Vt;a.name="eraserIndicator",a.scale.set(s,s,1),a.visible=!1;const o=new Ae(e,t);o.name="eraserIndicatorFill";const l=new Ae(n,i);l.name="eraserIndicatorOutline",a.add(o,l),this.editor.sceneHelpers.add(a),this.indicatorGroup=a};disposeIndicator=()=>{this.indicatorGroup&&(this.editor.sceneHelpers?.remove(this.indicatorGroup),this.indicatorGroup.traverse(e=>{if(e instanceof Ae){if(e.geometry.dispose(),Array.isArray(e.material)){e.material.forEach(t=>t.dispose());return}e.material.dispose()}}),this.indicatorGroup=null)};clearEraseHistory=()=>{this.deletedPoints=[]};emitSelectionChanged=()=>{this.editor.eventHandler.eventBus.emit("eraser:selection-changed",{selectedCount:this.selectedPoints.size})};invalidateEraseHistory=()=>{this.deletedPoints.length&&(this.clearEraseHistory(),this.selectedPoints.clear(),this.emitSelectionChanged(),this.editor.eventHandler.eventBus.emit("eraser:history-invalidated"))};handleEraserToggle=e=>{this.enabled=e,e||(this.hideIndicator(),this.unselectPoints())};handleClearEraseHistory=()=>{this.clearEraseHistory()};handleIntersectionsDetected=e=>{this.selectPoints(e)};handleMapPointsUpdate=()=>{this.invalidateEraseHistory()};handleUnselectPoints=()=>{this.unselectPoints()};handleDeletePoints=()=>{this.deletePoints()};handleRadiusChanged=e=>{e<=0||(this.radius=e,this.indicatorGroup?.scale.set(e,e,1))};handleViewportInitialized=()=>{this.createIndicator()};highlightPoints=e=>{const n=this.editor.pointsManager.mapPoints.geometry.getAttribute("color"),[i,s,a]=this.toRGBArray(e);for(const o of this.selectedPoints)n.setXYZ(o,i,s,a);n.needsUpdate=!0};toRGBArray(e){const t=new Le(e);return[t.r,t.g,t.b]}handleRestorePoints=()=>{this.restorePoints()}}class e1{editor;eventBus;constructor(e){this.editor=e,this.eventBus=FA()}registerEventListeners(){}registerCanvasEventListeners(){this.getCanvas()}deregisterEventListeners(){}deregisterCanvasEventListeners(){this.getCanvas()}dispose(){this.deregisterEventListeners(),this.deregisterCanvasEventListeners()}handleCanvasMouseDown=()=>{const e=this.getCanvas();e&&e.focus()};getCanvas(){return this.editor.viewport?.renderer?.domElement??null}}/*!
|
|
4380
|
+
fflate - fast JavaScript compression/decompression
|
|
4381
|
+
<https://101arrowz.github.io/fflate>
|
|
4382
|
+
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
4383
|
+
version 0.8.2
|
|
4384
|
+
*/var Ci=Uint8Array,da=Uint16Array,t1=Int32Array,cv=new Ci([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]),dv=new Ci([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]),n1=new Ci([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),hv=function(r,e){for(var t=new da(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new t1(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}},uv=hv(cv,2),fv=uv.b,i1=uv.r;fv[28]=258,i1[258]=28;var s1=hv(dv,0),r1=s1.b,xu=new da(32768);for(var $t=0;$t<32768;++$t){var Us=($t&43690)>>1|($t&21845)<<1;Us=(Us&52428)>>2|(Us&13107)<<2,Us=(Us&61680)>>4|(Us&3855)<<4,xu[$t]=((Us&65280)>>8|(Us&255)<<8)>>1}var bo=(function(r,e,t){for(var n=r.length,i=0,s=new da(e);i<n;++i)r[i]&&++s[r[i]-1];var a=new da(e);for(i=1;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;var o;if(t){o=new da(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[xu[h]>>l]=c}else for(o=new da(n),i=0;i<n;++i)r[i]&&(o[i]=xu[a[r[i]-1]++]>>15-r[i]);return o}),ko=new Ci(288);for(var $t=0;$t<144;++$t)ko[$t]=8;for(var $t=144;$t<256;++$t)ko[$t]=9;for(var $t=256;$t<280;++$t)ko[$t]=7;for(var $t=280;$t<288;++$t)ko[$t]=8;var pv=new Ci(32);for(var $t=0;$t<32;++$t)pv[$t]=5;var a1=bo(ko,9,1),o1=bo(pv,5,1),Hd=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},Fi=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},Gd=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},l1=function(r){return(r+7)/8|0},c1=function(r,e,t){return(t==null||t>r.length)&&(t=r.length),new Ci(r.subarray(e,t))},d1=["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"],Bi=function(r,e,t){var n=new Error(e||d1[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,Bi),!t)throw n;return n},h1=function(r,e,t,n){var i=r.length,s=0;if(!i||e.f&&!e.l)return t||new Ci(0);var a=!t,o=a||e.i!=2,l=e.i;a&&(t=new Ci(i*3));var c=function(fe){var be=t.length;if(fe>be){var Ce=new Ci(Math.max(be*2,fe));Ce.set(t),t=Ce}},d=e.f||0,h=e.p||0,u=e.b||0,f=e.l,m=e.d,v=e.m,g=e.n,b=i*8;do{if(!f){d=Fi(r,h,1);var y=Fi(r,h+1,3);if(h+=3,y)if(y==1)f=a1,m=o1,v=9,g=5;else if(y==2){var T=Fi(r,h,31)+257,P=Fi(r,h+10,15)+4,M=T+Fi(r,h+5,31)+1;h+=14;for(var x=new Ci(M),S=new Ci(19),C=0;C<P;++C)S[n1[C]]=Fi(r,h+C*3,7);h+=P*3;for(var k=Hd(S),I=(1<<k)-1,G=bo(S,k,1),C=0;C<M;){var q=G[Fi(r,h,I)];h+=q&15;var w=q>>4;if(w<16)x[C++]=w;else{var O=0,W=0;for(w==16?(W=3+Fi(r,h,3),h+=2,O=x[C-1]):w==17?(W=3+Fi(r,h,7),h+=3):w==18&&(W=11+Fi(r,h,127),h+=7);W--;)x[C++]=O}}var Z=x.subarray(0,T),K=x.subarray(T);v=Hd(Z),g=Hd(K),f=bo(Z,v,1),m=bo(K,g,1)}else Bi(1);else{var w=l1(h)+4,_=r[w-4]|r[w-3]<<8,R=w+_;if(R>i){l&&Bi(0);break}o&&c(u+_),t.set(r.subarray(w,R),u),e.b=u+=_,e.p=h=R*8,e.f=d;continue}if(h>b){l&&Bi(0);break}}o&&c(u+131072);for(var oe=(1<<v)-1,te=(1<<g)-1,ve=h;;ve=h){var O=f[Gd(r,h)&oe],ce=O>>4;if(h+=O&15,h>b){l&&Bi(0);break}if(O||Bi(2),ce<256)t[u++]=ce;else if(ce==256){ve=h,f=null;break}else{var Q=ce-254;if(ce>264){var C=ce-257,re=cv[C];Q=Fi(r,h,(1<<re)-1)+fv[C],h+=re}var J=m[Gd(r,h)&te],ne=J>>4;J||Bi(3),h+=J&15;var K=r1[ne];if(ne>3){var re=dv[ne];K+=Gd(r,h)&(1<<re)-1,h+=re}if(h>b){l&&Bi(0);break}o&&c(u+131072);var ue=u+Q;if(u<K){var Te=s-K,_e=Math.min(K,ue);for(Te+u<0&&Bi(3);u<_e;++u)t[u]=n[Te+u]}for(;u<ue;++u)t[u]=t[u-K]}}e.l=f,e.p=ve,e.b=u,e.f=d,f&&(d=1,e.m=v,e.d=m,e.n=g)}while(!d);return u!=t.length&&a?c1(t,0,u):t.subarray(0,u)},u1=new Ci(0),f1=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&Bi(6,"invalid zlib data"),(r[1]>>5&1)==1&&Bi(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function p1(r,e){return h1(r.subarray(f1(r),-4),{i:2},e,e)}var m1=typeof TextDecoder<"u"&&new TextDecoder,g1=0;try{m1.decode(u1,{stream:!0}),g1=1}catch{}function mv(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 b1(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 v1(r,e,t,n){const i=mv(r,n,e),s=b1(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 y1(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],v=l[h-f];o[h][f]=m+v;const g=o[f][h-1]/o[h][f];o[f][h]=u+m*g,u=v*g}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 v=0;v<=t;++v)m[v]=s.slice(0);m[0][0]=1;for(let v=1;v<=n;++v){let g=0;const b=h-v,y=t-v;h>=v&&(m[f][0]=m[u][0]/o[y+1][b],g=m[f][0]*o[b][y]);const w=b>=-1?1:-b,_=h-1<=y?v-1:t-h;for(let T=w;T<=_;++T)m[f][T]=(m[u][T]-m[u][T-1])/o[y+1][b+T],g+=m[f][T]*o[b+T][y];h<=y&&(m[f][v]=-m[u][v-1]/o[y+1][h],g+=m[f][v]*o[h][y]),a[v][h]=g;const R=u;u=f,f=R}}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 x1(r,e,t,n,i){const s=i<r?i:r,a=[],o=mv(r,n,e),l=y1(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 _1(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 w1(r){const e=r.length,t=[],n=[];for(let s=0;s<e;++s){const a=r[s];t[s]=new L(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(_1(s,o)*n[o]));i[s]=a.divideScalar(n[0])}return i}function S1(r,e,t,n,i){const s=x1(r,e,t,n,i);return w1(s)}class M1 extends Zi{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 L){const n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=v1(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 L){const n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=S1(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,fn,ei;class E1 extends di{constructor(e){super(e)}load(e,t,n,i){const s=this,a=s.path===""?Ks.extractUrlBase(e):s.path,o=new $s(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(N1(e))Tt=new R1().parse(e);else{const i=vv(e);if(!D1(i))throw new Error("THREE.FBXLoader: Unknown format.");if(Vm(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Vm(i));Tt=new P1().parse(i)}const n=new No(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new T1(n,this.manager).parse(Tt)}}class T1{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){fn=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),s=new A1().parse(i);return this.parseScene(i,s,n),ei}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?Pi:li,n.wrapT=o===0?Pi:li,"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 Bt;const a=s.path;a||s.setPath(this.textureLoader.path);const o=fn.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),!fn.has(n))return null;const a=this.parseParameters(e,t,n);let o;switch(s.toLowerCase()){case"phong":o=new Ri;break;case"lambert":o=new On;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),o=new Ri;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=dt.toWorkingColorSpace(new Le().fromArray(e.Diffuse.value),gt):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=dt.toWorkingColorSpace(new Le().fromArray(e.DiffuseColor.value),gt)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=dt.toWorkingColorSpace(new Le().fromArray(e.Emissive.value),gt):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=dt.toWorkingColorSpace(new Le().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=dt.toWorkingColorSpace(new Le().fromArray(e.Specular.value),gt):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=dt.toWorkingColorSpace(new Le().fromArray(e.SpecularColor.value),gt));const s=this;return fn.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=uc,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=fn.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=fn.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 ke().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=fn.get(parseInt(s.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,n.push(o)}return n}parseScene(e,t,n){ei=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),fn.get(l.ID).parents.forEach(function(h){const u=i.get(h.ID);u!==void 0&&u.add(l)}),l.parent===null&&ei.add(l)}),this.bindSkeleton(e.skeletons,t,i),this.addGlobalSceneSettings(),ei.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=bv(l.userData.transformData);l.applyMatrix4(c),l.updateWorldMatrix()}});const o=new C1().parse();ei.children.length===1&&ei.children[0].isGroup&&(ei.children[0].animations=o,ei=ei.children[0]),ei.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=fn.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 So;break;case"Null":default:d=new Vt;break}d.name=l.attrName?Nt.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 So,s.matrixWorld.copy(c.transformLink),s.name=i?Nt.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=dt.toWorkingColorSpace(new Le().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 yc(s,a,o,l);break;case 1:t=new Ic(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 nf(s,a,o,c,d,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new yc(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 Ri({name:di.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 Ri;o.push(c)}}return s.FBX_Deformer?(i=new qu(s,a),i.normalizeSkinWeights()):i=new Ae(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 Yn({name:di.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new Wn(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Co(t.RotationOrder.value):n.eulerOrder=Co(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&&fn.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),ei.add(e.target)):e.lookAt(new L().fromArray(a))}}})}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const s in e){const a=e[s];fn.get(parseInt(a.ID)).parents.forEach(function(l){if(t.has(l.ID)){const c=l.ID;fn.get(c).parents.forEach(function(h){n.has(h.ID)&&n.get(h.ID).bind(new Po(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 ke().fromArray(s.Matrix.a)}):e[i.Node]=new ke().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 Le().setRGB(t,n,i,gt);ei.add(new Xb(s,1))}}"UnitScaleFactor"in Tt.GlobalSettings&&(ei.userData.unitScaleFactor=Tt.GlobalSettings.UnitScaleFactor.value)}}}class A1{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=fn.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=Co(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=bv(c);return this.genGeometry(t,o,s,d)}genGeometry(e,t,n,i){const s=new mt;e.attrName&&(s.name=e.attrName);const a=this.parseGeoNode(e,t),o=this.genBuffers(a),l=new Fe(o.vertex,3);if(l.applyMatrix4(i),s.setAttribute("position",l),o.colors.length>0&&s.setAttribute("color",new Fe(o.colors,3)),t&&(s.setAttribute("skinIndex",new Wu(o.weightsIndices,4)),s.setAttribute("skinWeight",new Fe(o.vertexWeights,4)),s.FBX_Deformer=t),o.normal.length>0){const c=new xt().getNormalMatrix(i),d=new Fe(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 Fe(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 v,g=!1;f<0&&(f=f^-1,g=!0);let b=[],y=[];if(a.push(f*3,f*3+1,f*3+2),e.color){const w=Hl(m,n,f,e.color);l.push(w[0],w[1],w[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(w){y.push(w.weight),b.push(w.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 w=[0,0,0,0],_=[0,0,0,0];y.forEach(function(R,T){let P=R,M=b[T];_.forEach(function(x,S,C){if(P>x){C[S]=P,P=x;const k=w[S];w[S]=M,M=k}})}),b=w,y=_}for(;y.length<4;)y.push(0),b.push(0);for(let w=0;w<4;++w)d.push(y[w]),h.push(b[w])}if(e.normal){const w=Hl(m,n,f,e.normal);o.push(w[0],w[1],w[2])}e.material&&e.material.mappingType!=="AllSame"&&(v=Hl(m,n,f,e.material)[0],v<0&&(u.negativeMaterialIndices=!0,v=0)),e.uv&&e.uv.forEach(function(w,_){const R=Hl(m,n,f,w);c[_]===void 0&&(c[_]=[]),c[_].push(R[0]),c[_].push(R[1])}),i++,g&&(u.genFace(t,e,a,v,o,l,c,d,h,i),n++,i=0,a=[],o=[],l=[],c=[],d=[],h=[])}),t}getNormalNewell(e){const t=new L(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 L(0,1,0):new L(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 ge(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 b=0;b<n.length;b+=3)u.push(new L(f[n[b]],f[n[b+1]],f[n[b+2]]));const{tangent:m,bitangent:v}=this.getNormalTangentAndBitangent(u),g=[];for(const b of u)g.push(this.flattenVertex(b,m,v));h=ga.triangulateShape(g,[])}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(v,g){e.uvs[g]===void 0&&(e.uvs[g]=[]),e.uvs[g].push(o[g][u*2]),e.uvs[g].push(o[g][u*2+1]),e.uvs[g].push(o[g][f*2]),e.uvs[g].push(o[g][f*2+1]),e.uvs[g].push(o[g][m*2]),e.uvs[g].push(o[g][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 v=0;v<c.length;v++){const g=c[v]*3;h[g]=l[v*3],h[g+1]=l[v*3+1],h[g+2]=l[v*3+2]}const u={vertexIndices:o,vertexPositions:h,baseVertexPositions:a},f=this.genBuffers(u),m=new Fe(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 Le;a<i.length;a+=4)o.fromArray(i,a),dt.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 mt;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 M1(n,i,s,o,l).getPoints(s.length*12);return new mt().setFromPoints(d)}}class C1{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(L1),values:t[n].KeyValueFloat.a},s=fn.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=fn.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=fn.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?Nt.sanitizeNodeName(u.attrName):"",ID:u.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ei.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 ke),"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=fn.get(l.ID).parents.filter(function(b){return b.relationship!==void 0})[0].ID,u=fn.get(h).parents[0].ID,f=fn.get(u).parents[0].ID,m=fn.get(f).parents[0].ID,v=Tt.Objects.Model[m],g={modelName:v.attrName?Nt.sanitizeNodeName(v.attrName):"",morphName:Tt.Objects.Deformer[h].attrName};s[c]=g}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=fn.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 vc(e.name,-1,t)}generateTracks(e){const t=[];let n=new L,i=new L;if(e.transform&&e.transform.decompose(n,new Dt,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 Ms(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=Co(0);n!==void 0&&(n=n.map(bt.degToRad),n.push(l),n=new dn().fromArray(n),n=new Dt().setFromEuler(n)),i!==void 0&&(i=i.map(bt.degToRad),i.push(l),i=new dn().fromArray(i),i=new Dt().setFromEuler(i).invert());const c=new Dt,d=new dn,h=[];if(!o||!a)return new Ss(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 Dt().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 Ss(e+".quaternion",a,h)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(s){return s/100}),i=ei.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Er(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 v=Math.max(...f)/180,g=new dn(...c,i),b=new dn(...h,i),y=new Dt().setFromEuler(g),w=new Dt().setFromEuler(b);y.dot(w)&&w.set(-w.x,-w.y,-w.z,-w.w);const _=e.times[o-1],R=e.times[o]-_,T=new Dt,P=new dn;for(let M=0;M<1;M+=1/v)T.copy(y.clone().slerp(w.clone(),M)),s.push(_+M*R),P.setFromQuaternion(T,i),a.push(P.x),a.push(P.y),a.push(P.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 P1{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 gv,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],k1(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=Wd(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Wd(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=Wd(c);break}this.getPrevNode()[s]={type:a,type2:o,flag:l,value:c},this.setCurrentProp(this.getPrevNode(),s)}}class R1{parse(e){const t=new Gm(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 gv;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=p1(new Uint8Array(e.getArrayBuffer(a))),l=new Gm(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 Gm{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 gv{add(e,t){this[e]=t}}function N1(r){const e="Kaydara FBX Binary \0";return r.byteLength>=e.length&&e===vv(r,0,e.length)}function D1(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 Vm(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 L1(r){return r/46186158e3}const I1=[];function Hl(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 O1(I1,n.buffer,s,a)}const Vd=new dn,na=new L;function bv(r){const e=new ke,t=new ke,n=new ke,i=new ke,s=new ke,a=new ke,o=new ke,l=new ke,c=new ke,d=new ke,h=new ke,u=new ke,f=r.inheritType?r.inheritType:0;r.translation&&e.setPosition(na.fromArray(r.translation));const m=Co(0);if(r.preRotation){const C=r.preRotation.map(bt.degToRad);C.push(m),t.makeRotationFromEuler(Vd.fromArray(C))}if(r.rotation){const C=r.rotation.map(bt.degToRad);C.push(r.eulerOrder||m),n.makeRotationFromEuler(Vd.fromArray(C))}if(r.postRotation){const C=r.postRotation.map(bt.degToRad);C.push(m),i.makeRotationFromEuler(Vd.fromArray(C)),i.invert()}r.scale&&s.scale(na.fromArray(r.scale)),r.scalingOffset&&o.setPosition(na.fromArray(r.scalingOffset)),r.scalingPivot&&a.setPosition(na.fromArray(r.scalingPivot)),r.rotationOffset&&l.setPosition(na.fromArray(r.rotationOffset)),r.rotationPivot&&c.setPosition(na.fromArray(r.rotationPivot)),r.parentMatrixWorld&&(h.copy(r.parentMatrix),d.copy(r.parentMatrixWorld));const v=t.clone().multiply(n).multiply(i),g=new ke;g.extractRotation(d);const b=new ke;b.copyPosition(d);const y=b.clone().invert().multiply(d),w=g.clone().invert().multiply(y),_=s,R=new ke;if(f===0)R.copy(g).multiply(v).multiply(w).multiply(_);else if(f===1)R.copy(g).multiply(w).multiply(v).multiply(_);else{const k=new ke().scale(new L().setFromMatrixScale(h)).clone().invert(),I=w.clone().multiply(k);R.copy(g).multiply(v).multiply(I).multiply(_)}const T=c.clone().invert(),P=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(P);const x=new ke().copyPosition(M),S=d.clone().multiply(x);return u.copyPosition(S),M=u.clone().multiply(R),M.premultiply(d.invert()),M}function Co(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 Wd(r){return r.split(",").map(function(t){return parseFloat(t)})}function vv(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=r.byteLength),new TextDecoder().decode(new Uint8Array(r,e,t))}function k1(r,e){for(let t=0,n=r.length,i=e.length;t<i;t++,n++)r[n]=e[t]}function O1(r,e,t,n){for(let i=t,s=0;i<n;i++,s++)r[s]=e[i];return r}class Wm{link(e,t,n,i){for(let s=0;s<t.length-1;s++)yv(e,t[s],t[s+1],n,i)}}class F1{link(e,t,n,i){for(let s=0;s<t.length-1;s++)for(let a=s+1;a<t.length;a++)yv(e,t[s],t[a],n,i)}}class U1{constructor(e,t,n){this.nodeManager=e,this.eventBus=t,this.getSelectedObjects=n}strategy=new Wm;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}Rf.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 Wm:new F1),this.execute(e,n,i)};handleUnlinkNodes=()=>{const e=this.getSelectedObjects();if(e.length<2){Rf.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 yv(r,e,t,n,i){r.linkNodes(e,t,i),n&&r.linkNodes(t,e,i)}const jm={name:"",type:"NO_ENTRY"},B1=.2,Xm=.05,z1=.35,H1=1,G1=.85,V1=1,jd=.95,Xd=.75,W1=.16,qm=1,Zm=1.2,Ym=1.45,j1=.2,X1=.35,qd=new Le(16777215),q1=10,Z1=30;class Y1{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={...jm};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={...jm},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:B1}),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 Da(i),a=new jt({color:e,transparent:t,opacity:n,depthWrite:!t});return new Ae(s,a)}createLine({color:e,transparent:t,opacity:n}){const i=new mt,s=new Yn({color:e,transparent:t,opacity:n});return new Wn(i,s)}createLineLoop({color:e,transparent:t,opacity:n}){const i=new mt,s=new Yn({color:e,transparent:t,opacity:n});return new Nb(i,s)}disposeObject(e){if(e.removeFromParent(),e instanceof Ae){e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose();return}e instanceof Wn&&(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 mt().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 Le(e),n=t.clone().lerp(qd,j1),i=t.clone().lerp(qd,X1);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?Ym:this.draftHoveredVertexIndex===s?Zm:qm;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:jd:Xd}}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"?jd:Xd,radius:W1});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?Ym:this.draftHoveredVertexIndex===t?Zm:qm),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 Bm[e]??Bm.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"?jd:Xd)}),[this.previewLine,this.closingLine,this.draftOutlineLine].forEach(t=>{t?.material instanceof Yn&&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)}createCommittedZoneHitMesh(e){const t=new Ub(e.polygon.map(a=>new ge(a.x,a.y))),n=new ef(t),i=new jt({color:this.getZoneColor(e.type),transparent:!0,opacity:Xm,side:sn,depthWrite:!1}),s=new Ae(n,i);return s.name=`topology-zone-hit-${e.id}`,s.position.z=-.001,s.userData={...s.userData,zoneId:e.id,topologyObjectType:"zone",objectType:"topology-zone-hit-area"},s}getHighlightedZoneColor(e){return new Le(this.getZoneColor(e)).lerp(qd,.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 Le(s);e.lineLoop.material instanceof Yn&&(e.lineLoop.material.color.copy(a),e.lineLoop.material.transparent=!0,e.lineLoop.material.opacity=n?V1:t?H1:G1),e.hitMesh.material instanceof jt&&(e.hitMesh.material.color.setHex(s),e.hitMesh.material.opacity=n?z1:t?0:Xm)}disposeCommittedZone(e){this.zoneSelectableBridge.unregisterSelectableZone(e.hitMesh),this.disposeObject(e.hitMesh),this.disposeObject(e.lineLoop),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;n.name=`topology-zone-${e.id}`,n.userData={...n.userData,zoneId:e.id,zoneType:e.type,topologyObjectType:"zone",keep:!0};const i=this.createLineLoop({color:this.getZoneColor(e.type),transparent:!1,opacity:1});i.renderOrder=Z1,i.name=`topology-zone-outline-${e.id}`,i.userData={...i.userData,zoneId:e.id,topologyObjectType:"zone"},i.geometry.setFromPoints(e.polygon.map(o=>new L(o.x,o.y,0)));const s=this.createCommittedZoneHitMesh(e);s.renderOrder=q1,s.userData={...s.userData,zoneOwner:n},n.add(s),n.add(i),this.getScene().add(n),this.zoneSelectableBridge.registerSelectableZone(s);const a={group:n,lineLoop:i,hitMesh:s};this.hiddenCommittedZoneIds.has(e.id)&&(n.visible=!1),this.applyCommittedZoneHighlight(a,this.selectedZoneIds.has(e.id),this.focusedZoneId===e.id),this.committedZoneObjects.set(e.id,a)}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 L(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 xv=.012,K1=.012,$1=.35,_v=new Pc(xv,24);_v.translate(0,0,K1);class Q1{constructor(e){this.editor=e,this.linkModule=new U1(this,this.editor.eventHandler.eventBus,()=>this.editor.selectionManager.getSelectedObjects()),this.zoneModule=new Y1(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={[ps.GOAL]:"GOAL",[ps.ROUTE]:"ROUTE",[ps.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 On({color:12186288,side:sn}),ROUTE:new On({color:1573017,side:sn}),ALIGN:new On({color:16727988,side:sn}),MARKER:new On({color:16727988,side:sn})};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==="QD"?t:"PP"}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-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("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-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("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 ba&&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)})),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:Bd(a(o.rx)),ry:Bd(a(o.ry)),rz:Bd(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=`
|
|
4607
4385
|
background: #1e2337;
|
|
4608
4386
|
color: #c0caf5;
|
|
4609
|
-
`;const n=new ba(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===ps.ROUTE)i=this.routeMesh;else if(e===ps.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===ps.GOAL?"G":e===ps.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 _v;const t=this.getNodeRadiusKey(e);return this.nodeRadiusMap[t]*J1}getNodeRadiusKey(e){const t=Array.isArray(e.userData.features)?e.userData.features:[];if(e.userData.type===ps.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 ln().setFromObject(e).getBoundingSphere(new ni).radius}async cacheNodeAssets(e){const t=new e1,n=Bn("/nodes/goal2.fbx");try{const c=(await t.loadAsync(n)).children[0],d=c.material,h=new On;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=Bn("/nodes/route.fbx");try{const c=(await t.loadAsync(i)).children[0],d=c.material,h=new On;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=Bn("/nodes/marker.fbx");try{const c=(await t.loadAsync(o)).children[0],d=c.material,h=new On;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 ba)).map(n=>({object:n,visible:n.visible}))})}getSimpleMaterial(e){const t=Array.isArray(e.userData.features)?e.userData.features:[];return e.userData.type===ps.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=wv,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)}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}){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 I1;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 L().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"))};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())}}const tC=.07,nC=.03,iC=2,sC=24;class rC{editor;globalPath;globalPathMap;localPath;constructor(e){this.editor=e,this.globalPathMap=new Map;const t=new Zs,n=new Ao({color:16711680,linewidth:tC,vertexColors:!1,worldUnits:!0,dashed:!1});this.globalPath=new go(t,n),this.globalPath.position.set(0,0,.15),this.globalPath.renderOrder=Rn.PATH,this.globalPath.visible=!1;const i=new Zs,s=new Ao({color:16766282,linewidth:nC,vertexColors:!1,worldUnits:!0,dashed:!0,dashSize:iC,dashScale:sC});this.localPath=new go(i,s),this.localPath.position.set(0,0,.2),this.localPath.renderOrder=Rn.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 Zs;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 Zs;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){return e.flatMap(t=>t.map(n=>{const i=Number(n);return isNaN(i)&&console.warn(`Invalid number conversion for value: ${n}`),i}))}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 uf{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 L().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 L(i===0?e.x:n.x,s===0?e.y:n.y,a===0?e.z:n.z),l=new L(i===0?n.x:t.x,s===0?n.y:t.y,a===0?n.z:t.z),c=new ln(o,l);this.children.push(new uf(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 ff{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 ge(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 ge((e.x+t.x)/2,(e.y+t.y)/2),i=[new br(new ge(e.x,e.y),new ge(n.x,n.y)),new br(new ge(n.x,e.y),new ge(t.x,n.y)),new br(new ge(e.x,n.y),new ge(n.x,t.y)),new br(new ge(n.x,n.y),new ge(t.x,t.y))];if(this.children=i.map(s=>new ff(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 Qi=[{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}],aC=1024*3;class oC{editor;pointsOctree=null;pointsQuadTree=null;mappingPoints=null;mappingPointsGeo=null;mappingPointsMat=null;mappingKeyFrame=null;mappingKeyFrameGeo=null;mappingKeyFrameMat=null;mapPoints;mapPointsGeo;mapPointsMat;mapPointsData;lidarPoints;lidarPointsGeo;lidarPointsMat;lidarFloat32Array=new Float32Array;lidarPositionAttr;lastLidarSphereUpdateTime=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("ui:map-points-update-requested",this.handleMapPointsLoaded),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:lidar-point-size-set-requested",this.handleLidarPointSizeSetRequested)}deregisterEventListeners(){const e=this.editor.eventHandler.eventBus;e.off("lidar:updated",this.handleLidarUpdated),e.off("ui:map-points-update-requested",this.handleMapPointsLoaded),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:lidar-point-size-set-requested",this.handleLidarPointSizeSetRequested)}changeMapPointsOpacity(e){this.mapPointsMat.opacity=e*.01}clearMapPoints(){this.mapPointsGeo.deleteAttribute("position"),this.mapPointsGeo.setAttribute("position",new Fe([],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.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||!this.mapPointsMat)&&(this.mapPointsGeo.dispose(),this.mapPointsMat.dispose(),this.mapPointsData=null,this.lidarPointsGeo.dispose(),this.lidarPointsMat.dispose(),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.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.editor.eventHandler.eventBus.emit("points-manager:mappoints-updated",{mapBounds:s})}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()}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],v=e[u*3+2];f<n&&(n=f),f>a&&(a=f),m<i&&(i=m),m>o&&(o=m),v<s&&(s=v),v>l&&(l=v)}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}}createCloudOctree(){const e=this.mapPointsGeo.getAttribute("position"),t=new ln().setFromBufferAttribute(e);t.expandByScalar(1);const n=new uf(t,20);for(let i=0;i<e.count;i++){const s=new L().fromBufferAttribute(e,i);n.insert(s,i)}this.pointsOctree=n}createCloudQuadTree(){const e=this.mapPointsGeo.getAttribute("position"),t=new ln().setFromBufferAttribute(e),n=new br(new ge(t.min.x,t.min.y),new ge(t.max.x,t.max.y));n.expandByScalar(1);const i=new ff(n,20);try{for(let s=0;s<e.count;s++){const a=new L().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 Fe(i,3);s.setUsage(Bf),this.lidarPositionAttr=s,this.lidarPointsGeo.setAttribute("position",s)}}finalizeUpdate(){this.mapPointsGeo.attributes.position.needsUpdate=!0,this.mapPointsGeo.computeBoundingSphere()}clearPointsGeometry(e){e.deleteAttribute("position"),e.setAttribute("position",new Fe([],3)),e.boundingSphere=null,e.attributes.position.needsUpdate=!0}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()&&this.lidarPointsGeo.computeBoundingSphere()};handleLidarToggled=e=>{this.lidarPoints.visible=e};handleLidarPointSizeSetRequested=e=>{this.lidarPointsMat.size=e,this.lidarPointsMat.needsUpdate=!0};shouldUpdateSphere(){const e=performance.now();return e-this.lastLidarSphereUpdateTime>this.sphereUpdateInterval||this.lastLidarSphereUpdateTime===0?(this.lastLidarSphereUpdateTime=e,!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 Fe(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=Qi[0],d=Qi[1],h=e[0],u=e[1]):l<e[2]?(c=Qi[1],d=Qi[2],h=e[1],u=e[2]):l<e[3]?(c=Qi[2],d=Qi[3],h=e[2],u=e[3]):l<e[4]?(c=Qi[3],d=Qi[4],h=e[3],u=e[4]):(c=Qi[4],d=Qi[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 v=c.r*(1-m)+d.r*m,g=c.g*(1-m)+d.g*m,b=c.b*(1-m)+d.b*m;a.setXYZ(o,v,g,b)}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 Fe(s,3);return e.setAttribute("position",a),{position:s,numPoints:s.length/3}}handleMapPointsLoaded=e=>{this.updateMapPoints(e)};handleMappingStarted=()=>{this.handleMappingStopped(),this.resetMappingKeyFrameChunks(),this.mapPoints.visible=!1,this.mappingPointsGeo=new mt,this.mappingPointsGeo.setAttribute("position",new Fe([],3)),this.mappingPointsMat=new aa({size:.2,color:8245247}),this.mappingPoints=new lo(this.mappingPointsGeo,this.mappingPointsMat),this.mappingPoints.renderOrder=Rn.MAPPING_POINTS,this.mappingPoints.userData.keep=!0,this.editor.scene.add(this.mappingPoints),this.mappingKeyFrameGeo=new mt,this.mappingKeyFrameGeo.setAttribute("position",new Fe([],3)),this.mappingKeyFrameMat=new aa({size:.2,color:2450411}),this.mappingKeyFrame=new lo(this.mappingKeyFrameGeo,this.mappingKeyFrameMat),this.mappingKeyFrame.renderOrder=Rn.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)};handleEditorInitialized=()=>{this.mapPointsGeo=new mt,this.mapPointsGeo.setAttribute("position",new Fe([],3)),this.mapPointsMat=new aa({size:.15,vertexColors:!0,transparent:!0,opacity:1,depthWrite:!1}),this.mapPoints=new lo(this.mapPointsGeo,this.mapPointsMat),this.mapPoints.renderOrder=Rn.MAP_POINTS,this.mapPoints.userData.keep=!0,this.editor.scene.add(this.mapPoints),this.mapPointsData=[],this.lidarPointsGeo=new mt,this.lidarPointsMat=new aa({size:.15,color:16725342,transparent:!0,depthWrite:!1}),this.lidarPoints=new lo(this.lidarPointsGeo,this.lidarPointsMat),this.lidarPoints.renderOrder=Rn.LIDAR_POINTS,this.lidarPoints.userData.keep=!0,this.lidarPositionAttr=new Fe(new Float32Array(aC),3),this.lidarPositionAttr.setUsage(Bf)};resetMappingKeyFrameChunks=()=>{this.pendingMappingKeyFrameChunkNum=null,this.pendingMappingKeyFrameChunks.clear()}}class pf{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 Js extends Vt{transformBuf=new pf;tmpTransform=new L;clock=new sf;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 ln().setFromObject(e),s=-i.min.z;if(e.position.z+=s,n){const a=new L;i.getCenter(a),e.position.x-=a.x,e.position.y-=a.y}e.updateMatrixWorld(!0)}}class mf extends Js{static async create(){const e=new mf;return await e._initAsync(),e}constructor(){super(),this.name="RB-S100",this.userData.keep=!0}async _initAsync(){const e=new Rr,t=Bn(Es.S100.modelUrl);try{const i=(await e.loadAsync(t)).scene;i.traverse(s=>{s.userData.keep=!0}),i.renderOrder=Rn.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 lc={exports:{}};/* @license
|
|
4387
|
+
`;const n=new ba(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===ps.ROUTE)i=this.routeMesh;else if(e===ps.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===ps.GOAL?"G":e===ps.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 xv;const t=this.getNodeRadiusKey(e);return this.nodeRadiusMap[t]*$1}getNodeRadiusKey(e){const t=Array.isArray(e.userData.features)?e.userData.features:[];if(e.userData.type===ps.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 ln().setFromObject(e).getBoundingSphere(new ni).radius}async cacheNodeAssets(e){const t=new E1,n=Bn("/nodes/goal2.fbx");try{const c=(await t.loadAsync(n)).children[0],d=c.material,h=new On;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=Bn("/nodes/route.fbx");try{const c=(await t.loadAsync(i)).children[0],d=c.material,h=new On;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=Bn("/nodes/marker.fbx");try{const c=(await t.loadAsync(o)).children[0],d=c.material,h=new On;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 ba)).map(n=>({object:n,visible:n.visible}))})}getSimpleMaterial(e){const t=Array.isArray(e.userData.features)?e.userData.features:[];return e.userData.type===ps.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=_v,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)}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}){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 KA;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 L().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"))};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())}}const J1=.07,eC=.03,tC=2,nC=24;class iC{editor;globalPath;globalPathMap;localPath;constructor(e){this.editor=e,this.globalPathMap=new Map;const t=new Zs,n=new Ao({color:16711680,linewidth:J1,vertexColors:!1,worldUnits:!0,dashed:!1});this.globalPath=new go(t,n),this.globalPath.position.set(0,0,.15),this.globalPath.renderOrder=Rn.PATH,this.globalPath.visible=!1;const i=new Zs,s=new Ao({color:16766282,linewidth:eC,vertexColors:!1,worldUnits:!0,dashed:!0,dashSize:tC,dashScale:nC});this.localPath=new go(i,s),this.localPath.position.set(0,0,.2),this.localPath.renderOrder=Rn.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 Zs;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 Zs;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){return e.flatMap(t=>t.map(n=>{const i=Number(n);return isNaN(i)&&console.warn(`Invalid number conversion for value: ${n}`),i}))}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 hf{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 L().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 L(i===0?e.x:n.x,s===0?e.y:n.y,a===0?e.z:n.z),l=new L(i===0?n.x:t.x,s===0?n.y:t.y,a===0?n.z:t.z),c=new ln(o,l);this.children.push(new hf(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 uf{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 ge(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 ge((e.x+t.x)/2,(e.y+t.y)/2),i=[new br(new ge(e.x,e.y),new ge(n.x,n.y)),new br(new ge(n.x,e.y),new ge(t.x,n.y)),new br(new ge(e.x,n.y),new ge(n.x,t.y)),new br(new ge(n.x,n.y),new ge(t.x,t.y))];if(this.children=i.map(s=>new uf(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 Qi=[{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}],sC=1024*3;class rC{editor;pointsOctree=null;pointsQuadTree=null;mappingPoints=null;mappingPointsGeo=null;mappingPointsMat=null;mappingKeyFrame=null;mappingKeyFrameGeo=null;mappingKeyFrameMat=null;mapPoints;mapPointsGeo;mapPointsMat;mapPointsData;lidarPoints;lidarPointsGeo;lidarPointsMat;lidarFloat32Array=new Float32Array;lidarPositionAttr;lastLidarSphereUpdateTime=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("ui:map-points-update-requested",this.handleMapPointsLoaded),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:lidar-point-size-set-requested",this.handleLidarPointSizeSetRequested)}deregisterEventListeners(){const e=this.editor.eventHandler.eventBus;e.off("lidar:updated",this.handleLidarUpdated),e.off("ui:map-points-update-requested",this.handleMapPointsLoaded),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:lidar-point-size-set-requested",this.handleLidarPointSizeSetRequested)}changeMapPointsOpacity(e){this.mapPointsMat.opacity=e*.01}clearMapPoints(){this.mapPointsGeo.deleteAttribute("position"),this.mapPointsGeo.setAttribute("position",new Fe([],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.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||!this.mapPointsMat)&&(this.mapPointsGeo.dispose(),this.mapPointsMat.dispose(),this.mapPointsData=null,this.lidarPointsGeo.dispose(),this.lidarPointsMat.dispose(),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.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.editor.eventHandler.eventBus.emit("points-manager:mappoints-updated",{mapBounds:s})}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()}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],v=e[u*3+2];f<n&&(n=f),f>a&&(a=f),m<i&&(i=m),m>o&&(o=m),v<s&&(s=v),v>l&&(l=v)}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}}createCloudOctree(){const e=this.mapPointsGeo.getAttribute("position"),t=new ln().setFromBufferAttribute(e);t.expandByScalar(1);const n=new hf(t,20);for(let i=0;i<e.count;i++){const s=new L().fromBufferAttribute(e,i);n.insert(s,i)}this.pointsOctree=n}createCloudQuadTree(){const e=this.mapPointsGeo.getAttribute("position"),t=new ln().setFromBufferAttribute(e),n=new br(new ge(t.min.x,t.min.y),new ge(t.max.x,t.max.y));n.expandByScalar(1);const i=new uf(n,20);try{for(let s=0;s<e.count;s++){const a=new L().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 Fe(i,3);s.setUsage(Bf),this.lidarPositionAttr=s,this.lidarPointsGeo.setAttribute("position",s)}}finalizeUpdate(){this.mapPointsGeo.attributes.position.needsUpdate=!0,this.mapPointsGeo.computeBoundingSphere()}clearPointsGeometry(e){e.deleteAttribute("position"),e.setAttribute("position",new Fe([],3)),e.boundingSphere=null,e.attributes.position.needsUpdate=!0}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()&&this.lidarPointsGeo.computeBoundingSphere()};handleLidarToggled=e=>{this.lidarPoints.visible=e};handleLidarPointSizeSetRequested=e=>{this.lidarPointsMat.size=e,this.lidarPointsMat.needsUpdate=!0};shouldUpdateSphere(){const e=performance.now();return e-this.lastLidarSphereUpdateTime>this.sphereUpdateInterval||this.lastLidarSphereUpdateTime===0?(this.lastLidarSphereUpdateTime=e,!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 Fe(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=Qi[0],d=Qi[1],h=e[0],u=e[1]):l<e[2]?(c=Qi[1],d=Qi[2],h=e[1],u=e[2]):l<e[3]?(c=Qi[2],d=Qi[3],h=e[2],u=e[3]):l<e[4]?(c=Qi[3],d=Qi[4],h=e[3],u=e[4]):(c=Qi[4],d=Qi[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 v=c.r*(1-m)+d.r*m,g=c.g*(1-m)+d.g*m,b=c.b*(1-m)+d.b*m;a.setXYZ(o,v,g,b)}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 Fe(s,3);return e.setAttribute("position",a),{position:s,numPoints:s.length/3}}handleMapPointsLoaded=e=>{this.updateMapPoints(e)};handleMappingStarted=()=>{this.handleMappingStopped(),this.resetMappingKeyFrameChunks(),this.mapPoints.visible=!1,this.mappingPointsGeo=new mt,this.mappingPointsGeo.setAttribute("position",new Fe([],3)),this.mappingPointsMat=new aa({size:.2,color:8245247}),this.mappingPoints=new lo(this.mappingPointsGeo,this.mappingPointsMat),this.mappingPoints.renderOrder=Rn.MAPPING_POINTS,this.mappingPoints.userData.keep=!0,this.editor.scene.add(this.mappingPoints),this.mappingKeyFrameGeo=new mt,this.mappingKeyFrameGeo.setAttribute("position",new Fe([],3)),this.mappingKeyFrameMat=new aa({size:.2,color:2450411}),this.mappingKeyFrame=new lo(this.mappingKeyFrameGeo,this.mappingKeyFrameMat),this.mappingKeyFrame.renderOrder=Rn.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)};handleEditorInitialized=()=>{this.mapPointsGeo=new mt,this.mapPointsGeo.setAttribute("position",new Fe([],3)),this.mapPointsMat=new aa({size:.15,vertexColors:!0,transparent:!0,opacity:1,depthWrite:!1}),this.mapPoints=new lo(this.mapPointsGeo,this.mapPointsMat),this.mapPoints.renderOrder=Rn.MAP_POINTS,this.mapPoints.userData.keep=!0,this.editor.scene.add(this.mapPoints),this.mapPointsData=[],this.lidarPointsGeo=new mt,this.lidarPointsMat=new aa({size:.15,color:16725342,transparent:!0,depthWrite:!1}),this.lidarPoints=new lo(this.lidarPointsGeo,this.lidarPointsMat),this.lidarPoints.renderOrder=Rn.LIDAR_POINTS,this.lidarPoints.userData.keep=!0,this.lidarPositionAttr=new Fe(new Float32Array(sC),3),this.lidarPositionAttr.setUsage(Bf)};resetMappingKeyFrameChunks=()=>{this.pendingMappingKeyFrameChunkNum=null,this.pendingMappingKeyFrameChunks.clear()}}class ff{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 Js extends Vt{transformBuf=new ff;tmpTransform=new L;clock=new sf;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 ln().setFromObject(e),s=-i.min.z;if(e.position.z+=s,n){const a=new L;i.getCenter(a),e.position.x-=a.x,e.position.y-=a.y}e.updateMatrixWorld(!0)}}class pf extends Js{static async create(){const e=new pf;return await e._initAsync(),e}constructor(){super(),this.name="RB-S100",this.userData.keep=!0}async _initAsync(){const e=new Rr,t=Bn(Es.S100.modelUrl);try{const i=(await e.loadAsync(t)).scene;i.traverse(s=>{s.userData.keep=!0}),i.renderOrder=Rn.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 lc={exports:{}};/* @license
|
|
4610
4388
|
Papa Parse
|
|
4611
4389
|
v5.5.3
|
|
4612
4390
|
https://github.com/mholt/PapaParse
|
|
4613
4391
|
License: MIT
|
|
4614
|
-
*/var
|
|
4392
|
+
*/var aC=lc.exports,Km;function oC(){return Km||(Km=1,(function(r,e){((t,n)=>{r.exports=n()})(aC,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(x){var S=R(x);S.chunkSize=parseInt(S.chunkSize),x.step||x.chunk||(S.chunkSize=null),this._handle=new v(S),(this._handle.streamer=this)._config=S}.call(this,M),this.parseChunk=function(x,S){var C=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<C){let I=this._config.newline;I||(k=this._config.quoteChar||'"',I=this._handle.guessLineEndings(x,k)),x=[...x.split(I).slice(C)].join(I)}this.isFirstChunk&&P(this._config.beforeFirstChunk)&&(k=this._config.beforeFirstChunk(x))!==void 0&&(x=k),this.isFirstChunk=!1,this._halted=!1;var C=this._partialLine+x,k=(this._partialLine="",this._handle.parse(C,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(x=k.meta.cursor,C=(this._finished||(this._partialLine=C.substring(x-this._baseIndex),this._baseIndex=x),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:C});else if(P(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||!C||!P(this._config.complete)||k&&k.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),C||k&&k.meta.paused||this._nextChunk(),k}this._halted=!0},this._sendError=function(x){P(this._config.error)?this._config.error(x):a&&this._config.error&&n.postMessage({workerId:c.WORKER_ID,error:x,finished:!1})}}function h(M){var x;(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(x=new XMLHttpRequest,this._config.withCredentials&&(x.withCredentials=this._config.withCredentials),s||(x.onload=T(this._chunkLoaded,this),x.onerror=T(this._chunkError,this)),x.open(this._config.downloadRequestBody?"POST":"GET",this._input,!s),this._config.downloadRequestHeaders){var S,C=this._config.downloadRequestHeaders;for(S in C)x.setRequestHeader(S,C[S])}var k;this._config.chunkSize&&(k=this._start+this._config.chunkSize-1,x.setRequestHeader("Range","bytes="+this._start+"-"+k));try{x.send(this._config.downloadRequestBody)}catch(I){this._chunkError(I.message)}s&&x.status===0&&this._chunkError()}},this._chunkLoaded=function(){x.readyState===4&&(x.status<200||400<=x.status?this._chunkError():(this._start+=this._config.chunkSize||x.responseText.length,this._finished=!this._config.chunkSize||this._start>=(S=>(S=S.getResponseHeader("Content-Range"))!==null?parseInt(S.substring(S.lastIndexOf("/")+1)):-1)(x),this.parseChunk(x.responseText)))},this._chunkError=function(S){S=x.statusText||S,this._sendError(new Error(S))}}function u(M){(M=M||{}).chunkSize||(M.chunkSize=c.LocalChunkSize),d.call(this,M);var x,S,C=typeof FileReader<"u";this.stream=function(k){this._input=k,S=k.slice||k.webkitSlice||k.mozSlice,C?((x=new FileReader).onload=T(this._chunkLoaded,this),x.onerror=T(this._chunkError,this)):x=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,I=(this._config.chunkSize&&(I=Math.min(this._start+this._config.chunkSize,this._input.size),k=S.call(k,this._start,I)),x.readAsText(k,this._config.encoding));C||this._chunkLoaded({target:{result:I}})},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(x.error)}}function f(M){var x;d.call(this,M=M||{}),this.stream=function(S){return x=S,this._nextChunk()},this._nextChunk=function(){var S,C;if(!this._finished)return S=this._config.chunkSize,x=S?(C=x.substring(0,S),x.substring(S)):(C=x,""),this._finished=!x,this.parseChunk(C)}}function m(M){d.call(this,M=M||{});var x=[],S=!0,C=!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(){C&&x.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),x.length?this.parseChunk(x.shift()):S=!0},this._streamData=T(function(k){try{x.push(typeof k=="string"?k:k.toString(this._config.encoding)),S&&(S=!1,this._checkIsFinished(),this.parseChunk(x.shift()))}catch(I){this._streamError(I)}},this),this._streamError=T(function(k){this._streamCleanUp(),this._sendError(k)},this),this._streamEnd=T(function(){this._streamCleanUp(),C=!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 v(M){var x,S,C,k,I=Math.pow(2,53),G=-I,q=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,O=/^((\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)))$/,W=this,Z=0,K=0,oe=!1,te=!1,ve=[],ce={data:[],errors:[],meta:{}};function Q(ue){return M.skipEmptyLines==="greedy"?ue.join("").trim()==="":ue.length===1&&ue[0].length===0}function re(){if(ce&&C&&(ne("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+c.DefaultDelimiter+"'"),C=!1),M.skipEmptyLines&&(ce.data=ce.data.filter(function(fe){return!Q(fe)})),J()){let fe=function(be,Ce){P(M.transformHeader)&&(be=M.transformHeader(be,Ce)),ve.push(be)};if(ce)if(Array.isArray(ce.data[0])){for(var ue=0;J()&&ue<ce.data.length;ue++)ce.data[ue].forEach(fe);ce.data.splice(0,1)}else ce.data.forEach(fe)}function Te(fe,be){for(var Ce=M.header?{}:[],X=0;X<fe.length;X++){var Be=X,Me=fe[X],Me=((et,Se)=>(Ye=>(M.dynamicTypingFunction&&M.dynamicTyping[Ye]===void 0&&(M.dynamicTyping[Ye]=M.dynamicTypingFunction(Ye)),(M.dynamicTyping[Ye]||M.dynamicTyping)===!0))(et)?Se==="true"||Se==="TRUE"||Se!=="false"&&Se!=="FALSE"&&((Ye=>{if(q.test(Ye)&&(Ye=parseFloat(Ye),G<Ye&&Ye<I))return 1})(Se)?parseFloat(Se):O.test(Se)?new Date(Se):Se===""?null:Se):Se)(Be=M.header?X>=ve.length?"__parsed_extra":ve[X]:Be,Me=M.transform?M.transform(Me,Be):Me);Be==="__parsed_extra"?(Ce[Be]=Ce[Be]||[],Ce[Be].push(Me)):Ce[Be]=Me}return M.header&&(X>ve.length?ne("FieldMismatch","TooManyFields","Too many fields: expected "+ve.length+" fields but parsed "+X,K+be):X<ve.length&&ne("FieldMismatch","TooFewFields","Too few fields: expected "+ve.length+" fields but parsed "+X,K+be)),Ce}var _e;ce&&(M.header||M.dynamicTyping||M.transform)&&(_e=1,!ce.data.length||Array.isArray(ce.data[0])?(ce.data=ce.data.map(Te),_e=ce.data.length):ce.data=Te(ce.data,0),M.header&&ce.meta&&(ce.meta.fields=ve),K+=_e)}function J(){return M.header&&ve.length===0}function ne(ue,Te,_e,fe){ue={type:ue,code:Te,message:_e},fe!==void 0&&(ue.row=fe),ce.errors.push(ue)}P(M.step)&&(k=M.step,M.step=function(ue){ce=ue,J()?re():(re(),ce.data.length!==0&&(Z+=ue.data.length,M.preview&&Z>M.preview?S.abort():(ce.data=ce.data[0],k(ce,W))))}),this.parse=function(ue,Te,_e){var fe=M.quoteChar||'"',fe=(M.newline||(M.newline=this.guessLineEndings(ue,fe)),C=!1,M.delimiter?P(M.delimiter)&&(M.delimiter=M.delimiter(ue),ce.meta.delimiter=M.delimiter):((fe=((be,Ce,X,Be,Me)=>{var et,Se,Ye,ee;Me=Me||[","," ","|",";",c.RECORD_SEP,c.UNIT_SEP];for(var U=0;U<Me.length;U++){for(var A,Y=Me[U],V=0,$=0,le=0,Ie=(Ye=void 0,new b({comments:Be,delimiter:Y,newline:Ce,preview:10}).parse(be)),we=0;we<Ie.data.length;we++)X&&Q(Ie.data[we])?le++:(A=Ie.data[we].length,$+=A,Ye===void 0?Ye=A:0<A&&(V+=Math.abs(A-Ye),Ye=A));0<Ie.data.length&&($/=Ie.data.length-le),(Se===void 0||V<=Se)&&(ee===void 0||ee<$)&&1.99<$&&(Se=V,et=Y,ee=$)}return{successful:!!(M.delimiter=et),bestDelimiter:et}})(ue,M.newline,M.skipEmptyLines,M.comments,M.delimitersToGuess)).successful?M.delimiter=fe.bestDelimiter:(C=!0,M.delimiter=c.DefaultDelimiter),ce.meta.delimiter=M.delimiter),R(M));return M.preview&&M.header&&fe.preview++,x=ue,S=new b(fe),ce=S.parse(x,Te,_e),re(),oe?{meta:{paused:!0}}:ce||{meta:{paused:!1}}},this.paused=function(){return oe},this.pause=function(){oe=!0,S.abort(),x=P(M.chunk)?"":x.substring(S.getCharIndex())},this.resume=function(){W.streamer._halted?(oe=!1,W.streamer.parseChunk(x,!0)):setTimeout(W.resume,3)},this.aborted=function(){return te},this.abort=function(){te=!0,S.abort(),ce.meta.aborted=!0,P(M.complete)&&M.complete(ce),x=""},this.guessLineEndings=function(be,fe){be=be.substring(0,1048576);var fe=new RegExp(g(fe)+"([^]*?)"+g(fe),"gm"),_e=(be=be.replace(fe,"")).split("\r"),fe=be.split(`
|
|
4615
4393
|
`),be=1<fe.length&&fe[0].length<_e[0].length;if(_e.length===1||be)return`
|
|
4616
4394
|
`;for(var Ce=0,X=0;X<_e.length;X++)_e[X][0]===`
|
|
4617
4395
|
`&&Ce++;return Ce>=_e.length/2?`\r
|
|
@@ -4620,7 +4398,7 @@ License: MIT
|
|
|
4620
4398
|
`&&(S=`
|
|
4621
4399
|
`);var K=0,oe=!1;this.parse=function(te,ve,ce){if(typeof te!="string")throw new Error("Input must be a string");var Q=te.length,re=x.length,J=S.length,ne=C.length,ue=P(k),Te=[],_e=[],fe=[],be=K=0;if(!te)return V();if(G||G!==!1&&te.indexOf(W)===-1){for(var Ce=te.split(S),X=0;X<Ce.length;X++){if(fe=Ce[X],K+=fe.length,X!==Ce.length-1)K+=S.length;else if(ce)return V();if(!C||fe.substring(0,ne)!==C){if(ue){if(Te=[],ee(fe.split(x)),$(),oe)return V()}else ee(fe.split(x));if(I&&I<=X)return Te=Te.slice(0,I),V(!0)}}return V()}for(var Be=te.indexOf(x,K),Me=te.indexOf(S,K),et=new RegExp(g(Z)+g(W),"g"),Se=te.indexOf(W,K);;)if(te[K]===W)for(Se=K,K++;;){if((Se=te.indexOf(W,Se+1))===-1)return ce||_e.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:Te.length,index:K}),A();if(Se===Q-1)return A(te.substring(K,Se).replace(et,W));if(W===Z&&te[Se+1]===Z)Se++;else if(W===Z||Se===0||te[Se-1]!==Z){Be!==-1&&Be<Se+1&&(Be=te.indexOf(x,Se+1));var Ye=U((Me=Me!==-1&&Me<Se+1?te.indexOf(S,Se+1):Me)===-1?Be:Math.min(Be,Me));if(te.substr(Se+1+Ye,re)===x){fe.push(te.substring(K,Se).replace(et,W)),te[K=Se+1+Ye+re]!==W&&(Se=te.indexOf(W,K)),Be=te.indexOf(x,K),Me=te.indexOf(S,K);break}if(Ye=U(Me),te.substring(Se+1+Ye,Se+1+Ye+J)===S){if(fe.push(te.substring(K,Se).replace(et,W)),Y(Se+1+Ye+J),Be=te.indexOf(x,K),Se=te.indexOf(W,K),ue&&($(),oe))return V();if(I&&Te.length>=I)return V(!0);break}_e.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:Te.length,index:K}),Se++}}else if(C&&fe.length===0&&te.substring(K,K+ne)===C){if(Me===-1)return V();K=Me+J,Me=te.indexOf(S,K),Be=te.indexOf(x,K)}else if(Be!==-1&&(Be<Me||Me===-1))fe.push(te.substring(K,Be)),K=Be+re,Be=te.indexOf(x,K);else{if(Me===-1)break;if(fe.push(te.substring(K,Me)),Y(Me+J),ue&&($(),oe))return V();if(I&&Te.length>=I)return V(!0)}return A();function ee(le){Te.push(le),be=K}function U(le){var Ie=0;return Ie=le!==-1&&(le=te.substring(Se+1,le))&&le.trim()===""?le.length:Ie}function A(le){return ce||(le===void 0&&(le=te.substring(K)),fe.push(le),K=Q,ee(fe),ue&&$()),V()}function Y(le){K=le,ee(fe),fe=[],Me=te.indexOf(S,K)}function V(le){if(M.header&&!ve&&Te.length&&!O){var Ie=Te[0],we=Object.create(null),ze=new Set(Ie);let pt=!1;for(let Pe=0;Pe<Ie.length;Pe++){let Ue=Ie[Pe];if(we[Ue=P(M.transformHeader)?M.transformHeader(Ue,Pe):Ue]){let Qe,Ne=we[Ue];for(;Qe=Ue+"_"+Ne,Ne++,ze.has(Qe););ze.add(Qe),Ie[Pe]=Qe,we[Ue]++,pt=!0,(q=q===null?{}:q)[Qe]=Ue}else we[Ue]=1,Ie[Pe]=Ue;ze.add(Ue)}pt&&console.warn("Duplicate headers found and renamed."),O=!0}return{data:Te,errors:_e,meta:{delimiter:x,linebreak:S,aborted:oe,truncated:!!le,cursor:be+(ve||0),renamedHeaders:q}}}function $(){k(V()),Te=[],_e=[]}},this.abort=function(){oe=!0},this.getCharIndex=function(){return K}}function y(M){var x=M.data,S=o[x.workerId],C=!1;if(x.error)S.userError(x.error,x.file);else if(x.results&&x.results.data){var k={abort:function(){C=!0,w(x.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:_,resume:_};if(P(S.userStep)){for(var I=0;I<x.results.data.length&&(S.userStep({data:x.results.data[I],errors:x.results.errors,meta:x.results.meta},k),!C);I++);delete x.results}else P(S.userChunk)&&(S.userChunk(x.results,k,x.file),delete x.results)}x.finished&&!C&&w(x.workerId,x.results)}function w(M,x){var S=o[M];P(S.userComplete)&&S.userComplete(x),S.terminate(),delete o[M]}function _(){throw new Error("Not implemented.")}function R(M){if(typeof M!="object"||M===null)return M;var x,S=Array.isArray(M)?[]:{};for(x in M)S[x]=R(M[x]);return S}function T(M,x){return function(){M.apply(x,arguments)}}function P(M){return typeof M=="function"}return c.parse=function(M,x){var S=(x=x||{}).dynamicTyping||!1;if(P(S)&&(x.dynamicTypingFunction=S,S={}),x.dynamicTyping=S,x.transform=!!P(x.transform)&&x.transform,!x.worker||!c.WORKERS_SUPPORTED)return S=null,c.NODE_STREAM_INPUT,typeof M=="string"?(M=(C=>C.charCodeAt(0)!==65279?C:C.slice(1))(M),S=new(x.download?h:f)(x)):M.readable===!0&&P(M.read)&&P(M.on)?S=new m(x):(n.File&&M instanceof File||M instanceof Object)&&(S=new u(x)),S.stream(M);(S=(()=>{var C;return!!c.WORKERS_SUPPORTED&&(C=(()=>{var k=n.URL||n.webkitURL||null,I=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; ","(",I,")();"],{type:"text/javascript"})))})(),(C=new n.Worker(C)).onmessage=y,C.id=l++,o[C.id]=C)})()).userStep=x.step,S.userChunk=x.chunk,S.userComplete=x.complete,S.userError=x.error,x.step=P(x.step),x.chunk=P(x.chunk),x.complete=P(x.complete),x.error=P(x.error),delete x.worker,S.postMessage({input:M,config:x,workerId:S.id})},c.unparse=function(M,x){var S=!1,C=!0,k=",",I=`\r
|
|
4622
4400
|
`,G='"',q=G+G,O=!1,W=null,Z=!1,K=((()=>{if(typeof x=="object"){if(typeof x.delimiter!="string"||c.BAD_DELIMITERS.filter(function(ve){return x.delimiter.indexOf(ve)!==-1}).length||(k=x.delimiter),typeof x.quotes!="boolean"&&typeof x.quotes!="function"&&!Array.isArray(x.quotes)||(S=x.quotes),typeof x.skipEmptyLines!="boolean"&&typeof x.skipEmptyLines!="string"||(O=x.skipEmptyLines),typeof x.newline=="string"&&(I=x.newline),typeof x.quoteChar=="string"&&(G=x.quoteChar),typeof x.header=="boolean"&&(C=x.header),Array.isArray(x.columns)){if(x.columns.length===0)throw new Error("Option columns is empty");W=x.columns}x.escapeChar!==void 0&&(q=x.escapeChar+G),x.escapeFormulae instanceof RegExp?Z=x.escapeFormulae:typeof x.escapeFormulae=="boolean"&&x.escapeFormulae&&(Z=/^[=+\-@\t\r].*$/)}})(),new RegExp(g(G),"g"));if(typeof M=="string"&&(M=JSON.parse(M)),Array.isArray(M)){if(!M.length||Array.isArray(M[0]))return oe(null,M,O);if(typeof M[0]=="object")return oe(W||Object.keys(M[0]),M,O)}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||W),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])),oe(M.fields||[],M.data||[],O);throw new Error("Unable to serialize unrecognized input");function oe(ve,ce,Q){var re="",J=(typeof ve=="string"&&(ve=JSON.parse(ve)),typeof ce=="string"&&(ce=JSON.parse(ce)),Array.isArray(ve)&&0<ve.length),ne=!Array.isArray(ce[0]);if(J&&C){for(var ue=0;ue<ve.length;ue++)0<ue&&(re+=k),re+=te(ve[ue],ue);0<ce.length&&(re+=I)}for(var Te=0;Te<ce.length;Te++){var _e=(J?ve:ce[Te]).length,fe=!1,be=J?Object.keys(ce[Te]).length===0:ce[Te].length===0;if(Q&&!J&&(fe=Q==="greedy"?ce[Te].join("").trim()==="":ce[Te].length===1&&ce[Te][0].length===0),Q==="greedy"&&J){for(var Ce=[],X=0;X<_e;X++){var Be=ne?ve[X]:X;Ce.push(ce[Te][Be])}fe=Ce.join("").trim()===""}if(!fe){for(var Me=0;Me<_e;Me++){0<Me&&!be&&(re+=k);var et=J&&ne?ve[Me]:Me;re+=te(ce[Te][et],Me)}Te<ce.length-1&&(!Q||0<_e&&!be)&&(re+=I)}}return re}function te(ve,ce){var Q,re;return ve==null?"":ve.constructor===Date?JSON.stringify(ve).slice(1,25):(re=!1,Z&&typeof ve=="string"&&Z.test(ve)&&(ve="'"+ve,re=!0),Q=ve.toString().replace(K,q),(re=re||S===!0||typeof S=="function"&&S(ve,ce)||Array.isArray(S)&&S[ce]||((J,ne)=>{for(var ue=0;ue<ne.length;ue++)if(-1<J.indexOf(ne[ue]))return!0;return!1})(Q,c.BAD_DELIMITERS)||-1<Q.indexOf(k)||Q.charAt(0)===" "||Q.charAt(Q.length-1)===" ")?G+Q+G:Q)}},c.RECORD_SEP="",c.UNIT_SEP="",c.BYTE_ORDER_MARK="\uFEFF",c.BAD_DELIMITERS=["\r",`
|
|
4623
|
-
`,'"',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=b,c.ParserHandle=v,c.NetworkStreamer=h,c.FileStreamer=u,c.StringStreamer=f,c.ReadableStreamStreamer=m,n.jQuery&&((i=n.jQuery).fn.parse=function(M){var x=M.config||{},S=[];return this.each(function(I){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 G=0;G<this.files.length;G++)S.push({file:this.files[G],inputElem:this,instanceConfig:i.extend({},x)})}),C(),this;function C(){if(S.length===0)P(M.complete)&&M.complete();else{var I,G,q,O,W=S[0];if(P(M.before)){var Z=M.before(W.file,W.inputElem);if(typeof Z=="object"){if(Z.action==="abort")return I="AbortError",G=W.file,q=W.inputElem,O=Z.reason,void(P(M.error)&&M.error({name:I},G,q,O));if(Z.action==="skip")return void k();typeof Z.config=="object"&&(W.instanceConfig=i.extend(W.instanceConfig,Z.config))}else if(Z==="skip")return void k()}var K=W.instanceConfig.complete;W.instanceConfig.complete=function(oe){P(K)&&K(oe,W.file,W.inputElem),k()},c.parse(W.file,W.instanceConfig)}}function k(){S.splice(0,1),C()}}),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})})(lc)),lc.exports}var dC=cC();const hC=my(dC);class gf extends Js{robot;static async create(){const e=new gf;return await e._initAsync(),e}constructor(){super(),this.jointBuf=new pf,this.name="RBQ",this.userData.keep=!0}async _initAsync(){const e=new Lc,t=new cf(e),n=Bn(Es.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=Hv(e),s=await fetch(i).then(c=>c.text()),{data:a}=hC.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 bf extends Js{static async create(){const e=new bf;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 Kt(1.1044,.7484,.537,10,1,1),s=new Le(65535),a=new Le(16711680),o=[],l=-1.1044/2,c=1.1044/2,d=l+(c-l)*(2/3);for(let v=0;v<i.attributes.position.count;v++){const g=new L;g.fromBufferAttribute(i.attributes.position,v);const b=g.x>=d?a:s;o.push(b.r,b.g,b.b)}i.setAttribute("color",new Fe(o,3));const h=new jt({vertexColors:!0,transparent:!0,opacity:.65,depthWrite:!1,side:xi}),u=new Ae(i,h);u.position.set(0,0,.2685),u.userData.keep=!0,u.renderOrder=1;const f=new Rc(i),m=new Pr(f,new Yn({color:16777215}));m.renderOrder=2,m.userData.keep=!0,u.add(m),this.add(u)}}class vf extends Js{static async create(){const e=new vf;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 Kt(1.1044,.7484,.537,10,1,1),s=new Le(65535),a=new Le(16711680),o=[],l=-1.1044/2,c=1.1044/2,d=l+(c-l)*(2/3);for(let v=0;v<i.attributes.position.count;v++){const g=new L;g.fromBufferAttribute(i.attributes.position,v);const b=g.x>=d?a:s;o.push(b.r,b.g,b.b)}i.setAttribute("color",new Fe(o,3));const h=new jt({vertexColors:!0,transparent:!0,opacity:.65,depthWrite:!1,side:xi}),u=new Ae(i,h);u.position.set(0,0,.2685),u.userData.keep=!0,u.renderOrder=1;const f=new Rc(i),m=new Pr(f,new Yn({color:16777215}));m.renderOrder=2,m.userData.keep=!0,u.add(m),this.add(u)}}class xc extends Js{static async create(){const e=new xc;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 Kt(1.1044,.7484,.537,10,1,1),s=new Le(65535),a=new Le(16711680),o=[],l=-1.1044/2,c=1.1044/2,d=l+(c-l)*(2/3);for(let v=0;v<i.attributes.position.count;v++){const g=new L;g.fromBufferAttribute(i.attributes.position,v);const b=g.x>=d?a:s;o.push(b.r,b.g,b.b)}i.setAttribute("color",new Fe(o,3));const h=new jt({vertexColors:!0,transparent:!0,opacity:.65,depthWrite:!1,side:xi}),u=new Ae(i,h);u.position.set(0,0,.2685),u.userData.keep=!0,u.renderOrder=1;const f=new Rc(i),m=new Pr(f,new Yn({color:16777215}));m.renderOrder=2,m.userData.keep=!0,u.add(m),this.add(u)}}class yf extends Js{static async create(){const e=new yf;return await e._initAsync(),e}constructor(){super(),this.name="GAIA",this.userData.keep=!0}async _initAsync(){const e=new Rr,t=new Io,n=Bn(Es.GAIA.modelUrl);t.setDecoderPath(Bn("/draco/")),e.setDRACOLoader(t);try{const s=(await e.loadAsync(n)).scene;s.renderOrder=Rn.ROBOT;const a=new Vt;a.add(s),a.traverse(o=>{if(o.userData.keep=!0,!(o instanceof Ae))return;const l=c=>{const d=new On;return"color"in c&&c.color instanceof Le&&d.color.copy(c.color),"map"in c&&c.map instanceof Bt&&(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 xf extends Js{static async create(){const e=new xf;return await e._initAsync(),e}constructor(){super(),this.name="QD",this.userData.keep=!0}async _initAsync(){const e=new Rr,t=new Io,n=Bn(Es.QD.modelUrl);t.setDecoderPath(Bn("/draco/")),e.setDRACOLoader(t);try{const s=(await e.loadAsync(n)).scene;s.renderOrder=Rn.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 Qm={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 _f extends Js{robot;variant;static async create(e="rby1m"){const t=new _f(e);return await t._initAsync(),t}constructor(e){super(),this.variant=e,this.jointBuf=new pf,this.name=Qm[e].name,this.userData.keep=!0}async _initAsync(){const e=Qm[this.variant],t=Bn(e.urdfPath);await new Promise(n=>{const i=new Lc,s=new cf(i);let a=null,o=!1;const l=()=>{o||(o=!0,n())};s.loadMeshCb=av,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 Jm=["#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 uC{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=[...Jm]}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 ba(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 mf.create(),this.s100=t;break;case"RBQ":t=await gf.create(),this.rbq=t;break;case"SEM":t=await bf.create();break;case"SEC":t=await vf.create();break;case"D400":case"D400_NEW":case"DD-SEC_EE":t=await xc.create();break;case"QD":t=await yf.create();break;case"rby1a":case"rby1m":case"rby1ub":case"rby2c":t=await _f.create(e);break;case"QD-RBY":t=await xf.create();break;default:t=await xc.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 ka(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 Le(this.getUniqueColor()),t.material=n,t}getUniqueColor(){return this.availableColors.length===0&&(this.availableColors=[...Jm]),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 fC{_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)}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 pC{editor;_raycaster;_invMat=new ke;mouse=new ge;selectionRect=new br;constructor(e){this.editor=e,this._raycaster=new of,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 ge(Math.min(t.x,n.x),Math.min(t.y,n.y)),this.selectionRect.max=new ge(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 ge(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.editor.eventHandler.eventBus.emit("selector:zone-selected",{zoneIds:s.zoneIds}),this.select(null);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 L;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 br(new ge(e.x-t,e.y-t),new ge(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 T_(t,e,i,s,.3,.3);n.add(a)}accumulateQuadtreeIntersections(e,t,n,i,s){const a=t.boundary.clone().expandByScalar(n),o=new ln(new L(a.min.x,a.min.y,-n),new L(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}}/*! *****************************************************************************
|
|
4401
|
+
`,'"',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=b,c.ParserHandle=v,c.NetworkStreamer=h,c.FileStreamer=u,c.StringStreamer=f,c.ReadableStreamStreamer=m,n.jQuery&&((i=n.jQuery).fn.parse=function(M){var x=M.config||{},S=[];return this.each(function(I){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 G=0;G<this.files.length;G++)S.push({file:this.files[G],inputElem:this,instanceConfig:i.extend({},x)})}),C(),this;function C(){if(S.length===0)P(M.complete)&&M.complete();else{var I,G,q,O,W=S[0];if(P(M.before)){var Z=M.before(W.file,W.inputElem);if(typeof Z=="object"){if(Z.action==="abort")return I="AbortError",G=W.file,q=W.inputElem,O=Z.reason,void(P(M.error)&&M.error({name:I},G,q,O));if(Z.action==="skip")return void k();typeof Z.config=="object"&&(W.instanceConfig=i.extend(W.instanceConfig,Z.config))}else if(Z==="skip")return void k()}var K=W.instanceConfig.complete;W.instanceConfig.complete=function(oe){P(K)&&K(oe,W.file,W.inputElem),k()},c.parse(W.file,W.instanceConfig)}}function k(){S.splice(0,1),C()}}),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})})(lc)),lc.exports}var lC=oC();const cC=my(lC);class mf extends Js{robot;static async create(){const e=new mf;return await e._initAsync(),e}constructor(){super(),this.jointBuf=new ff,this.name="RBQ",this.userData.keep=!0}async _initAsync(){const e=new Lc,t=new cf(e),n=Bn(Es.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=Hv(e),s=await fetch(i).then(c=>c.text()),{data:a}=cC.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 gf extends Js{static async create(){const e=new gf;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 Kt(1.1044,.7484,.537,10,1,1),s=new Le(65535),a=new Le(16711680),o=[],l=-1.1044/2,c=1.1044/2,d=l+(c-l)*(2/3);for(let v=0;v<i.attributes.position.count;v++){const g=new L;g.fromBufferAttribute(i.attributes.position,v);const b=g.x>=d?a:s;o.push(b.r,b.g,b.b)}i.setAttribute("color",new Fe(o,3));const h=new jt({vertexColors:!0,transparent:!0,opacity:.65,depthWrite:!1,side:xi}),u=new Ae(i,h);u.position.set(0,0,.2685),u.userData.keep=!0,u.renderOrder=1;const f=new Rc(i),m=new Pr(f,new Yn({color:16777215}));m.renderOrder=2,m.userData.keep=!0,u.add(m),this.add(u)}}class bf extends Js{static async create(){const e=new bf;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 Kt(1.1044,.7484,.537,10,1,1),s=new Le(65535),a=new Le(16711680),o=[],l=-1.1044/2,c=1.1044/2,d=l+(c-l)*(2/3);for(let v=0;v<i.attributes.position.count;v++){const g=new L;g.fromBufferAttribute(i.attributes.position,v);const b=g.x>=d?a:s;o.push(b.r,b.g,b.b)}i.setAttribute("color",new Fe(o,3));const h=new jt({vertexColors:!0,transparent:!0,opacity:.65,depthWrite:!1,side:xi}),u=new Ae(i,h);u.position.set(0,0,.2685),u.userData.keep=!0,u.renderOrder=1;const f=new Rc(i),m=new Pr(f,new Yn({color:16777215}));m.renderOrder=2,m.userData.keep=!0,u.add(m),this.add(u)}}class xc extends Js{static async create(){const e=new xc;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 Kt(1.1044,.7484,.537,10,1,1),s=new Le(65535),a=new Le(16711680),o=[],l=-1.1044/2,c=1.1044/2,d=l+(c-l)*(2/3);for(let v=0;v<i.attributes.position.count;v++){const g=new L;g.fromBufferAttribute(i.attributes.position,v);const b=g.x>=d?a:s;o.push(b.r,b.g,b.b)}i.setAttribute("color",new Fe(o,3));const h=new jt({vertexColors:!0,transparent:!0,opacity:.65,depthWrite:!1,side:xi}),u=new Ae(i,h);u.position.set(0,0,.2685),u.userData.keep=!0,u.renderOrder=1;const f=new Rc(i),m=new Pr(f,new Yn({color:16777215}));m.renderOrder=2,m.userData.keep=!0,u.add(m),this.add(u)}}class vf extends Js{static async create(){const e=new vf;return await e._initAsync(),e}constructor(){super(),this.name="GAIA",this.userData.keep=!0}async _initAsync(){const e=new Rr,t=new Io,n=Bn(Es.GAIA.modelUrl);t.setDecoderPath(Bn("/draco/")),e.setDRACOLoader(t);try{const s=(await e.loadAsync(n)).scene;s.renderOrder=Rn.ROBOT;const a=new Vt;a.add(s),a.traverse(o=>{if(o.userData.keep=!0,!(o instanceof Ae))return;const l=c=>{const d=new On;return"color"in c&&c.color instanceof Le&&d.color.copy(c.color),"map"in c&&c.map instanceof Bt&&(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 yf extends Js{static async create(){const e=new yf;return await e._initAsync(),e}constructor(){super(),this.name="QD",this.userData.keep=!0}async _initAsync(){const e=new Rr,t=new Io,n=Bn(Es.QD.modelUrl);t.setDecoderPath(Bn("/draco/")),e.setDRACOLoader(t);try{const s=(await e.loadAsync(n)).scene;s.renderOrder=Rn.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 $m={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 xf extends Js{robot;variant;static async create(e="rby1m"){const t=new xf(e);return await t._initAsync(),t}constructor(e){super(),this.variant=e,this.jointBuf=new ff,this.name=$m[e].name,this.userData.keep=!0}async _initAsync(){const e=$m[this.variant],t=Bn(e.urdfPath);await new Promise(n=>{const i=new Lc,s=new cf(i);let a=null,o=!1;const l=()=>{o||(o=!0,n())};s.loadMeshCb=av,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 Qm=["#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=[...Qm]}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 ba(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 pf.create(),this.s100=t;break;case"RBQ":t=await mf.create(),this.rbq=t;break;case"SEM":t=await gf.create();break;case"SEC":t=await bf.create();break;case"D400":case"D400_NEW":case"DD-SEC_EE":t=await xc.create();break;case"QD":t=await vf.create();break;case"rby1a":case"rby1m":case"rby1ub":case"rby2c":t=await xf.create(e);break;case"QD-RBY":t=await yf.create();break;default:t=await xc.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 ka(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 Le(this.getUniqueColor()),t.material=n,t}getUniqueColor(){return this.availableColors.length===0&&(this.availableColors=[...Qm]),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 hC{_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)}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 uC{editor;_raycaster;_invMat=new ke;mouse=new ge;selectionRect=new br;constructor(e){this.editor=e,this._raycaster=new of,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 ge(Math.min(t.x,n.x),Math.min(t.y,n.y)),this.selectionRect.max=new ge(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 ge(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.editor.eventHandler.eventBus.emit("selector:zone-selected",{zoneIds:s.zoneIds}),this.select(null);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 L;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 br(new ge(e.x-t,e.y-t),new ge(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 T_(t,e,i,s,.3,.3);n.add(a)}accumulateQuadtreeIntersections(e,t,n,i,s){const a=t.boundary.clone().expandByScalar(n),o=new ln(new L(a.min.x,a.min.y,-n),new L(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}}/*! *****************************************************************************
|
|
4624
4402
|
Copyright (c) Microsoft Corporation.
|
|
4625
4403
|
|
|
4626
4404
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -4633,7 +4411,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
4633
4411
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
4634
4412
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
4635
4413
|
PERFORMANCE OF THIS SOFTWARE.
|
|
4636
|
-
***************************************************************************** */function Mn(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(d){try{c(n.next(d))}catch(h){a(h)}}function l(d){try{c(n.throw(d))}catch(h){a(h)}}function c(d){d.done?s(d.value):i(d.value).then(o,l)}c((n=n.apply(r,[])).next())})}class Oo{constructor(){this.name="",this.minZoom=0,this.maxZoom=20,this.bounds=[],this.center=[]}fetchTile(e,t,n){return null}getMetaData(){return Mn(this,void 0,void 0,function*(){})}}class mC extends Oo{constructor(e="https://a.tile.openstreetmap.org/"){super(),this.address=e,this.format="png",this.maxZoom=19}fetchTile(e,t,n){return new Promise((i,s)=>{const a=document.createElement("img");a.onload=function(){i(a)},a.onerror=function(){s()},a.crossOrigin="Anonymous",a.src=this.address+e+"/"+t+"/"+n+"."+this.format})}}class wf{static createOffscreenCanvas(e,t){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,t);{let n=document.createElement("canvas");return n.width=e,n.height=t,n}}}class Sv{static createFillTexture(e="#000000",t=1,n=1){const i=wf.createOffscreenCanvas(t,n),s=i.getContext("2d");s.fillStyle=e,s.fillRect(0,0,t,n);const a=new Bt(i);return a.format=Zn,a.magFilter=bn,a.minFilter=bn,a.generateMipmaps=!1,a.needsUpdate=!0,a}}class an{}an.root=-1;an.topLeft=0;an.topRight=1;an.bottomLeft=2;an.bottomRight=3;class Xn extends Ae{constructor(e=null,t=null,n=an.root,i=0,s=0,a=0,o=null,l=null){super(o,l),this.mapView=null,this.parentNode=null,this.subdivided=!1,this.disposed=!1,this.nodesLoaded=0,this.childrenCache=null,this.isMesh=!0,this.mapView=t,this.parentNode=e,this.disposed=!1,this.location=n,this.level=i,this.x=s,this.y=a,this.initialize()}initialize(){return Mn(this,void 0,void 0,function*(){})}createChildNodes(){}subdivide(){const e=this.mapView.maxZoom();this.children.length>0||this.level+1>e||this.parentNode!==null&&this.parentNode.nodesLoaded<Xn.childrens||(this.mapView.cacheTiles&&this.childrenCache!==null?(this.isMesh=!1,this.children=this.childrenCache,this.nodesLoaded=this.childrenCache.length):this.createChildNodes(),this.subdivided=!0)}simplify(){const e=this.mapView.minZoom();if(!(this.level-1<e)){if(this.mapView.cacheTiles)this.childrenCache=this.children;else for(let t=0;t<this.children.length;t++)this.children[t].dispose();this.subdivided=!1,this.isMesh=!0,this.children=[],this.nodesLoaded=0}}loadData(){return Mn(this,void 0,void 0,function*(){if(this.level<this.mapView.provider.minZoom||this.level>this.mapView.provider.maxZoom){console.warn("Geo-Three: Loading tile outside of provider range.",this),this.material.map=Xn.defaultTexture,this.material.needsUpdate=!0;return}try{const e=yield this.mapView.provider.fetchTile(this.level,this.x,this.y);yield this.applyTexture(e)}catch{if(this.disposed)return;console.warn("Geo-Three: Failed to load node tile data.",this),this.material.map=Xn.defaultTexture}this.material.needsUpdate=!0})}applyTexture(e){return Mn(this,void 0,void 0,function*(){if(this.disposed)return;const t=new Bt(e);parseInt(vr)>=152&&(t.colorSpace="srgb"),t.generateMipmaps=!1,t.format=Zn,t.magFilter=bn,t.minFilter=bn,t.needsUpdate=!0,this.material.map=t})}nodeReady(){if(this.disposed){console.warn("Geo-Three: nodeReady() called for disposed node.",this),this.dispose();return}if(this.parentNode!==null){if(this.parentNode.nodesLoaded++,this.parentNode.nodesLoaded===Xn.childrens){this.parentNode.subdivided===!0&&(this.parentNode.isMesh=!1);for(let e=0;e<this.parentNode.children.length;e++)this.parentNode.children[e].visible=!0}this.parentNode.nodesLoaded>Xn.childrens&&console.error("Geo-Three: Loaded more children objects than expected.",this.parentNode.nodesLoaded,this)}else this.visible=!0}dispose(){this.disposed=!0;const e=this;try{const t=e.material;t.dispose(),t.map&&t.map!==Xn.defaultTexture&&t.map.dispose()}catch{}try{e.geometry.dispose()}catch{}}}Xn.defaultTexture=Sv.createFillTexture();Xn.baseGeometry=null;Xn.baseScale=null;Xn.childrens=4;class Ts extends mt{constructor(e=1,t=1,n=1,i=1,s=!1,a=10){super();const o=[],l=[],c=[],d=[];Ts.buildPlane(e,t,n,i,o,l,c,d),s&&Ts.buildSkirt(e,t,n,i,a,o,l,c,d),this.setIndex(o),this.setAttribute("position",new Fe(l,3)),this.setAttribute("normal",new Fe(c,3)),this.setAttribute("uv",new Fe(d,2))}static buildPlane(e=1,t=1,n=1,i=1,s,a,o,l){const c=e/2,d=t/2,h=n+1,u=i+1,f=e/n,m=t/i;for(let v=0;v<u;v++){const g=v*m-d;for(let b=0;b<h;b++){const y=b*f-c;a.push(y,0,g),o.push(0,1,0),l.push(b/n,1-v/i)}}for(let v=0;v<i;v++)for(let g=0;g<n;g++){const b=g+h*v,y=g+h*(v+1),w=g+1+h*(v+1),_=g+1+h*v;s.push(b,y,_,y,w,_)}}static buildSkirt(e=1,t=1,n=1,i=1,s,a,o,l,c){const d=e/2,h=t/2,u=n+1,f=i+1,m=e/n,v=t/i;let g=o.length/3;for(let y=0;y<u;y++){const w=y*m-d,_=-h;o.push(w,-s,_),l.push(0,1,0),c.push(y/n,1)}for(let y=0;y<n;y++){const w=y,_=y+1,R=y+g,T=y+g+1;a.push(_,R,w,_,T,R)}g=o.length/3;for(let y=0;y<u;y++){const w=y*m-d,_=i*v-h;o.push(w,-s,_),l.push(0,1,0),c.push(y/n,0)}let b=u*f-n-1;for(let y=0;y<n;y++){const w=b+y,_=b+y+1,R=y+g,T=y+g+1;a.push(w,R,_,R,T,_)}g=o.length/3;for(let y=0;y<f;y++){const w=y*v-h,_=-d;o.push(_,-s,w),l.push(0,1,0),c.push(0,1-y/i)}for(let y=0;y<i;y++){const w=y*f,_=(y+1)*f,R=y+g,T=y+g+1;a.push(w,R,_,R,T,_)}g=o.length/3;for(let y=0;y<f;y++){const w=y*v-h,_=n*m-d;o.push(_,-s,w),l.push(0,1,0),c.push(1,1-y/i)}for(let y=0;y<i;y++){const w=y*f+i,_=(y+1)*f+i,R=y+g,T=y+g+1;a.push(_,R,w,_,T,R)}}}class Zd{constructor(e,t){this.latitude=e,this.longitude=t}}class At{static datumsToSpherical(e,t){const n=t*At.EARTH_ORIGIN/180;let i=Math.log(Math.tan((90+e)*Math.PI/360))/(Math.PI/180);return i=i*At.EARTH_ORIGIN/180,new ge(n,i)}static sphericalToDatums(e,t){const n=e/At.EARTH_ORIGIN*180;let i=t/At.EARTH_ORIGIN*180;return i=180/Math.PI*(2*Math.atan(Math.exp(i*Math.PI/180))-Math.PI/2),new Zd(i,n)}static quadtreeToDatums(e,t,n){const i=Math.pow(2,e),s=t/i*360-180,o=180*(Math.atan(Math.sinh(Math.PI*(1-2*n/i)))/Math.PI);return new Zd(o,s)}static vectorToDatums(e){const t=180/Math.PI,n=Math.atan2(e.y,Math.sqrt(Math.pow(e.x,2)+Math.pow(-e.z,2)))*t,i=Math.atan2(-e.z,e.x)*t;return new Zd(n,i)}static datumsToVector(e,t){const n=Math.PI/180,i=t*n,s=e*n;var a=Math.cos(s);return new L(-Math.cos(i+Math.PI)*a,Math.sin(s),Math.sin(i+Math.PI)*a)}static mapboxAltitude(e){return(e.r*255*65536+e.g*255*256+e.b*255)*.1-1e4}static getTileSize(e){const t=At.WEB_MERCATOR_MAX_EXTENT,n=Math.pow(2,e);return 2*t/n}static tileBounds(e,t,n){const i=At.getTileSize(e),s=-At.WEB_MERCATOR_MAX_EXTENT+t*i,a=At.WEB_MERCATOR_MAX_EXTENT-(n+1)*i;return[s,i,a,i]}static webMercatorToLatitude(e,t){const n=At.WEB_MERCATOR_MAX_EXTENT-t*At.getTileSize(e);return Math.atan(Math.sinh(n/At.EARTH_RADIUS))}static webMercatorToLongitude(e,t){return(-At.WEB_MERCATOR_MAX_EXTENT+t*At.getTileSize(e))/At.EARTH_RADIUS}}At.EARTH_RADIUS=6371008;At.EARTH_RADIUS_A=6378137;At.EARTH_RADIUS_B=6356752314245e-6;At.EARTH_PERIMETER=2*Math.PI*At.EARTH_RADIUS;At.EARTH_ORIGIN=At.EARTH_PERIMETER/2;At.WEB_MERCATOR_MAX_EXTENT=2003750834e-2;class Di extends Xn{constructor(e=null,t=null,n=an.root,i=0,s=0,a=0){super(e,t,n,i,s,a,Di.geometry,new jt({wireframe:!1})),this.matrixAutoUpdate=!1,this.isMesh=!0,this.visible=!1}initialize(){const e=Object.create(null,{initialize:{get:()=>super.initialize}});return Mn(this,void 0,void 0,function*(){e.initialize.call(this),yield this.loadData(),this.nodeReady()})}createChildNodes(){const e=this.level+1,t=this.x*2,n=this.y*2,i=Object.getPrototypeOf(this).constructor;let s=new i(this,this.mapView,an.topLeft,e,t,n);s.scale.set(.5,1,.5),s.position.set(-.25,0,-.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0),s=new i(this,this.mapView,an.topRight,e,t+1,n),s.scale.set(.5,1,.5),s.position.set(.25,0,-.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0),s=new i(this,this.mapView,an.bottomLeft,e,t,n+1),s.scale.set(.5,1,.5),s.position.set(-.25,0,.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0),s=new i(this,this.mapView,an.bottomRight,e,t+1,n+1),s.scale.set(.5,1,.5),s.position.set(.25,0,.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0)}raycast(e,t){this.isMesh===!0&&super.raycast(e,t)}}Di.geometry=new Ts(1,1,1,1,!1);Di.baseGeometry=Di.geometry;Di.baseScale=new L(At.EARTH_PERIMETER,1,At.EARTH_PERIMETER);class gC extends mt{constructor(e=1,t=1,n=1,i=1,s=!1,a=10,o=null,l=!0){super();const c=[],d=[],h=[],u=[];Ts.buildPlane(e,t,n,i,c,d,h,u);const f=o.data;for(let m=0,v=0;m<f.length&&v<d.length;m+=4,v+=3){const g=f[m],b=f[m+1],y=f[m+2],w=(g*65536+b*256+y)*.1-1e4;d[v+1]=w}s&&Ts.buildSkirt(e,t,n,i,a,c,d,h,u),this.setIndex(c),this.setAttribute("position",new Fe(d,3)),this.setAttribute("normal",new Fe(h,3)),this.setAttribute("uv",new Fe(u,2)),l&&this.computeNormals(n,i)}computeNormals(e,t){const n=this.getAttribute("position");if(n!==void 0){let i=this.getAttribute("normal");const s=t*e;for(let v=0;v<s;v++)i.setXYZ(v,0,0,0);const a=new L,o=new L,l=new L,c=new L,d=new L,h=new L,u=new L,f=new L,m=t*e*6;for(let v=0;v<m;v+=3){const g=this.index.getX(v+0),b=this.index.getX(v+1),y=this.index.getX(v+2);a.fromBufferAttribute(n,g),o.fromBufferAttribute(n,b),l.fromBufferAttribute(n,y),u.subVectors(l,o),f.subVectors(a,o),u.cross(f),c.fromBufferAttribute(i,g),d.fromBufferAttribute(i,b),h.fromBufferAttribute(i,y),c.add(u),d.add(u),h.add(u),i.setXYZ(g,c.x,c.y,c.z),i.setXYZ(b,d.x,d.y,d.z),i.setXYZ(y,h.x,h.y,h.z)}this.normalizeNormals(),i.needsUpdate=!0}}}class qi extends Xn{constructor(e=null,t=null,n=an.root,i=0,s=0,a=0,o=qi.geometry,l=new Ri({wireframe:!1,color:16777215})){super(e,t,n,i,s,a,o,l),this.heightLoaded=!1,this.textureLoaded=!1,this.geometrySize=16,this.geometryNormals=!1,this.isMesh=!0,this.visible=!1,this.matrixAutoUpdate=!1}initialize(){const e=Object.create(null,{initialize:{get:()=>super.initialize}});return Mn(this,void 0,void 0,function*(){e.initialize.call(this),yield this.loadData(),yield this.loadHeightGeometry(),this.nodeReady()})}loadData(){const e=Object.create(null,{loadData:{get:()=>super.loadData}});return Mn(this,void 0,void 0,function*(){yield e.loadData.call(this),this.textureLoaded=!0})}loadHeightGeometry(){return Mn(this,void 0,void 0,function*(){if(this.mapView.heightProvider===null)throw new Error("GeoThree: MapView.heightProvider provider is null.");if(this.level<this.mapView.heightProvider.minZoom||this.level>this.mapView.heightProvider.maxZoom){console.warn("Geo-Three: Loading tile outside of provider range.",this),this.geometry=Di.baseGeometry;return}try{const e=yield this.mapView.heightProvider.fetchTile(this.level,this.x,this.y);if(this.disposed)return;const t=wf.createOffscreenCanvas(this.geometrySize+1,this.geometrySize+1),n=t.getContext("2d");n.imageSmoothingEnabled=!1,n.drawImage(e,0,0,qi.tileSize,qi.tileSize,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height);this.geometry=new gC(1,1,this.geometrySize,this.geometrySize,!0,10,i,!0)}catch{if(this.disposed)return;this.geometry=Di.baseGeometry}this.heightLoaded=!0})}createChildNodes(){const e=this.level+1,t=Object.getPrototypeOf(this).constructor,n=this.x*2,i=this.y*2;let s=new t(this,this.mapView,an.topLeft,e,n,i);s.scale.set(.5,1,.5),s.position.set(-.25,0,-.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0),s=new t(this,this.mapView,an.topRight,e,n+1,i),s.scale.set(.5,1,.5),s.position.set(.25,0,-.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0),s=new t(this,this.mapView,an.bottomLeft,e,n,i+1),s.scale.set(.5,1,.5),s.position.set(-.25,0,.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0),s=new t(this,this.mapView,an.bottomRight,e,n+1,i+1),s.scale.set(.5,1,.5),s.position.set(.25,0,.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0)}raycast(e,t){this.isMesh===!0&&super.raycast(e,t)}}qi.tileSize=256;qi.geometry=new Ts(1,1,1,1);qi.baseGeometry=Di.geometry;qi.baseScale=new L(At.EARTH_PERIMETER,1,At.EARTH_PERIMETER);class Mv extends mt{constructor(e,t,n,i,s,a,o){super();const l=a+o;let c=0;const d=[],h=new L,u=new L,f=[],m=[],v=[],g=[];for(let b=0;b<=n;b++){const y=[],w=b/n;for(let _=0;_<=t;_++){const R=_/t;h.x=-e*Math.cos(i+R*s)*Math.sin(a+w*o),h.y=e*Math.cos(a+w*o),h.z=e*Math.sin(i+R*s)*Math.sin(a+w*o),m.push(h.x,h.y,h.z),u.set(h.x,h.y,h.z).normalize(),v.push(u.x,u.y,u.z),g.push(R,1-w),y.push(c++)}d.push(y)}for(let b=0;b<n;b++)for(let y=0;y<t;y++){const w=d[b][y+1],_=d[b][y],R=d[b+1][y],T=d[b+1][y+1];(b!==0||a>0)&&f.push(w,_,T),(b!==n-1||l<Math.PI)&&f.push(_,R,T)}this.setIndex(f),this.setAttribute("position",new Fe(m,3)),this.setAttribute("normal",new Fe(v,3)),this.setAttribute("uv",new Fe(g,2))}}class Tr extends Xn{constructor(e=null,t=null,n=an.root,i=0,s=0,a=0){let o=At.tileBounds(i,s,a);const l=`
|
|
4414
|
+
***************************************************************************** */function Mn(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(d){try{c(n.next(d))}catch(h){a(h)}}function l(d){try{c(n.throw(d))}catch(h){a(h)}}function c(d){d.done?s(d.value):i(d.value).then(o,l)}c((n=n.apply(r,[])).next())})}class Oo{constructor(){this.name="",this.minZoom=0,this.maxZoom=20,this.bounds=[],this.center=[]}fetchTile(e,t,n){return null}getMetaData(){return Mn(this,void 0,void 0,function*(){})}}class fC extends Oo{constructor(e="https://a.tile.openstreetmap.org/"){super(),this.address=e,this.format="png",this.maxZoom=19}fetchTile(e,t,n){return new Promise((i,s)=>{const a=document.createElement("img");a.onload=function(){i(a)},a.onerror=function(){s()},a.crossOrigin="Anonymous",a.src=this.address+e+"/"+t+"/"+n+"."+this.format})}}class _f{static createOffscreenCanvas(e,t){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,t);{let n=document.createElement("canvas");return n.width=e,n.height=t,n}}}class wv{static createFillTexture(e="#000000",t=1,n=1){const i=_f.createOffscreenCanvas(t,n),s=i.getContext("2d");s.fillStyle=e,s.fillRect(0,0,t,n);const a=new Bt(i);return a.format=Zn,a.magFilter=bn,a.minFilter=bn,a.generateMipmaps=!1,a.needsUpdate=!0,a}}class an{}an.root=-1;an.topLeft=0;an.topRight=1;an.bottomLeft=2;an.bottomRight=3;class Xn extends Ae{constructor(e=null,t=null,n=an.root,i=0,s=0,a=0,o=null,l=null){super(o,l),this.mapView=null,this.parentNode=null,this.subdivided=!1,this.disposed=!1,this.nodesLoaded=0,this.childrenCache=null,this.isMesh=!0,this.mapView=t,this.parentNode=e,this.disposed=!1,this.location=n,this.level=i,this.x=s,this.y=a,this.initialize()}initialize(){return Mn(this,void 0,void 0,function*(){})}createChildNodes(){}subdivide(){const e=this.mapView.maxZoom();this.children.length>0||this.level+1>e||this.parentNode!==null&&this.parentNode.nodesLoaded<Xn.childrens||(this.mapView.cacheTiles&&this.childrenCache!==null?(this.isMesh=!1,this.children=this.childrenCache,this.nodesLoaded=this.childrenCache.length):this.createChildNodes(),this.subdivided=!0)}simplify(){const e=this.mapView.minZoom();if(!(this.level-1<e)){if(this.mapView.cacheTiles)this.childrenCache=this.children;else for(let t=0;t<this.children.length;t++)this.children[t].dispose();this.subdivided=!1,this.isMesh=!0,this.children=[],this.nodesLoaded=0}}loadData(){return Mn(this,void 0,void 0,function*(){if(this.level<this.mapView.provider.minZoom||this.level>this.mapView.provider.maxZoom){console.warn("Geo-Three: Loading tile outside of provider range.",this),this.material.map=Xn.defaultTexture,this.material.needsUpdate=!0;return}try{const e=yield this.mapView.provider.fetchTile(this.level,this.x,this.y);yield this.applyTexture(e)}catch{if(this.disposed)return;console.warn("Geo-Three: Failed to load node tile data.",this),this.material.map=Xn.defaultTexture}this.material.needsUpdate=!0})}applyTexture(e){return Mn(this,void 0,void 0,function*(){if(this.disposed)return;const t=new Bt(e);parseInt(vr)>=152&&(t.colorSpace="srgb"),t.generateMipmaps=!1,t.format=Zn,t.magFilter=bn,t.minFilter=bn,t.needsUpdate=!0,this.material.map=t})}nodeReady(){if(this.disposed){console.warn("Geo-Three: nodeReady() called for disposed node.",this),this.dispose();return}if(this.parentNode!==null){if(this.parentNode.nodesLoaded++,this.parentNode.nodesLoaded===Xn.childrens){this.parentNode.subdivided===!0&&(this.parentNode.isMesh=!1);for(let e=0;e<this.parentNode.children.length;e++)this.parentNode.children[e].visible=!0}this.parentNode.nodesLoaded>Xn.childrens&&console.error("Geo-Three: Loaded more children objects than expected.",this.parentNode.nodesLoaded,this)}else this.visible=!0}dispose(){this.disposed=!0;const e=this;try{const t=e.material;t.dispose(),t.map&&t.map!==Xn.defaultTexture&&t.map.dispose()}catch{}try{e.geometry.dispose()}catch{}}}Xn.defaultTexture=wv.createFillTexture();Xn.baseGeometry=null;Xn.baseScale=null;Xn.childrens=4;class Ts extends mt{constructor(e=1,t=1,n=1,i=1,s=!1,a=10){super();const o=[],l=[],c=[],d=[];Ts.buildPlane(e,t,n,i,o,l,c,d),s&&Ts.buildSkirt(e,t,n,i,a,o,l,c,d),this.setIndex(o),this.setAttribute("position",new Fe(l,3)),this.setAttribute("normal",new Fe(c,3)),this.setAttribute("uv",new Fe(d,2))}static buildPlane(e=1,t=1,n=1,i=1,s,a,o,l){const c=e/2,d=t/2,h=n+1,u=i+1,f=e/n,m=t/i;for(let v=0;v<u;v++){const g=v*m-d;for(let b=0;b<h;b++){const y=b*f-c;a.push(y,0,g),o.push(0,1,0),l.push(b/n,1-v/i)}}for(let v=0;v<i;v++)for(let g=0;g<n;g++){const b=g+h*v,y=g+h*(v+1),w=g+1+h*(v+1),_=g+1+h*v;s.push(b,y,_,y,w,_)}}static buildSkirt(e=1,t=1,n=1,i=1,s,a,o,l,c){const d=e/2,h=t/2,u=n+1,f=i+1,m=e/n,v=t/i;let g=o.length/3;for(let y=0;y<u;y++){const w=y*m-d,_=-h;o.push(w,-s,_),l.push(0,1,0),c.push(y/n,1)}for(let y=0;y<n;y++){const w=y,_=y+1,R=y+g,T=y+g+1;a.push(_,R,w,_,T,R)}g=o.length/3;for(let y=0;y<u;y++){const w=y*m-d,_=i*v-h;o.push(w,-s,_),l.push(0,1,0),c.push(y/n,0)}let b=u*f-n-1;for(let y=0;y<n;y++){const w=b+y,_=b+y+1,R=y+g,T=y+g+1;a.push(w,R,_,R,T,_)}g=o.length/3;for(let y=0;y<f;y++){const w=y*v-h,_=-d;o.push(_,-s,w),l.push(0,1,0),c.push(0,1-y/i)}for(let y=0;y<i;y++){const w=y*f,_=(y+1)*f,R=y+g,T=y+g+1;a.push(w,R,_,R,T,_)}g=o.length/3;for(let y=0;y<f;y++){const w=y*v-h,_=n*m-d;o.push(_,-s,w),l.push(0,1,0),c.push(1,1-y/i)}for(let y=0;y<i;y++){const w=y*f+i,_=(y+1)*f+i,R=y+g,T=y+g+1;a.push(_,R,w,_,T,R)}}}class Zd{constructor(e,t){this.latitude=e,this.longitude=t}}class At{static datumsToSpherical(e,t){const n=t*At.EARTH_ORIGIN/180;let i=Math.log(Math.tan((90+e)*Math.PI/360))/(Math.PI/180);return i=i*At.EARTH_ORIGIN/180,new ge(n,i)}static sphericalToDatums(e,t){const n=e/At.EARTH_ORIGIN*180;let i=t/At.EARTH_ORIGIN*180;return i=180/Math.PI*(2*Math.atan(Math.exp(i*Math.PI/180))-Math.PI/2),new Zd(i,n)}static quadtreeToDatums(e,t,n){const i=Math.pow(2,e),s=t/i*360-180,o=180*(Math.atan(Math.sinh(Math.PI*(1-2*n/i)))/Math.PI);return new Zd(o,s)}static vectorToDatums(e){const t=180/Math.PI,n=Math.atan2(e.y,Math.sqrt(Math.pow(e.x,2)+Math.pow(-e.z,2)))*t,i=Math.atan2(-e.z,e.x)*t;return new Zd(n,i)}static datumsToVector(e,t){const n=Math.PI/180,i=t*n,s=e*n;var a=Math.cos(s);return new L(-Math.cos(i+Math.PI)*a,Math.sin(s),Math.sin(i+Math.PI)*a)}static mapboxAltitude(e){return(e.r*255*65536+e.g*255*256+e.b*255)*.1-1e4}static getTileSize(e){const t=At.WEB_MERCATOR_MAX_EXTENT,n=Math.pow(2,e);return 2*t/n}static tileBounds(e,t,n){const i=At.getTileSize(e),s=-At.WEB_MERCATOR_MAX_EXTENT+t*i,a=At.WEB_MERCATOR_MAX_EXTENT-(n+1)*i;return[s,i,a,i]}static webMercatorToLatitude(e,t){const n=At.WEB_MERCATOR_MAX_EXTENT-t*At.getTileSize(e);return Math.atan(Math.sinh(n/At.EARTH_RADIUS))}static webMercatorToLongitude(e,t){return(-At.WEB_MERCATOR_MAX_EXTENT+t*At.getTileSize(e))/At.EARTH_RADIUS}}At.EARTH_RADIUS=6371008;At.EARTH_RADIUS_A=6378137;At.EARTH_RADIUS_B=6356752314245e-6;At.EARTH_PERIMETER=2*Math.PI*At.EARTH_RADIUS;At.EARTH_ORIGIN=At.EARTH_PERIMETER/2;At.WEB_MERCATOR_MAX_EXTENT=2003750834e-2;class Di extends Xn{constructor(e=null,t=null,n=an.root,i=0,s=0,a=0){super(e,t,n,i,s,a,Di.geometry,new jt({wireframe:!1})),this.matrixAutoUpdate=!1,this.isMesh=!0,this.visible=!1}initialize(){const e=Object.create(null,{initialize:{get:()=>super.initialize}});return Mn(this,void 0,void 0,function*(){e.initialize.call(this),yield this.loadData(),this.nodeReady()})}createChildNodes(){const e=this.level+1,t=this.x*2,n=this.y*2,i=Object.getPrototypeOf(this).constructor;let s=new i(this,this.mapView,an.topLeft,e,t,n);s.scale.set(.5,1,.5),s.position.set(-.25,0,-.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0),s=new i(this,this.mapView,an.topRight,e,t+1,n),s.scale.set(.5,1,.5),s.position.set(.25,0,-.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0),s=new i(this,this.mapView,an.bottomLeft,e,t,n+1),s.scale.set(.5,1,.5),s.position.set(-.25,0,.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0),s=new i(this,this.mapView,an.bottomRight,e,t+1,n+1),s.scale.set(.5,1,.5),s.position.set(.25,0,.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0)}raycast(e,t){this.isMesh===!0&&super.raycast(e,t)}}Di.geometry=new Ts(1,1,1,1,!1);Di.baseGeometry=Di.geometry;Di.baseScale=new L(At.EARTH_PERIMETER,1,At.EARTH_PERIMETER);class pC extends mt{constructor(e=1,t=1,n=1,i=1,s=!1,a=10,o=null,l=!0){super();const c=[],d=[],h=[],u=[];Ts.buildPlane(e,t,n,i,c,d,h,u);const f=o.data;for(let m=0,v=0;m<f.length&&v<d.length;m+=4,v+=3){const g=f[m],b=f[m+1],y=f[m+2],w=(g*65536+b*256+y)*.1-1e4;d[v+1]=w}s&&Ts.buildSkirt(e,t,n,i,a,c,d,h,u),this.setIndex(c),this.setAttribute("position",new Fe(d,3)),this.setAttribute("normal",new Fe(h,3)),this.setAttribute("uv",new Fe(u,2)),l&&this.computeNormals(n,i)}computeNormals(e,t){const n=this.getAttribute("position");if(n!==void 0){let i=this.getAttribute("normal");const s=t*e;for(let v=0;v<s;v++)i.setXYZ(v,0,0,0);const a=new L,o=new L,l=new L,c=new L,d=new L,h=new L,u=new L,f=new L,m=t*e*6;for(let v=0;v<m;v+=3){const g=this.index.getX(v+0),b=this.index.getX(v+1),y=this.index.getX(v+2);a.fromBufferAttribute(n,g),o.fromBufferAttribute(n,b),l.fromBufferAttribute(n,y),u.subVectors(l,o),f.subVectors(a,o),u.cross(f),c.fromBufferAttribute(i,g),d.fromBufferAttribute(i,b),h.fromBufferAttribute(i,y),c.add(u),d.add(u),h.add(u),i.setXYZ(g,c.x,c.y,c.z),i.setXYZ(b,d.x,d.y,d.z),i.setXYZ(y,h.x,h.y,h.z)}this.normalizeNormals(),i.needsUpdate=!0}}}class qi extends Xn{constructor(e=null,t=null,n=an.root,i=0,s=0,a=0,o=qi.geometry,l=new Ri({wireframe:!1,color:16777215})){super(e,t,n,i,s,a,o,l),this.heightLoaded=!1,this.textureLoaded=!1,this.geometrySize=16,this.geometryNormals=!1,this.isMesh=!0,this.visible=!1,this.matrixAutoUpdate=!1}initialize(){const e=Object.create(null,{initialize:{get:()=>super.initialize}});return Mn(this,void 0,void 0,function*(){e.initialize.call(this),yield this.loadData(),yield this.loadHeightGeometry(),this.nodeReady()})}loadData(){const e=Object.create(null,{loadData:{get:()=>super.loadData}});return Mn(this,void 0,void 0,function*(){yield e.loadData.call(this),this.textureLoaded=!0})}loadHeightGeometry(){return Mn(this,void 0,void 0,function*(){if(this.mapView.heightProvider===null)throw new Error("GeoThree: MapView.heightProvider provider is null.");if(this.level<this.mapView.heightProvider.minZoom||this.level>this.mapView.heightProvider.maxZoom){console.warn("Geo-Three: Loading tile outside of provider range.",this),this.geometry=Di.baseGeometry;return}try{const e=yield this.mapView.heightProvider.fetchTile(this.level,this.x,this.y);if(this.disposed)return;const t=_f.createOffscreenCanvas(this.geometrySize+1,this.geometrySize+1),n=t.getContext("2d");n.imageSmoothingEnabled=!1,n.drawImage(e,0,0,qi.tileSize,qi.tileSize,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height);this.geometry=new pC(1,1,this.geometrySize,this.geometrySize,!0,10,i,!0)}catch{if(this.disposed)return;this.geometry=Di.baseGeometry}this.heightLoaded=!0})}createChildNodes(){const e=this.level+1,t=Object.getPrototypeOf(this).constructor,n=this.x*2,i=this.y*2;let s=new t(this,this.mapView,an.topLeft,e,n,i);s.scale.set(.5,1,.5),s.position.set(-.25,0,-.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0),s=new t(this,this.mapView,an.topRight,e,n+1,i),s.scale.set(.5,1,.5),s.position.set(.25,0,-.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0),s=new t(this,this.mapView,an.bottomLeft,e,n,i+1),s.scale.set(.5,1,.5),s.position.set(-.25,0,.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0),s=new t(this,this.mapView,an.bottomRight,e,n+1,i+1),s.scale.set(.5,1,.5),s.position.set(.25,0,.25),this.add(s),s.updateMatrix(),s.updateMatrixWorld(!0)}raycast(e,t){this.isMesh===!0&&super.raycast(e,t)}}qi.tileSize=256;qi.geometry=new Ts(1,1,1,1);qi.baseGeometry=Di.geometry;qi.baseScale=new L(At.EARTH_PERIMETER,1,At.EARTH_PERIMETER);class Sv extends mt{constructor(e,t,n,i,s,a,o){super();const l=a+o;let c=0;const d=[],h=new L,u=new L,f=[],m=[],v=[],g=[];for(let b=0;b<=n;b++){const y=[],w=b/n;for(let _=0;_<=t;_++){const R=_/t;h.x=-e*Math.cos(i+R*s)*Math.sin(a+w*o),h.y=e*Math.cos(a+w*o),h.z=e*Math.sin(i+R*s)*Math.sin(a+w*o),m.push(h.x,h.y,h.z),u.set(h.x,h.y,h.z).normalize(),v.push(u.x,u.y,u.z),g.push(R,1-w),y.push(c++)}d.push(y)}for(let b=0;b<n;b++)for(let y=0;y<t;y++){const w=d[b][y+1],_=d[b][y],R=d[b+1][y],T=d[b+1][y+1];(b!==0||a>0)&&f.push(w,_,T),(b!==n-1||l<Math.PI)&&f.push(_,R,T)}this.setIndex(f),this.setAttribute("position",new Fe(m,3)),this.setAttribute("normal",new Fe(v,3)),this.setAttribute("uv",new Fe(g,2))}}class Tr extends Xn{constructor(e=null,t=null,n=an.root,i=0,s=0,a=0){let o=At.tileBounds(i,s,a);const l=`
|
|
4637
4415
|
varying vec3 vPosition;
|
|
4638
4416
|
|
|
4639
4417
|
void main() {
|
|
@@ -4665,7 +4443,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
4665
4443
|
#include ${parseInt(vr)>=154?"<colorspace_fragment>":"<encodings_fragment>"}
|
|
4666
4444
|
`}
|
|
4667
4445
|
}
|
|
4668
|
-
`;let d=new _t(...o);const h=new wn({uniforms:{uTexture:{value:new Bt},webMercatorBounds:{value:d}},vertexShader:l,fragmentShader:c});super(e,t,n,i,s,a,Tr.createGeometry(i,s,a),h),this.applyScaleNode(),this.matrixAutoUpdate=!1,this.isMesh=!0,this.visible=!1}initialize(){const e=Object.create(null,{initialize:{get:()=>super.initialize}});return Mn(this,void 0,void 0,function*(){e.initialize.call(this),yield this.loadData(),this.nodeReady()})}static createGeometry(e,t,n){const i=Math.pow(2,e),s=40,a=Math.floor(Tr.segments*(s/(e+1))/s),o=t>0?At.webMercatorToLongitude(e,t)+Math.PI:0,l=t<i-1?At.webMercatorToLongitude(e,t+1)+Math.PI:2*Math.PI,c=o,d=l-o,h=n>0?At.webMercatorToLatitude(e,n):Math.PI/2,u=n<i-1?At.webMercatorToLatitude(e,n+1):-Math.PI/2,f=h-u,m=Math.PI-(h+Math.PI/2);return new
|
|
4446
|
+
`;let d=new _t(...o);const h=new wn({uniforms:{uTexture:{value:new Bt},webMercatorBounds:{value:d}},vertexShader:l,fragmentShader:c});super(e,t,n,i,s,a,Tr.createGeometry(i,s,a),h),this.applyScaleNode(),this.matrixAutoUpdate=!1,this.isMesh=!0,this.visible=!1}initialize(){const e=Object.create(null,{initialize:{get:()=>super.initialize}});return Mn(this,void 0,void 0,function*(){e.initialize.call(this),yield this.loadData(),this.nodeReady()})}static createGeometry(e,t,n){const i=Math.pow(2,e),s=40,a=Math.floor(Tr.segments*(s/(e+1))/s),o=t>0?At.webMercatorToLongitude(e,t)+Math.PI:0,l=t<i-1?At.webMercatorToLongitude(e,t+1)+Math.PI:2*Math.PI,c=o,d=l-o,h=n>0?At.webMercatorToLatitude(e,n):Math.PI/2,u=n<i-1?At.webMercatorToLatitude(e,n+1):-Math.PI/2,f=h-u,m=Math.PI-(h+Math.PI/2);return new Sv(1,a,a,c,d,m,f)}applyTexture(e){return Mn(this,void 0,void 0,function*(){const n=new No().load(e.src,function(){parseInt(vr)>=152&&(n.colorSpace="srgb")});this.material.uniforms.uTexture.value=n,this.material.uniforms.uTexture.needsUpdate=!0})}applyScaleNode(){this.geometry.computeBoundingBox();const t=this.geometry.boundingBox.clone().getCenter(new L),n=new ke;n.compose(new L(-t.x,-t.y,-t.z),new Dt,new L(At.EARTH_RADIUS,At.EARTH_RADIUS,At.EARTH_RADIUS)),this.geometry.applyMatrix4(n),this.position.copy(t),this.updateMatrix(),this.updateMatrixWorld()}updateMatrix(){this.matrix.setPosition(this.position),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e=!1){(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1)}createChildNodes(){const e=this.level+1,t=this.x*2,n=this.y*2,i=Object.getPrototypeOf(this).constructor;let s=new i(this,this.mapView,an.topLeft,e,t,n);this.add(s),s=new i(this,this.mapView,an.topRight,e,t+1,n),this.add(s),s=new i(this,this.mapView,an.bottomLeft,e,t,n+1),this.add(s),s=new i(this,this.mapView,an.bottomRight,e,t+1,n+1),this.add(s)}raycast(e,t){this.isMesh===!0&&super.raycast(e,t)}}Tr.baseGeometry=new Sv(At.EARTH_RADIUS,64,64,0,2*Math.PI,0,Math.PI);Tr.baseScale=new L(1,1,1);Tr.segments=80;class jn extends qi{constructor(e=null,t=null,n=an.root,i=0,s=0,a=0){const o=jn.prepareMaterial(new Ri({map:Xn.defaultTexture,color:16777215}));super(e,t,n,i,s,a,jn.geometry,o),this.frustumCulled=!1}static prepareMaterial(e){return e.userData={heightMap:{value:jn.defaultHeightTexture}},e.onBeforeCompile=t=>{for(const n in e.userData)t.uniforms[n]=e.userData[n];t.vertexShader=`
|
|
4669
4447
|
uniform sampler2D heightMap;
|
|
4670
4448
|
`+t.vertexShader,t.vertexShader=t.vertexShader.replace("#include <fog_vertex>",`
|
|
4671
4449
|
#include <fog_vertex>
|
|
@@ -4677,7 +4455,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
4677
4455
|
|
|
4678
4456
|
// Vertex position based on height
|
|
4679
4457
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(_transformed, 1.0);
|
|
4680
|
-
`)},e}loadData(){const e=Object.create(null,{loadData:{get:()=>super.loadData}});return Mn(this,void 0,void 0,function*(){yield e.loadData.call(this),this.textureLoaded=!0})}loadHeightGeometry(){return Mn(this,void 0,void 0,function*(){if(this.mapView.heightProvider===null)throw new Error("GeoThree: MapView.heightProvider provider is null.");if(this.level<this.mapView.heightProvider.minZoom||this.level>this.mapView.heightProvider.maxZoom){console.warn("Geo-Three: Loading tile outside of provider range.",this),this.material.map=jn.defaultTexture,this.material.needsUpdate=!0;return}try{const e=yield this.mapView.heightProvider.fetchTile(this.level,this.x,this.y);if(this.disposed)return;const t=new Bt(e);t.generateMipmaps=!1,t.format=Zn,t.magFilter=Sn,t.minFilter=Sn,t.needsUpdate=!0,this.material.userData.heightMap.value=t}catch{if(this.disposed)return;console.error("Geo-Three: Failed to load node tile height data.",this),this.material.userData.heightMap.value=jn.defaultHeightTexture}this.material.needsUpdate=!0,this.heightLoaded=!0})}raycast(e,t){this.isMesh===!0&&(this.geometry=Di.geometry,super.raycast(e,t),this.geometry=jn.geometry)}dispose(){super.dispose(),this.material.userData.heightMap.value&&this.material.userData.heightMap.value!==jn.defaultHeightTexture&&this.material.userData.heightMap.value.dispose()}}jn.defaultHeightTexture=
|
|
4458
|
+
`)},e}loadData(){const e=Object.create(null,{loadData:{get:()=>super.loadData}});return Mn(this,void 0,void 0,function*(){yield e.loadData.call(this),this.textureLoaded=!0})}loadHeightGeometry(){return Mn(this,void 0,void 0,function*(){if(this.mapView.heightProvider===null)throw new Error("GeoThree: MapView.heightProvider provider is null.");if(this.level<this.mapView.heightProvider.minZoom||this.level>this.mapView.heightProvider.maxZoom){console.warn("Geo-Three: Loading tile outside of provider range.",this),this.material.map=jn.defaultTexture,this.material.needsUpdate=!0;return}try{const e=yield this.mapView.heightProvider.fetchTile(this.level,this.x,this.y);if(this.disposed)return;const t=new Bt(e);t.generateMipmaps=!1,t.format=Zn,t.magFilter=Sn,t.minFilter=Sn,t.needsUpdate=!0,this.material.userData.heightMap.value=t}catch{if(this.disposed)return;console.error("Geo-Three: Failed to load node tile height data.",this),this.material.userData.heightMap.value=jn.defaultHeightTexture}this.material.needsUpdate=!0,this.heightLoaded=!0})}raycast(e,t){this.isMesh===!0&&(this.geometry=Di.geometry,super.raycast(e,t),this.geometry=jn.geometry)}dispose(){super.dispose(),this.material.userData.heightMap.value&&this.material.userData.heightMap.value!==jn.defaultHeightTexture&&this.material.userData.heightMap.value.dispose()}}jn.defaultHeightTexture=wv.createFillTexture("#0186C0");jn.geometrySize=256;jn.geometry=new Ts(1,1,jn.geometrySize,jn.geometrySize,!0);jn.baseGeometry=Di.geometry;jn.baseScale=new L(At.EARTH_PERIMETER,1,At.EARTH_PERIMETER);class mC{constructor(){this.subdivisionRays=1,this.thresholdUp=.6,this.thresholdDown=.15,this.raycaster=new of,this.mouse=new ge,this.powerDistance=!1,this.scaleDistance=!0}updateLOD(e,t,n,i){const s=[];for(let a=0;a<this.subdivisionRays;a++){this.mouse.set(Math.random()*2-1,Math.random()*2-1),this.raycaster.setFromCamera(this.mouse,t);let o=[];this.raycaster.intersectObjects(e.children,!0,o),o.length>0&&s.push(o[0])}for(let a=0;a<s.length;a++){const o=s[a].object;let l=s[a].distance;if(this.powerDistance&&(l=Math.pow(l*2,o.level)),this.scaleDistance){const c=o.matrixWorld.elements;l=new L(c[0],c[1],c[2]).length()/l}l>this.thresholdUp?o.subdivide():l<this.thresholdDown&&o.parentNode&&o.parentNode.simplify()}}}class gC{constructor(e=257){this.gridSize=e;const t=e-1;if(t&t-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=t*t*2-2,this.numParentTriangles=this.numTriangles-t*t,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let n=0;n<this.numTriangles;n++){let i=n+2,s=0,a=0,o=0,l=0,c=0,d=0;for(i&1?o=l=c=t:s=a=d=t;(i>>=1)>1;){const u=s+o>>1,f=a+l>>1;i&1?(o=s,l=a,s=c,a=d):(s=o,a=l,o=c,l=d),c=u,d=f}const h=n*4;this.coords[h+0]=s,this.coords[h+1]=a,this.coords[h+2]=o,this.coords[h+3]=l}}createTile(e){return new bC(e,this)}}class bC{constructor(e,t){const n=t.gridSize;if(e.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${e.length}.`);this.terrain=e,this.martini=t,this.errors=new Float32Array(e.length),this.update()}update(){const{numTriangles:e,numParentTriangles:t,coords:n,gridSize:i}=this.martini,{terrain:s,errors:a}=this;for(let o=e-1;o>=0;o--){const l=o*4,c=n[l+0],d=n[l+1],h=n[l+2],u=n[l+3],f=c+h>>1,m=d+u>>1,v=f+m-d,g=m+c-f,b=(s[d*i+c]+s[u*i+h])/2,y=m*i+f,w=Math.abs(b-s[y]);if(a[y]=Math.max(a[y],w),o<t){const _=(d+g>>1)*i+(c+v>>1),R=(u+g>>1)*i+(h+v>>1);a[y]=Math.max(a[y],a[_],a[R])}}}getMesh(e=0,t=!1){const{gridSize:n,indices:i}=this.martini,{errors:s}=this;let a=0,o=0;const l=n-1;let c,d,h=0;const u=[],f=[],m=[],v=[];i.fill(0);function g(P,M,x,S,C,k){const I=P+x>>1,G=M+S>>1;Math.abs(P-C)+Math.abs(M-k)>1&&s[G*n+I]>e?(g(C,k,P,M,I,G),g(x,S,C,k,I,G)):(c=M*n+P,d=S*n+x,h=k*n+C,i[c]===0&&(t&&(P===0?u.push(a):P===l&&f.push(a),M===0?m.push(a):M===l&&v.push(a)),i[c]=++a),i[d]===0&&(t&&(x===0?u.push(a):x===l&&f.push(a),S===0?m.push(a):S===l&&v.push(a)),i[d]=++a),i[h]===0&&(t&&(C===0?u.push(a):C===l&&f.push(a),k===0?m.push(a):k===l&&v.push(a)),i[h]=++a),o++)}g(0,0,l,l,l,0),g(l,l,0,0,0,l);let b=a*2,y=o*3;t&&(b+=(u.length+f.length+m.length+v.length)*2,y+=((u.length-1)*2+(f.length-1)*2+(m.length-1)*2+(v.length-1)*2)*3);const w=new Uint16Array(b),_=new Uint32Array(y);let R=0;function T(P,M,x,S,C,k){const I=P+x>>1,G=M+S>>1;if(Math.abs(P-C)+Math.abs(M-k)>1&&s[G*n+I]>e)T(C,k,P,M,I,G),T(x,S,C,k,I,G);else{const q=i[M*n+P]-1,O=i[S*n+x]-1,W=i[k*n+C]-1;w[2*q]=P,w[2*q+1]=M,w[2*O]=x,w[2*O+1]=S,w[2*W]=C,w[2*W+1]=k,_[R++]=q,_[R++]=O,_[R++]=W}}if(T(0,0,l,l,l,0),T(l,l,0,0,0,l),t){let M=function(x){const S=x.length;for(let C=0;C<S-1;C++){const k=x[C],I=x[C+1],G=P/2,q=(P+2)/2;w[P++]=w[2*k],w[P++]=w[2*k+1],_[R++]=k,_[R++]=G,_[R++]=I,_[R++]=G,_[R++]=q,_[R++]=I}w[P++]=w[2*x[S-1]],w[P++]=w[2*x[S-1]+1]};u.sort((x,S)=>w[2*x+1]-w[2*S+1]),f.sort((x,S)=>w[2*S+1]-w[2*x+1]),m.sort((x,S)=>w[2*S]-w[2*x]),v.sort((x,S)=>w[2*x]-w[2*S]);let P=a*2;M(u),M(f),M(m),M(v)}return{vertices:w,triangles:_,numVerticesWithoutSkirts:a}}}class Ai extends qi{constructor(e=null,t=null,n=an.root,i=0,s=0,a=0,{elevationDecoder:o=null,meshMaxError:l=10,exageration:c=1}={}){super(e,t,n,i,s,a,Ai.geometry,Ai.prepareMaterial(new Ri({map:Ai.emptyTexture,color:16777215,side:sn}),i,c)),this.elevationDecoder={rScaler:256,gScaler:1,bScaler:1/256,offset:-32768},this.exageration=1,this.meshMaxError=10,o&&(this.elevationDecoder=o),this.meshMaxError=l,this.exageration=c,this.frustumCulled=!1}static prepareMaterial(e,t,n=1){return e.userData={heightMap:{value:Ai.emptyTexture},drawNormals:{value:0},drawBlack:{value:0},zoomlevel:{value:t},computeNormals:{value:1},drawTexture:{value:1}},e.onBeforeCompile=i=>{for(let s in e.userData)i.uniforms[s]=e.userData[s];i.vertexShader=`
|
|
4681
4459
|
uniform bool computeNormals;
|
|
4682
4460
|
uniform float zoomlevel;
|
|
4683
4461
|
uniform sampler2D heightMap;
|
|
@@ -4734,7 +4512,229 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
4734
4512
|
v2.z = (e+ h + i + f) / 4.0;
|
|
4735
4513
|
vNormal = (normalize(cross(v2 - v0, v1 - v0))).rbg;
|
|
4736
4514
|
}
|
|
4737
|
-
`)},e}static getTerrain(e,t,n){const{rScaler:i,bScaler:s,gScaler:a,offset:o}=n,l=t+1,c=new Float32Array(l*l);for(let d=0,h=0;h<t;h++)for(let u=0;u<t;u++,d++){const f=d*4,m=e[f+0],v=e[f+1],g=e[f+2];c[d+h]=m*i+v*a+g*s+o}for(let d=l*(l-1),h=0;h<l-1;h++,d++)c[d]=c[d-l];for(let d=l-1,h=0;h<l;h++,d+=l)c[d]=c[d-1];return c}static getMeshAttributes(e,t,n,i,s){const a=n+1,o=e.length/2,l=new Float32Array(o*3),c=new Float32Array(o*2),[d,h,u,f]=i||[0,0,n,n],m=(u-d)/n,v=(f-h)/n;for(let g=0;g<o;g++){const b=e[g*2],y=e[g*2+1],w=y*a+b;l[3*g+0]=b*m+d,l[3*g+1]=-t[w]*s,l[3*g+2]=-y*v+f,c[2*g+0]=b/n,c[2*g+1]=y/n}return{position:{value:l,size:3},uv:{value:c,size:2}}}processHeight(e){return Mn(this,void 0,void 0,function*(){const t=e.width,n=t+1;var i=wf.createOffscreenCanvas(t,t),s=i.getContext("2d");s.imageSmoothingEnabled=!1,s.drawImage(e,0,0,t,t,0,0,i.width,i.height);var a=s.getImageData(0,0,i.width,i.height),o=a.data;const l=Ai.getTerrain(o,t,this.elevationDecoder),d=new vC(n).createTile(l),{vertices:h,triangles:u}=d.getMesh(typeof this.meshMaxError=="function"?this.meshMaxError(this.level):this.meshMaxError),f=Ai.getMeshAttributes(h,l,t,[-.5,-.5,.5,.5],this.exageration);this.geometry=new mt,this.geometry.setIndex(new ju(u,1)),this.geometry.setAttribute("position",new Fe(f.position.value,f.position.size)),this.geometry.setAttribute("uv",new Fe(f.uv.value,f.uv.size)),this.geometry.rotateX(Math.PI);var m=new Bt(e);m.generateMipmaps=!1,m.format=Zn,m.magFilter=Sn,m.minFilter=Sn,m.needsUpdate=!0,this.material.userData.heightMap.value=m,this.material.map=m,this.material.needsUpdate=!0})}loadHeightGeometry(){return Mn(this,void 0,void 0,function*(){if(this.mapView.heightProvider===null)throw new Error("GeoThree: MapView.heightProvider provider is null.");const e=yield this.mapView.heightProvider.fetchTile(this.level,this.x,this.y);this.disposed||(this.processHeight(e),this.heightLoaded=!0,this.nodeReady())})}}Ai.geometrySize=16;Ai.emptyTexture=new Bt;Ai.geometry=new Ts(1,1,1,1);Ai.tileSize=256;class Fn extends Ae{constructor(e=Fn.PLANAR,t=new mC,n=null){super(void 0,new jt({transparent:!0,opacity:0,depthWrite:!1,colorWrite:!1})),this.lod=null,this.provider=null,this.heightProvider=null,this.root=null,this.cacheTiles=!1,this.onBeforeRender=(i,s,a,o,l,c)=>{this.lod.updateLOD(this,a,i,s)},this.lod=new bC,this.provider=t,this.heightProvider=n,this.setRoot(e),this.preSubdivide()}setRoot(e){if(typeof e=="number"){if(!Fn.mapModes.has(e))throw new Error("Map mode "+e+" does is not registered.");const t=Fn.mapModes.get(e);e=new t(null,this)}this.root!==null&&(this.remove(this.root),this.root=null),this.root=e,this.root!==null&&(this.geometry=this.root.constructor.baseGeometry,this.scale.copy(this.root.constructor.baseScale),this.root.mapView=this,this.add(this.root),this.root.initialize())}preSubdivide(){var e,t;function n(s,a){if(!(a<=0)){s.subdivide();for(let o=0;o<s.children.length;o++)if(s.children[o]instanceof Xn){const l=s.children[o];n(l,a-1)}}}const i=Math.max(this.provider.minZoom,(t=(e=this.heightProvider)===null||e===void 0?void 0:e.minZoom)!==null&&t!==void 0?t:-1/0);i>0&&n(this.root,i)}setProvider(e){e!==this.provider&&(this.provider=e,this.clear())}setHeightProvider(e){e!==this.heightProvider&&(this.heightProvider=e,this.clear())}clear(){return this.traverse(function(e){e.childrenCache&&(e.childrenCache=null),e.initialize&&e.initialize()}),this}minZoom(){var e,t;return Math.max(this.provider.minZoom,(t=(e=this.heightProvider)===null||e===void 0?void 0:e.minZoom)!==null&&t!==void 0?t:-1/0)}maxZoom(){var e,t;return Math.min(this.provider.maxZoom,(t=(e=this.heightProvider)===null||e===void 0?void 0:e.maxZoom)!==null&&t!==void 0?t:1/0)}getMetaData(){this.provider.getMetaData()}raycast(e,t){return!1}}Fn.PLANAR=200;Fn.SPHERICAL=201;Fn.HEIGHT=202;Fn.HEIGHT_SHADER=203;Fn.MARTINI=204;Fn.mapModes=new Map([[Fn.PLANAR,Di],[Fn.SPHERICAL,Tr],[Fn.HEIGHT,qi],[Fn.HEIGHT_SHADER,jn],[Fn.MARTINI,Ai]]);new L;new L;new ke;new L;new Cc;new L;class Ev{static get(e){return Mn(this,void 0,void 0,function*(){return new Promise(function(t,n){const i=new XMLHttpRequest;i.overrideMimeType("text/plain"),i.open("GET",e,!0),i.onload=function(){t(i.response)},i.onerror=n,i.send(null)})})}static getRaw(e){return Mn(this,void 0,void 0,function*(){return new Promise(function(t,n){var i=new XMLHttpRequest;i.responseType="arraybuffer",i.open("GET",e,!0),i.onload=function(){t(i.response)},i.onerror=n,i.send(null)})})}static request(e,t,n,i,s,a,o){function l(d){try{return JSON.parse(d)}catch{return d}}const c=new XMLHttpRequest;if(c.overrideMimeType("text/plain"),c.open(t,e,!0),n!=null)for(const d in n)c.setRequestHeader(d,n[d]);return s!==void 0&&(c.onload=function(d){s(l(c.response),c)}),a!==void 0&&(c.onerror=a),o!==void 0&&(c.onprogress=o),c.send(i!==void 0?i:null),c}}class ns extends Oo{constructor(e="",t=ns.AERIAL){super(),this.maxZoom=19,this.minZoom=1,this.format="jpeg",this.mapSize=512,this.subdomain="t1",this.meta=null,this.apiKey=e,this.type=t}getMetaData(){return Mn(this,void 0,void 0,function*(){const e=ns.ADDRESS+"/REST/V1/Imagery/Metadata/RoadOnDemand?output=json&include=ImageryProviders&key="+this.apiKey,t=yield Ev.get(e);this.meta=JSON.parse(t)})}static quadKey(e,t,n){let i="";for(let s=e;s>0;s--){const a=1<<s-1;let o=0;(t&a)!==0&&o++,(n&a)!==0&&(o+=2),i+=o}return i}fetchTile(e,t,n){return new Promise((i,s)=>{const a=document.createElement("img");a.onload=function(){i(a)},a.onerror=function(){s()},a.crossOrigin="Anonymous",a.src="http://ecn."+this.subdomain+".tiles.virtualearth.net/tiles/"+this.type+ns.quadKey(e,t,n)+".jpeg?g=1173"})}}ns.ADDRESS="https://dev.virtualearth.net";ns.AERIAL="a";ns.ROAD="r";ns.AERIAL_LABELS="h";ns.OBLIQUE="o";ns.OBLIQUE_LABELS="b";class xC extends Oo{constructor(e="",t="",n="base",i="normal.day",s="png",a=512){super(),this.appId=e,this.appCode=t,this.style=n,this.scheme=i,this.format=s,this.size=a,this.version="newest",this.server=1}nextServer(){this.server=this.server%4===0?1:this.server+1}getMetaData(){return Mn(this,void 0,void 0,function*(){})}fetchTile(e,t,n){return this.nextServer(),new Promise((i,s)=>{const a=document.createElement("img");a.onload=function(){i(a)},a.onerror=function(){s()},a.crossOrigin="Anonymous",a.src="https://"+this.server+"."+this.style+".maps.api.here.com/maptile/2.1/maptile/"+this.version+"/"+this.scheme+"/"+e+"/"+t+"/"+n+"/"+this.size+"/"+this.format+"?app_id="+this.appId+"&app_code="+this.appCode})}}xC.PATH="/maptile/2.1/";class vs extends Oo{constructor(e="",t="",n=vs.STYLE,i="png",s=!1,a="v4"){super(),this.apiToken=e,this.format=i,this.useHDPI=s,this.mode=n,this.mapId=t,this.style=t,this.version=a}getMetaData(){return Mn(this,void 0,void 0,function*(){const e=vs.ADDRESS+this.version+"/"+this.mapId+".json?access_token="+this.apiToken,t=yield Ev.get(e),n=JSON.parse(t);this.name=n.name,this.minZoom=n.minZoom,this.maxZoom=n.maxZoom,this.bounds=n.bounds,this.center=n.center})}fetchTile(e,t,n){return new Promise((i,s)=>{const a=document.createElement("img");a.onload=function(){i(a)},a.onerror=function(){s()},a.crossOrigin="Anonymous",this.mode===vs.STYLE?a.src=vs.ADDRESS+"styles/v1/"+this.style+"/tiles/"+e+"/"+t+"/"+n+(this.useHDPI?"@2x?access_token=":"?access_token=")+this.apiToken:a.src=vs.ADDRESS+"v4/"+this.mapId+"/"+e+"/"+t+"/"+n+(this.useHDPI?"@2x.":".")+this.format+"?access_token="+this.apiToken})}}vs.ADDRESS="https://api.mapbox.com/";vs.STYLE=100;vs.MAP_ID=101;class _C extends Oo{mapName;isMsa;constructor(){super();const e=Gv("api_mode");this.isMsa=e!=="legacy"}fetchTile(e,t,n){if(this.mapName)return new Promise((i,s)=>{this.loadTileImage(e,t,n,i,s)})}loadTileImage(e,t,n,i,s){const a=document.createElement("img");a.onload=()=>i(a),a.onerror=()=>s(),a.crossOrigin="anonymous",this.isMsa?a.src=`${Vv}/map/tiles/${this.mapName}/${e}/${t}/${n}`:a.src=`${Wv}/api/map/tiles/${this.mapName}/${e}/${t}/${n}`}setMapName(e){this.mapName=e}}class wC{tileProvider;mapView;editor;constructor(e){const t=new _C;t.minZoom=0,t.maxZoom=25;const n=new Fn(Fn.PLANAR,t);n.position.set(0,0,-.2),n.rotation.x=Math.PI/2,this.editor=e,this.mapView=n,this.tileProvider=t}dispose=()=>{this.deregisterEventListeners()};handleMapName=e=>{this.tileProvider.setMapName(e)};registerEventListeners=()=>{const e=this.editor.eventHandler.eventBus;e.on("setTileVisibility",this.handleToggleTile),e.on("updatemapNameData",this.handleMapName)};deregisterEventListeners=()=>{const e=this.editor.eventHandler.eventBus;e.off("setTileVisibility",this.handleToggleTile),e.off("updatemapNameData",this.handleMapName)};handleToggleTile=e=>{e?this.addToScene():this.removeToScene()};addToScene=()=>{this.editor.scene.add(this.mapView)};removeToScene=()=>{this.editor.scene.remove(this.mapView)}}const SC=16711680;class MC{constructor(e){this.editor=e,this.group=new Vt,this.group.name="trajectory-group",this.group.renderOrder=Rn.PATH,this.group.userData.keep=!0,this.group.visible=!1}group;boxes=[];baseGeometry=null;baseMaterial=null;clear(){this.group.visible=!1,this.boxes.forEach(e=>{e.visible=!1})}dispose(){this.clear(),this.group.parent&&this.group.parent.remove(this.group),this.boxes.length=0,this.baseGeometry?.dispose(),this.baseGeometry=null,this.baseMaterial?.dispose(),this.baseMaterial=null}ensureInitialized(){if(this.ensureGroupAddedToScene(),this.baseGeometry&&this.baseMaterial)return;const{lengthX:e,widthY:t,heightZ:n}=this.getRobotDimensions(),i=new Kt(e,t,n);this.baseGeometry=new Rc(i),i.dispose(),this.baseMaterial=new Yn({color:SC,transparent:!0,opacity:.7})}updateTrajectory(e){if(this.ensureInitialized(),!e.length){this.clear();return}const t=e.slice(-100),{heightZ:n}=this.getRobotDimensions();t.forEach((i,s)=>{const a=this.getOrCreateBox(s),[o=0,l=0,c=0]=i;a.position.set(o,l,n/2),a.rotation.set(0,0,bt.degToRad(c)),a.visible=!0});for(let i=t.length;i<this.boxes.length;i+=1)this.boxes[i].visible=!1;this.group.visible=!0}getBaseGeometry(){if(this.ensureInitialized(),!this.baseGeometry)throw new Error("[TrajectoryDrawer] Base geometry is not initialized");return this.baseGeometry}getBaseMaterial(){if(this.ensureInitialized(),!this.baseMaterial)throw new Error("[TrajectoryDrawer] Base material is not initialized");return this.baseMaterial}getGroup(){return this.ensureGroupAddedToScene(),this.group}getRobotDimensions(){const e=this.resolveRobotSpecKey(this.editor.robotType);return Es[e].dimensions}ensureGroupAddedToScene(){!this.editor.scene||this.group.parent||this.editor.scene.add(this.group)}getOrCreateBox(e){const t=this.boxes[e];if(t)return t;const n=new Pr(this.getBaseGeometry(),this.getBaseMaterial());return n.name=`trajectory-box-${e}`,n.renderOrder=Rn.PATH,n.userData.keep=!0,n.visible=!1,this.group.add(n),this.boxes[e]=n,n}resolveRobotSpecKey(e){return!e||e==="S100-B-3D"?"S100":e==="QD-RBY"?"QD":e in Es?e:"S100"}}class EC extends Vt{constructor(){super(),this.name="S100Helper",this.userData.keep=!0,this.visible=!1,this._init()}updatePosition(e){const t=this.parent.worldToLocal(e.clone());this.position.copy(t)}updateRotation(e){const t=this.parent.worldToLocal(e.clone()),n=t.x-this.position.x,i=t.y-this.position.y;this.rotation.z=Math.atan2(i,n)}_init(){const e=new Rr,t=Bn(Es.S100.modelUrl);new Promise((n,i)=>{e.load(t,s=>{const a=s.scene;console.log("[S100Helper] model loaded from",t),a.traverse(l=>{if(l.userData.keep=!0,l instanceof Ae){const c=l.material;Array.isArray(c)?l.material=c.map(()=>new On({color:new Le(12436423),transparent:!0,opacity:.3})):l.material=new On({color:new Le(12436423),transparent:!0,opacity:.15})}}),a.updateMatrixWorld(!0),a.userData.keep=!0;const o=new ka(1);o.userData.keep=!0,a.add(o),n(a)},void 0,s=>{console.error(s),i(s)})}).then(n=>{this.add(n)}).catch(n=>{console.error("Failed to load s100 model:",n)})}}class TC extends Vt{constructor(){super(),this.name="QDHelper",this.userData.keep=!0,this.visible=!1,this._init()}updatePosition(e){if(!this.parent)return;const t=this.parent.worldToLocal(e.clone());this.position.copy(t)}updateRotation(e){if(!this.parent)return;const t=this.parent.worldToLocal(e.clone()),n=t.x-this.position.x,i=t.y-this.position.y;this.rotation.z=Math.atan2(i,n)}alignToGroundZUp(e){e.updateMatrixWorld(!0);const t=new ln().setFromObject(e);e.position.z+=-t.min.z,e.updateMatrixWorld(!0)}_init(){const e=new Rr,t=new Io,n=Bn(Es.QD.modelUrl);t.setDecoderPath(Bn("/draco/")),e.setDRACOLoader(t),e.loadAsync(n).then(i=>{const s=i.scene;s.traverse(o=>{if(o.userData.keep=!0,o instanceof Ae){const l=o.material;Array.isArray(l)?o.material=l.map(c=>new On({color:c.color,transparent:!0,opacity:.3})):o.material=new On({color:l.color,transparent:!0,opacity:.3})}}),this.alignToGroundZUp(s),s.updateMatrixWorld(!0),s.userData.keep=!0;const a=new ka(1);a.userData.keep=!0,s.add(a),this.add(s)}).catch(i=>{console.error("Failed to load qd model:",i)}).finally(()=>{t.dispose()})}}class AC extends Vt{constructor(){super(),this.name="GAIAHelper",this.userData.keep=!0,this.visible=!1,this._init()}updatePosition(e){if(!this.parent)return;const t=this.parent.worldToLocal(e.clone());this.position.copy(t)}updateRotation(e){if(!this.parent)return;const t=this.parent.worldToLocal(e.clone()),n=t.x-this.position.x,i=t.y-this.position.y;this.rotation.z=Math.atan2(i,n)}alignToGroundZUp(e){e.updateMatrixWorld(!0);const t=new ln().setFromObject(e);e.position.z+=-t.min.z,e.updateMatrixWorld(!0)}_init(){const e=new Rr,t=new Io,n=Bn(Es.GAIA.modelUrl);t.setDecoderPath(Bn("/draco/")),e.setDRACOLoader(t),e.loadAsync(n).then(i=>{const s=i.scene,a=new Vt;s.traverse(l=>{if(l.userData.keep=!0,!(l instanceof Ae))return;const c=d=>{const h=new On({transparent:!0,opacity:.3});return"color"in d&&d.color instanceof Le&&h.color.copy(d.color),"map"in d&&d.map instanceof Bt&&(h.map=d.map),"side"in d&&(h.side=d.side),h};Array.isArray(l.material)?l.material=l.material.map(c):l.material=c(l.material)}),this.alignToGroundZUp(s),s.updateMatrixWorld(!0),s.userData.keep=!0,a.userData.keep=!0,a.rotation.z=Math.PI;const o=new ka(1);o.userData.keep=!0,s.add(o),a.add(s),this.add(a)}).catch(i=>{console.error("Failed to load gaia model:",i)}).finally(()=>{t.dispose()})}}const eg={rby1a:{name:"RBY1-A-Helper",urdfPath:"/rby1a/rby1a.urdf"},rby1m:{name:"RBY1-M-Helper",urdfPath:"/rby1m/rby1m.urdf"},rby1ub:{name:"RBY1-UB-Helper",urdfPath:"/rby1ub/rby1ub.urdf"},rby2c:{name:"RBY2-C-Helper",urdfPath:"/rby2c/rby2c.urdf"}};class CC extends Vt{variant;constructor(e){super(),this.variant=e,this.name=eg[e].name,this.userData.keep=!0,this.visible=!1,this._init()}updatePosition(e){if(!this.parent)return;const t=this.parent.worldToLocal(e.clone());this.position.copy(t)}updateRotation(e){if(!this.parent)return;const t=this.parent.worldToLocal(e.clone()),n=t.x-this.position.x,i=t.y-this.position.y;this.rotation.z=Math.atan2(i,n)}alignToGroundZUp(e){e.updateMatrixWorld(!0);const t=new ln().setFromObject(e);e.position.z+=-t.min.z,e.updateMatrixWorld(!0)}toHelperMaterial(e){const t=new On({transparent:!0,opacity:.3,depthWrite:!1});return"color"in e&&e.color instanceof Le&&t.color.copy(e.color),"map"in e&&e.map instanceof Bt&&(t.map=e.map),"side"in e&&(t.side=e.side),t}_init(){const{urdfPath:e}=eg[this.variant],t=Bn(e),n=new Lc,i=new cf(n);let s=null,a=!1;const o=()=>{a||(a=!0)};i.loadMeshCb=av,n.onLoad=()=>{if(a)return;if(!s){o();return}s.userData.keep=!0,s.traverse(c=>{c.userData.keep=!0,c instanceof Ae&&(Array.isArray(c.material)?c.material=c.material.map(d=>this.toHelperMaterial(d)):c.material=this.toHelperMaterial(c.material))}),this.alignToGroundZUp(s),s.updateMatrixWorld(!0);const l=new ka(1);l.userData.keep=!0,s.add(l),this.add(s),o()},n.onError=l=>{a||(console.warn(`[RBYHelper] Load failed: ${l}`),o())},i.load(t,l=>{a||(s=l)},void 0,l=>{a||(console.error(`Failed to load ${this.variant} helper model:`,l),o())})}}var vo=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 vo.Panel("FPS","#0ff","#002")),l=t(new vo.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=t(new vo.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}};vo.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,v=document.createElement("canvas");v.width=o,v.height=l,v.style.cssText="width:80px;height:48px";var g=v.getContext("2d");return g.font="bold "+9*a+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=t,g.fillRect(0,0,o,l),g.fillStyle=e,g.fillText(r,c,d),g.fillRect(h,u,f,m),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(h,u,f,m),{dom:v,update:function(b,y){n=Math.min(n,b),i=Math.max(i,b),g.fillStyle=t,g.globalAlpha=1,g.fillRect(0,0,o,u),g.fillStyle=e,g.fillText(s(b)+" "+r+" ("+s(n)+"-"+s(i)+")",c,d),g.drawImage(v,h+a,u,f-a,m,h,u,f-a,m),g.fillRect(h+f-a,u,a,m),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(h+f-a,u,a,s((1-b/y)*m))}}};const tg=16,ng=.85,PC=.9;class RC{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*tg,deltaY:e.deltaY*tg};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*ng,-t*ng),n.update()};rotateFromTrackpad=(e,t)=>{const n=2*Math.PI/this.domElement.clientHeight*this.orbit.rotateSpeed*PC,i=this.orbit;i._rotateLeft(-e*n),i._rotateUp(-t*n),i.update()}}const NC=200,DC=3,LC=4,IC=20,kC=6,ig=1,OC=.15,to=1e-6,sg=[1,3,6,12,20,40],Gl=["text-7xl","text-5xl","text-4xl","text-base","text-sm","text-xs","hidden"];class FC{constructor(e){this.editor=e}_renderCSS2D;container;scene;sceneHelpers;camera;renderer;css2DRenderer;effectComposer;selectedNodeOutlinePass;activeNodeOutlinePass;robotPos=new L;robotQuat=new Dt;lookOffset=new L;robotForward=new L;PRIMARY_MOUSE_BUTTON=0;tmpView=new L;onDownPosition=new ge;onMovePosition=new ge;onUpPosition=new ge;onDownPx=new ge;onUpPx=new ge;startPoint=new ge;endPoint=new ge;fwd=new L;right=new L;up=new L;delta=new L;focusBox=new ln;focusCenter=new L;focusSphere=new ni;focusDirection=new L;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";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 sf;const e=this.editor.canvas;if(!e)throw new Error("[Viewport] Canvas is not ready");const t=e.parentElement;if(!t)throw new Error("[Viewport] Canvas parent element is not found");if(!(t instanceof HTMLDivElement))throw new Error("[Viewport] Canvas parent element must be a div");if(this.renderer=new cT({antialias:!0,canvas:e,alpha:!0}),this.container=t,window.location.hostname==="localhost"){const a=new vo;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),this.renderer.setClearColor(0,0),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.outputColorSpace=gt,this.renderer.setSize(t.clientWidth,t.clientHeight),this.renderer.setAnimationLoop(this.animate);const n=new ResizeObserver(a=>{for(const o of a){const{width:l,height:c}=o.contentRect;this.resizeWidth=Math.floor(l),this.resizeHeight=Math.floor(c),this.pendingResize=!0}});n.observe(t),this.resizeObserver=n,e.tabIndex=0,e.style.outline="none",this.camera instanceof gn&&(this.camera.aspect=e.clientWidth/e.clientHeight,this.camera.updateProjectionMatrix()),this.css2DRenderer=new wT,this.css2DRenderer.setSize(e.clientWidth,e.clientHeight),this.css2DRenderer.domElement.className="absolute top-0 left-0 w-full h-full z-10 pointer-events-none",this.container?.appendChild(this.css2DRenderer.domElement);const i=new b1(this.scene,this.camera);this.effectComposer=new p1(this.renderer),this.selectedNodeOutlinePass=new xs(new ge(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 xs(new ge(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(i),this.effectComposer.addPass(this.selectedNodeOutlinePass),this.effectComposer.addPass(this.activeNodeOutlinePass),this.effectComposer.addPass(new g1),this.control="orbit",this.orbit=new pA(this.editor.camera,this.renderer.domElement),this.orbit.mouseButtons={LEFT:-1,MIDDLE:yr.PAN,RIGHT:-1},this.orbit.touches={ONE:Xs.PAN,TWO:Xs.DOLLY_ROTATE},this.orbit.panSpeed=.75,this.orbit.rotateSpeed=.75,this.orbit.zoomSpeed=.5,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 RC({domElement:this.renderer.domElement,orbit:this.orbit}),this.trackpadOrbitController.attach(),this.orbit.addEventListener("change",this.handleOrbitChange),this.transformControls=new fT(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 x1({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-OC;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-draft-vertex-selected",this.handleZoneDraftVertexSelected),e.on("node-manager:selection-transform-changed",this.handleObjectChanged),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("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-draft-vertex-selected",this.handleZoneDraftVertexSelected),e.off("node-manager:selection-transform-changed",this.handleObjectChanged),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("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()),this.css2DRenderer?.domElement?.parentNode&&this.css2DRenderer.domElement.parentNode.removeChild(this.css2DRenderer.domElement),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 L(Number(e.x),Number(e.y),0);this.orbit.target.copy(t),this.orbit.update()}};handleLabelAdded=e=>{this.labels.push(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 ba&&(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;const e=this.resizeWidth,t=this.resizeHeight;if(this.pendingResize=!1,e<=0||t<=0)return;this.editor.canvas.style.width=`${e}px`,this.editor.canvas.style.height=`${t}px`;const n=this.editor.viewportCamera;n.aspect=e/t,n.updateProjectionMatrix(),this.effectComposer.setSize(e,t),this.selectedNodeOutlinePass.setSize(e,t),this.activeNodeOutlinePass.setSize(e,t),this.renderer.setSize(e,t,!1),this.css2DRenderer.setSize(e,t)};depthToBucket(e){for(let t=0;t<sg.length;t++)if(e<sg[t])return t;return Gl.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 L,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(Gl[s.bucket],Gl[o]):l.classList.add(Gl[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(DC*devicePixelRatio,2);if(e<NC&&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,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.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)};handleObjectChanged=()=>{this.editor.nodeManager.updateArrows()};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=e=>{this.transformControls.detach(),this.editor.nodeManager.focusTopologyLinks(e.linkIds)};handleZoneSelected=e=>{this.transformControls.detach(),this.editor.nodeManager.focusTopologyZones(e.zoneIds)};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=>{if(!e.label)return;const t=e.label,n=this.labels.findIndex(i=>i.obj===t);n>-1&&this.labels.splice(n,1),this.transformControls.detach()};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 ni;new ln().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;if(e.value){if(!t||!this.editor.selectionManager.isSelectable(t)){this.transformDragStart=null;return}this.transformDragStart={object:t,position:t.position.clone(),rotation:t.rotation.clone()};return}const n=this.transformDragStart;if(this.transformDragStart=null,!n||!t||n.object!==t)return;const i=n.position.distanceTo(t.position)>to,s=Math.abs(n.rotation.x-t.rotation.x)>to||Math.abs(n.rotation.y-t.rotation.y)>to||Math.abs(n.rotation.z-t.rotation.z)>to;!i&&!s||this.editor.eventHandler.eventBus.emit("topology:changed",{source:"node-updated"})};handleEditorInitialized=()=>{this.initialize()};handleTransformcontrolsSetModeRequested=e=>{if(!this.transformControls)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=.3,s=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(i);break;case"down":this.delta.copy(this.up).multiplyScalar(-i);break;case"left":this.delta.copy(this.right).multiplyScalar(-i);break;case"right":this.delta.copy(this.right).multiplyScalar(i);break;case"zoomin":this.delta.copy(this.fwd).multiplyScalar(s),t.position.add(this.delta),n.update(),this.emitCameraChanged();return;case"zoomout":this.delta.copy(this.fwd).multiplyScalar(-s),t.position.add(this.delta),n.update(),this.emitCameraChanged();return;case"center":{const a=t.position.z,o=.001;n.target.set(0,0,0),t.position.set(o,o,a),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=ig):(this.focusBox.getCenter(this.focusCenter),this.focusBox.getBoundingSphere(this.focusSphere));const t=Math.max(this.focusSphere.radius,ig),n=bt.clamp(t*kC,LC,IC);this.focusDirection.copy(this.camera.position).sub(this.orbit.target),this.focusDirection.lengthSq()<to?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 UC{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 fC,this.eventHandler=new U1(this),this.nodeManager=new eC(this),this.robotManager=new uC(this),this.selector=new pC(this),this.eraser=new F1(this),this.pathDrawer=new rC(this),this.trajectoryDrawer=new MC(this),this.pointsManager=new oC(this),this.tileMap=new wC(this),this.viewport=new FC(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 L(0,0,1),this.scene=new cu,this.sceneHelpers=new cu,this.camera=Ca.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 Qs(1e4,1e4),n=new jt({visible:!1}),i=new Ae(t,n);i.name="globalPlane",i.userData.keep=!0,this.globalPlane=i,this.scene.add(this.globalPlane);const s=new Cp(16777215,2105376,.5);s.userData.keep=!0,this.scene.add(s);const a=new Ic(16777215,1);a.position.set(0,0,100),a.userData.keep=!0,this.scene.add(a),this.sceneHelpers.add(new Cp(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 Da(.1),n=new jt({color:16711680}),i=new Ae(t,n);i.name="origin";const s=new ka(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(Ca),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 Ae&&(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 ba),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 TC:e==="rby1a"||e==="rby1m"||e==="rby1ub"||e==="rby2c"?t=new CC(e):e==="GAIA"||e==="QD"?t=new AC:t=new EC,this.previewHelper=t,this.scene.add(this.previewHelper)}}const Yd=r=>typeof r=="number"&&Number.isFinite(r),rg=r=>{if(!r||typeof r!="object")return!1;const e=r;return Yd(e.x)&&Yd(e.y)&&Yd(e.z)},BC=r=>{if(!r)return null;try{const e=JSON.parse(r);if(!e||typeof e!="object")return null;const t=e;return!rg(t.position)||!rg(t.target)?null:{position:t.position,target:t.target}}catch{return null}},zC=r=>{if(!r)return null;try{return BC(localStorage.getItem(r))}catch{return null}},HC=(r,e)=>{if(r)try{localStorage.setItem(r,JSON.stringify(e))}catch{}},GC=({className:r})=>p("div",{className:on("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:p(jv,{size:"3rem"})}),{useCallback:VC,useMemo:Vl,useReducer:WC,useState:Ui}=await wt("react"),jC={state:"idle",editingZoneId:null,selectedVertexIndex:null,name:"",type:"NO_ENTRY",pointCount:0,points:[]},_c={editor:!1,viewport:!1,nodeManager:!1,robot:!1,map:!1,topo:!1};function Tv(r,e){switch(e.type){case"RESET":return _c;case"SET":return r[e.key]===e.value?r:{...r,[e.key]:e.value};case"REPLACE":return e.ready}}function yN(){const[r,e]=WC(Tv,_c),[t,n]=Ui([]),[i,s]=Ui(null),[a,o]=Ui([]),[l,c]=Ui(null),[d,h]=Ui([]),[u,f]=Ui(null),[m,v]=Ui([]),[g,b]=Ui([]),[y,w]=Ui([]),[_,R]=Ui(null),[T,P]=Ui(jC),M=VC(I=>{e({type:"REPLACE",ready:I})},[]),x=Vl(()=>t[t.length-1]??null,[t]),S=Vl(()=>{if(a.length===0)return[];const I=new Set(a);return g.filter(G=>I.has(G.id))},[g,a]),C=Vl(()=>S.length===0||!l?null:S.find(I=>I.id===l)??null,[l,S]),k=Vl(()=>({onReadyChange:M,onSelectedObjectsChange:n,onSelectedNodeTransformChange:s,onSelectedLinksChange:o,onFocusedLinkChange:c,onSelectedZonesChange:h,onFocusedZoneChange:f,onNodesChange:v,onLinksChange:b,onZonesChange:w,onMapBoundsChange:R,onZoneDraftChange:P}),[M]);return{ready:r,selectedObjects:t,selectedNodeTransform:i,selectedNode:x,selectedLinkIds:a,focusedLinkId:l,selectedLinks:S,focusedLink:C,selectedZoneIds:d,focusedZoneId:u,nodes:m,links:g,zones:y,mapBounds:_,zoneDraft:T,worldStudioStateProps:k}}const{forwardRef:XC,useCallback:wi,useEffect:hn,useImperativeHandle:qC,useMemo:ZC,useReducer:YC,useRef:Wl,useState:ag}=await wt("react"),og={light:{background:"#f4f4f5",fine:5395026,coarse:5921370,xAxis:16717636,yAxis:65382},dark:{background:"#333333",fine:6052956,coarse:9079434,xAxis:16717636,yAxis:65382}},KC=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})),$C=XC(({className:r,cameraPositionKey:e,pointsData:t,topoData:n,mapCloudUpdatedAt:i,topologyUpdatedAt:s,robot:a,globalPath:o,localPath:l,trajectory:c,lidarPoints:d,mappingPoints:h,robotPose:u,selectedTool:f,showGrid:m,showNodeLabels:v,nodeRenderMode:g="default",showLidar:b,lidarPointSize:y,viewportCameraMode:w,mappingKeyFrame:_,onReadyChange:R,onSelectedObjectsChange:T,onSelectedNodeTransformChange:P,onSelectedLinksChange:M,onFocusedLinkChange:x,onSelectedZonesChange:S,onFocusedZoneChange:C,onNodesChange:k,onLinksChange:I,onZonesChange:G,onMapBoundsChange:q,onEraserHistoryInvalidated:O,onEraserSelectionChange:W,onZoneDraftChange:Z},K)=>{const{theme:oe}=Ar(),te=Wl(null),ve=Wl(null),ce=Wl(a??null),[Q,re]=ag(null),[J,ne]=YC(Tv,_c),ue=Wl(null),[Te,_e]=ag("none"),fe=ZC(()=>J.editor&&J.viewport&&J.nodeManager,[J]),be=wi((V,$)=>{if(J[V]===$)return;const le={...J,[V]:$};ne({type:"SET",key:V,value:$}),R?.(le)},[J,R]),Ce=wi(()=>{ne({type:"RESET"}),R?.(_c)},[R]),X=wi(V=>{k?.(KC(V))},[k]),Be=wi(()=>{const V=te.current?.nodeManager.getTopologyLinks()??[];I?.(V)},[I]),Me=wi(()=>{const V=te.current?.nodeManager.getTopologyZones()??[];G?.(V)},[G]),et=wi(V=>{if(T?.(V.selectedObjects),!!P){if(!V.object){P(null);return}P({x:V.object.position.x,y:V.object.position.y,z:V.object.position.z,rz:bt.radToDeg(V.object.rotation.z)})}},[P,T]),Se=wi(V=>{if(!V){P?.(null);return}const $=Number(V.x),le=Number(V.y),Ie=Number(V.z),we=Number(V.rz);if([$,le,Ie,we].some(ze=>Number.isNaN(ze))){P?.(null);return}P?.({x:$,y:le,z:Ie,rz:we})},[P]),Ye=wi(V=>{q?.(V.mapBounds),be("map",!0)},[q,be]),ee=wi(V=>{M?.(V.linkIds)},[M]),U=wi(V=>{S?.(V.zoneIds)},[S]),A=wi(V=>{x?.(V.linkId)},[x]),Y=wi(V=>{C?.(V.zoneId)},[C]);return qC(K,()=>({emit:(V,$)=>{te.current?.eventHandler.eventBus.emit(V,$)},getCamera:()=>{const V=te.current;return V?.viewportCamera??V?.camera??null},getCanvas:()=>te.current?.canvas??null,getEraserRadius:()=>te.current?.getEraserRadius()??.5,getMapPointsData:()=>te.current?.pointsManager?.mapPointsData??[],getPreviewTransform:()=>{const V=te.current?.previewHelper;return V?{x:V.position.x.toString(),y:V.position.y.toString(),z:V.position.z.toString(),rz:(V.rotation.z*(180/Math.PI)).toString()}:null},getTopologyData:()=>{const V=te.current?.selectionManager.getSelectableObjects()??[],$=te.current?.nodeManager.getTopologyLinks()??[],le=te.current?.nodeManager.getTopologyZones()??[],Ie=V.map(we=>({id:typeof we.userData.id=="string"?we.userData.id:we.uuid,name:we.name,context:typeof we.userData.context=="string"?we.userData.context:"",pose:{x:we.position.x,y:we.position.y,z:we.position.z,rx:bt.radToDeg(we.rotation.x),ry:bt.radToDeg(we.rotation.y),rz:bt.radToDeg(we.rotation.z)},size:{x:0,y:0,z:0},type:typeof we.userData.type=="string"?we.userData.type:"GOAL",safetyField:typeof we.userData.safetyField=="number"?we.userData.safetyField:0,features:Array.isArray(we.userData.features)?we.userData.features.filter(pt=>typeof pt=="string"):[]}));return{format_version:S1,nodes:Ie,links:$,zones:le}},getTopologyZones:()=>te.current?.nodeManager.getTopologyZones()??[],hidePreviewHelper:()=>{const V=te.current;V&&(V.setupPreviewHelper(null),V.previewHelper.visible=!1)},moveCamera:V=>{te.current?.eventHandler.eventBus.emit("ui:camera-move-requested",V)},startZoneDraft:V=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-start-requested",V)},cancelZoneDraft:()=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-cancel-requested",void 0)},clearZoneDraft:()=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-clear-requested",void 0)},undoZoneDraft:()=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-undo-requested",void 0)},closeZoneDraft:()=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-close-requested",void 0)},reopenZoneDraft:()=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-reopen-requested",void 0)},commitZoneDraft:()=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-commit-requested",void 0)},startZoneEdit:V=>{te.current?.eventHandler.eventBus.emit("ui:zone-edit-start-requested",{zoneId:V})},focusActiveTopologyZone:V=>{te.current?.nodeManager.focusActiveTopologyZone(V)},updateZoneDraftMeta:V=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-meta-updated",V)},deleteTopologyZone:V=>{te.current?.nodeManager.deleteTopologyZone(V)},onTopologyChanged:V=>{const $=te.current?.eventHandler.eventBus;return $?($.on("topology:changed",V),()=>{$.off("topology:changed",V)}):()=>{}}}),[]),hn(()=>{te.current||(te.current=new UC);const $=te.current.eventHandler.eventBus,le=()=>be("editor",!0),Ie=()=>be("viewport",!0),we=()=>be("nodeManager",!0),ze=Qe=>{HC(e,Qe)},pt=Qe=>{Z?.(Qe),_e(Qe.state==="drawing"?"zoneDraft":"none")},Pe=Qe=>{W?.(Qe.selectedCount)},Ue=()=>{O?.()};return $.on("editor:initialized",le),$.on("viewport:initialized",Ie),$.on("node-manager:ready",we),$.on("viewport:camera-changed",ze),$.on("points-manager:mappoints-updated",Ye),$.on("selector:object-selected",et),$.on("node-manager:selection-transform-changed",Se),$.on("selector:link-selected",ee),$.on("selector:link-focused",A),$.on("selector:zone-selected",U),$.on("selector:zone-focused",Y),$.on("topology:nodes-updated",X),$.on("node-manager:topo-updated",Be),$.on("node-manager:topo-updated",Me),$.on("eraser:history-invalidated",Ue),$.on("eraser:selection-changed",Pe),$.on("zone:draft-updated",pt),()=>{$.off("editor:initialized",le),$.off("viewport:initialized",Ie),$.off("node-manager:ready",we),$.off("viewport:camera-changed",ze),$.off("points-manager:mappoints-updated",Ye),$.off("selector:object-selected",et),$.off("node-manager:selection-transform-changed",Se),$.off("selector:link-selected",ee),$.off("selector:link-focused",A),$.off("selector:zone-selected",U),$.off("selector:zone-focused",Y),$.off("topology:nodes-updated",X),$.off("node-manager:topo-updated",Be),$.off("node-manager:topo-updated",Me),$.off("eraser:history-invalidated",Ue),$.off("eraser:selection-changed",Pe),$.off("zone:draft-updated",pt)}},[Ye,et,Se,A,Y,ee,U,x,C,O,W,Z,e,be,Be,X,Me]),hn(()=>{const V=te.current;V&&(ce.current=a??null,V.robotType=a??null)},[a]),hn(()=>{const V=te.current;if(V){if(!Q){ve.current=null;return}if(!(!Q.isConnected||!Q.parentElement)&&ve.current!==Q)return ve.current=Q,V.initialize({robotType:ce.current,canvas:Q,initialCameraState:zC(e)}),()=>{V.dispose(),ve.current=null,Ce()}}},[e,Q,Ce]),hn(()=>{const V=te.current;!fe||!V||t&&V.eventHandler.eventBus.emit("ui:map-points-update-requested",t)},[t,i,fe]),hn(()=>{const V=te.current;!fe||!V||V.pathDrawer.updateGlobalPath(o??[])},[o,fe]),hn(()=>{const V=te.current;!fe||!V||V.pathDrawer.updateLocalPath(l??[])},[l,fe]),hn(()=>{const V=te.current;!fe||!V||V.trajectoryDrawer.updateTrajectory(c??[])},[c,fe]),hn(()=>{const V=te.current;!fe||!V||V.eventHandler.eventBus.emit("ui:topo-update-requested",{topoData:n})},[n,s,fe]),hn(()=>{const V=te.current;!fe||!V||V.eventHandler.eventBus.emit("ui:grid-visibility-set-requested",m)},[m,fe]),hn(()=>{const V=te.current;!fe||!V||!w||V.eventHandler.eventBus.emit("ui:camera-mode-set-requested",w)},[fe,w]),hn(()=>{const V=te.current?.viewport;if(!fe||!V)return;const{background:$,fine:le,coarse:Ie,xAxis:we,yAxis:ze}=og[oe]??og.dark;V.setGridColors(le,Ie),V.setGridAxisColors(we,ze)},[oe,fe]),hn(()=>{const V=te.current;!fe||!V||!a||(V.robotManager.loadMainRobot(a),V.setupPreviewHelper(a))},[a,fe]),hn(()=>{const V=te.current;!fe||!V||!d||V.eventHandler.eventBus.emit("lidar:updated",{lidarPoints:d})},[d,fe]),hn(()=>{const V=te.current;if(!fe||!V||!u)return;const $=V.robotManager.mainRobot;$&&$.applyPose({x:Number(u.x??0),y:Number(u.y??0),rz:Number(u.rz??0)})},[u,fe]),hn(()=>{const V=te.current;if(!fe||!V)return;const $=V.eventHandler.eventBus;if($.emit("ui:localization-mode-toggle-requested",!1),Te==="zoneDraft"){$.emit("ui:pointer-action-set-requested","zoneDraft");return}switch(f){case"select":$.emit("ui:pointer-action-set-requested","inspect");break;case"target":$.emit("ui:localization-mode-toggle-requested",!0),$.emit("ui:pointer-action-set-requested","locatePreview");break;case"move":$.emit("ui:pointer-action-set-requested","select"),$.emit("ui:transformControls-set-mode-requested","translate");break;case"rotate":$.emit("ui:pointer-action-set-requested","select"),$.emit("ui:transformControls-set-mode-requested","rotate");break;case"scale":$.emit("ui:pointer-action-set-requested","select"),$.emit("ui:transformControls-set-mode-requested","scale");break}},[f,fe,Te]),hn(()=>{const V=te.current;!fe||!V||V.eventHandler.eventBus.emit("ui:label-visibility-set-requested",v)},[v,fe]),hn(()=>{const V=te.current;!fe||!V||V.eventHandler.eventBus.emit("ui:node-render-mode-set-requested",g)},[g,fe]),hn(()=>{const V=te.current;!fe||!V||V.eventHandler.eventBus.emit("ui:lidar-toggled",b)},[b,fe]),hn(()=>{const V=te.current;!fe||!V||typeof y!="number"||V.eventHandler.eventBus.emit("ui:lidar-point-size-set-requested",y)},[y,fe]),hn(()=>{const V=te.current;!fe||!V||!h||V.eventHandler.eventBus.emit("ui:mapping-data-received",h)},[h,fe]),hn(()=>{const V=te.current;if(!fe||!V||!_||_.data.length===0)return;const $=ue.current;$&&$.chunkNum===_.chunkNum&&$.chunkId===_.chunkId&&$.data===_.data||(ue.current=_,V.eventHandler.eventBus.emit("ui:mapping-keyframe-received",_))},[_,fe]),E("div",{className:on("WorldStudio","bg-bg-raised relative h-full w-full",r),children:[p("canvas",{ref:re,className:"h-full w-full"}),!fe&&p(GC,{})]})});$C.displayName="WorldStudio";const _u=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"}},Av=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"}},QC=(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:JC}=await wt("react"),eP=({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:v=0,inlierRatio:g=0})=>{const{t:b}=en();return E(j,{className:"pointer-events-none absolute top-4 left-4 z-10 gap-2.5",children:[E(me,{className:"items-start gap-4",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:b("move.amr.rightPanel.hud.localization")}),E(me,{className:"items-center gap-1 py-0.5",children:[p(ya,{className:`h-2.5 w-2.5 ${_u(r)}`}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:QC(r,b)}),p("span",{className:"typo-compact-2xs-medium text-fg-subtler ml-2",children:b("move.amr.rightPanel.hud.inlierError")}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:v.toFixed(3)}),p("span",{className:"typo-compact-2xs-medium text-fg-subtler ml-1",children:b("move.amr.rightPanel.hud.inlierRatio")}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:g.toFixed(2)})]})]}),E(j,{className:"gap-0.5",children:[p("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:b("move.amr.rightPanel.hud.autoMove")}),E(me,{className:"items-center gap-1 py-0.5",children:[p(Eu,{className:`h-2.5 w-2.5 ${_u(e)}`}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:e})]})]}),E(j,{className:"gap-0.5",children:[p("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:b("move.amr.rightPanel.hud.obstacleDetect")}),E(me,{className:"items-center gap-1 py-0.5",children:[p(zg,{className:`h-2.5 w-2.5 ${Av(t)}`}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:t})]})]})]}),E(j,{className:"gap-0.5",children:[p("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:b("move.amr.rightPanel.hud.robotTransform")}),E(j,{className:"gap-2",children:[E(me,{className:"items-center gap-3",children:[E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-danger",children:"X"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:n.toFixed(3)})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-success",children:"Y"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:i.toFixed(3)})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-information",children:"Z"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:s.toFixed(3)})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-information",children:"RZ"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:a.toFixed(3)})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:b("move.amr.rightPanel.hud.speed")}),E("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[o.toFixed(2)," m/s"]})]})]}),E(me,{className:"items-center gap-3",children:[E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"VX"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:l.toFixed(3)})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"VY"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:c.toFixed(3)})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"WZ"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:d.toFixed(3)})]})]})]})]}),E(j,{className:"gap-0.5",children:[p("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:b("move.amr.rightPanel.hud.imuSensor")}),E(me,{className:"items-center gap-3",children:[E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"Roll"}),E("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[h>0?"+":"",h.toFixed(2),"°"]})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"Pitch"}),E("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[u>0?"+":"",u.toFixed(2),"°"]})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"Yaw"}),E("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[f>0?"+":"",f.toFixed(2),"°"]})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle uppercase",children:"ω"}),E("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[m.toFixed(2)," deg/s"]})]})]})]})]})},xN=JC(eP),{useEffect:tP,useMemo:Kd,useRef:nP,useState:no}=await wt("react"),_N=({open:r,close:e,onOpenChange:t,currentMap:n,onLoadMap:i,mapList:s})=>{const{t:a}=en(),[o,l]=no(1),[c,d]=no(null),[h,u]=no(""),[f,m]=no(!1),[v,g]=no(!1),b=nP(null),y=()=>{e?.(),t?.(!1)},w=I=>I>=1024*1024?`${(I/(1024*1024)).toFixed(1)} MB`:I>=1024?`${(I/1024).toFixed(1)} KB`:`${I} B`,_=Kd(()=>(s?.list??[]).map((I,G)=>{const q=[...I.cloudInfo,...I.topoInfo].reduce((O,W)=>O+W.fileSize,0);return{id:`${G+1}`,name:I.mapName,modifiedDate:I.updatedAt,size:w(q)}}),[s?.list]),R=Kd(()=>_.filter(I=>I.name.toLowerCase().includes(h.toLowerCase())),[_,h]),T=16,P=Math.max(1,Math.ceil(R.length/T)),M=Math.min(o,P),x=(M-1)*T,S=Kd(()=>R.slice(x,x+T),[R,x,T]),C=I=>{const G=Math.max(1,Math.min(P,I));l(G)},k=()=>{if(!c)return;const I=_.find(G=>G.id===c);I&&(i(I.name),y())};return tP(()=>{if(!r){m(!1),g(!1);return}const I=b.current;if(!I)return;const G=I.querySelector('[data-slot="scroll-area-viewport"]');if(!G)return;const q=()=>{const O=G.scrollHeight>G.clientHeight+1,W=G.scrollTop+G.clientHeight>=G.scrollHeight-1,Z=G.scrollTop>1;m(O&&Z),g(O&&!W)};return q(),G.addEventListener("scroll",q),window.addEventListener("resize",q),()=>{G.removeEventListener("scroll",q),window.removeEventListener("resize",q)}},[S,r]),r?E(j,{className:"fixed inset-0 z-50 items-center justify-center p-4",children:[p("button",{type:"button","aria-label":a("move.amr.rightPanel.map.loadDialog.closeBackdrop"),className:"bg-bg-dim absolute inset-0",onClick:y}),E(j,{className:"bg-bg-overlay relative h-[560px] w-full max-w-4xl overflow-hidden rounded-lg p-4",children:[p(j,{className:"shrink-0 gap-0.5 p-1",children:E(me,{className:"items-start justify-between",children:[p(me,{className:"items-center gap-2 pb-2",children:E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-lg-semibold text-fg-default",children:a("move.amr.rightPanel.map.loadDialog.title")}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:a("move.amr.rightPanel.map.loadDialog.description")})]})}),p(qn,{variant:"transparent",size:"2xs",icon:p(Pa,{}),className:"text-fg-subtle",onClick:y})]})}),E(j,{className:"min-h-0 flex-1 gap-2",children:[p(me,{className:"bg-alt-1 items-center justify-between rounded-md px-2.5 py-2 [[data-theme='light']_&]:bg-white",children:E(me,{className:"items-center gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-success",children:a("move.amr.rightPanel.map.loadDialog.currentMap")}),p("p",{className:"typo-compact-xs-semibold text-fg-default",children:n||"-"})]})}),p(j,{className:"shrink-0 gap-3",children:p(un,{type:"search",value:h,placeholder:a("move.amr.rightPanel.map.loadDialog.searchPlaceholder"),prefixIcon:p(Xv,{className:"text-fg-subtler"}),onChange:I=>{u(I.target.value),l(1)},className:"w-full"})}),E(j,{ref:b,className:"relative min-h-0 flex-1 overflow-hidden",children:[f&&p("div",{className:"from-bg-overlay pointer-events-none absolute inset-x-0 top-0 z-10 h-4 bg-gradient-to-b to-transparent"}),p(qv,{className:"h-full min-h-0 w-full overflow-hidden",viewportClassName:"h-full w-full",children:p("div",{className:"grid grid-cols-2 gap-2 pr-2",children:S.length>0?S.map(I=>{const G=c===I.id,q=I.name===n;return p("button",{type:"button",onClick:()=>d(I.id),className:`rounded-md border px-3 py-2.5 text-left transition-colors ${G?"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:E(me,{className:"items-start",children:[E(j,{className:"min-w-0 flex-1 justify-between gap-2",children:[p("p",{className:"typo-compact-sm-semibold text-fg-default truncate",children:I.name}),E(j,{className:"gap-0.5",children:[E(me,{className:"gap-1",children:[E("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[a("move.amr.rightPanel.map.loadDialog.modified"),":"]}),p("p",{className:"typo-compact-xs-normal text-fg-default",children:I.modifiedDate})]}),E(me,{className:"gap-1",children:[E("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[a("move.amr.rightPanel.map.loadDialog.size"),":"]}),p("p",{className:"typo-compact-xs-normal text-fg-default",children:I.size})]})]})]}),G&&p(Hg,{className:"text-fg-brand size-4"}),!G&&q&&p("p",{className:"typo-compact-2xs-semibold text-fg-success uppercase",children:a("move.amr.rightPanel.map.loadDialog.current")})]})},I.id)}):E(j,{className:"col-span-2 items-center justify-center py-10",children:[p("p",{className:"typo-compact-sm-normal text-fg-subtler",children:a("move.amr.rightPanel.map.loadDialog.noMapsFound")}),p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:a("move.amr.rightPanel.map.loadDialog.tryDifferentSearch")})]})})}),v&&p("div",{className:"from-bg-overlay pointer-events-none absolute inset-x-0 bottom-0 h-4 bg-gradient-to-t to-transparent"})]})]}),E(j,{className:"shrink-0 gap-3",children:[p(me,{className:"justify-center",children:p(Zv,{currPage:M,listSize:T,pageSize:5,totalCount:R.length,handlePageChange:C})}),E(me,{className:"items-center justify-end gap-2",children:[p(We,{variant:"outlined",onClick:y,children:a("move.amr.rightPanel.common.cancel")}),p(We,{variant:"brand",disabled:!c,onClick:k,children:a("move.amr.rightPanel.map.loadDialog.loadSelectedMap")})]})]})]})]}):null},{memo:iP}=await wt("react"),sP=({mapName:r,onMapNameClick:e})=>{const t=!r,{theme:n}=Ar();return p("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:E("div",{className:"flex items-center gap-1 px-0.5",children:[p(xy,{className:`h-4 w-4 ${t?"text-fg-subtle":"text-fg-default"}`}),p("span",{className:"text-fg-default typo-compact-xs-semibold",children:r}),t&&p("span",{className:"text-fg-subtle typo-compact-xs-medium",children:"Empty"})]})})},wN=iP(sP),{useState:rP,useCallback:aP}=await wt("react"),Cv=new Set(["move","rotate","scale"]),SN=()=>{const[r,e]=rP("select"),t=aP(n=>{e(n)},[]);return{selectedTool:r,onToolChange:t}},{memo:oP}=await wt("react"),lP=[{id:"select",icon:Eu,label:"Select",shortcut:"V"},{id:"target",icon:vy,label:"Cursor",shortcut:"T"}],cP=[{id:"move",icon:Yv,label:"Move",shortcut:"G"},{id:"rotate",icon:Gg,label:"Rotate",shortcut:"R"},{id:"scale",icon:Vg,label:"Scale",shortcut:"S"}],dP=[lP,cP],hP=({selectedTool:r,onToolChange:e,hasSelectedNode:t=!0,toolGroups:n,className:i})=>{const{theme:s}=Ar(),a=s==="light"?"bg-default":"bg-alt-1",o=n??dP;return p(j,{className:on("gap-2",i),children:o.map((l,c)=>p("div",{className:"overflow-visible rounded-lg bg-transparent",children:l.map(d=>{const h=Cv.has(d.id);if(n===void 0&&h&&!t)return null;const u=r===d.id,f=d.shortcut?`${d.label} (${d.shortcut})`:d.label;return E("div",{className:"group relative",children:[p(qn,{variant:"transparent",size:"xs2",onClick:()=>e(d.id),className:on(a,"hover:!text-fg-default !text-fg-default shadow-down-xs relative rounded-sm",s==="light"?"hover:!bg-white":"hover:!bg-bg-alt-1"),icon:E(vi,{children:[u?p("span",{className:"bg-fill-subtler pointer-events-none absolute inset-1 rounded-md"}):null,p(d.icon,{className:"!text-fg-default relative z-10 h-4 w-4"})]}),"aria-label":d.ariaLabel??d.label}),p("p",{className:`typo-compact-xs2-normal ${a} 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:f})]},d.id)})},c))})},MN=oP(hP),{memo:uP}=await wt("react"),fP=({showJoysticks:r,showJoystickBtn:e=!0,setShowJoysticks:t,showViewControls:n,setShowViewControls:i,visibilityItems:s,onZoomIn:a,onZoomOut:o,isFullscreen:l,onFullscreenToggle:c,className:d})=>{const{theme:h}=Ar(),u=h==="light"?"bg-default":"bg-alt-1",f=h==="light"?"hover:bg-white":"hover:bg-alt-2";return E("div",{className:on("text-default flex flex-col gap-1.5",d),children:[E(j,{className:"group shadow-down-xs relative overflow-visible rounded-md",children:[p("button",{onClick:a,className:`${u} ${f} text-default rounded-md rounded-b-none p-2`,children:p(Wg,{className:"h-4 w-4"})}),p(ji,{type:"horizontal"}),p("button",{onClick:o,className:`${u} ${f} text-default rounded-md rounded-t-none p-2`,children:p(jg,{className:"h-4 w-4"})}),p("p",{className:`typo-compact-xs2-normal ${u} text-fg-default pointer-events-none invisible absolute top-1/2 right-full mr-2 -translate-y-1/2 rounded px-2 py-1.5 whitespace-nowrap group-hover:visible`,children:"Zoom Operation"})]}),E("div",{className:"group relative",children:[p("button",{onClick:c,className:`${u} ${f} text-default shadow-down-xs rounded p-2`,children:l?p(Kv,{className:"h-4 w-4"}):p(Vg,{className:"h-4 w-4"})}),p("p",{className:`typo-compact-xs2-normal ${u} text-fg-default pointer-events-none invisible absolute top-1/2 right-full mr-2 -translate-y-1/2 rounded px-2 py-1.5 whitespace-nowrap group-hover:visible`,children:l?"Exit Full Screen":"Full Screen"})]}),e&&E("div",{className:"group relative",children:[E("button",{onClick:()=>t(!r),className:`${u} ${f} text-default shadow-down-xs relative rounded-md p-2`,children:[r?p("span",{className:"bg-fill-subtler pointer-events-none absolute inset-1 rounded-md"}):null,p(Xg,{className:"relative z-10 h-4 w-4"})]}),p("p",{className:`typo-compact-xs2-normal ${u} text-fg-default pointer-events-none invisible absolute top-1/2 right-full mr-2 -translate-y-1/2 rounded px-2 py-1.5 whitespace-nowrap group-hover:visible`,children:"Virtual Joysticks"})]}),E("div",{className:"group relative",children:[E("button",{onClick:()=>i(!n),className:`${u} ${f} text-default shadow-down-xs relative rounded-md p-2`,children:[n?p("span",{className:"bg-fill-subtler pointer-events-none absolute inset-1 rounded-md"}):null,p(Sc,{className:"relative z-10 h-4 w-4"})]}),p("p",{className:`typo-compact-xs2-normal ${u} text-fg-default pointer-events-none invisible absolute top-1/2 right-full mr-2 -translate-y-1/2 rounded px-2 py-1.5 whitespace-nowrap group-hover:visible`,children:"Viewport Visibility"}),n&&E(j,{className:`${h==="light"?"bg-white":"bg-alt-1"} border-disabled shadow-down-xs absolute top-0 right-full z-50 mr-2 w-64 gap-2.5 rounded-md px-3 py-2.5`,children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Viewport Visibility"}),p(j,{children:s.map((m,v)=>E(j,{children:[E(me,{className:"items-center justify-between",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-xs2-semibold text-fg-default",children:m.label}),m.description?p("p",{className:"typo-compact-xs-normal text-fg-subtle",children:m.description}):null]}),p(xa,{checked:m.checked,onCheckedChange:g=>{m.onCheckedChange(!!g)}})]}),v<s.length-1?p(ji,{className:"py-2"}):null]},m.label))})]})]})]})},EN=uP(fP),{memo:pP}=await wt("react"),$d={fullscreen:"right-2",menuExpanded:"right-33",menuCollapsed:"right-12"},mP=({isLive:r,pointCount:e,latency:t,fps:n,nodeCount:i,linkCount:s,onToggleRobotControl:a,onToggleCameraStreams:o,onToggleObstacleMap:l,showCameraStreams:c,showObstacleMap:d,showRobotControlBtn:h,isFullscreen:u=!1,isMenuExpanded:f=!1})=>{const{theme:m}=Ar(),{t:v}=en(),g=!h,b=u?$d.fullscreen:f?$d.menuExpanded:$d.menuCollapsed;return E("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:[E("div",{className:"flex items-center gap-3",children:[E("div",{className:"flex items-center gap-1",children:[p("div",{className:`h-2 w-2 rounded-full ${r?"animate-pulse bg-green-500":"bg-gray-600"}`}),p("span",{className:"text-fg-default typo-compact-2xs-semibold",children:v(r?"move.amr.rightPanel.bottomBar.liveStream":"move.amr.rightPanel.bottomBar.offline")})]}),E("div",{className:"flex items-center gap-1",children:[E("span",{className:"text-fg-subtler typo-compact-2xs-normal",children:[v("move.amr.rightPanel.bottomBar.points"),":"]}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:e.toLocaleString()})]}),E("div",{className:"flex items-center gap-1",children:[E("span",{className:"text-fg-subtler typo-compact-2xs-normal",children:[v("move.amr.rightPanel.bottomBar.nodes"),":"]}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:i})]}),E("div",{className:"flex items-center gap-1",children:[E("span",{className:"text-fg-subtler typo-compact-2xs-normal",children:[v("move.amr.rightPanel.bottomBar.links"),":"]}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:s})]})]}),E("div",{className:on("pointer-events-auto absolute flex items-center gap-1.5",b),children:[p(We,{size:"2xs",variant:"inverse",leadingIcon:p(_h,{}),onClick:o,className:on(!c&&(m==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:v("move.amr.rightPanel.bottomBar.camera")}),p(We,{size:"2xs",variant:"inverse",leadingIcon:p(qg,{}),onClick:l,className:on(!d&&(m==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:"Obstacle Map"}),p(We,{size:"2xs",variant:"inverse",leadingIcon:p(Xg,{}),onClick:a,className:on(!g&&(m==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:v("move.amr.rightPanel.bottomBar.controlPanel")})]})]})},TN=pP(mP),{useEffect:lg,useRef:gP,useState:fi}=await wt("react"),bP=["button","point","manual"],cg={KeyW:"forward",KeyA:"left",KeyS:"backward",KeyD:"right",KeyQ:"rotateLeft",KeyE:"rotateRight"},dg=r=>{if(!(r instanceof HTMLElement))return!1;const e=r.tagName.toLowerCase();return r.isContentEditable||e==="input"||e==="textarea"||e==="select"},AN=({robotPose:r,handleButtonJog:e,onClose:t,onMoveTarget:n,onMoveLinear:i,linearSpeed:s,setLinearSpeed:a,rotationSpeed:o,setRotationSpeed:l,transparency:c,onTransparencyChange:d,className:h})=>{const{t:u}=en(),[f,m]=fi("button"),v=gP(null),[g,b]=fi("0.5"),[y,w]=fi("0.5"),[_,R]=fi("45"),[T,P]=fi("45"),[M,x]=fi("0.0"),[S,C]=fi("0.0"),[k,I]=fi("0.0"),[G,q]=fi("0.0"),[O,W]=fi("x"),[Z,K]=fi("1.0"),[oe,te]=fi("0.5"),[ve,ce]=fi(c),Q=()=>{n({goalPose:{x:Number.parseFloat(M)||0,y:Number.parseFloat(S)||0,rz:Number.parseFloat(G)||0},method:"pp",preset:1})},re=()=>{const J=Number.parseFloat(Z)||0,ne=Number.parseFloat(oe)||0;i({axis:O,target:J,speed:ne})};return lg(()=>{if(typeof window>"u")return;const J=()=>{v.current!==null&&(v.current=null,e("stop"))},ne=Te=>{if(f!=="button"||Te.repeat||dg(Te.target))return;const _e=cg[Te.code];_e&&(Te.preventDefault(),v.current!==_e&&(v.current=_e,e(_e)))},ue=Te=>{if(f!=="button"||dg(Te.target))return;const _e=cg[Te.code];!_e||v.current!==_e||(Te.preventDefault(),J())};return window.addEventListener("keydown",ne),window.addEventListener("keyup",ue),window.addEventListener("blur",J),()=>{window.removeEventListener("keydown",ne),window.removeEventListener("keyup",ue),window.removeEventListener("blur",J),J()}},[f,e]),lg(()=>{ce(c)},[c]),E(j,{className:on("border-subtle shadow-down-lg w-[39.375rem] overflow-hidden rounded-lg border pointer-events-auto",h),style:{backgroundColor:`color-mix(in srgb, var(--color-bg-alt-1) ${Math.max(0,Math.min(100,ve))}%, transparent)`},children:[E(me,{className:"border-subtle items-center justify-between gap-4 border-b px-3",children:[p(Au,{className:"min-h-0 flex-1",variant:"line",value:f,onValueChange:J=>{bP.includes(J)&&m(J)},children:E(Tu,{children:[p(Hi,{value:"button",children:u("move.amr.rightPanel.controlPanel.tab.button")}),p(Hi,{value:"point",children:u("move.amr.rightPanel.controlPanel.tab.point")}),p(Hi,{value:"manual",children:u("move.amr.rightPanel.controlPanel.tab.linear")})]})}),E(me,{className:"h-8 shrink-0 items-center gap-2",children:[p("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:u("move.amr.rightPanel.controlPanel.transparency")}),E("p",{className:"typo-compact-xs2-semibold text-fg-default w-8 text-right",children:[ve,"%"]}),p(Zg,{value:[ve],min:0,max:100,step:1,onValueChange:J=>{const ne=J[0];ce(ne),d(ne)},className:"w-24"}),p(qn,{icon:p(Pa,{}),variant:"transparent",size:"2xs",onClick:t})]})]}),E(j,{className:"p-3 pb-3.5",children:[f==="button"&&E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs2-normal text-fg-information",children:u("move.amr.rightPanel.controlPanel.button.description")}),E(me,{className:"items-end gap-4",children:[E(j,{className:"min-w-0 flex-1 gap-2.5",children:[E(me,{className:"items-start gap-3",children:[E("p",{className:"typo-compact-xs2-medium text-fg-subtler shrink-0",children:[u("move.amr.rightPanel.controlPanel.linearMotion.line1"),p("br",{}),u("move.amr.rightPanel.controlPanel.linearMotion.line2")]}),E("div",{className:"grid flex-1 grid-cols-3 gap-1",children:[E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:u("move.amr.rightPanel.controlPanel.speedMs")}),p(un,{size:"xs2",type:"number",value:s,className:"!w-full",onChange:J=>{a(Number.parseFloat(J.target.value)||0)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:u("move.amr.rightPanel.controlPanel.accelMs2")}),p(un,{size:"xs2",type:"number",value:g,className:"!w-full",disabled:!0,onChange:J=>{b(J.target.value)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:u("move.amr.rightPanel.controlPanel.decelMs2")}),p(un,{size:"xs2",type:"number",value:y,className:"!w-full",disabled:!0,onChange:J=>{w(J.target.value)}})]})]})]}),E(me,{className:"items-start gap-3",children:[E("p",{className:"typo-compact-xs2-medium text-fg-subtler shrink-0",children:[u("move.amr.rightPanel.controlPanel.angularMotion.line1"),p("br",{}),u("move.amr.rightPanel.controlPanel.angularMotion.line2")]}),E("div",{className:"grid flex-1 grid-cols-3 gap-1",children:[E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:u("move.amr.rightPanel.controlPanel.speedDegS")}),p(un,{size:"xs2",type:"number",value:o,className:"!w-full",onChange:J=>{l(Number.parseFloat(J.target.value)||0)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:u("move.amr.rightPanel.controlPanel.accelDegS2")}),p(un,{size:"xs2",type:"number",value:_,className:"!w-full",disabled:!0,onChange:J=>{R(J.target.value)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:u("move.amr.rightPanel.controlPanel.decelDegS2")}),p(un,{size:"xs2",type:"number",value:T,className:"!w-full",disabled:!0,onChange:J=>{P(J.target.value)}})]})]})]})]}),E(j,{className:"w-[8.25rem] shrink-0 items-center gap-1.5",children:[E("div",{className:"grid grid-cols-[2.5rem_2.5rem_2.5rem] grid-rows-2 gap-1.5",children:[p("div",{className:"size-10"}),p(qn,{variant:"soft",icon:p($v,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("forward"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")}),p("div",{className:"size-10"}),p(qn,{variant:"soft",icon:p(Qv,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("left"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")}),p(qn,{variant:"soft",icon:p(Jv,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("backward"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")}),p(qn,{variant:"soft",icon:p(Cu,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("right"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")})]}),E("div",{className:"grid w-full grid-cols-2 gap-1.5",children:[p(We,{leadingIcon:p(ey,{}),size:"xs",variant:"soft",className:"typo-compact-xs-semibold h-7 w-full",onMouseDown:()=>e("rotateLeft"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop"),children:u("move.amr.rightPanel.controlPanel.left")}),p(We,{leadingIcon:p(ty,{}),size:"xs",variant:"soft",className:"typo-compact-xs-semibold h-7 w-full",onMouseDown:()=>e("rotateRight"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop"),children:u("move.amr.rightPanel.controlPanel.right")})]})]})]})]}),f==="point"&&E(j,{className:"justify-between gap-2",children:[p("p",{className:"typo-compact-xs2-normal text-fg-information",children:u("move.amr.rightPanel.controlPanel.point.description")}),E(j,{className:"gap-3",children:[E("div",{className:"grid grid-cols-4 gap-2",children:[E(j,{className:"min-w-0 gap-1.5",children:[E(me,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-medium text-fg-danger",children:"X"}),p("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(m)"})]}),p(un,{size:"xs2",type:"number",className:"!w-full",value:M,onChange:J=>{x(J.target.value)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[E(me,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-medium text-fg-success",children:"Y"}),p("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(m)"})]}),p(un,{size:"xs2",type:"number",className:"!w-full",value:S,onChange:J=>{C(J.target.value)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[E(me,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-medium text-fg-brand",children:"Z"}),p("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(m)"})]}),p(un,{size:"xs2",type:"number",className:"!w-full",value:k,onChange:J=>{I(J.target.value)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[E(me,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-medium text-fg-debug",children:"Theta"}),p("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(°)"})]}),p(un,{size:"xs2",type:"number",className:"!w-full",value:G,onChange:J=>{q(J.target.value)}})]})]}),E(me,{className:"items-center justify-between gap-3",children:[E(me,{className:"min-w-0 items-center gap-0.5",children:[p(Pu,{className:"text-fg-subtle size-3.5 shrink-0"}),p("p",{className:"typo-compact-xs2-normal text-fg-subtle min-w-0 truncate",children:u("move.amr.rightPanel.controlPanel.currentPose",{x:r.x.toFixed(2),y:r.y.toFixed(2),yaw:r.yaw.toFixed(1)})})]}),p(We,{size:"xs2",variant:"brand",className:"h-8 w-32 !px-3",onClick:Q,children:u("move.amr.rightPanel.controlPanel.moveToPoint")})]})]})]}),f==="manual"&&E(j,{className:"justify-between gap-2",children:[p("p",{className:"typo-compact-xs2-normal text-fg-information",children:u("move.amr.rightPanel.controlPanel.linear.description")}),E(j,{className:"gap-3",children:[E("div",{className:"grid grid-cols-3 gap-2",children:[E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.controlPanel.axis")}),E("div",{className:"grid grid-cols-2 gap-1.5",children:[p(We,{variant:O==="x"?"brand":"soft",size:"xs2",className:"h-8 w-full !px-3",onClick:()=>{W("x")},children:"X"}),p(We,{variant:O==="y"?"brand":"soft",size:"xs2",className:"h-8 w-full !px-3",onClick:()=>{W("y")},children:"Y"})]})]}),E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.controlPanel.targetM")}),p(un,{size:"xs2",type:"number",className:"!w-full",value:Z,onChange:J=>{K(J.target.value)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.controlPanel.speedMs")}),p(un,{size:"xs2",type:"number",className:"!w-full",value:oe,onChange:J=>{te(J.target.value)}})]})]}),p(me,{className:"justify-end",children:p(We,{size:"xs2",variant:"brand",className:"h-8 w-32 !px-3",onClick:re,children:u("move.amr.rightPanel.controlPanel.executeMove")})})]})]})]})]})},{memo:vP}=await wt("react"),yP=(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%)`}},hg=r=>typeof r!="number"||Number.isNaN(r)?"-":r.toFixed(3),xP=r=>typeof r!="number"||Number.isNaN(r)?"-":`${(r*180/Math.PI).toFixed(3)}°`,_P=({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?E(j,{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:yP(a,o)},children:[E(me,{className:"items-center justify-between gap-3",children:[E(me,{className:"min-w-0 items-center",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-subtler mr-3",children:"Name"}),p("span",{className:"typo-compact-sm-semibold text-fg-default truncate",children:l})]}),c&&p(qn,{className:"pointer-events-auto",variant:"transparent",size:"2xs","aria-label":"Edit node",icon:p(Ru,{}),onClick:c})]}),E(me,{className:"flex flex-wrap gap-x-7",children:[E("p",{className:"whitespace-nowrap",children:[p("span",{className:"text-fg-danger typo-compact-sm2-semibold mr-3",children:"X"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:hg(n)})]}),E("p",{className:"whitespace-nowrap",children:[p("span",{className:"text-fg-success typo-compact-sm2-semibold mr-3",children:"Y"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:hg(i)})]}),E("p",{className:"whitespace-nowrap",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-information mr-3",children:"RZ"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:xP(s)})]})]}),(d||h)&&E(me,{className:"pointer-events-auto mt-3 gap-2",children:[d&&p(We,{variant:"danger",size:"sm",onClick:d,children:"Delete"}),h&&p(We,{variant:"soft",size:"sm",onClick:h,children:"Move To Node"})]})]}):null,CN=vP(_P),{memo:wP}=await wt("react"),SP=(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%)`}},MP=r=>typeof r!="number"||Number.isNaN(r)?"-":r.toFixed(2),EP=({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?E(j,{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:SP(l,c)},children:[n.length>1&&p(me,{className:"pointer-events-auto mb-2 gap-1.5",children:n.map((u,f)=>{const m=u.id===h.id;return p("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)})}),E(me,{className:"items-center justify-between gap-3",children:[E(me,{className:"min-w-0 items-center",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-subtler mr-3",children:"Link"}),p("span",{className:"typo-compact-sm-semibold text-fg-default truncate",children:h.title})]}),a&&p(qn,{className:"pointer-events-auto",variant:"transparent",size:"2xs","aria-label":"Edit link",icon:p(Ru,{}),onClick:a})]}),E(me,{className:"flex flex-wrap gap-x-7",children:[E("p",{className:"whitespace-nowrap",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-warning mr-3",children:"DIR"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.dir})]}),E("p",{className:"whitespace-nowrap",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-brand mr-3",children:"METHOD"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.method})]}),E("p",{className:"whitespace-nowrap",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-success mr-3",children:"SPEED"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:MP(h.speed)})]})]}),o&&p(me,{className:"pointer-events-auto mt-3 gap-2",children:p(We,{variant:"danger",size:"sm",onClick:o,children:"Delete"})})]}):null},PN=wP(EP),{memo:TP}=await wt("react"),AP=(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%)`}},CP=({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?E(j,{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:AP(l,c)},children:[n.length>1&&p(me,{className:"pointer-events-auto mb-2 gap-1.5",children:n.map((u,f)=>{const m=u.id===h.id;return p("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)})}),E(me,{className:"items-center justify-between gap-3",children:[E(me,{className:"min-w-0 items-center",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-subtler mr-3",children:"Zone"}),p("span",{className:"typo-compact-sm-semibold text-fg-default truncate",children:h.title})]}),a&&p(qn,{className:"pointer-events-auto",variant:"transparent",size:"2xs","aria-label":"Edit zone",icon:p(Ru,{}),onClick:a})]}),E(me,{className:"flex flex-wrap gap-x-7",children:[E("p",{className:"whitespace-nowrap",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-warning mr-3",children:"TYPE"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.type})]}),E("p",{className:"whitespace-nowrap",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-brand mr-3",children:"POINTS"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.pointCount})]})]}),o&&p(me,{className:"pointer-events-auto mt-3 gap-2",children:p(We,{variant:"danger",size:"sm",onClick:o,children:"Delete"})})]}):null},RN=TP(CP),{memo:PP,useCallback:Qd,useEffect:ug,useRef:cr,useState:Jd}=await wt("react"),jl={width:630,height:320},Xl={width:420,height:180},fg=24,pg=(r,e,t)=>Math.min(Math.max(r,e),t),RP=({cameras:r,onClose:e,onQualityChange:t,transparency:n=80})=>{const{t:i}=en(),[s,a]=Jd({x:0,y:0}),[o,l]=Jd(jl),[c,d]=Jd(null),h=cr(null),u=cr({x:0,y:0}),f=cr(jl),m=cr(!1),v=cr(!1),g=cr({mouseX:0,mouseY:0,panelX:0,panelY:0}),b=cr({mouseX:0,mouseY:0,panelX:0,panelY:0,width:jl.width,height:jl.height}),y=r.find(T=>T.id===c&&T.status==="live"&&T.streamUrl),w=Qd(T=>{T.preventDefault(),!v.current&&(m.current=!0,document.body.style.cursor="grabbing",g.current={mouseX:T.clientX,mouseY:T.clientY,panelX:u.current.x,panelY:u.current.y})},[]),_=Qd(T=>{T.preventDefault(),T.stopPropagation();const P=h.current?.getBoundingClientRect();v.current=!0,document.body.style.cursor="se-resize",document.body.style.userSelect="none",b.current={mouseX:T.clientX,mouseY:T.clientY,panelX:u.current.x,panelY:u.current.y,width:P?.width??f.current.width,height:P?.height??f.current.height}},[]),R=Qd(T=>{d(T)},[]);return ug(()=>{const T=M=>{if(m.current){const x=g.current.panelX+(M.clientX-g.current.mouseX),S=g.current.panelY+(M.clientY-g.current.mouseY);u.current={x,y:S},h.current&&(h.current.style.transform=`translate(${x}px, ${S}px)`)}if(v.current){const x=pg(b.current.width+(M.clientX-b.current.mouseX),Xl.width,Math.max(Xl.width,window.innerWidth-fg)),S=pg(b.current.height+(M.clientY-b.current.mouseY),Xl.height,Math.max(Xl.height,window.innerHeight-fg)),C={width:x,height:S},k={x:b.current.panelX+(x-b.current.width),y:b.current.panelY+(S-b.current.height)};f.current=C,u.current=k,l(C),a(k)}},P=()=>{const M=m.current,x=v.current;M&&(m.current=!1,document.body.style.cursor="",a({...u.current})),x&&(v.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return window.addEventListener("mousemove",T),window.addEventListener("mouseup",P),()=>{window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",P),document.body.style.cursor="",document.body.style.userSelect=""}},[]),ug(()=>{c&&!r.some(T=>T.id===c)&&d(null)},[r,c]),E("div",{className:"pointer-events-auto",children:[p(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:!!y,onOpenChange:T=>{T||d(null)},header:{title:y?.name??i("move.amr.rightPanel.cameraPanel.title")},children:y&&p("div",{className:"!bg-alt-2 flex h-full flex-col justify-between",children:p("div",{className:"bg-base-black h-[calc(var(--vh,1vh)*70)] overflow-hidden",children:p(Tf,{className:"bg-base-black h-full w-full overflow-hidden [&_video]:object-cover",url:y.streamUrl??"",label:y.name,lebelPosition:"top-left",initStatus:!0,disconnectedMessage:i("move.amr.rightPanel.cameraPanel.disconnected"),loadingMessage:i("move.amr.rightPanel.cameraPanel.connecting")})})})}),E("div",{ref:h,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,n))}%, transparent)`,transform:`translate(${s.x}px, ${s.y}px)`,width:o.width,height:o.height},children:[E("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:[E("div",{className:"typo-compact-xs2-semibold flex flex-1 items-center justify-start gap-1",children:[p("span",{className:"text-fg-default",children:i("move.amr.rightPanel.cameraPanel.title")}),p("span",{className:"text-fg-brand",children:r.length})]}),p(qn,{icon:p(Pa,{}),variant:"transparent",size:"2xs",onClick:e})]}),r.length===0?p("div",{className:"min-h-0 flex-1 px-3 pt-2 pb-3.5",children:p(_r,{className:"h-full rounded-md [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:p(_h,{className:"text-fg-subtlest size-5"}),message:i("move.amr.rightPanel.cameraPanel.empty")})}):p("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:p("div",{className:"flex h-full w-max min-w-full items-start gap-2",children:r.map(T=>E("div",{className:"inline-flex h-full shrink-0 flex-col gap-1.5",children:[E("div",{className:"flex items-center gap-1 px-0.5",children:[p("div",{className:"flex size-3 items-center justify-center",children:p(gi,{color:T.status==="live"?"green":"red"})}),p("span",{className:"text-fg-default typo-compact-xs2-semibold pr-2",children:T.name}),p("div",{onClick:P=>P.stopPropagation(),children:p(dc,{className:"min-w-20",size:"xs2",value:T.quality,handleChange:P=>{typeof P=="string"&&t?.(T.camId,P)},children:T.qualityOptions.map(P=>p(es,{value:P,children:P},P))})}),p("span",{className:"text-fg-subtler typo-compact-xs-normal ml-auto",children:T.resolution})]}),T.status==="live"&&T.streamUrl?p("div",{className:"bg-base-black border-subtle h-52 w-96 cursor-pointer overflow-hidden rounded-md border",onClick:P=>{P.stopPropagation(),R(T.id)},children:p(Tf,{className:"bg-base-black h-full w-full overflow-hidden [&_video]:object-cover",url:T.streamUrl??"",label:T.name,lebelPosition:"top-left",initStatus:!0,disconnectedMessage:i("move.amr.rightPanel.cameraPanel.disconnected"),loadingMessage:i("move.amr.rightPanel.cameraPanel.connecting")})}):E("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:[p(_h,{className:"text-fg-subtlest size-5"}),p("span",{className:"text-fg-subtler typo-compact-xs-normal",children:i("move.amr.rightPanel.cameraPanel.disconnected")})]})]},T.id))})}),p("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:_,children:p("span",{className:"border-fg-subtlest block size-2.5 border-r-2 border-b-2 opacity-70"})})]})]})},NN=PP(RP),{memo:NP,useEffect:io,useMemo:mg,useRef:eh,useState:th}=await wt("react"),DP=["static","dynamic","virtual","collision"],LP={static:[148,163,184,160],dynamic:[59,130,246,190],virtual:[168,85,247,180],collision:[239,68,68,210]},IP=320,nh=.5,ih=4,gg=.25,wc=(r,e,t)=>Math.max(e,Math.min(t,r)),bg=(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:wc(t.x,-n,n),y:wc(t.y,-i,i)}},vg=(r,e)=>(r%e+e)%e,kP=(()=>{const r=new ArrayBuffer(4),e=new Uint32Array(r),t=new Uint8Array(r);return e[0]=168496141,t[0]===13})(),OP=(r,e,t,n)=>kP?n<<24|t<<16|e<<8|r:r<<24|e<<16|t<<8|n,FP=(r,e)=>{const t=Math.max(r,1),n=Math.max(e,1),i=Math.max(t,n),s=Math.max(1,Math.floor(IP/i)),a=t*s,o=n*s;return{safeWidth:t,safeHeight:n,scale:s,canvasWidth:a,canvasHeight:o,centerX:a/2,centerY:o/2}},yg=(r,e)=>{r.width!==e.canvasWidth&&(r.width=e.canvasWidth),r.height!==e.canvasHeight&&(r.height=e.canvasHeight)},UP=(r,e)=>{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("Waiting for obstacle map data",e.canvasWidth/2,e.canvasHeight/2)},BP=(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=vg(e.centerX+n.x,s),o=vg(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()},zP=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=OP(o,l,c,d),m=new Uint32Array(u.buffer);for(let v=0;v<m.length;v+=1){if(!(u[v*4]>0)){m[v]=0;continue}m[v]=f}return a.putImageData(h,0,0),s}catch{return null}},HP=(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)},GP=(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,v)=>{const g=o(d),b=o(h),y=l(f),w=l(u);r.fillStyle=m,r.strokeStyle=v,r.lineWidth=1,r.fillRect(g,y,b-g,w-y),r.strokeRect(g,y,b-g,w-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)")},VP=(r,e,t,n,i,s)=>{if(!(t>0))return;const a=n.scale*i,o=w=>n.centerX+s.x+w/t*a,l=w=>n.centerY+s.y-w/t*a,c=o(e.obsBoxMinX),d=o(e.obsBoxMaxX),h=l(e.obsBoxMaxY),u=l(e.obsBoxMinY),f=d-c,m=u-h,v=(c+d)/2,g=(h+u)/2,b=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(v,g),r.lineTo(v+b,g),r.stroke(),r.beginPath(),r.moveTo(v+b,g),r.lineTo(v+b-5,g-2.5),r.lineTo(v+b-5,g+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(v,g),r.lineTo(v,g-y),r.stroke(),r.beginPath(),r.moveTo(v,g-y),r.lineTo(v-2.5,g-y+5),r.lineTo(v+2.5,g-y+5),r.closePath(),r.fill(),r.restore()},WP=(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()},jP=({layers:r,width:e,height:t,gridSize:n,safety:i,loading:s=!1,onClose:a,transparency:o=80,className:l})=>{const c=eh(null),d=eh(null),h=eh(null),[u,f]=th(1),[m,v]=th({x:0,y:0}),[g,b]=th([]),y=r.length,w=mg(()=>r.map(S=>S.name).join(", "),[r]),_=mg(()=>FP(e,t),[t,e]),R=e>0&&t>0?`${e} x ${t}`:"-",T=n>0?`${n.toFixed(3)} m/px`:"-",P=`${Math.round(u*100)}%`,M=u>1,x=s?"Waiting for stream":e>0&&t>0?y>0?"Live":"No active layers":"Idle";return io(()=>{v(S=>bg(_,u,S))},[_,u]),io(()=>{let S=!1;if(e<=0||t<=0||r.length===0){b([]);return}const C=DP.map(k=>({layerName:k,layer:r.find(I=>I.name===k)})).filter(k=>!!k.layer&&k.layer.data.length>0);return(async()=>{const k=await Promise.all(C.map(async({layerName:I,layer:G})=>{const q=await zP(G.data,e,t,LP[I]);return{layerName:I,tintedLayerCanvas:q}}));S||b(k.filter(I=>I.tintedLayerCanvas!==null))})(),()=>{S=!0}},[t,r,e]),io(()=>{const S=c.current,C=d.current;S&&yg(S,_),C&&yg(C,_)},[_]),io(()=>{const S=c.current;if(!S)return;const C=S.getContext("2d");if(!C)return;C.imageSmoothingEnabled=!1;const k=document.createElement("canvas");k.width=_.canvasWidth,k.height=_.canvasHeight;const I=k.getContext("2d");if(I){if(I.imageSmoothingEnabled=!1,e<=0||t<=0){UP(I,_),C.clearRect(0,0,_.canvasWidth,_.canvasHeight),C.drawImage(k,0,0);return}BP(I,_,u,m);for(const{tintedLayerCanvas:G}of g)HP(I,G,_,u,m);C.clearRect(0,0,_.canvasWidth,_.canvasHeight),C.drawImage(k,0,0)}},[g,t,_,m,e,u]),io(()=>{const S=d.current;if(!S)return;const C=S.getContext("2d");C&&(C.imageSmoothingEnabled=!1,C.clearRect(0,0,_.canvasWidth,_.canvasHeight),!(e<=0||t<=0)&&(GP(C,i,n,_,u,m),VP(C,i,n,_,u,m),WP(C,_)))},[n,t,e,i,_,m,u]),E(j,{className:on("border-subtle shadow-down-lg w-[25rem] overflow-hidden rounded-lg border pointer-events-auto",l),style:{backgroundColor:`color-mix(in srgb, var(--color-bg-alt-1) ${Math.max(0,Math.min(100,o))}%, transparent)`},children:[E(me,{className:"border-subtle items-center justify-between gap-4 border-b px-3 py-2.5",children:[E(me,{className:"min-w-0 items-center gap-2",children:[p("div",{className:"bg-fill-information-subtle flex size-8 shrink-0 items-center justify-center rounded-md",children:p(qg,{className:"text-fg-information size-4"})}),E(j,{className:"min-w-0 gap-0.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:"Obstacle Map"}),p("p",{className:"typo-compact-xs2-normal text-fg-subtle truncate",children:"Real-time 2D canvas preview"})]})]}),p(qn,{icon:p(Pa,{}),variant:"transparent",size:"2xs",onClick:a})]}),E(j,{className:"gap-3 p-3",children:[E("div",{className:on("bg-bg-default border-subtle relative aspect-square overflow-hidden rounded-md border",M?"touch-none cursor-grab active:cursor-grabbing":"cursor-default"),onPointerDown:S=>{!M||S.target instanceof Element&&S.target.closest("button")||(h.current={pointerId:S.pointerId,startX:S.clientX,startY:S.clientY,startPanX:m.x,startPanY:m.y},S.currentTarget.setPointerCapture(S.pointerId))},onPointerMove:S=>{const C=h.current;!C||C.pointerId!==S.pointerId||v(bg(_,u,{x:C.startPanX+S.clientX-C.startX,y:C.startPanY+S.clientY-C.startY}))},onPointerUp:S=>{h.current?.pointerId===S.pointerId&&(h.current=null,S.currentTarget.releasePointerCapture(S.pointerId))},onPointerCancel:S=>{h.current?.pointerId===S.pointerId&&(h.current=null,S.currentTarget.releasePointerCapture(S.pointerId))},children:[E(me,{className:"absolute top-3 right-3 z-10 gap-1.5 rounded-md bg-black/45 p-1 backdrop-blur-sm",children:[p(qn,{icon:p(Gg,{}),variant:"transparent",size:"2xs",disabled:u===1&&m.x===0&&m.y===0,onClick:()=>{f(1),v({x:0,y:0})}}),p(qn,{icon:p(jg,{}),variant:"transparent",size:"2xs",disabled:u<=nh,onClick:()=>{f(S=>{const C=wc(S-gg,nh,ih);return C<=1&&v({x:0,y:0}),C})}}),p(We,{size:"2xs",variant:"soft",disabled:!0,className:"min-w-14 justify-center",children:P}),p(qn,{icon:p(Wg,{}),variant:"transparent",size:"2xs",disabled:u>=ih,onClick:()=>{f(S=>wc(S+gg,nh,ih))}})]}),p("canvas",{ref:c,className:"absolute inset-0 h-full w-full [image-rendering:pixelated]"}),p("canvas",{ref:d,className:"pointer-events-none absolute inset-0 h-full w-full [image-rendering:pixelated]"}),p("div",{className:"absolute inset-x-3 bottom-3",children:E(me,{className:"justify-between rounded-md bg-black/45 px-2.5 py-2 backdrop-blur-sm",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-xs2-normal text-white/70",children:"Status"}),p("p",{className:"typo-compact-xs2-semibold text-white",children:x})]}),E(j,{className:"items-end gap-0.5",children:[p("p",{className:"typo-compact-xs2-normal text-white/70",children:"Grid"}),p("p",{className:"typo-compact-xs2-semibold text-white",children:R})]})]})})]}),E(me,{className:"flex-wrap gap-2",children:[p(We,{size:"2xs",variant:"soft",disabled:!0,children:T}),E(We,{size:"2xs",variant:"soft",disabled:!0,children:[y," Layers"]}),w?p(We,{size:"2xs",variant:"soft",disabled:!0,children:w}):null]})]})]})},DN=NP(jP),{useCallback:XP,useRef:qP}=await wt("react"),LN=({amrStatus:r,robotVersion:e,selectedTool:t="select",onToolChange:n,onInitLocalization:i,onSemiAutoInitLocalization:s,onStopLocalization:a,onBuildInfoOpenChange:o})=>{const{t:l}=en(),c=qP(null),d=M=>{const x=Number(M);return Number.isFinite(x)?x:0},h=r?.power?.batPercent??0,u=r?.locState?.locStatus??"none",f=r?.autoMove??"none",m=r?.obsState??"none",v=r?.operatingMode??"none",g=d(r?.pose?.x),b=d(r?.pose?.y),y=d(r?.pose?.z),w=d(r?.pose?.rz),_=r?.vel?Math.hypot(r.vel.vx??0,r.vel.vy??0):0,R=[{label:l("move.amr.rightPanel.overview.buildInfo.branch"),value:e?.gitBranch},{label:l("move.amr.rightPanel.overview.buildInfo.commit"),value:e?.gitCommit},{label:l("move.amr.rightPanel.overview.buildInfo.buildUser"),value:e?.gitAuthor},{label:l("move.amr.rightPanel.overview.buildInfo.buildDate"),value:e?.buildDate}],T=XP(()=>{c.current||(a(),c.current=window.setTimeout(()=>{c.current=null},300))},[a]),P=M=>M>50?"text-fg-success":M>20?"text-fg-caution":"text-fg-danger";return E(j,{className:"overflow-y-auto",children:[E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.overview.battery.title")}),E(me,{className:"flex items-center",children:[p("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:l("move.amr.rightPanel.overview.battery.chargeLevel")}),E(me,{className:"ml-auto flex items-center gap-1.5",children:[p("div",{className:"bg-fill-subtlest h-1.5 w-20 rounded-sm",children:p("div",{className:`h-1.5 rounded-full transition-all ${h>50?"bg-fill-success":h>20?"bg-fill-caution":"bg-fill-danger"}`,style:{width:`${h}%`}})}),E("p",{className:`typo-compact-xs2-medium ${P(h)}`,children:[h,"%"]})]})]})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.overview.localization.title")}),E(j,{className:"gap-2 rounded",children:[E(me,{className:"bg-fill-disabled items-center justify-between rounded-md p-3",children:[E(me,{className:"items-center gap-1",children:[p(ya,{className:"text-fg-subtle h-4 w-4"}),p("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:l("move.amr.rightPanel.overview.localization.positionTracking")})]}),E(me,{className:"items-center gap-1.5",children:[p(gi,{color:u!=="none"?"green":"gray"}),p("p",{className:"typo-compact-sm-semibold text-fg-default uppercase",children:u})]})]}),E(me,{className:"items-center justify-between gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:l("move.amr.rightPanel.overview.localization.cursor")}),p(xa,{size:"default",checked:t==="target",onCheckedChange:M=>{n?.(M?"target":"select")}})]}),E(me,{className:"gap-2",children:[p(We,{variant:"danger",leadingIcon:p(Yg,{}),className:"w-24",onClick:T,children:l("move.amr.rightPanel.common.stop")}),p(We,{variant:"brand",className:"flex-1",onClick:i,children:l("move.amr.rightPanel.overview.localization.start")})]}),p(We,{variant:"outlined",onClick:s,children:l("move.amr.rightPanel.overview.localization.semiAutoInit")}),E(me,{className:"items-start gap-1",children:[p("div",{className:"flex size-4 shrink-0 items-center justify-center",children:p(Pu,{className:"text-fg-subtlest size-3"})}),p("p",{className:"typo-compact-xs-normal text-fg-subtler flex-1",children:l("move.amr.rightPanel.overview.localization.description")})]})]})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.overview.moveStatus.title")}),E("div",{className:"bg-fill-disabled grid grid-cols-2 gap-x-3 gap-y-3 rounded-md px-3 py-3",children:[E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.overview.moveStatus.autoMove")}),E(me,{className:"items-center gap-1.5",children:[p(Eu,{className:`h-3 w-3 ${_u(f)}`}),p("p",{className:"typo-compact-xs2-medium text-fg-default",children:f})]})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.overview.moveStatus.operationMode")}),p("p",{className:`typo-compact-xs2-medium uppercase ${v==="auto"?"text-fg-information":v==="manual"?"text-fg-caution":"text-fg-subtler"}`,children:v})]})]}),E(me,{className:"bg-fill-disabled items-center justify-between rounded-md p-3",children:[p("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:l("move.amr.rightPanel.hud.obstacleDetect")}),E(me,{className:"items-center gap-1.5",children:[p(zg,{className:`h-3 w-3 ${Av(m)}`}),p("p",{className:"typo-compact-sm-semibold text-fg-default",children:m})]})]})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("label",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.overview.robotTransform.title")}),E("div",{className:"space-y-2",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtle",children:l("move.amr.rightPanel.overview.robotTransform.position")}),E("div",{className:"mt-2 flex items-center gap-4",children:[E("div",{className:"flex min-w-0 flex-1 items-center gap-4",children:[p("span",{className:"typo-compact-xs2-medium text-fg-danger uppercase",children:"X"}),E("span",{className:"typo-compact-xs2-normal text-fg-default font-mono",children:[g.toFixed(3)," m"]})]}),E("div",{className:"flex min-w-0 flex-1 items-center gap-4",children:[p("span",{className:"typo-compact-xs2-medium text-fg-success uppercase",children:"Y"}),E("span",{className:"typo-compact-xs2-normal text-fg-default font-mono",children:[b.toFixed(3)," m"]})]}),E("div",{className:"flex min-w-0 flex-1 items-center gap-4",children:[p("span",{className:"typo-compact-xs2-medium text-fg-brand uppercase",children:"Z"}),E("span",{className:"typo-compact-xs2-normal text-fg-default font-mono",children:[y.toFixed(3)," m"]})]})]}),E("div",{className:"flex items-center gap-4",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtle flex-1",children:l("move.amr.rightPanel.overview.robotTransform.rotation")}),p("span",{className:"typo-compact-xs-normal text-fg-subtle flex-1",children:l("move.amr.rightPanel.common.speed")})]}),E("div",{className:"flex items-center gap-4",children:[E("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[p("span",{className:"typo-compact-xs2-normal text-fg-danger uppercase",children:"RZ"}),E("span",{className:"typo-compact-xs2-normal text-fg-default",children:[w.toFixed(3),"°"]})]}),p("div",{className:"flex min-w-0 flex-1 items-center",children:E("span",{className:"typo-compact-xs2-normal text-fg-default",children:[_.toFixed(2)," m/s"]})})]})]})]}),p(j,{className:"border-subtler border-b px-1",children:p(ha,{handleOpenChange:M=>{o?.(M)},title:p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.overview.buildInfo.title")}),children:p("div",{className:"bg-fill-disabled flex w-full flex-col items-start justify-start gap-2 rounded-md p-2 px-2.5",children:R.map(M=>E("div",{className:"flex w-full items-center justify-between gap-3",children:[p("div",{className:"text-fg-subtle shrink-0 text-xs leading-4 font-normal",children:M.label}),p("div",{className:"text-fg-default min-w-0 truncate text-right text-xs leading-4 font-normal",children:M.value||"-"})]},M.label))})})})]})},{useEffect:so,useMemo:sh,useRef:xg,useState:Ji}=await wt("react"),ZP=[{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"}],YP=[{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}],KP=r=>typeof r=="boolean"?Number(r):r??0,_g=(r,e)=>(r&1<<e)!==0,wg=(r,e)=>typeof r!="number"||!Number.isFinite(r)?"-":`${r}${e}`,Pv=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)},$P=r=>{const e=Pv(r.bits);if(e)return{...r,bits:e}},Sg=(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)??""},QP=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=Pv(n.bits);i&&e.push({key:n.key,label:n.label,mcu:n.mcu,kind:n.kind,bits:i})}return e},ql=(r,e,t)=>r.find(n=>n.mcu===e&&n.kind===t),Mg=r=>r?.map(e=>e.value),Rv=r=>r?`0x${r.reduce((t,n)=>n.value?t|1<<n.pin:t,0).toString(16).toUpperCase().padStart(2,"0")}`:"-",Zl=r=>r?r.map(e=>({...e})):void 0,Eg=r=>r?.map(e=>e.pin).join(",")??"",Tg=({label:r,onClick:e})=>p(We,{variant:"outlined",className:"!typo-compact-xs-normal text-fg-subtle",size:"2xs",onClick:e,children:r}),Nv=({pin:r,active:e,disabled:t=!1,onClick:n})=>{const i=on("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?p("button",{type:"button",className:i,disabled:t,onClick:n,children:p("span",{className:"typo-compact-2xs-semibold leading-none",children:r})}):p("div",{className:i,children:p("span",{className:"typo-compact-2xs-semibold leading-none",children:r})})},JP=({label:r,bits:e})=>E(j,{className:"gap-1",children:[E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtle",children:r}),p("span",{className:"typo-compact-xs-semibold text-fg-subtle font-mono",children:Rv(e)})]}),e?p("div",{className:"grid w-full gap-1",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(t=>p(Nv,{pin:t.pin,active:t.value},t.pin))}):p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"-"})]}),eR=({label:r,bits:e,disabled:t,onToggle:n})=>E(j,{className:"gap-1",children:[E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtle",children:r}),p("span",{className:"typo-compact-xs-semibold text-fg-subtle font-mono",children:Rv(e)})]}),e?p("div",{className:"grid w-full gap-1",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((i,s)=>p(Nv,{pin:i.pin,active:i.value,disabled:t,onClick:()=>n(s)},i.pin))}):p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"-"})]}),IN=({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:v}=en(),g=r?.motor??[],b=g.length>0,y=b&&g.every(Ne=>!!Ne.status),w=b?!y:!1,_=!!r?.robotState?.emo,R=r?.chargeState?.charge??"",T=r?.chargeState?.dockId??"",P=r?.chargeState?.dockResult??"",M=!!r?.chargeState?.dock,x=R.trim()==="charging",S=!!r?.robotState?.sfOperationalStop,C=r?.robotState?.lidarField??null,k=xg(null);so(()=>{k.current===null&&C!=null&&(k.current=C)},[C]);const[I,G]=Ji(""),[q,O]=Ji(!1),[W,Z]=Ji(null);so(()=>{Z(null)},[C]);const K=q?I:String(W??k.current??C??0),oe=!!r?.robotState?.detectMode,[te,ve]=Ji(null);so(()=>{ve(null)},[oe]);const[ce,Q]=Ji(null),[re,J]=Ji(!1),[ne,ue]=Ji(!1),Te=ce??w;so(()=>{Q(null)},[w]);const _e=sh(()=>a?.rows?.length?a.rows.map($P).filter(Ne=>!!Ne):QP(a),[a]),fe=sh(()=>({mcu0Din:ql(_e,0,"din")?.bits,mcu1Din:ql(_e,1,"din")?.bits,mcu0Dio:ql(_e,0,"dio")?.bits,mcu1Dio:ql(_e,1,"dio")?.bits}),[_e]),be=sh(()=>_e.filter(Ne=>Ne.kind==="dio"&&(Ne.mcu===0||Ne.mcu===1)),[_e]),Ce=_e.length>0,[X,Be]=Ji({}),[Me,et]=Ji(!1),[Se,Ye]=Ji(!1),ee=`${Eg(fe.mcu0Dio)}|${Eg(fe.mcu1Dio)}`,U=xg(null);so(()=>{!fe.mcu0Dio||!fe.mcu1Dio||U.current!==ee&&(U.current=ee,Be({mcu0Din:Zl(fe.mcu0Dio),mcu1Din:Zl(fe.mcu1Dio)}),et(!1))},[ee,fe.mcu0Dio,fe.mcu1Dio]);const A=X.mcu0Din,Y=X.mcu1Din,V=!!l&&!!fe.mcu0Dio&&!!fe.mcu1Dio&&!!A&&!!Y,$=V&&Me,le=!V||o||Se,Ie=(Ne,Oe)=>{if(le||!A||!Y)return;const ht=Zl(A),at=Zl(Y);!ht||!at||(Ne===0?ht[Oe]={...ht[Oe],value:!ht[Oe].value}:at[Oe]={...at[Oe],value:!at[Oe].value},Be({mcu0Din:ht,mcu1Din:at}),et(!0))},we=Ne=>{if(Ne===0)return A;if(Ne===1)return Y},ze=Ne=>Sg(Ne.label,m),pt=async()=>{if(!(!l||!A||!Y||!$)){Ye(!0);try{await l({mcu0Din:Mg(A)??[],mcu1Din:Mg(Y)??[]}),et(!1)}catch{f?.()}finally{Ye(!1)}}},Pe=async()=>{if(e){J(!0);try{await e(!1),Q(!1),t?.({motorLock:!1}),c?.()}catch{h?.()}finally{J(!1)}}},Ue=()=>{O(!1),G("")},Qe=async()=>{const Ne=Number(I);if(Number.isNaN(Ne))O(!1);else{Z(Ne),O(!1);try{await i?.(Ne),d?.()}catch{Z(null),u?.()}}};return E("div",{className:"h-full min-h-0",children:[p("div",{className:"border-subtler border-b p-3",children:E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.emergencyStop")}),E("div",{className:"flex items-center gap-2",children:[p(gi,{color:_?"red":"green"}),p("span",{className:"typo-compact-xs-semibold text-fg-default",children:v(_?"move.amr.rightPanel.common.triggered":"move.amr.rightPanel.common.normal")})]})]})}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[E("button",{type:"button",className:"flex w-full items-center justify-between gap-2 text-left","aria-expanded":ne,onClick:()=>ue(Ne=>!Ne),children:[p("span",{className:"flex min-w-0 items-center",children:p("span",{className:"typo-compact-sm2-semibold text-fg-default truncate",children:v("move.amr.rightPanel.pdu.motorStatus")})}),E("div",{className:"flex shrink-0 items-center gap-2",children:[p(gi,{color:Te?"red":"green"}),p("span",{className:"typo-compact-xs-semibold text-fg-default",children:v(Te?"move.amr.rightPanel.common.disconnected":"move.amr.rightPanel.common.connected")}),ne?p(iy,{className:"text-fg-subtle size-3.5 shrink-0"}):p(sy,{className:"text-fg-subtle size-3.5 shrink-0"})]})]}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.motor")}),p(xa,{checked:!Te,disabled:!Te||re,onCheckedChange:Ne=>{Ne&&Pe()}})]}),ne&&p(j,{className:"gap-2 pt-1",children:g.length===0?p("span",{className:"typo-compact-xs-normal text-fg-disabled",children:"No motor data"}):g.map((Ne,Oe)=>{const ht=KP(Ne.status),at=_g(ht,0),Lt=!!Ne.connection;return E(j,{className:"border-subtle bg-alt-1 gap-2 rounded border p-2",children:[E("div",{className:"flex items-center justify-between",children:[E("span",{className:"typo-compact-sm2-semibold text-fg-default",children:["Motor ",Oe+1]}),E("div",{className:"flex items-center gap-2",children:[p(gi,{color:Lt?"green":"red"}),p("span",{className:"typo-compact-xs-semibold text-fg-default",children:Lt?"Connected":"Disconnected"})]})]}),E(j,{className:"bg-raised gap-2 rounded p-2",children:[E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Running"}),E("div",{className:"flex items-center gap-2",children:[p(gi,{color:at?"green":"red"}),p("span",{className:"typo-compact-xs-semibold text-fg-default",children:at?"On":"Off"})]})]}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Temperature"}),p("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:wg(Ne.temp,"°C")})]}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Current"}),p("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:wg(Ne.current,"A")})]})]}),E(j,{className:"gap-1",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Status Flags"}),p("div",{className:"grid grid-cols-2 gap-1.5",children:YP.map(se=>{const Ve=_g(ht,se.bit),ye=Ve?se.normalWhenActive?"green":"red":"gray";return E("div",{className:"bg-fill-disabled flex items-center justify-between gap-2 rounded px-2 py-1",children:[p("span",{className:"typo-compact-2xs-normal text-fg-subtle truncate",children:se.label}),p(ry,{type:"soft",color:ye,children:Ve?"On":"Off"})]},se.key)})})]})]},Oe)})})]}),E("div",{className:"border-subtler flex flex-col gap-1.5 border-b p-3",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.chargeContact")}),E("div",{className:"space-y-2",children:[E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.charge")}),E("div",{className:"flex items-center gap-2",children:[p(gi,{color:x?"green":"red"}),p("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:v(x?"move.amr.rightPanel.common.true":"move.amr.rightPanel.common.false")})]})]}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.dock")}),E("div",{className:"flex items-center gap-2",children:[p(gi,{color:M?"green":"red"}),p("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:v(M?"move.amr.rightPanel.common.true":"move.amr.rightPanel.common.false")})]})]}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.dockResult")}),p("span",{className:"typo-compact-xs-normal text-fg-subtle font-mono",children:P||"-"})]}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.dockId")}),p("span",{className:"typo-compact-xs-normal text-fg-subtle font-mono",children:T||"-"})]})]})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.safetyRecovery")}),p("div",{className:"space-y-2",children:ZP.map(({key:Ne,labelKey:Oe,robotStateKey:ht})=>{const at=!!r?.robotState?.[ht];return E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:v(Oe)}),E("div",{className:"flex items-center gap-3",children:[E("div",{className:"flex items-center gap-2",children:[p(gi,{color:at?"red":"green"}),p("span",{className:"typo-compact-xs-semibold text-fg-default w-7 text-right",children:v(at?"move.amr.rightPanel.common.trig":"move.amr.rightPanel.common.none")})]}),p(Tg,{label:v("move.amr.rightPanel.common.clear"),onClick:()=>n?.(Ne)})]})]},Oe)})})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.opMode")}),p("div",{className:"space-y-2",children:E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.opModeRestoration")}),E("div",{className:"flex items-center gap-2",children:[p(gi,{color:S?"red":"green"}),p("span",{className:"typo-compact-xs-semibold text-fg-default w-7 text-right",children:v(S?"move.amr.rightPanel.common.trig":"move.amr.rightPanel.common.none")}),p(Tg,{label:v("move.amr.rightPanel.common.clear"),onClick:()=>n?.("operationStop")})]})]})})]}),Ce&&E(j,{className:"border-subtler gap-3 border-b p-3",children:[E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:"Safety I/O"}),o&&p("span",{className:"typo-compact-2xs-normal text-fg-subtle",children:v("move.amr.rightPanel.pdu.safetyIo.pending")})]}),E(j,{className:"gap-2",children:[p("div",{className:"flex items-center justify-between gap-2",children:p("span",{className:"typo-compact-xs-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.safetyIo.read")})}),p(j,{className:"gap-2",children:_e.map(Ne=>p(JP,{label:Sg(Ne.label,m),bits:Ne.bits},Ne.key))})]}),be.length>0&&E(j,{className:"gap-2",children:[E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-xs-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.safetyIo.outputControl")}),p("div",{className:"flex items-center gap-1",children:p(We,{variant:"brand",size:"2xs",disabled:!$||le,onClick:pt,children:v("move.amr.rightPanel.pdu.safetyIo.apply")})})]}),p(j,{className:"gap-2",children:be.map(Ne=>p(eR,{label:ze(Ne),bits:we(Ne.mcu),disabled:le,onToggle:Oe=>{(Ne.mcu===0||Ne.mcu===1)&&Ie(Ne.mcu,Oe)}},`${Ne.key}-control`))})]})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.lidarField")}),q&&E("div",{className:"flex items-center gap-1",children:[p(We,{variant:"outlined",size:"2xs",onClick:Ue,children:v("move.amr.rightPanel.common.reset")}),p(We,{variant:"brand",size:"2xs",onClick:Qe,children:v("move.amr.rightPanel.common.save")})]})]}),p(cn,{className:"w-full",type:"number",size:"sm",value:K,handleChange:Ne=>{G(Ne!==void 0?String(Ne):""),O(!0)}})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:"OSSD"}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.detect")}),p(xa,{checked:te??oe,onCheckedChange:Ne=>{const Oe=te??oe;ve(Ne),s?.(Ne)?.catch(()=>ve(Oe))}})]})]})]})},{useMemo:tR}=await wt("react"),nR=({className:r,currentNode:e,targetNode:t,moveStatus:n})=>{const{t:i}=en(),s=tR(()=>n==="move"||n==="vir"||n==="moving",[n]);return E("div",{className:on("AMRNodeFromTo","relative pl-7",r),children:[E(j,{className:on("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:[E(j,{children:[p("span",{children:i("move.amr.rightPanel.task.currentNode")}),p("div",{className:"text-fg-subtle truncate",children:e||"-"})]}),E(j,{children:[p("span",{children:i("move.amr.rightPanel.task.targetNode")}),p("div",{className:"text-fg-subtle truncate",children:t||"-"})]})]}),p(iR,{className:"w-7",isMoving:s,children:p("span",{className:"moving-dot"})})]})},iR=Mc("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(
|
|
4515
|
+
`)},e}static getTerrain(e,t,n){const{rScaler:i,bScaler:s,gScaler:a,offset:o}=n,l=t+1,c=new Float32Array(l*l);for(let d=0,h=0;h<t;h++)for(let u=0;u<t;u++,d++){const f=d*4,m=e[f+0],v=e[f+1],g=e[f+2];c[d+h]=m*i+v*a+g*s+o}for(let d=l*(l-1),h=0;h<l-1;h++,d++)c[d]=c[d-l];for(let d=l-1,h=0;h<l;h++,d+=l)c[d]=c[d-1];return c}static getMeshAttributes(e,t,n,i,s){const a=n+1,o=e.length/2,l=new Float32Array(o*3),c=new Float32Array(o*2),[d,h,u,f]=i||[0,0,n,n],m=(u-d)/n,v=(f-h)/n;for(let g=0;g<o;g++){const b=e[g*2],y=e[g*2+1],w=y*a+b;l[3*g+0]=b*m+d,l[3*g+1]=-t[w]*s,l[3*g+2]=-y*v+f,c[2*g+0]=b/n,c[2*g+1]=y/n}return{position:{value:l,size:3},uv:{value:c,size:2}}}processHeight(e){return Mn(this,void 0,void 0,function*(){const t=e.width,n=t+1;var i=_f.createOffscreenCanvas(t,t),s=i.getContext("2d");s.imageSmoothingEnabled=!1,s.drawImage(e,0,0,t,t,0,0,i.width,i.height);var a=s.getImageData(0,0,i.width,i.height),o=a.data;const l=Ai.getTerrain(o,t,this.elevationDecoder),d=new gC(n).createTile(l),{vertices:h,triangles:u}=d.getMesh(typeof this.meshMaxError=="function"?this.meshMaxError(this.level):this.meshMaxError),f=Ai.getMeshAttributes(h,l,t,[-.5,-.5,.5,.5],this.exageration);this.geometry=new mt,this.geometry.setIndex(new ju(u,1)),this.geometry.setAttribute("position",new Fe(f.position.value,f.position.size)),this.geometry.setAttribute("uv",new Fe(f.uv.value,f.uv.size)),this.geometry.rotateX(Math.PI);var m=new Bt(e);m.generateMipmaps=!1,m.format=Zn,m.magFilter=Sn,m.minFilter=Sn,m.needsUpdate=!0,this.material.userData.heightMap.value=m,this.material.map=m,this.material.needsUpdate=!0})}loadHeightGeometry(){return Mn(this,void 0,void 0,function*(){if(this.mapView.heightProvider===null)throw new Error("GeoThree: MapView.heightProvider provider is null.");const e=yield this.mapView.heightProvider.fetchTile(this.level,this.x,this.y);this.disposed||(this.processHeight(e),this.heightLoaded=!0,this.nodeReady())})}}Ai.geometrySize=16;Ai.emptyTexture=new Bt;Ai.geometry=new Ts(1,1,1,1);Ai.tileSize=256;class Fn extends Ae{constructor(e=Fn.PLANAR,t=new fC,n=null){super(void 0,new jt({transparent:!0,opacity:0,depthWrite:!1,colorWrite:!1})),this.lod=null,this.provider=null,this.heightProvider=null,this.root=null,this.cacheTiles=!1,this.onBeforeRender=(i,s,a,o,l,c)=>{this.lod.updateLOD(this,a,i,s)},this.lod=new mC,this.provider=t,this.heightProvider=n,this.setRoot(e),this.preSubdivide()}setRoot(e){if(typeof e=="number"){if(!Fn.mapModes.has(e))throw new Error("Map mode "+e+" does is not registered.");const t=Fn.mapModes.get(e);e=new t(null,this)}this.root!==null&&(this.remove(this.root),this.root=null),this.root=e,this.root!==null&&(this.geometry=this.root.constructor.baseGeometry,this.scale.copy(this.root.constructor.baseScale),this.root.mapView=this,this.add(this.root),this.root.initialize())}preSubdivide(){var e,t;function n(s,a){if(!(a<=0)){s.subdivide();for(let o=0;o<s.children.length;o++)if(s.children[o]instanceof Xn){const l=s.children[o];n(l,a-1)}}}const i=Math.max(this.provider.minZoom,(t=(e=this.heightProvider)===null||e===void 0?void 0:e.minZoom)!==null&&t!==void 0?t:-1/0);i>0&&n(this.root,i)}setProvider(e){e!==this.provider&&(this.provider=e,this.clear())}setHeightProvider(e){e!==this.heightProvider&&(this.heightProvider=e,this.clear())}clear(){return this.traverse(function(e){e.childrenCache&&(e.childrenCache=null),e.initialize&&e.initialize()}),this}minZoom(){var e,t;return Math.max(this.provider.minZoom,(t=(e=this.heightProvider)===null||e===void 0?void 0:e.minZoom)!==null&&t!==void 0?t:-1/0)}maxZoom(){var e,t;return Math.min(this.provider.maxZoom,(t=(e=this.heightProvider)===null||e===void 0?void 0:e.maxZoom)!==null&&t!==void 0?t:1/0)}getMetaData(){this.provider.getMetaData()}raycast(e,t){return!1}}Fn.PLANAR=200;Fn.SPHERICAL=201;Fn.HEIGHT=202;Fn.HEIGHT_SHADER=203;Fn.MARTINI=204;Fn.mapModes=new Map([[Fn.PLANAR,Di],[Fn.SPHERICAL,Tr],[Fn.HEIGHT,qi],[Fn.HEIGHT_SHADER,jn],[Fn.MARTINI,Ai]]);new L;new L;new ke;new L;new Cc;new L;class Mv{static get(e){return Mn(this,void 0,void 0,function*(){return new Promise(function(t,n){const i=new XMLHttpRequest;i.overrideMimeType("text/plain"),i.open("GET",e,!0),i.onload=function(){t(i.response)},i.onerror=n,i.send(null)})})}static getRaw(e){return Mn(this,void 0,void 0,function*(){return new Promise(function(t,n){var i=new XMLHttpRequest;i.responseType="arraybuffer",i.open("GET",e,!0),i.onload=function(){t(i.response)},i.onerror=n,i.send(null)})})}static request(e,t,n,i,s,a,o){function l(d){try{return JSON.parse(d)}catch{return d}}const c=new XMLHttpRequest;if(c.overrideMimeType("text/plain"),c.open(t,e,!0),n!=null)for(const d in n)c.setRequestHeader(d,n[d]);return s!==void 0&&(c.onload=function(d){s(l(c.response),c)}),a!==void 0&&(c.onerror=a),o!==void 0&&(c.onprogress=o),c.send(i!==void 0?i:null),c}}class ns extends Oo{constructor(e="",t=ns.AERIAL){super(),this.maxZoom=19,this.minZoom=1,this.format="jpeg",this.mapSize=512,this.subdomain="t1",this.meta=null,this.apiKey=e,this.type=t}getMetaData(){return Mn(this,void 0,void 0,function*(){const e=ns.ADDRESS+"/REST/V1/Imagery/Metadata/RoadOnDemand?output=json&include=ImageryProviders&key="+this.apiKey,t=yield Mv.get(e);this.meta=JSON.parse(t)})}static quadKey(e,t,n){let i="";for(let s=e;s>0;s--){const a=1<<s-1;let o=0;(t&a)!==0&&o++,(n&a)!==0&&(o+=2),i+=o}return i}fetchTile(e,t,n){return new Promise((i,s)=>{const a=document.createElement("img");a.onload=function(){i(a)},a.onerror=function(){s()},a.crossOrigin="Anonymous",a.src="http://ecn."+this.subdomain+".tiles.virtualearth.net/tiles/"+this.type+ns.quadKey(e,t,n)+".jpeg?g=1173"})}}ns.ADDRESS="https://dev.virtualearth.net";ns.AERIAL="a";ns.ROAD="r";ns.AERIAL_LABELS="h";ns.OBLIQUE="o";ns.OBLIQUE_LABELS="b";class vC extends Oo{constructor(e="",t="",n="base",i="normal.day",s="png",a=512){super(),this.appId=e,this.appCode=t,this.style=n,this.scheme=i,this.format=s,this.size=a,this.version="newest",this.server=1}nextServer(){this.server=this.server%4===0?1:this.server+1}getMetaData(){return Mn(this,void 0,void 0,function*(){})}fetchTile(e,t,n){return this.nextServer(),new Promise((i,s)=>{const a=document.createElement("img");a.onload=function(){i(a)},a.onerror=function(){s()},a.crossOrigin="Anonymous",a.src="https://"+this.server+"."+this.style+".maps.api.here.com/maptile/2.1/maptile/"+this.version+"/"+this.scheme+"/"+e+"/"+t+"/"+n+"/"+this.size+"/"+this.format+"?app_id="+this.appId+"&app_code="+this.appCode})}}vC.PATH="/maptile/2.1/";class vs extends Oo{constructor(e="",t="",n=vs.STYLE,i="png",s=!1,a="v4"){super(),this.apiToken=e,this.format=i,this.useHDPI=s,this.mode=n,this.mapId=t,this.style=t,this.version=a}getMetaData(){return Mn(this,void 0,void 0,function*(){const e=vs.ADDRESS+this.version+"/"+this.mapId+".json?access_token="+this.apiToken,t=yield Mv.get(e),n=JSON.parse(t);this.name=n.name,this.minZoom=n.minZoom,this.maxZoom=n.maxZoom,this.bounds=n.bounds,this.center=n.center})}fetchTile(e,t,n){return new Promise((i,s)=>{const a=document.createElement("img");a.onload=function(){i(a)},a.onerror=function(){s()},a.crossOrigin="Anonymous",this.mode===vs.STYLE?a.src=vs.ADDRESS+"styles/v1/"+this.style+"/tiles/"+e+"/"+t+"/"+n+(this.useHDPI?"@2x?access_token=":"?access_token=")+this.apiToken:a.src=vs.ADDRESS+"v4/"+this.mapId+"/"+e+"/"+t+"/"+n+(this.useHDPI?"@2x.":".")+this.format+"?access_token="+this.apiToken})}}vs.ADDRESS="https://api.mapbox.com/";vs.STYLE=100;vs.MAP_ID=101;class yC extends Oo{mapName;isMsa;constructor(){super();const e=Gv("api_mode");this.isMsa=e!=="legacy"}fetchTile(e,t,n){if(this.mapName)return new Promise((i,s)=>{this.loadTileImage(e,t,n,i,s)})}loadTileImage(e,t,n,i,s){const a=document.createElement("img");a.onload=()=>i(a),a.onerror=()=>s(),a.crossOrigin="anonymous",this.isMsa?a.src=`${Vv}/map/tiles/${this.mapName}/${e}/${t}/${n}`:a.src=`${Wv}/api/map/tiles/${this.mapName}/${e}/${t}/${n}`}setMapName(e){this.mapName=e}}class xC{tileProvider;mapView;editor;constructor(e){const t=new yC;t.minZoom=0,t.maxZoom=25;const n=new Fn(Fn.PLANAR,t);n.position.set(0,0,-.2),n.rotation.x=Math.PI/2,this.editor=e,this.mapView=n,this.tileProvider=t}dispose=()=>{this.deregisterEventListeners()};handleMapName=e=>{this.tileProvider.setMapName(e)};registerEventListeners=()=>{const e=this.editor.eventHandler.eventBus;e.on("setTileVisibility",this.handleToggleTile),e.on("updatemapNameData",this.handleMapName)};deregisterEventListeners=()=>{const e=this.editor.eventHandler.eventBus;e.off("setTileVisibility",this.handleToggleTile),e.off("updatemapNameData",this.handleMapName)};handleToggleTile=e=>{e?this.addToScene():this.removeToScene()};addToScene=()=>{this.editor.scene.add(this.mapView)};removeToScene=()=>{this.editor.scene.remove(this.mapView)}}const _C=16711680;class wC{constructor(e){this.editor=e,this.group=new Vt,this.group.name="trajectory-group",this.group.renderOrder=Rn.PATH,this.group.userData.keep=!0,this.group.visible=!1}group;boxes=[];baseGeometry=null;baseMaterial=null;clear(){this.group.visible=!1,this.boxes.forEach(e=>{e.visible=!1})}dispose(){this.clear(),this.group.parent&&this.group.parent.remove(this.group),this.boxes.length=0,this.baseGeometry?.dispose(),this.baseGeometry=null,this.baseMaterial?.dispose(),this.baseMaterial=null}ensureInitialized(){if(this.ensureGroupAddedToScene(),this.baseGeometry&&this.baseMaterial)return;const{lengthX:e,widthY:t,heightZ:n}=this.getRobotDimensions(),i=new Kt(e,t,n);this.baseGeometry=new Rc(i),i.dispose(),this.baseMaterial=new Yn({color:_C,transparent:!0,opacity:.7})}updateTrajectory(e){if(this.ensureInitialized(),!e.length){this.clear();return}const t=e.slice(-100),{heightZ:n}=this.getRobotDimensions();t.forEach((i,s)=>{const a=this.getOrCreateBox(s),[o=0,l=0,c=0]=i;a.position.set(o,l,n/2),a.rotation.set(0,0,bt.degToRad(c)),a.visible=!0});for(let i=t.length;i<this.boxes.length;i+=1)this.boxes[i].visible=!1;this.group.visible=!0}getBaseGeometry(){if(this.ensureInitialized(),!this.baseGeometry)throw new Error("[TrajectoryDrawer] Base geometry is not initialized");return this.baseGeometry}getBaseMaterial(){if(this.ensureInitialized(),!this.baseMaterial)throw new Error("[TrajectoryDrawer] Base material is not initialized");return this.baseMaterial}getGroup(){return this.ensureGroupAddedToScene(),this.group}getRobotDimensions(){const e=this.resolveRobotSpecKey(this.editor.robotType);return Es[e].dimensions}ensureGroupAddedToScene(){!this.editor.scene||this.group.parent||this.editor.scene.add(this.group)}getOrCreateBox(e){const t=this.boxes[e];if(t)return t;const n=new Pr(this.getBaseGeometry(),this.getBaseMaterial());return n.name=`trajectory-box-${e}`,n.renderOrder=Rn.PATH,n.userData.keep=!0,n.visible=!1,this.group.add(n),this.boxes[e]=n,n}resolveRobotSpecKey(e){return!e||e==="S100-B-3D"?"S100":e==="QD-RBY"?"QD":e in Es?e:"S100"}}class SC extends Vt{constructor(){super(),this.name="S100Helper",this.userData.keep=!0,this.visible=!1,this._init()}updatePosition(e){const t=this.parent.worldToLocal(e.clone());this.position.copy(t)}updateRotation(e){const t=this.parent.worldToLocal(e.clone()),n=t.x-this.position.x,i=t.y-this.position.y;this.rotation.z=Math.atan2(i,n)}_init(){const e=new Rr,t=Bn(Es.S100.modelUrl);new Promise((n,i)=>{e.load(t,s=>{const a=s.scene;console.log("[S100Helper] model loaded from",t),a.traverse(l=>{if(l.userData.keep=!0,l instanceof Ae){const c=l.material;Array.isArray(c)?l.material=c.map(()=>new On({color:new Le(12436423),transparent:!0,opacity:.3})):l.material=new On({color:new Le(12436423),transparent:!0,opacity:.15})}}),a.updateMatrixWorld(!0),a.userData.keep=!0;const o=new ka(1);o.userData.keep=!0,a.add(o),n(a)},void 0,s=>{console.error(s),i(s)})}).then(n=>{this.add(n)}).catch(n=>{console.error("Failed to load s100 model:",n)})}}class MC extends Vt{constructor(){super(),this.name="QDHelper",this.userData.keep=!0,this.visible=!1,this._init()}updatePosition(e){if(!this.parent)return;const t=this.parent.worldToLocal(e.clone());this.position.copy(t)}updateRotation(e){if(!this.parent)return;const t=this.parent.worldToLocal(e.clone()),n=t.x-this.position.x,i=t.y-this.position.y;this.rotation.z=Math.atan2(i,n)}alignToGroundZUp(e){e.updateMatrixWorld(!0);const t=new ln().setFromObject(e);e.position.z+=-t.min.z,e.updateMatrixWorld(!0)}_init(){const e=new Rr,t=new Io,n=Bn(Es.QD.modelUrl);t.setDecoderPath(Bn("/draco/")),e.setDRACOLoader(t),e.loadAsync(n).then(i=>{const s=i.scene;s.traverse(o=>{if(o.userData.keep=!0,o instanceof Ae){const l=o.material;Array.isArray(l)?o.material=l.map(c=>new On({color:c.color,transparent:!0,opacity:.3})):o.material=new On({color:l.color,transparent:!0,opacity:.3})}}),this.alignToGroundZUp(s),s.updateMatrixWorld(!0),s.userData.keep=!0;const a=new ka(1);a.userData.keep=!0,s.add(a),this.add(s)}).catch(i=>{console.error("Failed to load qd model:",i)}).finally(()=>{t.dispose()})}}class EC extends Vt{constructor(){super(),this.name="GAIAHelper",this.userData.keep=!0,this.visible=!1,this._init()}updatePosition(e){if(!this.parent)return;const t=this.parent.worldToLocal(e.clone());this.position.copy(t)}updateRotation(e){if(!this.parent)return;const t=this.parent.worldToLocal(e.clone()),n=t.x-this.position.x,i=t.y-this.position.y;this.rotation.z=Math.atan2(i,n)}alignToGroundZUp(e){e.updateMatrixWorld(!0);const t=new ln().setFromObject(e);e.position.z+=-t.min.z,e.updateMatrixWorld(!0)}_init(){const e=new Rr,t=new Io,n=Bn(Es.GAIA.modelUrl);t.setDecoderPath(Bn("/draco/")),e.setDRACOLoader(t),e.loadAsync(n).then(i=>{const s=i.scene,a=new Vt;s.traverse(l=>{if(l.userData.keep=!0,!(l instanceof Ae))return;const c=d=>{const h=new On({transparent:!0,opacity:.3});return"color"in d&&d.color instanceof Le&&h.color.copy(d.color),"map"in d&&d.map instanceof Bt&&(h.map=d.map),"side"in d&&(h.side=d.side),h};Array.isArray(l.material)?l.material=l.material.map(c):l.material=c(l.material)}),this.alignToGroundZUp(s),s.updateMatrixWorld(!0),s.userData.keep=!0,a.userData.keep=!0,a.rotation.z=Math.PI;const o=new ka(1);o.userData.keep=!0,s.add(o),a.add(s),this.add(a)}).catch(i=>{console.error("Failed to load gaia model:",i)}).finally(()=>{t.dispose()})}}const Jm={rby1a:{name:"RBY1-A-Helper",urdfPath:"/rby1a/rby1a.urdf"},rby1m:{name:"RBY1-M-Helper",urdfPath:"/rby1m/rby1m.urdf"},rby1ub:{name:"RBY1-UB-Helper",urdfPath:"/rby1ub/rby1ub.urdf"},rby2c:{name:"RBY2-C-Helper",urdfPath:"/rby2c/rby2c.urdf"}};class TC extends Vt{variant;constructor(e){super(),this.variant=e,this.name=Jm[e].name,this.userData.keep=!0,this.visible=!1,this._init()}updatePosition(e){if(!this.parent)return;const t=this.parent.worldToLocal(e.clone());this.position.copy(t)}updateRotation(e){if(!this.parent)return;const t=this.parent.worldToLocal(e.clone()),n=t.x-this.position.x,i=t.y-this.position.y;this.rotation.z=Math.atan2(i,n)}alignToGroundZUp(e){e.updateMatrixWorld(!0);const t=new ln().setFromObject(e);e.position.z+=-t.min.z,e.updateMatrixWorld(!0)}toHelperMaterial(e){const t=new On({transparent:!0,opacity:.3,depthWrite:!1});return"color"in e&&e.color instanceof Le&&t.color.copy(e.color),"map"in e&&e.map instanceof Bt&&(t.map=e.map),"side"in e&&(t.side=e.side),t}_init(){const{urdfPath:e}=Jm[this.variant],t=Bn(e),n=new Lc,i=new cf(n);let s=null,a=!1;const o=()=>{a||(a=!0)};i.loadMeshCb=av,n.onLoad=()=>{if(a)return;if(!s){o();return}s.userData.keep=!0,s.traverse(c=>{c.userData.keep=!0,c instanceof Ae&&(Array.isArray(c.material)?c.material=c.material.map(d=>this.toHelperMaterial(d)):c.material=this.toHelperMaterial(c.material))}),this.alignToGroundZUp(s),s.updateMatrixWorld(!0);const l=new ka(1);l.userData.keep=!0,s.add(l),this.add(s),o()},n.onError=l=>{a||(console.warn(`[RBYHelper] Load failed: ${l}`),o())},i.load(t,l=>{a||(s=l)},void 0,l=>{a||(console.error(`Failed to load ${this.variant} helper model:`,l),o())})}}const Ev={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
4516
|
+
|
|
4517
|
+
varying vec2 vUv;
|
|
4518
|
+
|
|
4519
|
+
void main() {
|
|
4520
|
+
|
|
4521
|
+
vUv = uv;
|
|
4522
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4523
|
+
|
|
4524
|
+
}`,fragmentShader:`
|
|
4525
|
+
|
|
4526
|
+
uniform float opacity;
|
|
4527
|
+
|
|
4528
|
+
uniform sampler2D tDiffuse;
|
|
4529
|
+
|
|
4530
|
+
varying vec2 vUv;
|
|
4531
|
+
|
|
4532
|
+
void main() {
|
|
4533
|
+
|
|
4534
|
+
vec4 texel = texture2D( tDiffuse, vUv );
|
|
4535
|
+
gl_FragColor = opacity * texel;
|
|
4536
|
+
|
|
4537
|
+
|
|
4538
|
+
}`};class Fa{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const AC=new Lo(-1,1,1,-1,0,1);class CC extends mt{constructor(){super(),this.setAttribute("position",new Fe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Fe([0,2,0,0,2,0],2))}}const PC=new CC;class wf{constructor(e){this._mesh=new Ae(PC,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,AC)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class RC extends Fa{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof wn?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Na.clone(e.uniforms),this.material=new wn({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new wf(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(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 eg extends Fa{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const i=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),s.buffers.stencil.setFunc(i.ALWAYS,a,4294967295),s.buffers.stencil.setClear(o),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(i.EQUAL,1,4294967295),s.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),s.buffers.stencil.setLocked(!0)}}class NC extends Fa{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class DC{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new ge);this._width=n.width,this._height=n.height,t=new ti(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Ti}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new RC(Ev),this.copyPass.material.blending=Xi,this.clock=new sf}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let i=0,s=this.passes.length;i<s;i++){const a=this.passes[i];if(a.enabled!==!1){if(a.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),a.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),a.needsSwap){if(n){const o=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),l.setFunc(o.EQUAL,1,4294967295)}this.swapBuffers()}eg!==void 0&&(a instanceof eg?n=!0:a instanceof NC&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new ge);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(n,i),this.renderTarget2.setSize(n,i);for(let s=0;s<this.passes.length;s++)this.passes[s].setSize(n,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class xs extends Fa{constructor(e,t,n,i){super(),this.renderScene=t,this.renderCamera=n,this.selectedObjects=i!==void 0?i:[],this.visibleEdgeColor=new Le(1,1,1),this.hiddenEdgeColor=new Le(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,this._visibilityCache=new Map,this._selectionCache=new Set,this.resolution=e!==void 0?new ge(e.x,e.y):new ge(256,256);const s=Math.round(this.resolution.x/this.downSampleRatio),a=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new ti(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new Gb,this.depthMaterial.side=sn,this.depthMaterial.depthPacking=wb,this.depthMaterial.blending=Xi,this.prepareMaskMaterial=this.getPrepareMaskMaterial(),this.prepareMaskMaterial.side=sn,this.prepareMaskMaterial.fragmentShader=d(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetDepthBuffer=new ti(this.resolution.x,this.resolution.y,{type:Ti}),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new ti(s,a,{type:Ti}),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new ti(s,a,{type:Ti}),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new ti(Math.round(s/2),Math.round(a/2),{type:Ti}),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new ti(s,a,{type:Ti}),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new ti(Math.round(s/2),Math.round(a/2),{type:Ti}),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;const o=4,l=4;this.separableBlurMaterial1=this.getSeparableBlurMaterial(o),this.separableBlurMaterial1.uniforms.texSize.value.set(s,a),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeparableBlurMaterial(l),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(s/2),Math.round(a/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=l,this.overlayMaterial=this.getOverlayMaterial();const c=Ev;this.copyUniforms=Na.clone(c.uniforms),this.materialCopy=new wn({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:Xi,depthTest:!1,depthWrite:!1}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new Le,this.oldClearAlpha=1,this.fsQuad=new wf(null),this.tempPulseColor1=new Le,this.tempPulseColor2=new Le,this.textureMatrix=new ke;function d(h,u){const f=u.isPerspectiveCamera?"perspective":"orthographic";return h.replace(/DEPTH_TO_VIEW_Z/g,f+"DepthToViewZ")}}dispose(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),this.depthMaterial.dispose(),this.prepareMaskMaterial.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){this.renderTargetMaskBuffer.setSize(e,t),this.renderTargetDepthBuffer.setSize(e,t);let n=Math.round(e/this.downSampleRatio),i=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(n,i),this.renderTargetBlurBuffer1.setSize(n,i),this.renderTargetEdgeBuffer1.setSize(n,i),this.separableBlurMaterial1.uniforms.texSize.value.set(n,i),n=Math.round(n/2),i=Math.round(i/2),this.renderTargetBlurBuffer2.setSize(n,i),this.renderTargetEdgeBuffer2.setSize(n,i),this.separableBlurMaterial2.uniforms.texSize.value.set(n,i)}updateSelectionCache(){const e=this._selectionCache;function t(n){n.isMesh&&e.add(n)}e.clear();for(let n=0;n<this.selectedObjects.length;n++)this.selectedObjects[n].traverse(t)}changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;for(const n of this._selectionCache)e===!0?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e)}changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,n=this._selectionCache;function i(s){if(s.isMesh||s.isSprite){if(!n.has(s)){const a=s.visible;(e===!1||t.get(s)===!0)&&(s.visible=e),t.set(s,a)}}else(s.isPoints||s.isLine)&&(e===!0?s.visible=t.get(s):(t.set(s,s.visible),s.visible=e))}this.renderScene.traverse(i)}updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,n,i,s){if(this.selectedObjects.length>0){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const a=e.autoClear;e.autoClear=!1,s&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this.updateSelectionCache(),this.changeVisibilityOfSelectedObjects(!1);const o=this.renderScene.background,l=this.renderScene.overrideMaterial;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this.updateTextureMatrix(),this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this._selectionCache.clear(),this.renderScene.background=o,this.renderScene.overrideMaterial=l,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const c=.625+Math.cos(performance.now()*.01/this.pulsePeriod)*.75/2;this.tempPulseColor1.multiplyScalar(c),this.tempPulseColor2.multiplyScalar(c)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=xs.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=xs.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=xs.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=xs.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,s&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=a}this.renderToScreen&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}getPrepareMaskMaterial(){return new wn({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new ge(.5,.5)},textureMatrix:{value:null}},vertexShader:`#include <morphtarget_pars_vertex>
|
|
4539
|
+
#include <skinning_pars_vertex>
|
|
4540
|
+
|
|
4541
|
+
varying vec4 projTexCoord;
|
|
4542
|
+
varying vec4 vPosition;
|
|
4543
|
+
uniform mat4 textureMatrix;
|
|
4544
|
+
|
|
4545
|
+
void main() {
|
|
4546
|
+
|
|
4547
|
+
#include <skinbase_vertex>
|
|
4548
|
+
#include <begin_vertex>
|
|
4549
|
+
#include <morphtarget_vertex>
|
|
4550
|
+
#include <skinning_vertex>
|
|
4551
|
+
#include <project_vertex>
|
|
4552
|
+
|
|
4553
|
+
vPosition = mvPosition;
|
|
4554
|
+
|
|
4555
|
+
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
4556
|
+
|
|
4557
|
+
#ifdef USE_INSTANCING
|
|
4558
|
+
|
|
4559
|
+
worldPosition = instanceMatrix * worldPosition;
|
|
4560
|
+
|
|
4561
|
+
#endif
|
|
4562
|
+
|
|
4563
|
+
worldPosition = modelMatrix * worldPosition;
|
|
4564
|
+
|
|
4565
|
+
projTexCoord = textureMatrix * worldPosition;
|
|
4566
|
+
|
|
4567
|
+
}`,fragmentShader:`#include <packing>
|
|
4568
|
+
varying vec4 vPosition;
|
|
4569
|
+
varying vec4 projTexCoord;
|
|
4570
|
+
uniform sampler2D depthTexture;
|
|
4571
|
+
uniform vec2 cameraNearFar;
|
|
4572
|
+
|
|
4573
|
+
void main() {
|
|
4574
|
+
|
|
4575
|
+
float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));
|
|
4576
|
+
float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );
|
|
4577
|
+
float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;
|
|
4578
|
+
gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);
|
|
4579
|
+
|
|
4580
|
+
}`})}getEdgeDetectionMaterial(){return new wn({uniforms:{maskTexture:{value:null},texSize:{value:new ge(.5,.5)},visibleEdgeColor:{value:new L(1,1,1)},hiddenEdgeColor:{value:new L(1,1,1)}},vertexShader:`varying vec2 vUv;
|
|
4581
|
+
|
|
4582
|
+
void main() {
|
|
4583
|
+
vUv = uv;
|
|
4584
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4585
|
+
}`,fragmentShader:`varying vec2 vUv;
|
|
4586
|
+
|
|
4587
|
+
uniform sampler2D maskTexture;
|
|
4588
|
+
uniform vec2 texSize;
|
|
4589
|
+
uniform vec3 visibleEdgeColor;
|
|
4590
|
+
uniform vec3 hiddenEdgeColor;
|
|
4591
|
+
|
|
4592
|
+
void main() {
|
|
4593
|
+
vec2 invSize = 1.0 / texSize;
|
|
4594
|
+
vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);
|
|
4595
|
+
vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);
|
|
4596
|
+
vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);
|
|
4597
|
+
vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);
|
|
4598
|
+
vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);
|
|
4599
|
+
float diff1 = (c1.r - c2.r)*0.5;
|
|
4600
|
+
float diff2 = (c3.r - c4.r)*0.5;
|
|
4601
|
+
float d = length( vec2(diff1, diff2) );
|
|
4602
|
+
float a1 = min(c1.g, c2.g);
|
|
4603
|
+
float a2 = min(c3.g, c4.g);
|
|
4604
|
+
float visibilityFactor = min(a1, a2);
|
|
4605
|
+
vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;
|
|
4606
|
+
gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);
|
|
4607
|
+
}`})}getSeparableBlurMaterial(e){return new wn({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new ge(.5,.5)},direction:{value:new ge(.5,.5)},kernelRadius:{value:1}},vertexShader:`varying vec2 vUv;
|
|
4608
|
+
|
|
4609
|
+
void main() {
|
|
4610
|
+
vUv = uv;
|
|
4611
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4612
|
+
}`,fragmentShader:`#include <common>
|
|
4613
|
+
varying vec2 vUv;
|
|
4614
|
+
uniform sampler2D colorTexture;
|
|
4615
|
+
uniform vec2 texSize;
|
|
4616
|
+
uniform vec2 direction;
|
|
4617
|
+
uniform float kernelRadius;
|
|
4618
|
+
|
|
4619
|
+
float gaussianPdf(in float x, in float sigma) {
|
|
4620
|
+
return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
|
|
4621
|
+
}
|
|
4622
|
+
|
|
4623
|
+
void main() {
|
|
4624
|
+
vec2 invSize = 1.0 / texSize;
|
|
4625
|
+
float sigma = kernelRadius/2.0;
|
|
4626
|
+
float weightSum = gaussianPdf(0.0, sigma);
|
|
4627
|
+
vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;
|
|
4628
|
+
vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);
|
|
4629
|
+
vec2 uvOffset = delta;
|
|
4630
|
+
for( int i = 1; i <= MAX_RADIUS; i ++ ) {
|
|
4631
|
+
float x = kernelRadius * float(i) / float(MAX_RADIUS);
|
|
4632
|
+
float w = gaussianPdf(x, sigma);
|
|
4633
|
+
vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);
|
|
4634
|
+
vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);
|
|
4635
|
+
diffuseSum += ((sample1 + sample2) * w);
|
|
4636
|
+
weightSum += (2.0 * w);
|
|
4637
|
+
uvOffset += delta;
|
|
4638
|
+
}
|
|
4639
|
+
gl_FragColor = diffuseSum/weightSum;
|
|
4640
|
+
}`})}getOverlayMaterial(){return new wn({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:`varying vec2 vUv;
|
|
4641
|
+
|
|
4642
|
+
void main() {
|
|
4643
|
+
vUv = uv;
|
|
4644
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4645
|
+
}`,fragmentShader:`varying vec2 vUv;
|
|
4646
|
+
|
|
4647
|
+
uniform sampler2D maskTexture;
|
|
4648
|
+
uniform sampler2D edgeTexture1;
|
|
4649
|
+
uniform sampler2D edgeTexture2;
|
|
4650
|
+
uniform sampler2D patternTexture;
|
|
4651
|
+
uniform float edgeStrength;
|
|
4652
|
+
uniform float edgeGlow;
|
|
4653
|
+
uniform bool usePatternTexture;
|
|
4654
|
+
|
|
4655
|
+
void main() {
|
|
4656
|
+
vec4 edgeValue1 = texture2D(edgeTexture1, vUv);
|
|
4657
|
+
vec4 edgeValue2 = texture2D(edgeTexture2, vUv);
|
|
4658
|
+
vec4 maskColor = texture2D(maskTexture, vUv);
|
|
4659
|
+
vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);
|
|
4660
|
+
float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;
|
|
4661
|
+
vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;
|
|
4662
|
+
vec4 finalColor = edgeStrength * maskColor.r * edgeValue;
|
|
4663
|
+
if(usePatternTexture)
|
|
4664
|
+
finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);
|
|
4665
|
+
gl_FragColor = finalColor;
|
|
4666
|
+
}`,blending:Mh,depthTest:!1,depthWrite:!1,transparent:!0})}}xs.BlurDirectionX=new ge(1,0);xs.BlurDirectionY=new ge(0,1);const LC={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
|
4667
|
+
precision highp float;
|
|
4668
|
+
|
|
4669
|
+
uniform mat4 modelViewMatrix;
|
|
4670
|
+
uniform mat4 projectionMatrix;
|
|
4671
|
+
|
|
4672
|
+
attribute vec3 position;
|
|
4673
|
+
attribute vec2 uv;
|
|
4674
|
+
|
|
4675
|
+
varying vec2 vUv;
|
|
4676
|
+
|
|
4677
|
+
void main() {
|
|
4678
|
+
|
|
4679
|
+
vUv = uv;
|
|
4680
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4681
|
+
|
|
4682
|
+
}`,fragmentShader:`
|
|
4683
|
+
|
|
4684
|
+
precision highp float;
|
|
4685
|
+
|
|
4686
|
+
uniform sampler2D tDiffuse;
|
|
4687
|
+
|
|
4688
|
+
#include <tonemapping_pars_fragment>
|
|
4689
|
+
#include <colorspace_pars_fragment>
|
|
4690
|
+
|
|
4691
|
+
varying vec2 vUv;
|
|
4692
|
+
|
|
4693
|
+
void main() {
|
|
4694
|
+
|
|
4695
|
+
gl_FragColor = texture2D( tDiffuse, vUv );
|
|
4696
|
+
|
|
4697
|
+
// tone mapping
|
|
4698
|
+
|
|
4699
|
+
#ifdef LINEAR_TONE_MAPPING
|
|
4700
|
+
|
|
4701
|
+
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
|
|
4702
|
+
|
|
4703
|
+
#elif defined( REINHARD_TONE_MAPPING )
|
|
4704
|
+
|
|
4705
|
+
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
|
|
4706
|
+
|
|
4707
|
+
#elif defined( CINEON_TONE_MAPPING )
|
|
4708
|
+
|
|
4709
|
+
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
|
|
4710
|
+
|
|
4711
|
+
#elif defined( ACES_FILMIC_TONE_MAPPING )
|
|
4712
|
+
|
|
4713
|
+
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
|
|
4714
|
+
|
|
4715
|
+
#elif defined( AGX_TONE_MAPPING )
|
|
4716
|
+
|
|
4717
|
+
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
|
|
4718
|
+
|
|
4719
|
+
#elif defined( NEUTRAL_TONE_MAPPING )
|
|
4720
|
+
|
|
4721
|
+
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
|
|
4722
|
+
|
|
4723
|
+
#elif defined( CUSTOM_TONE_MAPPING )
|
|
4724
|
+
|
|
4725
|
+
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
|
|
4726
|
+
|
|
4727
|
+
#endif
|
|
4728
|
+
|
|
4729
|
+
// color space
|
|
4730
|
+
|
|
4731
|
+
#ifdef SRGB_TRANSFER
|
|
4732
|
+
|
|
4733
|
+
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4734
|
+
|
|
4735
|
+
#endif
|
|
4736
|
+
|
|
4737
|
+
}`};class IC extends Fa{constructor(){super();const e=LC;this.uniforms=Na.clone(e.uniforms),this.material=new $x({name:e.name,uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader}),this.fsQuad=new wf(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={},dt.getTransfer(this._outputColorSpace)===Ht&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===ib?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===sb?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===rb?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===ab?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===lb?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===cb?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===ob&&(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 kC extends Fa{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 Le}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 vo=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 vo.Panel("FPS","#0ff","#002")),l=t(new vo.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=t(new vo.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}};vo.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,v=document.createElement("canvas");v.width=o,v.height=l,v.style.cssText="width:80px;height:48px";var g=v.getContext("2d");return g.font="bold "+9*a+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=t,g.fillRect(0,0,o,l),g.fillStyle=e,g.fillText(r,c,d),g.fillRect(h,u,f,m),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(h,u,f,m),{dom:v,update:function(b,y){n=Math.min(n,b),i=Math.max(i,b),g.fillStyle=t,g.globalAlpha=1,g.fillRect(0,0,o,u),g.fillStyle=e,g.fillText(s(b)+" "+r+" ("+s(n)+"-"+s(i)+")",c,d),g.drawImage(v,h+a,u,f-a,m,h,u,f-a,m),g.fillRect(h+f-a,u,a,m),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(h+f-a,u,a,s((1-b/y)*m))}}};const tg=16,ng=.85,OC=.9;class FC{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*tg,deltaY:e.deltaY*tg};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*ng,-t*ng),n.update()};rotateFromTrackpad=(e,t)=>{const n=2*Math.PI/this.domElement.clientHeight*this.orbit.rotateSpeed*OC,i=this.orbit;i._rotateLeft(-e*n),i._rotateUp(-t*n),i.update()}}const UC=200,BC=3,zC=4,HC=20,GC=6,ig=1,VC=.15,to=1e-6,sg=[1,3,6,12,20,40],Gl=["text-7xl","text-5xl","text-4xl","text-base","text-sm","text-xs","hidden"];class WC{constructor(e){this.editor=e}_renderCSS2D;container;scene;sceneHelpers;camera;renderer;css2DRenderer;effectComposer;selectedNodeOutlinePass;activeNodeOutlinePass;robotPos=new L;robotQuat=new Dt;lookOffset=new L;robotForward=new L;PRIMARY_MOUSE_BUTTON=0;tmpView=new L;onDownPosition=new ge;onMovePosition=new ge;onUpPosition=new ge;onDownPx=new ge;onUpPx=new ge;startPoint=new ge;endPoint=new ge;fwd=new L;right=new L;up=new L;delta=new L;focusBox=new ln;focusCenter=new L;focusSphere=new ni;focusDirection=new L;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";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 sf;const e=this.editor.canvas;if(!e)throw new Error("[Viewport] Canvas is not ready");const t=RA(e,"Viewport");if(this.renderer=new cT({antialias:!0,canvas:e,alpha:!0}),this.container=t,window.location.hostname==="localhost"){const a=new vo;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),NA(this.renderer),this.renderer.setSize(t.clientWidth,t.clientHeight),this.renderer.setAnimationLoop(this.animate),this.resizeObserver=kA(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=LA(t);const n=new kC(this.scene,this.camera);this.effectComposer=new DC(this.renderer),this.selectedNodeOutlinePass=new xs(new ge(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 xs(new ge(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 IC),this.control="orbit",this.orbit=new pA(this.editor.camera,this.renderer.domElement),this.orbit.mouseButtons={LEFT:-1,MIDDLE:yr.PAN,RIGHT:-1},this.orbit.touches={ONE:Xs.PAN,TWO:Xs.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 FC({domElement:this.renderer.domElement,orbit:this.orbit}),this.trackpadOrbitController.attach(),this.orbit.addEventListener("change",this.handleOrbitChange),this.transformControls=new fT(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 PA({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-VC;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-draft-vertex-selected",this.handleZoneDraftVertexSelected),e.on("node-manager:selection-transform-changed",this.handleObjectChanged),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("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-draft-vertex-selected",this.handleZoneDraftVertexSelected),e.off("node-manager:selection-transform-changed",this.handleObjectChanged),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("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()),IA(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 L(Number(e.x),Number(e.y),0);this.orbit.target.copy(t),this.orbit.update()}};handleLabelAdded=e=>{this.labels.push(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 ba&&(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,OA({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<sg.length;t++)if(e<sg[t])return t;return Gl.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 L,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(Gl[s.bucket],Gl[o]):l.classList.add(Gl[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(BC*devicePixelRatio,2);if(e<UC&&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,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.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)};handleObjectChanged=()=>{this.editor.nodeManager.updateArrows()};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=e=>{this.transformControls.detach(),this.editor.nodeManager.focusTopologyLinks(e.linkIds)};handleZoneSelected=e=>{this.transformControls.detach(),this.editor.nodeManager.focusTopologyZones(e.zoneIds)};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=>{if(!e.label)return;const t=e.label,n=this.labels.findIndex(i=>i.obj===t);n>-1&&this.labels.splice(n,1),this.transformControls.detach()};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 ni;new ln().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;if(e.value){if(!t||!this.editor.selectionManager.isSelectable(t)){this.transformDragStart=null;return}this.transformDragStart={object:t,position:t.position.clone(),rotation:t.rotation.clone()};return}const n=this.transformDragStart;if(this.transformDragStart=null,!n||!t||n.object!==t)return;const i=n.position.distanceTo(t.position)>to,s=Math.abs(n.rotation.x-t.rotation.x)>to||Math.abs(n.rotation.y-t.rotation.y)>to||Math.abs(n.rotation.z-t.rotation.z)>to;!i&&!s||this.editor.eventHandler.eventBus.emit("topology:changed",{source:"node-updated"})};handleEditorInitialized=()=>{this.initialize()};handleTransformcontrolsSetModeRequested=e=>{if(!this.transformControls)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=.3,s=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(i);break;case"down":this.delta.copy(this.up).multiplyScalar(-i);break;case"left":this.delta.copy(this.right).multiplyScalar(-i);break;case"right":this.delta.copy(this.right).multiplyScalar(i);break;case"zoomin":this.delta.copy(this.fwd).multiplyScalar(s),t.position.add(this.delta),n.update(),this.emitCameraChanged();return;case"zoomout":this.delta.copy(this.fwd).multiplyScalar(-s),t.position.add(this.delta),n.update(),this.emitCameraChanged();return;case"center":{const a=t.position.z,o=.001;n.target.set(0,0,0),t.position.set(o,o,a),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=ig):(this.focusBox.getCenter(this.focusCenter),this.focusBox.getBoundingSphere(this.focusSphere));const t=Math.max(this.focusSphere.radius,ig),n=bt.clamp(t*GC,zC,HC);this.focusDirection.copy(this.camera.position).sub(this.orbit.target),this.focusDirection.lengthSq()<to?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 jC{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 hC,this.eventHandler=new e1(this),this.nodeManager=new Q1(this),this.robotManager=new dC(this),this.selector=new uC(this),this.eraser=new JA(this),this.pathDrawer=new iC(this),this.trajectoryDrawer=new wC(this),this.pointsManager=new rC(this),this.tileMap=new xC(this),this.viewport=new WC(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 L(0,0,1),this.scene=new cu,this.sceneHelpers=new cu,this.camera=Ca.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 Qs(1e4,1e4),n=new jt({visible:!1}),i=new Ae(t,n);i.name="globalPlane",i.userData.keep=!0,this.globalPlane=i,this.scene.add(this.globalPlane);const s=new Cp(16777215,2105376,.5);s.userData.keep=!0,this.scene.add(s);const a=new Ic(16777215,1);a.position.set(0,0,100),a.userData.keep=!0,this.scene.add(a),this.sceneHelpers.add(new Cp(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 Da(.1),n=new jt({color:16711680}),i=new Ae(t,n);i.name="origin";const s=new ka(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(Ca),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 Ae&&(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 ba),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 MC:e==="rby1a"||e==="rby1m"||e==="rby1ub"||e==="rby2c"?t=new TC(e):e==="GAIA"||e==="QD"?t=new EC:t=new SC,this.previewHelper=t,this.scene.add(this.previewHelper)}}const Yd=r=>typeof r=="number"&&Number.isFinite(r),rg=r=>{if(!r||typeof r!="object")return!1;const e=r;return Yd(e.x)&&Yd(e.y)&&Yd(e.z)},XC=r=>{if(!r)return null;try{const e=JSON.parse(r);if(!e||typeof e!="object")return null;const t=e;return!rg(t.position)||!rg(t.target)?null:{position:t.position,target:t.target}}catch{return null}},qC=r=>{if(!r)return null;try{return XC(localStorage.getItem(r))}catch{return null}},ZC=(r,e)=>{if(r)try{localStorage.setItem(r,JSON.stringify(e))}catch{}},YC=({className:r})=>p("div",{className:on("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:p(jv,{size:"3rem"})}),{useCallback:KC,useMemo:Vl,useReducer:$C,useState:Ui}=await wt("react"),QC={state:"idle",editingZoneId:null,selectedVertexIndex:null,name:"",type:"NO_ENTRY",pointCount:0,points:[]},_c={editor:!1,viewport:!1,nodeManager:!1,robot:!1,map:!1,topo:!1};function Tv(r,e){switch(e.type){case"RESET":return _c;case"SET":return r[e.key]===e.value?r:{...r,[e.key]:e.value};case"REPLACE":return e.ready}}function TN(){const[r,e]=$C(Tv,_c),[t,n]=Ui([]),[i,s]=Ui(null),[a,o]=Ui([]),[l,c]=Ui(null),[d,h]=Ui([]),[u,f]=Ui(null),[m,v]=Ui([]),[g,b]=Ui([]),[y,w]=Ui([]),[_,R]=Ui(null),[T,P]=Ui(QC),M=KC(I=>{e({type:"REPLACE",ready:I})},[]),x=Vl(()=>t[t.length-1]??null,[t]),S=Vl(()=>{if(a.length===0)return[];const I=new Set(a);return g.filter(G=>I.has(G.id))},[g,a]),C=Vl(()=>S.length===0||!l?null:S.find(I=>I.id===l)??null,[l,S]),k=Vl(()=>({onReadyChange:M,onSelectedObjectsChange:n,onSelectedNodeTransformChange:s,onSelectedLinksChange:o,onFocusedLinkChange:c,onSelectedZonesChange:h,onFocusedZoneChange:f,onNodesChange:v,onLinksChange:b,onZonesChange:w,onMapBoundsChange:R,onZoneDraftChange:P}),[M]);return{ready:r,selectedObjects:t,selectedNodeTransform:i,selectedNode:x,selectedLinkIds:a,focusedLinkId:l,selectedLinks:S,focusedLink:C,selectedZoneIds:d,focusedZoneId:u,nodes:m,links:g,zones:y,mapBounds:_,zoneDraft:T,worldStudioStateProps:k}}const{forwardRef:JC,useCallback:wi,useEffect:hn,useImperativeHandle:eP,useMemo:tP,useReducer:nP,useRef:Wl,useState:ag}=await wt("react"),og={light:{background:"#f4f4f5",fine:5395026,coarse:5921370,xAxis:16717636,yAxis:65382},dark:{background:"#333333",fine:6052956,coarse:9079434,xAxis:16717636,yAxis:65382}},iP=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})),sP=JC(({className:r,cameraPositionKey:e,pointsData:t,topoData:n,mapCloudUpdatedAt:i,topologyUpdatedAt:s,robot:a,globalPath:o,localPath:l,trajectory:c,lidarPoints:d,mappingPoints:h,robotPose:u,selectedTool:f,showGrid:m,showNodeLabels:v,nodeRenderMode:g="default",showLidar:b,lidarPointSize:y,viewportCameraMode:w,mappingKeyFrame:_,onReadyChange:R,onSelectedObjectsChange:T,onSelectedNodeTransformChange:P,onSelectedLinksChange:M,onFocusedLinkChange:x,onSelectedZonesChange:S,onFocusedZoneChange:C,onNodesChange:k,onLinksChange:I,onZonesChange:G,onMapBoundsChange:q,onEraserHistoryInvalidated:O,onEraserSelectionChange:W,onZoneDraftChange:Z},K)=>{const{theme:oe}=Ar(),te=Wl(null),ve=Wl(null),ce=Wl(a??null),[Q,re]=ag(null),[J,ne]=nP(Tv,_c),ue=Wl(null),[Te,_e]=ag("none"),fe=tP(()=>J.editor&&J.viewport&&J.nodeManager,[J]),be=wi((V,$)=>{if(J[V]===$)return;const le={...J,[V]:$};ne({type:"SET",key:V,value:$}),R?.(le)},[J,R]),Ce=wi(()=>{ne({type:"RESET"}),R?.(_c)},[R]),X=wi(V=>{k?.(iP(V))},[k]),Be=wi(()=>{const V=te.current?.nodeManager.getTopologyLinks()??[];I?.(V)},[I]),Me=wi(()=>{const V=te.current?.nodeManager.getTopologyZones()??[];G?.(V)},[G]),et=wi(V=>{if(T?.(V.selectedObjects),!!P){if(!V.object){P(null);return}P({x:V.object.position.x,y:V.object.position.y,z:V.object.position.z,rz:bt.radToDeg(V.object.rotation.z)})}},[P,T]),Se=wi(V=>{if(!V){P?.(null);return}const $=Number(V.x),le=Number(V.y),Ie=Number(V.z),we=Number(V.rz);if([$,le,Ie,we].some(ze=>Number.isNaN(ze))){P?.(null);return}P?.({x:$,y:le,z:Ie,rz:we})},[P]),Ye=wi(V=>{q?.(V.mapBounds),be("map",!0)},[q,be]),ee=wi(V=>{M?.(V.linkIds)},[M]),U=wi(V=>{S?.(V.zoneIds)},[S]),A=wi(V=>{x?.(V.linkId)},[x]),Y=wi(V=>{C?.(V.zoneId)},[C]);return eP(K,()=>({emit:(V,$)=>{te.current?.eventHandler.eventBus.emit(V,$)},getCamera:()=>{const V=te.current;return V?.viewportCamera??V?.camera??null},getCanvas:()=>te.current?.canvas??null,getEraserRadius:()=>te.current?.getEraserRadius()??.5,getMapPointsData:()=>te.current?.pointsManager?.mapPointsData??[],getPreviewTransform:()=>{const V=te.current?.previewHelper;return V?{x:V.position.x.toString(),y:V.position.y.toString(),z:V.position.z.toString(),rz:(V.rotation.z*(180/Math.PI)).toString()}:null},getTopologyData:()=>{const V=te.current?.selectionManager.getSelectableObjects()??[],$=te.current?.nodeManager.getTopologyLinks()??[],le=te.current?.nodeManager.getTopologyZones()??[],Ie=V.map(we=>({id:typeof we.userData.id=="string"?we.userData.id:we.uuid,name:we.name,context:typeof we.userData.context=="string"?we.userData.context:"",pose:{x:we.position.x,y:we.position.y,z:we.position.z,rx:bt.radToDeg(we.rotation.x),ry:bt.radToDeg(we.rotation.y),rz:bt.radToDeg(we.rotation.z)},size:{x:0,y:0,z:0},type:typeof we.userData.type=="string"?we.userData.type:"GOAL",safetyField:typeof we.userData.safetyField=="number"?we.userData.safetyField:0,features:Array.isArray(we.userData.features)?we.userData.features.filter(pt=>typeof pt=="string"):[]}));return{format_version:BA,nodes:Ie,links:$,zones:le}},getTopologyZones:()=>te.current?.nodeManager.getTopologyZones()??[],hidePreviewHelper:()=>{const V=te.current;V&&(V.setupPreviewHelper(null),V.previewHelper.visible=!1)},moveCamera:V=>{te.current?.eventHandler.eventBus.emit("ui:camera-move-requested",V)},startZoneDraft:V=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-start-requested",V)},cancelZoneDraft:()=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-cancel-requested",void 0)},clearZoneDraft:()=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-clear-requested",void 0)},undoZoneDraft:()=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-undo-requested",void 0)},closeZoneDraft:()=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-close-requested",void 0)},reopenZoneDraft:()=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-reopen-requested",void 0)},commitZoneDraft:()=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-commit-requested",void 0)},startZoneEdit:V=>{te.current?.eventHandler.eventBus.emit("ui:zone-edit-start-requested",{zoneId:V})},focusActiveTopologyZone:V=>{te.current?.nodeManager.focusActiveTopologyZone(V)},updateZoneDraftMeta:V=>{te.current?.eventHandler.eventBus.emit("ui:zone-draft-meta-updated",V)},deleteTopologyZone:V=>{te.current?.nodeManager.deleteTopologyZone(V)},onTopologyChanged:V=>{const $=te.current?.eventHandler.eventBus;return $?($.on("topology:changed",V),()=>{$.off("topology:changed",V)}):()=>{}}}),[]),hn(()=>{te.current||(te.current=new jC);const $=te.current.eventHandler.eventBus,le=()=>be("editor",!0),Ie=()=>be("viewport",!0),we=()=>be("nodeManager",!0),ze=Qe=>{ZC(e,Qe)},pt=Qe=>{Z?.(Qe),_e(Qe.state==="drawing"?"zoneDraft":"none")},Pe=Qe=>{W?.(Qe.selectedCount)},Ue=()=>{O?.()};return $.on("editor:initialized",le),$.on("viewport:initialized",Ie),$.on("node-manager:ready",we),$.on("viewport:camera-changed",ze),$.on("points-manager:mappoints-updated",Ye),$.on("selector:object-selected",et),$.on("node-manager:selection-transform-changed",Se),$.on("selector:link-selected",ee),$.on("selector:link-focused",A),$.on("selector:zone-selected",U),$.on("selector:zone-focused",Y),$.on("topology:nodes-updated",X),$.on("node-manager:topo-updated",Be),$.on("node-manager:topo-updated",Me),$.on("eraser:history-invalidated",Ue),$.on("eraser:selection-changed",Pe),$.on("zone:draft-updated",pt),()=>{$.off("editor:initialized",le),$.off("viewport:initialized",Ie),$.off("node-manager:ready",we),$.off("viewport:camera-changed",ze),$.off("points-manager:mappoints-updated",Ye),$.off("selector:object-selected",et),$.off("node-manager:selection-transform-changed",Se),$.off("selector:link-selected",ee),$.off("selector:link-focused",A),$.off("selector:zone-selected",U),$.off("selector:zone-focused",Y),$.off("topology:nodes-updated",X),$.off("node-manager:topo-updated",Be),$.off("node-manager:topo-updated",Me),$.off("eraser:history-invalidated",Ue),$.off("eraser:selection-changed",Pe),$.off("zone:draft-updated",pt)}},[Ye,et,Se,A,Y,ee,U,x,C,O,W,Z,e,be,Be,X,Me]),hn(()=>{const V=te.current;V&&(ce.current=a??null,V.robotType=a??null)},[a]),hn(()=>{const V=te.current;if(V){if(!Q){ve.current=null;return}if(!(!Q.isConnected||!Q.parentElement)&&ve.current!==Q)return ve.current=Q,V.initialize({robotType:ce.current,canvas:Q,initialCameraState:qC(e)}),()=>{V.dispose(),ve.current=null,Ce()}}},[e,Q,Ce]),hn(()=>{const V=te.current;!fe||!V||t&&V.eventHandler.eventBus.emit("ui:map-points-update-requested",t)},[t,i,fe]),hn(()=>{const V=te.current;!fe||!V||V.pathDrawer.updateGlobalPath(o??[])},[o,fe]),hn(()=>{const V=te.current;!fe||!V||V.pathDrawer.updateLocalPath(l??[])},[l,fe]),hn(()=>{const V=te.current;!fe||!V||V.trajectoryDrawer.updateTrajectory(c??[])},[c,fe]),hn(()=>{const V=te.current;!fe||!V||V.eventHandler.eventBus.emit("ui:topo-update-requested",{topoData:n})},[n,s,fe]),hn(()=>{const V=te.current;!fe||!V||V.eventHandler.eventBus.emit("ui:grid-visibility-set-requested",m)},[m,fe]),hn(()=>{const V=te.current;!fe||!V||!w||V.eventHandler.eventBus.emit("ui:camera-mode-set-requested",w)},[fe,w]),hn(()=>{const V=te.current?.viewport;if(!fe||!V)return;const{background:$,fine:le,coarse:Ie,xAxis:we,yAxis:ze}=og[oe]??og.dark;V.setGridColors(le,Ie),V.setGridAxisColors(we,ze)},[oe,fe]),hn(()=>{const V=te.current;!fe||!V||!a||(V.robotManager.loadMainRobot(a),V.setupPreviewHelper(a))},[a,fe]),hn(()=>{const V=te.current;!fe||!V||!d||V.eventHandler.eventBus.emit("lidar:updated",{lidarPoints:d})},[d,fe]),hn(()=>{const V=te.current;if(!fe||!V||!u)return;const $=V.robotManager.mainRobot;$&&$.applyPose({x:Number(u.x??0),y:Number(u.y??0),rz:Number(u.rz??0)})},[u,fe]),hn(()=>{const V=te.current;if(!fe||!V)return;const $=V.eventHandler.eventBus;if($.emit("ui:localization-mode-toggle-requested",!1),Te==="zoneDraft"){$.emit("ui:pointer-action-set-requested","zoneDraft");return}switch(f){case"select":$.emit("ui:pointer-action-set-requested","inspect");break;case"target":$.emit("ui:localization-mode-toggle-requested",!0),$.emit("ui:pointer-action-set-requested","locatePreview");break;case"move":$.emit("ui:pointer-action-set-requested","select"),$.emit("ui:transformControls-set-mode-requested","translate");break;case"rotate":$.emit("ui:pointer-action-set-requested","select"),$.emit("ui:transformControls-set-mode-requested","rotate");break;case"scale":$.emit("ui:pointer-action-set-requested","select"),$.emit("ui:transformControls-set-mode-requested","scale");break}},[f,fe,Te]),hn(()=>{const V=te.current;!fe||!V||V.eventHandler.eventBus.emit("ui:label-visibility-set-requested",v)},[v,fe]),hn(()=>{const V=te.current;!fe||!V||V.eventHandler.eventBus.emit("ui:node-render-mode-set-requested",g)},[g,fe]),hn(()=>{const V=te.current;!fe||!V||V.eventHandler.eventBus.emit("ui:lidar-toggled",b)},[b,fe]),hn(()=>{const V=te.current;!fe||!V||typeof y!="number"||V.eventHandler.eventBus.emit("ui:lidar-point-size-set-requested",y)},[y,fe]),hn(()=>{const V=te.current;!fe||!V||!h||V.eventHandler.eventBus.emit("ui:mapping-data-received",h)},[h,fe]),hn(()=>{const V=te.current;if(!fe||!V||!_||_.data.length===0)return;const $=ue.current;$&&$.chunkNum===_.chunkNum&&$.chunkId===_.chunkId&&$.data===_.data||(ue.current=_,V.eventHandler.eventBus.emit("ui:mapping-keyframe-received",_))},[_,fe]),E("div",{className:on("WorldStudio","bg-bg-raised relative h-full w-full",r),children:[p("canvas",{ref:re,className:"h-full w-full"}),!fe&&p(YC,{})]})});sP.displayName="WorldStudio";const _u=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"}},Av=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"}},rP=(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:aP}=await wt("react"),oP=({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:v=0,inlierRatio:g=0})=>{const{t:b}=en();return E(j,{className:"pointer-events-none absolute top-4 left-4 z-10 gap-2.5",children:[E(me,{className:"items-start gap-4",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:b("move.amr.rightPanel.hud.localization")}),E(me,{className:"items-center gap-1 py-0.5",children:[p(ya,{className:`h-2.5 w-2.5 ${_u(r)}`}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:rP(r,b)}),p("span",{className:"typo-compact-2xs-medium text-fg-subtler ml-2",children:b("move.amr.rightPanel.hud.inlierError")}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:v.toFixed(3)}),p("span",{className:"typo-compact-2xs-medium text-fg-subtler ml-1",children:b("move.amr.rightPanel.hud.inlierRatio")}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:g.toFixed(2)})]})]}),E(j,{className:"gap-0.5",children:[p("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:b("move.amr.rightPanel.hud.autoMove")}),E(me,{className:"items-center gap-1 py-0.5",children:[p(Eu,{className:`h-2.5 w-2.5 ${_u(e)}`}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:e})]})]}),E(j,{className:"gap-0.5",children:[p("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:b("move.amr.rightPanel.hud.obstacleDetect")}),E(me,{className:"items-center gap-1 py-0.5",children:[p(zg,{className:`h-2.5 w-2.5 ${Av(t)}`}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:t})]})]})]}),E(j,{className:"gap-0.5",children:[p("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:b("move.amr.rightPanel.hud.robotTransform")}),E(j,{className:"gap-2",children:[E(me,{className:"items-center gap-3",children:[E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-danger",children:"X"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:n.toFixed(3)})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-success",children:"Y"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:i.toFixed(3)})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-information",children:"Z"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:s.toFixed(3)})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-information",children:"RZ"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:a.toFixed(3)})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:b("move.amr.rightPanel.hud.speed")}),E("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[o.toFixed(2)," m/s"]})]})]}),E(me,{className:"items-center gap-3",children:[E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"VX"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:l.toFixed(3)})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"VY"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:c.toFixed(3)})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"WZ"}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:d.toFixed(3)})]})]})]})]}),E(j,{className:"gap-0.5",children:[p("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:b("move.amr.rightPanel.hud.imuSensor")}),E(me,{className:"items-center gap-3",children:[E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"Roll"}),E("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[h>0?"+":"",h.toFixed(2),"°"]})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"Pitch"}),E("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[u>0?"+":"",u.toFixed(2),"°"]})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"Yaw"}),E("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[f>0?"+":"",f.toFixed(2),"°"]})]}),E(j,{children:[p("p",{className:"typo-compact-2xs-medium text-fg-subtle uppercase",children:"ω"}),E("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[m.toFixed(2)," deg/s"]})]})]})]})]})},AN=aP(oP),{useEffect:lP,useMemo:Kd,useRef:cP,useState:no}=await wt("react"),CN=({open:r,close:e,onOpenChange:t,currentMap:n,onLoadMap:i,mapList:s})=>{const{t:a}=en(),[o,l]=no(1),[c,d]=no(null),[h,u]=no(""),[f,m]=no(!1),[v,g]=no(!1),b=cP(null),y=()=>{e?.(),t?.(!1)},w=I=>I>=1024*1024?`${(I/(1024*1024)).toFixed(1)} MB`:I>=1024?`${(I/1024).toFixed(1)} KB`:`${I} B`,_=Kd(()=>(s?.list??[]).map((I,G)=>{const q=[...I.cloudInfo,...I.topoInfo].reduce((O,W)=>O+W.fileSize,0);return{id:`${G+1}`,name:I.mapName,modifiedDate:I.updatedAt,size:w(q)}}),[s?.list]),R=Kd(()=>_.filter(I=>I.name.toLowerCase().includes(h.toLowerCase())),[_,h]),T=16,P=Math.max(1,Math.ceil(R.length/T)),M=Math.min(o,P),x=(M-1)*T,S=Kd(()=>R.slice(x,x+T),[R,x,T]),C=I=>{const G=Math.max(1,Math.min(P,I));l(G)},k=()=>{if(!c)return;const I=_.find(G=>G.id===c);I&&(i(I.name),y())};return lP(()=>{if(!r){m(!1),g(!1);return}const I=b.current;if(!I)return;const G=I.querySelector('[data-slot="scroll-area-viewport"]');if(!G)return;const q=()=>{const O=G.scrollHeight>G.clientHeight+1,W=G.scrollTop+G.clientHeight>=G.scrollHeight-1,Z=G.scrollTop>1;m(O&&Z),g(O&&!W)};return q(),G.addEventListener("scroll",q),window.addEventListener("resize",q),()=>{G.removeEventListener("scroll",q),window.removeEventListener("resize",q)}},[S,r]),r?E(j,{className:"fixed inset-0 z-50 items-center justify-center p-4",children:[p("button",{type:"button","aria-label":a("move.amr.rightPanel.map.loadDialog.closeBackdrop"),className:"bg-bg-dim absolute inset-0",onClick:y}),E(j,{className:"bg-bg-overlay relative h-[560px] w-full max-w-4xl overflow-hidden rounded-lg p-4",children:[p(j,{className:"shrink-0 gap-0.5 p-1",children:E(me,{className:"items-start justify-between",children:[p(me,{className:"items-center gap-2 pb-2",children:E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-lg-semibold text-fg-default",children:a("move.amr.rightPanel.map.loadDialog.title")}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:a("move.amr.rightPanel.map.loadDialog.description")})]})}),p(qn,{variant:"transparent",size:"2xs",icon:p(Pa,{}),className:"text-fg-subtle",onClick:y})]})}),E(j,{className:"min-h-0 flex-1 gap-2",children:[p(me,{className:"bg-alt-1 items-center justify-between rounded-md px-2.5 py-2 [[data-theme='light']_&]:bg-white",children:E(me,{className:"items-center gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-success",children:a("move.amr.rightPanel.map.loadDialog.currentMap")}),p("p",{className:"typo-compact-xs-semibold text-fg-default",children:n||"-"})]})}),p(j,{className:"shrink-0 gap-3",children:p(un,{type:"search",value:h,placeholder:a("move.amr.rightPanel.map.loadDialog.searchPlaceholder"),prefixIcon:p(Xv,{className:"text-fg-subtler"}),onChange:I=>{u(I.target.value),l(1)},className:"w-full"})}),E(j,{ref:b,className:"relative min-h-0 flex-1 overflow-hidden",children:[f&&p("div",{className:"from-bg-overlay pointer-events-none absolute inset-x-0 top-0 z-10 h-4 bg-gradient-to-b to-transparent"}),p(qv,{className:"h-full min-h-0 w-full overflow-hidden",viewportClassName:"h-full w-full",children:p("div",{className:"grid grid-cols-2 gap-2 pr-2",children:S.length>0?S.map(I=>{const G=c===I.id,q=I.name===n;return p("button",{type:"button",onClick:()=>d(I.id),className:`rounded-md border px-3 py-2.5 text-left transition-colors ${G?"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:E(me,{className:"items-start",children:[E(j,{className:"min-w-0 flex-1 justify-between gap-2",children:[p("p",{className:"typo-compact-sm-semibold text-fg-default truncate",children:I.name}),E(j,{className:"gap-0.5",children:[E(me,{className:"gap-1",children:[E("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[a("move.amr.rightPanel.map.loadDialog.modified"),":"]}),p("p",{className:"typo-compact-xs-normal text-fg-default",children:I.modifiedDate})]}),E(me,{className:"gap-1",children:[E("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[a("move.amr.rightPanel.map.loadDialog.size"),":"]}),p("p",{className:"typo-compact-xs-normal text-fg-default",children:I.size})]})]})]}),G&&p(Hg,{className:"text-fg-brand size-4"}),!G&&q&&p("p",{className:"typo-compact-2xs-semibold text-fg-success uppercase",children:a("move.amr.rightPanel.map.loadDialog.current")})]})},I.id)}):E(j,{className:"col-span-2 items-center justify-center py-10",children:[p("p",{className:"typo-compact-sm-normal text-fg-subtler",children:a("move.amr.rightPanel.map.loadDialog.noMapsFound")}),p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:a("move.amr.rightPanel.map.loadDialog.tryDifferentSearch")})]})})}),v&&p("div",{className:"from-bg-overlay pointer-events-none absolute inset-x-0 bottom-0 h-4 bg-gradient-to-t to-transparent"})]})]}),E(j,{className:"shrink-0 gap-3",children:[p(me,{className:"justify-center",children:p(Zv,{currPage:M,listSize:T,pageSize:5,totalCount:R.length,handlePageChange:C})}),E(me,{className:"items-center justify-end gap-2",children:[p(We,{variant:"outlined",onClick:y,children:a("move.amr.rightPanel.common.cancel")}),p(We,{variant:"brand",disabled:!c,onClick:k,children:a("move.amr.rightPanel.map.loadDialog.loadSelectedMap")})]})]})]})]}):null},{memo:dP}=await wt("react"),hP=({mapName:r,onMapNameClick:e})=>{const t=!r,{theme:n}=Ar();return p("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:E("div",{className:"flex items-center gap-1 px-0.5",children:[p(xy,{className:`h-4 w-4 ${t?"text-fg-subtle":"text-fg-default"}`}),p("span",{className:"text-fg-default typo-compact-xs-semibold",children:r}),t&&p("span",{className:"text-fg-subtle typo-compact-xs-medium",children:"Empty"})]})})},PN=dP(hP),{useState:uP,useCallback:fP}=await wt("react"),Cv=new Set(["move","rotate","scale"]),RN=()=>{const[r,e]=uP("select"),t=fP(n=>{e(n)},[]);return{selectedTool:r,onToolChange:t}},{memo:pP}=await wt("react"),mP=[{id:"select",icon:Eu,label:"Select",shortcut:"V"},{id:"target",icon:vy,label:"Cursor",shortcut:"T"}],gP=[{id:"move",icon:Yv,label:"Move",shortcut:"G"},{id:"rotate",icon:Gg,label:"Rotate",shortcut:"R"},{id:"scale",icon:Vg,label:"Scale",shortcut:"S"}],bP=[mP,gP],vP=({selectedTool:r,onToolChange:e,hasSelectedNode:t=!0,toolGroups:n,className:i})=>{const{theme:s}=Ar(),a=s==="light"?"bg-default":"bg-alt-1",o=n??bP;return p(j,{className:on("gap-2",i),children:o.map((l,c)=>p("div",{className:"overflow-visible rounded-lg bg-transparent",children:l.map(d=>{const h=Cv.has(d.id);if(n===void 0&&h&&!t)return null;const u=r===d.id,f=d.shortcut?`${d.label} (${d.shortcut})`:d.label;return E("div",{className:"group relative",children:[p(qn,{variant:"transparent",size:"xs2",onClick:()=>e(d.id),className:on(a,"hover:!text-fg-default !text-fg-default shadow-down-xs relative rounded-sm",s==="light"?"hover:!bg-white":"hover:!bg-bg-alt-1"),icon:E(vi,{children:[u?p("span",{className:"bg-fill-subtler pointer-events-none absolute inset-1 rounded-md"}):null,p(d.icon,{className:"!text-fg-default relative z-10 h-4 w-4"})]}),"aria-label":d.ariaLabel??d.label}),p("p",{className:`typo-compact-xs2-normal ${a} 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:f})]},d.id)})},c))})},NN=pP(vP),{memo:yP}=await wt("react"),xP=({showJoysticks:r,showJoystickBtn:e=!0,setShowJoysticks:t,showViewControls:n,setShowViewControls:i,visibilityItems:s,onZoomIn:a,onZoomOut:o,isFullscreen:l,onFullscreenToggle:c,className:d})=>{const{theme:h}=Ar(),u=h==="light"?"bg-default":"bg-alt-1",f=h==="light"?"hover:bg-white":"hover:bg-alt-2";return E("div",{className:on("text-default flex flex-col gap-1.5",d),children:[E(j,{className:"group shadow-down-xs relative overflow-visible rounded-md",children:[p("button",{onClick:a,className:`${u} ${f} text-default rounded-md rounded-b-none p-2`,children:p(Wg,{className:"h-4 w-4"})}),p(ji,{type:"horizontal"}),p("button",{onClick:o,className:`${u} ${f} text-default rounded-md rounded-t-none p-2`,children:p(jg,{className:"h-4 w-4"})}),p("p",{className:`typo-compact-xs2-normal ${u} text-fg-default pointer-events-none invisible absolute top-1/2 right-full mr-2 -translate-y-1/2 rounded px-2 py-1.5 whitespace-nowrap group-hover:visible`,children:"Zoom Operation"})]}),E("div",{className:"group relative",children:[p("button",{onClick:c,className:`${u} ${f} text-default shadow-down-xs rounded p-2`,children:l?p(Kv,{className:"h-4 w-4"}):p(Vg,{className:"h-4 w-4"})}),p("p",{className:`typo-compact-xs2-normal ${u} text-fg-default pointer-events-none invisible absolute top-1/2 right-full mr-2 -translate-y-1/2 rounded px-2 py-1.5 whitespace-nowrap group-hover:visible`,children:l?"Exit Full Screen":"Full Screen"})]}),e&&E("div",{className:"group relative",children:[E("button",{onClick:()=>t(!r),className:`${u} ${f} text-default shadow-down-xs relative rounded-md p-2`,children:[r?p("span",{className:"bg-fill-subtler pointer-events-none absolute inset-1 rounded-md"}):null,p(Xg,{className:"relative z-10 h-4 w-4"})]}),p("p",{className:`typo-compact-xs2-normal ${u} text-fg-default pointer-events-none invisible absolute top-1/2 right-full mr-2 -translate-y-1/2 rounded px-2 py-1.5 whitespace-nowrap group-hover:visible`,children:"Virtual Joysticks"})]}),E("div",{className:"group relative",children:[E("button",{onClick:()=>i(!n),className:`${u} ${f} text-default shadow-down-xs relative rounded-md p-2`,children:[n?p("span",{className:"bg-fill-subtler pointer-events-none absolute inset-1 rounded-md"}):null,p(Sc,{className:"relative z-10 h-4 w-4"})]}),p("p",{className:`typo-compact-xs2-normal ${u} text-fg-default pointer-events-none invisible absolute top-1/2 right-full mr-2 -translate-y-1/2 rounded px-2 py-1.5 whitespace-nowrap group-hover:visible`,children:"Viewport Visibility"}),n&&E(j,{className:`${h==="light"?"bg-white":"bg-alt-1"} border-disabled shadow-down-xs absolute top-0 right-full z-50 mr-2 w-64 gap-2.5 rounded-md px-3 py-2.5`,children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Viewport Visibility"}),p(j,{children:s.map((m,v)=>E(j,{children:[E(me,{className:"items-center justify-between",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-xs2-semibold text-fg-default",children:m.label}),m.description?p("p",{className:"typo-compact-xs-normal text-fg-subtle",children:m.description}):null]}),p(xa,{checked:m.checked,onCheckedChange:g=>{m.onCheckedChange(!!g)}})]}),v<s.length-1?p(ji,{className:"py-2"}):null]},m.label))})]})]})]})},DN=yP(xP),{memo:_P}=await wt("react"),$d={fullscreen:"right-2",menuExpanded:"right-33",menuCollapsed:"right-12"},wP=({isLive:r,pointCount:e,latency:t,fps:n,nodeCount:i,linkCount:s,onToggleRobotControl:a,onToggleCameraStreams:o,onToggleObstacleMap:l,showCameraStreams:c,showObstacleMap:d,showRobotControlBtn:h,isFullscreen:u=!1,isMenuExpanded:f=!1})=>{const{theme:m}=Ar(),{t:v}=en(),g=!h,b=u?$d.fullscreen:f?$d.menuExpanded:$d.menuCollapsed;return E("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:[E("div",{className:"flex items-center gap-3",children:[E("div",{className:"flex items-center gap-1",children:[p("div",{className:`h-2 w-2 rounded-full ${r?"animate-pulse bg-green-500":"bg-gray-600"}`}),p("span",{className:"text-fg-default typo-compact-2xs-semibold",children:v(r?"move.amr.rightPanel.bottomBar.liveStream":"move.amr.rightPanel.bottomBar.offline")})]}),E("div",{className:"flex items-center gap-1",children:[E("span",{className:"text-fg-subtler typo-compact-2xs-normal",children:[v("move.amr.rightPanel.bottomBar.points"),":"]}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:e.toLocaleString()})]}),E("div",{className:"flex items-center gap-1",children:[E("span",{className:"text-fg-subtler typo-compact-2xs-normal",children:[v("move.amr.rightPanel.bottomBar.nodes"),":"]}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:i})]}),E("div",{className:"flex items-center gap-1",children:[E("span",{className:"text-fg-subtler typo-compact-2xs-normal",children:[v("move.amr.rightPanel.bottomBar.links"),":"]}),p("span",{className:"typo-compact-2xs-semibold text-fg-default",children:s})]})]}),E("div",{className:on("pointer-events-auto absolute flex items-center gap-1.5",b),children:[p(We,{size:"2xs",variant:"inverse",leadingIcon:p(_h,{}),onClick:o,className:on(!c&&(m==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:v("move.amr.rightPanel.bottomBar.camera")}),p(We,{size:"2xs",variant:"inverse",leadingIcon:p(qg,{}),onClick:l,className:on(!d&&(m==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:"Obstacle Map"}),p(We,{size:"2xs",variant:"inverse",leadingIcon:p(Xg,{}),onClick:a,className:on(!g&&(m==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:v("move.amr.rightPanel.bottomBar.controlPanel")})]})]})},LN=_P(wP),{useEffect:lg,useRef:SP,useState:fi}=await wt("react"),MP=["button","point","manual"],cg={KeyW:"forward",KeyA:"left",KeyS:"backward",KeyD:"right",KeyQ:"rotateLeft",KeyE:"rotateRight"},dg=r=>{if(!(r instanceof HTMLElement))return!1;const e=r.tagName.toLowerCase();return r.isContentEditable||e==="input"||e==="textarea"||e==="select"},IN=({robotPose:r,handleButtonJog:e,onClose:t,onMoveTarget:n,onMoveLinear:i,linearSpeed:s,setLinearSpeed:a,rotationSpeed:o,setRotationSpeed:l,transparency:c,onTransparencyChange:d,className:h})=>{const{t:u}=en(),[f,m]=fi("button"),v=SP(null),[g,b]=fi("0.5"),[y,w]=fi("0.5"),[_,R]=fi("45"),[T,P]=fi("45"),[M,x]=fi("0.0"),[S,C]=fi("0.0"),[k,I]=fi("0.0"),[G,q]=fi("0.0"),[O,W]=fi("x"),[Z,K]=fi("1.0"),[oe,te]=fi("0.5"),[ve,ce]=fi(c),Q=()=>{n({goalPose:{x:Number.parseFloat(M)||0,y:Number.parseFloat(S)||0,rz:Number.parseFloat(G)||0},method:"pp",preset:1})},re=()=>{const J=Number.parseFloat(Z)||0,ne=Number.parseFloat(oe)||0;i({axis:O,target:J,speed:ne})};return lg(()=>{if(typeof window>"u")return;const J=()=>{v.current!==null&&(v.current=null,e("stop"))},ne=Te=>{if(f!=="button"||Te.repeat||dg(Te.target))return;const _e=cg[Te.code];_e&&(Te.preventDefault(),v.current!==_e&&(v.current=_e,e(_e)))},ue=Te=>{if(f!=="button"||dg(Te.target))return;const _e=cg[Te.code];!_e||v.current!==_e||(Te.preventDefault(),J())};return window.addEventListener("keydown",ne),window.addEventListener("keyup",ue),window.addEventListener("blur",J),()=>{window.removeEventListener("keydown",ne),window.removeEventListener("keyup",ue),window.removeEventListener("blur",J),J()}},[f,e]),lg(()=>{ce(c)},[c]),E(j,{className:on("border-subtle shadow-down-lg w-[39.375rem] overflow-hidden rounded-lg border pointer-events-auto",h),style:{backgroundColor:`color-mix(in srgb, var(--color-bg-alt-1) ${Math.max(0,Math.min(100,ve))}%, transparent)`},children:[E(me,{className:"border-subtle items-center justify-between gap-4 border-b px-3",children:[p(Au,{className:"min-h-0 flex-1",variant:"line",value:f,onValueChange:J=>{MP.includes(J)&&m(J)},children:E(Tu,{children:[p(Hi,{value:"button",children:u("move.amr.rightPanel.controlPanel.tab.button")}),p(Hi,{value:"point",children:u("move.amr.rightPanel.controlPanel.tab.point")}),p(Hi,{value:"manual",children:u("move.amr.rightPanel.controlPanel.tab.linear")})]})}),E(me,{className:"h-8 shrink-0 items-center gap-2",children:[p("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:u("move.amr.rightPanel.controlPanel.transparency")}),E("p",{className:"typo-compact-xs2-semibold text-fg-default w-8 text-right",children:[ve,"%"]}),p(Zg,{value:[ve],min:0,max:100,step:1,onValueChange:J=>{const ne=J[0];ce(ne),d(ne)},className:"w-24"}),p(qn,{icon:p(Pa,{}),variant:"transparent",size:"2xs",onClick:t})]})]}),E(j,{className:"p-3 pb-3.5",children:[f==="button"&&E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs2-normal text-fg-information",children:u("move.amr.rightPanel.controlPanel.button.description")}),E(me,{className:"items-end gap-4",children:[E(j,{className:"min-w-0 flex-1 gap-2.5",children:[E(me,{className:"items-start gap-3",children:[E("p",{className:"typo-compact-xs2-medium text-fg-subtler shrink-0",children:[u("move.amr.rightPanel.controlPanel.linearMotion.line1"),p("br",{}),u("move.amr.rightPanel.controlPanel.linearMotion.line2")]}),E("div",{className:"grid flex-1 grid-cols-3 gap-1",children:[E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:u("move.amr.rightPanel.controlPanel.speedMs")}),p(un,{size:"xs2",type:"number",value:s,className:"!w-full",onChange:J=>{a(Number.parseFloat(J.target.value)||0)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:u("move.amr.rightPanel.controlPanel.accelMs2")}),p(un,{size:"xs2",type:"number",value:g,className:"!w-full",disabled:!0,onChange:J=>{b(J.target.value)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:u("move.amr.rightPanel.controlPanel.decelMs2")}),p(un,{size:"xs2",type:"number",value:y,className:"!w-full",disabled:!0,onChange:J=>{w(J.target.value)}})]})]})]}),E(me,{className:"items-start gap-3",children:[E("p",{className:"typo-compact-xs2-medium text-fg-subtler shrink-0",children:[u("move.amr.rightPanel.controlPanel.angularMotion.line1"),p("br",{}),u("move.amr.rightPanel.controlPanel.angularMotion.line2")]}),E("div",{className:"grid flex-1 grid-cols-3 gap-1",children:[E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:u("move.amr.rightPanel.controlPanel.speedDegS")}),p(un,{size:"xs2",type:"number",value:o,className:"!w-full",onChange:J=>{l(Number.parseFloat(J.target.value)||0)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:u("move.amr.rightPanel.controlPanel.accelDegS2")}),p(un,{size:"xs2",type:"number",value:_,className:"!w-full",disabled:!0,onChange:J=>{R(J.target.value)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:u("move.amr.rightPanel.controlPanel.decelDegS2")}),p(un,{size:"xs2",type:"number",value:T,className:"!w-full",disabled:!0,onChange:J=>{P(J.target.value)}})]})]})]})]}),E(j,{className:"w-[8.25rem] shrink-0 items-center gap-1.5",children:[E("div",{className:"grid grid-cols-[2.5rem_2.5rem_2.5rem] grid-rows-2 gap-1.5",children:[p("div",{className:"size-10"}),p(qn,{variant:"soft",icon:p($v,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("forward"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")}),p("div",{className:"size-10"}),p(qn,{variant:"soft",icon:p(Qv,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("left"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")}),p(qn,{variant:"soft",icon:p(Jv,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("backward"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")}),p(qn,{variant:"soft",icon:p(Cu,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("right"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")})]}),E("div",{className:"grid w-full grid-cols-2 gap-1.5",children:[p(We,{leadingIcon:p(ey,{}),size:"xs",variant:"soft",className:"typo-compact-xs-semibold h-7 w-full",onMouseDown:()=>e("rotateLeft"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop"),children:u("move.amr.rightPanel.controlPanel.left")}),p(We,{leadingIcon:p(ty,{}),size:"xs",variant:"soft",className:"typo-compact-xs-semibold h-7 w-full",onMouseDown:()=>e("rotateRight"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop"),children:u("move.amr.rightPanel.controlPanel.right")})]})]})]})]}),f==="point"&&E(j,{className:"justify-between gap-2",children:[p("p",{className:"typo-compact-xs2-normal text-fg-information",children:u("move.amr.rightPanel.controlPanel.point.description")}),E(j,{className:"gap-3",children:[E("div",{className:"grid grid-cols-4 gap-2",children:[E(j,{className:"min-w-0 gap-1.5",children:[E(me,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-medium text-fg-danger",children:"X"}),p("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(m)"})]}),p(un,{size:"xs2",type:"number",className:"!w-full",value:M,onChange:J=>{x(J.target.value)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[E(me,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-medium text-fg-success",children:"Y"}),p("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(m)"})]}),p(un,{size:"xs2",type:"number",className:"!w-full",value:S,onChange:J=>{C(J.target.value)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[E(me,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-medium text-fg-brand",children:"Z"}),p("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(m)"})]}),p(un,{size:"xs2",type:"number",className:"!w-full",value:k,onChange:J=>{I(J.target.value)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[E(me,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-medium text-fg-debug",children:"Theta"}),p("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(°)"})]}),p(un,{size:"xs2",type:"number",className:"!w-full",value:G,onChange:J=>{q(J.target.value)}})]})]}),E(me,{className:"items-center justify-between gap-3",children:[E(me,{className:"min-w-0 items-center gap-0.5",children:[p(Pu,{className:"text-fg-subtle size-3.5 shrink-0"}),p("p",{className:"typo-compact-xs2-normal text-fg-subtle min-w-0 truncate",children:u("move.amr.rightPanel.controlPanel.currentPose",{x:r.x.toFixed(2),y:r.y.toFixed(2),yaw:r.yaw.toFixed(1)})})]}),p(We,{size:"xs2",variant:"brand",className:"h-8 w-32 !px-3",onClick:Q,children:u("move.amr.rightPanel.controlPanel.moveToPoint")})]})]})]}),f==="manual"&&E(j,{className:"justify-between gap-2",children:[p("p",{className:"typo-compact-xs2-normal text-fg-information",children:u("move.amr.rightPanel.controlPanel.linear.description")}),E(j,{className:"gap-3",children:[E("div",{className:"grid grid-cols-3 gap-2",children:[E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.controlPanel.axis")}),E("div",{className:"grid grid-cols-2 gap-1.5",children:[p(We,{variant:O==="x"?"brand":"soft",size:"xs2",className:"h-8 w-full !px-3",onClick:()=>{W("x")},children:"X"}),p(We,{variant:O==="y"?"brand":"soft",size:"xs2",className:"h-8 w-full !px-3",onClick:()=>{W("y")},children:"Y"})]})]}),E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.controlPanel.targetM")}),p(un,{size:"xs2",type:"number",className:"!w-full",value:Z,onChange:J=>{K(J.target.value)}})]}),E(j,{className:"min-w-0 gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.controlPanel.speedMs")}),p(un,{size:"xs2",type:"number",className:"!w-full",value:oe,onChange:J=>{te(J.target.value)}})]})]}),p(me,{className:"justify-end",children:p(We,{size:"xs2",variant:"brand",className:"h-8 w-32 !px-3",onClick:re,children:u("move.amr.rightPanel.controlPanel.executeMove")})})]})]})]})]})},{memo:EP}=await wt("react"),TP=(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%)`}},hg=r=>typeof r!="number"||Number.isNaN(r)?"-":r.toFixed(3),AP=r=>typeof r!="number"||Number.isNaN(r)?"-":`${(r*180/Math.PI).toFixed(3)}°`,CP=({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?E(j,{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:TP(a,o)},children:[E(me,{className:"items-center justify-between gap-3",children:[E(me,{className:"min-w-0 items-center",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-subtler mr-3",children:"Name"}),p("span",{className:"typo-compact-sm-semibold text-fg-default truncate",children:l})]}),c&&p(qn,{className:"pointer-events-auto",variant:"transparent",size:"2xs","aria-label":"Edit node",icon:p(Ru,{}),onClick:c})]}),E(me,{className:"flex flex-wrap gap-x-7",children:[E("p",{className:"whitespace-nowrap",children:[p("span",{className:"text-fg-danger typo-compact-sm2-semibold mr-3",children:"X"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:hg(n)})]}),E("p",{className:"whitespace-nowrap",children:[p("span",{className:"text-fg-success typo-compact-sm2-semibold mr-3",children:"Y"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:hg(i)})]}),E("p",{className:"whitespace-nowrap",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-information mr-3",children:"RZ"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:AP(s)})]})]}),(d||h)&&E(me,{className:"pointer-events-auto mt-3 gap-2",children:[d&&p(We,{variant:"danger",size:"sm",onClick:d,children:"Delete"}),h&&p(We,{variant:"soft",size:"sm",onClick:h,children:"Move To Node"})]})]}):null,kN=EP(CP),{memo:PP}=await wt("react"),RP=(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%)`}},NP=r=>typeof r!="number"||Number.isNaN(r)?"-":r.toFixed(2),DP=({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?E(j,{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:RP(l,c)},children:[n.length>1&&p(me,{className:"pointer-events-auto mb-2 gap-1.5",children:n.map((u,f)=>{const m=u.id===h.id;return p("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)})}),E(me,{className:"items-center justify-between gap-3",children:[E(me,{className:"min-w-0 items-center",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-subtler mr-3",children:"Link"}),p("span",{className:"typo-compact-sm-semibold text-fg-default truncate",children:h.title})]}),a&&p(qn,{className:"pointer-events-auto",variant:"transparent",size:"2xs","aria-label":"Edit link",icon:p(Ru,{}),onClick:a})]}),E(me,{className:"flex flex-wrap gap-x-7",children:[E("p",{className:"whitespace-nowrap",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-warning mr-3",children:"DIR"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.dir})]}),E("p",{className:"whitespace-nowrap",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-brand mr-3",children:"METHOD"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.method})]}),E("p",{className:"whitespace-nowrap",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-success mr-3",children:"SPEED"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:NP(h.speed)})]})]}),o&&p(me,{className:"pointer-events-auto mt-3 gap-2",children:p(We,{variant:"danger",size:"sm",onClick:o,children:"Delete"})})]}):null},ON=PP(DP),{memo:LP}=await wt("react"),IP=(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%)`}},kP=({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?E(j,{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:IP(l,c)},children:[n.length>1&&p(me,{className:"pointer-events-auto mb-2 gap-1.5",children:n.map((u,f)=>{const m=u.id===h.id;return p("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)})}),E(me,{className:"items-center justify-between gap-3",children:[E(me,{className:"min-w-0 items-center",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-subtler mr-3",children:"Zone"}),p("span",{className:"typo-compact-sm-semibold text-fg-default truncate",children:h.title})]}),a&&p(qn,{className:"pointer-events-auto",variant:"transparent",size:"2xs","aria-label":"Edit zone",icon:p(Ru,{}),onClick:a})]}),E(me,{className:"flex flex-wrap gap-x-7",children:[E("p",{className:"whitespace-nowrap",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-warning mr-3",children:"TYPE"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.type})]}),E("p",{className:"whitespace-nowrap",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-brand mr-3",children:"POINTS"}),p("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.pointCount})]})]}),o&&p(me,{className:"pointer-events-auto mt-3 gap-2",children:p(We,{variant:"danger",size:"sm",onClick:o,children:"Delete"})})]}):null},FN=LP(kP),{memo:OP,useCallback:Qd,useEffect:ug,useRef:cr,useState:Jd}=await wt("react"),jl={width:630,height:320},Xl={width:420,height:180},fg=24,pg=(r,e,t)=>Math.min(Math.max(r,e),t),FP=({cameras:r,onClose:e,onQualityChange:t,transparency:n=80})=>{const{t:i}=en(),[s,a]=Jd({x:0,y:0}),[o,l]=Jd(jl),[c,d]=Jd(null),h=cr(null),u=cr({x:0,y:0}),f=cr(jl),m=cr(!1),v=cr(!1),g=cr({mouseX:0,mouseY:0,panelX:0,panelY:0}),b=cr({mouseX:0,mouseY:0,panelX:0,panelY:0,width:jl.width,height:jl.height}),y=r.find(T=>T.id===c&&T.status==="live"&&T.streamUrl),w=Qd(T=>{T.preventDefault(),!v.current&&(m.current=!0,document.body.style.cursor="grabbing",g.current={mouseX:T.clientX,mouseY:T.clientY,panelX:u.current.x,panelY:u.current.y})},[]),_=Qd(T=>{T.preventDefault(),T.stopPropagation();const P=h.current?.getBoundingClientRect();v.current=!0,document.body.style.cursor="se-resize",document.body.style.userSelect="none",b.current={mouseX:T.clientX,mouseY:T.clientY,panelX:u.current.x,panelY:u.current.y,width:P?.width??f.current.width,height:P?.height??f.current.height}},[]),R=Qd(T=>{d(T)},[]);return ug(()=>{const T=M=>{if(m.current){const x=g.current.panelX+(M.clientX-g.current.mouseX),S=g.current.panelY+(M.clientY-g.current.mouseY);u.current={x,y:S},h.current&&(h.current.style.transform=`translate(${x}px, ${S}px)`)}if(v.current){const x=pg(b.current.width+(M.clientX-b.current.mouseX),Xl.width,Math.max(Xl.width,window.innerWidth-fg)),S=pg(b.current.height+(M.clientY-b.current.mouseY),Xl.height,Math.max(Xl.height,window.innerHeight-fg)),C={width:x,height:S},k={x:b.current.panelX+(x-b.current.width),y:b.current.panelY+(S-b.current.height)};f.current=C,u.current=k,l(C),a(k)}},P=()=>{const M=m.current,x=v.current;M&&(m.current=!1,document.body.style.cursor="",a({...u.current})),x&&(v.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return window.addEventListener("mousemove",T),window.addEventListener("mouseup",P),()=>{window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",P),document.body.style.cursor="",document.body.style.userSelect=""}},[]),ug(()=>{c&&!r.some(T=>T.id===c)&&d(null)},[r,c]),E("div",{className:"pointer-events-auto",children:[p(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:!!y,onOpenChange:T=>{T||d(null)},header:{title:y?.name??i("move.amr.rightPanel.cameraPanel.title")},children:y&&p("div",{className:"!bg-alt-2 flex h-full flex-col justify-between",children:p("div",{className:"bg-base-black h-[calc(var(--vh,1vh)*70)] overflow-hidden",children:p(Tf,{className:"bg-base-black h-full w-full overflow-hidden [&_video]:object-cover",url:y.streamUrl??"",label:y.name,lebelPosition:"top-left",initStatus:!0,disconnectedMessage:i("move.amr.rightPanel.cameraPanel.disconnected"),loadingMessage:i("move.amr.rightPanel.cameraPanel.connecting")})})})}),E("div",{ref:h,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,n))}%, transparent)`,transform:`translate(${s.x}px, ${s.y}px)`,width:o.width,height:o.height},children:[E("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:[E("div",{className:"typo-compact-xs2-semibold flex flex-1 items-center justify-start gap-1",children:[p("span",{className:"text-fg-default",children:i("move.amr.rightPanel.cameraPanel.title")}),p("span",{className:"text-fg-brand",children:r.length})]}),p(qn,{icon:p(Pa,{}),variant:"transparent",size:"2xs",onClick:e})]}),r.length===0?p("div",{className:"min-h-0 flex-1 px-3 pt-2 pb-3.5",children:p(_r,{className:"h-full rounded-md [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:p(_h,{className:"text-fg-subtlest size-5"}),message:i("move.amr.rightPanel.cameraPanel.empty")})}):p("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:p("div",{className:"flex h-full w-max min-w-full items-start gap-2",children:r.map(T=>E("div",{className:"inline-flex h-full shrink-0 flex-col gap-1.5",children:[E("div",{className:"flex items-center gap-1 px-0.5",children:[p("div",{className:"flex size-3 items-center justify-center",children:p(gi,{color:T.status==="live"?"green":"red"})}),p("span",{className:"text-fg-default typo-compact-xs2-semibold pr-2",children:T.name}),p("div",{onClick:P=>P.stopPropagation(),children:p(dc,{className:"min-w-20",size:"xs2",value:T.quality,handleChange:P=>{typeof P=="string"&&t?.(T.camId,P)},children:T.qualityOptions.map(P=>p(es,{value:P,children:P},P))})}),p("span",{className:"text-fg-subtler typo-compact-xs-normal ml-auto",children:T.resolution})]}),T.status==="live"&&T.streamUrl?p("div",{className:"bg-base-black border-subtle h-52 w-96 cursor-pointer overflow-hidden rounded-md border",onClick:P=>{P.stopPropagation(),R(T.id)},children:p(Tf,{className:"bg-base-black h-full w-full overflow-hidden [&_video]:object-cover",url:T.streamUrl??"",label:T.name,lebelPosition:"top-left",initStatus:!0,disconnectedMessage:i("move.amr.rightPanel.cameraPanel.disconnected"),loadingMessage:i("move.amr.rightPanel.cameraPanel.connecting")})}):E("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:[p(_h,{className:"text-fg-subtlest size-5"}),p("span",{className:"text-fg-subtler typo-compact-xs-normal",children:i("move.amr.rightPanel.cameraPanel.disconnected")})]})]},T.id))})}),p("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:_,children:p("span",{className:"border-fg-subtlest block size-2.5 border-r-2 border-b-2 opacity-70"})})]})]})},UN=OP(FP),{memo:UP,useEffect:io,useMemo:mg,useRef:eh,useState:th}=await wt("react"),BP=["static","dynamic","virtual","collision"],zP={static:[148,163,184,160],dynamic:[59,130,246,190],virtual:[168,85,247,180],collision:[239,68,68,210]},HP=320,nh=.5,ih=4,gg=.25,wc=(r,e,t)=>Math.max(e,Math.min(t,r)),bg=(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:wc(t.x,-n,n),y:wc(t.y,-i,i)}},vg=(r,e)=>(r%e+e)%e,GP=(()=>{const r=new ArrayBuffer(4),e=new Uint32Array(r),t=new Uint8Array(r);return e[0]=168496141,t[0]===13})(),VP=(r,e,t,n)=>GP?n<<24|t<<16|e<<8|r:r<<24|e<<16|t<<8|n,WP=(r,e)=>{const t=Math.max(r,1),n=Math.max(e,1),i=Math.max(t,n),s=Math.max(1,Math.floor(HP/i)),a=t*s,o=n*s;return{safeWidth:t,safeHeight:n,scale:s,canvasWidth:a,canvasHeight:o,centerX:a/2,centerY:o/2}},yg=(r,e)=>{r.width!==e.canvasWidth&&(r.width=e.canvasWidth),r.height!==e.canvasHeight&&(r.height=e.canvasHeight)},jP=(r,e)=>{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("Waiting for obstacle map data",e.canvasWidth/2,e.canvasHeight/2)},XP=(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=vg(e.centerX+n.x,s),o=vg(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()},qP=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=VP(o,l,c,d),m=new Uint32Array(u.buffer);for(let v=0;v<m.length;v+=1){if(!(u[v*4]>0)){m[v]=0;continue}m[v]=f}return a.putImageData(h,0,0),s}catch{return null}},ZP=(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)},YP=(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,v)=>{const g=o(d),b=o(h),y=l(f),w=l(u);r.fillStyle=m,r.strokeStyle=v,r.lineWidth=1,r.fillRect(g,y,b-g,w-y),r.strokeRect(g,y,b-g,w-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)")},KP=(r,e,t,n,i,s)=>{if(!(t>0))return;const a=n.scale*i,o=w=>n.centerX+s.x+w/t*a,l=w=>n.centerY+s.y-w/t*a,c=o(e.obsBoxMinX),d=o(e.obsBoxMaxX),h=l(e.obsBoxMaxY),u=l(e.obsBoxMinY),f=d-c,m=u-h,v=(c+d)/2,g=(h+u)/2,b=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(v,g),r.lineTo(v+b,g),r.stroke(),r.beginPath(),r.moveTo(v+b,g),r.lineTo(v+b-5,g-2.5),r.lineTo(v+b-5,g+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(v,g),r.lineTo(v,g-y),r.stroke(),r.beginPath(),r.moveTo(v,g-y),r.lineTo(v-2.5,g-y+5),r.lineTo(v+2.5,g-y+5),r.closePath(),r.fill(),r.restore()},$P=(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()},QP=({layers:r,width:e,height:t,gridSize:n,safety:i,loading:s=!1,onClose:a,transparency:o=80,className:l})=>{const c=eh(null),d=eh(null),h=eh(null),[u,f]=th(1),[m,v]=th({x:0,y:0}),[g,b]=th([]),y=r.length,w=mg(()=>r.map(S=>S.name).join(", "),[r]),_=mg(()=>WP(e,t),[t,e]),R=e>0&&t>0?`${e} x ${t}`:"-",T=n>0?`${n.toFixed(3)} m/px`:"-",P=`${Math.round(u*100)}%`,M=u>1,x=s?"Waiting for stream":e>0&&t>0?y>0?"Live":"No active layers":"Idle";return io(()=>{v(S=>bg(_,u,S))},[_,u]),io(()=>{let S=!1;if(e<=0||t<=0||r.length===0){b([]);return}const C=BP.map(k=>({layerName:k,layer:r.find(I=>I.name===k)})).filter(k=>!!k.layer&&k.layer.data.length>0);return(async()=>{const k=await Promise.all(C.map(async({layerName:I,layer:G})=>{const q=await qP(G.data,e,t,zP[I]);return{layerName:I,tintedLayerCanvas:q}}));S||b(k.filter(I=>I.tintedLayerCanvas!==null))})(),()=>{S=!0}},[t,r,e]),io(()=>{const S=c.current,C=d.current;S&&yg(S,_),C&&yg(C,_)},[_]),io(()=>{const S=c.current;if(!S)return;const C=S.getContext("2d");if(!C)return;C.imageSmoothingEnabled=!1;const k=document.createElement("canvas");k.width=_.canvasWidth,k.height=_.canvasHeight;const I=k.getContext("2d");if(I){if(I.imageSmoothingEnabled=!1,e<=0||t<=0){jP(I,_),C.clearRect(0,0,_.canvasWidth,_.canvasHeight),C.drawImage(k,0,0);return}XP(I,_,u,m);for(const{tintedLayerCanvas:G}of g)ZP(I,G,_,u,m);C.clearRect(0,0,_.canvasWidth,_.canvasHeight),C.drawImage(k,0,0)}},[g,t,_,m,e,u]),io(()=>{const S=d.current;if(!S)return;const C=S.getContext("2d");C&&(C.imageSmoothingEnabled=!1,C.clearRect(0,0,_.canvasWidth,_.canvasHeight),!(e<=0||t<=0)&&(YP(C,i,n,_,u,m),KP(C,i,n,_,u,m),$P(C,_)))},[n,t,e,i,_,m,u]),E(j,{className:on("border-subtle shadow-down-lg w-[25rem] overflow-hidden rounded-lg border pointer-events-auto",l),style:{backgroundColor:`color-mix(in srgb, var(--color-bg-alt-1) ${Math.max(0,Math.min(100,o))}%, transparent)`},children:[E(me,{className:"border-subtle items-center justify-between gap-4 border-b px-3 py-2.5",children:[E(me,{className:"min-w-0 items-center gap-2",children:[p("div",{className:"bg-fill-information-subtle flex size-8 shrink-0 items-center justify-center rounded-md",children:p(qg,{className:"text-fg-information size-4"})}),E(j,{className:"min-w-0 gap-0.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:"Obstacle Map"}),p("p",{className:"typo-compact-xs2-normal text-fg-subtle truncate",children:"Real-time 2D canvas preview"})]})]}),p(qn,{icon:p(Pa,{}),variant:"transparent",size:"2xs",onClick:a})]}),E(j,{className:"gap-3 p-3",children:[E("div",{className:on("bg-bg-default border-subtle relative aspect-square overflow-hidden rounded-md border",M?"touch-none cursor-grab active:cursor-grabbing":"cursor-default"),onPointerDown:S=>{!M||S.target instanceof Element&&S.target.closest("button")||(h.current={pointerId:S.pointerId,startX:S.clientX,startY:S.clientY,startPanX:m.x,startPanY:m.y},S.currentTarget.setPointerCapture(S.pointerId))},onPointerMove:S=>{const C=h.current;!C||C.pointerId!==S.pointerId||v(bg(_,u,{x:C.startPanX+S.clientX-C.startX,y:C.startPanY+S.clientY-C.startY}))},onPointerUp:S=>{h.current?.pointerId===S.pointerId&&(h.current=null,S.currentTarget.releasePointerCapture(S.pointerId))},onPointerCancel:S=>{h.current?.pointerId===S.pointerId&&(h.current=null,S.currentTarget.releasePointerCapture(S.pointerId))},children:[E(me,{className:"absolute top-3 right-3 z-10 gap-1.5 rounded-md bg-black/45 p-1 backdrop-blur-sm",children:[p(qn,{icon:p(Gg,{}),variant:"transparent",size:"2xs",disabled:u===1&&m.x===0&&m.y===0,onClick:()=>{f(1),v({x:0,y:0})}}),p(qn,{icon:p(jg,{}),variant:"transparent",size:"2xs",disabled:u<=nh,onClick:()=>{f(S=>{const C=wc(S-gg,nh,ih);return C<=1&&v({x:0,y:0}),C})}}),p(We,{size:"2xs",variant:"soft",disabled:!0,className:"min-w-14 justify-center",children:P}),p(qn,{icon:p(Wg,{}),variant:"transparent",size:"2xs",disabled:u>=ih,onClick:()=>{f(S=>wc(S+gg,nh,ih))}})]}),p("canvas",{ref:c,className:"absolute inset-0 h-full w-full [image-rendering:pixelated]"}),p("canvas",{ref:d,className:"pointer-events-none absolute inset-0 h-full w-full [image-rendering:pixelated]"}),p("div",{className:"absolute inset-x-3 bottom-3",children:E(me,{className:"justify-between rounded-md bg-black/45 px-2.5 py-2 backdrop-blur-sm",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-xs2-normal text-white/70",children:"Status"}),p("p",{className:"typo-compact-xs2-semibold text-white",children:x})]}),E(j,{className:"items-end gap-0.5",children:[p("p",{className:"typo-compact-xs2-normal text-white/70",children:"Grid"}),p("p",{className:"typo-compact-xs2-semibold text-white",children:R})]})]})})]}),E(me,{className:"flex-wrap gap-2",children:[p(We,{size:"2xs",variant:"soft",disabled:!0,children:T}),E(We,{size:"2xs",variant:"soft",disabled:!0,children:[y," Layers"]}),w?p(We,{size:"2xs",variant:"soft",disabled:!0,children:w}):null]})]})]})},BN=UP(QP),{useCallback:JP,useRef:eR}=await wt("react"),zN=({amrStatus:r,robotVersion:e,selectedTool:t="select",onToolChange:n,onInitLocalization:i,onSemiAutoInitLocalization:s,onStopLocalization:a,onBuildInfoOpenChange:o})=>{const{t:l}=en(),c=eR(null),d=M=>{const x=Number(M);return Number.isFinite(x)?x:0},h=r?.power?.batPercent??0,u=r?.locState?.locStatus??"none",f=r?.autoMove??"none",m=r?.obsState??"none",v=r?.operatingMode??"none",g=d(r?.pose?.x),b=d(r?.pose?.y),y=d(r?.pose?.z),w=d(r?.pose?.rz),_=r?.vel?Math.hypot(r.vel.vx??0,r.vel.vy??0):0,R=[{label:l("move.amr.rightPanel.overview.buildInfo.branch"),value:e?.gitBranch},{label:l("move.amr.rightPanel.overview.buildInfo.commit"),value:e?.gitCommit},{label:l("move.amr.rightPanel.overview.buildInfo.buildUser"),value:e?.gitAuthor},{label:l("move.amr.rightPanel.overview.buildInfo.buildDate"),value:e?.buildDate}],T=JP(()=>{c.current||(a(),c.current=window.setTimeout(()=>{c.current=null},300))},[a]),P=M=>M>50?"text-fg-success":M>20?"text-fg-caution":"text-fg-danger";return E(j,{className:"overflow-y-auto",children:[E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.overview.battery.title")}),E(me,{className:"flex items-center",children:[p("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:l("move.amr.rightPanel.overview.battery.chargeLevel")}),E(me,{className:"ml-auto flex items-center gap-1.5",children:[p("div",{className:"bg-fill-subtlest h-1.5 w-20 rounded-sm",children:p("div",{className:`h-1.5 rounded-full transition-all ${h>50?"bg-fill-success":h>20?"bg-fill-caution":"bg-fill-danger"}`,style:{width:`${h}%`}})}),E("p",{className:`typo-compact-xs2-medium ${P(h)}`,children:[h,"%"]})]})]})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.overview.localization.title")}),E(j,{className:"gap-2 rounded",children:[E(me,{className:"bg-fill-disabled items-center justify-between rounded-md p-3",children:[E(me,{className:"items-center gap-1",children:[p(ya,{className:"text-fg-subtle h-4 w-4"}),p("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:l("move.amr.rightPanel.overview.localization.positionTracking")})]}),E(me,{className:"items-center gap-1.5",children:[p(gi,{color:u!=="none"?"green":"gray"}),p("p",{className:"typo-compact-sm-semibold text-fg-default uppercase",children:u})]})]}),E(me,{className:"items-center justify-between gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:l("move.amr.rightPanel.overview.localization.cursor")}),p(xa,{size:"default",checked:t==="target",onCheckedChange:M=>{n?.(M?"target":"select")}})]}),E(me,{className:"gap-2",children:[p(We,{variant:"danger",leadingIcon:p(Yg,{}),className:"w-24",onClick:T,children:l("move.amr.rightPanel.common.stop")}),p(We,{variant:"brand",className:"flex-1",onClick:i,children:l("move.amr.rightPanel.overview.localization.start")})]}),p(We,{variant:"outlined",onClick:s,children:l("move.amr.rightPanel.overview.localization.semiAutoInit")}),E(me,{className:"items-start gap-1",children:[p("div",{className:"flex size-4 shrink-0 items-center justify-center",children:p(Pu,{className:"text-fg-subtlest size-3"})}),p("p",{className:"typo-compact-xs-normal text-fg-subtler flex-1",children:l("move.amr.rightPanel.overview.localization.description")})]})]})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.overview.moveStatus.title")}),E("div",{className:"bg-fill-disabled grid grid-cols-2 gap-x-3 gap-y-3 rounded-md px-3 py-3",children:[E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.overview.moveStatus.autoMove")}),E(me,{className:"items-center gap-1.5",children:[p(Eu,{className:`h-3 w-3 ${_u(f)}`}),p("p",{className:"typo-compact-xs2-medium text-fg-default",children:f})]})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.overview.moveStatus.operationMode")}),p("p",{className:`typo-compact-xs2-medium uppercase ${v==="auto"?"text-fg-information":v==="manual"?"text-fg-caution":"text-fg-subtler"}`,children:v})]})]}),E(me,{className:"bg-fill-disabled items-center justify-between rounded-md p-3",children:[p("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:l("move.amr.rightPanel.hud.obstacleDetect")}),E(me,{className:"items-center gap-1.5",children:[p(zg,{className:`h-3 w-3 ${Av(m)}`}),p("p",{className:"typo-compact-sm-semibold text-fg-default",children:m})]})]})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("label",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.overview.robotTransform.title")}),E("div",{className:"space-y-2",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtle",children:l("move.amr.rightPanel.overview.robotTransform.position")}),E("div",{className:"mt-2 flex items-center gap-4",children:[E("div",{className:"flex min-w-0 flex-1 items-center gap-4",children:[p("span",{className:"typo-compact-xs2-medium text-fg-danger uppercase",children:"X"}),E("span",{className:"typo-compact-xs2-normal text-fg-default font-mono",children:[g.toFixed(3)," m"]})]}),E("div",{className:"flex min-w-0 flex-1 items-center gap-4",children:[p("span",{className:"typo-compact-xs2-medium text-fg-success uppercase",children:"Y"}),E("span",{className:"typo-compact-xs2-normal text-fg-default font-mono",children:[b.toFixed(3)," m"]})]}),E("div",{className:"flex min-w-0 flex-1 items-center gap-4",children:[p("span",{className:"typo-compact-xs2-medium text-fg-brand uppercase",children:"Z"}),E("span",{className:"typo-compact-xs2-normal text-fg-default font-mono",children:[y.toFixed(3)," m"]})]})]}),E("div",{className:"flex items-center gap-4",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtle flex-1",children:l("move.amr.rightPanel.overview.robotTransform.rotation")}),p("span",{className:"typo-compact-xs-normal text-fg-subtle flex-1",children:l("move.amr.rightPanel.common.speed")})]}),E("div",{className:"flex items-center gap-4",children:[E("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[p("span",{className:"typo-compact-xs2-normal text-fg-danger uppercase",children:"RZ"}),E("span",{className:"typo-compact-xs2-normal text-fg-default",children:[w.toFixed(3),"°"]})]}),p("div",{className:"flex min-w-0 flex-1 items-center",children:E("span",{className:"typo-compact-xs2-normal text-fg-default",children:[_.toFixed(2)," m/s"]})})]})]})]}),p(j,{className:"border-subtler border-b px-1",children:p(ha,{handleOpenChange:M=>{o?.(M)},title:p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.overview.buildInfo.title")}),children:p("div",{className:"bg-fill-disabled flex w-full flex-col items-start justify-start gap-2 rounded-md p-2 px-2.5",children:R.map(M=>E("div",{className:"flex w-full items-center justify-between gap-3",children:[p("div",{className:"text-fg-subtle shrink-0 text-xs leading-4 font-normal",children:M.label}),p("div",{className:"text-fg-default min-w-0 truncate text-right text-xs leading-4 font-normal",children:M.value||"-"})]},M.label))})})})]})},{useEffect:so,useMemo:sh,useRef:xg,useState:Ji}=await wt("react"),tR=[{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"}],nR=[{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}],iR=r=>typeof r=="boolean"?Number(r):r??0,_g=(r,e)=>(r&1<<e)!==0,wg=(r,e)=>typeof r!="number"||!Number.isFinite(r)?"-":`${r}${e}`,Pv=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)},sR=r=>{const e=Pv(r.bits);if(e)return{...r,bits:e}},Sg=(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)??""},rR=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=Pv(n.bits);i&&e.push({key:n.key,label:n.label,mcu:n.mcu,kind:n.kind,bits:i})}return e},ql=(r,e,t)=>r.find(n=>n.mcu===e&&n.kind===t),Mg=r=>r?.map(e=>e.value),Rv=r=>r?`0x${r.reduce((t,n)=>n.value?t|1<<n.pin:t,0).toString(16).toUpperCase().padStart(2,"0")}`:"-",Zl=r=>r?r.map(e=>({...e})):void 0,Eg=r=>r?.map(e=>e.pin).join(",")??"",Tg=({label:r,onClick:e})=>p(We,{variant:"outlined",className:"!typo-compact-xs-normal text-fg-subtle",size:"2xs",onClick:e,children:r}),Nv=({pin:r,active:e,disabled:t=!1,onClick:n})=>{const i=on("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?p("button",{type:"button",className:i,disabled:t,onClick:n,children:p("span",{className:"typo-compact-2xs-semibold leading-none",children:r})}):p("div",{className:i,children:p("span",{className:"typo-compact-2xs-semibold leading-none",children:r})})},aR=({label:r,bits:e})=>E(j,{className:"gap-1",children:[E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtle",children:r}),p("span",{className:"typo-compact-xs-semibold text-fg-subtle font-mono",children:Rv(e)})]}),e?p("div",{className:"grid w-full gap-1",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(t=>p(Nv,{pin:t.pin,active:t.value},t.pin))}):p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"-"})]}),oR=({label:r,bits:e,disabled:t,onToggle:n})=>E(j,{className:"gap-1",children:[E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtle",children:r}),p("span",{className:"typo-compact-xs-semibold text-fg-subtle font-mono",children:Rv(e)})]}),e?p("div",{className:"grid w-full gap-1",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((i,s)=>p(Nv,{pin:i.pin,active:i.value,disabled:t,onClick:()=>n(s)},i.pin))}):p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"-"})]}),HN=({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:v}=en(),g=r?.motor??[],b=g.length>0,y=b&&g.every(Ne=>!!Ne.status),w=b?!y:!1,_=!!r?.robotState?.emo,R=r?.chargeState?.charge??"",T=r?.chargeState?.dockId??"",P=r?.chargeState?.dockResult??"",M=!!r?.chargeState?.dock,x=R.trim()==="charging",S=!!r?.robotState?.sfOperationalStop,C=r?.robotState?.lidarField??null,k=xg(null);so(()=>{k.current===null&&C!=null&&(k.current=C)},[C]);const[I,G]=Ji(""),[q,O]=Ji(!1),[W,Z]=Ji(null);so(()=>{Z(null)},[C]);const K=q?I:String(W??k.current??C??0),oe=!!r?.robotState?.detectMode,[te,ve]=Ji(null);so(()=>{ve(null)},[oe]);const[ce,Q]=Ji(null),[re,J]=Ji(!1),[ne,ue]=Ji(!1),Te=ce??w;so(()=>{Q(null)},[w]);const _e=sh(()=>a?.rows?.length?a.rows.map(sR).filter(Ne=>!!Ne):rR(a),[a]),fe=sh(()=>({mcu0Din:ql(_e,0,"din")?.bits,mcu1Din:ql(_e,1,"din")?.bits,mcu0Dio:ql(_e,0,"dio")?.bits,mcu1Dio:ql(_e,1,"dio")?.bits}),[_e]),be=sh(()=>_e.filter(Ne=>Ne.kind==="dio"&&(Ne.mcu===0||Ne.mcu===1)),[_e]),Ce=_e.length>0,[X,Be]=Ji({}),[Me,et]=Ji(!1),[Se,Ye]=Ji(!1),ee=`${Eg(fe.mcu0Dio)}|${Eg(fe.mcu1Dio)}`,U=xg(null);so(()=>{!fe.mcu0Dio||!fe.mcu1Dio||U.current!==ee&&(U.current=ee,Be({mcu0Din:Zl(fe.mcu0Dio),mcu1Din:Zl(fe.mcu1Dio)}),et(!1))},[ee,fe.mcu0Dio,fe.mcu1Dio]);const A=X.mcu0Din,Y=X.mcu1Din,V=!!l&&!!fe.mcu0Dio&&!!fe.mcu1Dio&&!!A&&!!Y,$=V&&Me,le=!V||o||Se,Ie=(Ne,Oe)=>{if(le||!A||!Y)return;const ht=Zl(A),at=Zl(Y);!ht||!at||(Ne===0?ht[Oe]={...ht[Oe],value:!ht[Oe].value}:at[Oe]={...at[Oe],value:!at[Oe].value},Be({mcu0Din:ht,mcu1Din:at}),et(!0))},we=Ne=>{if(Ne===0)return A;if(Ne===1)return Y},ze=Ne=>Sg(Ne.label,m),pt=async()=>{if(!(!l||!A||!Y||!$)){Ye(!0);try{await l({mcu0Din:Mg(A)??[],mcu1Din:Mg(Y)??[]}),et(!1)}catch{f?.()}finally{Ye(!1)}}},Pe=async()=>{if(e){J(!0);try{await e(!1),Q(!1),t?.({motorLock:!1}),c?.()}catch{h?.()}finally{J(!1)}}},Ue=()=>{O(!1),G("")},Qe=async()=>{const Ne=Number(I);if(Number.isNaN(Ne))O(!1);else{Z(Ne),O(!1);try{await i?.(Ne),d?.()}catch{Z(null),u?.()}}};return E("div",{className:"h-full min-h-0",children:[p("div",{className:"border-subtler border-b p-3",children:E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.emergencyStop")}),E("div",{className:"flex items-center gap-2",children:[p(gi,{color:_?"red":"green"}),p("span",{className:"typo-compact-xs-semibold text-fg-default",children:v(_?"move.amr.rightPanel.common.triggered":"move.amr.rightPanel.common.normal")})]})]})}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[E("button",{type:"button",className:"flex w-full items-center justify-between gap-2 text-left","aria-expanded":ne,onClick:()=>ue(Ne=>!Ne),children:[p("span",{className:"flex min-w-0 items-center",children:p("span",{className:"typo-compact-sm2-semibold text-fg-default truncate",children:v("move.amr.rightPanel.pdu.motorStatus")})}),E("div",{className:"flex shrink-0 items-center gap-2",children:[p(gi,{color:Te?"red":"green"}),p("span",{className:"typo-compact-xs-semibold text-fg-default",children:v(Te?"move.amr.rightPanel.common.disconnected":"move.amr.rightPanel.common.connected")}),ne?p(iy,{className:"text-fg-subtle size-3.5 shrink-0"}):p(sy,{className:"text-fg-subtle size-3.5 shrink-0"})]})]}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.motor")}),p(xa,{checked:!Te,disabled:!Te||re,onCheckedChange:Ne=>{Ne&&Pe()}})]}),ne&&p(j,{className:"gap-2 pt-1",children:g.length===0?p("span",{className:"typo-compact-xs-normal text-fg-disabled",children:"No motor data"}):g.map((Ne,Oe)=>{const ht=iR(Ne.status),at=_g(ht,0),Lt=!!Ne.connection;return E(j,{className:"border-subtle bg-alt-1 gap-2 rounded border p-2",children:[E("div",{className:"flex items-center justify-between",children:[E("span",{className:"typo-compact-sm2-semibold text-fg-default",children:["Motor ",Oe+1]}),E("div",{className:"flex items-center gap-2",children:[p(gi,{color:Lt?"green":"red"}),p("span",{className:"typo-compact-xs-semibold text-fg-default",children:Lt?"Connected":"Disconnected"})]})]}),E(j,{className:"bg-raised gap-2 rounded p-2",children:[E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Running"}),E("div",{className:"flex items-center gap-2",children:[p(gi,{color:at?"green":"red"}),p("span",{className:"typo-compact-xs-semibold text-fg-default",children:at?"On":"Off"})]})]}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Temperature"}),p("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:wg(Ne.temp,"°C")})]}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Current"}),p("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:wg(Ne.current,"A")})]})]}),E(j,{className:"gap-1",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Status Flags"}),p("div",{className:"grid grid-cols-2 gap-1.5",children:nR.map(se=>{const Ve=_g(ht,se.bit),ye=Ve?se.normalWhenActive?"green":"red":"gray";return E("div",{className:"bg-fill-disabled flex items-center justify-between gap-2 rounded px-2 py-1",children:[p("span",{className:"typo-compact-2xs-normal text-fg-subtle truncate",children:se.label}),p(ry,{type:"soft",color:ye,children:Ve?"On":"Off"})]},se.key)})})]})]},Oe)})})]}),E("div",{className:"border-subtler flex flex-col gap-1.5 border-b p-3",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.chargeContact")}),E("div",{className:"space-y-2",children:[E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.charge")}),E("div",{className:"flex items-center gap-2",children:[p(gi,{color:x?"green":"red"}),p("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:v(x?"move.amr.rightPanel.common.true":"move.amr.rightPanel.common.false")})]})]}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.dock")}),E("div",{className:"flex items-center gap-2",children:[p(gi,{color:M?"green":"red"}),p("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:v(M?"move.amr.rightPanel.common.true":"move.amr.rightPanel.common.false")})]})]}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.dockResult")}),p("span",{className:"typo-compact-xs-normal text-fg-subtle font-mono",children:P||"-"})]}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.dockId")}),p("span",{className:"typo-compact-xs-normal text-fg-subtle font-mono",children:T||"-"})]})]})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.safetyRecovery")}),p("div",{className:"space-y-2",children:tR.map(({key:Ne,labelKey:Oe,robotStateKey:ht})=>{const at=!!r?.robotState?.[ht];return E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:v(Oe)}),E("div",{className:"flex items-center gap-3",children:[E("div",{className:"flex items-center gap-2",children:[p(gi,{color:at?"red":"green"}),p("span",{className:"typo-compact-xs-semibold text-fg-default w-7 text-right",children:v(at?"move.amr.rightPanel.common.trig":"move.amr.rightPanel.common.none")})]}),p(Tg,{label:v("move.amr.rightPanel.common.clear"),onClick:()=>n?.(Ne)})]})]},Oe)})})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.opMode")}),p("div",{className:"space-y-2",children:E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.opModeRestoration")}),E("div",{className:"flex items-center gap-2",children:[p(gi,{color:S?"red":"green"}),p("span",{className:"typo-compact-xs-semibold text-fg-default w-7 text-right",children:v(S?"move.amr.rightPanel.common.trig":"move.amr.rightPanel.common.none")}),p(Tg,{label:v("move.amr.rightPanel.common.clear"),onClick:()=>n?.("operationStop")})]})]})})]}),Ce&&E(j,{className:"border-subtler gap-3 border-b p-3",children:[E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:"Safety I/O"}),o&&p("span",{className:"typo-compact-2xs-normal text-fg-subtle",children:v("move.amr.rightPanel.pdu.safetyIo.pending")})]}),E(j,{className:"gap-2",children:[p("div",{className:"flex items-center justify-between gap-2",children:p("span",{className:"typo-compact-xs-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.safetyIo.read")})}),p(j,{className:"gap-2",children:_e.map(Ne=>p(aR,{label:Sg(Ne.label,m),bits:Ne.bits},Ne.key))})]}),be.length>0&&E(j,{className:"gap-2",children:[E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-xs-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.safetyIo.outputControl")}),p("div",{className:"flex items-center gap-1",children:p(We,{variant:"brand",size:"2xs",disabled:!$||le,onClick:pt,children:v("move.amr.rightPanel.pdu.safetyIo.apply")})})]}),p(j,{className:"gap-2",children:be.map(Ne=>p(oR,{label:ze(Ne),bits:we(Ne.mcu),disabled:le,onToggle:Oe=>{(Ne.mcu===0||Ne.mcu===1)&&Ie(Ne.mcu,Oe)}},`${Ne.key}-control`))})]})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.pdu.lidarField")}),q&&E("div",{className:"flex items-center gap-1",children:[p(We,{variant:"outlined",size:"2xs",onClick:Ue,children:v("move.amr.rightPanel.common.reset")}),p(We,{variant:"brand",size:"2xs",onClick:Qe,children:v("move.amr.rightPanel.common.save")})]})]}),p(cn,{className:"w-full",type:"number",size:"sm",value:K,handleChange:Ne=>{G(Ne!==void 0?String(Ne):""),O(!0)}})]}),E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:"OSSD"}),E("div",{className:"flex items-center justify-between",children:[p("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:v("move.amr.rightPanel.pdu.detect")}),p(xa,{checked:te??oe,onCheckedChange:Ne=>{const Oe=te??oe;ve(Ne),s?.(Ne)?.catch(()=>ve(Oe))}})]})]})]})},{useMemo:lR}=await wt("react"),cR=({className:r,currentNode:e,targetNode:t,moveStatus:n})=>{const{t:i}=en(),s=lR(()=>n==="move"||n==="vir"||n==="moving",[n]);return E("div",{className:on("AMRNodeFromTo","relative pl-7",r),children:[E(j,{className:on("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:[E(j,{children:[p("span",{children:i("move.amr.rightPanel.task.currentNode")}),p("div",{className:"text-fg-subtle truncate",children:e||"-"})]}),E(j,{children:[p("span",{children:i("move.amr.rightPanel.task.targetNode")}),p("div",{className:"text-fg-subtle truncate",children:t||"-"})]})]}),p(dR,{className:"w-7",isMoving:s,children:p("span",{className:"moving-dot"})})]})},dR=Mc("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(
|
|
4738
4738
|
180deg,
|
|
4739
4739
|
color-mix(in srgb, var(--color-fg-default) 2%, transparent) 0%,
|
|
4740
4740
|
color-mix(in srgb, var(--color-fg-default) 16%, transparent) 35%,
|
|
@@ -4744,5 +4744,5 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
4744
4744
|
color-mix(in srgb, var(--color-fg-default) 58%, transparent) 0%,
|
|
4745
4745
|
color-mix(in srgb, var(--color-fg-default) 16%, transparent) 65%,
|
|
4746
4746
|
color-mix(in srgb, var(--color-fg-default) 2%, transparent) 100%
|
|
4747
|
-
);}.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);}}"),Dv=({className:r,items:e,latestIndex:t=0,latestIndexes:n,compact:i=!1,showResult:s=!i})=>e.length?p(sR,{className:on("gap-2",r),children:e.map((a,o)=>{const l=n?n.includes(o):o===t,c=o===0,d=o===e.length-1;return E("div",{className:"relative flex items-start gap-3 rounded-md px-2 py-1.5",children:[p(rR,{isFirst:c,isLast:d,children:p(aR,{isLatest:l})}),E(j,{className:"min-w-0 flex-1 gap-0.5",children:[E("div",{className:"flex min-h-5 items-center justify-between gap-1.5",children:[p("span",{className:on("typo-compact-xs2-semibold truncate font-mono",l?"text-fg-information":"text-fg-default"),children:a.message||"-"}),l?p("span",{className:"bg-fill-information typo-compact-2xs-semibold text-fg-inverse rounded-lg px-1.5 py-0.5",children:"Latest"}):null]}),!i&&E(vi,{children:[E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-2xs-medium text-fg-subtler",children:"Time"}),p("span",{className:"typo-compact-xs-normal text-fg-subtle truncate",children:ay(a.createdAt,"YYYY-MM-DD HH:mm:ss")})]}),E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-2xs-medium text-fg-subtler",children:"Command"}),p("span",{className:"typo-compact-xs-normal text-fg-subtle truncate",children:a.command||"-"})]})]}),s&&E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-2xs-medium text-fg-subtler",children:"Result"}),p("span",{className:on("typo-compact-xs-normal",{"text-fg-success":a.result==="success","text-fg-danger":a.result==="fail","text-fg-information":a.result==="start","text-fg-disabled":a.result==="cancel","text-fg-subtle":a.result!=="success"&&a.result!=="fail"&&a.result!=="start"&&a.result!=="cancel"}),children:a.result||"-"})]})]})]},`${a.createdAt}-${a.command}-${o}`)})}):p("div",{className:r,children:p("span",{className:"typo-compact-xs2-normal text-fg-subtle",children:"No history"})}),sR=Mc(j,{target:"edynay22"})({name:"bjn8wh",styles:"position:relative"}),rR=Mc("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;",";}"),aR=Mc("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:oR,useMemo:Ag,useState:lR}=await wt("react"),cR=[{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"}],dR=r=>r.toUpperCase().replace("_"," "),Cg=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())}`},hR=(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)},Pg=r=>{if(!r)return null;const e=new Date(r).getTime();return Number.isNaN(e)?null:e},uR=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`},fR=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`},pR=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:hR(e.createdAt,e.updateAt),previousNodes:t.map(n=>({createdAt:n.createdAt,message:fR(n),command:n.command,result:n.result}))}},kN=({logData:r,moveStatus:e})=>{const{t}=en(),[n,i]=lR(()=>Date.now()),s=pR(r),a=s?.status??"",o=a?dR(a):t("move.amr.rightPanel.task.idle"),l=s?.previousNodes??[],c=l.length?l:cR,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";oR(()=>{if(!u)return;const v=window.setInterval(()=>{i(Date.now())},1e3);return()=>{window.clearInterval(v)}},[u]);const f=Ag(()=>{const v=Pg(s?.createdAt),g=Pg(s?.updatedAt);if(v!==null){if(u)return Math.max(0,Math.floor((n-v)/1e3));if(g!==null&&g>=v)return Math.floor((g-v)/1e3)}return typeof s?.actualDuration=="number"&&s.actualDuration>=0?Math.floor(s.actualDuration):0},[u,n,s?.actualDuration,s?.createdAt,s?.updatedAt]),m=Ag(()=>uR(f),[f]);return E(j,{className:"h-full min-h-0",children:[E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[E("div",{className:"flex items-center justify-between",children:[p("div",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.task.status")}),E("div",{className:"flex flex-row items-center gap-2",children:[p(gi,{color:a!==""?"blue":"gray",className:a!==""?"animate-pulse":void 0}),p("div",{className:"typo-compact-xs-semibold text-fg-default",children:o})]})]}),E("div",{className:"flex items-center justify-between",children:[p("div",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.common.created")}),p("div",{className:"typo-compact-xs-normal text-fg-subtle",children:Cg(s?.createdAt)})]}),E("div",{className:"flex items-center justify-between",children:[p("div",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.task.lastUpdated")}),p("div",{className:"typo-compact-xs-normal text-fg-subtle",children:Cg(s?.updatedAt)})]})]}),p("div",{className:"border-subtler border-b p-3",children:E(j,{className:"bg-raised space-y-2 rounded p-2",children:[p(nR,{currentNode:h,targetNode:d,moveStatus:a}),p("div",{className:"border-subtler border-b"}),E(me,{className:"justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.task.duration")}),p("span",{className:"typo-compact-xs-normal text-fg-default",children:m})]})]})}),E(j,{className:"border-subtler min-h-0 gap-1.5 border-b p-3",children:[E(me,{className:"space-x-1.5",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:t("move.amr.rightPanel.task.pathHistory")}),p("span",{className:"typo-compact-sm2-normal text-fg-subtle",children:c.length})]}),p(Dv,{items:c,className:"min-h-0 flex-1 overflow-y-auto"})]})]})},{useEffect:ro,useRef:ia,useState:rh}=await wt("react"),Rg=[{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"}],ON=({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}=en(),[u,f]=rh(!1),[m,v]=rh(!1),[g,b]=rh(new Set),y=ia(!1),w=ia(!1),_=ia(!1),R=ia(""),T=ia(!1),P=ia(!1),M=r?.chargeState?.charge??"none",x=r?.chargeState?.dockResult??"",S=r?.chargeState?.dock??!1,C=M.toLowerCase(),k=x.toLowerCase(),I=k==="move",G=k==="fail",q=C!=="none"&&M!=="",O=C==="charging",W=C==="battery_on",Z=u||I||W,K=!Z&&S,oe=h(Z?"move.amr.rightPanel.dock.status.move":K?"move.amr.rightPanel.dock.status.dock":"move.amr.rightPanel.dock.status.undocked"),te=Z?"blue":K?"green":"red",ve=I&&!W&&!O,ce=[...u&&!I?["pointDock"]:[],...ve?["docking"]:[],...W?["checkCharge"]:[],...O?["complete"]:[]],Q=Rg.map(Ce=>({message:h(Ce.label),result:g.has(Ce.key)?"success":void 0})),re=ce.map(Ce=>Rg.findIndex(X=>X.key===Ce)).filter(Ce=>Ce>=0);ro(()=>{const Ce=y.current;y.current=O,!(!O||Ce||T.current)&&(f(!1),b(X=>{const Be=new Set(X);return Be.add("pointDock"),Be.add("docking"),Be.add("checkCharge"),Be.add("complete"),Be}))},[O]),ro(()=>{const Ce=w.current;w.current=W,!(!W||Ce||T.current)&&b(X=>{const Be=new Set(X);return Be.add("pointDock"),Be.add("docking"),Be})},[W]),ro(()=>{const Ce=_.current;_.current=I,!(!I||Ce||T.current)&&b(X=>{const Be=new Set(X);return Be.add("pointDock"),Be})},[I]),ro(()=>{const Ce=R.current;R.current=k,!(k!=="fail"||Ce==="fail")&&(f(!1),b(new Set))},[k]);const J=()=>{R.current="",b(new Set),f(!1),v(!1),T.current=!1,P.current=!1};ro(()=>{if(m){if(I){P.current=!0;return}P.current&&(P.current=!1,v(!1),T.current=!1)}},[m,I]);const ne=()=>{J(),f(!0),t()},ue=()=>{J(),i()},Te=()=>{s()},_e=()=>{a()},fe=()=>{J(),v(!0),T.current=!0,n()},be=()=>E(j,{className:"gap-2",children:[E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"successSoft",onClick:ne,disabled:c,children:h("move.amr.rightPanel.dock.action.dock")}),p(We,{variant:"dangerSoft",onClick:fe,disabled:c,children:h("move.amr.rightPanel.dock.action.undock")})]}),Z&&E(j,{className:"gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:h("move.amr.rightPanel.dock.operation.motion")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"dangerSoft",leadingIcon:p(Yg,{className:"size-3"}),disabled:m,onClick:ue,children:h("move.amr.rightPanel.common.stop")}),e?p(We,{variant:"soft",leadingIcon:p(ly,{className:"size-3"}),disabled:m,onClick:_e,children:h("move.amr.rightPanel.dock.action.resume")}):p(We,{variant:"soft",leadingIcon:p(cy,{className:"size-3"}),disabled:m,onClick:Te,children:h("move.amr.rightPanel.dock.action.pause")})]})]})]});return E(vi,{children:[E(j,{className:"border-subtler gap-2.5 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.dock.operation.title")}),E(j,{className:"gap-2 rounded",children:[E("div",{className:"bg-fill-disabled grid grid-cols-2 gap-x-3 rounded-md px-3 py-3",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:h("move.amr.rightPanel.dock.operation.dock")}),E(me,{className:"items-center gap-1.5",children:[p(gi,{color:te,className:Z||K?"animate-pulse":void 0}),p("p",{className:"typo-compact-xs2-medium text-fg-default",children:oe})]})]}),E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:h("move.amr.rightPanel.dock.operation.charge")}),p("p",{className:"typo-compact-xs2-medium text-fg-default uppercase",children:q?M:h("move.amr.rightPanel.common.none")})]})]}),be(),E(me,{className:"items-start gap-1",children:[p("div",{className:"flex size-4 shrink-0 items-center justify-center",children:p(Pu,{className:"text-fg-subtlest size-3"})}),p("p",{className:"typo-compact-xs-normal text-fg-subtler flex-1",children:h("move.amr.rightPanel.dock.operation.description")})]})]})]}),E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.dock.status.title")}),p(Dv,{items:Q,latestIndexes:m?[]:re,compact:!0})]}),E(j,{className:"border-subtler gap-2 border-b p-2.5",children:[E(me,{className:"items-center justify-between self-stretch",children:[E(me,{className:"flex-1 items-center gap-1.5",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.dock.retryCount")}),G&&p("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")})]}),E("button",{type:"button",className:"hover:bg-fill-hovered flex h-5 items-center gap-0.5 rounded-sm px-1.5",onClick:l,children:[p(Sc,{className:"text-fg-default size-3"}),p("span",{className:"text-fg-default text-[10px] leading-3 font-semibold",children:h("move.amr.rightPanel.common.settings")})]})]}),d&&E(me,{className:"border-danger bg-fill-danger-subtlest mt-1 items-start gap-2 rounded-md border px-3 py-2.5",children:[p(oy,{className:"text-fg-danger mt-0.5 size-4 shrink-0"}),p("p",{className:"typo-compact-xs-semibold text-fg-danger",children:d})]}),p("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?p("p",{className:"text-fg-default text-sm leading-5",children:o}):p("p",{className:"text-fg-subtler text-sm leading-5",children:"—"})})]})]})},{useEffect:mR,useState:ah}=await wt("react"),{createPortal:gR}=await wt("react-dom"),bR=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}`},FN=({onOpenChange:r,open:e,close:t,onSaveMapping:n,completedKeyframeCount:i=0,totalKeyframePoints:s=0,durationSeconds:a=0,existingMapNames:o=[]})=>{const{t:l}=en(),[c,d]=ah(""),[h,u]=ah(!1),[f,m]=ah(""),v=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 w=await n(y);if(w.ok){d(""),g();return}"reason"in w&&w.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)}},g=()=>{h||(d(""),m(""),t?.(),r?.(!1))};if(mR(()=>{e||(d(""),m(""),u(!1))},[e]),!e)return null;const b=E(j,{className:"fixed inset-0 z-50 items-center justify-center p-4",children:[p("button",{type:"button","aria-label":l("move.amr.rightPanel.map.saveDialog.closeBackdrop"),className:"bg-bg-dim absolute inset-0",onClick:g}),E(j,{className:"bg-bg-overlay relative w-full max-w-xl overflow-hidden rounded-lg p-4",children:[p(j,{className:"shrink-0 gap-0.5 p-1",children:E(me,{className:"items-start justify-between",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-lg-semibold text-fg-default",children:l("move.amr.rightPanel.map.saveDialog.title")}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.saveDialog.description")})]}),p(qn,{variant:"transparent",size:"2xs",icon:p(Pa,{}),className:"text-fg-subtle",onClick:g,disabled:h})]})}),E(j,{className:"gap-3 p-1 pt-3",children:[E(j,{className:"gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:l("move.amr.rightPanel.map.info.mapName")}),p(un,{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&&v()}}),p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.saveDialog.nameRule")})]}),f&&p(me,{className:"bg-bg-danger-tertiary outline-border-danger rounded-md p-2.5 outline outline-1 outline-offset-[-1px]",children:p("p",{className:"typo-compact-xs-normal text-fg-danger",children:f})}),E(j,{className:"bg-bg-alt-1 gap-1 rounded-md p-2.5",children:[E(me,{className:"items-center justify-between",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.mapping.keyframesReceived")}),p("p",{className:"typo-compact-2xs-semibold text-fg-information",children:i.toLocaleString()})]}),E(me,{className:"items-center justify-between",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.mapping.keyframePoints")}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:l("move.amr.rightPanel.map.mapping.points",{count:s.toLocaleString()})})]}),E(me,{className:"items-center justify-between",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.task.duration")}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:bR(a)})]})]})]}),E(me,{className:"shrink-0 items-center justify-end gap-2 p-1 pt-3",children:[p(We,{variant:"outlined",onClick:g,disabled:h,children:l("move.amr.rightPanel.common.cancel")}),p(We,{variant:"brand",onClick:v,disabled:h||!c.trim()||i<=0,children:l(h?"move.amr.rightPanel.common.saving":"move.amr.rightPanel.map.saveDialog.saveMap")})]})]})]});return typeof window>"u"?b:gR(b,document.body)},{useEffect:vR}=await wt("react"),UN=({isEraserEnabled:r=!1,onEraserToggle:e=()=>{},eraserRadius:t=1,setEraserRadius:n=()=>{},eraseSelectedAreaDisabled:i=!1,onEraseSelectedArea:s=()=>{},onReleaseSelectedPoints:a=()=>{},onSaveChanges:o=()=>{}})=>{const{t:l}=en();return vR(()=>()=>{e(!1)},[e]),E(j,{className:"h-full justify-between overflow-y-auto",children:[E(j,{children:[E(j,{className:"gap-0.5 px-3 pt-3",children:[E(me,{className:"justify-between",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.map.erasing.eraseMode")}),p(xa,{size:"default",checked:r,onCheckedChange:()=>e(!r)})]}),E("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[l("move.amr.rightPanel.map.erasing.descriptionLine1"),p("br",{}),l("move.amr.rightPanel.map.erasing.descriptionLine2")]})]}),E(j,{className:"gap-2 p-3",children:[E(me,{className:"justify-between",children:[p("p",{className:"typo-compact-xs2-normal text-fg-default",children:l("move.amr.rightPanel.map.erasing.eraserRadius")}),E("p",{className:"typo-compact-xs2-normal text-fg-default",children:[t.toFixed(1)," m"]})]}),p(Zg,{min:0,max:5,step:.1,value:[t],onValueChange:c=>n(c[0]),disabled:!r})]}),E(j,{className:"border-border-subtler gap-2 border-b-[1px] px-3 pb-3",children:[p(We,{size:"xs2",variant:"soft",leadingIcon:p(dy,{className:"size-3.5"}),disabled:!r||i,onClick:s,children:l("move.amr.rightPanel.map.erasing.eraseSelectedArea")}),p(We,{size:"xs2",variant:"soft",leadingIcon:p(hy,{className:"size-3.5"}),disabled:!r,onClick:a,children:l("move.amr.rightPanel.map.erasing.releaseSelectedPoints")})]})]}),p(j,{className:"p-3",children:p(We,{variant:"brand",size:"sm",onClick:o,disabled:!r,children:l("move.amr.rightPanel.common.saveChanges")})})]})},{useEffect:yR,useMemo:Yl,useState:Kl}=await wt("react"),BN=({selectedObjects:r,setTopologyTab:e,onSelectionResetRequested:t,onDeleteNodesRequested:n,onNodeSelected:i,nodes:s=[],nodesPerPage:a=5})=>{const{theme:o}=Ar(),{t:l}=en(),[c,d]=Kl(""),[h,u]=Kl(1),[f,m]=Kl("all"),[v,g]=Kl(!1),b=["all","goal","route","align"],y=Yl(()=>r.map(O=>({id:String(O.userData?.id??""),name:O.name,uuid:O.uuid,type:O.userData.type||"unknown",safetyField:typeof O.userData.safetyField=="number"?O.userData.safetyField:0,x:0,y:0,z:0})),[r]),w=Yl(()=>y.map(O=>O.uuid),[y]),_=Yl(()=>s.filter(O=>c?O.name?.toLowerCase()?.includes(c.toLowerCase()):!0),[s,c]),R=Yl(()=>({all:_,goal:_.filter(O=>O.type==="goal"),route:_.filter(O=>O.type==="route"),align:_.filter(O=>O.type==="align")}),[_]),T=R[f],P=Math.max(1,Math.ceil(T.length/a)),M=Math.min(h,P);yR(()=>{h!==M&&u(M)},[h,M]);const x=()=>{g(!1),t()},S=()=>{n()},C=O=>{!v&&(e?.("edit"),w.includes(O))||i(O)},k=O=>O.toLowerCase()==="goal"?p(Kg,{className:"text-fg-warning"}):O.toLowerCase()==="route"?p(Nu,{className:"text-fg-brand"}):p($g,{className:"text-fg-success"}),I=O=>O.toLowerCase()==="goal"?"text-fg-warning":O.toLowerCase()==="route"?"text-fg-brand":"text-fg-success",G=O=>{switch(O.toLowerCase()){case"goal":return l("move.amr.rightPanel.topology.nodeType.goal");case"route":return l("move.amr.rightPanel.topology.nodeType.route");case"align":return l("move.amr.rightPanel.topology.nodeType.align");default:return O.toUpperCase()}},q=O=>O.length===0?p(_r,{className:"h-full w-full flex-1 [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:p(Du,{}),message:l("move.amr.rightPanel.topology.nodes.empty")}):O.map(W=>E(j,{children:[E(me,{className:"cursor-pointer items-center justify-between py-2.5",onClick:()=>{C(W.uuid)},children:[E(me,{className:"items-center gap-2",children:[v&&p(Lu,{size:"md",name:"topology-node-select",checkValue:W.uuid,value:w,handleChange:()=>{C(W.uuid)}}),E(j,{className:"w-full gap-0.5",children:[p("p",{className:"typo-compact-sm-normal text-fg-default",children:`${W.name?W.name:W.id+"(ID)"}`}),E(me,{className:"items-center gap-2",children:[E(me,{className:"items-center gap-0.5",children:[k(W.type),p("p",{className:`typo-compact-2xs-semibold ${I(W.type)}`,children:G(W.type)})]}),p(ji,{type:"vertical",thickness:"thick",className:"text-fg-subtler h-4"}),p(me,{children:E("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[W.x.toFixed(1),", ",W.y.toFixed(1),","," ",W.z.toFixed(1)]})})]})]})]}),!v&&p(Qg,{className:"text-fg-default"})]}),p(ji,{className:"text-fg-subtler"})]},W.uuid));return E(j,{className:"h-full min-h-0",children:[E(me,{className:"items-center justify-between px-3 pt-3",children:[E(me,{className:"gap-1",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l(v?"move.amr.rightPanel.topology.nodes.selectedTitle":"move.amr.rightPanel.topology.nodes.title")}),v?p("p",{className:"typo-compact-sm2-semibold text-fg-brand",children:y.length}):E(me,{className:"items-baseline",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-brand",children:T.length}),E("p",{className:"typo-compact-2xs-semibold text-fg-subtler",children:["/",s.length]})]})]}),v?p(Af,{leadingIcon:p(Pa,{}),onClick:x,children:l("move.amr.rightPanel.common.cancel")}):p(Af,{leadingIcon:p(Hg,{}),onClick:()=>{g(!0)},children:l("move.amr.rightPanel.common.select")})]}),v?p("div",{className:"p-3",children:p(j,{className:`${o==="light"?"bg-white":"bg-raised"} max-h-32 overflow-y-auto rounded-md px-3 py-1`,children:y.length>0?y.map(O=>E(me,{className:"cursor-pointer justify-between py-1.5",onClick:()=>i(O.uuid),children:[p("p",{className:"typo-compact-sm-normal text-fg-default truncate",children:`${O.name?O.name:O.id+" (ID)"}`}),E(me,{className:"items-center gap-0.5",children:[k(O.type),p("p",{className:`typo-compact-2xs-semibold uppercase ${I(O.type)}`,children:G(O.type)})]})]},O.uuid)):p("p",{className:"typo-compact-sm-normal text-fg-subtler py-1",children:l("move.amr.rightPanel.topology.nodes.noSelected")})})}):p("div",{className:"p-3",children:p(un,{className:"w-full",size:"sm",type:"search",placeholder:l("move.amr.rightPanel.topology.nodes.searchByName"),value:c,onChange:O=>{d(O.target.value)}})}),E(Au,{className:"min-h-0 w-full flex-1 px-3",variant:"line",value:f,onValueChange:O=>{b.includes(O)&&m(O)},children:[E(Tu,{children:[p(Hi,{value:"all",children:l("move.amr.rightPanel.topology.nodeType.all")}),p(Hi,{value:"goal",children:l("move.amr.rightPanel.topology.nodeType.goal")}),p(Hi,{value:"route",children:l("move.amr.rightPanel.topology.nodeType.route")}),p(Hi,{value:"align",children:l("move.amr.rightPanel.topology.nodeType.align")})]}),E(j,{className:"min-h-0 flex-1 overflow-y-auto p-1",children:[p(js,{value:"all",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-2",children:q(R.all)})}),p(js,{value:"goal",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-2",children:q(R.goal)})}),p(js,{value:"route",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-2",children:q(R.route)})}),p(js,{value:"align",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-2",children:q(R.align)})})]})]}),v&&p(j,{className:"sticky bottom-0 z-[1] p-3",children:p(We,{leadingIcon:p(wr,{}),variant:"dangerSoft",className:"h-9",onClick:S,children:l("move.amr.rightPanel.topology.nodes.deleteCount",{count:y.length})})})]})},{useEffect:xR}=await wt("react"),zN=({selectedTool:r,onToolChange:e,selectedNodeType:t,onSelectNodeType:n,selectedNodePlacementType:i,onSelectNodePlacementType:s,onAddNodeAtRobot:a,onAddNodeAtCursor:o,onDeleteLastNode:l,canDeleteLastNode:c=!0,onSaveTopologyChanges:d,onCancelTopologyChanges:h})=>{const{confirmDialog:u}=As({confirmComponent:Cs}),{t:f}=en();return xR(()=>{e("target")},[e]),E(j,{className:"h-full min-h-0",children:[E(j,{className:"min-h-0 flex-1 overflow-y-auto",children:[E(j,{className:"border-subtler gap-0.5 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:f("move.amr.rightPanel.topology.add.title")}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:f("move.amr.rightPanel.topology.add.description")})]}),E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:f("move.amr.rightPanel.topology.add.selectNodeType")}),E("div",{className:"grid grid-cols-3 gap-2",children:[p(Ut,{className:"w-full",name:"topology-node-type-goal",checkValue:"goal",value:t,onChange:m=>{m.target.checked&&n("goal")},children:f("move.amr.rightPanel.topology.nodeType.goal")}),p(Ut,{className:"w-full",name:"topology-node-type-route",checkValue:"route",value:t,onChange:m=>{m.target.checked&&n("route")},children:f("move.amr.rightPanel.topology.nodeType.route")}),p(Ut,{className:"w-full",name:"topology-node-type-align",checkValue:"align",value:t,onChange:m=>{m.target.checked&&n("align")},children:f("move.amr.rightPanel.topology.nodeType.align")})]})]}),E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:f("move.amr.rightPanel.topology.add.selectPlacement")}),E(j,{className:"gap-2",children:[p(Ut,{className:"w-full",name:"topology-node-placement-cursor",checkValue:"cursor",value:i,onChange:m=>{m.target.checked&&s("cursor")},children:f("move.amr.rightPanel.topology.add.atCursorPosition")}),p(Ut,{className:"w-full",name:"topology-node-placement-robot",checkValue:"robot",value:i,onChange:m=>{m.target.checked&&s("robot")},children:f("move.amr.rightPanel.topology.add.atRobotPosition")})]})]})]}),E(j,{className:"border-subtler sticky bottom-0 z-1 gap-2 border-b p-3",children:[p(We,{variant:"soft",className:"text-fg-default",onClick:()=>{if(i==="robot"){a();return}o()},children:f("move.amr.rightPanel.topology.add.addNode")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"outlined",onClick:async()=>{await u({title:f("move.amr.rightPanel.common.cancel"),content:f("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:f("move.amr.rightPanel.common.discard"),no:f("move.amr.rightPanel.common.keepEditing")}})&&h?.()},children:f("move.amr.rightPanel.common.cancel")}),p(We,{variant:"brand",onClick:d,children:f("move.amr.rightPanel.common.save")})]})]})]})},{useEffect:Bs,useMemo:Ng,useRef:_R,useState:In}=await wt("react"),oh=["INIT","CHARGING","AUTO_DOOR","ARUCO","APRIL","V_MARKER","TAPE","PRECISION"],pi={dir:"FORWARD",method:"PP",speed:0,avoidRange:0,safetyField:0},Si=r=>Number(r.toFixed(3)),lh=(r,e,t,n)=>{const i=Number(r);return Number.isNaN(i)?n:Math.min(t,Math.max(e,i))},wR=r=>{const e=r.toLowerCase().replace("init","goal");return e==="route"||e==="align"?e:"goal"},HN=({selectedObjects:r,nodes:e=[],links:t=[],onToolChange:n,onUpdateNode:i,onUpdateLink:s,onDeleteLink:a,onFocusLink:o,onDeleteSelectedNodes:l,onCancelTopologyChanges:c,onSaveTopologyChanges:d})=>{const{confirmDialog:h}=As({confirmComponent:Cs}),{t:u}=en();Bs(()=>{n?.("select")},[n]);const f=Ng(()=>r.map(A=>{const Y=e.find(V=>V.uuid===A.uuid);return{uuid:A.uuid,externalId:String(A.userData?.id??""),name:A.name,type:wR(Y?.type||A.userData.type||"goal"),features:Array.isArray(A.userData.features)?A.userData.features.filter(V=>typeof V=="string"&&oh.includes(V)):[],x:A.position.x,y:A.position.y,z:A.position.z,rx:Si(A.rotation.x*180/Math.PI),ry:Si(A.rotation.y*180/Math.PI),rz:Si(A.rotation.z*180/Math.PI)}}),[e,r]),m=f[f.length-1],v=!!m,[g,b]=In(null),[y,w]=In(""),[_,R]=In("goal"),[T,P]=In([]),[M,x]=In("0.0"),[S,C]=In("0.0"),[k,I]=In("0.0"),[G,q]=In("0.0"),[O,W]=In(pi.dir),[Z,K]=In(pi.method),[oe,te]=In(String(pi.speed)),[ve,ce]=In(String(pi.avoidRange)),[Q,re]=In(String(pi.safetyField)),J=_R(null),[ne,ue]=In(!1),[Te,_e]=In(!1),[fe,be]=In(!1),[Ce,X]=In("1");Bs(()=>{w(m?.name??""),R(m?.type??"goal"),P(m?.features??[]),x(String(Si(m?.x??0))),C(String(Si(m?.y??0))),I(String(Si(m?.z??0))),q(String(Si(m?.rz??0)))},[m?.uuid,m?.name,m?.type,m?.features,m?.x,m?.y,m?.z,m?.rz]);const Be=Ng(()=>m?t.filter(Y=>Y.from===m.externalId||Y.to===m.externalId).map(Y=>{const V=Y.from===m.externalId,$=V?Y.to:Y.from,le=e.find(Ie=>Ie.id===$);return{...Y,isSource:V,oppositeNodeName:le?.name||le?.id||$}}):[],[m,t,e]);Bs(()=>{if(!Be.length){b(null);return}b(A=>A&&Be.some(Y=>Y.id===A)?A:null)},[Be]);const Me=Be.find(A=>A.id===g)??null,et=()=>{const A=J.current;if(!A){ue(!1),_e(!1);return}const{scrollTop:Y,scrollHeight:V,clientHeight:$}=A;if(!(V-$>1)){ue(!1),_e(!1);return}ue(Y>1),_e(Y+$<V-1)};Bs(()=>{b(null)},[m?.uuid]),Bs(()=>{!Me&&g!==null&&b(null)},[Me,g]),Bs(()=>{o?.(Me?.id??null)},[o,Me?.id]),Bs(()=>{et()},[Be.length]),Bs(()=>{W(Me?.dir??pi.dir),K(Me?.method??pi.method),te(String(Si(Me?.speed??pi.speed))),ce(String(Si(Me?.avoidRange??pi.avoidRange))),re(String(Si(Me?.safetyField??pi.safetyField)))},[Me?.id,Me?.dir,Me?.method,Me?.speed,Me?.avoidRange,Me?.safetyField]);const Se=(A,Y)=>{i?.(A,Y)},Ye=(A,Y)=>{s?.(A,Y)},ee=(A,Y)=>{if(!m)return;const V=Si(Number(Y||0)),$=String(V);A==="x"&&(x($),Se(m.uuid,{x:V})),A==="y"&&(C($),Se(m.uuid,{y:V})),A==="z"&&(I($),Se(m.uuid,{z:V}))},U=(A,Y)=>{if(!m)return;const V=Si(Number(Y||0)),$=String(V);q($),Se(m.uuid,{rz:V})};return E(j,{className:"h-full min-h-0 overflow-hidden",children:[v?E(j,{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto",children:[E(j,{className:"border-subtler gap-3 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.nodeProperties")}),E(j,{className:"gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.nodeId")}),E(me,{className:"items-center gap-1.5",children:[p("p",{className:"typo-compact-xs-normal text-fg-subtler flex-1",children:m?.externalId??""}),m?.externalId&&p("button",{className:"text-fg-subtler hover:text-fg-default shrink-0",onClick:()=>{eb({text:m.externalId??""})},children:p(Jg,{className:"size-3.5"})})]})]}),E(j,{className:"gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.name")}),p(un,{className:"w-full",type:"text",value:y,disabled:!v,onChange:A=>{if(!m)return;const Y=A.target.value;w(Y),Se(m.uuid,{name:Y})}})]})]}),p("div",{className:"border-subtler border-b p-1",children:p(ha,{title:p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.features")}),children:p("div",{className:"grid grid-cols-2 gap-x-2 gap-y-2",children:oh.map(A=>p(Lu,{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-${m?.uuid??""}`,checkValue:A,value:T,disabled:!v,handleChange:Y=>{if(!m||!Array.isArray(Y))return;const V=Y.filter($=>typeof $=="string"&&oh.includes($));P(V),Se(m.uuid,{features:V})},children:p("span",{className:"typo-compact-xs-normal text-fg-default",children:A})},A))})})}),p("div",{className:"border-subtler border-b p-1",children:E(ha,{initialOpen:!0,title:E(me,{className:"w-full items-center justify-between",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.transform")}),E(me,{className:"text-fg-default items-center gap-0.5",children:[p(We,{variant:"transparent",size:"2xs",leadingIcon:p(Sc,{}),onClick:A=>{A.preventDefault(),A.stopPropagation(),be(Y=>!Y)},children:u("move.amr.rightPanel.topology.edit.stepSize")}),p("div",{className:`overflow-hidden transition-all duration-200 ease-out ${fe?"w-32 opacity-100":"pointer-events-none w-0 opacity-0"}`,children:p(cn,{className:"h-8 w-32",value:Ce,step:.1,handleChange:A=>{X(A)}})})]})]}),children:[E(j,{className:"gap-2 pt-1",children:[E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-danger",children:"X"}),p("p",{className:"text-fg-subtle",children:"(mm)"})]}),p(cn,{className:"w-full",value:M,step:Number(Ce)||1,disabled:!v,handleChange:A=>{ee("x",A)}})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-success",children:"Y"}),p("p",{className:"text-fg-subtle",children:"(mm)"})]}),p(cn,{className:"w-full",value:S,step:Number(Ce)||1,disabled:!v,handleChange:A=>{ee("y",A)}})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-brand",children:"Z"}),p("p",{className:"text-fg-subtle",children:"(mm)"})]}),p(cn,{className:"w-full",value:k,step:Number(Ce)||1,disabled:!v,handleChange:A=>{ee("z",A)}})]})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-information",children:"RZ"}),p("p",{className:"text-fg-subtle",children:"(°)"})]}),p(cn,{className:"w-full",value:G,step:Number(Ce)||1,disabled:!v,min:0,max:360,handleChange:A=>{U("rz",A)}})]})]})}),p("div",{className:"border-subtler border-b p-1",children:p(ha,{title:E(me,{className:"items-center justify-between pr-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.connectedLinks")}),p("p",{className:"typo-compact-xs-normal text-fg-subtle",children:Be.length})]}),children:p(j,{className:"gap-2 pt-1",children:Be.length>0?E(vi,{children:[E("div",{className:"relative",children:[p(j,{ref:J,className:"border-border-subtle max-h-44 gap-1 overflow-y-auto rounded-md border p-1",onScroll:et,children:Be.map((A,Y)=>{const V=A.id===g;return p("button",{type:"button",className:`w-full rounded-md border px-3 py-2 text-left transition-colors ${V?"border-border-default bg-fill-subtler":"hover:border-border-subtle hover:bg-fill-control-surface border-transparent"}`,onClick:()=>{b(A.id)},children:E(me,{className:"typo-compact-sm-normal text-fg-default gap-1",children:[p("span",{className:"text-fg-subtle min-w-7",children:`${Y+1}.`}),A.isSource?E(vi,{children:[E(me,{className:"items-center gap-1",children:[p("span",{className:"bg-fill-brand block h-1.5 w-1.5 rounded-full"}),p("span",{className:"text-fg-default font-semibold",children:u("move.amr.rightPanel.topology.edit.thisNode")})]}),p("span",{className:"text-fg-subtle",children:"->"}),p("span",{children:A.oppositeNodeName})]}):E(vi,{children:[p("span",{children:A.oppositeNodeName}),p("span",{className:"text-fg-subtle",children:"->"}),E(me,{className:"items-center gap-1",children:[p("span",{className:"bg-fill-brand block h-1.5 w-1.5 rounded-full"}),p("span",{className:"text-fg-default font-semibold",children:u("move.amr.rightPanel.topology.edit.thisNode")})]})]})]})},A.id)})}),Be.length>4&&E(vi,{children:[ne&&p("div",{className:"from-bg-alt-1 pointer-events-none absolute top-0 right-0 left-0 h-3 rounded-t-md bg-gradient-to-b to-transparent"}),Te&&p("div",{className:"from-bg-alt-1 pointer-events-none absolute right-0 bottom-0 left-0 h-6 rounded-b-md bg-gradient-to-t to-transparent"})]})]}),Me&&E(j,{className:"border-border-subtle gap-3 rounded-md border p-3",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.selectedLinkInfo")}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.topology.link.dir")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(Ut,{className:"w-full",name:`topology-edit-link-dir-forward-${Me.id}`,checkValue:"FORWARD",value:O,onChange:A=>{A.target.checked&&(W("FORWARD"),Ye(Me.id,{dir:"FORWARD"}))},children:"FORWARD"}),p(Ut,{className:"w-full",name:`topology-edit-link-dir-reverse-${Me.id}`,checkValue:"REVERSE",value:O,onChange:A=>{A.target.checked&&(W("REVERSE"),Ye(Me.id,{dir:"REVERSE"}))},children:"REVERSE"})]})]}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.topology.link.method")}),p("div",{className:"grid grid-cols-3 gap-2",children:["PP","HPP","QD"].map(A=>p(Ut,{className:"w-full",name:`topology-edit-link-method-${Me.id}-${A.toLowerCase()}`,checkValue:A,value:Z,onChange:Y=>{Y.target.checked&&(K(A),Ye(Me.id,{method:A}))},children:A},A))})]}),E("div",{className:"grid grid-cols-2 gap-2",children:[E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-default",children:u("move.amr.rightPanel.common.speed")}),p("p",{className:"text-fg-subtle",children:"(max 1.0)"})]}),p(cn,{className:"w-full",value:oe,step:.1,min:0,max:1,handleChange:A=>{const Y=String(lh(A,0,1,pi.speed));te(Y),Ye(Me.id,{speed:Number(Y)})}})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-default",children:u("move.amr.rightPanel.topology.link.avoidRange")}),p("p",{className:"text-fg-subtle",children:"(max 1.2)"})]}),p(cn,{className:"w-full",value:ve,step:.1,min:0,max:1.2,handleChange:A=>{const Y=String(lh(A,0,1.2,pi.avoidRange));ce(Y),Ye(Me.id,{avoidRange:Number(Y)})}})]})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.topology.link.safetyField")}),p(cn,{className:"w-full",value:Q,step:1,min:0,handleChange:A=>{const Y=String(lh(A,0,Number.MAX_SAFE_INTEGER,pi.safetyField));re(Y),Ye(Me.id,{safetyField:Number(Y)})}})]}),p(We,{variant:"dangerSoft",className:"mt-1",leadingIcon:p(wr,{}),onClick:()=>{a?.(Me.id)},children:u("move.amr.rightPanel.topology.edit.deleteThisLink")})]})]}):E(j,{className:"border-border-subtle gap-1 rounded-md border p-3",children:[p("p",{className:"typo-compact-sm-normal text-fg-subtler",children:u("move.amr.rightPanel.topology.edit.noConnectedLinks")}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:u("move.amr.rightPanel.topology.edit.useLinkTab")})]})})})})]}):p(_r,{className:"flex-1 [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:p(Du,{}),message:u("move.amr.rightPanel.topology.nodes.empty"),description:u("move.amr.rightPanel.topology.edit.selectNodeToEdit")}),v&&E(j,{className:"gap-2 p-3",children:[p(We,{variant:"transparent",className:"text-fg-danger py-2",leadingIcon:p(wr,{}),onClick:l,children:u("move.amr.rightPanel.common.delete")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"outlined",className:"h-9",onClick: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?.()},children:u("move.amr.rightPanel.common.cancel")}),p(We,{variant:"brand",className:"h-9",onClick:d,children:u("move.amr.rightPanel.common.saveChanges")})]})]})]})},{useEffect:SR,useMemo:ch,useState:dr}=await wt("react"),zs={dir:"FORWARD",method:"PP",speed:0,avoidRange:0,safetyField:0},dh=(r,e,t,n)=>{const i=Number(r);return Number.isNaN(i)?n:Math.min(t,Math.max(e,i))},GN=({selectedObjects:r,nodes:e=[],onToolChange:t,onCreateLinks:n,onDeleteLinksBetweenSelected:i,onCancelTopologyChanges:s,onSaveTopologyChanges:a})=>{const{confirmDialog:o}=As({confirmComponent:Cs}),{t:l}=en();SR(()=>{t?.("select")},[t]);const[c,d]=dr("sequential"),[h,u]=dr("bidirectional"),[f,m]=dr(zs.dir),[v,g]=dr(zs.method),[b,y]=dr(String(zs.speed)),[w,_]=dr(String(zs.avoidRange)),[R,T]=dr(String(zs.safetyField)),P=ch(()=>r.map(I=>{const G=e.find(q=>q.uuid===I.uuid);return{id:I.uuid,name:G?.name||I.name||I.uuid,mesh:I}}),[e,r]),M=ch(()=>{const I=P.length;if(I<2)return l("move.amr.rightPanel.topology.link.selectAtLeastTwo");if(I===2){const[O,W]=P,Z=h==="bidirectional"?" ↔ ":" → ";return l("move.amr.rightPanel.topology.link.willCreateNamed",{from:O.name,connector:Z,to:W.name})}const G=c==="sequential"?I-1:I*(I-1)/2,q=h==="bidirectional"?G*2:G;return l("move.amr.rightPanel.topology.link.willCreateCount",{count:q})},[c,h,P,l]),x=ch(()=>({dir:f,method:v,speed:dh(b,0,1,zs.speed),avoidRange:dh(w,0,1.2,zs.avoidRange),safetyField:dh(R,0,Number.MAX_SAFE_INTEGER,zs.safetyField)}),[w,f,v,R,b]),S=I=>{P.length<2||n(I,c,x)},C=()=>{P.length<2||i()},k=P.length>=2;return E(j,{className:"h-full min-h-0 overflow-hidden",children:[E(j,{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto",children:[E(me,{className:"border-subtler gap-1.5 border-b p-3",children:[p(Cu,{className:"text-fg-default"}),E(j,{className:"gap-0.5",children:[p("p",{className:"compact-sm-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.nodeSelectedCount",{count:P.length})}),p("p",{className:"typo-compact-xs-normal text-fg-subtle",children:l("move.amr.rightPanel.topology.link.selectAtLeastTwoShort")})]})]}),E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.creationMode")}),E("div",{className:"grid grid-cols-2 gap-2",children:[E(Ut,{name:"topology-link-mode-sequential",className:"w-full",checkValue:"sequential",value:c,disabled:P.length<3,onChange:I=>{I.target.checked&&d("sequential")},children:[l("move.amr.rightPanel.topology.link.sequential"),p("br",{}),"(1→2→3)"]}),E(Ut,{name:"topology-link-mode-complete",className:"w-full",checkValue:"complete",value:c,disabled:P.length<3,onChange:I=>{I.target.checked&&d("complete")},children:[l("move.amr.rightPanel.topology.link.complete"),p("br",{}),"(all↔all)"]})]}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:l("move.amr.rightPanel.topology.link.modeAvailable")})]}),E(j,{className:"border-border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.direction")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(Ut,{name:"topology-link-direction-bidirectional",className:"w-full",checkValue:"bidirectional",value:h,disabled:!k,onChange:I=>{I.target.checked&&u("bidirectional")},children:l("move.amr.rightPanel.topology.link.bidirectional")}),p(Ut,{name:"topology-link-direction-unidirectional",className:"w-full",checkValue:"unidirectional",value:h,disabled:!k,onChange:I=>{I.target.checked&&u("unidirectional")},children:l("move.amr.rightPanel.topology.link.unidirectional")})]}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:l("move.amr.rightPanel.topology.link.configureDirection")})]}),E(j,{className:`border-subtler gap-2 border-b p-3 ${k?"":"opacity-50"}`,children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.properties")}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.dir")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(Ut,{name:"topology-link-dir-forward",className:"w-full",checkValue:"FORWARD",value:f,disabled:!k,onChange:I=>{I.target.checked&&m("FORWARD")},children:"FORWARD"}),p(Ut,{name:"topology-link-dir-reverse",className:"w-full",checkValue:"REVERSE",value:f,disabled:!k,onChange:I=>{I.target.checked&&m("REVERSE")},children:"REVERSE"})]})]}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.method")}),p("div",{className:"grid grid-cols-3 gap-2",children:["PP","HPP","QD"].map(I=>p(Ut,{name:`topology-link-method-${I.toLowerCase()}`,className:"w-full",checkValue:I,value:v,disabled:!k,onChange:G=>{G.target.checked&&g(I)},children:I},I))})]}),E("div",{className:"grid grid-cols-2 gap-2",children:[E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-default",children:l("move.amr.rightPanel.common.speed")}),p("p",{className:"text-fg-subtle",children:"(max 1.0)"})]}),p(cn,{className:"w-full",value:b,step:.1,min:0,max:1,disabled:!k,handleChange:I=>{y(I)}})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-default",children:l("move.amr.rightPanel.topology.link.avoidRange")}),p("p",{className:"text-fg-subtle",children:"(max 1.2)"})]}),p(cn,{className:"w-full",value:w,step:.1,min:0,max:1.2,disabled:!k,handleChange:I=>{_(I)}})]})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.safetyField")}),p(cn,{className:"w-full",value:R,step:1,min:0,disabled:!k,handleChange:I=>{T(I)}})]})]})]}),E(j,{className:"border-subtler border-b p-3",children:[p("p",{className:"typo-compact-xs-normal text-fg-subtle text-center",children:M}),p("p",{className:"typo-compact-xs-normal text-fg-subtler pt-1 text-center",children:l("move.amr.rightPanel.topology.link.previewProperties",{dir:x.dir,method:x.method,speed:x.speed.toFixed(1),avoid:x.avoidRange.toFixed(1)})}),E(j,{className:"gap-2 pt-3",children:[p(We,{variant:"soft",className:"text-fg-default py-2",disabled:P.length<2,onClick:()=>{S(h==="bidirectional")},children:l("move.amr.rightPanel.topology.link.linkSelected")}),p(We,{variant:"dangerSoft",onClick:C,disabled:P.length<2,leadingIcon:p(wr,{}),children:l("move.amr.rightPanel.topology.link.deleteLinks")}),E("div",{className:"grid grid-cols-2 gap-2 pt-1",children:[p(We,{variant:"outlined",className:"h-9",onClick:async()=>{await o({title:l("move.amr.rightPanel.common.cancel"),content:l("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:l("move.amr.rightPanel.common.discard"),no:l("move.amr.rightPanel.common.keepEditing")}})&&s?.()},children:l("move.amr.rightPanel.common.cancel")}),p(We,{variant:"brand",className:"h-9",onClick:a,children:l("move.amr.rightPanel.common.save")})]})]})]})]})},{useMemo:MR}=await wt("react"),ER=["NO_ENTRY","IGNORE_LIDAR_2D","IGNORE_LIDAR_3D"],VN=({draft:r,onDraftStart:e,onDraftCancel:t,onDraftClear:n,onDraftUndo:i,onDraftClose:s,onDraftCommit:a,onDraftMetaChange:o,zones:l,onDeleteZone:c,onSaveTopologyChanges:d,onCancelTopologyChanges:h})=>{const{confirmDialog:u}=As({confirmComponent:Cs}),f=MR(()=>r.state==="closed"?"Zone outline closed. Save to apply.":r.points.length===0?"No points placed yet. Start drawing to preview the flow.":r.points.length<3?"Need at least 3 points to close a zone.":"Ready to close zone.",[r.points.length,r.state]),m=r.state==="idle",v=r.state==="drawing",g=r.state==="closed",b=r.points.length>0&&!g,y=r.points.length>0&&!g,w=r.points.length>=3&&!g,_=g,R=r.points.length>0||g;return E(j,{className:"h-full min-h-0",children:[E(j,{className:"min-h-0 flex-1 gap-3 overflow-y-auto p-3",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Zone"}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Draw polygon zones with cursor preview and point connections."})]}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"1. Zone Details"}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Zone Name"}),p(un,{className:"w-full",size:"sm",placeholder:"Enter zone name",value:r.name,onChange:T=>{o({name:T.target.value})}})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Zone Type"}),p("div",{className:"grid grid-cols-1 gap-2",children:ER.map(T=>p(Ut,{className:"w-full",name:`topology-zone-type-${T.toLowerCase()}`,checkValue:T,value:r.type,onChange:P=>{P.target.checked&&o({type:T})},children:T},T))})]})]}),p(ji,{}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"2. Canvas Interaction Guide"}),E(j,{className:"gap-1 rounded-md border border-stroke-soft p-3",children:[p("p",{className:"typo-compact-xs-normal text-fg-default",children:g?"Zone draft is closed and ready to save":v?"Cursor preview follows the mouse in the scene":"Drawing starts only after you press Start Drawing"}),p("p",{className:"typo-compact-xs-normal text-fg-default",children:"Move cursor to preview a point"}),p("p",{className:"typo-compact-xs-normal text-fg-default",children:"Left click to place a zone point"}),p("p",{className:"typo-compact-xs-normal text-fg-default",children:"Each new point connects to the previous point"}),p("p",{className:"typo-compact-xs-normal text-fg-default",children:"Use Close Zone when the outline is complete"})]}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:f})]}),p(ji,{}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"3. Draft Point Preview"}),p(j,{className:"gap-1 rounded-md border border-stroke-soft p-2",children:r.points.length>0?r.points.map((T,P)=>E("div",{className:"flex items-center justify-between rounded-sm px-2 py-1.5",children:[E("div",{className:"flex items-center gap-2",children:[p("span",{className:"h-2 w-2 rounded-full bg-red-500"}),p("p",{className:"typo-compact-xs-semibold text-fg-default",children:`P${P+1}`})]}),E("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[T.x.toFixed(2),", ",T.y.toFixed(2)]})]},`${P}-${T.x}-${T.y}`)):p("p",{className:"typo-compact-xs-normal px-2 py-1 text-fg-subtler",children:"No points placed yet"})})]}),p(ji,{}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"4. Saved Zones"}),p(j,{className:"gap-1 rounded-md border border-stroke-soft p-2",children:l.length>0?l.map(T=>E("div",{className:"flex items-center justify-between gap-2 rounded-sm px-2 py-2",children:[E(j,{className:"min-w-0 flex-1 gap-0.5",children:[p("p",{className:"typo-compact-xs-semibold truncate text-fg-default",children:T.name||T.id}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:`${T.type} / ${T.polygon.length} points`})]}),p(We,{variant:"dangerSoft",className:"shrink-0",onClick:async()=>{await u({title:"Delete Zone",content:"Delete this saved zone?",buttonText:{yes:"Delete",no:"Keep"}})&&c(T.id)},children:"Delete"})]},T.id)):p("p",{className:"typo-compact-xs-normal px-2 py-1 text-fg-subtler",children:"No saved zones"})})]})]}),p(j,{className:"sticky bottom-0 z-[1] p-3",children:E(j,{className:"gap-2",children:[m&&p(We,{variant:"soft",className:"text-fg-default py-2",onClick:()=>{e({name:r.name,type:r.type})},children:"Start Drawing"}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"outlined",disabled:!b,onClick:i,children:"Undo Last Point"}),p(We,{variant:"outlined",disabled:!y,onClick:n,children:"Clear Points"})]}),p(We,{variant:"dangerSoft",disabled:!w,onClick:s,children:"Close Zone"}),E("div",{className:"grid grid-cols-2 gap-2 pt-1",children:[p(We,{variant:"outlined",onClick:async()=>{if(!R){h?.();return}await u({title:"Cancel",content:"Discard this zone draft and unsaved topology changes?",buttonText:{yes:"Discard",no:"Keep Editing"}})&&(t(),h?.())},children:"Cancel"}),p(We,{variant:"brand",disabled:!_,onClick:()=>{a(),d?.()},children:"Save"})]})]})})]})},Fo=({children:r,cancelLabel:e,saveLabel:t,onCancel:n,onSave:i,cancelDisabled:s=!1,saveDisabled:a=!1})=>E(j,{className:"border-subtler sticky bottom-0 z-1 gap-2 border-t p-3",children:[r,E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"outlined",className:"h-9",disabled:s,onClick:n,children:e}),p(We,{variant:"brand",className:"h-9",disabled:a,onClick:i,children:t})]})]}),{useEffect:hh,useMemo:sa,useState:Hs}=await wt("react"),mi={dir:"FORWARD",method:"PP",speed:0,avoidRange:0,safetyField:0},uh=(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))},TR=({selectedObjects:r,focusedLinkId:e,linkVisibilityFilter:t,nodes:n,visibleSelectedLinks:i,onFocusedLinkChange:s,onLinkVisibilityFilterChange:a,onToolChange:o,onCreateLinks:l,onUpdateLink:c,onDeleteLink:d,onDeleteLinksBetweenSelected:h,onCancelTopologyChanges:u,onSaveTopologyChanges:f})=>{const{confirmDialog:m}=As({confirmComponent:Cs}),{t:v}=en(),[g,b]=Hs("sequential"),[y,w]=Hs("bidirectional"),[_,R]=Hs(mi.dir),[T,P]=Hs(mi.method),[M,x]=Hs(String(mi.speed)),[S,C]=Hs(String(mi.avoidRange)),[k,I]=Hs(String(mi.safetyField)),[G,q]=Hs(!1);hh(()=>{o?.("select")},[o]);const O=sa(()=>r.map(be=>{const Ce=n.find(X=>X.uuid===be.uuid);return{id:be.uuid,name:Ce?.name||be.name||be.uuid,mesh:be}}),[n,r]),W=sa(()=>i.map(be=>{const Ce=n.find(Be=>Be.id===be.from),X=n.find(Be=>Be.id===be.to);return{...be,fromName:Ce?.name??be.from,toName:X?.name??be.to}}),[n,i]),Z=i.length>0,K=i.length,oe=sa(()=>e?i.find(be=>be.id===e)??null:null,[e,i]),te=be=>{be!=="all"&&be!=="forward"&&be!=="reverse"||a({...t,dir:be})},ve=be=>{be!=="all"&&be!=="PP"&&be!=="HPP"&&be!=="QD"||a({...t,method:be})},ce=sa(()=>W.find(be=>be.id===oe?.id)??null,[oe?.id,W]);hh(()=>{if(!Z){R(mi.dir),P(mi.method),x(String(mi.speed)),C(String(mi.avoidRange)),I(String(mi.safetyField)),q(!1);return}},[Z]),hh(()=>{oe&&(R(oe.dir),P(oe.method),x(String(oe.speed)),C(String(oe.avoidRange)),I(String(oe.safetyField)),q(!1))},[oe]);const Q=sa(()=>{const be=O.length;if(be<2)return v("move.amr.rightPanel.topology.link.selectAtLeastTwo");if(be===2){const[Be,Me]=O,et=y==="bidirectional"?" ↔ ":" → ";return v("move.amr.rightPanel.topology.link.willCreateNamed",{from:Be.name,connector:et,to:Me.name})}const Ce=g==="sequential"?be-1:be*(be-1)/2,X=y==="bidirectional"?Ce*2:Ce;return v("move.amr.rightPanel.topology.link.willCreateCount",{count:X})},[g,y,O,v]),re=sa(()=>({dir:_,method:T,speed:uh(M,-1,1,mi.speed),avoidRange:uh(S,-1,1.2,mi.avoidRange),safetyField:uh(k,-1,Number.MAX_SAFE_INTEGER,mi.safetyField)}),[S,_,T,k,M]),J=be=>{O.length<2||l?.(be,g,re)},ne=()=>{oe&&c?.(oe.id,re)},ue=()=>{oe&&d?.(oe.id)},Te=be=>Ce=>{if(q(!0),Number(Ce)<0){be("-1");return}be(Ce)},_e=O.length>=2,fe=Z?"edit":"add";return E(j,{className:"h-full min-h-0 overflow-hidden",children:[E(j,{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto",children:[E(me,{className:"border-subtler gap-1.5 border-b p-3",children:[p(Cu,{className:"text-fg-default"}),E(j,{className:"gap-0.5",children:[p("p",{className:"compact-sm-semibold text-fg-default",children:fe==="edit"?`${K} link${K>1?"s":""} selected`:v("move.amr.rightPanel.topology.link.nodeSelectedCount",{count:O.length})}),p("p",{className:"typo-compact-xs-normal text-fg-subtle",children:fe==="edit"?K>1?"Select one link from the list below to edit.":"Review and update the selected link.":v("move.amr.rightPanel.topology.link.selectAtLeastTwoShort")})]})]}),fe==="edit"&&E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Link Filter"}),E("div",{className:"grid grid-cols-2 gap-2",children:[E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Direction"}),E(dc,{size:"sm",value:t.dir,handleChange:te,children:[p(es,{value:"all",children:"All"}),p(es,{value:"forward",children:"Forward"}),p(es,{value:"reverse",children:"Reverse"})]})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Method"}),E(dc,{size:"sm",value:t.method,handleChange:ve,children:[p(es,{value:"all",children:"All"}),p(es,{value:"PP",children:"PP"}),p(es,{value:"HPP",children:"HPP"}),p(es,{value:"QD",children:"QD"})]})]})]})]}),fe==="add"&&E(vi,{children:[E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.topology.link.creationMode")}),E("div",{className:"grid grid-cols-2 gap-2",children:[E(Ut,{name:"topology-link-mode-sequential",className:"w-full",checkValue:"sequential",value:g,disabled:O.length<3,onChange:be=>{be.target.checked&&b("sequential")},children:[v("move.amr.rightPanel.topology.link.sequential"),p("br",{}),"(1→2→3)"]}),E(Ut,{name:"topology-link-mode-complete",className:"w-full",checkValue:"complete",value:g,disabled:O.length<3,onChange:be=>{be.target.checked&&b("complete")},children:[v("move.amr.rightPanel.topology.link.complete"),p("br",{}),"(all↔all)"]})]}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:v("move.amr.rightPanel.topology.link.modeAvailable")})]}),E(j,{className:"border-border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.topology.link.direction")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(Ut,{name:"topology-link-direction-bidirectional",className:"w-full",checkValue:"bidirectional",value:y,disabled:!_e,onChange:be=>{be.target.checked&&w("bidirectional")},children:v("move.amr.rightPanel.topology.link.bidirectional")}),p(Ut,{name:"topology-link-direction-unidirectional",className:"w-full",checkValue:"unidirectional",value:y,disabled:!_e,onChange:be=>{be.target.checked&&w("unidirectional")},children:v("move.amr.rightPanel.topology.link.unidirectional")})]}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:v("move.amr.rightPanel.topology.link.configureDirection")})]})]}),fe==="edit"&&E(j,{className:"border-subtler gap-3 border-b p-3",children:[E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Selected Links"}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:K>1?"Choose one link to load its properties into the editor.":"The selected link is ready to edit."})]}),p(j,{className:"border-border-subtle max-h-40 gap-1 overflow-y-auto rounded-md border p-1.5",children:W.map((be,Ce)=>E(me,{className:`items-center justify-between rounded-md border px-2 py-1.5 transition-colors ${be.id===oe?.id?"border-border-default bg-fill-subtler":"border-transparent bg-fill-control-surface hover:border-border-subtle"}`,onClick:()=>{s(be.id)},children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:`${Ce+1}. ${be.fromName} -> ${be.toName}`}),p("p",{className:"typo-compact-xs-normal text-fg-subtler shrink-0",children:`${be.method} / ${be.dir}`})]},be.id))})]}),E(j,{className:`border-subtler gap-2 border-b p-3 ${fe==="add"&&!_e?"opacity-50":""}`,children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.topology.link.properties")}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:v("move.amr.rightPanel.topology.link.dir")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(Ut,{name:"topology-link-dir-forward",className:"w-full",checkValue:"FORWARD",value:_,disabled:fe==="add"?!_e:!oe,onChange:be=>{be.target.checked&&(q(!0),R("FORWARD"))},children:"FORWARD"}),p(Ut,{name:"topology-link-dir-reverse",className:"w-full",checkValue:"REVERSE",value:_,disabled:fe==="add"?!_e:!oe,onChange:be=>{be.target.checked&&(q(!0),R("REVERSE"))},children:"REVERSE"})]})]}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:v("move.amr.rightPanel.topology.link.method")}),p("div",{className:"grid grid-cols-3 gap-2",children:["PP","HPP","QD"].map(be=>p(Ut,{name:`topology-link-method-${be.toLowerCase()}`,className:"w-full",checkValue:be,value:T,disabled:fe==="add"?!_e:!oe,onChange:Ce=>{Ce.target.checked&&(q(!0),P(be))},children:be},be))})]}),E("div",{className:"grid grid-cols-2 gap-2",children:[E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-default",children:v("move.amr.rightPanel.common.speed")}),p("p",{className:"text-fg-subtle",children:"(max 1.0)"})]}),p(cn,{className:"w-full",value:M,step:.1,increaseStep:Number(M)<0?1:.1,min:-1,max:1,disabled:fe==="add"?!_e:!oe,handleChange:Te(x)})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-default",children:v("move.amr.rightPanel.topology.link.avoidRange")}),p("p",{className:"text-fg-subtle",children:"(max 1.2)"})]}),p(cn,{className:"w-full",value:S,step:.1,increaseStep:Number(S)<0?1:.1,min:-1,max:1.2,disabled:fe==="add"?!_e:!oe,handleChange:Te(C)})]})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:v("move.amr.rightPanel.topology.link.safetyField")}),p(cn,{className:"w-full",value:k,step:1,min:-1,disabled:fe==="add"?!_e:!oe,handleChange:be=>{q(!0),I(be)}})]})]})]}),p(Fo,{cancelLabel:v("move.amr.rightPanel.common.cancel"),saveLabel:v("move.amr.rightPanel.common.save"),onCancel:async()=>{await m({title:v("move.amr.rightPanel.common.cancel"),content:v("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:v("move.amr.rightPanel.common.discard"),no:v("move.amr.rightPanel.common.keepEditing")}})&&u?.()},onSave:f,children:E(j,{className:"border-subtler border-b p-3",children:[p("p",{className:"typo-compact-xs-normal text-fg-subtle text-center",children:fe==="edit"?ce?`${ce.fromName} -> ${ce.toName} is selected for editing.`:"Select a link from the list above to edit.":Q}),p("p",{className:"typo-compact-xs-normal text-fg-subtler pt-1 text-center",children:fe==="edit"?oe?`dir ${re.dir} / method ${re.method} / speed ${re.speed.toFixed(1)} / avoid ${re.avoidRange.toFixed(1)}`:"":v("move.amr.rightPanel.topology.link.previewProperties",{dir:re.dir,method:re.method,speed:re.speed.toFixed(1),avoid:re.avoidRange.toFixed(1)})}),p(j,{className:"gap-2 pt-3",children:fe==="edit"?E(vi,{children:[p(We,{variant:"soft",className:"text-fg-default py-2",disabled:!oe||!G,onClick:ne,children:"Update selected link"}),p(We,{variant:"dangerSoft",onClick:ue,disabled:!oe,leadingIcon:p(wr,{}),children:"Delete selected link"})]}):E(vi,{children:[p(We,{variant:"soft",className:"text-fg-default py-2",disabled:O.length<2,onClick:()=>{J(y==="bidirectional")},children:v("move.amr.rightPanel.topology.link.linkSelected")}),p(We,{variant:"dangerSoft",onClick:h,disabled:O.length<2,leadingIcon:p(wr,{}),children:v("move.amr.rightPanel.topology.link.deleteLinks")})]})})]})})]})},AR=({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}=As({confirmComponent:Cs}),{t:u}=en(),f=r==="target";return E(j,{className:"h-full min-h-0 gap-0",children:[E(j,{className:"min-h-0 flex-1 overflow-y-auto",children:[E(j,{className:"border-subtler gap-0.5 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.add.title")}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:u("move.amr.rightPanel.topology.add.description")})]}),E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.add.selectNodeType")}),E("div",{className:"grid grid-cols-3 gap-2",children:[p(Ut,{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")}),p(Ut,{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")}),p(Ut,{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")})]})]}),E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.add.selectPlacement")}),E(me,{className:"items-center justify-between gap-2 py-1",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Cursor Preview"}),p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:"Enable cursor placement mode before adding at cursor position."})]}),p(xa,{checked:f,onCheckedChange:m=>{if(m){e?.("target");return}r==="target"&&e?.("select")}})]}),E(j,{className:"gap-2",children:[p(Ut,{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&&p(Ut,{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")})]})]})]}),p(Fo,{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:E(We,{variant:"soft",className:"text-fg-default",onClick:()=>{if(i==="robot"){a?.();return}if(r!=="target"){uy.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:fh,useMemo:Dg,useRef:ph,useState:ms}=await wt("react"),mh=["INIT","CHARGING","AUTO_DOOR","ARUCO","APRIL","V_MARKER","TAPE","PRECISION","SCAN_MATCH"],Mi=r=>Number(r.toFixed(3)),Lv=-1,Iv=31,CR=r=>{const e=r.trim();if(!/^-?\d+$/.test(e))return null;const t=Number(e);return Number.isInteger(t)?Math.min(Iv,Math.max(Lv,t)):null},PR=r=>{const e=r.toLowerCase().replace("init","goal");return e==="route"||e==="align"?e:"goal"},RR=({selectedObjects:r=[],selectedNodeTransform:e=null,nodes:t=[],robotPose:n=null,onUpdateNode:i,onTransformSelectedNodes:s,onDeleteSelectedNodes:a,onCancelTopologyChanges:o,onSaveTopologyChanges:l})=>{const{confirmDialog:c}=As({confirmComponent:Cs}),{t:d}=en(),[h,u]=ms(""),[f,m]=ms([]),[v,g]=ms("0"),[b,y]=ms("0.0"),[w,_]=ms("0.0"),[R,T]=ms("0.0"),[P,M]=ms("0.0"),[x,S]=ms(!1),[C,k]=ms("1"),I=ph({altKey:!1,metaKey:!1,ctrlKey:!1}),G=ph(null),q=ph(!1);fh(()=>{const ee=A=>{I.current={altKey:A.altKey,metaKey:A.metaKey,ctrlKey:A.ctrlKey}},U=()=>{I.current={altKey:!1,metaKey:!1,ctrlKey:!1},G.current=null};return window.addEventListener("keydown",ee),window.addEventListener("keyup",ee),window.addEventListener("blur",U),()=>{window.removeEventListener("keydown",ee),window.removeEventListener("keyup",ee),window.removeEventListener("blur",U)}},[]);const O=Dg(()=>r.map(ee=>{const U=t.find(A=>A.uuid===ee.uuid);return{uuid:ee.uuid,externalId:String(ee.userData?.id??""),name:ee.name,type:PR(U?.type||ee.userData?.type||"goal"),features:Array.isArray(ee.userData?.features)?ee.userData.features.filter(A=>typeof A=="string"&&mh.includes(A)):[],safetyField:typeof ee.userData?.safetyField=="number"?ee.userData.safetyField:U?.safetyField??0,x:ee.position.x,y:ee.position.y,z:ee.position.z,rz:Mi(ee.rotation.z*180/Math.PI)}}),[t,r]),W=O[O.length-1],Z=O.length===1,K=Dg(()=>{if(!n)return null;const ee=Number(n.x),U=Number(n.y),A=Number(n.rz);return[ee,U,A].some(Y=>Number.isNaN(Y))?null:{x:Mi(ee),y:Mi(U),rz:Mi(A)}},[n]);fh(()=>{u(W?.name??""),m(W?.features??[]),g(String(W?.safetyField??0))},[W?.uuid,W?.name,W?.features,W?.safetyField]),fh(()=>{let ee=null;e?ee={x:e.x,y:e.y,z:e.z,rz:e.rz}:W&&(ee={x:W.x,y:W.y,z:W.z,rz:W.rz}),y(String(Mi(ee?.x??0))),_(String(Mi(ee?.y??0))),T(String(Mi(ee?.z??0))),M(String(Mi(ee?.rz??0)))},[W,W?.uuid,W?.x,W?.y,W?.z,W?.rz,e]);const oe=(ee,U)=>{i?.(ee,U)},te=ee=>ee.filter(U=>typeof U=="string"&&mh.includes(U)),ve=(ee,U)=>{ee==="x"&&y(U),ee==="y"&&_(U),ee==="z"&&T(U)},ce=(ee,U)=>{if(ee==="x"||ee==="y"||ee==="z"){ve(ee,U);return}M(U)},Q=ee=>{const U=r[r.length-1];return U?ee==="x"?U.position.x:ee==="y"?U.position.y:ee==="z"?U.position.z:Mi(U.rotation.z*180/Math.PI):0},re=(ee=I.current)=>ee.altKey?"delta":ee.metaKey||ee.ctrlKey?"absolute":"single",J=()=>G.current??re(),ne=(ee,U)=>{G.current=re({altKey:U?.altKey,metaKey:U?.metaKey,ctrlKey:U?.ctrlKey})},ue=()=>{G.current=null},Te=ee=>{q.current=ee.metaKey||ee.ctrlKey},_e=(ee,U,A)=>{const Y=A?ee.features.includes(U)?ee.features:[...ee.features,U]:ee.features.filter(V=>V!==U);oe(ee.uuid,{features:Y})},fe=(ee,U)=>{if(!W||!Array.isArray(U))return;const A=te(U),Y=A.includes(ee),V=q.current;if(q.current=!1,m(A),V){for(const $ of O)_e($,ee,Y);return}oe(W.uuid,{features:A})},be=(ee,U,A)=>{if(!W)return;const Y=A?J():re(),V=Number(U);if(Number.isNaN(V))return;const $=Mi(V),le=String($);if(ee==="x"||ee==="y"||ee==="z"?ve(ee,le):M(le),Y==="delta"){const Ie=Mi(A?(A==="up"?1:-1)*(Number(C)||1):$-Q(ee));s?.(ee,Ie,"delta");return}if(Y==="absolute"){s?.(ee,$,"absolute");return}if(ee==="x"||ee==="y"||ee==="z"){oe(W.uuid,{[ee]:$});return}oe(W.uuid,{rz:$})},Ce=(ee,U,A)=>{if(A){be(ee,U,A);return}ce(ee,U)},X=(ee,U)=>{be(ee,U)},Be=(ee,U)=>{if(!W)return;const A=U?J():re(),Y=CR(ee);if(Y===null)return;const V=String(Y);if(g(V),A==="absolute"){for(const $ of O)oe($.uuid,{safetyField:Y});return}oe(W.uuid,{safetyField:Y})},Me=ee=>{W&&/^-?\d*$/.test(ee)&&g(ee)},et=(ee,U)=>{if(U){Be(ee,U);return}Me(ee)},Se=ee=>{Be(ee)},Ye=()=>{!Z||!K||(y(String(K.x)),_(String(K.y)),M(String(K.rz)),oe(W.uuid,K))};return E(j,{className:"h-full min-h-0 overflow-hidden",children:[E(j,{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto",children:[E(j,{className:"border-subtler gap-3 border-b p-3",children:[E(me,{className:"items-center justify-between gap-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:d("move.amr.rightPanel.topology.edit.nodeProperties")}),O.length>1&&E("p",{className:"typo-compact-2xs-semibold text-fg-subtler",children:[O.length," selected"]})]}),E(j,{className:"gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.topology.edit.nodeId")}),E(me,{className:"items-center gap-1.5",children:[p("p",{className:"typo-compact-xs-normal text-fg-subtler flex-1",children:W?.externalId??""}),W?.externalId&&p("button",{className:"text-fg-subtler hover:text-fg-default shrink-0",onClick:()=>{eb({text:W.externalId??""})},children:p(Jg,{className:"size-3.5"})})]})]}),E(j,{className:"gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.topology.edit.name")}),p(un,{className:"w-full",type:"text",value:h,onChange:ee=>{if(!W)return;const U=ee.target.value;u(U),oe(W.uuid,{name:U})}})]}),E(j,{className:"gap-1.5",children:[E(me,{className:"items-center gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.topology.link.safetyField")}),p("p",{className:"text-fg-subtle typo-compact-2xs-normal",children:"(-1 ~ 31)"})]}),p(cn,{className:"w-full",value:v,step:1,min:Lv,max:Iv,handleChange:(ee,U,A)=>{et(ee,A?.type)},handleEnter:ee=>{Se(ee)},onButtonPointerDown:ne,onButtonPointerUp:ue})]})]}),p("div",{className:"border-subtler border-b",children:p(ha,{title:p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:d("move.amr.rightPanel.topology.edit.features")}),children:p("div",{className:"grid grid-cols-2 gap-x-2 gap-y-2",children:mh.map(ee=>p(Lu,{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-${W?.uuid??""}`,checkValue:ee,value:f,onClick:Te,handleChange:U=>{fe(ee,U)},children:p("span",{className:"typo-compact-xs-normal text-fg-default",children:ee})},ee))})})}),p("div",{className:"border-subtler border-b",children:E(ha,{initialOpen:!0,title:E(me,{className:"w-full items-center justify-between",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:d("move.amr.rightPanel.topology.edit.transform")}),E(me,{className:"text-fg-default items-center gap-0.5",children:[p(We,{variant:"transparent",size:"2xs",leadingIcon:p(Sc,{}),onClick:ee=>{ee.preventDefault(),ee.stopPropagation(),S(U=>!U)},children:d("move.amr.rightPanel.topology.edit.stepSize")}),p("div",{className:`overflow-hidden transition-all duration-200 ease-out ${x?"w-32 opacity-100":"pointer-events-none w-0 opacity-0"}`,children:p(cn,{className:"h-8 w-32",value:C,step:.1,handleChange:ee=>{k(ee)}})})]})]}),children:[E(j,{className:"gap-2 pt-1",children:[E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-danger",children:"X"}),p("p",{className:"text-fg-subtle",children:"(m)"})]}),p(cn,{className:"w-full",value:b,step:Number(C)||1,handleChange:(ee,U,A)=>{Ce("x",ee,A?.type)},handleEnter:ee=>{X("x",ee)},onButtonPointerDown:ne,onButtonPointerUp:ue})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-success",children:"Y"}),p("p",{className:"text-fg-subtle",children:"(m)"})]}),p(cn,{className:"w-full",value:w,step:Number(C)||1,handleChange:(ee,U,A)=>{Ce("y",ee,A?.type)},handleEnter:ee=>{X("y",ee)},onButtonPointerDown:ne,onButtonPointerUp:ue})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-brand",children:"Z"}),p("p",{className:"text-fg-subtle",children:"(m)"})]}),p(cn,{className:"w-full",value:R,step:Number(C)||1,handleChange:(ee,U,A)=>{Ce("z",ee,A?.type)},handleEnter:ee=>{X("z",ee)},onButtonPointerDown:ne,onButtonPointerUp:ue})]})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-information",children:"RZ"}),p("p",{className:"text-fg-subtle",children:"(°)"})]}),p(cn,{className:"w-full",value:P,step:Number(C)||1,min:0,max:360,handleChange:(ee,U,A)=>{Ce("rz",ee,A?.type)},handleEnter:ee=>{X("rz",ee)},onButtonPointerDown:ne,onButtonPointerUp:ue}),Z&&K&&p(me,{className:"mt-2 justify-center",children:p(We,{variant:"transparent",size:"sm",leadingIcon:p(ya,{}),onClick:Ye,children:"Match Robot Pose"})})]})]})})]}),p(Fo,{cancelLabel:d("move.amr.rightPanel.common.cancel"),saveLabel:d("move.amr.rightPanel.common.saveChanges"),onCancel:async()=>{await c({title:d("move.amr.rightPanel.common.cancel"),content:d("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:d("move.amr.rightPanel.common.discard"),no:d("move.amr.rightPanel.common.keepEditing")}})&&o?.()},onSave:l,children:E("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:a,children:[p(wr,{className:"size-4"}),d("move.amr.rightPanel.common.delete")]})})]})},{useEffect:NR,useMemo:DR,useRef:LR,useState:$l}=await wt("react"),IR=r=>{const e=r.toLowerCase();return e==="goal"?p(Kg,{className:"text-fg-warning"}):e==="route"?p(Nu,{className:"text-fg-brand"}):p($g,{className:"text-fg-success"})},kR=({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,onTransformSelectedNodes:m,onDeleteSelectedNodes:v,onSaveTopologyChanges:g,onCancelTopologyChanges:b,showRobotPlacement:y=!0})=>{const{t:w}=en(),_=LR(null),[R,T]=$l(""),[P,M]=$l("all"),[x,S]=$l(!1),[C,k]=$l(!1),I=e.length>0,G=DR(()=>{const W=R.trim().toLowerCase(),Z=W?r.filter(K=>(K.name||K.id).toLowerCase().includes(W)):r;return{all:Z,goal:Z.filter(K=>K.type.toLowerCase()==="goal"),route:Z.filter(K=>K.type.toLowerCase()==="route"),align:Z.filter(K=>K.type.toLowerCase()==="align")}},[r,R]),q=G[P];NR(()=>{const W=_.current;if(!W)return;const Z=()=>{const{scrollTop:K,clientHeight:oe,scrollHeight:te}=W;S(K>4),k(K+oe<te-4)};return Z(),W.addEventListener("scroll",Z),()=>{W.removeEventListener("scroll",Z)}},[q]);const O=W=>W.length===0?p(_r,{className:"h-full w-full flex-1 [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:p(Du,{}),message:w("move.amr.rightPanel.topology.nodes.empty")}):W.map(Z=>E(j,{children:[E(me,{className:"hover:bg-fill-subtle cursor-pointer items-center justify-between rounded-md px-1.5 py-1.5 transition-colors",onClick:K=>{const oe=K.metaKey||K.ctrlKey?"remove":K.shiftKey?"add":"replace";i?.(Z.uuid,oe)},children:[E(me,{className:"min-w-0 flex-1 items-center gap-2",children:[IR(Z.type),E(me,{className:"min-w-0 flex-1 items-center justify-between gap-2",children:[p("p",{className:"typo-compact-xs-normal text-fg-default truncate",children:Z.name?Z.name:`${Z.id}(ID)`}),E(me,{className:"mr-2 shrink-0 items-center gap-1.5",children:[p("p",{className:"typo-compact-2xs-semibold text-fg-subtler uppercase",children:Z.type}),p(ji,{type:"vertical",thickness:"thick",className:"text-fg-subtler h-4"}),E("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:[Z.x.toFixed(1),", ",Z.y.toFixed(1),", ",Z.z.toFixed(1)]})]})]})]}),p(Qg,{className:"text-fg-default"})]}),p(ji,{className:"text-fg-subtler"})]},Z.uuid));return E(j,{className:"h-full min-h-0 gap-0",children:[E(j,{className:"border-subtler h-[25%] min-h-[16rem] gap-2 border-b p-3",children:[p(un,{size:"sm",className:"w-full",value:R,type:"search",placeholder:w("move.amr.rightPanel.topology.nodes.searchByName"),onChange:W=>{T(W.target.value)}}),E(Au,{className:"min-h-0 w-full flex-1",variant:"line",value:P,onValueChange:W=>{(W==="all"||W==="goal"||W==="route"||W==="align")&&M(W)},children:[E(me,{className:"items-center justify-between gap-2",children:[E(Tu,{children:[p(Hi,{value:"all",children:w("move.amr.rightPanel.topology.nodeType.all")}),p(Hi,{value:"goal",children:w("move.amr.rightPanel.topology.nodeType.goal")}),p(Hi,{value:"route",children:w("move.amr.rightPanel.topology.nodeType.route")}),p(Hi,{value:"align",children:w("move.amr.rightPanel.topology.nodeType.align")})]}),E("p",{className:"typo-compact-2xs-semibold text-fg-subtler shrink-0 px-2",children:[q.length," / ",r.length]})]}),E("div",{className:"border-border-subtle bg-fill-disabled relative min-h-0 flex-1 overflow-hidden rounded-md border",children:[q.length>4&&x&&p("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"}),E("div",{ref:_,className:"h-full min-h-0 overflow-y-auto px-1 py-0.5",children:[p(js,{value:"all",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-1",children:O(G.all)})}),p(js,{value:"goal",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-1",children:O(G.goal)})}),p(js,{value:"route",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-1",children:O(G.route)})}),p(js,{value:"align",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-1",children:O(G.align)})})]}),q.length>4&&C&&p("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"})]})]})]}),p(j,{className:"min-h-0 flex-1",children:I?p(RR,{selectedObjects:e,selectedNodeTransform:t,nodes:r,robotPose:n,onUpdateNode:f,onTransformSelectedNodes:m,onDeleteSelectedNodes:v,onCancelTopologyChanges:b,onSaveTopologyChanges:g}):p(AR,{selectedTool:s,onToolChange:a,selectedNodeType:o,onSelectNodeType:l,selectedNodePlacementType:c,onSelectNodePlacementType:d,onAddNodeAtRobot:h,onAddNodeAtCursor:u,onSaveTopologyChanges:g,onCancelTopologyChanges:b,showRobotPlacement:y})})]})},Ql=({label:r,value:e})=>E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtle",children:r}),p("span",{className:"typo-compact-xs-semibold text-fg-default",children:e})]}),OR=r=>{if(!r)return"-";const e=new Date(r);return Number.isNaN(e.getTime())?r:r.slice(0,19).replace("T"," ")},FR=({nodeCount:r=0,linkCount:e,zoneCount:t=0,createdAt:n,downloadDisabled:i=!1,downloadHelpText:s,onDownloadTopology:a,onCancelTopologyChanges:o,onSaveTopologyChanges:l})=>{const{t:c}=en();return E(j,{className:"h-full min-h-0",children:[E(j,{className:"min-h-0 flex-1 gap-4 p-3",children:[E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-sm-bold text-fg-default",children:"Overview"}),p("p",{className:"typo-compact-xs-normal text-fg-subtle",children:"Manage topology-level information and file actions."})]}),E(j,{className:"border-subtler bg-fill-control-surface gap-3 rounded-lg border p-3",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Topology Summary"}),E(j,{className:"gap-2",children:[p(Ql,{label:"Created At",value:OR(n)}),p(Ql,{label:"Nodes",value:r}),p(Ql,{label:"Links",value:e??"-"}),p(Ql,{label:"Zones",value:t})]})]}),E(j,{className:"border-subtler bg-fill-control-surface gap-2 rounded-lg border p-3",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Topology File"}),p("p",{className:"typo-compact-xs-normal text-fg-subtle",children:"Download the current topology data as topology.json."}),s&&p("p",{className:"typo-compact-xs-normal text-fg-warning",children:s})]})]}),p(Fo,{cancelLabel:c("move.amr.rightPanel.common.cancel"),saveLabel:c("move.amr.rightPanel.common.save"),onCancel:o,onSave:l,children:p(We,{variant:"soft",className:"h-9",disabled:i,leadingIcon:p(fy,{}),onClick:a,children:"Download topology"})})]})},{useMemo:Jl}=await wt("react"),UR=["NO_ENTRY","IGNORE_LIDAR_2D","IGNORE_LIDAR_3D"],BR=({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,onSaveTopologyChanges:v,onCancelTopologyChanges:g})=>{const{confirmDialog:b}=As({confirmComponent:Cs}),y=Jl(()=>{if(e.length===0)return[];const ne=new Set(e);return u.filter(ue=>ne.has(ue.id))},[e,u]),w=Jl(()=>r.editingZoneId?u.find(ne=>ne.id===r.editingZoneId)??null:t?y.find(ne=>ne.id===t)??null:y[0]??null,[r.editingZoneId,t,y,u]),_=Jl(()=>r.editingZoneId?u.find(ne=>ne.id===r.editingZoneId)??null:null,[r.editingZoneId,u]),R=e.length>1,T=Jl(()=>R?"multi-select":r.editingZoneId||y.length>0?"edit":"create",[r.editingZoneId,R,y.length]),P=_??w,M=r.state==="idle",x=r.state==="closed",S=r.editingZoneId!==null,C=r.state!=="idle",k=C,I=M&&w!==null,G=r.points.length>0&&!x,q=r.points.length>0&&!x,O=r.points.length>=3&&!x,W=x,Z=!C&&P===null,K=C?r.name:P?.name??"",oe=C?r.type:P?.type??"",te=S?"Update Zone":"Create Zone",ve=S?"Discard these edits and restore the original zone?":"Discard this zone draft and unsaved topology changes?",ce=I?"Create New Zone":"Start Drawing",Q=C,re=T==="create"&&M,J=T==="multi-select"?`${e.length} zones selected`:T==="edit"?r.editingZoneId?"Editing zone":"1 zone selected":"Create Zone";return E(j,{className:"h-full min-h-0",children:[E(j,{className:"min-h-0 flex-1 gap-3 overflow-y-auto p-3",children:[p(me,{className:"border-subtler gap-1.5 border-b pb-3",children:p(j,{className:"gap-0.5",children:p("p",{className:"compact-sm-semibold text-fg-default",children:J})})}),y.length>0&&!r.editingZoneId&&E(vi,{children:[E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Selected Zones"}),p(j,{className:"border-border-subtle max-h-40 gap-1 overflow-y-auto rounded-md border p-1.5",children:y.map((ne,ue)=>{const Te=ne.id===w?.id;return E(me,{className:`items-center justify-between rounded-md border px-2 py-1.5 transition-colors ${Te?"border-border-default bg-fill-subtler":"border-transparent bg-fill-control-surface hover:border-border-subtle"}`,onClick:()=>{n(ne.id)},children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:`${ue+1}. ${ne.name||ne.id}`}),p("p",{className:"typo-compact-xs-normal text-fg-subtler shrink-0",children:`${ne.type} / ${ne.polygon.length} pts`})]},ne.id)})})]}),p(ji,{})]}),E(j,{className:on("gap-2",Z&&"opacity-50"),children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Details"}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Zone Name"}),k?p(un,{className:"w-full",size:"sm",placeholder:"Enter zone name",value:K,onChange:ne=>{h?.({name:ne.target.value})}}):p("div",{className:"border-border-subtle bg-fill-control-surface rounded-md border px-3 py-2",children:p("p",{className:"typo-compact-xs-normal text-fg-default",children:K||"-"})})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Zone Type"}),k?p("div",{className:"grid grid-cols-1 gap-2",children:UR.map(ne=>p(Ut,{className:"w-full",name:`topology-zone-type-${ne.toLowerCase()}`,checkValue:ne,value:oe,onChange:ue=>{ue.target.checked&&h?.({type:ne})},children:ne},ne))}):p("div",{className:"border-border-subtle bg-fill-control-surface rounded-md border px-3 py-2",children:p("p",{className:"typo-compact-xs-normal text-fg-default",children:oe||"-"})})]})]}),p(ji,{})]}),E(Fo,{cancelLabel:"Cancel",saveLabel:te,saveDisabled:!Q||!W,onCancel:async()=>{if(!C){g?.();return}await b({title:"Cancel",content:ve,buttonText:{yes:"Discard",no:"Keep Editing"}})&&(s?.(),g?.())},onSave:()=>{d?.(),v?.()},children:[re&&p(We,{variant:"soft",className:"text-fg-default py-2",onClick:()=>{i?.({name:r.name,type:r.type})},children:ce}),M&&I&&E(vi,{children:[p(We,{variant:"soft",className:"text-fg-default py-2",onClick:()=>{f?.(w.id)},children:"Edit Zone"}),p(We,{variant:"dangerSoft",className:"py-2",onClick:async()=>{await b({title:"Delete Zone",content:"Delete this selected zone?",buttonText:{yes:"Delete",no:"Keep"}})&&m?.(w.id)},children:"Delete Zone"})]}),Q&&x&&p(We,{variant:"soft",className:"text-fg-default py-2",onClick:c,children:S?"Reopen Zone":"Reopen"}),Q&&E(vi,{children:[E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"outlined",disabled:!G,onClick:o,children:"Undo Last Point"}),p(We,{variant:"outlined",disabled:!q,onClick:a,children:"Clear Points"})]}),p(We,{variant:"dangerSoft",disabled:!O,onClick:l,children:"Close Zone"})]})]})]})},{memo:zR,useCallback:gh,useEffect:HR,useState:GR}=await wt("react"),bh="topology_tab",vh=r=>r==="overview"||r==="node"||r==="link"||r==="zone",VR=[{label:"Overview",value:"overview"},{label:"Node",value:"node"},{label:"Link",value:"link"},{label:"Zone",value:"zone"}],WR=({className:r,overviewTabProps:e,nodeTabProps:t,linkTabProps:n,zoneTabProps:i})=>{const{theme:s}=Ar(),{t:a}=en(),{confirmDialog:o}=As({confirmComponent:Cs}),[l,c]=Fy(),[d,h]=GR(()=>{const g=l.get(bh)??"";return vh(g)?g:"overview"}),u=i?.draft?.state==="drawing"||i?.draft?.state==="closed",f=gh(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=gh(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]),v=gh(async g=>{if(d===g||d==="zone"&&g!=="zone"&&u&&!await f())return;h(g);const b=new URLSearchParams(l);b.set(bh,g),c(b,{replace:!0})},[f,u,l,c,d]);return HR(()=>{const g=l.get(bh)??"",b=vh(g)?g:"overview";h(y=>y!==b?b:y)},[l]),p("div",{className:on("TopologyControl","h-full",r),children:p("div",{className:"flex h-full min-h-0 gap-0",children:E("div",{className:"flex h-full min-h-0 flex-1 flex-col overflow-x-hidden",children:[p("div",{className:on("sticky top-0 left-0 z-2",s==="light"?"bg-default":"bg-alt-1"),children:p(py,{tabItems:VR.map(g=>({key:g.value,label:a(g.label)})),activeKey:d,handleChange:async g=>{vh(g)&&await v(g)},size:"xs",tabBtnClassName:"typo-compact-xs-bold light:bg-white light:[&.active]:bg-fill-navy! light:[&.active]:text-white!"})}),E(j,{className:"min-h-0 flex-1 overflow-y-auto",children:[d==="overview"&&p(FR,{...e,nodeCount:t?.nodes?.length??0,linkCount:n?.links?.length??0,zoneCount:i?.zones?.length??0,onCancelTopologyChanges:m,onSaveTopologyChanges:t?.onSaveTopologyChanges}),d==="node"&&p(kR,{...t}),d==="link"&&p(TR,{...n}),d==="zone"&&p(BR,{...i})]})]})})})},WN=zR(WR),jR=await wt("react"),XR={APRILTAG:"AprilTag",ARUCO:"ArUco"},qR={x:"text-fg-danger",y:"text-fg-success",z:"text-fg-brand",rx:"text-fg-danger",ry:"text-fg-success",rz:"text-fg-brand"},ra=({label:r,value:e})=>E(me,{className:"items-baseline gap-1",children:[p("span",{className:`typo-compact-xs-semibold ${qR[r]??"text-fg-subtler"}`,children:r}),p("span",{className:"typo-compact-xs-normal text-fg-default font-mono",children:e})]}),ZR=({detection:r,isSelected:e,onSelect:t})=>{const n=XR[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 p("button",{type:"button",onClick:()=>t(String(r.markerId)),className:on("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:E(j,{className:"gap-1 px-3 py-2.5",children:[E(me,{className:"items-center justify-between",children:[E(me,{className:"items-center gap-2",children:[E("span",{className:["typo-compact-lg-semibold",e?"text-fg-brand":"text-fg-default"].join(" "),children:["#",r.markerId]}),p("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&&E("span",{className:["typo-compact-sm-semibold",s?"text-fg-success":"text-fg-caution"].join(" "),children:[i,"%"]})]}),p(me,{className:"items-center gap-1.5",children:a.map((o,l)=>E(jR.Fragment,{children:[l>0&&p("span",{className:"text-fg-subtler",children:"·"}),p("span",{className:"typo-compact-xs-normal text-fg-subtle",children:o})]},o))}),r.pose?E(j,{className:"gap-0.5",children:[E(me,{className:"items-center gap-3",children:[p(ra,{label:"x",value:r.pose.x.toFixed(3)}),p(ra,{label:"y",value:r.pose.y.toFixed(3)}),r.pose.z!=null&&p(ra,{label:"z",value:r.pose.z.toFixed(3)})]}),E(me,{className:"items-center gap-3",children:[r.pose.rx!=null&&p(ra,{label:"rx",value:`${r.pose.rx.toFixed(1)}°`}),r.pose.ry!=null&&p(ra,{label:"ry",value:`${r.pose.ry.toFixed(1)}°`}),p(ra,{label:"rz",value:`${r.pose.rz.toFixed(1)}°`})]})]}):p(_r,{type:"icon",icon:p(ya,{}),message:"No pose data",className:"py-1"})]})})},{useEffect:YR,useMemo:KR,useState:ao}=await wt("react"),$R=[{label:"0.04m",value:"0.04"},{label:"0.1m",value:"0.10"},{label:"0.15m",value:"0.15"}],QR=(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,JR=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||QR(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)}))},jN=({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}=en(),[h,u]=ao(""),f=KR(()=>JR(t),[t]);YR(()=>{s!=null&&u("")},[s]);const[m,v]=ao("WALL"),[g,b]=ao("0.10"),[y,w]=ao(null),[_,R]=ao(""),T=f.find(G=>String(G.markerId)===h)??null,P=G=>{u(G)},M=()=>{T&&n?.({camId:T.camId,markerId:T.markerId,type:T.type,mount:m,markerSizeM:Number(g)})},x=()=>{!y||!_||(c?.({markerNodeId:y.nodeId,markerId:y.markerId,nodeName:_}),R(""))},S=f.length>0,C=f.map(G=>G.distM).filter(G=>Number.isFinite(G)).sort((G,q)=>G-q)[0],k=C!=null?`${C.toFixed(2)}m`:"-",I=p(j,{className:"border-subtler gap-2 border-b p-3",children:E(j,{className:"bg-fill-disabled gap-1 rounded-md p-3",children:[E(me,{className:"items-center justify-between gap-3",children:[E(me,{className:"items-center gap-1",children:[p(ya,{className:"text-fg-subtle size-4"}),p("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:d("move.amr.rightPanel.marker.markerStatus")})]}),E(me,{className:"items-center gap-1.5",children:[p(gi,{color:S?"green":"gray"}),p("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")})]})]}),E(me,{className:"items-center justify-between gap-3",children:[E(me,{className:"items-center gap-1",children:[p(Nu,{className:"text-fg-subtle size-4"}),p("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:d("move.title.distance")})]}),p("p",{className:"typo-compact-sm-semibold text-fg-default",children:k})]})]})});return r==="register"?E(j,{className:"h-full gap-0",children:[I,E(j,{className:"flex-1 gap-0 overflow-y-auto",children:[f.length===0?p("div",{className:"p-3 pb-0",children:p(_r,{type:"icon",icon:p(Cf,{}),message:d("move.amr.rightPanel.marker.notFound"),className:"bg-fill-disabled rounded-md"})}):p(j,{className:"gap-2 p-3 pb-0",children:f.map(G=>p(ZR,{detection:G,isSelected:h===String(G.markerId),onSelect:P},G.markerId))}),E(j,{className:"gap-3 p-3",children:[E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.markerId")}),p("div",{className:"bg-fill-disabled border-border-subtler flex h-8 items-center rounded-md border px-3",children:p("p",{className:`typo-compact-sm-normal ${T?"text-fg-default":"text-fg-subtler"}`,children:T?`#${T.markerId}`:"—"})})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.markerType")}),p("div",{className:"bg-fill-disabled border-border-subtler flex h-8 items-center rounded-md border px-3",children:p("p",{className:`typo-compact-sm-normal ${T?"text-fg-default":"text-fg-subtler"}`,children:T?T.type==="ARUCO"?"ArUco":"AprilTag":"—"})})]}),E(j,{className:"gap-2",children:[E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.markerSize")}),p(me,{className:"items-center",children:p(cn,{className:"flex-1",size:"sm",value:g,step:.05,digit:2,fixedDigit:2,min:"0.01",max:"1.00",handleChange:G=>b(G)})})]}),p(me,{className:"gap-2",children:$R.map(G=>p(Ut,{className:"flex-1",value:g,checkValue:G.value,unCheckValue:G.value,handleChange:q=>b(q),size:"sm",children:G.label},G.value))})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.mount")}),E(me,{className:"gap-2",children:[p(Ut,{className:"w-full",value:m,checkValue:"WALL",unCheckValue:"WALL",handleChange:G=>v(G),size:"sm",children:d("move.amr.rightPanel.marker.mount.wall")}),p(Ut,{className:"w-full",value:m,checkValue:"FLOOR",unCheckValue:"FLOOR",handleChange:G=>v(G),size:"sm",children:d("move.amr.rightPanel.marker.mount.floor")})]})]})]})]}),p("div",{className:"p-3",children:p(We,{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")})})]}):E(j,{className:"h-full gap-0",children:[I,E(j,{className:"flex-1 gap-3 overflow-y-auto p-3",children:[E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.targetMarker")}),p(dc,{size:"sm",value:y?String(y.markerId):"",handleChange:G=>{const q=a.find(O=>String(O.markerId)===G);w(q??null)},disabled:a.length===0,children:a.length===0?p(es,{value:"",children:d("move.amr.rightPanel.marker.noRegisteredMarkers")}):a.map(G=>E(es,{value:String(G.markerId),children:["id ",G.markerId," · ",G.type," · ",G.mount]},G.markerId))})]}),y?.precisionTarget&&(()=>{const G=y.precisionTarget,q=G.context.match(/dock_offset=([^;]+)/)?.[1]?.split(",")??[];return p(j,{className:"gap-2",children:p("div",{className:"bg-fill-disabled rounded-md px-3 py-2.5",children:E(j,{className:"gap-2",children:[G.nodeName&&p("p",{className:"typo-compact-sm-semibold text-fg-default",children:G.nodeName}),q.length>0&&E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:d("move.amr.rightPanel.marker.dockOffset")}),p("div",{className:"grid grid-cols-3 gap-x-2 gap-y-0.5",children:["x","y","z","rx","ry","rz"].map((O,W)=>E(me,{className:"items-baseline gap-1",children:[p("span",{className:"typo-compact-xs-semibold text-fg-subtle w-4",children:O}),p("span",{className:"typo-compact-xs-normal text-fg-default truncate font-mono",children:q[W]?Number(q[W]).toFixed(3):"—"})]},O))})]})]})})})})(),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.capturedPose")}),o?p("div",{className:"bg-fill-disabled rounded-md px-3 py-2.5",children:p(me,{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:G,value:q,color:O})=>E(me,{className:"items-baseline gap-1",children:[p("span",{className:`typo-compact-xs-semibold ${O}`,children:G}),p("span",{className:"typo-compact-xs-normal text-fg-default font-mono",children:q})]},G))})}):p("div",{className:"bg-fill-disabled rounded-md px-3 py-2",children:p(_r,{type:"icon",icon:p(Cf,{}),message:d("move.amr.rightPanel.marker.moveRobotThenCapture"),className:"py-1"})}),p(We,{size:"xs2",variant:"soft",leadingIcon:p(ya,{}),onClick:l,disabled:!y,children:d("move.amr.rightPanel.marker.captureCurrentPose")})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.targetName")}),p(un,{className:"w-full",size:"sm",placeholder:d("move.amr.rightPanel.marker.targetNamePlaceholder"),value:_,onChange:G=>R(G.target.value)})]})]}),p("div",{className:"p-3",children:p(We,{variant:"brand",className:"h-9 w-full",onClick:x,disabled:!y||!_||!o,children:d("move.amr.rightPanel.marker.saveTarget")})})]})},{useEffect:eN}=await wt("react"),tN={KeyV:"select",KeyT:"target",KeyG:"move",KeyR:"rotate",KeyS:"scale"},Lg=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']")},XN=({enabled:r=!0,tools:e,topology:t,selection:n,camera:i})=>{const{enabled:s=!0,selectedTool:a,onToolChange:o,hasSelectedNode:l=!0}=e,c=t?.enabled??!0,d=!!t,h=t?.selectedNodePlacementType,u=t?.onAddNodeAtRobot,f=t?.onAddNodeAtCursor,m=n?.enabled??!0,v=!!n,g=n?.hasSelectedNodes??!1,b=n?.hasSelectedLinks??!1,y=n?.hasSelectedZones??!1,w=n?.onDeleteSelectedNodes,_=n?.onDeleteSelectedLinks,R=n?.onDeleteSelectedZones,T=i?.enabled??!0,P=!!i,M=i?.hasSelectedNode??!1,x=i?.onFocusSelectedNode;eN(()=>{if(!r)return;const S=(q,O)=>{s&&(a==="disabled"&&O!=="select"&&O!=="target"||Cv.has(O)&&!l||a!==O&&(q.preventDefault(),o(O)))},C=q=>{if(!(!d||!c)){if(h==="robot"){q.preventDefault(),u?.();return}a==="target"&&(q.preventDefault(),f?.())}},k=q=>{if(!(!v||!m)){if(g){q.preventDefault(),w?.();return}if(b){q.preventDefault(),_?.();return}y&&(q.preventDefault(),R?.())}},I=q=>{!P||!T||!M||(q.preventDefault(),x?.())},G=q=>{if(!(Lg(q.target)||Lg(document.activeElement))&&!q.repeat&&!(q.metaKey||q.ctrlKey||q.altKey||q.shiftKey))switch(q.code){case"KeyN":C(q);return;case"Delete":case"Backspace":k(q);return;case"KeyF":I(q);return;case"KeyV":case"KeyT":case"KeyG":case"KeyR":case"KeyS":{const O=tN[q.code];if(!O)return;S(q,O);return}default:return}};return window.addEventListener("keydown",G),()=>{window.removeEventListener("keydown",G)}},[r,T,P,M,v,b,l,g,y,d,f,u,_,w,R,x,o,h,a,m,s,c])},{useEffect:Ig,useRef:kg,useState:nN}=await wt("react"),Og=.5,iN=520;function qN({anchorObject:r,anchorWorldPosition:e,worldStudioRef:t,viewportHostRef:n,horizontalPlacementBoundary:i=iN}){const[s,a]=nN(null),o=kg(null),l=kg(null);return Ig(()=>{const c=()=>{const m=n.current,v=t.current?.getCanvas();o.current=m?.getBoundingClientRect()??null,l.current=v?.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]),Ig(()=>{if(!r&&!e){a(null);return}let c=0;const d=new L,h=new L,u=()=>{const f=t.current?.getCanvas(),m=t.current?.getCamera(),v=n.current;if(!f||!m||!v){a(P=>P===null?P:null),c=requestAnimationFrame(u);return}if(m.updateMatrixWorld(),r)r.updateMatrixWorld(),r.getWorldPosition(h);else if(e)h.copy(e);else{a(P=>P===null?P:null),c=requestAnimationFrame(u);return}d.copy(h).project(m);const g=o.current,b=l.current;if(!g||!b){a(P=>P===null?P:null),c=requestAnimationFrame(u);return}const y=(d.x+1)/2*b.width,w=(-d.y+1)/2*b.height,_=y+b.left-g.left,R=w+b.top-g.top,T=Number.isFinite(_)&&Number.isFinite(R)&&d.z>=-1&&d.z<=1&&_>=0&&_<=g.width&&R>=0&&R<=g.height;a(P=>{if(!T)return P===null?P:null;const M={x:_,y:R,placement:_>g.width-i?"left":"right"};return P&&Math.abs(P.x-M.x)<Og&&Math.abs(P.y-M.y)<Og&&P.placement===M.placement?P:M}),c=requestAnimationFrame(u)};return u(),()=>{cancelAnimationFrame(c)}},[r,e,i,n,t]),s}const{useMemo:yh,useState:Gs}=await wt("react"),ZN=()=>{const{t:r}=en(),[e,t]=Gs(!0),[n,i]=Gs(!1),[s,a]=Gs(!1),[o,l]=Gs(!1),[c,d]=Gs(!1),[h,u]=Gs(!0),[f,m]=Gs(.15),[v,g]=Gs("topView"),b=yh(()=>[{label:r("move.amr.viewportControls.visibility.lidarPoints"),description:r("move.amr.viewportControls.visibility.lidarPointsDescription"),checked:h,onCheckedChange:u},{label:r("move.amr.viewportControls.visibility.simpleNodes"),description:r("move.amr.viewportControls.visibility.simpleNodesDescription"),checked:c,onCheckedChange:d},{label:r("move.amr.viewportControls.visibility.nodeLabels"),description:r("move.amr.viewportControls.visibility.nodeLabelsDescription"),checked:o,onCheckedChange:l},{label:r("move.amr.viewportControls.visibility.grid"),description:r("move.amr.viewportControls.visibility.gridDescription"),checked:e,onCheckedChange:t}],[e,h,o,c,r]),y=yh(()=>({label:r("move.amr.viewportControls.camera.projection"),description:r("move.amr.viewportControls.camera.projectionDescription"),value:v,items:[{label:r("move.amr.viewportControls.camera.topView"),value:"topView",description:r("move.amr.viewportControls.camera.topViewDescription")},{label:r("move.amr.viewportControls.camera.perspective"),value:"perspective",description:r("move.amr.viewportControls.camera.perspectiveDescription")}],onChange:_=>{g(_)}}),[r,v]),w=yh(()=>[{label:r("move.amr.viewportControls.rendering.lidarPointSize"),description:r("move.amr.viewportControls.rendering.lidarPointSizeDescription"),value:f,min:.01,max:.3,step:.01,digit:2,onChange:m}],[f,r]);return{showGrid:e,setShowGrid:t,showJoysticks:n,setShowJoysticks:i,showViewControls:s,setShowViewControls:a,showNodeLabels:o,setShowNodeLabels:l,showSimpleNodes:c,setShowSimpleNodes:d,showLidar:h,setShowLidar:u,lidarPointSize:f,setLidarPointSize:m,viewportCameraMode:v,visibilityItems:b,cameraModeControl:y,renderingSettingItems:w}},{useMemo:sN}=await wt("react"),YN=({loading:r,isDefaultData:e,mapCloud:t,topology:n,nodes:i,links:s})=>sN(()=>{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:xh}=await wt("react"),KN=()=>{const r=xh((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=xh((n,i)=>{const s=JSON.stringify(i,null,2)??"";r(n,s,{mimeType:"application/json"})},[r]),t=xh((n,i)=>{const s=i.map(a=>a.map(o=>o??"").join(",")).join(`
|
|
4748
|
-
`);r(n,s,{mimeType:"text/csv;charset=utf-8;"})},[r]);return{downloadFile:r,downloadJsonFile:e,downloadCsvFile:t}};export{
|
|
4747
|
+
);}.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);}}"),Dv=({className:r,items:e,latestIndex:t=0,latestIndexes:n,compact:i=!1,showResult:s=!i})=>e.length?p(hR,{className:on("gap-2",r),children:e.map((a,o)=>{const l=n?n.includes(o):o===t,c=o===0,d=o===e.length-1;return E("div",{className:"relative flex items-start gap-3 rounded-md px-2 py-1.5",children:[p(uR,{isFirst:c,isLast:d,children:p(fR,{isLatest:l})}),E(j,{className:"min-w-0 flex-1 gap-0.5",children:[E("div",{className:"flex min-h-5 items-center justify-between gap-1.5",children:[p("span",{className:on("typo-compact-xs2-semibold truncate font-mono",l?"text-fg-information":"text-fg-default"),children:a.message||"-"}),l?p("span",{className:"bg-fill-information typo-compact-2xs-semibold text-fg-inverse rounded-lg px-1.5 py-0.5",children:"Latest"}):null]}),!i&&E(vi,{children:[E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-2xs-medium text-fg-subtler",children:"Time"}),p("span",{className:"typo-compact-xs-normal text-fg-subtle truncate",children:ay(a.createdAt,"YYYY-MM-DD HH:mm:ss")})]}),E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-2xs-medium text-fg-subtler",children:"Command"}),p("span",{className:"typo-compact-xs-normal text-fg-subtle truncate",children:a.command||"-"})]})]}),s&&E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-2xs-medium text-fg-subtler",children:"Result"}),p("span",{className:on("typo-compact-xs-normal",{"text-fg-success":a.result==="success","text-fg-danger":a.result==="fail","text-fg-information":a.result==="start","text-fg-disabled":a.result==="cancel","text-fg-subtle":a.result!=="success"&&a.result!=="fail"&&a.result!=="start"&&a.result!=="cancel"}),children:a.result||"-"})]})]})]},`${a.createdAt}-${a.command}-${o}`)})}):p("div",{className:r,children:p("span",{className:"typo-compact-xs2-normal text-fg-subtle",children:"No history"})}),hR=Mc(j,{target:"edynay22"})({name:"bjn8wh",styles:"position:relative"}),uR=Mc("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;",";}"),fR=Mc("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:pR,useMemo:Ag,useState:mR}=await wt("react"),gR=[{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"}],bR=r=>r.toUpperCase().replace("_"," "),Cg=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())}`},vR=(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)},Pg=r=>{if(!r)return null;const e=new Date(r).getTime();return Number.isNaN(e)?null:e},yR=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`},xR=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`},_R=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:vR(e.createdAt,e.updateAt),previousNodes:t.map(n=>({createdAt:n.createdAt,message:xR(n),command:n.command,result:n.result}))}},GN=({logData:r,moveStatus:e})=>{const{t}=en(),[n,i]=mR(()=>Date.now()),s=_R(r),a=s?.status??"",o=a?bR(a):t("move.amr.rightPanel.task.idle"),l=s?.previousNodes??[],c=l.length?l:gR,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";pR(()=>{if(!u)return;const v=window.setInterval(()=>{i(Date.now())},1e3);return()=>{window.clearInterval(v)}},[u]);const f=Ag(()=>{const v=Pg(s?.createdAt),g=Pg(s?.updatedAt);if(v!==null){if(u)return Math.max(0,Math.floor((n-v)/1e3));if(g!==null&&g>=v)return Math.floor((g-v)/1e3)}return typeof s?.actualDuration=="number"&&s.actualDuration>=0?Math.floor(s.actualDuration):0},[u,n,s?.actualDuration,s?.createdAt,s?.updatedAt]),m=Ag(()=>yR(f),[f]);return E(j,{className:"h-full min-h-0",children:[E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[E("div",{className:"flex items-center justify-between",children:[p("div",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.task.status")}),E("div",{className:"flex flex-row items-center gap-2",children:[p(gi,{color:a!==""?"blue":"gray",className:a!==""?"animate-pulse":void 0}),p("div",{className:"typo-compact-xs-semibold text-fg-default",children:o})]})]}),E("div",{className:"flex items-center justify-between",children:[p("div",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.common.created")}),p("div",{className:"typo-compact-xs-normal text-fg-subtle",children:Cg(s?.createdAt)})]}),E("div",{className:"flex items-center justify-between",children:[p("div",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.task.lastUpdated")}),p("div",{className:"typo-compact-xs-normal text-fg-subtle",children:Cg(s?.updatedAt)})]})]}),p("div",{className:"border-subtler border-b p-3",children:E(j,{className:"bg-raised space-y-2 rounded p-2",children:[p(cR,{currentNode:h,targetNode:d,moveStatus:a}),p("div",{className:"border-subtler border-b"}),E(me,{className:"justify-between",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.task.duration")}),p("span",{className:"typo-compact-xs-normal text-fg-default",children:m})]})]})}),E(j,{className:"border-subtler min-h-0 gap-1.5 border-b p-3",children:[E(me,{className:"space-x-1.5",children:[p("span",{className:"typo-compact-sm2-semibold text-fg-default",children:t("move.amr.rightPanel.task.pathHistory")}),p("span",{className:"typo-compact-sm2-normal text-fg-subtle",children:c.length})]}),p(Dv,{items:c,className:"min-h-0 flex-1 overflow-y-auto"})]})]})},{useEffect:ro,useRef:ia,useState:rh}=await wt("react"),Rg=[{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"}],VN=({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}=en(),[u,f]=rh(!1),[m,v]=rh(!1),[g,b]=rh(new Set),y=ia(!1),w=ia(!1),_=ia(!1),R=ia(""),T=ia(!1),P=ia(!1),M=r?.chargeState?.charge??"none",x=r?.chargeState?.dockResult??"",S=r?.chargeState?.dock??!1,C=M.toLowerCase(),k=x.toLowerCase(),I=k==="move",G=k==="fail",q=C!=="none"&&M!=="",O=C==="charging",W=C==="battery_on",Z=u||I||W,K=!Z&&S,oe=h(Z?"move.amr.rightPanel.dock.status.move":K?"move.amr.rightPanel.dock.status.dock":"move.amr.rightPanel.dock.status.undocked"),te=Z?"blue":K?"green":"red",ve=I&&!W&&!O,ce=[...u&&!I?["pointDock"]:[],...ve?["docking"]:[],...W?["checkCharge"]:[],...O?["complete"]:[]],Q=Rg.map(Ce=>({message:h(Ce.label),result:g.has(Ce.key)?"success":void 0})),re=ce.map(Ce=>Rg.findIndex(X=>X.key===Ce)).filter(Ce=>Ce>=0);ro(()=>{const Ce=y.current;y.current=O,!(!O||Ce||T.current)&&(f(!1),b(X=>{const Be=new Set(X);return Be.add("pointDock"),Be.add("docking"),Be.add("checkCharge"),Be.add("complete"),Be}))},[O]),ro(()=>{const Ce=w.current;w.current=W,!(!W||Ce||T.current)&&b(X=>{const Be=new Set(X);return Be.add("pointDock"),Be.add("docking"),Be})},[W]),ro(()=>{const Ce=_.current;_.current=I,!(!I||Ce||T.current)&&b(X=>{const Be=new Set(X);return Be.add("pointDock"),Be})},[I]),ro(()=>{const Ce=R.current;R.current=k,!(k!=="fail"||Ce==="fail")&&(f(!1),b(new Set))},[k]);const J=()=>{R.current="",b(new Set),f(!1),v(!1),T.current=!1,P.current=!1};ro(()=>{if(m){if(I){P.current=!0;return}P.current&&(P.current=!1,v(!1),T.current=!1)}},[m,I]);const ne=()=>{J(),f(!0),t()},ue=()=>{J(),i()},Te=()=>{s()},_e=()=>{a()},fe=()=>{J(),v(!0),T.current=!0,n()},be=()=>E(j,{className:"gap-2",children:[E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"successSoft",onClick:ne,disabled:c,children:h("move.amr.rightPanel.dock.action.dock")}),p(We,{variant:"dangerSoft",onClick:fe,disabled:c,children:h("move.amr.rightPanel.dock.action.undock")})]}),Z&&E(j,{className:"gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:h("move.amr.rightPanel.dock.operation.motion")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"dangerSoft",leadingIcon:p(Yg,{className:"size-3"}),disabled:m,onClick:ue,children:h("move.amr.rightPanel.common.stop")}),e?p(We,{variant:"soft",leadingIcon:p(ly,{className:"size-3"}),disabled:m,onClick:_e,children:h("move.amr.rightPanel.dock.action.resume")}):p(We,{variant:"soft",leadingIcon:p(cy,{className:"size-3"}),disabled:m,onClick:Te,children:h("move.amr.rightPanel.dock.action.pause")})]})]})]});return E(vi,{children:[E(j,{className:"border-subtler gap-2.5 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.dock.operation.title")}),E(j,{className:"gap-2 rounded",children:[E("div",{className:"bg-fill-disabled grid grid-cols-2 gap-x-3 rounded-md px-3 py-3",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:h("move.amr.rightPanel.dock.operation.dock")}),E(me,{className:"items-center gap-1.5",children:[p(gi,{color:te,className:Z||K?"animate-pulse":void 0}),p("p",{className:"typo-compact-xs2-medium text-fg-default",children:oe})]})]}),E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:h("move.amr.rightPanel.dock.operation.charge")}),p("p",{className:"typo-compact-xs2-medium text-fg-default uppercase",children:q?M:h("move.amr.rightPanel.common.none")})]})]}),be(),E(me,{className:"items-start gap-1",children:[p("div",{className:"flex size-4 shrink-0 items-center justify-center",children:p(Pu,{className:"text-fg-subtlest size-3"})}),p("p",{className:"typo-compact-xs-normal text-fg-subtler flex-1",children:h("move.amr.rightPanel.dock.operation.description")})]})]})]}),E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.dock.status.title")}),p(Dv,{items:Q,latestIndexes:m?[]:re,compact:!0})]}),E(j,{className:"border-subtler gap-2 border-b p-2.5",children:[E(me,{className:"items-center justify-between self-stretch",children:[E(me,{className:"flex-1 items-center gap-1.5",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.dock.retryCount")}),G&&p("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")})]}),E("button",{type:"button",className:"hover:bg-fill-hovered flex h-5 items-center gap-0.5 rounded-sm px-1.5",onClick:l,children:[p(Sc,{className:"text-fg-default size-3"}),p("span",{className:"text-fg-default text-[10px] leading-3 font-semibold",children:h("move.amr.rightPanel.common.settings")})]})]}),d&&E(me,{className:"border-danger bg-fill-danger-subtlest mt-1 items-start gap-2 rounded-md border px-3 py-2.5",children:[p(oy,{className:"text-fg-danger mt-0.5 size-4 shrink-0"}),p("p",{className:"typo-compact-xs-semibold text-fg-danger",children:d})]}),p("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?p("p",{className:"text-fg-default text-sm leading-5",children:o}):p("p",{className:"text-fg-subtler text-sm leading-5",children:"—"})})]})]})},{useEffect:wR,useState:ah}=await wt("react"),{createPortal:SR}=await wt("react-dom"),MR=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}`},WN=({onOpenChange:r,open:e,close:t,onSaveMapping:n,completedKeyframeCount:i=0,totalKeyframePoints:s=0,durationSeconds:a=0,existingMapNames:o=[]})=>{const{t:l}=en(),[c,d]=ah(""),[h,u]=ah(!1),[f,m]=ah(""),v=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 w=await n(y);if(w.ok){d(""),g();return}"reason"in w&&w.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)}},g=()=>{h||(d(""),m(""),t?.(),r?.(!1))};if(wR(()=>{e||(d(""),m(""),u(!1))},[e]),!e)return null;const b=E(j,{className:"fixed inset-0 z-50 items-center justify-center p-4",children:[p("button",{type:"button","aria-label":l("move.amr.rightPanel.map.saveDialog.closeBackdrop"),className:"bg-bg-dim absolute inset-0",onClick:g}),E(j,{className:"bg-bg-overlay relative w-full max-w-xl overflow-hidden rounded-lg p-4",children:[p(j,{className:"shrink-0 gap-0.5 p-1",children:E(me,{className:"items-start justify-between",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-lg-semibold text-fg-default",children:l("move.amr.rightPanel.map.saveDialog.title")}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.saveDialog.description")})]}),p(qn,{variant:"transparent",size:"2xs",icon:p(Pa,{}),className:"text-fg-subtle",onClick:g,disabled:h})]})}),E(j,{className:"gap-3 p-1 pt-3",children:[E(j,{className:"gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:l("move.amr.rightPanel.map.info.mapName")}),p(un,{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&&v()}}),p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.saveDialog.nameRule")})]}),f&&p(me,{className:"bg-bg-danger-tertiary outline-border-danger rounded-md p-2.5 outline outline-1 outline-offset-[-1px]",children:p("p",{className:"typo-compact-xs-normal text-fg-danger",children:f})}),E(j,{className:"bg-bg-alt-1 gap-1 rounded-md p-2.5",children:[E(me,{className:"items-center justify-between",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.mapping.keyframesReceived")}),p("p",{className:"typo-compact-2xs-semibold text-fg-information",children:i.toLocaleString()})]}),E(me,{className:"items-center justify-between",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.mapping.keyframePoints")}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:l("move.amr.rightPanel.map.mapping.points",{count:s.toLocaleString()})})]}),E(me,{className:"items-center justify-between",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.task.duration")}),p("p",{className:"typo-compact-2xs-semibold text-fg-default",children:MR(a)})]})]})]}),E(me,{className:"shrink-0 items-center justify-end gap-2 p-1 pt-3",children:[p(We,{variant:"outlined",onClick:g,disabled:h,children:l("move.amr.rightPanel.common.cancel")}),p(We,{variant:"brand",onClick:v,disabled:h||!c.trim()||i<=0,children:l(h?"move.amr.rightPanel.common.saving":"move.amr.rightPanel.map.saveDialog.saveMap")})]})]})]});return typeof window>"u"?b:SR(b,document.body)},{useEffect:ER}=await wt("react"),jN=({isEraserEnabled:r=!1,onEraserToggle:e=()=>{},eraserRadius:t=1,setEraserRadius:n=()=>{},eraseSelectedAreaDisabled:i=!1,onEraseSelectedArea:s=()=>{},onReleaseSelectedPoints:a=()=>{},onSaveChanges:o=()=>{}})=>{const{t:l}=en();return ER(()=>()=>{e(!1)},[e]),E(j,{className:"h-full justify-between overflow-y-auto",children:[E(j,{children:[E(j,{className:"gap-0.5 px-3 pt-3",children:[E(me,{className:"justify-between",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.map.erasing.eraseMode")}),p(xa,{size:"default",checked:r,onCheckedChange:()=>e(!r)})]}),E("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[l("move.amr.rightPanel.map.erasing.descriptionLine1"),p("br",{}),l("move.amr.rightPanel.map.erasing.descriptionLine2")]})]}),E(j,{className:"gap-2 p-3",children:[E(me,{className:"justify-between",children:[p("p",{className:"typo-compact-xs2-normal text-fg-default",children:l("move.amr.rightPanel.map.erasing.eraserRadius")}),E("p",{className:"typo-compact-xs2-normal text-fg-default",children:[t.toFixed(1)," m"]})]}),p(Zg,{min:0,max:5,step:.1,value:[t],onValueChange:c=>n(c[0]),disabled:!r})]}),E(j,{className:"border-border-subtler gap-2 border-b-[1px] px-3 pb-3",children:[p(We,{size:"xs2",variant:"soft",leadingIcon:p(dy,{className:"size-3.5"}),disabled:!r||i,onClick:s,children:l("move.amr.rightPanel.map.erasing.eraseSelectedArea")}),p(We,{size:"xs2",variant:"soft",leadingIcon:p(hy,{className:"size-3.5"}),disabled:!r,onClick:a,children:l("move.amr.rightPanel.map.erasing.releaseSelectedPoints")})]})]}),p(j,{className:"p-3",children:p(We,{variant:"brand",size:"sm",onClick:o,disabled:!r,children:l("move.amr.rightPanel.common.saveChanges")})})]})},{useEffect:TR,useMemo:Yl,useState:Kl}=await wt("react"),XN=({selectedObjects:r,setTopologyTab:e,onSelectionResetRequested:t,onDeleteNodesRequested:n,onNodeSelected:i,nodes:s=[],nodesPerPage:a=5})=>{const{theme:o}=Ar(),{t:l}=en(),[c,d]=Kl(""),[h,u]=Kl(1),[f,m]=Kl("all"),[v,g]=Kl(!1),b=["all","goal","route","align"],y=Yl(()=>r.map(O=>({id:String(O.userData?.id??""),name:O.name,uuid:O.uuid,type:O.userData.type||"unknown",safetyField:typeof O.userData.safetyField=="number"?O.userData.safetyField:0,x:0,y:0,z:0})),[r]),w=Yl(()=>y.map(O=>O.uuid),[y]),_=Yl(()=>s.filter(O=>c?O.name?.toLowerCase()?.includes(c.toLowerCase()):!0),[s,c]),R=Yl(()=>({all:_,goal:_.filter(O=>O.type==="goal"),route:_.filter(O=>O.type==="route"),align:_.filter(O=>O.type==="align")}),[_]),T=R[f],P=Math.max(1,Math.ceil(T.length/a)),M=Math.min(h,P);TR(()=>{h!==M&&u(M)},[h,M]);const x=()=>{g(!1),t()},S=()=>{n()},C=O=>{!v&&(e?.("edit"),w.includes(O))||i(O)},k=O=>O.toLowerCase()==="goal"?p(Kg,{className:"text-fg-warning"}):O.toLowerCase()==="route"?p(Nu,{className:"text-fg-brand"}):p($g,{className:"text-fg-success"}),I=O=>O.toLowerCase()==="goal"?"text-fg-warning":O.toLowerCase()==="route"?"text-fg-brand":"text-fg-success",G=O=>{switch(O.toLowerCase()){case"goal":return l("move.amr.rightPanel.topology.nodeType.goal");case"route":return l("move.amr.rightPanel.topology.nodeType.route");case"align":return l("move.amr.rightPanel.topology.nodeType.align");default:return O.toUpperCase()}},q=O=>O.length===0?p(_r,{className:"h-full w-full flex-1 [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:p(Du,{}),message:l("move.amr.rightPanel.topology.nodes.empty")}):O.map(W=>E(j,{children:[E(me,{className:"cursor-pointer items-center justify-between py-2.5",onClick:()=>{C(W.uuid)},children:[E(me,{className:"items-center gap-2",children:[v&&p(Lu,{size:"md",name:"topology-node-select",checkValue:W.uuid,value:w,handleChange:()=>{C(W.uuid)}}),E(j,{className:"w-full gap-0.5",children:[p("p",{className:"typo-compact-sm-normal text-fg-default",children:`${W.name?W.name:W.id+"(ID)"}`}),E(me,{className:"items-center gap-2",children:[E(me,{className:"items-center gap-0.5",children:[k(W.type),p("p",{className:`typo-compact-2xs-semibold ${I(W.type)}`,children:G(W.type)})]}),p(ji,{type:"vertical",thickness:"thick",className:"text-fg-subtler h-4"}),p(me,{children:E("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[W.x.toFixed(1),", ",W.y.toFixed(1),","," ",W.z.toFixed(1)]})})]})]})]}),!v&&p(Qg,{className:"text-fg-default"})]}),p(ji,{className:"text-fg-subtler"})]},W.uuid));return E(j,{className:"h-full min-h-0",children:[E(me,{className:"items-center justify-between px-3 pt-3",children:[E(me,{className:"gap-1",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l(v?"move.amr.rightPanel.topology.nodes.selectedTitle":"move.amr.rightPanel.topology.nodes.title")}),v?p("p",{className:"typo-compact-sm2-semibold text-fg-brand",children:y.length}):E(me,{className:"items-baseline",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-brand",children:T.length}),E("p",{className:"typo-compact-2xs-semibold text-fg-subtler",children:["/",s.length]})]})]}),v?p(Af,{leadingIcon:p(Pa,{}),onClick:x,children:l("move.amr.rightPanel.common.cancel")}):p(Af,{leadingIcon:p(Hg,{}),onClick:()=>{g(!0)},children:l("move.amr.rightPanel.common.select")})]}),v?p("div",{className:"p-3",children:p(j,{className:`${o==="light"?"bg-white":"bg-raised"} max-h-32 overflow-y-auto rounded-md px-3 py-1`,children:y.length>0?y.map(O=>E(me,{className:"cursor-pointer justify-between py-1.5",onClick:()=>i(O.uuid),children:[p("p",{className:"typo-compact-sm-normal text-fg-default truncate",children:`${O.name?O.name:O.id+" (ID)"}`}),E(me,{className:"items-center gap-0.5",children:[k(O.type),p("p",{className:`typo-compact-2xs-semibold uppercase ${I(O.type)}`,children:G(O.type)})]})]},O.uuid)):p("p",{className:"typo-compact-sm-normal text-fg-subtler py-1",children:l("move.amr.rightPanel.topology.nodes.noSelected")})})}):p("div",{className:"p-3",children:p(un,{className:"w-full",size:"sm",type:"search",placeholder:l("move.amr.rightPanel.topology.nodes.searchByName"),value:c,onChange:O=>{d(O.target.value)}})}),E(Au,{className:"min-h-0 w-full flex-1 px-3",variant:"line",value:f,onValueChange:O=>{b.includes(O)&&m(O)},children:[E(Tu,{children:[p(Hi,{value:"all",children:l("move.amr.rightPanel.topology.nodeType.all")}),p(Hi,{value:"goal",children:l("move.amr.rightPanel.topology.nodeType.goal")}),p(Hi,{value:"route",children:l("move.amr.rightPanel.topology.nodeType.route")}),p(Hi,{value:"align",children:l("move.amr.rightPanel.topology.nodeType.align")})]}),E(j,{className:"min-h-0 flex-1 overflow-y-auto p-1",children:[p(js,{value:"all",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-2",children:q(R.all)})}),p(js,{value:"goal",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-2",children:q(R.goal)})}),p(js,{value:"route",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-2",children:q(R.route)})}),p(js,{value:"align",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-2",children:q(R.align)})})]})]}),v&&p(j,{className:"sticky bottom-0 z-[1] p-3",children:p(We,{leadingIcon:p(wr,{}),variant:"dangerSoft",className:"h-9",onClick:S,children:l("move.amr.rightPanel.topology.nodes.deleteCount",{count:y.length})})})]})},{useEffect:AR}=await wt("react"),qN=({selectedTool:r,onToolChange:e,selectedNodeType:t,onSelectNodeType:n,selectedNodePlacementType:i,onSelectNodePlacementType:s,onAddNodeAtRobot:a,onAddNodeAtCursor:o,onDeleteLastNode:l,canDeleteLastNode:c=!0,onSaveTopologyChanges:d,onCancelTopologyChanges:h})=>{const{confirmDialog:u}=As({confirmComponent:Cs}),{t:f}=en();return AR(()=>{e("target")},[e]),E(j,{className:"h-full min-h-0",children:[E(j,{className:"min-h-0 flex-1 overflow-y-auto",children:[E(j,{className:"border-subtler gap-0.5 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:f("move.amr.rightPanel.topology.add.title")}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:f("move.amr.rightPanel.topology.add.description")})]}),E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:f("move.amr.rightPanel.topology.add.selectNodeType")}),E("div",{className:"grid grid-cols-3 gap-2",children:[p(Ut,{className:"w-full",name:"topology-node-type-goal",checkValue:"goal",value:t,onChange:m=>{m.target.checked&&n("goal")},children:f("move.amr.rightPanel.topology.nodeType.goal")}),p(Ut,{className:"w-full",name:"topology-node-type-route",checkValue:"route",value:t,onChange:m=>{m.target.checked&&n("route")},children:f("move.amr.rightPanel.topology.nodeType.route")}),p(Ut,{className:"w-full",name:"topology-node-type-align",checkValue:"align",value:t,onChange:m=>{m.target.checked&&n("align")},children:f("move.amr.rightPanel.topology.nodeType.align")})]})]}),E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:f("move.amr.rightPanel.topology.add.selectPlacement")}),E(j,{className:"gap-2",children:[p(Ut,{className:"w-full",name:"topology-node-placement-cursor",checkValue:"cursor",value:i,onChange:m=>{m.target.checked&&s("cursor")},children:f("move.amr.rightPanel.topology.add.atCursorPosition")}),p(Ut,{className:"w-full",name:"topology-node-placement-robot",checkValue:"robot",value:i,onChange:m=>{m.target.checked&&s("robot")},children:f("move.amr.rightPanel.topology.add.atRobotPosition")})]})]})]}),E(j,{className:"border-subtler sticky bottom-0 z-1 gap-2 border-b p-3",children:[p(We,{variant:"soft",className:"text-fg-default",onClick:()=>{if(i==="robot"){a();return}o()},children:f("move.amr.rightPanel.topology.add.addNode")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"outlined",onClick:async()=>{await u({title:f("move.amr.rightPanel.common.cancel"),content:f("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:f("move.amr.rightPanel.common.discard"),no:f("move.amr.rightPanel.common.keepEditing")}})&&h?.()},children:f("move.amr.rightPanel.common.cancel")}),p(We,{variant:"brand",onClick:d,children:f("move.amr.rightPanel.common.save")})]})]})]})},{useEffect:Bs,useMemo:Ng,useRef:CR,useState:In}=await wt("react"),oh=["INIT","CHARGING","AUTO_DOOR","ARUCO","APRIL","V_MARKER","TAPE","PRECISION"],pi={dir:"FORWARD",method:"PP",speed:0,avoidRange:0,safetyField:0},Si=r=>Number(r.toFixed(3)),lh=(r,e,t,n)=>{const i=Number(r);return Number.isNaN(i)?n:Math.min(t,Math.max(e,i))},PR=r=>{const e=r.toLowerCase().replace("init","goal");return e==="route"||e==="align"?e:"goal"},ZN=({selectedObjects:r,nodes:e=[],links:t=[],onToolChange:n,onUpdateNode:i,onUpdateLink:s,onDeleteLink:a,onFocusLink:o,onDeleteSelectedNodes:l,onCancelTopologyChanges:c,onSaveTopologyChanges:d})=>{const{confirmDialog:h}=As({confirmComponent:Cs}),{t:u}=en();Bs(()=>{n?.("select")},[n]);const f=Ng(()=>r.map(A=>{const Y=e.find(V=>V.uuid===A.uuid);return{uuid:A.uuid,externalId:String(A.userData?.id??""),name:A.name,type:PR(Y?.type||A.userData.type||"goal"),features:Array.isArray(A.userData.features)?A.userData.features.filter(V=>typeof V=="string"&&oh.includes(V)):[],x:A.position.x,y:A.position.y,z:A.position.z,rx:Si(A.rotation.x*180/Math.PI),ry:Si(A.rotation.y*180/Math.PI),rz:Si(A.rotation.z*180/Math.PI)}}),[e,r]),m=f[f.length-1],v=!!m,[g,b]=In(null),[y,w]=In(""),[_,R]=In("goal"),[T,P]=In([]),[M,x]=In("0.0"),[S,C]=In("0.0"),[k,I]=In("0.0"),[G,q]=In("0.0"),[O,W]=In(pi.dir),[Z,K]=In(pi.method),[oe,te]=In(String(pi.speed)),[ve,ce]=In(String(pi.avoidRange)),[Q,re]=In(String(pi.safetyField)),J=CR(null),[ne,ue]=In(!1),[Te,_e]=In(!1),[fe,be]=In(!1),[Ce,X]=In("1");Bs(()=>{w(m?.name??""),R(m?.type??"goal"),P(m?.features??[]),x(String(Si(m?.x??0))),C(String(Si(m?.y??0))),I(String(Si(m?.z??0))),q(String(Si(m?.rz??0)))},[m?.uuid,m?.name,m?.type,m?.features,m?.x,m?.y,m?.z,m?.rz]);const Be=Ng(()=>m?t.filter(Y=>Y.from===m.externalId||Y.to===m.externalId).map(Y=>{const V=Y.from===m.externalId,$=V?Y.to:Y.from,le=e.find(Ie=>Ie.id===$);return{...Y,isSource:V,oppositeNodeName:le?.name||le?.id||$}}):[],[m,t,e]);Bs(()=>{if(!Be.length){b(null);return}b(A=>A&&Be.some(Y=>Y.id===A)?A:null)},[Be]);const Me=Be.find(A=>A.id===g)??null,et=()=>{const A=J.current;if(!A){ue(!1),_e(!1);return}const{scrollTop:Y,scrollHeight:V,clientHeight:$}=A;if(!(V-$>1)){ue(!1),_e(!1);return}ue(Y>1),_e(Y+$<V-1)};Bs(()=>{b(null)},[m?.uuid]),Bs(()=>{!Me&&g!==null&&b(null)},[Me,g]),Bs(()=>{o?.(Me?.id??null)},[o,Me?.id]),Bs(()=>{et()},[Be.length]),Bs(()=>{W(Me?.dir??pi.dir),K(Me?.method??pi.method),te(String(Si(Me?.speed??pi.speed))),ce(String(Si(Me?.avoidRange??pi.avoidRange))),re(String(Si(Me?.safetyField??pi.safetyField)))},[Me?.id,Me?.dir,Me?.method,Me?.speed,Me?.avoidRange,Me?.safetyField]);const Se=(A,Y)=>{i?.(A,Y)},Ye=(A,Y)=>{s?.(A,Y)},ee=(A,Y)=>{if(!m)return;const V=Si(Number(Y||0)),$=String(V);A==="x"&&(x($),Se(m.uuid,{x:V})),A==="y"&&(C($),Se(m.uuid,{y:V})),A==="z"&&(I($),Se(m.uuid,{z:V}))},U=(A,Y)=>{if(!m)return;const V=Si(Number(Y||0)),$=String(V);q($),Se(m.uuid,{rz:V})};return E(j,{className:"h-full min-h-0 overflow-hidden",children:[v?E(j,{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto",children:[E(j,{className:"border-subtler gap-3 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.nodeProperties")}),E(j,{className:"gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.nodeId")}),E(me,{className:"items-center gap-1.5",children:[p("p",{className:"typo-compact-xs-normal text-fg-subtler flex-1",children:m?.externalId??""}),m?.externalId&&p("button",{className:"text-fg-subtler hover:text-fg-default shrink-0",onClick:()=>{eb({text:m.externalId??""})},children:p(Jg,{className:"size-3.5"})})]})]}),E(j,{className:"gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.name")}),p(un,{className:"w-full",type:"text",value:y,disabled:!v,onChange:A=>{if(!m)return;const Y=A.target.value;w(Y),Se(m.uuid,{name:Y})}})]})]}),p("div",{className:"border-subtler border-b p-1",children:p(ha,{title:p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.features")}),children:p("div",{className:"grid grid-cols-2 gap-x-2 gap-y-2",children:oh.map(A=>p(Lu,{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-${m?.uuid??""}`,checkValue:A,value:T,disabled:!v,handleChange:Y=>{if(!m||!Array.isArray(Y))return;const V=Y.filter($=>typeof $=="string"&&oh.includes($));P(V),Se(m.uuid,{features:V})},children:p("span",{className:"typo-compact-xs-normal text-fg-default",children:A})},A))})})}),p("div",{className:"border-subtler border-b p-1",children:E(ha,{initialOpen:!0,title:E(me,{className:"w-full items-center justify-between",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.transform")}),E(me,{className:"text-fg-default items-center gap-0.5",children:[p(We,{variant:"transparent",size:"2xs",leadingIcon:p(Sc,{}),onClick:A=>{A.preventDefault(),A.stopPropagation(),be(Y=>!Y)},children:u("move.amr.rightPanel.topology.edit.stepSize")}),p("div",{className:`overflow-hidden transition-all duration-200 ease-out ${fe?"w-32 opacity-100":"pointer-events-none w-0 opacity-0"}`,children:p(cn,{className:"h-8 w-32",value:Ce,step:.1,handleChange:A=>{X(A)}})})]})]}),children:[E(j,{className:"gap-2 pt-1",children:[E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-danger",children:"X"}),p("p",{className:"text-fg-subtle",children:"(mm)"})]}),p(cn,{className:"w-full",value:M,step:Number(Ce)||1,disabled:!v,handleChange:A=>{ee("x",A)}})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-success",children:"Y"}),p("p",{className:"text-fg-subtle",children:"(mm)"})]}),p(cn,{className:"w-full",value:S,step:Number(Ce)||1,disabled:!v,handleChange:A=>{ee("y",A)}})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-brand",children:"Z"}),p("p",{className:"text-fg-subtle",children:"(mm)"})]}),p(cn,{className:"w-full",value:k,step:Number(Ce)||1,disabled:!v,handleChange:A=>{ee("z",A)}})]})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-information",children:"RZ"}),p("p",{className:"text-fg-subtle",children:"(°)"})]}),p(cn,{className:"w-full",value:G,step:Number(Ce)||1,disabled:!v,min:0,max:360,handleChange:A=>{U("rz",A)}})]})]})}),p("div",{className:"border-subtler border-b p-1",children:p(ha,{title:E(me,{className:"items-center justify-between pr-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.connectedLinks")}),p("p",{className:"typo-compact-xs-normal text-fg-subtle",children:Be.length})]}),children:p(j,{className:"gap-2 pt-1",children:Be.length>0?E(vi,{children:[E("div",{className:"relative",children:[p(j,{ref:J,className:"border-border-subtle max-h-44 gap-1 overflow-y-auto rounded-md border p-1",onScroll:et,children:Be.map((A,Y)=>{const V=A.id===g;return p("button",{type:"button",className:`w-full rounded-md border px-3 py-2 text-left transition-colors ${V?"border-border-default bg-fill-subtler":"hover:border-border-subtle hover:bg-fill-control-surface border-transparent"}`,onClick:()=>{b(A.id)},children:E(me,{className:"typo-compact-sm-normal text-fg-default gap-1",children:[p("span",{className:"text-fg-subtle min-w-7",children:`${Y+1}.`}),A.isSource?E(vi,{children:[E(me,{className:"items-center gap-1",children:[p("span",{className:"bg-fill-brand block h-1.5 w-1.5 rounded-full"}),p("span",{className:"text-fg-default font-semibold",children:u("move.amr.rightPanel.topology.edit.thisNode")})]}),p("span",{className:"text-fg-subtle",children:"->"}),p("span",{children:A.oppositeNodeName})]}):E(vi,{children:[p("span",{children:A.oppositeNodeName}),p("span",{className:"text-fg-subtle",children:"->"}),E(me,{className:"items-center gap-1",children:[p("span",{className:"bg-fill-brand block h-1.5 w-1.5 rounded-full"}),p("span",{className:"text-fg-default font-semibold",children:u("move.amr.rightPanel.topology.edit.thisNode")})]})]})]})},A.id)})}),Be.length>4&&E(vi,{children:[ne&&p("div",{className:"from-bg-alt-1 pointer-events-none absolute top-0 right-0 left-0 h-3 rounded-t-md bg-gradient-to-b to-transparent"}),Te&&p("div",{className:"from-bg-alt-1 pointer-events-none absolute right-0 bottom-0 left-0 h-6 rounded-b-md bg-gradient-to-t to-transparent"})]})]}),Me&&E(j,{className:"border-border-subtle gap-3 rounded-md border p-3",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.topology.edit.selectedLinkInfo")}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.topology.link.dir")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(Ut,{className:"w-full",name:`topology-edit-link-dir-forward-${Me.id}`,checkValue:"FORWARD",value:O,onChange:A=>{A.target.checked&&(W("FORWARD"),Ye(Me.id,{dir:"FORWARD"}))},children:"FORWARD"}),p(Ut,{className:"w-full",name:`topology-edit-link-dir-reverse-${Me.id}`,checkValue:"REVERSE",value:O,onChange:A=>{A.target.checked&&(W("REVERSE"),Ye(Me.id,{dir:"REVERSE"}))},children:"REVERSE"})]})]}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.topology.link.method")}),p("div",{className:"grid grid-cols-3 gap-2",children:["PP","HPP","QD"].map(A=>p(Ut,{className:"w-full",name:`topology-edit-link-method-${Me.id}-${A.toLowerCase()}`,checkValue:A,value:Z,onChange:Y=>{Y.target.checked&&(K(A),Ye(Me.id,{method:A}))},children:A},A))})]}),E("div",{className:"grid grid-cols-2 gap-2",children:[E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-default",children:u("move.amr.rightPanel.common.speed")}),p("p",{className:"text-fg-subtle",children:"(max 1.0)"})]}),p(cn,{className:"w-full",value:oe,step:.1,min:0,max:1,handleChange:A=>{const Y=String(lh(A,0,1,pi.speed));te(Y),Ye(Me.id,{speed:Number(Y)})}})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-default",children:u("move.amr.rightPanel.topology.link.avoidRange")}),p("p",{className:"text-fg-subtle",children:"(max 1.2)"})]}),p(cn,{className:"w-full",value:ve,step:.1,min:0,max:1.2,handleChange:A=>{const Y=String(lh(A,0,1.2,pi.avoidRange));ce(Y),Ye(Me.id,{avoidRange:Number(Y)})}})]})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:u("move.amr.rightPanel.topology.link.safetyField")}),p(cn,{className:"w-full",value:Q,step:1,min:0,handleChange:A=>{const Y=String(lh(A,0,Number.MAX_SAFE_INTEGER,pi.safetyField));re(Y),Ye(Me.id,{safetyField:Number(Y)})}})]}),p(We,{variant:"dangerSoft",className:"mt-1",leadingIcon:p(wr,{}),onClick:()=>{a?.(Me.id)},children:u("move.amr.rightPanel.topology.edit.deleteThisLink")})]})]}):E(j,{className:"border-border-subtle gap-1 rounded-md border p-3",children:[p("p",{className:"typo-compact-sm-normal text-fg-subtler",children:u("move.amr.rightPanel.topology.edit.noConnectedLinks")}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:u("move.amr.rightPanel.topology.edit.useLinkTab")})]})})})})]}):p(_r,{className:"flex-1 [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:p(Du,{}),message:u("move.amr.rightPanel.topology.nodes.empty"),description:u("move.amr.rightPanel.topology.edit.selectNodeToEdit")}),v&&E(j,{className:"gap-2 p-3",children:[p(We,{variant:"transparent",className:"text-fg-danger py-2",leadingIcon:p(wr,{}),onClick:l,children:u("move.amr.rightPanel.common.delete")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"outlined",className:"h-9",onClick: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?.()},children:u("move.amr.rightPanel.common.cancel")}),p(We,{variant:"brand",className:"h-9",onClick:d,children:u("move.amr.rightPanel.common.saveChanges")})]})]})]})},{useEffect:RR,useMemo:ch,useState:dr}=await wt("react"),zs={dir:"FORWARD",method:"PP",speed:0,avoidRange:0,safetyField:0},dh=(r,e,t,n)=>{const i=Number(r);return Number.isNaN(i)?n:Math.min(t,Math.max(e,i))},YN=({selectedObjects:r,nodes:e=[],onToolChange:t,onCreateLinks:n,onDeleteLinksBetweenSelected:i,onCancelTopologyChanges:s,onSaveTopologyChanges:a})=>{const{confirmDialog:o}=As({confirmComponent:Cs}),{t:l}=en();RR(()=>{t?.("select")},[t]);const[c,d]=dr("sequential"),[h,u]=dr("bidirectional"),[f,m]=dr(zs.dir),[v,g]=dr(zs.method),[b,y]=dr(String(zs.speed)),[w,_]=dr(String(zs.avoidRange)),[R,T]=dr(String(zs.safetyField)),P=ch(()=>r.map(I=>{const G=e.find(q=>q.uuid===I.uuid);return{id:I.uuid,name:G?.name||I.name||I.uuid,mesh:I}}),[e,r]),M=ch(()=>{const I=P.length;if(I<2)return l("move.amr.rightPanel.topology.link.selectAtLeastTwo");if(I===2){const[O,W]=P,Z=h==="bidirectional"?" ↔ ":" → ";return l("move.amr.rightPanel.topology.link.willCreateNamed",{from:O.name,connector:Z,to:W.name})}const G=c==="sequential"?I-1:I*(I-1)/2,q=h==="bidirectional"?G*2:G;return l("move.amr.rightPanel.topology.link.willCreateCount",{count:q})},[c,h,P,l]),x=ch(()=>({dir:f,method:v,speed:dh(b,0,1,zs.speed),avoidRange:dh(w,0,1.2,zs.avoidRange),safetyField:dh(R,0,Number.MAX_SAFE_INTEGER,zs.safetyField)}),[w,f,v,R,b]),S=I=>{P.length<2||n(I,c,x)},C=()=>{P.length<2||i()},k=P.length>=2;return E(j,{className:"h-full min-h-0 overflow-hidden",children:[E(j,{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto",children:[E(me,{className:"border-subtler gap-1.5 border-b p-3",children:[p(Cu,{className:"text-fg-default"}),E(j,{className:"gap-0.5",children:[p("p",{className:"compact-sm-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.nodeSelectedCount",{count:P.length})}),p("p",{className:"typo-compact-xs-normal text-fg-subtle",children:l("move.amr.rightPanel.topology.link.selectAtLeastTwoShort")})]})]}),E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.creationMode")}),E("div",{className:"grid grid-cols-2 gap-2",children:[E(Ut,{name:"topology-link-mode-sequential",className:"w-full",checkValue:"sequential",value:c,disabled:P.length<3,onChange:I=>{I.target.checked&&d("sequential")},children:[l("move.amr.rightPanel.topology.link.sequential"),p("br",{}),"(1→2→3)"]}),E(Ut,{name:"topology-link-mode-complete",className:"w-full",checkValue:"complete",value:c,disabled:P.length<3,onChange:I=>{I.target.checked&&d("complete")},children:[l("move.amr.rightPanel.topology.link.complete"),p("br",{}),"(all↔all)"]})]}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:l("move.amr.rightPanel.topology.link.modeAvailable")})]}),E(j,{className:"border-border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.direction")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(Ut,{name:"topology-link-direction-bidirectional",className:"w-full",checkValue:"bidirectional",value:h,disabled:!k,onChange:I=>{I.target.checked&&u("bidirectional")},children:l("move.amr.rightPanel.topology.link.bidirectional")}),p(Ut,{name:"topology-link-direction-unidirectional",className:"w-full",checkValue:"unidirectional",value:h,disabled:!k,onChange:I=>{I.target.checked&&u("unidirectional")},children:l("move.amr.rightPanel.topology.link.unidirectional")})]}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:l("move.amr.rightPanel.topology.link.configureDirection")})]}),E(j,{className:`border-subtler gap-2 border-b p-3 ${k?"":"opacity-50"}`,children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.properties")}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.dir")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(Ut,{name:"topology-link-dir-forward",className:"w-full",checkValue:"FORWARD",value:f,disabled:!k,onChange:I=>{I.target.checked&&m("FORWARD")},children:"FORWARD"}),p(Ut,{name:"topology-link-dir-reverse",className:"w-full",checkValue:"REVERSE",value:f,disabled:!k,onChange:I=>{I.target.checked&&m("REVERSE")},children:"REVERSE"})]})]}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.method")}),p("div",{className:"grid grid-cols-3 gap-2",children:["PP","HPP","QD"].map(I=>p(Ut,{name:`topology-link-method-${I.toLowerCase()}`,className:"w-full",checkValue:I,value:v,disabled:!k,onChange:G=>{G.target.checked&&g(I)},children:I},I))})]}),E("div",{className:"grid grid-cols-2 gap-2",children:[E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-default",children:l("move.amr.rightPanel.common.speed")}),p("p",{className:"text-fg-subtle",children:"(max 1.0)"})]}),p(cn,{className:"w-full",value:b,step:.1,min:0,max:1,disabled:!k,handleChange:I=>{y(I)}})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-default",children:l("move.amr.rightPanel.topology.link.avoidRange")}),p("p",{className:"text-fg-subtle",children:"(max 1.2)"})]}),p(cn,{className:"w-full",value:w,step:.1,min:0,max:1.2,disabled:!k,handleChange:I=>{_(I)}})]})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:l("move.amr.rightPanel.topology.link.safetyField")}),p(cn,{className:"w-full",value:R,step:1,min:0,disabled:!k,handleChange:I=>{T(I)}})]})]})]}),E(j,{className:"border-subtler border-b p-3",children:[p("p",{className:"typo-compact-xs-normal text-fg-subtle text-center",children:M}),p("p",{className:"typo-compact-xs-normal text-fg-subtler pt-1 text-center",children:l("move.amr.rightPanel.topology.link.previewProperties",{dir:x.dir,method:x.method,speed:x.speed.toFixed(1),avoid:x.avoidRange.toFixed(1)})}),E(j,{className:"gap-2 pt-3",children:[p(We,{variant:"soft",className:"text-fg-default py-2",disabled:P.length<2,onClick:()=>{S(h==="bidirectional")},children:l("move.amr.rightPanel.topology.link.linkSelected")}),p(We,{variant:"dangerSoft",onClick:C,disabled:P.length<2,leadingIcon:p(wr,{}),children:l("move.amr.rightPanel.topology.link.deleteLinks")}),E("div",{className:"grid grid-cols-2 gap-2 pt-1",children:[p(We,{variant:"outlined",className:"h-9",onClick:async()=>{await o({title:l("move.amr.rightPanel.common.cancel"),content:l("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:l("move.amr.rightPanel.common.discard"),no:l("move.amr.rightPanel.common.keepEditing")}})&&s?.()},children:l("move.amr.rightPanel.common.cancel")}),p(We,{variant:"brand",className:"h-9",onClick:a,children:l("move.amr.rightPanel.common.save")})]})]})]})]})},{useMemo:NR}=await wt("react"),DR=["NO_ENTRY","IGNORE_LIDAR_2D","IGNORE_LIDAR_3D"],KN=({draft:r,onDraftStart:e,onDraftCancel:t,onDraftClear:n,onDraftUndo:i,onDraftClose:s,onDraftCommit:a,onDraftMetaChange:o,zones:l,onDeleteZone:c,onSaveTopologyChanges:d,onCancelTopologyChanges:h})=>{const{confirmDialog:u}=As({confirmComponent:Cs}),f=NR(()=>r.state==="closed"?"Zone outline closed. Save to apply.":r.points.length===0?"No points placed yet. Start drawing to preview the flow.":r.points.length<3?"Need at least 3 points to close a zone.":"Ready to close zone.",[r.points.length,r.state]),m=r.state==="idle",v=r.state==="drawing",g=r.state==="closed",b=r.points.length>0&&!g,y=r.points.length>0&&!g,w=r.points.length>=3&&!g,_=g,R=r.points.length>0||g;return E(j,{className:"h-full min-h-0",children:[E(j,{className:"min-h-0 flex-1 gap-3 overflow-y-auto p-3",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Zone"}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Draw polygon zones with cursor preview and point connections."})]}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"1. Zone Details"}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Zone Name"}),p(un,{className:"w-full",size:"sm",placeholder:"Enter zone name",value:r.name,onChange:T=>{o({name:T.target.value})}})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Zone Type"}),p("div",{className:"grid grid-cols-1 gap-2",children:DR.map(T=>p(Ut,{className:"w-full",name:`topology-zone-type-${T.toLowerCase()}`,checkValue:T,value:r.type,onChange:P=>{P.target.checked&&o({type:T})},children:T},T))})]})]}),p(ji,{}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"2. Canvas Interaction Guide"}),E(j,{className:"gap-1 rounded-md border border-stroke-soft p-3",children:[p("p",{className:"typo-compact-xs-normal text-fg-default",children:g?"Zone draft is closed and ready to save":v?"Cursor preview follows the mouse in the scene":"Drawing starts only after you press Start Drawing"}),p("p",{className:"typo-compact-xs-normal text-fg-default",children:"Move cursor to preview a point"}),p("p",{className:"typo-compact-xs-normal text-fg-default",children:"Left click to place a zone point"}),p("p",{className:"typo-compact-xs-normal text-fg-default",children:"Each new point connects to the previous point"}),p("p",{className:"typo-compact-xs-normal text-fg-default",children:"Use Close Zone when the outline is complete"})]}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:f})]}),p(ji,{}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"3. Draft Point Preview"}),p(j,{className:"gap-1 rounded-md border border-stroke-soft p-2",children:r.points.length>0?r.points.map((T,P)=>E("div",{className:"flex items-center justify-between rounded-sm px-2 py-1.5",children:[E("div",{className:"flex items-center gap-2",children:[p("span",{className:"h-2 w-2 rounded-full bg-red-500"}),p("p",{className:"typo-compact-xs-semibold text-fg-default",children:`P${P+1}`})]}),E("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[T.x.toFixed(2),", ",T.y.toFixed(2)]})]},`${P}-${T.x}-${T.y}`)):p("p",{className:"typo-compact-xs-normal px-2 py-1 text-fg-subtler",children:"No points placed yet"})})]}),p(ji,{}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"4. Saved Zones"}),p(j,{className:"gap-1 rounded-md border border-stroke-soft p-2",children:l.length>0?l.map(T=>E("div",{className:"flex items-center justify-between gap-2 rounded-sm px-2 py-2",children:[E(j,{className:"min-w-0 flex-1 gap-0.5",children:[p("p",{className:"typo-compact-xs-semibold truncate text-fg-default",children:T.name||T.id}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:`${T.type} / ${T.polygon.length} points`})]}),p(We,{variant:"dangerSoft",className:"shrink-0",onClick:async()=>{await u({title:"Delete Zone",content:"Delete this saved zone?",buttonText:{yes:"Delete",no:"Keep"}})&&c(T.id)},children:"Delete"})]},T.id)):p("p",{className:"typo-compact-xs-normal px-2 py-1 text-fg-subtler",children:"No saved zones"})})]})]}),p(j,{className:"sticky bottom-0 z-[1] p-3",children:E(j,{className:"gap-2",children:[m&&p(We,{variant:"soft",className:"text-fg-default py-2",onClick:()=>{e({name:r.name,type:r.type})},children:"Start Drawing"}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"outlined",disabled:!b,onClick:i,children:"Undo Last Point"}),p(We,{variant:"outlined",disabled:!y,onClick:n,children:"Clear Points"})]}),p(We,{variant:"dangerSoft",disabled:!w,onClick:s,children:"Close Zone"}),E("div",{className:"grid grid-cols-2 gap-2 pt-1",children:[p(We,{variant:"outlined",onClick:async()=>{if(!R){h?.();return}await u({title:"Cancel",content:"Discard this zone draft and unsaved topology changes?",buttonText:{yes:"Discard",no:"Keep Editing"}})&&(t(),h?.())},children:"Cancel"}),p(We,{variant:"brand",disabled:!_,onClick:()=>{a(),d?.()},children:"Save"})]})]})})]})},Fo=({children:r,cancelLabel:e,saveLabel:t,onCancel:n,onSave:i,cancelDisabled:s=!1,saveDisabled:a=!1})=>E(j,{className:"border-subtler sticky bottom-0 z-1 gap-2 border-t p-3",children:[r,E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"outlined",className:"h-9",disabled:s,onClick:n,children:e}),p(We,{variant:"brand",className:"h-9",disabled:a,onClick:i,children:t})]})]}),{useEffect:hh,useMemo:sa,useState:Hs}=await wt("react"),mi={dir:"FORWARD",method:"PP",speed:0,avoidRange:0,safetyField:0},uh=(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))},LR=({selectedObjects:r,focusedLinkId:e,linkVisibilityFilter:t,nodes:n,visibleSelectedLinks:i,onFocusedLinkChange:s,onLinkVisibilityFilterChange:a,onToolChange:o,onCreateLinks:l,onUpdateLink:c,onDeleteLink:d,onDeleteLinksBetweenSelected:h,onCancelTopologyChanges:u,onSaveTopologyChanges:f})=>{const{confirmDialog:m}=As({confirmComponent:Cs}),{t:v}=en(),[g,b]=Hs("sequential"),[y,w]=Hs("bidirectional"),[_,R]=Hs(mi.dir),[T,P]=Hs(mi.method),[M,x]=Hs(String(mi.speed)),[S,C]=Hs(String(mi.avoidRange)),[k,I]=Hs(String(mi.safetyField)),[G,q]=Hs(!1);hh(()=>{o?.("select")},[o]);const O=sa(()=>r.map(be=>{const Ce=n.find(X=>X.uuid===be.uuid);return{id:be.uuid,name:Ce?.name||be.name||be.uuid,mesh:be}}),[n,r]),W=sa(()=>i.map(be=>{const Ce=n.find(Be=>Be.id===be.from),X=n.find(Be=>Be.id===be.to);return{...be,fromName:Ce?.name??be.from,toName:X?.name??be.to}}),[n,i]),Z=i.length>0,K=i.length,oe=sa(()=>e?i.find(be=>be.id===e)??null:null,[e,i]),te=be=>{be!=="all"&&be!=="forward"&&be!=="reverse"||a({...t,dir:be})},ve=be=>{be!=="all"&&be!=="PP"&&be!=="HPP"&&be!=="QD"||a({...t,method:be})},ce=sa(()=>W.find(be=>be.id===oe?.id)??null,[oe?.id,W]);hh(()=>{if(!Z){R(mi.dir),P(mi.method),x(String(mi.speed)),C(String(mi.avoidRange)),I(String(mi.safetyField)),q(!1);return}},[Z]),hh(()=>{oe&&(R(oe.dir),P(oe.method),x(String(oe.speed)),C(String(oe.avoidRange)),I(String(oe.safetyField)),q(!1))},[oe]);const Q=sa(()=>{const be=O.length;if(be<2)return v("move.amr.rightPanel.topology.link.selectAtLeastTwo");if(be===2){const[Be,Me]=O,et=y==="bidirectional"?" ↔ ":" → ";return v("move.amr.rightPanel.topology.link.willCreateNamed",{from:Be.name,connector:et,to:Me.name})}const Ce=g==="sequential"?be-1:be*(be-1)/2,X=y==="bidirectional"?Ce*2:Ce;return v("move.amr.rightPanel.topology.link.willCreateCount",{count:X})},[g,y,O,v]),re=sa(()=>({dir:_,method:T,speed:uh(M,-1,1,mi.speed),avoidRange:uh(S,-1,1.2,mi.avoidRange),safetyField:uh(k,-1,Number.MAX_SAFE_INTEGER,mi.safetyField)}),[S,_,T,k,M]),J=be=>{O.length<2||l?.(be,g,re)},ne=()=>{oe&&c?.(oe.id,re)},ue=()=>{oe&&d?.(oe.id)},Te=be=>Ce=>{if(q(!0),Number(Ce)<0){be("-1");return}be(Ce)},_e=O.length>=2,fe=Z?"edit":"add";return E(j,{className:"h-full min-h-0 overflow-hidden",children:[E(j,{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto",children:[E(me,{className:"border-subtler gap-1.5 border-b p-3",children:[p(Cu,{className:"text-fg-default"}),E(j,{className:"gap-0.5",children:[p("p",{className:"compact-sm-semibold text-fg-default",children:fe==="edit"?`${K} link${K>1?"s":""} selected`:v("move.amr.rightPanel.topology.link.nodeSelectedCount",{count:O.length})}),p("p",{className:"typo-compact-xs-normal text-fg-subtle",children:fe==="edit"?K>1?"Select one link from the list below to edit.":"Review and update the selected link.":v("move.amr.rightPanel.topology.link.selectAtLeastTwoShort")})]})]}),fe==="edit"&&E(j,{className:"border-subtler gap-1.5 border-b p-3",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Link Filter"}),E("div",{className:"grid grid-cols-2 gap-2",children:[E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Direction"}),E(dc,{size:"sm",value:t.dir,handleChange:te,children:[p(es,{value:"all",children:"All"}),p(es,{value:"forward",children:"Forward"}),p(es,{value:"reverse",children:"Reverse"})]})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Method"}),E(dc,{size:"sm",value:t.method,handleChange:ve,children:[p(es,{value:"all",children:"All"}),p(es,{value:"PP",children:"PP"}),p(es,{value:"HPP",children:"HPP"}),p(es,{value:"QD",children:"QD"})]})]})]})]}),fe==="add"&&E(vi,{children:[E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.topology.link.creationMode")}),E("div",{className:"grid grid-cols-2 gap-2",children:[E(Ut,{name:"topology-link-mode-sequential",className:"w-full",checkValue:"sequential",value:g,disabled:O.length<3,onChange:be=>{be.target.checked&&b("sequential")},children:[v("move.amr.rightPanel.topology.link.sequential"),p("br",{}),"(1→2→3)"]}),E(Ut,{name:"topology-link-mode-complete",className:"w-full",checkValue:"complete",value:g,disabled:O.length<3,onChange:be=>{be.target.checked&&b("complete")},children:[v("move.amr.rightPanel.topology.link.complete"),p("br",{}),"(all↔all)"]})]}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:v("move.amr.rightPanel.topology.link.modeAvailable")})]}),E(j,{className:"border-border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.topology.link.direction")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(Ut,{name:"topology-link-direction-bidirectional",className:"w-full",checkValue:"bidirectional",value:y,disabled:!_e,onChange:be=>{be.target.checked&&w("bidirectional")},children:v("move.amr.rightPanel.topology.link.bidirectional")}),p(Ut,{name:"topology-link-direction-unidirectional",className:"w-full",checkValue:"unidirectional",value:y,disabled:!_e,onChange:be=>{be.target.checked&&w("unidirectional")},children:v("move.amr.rightPanel.topology.link.unidirectional")})]}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:v("move.amr.rightPanel.topology.link.configureDirection")})]})]}),fe==="edit"&&E(j,{className:"border-subtler gap-3 border-b p-3",children:[E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Selected Links"}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:K>1?"Choose one link to load its properties into the editor.":"The selected link is ready to edit."})]}),p(j,{className:"border-border-subtle max-h-40 gap-1 overflow-y-auto rounded-md border p-1.5",children:W.map((be,Ce)=>E(me,{className:`items-center justify-between rounded-md border px-2 py-1.5 transition-colors ${be.id===oe?.id?"border-border-default bg-fill-subtler":"border-transparent bg-fill-control-surface hover:border-border-subtle"}`,onClick:()=>{s(be.id)},children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:`${Ce+1}. ${be.fromName} -> ${be.toName}`}),p("p",{className:"typo-compact-xs-normal text-fg-subtler shrink-0",children:`${be.method} / ${be.dir}`})]},be.id))})]}),E(j,{className:`border-subtler gap-2 border-b p-3 ${fe==="add"&&!_e?"opacity-50":""}`,children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:v("move.amr.rightPanel.topology.link.properties")}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:v("move.amr.rightPanel.topology.link.dir")}),E("div",{className:"grid grid-cols-2 gap-2",children:[p(Ut,{name:"topology-link-dir-forward",className:"w-full",checkValue:"FORWARD",value:_,disabled:fe==="add"?!_e:!oe,onChange:be=>{be.target.checked&&(q(!0),R("FORWARD"))},children:"FORWARD"}),p(Ut,{name:"topology-link-dir-reverse",className:"w-full",checkValue:"REVERSE",value:_,disabled:fe==="add"?!_e:!oe,onChange:be=>{be.target.checked&&(q(!0),R("REVERSE"))},children:"REVERSE"})]})]}),E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:v("move.amr.rightPanel.topology.link.method")}),p("div",{className:"grid grid-cols-3 gap-2",children:["PP","HPP","QD"].map(be=>p(Ut,{name:`topology-link-method-${be.toLowerCase()}`,className:"w-full",checkValue:be,value:T,disabled:fe==="add"?!_e:!oe,onChange:Ce=>{Ce.target.checked&&(q(!0),P(be))},children:be},be))})]}),E("div",{className:"grid grid-cols-2 gap-2",children:[E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-default",children:v("move.amr.rightPanel.common.speed")}),p("p",{className:"text-fg-subtle",children:"(max 1.0)"})]}),p(cn,{className:"w-full",value:M,step:.1,increaseStep:Number(M)<0?1:.1,min:-1,max:1,disabled:fe==="add"?!_e:!oe,handleChange:Te(x)})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-default",children:v("move.amr.rightPanel.topology.link.avoidRange")}),p("p",{className:"text-fg-subtle",children:"(max 1.2)"})]}),p(cn,{className:"w-full",value:S,step:.1,increaseStep:Number(S)<0?1:.1,min:-1,max:1.2,disabled:fe==="add"?!_e:!oe,handleChange:Te(C)})]})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:v("move.amr.rightPanel.topology.link.safetyField")}),p(cn,{className:"w-full",value:k,step:1,min:-1,disabled:fe==="add"?!_e:!oe,handleChange:be=>{q(!0),I(be)}})]})]})]}),p(Fo,{cancelLabel:v("move.amr.rightPanel.common.cancel"),saveLabel:v("move.amr.rightPanel.common.save"),onCancel:async()=>{await m({title:v("move.amr.rightPanel.common.cancel"),content:v("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:v("move.amr.rightPanel.common.discard"),no:v("move.amr.rightPanel.common.keepEditing")}})&&u?.()},onSave:f,children:E(j,{className:"border-subtler border-b p-3",children:[p("p",{className:"typo-compact-xs-normal text-fg-subtle text-center",children:fe==="edit"?ce?`${ce.fromName} -> ${ce.toName} is selected for editing.`:"Select a link from the list above to edit.":Q}),p("p",{className:"typo-compact-xs-normal text-fg-subtler pt-1 text-center",children:fe==="edit"?oe?`dir ${re.dir} / method ${re.method} / speed ${re.speed.toFixed(1)} / avoid ${re.avoidRange.toFixed(1)}`:"":v("move.amr.rightPanel.topology.link.previewProperties",{dir:re.dir,method:re.method,speed:re.speed.toFixed(1),avoid:re.avoidRange.toFixed(1)})}),p(j,{className:"gap-2 pt-3",children:fe==="edit"?E(vi,{children:[p(We,{variant:"soft",className:"text-fg-default py-2",disabled:!oe||!G,onClick:ne,children:"Update selected link"}),p(We,{variant:"dangerSoft",onClick:ue,disabled:!oe,leadingIcon:p(wr,{}),children:"Delete selected link"})]}):E(vi,{children:[p(We,{variant:"soft",className:"text-fg-default py-2",disabled:O.length<2,onClick:()=>{J(y==="bidirectional")},children:v("move.amr.rightPanel.topology.link.linkSelected")}),p(We,{variant:"dangerSoft",onClick:h,disabled:O.length<2,leadingIcon:p(wr,{}),children:v("move.amr.rightPanel.topology.link.deleteLinks")})]})})]})})]})},IR=({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}=As({confirmComponent:Cs}),{t:u}=en(),f=r==="target";return E(j,{className:"h-full min-h-0 gap-0",children:[E(j,{className:"min-h-0 flex-1 overflow-y-auto",children:[E(j,{className:"border-subtler gap-0.5 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.add.title")}),p("p",{className:"typo-compact-xs-normal text-fg-subtler",children:u("move.amr.rightPanel.topology.add.description")})]}),E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.add.selectNodeType")}),E("div",{className:"grid grid-cols-3 gap-2",children:[p(Ut,{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")}),p(Ut,{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")}),p(Ut,{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")})]})]}),E(j,{className:"border-subtler gap-2 border-b p-3",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.add.selectPlacement")}),E(me,{className:"items-center justify-between gap-2 py-1",children:[E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Cursor Preview"}),p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:"Enable cursor placement mode before adding at cursor position."})]}),p(xa,{checked:f,onCheckedChange:m=>{if(m){e?.("target");return}r==="target"&&e?.("select")}})]}),E(j,{className:"gap-2",children:[p(Ut,{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&&p(Ut,{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")})]})]})]}),p(Fo,{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:E(We,{variant:"soft",className:"text-fg-default",onClick:()=>{if(i==="robot"){a?.();return}if(r!=="target"){uy.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:fh,useMemo:Dg,useRef:ph,useState:ms}=await wt("react"),mh=["INIT","CHARGING","AUTO_DOOR","ARUCO","APRIL","V_MARKER","TAPE","PRECISION","SCAN_MATCH"],Mi=r=>Number(r.toFixed(3)),Lv=-1,Iv=31,kR=r=>{const e=r.trim();if(!/^-?\d+$/.test(e))return null;const t=Number(e);return Number.isInteger(t)?Math.min(Iv,Math.max(Lv,t)):null},OR=r=>{const e=r.toLowerCase().replace("init","goal");return e==="route"||e==="align"?e:"goal"},FR=({selectedObjects:r=[],selectedNodeTransform:e=null,nodes:t=[],robotPose:n=null,onUpdateNode:i,onTransformSelectedNodes:s,onDeleteSelectedNodes:a,onCancelTopologyChanges:o,onSaveTopologyChanges:l})=>{const{confirmDialog:c}=As({confirmComponent:Cs}),{t:d}=en(),[h,u]=ms(""),[f,m]=ms([]),[v,g]=ms("0"),[b,y]=ms("0.0"),[w,_]=ms("0.0"),[R,T]=ms("0.0"),[P,M]=ms("0.0"),[x,S]=ms(!1),[C,k]=ms("1"),I=ph({altKey:!1,metaKey:!1,ctrlKey:!1}),G=ph(null),q=ph(!1);fh(()=>{const ee=A=>{I.current={altKey:A.altKey,metaKey:A.metaKey,ctrlKey:A.ctrlKey}},U=()=>{I.current={altKey:!1,metaKey:!1,ctrlKey:!1},G.current=null};return window.addEventListener("keydown",ee),window.addEventListener("keyup",ee),window.addEventListener("blur",U),()=>{window.removeEventListener("keydown",ee),window.removeEventListener("keyup",ee),window.removeEventListener("blur",U)}},[]);const O=Dg(()=>r.map(ee=>{const U=t.find(A=>A.uuid===ee.uuid);return{uuid:ee.uuid,externalId:String(ee.userData?.id??""),name:ee.name,type:OR(U?.type||ee.userData?.type||"goal"),features:Array.isArray(ee.userData?.features)?ee.userData.features.filter(A=>typeof A=="string"&&mh.includes(A)):[],safetyField:typeof ee.userData?.safetyField=="number"?ee.userData.safetyField:U?.safetyField??0,x:ee.position.x,y:ee.position.y,z:ee.position.z,rz:Mi(ee.rotation.z*180/Math.PI)}}),[t,r]),W=O[O.length-1],Z=O.length===1,K=Dg(()=>{if(!n)return null;const ee=Number(n.x),U=Number(n.y),A=Number(n.rz);return[ee,U,A].some(Y=>Number.isNaN(Y))?null:{x:Mi(ee),y:Mi(U),rz:Mi(A)}},[n]);fh(()=>{u(W?.name??""),m(W?.features??[]),g(String(W?.safetyField??0))},[W?.uuid,W?.name,W?.features,W?.safetyField]),fh(()=>{let ee=null;e?ee={x:e.x,y:e.y,z:e.z,rz:e.rz}:W&&(ee={x:W.x,y:W.y,z:W.z,rz:W.rz}),y(String(Mi(ee?.x??0))),_(String(Mi(ee?.y??0))),T(String(Mi(ee?.z??0))),M(String(Mi(ee?.rz??0)))},[W,W?.uuid,W?.x,W?.y,W?.z,W?.rz,e]);const oe=(ee,U)=>{i?.(ee,U)},te=ee=>ee.filter(U=>typeof U=="string"&&mh.includes(U)),ve=(ee,U)=>{ee==="x"&&y(U),ee==="y"&&_(U),ee==="z"&&T(U)},ce=(ee,U)=>{if(ee==="x"||ee==="y"||ee==="z"){ve(ee,U);return}M(U)},Q=ee=>{const U=r[r.length-1];return U?ee==="x"?U.position.x:ee==="y"?U.position.y:ee==="z"?U.position.z:Mi(U.rotation.z*180/Math.PI):0},re=(ee=I.current)=>ee.altKey?"delta":ee.metaKey||ee.ctrlKey?"absolute":"single",J=()=>G.current??re(),ne=(ee,U)=>{G.current=re({altKey:U?.altKey,metaKey:U?.metaKey,ctrlKey:U?.ctrlKey})},ue=()=>{G.current=null},Te=ee=>{q.current=ee.metaKey||ee.ctrlKey},_e=(ee,U,A)=>{const Y=A?ee.features.includes(U)?ee.features:[...ee.features,U]:ee.features.filter(V=>V!==U);oe(ee.uuid,{features:Y})},fe=(ee,U)=>{if(!W||!Array.isArray(U))return;const A=te(U),Y=A.includes(ee),V=q.current;if(q.current=!1,m(A),V){for(const $ of O)_e($,ee,Y);return}oe(W.uuid,{features:A})},be=(ee,U,A)=>{if(!W)return;const Y=A?J():re(),V=Number(U);if(Number.isNaN(V))return;const $=Mi(V),le=String($);if(ee==="x"||ee==="y"||ee==="z"?ve(ee,le):M(le),Y==="delta"){const Ie=Mi(A?(A==="up"?1:-1)*(Number(C)||1):$-Q(ee));s?.(ee,Ie,"delta");return}if(Y==="absolute"){s?.(ee,$,"absolute");return}if(ee==="x"||ee==="y"||ee==="z"){oe(W.uuid,{[ee]:$});return}oe(W.uuid,{rz:$})},Ce=(ee,U,A)=>{if(A){be(ee,U,A);return}ce(ee,U)},X=(ee,U)=>{be(ee,U)},Be=(ee,U)=>{if(!W)return;const A=U?J():re(),Y=kR(ee);if(Y===null)return;const V=String(Y);if(g(V),A==="absolute"){for(const $ of O)oe($.uuid,{safetyField:Y});return}oe(W.uuid,{safetyField:Y})},Me=ee=>{W&&/^-?\d*$/.test(ee)&&g(ee)},et=(ee,U)=>{if(U){Be(ee,U);return}Me(ee)},Se=ee=>{Be(ee)},Ye=()=>{!Z||!K||(y(String(K.x)),_(String(K.y)),M(String(K.rz)),oe(W.uuid,K))};return E(j,{className:"h-full min-h-0 overflow-hidden",children:[E(j,{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto",children:[E(j,{className:"border-subtler gap-3 border-b p-3",children:[E(me,{className:"items-center justify-between gap-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:d("move.amr.rightPanel.topology.edit.nodeProperties")}),O.length>1&&E("p",{className:"typo-compact-2xs-semibold text-fg-subtler",children:[O.length," selected"]})]}),E(j,{className:"gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.topology.edit.nodeId")}),E(me,{className:"items-center gap-1.5",children:[p("p",{className:"typo-compact-xs-normal text-fg-subtler flex-1",children:W?.externalId??""}),W?.externalId&&p("button",{className:"text-fg-subtler hover:text-fg-default shrink-0",onClick:()=>{eb({text:W.externalId??""})},children:p(Jg,{className:"size-3.5"})})]})]}),E(j,{className:"gap-1.5",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.topology.edit.name")}),p(un,{className:"w-full",type:"text",value:h,onChange:ee=>{if(!W)return;const U=ee.target.value;u(U),oe(W.uuid,{name:U})}})]}),E(j,{className:"gap-1.5",children:[E(me,{className:"items-center gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.topology.link.safetyField")}),p("p",{className:"text-fg-subtle typo-compact-2xs-normal",children:"(-1 ~ 31)"})]}),p(cn,{className:"w-full",value:v,step:1,min:Lv,max:Iv,handleChange:(ee,U,A)=>{et(ee,A?.type)},handleEnter:ee=>{Se(ee)},onButtonPointerDown:ne,onButtonPointerUp:ue})]})]}),p("div",{className:"border-subtler border-b",children:p(ha,{title:p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:d("move.amr.rightPanel.topology.edit.features")}),children:p("div",{className:"grid grid-cols-2 gap-x-2 gap-y-2",children:mh.map(ee=>p(Lu,{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-${W?.uuid??""}`,checkValue:ee,value:f,onClick:Te,handleChange:U=>{fe(ee,U)},children:p("span",{className:"typo-compact-xs-normal text-fg-default",children:ee})},ee))})})}),p("div",{className:"border-subtler border-b",children:E(ha,{initialOpen:!0,title:E(me,{className:"w-full items-center justify-between",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:d("move.amr.rightPanel.topology.edit.transform")}),E(me,{className:"text-fg-default items-center gap-0.5",children:[p(We,{variant:"transparent",size:"2xs",leadingIcon:p(Sc,{}),onClick:ee=>{ee.preventDefault(),ee.stopPropagation(),S(U=>!U)},children:d("move.amr.rightPanel.topology.edit.stepSize")}),p("div",{className:`overflow-hidden transition-all duration-200 ease-out ${x?"w-32 opacity-100":"pointer-events-none w-0 opacity-0"}`,children:p(cn,{className:"h-8 w-32",value:C,step:.1,handleChange:ee=>{k(ee)}})})]})]}),children:[E(j,{className:"gap-2 pt-1",children:[E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-danger",children:"X"}),p("p",{className:"text-fg-subtle",children:"(m)"})]}),p(cn,{className:"w-full",value:b,step:Number(C)||1,handleChange:(ee,U,A)=>{Ce("x",ee,A?.type)},handleEnter:ee=>{X("x",ee)},onButtonPointerDown:ne,onButtonPointerUp:ue})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-success",children:"Y"}),p("p",{className:"text-fg-subtle",children:"(m)"})]}),p(cn,{className:"w-full",value:w,step:Number(C)||1,handleChange:(ee,U,A)=>{Ce("y",ee,A?.type)},handleEnter:ee=>{X("y",ee)},onButtonPointerDown:ne,onButtonPointerUp:ue})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-brand",children:"Z"}),p("p",{className:"text-fg-subtle",children:"(m)"})]}),p(cn,{className:"w-full",value:R,step:Number(C)||1,handleChange:(ee,U,A)=>{Ce("z",ee,A?.type)},handleEnter:ee=>{X("z",ee)},onButtonPointerDown:ne,onButtonPointerUp:ue})]})]}),E(j,{className:"gap-1",children:[E(me,{className:"typo-compact-xs-medium gap-1",children:[p("p",{className:"text-fg-information",children:"RZ"}),p("p",{className:"text-fg-subtle",children:"(°)"})]}),p(cn,{className:"w-full",value:P,step:Number(C)||1,min:0,max:360,handleChange:(ee,U,A)=>{Ce("rz",ee,A?.type)},handleEnter:ee=>{X("rz",ee)},onButtonPointerDown:ne,onButtonPointerUp:ue}),Z&&K&&p(me,{className:"mt-2 justify-center",children:p(We,{variant:"transparent",size:"sm",leadingIcon:p(ya,{}),onClick:Ye,children:"Match Robot Pose"})})]})]})})]}),p(Fo,{cancelLabel:d("move.amr.rightPanel.common.cancel"),saveLabel:d("move.amr.rightPanel.common.saveChanges"),onCancel:async()=>{await c({title:d("move.amr.rightPanel.common.cancel"),content:d("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:d("move.amr.rightPanel.common.discard"),no:d("move.amr.rightPanel.common.keepEditing")}})&&o?.()},onSave:l,children:E("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:a,children:[p(wr,{className:"size-4"}),d("move.amr.rightPanel.common.delete")]})})]})},{useEffect:UR,useMemo:BR,useRef:zR,useState:$l}=await wt("react"),HR=r=>{const e=r.toLowerCase();return e==="goal"?p(Kg,{className:"text-fg-warning"}):e==="route"?p(Nu,{className:"text-fg-brand"}):p($g,{className:"text-fg-success"})},GR=({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,onTransformSelectedNodes:m,onDeleteSelectedNodes:v,onSaveTopologyChanges:g,onCancelTopologyChanges:b,showRobotPlacement:y=!0})=>{const{t:w}=en(),_=zR(null),[R,T]=$l(""),[P,M]=$l("all"),[x,S]=$l(!1),[C,k]=$l(!1),I=e.length>0,G=BR(()=>{const W=R.trim().toLowerCase(),Z=W?r.filter(K=>(K.name||K.id).toLowerCase().includes(W)):r;return{all:Z,goal:Z.filter(K=>K.type.toLowerCase()==="goal"),route:Z.filter(K=>K.type.toLowerCase()==="route"),align:Z.filter(K=>K.type.toLowerCase()==="align")}},[r,R]),q=G[P];UR(()=>{const W=_.current;if(!W)return;const Z=()=>{const{scrollTop:K,clientHeight:oe,scrollHeight:te}=W;S(K>4),k(K+oe<te-4)};return Z(),W.addEventListener("scroll",Z),()=>{W.removeEventListener("scroll",Z)}},[q]);const O=W=>W.length===0?p(_r,{className:"h-full w-full flex-1 [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:p(Du,{}),message:w("move.amr.rightPanel.topology.nodes.empty")}):W.map(Z=>E(j,{children:[E(me,{className:"hover:bg-fill-subtle cursor-pointer items-center justify-between rounded-md px-1.5 py-1.5 transition-colors",onClick:K=>{const oe=K.metaKey||K.ctrlKey?"remove":K.shiftKey?"add":"replace";i?.(Z.uuid,oe)},children:[E(me,{className:"min-w-0 flex-1 items-center gap-2",children:[HR(Z.type),E(me,{className:"min-w-0 flex-1 items-center justify-between gap-2",children:[p("p",{className:"typo-compact-xs-normal text-fg-default truncate",children:Z.name?Z.name:`${Z.id}(ID)`}),E(me,{className:"mr-2 shrink-0 items-center gap-1.5",children:[p("p",{className:"typo-compact-2xs-semibold text-fg-subtler uppercase",children:Z.type}),p(ji,{type:"vertical",thickness:"thick",className:"text-fg-subtler h-4"}),E("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:[Z.x.toFixed(1),", ",Z.y.toFixed(1),", ",Z.z.toFixed(1)]})]})]})]}),p(Qg,{className:"text-fg-default"})]}),p(ji,{className:"text-fg-subtler"})]},Z.uuid));return E(j,{className:"h-full min-h-0 gap-0",children:[E(j,{className:"border-subtler h-[25%] min-h-[16rem] gap-2 border-b p-3",children:[p(un,{size:"sm",className:"w-full",value:R,type:"search",placeholder:w("move.amr.rightPanel.topology.nodes.searchByName"),onChange:W=>{T(W.target.value)}}),E(Au,{className:"min-h-0 w-full flex-1",variant:"line",value:P,onValueChange:W=>{(W==="all"||W==="goal"||W==="route"||W==="align")&&M(W)},children:[E(me,{className:"items-center justify-between gap-2",children:[E(Tu,{children:[p(Hi,{value:"all",children:w("move.amr.rightPanel.topology.nodeType.all")}),p(Hi,{value:"goal",children:w("move.amr.rightPanel.topology.nodeType.goal")}),p(Hi,{value:"route",children:w("move.amr.rightPanel.topology.nodeType.route")}),p(Hi,{value:"align",children:w("move.amr.rightPanel.topology.nodeType.align")})]}),E("p",{className:"typo-compact-2xs-semibold text-fg-subtler shrink-0 px-2",children:[q.length," / ",r.length]})]}),E("div",{className:"border-border-subtle bg-fill-disabled relative min-h-0 flex-1 overflow-hidden rounded-md border",children:[q.length>4&&x&&p("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"}),E("div",{ref:_,className:"h-full min-h-0 overflow-y-auto px-1 py-0.5",children:[p(js,{value:"all",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-1",children:O(G.all)})}),p(js,{value:"goal",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-1",children:O(G.goal)})}),p(js,{value:"route",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-1",children:O(G.route)})}),p(js,{value:"align",className:"h-full",children:p(j,{className:"h-full min-h-0 gap-1",children:O(G.align)})})]}),q.length>4&&C&&p("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"})]})]})]}),p(j,{className:"min-h-0 flex-1",children:I?p(FR,{selectedObjects:e,selectedNodeTransform:t,nodes:r,robotPose:n,onUpdateNode:f,onTransformSelectedNodes:m,onDeleteSelectedNodes:v,onCancelTopologyChanges:b,onSaveTopologyChanges:g}):p(IR,{selectedTool:s,onToolChange:a,selectedNodeType:o,onSelectNodeType:l,selectedNodePlacementType:c,onSelectNodePlacementType:d,onAddNodeAtRobot:h,onAddNodeAtCursor:u,onSaveTopologyChanges:g,onCancelTopologyChanges:b,showRobotPlacement:y})})]})},Ql=({label:r,value:e})=>E("div",{className:"flex items-center justify-between gap-2",children:[p("span",{className:"typo-compact-xs-normal text-fg-subtle",children:r}),p("span",{className:"typo-compact-xs-semibold text-fg-default",children:e})]}),VR=r=>{if(!r)return"-";const e=new Date(r);return Number.isNaN(e.getTime())?r:r.slice(0,19).replace("T"," ")},WR=({nodeCount:r=0,linkCount:e,zoneCount:t=0,createdAt:n,downloadDisabled:i=!1,downloadHelpText:s,onDownloadTopology:a,onCancelTopologyChanges:o,onSaveTopologyChanges:l})=>{const{t:c}=en();return E(j,{className:"h-full min-h-0",children:[E(j,{className:"min-h-0 flex-1 gap-4 p-3",children:[E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-sm-bold text-fg-default",children:"Overview"}),p("p",{className:"typo-compact-xs-normal text-fg-subtle",children:"Manage topology-level information and file actions."})]}),E(j,{className:"border-subtler bg-fill-control-surface gap-3 rounded-lg border p-3",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Topology Summary"}),E(j,{className:"gap-2",children:[p(Ql,{label:"Created At",value:VR(n)}),p(Ql,{label:"Nodes",value:r}),p(Ql,{label:"Links",value:e??"-"}),p(Ql,{label:"Zones",value:t})]})]}),E(j,{className:"border-subtler bg-fill-control-surface gap-2 rounded-lg border p-3",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Topology File"}),p("p",{className:"typo-compact-xs-normal text-fg-subtle",children:"Download the current topology data as topology.json."}),s&&p("p",{className:"typo-compact-xs-normal text-fg-warning",children:s})]})]}),p(Fo,{cancelLabel:c("move.amr.rightPanel.common.cancel"),saveLabel:c("move.amr.rightPanel.common.save"),onCancel:o,onSave:l,children:p(We,{variant:"soft",className:"h-9",disabled:i,leadingIcon:p(fy,{}),onClick:a,children:"Download topology"})})]})},{useMemo:Jl}=await wt("react"),jR=["NO_ENTRY","IGNORE_LIDAR_2D","IGNORE_LIDAR_3D"],XR=({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,onSaveTopologyChanges:v,onCancelTopologyChanges:g})=>{const{confirmDialog:b}=As({confirmComponent:Cs}),y=Jl(()=>{if(e.length===0)return[];const ne=new Set(e);return u.filter(ue=>ne.has(ue.id))},[e,u]),w=Jl(()=>r.editingZoneId?u.find(ne=>ne.id===r.editingZoneId)??null:t?y.find(ne=>ne.id===t)??null:y[0]??null,[r.editingZoneId,t,y,u]),_=Jl(()=>r.editingZoneId?u.find(ne=>ne.id===r.editingZoneId)??null:null,[r.editingZoneId,u]),R=e.length>1,T=Jl(()=>R?"multi-select":r.editingZoneId||y.length>0?"edit":"create",[r.editingZoneId,R,y.length]),P=_??w,M=r.state==="idle",x=r.state==="closed",S=r.editingZoneId!==null,C=r.state!=="idle",k=C,I=M&&w!==null,G=r.points.length>0&&!x,q=r.points.length>0&&!x,O=r.points.length>=3&&!x,W=x,Z=!C&&P===null,K=C?r.name:P?.name??"",oe=C?r.type:P?.type??"",te=S?"Update Zone":"Create Zone",ve=S?"Discard these edits and restore the original zone?":"Discard this zone draft and unsaved topology changes?",ce=I?"Create New Zone":"Start Drawing",Q=C,re=T==="create"&&M,J=T==="multi-select"?`${e.length} zones selected`:T==="edit"?r.editingZoneId?"Editing zone":"1 zone selected":"Create Zone";return E(j,{className:"h-full min-h-0",children:[E(j,{className:"min-h-0 flex-1 gap-3 overflow-y-auto p-3",children:[p(me,{className:"border-subtler gap-1.5 border-b pb-3",children:p(j,{className:"gap-0.5",children:p("p",{className:"compact-sm-semibold text-fg-default",children:J})})}),y.length>0&&!r.editingZoneId&&E(vi,{children:[E(j,{className:"gap-2",children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Selected Zones"}),p(j,{className:"border-border-subtle max-h-40 gap-1 overflow-y-auto rounded-md border p-1.5",children:y.map((ne,ue)=>{const Te=ne.id===w?.id;return E(me,{className:`items-center justify-between rounded-md border px-2 py-1.5 transition-colors ${Te?"border-border-default bg-fill-subtler":"border-transparent bg-fill-control-surface hover:border-border-subtle"}`,onClick:()=>{n(ne.id)},children:[p("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:`${ue+1}. ${ne.name||ne.id}`}),p("p",{className:"typo-compact-xs-normal text-fg-subtler shrink-0",children:`${ne.type} / ${ne.polygon.length} pts`})]},ne.id)})})]}),p(ji,{})]}),E(j,{className:on("gap-2",Z&&"opacity-50"),children:[p("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Details"}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Zone Name"}),k?p(un,{className:"w-full",size:"sm",placeholder:"Enter zone name",value:K,onChange:ne=>{h?.({name:ne.target.value})}}):p("div",{className:"border-border-subtle bg-fill-control-surface rounded-md border px-3 py-2",children:p("p",{className:"typo-compact-xs-normal text-fg-default",children:K||"-"})})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Zone Type"}),k?p("div",{className:"grid grid-cols-1 gap-2",children:jR.map(ne=>p(Ut,{className:"w-full",name:`topology-zone-type-${ne.toLowerCase()}`,checkValue:ne,value:oe,onChange:ue=>{ue.target.checked&&h?.({type:ne})},children:ne},ne))}):p("div",{className:"border-border-subtle bg-fill-control-surface rounded-md border px-3 py-2",children:p("p",{className:"typo-compact-xs-normal text-fg-default",children:oe||"-"})})]})]}),p(ji,{})]}),E(Fo,{cancelLabel:"Cancel",saveLabel:te,saveDisabled:!Q||!W,onCancel:async()=>{if(!C){g?.();return}await b({title:"Cancel",content:ve,buttonText:{yes:"Discard",no:"Keep Editing"}})&&(s?.(),g?.())},onSave:()=>{d?.(),v?.()},children:[re&&p(We,{variant:"soft",className:"text-fg-default py-2",onClick:()=>{i?.({name:r.name,type:r.type})},children:ce}),M&&I&&E(vi,{children:[p(We,{variant:"soft",className:"text-fg-default py-2",onClick:()=>{f?.(w.id)},children:"Edit Zone"}),p(We,{variant:"dangerSoft",className:"py-2",onClick:async()=>{await b({title:"Delete Zone",content:"Delete this selected zone?",buttonText:{yes:"Delete",no:"Keep"}})&&m?.(w.id)},children:"Delete Zone"})]}),Q&&x&&p(We,{variant:"soft",className:"text-fg-default py-2",onClick:c,children:S?"Reopen Zone":"Reopen"}),Q&&E(vi,{children:[E("div",{className:"grid grid-cols-2 gap-2",children:[p(We,{variant:"outlined",disabled:!G,onClick:o,children:"Undo Last Point"}),p(We,{variant:"outlined",disabled:!q,onClick:a,children:"Clear Points"})]}),p(We,{variant:"dangerSoft",disabled:!O,onClick:l,children:"Close Zone"})]})]})]})},{memo:qR,useCallback:gh,useEffect:ZR,useState:YR}=await wt("react"),bh="topology_tab",vh=r=>r==="overview"||r==="node"||r==="link"||r==="zone",KR=[{label:"Overview",value:"overview"},{label:"Node",value:"node"},{label:"Link",value:"link"},{label:"Zone",value:"zone"}],$R=({className:r,overviewTabProps:e,nodeTabProps:t,linkTabProps:n,zoneTabProps:i})=>{const{theme:s}=Ar(),{t:a}=en(),{confirmDialog:o}=As({confirmComponent:Cs}),[l,c]=Fy(),[d,h]=YR(()=>{const g=l.get(bh)??"";return vh(g)?g:"overview"}),u=i?.draft?.state==="drawing"||i?.draft?.state==="closed",f=gh(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=gh(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]),v=gh(async g=>{if(d===g||d==="zone"&&g!=="zone"&&u&&!await f())return;h(g);const b=new URLSearchParams(l);b.set(bh,g),c(b,{replace:!0})},[f,u,l,c,d]);return ZR(()=>{const g=l.get(bh)??"",b=vh(g)?g:"overview";h(y=>y!==b?b:y)},[l]),p("div",{className:on("TopologyControl","h-full",r),children:p("div",{className:"flex h-full min-h-0 gap-0",children:E("div",{className:"flex h-full min-h-0 flex-1 flex-col overflow-x-hidden",children:[p("div",{className:on("sticky top-0 left-0 z-2",s==="light"?"bg-default":"bg-alt-1"),children:p(py,{tabItems:KR.map(g=>({key:g.value,label:a(g.label)})),activeKey:d,handleChange:async g=>{vh(g)&&await v(g)},size:"xs",tabBtnClassName:"typo-compact-xs-bold light:bg-white light:[&.active]:bg-fill-navy! light:[&.active]:text-white!"})}),E(j,{className:"min-h-0 flex-1 overflow-y-auto",children:[d==="overview"&&p(WR,{...e,nodeCount:t?.nodes?.length??0,linkCount:n?.links?.length??0,zoneCount:i?.zones?.length??0,onCancelTopologyChanges:m,onSaveTopologyChanges:t?.onSaveTopologyChanges}),d==="node"&&p(GR,{...t}),d==="link"&&p(LR,{...n}),d==="zone"&&p(XR,{...i})]})]})})})},$N=qR($R),QR=await wt("react"),JR={APRILTAG:"AprilTag",ARUCO:"ArUco"},eN={x:"text-fg-danger",y:"text-fg-success",z:"text-fg-brand",rx:"text-fg-danger",ry:"text-fg-success",rz:"text-fg-brand"},ra=({label:r,value:e})=>E(me,{className:"items-baseline gap-1",children:[p("span",{className:`typo-compact-xs-semibold ${eN[r]??"text-fg-subtler"}`,children:r}),p("span",{className:"typo-compact-xs-normal text-fg-default font-mono",children:e})]}),tN=({detection:r,isSelected:e,onSelect:t})=>{const n=JR[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 p("button",{type:"button",onClick:()=>t(String(r.markerId)),className:on("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:E(j,{className:"gap-1 px-3 py-2.5",children:[E(me,{className:"items-center justify-between",children:[E(me,{className:"items-center gap-2",children:[E("span",{className:["typo-compact-lg-semibold",e?"text-fg-brand":"text-fg-default"].join(" "),children:["#",r.markerId]}),p("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&&E("span",{className:["typo-compact-sm-semibold",s?"text-fg-success":"text-fg-caution"].join(" "),children:[i,"%"]})]}),p(me,{className:"items-center gap-1.5",children:a.map((o,l)=>E(QR.Fragment,{children:[l>0&&p("span",{className:"text-fg-subtler",children:"·"}),p("span",{className:"typo-compact-xs-normal text-fg-subtle",children:o})]},o))}),r.pose?E(j,{className:"gap-0.5",children:[E(me,{className:"items-center gap-3",children:[p(ra,{label:"x",value:r.pose.x.toFixed(3)}),p(ra,{label:"y",value:r.pose.y.toFixed(3)}),r.pose.z!=null&&p(ra,{label:"z",value:r.pose.z.toFixed(3)})]}),E(me,{className:"items-center gap-3",children:[r.pose.rx!=null&&p(ra,{label:"rx",value:`${r.pose.rx.toFixed(1)}°`}),r.pose.ry!=null&&p(ra,{label:"ry",value:`${r.pose.ry.toFixed(1)}°`}),p(ra,{label:"rz",value:`${r.pose.rz.toFixed(1)}°`})]})]}):p(_r,{type:"icon",icon:p(ya,{}),message:"No pose data",className:"py-1"})]})})},{useEffect:nN,useMemo:iN,useState:ao}=await wt("react"),sN=[{label:"0.04m",value:"0.04"},{label:"0.1m",value:"0.10"},{label:"0.15m",value:"0.15"}],rN=(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,aN=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||rN(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)}))},QN=({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}=en(),[h,u]=ao(""),f=iN(()=>aN(t),[t]);nN(()=>{s!=null&&u("")},[s]);const[m,v]=ao("WALL"),[g,b]=ao("0.10"),[y,w]=ao(null),[_,R]=ao(""),T=f.find(G=>String(G.markerId)===h)??null,P=G=>{u(G)},M=()=>{T&&n?.({camId:T.camId,markerId:T.markerId,type:T.type,mount:m,markerSizeM:Number(g)})},x=()=>{!y||!_||(c?.({markerNodeId:y.nodeId,markerId:y.markerId,nodeName:_}),R(""))},S=f.length>0,C=f.map(G=>G.distM).filter(G=>Number.isFinite(G)).sort((G,q)=>G-q)[0],k=C!=null?`${C.toFixed(2)}m`:"-",I=p(j,{className:"border-subtler gap-2 border-b p-3",children:E(j,{className:"bg-fill-disabled gap-1 rounded-md p-3",children:[E(me,{className:"items-center justify-between gap-3",children:[E(me,{className:"items-center gap-1",children:[p(ya,{className:"text-fg-subtle size-4"}),p("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:d("move.amr.rightPanel.marker.markerStatus")})]}),E(me,{className:"items-center gap-1.5",children:[p(gi,{color:S?"green":"gray"}),p("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")})]})]}),E(me,{className:"items-center justify-between gap-3",children:[E(me,{className:"items-center gap-1",children:[p(Nu,{className:"text-fg-subtle size-4"}),p("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:d("move.title.distance")})]}),p("p",{className:"typo-compact-sm-semibold text-fg-default",children:k})]})]})});return r==="register"?E(j,{className:"h-full gap-0",children:[I,E(j,{className:"flex-1 gap-0 overflow-y-auto",children:[f.length===0?p("div",{className:"p-3 pb-0",children:p(_r,{type:"icon",icon:p(Cf,{}),message:d("move.amr.rightPanel.marker.notFound"),className:"bg-fill-disabled rounded-md"})}):p(j,{className:"gap-2 p-3 pb-0",children:f.map(G=>p(tN,{detection:G,isSelected:h===String(G.markerId),onSelect:P},G.markerId))}),E(j,{className:"gap-3 p-3",children:[E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.markerId")}),p("div",{className:"bg-fill-disabled border-border-subtler flex h-8 items-center rounded-md border px-3",children:p("p",{className:`typo-compact-sm-normal ${T?"text-fg-default":"text-fg-subtler"}`,children:T?`#${T.markerId}`:"—"})})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.markerType")}),p("div",{className:"bg-fill-disabled border-border-subtler flex h-8 items-center rounded-md border px-3",children:p("p",{className:`typo-compact-sm-normal ${T?"text-fg-default":"text-fg-subtler"}`,children:T?T.type==="ARUCO"?"ArUco":"AprilTag":"—"})})]}),E(j,{className:"gap-2",children:[E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.markerSize")}),p(me,{className:"items-center",children:p(cn,{className:"flex-1",size:"sm",value:g,step:.05,digit:2,fixedDigit:2,min:"0.01",max:"1.00",handleChange:G=>b(G)})})]}),p(me,{className:"gap-2",children:sN.map(G=>p(Ut,{className:"flex-1",value:g,checkValue:G.value,unCheckValue:G.value,handleChange:q=>b(q),size:"sm",children:G.label},G.value))})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.mount")}),E(me,{className:"gap-2",children:[p(Ut,{className:"w-full",value:m,checkValue:"WALL",unCheckValue:"WALL",handleChange:G=>v(G),size:"sm",children:d("move.amr.rightPanel.marker.mount.wall")}),p(Ut,{className:"w-full",value:m,checkValue:"FLOOR",unCheckValue:"FLOOR",handleChange:G=>v(G),size:"sm",children:d("move.amr.rightPanel.marker.mount.floor")})]})]})]})]}),p("div",{className:"p-3",children:p(We,{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")})})]}):E(j,{className:"h-full gap-0",children:[I,E(j,{className:"flex-1 gap-3 overflow-y-auto p-3",children:[E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.targetMarker")}),p(dc,{size:"sm",value:y?String(y.markerId):"",handleChange:G=>{const q=a.find(O=>String(O.markerId)===G);w(q??null)},disabled:a.length===0,children:a.length===0?p(es,{value:"",children:d("move.amr.rightPanel.marker.noRegisteredMarkers")}):a.map(G=>E(es,{value:String(G.markerId),children:["id ",G.markerId," · ",G.type," · ",G.mount]},G.markerId))})]}),y?.precisionTarget&&(()=>{const G=y.precisionTarget,q=G.context.match(/dock_offset=([^;]+)/)?.[1]?.split(",")??[];return p(j,{className:"gap-2",children:p("div",{className:"bg-fill-disabled rounded-md px-3 py-2.5",children:E(j,{className:"gap-2",children:[G.nodeName&&p("p",{className:"typo-compact-sm-semibold text-fg-default",children:G.nodeName}),q.length>0&&E(j,{className:"gap-0.5",children:[p("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:d("move.amr.rightPanel.marker.dockOffset")}),p("div",{className:"grid grid-cols-3 gap-x-2 gap-y-0.5",children:["x","y","z","rx","ry","rz"].map((O,W)=>E(me,{className:"items-baseline gap-1",children:[p("span",{className:"typo-compact-xs-semibold text-fg-subtle w-4",children:O}),p("span",{className:"typo-compact-xs-normal text-fg-default truncate font-mono",children:q[W]?Number(q[W]).toFixed(3):"—"})]},O))})]})]})})})})(),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.capturedPose")}),o?p("div",{className:"bg-fill-disabled rounded-md px-3 py-2.5",children:p(me,{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:G,value:q,color:O})=>E(me,{className:"items-baseline gap-1",children:[p("span",{className:`typo-compact-xs-semibold ${O}`,children:G}),p("span",{className:"typo-compact-xs-normal text-fg-default font-mono",children:q})]},G))})}):p("div",{className:"bg-fill-disabled rounded-md px-3 py-2",children:p(_r,{type:"icon",icon:p(Cf,{}),message:d("move.amr.rightPanel.marker.moveRobotThenCapture"),className:"py-1"})}),p(We,{size:"xs2",variant:"soft",leadingIcon:p(ya,{}),onClick:l,disabled:!y,children:d("move.amr.rightPanel.marker.captureCurrentPose")})]}),E(j,{className:"gap-1",children:[p("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.targetName")}),p(un,{className:"w-full",size:"sm",placeholder:d("move.amr.rightPanel.marker.targetNamePlaceholder"),value:_,onChange:G=>R(G.target.value)})]})]}),p("div",{className:"p-3",children:p(We,{variant:"brand",className:"h-9 w-full",onClick:x,disabled:!y||!_||!o,children:d("move.amr.rightPanel.marker.saveTarget")})})]})},{useEffect:oN}=await wt("react"),lN={KeyV:"select",KeyT:"target",KeyG:"move",KeyR:"rotate",KeyS:"scale"},Lg=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']")},JN=({enabled:r=!0,tools:e,topology:t,selection:n,camera:i})=>{const{enabled:s=!0,selectedTool:a,onToolChange:o,hasSelectedNode:l=!0}=e,c=t?.enabled??!0,d=!!t,h=t?.selectedNodePlacementType,u=t?.onAddNodeAtRobot,f=t?.onAddNodeAtCursor,m=n?.enabled??!0,v=!!n,g=n?.hasSelectedNodes??!1,b=n?.hasSelectedLinks??!1,y=n?.hasSelectedZones??!1,w=n?.onDeleteSelectedNodes,_=n?.onDeleteSelectedLinks,R=n?.onDeleteSelectedZones,T=i?.enabled??!0,P=!!i,M=i?.hasSelectedNode??!1,x=i?.onFocusSelectedNode;oN(()=>{if(!r)return;const S=(q,O)=>{s&&(a==="disabled"&&O!=="select"&&O!=="target"||Cv.has(O)&&!l||a!==O&&(q.preventDefault(),o(O)))},C=q=>{if(!(!d||!c)){if(h==="robot"){q.preventDefault(),u?.();return}a==="target"&&(q.preventDefault(),f?.())}},k=q=>{if(!(!v||!m)){if(g){q.preventDefault(),w?.();return}if(b){q.preventDefault(),_?.();return}y&&(q.preventDefault(),R?.())}},I=q=>{!P||!T||!M||(q.preventDefault(),x?.())},G=q=>{if(!(Lg(q.target)||Lg(document.activeElement))&&!q.repeat&&!(q.metaKey||q.ctrlKey||q.altKey||q.shiftKey))switch(q.code){case"KeyN":C(q);return;case"Delete":case"Backspace":k(q);return;case"KeyF":I(q);return;case"KeyV":case"KeyT":case"KeyG":case"KeyR":case"KeyS":{const O=lN[q.code];if(!O)return;S(q,O);return}default:return}};return window.addEventListener("keydown",G),()=>{window.removeEventListener("keydown",G)}},[r,T,P,M,v,b,l,g,y,d,f,u,_,w,R,x,o,h,a,m,s,c])},{useEffect:Ig,useRef:kg,useState:cN}=await wt("react"),Og=.5,dN=520;function e2({anchorObject:r,anchorWorldPosition:e,worldStudioRef:t,viewportHostRef:n,horizontalPlacementBoundary:i=dN}){const[s,a]=cN(null),o=kg(null),l=kg(null);return Ig(()=>{const c=()=>{const m=n.current,v=t.current?.getCanvas();o.current=m?.getBoundingClientRect()??null,l.current=v?.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]),Ig(()=>{if(!r&&!e){a(null);return}let c=0;const d=new L,h=new L,u=()=>{const f=t.current?.getCanvas(),m=t.current?.getCamera(),v=n.current;if(!f||!m||!v){a(P=>P===null?P:null),c=requestAnimationFrame(u);return}if(m.updateMatrixWorld(),r)r.updateMatrixWorld(),r.getWorldPosition(h);else if(e)h.copy(e);else{a(P=>P===null?P:null),c=requestAnimationFrame(u);return}d.copy(h).project(m);const g=o.current,b=l.current;if(!g||!b){a(P=>P===null?P:null),c=requestAnimationFrame(u);return}const y=(d.x+1)/2*b.width,w=(-d.y+1)/2*b.height,_=y+b.left-g.left,R=w+b.top-g.top,T=Number.isFinite(_)&&Number.isFinite(R)&&d.z>=-1&&d.z<=1&&_>=0&&_<=g.width&&R>=0&&R<=g.height;a(P=>{if(!T)return P===null?P:null;const M={x:_,y:R,placement:_>g.width-i?"left":"right"};return P&&Math.abs(P.x-M.x)<Og&&Math.abs(P.y-M.y)<Og&&P.placement===M.placement?P:M}),c=requestAnimationFrame(u)};return u(),()=>{cancelAnimationFrame(c)}},[r,e,i,n,t]),s}const{useMemo:yh,useState:Gs}=await wt("react"),t2=()=>{const{t:r}=en(),[e,t]=Gs(!0),[n,i]=Gs(!1),[s,a]=Gs(!1),[o,l]=Gs(!1),[c,d]=Gs(!1),[h,u]=Gs(!0),[f,m]=Gs(.15),[v,g]=Gs("topView"),b=yh(()=>[{label:r("move.amr.viewportControls.visibility.lidarPoints"),description:r("move.amr.viewportControls.visibility.lidarPointsDescription"),checked:h,onCheckedChange:u},{label:r("move.amr.viewportControls.visibility.simpleNodes"),description:r("move.amr.viewportControls.visibility.simpleNodesDescription"),checked:c,onCheckedChange:d},{label:r("move.amr.viewportControls.visibility.nodeLabels"),description:r("move.amr.viewportControls.visibility.nodeLabelsDescription"),checked:o,onCheckedChange:l},{label:r("move.amr.viewportControls.visibility.grid"),description:r("move.amr.viewportControls.visibility.gridDescription"),checked:e,onCheckedChange:t}],[e,h,o,c,r]),y=yh(()=>({label:r("move.amr.viewportControls.camera.projection"),description:r("move.amr.viewportControls.camera.projectionDescription"),value:v,items:[{label:r("move.amr.viewportControls.camera.topView"),value:"topView",description:r("move.amr.viewportControls.camera.topViewDescription")},{label:r("move.amr.viewportControls.camera.perspective"),value:"perspective",description:r("move.amr.viewportControls.camera.perspectiveDescription")}],onChange:_=>{g(_)}}),[r,v]),w=yh(()=>[{label:r("move.amr.viewportControls.rendering.lidarPointSize"),description:r("move.amr.viewportControls.rendering.lidarPointSizeDescription"),value:f,min:.01,max:.3,step:.01,digit:2,onChange:m}],[f,r]);return{showGrid:e,setShowGrid:t,showJoysticks:n,setShowJoysticks:i,showViewControls:s,setShowViewControls:a,showNodeLabels:o,setShowNodeLabels:l,showSimpleNodes:c,setShowSimpleNodes:d,showLidar:h,setShowLidar:u,lidarPointSize:f,setLidarPointSize:m,viewportCameraMode:v,visibilityItems:b,cameraModeControl:y,renderingSettingItems:w}},{useMemo:hN}=await wt("react"),n2=({loading:r,isDefaultData:e,mapCloud:t,topology:n,nodes:i,links:s})=>hN(()=>{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:xh}=await wt("react"),i2=()=>{const r=xh((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=xh((n,i)=>{const s=JSON.stringify(i,null,2)??"";r(n,s,{mimeType:"application/json"})},[r]),t=xh((n,i)=>{const s=i.map(a=>a.map(o=>o??"").join(",")).join(`
|
|
4748
|
+
`);r(n,s,{mimeType:"text/csv;charset=utf-8;"})},[r]);return{downloadFile:r,downloadJsonFile:e,downloadCsvFile:t}};export{E_ as $,Uf as A,ci as B,Le as C,sn as D,dn as E,RA as F,Vt as G,Cp as H,LA as I,gn as J,Qs as K,go as L,Ri as M,_N as N,Pt as O,Vs as P,Dt as Q,gi as R,wn as S,fT as T,cf as U,L as V,cT as W,PA as X,pA as Y,OA as Z,IA as _,yN as a,MN as a$,bi as a0,vr as a1,Ra as a2,xi as a3,Da as a4,Wn as a5,SN as a6,ux as a7,wN as a8,FA as a9,NN as aA,e2 as aB,i2 as aC,RN as aD,t2 as aE,JN as aF,n2 as aG,CN as aH,AN as aI,PN as aJ,UN as aK,BN as aL,IN as aM,LN as aN,$N as aO,ON as aP,FN as aQ,kN as aR,bN as aS,vy as aT,Iy as aU,WN as aV,KA as aW,Ca as aX,mP as aY,bP as aZ,VN as a_,di as aa,$s as ab,gt as ac,Fe as ad,yi as ae,aa as af,Pr as ag,lo as ah,Pn as ai,Kt as aj,Dc as ak,ev as al,Rr as am,tv as an,On as ao,Fb as ap,Bd as aq,No as ar,Fy as as,gN as at,BA as au,TN as av,sP as aw,EN as ax,cR as ay,gP as az,jt as b,jC as b0,JA as b1,jN as b2,e1 as b3,QN as b4,ps as b5,Q1 as b6,zN as b7,iC as b8,HN as b9,DN as ba,dC as bb,uC as bc,GN as bd,Fo as be,qN as bf,ZN as bg,YN as bh,LR as bi,IR as bj,FR as bk,GR as bl,XN as bm,WR as bn,KN as bo,XR as bp,wC as bq,WC as br,xN as c,vn as d,Ae as e,bt as f,Pc as g,of as h,ge as i,mt as j,xt as k,vN as l,Yn as m,Nb as n,ke as o,Zs as p,Ao as q,ba as r,Lc as s,av as t,ln as u,kA as v,cu as w,Ic as x,NA as y,Wy as z};
|