1import{u as M,r as o,aG as $,j as e,L as N,K as w,h as P,a7 as R,aL as q,g as B,s as F}from"./index-BOoZFuWa.js";import{u as G,a as H}from"./app-shell-BjcDR96W.js";import{S as O}from"./sliders-horizontal-CVOUW4xt.js";import{C as W}from"./check-check-CADZvJGf.js";import{B as K}from"./bell-off-CehGxVTb.js";import"./bell-heW9z5p5.js";import"./arrow-right-BB--XxhS.js";import"./at-sign-O0OVfKsi.js";import"./tier-badge-BS_ot_P_.js";import"./feedback.functions-52mFnH9m.js";import"./star-7QRc-wM9.js";import"./gift-B_HBNbrl.js";import"./users-CZw1mlml.js";import"./user-plus-B99o8SMc.js";import"./trophy-1OJ8FeBL.js";import"./crown-Daal2D_2.js";import"./shield-check-D7xSLGV9.js";import"./info-Cf7MgNsT.js";import"./search-DLg3s1M3.js";import"./house-C5aSFVfe.js";import"./list-checks-Cv4-dcGV.js";import"./shopping-bag-CcD19NSf.js";import"./megaphone-UorZ1h2H.js";import"./chevron-down-DNuUnLmP.js";function ge(){const{items:p,markRead:v,markAllRead:C,unread:_,remove:z,clearAll:A}=G(),{user:x}=M(),[u,f]=o.useState([]),[d,g]=o.useState(!1),[h,S]=o.useState(!1),b=30,r=o.useMemo(()=>{const s=new Set,t=[];for(const a of[...p,...u])s.has(a.id)||(s.add(a.id),t.push(a));return t},[p,u]),L=async()=>{if(!x||d||h)return;g(!0);const s=r[r.length-1]?.created_at;let t=F.from("notifications").select("*").eq("user_id",x.id).order("created_at",{ascending:!1}).limit(b);s&&(t=t.lt("created_at",s));const{data:a}=await t,c=a||[];c.length<b&&S(!0),f(E=>[...E,...c]),g(!1)},{filter:l}=$({from:"/app/notifications"}),[n,j]=o.useState(l??"all");o.useEffect(()=>{l&&j(l)},[l]);const k=r.filter(s=>s.type==="task_tag").length,m=r.filter(s=>n==="all"?!0:s.type==="task_tag"),T=Date.now(),y=1440*60*1e3,i={today:[],week:[],earlier:[]};for(const s of m){const t=T-new Date(s.created_at).getTime();t<y?i.today.push(s):t<7*y?i.week.push(s):i.earlier.push(s)}const D=[{key:"today",label:"Today"},{key:"week",label:"This week"},{key:"earlier",label:"Earlier"}];return e.jsxs("div",{className:"mx-auto max-w-md",children:[e.jsx(H,{back:!0,title:"Notifications",subtitle:"Activity & alerts"}),e.jsx("div",{className:"px-5 mt-1 mb-2 flex gap-2 text-xs font-semibold overflow-x-auto no-scrollbar",children:[["all",`All (${r.length})`],["tagged",`Tagged${k?` (${k})`:""}`]].map(([s,t])=>e.jsx("button",{onClick:()=>j(s),className:`shrink-0 px-3 py-1.5 rounded-full border transition whitespace-nowrap ${n===s?"bg-foreground text-background border-foreground":"bg-card text-muted-foreground border-border"}`,children:t},s))}),e.jsxs("div",{className:"px-5 mb-3 flex items-center gap-3 justify-end",children:[e.jsxs(N,{to:"/app/follow-alerts",className:"mr-auto inline-flex items-center gap-1 text-[11px] font-semibold text-primary",children:[e.jsx(O,{className:"size-3.5"})," Manage notifications"]}),_>0&&e.jsxs("button",{onClick:()=>C(),className:"inline-flex items-center gap-1 text-[11px] font-semibold text-primary",children:[e.jsx(W,{className:"size-3.5"})," Mark all read"]}),r.length>0&&e.jsxs("button",{onClick:()=>{confirm("Clear all notifications? This can't be undone.")&&(A(),f([]),P.success("Notifications cleared"))},className:"inline-flex items-center gap-1 text-[11px] font-semibold text-destructive",children:[e.jsx(w,{className:"size-3.5"})," Clear all"]})]}),!m.length&&e.jsx(R,{icon:K,title:n==="tagged"?"No tags yet":"All caught up",description:n==="tagged"?"When someone tags you on a task, it'll show up here.":"We'll ping you when something happens."}),e.jsxs("div",{className:"px-3 space-y-4 pb-6",children:[D.map(s=>i[s.key].length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"px-2 mb-1.5 text-[11px] font-bold uppercase tracking-wider text-muted-foreground",children:s.label}),e.jsx("ul",{className:"space-y-1",children:i[s.key].map(t=>{const a=e.jsxs("div",{className:`flex-1 min-w-0 px-4 py-3 rounded-2xl ${t.read?"bg-card":"bg-primary-soft/30 border border-primary/20"} shadow-soft`,children:[e.jsxs("p",{className:"font-semibold text-sm flex items-center gap-2",children:[!t.read&&e.jsx("span",{className:"size-1.5 rounded-full bg-primary"}),t.title]}),t.body&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t.body}),t.image_url&&e.jsx("img",{src:t.image_url,alt:"",loading:"lazy",className:"mt-2 w-full max-h-56 object-cover rounded-xl bg-muted"}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:q(t.created_at)})]});return e.jsxs("li",{className:"flex items-stretch gap-1.5",children:[e.jsx("div",{className:"flex-1 min-w-0",onClick:()=>v(t.id),children:t.link?/^https?:\/\//i.test(t.link)?e.jsx("a",{href:t.link,target:"_blank",rel:"noopener noreferrer",children:a}):e.jsx(N,{to:t.link,children:a}):a}),e.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),z(t.id)},"aria-label":"Delete notification",className:"shrink-0 size-9 self-center rounded-full bg-card border border-border text-muted-foreground hover:text-destructive flex items-center justify-center",children:e.jsx(w,{className:"size-4"})})]},t.id)})})]},s.key)),m.length>0&&!h&&e.jsx("div",{className:"pt-2 flex justify-center",children:e.jsx("button",{onClick:L,disabled:d,className:"rounded-full bg-card border border-border px-4 py-2 text-xs font-semibold text-muted-foreground inline-flex items-center gap-1.5",children:d?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"size-3.5 animate-spin"}),"Loadingâ¦"]}):"Load older"})})]})]})}export{ge as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.