"use strict"; function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } /* global HMR_HOST, HMR_PORT, HMR_ENV_HASH, HMR_SECURE */ /*:: import type { HMRAsset, HMRMessage, } from '@parcel/reporter-dev-server/src/HMRServer.js'; interface ParcelRequire { (string): mixed; cache: {|[string]: ParcelModule|}; hotData: mixed; Module: any; parent: ?ParcelRequire; isParcelRequire: true; modules: {|[string]: [Function, {|[string]: string|}]|}; HMR_BUNDLE_ID: string; root: ParcelRequire; } interface ParcelModule { hot: {| data: mixed, accept(cb: (Function) => void): void, dispose(cb: (mixed) => void): void, // accept(deps: Array | string, cb: (Function) => void): void, // decline(): void, _acceptCallbacks: Array<(Function) => void>, _disposeCallbacks: Array<(mixed) => void>, |}; } declare var module: {bundle: ParcelRequire, ...}; declare var HMR_HOST: string; declare var HMR_PORT: string; declare var HMR_ENV_HASH: string; declare var HMR_SECURE: boolean; */ var OVERLAY_ID = '__parcel__error__overlay__'; var OldModule = module.bundle.Module; function Module(moduleName) { OldModule.call(this, moduleName); this.hot = { data: module.bundle.hotData, _acceptCallbacks: [], _disposeCallbacks: [], accept: function accept(fn) { this._acceptCallbacks.push(fn || function () {}); }, dispose: function dispose(fn) { this._disposeCallbacks.push(fn); } }; module.bundle.hotData = undefined; } module.bundle.Module = Module; var checkedAssets /*: {|[string]: boolean|} */ , acceptedAssets /*: {|[string]: boolean|} */ , assetsToAccept /*: Array<[ParcelRequire, string]> */ ; function getHostname() { return HMR_HOST || (location.protocol.indexOf('http') === 0 ? location.hostname : 'localhost'); } function getPort() { return HMR_PORT || location.port; } // eslint-disable-next-line no-redeclare var parent = module.bundle.parent; if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') { var hostname = getHostname(); var port = getPort(); var protocol = HMR_SECURE || location.protocol == 'https:' && !/localhost|127.0.0.1|0.0.0.0/.test(hostname) ? 'wss' : 'ws'; var ws = new WebSocket(protocol + '://' + hostname + (port ? ':' + port : '') + '/'); // $FlowFixMe ws.onmessage = function (event /*: {data: string, ...} */ ) { checkedAssets = {} /*: {|[string]: boolean|} */ ; acceptedAssets = {} /*: {|[string]: boolean|} */ ; assetsToAccept = []; var data /*: HMRMessage */ = JSON.parse(event.data); if (data.type === 'update') { // Remove error overlay if there is one if (typeof document !== 'undefined') { removeErrorOverlay(); } var assets = data.assets.filter(function (asset) { return asset.envHash === HMR_ENV_HASH; }); // Handle HMR Update var handled = assets.every(function (asset) { return asset.type === 'css' || asset.type === 'js' && hmrAcceptCheck(module.bundle.root, asset.id, asset.depsByBundle); }); if (handled) { console.clear(); assets.forEach(function (asset) { hmrApply(module.bundle.root, asset); }); for (var i = 0; i < assetsToAccept.length; i++) { var id = assetsToAccept[i][1]; if (!acceptedAssets[id]) { hmrAcceptRun(assetsToAccept[i][0], id); } } } else { window.location.reload(); } } if (data.type === 'error') { // Log parcel errors to console var _iterator = _createForOfIteratorHelper(data.diagnostics.ansi), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var ansiDiagnostic = _step.value; var stack = ansiDiagnostic.codeframe ? ansiDiagnostic.codeframe : ansiDiagnostic.stack; console.error('🚨 [parcel]: ' + ansiDiagnostic.message + '\n' + stack + '\n\n' + ansiDiagnostic.hints.join('\n')); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } if (typeof document !== 'undefined') { // Render the fancy html overlay removeErrorOverlay(); var overlay = createErrorOverlay(data.diagnostics.html); // $FlowFixMe document.body.appendChild(overlay); } } }; ws.onerror = function (e) { console.error(e.message); }; ws.onclose = function () { console.warn('[parcel] 🚨 Connection to the HMR server was lost'); }; } function removeErrorOverlay() { var overlay = document.getElementById(OVERLAY_ID); if (overlay) { overlay.remove(); console.log('[parcel] ✨ Error resolved'); } } function createErrorOverlay(diagnostics) { var overlay = document.createElement('div'); overlay.id = OVERLAY_ID; var errorHTML = '
'; var _iterator2 = _createForOfIteratorHelper(diagnostics), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var diagnostic = _step2.value; var stack = diagnostic.codeframe ? diagnostic.codeframe : diagnostic.stack; errorHTML += "\n
\n
\n \uD83D\uDEA8 ".concat(diagnostic.message, "\n
\n
").concat(stack, "
\n
\n ").concat(diagnostic.hints.map(function (hint) { return '
💡 ' + hint + '
'; }).join(''), "\n
\n ").concat(diagnostic.documentation ? "
\uD83D\uDCDD Learn more
") : '', "\n
\n "); } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } errorHTML += '
'; overlay.innerHTML = errorHTML; return overlay; } function getParents(bundle, id) /*: Array<[ParcelRequire, string]> */ { var modules = bundle.modules; if (!modules) { return []; } var parents = []; var k, d, dep; for (k in modules) { for (d in modules[k][1]) { dep = modules[k][1][d]; if (dep === id || Array.isArray(dep) && dep[dep.length - 1] === id) { parents.push([bundle, k]); } } } if (bundle.parent) { parents = parents.concat(getParents(bundle.parent, id)); } return parents; } function updateLink(link) { var newLink = link.cloneNode(); newLink.onload = function () { if (link.parentNode !== null) { // $FlowFixMe link.parentNode.removeChild(link); } }; newLink.setAttribute('href', // $FlowFixMe link.getAttribute('href').split('?')[0] + '?' + Date.now()); // $FlowFixMe link.parentNode.insertBefore(newLink, link.nextSibling); } var cssTimeout = null; function reloadCSS() { if (cssTimeout) { return; } cssTimeout = setTimeout(function () { var links = document.querySelectorAll('link[rel="stylesheet"]'); for (var i = 0; i < links.length; i++) { // $FlowFixMe[incompatible-type] var href /*: string */ = links[i].getAttribute('href'); var hostname = getHostname(); var servedFromHMRServer = hostname === 'localhost' ? new RegExp('^(https?:\\/\\/(0.0.0.0|127.0.0.1)|localhost):' + getPort()).test(href) : href.indexOf(hostname + ':' + getPort()); var absolute = /^https?:\/\//i.test(href) && href.indexOf(window.location.origin) !== 0 && !servedFromHMRServer; if (!absolute) { updateLink(links[i]); } } cssTimeout = null; }, 50); } function hmrApply(bundle /*: ParcelRequire */ , asset /*: HMRAsset */ ) { var modules = bundle.modules; if (!modules) { return; } if (asset.type === 'css') { reloadCSS(); } else if (asset.type === 'js') { var deps = asset.depsByBundle[bundle.HMR_BUNDLE_ID]; if (deps) { if (modules[asset.id]) { // Remove dependencies that are removed and will become orphaned. // This is necessary so that if the asset is added back again, the cache is gone, and we prevent a full page reload. var oldDeps = modules[asset.id][1]; for (var dep in oldDeps) { if (!deps[dep] || deps[dep] !== oldDeps[dep]) { var id = oldDeps[dep]; var parents = getParents(module.bundle.root, id); if (parents.length === 1) { hmrDelete(module.bundle.root, id); } } } } var fn = new Function('require', 'module', 'exports', asset.output); modules[asset.id] = [fn, deps]; } else if (bundle.parent) { hmrApply(bundle.parent, asset); } } } function hmrDelete(bundle, id) { var modules = bundle.modules; if (!modules) { return; } if (modules[id]) { // Collect dependencies that will become orphaned when this module is deleted. var deps = modules[id][1]; var orphans = []; for (var dep in deps) { var parents = getParents(module.bundle.root, deps[dep]); if (parents.length === 1) { orphans.push(deps[dep]); } } // Delete the module. This must be done before deleting dependencies in case of circular dependencies. delete modules[id]; delete bundle.cache[id]; // Now delete the orphans. orphans.forEach(function (id) { hmrDelete(module.bundle.root, id); }); } else if (bundle.parent) { hmrDelete(bundle.parent, id); } } function hmrAcceptCheck(bundle /*: ParcelRequire */ , id /*: string */ , depsByBundle /*: ?{ [string]: { [string]: string } }*/ ) { if (hmrAcceptCheckOne(bundle, id, depsByBundle)) { return true; } // Traverse parents breadth first. All possible ancestries must accept the HMR update, or we'll reload. var parents = getParents(module.bundle.root, id); var accepted = false; while (parents.length > 0) { var v = parents.shift(); var a = hmrAcceptCheckOne(v[0], v[1], null); if (a) { // If this parent accepts, stop traversing upward, but still consider siblings. accepted = true; } else { // Otherwise, queue the parents in the next level upward. var p = getParents(module.bundle.root, v[1]); if (p.length === 0) { // If there are no parents, then we've reached an entry without accepting. Reload. accepted = false; break; } parents.push.apply(parents, _toConsumableArray(p)); } } return accepted; } function hmrAcceptCheckOne(bundle /*: ParcelRequire */ , id /*: string */ , depsByBundle /*: ?{ [string]: { [string]: string } }*/ ) { var modules = bundle.modules; if (!modules) { return; } if (depsByBundle && !depsByBundle[bundle.HMR_BUNDLE_ID]) { // If we reached the root bundle without finding where the asset should go, // there's nothing to do. Mark as "accepted" so we don't reload the page. if (!bundle.parent) { return true; } return hmrAcceptCheck(bundle.parent, id, depsByBundle); } if (checkedAssets[id]) { return true; } checkedAssets[id] = true; var cached = bundle.cache[id]; assetsToAccept.push([bundle, id]); if (!cached || cached.hot && cached.hot._acceptCallbacks.length) { return true; } } function hmrAcceptRun(bundle /*: ParcelRequire */ , id /*: string */ ) { var cached = bundle.cache[id]; bundle.hotData = {}; if (cached && cached.hot) { cached.hot.data = bundle.hotData; } if (cached && cached.hot && cached.hot._disposeCallbacks.length) { cached.hot._disposeCallbacks.forEach(function (cb) { cb(bundle.hotData); }); } delete bundle.cache[id]; bundle(id); cached = bundle.cache[id]; if (cached && cached.hot && cached.hot._acceptCallbacks.length) { cached.hot._acceptCallbacks.forEach(function (cb) { var assetsToAlsoAccept = cb(function () { return getParents(module.bundle.root, id); }); if (assetsToAlsoAccept && assetsToAccept.length) { // $FlowFixMe[method-unbinding] assetsToAccept.push.apply(assetsToAccept, assetsToAlsoAccept); } }); } acceptedAssets[id] = true; }