meshy-node 0.4.6 → 0.4.7

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-D90kD6BP.js","assets/DashboardShared-C3JGW4Hk.js","assets/folder-Dl50jm8B.js","assets/play-B08sSxiw.js","assets/SharedConversationPage-CYx3AV6M.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-D9Y-YlT8.js","assets/DashboardShared-C7i9cRdE.js","assets/folder-6mjPM2Gc.js","assets/play-CSZ3EHkb.js","assets/SharedConversationPage-DaFHobVu.js"])))=>i.map(i=>d[i]);
2
2
  function XS(n,r){for(var o=0;o<r.length;o++){const i=r[o];if(typeof i!="string"&&!Array.isArray(i)){for(const u in i)if(u!=="default"&&!(u in n)){const d=Object.getOwnPropertyDescriptor(i,u);d&&Object.defineProperty(n,u,d.get?d:{enumerable:!0,get:()=>i[u]})}}}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 u of document.querySelectorAll('link[rel="modulepreload"]'))i(u);new MutationObserver(u=>{for(const d of u)if(d.type==="childList")for(const f of d.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function o(u){const d={};return u.integrity&&(d.integrity=u.integrity),u.referrerPolicy&&(d.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?d.credentials="include":u.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function i(u){if(u.ep)return;u.ep=!0;const d=o(u);fetch(u.href,d)}})();function Bv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var pd={exports:{}},_o={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -58,7 +58,7 @@ Error generating stack: `+l.message+`
58
58
  * @license MIT
59
59
  */var $g="popstate";function Gg(n){return typeof n=="object"&&n!=null&&"pathname"in n&&"search"in n&&"hash"in n&&"state"in n&&"key"in n}function a2(n={}){function r(i,u){var g;let d=(g=u.state)==null?void 0:g.masked,{pathname:f,search:h,hash:v}=d||i.location;return Bd("",{pathname:f,search:h,hash:v},u.state&&u.state.usr||null,u.state&&u.state.key||"default",d?{pathname:i.location.pathname,search:i.location.search,hash:i.location.hash}:void 0)}function o(i,u){return typeof u=="string"?u:Uo(u)}return r2(r,o,null,n)}function at(n,r){if(n===!1||n===null||typeof n>"u")throw new Error(r)}function En(n,r){if(!n){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function l2(){return Math.random().toString(36).substring(2,10)}function Xg(n,r){return{usr:n.state,key:n.key,idx:r,masked:n.unstable_mask?{pathname:n.pathname,search:n.search,hash:n.hash}:void 0}}function Bd(n,r,o=null,i,u){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof r=="string"?jr(r):r,state:o,key:r&&r.key||i||l2(),unstable_mask:u}}function Uo({pathname:n="/",search:r="",hash:o=""}){return r&&r!=="?"&&(n+=r.charAt(0)==="?"?r:"?"+r),o&&o!=="#"&&(n+=o.charAt(0)==="#"?o:"#"+o),n}function jr(n){let r={};if(n){let o=n.indexOf("#");o>=0&&(r.hash=n.substring(o),n=n.substring(0,o));let i=n.indexOf("?");i>=0&&(r.search=n.substring(i),n=n.substring(0,i)),n&&(r.pathname=n)}return r}function r2(n,r,o,i={}){let{window:u=document.defaultView,v5Compat:d=!1}=i,f=u.history,h="POP",v=null,g=x();g==null&&(g=0,f.replaceState({...f.state,idx:g},""));function x(){return(f.state||{idx:null}).idx}function p(){h="POP";let T=x(),C=T==null?null:T-g;g=T,v&&v({action:h,location:N.location,delta:C})}function S(T,C){h="PUSH";let M=Gg(T)?T:Bd(N.location,T,C);g=x()+1;let j=Xg(M,g),k=N.createHref(M.unstable_mask||M);try{f.pushState(j,"",k)}catch(q){if(q instanceof DOMException&&q.name==="DataCloneError")throw q;u.location.assign(k)}d&&v&&v({action:h,location:N.location,delta:1})}function E(T,C){h="REPLACE";let M=Gg(T)?T:Bd(N.location,T,C);g=x();let j=Xg(M,g),k=N.createHref(M.unstable_mask||M);f.replaceState(j,"",k),d&&v&&v({action:h,location:N.location,delta:0})}function R(T){return o2(T)}let N={get action(){return h},get location(){return n(u,f)},listen(T){if(v)throw new Error("A history only accepts one active listener");return u.addEventListener($g,p),v=T,()=>{u.removeEventListener($g,p),v=null}},createHref(T){return r(u,T)},createURL:R,encodeLocation(T){let C=R(T);return{pathname:C.pathname,search:C.search,hash:C.hash}},push:S,replace:E,go(T){return f.go(T)}};return N}function o2(n,r=!1){let o="http://localhost";typeof window<"u"&&(o=window.location.origin!=="null"?window.location.origin:window.location.href),at(o,"No window.location.(origin|href) available to create URL");let i=typeof n=="string"?n:Uo(n);return i=i.replace(/ $/,"%20"),!r&&i.startsWith("//")&&(i=o+i),new URL(i,o)}function qv(n,r,o="/"){return i2(n,r,o,!1)}function i2(n,r,o,i){let u=typeof r=="string"?jr(r):r,d=ma(u.pathname||"/",o);if(d==null)return null;let f=Yv(n);s2(f);let h=null;for(let v=0;h==null&&v<f.length;++v){let g=b2(d);h=v2(f[v],g,i)}return h}function Yv(n,r=[],o=[],i="",u=!1){let d=(f,h,v=u,g)=>{let x={relativePath:g===void 0?f.path||"":g,caseSensitive:f.caseSensitive===!0,childrenIndex:h,route:f};if(x.relativePath.startsWith("/")){if(!x.relativePath.startsWith(i)&&v)return;at(x.relativePath.startsWith(i),`Absolute route path "${x.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),x.relativePath=x.relativePath.slice(i.length)}let p=Yn([i,x.relativePath]),S=o.concat(x);f.children&&f.children.length>0&&(at(f.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),Yv(f.children,r,S,p,v)),!(f.path==null&&!f.index)&&r.push({path:p,score:p2(p,f.index),routesMeta:S})};return n.forEach((f,h)=>{var v;if(f.path===""||!((v=f.path)!=null&&v.includes("?")))d(f,h);else for(let g of $v(f.path))d(f,h,!0,g)}),r}function $v(n){let r=n.split("/");if(r.length===0)return[];let[o,...i]=r,u=o.endsWith("?"),d=o.replace(/\?$/,"");if(i.length===0)return u?[d,""]:[d];let f=$v(i.join("/")),h=[];return h.push(...f.map(v=>v===""?d:[d,v].join("/"))),u&&h.push(...f),h.map(v=>n.startsWith("/")&&v===""?"/":v)}function s2(n){n.sort((r,o)=>r.score!==o.score?o.score-r.score:g2(r.routesMeta.map(i=>i.childrenIndex),o.routesMeta.map(i=>i.childrenIndex)))}var c2=/^:[\w-]+$/,u2=3,d2=2,f2=1,m2=10,h2=-2,Qg=n=>n==="*";function p2(n,r){let o=n.split("/"),i=o.length;return o.some(Qg)&&(i+=h2),r&&(i+=d2),o.filter(u=>!Qg(u)).reduce((u,d)=>u+(c2.test(d)?u2:d===""?f2:m2),i)}function g2(n,r){return n.length===r.length&&n.slice(0,-1).every((i,u)=>i===r[u])?n[n.length-1]-r[r.length-1]:0}function v2(n,r,o=!1){let{routesMeta:i}=n,u={},d="/",f=[];for(let h=0;h<i.length;++h){let v=i[h],g=h===i.length-1,x=d==="/"?r:r.slice(d.length)||"/",p=Ns({path:v.relativePath,caseSensitive:v.caseSensitive,end:g},x),S=v.route;if(!p&&g&&o&&!i[i.length-1].route.index&&(p=Ns({path:v.relativePath,caseSensitive:v.caseSensitive,end:!1},x)),!p)return null;Object.assign(u,p.params),f.push({params:u,pathname:Yn([d,p.pathname]),pathnameBase:E2(Yn([d,p.pathnameBase])),route:S}),p.pathnameBase!=="/"&&(d=Yn([d,p.pathnameBase]))}return f}function Ns(n,r){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[o,i]=y2(n.path,n.caseSensitive,n.end),u=r.match(o);if(!u)return null;let d=u[0],f=d.replace(/(.)\/+$/,"$1"),h=u.slice(1);return{params:i.reduce((g,{paramName:x,isOptional:p},S)=>{if(x==="*"){let R=h[S]||"";f=d.slice(0,d.length-R.length).replace(/(.)\/+$/,"$1")}const E=h[S];return p&&!E?g[x]=void 0:g[x]=(E||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:f,pattern:n}}function y2(n,r=!1,o=!0){En(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let i=[],u="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(f,h,v,g,x)=>{if(i.push({paramName:h,isOptional:v!=null}),v){let p=x.charAt(g+f.length);return p&&p!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(i.push({paramName:"*"}),u+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):o?u+="\\/*$":n!==""&&n!=="/"&&(u+="(?:(?=\\/|$))"),[new RegExp(u,r?void 0:"i"),i]}function b2(n){try{return n.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return En(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${r}).`),n}}function ma(n,r){if(r==="/")return n;if(!n.toLowerCase().startsWith(r.toLowerCase()))return null;let o=r.endsWith("/")?r.length-1:r.length,i=n.charAt(o);return i&&i!=="/"?null:n.slice(o)||"/"}var x2=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function S2(n,r="/"){let{pathname:o,search:i="",hash:u=""}=typeof n=="string"?jr(n):n,d;return o?(o=o.replace(/\/\/+/g,"/"),o.startsWith("/")?d=Kg(o.substring(1),"/"):d=Kg(o,r)):d=r,{pathname:d,search:N2(i),hash:C2(u)}}function Kg(n,r){let o=r.replace(/\/+$/,"").split("/");return n.split("/").forEach(u=>{u===".."?o.length>1&&o.pop():u!=="."&&o.push(u)}),o.length>1?o.join("/"):"/"}function Sd(n,r,o,i){return`Cannot include a '${n}' character in a manually specified \`to.${r}\` field [${JSON.stringify(i)}]. Please separate it out to the \`to.${o}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function w2(n){return n.filter((r,o)=>o===0||r.route.path&&r.route.path.length>0)}function af(n){let r=w2(n);return r.map((o,i)=>i===r.length-1?o.pathname:o.pathnameBase)}function qs(n,r,o,i=!1){let u;typeof n=="string"?u=jr(n):(u={...n},at(!u.pathname||!u.pathname.includes("?"),Sd("?","pathname","search",u)),at(!u.pathname||!u.pathname.includes("#"),Sd("#","pathname","hash",u)),at(!u.search||!u.search.includes("#"),Sd("#","search","hash",u)));let d=n===""||u.pathname==="",f=d?"/":u.pathname,h;if(f==null)h=o;else{let p=r.length-1;if(!i&&f.startsWith("..")){let S=f.split("/");for(;S[0]==="..";)S.shift(),p-=1;u.pathname=S.join("/")}h=p>=0?r[p]:"/"}let v=S2(u,h),g=f&&f!=="/"&&f.endsWith("/"),x=(d||f===".")&&o.endsWith("/");return!v.pathname.endsWith("/")&&(g||x)&&(v.pathname+="/"),v}var Yn=n=>n.join("/").replace(/\/\/+/g,"/"),E2=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),N2=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,C2=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n,T2=class{constructor(n,r,o,i=!1){this.status=n,this.statusText=r||"",this.internal=i,o instanceof Error?(this.data=o.toString(),this.error=o):this.data=o}};function R2(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}function A2(n){return n.map(r=>r.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Gv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Xv(n,r){let o=n;if(typeof o!="string"||!x2.test(o))return{absoluteURL:void 0,isExternal:!1,to:o};let i=o,u=!1;if(Gv)try{let d=new URL(window.location.href),f=o.startsWith("//")?new URL(d.protocol+o):new URL(o),h=ma(f.pathname,r);f.origin===d.origin&&h!=null?o=h+f.search+f.hash:u=!0}catch{En(!1,`<Link to="${o}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:i,isExternal:u,to:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Qv=["POST","PUT","PATCH","DELETE"];new Set(Qv);var _2=["GET",...Qv];new Set(_2);var Or=y.createContext(null);Or.displayName="DataRouter";var Ys=y.createContext(null);Ys.displayName="DataRouterState";var j2=y.createContext(!1),Kv=y.createContext({isTransitioning:!1});Kv.displayName="ViewTransition";var O2=y.createContext(new Map);O2.displayName="Fetchers";var M2=y.createContext(null);M2.displayName="Await";var an=y.createContext(null);an.displayName="Navigation";var Vo=y.createContext(null);Vo.displayName="Location";var gn=y.createContext({outlet:null,matches:[],isDataRoute:!1});gn.displayName="Route";var lf=y.createContext(null);lf.displayName="RouteError";var Zv="REACT_ROUTER_ERROR",D2="REDIRECT",k2="ROUTE_ERROR_RESPONSE";function z2(n){if(n.startsWith(`${Zv}:${D2}:{`))try{let r=JSON.parse(n.slice(28));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string"&&typeof r.location=="string"&&typeof r.reloadDocument=="boolean"&&typeof r.replace=="boolean")return r}catch{}}function L2(n){if(n.startsWith(`${Zv}:${k2}:{`))try{let r=JSON.parse(n.slice(40));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string")return new T2(r.status,r.statusText,r.data)}catch{}}function U2(n,{relative:r}={}){at(Mr(),"useHref() may be used only in the context of a <Router> component.");let{basename:o,navigator:i}=y.useContext(an),{hash:u,pathname:d,search:f}=qo(n,{relative:r}),h=d;return o!=="/"&&(h=d==="/"?o:Yn([o,d])),i.createHref({pathname:h,search:f,hash:u})}function Mr(){return y.useContext(Vo)!=null}function Xn(){return at(Mr(),"useLocation() may be used only in the context of a <Router> component."),y.useContext(Vo).location}var Pv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Iv(n){y.useContext(an).static||y.useLayoutEffect(n)}function Fv(){let{isDataRoute:n}=y.useContext(gn);return n?F2():B2()}function B2(){at(Mr(),"useNavigate() may be used only in the context of a <Router> component.");let n=y.useContext(Or),{basename:r,navigator:o}=y.useContext(an),{matches:i}=y.useContext(gn),{pathname:u}=Xn(),d=JSON.stringify(af(i)),f=y.useRef(!1);return Iv(()=>{f.current=!0}),y.useCallback((v,g={})=>{if(En(f.current,Pv),!f.current)return;if(typeof v=="number"){o.go(v);return}let x=qs(v,JSON.parse(d),u,g.relative==="path");n==null&&r!=="/"&&(x.pathname=x.pathname==="/"?r:Yn([r,x.pathname])),(g.replace?o.replace:o.push)(x,g.state,g)},[r,o,d,u,n])}var Jv=y.createContext(null);function L3(){return y.useContext(Jv)}function H2(n){let r=y.useContext(gn).outlet;return y.useMemo(()=>r&&y.createElement(Jv.Provider,{value:n},r),[r,n])}function U3(){let{matches:n}=y.useContext(gn),r=n[n.length-1];return r?r.params:{}}function qo(n,{relative:r}={}){let{matches:o}=y.useContext(gn),{pathname:i}=Xn(),u=JSON.stringify(af(o));return y.useMemo(()=>qs(n,JSON.parse(u),i,r==="path"),[n,u,i,r])}function V2(n,r){return Wv(n,r)}function Wv(n,r,o){var T;at(Mr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=y.useContext(an),{matches:u}=y.useContext(gn),d=u[u.length-1],f=d?d.params:{},h=d?d.pathname:"/",v=d?d.pathnameBase:"/",g=d&&d.route;{let C=g&&g.path||"";t0(h,!g||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
60
60
 
61
- Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let x=Xn(),p;if(r){let C=typeof r=="string"?jr(r):r;at(v==="/"||((T=C.pathname)==null?void 0:T.startsWith(v)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${v}" but pathname "${C.pathname}" was given in the \`location\` prop.`),p=C}else p=x;let S=p.pathname||"/",E=S;if(v!=="/"){let C=v.replace(/^\//,"").split("/");E="/"+S.replace(/^\//,"").split("/").slice(C.length).join("/")}let R=qv(n,{pathname:E});En(g||R!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),En(R==null||R[R.length-1].route.element!==void 0||R[R.length-1].route.Component!==void 0||R[R.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let N=X2(R&&R.map(C=>Object.assign({},C,{params:Object.assign({},f,C.params),pathname:Yn([v,i.encodeLocation?i.encodeLocation(C.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?v:Yn([v,i.encodeLocation?i.encodeLocation(C.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),u,o);return r&&N?y.createElement(Vo.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...p},navigationType:"POP"}},N):N}function q2(){let n=I2(),r=R2(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),o=n instanceof Error?n.stack:null,i="rgba(200,200,200, 0.5)",u={padding:"0.5rem",backgroundColor:i},d={padding:"2px 4px",backgroundColor:i},f=null;return console.error("Error handled by React Router default ErrorBoundary:",n),f=y.createElement(y.Fragment,null,y.createElement("p",null,"💿 Hey developer 👋"),y.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",y.createElement("code",{style:d},"ErrorBoundary")," or"," ",y.createElement("code",{style:d},"errorElement")," prop on your route.")),y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},r),o?y.createElement("pre",{style:u},o):null,f)}var Y2=y.createElement(q2,null),e0=class extends y.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,r){return r.location!==n.location||r.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:r.error,location:r.location,revalidation:n.revalidation||r.revalidation}}componentDidCatch(n,r){this.props.onError?this.props.onError(n,r):console.error("React Router caught the following error during render",n)}render(){let n=this.state.error;if(this.context&&typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){const o=L2(n.digest);o&&(n=o)}let r=n!==void 0?y.createElement(gn.Provider,{value:this.props.routeContext},y.createElement(lf.Provider,{value:n,children:this.props.component})):this.props.children;return this.context?y.createElement($2,{error:n},r):r}};e0.contextType=j2;var wd=new WeakMap;function $2({children:n,error:r}){let{basename:o}=y.useContext(an);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let i=z2(r.digest);if(i){let u=wd.get(r);if(u)throw u;let d=Xv(i.location,o);if(Gv&&!wd.get(r))if(d.isExternal||i.reloadDocument)window.location.href=d.absoluteURL||d.to;else{const f=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(d.to,{replace:i.replace}));throw wd.set(r,f),f}return y.createElement("meta",{httpEquiv:"refresh",content:`0;url=${d.absoluteURL||d.to}`})}}return n}function G2({routeContext:n,match:r,children:o}){let i=y.useContext(Or);return i&&i.static&&i.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=r.route.id),y.createElement(gn.Provider,{value:n},o)}function X2(n,r=[],o){let i=o==null?void 0:o.state;if(n==null){if(!i)return null;if(i.errors)n=i.matches;else if(r.length===0&&!i.initialized&&i.matches.length>0)n=i.matches;else return null}let u=n,d=i==null?void 0:i.errors;if(d!=null){let x=u.findIndex(p=>p.route.id&&(d==null?void 0:d[p.route.id])!==void 0);at(x>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(d).join(",")}`),u=u.slice(0,Math.min(u.length,x+1))}let f=!1,h=-1;if(o&&i){f=i.renderFallback;for(let x=0;x<u.length;x++){let p=u[x];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(h=x),p.route.id){let{loaderData:S,errors:E}=i,R=p.route.loader&&!S.hasOwnProperty(p.route.id)&&(!E||E[p.route.id]===void 0);if(p.route.lazy||R){o.isStatic&&(f=!0),h>=0?u=u.slice(0,h+1):u=[u[0]];break}}}}let v=o==null?void 0:o.onError,g=i&&v?(x,p)=>{var S,E;v(x,{location:i.location,params:((E=(S=i.matches)==null?void 0:S[0])==null?void 0:E.params)??{},unstable_pattern:A2(i.matches),errorInfo:p})}:void 0;return u.reduceRight((x,p,S)=>{let E,R=!1,N=null,T=null;i&&(E=d&&p.route.id?d[p.route.id]:void 0,N=p.route.errorElement||Y2,f&&(h<0&&S===0?(t0("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),R=!0,T=null):h===S&&(R=!0,T=p.route.hydrateFallbackElement||null)));let C=r.concat(u.slice(0,S+1)),M=()=>{let j;return E?j=N:R?j=T:p.route.Component?j=y.createElement(p.route.Component,null):p.route.element?j=p.route.element:j=x,y.createElement(G2,{match:p,routeContext:{outlet:x,matches:C,isDataRoute:i!=null},children:j})};return i&&(p.route.ErrorBoundary||p.route.errorElement||S===0)?y.createElement(e0,{location:i.location,revalidation:i.revalidation,component:N,error:E,children:M(),routeContext:{outlet:null,matches:C,isDataRoute:!0},onError:g}):M()},null)}function rf(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Q2(n){let r=y.useContext(Or);return at(r,rf(n)),r}function K2(n){let r=y.useContext(Ys);return at(r,rf(n)),r}function Z2(n){let r=y.useContext(gn);return at(r,rf(n)),r}function of(n){let r=Z2(n),o=r.matches[r.matches.length-1];return at(o.route.id,`${n} can only be used on routes that contain a unique "id"`),o.route.id}function P2(){return of("useRouteId")}function I2(){var i;let n=y.useContext(lf),r=K2("useRouteError"),o=of("useRouteError");return n!==void 0?n:(i=r.errors)==null?void 0:i[o]}function F2(){let{router:n}=Q2("useNavigate"),r=of("useNavigate"),o=y.useRef(!1);return Iv(()=>{o.current=!0}),y.useCallback(async(u,d={})=>{En(o.current,Pv),o.current&&(typeof u=="number"?await n.navigate(u):await n.navigate(u,{fromRouteId:r,...d}))},[n,r])}var Zg={};function t0(n,r,o){!r&&!Zg[n]&&(Zg[n]=!0,En(!1,o))}y.memo(J2);function J2({routes:n,future:r,state:o,isStatic:i,onError:u}){return Wv(n,void 0,{state:o,isStatic:i,onError:u})}function Pg({to:n,replace:r,state:o,relative:i}){at(Mr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:u}=y.useContext(an);En(!u,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:d}=y.useContext(gn),{pathname:f}=Xn(),h=Fv(),v=qs(n,af(d),f,i==="path"),g=JSON.stringify(v);return y.useEffect(()=>{h(JSON.parse(g),{replace:r,state:o,relative:i})},[h,g,i,r,o]),null}function W2(n){return H2(n.context)}function Rl(n){at(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function ew({basename:n="/",children:r=null,location:o,navigationType:i="POP",navigator:u,static:d=!1,unstable_useTransitions:f}){at(!Mr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=n.replace(/^\/*/,"/"),v=y.useMemo(()=>({basename:h,navigator:u,static:d,unstable_useTransitions:f,future:{}}),[h,u,d,f]);typeof o=="string"&&(o=jr(o));let{pathname:g="/",search:x="",hash:p="",state:S=null,key:E="default",unstable_mask:R}=o,N=y.useMemo(()=>{let T=ma(g,h);return T==null?null:{location:{pathname:T,search:x,hash:p,state:S,key:E,unstable_mask:R},navigationType:i}},[h,g,x,p,S,E,i,R]);return En(N!=null,`<Router basename="${h}"> is not able to match the URL "${g}${x}${p}" because it does not start with the basename, so the <Router> won't render anything.`),N==null?null:y.createElement(an.Provider,{value:v},y.createElement(Vo.Provider,{children:r,value:N}))}function tw({children:n,location:r}){return V2(Hd(n),r)}function Hd(n,r=[]){let o=[];return y.Children.forEach(n,(i,u)=>{if(!y.isValidElement(i))return;let d=[...r,u];if(i.type===y.Fragment){o.push.apply(o,Hd(i.props.children,d));return}at(i.type===Rl,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),at(!i.props.index||!i.props.children,"An index route cannot have child routes.");let f={id:i.props.id||d.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,middleware:i.props.middleware,loader:i.props.loader,action:i.props.action,hydrateFallbackElement:i.props.hydrateFallbackElement,HydrateFallback:i.props.HydrateFallback,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.hasErrorBoundary===!0||i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(f.children=Hd(i.props.children,d)),o.push(f)}),o}var vs="get",ys="application/x-www-form-urlencoded";function $s(n){return typeof HTMLElement<"u"&&n instanceof HTMLElement}function nw(n){return $s(n)&&n.tagName.toLowerCase()==="button"}function aw(n){return $s(n)&&n.tagName.toLowerCase()==="form"}function lw(n){return $s(n)&&n.tagName.toLowerCase()==="input"}function rw(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function ow(n,r){return n.button===0&&(!r||r==="_self")&&!rw(n)}var rs=null;function iw(){if(rs===null)try{new FormData(document.createElement("form"),0),rs=!1}catch{rs=!0}return rs}var sw=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ed(n){return n!=null&&!sw.has(n)?(En(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ys}"`),null):n}function cw(n,r){let o,i,u,d,f;if(aw(n)){let h=n.getAttribute("action");i=h?ma(h,r):null,o=n.getAttribute("method")||vs,u=Ed(n.getAttribute("enctype"))||ys,d=new FormData(n)}else if(nw(n)||lw(n)&&(n.type==="submit"||n.type==="image")){let h=n.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let v=n.getAttribute("formaction")||h.getAttribute("action");if(i=v?ma(v,r):null,o=n.getAttribute("formmethod")||h.getAttribute("method")||vs,u=Ed(n.getAttribute("formenctype"))||Ed(h.getAttribute("enctype"))||ys,d=new FormData(h,n),!iw()){let{name:g,type:x,value:p}=n;if(x==="image"){let S=g?`${g}.`:"";d.append(`${S}x`,"0"),d.append(`${S}y`,"0")}else g&&d.append(g,p)}}else{if($s(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');o=vs,i=null,u=ys,f=n}return d&&u==="text/plain"&&(f=d,d=void 0),{action:i,method:o.toLowerCase(),encType:u,formData:d,body:f}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function sf(n,r){if(n===!1||n===null||typeof n>"u")throw new Error(r)}function uw(n,r,o,i){let u=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return o?u.pathname.endsWith("/")?u.pathname=`${u.pathname}_.${i}`:u.pathname=`${u.pathname}.${i}`:u.pathname==="/"?u.pathname=`_root.${i}`:r&&ma(u.pathname,r)==="/"?u.pathname=`${r.replace(/\/$/,"")}/_root.${i}`:u.pathname=`${u.pathname.replace(/\/$/,"")}.${i}`,u}async function dw(n,r){if(n.id in r)return r[n.id];try{let o=await import(n.module);return r[n.id]=o,o}catch(o){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(o),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function fw(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function mw(n,r,o){let i=await Promise.all(n.map(async u=>{let d=r.routes[u.route.id];if(d){let f=await dw(d,o);return f.links?f.links():[]}return[]}));return vw(i.flat(1).filter(fw).filter(u=>u.rel==="stylesheet"||u.rel==="preload").map(u=>u.rel==="stylesheet"?{...u,rel:"prefetch",as:"style"}:{...u,rel:"prefetch"}))}function Ig(n,r,o,i,u,d){let f=(v,g)=>o[g]?v.route.id!==o[g].route.id:!0,h=(v,g)=>{var x;return o[g].pathname!==v.pathname||((x=o[g].route.path)==null?void 0:x.endsWith("*"))&&o[g].params["*"]!==v.params["*"]};return d==="assets"?r.filter((v,g)=>f(v,g)||h(v,g)):d==="data"?r.filter((v,g)=>{var p;let x=i.routes[v.route.id];if(!x||!x.hasLoader)return!1;if(f(v,g)||h(v,g))return!0;if(v.route.shouldRevalidate){let S=v.route.shouldRevalidate({currentUrl:new URL(u.pathname+u.search+u.hash,window.origin),currentParams:((p=o[0])==null?void 0:p.params)||{},nextUrl:new URL(n,window.origin),nextParams:v.params,defaultShouldRevalidate:!0});if(typeof S=="boolean")return S}return!0}):[]}function hw(n,r,{includeHydrateFallback:o}={}){return pw(n.map(i=>{let u=r.routes[i.route.id];if(!u)return[];let d=[u.module];return u.clientActionModule&&(d=d.concat(u.clientActionModule)),u.clientLoaderModule&&(d=d.concat(u.clientLoaderModule)),o&&u.hydrateFallbackModule&&(d=d.concat(u.hydrateFallbackModule)),u.imports&&(d=d.concat(u.imports)),d}).flat(1))}function pw(n){return[...new Set(n)]}function gw(n){let r={},o=Object.keys(n).sort();for(let i of o)r[i]=n[i];return r}function vw(n,r){let o=new Set;return new Set(r),n.reduce((i,u)=>{let d=JSON.stringify(gw(u));return o.has(d)||(o.add(d),i.push({key:d,link:u})),i},[])}function n0(){let n=y.useContext(Or);return sf(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function yw(){let n=y.useContext(Ys);return sf(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var cf=y.createContext(void 0);cf.displayName="FrameworkContext";function a0(){let n=y.useContext(cf);return sf(n,"You must render this element inside a <HydratedRouter> element"),n}function bw(n,r){let o=y.useContext(cf),[i,u]=y.useState(!1),[d,f]=y.useState(!1),{onFocus:h,onBlur:v,onMouseEnter:g,onMouseLeave:x,onTouchStart:p}=r,S=y.useRef(null);y.useEffect(()=>{if(n==="render"&&f(!0),n==="viewport"){let N=C=>{C.forEach(M=>{f(M.isIntersecting)})},T=new IntersectionObserver(N,{threshold:.5});return S.current&&T.observe(S.current),()=>{T.disconnect()}}},[n]),y.useEffect(()=>{if(i){let N=setTimeout(()=>{f(!0)},100);return()=>{clearTimeout(N)}}},[i]);let E=()=>{u(!0)},R=()=>{u(!1),f(!1)};return o?n!=="intent"?[d,S,{}]:[d,S,{onFocus:Oo(h,E),onBlur:Oo(v,R),onMouseEnter:Oo(g,E),onMouseLeave:Oo(x,R),onTouchStart:Oo(p,E)}]:[!1,S,{}]}function Oo(n,r){return o=>{n&&n(o),o.defaultPrevented||r(o)}}function xw({page:n,...r}){let{router:o}=n0(),i=y.useMemo(()=>qv(o.routes,n,o.basename),[o.routes,n,o.basename]);return i?y.createElement(ww,{page:n,matches:i,...r}):null}function Sw(n){let{manifest:r,routeModules:o}=a0(),[i,u]=y.useState([]);return y.useEffect(()=>{let d=!1;return mw(n,r,o).then(f=>{d||u(f)}),()=>{d=!0}},[n,r,o]),i}function ww({page:n,matches:r,...o}){let i=Xn(),{future:u,manifest:d,routeModules:f}=a0(),{basename:h}=n0(),{loaderData:v,matches:g}=yw(),x=y.useMemo(()=>Ig(n,r,g,d,i,"data"),[n,r,g,d,i]),p=y.useMemo(()=>Ig(n,r,g,d,i,"assets"),[n,r,g,d,i]),S=y.useMemo(()=>{if(n===i.pathname+i.search+i.hash)return[];let N=new Set,T=!1;if(r.forEach(M=>{var k;let j=d.routes[M.route.id];!j||!j.hasLoader||(!x.some(q=>q.route.id===M.route.id)&&M.route.id in v&&((k=f[M.route.id])!=null&&k.shouldRevalidate)||j.hasClientLoader?T=!0:N.add(M.route.id))}),N.size===0)return[];let C=uw(n,h,u.unstable_trailingSlashAwareDataRequests,"data");return T&&N.size>0&&C.searchParams.set("_routes",r.filter(M=>N.has(M.route.id)).map(M=>M.route.id).join(",")),[C.pathname+C.search]},[h,u.unstable_trailingSlashAwareDataRequests,v,i,d,x,r,n,f]),E=y.useMemo(()=>hw(p,d),[p,d]),R=Sw(p);return y.createElement(y.Fragment,null,S.map(N=>y.createElement("link",{key:N,rel:"prefetch",as:"fetch",href:N,...o})),E.map(N=>y.createElement("link",{key:N,rel:"modulepreload",href:N,...o})),R.map(({key:N,link:T})=>y.createElement("link",{key:N,nonce:o.nonce,...T,crossOrigin:T.crossOrigin??o.crossOrigin})))}function Ew(...n){return r=>{n.forEach(o=>{typeof o=="function"?o(r):o!=null&&(o.current=r)})}}var Nw=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Nw&&(window.__reactRouterVersion="7.13.2")}catch{}function Cw({basename:n,children:r,unstable_useTransitions:o,window:i}){let u=y.useRef();u.current==null&&(u.current=a2({window:i,v5Compat:!0}));let d=u.current,[f,h]=y.useState({action:d.action,location:d.location}),v=y.useCallback(g=>{o===!1?h(g):y.startTransition(()=>h(g))},[o]);return y.useLayoutEffect(()=>d.listen(v),[d,v]),y.createElement(ew,{basename:n,children:r,location:f.location,navigationType:f.action,navigator:d,unstable_useTransitions:o})}var l0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,r0=y.forwardRef(function({onClick:r,discover:o="render",prefetch:i="none",relative:u,reloadDocument:d,replace:f,unstable_mask:h,state:v,target:g,to:x,preventScrollReset:p,viewTransition:S,unstable_defaultShouldRevalidate:E,...R},N){let{basename:T,navigator:C,unstable_useTransitions:M}=y.useContext(an),j=typeof x=="string"&&l0.test(x),k=Xv(x,T);x=k.to;let q=U2(x,{relative:u}),G=Xn(),H=null;if(h){let ce=qs(h,[],G.unstable_mask?G.unstable_mask.pathname:"/",!0);T!=="/"&&(ce.pathname=ce.pathname==="/"?T:Yn([T,ce.pathname])),H=C.createHref(ce)}let[V,ne,de]=bw(i,R),ye=Aw(x,{replace:f,unstable_mask:h,state:v,target:g,preventScrollReset:p,relative:u,viewTransition:S,unstable_defaultShouldRevalidate:E,unstable_useTransitions:M});function oe(ce){r&&r(ce),ce.defaultPrevented||ye(ce)}let se=!(k.isExternal||d),le=y.createElement("a",{...R,...de,href:(se?H:void 0)||k.absoluteURL||q,onClick:se?oe:r,ref:Ew(N,ne),target:g,"data-discover":!j&&o==="render"?"true":void 0});return V&&!j?y.createElement(y.Fragment,null,le,y.createElement(xw,{page:q})):le});r0.displayName="Link";var o0=y.forwardRef(function({"aria-current":r="page",caseSensitive:o=!1,className:i="",end:u=!1,style:d,to:f,viewTransition:h,children:v,...g},x){let p=qo(f,{relative:g.relative}),S=Xn(),E=y.useContext(Ys),{navigator:R,basename:N}=y.useContext(an),T=E!=null&&Dw(p)&&h===!0,C=R.encodeLocation?R.encodeLocation(p).pathname:p.pathname,M=S.pathname,j=E&&E.navigation&&E.navigation.location?E.navigation.location.pathname:null;o||(M=M.toLowerCase(),j=j?j.toLowerCase():null,C=C.toLowerCase()),j&&N&&(j=ma(j,N)||j);const k=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let q=M===C||!u&&M.startsWith(C)&&M.charAt(k)==="/",G=j!=null&&(j===C||!u&&j.startsWith(C)&&j.charAt(C.length)==="/"),H={isActive:q,isPending:G,isTransitioning:T},V=q?r:void 0,ne;typeof i=="function"?ne=i(H):ne=[i,q?"active":null,G?"pending":null,T?"transitioning":null].filter(Boolean).join(" ");let de=typeof d=="function"?d(H):d;return y.createElement(r0,{...g,"aria-current":V,className:ne,ref:x,style:de,to:f,viewTransition:h},typeof v=="function"?v(H):v)});o0.displayName="NavLink";var Tw=y.forwardRef(({discover:n="render",fetcherKey:r,navigate:o,reloadDocument:i,replace:u,state:d,method:f=vs,action:h,onSubmit:v,relative:g,preventScrollReset:x,viewTransition:p,unstable_defaultShouldRevalidate:S,...E},R)=>{let{unstable_useTransitions:N}=y.useContext(an),T=Ow(),C=Mw(h,{relative:g}),M=f.toLowerCase()==="get"?"get":"post",j=typeof h=="string"&&l0.test(h),k=q=>{if(v&&v(q),q.defaultPrevented)return;q.preventDefault();let G=q.nativeEvent.submitter,H=(G==null?void 0:G.getAttribute("formmethod"))||f,V=()=>T(G||q.currentTarget,{fetcherKey:r,method:H,navigate:o,replace:u,state:d,relative:g,preventScrollReset:x,viewTransition:p,unstable_defaultShouldRevalidate:S});N&&o!==!1?y.startTransition(()=>V()):V()};return y.createElement("form",{ref:R,method:M,action:C,onSubmit:i?v:k,...E,"data-discover":!j&&n==="render"?"true":void 0})});Tw.displayName="Form";function Rw(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function i0(n){let r=y.useContext(Or);return at(r,Rw(n)),r}function Aw(n,{target:r,replace:o,unstable_mask:i,state:u,preventScrollReset:d,relative:f,viewTransition:h,unstable_defaultShouldRevalidate:v,unstable_useTransitions:g}={}){let x=Fv(),p=Xn(),S=qo(n,{relative:f});return y.useCallback(E=>{if(ow(E,r)){E.preventDefault();let R=o!==void 0?o:Uo(p)===Uo(S),N=()=>x(n,{replace:R,unstable_mask:i,state:u,preventScrollReset:d,relative:f,viewTransition:h,unstable_defaultShouldRevalidate:v});g?y.startTransition(()=>N()):N()}},[p,x,S,o,i,u,r,n,d,f,h,v,g])}var _w=0,jw=()=>`__${String(++_w)}__`;function Ow(){let{router:n}=i0("useSubmit"),{basename:r}=y.useContext(an),o=P2(),i=n.fetch,u=n.navigate;return y.useCallback(async(d,f={})=>{let{action:h,method:v,encType:g,formData:x,body:p}=cw(d,r);if(f.navigate===!1){let S=f.fetcherKey||jw();await i(S,o,f.action||h,{unstable_defaultShouldRevalidate:f.unstable_defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:x,body:p,formMethod:f.method||v,formEncType:f.encType||g,flushSync:f.flushSync})}else await u(f.action||h,{unstable_defaultShouldRevalidate:f.unstable_defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:x,body:p,formMethod:f.method||v,formEncType:f.encType||g,replace:f.replace,state:f.state,fromRouteId:o,flushSync:f.flushSync,viewTransition:f.viewTransition})},[i,u,r,o])}function Mw(n,{relative:r}={}){let{basename:o}=y.useContext(an),i=y.useContext(gn);at(i,"useFormAction must be used inside a RouteContext");let[u]=i.matches.slice(-1),d={...qo(n||".",{relative:r})},f=Xn();if(n==null){d.search=f.search;let h=new URLSearchParams(d.search),v=h.getAll("index");if(v.some(x=>x==="")){h.delete("index"),v.filter(p=>p).forEach(p=>h.append("index",p));let x=h.toString();d.search=x?`?${x}`:""}}return(!n||n===".")&&u.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),o!=="/"&&(d.pathname=d.pathname==="/"?o:Yn([o,d.pathname])),Uo(d)}function Dw(n,{relative:r}={}){let o=y.useContext(Kv);at(o!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=i0("useViewTransitionState"),u=qo(n,{relative:r});if(!o.isTransitioning)return!1;let d=ma(o.currentLocation.pathname,i)||o.currentLocation.pathname,f=ma(o.nextLocation.pathname,i)||o.nextLocation.pathname;return Ns(u.pathname,f)!=null||Ns(u.pathname,d)!=null}var Yo=Hv();const s0=Bv(Yo),kw="/api";function zw(n,r){if(typeof n=="string"&&n)return n;if(n&&typeof n=="object"){const o=n,i=typeof o.error=="object"&&o.error!==null?o.error:void 0;if(typeof o.error=="string"&&o.error)return o.error;if(typeof(i==null?void 0:i.message)=="string"&&i.message)return i.message;if(typeof o.message=="string"&&o.message)return o.message}return r}async function Ce(n,r){const o=await fetch(`${kw}${n}`,{...r,headers:{"Content-Type":"application/json",...r==null?void 0:r.headers}});if(!o.ok){const i=await o.json().catch(()=>o.statusText);throw new Error(zw(i,`HTTP ${o.status}`))}return o.json()}function Lw(){return Ce("/system/info")}function B3(n){return Ce("/system/transport",{method:"POST",body:JSON.stringify({type:n})})}function Uw(n){return Ce("/system/runtime/restart",{method:"POST",body:JSON.stringify(n)})}function Bw(){return Ce("/system/runtime/stop",{method:"POST"})}function Hw(){return Ce("/cluster/state")}function H3(){return Ce("/cluster/promote",{method:"POST"})}function V3(n){return Ce("/cluster/connect",{method:"POST",body:JSON.stringify(n)})}function q3(){return Ce("/cluster/disconnect",{method:"POST"})}function Vw(n){return Ce(`/node-operations/${n}`)}async function qw(n={}){const r=new URLSearchParams;n.nodeId&&r.set("nodeId",n.nodeId),n.status&&r.set("status",n.status),n.kind&&r.set("kind",n.kind);const o=r.toString();return(await Ce(`/node-operations${o?`?${o}`:""}`)).operations}function Yw(n,r){return Ce(`/nodes/${n}/agents/${r}/upgrade`,{method:"POST"})}function $w(n,r){return Ce(`/nodes/${n}/runtime/restart`,{method:"POST",body:JSON.stringify(r)})}function Y3(n,r){return Ce(`/nodes/${n}/devtunnel`,{method:"POST",body:JSON.stringify({enabled:r})})}function $3(n,r={}){const o=new URLSearchParams;r.path&&o.set("path",r.path),r.limit!==void 0&&o.set("limit",String(Math.min(Math.max(1,r.limit),100))),r.offset!==void 0&&o.set("offset",String(Math.max(0,r.offset))),r.directoriesOnly!==void 0&&o.set("directoriesOnly",String(r.directoriesOnly)),r.allowAbsolute!==void 0&&o.set("allowAbsolute",String(r.allowAbsolute));const i=o.toString();return Ce(`/nodes/${n}/workdir/tree${i?`?${i}`:""}`)}function G3(n,r={}){const o=new URLSearchParams;r.path&&o.set("path",r.path),r.limit!==void 0&&o.set("limit",String(Math.min(Math.max(1,r.limit),20))),r.offset!==void 0&&o.set("offset",String(Math.max(0,r.offset))),r.allowAbsolute!==void 0&&o.set("allowAbsolute",String(r.allowAbsolute));const i=o.toString();return Ce(`/nodes/${n}/workdir/branch${i?`?${i}`:""}`)}function X3(n,r){const o=new URLSearchParams;return o.set("agent",r.agent),o.set("limit",String(Math.min(Math.max(1,r.limit),100))),Ce(`/nodes/${n}/native-sessions?${o.toString()}`)}function Q3(n,r){return Ce(`/nodes/${n}/workdir/branch`,{method:"POST",body:JSON.stringify({path:r.path,branchName:r.branchName,startPoint:r.startPoint,limit:r.limit,offset:r.offset,allowAbsolute:r.allowAbsolute})})}function K3(n,r){return Ce(`/nodes/${n}/terminal/sessions`,{method:"POST",body:JSON.stringify(r)})}function Z3(n){return Ce(`/nodes/${n}/terminal/sessions`)}function P3(n,r){return Ce(`/nodes/${n}/terminal/sessions/${r}`)}function I3(n,r){return Ce(`/nodes/${n}/terminal/sessions/${r}/stop`,{method:"POST"})}async function F3(n){const r=new URLSearchParams;n!=null&&n.status&&r.set("status",n.status),n!=null&&n.assignedTo&&r.set("assignedTo",n.assignedTo),n!=null&&n.priority&&r.set("priority",n.priority);{const u=Math.min(Math.max(1,n.limit),100);r.set("limit",String(u))}n!=null&&n.offset&&r.set("offset",String(n.offset));const o=r.toString();return(await Ce(`/tasks${o?`?${o}`:""}`)).tasks}function J3(n){return Ce(`/tasks/${n}`)}function W3(n){return Ce("/tasks",{method:"POST",body:JSON.stringify(n)})}function e_(n){return Ce("/tasks/import-session",{method:"POST",body:JSON.stringify(n)})}function t_(n){return Ce("/tasks/batch/delete",{method:"POST",body:JSON.stringify({ids:n})})}function n_(n){return Ce("/tasks/batch/archive",{method:"POST",body:JSON.stringify({ids:n})})}function a_(n){return Ce(`/tasks/${n}/cancel`,{method:"POST"})}function l_(n){return Ce(`/tasks/${n}/retry`,{method:"POST"})}function r_(n,r){return Ce(`/tasks/${n}/logs`)}function o_(n,r){return Ce(`/tasks/${n}/message`,{method:"POST",body:JSON.stringify({content:r})})}function i_(n,r){return Ce(`/tasks/${n}/share`,{method:"POST",body:JSON.stringify(r)})}function s_(n){return Ce(`/tasks/${n}/share`,{method:"DELETE"})}function c_(n){return Ce(`/shared/conversations/${encodeURIComponent(n)}`)}function u_(n,r){return Ce(`/shared/conversations/${encodeURIComponent(n)}/logs`)}function d_(n){return Ce(`/shared/conversations/${encodeURIComponent(n)}/output`)}function f_(n,r="."){return Ce(`/shared/conversations/${encodeURIComponent(n)}/output/tree?path=${encodeURIComponent(r)}`)}function m_(n,r){return Ce(`/shared/conversations/${encodeURIComponent(n)}/output/content?path=${encodeURIComponent(r)}`)}function h_(n,r){return Ce(`/shared/conversations/${encodeURIComponent(n)}/output/preview-sessions`,{method:"POST",body:JSON.stringify(r?{path:r}:{})})}function Gw(n){return n?typeof n=="string"?{path:n}:{...n.path?{path:n.path}:{},...n.port!==void 0?{port:n.port}:{}}:{}}function p_(n){return Ce(`/tasks/${n}/output`)}function g_(n,r="."){return Ce(`/tasks/${n}/output/tree?path=${encodeURIComponent(r)}`)}function v_(n,r){return Ce(`/tasks/${n}/output/content?path=${encodeURIComponent(r)}`)}function y_(n,r){return Ce(`/tasks/${n}/output/preview-sessions`,{method:"POST",body:JSON.stringify(Gw(r))})}function b_(n){return Ce(`/tasks/${n}/output/diff`)}function Xw(n,r,o=!0){const i=y.useRef(n);y.useEffect(()=>{i.current=n},[n]),y.useEffect(()=>{if(!o)return;const u=()=>i.current();u();const d=setInterval(u,r);return()=>clearInterval(d)},[r,o])}let Qw=0;function Kw(n=50){const[r,o]=y.useState([]),[i,u]=y.useState(!1),d=y.useRef(null),f=y.useRef(0),h=y.useRef(new Map);y.useEffect(()=>{const x=new EventSource("/api/events");d.current=x,x.onopen=()=>u(!0),x.onerror=()=>u(!1);const p=["node.joined","node.left","node.status","node.operation.created","node.operation.updated","task.created","task.assigned","task.status","task.updated","task.deleted","task.output","election.started","election.complete","cluster.state","transport.changed"];for(const S of p)x.addEventListener(S,E=>{const R={id:String(++Qw),type:S,data:JSON.parse(E.data),timestamp:Date.now()};o(N=>[R,...N].slice(0,n));for(const[,{pattern:N,callback:T}]of h.current)S.startsWith(N)&&T(R)});return()=>{x.close(),d.current=null,u(!1)}},[n]);const v=y.useCallback((x,p)=>{const S=++f.current;return h.current.set(S,{pattern:x,callback:p}),()=>{h.current.delete(S)}},[]),g=y.useCallback(()=>o([]),[]);return{events:r,connected:i,subscribe:v,clearEvents:g}}const c0=y.createContext(null);function Zw({children:n}){const[r,o]=y.useState(null),[i,u]=y.useState(null),[d,f]=y.useState(!0),[h,v]=y.useState(null),{events:g,connected:x,subscribe:p}=Kw(),S=y.useCallback(async()=>{try{const[E,R]=await Promise.all([Hw(),Lw()]),N=E,T=R.nodeId??R.id,C=N.nodes??[],M=C.find(k=>k.id===T)??{id:T,name:R.name,endpoint:R.endpoint,role:R.role,status:R.status,capabilities:R.capabilities,joinedAt:R.joinedAt,lastHeartbeat:R.lastHeartbeat},j=N.leaderId?C.find(k=>k.id===N.leaderId)??null:null;o({leader:j?{id:j.id,name:j.name,endpoint:j.endpoint,...j.dashboardOrigin?{dashboardOrigin:j.dashboardOrigin}:{}}:null,term:N.term??0,nodes:C,self:M,taskSummary:N.taskSummary??{total:0,pending:0,running:0,completed:0,failed:0}}),u(R),v(null)}catch(E){v(E instanceof Error?E.message:"Failed to fetch cluster state")}finally{f(!1)}},[]);return Xw(S,1e4),y.useEffect(()=>{const E=[p("cluster",S),p("election",S),p("node",S),p("transport",S),p("task",S)];return()=>E.forEach(R=>R())},[p,S]),m.jsx(c0.Provider,{value:{cluster:r,systemInfo:i,events:g,sseConnected:x,subscribe:p,refresh:S,loading:d,error:h},children:n})}function u0(){const n=y.useContext(c0);if(!n)throw new Error("useCluster must be used within ClusterProvider");return n}/**
61
+ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let x=Xn(),p;if(r){let C=typeof r=="string"?jr(r):r;at(v==="/"||((T=C.pathname)==null?void 0:T.startsWith(v)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${v}" but pathname "${C.pathname}" was given in the \`location\` prop.`),p=C}else p=x;let S=p.pathname||"/",E=S;if(v!=="/"){let C=v.replace(/^\//,"").split("/");E="/"+S.replace(/^\//,"").split("/").slice(C.length).join("/")}let R=qv(n,{pathname:E});En(g||R!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),En(R==null||R[R.length-1].route.element!==void 0||R[R.length-1].route.Component!==void 0||R[R.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let N=X2(R&&R.map(C=>Object.assign({},C,{params:Object.assign({},f,C.params),pathname:Yn([v,i.encodeLocation?i.encodeLocation(C.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?v:Yn([v,i.encodeLocation?i.encodeLocation(C.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),u,o);return r&&N?y.createElement(Vo.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...p},navigationType:"POP"}},N):N}function q2(){let n=I2(),r=R2(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),o=n instanceof Error?n.stack:null,i="rgba(200,200,200, 0.5)",u={padding:"0.5rem",backgroundColor:i},d={padding:"2px 4px",backgroundColor:i},f=null;return console.error("Error handled by React Router default ErrorBoundary:",n),f=y.createElement(y.Fragment,null,y.createElement("p",null,"💿 Hey developer 👋"),y.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",y.createElement("code",{style:d},"ErrorBoundary")," or"," ",y.createElement("code",{style:d},"errorElement")," prop on your route.")),y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},r),o?y.createElement("pre",{style:u},o):null,f)}var Y2=y.createElement(q2,null),e0=class extends y.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,r){return r.location!==n.location||r.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:r.error,location:r.location,revalidation:n.revalidation||r.revalidation}}componentDidCatch(n,r){this.props.onError?this.props.onError(n,r):console.error("React Router caught the following error during render",n)}render(){let n=this.state.error;if(this.context&&typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){const o=L2(n.digest);o&&(n=o)}let r=n!==void 0?y.createElement(gn.Provider,{value:this.props.routeContext},y.createElement(lf.Provider,{value:n,children:this.props.component})):this.props.children;return this.context?y.createElement($2,{error:n},r):r}};e0.contextType=j2;var wd=new WeakMap;function $2({children:n,error:r}){let{basename:o}=y.useContext(an);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let i=z2(r.digest);if(i){let u=wd.get(r);if(u)throw u;let d=Xv(i.location,o);if(Gv&&!wd.get(r))if(d.isExternal||i.reloadDocument)window.location.href=d.absoluteURL||d.to;else{const f=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(d.to,{replace:i.replace}));throw wd.set(r,f),f}return y.createElement("meta",{httpEquiv:"refresh",content:`0;url=${d.absoluteURL||d.to}`})}}return n}function G2({routeContext:n,match:r,children:o}){let i=y.useContext(Or);return i&&i.static&&i.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=r.route.id),y.createElement(gn.Provider,{value:n},o)}function X2(n,r=[],o){let i=o==null?void 0:o.state;if(n==null){if(!i)return null;if(i.errors)n=i.matches;else if(r.length===0&&!i.initialized&&i.matches.length>0)n=i.matches;else return null}let u=n,d=i==null?void 0:i.errors;if(d!=null){let x=u.findIndex(p=>p.route.id&&(d==null?void 0:d[p.route.id])!==void 0);at(x>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(d).join(",")}`),u=u.slice(0,Math.min(u.length,x+1))}let f=!1,h=-1;if(o&&i){f=i.renderFallback;for(let x=0;x<u.length;x++){let p=u[x];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(h=x),p.route.id){let{loaderData:S,errors:E}=i,R=p.route.loader&&!S.hasOwnProperty(p.route.id)&&(!E||E[p.route.id]===void 0);if(p.route.lazy||R){o.isStatic&&(f=!0),h>=0?u=u.slice(0,h+1):u=[u[0]];break}}}}let v=o==null?void 0:o.onError,g=i&&v?(x,p)=>{var S,E;v(x,{location:i.location,params:((E=(S=i.matches)==null?void 0:S[0])==null?void 0:E.params)??{},unstable_pattern:A2(i.matches),errorInfo:p})}:void 0;return u.reduceRight((x,p,S)=>{let E,R=!1,N=null,T=null;i&&(E=d&&p.route.id?d[p.route.id]:void 0,N=p.route.errorElement||Y2,f&&(h<0&&S===0?(t0("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),R=!0,T=null):h===S&&(R=!0,T=p.route.hydrateFallbackElement||null)));let C=r.concat(u.slice(0,S+1)),M=()=>{let j;return E?j=N:R?j=T:p.route.Component?j=y.createElement(p.route.Component,null):p.route.element?j=p.route.element:j=x,y.createElement(G2,{match:p,routeContext:{outlet:x,matches:C,isDataRoute:i!=null},children:j})};return i&&(p.route.ErrorBoundary||p.route.errorElement||S===0)?y.createElement(e0,{location:i.location,revalidation:i.revalidation,component:N,error:E,children:M(),routeContext:{outlet:null,matches:C,isDataRoute:!0},onError:g}):M()},null)}function rf(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Q2(n){let r=y.useContext(Or);return at(r,rf(n)),r}function K2(n){let r=y.useContext(Ys);return at(r,rf(n)),r}function Z2(n){let r=y.useContext(gn);return at(r,rf(n)),r}function of(n){let r=Z2(n),o=r.matches[r.matches.length-1];return at(o.route.id,`${n} can only be used on routes that contain a unique "id"`),o.route.id}function P2(){return of("useRouteId")}function I2(){var i;let n=y.useContext(lf),r=K2("useRouteError"),o=of("useRouteError");return n!==void 0?n:(i=r.errors)==null?void 0:i[o]}function F2(){let{router:n}=Q2("useNavigate"),r=of("useNavigate"),o=y.useRef(!1);return Iv(()=>{o.current=!0}),y.useCallback(async(u,d={})=>{En(o.current,Pv),o.current&&(typeof u=="number"?await n.navigate(u):await n.navigate(u,{fromRouteId:r,...d}))},[n,r])}var Zg={};function t0(n,r,o){!r&&!Zg[n]&&(Zg[n]=!0,En(!1,o))}y.memo(J2);function J2({routes:n,future:r,state:o,isStatic:i,onError:u}){return Wv(n,void 0,{state:o,isStatic:i,onError:u})}function Pg({to:n,replace:r,state:o,relative:i}){at(Mr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:u}=y.useContext(an);En(!u,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:d}=y.useContext(gn),{pathname:f}=Xn(),h=Fv(),v=qs(n,af(d),f,i==="path"),g=JSON.stringify(v);return y.useEffect(()=>{h(JSON.parse(g),{replace:r,state:o,relative:i})},[h,g,i,r,o]),null}function W2(n){return H2(n.context)}function Rl(n){at(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function ew({basename:n="/",children:r=null,location:o,navigationType:i="POP",navigator:u,static:d=!1,unstable_useTransitions:f}){at(!Mr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=n.replace(/^\/*/,"/"),v=y.useMemo(()=>({basename:h,navigator:u,static:d,unstable_useTransitions:f,future:{}}),[h,u,d,f]);typeof o=="string"&&(o=jr(o));let{pathname:g="/",search:x="",hash:p="",state:S=null,key:E="default",unstable_mask:R}=o,N=y.useMemo(()=>{let T=ma(g,h);return T==null?null:{location:{pathname:T,search:x,hash:p,state:S,key:E,unstable_mask:R},navigationType:i}},[h,g,x,p,S,E,i,R]);return En(N!=null,`<Router basename="${h}"> is not able to match the URL "${g}${x}${p}" because it does not start with the basename, so the <Router> won't render anything.`),N==null?null:y.createElement(an.Provider,{value:v},y.createElement(Vo.Provider,{children:r,value:N}))}function tw({children:n,location:r}){return V2(Hd(n),r)}function Hd(n,r=[]){let o=[];return y.Children.forEach(n,(i,u)=>{if(!y.isValidElement(i))return;let d=[...r,u];if(i.type===y.Fragment){o.push.apply(o,Hd(i.props.children,d));return}at(i.type===Rl,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),at(!i.props.index||!i.props.children,"An index route cannot have child routes.");let f={id:i.props.id||d.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,middleware:i.props.middleware,loader:i.props.loader,action:i.props.action,hydrateFallbackElement:i.props.hydrateFallbackElement,HydrateFallback:i.props.HydrateFallback,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.hasErrorBoundary===!0||i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(f.children=Hd(i.props.children,d)),o.push(f)}),o}var vs="get",ys="application/x-www-form-urlencoded";function $s(n){return typeof HTMLElement<"u"&&n instanceof HTMLElement}function nw(n){return $s(n)&&n.tagName.toLowerCase()==="button"}function aw(n){return $s(n)&&n.tagName.toLowerCase()==="form"}function lw(n){return $s(n)&&n.tagName.toLowerCase()==="input"}function rw(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function ow(n,r){return n.button===0&&(!r||r==="_self")&&!rw(n)}var rs=null;function iw(){if(rs===null)try{new FormData(document.createElement("form"),0),rs=!1}catch{rs=!0}return rs}var sw=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ed(n){return n!=null&&!sw.has(n)?(En(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ys}"`),null):n}function cw(n,r){let o,i,u,d,f;if(aw(n)){let h=n.getAttribute("action");i=h?ma(h,r):null,o=n.getAttribute("method")||vs,u=Ed(n.getAttribute("enctype"))||ys,d=new FormData(n)}else if(nw(n)||lw(n)&&(n.type==="submit"||n.type==="image")){let h=n.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let v=n.getAttribute("formaction")||h.getAttribute("action");if(i=v?ma(v,r):null,o=n.getAttribute("formmethod")||h.getAttribute("method")||vs,u=Ed(n.getAttribute("formenctype"))||Ed(h.getAttribute("enctype"))||ys,d=new FormData(h,n),!iw()){let{name:g,type:x,value:p}=n;if(x==="image"){let S=g?`${g}.`:"";d.append(`${S}x`,"0"),d.append(`${S}y`,"0")}else g&&d.append(g,p)}}else{if($s(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');o=vs,i=null,u=ys,f=n}return d&&u==="text/plain"&&(f=d,d=void 0),{action:i,method:o.toLowerCase(),encType:u,formData:d,body:f}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function sf(n,r){if(n===!1||n===null||typeof n>"u")throw new Error(r)}function uw(n,r,o,i){let u=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return o?u.pathname.endsWith("/")?u.pathname=`${u.pathname}_.${i}`:u.pathname=`${u.pathname}.${i}`:u.pathname==="/"?u.pathname=`_root.${i}`:r&&ma(u.pathname,r)==="/"?u.pathname=`${r.replace(/\/$/,"")}/_root.${i}`:u.pathname=`${u.pathname.replace(/\/$/,"")}.${i}`,u}async function dw(n,r){if(n.id in r)return r[n.id];try{let o=await import(n.module);return r[n.id]=o,o}catch(o){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(o),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function fw(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function mw(n,r,o){let i=await Promise.all(n.map(async u=>{let d=r.routes[u.route.id];if(d){let f=await dw(d,o);return f.links?f.links():[]}return[]}));return vw(i.flat(1).filter(fw).filter(u=>u.rel==="stylesheet"||u.rel==="preload").map(u=>u.rel==="stylesheet"?{...u,rel:"prefetch",as:"style"}:{...u,rel:"prefetch"}))}function Ig(n,r,o,i,u,d){let f=(v,g)=>o[g]?v.route.id!==o[g].route.id:!0,h=(v,g)=>{var x;return o[g].pathname!==v.pathname||((x=o[g].route.path)==null?void 0:x.endsWith("*"))&&o[g].params["*"]!==v.params["*"]};return d==="assets"?r.filter((v,g)=>f(v,g)||h(v,g)):d==="data"?r.filter((v,g)=>{var p;let x=i.routes[v.route.id];if(!x||!x.hasLoader)return!1;if(f(v,g)||h(v,g))return!0;if(v.route.shouldRevalidate){let S=v.route.shouldRevalidate({currentUrl:new URL(u.pathname+u.search+u.hash,window.origin),currentParams:((p=o[0])==null?void 0:p.params)||{},nextUrl:new URL(n,window.origin),nextParams:v.params,defaultShouldRevalidate:!0});if(typeof S=="boolean")return S}return!0}):[]}function hw(n,r,{includeHydrateFallback:o}={}){return pw(n.map(i=>{let u=r.routes[i.route.id];if(!u)return[];let d=[u.module];return u.clientActionModule&&(d=d.concat(u.clientActionModule)),u.clientLoaderModule&&(d=d.concat(u.clientLoaderModule)),o&&u.hydrateFallbackModule&&(d=d.concat(u.hydrateFallbackModule)),u.imports&&(d=d.concat(u.imports)),d}).flat(1))}function pw(n){return[...new Set(n)]}function gw(n){let r={},o=Object.keys(n).sort();for(let i of o)r[i]=n[i];return r}function vw(n,r){let o=new Set;return new Set(r),n.reduce((i,u)=>{let d=JSON.stringify(gw(u));return o.has(d)||(o.add(d),i.push({key:d,link:u})),i},[])}function n0(){let n=y.useContext(Or);return sf(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function yw(){let n=y.useContext(Ys);return sf(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var cf=y.createContext(void 0);cf.displayName="FrameworkContext";function a0(){let n=y.useContext(cf);return sf(n,"You must render this element inside a <HydratedRouter> element"),n}function bw(n,r){let o=y.useContext(cf),[i,u]=y.useState(!1),[d,f]=y.useState(!1),{onFocus:h,onBlur:v,onMouseEnter:g,onMouseLeave:x,onTouchStart:p}=r,S=y.useRef(null);y.useEffect(()=>{if(n==="render"&&f(!0),n==="viewport"){let N=C=>{C.forEach(M=>{f(M.isIntersecting)})},T=new IntersectionObserver(N,{threshold:.5});return S.current&&T.observe(S.current),()=>{T.disconnect()}}},[n]),y.useEffect(()=>{if(i){let N=setTimeout(()=>{f(!0)},100);return()=>{clearTimeout(N)}}},[i]);let E=()=>{u(!0)},R=()=>{u(!1),f(!1)};return o?n!=="intent"?[d,S,{}]:[d,S,{onFocus:Oo(h,E),onBlur:Oo(v,R),onMouseEnter:Oo(g,E),onMouseLeave:Oo(x,R),onTouchStart:Oo(p,E)}]:[!1,S,{}]}function Oo(n,r){return o=>{n&&n(o),o.defaultPrevented||r(o)}}function xw({page:n,...r}){let{router:o}=n0(),i=y.useMemo(()=>qv(o.routes,n,o.basename),[o.routes,n,o.basename]);return i?y.createElement(ww,{page:n,matches:i,...r}):null}function Sw(n){let{manifest:r,routeModules:o}=a0(),[i,u]=y.useState([]);return y.useEffect(()=>{let d=!1;return mw(n,r,o).then(f=>{d||u(f)}),()=>{d=!0}},[n,r,o]),i}function ww({page:n,matches:r,...o}){let i=Xn(),{future:u,manifest:d,routeModules:f}=a0(),{basename:h}=n0(),{loaderData:v,matches:g}=yw(),x=y.useMemo(()=>Ig(n,r,g,d,i,"data"),[n,r,g,d,i]),p=y.useMemo(()=>Ig(n,r,g,d,i,"assets"),[n,r,g,d,i]),S=y.useMemo(()=>{if(n===i.pathname+i.search+i.hash)return[];let N=new Set,T=!1;if(r.forEach(M=>{var k;let j=d.routes[M.route.id];!j||!j.hasLoader||(!x.some(q=>q.route.id===M.route.id)&&M.route.id in v&&((k=f[M.route.id])!=null&&k.shouldRevalidate)||j.hasClientLoader?T=!0:N.add(M.route.id))}),N.size===0)return[];let C=uw(n,h,u.unstable_trailingSlashAwareDataRequests,"data");return T&&N.size>0&&C.searchParams.set("_routes",r.filter(M=>N.has(M.route.id)).map(M=>M.route.id).join(",")),[C.pathname+C.search]},[h,u.unstable_trailingSlashAwareDataRequests,v,i,d,x,r,n,f]),E=y.useMemo(()=>hw(p,d),[p,d]),R=Sw(p);return y.createElement(y.Fragment,null,S.map(N=>y.createElement("link",{key:N,rel:"prefetch",as:"fetch",href:N,...o})),E.map(N=>y.createElement("link",{key:N,rel:"modulepreload",href:N,...o})),R.map(({key:N,link:T})=>y.createElement("link",{key:N,nonce:o.nonce,...T,crossOrigin:T.crossOrigin??o.crossOrigin})))}function Ew(...n){return r=>{n.forEach(o=>{typeof o=="function"?o(r):o!=null&&(o.current=r)})}}var Nw=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Nw&&(window.__reactRouterVersion="7.13.2")}catch{}function Cw({basename:n,children:r,unstable_useTransitions:o,window:i}){let u=y.useRef();u.current==null&&(u.current=a2({window:i,v5Compat:!0}));let d=u.current,[f,h]=y.useState({action:d.action,location:d.location}),v=y.useCallback(g=>{o===!1?h(g):y.startTransition(()=>h(g))},[o]);return y.useLayoutEffect(()=>d.listen(v),[d,v]),y.createElement(ew,{basename:n,children:r,location:f.location,navigationType:f.action,navigator:d,unstable_useTransitions:o})}var l0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,r0=y.forwardRef(function({onClick:r,discover:o="render",prefetch:i="none",relative:u,reloadDocument:d,replace:f,unstable_mask:h,state:v,target:g,to:x,preventScrollReset:p,viewTransition:S,unstable_defaultShouldRevalidate:E,...R},N){let{basename:T,navigator:C,unstable_useTransitions:M}=y.useContext(an),j=typeof x=="string"&&l0.test(x),k=Xv(x,T);x=k.to;let q=U2(x,{relative:u}),G=Xn(),H=null;if(h){let ce=qs(h,[],G.unstable_mask?G.unstable_mask.pathname:"/",!0);T!=="/"&&(ce.pathname=ce.pathname==="/"?T:Yn([T,ce.pathname])),H=C.createHref(ce)}let[V,ne,de]=bw(i,R),ye=Aw(x,{replace:f,unstable_mask:h,state:v,target:g,preventScrollReset:p,relative:u,viewTransition:S,unstable_defaultShouldRevalidate:E,unstable_useTransitions:M});function oe(ce){r&&r(ce),ce.defaultPrevented||ye(ce)}let se=!(k.isExternal||d),le=y.createElement("a",{...R,...de,href:(se?H:void 0)||k.absoluteURL||q,onClick:se?oe:r,ref:Ew(N,ne),target:g,"data-discover":!j&&o==="render"?"true":void 0});return V&&!j?y.createElement(y.Fragment,null,le,y.createElement(xw,{page:q})):le});r0.displayName="Link";var o0=y.forwardRef(function({"aria-current":r="page",caseSensitive:o=!1,className:i="",end:u=!1,style:d,to:f,viewTransition:h,children:v,...g},x){let p=qo(f,{relative:g.relative}),S=Xn(),E=y.useContext(Ys),{navigator:R,basename:N}=y.useContext(an),T=E!=null&&Dw(p)&&h===!0,C=R.encodeLocation?R.encodeLocation(p).pathname:p.pathname,M=S.pathname,j=E&&E.navigation&&E.navigation.location?E.navigation.location.pathname:null;o||(M=M.toLowerCase(),j=j?j.toLowerCase():null,C=C.toLowerCase()),j&&N&&(j=ma(j,N)||j);const k=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let q=M===C||!u&&M.startsWith(C)&&M.charAt(k)==="/",G=j!=null&&(j===C||!u&&j.startsWith(C)&&j.charAt(C.length)==="/"),H={isActive:q,isPending:G,isTransitioning:T},V=q?r:void 0,ne;typeof i=="function"?ne=i(H):ne=[i,q?"active":null,G?"pending":null,T?"transitioning":null].filter(Boolean).join(" ");let de=typeof d=="function"?d(H):d;return y.createElement(r0,{...g,"aria-current":V,className:ne,ref:x,style:de,to:f,viewTransition:h},typeof v=="function"?v(H):v)});o0.displayName="NavLink";var Tw=y.forwardRef(({discover:n="render",fetcherKey:r,navigate:o,reloadDocument:i,replace:u,state:d,method:f=vs,action:h,onSubmit:v,relative:g,preventScrollReset:x,viewTransition:p,unstable_defaultShouldRevalidate:S,...E},R)=>{let{unstable_useTransitions:N}=y.useContext(an),T=Ow(),C=Mw(h,{relative:g}),M=f.toLowerCase()==="get"?"get":"post",j=typeof h=="string"&&l0.test(h),k=q=>{if(v&&v(q),q.defaultPrevented)return;q.preventDefault();let G=q.nativeEvent.submitter,H=(G==null?void 0:G.getAttribute("formmethod"))||f,V=()=>T(G||q.currentTarget,{fetcherKey:r,method:H,navigate:o,replace:u,state:d,relative:g,preventScrollReset:x,viewTransition:p,unstable_defaultShouldRevalidate:S});N&&o!==!1?y.startTransition(()=>V()):V()};return y.createElement("form",{ref:R,method:M,action:C,onSubmit:i?v:k,...E,"data-discover":!j&&n==="render"?"true":void 0})});Tw.displayName="Form";function Rw(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function i0(n){let r=y.useContext(Or);return at(r,Rw(n)),r}function Aw(n,{target:r,replace:o,unstable_mask:i,state:u,preventScrollReset:d,relative:f,viewTransition:h,unstable_defaultShouldRevalidate:v,unstable_useTransitions:g}={}){let x=Fv(),p=Xn(),S=qo(n,{relative:f});return y.useCallback(E=>{if(ow(E,r)){E.preventDefault();let R=o!==void 0?o:Uo(p)===Uo(S),N=()=>x(n,{replace:R,unstable_mask:i,state:u,preventScrollReset:d,relative:f,viewTransition:h,unstable_defaultShouldRevalidate:v});g?y.startTransition(()=>N()):N()}},[p,x,S,o,i,u,r,n,d,f,h,v,g])}var _w=0,jw=()=>`__${String(++_w)}__`;function Ow(){let{router:n}=i0("useSubmit"),{basename:r}=y.useContext(an),o=P2(),i=n.fetch,u=n.navigate;return y.useCallback(async(d,f={})=>{let{action:h,method:v,encType:g,formData:x,body:p}=cw(d,r);if(f.navigate===!1){let S=f.fetcherKey||jw();await i(S,o,f.action||h,{unstable_defaultShouldRevalidate:f.unstable_defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:x,body:p,formMethod:f.method||v,formEncType:f.encType||g,flushSync:f.flushSync})}else await u(f.action||h,{unstable_defaultShouldRevalidate:f.unstable_defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:x,body:p,formMethod:f.method||v,formEncType:f.encType||g,replace:f.replace,state:f.state,fromRouteId:o,flushSync:f.flushSync,viewTransition:f.viewTransition})},[i,u,r,o])}function Mw(n,{relative:r}={}){let{basename:o}=y.useContext(an),i=y.useContext(gn);at(i,"useFormAction must be used inside a RouteContext");let[u]=i.matches.slice(-1),d={...qo(n||".",{relative:r})},f=Xn();if(n==null){d.search=f.search;let h=new URLSearchParams(d.search),v=h.getAll("index");if(v.some(x=>x==="")){h.delete("index"),v.filter(p=>p).forEach(p=>h.append("index",p));let x=h.toString();d.search=x?`?${x}`:""}}return(!n||n===".")&&u.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),o!=="/"&&(d.pathname=d.pathname==="/"?o:Yn([o,d.pathname])),Uo(d)}function Dw(n,{relative:r}={}){let o=y.useContext(Kv);at(o!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=i0("useViewTransitionState"),u=qo(n,{relative:r});if(!o.isTransitioning)return!1;let d=ma(o.currentLocation.pathname,i)||o.currentLocation.pathname,f=ma(o.nextLocation.pathname,i)||o.nextLocation.pathname;return Ns(u.pathname,f)!=null||Ns(u.pathname,d)!=null}var Yo=Hv();const s0=Bv(Yo),kw="/api";function zw(n,r){if(typeof n=="string"&&n)return n;if(n&&typeof n=="object"){const o=n,i=typeof o.error=="object"&&o.error!==null?o.error:void 0;if(typeof o.error=="string"&&o.error)return o.error;if(typeof(i==null?void 0:i.message)=="string"&&i.message)return i.message;if(typeof o.message=="string"&&o.message)return o.message}return r}async function Ce(n,r){const o=await fetch(`${kw}${n}`,{...r,headers:{"Content-Type":"application/json",...r==null?void 0:r.headers}});if(!o.ok){const i=await o.json().catch(()=>o.statusText);throw new Error(zw(i,`HTTP ${o.status}`))}return o.json()}function Lw(){return Ce("/system/info")}function B3(n){return Ce("/system/transport",{method:"POST",body:JSON.stringify({type:n})})}function Uw(n){return Ce("/system/runtime/restart",{method:"POST",body:JSON.stringify(n)})}function Bw(){return Ce("/system/runtime/stop",{method:"POST"})}function Hw(){return Ce("/cluster/state")}function H3(){return Ce("/cluster/promote",{method:"POST"})}function V3(n){return Ce("/cluster/connect",{method:"POST",body:JSON.stringify(n)})}function q3(){return Ce("/cluster/disconnect",{method:"POST"})}function Vw(n){return Ce(`/node-operations/${n}`)}async function qw(n={}){const r=new URLSearchParams;n.nodeId&&r.set("nodeId",n.nodeId),n.status&&r.set("status",n.status),n.kind&&r.set("kind",n.kind);const o=r.toString();return(await Ce(`/node-operations${o?`?${o}`:""}`)).operations}function Yw(n,r){return Ce(`/nodes/${n}/agents/${r}/upgrade`,{method:"POST"})}function $w(n,r){return Ce(`/nodes/${n}/runtime/restart`,{method:"POST",body:JSON.stringify(r)})}function Y3(n,r){return Ce(`/nodes/${n}/devtunnel`,{method:"POST",body:JSON.stringify({enabled:r})})}function $3(n,r={}){const o=new URLSearchParams;r.path&&o.set("path",r.path),r.limit!==void 0&&o.set("limit",String(Math.min(Math.max(1,r.limit),100))),r.offset!==void 0&&o.set("offset",String(Math.max(0,r.offset))),r.directoriesOnly!==void 0&&o.set("directoriesOnly",String(r.directoriesOnly)),r.allowAbsolute!==void 0&&o.set("allowAbsolute",String(r.allowAbsolute));const i=o.toString();return Ce(`/nodes/${n}/workdir/tree${i?`?${i}`:""}`)}function G3(n,r={}){const o=new URLSearchParams;r.path&&o.set("path",r.path),r.limit!==void 0&&o.set("limit",String(Math.min(Math.max(1,r.limit),20))),r.offset!==void 0&&o.set("offset",String(Math.max(0,r.offset))),r.allowAbsolute!==void 0&&o.set("allowAbsolute",String(r.allowAbsolute));const i=o.toString();return Ce(`/nodes/${n}/workdir/branch${i?`?${i}`:""}`)}function X3(n,r){const o=new URLSearchParams;return o.set("agent",r.agent),o.set("limit",String(Math.min(Math.max(1,r.limit),100))),Ce(`/nodes/${n}/native-sessions?${o.toString()}`)}function Q3(n,r){return Ce(`/nodes/${n}/workdir/branch`,{method:"POST",body:JSON.stringify({path:r.path,branchName:r.branchName,startPoint:r.startPoint,limit:r.limit,offset:r.offset,allowAbsolute:r.allowAbsolute})})}function K3(n,r){return Ce(`/nodes/${n}/terminal/sessions`,{method:"POST",body:JSON.stringify(r)})}function Z3(n){return Ce(`/nodes/${n}/terminal/sessions`)}function P3(n,r){return Ce(`/nodes/${n}/terminal/sessions/${r}`)}function I3(n,r){return Ce(`/nodes/${n}/terminal/sessions/${r}/stop`,{method:"POST"})}async function F3(n){const r=new URLSearchParams;if(n!=null&&n.status&&r.set("status",n.status),n!=null&&n.assignedTo&&r.set("assignedTo",n.assignedTo),n!=null&&n.priority&&r.set("priority",n.priority),n!=null&&n.limit){const u=Math.min(Math.max(1,n.limit),100);r.set("limit",String(u))}n!=null&&n.offset&&r.set("offset",String(n.offset));const o=r.toString();return(await Ce(`/tasks${o?`?${o}`:""}`)).tasks}function J3(n){return Ce(`/tasks/${n}`)}function W3(n){return Ce("/tasks",{method:"POST",body:JSON.stringify(n)})}function e_(n){return Ce("/tasks/import-session",{method:"POST",body:JSON.stringify(n)})}function t_(n){return Ce("/tasks/batch/delete",{method:"POST",body:JSON.stringify({ids:n})})}function n_(n){return Ce("/tasks/batch/archive",{method:"POST",body:JSON.stringify({ids:n})})}function a_(n){return Ce(`/tasks/${n}/cancel`,{method:"POST"})}function l_(n){return Ce(`/tasks/${n}/retry`,{method:"POST"})}function r_(n,r){return Ce(`/tasks/${n}/logs`)}function o_(n,r){return Ce(`/tasks/${n}/message`,{method:"POST",body:JSON.stringify({content:r})})}function i_(n,r){return Ce(`/tasks/${n}/share`,{method:"POST",body:JSON.stringify(r)})}function s_(n){return Ce(`/tasks/${n}/share`,{method:"DELETE"})}function c_(n){return Ce(`/shared/conversations/${encodeURIComponent(n)}`)}function u_(n,r){return Ce(`/shared/conversations/${encodeURIComponent(n)}/logs`)}function d_(n){return Ce(`/shared/conversations/${encodeURIComponent(n)}/output`)}function f_(n,r="."){return Ce(`/shared/conversations/${encodeURIComponent(n)}/output/tree?path=${encodeURIComponent(r)}`)}function m_(n,r){return Ce(`/shared/conversations/${encodeURIComponent(n)}/output/content?path=${encodeURIComponent(r)}`)}function h_(n,r){return Ce(`/shared/conversations/${encodeURIComponent(n)}/output/preview-sessions`,{method:"POST",body:JSON.stringify(r?{path:r}:{})})}function Gw(n){return n?typeof n=="string"?{path:n}:{...n.path?{path:n.path}:{},...n.port!==void 0?{port:n.port}:{}}:{}}function p_(n){return Ce(`/tasks/${n}/output`)}function g_(n,r="."){return Ce(`/tasks/${n}/output/tree?path=${encodeURIComponent(r)}`)}function v_(n,r){return Ce(`/tasks/${n}/output/content?path=${encodeURIComponent(r)}`)}function y_(n,r){return Ce(`/tasks/${n}/output/preview-sessions`,{method:"POST",body:JSON.stringify(Gw(r))})}function b_(n){return Ce(`/tasks/${n}/output/diff`)}function Xw(n,r,o=!0){const i=y.useRef(n);y.useEffect(()=>{i.current=n},[n]),y.useEffect(()=>{if(!o)return;const u=()=>i.current();u();const d=setInterval(u,r);return()=>clearInterval(d)},[r,o])}let Qw=0;function Kw(n=50){const[r,o]=y.useState([]),[i,u]=y.useState(!1),d=y.useRef(null),f=y.useRef(0),h=y.useRef(new Map);y.useEffect(()=>{const x=new EventSource("/api/events");d.current=x,x.onopen=()=>u(!0),x.onerror=()=>u(!1);const p=["node.joined","node.left","node.status","node.operation.created","node.operation.updated","task.created","task.assigned","task.status","task.updated","task.deleted","task.output","election.started","election.complete","cluster.state","transport.changed"];for(const S of p)x.addEventListener(S,E=>{const R={id:String(++Qw),type:S,data:JSON.parse(E.data),timestamp:Date.now()};o(N=>[R,...N].slice(0,n));for(const[,{pattern:N,callback:T}]of h.current)S.startsWith(N)&&T(R)});return()=>{x.close(),d.current=null,u(!1)}},[n]);const v=y.useCallback((x,p)=>{const S=++f.current;return h.current.set(S,{pattern:x,callback:p}),()=>{h.current.delete(S)}},[]),g=y.useCallback(()=>o([]),[]);return{events:r,connected:i,subscribe:v,clearEvents:g}}const c0=y.createContext(null);function Zw({children:n}){const[r,o]=y.useState(null),[i,u]=y.useState(null),[d,f]=y.useState(!0),[h,v]=y.useState(null),{events:g,connected:x,subscribe:p}=Kw(),S=y.useCallback(async()=>{try{const[E,R]=await Promise.all([Hw(),Lw()]),N=E,T=R.nodeId??R.id,C=N.nodes??[],M=C.find(k=>k.id===T)??{id:T,name:R.name,endpoint:R.endpoint,role:R.role,status:R.status,capabilities:R.capabilities,joinedAt:R.joinedAt,lastHeartbeat:R.lastHeartbeat},j=N.leaderId?C.find(k=>k.id===N.leaderId)??null:null;o({leader:j?{id:j.id,name:j.name,endpoint:j.endpoint,...j.dashboardOrigin?{dashboardOrigin:j.dashboardOrigin}:{}}:null,term:N.term??0,nodes:C,self:M,taskSummary:N.taskSummary??{total:0,pending:0,running:0,completed:0,failed:0}}),u(R),v(null)}catch(E){v(E instanceof Error?E.message:"Failed to fetch cluster state")}finally{f(!1)}},[]);return Xw(S,1e4),y.useEffect(()=>{const E=[p("cluster",S),p("election",S),p("node",S),p("transport",S),p("task",S)];return()=>E.forEach(R=>R())},[p,S]),m.jsx(c0.Provider,{value:{cluster:r,systemInfo:i,events:g,sseConnected:x,subscribe:p,refresh:S,loading:d,error:h},children:n})}function u0(){const n=y.useContext(c0);if(!n)throw new Error("useCluster must be used within ClusterProvider");return n}/**
62
62
  * @license lucide-react v1.7.0 - ISC
63
63
  *
64
64
  * This source code is licensed under the ISC license.
@@ -298,4 +298,4 @@ You can add a description to the \`${Rr}\` by passing a \`${sx}\` component as a
298
298
 
299
299
  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 \`${Rr}\`. 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.
300
300
 
301
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return y.useEffect(()=>{var i;document.getElementById((i=n.current)==null?void 0:i.getAttribute("aria-describedby"))||console.warn(r)},[r,n]),null},CA=tx,TA=nx,RA=ax,mx=lx,hx=rx,px=ux,gx=fx,vx=ix,yx=cx;const Wd=CA,ef=TA,AA=RA,bx=y.forwardRef(({className:n,...r},o)=>m.jsx(mx,{className:ve("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}));bx.displayName=mx.displayName;const ks=y.forwardRef(({className:n,...r},o)=>m.jsxs(AA,{children:[m.jsx(bx,{}),m.jsx(hx,{ref:o,className:ve("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 rounded-[22px] border bg-background p-6 shadow-[0_34px_110px_-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})]}));ks.displayName=hx.displayName;const zs=({className:n,...r})=>m.jsx("div",{className:ve("flex flex-col space-y-2 text-center sm:text-left",n),...r});zs.displayName="AlertDialogHeader";const Ls=({className:n,...r})=>m.jsx("div",{className:ve("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...r});Ls.displayName="AlertDialogFooter";const Us=y.forwardRef(({className:n,...r},o)=>m.jsx(vx,{ref:o,className:ve("text-lg font-semibold",n),...r}));Us.displayName=vx.displayName;const Bs=y.forwardRef(({className:n,...r},o)=>m.jsx(yx,{ref:o,className:ve("text-sm text-muted-foreground",n),...r}));Bs.displayName=yx.displayName;const Hs=y.forwardRef(({className:n,...r},o)=>m.jsx(px,{ref:o,className:ve(hf(),n),...r}));Hs.displayName=px.displayName;const Vs=y.forwardRef(({className:n,...r},o)=>m.jsx(gx,{ref:o,className:ve(hf({variant:"outline"}),"mt-2 sm:mt-0",n),...r}));Vs.displayName=gx.displayName;var nc="Checkbox",[_A]=Wa(nc),[jA,Hf]=_A(nc);function OA(n){const{__scopeCheckbox:r,checked:o,children:i,defaultChecked:u,disabled:d,form:f,name:h,onCheckedChange:v,required:g,value:x="on",internal_do_not_use_render:p}=n,[S,E]=Ar({prop:o,defaultProp:u??!1,onChange:v,caller:nc}),[R,N]=y.useState(null),[T,C]=y.useState(null),M=y.useRef(!1),j=R?!!f||!!R.closest("form"):!0,k={checked:S,disabled:d,setChecked:E,control:R,setControl:N,name:h,form:f,value:x,hasConsumerStoppedPropagationRef:M,required:g,defaultChecked:Za(u)?!1:u,isFormControl:j,bubbleInput:T,setBubbleInput:C};return m.jsx(jA,{scope:r,...k,children:MA(p)?p(k):i})}var xx="CheckboxTrigger",Sx=y.forwardRef(({__scopeCheckbox:n,onKeyDown:r,onClick:o,...i},u)=>{const{control:d,value:f,disabled:h,checked:v,required:g,setControl:x,setChecked:p,hasConsumerStoppedPropagationRef:S,isFormControl:E,bubbleInput:R}=Hf(xx,n),N=Ie(u,x),T=y.useRef(v);return y.useEffect(()=>{const C=d==null?void 0:d.form;if(C){const M=()=>p(T.current);return C.addEventListener("reset",M),()=>C.removeEventListener("reset",M)}},[d,p]),m.jsx(Ue.button,{type:"button",role:"checkbox","aria-checked":Za(v)?"mixed":v,"aria-required":g,"data-state":Tx(v),"data-disabled":h?"":void 0,disabled:h,value:f,...i,ref:N,onKeyDown:Me(r,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:Me(o,C=>{p(M=>Za(M)?!0:!M),R&&E&&(S.current=C.isPropagationStopped(),S.current||C.stopPropagation())})})});Sx.displayName=xx;var Vf=y.forwardRef((n,r)=>{const{__scopeCheckbox:o,name:i,checked:u,defaultChecked:d,required:f,disabled:h,value:v,onCheckedChange:g,form:x,...p}=n;return m.jsx(OA,{__scopeCheckbox:o,checked:u,defaultChecked:d,disabled:h,required:f,onCheckedChange:g,name:i,form:x,value:v,internal_do_not_use_render:({isFormControl:S})=>m.jsxs(m.Fragment,{children:[m.jsx(Sx,{...p,ref:r,__scopeCheckbox:o}),S&&m.jsx(Cx,{__scopeCheckbox:o})]})})});Vf.displayName=nc;var wx="CheckboxIndicator",Ex=y.forwardRef((n,r)=>{const{__scopeCheckbox:o,forceMount:i,...u}=n,d=Hf(wx,o);return m.jsx(Dr,{present:i||Za(d.checked)||d.checked===!0,children:m.jsx(Ue.span,{"data-state":Tx(d.checked),"data-disabled":d.disabled?"":void 0,...u,ref:r,style:{pointerEvents:"none",...n.style}})})});Ex.displayName=wx;var Nx="CheckboxBubbleInput",Cx=y.forwardRef(({__scopeCheckbox:n,...r},o)=>{const{control:i,hasConsumerStoppedPropagationRef:u,checked:d,defaultChecked:f,required:h,disabled:v,name:g,value:x,form:p,bubbleInput:S,setBubbleInput:E}=Hf(Nx,n),R=Ie(o,E),N=Ky(d),T=Ly(i);y.useEffect(()=>{const M=S;if(!M)return;const j=window.HTMLInputElement.prototype,q=Object.getOwnPropertyDescriptor(j,"checked").set,G=!u.current;if(N!==d&&q){const H=new Event("click",{bubbles:G});M.indeterminate=Za(d),q.call(M,Za(d)?!1:d),M.dispatchEvent(H)}},[S,N,d,u]);const C=y.useRef(Za(d)?!1:d);return m.jsx(Ue.input,{type:"checkbox","aria-hidden":!0,defaultChecked:f??C.current,required:h,disabled:v,name:g,value:x,form:p,...r,tabIndex:-1,ref:R,style:{...r.style,...T,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Cx.displayName=Nx;function MA(n){return typeof n=="function"}function Za(n){return n==="indeterminate"}function Tx(n){return Za(n)?"indeterminate":n?"checked":"unchecked"}const Rx=y.forwardRef(({className:n,...r},o)=>m.jsx(Vf,{ref:o,className:ve("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:m.jsx(Ex,{className:ve("flex items-center justify-center text-current"),children:m.jsx(uf,{className:"h-3.5 w-3.5"})})}));Rx.displayName=Vf.displayName;const Ax=y.forwardRef(({className:n,type:r,...o},i)=>m.jsx("input",{type:r,className:ve("flex h-10 w-full rounded-[16px] border border-input/85 bg-background/72 px-3 py-2 text-sm shadow-sm ring-offset-background transition-all duration-200 file:border-0 file:bg-transparent file:text-sm 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:i,...o}));Ax.displayName="Input";const kv=["queued","running"];function DA(n){return n==="claude"||n==="codex"}function _x(n){var o;if(n.kind!=="agent.upgrade")return null;const r=(o=n.payload)==null?void 0:o.agent;return DA(r)?`${n.nodeId}:${r}`:null}function kA(n){return n.status==="succeeded"||n.status==="failed"}async function jx(n,r={}){const o=r.getOperation??Vw,i=r.pollIntervalMs??2e3,u=r.timeoutMs??24e4,d=Date.now()+u;let f=n;for(;!kA(f)&&Date.now()<d;)await LA(i),f=await o(n.id);return f}async function zA(n,r=qw){const o=new Set(n),i=await Promise.all(kv.map(d=>r({kind:"agent.upgrade",status:d}))),u=new Map;for(const d of i.flat()){if(!kv.includes(d.status)||o.size>0&&!o.has(d.nodeId))continue;const f=_x(d);if(!f)continue;const h=u.get(f);(!h||d.updatedAt>h.updatedAt)&&u.set(f,d)}return u}function LA(n){return new Promise(r=>setTimeout(r,n))}function UA(n,r=!0){return r?(n==null?void 0:n.restartMode)==="development"?"Restart dev runtime":n!=null&&n.updateAvailable?"Update & restart":"Restart runtime":n!=null&&n.updateAvailable?"Update & restart follower":"Restart follower"}function BA({checkedLabel:n,disableAuthDefault:r,endpoint:o,isLiveLocalNode:i,nodeId:u,nodeName:d,pid:f,transportType:h,update:v,workDir:g}){const x=UA(v,i),[p,S]=y.useState(null),[E,R]=y.useState(()=>zv({disableAuthDefault:r,endpoint:o,nodeName:d,transportType:h,workDir:g})),[N,T]=y.useState(!1),[C,M]=y.useState(!1),[j,k]=y.useState(!1);y.useEffect(()=>{R(zv({disableAuthDefault:r,endpoint:o,nodeName:d,transportType:h,workDir:g}))},[r,o,d,h,g]);async function q(){if(!u||N||C)return;const ne=v.updateAvailable?"update":"restart",de=qA(E);if(E.port.trim()&&(de==null?void 0:de.port)===void 0){Et.error("Runtime restart port must be a positive integer");return}const ye=de?{reason:ne,startArgs:de}:{reason:ne};T(!0);try{if(i){const ce=await Uw(ye);S({...ce,pid:ce.pid??f,status:"accepted"}),Et.info(`Restarting ${d} from a detached helper. PID ${ce.pid??f??"unknown"} will not stay attached to the original terminal window; follow ${ce.logPath} for launch output.`);return}const oe=await $w(u,ye);S({operationId:oe.id,pid:f,status:oe.status}),Et.info(`Restart requested on ${d}. Operation ${Ud(oe.id)} will hand off to a detached process, so the new runtime will not stay attached to the original terminal window.`);const se=await jx(oe,{timeoutMs:6e4}),le=VA(se);S({command:le==null?void 0:le.command,logPath:le==null?void 0:le.logPath,mode:le==null?void 0:le.mode,operationId:se.id,pid:(le==null?void 0:le.pid)??f,status:se.status}),se.status==="succeeded"?Et.success(`Restart handoff accepted on ${d}. Follow ${(le==null?void 0:le.logPath)??"the node restart log"} for launch output.`):se.status==="failed"?Et.error(se.error??`Restart failed on ${d}`):Et.info(`Restart operation ${Ud(se.id)} is still ${se.status}. More details will update after the node reports back.`),T(!1)}catch(oe){T(!1),Et.error(oe instanceof Error?oe.message:"Runtime restart failed")}}async function G(){if(!(!i||N||C)){M(!0);try{const ne=await Bw();Et.info(`Stopping Meshy process ${ne.pid}`)}catch(ne){M(!1),Et.error(ne instanceof Error?ne.message:"Runtime stop failed")}}}const H=N?"restarting":C?"stopping":(p==null?void 0:p.status)??"idle",V=v.restartMode==="development";return m.jsxs("div",{className:"rounded-xl border border-border/70 bg-background/70 overflow-hidden",children:[m.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border/50",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Cs,{className:"h-3.5 w-3.5 text-primary shrink-0"}),m.jsxs("div",{children:[m.jsx("div",{className:"text-[11px] font-semibold text-foreground leading-tight",children:"Runtime"}),m.jsx("div",{className:"text-[10px] text-muted-foreground leading-tight",children:V?"Development launcher":`Latest ${v.latestVersion??"—"}`})]})]}),m.jsx("div",{className:"flex items-center gap-1.5",children:m.jsx(bt,{variant:v.updateAvailable?"default":"outline",className:"rounded-full border-border/70 bg-background/60 font-mono text-[10px] px-2 py-0.5",children:V?"dev":v.updateAvailable?`→ ${v.latestVersion}`:"current"})})]}),m.jsxs("div",{className:"grid grid-cols-2 divide-x divide-border/50 border-b border-border/50",children:[m.jsxs("div",{className:"px-3 py-1.5",children:[m.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:"PID"}),m.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-foreground",children:f??"—"})]}),m.jsxs("div",{className:"px-3 py-1.5",children:[m.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:"Status"}),m.jsx("div",{className:"mt-0.5 text-[11px] text-foreground capitalize",children:H})]})]}),m.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2",children:[m.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["Checked ",n]}),m.jsxs("div",{className:"flex items-center gap-1.5",children:[i&&m.jsxs(Wd,{children:[m.jsx(ef,{asChild:!0,children:m.jsxs(Gn,{type:"button",size:"sm",variant:"ghost",disabled:N||C,className:"h-7 rounded-lg px-2 text-[11px] text-muted-foreground hover:text-destructive hover:bg-destructive/10",children:[m.jsx(DE,{className:ve("mr-1 h-3.5 w-3.5",C&&"animate-pulse")}),C?"Stopping":"Stop"]})}),m.jsxs(ks,{className:"max-w-[22rem] rounded-xl gap-2 p-4",children:[m.jsxs(zs,{className:"space-y-1",children:[m.jsx(Us,{className:"text-sm",children:"Stop runtime?"}),m.jsx(Bs,{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."})]}),m.jsxs(Ls,{className:"gap-1 pt-0 sm:space-x-1",children:[m.jsx(Vs,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),m.jsx(Hs,{className:"h-7 rounded-lg px-2 text-[11px] bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>void G(),children:"Stop runtime"})]})]})]}),m.jsxs(Wd,{children:[m.jsx(ef,{asChild:!0,children:m.jsxs(Gn,{type:"button",size:"sm",variant:v.updateAvailable?"default":"outline",disabled:!u||N||C,className:"h-7 rounded-lg px-2 text-[11px]",children:[m.jsx(LE,{className:ve("mr-1 h-3.5 w-3.5",N&&"animate-spin")}),N?"Restarting…":x]})}),m.jsxs(ks,{className:"max-w-[28rem] gap-3 rounded-xl p-4",children:[m.jsxs(zs,{className:"space-y-1",children:[m.jsxs(Us,{className:"text-sm",children:[x,"?"]}),m.jsxs(Bs,{className:"text-[11px] leading-4",children:["Starts a detached restart helper, shuts down ",i?"the current node":d,", and brings it back with the configured launcher. The new process will not stay attached to the original terminal window."]})]}),m.jsx(HA,{value:E,onChange:R}),m.jsxs(Ls,{className:"gap-1 pt-0 sm:space-x-1",children:[m.jsx(Vs,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),m.jsx(Hs,{className:"h-7 rounded-lg px-2 text-[11px]",onClick:()=>void q(),children:x})]})]})]})]})]}),m.jsxs("div",{className:"border-t border-border/50",children:[m.jsxs("button",{type:"button",onClick:()=>k(ne=>!ne),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:[m.jsxs("span",{className:"flex items-center gap-1.5",children:[m.jsx(v0,{className:"h-3 w-3"}),"Restart details"]}),m.jsx(Gs,{className:ve("h-3 w-3 transition-transform duration-150",j&&"rotate-180")})]}),j&&m.jsxs("div",{className:"border-t border-border/50 bg-muted/20 px-3 py-2 space-y-1",children:[m.jsx(Tl,{label:"Current PID",value:f===void 0?"—":String(f),mono:f!==void 0}),m.jsx(Tl,{label:"Restart PID",value:(p==null?void 0:p.pid)===void 0?"Pending":String(p.pid),mono:(p==null?void 0:p.pid)!==void 0}),m.jsx(Tl,{label:"Operation",value:p!=null&&p.operationId?Ud(p.operationId):"Local direct request",mono:!!(p!=null&&p.operationId)}),m.jsx(Tl,{label:"Status",value:(p==null?void 0:p.status)??(N?"requested":"idle")}),m.jsx(Tl,{label:"Launcher",value:(p==null?void 0:p.command)??"Available after restart",mono:!!(p!=null&&p.command)}),m.jsx(Tl,{label:"Log",value:(p==null?void 0:p.logPath)??"Available after restart",mono:!!(p!=null&&p.logPath)}),m.jsx(Tl,{label:"Terminal",value:"New process is detached from original terminal"})]})]}),v.detail&&m.jsx("div",{className:"border-t border-border/50 px-3 py-1.5 text-[10px] text-muted-foreground bg-muted/20",children:v.detail})]})}function HA({onChange:n,value:r}){const o=(i,u)=>{n({...r,[i]:u})};return m.jsxs("div",{className:"rounded-lg border border-border/70 bg-muted/30 p-3 space-y-3",children:[m.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Startup arguments"}),m.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[m.jsx(Do,{label:"HTTP port",value:r.port,onChange:i=>o("port",i),inputMode:"numeric"}),m.jsx(Do,{label:"Node name",value:r.name,onChange:i=>o("name",i)}),m.jsx(Do,{label:"Join endpoint",value:r.join,onChange:i=>o("join",i),className:"sm:col-span-2"}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("label",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:"Transport"}),m.jsxs(jb,{value:r.transport,onValueChange:i=>o("transport",Ox(i)),children:[m.jsx(Lf,{className:"h-7 rounded-md border-border/70 bg-background/70 px-2 text-[10px]",children:m.jsx(Ob,{placeholder:"Transport"})}),m.jsxs(Uf,{children:[m.jsx(Nr,{className:"py-1 text-[11px]",value:"inherit",children:"current / default"}),m.jsx(Nr,{className:"py-1 text-[11px]",value:"direct",children:"direct"}),m.jsx(Nr,{className:"py-1 text-[11px]",value:"devtunnel",children:"devtunnel"}),m.jsx(Nr,{className:"py-1 text-[11px]",value:"tailscale",children:"tailscale"})]})]})]}),m.jsx(Do,{label:"Working directory",value:r.workDir,onChange:i=>o("workDir",i)}),m.jsx(Do,{label:"Config path",value:r.config,onChange:i=>o("config",i),className:"sm:col-span-2"}),m.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:[m.jsx(Rx,{className:"h-3.5 w-3.5",checked:r.disableAuth,onCheckedChange:i=>n({...r,disableAuth:i===!0,disableAuthKnown:!0})}),"Disable auth"]})]})]})}function Do({className:n,inputMode:r,label:o,onChange:i,value:u}){return m.jsxs("label",{className:ve("space-y-1",n),children:[m.jsx("span",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:o}),m.jsx(Ax,{className:"h-7 rounded-md px-2 text-[10px]",inputMode:r,value:u,onChange:d=>i(d.target.value)})]})}function Tl({label:n,value:r,mono:o=!1}){return m.jsxs("div",{className:"flex items-start justify-between gap-3 text-[10px]",children:[m.jsx("span",{className:"shrink-0 uppercase tracking-[0.14em] text-muted-foreground",children:n}),m.jsx("span",{className:ve("break-all text-right text-foreground",o&&"font-mono"),children:r})]})}function VA(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 zv(n){return{port:YA(n.endpoint),name:n.nodeName,join:"",transport:Ox(n.transportType),workDir:n.workDir??"",config:"",disableAuth:n.disableAuthDefault===!0,disableAuthKnown:n.disableAuthDefault!==void 0}}function qA(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 Ox(n){return n==="direct"||n==="devtunnel"||n==="tailscale"?n:"inherit"}function YA(n){if(!n)return"";try{return new URL(n).port||""}catch{return""}}function Ud(n){return n.length<=8?n:n.slice(0,8)}function gs({formatDateTime:n,name:r,status:o,statusVariant:i}){return m.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:[m.jsxs("div",{children:[m.jsx("div",{className:"text-[11px] font-medium text-foreground",children:r}),m.jsx("div",{className:"text-[10px] text-muted-foreground",children:n(o==null?void 0:o.checkedAt)})]}),m.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof(o==null?void 0:o.authenticated)=="boolean"&&m.jsx(bt,{variant:o.authenticated?"default":"outline",className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o.authenticated?"auth ok":"auth required"}),m.jsx(bt,{variant:i(o==null?void 0:o.status),className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:(o==null?void 0:o.status)??"unknown"})]})]})}function pn(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 $A(n){const r=Math.max(0,Math.floor(n)),o=Math.floor(r/86400),i=Math.floor(r%86400/3600),u=Math.floor(r%3600/60);return o>0?`${o}d ${i}h`:i>0?`${i}h ${u}m`:`${u}m`}function Lv(n){if(n==null||Number.isNaN(n))return"Unavailable";const r=["B","KB","MB","GB","TB"];let o=n,i=0;for(;o>=1024&&i<r.length-1;)o/=1024,i+=1;return`${o.toFixed(o>=10||i===0?0:1)} ${r[i]}`}function Lo(n){return n==="ok"?"default":n==="missing"||n==="install-failed"||n==="login-failed"?"destructive":n==="not-authenticated"||n==="unsupported-platform"?"outline":"secondary"}function GA(n){return n.available?m.jsxs(bt,{className:"gap-1 rounded-full px-2 py-0.5 text-[10px]",children:[m.jsx(ko,{className:"h-3 w-3"}),"Available"]}):m.jsxs(bt,{variant:"destructive",className:"gap-1 rounded-full px-2 py-0.5 text-[10px]",children:[m.jsx(vE,{className:"h-3 w-3"}),"Unavailable"]})}function XA(n){return n.update?n.update.updateAvailable?m.jsxs(bt,{variant:"outline",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.14em]",children:["Update ",n.update.latestVersion]}):m.jsx(bt,{variant:"secondary",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.14em]",children:"Up to date"}):null}function QA(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 KA(n){if(n.error)return n.error;const r=n.result;return(r==null?void 0:r.detail)??null}function Le({label:n,value:r,mono:o=!1}){return m.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:[m.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:n}),m.jsx("span",{className:ve("break-all text-right text-[11px] text-foreground",o&&"font-mono text-[11px]"),children:r})]})}function ZA({agent:n,nodeName:r,activeOperation:o,onUpgrade:i}){var h,v;const u=((h=n.update)==null?void 0:h.updateAvailable)===!0,d=XA(n),f=!!o;return m.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/70 p-2.5 shadow-sm",children:[m.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[m.jsx(f0,{className:"h-3.5 w-3.5 text-primary"}),n.label]}),m.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:["Command: ",m.jsx("span",{className:"font-mono text-[10px]",children:n.command})]})]}),m.jsxs("div",{className:"flex flex-col items-end gap-1",children:[GA(n),o?m.jsxs(bt,{variant:"outline",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.14em]",children:["Upgrade ",o.status]}):u?m.jsxs(Wd,{children:[m.jsx(ef,{asChild:!0,children:m.jsx("button",{type:"button",disabled:f,className:"rounded-full transition duration-150 hover:-translate-y-0.5 hover:scale-[1.03] hover:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 focus-visible:ring-offset-2 active:translate-y-0 active:scale-95 disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:translate-y-0 disabled:hover:scale-100 disabled:hover:shadow-none",children:d})}),m.jsxs(ks,{children:[m.jsxs(zs,{children:[m.jsxs(Us,{children:["Upgrade ",n.label,"?"]}),m.jsxs(Bs,{children:["This runs ",QA(n)," on ",r,". Remote nodes execute the command on the remote machine."]})]}),m.jsxs(Ls,{children:[m.jsx(Vs,{children:"Cancel"}),m.jsx(Hs,{onClick:()=>i(n),children:"Upgrade"})]})]})]}):d]})]}),m.jsxs("div",{className:"mt-2 space-y-1 text-[11px]",children:[m.jsx(Le,{label:"Version",value:n.version??"Unavailable",mono:!!n.version}),n.update&&m.jsx(Le,{label:"Latest",value:n.update.latestVersion??"Unavailable",mono:!!n.update.latestVersion}),m.jsx(Le,{label:"Path",value:n.path??"Not on PATH",mono:!!n.path}),m.jsx(Le,{label:"Checked",value:pn(n.checkedAt)}),n.update&&m.jsx(Le,{label:"Update check",value:pn(n.update.checkedAt)})]}),((v=n.update)==null?void 0:v.detail)&&m.jsx("div",{className:"mt-1.5 rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[10px] text-muted-foreground",children:n.update.detail}),n.metadataStatus&&m.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[m.jsx(bt,{variant:Lo(n.metadataStatus),className:"rounded-full px-2 py-0 text-[10px] uppercase tracking-[0.14em]",children:n.metadataStatus}),m.jsx("span",{children:"Startup preflight"})]}),n.detail&&m.jsx("div",{className:"mt-1.5 rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[10px] text-muted-foreground",children:n.detail})]})}function PA(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 IA(n,r){var o;return(o=n==null?void 0:n.nodes)!=null&&o.length?n.nodes:r?[r]:[]}function FA(n,r){var i;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:((i=o==null?void 0:o.runtime)==null?void 0:i.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 JA(n,r){return n.id===r?`${n.name} (this node)`:`${n.name} (${n.role})`}function WA(n){return n==="claude"?"Claude Code":"Codex"}function e3(n){var o;const r=(o=n.payload)==null?void 0:o.agent;return r==="claude"||r==="codex"?r:null}function t3({cluster:n,systemInfo:r,sseConnected:o,onRefresh:i}){var H,V,ne,de,ye,oe,se,le,ce,O,$,I,ie,F,_,X,K,J,W,ae,ee,re,ue,Te,we,Se,Fe;const u=y.useMemo(()=>IA(n,r),[n,r]),[d,f]=y.useState(()=>{var fe;return(r==null?void 0:r.nodeId)??((fe=n==null?void 0:n.self)==null?void 0:fe.id)??""}),[h,v]=y.useState(()=>new Map),g=y.useRef(new Set),x=y.useRef(new Set),p=(n==null?void 0:n.self)??r??u[0]??null,S=u.find(fe=>fe.id===d)??p,E=S?FA(S,r):null,R=!!(r&&S&&S.id===r.nodeId),N=R||!!(S!=null&&S.settingsSnapshot),T=y.useMemo(()=>PA(E==null?void 0:E.packages),[E==null?void 0:E.packages]),C=E==null?void 0:E.runtimeUpdate,M=((H=E==null?void 0:E.startupRequirements)==null?void 0:H.components)??(E==null?void 0:E.components)??{},j=y.useMemo(()=>u.map(fe=>fe.id),[u]),k=j.join("\0"),q=y.useCallback(async(fe,Ge)=>{const Ze=_x(fe);if(!Ze||g.current.has(fe.id))return;const ft=e3(fe),Lt=u.find(lt=>lt.id===fe.nodeId),Je=(Ge==null?void 0:Ge.agentLabel)??(ft?WA(ft):"Agent"),Rn=(Ge==null?void 0:Ge.nodeName)??(Lt==null?void 0:Lt.name)??fe.nodeId;g.current.add(fe.id),v(lt=>new Map(lt).set(Ze,fe));try{const lt=await jx(fe);if(lt.status==="succeeded")await(i==null?void 0:i()),x.current.has(lt.id)||(Et.success(`${Je} upgrade finished on ${Rn}`),x.current.add(lt.id));else if(lt.status==="failed")x.current.has(lt.id)||(Et.error(KA(lt)??`${Je} upgrade failed`),x.current.add(lt.id));else{v(st=>new Map(st).set(Ze,lt)),Et.info(`${Je} upgrade is still ${lt.status} on ${Rn}`);return}v(st=>{const _t=new Map(st),ct=_t.get(Ze);return(!ct||ct.id===lt.id)&&_t.delete(Ze),_t})}catch(lt){v(st=>{const _t=new Map(st),ct=_t.get(Ze);return(!ct||ct.id===fe.id)&&_t.delete(Ze),_t}),Et.error(lt instanceof Error?lt.message:`${Je} upgrade failed`)}finally{g.current.delete(fe.id)}},[i,u]);y.useEffect(()=>{if(j.length===0)return;let fe=!1;async function Ge(){let Ze;try{Ze=await zA(j)}catch{return}if(!fe){v(ft=>{const Lt=new Map(ft);for(const[Je,Rn]of Ze)Lt.set(Je,Rn);return Lt});for(const ft of Ze.values())q(ft)}}return Ge(),()=>{fe=!0}},[q,k]);async function G(fe){if(S)try{const Ge=await Yw(S.id,fe.id);Et.info(`${fe.label} upgrade started on ${S.name}`),await q(Ge,{agentLabel:fe.label,nodeName:S.name})}catch(Ge){Et.error(Ge instanceof Error?Ge.message:`${fe.label} upgrade failed`)}}return!S||!E?m.jsx("div",{className:"rounded-2xl border border-dashed border-border/70 bg-muted/20 px-4 py-8 text-center text-[12px] text-muted-foreground",children:"Loading session metadata..."}):m.jsxs("div",{className:"space-y-4",children:[m.jsx("section",{className:"rounded-2xl border border-border/70 bg-[radial-gradient(circle_at_top_left,rgba(59,130,246,0.18),transparent_42%),radial-gradient(circle_at_bottom_right,rgba(16,185,129,0.12),transparent_32%),rgba(255,255,255,0.72)] p-3 shadow-[0_24px_90px_-54px_rgba(15,23,42,0.55)] dark:bg-[radial-gradient(circle_at_top_left,rgba(59,130,246,0.18),transparent_42%),radial-gradient(circle_at_bottom_right,rgba(16,185,129,0.12),transparent_32%),rgba(10,15,23,0.78)]",children:m.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-end md:justify-between",children:[m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[m.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-border/70 bg-background/75 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur",children:[m.jsx(L0,{status:S.status}),m.jsx("span",{className:"font-medium text-foreground",children:S.name})]}),m.jsx(qN,{role:S.role}),m.jsx(bt,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:S.transportType??E.transportType??"direct"}),m.jsx(bt,{variant:R?"default":"outline",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:R?"Live local session":"Leader-synced snapshot"})]}),m.jsxs("div",{children:[m.jsx("div",{className:"text-[10px] uppercase tracking-[0.34em] text-muted-foreground",children:"Session"}),m.jsx("h3",{className:"mt-0.5 text-sm font-semibold tracking-tight text-foreground",children:"Node runtime"}),m.jsx("p",{className:"mt-1 max-w-2xl text-[11px] text-muted-foreground",children:"Inspect the selected node's runtime environment, connectivity surface, and packaged build metadata from one place."})]}),u.length>1&&m.jsxs("div",{className:"max-w-md space-y-1.5",children:[m.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:"Inspect node"}),m.jsxs(jb,{value:S.id,onValueChange:f,children:[m.jsx(Lf,{className:"h-7 rounded-lg border-border/70 bg-background/70 text-[11px]",children:m.jsx(Ob,{placeholder:"Choose a node"})}),m.jsx(Uf,{children:u.map(fe=>m.jsx(Nr,{value:fe.id,children:JA(fe,r==null?void 0:r.nodeId)},fe.id))})]})]})]}),m.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[m.jsxs(bt,{variant:o?"default":"outline",className:"gap-1 rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:[m.jsx(p0,{className:"h-3 w-3"}),o?"Live link connected":"Live link reconnecting"]}),m.jsxs(bt,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Uptime ",$A(E.uptime)]}),!R&&m.jsxs(bt,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Updated ",pn((V=S.settingsSnapshot)==null?void 0:V.collectedAt)]})]})]})}),!N&&m.jsx("div",{className:"rounded-xl 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."}),m.jsxs(pA,{defaultValue:"session",className:"space-y-2",children:[m.jsxs(Wb,{className:"h-auto flex-wrap rounded-xl border border-border/60 bg-muted/40 p-0.5",children:[m.jsx(ws,{value:"session",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Session"}),m.jsx(ws,{value:"access",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Access"}),m.jsx(ws,{value:"about",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"About"})]}),m.jsxs(Es,{value:"session",className:"mt-0 grid gap-2 xl:grid-cols-[1.15fr_0.85fr]",children:[m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(BE,{className:"h-3.5 w-3.5 text-primary"}),"Selected node"]}),m.jsx(Bn,{className:"text-[10px]",children:"Cluster role, identity, and node-scoped runtime state."})]}),m.jsxs(Hn,{className:"space-y-0 px-3 pb-2.5",children:[m.jsx(Le,{label:"Node ID",value:E.nodeId,mono:!0}),m.jsx(Le,{label:"Status",value:S.status}),m.jsx(Le,{label:"Role",value:S.role}),m.jsx(Le,{label:"Endpoint",value:S.endpoint,mono:!0}),m.jsx(Le,{label:"Joined",value:pn(S.joinedAt)}),m.jsx(Le,{label:"Heartbeat",value:pn(S.lastHeartbeat)}),m.jsx(Le,{label:"Capabilities",value:S.capabilities.length>0?S.capabilities.join(", "):"None"})]})]}),m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(SE,{className:"h-3.5 w-3.5 text-primary"}),"OS info"]}),m.jsx(Bn,{className:"text-[10px]",children:"Host and resource details reported by the current process."})]}),m.jsxs(Hn,{className:"space-y-0 px-3 pb-2.5",children:[m.jsx(Le,{label:"Host",value:((ne=E.os)==null?void 0:ne.hostname)??"Unavailable"}),m.jsx(Le,{label:"Platform",value:E.os?`${E.os.platform} ${E.os.release}`:"Unavailable"}),m.jsx(Le,{label:"Arch",value:((de=E.os)==null?void 0:de.arch)??"Unavailable"}),m.jsx(Le,{label:"CPU",value:((ye=E.os)==null?void 0:ye.cpuModel)??"Unavailable"}),m.jsx(Le,{label:"Cores",value:String(((oe=E.os)==null?void 0:oe.cpuCount)??"Unavailable")}),m.jsx(Le,{label:"Memory",value:E.os?`${Lv(E.os.freeMemoryBytes)} free / ${Lv(E.os.totalMemoryBytes)} total`:"Unavailable"})]})]}),m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)] xl:col-span-2",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(f0,{className:"h-3.5 w-3.5 text-primary"}),"Available agents"]}),m.jsx(Bn,{className:"text-[10px]",children:R?"Live command availability for Codex and Claude Code on this node.":"Most recent agent availability snapshot synced from this node."})]}),m.jsx(Hn,{className:"grid gap-2 px-3 pb-2.5 md:grid-cols-2",children:(E.agents??[]).map(fe=>m.jsx(ZA,{agent:fe,nodeName:S.name,activeOperation:h.get(`${S.id}:${fe.id}`),onUpgrade:G},fe.id))})]})]}),m.jsxs(Es,{value:"access",className:"mt-0 grid gap-2 xl:grid-cols-2",children:[m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(oE,{className:"h-3.5 w-3.5 text-primary"}),"Access surface"]}),m.jsx(Bn,{className:"text-[10px]",children:"How this node is exposed to the dashboard and other peers."})]}),m.jsxs(Hn,{className:"space-y-0 px-3 pb-2.5",children:[m.jsx(Le,{label:"Transport",value:S.transportType??E.transportType??"direct"}),m.jsx(Le,{label:"Node URL",value:S.endpoint,mono:!0}),m.jsx(Le,{label:"Node tunnel",value:S.devtunnelEndpoint??"Disabled",mono:!!S.devtunnelEndpoint}),m.jsx(Le,{label:"Dashboard URL",value:S.dashboardOrigin??E.localDashboardOrigin??"Unavailable",mono:!!(S.dashboardOrigin||E.localDashboardOrigin)}),m.jsx(Le,{label:"Local dashboard",value:E.localDashboardOrigin??"Unavailable",mono:!!E.localDashboardOrigin})]})]}),m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(YE,{className:"h-3.5 w-3.5 text-primary"}),"Auth"]}),m.jsx(Bn,{className:"text-[10px]",children:"Current bearer-auth and trusted access posture."})]}),m.jsxs(Hn,{className:"space-y-0 px-3 pb-2.5",children:[m.jsx(Le,{label:"Enabled",value:(se=E.auth)!=null&&se.enabled?"Yes":"No"}),m.jsx(Le,{label:"Same tenant",value:(le=E.auth)!=null&&le.allowSameTenant?"Allowed":"Off"}),m.jsx(Le,{label:"Allowed users",value:(ce=E.auth)!=null&&ce.allowedUsers.length?E.auth.allowedUsers.join(", "):"None"})]})]}),m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(CE,{className:"h-3.5 w-3.5 text-primary"}),"Paths"]}),m.jsx(Bn,{className:"text-[10px]",children:"Workspace and runtime paths currently used by this node."})]}),m.jsxs(Hn,{className:"space-y-0 px-3 pb-2.5",children:[m.jsx(Le,{label:"Work dir",value:((O=E.runtime)==null?void 0:O.workDir)??E.workDir??"Unavailable",mono:!!((($=E.runtime)==null?void 0:$.workDir)??E.workDir)}),m.jsx(Le,{label:"Storage",value:((I=E.runtime)==null?void 0:I.storagePath)??"Unavailable",mono:!!((ie=E.runtime)!=null&&ie.storagePath)}),m.jsx(Le,{label:"Process cwd",value:((F=E.runtime)==null?void 0:F.cwd)??"Unavailable",mono:!!((_=E.runtime)!=null&&_.cwd)}),m.jsx(Le,{label:"Started",value:pn((X=E.runtime)==null?void 0:X.startedAt)}),m.jsx(Le,{label:"PID",value:E.runtime?String(E.runtime.pid):"Unavailable",mono:!!E.runtime})]})]}),m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(Cs,{className:"h-3.5 w-3.5 text-primary"}),"Startup checks"]}),m.jsx(Bn,{className:"text-[10px]",children:"Dependency preflight snapshot persisted during node startup."})]}),m.jsxs(Hn,{className:"space-y-3 px-3 pb-2.5",children:[m.jsxs("div",{className:"rounded-xl border border-border/60 bg-background/70 px-3 py-2",children:[m.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:"Last checked"}),m.jsx("div",{className:"mt-0.5 text-[11px] text-foreground",children:pn((K=E.startupRequirements)==null?void 0:K.lastCheckedAt)})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(gs,{formatDateTime:pn,name:"Azure CLI",status:M.az,statusVariant:Lo}),m.jsx(gs,{formatDateTime:pn,name:"DevTunnel",status:M.devtunnel,statusVariant:Lo}),m.jsx(gs,{formatDateTime:pn,name:"Claude Code",status:M.claude,statusVariant:Lo}),m.jsx(gs,{formatDateTime:pn,name:"Codex",status:M.codex,statusVariant:Lo})]})]})]})]}),m.jsxs(Es,{value:"about",className:"mt-0 grid gap-2 xl:grid-cols-[0.92fr_1.08fr]",children:[m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(aE,{className:"h-3.5 w-3.5 text-primary"}),"Repository"]}),m.jsx(Bn,{className:"text-[10px]",children:"Source-of-truth repository metadata for this running node."})]}),m.jsxs(Hn,{className:"space-y-3 px-3 pb-2.5",children:[(J=E.repository)!=null&&J.url?m.jsxs("a",{href:E.repository.url,target:"_blank",rel:"noreferrer",className:"group flex items-center justify-between rounded-lg 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:[m.jsx("span",{className:"font-mono text-[10px]",children:E.repository.url}),m.jsx(EE,{className:"h-3.5 w-3.5 text-muted-foreground transition-transform group-hover:-translate-y-0.5 group-hover:translate-x-0.5"})]}):m.jsx("div",{className:"rounded-lg 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."}),m.jsxs("div",{className:"space-y-0",children:[m.jsx(Le,{label:"Branch",value:((W=E.repository)==null?void 0:W.branch)??"Unavailable",mono:!!((ae=E.repository)!=null&&ae.branch)}),m.jsx(Le,{label:"Commit",value:((ee=E.repository)==null?void 0:ee.commit)??"Unavailable",mono:!!((re=E.repository)!=null&&re.commit)}),m.jsx(Le,{label:"Runtime",value:`${E.packageName??"meshy"} ${E.version}`,mono:!0}),m.jsx(Le,{label:"Node.js",value:((ue=E.runtime)==null?void 0:ue.nodeVersion)??"Unavailable",mono:!!((Te=E.runtime)!=null&&Te.nodeVersion)})]})]})]}),m.jsxs("div",{className:"space-y-2",children:[C&&m.jsx(BA,{checkedLabel:pn(C.checkedAt),disableAuthDefault:((we=E.auth)==null?void 0:we.enabled)===void 0?void 0:E.auth.enabled===!1,endpoint:S.endpoint,isLiveLocalNode:R,nodeId:S.id,nodeName:S.name,pid:(Se=E.runtime)==null?void 0:Se.pid,transportType:S.transportType,update:C,workDir:((Fe=E.runtime)==null?void 0:Fe.workDir)??S.workDir}),m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(RE,{className:"h-3.5 w-3.5 text-primary"}),"Package versions"]}),m.jsx(Bn,{className:"text-[10px]",children:"Version snapshot for the packages most relevant to this dashboard session."})]}),m.jsx(Hn,{className:"space-y-1.5 px-3 pb-2.5",children:T.map(fe=>{var Ge,Ze;return m.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-border/60 bg-background/70 px-2.5 py-1.5",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-[11px] font-medium text-foreground",children:fe.label}),m.jsx("div",{className:"text-[10px] text-muted-foreground",children:(Ge=fe.value)==null?void 0:Ge.name})]}),m.jsx(bt,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60 font-mono text-[10px]",children:(Ze=fe.value)==null?void 0:Ze.version})]},fe.key)})})]})]})]})]})]})}function n3(){const{cluster:n,systemInfo:r,sseConnected:o,refresh:i}=u0(),[u,d]=y.useState(!1);return m.jsxs(t5,{open:u,onOpenChange:d,children:[m.jsx(n5,{asChild:!0,children:m.jsx(Gn,{variant:"ghost",size:"icon","aria-label":"Settings",title:"Settings",className:"rounded-[16px] border border-border/70 bg-background/70 shadow-sm",children:m.jsx(VE,{className:"h-4 w-4"})})}),m.jsxs(by,{className:"grid h-[min(82vh,42rem)] max-h-[82vh] max-w-[min(90vw,56rem)] grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[22px] border-border/70 bg-background/96 p-0 shadow-[0_40px_120px_-56px_rgba(15,23,42,0.75)] backdrop-blur-xl",children:[m.jsxs(xy,{className:"shrink-0 border-b border-border/60 px-3 py-2 sm:px-4",children:[m.jsxs(Sy,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(_E,{className:"h-3.5 w-3.5 text-primary"}),"Settings"]}),m.jsx(wy,{className:"text-[11px]",children:"Session diagnostics, access configuration, and build metadata for the current Meshy node."})]}),m.jsx("div",{className:"min-h-0 overflow-y-auto px-3 py-2.5 sm:px-4 sm:py-3",children:m.jsx(t3,{cluster:n,systemInfo:r,sseConnected:o,onRefresh:i})})]})]})}const E_="bypass",a3=[{value:"claudecode",label:"claudecode",supportsFollowUp:!0},{value:"codex",label:"codex",supportsFollowUp:!0},{value:"mars",label:"mars",disabled:!0,description:"coming soon"},{value:"eureka",label:"eureka",disabled:!0,description:"coming soon"}],N_=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],C_=new Set(a3.filter(n=>n.supportsFollowUp).map(n=>n.value)),T_=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"shared",label:"Shared"},{value:"archived",label:"Archived"}],R_=[{value:"all",label:"All task types"},{value:"native",label:"Native sessions"},{value:"meshy",label:"Meshy chats"}],l3=new Set(["pending","assigned"]),r3=new Set(["running"]),o3=new Set(["completed","failed","cancelled"]);function A_(n,r){switch(r){case"running":return r3.has(n.status);case"waiting":return l3.has(n.status);case"closed":return o3.has(n.status);case"shared":return!!n.activeShare;case"archived":return n.status==="archived";case"active":default:return n.status!=="archived"}}function __(n,r){if(r==="all")return!0;const o=n.conversationKind==="nativeSession";return r==="native"?o:!o}function j_(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(i=>i.toLowerCase().includes(o)):!0}function i3(n,r,o){if(!n)return"unassigned";const i=r==null?void 0:r.find(u=>u.id===n);return(i==null?void 0:i.name)??o??n.slice(0,8)}function O_(n,r,o){return i3(n,r,o).toLowerCase()}function M_(n,r,o){return!n.assignedTo||(o==null?void 0:o.id)===n.assignedTo?!0:(r==null?void 0:r.some(i=>i.id===n.assignedTo))??!1}function D_(n,r){return[...n].sort((o,i)=>o.id===r?-1:i.id===r?1:o.name.localeCompare(i.name))}function k_(n){if(!n||typeof n!="object")return null;const r=n,o=r.createMode,i=o==="chat"||o==="native"?o: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:i}}function z_(n){switch(n){case"running":return"bg-amber-500";case"completed":return"bg-emerald-500";case"failed":return"bg-destructive";case"cancelled":case"archived":return"bg-slate-400";case"assigned":return"bg-teal-500";case"pending":default:return"bg-muted-foreground"}}function L_(n){return n==="default workspace"?n:n.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??n}function U_(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 B_(n){return new Date(n).toLocaleString()}function H_(n){const r=Math.floor(n/1e3),o=Math.floor(r/3600),i=Math.floor(r%3600/60),u=r%60;return`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}:${String(u).padStart(2,"0")}`}async function s3(n,r="Copied to clipboard"){var o,i,u;try{if((i=(o=globalThis.navigator)==null?void 0:o.clipboard)!=null&&i.writeText)return await globalThis.navigator.clipboard.writeText(n),Et.success(r),!0;const d=globalThis.document,f=(u=d==null?void 0:d.execCommand)==null?void 0:u.bind(d);if(!(d!=null&&d.body)||typeof d.createElement!="function"||typeof f!="function")throw new Error("Clipboard access is unavailable");const h=d.createElement("textarea"),v=d.activeElement,g=v&&typeof v.focus=="function"?v:null;h.value=n,h.setAttribute("readonly","true"),h.style.position="fixed",h.style.opacity="0",h.style.pointerEvents="none",d.body.appendChild(h),h.select(),h.setSelectionRange(0,h.value.length);const x=f("copy");if(d.body.removeChild(h),g==null||g.focus(),!x)throw new Error("Clipboard access is unavailable");return Et.success(r),!0}catch(d){return Et.error(d instanceof Error?d.message:"Failed to copy"),!1}}function V_(n,r,o){const i=new Map;for(const d of n){const f=d.assignedTo??null,h=f??"__unassigned__",v=f?r.get(f)??d.assignedNodeName??f.slice(0,8):"Unassigned",g=d.effectiveProjectPath??d.project??"default workspace";i.has(h)||i.set(h,{nodeId:f,nodeName:v,dirMap:new Map});const x=i.get(h);x.dirMap.has(g)||x.dirMap.set(g,[]),x.dirMap.get(g).push(d)}const u=Array.from(i.values()).map(({nodeId:d,nodeName:f,dirMap:h})=>{const v=Array.from(h.entries()).map(([g,x])=>({path:g,tasks:x})).sort((g,x)=>x.tasks.length-g.tasks.length||g.path.localeCompare(x.path));return{nodeId:d,nodeName:f,dirs:v}});return u.sort((d,f)=>{if(o){if(d.nodeId===o)return-1;if(f.nodeId===o)return 1}return d.nodeId===null?1:f.nodeId===null?-1:d.nodeName.localeCompare(f.nodeName)}),u}const c3={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"};function u3(n){return n.split(".")[0]??"unknown"}function d3(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function Er(n,r){return(r==null?void 0:r.get(n))??n}function Mx(n,r){const o=n.data,i=o.operation;switch(n.type){case"node.joined":return`${o.name} joined the cluster`;case"node.left":return`${Er(o.nodeId,r)} left (${o.reason})`;case"node.status":return`${Er(o.nodeId,r)} is now ${o.status}`;case"node.operation.created":return`${i==null?void 0:i.kind} ${i==null?void 0:i.status} on ${Er(i==null?void 0:i.nodeId,r)}`;case"node.operation.updated":return`${i==null?void 0:i.kind} ${i==null?void 0:i.status} on ${Er(i==null?void 0:i.nodeId,r)}`;case"transport.changed":return`${Er(o.nodeId,r)} transport switched to ${o.transportType}`;case"task.created":return`"${o.title}" created`;case"task.assigned":return`task assigned to ${Er(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 f3(n){return JSON.stringify(n,null,2)}function m3({events:n,maxHeight:r="400px",nodeNameById:o,onDismiss:i}){return n.length===0?null:m.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:r},children:m.jsx("div",{className:"space-y-1.5",children:n.map(u=>{const d=u3(u.type);return m.jsx("div",{className:"rounded-lg px-1.5 py-1 transition-colors hover:bg-muted/30",children:m.jsxs("div",{className:"space-y-1",children:[m.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[m.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[m.jsx("div",{className:"font-mono text-[9px] text-muted-foreground",children:d3(u.timestamp)}),m.jsx(bt,{variant:"outline",className:ve("w-fit text-[9px] font-medium uppercase tracking-[0.14em] px-1.5 py-0",c3[d]),children:u.type})]}),m.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[m.jsx(Gn,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 rounded-[8px] text-muted-foreground",onClick:()=>void s3(f3(u),"Event copied"),"aria-label":`Copy ${u.type} event`,title:"Copy event",children:m.jsx(bE,{className:"h-3 w-3"})}),i&&m.jsx(Gn,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 rounded-[8px] text-muted-foreground hover:text-foreground",onClick:()=>i(u.id),"aria-label":`Dismiss ${u.type} event`,title:"Dismiss event",children:m.jsx(y0,{className:"h-3 w-3"})})]})]}),m.jsx("div",{className:"text-[9px] leading-snug text-foreground/85",children:Mx(u,o)})]})},u.id)})})})}const h3=["node.","election.","transport."],p3="cluster.state";function g3(n){return n.type==="node.status"?!1:h3.some(r=>n.type.startsWith(r))}function v3(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function y3(n,r){return n?{time:v3(n.timestamp),text:Mx(n,r)}:null}function b3(n){return n.transportType==="devtunnel"||!!n.devtunnelEndpoint}function x3(n){if(n.length===0)return"No node tunnel";const r=n.filter(u=>u.status==="offline").length;if(r>0)return`${r} offline`;const o=n.filter(u=>{var d;return((d=u.devtunnelHealth)==null?void 0:d.status)==="failed"}).length;if(o>0)return`${o} failed`;const i=n.filter(u=>{var d;return u.status!=="offline"&&((d=u.devtunnelHealth)==null?void 0:d.status)!=="healthy"}).length;return i>0?`${i} checking`:"Healthy"}function S3(n,r){var u;const o=(r==null?void 0:r.get(n.id))??n.name??n.id;if(n.status==="offline")return{label:o,status:"offline"};const i=((u=n.devtunnelHealth)==null?void 0:u.status)??"checking";return{label:o,status:i}}function w3(n){if(n.length===0)return"No nodes";const r=n.filter(i=>i.status==="offline").length;if(r>0)return`${r} offline`;const o=n.filter(i=>i.status==="busy").length;return o>0?`${o} busy`:"Healthy"}function E3(n,r){return{label:(r==null?void 0:r.get(n.id))??n.name??n.id,status:n.status}}function N3({connected:n,events:r,nodes:o=[],nodeNameById:i,defaultOpen:u=!1}){const[d,f]=y.useState(u),[h,v]=y.useState(!0),[g,x]=y.useState(new Set),p=y.useRef(null),S=y.useMemo(()=>r.filter(k=>g3(k)&&!g.has(k.id)),[r,g]),E=y.useMemo(()=>r.find(k=>k.type===p3)??S[0],[r,S]),R=y.useMemo(()=>y3(E,i),[E,i]),N=y.useMemo(()=>o.filter(b3),[o]),T=N.some(k=>{var q;return k.status==="offline"||((q=k.devtunnelHealth)==null?void 0:q.status)==="failed"}),C=o.some(k=>k.status==="offline"),M=o.some(k=>k.status==="busy"),j=o.length>0;return y.useEffect(()=>{x(k=>{if(k.size===0)return k;const q=new Set(r.map(H=>H.id)),G=new Set(Array.from(k).filter(H=>q.has(H)));return G.size===k.size?k:G})},[r]),y.useEffect(()=>{if(!d)return;const k=G=>{var H;(H=p.current)!=null&&H.contains(G.target)||f(!1)},q=G=>{G.key==="Escape"&&f(!1)};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",q),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",q)}},[d]),m.jsxs("div",{ref:p,className:"relative",children:[m.jsxs("button",{type:"button","aria-expanded":d,"aria-haspopup":"dialog",onClick:()=>f(k=>!k),className:ve("flex items-center gap-1.5 rounded-[16px] border px-2 py-1.5 text-[11px] shadow-sm transition-all sm:gap-2 sm:px-3 sm:py-2 sm:text-xs",n?"border-emerald-500/25 bg-emerald-500/8 text-muted-foreground hover:border-emerald-500/40 hover:bg-emerald-500/12":"border-destructive/25 bg-destructive/8 text-muted-foreground hover:border-destructive/40 hover:bg-destructive/12",d&&"shadow-[0_14px_40px_-26px_rgba(16,185,129,0.95)]"),title:n?"Live link connected":"Live link reconnecting",children:[m.jsx(p0,{className:ve("h-3.5 w-3.5",n?"text-emerald-500":"text-destructive")}),n?"Live link":"Reconnecting"]}),d&&m.jsxs("div",{role:"dialog","aria-label":"Live link connection events",className:"absolute right-0 top-[calc(100%+0.4rem)] z-50 w-[18rem] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-[18px] 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:[m.jsx("div",{className:"border-b border-border/60 bg-muted/25 px-2.5 py-1.5",children:m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[n?m.jsx(Cs,{className:"h-3 w-3 text-emerald-500"}):m.jsx(ZE,{className:"h-3 w-3 text-destructive"}),m.jsx("span",{className:"text-[10px] font-semibold text-foreground",children:"Live link"}),m.jsx("span",{className:"text-[9px] text-muted-foreground",children:n?"· SSE connected":"· reconnecting"})]}),m.jsx("div",{className:ve("rounded-[9px] 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"})]})}),m.jsxs("div",{className:"grid grid-cols-2 border-b border-border/60",children:[m.jsxs("div",{className:"border-r border-border/60 px-2.5 py-1.5",children:[m.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Events"}),m.jsx("div",{className:"mt-0.5 text-base font-semibold tracking-tight text-foreground",children:S.length})]}),m.jsxs("div",{className:"min-w-0 px-2.5 py-1.5",children:[m.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Latest"}),R?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"mt-0.5 truncate text-[9px] leading-snug text-foreground/80",children:R.text}),m.jsx("div",{className:"font-mono text-[8px] text-muted-foreground/60",children:R.time})]}):m.jsx("div",{className:"mt-0.5 text-[8px] text-muted-foreground/50",children:"—"})]})]}),m.jsxs("div",{className:"border-b border-border/60 px-2.5 py-1.5",children:[m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[C?m.jsx(os,{className:"h-3 w-3 shrink-0 text-destructive"}):M?m.jsx(Cs,{className:"h-3 w-3 shrink-0 text-amber-500"}):m.jsx(ko,{className:ve("h-3 w-3 shrink-0",j?"text-emerald-500":"text-muted-foreground")}),m.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Node health"})]}),m.jsx("span",{className:ve("shrink-0 rounded-[8px] border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",C?"border-destructive/30 bg-destructive/10 text-destructive":M?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":j?"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:w3(o)})]}),o.length>0&&m.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:o.map(k=>{const{label:q,status:G}=E3(k,i),H=G==="offline",V=G==="busy";return m.jsxs("div",{"aria-label":`${q} ${G}`,className:ve("flex items-center justify-between gap-2 rounded-[7px] px-2 py-0.5",H?"bg-destructive/6":V?"bg-amber-500/6":"bg-emerald-500/5"),title:`${q} ${G}`,children:[m.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:q}),H?m.jsx(os,{className:"h-3 w-3 shrink-0 text-destructive"}):V?m.jsx(Jg,{className:"h-3 w-3 shrink-0 text-amber-500"}):m.jsx(ko,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},k.id)})})]}),N.length>0&&m.jsxs("div",{className:"border-b border-border/60 px-2.5 py-1.5",children:[m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[T?m.jsx(os,{className:"h-3 w-3 shrink-0 text-destructive"}):m.jsx(ko,{className:"h-3 w-3 shrink-0 text-emerald-500"}),m.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"DevTunnel"})]}),m.jsx("span",{className:ve("shrink-0 rounded-[8px] border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",T?"border-destructive/30 bg-destructive/10 text-destructive":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:x3(N)})]}),m.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:N.map(k=>{var de;const{label:q,status:G}=S3(k,i),H=G==="failed"||G==="offline",V=G!=="healthy"&&G!=="failed"&&G!=="offline",ne=(de=k.devtunnelHealth)!=null&&de.reason?`${q} ${G}: ${k.devtunnelHealth.reason}`:`${q} ${G}`;return m.jsxs("div",{"aria-label":`${q} ${G}`,className:ve("flex items-center justify-between gap-2 rounded-[7px] px-2 py-0.5",H?"bg-destructive/6":V?"bg-muted/30":"bg-emerald-500/5"),title:ne,children:[m.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:q}),H?m.jsx(os,{className:"h-3 w-3 shrink-0 text-destructive"}):V?m.jsx(Jg,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):m.jsx(ko,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},k.id)})})]}),m.jsxs("div",{children:[m.jsxs("button",{type:"button",onClick:()=>v(k=>!k),className:"flex w-full items-center justify-between px-2.5 py-1.5 text-left hover:bg-muted/30",children:[m.jsxs("span",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:["Notifications ",S.length>0&&`(${S.length})`]}),h?m.jsx(Gs,{className:"h-3 w-3 text-muted-foreground"}):m.jsx(uE,{className:"h-3 w-3 text-muted-foreground"})]}),h&&m.jsx("div",{className:"px-2 pb-2",children:m.jsx(m3,{events:S,maxHeight:"12rem",emptyTitle:"No connection events yet",emptyDescription:"Node, election, and system events will appear here.",nodeNameById:i,onDismiss:k=>x(q=>new Set(q).add(k))})})]}),m.jsxs("div",{className:"flex items-center justify-end gap-1 border-t border-border/60 px-2.5 py-1",children:[m.jsx(Gn,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-[9px] px-1.5 text-[9px]",onClick:()=>x(new Set(r.map(k=>k.id))),disabled:S.length===0,title:"Dismiss all notifications",children:"Dismiss all"}),m.jsx(Gn,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-[9px] px-1.5 text-[9px]",onClick:()=>f(!1),children:"Close"})]})]})]})}const Dx=y.createContext(null);function C3({children:n}){const[r,o]=y.useState(()=>typeof window<"u"?localStorage.getItem("meshy-theme")??"system":"system"),[i,u]=y.useState(()=>typeof window<"u"?localStorage.getItem("meshy-palette")??"default":"default");return y.useEffect(()=>{const d=document.documentElement,f=h=>{if(h==="system"){const v=window.matchMedia("(prefers-color-scheme: dark)").matches;d.classList.toggle("dark",v)}else d.classList.toggle("dark",h==="dark")};if(f(r),localStorage.setItem("meshy-theme",r),r==="system"){const h=window.matchMedia("(prefers-color-scheme: dark)"),v=()=>f("system");return h.addEventListener("change",v),()=>h.removeEventListener("change",v)}},[r]),y.useEffect(()=>{const d=document.documentElement;i==="default"?d.removeAttribute("data-palette"):d.setAttribute("data-palette",i),localStorage.setItem("meshy-palette",i)},[i]),m.jsx(Dx.Provider,{value:{theme:r,setTheme:o,palette:i,setPalette:u},children:n})}function T3(){const n=y.useContext(Dx);if(!n)throw new Error("useTheme must be used within ThemeProvider");return n}const R3=[{value:"light",label:"Light",icon:g0},{value:"dark",label:"Dark",icon:h0},{value:"system",label:"System",icon:m0}],A3=[{value:"default",label:"Default",hint:"Porcelain + blue"},{value:"warm",label:"Warm",hint:"Cream + amber"},{value:"finsight",label:"FinSight",hint:"Cool sage green"},{value:"inshield",label:"inShield",hint:"Pure white + navy"},{value:"edge",label:"Edge",hint:"Rounded violet panels"}];function _3(){const{theme:n,setTheme:r,palette:o,setPalette:i}=T3(),[u,d]=y.useState(!1),f=y.useRef(null),h=y.useRef(null),v=n==="dark"?h0:n==="light"?g0:m0,g=()=>{f.current&&(clearTimeout(f.current),f.current=null)},x=()=>{g(),f.current=setTimeout(()=>d(!1),180)};return y.useEffect(()=>{if(!u)return;const p=S=>{h.current&&!h.current.contains(S.target)&&d(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[u]),y.useEffect(()=>()=>g(),[]),m.jsxs("div",{ref:h,className:"relative",onMouseEnter:()=>{g(),d(!0)},onMouseLeave:x,children:[m.jsx(Gn,{variant:"ghost",size:"icon",onClick:()=>d(p=>!p),className:ve("rounded-[16px] border bg-background/70",o==="default"?"border-border/60":"border-primary/60 text-primary"),title:"Appearance","aria-haspopup":"menu","aria-expanded":u,children:m.jsx(v,{className:"h-4 w-4"})}),u&&m.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+8px)] z-50 w-64 rounded-[20px] border border-border/70 bg-popover/95 p-3 text-popover-foreground shadow-[0_24px_80px_-32px_rgba(0,0,0,0.35)] backdrop-blur-xl",children:[m.jsx("div",{className:"px-1 pb-1 text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Theme"}),m.jsx("div",{className:"mb-2 grid grid-cols-3 gap-1",children:R3.map(({value:p,label:S,icon:E})=>{const R=n===p;return m.jsxs("button",{type:"button",onClick:()=>r(p),className:ve("flex flex-col items-center gap-1 rounded-[14px] border px-2 py-2 text-[11px] font-medium transition-colors",R?"border-primary/50 bg-primary/10 text-primary":"border-border/60 text-muted-foreground hover:border-border hover:bg-muted/60 hover:text-foreground"),children:[m.jsx(E,{className:"h-4 w-4"}),S]},p)})}),m.jsxs("div",{className:"mt-2 flex items-center gap-1.5 px-1 pb-1 text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:[m.jsx(GE,{className:"h-3 w-3"}),"Palette"]}),m.jsx("div",{className:"space-y-1",children:A3.map(({value:p,label:S,hint:E})=>{const R=o===p;return m.jsxs("button",{type:"button",onClick:()=>i(p),className:ve("flex w-full items-center gap-2 rounded-[14px] border px-2.5 py-1.5 text-left transition-colors",R?"border-primary/50 bg-primary/10":"border-transparent hover:bg-muted/60"),children:[m.jsx(j3,{value:p}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:ve("text-[12px] font-medium",R?"text-primary":"text-foreground"),children:S}),m.jsx("div",{className:"text-[10px] text-muted-foreground",children:E})]}),R&&m.jsx(uf,{className:"h-3.5 w-3.5 text-primary"})]},p)})})]})]})}function j3({value:n}){const r={default:["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%)"],inshield:["hsl(220 25% 12%)","hsl(0 0% 100%)","hsl(195 80% 55%)"],edge:["hsl(265 75% 55%)","hsl(260 12% 98%)","hsl(285 70% 65%)"]},[o,i,u]=r[n];return m.jsxs("div",{className:ve("flex h-6 w-6 shrink-0 overflow-hidden border border-border/60",n==="edge"?"rounded-[10px]":"rounded-[12px]"),children:[m.jsx("div",{className:"h-full w-1/3",style:{background:o}}),m.jsx("div",{className:"h-full w-1/3",style:{background:i}}),m.jsx("div",{className:"h-full w-1/3",style:{background:u}})]})}function O3(){var v,g;const{cluster:n,events:r,sseConnected:o}=u0(),i=Xn(),[u,d]=y.useState(!1),f=i.pathname==="/"||/^\/tasks\/[^/]+$/.test(i.pathname),h=y.useMemo(()=>{const x=new Map;for(const p of(n==null?void 0:n.nodes)??[])x.set(p.id,p.name);return x},[n==null?void 0:n.nodes]);return m.jsxs("div",{className:"relative h-full overflow-hidden bg-background text-foreground",children:[m.jsx("div",{className:"mesh-grid pointer-events-none absolute inset-0"}),m.jsxs("div",{className:"relative z-10 flex h-full min-h-0 flex-col",children:[m.jsx("header",{className:"relative z-50 shrink-0 px-2 pb-2 pt-3 sm:px-5 sm:pb-3 sm:pt-4 lg:px-6",children:m.jsxs("div",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle mx-auto flex max-w-[1760px] flex-wrap items-center justify-between gap-2 rounded-[22px] px-3 py-2 sm:gap-3 sm:rounded-[24px] sm:px-4 sm:py-3",children:[m.jsx("div",{className:"flex min-w-0 items-center gap-4",children:m.jsxs(o0,{to:"/",className:"flex items-center gap-3",children:[m.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-[15px] border border-border/70 bg-foreground text-xs font-semibold tracking-[0.24em] text-background shadow-sm sm:h-11 sm:w-11 sm:rounded-[17px] sm:text-sm",children:"M"}),m.jsxs("div",{className:"hidden min-w-0 sm:block",children:[m.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.34em] text-muted-foreground",children:"MESHY"}),m.jsx("div",{className:"truncate text-base font-semibold tracking-tight text-foreground",children:"Workspace"})]})]})}),m.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[m.jsxs("div",{className:"hidden items-center gap-2 rounded-[16px] border border-border/70 bg-background/70 px-3 py-2 text-xs text-muted-foreground shadow-sm sm:flex",children:[m.jsxs("span",{className:"flex items-center gap-2",children:[(n==null?void 0:n.self)&&m.jsx(L0,{status:n.self.status}),m.jsx("span",{className:"font-medium text-foreground",children:((v=n==null?void 0:n.self)==null?void 0:v.name)??"offline"})]}),m.jsx("span",{className:"text-border",children:"/"}),m.jsx("span",{className:"capitalize",children:((g=n==null?void 0:n.self)==null?void 0:g.role)??"node"})]}),m.jsx(N3,{connected:o,events:r,nodes:(n==null?void 0:n.nodes)??[],nodeNameById:h}),f&&m.jsx(Gn,{variant:"ghost",size:"icon",onClick:()=>d(x=>!x),"aria-label":u?"Close terminal":"Open terminal",title:u?"Close terminal":"Open terminal",className:ve("rounded-[16px] border bg-background/70 shadow-sm",u?"border-primary/50 bg-primary/10 text-primary":"border-border/70"),children:m.jsx(v0,{className:"h-4 w-4"})}),m.jsx(n3,{}),m.jsx(_3,{})]})]})}),m.jsx("main",{className:ve("min-h-0 flex-1 px-3 pb-3 sm:px-5 lg:px-6",f?"overflow-hidden":"overflow-y-auto"),children:m.jsx("div",{className:"mx-auto h-full min-h-0 max-w-[1760px]",children:m.jsx(W2,{context:{terminalOpen:u,setTerminalOpen:d}})})})]})]})}const Uv=y.lazy(async()=>({default:(await Vv(()=>import("./DashboardPage-D90kD6BP.js").then(r=>r.D),__vite__mapDeps([0,1,2,3]))).DashboardPage})),M3=y.lazy(async()=>({default:(await Vv(()=>import("./SharedConversationPage-CYx3AV6M.js"),__vite__mapDeps([4,1]))).SharedConversationPage}));function D3(){return m.jsx(Cw,{children:m.jsx(y.Suspense,{fallback:m.jsx(k3,{}),children:m.jsxs(tw,{children:[m.jsx(Rl,{path:"/shared/tasks/:shareId",element:m.jsx(M3,{})}),m.jsxs(Rl,{element:m.jsx(Zw,{children:m.jsx(O3,{})}),children:[m.jsx(Rl,{path:"/",element:m.jsx(Uv,{})}),m.jsx(Rl,{path:"/nodes",element:m.jsx(Pg,{to:"/",replace:!0})}),m.jsx(Rl,{path:"/tasks",element:m.jsx(Pg,{to:"/",replace:!0})}),m.jsx(Rl,{path:"/tasks/:id",element:m.jsx(Uv,{})})]})]})})})}function k3(){return m.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading workspace..."})}function z3(n){return m.jsx(gC,{className:"toaster group",style:{"--normal-bg":"hsl(var(--popover))","--normal-text":"hsl(var(--popover-foreground))","--normal-border":"hsl(var(--border))"},...n})}e2.createRoot(document.getElementById("root")).render(m.jsx(y.StrictMode,{children:m.jsxs(C3,{children:[m.jsx(D3,{}),m.jsx(z3,{})]})}));export{Ls as $,a3 as A,bt as B,uf as C,by as D,GE as E,CE as F,W3 as G,t5 as H,Ax as I,bE as J,s3 as K,i3 as L,pA as M,x_ as N,Wb as O,S_ as P,ws as Q,B_ as R,Nr as S,N_ as T,Es as U,Wd as V,ks as W,y0 as X,zs as Y,Us as Z,Bs as _,bC as a,g_ as a$,Vs as a0,Hs as a1,Vv as a2,P3 as a3,v0 as a4,ko as a5,vE as a6,Z3 as a7,I3 as a8,K3 as a9,k_ as aA,M_ as aB,A_ as aC,__ as aD,O_ as aE,j_ as aF,J3 as aG,C_ as aH,r3 as aI,o_ as aJ,a_ as aK,l_ as aL,n_ as aM,t_ as aN,H3 as aO,q3 as aP,B3 as aQ,Y3 as aR,m_ as aS,f_ as aT,d_ as aU,c_ as aV,u_ as aW,h_ as aX,fE as aY,Bv as aZ,v_ as a_,D_ as aa,p0 as ab,m3 as ac,L0 as ad,EE as ae,qN as af,H_ as ag,l3 as ah,V_ as ai,T_ as aj,R_ as ak,Rx as al,L_ as am,z_ as an,U_ as ao,ef as ap,i_ as aq,s_ as ar,F3 as as,Xw as at,r_ as au,U3 as av,Xn as aw,Fv as ax,L3 as ay,u0 as az,ve as b,p_ as b0,LE as b1,y_ as b2,w_ as b3,b_ as b4,qe as c,z0 as d,V3 as e,xy as f,Sy as g,l5 as h,Gn as i,m as j,G3 as k,Q3 as l,Vw as m,$3 as n,uE as o,E_ as p,X3 as q,y as r,e_ as s,Et as t,jb as u,Lf as v,Ob as w,Uf as x,f0 as y,Gs as z};
301
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return y.useEffect(()=>{var i;document.getElementById((i=n.current)==null?void 0:i.getAttribute("aria-describedby"))||console.warn(r)},[r,n]),null},CA=tx,TA=nx,RA=ax,mx=lx,hx=rx,px=ux,gx=fx,vx=ix,yx=cx;const Wd=CA,ef=TA,AA=RA,bx=y.forwardRef(({className:n,...r},o)=>m.jsx(mx,{className:ve("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}));bx.displayName=mx.displayName;const ks=y.forwardRef(({className:n,...r},o)=>m.jsxs(AA,{children:[m.jsx(bx,{}),m.jsx(hx,{ref:o,className:ve("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 rounded-[22px] border bg-background p-6 shadow-[0_34px_110px_-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})]}));ks.displayName=hx.displayName;const zs=({className:n,...r})=>m.jsx("div",{className:ve("flex flex-col space-y-2 text-center sm:text-left",n),...r});zs.displayName="AlertDialogHeader";const Ls=({className:n,...r})=>m.jsx("div",{className:ve("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...r});Ls.displayName="AlertDialogFooter";const Us=y.forwardRef(({className:n,...r},o)=>m.jsx(vx,{ref:o,className:ve("text-lg font-semibold",n),...r}));Us.displayName=vx.displayName;const Bs=y.forwardRef(({className:n,...r},o)=>m.jsx(yx,{ref:o,className:ve("text-sm text-muted-foreground",n),...r}));Bs.displayName=yx.displayName;const Hs=y.forwardRef(({className:n,...r},o)=>m.jsx(px,{ref:o,className:ve(hf(),n),...r}));Hs.displayName=px.displayName;const Vs=y.forwardRef(({className:n,...r},o)=>m.jsx(gx,{ref:o,className:ve(hf({variant:"outline"}),"mt-2 sm:mt-0",n),...r}));Vs.displayName=gx.displayName;var nc="Checkbox",[_A]=Wa(nc),[jA,Hf]=_A(nc);function OA(n){const{__scopeCheckbox:r,checked:o,children:i,defaultChecked:u,disabled:d,form:f,name:h,onCheckedChange:v,required:g,value:x="on",internal_do_not_use_render:p}=n,[S,E]=Ar({prop:o,defaultProp:u??!1,onChange:v,caller:nc}),[R,N]=y.useState(null),[T,C]=y.useState(null),M=y.useRef(!1),j=R?!!f||!!R.closest("form"):!0,k={checked:S,disabled:d,setChecked:E,control:R,setControl:N,name:h,form:f,value:x,hasConsumerStoppedPropagationRef:M,required:g,defaultChecked:Za(u)?!1:u,isFormControl:j,bubbleInput:T,setBubbleInput:C};return m.jsx(jA,{scope:r,...k,children:MA(p)?p(k):i})}var xx="CheckboxTrigger",Sx=y.forwardRef(({__scopeCheckbox:n,onKeyDown:r,onClick:o,...i},u)=>{const{control:d,value:f,disabled:h,checked:v,required:g,setControl:x,setChecked:p,hasConsumerStoppedPropagationRef:S,isFormControl:E,bubbleInput:R}=Hf(xx,n),N=Ie(u,x),T=y.useRef(v);return y.useEffect(()=>{const C=d==null?void 0:d.form;if(C){const M=()=>p(T.current);return C.addEventListener("reset",M),()=>C.removeEventListener("reset",M)}},[d,p]),m.jsx(Ue.button,{type:"button",role:"checkbox","aria-checked":Za(v)?"mixed":v,"aria-required":g,"data-state":Tx(v),"data-disabled":h?"":void 0,disabled:h,value:f,...i,ref:N,onKeyDown:Me(r,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:Me(o,C=>{p(M=>Za(M)?!0:!M),R&&E&&(S.current=C.isPropagationStopped(),S.current||C.stopPropagation())})})});Sx.displayName=xx;var Vf=y.forwardRef((n,r)=>{const{__scopeCheckbox:o,name:i,checked:u,defaultChecked:d,required:f,disabled:h,value:v,onCheckedChange:g,form:x,...p}=n;return m.jsx(OA,{__scopeCheckbox:o,checked:u,defaultChecked:d,disabled:h,required:f,onCheckedChange:g,name:i,form:x,value:v,internal_do_not_use_render:({isFormControl:S})=>m.jsxs(m.Fragment,{children:[m.jsx(Sx,{...p,ref:r,__scopeCheckbox:o}),S&&m.jsx(Cx,{__scopeCheckbox:o})]})})});Vf.displayName=nc;var wx="CheckboxIndicator",Ex=y.forwardRef((n,r)=>{const{__scopeCheckbox:o,forceMount:i,...u}=n,d=Hf(wx,o);return m.jsx(Dr,{present:i||Za(d.checked)||d.checked===!0,children:m.jsx(Ue.span,{"data-state":Tx(d.checked),"data-disabled":d.disabled?"":void 0,...u,ref:r,style:{pointerEvents:"none",...n.style}})})});Ex.displayName=wx;var Nx="CheckboxBubbleInput",Cx=y.forwardRef(({__scopeCheckbox:n,...r},o)=>{const{control:i,hasConsumerStoppedPropagationRef:u,checked:d,defaultChecked:f,required:h,disabled:v,name:g,value:x,form:p,bubbleInput:S,setBubbleInput:E}=Hf(Nx,n),R=Ie(o,E),N=Ky(d),T=Ly(i);y.useEffect(()=>{const M=S;if(!M)return;const j=window.HTMLInputElement.prototype,q=Object.getOwnPropertyDescriptor(j,"checked").set,G=!u.current;if(N!==d&&q){const H=new Event("click",{bubbles:G});M.indeterminate=Za(d),q.call(M,Za(d)?!1:d),M.dispatchEvent(H)}},[S,N,d,u]);const C=y.useRef(Za(d)?!1:d);return m.jsx(Ue.input,{type:"checkbox","aria-hidden":!0,defaultChecked:f??C.current,required:h,disabled:v,name:g,value:x,form:p,...r,tabIndex:-1,ref:R,style:{...r.style,...T,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Cx.displayName=Nx;function MA(n){return typeof n=="function"}function Za(n){return n==="indeterminate"}function Tx(n){return Za(n)?"indeterminate":n?"checked":"unchecked"}const Rx=y.forwardRef(({className:n,...r},o)=>m.jsx(Vf,{ref:o,className:ve("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:m.jsx(Ex,{className:ve("flex items-center justify-center text-current"),children:m.jsx(uf,{className:"h-3.5 w-3.5"})})}));Rx.displayName=Vf.displayName;const Ax=y.forwardRef(({className:n,type:r,...o},i)=>m.jsx("input",{type:r,className:ve("flex h-10 w-full rounded-[16px] border border-input/85 bg-background/72 px-3 py-2 text-sm shadow-sm ring-offset-background transition-all duration-200 file:border-0 file:bg-transparent file:text-sm 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:i,...o}));Ax.displayName="Input";const kv=["queued","running"];function DA(n){return n==="claude"||n==="codex"}function _x(n){var o;if(n.kind!=="agent.upgrade")return null;const r=(o=n.payload)==null?void 0:o.agent;return DA(r)?`${n.nodeId}:${r}`:null}function kA(n){return n.status==="succeeded"||n.status==="failed"}async function jx(n,r={}){const o=r.getOperation??Vw,i=r.pollIntervalMs??2e3,u=r.timeoutMs??24e4,d=Date.now()+u;let f=n;for(;!kA(f)&&Date.now()<d;)await LA(i),f=await o(n.id);return f}async function zA(n,r=qw){const o=new Set(n),i=await Promise.all(kv.map(d=>r({kind:"agent.upgrade",status:d}))),u=new Map;for(const d of i.flat()){if(!kv.includes(d.status)||o.size>0&&!o.has(d.nodeId))continue;const f=_x(d);if(!f)continue;const h=u.get(f);(!h||d.updatedAt>h.updatedAt)&&u.set(f,d)}return u}function LA(n){return new Promise(r=>setTimeout(r,n))}function UA(n,r=!0){return r?(n==null?void 0:n.restartMode)==="development"?"Restart dev runtime":n!=null&&n.updateAvailable?"Update & restart":"Restart runtime":n!=null&&n.updateAvailable?"Update & restart follower":"Restart follower"}function BA({checkedLabel:n,disableAuthDefault:r,endpoint:o,isLiveLocalNode:i,nodeId:u,nodeName:d,pid:f,transportType:h,update:v,workDir:g}){const x=UA(v,i),[p,S]=y.useState(null),[E,R]=y.useState(()=>zv({disableAuthDefault:r,endpoint:o,nodeName:d,transportType:h,workDir:g})),[N,T]=y.useState(!1),[C,M]=y.useState(!1),[j,k]=y.useState(!1);y.useEffect(()=>{R(zv({disableAuthDefault:r,endpoint:o,nodeName:d,transportType:h,workDir:g}))},[r,o,d,h,g]);async function q(){if(!u||N||C)return;const ne=v.updateAvailable?"update":"restart",de=qA(E);if(E.port.trim()&&(de==null?void 0:de.port)===void 0){Et.error("Runtime restart port must be a positive integer");return}const ye=de?{reason:ne,startArgs:de}:{reason:ne};T(!0);try{if(i){const ce=await Uw(ye);S({...ce,pid:ce.pid??f,status:"accepted"}),Et.info(`Restarting ${d} from a detached helper. PID ${ce.pid??f??"unknown"} will not stay attached to the original terminal window; follow ${ce.logPath} for launch output.`);return}const oe=await $w(u,ye);S({operationId:oe.id,pid:f,status:oe.status}),Et.info(`Restart requested on ${d}. Operation ${Ud(oe.id)} will hand off to a detached process, so the new runtime will not stay attached to the original terminal window.`);const se=await jx(oe,{timeoutMs:6e4}),le=VA(se);S({command:le==null?void 0:le.command,logPath:le==null?void 0:le.logPath,mode:le==null?void 0:le.mode,operationId:se.id,pid:(le==null?void 0:le.pid)??f,status:se.status}),se.status==="succeeded"?Et.success(`Restart handoff accepted on ${d}. Follow ${(le==null?void 0:le.logPath)??"the node restart log"} for launch output.`):se.status==="failed"?Et.error(se.error??`Restart failed on ${d}`):Et.info(`Restart operation ${Ud(se.id)} is still ${se.status}. More details will update after the node reports back.`),T(!1)}catch(oe){T(!1),Et.error(oe instanceof Error?oe.message:"Runtime restart failed")}}async function G(){if(!(!i||N||C)){M(!0);try{const ne=await Bw();Et.info(`Stopping Meshy process ${ne.pid}`)}catch(ne){M(!1),Et.error(ne instanceof Error?ne.message:"Runtime stop failed")}}}const H=N?"restarting":C?"stopping":(p==null?void 0:p.status)??"idle",V=v.restartMode==="development";return m.jsxs("div",{className:"rounded-xl border border-border/70 bg-background/70 overflow-hidden",children:[m.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border/50",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Cs,{className:"h-3.5 w-3.5 text-primary shrink-0"}),m.jsxs("div",{children:[m.jsx("div",{className:"text-[11px] font-semibold text-foreground leading-tight",children:"Runtime"}),m.jsx("div",{className:"text-[10px] text-muted-foreground leading-tight",children:V?"Development launcher":`Latest ${v.latestVersion??"—"}`})]})]}),m.jsx("div",{className:"flex items-center gap-1.5",children:m.jsx(bt,{variant:v.updateAvailable?"default":"outline",className:"rounded-full border-border/70 bg-background/60 font-mono text-[10px] px-2 py-0.5",children:V?"dev":v.updateAvailable?`→ ${v.latestVersion}`:"current"})})]}),m.jsxs("div",{className:"grid grid-cols-2 divide-x divide-border/50 border-b border-border/50",children:[m.jsxs("div",{className:"px-3 py-1.5",children:[m.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:"PID"}),m.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-foreground",children:f??"—"})]}),m.jsxs("div",{className:"px-3 py-1.5",children:[m.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:"Status"}),m.jsx("div",{className:"mt-0.5 text-[11px] text-foreground capitalize",children:H})]})]}),m.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2",children:[m.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["Checked ",n]}),m.jsxs("div",{className:"flex items-center gap-1.5",children:[i&&m.jsxs(Wd,{children:[m.jsx(ef,{asChild:!0,children:m.jsxs(Gn,{type:"button",size:"sm",variant:"ghost",disabled:N||C,className:"h-7 rounded-lg px-2 text-[11px] text-muted-foreground hover:text-destructive hover:bg-destructive/10",children:[m.jsx(DE,{className:ve("mr-1 h-3.5 w-3.5",C&&"animate-pulse")}),C?"Stopping":"Stop"]})}),m.jsxs(ks,{className:"max-w-[22rem] rounded-xl gap-2 p-4",children:[m.jsxs(zs,{className:"space-y-1",children:[m.jsx(Us,{className:"text-sm",children:"Stop runtime?"}),m.jsx(Bs,{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."})]}),m.jsxs(Ls,{className:"gap-1 pt-0 sm:space-x-1",children:[m.jsx(Vs,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),m.jsx(Hs,{className:"h-7 rounded-lg px-2 text-[11px] bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>void G(),children:"Stop runtime"})]})]})]}),m.jsxs(Wd,{children:[m.jsx(ef,{asChild:!0,children:m.jsxs(Gn,{type:"button",size:"sm",variant:v.updateAvailable?"default":"outline",disabled:!u||N||C,className:"h-7 rounded-lg px-2 text-[11px]",children:[m.jsx(LE,{className:ve("mr-1 h-3.5 w-3.5",N&&"animate-spin")}),N?"Restarting…":x]})}),m.jsxs(ks,{className:"max-w-[28rem] gap-3 rounded-xl p-4",children:[m.jsxs(zs,{className:"space-y-1",children:[m.jsxs(Us,{className:"text-sm",children:[x,"?"]}),m.jsxs(Bs,{className:"text-[11px] leading-4",children:["Starts a detached restart helper, shuts down ",i?"the current node":d,", and brings it back with the configured launcher. The new process will not stay attached to the original terminal window."]})]}),m.jsx(HA,{value:E,onChange:R}),m.jsxs(Ls,{className:"gap-1 pt-0 sm:space-x-1",children:[m.jsx(Vs,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),m.jsx(Hs,{className:"h-7 rounded-lg px-2 text-[11px]",onClick:()=>void q(),children:x})]})]})]})]})]}),m.jsxs("div",{className:"border-t border-border/50",children:[m.jsxs("button",{type:"button",onClick:()=>k(ne=>!ne),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:[m.jsxs("span",{className:"flex items-center gap-1.5",children:[m.jsx(v0,{className:"h-3 w-3"}),"Restart details"]}),m.jsx(Gs,{className:ve("h-3 w-3 transition-transform duration-150",j&&"rotate-180")})]}),j&&m.jsxs("div",{className:"border-t border-border/50 bg-muted/20 px-3 py-2 space-y-1",children:[m.jsx(Tl,{label:"Current PID",value:f===void 0?"—":String(f),mono:f!==void 0}),m.jsx(Tl,{label:"Restart PID",value:(p==null?void 0:p.pid)===void 0?"Pending":String(p.pid),mono:(p==null?void 0:p.pid)!==void 0}),m.jsx(Tl,{label:"Operation",value:p!=null&&p.operationId?Ud(p.operationId):"Local direct request",mono:!!(p!=null&&p.operationId)}),m.jsx(Tl,{label:"Status",value:(p==null?void 0:p.status)??(N?"requested":"idle")}),m.jsx(Tl,{label:"Launcher",value:(p==null?void 0:p.command)??"Available after restart",mono:!!(p!=null&&p.command)}),m.jsx(Tl,{label:"Log",value:(p==null?void 0:p.logPath)??"Available after restart",mono:!!(p!=null&&p.logPath)}),m.jsx(Tl,{label:"Terminal",value:"New process is detached from original terminal"})]})]}),v.detail&&m.jsx("div",{className:"border-t border-border/50 px-3 py-1.5 text-[10px] text-muted-foreground bg-muted/20",children:v.detail})]})}function HA({onChange:n,value:r}){const o=(i,u)=>{n({...r,[i]:u})};return m.jsxs("div",{className:"rounded-lg border border-border/70 bg-muted/30 p-3 space-y-3",children:[m.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Startup arguments"}),m.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[m.jsx(Do,{label:"HTTP port",value:r.port,onChange:i=>o("port",i),inputMode:"numeric"}),m.jsx(Do,{label:"Node name",value:r.name,onChange:i=>o("name",i)}),m.jsx(Do,{label:"Join endpoint",value:r.join,onChange:i=>o("join",i),className:"sm:col-span-2"}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("label",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:"Transport"}),m.jsxs(jb,{value:r.transport,onValueChange:i=>o("transport",Ox(i)),children:[m.jsx(Lf,{className:"h-7 rounded-md border-border/70 bg-background/70 px-2 text-[10px]",children:m.jsx(Ob,{placeholder:"Transport"})}),m.jsxs(Uf,{children:[m.jsx(Nr,{className:"py-1 text-[11px]",value:"inherit",children:"current / default"}),m.jsx(Nr,{className:"py-1 text-[11px]",value:"direct",children:"direct"}),m.jsx(Nr,{className:"py-1 text-[11px]",value:"devtunnel",children:"devtunnel"}),m.jsx(Nr,{className:"py-1 text-[11px]",value:"tailscale",children:"tailscale"})]})]})]}),m.jsx(Do,{label:"Working directory",value:r.workDir,onChange:i=>o("workDir",i)}),m.jsx(Do,{label:"Config path",value:r.config,onChange:i=>o("config",i),className:"sm:col-span-2"}),m.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:[m.jsx(Rx,{className:"h-3.5 w-3.5",checked:r.disableAuth,onCheckedChange:i=>n({...r,disableAuth:i===!0,disableAuthKnown:!0})}),"Disable auth"]})]})]})}function Do({className:n,inputMode:r,label:o,onChange:i,value:u}){return m.jsxs("label",{className:ve("space-y-1",n),children:[m.jsx("span",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:o}),m.jsx(Ax,{className:"h-7 rounded-md px-2 text-[10px]",inputMode:r,value:u,onChange:d=>i(d.target.value)})]})}function Tl({label:n,value:r,mono:o=!1}){return m.jsxs("div",{className:"flex items-start justify-between gap-3 text-[10px]",children:[m.jsx("span",{className:"shrink-0 uppercase tracking-[0.14em] text-muted-foreground",children:n}),m.jsx("span",{className:ve("break-all text-right text-foreground",o&&"font-mono"),children:r})]})}function VA(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 zv(n){return{port:YA(n.endpoint),name:n.nodeName,join:"",transport:Ox(n.transportType),workDir:n.workDir??"",config:"",disableAuth:n.disableAuthDefault===!0,disableAuthKnown:n.disableAuthDefault!==void 0}}function qA(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 Ox(n){return n==="direct"||n==="devtunnel"||n==="tailscale"?n:"inherit"}function YA(n){if(!n)return"";try{return new URL(n).port||""}catch{return""}}function Ud(n){return n.length<=8?n:n.slice(0,8)}function gs({formatDateTime:n,name:r,status:o,statusVariant:i}){return m.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:[m.jsxs("div",{children:[m.jsx("div",{className:"text-[11px] font-medium text-foreground",children:r}),m.jsx("div",{className:"text-[10px] text-muted-foreground",children:n(o==null?void 0:o.checkedAt)})]}),m.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof(o==null?void 0:o.authenticated)=="boolean"&&m.jsx(bt,{variant:o.authenticated?"default":"outline",className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o.authenticated?"auth ok":"auth required"}),m.jsx(bt,{variant:i(o==null?void 0:o.status),className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:(o==null?void 0:o.status)??"unknown"})]})]})}function pn(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 $A(n){const r=Math.max(0,Math.floor(n)),o=Math.floor(r/86400),i=Math.floor(r%86400/3600),u=Math.floor(r%3600/60);return o>0?`${o}d ${i}h`:i>0?`${i}h ${u}m`:`${u}m`}function Lv(n){if(n==null||Number.isNaN(n))return"Unavailable";const r=["B","KB","MB","GB","TB"];let o=n,i=0;for(;o>=1024&&i<r.length-1;)o/=1024,i+=1;return`${o.toFixed(o>=10||i===0?0:1)} ${r[i]}`}function Lo(n){return n==="ok"?"default":n==="missing"||n==="install-failed"||n==="login-failed"?"destructive":n==="not-authenticated"||n==="unsupported-platform"?"outline":"secondary"}function GA(n){return n.available?m.jsxs(bt,{className:"gap-1 rounded-full px-2 py-0.5 text-[10px]",children:[m.jsx(ko,{className:"h-3 w-3"}),"Available"]}):m.jsxs(bt,{variant:"destructive",className:"gap-1 rounded-full px-2 py-0.5 text-[10px]",children:[m.jsx(vE,{className:"h-3 w-3"}),"Unavailable"]})}function XA(n){return n.update?n.update.updateAvailable?m.jsxs(bt,{variant:"outline",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.14em]",children:["Update ",n.update.latestVersion]}):m.jsx(bt,{variant:"secondary",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.14em]",children:"Up to date"}):null}function QA(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 KA(n){if(n.error)return n.error;const r=n.result;return(r==null?void 0:r.detail)??null}function Le({label:n,value:r,mono:o=!1}){return m.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:[m.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:n}),m.jsx("span",{className:ve("break-all text-right text-[11px] text-foreground",o&&"font-mono text-[11px]"),children:r})]})}function ZA({agent:n,nodeName:r,activeOperation:o,onUpgrade:i}){var h,v;const u=((h=n.update)==null?void 0:h.updateAvailable)===!0,d=XA(n),f=!!o;return m.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/70 p-2.5 shadow-sm",children:[m.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[m.jsx(f0,{className:"h-3.5 w-3.5 text-primary"}),n.label]}),m.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:["Command: ",m.jsx("span",{className:"font-mono text-[10px]",children:n.command})]})]}),m.jsxs("div",{className:"flex flex-col items-end gap-1",children:[GA(n),o?m.jsxs(bt,{variant:"outline",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.14em]",children:["Upgrade ",o.status]}):u?m.jsxs(Wd,{children:[m.jsx(ef,{asChild:!0,children:m.jsx("button",{type:"button",disabled:f,className:"rounded-full transition duration-150 hover:-translate-y-0.5 hover:scale-[1.03] hover:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 focus-visible:ring-offset-2 active:translate-y-0 active:scale-95 disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:translate-y-0 disabled:hover:scale-100 disabled:hover:shadow-none",children:d})}),m.jsxs(ks,{children:[m.jsxs(zs,{children:[m.jsxs(Us,{children:["Upgrade ",n.label,"?"]}),m.jsxs(Bs,{children:["This runs ",QA(n)," on ",r,". Remote nodes execute the command on the remote machine."]})]}),m.jsxs(Ls,{children:[m.jsx(Vs,{children:"Cancel"}),m.jsx(Hs,{onClick:()=>i(n),children:"Upgrade"})]})]})]}):d]})]}),m.jsxs("div",{className:"mt-2 space-y-1 text-[11px]",children:[m.jsx(Le,{label:"Version",value:n.version??"Unavailable",mono:!!n.version}),n.update&&m.jsx(Le,{label:"Latest",value:n.update.latestVersion??"Unavailable",mono:!!n.update.latestVersion}),m.jsx(Le,{label:"Path",value:n.path??"Not on PATH",mono:!!n.path}),m.jsx(Le,{label:"Checked",value:pn(n.checkedAt)}),n.update&&m.jsx(Le,{label:"Update check",value:pn(n.update.checkedAt)})]}),((v=n.update)==null?void 0:v.detail)&&m.jsx("div",{className:"mt-1.5 rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[10px] text-muted-foreground",children:n.update.detail}),n.metadataStatus&&m.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[m.jsx(bt,{variant:Lo(n.metadataStatus),className:"rounded-full px-2 py-0 text-[10px] uppercase tracking-[0.14em]",children:n.metadataStatus}),m.jsx("span",{children:"Startup preflight"})]}),n.detail&&m.jsx("div",{className:"mt-1.5 rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[10px] text-muted-foreground",children:n.detail})]})}function PA(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 IA(n,r){var o;return(o=n==null?void 0:n.nodes)!=null&&o.length?n.nodes:r?[r]:[]}function FA(n,r){var i;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:((i=o==null?void 0:o.runtime)==null?void 0:i.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 JA(n,r){return n.id===r?`${n.name} (this node)`:`${n.name} (${n.role})`}function WA(n){return n==="claude"?"Claude Code":"Codex"}function e3(n){var o;const r=(o=n.payload)==null?void 0:o.agent;return r==="claude"||r==="codex"?r:null}function t3({cluster:n,systemInfo:r,sseConnected:o,onRefresh:i}){var H,V,ne,de,ye,oe,se,le,ce,O,$,I,ie,F,_,X,K,J,W,ae,ee,re,ue,Te,we,Se,Fe;const u=y.useMemo(()=>IA(n,r),[n,r]),[d,f]=y.useState(()=>{var fe;return(r==null?void 0:r.nodeId)??((fe=n==null?void 0:n.self)==null?void 0:fe.id)??""}),[h,v]=y.useState(()=>new Map),g=y.useRef(new Set),x=y.useRef(new Set),p=(n==null?void 0:n.self)??r??u[0]??null,S=u.find(fe=>fe.id===d)??p,E=S?FA(S,r):null,R=!!(r&&S&&S.id===r.nodeId),N=R||!!(S!=null&&S.settingsSnapshot),T=y.useMemo(()=>PA(E==null?void 0:E.packages),[E==null?void 0:E.packages]),C=E==null?void 0:E.runtimeUpdate,M=((H=E==null?void 0:E.startupRequirements)==null?void 0:H.components)??(E==null?void 0:E.components)??{},j=y.useMemo(()=>u.map(fe=>fe.id),[u]),k=j.join("\0"),q=y.useCallback(async(fe,Ge)=>{const Ze=_x(fe);if(!Ze||g.current.has(fe.id))return;const ft=e3(fe),Lt=u.find(lt=>lt.id===fe.nodeId),Je=(Ge==null?void 0:Ge.agentLabel)??(ft?WA(ft):"Agent"),Rn=(Ge==null?void 0:Ge.nodeName)??(Lt==null?void 0:Lt.name)??fe.nodeId;g.current.add(fe.id),v(lt=>new Map(lt).set(Ze,fe));try{const lt=await jx(fe);if(lt.status==="succeeded")await(i==null?void 0:i()),x.current.has(lt.id)||(Et.success(`${Je} upgrade finished on ${Rn}`),x.current.add(lt.id));else if(lt.status==="failed")x.current.has(lt.id)||(Et.error(KA(lt)??`${Je} upgrade failed`),x.current.add(lt.id));else{v(st=>new Map(st).set(Ze,lt)),Et.info(`${Je} upgrade is still ${lt.status} on ${Rn}`);return}v(st=>{const _t=new Map(st),ct=_t.get(Ze);return(!ct||ct.id===lt.id)&&_t.delete(Ze),_t})}catch(lt){v(st=>{const _t=new Map(st),ct=_t.get(Ze);return(!ct||ct.id===fe.id)&&_t.delete(Ze),_t}),Et.error(lt instanceof Error?lt.message:`${Je} upgrade failed`)}finally{g.current.delete(fe.id)}},[i,u]);y.useEffect(()=>{if(j.length===0)return;let fe=!1;async function Ge(){let Ze;try{Ze=await zA(j)}catch{return}if(!fe){v(ft=>{const Lt=new Map(ft);for(const[Je,Rn]of Ze)Lt.set(Je,Rn);return Lt});for(const ft of Ze.values())q(ft)}}return Ge(),()=>{fe=!0}},[q,k]);async function G(fe){if(S)try{const Ge=await Yw(S.id,fe.id);Et.info(`${fe.label} upgrade started on ${S.name}`),await q(Ge,{agentLabel:fe.label,nodeName:S.name})}catch(Ge){Et.error(Ge instanceof Error?Ge.message:`${fe.label} upgrade failed`)}}return!S||!E?m.jsx("div",{className:"rounded-2xl border border-dashed border-border/70 bg-muted/20 px-4 py-8 text-center text-[12px] text-muted-foreground",children:"Loading session metadata..."}):m.jsxs("div",{className:"space-y-4",children:[m.jsx("section",{className:"rounded-2xl border border-border/70 bg-[radial-gradient(circle_at_top_left,rgba(59,130,246,0.18),transparent_42%),radial-gradient(circle_at_bottom_right,rgba(16,185,129,0.12),transparent_32%),rgba(255,255,255,0.72)] p-3 shadow-[0_24px_90px_-54px_rgba(15,23,42,0.55)] dark:bg-[radial-gradient(circle_at_top_left,rgba(59,130,246,0.18),transparent_42%),radial-gradient(circle_at_bottom_right,rgba(16,185,129,0.12),transparent_32%),rgba(10,15,23,0.78)]",children:m.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-end md:justify-between",children:[m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[m.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-border/70 bg-background/75 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur",children:[m.jsx(L0,{status:S.status}),m.jsx("span",{className:"font-medium text-foreground",children:S.name})]}),m.jsx(qN,{role:S.role}),m.jsx(bt,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:S.transportType??E.transportType??"direct"}),m.jsx(bt,{variant:R?"default":"outline",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:R?"Live local session":"Leader-synced snapshot"})]}),m.jsxs("div",{children:[m.jsx("div",{className:"text-[10px] uppercase tracking-[0.34em] text-muted-foreground",children:"Session"}),m.jsx("h3",{className:"mt-0.5 text-sm font-semibold tracking-tight text-foreground",children:"Node runtime"}),m.jsx("p",{className:"mt-1 max-w-2xl text-[11px] text-muted-foreground",children:"Inspect the selected node's runtime environment, connectivity surface, and packaged build metadata from one place."})]}),u.length>1&&m.jsxs("div",{className:"max-w-md space-y-1.5",children:[m.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:"Inspect node"}),m.jsxs(jb,{value:S.id,onValueChange:f,children:[m.jsx(Lf,{className:"h-7 rounded-lg border-border/70 bg-background/70 text-[11px]",children:m.jsx(Ob,{placeholder:"Choose a node"})}),m.jsx(Uf,{children:u.map(fe=>m.jsx(Nr,{value:fe.id,children:JA(fe,r==null?void 0:r.nodeId)},fe.id))})]})]})]}),m.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[m.jsxs(bt,{variant:o?"default":"outline",className:"gap-1 rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:[m.jsx(p0,{className:"h-3 w-3"}),o?"Live link connected":"Live link reconnecting"]}),m.jsxs(bt,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Uptime ",$A(E.uptime)]}),!R&&m.jsxs(bt,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Updated ",pn((V=S.settingsSnapshot)==null?void 0:V.collectedAt)]})]})]})}),!N&&m.jsx("div",{className:"rounded-xl 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."}),m.jsxs(pA,{defaultValue:"session",className:"space-y-2",children:[m.jsxs(Wb,{className:"h-auto flex-wrap rounded-xl border border-border/60 bg-muted/40 p-0.5",children:[m.jsx(ws,{value:"session",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Session"}),m.jsx(ws,{value:"access",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Access"}),m.jsx(ws,{value:"about",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"About"})]}),m.jsxs(Es,{value:"session",className:"mt-0 grid gap-2 xl:grid-cols-[1.15fr_0.85fr]",children:[m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(BE,{className:"h-3.5 w-3.5 text-primary"}),"Selected node"]}),m.jsx(Bn,{className:"text-[10px]",children:"Cluster role, identity, and node-scoped runtime state."})]}),m.jsxs(Hn,{className:"space-y-0 px-3 pb-2.5",children:[m.jsx(Le,{label:"Node ID",value:E.nodeId,mono:!0}),m.jsx(Le,{label:"Status",value:S.status}),m.jsx(Le,{label:"Role",value:S.role}),m.jsx(Le,{label:"Endpoint",value:S.endpoint,mono:!0}),m.jsx(Le,{label:"Joined",value:pn(S.joinedAt)}),m.jsx(Le,{label:"Heartbeat",value:pn(S.lastHeartbeat)}),m.jsx(Le,{label:"Capabilities",value:S.capabilities.length>0?S.capabilities.join(", "):"None"})]})]}),m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(SE,{className:"h-3.5 w-3.5 text-primary"}),"OS info"]}),m.jsx(Bn,{className:"text-[10px]",children:"Host and resource details reported by the current process."})]}),m.jsxs(Hn,{className:"space-y-0 px-3 pb-2.5",children:[m.jsx(Le,{label:"Host",value:((ne=E.os)==null?void 0:ne.hostname)??"Unavailable"}),m.jsx(Le,{label:"Platform",value:E.os?`${E.os.platform} ${E.os.release}`:"Unavailable"}),m.jsx(Le,{label:"Arch",value:((de=E.os)==null?void 0:de.arch)??"Unavailable"}),m.jsx(Le,{label:"CPU",value:((ye=E.os)==null?void 0:ye.cpuModel)??"Unavailable"}),m.jsx(Le,{label:"Cores",value:String(((oe=E.os)==null?void 0:oe.cpuCount)??"Unavailable")}),m.jsx(Le,{label:"Memory",value:E.os?`${Lv(E.os.freeMemoryBytes)} free / ${Lv(E.os.totalMemoryBytes)} total`:"Unavailable"})]})]}),m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)] xl:col-span-2",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(f0,{className:"h-3.5 w-3.5 text-primary"}),"Available agents"]}),m.jsx(Bn,{className:"text-[10px]",children:R?"Live command availability for Codex and Claude Code on this node.":"Most recent agent availability snapshot synced from this node."})]}),m.jsx(Hn,{className:"grid gap-2 px-3 pb-2.5 md:grid-cols-2",children:(E.agents??[]).map(fe=>m.jsx(ZA,{agent:fe,nodeName:S.name,activeOperation:h.get(`${S.id}:${fe.id}`),onUpgrade:G},fe.id))})]})]}),m.jsxs(Es,{value:"access",className:"mt-0 grid gap-2 xl:grid-cols-2",children:[m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(oE,{className:"h-3.5 w-3.5 text-primary"}),"Access surface"]}),m.jsx(Bn,{className:"text-[10px]",children:"How this node is exposed to the dashboard and other peers."})]}),m.jsxs(Hn,{className:"space-y-0 px-3 pb-2.5",children:[m.jsx(Le,{label:"Transport",value:S.transportType??E.transportType??"direct"}),m.jsx(Le,{label:"Node URL",value:S.endpoint,mono:!0}),m.jsx(Le,{label:"Node tunnel",value:S.devtunnelEndpoint??"Disabled",mono:!!S.devtunnelEndpoint}),m.jsx(Le,{label:"Dashboard URL",value:S.dashboardOrigin??E.localDashboardOrigin??"Unavailable",mono:!!(S.dashboardOrigin||E.localDashboardOrigin)}),m.jsx(Le,{label:"Local dashboard",value:E.localDashboardOrigin??"Unavailable",mono:!!E.localDashboardOrigin})]})]}),m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(YE,{className:"h-3.5 w-3.5 text-primary"}),"Auth"]}),m.jsx(Bn,{className:"text-[10px]",children:"Current bearer-auth and trusted access posture."})]}),m.jsxs(Hn,{className:"space-y-0 px-3 pb-2.5",children:[m.jsx(Le,{label:"Enabled",value:(se=E.auth)!=null&&se.enabled?"Yes":"No"}),m.jsx(Le,{label:"Same tenant",value:(le=E.auth)!=null&&le.allowSameTenant?"Allowed":"Off"}),m.jsx(Le,{label:"Allowed users",value:(ce=E.auth)!=null&&ce.allowedUsers.length?E.auth.allowedUsers.join(", "):"None"})]})]}),m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(CE,{className:"h-3.5 w-3.5 text-primary"}),"Paths"]}),m.jsx(Bn,{className:"text-[10px]",children:"Workspace and runtime paths currently used by this node."})]}),m.jsxs(Hn,{className:"space-y-0 px-3 pb-2.5",children:[m.jsx(Le,{label:"Work dir",value:((O=E.runtime)==null?void 0:O.workDir)??E.workDir??"Unavailable",mono:!!((($=E.runtime)==null?void 0:$.workDir)??E.workDir)}),m.jsx(Le,{label:"Storage",value:((I=E.runtime)==null?void 0:I.storagePath)??"Unavailable",mono:!!((ie=E.runtime)!=null&&ie.storagePath)}),m.jsx(Le,{label:"Process cwd",value:((F=E.runtime)==null?void 0:F.cwd)??"Unavailable",mono:!!((_=E.runtime)!=null&&_.cwd)}),m.jsx(Le,{label:"Started",value:pn((X=E.runtime)==null?void 0:X.startedAt)}),m.jsx(Le,{label:"PID",value:E.runtime?String(E.runtime.pid):"Unavailable",mono:!!E.runtime})]})]}),m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(Cs,{className:"h-3.5 w-3.5 text-primary"}),"Startup checks"]}),m.jsx(Bn,{className:"text-[10px]",children:"Dependency preflight snapshot persisted during node startup."})]}),m.jsxs(Hn,{className:"space-y-3 px-3 pb-2.5",children:[m.jsxs("div",{className:"rounded-xl border border-border/60 bg-background/70 px-3 py-2",children:[m.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:"Last checked"}),m.jsx("div",{className:"mt-0.5 text-[11px] text-foreground",children:pn((K=E.startupRequirements)==null?void 0:K.lastCheckedAt)})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(gs,{formatDateTime:pn,name:"Azure CLI",status:M.az,statusVariant:Lo}),m.jsx(gs,{formatDateTime:pn,name:"DevTunnel",status:M.devtunnel,statusVariant:Lo}),m.jsx(gs,{formatDateTime:pn,name:"Claude Code",status:M.claude,statusVariant:Lo}),m.jsx(gs,{formatDateTime:pn,name:"Codex",status:M.codex,statusVariant:Lo})]})]})]})]}),m.jsxs(Es,{value:"about",className:"mt-0 grid gap-2 xl:grid-cols-[0.92fr_1.08fr]",children:[m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(aE,{className:"h-3.5 w-3.5 text-primary"}),"Repository"]}),m.jsx(Bn,{className:"text-[10px]",children:"Source-of-truth repository metadata for this running node."})]}),m.jsxs(Hn,{className:"space-y-3 px-3 pb-2.5",children:[(J=E.repository)!=null&&J.url?m.jsxs("a",{href:E.repository.url,target:"_blank",rel:"noreferrer",className:"group flex items-center justify-between rounded-lg 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:[m.jsx("span",{className:"font-mono text-[10px]",children:E.repository.url}),m.jsx(EE,{className:"h-3.5 w-3.5 text-muted-foreground transition-transform group-hover:-translate-y-0.5 group-hover:translate-x-0.5"})]}):m.jsx("div",{className:"rounded-lg 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."}),m.jsxs("div",{className:"space-y-0",children:[m.jsx(Le,{label:"Branch",value:((W=E.repository)==null?void 0:W.branch)??"Unavailable",mono:!!((ae=E.repository)!=null&&ae.branch)}),m.jsx(Le,{label:"Commit",value:((ee=E.repository)==null?void 0:ee.commit)??"Unavailable",mono:!!((re=E.repository)!=null&&re.commit)}),m.jsx(Le,{label:"Runtime",value:`${E.packageName??"meshy"} ${E.version}`,mono:!0}),m.jsx(Le,{label:"Node.js",value:((ue=E.runtime)==null?void 0:ue.nodeVersion)??"Unavailable",mono:!!((Te=E.runtime)!=null&&Te.nodeVersion)})]})]})]}),m.jsxs("div",{className:"space-y-2",children:[C&&m.jsx(BA,{checkedLabel:pn(C.checkedAt),disableAuthDefault:((we=E.auth)==null?void 0:we.enabled)===void 0?void 0:E.auth.enabled===!1,endpoint:S.endpoint,isLiveLocalNode:R,nodeId:S.id,nodeName:S.name,pid:(Se=E.runtime)==null?void 0:Se.pid,transportType:S.transportType,update:C,workDir:((Fe=E.runtime)==null?void 0:Fe.workDir)??S.workDir}),m.jsxs(zn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[m.jsxs(Ln,{className:"pb-1.5 pt-2.5 px-3",children:[m.jsxs(Un,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(RE,{className:"h-3.5 w-3.5 text-primary"}),"Package versions"]}),m.jsx(Bn,{className:"text-[10px]",children:"Version snapshot for the packages most relevant to this dashboard session."})]}),m.jsx(Hn,{className:"space-y-1.5 px-3 pb-2.5",children:T.map(fe=>{var Ge,Ze;return m.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-border/60 bg-background/70 px-2.5 py-1.5",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-[11px] font-medium text-foreground",children:fe.label}),m.jsx("div",{className:"text-[10px] text-muted-foreground",children:(Ge=fe.value)==null?void 0:Ge.name})]}),m.jsx(bt,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60 font-mono text-[10px]",children:(Ze=fe.value)==null?void 0:Ze.version})]},fe.key)})})]})]})]})]})]})}function n3(){const{cluster:n,systemInfo:r,sseConnected:o,refresh:i}=u0(),[u,d]=y.useState(!1);return m.jsxs(t5,{open:u,onOpenChange:d,children:[m.jsx(n5,{asChild:!0,children:m.jsx(Gn,{variant:"ghost",size:"icon","aria-label":"Settings",title:"Settings",className:"rounded-[16px] border border-border/70 bg-background/70 shadow-sm",children:m.jsx(VE,{className:"h-4 w-4"})})}),m.jsxs(by,{className:"grid h-[min(82vh,42rem)] max-h-[82vh] max-w-[min(90vw,56rem)] grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[22px] border-border/70 bg-background/96 p-0 shadow-[0_40px_120px_-56px_rgba(15,23,42,0.75)] backdrop-blur-xl",children:[m.jsxs(xy,{className:"shrink-0 border-b border-border/60 px-3 py-2 sm:px-4",children:[m.jsxs(Sy,{className:"flex items-center gap-1.5 text-[12px]",children:[m.jsx(_E,{className:"h-3.5 w-3.5 text-primary"}),"Settings"]}),m.jsx(wy,{className:"text-[11px]",children:"Session diagnostics, access configuration, and build metadata for the current Meshy node."})]}),m.jsx("div",{className:"min-h-0 overflow-y-auto px-3 py-2.5 sm:px-4 sm:py-3",children:m.jsx(t3,{cluster:n,systemInfo:r,sseConnected:o,onRefresh:i})})]})]})}const E_="bypass",a3=[{value:"claudecode",label:"claudecode",supportsFollowUp:!0},{value:"codex",label:"codex",supportsFollowUp:!0},{value:"mars",label:"mars",disabled:!0,description:"coming soon"},{value:"eureka",label:"eureka",disabled:!0,description:"coming soon"}],N_=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],C_=new Set(a3.filter(n=>n.supportsFollowUp).map(n=>n.value)),T_=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"shared",label:"Shared"},{value:"archived",label:"Archived"}],R_=[{value:"all",label:"All task types"},{value:"native",label:"Native sessions"},{value:"meshy",label:"Meshy chats"}],l3=new Set(["pending","assigned"]),r3=new Set(["running"]),o3=new Set(["completed","failed","cancelled"]);function A_(n,r){switch(r){case"running":return r3.has(n.status);case"waiting":return l3.has(n.status);case"closed":return o3.has(n.status);case"shared":return!!n.activeShare;case"archived":return n.status==="archived";case"active":default:return n.status!=="archived"}}function __(n,r){if(r==="all")return!0;const o=n.conversationKind==="nativeSession";return r==="native"?o:!o}function j_(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(i=>i.toLowerCase().includes(o)):!0}function i3(n,r,o){if(!n)return"unassigned";const i=r==null?void 0:r.find(u=>u.id===n);return(i==null?void 0:i.name)??o??n.slice(0,8)}function O_(n,r,o){return i3(n,r,o).toLowerCase()}function M_(n,r,o){return!n.assignedTo||(o==null?void 0:o.id)===n.assignedTo?!0:(r==null?void 0:r.some(i=>i.id===n.assignedTo))??!1}function D_(n,r){return[...n].sort((o,i)=>o.id===r?-1:i.id===r?1:o.name.localeCompare(i.name))}function k_(n){if(!n||typeof n!="object")return null;const r=n,o=r.createMode,i=o==="chat"||o==="native"?o: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:i}}function z_(n){switch(n){case"running":return"bg-amber-500";case"completed":return"bg-emerald-500";case"failed":return"bg-destructive";case"cancelled":case"archived":return"bg-slate-400";case"assigned":return"bg-teal-500";case"pending":default:return"bg-muted-foreground"}}function L_(n){return n==="default workspace"?n:n.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??n}function U_(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 B_(n){return new Date(n).toLocaleString()}function H_(n){const r=Math.floor(n/1e3),o=Math.floor(r/3600),i=Math.floor(r%3600/60),u=r%60;return`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}:${String(u).padStart(2,"0")}`}async function s3(n,r="Copied to clipboard"){var o,i,u;try{if((i=(o=globalThis.navigator)==null?void 0:o.clipboard)!=null&&i.writeText)return await globalThis.navigator.clipboard.writeText(n),Et.success(r),!0;const d=globalThis.document,f=(u=d==null?void 0:d.execCommand)==null?void 0:u.bind(d);if(!(d!=null&&d.body)||typeof d.createElement!="function"||typeof f!="function")throw new Error("Clipboard access is unavailable");const h=d.createElement("textarea"),v=d.activeElement,g=v&&typeof v.focus=="function"?v:null;h.value=n,h.setAttribute("readonly","true"),h.style.position="fixed",h.style.opacity="0",h.style.pointerEvents="none",d.body.appendChild(h),h.select(),h.setSelectionRange(0,h.value.length);const x=f("copy");if(d.body.removeChild(h),g==null||g.focus(),!x)throw new Error("Clipboard access is unavailable");return Et.success(r),!0}catch(d){return Et.error(d instanceof Error?d.message:"Failed to copy"),!1}}function V_(n,r,o){const i=new Map;for(const d of n){const f=d.assignedTo??null,h=f??"__unassigned__",v=f?r.get(f)??d.assignedNodeName??f.slice(0,8):"Unassigned",g=d.effectiveProjectPath??d.project??"default workspace";i.has(h)||i.set(h,{nodeId:f,nodeName:v,dirMap:new Map});const x=i.get(h);x.dirMap.has(g)||x.dirMap.set(g,[]),x.dirMap.get(g).push(d)}const u=Array.from(i.values()).map(({nodeId:d,nodeName:f,dirMap:h})=>{const v=Array.from(h.entries()).map(([g,x])=>({path:g,tasks:x})).sort((g,x)=>x.tasks.length-g.tasks.length||g.path.localeCompare(x.path));return{nodeId:d,nodeName:f,dirs:v}});return u.sort((d,f)=>{if(o){if(d.nodeId===o)return-1;if(f.nodeId===o)return 1}return d.nodeId===null?1:f.nodeId===null?-1:d.nodeName.localeCompare(f.nodeName)}),u}const c3={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"};function u3(n){return n.split(".")[0]??"unknown"}function d3(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function Er(n,r){return(r==null?void 0:r.get(n))??n}function Mx(n,r){const o=n.data,i=o.operation;switch(n.type){case"node.joined":return`${o.name} joined the cluster`;case"node.left":return`${Er(o.nodeId,r)} left (${o.reason})`;case"node.status":return`${Er(o.nodeId,r)} is now ${o.status}`;case"node.operation.created":return`${i==null?void 0:i.kind} ${i==null?void 0:i.status} on ${Er(i==null?void 0:i.nodeId,r)}`;case"node.operation.updated":return`${i==null?void 0:i.kind} ${i==null?void 0:i.status} on ${Er(i==null?void 0:i.nodeId,r)}`;case"transport.changed":return`${Er(o.nodeId,r)} transport switched to ${o.transportType}`;case"task.created":return`"${o.title}" created`;case"task.assigned":return`task assigned to ${Er(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 f3(n){return JSON.stringify(n,null,2)}function m3({events:n,maxHeight:r="400px",nodeNameById:o,onDismiss:i}){return n.length===0?null:m.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:r},children:m.jsx("div",{className:"space-y-1.5",children:n.map(u=>{const d=u3(u.type);return m.jsx("div",{className:"rounded-lg px-1.5 py-1 transition-colors hover:bg-muted/30",children:m.jsxs("div",{className:"space-y-1",children:[m.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[m.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[m.jsx("div",{className:"font-mono text-[9px] text-muted-foreground",children:d3(u.timestamp)}),m.jsx(bt,{variant:"outline",className:ve("w-fit text-[9px] font-medium uppercase tracking-[0.14em] px-1.5 py-0",c3[d]),children:u.type})]}),m.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[m.jsx(Gn,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 rounded-[8px] text-muted-foreground",onClick:()=>void s3(f3(u),"Event copied"),"aria-label":`Copy ${u.type} event`,title:"Copy event",children:m.jsx(bE,{className:"h-3 w-3"})}),i&&m.jsx(Gn,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 rounded-[8px] text-muted-foreground hover:text-foreground",onClick:()=>i(u.id),"aria-label":`Dismiss ${u.type} event`,title:"Dismiss event",children:m.jsx(y0,{className:"h-3 w-3"})})]})]}),m.jsx("div",{className:"text-[9px] leading-snug text-foreground/85",children:Mx(u,o)})]})},u.id)})})})}const h3=["node.","election.","transport."],p3="cluster.state";function g3(n){return n.type==="node.status"?!1:h3.some(r=>n.type.startsWith(r))}function v3(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function y3(n,r){return n?{time:v3(n.timestamp),text:Mx(n,r)}:null}function b3(n){return n.transportType==="devtunnel"||!!n.devtunnelEndpoint}function x3(n){if(n.length===0)return"No node tunnel";const r=n.filter(u=>u.status==="offline").length;if(r>0)return`${r} offline`;const o=n.filter(u=>{var d;return((d=u.devtunnelHealth)==null?void 0:d.status)==="failed"}).length;if(o>0)return`${o} failed`;const i=n.filter(u=>{var d;return u.status!=="offline"&&((d=u.devtunnelHealth)==null?void 0:d.status)!=="healthy"}).length;return i>0?`${i} checking`:"Healthy"}function S3(n,r){var u;const o=(r==null?void 0:r.get(n.id))??n.name??n.id;if(n.status==="offline")return{label:o,status:"offline"};const i=((u=n.devtunnelHealth)==null?void 0:u.status)??"checking";return{label:o,status:i}}function w3(n){if(n.length===0)return"No nodes";const r=n.filter(i=>i.status==="offline").length;if(r>0)return`${r} offline`;const o=n.filter(i=>i.status==="busy").length;return o>0?`${o} busy`:"Healthy"}function E3(n,r){return{label:(r==null?void 0:r.get(n.id))??n.name??n.id,status:n.status}}function N3({connected:n,events:r,nodes:o=[],nodeNameById:i,defaultOpen:u=!1}){const[d,f]=y.useState(u),[h,v]=y.useState(!0),[g,x]=y.useState(new Set),p=y.useRef(null),S=y.useMemo(()=>r.filter(k=>g3(k)&&!g.has(k.id)),[r,g]),E=y.useMemo(()=>r.find(k=>k.type===p3)??S[0],[r,S]),R=y.useMemo(()=>y3(E,i),[E,i]),N=y.useMemo(()=>o.filter(b3),[o]),T=N.some(k=>{var q;return k.status==="offline"||((q=k.devtunnelHealth)==null?void 0:q.status)==="failed"}),C=o.some(k=>k.status==="offline"),M=o.some(k=>k.status==="busy"),j=o.length>0;return y.useEffect(()=>{x(k=>{if(k.size===0)return k;const q=new Set(r.map(H=>H.id)),G=new Set(Array.from(k).filter(H=>q.has(H)));return G.size===k.size?k:G})},[r]),y.useEffect(()=>{if(!d)return;const k=G=>{var H;(H=p.current)!=null&&H.contains(G.target)||f(!1)},q=G=>{G.key==="Escape"&&f(!1)};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",q),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",q)}},[d]),m.jsxs("div",{ref:p,className:"relative",children:[m.jsxs("button",{type:"button","aria-expanded":d,"aria-haspopup":"dialog",onClick:()=>f(k=>!k),className:ve("flex items-center gap-1.5 rounded-[16px] border px-2 py-1.5 text-[11px] shadow-sm transition-all sm:gap-2 sm:px-3 sm:py-2 sm:text-xs",n?"border-emerald-500/25 bg-emerald-500/8 text-muted-foreground hover:border-emerald-500/40 hover:bg-emerald-500/12":"border-destructive/25 bg-destructive/8 text-muted-foreground hover:border-destructive/40 hover:bg-destructive/12",d&&"shadow-[0_14px_40px_-26px_rgba(16,185,129,0.95)]"),title:n?"Live link connected":"Live link reconnecting",children:[m.jsx(p0,{className:ve("h-3.5 w-3.5",n?"text-emerald-500":"text-destructive")}),n?"Live link":"Reconnecting"]}),d&&m.jsxs("div",{role:"dialog","aria-label":"Live link connection events",className:"absolute right-0 top-[calc(100%+0.4rem)] z-50 w-[18rem] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-[18px] 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:[m.jsx("div",{className:"border-b border-border/60 bg-muted/25 px-2.5 py-1.5",children:m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[n?m.jsx(Cs,{className:"h-3 w-3 text-emerald-500"}):m.jsx(ZE,{className:"h-3 w-3 text-destructive"}),m.jsx("span",{className:"text-[10px] font-semibold text-foreground",children:"Live link"}),m.jsx("span",{className:"text-[9px] text-muted-foreground",children:n?"· SSE connected":"· reconnecting"})]}),m.jsx("div",{className:ve("rounded-[9px] 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"})]})}),m.jsxs("div",{className:"grid grid-cols-2 border-b border-border/60",children:[m.jsxs("div",{className:"border-r border-border/60 px-2.5 py-1.5",children:[m.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Events"}),m.jsx("div",{className:"mt-0.5 text-base font-semibold tracking-tight text-foreground",children:S.length})]}),m.jsxs("div",{className:"min-w-0 px-2.5 py-1.5",children:[m.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Latest"}),R?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"mt-0.5 truncate text-[9px] leading-snug text-foreground/80",children:R.text}),m.jsx("div",{className:"font-mono text-[8px] text-muted-foreground/60",children:R.time})]}):m.jsx("div",{className:"mt-0.5 text-[8px] text-muted-foreground/50",children:"—"})]})]}),m.jsxs("div",{className:"border-b border-border/60 px-2.5 py-1.5",children:[m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[C?m.jsx(os,{className:"h-3 w-3 shrink-0 text-destructive"}):M?m.jsx(Cs,{className:"h-3 w-3 shrink-0 text-amber-500"}):m.jsx(ko,{className:ve("h-3 w-3 shrink-0",j?"text-emerald-500":"text-muted-foreground")}),m.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Node health"})]}),m.jsx("span",{className:ve("shrink-0 rounded-[8px] border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",C?"border-destructive/30 bg-destructive/10 text-destructive":M?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":j?"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:w3(o)})]}),o.length>0&&m.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:o.map(k=>{const{label:q,status:G}=E3(k,i),H=G==="offline",V=G==="busy";return m.jsxs("div",{"aria-label":`${q} ${G}`,className:ve("flex items-center justify-between gap-2 rounded-[7px] px-2 py-0.5",H?"bg-destructive/6":V?"bg-amber-500/6":"bg-emerald-500/5"),title:`${q} ${G}`,children:[m.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:q}),H?m.jsx(os,{className:"h-3 w-3 shrink-0 text-destructive"}):V?m.jsx(Jg,{className:"h-3 w-3 shrink-0 text-amber-500"}):m.jsx(ko,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},k.id)})})]}),N.length>0&&m.jsxs("div",{className:"border-b border-border/60 px-2.5 py-1.5",children:[m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[T?m.jsx(os,{className:"h-3 w-3 shrink-0 text-destructive"}):m.jsx(ko,{className:"h-3 w-3 shrink-0 text-emerald-500"}),m.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"DevTunnel"})]}),m.jsx("span",{className:ve("shrink-0 rounded-[8px] border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",T?"border-destructive/30 bg-destructive/10 text-destructive":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:x3(N)})]}),m.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:N.map(k=>{var de;const{label:q,status:G}=S3(k,i),H=G==="failed"||G==="offline",V=G!=="healthy"&&G!=="failed"&&G!=="offline",ne=(de=k.devtunnelHealth)!=null&&de.reason?`${q} ${G}: ${k.devtunnelHealth.reason}`:`${q} ${G}`;return m.jsxs("div",{"aria-label":`${q} ${G}`,className:ve("flex items-center justify-between gap-2 rounded-[7px] px-2 py-0.5",H?"bg-destructive/6":V?"bg-muted/30":"bg-emerald-500/5"),title:ne,children:[m.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:q}),H?m.jsx(os,{className:"h-3 w-3 shrink-0 text-destructive"}):V?m.jsx(Jg,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):m.jsx(ko,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},k.id)})})]}),m.jsxs("div",{children:[m.jsxs("button",{type:"button",onClick:()=>v(k=>!k),className:"flex w-full items-center justify-between px-2.5 py-1.5 text-left hover:bg-muted/30",children:[m.jsxs("span",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:["Notifications ",S.length>0&&`(${S.length})`]}),h?m.jsx(Gs,{className:"h-3 w-3 text-muted-foreground"}):m.jsx(uE,{className:"h-3 w-3 text-muted-foreground"})]}),h&&m.jsx("div",{className:"px-2 pb-2",children:m.jsx(m3,{events:S,maxHeight:"12rem",emptyTitle:"No connection events yet",emptyDescription:"Node, election, and system events will appear here.",nodeNameById:i,onDismiss:k=>x(q=>new Set(q).add(k))})})]}),m.jsxs("div",{className:"flex items-center justify-end gap-1 border-t border-border/60 px-2.5 py-1",children:[m.jsx(Gn,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-[9px] px-1.5 text-[9px]",onClick:()=>x(new Set(r.map(k=>k.id))),disabled:S.length===0,title:"Dismiss all notifications",children:"Dismiss all"}),m.jsx(Gn,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-[9px] px-1.5 text-[9px]",onClick:()=>f(!1),children:"Close"})]})]})]})}const Dx=y.createContext(null);function C3({children:n}){const[r,o]=y.useState(()=>typeof window<"u"?localStorage.getItem("meshy-theme")??"system":"system"),[i,u]=y.useState(()=>typeof window<"u"?localStorage.getItem("meshy-palette")??"default":"default");return y.useEffect(()=>{const d=document.documentElement,f=h=>{if(h==="system"){const v=window.matchMedia("(prefers-color-scheme: dark)").matches;d.classList.toggle("dark",v)}else d.classList.toggle("dark",h==="dark")};if(f(r),localStorage.setItem("meshy-theme",r),r==="system"){const h=window.matchMedia("(prefers-color-scheme: dark)"),v=()=>f("system");return h.addEventListener("change",v),()=>h.removeEventListener("change",v)}},[r]),y.useEffect(()=>{const d=document.documentElement;i==="default"?d.removeAttribute("data-palette"):d.setAttribute("data-palette",i),localStorage.setItem("meshy-palette",i)},[i]),m.jsx(Dx.Provider,{value:{theme:r,setTheme:o,palette:i,setPalette:u},children:n})}function T3(){const n=y.useContext(Dx);if(!n)throw new Error("useTheme must be used within ThemeProvider");return n}const R3=[{value:"light",label:"Light",icon:g0},{value:"dark",label:"Dark",icon:h0},{value:"system",label:"System",icon:m0}],A3=[{value:"default",label:"Default",hint:"Porcelain + blue"},{value:"warm",label:"Warm",hint:"Cream + amber"},{value:"finsight",label:"FinSight",hint:"Cool sage green"},{value:"inshield",label:"inShield",hint:"Pure white + navy"},{value:"edge",label:"Edge",hint:"Rounded violet panels"}];function _3(){const{theme:n,setTheme:r,palette:o,setPalette:i}=T3(),[u,d]=y.useState(!1),f=y.useRef(null),h=y.useRef(null),v=n==="dark"?h0:n==="light"?g0:m0,g=()=>{f.current&&(clearTimeout(f.current),f.current=null)},x=()=>{g(),f.current=setTimeout(()=>d(!1),180)};return y.useEffect(()=>{if(!u)return;const p=S=>{h.current&&!h.current.contains(S.target)&&d(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[u]),y.useEffect(()=>()=>g(),[]),m.jsxs("div",{ref:h,className:"relative",onMouseEnter:()=>{g(),d(!0)},onMouseLeave:x,children:[m.jsx(Gn,{variant:"ghost",size:"icon",onClick:()=>d(p=>!p),className:ve("rounded-[16px] border bg-background/70",o==="default"?"border-border/60":"border-primary/60 text-primary"),title:"Appearance","aria-haspopup":"menu","aria-expanded":u,children:m.jsx(v,{className:"h-4 w-4"})}),u&&m.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+8px)] z-50 w-64 rounded-[20px] border border-border/70 bg-popover/95 p-3 text-popover-foreground shadow-[0_24px_80px_-32px_rgba(0,0,0,0.35)] backdrop-blur-xl",children:[m.jsx("div",{className:"px-1 pb-1 text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Theme"}),m.jsx("div",{className:"mb-2 grid grid-cols-3 gap-1",children:R3.map(({value:p,label:S,icon:E})=>{const R=n===p;return m.jsxs("button",{type:"button",onClick:()=>r(p),className:ve("flex flex-col items-center gap-1 rounded-[14px] border px-2 py-2 text-[11px] font-medium transition-colors",R?"border-primary/50 bg-primary/10 text-primary":"border-border/60 text-muted-foreground hover:border-border hover:bg-muted/60 hover:text-foreground"),children:[m.jsx(E,{className:"h-4 w-4"}),S]},p)})}),m.jsxs("div",{className:"mt-2 flex items-center gap-1.5 px-1 pb-1 text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:[m.jsx(GE,{className:"h-3 w-3"}),"Palette"]}),m.jsx("div",{className:"space-y-1",children:A3.map(({value:p,label:S,hint:E})=>{const R=o===p;return m.jsxs("button",{type:"button",onClick:()=>i(p),className:ve("flex w-full items-center gap-2 rounded-[14px] border px-2.5 py-1.5 text-left transition-colors",R?"border-primary/50 bg-primary/10":"border-transparent hover:bg-muted/60"),children:[m.jsx(j3,{value:p}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:ve("text-[12px] font-medium",R?"text-primary":"text-foreground"),children:S}),m.jsx("div",{className:"text-[10px] text-muted-foreground",children:E})]}),R&&m.jsx(uf,{className:"h-3.5 w-3.5 text-primary"})]},p)})})]})]})}function j3({value:n}){const r={default:["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%)"],inshield:["hsl(220 25% 12%)","hsl(0 0% 100%)","hsl(195 80% 55%)"],edge:["hsl(265 75% 55%)","hsl(260 12% 98%)","hsl(285 70% 65%)"]},[o,i,u]=r[n];return m.jsxs("div",{className:ve("flex h-6 w-6 shrink-0 overflow-hidden border border-border/60",n==="edge"?"rounded-[10px]":"rounded-[12px]"),children:[m.jsx("div",{className:"h-full w-1/3",style:{background:o}}),m.jsx("div",{className:"h-full w-1/3",style:{background:i}}),m.jsx("div",{className:"h-full w-1/3",style:{background:u}})]})}function O3(){var v,g;const{cluster:n,events:r,sseConnected:o}=u0(),i=Xn(),[u,d]=y.useState(!1),f=i.pathname==="/"||/^\/tasks\/[^/]+$/.test(i.pathname),h=y.useMemo(()=>{const x=new Map;for(const p of(n==null?void 0:n.nodes)??[])x.set(p.id,p.name);return x},[n==null?void 0:n.nodes]);return m.jsxs("div",{className:"relative h-full overflow-hidden bg-background text-foreground",children:[m.jsx("div",{className:"mesh-grid pointer-events-none absolute inset-0"}),m.jsxs("div",{className:"relative z-10 flex h-full min-h-0 flex-col",children:[m.jsx("header",{className:"relative z-50 shrink-0 px-2 pb-2 pt-3 sm:px-5 sm:pb-3 sm:pt-4 lg:px-6",children:m.jsxs("div",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle mx-auto flex max-w-[1760px] flex-wrap items-center justify-between gap-2 rounded-[22px] px-3 py-2 sm:gap-3 sm:rounded-[24px] sm:px-4 sm:py-3",children:[m.jsx("div",{className:"flex min-w-0 items-center gap-4",children:m.jsxs(o0,{to:"/",className:"flex items-center gap-3",children:[m.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-[15px] border border-border/70 bg-foreground text-xs font-semibold tracking-[0.24em] text-background shadow-sm sm:h-11 sm:w-11 sm:rounded-[17px] sm:text-sm",children:"M"}),m.jsxs("div",{className:"hidden min-w-0 sm:block",children:[m.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.34em] text-muted-foreground",children:"MESHY"}),m.jsx("div",{className:"truncate text-base font-semibold tracking-tight text-foreground",children:"Workspace"})]})]})}),m.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[m.jsxs("div",{className:"hidden items-center gap-2 rounded-[16px] border border-border/70 bg-background/70 px-3 py-2 text-xs text-muted-foreground shadow-sm sm:flex",children:[m.jsxs("span",{className:"flex items-center gap-2",children:[(n==null?void 0:n.self)&&m.jsx(L0,{status:n.self.status}),m.jsx("span",{className:"font-medium text-foreground",children:((v=n==null?void 0:n.self)==null?void 0:v.name)??"offline"})]}),m.jsx("span",{className:"text-border",children:"/"}),m.jsx("span",{className:"capitalize",children:((g=n==null?void 0:n.self)==null?void 0:g.role)??"node"})]}),m.jsx(N3,{connected:o,events:r,nodes:(n==null?void 0:n.nodes)??[],nodeNameById:h}),f&&m.jsx(Gn,{variant:"ghost",size:"icon",onClick:()=>d(x=>!x),"aria-label":u?"Close terminal":"Open terminal",title:u?"Close terminal":"Open terminal",className:ve("rounded-[16px] border bg-background/70 shadow-sm",u?"border-primary/50 bg-primary/10 text-primary":"border-border/70"),children:m.jsx(v0,{className:"h-4 w-4"})}),m.jsx(n3,{}),m.jsx(_3,{})]})]})}),m.jsx("main",{className:ve("min-h-0 flex-1 px-3 pb-3 sm:px-5 lg:px-6",f?"overflow-hidden":"overflow-y-auto"),children:m.jsx("div",{className:"mx-auto h-full min-h-0 max-w-[1760px]",children:m.jsx(W2,{context:{terminalOpen:u,setTerminalOpen:d}})})})]})]})}const Uv=y.lazy(async()=>({default:(await Vv(()=>import("./DashboardPage-D9Y-YlT8.js").then(r=>r.D),__vite__mapDeps([0,1,2,3]))).DashboardPage})),M3=y.lazy(async()=>({default:(await Vv(()=>import("./SharedConversationPage-DaFHobVu.js"),__vite__mapDeps([4,1]))).SharedConversationPage}));function D3(){return m.jsx(Cw,{children:m.jsx(y.Suspense,{fallback:m.jsx(k3,{}),children:m.jsxs(tw,{children:[m.jsx(Rl,{path:"/shared/tasks/:shareId",element:m.jsx(M3,{})}),m.jsxs(Rl,{element:m.jsx(Zw,{children:m.jsx(O3,{})}),children:[m.jsx(Rl,{path:"/",element:m.jsx(Uv,{})}),m.jsx(Rl,{path:"/nodes",element:m.jsx(Pg,{to:"/",replace:!0})}),m.jsx(Rl,{path:"/tasks",element:m.jsx(Pg,{to:"/",replace:!0})}),m.jsx(Rl,{path:"/tasks/:id",element:m.jsx(Uv,{})})]})]})})})}function k3(){return m.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading workspace..."})}function z3(n){return m.jsx(gC,{className:"toaster group",style:{"--normal-bg":"hsl(var(--popover))","--normal-text":"hsl(var(--popover-foreground))","--normal-border":"hsl(var(--border))"},...n})}e2.createRoot(document.getElementById("root")).render(m.jsx(y.StrictMode,{children:m.jsxs(C3,{children:[m.jsx(D3,{}),m.jsx(z3,{})]})}));export{Ls as $,a3 as A,bt as B,uf as C,by as D,GE as E,CE as F,W3 as G,t5 as H,Ax as I,bE as J,s3 as K,i3 as L,pA as M,x_ as N,Wb as O,S_ as P,ws as Q,B_ as R,Nr as S,N_ as T,Es as U,Wd as V,ks as W,y0 as X,zs as Y,Us as Z,Bs as _,bC as a,g_ as a$,Vs as a0,Hs as a1,Vv as a2,P3 as a3,v0 as a4,ko as a5,vE as a6,Z3 as a7,I3 as a8,K3 as a9,k_ as aA,M_ as aB,A_ as aC,__ as aD,O_ as aE,j_ as aF,J3 as aG,C_ as aH,r3 as aI,o_ as aJ,a_ as aK,l_ as aL,n_ as aM,t_ as aN,H3 as aO,q3 as aP,B3 as aQ,Y3 as aR,m_ as aS,f_ as aT,d_ as aU,c_ as aV,u_ as aW,h_ as aX,fE as aY,Bv as aZ,v_ as a_,D_ as aa,p0 as ab,m3 as ac,L0 as ad,EE as ae,qN as af,H_ as ag,l3 as ah,V_ as ai,T_ as aj,R_ as ak,Rx as al,L_ as am,z_ as an,U_ as ao,ef as ap,i_ as aq,s_ as ar,F3 as as,Xw as at,r_ as au,U3 as av,Xn as aw,Fv as ax,L3 as ay,u0 as az,ve as b,p_ as b0,LE as b1,y_ as b2,w_ as b3,b_ as b4,qe as c,z0 as d,V3 as e,xy as f,Sy as g,l5 as h,Gn as i,m as j,G3 as k,Q3 as l,Vw as m,$3 as n,uE as o,E_ as p,X3 as q,y as r,e_ as s,Et as t,jb as u,Lf as v,Ob as w,Uf as x,f0 as y,Gs as z};