import{M as v}from"./MkPagination-DzUgufpZ.js";import{X as g}from"./MkNotification-DuBjKjip.js";import{_ as N}from"./MkDateSeparatedList.vue_vue_type_style_index_0_lang-87CjANkN.js";import{M as h}from"./MkNote-RPFbRjy2.js";import{B as d,c as k,b as T,$ as p,_ as b}from"./app-QjDgb7aF.js";import{b as M,c as R,o as q,g as a,i as l,k as x,q as u,u as r,D as B,a as C,f as X,j as c}from"./vue-Cm77DuTi.js";const O={class:"_fullinfo"},S=["src"],$=M({__name:"MkNotifications",props:{includeTypes:{},unreadOnly:{type:Boolean}},setup(m){const o=m,i=C(),f={endpoint:"i/notifications",limit:10,params:X(()=>({includeTypes:o.includeTypes??void 0,excludeTypes:o.includeTypes?void 0:p.mutingNotificationTypes,unreadOnly:o.unreadOnly}))},y=t=>{const e=o.includeTypes?!o.includeTypes.includes(t.type):p.mutingNotificationTypes.includes(t.type);(e||document.visibilityState==="visible")&&d.send("readNotification",{id:t.id}),e||i.value.prepend({...t,isRead:document.visibilityState==="visible"})};let n;return R(()=>{n=d.useChannel("main"),n.on("notification",y),n.on("readAllNotifications",()=>{if(i.value){for(const t of i.value.queue)t.isRead=!0;for(const t of i.value.items)t.isRead=!0}}),n.on("readNotifications",t=>{if(i.value){for(let e=0;e<i.value.queue.length;e++)t.includes(i.value.queue[e].id)&&(i.value.queue[e].isRead=!0);for(let e=0;e<(i.value.items||[]).length;e++)t.includes(i.value.items[e].id)&&(i.value.items[e].isRead=!0)}})}),q(()=>{n&&n.dispose()}),(t,e)=>(c(),a(v,{ref_key:"pagingComponent",ref:i,pagination:f},{empty:l(()=>[u("div",O,[u("img",{src:r(k).images.info,class:"_ghost",alt:"Info"},null,8,S),u("div",null,B(r(T).ts.noNotifications),1)])]),default:l(({items:_})=>[x(N,{class:"elsfgstc",items:_,"no-gap":!0},{default:l(({item:s})=>[["reply","quote","mention"].includes(s.type)?(c(),a(h,{key:s.id,note:s.note,collapsedReply:s.type==="reply"||s.type==="mention"&&s.note.replyId!=null},null,8,["note","collapsedReply"])):(c(),a(g,{key:s.id,notification:s,"with-time":!0,full:!0,class:"_panel notification"},null,8,["notification"]))]),_:1},8,["items"])]),_:1},512))}}),P=b($,[["__scopeId","data-v-de468fb4"]]);export{P as X};
//# sourceMappingURL=MkNotifications-3MvKmBnV.js.map
