@shmulikdav/solix 1.3.0 → 1.4.1

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.
@@ -53,7 +53,7 @@ Error generating stack: `+s.message+`
53
53
  *
54
54
  * This source code is licensed under the MIT license found in the
55
55
  * LICENSE file in the root directory of this source tree.
56
- */var Ad=Ie,aE=oE;function lE(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var cE=typeof Object.is=="function"?Object.is:lE,uE=aE.useSyncExternalStore,dE=Ad.useRef,hE=Ad.useEffect,fE=Ad.useMemo,pE=Ad.useDebugValue;K_.useSyncExternalStoreWithSelector=function(n,e,t,i,r){var s=dE(null);if(s.current===null){var o={hasValue:!1,value:null};s.current=o}else o=s.current;s=fE(function(){function l(p){if(!c){if(c=!0,u=p,p=i(p),r!==void 0&&o.hasValue){var m=o.value;if(r(m,p))return d=m}return d=p}if(m=d,cE(u,p))return m;var y=i(p);return r!==void 0&&r(m,y)?(u=p,m):(u=p,d=y)}var c=!1,u,d,h=t===void 0?null:t;return[function(){return l(e())},h===null?void 0:function(){return l(h())}]},[e,t,i,r]);var a=uE(n,s[0],s[1]);return hE(function(){o.hasValue=!0,o.value=a},[a]),pE(a),a};Z_.exports=K_;var mE=Z_.exports;const gE=kv(mE),eS={},{useDebugValue:xE}=Uw,{useSyncExternalStoreWithSelector:vE}=gE;let jx=!1;const yE=n=>n;function _E(n,e=yE,t){(eS?"production":void 0)!=="production"&&t&&!jx&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),jx=!0);const i=vE(n.subscribe,n.getState,n.getServerState||n.getInitialState,e,t);return xE(i),i}const Xx=n=>{(eS?"production":void 0)!=="production"&&typeof n!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e=typeof n=="function"?Zb(n):n,t=(i,r)=>_E(e,i,r);return Object.assign(t,e),t},SE=n=>n?Xx(n):Xx,ME="solix.notifications.v1";function wE(){try{return localStorage.getItem(ME)==="off"?"off":"on"}catch{return"on"}}let Yx=!1;async function bE(){if(typeof Notification>"u")return"denied";if(Notification.permission!=="default"||Yx)return Notification.permission;Yx=!0;try{return await Notification.requestPermission()}catch{return"denied"}}async function EE(n){if(!(wE()==="off"||typeof Notification>"u"||typeof document<"u"&&!document.hidden||await bE()!=="granted"))try{new Notification(n.title,{body:n.body,tag:n.tag})}catch{}}const TE="solix.sound.v1";let Vh=null;function AE(){try{if(localStorage.getItem(TE)!=="on"||typeof window>"u")return;if(!Vh){const r=window.AudioContext||window.webkitAudioContext;if(!r)return;Vh=new r}const n=Vh,e=n.createOscillator(),t=n.createGain();e.connect(t),t.connect(n.destination),e.type="sine",e.frequency.value=880,t.gain.value=1e-4;const i=n.currentTime;t.gain.exponentialRampToValueAtTime(.06,i+.01),t.gain.exponentialRampToValueAtTime(1e-4,i+.35),e.start(i),e.stop(i+.4)}catch{}}function $x(n,e,t,i){const r={},s={},a=[];for(const l of n){if(l.ts>e)break;switch(l.type){case"session_started":{const c=t[l.sessionId];if(!c)continue;r[l.sessionId]={...c,status:"idle"};break}case"session_terminated":{delete r[l.sessionId];break}case"mission_started":{if(!l.missionId)continue;const c=i[l.missionId],u=r[l.sessionId];u&&(r[l.sessionId]={...u,status:"active",currentMissionId:l.missionId}),c&&(s[l.missionId]={...c,status:"active"});break}case"mission_completed":{if(!l.missionId)continue;const c=r[l.sessionId],u=i[l.missionId];c&&c.currentMissionId===l.missionId&&(r[l.sessionId]={...c,status:"idle",currentMissionId:void 0,lastCompletedMissionId:l.missionId}),u&&(s[l.missionId]={...u,status:"completed"});break}case"tool_call":{e-l.ts<=2e3&&a.push({id:`tc-${l.ts}-${l.sessionId}`,sessionId:l.sessionId,tool:l.toolName??"tool",args:{},startedAt:l.ts,status:"ok",receivedAt:l.ts});break}}}return{derivedSessions:r,derivedMissions:s,derivedToolCalls:a}}const qx={active:!1,loading:!1,events:[],earliestMs:0,latestMs:0,currentMs:0,playing:!1,speed:4,derivedSessions:{},derivedMissions:{},derivedToolCalls:[]},Zx=2e3,tS="solix.motion.v1",nS="solix.viewMode.v1";function CE(){try{return localStorage.getItem(tS)==="1"}catch{return!1}}function Kx(n){try{localStorage.setItem(tS,n?"1":"0")}catch{}}function RE(){try{const n=localStorage.getItem(nS);return n==="list"||n==="missions"||n==="galaxy"?n:"galaxy"}catch{return"galaxy"}}function Jx(n){try{localStorage.setItem(nS,n)}catch{}}const Ee=SE((n,e)=>({connected:!1,projects:{},sessions:{},missions:{},advisors:{},skills:{},chatBySessionId:{},recentToolCalls:[],pendingPermissions:{},selectedSessionId:null,selectedAdvisorId:null,selectedSkillId:null,motionEnabled:CE(),viewMode:RE(),playback:qx,toasts:[],setConnected:t=>n({connected:t}),applyMessage:t=>{switch(t.type){case"snapshot":{const i={};for(const l of t.projects)i[l.id]=l;const r={};for(const l of t.sessions)r[l.id]=l;const s={};for(const l of t.missions)s[l.id]=l;const o={};for(const l of t.advisors)o[l.id]=l;const a={};for(const l of t.skills)a[l.id]=l;n({projects:i,sessions:r,missions:s,advisors:o,skills:a});break}case"advisor_upsert":{n(i=>({advisors:{...i.advisors,[t.advisor.id]:t.advisor}}));break}case"skill_upsert":{n(i=>({skills:{...i.skills,[t.skill.id]:t.skill}}));break}case"galaxy_imported":{const i=`${Date.now()}-galaxy`;n(r=>({toasts:[...r.toasts,{id:i,level:"info",message:`Imported galaxy: ${t.manifest.name}`}].slice(-6)})),setTimeout(()=>e().dismissToast(i),5e3);break}case"session_upsert":{n(i=>({sessions:{...i.sessions,[t.session.id]:t.session}}));break}case"session_remove":{n(i=>{const r={...i.sessions};return delete r[t.sessionId],{sessions:r}});break}case"mission_upsert":{n(i=>({missions:{...i.missions,[t.mission.id]:t.mission}}));break}case"tool_call":{const i={...t.toolCall,receivedAt:Date.now()};n(r=>({recentToolCalls:[...r.recentToolCalls,i].slice(-200)})),setTimeout(()=>{n(r=>({recentToolCalls:r.recentToolCalls.filter(s=>Date.now()-s.receivedAt<Zx)}))},Zx+50);break}case"permission_request":{const i={requestId:t.requestId,sessionId:t.sessionId,tool:t.tool,args:t.args,receivedAt:Date.now()};n(a=>({pendingPermissions:{...a.pendingPermissions,[t.requestId]:i}}));const r=e().sessions[t.sessionId],s=(r==null?void 0:r.name)??t.sessionId.slice(0,8),o=(()=>{const a=Object.keys(t.args)[0];if(!a)return"";const l=t.args[a],c=typeof l=="string"?l:JSON.stringify(l);return`: ${c.length>60?c.slice(0,60)+"…":c}`})();EE({title:`${s} needs you`,body:`${t.tool}${o}`,tag:`solix-perm-${t.sessionId}`,whenHidden:!0}),AE();break}case"context_update":{n(i=>{const r=i.sessions[t.sessionId];return r?{sessions:{...i.sessions,[t.sessionId]:{...r,contextUsagePct:t.usagePct}}}:i});break}case"chat_delta":{const i={...t.delta,receivedAt:Date.now()};n(r=>{const a=[...(r.chatBySessionId[t.sessionId]??[]).filter(l=>l.messageId!==i.messageId),i].slice(-200);return{chatBySessionId:{...r.chatBySessionId,[t.sessionId]:a}}});break}case"toast":{const i=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;n(r=>({toasts:[...r.toasts,{id:i,level:t.level,message:t.message}].slice(-6)})),setTimeout(()=>e().dismissToast(i),5e3);break}}},selectSession:t=>n({selectedSessionId:t,selectedAdvisorId:t?null:e().selectedAdvisorId,selectedSkillId:t?null:e().selectedSkillId}),selectAdvisor:t=>n({selectedAdvisorId:t,selectedSessionId:t?null:e().selectedSessionId,selectedSkillId:t?null:e().selectedSkillId}),selectSkill:t=>n({selectedSkillId:t,selectedSessionId:t?null:e().selectedSessionId,selectedAdvisorId:t?null:e().selectedAdvisorId}),dismissToast:t=>n(i=>({toasts:i.toasts.filter(r=>r.id!==t)})),resolvePermission:(t,i)=>{const r=e().send;r({type:"permission_response",requestId:t,approved:i}),n(s=>{const o={...s.pendingPermissions};return delete o[t],{pendingPermissions:o}})},invokeAdvisor:(t,i)=>{const r=e().send,s=e().selectedSessionId??void 0;r({type:"invoke_advisor",advisorId:t,targetSessionId:s,prompt:i})},pinAdvisor:t=>{e().send({type:"pin_advisor",advisorId:t})},unpinAdvisor:t=>{e().send({type:"unpin_advisor",advisorId:t})},sendPromptTo:(t,i)=>{if(!i.trim())return;e().send({type:"send_prompt",sessionId:t,text:i});const r={messageId:`pending-${Date.now()}`,role:"user",content:i,ts:Date.now(),done:!0,receivedAt:Date.now()};n(s=>({chatBySessionId:{...s.chatBySessionId,[t]:[...s.chatBySessionId[t]??[],r].slice(-200)}}))},launchTask:(t,i,r,s)=>{e().send({type:"launch_session",cwd:t,model:i,initialPrompt:r,worktreeBranch:s==null?void 0:s.worktreeBranch,worktreeBaseRef:s==null?void 0:s.worktreeBaseRef})},selectedSessionIds:new Set,toggleSessionSelection:t=>{n(i=>{const r=new Set(i.selectedSessionIds);return r.has(t)?r.delete(t):r.add(t),{selectedSessionIds:r}})},clearSessionSelection:()=>{n({selectedSessionIds:new Set})},terminateSessions:t=>{const i=e().send;for(const r of t)i({type:"terminate_session",sessionId:r});n({selectedSessionIds:new Set})},setMotionEnabled:t=>{Kx(t),n({motionEnabled:t})},toggleMotion:()=>{const t=!e().motionEnabled;Kx(t),n({motionEnabled:t})},setViewMode:t=>{Jx(t),n({viewMode:t})},toggleViewMode:()=>{const t=["galaxy","list","missions"],i=e().viewMode,r=t.indexOf(i),s=t[(r+1)%t.length]??"galaxy";Jx(s),n({viewMode:s})},enterPlayback:(t,i,r)=>{const s=i;n(o=>({playback:{...o.playback,active:!0,loading:!1,events:t,earliestMs:i,latestMs:r,currentMs:s,playing:!1,...$x(t,s,e().sessions,e().missions)}}))},exitPlayback:()=>n({playback:qx}),setPlaybackTime:t=>{n(i=>{const r=Math.max(i.playback.earliestMs,Math.min(t,i.playback.latestMs));return{playback:{...i.playback,currentMs:r,...$x(i.playback.events,r,e().sessions,e().missions)}}})},setPlaybackSpeed:t=>n(i=>({playback:{...i.playback,speed:t}})),setPlaybackPlaying:t=>n(i=>({playback:{...i.playback,playing:t}})),setPlaybackLoading:t=>n(i=>({playback:{...i.playback,loading:t}})),send:()=>{},attachSocket:t=>n({send:t})}));function Fm(n){return n.playback.active?n.playback.derivedSessions:n.sessions}function iS(n){return Object.values(Fm(n)).filter(e=>!e.parentSessionId&&e.kind!=="advisor")}function PE(n){return Object.values(Fm(n)).filter(e=>!e.parentSessionId&&e.kind==="advisor")}function z3(n,e){return Object.values(Fm(n)).filter(t=>t.parentSessionId===e)}function V3(n){return Object.values(n.advisors).filter(e=>e.enabled)}function H3(n){return Object.values(n.skills)}function IE(n){switch(n){case"opus":return"#a855f7";case"sonnet":return"#3b82f6";case"haiku":return"#06b6d4";case"default":return"#94a3b8";default:return"#94a3b8"}}function G3(n){switch(n){case"active":return{color:"#fde68a",intensity:.9};case"awaiting_permission":return{color:"#ef4444",intensity:1};case"awaiting_input":return{color:"#f59e0b",intensity:.7};case"plan_review":return{color:"#a78bfa",intensity:.5};case"error":return{color:"#dc2626",intensity:.6};case"spawning":return{color:"#ffffff",intensity:.4};case"idle":default:return{color:"#1e293b",intensity:.1}}}function rS(n){switch(n){case"active":return"Active";case"awaiting_permission":return"Permission";case"awaiting_input":return"Awaiting input";case"plan_review":return"Plan review";case"error":return"Error";case"spawning":return"Spawning";case"terminated":return"Terminated";case"idle":default:return"Idle"}}function NE(n,e,t){const i=[];let r=30;switch(n.status){case"error":r=0,i.push("In error state");break;case"plan_review":case"awaiting_input":r=15,i.push(`Status: ${n.status}`);break;case"awaiting_permission":r=12,i.push("Awaiting permission");break;case"terminated":r=5,i.push("Terminated");break;default:r=30}const s=Math.max(0,30-t*15);t>0&&i.push(`${t} pending permission${t===1?"":"s"}`);const a=25*Math.max(0,1-n.contextUsagePct/100);n.contextUsagePct>=90?i.push(`Context at ${n.contextUsagePct.toFixed(0)}%`):n.contextUsagePct>=80&&i.push(`Context warm (${n.contextUsagePct.toFixed(0)}%)`);let l=0;if(e&&e.status==="active"){const u=e.metrics.toolCallCount;l=Math.min(15,u*2)}else e&&e.status==="completed"&&(l=15);return{score:Math.round(Math.max(0,Math.min(100,r+s+a+l))),reasons:i}}function LE(n){return n>=75?"#10b981":n>=50?"#fbbf24":n>=25?"#f97316":"#ef4444"}const Bm={active:"The agent is currently working — emitting tool calls or generating output.",idle:"No mission running. The agent is waiting for the next prompt or has been quiet for a while.",spawning:"The agent process just started. It will transition to active within a second or two.",awaiting_permission:"The agent paused to ask permission for a sensitive tool call. Approve or deny in the Decision Queue.",awaiting_input:"The agent finished what it could and is waiting for your next prompt.",plan_review:"The agent produced a plan and is waiting for your approval before executing.",error:"The agent crashed or hit an unrecoverable error. Look at the SidePanel transcript for details.",terminated:"The agent process exited. No more activity will come from this session.",subagent:"A child agent spawned by another session (typically via the Task tool). Rendered as a moon orbiting the parent planet.",advisor:"A long-lived specialist agent (Compass, Forge, Lumen, Argus, Sentinel, …) with its own AGENT.md describing its role.",pinned:"An advisor that's always running. Pinned advisors orbit close to the sun in the inner ring."},Qx={awaiting_permission:0,awaiting_input:1,plan_review:2,error:3,active:4,spawning:5,idle:6,terminated:7};function DE(){const n=Ee(iS),e=Ee(PE),t=Ee(_=>_.projects),i=Ee(_=>_.missions),r=Ee(_=>_.pendingPermissions),s=Ee(_=>_.selectSession),o=Ee(_=>_.selectedSessionIds),a=Ee(_=>_.toggleSessionSelection),l=Ee(_=>_.clearSessionSelection),c=Ee(_=>_.terminateSessions),[u,d]=Ie.useState("needs"),[h,p]=Ie.useState("asc"),m=Ie.useMemo(()=>{const _=[...n,...e],R=new Set(Object.values(r).map(M=>M.sessionId));return _.map(M=>{const T=M.currentMissionId?i[M.currentMissionId]:void 0,A=Object.values(r).filter(L=>L.sessionId===M.id).length,{score:E,reasons:w}=NE(M,T,A);return{session:M,project:t[M.projectId],mission:T,needsAttention:R.has(M.id)||M.status==="awaiting_permission"||M.status==="awaiting_input"||M.status==="plan_review",health:E,healthReasons:w}})},[n,e,t,i,r]),y=Ie.useMemo(()=>{var R;const _=new Map;for(const M of m){const T=((R=M.project)==null?void 0:R.id)??"_",A=_.get(T);A?A.rows.push(M):_.set(T,{project:M.project,rows:[M]})}return[..._.values()].sort((M,T)=>{var A,E;return(((A=T.project)==null?void 0:A.lastActiveAt)??0)-(((E=M.project)==null?void 0:E.lastActiveAt)??0)})},[m]),g=(_,R)=>{var T,A;const M=h==="asc"?1:-1;switch(u){case"name":return((_.session.name??_.session.id)>(R.session.name??R.session.id)?1:-1)*M;case"status":return((Qx[_.session.status]??99)-(Qx[R.session.status]??99))*M;case"progress":return((((T=_.mission)==null?void 0:T.metrics.toolCallCount)??0)-(((A=R.mission)==null?void 0:A.metrics.toolCallCount)??0))*M;case"context":return(_.session.contextUsagePct-R.session.contextUsagePct)*M;case"lastActivity":return(_.session.updatedAt-R.session.updatedAt)*M;case"needs":return _.needsAttention===R.needsAttention?0:_.needsAttention?-1*M:1*M;case"health":return(_.health-R.health)*M}},f=_=>{u===_?p(h==="asc"?"desc":"asc"):(d(_),p(_==="lastActivity"?"desc":"asc"))},v=_=>u!==_?"":h==="asc"?" ▲":" ▼",x=o.size;return S.jsxs("div",{className:"absolute inset-0 overflow-y-auto bg-solix-bg pt-20 pb-20 px-6 z-0",children:[x>0&&S.jsx("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-30 pointer-events-auto",children:S.jsxs("div",{className:"rounded-full border border-solix-accent/60 bg-solix-panel/95 backdrop-blur shadow-2xl px-4 py-2 flex items-center gap-3",children:[S.jsxs("span",{className:"text-xs text-slate-200 font-mono",children:[x," selected"]}),S.jsx("button",{onClick:()=>c([...o]),className:"text-xs px-3 py-1 rounded border border-solix-danger text-solix-danger hover:bg-solix-danger/15",children:"Terminate"}),S.jsx("button",{onClick:l,className:"text-xs text-slate-400 hover:text-slate-200",children:"Clear"})]})}),S.jsxs("div",{className:"max-w-6xl mx-auto",children:[S.jsxs("div",{className:"text-xs text-slate-500 uppercase tracking-widest mb-3",children:["List view · ",m.length," agent",m.length===1?"":"s"]}),m.length===0?S.jsxs("div",{className:"text-sm text-slate-500 italic py-12 text-center border border-solix-border rounded",children:["No agents yet. Run ",S.jsx("code",{children:"claude"})," in any terminal — a row will appear here within a second."]}):y.map(({project:_,rows:R})=>{const M=[...R].sort(g),T=(_==null?void 0:_.name)??"(unassigned)";return S.jsxs("section",{className:"mb-8 rounded border border-solix-border overflow-hidden",children:[S.jsxs("header",{className:"bg-solix-panel/60 px-4 py-2 flex items-center justify-between",children:[S.jsxs("div",{children:[S.jsx("span",{className:"text-sm font-semibold text-slate-100",children:T}),S.jsxs("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-slate-500",children:[R.length," agent",R.length===1?"":"s"]})]}),(_==null?void 0:_.cwd)&&S.jsx("span",{className:"text-[10px] font-mono text-slate-500 truncate max-w-[55%]",children:_.cwd})]}),S.jsxs("table",{className:"w-full text-sm",children:[S.jsx("thead",{className:"bg-black/30 text-[10px] uppercase tracking-wide text-slate-500",children:S.jsxs("tr",{children:[S.jsx(Ri,{children:S.jsx("input",{type:"checkbox","aria-label":"Select all in project",checked:M.length>0&&M.every(A=>o.has(A.session.id)),onChange:A=>{A.stopPropagation();const E=M.every(w=>o.has(w.session.id));for(const w of M){const L=o.has(w.session.id);(E&&L||!E&&!L)&&a(w.session.id)}},className:"cursor-pointer"})}),S.jsxs(Ri,{onClick:()=>f("needs"),children:["● ",v("needs")]}),S.jsxs(Ri,{onClick:()=>f("name"),children:["Agent",v("name")]}),S.jsx(Ri,{children:"Advisor"}),S.jsxs(Ri,{onClick:()=>f("status"),children:["Status",v("status")]}),S.jsxs(Ri,{onClick:()=>f("health"),numeric:!0,children:["Health",v("health")]}),S.jsxs(Ri,{onClick:()=>f("progress"),children:["Mission · tools",v("progress")]}),S.jsxs(Ri,{onClick:()=>f("context"),numeric:!0,children:["Context",v("context")]}),S.jsxs(Ri,{onClick:()=>f("lastActivity"),numeric:!0,children:["Last activity",v("lastActivity")]})]})}),S.jsx("tbody",{children:M.map(A=>S.jsxs("tr",{onClick:()=>s(A.session.id),className:`border-t border-solix-border hover:bg-solix-border/20 cursor-pointer ${A.needsAttention?"bg-solix-danger/5":""} ${o.has(A.session.id)?"bg-solix-accent/5":""}`,children:[S.jsx("td",{className:"px-3 py-2",onClick:E=>E.stopPropagation(),children:S.jsx("input",{type:"checkbox","aria-label":"Select agent",checked:o.has(A.session.id),onChange:()=>a(A.session.id),className:"cursor-pointer"})}),S.jsx("td",{className:"px-3 py-2",children:A.needsAttention?S.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-solix-danger solix-pulse"}):A.session.status==="active"?S.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-solix-ok"}):S.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-slate-600"})}),S.jsx("td",{className:"px-3 py-2",children:S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{background:IE(A.session.model)},title:String(A.session.model)}),S.jsx("span",{className:"text-slate-100 font-medium",children:A.session.name??A.session.id.slice(0,8)}),A.session.kind==="advisor"&&S.jsx("span",{className:"text-[9px] uppercase tracking-wide text-amber-300",children:"advisor"}),A.session.wrapperSocketPath&&S.jsx("span",{className:"text-[9px] uppercase tracking-wide text-solix-accent",title:"Wrapped by `solix run` — UI composer is enabled",children:"wrapped"}),A.session.worktreePath&&S.jsxs("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded border border-solix-accent/40 text-solix-accent",title:A.session.worktreePath,children:["⌥",UE(A.session.worktreePath)]})]})}),S.jsx("td",{className:"px-3 py-2 text-xs",children:S.jsx(OE,{session:A.session,mission:A.mission})}),S.jsx("td",{className:"px-3 py-2 text-xs text-slate-300",title:Bm[A.session.status]??void 0,children:rS(A.session.status)}),S.jsx("td",{className:"px-3 py-2 text-right",children:S.jsx(FE,{score:A.health,reasons:A.healthReasons})}),S.jsx("td",{className:"px-3 py-2 text-xs text-slate-300 truncate max-w-xs",children:A.mission?S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"text-slate-100",children:A.mission.shortName}),S.jsxs("span",{className:"text-slate-500 ml-1",children:["· ",A.mission.metrics.toolCallCount," tools"]})]}):S.jsx("span",{className:"text-slate-500 italic",children:"idle"})}),S.jsx("td",{className:"px-3 py-2 text-right",children:S.jsx(BE,{pct:A.session.contextUsagePct})}),S.jsx("td",{className:"px-3 py-2 text-right text-[11px] text-slate-500 font-mono",children:zE(A.session.updatedAt)})]},A.session.id))})]})]},(_==null?void 0:_.id)??"_")})]})]})}function UE(n){const e=n.split("/").filter(Boolean);return e[e.length-1]??n}const kE=/^\[Acting as ([^\s—]+)/;function OE({session:n,mission:e}){var s;const t=Ee(o=>o.advisors);let i,r=!1;if(n.advisorRole)i=Object.values(t).find(o=>o.id===n.advisorRole);else if(e!=null&&e.prompt){const o=e.prompt.match(kE),a=(s=o==null?void 0:o[1])==null?void 0:s.toLowerCase();a&&(i=Object.values(t).find(l=>l.codename.toLowerCase()===a),r=!0)}return i?S.jsxs("span",{className:`inline-flex items-center gap-1 ${r?"opacity-60":""}`,title:i.description,children:[S.jsx("span",{style:{color:i.color},children:i.glyph}),S.jsx("span",{className:"text-slate-200",children:i.codename})]}):S.jsx("span",{className:"text-slate-700",children:"—"})}function Ri({children:n,onClick:e,numeric:t}){return S.jsx("th",{onClick:e,className:`px-3 py-2 select-none ${t?"text-right":"text-left"} ${e?"cursor-pointer hover:text-slate-300":""}`,children:n})}function FE({score:n,reasons:e}){const t=LE(n);return S.jsxs("div",{className:"relative inline-flex items-center gap-2 group",children:[S.jsx("span",{className:"text-[11px] font-mono font-bold",style:{color:t},children:n}),S.jsx("div",{className:"w-16 h-1.5 rounded-full bg-slate-800 overflow-hidden",children:S.jsx("div",{className:"h-full",style:{width:`${Math.max(2,n)}%`,background:t}})}),S.jsxs("div",{className:"pointer-events-none absolute right-0 top-full mt-1 z-50 hidden group-hover:block w-64 rounded border border-solix-border bg-solix-panel/95 backdrop-blur p-2 text-left shadow-xl",children:[S.jsxs("div",{className:"flex items-center justify-between mb-1",children:[S.jsx("span",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Health"}),S.jsxs("span",{className:"text-xs font-bold",style:{color:t},children:[n,"/100"]})]}),e.length===0?S.jsx("div",{className:"text-[11px] text-slate-400 italic",children:"All four bands healthy: stable status, no pending decisions, context budget, mission progress."}):S.jsx("ul",{className:"space-y-0.5",children:e.map(i=>S.jsxs("li",{className:"text-[11px] text-slate-200 leading-snug",children:["· ",i]},i))})]})]})}function BE({pct:n}){const e=n>=90?"bg-solix-danger":n>=80?"bg-solix-warn":"bg-solix-accent";return S.jsxs("div",{className:"inline-flex items-center gap-2",children:[S.jsxs("span",{className:"text-[11px] text-slate-400 font-mono",children:[n.toFixed(0),"%"]}),S.jsx("div",{className:"w-20 h-1.5 rounded-full bg-slate-800 overflow-hidden",children:S.jsx("div",{className:`h-full ${e}`,style:{width:`${Math.min(100,n)}%`}})})]})}function zE(n){const e=Date.now()-n;if(e<0)return"now";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const i=Math.floor(t/60);if(i<60)return`${i}m`;const r=Math.floor(i/60);return r<24?`${r}h`:new Date(n).toLocaleDateString()}function VE(){const n=Ee(l=>l.missions),e=Ee(l=>l.sessions),t=Ee(l=>l.projects),i=Ee(l=>l.selectSession),[r,s]=Ie.useState("all"),o=Ie.useMemo(()=>{const l=Object.values(n).sort((c,u)=>u.startedAt-c.startedAt);return r==="all"?l:l.filter(c=>c.status===r)},[n,r]),a=Ie.useMemo(()=>{const l=new Map;for(const c of o){const u=e[c.sessionId],d=u?t[u.projectId]:void 0,h=(d==null?void 0:d.id)??"_",p=l.get(h);p?p.missions.push(c):l.set(h,{project:d,missions:[c]})}return[...l.values()].sort((c,u)=>{var d,h;return(((d=u.missions[0])==null?void 0:d.startedAt)??0)-(((h=c.missions[0])==null?void 0:h.startedAt)??0)})},[o,e,t]);return S.jsx("div",{className:"absolute inset-0 overflow-y-auto bg-solix-bg pt-20 pb-8 px-6 z-0",children:S.jsxs("div",{className:"max-w-4xl mx-auto",children:[S.jsxs("div",{className:"flex items-center justify-between mb-3",children:[S.jsxs("div",{className:"text-xs text-slate-500 uppercase tracking-widest",children:["Missions · ",o.length]}),S.jsx("div",{className:"flex items-center gap-1.5",children:["all","active","completed","failed","cancelled"].map(l=>S.jsx("button",{onClick:()=>s(l),className:`text-[10px] px-2 py-0.5 rounded border ${r===l?"bg-solix-accent/15 border-solix-accent text-solix-accent":"border-solix-border text-slate-400 hover:text-slate-200"}`,children:l},l))})]}),o.length===0?S.jsx("div",{className:"text-sm text-slate-500 italic py-12 text-center border border-solix-border rounded",children:"No missions yet. Send a prompt to a Claude Code session and a mission card will appear here."}):a.map(({project:l,missions:c})=>{const u=(l==null?void 0:l.name)??"(unassigned)";return S.jsxs("section",{className:"mb-6 rounded border border-solix-border overflow-hidden",children:[S.jsxs("header",{className:"bg-solix-panel/60 px-4 py-2 flex items-center justify-between",children:[S.jsxs("div",{children:[S.jsx("span",{className:"text-sm font-semibold text-slate-100",children:u}),S.jsxs("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-slate-500",children:[c.length," mission",c.length===1?"":"s"]})]}),(l==null?void 0:l.cwd)&&S.jsx("span",{className:"text-[10px] font-mono text-slate-500 truncate max-w-[55%]",children:l.cwd})]}),S.jsx("ul",{className:"divide-y divide-solix-border",children:c.map(d=>{const h=e[d.sessionId];return S.jsx("li",{children:S.jsxs("button",{onClick:()=>i(d.sessionId),className:"w-full text-left p-4 hover:bg-solix-border/20 cursor-pointer block",children:[S.jsxs("div",{className:"flex items-start justify-between gap-3",children:[S.jsxs("div",{className:"min-w-0 flex-1",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-sm font-semibold text-slate-100",children:d.shortName}),S.jsx(HE,{status:d.status})]}),S.jsx("div",{className:"mt-1 text-xs text-slate-400 line-clamp-2",children:d.prompt}),d.longSummary&&S.jsx("div",{className:"mt-1 text-xs text-slate-300 italic",children:d.longSummary}),d.status==="failed"&&d.errorSummary&&S.jsxs("div",{className:"mt-1 text-xs text-solix-danger italic line-clamp-2",children:["error: ",d.errorSummary]})]}),S.jsxs("div",{className:"text-right text-[10px] text-slate-500 font-mono whitespace-nowrap",children:[WE(d.startedAt),d.metrics.durationMs!==void 0&&S.jsxs("div",{children:[(d.metrics.durationMs/1e3).toFixed(1),"s"]})]})]}),S.jsxs("div",{className:"mt-2 flex items-center gap-3 text-[10px] text-slate-500",children:[h&&S.jsxs("span",{children:["agent:"," ",S.jsx("span",{className:"text-slate-300",children:h.name??h.id.slice(0,8)})]}),S.jsxs("span",{children:[d.metrics.toolCallCount," tools"]}),S.jsxs("span",{title:Bm.subagent,children:[d.metrics.subagentCount," subagents"]}),S.jsxs("span",{children:[d.filesTouched.length," files"]})]}),d.filesTouched.length>0&&S.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[d.filesTouched.slice(0,6).map(p=>S.jsx("span",{className:"text-[10px] font-mono text-slate-400 bg-black/30 border border-solix-border rounded px-1.5 py-0.5",children:GE(p)},p)),d.filesTouched.length>6&&S.jsxs("span",{className:"text-[10px] text-slate-500",children:["+",d.filesTouched.length-6]})]})]})},d.id)})})]},(l==null?void 0:l.id)??"_")})]})})}function HE({status:n}){const e=n==="active"?"border-solix-warn text-solix-warn":n==="completed"?"border-solix-ok text-solix-ok":n==="failed"?"border-solix-danger text-solix-danger":"border-solix-border text-slate-400";return S.jsx("span",{className:`text-[9px] uppercase tracking-wide px-1.5 py-0.5 rounded border ${e}`,children:n})}function GE(n){const e=n.match(/[^/\\]+\/?$/);return e?e[0].replace(/\/$/,""):n}function WE(n){const e=Date.now()-n;if(e<0)return"now";const t=Math.floor(e/1e3);if(t<60)return`${t}s ago`;const i=Math.floor(t/60);if(i<60)return`${i}m ago`;const r=Math.floor(i/60);return r<24?`${r}h ago`:new Date(n).toLocaleDateString()}function jE({onOpenGalaxy:n,onNewTask:e,onOpenTimeline:t,onOpenHelp:i}={}){const r=Ee(u=>u.connected),s=Ee(iS),o=Ee(u=>u.viewMode),a=Ee(u=>u.playback.active),l=Ee(u=>u.exitPlayback),c=s.reduce((u,d)=>(d.status==="active"?u.active+=1:d.status==="awaiting_permission"||d.status==="awaiting_input"||d.status==="plan_review"?u.attention+=1:d.status==="idle"&&(u.idle+=1),u),{active:0,idle:0,attention:0});return S.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-start justify-between p-4 z-40",children:[S.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 sm:gap-3",children:[S.jsx("div",{className:"text-xl font-bold tracking-widest text-solix-accent",children:"SOLIX"}),S.jsx("div",{className:"hidden md:block text-xs text-slate-400",children:"a solar-system command center"}),S.jsx("div",{className:`ml-1 sm:ml-3 px-2 py-1 rounded text-[10px] border ${r?"border-solix-ok text-solix-ok":"border-solix-danger text-solix-danger solix-pulse"}`,children:r?"CONNECTED":"OFFLINE"}),a&&S.jsxs("button",{onClick:l,className:"ml-2 px-2 py-1 rounded text-[10px] border border-solix-accent text-solix-accent solix-pulse hover:bg-solix-accent/15 cursor-pointer flex items-center gap-1.5",title:"Exit Timeline Playback (Esc)","aria-label":"Exit playback",children:[S.jsx("span",{children:"▸ PLAYBACK"}),S.jsx("span",{className:"opacity-70",children:"· exit ✕"})]})]}),S.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 sm:gap-3 text-xs",children:[S.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[S.jsx(Hh,{label:"active",value:c.active,color:"text-solix-ok"}),S.jsx(Hh,{label:"attention",value:c.attention,color:"text-solix-warn"}),S.jsx(Hh,{label:"idle",value:c.idle,color:"text-slate-400"})]}),S.jsx(XE,{viewMode:o}),t&&S.jsx("button",{onClick:t,className:"hidden sm:inline-block px-2 py-1 rounded bg-solix-panel border border-solix-border text-slate-300 hover:text-white hover:bg-solix-border/30",title:"Timeline playback (T)",children:"⏱ Timeline"}),e&&S.jsx("button",{onClick:e,className:"px-2 py-1 rounded bg-solix-ok/15 border border-solix-ok/40 text-solix-ok hover:bg-solix-ok/25",title:"Launch a new Claude Code task (L)",children:"+ Task"}),n&&S.jsx("button",{onClick:n,className:"px-2 py-1 rounded bg-solix-accent/15 border border-solix-accent/40 text-solix-accent hover:bg-solix-accent/25",title:"Galaxy: export and import (G)",children:"⌬ Galaxy"}),i&&S.jsx("button",{onClick:i,className:"w-7 h-7 rounded-full bg-solix-panel border border-solix-border text-slate-300 hover:text-white hover:bg-solix-border/30 text-sm",title:"Help (?)","aria-label":"Help",children:"?"})]})]})}function XE({viewMode:n}){const e=Ee(i=>i.setViewMode),t=[{mode:"galaxy",label:"🪐"},{mode:"list",label:"☰"},{mode:"missions",label:"◎"}];return S.jsx("div",{className:"inline-flex rounded border border-solix-border bg-solix-panel overflow-hidden",children:t.map(i=>S.jsxs("button",{onClick:()=>e(i.mode),className:`px-2 py-1 text-xs ${n===i.mode?"bg-solix-border/50 text-white":"text-slate-400 hover:text-slate-100"}`,title:`${i.mode} view (V)`,children:[i.label," ",S.jsx("span",{className:"hidden sm:inline capitalize",children:i.mode})]},i.mode))})}function Hh({label:n,value:e,color:t}){return S.jsxs("div",{className:"px-2 py-1 rounded bg-solix-panel border border-solix-border",children:[S.jsx("span",{className:`font-bold ${t}`,children:e}),S.jsx("span",{className:"ml-1 opacity-60 uppercase tracking-wide",children:n})]})}function YE(){const n=Ee(t=>t.toasts),e=Ee(t=>t.dismissToast);return S.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 flex flex-col gap-2 z-30",children:n.map(t=>S.jsx("button",{onClick:()=>e(t.id),className:`pointer-events-auto px-3 py-2 rounded text-xs border max-w-md text-left ${t.level==="error"?"bg-solix-danger/10 border-solix-danger text-solix-danger":t.level==="warn"?"bg-solix-warn/10 border-solix-warn text-solix-warn":"bg-solix-panel border-solix-border text-slate-200"}`,children:t.message},t.id))})}const e0="solix.welcome.dismissed.v1";function $E({onOpenGalaxy:n,forceOpen:e=!1,onClose:t}){const[i,r]=Ie.useState(!1),s=Ee(u=>u.advisors),o=Ee(u=>Object.keys(u.skills).length),a=Ee(u=>Object.keys(u.sessions).length);if(Ie.useEffect(()=>{try{r(localStorage.getItem(e0)==="1")}catch{}},[]),!e&&(i||a>0))return null;const l=()=>{try{localStorage.setItem(e0,"1")}catch{}r(!0),t==null||t()},c=Object.values(s).filter(u=>u.enabled).sort((u,d)=>u.codename.localeCompare(d.codename));return S.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center pointer-events-none",children:S.jsxs("div",{className:"pointer-events-auto max-w-xl w-full mx-4 rounded-xl border border-solix-accent/40 bg-solix-panel/95 backdrop-blur-md shadow-2xl",children:[S.jsxs("div",{className:"px-6 pt-5 pb-3 border-b border-solix-border",children:[S.jsx("div",{className:"text-xs uppercase tracking-widest text-solix-accent",children:"welcome"}),S.jsx("div",{className:"text-2xl font-bold mt-1",children:"Solix — your agent solar system"}),S.jsx("div",{className:"text-sm text-slate-400 mt-1",children:"Mission control for Claude Code. Each agent orbits the sun; each click is a conversation with one of your planets."})]}),S.jsxs("div",{className:"px-6 py-4 space-y-3 text-sm text-slate-300",children:[S.jsx(ta,{n:1,title:"Run a Claude Code session",body:S.jsxs(S.Fragment,{children:["Open a terminal anywhere and run"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"claude"}),". A planet will appear here within a second."]})}),S.jsx(ta,{n:2,title:"Or seed the demo state",body:S.jsxs(S.Fragment,{children:["In another terminal:"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"solix demo"}),". You'll get 3 planets, a moon, a permission flare, and a pinned advisor — without running Claude Code."]})}),S.jsx(ta,{n:3,title:"Meet the advisor crew",body:S.jsxs(S.Fragment,{children:[c.length>0?`${c.length} crew members loaded. Click any in the inner ring to read their role and invoke them on the focused planet.`:"Crew loading…",c.length>0&&S.jsx("ul",{className:"mt-2 space-y-1",children:c.map(u=>S.jsxs("li",{className:"flex items-baseline gap-2",children:[S.jsxs("span",{className:"font-mono text-xs",style:{color:u.color},children:[u.glyph," ",u.codename]}),S.jsx("span",{className:"text-slate-500 text-xs",children:"—"}),S.jsx("span",{className:"text-slate-300 text-xs",children:u.name})]},u.id))})]})}),S.jsx(ta,{n:4,title:"Browse the asteroid belt",body:S.jsxs(S.Fragment,{children:["Each asteroid is a Skill (",o," discovered). Click one to read its SKILL.md and see which advisors require it."]})}),S.jsx(ta,{n:5,title:"Share your galaxy",body:S.jsxs(S.Fragment,{children:["Press"," ",S.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-black/50 border border-solix-border text-[10px]",children:"G"})," ","or click ",S.jsx("span",{className:"text-solix-accent",children:"⌬ Galaxy"})," ","in the top bar to export, import, publish, or install a galaxy from a registry."]})})]}),S.jsxs("div",{className:"px-6 pb-3 pt-1",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-widest text-slate-500 mb-1.5",children:"Keyboard shortcuts"}),S.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-[11px] text-slate-400",children:[S.jsx(pi,{k:"V",children:"cycle Galaxy → List → Missions"}),S.jsx(pi,{k:"G",children:"toggle Galaxy panel"}),S.jsx(pi,{k:"L",children:"new task"}),S.jsx(pi,{k:"T",children:"timeline"}),S.jsx(pi,{k:"M",children:"jump to Missions"}),S.jsx(pi,{k:"Y",children:"approve top decision"}),S.jsx(pi,{k:"N",children:"deny top decision"}),S.jsx(pi,{k:"Space",children:"play / pause orbits"}),S.jsx(pi,{k:"?",children:"re-open this help"}),S.jsx(pi,{k:"Esc",children:"close panels / exit playback"})]}),S.jsx("div",{className:"text-[10px] text-slate-500 italic mt-2",children:"If clicks feel stuck, a third-party screen overlay (note-taker, recorder) may be intercepting. Quit it temporarily, or use the shortcuts above."})]}),S.jsxs("div",{className:"px-6 py-3 border-t border-solix-border flex items-center gap-2",children:[S.jsx("button",{onClick:()=>{n(),l()},className:"px-3 py-1.5 rounded bg-solix-accent/15 border border-solix-accent/40 text-solix-accent text-xs hover:bg-solix-accent/25",children:"Open Galaxy panel"}),S.jsx("div",{className:"flex-1"}),S.jsx("button",{onClick:l,className:"px-3 py-1.5 rounded border border-solix-border text-xs text-slate-300 hover:text-white",children:"Got it"})]})]})})}function pi({k:n,children:e}){return S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("kbd",{className:"shrink-0 px-1.5 py-0.5 rounded bg-black/50 border border-solix-border text-[10px] font-mono text-slate-300",children:n}),S.jsx("span",{className:"truncate",children:e})]})}function ta({n,title:e,body:t}){return S.jsxs("div",{className:"flex gap-3",children:[S.jsx("div",{className:"shrink-0 w-6 h-6 rounded-full bg-solix-accent/20 border border-solix-accent/40 text-solix-accent text-xs flex items-center justify-center",children:n}),S.jsxs("div",{children:[S.jsx("div",{className:"text-slate-100 font-medium text-sm",children:e}),S.jsx("div",{className:"text-slate-400 text-xs mt-0.5 leading-relaxed",children:t})]})]})}function qE(n,e,t,i){const r=Gh(i,"command"),s=Gh(i,"file_path"),o=Gh(i,"url");if(t==="Bash"&&r){if(/\brm\s+-rf\b/i.test(r)||/\bsudo\b/i.test(r))return{severity:"danger",text:"Destructive command. Deny unless you have already confirmed the diff."};if(/--no-verify\b/.test(r))return{severity:"warn",text:"Skipping pre-commit hooks. Investigate the failure first."};if(/git\s+push.*--force\b/.test(r))return{severity:"danger",text:"Force-push. Confirm no one else has pushed since."};if(/git\s+push/.test(r)&&/\b(main|master|prod|production)\b/.test(r))return{severity:"warn",text:"Pushing to main/prod. Confirm the diff first."};if(/git\s+reset\s+--hard\b/.test(r))return{severity:"warn",text:"Hard reset will discard uncommitted changes. Stash first if unsure."}}if((t==="Edit"||t==="Write"||t==="MultiEdit")&&s){if(/\.env(\b|\.|\/)|credentials\.json|\.pem$|\.key$/i.test(s))return{severity:"danger",text:"Editing a secrets file. Make sure the agent really needs to."};if(/(^|\/)\.git\//.test(s))return{severity:"warn",text:"Editing inside .git/. Almost certainly a mistake."}}if(t==="WebFetch"&&o){if(/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)/.test(o))return null;if(/^http:\/\//.test(o))return{severity:"info",text:"Plain HTTP fetch. OK for known internal hosts."}}return n.contextUsagePct>=90?{severity:"warn",text:`Context at ${n.contextUsagePct.toFixed(0)}%. Run /compact before continuing.`}:null}function ZE(n,e){return n.status==="error"?{severity:"danger",text:"Session is in error state. Check the chat tab and consider restarting."}:n.contextUsagePct>=90?{severity:"warn",text:`Context at ${n.contextUsagePct.toFixed(0)}%. Compact the conversation before the next prompt.`}:n.contextUsagePct>=80?{severity:"info",text:`Context at ${n.contextUsagePct.toFixed(0)}%. Watch out — output quality drops past 90.`}:e&&e.status==="active"&&e.metrics.toolCallCount===0&&Date.now()-e.startedAt>5*60*1e3?{severity:"info",text:"Active mission with no tool calls in 5+ minutes. Agent may be stuck."}:null}function Gh(n,e){const t=n[e];return typeof t=="string"?t:null}function KE(){const n=Ee(u=>u.pendingPermissions),e=Ee(u=>u.sessions),t=Ee(u=>u.missions),i=Ee(u=>u.resolvePermission),r=Ee(u=>u.selectSession),s=Object.values(n).sort((u,d)=>d.receivedAt-u.receivedAt),[o,a]=Ie.useState(!1),l=s.length;Ie.useEffect(()=>{l>0&&a(!1)},[l]);const c=u=>{r(u),a(!0)};return l===0?S.jsx("div",{className:"absolute top-20 right-4 z-30 pointer-events-none",children:S.jsxs("div",{className:"pointer-events-auto rounded-full border border-solix-border bg-solix-panel/60 backdrop-blur px-3 py-1 text-[10px] text-slate-500 flex items-center gap-2",children:[S.jsx("span",{className:"uppercase tracking-widest",children:"decisions"}),S.jsx("span",{className:"font-bold",children:"0"}),S.jsx("span",{className:"italic opacity-80",children:"— all clear"})]})}):S.jsxs("div",{className:"absolute top-20 right-4 z-30 w-80 flex flex-col gap-2 pointer-events-none",children:[S.jsxs("div",{className:"pointer-events-auto rounded border border-solix-border bg-solix-panel/85 backdrop-blur px-3 py-2 flex items-center justify-between",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-[10px] uppercase tracking-widest text-slate-400",children:"Decisions"}),S.jsx("span",{className:"text-xs font-bold text-solix-danger",children:l})]}),S.jsx("button",{onClick:()=>a(u=>!u),className:"text-[10px] text-slate-400 hover:text-slate-100",children:o?"show":"hide"})]}),!o&&s.map(u=>{const d=e[u.sessionId],h=d!=null&&d.currentMissionId?t[d.currentMissionId]:void 0;return S.jsx(JE,{session:d,mission:h,tool:u.tool,args:u.args,onApprove:()=>i(u.requestId,!0),onDeny:()=>i(u.requestId,!1),onAsk:()=>c(u.sessionId)},u.requestId)})]})}function JE({session:n,mission:e,tool:t,args:i,onApprove:r,onDeny:s,onAsk:o}){const a=(n==null?void 0:n.name)??(n==null?void 0:n.id.slice(0,8))??"unknown agent",l=n!=null&&n.cwd?nT(n.cwd):"",c=n?qE(n,e,t,i):null;return S.jsxs("div",{className:"pointer-events-auto rounded border border-solix-danger bg-solix-danger/10 p-3 backdrop-blur shadow-lg",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("div",{className:"text-xs uppercase tracking-wide text-solix-danger",children:a}),l&&S.jsx("div",{className:"text-[10px] text-slate-500 truncate ml-2 max-w-[55%]",children:l})]}),e&&S.jsxs("div",{className:"mt-1 text-[11px] text-slate-400 italic truncate",children:["mission: ",e.shortName]}),S.jsxs("div",{className:"mt-2 text-sm text-slate-100",children:[S.jsx("span",{className:"font-semibold",children:t}),S.jsx("span",{className:"ml-1 text-slate-300 text-xs break-words",children:iT(i)})]}),S.jsx(QE,{tool:t,args:i}),c&&S.jsx(tT,{suggestion:c}),S.jsxs("div",{className:"mt-3 flex gap-1.5",children:[S.jsx("button",{onClick:r,className:"flex-1 py-1.5 rounded bg-solix-ok/20 border border-solix-ok text-solix-ok text-xs hover:bg-solix-ok/30",children:"Approve · Y"}),S.jsx("button",{onClick:s,className:"flex-1 py-1.5 rounded bg-solix-danger/20 border border-solix-danger text-solix-danger text-xs hover:bg-solix-danger/30",children:"Deny · N"}),S.jsx("button",{onClick:o,className:"px-2.5 py-1.5 rounded border border-solix-border text-slate-300 text-xs hover:text-white hover:bg-solix-border/30",title:"Open chat with this agent for context",children:"Ask"})]})]})}function QE({tool:n,args:e}){const[t,i]=Ie.useState(!1);if(n==="Bash"){const r=rr(e,"command")??"",s=rr(e,"description");return r?S.jsxs(Wh,{label:"will run",children:[S.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-[11px] text-slate-100",children:r}),s&&S.jsx("div",{className:"mt-1 text-[10px] text-slate-500 italic",children:s})]}):null}if(n==="Edit"||n==="NotebookEdit"){const r=rr(e,"file_path")??rr(e,"notebook_path"),s=rr(e,"old_string"),o=rr(e,"new_string");return!r&&!s&&!o?null:S.jsxs(Wh,{label:"patch",children:[r&&S.jsx("div",{className:"font-mono text-[11px] text-solix-accent break-all",children:r}),s&&S.jsx(jh,{sign:"-",text:s,expanded:t,colorClass:"text-solix-danger bg-solix-danger/10"}),o&&S.jsx(jh,{sign:"+",text:o,expanded:t,colorClass:"text-solix-ok bg-solix-ok/10"}),(Xh(s)||Xh(o))&&S.jsx("button",{onClick:()=>i(a=>!a),className:"mt-1 text-[10px] text-slate-400 hover:text-slate-100",children:t?"collapse":"expand"})]})}if(n==="Write"){const r=rr(e,"file_path"),s=rr(e,"content")??"";return r?S.jsxs(Wh,{label:"will write",children:[S.jsx("div",{className:"font-mono text-[11px] text-solix-accent break-all",children:r}),s&&S.jsx(jh,{sign:"+",text:s,expanded:t,colorClass:"text-solix-ok bg-solix-ok/10"}),Xh(s)&&S.jsx("button",{onClick:()=>i(o=>!o),className:"mt-1 text-[10px] text-slate-400 hover:text-slate-100",children:t?"collapse":"expand"})]}):null}return null}function Wh({label:n,children:e}){return S.jsxs("div",{className:"mt-2 rounded border border-solix-border bg-black/30 px-2 py-1.5",children:[S.jsx("div",{className:"text-[9px] uppercase tracking-wider text-slate-500 mb-1",children:n}),e]})}function jh({sign:n,text:e,expanded:t,colorClass:i}){const r=t?e:eT(e,240);return S.jsxs("pre",{className:`mt-1 px-1.5 py-1 rounded text-[11px] font-mono whitespace-pre-wrap break-words ${i}`,children:[S.jsx("span",{className:"opacity-50 mr-1",children:n}),r]})}function rr(n,e){const t=n[e];return typeof t=="string"?t:void 0}function Xh(n){return!!(n&&n.length>240)}function eT(n,e){if(n.length<=e)return n;const t=Math.floor((e-3)/2);return`${n.slice(0,t)}
56
+ */var Ad=Ie,aE=oE;function lE(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var cE=typeof Object.is=="function"?Object.is:lE,uE=aE.useSyncExternalStore,dE=Ad.useRef,hE=Ad.useEffect,fE=Ad.useMemo,pE=Ad.useDebugValue;K_.useSyncExternalStoreWithSelector=function(n,e,t,i,r){var s=dE(null);if(s.current===null){var o={hasValue:!1,value:null};s.current=o}else o=s.current;s=fE(function(){function l(p){if(!c){if(c=!0,u=p,p=i(p),r!==void 0&&o.hasValue){var m=o.value;if(r(m,p))return d=m}return d=p}if(m=d,cE(u,p))return m;var y=i(p);return r!==void 0&&r(m,y)?(u=p,m):(u=p,d=y)}var c=!1,u,d,h=t===void 0?null:t;return[function(){return l(e())},h===null?void 0:function(){return l(h())}]},[e,t,i,r]);var a=uE(n,s[0],s[1]);return hE(function(){o.hasValue=!0,o.value=a},[a]),pE(a),a};Z_.exports=K_;var mE=Z_.exports;const gE=kv(mE),eS={},{useDebugValue:xE}=Uw,{useSyncExternalStoreWithSelector:vE}=gE;let jx=!1;const yE=n=>n;function _E(n,e=yE,t){(eS?"production":void 0)!=="production"&&t&&!jx&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),jx=!0);const i=vE(n.subscribe,n.getState,n.getServerState||n.getInitialState,e,t);return xE(i),i}const Xx=n=>{(eS?"production":void 0)!=="production"&&typeof n!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e=typeof n=="function"?Zb(n):n,t=(i,r)=>_E(e,i,r);return Object.assign(t,e),t},SE=n=>n?Xx(n):Xx,ME="solix.notifications.v1";function wE(){try{return localStorage.getItem(ME)==="off"?"off":"on"}catch{return"on"}}let Yx=!1;async function bE(){if(typeof Notification>"u")return"denied";if(Notification.permission!=="default"||Yx)return Notification.permission;Yx=!0;try{return await Notification.requestPermission()}catch{return"denied"}}async function EE(n){if(!(wE()==="off"||typeof Notification>"u"||typeof document<"u"&&!document.hidden||await bE()!=="granted"))try{new Notification(n.title,{body:n.body,tag:n.tag})}catch{}}const TE="solix.sound.v1";let Vh=null;function AE(){try{if(localStorage.getItem(TE)!=="on"||typeof window>"u")return;if(!Vh){const r=window.AudioContext||window.webkitAudioContext;if(!r)return;Vh=new r}const n=Vh,e=n.createOscillator(),t=n.createGain();e.connect(t),t.connect(n.destination),e.type="sine",e.frequency.value=880,t.gain.value=1e-4;const i=n.currentTime;t.gain.exponentialRampToValueAtTime(.06,i+.01),t.gain.exponentialRampToValueAtTime(1e-4,i+.35),e.start(i),e.stop(i+.4)}catch{}}function $x(n,e,t,i){const r={},s={},a=[];for(const l of n){if(l.ts>e)break;switch(l.type){case"session_started":{const c=t[l.sessionId];if(!c)continue;r[l.sessionId]={...c,status:"idle"};break}case"session_terminated":{delete r[l.sessionId];break}case"mission_started":{if(!l.missionId)continue;const c=i[l.missionId],u=r[l.sessionId];u&&(r[l.sessionId]={...u,status:"active",currentMissionId:l.missionId}),c&&(s[l.missionId]={...c,status:"active"});break}case"mission_completed":{if(!l.missionId)continue;const c=r[l.sessionId],u=i[l.missionId];c&&c.currentMissionId===l.missionId&&(r[l.sessionId]={...c,status:"idle",currentMissionId:void 0,lastCompletedMissionId:l.missionId}),u&&(s[l.missionId]={...u,status:"completed"});break}case"tool_call":{e-l.ts<=2e3&&a.push({id:`tc-${l.ts}-${l.sessionId}`,sessionId:l.sessionId,tool:l.toolName??"tool",args:{},startedAt:l.ts,status:"ok",receivedAt:l.ts});break}}}return{derivedSessions:r,derivedMissions:s,derivedToolCalls:a}}const qx={active:!1,loading:!1,events:[],earliestMs:0,latestMs:0,currentMs:0,playing:!1,speed:4,derivedSessions:{},derivedMissions:{},derivedToolCalls:[]},Zx=2e3,tS="solix.motion.v1",nS="solix.viewMode.v1";function CE(){try{return localStorage.getItem(tS)==="1"}catch{return!1}}function Kx(n){try{localStorage.setItem(tS,n?"1":"0")}catch{}}function RE(){try{const n=localStorage.getItem(nS);return n==="list"||n==="missions"||n==="galaxy"?n:"galaxy"}catch{return"galaxy"}}function Jx(n){try{localStorage.setItem(nS,n)}catch{}}const Ee=SE((n,e)=>({connected:!1,projects:{},sessions:{},missions:{},advisors:{},skills:{},chatBySessionId:{},recentToolCalls:[],pendingPermissions:{},selectedSessionId:null,selectedAdvisorId:null,selectedSkillId:null,motionEnabled:CE(),viewMode:RE(),playback:qx,toasts:[],setConnected:t=>n({connected:t}),applyMessage:t=>{switch(t.type){case"snapshot":{const i={};for(const l of t.projects)i[l.id]=l;const r={};for(const l of t.sessions)r[l.id]=l;const s={};for(const l of t.missions)s[l.id]=l;const o={};for(const l of t.advisors)o[l.id]=l;const a={};for(const l of t.skills)a[l.id]=l;n({projects:i,sessions:r,missions:s,advisors:o,skills:a});break}case"advisor_upsert":{n(i=>({advisors:{...i.advisors,[t.advisor.id]:t.advisor}}));break}case"skill_upsert":{n(i=>({skills:{...i.skills,[t.skill.id]:t.skill}}));break}case"galaxy_imported":{const i=`${Date.now()}-galaxy`;n(r=>({toasts:[...r.toasts,{id:i,level:"info",message:`Imported galaxy: ${t.manifest.name}`}].slice(-6)})),setTimeout(()=>e().dismissToast(i),5e3);break}case"session_upsert":{n(i=>({sessions:{...i.sessions,[t.session.id]:t.session}}));break}case"session_remove":{n(i=>{const r={...i.sessions};return delete r[t.sessionId],{sessions:r}});break}case"mission_upsert":{n(i=>({missions:{...i.missions,[t.mission.id]:t.mission}}));break}case"tool_call":{const i={...t.toolCall,receivedAt:Date.now()};n(r=>({recentToolCalls:[...r.recentToolCalls,i].slice(-200)})),setTimeout(()=>{n(r=>({recentToolCalls:r.recentToolCalls.filter(s=>Date.now()-s.receivedAt<Zx)}))},Zx+50);break}case"permission_request":{const i={requestId:t.requestId,sessionId:t.sessionId,tool:t.tool,args:t.args,receivedAt:Date.now()};n(a=>({pendingPermissions:{...a.pendingPermissions,[t.requestId]:i}}));const r=e().sessions[t.sessionId],s=(r==null?void 0:r.name)??t.sessionId.slice(0,8),o=(()=>{const a=Object.keys(t.args)[0];if(!a)return"";const l=t.args[a],c=typeof l=="string"?l:JSON.stringify(l);return`: ${c.length>60?c.slice(0,60)+"…":c}`})();EE({title:`${s} needs you`,body:`${t.tool}${o}`,tag:`solix-perm-${t.sessionId}`,whenHidden:!0}),AE();break}case"context_update":{n(i=>{const r=i.sessions[t.sessionId];return r?{sessions:{...i.sessions,[t.sessionId]:{...r,contextUsagePct:t.usagePct}}}:i});break}case"chat_delta":{const i={...t.delta,receivedAt:Date.now()};n(r=>{const a=[...(r.chatBySessionId[t.sessionId]??[]).filter(l=>l.messageId!==i.messageId),i].slice(-200);return{chatBySessionId:{...r.chatBySessionId,[t.sessionId]:a}}});break}case"toast":{const i=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;n(r=>({toasts:[...r.toasts,{id:i,level:t.level,message:t.message}].slice(-6)})),setTimeout(()=>e().dismissToast(i),5e3);break}}},selectSession:t=>n({selectedSessionId:t,selectedAdvisorId:t?null:e().selectedAdvisorId,selectedSkillId:t?null:e().selectedSkillId}),selectAdvisor:t=>n({selectedAdvisorId:t,selectedSessionId:t?null:e().selectedSessionId,selectedSkillId:t?null:e().selectedSkillId}),selectSkill:t=>n({selectedSkillId:t,selectedSessionId:t?null:e().selectedSessionId,selectedAdvisorId:t?null:e().selectedAdvisorId}),dismissToast:t=>n(i=>({toasts:i.toasts.filter(r=>r.id!==t)})),resolvePermission:(t,i)=>{const r=e().send;r({type:"permission_response",requestId:t,approved:i}),n(s=>{const o={...s.pendingPermissions};return delete o[t],{pendingPermissions:o}})},invokeAdvisor:(t,i)=>{const r=e().send,s=e().selectedSessionId??void 0;r({type:"invoke_advisor",advisorId:t,targetSessionId:s,prompt:i})},pinAdvisor:t=>{e().send({type:"pin_advisor",advisorId:t})},unpinAdvisor:t=>{e().send({type:"unpin_advisor",advisorId:t})},sendPromptTo:(t,i)=>{if(!i.trim())return;e().send({type:"send_prompt",sessionId:t,text:i});const r={messageId:`pending-${Date.now()}`,role:"user",content:i,ts:Date.now(),done:!0,receivedAt:Date.now()};n(s=>({chatBySessionId:{...s.chatBySessionId,[t]:[...s.chatBySessionId[t]??[],r].slice(-200)}}))},launchTask:(t,i,r,s)=>{e().send({type:"launch_session",cwd:t,model:i,initialPrompt:r,worktreeBranch:s==null?void 0:s.worktreeBranch,worktreeBaseRef:s==null?void 0:s.worktreeBaseRef})},selectedSessionIds:new Set,toggleSessionSelection:t=>{n(i=>{const r=new Set(i.selectedSessionIds);return r.has(t)?r.delete(t):r.add(t),{selectedSessionIds:r}})},clearSessionSelection:()=>{n({selectedSessionIds:new Set})},terminateSessions:t=>{const i=e().send;for(const r of t)i({type:"terminate_session",sessionId:r});n({selectedSessionIds:new Set})},setMotionEnabled:t=>{Kx(t),n({motionEnabled:t})},toggleMotion:()=>{const t=!e().motionEnabled;Kx(t),n({motionEnabled:t})},setViewMode:t=>{Jx(t),n({viewMode:t})},toggleViewMode:()=>{const t=["galaxy","list","missions"],i=e().viewMode,r=t.indexOf(i),s=t[(r+1)%t.length]??"galaxy";Jx(s),n({viewMode:s})},enterPlayback:(t,i,r)=>{const s=i;n(o=>({playback:{...o.playback,active:!0,loading:!1,events:t,earliestMs:i,latestMs:r,currentMs:s,playing:!1,...$x(t,s,e().sessions,e().missions)}}))},exitPlayback:()=>n({playback:qx}),setPlaybackTime:t=>{n(i=>{const r=Math.max(i.playback.earliestMs,Math.min(t,i.playback.latestMs));return{playback:{...i.playback,currentMs:r,...$x(i.playback.events,r,e().sessions,e().missions)}}})},setPlaybackSpeed:t=>n(i=>({playback:{...i.playback,speed:t}})),setPlaybackPlaying:t=>n(i=>({playback:{...i.playback,playing:t}})),setPlaybackLoading:t=>n(i=>({playback:{...i.playback,loading:t}})),send:()=>{},attachSocket:t=>n({send:t})}));function Fm(n){return n.playback.active?n.playback.derivedSessions:n.sessions}function iS(n){return Object.values(Fm(n)).filter(e=>!e.parentSessionId&&e.kind!=="advisor")}function PE(n){return Object.values(Fm(n)).filter(e=>!e.parentSessionId&&e.kind==="advisor")}function z3(n,e){return Object.values(Fm(n)).filter(t=>t.parentSessionId===e)}function V3(n){return Object.values(n.advisors).filter(e=>e.enabled)}function H3(n){return Object.values(n.skills)}function IE(n){switch(n){case"opus":return"#a855f7";case"sonnet":return"#3b82f6";case"haiku":return"#06b6d4";case"default":return"#94a3b8";default:return"#94a3b8"}}function G3(n){switch(n){case"active":return{color:"#fde68a",intensity:.3};case"awaiting_permission":return{color:"#ef4444",intensity:.5};case"awaiting_input":return{color:"#f59e0b",intensity:.25};case"plan_review":return{color:"#a78bfa",intensity:.2};case"error":return{color:"#dc2626",intensity:.3};case"spawning":return{color:"#ffffff",intensity:.2};case"idle":default:return{color:"#1e293b",intensity:.05}}}function rS(n){switch(n){case"active":return"Active";case"awaiting_permission":return"Permission";case"awaiting_input":return"Awaiting input";case"plan_review":return"Plan review";case"error":return"Error";case"spawning":return"Spawning";case"terminated":return"Terminated";case"idle":default:return"Idle"}}function NE(n,e,t){const i=[];let r=30;switch(n.status){case"error":r=0,i.push("In error state");break;case"plan_review":case"awaiting_input":r=15,i.push(`Status: ${n.status}`);break;case"awaiting_permission":r=12,i.push("Awaiting permission");break;case"terminated":r=5,i.push("Terminated");break;default:r=30}const s=Math.max(0,30-t*15);t>0&&i.push(`${t} pending permission${t===1?"":"s"}`);const a=25*Math.max(0,1-n.contextUsagePct/100);n.contextUsagePct>=90?i.push(`Context at ${n.contextUsagePct.toFixed(0)}%`):n.contextUsagePct>=80&&i.push(`Context warm (${n.contextUsagePct.toFixed(0)}%)`);let l=0;if(e&&e.status==="active"){const u=e.metrics.toolCallCount;l=Math.min(15,u*2)}else e&&e.status==="completed"&&(l=15);return{score:Math.round(Math.max(0,Math.min(100,r+s+a+l))),reasons:i}}function LE(n){return n>=75?"#10b981":n>=50?"#fbbf24":n>=25?"#f97316":"#ef4444"}const Bm={active:"The agent is currently working — emitting tool calls or generating output.",idle:"No mission running. The agent is waiting for the next prompt or has been quiet for a while.",spawning:"The agent process just started. It will transition to active within a second or two.",awaiting_permission:"The agent paused to ask permission for a sensitive tool call. Approve or deny in the Decision Queue.",awaiting_input:"The agent finished what it could and is waiting for your next prompt.",plan_review:"The agent produced a plan and is waiting for your approval before executing.",error:"The agent crashed or hit an unrecoverable error. Look at the SidePanel transcript for details.",terminated:"The agent process exited. No more activity will come from this session.",subagent:"A child agent spawned by another session (typically via the Task tool). Rendered as a moon orbiting the parent planet.",advisor:"A long-lived specialist agent (Compass, Forge, Lumen, Argus, Sentinel, …) with its own AGENT.md describing its role.",pinned:"An advisor that's always running. Pinned advisors orbit close to the sun in the inner ring."},Qx={awaiting_permission:0,awaiting_input:1,plan_review:2,error:3,active:4,spawning:5,idle:6,terminated:7};function DE(){const n=Ee(iS),e=Ee(PE),t=Ee(_=>_.projects),i=Ee(_=>_.missions),r=Ee(_=>_.pendingPermissions),s=Ee(_=>_.selectSession),o=Ee(_=>_.selectedSessionIds),a=Ee(_=>_.toggleSessionSelection),l=Ee(_=>_.clearSessionSelection),c=Ee(_=>_.terminateSessions),[u,d]=Ie.useState("needs"),[h,p]=Ie.useState("asc"),m=Ie.useMemo(()=>{const _=[...n,...e],R=new Set(Object.values(r).map(M=>M.sessionId));return _.map(M=>{const T=M.currentMissionId?i[M.currentMissionId]:void 0,A=Object.values(r).filter(L=>L.sessionId===M.id).length,{score:E,reasons:w}=NE(M,T,A);return{session:M,project:t[M.projectId],mission:T,needsAttention:R.has(M.id)||M.status==="awaiting_permission"||M.status==="awaiting_input"||M.status==="plan_review",health:E,healthReasons:w}})},[n,e,t,i,r]),y=Ie.useMemo(()=>{var R;const _=new Map;for(const M of m){const T=((R=M.project)==null?void 0:R.id)??"_",A=_.get(T);A?A.rows.push(M):_.set(T,{project:M.project,rows:[M]})}return[..._.values()].sort((M,T)=>{var A,E;return(((A=T.project)==null?void 0:A.lastActiveAt)??0)-(((E=M.project)==null?void 0:E.lastActiveAt)??0)})},[m]),g=(_,R)=>{var T,A;const M=h==="asc"?1:-1;switch(u){case"name":return((_.session.name??_.session.id)>(R.session.name??R.session.id)?1:-1)*M;case"status":return((Qx[_.session.status]??99)-(Qx[R.session.status]??99))*M;case"progress":return((((T=_.mission)==null?void 0:T.metrics.toolCallCount)??0)-(((A=R.mission)==null?void 0:A.metrics.toolCallCount)??0))*M;case"context":return(_.session.contextUsagePct-R.session.contextUsagePct)*M;case"lastActivity":return(_.session.updatedAt-R.session.updatedAt)*M;case"needs":return _.needsAttention===R.needsAttention?0:_.needsAttention?-1*M:1*M;case"health":return(_.health-R.health)*M}},f=_=>{u===_?p(h==="asc"?"desc":"asc"):(d(_),p(_==="lastActivity"?"desc":"asc"))},v=_=>u!==_?"":h==="asc"?" ▲":" ▼",x=o.size;return S.jsxs("div",{className:"absolute inset-0 overflow-y-auto bg-solix-bg pt-20 pb-20 px-6 z-0",children:[x>0&&S.jsx("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-30 pointer-events-auto",children:S.jsxs("div",{className:"rounded-full border border-solix-accent/60 bg-solix-panel/95 backdrop-blur shadow-2xl px-4 py-2 flex items-center gap-3",children:[S.jsxs("span",{className:"text-xs text-slate-200 font-mono",children:[x," selected"]}),S.jsx("button",{onClick:()=>c([...o]),className:"text-xs px-3 py-1 rounded border border-solix-danger text-solix-danger hover:bg-solix-danger/15",children:"Terminate"}),S.jsx("button",{onClick:l,className:"text-xs text-slate-400 hover:text-slate-200",children:"Clear"})]})}),S.jsxs("div",{className:"max-w-6xl mx-auto",children:[S.jsxs("div",{className:"text-xs text-slate-500 uppercase tracking-widest mb-3",children:["List view · ",m.length," agent",m.length===1?"":"s"]}),m.length===0?S.jsxs("div",{className:"text-sm text-slate-500 italic py-12 text-center border border-solix-border rounded",children:["No agents yet. Run ",S.jsx("code",{children:"claude"})," in any terminal — a row will appear here within a second."]}):y.map(({project:_,rows:R})=>{const M=[...R].sort(g),T=(_==null?void 0:_.name)??"(unassigned)";return S.jsxs("section",{className:"mb-8 rounded border border-solix-border overflow-hidden",children:[S.jsxs("header",{className:"bg-solix-panel/60 px-4 py-2 flex items-center justify-between",children:[S.jsxs("div",{children:[S.jsx("span",{className:"text-sm font-semibold text-slate-100",children:T}),S.jsxs("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-slate-500",children:[R.length," agent",R.length===1?"":"s"]})]}),(_==null?void 0:_.cwd)&&S.jsx("span",{className:"text-[10px] font-mono text-slate-500 truncate max-w-[55%]",children:_.cwd})]}),S.jsxs("table",{className:"w-full text-sm",children:[S.jsx("thead",{className:"bg-black/30 text-[10px] uppercase tracking-wide text-slate-500",children:S.jsxs("tr",{children:[S.jsx(Ri,{children:S.jsx("input",{type:"checkbox","aria-label":"Select all in project",checked:M.length>0&&M.every(A=>o.has(A.session.id)),onChange:A=>{A.stopPropagation();const E=M.every(w=>o.has(w.session.id));for(const w of M){const L=o.has(w.session.id);(E&&L||!E&&!L)&&a(w.session.id)}},className:"cursor-pointer"})}),S.jsxs(Ri,{onClick:()=>f("needs"),children:["● ",v("needs")]}),S.jsxs(Ri,{onClick:()=>f("name"),children:["Agent",v("name")]}),S.jsx(Ri,{children:"Advisor"}),S.jsxs(Ri,{onClick:()=>f("status"),children:["Status",v("status")]}),S.jsxs(Ri,{onClick:()=>f("health"),numeric:!0,children:["Health",v("health")]}),S.jsxs(Ri,{onClick:()=>f("progress"),children:["Mission · tools",v("progress")]}),S.jsxs(Ri,{onClick:()=>f("context"),numeric:!0,children:["Context",v("context")]}),S.jsxs(Ri,{onClick:()=>f("lastActivity"),numeric:!0,children:["Last activity",v("lastActivity")]})]})}),S.jsx("tbody",{children:M.map(A=>S.jsxs("tr",{onClick:()=>s(A.session.id),className:`border-t border-solix-border hover:bg-solix-border/20 cursor-pointer ${A.needsAttention?"bg-solix-danger/5":""} ${o.has(A.session.id)?"bg-solix-accent/5":""}`,children:[S.jsx("td",{className:"px-3 py-2",onClick:E=>E.stopPropagation(),children:S.jsx("input",{type:"checkbox","aria-label":"Select agent",checked:o.has(A.session.id),onChange:()=>a(A.session.id),className:"cursor-pointer"})}),S.jsx("td",{className:"px-3 py-2",children:A.needsAttention?S.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-solix-danger solix-pulse"}):A.session.status==="active"?S.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-solix-ok"}):S.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-slate-600"})}),S.jsx("td",{className:"px-3 py-2",children:S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{background:IE(A.session.model)},title:String(A.session.model)}),S.jsx("span",{className:"text-slate-100 font-medium",children:A.session.name??A.session.id.slice(0,8)}),A.session.kind==="advisor"&&S.jsx("span",{className:"text-[9px] uppercase tracking-wide text-amber-300",children:"advisor"}),A.session.wrapperSocketPath&&S.jsx("span",{className:"text-[9px] uppercase tracking-wide text-solix-accent",title:"Wrapped by `solix run` — UI composer is enabled",children:"wrapped"}),A.session.worktreePath&&S.jsxs("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded border border-solix-accent/40 text-solix-accent",title:A.session.worktreePath,children:["⌥",UE(A.session.worktreePath)]})]})}),S.jsx("td",{className:"px-3 py-2 text-xs",children:S.jsx(OE,{session:A.session,mission:A.mission})}),S.jsx("td",{className:"px-3 py-2 text-xs text-slate-300",title:Bm[A.session.status]??void 0,children:rS(A.session.status)}),S.jsx("td",{className:"px-3 py-2 text-right",children:S.jsx(FE,{score:A.health,reasons:A.healthReasons})}),S.jsx("td",{className:"px-3 py-2 text-xs text-slate-300 truncate max-w-xs",children:A.mission?S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"text-slate-100",children:A.mission.shortName}),S.jsxs("span",{className:"text-slate-500 ml-1",children:["· ",A.mission.metrics.toolCallCount," tools"]})]}):S.jsx("span",{className:"text-slate-500 italic",children:"idle"})}),S.jsx("td",{className:"px-3 py-2 text-right",children:S.jsx(BE,{pct:A.session.contextUsagePct})}),S.jsx("td",{className:"px-3 py-2 text-right text-[11px] text-slate-500 font-mono",children:zE(A.session.updatedAt)})]},A.session.id))})]})]},(_==null?void 0:_.id)??"_")})]})]})}function UE(n){const e=n.split("/").filter(Boolean);return e[e.length-1]??n}const kE=/^\[Acting as ([^\s—]+)/;function OE({session:n,mission:e}){var s;const t=Ee(o=>o.advisors);let i,r=!1;if(n.advisorRole)i=Object.values(t).find(o=>o.id===n.advisorRole);else if(e!=null&&e.prompt){const o=e.prompt.match(kE),a=(s=o==null?void 0:o[1])==null?void 0:s.toLowerCase();a&&(i=Object.values(t).find(l=>l.codename.toLowerCase()===a),r=!0)}return i?S.jsxs("span",{className:`inline-flex items-center gap-1 ${r?"opacity-60":""}`,title:i.description,children:[S.jsx("span",{style:{color:i.color},children:i.glyph}),S.jsx("span",{className:"text-slate-200",children:i.codename})]}):S.jsx("span",{className:"text-slate-700",children:"—"})}function Ri({children:n,onClick:e,numeric:t}){return S.jsx("th",{onClick:e,className:`px-3 py-2 select-none ${t?"text-right":"text-left"} ${e?"cursor-pointer hover:text-slate-300":""}`,children:n})}function FE({score:n,reasons:e}){const t=LE(n);return S.jsxs("div",{className:"relative inline-flex items-center gap-2 group",children:[S.jsx("span",{className:"text-[11px] font-mono font-bold",style:{color:t},children:n}),S.jsx("div",{className:"w-16 h-1.5 rounded-full bg-slate-800 overflow-hidden",children:S.jsx("div",{className:"h-full",style:{width:`${Math.max(2,n)}%`,background:t}})}),S.jsxs("div",{className:"pointer-events-none absolute right-0 top-full mt-1 z-50 hidden group-hover:block w-64 rounded border border-solix-border bg-solix-panel/95 backdrop-blur p-2 text-left shadow-xl",children:[S.jsxs("div",{className:"flex items-center justify-between mb-1",children:[S.jsx("span",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Health"}),S.jsxs("span",{className:"text-xs font-bold",style:{color:t},children:[n,"/100"]})]}),e.length===0?S.jsx("div",{className:"text-[11px] text-slate-400 italic",children:"All four bands healthy: stable status, no pending decisions, context budget, mission progress."}):S.jsx("ul",{className:"space-y-0.5",children:e.map(i=>S.jsxs("li",{className:"text-[11px] text-slate-200 leading-snug",children:["· ",i]},i))})]})]})}function BE({pct:n}){const e=n>=90?"bg-solix-danger":n>=80?"bg-solix-warn":"bg-solix-accent";return S.jsxs("div",{className:"inline-flex items-center gap-2",children:[S.jsxs("span",{className:"text-[11px] text-slate-400 font-mono",children:[n.toFixed(0),"%"]}),S.jsx("div",{className:"w-20 h-1.5 rounded-full bg-slate-800 overflow-hidden",children:S.jsx("div",{className:`h-full ${e}`,style:{width:`${Math.min(100,n)}%`}})})]})}function zE(n){const e=Date.now()-n;if(e<0)return"now";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const i=Math.floor(t/60);if(i<60)return`${i}m`;const r=Math.floor(i/60);return r<24?`${r}h`:new Date(n).toLocaleDateString()}function VE(){const n=Ee(l=>l.missions),e=Ee(l=>l.sessions),t=Ee(l=>l.projects),i=Ee(l=>l.selectSession),[r,s]=Ie.useState("all"),o=Ie.useMemo(()=>{const l=Object.values(n).sort((c,u)=>u.startedAt-c.startedAt);return r==="all"?l:l.filter(c=>c.status===r)},[n,r]),a=Ie.useMemo(()=>{const l=new Map;for(const c of o){const u=e[c.sessionId],d=u?t[u.projectId]:void 0,h=(d==null?void 0:d.id)??"_",p=l.get(h);p?p.missions.push(c):l.set(h,{project:d,missions:[c]})}return[...l.values()].sort((c,u)=>{var d,h;return(((d=u.missions[0])==null?void 0:d.startedAt)??0)-(((h=c.missions[0])==null?void 0:h.startedAt)??0)})},[o,e,t]);return S.jsx("div",{className:"absolute inset-0 overflow-y-auto bg-solix-bg pt-20 pb-8 px-6 z-0",children:S.jsxs("div",{className:"max-w-4xl mx-auto",children:[S.jsxs("div",{className:"flex items-center justify-between mb-3",children:[S.jsxs("div",{className:"text-xs text-slate-500 uppercase tracking-widest",children:["Missions · ",o.length]}),S.jsx("div",{className:"flex items-center gap-1.5",children:["all","active","completed","failed","cancelled"].map(l=>S.jsx("button",{onClick:()=>s(l),className:`text-[10px] px-2 py-0.5 rounded border ${r===l?"bg-solix-accent/15 border-solix-accent text-solix-accent":"border-solix-border text-slate-400 hover:text-slate-200"}`,children:l},l))})]}),o.length===0?S.jsx("div",{className:"text-sm text-slate-500 italic py-12 text-center border border-solix-border rounded",children:"No missions yet. Send a prompt to a Claude Code session and a mission card will appear here."}):a.map(({project:l,missions:c})=>{const u=(l==null?void 0:l.name)??"(unassigned)";return S.jsxs("section",{className:"mb-6 rounded border border-solix-border overflow-hidden",children:[S.jsxs("header",{className:"bg-solix-panel/60 px-4 py-2 flex items-center justify-between",children:[S.jsxs("div",{children:[S.jsx("span",{className:"text-sm font-semibold text-slate-100",children:u}),S.jsxs("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-slate-500",children:[c.length," mission",c.length===1?"":"s"]})]}),(l==null?void 0:l.cwd)&&S.jsx("span",{className:"text-[10px] font-mono text-slate-500 truncate max-w-[55%]",children:l.cwd})]}),S.jsx("ul",{className:"divide-y divide-solix-border",children:c.map(d=>{const h=e[d.sessionId];return S.jsx("li",{children:S.jsxs("button",{onClick:()=>i(d.sessionId),className:"w-full text-left p-4 hover:bg-solix-border/20 cursor-pointer block",children:[S.jsxs("div",{className:"flex items-start justify-between gap-3",children:[S.jsxs("div",{className:"min-w-0 flex-1",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-sm font-semibold text-slate-100",children:d.shortName}),S.jsx(HE,{status:d.status})]}),S.jsx("div",{className:"mt-1 text-xs text-slate-400 line-clamp-2",children:d.prompt}),d.longSummary&&S.jsx("div",{className:"mt-1 text-xs text-slate-300 italic",children:d.longSummary}),d.status==="failed"&&d.errorSummary&&S.jsxs("div",{className:"mt-1 text-xs text-solix-danger italic line-clamp-2",children:["error: ",d.errorSummary]})]}),S.jsxs("div",{className:"text-right text-[10px] text-slate-500 font-mono whitespace-nowrap",children:[WE(d.startedAt),d.metrics.durationMs!==void 0&&S.jsxs("div",{children:[(d.metrics.durationMs/1e3).toFixed(1),"s"]})]})]}),S.jsxs("div",{className:"mt-2 flex items-center gap-3 text-[10px] text-slate-500",children:[h&&S.jsxs("span",{children:["agent:"," ",S.jsx("span",{className:"text-slate-300",children:h.name??h.id.slice(0,8)})]}),S.jsxs("span",{children:[d.metrics.toolCallCount," tools"]}),S.jsxs("span",{title:Bm.subagent,children:[d.metrics.subagentCount," subagents"]}),S.jsxs("span",{children:[d.filesTouched.length," files"]})]}),d.filesTouched.length>0&&S.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[d.filesTouched.slice(0,6).map(p=>S.jsx("span",{className:"text-[10px] font-mono text-slate-400 bg-black/30 border border-solix-border rounded px-1.5 py-0.5",children:GE(p)},p)),d.filesTouched.length>6&&S.jsxs("span",{className:"text-[10px] text-slate-500",children:["+",d.filesTouched.length-6]})]})]})},d.id)})})]},(l==null?void 0:l.id)??"_")})]})})}function HE({status:n}){const e=n==="active"?"border-solix-warn text-solix-warn":n==="completed"?"border-solix-ok text-solix-ok":n==="failed"?"border-solix-danger text-solix-danger":"border-solix-border text-slate-400";return S.jsx("span",{className:`text-[9px] uppercase tracking-wide px-1.5 py-0.5 rounded border ${e}`,children:n})}function GE(n){const e=n.match(/[^/\\]+\/?$/);return e?e[0].replace(/\/$/,""):n}function WE(n){const e=Date.now()-n;if(e<0)return"now";const t=Math.floor(e/1e3);if(t<60)return`${t}s ago`;const i=Math.floor(t/60);if(i<60)return`${i}m ago`;const r=Math.floor(i/60);return r<24?`${r}h ago`:new Date(n).toLocaleDateString()}function jE({onOpenGalaxy:n,onNewTask:e,onOpenTimeline:t,onOpenHelp:i}={}){const r=Ee(u=>u.connected),s=Ee(iS),o=Ee(u=>u.viewMode),a=Ee(u=>u.playback.active),l=Ee(u=>u.exitPlayback),c=s.reduce((u,d)=>(d.status==="active"?u.active+=1:d.status==="awaiting_permission"||d.status==="awaiting_input"||d.status==="plan_review"?u.attention+=1:d.status==="idle"&&(u.idle+=1),u),{active:0,idle:0,attention:0});return S.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-start justify-between p-4 z-40",children:[S.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 sm:gap-3",children:[S.jsx("div",{className:"text-xl font-bold tracking-widest text-solix-accent",children:"SOLIX"}),S.jsx("div",{className:"hidden md:block text-xs text-slate-400",children:"a solar-system command center"}),S.jsx("div",{className:`ml-1 sm:ml-3 px-2 py-1 rounded text-[10px] border ${r?"border-solix-ok text-solix-ok":"border-solix-danger text-solix-danger solix-pulse"}`,children:r?"CONNECTED":"OFFLINE"}),a&&S.jsxs("button",{onClick:l,className:"ml-2 px-2 py-1 rounded text-[10px] border border-solix-accent text-solix-accent solix-pulse hover:bg-solix-accent/15 cursor-pointer flex items-center gap-1.5",title:"Exit Timeline Playback (Esc)","aria-label":"Exit playback",children:[S.jsx("span",{children:"▸ PLAYBACK"}),S.jsx("span",{className:"opacity-70",children:"· exit ✕"})]})]}),S.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 sm:gap-3 text-xs",children:[S.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[S.jsx(Hh,{label:"active",value:c.active,color:"text-solix-ok"}),S.jsx(Hh,{label:"attention",value:c.attention,color:"text-solix-warn"}),S.jsx(Hh,{label:"idle",value:c.idle,color:"text-slate-400"})]}),S.jsx(XE,{viewMode:o}),t&&S.jsx("button",{onClick:t,className:"hidden sm:inline-block px-2 py-1 rounded bg-solix-panel border border-solix-border text-slate-300 hover:text-white hover:bg-solix-border/30",title:"Timeline playback (T)",children:"⏱ Timeline"}),e&&S.jsx("button",{onClick:e,className:"px-2 py-1 rounded bg-solix-ok/15 border border-solix-ok/40 text-solix-ok hover:bg-solix-ok/25",title:"Launch a new Claude Code task (L)",children:"+ Task"}),n&&S.jsx("button",{onClick:n,className:"px-2 py-1 rounded bg-solix-accent/15 border border-solix-accent/40 text-solix-accent hover:bg-solix-accent/25",title:"Galaxy: export and import (G)",children:"⌬ Galaxy"}),i&&S.jsx("button",{onClick:i,className:"w-7 h-7 rounded-full bg-solix-panel border border-solix-border text-slate-300 hover:text-white hover:bg-solix-border/30 text-sm",title:"Help (?)","aria-label":"Help",children:"?"})]})]})}function XE({viewMode:n}){const e=Ee(i=>i.setViewMode),t=[{mode:"galaxy",label:"🪐"},{mode:"list",label:"☰"},{mode:"missions",label:"◎"}];return S.jsx("div",{className:"inline-flex rounded border border-solix-border bg-solix-panel overflow-hidden",children:t.map(i=>S.jsxs("button",{onClick:()=>e(i.mode),className:`px-2 py-1 text-xs ${n===i.mode?"bg-solix-border/50 text-white":"text-slate-400 hover:text-slate-100"}`,title:`${i.mode} view (V)`,children:[i.label," ",S.jsx("span",{className:"hidden sm:inline capitalize",children:i.mode})]},i.mode))})}function Hh({label:n,value:e,color:t}){return S.jsxs("div",{className:"px-2 py-1 rounded bg-solix-panel border border-solix-border",children:[S.jsx("span",{className:`font-bold ${t}`,children:e}),S.jsx("span",{className:"ml-1 opacity-60 uppercase tracking-wide",children:n})]})}function YE(){const n=Ee(t=>t.toasts),e=Ee(t=>t.dismissToast);return S.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 flex flex-col gap-2 z-30",children:n.map(t=>S.jsx("button",{onClick:()=>e(t.id),className:`pointer-events-auto px-3 py-2 rounded text-xs border max-w-md text-left ${t.level==="error"?"bg-solix-danger/10 border-solix-danger text-solix-danger":t.level==="warn"?"bg-solix-warn/10 border-solix-warn text-solix-warn":"bg-solix-panel border-solix-border text-slate-200"}`,children:t.message},t.id))})}const e0="solix.welcome.dismissed.v1";function $E({onOpenGalaxy:n,forceOpen:e=!1,onClose:t}){const[i,r]=Ie.useState(!1),s=Ee(u=>u.advisors),o=Ee(u=>Object.keys(u.skills).length),a=Ee(u=>Object.keys(u.sessions).length);if(Ie.useEffect(()=>{try{r(localStorage.getItem(e0)==="1")}catch{}},[]),!e&&(i||a>0))return null;const l=()=>{try{localStorage.setItem(e0,"1")}catch{}r(!0),t==null||t()},c=Object.values(s).filter(u=>u.enabled).sort((u,d)=>u.codename.localeCompare(d.codename));return S.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center pointer-events-none",children:S.jsxs("div",{className:"pointer-events-auto max-w-xl w-full mx-4 rounded-xl border border-solix-accent/40 bg-solix-panel/95 backdrop-blur-md shadow-2xl",children:[S.jsxs("div",{className:"px-6 pt-5 pb-3 border-b border-solix-border",children:[S.jsx("div",{className:"text-xs uppercase tracking-widest text-solix-accent",children:"welcome"}),S.jsx("div",{className:"text-2xl font-bold mt-1",children:"Solix — your agent solar system"}),S.jsx("div",{className:"text-sm text-slate-400 mt-1",children:"Mission control for Claude Code. Each agent orbits the sun; each click is a conversation with one of your planets."})]}),S.jsxs("div",{className:"px-6 py-4 space-y-3 text-sm text-slate-300",children:[S.jsx(ta,{n:1,title:"Run a Claude Code session",body:S.jsxs(S.Fragment,{children:["Open a terminal anywhere and run"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"claude"}),". A planet will appear here within a second."]})}),S.jsx(ta,{n:2,title:"Or seed the demo state",body:S.jsxs(S.Fragment,{children:["In another terminal:"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"solix demo"}),". You'll get 3 planets, a moon, a permission flare, and a pinned advisor — without running Claude Code."]})}),S.jsx(ta,{n:3,title:"Meet the advisor crew",body:S.jsxs(S.Fragment,{children:[c.length>0?`${c.length} crew members loaded. Click any in the inner ring to read their role and invoke them on the focused planet.`:"Crew loading…",c.length>0&&S.jsx("ul",{className:"mt-2 space-y-1",children:c.map(u=>S.jsxs("li",{className:"flex items-baseline gap-2",children:[S.jsxs("span",{className:"font-mono text-xs",style:{color:u.color},children:[u.glyph," ",u.codename]}),S.jsx("span",{className:"text-slate-500 text-xs",children:"—"}),S.jsx("span",{className:"text-slate-300 text-xs",children:u.name})]},u.id))})]})}),S.jsx(ta,{n:4,title:"Browse the asteroid belt",body:S.jsxs(S.Fragment,{children:["Each asteroid is a Skill (",o," discovered). Click one to read its SKILL.md and see which advisors require it."]})}),S.jsx(ta,{n:5,title:"Share your galaxy",body:S.jsxs(S.Fragment,{children:["Press"," ",S.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-black/50 border border-solix-border text-[10px]",children:"G"})," ","or click ",S.jsx("span",{className:"text-solix-accent",children:"⌬ Galaxy"})," ","in the top bar to export, import, publish, or install a galaxy from a registry."]})})]}),S.jsxs("div",{className:"px-6 pb-3 pt-1",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-widest text-slate-500 mb-1.5",children:"Keyboard shortcuts"}),S.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-[11px] text-slate-400",children:[S.jsx(pi,{k:"V",children:"cycle Galaxy → List → Missions"}),S.jsx(pi,{k:"G",children:"toggle Galaxy panel"}),S.jsx(pi,{k:"L",children:"new task"}),S.jsx(pi,{k:"T",children:"timeline"}),S.jsx(pi,{k:"M",children:"jump to Missions"}),S.jsx(pi,{k:"Y",children:"approve top decision"}),S.jsx(pi,{k:"N",children:"deny top decision"}),S.jsx(pi,{k:"Space",children:"play / pause orbits"}),S.jsx(pi,{k:"?",children:"re-open this help"}),S.jsx(pi,{k:"Esc",children:"close panels / exit playback"})]}),S.jsx("div",{className:"text-[10px] text-slate-500 italic mt-2",children:"If clicks feel stuck, a third-party screen overlay (note-taker, recorder) may be intercepting. Quit it temporarily, or use the shortcuts above."})]}),S.jsxs("div",{className:"px-6 py-3 border-t border-solix-border flex items-center gap-2",children:[S.jsx("button",{onClick:()=>{n(),l()},className:"px-3 py-1.5 rounded bg-solix-accent/15 border border-solix-accent/40 text-solix-accent text-xs hover:bg-solix-accent/25",children:"Open Galaxy panel"}),S.jsx("div",{className:"flex-1"}),S.jsx("button",{onClick:l,className:"px-3 py-1.5 rounded border border-solix-border text-xs text-slate-300 hover:text-white",children:"Got it"})]})]})})}function pi({k:n,children:e}){return S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("kbd",{className:"shrink-0 px-1.5 py-0.5 rounded bg-black/50 border border-solix-border text-[10px] font-mono text-slate-300",children:n}),S.jsx("span",{className:"truncate",children:e})]})}function ta({n,title:e,body:t}){return S.jsxs("div",{className:"flex gap-3",children:[S.jsx("div",{className:"shrink-0 w-6 h-6 rounded-full bg-solix-accent/20 border border-solix-accent/40 text-solix-accent text-xs flex items-center justify-center",children:n}),S.jsxs("div",{children:[S.jsx("div",{className:"text-slate-100 font-medium text-sm",children:e}),S.jsx("div",{className:"text-slate-400 text-xs mt-0.5 leading-relaxed",children:t})]})]})}function qE(n,e,t,i){const r=Gh(i,"command"),s=Gh(i,"file_path"),o=Gh(i,"url");if(t==="Bash"&&r){if(/\brm\s+-rf\b/i.test(r)||/\bsudo\b/i.test(r))return{severity:"danger",text:"Destructive command. Deny unless you have already confirmed the diff."};if(/--no-verify\b/.test(r))return{severity:"warn",text:"Skipping pre-commit hooks. Investigate the failure first."};if(/git\s+push.*--force\b/.test(r))return{severity:"danger",text:"Force-push. Confirm no one else has pushed since."};if(/git\s+push/.test(r)&&/\b(main|master|prod|production)\b/.test(r))return{severity:"warn",text:"Pushing to main/prod. Confirm the diff first."};if(/git\s+reset\s+--hard\b/.test(r))return{severity:"warn",text:"Hard reset will discard uncommitted changes. Stash first if unsure."}}if((t==="Edit"||t==="Write"||t==="MultiEdit")&&s){if(/\.env(\b|\.|\/)|credentials\.json|\.pem$|\.key$/i.test(s))return{severity:"danger",text:"Editing a secrets file. Make sure the agent really needs to."};if(/(^|\/)\.git\//.test(s))return{severity:"warn",text:"Editing inside .git/. Almost certainly a mistake."}}if(t==="WebFetch"&&o){if(/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)/.test(o))return null;if(/^http:\/\//.test(o))return{severity:"info",text:"Plain HTTP fetch. OK for known internal hosts."}}return n.contextUsagePct>=90?{severity:"warn",text:`Context at ${n.contextUsagePct.toFixed(0)}%. Run /compact before continuing.`}:null}function ZE(n,e){return n.status==="error"?{severity:"danger",text:"Session is in error state. Check the chat tab and consider restarting."}:n.contextUsagePct>=90?{severity:"warn",text:`Context at ${n.contextUsagePct.toFixed(0)}%. Compact the conversation before the next prompt.`}:n.contextUsagePct>=80?{severity:"info",text:`Context at ${n.contextUsagePct.toFixed(0)}%. Watch out — output quality drops past 90.`}:e&&e.status==="active"&&e.metrics.toolCallCount===0&&Date.now()-e.startedAt>5*60*1e3?{severity:"info",text:"Active mission with no tool calls in 5+ minutes. Agent may be stuck."}:null}function Gh(n,e){const t=n[e];return typeof t=="string"?t:null}function KE(){const n=Ee(u=>u.pendingPermissions),e=Ee(u=>u.sessions),t=Ee(u=>u.missions),i=Ee(u=>u.resolvePermission),r=Ee(u=>u.selectSession),s=Object.values(n).sort((u,d)=>d.receivedAt-u.receivedAt),[o,a]=Ie.useState(!1),l=s.length;Ie.useEffect(()=>{l>0&&a(!1)},[l]);const c=u=>{r(u),a(!0)};return l===0?S.jsx("div",{className:"absolute top-20 right-4 z-30 pointer-events-none",children:S.jsxs("div",{className:"pointer-events-auto rounded-full border border-solix-border bg-solix-panel/60 backdrop-blur px-3 py-1 text-[10px] text-slate-500 flex items-center gap-2",children:[S.jsx("span",{className:"uppercase tracking-widest",children:"decisions"}),S.jsx("span",{className:"font-bold",children:"0"}),S.jsx("span",{className:"italic opacity-80",children:"— all clear"})]})}):S.jsxs("div",{className:"absolute top-20 right-4 z-30 w-80 flex flex-col gap-2 pointer-events-none",children:[S.jsxs("div",{className:"pointer-events-auto rounded border border-solix-border bg-solix-panel/85 backdrop-blur px-3 py-2 flex items-center justify-between",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-[10px] uppercase tracking-widest text-slate-400",children:"Decisions"}),S.jsx("span",{className:"text-xs font-bold text-solix-danger",children:l})]}),S.jsx("button",{onClick:()=>a(u=>!u),className:"text-[10px] text-slate-400 hover:text-slate-100",children:o?"show":"hide"})]}),!o&&s.map(u=>{const d=e[u.sessionId],h=d!=null&&d.currentMissionId?t[d.currentMissionId]:void 0;return S.jsx(JE,{session:d,mission:h,tool:u.tool,args:u.args,onApprove:()=>i(u.requestId,!0),onDeny:()=>i(u.requestId,!1),onAsk:()=>c(u.sessionId)},u.requestId)})]})}function JE({session:n,mission:e,tool:t,args:i,onApprove:r,onDeny:s,onAsk:o}){const a=(n==null?void 0:n.name)??(n==null?void 0:n.id.slice(0,8))??"unknown agent",l=n!=null&&n.cwd?nT(n.cwd):"",c=n?qE(n,e,t,i):null;return S.jsxs("div",{className:"pointer-events-auto rounded border border-solix-danger bg-solix-danger/10 p-3 backdrop-blur shadow-lg",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("div",{className:"text-xs uppercase tracking-wide text-solix-danger",children:a}),l&&S.jsx("div",{className:"text-[10px] text-slate-500 truncate ml-2 max-w-[55%]",children:l})]}),e&&S.jsxs("div",{className:"mt-1 text-[11px] text-slate-400 italic truncate",children:["mission: ",e.shortName]}),S.jsxs("div",{className:"mt-2 text-sm text-slate-100",children:[S.jsx("span",{className:"font-semibold",children:t}),S.jsx("span",{className:"ml-1 text-slate-300 text-xs break-words",children:iT(i)})]}),S.jsx(QE,{tool:t,args:i}),c&&S.jsx(tT,{suggestion:c}),S.jsxs("div",{className:"mt-3 flex gap-1.5",children:[S.jsx("button",{onClick:r,className:"flex-1 py-1.5 rounded bg-solix-ok/20 border border-solix-ok text-solix-ok text-xs hover:bg-solix-ok/30",children:"Approve · Y"}),S.jsx("button",{onClick:s,className:"flex-1 py-1.5 rounded bg-solix-danger/20 border border-solix-danger text-solix-danger text-xs hover:bg-solix-danger/30",children:"Deny · N"}),S.jsx("button",{onClick:o,className:"px-2.5 py-1.5 rounded border border-solix-border text-slate-300 text-xs hover:text-white hover:bg-solix-border/30",title:"Open chat with this agent for context",children:"Ask"})]})]})}function QE({tool:n,args:e}){const[t,i]=Ie.useState(!1);if(n==="Bash"){const r=rr(e,"command")??"",s=rr(e,"description");return r?S.jsxs(Wh,{label:"will run",children:[S.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-[11px] text-slate-100",children:r}),s&&S.jsx("div",{className:"mt-1 text-[10px] text-slate-500 italic",children:s})]}):null}if(n==="Edit"||n==="NotebookEdit"){const r=rr(e,"file_path")??rr(e,"notebook_path"),s=rr(e,"old_string"),o=rr(e,"new_string");return!r&&!s&&!o?null:S.jsxs(Wh,{label:"patch",children:[r&&S.jsx("div",{className:"font-mono text-[11px] text-solix-accent break-all",children:r}),s&&S.jsx(jh,{sign:"-",text:s,expanded:t,colorClass:"text-solix-danger bg-solix-danger/10"}),o&&S.jsx(jh,{sign:"+",text:o,expanded:t,colorClass:"text-solix-ok bg-solix-ok/10"}),(Xh(s)||Xh(o))&&S.jsx("button",{onClick:()=>i(a=>!a),className:"mt-1 text-[10px] text-slate-400 hover:text-slate-100",children:t?"collapse":"expand"})]})}if(n==="Write"){const r=rr(e,"file_path"),s=rr(e,"content")??"";return r?S.jsxs(Wh,{label:"will write",children:[S.jsx("div",{className:"font-mono text-[11px] text-solix-accent break-all",children:r}),s&&S.jsx(jh,{sign:"+",text:s,expanded:t,colorClass:"text-solix-ok bg-solix-ok/10"}),Xh(s)&&S.jsx("button",{onClick:()=>i(o=>!o),className:"mt-1 text-[10px] text-slate-400 hover:text-slate-100",children:t?"collapse":"expand"})]}):null}return null}function Wh({label:n,children:e}){return S.jsxs("div",{className:"mt-2 rounded border border-solix-border bg-black/30 px-2 py-1.5",children:[S.jsx("div",{className:"text-[9px] uppercase tracking-wider text-slate-500 mb-1",children:n}),e]})}function jh({sign:n,text:e,expanded:t,colorClass:i}){const r=t?e:eT(e,240);return S.jsxs("pre",{className:`mt-1 px-1.5 py-1 rounded text-[11px] font-mono whitespace-pre-wrap break-words ${i}`,children:[S.jsx("span",{className:"opacity-50 mr-1",children:n}),r]})}function rr(n,e){const t=n[e];return typeof t=="string"?t:void 0}function Xh(n){return!!(n&&n.length>240)}function eT(n,e){if(n.length<=e)return n;const t=Math.floor((e-3)/2);return`${n.slice(0,t)}
57
57
 
58
58
  ${n.slice(-t)}`}function tT({suggestion:n}){const e=n.severity==="danger"?"text-solix-danger border-solix-danger/40 bg-solix-danger/10":n.severity==="warn"?"text-solix-warn border-solix-warn/40 bg-solix-warn/10":"text-slate-300 border-solix-border bg-black/20";return S.jsxs("div",{className:`mt-2 px-2 py-1 rounded border text-[11px] leading-snug ${e}`,children:[S.jsx("span",{className:"font-semibold mr-1",children:"Suggested:"}),n.text]})}function nT(n){const e=n.match(/[^/\\]+\/?$/);return e?e[0].replace(/\/$/,""):n}function iT(n){const e=Object.keys(n);return e.length?e.slice(0,2).map(i=>{const r=n[i],s=typeof r=="string"?r:JSON.stringify(r);return`${i}=${s.length>40?s.slice(0,40)+"…":s}`}).join(" · "):""}const t0="solix.scenehint.dismissed.v1";function rT(){const n=Ee(o=>o.motionEnabled),e=Ee(o=>o.viewMode),t=Ee(o=>o.toggleMotion),[i,r]=Ie.useState(!0);Ie.useEffect(()=>{try{r(localStorage.getItem(t0)==="1")}catch{}},[]);const s=()=>{try{localStorage.setItem(t0,"1")}catch{}r(!0)};return S.jsxs(S.Fragment,{children:[e==="galaxy"&&!i&&S.jsx("div",{className:"pointer-events-none absolute bottom-4 left-1/2 -translate-x-1/2 z-20",children:S.jsxs("div",{className:"pointer-events-auto rounded-full border border-solix-border bg-solix-panel/85 backdrop-blur px-3 py-1.5 text-[11px] text-slate-300 flex items-center gap-3",children:[S.jsxs("span",{children:[S.jsx("kbd",{className:"px-1 py-0.5 rounded bg-black/40 border border-solix-border text-[10px] mr-1",children:"drag"}),"pan"]}),S.jsxs("span",{children:[S.jsx("kbd",{className:"px-1 py-0.5 rounded bg-black/40 border border-solix-border text-[10px] mr-1",children:"scroll"}),"zoom"]}),S.jsxs("span",{children:[S.jsx("kbd",{className:"px-1 py-0.5 rounded bg-black/40 border border-solix-border text-[10px] mr-1",children:"space"}),"pause"]}),S.jsx("button",{onClick:s,className:"ml-1 text-slate-500 hover:text-slate-100","aria-label":"Dismiss hint",children:"✕"})]})}),S.jsx("div",{className:"pointer-events-none absolute bottom-4 right-4 z-20",children:S.jsx("button",{onClick:t,title:`${n?"Pause":"Play"} orbital motion (Space)`,className:`pointer-events-auto w-10 h-10 rounded-full text-base flex items-center justify-center border backdrop-blur transition-colors ${n?"bg-solix-accent/20 border-solix-accent text-solix-accent":"bg-solix-panel/80 border-solix-border text-slate-300 hover:bg-solix-border/40 hover:text-white"}`,children:n?"⏸":"▶"})})]})}/**
59
59
  * @license
@@ -3897,4 +3897,4 @@ void main() {
3897
3897
 
3898
3898
  }`;class pI{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const r=new Ct,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new ci({vertexShader:hI,fragmentShader:fI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new kt(new Wo(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class mI extends Ti{constructor(e,t){super();const i=this;let r=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,d=null,h=null,p=null,m=null;const y=new pI,g=t.getContextAttributes();let f=null,v=null;const x=[],_=[],R=new K;let M=null;const T=new $t;T.layers.enable(1),T.viewport=new ct;const A=new $t;A.layers.enable(2),A.viewport=new ct;const E=[T,A],w=new xM;w.layers.enable(1),w.layers.enable(2);let L=null,V=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let se=x[j];return se===void 0&&(se=new vf,x[j]=se),se.getTargetRaySpace()},this.getControllerGrip=function(j){let se=x[j];return se===void 0&&(se=new vf,x[j]=se),se.getGripSpace()},this.getHand=function(j){let se=x[j];return se===void 0&&(se=new vf,x[j]=se),se.getHandSpace()};function F(j){const se=_.indexOf(j.inputSource);if(se===-1)return;const xe=x[se];xe!==void 0&&(xe.update(j.inputSource,j.frame,c||o),xe.dispatchEvent({type:j.type,data:j.inputSource}))}function G(){r.removeEventListener("select",F),r.removeEventListener("selectstart",F),r.removeEventListener("selectend",F),r.removeEventListener("squeeze",F),r.removeEventListener("squeezestart",F),r.removeEventListener("squeezeend",F),r.removeEventListener("end",G),r.removeEventListener("inputsourceschange",Y);for(let j=0;j<x.length;j++){const se=_[j];se!==null&&(_[j]=null,x[j].disconnect(se))}L=null,V=null,y.reset(),e.setRenderTarget(f),p=null,h=null,d=null,r=null,v=null,Ke.stop(),i.isPresenting=!1,e.setPixelRatio(M),e.setSize(R.width,R.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){s=j,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){a=j,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(j){c=j},this.getBaseLayer=function(){return h!==null?h:p},this.getBinding=function(){return d},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(j){if(r=j,r!==null){if(f=e.getRenderTarget(),r.addEventListener("select",F),r.addEventListener("selectstart",F),r.addEventListener("selectend",F),r.addEventListener("squeeze",F),r.addEventListener("squeezestart",F),r.addEventListener("squeezeend",F),r.addEventListener("end",G),r.addEventListener("inputsourceschange",Y),g.xrCompatible!==!0&&await t.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(R),r.renderState.layers===void 0){const se={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,se),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),v=new li(p.framebufferWidth,p.framebufferHeight,{format:dn,type:Ei,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil})}else{let se=null,xe=null,de=null;g.depth&&(de=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=g.stencil?ws:ps,xe=g.stencil?Ms:Ji);const De={colorFormat:t.RGBA8,depthFormat:de,scaleFactor:s};d=new XRWebGLBinding(r,t),h=d.createProjectionLayer(De),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),v=new li(h.textureWidth,h.textureHeight,{format:dn,type:Ei,depthTexture:new rg(h.textureWidth,h.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1})}v.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await r.requestReferenceSpace(a),Ke.setContext(r),Ke.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function Y(j){for(let se=0;se<j.removed.length;se++){const xe=j.removed[se],de=_.indexOf(xe);de>=0&&(_[de]=null,x[de].disconnect(xe))}for(let se=0;se<j.added.length;se++){const xe=j.added[se];let de=_.indexOf(xe);if(de===-1){for(let He=0;He<x.length;He++)if(He>=_.length){_.push(xe),de=He;break}else if(_[He]===null){_[He]=xe,de=He;break}if(de===-1)break}const De=x[de];De&&De.connect(xe)}}const W=new I,ne=new I;function D(j,se,xe){W.setFromMatrixPosition(se.matrixWorld),ne.setFromMatrixPosition(xe.matrixWorld);const de=W.distanceTo(ne),De=se.projectionMatrix.elements,He=xe.projectionMatrix.elements,Be=De[14]/(De[10]-1),it=De[14]/(De[10]+1),P=(De[9]+1)/De[5],le=(De[9]-1)/De[5],ie=(De[8]-1)/De[0],ge=(He[8]+1)/He[0],$=Be*ie,Ue=Be*ge,me=de/(-ie+ge),we=me*-ie;if(se.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(we),j.translateZ(me),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert(),De[10]===-1)j.projectionMatrix.copy(se.projectionMatrix),j.projectionMatrixInverse.copy(se.projectionMatrixInverse);else{const N=Be+me,b=it+me,z=$-we,J=Ue+(de-we),Z=P*it/b*N,te=le*it/b*N;j.projectionMatrix.makePerspective(z,J,Z,te,N,b),j.projectionMatrixInverse.copy(j.projectionMatrix).invert()}}function X(j,se){se===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(se.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(r===null)return;let se=j.near,xe=j.far;y.texture!==null&&(y.depthNear>0&&(se=y.depthNear),y.depthFar>0&&(xe=y.depthFar)),w.near=A.near=T.near=se,w.far=A.far=T.far=xe,(L!==w.near||V!==w.far)&&(r.updateRenderState({depthNear:w.near,depthFar:w.far}),L=w.near,V=w.far);const de=j.parent,De=w.cameras;X(w,de);for(let He=0;He<De.length;He++)X(De[He],de);De.length===2?D(w,T,A):w.projectionMatrix.copy(T.projectionMatrix),Q(j,w,de)};function Q(j,se,xe){xe===null?j.matrix.copy(se.matrixWorld):(j.matrix.copy(xe.matrixWorld),j.matrix.invert(),j.matrix.multiply(se.matrixWorld)),j.matrix.decompose(j.position,j.quaternion,j.scale),j.updateMatrixWorld(!0),j.projectionMatrix.copy(se.projectionMatrix),j.projectionMatrixInverse.copy(se.projectionMatrixInverse),j.isPerspectiveCamera&&(j.fov=Uo*2*Math.atan(1/j.projectionMatrix.elements[5]),j.zoom=1)}this.getCamera=function(){return w},this.getFoveation=function(){if(!(h===null&&p===null))return l},this.setFoveation=function(j){l=j,h!==null&&(h.fixedFoveation=j),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=j)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(w)};let oe=null;function Re(j,se){if(u=se.getViewerPose(c||o),m=se,u!==null){const xe=u.views;p!==null&&(e.setRenderTargetFramebuffer(v,p.framebuffer),e.setRenderTarget(v));let de=!1;xe.length!==w.cameras.length&&(w.cameras.length=0,de=!0);for(let He=0;He<xe.length;He++){const Be=xe[He];let it=null;if(p!==null)it=p.getViewport(Be);else{const le=d.getViewSubImage(h,Be);it=le.viewport,He===0&&(e.setRenderTargetTextures(v,le.colorTexture,h.ignoreDepthValues?void 0:le.depthStencilTexture),e.setRenderTarget(v))}let P=E[He];P===void 0&&(P=new $t,P.layers.enable(He),P.viewport=new ct,E[He]=P),P.matrix.fromArray(Be.transform.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale),P.projectionMatrix.fromArray(Be.projectionMatrix),P.projectionMatrixInverse.copy(P.projectionMatrix).invert(),P.viewport.set(it.x,it.y,it.width,it.height),He===0&&(w.matrix.copy(P.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale)),de===!0&&w.cameras.push(P)}const De=r.enabledFeatures;if(De&&De.includes("depth-sensing")){const He=d.getDepthInformation(xe[0]);He&&He.isValid&&He.texture&&y.init(e,He,r.renderState)}}for(let xe=0;xe<x.length;xe++){const de=_[xe],De=x[xe];de!==null&&De!==void 0&&De.update(de,se,c||o)}oe&&oe(j,se),se.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:se}),m=null}const Ke=new dM;Ke.setAnimationLoop(Re),this.setAnimationLoop=function(j){oe=j},this.dispose=function(){}}}const Xr=new On,gI=new ke;function xI(n,e){function t(g,f){g.matrixAutoUpdate===!0&&g.updateMatrix(),f.value.copy(g.matrix)}function i(g,f){f.color.getRGB(g.fogColor.value,aM(n)),f.isFog?(g.fogNear.value=f.near,g.fogFar.value=f.far):f.isFogExp2&&(g.fogDensity.value=f.density)}function r(g,f,v,x,_){f.isMeshBasicMaterial||f.isMeshLambertMaterial?s(g,f):f.isMeshToonMaterial?(s(g,f),d(g,f)):f.isMeshPhongMaterial?(s(g,f),u(g,f)):f.isMeshStandardMaterial?(s(g,f),h(g,f),f.isMeshPhysicalMaterial&&p(g,f,_)):f.isMeshMatcapMaterial?(s(g,f),m(g,f)):f.isMeshDepthMaterial?s(g,f):f.isMeshDistanceMaterial?(s(g,f),y(g,f)):f.isMeshNormalMaterial?s(g,f):f.isLineBasicMaterial?(o(g,f),f.isLineDashedMaterial&&a(g,f)):f.isPointsMaterial?l(g,f,v,x):f.isSpriteMaterial?c(g,f):f.isShadowMaterial?(g.color.value.copy(f.color),g.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(g,f){g.opacity.value=f.opacity,f.color&&g.diffuse.value.copy(f.color),f.emissive&&g.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.bumpMap&&(g.bumpMap.value=f.bumpMap,t(f.bumpMap,g.bumpMapTransform),g.bumpScale.value=f.bumpScale,f.side===fn&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,t(f.normalMap,g.normalMapTransform),g.normalScale.value.copy(f.normalScale),f.side===fn&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,t(f.displacementMap,g.displacementMapTransform),g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,g.emissiveMapTransform)),f.specularMap&&(g.specularMap.value=f.specularMap,t(f.specularMap,g.specularMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);const v=e.get(f),x=v.envMap,_=v.envMapRotation;x&&(g.envMap.value=x,Xr.copy(_),Xr.x*=-1,Xr.y*=-1,Xr.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(Xr.y*=-1,Xr.z*=-1),g.envMapRotation.value.setFromMatrix4(gI.makeRotationFromEuler(Xr)),g.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,g.lightMapTransform)),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,g.aoMapTransform))}function o(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform))}function a(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function l(g,f,v,x){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*v,g.scale.value=x*.5,f.map&&(g.map.value=f.map,t(f.map,g.uvTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function c(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function u(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4)}function d(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap)}function h(g,f){g.metalness.value=f.metalness,f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,g.metalnessMapTransform)),g.roughness.value=f.roughness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,g.roughnessMapTransform)),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function p(g,f,v){g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,g.sheenColorMapTransform)),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,g.sheenRoughnessMapTransform))),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,g.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(g.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===fn&&g.clearcoatNormalScale.value.negate())),f.dispersion>0&&(g.dispersion.value=f.dispersion),f.iridescence>0&&(g.iridescence.value=f.iridescence,g.iridescenceIOR.value=f.iridescenceIOR,g.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(g.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,g.iridescenceMapTransform)),f.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,g.transmissionMapTransform)),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(g.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(g.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,g.specularColorMapTransform)),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,f){f.matcap&&(g.matcap.value=f.matcap)}function y(g,f){const v=e.get(f).light;g.referencePosition.value.setFromMatrixPosition(v.matrixWorld),g.nearDistance.value=v.shadow.camera.near,g.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function vI(n,e,t,i){let r={},s={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,x){const _=x.program;i.uniformBlockBinding(v,_)}function c(v,x){let _=r[v.id];_===void 0&&(m(v),_=u(v),r[v.id]=_,v.addEventListener("dispose",g));const R=x.program;i.updateUBOMapping(v,R);const M=e.render.frame;s[v.id]!==M&&(h(v),s[v.id]=M)}function u(v){const x=d();v.__bindingPointIndex=x;const _=n.createBuffer(),R=v.__size,M=v.usage;return n.bindBuffer(n.UNIFORM_BUFFER,_),n.bufferData(n.UNIFORM_BUFFER,R,M),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,x,_),_}function d(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){const x=r[v.id],_=v.uniforms,R=v.__cache;n.bindBuffer(n.UNIFORM_BUFFER,x);for(let M=0,T=_.length;M<T;M++){const A=Array.isArray(_[M])?_[M]:[_[M]];for(let E=0,w=A.length;E<w;E++){const L=A[E];if(p(L,M,E,R)===!0){const V=L.__offset,F=Array.isArray(L.value)?L.value:[L.value];let G=0;for(let Y=0;Y<F.length;Y++){const W=F[Y],ne=y(W);typeof W=="number"||typeof W=="boolean"?(L.__data[0]=W,n.bufferSubData(n.UNIFORM_BUFFER,V+G,L.__data)):W.isMatrix3?(L.__data[0]=W.elements[0],L.__data[1]=W.elements[1],L.__data[2]=W.elements[2],L.__data[3]=0,L.__data[4]=W.elements[3],L.__data[5]=W.elements[4],L.__data[6]=W.elements[5],L.__data[7]=0,L.__data[8]=W.elements[6],L.__data[9]=W.elements[7],L.__data[10]=W.elements[8],L.__data[11]=0):(W.toArray(L.__data,G),G+=ne.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,V,L.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(v,x,_,R){const M=v.value,T=x+"_"+_;if(R[T]===void 0)return typeof M=="number"||typeof M=="boolean"?R[T]=M:R[T]=M.clone(),!0;{const A=R[T];if(typeof M=="number"||typeof M=="boolean"){if(A!==M)return R[T]=M,!0}else if(A.equals(M)===!1)return A.copy(M),!0}return!1}function m(v){const x=v.uniforms;let _=0;const R=16;for(let T=0,A=x.length;T<A;T++){const E=Array.isArray(x[T])?x[T]:[x[T]];for(let w=0,L=E.length;w<L;w++){const V=E[w],F=Array.isArray(V.value)?V.value:[V.value];for(let G=0,Y=F.length;G<Y;G++){const W=F[G],ne=y(W),D=_%R,X=D%ne.boundary,Q=D+X;_+=X,Q!==0&&R-Q<ne.storage&&(_+=R-Q),V.__data=new Float32Array(ne.storage/Float32Array.BYTES_PER_ELEMENT),V.__offset=_,_+=ne.storage}}}const M=_%R;return M>0&&(_+=R-M),v.__size=_,v.__cache={},this}function y(v){const x={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){const x=v.target;x.removeEventListener("dispose",g);const _=o.indexOf(x.__bindingPointIndex);o.splice(_,1),n.deleteBuffer(r[x.id]),delete r[x.id],delete s[x.id]}function f(){for(const v in r)n.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:l,update:c,dispose:f}}class yI{constructor(e={}){const{canvas:t=iM(),context:i=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let h;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=i.getContextAttributes().alpha}else h=o;const p=new Uint32Array(4),m=new Int32Array(4);let y=null,g=null;const f=[],v=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Hn,this.toneMapping=ji,this.toneMappingExposure=1;const x=this;let _=!1,R=0,M=0,T=null,A=-1,E=null;const w=new ct,L=new ct;let V=null;const F=new ye(0);let G=0,Y=t.width,W=t.height,ne=1,D=null,X=null;const Q=new ct(0,0,Y,W),oe=new ct(0,0,Y,W);let Re=!1;const Ke=new Nl;let j=!1,se=!1;const xe=new ke,de=new I,De=new ct,He={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Be=!1;function it(){return T===null?ne:1}let P=i;function le(C,k){return t.getContext(C,k)}try{const C={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Cd}`),t.addEventListener("webglcontextlost",q,!1),t.addEventListener("webglcontextrestored",ee,!1),t.addEventListener("webglcontextcreationerror",he,!1),P===null){const k="webgl2";if(P=le(k,C),P===null)throw le(k)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(C){throw console.error("THREE.WebGLRenderer: "+C.message),C}let ie,ge,$,Ue,me,we,N,b,z,J,Z,te,Le,pe,Se,We,ae,_e,Je,Ve,be,Ge,qe,vt;function U(){ie=new EP(P),ie.init(),Ge=new gM(P,ie),ge=new yP(P,ie,e,Ge),$=new rI(P),Ue=new CP(P),me=new X2,we=new uI(P,ie,$,me,ge,Ge,Ue),N=new SP(x),b=new bP(x),z=new UA(P),qe=new xP(P,z),J=new TP(P,z,Ue,qe),Z=new PP(P,J,z,Ue),Je=new RP(P,ge,we),We=new _P(me),te=new j2(x,N,b,ie,ge,qe,We),Le=new xI(x,me),pe=new $2,Se=new eI(ie),_e=new gP(x,N,b,$,Z,h,l),ae=new iI(x,Z,ge),vt=new vI(P,Ue,ge,$),Ve=new vP(P,ie,Ue),be=new AP(P,ie,Ue),Ue.programs=te.programs,x.capabilities=ge,x.extensions=ie,x.properties=me,x.renderLists=pe,x.shadowMap=ae,x.state=$,x.info=Ue}U();const ce=new mI(x,P);this.xr=ce,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){const C=ie.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=ie.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(C){C!==void 0&&(ne=C,this.setSize(Y,W,!1))},this.getSize=function(C){return C.set(Y,W)},this.setSize=function(C,k,B=!0){if(ce.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Y=C,W=k,t.width=Math.floor(C*ne),t.height=Math.floor(k*ne),B===!0&&(t.style.width=C+"px",t.style.height=k+"px"),this.setViewport(0,0,C,k)},this.getDrawingBufferSize=function(C){return C.set(Y*ne,W*ne).floor()},this.setDrawingBufferSize=function(C,k,B){Y=C,W=k,ne=B,t.width=Math.floor(C*B),t.height=Math.floor(k*B),this.setViewport(0,0,C,k)},this.getCurrentViewport=function(C){return C.copy(w)},this.getViewport=function(C){return C.copy(Q)},this.setViewport=function(C,k,B,H){C.isVector4?Q.set(C.x,C.y,C.z,C.w):Q.set(C,k,B,H),$.viewport(w.copy(Q).multiplyScalar(ne).round())},this.getScissor=function(C){return C.copy(oe)},this.setScissor=function(C,k,B,H){C.isVector4?oe.set(C.x,C.y,C.z,C.w):oe.set(C,k,B,H),$.scissor(L.copy(oe).multiplyScalar(ne).round())},this.getScissorTest=function(){return Re},this.setScissorTest=function(C){$.setScissorTest(Re=C)},this.setOpaqueSort=function(C){D=C},this.setTransparentSort=function(C){X=C},this.getClearColor=function(C){return C.copy(_e.getClearColor())},this.setClearColor=function(){_e.setClearColor.apply(_e,arguments)},this.getClearAlpha=function(){return _e.getClearAlpha()},this.setClearAlpha=function(){_e.setClearAlpha.apply(_e,arguments)},this.clear=function(C=!0,k=!0,B=!0){let H=0;if(C){let O=!1;if(T!==null){const ue=T.texture.format;O=ue===Ud||ue===Dd||ue===Rl}if(O){const ue=T.texture.type,ve=ue===Ei||ue===Ji||ue===Do||ue===Ms||ue===Id||ue===Nd,Te=_e.getClearColor(),Ae=_e.getClearAlpha(),Fe=Te.r,ze=Te.g,Pe=Te.b;ve?(p[0]=Fe,p[1]=ze,p[2]=Pe,p[3]=Ae,P.clearBufferuiv(P.COLOR,0,p)):(m[0]=Fe,m[1]=ze,m[2]=Pe,m[3]=Ae,P.clearBufferiv(P.COLOR,0,m))}else H|=P.COLOR_BUFFER_BIT}k&&(H|=P.DEPTH_BUFFER_BIT),B&&(H|=P.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),P.clear(H)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",q,!1),t.removeEventListener("webglcontextrestored",ee,!1),t.removeEventListener("webglcontextcreationerror",he,!1),pe.dispose(),Se.dispose(),me.dispose(),N.dispose(),b.dispose(),Z.dispose(),qe.dispose(),vt.dispose(),te.dispose(),ce.dispose(),ce.removeEventListener("sessionstart",hi),ce.removeEventListener("sessionend",Ag),zr.stop()};function q(C){C.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_=!0}function ee(){console.log("THREE.WebGLRenderer: Context Restored."),_=!1;const C=Ue.autoReset,k=ae.enabled,B=ae.autoUpdate,H=ae.needsUpdate,O=ae.type;U(),Ue.autoReset=C,ae.enabled=k,ae.autoUpdate=B,ae.needsUpdate=H,ae.type=O}function he(C){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",C.statusMessage)}function Oe(C){const k=C.target;k.removeEventListener("dispose",Oe),Qe(k)}function Qe(C){It(C),me.remove(C)}function It(C){const k=me.get(C).programs;k!==void 0&&(k.forEach(function(B){te.releaseProgram(B)}),C.isShaderMaterial&&te.releaseShaderCache(C))}this.renderBufferDirect=function(C,k,B,H,O,ue){k===null&&(k=He);const ve=O.isMesh&&O.matrixWorld.determinant()<0,Te=gw(C,k,B,H,O);$.setMaterial(H,ve);let Ae=B.index,Fe=1;if(H.wireframe===!0){if(Ae=J.getWireframeAttribute(B),Ae===void 0)return;Fe=2}const ze=B.drawRange,Pe=B.attributes.position;let ot=ze.start*Fe,wt=(ze.start+ze.count)*Fe;ue!==null&&(ot=Math.max(ot,ue.start*Fe),wt=Math.min(wt,(ue.start+ue.count)*Fe)),Ae!==null?(ot=Math.max(ot,0),wt=Math.min(wt,Ae.count)):Pe!=null&&(ot=Math.max(ot,0),wt=Math.min(wt,Pe.count));const bt=wt-ot;if(bt<0||bt===1/0)return;qe.setup(O,H,Te,B,Ae);let An,at=Ve;if(Ae!==null&&(An=z.get(Ae),at=be,at.setIndex(An)),O.isMesh)H.wireframe===!0?($.setLineWidth(H.wireframeLinewidth*it()),at.setMode(P.LINES)):at.setMode(P.TRIANGLES);else if(O.isLine){let Ne=H.linewidth;Ne===void 0&&(Ne=1),$.setLineWidth(Ne*it()),O.isLineSegments?at.setMode(P.LINES):O.isLineLoop?at.setMode(P.LINE_LOOP):at.setMode(P.LINE_STRIP)}else O.isPoints?at.setMode(P.POINTS):O.isSprite&&at.setMode(P.TRIANGLES);if(O.isBatchedMesh)if(O._multiDrawInstances!==null)at.renderMultiDrawInstances(O._multiDrawStarts,O._multiDrawCounts,O._multiDrawCount,O._multiDrawInstances);else if(ie.get("WEBGL_multi_draw"))at.renderMultiDraw(O._multiDrawStarts,O._multiDrawCounts,O._multiDrawCount);else{const Ne=O._multiDrawStarts,Xt=O._multiDrawCounts,lt=O._multiDrawCount,Zn=Ae?z.get(Ae).bytesPerElement:1,Is=me.get(H).currentProgram.getUniforms();for(let Cn=0;Cn<lt;Cn++)Is.setValue(P,"_gl_DrawID",Cn),at.render(Ne[Cn]/Zn,Xt[Cn])}else if(O.isInstancedMesh)at.renderInstances(ot,bt,O.count);else if(B.isInstancedBufferGeometry){const Ne=B._maxInstanceCount!==void 0?B._maxInstanceCount:1/0,Xt=Math.min(B.instanceCount,Ne);at.renderInstances(ot,bt,Xt)}else at.render(ot,bt)};function jt(C,k,B){C.transparent===!0&&C.side===vi&&C.forceSinglePass===!1?(C.side=fn,C.needsUpdate=!0,Bl(C,k,B),C.side=Zi,C.needsUpdate=!0,Bl(C,k,B),C.side=vi):Bl(C,k,B)}this.compile=function(C,k,B=null){B===null&&(B=C),g=Se.get(B),g.init(k),v.push(g),B.traverseVisible(function(O){O.isLight&&O.layers.test(k.layers)&&(g.pushLight(O),O.castShadow&&g.pushShadow(O))}),C!==B&&C.traverseVisible(function(O){O.isLight&&O.layers.test(k.layers)&&(g.pushLight(O),O.castShadow&&g.pushShadow(O))}),g.setupLights();const H=new Set;return C.traverse(function(O){const ue=O.material;if(ue)if(Array.isArray(ue))for(let ve=0;ve<ue.length;ve++){const Te=ue[ve];jt(Te,B,O),H.add(Te)}else jt(ue,B,O),H.add(ue)}),v.pop(),g=null,H},this.compileAsync=function(C,k,B=null){const H=this.compile(C,k,B);return new Promise(O=>{function ue(){if(H.forEach(function(ve){me.get(ve).currentProgram.isReady()&&H.delete(ve)}),H.size===0){O(C);return}setTimeout(ue,10)}ie.get("KHR_parallel_shader_compile")!==null?ue():setTimeout(ue,10)})};let st=null;function Ci(C){st&&st(C)}function hi(){zr.stop()}function Ag(){zr.start()}const zr=new dM;zr.setAnimationLoop(Ci),typeof self<"u"&&zr.setContext(self),this.setAnimationLoop=function(C){st=C,ce.setAnimationLoop(C),C===null?zr.stop():zr.start()},ce.addEventListener("sessionstart",hi),ce.addEventListener("sessionend",Ag),this.render=function(C,k){if(k!==void 0&&k.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_===!0)return;if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),k.parent===null&&k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),ce.enabled===!0&&ce.isPresenting===!0&&(ce.cameraAutoUpdate===!0&&ce.updateCamera(k),k=ce.getCamera()),C.isScene===!0&&C.onBeforeRender(x,C,k,T),g=Se.get(C,v.length),g.init(k),v.push(g),xe.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),Ke.setFromProjectionMatrix(xe),se=this.localClippingEnabled,j=We.init(this.clippingPlanes,se),y=pe.get(C,f.length),y.init(),f.push(y),ce.enabled===!0&&ce.isPresenting===!0){const ue=x.xr.getDepthSensingMesh();ue!==null&&uh(ue,k,-1/0,x.sortObjects)}uh(C,k,0,x.sortObjects),y.finish(),x.sortObjects===!0&&y.sort(D,X),Be=ce.enabled===!1||ce.isPresenting===!1||ce.hasDepthSensing()===!1,Be&&_e.addToRenderList(y,C),this.info.render.frame++,j===!0&&We.beginShadows();const B=g.state.shadowsArray;ae.render(B,C,k),j===!0&&We.endShadows(),this.info.autoReset===!0&&this.info.reset();const H=y.opaque,O=y.transmissive;if(g.setupLights(),k.isArrayCamera){const ue=k.cameras;if(O.length>0)for(let ve=0,Te=ue.length;ve<Te;ve++){const Ae=ue[ve];Rg(H,O,C,Ae)}Be&&_e.render(C);for(let ve=0,Te=ue.length;ve<Te;ve++){const Ae=ue[ve];Cg(y,C,Ae,Ae.viewport)}}else O.length>0&&Rg(H,O,C,k),Be&&_e.render(C),Cg(y,C,k);T!==null&&(we.updateMultisampleRenderTarget(T),we.updateRenderTargetMipmap(T)),C.isScene===!0&&C.onAfterRender(x,C,k),qe.resetDefaultState(),A=-1,E=null,v.pop(),v.length>0?(g=v[v.length-1],j===!0&&We.setGlobalState(x.clippingPlanes,g.state.camera)):g=null,f.pop(),f.length>0?y=f[f.length-1]:y=null};function uh(C,k,B,H){if(C.visible===!1)return;if(C.layers.test(k.layers)){if(C.isGroup)B=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(k);else if(C.isLight)g.pushLight(C),C.castShadow&&g.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Ke.intersectsSprite(C)){H&&De.setFromMatrixPosition(C.matrixWorld).applyMatrix4(xe);const ve=Z.update(C),Te=C.material;Te.visible&&y.push(C,ve,Te,B,De.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Ke.intersectsObject(C))){const ve=Z.update(C),Te=C.material;if(H&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),De.copy(C.boundingSphere.center)):(ve.boundingSphere===null&&ve.computeBoundingSphere(),De.copy(ve.boundingSphere.center)),De.applyMatrix4(C.matrixWorld).applyMatrix4(xe)),Array.isArray(Te)){const Ae=ve.groups;for(let Fe=0,ze=Ae.length;Fe<ze;Fe++){const Pe=Ae[Fe],ot=Te[Pe.materialIndex];ot&&ot.visible&&y.push(C,ve,ot,B,De.z,Pe)}}else Te.visible&&y.push(C,ve,Te,B,De.z,null)}}const ue=C.children;for(let ve=0,Te=ue.length;ve<Te;ve++)uh(ue[ve],k,B,H)}function Cg(C,k,B,H){const O=C.opaque,ue=C.transmissive,ve=C.transparent;g.setupLightsView(B),j===!0&&We.setGlobalState(x.clippingPlanes,B),H&&$.viewport(w.copy(H)),O.length>0&&Fl(O,k,B),ue.length>0&&Fl(ue,k,B),ve.length>0&&Fl(ve,k,B),$.buffers.depth.setTest(!0),$.buffers.depth.setMask(!0),$.buffers.color.setMask(!0),$.setPolygonOffset(!1)}function Rg(C,k,B,H){if((B.isScene===!0?B.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[H.id]===void 0&&(g.state.transmissionRenderTarget[H.id]=new li(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")||ie.has("EXT_color_buffer_float")?Ho:Ei,minFilter:yi,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:rt.workingColorSpace}));const ue=g.state.transmissionRenderTarget[H.id],ve=H.viewport||w;ue.setSize(ve.z,ve.w);const Te=x.getRenderTarget();x.setRenderTarget(ue),x.getClearColor(F),G=x.getClearAlpha(),G<1&&x.setClearColor(16777215,.5),x.clear(),Be&&_e.render(B);const Ae=x.toneMapping;x.toneMapping=ji;const Fe=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),g.setupLightsView(H),j===!0&&We.setGlobalState(x.clippingPlanes,H),Fl(C,B,H),we.updateMultisampleRenderTarget(ue),we.updateRenderTargetMipmap(ue),ie.has("WEBGL_multisampled_render_to_texture")===!1){let ze=!1;for(let Pe=0,ot=k.length;Pe<ot;Pe++){const wt=k[Pe],bt=wt.object,An=wt.geometry,at=wt.material,Ne=wt.group;if(at.side===vi&&bt.layers.test(H.layers)){const Xt=at.side;at.side=fn,at.needsUpdate=!0,Pg(bt,B,H,An,at,Ne),at.side=Xt,at.needsUpdate=!0,ze=!0}}ze===!0&&(we.updateMultisampleRenderTarget(ue),we.updateRenderTargetMipmap(ue))}x.setRenderTarget(Te),x.setClearColor(F,G),Fe!==void 0&&(H.viewport=Fe),x.toneMapping=Ae}function Fl(C,k,B){const H=k.isScene===!0?k.overrideMaterial:null;for(let O=0,ue=C.length;O<ue;O++){const ve=C[O],Te=ve.object,Ae=ve.geometry,Fe=H===null?ve.material:H,ze=ve.group;Te.layers.test(B.layers)&&Pg(Te,k,B,Ae,Fe,ze)}}function Pg(C,k,B,H,O,ue){C.onBeforeRender(x,k,B,H,O,ue),C.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix),O.onBeforeRender(x,k,B,H,C,ue),O.transparent===!0&&O.side===vi&&O.forceSinglePass===!1?(O.side=fn,O.needsUpdate=!0,x.renderBufferDirect(B,k,H,O,C,ue),O.side=Zi,O.needsUpdate=!0,x.renderBufferDirect(B,k,H,O,C,ue),O.side=vi):x.renderBufferDirect(B,k,H,O,C,ue),C.onAfterRender(x,k,B,H,O,ue)}function Bl(C,k,B){k.isScene!==!0&&(k=He);const H=me.get(C),O=g.state.lights,ue=g.state.shadowsArray,ve=O.state.version,Te=te.getParameters(C,O.state,ue,k,B),Ae=te.getProgramCacheKey(Te);let Fe=H.programs;H.environment=C.isMeshStandardMaterial?k.environment:null,H.fog=k.fog,H.envMap=(C.isMeshStandardMaterial?b:N).get(C.envMap||H.environment),H.envMapRotation=H.environment!==null&&C.envMap===null?k.environmentRotation:C.envMapRotation,Fe===void 0&&(C.addEventListener("dispose",Oe),Fe=new Map,H.programs=Fe);let ze=Fe.get(Ae);if(ze!==void 0){if(H.currentProgram===ze&&H.lightsStateVersion===ve)return Ng(C,Te),ze}else Te.uniforms=te.getUniforms(C),C.onBeforeCompile(Te,x),ze=te.acquireProgram(Te,Ae),Fe.set(Ae,ze),H.uniforms=Te.uniforms;const Pe=H.uniforms;return(!C.isShaderMaterial&&!C.isRawShaderMaterial||C.clipping===!0)&&(Pe.clippingPlanes=We.uniform),Ng(C,Te),H.needsLights=vw(C),H.lightsStateVersion=ve,H.needsLights&&(Pe.ambientLightColor.value=O.state.ambient,Pe.lightProbe.value=O.state.probe,Pe.directionalLights.value=O.state.directional,Pe.directionalLightShadows.value=O.state.directionalShadow,Pe.spotLights.value=O.state.spot,Pe.spotLightShadows.value=O.state.spotShadow,Pe.rectAreaLights.value=O.state.rectArea,Pe.ltc_1.value=O.state.rectAreaLTC1,Pe.ltc_2.value=O.state.rectAreaLTC2,Pe.pointLights.value=O.state.point,Pe.pointLightShadows.value=O.state.pointShadow,Pe.hemisphereLights.value=O.state.hemi,Pe.directionalShadowMap.value=O.state.directionalShadowMap,Pe.directionalShadowMatrix.value=O.state.directionalShadowMatrix,Pe.spotShadowMap.value=O.state.spotShadowMap,Pe.spotLightMatrix.value=O.state.spotLightMatrix,Pe.spotLightMap.value=O.state.spotLightMap,Pe.pointShadowMap.value=O.state.pointShadowMap,Pe.pointShadowMatrix.value=O.state.pointShadowMatrix),H.currentProgram=ze,H.uniformsList=null,ze}function Ig(C){if(C.uniformsList===null){const k=C.currentProgram.getUniforms();C.uniformsList=lu.seqWithValue(k.seq,C.uniforms)}return C.uniformsList}function Ng(C,k){const B=me.get(C);B.outputColorSpace=k.outputColorSpace,B.batching=k.batching,B.batchingColor=k.batchingColor,B.instancing=k.instancing,B.instancingColor=k.instancingColor,B.instancingMorph=k.instancingMorph,B.skinning=k.skinning,B.morphTargets=k.morphTargets,B.morphNormals=k.morphNormals,B.morphColors=k.morphColors,B.morphTargetsCount=k.morphTargetsCount,B.numClippingPlanes=k.numClippingPlanes,B.numIntersection=k.numClipIntersection,B.vertexAlphas=k.vertexAlphas,B.vertexTangents=k.vertexTangents,B.toneMapping=k.toneMapping}function gw(C,k,B,H,O){k.isScene!==!0&&(k=He),we.resetTextureUnits();const ue=k.fog,ve=H.isMeshStandardMaterial?k.environment:null,Te=T===null?x.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:tr,Ae=(H.isMeshStandardMaterial?b:N).get(H.envMap||ve),Fe=H.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,ze=!!B.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Pe=!!B.morphAttributes.position,ot=!!B.morphAttributes.normal,wt=!!B.morphAttributes.color;let bt=ji;H.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(bt=x.toneMapping);const An=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,at=An!==void 0?An.length:0,Ne=me.get(H),Xt=g.state.lights;if(j===!0&&(se===!0||C!==E)){const zn=C===E&&H.id===A;We.setState(H,C,zn)}let lt=!1;H.version===Ne.__version?(Ne.needsLights&&Ne.lightsStateVersion!==Xt.state.version||Ne.outputColorSpace!==Te||O.isBatchedMesh&&Ne.batching===!1||!O.isBatchedMesh&&Ne.batching===!0||O.isBatchedMesh&&Ne.batchingColor===!0&&O.colorTexture===null||O.isBatchedMesh&&Ne.batchingColor===!1&&O.colorTexture!==null||O.isInstancedMesh&&Ne.instancing===!1||!O.isInstancedMesh&&Ne.instancing===!0||O.isSkinnedMesh&&Ne.skinning===!1||!O.isSkinnedMesh&&Ne.skinning===!0||O.isInstancedMesh&&Ne.instancingColor===!0&&O.instanceColor===null||O.isInstancedMesh&&Ne.instancingColor===!1&&O.instanceColor!==null||O.isInstancedMesh&&Ne.instancingMorph===!0&&O.morphTexture===null||O.isInstancedMesh&&Ne.instancingMorph===!1&&O.morphTexture!==null||Ne.envMap!==Ae||H.fog===!0&&Ne.fog!==ue||Ne.numClippingPlanes!==void 0&&(Ne.numClippingPlanes!==We.numPlanes||Ne.numIntersection!==We.numIntersection)||Ne.vertexAlphas!==Fe||Ne.vertexTangents!==ze||Ne.morphTargets!==Pe||Ne.morphNormals!==ot||Ne.morphColors!==wt||Ne.toneMapping!==bt||Ne.morphTargetsCount!==at)&&(lt=!0):(lt=!0,Ne.__version=H.version);let Zn=Ne.currentProgram;lt===!0&&(Zn=Bl(H,k,O));let Is=!1,Cn=!1,dh=!1;const Nt=Zn.getUniforms(),nr=Ne.uniforms;if($.useProgram(Zn.program)&&(Is=!0,Cn=!0,dh=!0),H.id!==A&&(A=H.id,Cn=!0),Is||E!==C){Nt.setValue(P,"projectionMatrix",C.projectionMatrix),Nt.setValue(P,"viewMatrix",C.matrixWorldInverse);const zn=Nt.map.cameraPosition;zn!==void 0&&zn.setValue(P,de.setFromMatrixPosition(C.matrixWorld)),ge.logarithmicDepthBuffer&&Nt.setValue(P,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Nt.setValue(P,"isOrthographic",C.isOrthographicCamera===!0),E!==C&&(E=C,Cn=!0,dh=!0)}if(O.isSkinnedMesh){Nt.setOptional(P,O,"bindMatrix"),Nt.setOptional(P,O,"bindMatrixInverse");const zn=O.skeleton;zn&&(zn.boneTexture===null&&zn.computeBoneTexture(),Nt.setValue(P,"boneTexture",zn.boneTexture,we))}O.isBatchedMesh&&(Nt.setOptional(P,O,"batchingTexture"),Nt.setValue(P,"batchingTexture",O._matricesTexture,we),Nt.setOptional(P,O,"batchingIdTexture"),Nt.setValue(P,"batchingIdTexture",O._indirectTexture,we),Nt.setOptional(P,O,"batchingColorTexture"),O._colorsTexture!==null&&Nt.setValue(P,"batchingColorTexture",O._colorsTexture,we));const hh=B.morphAttributes;if((hh.position!==void 0||hh.normal!==void 0||hh.color!==void 0)&&Je.update(O,B,Zn),(Cn||Ne.receiveShadow!==O.receiveShadow)&&(Ne.receiveShadow=O.receiveShadow,Nt.setValue(P,"receiveShadow",O.receiveShadow)),H.isMeshGouraudMaterial&&H.envMap!==null&&(nr.envMap.value=Ae,nr.flipEnvMap.value=Ae.isCubeTexture&&Ae.isRenderTargetTexture===!1?-1:1),H.isMeshStandardMaterial&&H.envMap===null&&k.environment!==null&&(nr.envMapIntensity.value=k.environmentIntensity),Cn&&(Nt.setValue(P,"toneMappingExposure",x.toneMappingExposure),Ne.needsLights&&xw(nr,dh),ue&&H.fog===!0&&Le.refreshFogUniforms(nr,ue),Le.refreshMaterialUniforms(nr,H,ne,W,g.state.transmissionRenderTarget[C.id]),lu.upload(P,Ig(Ne),nr,we)),H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(lu.upload(P,Ig(Ne),nr,we),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Nt.setValue(P,"center",O.center),Nt.setValue(P,"modelViewMatrix",O.modelViewMatrix),Nt.setValue(P,"normalMatrix",O.normalMatrix),Nt.setValue(P,"modelMatrix",O.matrixWorld),H.isShaderMaterial||H.isRawShaderMaterial){const zn=H.uniformsGroups;for(let fh=0,yw=zn.length;fh<yw;fh++){const Lg=zn[fh];vt.update(Lg,Zn),vt.bind(Lg,Zn)}}return Zn}function xw(C,k){C.ambientLightColor.needsUpdate=k,C.lightProbe.needsUpdate=k,C.directionalLights.needsUpdate=k,C.directionalLightShadows.needsUpdate=k,C.pointLights.needsUpdate=k,C.pointLightShadows.needsUpdate=k,C.spotLights.needsUpdate=k,C.spotLightShadows.needsUpdate=k,C.rectAreaLights.needsUpdate=k,C.hemisphereLights.needsUpdate=k}function vw(C){return C.isMeshLambertMaterial||C.isMeshToonMaterial||C.isMeshPhongMaterial||C.isMeshStandardMaterial||C.isShadowMaterial||C.isShaderMaterial&&C.lights===!0}this.getActiveCubeFace=function(){return R},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(C,k,B){me.get(C.texture).__webglTexture=k,me.get(C.depthTexture).__webglTexture=B;const H=me.get(C);H.__hasExternalTextures=!0,H.__autoAllocateDepthBuffer=B===void 0,H.__autoAllocateDepthBuffer||ie.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),H.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(C,k){const B=me.get(C);B.__webglFramebuffer=k,B.__useDefaultFramebuffer=k===void 0},this.setRenderTarget=function(C,k=0,B=0){T=C,R=k,M=B;let H=!0,O=null,ue=!1,ve=!1;if(C){const Ae=me.get(C);if(Ae.__useDefaultFramebuffer!==void 0)$.bindFramebuffer(P.FRAMEBUFFER,null),H=!1;else if(Ae.__webglFramebuffer===void 0)we.setupRenderTarget(C);else if(Ae.__hasExternalTextures)we.rebindTextures(C,me.get(C.texture).__webglTexture,me.get(C.depthTexture).__webglTexture);else if(C.depthBuffer){const Pe=C.depthTexture;if(Ae.__boundDepthTexture!==Pe){if(Pe!==null&&me.has(Pe)&&(C.width!==Pe.image.width||C.height!==Pe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");we.setupDepthRenderbuffer(C)}}const Fe=C.texture;(Fe.isData3DTexture||Fe.isDataArrayTexture||Fe.isCompressedArrayTexture)&&(ve=!0);const ze=me.get(C).__webglFramebuffer;C.isWebGLCubeRenderTarget?(Array.isArray(ze[k])?O=ze[k][B]:O=ze[k],ue=!0):C.samples>0&&we.useMultisampledRTT(C)===!1?O=me.get(C).__webglMultisampledFramebuffer:Array.isArray(ze)?O=ze[B]:O=ze,w.copy(C.viewport),L.copy(C.scissor),V=C.scissorTest}else w.copy(Q).multiplyScalar(ne).floor(),L.copy(oe).multiplyScalar(ne).floor(),V=Re;if($.bindFramebuffer(P.FRAMEBUFFER,O)&&H&&$.drawBuffers(C,O),$.viewport(w),$.scissor(L),$.setScissorTest(V),ue){const Ae=me.get(C.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+k,Ae.__webglTexture,B)}else if(ve){const Ae=me.get(C.texture),Fe=k||0;P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,Ae.__webglTexture,B||0,Fe)}A=-1},this.readRenderTargetPixels=function(C,k,B,H,O,ue,ve){if(!(C&&C.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=me.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&ve!==void 0&&(Te=Te[ve]),Te){$.bindFramebuffer(P.FRAMEBUFFER,Te);try{const Ae=C.texture,Fe=Ae.format,ze=Ae.type;if(!ge.textureFormatReadable(Fe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ge.textureTypeReadable(ze)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}k>=0&&k<=C.width-H&&B>=0&&B<=C.height-O&&P.readPixels(k,B,H,O,Ge.convert(Fe),Ge.convert(ze),ue)}finally{const Ae=T!==null?me.get(T).__webglFramebuffer:null;$.bindFramebuffer(P.FRAMEBUFFER,Ae)}}},this.readRenderTargetPixelsAsync=async function(C,k,B,H,O,ue,ve){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=me.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&ve!==void 0&&(Te=Te[ve]),Te){$.bindFramebuffer(P.FRAMEBUFFER,Te);try{const Ae=C.texture,Fe=Ae.format,ze=Ae.type;if(!ge.textureFormatReadable(Fe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ge.textureTypeReadable(ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(k>=0&&k<=C.width-H&&B>=0&&B<=C.height-O){const Pe=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,Pe),P.bufferData(P.PIXEL_PACK_BUFFER,ue.byteLength,P.STREAM_READ),P.readPixels(k,B,H,O,Ge.convert(Fe),Ge.convert(ze),0),P.flush();const ot=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);await oA(P,ot,4);try{P.bindBuffer(P.PIXEL_PACK_BUFFER,Pe),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,ue)}finally{P.deleteBuffer(Pe),P.deleteSync(ot)}return ue}}finally{const Ae=T!==null?me.get(T).__webglFramebuffer:null;$.bindFramebuffer(P.FRAMEBUFFER,Ae)}}},this.copyFramebufferToTexture=function(C,k=null,B=0){C.isTexture!==!0&&(bo("WebGLRenderer: copyFramebufferToTexture function signature has changed."),k=arguments[0]||null,C=arguments[1]);const H=Math.pow(2,-B),O=Math.floor(C.image.width*H),ue=Math.floor(C.image.height*H),ve=k!==null?k.x:0,Te=k!==null?k.y:0;we.setTexture2D(C,0),P.copyTexSubImage2D(P.TEXTURE_2D,B,0,0,ve,Te,O,ue),$.unbindTexture()},this.copyTextureToTexture=function(C,k,B=null,H=null,O=0){C.isTexture!==!0&&(bo("WebGLRenderer: copyTextureToTexture function signature has changed."),H=arguments[0]||null,C=arguments[1],k=arguments[2],O=arguments[3]||0,B=null);let ue,ve,Te,Ae,Fe,ze;B!==null?(ue=B.max.x-B.min.x,ve=B.max.y-B.min.y,Te=B.min.x,Ae=B.min.y):(ue=C.image.width,ve=C.image.height,Te=0,Ae=0),H!==null?(Fe=H.x,ze=H.y):(Fe=0,ze=0);const Pe=Ge.convert(k.format),ot=Ge.convert(k.type);we.setTexture2D(k,0),P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,k.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,k.unpackAlignment);const wt=P.getParameter(P.UNPACK_ROW_LENGTH),bt=P.getParameter(P.UNPACK_IMAGE_HEIGHT),An=P.getParameter(P.UNPACK_SKIP_PIXELS),at=P.getParameter(P.UNPACK_SKIP_ROWS),Ne=P.getParameter(P.UNPACK_SKIP_IMAGES),Xt=C.isCompressedTexture?C.mipmaps[O]:C.image;P.pixelStorei(P.UNPACK_ROW_LENGTH,Xt.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Xt.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Te),P.pixelStorei(P.UNPACK_SKIP_ROWS,Ae),C.isDataTexture?P.texSubImage2D(P.TEXTURE_2D,O,Fe,ze,ue,ve,Pe,ot,Xt.data):C.isCompressedTexture?P.compressedTexSubImage2D(P.TEXTURE_2D,O,Fe,ze,Xt.width,Xt.height,Pe,Xt.data):P.texSubImage2D(P.TEXTURE_2D,O,Fe,ze,ue,ve,Pe,ot,Xt),P.pixelStorei(P.UNPACK_ROW_LENGTH,wt),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,bt),P.pixelStorei(P.UNPACK_SKIP_PIXELS,An),P.pixelStorei(P.UNPACK_SKIP_ROWS,at),P.pixelStorei(P.UNPACK_SKIP_IMAGES,Ne),O===0&&k.generateMipmaps&&P.generateMipmap(P.TEXTURE_2D),$.unbindTexture()},this.copyTextureToTexture3D=function(C,k,B=null,H=null,O=0){C.isTexture!==!0&&(bo("WebGLRenderer: copyTextureToTexture3D function signature has changed."),B=arguments[0]||null,H=arguments[1]||null,C=arguments[2],k=arguments[3],O=arguments[4]||0);let ue,ve,Te,Ae,Fe,ze,Pe,ot,wt;const bt=C.isCompressedTexture?C.mipmaps[O]:C.image;B!==null?(ue=B.max.x-B.min.x,ve=B.max.y-B.min.y,Te=B.max.z-B.min.z,Ae=B.min.x,Fe=B.min.y,ze=B.min.z):(ue=bt.width,ve=bt.height,Te=bt.depth,Ae=0,Fe=0,ze=0),H!==null?(Pe=H.x,ot=H.y,wt=H.z):(Pe=0,ot=0,wt=0);const An=Ge.convert(k.format),at=Ge.convert(k.type);let Ne;if(k.isData3DTexture)we.setTexture3D(k,0),Ne=P.TEXTURE_3D;else if(k.isDataArrayTexture||k.isCompressedArrayTexture)we.setTexture2DArray(k,0),Ne=P.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,k.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,k.unpackAlignment);const Xt=P.getParameter(P.UNPACK_ROW_LENGTH),lt=P.getParameter(P.UNPACK_IMAGE_HEIGHT),Zn=P.getParameter(P.UNPACK_SKIP_PIXELS),Is=P.getParameter(P.UNPACK_SKIP_ROWS),Cn=P.getParameter(P.UNPACK_SKIP_IMAGES);P.pixelStorei(P.UNPACK_ROW_LENGTH,bt.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,bt.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Ae),P.pixelStorei(P.UNPACK_SKIP_ROWS,Fe),P.pixelStorei(P.UNPACK_SKIP_IMAGES,ze),C.isDataTexture||C.isData3DTexture?P.texSubImage3D(Ne,O,Pe,ot,wt,ue,ve,Te,An,at,bt.data):k.isCompressedArrayTexture?P.compressedTexSubImage3D(Ne,O,Pe,ot,wt,ue,ve,Te,An,bt.data):P.texSubImage3D(Ne,O,Pe,ot,wt,ue,ve,Te,An,at,bt),P.pixelStorei(P.UNPACK_ROW_LENGTH,Xt),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,lt),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Zn),P.pixelStorei(P.UNPACK_SKIP_ROWS,Is),P.pixelStorei(P.UNPACK_SKIP_IMAGES,Cn),O===0&&k.generateMipmaps&&P.generateMipmap(Ne),$.unbindTexture()},this.initRenderTarget=function(C){me.get(C).__webglFramebuffer===void 0&&we.setupRenderTarget(C)},this.initTexture=function(C){C.isCubeTexture?we.setTextureCube(C,0):C.isData3DTexture?we.setTexture3D(C,0):C.isDataArrayTexture||C.isCompressedArrayTexture?we.setTexture2DArray(C,0):we.setTexture2D(C,0),$.unbindTexture()},this.resetState=function(){R=0,M=0,T=null,$.reset(),qe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return _i}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Od?"display-p3":"srgb",t.unpackColorSpace=rt.workingColorSpace===Pl?"display-p3":"srgb"}}class Gd{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ye(e),this.density=t}clone(){return new Gd(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Wd{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new ye(e),this.near=t,this.far=i}clone(){return new Wd(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}let vM=class extends nt{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 On,this.environmentIntensity=1,this.environmentRotation=new On,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 jd{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=hl,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Un()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return bo("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}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,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Un()),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]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}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=Un()),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 an=new I;class bs{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)an.fromBufferAttribute(this,t),an.applyMatrix4(e),this.setXYZ(t,an.x,an.y,an.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)an.fromBufferAttribute(this,t),an.applyNormalMatrix(e),this.setXYZ(t,an.x,an.y,an.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)an.fromBufferAttribute(this,t),an.transformDirection(e),this.setXYZ(t,an.x,an.y,an.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=un(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Xe(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=Xe(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Xe(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Xe(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Xe(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=un(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=un(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=un(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=un(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Xe(t,this.array),i=Xe(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Xe(t,this.array),i=Xe(i,this.array),r=Xe(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Xe(t,this.array),i=Xe(i,this.array),r=Xe(r,this.array),s=Xe(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,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 i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new ht(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 bs(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 i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class ag extends on{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ye(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 qs;const aa=new I,Zs=new I,Ks=new I,Js=new K,la=new K,yM=new ke,bc=new I,ca=new I,Ec=new I,W0=new K,yf=new K,j0=new K;class _M extends nt{constructor(e=new ag){if(super(),this.isSprite=!0,this.type="Sprite",qs===void 0){qs=new $e;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new jd(t,5);qs.setIndex([0,1,2,0,2,3]),qs.setAttribute("position",new bs(i,3,0,!1)),qs.setAttribute("uv",new bs(i,2,3,!1))}this.geometry=qs,this.material=e,this.center=new K(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Zs.setFromMatrixScale(this.matrixWorld),yM.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ks.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Zs.multiplyScalar(-Ks.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const o=this.center;Tc(bc.set(-.5,-.5,0),Ks,o,Zs,r,s),Tc(ca.set(.5,-.5,0),Ks,o,Zs,r,s),Tc(Ec.set(.5,.5,0),Ks,o,Zs,r,s),W0.set(0,0),yf.set(1,0),j0.set(1,1);let a=e.ray.intersectTriangle(bc,ca,Ec,!1,aa);if(a===null&&(Tc(ca.set(-.5,.5,0),Ks,o,Zs,r,s),yf.set(0,1),a=e.ray.intersectTriangle(bc,Ec,ca,!1,aa),a===null))return;const l=e.ray.origin.distanceTo(aa);l<e.near||l>e.far||t.push({distance:l,point:aa.clone(),uv:Nn.getInterpolation(aa,bc,ca,Ec,W0,yf,j0,new K),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 Tc(n,e,t,i,r,s){Js.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(la.x=s*Js.x-r*Js.y,la.y=r*Js.x+s*Js.y):la.copy(Js),n.copy(e),n.x+=la.x,n.y+=la.y,n.applyMatrix4(yM)}const Ac=new I,X0=new I;class SM extends nt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const r=this.levels;let s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Ac.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(Ac);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Ac.setFromMatrixPosition(e.matrixWorld),X0.setFromMatrixPosition(this.matrixWorld);const i=Ac.distanceTo(X0)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let o=t[r].distance;if(t[r].object.visible&&(o-=o*t[r].hysteresis),i>=o)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let r=0,s=i.length;r<s;r++){const o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}}const Y0=new I,$0=new ct,q0=new ct,_I=new I,Z0=new ke,Cc=new I,_f=new rn,K0=new ke,Sf=new Go;class MM extends kt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Ip,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 pn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Cc),this.boundingBox.expandByPoint(Cc)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new rn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Cc),this.boundingSphere.expandByPoint(Cc)}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 i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),_f.copy(this.boundingSphere),_f.applyMatrix4(r),e.ray.intersectsSphere(_f)!==!1&&(K0.copy(r).invert(),Sf.copy(e.ray).applyMatrix4(K0),!(this.boundingBox!==null&&Sf.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Sf)))}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 ct,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Ip?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===HS?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;$0.fromBufferAttribute(r.attributes.skinIndex,e),q0.fromBufferAttribute(r.attributes.skinWeight,e),Y0.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const o=q0.getComponent(s);if(o!==0){const a=$0.getComponent(s);Z0.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(_I.copy(Y0).applyMatrix4(Z0),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}class lg extends nt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class wi extends Ct{constructor(e=null,t=1,i=1,r,s,o,a,l,c=Gt,u=Gt,d,h){super(null,o,a,l,c,u,r,s,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const J0=new ke,SI=new ke;class Xd{constructor(e=[],t=[]){this.uuid=Un(),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 i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new ke)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new ke;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){const a=e[s]?e[s].matrixWorld:SI;J0.multiplyMatrices(a,t[s]),J0.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Xd(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 i=new wi(t,e,e,dn,Sn);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const s=e.bones[i];let o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new lg),this.bones.push(o),this.boneInverses.push(new ke().fromArray(e.boneInverses[i]))}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,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const o=t[r];e.bones.push(o.uuid);const a=i[r];e.boneInverses.push(a.toArray())}return e}}class Oo extends ht{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Qs=new ke,Q0=new ke,Rc=[],ev=new pn,MI=new ke,ua=new kt,da=new rn;class wM extends kt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Oo(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,MI)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new pn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Qs),ev.copy(e.boundingBox).applyMatrix4(Qs),this.boundingBox.union(ev)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new rn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Qs),da.copy(e.boundingSphere).applyMatrix4(Qs),this.boundingSphere.union(da)}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 i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=i.length+1,o=e*s+1;for(let a=0;a<i.length;a++)i[a]=r[o+a]}raycast(e,t){const i=this.matrixWorld,r=this.count;if(ua.geometry=this.geometry,ua.material=this.material,ua.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),da.copy(this.boundingSphere),da.applyMatrix4(i),e.ray.intersectsSphere(da)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Qs),Q0.multiplyMatrices(i,Qs),ua.matrixWorld=Q0,ua.raycast(e,Rc);for(let o=0,a=Rc.length;o<a;o++){const l=Rc[o];l.instanceId=s,l.object=this,t.push(l)}Rc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Oo(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 i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new wi(new Float32Array(r*this.count),r,this.count,Ld,Sn));const s=this.morphTexture.source.data.data;let o=0;for(let c=0;c<i.length;c++)o+=i[c];const a=this.geometry.morphTargetsRelative?1:1-o,l=r*e;s[l]=a,s.set(i,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function wI(n,e){return n.z-e.z}function bI(n,e){return e.z-n.z}class EI{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const o=r[this.index];s.push(o),this.index++,o.start=e.start,o.count=e.count,o.z=t,o.index=i}reset(){this.list.length=0,this.index=0}}const dr=new ke,Mf=new ke,TI=new ke,AI=new ye(1,1,1),tv=new ke,wf=new Nl,Pc=new pn,Yr=new rn,ha=new I,nv=new I,CI=new I,bf=new EI,tn=new kt,Ic=[];function RI(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let s=0;s<r;s++)for(let o=0;o<i;o++)e.setComponent(s+t,o,n.getComponent(s,o))}else e.array.set(n.array,t*i);e.needsUpdate=!0}class bM extends kt{get maxInstanceCount(){return this._maxInstanceCount}constructor(e,t,i=t*2,r){super(new $e,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new wi(t,e,e,dn,Sn);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new wi(t,e,e,Rl,Ji);this._indirectTexture=i}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),i=new wi(t,e,e,dn,Sn);i.colorSpace=rt.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const o=e.getAttribute(s),{array:a,itemSize:l,normalized:c}=o,u=new a.constructor(i*l),d=new ht(u,l,c);t.setAttribute(s,d)}if(e.getIndex()!==null){const s=i>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new ht(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new pn);const e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,dr),this.getBoundingBoxAt(s,Pc).applyMatrix4(dr),e.union(Pc)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new rn);const e=this.boundingSphere,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,dr),this.getBoundingSphereAt(s,Yr).applyMatrix4(dr),e.union(Yr)}}addInstance(e){if(this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");this._drawInfo.push({visible:!0,active:!0,geometryIndex:e});const t=this._drawInfo.length-1,i=this._matricesTexture,r=i.image.data;TI.toArray(r,t*16),i.needsUpdate=!0;const s=this._colorsTexture;return s&&(AI.toArray(s.image.data,t*4),s.needsUpdate=!0),t}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const o=this._reservedRanges,a=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(i===-1?r.indexCount=c.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const d=this._geometryCount;return this._geometryCount++,o.push(r),a.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new pn,sphereInitialized:!1,sphere:new rn}),this.setGeometryAt(d,e),d}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(r&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=a.vertexStart,c=a.vertexCount;for(const p in i.attributes){const m=t.getAttribute(p),y=i.getAttribute(p);RI(m,y,l);const g=m.itemSize;for(let f=m.count,v=c;f<v;f++){const x=l+f;for(let _=0;_<g;_++)y.setComponent(x,_,0)}y.needsUpdate=!0,y.addUpdateRange(l*g,c*g)}if(r){const p=a.indexStart;for(let m=0;m<o.count;m++)s.setX(p+m,l+o.getX(m));for(let m=o.count,y=a.indexCount;m<y;m++)s.setX(p+m,l);s.needsUpdate=!0,s.addUpdateRange(p,a.indexCount)}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const d=this._drawRanges[e],h=t.getAttribute("position");return d.count=r?o.count:h.count,this._visibilityChanged=!0,e}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.box,s=this.geometry;if(i.boxInitialized===!1){r.makeEmpty();const o=s.index,a=s.attributes.position,l=this._drawRanges[e];for(let c=l.start,u=l.start+l.count;c<u;c++){let d=c;o&&(d=o.getX(d)),r.expandByPoint(ha.fromBufferAttribute(a,d))}i.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.sphere,s=this.geometry;if(i.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,Pc),Pc.getCenter(r.center);const o=s.index,a=s.attributes.position,l=this._drawRanges[e];let c=0;for(let u=l.start,d=l.start+l.count;u<d;u++){let h=u;o&&(h=o.getX(h)),ha.fromBufferAttribute(a,h),c=Math.max(c,r.center.distanceToSquared(ha))}r.radius=Math.sqrt(c),i.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture,s=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?null:t.fromArray(r,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const i=this._colorsTexture,r=this._colorsTexture.image.data,s=this._drawInfo;return e>=s.length||s[e].active===!1?this:(t.toArray(r,e*4),i.needsUpdate=!0,this)}getColorAt(e,t){const i=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||r[e].active===!1?null:t.fromArray(i,e*4)}setVisibleAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||i[e].visible===t?this:(i[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?!1:t[e].visible}raycast(e,t){const i=this._drawInfo,r=this._drawRanges,s=this.matrixWorld,o=this.geometry;tn.material=this.material,tn.geometry.index=o.index,tn.geometry.attributes=o.attributes,tn.geometry.boundingBox===null&&(tn.geometry.boundingBox=new pn),tn.geometry.boundingSphere===null&&(tn.geometry.boundingSphere=new rn);for(let a=0,l=i.length;a<l;a++){if(!i[a].visible||!i[a].active)continue;const c=i[a].geometryIndex,u=r[c];tn.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(a,tn.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,tn.geometry.boundingBox),this.getBoundingSphereAt(c,tn.geometry.boundingSphere),tn.raycast(e,Ic);for(let d=0,h=Ic.length;d<h;d++){const p=Ic[d];p.object=this,p.batchId=a,t.push(p)}Ic.length=0}tn.material=null,tn.geometry.index=null,tn.geometry.attributes={},tn.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._drawInfo=e._drawInfo.map(t=>({...t})),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,l=this._drawInfo,c=this._multiDrawStarts,u=this._multiDrawCounts,d=this._drawRanges,h=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data;h&&(tv.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),wf.setFromProjectionMatrix(tv,e.coordinateSystem));let y=0;if(this.sortObjects){Mf.copy(this.matrixWorld).invert(),ha.setFromMatrixPosition(i.matrixWorld).applyMatrix4(Mf),nv.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(Mf);for(let v=0,x=l.length;v<x;v++)if(l[v].visible&&l[v].active){const _=l[v].geometryIndex;this.getMatrixAt(v,dr),this.getBoundingSphereAt(_,Yr).applyMatrix4(dr);let R=!1;if(h&&(R=!wf.intersectsSphere(Yr)),!R){const M=CI.subVectors(Yr.center,ha).dot(nv);bf.push(d[_],M,v)}}const g=bf.list,f=this.customSort;f===null?g.sort(s.transparent?bI:wI):f.call(this,g,i);for(let v=0,x=g.length;v<x;v++){const _=g[v];c[y]=_.start*a,u[y]=_.count,m[y]=_.index,y++}bf.reset()}else for(let g=0,f=l.length;g<f;g++)if(l[g].visible&&l[g].active){const v=l[g].geometryIndex;let x=!1;if(h&&(this.getMatrixAt(g,dr),this.getBoundingSphereAt(v,Yr).applyMatrix4(dr),x=!wf.intersectsSphere(Yr)),!x){const _=d[v];c[y]=_.start*a,u[y]=_.count,m[y]=g,y++}}p.needsUpdate=!0,this._multiDrawCount=y,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,o){this.onBeforeRender(e,null,r,s,o)}}class xn extends on{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ye(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 ld=new I,cd=new I,iv=new ke,fa=new Go,Nc=new rn,Ef=new I,rv=new I;class Nr extends nt{constructor(e=new $e,t=new xn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=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,i=[0];for(let r=1,s=t.count;r<s;r++)ld.fromBufferAttribute(t,r-1),cd.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=ld.distanceTo(cd);e.setAttribute("lineDistance",new Ce(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Nc.copy(i.boundingSphere),Nc.applyMatrix4(r),Nc.radius+=s,e.ray.intersectsSphere(Nc)===!1)return;iv.copy(r).invert(),fa.copy(e.ray).applyMatrix4(iv);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){const p=Math.max(0,o.start),m=Math.min(u.count,o.start+o.count);for(let y=p,g=m-1;y<g;y+=c){const f=u.getX(y),v=u.getX(y+1),x=Lc(this,e,fa,l,f,v);x&&t.push(x)}if(this.isLineLoop){const y=u.getX(m-1),g=u.getX(p),f=Lc(this,e,fa,l,y,g);f&&t.push(f)}}else{const p=Math.max(0,o.start),m=Math.min(h.count,o.start+o.count);for(let y=p,g=m-1;y<g;y+=c){const f=Lc(this,e,fa,l,y,y+1);f&&t.push(f)}if(this.isLineLoop){const y=Lc(this,e,fa,l,m-1,p);y&&t.push(y)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function Lc(n,e,t,i,r,s){const o=n.geometry.attributes.position;if(ld.fromBufferAttribute(o,r),cd.fromBufferAttribute(o,s),t.distanceSqToSegment(ld,cd,Ef,rv)>i)return;Ef.applyMatrix4(n.matrixWorld);const l=e.ray.origin.distanceTo(Ef);if(!(l<e.near||l>e.far))return{distance:l,point:rv.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,object:n}}const sv=new I,ov=new I;class Ai extends Nr{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,i=[];for(let r=0,s=t.count;r<s;r+=2)sv.fromBufferAttribute(t,r),ov.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+sv.distanceTo(ov);e.setAttribute("lineDistance",new Ce(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class EM extends Nr{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class cg extends on{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ye(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 av=new ke,Op=new Go,Dc=new rn,Uc=new I;class TM extends nt{constructor(e=new $e,t=new cg){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Dc.copy(i.boundingSphere),Dc.applyMatrix4(r),Dc.radius+=s,e.ray.intersectsSphere(Dc)===!1)return;av.copy(r).invert(),Op.copy(e.ray).applyMatrix4(av);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=i.index,d=i.attributes.position;if(c!==null){const h=Math.max(0,o.start),p=Math.min(c.count,o.start+o.count);for(let m=h,y=p;m<y;m++){const g=c.getX(m);Uc.fromBufferAttribute(d,g),lv(Uc,g,l,r,e,t,this)}}else{const h=Math.max(0,o.start),p=Math.min(d.count,o.start+o.count);for(let m=h,y=p;m<y;m++)Uc.fromBufferAttribute(d,m),lv(Uc,m,l,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function lv(n,e,t,i,r,s,o){const a=Op.distanceSqToPoint(n);if(a<t){const l=new I;Op.closestPointToPoint(n,l),l.applyMatrix4(i);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class PI extends Ct{constructor(e,t,i,r,s,o,a,l,c){super(e,t,i,r,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Ut,this.magFilter=s!==void 0?s:Ut,this.generateMipmaps=!1;const u=this;function d(){u.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class II extends Ct{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Gt,this.minFilter=Gt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Yd extends Ct{constructor(e,t,i,r,s,o,a,l,c,u,d,h){super(null,o,a,l,c,u,r,s,d,h),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class NI extends Yd{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Xn,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class LI extends Yd{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,Ki),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class DI extends Ct{constructor(e,t,i,r,s,o,a,l,c){super(e,t,i,r,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ui{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/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 i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let o;t?o=t:o=e*i[s-1];let a=0,l=s-1,c;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),c=i[r]-o,c<0)a=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===o)return r/(s-1);const u=i[r],h=i[r+1]-u,p=(o-u)/h;return(r+p)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),a=this.getPoint(s),l=t||(o.isVector2?new K:new I);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new I,r=[],s=[],o=[],a=new I,l=new ke;for(let p=0;p<=e;p++){const m=p/e;r[p]=this.getTangentAt(m,new I)}s[0]=new I,o[0]=new I;let c=Number.MAX_VALUE;const u=Math.abs(r[0].x),d=Math.abs(r[0].y),h=Math.abs(r[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(r[p-1],r[p]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(At(r[p-1].dot(r[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(a,m))}o[p].crossVectors(r[p],s[p])}if(t===!0){let p=Math.acos(At(s[0].dot(s[e]),-1,1));p/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),o[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:o}}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 $d extends ui{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new K){const i=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);const a=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),d=Math.sin(this.aRotation),h=l-this.aX,p=c-this.aY;l=h*u-p*d+this.aX,c=h*d+p*u+this.aY}return i.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 AM extends $d{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function ug(){let n=0,e=0,t=0,i=0;function r(s,o,a,l){n=s,e=a,t=-3*s+3*o-2*a-l,i=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){r(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,u,d){let h=(o-s)/c-(a-s)/(c+u)+(a-o)/u,p=(a-o)/u-(l-o)/(u+d)+(l-a)/d;h*=u,p*=u,r(o,a,h,p)},calc:function(s){const o=s*s,a=o*s;return n+e*s+t*o+i*a}}}const kc=new I,Tf=new ug,Af=new ug,Cf=new ug;class CM extends ui{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new I){const i=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=r[(a-1)%s]:(kc.subVectors(r[0],r[1]).add(r[0]),c=kc);const d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(kc.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=kc),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(d),p),y=Math.pow(d.distanceToSquared(h),p),g=Math.pow(h.distanceToSquared(u),p);y<1e-4&&(y=1),m<1e-4&&(m=y),g<1e-4&&(g=y),Tf.initNonuniformCatmullRom(c.x,d.x,h.x,u.x,m,y,g),Af.initNonuniformCatmullRom(c.y,d.y,h.y,u.y,m,y,g),Cf.initNonuniformCatmullRom(c.z,d.z,h.z,u.z,m,y,g)}else this.curveType==="catmullrom"&&(Tf.initCatmullRom(c.x,d.x,h.x,u.x,this.tension),Af.initCatmullRom(c.y,d.y,h.y,u.y,this.tension),Cf.initCatmullRom(c.z,d.z,h.z,u.z,this.tension));return i.set(Tf.calc(l),Af.calc(l),Cf.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.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,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.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,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new I().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function cv(n,e,t,i,r){const s=(i-e)*.5,o=(r-t)*.5,a=n*n,l=n*a;return(2*t-2*i+s+o)*l+(-3*t+3*i-2*s-o)*a+s*n+t}function UI(n,e){const t=1-n;return t*t*e}function kI(n,e){return 2*(1-n)*n*e}function OI(n,e){return n*n*e}function Oa(n,e,t,i){return UI(n,e)+kI(n,t)+OI(n,i)}function FI(n,e){const t=1-n;return t*t*t*e}function BI(n,e){const t=1-n;return 3*t*t*n*e}function zI(n,e){return 3*(1-n)*n*n*e}function VI(n,e){return n*n*n*e}function Fa(n,e,t,i,r){return FI(n,e)+BI(n,t)+zI(n,i)+VI(n,r)}class dg extends ui{constructor(e=new K,t=new K,i=new K,r=new K){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new K){const i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(Fa(e,r.x,s.x,o.x,a.x),Fa(e,r.y,s.y,o.y,a.y)),i}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 RM extends ui{constructor(e=new I,t=new I,i=new I,r=new I){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new I){const i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(Fa(e,r.x,s.x,o.x,a.x),Fa(e,r.y,s.y,o.y,a.y),Fa(e,r.z,s.z,o.z,a.z)),i}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 hg extends ui{constructor(e=new K,t=new K){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new K){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new K){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 PM extends ui{constructor(e=new I,t=new I){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new I){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new I){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 fg extends ui{constructor(e=new K,t=new K,i=new K){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new K){const i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Oa(e,r.x,s.x,o.x),Oa(e,r.y,s.y,o.y)),i}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 pg extends ui{constructor(e=new I,t=new I,i=new I){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new I){const i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Oa(e,r.x,s.x,o.x),Oa(e,r.y,s.y,o.y),Oa(e,r.z,s.z,o.z)),i}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 mg extends ui{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new K){const i=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),a=s-o,l=r[o===0?o:o-1],c=r[o],u=r[o>r.length-2?r.length-1:o+1],d=r[o>r.length-3?r.length-1:o+2];return i.set(cv(a,l.x,c.x,u.x,d.x),cv(a,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new K().fromArray(r))}return this}}var ud=Object.freeze({__proto__:null,ArcCurve:AM,CatmullRomCurve3:CM,CubicBezierCurve:dg,CubicBezierCurve3:RM,EllipseCurve:$d,LineCurve:hg,LineCurve3:PM,QuadraticBezierCurve:fg,QuadraticBezierCurve3:pg,SplineCurve:mg});class IM extends ui{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 i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new ud[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=i){const o=r[s]-i,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.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 i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,s=this.curves;r<s.length;r++){const o=s[r],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){const u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}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,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new ud[r.type]().fromJSON(r))}return this}}class ml extends IM{constructor(e){super(),this.type="Path",this.currentPoint=new K,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;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 i=new hg(this.currentPoint.clone(),new K(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const s=new fg(this.currentPoint.clone(),new K(e,t),new K(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,o){const a=new dg(this.currentPoint.clone(),new K(e,t),new K(i,r),new K(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new mg(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,i,r,s,o),this}absarc(e,t,i,r,s,o){return this.absellipse(e,t,i,i,r,s,o),this}ellipse(e,t,i,r,s,o,a,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,r,s,o,a,l),this}absellipse(e,t,i,r,s,o,a,l){const c=new $d(e,t,i,r,s,o,a,l);if(this.curves.length>0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),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 Ll extends $e{constructor(e=[new K(0,-.5),new K(.5,0),new K(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=At(r,0,Math.PI*2);const s=[],o=[],a=[],l=[],c=[],u=1/t,d=new I,h=new K,p=new I,m=new I,y=new I;let g=0,f=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,f=e[v+1].y-e[v].y,p.x=f*1,p.y=-g,p.z=f*0,y.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(y.x,y.y,y.z);break;default:g=e[v+1].x-e[v].x,f=e[v+1].y-e[v].y,p.x=f*1,p.y=-g,p.z=f*0,m.copy(p),p.x+=y.x,p.y+=y.y,p.z+=y.z,p.normalize(),l.push(p.x,p.y,p.z),y.copy(m)}for(let v=0;v<=t;v++){const x=i+v*u*r,_=Math.sin(x),R=Math.cos(x);for(let M=0;M<=e.length-1;M++){d.x=e[M].x*_,d.y=e[M].y,d.z=e[M].x*R,o.push(d.x,d.y,d.z),h.x=v/t,h.y=M/(e.length-1),a.push(h.x,h.y);const T=l[3*M+0]*_,A=l[3*M+1],E=l[3*M+0]*R;c.push(T,A,E)}}for(let v=0;v<t;v++)for(let x=0;x<e.length-1;x++){const _=x+v*e.length,R=_,M=_+e.length,T=_+e.length+1,A=_+1;s.push(R,M,A),s.push(T,A,M)}this.setIndex(s),this.setAttribute("position",new Ce(o,3)),this.setAttribute("uv",new Ce(a,2)),this.setAttribute("normal",new Ce(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ll(e.points,e.segments,e.phiStart,e.phiLength)}}class qd extends Ll{constructor(e=1,t=1,i=4,r=8){const s=new ml;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new qd(e.radius,e.length,e.capSegments,e.radialSegments)}}class Zd extends $e{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);const s=[],o=[],a=[],l=[],c=new I,u=new K;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let d=0,h=3;d<=t;d++,h+=3){const p=i+d/t*r;c.x=e*Math.cos(p),c.y=e*Math.sin(p),o.push(c.x,c.y,c.z),a.push(0,0,1),u.x=(o[h]/e+1)/2,u.y=(o[h+1]/e+1)/2,l.push(u.x,u.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new Ce(o,3)),this.setAttribute("normal",new Ce(a,3)),this.setAttribute("uv",new Ce(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zd(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Xo extends $e{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};const c=this;r=Math.floor(r),s=Math.floor(s);const u=[],d=[],h=[],p=[];let m=0;const y=[],g=i/2;let f=0;v(),o===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new Ce(d,3)),this.setAttribute("normal",new Ce(h,3)),this.setAttribute("uv",new Ce(p,2));function v(){const _=new I,R=new I;let M=0;const T=(t-e)/i;for(let A=0;A<=s;A++){const E=[],w=A/s,L=w*(t-e)+e;for(let V=0;V<=r;V++){const F=V/r,G=F*l+a,Y=Math.sin(G),W=Math.cos(G);R.x=L*Y,R.y=-w*i+g,R.z=L*W,d.push(R.x,R.y,R.z),_.set(Y,T,W).normalize(),h.push(_.x,_.y,_.z),p.push(F,1-w),E.push(m++)}y.push(E)}for(let A=0;A<r;A++)for(let E=0;E<s;E++){const w=y[E][A],L=y[E+1][A],V=y[E+1][A+1],F=y[E][A+1];u.push(w,L,F),u.push(L,V,F),M+=6}c.addGroup(f,M,0),f+=M}function x(_){const R=m,M=new K,T=new I;let A=0;const E=_===!0?e:t,w=_===!0?1:-1;for(let V=1;V<=r;V++)d.push(0,g*w,0),h.push(0,w,0),p.push(.5,.5),m++;const L=m;for(let V=0;V<=r;V++){const G=V/r*l+a,Y=Math.cos(G),W=Math.sin(G);T.x=E*W,T.y=g*w,T.z=E*Y,d.push(T.x,T.y,T.z),h.push(0,w,0),M.x=Y*.5+.5,M.y=W*.5*w+.5,p.push(M.x,M.y),m++}for(let V=0;V<r;V++){const F=R+V,G=L+V;_===!0?u.push(G,G+1,F):u.push(G+1,G,F),A+=3}c.addGroup(f,A,_===!0?1:2),f+=A}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xo(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Kd extends Xo{constructor(e=1,t=1,i=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,i,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new Kd(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Fr extends $e{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const s=[],o=[];a(r),c(i),u(),this.setAttribute("position",new Ce(s,3)),this.setAttribute("normal",new Ce(s.slice(),3)),this.setAttribute("uv",new Ce(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){const x=new I,_=new I,R=new I;for(let M=0;M<t.length;M+=3)p(t[M+0],x),p(t[M+1],_),p(t[M+2],R),l(x,_,R,v)}function l(v,x,_,R){const M=R+1,T=[];for(let A=0;A<=M;A++){T[A]=[];const E=v.clone().lerp(_,A/M),w=x.clone().lerp(_,A/M),L=M-A;for(let V=0;V<=L;V++)V===0&&A===M?T[A][V]=E:T[A][V]=E.clone().lerp(w,V/L)}for(let A=0;A<M;A++)for(let E=0;E<2*(M-A)-1;E++){const w=Math.floor(E/2);E%2===0?(h(T[A][w+1]),h(T[A+1][w]),h(T[A][w])):(h(T[A][w+1]),h(T[A+1][w+1]),h(T[A+1][w]))}}function c(v){const x=new I;for(let _=0;_<s.length;_+=3)x.x=s[_+0],x.y=s[_+1],x.z=s[_+2],x.normalize().multiplyScalar(v),s[_+0]=x.x,s[_+1]=x.y,s[_+2]=x.z}function u(){const v=new I;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];const _=g(v)/2/Math.PI+.5,R=f(v)/Math.PI+.5;o.push(_,1-R)}m(),d()}function d(){for(let v=0;v<o.length;v+=6){const x=o[v+0],_=o[v+2],R=o[v+4],M=Math.max(x,_,R),T=Math.min(x,_,R);M>.9&&T<.1&&(x<.2&&(o[v+0]+=1),_<.2&&(o[v+2]+=1),R<.2&&(o[v+4]+=1))}}function h(v){s.push(v.x,v.y,v.z)}function p(v,x){const _=v*3;x.x=e[_+0],x.y=e[_+1],x.z=e[_+2]}function m(){const v=new I,x=new I,_=new I,R=new I,M=new K,T=new K,A=new K;for(let E=0,w=0;E<s.length;E+=9,w+=6){v.set(s[E+0],s[E+1],s[E+2]),x.set(s[E+3],s[E+4],s[E+5]),_.set(s[E+6],s[E+7],s[E+8]),M.set(o[w+0],o[w+1]),T.set(o[w+2],o[w+3]),A.set(o[w+4],o[w+5]),R.copy(v).add(x).add(_).divideScalar(3);const L=g(R);y(M,w+0,v,L),y(T,w+2,x,L),y(A,w+4,_,L)}}function y(v,x,_,R){R<0&&v.x===1&&(o[x]=v.x-1),_.x===0&&_.z===0&&(o[x]=R/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function f(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fr(e.vertices,e.indices,e.radius,e.details)}}class Jd extends Fr{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Jd(e.radius,e.detail)}}const Oc=new I,Fc=new I,Rf=new I,Bc=new Nn;class NM extends $e{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const r=Math.pow(10,4),s=Math.cos(ms*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],u=["a","b","c"],d=new Array(3),h={},p=[];for(let m=0;m<l;m+=3){o?(c[0]=o.getX(m),c[1]=o.getX(m+1),c[2]=o.getX(m+2)):(c[0]=m,c[1]=m+1,c[2]=m+2);const{a:y,b:g,c:f}=Bc;if(y.fromBufferAttribute(a,c[0]),g.fromBufferAttribute(a,c[1]),f.fromBufferAttribute(a,c[2]),Bc.getNormal(Rf),d[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,d[1]=`${Math.round(g.x*r)},${Math.round(g.y*r)},${Math.round(g.z*r)}`,d[2]=`${Math.round(f.x*r)},${Math.round(f.y*r)},${Math.round(f.z*r)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let v=0;v<3;v++){const x=(v+1)%3,_=d[v],R=d[x],M=Bc[u[v]],T=Bc[u[x]],A=`${_}_${R}`,E=`${R}_${_}`;E in h&&h[E]?(Rf.dot(h[E].normal)<=s&&(p.push(M.x,M.y,M.z),p.push(T.x,T.y,T.z)),h[E]=null):A in h||(h[A]={index0:c[v],index1:c[x],normal:Rf.clone()})}}for(const m in h)if(h[m]){const{index0:y,index1:g}=h[m];Oc.fromBufferAttribute(a,y),Fc.fromBufferAttribute(a,g),p.push(Oc.x,Oc.y,Oc.z),p.push(Fc.x,Fc.y,Fc.z)}this.setAttribute("position",new Ce(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class gs extends ml{constructor(e){super(e),this.uuid=Un(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].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,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new ml().fromJSON(r))}return this}}const HI={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=LM(n,0,r,t,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c,u,d,h,p;if(i&&(s=YI(n,e,s,t)),n.length>80*t){a=c=n[0],l=u=n[1];for(let m=t;m<r;m+=t)d=n[m],h=n[m+1],d<a&&(a=d),h<l&&(l=h),d>c&&(c=d),h>u&&(u=h);p=Math.max(c-a,u-l),p=p!==0?32767/p:0}return gl(s,o,t,a,l,p,0),o}};function LM(n,e,t,i,r){let s,o;if(r===rN(n,e,t,i)>0)for(s=e;s<t;s+=i)o=uv(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=uv(s,n[s],n[s+1],o);return o&&Qd(o,o.next)&&(vl(o),o=o.next),o}function Es(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Qd(t,t.next)||_t(t.prev,t,t.next)===0)){if(vl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function gl(n,e,t,i,r,s,o){if(!n)return;!o&&s&&JI(n,i,r,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?WI(n,i,r,s):GI(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),vl(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=jI(Es(n),e,t),gl(n,e,t,i,r,s,2)):o===2&&XI(n,e,t,i,r,s):gl(Es(n),e,t,i,r,s,1);break}}}function GI(n){const e=n.prev,t=n,i=n.next;if(_t(e,t,i)>=0)return!1;const r=e.x,s=t.x,o=i.x,a=e.y,l=t.y,c=i.y,u=r<s?r<o?r:o:s<o?s:o,d=a<l?a<c?a:c:l<c?l:c,h=r>s?r>o?r:o:s>o?s:o,p=a>l?a>c?a:c:l>c?l:c;let m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=h&&m.y>=d&&m.y<=p&&xo(r,a,s,l,o,c,m.x,m.y)&&_t(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function WI(n,e,t,i){const r=n.prev,s=n,o=n.next;if(_t(r,s,o)>=0)return!1;const a=r.x,l=s.x,c=o.x,u=r.y,d=s.y,h=o.y,p=a<l?a<c?a:c:l<c?l:c,m=u<d?u<h?u:h:d<h?d:h,y=a>l?a>c?a:c:l>c?l:c,g=u>d?u>h?u:h:d>h?d:h,f=Fp(p,m,e,t,i),v=Fp(y,g,e,t,i);let x=n.prevZ,_=n.nextZ;for(;x&&x.z>=f&&_&&_.z<=v;){if(x.x>=p&&x.x<=y&&x.y>=m&&x.y<=g&&x!==r&&x!==o&&xo(a,u,l,d,c,h,x.x,x.y)&&_t(x.prev,x,x.next)>=0||(x=x.prevZ,_.x>=p&&_.x<=y&&_.y>=m&&_.y<=g&&_!==r&&_!==o&&xo(a,u,l,d,c,h,_.x,_.y)&&_t(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;x&&x.z>=f;){if(x.x>=p&&x.x<=y&&x.y>=m&&x.y<=g&&x!==r&&x!==o&&xo(a,u,l,d,c,h,x.x,x.y)&&_t(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;_&&_.z<=v;){if(_.x>=p&&_.x<=y&&_.y>=m&&_.y<=g&&_!==r&&_!==o&&xo(a,u,l,d,c,h,_.x,_.y)&&_t(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function jI(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!Qd(r,s)&&DM(r,i,i.next,s)&&xl(r,s)&&xl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),vl(i),vl(i.next),i=n=s),i=i.next}while(i!==n);return Es(i)}function XI(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&tN(o,a)){let l=UM(o,a);o=Es(o,o.next),l=Es(l,l.next),gl(o,e,t,i,r,s,0),gl(l,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function YI(n,e,t,i){const r=[];let s,o,a,l,c;for(s=0,o=e.length;s<o;s++)a=e[s]*i,l=s<o-1?e[s+1]*i:n.length,c=LM(n,a,l,i,!1),c===c.next&&(c.steiner=!0),r.push(eN(c));for(r.sort($I),s=0;s<r.length;s++)t=qI(r[s],t);return t}function $I(n,e){return n.x-e.x}function qI(n,e){const t=ZI(n,e);if(!t)return e;const i=UM(t,n);return Es(i,i.next),Es(t,t.next)}function ZI(n,e){let t=e,i=-1/0,r;const s=n.x,o=n.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){const h=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=s&&h>i&&(i=h,r=t.x<t.next.x?t:t.next,h===s))return r}t=t.next}while(t!==e);if(!r)return null;const a=r,l=r.x,c=r.y;let u=1/0,d;t=r;do s>=t.x&&t.x>=l&&s!==t.x&&xo(o<c?s:i,o,l,c,o<c?i:s,o,t.x,t.y)&&(d=Math.abs(o-t.y)/(s-t.x),xl(t,n)&&(d<u||d===u&&(t.x>r.x||t.x===r.x&&KI(r,t)))&&(r=t,u=d)),t=t.next;while(t!==a);return r}function KI(n,e){return _t(n.prev,n,e.prev)<0&&_t(e.next,n,n.next)<0}function JI(n,e,t,i){let r=n;do r.z===0&&(r.z=Fp(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,QI(r)}function QI(n){let e,t,i,r,s,o,a,l,c=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<c&&(a++,i=i.nextZ,!!i);e++);for(l=c;a>0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(o>1);return n}function Fp(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function eN(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function xo(n,e,t,i,r,s,o,a){return(r-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function tN(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!nN(n,e)&&(xl(n,e)&&xl(e,n)&&iN(n,e)&&(_t(n.prev,n,e.prev)||_t(n,e.prev,e))||Qd(n,e)&&_t(n.prev,n,n.next)>0&&_t(e.prev,e,e.next)>0)}function _t(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Qd(n,e){return n.x===e.x&&n.y===e.y}function DM(n,e,t,i){const r=Vc(_t(n,e,t)),s=Vc(_t(n,e,i)),o=Vc(_t(t,i,n)),a=Vc(_t(t,i,e));return!!(r!==s&&o!==a||r===0&&zc(n,t,e)||s===0&&zc(n,i,e)||o===0&&zc(t,n,i)||a===0&&zc(t,e,i))}function zc(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Vc(n){return n>0?1:n<0?-1:0}function nN(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&DM(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function xl(n,e){return _t(n.prev,n,n.next)<0?_t(n,e,n.next)>=0&&_t(n,n.prev,e)>=0:_t(n,e,n.prev)<0||_t(n,n.next,e)<0}function iN(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function UM(n,e){const t=new Bp(n.i,n.x,n.y),i=new Bp(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function uv(n,e,t,i){const r=new Bp(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function vl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Bp(n,e,t){this.i=n,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 rN(n,e,t,i){let r=0;for(let s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}class bi{static area(e){const t=e.length;let i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return bi.area(e)<0}static triangulateShape(e,t){const i=[],r=[],s=[];dv(e),hv(i,e);let o=e.length;t.forEach(dv);for(let l=0;l<t.length;l++)r.push(o),o+=t[l].length,hv(i,t[l]);const a=HI.triangulate(i,r);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function dv(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function hv(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class eh extends $e{constructor(e=new gs([new K(.5,.5),new K(-.5,.5),new K(-.5,-.5),new K(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],s=[];for(let a=0,l=e.length;a<l;a++){const c=e[a];o(c)}this.setAttribute("position",new Ce(r,3)),this.setAttribute("uv",new Ce(s,2)),this.computeVertexNormals();function o(a){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let h=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const f=t.extrudePath,v=t.UVGenerator!==void 0?t.UVGenerator:sN;let x,_=!1,R,M,T,A;f&&(x=f.getSpacedPoints(u),_=!0,h=!1,R=f.computeFrenetFrames(u,!1),M=new I,T=new I,A=new I),h||(g=0,p=0,m=0,y=0);const E=a.extractPoints(c);let w=E.shape;const L=E.holes;if(!bi.isClockWise(w)){w=w.reverse();for(let P=0,le=L.length;P<le;P++){const ie=L[P];bi.isClockWise(ie)&&(L[P]=ie.reverse())}}const F=bi.triangulateShape(w,L),G=w;for(let P=0,le=L.length;P<le;P++){const ie=L[P];w=w.concat(ie)}function Y(P,le,ie){return le||console.error("THREE.ExtrudeGeometry: vec does not exist"),P.clone().addScaledVector(le,ie)}const W=w.length,ne=F.length;function D(P,le,ie){let ge,$,Ue;const me=P.x-le.x,we=P.y-le.y,N=ie.x-P.x,b=ie.y-P.y,z=me*me+we*we,J=me*b-we*N;if(Math.abs(J)>Number.EPSILON){const Z=Math.sqrt(z),te=Math.sqrt(N*N+b*b),Le=le.x-we/Z,pe=le.y+me/Z,Se=ie.x-b/te,We=ie.y+N/te,ae=((Se-Le)*b-(We-pe)*N)/(me*b-we*N);ge=Le+me*ae-P.x,$=pe+we*ae-P.y;const _e=ge*ge+$*$;if(_e<=2)return new K(ge,$);Ue=Math.sqrt(_e/2)}else{let Z=!1;me>Number.EPSILON?N>Number.EPSILON&&(Z=!0):me<-Number.EPSILON?N<-Number.EPSILON&&(Z=!0):Math.sign(we)===Math.sign(b)&&(Z=!0),Z?(ge=-we,$=me,Ue=Math.sqrt(z)):(ge=me,$=we,Ue=Math.sqrt(z/2))}return new K(ge/Ue,$/Ue)}const X=[];for(let P=0,le=G.length,ie=le-1,ge=P+1;P<le;P++,ie++,ge++)ie===le&&(ie=0),ge===le&&(ge=0),X[P]=D(G[P],G[ie],G[ge]);const Q=[];let oe,Re=X.concat();for(let P=0,le=L.length;P<le;P++){const ie=L[P];oe=[];for(let ge=0,$=ie.length,Ue=$-1,me=ge+1;ge<$;ge++,Ue++,me++)Ue===$&&(Ue=0),me===$&&(me=0),oe[ge]=D(ie[ge],ie[Ue],ie[me]);Q.push(oe),Re=Re.concat(oe)}for(let P=0;P<g;P++){const le=P/g,ie=p*Math.cos(le*Math.PI/2),ge=m*Math.sin(le*Math.PI/2)+y;for(let $=0,Ue=G.length;$<Ue;$++){const me=Y(G[$],X[$],ge);de(me.x,me.y,-ie)}for(let $=0,Ue=L.length;$<Ue;$++){const me=L[$];oe=Q[$];for(let we=0,N=me.length;we<N;we++){const b=Y(me[we],oe[we],ge);de(b.x,b.y,-ie)}}}const Ke=m+y;for(let P=0;P<W;P++){const le=h?Y(w[P],Re[P],Ke):w[P];_?(T.copy(R.normals[0]).multiplyScalar(le.x),M.copy(R.binormals[0]).multiplyScalar(le.y),A.copy(x[0]).add(T).add(M),de(A.x,A.y,A.z)):de(le.x,le.y,0)}for(let P=1;P<=u;P++)for(let le=0;le<W;le++){const ie=h?Y(w[le],Re[le],Ke):w[le];_?(T.copy(R.normals[P]).multiplyScalar(ie.x),M.copy(R.binormals[P]).multiplyScalar(ie.y),A.copy(x[P]).add(T).add(M),de(A.x,A.y,A.z)):de(ie.x,ie.y,d/u*P)}for(let P=g-1;P>=0;P--){const le=P/g,ie=p*Math.cos(le*Math.PI/2),ge=m*Math.sin(le*Math.PI/2)+y;for(let $=0,Ue=G.length;$<Ue;$++){const me=Y(G[$],X[$],ge);de(me.x,me.y,d+ie)}for(let $=0,Ue=L.length;$<Ue;$++){const me=L[$];oe=Q[$];for(let we=0,N=me.length;we<N;we++){const b=Y(me[we],oe[we],ge);_?de(b.x,b.y+x[u-1].y,x[u-1].x+ie):de(b.x,b.y,d+ie)}}}j(),se();function j(){const P=r.length/3;if(h){let le=0,ie=W*le;for(let ge=0;ge<ne;ge++){const $=F[ge];De($[2]+ie,$[1]+ie,$[0]+ie)}le=u+g*2,ie=W*le;for(let ge=0;ge<ne;ge++){const $=F[ge];De($[0]+ie,$[1]+ie,$[2]+ie)}}else{for(let le=0;le<ne;le++){const ie=F[le];De(ie[2],ie[1],ie[0])}for(let le=0;le<ne;le++){const ie=F[le];De(ie[0]+W*u,ie[1]+W*u,ie[2]+W*u)}}i.addGroup(P,r.length/3-P,0)}function se(){const P=r.length/3;let le=0;xe(G,le),le+=G.length;for(let ie=0,ge=L.length;ie<ge;ie++){const $=L[ie];xe($,le),le+=$.length}i.addGroup(P,r.length/3-P,1)}function xe(P,le){let ie=P.length;for(;--ie>=0;){const ge=ie;let $=ie-1;$<0&&($=P.length-1);for(let Ue=0,me=u+g*2;Ue<me;Ue++){const we=W*Ue,N=W*(Ue+1),b=le+ge+we,z=le+$+we,J=le+$+N,Z=le+ge+N;He(b,z,J,Z)}}}function de(P,le,ie){l.push(P),l.push(le),l.push(ie)}function De(P,le,ie){Be(P),Be(le),Be(ie);const ge=r.length/3,$=v.generateTopUV(i,r,ge-3,ge-2,ge-1);it($[0]),it($[1]),it($[2])}function He(P,le,ie,ge){Be(P),Be(le),Be(ge),Be(le),Be(ie),Be(ge);const $=r.length/3,Ue=v.generateSideWallUV(i,r,$-6,$-3,$-2,$-1);it(Ue[0]),it(Ue[1]),it(Ue[3]),it(Ue[1]),it(Ue[2]),it(Ue[3])}function Be(P){r.push(l[P*3+0]),r.push(l[P*3+1]),r.push(l[P*3+2])}function it(P){s.push(P.x),s.push(P.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return oN(t,i,e)}static fromJSON(e,t){const i=[];for(let s=0,o=e.shapes.length;s<o;s++){const a=t[e.shapes[s]];i.push(a)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new ud[r.type]().fromJSON(r)),new eh(i,e.options)}}const sN={generateTopUV:function(n,e,t,i,r){const s=e[t*3],o=e[t*3+1],a=e[i*3],l=e[i*3+1],c=e[r*3],u=e[r*3+1];return[new K(s,o),new K(a,l),new K(c,u)]},generateSideWallUV:function(n,e,t,i,r,s){const o=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],d=e[i*3+2],h=e[r*3],p=e[r*3+1],m=e[r*3+2],y=e[s*3],g=e[s*3+1],f=e[s*3+2];return Math.abs(a-u)<Math.abs(o-c)?[new K(o,1-l),new K(c,1-d),new K(h,1-m),new K(y,1-f)]:[new K(a,1-l),new K(u,1-d),new K(p,1-m),new K(g,1-f)]}};function oN(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){const s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class th extends Fr{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new th(e.radius,e.detail)}}class Dl extends Fr{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[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(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Dl(e.radius,e.detail)}}class nh extends $e{constructor(e=.5,t=1,i=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},i=Math.max(3,i),r=Math.max(1,r);const a=[],l=[],c=[],u=[];let d=e;const h=(t-e)/r,p=new I,m=new K;for(let y=0;y<=r;y++){for(let g=0;g<=i;g++){const f=s+g/i*o;p.x=d*Math.cos(f),p.y=d*Math.sin(f),l.push(p.x,p.y,p.z),c.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,u.push(m.x,m.y)}d+=h}for(let y=0;y<r;y++){const g=y*(i+1);for(let f=0;f<i;f++){const v=f+g,x=v,_=v+i+1,R=v+i+2,M=v+1;a.push(x,_,M),a.push(_,R,M)}}this.setIndex(a),this.setAttribute("position",new Ce(l,3)),this.setAttribute("normal",new Ce(c,3)),this.setAttribute("uv",new Ce(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new nh(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class ih extends $e{constructor(e=new gs([new K(0,.5),new K(-.5,-.5),new K(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],s=[],o=[];let a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(a,l,u),a+=l,l=0;this.setIndex(i),this.setAttribute("position",new Ce(r,3)),this.setAttribute("normal",new Ce(s,3)),this.setAttribute("uv",new Ce(o,2));function c(u){const d=r.length/3,h=u.extractPoints(t);let p=h.shape;const m=h.holes;bi.isClockWise(p)===!1&&(p=p.reverse());for(let g=0,f=m.length;g<f;g++){const v=m[g];bi.isClockWise(v)===!0&&(m[g]=v.reverse())}const y=bi.triangulateShape(p,m);for(let g=0,f=m.length;g<f;g++){const v=m[g];p=p.concat(v)}for(let g=0,f=p.length;g<f;g++){const v=p[g];r.push(v.x,v.y,0),s.push(0,0,1),o.push(v.x,v.y)}for(let g=0,f=y.length;g<f;g++){const v=y[g],x=v[0]+d,_=v[1]+d,R=v[2]+d;i.push(x,_,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 aN(t,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const o=t[e.shapes[r]];i.push(o)}return new ih(i,e.curveSegments)}}function aN(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}class Ul extends $e{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(o+a,Math.PI);let c=0;const u=[],d=new I,h=new I,p=[],m=[],y=[],g=[];for(let f=0;f<=i;f++){const v=[],x=f/i;let _=0;f===0&&o===0?_=.5/t:f===i&&l===Math.PI&&(_=-.5/t);for(let R=0;R<=t;R++){const M=R/t;d.x=-e*Math.cos(r+M*s)*Math.sin(o+x*a),d.y=e*Math.cos(o+x*a),d.z=e*Math.sin(r+M*s)*Math.sin(o+x*a),m.push(d.x,d.y,d.z),h.copy(d).normalize(),y.push(h.x,h.y,h.z),g.push(M+_,1-x),v.push(c++)}u.push(v)}for(let f=0;f<i;f++)for(let v=0;v<t;v++){const x=u[f][v+1],_=u[f][v],R=u[f+1][v],M=u[f+1][v+1];(f!==0||o>0)&&p.push(x,_,M),(f!==i-1||l<Math.PI)&&p.push(_,R,M)}this.setIndex(p),this.setAttribute("position",new Ce(m,3)),this.setAttribute("normal",new Ce(y,3)),this.setAttribute("uv",new Ce(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ul(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class rh extends Fr{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new rh(e.radius,e.detail)}}class sh extends $e{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);const o=[],a=[],l=[],c=[],u=new I,d=new I,h=new I;for(let p=0;p<=i;p++)for(let m=0;m<=r;m++){const y=m/r*s,g=p/i*Math.PI*2;d.x=(e+t*Math.cos(g))*Math.cos(y),d.y=(e+t*Math.cos(g))*Math.sin(y),d.z=t*Math.sin(g),a.push(d.x,d.y,d.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),h.subVectors(d,u).normalize(),l.push(h.x,h.y,h.z),c.push(m/r),c.push(p/i)}for(let p=1;p<=i;p++)for(let m=1;m<=r;m++){const y=(r+1)*p+m-1,g=(r+1)*(p-1)+m-1,f=(r+1)*(p-1)+m,v=(r+1)*p+m;o.push(y,g,v),o.push(g,f,v)}this.setIndex(o),this.setAttribute("position",new Ce(a,3)),this.setAttribute("normal",new Ce(l,3)),this.setAttribute("uv",new Ce(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new sh(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class oh extends $e{constructor(e=1,t=.4,i=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:o},i=Math.floor(i),r=Math.floor(r);const a=[],l=[],c=[],u=[],d=new I,h=new I,p=new I,m=new I,y=new I,g=new I,f=new I;for(let x=0;x<=i;++x){const _=x/i*s*Math.PI*2;v(_,s,o,e,p),v(_+.01,s,o,e,m),g.subVectors(m,p),f.addVectors(m,p),y.crossVectors(g,f),f.crossVectors(y,g),y.normalize(),f.normalize();for(let R=0;R<=r;++R){const M=R/r*Math.PI*2,T=-t*Math.cos(M),A=t*Math.sin(M);d.x=p.x+(T*f.x+A*y.x),d.y=p.y+(T*f.y+A*y.y),d.z=p.z+(T*f.z+A*y.z),l.push(d.x,d.y,d.z),h.subVectors(d,p).normalize(),c.push(h.x,h.y,h.z),u.push(x/i),u.push(R/r)}}for(let x=1;x<=i;x++)for(let _=1;_<=r;_++){const R=(r+1)*(x-1)+(_-1),M=(r+1)*x+(_-1),T=(r+1)*x+_,A=(r+1)*(x-1)+_;a.push(R,M,A),a.push(M,T,A)}this.setIndex(a),this.setAttribute("position",new Ce(l,3)),this.setAttribute("normal",new Ce(c,3)),this.setAttribute("uv",new Ce(u,2));function v(x,_,R,M,T){const A=Math.cos(x),E=Math.sin(x),w=R/_*x,L=Math.cos(w);T.x=M*(2+L)*.5*A,T.y=M*(2+L)*E*.5,T.z=M*Math.sin(w)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new oh(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class ah extends $e{constructor(e=new pg(new I(-1,-1,0),new I(-1,1,0),new I(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};const o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new I,l=new I,c=new K;let u=new I;const d=[],h=[],p=[],m=[];y(),this.setIndex(m),this.setAttribute("position",new Ce(d,3)),this.setAttribute("normal",new Ce(h,3)),this.setAttribute("uv",new Ce(p,2));function y(){for(let x=0;x<t;x++)g(x);g(s===!1?t:0),v(),f()}function g(x){u=e.getPointAt(x/t,u);const _=o.normals[x],R=o.binormals[x];for(let M=0;M<=r;M++){const T=M/r*Math.PI*2,A=Math.sin(T),E=-Math.cos(T);l.x=E*_.x+A*R.x,l.y=E*_.y+A*R.y,l.z=E*_.z+A*R.z,l.normalize(),h.push(l.x,l.y,l.z),a.x=u.x+i*l.x,a.y=u.y+i*l.y,a.z=u.z+i*l.z,d.push(a.x,a.y,a.z)}}function f(){for(let x=1;x<=t;x++)for(let _=1;_<=r;_++){const R=(r+1)*(x-1)+(_-1),M=(r+1)*x+(_-1),T=(r+1)*x+_,A=(r+1)*(x-1)+_;m.push(R,M,A),m.push(M,T,A)}}function v(){for(let x=0;x<=t;x++)for(let _=0;_<=r;_++)c.x=x/t,c.y=_/r,p.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new ah(new ud[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class kM extends $e{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,r=new I,s=new I;if(e.index!==null){const o=e.attributes.position,a=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:a.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const d=l[c],h=d.start,p=d.count;for(let m=h,y=h+p;m<y;m+=3)for(let g=0;g<3;g++){const f=a.getX(m+g),v=a.getX(m+(g+1)%3);r.fromBufferAttribute(o,f),s.fromBufferAttribute(o,v),fv(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const o=e.attributes.position;for(let a=0,l=o.count/3;a<l;a++)for(let c=0;c<3;c++){const u=3*a+c,d=3*a+(c+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,d),fv(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Ce(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function fv(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}var pv=Object.freeze({__proto__:null,BoxGeometry:Cs,CapsuleGeometry:qd,CircleGeometry:Zd,ConeGeometry:Kd,CylinderGeometry:Xo,DodecahedronGeometry:Jd,EdgesGeometry:NM,ExtrudeGeometry:eh,IcosahedronGeometry:th,LatheGeometry:Ll,OctahedronGeometry:Dl,PlaneGeometry:Wo,PolyhedronGeometry:Fr,RingGeometry:nh,ShapeGeometry:ih,SphereGeometry:Ul,TetrahedronGeometry:rh,TorusGeometry:sh,TorusKnotGeometry:oh,TubeGeometry:ah,WireframeGeometry:kM});class OM extends on{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ye(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class FM extends ci{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class gg extends on{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new ye(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 ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new K(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 On,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 BM extends gg{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 K(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return At(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 ye(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 ye(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ye(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 zM extends on{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ye(16777215),this.specular=new ye(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new On,this.combine=Cl,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 VM extends on{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ye(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class HM extends on{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class GM extends on{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ye(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new On,this.combine=Cl,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 WM extends on{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ye(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class jM extends xn{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function us(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function XM(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function YM(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function zp(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){const a=t[s]*e;for(let l=0;l!==e;++l)r[o++]=n[a+l]}return r}function xg(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)}function lN(n,e,t,i,r=30){const s=n.clone();s.name=e;const o=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],u=c.getValueSize(),d=[],h=[];for(let p=0;p<c.times.length;++p){const m=c.times[p]*r;if(!(m<t||m>=i)){d.push(c.times[p]);for(let y=0;y<u;++y)h.push(c.values[p*u+y])}}d.length!==0&&(c.times=us(d,c.times.constructor),c.values=us(h,c.values.constructor),o.push(c))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s}function cN(n,e=0,t=n,i=30){i<=0&&(i=30);const r=t.tracks.length,s=e/i;for(let o=0;o<r;++o){const a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;const c=n.tracks.find(function(f){return f.name===a.name&&f.ValueTypeName===l});if(c===void 0)continue;let u=0;const d=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=d/3);let h=0;const p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=p/3);const m=a.times.length-1;let y;if(s<=a.times[0]){const f=u,v=d-u;y=a.values.slice(f,v)}else if(s>=a.times[m]){const f=m*d+u,v=f+d-u;y=a.values.slice(f,v)}else{const f=a.createInterpolant(),v=u,x=d-u;f.evaluate(s),y=f.resultBuffer.slice(v,x)}l==="quaternion"&&new En().fromArray(y).normalize().conjugate().toArray(y);const g=c.times.length;for(let f=0;f<g;++f){const v=f*p+h;if(l==="quaternion")En.multiplyQuaternionsFlat(c.values,v,y,0,c.values,v);else{const x=p-h*2;for(let _=0;_<x;++_)c.values[v+_]-=y[_]}}}return n.blendMode=Km,n}const uN={convertArray:us,isTypedArray:XM,getKeyframeOrder:YM,sortedArray:zp,flattenJSON:xg,subclip:lN,makeClipAdditive:cN};class kl{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}o=t.length;break n}if(!(e>=s)){const a=t[1];e<a&&(i=2,s=a);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=s,s=t[--i-1],e>=s)break t}o=i,i=0;break n}break e}for(;i<o;){const a=i+o>>>1;e<t[a]?o=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=i[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class $M extends kl{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:as,endingEnd:as}}intervalChanged_(e,t,i){const r=this.parameterPositions;let s=e-2,o=e+1,a=r[s],l=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case ls:s=e,a=2*t-i;break;case ll:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(l===void 0)switch(this.getSettings_().endingEnd){case ls:o=e,l=2*i-t;break;case ll:o=1,l=i+r[1]-r[0];break;default:o=e-1,l=t}const c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-i),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,p=this._weightNext,m=(i-t)/(r-t),y=m*m,g=y*m,f=-h*g+2*h*y-h*m,v=(1+h)*g+(-1.5-2*h)*y+(-.5+h)*m+1,x=(-1-p)*g+(1.5+p)*y+.5*m,_=p*g-p*y;for(let R=0;R!==a;++R)s[R]=f*o[u+R]+v*o[c+R]+x*o[l+R]+_*o[d+R];return s}}class vg extends kl{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=(i-t)/(r-t),d=1-u;for(let h=0;h!==a;++h)s[h]=o[c+h]*d+o[l+h]*u;return s}}class qM extends kl{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class di{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=us(t,this.TimeBufferType),this.values=us(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:us(e.times,Array),values:us(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new qM(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new vg(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new $M(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case al:t=this.InterpolantFactoryMethodDiscrete;break;case ad:t=this.InterpolantFactoryMethodLinear;break;case au:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="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(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return al;case this.InterpolantFactoryMethodLinear:return ad;case this.InterpolantFactoryMethodSmooth:return au}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let s=0,o=r-1;for(;s!==r&&i[s]<e;)++s;for(;o!==-1&&i[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}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 i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(r!==void 0&&XM(r))for(let a=0,l=r.length;a!==l;++a){const c=r[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===au,s=e.length-1;let o=1;for(let a=1;a<s;++a){let l=!1;const c=e[a],u=e[a+1];if(c!==u&&(a!==1||c!==e[0]))if(r)l=!0;else{const d=a*i,h=d-i,p=d+i;for(let m=0;m!==i;++m){const y=t[d+m];if(y!==t[h+m]||y!==t[p+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];const d=a*i,h=o*i;for(let p=0;p!==i;++p)t[h+p]=t[d+p]}++o}}if(s>0){e[o]=e[s];for(let a=s*i,l=o*i,c=0;c!==i;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}di.prototype.TimeBufferType=Float32Array;di.prototype.ValueBufferType=Float32Array;di.prototype.DefaultInterpolation=ad;class Rs extends di{constructor(e,t,i){super(e,t,i)}}Rs.prototype.ValueTypeName="bool";Rs.prototype.ValueBufferType=Array;Rs.prototype.DefaultInterpolation=al;Rs.prototype.InterpolantFactoryMethodLinear=void 0;Rs.prototype.InterpolantFactoryMethodSmooth=void 0;class yg extends di{}yg.prototype.ValueTypeName="color";class yl extends di{}yl.prototype.ValueTypeName="number";class ZM extends kl{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(i-t)/(r-t);let c=e*a;for(let u=c+a;c!==u;c+=4)En.slerpFlat(s,0,o,c-a,o,c,l);return s}}class Ol extends di{InterpolantFactoryMethodLinear(e){return new ZM(this.times,this.values,this.getValueSize(),e)}}Ol.prototype.ValueTypeName="quaternion";Ol.prototype.InterpolantFactoryMethodSmooth=void 0;class Ps extends di{constructor(e,t,i){super(e,t,i)}}Ps.prototype.ValueTypeName="string";Ps.prototype.ValueBufferType=Array;Ps.prototype.DefaultInterpolation=al;Ps.prototype.InterpolantFactoryMethodLinear=void 0;Ps.prototype.InterpolantFactoryMethodSmooth=void 0;class _l extends di{}_l.prototype.ValueTypeName="vector";class Sl{constructor(e="",t=-1,i=[],r=kd){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Un(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(hN(i[o]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(di.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);const u=YM(l);l=zp(l,1,u),c=zp(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new yl(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){const c=e[a],u=c.name.match(s);if(u&&u.length>1){const d=u[1];let h=r[d];h||(r[d]=h=[]),h.push(c)}}const o=[];for(const a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(d,h,p,m,y){if(p.length!==0){const g=[],f=[];xg(p,g,f,m),g.length!==0&&y.push(new d(h,g,f))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let d=0;d<c.length;d++){const h=c[d].keys;if(!(!h||h.length===0))if(h[0].morphTargets){const p={};let m;for(m=0;m<h.length;m++)if(h[m].morphTargets)for(let y=0;y<h[m].morphTargets.length;y++)p[h[m].morphTargets[y]]=-1;for(const y in p){const g=[],f=[];for(let v=0;v!==h[m].morphTargets.length;++v){const x=h[m];g.push(x.time),f.push(x.morphTarget===y?1:0)}r.push(new yl(".morphTargetInfluence["+y+"]",g,f))}l=p.length*o}else{const p=".bones["+t[d].name+"]";i(_l,p+".position",h,"pos",r),i(Ol,p+".quaternion",h,"rot",r),i(_l,p+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,a)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const s=this.tracks[i];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 dN(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return yl;case"vector":case"vector2":case"vector3":case"vector4":return _l;case"color":return yg;case"quaternion":return Ol;case"bool":case"boolean":return Rs;case"string":return Ps}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function hN(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=dN(n.type);if(n.times===void 0){const t=[],i=[];xg(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const Hi={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class _g{constructor(e,t,i){const r=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,d){return c.push(u,d),this},this.removeHandler=function(u){const d=c.indexOf(u);return d!==-1&&c.splice(d,2),this},this.getHandler=function(u){for(let d=0,h=c.length;d<h;d+=2){const p=c[d],m=c[d+1];if(p.global&&(p.lastIndex=0),p.test(u))return m}return null}}}const KM=new _g;class Tn{constructor(e){this.manager=e!==void 0?e:KM,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Tn.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ui={};class fN extends Error{constructor(e,t){super(e),this.response=t}}class Qi extends Tn{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Hi.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ui[e]!==void 0){Ui[e].push({onLoad:t,onProgress:i,onError:r});return}Ui[e]=[],Ui[e].push({onLoad:t,onProgress:i,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).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 u=Ui[e],d=c.body.getReader(),h=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=h?parseInt(h):0,m=p!==0;let y=0;const g=new ReadableStream({start(f){v();function v(){d.read().then(({done:x,value:_})=>{if(x)f.close();else{y+=_.byteLength;const R=new ProgressEvent("progress",{lengthComputable:m,loaded:y,total:p});for(let M=0,T=u.length;M<T;M++){const A=u[M];A.onProgress&&A.onProgress(R)}f.enqueue(_),v()}},x=>{f.error(x)})}}});return new Response(g)}else throw new fN(`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(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,p=new TextDecoder(h);return c.arrayBuffer().then(m=>p.decode(m))}}}).then(c=>{Hi.add(e,c);const u=Ui[e];delete Ui[e];for(let d=0,h=u.length;d<h;d++){const p=u[d];p.onLoad&&p.onLoad(c)}}).catch(c=>{const u=Ui[e];if(u===void 0)throw this.manager.itemError(e),c;delete Ui[e];for(let d=0,h=u.length;d<h;d++){const p=u[d];p.onError&&p.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class pN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Qi(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=Sl.parse(e[i]);t.push(r)}return t}}class mN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=this,o=[],a=new Yd,l=new Qi(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function u(d){l.load(e[d],function(h){const p=s.parse(h,!0);o[d]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},c+=1,c===6&&(p.mipmapCount===1&&(a.minFilter=Ut),a.image=o,a.format=p.format,a.needsUpdate=!0,t&&t(a))},i,r)}if(Array.isArray(e))for(let d=0,h=e.length;d<h;++d)u(d);else l.load(e,function(d){const h=s.parse(d,!0);if(h.isCubemap){const p=h.mipmaps.length/h.mipmapCount;for(let m=0;m<p;m++){o[m]={mipmaps:[]};for(let y=0;y<h.mipmapCount;y++)o[m].mipmaps.push(h.mipmaps[m*h.mipmapCount+y]),o[m].format=h.format,o[m].width=h.width,o[m].height=h.height}a.image=o}else a.image.width=h.width,a.image.height=h.height,a.mipmaps=h.mipmaps;h.mipmapCount===1&&(a.minFilter=Ut),a.format=h.format,a.needsUpdate=!0,t&&t(a)},i,r);return a}}class Ml extends Tn{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Hi.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=pl("img");function l(){u(),Hi.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(d){u(),r&&r(d),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class gN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=new Il;s.colorSpace=Hn;const o=new Ml(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(e[c],function(u){s.images[c]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return s}}class xN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new wi,a=new Qi(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(l){let c;try{c=s.parse(l)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:Xn,o.wrapT=c.wrapT!==void 0?c.wrapT:Xn,o.magFilter=c.magFilter!==void 0?c.magFilter:Ut,o.minFilter=c.minFilter!==void 0?c.minFilter:Ut,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(o.colorSpace=c.colorSpace),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=yi),c.mipmapCount===1&&(o.minFilter=Ut),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c)},i,r),o}}class vN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=new Ct,o=new Ml(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class Br extends nt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ye(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 JM extends Br{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(nt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ye(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Pf=new ke,mv=new I,gv=new I;class Sg{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new K(512,512),this.map=null,this.mapPass=null,this.matrix=new ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Nl,this._frameExtents=new K(1,1),this._viewportCount=1,this._viewports=[new ct(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;mv.setFromMatrixPosition(e.matrixWorld),t.position.copy(mv),gv.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(gv),t.updateMatrixWorld(),Pf.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Pf),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Pf)}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 yN extends Sg{constructor(){super(new $t(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=Uo*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class QM extends Br{constructor(e,t,i=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(nt.DEFAULT_UP),this.updateMatrix(),this.target=new nt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new yN}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 xv=new ke,pa=new I,If=new I;class _N extends Sg{constructor(){super(new $t(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new K(4,2),this._viewportCount=6,this._viewports=[new ct(2,1,1,1),new ct(0,1,1,1),new ct(3,1,1,1),new ct(1,1,1,1),new ct(3,0,1,1),new ct(1,0,1,1)],this._cubeDirections=[new I(1,0,0),new I(-1,0,0),new I(0,0,1),new I(0,0,-1),new I(0,1,0),new I(0,-1,0)],this._cubeUps=[new I(0,1,0),new I(0,1,0),new I(0,1,0),new I(0,1,0),new I(0,0,1),new I(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),pa.setFromMatrixPosition(e.matrixWorld),i.position.copy(pa),If.copy(i.position),If.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(If),i.updateMatrixWorld(),r.makeTranslation(-pa.x,-pa.y,-pa.z),xv.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(xv)}}class ew extends Br{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new _N}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 SN extends Sg{constructor(){super(new Vd(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class tw extends Br{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(nt.DEFAULT_UP),this.updateMatrix(),this.target=new nt,this.shadow=new SN}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class nw extends Br{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class iw extends Br{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class rw{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new I)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(i*s)),t.addScaledVector(o[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*i*s),t.addScaledVector(o[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}}class sw extends Br{constructor(e=new rw,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class lh extends Tn{constructor(e){super(e),this.textures={}}load(e,t,i,r){const s=this,o=new Qi(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const r=lh.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new ye().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new ye().setHex(o.value);break;case"v2":r.uniforms[s].value=new K().fromArray(o.value);break;case"v3":r.uniforms[s].value=new I().fromArray(o.value);break;case"v4":r.uniforms[s].value=new ct().fromArray(o.value);break;case"m3":r.uniforms[s].value=new je().fromArray(o.value);break;case"m4":r.uniforms[s].value=new ke().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new K().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new K().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:OM,SpriteMaterial:ag,RawShaderMaterial:FM,ShaderMaterial:ci,PointsMaterial:cg,MeshPhysicalMaterial:BM,MeshStandardMaterial:gg,MeshPhongMaterial:zM,MeshToonMaterial:VM,MeshNormalMaterial:HM,MeshLambertMaterial:GM,MeshDepthMaterial:sg,MeshDistanceMaterial:og,MeshBasicMaterial:Or,MeshMatcapMaterial:WM,LineDashedMaterial:jM,LineBasicMaterial:xn,Material:on};return new t[e]}}class Vp{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 i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);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 ow extends $e{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 aw extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Qi(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(p,m){if(t[m]!==void 0)return t[m];const g=p.interleavedBuffers[m],f=s(p,g.buffer),v=po(g.type,f),x=new jd(v,g.stride);return x.uuid=g.uuid,t[m]=x,x}function s(p,m){if(i[m]!==void 0)return i[m];const g=p.arrayBuffers[m],f=new Uint32Array(g).buffer;return i[m]=f,f}const o=e.isInstancedBufferGeometry?new ow:new $e,a=e.data.index;if(a!==void 0){const p=po(a.type,a.array);o.setIndex(new ht(p,1))}const l=e.data.attributes;for(const p in l){const m=l[p];let y;if(m.isInterleavedBufferAttribute){const g=r(e.data,m.data);y=new bs(g,m.itemSize,m.offset,m.normalized)}else{const g=po(m.type,m.array),f=m.isInstancedBufferAttribute?Oo:ht;y=new f(g,m.itemSize,m.normalized)}m.name!==void 0&&(y.name=m.name),m.usage!==void 0&&y.setUsage(m.usage),o.setAttribute(p,y)}const c=e.data.morphAttributes;if(c)for(const p in c){const m=c[p],y=[];for(let g=0,f=m.length;g<f;g++){const v=m[g];let x;if(v.isInterleavedBufferAttribute){const _=r(e.data,v.data);x=new bs(_,v.itemSize,v.offset,v.normalized)}else{const _=po(v.type,v.array);x=new ht(_,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),y.push(x)}o.morphAttributes[p]=y}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let p=0,m=d.length;p!==m;++p){const y=d[p];o.addGroup(y.start,y.count,y.materialIndex)}const h=e.data.boundingSphere;if(h!==void 0){const p=new I;h.center!==void 0&&p.fromArray(h.center),o.boundingSphere=new rn(p,h.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}class MN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=this,o=this.path===""?Vp.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new Qi(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(d){r!==void 0&&r(d),console.error("THREE:ObjectLoader: Can't parse "+e+".",d.message);return}const u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?Vp.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new Qi(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const o=await s.loadAsync(e,t),a=JSON.parse(o),l=a.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(a)}parse(e,t){const i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(c)}),a=this.parseTextures(e.textures,o),l=this.parseMaterials(e.materials,a),c=this.parseObject(e.object,s,l,a,i),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),this.bindLightTargets(c),t!==void 0){let d=!1;for(const h in o)if(o[h].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),l=this.parseObject(e.object,r,a,o,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const s=new gs().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){const a=new Xd().fromJSON(e[s],r);i[a.uuid]=a}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new aw;for(let s=0,o=e.length;s<o;s++){let a;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":a=r.parse(l);break;default:l.type in pv?a=pv[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}a.uuid=l.uuid,l.name!==void 0&&(a.name=l.name),l.userData!==void 0&&(a.userData=l.userData),i[l.uuid]=a}}return i}parseMaterials(e,t){const i={},r={};if(e!==void 0){const s=new lh;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){const l=e[o];i[l.uuid]===void 0&&(i[l.uuid]=s.parse(l)),r[l.uuid]=i[l.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const r=e[i],s=Sl.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const i=this,r={};let s;function o(l){return i.manager.itemStart(l),s.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function a(l){if(typeof l=="string"){const c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return o(u)}else return l.data?{data:po(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new _g(t);s=new Ml(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){const d=e[c],h=d.url;if(Array.isArray(h)){const p=[];for(let m=0,y=h.length;m<y;m++){const g=h[m],f=a(g);f!==null&&(f instanceof HTMLImageElement?p.push(f):p.push(new wi(f.data,f.width,f.height)))}r[d.uuid]=new cs(p)}else{const p=a(d.url);r[d.uuid]=new cs(p)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function s(o){if(typeof o=="string"){const a=o,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await r.loadAsync(l)}else return o.data?{data:po(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new Ml(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){const l=e[o],c=l.url;if(Array.isArray(c)){const u=[];for(let d=0,h=c.length;d<h;d++){const p=c[d],m=await s(p);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new wi(m.data,m.width,m.height)))}i[l.uuid]=new cs(u)}else{const u=await s(l.url);i[l.uuid]=new cs(u)}}}return i}parseTextures(e,t){function i(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}const r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){const a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);const l=t[a.image],c=l.data;let u;Array.isArray(c)?(u=new Il,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new wi:u=new Ct,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=i(a.mapping,wN)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=i(a.wrap[0],vv),u.wrapT=i(a.wrap[1],vv)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=i(a.minFilter,yv)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,yv)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),r[a.uuid]=u}return r}parseObject(e,t,i,r,s){let o;function a(h){return t[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",h),t[h]}function l(h){if(h!==void 0){if(Array.isArray(h)){const p=[];for(let m=0,y=h.length;m<y;m++){const g=h[m];i[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),p.push(i[g])}return p}return i[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",h),i[h]}}function c(h){return r[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",h),r[h]}let u,d;switch(e.type){case"Scene":o=new vM,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new ye(e.background):o.background=c(e.background)),e.environment!==void 0&&(o.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new Wd(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Gd(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(o.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new $t(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new Vd(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new nw(e.color,e.intensity);break;case"DirectionalLight":o=new tw(e.color,e.intensity),o.target=e.target||"";break;case"PointLight":o=new ew(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new iw(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new QM(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),o.target=e.target||"";break;case"HemisphereLight":o=new JM(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new sw().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),d=l(e.material),o=new MM(u,d),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),d=l(e.material),o=new kt(u,d);break;case"InstancedMesh":u=a(e.geometry),d=l(e.material);const h=e.count,p=e.instanceMatrix,m=e.instanceColor;o=new wM(u,d,h),o.instanceMatrix=new Oo(new Float32Array(p.array),16),m!==void 0&&(o.instanceColor=new Oo(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=a(e.geometry),d=l(e.material),o=new bM(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,d),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(y=>{const g=new pn;g.min.fromArray(y.boxMin),g.max.fromArray(y.boxMax);const f=new rn;return f.radius=y.sphereRadius,f.center.fromArray(y.sphereCenter),{boxInitialized:y.boxInitialized,box:g,sphereInitialized:y.sphereInitialized,sphere:f}}),o._maxInstanceCount=e.maxInstanceCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(o._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":o=new SM;break;case"Line":o=new Nr(a(e.geometry),l(e.material));break;case"LineLoop":o=new EM(a(e.geometry),l(e.material));break;case"LineSegments":o=new Ai(a(e.geometry),l(e.material));break;case"PointCloud":case"Points":o=new TM(a(e.geometry),l(e.material));break;case"Sprite":o=new _M(l(e.material));break;case"Group":o=new go;break;case"Bone":o=new lg;break;default:o=new nt}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(o.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const h=e.children;for(let p=0;p<h.length;p++)o.add(this.parseObject(h[p],t,i,r,s))}if(e.animations!==void 0){const h=e.animations;for(let p=0;p<h.length;p++){const m=h[p];o.animations.push(s[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);const h=e.levels;for(let p=0;p<h.length;p++){const m=h[p],y=o.getObjectByProperty("uuid",m.object);y!==void 0&&o.addLevel(y,m.distance,m.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=t.target,r=e.getObjectByProperty("uuid",i);r!==void 0?t.target=r:t.target=new nt}})}}const wN={UVMapping:Rd,CubeReflectionMapping:Ki,CubeRefractionMapping:Ir,EquirectangularReflectionMapping:il,EquirectangularRefractionMapping:rl,CubeUVReflectionMapping:Vo},vv={RepeatWrapping:sl,ClampToEdgeWrapping:Xn,MirroredRepeatWrapping:ol},yv={NearestFilter:Gt,NearestMipmapNearestFilter:Vm,NearestMipmapLinearFilter:fo,LinearFilter:Ut,LinearMipmapNearestFilter:Pa,LinearMipmapLinearFilter:yi};class bN extends Tn{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,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Hi.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return Hi.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),Hi.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Hi.add(e,l),s.manager.itemStart(e)}}let Hc;class Mg{static getContext(){return Hc===void 0&&(Hc=new(window.AudioContext||window.webkitAudioContext)),Hc}static setContext(e){Hc=e}}class EN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Qi(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{const c=l.slice(0);Mg.getContext().decodeAudioData(c,function(d){t(d)}).catch(a)}catch(c){a(c)}},i,r);function a(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const _v=new ke,Sv=new ke,$r=new ke;class TN{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new $t,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new $t,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,$r.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(ms*t.fov*.5)/t.zoom;let a,l;Sv.elements[12]=-r,_v.elements[12]=r,a=-o*t.aspect+s,l=o*t.aspect+s,$r.elements[0]=2*t.near/(l-a),$r.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy($r),a=-o*t.aspect-s,l=o*t.aspect-s,$r.elements[0]=2*t.near/(l-a),$r.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy($r)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Sv),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(_v)}}class lw{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Mv(),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=Mv();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Mv(){return(typeof performance>"u"?Date:performance).now()}const qr=new I,wv=new En,AN=new I,Zr=new I;class CN extends nt{constructor(){super(),this.type="AudioListener",this.context=Mg.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new lw}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(qr,wv,AN),Zr.set(0,0,-1).applyQuaternion(wv),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(qr.x,r),t.positionY.linearRampToValueAtTime(qr.y,r),t.positionZ.linearRampToValueAtTime(qr.z,r),t.forwardX.linearRampToValueAtTime(Zr.x,r),t.forwardY.linearRampToValueAtTime(Zr.y,r),t.forwardZ.linearRampToValueAtTime(Zr.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(qr.x,qr.y,qr.z),t.setOrientation(Zr.x,Zr.y,Zr.z,i.x,i.y,i.z)}}class cw extends nt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const Kr=new I,bv=new En,RN=new I,Jr=new I;class PN extends cw{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Kr,bv,RN),Jr.set(0,0,1).applyQuaternion(bv);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Kr.x,i),t.positionY.linearRampToValueAtTime(Kr.y,i),t.positionZ.linearRampToValueAtTime(Kr.z,i),t.orientationX.linearRampToValueAtTime(Jr.x,i),t.orientationY.linearRampToValueAtTime(Jr.y,i),t.orientationZ.linearRampToValueAtTime(Jr.z,i)}else t.setPosition(Kr.x,Kr.y,Kr.z),t.setOrientation(Jr.x,Jr.y,Jr.z)}}class IN{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class uw{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,o;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,r=this.valueSize,s=e*r+r;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)i[s+a]=i[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-s,t)}o>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){a.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){En.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const o=this._workIndex*s;En.multiplyQuaternionsFlat(e,o,e,t,e,i),En.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){const o=1-r;for(let a=0;a!==s;++a){const l=t+a;e[l]=e[l]*o+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){const a=t+o;e[a]=e[a]+e[i+o]*r}}}const wg="\\[\\]\\.:\\/",NN=new RegExp("["+wg+"]","g"),bg="[^"+wg+"]",LN="[^"+wg.replace("\\.","")+"]",DN=/((?:WC+[\/:])*)/.source.replace("WC",bg),UN=/(WCOD+)?/.source.replace("WCOD",LN),kN=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",bg),ON=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",bg),FN=new RegExp("^"+DN+UN+kN+ON+"$"),BN=["material","materials","bones","map"];class zN{constructor(e,t,i){const r=i||et.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class et{constructor(e,t,i){this.path=t,this.parsedPath=i||et.parseTrackName(t),this.node=et.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new et.Composite(e,t,i):new et(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(NN,"")}static parseTrackName(e){const t=FN.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);BN.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let o=0;o<s.length;o++){const a=s[o];if(a.name===t||a.uuid===t)return a;const l=i(a.children);if(l)return l}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=et.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(i){let c=t.objectIndex;switch(i){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 u=0;u<e.length;u++)if(e[u].name===c){c=u;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[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}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 o=e[r];if(o===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="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=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}et.Composite=zN;et.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};et.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};et.prototype.GetterByBindingType=[et.prototype._getValue_direct,et.prototype._getValue_array,et.prototype._getValue_arrayElement,et.prototype._getValue_toArray];et.prototype.SetterByBindingTypeAndVersioning=[[et.prototype._setValue_direct,et.prototype._setValue_direct_setNeedsUpdate,et.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[et.prototype._setValue_array,et.prototype._setValue_array_setNeedsUpdate,et.prototype._setValue_array_setMatrixWorldNeedsUpdate],[et.prototype._setValue_arrayElement,et.prototype._setValue_arrayElement_setNeedsUpdate,et.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[et.prototype._setValue_fromArray,et.prototype._setValue_fromArray_setNeedsUpdate,et.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class VN{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Un(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length;let a,l=e.length,c=this.nCachedObjects_;for(let u=0,d=arguments.length;u!==d;++u){const h=arguments[u],p=h.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(h);for(let y=0,g=o;y!==g;++y)s[y].push(new et(h,i[y],r[y]))}else if(m<c){a=e[m];const y=--c,g=e[y];t[g.uuid]=m,e[m]=g,t[p]=y,e[y]=h;for(let f=0,v=o;f!==v;++f){const x=s[f],_=x[y];let R=x[m];x[m]=_,R===void 0&&(R=new et(h,i[f],r[f])),x[y]=R}}else e[m]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const l=arguments[o],c=l.uuid,u=t[c];if(u!==void 0&&u>=s){const d=s++,h=e[d];t[h.uuid]=u,e[u]=h,t[c]=d,e[d]=l;for(let p=0,m=r;p!==m;++p){const y=i[p],g=y[d],f=y[u];y[u]=g,y[d]=f}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){const c=arguments[a],u=c.uuid,d=t[u];if(d!==void 0)if(delete t[u],d<s){const h=--s,p=e[h],m=--o,y=e[m];t[p.uuid]=d,e[d]=p,t[y.uuid]=h,e[h]=y,e.pop();for(let g=0,f=r;g!==f;++g){const v=i[g],x=v[h],_=v[m];v[d]=x,v[h]=_,v.pop()}}else{const h=--o,p=e[h];h>0&&(t[p.uuid]=d),e[d]=p,e.pop();for(let m=0,y=r;m!==y;++m){const g=i[m];g[d]=g[h],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,d=new Array(c);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(d);for(let h=u,p=l.length;h!==p;++h){const m=l[h];d[h]=new et(m,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=i,o[i]=l,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}}class dw{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,o=s.length,a=new Array(o),l={endingStart:as,endingEnd:as};for(let c=0;c!==o;++c){const u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=WS,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,s=r.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/o,c[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Km:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case kd:default:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(o),c[u].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,s=this._loopCount;const o=i===jS;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===GS){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){const a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=ls,r.endingEnd=ls):(e?r.endingStart=this.zeroSlopeAtStart?ls:as:r.endingStart=ll,t?r.endingEnd=this.zeroSlopeAtEnd?ls:as:r.endingEnd=ll)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=i,this}}const HN=new Float32Array(1);class GN extends Ti{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let d=0;d!==s;++d){const h=r[d],p=h.name;let m=u[p];if(m!==void 0)++m.referenceCount,o[d]=m;else{if(m=o[d],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const y=t&&t._propertyBindings[d].binding.parsedPath;m=new uw(et.create(i,p,y),h.ValueTypeName,h.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),o[d]=m}a[d].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const r=this._actions,s=this._actionsByClip;let o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{const a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;const d=a.actionByRoot,h=(e._localRoot||this._root).uuid;delete d[h],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){const r=this._bindingsByRootAndName,s=this._bindings;let o=r[t];o===void 0&&(o={},r[t]=o),o[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,o=this._bindingsByRootAndName,a=o[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new vg(new Float32Array(2),new Float32Array(2),1,HN),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){const r=t||this._root,s=r.uuid;let o=typeof e=="string"?Sl.findByName(r,e):e;const a=o!==null?o.uuid:e,l=this._actionsByClip[a];let c=null;if(i===void 0&&(o!==null?i=o.blendMode:i=kd),l!==void 0){const d=l.actionByRoot[s];if(d!==void 0&&d.blendMode===i)return d;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;const u=new dw(this,o,t,i);return this._bindAction(u,c),this._addInactiveAction(u,a,s),u}existingAction(e,t){const i=t||this._root,r=i.uuid,s=typeof e=="string"?Sl.findByName(i,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){const o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){const c=o[a];this._deactivateAction(c);const u=c._cacheIndex,d=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,d._cacheIndex=u,t[u]=d,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const o in i){const a=i[o].actionByRoot,l=a[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(const o in s){const a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class Eg{constructor(e){this.value=e}clone(){return new Eg(this.value.clone===void 0?this.value:this.value.clone())}}let WN=0;class jN extends Ti{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:WN++}),this.name="",this.usage=hl,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){const s=Array.isArray(t[i])?t[i]:[t[i]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}}class XN extends jd{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class YN{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const Ev=new ke;class $N{constructor(e,t,i=0,r=1/0){this.ray=new Go(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Bd,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 Ev.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Ev),this}intersectObject(e,t=!0,i=[]){return Hp(e,this,i,t),i.sort(Tv),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Hp(e[r],this,i,t);return i.sort(Tv),i}}function Tv(n,e){return n.distance-e.distance}function Hp(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const s=n.children;for(let o=0,a=s.length;o<a;o++)Hp(s[o],e,t,!0)}}class qN{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(At(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class ZN{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}class Tg{constructor(e,t,i,r){Tg.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=r,this}}const Av=new K;class KN{constructor(e=new K(1/0,1/0),t=new K(-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,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Av.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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,Av).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 Cv=new I,Gc=new I;class JN{constructor(e=new I,t=new I){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){Cv.subVectors(e,this.start),Gc.subVectors(this.end,this.start);const i=Gc.dot(Gc);let s=Gc.dot(Cv)/i;return t&&(s=At(s,0,1)),s}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Rv=new I;class QN extends nt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new $e,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){const c=o/l*Math.PI*2,u=a/l*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new Ce(r,3));const s=new xn({fog:!1,toneMapped:!1});this.cone=new Ai(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Rv.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Rv),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const hr=new I,Wc=new ke,Nf=new ke;class e3 extends Ai{constructor(e){const t=hw(e),i=new $e,r=[],s=[],o=new ye(0,0,1),a=new ye(0,1,0);for(let c=0;c<t.length;c++){const u=t[c];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new Ce(r,3)),i.setAttribute("color",new Ce(s,3));const l=new xn({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,r=i.getAttribute("position");Nf.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){const a=t[s];a.parent&&a.parent.isBone&&(Wc.multiplyMatrices(Nf,a.matrixWorld),hr.setFromMatrixPosition(Wc),r.setXYZ(o,hr.x,hr.y,hr.z),Wc.multiplyMatrices(Nf,a.parent.matrixWorld),hr.setFromMatrixPosition(Wc),r.setXYZ(o+1,hr.x,hr.y,hr.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function hw(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,hw(n.children[t]));return e}class t3 extends kt{constructor(e,t,i){const r=new Ul(t,4,2),s=new Or({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const n3=new I,Pv=new ye,Iv=new ye;class i3 extends nt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const r=new Dl(t);r.rotateY(Math.PI*.5),this.material=new Or({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new ht(o,3)),this.add(new kt(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Pv.copy(this.light.color),Iv.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const s=i<r/2?Pv:Iv;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(n3.setFromMatrixPosition(this.light.matrixWorld).negate())}}class r3 extends Ai{constructor(e=10,t=10,i=4473924,r=8947848){i=new ye(i),r=new ye(r);const s=t/2,o=e/t,a=e/2,l=[],c=[];for(let h=0,p=0,m=-a;h<=t;h++,m+=o){l.push(-a,0,m,a,0,m),l.push(m,0,-a,m,0,a);const y=h===s?i:r;y.toArray(c,p),p+=3,y.toArray(c,p),p+=3,y.toArray(c,p),p+=3,y.toArray(c,p),p+=3}const u=new $e;u.setAttribute("position",new Ce(l,3)),u.setAttribute("color",new Ce(c,3));const d=new xn({vertexColors:!0,toneMapped:!1});super(u,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class s3 extends Ai{constructor(e=10,t=16,i=8,r=64,s=4473924,o=8947848){s=new ye(s),o=new ye(o);const a=[],l=[];if(t>1)for(let d=0;d<t;d++){const h=d/t*(Math.PI*2),p=Math.sin(h)*e,m=Math.cos(h)*e;a.push(0,0,0),a.push(p,0,m);const y=d&1?s:o;l.push(y.r,y.g,y.b),l.push(y.r,y.g,y.b)}for(let d=0;d<i;d++){const h=d&1?s:o,p=e-e/i*d;for(let m=0;m<r;m++){let y=m/r*(Math.PI*2),g=Math.sin(y)*p,f=Math.cos(y)*p;a.push(g,0,f),l.push(h.r,h.g,h.b),y=(m+1)/r*(Math.PI*2),g=Math.sin(y)*p,f=Math.cos(y)*p,a.push(g,0,f),l.push(h.r,h.g,h.b)}}const c=new $e;c.setAttribute("position",new Ce(a,3)),c.setAttribute("color",new Ce(l,3));const u=new xn({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Nv=new I,jc=new I,Lv=new I;class o3 extends nt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new $e;r.setAttribute("position",new Ce([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new xn({fog:!1,toneMapped:!1});this.lightPlane=new Nr(r,s),this.add(this.lightPlane),r=new $e,r.setAttribute("position",new Ce([0,0,0,0,0,1],3)),this.targetLine=new Nr(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Nv.setFromMatrixPosition(this.light.matrixWorld),jc.setFromMatrixPosition(this.light.target.matrixWorld),Lv.subVectors(jc,Nv),this.lightPlane.lookAt(jc),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(jc),this.targetLine.scale.z=Lv.length()}}const Xc=new I,Et=new zd;class a3 extends Ai{constructor(e){const t=new $e,i=new xn({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,y){l(m),l(y)}function l(m){r.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(r.length/3-1)}t.setAttribute("position",new Ce(r,3)),t.setAttribute("color",new Ce(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const c=new ye(16755200),u=new ye(16711680),d=new ye(43775),h=new ye(16777215),p=new ye(3355443);this.setColors(c,u,d,h,p)}setColors(e,t,i,r,s){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,i=1,r=1;Et.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Rt("c",t,e,Et,0,0,-1),Rt("t",t,e,Et,0,0,1),Rt("n1",t,e,Et,-i,-r,-1),Rt("n2",t,e,Et,i,-r,-1),Rt("n3",t,e,Et,-i,r,-1),Rt("n4",t,e,Et,i,r,-1),Rt("f1",t,e,Et,-i,-r,1),Rt("f2",t,e,Et,i,-r,1),Rt("f3",t,e,Et,-i,r,1),Rt("f4",t,e,Et,i,r,1),Rt("u1",t,e,Et,i*.7,r*1.1,-1),Rt("u2",t,e,Et,-i*.7,r*1.1,-1),Rt("u3",t,e,Et,0,r*2,-1),Rt("cf1",t,e,Et,-i,0,1),Rt("cf2",t,e,Et,i,0,1),Rt("cf3",t,e,Et,0,-r,1),Rt("cf4",t,e,Et,0,r,1),Rt("cn1",t,e,Et,-i,0,-1),Rt("cn2",t,e,Et,i,0,-1),Rt("cn3",t,e,Et,0,-r,-1),Rt("cn4",t,e,Et,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Rt(n,e,t,i,r,s,o){Xc.set(r,s,o).unproject(i);const a=e[n];if(a!==void 0){const l=t.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],Xc.x,Xc.y,Xc.z)}}const Yc=new pn;class l3 extends Ai{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(8*3),s=new $e;s.setIndex(new ht(i,1)),s.setAttribute("position",new ht(r,3)),super(s,new xn({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Yc.setFromObject(this.object),Yc.isEmpty())return;const t=Yc.min,i=Yc.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class c3 extends Ai{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new $e;s.setIndex(new ht(i,1)),s.setAttribute("position",new Ce(r,3)),super(s,new xn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class u3 extends Nr{constructor(e,t=1,i=16776960){const r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new $e;o.setAttribute("position",new Ce(s,3)),o.computeBoundingSphere(),super(o,new xn({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new $e;l.setAttribute("position",new Ce(a,3)),l.computeBoundingSphere(),this.add(new kt(l,new Or({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Dv=new I;let $c,Lf;class d3 extends nt{constructor(e=new I(0,0,1),t=new I(0,0,0),i=1,r=16776960,s=i*.2,o=s*.2){super(),this.type="ArrowHelper",$c===void 0&&($c=new $e,$c.setAttribute("position",new Ce([0,0,0,0,1,0],3)),Lf=new Xo(0,.5,1,5,1),Lf.translate(0,-.5,0)),this.position.copy(t),this.line=new Nr($c,new xn({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new kt(Lf,new Or({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Dv.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Dv,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),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 h3 extends Ai{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new $e;r.setAttribute("position",new Ce(t,3)),r.setAttribute("color",new Ce(i,3));const s=new xn({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){const r=new ye,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class f3{constructor(){this.type="ShapePath",this.color=new ye,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new ml,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(f){const v=[];for(let x=0,_=f.length;x<_;x++){const R=f[x],M=new gs;M.curves=R.curves,v.push(M)}return v}function i(f,v){const x=v.length;let _=!1;for(let R=x-1,M=0;M<x;R=M++){let T=v[R],A=v[M],E=A.x-T.x,w=A.y-T.y;if(Math.abs(w)>Number.EPSILON){if(w<0&&(T=v[M],E=-E,A=v[R],w=-w),f.y<T.y||f.y>A.y)continue;if(f.y===T.y){if(f.x===T.x)return!0}else{const L=w*(f.x-T.x)-E*(f.y-T.y);if(L===0)return!0;if(L<0)continue;_=!_}}else{if(f.y!==T.y)continue;if(A.x<=f.x&&f.x<=T.x||T.x<=f.x&&f.x<=A.x)return!0}}return _}const r=bi.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l;const c=[];if(s.length===1)return a=s[0],l=new gs,l.curves=a.curves,c.push(l),c;let u=!r(s[0].getPoints());u=e?!u:u;const d=[],h=[];let p=[],m=0,y;h[m]=void 0,p[m]=[];for(let f=0,v=s.length;f<v;f++)a=s[f],y=a.getPoints(),o=r(y),o=e?!o:o,o?(!u&&h[m]&&m++,h[m]={s:new gs,p:y},h[m].s.curves=a.curves,u&&m++,p[m]=[]):p[m].push({h:a,p:y[0]});if(!h[0])return t(s);if(h.length>1){let f=!1,v=0;for(let x=0,_=h.length;x<_;x++)d[x]=[];for(let x=0,_=h.length;x<_;x++){const R=p[x];for(let M=0;M<R.length;M++){const T=R[M];let A=!0;for(let E=0;E<h.length;E++)i(T.p,h[E].p)&&(x!==E&&v++,A?(A=!1,d[E].push(T)):f=!0);A&&d[x].push(T)}}v>0&&f===!1&&(p=d)}let g;for(let f=0,v=h.length;f<v;f++){l=h[f].s,c.push(l),g=p[f];for(let x=0,_=g.length;x<_;x++)l.holes.push(g[x].h)}return c}}class p3 extends Ti{constructor(e,t){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(){}}class m3 extends li{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Cd}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Cd);const j3=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:FS,AddEquation:vr,AddOperation:DS,AdditiveAnimationBlendMode:Km,AdditiveBlending:Cp,AgXToneMapping:zS,AlphaFormat:jm,AlwaysCompare:tM,AlwaysDepth:AS,AlwaysStencilFunc:Np,AmbientLight:nw,AnimationAction:dw,AnimationClip:Sl,AnimationLoader:pN,AnimationMixer:GN,AnimationObjectGroup:VN,AnimationUtils:uN,ArcCurve:AM,ArrayCamera:xM,ArrowHelper:d3,AttachedBindMode:Ip,Audio:cw,AudioAnalyser:IN,AudioContext:Mg,AudioListener:CN,AudioLoader:EN,AxesHelper:h3,BackSide:fn,BasicDepthPacking:XS,BasicShadowMap:lT,BatchedMesh:bM,Bone:lg,BooleanKeyframeTrack:Rs,Box2:KN,Box3:pn,Box3Helper:c3,BoxGeometry:Cs,BoxHelper:l3,BufferAttribute:ht,BufferGeometry:$e,BufferGeometryLoader:aw,ByteType:Hm,Cache:Hi,Camera:zd,CameraHelper:a3,CanvasTexture:DI,CapsuleGeometry:qd,CatmullRomCurve3:CM,CineonToneMapping:OS,CircleGeometry:Zd,ClampToEdgeWrapping:Xn,Clock:lw,Color:ye,ColorKeyframeTrack:yg,ColorManagement:rt,CompressedArrayTexture:NI,CompressedCubeTexture:LI,CompressedTexture:Yd,CompressedTextureLoader:mN,ConeGeometry:Kd,ConstantAlphaFactor:bS,ConstantColorFactor:MS,Controls:p3,CubeCamera:cM,CubeReflectionMapping:Ki,CubeRefractionMapping:Ir,CubeTexture:Il,CubeTextureLoader:gN,CubeUVReflectionMapping:Vo,CubicBezierCurve:dg,CubicBezierCurve3:RM,CubicInterpolant:$M,CullFaceBack:Ap,CullFaceFront:oS,CullFaceFrontBack:aT,CullFaceNone:sS,Curve:ui,CurvePath:IM,CustomBlending:lS,CustomToneMapping:BS,CylinderGeometry:Xo,Cylindrical:ZN,Data3DTexture:eg,DataArrayTexture:Fd,DataTexture:wi,DataTextureLoader:xN,DataUtils:SA,DecrementStencilOp:MT,DecrementWrapStencilOp:bT,DefaultLoadingManager:KM,DepthFormat:ps,DepthStencilFormat:ws,DepthTexture:rg,DetachedBindMode:HS,DirectionalLight:tw,DirectionalLightHelper:o3,DiscreteInterpolant:qM,DisplayP3ColorSpace:Od,DodecahedronGeometry:Jd,DoubleSide:vi,DstAlphaFactor:xS,DstColorFactor:yS,DynamicCopyUsage:BT,DynamicDrawUsage:LT,DynamicReadUsage:kT,EdgesGeometry:NM,EllipseCurve:$d,EqualCompare:KS,EqualDepth:RS,EqualStencilFunc:CT,EquirectangularReflectionMapping:il,EquirectangularRefractionMapping:rl,Euler:On,EventDispatcher:Ti,ExtrudeGeometry:eh,FileLoader:Qi,Float16BufferAttribute:AA,Float32BufferAttribute:Ce,FloatType:Sn,Fog:Wd,FogExp2:Gd,FramebufferTexture:II,FrontSide:Zi,Frustum:Nl,GLBufferAttribute:YN,GLSL1:VT,GLSL3:Lp,GreaterCompare:JS,GreaterDepth:IS,GreaterEqualCompare:eM,GreaterEqualDepth:PS,GreaterEqualStencilFunc:NT,GreaterStencilFunc:PT,GridHelper:r3,Group:go,HalfFloatType:Ho,HemisphereLight:JM,HemisphereLightHelper:i3,IcosahedronGeometry:th,ImageBitmapLoader:bN,ImageLoader:Ml,ImageUtils:rM,IncrementStencilOp:ST,IncrementWrapStencilOp:wT,InstancedBufferAttribute:Oo,InstancedBufferGeometry:ow,InstancedInterleavedBuffer:XN,InstancedMesh:wM,Int16BufferAttribute:EA,Int32BufferAttribute:TA,Int8BufferAttribute:MA,IntType:Pd,InterleavedBuffer:jd,InterleavedBufferAttribute:bs,Interpolant:kl,InterpolateDiscrete:al,InterpolateLinear:ad,InterpolateSmooth:au,InvertStencilOp:ET,KeepStencilOp:ts,KeyframeTrack:di,LOD:SM,LatheGeometry:Ll,Layers:Bd,LessCompare:ZS,LessDepth:CS,LessEqualCompare:Jm,LessEqualDepth:nl,LessEqualStencilFunc:RT,LessStencilFunc:AT,Light:Br,LightProbe:sw,Line:Nr,Line3:JN,LineBasicMaterial:xn,LineCurve:hg,LineCurve3:PM,LineDashedMaterial:jM,LineLoop:EM,LineSegments:Ai,LinearDisplayP3ColorSpace:Pl,LinearFilter:Ut,LinearInterpolant:vg,LinearMipMapLinearFilter:hT,LinearMipMapNearestFilter:dT,LinearMipmapLinearFilter:yi,LinearMipmapNearestFilter:Pa,LinearSRGBColorSpace:tr,LinearToneMapping:US,LinearTransfer:cl,Loader:Tn,LoaderUtils:Vp,LoadingManager:_g,LoopOnce:GS,LoopPingPong:jS,LoopRepeat:WS,LuminanceAlphaFormat:$m,LuminanceFormat:Ym,MOUSE:sT,Material:on,MaterialLoader:lh,MathUtils:rA,Matrix2:Tg,Matrix3:je,Matrix4:ke,MaxEquation:hS,Mesh:kt,MeshBasicMaterial:Or,MeshDepthMaterial:sg,MeshDistanceMaterial:og,MeshLambertMaterial:GM,MeshMatcapMaterial:WM,MeshNormalMaterial:HM,MeshPhongMaterial:zM,MeshPhysicalMaterial:BM,MeshStandardMaterial:gg,MeshToonMaterial:VM,MinEquation:dS,MirroredRepeatWrapping:ol,MixOperation:LS,MultiplyBlending:Pp,MultiplyOperation:Cl,NearestFilter:Gt,NearestMipMapLinearFilter:uT,NearestMipMapNearestFilter:cT,NearestMipmapLinearFilter:fo,NearestMipmapNearestFilter:Vm,NeutralToneMapping:VS,NeverCompare:qS,NeverDepth:TS,NeverStencilFunc:TT,NoBlending:Wi,NoColorSpace:Fi,NoToneMapping:ji,NormalAnimationBlendMode:kd,NormalBlending:fs,NotEqualCompare:QS,NotEqualDepth:NS,NotEqualStencilFunc:IT,NumberKeyframeTrack:yl,Object3D:nt,ObjectLoader:MN,ObjectSpaceNormalMap:$S,OctahedronGeometry:Dl,OneFactor:pS,OneMinusConstantAlphaFactor:ES,OneMinusConstantColorFactor:wS,OneMinusDstAlphaFactor:vS,OneMinusDstColorFactor:_S,OneMinusSrcAlphaFactor:Du,OneMinusSrcColorFactor:gS,OrthographicCamera:Vd,P3Primaries:dl,PCFShadowMap:zm,PCFSoftShadowMap:aS,PMREMGenerator:Dp,Path:ml,PerspectiveCamera:$t,Plane:mr,PlaneGeometry:Wo,PlaneHelper:u3,PointLight:ew,PointLightHelper:t3,Points:TM,PointsMaterial:cg,PolarGridHelper:s3,PolyhedronGeometry:Fr,PositionalAudio:PN,PropertyBinding:et,PropertyMixer:uw,QuadraticBezierCurve:fg,QuadraticBezierCurve3:pg,Quaternion:En,QuaternionKeyframeTrack:Ol,QuaternionLinearInterpolant:ZM,RED_GREEN_RGTC2_Format:sd,RED_RGTC1_Format:Zm,REVISION:Cd,RGBADepthPacking:YS,RGBAFormat:dn,RGBAIntegerFormat:Ud,RGBA_ASTC_10x10_Format:Qu,RGBA_ASTC_10x5_Format:Zu,RGBA_ASTC_10x6_Format:Ku,RGBA_ASTC_10x8_Format:Ju,RGBA_ASTC_12x10_Format:ed,RGBA_ASTC_12x12_Format:td,RGBA_ASTC_4x4_Format:Hu,RGBA_ASTC_5x4_Format:Gu,RGBA_ASTC_5x5_Format:Wu,RGBA_ASTC_6x5_Format:ju,RGBA_ASTC_6x6_Format:Xu,RGBA_ASTC_8x5_Format:Yu,RGBA_ASTC_8x6_Format:$u,RGBA_ASTC_8x8_Format:qu,RGBA_BPTC_Format:Ua,RGBA_ETC2_EAC_Format:Vu,RGBA_PVRTC_2BPPV1_Format:Fu,RGBA_PVRTC_4BPPV1_Format:Ou,RGBA_S3TC_DXT1_Format:Na,RGBA_S3TC_DXT3_Format:La,RGBA_S3TC_DXT5_Format:Da,RGBDepthPacking:xT,RGBFormat:Xm,RGBIntegerFormat:fT,RGB_BPTC_SIGNED_Format:nd,RGB_BPTC_UNSIGNED_Format:id,RGB_ETC1_Format:Bu,RGB_ETC2_Format:zu,RGB_PVRTC_2BPPV1_Format:ku,RGB_PVRTC_4BPPV1_Format:Uu,RGB_S3TC_DXT1_Format:Ia,RGDepthPacking:vT,RGFormat:qm,RGIntegerFormat:Dd,RawShaderMaterial:FM,Ray:Go,Raycaster:$N,Rec709Primaries:ul,RectAreaLight:iw,RedFormat:Ld,RedIntegerFormat:Rl,ReinhardToneMapping:kS,RenderTarget:sM,RepeatWrapping:sl,ReplaceStencilOp:_T,ReverseSubtractEquation:uS,RingGeometry:nh,SIGNED_RED_GREEN_RGTC2_Format:od,SIGNED_RED_RGTC1_Format:rd,SRGBColorSpace:Hn,SRGBTransfer:ft,Scene:vM,ShaderChunk:Ye,ShaderLib:ri,ShaderMaterial:ci,ShadowMaterial:OM,Shape:gs,ShapeGeometry:ih,ShapePath:f3,ShapeUtils:bi,ShortType:Gm,Skeleton:Xd,SkeletonHelper:e3,SkinnedMesh:MM,Source:cs,Sphere:rn,SphereGeometry:Ul,Spherical:qN,SphericalHarmonics3:rw,SplineCurve:mg,SpotLight:QM,SpotLightHelper:QN,Sprite:_M,SpriteMaterial:ag,SrcAlphaFactor:Lu,SrcAlphaSaturateFactor:SS,SrcColorFactor:mS,StaticCopyUsage:FT,StaticDrawUsage:hl,StaticReadUsage:UT,StereoCamera:TN,StreamCopyUsage:zT,StreamDrawUsage:DT,StreamReadUsage:OT,StringKeyframeTrack:Ps,SubtractEquation:cS,SubtractiveBlending:Rp,TOUCH:oT,TangentSpaceNormalMap:kr,TetrahedronGeometry:rh,Texture:Ct,TextureLoader:vN,TextureUtils:cI,TorusGeometry:sh,TorusKnotGeometry:oh,Triangle:Nn,TriangleFanDrawMode:gT,TriangleStripDrawMode:mT,TrianglesDrawMode:pT,TubeGeometry:ah,UVMapping:Rd,Uint16BufferAttribute:tg,Uint32BufferAttribute:ng,Uint8BufferAttribute:wA,Uint8ClampedBufferAttribute:bA,Uniform:Eg,UniformsGroup:jN,UniformsLib:fe,UniformsUtils:lM,UnsignedByteType:Ei,UnsignedInt248Type:Ms,UnsignedInt5999Type:Wm,UnsignedIntType:Ji,UnsignedShort4444Type:Id,UnsignedShort5551Type:Nd,UnsignedShortType:Do,VSMShadowMap:gi,Vector2:K,Vector3:I,Vector4:ct,VectorKeyframeTrack:_l,VideoTexture:PI,WebGL3DRenderTarget:dA,WebGLArrayRenderTarget:uA,WebGLCoordinateSystem:_i,WebGLCubeRenderTarget:uM,WebGLMultipleRenderTargets:m3,WebGLRenderTarget:li,WebGLRenderer:yI,WebGLUtils:gM,WebGPUCoordinateSystem:fl,WireframeGeometry:kM,WrapAroundEnding:ll,ZeroCurvatureEnding:as,ZeroFactor:fS,ZeroSlopeEnding:ls,ZeroStencilOp:yT,createCanvasElement:iM},Symbol.toStringTag,{value:"Module"})),ut={controls:null,camera:null,initialPosition:null,initialTarget:null};function X3(n,e){ut.controls=n,ut.camera=e,e&&!ut.initialPosition&&(ut.initialPosition=e.position.clone()),n&&!ut.initialTarget&&(ut.initialTarget=n.target.clone())}function Y3(){ut.controls=null,ut.camera=null}const fw=1.18,Uv=2.5;function pw(n=fw){if(!ut.controls||!ut.camera)return;const e=new I().subVectors(ut.controls.target,ut.camera.position).multiplyScalar(1-1/n);ut.camera.position.add(e),ut.controls.update()}function g3(n=fw){pw(1/n)}function ch(n,e){if(!ut.controls||!ut.camera)return;const t=ut.camera,i=new I().subVectors(ut.controls.target,t.position).normalize(),r=new I().crossVectors(i,t.up).normalize(),s=new I().crossVectors(r,i).normalize(),o=new I().addScaledVector(r,n*Uv).addScaledVector(s,e*Uv);t.position.add(o),ut.controls.target.add(o),ut.controls.update()}const x3=()=>ch(-1,0),v3=()=>ch(1,0),y3=()=>ch(0,1),_3=()=>ch(0,-1);function S3(){!ut.controls||!ut.camera||(ut.initialPosition&&ut.camera.position.copy(ut.initialPosition),ut.initialTarget&&ut.controls.target.copy(ut.initialTarget),ut.controls.update())}function M3(){const n=Ee(_=>_.selectedSessionId),e=Ee(_=>_.sessions),t=Ee(_=>_.missions),i=Ee(_=>_.chatBySessionId),r=Ee(_=>_.selectSession),s=Ee(_=>_.sendPromptTo),[o,a]=Ie.useState("chat"),[l,c]=Ie.useState(""),u=Ie.useRef(null),d=n?e[n]:null,h=Ie.useMemo(()=>n?i[n]??[]:[],[i,n]),p=Ie.useMemo(()=>d?Object.values(t).filter(_=>_.sessionId===d.id).sort((_,R)=>R.startedAt-_.startedAt):[],[t,d]),m=Ie.useMemo(()=>{if(d!=null&&d.currentMissionId)return t[d.currentMissionId]},[t,d]),y=d?ZE(d,m):null;if(Ie.useEffect(()=>{if(o!=="chat")return;const _=u.current;_&&(_.scrollTop=_.scrollHeight)},[o,h.length,n]),!d)return null;const g=d.origin==="internal",f=!!d.wrapperSocketPath,v=g||f,x=()=>{l.trim()&&(s(d.id,l),c(""))};return S.jsxs("div",{className:"absolute top-0 right-0 h-full w-full sm:w-[460px] bg-solix-panel border-l border-solix-border backdrop-blur-md flex flex-col z-20",children:[S.jsxs("div",{className:"px-4 py-3 border-b border-solix-border flex items-start justify-between",children:[S.jsxs("div",{className:"min-w-0",children:[S.jsx("div",{className:"text-xs uppercase tracking-wide text-slate-400",children:"Planet"}),S.jsx("div",{className:"text-lg font-semibold truncate",children:d.name??d.id.slice(0,8)}),S.jsxs("div",{className:"text-xs text-slate-400 mt-0.5 truncate",title:Bm[d.status]??void 0,children:[String(d.model)," · ",rS(d.status),d.origin==="external"?" · external":" · internal",f&&S.jsx("span",{className:"ml-1.5 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide border border-solix-accent/50 text-solix-accent",title:"Wrapped by `solix run` — UI prompts go to your terminal.",children:"wrapped"})]})]}),S.jsx("button",{onClick:()=>r(null),className:"text-slate-400 hover:text-slate-100","aria-label":"Close",children:"✕"})]}),y&&S.jsxs("div",{className:`px-4 py-2 border-b border-solix-border text-[11px] leading-snug ${y.severity==="danger"?"text-solix-danger bg-solix-danger/10":y.severity==="warn"?"text-solix-warn bg-solix-warn/10":"text-slate-300 bg-black/20"}`,children:[S.jsx("span",{className:"font-semibold mr-1",children:"Suggested:"}),y.text]}),S.jsxs("div",{className:"px-4 py-2 border-b border-solix-border",children:[S.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[S.jsx("span",{children:"context"}),S.jsxs("span",{children:[d.contextUsagePct.toFixed(0),"%"]})]}),S.jsx("div",{className:"mt-1 h-1.5 rounded-full bg-slate-800 overflow-hidden",children:S.jsx("div",{className:`h-full ${d.contextUsagePct>=90?"bg-solix-danger":d.contextUsagePct>=80?"bg-solix-warn":"bg-solix-accent"}`,style:{width:`${Math.min(100,d.contextUsagePct)}%`}})})]}),S.jsxs("div",{className:"flex border-b border-solix-border text-xs",children:[S.jsxs(Df,{active:o==="chat",onClick:()=>a("chat"),children:["Chat ",h.length>0&&S.jsxs("span",{className:"opacity-60",children:["(",h.length,")"]})]}),S.jsxs(Df,{active:o==="missions",onClick:()=>a("missions"),children:["Missions ",p.length>0&&S.jsxs("span",{className:"opacity-60",children:["(",p.length,")"]})]}),S.jsx(Df,{active:o==="files",onClick:()=>a("files"),children:"Files"})]}),S.jsxs("div",{className:"flex-1 overflow-hidden",children:[o==="chat"&&S.jsx(w3,{chat:h,scrollRef:u,session:d}),o==="missions"&&S.jsx(b3,{missions:p}),o==="files"&&S.jsx(E3,{missions:p})]}),o==="chat"&&S.jsx("div",{className:"px-3 py-3 border-t border-solix-border",children:v?S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"flex gap-2",children:[S.jsx("textarea",{value:l,onChange:_=>c(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),x())},placeholder:f?"Type a prompt — it goes straight into your terminal claude (Cmd/Ctrl+Enter)":"Send a prompt to this session… (Cmd/Ctrl+Enter)",rows:2,className:"flex-1 text-sm bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent resize-none"}),S.jsx("button",{onClick:x,disabled:!l.trim(),className:"px-3 py-2 rounded bg-solix-accent/20 border border-solix-accent text-solix-accent text-sm hover:bg-solix-accent/30 disabled:opacity-40",children:"Send"})]}),f&&S.jsxs("div",{className:"text-[10px] text-slate-500 italic mt-1.5",children:["Wrapped by ",S.jsx("code",{children:"solix run"}),". Don't type in the terminal while sending from here, or characters will interleave."]})]}):S.jsxs("div",{className:"text-xs text-slate-500",children:["External session — keep typing in your terminal. To send prompts from here instead, restart the session with"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"solix run"}),"."]})})]})}function Df({active:n,onClick:e,children:t}){return S.jsx("button",{onClick:e,className:`flex-1 px-3 py-2 ${n?"text-solix-accent border-b-2 border-solix-accent":"text-slate-400 hover:text-slate-200 border-b-2 border-transparent"}`,children:t})}function w3({chat:n,scrollRef:e,session:t}){return S.jsxs("div",{ref:e,className:"h-full overflow-y-auto p-4 space-y-3",children:[n.length===0&&S.jsxs("div",{className:"text-sm text-slate-500 italic",children:["No chat yet. Type a prompt to this session in your terminal — it will stream here as it happens.",S.jsxs("div",{className:"mt-2 text-[11px] text-slate-600",children:["Watching transcript at ",S.jsxs("code",{children:["~/.claude/projects/","<encoded>","/",t.id,".jsonl"]})]})]}),n.map(i=>S.jsx("div",{className:`flex ${i.role==="user"?"justify-end":"justify-start"}`,children:S.jsxs("div",{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${i.role==="user"?"bg-solix-accent/15 border border-solix-accent/40 text-slate-100":"bg-black/40 border border-solix-border text-slate-200"}`,children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide opacity-60 mb-1",children:[i.role,S.jsx("span",{className:"ml-2 text-slate-500",children:new Date(i.ts).toLocaleTimeString()})]}),S.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed",children:i.content})]})},i.messageId))]})}function b3({missions:n}){return S.jsx("div",{className:"h-full overflow-y-auto p-4 space-y-3",children:n.length===0?S.jsx("div",{className:"text-sm text-slate-500 italic",children:"No missions yet."}):n.map(e=>S.jsxs("div",{className:"rounded border border-solix-border p-3 bg-black/30",children:[S.jsxs("div",{className:"flex items-center justify-between text-xs",children:[S.jsx("span",{className:`font-semibold ${e.status==="active"?"text-solix-warn":e.status==="completed"?"text-solix-ok":"text-slate-300"}`,children:e.shortName}),S.jsx("span",{className:"text-slate-500",children:new Date(e.startedAt).toLocaleTimeString()})]}),S.jsx("div",{className:"mt-1 text-sm text-slate-200 line-clamp-3",children:e.prompt}),S.jsxs("div",{className:"mt-2 flex gap-3 text-[10px] text-slate-500",children:[S.jsxs("span",{children:[e.metrics.toolCallCount," tools"]}),S.jsxs("span",{children:[e.metrics.subagentCount," subagents"]}),S.jsxs("span",{children:[e.filesTouched.length," files"]}),e.metrics.durationMs!==void 0&&S.jsxs("span",{children:[(e.metrics.durationMs/1e3).toFixed(1),"s"]})]})]},e.id))})}function E3({missions:n}){const e=Array.from(new Set(n.flatMap(t=>t.filesTouched))).sort();return S.jsx("div",{className:"h-full overflow-y-auto p-4",children:e.length===0?S.jsx("div",{className:"text-sm text-slate-500 italic",children:"No files touched yet."}):S.jsx("ul",{className:"space-y-1 text-xs font-mono text-slate-300",children:e.map(t=>S.jsx("li",{className:"truncate",children:t},t))})})}function T3(){const n=Ee(m=>m.selectedAdvisorId),e=Ee(m=>n?m.advisors[n]:null),t=Ee(m=>m.selectedSessionId?m.sessions[m.selectedSessionId]:null),i=Ee(m=>m.selectAdvisor),r=Ee(m=>m.invokeAdvisor),s=Ee(m=>m.pinAdvisor),o=Ee(m=>m.unpinAdvisor),[a,l]=Ie.useState(""),[c,u]=Ie.useState(null),[d,h]=Ie.useState(!1);if(Ie.useEffect(()=>{if(!e){u(null);return}let m=!1;const y=new URLSearchParams;t&&y.set("targetSessionId",t.id),a.trim()&&y.set("prompt",a.trim());const g=y.toString();return fetch(`/api/advisors/${encodeURIComponent(e.id)}/preview${g?`?${g}`:""}`).then(f=>f.ok?f.json():null).then(f=>{m||u(f)}).catch(()=>{m||u(null)}),()=>{m=!0}},[e==null?void 0:e.id,t==null?void 0:t.id,a]),!e)return null;const p=()=>{r(e.id,a.trim()||void 0),l("")};return S.jsxs("div",{className:"absolute top-0 right-0 h-full w-[420px] bg-solix-panel border-l border-solix-border backdrop-blur-md flex flex-col z-20",children:[S.jsxs("div",{className:"px-4 py-3 border-b border-solix-border flex items-start justify-between",children:[S.jsxs("div",{children:[S.jsx("div",{className:"text-xs uppercase tracking-wide text-amber-200/70",children:"Advisor"}),S.jsxs("div",{className:"text-lg font-semibold flex items-center gap-2",children:[S.jsx("span",{style:{color:e.color},children:e.glyph}),S.jsx("span",{children:e.codename}),e.pinned&&S.jsx("span",{className:"text-[10px] uppercase tracking-wider text-amber-300 border border-amber-300/40 rounded px-1.5 py-0.5",children:"pinned"})]}),S.jsxs("div",{className:"text-xs text-slate-400 mt-0.5",children:[e.name," · ",String(e.defaultModel)]})]}),S.jsx("button",{onClick:()=>i(null),className:"text-slate-400 hover:text-slate-100","aria-label":"Close",children:"✕"})]}),S.jsx("div",{className:"px-4 py-3 border-b border-solix-border text-sm text-slate-300 leading-relaxed",children:e.description}),e.requiredSkills.length>0&&S.jsxs("div",{className:"px-4 py-2 border-b border-solix-border",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500 mb-1",children:"requires skills"}),S.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.requiredSkills.map(m=>S.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-solix-accent/15 border border-solix-accent/40 text-solix-accent",children:m},m))})]}),S.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 text-sm text-slate-300",children:[S.jsx("div",{className:"text-xs uppercase tracking-wide text-slate-400",children:"Invoke"}),S.jsx("div",{className:"text-xs text-slate-500",children:t?S.jsxs(S.Fragment,{children:["Will dispatch to"," ",S.jsx("span",{className:"text-slate-200",children:t.name??t.id.slice(0,8)})," ",S.jsxs("span",{className:"text-slate-500",children:["(",t.cwd,")"]})]}):S.jsx(S.Fragment,{children:"No planet focused. Click a user planet first to set a target."})}),S.jsx("textarea",{value:a,onChange:m=>l(m.target.value),placeholder:`Optional: hand ${e.codename} a specific brief…`,rows:4,className:"w-full text-sm bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent resize-none"}),c&&S.jsxs("div",{className:"rounded border border-solix-border bg-black/30",children:[S.jsxs("button",{onClick:()=>h(m=>!m),className:"w-full text-left px-2 py-1.5 text-xs flex items-center justify-between text-slate-400 hover:text-slate-100",children:[S.jsxs("span",{children:["Context envelope · ",c.recentMissionsCount," mission(s)",c.contextUsagePct!==null&&` · target at ${c.contextUsagePct.toFixed(0)}%`]}),S.jsx("span",{children:d?"▾":"▸"})]}),d&&S.jsx("pre",{className:"text-[10.5px] text-slate-300 whitespace-pre-wrap px-3 pb-3 max-h-72 overflow-auto leading-relaxed",children:c.prompt})]})]}),S.jsxs("div",{className:"px-4 py-3 border-t border-solix-border flex gap-2",children:[S.jsx("button",{onClick:p,className:"flex-1 py-2 rounded bg-solix-accent/20 border border-solix-accent text-solix-accent text-sm hover:bg-solix-accent/30",children:"Invoke"}),e.pinned?S.jsx("button",{onClick:()=>o(e.id),className:"px-3 py-2 rounded bg-amber-500/15 border border-amber-400/50 text-amber-200 text-sm hover:bg-amber-500/25",children:"Unpin"}):S.jsx("button",{onClick:()=>s(e.id),className:"px-3 py-2 rounded bg-amber-500/10 border border-amber-400/30 text-amber-200/80 text-sm hover:bg-amber-500/20",title:"Spawn an always-on session for this advisor",children:"Pin"})]})]})}function A3(){const n=Ee(c=>c.selectedSkillId),e=Ee(c=>n?c.skills[n]:null),t=Ee(c=>c.selectSkill),i=Ee(c=>c.advisors),[r,s]=Ie.useState(null),[o,a]=Ie.useState(!1);if(Ie.useEffect(()=>{if(!n){s(null);return}let c=!1;return a(!0),fetch(`/api/skills/${encodeURIComponent(n)}`).then(u=>u.ok?u.json():null).then(u=>{c||s(u)}).catch(()=>{c||s(null)}).finally(()=>{c||a(!1)}),()=>{c=!0}},[n]),!e)return null;const l=Object.values(i).filter(c=>c.requiredSkills.some(u=>e.id.endsWith(`:${u}`)||e.id===u));return S.jsxs("div",{className:"absolute top-0 right-0 h-full w-[480px] bg-solix-panel border-l border-solix-border backdrop-blur-md flex flex-col z-20",children:[S.jsxs("div",{className:"px-4 py-3 border-b border-solix-border flex items-start justify-between",children:[S.jsxs("div",{children:[S.jsxs("div",{className:"text-xs uppercase tracking-wide text-cyan-300/70",children:["Skill · ",e.source]}),S.jsx("div",{className:"text-lg font-semibold",children:e.name}),S.jsx("div",{className:"text-xs text-slate-400 mt-0.5 break-all",children:e.id})]}),S.jsx("button",{onClick:()=>t(null),className:"text-slate-400 hover:text-slate-100","aria-label":"Close",children:"✕"})]}),l.length>0&&S.jsxs("div",{className:"px-4 py-2 border-b border-solix-border",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500 mb-1",children:"required by"}),S.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.map(c=>S.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded border border-amber-300/40 text-amber-200",children:[S.jsx("span",{className:"mr-1",children:c.glyph}),c.codename]},c.id))})]}),S.jsx("div",{className:"px-4 py-3 border-b border-solix-border text-sm text-slate-300 leading-relaxed",children:e.description}),S.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500 mb-2",children:"manifest"}),o&&S.jsx("div",{className:"text-sm text-slate-500 italic",children:"Loading…"}),r&&S.jsx("pre",{className:"text-[11px] text-slate-300 whitespace-pre-wrap break-words bg-black/40 p-3 rounded border border-solix-border",children:r.manifest})]}),S.jsx("div",{className:"px-4 py-3 border-t border-solix-border text-xs text-slate-500",children:e.installedInProjects.length===0?"Not installed in any project yet.":`Installed in ${e.installedInProjects.length} project(s).`})]})}const C3=["default","opus","sonnet","haiku"];function R3({open:n,onClose:e}){const t=Ee(M=>M.projects),i=Ee(M=>M.advisors),r=Ee(M=>M.launchTask),s=Object.values(t).sort((M,T)=>T.lastActiveAt-M.lastActiveAt),o=Ie.useMemo(()=>Object.values(i).filter(M=>M.enabled).sort((M,T)=>M.codename.localeCompare(T.codename)),[i]),[a,l]=Ie.useState(""),[c,u]=Ie.useState("default"),[d,h]=Ie.useState(null),[p,m]=Ie.useState(""),[y,g]=Ie.useState(""),[f,v]=Ie.useState(""),[x,_]=Ie.useState(null);if(Ie.useEffect(()=>{if(!n)return;let M=!1;return fetch("/api/system/preflight").then(T=>T.ok?T.json():null).then(T=>{M||_(T)}).catch(()=>{}),()=>{M=!0}},[n]),Ie.useEffect(()=>{if(!n||a)return;const M=s[0];M&&l(M.cwd)},[n,s,a]),!n)return null;const R=()=>{const M=a.trim(),T=p.trim();if(!M||!T)return;const A=d?o.find(V=>V.id===d):void 0,E=A?`[Acting as ${A.codename} — ${A.name}. ${A.description}]
3899
3899
 
3900
- ${T}`:T,w=A&&c==="default"?A.defaultModel:c,L=y.trim();r(M,w,E,{worktreeBranch:L||void 0,worktreeBaseRef:L&&f.trim()||void 0}),m(""),h(null),g(""),v(""),e()};return S.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm",children:S.jsxs("div",{className:"w-[520px] max-w-[92vw] rounded-xl border border-solix-accent/40 bg-solix-panel/95 shadow-2xl",children:[S.jsxs("div",{className:"px-5 py-4 border-b border-solix-border flex items-start justify-between",children:[S.jsxs("div",{children:[S.jsx("div",{className:"text-xs uppercase tracking-widest text-solix-accent",children:"new task"}),S.jsx("div",{className:"text-lg font-semibold mt-0.5",children:"Launch a Claude Code session"}),S.jsxs("div",{className:"text-xs text-slate-400 mt-1",children:["Solix will spawn ",S.jsx("code",{children:"claude --print"})," in this folder. A new planet appears the moment it starts."]}),x&&!x.claudeAvailable&&S.jsxs("div",{className:"mt-2 text-[11px] text-solix-danger border border-solix-danger/40 bg-solix-danger/10 rounded px-2 py-1",children:[S.jsx("span",{className:"font-semibold",children:"claude"})," not found on the server's PATH. Install Claude Code, then restart the Solix server."]}),(x==null?void 0:x.claudeAvailable)&&x.version&&S.jsxs("div",{className:"mt-1 text-[10px] text-slate-500 font-mono",children:["claude detected · ",x.version]})]}),S.jsx("button",{onClick:e,className:"text-slate-400 hover:text-slate-100",children:"✕"})]}),S.jsxs("div",{className:"px-5 py-4 space-y-4",children:[S.jsxs("label",{className:"block",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:"Working directory"}),s.length>0&&S.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:s.slice(0,6).map(M=>S.jsx("button",{onClick:()=>l(M.cwd),className:`text-[10px] px-2 py-1 rounded border ${a===M.cwd?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:M.name},M.id))}),S.jsx("input",{value:a,onChange:M=>l(M.target.value),placeholder:"/Users/you/path/to/project",className:"w-full text-sm font-mono bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent"})]}),S.jsxs("label",{className:"block",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:"Model"}),S.jsx("div",{className:"flex gap-1.5",children:C3.map(M=>S.jsx("button",{onClick:()=>u(M),className:`text-xs px-3 py-1.5 rounded border ${c===M?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:M},M))})]}),o.length>0&&S.jsxs("label",{className:"block",children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:["Advisor ",S.jsx("span",{className:"text-slate-600 normal-case",children:"(optional)"})]}),S.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[S.jsx("button",{onClick:()=>h(null),className:`text-xs px-3 py-1.5 rounded border ${d===null?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:"none"}),o.map(M=>S.jsxs("button",{onClick:()=>h(M.id),title:M.description,className:`text-xs px-3 py-1.5 rounded border flex items-center gap-1.5 ${d===M.id?"border-amber-300 text-amber-100 bg-amber-500/15":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:[S.jsx("span",{style:{color:M.color},children:M.glyph}),M.codename]},M.id))]}),d&&S.jsx("div",{className:"mt-1.5 text-[10px] text-slate-500 italic",children:"The advisor's role will be prepended to your prompt."})]}),S.jsxs("label",{className:"block",children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:["Worktree branch"," ",S.jsx("span",{className:"text-slate-600 normal-case",children:"(optional)"})]}),S.jsx("input",{value:y,onChange:M=>g(M.target.value),placeholder:"leave empty to run in the chosen directory",className:"w-full text-sm font-mono bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent"}),y.trim()&&S.jsxs("div",{className:"mt-2 space-y-1",children:[S.jsxs("div",{className:"text-[10px] text-slate-500 italic",children:["Solix will create (or reuse) a fresh git worktree at ~/.solix/worktrees/<repo>-",y.trim()||"<branch>","and spawn Claude there. Existing branches are reused."]}),S.jsx("input",{value:f,onChange:M=>v(M.target.value),placeholder:"based on (default: HEAD)",className:"w-full text-xs font-mono bg-black/40 border border-solix-border rounded p-1.5 text-slate-200 placeholder-slate-600 focus:outline-none focus:border-solix-accent"})]})]}),S.jsxs("label",{className:"block",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:"Prompt"}),S.jsx("textarea",{value:p,onChange:M=>m(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.metaKey||M.ctrlKey)&&(M.preventDefault(),R())},placeholder:"What should this Claude Code session do?",rows:4,className:"w-full text-sm bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent resize-none"})]})]}),S.jsxs("div",{className:"px-5 py-3 border-t border-solix-border flex items-center gap-2",children:[S.jsx("button",{onClick:e,className:"px-3 py-1.5 rounded border border-solix-border text-xs text-slate-300 hover:text-white",children:"Cancel"}),S.jsx("div",{className:"flex-1"}),S.jsx("span",{className:"text-[10px] text-slate-500 mr-2",children:"Cmd/Ctrl+Enter"}),S.jsx("button",{onClick:R,disabled:!a.trim()||!p.trim()||(x==null?void 0:x.claudeAvailable)===!1,className:"px-4 py-1.5 rounded bg-solix-accent/20 border border-solix-accent text-solix-accent text-sm hover:bg-solix-accent/30 disabled:opacity-40",children:"Launch"})]})]})})}const P3=1500;function I3(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`}function N3(){let n=null,e=!1;const t=r=>{n&&n.readyState===WebSocket.OPEN&&n.send(JSON.stringify(r))};Ee.getState().attachSocket(t);const i=()=>{if(e)return;n=new WebSocket(I3()),n.onopen=()=>{Ee.getState().setConnected(!0)},n.onmessage=s=>{try{const o=JSON.parse(s.data);Ee.getState().applyMessage(o)}catch(o){console.warn("[ws] bad message",o)}};const r=()=>{Ee.getState().setConnected(!1),e||setTimeout(i,P3)};n.onclose=r,n.onerror=()=>n==null?void 0:n.close()};i(),window.addEventListener("beforeunload",()=>{e=!0,n==null||n.close()})}const L3=Ie.lazy(()=>Om(()=>import("./Scene-BRE59mDX.js"),[]).then(n=>({default:n.Scene}))),D3=Ie.lazy(()=>Om(()=>import("./TimelineDrawer-D164Rv-U.js"),[]).then(n=>({default:n.TimelineDrawer}))),U3=Ie.lazy(()=>Om(()=>import("./GalaxyPanel-B1Y8EmJ-.js"),[]).then(n=>({default:n.GalaxyPanel})));function k3(){const[n,e]=Ie.useState(!1),[t,i]=Ie.useState(!1),[r,s]=Ie.useState(!1),[o,a]=Ie.useState(!1);return Ie.useEffect(()=>{N3()},[]),Ie.useEffect(()=>{const l=c=>{const u=Ee.getState(),d=c.target,h=(d==null?void 0:d.tagName)==="INPUT"||(d==null?void 0:d.tagName)==="TEXTAREA"||(d==null?void 0:d.isContentEditable)===!0,m=Object.values(u.pendingPermissions)[0];c.key==="Escape"?(u.selectSession(null),u.selectAdvisor(null),u.selectSkill(null),e(!1),i(!1),a(!1),u.playback.active&&(u.exitPlayback(),s(!1))):!h&&c.key==="?"?a(y=>!y):!h&&(c.key==="g"||c.key==="G")?e(y=>!y):!h&&(c.key==="l"||c.key==="L")?i(!0):!h&&(c.key==="+"||c.key==="=")?pw():!h&&c.key==="-"?g3():!h&&c.key==="0"?S3():!h&&c.key==="ArrowLeft"?x3():!h&&c.key==="ArrowRight"?v3():!h&&c.key==="ArrowUp"?y3():!h&&c.key==="ArrowDown"?_3():!h&&c.key===" "?(c.preventDefault(),u.toggleMotion()):!h&&(c.key==="v"||c.key==="V")?u.toggleViewMode():!h&&(c.key==="m"||c.key==="M")?u.setViewMode("missions"):!h&&(c.key==="t"||c.key==="T")?s(y=>!y):!h&&m&&(c.key==="y"||c.key==="Y")?u.resolvePermission(m.requestId,!0):!h&&m&&(c.key==="n"||c.key==="N")&&u.resolvePermission(m.requestId,!1)};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),S.jsxs("div",{className:"relative h-full w-full",children:[S.jsx(O3,{}),S.jsx(jE,{onOpenGalaxy:()=>e(!0),onNewTask:()=>i(!0),onOpenTimeline:()=>s(!0),onOpenHelp:()=>a(!0)}),S.jsx(KE,{}),S.jsx(M3,{}),S.jsx(T3,{}),S.jsx(A3,{}),n&&S.jsx(Ie.Suspense,{fallback:null,children:S.jsx(U3,{open:n,onClose:()=>e(!1)})}),S.jsx(R3,{open:t,onClose:()=>i(!1)}),r&&S.jsx(Ie.Suspense,{fallback:null,children:S.jsx(D3,{open:r,onClose:()=>s(!1)})}),S.jsx(rT,{}),S.jsx($E,{onOpenGalaxy:()=>e(!0),forceOpen:o,onClose:()=>a(!1)}),S.jsx(YE,{}),S.jsx(B3,{})]})}function O3(){const n=Ee(e=>e.viewMode);return n==="list"?S.jsx(DE,{}):n==="missions"?S.jsx(VE,{}):S.jsx(Ie.Suspense,{fallback:S.jsx(F3,{}),children:S.jsx(L3,{})})}function F3(){return S.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-solix-bg z-0",children:S.jsx("div",{className:"text-xs text-slate-500 uppercase tracking-widest solix-pulse",children:"loading galaxy…"})})}function B3(){const n=Ee(t=>Object.keys(t.sessions).length),e=Ee(t=>t.connected);return n>0?null:S.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center z-10",children:S.jsxs("div",{className:"rounded-lg border border-solix-border bg-solix-panel p-6 max-w-md text-center backdrop-blur",children:[S.jsx("div",{className:"text-sm uppercase tracking-widest text-solix-accent",children:"empty system"}),S.jsx("div",{className:"mt-2 text-slate-200",children:e?"Run `claude` in any terminal — the planet will appear here.":"Waiting for the Solix server…"}),S.jsx("div",{className:"mt-3 text-xs text-slate-500",children:"The sun is mission control. Each agent orbits it as a planet."})]})})}const mw=document.getElementById("root");if(!mw)throw new Error("#root not found");q_(mw).render(S.jsx(Ie.StrictMode,{children:S.jsx(k3,{})}));export{Eg as $,FS as A,lT as B,zd as C,vi as D,HM as E,Sn as F,Gt as G,XS as H,Ti as I,tr as J,Fi as K,Bd as L,sT as M,ji as N,Vd as O,$t as P,En as Q,$N as R,vM as S,j3 as T,Ei as U,gi as V,yI as W,kt as X,fn as Y,Zi as Z,Wi as _,aS as a,on as a0,AS as a1,$e as a2,ht as a3,ct as a4,Uw as a5,Ho as a6,sl as a7,Ee as a8,IE as a9,G3 as aa,rA as ab,z3 as ac,NE as ad,Bm as ae,rS as af,LE as ag,V3 as ah,H3 as ai,nt as aj,iS as ak,PE as al,X3 as am,Y3 as an,zm as b,I as c,K as d,lw as e,dn as f,kv as g,q_ as h,oT as i,S as j,qN as k,Go as l,mr as m,Ct as n,vN as o,Cd as p,ye as q,Ie as r,Cp as s,ci as t,Hn as u,rg as v,ws as w,Ms as x,li as y,Ut as z};
3900
+ ${T}`:T,w=A&&c==="default"?A.defaultModel:c,L=y.trim();r(M,w,E,{worktreeBranch:L||void 0,worktreeBaseRef:L&&f.trim()||void 0}),m(""),h(null),g(""),v(""),e()};return S.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm",children:S.jsxs("div",{className:"w-[520px] max-w-[92vw] rounded-xl border border-solix-accent/40 bg-solix-panel/95 shadow-2xl",children:[S.jsxs("div",{className:"px-5 py-4 border-b border-solix-border flex items-start justify-between",children:[S.jsxs("div",{children:[S.jsx("div",{className:"text-xs uppercase tracking-widest text-solix-accent",children:"new task"}),S.jsx("div",{className:"text-lg font-semibold mt-0.5",children:"Launch a Claude Code session"}),S.jsxs("div",{className:"text-xs text-slate-400 mt-1",children:["Solix will spawn ",S.jsx("code",{children:"claude --print"})," in this folder. A new planet appears the moment it starts."]}),x&&!x.claudeAvailable&&S.jsxs("div",{className:"mt-2 text-[11px] text-solix-danger border border-solix-danger/40 bg-solix-danger/10 rounded px-2 py-1",children:[S.jsx("span",{className:"font-semibold",children:"claude"})," not found on the server's PATH. Install Claude Code, then restart the Solix server."]}),(x==null?void 0:x.claudeAvailable)&&x.version&&S.jsxs("div",{className:"mt-1 text-[10px] text-slate-500 font-mono",children:["claude detected · ",x.version]})]}),S.jsx("button",{onClick:e,className:"text-slate-400 hover:text-slate-100",children:"✕"})]}),S.jsxs("div",{className:"px-5 py-4 space-y-4",children:[S.jsxs("label",{className:"block",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:"Working directory"}),s.length>0&&S.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:s.slice(0,6).map(M=>S.jsx("button",{onClick:()=>l(M.cwd),className:`text-[10px] px-2 py-1 rounded border ${a===M.cwd?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:M.name},M.id))}),S.jsx("input",{value:a,onChange:M=>l(M.target.value),placeholder:"/Users/you/path/to/project",className:"w-full text-sm font-mono bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent"})]}),S.jsxs("label",{className:"block",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:"Model"}),S.jsx("div",{className:"flex gap-1.5",children:C3.map(M=>S.jsx("button",{onClick:()=>u(M),className:`text-xs px-3 py-1.5 rounded border ${c===M?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:M},M))})]}),o.length>0&&S.jsxs("label",{className:"block",children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:["Advisor ",S.jsx("span",{className:"text-slate-600 normal-case",children:"(optional)"})]}),S.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[S.jsx("button",{onClick:()=>h(null),className:`text-xs px-3 py-1.5 rounded border ${d===null?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:"none"}),o.map(M=>S.jsxs("button",{onClick:()=>h(M.id),title:M.description,className:`text-xs px-3 py-1.5 rounded border flex items-center gap-1.5 ${d===M.id?"border-amber-300 text-amber-100 bg-amber-500/15":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:[S.jsx("span",{style:{color:M.color},children:M.glyph}),M.codename]},M.id))]}),d&&S.jsx("div",{className:"mt-1.5 text-[10px] text-slate-500 italic",children:"The advisor's role will be prepended to your prompt."})]}),S.jsxs("label",{className:"block",children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:["Worktree branch"," ",S.jsx("span",{className:"text-slate-600 normal-case",children:"(optional)"})]}),S.jsx("input",{value:y,onChange:M=>g(M.target.value),placeholder:"leave empty to run in the chosen directory",className:"w-full text-sm font-mono bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent"}),y.trim()&&S.jsxs("div",{className:"mt-2 space-y-1",children:[S.jsxs("div",{className:"text-[10px] text-slate-500 italic",children:["Solix will create (or reuse) a fresh git worktree at ~/.solix/worktrees/<repo>-",y.trim()||"<branch>","and spawn Claude there. Existing branches are reused."]}),S.jsx("input",{value:f,onChange:M=>v(M.target.value),placeholder:"based on (default: HEAD)",className:"w-full text-xs font-mono bg-black/40 border border-solix-border rounded p-1.5 text-slate-200 placeholder-slate-600 focus:outline-none focus:border-solix-accent"})]})]}),S.jsxs("label",{className:"block",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:"Prompt"}),S.jsx("textarea",{value:p,onChange:M=>m(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.metaKey||M.ctrlKey)&&(M.preventDefault(),R())},placeholder:"What should this Claude Code session do?",rows:4,className:"w-full text-sm bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent resize-none"})]})]}),S.jsxs("div",{className:"px-5 py-3 border-t border-solix-border flex items-center gap-2",children:[S.jsx("button",{onClick:e,className:"px-3 py-1.5 rounded border border-solix-border text-xs text-slate-300 hover:text-white",children:"Cancel"}),S.jsx("div",{className:"flex-1"}),S.jsx("span",{className:"text-[10px] text-slate-500 mr-2",children:"Cmd/Ctrl+Enter"}),S.jsx("button",{onClick:R,disabled:!a.trim()||!p.trim()||(x==null?void 0:x.claudeAvailable)===!1,className:"px-4 py-1.5 rounded bg-solix-accent/20 border border-solix-accent text-solix-accent text-sm hover:bg-solix-accent/30 disabled:opacity-40",children:"Launch"})]})]})})}const P3=1500;function I3(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`}function N3(){let n=null,e=!1;const t=r=>{n&&n.readyState===WebSocket.OPEN&&n.send(JSON.stringify(r))};Ee.getState().attachSocket(t);const i=()=>{if(e)return;n=new WebSocket(I3()),n.onopen=()=>{Ee.getState().setConnected(!0)},n.onmessage=s=>{try{const o=JSON.parse(s.data);Ee.getState().applyMessage(o)}catch(o){console.warn("[ws] bad message",o)}};const r=()=>{Ee.getState().setConnected(!1),e||setTimeout(i,P3)};n.onclose=r,n.onerror=()=>n==null?void 0:n.close()};i(),window.addEventListener("beforeunload",()=>{e=!0,n==null||n.close()})}const L3=Ie.lazy(()=>Om(()=>import("./Scene-DGvQzQki.js"),[]).then(n=>({default:n.Scene}))),D3=Ie.lazy(()=>Om(()=>import("./TimelineDrawer-CcNI10xd.js"),[]).then(n=>({default:n.TimelineDrawer}))),U3=Ie.lazy(()=>Om(()=>import("./GalaxyPanel-D3Z8JKOp.js"),[]).then(n=>({default:n.GalaxyPanel})));function k3(){const[n,e]=Ie.useState(!1),[t,i]=Ie.useState(!1),[r,s]=Ie.useState(!1),[o,a]=Ie.useState(!1);return Ie.useEffect(()=>{N3()},[]),Ie.useEffect(()=>{const l=c=>{const u=Ee.getState(),d=c.target,h=(d==null?void 0:d.tagName)==="INPUT"||(d==null?void 0:d.tagName)==="TEXTAREA"||(d==null?void 0:d.isContentEditable)===!0,m=Object.values(u.pendingPermissions)[0];c.key==="Escape"?(u.selectSession(null),u.selectAdvisor(null),u.selectSkill(null),e(!1),i(!1),a(!1),u.playback.active&&(u.exitPlayback(),s(!1))):!h&&c.key==="?"?a(y=>!y):!h&&(c.key==="g"||c.key==="G")?e(y=>!y):!h&&(c.key==="l"||c.key==="L")?i(!0):!h&&(c.key==="+"||c.key==="=")?pw():!h&&c.key==="-"?g3():!h&&c.key==="0"?S3():!h&&c.key==="ArrowLeft"?x3():!h&&c.key==="ArrowRight"?v3():!h&&c.key==="ArrowUp"?y3():!h&&c.key==="ArrowDown"?_3():!h&&c.key===" "?(c.preventDefault(),u.toggleMotion()):!h&&(c.key==="v"||c.key==="V")?u.toggleViewMode():!h&&(c.key==="m"||c.key==="M")?u.setViewMode("missions"):!h&&(c.key==="t"||c.key==="T")?s(y=>!y):!h&&m&&(c.key==="y"||c.key==="Y")?u.resolvePermission(m.requestId,!0):!h&&m&&(c.key==="n"||c.key==="N")&&u.resolvePermission(m.requestId,!1)};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),S.jsxs("div",{className:"relative h-full w-full",children:[S.jsx(O3,{}),S.jsx(jE,{onOpenGalaxy:()=>e(!0),onNewTask:()=>i(!0),onOpenTimeline:()=>s(!0),onOpenHelp:()=>a(!0)}),S.jsx(KE,{}),S.jsx(M3,{}),S.jsx(T3,{}),S.jsx(A3,{}),n&&S.jsx(Ie.Suspense,{fallback:null,children:S.jsx(U3,{open:n,onClose:()=>e(!1)})}),S.jsx(R3,{open:t,onClose:()=>i(!1)}),r&&S.jsx(Ie.Suspense,{fallback:null,children:S.jsx(D3,{open:r,onClose:()=>s(!1)})}),S.jsx(rT,{}),S.jsx($E,{onOpenGalaxy:()=>e(!0),forceOpen:o,onClose:()=>a(!1)}),S.jsx(YE,{}),S.jsx(B3,{})]})}function O3(){const n=Ee(e=>e.viewMode);return n==="list"?S.jsx(DE,{}):n==="missions"?S.jsx(VE,{}):S.jsx(Ie.Suspense,{fallback:S.jsx(F3,{}),children:S.jsx(L3,{})})}function F3(){return S.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-solix-bg z-0",children:S.jsx("div",{className:"text-xs text-slate-500 uppercase tracking-widest solix-pulse",children:"loading galaxy…"})})}function B3(){const n=Ee(t=>Object.keys(t.sessions).length),e=Ee(t=>t.connected);return n>0?null:S.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center z-10",children:S.jsxs("div",{className:"rounded-lg border border-solix-border bg-solix-panel p-6 max-w-md text-center backdrop-blur",children:[S.jsx("div",{className:"text-sm uppercase tracking-widest text-solix-accent",children:"empty system"}),S.jsx("div",{className:"mt-2 text-slate-200",children:e?"Run `claude` in any terminal — the planet will appear here.":"Waiting for the Solix server…"}),S.jsx("div",{className:"mt-3 text-xs text-slate-500",children:"The sun is mission control. Each agent orbits it as a planet."})]})})}const mw=document.getElementById("root");if(!mw)throw new Error("#root not found");q_(mw).render(S.jsx(Ie.StrictMode,{children:S.jsx(k3,{})}));export{Eg as $,FS as A,lT as B,zd as C,vi as D,HM as E,Sn as F,Gt as G,XS as H,Ti as I,tr as J,Fi as K,Bd as L,sT as M,ji as N,Vd as O,$t as P,En as Q,$N as R,vM as S,j3 as T,Ei as U,gi as V,yI as W,kt as X,fn as Y,Zi as Z,Wi as _,aS as a,on as a0,AS as a1,$e as a2,ht as a3,ct as a4,Uw as a5,Ho as a6,sl as a7,DI as a8,Ee as a9,IE as aa,G3 as ab,rA as ac,z3 as ad,NE as ae,Bm as af,rS as ag,LE as ah,V3 as ai,H3 as aj,nt as ak,iS as al,PE as am,X3 as an,Y3 as ao,zm as b,I as c,K as d,lw as e,dn as f,kv as g,q_ as h,oT as i,S as j,qN as k,Go as l,mr as m,Ct as n,vN as o,Cd as p,ye as q,Ie as r,Cp as s,ci as t,Hn as u,rg as v,ws as w,Ms as x,li as y,Ut as z};