import{E as e,b as t,t as n,y as r}from"./jsx-runtime-DLhMyTcm.js";import{t as i}from"./createLucideIcon-BkDu6nzg.js";import{n as a,t as o}from"./StatCard-BMr_SHN6.js";import{t as s}from"./zap-BWlR9dm3.js";import{t as c}from"./use-document-meta-Bjf8eIPh.js";import{a as l,c as u,i as d,n as f,o as p,r as m,t as h}from"./table-CCNPbiUy.js";import{a as g,i as _,n as v,o as y,t as b}from"./TimeAgo-CqesrrWG.js";import{t as x}from"./TriggerBadge-BeFRVz4z.js";var S=i(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),C=i(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),w=n();function T({stats:e}){return(0,w.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,w.jsx)(o,{label:`Total Runs`,value:e.total_runs,icon:S,iconClassName:`bg-blue-100 text-blue-600 dark:bg-blue-950 dark:text-blue-400`}),(0,w.jsx)(o,{label:`Success Rate`,value:y(e.success_rate_percent),icon:C,iconClassName:`bg-emerald-100 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400`}),(0,w.jsx)(o,{label:`Active`,value:e.active_runs,icon:s,iconClassName:`bg-amber-100 text-amber-600 dark:bg-amber-950 dark:text-amber-400`}),(0,w.jsx)(o,{label:`Total Cost`,value:_(e.total_cost_usd),icon:a,iconClassName:`bg-violet-100 text-violet-600 dark:bg-violet-950 dark:text-violet-400`})]})}function E({runs:e}){return(0,w.jsxs)(`div`,{className:`mt-8`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,w.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Recent Runs`}),(0,w.jsx)(t,{to:`/runs`,className:`text-sm text-blue-600 hover:text-blue-700`,children:`View All`})]}),e.length===0?(0,w.jsx)(`div`,{className:`text-center py-12 text-muted-foreground border rounded-lg bg-muted/20`,children:`No runs yet. Trigger a workflow to see results here.`}):(0,w.jsx)(`div`,{className:`rounded-lg border`,children:(0,w.jsxs)(h,{children:[(0,w.jsx)(l,{children:(0,w.jsxs)(p,{children:[(0,w.jsx)(d,{children:`Status`}),(0,w.jsx)(d,{children:`Workflow`}),(0,w.jsx)(d,{children:`Trigger`}),(0,w.jsx)(d,{children:`Duration`}),(0,w.jsx)(d,{children:`Cost`}),(0,w.jsx)(d,{children:`Started`})]})}),(0,w.jsx)(f,{children:e.map(e=>(0,w.jsxs)(p,{className:`hover:bg-muted/50`,children:[(0,w.jsx)(m,{children:(0,w.jsx)(v,{status:e.status})}),(0,w.jsx)(m,{children:(0,w.jsx)(t,{to:`/runs/${e.id}`,className:`hover:underline`,children:e.workflow_name})}),(0,w.jsx)(m,{children:(0,w.jsx)(x,{trigger:e.trigger})}),(0,w.jsx)(m,{children:g(e.duration_ms)}),(0,w.jsx)(m,{children:_(e.cost_usd)}),(0,w.jsx)(m,{children:(0,w.jsx)(b,{date:e.started_at||e.created_at})})]},e.id))})]})})]})}async function D(){let[e,t]=await Promise.all([r.get(`/stats`),r.get(`/runs?page=1&per_page=5`)]);return{stats:e.data,recentRuns:t.data}}function O(){let{stats:t,recentRuns:n}=e();return c({title:`Dashboard`,description:`Overview of your workflow executions.`}),(0,w.jsx)(u,{title:`Dashboard`,description:`Overview of your workflow executions.`,children:(0,w.jsxs)(`div`,{className:`space-y-6`,children:[(0,w.jsx)(T,{stats:t}),(0,w.jsx)(E,{runs:n})]})})}export{O as Component,D as loader};