import{r}from"./index-oxficqJQ.js";function n(){return typeof Notification<"u"&&(document.hidden===!0||!document.hasFocus())&&Notification.permission==="granted"}async function l(a){n()&&"serviceWorker"in navigator&&(await r(),await(await navigator.serviceWorker.ready).showNotification(a.title,{body:a.body||"",silent:!0,data:a.data}))}async function s(a){n()&&"serviceWorker"in navigator&&(await r(),await(await navigator.serviceWorker.ready).showNotification("Входящий звонок",{body:`${a.callerName||"Контакт"} звонит вам`,tag:`incoming-call:${a.callId||"unknown"}`,requireInteraction:!0,silent:!1,data:{type:"call",url:"/",callerName:a.callerName,callId:a.callId,...a.data||{}}}))}async function f(a){var t;if(!a||!("serviceWorker"in navigator))return;const i=await navigator.serviceWorker.getRegistration(),e=await((t=i==null?void 0:i.getNotifications)==null?void 0:t.call(i,{tag:`incoming-call:${a}`}));e==null||e.forEach(o=>o.close())}export{n as canNotifyNow,f as closeIncomingCallNotification,s as showIncomingCallNotification,l as showMessageNotification};
