{"version":3,"sources":["webpack:///./node_modules/register-service-worker/index.js"],"names":["waitWindowLoad","register","swUrl","hooks","registrationOptions","emit","hook","args","len","arguments","length","apply","navigator","then","Boolean","window","location","hostname","match","fetch","response","status","Error","unregister","headers","get","indexOf","registerValidSW","catch","error","handleError","checkValidServiceWorker","serviceWorker","ready","registration","onLine","waiting","onupdatefound","installingWorker","installing","onstatechange","state","controller","Promise","resolve","addEventListener","cb"],"mappings":"uHAAA,kCAOA,IAUIA,EAcG,SAASC,EAAUC,EAAOC,QAChB,IAAVA,IAAmBA,EAAQ,IAEhC,IAAIC,EAAsBD,EAAMC,yBAAkD,IAAxBA,IAAiCA,EAAsB,WAC1GD,EAAMC,oBAEb,IAAIC,EAAO,SAAUC,GAEnB,IADA,IAAIC,EAAO,GAAIC,EAAMC,UAAUC,OAAS,EAChCF,KAAQ,GAAID,EAAMC,GAAQC,UAAWD,EAAM,GAE/CL,GAASA,EAAMG,IACjBH,EAAMG,GAAMK,MAAMR,EAAOI,IAIzB,kBAAmBK,WACrBZ,EAAea,MAAK,WAxCeC,QACR,cAA7BC,OAAOC,SAASC,UAEe,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAASC,MACvB,6DA4FN,SAAkChB,EAAOG,EAAMD,GAE7Ce,MAAMjB,GACHW,MAAK,SAAUO,GAEU,MAApBA,EAASC,QAEXhB,EAAK,QAAS,IAAIiB,MAAO,+BAAiCpB,IAC1DqB,MACyE,IAAhEH,EAASI,QAAQC,IAAI,gBAAgBC,QAAQ,eACtDrB,EAAK,QAAS,IAAIiB,MAChB,YAAcpB,EAAd,kDACmBkB,EAASI,QAAQC,IAAI,kBAC1CF,KAGAI,EAAgBzB,EAAOG,EAAMD,MAGhCwB,OAAM,SAAUC,GAAS,OAAOC,EAAYzB,EAAMwB,MA1E/CE,CAAwB7B,EAAOG,EAAMD,GACrCQ,UAAUoB,cAAcC,MAAMpB,MAAK,SAAUqB,GAC3C7B,EAAK,QAAS6B,MACbN,OAAM,SAAUC,GAAS,OAAOC,EAAYzB,EAAMwB,QAGrDF,EAAgBzB,EAAOG,EAAMD,GAC7BQ,UAAUoB,cAAcC,MAAMpB,MAAK,SAAUqB,GAC3C7B,EAAK,QAAS6B,MACbN,OAAM,SAAUC,GAAS,OAAOC,EAAYzB,EAAMwB,UAM7D,SAASC,EAAazB,EAAMwB,GACrBjB,UAAUuB,QACb9B,EAAK,WAEPA,EAAK,QAASwB,GAGhB,SAASF,EAAiBzB,EAAOG,EAAMD,GACrCQ,UAAUoB,cACP/B,SAASC,EAAOE,GAChBS,MAAK,SAAUqB,GACd7B,EAAK,aAAc6B,GACfA,EAAaE,QACf/B,EAAK,UAAW6B,GAGlBA,EAAaG,cAAgB,WAC3BhC,EAAK,cAAe6B,GACpB,IAAII,EAAmBJ,EAAaK,WACpCD,EAAiBE,cAAgB,WACA,cAA3BF,EAAiBG,QACf7B,UAAUoB,cAAcU,WAK1BrC,EAAK,UAAW6B,GAKhB7B,EAAK,SAAU6B,SAMxBN,OAAM,SAAUC,GAAS,OAAOC,EAAYzB,EAAMwB,MAyBhD,SAASN,IACV,kBAAmBX,WACrBA,UAAUoB,cAAcC,MAAMpB,MAAK,SAAUqB,GAC3CA,EAAaX,gBACZK,OAAM,SAAUC,GAAS,OAAOC,EAAYzB,KAAMwB,MAhHnC,oBAAXd,SAMPf,EADqB,oBAAZ2C,QACQ,IAAIA,SAAQ,SAAUC,GAAW,OAAO7B,OAAO8B,iBAAiB,OAAQD,MAExE,CAAE/B,KAAM,SAAUiC,GAAM,OAAO/B,OAAO8B,iBAAiB,OAAQC","file":"js/npm.register-service-worker-legacy.988cd5a8.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"],"sourceRoot":""}