import{u as d,j as e}from"./query-Bw69rE6b.js";import{a as v,b as N,L as k}from"./react-CQKYBN-P.js";import{D as p,e as m,g as C,h as $,c as w,a as x}from"./index-CoUu6FiM.js";import{P}from"./PageHeader-qtVByY5c.js";import{C as L,a as D,b as q}from"./Card-nuKO-lKR.js";import{E as f}from"./EmptyState-CgO0CCgi.js";function H(){const h=v(),u=N(),a=h.profile??"",s=u.pathname.startsWith("/cat/"),r=d({queryKey:["live-catalogs",a],queryFn:()=>x.liveCatalogs({profile:a}),enabled:!!a&&s,retry:!1}),c=d({queryKey:["live-databases",a],queryFn:()=>x.liveDatabases({profile:a}),enabled:!!a&&!s,retry:!1});if(!a)return e.jsx(f,{icon:p,title:"Pick a profile from the sidebar",description:"Expand a DB profile in the left tree to start browsing."});const i=s?r:c,o=s?r.data?.catalogs??[]:c.data?.databases??[],b=s?r.data?.active_catalog??r.data?.active_project??null:c.data?.active_database??null,g=s?"/cat":"/db",j=s?C:$,l=s?"Catalogs":"Databases",n=s?"catalog":"database";return e.jsxs(e.Fragment,{children:[e.jsx(P,{title:a,breadcrumbs:[{label:"Browse",to:"/"},{label:a}],description:e.jsxs("span",{className:"block text-[11px] uppercase tracking-wider text-ink-dim",children:["Profile · pick a ",n," to drill into"]})}),e.jsxs(L,{children:[e.jsx(D,{title:l,description:i.data?`${o.length} ${n}${o.length===1?"":"s"} reachable.`:void 0}),e.jsx(q,{className:"p-0",children:i.isLoading?e.jsx("ul",{className:"divide-y divide-border",children:Array.from({length:3}).map((t,y)=>e.jsxs("li",{className:"flex items-center gap-3 px-5 py-3",children:[e.jsx(m,{shape:"circle",className:"h-3.5 w-3.5"}),e.jsx(m,{className:"h-3 w-1/3"})]},y))}):i.error?e.jsx("div",{className:"px-5 py-6 text-sm text-critical",children:i.error.message}):o.length?e.jsx("ul",{className:"divide-y divide-border",children:o.map(t=>e.jsx("li",{className:"group flex items-stretch text-sm transition-colors duration-fast hover:bg-surface-subtle/50",children:e.jsxs(k,{to:`${g}/${encodeURIComponent(a)}/${encodeURIComponent(t)}`,className:"flex flex-1 items-center gap-3 px-5 py-2.5",children:[e.jsx(j,{size:14,className:"text-accent"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-ink",children:t}),b===t&&e.jsx("span",{className:w("shrink-0 rounded bg-accent-soft px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide text-accent-ink"),title:`Profile is pinned to ${t}`,children:"active"})]})},t))}):e.jsx("div",{className:"px-5 py-5",children:e.jsx(f,{icon:p,title:`No ${l.toLowerCase()} reachable`,description:`The profile's connector returned no ${n}s. Check credentials or the profile configuration under Settings.`,compact:!0})})})]})]})}export{H as default};
