{"version":3,"sources":["webpack:///./node_modules/register-service-worker/index.js","webpack:///./src/registerServiceWorker.js"],"names":["waitWindowLoad","isLocalhost","Boolean","window","location","hostname","match","register","swUrl","hooks","registrationOptions","emit","hook","args","len","arguments","length","apply","navigator","then","checkValidServiceWorker","serviceWorker","ready","registration","catch","error","handleError","registerValidSW","onLine","waiting","onupdatefound","installingWorker","installing","onstatechange","state","controller","fetch","response","status","Error","unregister","headers","get","indexOf","Promise","resolve","addEventListener","cb","console","log","registered","cached","updatefound","updated","reload","offline"],"mappings":"uHAOA,IAUIA,EAVAC,EAAc,WAAc,OAAOC,QACR,cAA7BC,OAAOC,SAASC,UAEe,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAASC,MACvB,4DAkBC,SAASC,EAAUC,EAAOC,QAChB,IAAVA,IAAmBA,EAAQ,IAEhC,IAAIC,EAAsBD,EAAMC,yBAAkD,IAAxBA,IAAiCA,EAAsB,WAC1GD,EAAMC,oBAEb,IAAIC,EAAO,SAAUC,GACnB,IAAIC,EAAO,GAAIC,EAAMC,UAAUC,OAAS,EACxC,MAAQF,KAAQ,EAAID,EAAMC,GAAQC,UAAWD,EAAM,GAE/CL,GAASA,EAAMG,IACjBH,EAAMG,GAAMK,MAAMR,EAAOI,IAIzB,kBAAmBK,WACrBlB,EAAemB,MAAK,WACdlB,KAEFmB,EAAwBZ,EAAOG,EAAMD,GACrCQ,UAAUG,cAAcC,MAAMH,MAAK,SAAUI,GAC3CZ,EAAK,QAASY,MACbC,OAAM,SAAUC,GAAS,OAAOC,EAAYf,EAAMc,QAGrDE,EAAgBnB,EAAOG,EAAMD,GAC7BQ,UAAUG,cAAcC,MAAMH,MAAK,SAAUI,GAC3CZ,EAAK,QAASY,MACbC,OAAM,SAAUC,GAAS,OAAOC,EAAYf,EAAMc,UAM7D,SAASC,EAAaf,EAAMc,GACrBP,UAAUU,QACbjB,EAAK,WAEPA,EAAK,QAASc,GAGhB,SAASE,EAAiBnB,EAAOG,EAAM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UACIP,QAAQC,IAAI,kEAEhBxB,MAAMA,GACFuB,QAAQvB,MAAM,4CAA6CA","file":"js/chunk-2d22998c.25e802a4.js","sourcesContent":["// Register a service worker to serve assets from local cache.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on the \"N+1\" visit to a page, since previously\n// cached resources are updated in the background.\n\nvar isLocalhost = function () { return Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.1/8 is considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n); }\n\nvar waitWindowLoad\n// https://github.com/yyx990803/register-service-worker/pull/33#discussion_r394181861\nif (typeof window !== 'undefined') {\n // Typically, a browser that supports `serviceWorker` should also have supported\n // `Promise`. But as this package can be used in environments without service\n // worker support (in that case it would do nothing), there's a chance that\n // `Promise` does not exist. So we must check for its existence first.\n if (typeof Promise !== 'undefined') {\n waitWindowLoad = new Promise(function (resolve) { return window.addEventListener('load', resolve); })\n } else {\n waitWindowLoad = { then: function (cb) { return window.addEventListener('load', cb); } }\n }\n}\n\nexport function register (swUrl, hooks) {\n if ( hooks === void 0 ) hooks = {};\n\n var registrationOptions = hooks.registrationOptions; if ( registrationOptions === void 0 ) registrationOptions = {};\n delete hooks.registrationOptions\n\n var emit = function (hook) {\n var args = [], len = arguments.length - 1;\n while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];\n\n if (hooks && hooks[hook]) {\n hooks[hook].apply(hooks, args)\n }\n }\n\n if ('serviceWorker' in navigator) {\n waitWindowLoad.then(function () {\n if (isLocalhost()) {\n // This is running on localhost. Lets check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, emit, registrationOptions)\n navigator.serviceWorker.ready.then(function (registration) {\n emit('ready', registration)\n }).catch(function (error) { return handleError(emit, error); })\n } else {\n // Is not local host. Just register service worker\n registerValidSW(swUrl, emit, registrationOptions)\n navigator.serviceWorker.ready.then(function (registration) {\n emit('ready', registration)\n }).catch(function (error) { return handleError(emit, error); })\n }\n })\n }\n}\n\nfunction handleError (emit, error) {\n if (!navigator.onLine) {\n emit('offline')\n }\n emit('error', error)\n}\n\nfunction registerValidSW (swUrl, emit, registrationOptions) {\n navigator.serviceWorker\n .register(swUrl, registrationOptions)\n .then(function (registration) {\n emit('registered', registration)\n if (registration.waiting) {\n emit('updated', registration)\n return\n }\n registration.onupdatefound = function () {\n emit('updatefound', registration)\n var installingWorker = registration.installing\n installingWorker.onstatechange = function () {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the old content will have been purged and\n // the fresh content will have been added to the cache.\n // It's the perfect time to display a \"New content is\n // available; please refresh.\" message in your web app.\n emit('updated', registration)\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n emit('cached', registration)\n }\n }\n }\n }\n })\n .catch(function (error) { return handleError(emit, error); })\n}\n\nfunction checkValidServiceWorker (swUrl, emit, registrationOptions) {\n // Check if the service worker can be found.\n fetch(swUrl)\n .then(function (response) {\n // Ensure service worker exists, and that we really are getting a JS file.\n if (response.status === 404) {\n // No service worker found.\n emit('error', new Error((\"Service worker not found at \" + swUrl)))\n unregister()\n } else if (response.headers.get('content-type').indexOf('javascript') === -1) {\n emit('error', new Error(\n \"Expected \" + swUrl + \" to have javascript content-type, \" +\n \"but received \" + (response.headers.get('content-type'))))\n unregister()\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, emit, registrationOptions)\n }\n })\n .catch(function (error) { return handleError(emit, error); })\n}\n\nexport function unregister () {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready.then(function (registration) {\n registration.unregister()\n }).catch(function (error) { return handleError(emit, error); })\n }\n}\n","/* eslint-disable no-console */\n\nimport { register } from \"register-service-worker\";\n\nif (process.env.NODE_ENV === \"production\") {\n register(`/service-worker.js`, {\n ready() {\n console.log(\n \"App is being served from cache by a service worker.\\n\" +\n \"For more details, visit https://goo.gl/AFskqB\",\n );\n },\n registered() {\n console.log(\"Service worker has been registered.\");\n },\n cached() {\n console.log(\"Content has been cached for offline use.\");\n },\n updatefound() {\n console.log(\"New content is downloading.\");\n },\n updated() {\n console.log(\"New content is available; please refresh.\");\n window.location.reload();\n },\n offline() {\n console.log(\"No internet connection found. App is running in offline mode.\");\n },\n error(error) {\n console.error(\"Error during service worker registration:\", error);\n },\n });\n}\n"],"sourceRoot":""}