1import{r as e}from"./rolldown-runtime-C0FnF6B9.js";import{y as t}from"./initial_state-DnZ5UeDQ.js";import{t as n}from"./api-CGawW2vu.js";import{r}from"./settings-Cq4pjZIN.js";var i=e=>{let t=window.atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n},a=`PUSH_NOTIFICATIONS_SET_BROWSER_SUPPORT`,o=`PUSH_NOTIFICATIONS_SET_SUBSCRIPTION`,s=`PUSH_NOTIFICATIONS_CLEAR_SUBSCRIPTION`,c=`PUSH_NOTIFICATIONS_SET_ALERTS`;function l(e){return{type:a,value:e}}function u(e){return{type:o,subscription:e}}function d(){return{type:s}}function f(e,t){return n=>{n({type:c,path:e,value:t})}}var p=e=>i((e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`)),m=()=>document.querySelector(`[name="applicationServerKey"]`).getAttribute(`content`),h=()=>navigator.serviceWorker.ready,g=e=>e.pushManager.getSubscription().then(t=>({registration:e,subscription:t})),_=e=>e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:p(m())}),v=({registration:e,subscription:t})=>t?t.unsubscribe().then(()=>e):e,y=e=>{let i={subscription:{...e.toJSON(),standard:!0}};if(t){let e=r.get(t);e&&(i.data=e)}return n().post(`/api/web/push_subscriptions`,i).then(e=>e.data)},b=`serviceWorker`in navigator&&`PushManager`in window&&`getKey`in PushSubscription.prototype;function x(){return(e,n)=>{if(e(l(b)),b){if(!m()){console.error(`The VAPID public key is not set. You will not be able to receive Web Push Notifications.`);return}h().then(g).then(({registration:e,subscription:t})=>{if(t!==null){let r=new Uint8Array(t.options.applicationServerKey).toString(),i=p(m()).toString(),a=n().getIn([`push_notifications`,`subscription`,`endpoint`]);return i===r&&t.endpoint===a?t:v({registration:e,subscription:t}).then(_).then(e=>y(e))}return _(e).then(e=>y(e))}).then(n=>{n instanceof PushSubscription||(e(u(n)),t&&r.set(t,{alerts:n.alerts}))}).catch(n=>(n.code===20&&n.name===`AbortError`?console.warn(`Your browser supports Web Push Notifications, but does not seem to implement the VAPID protocol.`):n.code===5&&n.name===`InvalidCharacterError`&&console.error(`The VAPID public key seems to be invalid:`,m()),e(d()),t&&r.remove(t),h().then(g).then(v))).catch(console.warn)}else console.warn(`Your browser does not support Web Push Notifications.`)}}function S(){return(e,i)=>{let a=i().get(`push_notifications`),o=a.get(`subscription`),s={alerts:a.get(`alerts`)};n().put(`/api/web/push_subscriptions/${o.get(`id`)}`,{data:s}).then(()=>{t&&r.set(t,s)}).catch(console.warn)}}var C=e({CLEAR_SUBSCRIPTION:()=>s,SET_ALERTS:()=>c,SET_BROWSER_SUPPORT:()=>a,SET_SUBSCRIPTION:()=>o,changeAlerts:()=>w,register:()=>x});function w(e,t){return n=>{n(f(e,t)),n(S())}}export{c as a,s as i,C as n,a as o,x as r,o as s,w as t}; 2//# sourceMappingURL=push_notifications-C0ir4q-Q.js.map
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.