meshy-node 0.9.8 → 0.9.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-D5Gk6vkS.js","assets/DashboardShared-CdOWTY_U.js","assets/MarkdownPreviewFrame-Bf2NJ862.js","assets/PreviewTab-CO-6Sjwr.js","assets/DashboardPage-i714dDoR.css","assets/SharedConversationPage-DVAMKKX3.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-DbD4Z2U0.js","assets/DashboardShared-1UhBYL1-.js","assets/MarkdownPreviewFrame-CH3rgET1.js","assets/PreviewTab-C5m4cFxf.js","assets/DashboardPage-i714dDoR.css","assets/SharedConversationPage-CtQLabVf.js"])))=>i.map(i=>d[i]);
2
2
  var Rw=Object.defineProperty;var Cw=(n,r,o)=>r in n?Rw(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o;var ot=(n,r,o)=>Cw(n,typeof r!="symbol"?r+"":r,o);function Aw(n,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 n)){const u=Object.getOwnPropertyDescriptor(s,c);u&&Object.defineProperty(n,c,u.get?u:{enumerable:!0,get:()=>s[c]})}}}return Object.freeze(Object.defineProperty(n,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 f0(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Nd={exports:{}},Ol={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -338,4 +338,4 @@ You can add a description to the \`${To}\` by passing a \`${Ux}\` component as a
338
338
 
339
339
  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 \`${To}\`. 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.
340
340
 
341
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return v.useEffect(()=>{var s;document.getElementById((s=n.current)==null?void 0:s.getAttribute("aria-describedby"))||console.warn(r)},[r,n]),null},qk=jx,Vk=_x,Yk=Mx,qx=Ox,Vx=Dx,Yx=Hx,Gx=Px,Ix=Lx,Xx=Bx;const yf=qk,bf=Vk,Gk=Yk,Qx=v.forwardRef(({className:n,...r},o)=>f.jsx(qx,{className:ne("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",n),...r,ref:o}));Qx.displayName=qx.displayName;const Yi=v.forwardRef(({className:n,...r},o)=>f.jsxs(Gk,{children:[f.jsx(Qx,{}),f.jsx(Vx,{ref:o,className:ne("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%]",n),...r})]}));Yi.displayName=Vx.displayName;const Gi=({className:n,...r})=>f.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",n),...r});Gi.displayName="AlertDialogHeader";const Ii=({className:n,...r})=>f.jsx("div",{className:ne("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...r});Ii.displayName="AlertDialogFooter";const Xi=v.forwardRef(({className:n,...r},o)=>f.jsx(Ix,{ref:o,className:ne("text-sm font-semibold",n),...r}));Xi.displayName=Ix.displayName;const Qi=v.forwardRef(({className:n,...r},o)=>f.jsx(Xx,{ref:o,className:ne("text-[11px] text-muted-foreground",n),...r}));Qi.displayName=Xx.displayName;const Ki=v.forwardRef(({className:n,...r},o)=>f.jsx(Yx,{ref:o,className:ne(zf(),n),...r}));Ki.displayName=Yx.displayName;const Zi=v.forwardRef(({className:n,...r},o)=>f.jsx(Gx,{ref:o,className:ne(zf({variant:"outline"}),"mt-2 sm:mt-0",n),...r}));Zi.displayName=Gx.displayName;const Ik={online:"bg-emerald-500",busy:"bg-amber-500",offline:"bg-destructive"};function Xk({status:n}){return f.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5",children:[n==="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:ne("relative inline-flex h-2.5 w-2.5 rounded-full",Ik[n])})]})}function Qk({role:n,size:r="default"}){return f.jsx(Et,{variant:n==="leader"?"default":"secondary",className:ne(r==="compact"?"px-1.5 py-0 text-[9px] leading-4":"text-[11px]"),children:n})}const Kx={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 K3({status:n,size:r="default"}){const o=Kx[n],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(Et,{variant:o.variant,className:ne("rounded-sm font-medium shadow-none",s,o.className),children:[f.jsx("span",{className:ne("rounded-full",o.dotClass)}),n]})}function Z3({status:n,isNative:r=!1,size:o="default",className:s}){const c=Kx[n],u=[n,r?"native":null].filter(Boolean).join(", "),m=o==="compact"?"h-1.5 w-1.5":"h-2 w-2";return f.jsxs("span",{className:ne("inline-flex shrink-0 items-center gap-1",s),title:u,"aria-label":u,children:[f.jsx("span",{className:ne("rounded-full",m,c.dotClass),title:n}),r&&f.jsx("span",{className:ne("rounded-full bg-sky-500",m),title:"native"})]})}const Kk={critical:{variant:"destructive",label:"Critical"},high:{variant:"outline",label:"High"},normal:{variant:"secondary",label:"Normal"},low:{variant:"secondary",label:"Low"}};function F3({priority:n}){const r=Kk[n];return f.jsx(Et,{variant:r.variant,className:"rounded-sm px-1.5 py-0 text-[10px] leading-4 shadow-none",children:r.label})}function Zk(n){return[{key:"workspace",label:"Workspace",value:n==null?void 0:n.workspace},{key:"node",label:"Node app",value:n==null?void 0:n.node},{key:"core",label:"Core",value:n==null?void 0:n.core},{key:"dashboard",label:"Dashboard",value:n==null?void 0:n.dashboard},{key:"api",label:"API",value:n==null?void 0:n.api}].filter(o=>o.value)}function yo({label:n,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:n}),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 Fk({formatDateTime:n,viewInfo:r}){var s,c,u,m,h,y,p,b;const o=Zk(r.packages);return f.jsxs(Yl,{value:"about","data-about-layout":"compact",className:"mt-0 space-y-2",children:[f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(uN,{className:"h-3.5 w-3.5 text-primary"}),"Repository & runtime"]}),f.jsx(Un,{className:"text-[10px]",children:"Build source and runtime identity for this node."})]}),f.jsxs(Bn,{className:"space-y-2 px-3 pb-2.5",children:[(s=r.repository)!=null&&s.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(kN,{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(yo,{label:"Branch",value:((c=r.repository)==null?void 0:c.branch)??"Unavailable",mono:!!((u=r.repository)!=null&&u.branch)}),f.jsx(yo,{label:"Commit",value:((m=r.repository)==null?void 0:m.commit)??"Unavailable",mono:!!((h=r.repository)!=null&&h.commit)}),f.jsx(yo,{label:"Runtime",value:`${r.packageName??"meshy"} ${r.version}`,mono:!0}),f.jsx(yo,{label:"Node.js",value:((y=r.runtime)==null?void 0:y.nodeVersion)??"Unavailable",mono:!!((p=r.runtime)!=null&&p.nodeVersion)}),f.jsx(yo,{label:"PID",value:r.runtime?String(r.runtime.pid):"Unavailable",mono:!!r.runtime}),f.jsx(yo,{label:"Started",value:n((b=r.runtime)==null?void 0:b.startedAt)})]})]})]}),f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(zN,{className:"h-3.5 w-3.5 text-primary"}),"Package versions"]}),f.jsx(Un,{className:"text-[10px]",children:"Version snapshot for the packages most relevant to this dashboard session."})]}),f.jsx(Bn,{"data-package-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:o.map(g=>{var S,N;return 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:g.label}),f.jsx("div",{className:"min-w-0 truncate text-[10px] text-muted-foreground",children:(S=g.value)==null?void 0:S.name}),f.jsx(Et,{variant:"outline",className:"w-fit rounded-sm border-border/70 bg-background/60 font-mono text-[10px]",children:(N=g.value)==null?void 0:N.version})]},g.key)})})]})]})}const hc=v.forwardRef(({className:n,type:r,...o},s)=>f.jsx("input",{type:r,className:ne("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",n),ref:s,...o}));hc.displayName="Input";function Wk(){return we("/system/quick-chats")}function Jk(n){return we("/system/quick-chats",{method:"PUT",body:JSON.stringify({quickChats:n})})}const xf="quick-chats:updated";function ej(){typeof window>"u"||window.dispatchEvent(new CustomEvent(xf))}function tj(){const[n,r]=v.useState([]),[o,s]=v.useState(!0),[c,u]=v.useState(!1),[m,h]=v.useState(null),y=v.useCallback(async()=>{s(!0);try{const b=await Wk();r(b.quickChats),h(null)}catch(b){h(b instanceof Error?b.message:"Failed to load quick chats")}finally{s(!1)}},[]),p=v.useCallback(async b=>{u(!0);try{const g=await Jk(b);return r(g.quickChats),h(null),ej(),g.quickChats}catch(g){const S=g instanceof Error?g.message:"Failed to save quick chats";throw h(S),g}finally{u(!1)}},[]);return v.useEffect(()=>{y()},[y]),v.useEffect(()=>{if(typeof window>"u")return;const b=()=>{y()};return window.addEventListener(xf,b),()=>window.removeEventListener(xf,b)},[y]),{error:m,loading:o,quickChats:n,refresh:y,save:p,saving:c}}function Zx(n){return n.trim().replace(/^\/+/,"").toLowerCase()}function Fx(n,r){const o=n.trim();if(!o.startsWith("/"))return[];const s=Zx(o);return r.filter(c=>c.alias.startsWith(s))}function Fi(n,r){return r<=0?-1:(n%r+r)%r}function W3(n,r,o=0){const s=Fx(n,r),c=Fi(o,s.length);return c>=0?s[c]??null:null}function J3(n,r,o){const s=Fi(n,r);return s<0?0:Fi(s+o,r)}function eM({query:n,quickChats:r,selectedIndex:o=0,onSelect:s,onActiveIndexChange:c}){const u=Fx(n,r);if(u.length===0)return null;const m=Fi(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(q0,{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,y)=>f.jsxs("button",{type:"button",role:"option","aria-selected":y===m,"data-selected":y===m?"true":void 0,onMouseEnter:()=>c==null?void 0:c(y),onClick:()=>s(h),className:ne("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:ne("shrink-0 font-mono text-[9px] leading-3 text-primary/70",y===m&&"text-primary"),children:["/",h.alias]}),f.jsx("span",{"data-quick-chat-prompt":"true",className:ne("line-clamp-1 min-w-0 text-[9px] leading-3 text-muted-foreground",y===m&&"text-primary/90"),children:h.prompt})]},h.alias))})]})}const nj="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 aj=0;function _i(n,r=0){return{id:n?`${n.alias}:${r}`:`new:${aj++}`,alias:(n==null?void 0:n.alias)??"",prompt:(n==null?void 0:n.prompt)??""}}function Sf(n){return{quickChats:n.map(r=>({alias:Zx(r.alias),prompt:r.prompt.trim()})).filter(r=>r.alias.length>0&&r.prompt.length>0)}}function rj(n,r){const o=Sf(n).quickChats,s=r.map((u,m)=>_i(u,m)),c=Sf(s).quickChats;return JSON.stringify(o)!==JSON.stringify(c)}function oj(){const{error:n,loading:r,quickChats:o,save:s,saving:c}=tj(),[u,m]=v.useState(()=>o.map((g,S)=>_i(g,S))),h=u.length>0,y=v.useMemo(()=>Sf(u),[u]),p=v.useMemo(()=>rj(u,o),[u,o]);v.useEffect(()=>{m(o.map((g,S)=>_i(g,S)))},[o]);async function b(){try{await s(y.quickChats),Ve.success("Quick chats saved")}catch(g){Ve.error(g instanceof Error?g.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(q0,{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(Bt,{type:"button",variant:"outline",onClick:()=>m(g=>[...g,_i(void 0,g.length)]),className:"h-7 rounded-sm px-2 text-[10px]",children:[f.jsx(YN,{className:"h-3.5 w-3.5"}),"Add"]}),f.jsxs(Bt,{type:"button",onClick:b,disabled:c||!p,className:"h-7 rounded-sm px-2 text-[10px]",children:[c?f.jsx(UN,{className:"h-3.5 w-3.5 animate-spin"}):f.jsx(WN,{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((g,S)=>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(hc,{"aria-label":`Quick chat ${S+1} alias`,value:g.alias,onChange:N=>m(T=>T.map(E=>E.id===g.id?{...E,alias:N.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 ${S+1} prompt`,value:g.prompt,onChange:N=>m(T=>T.map(E=>E.id===g.id?{...E,prompt:N.target.value}:E)),placeholder:"Prompt text",className:nj}),f.jsx(Bt,{type:"button",variant:"ghost",size:"icon",onClick:()=>m(N=>N.filter(T=>T.id!==g.id)),"aria-label":`Remove quick chat ${S+1}`,className:"h-7 w-7 rounded-sm text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:f.jsx(dT,{className:"h-3.5 w-3.5"})})]},g.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."}),n&&f.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:n})]})}var pc="Checkbox",[lj]=Xa(pc),[sj,lm]=lj(pc);function ij(n){const{__scopeCheckbox:r,checked:o,children:s,defaultChecked:c,disabled:u,form:m,name:h,onCheckedChange:y,required:p,value:b="on",internal_do_not_use_render:g}=n,[S,N]=Ro({prop:o,defaultProp:c??!1,onChange:y,caller:pc}),[T,E]=v.useState(null),[R,A]=v.useState(null),j=v.useRef(!1),_=T?!!m||!!T.closest("form"):!0,U={checked:S,disabled:u,setChecked:N,control:T,setControl:E,name:h,form:m,value:b,hasConsumerStoppedPropagationRef:j,required:p,defaultChecked:qa(c)?!1:c,isFormControl:_,bubbleInput:R,setBubbleInput:A};return f.jsx(sj,{scope:r,...U,children:cj(g)?g(U):s})}var Wx="CheckboxTrigger",Jx=v.forwardRef(({__scopeCheckbox:n,onKeyDown:r,onClick:o,...s},c)=>{const{control:u,value:m,disabled:h,checked:y,required:p,setControl:b,setChecked:g,hasConsumerStoppedPropagationRef:S,isFormControl:N,bubbleInput:T}=lm(Wx,n),E=tt(c,b),R=v.useRef(y);return v.useEffect(()=>{const A=u==null?void 0:u.form;if(A){const j=()=>g(R.current);return A.addEventListener("reset",j),()=>A.removeEventListener("reset",j)}},[u,g]),f.jsx(Ue.button,{type:"button",role:"checkbox","aria-checked":qa(y)?"mixed":y,"aria-required":p,"data-state":r1(y),"data-disabled":h?"":void 0,disabled:h,value:m,...s,ref:E,onKeyDown:Le(r,A=>{A.key==="Enter"&&A.preventDefault()}),onClick:Le(o,A=>{g(j=>qa(j)?!0:!j),T&&N&&(S.current=A.isPropagationStopped(),S.current||A.stopPropagation())})})});Jx.displayName=Wx;var sm=v.forwardRef((n,r)=>{const{__scopeCheckbox:o,name:s,checked:c,defaultChecked:u,required:m,disabled:h,value:y,onCheckedChange:p,form:b,...g}=n;return f.jsx(ij,{__scopeCheckbox:o,checked:c,defaultChecked:u,disabled:h,required:m,onCheckedChange:p,name:s,form:b,value:y,internal_do_not_use_render:({isFormControl:S})=>f.jsxs(f.Fragment,{children:[f.jsx(Jx,{...g,ref:r,__scopeCheckbox:o}),S&&f.jsx(a1,{__scopeCheckbox:o})]})})});sm.displayName=pc;var e1="CheckboxIndicator",t1=v.forwardRef((n,r)=>{const{__scopeCheckbox:o,forceMount:s,...c}=n,u=lm(e1,o);return f.jsx(Mo,{present:s||qa(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",...n.style}})})});t1.displayName=e1;var n1="CheckboxBubbleInput",a1=v.forwardRef(({__scopeCheckbox:n,...r},o)=>{const{control:s,hasConsumerStoppedPropagationRef:c,checked:u,defaultChecked:m,required:h,disabled:y,name:p,value:b,form:g,bubbleInput:S,setBubbleInput:N}=lm(n1,n),T=tt(o,N),E=wb(u),R=db(s);v.useEffect(()=>{const j=S;if(!j)return;const _=window.HTMLInputElement.prototype,z=Object.getOwnPropertyDescriptor(_,"checked").set,Y=!c.current;if(E!==u&&z){const G=new Event("click",{bubbles:Y});j.indeterminate=qa(u),z.call(j,qa(u)?!1:u),j.dispatchEvent(G)}},[S,E,u,c]);const A=v.useRef(qa(u)?!1:u);return f.jsx(Ue.input,{type:"checkbox","aria-hidden":!0,defaultChecked:m??A.current,required:h,disabled:y,name:p,value:b,form:g,...r,tabIndex:-1,ref:T,style:{...r.style,...R,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});a1.displayName=n1;function cj(n){return typeof n=="function"}function qa(n){return n==="indeterminate"}function r1(n){return qa(n)?"indeterminate":n?"checked":"unchecked"}const o1=v.forwardRef(({className:n,...r},o)=>f.jsx(sm,{ref:o,className:ne("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",n),...r,children:f.jsx(t1,{className:ne("flex items-center justify-center text-current"),children:f.jsx(zi,{className:"h-3.5 w-3.5"})})}));o1.displayName=sm.displayName;const e0=["queued","running"];function uj(n){return n.map(r=>`${r.id}:${r.name}`).join("\0")}function dj(n){return n==="claude"||n==="codex"||n==="copilot"}function l1(n){var o;if(n.kind!=="agent.upgrade")return null;const r=(o=n.payload)==null?void 0:o.agent;return dj(r)?`${n.nodeId}:${r}`:null}function fj(n){return n.status==="succeeded"||n.status==="failed"}async function s1(n,r={}){const o=r.getOperation??TE,s=r.pollIntervalMs??2e3,c=r.timeoutMs??24e4,u=Date.now()+c;let m=n;for(;!fj(m)&&Date.now()<u;)await hj(s),m=await o(n.id);return m}async function mj(n,r=RE){const o=new Set(n),s=await Promise.all(e0.map(u=>r({kind:"agent.upgrade",status:u}))),c=new Map;for(const u of s.flat()){if(!e0.includes(u.status)||o.size>0&&!o.has(u.nodeId))continue;const m=l1(u);if(!m)continue;const h=c.get(m);(!h||u.updatedAt>h.updatedAt)&&c.set(m,u)}return c}function hj(n){return new Promise(r=>setTimeout(r,n))}const pj=1500,gj=1e3,vj=9e4;async function i1(n={}){const r=n.fetchHealth??yj,o=n.initialDelayMs??pj,s=n.pollIntervalMs??gj,c=n.previousPid,u=n.reload??(()=>window.location.reload()),m=n.sleep??xj,h=n.timeoutMs??vj,y=Date.now()+h;let p=!1;for(o>0&&await m(o);Date.now()<=y;){const b=bj(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 yj(){try{const n=await fetch("/api/system/health",{cache:"no-store"}),r=await n.json().catch(()=>null),o=r&&typeof r=="object"&&typeof r.pid=="number"?r.pid:void 0;return{ok:n.ok,pid:o}}catch{return!1}}function bj(n){return typeof n=="boolean"?{ok:n}:n}function xj(n){return new Promise(r=>window.setTimeout(r,n))}function Sj(n,r=!0){return r?(n==null?void 0:n.restartMode)==="development"?"Restart dev runtime":n!=null&&n.updateAvailable?"Restart to update":"Restart runtime":n!=null&&n.updateAvailable?"Restart follower to update":"Restart follower"}function wj({checkedLabel:n,disableAuthDefault:r,endpoint:o,isLiveLocalNode:s,nodeId:c,nodeName:u,onRefresh:m,pid:h,transportType:y,update:p,workDir:b}){const g=Sj(p,s),[S,N]=v.useState(null),[T,E]=v.useState(()=>t0({disableAuthDefault:r,endpoint:o,nodeName:u,transportType:y,workDir:b})),[R,A]=v.useState(!1),[j,_]=v.useState(!1),[U,z]=v.useState(!1);v.useEffect(()=>{E(t0({disableAuthDefault:r,endpoint:o,nodeName:u,transportType:y,workDir:b}))},[r,o,u,y,b]);async function Y(){if(!c||R||j)return;const oe=p.updateAvailable?"update":"restart",fe=Tj(T);if(T.port.trim()&&(fe==null?void 0:fe.port)===void 0){Ve.error("Runtime restart port must be a positive integer");return}const ue=fe?{reason:oe,startArgs:fe}:{reason:oe};A(!0);try{if(s){const M=await L0(ue);N({...M,pid:M.pid??h,status:"accepted"}),Ve.info(`Restarting ${u} from a detached helper. PID ${M.pid??h??"unknown"} will not stay attached to the original terminal window; follow ${M.logPath} for launch output.`),i1({previousPid:M.pid??h}).then(q=>{q||(A(!1),Ve.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout. Refresh the page after the node finishes starting."))}).catch(q=>{A(!1),Ve.error(q instanceof Error?q.message:"Runtime restart recovery failed")});return}const ie=await AE(c,ue);N({operationId:ie.id,pid:h,status:ie.status}),Ve.info(`Restart requested on ${u}. Operation ${Id(ie.id)} will hand off to a detached process, so the new runtime will not stay attached to the original terminal window.`);const me=await s1(ie,{timeoutMs:6e4}),ae=Nj(me);N({command:ae==null?void 0:ae.command,logPath:ae==null?void 0:ae.logPath,mode:ae==null?void 0:ae.mode,operationId:me.id,pid:(ae==null?void 0:ae.pid)??h,status:me.status}),me.status==="succeeded"?(await(m==null?void 0:m()),Ve.success(`Restart handoff accepted on ${u}. Follow ${(ae==null?void 0:ae.logPath)??"the node restart log"} for launch output.`)):me.status==="failed"?Ve.error(me.error??`Restart failed on ${u}`):Ve.info(`Restart operation ${Id(me.id)} is still ${me.status}. More details will update after the node reports back.`),A(!1)}catch(ie){A(!1),Ve.error(ie instanceof Error?ie.message:"Runtime restart failed")}}async function G(){if(!(!s||R||j)){_(!0);try{const oe=await EE();Ve.info(`Stopping Meshy process ${oe.pid}`)}catch(oe){_(!1),Ve.error(oe instanceof Error?oe.message:"Runtime stop failed")}}}const P=R?"restarting":j?"stopping":(S==null?void 0:S.status)??"idle",ee=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(Di,{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:ee?"Development launcher":`Latest ${p.latestVersion??"—"}`})]})]}),f.jsx("div",{className:"flex items-center gap-1.5",children:f.jsx(Et,{variant:p.updateAvailable?"default":"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 font-mono text-[10px]",children:ee?"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 ",n]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[s&&f.jsxs(yf,{children:[f.jsx(bf,{asChild:!0,children:f.jsxs(Bt,{type:"button",size:"sm",variant:"ghost",disabled:R||j,className:"h-7 rounded-sm px-2 text-[11px] text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:[f.jsx(IN,{className:ne("mr-1 h-3.5 w-3.5",j&&"animate-pulse")}),j?"Stopping":"Stop"]})}),f.jsxs(Yi,{className:"max-w-[22rem] gap-2 rounded-sm p-4",children:[f.jsxs(Gi,{className:"space-y-1",children:[f.jsx(Xi,{className:"text-sm",children:"Stop runtime?"}),f.jsx(Qi,{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(Ii,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(Zi,{className:"h-7 rounded-sm px-2 text-[11px]",children:"Cancel"}),f.jsx(Ki,{className:"h-7 rounded-sm bg-destructive px-2 text-[11px] text-destructive-foreground hover:bg-destructive/90",onClick:()=>void G(),children:"Stop runtime"})]})]})]}),f.jsxs(yf,{children:[f.jsx(bf,{asChild:!0,children:f.jsxs(Bt,{type:"button",size:"sm",variant:p.updateAvailable?"default":"outline",disabled:!c||R||j,className:"h-7 rounded-sm px-2 text-[11px]",children:[f.jsx(af,{className:ne("mr-1 h-3.5 w-3.5",R&&"animate-spin")}),R?"Restarting…":g]})}),f.jsxs(Yi,{className:"max-w-[28rem] gap-3 rounded-sm p-4",children:[f.jsxs(Gi,{className:"space-y-1",children:[f.jsxs(Xi,{className:"text-sm",children:[g,"?"]}),f.jsxs(Qi,{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(Ej,{value:T,onChange:E}),f.jsxs(Ii,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(Zi,{className:"h-7 rounded-sm px-2 text-[11px]",children:"Cancel"}),f.jsx(Ki,{className:"h-7 rounded-sm px-2 text-[11px]",onClick:()=>void Y(),children:g})]})]})]})]})]}),f.jsxs("div",{className:"border-t border-border/50",children:[f.jsxs("button",{type:"button",onClick:()=>z(oe=>!oe),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(X0,{className:"h-3 w-3"}),"Restart details"]}),f.jsx(Ql,{className:ne("h-3 w-3 transition-transform duration-150",U&&"rotate-180")})]}),U&&f.jsxs("div",{className:"border-t border-border/50 bg-muted/20 px-3 py-2 space-y-1",children:[f.jsx(yr,{label:"Current PID",value:h===void 0?"—":String(h),mono:h!==void 0}),f.jsx(yr,{label:"Restart PID",value:(S==null?void 0:S.pid)===void 0?"Pending":String(S.pid),mono:(S==null?void 0:S.pid)!==void 0}),f.jsx(yr,{label:"Operation",value:S!=null&&S.operationId?Id(S.operationId):"Local direct request",mono:!!(S!=null&&S.operationId)}),f.jsx(yr,{label:"Status",value:(S==null?void 0:S.status)??(R?"requested":"idle")}),f.jsx(yr,{label:"Launcher",value:(S==null?void 0:S.command)??"Available after restart",mono:!!(S!=null&&S.command)}),f.jsx(yr,{label:"Log",value:(S==null?void 0:S.logPath)??"Available after restart",mono:!!(S!=null&&S.logPath)}),f.jsx(yr,{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 Ej({onChange:n,value:r}){const o=(s,c)=>{n({...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(Bl,{label:"HTTP port",value:r.port,onChange:s=>o("port",s),inputMode:"numeric"}),f.jsx(Bl,{label:"Node name",value:r.name,onChange:s=>o("name",s)}),f.jsx(Bl,{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(ox,{value:r.transport,onValueChange:s=>o("transport",c1(s)),children:[f.jsx(am,{className:"h-7 rounded-md border-border/70 bg-background/70 px-2 text-[10px]",children:f.jsx(lx,{placeholder:"Transport"})}),f.jsxs(rm,{children:[f.jsx(wo,{className:"py-1 text-[11px]",value:"inherit",children:"current / default"}),f.jsx(wo,{className:"py-1 text-[11px]",value:"direct",children:"direct"}),f.jsx(wo,{className:"py-1 text-[11px]",value:"devtunnel",children:"devtunnel"}),f.jsx(wo,{className:"py-1 text-[11px]",value:"tailscale",children:"tailscale"})]})]})]}),f.jsx(Bl,{label:"Working directory",value:r.workDir,onChange:s=>o("workDir",s)}),f.jsx(Bl,{label:"Config path",value:r.config,onChange:s=>o("config",s),className:"sm:col-span-2"}),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(o1,{className:"h-3.5 w-3.5",checked:r.disableAuth,onCheckedChange:s=>n({...r,disableAuth:s===!0,disableAuthKnown:!0})}),"Disable auth"]})]})]})}function Bl({className:n,inputMode:r,label:o,onChange:s,value:c}){return f.jsxs("label",{className:ne("space-y-1",n),children:[f.jsx("span",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:o}),f.jsx(hc,{className:"h-7 rounded-md px-2 text-[10px]",inputMode:r,value:c,onChange:u=>s(u.target.value)})]})}function yr({label:n,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:n}),f.jsx("span",{className:ne("break-all text-right text-foreground",o&&"font-mono"),children:r})]})}function Nj(n){const r=n.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 t0(n){return{port:Rj(n.endpoint),name:n.nodeName,join:"",transport:c1(n.transportType),workDir:n.workDir??"",config:"",disableAuth:n.disableAuthDefault===!0,disableAuthKnown:n.disableAuthDefault!==void 0}}function Tj(n){const r={},o=Number(n.port.trim());return n.port.trim()&&Number.isInteger(o)&&o>0&&(r.port=o),n.name.trim()&&(r.name=n.name.trim()),n.join.trim()&&(r.join=n.join.trim()),n.transport!=="inherit"&&(r.transport=n.transport),n.workDir.trim()&&(r.workDir=n.workDir.trim()),n.config.trim()&&(r.config=n.config.trim()),n.disableAuthKnown&&(r.disableAuth=n.disableAuth),Object.keys(r).length>0?r:void 0}function c1(n){return n==="direct"||n==="devtunnel"||n==="tailscale"?n:"inherit"}function Rj(n){if(!n)return"";try{return new URL(n).port||""}catch{return""}}function Id(n){return n.length<=8?n:n.slice(0,8)}function Hl({formatDateTime:n,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:n(o==null?void 0:o.checkedAt)})]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof(o==null?void 0:o.authenticated)=="boolean"&&f.jsx(Et,{variant:o.authenticated?"default":"outline",className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o.authenticated?"auth ok":"auth required"}),f.jsx(Et,{variant:s(o==null?void 0:o.status),className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:(o==null?void 0:o.status)??"unknown"})]})]})}function Yt(n){if(n==null||n==="")return"Unavailable";const r=new Date(n);return Number.isNaN(r.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(r)}function Cj(n){const r=Math.max(0,Math.floor(n)),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 n0(n){if(n==null||Number.isNaN(n))return"Unavailable";const r=["B","KB","MB","GB","TB"];let o=n,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 So(n){return n==="ok"?"default":n==="missing"||n==="install-failed"||n==="login-failed"?"destructive":n==="not-authenticated"||n==="unsupported-platform"?"outline":"secondary"}function Aj(n){return n.available?f.jsxs(Et,{className:"gap-1 rounded-sm px-1.5 py-0 text-[10px]",children:[f.jsx(Pl,{className:"h-3 w-3"}),"Available"]}):f.jsxs(Et,{variant:"destructive",className:"gap-1 rounded-sm px-1.5 py-0 text-[10px]",children:[f.jsx(EN,{className:"h-3 w-3"}),"Unavailable"]})}function kj(n){return n.update?n.update.updateAvailable?f.jsxs(Et,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:["Update ",n.update.latestVersion]}):f.jsx(Et,{variant:"secondary",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:"Up to date"}):null}function jj(n){return n.available?null:n.metadataStatus??null}function _j(n){var o;const r=`npm install -g ${(o=n.update)==null?void 0:o.packageName}@latest`;return n.id==="claude"?`${r} --include=optional --ignore-scripts=false`:r}function Mj(n){if(n.error)return n.error;const r=n.result;return(r==null?void 0:r.detail)??null}function et({label:n,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:n}),f.jsx("span",{className:ne("break-all text-right text-[11px] text-foreground",o&&"font-mono text-[11px]"),children:r})]})}function $l({label:n,value:r,mono:o=!1,className:s}){return f.jsxs("div",{className:ne("min-w-0 space-y-0.5",s),children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:n}),f.jsx("div",{className:ne("truncate text-[11px] text-foreground",o&&"font-mono",n==="Path"&&"break-all whitespace-normal"),children:r})]})}function Oj({agent:n,nodeName:r,activeOperation:o,onUpgrade:s}){var y,p;const c=((y=n.update)==null?void 0:y.updateAvailable)===!0,u=kj(n),m=!!o,h=jj(n);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(P0,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),f.jsx("span",{className:"truncate",children:n.label})]}),f.jsxs("div",{className:"truncate text-[10px] text-muted-foreground",children:["Command: ",f.jsx("span",{className:"font-mono text-[10px]",children:n.command})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Aj(n),h&&f.jsx(Et,{variant:So(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($l,{label:"Version",value:n.version??"Unavailable",mono:!!n.version}),n.update&&f.jsx($l,{label:"Latest",value:n.update.latestVersion??"Unavailable",mono:!!n.update.latestVersion}),f.jsx($l,{label:"Checked",value:Yt(n.checkedAt)}),n.update&&f.jsx($l,{label:"Update check",value:Yt(n.update.checkedAt)}),f.jsx($l,{label:"Path",value:n.path??"Not on PATH",mono:!!n.path,className:"sm:col-span-2"})]}),f.jsx("div",{className:"flex items-start justify-start lg:justify-end",children:o?f.jsxs(Et,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:["Upgrade ",o.status]}):c?f.jsxs(yf,{children:[f.jsx(bf,{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(Yi,{children:[f.jsxs(Gi,{children:[f.jsxs(Xi,{children:["Upgrade ",n.label,"?"]}),f.jsxs(Qi,{children:["This runs ",_j(n)," on ",r,". Remote nodes execute the command on the remote machine."]})]}),f.jsxs(Ii,{children:[f.jsx(Zi,{children:"Cancel"}),f.jsx(Ki,{onClick:()=>s(n),children:"Upgrade"})]})]})]}):u})]}),((p=n.update)==null?void 0:p.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:n.update.detail}),n.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:n.detail})]})}function Dj(n,r){var o;return(o=n==null?void 0:n.nodes)!=null&&o.length?n.nodes:r?[r]:[]}function zj(n,r){var s;if(r&&n.id===r.nodeId)return r;const o=n.settingsSnapshot;return{...n,nodeId:n.id,version:(o==null?void 0:o.version)??"Unavailable",packageName:o==null?void 0:o.packageName,uptime:(o==null?void 0:o.uptime)??0,localDashboardOrigin:((s=o==null?void 0:o.runtime)==null?void 0:s.localDashboardOrigin)??void 0,auth:o==null?void 0:o.auth,os:o==null?void 0:o.os,runtime:o==null?void 0:o.runtime,runtimeUpdate:o==null?void 0:o.runtimeUpdate,agents:o==null?void 0:o.agents,startupRequirements:o==null?void 0:o.startupRequirements,components:o==null?void 0:o.components,repository:o==null?void 0:o.repository,packages:o==null?void 0:o.packages}}function Lj(n,r){return n.id===r?`${n.name} (this node)`:`${n.name} (${n.role})`}function Uj(n){return n==="claude"?"Claude Code":n==="copilot"?"Copilot CLI":"Codex"}function Bj(n){var o;const r=(o=n.payload)==null?void 0:o.agent;return r==="claude"||r==="codex"||r==="copilot"?r:null}function Hj({cluster:n,systemInfo:r,sseConnected:o,initialSelectedNodeId:s,onRefresh:c}){var ee,oe,fe,ue,ie,me,ae,M,q,K,de,C,V,F,I,W,se,re,ce,le;const u=v.useMemo(()=>Dj(n,r),[n,r]),[m,h]=v.useState(()=>{var J;return s??(r==null?void 0:r.nodeId)??((J=n==null?void 0:n.self)==null?void 0:J.id)??""}),[y,p]=v.useState(()=>new Map),b=v.useRef(new Set),g=v.useRef(new Set),S=(n==null?void 0:n.self)??r??u[0]??null,N=u.find(J=>J.id===m)??S,T=N?zj(N,r):null,E=!!(r&&N&&N.id===r.nodeId),R=E||!!(N!=null&&N.settingsSnapshot),A=T==null?void 0:T.runtimeUpdate,j=((ee=T==null?void 0:T.startupRequirements)==null?void 0:ee.components)??(T==null?void 0:T.components)??{},_=v.useMemo(()=>u.map(J=>J.id),[u]),U=_.join("\0"),z=uj(u),Y=v.useMemo(()=>new Map(u.map(J=>[J.id,J.name])),[z]);v.useEffect(()=>{s&&_.includes(s)&&h(s)},[s,U]);const G=v.useCallback(async(J,ve)=>{const ye=l1(J);if(!ye||b.current.has(J.id))return;const Se=Bj(J),Be=(ve==null?void 0:ve.agentLabel)??(Se?Uj(Se):"Agent"),$e=(ve==null?void 0:ve.nodeName)??Y.get(J.nodeId)??J.nodeId;b.current.add(J.id),p(Ge=>new Map(Ge).set(ye,J));try{const Ge=await s1(J);if(Ge.status==="succeeded")await(c==null?void 0:c()),g.current.has(Ge.id)||(Ve.success(`${Be} upgrade finished on ${$e}`),g.current.add(Ge.id));else if(Ge.status==="failed")g.current.has(Ge.id)||(Ve.error(Mj(Ge)??`${Be} upgrade failed`),g.current.add(Ge.id));else{p(vt=>new Map(vt).set(ye,Ge)),Ve.info(`${Be} upgrade is still ${Ge.status} on ${$e}`);return}p(vt=>{const _e=new Map(vt),Ht=_e.get(ye);return(!Ht||Ht.id===Ge.id)&&_e.delete(ye),_e})}catch(Ge){p(vt=>{const _e=new Map(vt),Ht=_e.get(ye);return(!Ht||Ht.id===J.id)&&_e.delete(ye),_e}),Ve.error(Ge instanceof Error?Ge.message:`${Be} upgrade failed`)}finally{b.current.delete(J.id)}},[c,Y]);v.useEffect(()=>{if(_.length===0)return;let J=!1;async function ve(){let ye;try{ye=await mj(_)}catch{return}if(!J){p(Se=>{const Be=new Map(Se);for(const[$e,Ge]of ye)Be.set($e,Ge);return Be});for(const Se of ye.values())G(Se)}}return ve(),()=>{J=!0}},[G,U]);async function P(J){if(N)try{const ve=await CE(N.id,J.id);Ve.info(`${J.label} upgrade started on ${N.name}`),await G(ve,{agentLabel:J.label,nodeName:N.name})}catch(ve){Ve.error(ve instanceof Error?ve.message:`${J.label} upgrade failed`)}}return!N||!T?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:[!E&&f.jsxs(Et,{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 ",Yt((oe=N.settingsSnapshot)==null?void 0:oe.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(Xk,{status:N.status}),f.jsx("span",{className:"font-medium text-foreground",children:N.name})]}),f.jsx(Qk,{role:N.role}),f.jsx(Et,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:N.transportType??T.transportType??"direct"}),f.jsx(Et,{variant:E?"default":"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:E?"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(ox,{value:N.id,onValueChange:h,children:[f.jsx(am,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px]",children:f.jsx(lx,{placeholder:"Choose a node"})}),f.jsx(rm,{className:"settings-node-select-content rounded-sm text-[10px] leading-4",children:u.map(J=>f.jsx(wo,{value:J.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:Lj(J,r==null?void 0:r.nodeId)},J.id))})]})]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(Et,{variant:o?"default":"outline",className:"gap-1 rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:[f.jsx(QN,{className:"h-3 w-3"}),o?"Live link":"Reconnecting"]}),f.jsxs(Et,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:["Uptime ",Cj(T.uptime)]})]})]})]}),!R&&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(Mk,{defaultValue:"session",className:"space-y-2",children:[f.jsxs(Ax,{className:"h-auto flex-wrap rounded-sm border border-border/60 bg-muted/40 p-0.5",children:[f.jsx(Vl,{value:"session",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Session"}),f.jsx(Vl,{value:"access",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Access"}),f.jsx(Vl,{value:"quick-chats",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Quick chats"}),f.jsx(Vl,{value:"about",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"About"})]}),f.jsxs(Yl,{value:"session",className:"mt-0 grid gap-2 xl:grid-cols-[1.15fr_0.85fr]",children:[f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(G0,{className:"h-3.5 w-3.5 text-primary"}),"Selected node"]}),f.jsx(Un,{className:"text-[10px]",children:"Cluster role, identity, and node-scoped runtime state."})]}),f.jsxs(Bn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Node ID",value:T.nodeId,mono:!0}),f.jsx(et,{label:"Status",value:N.status}),f.jsx(et,{label:"Role",value:N.role}),f.jsx(et,{label:"Endpoint",value:N.endpoint,mono:!0}),f.jsx(et,{label:"Joined",value:Yt(N.joinedAt)}),f.jsx(et,{label:"Heartbeat",value:Yt(N.lastHeartbeat)}),f.jsx(et,{label:"Capabilities",value:N.capabilities.length>0?N.capabilities.join(", "):"None"})]})]}),f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(CN,{className:"h-3.5 w-3.5 text-primary"}),"OS info"]}),f.jsx(Un,{className:"text-[10px]",children:"Host and resource details reported by the current process."})]}),f.jsxs(Bn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Host",value:((fe=T.os)==null?void 0:fe.hostname)??"Unavailable"}),f.jsx(et,{label:"Platform",value:T.os?`${T.os.platform} ${T.os.release}`:"Unavailable"}),f.jsx(et,{label:"Arch",value:((ue=T.os)==null?void 0:ue.arch)??"Unavailable"}),f.jsx(et,{label:"CPU",value:((ie=T.os)==null?void 0:ie.cpuModel)??"Unavailable"}),f.jsx(et,{label:"Cores",value:String(((me=T.os)==null?void 0:me.cpuCount)??"Unavailable")}),f.jsx(et,{label:"Memory",value:T.os?`${n0(T.os.freeMemoryBytes)} free / ${n0(T.os.totalMemoryBytes)} total`:"Unavailable"})]})]}),A&&f.jsx("div",{className:"xl:col-span-2",children:f.jsx(wj,{checkedLabel:Yt(A.checkedAt),disableAuthDefault:((ae=T.auth)==null?void 0:ae.enabled)===void 0?void 0:T.auth.enabled===!1,endpoint:N.endpoint,isLiveLocalNode:E,nodeId:N.id,nodeName:N.name,onRefresh:c,pid:(M=T.runtime)==null?void 0:M.pid,transportType:N.transportType,update:A,workDir:((q=T.runtime)==null?void 0:q.workDir)??N.workDir})}),f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none xl:col-span-2",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(P0,{className:"h-3.5 w-3.5 text-primary"}),"Available agents"]}),f.jsx(Un,{className:"text-[10px]",children:E?"Live command availability for runtime agents on this node.":"Most recent agent availability snapshot synced from this node."})]}),f.jsx(Bn,{"data-agent-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:(T.agents??[]).map(J=>f.jsx(Oj,{agent:J,nodeName:N.name,activeOperation:y.get(`${N.id}:${J.id}`),onUpgrade:P},J.id))})]})]}),f.jsxs(Yl,{value:"access",className:"mt-0 grid gap-2 xl:grid-cols-2",children:[f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(mN,{className:"h-3.5 w-3.5 text-primary"}),"Access surface"]}),f.jsx(Un,{className:"text-[10px]",children:"How this node is exposed to the dashboard and other peers."})]}),f.jsxs(Bn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Transport",value:N.transportType??T.transportType??"direct"}),f.jsx(et,{label:"Node URL",value:N.endpoint,mono:!0}),f.jsx(et,{label:"Node tunnel",value:N.devtunnelEndpoint??"Disabled",mono:!!N.devtunnelEndpoint}),f.jsx(et,{label:"Dashboard URL",value:N.dashboardOrigin??T.localDashboardOrigin??"Unavailable",mono:!!(N.dashboardOrigin||T.localDashboardOrigin)}),f.jsx(et,{label:"Local dashboard",value:T.localDashboardOrigin??"Unavailable",mono:!!T.localDashboardOrigin})]})]}),f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(oT,{className:"h-3.5 w-3.5 text-primary"}),"Auth"]}),f.jsx(Un,{className:"text-[10px]",children:"Current bearer-auth and trusted access posture."})]}),f.jsxs(Bn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Enabled",value:(K=T.auth)!=null&&K.enabled?"Yes":"No"}),f.jsx(et,{label:"Same tenant",value:(de=T.auth)!=null&&de.allowSameTenant?"Allowed":"Off"}),f.jsx(et,{label:"Allowed users",value:(C=T.auth)!=null&&C.allowedUsers.length?T.auth.allowedUsers.join(", "):"None"})]})]}),f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(_N,{className:"h-3.5 w-3.5 text-primary"}),"Paths"]}),f.jsx(Un,{className:"text-[10px]",children:"Workspace and runtime paths currently used by this node."})]}),f.jsxs(Bn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Work dir",value:((V=T.runtime)==null?void 0:V.workDir)??T.workDir??"Unavailable",mono:!!(((F=T.runtime)==null?void 0:F.workDir)??T.workDir)}),f.jsx(et,{label:"Storage",value:((I=T.runtime)==null?void 0:I.storagePath)??"Unavailable",mono:!!((W=T.runtime)!=null&&W.storagePath)}),f.jsx(et,{label:"Process cwd",value:((se=T.runtime)==null?void 0:se.cwd)??"Unavailable",mono:!!((re=T.runtime)!=null&&re.cwd)}),f.jsx(et,{label:"Started",value:Yt((ce=T.runtime)==null?void 0:ce.startedAt)}),f.jsx(et,{label:"PID",value:T.runtime?String(T.runtime.pid):"Unavailable",mono:!!T.runtime})]})]}),f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(Di,{className:"h-3.5 w-3.5 text-primary"}),"Startup checks"]}),f.jsx(Un,{className:"text-[10px]",children:"Dependency preflight snapshot persisted during node startup."})]}),f.jsxs(Bn,{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:Yt((le=T.startupRequirements)==null?void 0:le.lastCheckedAt)})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Hl,{formatDateTime:Yt,name:"Azure CLI",status:j.az,statusVariant:So}),f.jsx(Hl,{formatDateTime:Yt,name:"DevTunnel",status:j.devtunnel,statusVariant:So}),f.jsx(Hl,{formatDateTime:Yt,name:"Claude Code",status:j.claude,statusVariant:So}),f.jsx(Hl,{formatDateTime:Yt,name:"Codex",status:j.codex,statusVariant:So}),f.jsx(Hl,{formatDateTime:Yt,name:"Copilot CLI",status:j.copilot,statusVariant:So})]})]})]})]}),f.jsx(Yl,{value:"quick-chats",className:"mt-0",children:f.jsx(oj,{})}),f.jsx(Fk,{formatDateTime:Yt,viewInfo:T})]})]})}function $j({initialSelectedNodeId:n,open:r,onOpenChange:o,showTrigger:s=!0}={}){const{cluster:c,systemInfo:u,sseConnected:m,refresh:h}=H0();return f.jsx(SA,{open:r,onOpenChange:o,showTrigger:s,children:f.jsx(Hj,{cluster:c,systemInfo:u,sseConnected:m,initialSelectedNodeId:n,onRefresh:h})})}const tM="codex",nM="bypass",Pj=[{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"}],aM=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],rM=new Set(Pj.filter(n=>n.supportsFollowUp).map(n=>n.value)),oM=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"shared",label:"Shared"},{value:"archived",label:"Archived"}],lM=[{value:"all",label:"All task types"},{value:"native",label:"Native sessions"},{value:"meshy",label:"Meshy chats"}],qj=new Set(["pending","assigned"]),Vj=new Set(["running"]),Yj=new Set(["completed","failed","cancelled"]),sM=10;function iM(n,r){switch(r){case"running":return Vj.has(n.status);case"waiting":return qj.has(n.status);case"closed":return Yj.has(n.status);case"shared":return!!n.activeShare;case"archived":return n.status==="archived";case"active":default:return n.status!=="archived"}}function cM(n,r){if(r==="all")return!0;const o=n.conversationKind==="nativeSession";return r==="native"?o:!o}function uM(n,r){const o=r.trim().toLowerCase();return o?[n.title,n.description,n.id,n.agent,n.assignedTo??"",n.assignedNodeName??"",n.project??"",n.effectiveProjectPath??"",n.conversationKind==="nativeSession"?"native session":"meshy chat",n.activeShare?"shared conversation":""].some(s=>s.toLowerCase().includes(o)):!0}function Gj(n,r,o){if(!n)return"unassigned";const s=r==null?void 0:r.find(c=>c.id===n);return(s==null?void 0:s.name)??o??n.slice(0,8)}function dM(n,r,o){return Gj(n,r,o).toLowerCase()}function fM(n){return n.type!=="node.status"&&n.type!=="cluster.state"}function mM(n,r,o){return!n.assignedTo||(o==null?void 0:o.id)===n.assignedTo?!0:(r==null?void 0:r.some(s=>s.id===n.assignedTo))??!1}function hM(n,r){return[...n].sort((o,s)=>o.id===r?-1:s.id===r?1:o.name.localeCompare(s.name))}function pM(n){if(!n||typeof n!="object")return null;const r=n,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 gM(n){return n==="default workspace"?n:n.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??n}function vM(n){const r=Date.now()-n;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 yM(n){return new Date(n).toLocaleString()}function bM(n){const r=Math.floor(n/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 Ij(n,r="Copied to clipboard"){var o,s,c;try{if((s=(o=globalThis.navigator)==null?void 0:o.clipboard)!=null&&s.writeText)return await globalThis.navigator.clipboard.writeText(n),Ve.success(r),!0;const u=globalThis.document,m=(c=u==null?void 0:u.execCommand)==null?void 0:c.bind(u);if(!(u!=null&&u.body)||typeof u.createElement!="function"||typeof m!="function")throw new Error("Clipboard access is unavailable");const h=u.createElement("textarea"),y=u.activeElement,p=y&&typeof y.focus=="function"?y:null;h.value=n,h.setAttribute("readonly","true"),h.style.position="fixed",h.style.opacity="0",h.style.pointerEvents="none",u.body.appendChild(h),h.select(),h.setSelectionRange(0,h.value.length);const b=m("copy");if(u.body.removeChild(h),p==null||p.focus(),!b)throw new Error("Clipboard access is unavailable");return Ve.success(r),!0}catch(u){return Ve.error(u instanceof Error?u.message:"Failed to copy"),!1}}const Xj="default workspace";function Mi(n){const r=n.replace(/\\/g,"/");return r==="/"||/^[A-Za-z]:\/$/.test(r)?r:r.replace(/\/+$/g,"")||r}function Qj(n){const r=n.replace(/\\/g,"/");return r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r)}function Kj(n,r){const o=Mi(n),s=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!s||s==="."?o:o==="/"||/^[A-Za-z]:\/$/.test(o)?`${o}${s}`:`${o}/${s}`}function Zj(n,r){var u,m,h;const o=(u=n.effectiveProjectPath)==null?void 0:u.trim();if(o)return Mi(o);const s=(m=n.project)==null?void 0:m.trim();if(!s)return Xj;if(Qj(s)||!n.assignedTo)return Mi(s);const c=(h=r==null?void 0:r.get(n.assignedTo))==null?void 0:h.trim();return c?Kj(c,s):Mi(s)}function xM(n,r,o,s){const c=new Map;for(const m of n){const h=m.assignedTo??null,y=h??"__unassigned__",p=h?r.get(h)??m.assignedNodeName??h.slice(0,8):"Unassigned",b=Zj(m,s);c.has(y)||c.set(y,{nodeId:h,nodeName:p,dirMap:new Map});const g=c.get(y);g.dirMap.has(b)||g.dirMap.set(b,[]),g.dirMap.get(b).push(m)}const u=Array.from(c.values()).map(({nodeId:m,nodeName:h,dirMap:y})=>{const p=Array.from(y.entries()).map(([b,g])=>({path:b,tasks:g})).sort((b,g)=>g.tasks.length-b.tasks.length||b.path.localeCompare(g.path));return{nodeId:m,nodeName:h,dirs:p}});return u.sort((m,h)=>{if(o){if(m.nodeId===o)return-1;if(h.nodeId===o)return 1}return m.nodeId===null?1:h.nodeId===null?-1:m.nodeName.localeCompare(h.nodeName)}),u}const Fj={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"},Wj={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 Jj(n){return n.split(".")[0]??"unknown"}function e_(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function bo(n,r,o){return typeof o=="string"&&o.length>0?o:(r==null?void 0:r.get(n))??n}function u1(n,r){const o=n.data,s=o.operation;switch(n.type){case"node.joined":return`${o.name} joined the cluster`;case"node.left":return`${bo(o.nodeId,r,o.name)} left (${o.reason})`;case"node.status":return`${bo(o.nodeId,r)} is now ${o.status}`;case"node.operation.created":return`${s==null?void 0:s.kind} ${s==null?void 0:s.status} on ${bo(s==null?void 0:s.nodeId,r)}`;case"node.operation.updated":return`${s==null?void 0:s.kind} ${s==null?void 0:s.status} on ${bo(s==null?void 0:s.nodeId,r)}`;case"transport.changed":return`${bo(o.nodeId,r)} transport switched to ${o.transportType}`;case"task.created":return`"${o.title}" created`;case"task.assigned":return`task assigned to ${bo(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 t_(n){return JSON.stringify(n,null,2)}function n_({events:n,maxHeight:r="400px",nodeNameById:o,onDismiss:s,density:c="default"}){if(n.length===0)return null;const u=c==="compact";return f.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:r},children:f.jsx("div",{className:"space-y-1.5",children:n.map(m=>{const h=Jj(m.type);return f.jsx("div",{className:ne("transition-colors hover:bg-muted/30",u?"rounded-sm px-1 py-0.5":"rounded-lg 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:ne("font-mono text-muted-foreground",u?"text-[8px]":"text-[9px]"),children:e_(m.timestamp)}),u?f.jsx("span",{className:ne("max-w-[8.5rem] truncate text-[7px] font-medium uppercase tracking-[0.08em] text-muted-foreground/70",Wj[h]),children:m.type}):f.jsx(Et,{variant:"outline",className:ne("w-fit text-[9px] font-medium uppercase tracking-[0.14em] px-1.5 py-0",Fj[h]),children:m.type})]}),f.jsxs("div",{className:ne("flex shrink-0 items-center",u?"gap-px":"gap-0.5"),children:[f.jsx(Bt,{type:"button",variant:"ghost",size:"icon",className:ne("rounded-sm text-muted-foreground hover:text-foreground",u?"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:()=>void Ij(t_(m),"Event copied"),"aria-label":`Copy ${m.type} event`,title:"Copy event",children:f.jsx(TN,{className:u?"h-2.5 w-2.5":"h-3 w-3"})}),s&&f.jsx(Bt,{type:"button",variant:"ghost",size:"icon",className:ne("rounded-sm text-muted-foreground hover:text-foreground",u?"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:()=>s(m.id),"aria-label":`Dismiss ${m.type} event`,title:"Dismiss event",children:f.jsx(Q0,{className:u?"h-2.5 w-2.5":"h-3 w-3"})})]})]}),f.jsx("div",{className:"text-[9px] leading-snug text-foreground/85",children:u1(m,o)})]})},m.id)})})})}const a_=["node.","election.","transport."],r_="cluster.state";function o_(n){return n.type==="node.status"?!1:a_.some(r=>n.type.startsWith(r))}function l_(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function s_(n,r){return n?{time:l_(n.timestamp),text:u1(n,r)}:null}function i_(n){return n.transportType==="devtunnel"||!!n.devtunnelEndpoint}function c_(n){if(n.length===0)return"No node tunnel";const r=n.filter(c=>c.status==="offline").length;if(r>0)return`${r} offline`;const o=n.filter(c=>{var u;return((u=c.devtunnelHealth)==null?void 0:u.status)==="failed"}).length;if(o>0)return`${o} failed`;const s=n.filter(c=>{var u;return c.status!=="offline"&&((u=c.devtunnelHealth)==null?void 0:u.status)!=="healthy"}).length;return s>0?`${s} checking`:"Healthy"}function u_(n,r){var c;const o=(r==null?void 0:r.get(n.id))??n.name??n.id;if(n.status==="offline")return{label:o,status:"offline"};const s=((c=n.devtunnelHealth)==null?void 0:c.status)??"checking";return{label:o,status:s}}function d_(n){if(n.length===0)return"No nodes";const r=n.filter(s=>s.status==="offline").length;if(r>0)return`${r} offline`;const o=n.filter(s=>s.status==="busy").length;return o>0?`${o} busy`:"Healthy"}function f_(n,r){return{label:(r==null?void 0:r.get(n.id))??n.name??n.id,status:n.status}}function m_({connected:n,events:r,nodes:o=[],currentNode:s=null,nodeNameById:c,desktopUpdate:u=null,defaultOpen:m=!1,defaultActionMenuOpen:h=!1,onDesktopUpdate:y,onDesktopRestart:p,onReload:b,onRestart:g}){const[S,N]=v.useState(m),[T,E]=v.useState(h),[R,A]=v.useState(!0),[j,_]=v.useState(new Set),[U,z]=v.useState(!1),[Y,G]=v.useState(!1),P=v.useRef(null),ee=v.useRef(null),oe=v.useMemo(()=>r.filter(be=>o_(be)&&!j.has(be.id)),[r,j]),fe=v.useMemo(()=>r.find(be=>be.type===r_)??oe[0],[r,oe]),ue=v.useMemo(()=>s_(fe,c),[fe,c]),ie=v.useMemo(()=>{const be=new Map(o.map(Pe=>[Pe.id,Pe]));return s&&be.set(s.id,s),Array.from(be.values())},[s,o]),me=v.useMemo(()=>ie.filter(i_),[ie]),ae=me.some(be=>{var Pe;return be.status==="offline"||((Pe=be.devtunnelHealth)==null?void 0:Pe.status)==="failed"}),M=ie.some(be=>be.status==="offline"),q=ie.some(be=>be.status==="busy"),K=ie.length>0,de=(s==null?void 0:s.name)??"offline",C=(s==null?void 0:s.role)==="leader"?"Leader":(s==null?void 0:s.role)==="follower"?"Follower":"Node",V=u!==null,F=!!(V&&(u!=null&&u.updateAvailable)&&u.latestVersion),I=(u==null?void 0:u.latestVersion)??null,W=!!(V&&!F&&!I&&(u!=null&&u.detail)),se=U?"Relaunching runtime...":"Relaunch to apply update",re=Y?"Downloading and installing desktop update...":F&&I?`Available version ${I}`:W?(u==null?void 0:u.detail)??"Desktop update unavailable":"Desktop is current",ce=!!b,le=!!(V&&p),J=ce||le,ve=V||!!g,ye=V||!!g||ce,Se=ve?V?"Update":"Relaunch":"Reload",Be=ve?V?re:se:"Reload dashboard page",$e=ve?V?Y:U:!1,Ge=ve?V?$e||!F||!y:$e:!1,vt=V?F&&I?`Install desktop update ${I}`:W?"Desktop update unavailable":"Desktop is current":ve?U?"Relaunching runtime":"Relaunch runtime":"Reload dashboard page";function _e(){ee.current&&(clearTimeout(ee.current),ee.current=null)}function Ht(){_e(),N(!0)}function yt(){_e(),ee.current=setTimeout(()=>{N(!1),ee.current=null},180)}function Rr(){_e()}function ha(){_e(),E(!1),N(!1)}async function kt(){if(!(!g||U)){z(!0);try{await g()}finally{z(!1)}}}async function pn(){if(!(!F||!y||Y)){G(!0);try{await y()}finally{G(!1)}}}async function Lo(){if(!(!p||U)){E(!1),z(!0);try{await p()}finally{z(!1)}}}async function Cr(){if(!ve){await It();return}if(V){await pn();return}await kt()}async function It(){b&&(E(!1),await b())}return v.useEffect(()=>()=>{_e()},[]),v.useEffect(()=>{_(be=>{if(be.size===0)return be;const Pe=new Set(r.map(it=>it.id)),Me=new Set(Array.from(be).filter(it=>Pe.has(it)));return Me.size===be.size?be:Me})},[r]),v.useEffect(()=>{S||E(!1)},[S]),v.useEffect(()=>{if(!S)return;const be=Me=>{var it;(it=P.current)!=null&&it.contains(Me.target)||(_e(),E(!1),N(!1))},Pe=Me=>{Me.key==="Escape"&&(_e(),E(!1),N(!1))};return document.addEventListener("pointerdown",be),document.addEventListener("keydown",Pe),()=>{document.removeEventListener("pointerdown",be),document.removeEventListener("keydown",Pe)}},[S]),f.jsxs("div",{ref:P,className:"relative",children:[f.jsxs("button",{type:"button","aria-label":n?"Cluster link connected":"Cluster link reconnecting","aria-expanded":S,"aria-haspopup":"dialog",onClick:()=>N(be=>!be),onMouseEnter:Ht,onMouseLeave:yt,className:ne("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]",n?"bg-muted/40 text-muted-foreground hover:bg-muted/60 hover:text-foreground":"bg-destructive/8 text-destructive hover:bg-destructive/12",S&&(n?"bg-muted/60 text-foreground":"bg-destructive/12")),title:n?"Cluster link connected":"Cluster link reconnecting",children:[f.jsxs("span",{className:ne("relative flex h-2 w-2 shrink-0"),children:[n&&f.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-60"}),f.jsx("span",{className:ne("relative inline-flex h-2 w-2 rounded-full",n?"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:de}),f.jsx("span",{className:ne("shrink-0 rounded border px-1 py-px text-[8px] font-semibold uppercase tracking-[0.1em]",n?"border-emerald-500/25 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-destructive/30 bg-destructive/10 text-destructive"),children:C})]})]}),S&&f.jsxs("div",{role:"dialog","aria-label":"Live link connection events",onMouseEnter:Rr,onMouseLeave:ha,className:"absolute right-0 top-[calc(100%+0.4rem)] z-50 w-[18rem] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-lg border border-border/70 bg-background/96 shadow-[0_28px_90px_-42px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl 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:[n?f.jsx(Di,{className:"h-3 w-3 text-emerald-500"}):f.jsx(mT,{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:n?"· SSE connected":"· reconnecting"})]}),f.jsx("div",{className:ne("rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.12em]",n?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-destructive/30 bg-destructive/10 text-destructive"),children:n?"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:oe.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"}),ue?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mt-0.5 truncate text-[9px] leading-snug text-foreground/80",children:ue.text}),f.jsx("div",{className:"font-mono text-[8px] text-muted-foreground/60",children:ue.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:[M?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):q?f.jsx(Di,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Pl,{className:ne("h-3 w-3 shrink-0",K?"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:ne("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",M?"border-destructive/30 bg-destructive/10 text-destructive":q?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":K?"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:d_(ie)})]}),ie.length>0&&f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:ie.map(be=>{const{label:Pe,status:Me}=f_(be,c),it=Me==="offline",Tn=Me==="busy";return f.jsxs("div",{"aria-label":`${Pe} ${Me}`,className:ne("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",it?"bg-destructive/6":Tn?"bg-amber-500/6":"bg-emerald-500/5"),title:`${Pe} ${Me}`,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Pe}),it?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):Tn?f.jsx(vv,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Pl,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},be.id)})})]}),me.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:[ae?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):f.jsx(Pl,{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:ne("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",ae?"border-destructive/30 bg-destructive/10 text-destructive":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:c_(me)})]}),f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:me.map(be=>{var Gn;const{label:Pe,status:Me}=u_(be,c),it=Me==="failed"||Me==="offline",Tn=Me!=="healthy"&&Me!=="failed"&&Me!=="offline",Rn=(Gn=be.devtunnelHealth)!=null&&Gn.reason?`${Pe} ${Me}: ${be.devtunnelHealth.reason}`:`${Pe} ${Me}`;return f.jsxs("div",{"aria-label":`${Pe} ${Me}`,className:ne("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",it?"bg-destructive/6":Tn?"bg-muted/30":"bg-emerald-500/5"),title:Rn,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Pe}),it?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):Tn?f.jsx(vv,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):f.jsx(Pl,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},be.id)})})]}),f.jsxs("div",{children:[f.jsxs("button",{type:"button",onClick:()=>A(be=>!be),className:"flex w-full items-center justify-between px-2.5 py-1.5 text-left hover:bg-muted/30",children:[f.jsxs("span",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:["Notifications ",oe.length>0&&`(${oe.length})`]}),R?f.jsx(Ql,{className:"h-3 w-3 text-muted-foreground"}):f.jsx(nf,{className:"h-3 w-3 text-muted-foreground"})]}),R&&f.jsx("div",{className:"px-2 pb-2",children:f.jsx(n_,{events:oe,maxHeight:"12rem",density:"compact",emptyTitle:"No connection events yet",emptyDescription:"Node, election, and system events will appear here.",nodeNameById:c,onDismiss:be=>_(Pe=>new Set(Pe).add(be))})})]}),V&&(u==null?void 0:u.detail)&&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:ye&&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(Bt,{type:"button",variant:"ghost",size:"sm",className:ne("h-5 rounded-none border-0 px-1.5 text-[9px] font-medium hover:text-foreground [&_svg]:size-2.5",F?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>void Cr(),disabled:Ge,"aria-label":vt,"aria-describedby":"live-link-restart-hint",title:Be,children:[f.jsx(yv,{className:ne("h-2.5 w-2.5",$e&&"animate-pulse")}),f.jsx("span",{children:Se})]}),J&&f.jsx(Bt,{type:"button",variant:"ghost",size:"sm",className:ne("h-5 rounded-none border-l border-border/50 px-1 text-[9px] hover:text-foreground [&_svg]:size-2.5",F?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>E(be=>!be),"aria-label":"Open live link actions","aria-expanded":T,title:"Live link actions",children:f.jsx(Ql,{className:"h-2.5 w-2.5"})})]}),J&&T&&f.jsxs("div",{className:"absolute bottom-[calc(100%+0.25rem)] left-0 z-20 min-w-28 overflow-hidden rounded-md border border-border/70 bg-background text-[9px] shadow-lg",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:()=>void Cr(),disabled:Ge,"aria-label":vt,children:[f.jsx(yv,{className:ne("h-2.5 w-2.5",$e&&"animate-pulse")}),f.jsx("span",{children:Se})]}),le&&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:()=>void Lo(),disabled:U,"aria-label":"Restart Meshy Desktop",children:[f.jsx(af,{className:ne("h-2.5 w-2.5",U&&"animate-spin")}),f.jsx("span",{children:"Restart"})]}),ce&&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:()=>void It(),"aria-label":"Reload dashboard page",children:[f.jsx(af,{className:"h-2.5 w-2.5"}),f.jsx("span",{children:"Reload"})]})]}),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:Be})]})}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Bt,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:()=>_(new Set(r.map(be=>be.id))),disabled:oe.length===0,title:"Dismiss all notifications",children:"Dismiss all"}),f.jsx(Bt,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:()=>N(!1),children:"Close"})]})]})]})]})}const a0="dark",Nr="fluent",h_="clean",Xd="meshy-layout-default-migrated-to-compact",wf="true",p_="compact",g_=new Set(["airy","clean","fluent"]);function v_(n){return n!==null&&g_.has(n)}function gc(n){return n===p_?"fluent":v_(n)?n:null}function y_(n,r){const o=gc(n);return o===h_&&r!==wf?Nr:o??Nr}const Wi="symphony",d1="default",b_=new Set(["light","dark","system"]),x_=new Set(["porcelain","warm","finsight","edge","symphony","launcher"]),f1=v.createContext(null);function S_(n){const r=new URLSearchParams(n).get("theme");return m1(r)?r:null}function w_(n){const r=new URLSearchParams(n).get("palette");return im(r)}function E_(n){const r=new URLSearchParams(n).get("layout");return gc(r)}function N_(){if(typeof document>"u")return null;const n=document.documentElement;return{theme:n.classList.contains("dark")?"dark":"light",palette:im(n.getAttribute("data-palette"))??Wi,layout:gc(n.getAttribute("data-layout"))??Nr}}function SM(n,r=N_()){if(!r)return n;try{const o=/^[a-z][a-z\d+\-.]*:/i.test(n),s=typeof window<"u"?window.location.href:"http://localhost",c=new URL(n,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 n}}const Qd=.9;function r0(n){const r=n.trim().match(/^(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)%\s+(-?\d+(?:\.\d+)?)%$/);if(!r)return null;const o=(Number(r[1])%360+360)%360/60,s=Ji(Number(r[2])/100,0,1),c=Ji(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,[y,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((y+h)*255),Math.round((p+h)*255),Math.round((b+h)*255),255]}function T_(n){const r=n.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[xo(Number(o[1])),xo(Number(o[2])),xo(Number(o[3])),s0(o[4])];const s=r.match(/^rgba?\(\s*([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)(?:\s*\/\s*([+-]?\d+(?:\.\d+)?%?))?\s*\)$/i);return s?[xo(Number(s[1])),xo(Number(s[2])),xo(Number(s[3])),s0(s[4])]:null}function R_(n,r,o){const s=r0(n);if(!s)return null;if(o==="clean"||o==="fluent")return s;const c=r0(r);return c?[Kd(s[0],c[0],Qd),Kd(s[1],c[1],Qd),Kd(s[2],c[2],Qd),255]:null}function C_(){const n=document.querySelector(".dashboard-shell-header-panel");if(!n)return null;const r=T_(getComputedStyle(n).backgroundColor);return!r||r[3]===0?null:r}function o0(){var m,h;if(typeof window>"u"||typeof document>"u")return;const n=((h=(m=window.__TAURI__)==null?void 0:m.core)==null?void 0:h.invoke)??null;if(!n)return;const r=document.documentElement,o=r.classList.contains("dark")?"dark":"light",s=getComputedStyle(r),c=gc(r.getAttribute("data-layout"))??Nr,u=C_()??R_(s.getPropertyValue("--card"),s.getPropertyValue("--background"),c);n("sync_desktop_theme",{theme:o,backgroundColor:u}).catch(()=>{})}function l0(){if(typeof window>"u")return()=>{};if(o0(),typeof window.requestAnimationFrame!="function")return()=>{};const n=window.requestAnimationFrame(()=>o0());return()=>window.cancelAnimationFrame(n)}function Kd(n,r,o){return Math.round(n*o+r*(1-o))}function Ji(n,r,o){return Math.min(Math.max(n,r),o)}function xo(n){return Math.round(Ji(n,0,255))}function s0(n){if(n==null||n==="")return 255;const r=n.endsWith("%")?Number(n.slice(0,-1))/100:Number(n);return Math.round(Ji(r,0,1)*255)}function A_({children:n}){const[r,o]=v.useState(()=>typeof window<"u"?S_(window.location.search)??__(localStorage.getItem("meshy-theme"))??a0:a0),[s,c]=v.useState(()=>typeof window<"u"?w_(window.location.search)??M_(localStorage.getItem("meshy-palette"))??Wi:Wi),[u,m]=v.useState(()=>{if(typeof window<"u"){const h=E_(window.location.search);if(h)return localStorage.setItem(Xd,wf),h;const y=y_(localStorage.getItem("meshy-layout"),localStorage.getItem(Xd));return localStorage.setItem(Xd,wf),y}return Nr});return v.useEffect(()=>{const h=document.documentElement,y=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(y(r),localStorage.setItem("meshy-theme",r),r==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)"),b=()=>{y("system"),l0()};return p.addEventListener("change",b),()=>p.removeEventListener("change",b)}},[r]),v.useEffect(()=>{document.documentElement.setAttribute("data-palette",s),localStorage.setItem("meshy-palette",s)},[s]),v.useEffect(()=>{const h=document.documentElement;u===Nr?h.removeAttribute("data-layout"):h.setAttribute("data-layout",u),localStorage.setItem("meshy-layout",u)},[u]),v.useEffect(()=>l0(),[r,s,u]),f.jsx(f1.Provider,{value:{theme:r,setTheme:o,palette:s,setPalette:c,layout:u,setLayout:m},children:n})}function k_(){const n=v.useContext(f1);if(!n)throw new Error("useTheme must be used within ThemeProvider");return n}function m1(n){return n!==null&&b_.has(n)}function j_(n){return n!==null&&x_.has(n)}function __(n){return m1(n)?n:null}function im(n){return n===d1?"porcelain":j_(n)?n:null}function M_(n){return n===d1?null:im(n)}const O_=[{value:"light",label:"Light",icon:I0},{value:"dark",label:"Dark",icon:Y0},{value:"system",label:"System",icon:V0}],h1=[{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"}],p1=[{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 D_(){const{theme:n,setTheme:r,palette:o,setPalette:s,layout:c,setLayout:u}=k_(),[m,h]=v.useState(!1),y=v.useRef(null),p=v.useRef(null),b=n==="dark"?Y0:n==="light"?I0:V0,g=()=>{y.current&&(clearTimeout(y.current),y.current=null)},S=()=>{g(),y.current=setTimeout(()=>h(!1),180)};return v.useEffect(()=>{if(!m)return;const N=T=>{p.current&&!p.current.contains(T.target)&&h(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[m]),v.useEffect(()=>()=>g(),[]),f.jsxs("div",{ref:p,className:"relative",onMouseEnter:()=>{g(),h(!0)},onMouseLeave:S,children:[f.jsx(Bt,{variant:"ghost",size:"icon",onClick:()=>h(N=>!N),className:ne("h-8 w-8 rounded-sm",o!==Wi||c!==Nr?"text-primary":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),title:"Appearance","aria-haspopup":"menu","aria-expanded":m,children:f.jsx(b,{className:"h-4 w-4"})}),m&&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:[z_(c)," / ",L_(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:n})]}),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:O_.map(({value:N,label:T,icon:E})=>{const R=n===N;return f.jsxs("button",{type:"button",onClick:()=>r(N),role:"menuitemradio","aria-checked":R,className:ne("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",R?"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(E,{className:"h-3 w-3"}),T]},N)})}),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:p1.map(({value:N,label:T,hint:E})=>{const R=c===N;return f.jsxs("button",{type:"button",onClick:()=>u(N),role:"menuitemradio","aria-checked":R,className:ne("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",R?"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:ne("text-[10px] font-medium leading-tight",R?"text-primary":"text-foreground"),children:T}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:E})]}),R&&f.jsx(zi,{className:"h-3 w-3 text-primary"})]},N)})})]}),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(sT,{className:"h-2.5 w-2.5"}),"Palette"]}),f.jsx("div",{className:"space-y-1",children:h1.map(({value:N,label:T,hint:E})=>{const R=o===N;return f.jsxs("button",{type:"button",onClick:()=>s(N),role:"menuitemradio","aria-checked":R,className:ne("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",R?"border-primary/55 bg-primary/10":"border-border/45 bg-background/45 hover:border-border hover:bg-muted/55"),children:[f.jsx(U_,{value:N}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:ne("text-[10px] font-medium leading-tight",R?"text-primary":"text-foreground"),children:T}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:E})]}),R&&f.jsx(zi,{className:"h-3 w-3 text-primary"})]},N)})})]})]})]})]})}function z_(n){var r;return((r=p1.find(o=>o.value===n))==null?void 0:r.label)??n}function L_(n){var r;return((r=h1.find(o=>o.value===n))==null?void 0:r.label)??n}function U_({value:n}){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[n];return f.jsxs("div",{className:ne("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 Gl={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}},g1="meshy-dashboard-panel-state-v2",v1="meshy-dashboard-terminal-open-v1";function wM({operationsOpen:n}){return{layout:{desktopTasksOpen:!0,operationsOpen:n},sizes:{tasks:Gl.tasks.defaultSize,operations:Gl.operations.defaultSize,terminal:Gl.terminal.defaultSize}}}function Zd(n){return typeof n=="object"&&n!==null}function i0(n,r){return typeof n=="boolean"?n:r}function Fd(n,r,o){return typeof r=="number"&&Number.isFinite(r)?Il(n,r):o}function Il(n,r){const o=Gl[n];return Math.min(o.max,Math.max(o.min,r))}function EM(n,r){if(!n)return r;try{const o=n.getItem(g1);if(!o)return r;const s=JSON.parse(o);if(!Zd(s))return r;const c=Zd(s.layout)?s.layout:{},u=Zd(s.sizes)?s.sizes:{};return{layout:{desktopTasksOpen:i0(c.desktopTasksOpen,r.layout.desktopTasksOpen),operationsOpen:i0(c.operationsOpen,r.layout.operationsOpen)},sizes:{tasks:Fd("tasks",u.tasks,r.sizes.tasks),operations:Fd("operations",u.operations,r.sizes.operations),terminal:Fd("terminal",u.terminal,r.sizes.terminal)}}}catch{return r}}function NM(n,r){if(n)try{n.setItem(g1,JSON.stringify(r))}catch{}}function B_(n,r){if(!n)return r;try{const o=n.getItem(v1);return o==="true"?!0:o==="false"?!1:r}catch{return r}}function H_(n,r){if(n)try{n.setItem(v1,String(r))}catch{}}function c0(){var n;try{return((n=globalThis.window)==null?void 0:n.localStorage)??globalThis.localStorage??null}catch{return null}}function TM(n){return`${Number(n.toFixed(2))}rem`}function RM(n,r,o,s,c,u,m){const h=Number.isFinite(m)&&m>0?m:16;return n==="tasks"?Il(n,r+(c-o)/h):n==="operations"?Il(n,r+(o-c)/h):Il(n,r+(s-u)/h)}function CM(n,r,o){const s=o===0?0:o>0?-1:1;return Il(n,r+s*Gl[n].wheelStep)}const $_=7200*1e3;function P_(){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 Ti(){var n,r;return typeof window>"u"?null:((r=(n=window.__TAURI__)==null?void 0:n.core)==null?void 0:r.invoke)??null}function u0(n){return{currentVersion:null,latestVersion:null,updateAvailable:!1,checkedAt:new Date().toISOString(),releaseUrl:null,assetName:null,installable:!1,detail:n}}function Wd(n,r){if(n instanceof Error&&n.message.trim())return n.message;if(typeof n=="string"&&n.trim())return n;if(n&&typeof n=="object"&&"message"in n){const o=n.message;if(typeof o=="string"&&o.trim())return o}return r}function q_(n){return n.openedRelease?"Opened the latest Meshy release page.":n.installMethod==="tauri-updater"?"Installing desktop update. Meshy will relaunch to finish updating.":(n.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 V_(){const{cluster:n,events:r,sseConnected:o,systemInfo:s}=H0(),c=Vn(),[u,m]=v.useState(()=>B_(c0(),!1)),[h,y]=v.useState(""),[p,b]=v.useState(null),[g,S]=v.useState(null),N=!!Ti(),T=N?"max-w-none":"max-w-[1760px]",E=c.pathname==="/"||/^\/tasks\/[^/]+$/.test(c.pathname),R=v.useMemo(()=>{const z=new Map;for(const Y of(n==null?void 0:n.nodes)??[])z.set(Y.id,Y.name);return n!=null&&n.self&&z.set(n.self.id,n.self.name),z},[n==null?void 0:n.nodes,n==null?void 0:n.self]),A=v.useCallback(z=>{m(Y=>typeof z=="function"?z(Y):z)},[]);v.useEffect(()=>{H_(c0(),u)},[u]),v.useEffect(()=>{const z=Ti();if(!z){S(null);return}let Y=!1,G=!1;const P=oe=>{G||(G=!0,oe&&S(u0("Checking desktop update...")),z("check_desktop_update").then(fe=>{Y||S(fe)}).catch(fe=>{if(!Y){const ue=Wd(fe,"Desktop update check failed");S(ie=>ie!=null&&ie.updateAvailable?ie:u0(ue))}}).finally(()=>{G=!1}))};P(!0);const ee=window.setInterval(()=>P(!1),$_);return()=>{Y=!0,window.clearInterval(ee)}},[s==null?void 0:s.version]);async function j(){try{const z=await L0({reason:"restart"});Ve.info(`Restarting runtime. Follow ${z.logPath} for launch output.`),await i1({previousPid:z.pid})||Ve.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout.")}catch(z){Ve.error(z instanceof Error?z.message:"Runtime restart failed")}}async function _(){const z=Ti();if(!z){Ve.error("Desktop updater is not available in this window");return}try{Ve.info("Downloading desktop update...");const Y=await z("install_desktop_update");Ve.info(q_(Y))}catch(Y){Ve.error(Wd(Y,"Desktop update failed"))}}async function U(){const z=Ti();if(!z){Ve.error("Desktop restart is not available in this window");return}try{Ve.info("Restarting Meshy Desktop..."),await z("restart_desktop_app")}catch(Y){Ve.error(Wd(Y,"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:ne("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",T),children:[f.jsx("div",{className:"flex shrink-0 items-center gap-3 pr-3",children:f.jsxs(tf,{to:"/","aria-label":"Meshy home",className:"flex items-center gap-2",children:[f.jsx(P_,{}),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"}),E&&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:()=>y(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(G0,{className:"h-3 w-3 shrink-0 text-primary/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.nodeName})]}),f.jsx(nf,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsxs("button",{type:"button",onClick:()=>y(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(ON,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.projectLabel})]}),f.jsx(nf,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsx(tf,{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(eT,{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(hc,{"aria-label":"Search tasks",value:h,onChange:z=>y(z.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:[E&&f.jsx(Bt,{variant:"ghost",size:"icon",onClick:()=>A(z=>!z),"aria-label":u?"Close terminal":"Open terminal",title:u?"Close terminal":"Open terminal",className:ne("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(X0,{className:"h-4 w-4"})}),f.jsx($j,{}),f.jsx(D_,{}),f.jsx("div",{className:"mx-0 h-4 w-px shrink-0 bg-border/50"}),f.jsx(m_,{connected:o,events:r,nodes:(n==null?void 0:n.nodes)??[],currentNode:(n==null?void 0:n.self)??null,nodeNameById:R,desktopUpdate:g,onDesktopUpdate:g!=null&&g.updateAvailable?_:void 0,onDesktopRestart:N?U:void 0,onReload:N?()=>window.location.reload():void 0,onRestart:j})]})]})}),f.jsx("main",{className:ne("dashboard-shell-main min-h-0 flex-1 px-2 pb-2",E?"overflow-hidden":"overflow-y-auto"),children:f.jsx("div",{className:ne("dashboard-shell-content mx-auto h-full min-h-0",T),children:f.jsx(L2,{context:{terminalOpen:u,setTerminalOpen:A,headerSearchQuery:h,setHeaderSearchQuery:y,setHeaderTaskContext:b}})})})]})]})}const d0=v.lazy(async()=>({default:(await h0(()=>import("./DashboardPage-D5Gk6vkS.js").then(r=>r.D),__vite__mapDeps([0,1,2,3,4]))).DashboardPage})),Y_=v.lazy(async()=>({default:(await h0(()=>import("./SharedConversationPage-DVAMKKX3.js"),__vite__mapDeps([5,1]))).SharedConversationPage}));function G_(){return f.jsx(iE,{children:f.jsx(v.Suspense,{fallback:f.jsx(I_,{}),children:f.jsxs(B2,{children:[f.jsx(br,{path:"/shared/tasks/:shareId",element:f.jsx(Y_,{})}),f.jsxs(br,{element:f.jsx(tN,{children:f.jsx(V_,{})}),children:[f.jsx(br,{path:"/",element:f.jsx(d0,{})}),f.jsx(br,{path:"/nodes",element:f.jsx(dv,{to:"/",replace:!0})}),f.jsx(br,{path:"/tasks",element:f.jsx(dv,{to:"/",replace:!0})}),f.jsx(br,{path:"/tasks/:id",element:f.jsx(d0,{})})]})]})})})}function I_(){return f.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading workspace..."})}function X_(n){const r=n??(typeof window>"u"?void 0:window);r!=null&&r.__TAURI__&&r.addEventListener("contextmenu",o=>{o.preventDefault()})}function Q_(n){return f.jsx(jR,{className:"toaster group",style:{"--normal-bg":"hsl(var(--popover))","--normal-text":"hsl(var(--popover-foreground))","--normal-border":"hsl(var(--border))"},...n})}X_();Uw.createRoot(document.getElementById("root")).render(f.jsx(v.StrictMode,{children:f.jsxs(A_,{children:[f.jsx(G_,{}),f.jsx(Q_,{})]})}));export{Et as $,tM as A,Bt as B,zi as C,nM as D,w3 as E,_N as F,vA as G,Qy as H,hc as I,Zy as J,SM as K,UN as L,TN as M,Ij as N,Ax as O,YN as P,eM as Q,q0 as R,G0 as S,aM as T,Vl as U,Gj as V,P0 as W,Q0 as X,Mk as Y,Z3 as Z,F3 as _,W3 as a,A3 as a$,yM as a0,Yl as a1,yf as a2,Yi as a3,Gi as a4,Xi as a5,Qi as a6,Ii as a7,Zi as a8,Ki as a9,Fy as aA,af as aB,sM as aC,xM as aD,oM as aE,lM as aF,gM as aG,o1 as aH,vM as aI,bf as aJ,dT as aK,_3 as aL,M3 as aM,EM as aN,wM as aO,c0 as aP,NM as aQ,CM as aR,TM as aS,RM as aT,x3 as aU,QE as aV,jE as aW,I3 as aX,G3 as aY,X3 as aZ,FE as a_,h0 as aa,e3 as ab,Ky as ac,xA as ad,m3 as ae,X0 as af,Pl as ag,EN as ah,f3 as ai,h3 as aj,d3 as ak,mT as al,aT as am,uN as an,$N as ao,Jl as ap,hM as aq,QN as ar,n_ as as,Xk as at,kN as au,Qk as av,bM as aw,qj as ax,V3 as ay,qR as az,zR as b,r3 as b0,n3 as b1,a3 as b2,o3 as b3,RE as b4,$j as b5,k3 as b6,j3 as b7,y3 as b8,p3 as b9,l3 as bA,K3 as bB,U3 as bC,L3 as bD,z3 as bE,O3 as bF,D3 as bG,B3 as bH,yA as bI,Pj as bJ,f0 as bK,yN as bL,P3 as bM,$3 as bN,H3 as bO,q3 as bP,Q3 as bQ,Y3 as bR,g3 as ba,v3 as bb,b3 as bc,F_ as bd,Vn as be,T0 as bf,Z_ as bg,H0 as bh,pM as bi,tj as bj,mM as bk,iM as bl,cM as bm,dM as bn,uM as bo,fM as bp,S3 as bq,rM as br,Vj as bs,R3 as bt,C3 as bu,T3 as bv,N3 as bw,J_ as bx,t3 as by,W_ as bz,je as c,ne as d,dy as e,Fx as f,i3 as g,u3 as h,TE as i,f as j,s3 as k,ON as l,J3 as m,nf as n,wo as o,c3 as p,E3 as q,v as r,ox as s,Ve as t,am as u,lx as v,rm as w,eT as x,Ql as y,sT as z};
341
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return v.useEffect(()=>{var s;document.getElementById((s=n.current)==null?void 0:s.getAttribute("aria-describedby"))||console.warn(r)},[r,n]),null},qk=jx,Vk=_x,Yk=Mx,qx=Ox,Vx=Dx,Yx=Hx,Gx=Px,Ix=Lx,Xx=Bx;const yf=qk,bf=Vk,Gk=Yk,Qx=v.forwardRef(({className:n,...r},o)=>f.jsx(qx,{className:ne("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",n),...r,ref:o}));Qx.displayName=qx.displayName;const Yi=v.forwardRef(({className:n,...r},o)=>f.jsxs(Gk,{children:[f.jsx(Qx,{}),f.jsx(Vx,{ref:o,className:ne("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%]",n),...r})]}));Yi.displayName=Vx.displayName;const Gi=({className:n,...r})=>f.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",n),...r});Gi.displayName="AlertDialogHeader";const Ii=({className:n,...r})=>f.jsx("div",{className:ne("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...r});Ii.displayName="AlertDialogFooter";const Xi=v.forwardRef(({className:n,...r},o)=>f.jsx(Ix,{ref:o,className:ne("text-sm font-semibold",n),...r}));Xi.displayName=Ix.displayName;const Qi=v.forwardRef(({className:n,...r},o)=>f.jsx(Xx,{ref:o,className:ne("text-[11px] text-muted-foreground",n),...r}));Qi.displayName=Xx.displayName;const Ki=v.forwardRef(({className:n,...r},o)=>f.jsx(Yx,{ref:o,className:ne(zf(),n),...r}));Ki.displayName=Yx.displayName;const Zi=v.forwardRef(({className:n,...r},o)=>f.jsx(Gx,{ref:o,className:ne(zf({variant:"outline"}),"mt-2 sm:mt-0",n),...r}));Zi.displayName=Gx.displayName;const Ik={online:"bg-emerald-500",busy:"bg-amber-500",offline:"bg-destructive"};function Xk({status:n}){return f.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5",children:[n==="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:ne("relative inline-flex h-2.5 w-2.5 rounded-full",Ik[n])})]})}function Qk({role:n,size:r="default"}){return f.jsx(Et,{variant:n==="leader"?"default":"secondary",className:ne(r==="compact"?"px-1.5 py-0 text-[9px] leading-4":"text-[11px]"),children:n})}const Kx={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 K3({status:n,size:r="default"}){const o=Kx[n],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(Et,{variant:o.variant,className:ne("rounded-sm font-medium shadow-none",s,o.className),children:[f.jsx("span",{className:ne("rounded-full",o.dotClass)}),n]})}function Z3({status:n,isNative:r=!1,size:o="default",className:s}){const c=Kx[n],u=[n,r?"native":null].filter(Boolean).join(", "),m=o==="compact"?"h-1.5 w-1.5":"h-2 w-2";return f.jsxs("span",{className:ne("inline-flex shrink-0 items-center gap-1",s),title:u,"aria-label":u,children:[f.jsx("span",{className:ne("rounded-full",m,c.dotClass),title:n}),r&&f.jsx("span",{className:ne("rounded-full bg-sky-500",m),title:"native"})]})}const Kk={critical:{variant:"destructive",label:"Critical"},high:{variant:"outline",label:"High"},normal:{variant:"secondary",label:"Normal"},low:{variant:"secondary",label:"Low"}};function F3({priority:n}){const r=Kk[n];return f.jsx(Et,{variant:r.variant,className:"rounded-sm px-1.5 py-0 text-[10px] leading-4 shadow-none",children:r.label})}function Zk(n){return[{key:"workspace",label:"Workspace",value:n==null?void 0:n.workspace},{key:"node",label:"Node app",value:n==null?void 0:n.node},{key:"core",label:"Core",value:n==null?void 0:n.core},{key:"dashboard",label:"Dashboard",value:n==null?void 0:n.dashboard},{key:"api",label:"API",value:n==null?void 0:n.api}].filter(o=>o.value)}function yo({label:n,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:n}),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 Fk({formatDateTime:n,viewInfo:r}){var s,c,u,m,h,y,p,b;const o=Zk(r.packages);return f.jsxs(Yl,{value:"about","data-about-layout":"compact",className:"mt-0 space-y-2",children:[f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(uN,{className:"h-3.5 w-3.5 text-primary"}),"Repository & runtime"]}),f.jsx(Un,{className:"text-[10px]",children:"Build source and runtime identity for this node."})]}),f.jsxs(Bn,{className:"space-y-2 px-3 pb-2.5",children:[(s=r.repository)!=null&&s.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(kN,{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(yo,{label:"Branch",value:((c=r.repository)==null?void 0:c.branch)??"Unavailable",mono:!!((u=r.repository)!=null&&u.branch)}),f.jsx(yo,{label:"Commit",value:((m=r.repository)==null?void 0:m.commit)??"Unavailable",mono:!!((h=r.repository)!=null&&h.commit)}),f.jsx(yo,{label:"Runtime",value:`${r.packageName??"meshy"} ${r.version}`,mono:!0}),f.jsx(yo,{label:"Node.js",value:((y=r.runtime)==null?void 0:y.nodeVersion)??"Unavailable",mono:!!((p=r.runtime)!=null&&p.nodeVersion)}),f.jsx(yo,{label:"PID",value:r.runtime?String(r.runtime.pid):"Unavailable",mono:!!r.runtime}),f.jsx(yo,{label:"Started",value:n((b=r.runtime)==null?void 0:b.startedAt)})]})]})]}),f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(zN,{className:"h-3.5 w-3.5 text-primary"}),"Package versions"]}),f.jsx(Un,{className:"text-[10px]",children:"Version snapshot for the packages most relevant to this dashboard session."})]}),f.jsx(Bn,{"data-package-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:o.map(g=>{var S,N;return 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:g.label}),f.jsx("div",{className:"min-w-0 truncate text-[10px] text-muted-foreground",children:(S=g.value)==null?void 0:S.name}),f.jsx(Et,{variant:"outline",className:"w-fit rounded-sm border-border/70 bg-background/60 font-mono text-[10px]",children:(N=g.value)==null?void 0:N.version})]},g.key)})})]})]})}const hc=v.forwardRef(({className:n,type:r,...o},s)=>f.jsx("input",{type:r,className:ne("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",n),ref:s,...o}));hc.displayName="Input";function Wk(){return we("/system/quick-chats")}function Jk(n){return we("/system/quick-chats",{method:"PUT",body:JSON.stringify({quickChats:n})})}const xf="quick-chats:updated";function ej(){typeof window>"u"||window.dispatchEvent(new CustomEvent(xf))}function tj(){const[n,r]=v.useState([]),[o,s]=v.useState(!0),[c,u]=v.useState(!1),[m,h]=v.useState(null),y=v.useCallback(async()=>{s(!0);try{const b=await Wk();r(b.quickChats),h(null)}catch(b){h(b instanceof Error?b.message:"Failed to load quick chats")}finally{s(!1)}},[]),p=v.useCallback(async b=>{u(!0);try{const g=await Jk(b);return r(g.quickChats),h(null),ej(),g.quickChats}catch(g){const S=g instanceof Error?g.message:"Failed to save quick chats";throw h(S),g}finally{u(!1)}},[]);return v.useEffect(()=>{y()},[y]),v.useEffect(()=>{if(typeof window>"u")return;const b=()=>{y()};return window.addEventListener(xf,b),()=>window.removeEventListener(xf,b)},[y]),{error:m,loading:o,quickChats:n,refresh:y,save:p,saving:c}}function Zx(n){return n.trim().replace(/^\/+/,"").toLowerCase()}function Fx(n,r){const o=n.trim();if(!o.startsWith("/"))return[];const s=Zx(o);return r.filter(c=>c.alias.startsWith(s))}function Fi(n,r){return r<=0?-1:(n%r+r)%r}function W3(n,r,o=0){const s=Fx(n,r),c=Fi(o,s.length);return c>=0?s[c]??null:null}function J3(n,r,o){const s=Fi(n,r);return s<0?0:Fi(s+o,r)}function eM({query:n,quickChats:r,selectedIndex:o=0,onSelect:s,onActiveIndexChange:c}){const u=Fx(n,r);if(u.length===0)return null;const m=Fi(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(q0,{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,y)=>f.jsxs("button",{type:"button",role:"option","aria-selected":y===m,"data-selected":y===m?"true":void 0,onMouseEnter:()=>c==null?void 0:c(y),onClick:()=>s(h),className:ne("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:ne("shrink-0 font-mono text-[9px] leading-3 text-primary/70",y===m&&"text-primary"),children:["/",h.alias]}),f.jsx("span",{"data-quick-chat-prompt":"true",className:ne("line-clamp-1 min-w-0 text-[9px] leading-3 text-muted-foreground",y===m&&"text-primary/90"),children:h.prompt})]},h.alias))})]})}const nj="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 aj=0;function _i(n,r=0){return{id:n?`${n.alias}:${r}`:`new:${aj++}`,alias:(n==null?void 0:n.alias)??"",prompt:(n==null?void 0:n.prompt)??""}}function Sf(n){return{quickChats:n.map(r=>({alias:Zx(r.alias),prompt:r.prompt.trim()})).filter(r=>r.alias.length>0&&r.prompt.length>0)}}function rj(n,r){const o=Sf(n).quickChats,s=r.map((u,m)=>_i(u,m)),c=Sf(s).quickChats;return JSON.stringify(o)!==JSON.stringify(c)}function oj(){const{error:n,loading:r,quickChats:o,save:s,saving:c}=tj(),[u,m]=v.useState(()=>o.map((g,S)=>_i(g,S))),h=u.length>0,y=v.useMemo(()=>Sf(u),[u]),p=v.useMemo(()=>rj(u,o),[u,o]);v.useEffect(()=>{m(o.map((g,S)=>_i(g,S)))},[o]);async function b(){try{await s(y.quickChats),Ve.success("Quick chats saved")}catch(g){Ve.error(g instanceof Error?g.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(q0,{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(Bt,{type:"button",variant:"outline",onClick:()=>m(g=>[...g,_i(void 0,g.length)]),className:"h-7 rounded-sm px-2 text-[10px]",children:[f.jsx(YN,{className:"h-3.5 w-3.5"}),"Add"]}),f.jsxs(Bt,{type:"button",onClick:b,disabled:c||!p,className:"h-7 rounded-sm px-2 text-[10px]",children:[c?f.jsx(UN,{className:"h-3.5 w-3.5 animate-spin"}):f.jsx(WN,{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((g,S)=>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(hc,{"aria-label":`Quick chat ${S+1} alias`,value:g.alias,onChange:N=>m(T=>T.map(E=>E.id===g.id?{...E,alias:N.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 ${S+1} prompt`,value:g.prompt,onChange:N=>m(T=>T.map(E=>E.id===g.id?{...E,prompt:N.target.value}:E)),placeholder:"Prompt text",className:nj}),f.jsx(Bt,{type:"button",variant:"ghost",size:"icon",onClick:()=>m(N=>N.filter(T=>T.id!==g.id)),"aria-label":`Remove quick chat ${S+1}`,className:"h-7 w-7 rounded-sm text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:f.jsx(dT,{className:"h-3.5 w-3.5"})})]},g.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."}),n&&f.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:n})]})}var pc="Checkbox",[lj]=Xa(pc),[sj,lm]=lj(pc);function ij(n){const{__scopeCheckbox:r,checked:o,children:s,defaultChecked:c,disabled:u,form:m,name:h,onCheckedChange:y,required:p,value:b="on",internal_do_not_use_render:g}=n,[S,N]=Ro({prop:o,defaultProp:c??!1,onChange:y,caller:pc}),[T,E]=v.useState(null),[R,A]=v.useState(null),j=v.useRef(!1),_=T?!!m||!!T.closest("form"):!0,U={checked:S,disabled:u,setChecked:N,control:T,setControl:E,name:h,form:m,value:b,hasConsumerStoppedPropagationRef:j,required:p,defaultChecked:qa(c)?!1:c,isFormControl:_,bubbleInput:R,setBubbleInput:A};return f.jsx(sj,{scope:r,...U,children:cj(g)?g(U):s})}var Wx="CheckboxTrigger",Jx=v.forwardRef(({__scopeCheckbox:n,onKeyDown:r,onClick:o,...s},c)=>{const{control:u,value:m,disabled:h,checked:y,required:p,setControl:b,setChecked:g,hasConsumerStoppedPropagationRef:S,isFormControl:N,bubbleInput:T}=lm(Wx,n),E=tt(c,b),R=v.useRef(y);return v.useEffect(()=>{const A=u==null?void 0:u.form;if(A){const j=()=>g(R.current);return A.addEventListener("reset",j),()=>A.removeEventListener("reset",j)}},[u,g]),f.jsx(Ue.button,{type:"button",role:"checkbox","aria-checked":qa(y)?"mixed":y,"aria-required":p,"data-state":r1(y),"data-disabled":h?"":void 0,disabled:h,value:m,...s,ref:E,onKeyDown:Le(r,A=>{A.key==="Enter"&&A.preventDefault()}),onClick:Le(o,A=>{g(j=>qa(j)?!0:!j),T&&N&&(S.current=A.isPropagationStopped(),S.current||A.stopPropagation())})})});Jx.displayName=Wx;var sm=v.forwardRef((n,r)=>{const{__scopeCheckbox:o,name:s,checked:c,defaultChecked:u,required:m,disabled:h,value:y,onCheckedChange:p,form:b,...g}=n;return f.jsx(ij,{__scopeCheckbox:o,checked:c,defaultChecked:u,disabled:h,required:m,onCheckedChange:p,name:s,form:b,value:y,internal_do_not_use_render:({isFormControl:S})=>f.jsxs(f.Fragment,{children:[f.jsx(Jx,{...g,ref:r,__scopeCheckbox:o}),S&&f.jsx(a1,{__scopeCheckbox:o})]})})});sm.displayName=pc;var e1="CheckboxIndicator",t1=v.forwardRef((n,r)=>{const{__scopeCheckbox:o,forceMount:s,...c}=n,u=lm(e1,o);return f.jsx(Mo,{present:s||qa(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",...n.style}})})});t1.displayName=e1;var n1="CheckboxBubbleInput",a1=v.forwardRef(({__scopeCheckbox:n,...r},o)=>{const{control:s,hasConsumerStoppedPropagationRef:c,checked:u,defaultChecked:m,required:h,disabled:y,name:p,value:b,form:g,bubbleInput:S,setBubbleInput:N}=lm(n1,n),T=tt(o,N),E=wb(u),R=db(s);v.useEffect(()=>{const j=S;if(!j)return;const _=window.HTMLInputElement.prototype,z=Object.getOwnPropertyDescriptor(_,"checked").set,Y=!c.current;if(E!==u&&z){const G=new Event("click",{bubbles:Y});j.indeterminate=qa(u),z.call(j,qa(u)?!1:u),j.dispatchEvent(G)}},[S,E,u,c]);const A=v.useRef(qa(u)?!1:u);return f.jsx(Ue.input,{type:"checkbox","aria-hidden":!0,defaultChecked:m??A.current,required:h,disabled:y,name:p,value:b,form:g,...r,tabIndex:-1,ref:T,style:{...r.style,...R,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});a1.displayName=n1;function cj(n){return typeof n=="function"}function qa(n){return n==="indeterminate"}function r1(n){return qa(n)?"indeterminate":n?"checked":"unchecked"}const o1=v.forwardRef(({className:n,...r},o)=>f.jsx(sm,{ref:o,className:ne("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",n),...r,children:f.jsx(t1,{className:ne("flex items-center justify-center text-current"),children:f.jsx(zi,{className:"h-3.5 w-3.5"})})}));o1.displayName=sm.displayName;const e0=["queued","running"];function uj(n){return n.map(r=>`${r.id}:${r.name}`).join("\0")}function dj(n){return n==="claude"||n==="codex"||n==="copilot"}function l1(n){var o;if(n.kind!=="agent.upgrade")return null;const r=(o=n.payload)==null?void 0:o.agent;return dj(r)?`${n.nodeId}:${r}`:null}function fj(n){return n.status==="succeeded"||n.status==="failed"}async function s1(n,r={}){const o=r.getOperation??TE,s=r.pollIntervalMs??2e3,c=r.timeoutMs??24e4,u=Date.now()+c;let m=n;for(;!fj(m)&&Date.now()<u;)await hj(s),m=await o(n.id);return m}async function mj(n,r=RE){const o=new Set(n),s=await Promise.all(e0.map(u=>r({kind:"agent.upgrade",status:u}))),c=new Map;for(const u of s.flat()){if(!e0.includes(u.status)||o.size>0&&!o.has(u.nodeId))continue;const m=l1(u);if(!m)continue;const h=c.get(m);(!h||u.updatedAt>h.updatedAt)&&c.set(m,u)}return c}function hj(n){return new Promise(r=>setTimeout(r,n))}const pj=1500,gj=1e3,vj=9e4;async function i1(n={}){const r=n.fetchHealth??yj,o=n.initialDelayMs??pj,s=n.pollIntervalMs??gj,c=n.previousPid,u=n.reload??(()=>window.location.reload()),m=n.sleep??xj,h=n.timeoutMs??vj,y=Date.now()+h;let p=!1;for(o>0&&await m(o);Date.now()<=y;){const b=bj(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 yj(){try{const n=await fetch("/api/system/health",{cache:"no-store"}),r=await n.json().catch(()=>null),o=r&&typeof r=="object"&&typeof r.pid=="number"?r.pid:void 0;return{ok:n.ok,pid:o}}catch{return!1}}function bj(n){return typeof n=="boolean"?{ok:n}:n}function xj(n){return new Promise(r=>window.setTimeout(r,n))}function Sj(n,r=!0){return r?(n==null?void 0:n.restartMode)==="development"?"Restart dev runtime":n!=null&&n.updateAvailable?"Restart to update":"Restart runtime":n!=null&&n.updateAvailable?"Restart follower to update":"Restart follower"}function wj({checkedLabel:n,disableAuthDefault:r,endpoint:o,isLiveLocalNode:s,nodeId:c,nodeName:u,onRefresh:m,pid:h,transportType:y,update:p,workDir:b}){const g=Sj(p,s),[S,N]=v.useState(null),[T,E]=v.useState(()=>t0({disableAuthDefault:r,endpoint:o,nodeName:u,transportType:y,workDir:b})),[R,A]=v.useState(!1),[j,_]=v.useState(!1),[U,z]=v.useState(!1);v.useEffect(()=>{E(t0({disableAuthDefault:r,endpoint:o,nodeName:u,transportType:y,workDir:b}))},[r,o,u,y,b]);async function Y(){if(!c||R||j)return;const oe=p.updateAvailable?"update":"restart",fe=Tj(T);if(T.port.trim()&&(fe==null?void 0:fe.port)===void 0){Ve.error("Runtime restart port must be a positive integer");return}const ue=fe?{reason:oe,startArgs:fe}:{reason:oe};A(!0);try{if(s){const M=await L0(ue);N({...M,pid:M.pid??h,status:"accepted"}),Ve.info(`Restarting ${u} from a detached helper. PID ${M.pid??h??"unknown"} will not stay attached to the original terminal window; follow ${M.logPath} for launch output.`),i1({previousPid:M.pid??h}).then(q=>{q||(A(!1),Ve.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout. Refresh the page after the node finishes starting."))}).catch(q=>{A(!1),Ve.error(q instanceof Error?q.message:"Runtime restart recovery failed")});return}const ie=await AE(c,ue);N({operationId:ie.id,pid:h,status:ie.status}),Ve.info(`Restart requested on ${u}. Operation ${Id(ie.id)} will hand off to a detached process, so the new runtime will not stay attached to the original terminal window.`);const me=await s1(ie,{timeoutMs:6e4}),ae=Nj(me);N({command:ae==null?void 0:ae.command,logPath:ae==null?void 0:ae.logPath,mode:ae==null?void 0:ae.mode,operationId:me.id,pid:(ae==null?void 0:ae.pid)??h,status:me.status}),me.status==="succeeded"?(await(m==null?void 0:m()),Ve.success(`Restart handoff accepted on ${u}. Follow ${(ae==null?void 0:ae.logPath)??"the node restart log"} for launch output.`)):me.status==="failed"?Ve.error(me.error??`Restart failed on ${u}`):Ve.info(`Restart operation ${Id(me.id)} is still ${me.status}. More details will update after the node reports back.`),A(!1)}catch(ie){A(!1),Ve.error(ie instanceof Error?ie.message:"Runtime restart failed")}}async function G(){if(!(!s||R||j)){_(!0);try{const oe=await EE();Ve.info(`Stopping Meshy process ${oe.pid}`)}catch(oe){_(!1),Ve.error(oe instanceof Error?oe.message:"Runtime stop failed")}}}const P=R?"restarting":j?"stopping":(S==null?void 0:S.status)??"idle",ee=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(Di,{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:ee?"Development launcher":`Latest ${p.latestVersion??"—"}`})]})]}),f.jsx("div",{className:"flex items-center gap-1.5",children:f.jsx(Et,{variant:p.updateAvailable?"default":"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 font-mono text-[10px]",children:ee?"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 ",n]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[s&&f.jsxs(yf,{children:[f.jsx(bf,{asChild:!0,children:f.jsxs(Bt,{type:"button",size:"sm",variant:"ghost",disabled:R||j,className:"h-7 rounded-sm px-2 text-[11px] text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:[f.jsx(IN,{className:ne("mr-1 h-3.5 w-3.5",j&&"animate-pulse")}),j?"Stopping":"Stop"]})}),f.jsxs(Yi,{className:"max-w-[22rem] gap-2 rounded-sm p-4",children:[f.jsxs(Gi,{className:"space-y-1",children:[f.jsx(Xi,{className:"text-sm",children:"Stop runtime?"}),f.jsx(Qi,{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(Ii,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(Zi,{className:"h-7 rounded-sm px-2 text-[11px]",children:"Cancel"}),f.jsx(Ki,{className:"h-7 rounded-sm bg-destructive px-2 text-[11px] text-destructive-foreground hover:bg-destructive/90",onClick:()=>void G(),children:"Stop runtime"})]})]})]}),f.jsxs(yf,{children:[f.jsx(bf,{asChild:!0,children:f.jsxs(Bt,{type:"button",size:"sm",variant:p.updateAvailable?"default":"outline",disabled:!c||R||j,className:"h-7 rounded-sm px-2 text-[11px]",children:[f.jsx(af,{className:ne("mr-1 h-3.5 w-3.5",R&&"animate-spin")}),R?"Restarting…":g]})}),f.jsxs(Yi,{className:"max-w-[28rem] gap-3 rounded-sm p-4",children:[f.jsxs(Gi,{className:"space-y-1",children:[f.jsxs(Xi,{className:"text-sm",children:[g,"?"]}),f.jsxs(Qi,{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(Ej,{value:T,onChange:E}),f.jsxs(Ii,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(Zi,{className:"h-7 rounded-sm px-2 text-[11px]",children:"Cancel"}),f.jsx(Ki,{className:"h-7 rounded-sm px-2 text-[11px]",onClick:()=>void Y(),children:g})]})]})]})]})]}),f.jsxs("div",{className:"border-t border-border/50",children:[f.jsxs("button",{type:"button",onClick:()=>z(oe=>!oe),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(X0,{className:"h-3 w-3"}),"Restart details"]}),f.jsx(Ql,{className:ne("h-3 w-3 transition-transform duration-150",U&&"rotate-180")})]}),U&&f.jsxs("div",{className:"border-t border-border/50 bg-muted/20 px-3 py-2 space-y-1",children:[f.jsx(yr,{label:"Current PID",value:h===void 0?"—":String(h),mono:h!==void 0}),f.jsx(yr,{label:"Restart PID",value:(S==null?void 0:S.pid)===void 0?"Pending":String(S.pid),mono:(S==null?void 0:S.pid)!==void 0}),f.jsx(yr,{label:"Operation",value:S!=null&&S.operationId?Id(S.operationId):"Local direct request",mono:!!(S!=null&&S.operationId)}),f.jsx(yr,{label:"Status",value:(S==null?void 0:S.status)??(R?"requested":"idle")}),f.jsx(yr,{label:"Launcher",value:(S==null?void 0:S.command)??"Available after restart",mono:!!(S!=null&&S.command)}),f.jsx(yr,{label:"Log",value:(S==null?void 0:S.logPath)??"Available after restart",mono:!!(S!=null&&S.logPath)}),f.jsx(yr,{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 Ej({onChange:n,value:r}){const o=(s,c)=>{n({...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(Bl,{label:"HTTP port",value:r.port,onChange:s=>o("port",s),inputMode:"numeric"}),f.jsx(Bl,{label:"Node name",value:r.name,onChange:s=>o("name",s)}),f.jsx(Bl,{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(ox,{value:r.transport,onValueChange:s=>o("transport",c1(s)),children:[f.jsx(am,{className:"h-7 rounded-md border-border/70 bg-background/70 px-2 text-[10px]",children:f.jsx(lx,{placeholder:"Transport"})}),f.jsxs(rm,{children:[f.jsx(wo,{className:"py-1 text-[11px]",value:"inherit",children:"current / default"}),f.jsx(wo,{className:"py-1 text-[11px]",value:"direct",children:"direct"}),f.jsx(wo,{className:"py-1 text-[11px]",value:"devtunnel",children:"devtunnel"}),f.jsx(wo,{className:"py-1 text-[11px]",value:"tailscale",children:"tailscale"})]})]})]}),f.jsx(Bl,{label:"Working directory",value:r.workDir,onChange:s=>o("workDir",s)}),f.jsx(Bl,{label:"Config path",value:r.config,onChange:s=>o("config",s),className:"sm:col-span-2"}),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(o1,{className:"h-3.5 w-3.5",checked:r.disableAuth,onCheckedChange:s=>n({...r,disableAuth:s===!0,disableAuthKnown:!0})}),"Disable auth"]})]})]})}function Bl({className:n,inputMode:r,label:o,onChange:s,value:c}){return f.jsxs("label",{className:ne("space-y-1",n),children:[f.jsx("span",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:o}),f.jsx(hc,{className:"h-7 rounded-md px-2 text-[10px]",inputMode:r,value:c,onChange:u=>s(u.target.value)})]})}function yr({label:n,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:n}),f.jsx("span",{className:ne("break-all text-right text-foreground",o&&"font-mono"),children:r})]})}function Nj(n){const r=n.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 t0(n){return{port:Rj(n.endpoint),name:n.nodeName,join:"",transport:c1(n.transportType),workDir:n.workDir??"",config:"",disableAuth:n.disableAuthDefault===!0,disableAuthKnown:n.disableAuthDefault!==void 0}}function Tj(n){const r={},o=Number(n.port.trim());return n.port.trim()&&Number.isInteger(o)&&o>0&&(r.port=o),n.name.trim()&&(r.name=n.name.trim()),n.join.trim()&&(r.join=n.join.trim()),n.transport!=="inherit"&&(r.transport=n.transport),n.workDir.trim()&&(r.workDir=n.workDir.trim()),n.config.trim()&&(r.config=n.config.trim()),n.disableAuthKnown&&(r.disableAuth=n.disableAuth),Object.keys(r).length>0?r:void 0}function c1(n){return n==="direct"||n==="devtunnel"||n==="tailscale"?n:"inherit"}function Rj(n){if(!n)return"";try{return new URL(n).port||""}catch{return""}}function Id(n){return n.length<=8?n:n.slice(0,8)}function Hl({formatDateTime:n,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:n(o==null?void 0:o.checkedAt)})]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof(o==null?void 0:o.authenticated)=="boolean"&&f.jsx(Et,{variant:o.authenticated?"default":"outline",className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o.authenticated?"auth ok":"auth required"}),f.jsx(Et,{variant:s(o==null?void 0:o.status),className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:(o==null?void 0:o.status)??"unknown"})]})]})}function Yt(n){if(n==null||n==="")return"Unavailable";const r=new Date(n);return Number.isNaN(r.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(r)}function Cj(n){const r=Math.max(0,Math.floor(n)),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 n0(n){if(n==null||Number.isNaN(n))return"Unavailable";const r=["B","KB","MB","GB","TB"];let o=n,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 So(n){return n==="ok"?"default":n==="missing"||n==="install-failed"||n==="login-failed"?"destructive":n==="not-authenticated"||n==="unsupported-platform"?"outline":"secondary"}function Aj(n){return n.available?f.jsxs(Et,{className:"gap-1 rounded-sm px-1.5 py-0 text-[10px]",children:[f.jsx(Pl,{className:"h-3 w-3"}),"Available"]}):f.jsxs(Et,{variant:"destructive",className:"gap-1 rounded-sm px-1.5 py-0 text-[10px]",children:[f.jsx(EN,{className:"h-3 w-3"}),"Unavailable"]})}function kj(n){return n.update?n.update.updateAvailable?f.jsxs(Et,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:["Update ",n.update.latestVersion]}):f.jsx(Et,{variant:"secondary",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:"Up to date"}):null}function jj(n){return n.available?null:n.metadataStatus??null}function _j(n){var o;const r=`npm install -g ${(o=n.update)==null?void 0:o.packageName}@latest`;return n.id==="claude"?`${r} --include=optional --ignore-scripts=false`:r}function Mj(n){if(n.error)return n.error;const r=n.result;return(r==null?void 0:r.detail)??null}function et({label:n,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:n}),f.jsx("span",{className:ne("break-all text-right text-[11px] text-foreground",o&&"font-mono text-[11px]"),children:r})]})}function $l({label:n,value:r,mono:o=!1,className:s}){return f.jsxs("div",{className:ne("min-w-0 space-y-0.5",s),children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:n}),f.jsx("div",{className:ne("truncate text-[11px] text-foreground",o&&"font-mono",n==="Path"&&"break-all whitespace-normal"),children:r})]})}function Oj({agent:n,nodeName:r,activeOperation:o,onUpgrade:s}){var y,p;const c=((y=n.update)==null?void 0:y.updateAvailable)===!0,u=kj(n),m=!!o,h=jj(n);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(P0,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),f.jsx("span",{className:"truncate",children:n.label})]}),f.jsxs("div",{className:"truncate text-[10px] text-muted-foreground",children:["Command: ",f.jsx("span",{className:"font-mono text-[10px]",children:n.command})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Aj(n),h&&f.jsx(Et,{variant:So(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($l,{label:"Version",value:n.version??"Unavailable",mono:!!n.version}),n.update&&f.jsx($l,{label:"Latest",value:n.update.latestVersion??"Unavailable",mono:!!n.update.latestVersion}),f.jsx($l,{label:"Checked",value:Yt(n.checkedAt)}),n.update&&f.jsx($l,{label:"Update check",value:Yt(n.update.checkedAt)}),f.jsx($l,{label:"Path",value:n.path??"Not on PATH",mono:!!n.path,className:"sm:col-span-2"})]}),f.jsx("div",{className:"flex items-start justify-start lg:justify-end",children:o?f.jsxs(Et,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:["Upgrade ",o.status]}):c?f.jsxs(yf,{children:[f.jsx(bf,{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(Yi,{children:[f.jsxs(Gi,{children:[f.jsxs(Xi,{children:["Upgrade ",n.label,"?"]}),f.jsxs(Qi,{children:["This runs ",_j(n)," on ",r,". Remote nodes execute the command on the remote machine."]})]}),f.jsxs(Ii,{children:[f.jsx(Zi,{children:"Cancel"}),f.jsx(Ki,{onClick:()=>s(n),children:"Upgrade"})]})]})]}):u})]}),((p=n.update)==null?void 0:p.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:n.update.detail}),n.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:n.detail})]})}function Dj(n,r){var o;return(o=n==null?void 0:n.nodes)!=null&&o.length?n.nodes:r?[r]:[]}function zj(n,r){var s;if(r&&n.id===r.nodeId)return r;const o=n.settingsSnapshot;return{...n,nodeId:n.id,version:(o==null?void 0:o.version)??"Unavailable",packageName:o==null?void 0:o.packageName,uptime:(o==null?void 0:o.uptime)??0,localDashboardOrigin:((s=o==null?void 0:o.runtime)==null?void 0:s.localDashboardOrigin)??void 0,auth:o==null?void 0:o.auth,os:o==null?void 0:o.os,runtime:o==null?void 0:o.runtime,runtimeUpdate:o==null?void 0:o.runtimeUpdate,agents:o==null?void 0:o.agents,startupRequirements:o==null?void 0:o.startupRequirements,components:o==null?void 0:o.components,repository:o==null?void 0:o.repository,packages:o==null?void 0:o.packages}}function Lj(n,r){return n.id===r?`${n.name} (this node)`:`${n.name} (${n.role})`}function Uj(n){return n==="claude"?"Claude Code":n==="copilot"?"Copilot CLI":"Codex"}function Bj(n){var o;const r=(o=n.payload)==null?void 0:o.agent;return r==="claude"||r==="codex"||r==="copilot"?r:null}function Hj({cluster:n,systemInfo:r,sseConnected:o,initialSelectedNodeId:s,onRefresh:c}){var ee,oe,fe,ue,ie,me,ae,M,q,K,de,C,V,F,I,W,se,re,ce,le;const u=v.useMemo(()=>Dj(n,r),[n,r]),[m,h]=v.useState(()=>{var J;return s??(r==null?void 0:r.nodeId)??((J=n==null?void 0:n.self)==null?void 0:J.id)??""}),[y,p]=v.useState(()=>new Map),b=v.useRef(new Set),g=v.useRef(new Set),S=(n==null?void 0:n.self)??r??u[0]??null,N=u.find(J=>J.id===m)??S,T=N?zj(N,r):null,E=!!(r&&N&&N.id===r.nodeId),R=E||!!(N!=null&&N.settingsSnapshot),A=T==null?void 0:T.runtimeUpdate,j=((ee=T==null?void 0:T.startupRequirements)==null?void 0:ee.components)??(T==null?void 0:T.components)??{},_=v.useMemo(()=>u.map(J=>J.id),[u]),U=_.join("\0"),z=uj(u),Y=v.useMemo(()=>new Map(u.map(J=>[J.id,J.name])),[z]);v.useEffect(()=>{s&&_.includes(s)&&h(s)},[s,U]);const G=v.useCallback(async(J,ve)=>{const ye=l1(J);if(!ye||b.current.has(J.id))return;const Se=Bj(J),Be=(ve==null?void 0:ve.agentLabel)??(Se?Uj(Se):"Agent"),$e=(ve==null?void 0:ve.nodeName)??Y.get(J.nodeId)??J.nodeId;b.current.add(J.id),p(Ge=>new Map(Ge).set(ye,J));try{const Ge=await s1(J);if(Ge.status==="succeeded")await(c==null?void 0:c()),g.current.has(Ge.id)||(Ve.success(`${Be} upgrade finished on ${$e}`),g.current.add(Ge.id));else if(Ge.status==="failed")g.current.has(Ge.id)||(Ve.error(Mj(Ge)??`${Be} upgrade failed`),g.current.add(Ge.id));else{p(vt=>new Map(vt).set(ye,Ge)),Ve.info(`${Be} upgrade is still ${Ge.status} on ${$e}`);return}p(vt=>{const _e=new Map(vt),Ht=_e.get(ye);return(!Ht||Ht.id===Ge.id)&&_e.delete(ye),_e})}catch(Ge){p(vt=>{const _e=new Map(vt),Ht=_e.get(ye);return(!Ht||Ht.id===J.id)&&_e.delete(ye),_e}),Ve.error(Ge instanceof Error?Ge.message:`${Be} upgrade failed`)}finally{b.current.delete(J.id)}},[c,Y]);v.useEffect(()=>{if(_.length===0)return;let J=!1;async function ve(){let ye;try{ye=await mj(_)}catch{return}if(!J){p(Se=>{const Be=new Map(Se);for(const[$e,Ge]of ye)Be.set($e,Ge);return Be});for(const Se of ye.values())G(Se)}}return ve(),()=>{J=!0}},[G,U]);async function P(J){if(N)try{const ve=await CE(N.id,J.id);Ve.info(`${J.label} upgrade started on ${N.name}`),await G(ve,{agentLabel:J.label,nodeName:N.name})}catch(ve){Ve.error(ve instanceof Error?ve.message:`${J.label} upgrade failed`)}}return!N||!T?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:[!E&&f.jsxs(Et,{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 ",Yt((oe=N.settingsSnapshot)==null?void 0:oe.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(Xk,{status:N.status}),f.jsx("span",{className:"font-medium text-foreground",children:N.name})]}),f.jsx(Qk,{role:N.role}),f.jsx(Et,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:N.transportType??T.transportType??"direct"}),f.jsx(Et,{variant:E?"default":"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:E?"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(ox,{value:N.id,onValueChange:h,children:[f.jsx(am,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px]",children:f.jsx(lx,{placeholder:"Choose a node"})}),f.jsx(rm,{className:"settings-node-select-content rounded-sm text-[10px] leading-4",children:u.map(J=>f.jsx(wo,{value:J.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:Lj(J,r==null?void 0:r.nodeId)},J.id))})]})]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(Et,{variant:o?"default":"outline",className:"gap-1 rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:[f.jsx(QN,{className:"h-3 w-3"}),o?"Live link":"Reconnecting"]}),f.jsxs(Et,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:["Uptime ",Cj(T.uptime)]})]})]})]}),!R&&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(Mk,{defaultValue:"session",className:"space-y-2",children:[f.jsxs(Ax,{className:"h-auto flex-wrap rounded-sm border border-border/60 bg-muted/40 p-0.5",children:[f.jsx(Vl,{value:"session",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Session"}),f.jsx(Vl,{value:"access",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Access"}),f.jsx(Vl,{value:"quick-chats",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Quick chats"}),f.jsx(Vl,{value:"about",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"About"})]}),f.jsxs(Yl,{value:"session",className:"mt-0 grid gap-2 xl:grid-cols-[1.15fr_0.85fr]",children:[f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(G0,{className:"h-3.5 w-3.5 text-primary"}),"Selected node"]}),f.jsx(Un,{className:"text-[10px]",children:"Cluster role, identity, and node-scoped runtime state."})]}),f.jsxs(Bn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Node ID",value:T.nodeId,mono:!0}),f.jsx(et,{label:"Status",value:N.status}),f.jsx(et,{label:"Role",value:N.role}),f.jsx(et,{label:"Endpoint",value:N.endpoint,mono:!0}),f.jsx(et,{label:"Joined",value:Yt(N.joinedAt)}),f.jsx(et,{label:"Heartbeat",value:Yt(N.lastHeartbeat)}),f.jsx(et,{label:"Capabilities",value:N.capabilities.length>0?N.capabilities.join(", "):"None"})]})]}),f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(CN,{className:"h-3.5 w-3.5 text-primary"}),"OS info"]}),f.jsx(Un,{className:"text-[10px]",children:"Host and resource details reported by the current process."})]}),f.jsxs(Bn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Host",value:((fe=T.os)==null?void 0:fe.hostname)??"Unavailable"}),f.jsx(et,{label:"Platform",value:T.os?`${T.os.platform} ${T.os.release}`:"Unavailable"}),f.jsx(et,{label:"Arch",value:((ue=T.os)==null?void 0:ue.arch)??"Unavailable"}),f.jsx(et,{label:"CPU",value:((ie=T.os)==null?void 0:ie.cpuModel)??"Unavailable"}),f.jsx(et,{label:"Cores",value:String(((me=T.os)==null?void 0:me.cpuCount)??"Unavailable")}),f.jsx(et,{label:"Memory",value:T.os?`${n0(T.os.freeMemoryBytes)} free / ${n0(T.os.totalMemoryBytes)} total`:"Unavailable"})]})]}),A&&f.jsx("div",{className:"xl:col-span-2",children:f.jsx(wj,{checkedLabel:Yt(A.checkedAt),disableAuthDefault:((ae=T.auth)==null?void 0:ae.enabled)===void 0?void 0:T.auth.enabled===!1,endpoint:N.endpoint,isLiveLocalNode:E,nodeId:N.id,nodeName:N.name,onRefresh:c,pid:(M=T.runtime)==null?void 0:M.pid,transportType:N.transportType,update:A,workDir:((q=T.runtime)==null?void 0:q.workDir)??N.workDir})}),f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none xl:col-span-2",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(P0,{className:"h-3.5 w-3.5 text-primary"}),"Available agents"]}),f.jsx(Un,{className:"text-[10px]",children:E?"Live command availability for runtime agents on this node.":"Most recent agent availability snapshot synced from this node."})]}),f.jsx(Bn,{"data-agent-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:(T.agents??[]).map(J=>f.jsx(Oj,{agent:J,nodeName:N.name,activeOperation:y.get(`${N.id}:${J.id}`),onUpgrade:P},J.id))})]})]}),f.jsxs(Yl,{value:"access",className:"mt-0 grid gap-2 xl:grid-cols-2",children:[f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(mN,{className:"h-3.5 w-3.5 text-primary"}),"Access surface"]}),f.jsx(Un,{className:"text-[10px]",children:"How this node is exposed to the dashboard and other peers."})]}),f.jsxs(Bn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Transport",value:N.transportType??T.transportType??"direct"}),f.jsx(et,{label:"Node URL",value:N.endpoint,mono:!0}),f.jsx(et,{label:"Node tunnel",value:N.devtunnelEndpoint??"Disabled",mono:!!N.devtunnelEndpoint}),f.jsx(et,{label:"Dashboard URL",value:N.dashboardOrigin??T.localDashboardOrigin??"Unavailable",mono:!!(N.dashboardOrigin||T.localDashboardOrigin)}),f.jsx(et,{label:"Local dashboard",value:T.localDashboardOrigin??"Unavailable",mono:!!T.localDashboardOrigin})]})]}),f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(oT,{className:"h-3.5 w-3.5 text-primary"}),"Auth"]}),f.jsx(Un,{className:"text-[10px]",children:"Current bearer-auth and trusted access posture."})]}),f.jsxs(Bn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Enabled",value:(K=T.auth)!=null&&K.enabled?"Yes":"No"}),f.jsx(et,{label:"Same tenant",value:(de=T.auth)!=null&&de.allowSameTenant?"Allowed":"Off"}),f.jsx(et,{label:"Allowed users",value:(C=T.auth)!=null&&C.allowedUsers.length?T.auth.allowedUsers.join(", "):"None"})]})]}),f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(_N,{className:"h-3.5 w-3.5 text-primary"}),"Paths"]}),f.jsx(Un,{className:"text-[10px]",children:"Workspace and runtime paths currently used by this node."})]}),f.jsxs(Bn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Work dir",value:((V=T.runtime)==null?void 0:V.workDir)??T.workDir??"Unavailable",mono:!!(((F=T.runtime)==null?void 0:F.workDir)??T.workDir)}),f.jsx(et,{label:"Storage",value:((I=T.runtime)==null?void 0:I.storagePath)??"Unavailable",mono:!!((W=T.runtime)!=null&&W.storagePath)}),f.jsx(et,{label:"Process cwd",value:((se=T.runtime)==null?void 0:se.cwd)??"Unavailable",mono:!!((re=T.runtime)!=null&&re.cwd)}),f.jsx(et,{label:"Started",value:Yt((ce=T.runtime)==null?void 0:ce.startedAt)}),f.jsx(et,{label:"PID",value:T.runtime?String(T.runtime.pid):"Unavailable",mono:!!T.runtime})]})]}),f.jsxs(Dn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(zn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Ln,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(Di,{className:"h-3.5 w-3.5 text-primary"}),"Startup checks"]}),f.jsx(Un,{className:"text-[10px]",children:"Dependency preflight snapshot persisted during node startup."})]}),f.jsxs(Bn,{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:Yt((le=T.startupRequirements)==null?void 0:le.lastCheckedAt)})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Hl,{formatDateTime:Yt,name:"Azure CLI",status:j.az,statusVariant:So}),f.jsx(Hl,{formatDateTime:Yt,name:"DevTunnel",status:j.devtunnel,statusVariant:So}),f.jsx(Hl,{formatDateTime:Yt,name:"Claude Code",status:j.claude,statusVariant:So}),f.jsx(Hl,{formatDateTime:Yt,name:"Codex",status:j.codex,statusVariant:So}),f.jsx(Hl,{formatDateTime:Yt,name:"Copilot CLI",status:j.copilot,statusVariant:So})]})]})]})]}),f.jsx(Yl,{value:"quick-chats",className:"mt-0",children:f.jsx(oj,{})}),f.jsx(Fk,{formatDateTime:Yt,viewInfo:T})]})]})}function $j({initialSelectedNodeId:n,open:r,onOpenChange:o,showTrigger:s=!0}={}){const{cluster:c,systemInfo:u,sseConnected:m,refresh:h}=H0();return f.jsx(SA,{open:r,onOpenChange:o,showTrigger:s,children:f.jsx(Hj,{cluster:c,systemInfo:u,sseConnected:m,initialSelectedNodeId:n,onRefresh:h})})}const tM="codex",nM="bypass",Pj=[{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"}],aM=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],rM=new Set(Pj.filter(n=>n.supportsFollowUp).map(n=>n.value)),oM=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"shared",label:"Shared"},{value:"archived",label:"Archived"}],lM=[{value:"all",label:"All task types"},{value:"native",label:"Native sessions"},{value:"meshy",label:"Meshy chats"}],qj=new Set(["pending","assigned"]),Vj=new Set(["running"]),Yj=new Set(["completed","failed","cancelled"]),sM=10;function iM(n,r){switch(r){case"running":return Vj.has(n.status);case"waiting":return qj.has(n.status);case"closed":return Yj.has(n.status);case"shared":return!!n.activeShare;case"archived":return n.status==="archived";case"active":default:return n.status!=="archived"}}function cM(n,r){if(r==="all")return!0;const o=n.conversationKind==="nativeSession";return r==="native"?o:!o}function uM(n,r){const o=r.trim().toLowerCase();return o?[n.title,n.description,n.id,n.agent,n.assignedTo??"",n.assignedNodeName??"",n.project??"",n.effectiveProjectPath??"",n.conversationKind==="nativeSession"?"native session":"meshy chat",n.activeShare?"shared conversation":""].some(s=>s.toLowerCase().includes(o)):!0}function Gj(n,r,o){if(!n)return"unassigned";const s=r==null?void 0:r.find(c=>c.id===n);return(s==null?void 0:s.name)??o??n.slice(0,8)}function dM(n,r,o){return Gj(n,r,o).toLowerCase()}function fM(n){return n.type!=="node.status"&&n.type!=="cluster.state"}function mM(n,r,o){return!n.assignedTo||(o==null?void 0:o.id)===n.assignedTo?!0:(r==null?void 0:r.some(s=>s.id===n.assignedTo))??!1}function hM(n,r){return[...n].sort((o,s)=>o.id===r?-1:s.id===r?1:o.name.localeCompare(s.name))}function pM(n){if(!n||typeof n!="object")return null;const r=n,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 gM(n){return n==="default workspace"?n:n.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??n}function vM(n){const r=Date.now()-n;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 yM(n){return new Date(n).toLocaleString()}function bM(n){const r=Math.floor(n/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 Ij(n,r="Copied to clipboard"){var o,s,c;try{if((s=(o=globalThis.navigator)==null?void 0:o.clipboard)!=null&&s.writeText)return await globalThis.navigator.clipboard.writeText(n),Ve.success(r),!0;const u=globalThis.document,m=(c=u==null?void 0:u.execCommand)==null?void 0:c.bind(u);if(!(u!=null&&u.body)||typeof u.createElement!="function"||typeof m!="function")throw new Error("Clipboard access is unavailable");const h=u.createElement("textarea"),y=u.activeElement,p=y&&typeof y.focus=="function"?y:null;h.value=n,h.setAttribute("readonly","true"),h.style.position="fixed",h.style.opacity="0",h.style.pointerEvents="none",u.body.appendChild(h),h.select(),h.setSelectionRange(0,h.value.length);const b=m("copy");if(u.body.removeChild(h),p==null||p.focus(),!b)throw new Error("Clipboard access is unavailable");return Ve.success(r),!0}catch(u){return Ve.error(u instanceof Error?u.message:"Failed to copy"),!1}}const Xj="default workspace";function Mi(n){const r=n.replace(/\\/g,"/");return r==="/"||/^[A-Za-z]:\/$/.test(r)?r:r.replace(/\/+$/g,"")||r}function Qj(n){const r=n.replace(/\\/g,"/");return r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r)}function Kj(n,r){const o=Mi(n),s=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!s||s==="."?o:o==="/"||/^[A-Za-z]:\/$/.test(o)?`${o}${s}`:`${o}/${s}`}function Zj(n,r){var u,m,h;const o=(u=n.effectiveProjectPath)==null?void 0:u.trim();if(o)return Mi(o);const s=(m=n.project)==null?void 0:m.trim();if(!s)return Xj;if(Qj(s)||!n.assignedTo)return Mi(s);const c=(h=r==null?void 0:r.get(n.assignedTo))==null?void 0:h.trim();return c?Kj(c,s):Mi(s)}function xM(n,r,o,s){const c=new Map;for(const m of n){const h=m.assignedTo??null,y=h??"__unassigned__",p=h?r.get(h)??m.assignedNodeName??h.slice(0,8):"Unassigned",b=Zj(m,s);c.has(y)||c.set(y,{nodeId:h,nodeName:p,dirMap:new Map});const g=c.get(y);g.dirMap.has(b)||g.dirMap.set(b,[]),g.dirMap.get(b).push(m)}const u=Array.from(c.values()).map(({nodeId:m,nodeName:h,dirMap:y})=>{const p=Array.from(y.entries()).map(([b,g])=>({path:b,tasks:g})).sort((b,g)=>g.tasks.length-b.tasks.length||b.path.localeCompare(g.path));return{nodeId:m,nodeName:h,dirs:p}});return u.sort((m,h)=>{if(o){if(m.nodeId===o)return-1;if(h.nodeId===o)return 1}return m.nodeId===null?1:h.nodeId===null?-1:m.nodeName.localeCompare(h.nodeName)}),u}const Fj={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"},Wj={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 Jj(n){return n.split(".")[0]??"unknown"}function e_(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function bo(n,r,o){return typeof o=="string"&&o.length>0?o:(r==null?void 0:r.get(n))??n}function u1(n,r){const o=n.data,s=o.operation;switch(n.type){case"node.joined":return`${o.name} joined the cluster`;case"node.left":return`${bo(o.nodeId,r,o.name)} left (${o.reason})`;case"node.status":return`${bo(o.nodeId,r)} is now ${o.status}`;case"node.operation.created":return`${s==null?void 0:s.kind} ${s==null?void 0:s.status} on ${bo(s==null?void 0:s.nodeId,r)}`;case"node.operation.updated":return`${s==null?void 0:s.kind} ${s==null?void 0:s.status} on ${bo(s==null?void 0:s.nodeId,r)}`;case"transport.changed":return`${bo(o.nodeId,r)} transport switched to ${o.transportType}`;case"task.created":return`"${o.title}" created`;case"task.assigned":return`task assigned to ${bo(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 t_(n){return JSON.stringify(n,null,2)}function n_({events:n,maxHeight:r="400px",nodeNameById:o,onDismiss:s,density:c="default"}){if(n.length===0)return null;const u=c==="compact";return f.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:r},children:f.jsx("div",{className:"space-y-1.5",children:n.map(m=>{const h=Jj(m.type);return f.jsx("div",{className:ne("transition-colors hover:bg-muted/30",u?"rounded-sm px-1 py-0.5":"rounded-lg 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:ne("font-mono text-muted-foreground",u?"text-[8px]":"text-[9px]"),children:e_(m.timestamp)}),u?f.jsx("span",{className:ne("max-w-[8.5rem] truncate text-[7px] font-medium uppercase tracking-[0.08em] text-muted-foreground/70",Wj[h]),children:m.type}):f.jsx(Et,{variant:"outline",className:ne("w-fit text-[9px] font-medium uppercase tracking-[0.14em] px-1.5 py-0",Fj[h]),children:m.type})]}),f.jsxs("div",{className:ne("flex shrink-0 items-center",u?"gap-px":"gap-0.5"),children:[f.jsx(Bt,{type:"button",variant:"ghost",size:"icon",className:ne("rounded-sm text-muted-foreground hover:text-foreground",u?"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:()=>void Ij(t_(m),"Event copied"),"aria-label":`Copy ${m.type} event`,title:"Copy event",children:f.jsx(TN,{className:u?"h-2.5 w-2.5":"h-3 w-3"})}),s&&f.jsx(Bt,{type:"button",variant:"ghost",size:"icon",className:ne("rounded-sm text-muted-foreground hover:text-foreground",u?"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:()=>s(m.id),"aria-label":`Dismiss ${m.type} event`,title:"Dismiss event",children:f.jsx(Q0,{className:u?"h-2.5 w-2.5":"h-3 w-3"})})]})]}),f.jsx("div",{className:"text-[9px] leading-snug text-foreground/85",children:u1(m,o)})]})},m.id)})})})}const a_=["node.","election.","transport."],r_="cluster.state";function o_(n){return n.type==="node.status"?!1:a_.some(r=>n.type.startsWith(r))}function l_(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function s_(n,r){return n?{time:l_(n.timestamp),text:u1(n,r)}:null}function i_(n){return n.transportType==="devtunnel"||!!n.devtunnelEndpoint}function c_(n){if(n.length===0)return"No node tunnel";const r=n.filter(c=>c.status==="offline").length;if(r>0)return`${r} offline`;const o=n.filter(c=>{var u;return((u=c.devtunnelHealth)==null?void 0:u.status)==="failed"}).length;if(o>0)return`${o} failed`;const s=n.filter(c=>{var u;return c.status!=="offline"&&((u=c.devtunnelHealth)==null?void 0:u.status)!=="healthy"}).length;return s>0?`${s} checking`:"Healthy"}function u_(n,r){var c;const o=(r==null?void 0:r.get(n.id))??n.name??n.id;if(n.status==="offline")return{label:o,status:"offline"};const s=((c=n.devtunnelHealth)==null?void 0:c.status)??"checking";return{label:o,status:s}}function d_(n){if(n.length===0)return"No nodes";const r=n.filter(s=>s.status==="offline").length;if(r>0)return`${r} offline`;const o=n.filter(s=>s.status==="busy").length;return o>0?`${o} busy`:"Healthy"}function f_(n,r){return{label:(r==null?void 0:r.get(n.id))??n.name??n.id,status:n.status}}function m_({connected:n,events:r,nodes:o=[],currentNode:s=null,nodeNameById:c,desktopUpdate:u=null,defaultOpen:m=!1,defaultActionMenuOpen:h=!1,onDesktopUpdate:y,onDesktopRestart:p,onReload:b,onRestart:g}){const[S,N]=v.useState(m),[T,E]=v.useState(h),[R,A]=v.useState(!0),[j,_]=v.useState(new Set),[U,z]=v.useState(!1),[Y,G]=v.useState(!1),P=v.useRef(null),ee=v.useRef(null),oe=v.useMemo(()=>r.filter(be=>o_(be)&&!j.has(be.id)),[r,j]),fe=v.useMemo(()=>r.find(be=>be.type===r_)??oe[0],[r,oe]),ue=v.useMemo(()=>s_(fe,c),[fe,c]),ie=v.useMemo(()=>{const be=new Map(o.map(Pe=>[Pe.id,Pe]));return s&&be.set(s.id,s),Array.from(be.values())},[s,o]),me=v.useMemo(()=>ie.filter(i_),[ie]),ae=me.some(be=>{var Pe;return be.status==="offline"||((Pe=be.devtunnelHealth)==null?void 0:Pe.status)==="failed"}),M=ie.some(be=>be.status==="offline"),q=ie.some(be=>be.status==="busy"),K=ie.length>0,de=(s==null?void 0:s.name)??"offline",C=(s==null?void 0:s.role)==="leader"?"Leader":(s==null?void 0:s.role)==="follower"?"Follower":"Node",V=u!==null,F=!!(V&&(u!=null&&u.updateAvailable)&&u.latestVersion),I=(u==null?void 0:u.latestVersion)??null,W=!!(V&&!F&&!I&&(u!=null&&u.detail)),se=U?"Relaunching runtime...":"Relaunch to apply update",re=Y?"Downloading and installing desktop update...":F&&I?`Available version ${I}`:W?(u==null?void 0:u.detail)??"Desktop update unavailable":"Desktop is current",ce=!!b,le=!!(V&&p),J=ce||le,ve=V||!!g,ye=V||!!g||ce,Se=ve?V?"Update":"Relaunch":"Reload",Be=ve?V?re:se:"Reload dashboard page",$e=ve?V?Y:U:!1,Ge=ve?V?$e||!F||!y:$e:!1,vt=V?F&&I?`Install desktop update ${I}`:W?"Desktop update unavailable":"Desktop is current":ve?U?"Relaunching runtime":"Relaunch runtime":"Reload dashboard page";function _e(){ee.current&&(clearTimeout(ee.current),ee.current=null)}function Ht(){_e(),N(!0)}function yt(){_e(),ee.current=setTimeout(()=>{N(!1),ee.current=null},180)}function Rr(){_e()}function ha(){_e(),E(!1),N(!1)}async function kt(){if(!(!g||U)){z(!0);try{await g()}finally{z(!1)}}}async function pn(){if(!(!F||!y||Y)){G(!0);try{await y()}finally{G(!1)}}}async function Lo(){if(!(!p||U)){E(!1),z(!0);try{await p()}finally{z(!1)}}}async function Cr(){if(!ve){await It();return}if(V){await pn();return}await kt()}async function It(){b&&(E(!1),await b())}return v.useEffect(()=>()=>{_e()},[]),v.useEffect(()=>{_(be=>{if(be.size===0)return be;const Pe=new Set(r.map(it=>it.id)),Me=new Set(Array.from(be).filter(it=>Pe.has(it)));return Me.size===be.size?be:Me})},[r]),v.useEffect(()=>{S||E(!1)},[S]),v.useEffect(()=>{if(!S)return;const be=Me=>{var it;(it=P.current)!=null&&it.contains(Me.target)||(_e(),E(!1),N(!1))},Pe=Me=>{Me.key==="Escape"&&(_e(),E(!1),N(!1))};return document.addEventListener("pointerdown",be),document.addEventListener("keydown",Pe),()=>{document.removeEventListener("pointerdown",be),document.removeEventListener("keydown",Pe)}},[S]),f.jsxs("div",{ref:P,className:"relative",children:[f.jsxs("button",{type:"button","aria-label":n?"Cluster link connected":"Cluster link reconnecting","aria-expanded":S,"aria-haspopup":"dialog",onClick:()=>N(be=>!be),onMouseEnter:Ht,onMouseLeave:yt,className:ne("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]",n?"bg-muted/40 text-muted-foreground hover:bg-muted/60 hover:text-foreground":"bg-destructive/8 text-destructive hover:bg-destructive/12",S&&(n?"bg-muted/60 text-foreground":"bg-destructive/12")),title:n?"Cluster link connected":"Cluster link reconnecting",children:[f.jsxs("span",{className:ne("relative flex h-2 w-2 shrink-0"),children:[n&&f.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-60"}),f.jsx("span",{className:ne("relative inline-flex h-2 w-2 rounded-full",n?"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:de}),f.jsx("span",{className:ne("shrink-0 rounded border px-1 py-px text-[8px] font-semibold uppercase tracking-[0.1em]",n?"border-emerald-500/25 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-destructive/30 bg-destructive/10 text-destructive"),children:C})]})]}),S&&f.jsxs("div",{role:"dialog","aria-label":"Live link connection events",onMouseEnter:Rr,onMouseLeave:ha,className:"absolute right-0 top-[calc(100%+0.4rem)] z-50 w-[18rem] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-lg border border-border/70 bg-background/96 shadow-[0_28px_90px_-42px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl 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:[n?f.jsx(Di,{className:"h-3 w-3 text-emerald-500"}):f.jsx(mT,{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:n?"· SSE connected":"· reconnecting"})]}),f.jsx("div",{className:ne("rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.12em]",n?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-destructive/30 bg-destructive/10 text-destructive"),children:n?"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:oe.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"}),ue?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mt-0.5 truncate text-[9px] leading-snug text-foreground/80",children:ue.text}),f.jsx("div",{className:"font-mono text-[8px] text-muted-foreground/60",children:ue.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:[M?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):q?f.jsx(Di,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Pl,{className:ne("h-3 w-3 shrink-0",K?"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:ne("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",M?"border-destructive/30 bg-destructive/10 text-destructive":q?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":K?"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:d_(ie)})]}),ie.length>0&&f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:ie.map(be=>{const{label:Pe,status:Me}=f_(be,c),it=Me==="offline",Tn=Me==="busy";return f.jsxs("div",{"aria-label":`${Pe} ${Me}`,className:ne("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",it?"bg-destructive/6":Tn?"bg-amber-500/6":"bg-emerald-500/5"),title:`${Pe} ${Me}`,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Pe}),it?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):Tn?f.jsx(vv,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Pl,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},be.id)})})]}),me.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:[ae?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):f.jsx(Pl,{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:ne("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",ae?"border-destructive/30 bg-destructive/10 text-destructive":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:c_(me)})]}),f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:me.map(be=>{var Gn;const{label:Pe,status:Me}=u_(be,c),it=Me==="failed"||Me==="offline",Tn=Me!=="healthy"&&Me!=="failed"&&Me!=="offline",Rn=(Gn=be.devtunnelHealth)!=null&&Gn.reason?`${Pe} ${Me}: ${be.devtunnelHealth.reason}`:`${Pe} ${Me}`;return f.jsxs("div",{"aria-label":`${Pe} ${Me}`,className:ne("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",it?"bg-destructive/6":Tn?"bg-muted/30":"bg-emerald-500/5"),title:Rn,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Pe}),it?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):Tn?f.jsx(vv,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):f.jsx(Pl,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},be.id)})})]}),f.jsxs("div",{children:[f.jsxs("button",{type:"button",onClick:()=>A(be=>!be),className:"flex w-full items-center justify-between px-2.5 py-1.5 text-left hover:bg-muted/30",children:[f.jsxs("span",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:["Notifications ",oe.length>0&&`(${oe.length})`]}),R?f.jsx(Ql,{className:"h-3 w-3 text-muted-foreground"}):f.jsx(nf,{className:"h-3 w-3 text-muted-foreground"})]}),R&&f.jsx("div",{className:"px-2 pb-2",children:f.jsx(n_,{events:oe,maxHeight:"12rem",density:"compact",emptyTitle:"No connection events yet",emptyDescription:"Node, election, and system events will appear here.",nodeNameById:c,onDismiss:be=>_(Pe=>new Set(Pe).add(be))})})]}),V&&(u==null?void 0:u.detail)&&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:ye&&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(Bt,{type:"button",variant:"ghost",size:"sm",className:ne("h-5 rounded-none border-0 px-1.5 text-[9px] font-medium hover:text-foreground [&_svg]:size-2.5",F?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>void Cr(),disabled:Ge,"aria-label":vt,"aria-describedby":"live-link-restart-hint",title:Be,children:[f.jsx(yv,{className:ne("h-2.5 w-2.5",$e&&"animate-pulse")}),f.jsx("span",{children:Se})]}),J&&f.jsx(Bt,{type:"button",variant:"ghost",size:"sm",className:ne("h-5 rounded-none border-l border-border/50 px-1 text-[9px] hover:text-foreground [&_svg]:size-2.5",F?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>E(be=>!be),"aria-label":"Open live link actions","aria-expanded":T,title:"Live link actions",children:f.jsx(Ql,{className:"h-2.5 w-2.5"})})]}),J&&T&&f.jsxs("div",{className:"absolute bottom-[calc(100%+0.25rem)] left-0 z-20 min-w-28 overflow-hidden rounded-md border border-border/70 bg-background text-[9px] shadow-lg",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:()=>void Cr(),disabled:Ge,"aria-label":vt,children:[f.jsx(yv,{className:ne("h-2.5 w-2.5",$e&&"animate-pulse")}),f.jsx("span",{children:Se})]}),le&&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:()=>void Lo(),disabled:U,"aria-label":"Restart Meshy Desktop",children:[f.jsx(af,{className:ne("h-2.5 w-2.5",U&&"animate-spin")}),f.jsx("span",{children:"Restart"})]}),ce&&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:()=>void It(),"aria-label":"Reload dashboard page",children:[f.jsx(af,{className:"h-2.5 w-2.5"}),f.jsx("span",{children:"Reload"})]})]}),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:Be})]})}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Bt,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:()=>_(new Set(r.map(be=>be.id))),disabled:oe.length===0,title:"Dismiss all notifications",children:"Dismiss all"}),f.jsx(Bt,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:()=>N(!1),children:"Close"})]})]})]})]})}const a0="dark",Nr="fluent",h_="clean",Xd="meshy-layout-default-migrated-to-compact",wf="true",p_="compact",g_=new Set(["airy","clean","fluent"]);function v_(n){return n!==null&&g_.has(n)}function gc(n){return n===p_?"fluent":v_(n)?n:null}function y_(n,r){const o=gc(n);return o===h_&&r!==wf?Nr:o??Nr}const Wi="symphony",d1="default",b_=new Set(["light","dark","system"]),x_=new Set(["porcelain","warm","finsight","edge","symphony","launcher"]),f1=v.createContext(null);function S_(n){const r=new URLSearchParams(n).get("theme");return m1(r)?r:null}function w_(n){const r=new URLSearchParams(n).get("palette");return im(r)}function E_(n){const r=new URLSearchParams(n).get("layout");return gc(r)}function N_(){if(typeof document>"u")return null;const n=document.documentElement;return{theme:n.classList.contains("dark")?"dark":"light",palette:im(n.getAttribute("data-palette"))??Wi,layout:gc(n.getAttribute("data-layout"))??Nr}}function SM(n,r=N_()){if(!r)return n;try{const o=/^[a-z][a-z\d+\-.]*:/i.test(n),s=typeof window<"u"?window.location.href:"http://localhost",c=new URL(n,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 n}}const Qd=.9;function r0(n){const r=n.trim().match(/^(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)%\s+(-?\d+(?:\.\d+)?)%$/);if(!r)return null;const o=(Number(r[1])%360+360)%360/60,s=Ji(Number(r[2])/100,0,1),c=Ji(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,[y,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((y+h)*255),Math.round((p+h)*255),Math.round((b+h)*255),255]}function T_(n){const r=n.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[xo(Number(o[1])),xo(Number(o[2])),xo(Number(o[3])),s0(o[4])];const s=r.match(/^rgba?\(\s*([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)(?:\s*\/\s*([+-]?\d+(?:\.\d+)?%?))?\s*\)$/i);return s?[xo(Number(s[1])),xo(Number(s[2])),xo(Number(s[3])),s0(s[4])]:null}function R_(n,r,o){const s=r0(n);if(!s)return null;if(o==="clean"||o==="fluent")return s;const c=r0(r);return c?[Kd(s[0],c[0],Qd),Kd(s[1],c[1],Qd),Kd(s[2],c[2],Qd),255]:null}function C_(){const n=document.querySelector(".dashboard-shell-header-panel");if(!n)return null;const r=T_(getComputedStyle(n).backgroundColor);return!r||r[3]===0?null:r}function o0(){var m,h;if(typeof window>"u"||typeof document>"u")return;const n=((h=(m=window.__TAURI__)==null?void 0:m.core)==null?void 0:h.invoke)??null;if(!n)return;const r=document.documentElement,o=r.classList.contains("dark")?"dark":"light",s=getComputedStyle(r),c=gc(r.getAttribute("data-layout"))??Nr,u=C_()??R_(s.getPropertyValue("--card"),s.getPropertyValue("--background"),c);n("sync_desktop_theme",{theme:o,backgroundColor:u}).catch(()=>{})}function l0(){if(typeof window>"u")return()=>{};if(o0(),typeof window.requestAnimationFrame!="function")return()=>{};const n=window.requestAnimationFrame(()=>o0());return()=>window.cancelAnimationFrame(n)}function Kd(n,r,o){return Math.round(n*o+r*(1-o))}function Ji(n,r,o){return Math.min(Math.max(n,r),o)}function xo(n){return Math.round(Ji(n,0,255))}function s0(n){if(n==null||n==="")return 255;const r=n.endsWith("%")?Number(n.slice(0,-1))/100:Number(n);return Math.round(Ji(r,0,1)*255)}function A_({children:n}){const[r,o]=v.useState(()=>typeof window<"u"?S_(window.location.search)??__(localStorage.getItem("meshy-theme"))??a0:a0),[s,c]=v.useState(()=>typeof window<"u"?w_(window.location.search)??M_(localStorage.getItem("meshy-palette"))??Wi:Wi),[u,m]=v.useState(()=>{if(typeof window<"u"){const h=E_(window.location.search);if(h)return localStorage.setItem(Xd,wf),h;const y=y_(localStorage.getItem("meshy-layout"),localStorage.getItem(Xd));return localStorage.setItem(Xd,wf),y}return Nr});return v.useEffect(()=>{const h=document.documentElement,y=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(y(r),localStorage.setItem("meshy-theme",r),r==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)"),b=()=>{y("system"),l0()};return p.addEventListener("change",b),()=>p.removeEventListener("change",b)}},[r]),v.useEffect(()=>{document.documentElement.setAttribute("data-palette",s),localStorage.setItem("meshy-palette",s)},[s]),v.useEffect(()=>{const h=document.documentElement;u===Nr?h.removeAttribute("data-layout"):h.setAttribute("data-layout",u),localStorage.setItem("meshy-layout",u)},[u]),v.useEffect(()=>l0(),[r,s,u]),f.jsx(f1.Provider,{value:{theme:r,setTheme:o,palette:s,setPalette:c,layout:u,setLayout:m},children:n})}function k_(){const n=v.useContext(f1);if(!n)throw new Error("useTheme must be used within ThemeProvider");return n}function m1(n){return n!==null&&b_.has(n)}function j_(n){return n!==null&&x_.has(n)}function __(n){return m1(n)?n:null}function im(n){return n===d1?"porcelain":j_(n)?n:null}function M_(n){return n===d1?null:im(n)}const O_=[{value:"light",label:"Light",icon:I0},{value:"dark",label:"Dark",icon:Y0},{value:"system",label:"System",icon:V0}],h1=[{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"}],p1=[{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 D_(){const{theme:n,setTheme:r,palette:o,setPalette:s,layout:c,setLayout:u}=k_(),[m,h]=v.useState(!1),y=v.useRef(null),p=v.useRef(null),b=n==="dark"?Y0:n==="light"?I0:V0,g=()=>{y.current&&(clearTimeout(y.current),y.current=null)},S=()=>{g(),y.current=setTimeout(()=>h(!1),180)};return v.useEffect(()=>{if(!m)return;const N=T=>{p.current&&!p.current.contains(T.target)&&h(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[m]),v.useEffect(()=>()=>g(),[]),f.jsxs("div",{ref:p,className:"relative",onMouseEnter:()=>{g(),h(!0)},onMouseLeave:S,children:[f.jsx(Bt,{variant:"ghost",size:"icon",onClick:()=>h(N=>!N),className:ne("h-8 w-8 rounded-sm",o!==Wi||c!==Nr?"text-primary":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),title:"Appearance","aria-haspopup":"menu","aria-expanded":m,children:f.jsx(b,{className:"h-4 w-4"})}),m&&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:[z_(c)," / ",L_(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:n})]}),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:O_.map(({value:N,label:T,icon:E})=>{const R=n===N;return f.jsxs("button",{type:"button",onClick:()=>r(N),role:"menuitemradio","aria-checked":R,className:ne("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",R?"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(E,{className:"h-3 w-3"}),T]},N)})}),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:p1.map(({value:N,label:T,hint:E})=>{const R=c===N;return f.jsxs("button",{type:"button",onClick:()=>u(N),role:"menuitemradio","aria-checked":R,className:ne("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",R?"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:ne("text-[10px] font-medium leading-tight",R?"text-primary":"text-foreground"),children:T}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:E})]}),R&&f.jsx(zi,{className:"h-3 w-3 text-primary"})]},N)})})]}),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(sT,{className:"h-2.5 w-2.5"}),"Palette"]}),f.jsx("div",{className:"space-y-1",children:h1.map(({value:N,label:T,hint:E})=>{const R=o===N;return f.jsxs("button",{type:"button",onClick:()=>s(N),role:"menuitemradio","aria-checked":R,className:ne("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",R?"border-primary/55 bg-primary/10":"border-border/45 bg-background/45 hover:border-border hover:bg-muted/55"),children:[f.jsx(U_,{value:N}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:ne("text-[10px] font-medium leading-tight",R?"text-primary":"text-foreground"),children:T}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:E})]}),R&&f.jsx(zi,{className:"h-3 w-3 text-primary"})]},N)})})]})]})]})]})}function z_(n){var r;return((r=p1.find(o=>o.value===n))==null?void 0:r.label)??n}function L_(n){var r;return((r=h1.find(o=>o.value===n))==null?void 0:r.label)??n}function U_({value:n}){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[n];return f.jsxs("div",{className:ne("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 Gl={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}},g1="meshy-dashboard-panel-state-v2",v1="meshy-dashboard-terminal-open-v1";function wM({operationsOpen:n}){return{layout:{desktopTasksOpen:!0,operationsOpen:n},sizes:{tasks:Gl.tasks.defaultSize,operations:Gl.operations.defaultSize,terminal:Gl.terminal.defaultSize}}}function Zd(n){return typeof n=="object"&&n!==null}function i0(n,r){return typeof n=="boolean"?n:r}function Fd(n,r,o){return typeof r=="number"&&Number.isFinite(r)?Il(n,r):o}function Il(n,r){const o=Gl[n];return Math.min(o.max,Math.max(o.min,r))}function EM(n,r){if(!n)return r;try{const o=n.getItem(g1);if(!o)return r;const s=JSON.parse(o);if(!Zd(s))return r;const c=Zd(s.layout)?s.layout:{},u=Zd(s.sizes)?s.sizes:{};return{layout:{desktopTasksOpen:i0(c.desktopTasksOpen,r.layout.desktopTasksOpen),operationsOpen:i0(c.operationsOpen,r.layout.operationsOpen)},sizes:{tasks:Fd("tasks",u.tasks,r.sizes.tasks),operations:Fd("operations",u.operations,r.sizes.operations),terminal:Fd("terminal",u.terminal,r.sizes.terminal)}}}catch{return r}}function NM(n,r){if(n)try{n.setItem(g1,JSON.stringify(r))}catch{}}function B_(n,r){if(!n)return r;try{const o=n.getItem(v1);return o==="true"?!0:o==="false"?!1:r}catch{return r}}function H_(n,r){if(n)try{n.setItem(v1,String(r))}catch{}}function c0(){var n;try{return((n=globalThis.window)==null?void 0:n.localStorage)??globalThis.localStorage??null}catch{return null}}function TM(n){return`${Number(n.toFixed(2))}rem`}function RM(n,r,o,s,c,u,m){const h=Number.isFinite(m)&&m>0?m:16;return n==="tasks"?Il(n,r+(c-o)/h):n==="operations"?Il(n,r+(o-c)/h):Il(n,r+(s-u)/h)}function CM(n,r,o){const s=o===0?0:o>0?-1:1;return Il(n,r+s*Gl[n].wheelStep)}const $_=7200*1e3;function P_(){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 Ti(){var n,r;return typeof window>"u"?null:((r=(n=window.__TAURI__)==null?void 0:n.core)==null?void 0:r.invoke)??null}function u0(n){return{currentVersion:null,latestVersion:null,updateAvailable:!1,checkedAt:new Date().toISOString(),releaseUrl:null,assetName:null,installable:!1,detail:n}}function Wd(n,r){if(n instanceof Error&&n.message.trim())return n.message;if(typeof n=="string"&&n.trim())return n;if(n&&typeof n=="object"&&"message"in n){const o=n.message;if(typeof o=="string"&&o.trim())return o}return r}function q_(n){return n.openedRelease?"Opened the latest Meshy release page.":n.installMethod==="tauri-updater"?"Installing desktop update. Meshy will relaunch to finish updating.":(n.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 V_(){const{cluster:n,events:r,sseConnected:o,systemInfo:s}=H0(),c=Vn(),[u,m]=v.useState(()=>B_(c0(),!1)),[h,y]=v.useState(""),[p,b]=v.useState(null),[g,S]=v.useState(null),N=!!Ti(),T=N?"max-w-none":"max-w-[1760px]",E=c.pathname==="/"||/^\/tasks\/[^/]+$/.test(c.pathname),R=v.useMemo(()=>{const z=new Map;for(const Y of(n==null?void 0:n.nodes)??[])z.set(Y.id,Y.name);return n!=null&&n.self&&z.set(n.self.id,n.self.name),z},[n==null?void 0:n.nodes,n==null?void 0:n.self]),A=v.useCallback(z=>{m(Y=>typeof z=="function"?z(Y):z)},[]);v.useEffect(()=>{H_(c0(),u)},[u]),v.useEffect(()=>{const z=Ti();if(!z){S(null);return}let Y=!1,G=!1;const P=oe=>{G||(G=!0,oe&&S(u0("Checking desktop update...")),z("check_desktop_update").then(fe=>{Y||S(fe)}).catch(fe=>{if(!Y){const ue=Wd(fe,"Desktop update check failed");S(ie=>ie!=null&&ie.updateAvailable?ie:u0(ue))}}).finally(()=>{G=!1}))};P(!0);const ee=window.setInterval(()=>P(!1),$_);return()=>{Y=!0,window.clearInterval(ee)}},[s==null?void 0:s.version]);async function j(){try{const z=await L0({reason:"restart"});Ve.info(`Restarting runtime. Follow ${z.logPath} for launch output.`),await i1({previousPid:z.pid})||Ve.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout.")}catch(z){Ve.error(z instanceof Error?z.message:"Runtime restart failed")}}async function _(){const z=Ti();if(!z){Ve.error("Desktop updater is not available in this window");return}try{Ve.info("Downloading desktop update...");const Y=await z("install_desktop_update");Ve.info(q_(Y))}catch(Y){Ve.error(Wd(Y,"Desktop update failed"))}}async function U(){const z=Ti();if(!z){Ve.error("Desktop restart is not available in this window");return}try{Ve.info("Restarting Meshy Desktop..."),await z("restart_desktop_app")}catch(Y){Ve.error(Wd(Y,"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:ne("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",T),children:[f.jsx("div",{className:"flex shrink-0 items-center gap-3 pr-3",children:f.jsxs(tf,{to:"/","aria-label":"Meshy home",className:"flex items-center gap-2",children:[f.jsx(P_,{}),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"}),E&&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:()=>y(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(G0,{className:"h-3 w-3 shrink-0 text-primary/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.nodeName})]}),f.jsx(nf,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsxs("button",{type:"button",onClick:()=>y(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(ON,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.projectLabel})]}),f.jsx(nf,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsx(tf,{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(eT,{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(hc,{"aria-label":"Search tasks",value:h,onChange:z=>y(z.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:[E&&f.jsx(Bt,{variant:"ghost",size:"icon",onClick:()=>A(z=>!z),"aria-label":u?"Close terminal":"Open terminal",title:u?"Close terminal":"Open terminal",className:ne("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(X0,{className:"h-4 w-4"})}),f.jsx($j,{}),f.jsx(D_,{}),f.jsx("div",{className:"mx-0 h-4 w-px shrink-0 bg-border/50"}),f.jsx(m_,{connected:o,events:r,nodes:(n==null?void 0:n.nodes)??[],currentNode:(n==null?void 0:n.self)??null,nodeNameById:R,desktopUpdate:g,onDesktopUpdate:g!=null&&g.updateAvailable?_:void 0,onDesktopRestart:N?U:void 0,onReload:N?()=>window.location.reload():void 0,onRestart:j})]})]})}),f.jsx("main",{className:ne("dashboard-shell-main min-h-0 flex-1 px-2 pb-2",E?"overflow-hidden":"overflow-y-auto"),children:f.jsx("div",{className:ne("dashboard-shell-content mx-auto h-full min-h-0",T),children:f.jsx(L2,{context:{terminalOpen:u,setTerminalOpen:A,headerSearchQuery:h,setHeaderSearchQuery:y,setHeaderTaskContext:b}})})})]})]})}const d0=v.lazy(async()=>({default:(await h0(()=>import("./DashboardPage-DbD4Z2U0.js").then(r=>r.D),__vite__mapDeps([0,1,2,3,4]))).DashboardPage})),Y_=v.lazy(async()=>({default:(await h0(()=>import("./SharedConversationPage-CtQLabVf.js"),__vite__mapDeps([5,1]))).SharedConversationPage}));function G_(){return f.jsx(iE,{children:f.jsx(v.Suspense,{fallback:f.jsx(I_,{}),children:f.jsxs(B2,{children:[f.jsx(br,{path:"/shared/tasks/:shareId",element:f.jsx(Y_,{})}),f.jsxs(br,{element:f.jsx(tN,{children:f.jsx(V_,{})}),children:[f.jsx(br,{path:"/",element:f.jsx(d0,{})}),f.jsx(br,{path:"/nodes",element:f.jsx(dv,{to:"/",replace:!0})}),f.jsx(br,{path:"/tasks",element:f.jsx(dv,{to:"/",replace:!0})}),f.jsx(br,{path:"/tasks/:id",element:f.jsx(d0,{})})]})]})})})}function I_(){return f.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading workspace..."})}function X_(n){const r=n??(typeof window>"u"?void 0:window);r!=null&&r.__TAURI__&&r.addEventListener("contextmenu",o=>{o.preventDefault()})}function Q_(n){return f.jsx(jR,{className:"toaster group",style:{"--normal-bg":"hsl(var(--popover))","--normal-text":"hsl(var(--popover-foreground))","--normal-border":"hsl(var(--border))"},...n})}X_();Uw.createRoot(document.getElementById("root")).render(f.jsx(v.StrictMode,{children:f.jsxs(A_,{children:[f.jsx(G_,{}),f.jsx(Q_,{})]})}));export{Et as $,tM as A,Bt as B,zi as C,nM as D,w3 as E,_N as F,vA as G,Qy as H,hc as I,Zy as J,SM as K,UN as L,TN as M,Ij as N,Ax as O,YN as P,eM as Q,q0 as R,G0 as S,aM as T,Vl as U,Gj as V,P0 as W,Q0 as X,Mk as Y,Z3 as Z,F3 as _,W3 as a,A3 as a$,yM as a0,Yl as a1,yf as a2,Yi as a3,Gi as a4,Xi as a5,Qi as a6,Ii as a7,Zi as a8,Ki as a9,Fy as aA,af as aB,sM as aC,xM as aD,oM as aE,lM as aF,gM as aG,o1 as aH,vM as aI,bf as aJ,dT as aK,_3 as aL,M3 as aM,EM as aN,wM as aO,c0 as aP,NM as aQ,CM as aR,TM as aS,RM as aT,x3 as aU,QE as aV,jE as aW,I3 as aX,G3 as aY,X3 as aZ,FE as a_,h0 as aa,e3 as ab,Ky as ac,xA as ad,m3 as ae,X0 as af,Pl as ag,EN as ah,f3 as ai,h3 as aj,d3 as ak,mT as al,aT as am,uN as an,$N as ao,Jl as ap,hM as aq,QN as ar,n_ as as,Xk as at,kN as au,Qk as av,bM as aw,qj as ax,V3 as ay,qR as az,zR as b,r3 as b0,n3 as b1,a3 as b2,o3 as b3,RE as b4,$j as b5,k3 as b6,j3 as b7,y3 as b8,p3 as b9,l3 as bA,K3 as bB,U3 as bC,L3 as bD,z3 as bE,O3 as bF,D3 as bG,B3 as bH,yA as bI,Pj as bJ,f0 as bK,yN as bL,P3 as bM,$3 as bN,H3 as bO,q3 as bP,Q3 as bQ,Y3 as bR,g3 as ba,v3 as bb,b3 as bc,F_ as bd,Vn as be,T0 as bf,Z_ as bg,H0 as bh,pM as bi,tj as bj,mM as bk,iM as bl,cM as bm,dM as bn,uM as bo,fM as bp,S3 as bq,rM as br,Vj as bs,R3 as bt,C3 as bu,T3 as bv,N3 as bw,J_ as bx,t3 as by,W_ as bz,je as c,ne as d,dy as e,Fx as f,i3 as g,u3 as h,TE as i,f as j,s3 as k,ON as l,J3 as m,nf as n,wo as o,c3 as p,E3 as q,v as r,ox as s,Ve as t,am as u,lx as v,rm as w,eT as x,Ql as y,sT as z};