import{n as w,a as v,b as D,d as y,u as k,e as K,j as e,k as M,B as d,T as E,S as L,f as q,g as A,h as F,i as V,l as h,m as b}from"./index-DXI13nSQ.js";import{r as x}from"./react-Cb2sDjhD.js";import{D as _}from"./data-table-BVcXWtPw.js";import{E as Q}from"./empty-state-WHzNYVaT.js";import{S as $}from"./status-badge-DeESb2dc.js";import{C as H}from"./confirm-dialog-_BtUs6oW.js";import{D as U,a as Z,b as G,c as J,d as W,e as X}from"./dialog-BVYFRXlI.js";import{u as Y}from"./useQuery-CEwGD94N.js";import{L as ee}from"./loader-circle-BS5FFFg-.js";import{R as se}from"./refresh-ccw-BPKXoMZa.js";import{B as te}from"./bell-DifbuUaI.js";import"./table-oUi0mGOn.js";import"./arrow-up-DtrvOH7Z.js";import"./arrow-down-OdSfpgG4.js";import"./x-OHUicFfn.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ae=w("BellOff",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ne=w("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]),C={all:["reminders"],list:s=>["reminders","list",s]};function ie(s){return Y({queryKey:C.list(s),queryFn:()=>y.listReminders(s),refetchInterval:5e3,refetchIntervalInBackground:!1})}function re(){const s=v();return D({mutationFn:a=>y.cancelReminder(a),onSuccess:()=>s.invalidateQueries({queryKey:C.all})})}function le(){const s=v();return D({mutationFn:({id:a,body:i})=>y.snoozeReminder(a,i),onSuccess:()=>s.invalidateQueries({queryKey:C.all})})}const oe=["pending","firing","fired","cancelled","failed"],ce=[{duration:"5m",i18nKey:"snooze.preset5m"},{duration:"30m",i18nKey:"snooze.preset30m"},{duration:"1h",i18nKey:"snooze.preset1h"},{duration:"1d",i18nKey:"snooze.preset1d"}];function ke(){const{t:s}=k(["reminders","common"]),[a,i]=K(),r=a.get("status")??"pending",l=x.useMemo(()=>({status:r,limit:200}),[r]),{data:o,isLoading:z,isFetching:N,refetch:T}=ie(l),P=o?.reminders??[],m=re(),c=le(),[f,S]=x.useState(null),[p,g]=x.useState(null);function R(t){const n=new URLSearchParams(a);for(const[u,j]of Object.entries(t))j==null||j===""?n.delete(u):n.set(u,j);i(n,{replace:!0})}async function O(){if(f!=null)try{await m.mutateAsync(f),h.success(s("toast.cancelled"))}catch(t){const{message:n}=b(t,s);throw h.error(n),t}}async function I(t){if(p!=null)try{await c.mutateAsync({id:p,body:{duration:t}}),h.success(s("snooze.toastOk",{duration:t})),g(null)}catch(n){const{message:u}=b(n,s);h.error(u)}}const B=x.useMemo(()=>[{id:"id",header:s("col.id"),cell:t=>e.jsxs("span",{className:"tabular-nums text-text-dim",children:["#",t.id]}),headClassName:"w-16"},{id:"fireAt",header:s("col.fireAt"),cell:t=>e.jsx("span",{className:"font-medium tabular-nums",children:me(t.fire_at)}),headClassName:"w-40"},{id:"text",header:s("col.text"),cell:t=>e.jsx("span",{className:"line-clamp-2 text-text-dim",children:t.text}),asCardTitle:!0},{id:"status",header:s("col.status"),cell:t=>e.jsx($,{status:t.status,children:s(`status.${t.status}`,{defaultValue:t.status})}),headClassName:"w-28"},{id:"platform",header:s("col.platform"),cell:t=>e.jsx("span",{className:"text-text-dim",children:t.platform}),headClassName:"w-24",hideOnMobile:!0},{id:"recurrence",header:s("col.recurrence"),cell:t=>t.recurrence_label?e.jsx(M,{variant:"info",children:t.recurrence_label}):e.jsx("span",{className:"text-text-muted",children:"—"}),headClassName:"w-36",hideOnMobile:!0},{id:"source",header:s("col.source"),cell:t=>e.jsx("span",{className:"text-text-dim",children:s(`source.${t.source}`,{defaultValue:t.source})}),headClassName:"w-24",hideOnMobile:!0},{id:"actions",header:"",cell:t=>t.status==="pending"?e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsxs(d,{variant:"ghost",size:"sm",onClick:n=>{n.stopPropagation(),g(t.id)},disabled:c.isPending||m.isPending,children:[e.jsx(ne,{className:"h-3 w-3"}),s("action.snooze")]}),e.jsxs(d,{variant:"outline",size:"sm",onClick:n=>{n.stopPropagation(),S(t.id)},disabled:m.isPending||c.isPending,children:[e.jsx(ae,{className:"h-3 w-3"}),s("action.cancel")]})]}):null,headClassName:"w-48"}],[s,m.isPending,c.isPending]);return e.jsxs("div",{className:"flex min-h-dvh flex-col bg-bg",children:[e.jsx(E,{}),e.jsxs("main",{className:"mx-auto flex w-full max-w-7xl flex-1 flex-col gap-4 px-3 py-4 sm:px-4 pb-safe",children:[e.jsxs("header",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("h1",{className:"text-xl font-semibold",children:s("pageTitle")}),e.jsxs(d,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>T(),disabled:N,"aria-label":s("actions.refresh",{ns:"common"}),children:[N?e.jsx(ee,{className:"h-4 w-4 animate-spin"}):e.jsx(se,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s("actions.refresh",{ns:"common"})})]})]}),e.jsx("p",{className:"text-sm text-text-dim",children:s("subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("label",{className:"text-sm text-text-dim",htmlFor:"status-filter",children:s("filter.status")}),e.jsxs(L,{value:r,onValueChange:t=>R({status:t}),children:[e.jsx(q,{id:"status-filter",className:"w-[160px]",children:e.jsx(A,{})}),e.jsx(F,{children:oe.map(t=>e.jsx(V,{value:t,children:s(`status.${t}`,{defaultValue:t})},t))})]})]}),e.jsx(_,{columns:B,rows:P,getRowId:t=>String(t.id),loading:z,emptyState:e.jsx(Q,{icon:e.jsx(te,{}),title:s("empty.title"),description:s("empty.description")})}),e.jsx(H,{open:f!=null,onOpenChange:t=>{t||S(null)},title:s("action.confirmCancel"),description:s("action.confirmCancelDesc"),intent:"danger",confirmLabel:s("action.cancel"),onConfirm:O}),e.jsx(de,{open:p!=null,busy:c.isPending,onOpenChange:t=>{t||g(null)},onPick:I})]})]})}function de({open:s,busy:a,onOpenChange:i,onPick:r}){const{t:l}=k(["reminders","common"]);return e.jsx(U,{open:s,onOpenChange:a?()=>{}:i,children:e.jsxs(Z,{children:[e.jsxs(G,{children:[e.jsx(J,{children:l("snooze.title")}),e.jsx(W,{children:l("snooze.description")})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ce.map(o=>e.jsx(d,{type:"button",variant:"outline",disabled:a,onClick:()=>void r(o.duration),children:l(o.i18nKey)},o.duration))}),e.jsx(X,{children:e.jsx(d,{type:"button",variant:"secondary",disabled:a,onClick:()=>i(!1),children:l("actions.cancel",{ns:"common"})})})]})})}function me(s){try{const a=new Date(s);if(Number.isNaN(a.getTime()))return s;const i=new Date;return a.toDateString()===i.toDateString()?a.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):a.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return s}}export{ke as default};
//# sourceMappingURL=reminders-CP2qtNSr.js.map
