1import{a as P}from"./index-DcN63-UG.js";import"./vendor-BOadm9Gy.js";import"./vendor-icons-kUGsRs8M.js";import"./vendor-ui-CeWyqG0w.js";import"./vendor-classnames-CSqCgoPn.js";import"./vendor-motion-DwikGbVM.js";import"./vendor-toast-D6B0hGGw.js";const N="/sw-push.js",u="sn_push_owner",h="sn_push_prompt_dismissed";function s(){const t=typeof window<"u"?window:void 0;let i;try{i=t?.localStorage}catch{i=void 0}return{window:t,navigator:typeof navigator<"u"?navigator:void 0,Notification:t&&"Notification"in t?t.Notification:void 0,storage:i,api:(e,n)=>P(e,n)}}function w(t,i){try{return t.storage?.getItem(i)??null}catch{return null}}function a(t,i,e){try{e===null?t.storage?.removeItem(i):t.storage?.setItem(i,e)}catch{}}function k(t){if(!t)return!1;const i=t.userAgent||"";return/iPad|iPhone|iPod/.test(i)||/Macintosh/.test(i)&&(t.maxTouchPoints||0)>1}function f(t=s()){const i=t.window;return!!i&&!!t.navigator&&"serviceWorker"in t.navigator&&"PushManager"in i&&!!t.Notification&&i.isSecureContext!==!1?"supported":k(t.navigator)?"ios":"unsupported"}function O(t){const i=(t+"=".repeat((4-t.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),e=atob(i),n=new Uint8Array(new ArrayBuffer(e.length));for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}async function _(t){try{return await t.navigator.serviceWorker.getRegistration("/")||null}catch{return null}}async function A(t){const i=t.navigator.serviceWorker;return await i.register(N,{scope:"/",updateViaCache:"none"}),i.ready}async function d(t){const i=await _(t);if(!i?.pushManager)return null;try{return await i.pushManager.getSubscription()}catch{return null}}async function E(t=s()){const i=f(t);if(i!=="supported")return i;const e=t.Notification.permission;return e==="denied"?"denied":e!=="granted"?"off":await d(t)?"on":"off"}async function y(t,i){await t.api("/notifications/push/subscribe",{method:"POST",body:JSON.stringify({subscription:i.toJSON()})})}async function b(t){const i=await A(t),e=await i.pushManager.getSubscription(),n=await t.api("/notifications/push/key"),r=String(n?.data?.publicKey||"");if(!r)throw new Error("No push key");const o=O(r);if(e){const l=e.options?.applicationServerKey;if(!l||l.byteLength===o.byteLength&&new Uint8Array(l).every((m,S)=>m===o[S]))return e;await e.unsubscribe().catch(()=>!1)}return i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:o})}async function C(t,i=s()){const e=f(i);if(e!=="supported")return e;let n=i.Notification.permission;if(n==="default"&&(n=await i.Notification.requestPermission()),n==="denied")return"denied";if(n!=="granted")return"off";const r=await b(i);return await y(i,r),t&&a(i,u,t),a(i,h,null),"on"}async function Y(t=s()){c=null;const i=await d(t);return a(t,u,null),i&&(await t.api("/notifications/push/unsubscribe",{method:"POST",body:JSON.stringify({endpoint:i.endpoint})}).catch(()=>{}),await i.unsubscribe().catch(()=>!1)),E(t)}let c=null;async function J(t,i=s()){const e=f(i);if(e!=="supported")return e;M(i);const n=i.Notification.permission,r=w(i,u),o=await d(i);if(r&&r!==t)return o&&await o.unsubscribe().catch(()=>!1),a(i,u,null),n==="denied"?"denied":"off";if(n!=="granted")return n==="denied"?"denied":"off";if(r!==t)return o?"on":"off";if(c===t&&o)return"on";try{return await y(i,await b(i)),c=t,"on"}catch{return o?"on":"off"}}async function B(t=s()){if(c=null,f(t)!=="supported")return;const i=await d(t);i&&await i.unsubscribe().catch(()=>!1)}function D(t,i=s()){return t==="off"&&i.Notification?.permission==="default"&&w(i,h)!=="1"}function F(t=s()){a(t,h,"1")}let g=!1;const p=new Set;function I(t){return p.add(t),()=>p.delete(t)}function M(t){g||!t.navigator?.serviceWorker||!t.window||(g=!0,t.navigator.serviceWorker.addEventListener("message",i=>{const e=i.data;if(e?.type==="snestico:push"){p.forEach(n=>{try{n()}catch{}});return}if(!(e?.type!=="snestico:navigate"||typeof e.url!="string"))try{const n=new URL(e.url,t.window.location.origin);n.origin===t.window.location.origin&&t.window.location.assign(n.href)}catch{}}))}function V(t){switch(t){case"on":return"This device gets an alert for new messages, matches and other notifications, even when Snestico is closed.";case"denied":return"Notifications are blocked for Snestico in this browser. Allow them in your browserâs site settings, then come back here.";case"ios":return"Alerts arenât supported in Safari on iPhone and iPad. Youâll still see everything here and by email.";case"unsupported":return"This browser doesnât support alerts. Youâll still see everything here and by email.";default:return"Get an alert on this device for new messages, matches and other notifications, even when Snestico is closed."}}export{N as SW_URL,Y as disablePush,F as dismissPushOffer,C as enablePush,B as forgetDevice,E as getPushState,k as isIOS,I as onPushReceived,V as pushStateText,f as pushSupport,D as shouldOfferPush,J as syncPush,O as urlBase64ToUint8Array};
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.