1import{u as $,ak as P,p as T,z as E,k as p,j as r}from"./Do214wVL.js";function I(){const s=$(),i=E().public.apiBase,a=P("notifications.unread",()=>0),o=r(null),h=r(!1),l=r(null),u=r(1),c=r(20),f=r(!1);function v(){return s.token?{Authorization:`Bearer ${s.token}`}:{}}async function d(){if(!s.token){l.value="ë¡ê·¸ì¸ì´ íìí©ëë¤.";return}h.value=!0,l.value=null;try{const e={page:u.value,size:c.value};f.value&&(e.unread=!0);const t=await $fetch("/members/me/notifications",{method:"GET",baseURL:i,headers:v(),params:e});o.value=t,a.value=t.unreadCount}catch(e){l.value=e?.data?.message??"ì림ì ë¶ë¬ì¤ì§ 못íìµëë¤."}finally{h.value=!1}}async function w(){if(!s.token){a.value=0;return}try{const e=await $fetch("/members/me/notifications",{method:"GET",baseURL:i,headers:v(),params:{page:1,size:1}});a.value=e.unreadCount}catch{}}async function y(e){if(!s.token)return;const t=o.value?.items.find(n=>n.id===e)??null,m=!!(t&&!t.readAt);t&&m&&(t.readAt=new Date().toISOString(),a.value=Math.max(0,a.value-1));try{await $fetch(`/members/me/notifications/${e}/read`,{method:"POST",baseURL:i,headers:v()})}catch{t&&m&&(t.readAt=null,a.value=a.value+1)}}async function k(){if(!s.token)return;const e=o.value?o.value.items.filter(n=>!n.readAt).map(n=>({item:n,prev:n.readAt})):[],t=a.value,m=new Date().toISOString();for(const{item:n}of e)n.readAt=m;a.value=0;try{await $fetch("/members/me/notifications/read-all",{method:"POST",baseURL:i,headers:v()})}catch{for(const{item:n,prev:O}of e)n.readAt=O;a.value=t}}function A(e){const t=g.value;e<1||e>t||e===u.value||(u.value=e,d(),typeof window<"u"&&window.scrollTo({top:0,behavior:"smooth"}))}function S(e){e<=0||e===c.value||(c.value=e,u.value=1,d())}function b(e){f.value!==e&&(f.value=e,u.value=1,d())}const z=p(()=>o.value?.items??[]),C=p(()=>o.value?.meta.totalElements??0),g=p(()=>o.value?.meta.totalPages??1);return T(()=>s.token,e=>{e||(a.value=0,o.value=null)}),{items:z,data:o,unreadCount:a,loading:h,error:l,page:u,size:c,unreadOnly:f,totalElements:C,totalPages:g,fetchList:d,refreshUnreadCount:w,markRead:y,markAllRead:k,setPage:A,setSize:S,setUnreadOnly:b}}export{I as u};
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.