import{t as e}from"./vite-preload-helper-BqcqN_AC.js";import{Tt as t}from"./vue-vendor-DMUmTARL.js";var n=`false`,r=`false`,i=n===`true`,a=r===`true`;function o(t={}){let{immediate:n=!1,onNeedReload:r,onNeedRefresh:o,onOfflineReady:s,onRegistered:c,onRegisteredSW:l,onRegisterError:u}=t,d,f,p,m=async(e=!0)=>{await f,i||p?.()};async function h(){if(`serviceWorker`in navigator){if(d=await e(async()=>{let{Workbox:e}=await import(`./workbox-window.prod.es5-CS4IBAUX.js`);return{Workbox:e}},[]).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{u?.(e)}),!d)return;if(p=()=>{d?.messageSkipWaiting()},!a)if(i)d.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(r?r():window.location.reload())}),d.addEventListener(`installed`,e=>{e.isUpdate||s?.()});else{let e=!1,t=()=>{e=!0,d?.addEventListener(`controlling`,e=>{e.isUpdate&&(r?r():window.location.reload())}),o?.()};d.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&s?.():n.isExternal?t():!e&&s?.():n.isUpdate||s?.()}),d.addEventListener(`waiting`,t)}d.register({immediate:n}).then(e=>{l?l(`/sw.js`,e):c?.(e)}).catch(e=>{u?.(e)})}}return f=h(),m}function s(e={}){let{immediate:n=!0,onNeedReload:r,onNeedRefresh:i,onOfflineReady:a,onRegistered:s,onRegisteredSW:c,onRegisterError:l}=e,u=t(!1),d=t(!1);return{updateServiceWorker:o({immediate:n,onNeedReload:r,onNeedRefresh(){u.value=!0,i?.()},onOfflineReady(){d.value=!0,a?.()},onRegistered:s,onRegisteredSW:c,onRegisterError:l}),offlineReady:d,needRefresh:u}}export{s as useRegisterSW};