1import{u as V,aw as E,V as I,U as O,Z as a,l as s,i as r,q as A,aa as p,k as c,P as D,aA as F,F as J,a2 as P,aE as j,b as z,a1 as v,ao as S}from"./vendor-vue-DO5-hTFl.js";import U from"./Icon-DJVXEN3t.js";import{_ as q}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./createLucideIcon-CvPmzaXe.js";import"./x-BhLyuTBD.js";import"./users-DzU9Yozq.js";import"./wallet-vByLPeeN.js";import"./trophy-C0xjRGQr.js";import"./smartphone-CqUsGvZt.js";import"./send-CtitI9gV.js";import"./search-DzE3Wg-v.js";import"./plus-IW5t7efP.js";import"./history-BXlEaBDh.js";import"./download-CGTQ_OA4.js";import"./clock-aChRcM9W.js";import"./circle-alert-Ac9nKvNW.js";import"./chevron-right-DG4lyrf_.js";import"./check-BOXqqf8S.js";import"./bookmark-B7AFb21t.js";import"./bell-BGP-bVxg.js";import"./arrow-left-Df_TXDbX.js";const G={key:0,class:"nb__badge"},H={key:0,class:"nb__panel"},K={class:"nb__head"},X={class:"nb__head-actions"},Y={key:0,class:"nb__empty"},Z={key:1,class:"nb__list"},Q=["onClick"],W={class:"nb__item-body"},tt={class:"nb__item-title"},et={key:0,class:"nb__item-text"},nt={class:"nb__item-time"},ot=["onClick"],y="lk:notifications:v1",b=500,it=V({__name:"NotificationBell",setup(at){const d=v(!1),m=v(null),o=v([]),u=()=>o.value.filter(n=>!n.read).length;function l(){if(!(typeof window>"u"))try{window.localStorage.setItem(y,JSON.stringify(o.value))}catch{}}function M(){if(!(typeof window>"u"))try{const n=window.localStorage.getItem(y);if(!n)return;const t=JSON.parse(n);if(!Array.isArray(t))return;o.value=t.filter(e=>typeof e=="object"&&e!==null&&typeof e.id=="string"&&typeof e.title=="string"&&typeof e.ts=="number"&&typeof e.read=="boolean").slice(0,b)}catch{}}function w(n){const t=n.id??`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;if(o.value.some(i=>i.id===t))return;const e={id:t,ts:n.ts??Date.now(),read:!1,type:n.type??"info",title:n.title,body:n.body};o.value.unshift(e),o.value.length>b&&(o.value=o.value.slice(0,b)),l()}function g(n){const t=n.detail;!t||!t.title||w({id:t.id,ts:t.ts,title:t.title,body:t.body,type:t.type??"info"})}function $(){o.value=o.value.map(n=>({...n,read:!0})),l()}function L(n){o.value=o.value.map(t=>t.id===n?{...t,read:!0}:t),l()}function x(n){o.value=o.value.filter(t=>t.id!==n),l()}function B(){o.value.length!==0&&(typeof window<"u"&&!window.confirm("Clear all notifications? This can't be undone.")||(o.value=[],l()))}function R(n){const t=new Date(n);if(Number.isNaN(t.getTime()))return"";const i=Date.now()-n,f=Math.floor(i/6e4);if(f<1)return"just now";if(f<60)return`${f}m ago`;const _=Math.floor(f/60);if(_<24)return`${_}h ago`;const C=Math.floor(_/24);return C<7?`${C}d ago`:t.toLocaleDateString([],{month:"short",day:"numeric"})}function h(n){!m.value||!d.value||(!n.target?.valueOf||!m.value.contains(n.target))&&(d.value=!1)}function k(n){if(!(n.key!==y||n.newValue===null))try{const t=JSON.parse(n.newValue);Array.isArray(t)&&(o.value=t)}catch{}}E(o,l,{deep:!0});function N(){if(typeof window>"u")return;const t=S().props?.mamont_notifications;if(!(!Array.isArray(t)||t.length===0)){for(const e of t){if(!e||typeof e.id!="string"||e.id==="")continue;const i=e.created_at?Date.parse(e.created_at):Date.now();w({id:e.id,ts:Number.isFinite(i)?i:Date.now(),title:e.title||"Уведомление",body:e.text||void 0,type:"info"})}o.value=[...o.value].sort((e,i)=>i.ts-e.ts),l()}}const T=S();return E(()=>T.props.mamont_notifications,()=>N(),{deep:!0}),I(()=>{M(),N(),window.addEventListener("lk:notify",g),document.addEventListener("mousedown",h),window.addEventListener("storage",k)}),O(()=>{window.removeEventListener("lk:notify",g),document.removeEventListener("mousedown",h),window.removeEventListener("storage",k)}),(n,t)=>(a(),s("div",{ref_key:"wrapRef",ref:m,class:"nb"},[r("button",{type:"button",class:D(["nb__btn",{"nb__btn--open":d.value}]),onClick:t[0]||(t[0]=e=>d.value=!d.value)},[A(U,{name:"bell",size:18}),u()>0?(a(),s("span",G,p(u()>9?"9+":u()),1)):c("",!0)],2),A(z,{name:"nb-pop"},{default:F(()=>[d.value?(a(),s("div",H,[r("div",K,[t[1]||(t[1]=r("span",{class:"nb__head-title"},"Notifications",-1)),r("div",X,[u()>
10?(a(),s("button",{key:0,type:"button",class:"nb__mark-all",onClick:$}," Mark all read ")):c("",!0),o.value.length>0?(a(),s("button",{key:1,type:"button",class:"nb__clear-all",onClick:B}," Clear all ")):c("",!0)])]),o.value.length===0?(a(),s("div",Y," No notifications yet ")):(a(),s("div",Z,[(a(!0),s(J,null,P(o.value,e=>(a(),s("div",{key:e.id,class:D(["nb__item",[`nb__item--${e.type}`,{"nb__item--unread":!e.read}]]),onClick:i=>L(e.id)},[t[2]||(t[2]=r("div",{class:"nb__item-dot"},null,-1)),r("div",W,[r("span",tt,p(e.title),1),e.body?(a(),s("span",et,p(e.body),1)):c("",!0),r("span",nt,p(R(e.ts)),1)]),r("button",{type:"button",class:"nb__item-close",onClick:j(i=>x(e.id),["stop"])},"Ã",8,ot)],10,Q))),128))]))])):c("",!0)]),_:1})],512))}}),Dt=q(it,[["__scopeId","data-v-a80e52b3"]]);export{Dt 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.