{"ast":null,"code":"\"use strict\";\n\nvar _slicedToArray = require(\"@babel/runtime/helpers/slicedToArray\");\n\nvar _regeneratorRuntime = require(\"@babel/runtime/regenerator\");\n\nvar _asyncToGenerator = require(\"@babel/runtime/helpers/asyncToGenerator\");\n\nvar _classCallCheck = require(\"@babel/runtime/helpers/classCallCheck\");\n\nvar _createClass = require(\"@babel/runtime/helpers/createClass\");\n\nexports.__esModule = true;\nexports.addBasePath = addBasePath;\nexports.delBasePath = delBasePath;\nexports.resolveHref = resolveHref;\nexports[\"default\"] = void 0;\n\nvar _mitt = _interopRequireDefault(require(\"../mitt\"));\n\nvar _utils = require(\"../utils\");\n\nvar _isDynamic = require(\"./utils/is-dynamic\");\n\nvar _routeMatcher = require(\"./utils/route-matcher\");\n\nvar _routeRegex = require(\"./utils/route-regex\");\n\nvar _searchParamsToUrlQuery = require(\"./utils/search-params-to-url-query\");\n\nvar _parseRelativeUrl = require(\"./utils/parse-relative-url\");\n\nvar _normalizeTrailingSlash = require(\"../../../client/normalize-trailing-slash\");\n\nfunction _interopRequireDefault(obj) {\n  return obj && obj.__esModule ? obj : {\n    \"default\": obj\n  };\n}\n/* global __NEXT_DATA__ */\n// tslint:disable:no-console\n\n\nvar basePath = process.env.__NEXT_ROUTER_BASEPATH || '';\n\nfunction buildCancellationError() {\n  return Object.assign(new Error('Route Cancelled'), {\n    cancelled: true\n  });\n}\n\nfunction addBasePath(path) {\n  return basePath ? path === '/' ? (0, _normalizeTrailingSlash.normalizePathTrailingSlash)(basePath) : basePath + path : path;\n}\n\nfunction delBasePath(path) {\n  return path.slice(basePath.length) || '/';\n}\n/**\n* Resolves a given hyperlink with a certain router state (basePath not included).\n* Preserves absolute urls.\n*/\n\n\nfunction resolveHref(currentPath, href) {\n  // we use a dummy base url for relative urls\n  var base = new URL(currentPath, 'http://n');\n  var urlAsString = typeof href === 'string' ? href : (0, _utils.formatWithValidation)(href);\n  var finalUrl = new URL(urlAsString, base);\n  finalUrl.pathname = (0, _normalizeTrailingSlash.normalizePathTrailingSlash)(finalUrl.pathname); // if the origin didn't change, it means we received a relative href\n\n  return finalUrl.origin === base.origin ? finalUrl.href.slice(finalUrl.origin.length) : finalUrl.href;\n}\n\nfunction prepareUrlAs(router, url, as) {\n  // If url and as provided as an object representation,\n  // we'll format them into the string version here.\n  return {\n    url: addBasePath(resolveHref(router.pathname, url)),\n    as: as ? addBasePath(resolveHref(router.pathname, as)) : as\n  };\n}\n\nfunction tryParseRelativeUrl(url) {\n  try {\n    return (0, _parseRelativeUrl.parseRelativeUrl)(url);\n  } catch (err) {\n    if (true) {\n      throw new Error(\"Invalid href passed to router: \".concat(url, \" https://err.sh/vercel/next.js/invalid-href-passed\"));\n    }\n\n    return null;\n  }\n}\n\nvar manualScrollRestoration = process.env.__NEXT_SCROLL_RESTORATION && true && 'scrollRestoration' in window.history;\n\nfunction fetchRetry(url, attempts) {\n  return fetch(url, {\n    // Cookies are required to be present for Next.js' SSG \"Preview Mode\".\n    // Cookies may also be required for `getServerSideProps`.\n    //\n    // > `fetch` won’t send cookies, unless you set the credentials init\n    // > option.\n    // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch\n    //\n    // > For maximum browser compatibility when it comes to sending &\n    // > receiving cookies, always supply the `credentials: 'same-origin'`\n    // > option instead of relying on the default.\n    // https://github.com/github/fetch#caveats\n    credentials: 'same-origin'\n  }).then(function (res) {\n    if (!res.ok) {\n      if (attempts > 1 && res.status >= 500) {\n        return fetchRetry(url, attempts - 1);\n      }\n\n      throw new Error(\"Failed to load static props\");\n    }\n\n    return res.json();\n  });\n}\n\nfunction fetchNextData(dataHref, isServerRender) {\n  return fetchRetry(dataHref, isServerRender ? 3 : 1)[\"catch\"](function (err) {\n    // We should only trigger a server-side transition if this was caused\n    // on a client-side transition. Otherwise, we'd get into an infinite\n    // loop.\n    if (!isServerRender) {\n      ;\n      err.code = 'PAGE_LOAD_ERROR';\n    }\n\n    throw err;\n  });\n}\n\nvar Router = /*#__PURE__*/function () {\n  /**\n  * Map of all components loaded in `Router`\n  */\n  // Static Data Cache\n  function Router(_pathname, _query, _as, _ref) {\n    var _this = this;\n\n    var initialProps = _ref.initialProps,\n        pageLoader = _ref.pageLoader,\n        App = _ref.App,\n        wrapApp = _ref.wrapApp,\n        Component = _ref.Component,\n        err = _ref.err,\n        subscription = _ref.subscription,\n        isFallback = _ref.isFallback;\n\n    _classCallCheck(this, Router);\n\n    this.route = void 0;\n    this.pathname = void 0;\n    this.query = void 0;\n    this.asPath = void 0;\n    this.basePath = void 0;\n    this.components = void 0;\n    this.sdc = {};\n    this.sub = void 0;\n    this.clc = void 0;\n    this.pageLoader = void 0;\n    this._bps = void 0;\n    this.events = void 0;\n    this._wrapApp = void 0;\n    this.isSsr = void 0;\n    this.isFallback = void 0;\n    this._inFlightRoute = void 0;\n\n    this.onPopState = function (e) {\n      if (!e.state) {\n        // We get state as undefined for two reasons.\n        //  1. With older safari (< 8) and older chrome (< 34)\n        //  2. When the URL changed with #\n        //\n        // In the both cases, we don't need to proceed and change the route.\n        // (as it's already changed)\n        // But we can simply replace the state with the new changes.\n        // Actually, for (1) we don't need to nothing. But it's hard to detect that event.\n        // So, doing the following for (1) does no harm.\n        var _pathname2 = _this.pathname,\n            query = _this.query;\n\n        _this.changeState('replaceState', (0, _utils.formatWithValidation)({\n          pathname: addBasePath(_pathname2),\n          query: query\n        }), (0, _utils.getURL)());\n\n        return;\n      }\n\n      var _e$state = e.state,\n          url = _e$state.url,\n          as = _e$state.as,\n          options = _e$state.options;\n\n      var _ref2 = (0, _parseRelativeUrl.parseRelativeUrl)(url),\n          pathname = _ref2.pathname; // Make sure we don't re-render on initial load,\n      // can be caused by navigating back from an external site\n\n\n      if (_this.isSsr && as === _this.asPath && pathname === _this.pathname) {\n        return;\n      } // If the downstream application returns falsy, return.\n      // They will then be responsible for handling the event.\n\n\n      if (_this._bps && !_this._bps(e.state)) {\n        return;\n      }\n\n      if (true) {\n        if (typeof url === 'undefined' || typeof as === 'undefined') {\n          console.warn('`popstate` event triggered but `event.state` did not have `url` or `as` https://err.sh/vercel/next.js/popstate-state-empty');\n        }\n      }\n\n      _this.change('replaceState', url, as, options);\n    }; // represents the current component key\n\n\n    this.route = (0, _normalizeTrailingSlash.removePathTrailingSlash)(_pathname); // set up the component cache (by route keys)\n\n    this.components = {}; // We should not keep the cache, if there's an error\n    // Otherwise, this cause issues when when going back and\n    // come again to the errored page.\n\n    if (_pathname !== '/_error') {\n      this.components[this.route] = {\n        Component: Component,\n        props: initialProps,\n        err: err,\n        __N_SSG: initialProps && initialProps.__N_SSG,\n        __N_SSP: initialProps && initialProps.__N_SSP\n      };\n    }\n\n    this.components['/_app'] = {\n      Component: App\n    }; // Backwards compat for Router.router.events\n    // TODO: Should be remove the following major version as it was never documented\n\n    this.events = Router.events;\n    this.pageLoader = pageLoader;\n    this.pathname = _pathname;\n    this.query = _query; // if auto prerendered and dynamic route wait to update asPath\n    // until after mount to prevent hydration mismatch\n\n    this.asPath = // @ts-ignore this is temporarily global (attached to window)\n    (0, _isDynamic.isDynamicRoute)(_pathname) && __NEXT_DATA__.autoExport ? _pathname : _as;\n    this.basePath = basePath;\n    this.sub = subscription;\n    this.clc = null;\n    this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating\n    // back from external site\n\n    this.isSsr = true;\n    this.isFallback = isFallback;\n\n    if (true) {\n      // make sure \"as\" doesn't start with double slashes or else it can\n      // throw an error as it's considered invalid\n      if (_as.substr(0, 2) !== '//') {\n        // in order for `e.state` to work on the `onpopstate` event\n        // we have to register the initial route upon initialization\n        this.changeState('replaceState', (0, _utils.formatWithValidation)({\n          pathname: addBasePath(_pathname),\n          query: _query\n        }), (0, _utils.getURL)());\n      }\n\n      window.addEventListener('popstate', this.onPopState); // enable custom scroll restoration handling when available\n      // otherwise fallback to browser's default handling\n\n      if (process.env.__NEXT_SCROLL_RESTORATION) {\n        if (manualScrollRestoration) {\n          window.history.scrollRestoration = 'manual';\n          var scrollDebounceTimeout;\n\n          var debouncedScrollSave = function debouncedScrollSave() {\n            if (scrollDebounceTimeout) clearTimeout(scrollDebounceTimeout);\n            scrollDebounceTimeout = setTimeout(function () {\n              var _history$state = history.state,\n                  url = _history$state.url,\n                  curAs = _history$state.as,\n                  options = _history$state.options;\n\n              _this.changeState('replaceState', url, curAs, Object.assign({}, options, {\n                _N_X: window.scrollX,\n                _N_Y: window.scrollY\n              }));\n            }, 10);\n          };\n\n          window.addEventListener('scroll', debouncedScrollSave);\n        }\n      }\n    }\n  } // @deprecated backwards compatibility even though it's a private method.\n\n\n  _createClass(Router, [{\n    key: \"update\",\n    value: function update(route, mod) {\n      var Component = mod[\"default\"] || mod;\n      var data = this.components[route];\n\n      if (!data) {\n        throw new Error(\"Cannot update unavailable route: \".concat(route));\n      }\n\n      var newData = Object.assign({}, data, {\n        Component: Component,\n        __N_SSG: mod.__N_SSG,\n        __N_SSP: mod.__N_SSP\n      });\n      this.components[route] = newData; // pages/_app.js updated\n\n      if (route === '/_app') {\n        this.notify(this.components[this.route]);\n        return;\n      }\n\n      if (route === this.route) {\n        this.notify(newData);\n      }\n    }\n  }, {\n    key: \"reload\",\n    value: function reload() {\n      window.location.reload();\n    }\n    /**\n    * Go back in history\n    */\n\n  }, {\n    key: \"back\",\n    value: function back() {\n      window.history.back();\n    }\n    /**\n    * Performs a `pushState` with arguments\n    * @param url of the route\n    * @param as masks `url` for the browser\n    * @param options object you can define `shallow` and other options\n    */\n\n  }, {\n    key: \"push\",\n    value: function push(url) {\n      var as = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : url;\n      var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n      ;\n\n      var _prepareUrlAs = prepareUrlAs(this, url, as);\n\n      url = _prepareUrlAs.url;\n      as = _prepareUrlAs.as;\n      return this.change('pushState', url, as, options);\n    }\n    /**\n    * Performs a `replaceState` with arguments\n    * @param url of the route\n    * @param as masks `url` for the browser\n    * @param options object you can define `shallow` and other options\n    */\n\n  }, {\n    key: \"replace\",\n    value: function replace(url) {\n      var as = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : url;\n      var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n      ;\n\n      var _prepareUrlAs2 = prepareUrlAs(this, url, as);\n\n      url = _prepareUrlAs2.url;\n      as = _prepareUrlAs2.as;\n      return this.change('replaceState', url, as, options);\n    }\n  }, {\n    key: \"change\",\n    value: function () {\n      var _change = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(method, url, as, options) {\n        var rewriteUrlForNextExport, cleanedAs, parsed, pathname, searchParams, query, route, _options$shallow, shallow, _ref3, asPathname, routeRegex, routeMatch, missingParams, routeInfo, error, appComp;\n\n        return _regeneratorRuntime.wrap(function _callee$(_context) {\n          while (1) {\n            switch (_context.prev = _context.next) {\n              case 0:\n                if (!options._h) {\n                  this.isSsr = false;\n                } // marking route changes as a navigation start entry\n\n\n                if (_utils.ST) {\n                  performance.mark('routeChange');\n                } // Add the ending slash to the paths. So, we can serve the\n                // \"<page>/index.html\" directly for the SSR page.\n\n\n                if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n                  rewriteUrlForNextExport = require('./rewrite-url-for-export').rewriteUrlForNextExport; // @ts-ignore this is temporarily global (attached to window)\n\n                  if (__NEXT_DATA__.nextExport) {\n                    as = rewriteUrlForNextExport(as);\n                  }\n                }\n\n                if (this._inFlightRoute) {\n                  this.abortComponentLoad(this._inFlightRoute);\n                }\n\n                cleanedAs = delBasePath(as);\n                this._inFlightRoute = as; // If the url change is only related to a hash change\n                // We should not proceed. We should only change the state.\n                // WARNING: `_h` is an internal option for handing Next.js client-side\n                // hydration. Your app should _never_ use this property. It may change at\n                // any time without notice.\n\n                if (!(!options._h && this.onlyAHashChange(cleanedAs))) {\n                  _context.next = 13;\n                  break;\n                }\n\n                this.asPath = cleanedAs;\n                Router.events.emit('hashChangeStart', as);\n                this.changeState(method, url, as, options);\n                this.scrollToHash(cleanedAs);\n                Router.events.emit('hashChangeComplete', as);\n                return _context.abrupt(\"return\", true);\n\n              case 13:\n                parsed = tryParseRelativeUrl(url);\n\n                if (parsed) {\n                  _context.next = 16;\n                  break;\n                }\n\n                return _context.abrupt(\"return\", false);\n\n              case 16:\n                pathname = parsed.pathname, searchParams = parsed.searchParams;\n                query = (0, _searchParamsToUrlQuery.searchParamsToUrlQuery)(searchParams); // url and as should always be prefixed with basePath by this\n                // point by either next/link or router.push/replace so strip the\n                // basePath from the pathname to match the pages dir 1-to-1\n\n                pathname = pathname ? (0, _normalizeTrailingSlash.removePathTrailingSlash)(delBasePath(pathname)) : pathname; // If asked to change the current URL we should reload the current page\n                // (not location.reload() but reload getInitialProps and other Next.js stuffs)\n                // We also need to set the method = replaceState always\n                // as this should not go into the history (That's how browsers work)\n                // We should compare the new asPath to the current asPath, not the url\n\n                if (!this.urlIsNew(cleanedAs)) {\n                  method = 'replaceState';\n                }\n\n                route = (0, _normalizeTrailingSlash.removePathTrailingSlash)(pathname);\n                _options$shallow = options.shallow, shallow = _options$shallow === void 0 ? false : _options$shallow;\n\n                if (!(0, _isDynamic.isDynamicRoute)(route)) {\n                  _context.next = 34;\n                  break;\n                }\n\n                _ref3 = (0, _parseRelativeUrl.parseRelativeUrl)(cleanedAs), asPathname = _ref3.pathname;\n                routeRegex = (0, _routeRegex.getRouteRegex)(route);\n                routeMatch = (0, _routeMatcher.getRouteMatcher)(routeRegex)(asPathname);\n\n                if (routeMatch) {\n                  _context.next = 33;\n                  break;\n                }\n\n                missingParams = Object.keys(routeRegex.groups).filter(function (param) {\n                  return !query[param];\n                });\n\n                if (!(missingParams.length > 0)) {\n                  _context.next = 31;\n                  break;\n                }\n\n                if (true) {\n                  console.warn(\"Mismatching `as` and `href` failed to manually provide \" + \"the params: \".concat(missingParams.join(', '), \" in the `href`'s `query`\"));\n                }\n\n                throw new Error(\"The provided `as` value (\".concat(asPathname, \") is incompatible with the `href` value (\").concat(route, \"). \") + \"Read more: https://err.sh/vercel/next.js/incompatible-href-as\");\n\n              case 31:\n                _context.next = 34;\n                break;\n\n              case 33:\n                // Merge params into `query`, overwriting any specified in search\n                Object.assign(query, routeMatch);\n\n              case 34:\n                Router.events.emit('routeChangeStart', as);\n                _context.prev = 35;\n                _context.next = 38;\n                return this.getRouteInfo(route, pathname, query, as, shallow);\n\n              case 38:\n                routeInfo = _context.sent;\n                error = routeInfo.error;\n                Router.events.emit('beforeHistoryChange', as);\n                this.changeState(method, url, as, options);\n\n                if (true) {\n                  appComp = this.components['/_app'].Component;\n                  window.next.isPrerendered = appComp.getInitialProps === appComp.origGetInitialProps && !routeInfo.Component.getInitialProps;\n                }\n\n                _context.next = 45;\n                return this.set(route, pathname, query, cleanedAs, routeInfo);\n\n              case 45:\n                if (!error) {\n                  _context.next = 48;\n                  break;\n                }\n\n                Router.events.emit('routeChangeError', error, cleanedAs);\n                throw error;\n\n              case 48:\n                if (process.env.__NEXT_SCROLL_RESTORATION) {\n                  if (manualScrollRestoration && '_N_X' in options) {\n                    window.scrollTo(options._N_X, options._N_Y);\n                  }\n                }\n\n                Router.events.emit('routeChangeComplete', as);\n                return _context.abrupt(\"return\", true);\n\n              case 53:\n                _context.prev = 53;\n                _context.t0 = _context[\"catch\"](35);\n\n                if (!_context.t0.cancelled) {\n                  _context.next = 57;\n                  break;\n                }\n\n                return _context.abrupt(\"return\", false);\n\n              case 57:\n                throw _context.t0;\n\n              case 58:\n              case \"end\":\n                return _context.stop();\n            }\n          }\n        }, _callee, this, [[35, 53]]);\n      }));\n\n      function change(_x, _x2, _x3, _x4) {\n        return _change.apply(this, arguments);\n      }\n\n      return change;\n    }()\n  }, {\n    key: \"changeState\",\n    value: function changeState(method, url, as) {\n      var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n\n      if (true) {\n        if (typeof window.history === 'undefined') {\n          console.error(\"Warning: window.history is not available.\");\n          return;\n        }\n\n        if (typeof window.history[method] === 'undefined') {\n          console.error(\"Warning: window.history.\".concat(method, \" is not available\"));\n          return;\n        }\n      }\n\n      if (method !== 'pushState' || (0, _utils.getURL)() !== as) {\n        window.history[method]({\n          url: url,\n          as: as,\n          options: options\n        }, // Most browsers currently ignores this parameter, although they may use it in the future.\n        // Passing the empty string here should be safe against future changes to the method.\n        // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState\n        '', as);\n      }\n    }\n  }, {\n    key: \"handleRouteInfoError\",\n    value: function () {\n      var _handleRouteInfoError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(err, pathname, query, as, loadErrorFail) {\n        var _yield$this$fetchComp, Component, routeInfo;\n\n        return _regeneratorRuntime.wrap(function _callee2$(_context2) {\n          while (1) {\n            switch (_context2.prev = _context2.next) {\n              case 0:\n                if (!err.cancelled) {\n                  _context2.next = 2;\n                  break;\n                }\n\n                throw err;\n\n              case 2:\n                if (!(err.code === 'PAGE_LOAD_ERROR' || loadErrorFail)) {\n                  _context2.next = 6;\n                  break;\n                }\n\n                Router.events.emit('routeChangeError', err, as); // If we can't load the page it could be one of following reasons\n                //  1. Page doesn't exists\n                //  2. Page does exist in a different zone\n                //  3. Internal error while loading the page\n                // So, doing a hard reload is the proper way to deal with this.\n\n                window.location.href = as; // Changing the URL doesn't block executing the current code path.\n                // So let's throw a cancellation error stop the routing logic.\n\n                throw buildCancellationError();\n\n              case 6:\n                _context2.prev = 6;\n                _context2.next = 9;\n                return this.fetchComponent('/_error');\n\n              case 9:\n                _yield$this$fetchComp = _context2.sent;\n                Component = _yield$this$fetchComp.page;\n                routeInfo = {\n                  Component: Component,\n                  err: err,\n                  error: err\n                };\n                _context2.prev = 12;\n                _context2.next = 15;\n                return this.getInitialProps(Component, {\n                  err: err,\n                  pathname: pathname,\n                  query: query\n                });\n\n              case 15:\n                routeInfo.props = _context2.sent;\n                _context2.next = 22;\n                break;\n\n              case 18:\n                _context2.prev = 18;\n                _context2.t0 = _context2[\"catch\"](12);\n                console.error('Error in error page `getInitialProps`: ', _context2.t0);\n                routeInfo.props = {};\n\n              case 22:\n                return _context2.abrupt(\"return\", routeInfo);\n\n              case 25:\n                _context2.prev = 25;\n                _context2.t1 = _context2[\"catch\"](6);\n                return _context2.abrupt(\"return\", this.handleRouteInfoError(_context2.t1, pathname, query, as, true));\n\n              case 28:\n              case \"end\":\n                return _context2.stop();\n            }\n          }\n        }, _callee2, this, [[6, 25], [12, 18]]);\n      }));\n\n      function handleRouteInfoError(_x5, _x6, _x7, _x8, _x9) {\n        return _handleRouteInfoError.apply(this, arguments);\n      }\n\n      return handleRouteInfoError;\n    }()\n  }, {\n    key: \"getRouteInfo\",\n    value: function () {\n      var _getRouteInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(route, pathname, query, as) {\n        var _this2 = this;\n\n        var shallow,\n            cachedRouteInfo,\n            routeInfo,\n            Component,\n            __N_SSG,\n            __N_SSP,\n            _require,\n            isValidElementType,\n            dataHref,\n            props,\n            _args3 = arguments;\n\n        return _regeneratorRuntime.wrap(function _callee3$(_context3) {\n          while (1) {\n            switch (_context3.prev = _context3.next) {\n              case 0:\n                shallow = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : false;\n                _context3.prev = 1;\n                cachedRouteInfo = this.components[route];\n\n                if (!(shallow && cachedRouteInfo && this.route === route)) {\n                  _context3.next = 5;\n                  break;\n                }\n\n                return _context3.abrupt(\"return\", cachedRouteInfo);\n\n              case 5:\n                if (!cachedRouteInfo) {\n                  _context3.next = 9;\n                  break;\n                }\n\n                _context3.t0 = cachedRouteInfo;\n                _context3.next = 12;\n                break;\n\n              case 9:\n                _context3.next = 11;\n                return this.fetchComponent(route).then(function (res) {\n                  return {\n                    Component: res.page,\n                    __N_SSG: res.mod.__N_SSG,\n                    __N_SSP: res.mod.__N_SSP\n                  };\n                });\n\n              case 11:\n                _context3.t0 = _context3.sent;\n\n              case 12:\n                routeInfo = _context3.t0;\n                Component = routeInfo.Component, __N_SSG = routeInfo.__N_SSG, __N_SSP = routeInfo.__N_SSP;\n\n                if (!true) {\n                  _context3.next = 18;\n                  break;\n                }\n\n                _require = require('react-is'), isValidElementType = _require.isValidElementType;\n\n                if (isValidElementType(Component)) {\n                  _context3.next = 18;\n                  break;\n                }\n\n                throw new Error(\"The default export is not a React Component in page: \\\"\".concat(pathname, \"\\\"\"));\n\n              case 18:\n                if (__N_SSG || __N_SSP) {\n                  dataHref = this.pageLoader.getDataHref((0, _utils.formatWithValidation)({\n                    pathname: pathname,\n                    query: query\n                  }), as, __N_SSG);\n                }\n\n                _context3.next = 21;\n                return this._getData(function () {\n                  return __N_SSG ? _this2._getStaticData(dataHref) : __N_SSP ? _this2._getServerData(dataHref) : _this2.getInitialProps(Component, // we provide AppTree later so this needs to be `any`\n                  {\n                    pathname: pathname,\n                    query: query,\n                    asPath: as\n                  });\n                });\n\n              case 21:\n                props = _context3.sent;\n                routeInfo.props = props;\n                this.components[route] = routeInfo;\n                return _context3.abrupt(\"return\", routeInfo);\n\n              case 27:\n                _context3.prev = 27;\n                _context3.t1 = _context3[\"catch\"](1);\n                return _context3.abrupt(\"return\", this.handleRouteInfoError(_context3.t1, pathname, query, as));\n\n              case 30:\n              case \"end\":\n                return _context3.stop();\n            }\n          }\n        }, _callee3, this, [[1, 27]]);\n      }));\n\n      function getRouteInfo(_x10, _x11, _x12, _x13) {\n        return _getRouteInfo.apply(this, arguments);\n      }\n\n      return getRouteInfo;\n    }()\n  }, {\n    key: \"set\",\n    value: function set(route, pathname, query, as, data) {\n      this.isFallback = false;\n      this.route = route;\n      this.pathname = pathname;\n      this.query = query;\n      this.asPath = as;\n      return this.notify(data);\n    }\n    /**\n    * Callback to execute before replacing router state\n    * @param cb callback to be executed\n    */\n\n  }, {\n    key: \"beforePopState\",\n    value: function beforePopState(cb) {\n      this._bps = cb;\n    }\n  }, {\n    key: \"onlyAHashChange\",\n    value: function onlyAHashChange(as) {\n      if (!this.asPath) return false;\n\n      var _this$asPath$split = this.asPath.split('#'),\n          _this$asPath$split2 = _slicedToArray(_this$asPath$split, 2),\n          oldUrlNoHash = _this$asPath$split2[0],\n          oldHash = _this$asPath$split2[1];\n\n      var _as$split = as.split('#'),\n          _as$split2 = _slicedToArray(_as$split, 2),\n          newUrlNoHash = _as$split2[0],\n          newHash = _as$split2[1]; // Makes sure we scroll to the provided hash if the url/hash are the same\n\n\n      if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {\n        return true;\n      } // If the urls are change, there's more than a hash change\n\n\n      if (oldUrlNoHash !== newUrlNoHash) {\n        return false;\n      } // If the hash has changed, then it's a hash only change.\n      // This check is necessary to handle both the enter and\n      // leave hash === '' cases. The identity case falls through\n      // and is treated as a next reload.\n\n\n      return oldHash !== newHash;\n    }\n  }, {\n    key: \"scrollToHash\",\n    value: function scrollToHash(as) {\n      var _as$split3 = as.split('#'),\n          _as$split4 = _slicedToArray(_as$split3, 2),\n          hash = _as$split4[1]; // Scroll to top if the hash is just `#` with no value\n\n\n      if (hash === '') {\n        window.scrollTo(0, 0);\n        return;\n      } // First we check if the element by id is found\n\n\n      var idEl = document.getElementById(hash);\n\n      if (idEl) {\n        idEl.scrollIntoView();\n        return;\n      } // If there's no element with the id, we check the `name` property\n      // To mirror browsers\n\n\n      var nameEl = document.getElementsByName(hash)[0];\n\n      if (nameEl) {\n        nameEl.scrollIntoView();\n      }\n    }\n  }, {\n    key: \"urlIsNew\",\n    value: function urlIsNew(asPath) {\n      return this.asPath !== asPath;\n    }\n    /**\n    * Prefetch page code, you may wait for the data during page rendering.\n    * This feature only works in production!\n    * @param url the href of prefetched page\n    * @param asPath the as path of the prefetched page\n    */\n\n  }, {\n    key: \"prefetch\",\n    value: function () {\n      var _prefetch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(url) {\n        var asPath,\n            options,\n            parsed,\n            pathname,\n            route,\n            _args4 = arguments;\n        return _regeneratorRuntime.wrap(function _callee4$(_context4) {\n          while (1) {\n            switch (_context4.prev = _context4.next) {\n              case 0:\n                asPath = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : url;\n                options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};\n                parsed = tryParseRelativeUrl(url);\n\n                if (parsed) {\n                  _context4.next = 5;\n                  break;\n                }\n\n                return _context4.abrupt(\"return\");\n\n              case 5:\n                pathname = parsed.pathname; // Prefetch is not supported in development mode because it would trigger on-demand-entries\n\n                if (!true) {\n                  _context4.next = 8;\n                  break;\n                }\n\n                return _context4.abrupt(\"return\");\n\n              case 8:\n                route = (0, _normalizeTrailingSlash.removePathTrailingSlash)(pathname);\n                _context4.next = 11;\n                return Promise.all([this.pageLoader.prefetchData(url, asPath), this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route)]);\n\n              case 11:\n              case \"end\":\n                return _context4.stop();\n            }\n          }\n        }, _callee4, this);\n      }));\n\n      function prefetch(_x14) {\n        return _prefetch.apply(this, arguments);\n      }\n\n      return prefetch;\n    }()\n  }, {\n    key: \"fetchComponent\",\n    value: function () {\n      var _fetchComponent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(route) {\n        var cancelled, cancel, componentResult, error;\n        return _regeneratorRuntime.wrap(function _callee5$(_context5) {\n          while (1) {\n            switch (_context5.prev = _context5.next) {\n              case 0:\n                cancelled = false;\n\n                cancel = this.clc = function () {\n                  cancelled = true;\n                };\n\n                _context5.next = 4;\n                return this.pageLoader.loadPage(route);\n\n              case 4:\n                componentResult = _context5.sent;\n\n                if (!cancelled) {\n                  _context5.next = 9;\n                  break;\n                }\n\n                error = new Error(\"Abort fetching component for route: \\\"\".concat(route, \"\\\"\"));\n                error.cancelled = true;\n                throw error;\n\n              case 9:\n                if (cancel === this.clc) {\n                  this.clc = null;\n                }\n\n                return _context5.abrupt(\"return\", componentResult);\n\n              case 11:\n              case \"end\":\n                return _context5.stop();\n            }\n          }\n        }, _callee5, this);\n      }));\n\n      function fetchComponent(_x15) {\n        return _fetchComponent.apply(this, arguments);\n      }\n\n      return fetchComponent;\n    }()\n  }, {\n    key: \"_getData\",\n    value: function _getData(fn) {\n      var _this3 = this;\n\n      var cancelled = false;\n\n      var cancel = function cancel() {\n        cancelled = true;\n      };\n\n      this.clc = cancel;\n      return fn().then(function (data) {\n        if (cancel === _this3.clc) {\n          _this3.clc = null;\n        }\n\n        if (cancelled) {\n          var err = new Error('Loading initial props cancelled');\n          err.cancelled = true;\n          throw err;\n        }\n\n        return data;\n      });\n    }\n  }, {\n    key: \"_getStaticData\",\n    value: function _getStaticData(dataHref) {\n      var _this4 = this;\n\n      var _URL = new URL(dataHref, window.location.href),\n          cacheKey = _URL.href;\n\n      if (false && this.sdc[cacheKey]) {\n        return Promise.resolve(this.sdc[cacheKey]);\n      }\n\n      return fetchNextData(dataHref, this.isSsr).then(function (data) {\n        _this4.sdc[cacheKey] = data;\n        return data;\n      });\n    }\n  }, {\n    key: \"_getServerData\",\n    value: function _getServerData(dataHref) {\n      return fetchNextData(dataHref, this.isSsr);\n    }\n  }, {\n    key: \"getInitialProps\",\n    value: function getInitialProps(Component, ctx) {\n      var App = this.components['/_app'].Component;\n\n      var AppTree = this._wrapApp(App);\n\n      ctx.AppTree = AppTree;\n      return (0, _utils.loadGetInitialProps)(App, {\n        AppTree: AppTree,\n        Component: Component,\n        router: this,\n        ctx: ctx\n      });\n    }\n  }, {\n    key: \"abortComponentLoad\",\n    value: function abortComponentLoad(as) {\n      if (this.clc) {\n        Router.events.emit('routeChangeError', buildCancellationError(), as);\n        this.clc();\n        this.clc = null;\n      }\n    }\n  }, {\n    key: \"notify\",\n    value: function notify(data) {\n      return this.sub(data, this.components['/_app'].Component);\n    }\n  }], [{\n    key: \"_rewriteUrlForNextExport\",\n    value: function _rewriteUrlForNextExport(url) {\n      if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n        var rewriteUrlForNextExport = require('./rewrite-url-for-export').rewriteUrlForNextExport;\n\n        return rewriteUrlForNextExport(url);\n      } else {\n        return url;\n      }\n    }\n  }]);\n\n  return Router;\n}();\n\nexports[\"default\"] = Router;\nRouter.events = (0, _mitt[\"default\"])();","map":{"version":3,"sources":["../../../../next-server/lib/router/router.ts"],"names":["basePath","process","Object","cancelled","path","base","urlAsString","finalUrl","url","addBasePath","resolveHref","router","as","manualScrollRestoration","window","credentials","res","attempts","fetchRetry","isServerRender","err","Router","route","pathname","query","asPath","components","sdc","sub","clc","pageLoader","_bps","events","_wrapApp","isSsr","isFallback","_inFlightRoute","constructor","Component","props","__N_SSG","initialProps","__N_SSP","__NEXT_DATA__","debouncedScrollSave","clearTimeout","scrollDebounceTimeout","setTimeout","history","_N_X","_N_Y","rewriteUrlForNextExport","require","e","console","update","mod","data","newData","reload","options","prepareUrlAs","ST","performance","cleanedAs","delBasePath","parsed","tryParseRelativeUrl","method","shallow","routeRegex","routeMatch","missingParams","param","asPathname","routeInfo","appComp","buildCancellationError","page","error","cachedRouteInfo","isValidElementType","dataHref","onlyAHashChange","newHash","oldUrlNoHash","oldHash","scrollToHash","hash","idEl","document","nameEl","urlIsNew","Promise","cancel","componentResult","fn","_getStaticData","href","fetchNextData","_getServerData","getInitialProps","AppTree","ctx","abortComponentLoad","notify"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,IAAA,KAAA,GAAA,sBAAA,CAAA,OAAA,CAAA,SAAA,CAAA,CAAA;;AACA,IAAA,MAAA,GAAA,OAAA,CAAA,UAAA,CAAA;;AAQA,IAAA,UAAA,GAAA,OAAA,CAAA,oBAAA,CAAA;;AACA,IAAA,aAAA,GAAA,OAAA,CAAA,uBAAA,CAAA;;AACA,IAAA,WAAA,GAAA,OAAA,CAAA,qBAAA,CAAA;;AACA,IAAA,uBAAA,GAAA,OAAA,CAAA,oCAAA,CAAA;;AACA,IAAA,iBAAA,GAAA,OAAA,CAAA,4BAAA,CAAA;;AACA,IAAA,uBAAA,GAAA,OAAA,CAAA,0CAAA,CAAA;;;;;;AAnBA;AAAA;AACA;;;AAuBA,IAAMA,QAAQ,GAAIC,OAAO,CAAPA,GAAAA,CAAD,sBAACA,IAAlB,EAAA;;AAEA,SAA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AA;AACA,aAAA,GAAA;AACA,aAAA,GAAA,GAAA,IAAA;AAEH;AAEDoF;;;2BAAM,I,EAAiC;AACrC,aAAO,KAAA,GAAA,CAAA,IAAA,EAAe,KAAA,UAAA,CAAA,OAAA,EAAtB,SAAO,CAAP;AAhuB8C;;;6CA2IhD,G,EAAqD;AACnD,UAAIxG,OAAO,CAAPA,GAAAA,CAAJ,4BAAA,EAA8C;AAC5C,YAAMkD,uBAAuB,GAAGC,OAAO,CAAPA,0BAAO,CAAPA,CAAhC,uBAAA;;AAEA,eAAOD,uBAAuB,CAA9B,GAA8B,CAA9B;AAHF,OAAA,MAIO;AACL,eAAA,GAAA;AAEH;AA+CDI;;;;;;;AAlMmBlC,M,CAuBZW,MAvBYX,GAuBU,CAAA,GAAA,KAAA,WAAA,GAvBVA","sourcesContent":["/* global __NEXT_DATA__ */\n// tslint:disable:no-console\nimport { ParsedUrlQuery } from 'querystring'\nimport { ComponentType } from 'react'\nimport { UrlObject } from 'url'\nimport mitt, { MittEmitter } from '../mitt'\nimport {\n  AppContextType,\n  formatWithValidation,\n  getURL,\n  loadGetInitialProps,\n  NextPageContext,\n  ST,\n} from '../utils'\nimport { isDynamicRoute } from './utils/is-dynamic'\nimport { getRouteMatcher } from './utils/route-matcher'\nimport { getRouteRegex } from './utils/route-regex'\nimport { searchParamsToUrlQuery } from './utils/search-params-to-url-query'\nimport { parseRelativeUrl } from './utils/parse-relative-url'\nimport {\n  removePathTrailingSlash,\n  normalizePathTrailingSlash,\n} from '../../../client/normalize-trailing-slash'\n\nconst basePath = (process.env.__NEXT_ROUTER_BASEPATH as string) || ''\n\nfunction buildCancellationError() {\n  return Object.assign(new Error('Route Cancelled'), {\n    cancelled: true,\n  })\n}\n\nexport function addBasePath(path: string): string {\n  return basePath\n    ? path === '/'\n      ? normalizePathTrailingSlash(basePath)\n      : basePath + path\n    : path\n}\n\nexport function delBasePath(path: string): string {\n  return path.slice(basePath.length) || '/'\n}\n\ntype Url = UrlObject | string\n\n/**\n * Resolves a given hyperlink with a certain router state (basePath not included).\n * Preserves absolute urls.\n */\nexport function resolveHref(currentPath: string, href: Url): string {\n  // we use a dummy base url for relative urls\n  const base = new URL(currentPath, 'http://n')\n  const urlAsString =\n    typeof href === 'string' ? href : formatWithValidation(href)\n  const finalUrl = new URL(urlAsString, base)\n  finalUrl.pathname = normalizePathTrailingSlash(finalUrl.pathname)\n  // if the origin didn't change, it means we received a relative href\n  return finalUrl.origin === base.origin\n    ? finalUrl.href.slice(finalUrl.origin.length)\n    : finalUrl.href\n}\n\nfunction prepareUrlAs(router: NextRouter, url: Url, as: Url) {\n  // If url and as provided as an object representation,\n  // we'll format them into the string version here.\n  return {\n    url: addBasePath(resolveHref(router.pathname, url)),\n    as: as ? addBasePath(resolveHref(router.pathname, as)) : as,\n  }\n}\n\nfunction tryParseRelativeUrl(\n  url: string\n): null | ReturnType<typeof parseRelativeUrl> {\n  try {\n    return parseRelativeUrl(url)\n  } catch (err) {\n    if (process.env.NODE_ENV !== 'production') {\n      throw new Error(\n        `Invalid href passed to router: ${url} https://err.sh/vercel/next.js/invalid-href-passed`\n      )\n    }\n    return null\n  }\n}\n\ntype ComponentRes = { page: ComponentType; mod: any }\n\nexport type BaseRouter = {\n  route: string\n  pathname: string\n  query: ParsedUrlQuery\n  asPath: string\n  basePath: string\n}\n\nexport type NextRouter = BaseRouter &\n  Pick<\n    Router,\n    | 'push'\n    | 'replace'\n    | 'reload'\n    | 'back'\n    | 'prefetch'\n    | 'beforePopState'\n    | 'events'\n    | 'isFallback'\n  >\n\nexport type PrefetchOptions = {\n  priority?: boolean\n}\n\ntype RouteInfo = {\n  Component: ComponentType\n  __N_SSG?: boolean\n  __N_SSP?: boolean\n  props?: any\n  err?: Error\n  error?: any\n}\n\ntype Subscription = (data: RouteInfo, App?: ComponentType) => Promise<void>\n\ntype BeforePopStateCallback = (state: any) => boolean\n\ntype ComponentLoadCancel = (() => void) | null\n\ntype HistoryMethod = 'replaceState' | 'pushState'\n\nconst manualScrollRestoration =\n  process.env.__NEXT_SCROLL_RESTORATION &&\n  typeof window !== 'undefined' &&\n  'scrollRestoration' in window.history\n\nfunction fetchRetry(url: string, attempts: number): Promise<any> {\n  return fetch(url, {\n    // Cookies are required to be present for Next.js' SSG \"Preview Mode\".\n    // Cookies may also be required for `getServerSideProps`.\n    //\n    // > `fetch` won’t send cookies, unless you set the credentials init\n    // > option.\n    // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch\n    //\n    // > For maximum browser compatibility when it comes to sending &\n    // > receiving cookies, always supply the `credentials: 'same-origin'`\n    // > option instead of relying on the default.\n    // https://github.com/github/fetch#caveats\n    credentials: 'same-origin',\n  }).then((res) => {\n    if (!res.ok) {\n      if (attempts > 1 && res.status >= 500) {\n        return fetchRetry(url, attempts - 1)\n      }\n      throw new Error(`Failed to load static props`)\n    }\n\n    return res.json()\n  })\n}\n\nfunction fetchNextData(dataHref: string, isServerRender: boolean) {\n  return fetchRetry(dataHref, isServerRender ? 3 : 1).catch((err: Error) => {\n    // We should only trigger a server-side transition if this was caused\n    // on a client-side transition. Otherwise, we'd get into an infinite\n    // loop.\n    if (!isServerRender) {\n      ;(err as any).code = 'PAGE_LOAD_ERROR'\n    }\n    throw err\n  })\n}\n\nexport default class Router implements BaseRouter {\n  route: string\n  pathname: string\n  query: ParsedUrlQuery\n  asPath: string\n  basePath: string\n\n  /**\n   * Map of all components loaded in `Router`\n   */\n  components: { [pathname: string]: RouteInfo }\n  // Static Data Cache\n  sdc: { [asPath: string]: object } = {}\n  sub: Subscription\n  clc: ComponentLoadCancel\n  pageLoader: any\n  _bps: BeforePopStateCallback | undefined\n  events: MittEmitter\n  _wrapApp: (App: ComponentType) => any\n  isSsr: boolean\n  isFallback: boolean\n  _inFlightRoute?: string\n\n  static events: MittEmitter = mitt()\n\n  constructor(\n    pathname: string,\n    query: ParsedUrlQuery,\n    as: string,\n    {\n      initialProps,\n      pageLoader,\n      App,\n      wrapApp,\n      Component,\n      err,\n      subscription,\n      isFallback,\n    }: {\n      subscription: Subscription\n      initialProps: any\n      pageLoader: any\n      Component: ComponentType\n      App: ComponentType\n      wrapApp: (App: ComponentType) => any\n      err?: Error\n      isFallback: boolean\n    }\n  ) {\n    // represents the current component key\n    this.route = removePathTrailingSlash(pathname)\n\n    // set up the component cache (by route keys)\n    this.components = {}\n    // We should not keep the cache, if there's an error\n    // Otherwise, this cause issues when when going back and\n    // come again to the errored page.\n    if (pathname !== '/_error') {\n      this.components[this.route] = {\n        Component,\n        props: initialProps,\n        err,\n        __N_SSG: initialProps && initialProps.__N_SSG,\n        __N_SSP: initialProps && initialProps.__N_SSP,\n      }\n    }\n\n    this.components['/_app'] = { Component: App }\n\n    // Backwards compat for Router.router.events\n    // TODO: Should be remove the following major version as it was never documented\n    this.events = Router.events\n\n    this.pageLoader = pageLoader\n    this.pathname = pathname\n    this.query = query\n    // if auto prerendered and dynamic route wait to update asPath\n    // until after mount to prevent hydration mismatch\n    this.asPath =\n      // @ts-ignore this is temporarily global (attached to window)\n      isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as\n    this.basePath = basePath\n    this.sub = subscription\n    this.clc = null\n    this._wrapApp = wrapApp\n    // make sure to ignore extra popState in safari on navigating\n    // back from external site\n    this.isSsr = true\n\n    this.isFallback = isFallback\n\n    if (typeof window !== 'undefined') {\n      // make sure \"as\" doesn't start with double slashes or else it can\n      // throw an error as it's considered invalid\n      if (as.substr(0, 2) !== '//') {\n        // in order for `e.state` to work on the `onpopstate` event\n        // we have to register the initial route upon initialization\n\n        this.changeState(\n          'replaceState',\n          formatWithValidation({ pathname: addBasePath(pathname), query }),\n          getURL()\n        )\n      }\n\n      window.addEventListener('popstate', this.onPopState)\n\n      // enable custom scroll restoration handling when available\n      // otherwise fallback to browser's default handling\n      if (process.env.__NEXT_SCROLL_RESTORATION) {\n        if (manualScrollRestoration) {\n          window.history.scrollRestoration = 'manual'\n\n          let scrollDebounceTimeout: undefined | NodeJS.Timeout\n\n          const debouncedScrollSave = () => {\n            if (scrollDebounceTimeout) clearTimeout(scrollDebounceTimeout)\n\n            scrollDebounceTimeout = setTimeout(() => {\n              const { url, as: curAs, options } = history.state\n              this.changeState(\n                'replaceState',\n                url,\n                curAs,\n                Object.assign({}, options, {\n                  _N_X: window.scrollX,\n                  _N_Y: window.scrollY,\n                })\n              )\n            }, 10)\n          }\n\n          window.addEventListener('scroll', debouncedScrollSave)\n        }\n      }\n    }\n  }\n\n  // @deprecated backwards compatibility even though it's a private method.\n  static _rewriteUrlForNextExport(url: string): string {\n    if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n      const rewriteUrlForNextExport = require('./rewrite-url-for-export')\n        .rewriteUrlForNextExport\n      return rewriteUrlForNextExport(url)\n    } else {\n      return url\n    }\n  }\n\n  onPopState = (e: PopStateEvent): void => {\n    if (!e.state) {\n      // We get state as undefined for two reasons.\n      //  1. With older safari (< 8) and older chrome (< 34)\n      //  2. When the URL changed with #\n      //\n      // In the both cases, we don't need to proceed and change the route.\n      // (as it's already changed)\n      // But we can simply replace the state with the new changes.\n      // Actually, for (1) we don't need to nothing. But it's hard to detect that event.\n      // So, doing the following for (1) does no harm.\n      const { pathname, query } = this\n      this.changeState(\n        'replaceState',\n        formatWithValidation({ pathname: addBasePath(pathname), query }),\n        getURL()\n      )\n      return\n    }\n\n    const { url, as, options } = e.state\n    const { pathname } = parseRelativeUrl(url)\n\n    // Make sure we don't re-render on initial load,\n    // can be caused by navigating back from an external site\n    if (this.isSsr && as === this.asPath && pathname === this.pathname) {\n      return\n    }\n\n    // If the downstream application returns falsy, return.\n    // They will then be responsible for handling the event.\n    if (this._bps && !this._bps(e.state)) {\n      return\n    }\n\n    if (process.env.NODE_ENV !== 'production') {\n      if (typeof url === 'undefined' || typeof as === 'undefined') {\n        console.warn(\n          '`popstate` event triggered but `event.state` did not have `url` or `as` https://err.sh/vercel/next.js/popstate-state-empty'\n        )\n      }\n    }\n    this.change('replaceState', url, as, options)\n  }\n\n  update(route: string, mod: any) {\n    const Component: ComponentType = mod.default || mod\n    const data = this.components[route]\n    if (!data) {\n      throw new Error(`Cannot update unavailable route: ${route}`)\n    }\n\n    const newData = Object.assign({}, data, {\n      Component,\n      __N_SSG: mod.__N_SSG,\n      __N_SSP: mod.__N_SSP,\n    })\n    this.components[route] = newData\n\n    // pages/_app.js updated\n    if (route === '/_app') {\n      this.notify(this.components[this.route])\n      return\n    }\n\n    if (route === this.route) {\n      this.notify(newData)\n    }\n  }\n\n  reload(): void {\n    window.location.reload()\n  }\n\n  /**\n   * Go back in history\n   */\n  back() {\n    window.history.back()\n  }\n\n  /**\n   * Performs a `pushState` with arguments\n   * @param url of the route\n   * @param as masks `url` for the browser\n   * @param options object you can define `shallow` and other options\n   */\n  push(url: Url, as: Url = url, options = {}) {\n    ;({ url, as } = prepareUrlAs(this, url, as))\n    return this.change('pushState', url, as, options)\n  }\n\n  /**\n   * Performs a `replaceState` with arguments\n   * @param url of the route\n   * @param as masks `url` for the browser\n   * @param options object you can define `shallow` and other options\n   */\n  replace(url: Url, as: Url = url, options = {}) {\n    ;({ url, as } = prepareUrlAs(this, url, as))\n    return this.change('replaceState', url, as, options)\n  }\n\n  async change(\n    method: HistoryMethod,\n    url: string,\n    as: string,\n    options: any\n  ): Promise<boolean> {\n    if (!options._h) {\n      this.isSsr = false\n    }\n    // marking route changes as a navigation start entry\n    if (ST) {\n      performance.mark('routeChange')\n    }\n\n    // Add the ending slash to the paths. So, we can serve the\n    // \"<page>/index.html\" directly for the SSR page.\n    if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n      const rewriteUrlForNextExport = require('./rewrite-url-for-export')\n        .rewriteUrlForNextExport\n      // @ts-ignore this is temporarily global (attached to window)\n      if (__NEXT_DATA__.nextExport) {\n        as = rewriteUrlForNextExport(as)\n      }\n    }\n\n    if (this._inFlightRoute) {\n      this.abortComponentLoad(this._inFlightRoute)\n    }\n\n    const cleanedAs = delBasePath(as)\n    this._inFlightRoute = as\n\n    // If the url change is only related to a hash change\n    // We should not proceed. We should only change the state.\n\n    // WARNING: `_h` is an internal option for handing Next.js client-side\n    // hydration. Your app should _never_ use this property. It may change at\n    // any time without notice.\n    if (!options._h && this.onlyAHashChange(cleanedAs)) {\n      this.asPath = cleanedAs\n      Router.events.emit('hashChangeStart', as)\n      this.changeState(method, url, as, options)\n      this.scrollToHash(cleanedAs)\n      Router.events.emit('hashChangeComplete', as)\n      return true\n    }\n\n    const parsed = tryParseRelativeUrl(url)\n\n    if (!parsed) return false\n\n    let { pathname, searchParams } = parsed\n    const query = searchParamsToUrlQuery(searchParams)\n\n    // url and as should always be prefixed with basePath by this\n    // point by either next/link or router.push/replace so strip the\n    // basePath from the pathname to match the pages dir 1-to-1\n    pathname = pathname\n      ? removePathTrailingSlash(delBasePath(pathname))\n      : pathname\n\n    // If asked to change the current URL we should reload the current page\n    // (not location.reload() but reload getInitialProps and other Next.js stuffs)\n    // We also need to set the method = replaceState always\n    // as this should not go into the history (That's how browsers work)\n    // We should compare the new asPath to the current asPath, not the url\n    if (!this.urlIsNew(cleanedAs)) {\n      method = 'replaceState'\n    }\n\n    const route = removePathTrailingSlash(pathname)\n    const { shallow = false } = options\n\n    if (isDynamicRoute(route)) {\n      const { pathname: asPathname } = parseRelativeUrl(cleanedAs)\n      const routeRegex = getRouteRegex(route)\n      const routeMatch = getRouteMatcher(routeRegex)(asPathname)\n      if (!routeMatch) {\n        const missingParams = Object.keys(routeRegex.groups).filter(\n          (param) => !query[param]\n        )\n\n        if (missingParams.length > 0) {\n          if (process.env.NODE_ENV !== 'production') {\n            console.warn(\n              `Mismatching \\`as\\` and \\`href\\` failed to manually provide ` +\n                `the params: ${missingParams.join(\n                  ', '\n                )} in the \\`href\\`'s \\`query\\``\n            )\n          }\n\n          throw new Error(\n            `The provided \\`as\\` value (${asPathname}) is incompatible with the \\`href\\` value (${route}). ` +\n              `Read more: https://err.sh/vercel/next.js/incompatible-href-as`\n          )\n        }\n      } else {\n        // Merge params into `query`, overwriting any specified in search\n        Object.assign(query, routeMatch)\n      }\n    }\n\n    Router.events.emit('routeChangeStart', as)\n\n    try {\n      const routeInfo = await this.getRouteInfo(\n        route,\n        pathname,\n        query,\n        as,\n        shallow\n      )\n      const { error } = routeInfo\n\n      Router.events.emit('beforeHistoryChange', as)\n      this.changeState(method, url, as, options)\n\n      if (process.env.NODE_ENV !== 'production') {\n        const appComp: any = this.components['/_app'].Component\n        ;(window as any).next.isPrerendered =\n          appComp.getInitialProps === appComp.origGetInitialProps &&\n          !(routeInfo.Component as any).getInitialProps\n      }\n\n      await this.set(route, pathname!, query, cleanedAs, routeInfo)\n\n      if (error) {\n        Router.events.emit('routeChangeError', error, cleanedAs)\n        throw error\n      }\n\n      if (process.env.__NEXT_SCROLL_RESTORATION) {\n        if (manualScrollRestoration && '_N_X' in options) {\n          window.scrollTo(options._N_X, options._N_Y)\n        }\n      }\n      Router.events.emit('routeChangeComplete', as)\n\n      return true\n    } catch (err) {\n      if (err.cancelled) {\n        return false\n      }\n      throw err\n    }\n  }\n\n  changeState(\n    method: HistoryMethod,\n    url: string,\n    as: string,\n    options = {}\n  ): void {\n    if (process.env.NODE_ENV !== 'production') {\n      if (typeof window.history === 'undefined') {\n        console.error(`Warning: window.history is not available.`)\n        return\n      }\n\n      if (typeof window.history[method] === 'undefined') {\n        console.error(`Warning: window.history.${method} is not available`)\n        return\n      }\n    }\n\n    if (method !== 'pushState' || getURL() !== as) {\n      window.history[method](\n        {\n          url,\n          as,\n          options,\n        },\n        // Most browsers currently ignores this parameter, although they may use it in the future.\n        // Passing the empty string here should be safe against future changes to the method.\n        // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState\n        '',\n        as\n      )\n    }\n  }\n\n  async handleRouteInfoError(\n    err: Error & { code: any; cancelled: boolean },\n    pathname: string,\n    query: any,\n    as: string,\n    loadErrorFail?: boolean\n  ): Promise<RouteInfo> {\n    if (err.cancelled) {\n      // bubble up cancellation errors\n      throw err\n    }\n\n    if (err.code === 'PAGE_LOAD_ERROR' || loadErrorFail) {\n      Router.events.emit('routeChangeError', err, as)\n\n      // If we can't load the page it could be one of following reasons\n      //  1. Page doesn't exists\n      //  2. Page does exist in a different zone\n      //  3. Internal error while loading the page\n\n      // So, doing a hard reload is the proper way to deal with this.\n      window.location.href = as\n\n      // Changing the URL doesn't block executing the current code path.\n      // So let's throw a cancellation error stop the routing logic.\n      throw buildCancellationError()\n    }\n\n    try {\n      const { page: Component } = await this.fetchComponent('/_error')\n      const routeInfo: RouteInfo = { Component, err, error: err }\n\n      try {\n        routeInfo.props = await this.getInitialProps(Component, {\n          err,\n          pathname,\n          query,\n        } as any)\n      } catch (gipErr) {\n        console.error('Error in error page `getInitialProps`: ', gipErr)\n        routeInfo.props = {}\n      }\n\n      return routeInfo\n    } catch (routeInfoErr) {\n      return this.handleRouteInfoError(routeInfoErr, pathname, query, as, true)\n    }\n  }\n\n  async getRouteInfo(\n    route: string,\n    pathname: string,\n    query: any,\n    as: string,\n    shallow: boolean = false\n  ): Promise<RouteInfo> {\n    try {\n      const cachedRouteInfo = this.components[route]\n\n      if (shallow && cachedRouteInfo && this.route === route) {\n        return cachedRouteInfo\n      }\n\n      const routeInfo = cachedRouteInfo\n        ? cachedRouteInfo\n        : await this.fetchComponent(route).then(\n            (res) =>\n              ({\n                Component: res.page,\n                __N_SSG: res.mod.__N_SSG,\n                __N_SSP: res.mod.__N_SSP,\n              } as RouteInfo)\n          )\n\n      const { Component, __N_SSG, __N_SSP } = routeInfo\n\n      if (process.env.NODE_ENV !== 'production') {\n        const { isValidElementType } = require('react-is')\n        if (!isValidElementType(Component)) {\n          throw new Error(\n            `The default export is not a React Component in page: \"${pathname}\"`\n          )\n        }\n      }\n\n      let dataHref: string | undefined\n\n      if (__N_SSG || __N_SSP) {\n        dataHref = this.pageLoader.getDataHref(\n          formatWithValidation({ pathname, query }),\n          as,\n          __N_SSG\n        )\n      }\n\n      const props = await this._getData<RouteInfo>(() =>\n        __N_SSG\n          ? this._getStaticData(dataHref!)\n          : __N_SSP\n          ? this._getServerData(dataHref!)\n          : this.getInitialProps(\n              Component,\n              // we provide AppTree later so this needs to be `any`\n              {\n                pathname,\n                query,\n                asPath: as,\n              } as any\n            )\n      )\n      routeInfo.props = props\n      this.components[route] = routeInfo\n      return routeInfo\n    } catch (err) {\n      return this.handleRouteInfoError(err, pathname, query, as)\n    }\n  }\n\n  set(\n    route: string,\n    pathname: string,\n    query: any,\n    as: string,\n    data: RouteInfo\n  ): Promise<void> {\n    this.isFallback = false\n\n    this.route = route\n    this.pathname = pathname\n    this.query = query\n    this.asPath = as\n    return this.notify(data)\n  }\n\n  /**\n   * Callback to execute before replacing router state\n   * @param cb callback to be executed\n   */\n  beforePopState(cb: BeforePopStateCallback) {\n    this._bps = cb\n  }\n\n  onlyAHashChange(as: string): boolean {\n    if (!this.asPath) return false\n    const [oldUrlNoHash, oldHash] = this.asPath.split('#')\n    const [newUrlNoHash, newHash] = as.split('#')\n\n    // Makes sure we scroll to the provided hash if the url/hash are the same\n    if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {\n      return true\n    }\n\n    // If the urls are change, there's more than a hash change\n    if (oldUrlNoHash !== newUrlNoHash) {\n      return false\n    }\n\n    // If the hash has changed, then it's a hash only change.\n    // This check is necessary to handle both the enter and\n    // leave hash === '' cases. The identity case falls through\n    // and is treated as a next reload.\n    return oldHash !== newHash\n  }\n\n  scrollToHash(as: string): void {\n    const [, hash] = as.split('#')\n    // Scroll to top if the hash is just `#` with no value\n    if (hash === '') {\n      window.scrollTo(0, 0)\n      return\n    }\n\n    // First we check if the element by id is found\n    const idEl = document.getElementById(hash)\n    if (idEl) {\n      idEl.scrollIntoView()\n      return\n    }\n    // If there's no element with the id, we check the `name` property\n    // To mirror browsers\n    const nameEl = document.getElementsByName(hash)[0]\n    if (nameEl) {\n      nameEl.scrollIntoView()\n    }\n  }\n\n  urlIsNew(asPath: string): boolean {\n    return this.asPath !== asPath\n  }\n\n  /**\n   * Prefetch page code, you may wait for the data during page rendering.\n   * This feature only works in production!\n   * @param url the href of prefetched page\n   * @param asPath the as path of the prefetched page\n   */\n  async prefetch(\n    url: string,\n    asPath: string = url,\n    options: PrefetchOptions = {}\n  ): Promise<void> {\n    const parsed = tryParseRelativeUrl(url)\n\n    if (!parsed) return\n\n    const { pathname } = parsed\n\n    // Prefetch is not supported in development mode because it would trigger on-demand-entries\n    if (process.env.NODE_ENV !== 'production') {\n      return\n    }\n\n    const route = removePathTrailingSlash(pathname)\n    await Promise.all([\n      this.pageLoader.prefetchData(url, asPath),\n      this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route),\n    ])\n  }\n\n  async fetchComponent(route: string): Promise<ComponentRes> {\n    let cancelled = false\n    const cancel = (this.clc = () => {\n      cancelled = true\n    })\n\n    const componentResult = await this.pageLoader.loadPage(route)\n\n    if (cancelled) {\n      const error: any = new Error(\n        `Abort fetching component for route: \"${route}\"`\n      )\n      error.cancelled = true\n      throw error\n    }\n\n    if (cancel === this.clc) {\n      this.clc = null\n    }\n\n    return componentResult\n  }\n\n  _getData<T>(fn: () => Promise<T>): Promise<T> {\n    let cancelled = false\n    const cancel = () => {\n      cancelled = true\n    }\n    this.clc = cancel\n    return fn().then((data) => {\n      if (cancel === this.clc) {\n        this.clc = null\n      }\n\n      if (cancelled) {\n        const err: any = new Error('Loading initial props cancelled')\n        err.cancelled = true\n        throw err\n      }\n\n      return data\n    })\n  }\n\n  _getStaticData(dataHref: string): Promise<object> {\n    const { href: cacheKey } = new URL(dataHref, window.location.href)\n    if (process.env.NODE_ENV === 'production' && this.sdc[cacheKey]) {\n      return Promise.resolve(this.sdc[cacheKey])\n    }\n    return fetchNextData(dataHref, this.isSsr).then((data) => {\n      this.sdc[cacheKey] = data\n      return data\n    })\n  }\n\n  _getServerData(dataHref: string): Promise<object> {\n    return fetchNextData(dataHref, this.isSsr)\n  }\n\n  getInitialProps(\n    Component: ComponentType,\n    ctx: NextPageContext\n  ): Promise<any> {\n    const { Component: App } = this.components['/_app']\n    const AppTree = this._wrapApp(App)\n    ctx.AppTree = AppTree\n    return loadGetInitialProps<AppContextType<Router>>(App, {\n      AppTree,\n      Component,\n      router: this,\n      ctx,\n    })\n  }\n\n  abortComponentLoad(as: string): void {\n    if (this.clc) {\n      Router.events.emit('routeChangeError', buildCancellationError(), as)\n      this.clc()\n      this.clc = null\n    }\n  }\n\n  notify(data: RouteInfo): Promise<void> {\n    return this.sub(data, this.components['/_app'].Component)\n  }\n}\n"]},"metadata":{},"sourceType":"script"}