import{r as e,j as s}from"./vendor-react-Dp9pL_Wn.js";import{aL as t,aM as a,aN as n,aO as l,aP as i,aQ as r,aR as d,aj as x,aS as o}from"./c6eedc03a-CsEFTfjy.js";import{aV as c,aW as u,aX as m}from"./index-CBEPphRm.js";import{u as p,M as j}from"./vendor-intl-D2wGIp4M.js";function f({isScheduledDuringPeakHours:e,peakHoursWindowPst:s,variant:a}){return p(),t(),null}function h(e){return!e.enabled&&!!e.fireAt&&!!e.lastRunAt}const g="group relative flex h-28 flex-col justify-between p-3 rounded-lg bg-bg-100 ring-1 ring-inset ring-border-300 hover:bg-bg-200 outline-none focus-visible:shadow-focus transition-colors text-left text-sm no-underline cursor-pointer",N="inline-flex items-center gap-1 h-[18px] max-w-[8rem] px-1.5 rounded bg-bg-300 text-xs text-text-300 shrink-0 truncate";e.memo(({scheduledTask:t,detailRoutePrefix:b,displayName:w,contextLabel:v,scheduleTextFallback:k,triggerCount:M=0,sourceBadge:A,statusOverride:H,onClick:P})=>{const R=p(),S="string"==typeof v?[v]:v,y=e.useMemo(()=>a(t.cronExpression,Math.round((t.jitterSeconds??0)/60),R,t.fireAt),[t.cronExpression,t.jitterSeconds,t.fireAt,R]),C=t.enabled?t.fireAt&&!t.lastRunAt?n(new Date(t.fireAt),R,"future"):l(i(t.cronExpression),t.nextRunAt,Math.round((t.jitterSeconds??0)/60),R):null,F=!C&&t.enabled&&t.lastRunAt?n(new Date(t.lastRunAt),R,"past"):null,z=H??(t.enabled?null:h(t)?"completed":"paused"),D=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium text-text-100 truncate",children:w??r(t.id)}),s.jsx(f,{variant:"icon",isScheduledDuringPeakHours:t.isScheduledDuringPeakHours,peakHoursWindowPst:t.peakHoursWindowPst}),S&&S.length>0&&s.jsx("span",{className:`${N} ml-auto`,title:S.join("\n"),children:S.length>1?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"truncate",children:S[0].split("/").pop()}),s.jsx("span",{className:"shrink-0 text-text-500",children:s.jsx(j,{defaultMessage:"+{n}",id:"gxFSojQzTJ",values:{n:S.length-1}})})]}):S[0].split("/").pop()}),"local"===A&&s.jsxs("span",{className:N,children:[s.jsx(c,{size:12}),s.jsx(j,{defaultMessage:"Local",id:"W4SaxYXWRk"})]}),"remote"===A&&s.jsxs("span",{className:N,children:[s.jsx(u,{size:12}),s.jsx(j,{defaultMessage:"Cloud",id:"fiPvwYljok"})]})]}),s.jsxs("div",{className:"text-text-400 font-small",children:[y||k||"\xa0",M>1&&s.jsx("span",{className:"ml-1.5 text-text-500",children:s.jsx(j,{defaultMessage:"+{n} more",id:"Fo49VHwJiZ",values:{n:M-1}})})]})]}),s.jsxs("div",{className:"flex items-center justify-between text-text-400 font-small",children:[s.jsx("span",{children:C?t.fireAt?s.jsx(j,{defaultMessage:"Runs at: {when}",id:"Ncpy/sig/G",values:{when:s.jsx("span",{className:"text-text-200",children:C})}}):s.jsx(j,{defaultMessage:"Next run: {when}",id:"tXnyVYHFxs",values:{when:s.jsx("span",{className:"text-text-200",children:C})}}):F?s.jsx(j,{defaultMessage:"Last run: {when}",id:"4AXNTH5eDF",values:{when:s.jsx("span",{className:"text-text-200",children:F})}}):"\xa0"}),"paused"===z&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-text-300",children:[s.jsx(m,{size:12}),s.jsx(j,{defaultMessage:"Paused",id:"C2iTEHtK//"})]}),"completed"===z&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-text-300",children:[s.jsx(d,{size:12}),s.jsx(j,{defaultMessage:"Ran",id:"+CuLVSpi4n"})]}),"auto-disabled"===z&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-danger-000",children:[s.jsx(x,{size:12}),s.jsx(j,{defaultMessage:"Auto-disabled",id:"oKQHGunEG3"})]})]})]});return P?s.jsx("button",{type:"button",onClick:P,className:g,children:D}):s.jsx(o,{href:b?`${b}/${encodeURIComponent(t.id)}`:"#",className:g,children:D})}).displayName="ScheduledTaskCard";export{f as P,h as i};
