import{c as O,a as s,f as i}from"../chunks/vfPE-AD7.js";import{i as $,p as se,o as oe,c as ie,g as a,e as v,f as d,d as E,s as ne,u as I,n as z,r as o,t as A}from"../chunks/DhUiKsxN.js";import{s as D}from"../chunks/Dsv8gxIT.js";import{l as le,b as ve,i as R}from"../chunks/DUil1G3I.js";import{I as de,a as fe,e as G}from"../chunks/QNXDtpsh.js";import{s as n}from"../chunks/SjYvl9yQ.js";import{p as S}from"../chunks/DEcqogKB.js";import"../chunks/CwpRVHMW.js";import{P as J,a as K}from"../chunks/D0aYus9O.js";import{B as F}from"../chunks/BWzyK28a.js";import"../chunks/1jpszzm8.js";function ce(k,M){const c=le(M,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const L=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}],["path",{d:"M8 16H3v5"}]];de(k,ve({name:"refresh-cw"},()=>c,{get iconNode(){return L},children:(x,N)=>{var p=O(),b=$(p);fe(b,M,"default",{}),s(x,p)},$$slots:{default:!0}}))}var pe=i("<!> Refresh",1),_e=i("<!> New Profile",1),he=i('<div class="text-center py-12 text-muted-foreground">Loading servers...</div>'),me=i('<div class="text-center py-12 text-red-500"> </div>'),ge=i('<div class="text-center py-8 text-muted-foreground bg-white dark:bg-gray-800 rounded-lg border">No servers running. Start a profile to begin.</div>'),ue=i('<div class="space-y-4"></div>'),$e=i('<section><h2 class="text-lg font-semibold mb-4"> </h2> <div class="space-y-4"></div></section>'),xe=i("<!> Create Your First Profile",1),be=i('<div class="text-center py-12"><p class="text-muted-foreground mb-4">No profiles configured yet.</p> <!></div>'),ye=i('<section><h2 class="text-lg font-semibold mb-4"> </h2> <!></section> <!> <!>',1),Pe=i('<div class="space-y-6"><div class="flex items-center justify-between"><h1 class="text-2xl font-bold">Server Dashboard</h1> <div class="flex gap-2"><!> <!></div></div> <!></div>');function ze(k,M){se(M,!0);let c=ne(!1);oe(()=>{n.refresh(),S.refresh();const e=setInterval(()=>n.refresh(),5e3);return()=>clearInterval(e)});async function L(){E(c,!0),await Promise.all([n.refresh(),S.refresh()]),E(c,!1)}const x=I(()=>S.profiles.filter(e=>n.isRunning(e.id))),N=I(()=>S.profiles.filter(e=>!n.isRunning(e.id)));var p=Pe(),b=v(p),H=d(v(b),2),Y=v(H);F(Y,{variant:"outline",onclick:L,get disabled(){return a(c)},children:(e,_)=>{var f=pe(),y=$(f);{let B=I(()=>a(c)?"animate-spin":"");ce(y,{get class(){return`w-4 h-4 mr-2 ${a(B)??""}`}})}z(),s(e,f)},$$slots:{default:!0}});var Q=d(Y,2);F(Q,{href:"/profiles/new",children:(e,_)=>{var f=_e(),y=$(f);J(y,{class:"w-4 h-4 mr-2"}),z(),s(e,f)},$$slots:{default:!0}}),o(H),o(b);var T=d(b,2);{var U=e=>{var _=he();s(e,_)},V=e=>{var _=O(),f=$(_);{var y=h=>{var m=me(),P=v(m,!0);o(m),A(()=>D(P,n.error)),s(h,m)},B=h=>{var m=ye(),P=$(m),C=v(P),W=v(C);o(C);var X=d(C,2);{var Z=r=>{var t=ge();s(r,t)},ee=r=>{var t=ue();G(t,21,()=>a(x),l=>l.id,(l,g)=>{{let w=I(()=>n.getServer(a(g).id));K(l,{get profile(){return a(g)},get server(){return a(w)}})}}),o(t),s(r,t)};R(X,r=>{a(x).length===0?r(Z):r(ee,!1)})}o(P);var q=d(P,2);{var re=r=>{var t=$e(),l=v(t),g=v(l);o(l);var w=d(l,2);G(w,21,()=>a(N),u=>u.id,(u,j)=>{K(u,{get profile(){return a(j)}})}),o(w),o(t),A(()=>D(g,`Available Profiles (${a(N).length??""})`)),s(r,t)};R(q,r=>{a(N).length>0&&r(re)})}var te=d(q,2);{var ae=r=>{var t=be(),l=d(v(t),2);F(l,{href:"/profiles/new",children:(g,w)=>{var u=xe(),j=$(u);J(j,{class:"w-4 h-4 mr-2"}),z(),s(g,u)},$$slots:{default:!0}}),o(t),s(r,t)};R(te,r=>{S.profiles.length===0&&r(ae)})}A(()=>D(W,`Running Servers (${a(x).length??""})`)),s(h,m)};R(f,h=>{n.error?h(y):h(B,!1)},!0)}s(e,_)};R(T,e=>{n.loading&&n.servers.length===0?e(U):e(V,!1)})}o(p),s(k,p),ie()}export{ze as component};
