1import{y as b,U as N,F as v,j as e,ar as l,ao as f,B as u,ah as x,d as h}from"./index-B9xblx1X.js";import{M as _}from"./MetricGrid-B9fQdybB.js";import{S as p}from"./StatusBadge-CJs5Fb83.js";import{C,b as k,c as S,a as q}from"./card-CK5sTH4r.js";import{S as w}from"./skeleton-DfJRheVQ.js";import"./badge-4Ub-F2rG.js";import"./circle-check-Bam9U-dU.js";import"./triangle-alert-D0ZXp46o.js";function O(){var d,n,m,o,c;const j=b(),{data:a,isLoading:y,error:r}=N({queryKey:["admin","system"],queryFn:()=>x("system"),refetchInterval:3e4}),i=v({mutationFn:s=>x("items.retry",{itemId:s}),onSuccess:async()=>{h.success("Retry queued"),await j.invalidateQueries({queryKey:["admin","system"]})},onError:s=>h.error(s.message)});if(y)return e.jsx("div",{className:"space-y-3",children:Array.from({length:3}).map((s,g)=>e.jsx(w,{className:"h-32"},g))});if(r||!(a!=null&&a.system))return e.jsx("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive",children:r instanceof Error?r.message:"Failed to load system health"});const t=a.system;return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold tracking-tight sm:text-2xl",children:"System health"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Capture queue, failures, and operational signals."})]}),e.jsx(_,{items:[{label:"Queued",value:t.queued},{label:"Processing",value:t.parsing},{label:"Failed 24h",value:t.failed_24h},{label:"Avg duration",value:t.avg_processing_ms==null?"â":`${t.avg_processing_ms} ms`},{label:"Oldest queued",value:t.oldest_queued_at?l(t.oldest_queued_at):"â"},{label:"Storage",value:f(t.storage_bytes)},{label:"Database",value:(d=t.database)!=null&&d.ok?"OK":"Issue"},{label:"Stripe",value:(n=t.config)!=null&&n.stripeConfigured?"Configured":"Not set"},{label:"Webhook",value:(m=t.config)!=null&&m.stripeWebhookConfigured?"Configured":"Not set"},{label:"Build",value:((c=(o=t.deployment)==null?void 0:o.gitSha)==null?void 0:c.slice(0,7))||"â"}]}),e.jsxs(C,{className:"border-border/60 shadow-none",children:[e.jsx(k,{className:"pb-2",children:e.jsx(S,{className:"text-sm",children:"Recent failures"})}),e.jsx(q,{children:(t.recent_failures||[]).length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No recent failures."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden overflow-x-auto md:block",children:e.jsxs("table",{className:"w-full min-w-[800px] text-left text-sm",children:[e.jsx("thead",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"py-2 font-medium",children:"Time"}),e.jsx("th",{className:"py-2 font-medium",children:"Job / item"}),e.jsx("th",{className:"py-2 font-medium",children:"Domain"}),e.jsx("th",{className:"py-2 font-medium",children:"Error"}),e.jsx("th",{className:"py-2 font-medium",children:"Retries"}),e.jsx("th",{className:"py-2 font-medium",children:"State"}),e.jsx("th",{className:"py-2 font-medium"})]})}),e.jsx("tbody",{children:t.recent_failures.map(s=>e.jsxs("tr",{className:"border-t border-border/40 align-top",children:[e.jsx("td",{className:"py-2 text-xs",children:l(s.time)}),e.jsxs("td",{className:"py-2 font-mono text-[11px]",children:[e.jsxs("div",{children:[s.job_id.slice(0,8),"â¦"]}),e.jsxs("div",{className:"text-muted-foreground",children:[s.item_id.slice(0,8),"â¦"]})]}),e.jsx("td",{className:"py-2 text-xs",children:s.domain||"â"}),e.jsx("td",{className:"py-2 max-w-[280px] text-xs text-destructive",children:s.error_type}),e.jsx("td",{className:"py-2 tabular-nums",children:s.retry_count}),e.jsx("td",{className:"py-2",children:e.jsx(p,{status:s.state})}),e.jsx("td",{className:"py-2",children:e.jsx(u,{size:"sm",variant:"outline",className:"h-7 text-xs",disabled:i.isPending,onClick:()=>i.mutate(s.item_id),children:"Retry"})})]},s.job_id))})]})}),e.jsx("div",{className:"space-y-2 md:hidden",children:t.recent_failures.map(s=>e.jsxs("div",{className:"rounded-lg border border-border/60 p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(p,{status:s.state}),e.jsx(u,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>i.mutate(s.item_id),children:"Retry"})]}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:[l(s.time)," · ",s.domain||"â"]}
1),e.jsx("p",{className:"mt-1 text-xs text-destructive",children:s.error_type})]},s.job_id))})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"API usage, rate-limit events, and background worker heartbeats are not persisted in Postgres yet â TODO when those signals exist."})]})}export{O as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.