import{r as m,j as e}from"./vendor-tanstack-BpuysabX.js";import{c as u}from"./cronstrue-B5bn720s.js";import{X as j,Y as f,H as i,Z as p,b4 as v,c4 as c,bM as l,bN as o,bO as d,az as g,cK as T,f as $}from"./index-CREafGO4.js";import{f as S,Z as w}from"./vendor-date-C1t37jsh.js";import{u as y}from"./use-is-overflowing-Cq93g4co.js";const x=({schedule:a,...r})=>{const{schedule:n}=a;if("cron"in n)return e.jsx(N,{schedule:n,active:a.active,...r});if("interval"in n)return e.jsx(z,{schedule:n,active:a.active,...r});if("rrule"in n)return e.jsx(B,{schedule:n,active:a.active,...r})},N=({active:a,schedule:r,...n})=>{const t=u.toString(r.cron),s=`${a?"":"(Paused)"} ${t} (${r.timezone})`;return e.jsx(c,{children:e.jsxs(l,{children:[e.jsx(o,{children:e.jsx(i,{variant:"secondary",className:`${a?"":"opacity-50"}`,...n,children:e.jsx("span",{className:"truncate",children:t})})}),e.jsx(d,{children:s})]})})},z=({active:a,schedule:r,...n})=>{const t=`Every ${g(T(r.interval)*1e3)}`;let s=`${a?"":"(Paused)"} ${t}`;return r.anchor_date&&(s+=` using ${S(new Date(r.anchor_date),"MMM do, yyyy 'at' hh:mm:ss aa")} (${r.timezone}) as the anchor date`),e.jsx(c,{children:e.jsxs(l,{children:[e.jsx(o,{children:e.jsx(i,{variant:"secondary",className:`${a?"":"opacity-50"}`,...n,children:e.jsx("span",{className:"truncate",children:t})})}),e.jsx(d,{children:s})]})})},B=({active:a,schedule:r,...n})=>{const t=w(r.rrule).toText(),s=$(t),h=`${a?"":"(Paused)"} ${s} (${r.timezone})`;return e.jsx(c,{children:e.jsxs(l,{children:[e.jsx(o,{children:e.jsx(i,{variant:"secondary",className:`${a?"":"opacity-50"}`,...n,children:e.jsx("span",{className:"truncate",children:s})})}),e.jsx(d,{children:h})]})})},P=({schedules:a,className:r})=>{const n=m.useRef(null),t=y(n);return!a||a.length===0?null:t?e.jsx("div",{className:v("flex flex-row gap-2 items-center no-wrap",r),children:e.jsxs(j,{children:[e.jsx(f,{children:e.jsxs(i,{variant:"secondary",className:"whitespace-nowrap",children:[a.length," schedules"]})}),e.jsx(p,{className:"flex flex-col flex-wrap gap-1 w-fit",children:a.map(s=>e.jsx(x,{schedule:s},s.id))})]})}):e.jsx("div",{className:"flex flex-row gap-2 items-center no-wrap",ref:n,children:a.map(s=>e.jsx(x,{schedule:s,className:"max-w-28"},s.id))})};export{P as S};
//# sourceMappingURL=index-B4IVsJnG.js.map
