meshy-node 0.10.8 → 0.10.9

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-BA5_31Nu.js","assets/DashboardShared-BfK1KyJO.js","assets/MarkdownPreviewFrame-C56qjNyn.js","assets/PreviewTab-DQ4yhJji.js","assets/DashboardPage-BaHExl1O.css","assets/SharedConversationPage-hiwRfWZA.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-bZy6ZY6K.js","assets/DashboardShared-CrDF53oL.js","assets/MarkdownPreviewFrame-L2oxne--.js","assets/PreviewTab-UMpaLVaV.js","assets/DashboardPage-BaHExl1O.css","assets/SharedConversationPage-CTyYVCbw.js"])))=>i.map(i=>d[i]);
2
2
  function Jw(t,r){for(var o=0;o<r.length;o++){const s=r[o];if(typeof s!="string"&&!Array.isArray(s)){for(const c in s)if(c!=="default"&&!(c in t)){const u=Object.getOwnPropertyDescriptor(s,c);u&&Object.defineProperty(t,c,u.get?u:{enumerable:!0,get:()=>s[c]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))s(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const m of u.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&s(m)}).observe(document,{childList:!0,subtree:!0});function o(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(c){if(c.ep)return;c.ep=!0;const u=o(c);fetch(c.href,u)}})();function T0(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var jd={exports:{}},zl={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -343,4 +343,4 @@ You can add a description to the \`${jo}\` by passing a \`${a1}\` component as a
343
343
 
344
344
  Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${jo}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
345
345
 
346
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return g.useEffect(()=>{document.getElementById(t.current?.getAttribute("aria-describedby"))||console.warn(r)},[r,t]),null},fj=Zx,mj=Fx,hj=Wx,i1=Jx,c1=e1,u1=o1,d1=s1,f1=n1,m1=r1;const Cf=fj,Rf=mj,pj=hj,h1=g.forwardRef(({className:t,...r},o)=>f.jsx(i1,{className:ae("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...r,ref:o}));h1.displayName=i1.displayName;const Qi=g.forwardRef(({className:t,...r},o)=>f.jsxs(pj,{children:[f.jsx(h1,{}),f.jsx(c1,{ref:o,className:ae("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-3 rounded-sm border bg-background p-4 shadow-[0_24px_84px_-54px_rgba(0,0,0,0.55)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",t),...r})]}));Qi.displayName=c1.displayName;const Ki=({className:t,...r})=>f.jsx("div",{className:ae("flex flex-col space-y-1.5 text-center sm:text-left",t),...r});Ki.displayName="AlertDialogHeader";const Zi=({className:t,...r})=>f.jsx("div",{className:ae("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...r});Zi.displayName="AlertDialogFooter";const Fi=g.forwardRef(({className:t,...r},o)=>f.jsx(f1,{ref:o,className:ae("text-sm font-semibold",t),...r}));Fi.displayName=f1.displayName;const Wi=g.forwardRef(({className:t,...r},o)=>f.jsx(m1,{ref:o,className:ae("text-[11px] text-muted-foreground",t),...r}));Wi.displayName=m1.displayName;const Ji=g.forwardRef(({className:t,...r},o)=>f.jsx(u1,{ref:o,className:ae(Kf(),t),...r}));Ji.displayName=u1.displayName;const ec=g.forwardRef(({className:t,...r},o)=>f.jsx(d1,{ref:o,className:ae(Kf({variant:"outline"}),"mt-2 sm:mt-0",t),...r}));ec.displayName=d1.displayName;const gj={online:"bg-emerald-500",busy:"bg-amber-500",offline:"bg-destructive"};function vj({status:t}){return f.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5",children:[t==="online"&&f.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-500 opacity-30"}),f.jsx("span",{className:ae("relative inline-flex h-2.5 w-2.5 rounded-full",gj[t])})]})}function yj({role:t,size:r="default"}){return f.jsx(_t,{variant:t==="leader"?"default":"secondary",className:ae(r==="compact"?"px-1.5 py-0 text-[9px] leading-4":"text-[11px]"),children:t})}const p1={pending:{variant:"secondary",dotClass:"bg-muted-foreground",className:"border-transparent bg-muted/55 text-muted-foreground"},assigned:{variant:"outline",dotClass:"bg-teal-500",className:"border-teal-500/20 bg-teal-500/8 text-teal-700 dark:text-teal-300"},running:{variant:"outline",dotClass:"bg-amber-500",className:"border-amber-500/22 bg-amber-500/9 text-amber-700 dark:text-amber-300"},completed:{variant:"outline",dotClass:"bg-emerald-500",className:"border-emerald-500/18 bg-emerald-500/8 text-emerald-700 dark:text-emerald-300"},failed:{variant:"destructive",dotClass:"bg-destructive-foreground",className:"border-destructive/20 bg-destructive/90 text-destructive-foreground"},cancelled:{variant:"secondary",dotClass:"bg-muted-foreground",className:"border-transparent bg-muted/55 text-muted-foreground"},archived:{variant:"secondary",dotClass:"bg-slate-400",className:"border-transparent bg-muted/50 text-muted-foreground"}};function $O({status:t,size:r="default"}){const o=p1[t],s=r==="compact"?"gap-0.5 px-1 py-0 text-[8px] leading-3 [&>span]:h-[3px] [&>span]:w-[3px]":"gap-1 px-1.5 py-0 text-[10px] leading-4 [&>span]:h-[5px] [&>span]:w-[5px]";return f.jsxs(_t,{variant:o.variant,className:ae("rounded-sm font-medium shadow-none",s,o.className),children:[f.jsx("span",{className:ae("rounded-full",o.dotClass)}),t]})}function qO({status:t,isNative:r=!1,size:o="default",className:s}){const c=p1[t],u=[t,r?"native":null].filter(Boolean).join(", "),m=o==="compact"?"h-1.5 w-1.5":"h-2 w-2";return f.jsxs("span",{className:ae("inline-flex shrink-0 items-center gap-1",s),title:u,"aria-label":u,children:[f.jsx("span",{className:ae("rounded-full",m,c.dotClass),title:t}),r&&f.jsx("span",{className:ae("rounded-full bg-sky-500",m),title:"native"})]})}const bj={critical:{variant:"destructive",label:"Critical"},high:{variant:"outline",label:"High"},normal:{variant:"secondary",label:"Normal"},low:{variant:"secondary",label:"Low"}};function VO({priority:t}){const r=bj[t];return f.jsx(_t,{variant:r.variant,className:"rounded-sm px-1.5 py-0 text-[10px] leading-4 shadow-none",children:r.label})}function xj(t){return[{key:"workspace",label:"Workspace",value:t?.workspace},{key:"node",label:"Node app",value:t?.node},{key:"core",label:"Core",value:t?.core},{key:"dashboard",label:"Dashboard",value:t?.dashboard},{key:"api",label:"API",value:t?.api}].filter(o=>o.value)}function Eo({label:t,value:r,mono:o=!1}){return f.jsxs("div",{className:"min-w-0 rounded-sm border border-border/60 bg-background/65 px-2.5 py-1.5",children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:t}),f.jsx("div",{className:o?"mt-0.5 break-all font-mono text-[11px] text-foreground":"mt-0.5 break-all text-[11px] text-foreground",children:r})]})}function Sj({formatDateTime:t,viewInfo:r}){const o=xj(r.packages);return f.jsxs(Gl,{value:"about","data-about-layout":"compact",className:"mt-0 space-y-2",children:[f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(LN,{className:"h-3.5 w-3.5 text-primary"}),"Repository & runtime"]}),f.jsx(Nn,{className:"text-[10px]",children:"Build source and runtime identity for this node."})]}),f.jsxs(Tn,{className:"space-y-2 px-3 pb-2.5",children:[r.repository?.url?f.jsxs("a",{href:r.repository.url,target:"_blank",rel:"noreferrer",className:"group flex min-w-0 items-center justify-between gap-2 rounded-sm border border-border/70 bg-background/70 px-2.5 py-1.5 text-[11px] text-foreground transition-colors hover:border-primary/40 hover:bg-primary/5",children:[f.jsx("span",{className:"truncate font-mono text-[10px]",children:r.repository.url}),f.jsx(sy,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform group-hover:-translate-y-0.5 group-hover:translate-x-0.5"})]}):f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-2.5 py-1.5 text-[11px] text-muted-foreground",children:"Repository URL is unavailable in this runtime."}),f.jsxs("div",{className:"grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3",children:[f.jsx(Eo,{label:"Branch",value:r.repository?.branch??"Unavailable",mono:!!r.repository?.branch}),f.jsx(Eo,{label:"Commit",value:r.repository?.commit??"Unavailable",mono:!!r.repository?.commit}),f.jsx(Eo,{label:"Runtime",value:`${r.packageName??"meshy"} ${r.version}`,mono:!0}),f.jsx(Eo,{label:"Node.js",value:r.runtime?.nodeVersion??"Unavailable",mono:!!r.runtime?.nodeVersion}),f.jsx(Eo,{label:"PID",value:r.runtime?String(r.runtime.pid):"Unavailable",mono:!!r.runtime}),f.jsx(Eo,{label:"Started",value:t(r.runtime?.startedAt)})]})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(rT,{className:"h-3.5 w-3.5 text-primary"}),"Package versions"]}),f.jsx(Nn,{className:"text-[10px]",children:"Version snapshot for the packages most relevant to this dashboard session."})]}),f.jsx(Tn,{"data-package-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:o.map(s=>f.jsxs("div",{className:"grid gap-1.5 rounded-sm border border-border/60 bg-background/65 px-2.5 py-1.5 sm:grid-cols-[9rem_minmax(0,1fr)_auto] sm:items-center",children:[f.jsx("div",{className:"text-[11px] font-medium text-foreground",children:s.label}),f.jsx("div",{className:"min-w-0 truncate text-[10px] text-muted-foreground",children:s.value?.name}),f.jsx(_t,{variant:"outline",className:"w-fit rounded-sm border-border/70 bg-background/60 font-mono text-[10px]",children:s.value?.version})]},s.key))})]})]})}const wj="codex",IO="bypass",g1=[{value:"codex",label:"Codex",supportsFollowUp:!0},{value:"claudecode",label:"Claude Code",supportsFollowUp:!0},{value:"copilot",label:"Copilot",supportsFollowUp:!0},{value:"mars",label:"mars",disabled:!0,description:"coming soon"},{value:"eureka",label:"eureka",disabled:!0,description:"coming soon"}],v1=g1.filter(t=>t.value==="codex"||t.value==="claudecode"||t.value==="copilot");function Af(t){return v1.some(r=>r.value===t)?t:wj}const YO=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],Ej=new Set(g1.filter(t=>t.supportsFollowUp).map(t=>t.value));function GO(t){const r=s=>typeof s=="string"&&Ej.has(s),o=(t.nodeSupportedAgents??[]).filter(r);return o.length>0?Array.from(new Set(o)):Array.from(new Set([t.taskAgent,t.activeAgent].filter(r)))}const XO=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"shared",label:"Shared"},{value:"archived",label:"Archived"}],QO=[{value:"all",label:"All task types"},{value:"native",label:"Native sessions"},{value:"meshy",label:"Meshy chats"}],Nj=new Set(["pending","assigned"]),Tj=new Set(["running"]),Cj=new Set(["completed","failed","cancelled"]),KO=10;function ZO(t,r){switch(r){case"running":return Tj.has(t.status);case"waiting":return Nj.has(t.status);case"closed":return Cj.has(t.status);case"shared":return!!t.activeShare;case"archived":return t.status==="archived";default:return t.status!=="archived"}}function FO(t,r){if(r==="all")return!0;const o=t.conversationKind==="nativeSession";return r==="native"?o:!o}function WO(t,r){const o=r.trim().toLowerCase();return o?[t.title,t.description,t.id,t.agent,t.assignedTo??"",t.assignedNodeName??"",t.project??"",t.effectiveProjectPath??"",t.conversationKind==="nativeSession"?"native session":"meshy chat",t.activeShare?"shared conversation":""].some(s=>s.toLowerCase().includes(o)):!0}function Rj(t,r,o){return t?r?.find(c=>c.id===t)?.name??o??t.slice(0,8):"unassigned"}function JO(t,r,o){return Rj(t,r,o).toLowerCase()}function eM(t){return t.type!=="node.status"&&t.type!=="cluster.state"}function tM(t,r,o){return!t.assignedTo||o?.id===t.assignedTo?!0:r?.some(s=>s.id===t.assignedTo)??!1}function nM(t,r){return[...t].sort((o,s)=>o.id===r?-1:s.id===r?1:o.name.localeCompare(s.name))}function aM(t){if(!t||typeof t!="object")return null;const r=t,o=r.createMode,s=o==="chat"||o==="native"?o:void 0,c=r.createDefaults,u=c&&typeof c=="object"&&!Array.isArray(c)?c:null,m=u?{assignTo:typeof u.assignTo=="string"||u.assignTo===null?u.assignTo:void 0,project:typeof u.project=="string"||u.project===null?u.project:void 0}:void 0;return{draftNewTask:r.draftNewTask===!0,returnRoute:typeof r.returnRoute=="string"?r.returnRoute:void 0,returnTaskId:typeof r.returnTaskId=="string"||r.returnTaskId===null?r.returnTaskId:void 0,createMode:s,createDefaults:m}}function rM(t){return t==="default workspace"?t:t.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??t}function oM(t){const r=Date.now()-t;return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m`:r<864e5?`${Math.floor(r/36e5)}h`:`${Math.floor(r/864e5)}d`}function lM(t){return new Date(t).toLocaleString()}function sM(t){const r=Math.floor(t/1e3),o=Math.floor(r/3600),s=Math.floor(r%3600/60),c=r%60;return`${String(o).padStart(2,"0")}:${String(s).padStart(2,"0")}:${String(c).padStart(2,"0")}`}async function y1(t,r="Copied to clipboard"){try{if(globalThis.navigator?.clipboard?.writeText)return await globalThis.navigator.clipboard.writeText(t),Ce.success(r),!0;const o=globalThis.document,s=o?.execCommand?.bind(o);if(!o?.body||typeof o.createElement!="function"||typeof s!="function")throw new Error("Clipboard access is unavailable");const c=o.createElement("textarea"),u=o.activeElement,m=u&&typeof u.focus=="function"?u:null;c.value=t,c.setAttribute("readonly","true"),c.style.position="fixed",c.style.opacity="0",c.style.pointerEvents="none",o.body.appendChild(c),c.select(),c.setSelectionRange(0,c.value.length);const h=s("copy");if(o.body.removeChild(c),m?.focus(),!h)throw new Error("Clipboard access is unavailable");return Ce.success(r),!0}catch(o){return Ce.error(o instanceof Error?o.message:"Failed to copy"),!1}}const Aj="default workspace";function Oi(t){const r=t.replace(/\\/g,"/");return r==="/"||/^[A-Za-z]:\/$/.test(r)?r:r.replace(/\/+$/g,"")||r}function kj(t){const r=t.replace(/\\/g,"/");return r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r)}function jj(t,r){const o=Oi(t),s=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!s||s==="."?o:o==="/"||/^[A-Za-z]:\/$/.test(o)?`${o}${s}`:`${o}/${s}`}function _j(t,r){const o=t.effectiveProjectPath?.trim();if(o)return Oi(o);const s=t.project?.trim();if(!s)return Aj;if(kj(s)||!t.assignedTo)return Oi(s);const c=r?.get(t.assignedTo)?.trim();return c?jj(c,s):Oi(s)}function iM({nodeStatusById:t,nodeNameById:r,nodeFilter:o,searchQuery:s,nodeWorkDirById:c}){const u=o.trim().toLowerCase(),m=s.trim().toLowerCase(),h=[];for(const[v,p]of t){if(p==="offline"||u==="unassigned")continue;const b=r.get(v)??v.slice(0,8);if(!(u&&u!=="all"&&b.toLowerCase()!==u)){if(m){const y=c?.get(v)??"";if(![v,b,y].some(k=>k.toLowerCase().includes(m)))continue}h.push(v)}}return h}function cM(t,r,o,s,c){const u=new Map;for(const h of t){const v=h.assignedTo??null,p=v??"__unassigned__",b=v?r.get(v)??h.assignedNodeName??v.slice(0,8):"Unassigned",y=_j(h,s);u.has(p)||u.set(p,{nodeId:v,nodeName:b,dirMap:new Map});const w=u.get(p);w.dirMap.has(y)||w.dirMap.set(y,[]),w.dirMap.get(y).push(h)}for(const h of c??[])u.has(h)||u.set(h,{nodeId:h,nodeName:r.get(h)??h.slice(0,8),dirMap:new Map});const m=Array.from(u.values()).map(({nodeId:h,nodeName:v,dirMap:p})=>{const b=Array.from(p.entries()).map(([y,w])=>({path:y,tasks:w})).sort((y,w)=>w.tasks.length-y.tasks.length||y.path.localeCompare(w.path));return{nodeId:h,nodeName:v,dirs:b}});return m.sort((h,v)=>{if(o){if(h.nodeId===o)return-1;if(v.nodeId===o)return 1}return h.nodeId===null?1:v.nodeId===null?-1:h.nodeName.localeCompare(v.nodeName)}),m}const Oj=["queued","running"],Mj=["copilot.tunnel","copilot.tunnel.disable"],Dj=1e4;function d0(t){return t?.status==="succeeded"||t?.status==="failed"}function zj(t){return t.reduce((r,o)=>!r||o.updatedAt>r.updatedAt?o:r,null)}async function Uj(t,r=J0){const o=await Promise.all(Mj.flatMap(s=>Oj.map(c=>r({kind:s,status:c,nodeId:t}))));return zj(o.flat())}function f0(t){return t?.split(/\r?\n/).map(r=>r.trim()).filter(Boolean).at(-1)??null}function Lj(t,r){return[t,...r].join(" ")}function Bj(t,r,o){return r&&!t?"Checking port 8314":t?t.status==="queued"?"Queued":t.status==="running"?t.kind==="copilot.tunnel.disable"?"Stopping Meshy-managed tunnel":t.kind==="copilot.tunnel"?t.result?.status==="auth-required"?"Waiting for GitHub device authorization":"Starting Copilot tunnel":"Checking port 8314":t.status==="succeeded"?t.result?.available?t.result.status==="already-running"?"Port 8314 is already reachable":"Proxy is listening on 8314":t.result?.status==="stopped"?"Meshy-managed tunnel stopped":"Port 8314 is not listening":o??"Tunnel operation failed":"Port 8314 status has not been checked"}function Hj(t,r){return r||t?.status==="queued"||t?.status==="running"?f.jsx(iy,{className:"h-3.5 w-3.5 animate-spin text-primary"}):t?.result?.available?f.jsx(Ro,{className:"h-3.5 w-3.5 text-emerald-500"}):t?.status==="failed"?f.jsx(uf,{className:"h-3.5 w-3.5 text-destructive"}):f.jsx(uf,{className:"h-3.5 w-3.5 text-muted-foreground"})}function Pj({checked:t,disabled:r,onCheckedChange:o}){return f.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":"Toggle GitHub Copilot Tunnel",title:t?"Disable GitHub Copilot Tunnel":"Enable GitHub Copilot Tunnel","data-copilot-tunnel-switch":"true",disabled:r,onClick:()=>o(!t),className:ae("relative h-5 w-9 shrink-0 rounded-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t?"bg-primary/85":"bg-muted"),children:f.jsx("span",{className:ae("absolute left-0.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 rounded-sm bg-background shadow-sm transition-transform",t?"translate-x-4":"translate-x-0")})})}function $j({nodeId:t,nodeName:r}){const[o,s]=g.useState(null),[c,u]=g.useState(!1),[m,h]=g.useState(!1),v=o?.status==="queued"||o?.status==="running",p=o?.result,b=p?.auth??null,y=o?.error??p?.detail??f0(p?.stderr)??f0(p?.stdout),w=p?Lj(p.command,p.args):"npx -y ghc-tunnel@latest -d",k=!!p?.available||v&&o?.kind==="copilot.tunnel",A=c||m||v,E=g.useMemo(()=>Bj(o,c,y),[c,y,o]);g.useEffect(()=>{let T=!1;async function R(){u(!0);try{const O=await Uj(t);if(T)return;if(O){s(O);return}const H=await Tv(t);T||s(H)}catch(O){T||Ce.error(O instanceof Error?O.message:"Failed to check Copilot tunnel")}finally{T||u(!1)}}return s(null),R(),()=>{T=!0}},[t]),g.useEffect(()=>{if(!o||d0(o))return;let T=!1;const R=o.id;async function O(){try{const z=await W0(R);if(T)return;if(z.kind==="copilot.tunnel.status"&&!d0(z)&&Date.now()-z.createdAt>Dj){const K=await Tv(t);T||s(K);return}s(z),z.status==="succeeded"&&z.kind==="copilot.tunnel"&&Ce.success(`Copilot tunnel is available on ${r}`),z.status==="succeeded"&&z.kind==="copilot.tunnel.disable"&&Ce.success(`Copilot tunnel stopped on ${r}`),z.status==="failed"&&z.kind!=="copilot.tunnel.status"&&Ce.error(z.error??"Copilot tunnel failed")}catch(z){T||Ce.error(z instanceof Error?z.message:"Failed to refresh Copilot tunnel")}}O();const H=window.setInterval(O,2e3);return()=>{T=!0,window.clearInterval(H)}},[t,r,o?.id,o?.status]);const N=g.useCallback(async T=>{h(!0);try{const R=T?await XE(t):await QE(t);s(R),Ce.info(T?`Copilot tunnel enable requested on ${r}`:`Copilot tunnel stop requested on ${r}`)}catch(R){Ce.error(R instanceof Error?R.message:"Failed to update Copilot tunnel")}finally{h(!1)}},[t,r]);return f.jsxs(Sn,{"data-copilot-tunnel-section":"true",className:"rounded-sm border-border/70 bg-background/75 shadow-none xl:col-span-2",children:[f.jsx(wn,{className:"pb-1.5 pt-2.5 px-3",children:f.jsxs("div",{className:"flex items-start justify-between gap-3",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(oy,{className:"h-3.5 w-3.5 text-primary"}),"GitHub Copilot Tunnel"]}),f.jsx(Nn,{className:"text-[10px]",children:"Node-local Copilot proxy model provider."})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[f.jsx("span",{"aria-label":E,title:E,className:"inline-flex h-5 w-5 items-center justify-center",children:Hj(o,c)}),f.jsx(Pj,{checked:k,disabled:A,onCheckedChange:T=>{N(T)}})]})]})}),f.jsxs(Tn,{className:"space-y-2 px-3 pb-2.5",children:[f.jsxs("div",{className:"space-y-1.5 rounded-sm bg-background/55 px-2.5 py-2",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[f.jsx("span",{className:ae("h-1.5 w-1.5 rounded-sm",p?.available?"bg-emerald-500":v||c?"animate-pulse bg-amber-500":o?.status==="failed"?"bg-destructive":"bg-muted-foreground/50")}),E]}),f.jsx("div",{className:"truncate font-mono text-[10px] text-muted-foreground",children:w}),(v||c||m)&&f.jsx("div",{className:"h-0.5 overflow-hidden rounded-sm bg-muted",children:f.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})})]}),b&&v&&f.jsxs("div",{className:"grid gap-2 rounded-sm border border-primary/35 bg-primary/8 px-2.5 py-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",children:[f.jsxs("div",{className:"min-w-0 space-y-1",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[f.jsx(lT,{className:"h-3.5 w-3.5 animate-pulse text-primary"}),"GitHub device login"]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:[f.jsx("span",{className:"font-mono text-[11px] text-foreground",children:b.code}),b.expiresInSeconds?f.jsxs("span",{children:[Math.ceil(b.expiresInSeconds/60),"m expiry"]}):null]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Ct,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7 rounded-sm",title:"Copy device code","aria-label":"Copy device code",onClick:()=>{y1(b.code,"Device code copied")},children:f.jsx(ly,{className:"h-3.5 w-3.5"})}),f.jsx(Ct,{asChild:!0,variant:"outline",size:"icon",className:"h-7 w-7 rounded-sm",title:"Open GitHub device login","aria-label":"Open GitHub device login",children:f.jsx("a",{href:b.url,target:"_blank",rel:"noreferrer",children:f.jsx(sy,{className:"h-3.5 w-3.5"})})})]})]}),y&&o?.status!=="succeeded"&&f.jsx("div",{className:"rounded-sm border border-border/60 bg-muted/35 px-2 py-1 text-[10px] text-muted-foreground",children:y})]})]})}function qj({value:t,disabled:r=!1,saving:o=!1,onChange:s}){const c=Af(t);return f.jsxs("div",{"data-default-task-agent-selector":"true",className:"flex shrink-0 flex-col gap-1 sm:items-end",children:[f.jsxs("div",{className:"flex items-center gap-1 text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:[f.jsx(Yf,{className:"h-3 w-3"}),"Default agent"]}),f.jsx("div",{className:"flex h-7 items-center gap-0.5 rounded-sm border border-border/60 bg-background/60 p-0.5",children:v1.map(u=>{const m=u.value===c;return f.jsx("button",{type:"button","data-default-task-agent-option":u.value,"aria-pressed":m,disabled:r||o,onClick:()=>s(u.value),className:ae("h-6 rounded-sm border border-transparent px-2 text-[10px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",m?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:u.label},u.value)})})]})}const xc=g.forwardRef(({className:t,type:r,...o},s)=>f.jsx("input",{type:r,className:ae("flex h-8 w-full rounded-sm border border-input/85 bg-background/72 px-2.5 py-1.5 text-[11px] shadow-sm ring-offset-background transition-all duration-200 file:border-0 file:bg-transparent file:text-[11px] file:font-medium file:text-foreground placeholder:text-muted-foreground/75 focus-visible:border-primary/45 focus-visible:bg-background/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/45 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...o}));xc.displayName="Input";function Vj(){return ve("/system/quick-chats")}function Ij(t){return ve("/system/quick-chats",{method:"PUT",body:JSON.stringify({quickChats:t})})}const kf="quick-chats:updated";function Yj(){typeof window>"u"||window.dispatchEvent(new CustomEvent(kf))}function Gj(){const[t,r]=g.useState([]),[o,s]=g.useState(!0),[c,u]=g.useState(!1),[m,h]=g.useState(null),v=g.useCallback(async()=>{s(!0);try{const b=await Vj();r(b.quickChats),h(null)}catch(b){h(b instanceof Error?b.message:"Failed to load quick chats")}finally{s(!1)}},[]),p=g.useCallback(async b=>{u(!0);try{const y=await Ij(b);return r(y.quickChats),h(null),Yj(),y.quickChats}catch(y){const w=y instanceof Error?y.message:"Failed to save quick chats";throw h(w),y}finally{u(!1)}},[]);return g.useEffect(()=>{v()},[v]),g.useEffect(()=>{if(typeof window>"u")return;const b=()=>{v()};return window.addEventListener(kf,b),()=>window.removeEventListener(kf,b)},[v]),{error:m,loading:o,quickChats:t,refresh:v,save:p,saving:c}}function b1(t){return t.trim().replace(/^\/+/,"").toLowerCase()}function x1(t,r){const o=t.trim();if(!o.startsWith("/"))return[];const s=b1(o);return r.filter(c=>c.alias.startsWith(s))}function tc(t,r){return r<=0?-1:(t%r+r)%r}function uM(t,r,o=0){const s=x1(t,r),c=tc(o,s.length);return c>=0?s[c]??null:null}function dM(t,r,o){const s=tc(t,r);return s<0?0:tc(s+o,r)}function fM({query:t,quickChats:r,selectedIndex:o=0,onSelect:s,onActiveIndexChange:c}){const u=x1(t,r);if(u.length===0)return null;const m=tc(o,u.length);return f.jsxs("div",{"data-quick-chat-menu":"true",className:"mx-2 mb-0.5 rounded-sm bg-background/70 p-0.5 shadow-none sm:mx-5",children:[f.jsxs("div",{className:"flex items-center gap-1 px-1 py-0.5 text-[8px] uppercase tracking-[0.14em] text-muted-foreground/75",children:[f.jsx(cy,{className:"h-2.5 w-2.5 text-primary/55"}),"Quick chats"]}),f.jsx("div",{className:"max-h-24 overflow-y-auto",role:"listbox","aria-label":"Quick chats",children:u.map((h,v)=>f.jsxs("button",{type:"button",role:"option","aria-selected":v===m,"data-selected":v===m?"true":void 0,onMouseEnter:()=>c?.(v),onClick:()=>s(h),className:ae("flex w-full min-w-0 items-start gap-1.5 rounded-sm px-1 py-1 text-left text-[9px] transition-colors hover:bg-muted/50 hover:text-foreground"),children:[f.jsxs("span",{"data-quick-chat-alias":"true",className:ae("shrink-0 font-mono text-[9px] leading-3 text-primary/70",v===m&&"text-primary"),children:["/",h.alias]}),f.jsx("span",{"data-quick-chat-prompt":"true",className:ae("line-clamp-1 min-w-0 text-[9px] leading-3 text-muted-foreground",v===m&&"text-primary/90"),children:h.prompt})]},h.alias))})]})}const Xj="h-14 w-full resize-none rounded-sm border border-border/70 bg-background/80 px-2 py-1.5 text-[11px] leading-4 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";let Qj=0;function Mi(t,r=0){return{id:t?`${t.alias}:${r}`:`new:${Qj++}`,alias:t?.alias??"",prompt:t?.prompt??""}}function jf(t){return{quickChats:t.map(r=>({alias:b1(r.alias),prompt:r.prompt.trim()})).filter(r=>r.alias.length>0&&r.prompt.length>0)}}function Kj(t,r){const o=jf(t).quickChats,s=r.map((u,m)=>Mi(u,m)),c=jf(s).quickChats;return JSON.stringify(o)!==JSON.stringify(c)}function Zj(){const{error:t,loading:r,quickChats:o,save:s,saving:c}=Gj(),[u,m]=g.useState(()=>o.map((y,w)=>Mi(y,w))),h=u.length>0,v=g.useMemo(()=>jf(u),[u]),p=g.useMemo(()=>Kj(u,o),[u,o]);g.useEffect(()=>{m(o.map((y,w)=>Mi(y,w)))},[o]);async function b(){try{await s(v.quickChats),Ce.success("Quick chats saved")}catch(y){Ce.error(y instanceof Error?y.message:"Failed to save quick chats")}}return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"rounded-sm border border-border/70 bg-background/75 px-3 py-2.5",children:f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[f.jsx(cy,{className:"h-3.5 w-3.5 text-primary"}),"Quick chats"]}),f.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:"Reusable slash aliases for chat composers on this leader."})]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsxs(Ct,{type:"button",variant:"outline",onClick:()=>m(y=>[...y,Mi(void 0,y.length)]),className:"h-7 rounded-sm px-2 text-[10px]",children:[f.jsx(hT,{className:"h-3.5 w-3.5"}),"Add"]}),f.jsxs(Ct,{type:"button",onClick:b,disabled:c||!p,className:"h-7 rounded-sm px-2 text-[10px]",children:[c?f.jsx(iy,{className:"h-3.5 w-3.5 animate-spin"}):f.jsx(wT,{className:"h-3.5 w-3.5"}),"Save"]})]})]})}),r&&!h?f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-4 text-[11px] text-muted-foreground",children:"Loading quick chats..."}):h?f.jsx("div",{className:"space-y-1.5",children:u.map((y,w)=>f.jsxs("div",{className:"grid gap-1.5 rounded-sm border border-border/60 bg-background/70 px-2 py-2 md:grid-cols-[12rem_minmax(0,1fr)_auto]",children:[f.jsx(xc,{"aria-label":`Quick chat ${w+1} alias`,value:y.alias,onChange:k=>m(A=>A.map(E=>E.id===y.id?{...E,alias:k.target.value}:E)),placeholder:"alias",className:"h-7 rounded-sm border-border/70 bg-background/80 px-2 font-mono text-[11px]"}),f.jsx("textarea",{"aria-label":`Quick chat ${w+1} prompt`,value:y.prompt,onChange:k=>m(A=>A.map(E=>E.id===y.id?{...E,prompt:k.target.value}:E)),placeholder:"Prompt text",className:Xj}),f.jsx(Ct,{type:"button",variant:"ghost",size:"icon",onClick:()=>m(k=>k.filter(A=>A.id!==y.id)),"aria-label":`Remove quick chat ${w+1}`,className:"h-7 w-7 rounded-sm text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:f.jsx(zT,{className:"h-3.5 w-3.5"})})]},y.id))}):f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-4 text-[11px] text-muted-foreground",children:"No quick chats configured."}),t&&f.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:t})]})}var Sc="Checkbox",[Fj]=Fa(Sc),[Wj,ym]=Fj(Sc);function Jj(t){const{__scopeCheckbox:r,checked:o,children:s,defaultChecked:c,disabled:u,form:m,name:h,onCheckedChange:v,required:p,value:b="on",internal_do_not_use_render:y}=t,[w,k]=_o({prop:o,defaultProp:c??!1,onChange:v,caller:Sc}),[A,E]=g.useState(null),[N,T]=g.useState(null),R=g.useRef(!1),O=A?!!m||!!A.closest("form"):!0,H={checked:w,disabled:u,setChecked:k,control:A,setControl:E,name:h,form:m,value:b,hasConsumerStoppedPropagationRef:R,required:p,defaultChecked:Ga(c)?!1:c,isFormControl:O,bubbleInput:N,setBubbleInput:T};return f.jsx(Wj,{scope:r,...H,children:e_(y)?y(H):s})}var S1="CheckboxTrigger",w1=g.forwardRef(({__scopeCheckbox:t,onKeyDown:r,onClick:o,...s},c)=>{const{control:u,value:m,disabled:h,checked:v,required:p,setControl:b,setChecked:y,hasConsumerStoppedPropagationRef:w,isFormControl:k,bubbleInput:A}=ym(S1,t),E=We(c,b),N=g.useRef(v);return g.useEffect(()=>{const T=u?.form;if(T){const R=()=>y(N.current);return T.addEventListener("reset",R),()=>T.removeEventListener("reset",R)}},[u,y]),f.jsx(Ue.button,{type:"button",role:"checkbox","aria-checked":Ga(v)?"mixed":v,"aria-required":p,"data-state":R1(v),"data-disabled":h?"":void 0,disabled:h,value:m,...s,ref:E,onKeyDown:ze(r,T=>{T.key==="Enter"&&T.preventDefault()}),onClick:ze(o,T=>{y(R=>Ga(R)?!0:!R),A&&k&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})})});w1.displayName=S1;var bm=g.forwardRef((t,r)=>{const{__scopeCheckbox:o,name:s,checked:c,defaultChecked:u,required:m,disabled:h,value:v,onCheckedChange:p,form:b,...y}=t;return f.jsx(Jj,{__scopeCheckbox:o,checked:c,defaultChecked:u,disabled:h,required:m,onCheckedChange:p,name:s,form:b,value:v,internal_do_not_use_render:({isFormControl:w})=>f.jsxs(f.Fragment,{children:[f.jsx(w1,{...y,ref:r,__scopeCheckbox:o}),w&&f.jsx(C1,{__scopeCheckbox:o})]})})});bm.displayName=Sc;var E1="CheckboxIndicator",N1=g.forwardRef((t,r)=>{const{__scopeCheckbox:o,forceMount:s,...c}=t,u=ym(E1,o);return f.jsx(Lo,{present:s||Ga(u.checked)||u.checked===!0,children:f.jsx(Ue.span,{"data-state":R1(u.checked),"data-disabled":u.disabled?"":void 0,...c,ref:r,style:{pointerEvents:"none",...t.style}})})});N1.displayName=E1;var T1="CheckboxBubbleInput",C1=g.forwardRef(({__scopeCheckbox:t,...r},o)=>{const{control:s,hasConsumerStoppedPropagationRef:c,checked:u,defaultChecked:m,required:h,disabled:v,name:p,value:b,form:y,bubbleInput:w,setBubbleInput:k}=ym(T1,t),A=We(o,k),E=Vb(u),N=Ob(s);g.useEffect(()=>{const R=w;if(!R)return;const O=window.HTMLInputElement.prototype,z=Object.getOwnPropertyDescriptor(O,"checked").set,K=!c.current;if(E!==u&&z){const I=new Event("click",{bubbles:K});R.indeterminate=Ga(u),z.call(R,Ga(u)?!1:u),R.dispatchEvent(I)}},[w,E,u,c]);const T=g.useRef(Ga(u)?!1:u);return f.jsx(Ue.input,{type:"checkbox","aria-hidden":!0,defaultChecked:m??T.current,required:h,disabled:v,name:p,value:b,form:y,...r,tabIndex:-1,ref:A,style:{...r.style,...N,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});C1.displayName=T1;function e_(t){return typeof t=="function"}function Ga(t){return t==="indeterminate"}function R1(t){return Ga(t)?"indeterminate":t?"checked":"unchecked"}const A1=g.forwardRef(({className:t,...r},o)=>f.jsx(bm,{ref:o,className:ae("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...r,children:f.jsx(N1,{className:ae("flex items-center justify-center text-current"),children:f.jsx(Li,{className:"h-3.5 w-3.5"})})}));A1.displayName=bm.displayName;const m0=["queued","running"];function t_(t){return t.map(r=>`${r.id}:${r.name}`).join("\0")}function n_(t){return t==="claude"||t==="codex"||t==="copilot"}function k1(t){if(t.kind!=="agent.upgrade")return null;const r=t.payload?.agent;return n_(r)?`${t.nodeId}:${r}`:null}function a_(t){return t.status==="succeeded"||t.status==="failed"}async function j1(t,r={}){const o=r.getOperation??W0,s=r.pollIntervalMs??2e3,c=r.timeoutMs??24e4,u=Date.now()+c;let m=t;for(;!a_(m)&&Date.now()<u;)await o_(s),m=await o(t.id);return m}async function r_(t,r=J0){const o=new Set(t),s=await Promise.all(m0.map(u=>r({kind:"agent.upgrade",status:u}))),c=new Map;for(const u of s.flat()){if(!m0.includes(u.status)||o.size>0&&!o.has(u.nodeId))continue;const m=k1(u);if(!m)continue;const h=c.get(m);(!h||u.updatedAt>h.updatedAt)&&c.set(m,u)}return c}function o_(t){return new Promise(r=>setTimeout(r,t))}const l_=1500,s_=1e3,i_=9e4;async function _1(t={}){const r=t.fetchHealth??c_,o=t.initialDelayMs??l_,s=t.pollIntervalMs??s_,c=t.previousPid,u=t.reload??(()=>window.location.reload()),m=t.sleep??d_,h=t.timeoutMs??i_,v=Date.now()+h;let p=!1;for(o>0&&await m(o);Date.now()<=v;){const b=u_(await r());if(!b.ok){p=!0,await m(s);continue}if(c===void 0||b.pid!==void 0&&b.pid!==c||p)return u(),!0;await m(s)}return!1}async function c_(){try{const t=await fetch("/api/system/health",{cache:"no-store"}),r=await t.json().catch(()=>null),o=r&&typeof r=="object"&&typeof r.pid=="number"?r.pid:void 0;return{ok:t.ok,pid:o}}catch{return!1}}function u_(t){return typeof t=="boolean"?{ok:t}:t}function d_(t){return new Promise(r=>window.setTimeout(r,t))}function f_(t,r=!0){return r?t?.restartMode==="development"?"Restart dev runtime":t?.updateAvailable?"Restart to update":"Restart runtime":t?.updateAvailable?"Restart follower to update":"Restart follower"}function m_({checkedLabel:t,disableAuthDefault:r,endpoint:o,isLiveLocalNode:s,nodeId:c,nodeName:u,onRefresh:m,pid:h,transportType:v,update:p,workDir:b}){const y=f_(p,s),[w,k]=g.useState(null),[A,E]=g.useState(()=>h0({disableAuthDefault:r,endpoint:o,nodeName:u,transportType:v,workDir:b})),[N,T]=g.useState(!1),[R,O]=g.useState(!1),[H,z]=g.useState(!1);g.useEffect(()=>{E(h0({disableAuthDefault:r,endpoint:o,nodeName:u,transportType:v,workDir:b}))},[r,o,u,v,b]);async function K(){if(!c||N||R)return;const de=p.updateAvailable?"update":"restart",fe=g_(A);if(A.port.trim()&&fe?.port===void 0){Ce.error("Runtime restart port must be a positive integer");return}const W=fe?{reason:de,startArgs:fe}:{reason:de};T(!0);try{if(s){const _=await ey(W);k({..._,pid:_.pid??h,status:"accepted"}),Ce.info(`Restarting ${u} from a detached helper. PID ${_.pid??h??"unknown"} will not stay attached to the original terminal window; follow ${_.logPath} for launch output.`),_1({previousPid:_.pid??h}).then(B=>{B||(T(!1),Ce.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout. Refresh the page after the node finishes starting."))}).catch(B=>{T(!1),Ce.error(B instanceof Error?B.message:"Runtime restart recovery failed")});return}const te=await eN(c,W);k({operationId:te.id,pid:h,status:te.status}),Ce.info(`Restart requested on ${u}. Operation ${Jd(te.id)} will hand off to a detached process, so the new runtime will not stay attached to the original terminal window.`);const se=await j1(te,{timeoutMs:6e4}),X=p_(se);k({command:X?.command,logPath:X?.logPath,mode:X?.mode,operationId:se.id,pid:X?.pid??h,status:se.status}),se.status==="succeeded"?(await m?.(),Ce.success(`Restart handoff accepted on ${u}. Follow ${X?.logPath??"the node restart log"} for launch output.`)):se.status==="failed"?Ce.error(se.error??`Restart failed on ${u}`):Ce.info(`Restart operation ${Jd(se.id)} is still ${se.status}. More details will update after the node reports back.`),T(!1)}catch(te){T(!1),Ce.error(te instanceof Error?te.message:"Runtime restart failed")}}async function I(){if(!(!s||N||R)){O(!0);try{const de=await FE();Ce.info(`Stopping Meshy process ${de.pid}`)}catch(de){O(!1),Ce.error(de instanceof Error?de.message:"Runtime stop failed")}}}const P=N?"restarting":R?"stopping":w?.status??"idle",le=p.restartMode==="development";return f.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/70 bg-background/70",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border/50",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ui,{className:"h-3.5 w-3.5 text-primary shrink-0"}),f.jsxs("div",{children:[f.jsx("div",{className:"text-[11px] font-semibold text-foreground leading-tight",children:"Runtime"}),f.jsx("div",{className:"text-[10px] text-muted-foreground leading-tight",children:le?"Development launcher":`Latest ${p.latestVersion??"—"}`})]})]}),f.jsx("div",{className:"flex items-center gap-1.5",children:f.jsx(_t,{variant:p.updateAvailable?"default":"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 font-mono text-[10px]",children:le?"dev":p.updateAvailable?`→ ${p.latestVersion}`:"current"})})]}),f.jsxs("div",{className:"grid grid-cols-2 divide-x divide-border/50 border-b border-border/50",children:[f.jsxs("div",{className:"px-3 py-1.5",children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:"PID"}),f.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-foreground",children:h??"—"})]}),f.jsxs("div",{className:"px-3 py-1.5",children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:"Status"}),f.jsx("div",{className:"mt-0.5 text-[11px] text-foreground capitalize",children:P})]})]}),f.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2",children:[f.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["Checked ",t]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[s&&f.jsxs(Cf,{children:[f.jsx(Rf,{asChild:!0,children:f.jsxs(Ct,{type:"button",size:"sm",variant:"ghost",disabled:N||R,className:"h-7 rounded-sm px-2 text-[11px] text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:[f.jsx(gT,{className:ae("mr-1 h-3.5 w-3.5",R&&"animate-pulse")}),R?"Stopping":"Stop"]})}),f.jsxs(Qi,{className:"max-w-[22rem] gap-2 rounded-sm p-4",children:[f.jsxs(Ki,{className:"space-y-1",children:[f.jsx(Fi,{className:"text-sm",children:"Stop runtime?"}),f.jsx(Wi,{className:"text-[11px] leading-4",children:"Gracefully stops the current Meshy process without launching a replacement. The dashboard will disconnect until the node is started again."})]}),f.jsxs(Zi,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(ec,{className:"h-7 rounded-sm px-2 text-[11px]",children:"Cancel"}),f.jsx(Ji,{className:"h-7 rounded-sm bg-destructive px-2 text-[11px] text-destructive-foreground hover:bg-destructive/90",onClick:()=>{I()},children:"Stop runtime"})]})]})]}),f.jsxs(Cf,{children:[f.jsx(Rf,{asChild:!0,children:f.jsxs(Ct,{type:"button",size:"sm",variant:p.updateAvailable?"default":"outline",disabled:!c||N||R,className:"h-7 rounded-sm px-2 text-[11px]",children:[f.jsx(Ai,{className:ae("mr-1 h-3.5 w-3.5",N&&"animate-spin")}),N?"Restarting…":y]})}),f.jsxs(Qi,{className:"max-w-[28rem] gap-3 rounded-sm p-4",children:[f.jsxs(Ki,{className:"space-y-1",children:[f.jsxs(Fi,{className:"text-sm",children:[y,"?"]}),f.jsxs(Wi,{className:"text-[11px] leading-4",children:["Starts a detached restart helper, shuts down ",s?"the current node":u,", and brings it back with the configured launcher. The new process will not stay attached to the original terminal window."]})]}),f.jsx(h_,{value:A,onChange:E}),f.jsxs(Zi,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(ec,{className:"h-7 rounded-sm px-2 text-[11px]",children:"Cancel"}),f.jsx(Ji,{className:"h-7 rounded-sm px-2 text-[11px]",onClick:()=>{K()},children:y})]})]})]})]})]}),f.jsxs("div",{className:"border-t border-border/50",children:[f.jsxs("button",{type:"button",onClick:()=>z(de=>!de),className:"flex w-full items-center justify-between px-3 py-1.5 text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(hy,{className:"h-3 w-3"}),"Restart details"]}),f.jsx(Zl,{className:ae("h-3 w-3 transition-transform duration-150",H&&"rotate-180")})]}),H&&f.jsxs("div",{className:"border-t border-border/50 bg-muted/20 px-3 py-2 space-y-1",children:[f.jsx(Er,{label:"Current PID",value:h===void 0?"—":String(h),mono:h!==void 0}),f.jsx(Er,{label:"Restart PID",value:w?.pid===void 0?"Pending":String(w.pid),mono:w?.pid!==void 0}),f.jsx(Er,{label:"Operation",value:w?.operationId?Jd(w.operationId):"Local direct request",mono:!!w?.operationId}),f.jsx(Er,{label:"Status",value:w?.status??(N?"requested":"idle")}),f.jsx(Er,{label:"Launcher",value:w?.command??"Available after restart",mono:!!w?.command}),f.jsx(Er,{label:"Log",value:w?.logPath??"Available after restart",mono:!!w?.logPath}),f.jsx(Er,{label:"Terminal",value:"New process is detached from original terminal"})]})]}),p.detail&&f.jsx("div",{className:"border-t border-border/50 px-3 py-1.5 text-[10px] text-muted-foreground bg-muted/20",children:p.detail})]})}function h_({onChange:t,value:r}){const o=(s,c)=>{t({...r,[s]:c})};return f.jsxs("div",{className:"rounded-lg border border-border/70 bg-muted/30 p-3 space-y-3",children:[f.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Startup arguments"}),f.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[f.jsx(Pl,{label:"HTTP port",value:r.port,onChange:s=>o("port",s),inputMode:"numeric"}),f.jsx(Pl,{label:"Node name",value:r.name,onChange:s=>o("name",s)}),f.jsx(Pl,{label:"Join endpoint",value:r.join,onChange:s=>o("join",s),className:"sm:col-span-2"}),f.jsxs("div",{className:"space-y-1",children:[f.jsx("label",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:"Transport"}),f.jsxs(Ef,{value:r.transport,onValueChange:s=>o("transport",O1(s)),children:[f.jsx(Gi,{className:"h-7 rounded-md border-border/70 bg-background/70 px-2 text-[10px]",children:f.jsx(Nf,{placeholder:"Transport"})}),f.jsxs(Xi,{children:[f.jsx(ua,{className:"py-1 text-[11px]",value:"inherit",children:"current / default"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"direct",children:"direct"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"devtunnel",children:"devtunnel"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"tailscale",children:"tailscale"})]})]})]}),f.jsx(Pl,{label:"Working directory",value:r.workDir,onChange:s=>o("workDir",s)}),f.jsx(Pl,{label:"Config path",value:r.config,onChange:s=>o("config",s),className:"sm:col-span-2"}),f.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[f.jsx("label",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:"GHC tunnel"}),f.jsxs(Ef,{value:r.ghcTunnel,onValueChange:s=>o("ghcTunnel",v_(s)),children:[f.jsx(Gi,{className:"h-7 rounded-sm border-border/70 bg-background/70 px-2 text-[10px]",children:f.jsx(Nf,{placeholder:"GHC tunnel"})}),f.jsxs(Xi,{children:[f.jsx(ua,{className:"py-1 text-[11px]",value:"inherit",children:"current / remembered"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"enable",children:"enable"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"disable",children:"disable"})]})]})]}),f.jsxs("label",{className:"flex items-center gap-2 rounded-md border border-border/60 bg-background/60 px-2 py-1.5 text-[10px] text-foreground sm:col-span-2 cursor-pointer hover:bg-muted/40 transition-colors",children:[f.jsx(A1,{className:"h-3.5 w-3.5",checked:r.disableAuth,onCheckedChange:s=>t({...r,disableAuth:s===!0,disableAuthKnown:!0})}),"Disable auth"]})]})]})}function Pl({className:t,inputMode:r,label:o,onChange:s,value:c}){return f.jsxs("label",{className:ae("space-y-1",t),children:[f.jsx("span",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:o}),f.jsx(xc,{className:"h-7 rounded-md px-2 text-[10px]",inputMode:r,value:c,onChange:u=>s(u.target.value)})]})}function Er({label:t,value:r,mono:o=!1}){return f.jsxs("div",{className:"flex items-start justify-between gap-3 text-[10px]",children:[f.jsx("span",{className:"shrink-0 uppercase tracking-[0.14em] text-muted-foreground",children:t}),f.jsx("span",{className:ae("break-all text-right text-foreground",o&&"font-mono"),children:r})]})}function p_(t){const r=t.result;if(!r||typeof r!="object")return null;const o=r;return o.ok!==!0||typeof o.command!="string"||typeof o.logPath!="string"?null:{ok:!0,mode:o.mode==="package"?"package":"development",command:o.command,logPath:o.logPath,pid:typeof o.pid=="number"?o.pid:void 0}}function h0(t){return{port:y_(t.endpoint),name:t.nodeName,join:"",transport:O1(t.transportType),workDir:t.workDir??"",config:"",disableAuth:t.disableAuthDefault===!0,disableAuthKnown:t.disableAuthDefault!==void 0,ghcTunnel:"inherit"}}function g_(t){const r={},o=Number(t.port.trim());return t.port.trim()&&Number.isInteger(o)&&o>0&&(r.port=o),t.name.trim()&&(r.name=t.name.trim()),t.join.trim()&&(r.join=t.join.trim()),t.transport!=="inherit"&&(r.transport=t.transport),t.workDir.trim()&&(r.workDir=t.workDir.trim()),t.config.trim()&&(r.config=t.config.trim()),t.disableAuthKnown&&(r.disableAuth=t.disableAuth),t.ghcTunnel==="enable"&&(r.ghcTunnel=!0),t.ghcTunnel==="disable"&&(r.ghcTunnel=!1),Object.keys(r).length>0?r:void 0}function O1(t){return t==="direct"||t==="devtunnel"||t==="tailscale"?t:"inherit"}function v_(t){return t==="enable"||t==="disable"?t:"inherit"}function y_(t){if(!t)return"";try{return new URL(t).port||""}catch{return""}}function Jd(t){return t.length<=8?t:t.slice(0,8)}function $l({formatDateTime:t,name:r,status:o,statusVariant:s}){return f.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-border/60 bg-background/70 px-2.5 py-1.5",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[11px] font-medium text-foreground",children:r}),f.jsx("div",{className:"text-[10px] text-muted-foreground",children:t(o?.checkedAt)})]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof o?.authenticated=="boolean"&&f.jsx(_t,{variant:o.authenticated?"default":"outline",className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o.authenticated?"auth ok":"auth required"}),f.jsx(_t,{variant:s(o?.status),className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o?.status??"unknown"})]})]})}function qt(t){if(t==null||t==="")return"Unavailable";const r=new Date(t);return Number.isNaN(r.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(r)}function b_(t){const r=Math.max(0,Math.floor(t)),o=Math.floor(r/86400),s=Math.floor(r%86400/3600),c=Math.floor(r%3600/60);return o>0?`${o}d ${s}h`:s>0?`${s}h ${c}m`:`${c}m`}function p0(t){if(t==null||Number.isNaN(t))return"Unavailable";const r=["B","KB","MB","GB","TB"];let o=t,s=0;for(;o>=1024&&s<r.length-1;)o/=1024,s+=1;return`${o.toFixed(o>=10||s===0?0:1)} ${r[s]}`}function Co(t){return t==="ok"?"default":t==="missing"||t==="install-failed"||t==="login-failed"?"destructive":t==="not-authenticated"||t==="unsupported-platform"?"outline":"secondary"}function x_(t){return t.available?f.jsx("span",{"data-agent-availability":"available","aria-label":"Available",title:"Available",className:"inline-flex h-5 w-5 items-center justify-center text-emerald-500",children:f.jsx(Ro,{className:"h-3.5 w-3.5"})}):f.jsx("span",{"data-agent-availability":"unavailable","aria-label":"Unavailable",title:"Unavailable",className:"inline-flex h-5 w-5 items-center justify-center text-destructive",children:f.jsx(uf,{className:"h-3.5 w-3.5"})})}function S_(t){return t.update?t.update.updateAvailable?f.jsxs(_t,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:["Update ",t.update.latestVersion]}):f.jsx(_t,{variant:"secondary",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:"Up to date"}):null}function w_(t){return t.available?null:t.metadataStatus??null}function E_(t){const r=`npm install -g ${t.update?.packageName}@latest`;return t.id==="claude"?`${r} --include=optional --ignore-scripts=false`:r}function N_(t){return t.error?t.error:t.result?.detail??null}function Fe({label:t,value:r,mono:o=!1}){return f.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border/50 py-1 last:border-b-0 last:pb-0 first:pt-0",children:[f.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:t}),f.jsx("span",{className:ae("break-all text-right text-[11px] text-foreground",o&&"font-mono text-[11px]"),children:r})]})}function ql({label:t,value:r,mono:o=!1,className:s}){return f.jsxs("div",{className:ae("min-w-0 space-y-0.5",s),children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:t}),f.jsx("div",{className:ae("truncate text-[11px] text-foreground",o&&"font-mono",t==="Path"&&"break-all whitespace-normal"),children:r})]})}function T_({agent:t,nodeName:r,activeOperation:o,onUpgrade:s}){const c=t.update?.updateAvailable===!0,u=S_(t),m=!!o,h=w_(t);return f.jsxs("div",{className:"rounded-sm border border-border/60 bg-background/65 px-3 py-2.5 transition-colors hover:bg-background/85",children:[f.jsxs("div",{className:"grid gap-3 lg:grid-cols-[12rem_minmax(0,1fr)_auto] lg:items-start",children:[f.jsxs("div",{className:"min-w-0 space-y-1.5",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[f.jsx(Yf,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),f.jsx("span",{className:"truncate",children:t.label})]}),f.jsxs("div",{className:"truncate text-[10px] text-muted-foreground",children:["Command: ",f.jsx("span",{className:"font-mono text-[10px]",children:t.command})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[x_(t),h&&f.jsx(_t,{variant:Co(h),className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:h})]})]}),f.jsxs("div",{className:"grid min-w-0 gap-x-4 gap-y-1.5 sm:grid-cols-2",children:[f.jsx(ql,{label:"Version",value:t.version??"Unavailable",mono:!!t.version}),t.update&&f.jsx(ql,{label:"Latest",value:t.update.latestVersion??"Unavailable",mono:!!t.update.latestVersion}),f.jsx(ql,{label:"Checked",value:qt(t.checkedAt)}),t.update&&f.jsx(ql,{label:"Update check",value:qt(t.update.checkedAt)}),f.jsx(ql,{label:"Path",value:t.path??"Not on PATH",mono:!!t.path,className:"sm:col-span-2"})]}),f.jsx("div",{className:"flex items-start justify-start lg:justify-end",children:o?f.jsxs(_t,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:["Upgrade ",o.status]}):c?f.jsxs(Cf,{children:[f.jsx(Rf,{asChild:!0,children:f.jsx("button",{type:"button",disabled:m,className:"rounded-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60",children:u})}),f.jsxs(Qi,{children:[f.jsxs(Ki,{children:[f.jsxs(Fi,{children:["Upgrade ",t.label,"?"]}),f.jsxs(Wi,{children:["This runs ",E_(t)," on ",r,". Remote nodes execute the command on the remote machine."]})]}),f.jsxs(Zi,{children:[f.jsx(ec,{children:"Cancel"}),f.jsx(Ji,{onClick:()=>s(t),children:"Upgrade"})]})]})]}):u})]}),t.update?.detail&&f.jsx("div",{className:"mt-2 rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[10px] text-muted-foreground",children:t.update.detail}),t.detail&&f.jsx("div",{className:"mt-2 rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[10px] text-muted-foreground",children:t.detail})]})}function C_(t,r){return t?.nodes?.length?t.nodes:r?[r]:[]}function R_(t,r){if(r&&t.id===r.nodeId)return r;const o=t.settingsSnapshot;return{...t,nodeId:t.id,version:o?.version??"Unavailable",packageName:o?.packageName,uptime:o?.uptime??0,defaultTaskAgent:o?.defaultTaskAgent,localDashboardOrigin:o?.runtime?.localDashboardOrigin??void 0,auth:o?.auth,os:o?.os,runtime:o?.runtime,runtimeUpdate:o?.runtimeUpdate,agents:o?.agents,startupRequirements:o?.startupRequirements,components:o?.components,repository:o?.repository,packages:o?.packages}}function A_(t,r){return t.id===r?`${t.name} (this node)`:`${t.name} (${t.role})`}function k_(t){return t==="claude"?"Claude Code":t==="copilot"?"Copilot CLI":"Codex"}function j_(t){const r=t.payload?.agent;return r==="claude"||r==="codex"||r==="copilot"?r:null}function __({cluster:t,systemInfo:r,sseConnected:o,initialSelectedNodeId:s,onRefresh:c}){const u=g.useMemo(()=>C_(t,r),[t,r]),[m,h]=g.useState(()=>s??r?.nodeId??t?.self?.id??""),[v,p]=g.useState(()=>new Map),[b,y]=g.useState("codex"),[w,k]=g.useState(!1),A=g.useRef(new Set),E=g.useRef(new Set),N=t?.self??r??u[0]??null,T=u.find(X=>X.id===m)??N,R=T?R_(T,r):null,O=!!(r&&T&&T.id===r.nodeId),H=O||!!T?.settingsSnapshot,z=R?.runtimeUpdate,K=Af(R?.defaultTaskAgent),I=R?.startupRequirements?.components??R?.components??{},P=g.useMemo(()=>u.map(X=>X.id),[u]),le=P.join("\0"),de=t_(u),fe=g.useMemo(()=>new Map(u.map(X=>[X.id,X.name])),[de]);g.useEffect(()=>{s&&P.includes(s)&&h(s)},[s,le]),g.useEffect(()=>{y(K)},[T?.id,K]);const W=g.useCallback(async(X,_)=>{const B=k1(X);if(!B||A.current.has(X.id))return;const Q=j_(X),ue=_?.agentLabel??(Q?k_(Q):"Agent"),C=_?.nodeName??fe.get(X.nodeId)??X.nodeId;A.current.add(X.id),p(V=>new Map(V).set(B,X));try{const V=await j1(X);if(V.status==="succeeded")await c?.(),E.current.has(V.id)||(Ce.success(`${ue} upgrade finished on ${C}`),E.current.add(V.id));else if(V.status==="failed")E.current.has(V.id)||(Ce.error(N_(V)??`${ue} upgrade failed`),E.current.add(V.id));else{p(re=>new Map(re).set(B,V)),Ce.info(`${ue} upgrade is still ${V.status} on ${C}`);return}p(re=>{const Y=new Map(re),ee=Y.get(B);return(!ee||ee.id===V.id)&&Y.delete(B),Y})}catch(V){p(re=>{const Y=new Map(re),ee=Y.get(B);return(!ee||ee.id===X.id)&&Y.delete(B),Y}),Ce.error(V instanceof Error?V.message:`${ue} upgrade failed`)}finally{A.current.delete(X.id)}},[c,fe]);g.useEffect(()=>{if(P.length===0)return;let X=!1;async function _(){let B;try{B=await r_(P)}catch{return}if(!X){p(Q=>{const ue=new Map(Q);for(const[C,V]of B)ue.set(C,V);return ue});for(const Q of B.values())W(Q)}}return _(),()=>{X=!0}},[W,le]);async function te(X){if(T)try{const _=await JE(T.id,X.id);Ce.info(`${X.label} upgrade started on ${T.name}`),await W(_,{agentLabel:X.label,nodeName:T.name})}catch(_){Ce.error(_ instanceof Error?_.message:`${X.label} upgrade failed`)}}async function se(X){if(!O||X===K)return;const _=b;y(X),k(!0);try{const B=await ZE(X);y(Af(B.defaultTaskAgent)),await c?.(),Ce.success("Default agent updated")}catch(B){y(_),Ce.error(B instanceof Error?B.message:"Failed to update default agent")}finally{k(!1)}}return!T||!R?f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-5 text-center text-[11px] text-muted-foreground",children:"Loading session metadata..."}):f.jsxs("div",{className:"space-y-3",children:[f.jsxs("section",{className:"relative mt-1 rounded-sm border border-border/70 bg-background/75 p-3 shadow-none",children:[!O&&f.jsxs(_t,{variant:"outline",className:"absolute right-3 top-2.5 rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em] whitespace-nowrap",children:["Updated ",qt(T.settingsSnapshot?.collectedAt)]}),f.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-end md:justify-between",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.jsxs("span",{className:"flex items-center gap-1.5 rounded-sm border border-border/70 bg-background/75 px-1.5 py-0 text-[10px] text-muted-foreground",children:[f.jsx(vj,{status:T.status}),f.jsx("span",{className:"font-medium text-foreground",children:T.name})]}),f.jsx(yj,{role:T.role}),f.jsx(_t,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:T.transportType??R.transportType??"direct"}),f.jsx(_t,{variant:O?"default":"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:O?"Live local session":"Leader-synced snapshot"})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-[10px] uppercase tracking-[0.34em] text-muted-foreground",children:"Session"}),f.jsx("h3",{className:"mt-0.5 text-sm font-semibold tracking-tight text-foreground",children:"Node runtime"}),f.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Runtime environment, connectivity, and build metadata."})]}),u.length>1&&f.jsxs("div",{className:"w-48 space-y-1.5",children:[f.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:"Inspect node"}),f.jsxs(Ef,{value:T.id,onValueChange:h,children:[f.jsx(Gi,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px]",children:f.jsx(Nf,{placeholder:"Choose a node"})}),f.jsx(Xi,{className:"settings-node-select-content rounded-sm text-[10px] leading-4",children:u.map(X=>f.jsx(ua,{value:X.id,className:"settings-node-select-item py-1 pl-6 pr-2 text-[10px] leading-4 [&>span]:left-1.5 [&_svg]:h-3 [&_svg]:w-3",children:A_(X,r?.nodeId)},X.id))})]})]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(_t,{variant:o?"default":"outline",className:"gap-1 rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:[f.jsx(yT,{className:"h-3 w-3"}),o?"Live link":"Reconnecting"]}),f.jsxs(_t,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:["Uptime ",b_(R.uptime)]})]})]})]}),!H&&f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-[11px] text-muted-foreground",children:"This node has not synced its settings snapshot to the leader yet. Wait for the next keepalive and reopen the dialog if needed."}),f.jsxs(nj,{defaultValue:"session",className:"space-y-2",children:[f.jsxs(Qx,{className:"h-auto flex-wrap rounded-sm border border-border/60 bg-muted/40 p-0.5",children:[f.jsx(Yl,{value:"session",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Session"}),f.jsx(Yl,{value:"access",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Access"}),f.jsx(Yl,{value:"quick-chats",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Quick chats"}),f.jsx(Yl,{value:"about",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"About"})]}),f.jsxs(Gl,{value:"session",className:"mt-0 grid gap-2 xl:grid-cols-[1.15fr_0.85fr]",children:[f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(fy,{className:"h-3.5 w-3.5 text-primary"}),"Selected node"]}),f.jsx(Nn,{className:"text-[10px]",children:"Cluster role, identity, and node-scoped runtime state."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Node ID",value:R.nodeId,mono:!0}),f.jsx(Fe,{label:"Status",value:T.status}),f.jsx(Fe,{label:"Role",value:T.role}),f.jsx(Fe,{label:"Endpoint",value:T.endpoint,mono:!0}),f.jsx(Fe,{label:"Joined",value:qt(T.joinedAt)}),f.jsx(Fe,{label:"Heartbeat",value:qt(T.lastHeartbeat)}),f.jsx(Fe,{label:"Capabilities",value:T.capabilities.length>0?T.capabilities.join(", "):"None"})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(FN,{className:"h-3.5 w-3.5 text-primary"}),"OS info"]}),f.jsx(Nn,{className:"text-[10px]",children:"Host and resource details reported by the current process."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Host",value:R.os?.hostname??"Unavailable"}),f.jsx(Fe,{label:"Platform",value:R.os?`${R.os.platform} ${R.os.release}`:"Unavailable"}),f.jsx(Fe,{label:"Arch",value:R.os?.arch??"Unavailable"}),f.jsx(Fe,{label:"CPU",value:R.os?.cpuModel??"Unavailable"}),f.jsx(Fe,{label:"Cores",value:String(R.os?.cpuCount??"Unavailable")}),f.jsx(Fe,{label:"Memory",value:R.os?`${p0(R.os.freeMemoryBytes)} free / ${p0(R.os.totalMemoryBytes)} total`:"Unavailable"})]})]}),z&&f.jsx("div",{className:"xl:col-span-2",children:f.jsx(m_,{checkedLabel:qt(z.checkedAt),disableAuthDefault:R.auth?.enabled===void 0?void 0:R.auth.enabled===!1,endpoint:T.endpoint,isLiveLocalNode:O,nodeId:T.id,nodeName:T.name,onRefresh:c,pid:R.runtime?.pid,transportType:T.transportType,update:z,workDir:R.runtime?.workDir??T.workDir})}),f.jsx($j,{nodeId:T.id,nodeName:T.name}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none xl:col-span-2",children:[f.jsx(wn,{className:"pb-1.5 pt-2.5 px-3",children:f.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[f.jsxs("div",{className:"min-w-0 space-y-1",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(Yf,{className:"h-3.5 w-3.5 text-primary"}),"Available agents"]}),f.jsx(Nn,{className:"text-[10px]",children:O?"Live command availability for runtime agents on this node.":"Most recent agent availability snapshot synced from this node."})]}),f.jsx(qj,{value:w?b:K,disabled:!O,saving:w,onChange:se})]})}),f.jsx(Tn,{"data-agent-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:(R.agents??[]).map(X=>f.jsx(T_,{agent:X,nodeName:T.name,activeOperation:v.get(`${T.id}:${X.id}`),onUpgrade:te},X.id))})]})]}),f.jsxs(Gl,{value:"access",className:"mt-0 grid gap-2 xl:grid-cols-2",children:[f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(oy,{className:"h-3.5 w-3.5 text-primary"}),"Access surface"]}),f.jsx(Nn,{className:"text-[10px]",children:"How this node is exposed to the dashboard and other peers."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Transport",value:T.transportType??R.transportType??"direct"}),f.jsx(Fe,{label:"Node URL",value:T.endpoint,mono:!0}),f.jsx(Fe,{label:"Node tunnel",value:T.devtunnelEndpoint??"Disabled",mono:!!T.devtunnelEndpoint}),f.jsx(Fe,{label:"Dashboard URL",value:T.dashboardOrigin??R.localDashboardOrigin??"Unavailable",mono:!!(T.dashboardOrigin||R.localDashboardOrigin)}),f.jsx(Fe,{label:"Local dashboard",value:R.localDashboardOrigin??"Unavailable",mono:!!R.localDashboardOrigin})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(kT,{className:"h-3.5 w-3.5 text-primary"}),"Auth"]}),f.jsx(Nn,{className:"text-[10px]",children:"Current bearer-auth and trusted access posture."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Enabled",value:R.auth?.enabled?"Yes":"No"}),f.jsx(Fe,{label:"Same tenant",value:R.auth?.allowSameTenant?"Allowed":"Off"}),f.jsx(Fe,{label:"Allowed users",value:R.auth?.allowedUsers.length?R.auth.allowedUsers.join(", "):"None"})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(eT,{className:"h-3.5 w-3.5 text-primary"}),"Paths"]}),f.jsx(Nn,{className:"text-[10px]",children:"Workspace and runtime paths currently used by this node."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Work dir",value:R.runtime?.workDir??R.workDir??"Unavailable",mono:!!(R.runtime?.workDir??R.workDir)}),f.jsx(Fe,{label:"Storage",value:R.runtime?.storagePath??"Unavailable",mono:!!R.runtime?.storagePath}),f.jsx(Fe,{label:"Process cwd",value:R.runtime?.cwd??"Unavailable",mono:!!R.runtime?.cwd}),f.jsx(Fe,{label:"Started",value:qt(R.runtime?.startedAt)}),f.jsx(Fe,{label:"PID",value:R.runtime?String(R.runtime.pid):"Unavailable",mono:!!R.runtime})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(Ui,{className:"h-3.5 w-3.5 text-primary"}),"Startup checks"]}),f.jsx(Nn,{className:"text-[10px]",children:"Dependency preflight snapshot persisted during node startup."})]}),f.jsxs(Tn,{className:"space-y-3 px-3 pb-2.5",children:[f.jsxs("div",{className:"rounded-sm border border-border/60 bg-background/70 px-3 py-2",children:[f.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:"Last checked"}),f.jsx("div",{className:"mt-0.5 text-[11px] text-foreground",children:qt(R.startupRequirements?.lastCheckedAt)})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx($l,{formatDateTime:qt,name:"Azure CLI",status:I.az,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"DevTunnel",status:I.devtunnel,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"Claude Code",status:I.claude,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"Codex",status:I.codex,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"Copilot CLI",status:I.copilot,statusVariant:Co})]})]})]})]}),f.jsx(Gl,{value:"quick-chats",className:"mt-0",children:f.jsx(Zj,{})}),f.jsx(Sj,{formatDateTime:qt,viewInfo:R})]})]})}function O_({initialSelectedNodeId:t,open:r,onOpenChange:o,showTrigger:s=!0}={}){const{cluster:c,systemInfo:u,sseConnected:m,refresh:h}=ay();return f.jsx(YA,{open:r,onOpenChange:o,showTrigger:s,children:f.jsx(__,{cluster:c,systemInfo:u,sseConnected:m,initialSelectedNodeId:t,onRefresh:h})})}const nc="meshy:show-live-events";function M1(){const t=globalThis.window;if(!t)return;const r=typeof t.CustomEvent=="function"?new t.CustomEvent(nc):new t.Event(nc);t.dispatchEvent(r)}function mM(t){const r=globalThis.window;return r?(r.addEventListener(nc,t),()=>r.removeEventListener(nc,t)):()=>{}}const M_={node:"border-teal-500/30 bg-teal-500/10 text-teal-700 dark:text-teal-300",task:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",election:"border-indigo-500/30 bg-indigo-500/10 text-indigo-700 dark:text-indigo-300",cluster:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",transport:"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300"},D_={node:"text-teal-700/70 dark:text-teal-300/70",task:"text-amber-700/70 dark:text-amber-300/70",election:"text-indigo-700/70 dark:text-indigo-300/70",cluster:"text-emerald-700/70 dark:text-emerald-300/70",transport:"text-sky-700/70 dark:text-sky-300/70"};function z_(t){return t.split(".")[0]??"unknown"}function U_(t){return new Date(t).toLocaleTimeString("en-US",{hour12:!1})}function No(t,r,o){return typeof o=="string"&&o.length>0?o:r?.get(t)??t}function D1(t,r){const o=t.data,s=o.operation;switch(t.type){case"node.joined":return`${o.name} joined the cluster`;case"node.left":return`${No(o.nodeId,r,o.name)} left (${o.reason})`;case"node.status":return`${No(o.nodeId,r)} is now ${o.status}`;case"node.operation.created":return`${s?.kind} ${s?.status} on ${No(s?.nodeId,r)}`;case"node.operation.updated":return`${s?.kind} ${s?.status} on ${No(s?.nodeId,r)}`;case"transport.changed":return`${No(o.nodeId,r)} transport switched to ${o.transportType}`;case"task.created":return`"${o.title}" created`;case"task.assigned":return`task assigned to ${No(o.nodeId,r)}`;case"task.status":return`task ${o.taskId.slice(0,8)} -> ${o.status}`;case"election.started":return`candidate ${o.candidateId.slice(0,8)} term ${o.term}`;case"election.complete":return`leader elected, term ${o.term}`;case"cluster.state":return`${o.nodeCount} nodes, term ${o.term}`;default:return JSON.stringify(o)}}function L_(t){return JSON.stringify(t,null,2)}function B_({events:t,maxHeight:r="400px",nodeNameById:o,onDismiss:s,onSelect:c,density:u="default"}){if(t.length===0)return null;const m=u==="compact";return f.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:r},children:f.jsx("div",{className:"space-y-1.5",children:t.map(h=>{const v=z_(h.type);return f.jsx("div",{onClick:c?()=>c(h.id):void 0,onKeyDown:c?p=>{p.target===p.currentTarget&&(p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),c(h.id)))}:void 0,"data-click-open-live-events":c?"true":void 0,role:c?"button":void 0,tabIndex:c?0:void 0,title:c?"Open in Live events":void 0,className:ae("transition-colors hover:bg-muted/30",c&&"cursor-pointer",m?"rounded-sm px-1 py-0.5":"rounded-sm px-1.5 py-1"),children:f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.jsx("div",{className:ae("font-mono text-muted-foreground",m?"text-[8px]":"text-[9px]"),children:U_(h.timestamp)}),m?f.jsx("span",{className:ae("max-w-[8.5rem] truncate text-[7px] font-medium uppercase tracking-[0.08em] text-muted-foreground/70",D_[v]),children:h.type}):f.jsx(_t,{variant:"outline",className:ae("w-fit text-[9px] font-medium uppercase tracking-[0.14em] px-1.5 py-0",M_[v]),children:h.type})]}),f.jsxs("div",{className:ae("flex shrink-0 items-center",m?"gap-px":"gap-0.5"),children:[f.jsx(Ct,{type:"button",variant:"ghost",size:"icon",className:ae("rounded-sm text-muted-foreground hover:text-foreground",m?"h-3.5 w-3.5 p-0 opacity-65 hover:bg-muted/40 hover:opacity-100 [&_svg]:size-2.5":"h-5 w-5"),onClick:p=>{p.stopPropagation(),y1(L_(h),"Event copied")},"aria-label":`Copy ${h.type} event`,title:"Copy event",children:f.jsx(ly,{className:m?"h-2.5 w-2.5":"h-3 w-3"})}),s&&f.jsx(Ct,{type:"button",variant:"ghost",size:"icon",className:ae("rounded-sm text-muted-foreground hover:text-foreground",m?"h-3.5 w-3.5 p-0 opacity-65 hover:bg-muted/40 hover:opacity-100 [&_svg]:size-2.5":"h-5 w-5"),onClick:p=>{p.stopPropagation(),s(h.id)},"aria-label":`Dismiss ${h.type} event`,title:"Dismiss event",children:f.jsx(py,{className:m?"h-2.5 w-2.5":"h-3 w-3"})})]})]}),f.jsx("div",{className:"text-[9px] leading-snug text-foreground/85",children:D1(h,o)})]})},h.id)})})})}function z1(t){return t!==null}function U1(t){return t==="click"?t:"hover"}function _f(t){return t==="hover"?null:t}function L1(t){return t==="click"?null:"click"}const H_=["node.","election.","transport."],P_="cluster.state";function $_(t){return t.type==="node.status"?!1:H_.some(r=>t.type.startsWith(r))}function q_(t){return new Date(t).toLocaleTimeString("en-US",{hour12:!1})}function V_(t,r){return t?{time:q_(t.timestamp),text:D1(t,r)}:null}function I_(t){return t.transportType==="devtunnel"||!!t.devtunnelEndpoint}function Y_(t){if(t.length===0)return"No node tunnel";const r=t.filter(c=>c.status==="offline").length;if(r>0)return`${r} offline`;const o=t.filter(c=>c.devtunnelHealth?.status==="failed").length;if(o>0)return`${o} failed`;const s=t.filter(c=>c.status!=="offline"&&c.devtunnelHealth?.status!=="healthy").length;return s>0?`${s} checking`:"Healthy"}function G_(t,r){const o=r?.get(t.id)??t.name??t.id;if(t.status==="offline")return{label:o,status:"offline"};const s=t.devtunnelHealth?.status??"checking";return{label:o,status:s}}function X_(t){if(t.length===0)return"No nodes";const r=t.filter(s=>s.status==="offline").length;if(r>0)return`${r} offline`;const o=t.filter(s=>s.status==="busy").length;return o>0?`${o} busy`:"Healthy"}function Q_(t,r){return{label:r?.get(t.id)??t.name??t.id,status:t.status}}function K_({connected:t,events:r,nodes:o=[],currentNode:s=null,nodeNameById:c,desktopUpdate:u=null,desktopUpdateCheckPending:m=!1,desktopUpdateProgress:h=null,defaultOpen:v=!1,defaultActionMenuOpen:p=!1,onDesktopUpdateCheck:b,onDesktopUpdate:y,onDesktopRestart:w,onReload:k,onRestart:A}){const[E,N]=g.useState(v?"click":null),[T,R]=g.useState(p),[O,H]=g.useState(!0),[z,K]=g.useState(new Set),[I,P]=g.useState(!1),[le,de]=g.useState(!1),fe=z1(E),W=g.useRef(null),te=g.useRef(null),se=g.useMemo(()=>r.filter(be=>$_(be)&&!z.has(be.id)),[r,z]),X=g.useMemo(()=>r.find(be=>be.type===P_)??se[0],[r,se]),_=g.useMemo(()=>V_(X,c),[X,c]),B=g.useMemo(()=>{const be=new Map(o.map(Xe=>[Xe.id,Xe]));return s&&be.set(s.id,s),Array.from(be.values())},[s,o]),Q=g.useMemo(()=>B.filter(I_),[B]),ue=Q.some(be=>be.status==="offline"||be.devtunnelHealth?.status==="failed"),C=B.some(be=>be.status==="offline"),V=B.some(be=>be.status==="busy"),re=B.length>0,Y=s?.name??"offline",ee=s?.role==="leader"?"Leader":s?.role==="follower"?"Follower":"Node",J=u!==null,ne=!!(J&&u?.updateAvailable&&u.latestVersion),ie=u?.latestVersion??null,ce=!!(J&&!ne&&ie),xe=!!(J&&u?.detail==="Checking desktop update..."),Re=!!(J&&!ne&&!ie&&u?.detail&&!xe),Ne=h?.percent??null,Ae=Ne===null?null:`${Ne}%`,et=I?"Relaunching runtime...":"Relaunch to apply update",rt=Ae?`Downloading ${Ae}`:le?"Downloading and installing desktop update...":ne&&ie?`Available version ${ie}`:Re?u?.detail??"Desktop update unavailable":"Desktop is current",hn=!!k,pn=!!(J&&w),er=!!(J&&b)||hn||pn,pt=J||!!A,_r=J||!!A||hn,In=pt?J?ne?"Update":ce?"Latest":"Check":"Relaunch":"Reload",it=J&&!ne,gn=it?"Check":In,Or=pt?J?rt:et:"Reload dashboard page",ga=pt?J?le||h!==null:I:!1,It=pt?J?ga||!ne||!y:ga:!1,Rt=m||le||!b,Ut=J?ne&&ie?`Install desktop update ${ie}`:Re?"Desktop update unavailable":"Desktop is current":pt?I?"Relaunching runtime":"Relaunch runtime":"Reload dashboard page";function Je(){te.current&&(clearTimeout(te.current),te.current=null)}function On(){Je(),N(be=>U1(be))}function Mr(){Je(),te.current=setTimeout(()=>{N(be=>_f(be)),te.current=null},180)}function Mn(){Je()}function va(){Je(),N(be=>_f(be))}async function ya(){if(!(!A||I)){P(!0);try{await A()}finally{P(!1)}}}async function nn(){if(!(!ne||!y||le)){de(!0);try{await y()}finally{de(!1)}}}async function Yn(){!b||m||le||await b()}async function Gn(){if(!(!w||I)){R(!1),P(!0);try{await w()}finally{P(!1)}}}async function ba(){if(!pt){await Lt();return}if(J){await nn();return}await ya()}async function Lt(){k&&(R(!1),await k())}function tr(){K(be=>{const Xe=new Set(be);return se.forEach(me=>Xe.add(me.id)),Xe})}function nr(){M1(),N(null)}return g.useEffect(()=>()=>{Je()},[]),g.useEffect(()=>{K(be=>{if(be.size===0)return be;const Xe=new Set(r.map(He=>He.id)),me=new Set(Array.from(be).filter(He=>Xe.has(He)));return me.size===be.size?be:me})},[r]),g.useEffect(()=>{fe||R(!1)},[fe]),g.useEffect(()=>{if(!fe)return;const be=me=>{W.current?.contains(me.target)||(Je(),R(!1),N(null))},Xe=me=>{me.key==="Escape"&&(Je(),R(!1),N(null))};return document.addEventListener("pointerdown",be),document.addEventListener("keydown",Xe),()=>{document.removeEventListener("pointerdown",be),document.removeEventListener("keydown",Xe)}},[fe]),f.jsxs("div",{ref:W,className:"relative",children:[f.jsxs("button",{type:"button","aria-label":t?"Cluster link connected":"Cluster link reconnecting","aria-expanded":fe,"aria-haspopup":"dialog",onClick:()=>N(be=>L1(be)),onMouseEnter:On,onMouseLeave:Mr,className:ae("flex h-8 max-w-[18rem] items-center gap-1.5 rounded-sm px-2 text-[10px] transition-all sm:gap-2 sm:px-2.5 sm:text-[11px]",t?"bg-muted/40 text-muted-foreground hover:bg-muted/60 hover:text-foreground":"bg-destructive/8 text-destructive hover:bg-destructive/12",fe&&(t?"bg-muted/60 text-foreground":"bg-destructive/12")),title:t?"Cluster link connected":"Cluster link reconnecting",children:[f.jsxs("span",{className:ae("relative flex h-2 w-2 shrink-0"),children:[t&&f.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-60"}),f.jsx("span",{className:ae("relative inline-flex h-2 w-2 rounded-full",t?"bg-emerald-500":"bg-destructive")})]}),f.jsxs("span",{className:"hidden min-w-0 items-center gap-2 sm:flex",children:[f.jsx("span",{className:"truncate font-medium text-foreground",children:Y}),f.jsx("span",{className:ae("shrink-0 rounded border px-1 py-px text-[8px] font-semibold uppercase tracking-[0.1em]",t?"border-emerald-500/25 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-destructive/30 bg-destructive/10 text-destructive"),children:ee})]})]}),fe&&f.jsxs("div",{role:"dialog","aria-label":"Live link connection events",onMouseEnter:Mn,onMouseLeave:va,className:"absolute right-0 top-[calc(100%+0.35rem)] z-50 w-[17rem] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-sm border border-border/60 bg-popover/98 shadow-[0_16px_44px_-34px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-sm max-sm:fixed max-sm:right-3 max-sm:top-[3.75rem] max-sm:w-[calc(100vw-1.5rem)]",children:[f.jsx("div",{className:"border-b border-border/60 bg-muted/25 px-2.5 py-1.5",children:f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[t?f.jsx(Ui,{className:"h-3 w-3 text-emerald-500"}):f.jsx(LT,{className:"h-3 w-3 text-destructive"}),f.jsx("span",{className:"text-[10px] font-semibold text-foreground",children:"Live link"}),f.jsx("span",{className:"text-[9px] text-muted-foreground",children:t?"· SSE connected":"· reconnecting"})]}),f.jsx("div",{className:ae("rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.12em]",t?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-destructive/30 bg-destructive/10 text-destructive"),children:t?"Connected":"Retrying"})]})}),f.jsxs("div",{className:"grid grid-cols-2 border-b border-border/60",children:[f.jsxs("div",{className:"border-r border-border/60 px-2.5 py-1.5",children:[f.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Events"}),f.jsx("div",{className:"mt-0.5 text-base font-semibold tracking-tight text-foreground",children:se.length})]}),f.jsxs("div",{className:"min-w-0 px-2.5 py-1.5",children:[f.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Latest"}),_?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mt-0.5 truncate text-[9px] leading-snug text-foreground/80",children:_.text}),f.jsx("div",{className:"font-mono text-[8px] text-muted-foreground/60",children:_.time})]}):f.jsx("div",{className:"mt-0.5 text-[8px] text-muted-foreground/50",children:"—"})]})]}),f.jsxs("div",{className:"border-b border-border/60 px-2.5 py-1.5",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[C?f.jsx(gi,{className:"h-3 w-3 shrink-0 text-destructive"}):V?f.jsx(Ui,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Ro,{className:ae("h-3 w-3 shrink-0",re?"text-emerald-500":"text-muted-foreground")}),f.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Node health"})]}),f.jsx("span",{className:ae("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",C?"border-destructive/30 bg-destructive/10 text-destructive":V?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":re?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-border/70 bg-background/60 text-muted-foreground"),children:X_(B)})]}),B.length>0&&f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:B.map(be=>{const{label:Xe,status:me}=Q_(be,c),He=me==="offline",Qe=me==="busy";return f.jsxs("div",{"aria-label":`${Xe} ${me}`,className:ae("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",He?"bg-destructive/6":Qe?"bg-amber-500/6":"bg-emerald-500/5"),title:`${Xe} ${me}`,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Xe}),He?f.jsx(gi,{className:"h-3 w-3 shrink-0 text-destructive"}):Qe?f.jsx(Av,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Ro,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},be.id)})})]}),Q.length>0&&f.jsxs("div",{className:"border-b border-border/60 px-2.5 py-1.5",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[ue?f.jsx(gi,{className:"h-3 w-3 shrink-0 text-destructive"}):f.jsx(Ro,{className:"h-3 w-3 shrink-0 text-emerald-500"}),f.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"DevTunnel"})]}),f.jsx("span",{className:ae("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",ue?"border-destructive/30 bg-destructive/10 text-destructive":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:Y_(Q)})]}),f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:Q.map(be=>{const{label:Xe,status:me}=G_(be,c),He=me==="failed"||me==="offline",Qe=me!=="healthy"&&me!=="failed"&&me!=="offline",gt=be.devtunnelHealth?.reason?`${Xe} ${me}: ${be.devtunnelHealth.reason}`:`${Xe} ${me}`;return f.jsxs("div",{"aria-label":`${Xe} ${me}`,className:ae("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",He?"bg-destructive/6":Qe?"bg-muted/30":"bg-emerald-500/5"),title:gt,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Xe}),He?f.jsx(gi,{className:"h-3 w-3 shrink-0 text-destructive"}):Qe?f.jsx(Av,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):f.jsx(Ro,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},be.id)})})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-1 px-2 py-1",children:[f.jsxs("button",{type:"button",onClick:()=>H(be=>!be),className:"flex min-w-0 flex-1 items-center justify-between rounded-sm px-0.5 py-0.5 text-left hover:bg-muted/25",children:[f.jsxs("span",{className:"truncate text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:["Notifications ",se.length>0&&`(${se.length})`]}),O?f.jsx(Zl,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):f.jsx(cf,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}),!O&&se.length>0&&f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px] font-medium text-muted-foreground hover:text-foreground",onClick:tr,title:"Clear all notifications",children:"Clear all"})]}),O&&f.jsx("div",{className:"px-2 pb-1.5",children:f.jsx(B_,{events:se,maxHeight:"10rem",density:"compact",emptyTitle:"No connection events yet",emptyDescription:"Node, election, and system events will appear here.",nodeNameById:c,onSelect:nr,onDismiss:be=>K(Xe=>new Set(Xe).add(be))})})]}),J&&u?.detail&&!xe&&f.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border/60 px-2.5 py-1 text-[8px] text-muted-foreground",children:[f.jsx("span",{className:"shrink-0 font-medium uppercase tracking-[0.12em]",children:"Desktop update"}),f.jsx("span",{className:"truncate",title:u.detail,children:u.detail})]}),f.jsxs("div",{className:"flex items-center justify-between gap-1 border-t border-border/60 px-2.5 py-1",children:[f.jsx("div",{children:_r&&f.jsxs("div",{className:"group/restart relative flex items-center",children:[f.jsxs("div",{className:"flex items-center overflow-hidden rounded-sm border border-border/50",children:[f.jsxs(Ct,{type:"button",variant:"ghost",size:"sm",className:ae("relative h-5 overflow-hidden rounded-none border-0 px-1.5 text-[9px] font-medium hover:text-foreground [&_svg]:size-2.5",ne?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>{ba()},disabled:It,"aria-label":Ut,"aria-describedby":"live-link-restart-hint",title:Or,children:[Ne!==null&&f.jsx("span",{role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Ne,className:"pointer-events-none absolute inset-y-0 left-0 bg-primary/24",style:{width:`${Ne}%`}}),Ne===null&&f.jsx(kv,{className:ae("relative z-10 h-2.5 w-2.5",ga&&"animate-pulse")}),f.jsx("span",{className:"relative z-10",children:Ae??In})]}),er&&f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:ae("h-5 rounded-none border-l border-border/50 px-1 text-[9px] hover:text-foreground [&_svg]:size-2.5",ne?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>R(be=>!be),"aria-label":"Open live link actions","aria-expanded":T,title:"Live link actions",children:f.jsx(Zl,{className:"h-2.5 w-2.5"})})]}),er&&T&&f.jsxs("div",{className:"absolute bottom-[calc(100%+0.25rem)] left-0 z-20 min-w-28 overflow-hidden rounded-sm border border-border/70 bg-background text-[9px] shadow-sm",children:[f.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 px-2 py-1 text-left text-muted-foreground hover:bg-muted/55 hover:text-foreground disabled:opacity-45 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",onClick:()=>{it?Yn():ba()},disabled:it?Rt:It,"aria-label":it?"Check for desktop updates":Ut,children:[it?f.jsx(Ai,{className:ae("h-2.5 w-2.5",m&&"animate-spin")}):f.jsx(kv,{className:ae("h-2.5 w-2.5",ga&&"animate-pulse")}),f.jsx("span",{children:gn})]}),hn&&f.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 border-t border-border/50 px-2 py-1 text-left text-muted-foreground hover:bg-muted/55 hover:text-foreground disabled:opacity-45 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",onClick:()=>{Lt()},"aria-label":"Reload dashboard page",children:[f.jsx(Ai,{className:"h-2.5 w-2.5"}),f.jsx("span",{children:"Reload"})]}),pn&&f.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 border-t border-border/50 px-2 py-1 text-left text-muted-foreground hover:bg-muted/55 hover:text-foreground",onClick:()=>{Gn()},disabled:I,"aria-label":"Restart Meshy Desktop",children:[f.jsx(Ai,{className:ae("h-2.5 w-2.5",I&&"animate-spin")}),f.jsx("span",{children:"Restart"})]})]}),f.jsx("span",{id:"live-link-restart-hint",role:"tooltip",className:"pointer-events-none absolute left-6 top-1/2 z-10 -translate-y-1/2 whitespace-nowrap rounded-sm border border-border/70 bg-background px-1.5 py-0.5 text-[8px] text-muted-foreground opacity-0 shadow-sm transition-opacity group-hover/restart:opacity-100 group-focus-within/restart:opacity-100",children:Or})]})}),f.jsxs("div",{className:"flex items-center gap-1",children:[O&&f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:tr,disabled:se.length===0,title:"Clear all notifications",children:"Clear all"}),f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:()=>N(null),children:"Close"})]})]})]})]})}const g0="dark",kr="fluent",Z_="clean",ef="meshy-layout-default-migrated-to-compact",Of="true",F_="compact",W_=new Set(["airy","clean","fluent"]);function J_(t){return t!==null&&W_.has(t)}function wc(t){return t===F_?"fluent":J_(t)?t:null}function e3(t,r){const o=wc(t);return o===Z_&&r!==Of?kr:o??kr}const ac="symphony",B1="default",t3=new Set(["light","dark","system"]),n3=new Set(["porcelain","warm","finsight","edge","symphony","launcher"]),H1=g.createContext(null);function a3(t){const r=new URLSearchParams(t).get("theme");return P1(r)?r:null}function r3(t){const r=new URLSearchParams(t).get("palette");return xm(r)}function o3(t){const r=new URLSearchParams(t).get("layout");return wc(r)}function l3(){if(typeof document>"u")return null;const t=document.documentElement;return{theme:t.classList.contains("dark")?"dark":"light",palette:xm(t.getAttribute("data-palette"))??ac,layout:wc(t.getAttribute("data-layout"))??kr}}function hM(t,r=l3()){if(!r)return t;try{const o=/^[a-z][a-z\d+\-.]*:/i.test(t),s=typeof window<"u"?window.location.href:"http://localhost",c=new URL(t,s);return c.searchParams.set("theme",r.theme),c.searchParams.set("palette",r.palette),c.searchParams.set("layout",r.layout),o?c.toString():`${c.pathname}${c.search}${c.hash}`}catch{return t}}const tf=.9;function v0(t){const r=t.trim().match(/^(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)%\s+(-?\d+(?:\.\d+)?)%$/);if(!r)return null;const o=(Number(r[1])%360+360)%360/60,s=rc(Number(r[2])/100,0,1),c=rc(Number(r[3])/100,0,1),u=(1-Math.abs(2*c-1))*s,m=u*(1-Math.abs(o%2-1)),h=c-u/2,[v,p,b]=o<1?[u,m,0]:o<2?[m,u,0]:o<3?[0,u,m]:o<4?[0,m,u]:o<5?[m,0,u]:[u,0,m];return[Math.round((v+h)*255),Math.round((p+h)*255),Math.round((b+h)*255),255]}function s3(t){const r=t.trim();if(!r||r==="transparent")return null;const o=r.match(/^rgba?\(\s*([+-]?\d+(?:\.\d+)?)\s*,\s*([+-]?\d+(?:\.\d+)?)\s*,\s*([+-]?\d+(?:\.\d+)?)(?:\s*,\s*([+-]?\d+(?:\.\d+)?))?\s*\)$/i);if(o)return[To(Number(o[1])),To(Number(o[2])),To(Number(o[3])),x0(o[4])];const s=r.match(/^rgba?\(\s*([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)(?:\s*\/\s*([+-]?\d+(?:\.\d+)?%?))?\s*\)$/i);return s?[To(Number(s[1])),To(Number(s[2])),To(Number(s[3])),x0(s[4])]:null}function i3(t,r,o){const s=v0(t);if(!s)return null;if(o==="clean"||o==="fluent")return s;const c=v0(r);return c?[nf(s[0],c[0],tf),nf(s[1],c[1],tf),nf(s[2],c[2],tf),255]:null}function c3(){const t=document.querySelector(".dashboard-shell-header-panel");if(!t)return null;const r=s3(getComputedStyle(t).backgroundColor);return!r||r[3]===0?null:r}function y0(){if(typeof window>"u"||typeof document>"u")return;const t=window.__TAURI__?.core?.invoke??null;if(!t)return;const r=document.documentElement,o=r.classList.contains("dark")?"dark":"light",s=getComputedStyle(r),c=wc(r.getAttribute("data-layout"))??kr,u=c3()??i3(s.getPropertyValue("--card"),s.getPropertyValue("--background"),c);t("sync_desktop_theme",{theme:o,backgroundColor:u}).catch(()=>{})}function b0(){if(typeof window>"u")return()=>{};if(y0(),typeof window.requestAnimationFrame!="function")return()=>{};const t=window.requestAnimationFrame(()=>y0());return()=>window.cancelAnimationFrame(t)}function nf(t,r,o){return Math.round(t*o+r*(1-o))}function rc(t,r,o){return Math.min(Math.max(t,r),o)}function To(t){return Math.round(rc(t,0,255))}function x0(t){if(t==null||t==="")return 255;const r=t.endsWith("%")?Number(t.slice(0,-1))/100:Number(t);return Math.round(rc(r,0,1)*255)}function u3({children:t}){const[r,o]=g.useState(()=>typeof window<"u"?a3(window.location.search)??m3(localStorage.getItem("meshy-theme"))??g0:g0),[s,c]=g.useState(()=>typeof window<"u"?r3(window.location.search)??h3(localStorage.getItem("meshy-palette"))??ac:ac),[u,m]=g.useState(()=>{if(typeof window<"u"){const h=o3(window.location.search);if(h)return localStorage.setItem(ef,Of),h;const v=e3(localStorage.getItem("meshy-layout"),localStorage.getItem(ef));return localStorage.setItem(ef,Of),v}return kr});return g.useEffect(()=>{const h=document.documentElement,v=p=>{if(p==="system"){const b=window.matchMedia("(prefers-color-scheme: dark)").matches;h.classList.toggle("dark",b)}else h.classList.toggle("dark",p==="dark")};if(v(r),localStorage.setItem("meshy-theme",r),r==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)"),b=()=>{v("system"),b0()};return p.addEventListener("change",b),()=>p.removeEventListener("change",b)}},[r]),g.useEffect(()=>{document.documentElement.setAttribute("data-palette",s),localStorage.setItem("meshy-palette",s)},[s]),g.useEffect(()=>{const h=document.documentElement;u===kr?h.removeAttribute("data-layout"):h.setAttribute("data-layout",u),localStorage.setItem("meshy-layout",u)},[u]),g.useEffect(()=>b0(),[r,s,u]),f.jsx(H1.Provider,{value:{theme:r,setTheme:o,palette:s,setPalette:c,layout:u,setLayout:m},children:t})}function d3(){const t=g.useContext(H1);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function P1(t){return t!==null&&t3.has(t)}function f3(t){return t!==null&&n3.has(t)}function m3(t){return P1(t)?t:null}function xm(t){return t===B1?"porcelain":f3(t)?t:null}function h3(t){return t===B1?null:xm(t)}const p3=[{value:"light",label:"Light",icon:my},{value:"dark",label:"Dark",icon:dy},{value:"system",label:"System",icon:uy}],$1=[{value:"finsight",label:"FinSight",hint:"Cool sage green"},{value:"porcelain",label:"Porcelain",hint:"Blue workspace"},{value:"warm",label:"Warm",hint:"Cream + amber"},{value:"edge",label:"Edge",hint:"Rounded violet panels"},{value:"symphony",label:"Symphony",hint:"Near-black rose accent"},{value:"launcher",label:"Launcher",hint:"Desktop startup blue"}],q1=[{value:"airy",label:"Airy",hint:"Gradients, blur, spacious"},{value:"clean",label:"Clean",hint:"Flat, borders, high density"},{value:"fluent",label:"Fluent",hint:"Compact neutral"}];function g3(){const{theme:t,setTheme:r,palette:o,setPalette:s,layout:c,setLayout:u}=d3(),[m,h]=g.useState(null),v=g.useRef(null),p=g.useRef(null),b=z1(m),y=t==="dark"?dy:t==="light"?my:uy,w=()=>{v.current&&(clearTimeout(v.current),v.current=null)},k=()=>{w(),v.current=setTimeout(()=>h(A=>_f(A)),180)};return g.useEffect(()=>{if(!b)return;const A=E=>{p.current&&!p.current.contains(E.target)&&h(null)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[b]),g.useEffect(()=>()=>w(),[]),f.jsxs("div",{ref:p,className:"relative",onMouseEnter:()=>{w(),h(A=>U1(A))},onMouseLeave:k,children:[f.jsx(Ct,{variant:"ghost",size:"icon",onClick:()=>h(A=>L1(A)),className:ae("h-8 w-8 rounded-sm",o!==ac||c!==kr?"text-primary":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),title:"Appearance","aria-haspopup":"menu","aria-expanded":b,children:f.jsx(y,{className:"h-4 w-4"})}),b&&f.jsxs("div",{role:"menu",className:"fixed left-2 right-2 top-[4.25rem] z-50 w-auto max-w-none rounded-md border border-border/70 bg-popover/95 p-2 text-popover-foreground shadow-[0_24px_70px_-32px_rgba(0,0,0,0.45)] backdrop-blur-xl sm:absolute sm:left-auto sm:right-0 sm:top-[calc(100%+6px)] sm:w-[23rem] sm:max-w-[23rem]",children:[f.jsxs("div",{className:"mb-2 flex items-end justify-between gap-2",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Appearance"}),f.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:[v3(c)," / ",y3(o)]})]}),f.jsx("div",{className:"rounded-sm border border-border/60 bg-background/70 px-1.5 py-0.5 text-[8px] font-medium capitalize text-muted-foreground",children:t})]}),f.jsx("div",{className:"px-0.5 pb-1 text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Theme"}),f.jsx("div",{className:"mb-2 grid grid-cols-3 gap-1 rounded-sm bg-muted/35 p-0.5",children:p3.map(({value:A,label:E,icon:N})=>{const T=t===A;return f.jsxs("button",{type:"button",onClick:()=>r(A),role:"menuitemradio","aria-checked":T,className:ae("flex min-h-[2.1rem] flex-col items-center justify-center gap-0.5 rounded-sm border px-1.5 py-1 text-[9px] font-medium transition-colors",T?"border-primary/55 bg-background text-primary shadow-sm":"border-transparent text-muted-foreground hover:border-border/70 hover:bg-background/80 hover:text-foreground"),children:[f.jsx(N,{className:"h-3 w-3"}),E]},A)})}),f.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[f.jsxs("div",{children:[f.jsx("div",{className:"px-0.5 pb-1 text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Layout"}),f.jsx("div",{className:"space-y-1",children:q1.map(({value:A,label:E,hint:N})=>{const T=c===A;return f.jsxs("button",{type:"button",onClick:()=>u(A),role:"menuitemradio","aria-checked":T,className:ae("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",T?"border-primary/55 bg-primary/10":"border-border/45 bg-background/45 hover:border-border hover:bg-muted/55"),children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:ae("text-[10px] font-medium leading-tight",T?"text-primary":"text-foreground"),children:E}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:N})]}),T&&f.jsx(Li,{className:"h-3 w-3 text-primary"})]},A)})})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-1.5 px-0.5 pb-1 text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:[f.jsx(_T,{className:"h-2.5 w-2.5"}),"Palette"]}),f.jsx("div",{className:"space-y-1",children:$1.map(({value:A,label:E,hint:N})=>{const T=o===A;return f.jsxs("button",{type:"button",onClick:()=>s(A),role:"menuitemradio","aria-checked":T,className:ae("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",T?"border-primary/55 bg-primary/10":"border-border/45 bg-background/45 hover:border-border hover:bg-muted/55"),children:[f.jsx(b3,{value:A}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:ae("text-[10px] font-medium leading-tight",T?"text-primary":"text-foreground"),children:E}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:N})]}),T&&f.jsx(Li,{className:"h-3 w-3 text-primary"})]},A)})})]})]})]})]})}function v3(t){return q1.find(r=>r.value===t)?.label??t}function y3(t){return $1.find(r=>r.value===t)?.label??t}function b3({value:t}){const r={porcelain:["hsl(212 76% 44%)","hsl(210 22% 98%)","hsl(174 42% 61%)"],warm:["hsl(35 88% 56%)","hsl(42 22% 97%)","hsl(160 60% 45%)"],finsight:["hsl(152 38% 32%)","hsl(150 14% 97%)","hsl(142 55% 58%)"],edge:["hsl(265 75% 55%)","hsl(260 12% 98%)","hsl(285 70% 65%)"],symphony:["hsl(348 100% 71%)","hsl(0 0% 6%)","hsl(240 2% 9%)"],launcher:["hsl(213 77% 49%)","hsl(60 10% 96%)","hsl(0 0% 100%)"]},[o,s,c]=r[t];return f.jsxs("div",{className:ae("flex h-5 w-5 shrink-0 overflow-hidden border border-border/60 shadow-sm","rounded-sm"),children:[f.jsx("div",{className:"h-full w-1/3",style:{background:o}}),f.jsx("div",{className:"h-full w-1/3",style:{background:s}}),f.jsx("div",{className:"h-full w-1/3",style:{background:c}})]})}const Xl={tasks:{defaultSize:20,min:16,max:36,wheelStep:1},operations:{defaultSize:20,min:18,max:38,wheelStep:1},terminal:{defaultSize:18,min:10,max:30,wheelStep:1}},V1="meshy-dashboard-panel-state-v2",I1="meshy-dashboard-terminal-open-v1";function pM({operationsOpen:t}){return{layout:{desktopTasksOpen:!0,operationsOpen:t},sizes:{tasks:Xl.tasks.defaultSize,operations:Xl.operations.defaultSize,terminal:Xl.terminal.defaultSize}}}function af(t){return typeof t=="object"&&t!==null}function S0(t,r){return typeof t=="boolean"?t:r}function rf(t,r,o){return typeof r=="number"&&Number.isFinite(r)?Ql(t,r):o}function Ql(t,r){const o=Xl[t];return Math.min(o.max,Math.max(o.min,r))}function gM(t,r){if(!t)return r;try{const o=t.getItem(V1);if(!o)return r;const s=JSON.parse(o);if(!af(s))return r;const c=af(s.layout)?s.layout:{},u=af(s.sizes)?s.sizes:{};return{layout:{desktopTasksOpen:S0(c.desktopTasksOpen,r.layout.desktopTasksOpen),operationsOpen:S0(c.operationsOpen,r.layout.operationsOpen)},sizes:{tasks:rf("tasks",u.tasks,r.sizes.tasks),operations:rf("operations",u.operations,r.sizes.operations),terminal:rf("terminal",u.terminal,r.sizes.terminal)}}}catch{return r}}function vM(t,r){if(t)try{t.setItem(V1,JSON.stringify(r))}catch{}}function x3(t,r){if(!t)return r;try{const o=t.getItem(I1);return o==="true"?!0:o==="false"?!1:r}catch{return r}}function S3(t,r){if(t)try{t.setItem(I1,String(r))}catch{}}function w0(){try{return globalThis.window?.localStorage??globalThis.localStorage??null}catch{return null}}function yM(t){return`${Number(t.toFixed(2))}rem`}function bM(t,r,o,s,c,u,m){const h=Number.isFinite(m)&&m>0?m:16;return t==="tasks"?Ql(t,r+(c-o)/h):t==="operations"?Ql(t,r+(o-c)/h):Ql(t,r+(s-u)/h)}function xM(t,r,o){const s=o===0?0:o>0?-1:1;return Ql(t,r+s*Xl[t].wheelStep)}const w3=7200*1e3,E3=15*1e3,N3="meshy://desktop-update-progress",T3="Desktop update check timed out";function C3(){return f.jsxs("svg",{"data-meshy-app-icon":"header",viewBox:"0 0 1024 1024",className:"h-8 w-8","aria-hidden":"true",children:[f.jsxs("defs",{children:[f.jsxs("linearGradient",{id:"meshy-header-icon-bg",x1:"160",y1:"128",x2:"864",y2:"896",gradientUnits:"userSpaceOnUse",children:[f.jsx("stop",{offset:"0",stopColor:"#182033"}),f.jsx("stop",{offset:"1",stopColor:"#0a0f1f"})]}),f.jsxs("linearGradient",{id:"meshy-header-icon-edge",x1:"260",y1:"244",x2:"768",y2:"780",gradientUnits:"userSpaceOnUse",children:[f.jsx("stop",{offset:"0",stopColor:"#66e3ff"}),f.jsx("stop",{offset:"0.52",stopColor:"#8fd56b"}),f.jsx("stop",{offset:"1",stopColor:"#ffcb5b"})]})]}),f.jsx("rect",{width:"1024",height:"1024",rx:"224",fill:"url(#meshy-header-icon-bg)"}),f.jsx("path",{d:"M308 652V372l204 174 204-174v280",fill:"none",stroke:"url(#meshy-header-icon-edge)",strokeWidth:"86",strokeLinecap:"round",strokeLinejoin:"round"}),f.jsx("circle",{cx:"308",cy:"372",r:"58",fill:"#66e3ff"}),f.jsx("circle",{cx:"512",cy:"546",r:"58",fill:"#8fd56b"}),f.jsx("circle",{cx:"716",cy:"372",r:"58",fill:"#ffcb5b"}),f.jsx("circle",{cx:"308",cy:"652",r:"58",fill:"#66e3ff"}),f.jsx("circle",{cx:"716",cy:"652",r:"58",fill:"#ffcb5b"})]})}function Vl(){return typeof window>"u"?null:window.__TAURI__?.core?.invoke??null}function R3(){return typeof window>"u"?null:window.__TAURI__?.event?.listen??null}function A3(t){if(!t||typeof t!="object")return null;const r=t;return r.phase!=="downloading"&&r.phase!=="installing"&&r.phase!=="complete"?null:{phase:r.phase,receivedBytes:typeof r.receivedBytes=="number"?r.receivedBytes:0,totalBytes:typeof r.totalBytes=="number"?r.totalBytes:null,percent:typeof r.percent=="number"?Math.max(0,Math.min(100,Math.round(r.percent))):null}}function E0(t){return{currentVersion:null,latestVersion:null,updateAvailable:!1,checkedAt:new Date().toISOString(),releaseUrl:null,assetName:null,installable:!1,detail:t}}async function k3(t,r,o){let s;const c=new Promise((u,m)=>{s=setTimeout(()=>{m(new Error(T3))},r)});try{return await Promise.race([t,c])}finally{s!==void 0&&clearTimeout(s)}}async function j3({activeCheck:t,startCheck:r,timeoutMs:o,shouldApply:s,applyUpdate:c,applyFailure:u,failureFallback:m="Desktop update check failed"}){let h=t.current;if(!h){let v;try{v=r()}catch(p){v=Promise.reject(p)}h=k3(v,o),t.current=h}try{const v=await h;return s()&&c(v),v}catch(v){return s()&&u(Mf(v,m)),null}finally{t.current===h&&(t.current=null)}}function Mf(t,r){if(t instanceof Error&&t.message.trim())return t.message;if(typeof t=="string"&&t.trim())return t;if(t&&typeof t=="object"&&"message"in t){const o=t.message;if(typeof o=="string"&&o.trim())return o}return r}function _3(t){return t.openedRelease?"Opened the latest Meshy release page.":t.installMethod==="tauri-updater"?"Installing desktop update. Meshy will relaunch to finish updating.":(t.assetName??"desktop update").toLowerCase().endsWith(".dmg")?"Downloaded desktop update. Open the DMG and drag Meshy to Applications to finish updating.":"Downloaded desktop update. Follow the installer to finish updating."}function O3(){const{cluster:t,events:r,sseConnected:o,systemInfo:s}=ay(),c=jn(),[u,m]=g.useState(()=>x3(w0(),!1)),[h,v]=g.useState(""),[p,b]=g.useState(null),[y,w]=g.useState(null),[k,A]=g.useState(!1),[E,N]=g.useState(null),T=g.useRef(null),R=!!Vl(),O=R?"max-w-none":"max-w-[1760px]",H=c.pathname==="/"||/^\/tasks\/[^/]+$/.test(c.pathname),z=g.useMemo(()=>{const W=new Map;for(const te of t?.nodes??[])W.set(te.id,te.name);return t?.self&&W.set(t.self.id,t.self.name),W},[t?.nodes,t?.self]),K=g.useCallback(W=>{m(te=>typeof W=="function"?W(te):W)},[]);g.useEffect(()=>{S3(w0(),u)},[u]);const I=g.useCallback(async(W=!0,te=()=>!0)=>{const se=Vl();return se?(W&&te()&&w(E0("Checking desktop update...")),j3({activeCheck:T,startCheck:()=>se("check_desktop_update"),timeoutMs:E3,shouldApply:te,applyUpdate:X=>w(X),applyFailure:X=>w(_=>_?.updateAvailable?_:E0(X))})):(te()&&w(null),null)},[]);async function P(){A(!0);try{await I(!1)}finally{A(!1)}}g.useEffect(()=>{if(!Vl()){w(null);return}let W=!1;const te=()=>!W;I(!0,te);const se=window.setInterval(()=>{I(!1,te)},w3);return()=>{W=!0,window.clearInterval(se)}},[I,s?.version]),g.useEffect(()=>{const W=R3();if(!W)return;let te=!1,se;return W(N3,X=>{const _=A3(X.payload);_&&N(_)}).then(X=>{if(te){X();return}se=X}).catch(()=>{}),()=>{te=!0,se?.()}},[]);async function le(){try{const W=await ey({reason:"restart"});Ce.info(`Restarting runtime. Follow ${W.logPath} for launch output.`),await _1({previousPid:W.pid})||Ce.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout.")}catch(W){Ce.error(W instanceof Error?W.message:"Runtime restart failed")}}async function de(){const W=Vl();if(!W){Ce.error("Desktop updater is not available in this window");return}try{Ce.info("Downloading desktop update..."),N({phase:"downloading",receivedBytes:0,totalBytes:null,percent:0});const te=await W("install_desktop_update");N({phase:"complete",receivedBytes:1,totalBytes:1,percent:100}),Ce.info(_3(te))}catch(te){Ce.error(Mf(te,"Desktop update failed"))}finally{N(null)}}async function fe(){const W=Vl();if(!W){Ce.error("Desktop restart is not available in this window");return}try{Ce.info("Restarting Meshy Desktop..."),await W("restart_desktop_app")}catch(te){Ce.error(Mf(te,"Desktop restart failed"))}}return f.jsxs("div",{className:"relative h-full overflow-hidden bg-background text-foreground",children:[f.jsx("div",{className:"mesh-grid pointer-events-none absolute inset-0"}),f.jsxs("div",{className:"relative z-10 flex h-full min-h-0 flex-col",children:[f.jsx("header",{className:"dashboard-shell-header relative z-50 shrink-0 px-2 py-2",children:f.jsxs("div",{className:ae("dashboard-shell-header-panel dashboard-panel dashboard-panel-muted animate-panel-settle mx-auto flex items-center gap-0 rounded-lg px-3 py-2",O),children:[f.jsx("div",{className:"flex shrink-0 items-center gap-3 pr-3",children:f.jsxs(sf,{to:"/","aria-label":"Meshy home",className:"flex items-center gap-2",children:[f.jsx(C3,{}),f.jsxs("div",{className:"hidden min-w-0 items-baseline gap-1.5 sm:flex",children:[f.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:"MESHY"}),f.jsx("span",{className:"truncate text-[13px] font-semibold tracking-tight text-foreground",children:"Workspace"})]})]})}),f.jsx("div",{className:"mx-0 hidden h-4 w-px shrink-0 bg-border/50 md:block"}),H&&f.jsxs("div",{className:"hidden min-w-0 flex-1 items-center px-3 md:flex",children:[p&&f.jsxs("nav",{"aria-label":"Current task location",className:"flex min-w-0 max-w-[38rem] items-center gap-1 rounded-sm bg-background/55 px-2 py-1 text-[10px] text-muted-foreground",children:[f.jsxs("button",{type:"button",onClick:()=>v(p.nodeName),className:"flex min-w-0 items-center gap-1 rounded-sm px-1 py-0.5 hover:bg-muted/60 hover:text-foreground",title:`Filter by ${p.nodeName}`,children:[f.jsx(fy,{className:"h-3 w-3 shrink-0 text-primary/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.nodeName})]}),f.jsx(cf,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsxs("button",{type:"button",onClick:()=>v(p.projectLabel),className:"flex min-w-0 items-center gap-1 rounded-sm px-1 py-0.5 hover:bg-muted/60 hover:text-foreground",title:p.projectPath,children:[f.jsx(nT,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.projectLabel})]}),f.jsx(cf,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsx(sf,{to:`/tasks/${p.taskId}`,className:"min-w-0 truncate px-1 font-medium text-foreground/85 hover:text-foreground",title:p.taskTitle,children:p.taskTitle})]}),f.jsxs("div",{className:"relative ml-auto w-[18rem] max-w-[28rem]",children:[f.jsx(NT,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/60"}),f.jsx(xc,{"aria-label":"Search tasks",value:h,onChange:W=>v(W.target.value),placeholder:"Search tasks, nodes, workspaces",className:"h-8 rounded-sm border-0 bg-background/62 pl-8 pr-2 text-[11px] shadow-none focus-visible:ring-0 focus-visible:ring-offset-0"})]})]}),f.jsx("div",{className:"mx-0 hidden h-4 w-px shrink-0 bg-border/50 md:block"}),f.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5 pl-3 sm:gap-2 md:ml-0",children:[H&&f.jsx(Ct,{variant:"ghost",size:"icon",onClick:()=>K(W=>!W),"aria-label":u?"Close terminal":"Open terminal",title:u?"Close terminal":"Open terminal",className:ae("h-8 w-8 rounded-sm text-muted-foreground hover:bg-muted/50 hover:text-foreground",u&&"bg-primary/8 text-primary"),children:f.jsx(hy,{className:"h-4 w-4"})}),f.jsx(O_,{}),f.jsx(g3,{}),f.jsx("div",{className:"mx-0 h-4 w-px shrink-0 bg-border/50"}),f.jsx(K_,{connected:o,events:r,nodes:t?.nodes??[],currentNode:t?.self??null,nodeNameById:z,desktopUpdate:y,desktopUpdateCheckPending:k,desktopUpdateProgress:E,onDesktopUpdateCheck:R?P:void 0,onDesktopUpdate:y?.updateAvailable?de:void 0,onDesktopRestart:R?fe:void 0,onReload:R?()=>window.location.reload():void 0,onRestart:le})]})]})}),f.jsx("main",{className:ae("dashboard-shell-main min-h-0 flex-1 px-2 pb-2",H?"overflow-hidden":"overflow-y-auto"),children:f.jsx("div",{className:ae("dashboard-shell-content mx-auto h-full min-h-0",O),children:f.jsx(cE,{context:{terminalOpen:u,setTerminalOpen:K,headerSearchQuery:h,setHeaderSearchQuery:v,setHeaderTaskContext:b}})})})]})]})}const N0=g.lazy(async()=>({default:(await R0(()=>import("./DashboardPage-BA5_31Nu.js").then(r=>r.D),__vite__mapDeps([0,1,2,3,4]))).DashboardPage})),M3=g.lazy(async()=>({default:(await R0(()=>import("./SharedConversationPage-hiwRfWZA.js"),__vite__mapDeps([5,1]))).SharedConversationPage}));function D3(){return f.jsx(zE,{children:f.jsx(g.Suspense,{fallback:f.jsx(z3,{}),children:f.jsxs(dE,{children:[f.jsx(Nr,{path:"/shared/tasks/:shareId",element:f.jsx(M3,{})}),f.jsxs(Nr,{element:f.jsx(AN,{children:f.jsx(O3,{})}),children:[f.jsx(Nr,{path:"/",element:f.jsx(N0,{})}),f.jsx(Nr,{path:"/nodes",element:f.jsx(Ev,{to:"/",replace:!0})}),f.jsx(Nr,{path:"/tasks",element:f.jsx(Ev,{to:"/",replace:!0})}),f.jsx(Nr,{path:"/tasks/:id",element:f.jsx(N0,{})})]})]})})})}function z3(){return f.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading workspace..."})}function U3(t){const r=t??(typeof window>"u"?void 0:window);r?.__TAURI__&&r.addEventListener("contextmenu",o=>{o.preventDefault()})}function L3(t){const{className:r,style:o,toastOptions:s,...c}=t;function u(m){const h=m.target;if(!(h instanceof Element)||h.closest("button, a, input, textarea, select, [data-close-button], [data-button]"))return;const v=h.closest("[data-sonner-toast]");v&&v.dataset.type!=="loading"&&M1()}return f.jsx("div",{onClick:u,children:f.jsx(eR,{className:["toaster group",r].filter(Boolean).join(" "),closeButton:!0,gap:6,offset:{right:"0.6rem",bottom:"0.6rem"},mobileOffset:{right:"0.5rem",bottom:"0.5rem",left:"0.5rem"},position:"bottom-right",visibleToasts:3,style:{"--normal-bg":"hsl(var(--popover))","--normal-text":"hsl(var(--popover-foreground))","--normal-border":"hsl(var(--border) / 0.7)","--width":"17rem",...o},toastOptions:{duration:3e3,closeButton:!0,...s,classNames:{toast:"meshy-toast",title:"meshy-toast__title",description:"meshy-toast__description",content:"meshy-toast__content",icon:"meshy-toast__icon",closeButton:"meshy-toast__close",actionButton:"meshy-toast__action",cancelButton:"meshy-toast__cancel",success:"meshy-toast--success",error:"meshy-toast--error",info:"meshy-toast--info",warning:"meshy-toast--warning",...s?.classNames}},...c})})}U3();i2.createRoot(document.getElementById("root")).render(f.jsx(g.StrictMode,{children:f.jsxs(u3,{children:[f.jsx(D3,{}),f.jsx(L3,{})]})}));export{qO as $,Af as A,Ct as B,Li as C,IO as D,fO as E,eT as F,$A as G,pb as H,xc as I,vb as J,hM as K,iy as L,ly as M,y1 as N,Qx as O,hT as P,fM as Q,cy as R,fy as S,YO as T,Yl as U,IN as V,Rj as W,py as X,GO as Y,Yf as Z,nj as _,uM as a,uO as a$,VO as a0,_t as a1,lM as a2,Gl as a3,Cf as a4,Qi as a5,Ki as a6,Fi as a7,Wi as a8,Zi as a9,B_ as aA,vj as aB,sy as aC,yj as aD,sM as aE,Nj as aF,MO as aG,fR as aH,KO as aI,iM as aJ,cM as aK,XO as aL,QO as aM,rM as aN,A1 as aO,oM as aP,Rf as aQ,zT as aR,SO as aS,wO as aT,gM as aU,pM as aV,w0 as aW,vM as aX,xM as aY,yM as aZ,bM as a_,ec as aa,Ji as ab,R0 as ac,q3 as ad,gb as ae,IA as af,aO as ag,hy as ah,Ro as ai,uf as aj,nO as ak,rO as al,tO as am,zO as an,I3 as ao,Y3 as ap,qA as aq,yb as ar,Ai as as,LT as at,RT as au,LN as av,uT as aw,ts as ax,nM as ay,yT as az,oR as b,SN as b0,nN as b1,LO as b2,UO as b3,BO as b4,NN as b5,yO as b6,Q3 as b7,G3 as b8,J0 as b9,Tj as bA,gO as bB,vO as bC,pO as bD,hO as bE,$3 as bF,V3 as bG,P3 as bH,Z3 as bI,$O as bJ,RO as bK,CO as bL,TO as bM,EO as bN,NO as bO,AO as bP,g1 as bQ,Pk as bR,PO as bS,Hk as bT,T0 as bU,_O as bV,jO as bW,kO as bX,OO as bY,HO as bZ,DO as b_,X3 as ba,K3 as bb,O_ as bc,bO as bd,xO as be,iO as bf,oO as bg,lO as bh,sO as bi,cO as bj,H3 as bk,jn as bl,V0 as bm,B3 as bn,ay as bo,aM as bp,Gj as bq,mM as br,tM as bs,ZO as bt,FO as bu,JO as bv,WO as bw,eM as bx,dO as by,Ej as bz,ke as c,ae as d,Oy as e,x1 as f,W3 as g,eO as h,W0 as i,f as j,F3 as k,nT as l,dM as m,cf as n,ua as o,J3 as p,mO as q,g as r,Ef as s,Ce as t,Gi as u,Nf as v,Xi as w,NT as x,Zl as y,_T as z};
346
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return g.useEffect(()=>{document.getElementById(t.current?.getAttribute("aria-describedby"))||console.warn(r)},[r,t]),null},fj=Zx,mj=Fx,hj=Wx,i1=Jx,c1=e1,u1=o1,d1=s1,f1=n1,m1=r1;const Cf=fj,Rf=mj,pj=hj,h1=g.forwardRef(({className:t,...r},o)=>f.jsx(i1,{className:ae("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...r,ref:o}));h1.displayName=i1.displayName;const Qi=g.forwardRef(({className:t,...r},o)=>f.jsxs(pj,{children:[f.jsx(h1,{}),f.jsx(c1,{ref:o,className:ae("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-3 rounded-sm border bg-background p-4 shadow-[0_24px_84px_-54px_rgba(0,0,0,0.55)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",t),...r})]}));Qi.displayName=c1.displayName;const Ki=({className:t,...r})=>f.jsx("div",{className:ae("flex flex-col space-y-1.5 text-center sm:text-left",t),...r});Ki.displayName="AlertDialogHeader";const Zi=({className:t,...r})=>f.jsx("div",{className:ae("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...r});Zi.displayName="AlertDialogFooter";const Fi=g.forwardRef(({className:t,...r},o)=>f.jsx(f1,{ref:o,className:ae("text-sm font-semibold",t),...r}));Fi.displayName=f1.displayName;const Wi=g.forwardRef(({className:t,...r},o)=>f.jsx(m1,{ref:o,className:ae("text-[11px] text-muted-foreground",t),...r}));Wi.displayName=m1.displayName;const Ji=g.forwardRef(({className:t,...r},o)=>f.jsx(u1,{ref:o,className:ae(Kf(),t),...r}));Ji.displayName=u1.displayName;const ec=g.forwardRef(({className:t,...r},o)=>f.jsx(d1,{ref:o,className:ae(Kf({variant:"outline"}),"mt-2 sm:mt-0",t),...r}));ec.displayName=d1.displayName;const gj={online:"bg-emerald-500",busy:"bg-amber-500",offline:"bg-destructive"};function vj({status:t}){return f.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5",children:[t==="online"&&f.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-500 opacity-30"}),f.jsx("span",{className:ae("relative inline-flex h-2.5 w-2.5 rounded-full",gj[t])})]})}function yj({role:t,size:r="default"}){return f.jsx(_t,{variant:t==="leader"?"default":"secondary",className:ae(r==="compact"?"px-1.5 py-0 text-[9px] leading-4":"text-[11px]"),children:t})}const p1={pending:{variant:"secondary",dotClass:"bg-muted-foreground",className:"border-transparent bg-muted/55 text-muted-foreground"},assigned:{variant:"outline",dotClass:"bg-teal-500",className:"border-teal-500/20 bg-teal-500/8 text-teal-700 dark:text-teal-300"},running:{variant:"outline",dotClass:"bg-amber-500",className:"border-amber-500/22 bg-amber-500/9 text-amber-700 dark:text-amber-300"},completed:{variant:"outline",dotClass:"bg-emerald-500",className:"border-emerald-500/18 bg-emerald-500/8 text-emerald-700 dark:text-emerald-300"},failed:{variant:"destructive",dotClass:"bg-destructive-foreground",className:"border-destructive/20 bg-destructive/90 text-destructive-foreground"},cancelled:{variant:"secondary",dotClass:"bg-muted-foreground",className:"border-transparent bg-muted/55 text-muted-foreground"},archived:{variant:"secondary",dotClass:"bg-slate-400",className:"border-transparent bg-muted/50 text-muted-foreground"}};function $O({status:t,size:r="default"}){const o=p1[t],s=r==="compact"?"gap-0.5 px-1 py-0 text-[8px] leading-3 [&>span]:h-[3px] [&>span]:w-[3px]":"gap-1 px-1.5 py-0 text-[10px] leading-4 [&>span]:h-[5px] [&>span]:w-[5px]";return f.jsxs(_t,{variant:o.variant,className:ae("rounded-sm font-medium shadow-none",s,o.className),children:[f.jsx("span",{className:ae("rounded-full",o.dotClass)}),t]})}function qO({status:t,isNative:r=!1,size:o="default",className:s}){const c=p1[t],u=[t,r?"native":null].filter(Boolean).join(", "),m=o==="compact"?"h-1.5 w-1.5":"h-2 w-2";return f.jsxs("span",{className:ae("inline-flex shrink-0 items-center gap-1",s),title:u,"aria-label":u,children:[f.jsx("span",{className:ae("rounded-full",m,c.dotClass),title:t}),r&&f.jsx("span",{className:ae("rounded-full bg-sky-500",m),title:"native"})]})}const bj={critical:{variant:"destructive",label:"Critical"},high:{variant:"outline",label:"High"},normal:{variant:"secondary",label:"Normal"},low:{variant:"secondary",label:"Low"}};function VO({priority:t}){const r=bj[t];return f.jsx(_t,{variant:r.variant,className:"rounded-sm px-1.5 py-0 text-[10px] leading-4 shadow-none",children:r.label})}function xj(t){return[{key:"workspace",label:"Workspace",value:t?.workspace},{key:"node",label:"Node app",value:t?.node},{key:"core",label:"Core",value:t?.core},{key:"dashboard",label:"Dashboard",value:t?.dashboard},{key:"api",label:"API",value:t?.api}].filter(o=>o.value)}function Eo({label:t,value:r,mono:o=!1}){return f.jsxs("div",{className:"min-w-0 rounded-sm border border-border/60 bg-background/65 px-2.5 py-1.5",children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:t}),f.jsx("div",{className:o?"mt-0.5 break-all font-mono text-[11px] text-foreground":"mt-0.5 break-all text-[11px] text-foreground",children:r})]})}function Sj({formatDateTime:t,viewInfo:r}){const o=xj(r.packages);return f.jsxs(Gl,{value:"about","data-about-layout":"compact",className:"mt-0 space-y-2",children:[f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(LN,{className:"h-3.5 w-3.5 text-primary"}),"Repository & runtime"]}),f.jsx(Nn,{className:"text-[10px]",children:"Build source and runtime identity for this node."})]}),f.jsxs(Tn,{className:"space-y-2 px-3 pb-2.5",children:[r.repository?.url?f.jsxs("a",{href:r.repository.url,target:"_blank",rel:"noreferrer",className:"group flex min-w-0 items-center justify-between gap-2 rounded-sm border border-border/70 bg-background/70 px-2.5 py-1.5 text-[11px] text-foreground transition-colors hover:border-primary/40 hover:bg-primary/5",children:[f.jsx("span",{className:"truncate font-mono text-[10px]",children:r.repository.url}),f.jsx(sy,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform group-hover:-translate-y-0.5 group-hover:translate-x-0.5"})]}):f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-2.5 py-1.5 text-[11px] text-muted-foreground",children:"Repository URL is unavailable in this runtime."}),f.jsxs("div",{className:"grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3",children:[f.jsx(Eo,{label:"Branch",value:r.repository?.branch??"Unavailable",mono:!!r.repository?.branch}),f.jsx(Eo,{label:"Commit",value:r.repository?.commit??"Unavailable",mono:!!r.repository?.commit}),f.jsx(Eo,{label:"Runtime",value:`${r.packageName??"meshy"} ${r.version}`,mono:!0}),f.jsx(Eo,{label:"Node.js",value:r.runtime?.nodeVersion??"Unavailable",mono:!!r.runtime?.nodeVersion}),f.jsx(Eo,{label:"PID",value:r.runtime?String(r.runtime.pid):"Unavailable",mono:!!r.runtime}),f.jsx(Eo,{label:"Started",value:t(r.runtime?.startedAt)})]})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(rT,{className:"h-3.5 w-3.5 text-primary"}),"Package versions"]}),f.jsx(Nn,{className:"text-[10px]",children:"Version snapshot for the packages most relevant to this dashboard session."})]}),f.jsx(Tn,{"data-package-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:o.map(s=>f.jsxs("div",{className:"grid gap-1.5 rounded-sm border border-border/60 bg-background/65 px-2.5 py-1.5 sm:grid-cols-[9rem_minmax(0,1fr)_auto] sm:items-center",children:[f.jsx("div",{className:"text-[11px] font-medium text-foreground",children:s.label}),f.jsx("div",{className:"min-w-0 truncate text-[10px] text-muted-foreground",children:s.value?.name}),f.jsx(_t,{variant:"outline",className:"w-fit rounded-sm border-border/70 bg-background/60 font-mono text-[10px]",children:s.value?.version})]},s.key))})]})]})}const wj="codex",IO="bypass",g1=[{value:"codex",label:"Codex",supportsFollowUp:!0},{value:"claudecode",label:"Claude Code",supportsFollowUp:!0},{value:"copilot",label:"Copilot",supportsFollowUp:!0},{value:"mars",label:"mars",disabled:!0,description:"coming soon"},{value:"eureka",label:"eureka",disabled:!0,description:"coming soon"}],v1=g1.filter(t=>t.value==="codex"||t.value==="claudecode"||t.value==="copilot");function Af(t){return v1.some(r=>r.value===t)?t:wj}const YO=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],Ej=new Set(g1.filter(t=>t.supportsFollowUp).map(t=>t.value));function GO(t){const r=s=>typeof s=="string"&&Ej.has(s),o=(t.nodeSupportedAgents??[]).filter(r);return o.length>0?Array.from(new Set(o)):Array.from(new Set([t.taskAgent,t.activeAgent].filter(r)))}const XO=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"shared",label:"Shared"},{value:"archived",label:"Archived"}],QO=[{value:"all",label:"All task types"},{value:"native",label:"Native sessions"},{value:"meshy",label:"Meshy chats"}],Nj=new Set(["pending","assigned"]),Tj=new Set(["running"]),Cj=new Set(["completed","failed","cancelled"]),KO=10;function ZO(t,r){switch(r){case"running":return Tj.has(t.status);case"waiting":return Nj.has(t.status);case"closed":return Cj.has(t.status);case"shared":return!!t.activeShare;case"archived":return t.status==="archived";default:return t.status!=="archived"}}function FO(t,r){if(r==="all")return!0;const o=t.conversationKind==="nativeSession";return r==="native"?o:!o}function WO(t,r){const o=r.trim().toLowerCase();return o?[t.title,t.description,t.id,t.agent,t.assignedTo??"",t.assignedNodeName??"",t.project??"",t.effectiveProjectPath??"",t.conversationKind==="nativeSession"?"native session":"meshy chat",t.activeShare?"shared conversation":""].some(s=>s.toLowerCase().includes(o)):!0}function Rj(t,r,o){return t?r?.find(c=>c.id===t)?.name??o??t.slice(0,8):"unassigned"}function JO(t,r,o){return Rj(t,r,o).toLowerCase()}function eM(t){return t.type!=="node.status"&&t.type!=="cluster.state"}function tM(t,r,o){return!t.assignedTo||o?.id===t.assignedTo?!0:r?.some(s=>s.id===t.assignedTo)??!1}function nM(t,r){return[...t].sort((o,s)=>o.id===r?-1:s.id===r?1:o.name.localeCompare(s.name))}function aM(t){if(!t||typeof t!="object")return null;const r=t,o=r.createMode,s=o==="chat"||o==="native"?o:void 0,c=r.createDefaults,u=c&&typeof c=="object"&&!Array.isArray(c)?c:null,m=u?{assignTo:typeof u.assignTo=="string"||u.assignTo===null?u.assignTo:void 0,project:typeof u.project=="string"||u.project===null?u.project:void 0}:void 0;return{draftNewTask:r.draftNewTask===!0,returnRoute:typeof r.returnRoute=="string"?r.returnRoute:void 0,returnTaskId:typeof r.returnTaskId=="string"||r.returnTaskId===null?r.returnTaskId:void 0,createMode:s,createDefaults:m}}function rM(t){return t==="default workspace"?t:t.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??t}function oM(t){const r=Date.now()-t;return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m`:r<864e5?`${Math.floor(r/36e5)}h`:`${Math.floor(r/864e5)}d`}function lM(t){return new Date(t).toLocaleString()}function sM(t){const r=Math.floor(t/1e3),o=Math.floor(r/3600),s=Math.floor(r%3600/60),c=r%60;return`${String(o).padStart(2,"0")}:${String(s).padStart(2,"0")}:${String(c).padStart(2,"0")}`}async function y1(t,r="Copied to clipboard"){try{if(globalThis.navigator?.clipboard?.writeText)return await globalThis.navigator.clipboard.writeText(t),Ce.success(r),!0;const o=globalThis.document,s=o?.execCommand?.bind(o);if(!o?.body||typeof o.createElement!="function"||typeof s!="function")throw new Error("Clipboard access is unavailable");const c=o.createElement("textarea"),u=o.activeElement,m=u&&typeof u.focus=="function"?u:null;c.value=t,c.setAttribute("readonly","true"),c.style.position="fixed",c.style.opacity="0",c.style.pointerEvents="none",o.body.appendChild(c),c.select(),c.setSelectionRange(0,c.value.length);const h=s("copy");if(o.body.removeChild(c),m?.focus(),!h)throw new Error("Clipboard access is unavailable");return Ce.success(r),!0}catch(o){return Ce.error(o instanceof Error?o.message:"Failed to copy"),!1}}const Aj="default workspace";function Oi(t){const r=t.replace(/\\/g,"/");return r==="/"||/^[A-Za-z]:\/$/.test(r)?r:r.replace(/\/+$/g,"")||r}function kj(t){const r=t.replace(/\\/g,"/");return r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r)}function jj(t,r){const o=Oi(t),s=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!s||s==="."?o:o==="/"||/^[A-Za-z]:\/$/.test(o)?`${o}${s}`:`${o}/${s}`}function _j(t,r){const o=t.effectiveProjectPath?.trim();if(o)return Oi(o);const s=t.project?.trim();if(!s)return Aj;if(kj(s)||!t.assignedTo)return Oi(s);const c=r?.get(t.assignedTo)?.trim();return c?jj(c,s):Oi(s)}function iM({nodeStatusById:t,nodeNameById:r,nodeFilter:o,searchQuery:s,nodeWorkDirById:c}){const u=o.trim().toLowerCase(),m=s.trim().toLowerCase(),h=[];for(const[v,p]of t){if(p==="offline"||u==="unassigned")continue;const b=r.get(v)??v.slice(0,8);if(!(u&&u!=="all"&&b.toLowerCase()!==u)){if(m){const y=c?.get(v)??"";if(![v,b,y].some(k=>k.toLowerCase().includes(m)))continue}h.push(v)}}return h}function cM(t,r,o,s,c){const u=new Map;for(const h of t){const v=h.assignedTo??null,p=v??"__unassigned__",b=v?r.get(v)??h.assignedNodeName??v.slice(0,8):"Unassigned",y=_j(h,s);u.has(p)||u.set(p,{nodeId:v,nodeName:b,dirMap:new Map});const w=u.get(p);w.dirMap.has(y)||w.dirMap.set(y,[]),w.dirMap.get(y).push(h)}for(const h of c??[])u.has(h)||u.set(h,{nodeId:h,nodeName:r.get(h)??h.slice(0,8),dirMap:new Map});const m=Array.from(u.values()).map(({nodeId:h,nodeName:v,dirMap:p})=>{const b=Array.from(p.entries()).map(([y,w])=>({path:y,tasks:w})).sort((y,w)=>w.tasks.length-y.tasks.length||y.path.localeCompare(w.path));return{nodeId:h,nodeName:v,dirs:b}});return m.sort((h,v)=>{if(o){if(h.nodeId===o)return-1;if(v.nodeId===o)return 1}return h.nodeId===null?1:v.nodeId===null?-1:h.nodeName.localeCompare(v.nodeName)}),m}const Oj=["queued","running"],Mj=["copilot.tunnel","copilot.tunnel.disable"],Dj=1e4;function d0(t){return t?.status==="succeeded"||t?.status==="failed"}function zj(t){return t.reduce((r,o)=>!r||o.updatedAt>r.updatedAt?o:r,null)}async function Uj(t,r=J0){const o=await Promise.all(Mj.flatMap(s=>Oj.map(c=>r({kind:s,status:c,nodeId:t}))));return zj(o.flat())}function f0(t){return t?.split(/\r?\n/).map(r=>r.trim()).filter(Boolean).at(-1)??null}function Lj(t,r){return[t,...r].join(" ")}function Bj(t,r,o){return r&&!t?"Checking port 8314":t?t.status==="queued"?"Queued":t.status==="running"?t.kind==="copilot.tunnel.disable"?"Stopping Meshy-managed tunnel":t.kind==="copilot.tunnel"?t.result?.status==="auth-required"?"Waiting for GitHub device authorization":"Starting Copilot tunnel":"Checking port 8314":t.status==="succeeded"?t.result?.available?t.result.status==="already-running"?"Port 8314 is already reachable":"Proxy is listening on 8314":t.result?.status==="stopped"?"Meshy-managed tunnel stopped":"Port 8314 is not listening":o??"Tunnel operation failed":"Port 8314 status has not been checked"}function Hj(t,r){return r||t?.status==="queued"||t?.status==="running"?f.jsx(iy,{className:"h-3.5 w-3.5 animate-spin text-primary"}):t?.result?.available?f.jsx(Ro,{className:"h-3.5 w-3.5 text-emerald-500"}):t?.status==="failed"?f.jsx(uf,{className:"h-3.5 w-3.5 text-destructive"}):f.jsx(uf,{className:"h-3.5 w-3.5 text-muted-foreground"})}function Pj({checked:t,disabled:r,onCheckedChange:o}){return f.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":"Toggle GitHub Copilot Tunnel",title:t?"Disable GitHub Copilot Tunnel":"Enable GitHub Copilot Tunnel","data-copilot-tunnel-switch":"true",disabled:r,onClick:()=>o(!t),className:ae("relative h-5 w-9 shrink-0 rounded-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t?"bg-primary/85":"bg-muted"),children:f.jsx("span",{className:ae("absolute left-0.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 rounded-sm bg-background shadow-sm transition-transform",t?"translate-x-4":"translate-x-0")})})}function $j({nodeId:t,nodeName:r}){const[o,s]=g.useState(null),[c,u]=g.useState(!1),[m,h]=g.useState(!1),v=o?.status==="queued"||o?.status==="running",p=o?.result,b=p?.auth??null,y=o?.error??p?.detail??f0(p?.stderr)??f0(p?.stdout),w=p?Lj(p.command,p.args):"npx -y ghc-tunnel@latest -d",k=!!p?.available||v&&o?.kind==="copilot.tunnel",A=c||m||v,E=g.useMemo(()=>Bj(o,c,y),[c,y,o]);g.useEffect(()=>{let T=!1;async function R(){u(!0);try{const O=await Uj(t);if(T)return;if(O){s(O);return}const H=await Tv(t);T||s(H)}catch(O){T||Ce.error(O instanceof Error?O.message:"Failed to check Copilot tunnel")}finally{T||u(!1)}}return s(null),R(),()=>{T=!0}},[t]),g.useEffect(()=>{if(!o||d0(o))return;let T=!1;const R=o.id;async function O(){try{const z=await W0(R);if(T)return;if(z.kind==="copilot.tunnel.status"&&!d0(z)&&Date.now()-z.createdAt>Dj){const K=await Tv(t);T||s(K);return}s(z),z.status==="succeeded"&&z.kind==="copilot.tunnel"&&Ce.success(`Copilot tunnel is available on ${r}`),z.status==="succeeded"&&z.kind==="copilot.tunnel.disable"&&Ce.success(`Copilot tunnel stopped on ${r}`),z.status==="failed"&&z.kind!=="copilot.tunnel.status"&&Ce.error(z.error??"Copilot tunnel failed")}catch(z){T||Ce.error(z instanceof Error?z.message:"Failed to refresh Copilot tunnel")}}O();const H=window.setInterval(O,2e3);return()=>{T=!0,window.clearInterval(H)}},[t,r,o?.id,o?.status]);const N=g.useCallback(async T=>{h(!0);try{const R=T?await XE(t):await QE(t);s(R),Ce.info(T?`Copilot tunnel enable requested on ${r}`:`Copilot tunnel stop requested on ${r}`)}catch(R){Ce.error(R instanceof Error?R.message:"Failed to update Copilot tunnel")}finally{h(!1)}},[t,r]);return f.jsxs(Sn,{"data-copilot-tunnel-section":"true",className:"rounded-sm border-border/70 bg-background/75 shadow-none xl:col-span-2",children:[f.jsx(wn,{className:"pb-1.5 pt-2.5 px-3",children:f.jsxs("div",{className:"flex items-start justify-between gap-3",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(oy,{className:"h-3.5 w-3.5 text-primary"}),"GitHub Copilot Tunnel"]}),f.jsx(Nn,{className:"text-[10px]",children:"Node-local Copilot proxy model provider."})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[f.jsx("span",{"aria-label":E,title:E,className:"inline-flex h-5 w-5 items-center justify-center",children:Hj(o,c)}),f.jsx(Pj,{checked:k,disabled:A,onCheckedChange:T=>{N(T)}})]})]})}),f.jsxs(Tn,{className:"space-y-2 px-3 pb-2.5",children:[f.jsxs("div",{className:"space-y-1.5 rounded-sm bg-background/55 px-2.5 py-2",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[f.jsx("span",{className:ae("h-1.5 w-1.5 rounded-sm",p?.available?"bg-emerald-500":v||c?"animate-pulse bg-amber-500":o?.status==="failed"?"bg-destructive":"bg-muted-foreground/50")}),E]}),f.jsx("div",{className:"truncate font-mono text-[10px] text-muted-foreground",children:w}),(v||c||m)&&f.jsx("div",{className:"h-0.5 overflow-hidden rounded-sm bg-muted",children:f.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})})]}),b&&v&&f.jsxs("div",{className:"grid gap-2 rounded-sm border border-primary/35 bg-primary/8 px-2.5 py-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",children:[f.jsxs("div",{className:"min-w-0 space-y-1",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[f.jsx(lT,{className:"h-3.5 w-3.5 animate-pulse text-primary"}),"GitHub device login"]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:[f.jsx("span",{className:"font-mono text-[11px] text-foreground",children:b.code}),b.expiresInSeconds?f.jsxs("span",{children:[Math.ceil(b.expiresInSeconds/60),"m expiry"]}):null]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Ct,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7 rounded-sm",title:"Copy device code","aria-label":"Copy device code",onClick:()=>{y1(b.code,"Device code copied")},children:f.jsx(ly,{className:"h-3.5 w-3.5"})}),f.jsx(Ct,{asChild:!0,variant:"outline",size:"icon",className:"h-7 w-7 rounded-sm",title:"Open GitHub device login","aria-label":"Open GitHub device login",children:f.jsx("a",{href:b.url,target:"_blank",rel:"noreferrer",children:f.jsx(sy,{className:"h-3.5 w-3.5"})})})]})]}),y&&o?.status!=="succeeded"&&f.jsx("div",{className:"rounded-sm border border-border/60 bg-muted/35 px-2 py-1 text-[10px] text-muted-foreground",children:y})]})]})}function qj({value:t,disabled:r=!1,saving:o=!1,onChange:s}){const c=Af(t);return f.jsxs("div",{"data-default-task-agent-selector":"true",className:"flex shrink-0 flex-col gap-1 sm:items-end",children:[f.jsxs("div",{className:"flex items-center gap-1 text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:[f.jsx(Yf,{className:"h-3 w-3"}),"Default agent"]}),f.jsx("div",{className:"flex h-7 items-center gap-0.5 rounded-sm border border-border/60 bg-background/60 p-0.5",children:v1.map(u=>{const m=u.value===c;return f.jsx("button",{type:"button","data-default-task-agent-option":u.value,"aria-pressed":m,disabled:r||o,onClick:()=>s(u.value),className:ae("h-6 rounded-sm border border-transparent px-2 text-[10px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",m?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:u.label},u.value)})})]})}const xc=g.forwardRef(({className:t,type:r,...o},s)=>f.jsx("input",{type:r,className:ae("flex h-8 w-full rounded-sm border border-input/85 bg-background/72 px-2.5 py-1.5 text-[11px] shadow-sm ring-offset-background transition-all duration-200 file:border-0 file:bg-transparent file:text-[11px] file:font-medium file:text-foreground placeholder:text-muted-foreground/75 focus-visible:border-primary/45 focus-visible:bg-background/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/45 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...o}));xc.displayName="Input";function Vj(){return ve("/system/quick-chats")}function Ij(t){return ve("/system/quick-chats",{method:"PUT",body:JSON.stringify({quickChats:t})})}const kf="quick-chats:updated";function Yj(){typeof window>"u"||window.dispatchEvent(new CustomEvent(kf))}function Gj(){const[t,r]=g.useState([]),[o,s]=g.useState(!0),[c,u]=g.useState(!1),[m,h]=g.useState(null),v=g.useCallback(async()=>{s(!0);try{const b=await Vj();r(b.quickChats),h(null)}catch(b){h(b instanceof Error?b.message:"Failed to load quick chats")}finally{s(!1)}},[]),p=g.useCallback(async b=>{u(!0);try{const y=await Ij(b);return r(y.quickChats),h(null),Yj(),y.quickChats}catch(y){const w=y instanceof Error?y.message:"Failed to save quick chats";throw h(w),y}finally{u(!1)}},[]);return g.useEffect(()=>{v()},[v]),g.useEffect(()=>{if(typeof window>"u")return;const b=()=>{v()};return window.addEventListener(kf,b),()=>window.removeEventListener(kf,b)},[v]),{error:m,loading:o,quickChats:t,refresh:v,save:p,saving:c}}function b1(t){return t.trim().replace(/^\/+/,"").toLowerCase()}function x1(t,r){const o=t.trim();if(!o.startsWith("/"))return[];const s=b1(o);return r.filter(c=>c.alias.startsWith(s))}function tc(t,r){return r<=0?-1:(t%r+r)%r}function uM(t,r,o=0){const s=x1(t,r),c=tc(o,s.length);return c>=0?s[c]??null:null}function dM(t,r,o){const s=tc(t,r);return s<0?0:tc(s+o,r)}function fM({query:t,quickChats:r,selectedIndex:o=0,onSelect:s,onActiveIndexChange:c}){const u=x1(t,r);if(u.length===0)return null;const m=tc(o,u.length);return f.jsxs("div",{"data-quick-chat-menu":"true",className:"mx-2 mb-0.5 rounded-sm bg-background/70 p-0.5 shadow-none sm:mx-5",children:[f.jsxs("div",{className:"flex items-center gap-1 px-1 py-0.5 text-[8px] uppercase tracking-[0.14em] text-muted-foreground/75",children:[f.jsx(cy,{className:"h-2.5 w-2.5 text-primary/55"}),"Quick chats"]}),f.jsx("div",{className:"max-h-24 overflow-y-auto",role:"listbox","aria-label":"Quick chats",children:u.map((h,v)=>f.jsxs("button",{type:"button",role:"option","aria-selected":v===m,"data-selected":v===m?"true":void 0,onMouseEnter:()=>c?.(v),onClick:()=>s(h),className:ae("flex w-full min-w-0 items-start gap-1.5 rounded-sm px-1 py-1 text-left text-[9px] transition-colors hover:bg-muted/50 hover:text-foreground"),children:[f.jsxs("span",{"data-quick-chat-alias":"true",className:ae("shrink-0 font-mono text-[9px] leading-3 text-primary/70",v===m&&"text-primary"),children:["/",h.alias]}),f.jsx("span",{"data-quick-chat-prompt":"true",className:ae("line-clamp-1 min-w-0 text-[9px] leading-3 text-muted-foreground",v===m&&"text-primary/90"),children:h.prompt})]},h.alias))})]})}const Xj="h-14 w-full resize-none rounded-sm border border-border/70 bg-background/80 px-2 py-1.5 text-[11px] leading-4 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";let Qj=0;function Mi(t,r=0){return{id:t?`${t.alias}:${r}`:`new:${Qj++}`,alias:t?.alias??"",prompt:t?.prompt??""}}function jf(t){return{quickChats:t.map(r=>({alias:b1(r.alias),prompt:r.prompt.trim()})).filter(r=>r.alias.length>0&&r.prompt.length>0)}}function Kj(t,r){const o=jf(t).quickChats,s=r.map((u,m)=>Mi(u,m)),c=jf(s).quickChats;return JSON.stringify(o)!==JSON.stringify(c)}function Zj(){const{error:t,loading:r,quickChats:o,save:s,saving:c}=Gj(),[u,m]=g.useState(()=>o.map((y,w)=>Mi(y,w))),h=u.length>0,v=g.useMemo(()=>jf(u),[u]),p=g.useMemo(()=>Kj(u,o),[u,o]);g.useEffect(()=>{m(o.map((y,w)=>Mi(y,w)))},[o]);async function b(){try{await s(v.quickChats),Ce.success("Quick chats saved")}catch(y){Ce.error(y instanceof Error?y.message:"Failed to save quick chats")}}return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"rounded-sm border border-border/70 bg-background/75 px-3 py-2.5",children:f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[f.jsx(cy,{className:"h-3.5 w-3.5 text-primary"}),"Quick chats"]}),f.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:"Reusable slash aliases for chat composers on this leader."})]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsxs(Ct,{type:"button",variant:"outline",onClick:()=>m(y=>[...y,Mi(void 0,y.length)]),className:"h-7 rounded-sm px-2 text-[10px]",children:[f.jsx(hT,{className:"h-3.5 w-3.5"}),"Add"]}),f.jsxs(Ct,{type:"button",onClick:b,disabled:c||!p,className:"h-7 rounded-sm px-2 text-[10px]",children:[c?f.jsx(iy,{className:"h-3.5 w-3.5 animate-spin"}):f.jsx(wT,{className:"h-3.5 w-3.5"}),"Save"]})]})]})}),r&&!h?f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-4 text-[11px] text-muted-foreground",children:"Loading quick chats..."}):h?f.jsx("div",{className:"space-y-1.5",children:u.map((y,w)=>f.jsxs("div",{className:"grid gap-1.5 rounded-sm border border-border/60 bg-background/70 px-2 py-2 md:grid-cols-[12rem_minmax(0,1fr)_auto]",children:[f.jsx(xc,{"aria-label":`Quick chat ${w+1} alias`,value:y.alias,onChange:k=>m(A=>A.map(E=>E.id===y.id?{...E,alias:k.target.value}:E)),placeholder:"alias",className:"h-7 rounded-sm border-border/70 bg-background/80 px-2 font-mono text-[11px]"}),f.jsx("textarea",{"aria-label":`Quick chat ${w+1} prompt`,value:y.prompt,onChange:k=>m(A=>A.map(E=>E.id===y.id?{...E,prompt:k.target.value}:E)),placeholder:"Prompt text",className:Xj}),f.jsx(Ct,{type:"button",variant:"ghost",size:"icon",onClick:()=>m(k=>k.filter(A=>A.id!==y.id)),"aria-label":`Remove quick chat ${w+1}`,className:"h-7 w-7 rounded-sm text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:f.jsx(zT,{className:"h-3.5 w-3.5"})})]},y.id))}):f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-4 text-[11px] text-muted-foreground",children:"No quick chats configured."}),t&&f.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:t})]})}var Sc="Checkbox",[Fj]=Fa(Sc),[Wj,ym]=Fj(Sc);function Jj(t){const{__scopeCheckbox:r,checked:o,children:s,defaultChecked:c,disabled:u,form:m,name:h,onCheckedChange:v,required:p,value:b="on",internal_do_not_use_render:y}=t,[w,k]=_o({prop:o,defaultProp:c??!1,onChange:v,caller:Sc}),[A,E]=g.useState(null),[N,T]=g.useState(null),R=g.useRef(!1),O=A?!!m||!!A.closest("form"):!0,H={checked:w,disabled:u,setChecked:k,control:A,setControl:E,name:h,form:m,value:b,hasConsumerStoppedPropagationRef:R,required:p,defaultChecked:Ga(c)?!1:c,isFormControl:O,bubbleInput:N,setBubbleInput:T};return f.jsx(Wj,{scope:r,...H,children:e_(y)?y(H):s})}var S1="CheckboxTrigger",w1=g.forwardRef(({__scopeCheckbox:t,onKeyDown:r,onClick:o,...s},c)=>{const{control:u,value:m,disabled:h,checked:v,required:p,setControl:b,setChecked:y,hasConsumerStoppedPropagationRef:w,isFormControl:k,bubbleInput:A}=ym(S1,t),E=We(c,b),N=g.useRef(v);return g.useEffect(()=>{const T=u?.form;if(T){const R=()=>y(N.current);return T.addEventListener("reset",R),()=>T.removeEventListener("reset",R)}},[u,y]),f.jsx(Ue.button,{type:"button",role:"checkbox","aria-checked":Ga(v)?"mixed":v,"aria-required":p,"data-state":R1(v),"data-disabled":h?"":void 0,disabled:h,value:m,...s,ref:E,onKeyDown:ze(r,T=>{T.key==="Enter"&&T.preventDefault()}),onClick:ze(o,T=>{y(R=>Ga(R)?!0:!R),A&&k&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})})});w1.displayName=S1;var bm=g.forwardRef((t,r)=>{const{__scopeCheckbox:o,name:s,checked:c,defaultChecked:u,required:m,disabled:h,value:v,onCheckedChange:p,form:b,...y}=t;return f.jsx(Jj,{__scopeCheckbox:o,checked:c,defaultChecked:u,disabled:h,required:m,onCheckedChange:p,name:s,form:b,value:v,internal_do_not_use_render:({isFormControl:w})=>f.jsxs(f.Fragment,{children:[f.jsx(w1,{...y,ref:r,__scopeCheckbox:o}),w&&f.jsx(C1,{__scopeCheckbox:o})]})})});bm.displayName=Sc;var E1="CheckboxIndicator",N1=g.forwardRef((t,r)=>{const{__scopeCheckbox:o,forceMount:s,...c}=t,u=ym(E1,o);return f.jsx(Lo,{present:s||Ga(u.checked)||u.checked===!0,children:f.jsx(Ue.span,{"data-state":R1(u.checked),"data-disabled":u.disabled?"":void 0,...c,ref:r,style:{pointerEvents:"none",...t.style}})})});N1.displayName=E1;var T1="CheckboxBubbleInput",C1=g.forwardRef(({__scopeCheckbox:t,...r},o)=>{const{control:s,hasConsumerStoppedPropagationRef:c,checked:u,defaultChecked:m,required:h,disabled:v,name:p,value:b,form:y,bubbleInput:w,setBubbleInput:k}=ym(T1,t),A=We(o,k),E=Vb(u),N=Ob(s);g.useEffect(()=>{const R=w;if(!R)return;const O=window.HTMLInputElement.prototype,z=Object.getOwnPropertyDescriptor(O,"checked").set,K=!c.current;if(E!==u&&z){const I=new Event("click",{bubbles:K});R.indeterminate=Ga(u),z.call(R,Ga(u)?!1:u),R.dispatchEvent(I)}},[w,E,u,c]);const T=g.useRef(Ga(u)?!1:u);return f.jsx(Ue.input,{type:"checkbox","aria-hidden":!0,defaultChecked:m??T.current,required:h,disabled:v,name:p,value:b,form:y,...r,tabIndex:-1,ref:A,style:{...r.style,...N,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});C1.displayName=T1;function e_(t){return typeof t=="function"}function Ga(t){return t==="indeterminate"}function R1(t){return Ga(t)?"indeterminate":t?"checked":"unchecked"}const A1=g.forwardRef(({className:t,...r},o)=>f.jsx(bm,{ref:o,className:ae("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...r,children:f.jsx(N1,{className:ae("flex items-center justify-center text-current"),children:f.jsx(Li,{className:"h-3.5 w-3.5"})})}));A1.displayName=bm.displayName;const m0=["queued","running"];function t_(t){return t.map(r=>`${r.id}:${r.name}`).join("\0")}function n_(t){return t==="claude"||t==="codex"||t==="copilot"}function k1(t){if(t.kind!=="agent.upgrade")return null;const r=t.payload?.agent;return n_(r)?`${t.nodeId}:${r}`:null}function a_(t){return t.status==="succeeded"||t.status==="failed"}async function j1(t,r={}){const o=r.getOperation??W0,s=r.pollIntervalMs??2e3,c=r.timeoutMs??24e4,u=Date.now()+c;let m=t;for(;!a_(m)&&Date.now()<u;)await o_(s),m=await o(t.id);return m}async function r_(t,r=J0){const o=new Set(t),s=await Promise.all(m0.map(u=>r({kind:"agent.upgrade",status:u}))),c=new Map;for(const u of s.flat()){if(!m0.includes(u.status)||o.size>0&&!o.has(u.nodeId))continue;const m=k1(u);if(!m)continue;const h=c.get(m);(!h||u.updatedAt>h.updatedAt)&&c.set(m,u)}return c}function o_(t){return new Promise(r=>setTimeout(r,t))}const l_=1500,s_=1e3,i_=9e4;async function _1(t={}){const r=t.fetchHealth??c_,o=t.initialDelayMs??l_,s=t.pollIntervalMs??s_,c=t.previousPid,u=t.reload??(()=>window.location.reload()),m=t.sleep??d_,h=t.timeoutMs??i_,v=Date.now()+h;let p=!1;for(o>0&&await m(o);Date.now()<=v;){const b=u_(await r());if(!b.ok){p=!0,await m(s);continue}if(c===void 0||b.pid!==void 0&&b.pid!==c||p)return u(),!0;await m(s)}return!1}async function c_(){try{const t=await fetch("/api/system/health",{cache:"no-store"}),r=await t.json().catch(()=>null),o=r&&typeof r=="object"&&typeof r.pid=="number"?r.pid:void 0;return{ok:t.ok,pid:o}}catch{return!1}}function u_(t){return typeof t=="boolean"?{ok:t}:t}function d_(t){return new Promise(r=>window.setTimeout(r,t))}function f_(t,r=!0){return r?t?.restartMode==="development"?"Restart dev runtime":t?.updateAvailable?"Restart to update":"Restart runtime":t?.updateAvailable?"Restart follower to update":"Restart follower"}function m_({checkedLabel:t,disableAuthDefault:r,endpoint:o,isLiveLocalNode:s,nodeId:c,nodeName:u,onRefresh:m,pid:h,transportType:v,update:p,workDir:b}){const y=f_(p,s),[w,k]=g.useState(null),[A,E]=g.useState(()=>h0({disableAuthDefault:r,endpoint:o,nodeName:u,transportType:v,workDir:b})),[N,T]=g.useState(!1),[R,O]=g.useState(!1),[H,z]=g.useState(!1);g.useEffect(()=>{E(h0({disableAuthDefault:r,endpoint:o,nodeName:u,transportType:v,workDir:b}))},[r,o,u,v,b]);async function K(){if(!c||N||R)return;const de=p.updateAvailable?"update":"restart",fe=g_(A);if(A.port.trim()&&fe?.port===void 0){Ce.error("Runtime restart port must be a positive integer");return}const W=fe?{reason:de,startArgs:fe}:{reason:de};T(!0);try{if(s){const _=await ey(W);k({..._,pid:_.pid??h,status:"accepted"}),Ce.info(`Restarting ${u} from a detached helper. PID ${_.pid??h??"unknown"} will not stay attached to the original terminal window; follow ${_.logPath} for launch output.`),_1({previousPid:_.pid??h}).then(B=>{B||(T(!1),Ce.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout. Refresh the page after the node finishes starting."))}).catch(B=>{T(!1),Ce.error(B instanceof Error?B.message:"Runtime restart recovery failed")});return}const te=await eN(c,W);k({operationId:te.id,pid:h,status:te.status}),Ce.info(`Restart requested on ${u}. Operation ${Jd(te.id)} will hand off to a detached process, so the new runtime will not stay attached to the original terminal window.`);const se=await j1(te,{timeoutMs:6e4}),X=p_(se);k({command:X?.command,logPath:X?.logPath,mode:X?.mode,operationId:se.id,pid:X?.pid??h,status:se.status}),se.status==="succeeded"?(await m?.(),Ce.success(`Restart handoff accepted on ${u}. Follow ${X?.logPath??"the node restart log"} for launch output.`)):se.status==="failed"?Ce.error(se.error??`Restart failed on ${u}`):Ce.info(`Restart operation ${Jd(se.id)} is still ${se.status}. More details will update after the node reports back.`),T(!1)}catch(te){T(!1),Ce.error(te instanceof Error?te.message:"Runtime restart failed")}}async function I(){if(!(!s||N||R)){O(!0);try{const de=await FE();Ce.info(`Stopping Meshy process ${de.pid}`)}catch(de){O(!1),Ce.error(de instanceof Error?de.message:"Runtime stop failed")}}}const P=N?"restarting":R?"stopping":w?.status??"idle",le=p.restartMode==="development";return f.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/70 bg-background/70",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border/50",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ui,{className:"h-3.5 w-3.5 text-primary shrink-0"}),f.jsxs("div",{children:[f.jsx("div",{className:"text-[11px] font-semibold text-foreground leading-tight",children:"Runtime"}),f.jsx("div",{className:"text-[10px] text-muted-foreground leading-tight",children:le?"Development launcher":`Latest ${p.latestVersion??"—"}`})]})]}),f.jsx("div",{className:"flex items-center gap-1.5",children:f.jsx(_t,{variant:p.updateAvailable?"default":"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 font-mono text-[10px]",children:le?"dev":p.updateAvailable?`→ ${p.latestVersion}`:"current"})})]}),f.jsxs("div",{className:"grid grid-cols-2 divide-x divide-border/50 border-b border-border/50",children:[f.jsxs("div",{className:"px-3 py-1.5",children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:"PID"}),f.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-foreground",children:h??"—"})]}),f.jsxs("div",{className:"px-3 py-1.5",children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:"Status"}),f.jsx("div",{className:"mt-0.5 text-[11px] text-foreground capitalize",children:P})]})]}),f.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2",children:[f.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["Checked ",t]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[s&&f.jsxs(Cf,{children:[f.jsx(Rf,{asChild:!0,children:f.jsxs(Ct,{type:"button",size:"sm",variant:"ghost",disabled:N||R,className:"h-7 rounded-sm px-2 text-[11px] text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:[f.jsx(gT,{className:ae("mr-1 h-3.5 w-3.5",R&&"animate-pulse")}),R?"Stopping":"Stop"]})}),f.jsxs(Qi,{className:"max-w-[22rem] gap-2 rounded-sm p-4",children:[f.jsxs(Ki,{className:"space-y-1",children:[f.jsx(Fi,{className:"text-sm",children:"Stop runtime?"}),f.jsx(Wi,{className:"text-[11px] leading-4",children:"Gracefully stops the current Meshy process without launching a replacement. The dashboard will disconnect until the node is started again."})]}),f.jsxs(Zi,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(ec,{className:"h-7 rounded-sm px-2 text-[11px]",children:"Cancel"}),f.jsx(Ji,{className:"h-7 rounded-sm bg-destructive px-2 text-[11px] text-destructive-foreground hover:bg-destructive/90",onClick:()=>{I()},children:"Stop runtime"})]})]})]}),f.jsxs(Cf,{children:[f.jsx(Rf,{asChild:!0,children:f.jsxs(Ct,{type:"button",size:"sm",variant:p.updateAvailable?"default":"outline",disabled:!c||N||R,className:"h-7 rounded-sm px-2 text-[11px]",children:[f.jsx(Ai,{className:ae("mr-1 h-3.5 w-3.5",N&&"animate-spin")}),N?"Restarting…":y]})}),f.jsxs(Qi,{className:"max-w-[28rem] gap-3 rounded-sm p-4",children:[f.jsxs(Ki,{className:"space-y-1",children:[f.jsxs(Fi,{className:"text-sm",children:[y,"?"]}),f.jsxs(Wi,{className:"text-[11px] leading-4",children:["Starts a detached restart helper, shuts down ",s?"the current node":u,", and brings it back with the configured launcher. The new process will not stay attached to the original terminal window."]})]}),f.jsx(h_,{value:A,onChange:E}),f.jsxs(Zi,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(ec,{className:"h-7 rounded-sm px-2 text-[11px]",children:"Cancel"}),f.jsx(Ji,{className:"h-7 rounded-sm px-2 text-[11px]",onClick:()=>{K()},children:y})]})]})]})]})]}),f.jsxs("div",{className:"border-t border-border/50",children:[f.jsxs("button",{type:"button",onClick:()=>z(de=>!de),className:"flex w-full items-center justify-between px-3 py-1.5 text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(hy,{className:"h-3 w-3"}),"Restart details"]}),f.jsx(Zl,{className:ae("h-3 w-3 transition-transform duration-150",H&&"rotate-180")})]}),H&&f.jsxs("div",{className:"border-t border-border/50 bg-muted/20 px-3 py-2 space-y-1",children:[f.jsx(Er,{label:"Current PID",value:h===void 0?"—":String(h),mono:h!==void 0}),f.jsx(Er,{label:"Restart PID",value:w?.pid===void 0?"Pending":String(w.pid),mono:w?.pid!==void 0}),f.jsx(Er,{label:"Operation",value:w?.operationId?Jd(w.operationId):"Local direct request",mono:!!w?.operationId}),f.jsx(Er,{label:"Status",value:w?.status??(N?"requested":"idle")}),f.jsx(Er,{label:"Launcher",value:w?.command??"Available after restart",mono:!!w?.command}),f.jsx(Er,{label:"Log",value:w?.logPath??"Available after restart",mono:!!w?.logPath}),f.jsx(Er,{label:"Terminal",value:"New process is detached from original terminal"})]})]}),p.detail&&f.jsx("div",{className:"border-t border-border/50 px-3 py-1.5 text-[10px] text-muted-foreground bg-muted/20",children:p.detail})]})}function h_({onChange:t,value:r}){const o=(s,c)=>{t({...r,[s]:c})};return f.jsxs("div",{className:"rounded-lg border border-border/70 bg-muted/30 p-3 space-y-3",children:[f.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Startup arguments"}),f.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[f.jsx(Pl,{label:"HTTP port",value:r.port,onChange:s=>o("port",s),inputMode:"numeric"}),f.jsx(Pl,{label:"Node name",value:r.name,onChange:s=>o("name",s)}),f.jsx(Pl,{label:"Join endpoint",value:r.join,onChange:s=>o("join",s),className:"sm:col-span-2"}),f.jsxs("div",{className:"space-y-1",children:[f.jsx("label",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:"Transport"}),f.jsxs(Ef,{value:r.transport,onValueChange:s=>o("transport",O1(s)),children:[f.jsx(Gi,{className:"h-7 rounded-md border-border/70 bg-background/70 px-2 text-[10px]",children:f.jsx(Nf,{placeholder:"Transport"})}),f.jsxs(Xi,{children:[f.jsx(ua,{className:"py-1 text-[11px]",value:"inherit",children:"current / default"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"direct",children:"direct"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"devtunnel",children:"devtunnel"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"tailscale",children:"tailscale"})]})]})]}),f.jsx(Pl,{label:"Working directory",value:r.workDir,onChange:s=>o("workDir",s)}),f.jsx(Pl,{label:"Config path",value:r.config,onChange:s=>o("config",s),className:"sm:col-span-2"}),f.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[f.jsx("label",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:"GHC tunnel"}),f.jsxs(Ef,{value:r.ghcTunnel,onValueChange:s=>o("ghcTunnel",v_(s)),children:[f.jsx(Gi,{className:"h-7 rounded-sm border-border/70 bg-background/70 px-2 text-[10px]",children:f.jsx(Nf,{placeholder:"GHC tunnel"})}),f.jsxs(Xi,{children:[f.jsx(ua,{className:"py-1 text-[11px]",value:"inherit",children:"current / remembered"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"enable",children:"enable"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"disable",children:"disable"})]})]})]}),f.jsxs("label",{className:"flex items-center gap-2 rounded-md border border-border/60 bg-background/60 px-2 py-1.5 text-[10px] text-foreground sm:col-span-2 cursor-pointer hover:bg-muted/40 transition-colors",children:[f.jsx(A1,{className:"h-3.5 w-3.5",checked:r.disableAuth,onCheckedChange:s=>t({...r,disableAuth:s===!0,disableAuthKnown:!0})}),"Disable auth"]})]})]})}function Pl({className:t,inputMode:r,label:o,onChange:s,value:c}){return f.jsxs("label",{className:ae("space-y-1",t),children:[f.jsx("span",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:o}),f.jsx(xc,{className:"h-7 rounded-md px-2 text-[10px]",inputMode:r,value:c,onChange:u=>s(u.target.value)})]})}function Er({label:t,value:r,mono:o=!1}){return f.jsxs("div",{className:"flex items-start justify-between gap-3 text-[10px]",children:[f.jsx("span",{className:"shrink-0 uppercase tracking-[0.14em] text-muted-foreground",children:t}),f.jsx("span",{className:ae("break-all text-right text-foreground",o&&"font-mono"),children:r})]})}function p_(t){const r=t.result;if(!r||typeof r!="object")return null;const o=r;return o.ok!==!0||typeof o.command!="string"||typeof o.logPath!="string"?null:{ok:!0,mode:o.mode==="package"?"package":"development",command:o.command,logPath:o.logPath,pid:typeof o.pid=="number"?o.pid:void 0}}function h0(t){return{port:y_(t.endpoint),name:t.nodeName,join:"",transport:O1(t.transportType),workDir:t.workDir??"",config:"",disableAuth:t.disableAuthDefault===!0,disableAuthKnown:t.disableAuthDefault!==void 0,ghcTunnel:"inherit"}}function g_(t){const r={},o=Number(t.port.trim());return t.port.trim()&&Number.isInteger(o)&&o>0&&(r.port=o),t.name.trim()&&(r.name=t.name.trim()),t.join.trim()&&(r.join=t.join.trim()),t.transport!=="inherit"&&(r.transport=t.transport),t.workDir.trim()&&(r.workDir=t.workDir.trim()),t.config.trim()&&(r.config=t.config.trim()),t.disableAuthKnown&&(r.disableAuth=t.disableAuth),t.ghcTunnel==="enable"&&(r.ghcTunnel=!0),t.ghcTunnel==="disable"&&(r.ghcTunnel=!1),Object.keys(r).length>0?r:void 0}function O1(t){return t==="direct"||t==="devtunnel"||t==="tailscale"?t:"inherit"}function v_(t){return t==="enable"||t==="disable"?t:"inherit"}function y_(t){if(!t)return"";try{return new URL(t).port||""}catch{return""}}function Jd(t){return t.length<=8?t:t.slice(0,8)}function $l({formatDateTime:t,name:r,status:o,statusVariant:s}){return f.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-border/60 bg-background/70 px-2.5 py-1.5",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[11px] font-medium text-foreground",children:r}),f.jsx("div",{className:"text-[10px] text-muted-foreground",children:t(o?.checkedAt)})]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof o?.authenticated=="boolean"&&f.jsx(_t,{variant:o.authenticated?"default":"outline",className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o.authenticated?"auth ok":"auth required"}),f.jsx(_t,{variant:s(o?.status),className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o?.status??"unknown"})]})]})}function qt(t){if(t==null||t==="")return"Unavailable";const r=new Date(t);return Number.isNaN(r.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(r)}function b_(t){const r=Math.max(0,Math.floor(t)),o=Math.floor(r/86400),s=Math.floor(r%86400/3600),c=Math.floor(r%3600/60);return o>0?`${o}d ${s}h`:s>0?`${s}h ${c}m`:`${c}m`}function p0(t){if(t==null||Number.isNaN(t))return"Unavailable";const r=["B","KB","MB","GB","TB"];let o=t,s=0;for(;o>=1024&&s<r.length-1;)o/=1024,s+=1;return`${o.toFixed(o>=10||s===0?0:1)} ${r[s]}`}function Co(t){return t==="ok"?"default":t==="missing"||t==="install-failed"||t==="login-failed"?"destructive":t==="not-authenticated"||t==="unsupported-platform"?"outline":"secondary"}function x_(t){return t.available?f.jsx("span",{"data-agent-availability":"available","aria-label":"Available",title:"Available",className:"inline-flex h-5 w-5 items-center justify-center text-emerald-500",children:f.jsx(Ro,{className:"h-3.5 w-3.5"})}):f.jsx("span",{"data-agent-availability":"unavailable","aria-label":"Unavailable",title:"Unavailable",className:"inline-flex h-5 w-5 items-center justify-center text-destructive",children:f.jsx(uf,{className:"h-3.5 w-3.5"})})}function S_(t){return t.update?t.update.updateAvailable?f.jsxs(_t,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:["Update ",t.update.latestVersion]}):f.jsx(_t,{variant:"secondary",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:"Up to date"}):null}function w_(t){return t.available?null:t.metadataStatus??null}function E_(t){const r=`npm install -g ${t.update?.packageName}@latest`;return t.id==="claude"?`${r} --include=optional --ignore-scripts=false`:r}function N_(t){return t.error?t.error:t.result?.detail??null}function Fe({label:t,value:r,mono:o=!1}){return f.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border/50 py-1 last:border-b-0 last:pb-0 first:pt-0",children:[f.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:t}),f.jsx("span",{className:ae("break-all text-right text-[11px] text-foreground",o&&"font-mono text-[11px]"),children:r})]})}function ql({label:t,value:r,mono:o=!1,className:s}){return f.jsxs("div",{className:ae("min-w-0 space-y-0.5",s),children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:t}),f.jsx("div",{className:ae("truncate text-[11px] text-foreground",o&&"font-mono",t==="Path"&&"break-all whitespace-normal"),children:r})]})}function T_({agent:t,nodeName:r,activeOperation:o,onUpgrade:s}){const c=t.update?.updateAvailable===!0,u=S_(t),m=!!o,h=w_(t);return f.jsxs("div",{className:"rounded-sm border border-border/60 bg-background/65 px-3 py-2.5 transition-colors hover:bg-background/85",children:[f.jsxs("div",{className:"grid gap-3 lg:grid-cols-[12rem_minmax(0,1fr)_auto] lg:items-start",children:[f.jsxs("div",{className:"min-w-0 space-y-1.5",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[f.jsx(Yf,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),f.jsx("span",{className:"truncate",children:t.label})]}),f.jsxs("div",{className:"truncate text-[10px] text-muted-foreground",children:["Command: ",f.jsx("span",{className:"font-mono text-[10px]",children:t.command})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[x_(t),h&&f.jsx(_t,{variant:Co(h),className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:h})]})]}),f.jsxs("div",{className:"grid min-w-0 gap-x-4 gap-y-1.5 sm:grid-cols-2",children:[f.jsx(ql,{label:"Version",value:t.version??"Unavailable",mono:!!t.version}),t.update&&f.jsx(ql,{label:"Latest",value:t.update.latestVersion??"Unavailable",mono:!!t.update.latestVersion}),f.jsx(ql,{label:"Checked",value:qt(t.checkedAt)}),t.update&&f.jsx(ql,{label:"Update check",value:qt(t.update.checkedAt)}),f.jsx(ql,{label:"Path",value:t.path??"Not on PATH",mono:!!t.path,className:"sm:col-span-2"})]}),f.jsx("div",{className:"flex items-start justify-start lg:justify-end",children:o?f.jsxs(_t,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:["Upgrade ",o.status]}):c?f.jsxs(Cf,{children:[f.jsx(Rf,{asChild:!0,children:f.jsx("button",{type:"button",disabled:m,className:"rounded-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60",children:u})}),f.jsxs(Qi,{children:[f.jsxs(Ki,{children:[f.jsxs(Fi,{children:["Upgrade ",t.label,"?"]}),f.jsxs(Wi,{children:["This runs ",E_(t)," on ",r,". Remote nodes execute the command on the remote machine."]})]}),f.jsxs(Zi,{children:[f.jsx(ec,{children:"Cancel"}),f.jsx(Ji,{onClick:()=>s(t),children:"Upgrade"})]})]})]}):u})]}),t.update?.detail&&f.jsx("div",{className:"mt-2 rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[10px] text-muted-foreground",children:t.update.detail}),t.detail&&f.jsx("div",{className:"mt-2 rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[10px] text-muted-foreground",children:t.detail})]})}function C_(t,r){return t?.nodes?.length?t.nodes:r?[r]:[]}function R_(t,r){if(r&&t.id===r.nodeId)return r;const o=t.settingsSnapshot;return{...t,nodeId:t.id,version:o?.version??"Unavailable",packageName:o?.packageName,uptime:o?.uptime??0,defaultTaskAgent:o?.defaultTaskAgent,localDashboardOrigin:o?.runtime?.localDashboardOrigin??void 0,auth:o?.auth,os:o?.os,runtime:o?.runtime,runtimeUpdate:o?.runtimeUpdate,agents:o?.agents,startupRequirements:o?.startupRequirements,components:o?.components,repository:o?.repository,packages:o?.packages}}function A_(t,r){return t.id===r?`${t.name} (this node)`:`${t.name} (${t.role})`}function k_(t){return t==="claude"?"Claude Code":t==="copilot"?"Copilot CLI":"Codex"}function j_(t){const r=t.payload?.agent;return r==="claude"||r==="codex"||r==="copilot"?r:null}function __({cluster:t,systemInfo:r,sseConnected:o,initialSelectedNodeId:s,onRefresh:c}){const u=g.useMemo(()=>C_(t,r),[t,r]),[m,h]=g.useState(()=>s??r?.nodeId??t?.self?.id??""),[v,p]=g.useState(()=>new Map),[b,y]=g.useState("codex"),[w,k]=g.useState(!1),A=g.useRef(new Set),E=g.useRef(new Set),N=t?.self??r??u[0]??null,T=u.find(X=>X.id===m)??N,R=T?R_(T,r):null,O=!!(r&&T&&T.id===r.nodeId),H=O||!!T?.settingsSnapshot,z=R?.runtimeUpdate,K=Af(R?.defaultTaskAgent),I=R?.startupRequirements?.components??R?.components??{},P=g.useMemo(()=>u.map(X=>X.id),[u]),le=P.join("\0"),de=t_(u),fe=g.useMemo(()=>new Map(u.map(X=>[X.id,X.name])),[de]);g.useEffect(()=>{s&&P.includes(s)&&h(s)},[s,le]),g.useEffect(()=>{y(K)},[T?.id,K]);const W=g.useCallback(async(X,_)=>{const B=k1(X);if(!B||A.current.has(X.id))return;const Q=j_(X),ue=_?.agentLabel??(Q?k_(Q):"Agent"),C=_?.nodeName??fe.get(X.nodeId)??X.nodeId;A.current.add(X.id),p(V=>new Map(V).set(B,X));try{const V=await j1(X);if(V.status==="succeeded")await c?.(),E.current.has(V.id)||(Ce.success(`${ue} upgrade finished on ${C}`),E.current.add(V.id));else if(V.status==="failed")E.current.has(V.id)||(Ce.error(N_(V)??`${ue} upgrade failed`),E.current.add(V.id));else{p(re=>new Map(re).set(B,V)),Ce.info(`${ue} upgrade is still ${V.status} on ${C}`);return}p(re=>{const Y=new Map(re),ee=Y.get(B);return(!ee||ee.id===V.id)&&Y.delete(B),Y})}catch(V){p(re=>{const Y=new Map(re),ee=Y.get(B);return(!ee||ee.id===X.id)&&Y.delete(B),Y}),Ce.error(V instanceof Error?V.message:`${ue} upgrade failed`)}finally{A.current.delete(X.id)}},[c,fe]);g.useEffect(()=>{if(P.length===0)return;let X=!1;async function _(){let B;try{B=await r_(P)}catch{return}if(!X){p(Q=>{const ue=new Map(Q);for(const[C,V]of B)ue.set(C,V);return ue});for(const Q of B.values())W(Q)}}return _(),()=>{X=!0}},[W,le]);async function te(X){if(T)try{const _=await JE(T.id,X.id);Ce.info(`${X.label} upgrade started on ${T.name}`),await W(_,{agentLabel:X.label,nodeName:T.name})}catch(_){Ce.error(_ instanceof Error?_.message:`${X.label} upgrade failed`)}}async function se(X){if(!O||X===K)return;const _=b;y(X),k(!0);try{const B=await ZE(X);y(Af(B.defaultTaskAgent)),await c?.(),Ce.success("Default agent updated")}catch(B){y(_),Ce.error(B instanceof Error?B.message:"Failed to update default agent")}finally{k(!1)}}return!T||!R?f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-5 text-center text-[11px] text-muted-foreground",children:"Loading session metadata..."}):f.jsxs("div",{className:"space-y-3",children:[f.jsxs("section",{className:"relative mt-1 rounded-sm border border-border/70 bg-background/75 p-3 shadow-none",children:[!O&&f.jsxs(_t,{variant:"outline",className:"absolute right-3 top-2.5 rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em] whitespace-nowrap",children:["Updated ",qt(T.settingsSnapshot?.collectedAt)]}),f.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-end md:justify-between",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.jsxs("span",{className:"flex items-center gap-1.5 rounded-sm border border-border/70 bg-background/75 px-1.5 py-0 text-[10px] text-muted-foreground",children:[f.jsx(vj,{status:T.status}),f.jsx("span",{className:"font-medium text-foreground",children:T.name})]}),f.jsx(yj,{role:T.role}),f.jsx(_t,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:T.transportType??R.transportType??"direct"}),f.jsx(_t,{variant:O?"default":"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:O?"Live local session":"Leader-synced snapshot"})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-[10px] uppercase tracking-[0.34em] text-muted-foreground",children:"Session"}),f.jsx("h3",{className:"mt-0.5 text-sm font-semibold tracking-tight text-foreground",children:"Node runtime"}),f.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Runtime environment, connectivity, and build metadata."})]}),u.length>1&&f.jsxs("div",{className:"w-48 space-y-1.5",children:[f.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:"Inspect node"}),f.jsxs(Ef,{value:T.id,onValueChange:h,children:[f.jsx(Gi,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px]",children:f.jsx(Nf,{placeholder:"Choose a node"})}),f.jsx(Xi,{className:"settings-node-select-content rounded-sm text-[10px] leading-4",children:u.map(X=>f.jsx(ua,{value:X.id,className:"settings-node-select-item py-1 pl-6 pr-2 text-[10px] leading-4 [&>span]:left-1.5 [&_svg]:h-3 [&_svg]:w-3",children:A_(X,r?.nodeId)},X.id))})]})]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(_t,{variant:o?"default":"outline",className:"gap-1 rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:[f.jsx(yT,{className:"h-3 w-3"}),o?"Live link":"Reconnecting"]}),f.jsxs(_t,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:["Uptime ",b_(R.uptime)]})]})]})]}),!H&&f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-[11px] text-muted-foreground",children:"This node has not synced its settings snapshot to the leader yet. Wait for the next keepalive and reopen the dialog if needed."}),f.jsxs(nj,{defaultValue:"session",className:"space-y-2",children:[f.jsxs(Qx,{className:"h-auto flex-wrap rounded-sm border border-border/60 bg-muted/40 p-0.5",children:[f.jsx(Yl,{value:"session",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Session"}),f.jsx(Yl,{value:"access",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Access"}),f.jsx(Yl,{value:"quick-chats",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Quick chats"}),f.jsx(Yl,{value:"about",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"About"})]}),f.jsxs(Gl,{value:"session",className:"mt-0 grid gap-2 xl:grid-cols-[1.15fr_0.85fr]",children:[f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(fy,{className:"h-3.5 w-3.5 text-primary"}),"Selected node"]}),f.jsx(Nn,{className:"text-[10px]",children:"Cluster role, identity, and node-scoped runtime state."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Node ID",value:R.nodeId,mono:!0}),f.jsx(Fe,{label:"Status",value:T.status}),f.jsx(Fe,{label:"Role",value:T.role}),f.jsx(Fe,{label:"Endpoint",value:T.endpoint,mono:!0}),f.jsx(Fe,{label:"Joined",value:qt(T.joinedAt)}),f.jsx(Fe,{label:"Heartbeat",value:qt(T.lastHeartbeat)}),f.jsx(Fe,{label:"Capabilities",value:T.capabilities.length>0?T.capabilities.join(", "):"None"})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(FN,{className:"h-3.5 w-3.5 text-primary"}),"OS info"]}),f.jsx(Nn,{className:"text-[10px]",children:"Host and resource details reported by the current process."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Host",value:R.os?.hostname??"Unavailable"}),f.jsx(Fe,{label:"Platform",value:R.os?`${R.os.platform} ${R.os.release}`:"Unavailable"}),f.jsx(Fe,{label:"Arch",value:R.os?.arch??"Unavailable"}),f.jsx(Fe,{label:"CPU",value:R.os?.cpuModel??"Unavailable"}),f.jsx(Fe,{label:"Cores",value:String(R.os?.cpuCount??"Unavailable")}),f.jsx(Fe,{label:"Memory",value:R.os?`${p0(R.os.freeMemoryBytes)} free / ${p0(R.os.totalMemoryBytes)} total`:"Unavailable"})]})]}),z&&f.jsx("div",{className:"xl:col-span-2",children:f.jsx(m_,{checkedLabel:qt(z.checkedAt),disableAuthDefault:R.auth?.enabled===void 0?void 0:R.auth.enabled===!1,endpoint:T.endpoint,isLiveLocalNode:O,nodeId:T.id,nodeName:T.name,onRefresh:c,pid:R.runtime?.pid,transportType:T.transportType,update:z,workDir:R.runtime?.workDir??T.workDir})}),f.jsx($j,{nodeId:T.id,nodeName:T.name}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none xl:col-span-2",children:[f.jsx(wn,{className:"pb-1.5 pt-2.5 px-3",children:f.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[f.jsxs("div",{className:"min-w-0 space-y-1",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(Yf,{className:"h-3.5 w-3.5 text-primary"}),"Available agents"]}),f.jsx(Nn,{className:"text-[10px]",children:O?"Live command availability for runtime agents on this node.":"Most recent agent availability snapshot synced from this node."})]}),f.jsx(qj,{value:w?b:K,disabled:!O,saving:w,onChange:se})]})}),f.jsx(Tn,{"data-agent-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:(R.agents??[]).map(X=>f.jsx(T_,{agent:X,nodeName:T.name,activeOperation:v.get(`${T.id}:${X.id}`),onUpgrade:te},X.id))})]})]}),f.jsxs(Gl,{value:"access",className:"mt-0 grid gap-2 xl:grid-cols-2",children:[f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(oy,{className:"h-3.5 w-3.5 text-primary"}),"Access surface"]}),f.jsx(Nn,{className:"text-[10px]",children:"How this node is exposed to the dashboard and other peers."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Transport",value:T.transportType??R.transportType??"direct"}),f.jsx(Fe,{label:"Node URL",value:T.endpoint,mono:!0}),f.jsx(Fe,{label:"Node tunnel",value:T.devtunnelEndpoint??"Disabled",mono:!!T.devtunnelEndpoint}),f.jsx(Fe,{label:"Dashboard URL",value:T.dashboardOrigin??R.localDashboardOrigin??"Unavailable",mono:!!(T.dashboardOrigin||R.localDashboardOrigin)}),f.jsx(Fe,{label:"Local dashboard",value:R.localDashboardOrigin??"Unavailable",mono:!!R.localDashboardOrigin})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(kT,{className:"h-3.5 w-3.5 text-primary"}),"Auth"]}),f.jsx(Nn,{className:"text-[10px]",children:"Current bearer-auth and trusted access posture."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Enabled",value:R.auth?.enabled?"Yes":"No"}),f.jsx(Fe,{label:"Same tenant",value:R.auth?.allowSameTenant?"Allowed":"Off"}),f.jsx(Fe,{label:"Allowed users",value:R.auth?.allowedUsers.length?R.auth.allowedUsers.join(", "):"None"})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(eT,{className:"h-3.5 w-3.5 text-primary"}),"Paths"]}),f.jsx(Nn,{className:"text-[10px]",children:"Workspace and runtime paths currently used by this node."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Work dir",value:R.runtime?.workDir??R.workDir??"Unavailable",mono:!!(R.runtime?.workDir??R.workDir)}),f.jsx(Fe,{label:"Storage",value:R.runtime?.storagePath??"Unavailable",mono:!!R.runtime?.storagePath}),f.jsx(Fe,{label:"Process cwd",value:R.runtime?.cwd??"Unavailable",mono:!!R.runtime?.cwd}),f.jsx(Fe,{label:"Started",value:qt(R.runtime?.startedAt)}),f.jsx(Fe,{label:"PID",value:R.runtime?String(R.runtime.pid):"Unavailable",mono:!!R.runtime})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(Ui,{className:"h-3.5 w-3.5 text-primary"}),"Startup checks"]}),f.jsx(Nn,{className:"text-[10px]",children:"Dependency preflight snapshot persisted during node startup."})]}),f.jsxs(Tn,{className:"space-y-3 px-3 pb-2.5",children:[f.jsxs("div",{className:"rounded-sm border border-border/60 bg-background/70 px-3 py-2",children:[f.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:"Last checked"}),f.jsx("div",{className:"mt-0.5 text-[11px] text-foreground",children:qt(R.startupRequirements?.lastCheckedAt)})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx($l,{formatDateTime:qt,name:"Azure CLI",status:I.az,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"DevTunnel",status:I.devtunnel,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"Claude Code",status:I.claude,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"Codex",status:I.codex,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"Copilot CLI",status:I.copilot,statusVariant:Co})]})]})]})]}),f.jsx(Gl,{value:"quick-chats",className:"mt-0",children:f.jsx(Zj,{})}),f.jsx(Sj,{formatDateTime:qt,viewInfo:R})]})]})}function O_({initialSelectedNodeId:t,open:r,onOpenChange:o,showTrigger:s=!0}={}){const{cluster:c,systemInfo:u,sseConnected:m,refresh:h}=ay();return f.jsx(YA,{open:r,onOpenChange:o,showTrigger:s,children:f.jsx(__,{cluster:c,systemInfo:u,sseConnected:m,initialSelectedNodeId:t,onRefresh:h})})}const nc="meshy:show-live-events";function M1(){const t=globalThis.window;if(!t)return;const r=typeof t.CustomEvent=="function"?new t.CustomEvent(nc):new t.Event(nc);t.dispatchEvent(r)}function mM(t){const r=globalThis.window;return r?(r.addEventListener(nc,t),()=>r.removeEventListener(nc,t)):()=>{}}const M_={node:"border-teal-500/30 bg-teal-500/10 text-teal-700 dark:text-teal-300",task:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",election:"border-indigo-500/30 bg-indigo-500/10 text-indigo-700 dark:text-indigo-300",cluster:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",transport:"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300"},D_={node:"text-teal-700/70 dark:text-teal-300/70",task:"text-amber-700/70 dark:text-amber-300/70",election:"text-indigo-700/70 dark:text-indigo-300/70",cluster:"text-emerald-700/70 dark:text-emerald-300/70",transport:"text-sky-700/70 dark:text-sky-300/70"};function z_(t){return t.split(".")[0]??"unknown"}function U_(t){return new Date(t).toLocaleTimeString("en-US",{hour12:!1})}function No(t,r,o){return typeof o=="string"&&o.length>0?o:r?.get(t)??t}function D1(t,r){const o=t.data,s=o.operation;switch(t.type){case"node.joined":return`${o.name} joined the cluster`;case"node.left":return`${No(o.nodeId,r,o.name)} left (${o.reason})`;case"node.status":return`${No(o.nodeId,r)} is now ${o.status}`;case"node.operation.created":return`${s?.kind} ${s?.status} on ${No(s?.nodeId,r)}`;case"node.operation.updated":return`${s?.kind} ${s?.status} on ${No(s?.nodeId,r)}`;case"transport.changed":return`${No(o.nodeId,r)} transport switched to ${o.transportType}`;case"task.created":return`"${o.title}" created`;case"task.assigned":return`task assigned to ${No(o.nodeId,r)}`;case"task.status":return`task ${o.taskId.slice(0,8)} -> ${o.status}`;case"election.started":return`candidate ${o.candidateId.slice(0,8)} term ${o.term}`;case"election.complete":return`leader elected, term ${o.term}`;case"cluster.state":return`${o.nodeCount} nodes, term ${o.term}`;default:return JSON.stringify(o)}}function L_(t){return JSON.stringify(t,null,2)}function B_({events:t,maxHeight:r="400px",nodeNameById:o,onDismiss:s,onSelect:c,density:u="default"}){if(t.length===0)return null;const m=u==="compact";return f.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:r},children:f.jsx("div",{className:"space-y-1.5",children:t.map(h=>{const v=z_(h.type);return f.jsx("div",{onClick:c?()=>c(h.id):void 0,onKeyDown:c?p=>{p.target===p.currentTarget&&(p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),c(h.id)))}:void 0,"data-click-open-live-events":c?"true":void 0,role:c?"button":void 0,tabIndex:c?0:void 0,title:c?"Open in Live events":void 0,className:ae("transition-colors hover:bg-muted/30",c&&"cursor-pointer",m?"rounded-sm px-1 py-0.5":"rounded-sm px-1.5 py-1"),children:f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.jsx("div",{className:ae("font-mono text-muted-foreground",m?"text-[8px]":"text-[9px]"),children:U_(h.timestamp)}),m?f.jsx("span",{className:ae("max-w-[8.5rem] truncate text-[7px] font-medium uppercase tracking-[0.08em] text-muted-foreground/70",D_[v]),children:h.type}):f.jsx(_t,{variant:"outline",className:ae("w-fit text-[9px] font-medium uppercase tracking-[0.14em] px-1.5 py-0",M_[v]),children:h.type})]}),f.jsxs("div",{className:ae("flex shrink-0 items-center",m?"gap-px":"gap-0.5"),children:[f.jsx(Ct,{type:"button",variant:"ghost",size:"icon",className:ae("rounded-sm text-muted-foreground hover:text-foreground",m?"h-3.5 w-3.5 p-0 opacity-65 hover:bg-muted/40 hover:opacity-100 [&_svg]:size-2.5":"h-5 w-5"),onClick:p=>{p.stopPropagation(),y1(L_(h),"Event copied")},"aria-label":`Copy ${h.type} event`,title:"Copy event",children:f.jsx(ly,{className:m?"h-2.5 w-2.5":"h-3 w-3"})}),s&&f.jsx(Ct,{type:"button",variant:"ghost",size:"icon",className:ae("rounded-sm text-muted-foreground hover:text-foreground",m?"h-3.5 w-3.5 p-0 opacity-65 hover:bg-muted/40 hover:opacity-100 [&_svg]:size-2.5":"h-5 w-5"),onClick:p=>{p.stopPropagation(),s(h.id)},"aria-label":`Dismiss ${h.type} event`,title:"Dismiss event",children:f.jsx(py,{className:m?"h-2.5 w-2.5":"h-3 w-3"})})]})]}),f.jsx("div",{className:"text-[9px] leading-snug text-foreground/85",children:D1(h,o)})]})},h.id)})})})}function z1(t){return t!==null}function U1(t){return t==="click"?t:"hover"}function _f(t){return t==="hover"?null:t}function L1(t){return t==="click"?null:"click"}const H_=["node.","election.","transport."],P_="cluster.state";function $_(t){return t.type==="node.status"?!1:H_.some(r=>t.type.startsWith(r))}function q_(t){return new Date(t).toLocaleTimeString("en-US",{hour12:!1})}function V_(t,r){return t?{time:q_(t.timestamp),text:D1(t,r)}:null}function I_(t){return t.transportType==="devtunnel"||!!t.devtunnelEndpoint}function Y_(t){if(t.length===0)return"No node tunnel";const r=t.filter(c=>c.status==="offline").length;if(r>0)return`${r} offline`;const o=t.filter(c=>c.devtunnelHealth?.status==="failed").length;if(o>0)return`${o} failed`;const s=t.filter(c=>c.status!=="offline"&&c.devtunnelHealth?.status!=="healthy").length;return s>0?`${s} checking`:"Healthy"}function G_(t,r){const o=r?.get(t.id)??t.name??t.id;if(t.status==="offline")return{label:o,status:"offline"};const s=t.devtunnelHealth?.status??"checking";return{label:o,status:s}}function X_(t){if(t.length===0)return"No nodes";const r=t.filter(s=>s.status==="offline").length;if(r>0)return`${r} offline`;const o=t.filter(s=>s.status==="busy").length;return o>0?`${o} busy`:"Healthy"}function Q_(t,r){return{label:r?.get(t.id)??t.name??t.id,status:t.status}}function K_({connected:t,events:r,nodes:o=[],currentNode:s=null,nodeNameById:c,desktopUpdate:u=null,desktopUpdateCheckPending:m=!1,desktopUpdateProgress:h=null,defaultOpen:v=!1,defaultActionMenuOpen:p=!1,onDesktopUpdateCheck:b,onDesktopUpdate:y,onDesktopRestart:w,onReload:k,onRestart:A}){const[E,N]=g.useState(v?"click":null),[T,R]=g.useState(p),[O,H]=g.useState(!0),[z,K]=g.useState(new Set),[I,P]=g.useState(!1),[le,de]=g.useState(!1),fe=z1(E),W=g.useRef(null),te=g.useRef(null),se=g.useMemo(()=>r.filter(be=>$_(be)&&!z.has(be.id)),[r,z]),X=g.useMemo(()=>r.find(be=>be.type===P_)??se[0],[r,se]),_=g.useMemo(()=>V_(X,c),[X,c]),B=g.useMemo(()=>{const be=new Map(o.map(Xe=>[Xe.id,Xe]));return s&&be.set(s.id,s),Array.from(be.values())},[s,o]),Q=g.useMemo(()=>B.filter(I_),[B]),ue=Q.some(be=>be.status==="offline"||be.devtunnelHealth?.status==="failed"),C=B.some(be=>be.status==="offline"),V=B.some(be=>be.status==="busy"),re=B.length>0,Y=s?.name??"offline",ee=s?.role==="leader"?"Leader":s?.role==="follower"?"Follower":"Node",J=u!==null,ne=!!(J&&u?.updateAvailable&&u.latestVersion),ie=u?.latestVersion??null,ce=!!(J&&!ne&&ie),xe=!!(J&&u?.detail==="Checking desktop update..."),Re=!!(J&&!ne&&!ie&&u?.detail&&!xe),Ne=h?.percent??null,Ae=Ne===null?null:`${Ne}%`,et=I?"Relaunching runtime...":"Relaunch to apply update",rt=Ae?`Downloading ${Ae}`:le?"Downloading and installing desktop update...":ne&&ie?`Available version ${ie}`:Re?u?.detail??"Desktop update unavailable":"Desktop is current",hn=!!k,pn=!!(J&&w),er=!!(J&&b)||hn||pn,pt=J||!!A,_r=J||!!A||hn,In=pt?J?ne?"Update":ce?"Latest":"Check":"Relaunch":"Reload",it=J&&!ne,gn=it?"Check":In,Or=pt?J?rt:et:"Reload dashboard page",ga=pt?J?le||h!==null:I:!1,It=pt?J?ga||!ne||!y:ga:!1,Rt=m||le||!b,Ut=J?ne&&ie?`Install desktop update ${ie}`:Re?"Desktop update unavailable":"Desktop is current":pt?I?"Relaunching runtime":"Relaunch runtime":"Reload dashboard page";function Je(){te.current&&(clearTimeout(te.current),te.current=null)}function On(){Je(),N(be=>U1(be))}function Mr(){Je(),te.current=setTimeout(()=>{N(be=>_f(be)),te.current=null},180)}function Mn(){Je()}function va(){Je(),N(be=>_f(be))}async function ya(){if(!(!A||I)){P(!0);try{await A()}finally{P(!1)}}}async function nn(){if(!(!ne||!y||le)){de(!0);try{await y()}finally{de(!1)}}}async function Yn(){!b||m||le||await b()}async function Gn(){if(!(!w||I)){R(!1),P(!0);try{await w()}finally{P(!1)}}}async function ba(){if(!pt){await Lt();return}if(J){await nn();return}await ya()}async function Lt(){k&&(R(!1),await k())}function tr(){K(be=>{const Xe=new Set(be);return se.forEach(me=>Xe.add(me.id)),Xe})}function nr(){M1(),N(null)}return g.useEffect(()=>()=>{Je()},[]),g.useEffect(()=>{K(be=>{if(be.size===0)return be;const Xe=new Set(r.map(He=>He.id)),me=new Set(Array.from(be).filter(He=>Xe.has(He)));return me.size===be.size?be:me})},[r]),g.useEffect(()=>{fe||R(!1)},[fe]),g.useEffect(()=>{if(!fe)return;const be=me=>{W.current?.contains(me.target)||(Je(),R(!1),N(null))},Xe=me=>{me.key==="Escape"&&(Je(),R(!1),N(null))};return document.addEventListener("pointerdown",be),document.addEventListener("keydown",Xe),()=>{document.removeEventListener("pointerdown",be),document.removeEventListener("keydown",Xe)}},[fe]),f.jsxs("div",{ref:W,className:"relative",children:[f.jsxs("button",{type:"button","aria-label":t?"Cluster link connected":"Cluster link reconnecting","aria-expanded":fe,"aria-haspopup":"dialog",onClick:()=>N(be=>L1(be)),onMouseEnter:On,onMouseLeave:Mr,className:ae("flex h-8 max-w-[18rem] items-center gap-1.5 rounded-sm px-2 text-[10px] transition-all sm:gap-2 sm:px-2.5 sm:text-[11px]",t?"bg-muted/40 text-muted-foreground hover:bg-muted/60 hover:text-foreground":"bg-destructive/8 text-destructive hover:bg-destructive/12",fe&&(t?"bg-muted/60 text-foreground":"bg-destructive/12")),title:t?"Cluster link connected":"Cluster link reconnecting",children:[f.jsxs("span",{className:ae("relative flex h-2 w-2 shrink-0"),children:[t&&f.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-60"}),f.jsx("span",{className:ae("relative inline-flex h-2 w-2 rounded-full",t?"bg-emerald-500":"bg-destructive")})]}),f.jsxs("span",{className:"hidden min-w-0 items-center gap-2 sm:flex",children:[f.jsx("span",{className:"truncate font-medium text-foreground",children:Y}),f.jsx("span",{className:ae("shrink-0 rounded border px-1 py-px text-[8px] font-semibold uppercase tracking-[0.1em]",t?"border-emerald-500/25 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-destructive/30 bg-destructive/10 text-destructive"),children:ee})]})]}),fe&&f.jsxs("div",{role:"dialog","aria-label":"Live link connection events",onMouseEnter:Mn,onMouseLeave:va,className:"absolute right-0 top-[calc(100%+0.35rem)] z-50 w-[17rem] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-sm border border-border/60 bg-popover/98 shadow-[0_16px_44px_-34px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-sm max-sm:fixed max-sm:right-3 max-sm:top-[3.75rem] max-sm:w-[calc(100vw-1.5rem)]",children:[f.jsx("div",{className:"border-b border-border/60 bg-muted/25 px-2.5 py-1.5",children:f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[t?f.jsx(Ui,{className:"h-3 w-3 text-emerald-500"}):f.jsx(LT,{className:"h-3 w-3 text-destructive"}),f.jsx("span",{className:"text-[10px] font-semibold text-foreground",children:"Live link"}),f.jsx("span",{className:"text-[9px] text-muted-foreground",children:t?"· SSE connected":"· reconnecting"})]}),f.jsx("div",{className:ae("rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.12em]",t?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-destructive/30 bg-destructive/10 text-destructive"),children:t?"Connected":"Retrying"})]})}),f.jsxs("div",{className:"grid grid-cols-2 border-b border-border/60",children:[f.jsxs("div",{className:"border-r border-border/60 px-2.5 py-1.5",children:[f.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Events"}),f.jsx("div",{className:"mt-0.5 text-base font-semibold tracking-tight text-foreground",children:se.length})]}),f.jsxs("div",{className:"min-w-0 px-2.5 py-1.5",children:[f.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Latest"}),_?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mt-0.5 truncate text-[9px] leading-snug text-foreground/80",children:_.text}),f.jsx("div",{className:"font-mono text-[8px] text-muted-foreground/60",children:_.time})]}):f.jsx("div",{className:"mt-0.5 text-[8px] text-muted-foreground/50",children:"—"})]})]}),f.jsxs("div",{className:"border-b border-border/60 px-2.5 py-1.5",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[C?f.jsx(gi,{className:"h-3 w-3 shrink-0 text-destructive"}):V?f.jsx(Ui,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Ro,{className:ae("h-3 w-3 shrink-0",re?"text-emerald-500":"text-muted-foreground")}),f.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Node health"})]}),f.jsx("span",{className:ae("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",C?"border-destructive/30 bg-destructive/10 text-destructive":V?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":re?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-border/70 bg-background/60 text-muted-foreground"),children:X_(B)})]}),B.length>0&&f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:B.map(be=>{const{label:Xe,status:me}=Q_(be,c),He=me==="offline",Qe=me==="busy";return f.jsxs("div",{"aria-label":`${Xe} ${me}`,className:ae("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",He?"bg-destructive/6":Qe?"bg-amber-500/6":"bg-emerald-500/5"),title:`${Xe} ${me}`,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Xe}),He?f.jsx(gi,{className:"h-3 w-3 shrink-0 text-destructive"}):Qe?f.jsx(Av,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Ro,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},be.id)})})]}),Q.length>0&&f.jsxs("div",{className:"border-b border-border/60 px-2.5 py-1.5",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[ue?f.jsx(gi,{className:"h-3 w-3 shrink-0 text-destructive"}):f.jsx(Ro,{className:"h-3 w-3 shrink-0 text-emerald-500"}),f.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"DevTunnel"})]}),f.jsx("span",{className:ae("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",ue?"border-destructive/30 bg-destructive/10 text-destructive":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:Y_(Q)})]}),f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:Q.map(be=>{const{label:Xe,status:me}=G_(be,c),He=me==="failed"||me==="offline",Qe=me!=="healthy"&&me!=="failed"&&me!=="offline",gt=be.devtunnelHealth?.reason?`${Xe} ${me}: ${be.devtunnelHealth.reason}`:`${Xe} ${me}`;return f.jsxs("div",{"aria-label":`${Xe} ${me}`,className:ae("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",He?"bg-destructive/6":Qe?"bg-muted/30":"bg-emerald-500/5"),title:gt,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Xe}),He?f.jsx(gi,{className:"h-3 w-3 shrink-0 text-destructive"}):Qe?f.jsx(Av,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):f.jsx(Ro,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},be.id)})})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-1 px-2 py-1",children:[f.jsxs("button",{type:"button",onClick:()=>H(be=>!be),className:"flex min-w-0 flex-1 items-center justify-between rounded-sm px-0.5 py-0.5 text-left hover:bg-muted/25",children:[f.jsxs("span",{className:"truncate text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:["Notifications ",se.length>0&&`(${se.length})`]}),O?f.jsx(Zl,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):f.jsx(cf,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}),!O&&se.length>0&&f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px] font-medium text-muted-foreground hover:text-foreground",onClick:tr,title:"Clear all notifications",children:"Clear all"})]}),O&&f.jsx("div",{className:"px-2 pb-1.5",children:f.jsx(B_,{events:se,maxHeight:"10rem",density:"compact",emptyTitle:"No connection events yet",emptyDescription:"Node, election, and system events will appear here.",nodeNameById:c,onSelect:nr,onDismiss:be=>K(Xe=>new Set(Xe).add(be))})})]}),J&&u?.detail&&!xe&&f.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border/60 px-2.5 py-1 text-[8px] text-muted-foreground",children:[f.jsx("span",{className:"shrink-0 font-medium uppercase tracking-[0.12em]",children:"Desktop update"}),f.jsx("span",{className:"truncate",title:u.detail,children:u.detail})]}),f.jsxs("div",{className:"flex items-center justify-between gap-1 border-t border-border/60 px-2.5 py-1",children:[f.jsx("div",{children:_r&&f.jsxs("div",{className:"group/restart relative flex items-center",children:[f.jsxs("div",{className:"flex items-center overflow-hidden rounded-sm border border-border/50",children:[f.jsxs(Ct,{type:"button",variant:"ghost",size:"sm",className:ae("relative h-5 overflow-hidden rounded-none border-0 px-1.5 text-[9px] font-medium hover:text-foreground [&_svg]:size-2.5",ne?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>{ba()},disabled:It,"aria-label":Ut,"aria-describedby":"live-link-restart-hint",title:Or,children:[Ne!==null&&f.jsx("span",{role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Ne,className:"pointer-events-none absolute inset-y-0 left-0 bg-primary/24",style:{width:`${Ne}%`}}),Ne===null&&f.jsx(kv,{className:ae("relative z-10 h-2.5 w-2.5",ga&&"animate-pulse")}),f.jsx("span",{className:"relative z-10",children:Ae??In})]}),er&&f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:ae("h-5 rounded-none border-l border-border/50 px-1 text-[9px] hover:text-foreground [&_svg]:size-2.5",ne?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>R(be=>!be),"aria-label":"Open live link actions","aria-expanded":T,title:"Live link actions",children:f.jsx(Zl,{className:"h-2.5 w-2.5"})})]}),er&&T&&f.jsxs("div",{className:"absolute bottom-[calc(100%+0.25rem)] left-0 z-20 min-w-28 overflow-hidden rounded-sm border border-border/70 bg-background text-[9px] shadow-sm",children:[f.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 px-2 py-1 text-left text-muted-foreground hover:bg-muted/55 hover:text-foreground disabled:opacity-45 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",onClick:()=>{it?Yn():ba()},disabled:it?Rt:It,"aria-label":it?"Check for desktop updates":Ut,children:[it?f.jsx(Ai,{className:ae("h-2.5 w-2.5",m&&"animate-spin")}):f.jsx(kv,{className:ae("h-2.5 w-2.5",ga&&"animate-pulse")}),f.jsx("span",{children:gn})]}),hn&&f.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 border-t border-border/50 px-2 py-1 text-left text-muted-foreground hover:bg-muted/55 hover:text-foreground disabled:opacity-45 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",onClick:()=>{Lt()},"aria-label":"Reload dashboard page",children:[f.jsx(Ai,{className:"h-2.5 w-2.5"}),f.jsx("span",{children:"Reload"})]}),pn&&f.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 border-t border-border/50 px-2 py-1 text-left text-muted-foreground hover:bg-muted/55 hover:text-foreground",onClick:()=>{Gn()},disabled:I,"aria-label":"Restart Meshy Desktop",children:[f.jsx(Ai,{className:ae("h-2.5 w-2.5",I&&"animate-spin")}),f.jsx("span",{children:"Restart"})]})]}),f.jsx("span",{id:"live-link-restart-hint",role:"tooltip",className:"pointer-events-none absolute left-6 top-1/2 z-10 -translate-y-1/2 whitespace-nowrap rounded-sm border border-border/70 bg-background px-1.5 py-0.5 text-[8px] text-muted-foreground opacity-0 shadow-sm transition-opacity group-hover/restart:opacity-100 group-focus-within/restart:opacity-100",children:Or})]})}),f.jsxs("div",{className:"flex items-center gap-1",children:[O&&f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:tr,disabled:se.length===0,title:"Clear all notifications",children:"Clear all"}),f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:()=>N(null),children:"Close"})]})]})]})]})}const g0="dark",kr="fluent",Z_="clean",ef="meshy-layout-default-migrated-to-compact",Of="true",F_="compact",W_=new Set(["airy","clean","fluent"]);function J_(t){return t!==null&&W_.has(t)}function wc(t){return t===F_?"fluent":J_(t)?t:null}function e3(t,r){const o=wc(t);return o===Z_&&r!==Of?kr:o??kr}const ac="symphony",B1="default",t3=new Set(["light","dark","system"]),n3=new Set(["porcelain","warm","finsight","edge","symphony","launcher"]),H1=g.createContext(null);function a3(t){const r=new URLSearchParams(t).get("theme");return P1(r)?r:null}function r3(t){const r=new URLSearchParams(t).get("palette");return xm(r)}function o3(t){const r=new URLSearchParams(t).get("layout");return wc(r)}function l3(){if(typeof document>"u")return null;const t=document.documentElement;return{theme:t.classList.contains("dark")?"dark":"light",palette:xm(t.getAttribute("data-palette"))??ac,layout:wc(t.getAttribute("data-layout"))??kr}}function hM(t,r=l3()){if(!r)return t;try{const o=/^[a-z][a-z\d+\-.]*:/i.test(t),s=typeof window<"u"?window.location.href:"http://localhost",c=new URL(t,s);return c.searchParams.set("theme",r.theme),c.searchParams.set("palette",r.palette),c.searchParams.set("layout",r.layout),o?c.toString():`${c.pathname}${c.search}${c.hash}`}catch{return t}}const tf=.9;function v0(t){const r=t.trim().match(/^(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)%\s+(-?\d+(?:\.\d+)?)%$/);if(!r)return null;const o=(Number(r[1])%360+360)%360/60,s=rc(Number(r[2])/100,0,1),c=rc(Number(r[3])/100,0,1),u=(1-Math.abs(2*c-1))*s,m=u*(1-Math.abs(o%2-1)),h=c-u/2,[v,p,b]=o<1?[u,m,0]:o<2?[m,u,0]:o<3?[0,u,m]:o<4?[0,m,u]:o<5?[m,0,u]:[u,0,m];return[Math.round((v+h)*255),Math.round((p+h)*255),Math.round((b+h)*255),255]}function s3(t){const r=t.trim();if(!r||r==="transparent")return null;const o=r.match(/^rgba?\(\s*([+-]?\d+(?:\.\d+)?)\s*,\s*([+-]?\d+(?:\.\d+)?)\s*,\s*([+-]?\d+(?:\.\d+)?)(?:\s*,\s*([+-]?\d+(?:\.\d+)?))?\s*\)$/i);if(o)return[To(Number(o[1])),To(Number(o[2])),To(Number(o[3])),x0(o[4])];const s=r.match(/^rgba?\(\s*([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)(?:\s*\/\s*([+-]?\d+(?:\.\d+)?%?))?\s*\)$/i);return s?[To(Number(s[1])),To(Number(s[2])),To(Number(s[3])),x0(s[4])]:null}function i3(t,r,o){const s=v0(t);if(!s)return null;if(o==="clean"||o==="fluent")return s;const c=v0(r);return c?[nf(s[0],c[0],tf),nf(s[1],c[1],tf),nf(s[2],c[2],tf),255]:null}function c3(){const t=document.querySelector(".dashboard-shell-header-panel");if(!t)return null;const r=s3(getComputedStyle(t).backgroundColor);return!r||r[3]===0?null:r}function y0(){if(typeof window>"u"||typeof document>"u")return;const t=window.__TAURI__?.core?.invoke??null;if(!t)return;const r=document.documentElement,o=r.classList.contains("dark")?"dark":"light",s=getComputedStyle(r),c=wc(r.getAttribute("data-layout"))??kr,u=c3()??i3(s.getPropertyValue("--card"),s.getPropertyValue("--background"),c);t("sync_desktop_theme",{theme:o,backgroundColor:u}).catch(()=>{})}function b0(){if(typeof window>"u")return()=>{};if(y0(),typeof window.requestAnimationFrame!="function")return()=>{};const t=window.requestAnimationFrame(()=>y0());return()=>window.cancelAnimationFrame(t)}function nf(t,r,o){return Math.round(t*o+r*(1-o))}function rc(t,r,o){return Math.min(Math.max(t,r),o)}function To(t){return Math.round(rc(t,0,255))}function x0(t){if(t==null||t==="")return 255;const r=t.endsWith("%")?Number(t.slice(0,-1))/100:Number(t);return Math.round(rc(r,0,1)*255)}function u3({children:t}){const[r,o]=g.useState(()=>typeof window<"u"?a3(window.location.search)??m3(localStorage.getItem("meshy-theme"))??g0:g0),[s,c]=g.useState(()=>typeof window<"u"?r3(window.location.search)??h3(localStorage.getItem("meshy-palette"))??ac:ac),[u,m]=g.useState(()=>{if(typeof window<"u"){const h=o3(window.location.search);if(h)return localStorage.setItem(ef,Of),h;const v=e3(localStorage.getItem("meshy-layout"),localStorage.getItem(ef));return localStorage.setItem(ef,Of),v}return kr});return g.useEffect(()=>{const h=document.documentElement,v=p=>{if(p==="system"){const b=window.matchMedia("(prefers-color-scheme: dark)").matches;h.classList.toggle("dark",b)}else h.classList.toggle("dark",p==="dark")};if(v(r),localStorage.setItem("meshy-theme",r),r==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)"),b=()=>{v("system"),b0()};return p.addEventListener("change",b),()=>p.removeEventListener("change",b)}},[r]),g.useEffect(()=>{document.documentElement.setAttribute("data-palette",s),localStorage.setItem("meshy-palette",s)},[s]),g.useEffect(()=>{const h=document.documentElement;u===kr?h.removeAttribute("data-layout"):h.setAttribute("data-layout",u),localStorage.setItem("meshy-layout",u)},[u]),g.useEffect(()=>b0(),[r,s,u]),f.jsx(H1.Provider,{value:{theme:r,setTheme:o,palette:s,setPalette:c,layout:u,setLayout:m},children:t})}function d3(){const t=g.useContext(H1);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function P1(t){return t!==null&&t3.has(t)}function f3(t){return t!==null&&n3.has(t)}function m3(t){return P1(t)?t:null}function xm(t){return t===B1?"porcelain":f3(t)?t:null}function h3(t){return t===B1?null:xm(t)}const p3=[{value:"light",label:"Light",icon:my},{value:"dark",label:"Dark",icon:dy},{value:"system",label:"System",icon:uy}],$1=[{value:"finsight",label:"FinSight",hint:"Cool sage green"},{value:"porcelain",label:"Porcelain",hint:"Blue workspace"},{value:"warm",label:"Warm",hint:"Cream + amber"},{value:"edge",label:"Edge",hint:"Rounded violet panels"},{value:"symphony",label:"Symphony",hint:"Near-black rose accent"},{value:"launcher",label:"Launcher",hint:"Desktop startup blue"}],q1=[{value:"airy",label:"Airy",hint:"Gradients, blur, spacious"},{value:"clean",label:"Clean",hint:"Flat, borders, high density"},{value:"fluent",label:"Fluent",hint:"Compact neutral"}];function g3(){const{theme:t,setTheme:r,palette:o,setPalette:s,layout:c,setLayout:u}=d3(),[m,h]=g.useState(null),v=g.useRef(null),p=g.useRef(null),b=z1(m),y=t==="dark"?dy:t==="light"?my:uy,w=()=>{v.current&&(clearTimeout(v.current),v.current=null)},k=()=>{w(),v.current=setTimeout(()=>h(A=>_f(A)),180)};return g.useEffect(()=>{if(!b)return;const A=E=>{p.current&&!p.current.contains(E.target)&&h(null)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[b]),g.useEffect(()=>()=>w(),[]),f.jsxs("div",{ref:p,className:"relative",onMouseEnter:()=>{w(),h(A=>U1(A))},onMouseLeave:k,children:[f.jsx(Ct,{variant:"ghost",size:"icon",onClick:()=>h(A=>L1(A)),className:ae("h-8 w-8 rounded-sm",o!==ac||c!==kr?"text-primary":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),title:"Appearance","aria-haspopup":"menu","aria-expanded":b,children:f.jsx(y,{className:"h-4 w-4"})}),b&&f.jsxs("div",{role:"menu",className:"fixed left-2 right-2 top-[4.25rem] z-50 w-auto max-w-none rounded-md border border-border/70 bg-popover/95 p-2 text-popover-foreground shadow-[0_24px_70px_-32px_rgba(0,0,0,0.45)] backdrop-blur-xl sm:absolute sm:left-auto sm:right-0 sm:top-[calc(100%+6px)] sm:w-[23rem] sm:max-w-[23rem]",children:[f.jsxs("div",{className:"mb-2 flex items-end justify-between gap-2",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Appearance"}),f.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:[v3(c)," / ",y3(o)]})]}),f.jsx("div",{className:"rounded-sm border border-border/60 bg-background/70 px-1.5 py-0.5 text-[8px] font-medium capitalize text-muted-foreground",children:t})]}),f.jsx("div",{className:"px-0.5 pb-1 text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Theme"}),f.jsx("div",{className:"mb-2 grid grid-cols-3 gap-1 rounded-sm bg-muted/35 p-0.5",children:p3.map(({value:A,label:E,icon:N})=>{const T=t===A;return f.jsxs("button",{type:"button",onClick:()=>r(A),role:"menuitemradio","aria-checked":T,className:ae("flex min-h-[2.1rem] flex-col items-center justify-center gap-0.5 rounded-sm border px-1.5 py-1 text-[9px] font-medium transition-colors",T?"border-primary/55 bg-background text-primary shadow-sm":"border-transparent text-muted-foreground hover:border-border/70 hover:bg-background/80 hover:text-foreground"),children:[f.jsx(N,{className:"h-3 w-3"}),E]},A)})}),f.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[f.jsxs("div",{children:[f.jsx("div",{className:"px-0.5 pb-1 text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Layout"}),f.jsx("div",{className:"space-y-1",children:q1.map(({value:A,label:E,hint:N})=>{const T=c===A;return f.jsxs("button",{type:"button",onClick:()=>u(A),role:"menuitemradio","aria-checked":T,className:ae("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",T?"border-primary/55 bg-primary/10":"border-border/45 bg-background/45 hover:border-border hover:bg-muted/55"),children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:ae("text-[10px] font-medium leading-tight",T?"text-primary":"text-foreground"),children:E}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:N})]}),T&&f.jsx(Li,{className:"h-3 w-3 text-primary"})]},A)})})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-1.5 px-0.5 pb-1 text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:[f.jsx(_T,{className:"h-2.5 w-2.5"}),"Palette"]}),f.jsx("div",{className:"space-y-1",children:$1.map(({value:A,label:E,hint:N})=>{const T=o===A;return f.jsxs("button",{type:"button",onClick:()=>s(A),role:"menuitemradio","aria-checked":T,className:ae("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",T?"border-primary/55 bg-primary/10":"border-border/45 bg-background/45 hover:border-border hover:bg-muted/55"),children:[f.jsx(b3,{value:A}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:ae("text-[10px] font-medium leading-tight",T?"text-primary":"text-foreground"),children:E}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:N})]}),T&&f.jsx(Li,{className:"h-3 w-3 text-primary"})]},A)})})]})]})]})]})}function v3(t){return q1.find(r=>r.value===t)?.label??t}function y3(t){return $1.find(r=>r.value===t)?.label??t}function b3({value:t}){const r={porcelain:["hsl(212 76% 44%)","hsl(210 22% 98%)","hsl(174 42% 61%)"],warm:["hsl(35 88% 56%)","hsl(42 22% 97%)","hsl(160 60% 45%)"],finsight:["hsl(152 38% 32%)","hsl(150 14% 97%)","hsl(142 55% 58%)"],edge:["hsl(265 75% 55%)","hsl(260 12% 98%)","hsl(285 70% 65%)"],symphony:["hsl(348 100% 71%)","hsl(0 0% 6%)","hsl(240 2% 9%)"],launcher:["hsl(213 77% 49%)","hsl(60 10% 96%)","hsl(0 0% 100%)"]},[o,s,c]=r[t];return f.jsxs("div",{className:ae("flex h-5 w-5 shrink-0 overflow-hidden border border-border/60 shadow-sm","rounded-sm"),children:[f.jsx("div",{className:"h-full w-1/3",style:{background:o}}),f.jsx("div",{className:"h-full w-1/3",style:{background:s}}),f.jsx("div",{className:"h-full w-1/3",style:{background:c}})]})}const Xl={tasks:{defaultSize:20,min:16,max:36,wheelStep:1},operations:{defaultSize:20,min:18,max:38,wheelStep:1},terminal:{defaultSize:18,min:10,max:30,wheelStep:1}},V1="meshy-dashboard-panel-state-v2",I1="meshy-dashboard-terminal-open-v1";function pM({operationsOpen:t}){return{layout:{desktopTasksOpen:!0,operationsOpen:t},sizes:{tasks:Xl.tasks.defaultSize,operations:Xl.operations.defaultSize,terminal:Xl.terminal.defaultSize}}}function af(t){return typeof t=="object"&&t!==null}function S0(t,r){return typeof t=="boolean"?t:r}function rf(t,r,o){return typeof r=="number"&&Number.isFinite(r)?Ql(t,r):o}function Ql(t,r){const o=Xl[t];return Math.min(o.max,Math.max(o.min,r))}function gM(t,r){if(!t)return r;try{const o=t.getItem(V1);if(!o)return r;const s=JSON.parse(o);if(!af(s))return r;const c=af(s.layout)?s.layout:{},u=af(s.sizes)?s.sizes:{};return{layout:{desktopTasksOpen:S0(c.desktopTasksOpen,r.layout.desktopTasksOpen),operationsOpen:S0(c.operationsOpen,r.layout.operationsOpen)},sizes:{tasks:rf("tasks",u.tasks,r.sizes.tasks),operations:rf("operations",u.operations,r.sizes.operations),terminal:rf("terminal",u.terminal,r.sizes.terminal)}}}catch{return r}}function vM(t,r){if(t)try{t.setItem(V1,JSON.stringify(r))}catch{}}function x3(t,r){if(!t)return r;try{const o=t.getItem(I1);return o==="true"?!0:o==="false"?!1:r}catch{return r}}function S3(t,r){if(t)try{t.setItem(I1,String(r))}catch{}}function w0(){try{return globalThis.window?.localStorage??globalThis.localStorage??null}catch{return null}}function yM(t){return`${Number(t.toFixed(2))}rem`}function bM(t,r,o,s,c,u,m){const h=Number.isFinite(m)&&m>0?m:16;return t==="tasks"?Ql(t,r+(c-o)/h):t==="operations"?Ql(t,r+(o-c)/h):Ql(t,r+(s-u)/h)}function xM(t,r,o){const s=o===0?0:o>0?-1:1;return Ql(t,r+s*Xl[t].wheelStep)}const w3=7200*1e3,E3=15*1e3,N3="meshy://desktop-update-progress",T3="Desktop update check timed out";function C3(){return f.jsxs("svg",{"data-meshy-app-icon":"header",viewBox:"0 0 1024 1024",className:"h-8 w-8","aria-hidden":"true",children:[f.jsxs("defs",{children:[f.jsxs("linearGradient",{id:"meshy-header-icon-bg",x1:"160",y1:"128",x2:"864",y2:"896",gradientUnits:"userSpaceOnUse",children:[f.jsx("stop",{offset:"0",stopColor:"#182033"}),f.jsx("stop",{offset:"1",stopColor:"#0a0f1f"})]}),f.jsxs("linearGradient",{id:"meshy-header-icon-edge",x1:"260",y1:"244",x2:"768",y2:"780",gradientUnits:"userSpaceOnUse",children:[f.jsx("stop",{offset:"0",stopColor:"#66e3ff"}),f.jsx("stop",{offset:"0.52",stopColor:"#8fd56b"}),f.jsx("stop",{offset:"1",stopColor:"#ffcb5b"})]})]}),f.jsx("rect",{width:"1024",height:"1024",rx:"224",fill:"url(#meshy-header-icon-bg)"}),f.jsx("path",{d:"M308 652V372l204 174 204-174v280",fill:"none",stroke:"url(#meshy-header-icon-edge)",strokeWidth:"86",strokeLinecap:"round",strokeLinejoin:"round"}),f.jsx("circle",{cx:"308",cy:"372",r:"58",fill:"#66e3ff"}),f.jsx("circle",{cx:"512",cy:"546",r:"58",fill:"#8fd56b"}),f.jsx("circle",{cx:"716",cy:"372",r:"58",fill:"#ffcb5b"}),f.jsx("circle",{cx:"308",cy:"652",r:"58",fill:"#66e3ff"}),f.jsx("circle",{cx:"716",cy:"652",r:"58",fill:"#ffcb5b"})]})}function Vl(){return typeof window>"u"?null:window.__TAURI__?.core?.invoke??null}function R3(){return typeof window>"u"?null:window.__TAURI__?.event?.listen??null}function A3(t){if(!t||typeof t!="object")return null;const r=t;return r.phase!=="downloading"&&r.phase!=="installing"&&r.phase!=="complete"?null:{phase:r.phase,receivedBytes:typeof r.receivedBytes=="number"?r.receivedBytes:0,totalBytes:typeof r.totalBytes=="number"?r.totalBytes:null,percent:typeof r.percent=="number"?Math.max(0,Math.min(100,Math.round(r.percent))):null}}function E0(t){return{currentVersion:null,latestVersion:null,updateAvailable:!1,checkedAt:new Date().toISOString(),releaseUrl:null,assetName:null,installable:!1,detail:t}}async function k3(t,r,o){let s;const c=new Promise((u,m)=>{s=setTimeout(()=>{m(new Error(T3))},r)});try{return await Promise.race([t,c])}finally{s!==void 0&&clearTimeout(s)}}async function j3({activeCheck:t,startCheck:r,timeoutMs:o,shouldApply:s,applyUpdate:c,applyFailure:u,failureFallback:m="Desktop update check failed"}){let h=t.current;if(!h){let v;try{v=r()}catch(p){v=Promise.reject(p)}h=k3(v,o),t.current=h}try{const v=await h;return s()&&c(v),v}catch(v){return s()&&u(Mf(v,m)),null}finally{t.current===h&&(t.current=null)}}function Mf(t,r){if(t instanceof Error&&t.message.trim())return t.message;if(typeof t=="string"&&t.trim())return t;if(t&&typeof t=="object"&&"message"in t){const o=t.message;if(typeof o=="string"&&o.trim())return o}return r}function _3(t){return t.openedRelease?"Opened the latest Meshy release page.":t.installMethod==="tauri-updater"?"Installing desktop update. Meshy will relaunch to finish updating.":(t.assetName??"desktop update").toLowerCase().endsWith(".dmg")?"Downloaded desktop update. Open the DMG and drag Meshy to Applications to finish updating.":"Downloaded desktop update. Follow the installer to finish updating."}function O3(){const{cluster:t,events:r,sseConnected:o,systemInfo:s}=ay(),c=jn(),[u,m]=g.useState(()=>x3(w0(),!1)),[h,v]=g.useState(""),[p,b]=g.useState(null),[y,w]=g.useState(null),[k,A]=g.useState(!1),[E,N]=g.useState(null),T=g.useRef(null),R=!!Vl(),O=R?"max-w-none":"max-w-[1760px]",H=c.pathname==="/"||/^\/tasks\/[^/]+$/.test(c.pathname),z=g.useMemo(()=>{const W=new Map;for(const te of t?.nodes??[])W.set(te.id,te.name);return t?.self&&W.set(t.self.id,t.self.name),W},[t?.nodes,t?.self]),K=g.useCallback(W=>{m(te=>typeof W=="function"?W(te):W)},[]);g.useEffect(()=>{S3(w0(),u)},[u]);const I=g.useCallback(async(W=!0,te=()=>!0)=>{const se=Vl();return se?(W&&te()&&w(E0("Checking desktop update...")),j3({activeCheck:T,startCheck:()=>se("check_desktop_update"),timeoutMs:E3,shouldApply:te,applyUpdate:X=>w(X),applyFailure:X=>w(_=>_?.updateAvailable?_:E0(X))})):(te()&&w(null),null)},[]);async function P(){A(!0);try{await I(!1)}finally{A(!1)}}g.useEffect(()=>{if(!Vl()){w(null);return}let W=!1;const te=()=>!W;I(!0,te);const se=window.setInterval(()=>{I(!1,te)},w3);return()=>{W=!0,window.clearInterval(se)}},[I,s?.version]),g.useEffect(()=>{const W=R3();if(!W)return;let te=!1,se;return W(N3,X=>{const _=A3(X.payload);_&&N(_)}).then(X=>{if(te){X();return}se=X}).catch(()=>{}),()=>{te=!0,se?.()}},[]);async function le(){try{const W=await ey({reason:"restart"});Ce.info(`Restarting runtime. Follow ${W.logPath} for launch output.`),await _1({previousPid:W.pid})||Ce.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout.")}catch(W){Ce.error(W instanceof Error?W.message:"Runtime restart failed")}}async function de(){const W=Vl();if(!W){Ce.error("Desktop updater is not available in this window");return}try{Ce.info("Downloading desktop update..."),N({phase:"downloading",receivedBytes:0,totalBytes:null,percent:0});const te=await W("install_desktop_update");N({phase:"complete",receivedBytes:1,totalBytes:1,percent:100}),Ce.info(_3(te))}catch(te){Ce.error(Mf(te,"Desktop update failed"))}finally{N(null)}}async function fe(){const W=Vl();if(!W){Ce.error("Desktop restart is not available in this window");return}try{Ce.info("Restarting Meshy Desktop..."),await W("restart_desktop_app")}catch(te){Ce.error(Mf(te,"Desktop restart failed"))}}return f.jsxs("div",{className:"relative h-full overflow-hidden bg-background text-foreground",children:[f.jsx("div",{className:"mesh-grid pointer-events-none absolute inset-0"}),f.jsxs("div",{className:"relative z-10 flex h-full min-h-0 flex-col",children:[f.jsx("header",{className:"dashboard-shell-header relative z-50 shrink-0 px-2 py-2",children:f.jsxs("div",{className:ae("dashboard-shell-header-panel dashboard-panel dashboard-panel-muted animate-panel-settle mx-auto flex items-center gap-0 rounded-lg px-3 py-2",O),children:[f.jsx("div",{className:"flex shrink-0 items-center gap-3 pr-3",children:f.jsxs(sf,{to:"/","aria-label":"Meshy home",className:"flex items-center gap-2",children:[f.jsx(C3,{}),f.jsxs("div",{className:"hidden min-w-0 items-baseline gap-1.5 sm:flex",children:[f.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:"MESHY"}),f.jsx("span",{className:"truncate text-[13px] font-semibold tracking-tight text-foreground",children:"Workspace"})]})]})}),f.jsx("div",{className:"mx-0 hidden h-4 w-px shrink-0 bg-border/50 md:block"}),H&&f.jsxs("div",{className:"hidden min-w-0 flex-1 items-center px-3 md:flex",children:[p&&f.jsxs("nav",{"aria-label":"Current task location",className:"flex min-w-0 max-w-[38rem] items-center gap-1 rounded-sm bg-background/55 px-2 py-1 text-[10px] text-muted-foreground",children:[f.jsxs("button",{type:"button",onClick:()=>v(p.nodeName),className:"flex min-w-0 items-center gap-1 rounded-sm px-1 py-0.5 hover:bg-muted/60 hover:text-foreground",title:`Filter by ${p.nodeName}`,children:[f.jsx(fy,{className:"h-3 w-3 shrink-0 text-primary/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.nodeName})]}),f.jsx(cf,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsxs("button",{type:"button",onClick:()=>v(p.projectLabel),className:"flex min-w-0 items-center gap-1 rounded-sm px-1 py-0.5 hover:bg-muted/60 hover:text-foreground",title:p.projectPath,children:[f.jsx(nT,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.projectLabel})]}),f.jsx(cf,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsx(sf,{to:`/tasks/${p.taskId}`,className:"min-w-0 truncate px-1 font-medium text-foreground/85 hover:text-foreground",title:p.taskTitle,children:p.taskTitle})]}),f.jsxs("div",{className:"relative ml-auto w-[18rem] max-w-[28rem]",children:[f.jsx(NT,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/60"}),f.jsx(xc,{"aria-label":"Search tasks",value:h,onChange:W=>v(W.target.value),placeholder:"Search tasks, nodes, workspaces",className:"h-8 rounded-sm border-0 bg-background/62 pl-8 pr-2 text-[11px] shadow-none focus-visible:ring-0 focus-visible:ring-offset-0"})]})]}),f.jsx("div",{className:"mx-0 hidden h-4 w-px shrink-0 bg-border/50 md:block"}),f.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5 pl-3 sm:gap-2 md:ml-0",children:[H&&f.jsx(Ct,{variant:"ghost",size:"icon",onClick:()=>K(W=>!W),"aria-label":u?"Close terminal":"Open terminal",title:u?"Close terminal":"Open terminal",className:ae("h-8 w-8 rounded-sm text-muted-foreground hover:bg-muted/50 hover:text-foreground",u&&"bg-primary/8 text-primary"),children:f.jsx(hy,{className:"h-4 w-4"})}),f.jsx(O_,{}),f.jsx(g3,{}),f.jsx("div",{className:"mx-0 h-4 w-px shrink-0 bg-border/50"}),f.jsx(K_,{connected:o,events:r,nodes:t?.nodes??[],currentNode:t?.self??null,nodeNameById:z,desktopUpdate:y,desktopUpdateCheckPending:k,desktopUpdateProgress:E,onDesktopUpdateCheck:R?P:void 0,onDesktopUpdate:y?.updateAvailable?de:void 0,onDesktopRestart:R?fe:void 0,onReload:R?()=>window.location.reload():void 0,onRestart:le})]})]})}),f.jsx("main",{className:ae("dashboard-shell-main min-h-0 flex-1 px-2 pb-2",H?"overflow-hidden":"overflow-y-auto"),children:f.jsx("div",{className:ae("dashboard-shell-content mx-auto h-full min-h-0",O),children:f.jsx(cE,{context:{terminalOpen:u,setTerminalOpen:K,headerSearchQuery:h,setHeaderSearchQuery:v,setHeaderTaskContext:b}})})})]})]})}const N0=g.lazy(async()=>({default:(await R0(()=>import("./DashboardPage-bZy6ZY6K.js").then(r=>r.D),__vite__mapDeps([0,1,2,3,4]))).DashboardPage})),M3=g.lazy(async()=>({default:(await R0(()=>import("./SharedConversationPage-CTyYVCbw.js"),__vite__mapDeps([5,1]))).SharedConversationPage}));function D3(){return f.jsx(zE,{children:f.jsx(g.Suspense,{fallback:f.jsx(z3,{}),children:f.jsxs(dE,{children:[f.jsx(Nr,{path:"/shared/tasks/:shareId",element:f.jsx(M3,{})}),f.jsxs(Nr,{element:f.jsx(AN,{children:f.jsx(O3,{})}),children:[f.jsx(Nr,{path:"/",element:f.jsx(N0,{})}),f.jsx(Nr,{path:"/nodes",element:f.jsx(Ev,{to:"/",replace:!0})}),f.jsx(Nr,{path:"/tasks",element:f.jsx(Ev,{to:"/",replace:!0})}),f.jsx(Nr,{path:"/tasks/:id",element:f.jsx(N0,{})})]})]})})})}function z3(){return f.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading workspace..."})}function U3(t){const r=t??(typeof window>"u"?void 0:window);r?.__TAURI__&&r.addEventListener("contextmenu",o=>{o.preventDefault()})}function L3(t){const{className:r,style:o,toastOptions:s,...c}=t;function u(m){const h=m.target;if(!(h instanceof Element)||h.closest("button, a, input, textarea, select, [data-close-button], [data-button]"))return;const v=h.closest("[data-sonner-toast]");v&&v.dataset.type!=="loading"&&M1()}return f.jsx("div",{onClick:u,children:f.jsx(eR,{className:["toaster group",r].filter(Boolean).join(" "),closeButton:!0,gap:6,offset:{right:"0.6rem",bottom:"0.6rem"},mobileOffset:{right:"0.5rem",bottom:"0.5rem",left:"0.5rem"},position:"bottom-right",visibleToasts:3,style:{"--normal-bg":"hsl(var(--popover))","--normal-text":"hsl(var(--popover-foreground))","--normal-border":"hsl(var(--border) / 0.7)","--width":"17rem",...o},toastOptions:{duration:3e3,closeButton:!0,...s,classNames:{toast:"meshy-toast",title:"meshy-toast__title",description:"meshy-toast__description",content:"meshy-toast__content",icon:"meshy-toast__icon",closeButton:"meshy-toast__close",actionButton:"meshy-toast__action",cancelButton:"meshy-toast__cancel",success:"meshy-toast--success",error:"meshy-toast--error",info:"meshy-toast--info",warning:"meshy-toast--warning",...s?.classNames}},...c})})}U3();i2.createRoot(document.getElementById("root")).render(f.jsx(g.StrictMode,{children:f.jsxs(u3,{children:[f.jsx(D3,{}),f.jsx(L3,{})]})}));export{qO as $,Af as A,Ct as B,Li as C,IO as D,fO as E,eT as F,$A as G,pb as H,xc as I,vb as J,hM as K,iy as L,ly as M,y1 as N,Qx as O,hT as P,fM as Q,cy as R,fy as S,YO as T,Yl as U,IN as V,Rj as W,py as X,GO as Y,Yf as Z,nj as _,uM as a,uO as a$,VO as a0,_t as a1,lM as a2,Gl as a3,Cf as a4,Qi as a5,Ki as a6,Fi as a7,Wi as a8,Zi as a9,B_ as aA,vj as aB,sy as aC,yj as aD,sM as aE,Nj as aF,MO as aG,fR as aH,KO as aI,iM as aJ,cM as aK,XO as aL,QO as aM,rM as aN,A1 as aO,oM as aP,Rf as aQ,zT as aR,SO as aS,wO as aT,gM as aU,pM as aV,w0 as aW,vM as aX,xM as aY,yM as aZ,bM as a_,ec as aa,Ji as ab,R0 as ac,q3 as ad,gb as ae,IA as af,aO as ag,hy as ah,Ro as ai,uf as aj,nO as ak,rO as al,tO as am,zO as an,I3 as ao,Y3 as ap,qA as aq,yb as ar,Ai as as,LT as at,RT as au,LN as av,uT as aw,ts as ax,nM as ay,yT as az,oR as b,SN as b0,nN as b1,LO as b2,UO as b3,BO as b4,NN as b5,yO as b6,Q3 as b7,G3 as b8,J0 as b9,Tj as bA,gO as bB,vO as bC,pO as bD,hO as bE,$3 as bF,V3 as bG,P3 as bH,Z3 as bI,$O as bJ,RO as bK,CO as bL,TO as bM,EO as bN,NO as bO,AO as bP,g1 as bQ,Pk as bR,PO as bS,Hk as bT,T0 as bU,_O as bV,jO as bW,kO as bX,OO as bY,HO as bZ,DO as b_,X3 as ba,K3 as bb,O_ as bc,bO as bd,xO as be,iO as bf,oO as bg,lO as bh,sO as bi,cO as bj,H3 as bk,jn as bl,V0 as bm,B3 as bn,ay as bo,aM as bp,Gj as bq,mM as br,tM as bs,ZO as bt,FO as bu,JO as bv,WO as bw,eM as bx,dO as by,Ej as bz,ke as c,ae as d,Oy as e,x1 as f,W3 as g,eO as h,W0 as i,f as j,F3 as k,nT as l,dM as m,cf as n,ua as o,J3 as p,mO as q,g as r,Ef as s,Ce as t,Gi as u,Nf as v,Xi as w,NT as x,Zl as y,_T as z};