import{j as e,a as m}from"./vendor-react-C9dYU-TK.js";import{B as x,C as j,c as p,S as o,u as g,l as w}from"./index-BMBS6scK.js";import{C as N,i as y,Q as v,a7 as b,o as k,a0 as C,W as R}from"./vendor-icons-BSV6HBy1.js";import{s as f}from"./socialService-686c7vsx.js";import"./vendor-CjLUfV8Y.js";import"./vendor-security-DsrNJhpn.js";import"./vendor-router-Dr0ZB7zf.js";import"./vendor-tanstack-C4XaEYj2.js";import"./vendor-http-CctT3C58.js";import"./vendor-utils-D0JLFg89.js";import"./vendor-motion-CbAtAbUE.js";import"./vendor-i18n-PN7w4axr.js";function A({onMarkAllRead:s,onClearAll:t}){return e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-end gap-4 mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-heading font-bold text-foreground mb-1",children:"Notifications"}),e.jsx("p",{className:"text-muted-foreground font-mono text-xs",children:"NETWORK ACTIVITY"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(x,{variant:"outline",size:"sm",onClick:s,className:"border-primary/20 hover:bg-primary/10 text-primary",children:[e.jsx(N,{className:"w-4 h-4 mr-2"})," Mark all read"]}),e.jsxs(x,{variant:"outline",size:"sm",onClick:t,className:"border-destructive/20 hover:bg-destructive/10 text-destructive",children:[e.jsx(y,{className:"w-4 h-4 mr-2"})," Clear"]})]})]})}const S=["all","unread","mentions"];function V({filter:s,onFilterChange:t,count:r}){return e.jsxs(j,{variant:"glass",className:"p-2 flex items-center justify-between border-white/5 bg-black/40",children:[e.jsx("div",{className:"flex gap-1",children:S.map(a=>e.jsx(x,{variant:s===a?"default":"ghost",size:"sm",onClick:()=>t(a),className:"capitalize",children:a},a))}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground px-2",children:[e.jsx(v,{className:"w-3 h-3"})," ",r," items"]})]})}function E(){return e.jsxs("div",{className:"text-center py-24 rounded-2xl border border-dashed border-white/10 text-muted-foreground bg-black/20",children:[e.jsx(b,{className:"w-12 h-12 mx-auto mb-4 opacity-20"}),e.jsx("p",{children:"No new signals detected."})]})}function T({notification:s,onRead:t}){const r=s.type==="like"?e.jsx(k,{className:"w-4 h-4"}):s.type==="follow"?e.jsx(C,{className:"w-4 h-4"}):e.jsx(R,{className:"w-4 h-4"}),a=s.type==="like"?"bg-destructive/10 text-destructive":s.type==="follow"?"bg-success/10 text-success":"bg-primary/10 text-primary";return e.jsxs(j,{variant:"glass",className:p("p-4 flex gap-4 transition-all hover:bg-white/5",!s.read&&"border-l-2 border-l-primary bg-primary/5"),children:[e.jsx("div",{className:p("p-2 rounded-full h-fit",a),children:r}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-foreground mb-1",children:s.message}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(s.timestamp).toLocaleString()})]}),!s.read&&e.jsx(x,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 rounded-full hover:bg-primary/20 text-primary",onClick:()=>t(s.id),children:e.jsx(N,{className:"w-4 h-4"})})]})}function F(){return e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6 pb-20 container px-4 py-8 min-h-layout-page",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-end gap-4 mb-2",children:[e.jsxs("div",{children:[e.jsx(o,{className:"h-9 w-48 mb-2"}),e.jsx(o,{className:"h-4 w-32"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(o,{className:"h-9 w-28"}),e.jsx(o,{className:"h-9 w-20"})]})]}),e.jsx(o,{className:"h-12 w-full rounded-xl"}),e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(s=>e.jsx(o,{className:"h-20 w-full rounded-xl"},s))})]})}function M(s){const{addToast:t}=g(),[r,a]=m.useState(s??[]),[i,u]=m.useState("all"),[h,c]=m.useState(s===void 0);m.useEffect(()=>{if(s!==void 0)return;(async()=>{try{c(!0);const n=await f.getNotifications();a(n.notifications??[])}catch(n){w.error("Error loading notifications",{error:n})}finally{c(!1)}})()},[s]);const d=r.filter(l=>i==="unread"?!l.read:i==="mentions"?l.type==="mention"||l.type==="like"||l.type==="follow":!0);return{notifications:r,filter:i,setFilter:u,loading:h,filtered:d,handleRead:async l=>{a(r.map(n=>n.id===l?{...n,read:!0}:n))},handleMarkAllRead:async()=>{a(r.map(l=>({...l,read:!0}))),await f.markAllRead(),t("All notifications marked as read","success")},handleClearAll:()=>{a([]),t("Notifications cleared","info")}}}function J({initialNotifications:s}={}){const{filter:t,setFilter:r,loading:a,filtered:i,handleRead:u,handleMarkAllRead:h,handleClearAll:c}=M(s);return a?e.jsx(F,{}):e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6 pb-20 container px-4 py-8 min-h-layout-page",children:[e.jsx(A,{onMarkAllRead:h,onClearAll:c}),e.jsx(V,{filter:t,onFilterChange:r,count:i.length}),e.jsx("div",{className:"space-y-2",children:i.length===0?e.jsx(E,{}):i.map(d=>e.jsx(T,{notification:d,onRead:u},d.id))})]})}export{J as NotificationsView};