1import{e as V,u as B,m as f,R as H,j as e,V as G}from"./index-CiCw9Duq.js";import{r as o}from"./vendor-i18n-BBu7i065.js";import{u as I,L as w}from"./vendor-react-BL5zx_iT.js";import{g as O}from"./notification-grouping-DdPywy3u.js";import{u as P}from"./use-document-meta-RQbJsPUf.js";import{N as W}from"./PostSkeleton-DI9Lh4Fi.js";import{A as Y,_ as Z,c as q,n as J,bB as k,d as K,au as Q,G as $,aa as X,Z as ee,w as te,ai as se}from"./vendor-ui-Ct1FBp4w.js";import"./vendor-solana-BIelvPCZ.js";import"./vendor-supabase-DbyvBBOg.js";function xe(){const N=I(),{user:i}=V(),{theme:S}=B(),a=S==="light",[l,h]=o.useState([]),[_,p]=o.useState(!0),[y,j]=o.useState(!1),[n,A]=o.useState("all");P({title:"Notifications",description:"Your latest activity on LimitlessFlo: likes, replies, follows, and more.",noindex:!0});const g=o.useCallback(async()=>{if(i?.id)try{p(!0);const t=await f.getNotifications(i.id,50);h(t)}catch(t){console.error("Failed to fetch notifications:",t)}finally{p(!1)}},[i?.id]);o.useEffect(()=>{i&&g()},[i,g]),o.useEffect(()=>{if(!i?.id||l.length===0||!l.some(s=>!s.read))return;const r=setTimeout(async()=>{try{await f.markAllAsRead(i.id),h(s=>s.map(c=>({...c,read:!0})))}catch(s){console.error("Failed to auto-mark as read:",s)}},1500);return()=>clearTimeout(r)},[i?.id,l]),H(g,i?.id||"");const M=async t=>{try{await f.markAsRead(t),h(r=>r.map(s=>s.id===t?{...s,read:!0}:s))}catch(r){console.error("Failed to mark as read:",r)}},C=async()=>{if(!(!i?.id||y)){j(!0);try{await f.markAllAsRead(i.id),h(t=>t.map(r=>({...r,read:!0})))}catch(t){console.error("Failed to mark all as read:",t)}finally{j(!1)}}},R=t=>{switch(t){case"like":return e.jsx(se,{className:"w-5 h-5 text-pink-500",fill:"currentColor"});case"reply":case"mention":return e.jsx(te,{className:"accent-tinted w-5 h-5 text-sky-500"});case"repost":return e.jsx(ee,{className:"w-5 h-5 text-green-500"});case"follow":return e.jsx(X,{className:"accent-tinted w-5 h-5 text-sky-500"});case"purchase":return e.jsx($,{className:"w-5 h-5 text-emerald-500"});case"tip":return e.jsx($,{className:"w-5 h-5 text-green-400"});case"message":return e.jsx(Q,{className:"w-5 h-5 text-sky-400"});case"moderation_block":return e.jsx(K,{className:"w-5 h-5 text-amber-500"});default:return e.jsx(k,{className:`w-5 h-5 ${a?"text-gray-400":"text-white/50"}`})}},T=(t,r)=>{switch(t){case"like":return"liked your post";case"reply":return"replied to your post";case"repost":return"reposted your post";case"follow":return"followed you";case"purchase":return"purchased your content";case"tip":return"sent you a tip";case"mention":return"mentioned you";case"message":return"sent you a message";default:return""}},F=t=>{const r=t.actor?.username||"Someone",s=t.actor,c=s?.verified||s?.is_lifetime_member||s?.is_diamond_member||s?.account_type==="business",d=T(t.type,t.content);if(t.type==="moderation_block")return e.jsxs("span",{className:a?"text-gray-600":"text-white/70",children:[e.jsx("strong",{className:`font-semibold ${a?"text-amber-600":"text-amber-400"}`,children:"Content blocked by moderation."}),t.content&&e.jsxs(e.Fragment,{children:[" ",t.content]})]});const m=c?e.jsx("span",{className:"inline-flex align-[-3px]",children:e.jsx(G,{size:"xs",username:r,accountType:s?.account_type,isPrime:s?.is_diamond_member})}):null;return e.jsxs(e.Fragment,{children:[e.jsxs("strong",{className:`font-semibold ${a?"text-gray-900":"text-white"}`,children:["@",r]}),m&&e.jsxs(e.Fragment,{children:[" ",m]}),e.jsxs("span",{className:a?"text-gray-600":"text-white/70",children:[" ",d]}),t.type==="tip"&&t.content&&e.jsxs("span",{className:"text-green-500 font-semibold",children:[" ",t.content]})]})},L=t=>{const r=new Date(t),c=new Date().getTime()-r.getTime(),d=Math.floor(c/6e4),m=Math.floor(c/36e5),x=Math.floor(c/864e5);return d<1?"now":d<60?`${d}m`:m<24?`${m}h`:x<7?`${x}d`:r.toLocaleDateString("en-US",{month:"short",day:"numeric"})},U=t=>t.type==="message"?"/messages":t.post_id?`/post/${t.post_id}`:t.type==="follow"&&t.actor?.username?`/profile/${t.actor.username}`:"#",v=o.useMemo(()=>{const t=new Set,r=l.filter(s=>t.has(s.id)?!1:(t.add(s.id),n==="all"?!0:n==="verified"?!!(s.actor?.verified||s.actor?.is_lifetime_member||s.actor?.is_diamond_member):n==="mentions"?s.type==="mention"||s.type==="reply":n==="like
1s"?s.type==="like":n==="reposts"?s.type==="repost":n==="follows"?s.type==="follow":n==="moderation"?s.type==="moderation_block":!1));return O(r)},[l,n]),b=o.useMemo(()=>l.filter(t=>!t.read).length,[l]),[z,E]=o.useState(""),u=o.useMemo(()=>({current:new Set}),[]);o.useEffect(()=>{const t=l.filter(r=>!u.current.has(r.id));u.current.size>0&&t.length>0&&E(t.length===1?`New notification from @${t[0].actor?.username||"someone"}`:`${t.length} new notifications`),l.forEach(r=>u.current.add(r.id))},[l,u]);const D=o.useMemo(()=>[{id:"all",label:"All"},{id:"verified",label:"Verified"},{id:"mentions",label:"Mentions"},{id:"likes",label:"Likes"},{id:"reposts",label:"Reposts"},{id:"follows",label:"Follows"},{id:"moderation",label:"Moderation"}],[]);return o.useEffect(()=>{i||p(!1)},[i]),e.jsxs("div",{className:`min-h-screen ${a?"bg-gray-50":"bg-black"}`,children:[e.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:z}),e.jsxs("div",{className:`max-w-2xl mx-auto border-x ${a?"border-gray-200":"border-white/[0.08]"}`,children:[e.jsxs("div",{className:`sticky top-0 z-40 backdrop-blur-xl border-b ${a?"bg-white/95 border-gray-200":"bg-black/95 border-white/[0.06]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 h-14",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>N(-1),className:`p-2 -ml-2 rounded-full transition-colors ${a?"hover:bg-gray-100":"hover:bg-white/[0.08]"}`,"aria-label":"Go back",children:e.jsx(Y,{className:`w-5 h-5 ${a?"text-gray-900":"text-white"}`})}),e.jsxs("div",{children:[e.jsx("h1",{className:`text-xl font-bold ${a?"text-gray-900":"text-white"}`,children:"Notifications"}),b>0&&e.jsxs("p",{className:`text-xs ${a?"text-gray-500":"text-white/50"}`,children:[b," unread"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[i&&b>0&&e.jsxs("button",{onClick:C,disabled:y,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-sky-500 hover:bg-sky-500/10 rounded-full transition-colors disabled:opacity-50",children:[y?e.jsx(Z,{className:"w-4 h-4 animate-spin"}):e.jsx(q,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Mark all read"})]}),e.jsx("button",{onClick:()=>N("/settings/notifications"),className:`p-2 rounded-full transition-colors ${a?"hover:bg-gray-100":"hover:bg-white/[0.08]"}`,"aria-label":"Notification settings",children:e.jsx(J,{className:`w-5 h-5 ${a?"text-gray-500":"text-white/60"}`})})]})]}),e.jsx("div",{className:`flex border-b overflow-x-auto scrollbar-hide ${a?"border-gray-200":"border-white/[0.08]"}`,children:D.map(t=>e.jsxs("button",{onClick:()=>A(t.id),className:`flex-1 min-w-fit px-3 sm:px-4 py-3 text-sm font-medium transition-colors relative whitespace-nowrap ${n===t.id?a?"text-gray-900":"text-white":a?"text-gray-500 hover:text-gray-700 hover:bg-gray-50":"text-white/50 hover:text-white/70 hover:bg-white/[0.03]"}`,children:[t.label,n===t.id&&e.jsx("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 w-10 sm:w-14 h-1 bg-sky-500 rounded-full"})]},t.id))})]}),e.jsx("div",{className:"min-h-[50vh]",children:_?e.jsx(W,{isLight:a,count:6}):v.length===0?e.jsxs("div",{className:"text-center py-16 px-4",children:[e.jsx(k,{className:`w-12 h-12 mx-auto mb-4 ${a?"text-gray-300":"text-white/20"}`}),e.jsx("h3",{className:`text-lg font-semibold mb-2 ${a?"text-gray-900":"text-white"}`,children:i?n==="all"?"No notifications yet":`No ${n}`:"Stay in the loop"}),e.jsx("p",{className:`text-sm max-w-xs mx-auto ${a?"text-gray-500":"text-white/40"}`,children:i?n==="all"?"When someone interacts with your posts, you'll see it here.":`You don't have any ${n} notifications yet.`:"Sign in to get notified about likes, replies, follows and more."}),!i&&e.jsx(w,{to:"/auth",className:"inline-block mt-6 px-6 py-2.5 bg-sky-500 hover:bg-sky-600 text-white font-semibold rounded-full transition-colors",children:"Sign In"})]}):e.jsx("div",{children:v.map(t=>{const r=t.primary,s=r.actor?.username,c=s?`/profile/${s}`:null,d=()=>{t.items.filter(x=>!x.read).forEach(x=>M(x.id))},m=r.type==="tip"&&t.tipSummary&&t.tipSummary.count>1;return e.jsxs("div",{className:`relative flex items-start gap-3 px-4 py-4 border-b transition-colors ${a?`border-gray-100 hover:bg-gray-50 ${t.hasUnread?"bg-sky-50":""}`:`border-white/[0.04] hover:bg-white/[0.02] ${t.hasUnread?"bg-sky-500/[0.04]":""}`}`,children:[e.jsx("div",{className:"flex-shrink-0 w-8 flex justify-center pt-1 relative z-[1]",children:R(r.type)}),e.jsx("div",{className:"flex-shrink-0 relative z-[2]",children:c?e.jsx(w,{to:c,onClick:d,"aria-label":`View @${s}'s profile`,className:"block w-10 h-10 rounded-full overflow-hidden hover:opacity-90 transition-opacity",children:e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center overflow-hidden ${a?"bg-gray-100":"bg-gray-800"}`,children:r.actor?.avatar?.startsWith("http")?e.jsx("img",{src:r.actor.avatar,alt:"",className:"w-full h-full object-cover",loading:"lazy",decoding:"async"}):e.jsx("span",{className:`text-sm font-semibold ${a?"text-gray-900":"text-white"}`,children:r.actor?.username?.[0]?.toUpperCase()||"?"})})}):e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center overflow-hidden ${a?"bg-gray-100":"bg-gray-800"}`,children:e.jsx("span",{className:`text-sm font-semibold ${a?"text-gray-900":"text-white"}`,children:r.actor?.username?.[0]?.toUpperCase()||"?"})})}),e.jsx(w,{to:U(r),onClick:d,"aria-label":"Open notification",className:"absolute inset-0 z-[1]"}),e.jsxs("div",{className:"flex-1 min-w-0 relative z-[1] pointer-events-none",children:[e.jsx("div",{className:"text-[15px] leading-snug",children:m?e.jsxs(e.Fragment,{children:[e.jsxs("strong",{className:`font-semibold ${a?"text-gray-900":"text-white"}`,children:["@",s||"Someone"]}),e.jsxs("span",{className:a?"text-gray-600":"text-white/70",children:[" ","sent you"," "]}),e.jsxs("span",{className:`font-semibold ${a?"text-gray-900":"text-white"}`,children:["Ã",t.tipSummary.count]}),e.jsxs("span",{className:a?"text-gray-600":"text-white/70",children:[" ","tips"]}),t.tipSummary.display&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:a?"text-gray-400":"text-white/40",children:[" ","·"," "]}),e.jsx("span",{className:"text-green-500 font-semibold",children:t.tipSummary.display})]})]}):F(r)}),e.jsx("div",{className:`text-sm mt-1 ${a?"text-gray-400":"text-white/40"}`,children:L(r.created_at)})]}),t.hasUnread&&e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-sky-500 flex-shrink-0 mt-2 relative z-[1]"})]},t.key)})})})]})]})}export{xe as default};
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.