import{a as e,n as t,r as n}from"./useStore-CusP06SD.js";import{L as r}from"./sidebar-y9WJu7Jw.js";import{t as i}from"./Page-C7KClZ28.js";import{t as a}from"./button-1cIaa9Lf.js";import{t as o}from"./createLucideIcon-zYRS_Hrv.js";import{t as s}from"./check-CUrWQ2C7.js";import{d as c,u as l}from"./index-DinSQfHc.js";import{t as u}from"./badge-hukNSIir.js";import{a as d,i as f,n as p,o as m,r as h,t as g}from"./table-B1Y18B60.js";import{t as _}from"./time-DjUFOA4D.js";var v=o(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),y=e(n()),b=t();function x(){let e=r(),[t,n]=(0,y.useState)(new Set),{data:o}=c(e.jobs.getJobStatuses.queryOptions(void 0,{refetchInterval:5e3})),{mutate:x}=l(e.jobs.triggerJob.mutationOptions({onSuccess:(e,{name:t})=>{n(e=>new Set(e).add(t)),setTimeout(()=>{n(e=>{let n=new Set(e);return n.delete(t),n})},3e3)},onError:e=>{console.error(`Failed to trigger job:`,e.message)}})),S=e=>e.isActive?(0,b.jsx)(u,{variant:`default`,className:`bg-blue-500`,children:`Running`}):e.nextExecution===`now`?(0,b.jsx)(u,{variant:`secondary`,children:`Ready`}):(0,b.jsx)(u,{variant:`outline`,children:`Scheduled`}),C=e=>e.split(/(?=[A-Z])/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `);return(0,b.jsx)(i,{children:(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-lg border`,children:(0,b.jsxs)(g,{children:[(0,b.jsx)(d,{className:`bg-muted sticky top-0 z-10`,children:(0,b.jsxs)(m,{className:`border-b`,children:[(0,b.jsx)(f,{children:`Name`}),(0,b.jsx)(f,{children:`Interval`}),(0,b.jsx)(f,{children:`Last Execution`}),(0,b.jsx)(f,{children:`Next Execution`}),(0,b.jsx)(f,{children:`Status`}),(0,b.jsx)(f,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(p,{children:o?.map(e=>(0,b.jsxs)(m,{children:[(0,b.jsx)(h,{className:`font-medium`,children:C(e.name)}),(0,b.jsx)(h,{children:e.interval}),(0,b.jsx)(h,{children:e.lastExecution?_(e.lastExecution):`Never`}),(0,b.jsx)(h,{children:e.nextExecution===`now`?`Now`:_(e.nextExecution)}),(0,b.jsx)(h,{children:S(e)}),(0,b.jsx)(h,{className:`text-right`,children:(0,b.jsx)(a,{variant:`outline`,size:`sm`,disabled:e.isActive||!e.canRunNow,onClick:()=>x({name:e.name}),children:t.has(e.name)?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(s,{className:`mr-1 h-4 w-4 text-green-600`}),`Started`]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(v,{className:`mr-1 h-4 w-4`}),`Run`]})})})]},e.name))})]})})})}export{x as component};