1import{V as K,u as W,aU as X,e as Y,c as p,aX as G,b2 as J,a as r,b as h,k as t,m as y,p as g,j as l,F as x,n as B,b3 as O,y as Z,v as R,Q as T,ec as tt,b6 as et,b4 as at,o as a,l as A,de as it,q as I,_ as P,fU as ot,U as st,fA as nt}from"./DvgxvNL0.js";import{B as rt}from"./CIc5UpU6.js";import{m as lt,N as ct,f as dt,g as ut}from"./Cc82Urnl.js";import{_ as ft}from"./BdoLP461.js";import{C as pt}from"./Bl8aBdQp.js";import"./Dcw-4ZSv.js";import"./CwfuRisP.js";import"./B9FvJp-L.js";import"./Cvyrctwg.js";import"./Dt8Hubkr.js";import"./BEQ0QmdP.js";import"./DG1csYqL.js";import"./C0jx6QEY.js";import"./DfQlAftT.js";import"./CdqRIBwd.js";import"./BlSIKElK.js";import"./BYO7PYqm.js";import"./Blht4sEL.js";const ht={class:"universal-card"},mt={class:"header__row"},vt={class:"header__title"},yt={key:0,class:"text-2xl"},gt={key:1,class:"text-2xl"},_t={key:2},bt={key:5},kt={class:"flex justify-end"},wt={__name:"notifications",async setup(Nt){let _,C;const{formatMessage:o}=W(),n=st({historyLabel:{id:"dashboard.overview.notifications.history.label",defaultMessage:"History"},notificationHistoryTitle:{id:"dashboard.overview.notifications.history.title",defaultMessage:"Notification history"},viewHistory:{id:"dashboard.overview.notifications.button.view-history",defaultMessage:"View history"},markAllAsRead:{id:"dashboard.overview.notifications.button.mark-all-as-read",defaultMessage:"Mark all as read"},loadingNotifications:{id:"dashboard.overview.notifications.loading",defaultMessage:"Loading notifications..."},errorLoadingNotifications:{id:"dashboard.overview.notifications.error.loading",defaultMessage:"Error loading notifications:"},noUnreadNotifications:{id:"dashboard.overview.notifications.empty.no-unread",defaultMessage:"You don't have any unread notifications."}}),w=X(),b=([_,C]=Y(()=>et()),_=await _,C(),_),$=at(),j=tt(),c=p(()=>$.name==="dashboard-notifications-history");G({title:()=>`${o(c.value?n.notificationHistoryTitle:A.notificationsLabel)} - Modrinth`});const d=T("all"),m=T(1),k=T(50),{data:v,isPending:F,error:V,refetch:L}=J({queryKey:p(()=>["user",b.value?.user?.id,"notifications",m.value,c.value,d.value]),queryFn:async()=>{const u=m.value-1,e=c.value,N=(await w.labrinth.notifications_v2.getUserNotifications(b.value?.user?.id)).filter(s=>!s.type?.startsWith("shared_instance_")),M=[...new Set(N.filter(s=>e||!s.read).map(s=>s.type))],U=N.filter(s=>(d.value==="all"||s.type===d.value)&&(e||!s.read)),Q=Math.max(1,Math.ceil(U.length/k.value));return dt(w,U.slice(u*k.value,u*k.value+k.value)).then(s=>({notifications:s,notifTypes:M.length>1?["all",...M]:M,pages:Q,hasRead:N.some(z=>z.read)}))},enabled:p(()=>!!b.value?.user?.id),placeholderData:{notifications:[],notifTypes:[],pages:1,hasRead:!1}}),f=p(()=>v.value?ut(v.value.notifications):[]),H=p(()=>v.value?.notifTypes||[]),q=p(()=>v.value?.pages??1);function D(){j.push(c.value?"/dashboard/notifications":"/dashboard/notifications/history"),d.value="all",m.value=1}async function E(){const u=f.value.flatMap(e=>[e.id,...e.grouped_notifs?e.grouped_notifs.map(i=>i.id):[]]);await lt(w,u),await L()}function S(u){m.value=u,window.scrollTo({top:0,behavior:"smooth"})}return(u,e)=>(a(),r("div",null,[h("section",ht,[t(c)?(a(),y(rt,{key:0,"current-title":t(o)(t(n).historyLabel),"link-stack":[{href:"/dashboard/notifications",label:t(o)(t(A).notificationsLabel)}]},null,8,["current-title","link-stack"])):g("",!0),h("div",mt,[h("div",vt,[t(c)?(a(),r("h2",yt,l(t(o)(t(n).notificationHistoryTitle)),1)):(a(),r("h2",gt,l(t(o)(t(A).notificationsLabel)),1))]),t(c)?g("",!0):(a(),r(x,{key:0},[t(v).hasRead?(a(),y(t(P),{key:0,onClick:e[0]||(e[0]=i=>D())},{default:B(()=>[R(t(it)),I(" "+l(t(o)(t(n).viewHistory)),1)]),_:1})):g("",!0),t(f).length>0?(a(),y(t(P),{key:1,type:"colored",color:"red",onClick:e[1]||(e[1]=i=>E())},{default:B(()=>[R(t(ot)),I(" "+l(t(o)(t(n).markAllAsRead)),1)]),_:1})):g("",!0)],64))]),t(H).length>1?(a(),y(t(pt),{key:1,modelValue:t(d),"onUpdate:modelValue":e[2]||(e[2]=i=>O(d)?d.value=i:null),items:t(H),"format-label":i=>i==="all"?"All":t(nt)(i).replace("_"," ")+"s",capitalize:!1},null,8,["modelValue","items","format-label"])):g("",!0),t(F)?(a(),r("p",_t,l(t(o)(t(n).loadingNotifications)),1)):t(V)?(a(),r(x,{key:3},[h("p",null,l(t(o)(t(n).errorLoadingNotifications)),1),h("pre",null," "+l(t(V))+` 2 `,1)],64)):t(f)&&t(f).length>0?(a(!0),r(x,{key:4},Z(t(f),i=>(a(),y(ct,{key:i.id,notifications:t(f),class:"universal-card recessed",notification:i,auth:t(b),raised:"","onUpdate:notifications":e[3]||(e[3]=()=>t(L)())},null,8,["notifications","notification","auth"]))),128)):(a(),r("p",bt,l(t(o)(t(n).noUnreadNotifications)),1)),h("div",kt,[R(t(ft),{page:t(m),count:t(q),onSwitchPage:S},null,8,["page","count"])])])]))}},Et=K(wt,[["__scopeId","data-v-8e5bdc8d"]]);export{Et 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.