import{d as c,r,j as e,A as v,m as b,a as i}from"./app-vYFZLebK.js";const u=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],y=c("bell",u);const N=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],f=c("check",N);const g=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],k=c("database",g);const j=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],_=c("shield",j);function S(){const[s,n]=r.useState([]),[l,d]=r.useState(!1),[x,o]=r.useState(0),h=async()=>{try{const t=await i.get("/api/notifications");n(t.data),o(t.data.filter(a=>!a.read_at).length)}catch(t){console.error(t)}};r.useEffect(()=>{h();const t=setInterval(h,3e4);return()=>clearInterval(t)},[]);const m=async t=>{try{await i.put(`/api/notifications/${t}/read`),n(s.map(a=>a.id===t?{...a,read_at:new Date().toISOString()}:a)),o(a=>Math.max(0,a-1))}catch{}},p=async()=>{try{await i.put("/api/notifications/read-all"),n(s.map(t=>({...t,read_at:new Date().toISOString()}))),o(0)}catch{}};return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>d(!l),className:"relative p-2 text-[var(--text-muted)] hover:text-[var(--text-main)] transition-colors",children:[e.jsx(y,{size:20}),x>0&&e.jsx("span",{className:"absolute top-1 right-1 w-2.5 h-2.5 bg-rose-500 rounded-full border-2 border-[var(--bg-surface)]"})]}),e.jsx(v,{children:l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>d(!1)}),e.jsxs(b.div,{initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:"absolute right-0 mt-2 w-80 bg-[var(--bg-surface)] border border-[var(--border)] rounded-xl shadow-2xl z-50 overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-[var(--border)] flex justify-between items-center bg-[var(--bg-elevated)]",children:[e.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-[var(--text-main)]",children:"Notifications"}),x>0&&e.jsx("button",{onClick:p,className:"text-[9px] font-bold text-cyan-500 hover:underline",children:"Mark_All_Read"})]}),e.jsx("div",{className:"max-h-80 overflow-y-auto",children:s.length>0?s.map(t=>e.jsx("div",{className:`p-4 border-b border-[var(--border)] last:border-0 hover:bg-[var(--bg-elevated)] transition-colors ${t.read_at?"":"bg-cyan-500/5"}`,children:e.jsxs("div",{className:"flex justify-between items-start gap-3",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("p",{className:"text-xs font-bold text-[var(--text-main)]",children:t.data?.message||"New Notification"}),e.jsx("p",{className:"text-[9px] text-[var(--text-muted)]",children:new Date(t.created_at).toLocaleString()})]}),!t.read_at&&e.jsx("button",{onClick:()=>m(t.id),className:"text-cyan-500 hover:text-cyan-400",children:e.jsx(f,{size:14})})]})},t.id)):e.jsx("div",{className:"p-8 text-center text-[var(--text-muted)] text-xs",children:"No_New_Signals"})})]})]})})]})}export{k as D,S as N,_ as S};
