1import{_ as S,G as E,K as p,H as F,M as B,O as I,c as a,a as i,f as y,t as l,x as T,F as d,g,m as k,ak as V,o as s,n as x,k as A,W as f,Y as j,Z as z,e as w,aW as C,h as O}from"./app-JECN6kol.js";const R={id:"page__notifications"},H={class:"container"},P={class:"bt"},W={key:0,class:"list__notifications"},Y=["id"],G={class:"icon"},K={key:0,src:"/img/anounce_icon.png",alt:"icon",class:"avatar-icon"},Z=["src"],q={key:3,src:"/img/anounce_icon.png",alt:"icon",class:"avatar-icon"},J={class:"message"},Q={key:0},U=["href"],X={key:1},ee=["href"],te={class:"date"},ae={class:"actions-group"},se=["onClick","title","aria-label"],ne=["onClick","title","aria-label"],oe={key:1,class:"empty-state"},ie={key:2,class:"pagination"},le=["onClick"],re={key:3,class:"actions"},ce={__name:"NotificationsView",setup(de){const _=E(),r=p([]),h=p(1),m=p(1),M=F(()=>_.params.locale||"lv"),c=n=>T(n,M.value);function N(n){try{const e=new Date(n);if(isNaN(e.getTime()))return n;const t=String(e.getDate()).padStart(2,"0"),o=String(e.getMonth()+1).padStart(2,"0"),u=e.getFullYear();return`${t}.${o}.${u}`}catch{return n}}async function v(n=1){try{const{data:e}=await k.get(`/api/notifications?page=${n}`);r.value=e.data,h.value=e.current_page,m.value=e.last_page,V(()=>{b()})}catch(e){console.error("Failed to fetch notifications",e)}}function b(){if(_.hash){const n=document.getElementById(_.hash.substring(1));n&&(n.scrollIntoView({behavior:"smooth",block:"center"}),n.classList.add("highlight-pulse"),setTimeout(()=>{n.classList.remove("highlight-pulse")},3e3))}}B(()=>_.hash,()=>{b()});async function L(n){try{await k.delete(`/api/notifications/${n}`),r.value=r.value.filter(e=>e.id!==n),r.value.length===0&&h.value>1?v(h.value-1):r.value.length===0&&v(1)}catch(e){console.error(e)}}async function $(n){try{await k.post(`/api/notifications/${n}/read`);const e=r.value.find(t=>t.id===n);e&&(e.read_at=new Date().toISOString()),window.dispatchEvent(new Event("notifications-updated"))}catch(e){console.error(e)}}async function D(){try{await k.post("/api/notifications/read-all"),r.value.forEach(n=>n.read_at=new Date().toISOString()),window.dispatchEvent(new Event("notifications-updated"))}catch(n){console.error(n)}}return I(()=>{v()}),(n,e)=>(s(),a("section",R,[i("div",H,[i("div",P,l(c("Notifications")),1),r.value.length>0?(s(),a("div",W,[(s(!0),a(d,null,g(r.value,t=>(s(),a("article",{class:x(["item",{unread:!t.read_at}]),key:t.id,id:"notification-"+t.id},[i("div",G,[t.data.type==="admin_message"?(s(),a("img",K)):t.data.avatar?(s(),a("img",{key:1,src:t.data.avatar,alt:"icon",class:"avatar-icon"},null,8,Z)):t.data.sender_name?(s(),a("div",{key:2,class:"user-avatar-initials",style:A({backgroundColor:f(j)(t.data.sender_name)})},l(f(z)(t.data.sender_name)),5)):(s(),a("img",q))]),i("div",J,[t.data.subject?(s(),a("p",Q,[i("strong",null,l(t.data.subject)+":",1),e[0]||(e[0]=w(l(" ")+" ",-1)),(s(!0),a(d,null,g(f(C)(t.data.message),(o,u)=>(s(),a(d,{key:"m-"+u},[o.type==="link"?(s(),a("a",{key:0,href:o.href,class:"notification-text-link",target:"_self"},l(o.value),9,U)):(s(),a(d,{key:1},[w(l(o.value),1)],64))],64))),128))])):(s(),a("p",X,[(s(!0),a(d,null,g(f(C)(t.data.message||c("New notification")),(o,u)=>(s(),a(d,{key:u},[o.type==="link"?(s(),a("a",{key:0,href:o.href,class:"notification-text-link",target:"_self"},l(o.value),9,ee)):(s(),a(d,{key:1},[w(l(o.value),1)],64))],64))),128))])),i("div",te,l(N(t.created_at)),1)]),i("div",ae,[t.read_at?y("",!0):(s(),a("button",{key:0,class:"btn btn-mark-read",onClick:o=>$(t.id),title:c("Mark as read"),"aria-label":c("Mark as read")},[...e[1]||(e[1]=[i("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[i("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z",fill:"currentColor"})],-1)])],8,se)),i("button",{class:"btn btn-close",onClick:o=>L(t.id),title:c("Delete"),"aria-label":c("Delete")},[...e[2]||(e[2]=[i("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[i("path",{d:"M3.33203 16.6666L9.9987 9.99998M9.9987 9.99998L16.6654 3.33331M9.9987 9.99998L3.33203 3.33331M9.9987 9.99998L16.6654 16.6666",stroke:"#8F8F8F","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,ne)])],10,Y))),128))])):(s(),a("div",oe,[i("p",null,l(c("No notifications")),1)])),m.value>1?(s(),a("div",ie,[(s(!0),a(d,null,g(m.value,t=>(s(),a("a",{href:"#",key:t,class:x({current:h.value===t}),onClick:O(o=>v(t),["prevent"])},l(t),11,le))),128))])):y("",!0),r.value.length>0?(s(),a("div",re,[i("button",{onClick:D,class:"btn btn-black"},l(c("Mark all as read")),1)])):y("",!0)])]))}}
1,_e=S(ce,[["__scopeId","data-v-ecf9072e"]]);export{_e 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.