import{_ as f}from"./index-CBxrqwze.js";function g(p={}){const{immediate:u=!1,onNeedRefresh:n,onOfflineReady:i,onRegistered:o,onRegisteredSW:c,onRegisterError:r}=p;let e,l,a;const m=async(t=!0)=>{await l,a==null||a()};async function _(){if("serviceWorker"in navigator){if(e=await f(async()=>{const{Workbox:t}=await import("./workbox-window.prod.es5-B9K5rw8f.js");return{Workbox:t}},[],import.meta.url).then(({Workbox:t})=>new t("./sw.js",{scope:"./",type:"classic"})).catch(t=>{r==null||r(t)}),!e)return;a=()=>{e==null||e.messageSkipWaiting()};{let t=!1;const d=()=>{t=!0,e==null||e.addEventListener("controlling",s=>{s.isUpdate&&window.location.reload()}),n==null||n()};e.addEventListener("installed",s=>{typeof s.isUpdate>"u"?typeof s.isExternal<"u"&&s.isExternal?d():!t&&(i==null||i()):s.isUpdate||i==null||i()}),e.addEventListener("waiting",d)}e.register({immediate:u}).then(t=>{c?c("./sw.js",t):o==null||o(t)}).catch(t=>{r==null||r(t)})}}return l=_(),m}export{g as registerSW};
