@zigbang/honeyfarm-dashboard
Version:
HoneyFarm Node에 등록 되어 있는 안드로이드 단말을 웹페이지에서 실시간으로 확인 및 사용 할수 있도록 구현된 웹
1 lines • 125 kB
JSON
{"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.addLocale = addLocale;\nexports.delLocale = delLocale;\nexports.hasBasePath = hasBasePath;\nexports.addBasePath = addBasePath;\nexports.delBasePath = delBasePath;\nexports.isLocalURL = isLocalURL;\nexports.interpolateAs = interpolateAs;\nexports.resolveHref = resolveHref;\nexports[\"default\"] = void 0;\n\nvar _normalizeTrailingSlash = require(\"../../../client/normalize-trailing-slash\");\n\nvar _routeLoader = require(\"../../../client/route-loader\");\n\nvar _denormalizePagePath = require(\"../../server/denormalize-page-path\");\n\nvar _normalizeLocalePath = require(\"../i18n/normalize-locale-path\");\n\nvar _mitt = _interopRequireDefault(require(\"../mitt\"));\n\nvar _utils = require(\"../utils\");\n\nvar _escapePathDelimiters = _interopRequireDefault(require(\"./utils/escape-path-delimiters\"));\n\nvar _isDynamic = require(\"./utils/is-dynamic\");\n\nvar _parseRelativeUrl = require(\"./utils/parse-relative-url\");\n\nvar _querystring = require(\"./utils/querystring\");\n\nvar _resolveRewrites = _interopRequireDefault(require(\"./utils/resolve-rewrites\"));\n\nvar _routeMatcher = require(\"./utils/route-matcher\");\n\nvar _routeRegex = require(\"./utils/route-regex\");\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 addPathPrefix(path, prefix) {\n return prefix && path.startsWith('/') ? path === '/' ? (0, _normalizeTrailingSlash.normalizePathTrailingSlash)(prefix) : \"\".concat(prefix).concat(path) : path;\n}\n\nfunction addLocale(path, locale, defaultLocale) {\n if (process.env.__NEXT_I18N_SUPPORT) {\n return locale && locale !== defaultLocale && !path.startsWith('/' + locale + '/') && path !== '/' + locale ? addPathPrefix(path, '/' + locale) : path;\n }\n\n return path;\n}\n\nfunction delLocale(path, locale) {\n if (process.env.__NEXT_I18N_SUPPORT) {\n return locale && (path.startsWith('/' + locale + '/') || path === '/' + locale) ? path.substr(locale.length + 1) || '/' : path;\n }\n\n return path;\n}\n\nfunction hasBasePath(path) {\n return path === basePath || path.startsWith(basePath + '/');\n}\n\nfunction addBasePath(path) {\n // we only add the basepath on relative urls\n return addPathPrefix(path, basePath);\n}\n\nfunction delBasePath(path) {\n return path.slice(basePath.length) || '/';\n}\n/**\n* Detects whether a given url is routable by the Next.js router (browser only).\n*/\n\n\nfunction isLocalURL(url) {\n if (url.startsWith('/')) return true;\n\n try {\n // absolute urls can be local if they are on the same origin\n var locationOrigin = (0, _utils.getLocationOrigin)();\n var resolved = new URL(url, locationOrigin);\n return resolved.origin === locationOrigin && hasBasePath(resolved.pathname);\n } catch (_) {\n return false;\n }\n}\n\nfunction interpolateAs(route, asPathname, query) {\n var interpolatedRoute = '';\n var dynamicRegex = (0, _routeRegex.getRouteRegex)(route);\n var dynamicGroups = dynamicRegex.groups;\n var dynamicMatches = // Try to match the dynamic route against the asPath\n (asPathname !== route ? (0, _routeMatcher.getRouteMatcher)(dynamicRegex)(asPathname) : '') || // Fall back to reading the values from the href\n // TODO: should this take priority; also need to change in the router.\n query;\n interpolatedRoute = route;\n var params = Object.keys(dynamicGroups);\n\n if (!params.every(function (param) {\n var value = dynamicMatches[param] || '';\n var _dynamicGroups$param = dynamicGroups[param],\n repeat = _dynamicGroups$param.repeat,\n optional = _dynamicGroups$param.optional; // support single-level catch-all\n // TODO: more robust handling for user-error (passing `/`)\n\n var replaced = \"[\".concat(repeat ? '...' : '').concat(param, \"]\");\n\n if (optional) {\n replaced = \"\".concat(!value ? '/' : '', \"[\").concat(replaced, \"]\");\n }\n\n if (repeat && !Array.isArray(value)) value = [value];\n return (optional || param in dynamicMatches) && ( // Interpolate group into data URL if present\n interpolatedRoute = interpolatedRoute.replace(replaced, repeat ? value.map(_escapePathDelimiters[\"default\"]).join('/') : (0, _escapePathDelimiters[\"default\"])(value)) || '/');\n })) {\n interpolatedRoute = ''; // did not satisfy all requirements\n // n.b. We ignore this error because we handle warning for this case in\n // development in the `<Link>` component directly.\n }\n\n return {\n params: params,\n result: interpolatedRoute\n };\n}\n\nfunction omitParmsFromQuery(query, params) {\n var filteredQuery = {};\n Object.keys(query).forEach(function (key) {\n if (!params.includes(key)) {\n filteredQuery[key] = query[key];\n }\n });\n return filteredQuery;\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, resolveAs) {\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); // Return because it cannot be routed by the Next.js router\n\n if (!isLocalURL(urlAsString)) {\n return resolveAs ? [urlAsString] : urlAsString;\n }\n\n try {\n var finalUrl = new URL(urlAsString, base);\n finalUrl.pathname = (0, _normalizeTrailingSlash.normalizePathTrailingSlash)(finalUrl.pathname);\n var interpolatedAs = '';\n\n if ((0, _isDynamic.isDynamicRoute)(finalUrl.pathname) && finalUrl.searchParams && resolveAs) {\n var query = (0, _querystring.searchParamsToUrlQuery)(finalUrl.searchParams);\n\n var _interpolateAs = interpolateAs(finalUrl.pathname, finalUrl.pathname, query),\n result = _interpolateAs.result,\n params = _interpolateAs.params;\n\n if (result) {\n interpolatedAs = (0, _utils.formatWithValidation)({\n pathname: result,\n hash: finalUrl.hash,\n query: omitParmsFromQuery(query, params)\n });\n }\n } // if the origin didn't change, it means we received a relative href\n\n\n var resolvedHref = finalUrl.origin === base.origin ? finalUrl.href.slice(finalUrl.origin.length) : finalUrl.href;\n return resolveAs ? [resolvedHref, interpolatedAs || resolvedHref] : resolvedHref;\n } catch (_) {\n return resolveAs ? [urlAsString] : urlAsString;\n }\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\nvar manualScrollRestoration = process.env.__NEXT_SCROLL_RESTORATION && true && 'scrollRestoration' in window.history;\nvar SSG_DATA_NOT_FOUND_ERROR = 'SSG Data NOT_FOUND';\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 if (res.status === 404) {\n // TODO: handle reloading in development from fallback returning 200\n // to on-demand-entry-handler causing it to reload periodically\n throw new Error(SSG_DATA_NOT_FOUND_ERROR);\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 (0, _routeLoader.markAssetError)(err);\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 locale = _ref.locale,\n locales = _ref.locales,\n defaultLocale = _ref.defaultLocale;\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 this._shallow = void 0;\n this.locale = void 0;\n this.locales = void 0;\n this.defaultLocale = void 0;\n\n this.onPopState = function (e) {\n var state = e.state;\n\n if (!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 if (!state.__N) {\n return;\n }\n\n var url = state.url,\n as = state.as,\n options = 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(state)) {\n return;\n }\n\n _this.change('replaceState', url, as, Object.assign({}, options, {\n shallow: options.shallow && _this._shallow,\n locale: options.locale || _this.defaultLocale\n }));\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 initial: true,\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 styleSheets: [\n /* /_app does not need its stylesheets managed */\n ]\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 (process.env.__NEXT_I18N_SUPPORT) {\n this.locale = locale;\n this.locales = locales;\n this.defaultLocale = defaultLocale;\n }\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 locale: locale\n });\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 }\n\n _createClass(Router, [{\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 _this2 = this;\n\n var localeChange, _this$locales, parsedAs, localePathResult, _options$shallow, shallow, routeProps, cleanedAs, parsed, _parsed, pathname, query, pages, rewrites, _yield, route, resolvedAs, potentialHref, _parsedAs, asPathname, routeRegex, routeMatch, shouldInterpolate, interpolatedAs, missingParams, routeInfo, error, props, __N_SSG, __N_SSP, destination, parsedHref, _prepareUrlAs3, newUrl, newAs, appComp;\n\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n if (isLocalURL(url)) {\n _context.next = 3;\n break;\n }\n\n window.location.href = url;\n return _context.abrupt(\"return\", false);\n\n case 3:\n localeChange = options.locale !== this.locale;\n\n if (!process.env.__NEXT_I18N_SUPPORT) {\n _context.next = 14;\n break;\n }\n\n this.locale = options.locale === false ? this.defaultLocale : options.locale || this.locale;\n\n if (typeof options.locale === 'undefined') {\n options.locale = this.locale;\n }\n\n parsedAs = (0, _parseRelativeUrl.parseRelativeUrl)(hasBasePath(as) ? delBasePath(as) : as);\n localePathResult = (0, _normalizeLocalePath.normalizeLocalePath)(parsedAs.pathname, this.locales);\n\n if (localePathResult.detectedLocale) {\n this.locale = localePathResult.detectedLocale;\n url = addBasePath(localePathResult.pathname);\n } // if the locale isn't configured hard navigate to show 404 page\n\n\n if ((_this$locales = this.locales) == null ? void 0 : _this$locales.includes(this.locale)) {\n _context.next = 14;\n break;\n }\n\n parsedAs.pathname = addLocale(parsedAs.pathname, this.locale);\n window.location.href = (0, _utils.formatWithValidation)(parsedAs);\n return _context.abrupt(\"return\", new Promise(function () {}));\n\n case 14:\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 }\n\n _options$shallow = options.shallow, shallow = _options$shallow === void 0 ? false : _options$shallow;\n routeProps = {\n shallow: shallow\n };\n\n if (this._inFlightRoute) {\n this.abortComponentLoad(this._inFlightRoute, routeProps);\n }\n\n as = addBasePath(addLocale(hasBasePath(as) ? delBasePath(as) : as, options.locale, this.defaultLocale));\n cleanedAs = delLocale(hasBasePath(as) ? delBasePath(as) : as, this.locale);\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 = 30;\n break;\n }\n\n this.asPath = cleanedAs;\n Router.events.emit('hashChangeStart', as, routeProps); // TODO: do we need the resolved href when only a hash change?\n\n this.changeState(method, url, as, options);\n this.scrollToHash(cleanedAs);\n this.notify(this.components[this.route]);\n Router.events.emit('hashChangeComplete', as, routeProps);\n return _context.abrupt(\"return\", true);\n\n case 30:\n parsed = (0, _parseRelativeUrl.parseRelativeUrl)(url);\n _parsed = parsed, pathname = _parsed.pathname, query = _parsed.query; // The build manifest needs to be loaded before auto-static dynamic pages\n // get their query parameters to allow ensuring they can be parsed properly\n // when rewritten to\n\n _context.prev = 32;\n _context.next = 35;\n return this.pageLoader.getPageList();\n\n case 35:\n pages = _context.sent;\n _context.next = 38;\n return (0, _routeLoader.getClientBuildManifest)();\n\n case 38:\n _yield = _context.sent;\n rewrites = _yield.__rewrites;\n _context.next = 46;\n break;\n\n case 42:\n _context.prev = 42;\n _context.t0 = _context[\"catch\"](32);\n // If we fail to resolve the page list or client-build manifest, we must\n // do a server-side transition:\n window.location.href = as;\n return _context.abrupt(\"return\", false);\n\n case 46:\n parsed = this._resolveHref(parsed, pages);\n\n if (parsed.pathname !== pathname) {\n pathname = parsed.pathname;\n url = (0, _utils.formatWithValidation)(parsed);\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\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) && !localeChange) {\n method = 'replaceState';\n }\n\n route = (0, _normalizeTrailingSlash.removePathTrailingSlash)(pathname); // we need to resolve the as value using rewrites for dynamic SSG\n // pages to allow building the data URL correctly\n\n resolvedAs = as;\n\n if (process.env.__NEXT_HAS_REWRITES) {\n resolvedAs = (0, _resolveRewrites[\"default\"])(addBasePath(addLocale(delBasePath((0, _parseRelativeUrl.parseRelativeUrl)(as).pathname), this.locale)), pages, rewrites, query, function (p) {\n return _this2._resolveHref({\n pathname: p\n }, pages).pathname;\n }, this.locales);\n\n if (resolvedAs !== as) {\n potentialHref = (0, _normalizeTrailingSlash.removePathTrailingSlash)(this._resolveHref(Object.assign({}, parsed, {\n pathname: (0, _normalizeLocalePath.normalizeLocalePath)(hasBasePath(resolvedAs) ? delBasePath(resolvedAs) : resolvedAs, this.locales).pathname\n }), pages, false).pathname); // if this directly matches a page we need to update the href to\n // allow the correct page chunk to be loaded\n\n if (pages.includes(potentialHref)) {\n route = potentialHref;\n pathname = potentialHref;\n parsed.pathname = pathname;\n url = (0, _utils.formatWithValidation)(parsed);\n }\n }\n }\n\n resolvedAs = delLocale(delBasePath(resolvedAs), this.locale);\n\n if (!(0, _isDynamic.isDynamicRoute)(route)) {\n _context.next = 69;\n break;\n }\n\n _parsedAs = (0, _parseRelativeUrl.parseRelativeUrl)(resolvedAs);\n asPathname = _parsedAs.pathname;\n routeRegex = (0, _routeRegex.getRouteRegex)(route);\n routeMatch = (0, _routeMatcher.getRouteMatcher)(routeRegex)(asPathname);\n shouldInterpolate = route === asPathname;\n interpolatedAs = shouldInterpolate ? interpolateAs(route, asPathname, query) : {};\n\n if (!(!routeMatch || shouldInterpolate && !interpolatedAs.result)) {\n _context.next = 68;\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 = 66;\n break;\n }\n\n if (true) {\n console.warn(\"\".concat(shouldInterpolate ? \"Interpolating href\" : \"Mismatching `as` and `href`\", \" failed to manually provide \") + \"the params: \".concat(missingParams.join(', '), \" in the `href`'s `query`\"));\n }\n\n throw new Error((shouldInterpolate ? \"The provided `href` (\".concat(url, \") value is missing query values (\").concat(missingParams.join(', '), \") to be interpolated properly. \") : \"The provided `as` value (\".concat(asPathname, \") is incompatible with the `href` value (\").concat(route, \"). \")) + \"Read more: https://err.sh/vercel/next.js/\".concat(shouldInterpolate ? 'href-interpolation-failed' : 'incompatible-href-as'));\n\n case 66:\n _context.next = 69;\n break;\n\n case 68:\n if (shouldInterpolate) {\n as = (0, _utils.formatWithValidation)(Object.assign({}, _parsedAs, {\n pathname: interpolatedAs.result,\n query: omitParmsFromQuery(query, interpolatedAs.params)\n }));\n } else {\n // Merge params into `query`, overwriting any specified in search\n Object.assign(query, routeMatch);\n }\n\n case 69:\n Router.events.emit('routeChangeStart', as, routeProps);\n _context.prev = 70;\n _context.next = 73;\n return this.getRouteInfo(route, pathname, query, as, routeProps);\n\n case 73:\n routeInfo = _context.sent;\n error = routeInfo.error, props = routeInfo.props, __N_SSG = routeInfo.__N_SSG, __N_SSP = routeInfo.__N_SSP; // handle redirect on client-transition\n\n if (!((__N_SSG || __N_SSP) && props && props.pageProps && props.pageProps.__N_REDIRECT)) {\n _context.next = 85;\n break;\n }\n\n destination = props.pageProps.__N_REDIRECT; // check if destination is internal (resolves to a page) and attempt\n // client-navigation if it is falling back to hard navigation if\n // it's not\n\n if (!destination.startsWith('/')) {\n _context.next = 83;\n break;\n }\n\n parsedHref = (0, _parseRelativeUrl.parseRelativeUrl)(destination);\n\n this._resolveHref(parsedHref, pages, false);\n\n if (!pages.includes(parsedHref.pathname)) {\n _context.next = 83;\n break;\n }\n\n _prepareUrlAs3 = prepareUrlAs(this, destination, destination), newUrl = _prepareUrlAs3.url, newAs = _prepareUrlAs3.as;\n return _context.abrupt(\"return\", this.change(method, newUrl, newAs, options));\n\n case 83:\n window.location.href = destination;\n return _context.abrupt(\"return\", new Promise(function () {}));\n\n case 85:\n Router.events.emit('beforeHistoryChange', as, routeProps);\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 = 90;\n return this.set(route, pathname, query, cleanedAs, routeInfo)[\"catch\"](function (e) {\n if (e.cancelled) error = error || e;else throw e;\n });\n\n case 90:\n if (!error) {\n _context.next = 93;\n break;\n }\n\n Router.events.emit('routeChangeError', error, cleanedAs, routeProps);\n throw error;\n\n case 93:\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 if (process.env.__NEXT_I18N_SUPPORT) {\n if (this.locale) {\n document.documentElement.lang = this.locale;\n }\n }\n\n Router.events.emit('routeChangeComplete', as, routeProps);\n return _context.abrupt(\"return\", true);\n\n case 99:\n _context.prev = 99;\n _context.t1 = _context[\"catch\"](70);\n\n if (!_context.t1.cancelled) {\n _context.next = 103;\n break;\n }\n\n return _context.abrupt(\"return\", false);\n\n case 103:\n throw _context.t1;\n\n case 104:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this, [[32, 42], [70, 99]]);\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 this._shallow = options.shallow;\n window.history[method]({\n url: url,\n as: as,\n options: options,\n __N: true\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, routeProps, loadErrorFail) {\n var Component, styleSheets, props, ssg404, mod, _yield$this$fetchComp, _yield$this$fetchComp2, 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 (!((0, _routeLoader.isAssetError)(err) || loadErrorFail)) {\n _context2.next = 6;\n break;\n }\n\n Router.events.emit('routeChangeError', err, as, routeProps); // 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 ssg404 = err.message === SSG_DATA_NOT_FOUND_ERROR;\n\n if (!ssg404) {\n _context2.next = 24;\n break;\n }\n\n _context2.prev = 9;\n _context2.next = 12;\n return this.fetchComponent('/404');\n\n case 12:\n _yield$this$fetchComp = _context2.sent;\n Component = _yield$this$fetchComp.page;\n styleSheets = _yield$this$fetchComp.styleSheets;\n mod = _yield$this$fetchComp.mod;\n\n if (!(mod && mod.__N_SSG)) {\n _context2.next = 20;\n break;\n }\n\n _context2.next = 19;\n return this._getStaticData(this.pageLoader.getDataHref('/404', '/404', true, this.locale));\n\n case 19:\n props = _context2.sent;\n\n case 20:\n _context2.next = 24;\n break;\n\n case 22:\n _context2.prev = 22;\n _context2.t0 = _context2[\"catch\"](9);\n\n case 24:\n if (!(typeof Component === 'undefined' || typeof styleSheets === 'undefined')) {\n _context2.next = 31;\n break;\n }\n\n ;\n _context2.next = 28;\n return this.fetchComponent('/_error');\n\n case 28:\n _yield$this$fetchComp2 = _context2.sent;\n Component = _yield$this$fetchComp2.page;\n styleSheets = _yield$this$fetchComp2.styleSheets;\n\n case 31:\n routeInfo = {\n props: props,\n Component: Component,\n styleSheets: styleSheets,\n err: ssg404 ? undefined : err,\n error: ssg404 ? undefined : err\n };\n\n if (routeInfo.props) {\n _context2.next = 43;\n break;\n }\n\n _context2.prev = 33;\n _context2.next = 36;\n return this.getInitialProps(Component, {\n err: err,\n pathname: pathname,\n query: query\n });\n\n case 36:\n routeInfo.props = _context2.sent;\n _context2.next = 43;\n break;\n\n case 39:\n _context2.prev = 39;\n _context2.t1 = _context2[\"catch\"](33);\n console.error('Error in error page `getInitialProps`: ', _context2.t1);\n routeInfo.props = {};\n\n case 43:\n return _context2.abrupt(\"return\", routeInfo);\n\n case 46:\n _context2.prev = 46;\n _context2.t2 = _context2[\"catch\"](6);\n return _context2.abrupt(\"return\", this.handleRouteInfoError(_context2.t2, pathname, query, as, routeProps, true));\n\n case 49:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this, [[6, 46], [9, 22], [33, 39]]);\n }));\n\n function handleRouteInfoError(_x5, _x6, _x7, _x8, _x9, _x10) {\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, routeProps) {\n var _this3 = this;\n\n var existingRouteInfo, cachedRouteInfo, routeInfo, Component, __N_SSG, __N_SSP, _require, isValidElementType, dataHref, props;\n\n return _regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n existingRouteInfo = this.components[route];\n\n if (!(routeProps.shallow && existingRouteInfo && this.route === route)) {\n _context3.next = 4;\n break;\n }\n\n return _context3.abrupt(\"return\", existingRouteInfo);\n\n case 4:\n cachedRouteInfo = existingRouteInfo && 'initial' in existingRouteInfo ? undefined : existingRouteInfo;\n\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 styleSheets: res.styleSheets,\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 }), delBasePath(as), __N_SSG, this.locale);\n }\n\n _context3.next = 21;\n return this._getData(function () {\n return __N_SSG ? _this3._getStaticData(dataHref) : __N_SSP ? _this3._getServerData(dataHref) : _this3.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\"](0);\n return _context3.abrupt(\"return\", this.handleRouteInfoError(_context3.t1, pathname, query, as, routeProps));\n\n case 30:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, this, [[0, 27]]);\n }));\n\n function getRouteInfo(_x11, _x12, _x13, _x14, _x15) {\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 key: \"_resolveHref\",\n value: function _resolveHref(parsedHref, pages) {\n var applyBasePath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n var pathname = parsedHref.pathname;\n var cleanPathname = (0, _normalizeTrailingSlash.removePathTrailingSlash)((0, _denormalizePagePath.denormalizePagePath)(applyBasePath ? delBasePath(pathname) : pathname));\n\n if (cleanPathname === '/404' || cleanPathname === '/_error') {\n return parsedHref;\n } // handle resolving href for dynamic routes\n\n\n if (!pages.includes(cleanPathname)) {\n // eslint-disable-next-line array-callback-return\n pages.some(function (page) {\n if ((0, _isDynamic.isDynamicRoute)(page) && (0, _routeRegex.getRouteRegex)(page).re.test(cleanPathname)) {\n parsedHref.pathname = applyBasePath ? addBasePath(page) : page;\n return true;\n }\n });\n }\n\n parsedHref.pathname = (0, _normalizeTrailingSlash.removePathTrailingSlash)(parsedHref.pathname);\n return parsedHref;\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 _this4 = this;\n\n var asPath,\n options,\n parsed,\n _parsed2,\n pathname,\n parsedAs,\n localePathResult,\n pages,\n route,\n _args4 = arguments;\n\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 = (0, _parseRelativeUrl.parseRelativeUrl)(url);\n _parsed2 = parsed, pathname = _parsed2.pathname;\n\n if (process.env.__NEXT_I18N_SUPPORT) {\n if (options.locale === false) {\n pathname = (0, _normalizeLocalePath.normalizeLocalePath)(pathname, this.locales).pathname;\n parsed.pathname = pathname;\n url = (0, _utils.formatWithValidation)(parsed);\n parsedAs = (0, _parseRelativeUrl.parseRelativeUrl)(asPath);\n localePathResult = (0, _normalizeLocalePath.normalizeLocalePath)(parsedAs.pathname, this.locales);\n parsedAs.pathname = localePathResult.pathname;\n options.locale = localePathResult.detectedLocale || this.defaultLocale;\n asPath = (0, _utils.formatWithValidation)(parsedAs);\n }\n }\n\n _context4.next = 7;\n return this.pageLoader.getPageList();\n\n case 7:\n pages = _context4.sent;\n parsed = this._resolveHref(parsed, pages, false);\n\n if (parsed.pathname !== pathname) {\n pathname = parsed.pathname;\n url = (0, _utils.formatWithValidation)(parsed);\n } // Prefetch is not supported in development mode because it would trigger on-demand-entries\n\n\n if (!true) {\n _context4.next = 12;\n break;\n }\n\n return _context4.abrupt(\"return\");\n\n case 12:\n route = (0, _normalizeTrailingSlash.removePathTrailingSlash)(pathname);\n _context4.next = 15;\n return Promise.all([this.pageLoader._isSsg(url).then(function (isSsg) {\n return isSsg ? _this4._getStaticData(_this4.pageLoader.getDataHref(url, asPath, true, typeof options.locale !== 'undefined' ? options.locale : _this4.locale)) : false;\n }), this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route)]);\n\n case 15:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4, this);\n }));\n\n function prefetch(_x16) {\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(_x17) {\n return _fetchComponent.apply(this, arguments);\n }\n\n return fetchComponent;\n }()\n }, {\n key: \"_getData\",\n value: function _getData(fn) {\n var _this5 = 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 === _this5.clc) {\n _this5.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 _this6 = 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 _this6.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, routeProps) {\n if (this.clc) {\n Router.events.emit('routeChangeError', buildCancellationError(), as, routeProps);\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\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","prefix","path","locale","addPathPrefix","url","locationOrigin","resolved","hasBasePath","interpolatedRoute","dynamicRegex","dynamicGroups","dynamicMatches","asPathname","params","param","value","replaced","repeat","Array","optional","escapePathDelimiters","result","filteredQuery","key","query","base","urlAsString","isLocalURL","resolveAs","finalUrl","interpolatedAs","interpolateAs","pathname","hash","omitParmsFromQuery","resolvedHref","addBasePath","resolveHref","router","as","manualScrollRestoration","window","SSG_DATA_NOT_FOUND_ERROR","credentials","res","attempts","fetchRetry","isServerRender","err","Router","route","asPath","components","sdc","sub","clc","pageLoader","_bps","events","_wrapApp","isSsr","isFallback","_inFlightRoute","_shallow","locales","defaultLocale","constructor","Component","initial","props","__N_SSG","initialProps","__N_SSP","styleSheets","__NEXT_DATA__","debouncedScrollSave","clearTimeout","scrollDebounceTimeout","setTimeout","history","_N_X","_N_Y","e","state","shallow","options","reload","prepareUrlAs","localeChange","parsedAs","delBasePath","localePathResult","addLocale","ST","performance","routeProps","cleanedAs","delLocale","parsed","pages","__rewrites","method","resolvedAs","p","potentialHref","routeRegex","routeMatch","shouldInterpolate","missingParams","console","routeInfo","destination","parsedHref","appComp","error","document","__N","buildCancellationError","ssg404","page","mod","existingRouteInfo","cachedRouteInfo","require","isValidElementType","dataHref","onlyAHashChange","newHash","oldUrlNoHash","oldHash","scrollToHash","idEl","nameEl","urlIsNew","_resolveHref","applyBasePath","cleanPathname","Promise","isSsg","cancel","componentResult","fn","data","_getStaticData","href","fetchNextData","_getServerData","getInitialProps","AppTree","ctx","abortComponentLoad","notify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAA,uBAAA,GAAA,OAAA,CAAA,0CAAA,CAAA;;AAKA,IAAA,YAAA,GAAA,OAAA,CAAA,8BAAA,CAAA;;AAKA,IAAA,oBAAA,GAAA,OAAA,CAAA,oCAAA,CAAA;;AACA,IAAA,oBAAA,GAAA,OAAA,CAAA,+BAAA,CAAA;;AACA,IAAA,KAAA,GAAA,sBAAA,CAAA,OAAA,CAAA,SAAA,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z/B8C;;;;;;;AAA7BtG,M,CA2BZS,MA3BYT,GA2BU,CAAA,GAAA,KAAA,WAAA,GA3BVA","sourcesContent":["/* global __NEXT_DATA__ */\n// tslint:disable:no-console\nimport { ParsedUrlQuery } from 'querystring'\nimport { ComponentType } from 'react'\nimport { UrlObject } from 'url'\nimport {\n normalizePathTrailingSlash,\n removePathTrailingSlash,\n} from '../../../client/normalize-trailing-slash'\nimport { GoodPageCache, StyleSheetTuple } from '../../../client/page-loader'\nimport {\n getClientBuildManifest,\n isAssetError,\n markAssetError,\n} from '../../../client/route-loader'\nimport { denormalizePagePath } from '../../server/denormalize-page-path'\nimport { normalizeLocalePath } from '../i18n/normalize-locale-path'\nimport mitt, { MittEmitter } from '../mitt'\nimport {\n AppContextType,\n formatWithValidation,\n getLocationOrigin,\n getURL,\n loadGetInitialProps,\n NextPageContext,\n ST,\n} from '../utils'\nimport escapePathDelimiters from './utils/escape-path-delimiters'\nimport { isDynamicRoute } from './utils/is-dynamic'\nimport { parseRelativeUrl } from './utils/parse-relative-url'\nimport { searchParamsToUrlQuery } from './utils/querystring'\nimport resolveRewrites from './utils/resolve-rewrites'\nimport { getRouteMatcher } from './utils/route-matcher'\nimport { getRouteRegex } from './utils/route-regex'\n\ninterface RouteProperties {\n shallow: boolean\n}\n\ninterface TransitionOptions {\n shallow?: boolean\n locale?: string | false\n}\n\ninterface NextHistoryState {\n url: string\n as: string\n options: TransitionOptions\n}\n\ntype HistoryState = null | { __N: false } | ({ __N: true } & NextHistoryState)\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\nfunction addPathPrefix(path: string, prefix?: string) {\n return prefix && path.startsWith('/')\n ? path === '/'\n ? normalizePathTrailingSlash(prefix)\n : `${prefix}${path}`\n : path\n}\n\nexport function addLocale(\n path: string,\n locale?: string | false,\n defaultLocale?: string\n) {\n if (process.env.__NEXT_I18N_SUPPORT) {\n return locale &&\n locale !== defaultLocale &&\n !path.startsWith('/' + locale + '/') &&\n path !== '/' + locale\n ? addPathPrefix(path, '/' + locale)\n : path\n }\n return path\n}\n\nexport function delLocale(path: string, locale?: string) {\n if (process.env.__NEXT_I18N_SUPPORT) {\n return locale &&\n (path.startsWith('/' + locale + '/') || path === '/' + locale)\n ? path.substr(locale.length + 1) || '/'\n : path\n }\n return path\n}\n\nexport function hasBasePath(path: string): boolean {\n return path === basePath || path.startsWith(basePath + '/')\n}\n\nexport function addBasePath(path: string): string {\n // we only add the basepath on relative urls\n return addPathPrefix(path, basePath)\n}\n\nexport function delBasePath(path: string): string {\n return path.slice(basePath.length) || '/'\n}\n\n/**\n * Detects whether a given url is routable by the Next.js router (browser only).\n */\nexport function isLocalURL(url: string): boolean {\n if (url.startsWith('/')) return true\n try {\n // absolute urls can be local if they are on the same origin\n const locationOrigin = getLocationOrigin()\n const resolved = new URL(url, locationOrigin)\n return resolved.origin === locationOrigin && hasBasePath(resolved.pathname)\n } catch (_) {\n return false\n }\n}\n\ntype Url = UrlObject | string\n\nexport function interpolateAs(\n route: string,\n asPathname: string,\n query: ParsedUrlQuery\n) {\n let interpolatedRoute = ''\n\n const dynamicRegex = getRouteRegex(route)\n const dynamicGroups = dynamicRegex.groups\n const dynamicMatches =\n // Try to match the dynamic route against the asPath\n (asPathname !== route ? getRouteMatcher(dynamicRegex)(asPathname) : '') ||\n // Fall back to reading the values from the href\n // TODO: should this take priority; also need to change in the router.\n query\n\n interpolatedRoute = route\n const params = Object.keys(dynamicGroups)\n\n if (\n !params.every((param) => {\n let value = dynamicMatches[param] || ''\n const { repeat, optional } = dynamicGroups[param]\n\n // support single-level catch-all\n // TODO: more robust handling for user-error (passing `/`)\n let replaced = `[${repeat ? '...' : ''}${param}]`\n if (optional) {\n replaced = `${!value ? '/' : ''}[${replaced}]`\n }\n if (repeat && !Array.isArray(value)) value = [value]\n\n return (\n (optional || param in dynamicMatches) &&\n // Interpolate group into data URL if present\n (interpolatedRoute =\n interpolatedRoute!.replace(\n replaced,\n repeat\n ? (value as string[]).map(escapePathDelimiters).join('/')\n : escapePathDelimiters(value as string)\n ) || '/')\n )\n })\n ) {\n interpolatedRoute = '' // did not satisfy all requirements\n\n // n.b. We ignore this error because we handle warning for this case in\n // development in the `<Link>` component directly.\n }\n return {\n params,\n result: interpolatedRoute,\n }\n}\n\nfunction omitParmsFromQuery(query: ParsedUrlQuery, params: string[]) {\n const filteredQuery: ParsedUrlQuery = {}\n\n Object.keys(query).forEach((key) => {\n if (!params.includes(key)) {\n filteredQuery[key] = query[key]\n }\n })\n return filteredQuery\n}\n\n/**\n * Resolves a given hyperlink with a certain router state (basePath not included).\n * Preserves absolute urls.\n */\nexport function resolveHref(\n currentPath: string,\n href: Url,\n resolveAs?: boolean\n): 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 // Return because it cannot be routed by the Next.js router\n if (!isLocalURL(urlAsString)) {\n return (resolveAs ? [urlAsString] : urlAsString) as string\n }\n try {\n const finalUrl = new URL(urlAsString, base)\n finalUrl.pathname = normalizePathTrailingSlash(finalUrl.pathname)\n let interpolatedAs = ''\n\n if (\n isDynamicRoute(finalUrl.pathname) &&\n finalUrl.searchParams &&\n resolveAs\n ) {\n const query = searchParamsToUrlQuery(finalUrl.searchParams)\n\n const { result, params } = interpolateAs(\n finalUrl.pathname,\n finalUrl.pathname,\n query\n )\n\n if (result) {\n interpolatedAs = formatWithValidation({\n pathname: result,\n hash: finalUrl.hash,\n query: omitParmsFromQuery(query, params),\n })\n }\n }\n\n // if the origin didn't change, it means we received a relative href\n const resolvedHref =\n finalUrl.origin === base.origin\n ? finalUrl.href.slice(finalUrl.origin.length)\n : finalUrl.href\n\n return (resolveAs\n ? [resolvedHref, interpolatedAs || resolvedHref]\n : resolvedHref) as string\n } catch (_) {\n return (resolveAs ? [urlAsString] : urlAsString) as string\n }\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\nexport type BaseRouter = {\n route: string\n pathname: string\n query: ParsedUrlQuery\n asPath: string\n basePath: string\n locale?: string\n locales?: string[]\n defaultLocale?: 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 locale?: string | false\n}\n\nexport type PrivateRouteInfo =\n | (Omit<CompletePrivateRouteInfo, 'styleSheets'> & { initial: true })\n | CompletePrivateRouteInfo\n\nexport type CompletePrivateRouteInfo = {\n Component: ComponentType\n styleSheets: StyleSheetTuple[]\n __N_SSG?: boolean\n __N_SSP?: boolean\n props?: Record<string, any>\n err?: Error\n error?: any\n}\n\nexport type AppProps = Pick<CompletePrivateRouteInfo, 'Component' | 'err'> & {\n router: Router\n} & Record<string, any>\nexport type AppComponent = ComponentType<AppProps>\n\ntype Subscription = (data: PrivateRouteInfo, App: AppComponent) => Promise<void>\n\ntype BeforePopStateCallback = (state: NextHistoryState) => 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\nconst SSG_DATA_NOT_FOUND_ERROR = 'SSG Data NOT_FOUND'\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 if (res.status === 404) {\n // TODO: handle reloading in development from fallback returning 200\n // to on-demand-entry-handler causing it to reload periodically\n throw new Error(SSG_DATA_NOT_FOUND_ERROR)\n }\n throw new Error(`Failed to load static props`)\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\n if (!isServerRender) {\n markAssetError(err)\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]: PrivateRouteInfo }\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: AppComponent) => any\n isSsr: boolean\n isFallback: boolean\n _inFlightRoute?: string\n _shallow?: boolean\n locale?: string\n locales?: string[]\n defaultLocale?: 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 locale,\n locales,\n defaultLocale,\n }: {\n subscription: Subscription\n initialProps: any\n pageLoader: any\n Component: ComponentType\n App: AppComponent\n wrapApp: (App: AppComponent) => any\n err?: Error\n isFallback: boolean\n locale?: string\n locales?: string[]\n defaultLocale?: string\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 initial: true,\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'] = {\n Component: App as ComponentType,\n styleSheets: [\n /* /_app does not need its stylesheets managed */\n ],\n }\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 (process.env.__NEXT_I18N_SUPPORT) {\n this.locale = locale\n this.locales = locales\n this.defaultLocale = defaultLocale\n }\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 this.changeState(\n 'replaceState',\n formatWithValidation({ pathname: addBasePath(pathname), query }),\n getURL(),\n { locale }\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 onPopState = (e: PopStateEvent): void => {\n const state = e.state as HistoryState\n\n if (!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 if (!state.__N) {\n return\n }\n\n const { url, as, options } = state\n\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(state)) {\n return\n }\n\n this.change(\n 'replaceState',\n url,\n as,\n Object.assign({}, options, {\n shallow: options.shallow && this._shallow,\n locale: options.locale || this.defaultLocale,\n })\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: TransitionOptions = {}) {\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: TransitionOptions = {}) {\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: TransitionOptions\n ): Promise<boolean> {\n if (!isLocalURL(url)) {\n window.location.href = url\n return false\n }\n let localeChange = options.locale !== this.locale\n\n if (process.env.__NEXT_I18N_SUPPORT) {\n this.locale =\n options.locale === false\n ? this.defaultLocale\n : options.locale || this.locale\n\n if (typeof options.locale === 'undefined') {\n options.locale = this.locale\n }\n\n const parsedAs = parseRelativeUrl(hasBasePath(as) ? delBasePath(as) : as)\n const localePathResult = normalizeLocalePath(\n parsedAs.pathname,\n this.locales\n )\n if (localePathResult.detectedLocale) {\n this.locale = localePathResult.detectedLocale\n url = addBasePath(localePathResult.pathname)\n }\n\n // if the locale isn't configured hard navigate to show 404 page\n if (!this.locales?.includes(this.locale!)) {\n parsedAs.pathname = addLocale(parsedAs.pathname, this.locale)\n window.location.href = formatWithValidation(parsedAs)\n return new Promise(() => {})\n }\n }\n\n if (!(options as any)._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 const { shallow = false } = options\n const routeProps = { shallow }\n\n if (this._inFlightRoute) {\n this.abortComponentLoad(this._inFlightRoute, routeProps)\n }\n\n as = addBasePath(\n addLocale(\n hasBasePath(as) ? delBasePath(as) : as,\n options.locale,\n this.defaultLocale\n )\n )\n const cleanedAs = delLocale(\n hasBasePath(as) ? delBasePath(as) : as,\n this.locale\n )\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 as any)._h && this.onlyAHashChange(cleanedAs)) {\n this.asPath = cleanedAs\n Router.events.emit('hashChangeStart', as, routeProps)\n // TODO: do we need the resolved href when only a hash change?\n this.changeState(method, url, as, options)\n this.scrollToHash(cleanedAs)\n this.notify(this.components[this.route])\n Router.events.emit('hashChangeComplete', as, routeProps)\n return true\n }\n\n let parsed = parseRelativeUrl(url)\n let { pathname, query } = parsed\n\n // The build manifest needs to be loaded before auto-static dynamic pages\n // get their query parameters to allow ensuring they can be parsed properly\n // when rewritten to\n let pages: any, rewrites: any\n try {\n pages = await this.pageLoader.getPageList()\n ;({ __rewrites: rewrites } = await getClientBuildManifest())\n } catch (err) {\n // If we fail to resolve the page list or client-build manifest, we must\n // do a server-side transition:\n window.location.href = as\n return false\n }\n\n parsed = this._resolveHref(parsed, pages) as typeof parsed\n\n if (parsed.pathname !== pathname) {\n pathname = parsed.pathname\n url = formatWithValidation(parsed)\n }\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) && !localeChange) {\n method = 'replaceState'\n }\n\n let route = removePathTrailingSlash(pathname)\n\n // we need to resolve the as value using rewrites for dynamic SSG\n // pages to allow building the data URL correctly\n let resolvedAs = as\n\n if (process.env.__NEXT_HAS_REWRITES) {\n resolvedAs = resolveRewrites(\n addBasePath(\n addLocale(delBasePath(parseRelativeUrl(as).pathname), this.locale)\n ),\n pages,\n rewrites,\n query,\n (p: string) => this._resolveHref({ pathname: p }, pages).pathname!,\n this.locales\n )\n\n if (resolvedAs !== as) {\n const potentialHref = removePathTrailingSlash(\n this._resolveHref(\n Object.assign({}, parsed, {\n pathname: normalizeLocalePath(\n hasBasePath(resolvedAs) ? delBasePath(resolvedAs) : resolvedAs,\n this.locales\n ).pathname,\n }),\n pages,\n false\n ).pathname!\n )\n\n // if this directly matches a page we need to update the href to\n // allow the correct page chunk to be loaded\n if (pages.includes(potentialHref)) {\n route = potentialHref\n pathname = potentialHref\n parsed.pathname = pathname\n url = formatWithValidation(parsed)\n }\n }\n }\n resolvedAs = delLocale(delBasePath(resolvedAs), this.locale)\n\n if (isDynamicRoute(route)) {\n const parsedAs = parseRelativeUrl(resolvedAs)\n const asPathname = parsedAs.pathname\n\n const routeRegex = getRouteRegex(route)\n const routeMatch = getRouteMatcher(routeRegex)(asPathname)\n const shouldInterpolate = route === asPathname\n const interpolatedAs = shouldInterpolate\n ? interpolateAs(route, asPathname, query)\n : ({} as { result: undefined; params: undefined })\n\n if (!routeMatch || (shouldInterpolate && !interpolatedAs.result)) {\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 `${\n shouldInterpolate\n ? `Interpolating href`\n : `Mismatching \\`as\\` and \\`href\\``\n } failed to manually provide ` +\n `the params: ${missingParams.join(\n ', '\n )} in the \\`href\\`'s \\`query\\``\n )\n }\n\n throw new Error(\n (shouldInterpolate\n ? `The provided \\`href\\` (${url}) value is missing query values (${missingParams.join(\n ', '\n )}) to be interpolated properly. `\n : `The provided \\`as\\` value (${asPathname}) is incompatible with the \\`href\\` value (${route}). `) +\n `Read more: https://err.sh/vercel/next.js/${\n shouldInterpolate\n ? 'href-interpolation-failed'\n : 'incompatible-href-as'\n }`\n )\n }\n } else if (shouldInterpolate) {\n as = formatWithValidation(\n Object.assign({}, parsedAs, {\n pathname: interpolatedAs.result,\n query: omitParmsFromQuery(query, interpolatedAs.params!),\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, routeProps)\n\n try {\n const routeInfo = await this.getRouteInfo(\n route,\n pathname,\n query,\n as,\n routeProps\n )\n let { error, props, __N_SSG, __N_SSP } = routeInfo\n\n // handle redirect on client-transition\n if (\n (__N_SSG || __N_SSP) &&\n props &&\n (props as any).pageProps &&\n (props as any).pageProps.__N_REDIRECT\n ) {\n const destination = (props as any).pageProps.__N_REDIRECT\n\n // check if destination is internal (resolves to a page) and attempt\n // client-navigation if it is falling back to hard navigation if\n // it's not\n if (destination.startsWith('/')) {\n const parsedHref = parseRelativeUrl(destination)\n this._resolveHref(parsedHref, pages, false)\n\n if (pages.includes(parsedHref.pathname)) {\n const { url: newUrl, as: newAs } = prepareUrlAs(\n this,\n destination,\n destination\n )\n return this.change(method, newUrl, newAs, options)\n }\n }\n\n window.location.href = destination\n return new Promise(() => {})\n }\n\n Router.events.emit('beforeHistoryChange', as, routeProps)\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).catch(\n (e) => {\n if (e.cancelled) error = error || e\n else throw e\n }\n )\n\n if (error) {\n Router.events.emit('routeChangeError', error, cleanedAs, routeProps)\n throw error\n }\n\n if (process.env.__NEXT_SCROLL_RESTORATION) {\n if (manualScrollRestoration && '_N_X' in options) {\n window.scrollTo((options as any)._N_X, (options as any)._N_Y)\n }\n }\n\n if (process.env.__NEXT_I18N_SUPPORT) {\n if (this.locale) {\n document.documentElement.lang = this.locale\n }\n }\n Router.events.emit('routeChangeComplete', as, routeProps)\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: TransitionOptions = {}\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 this._shallow = options.shallow\n window.history[method](\n {\n url,\n as,\n options,\n __N: true,\n } as HistoryState,\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: ParsedUrlQuery,\n as: string,\n routeProps: RouteProperties,\n loadErrorFail?: boolean\n ): Promise<CompletePrivateRouteInfo> {\n if (err.cancelled) {\n // bubble up cancellation errors\n throw err\n }\n\n if (isAssetError(err) || loadErrorFail) {\n Router.events.emit('routeChangeError', err, as, routeProps)\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 let Component: ComponentType\n let styleSheets: StyleSheetTuple[]\n let props: Record<string, any> | undefined\n const ssg404 = err.message === SSG_DATA_NOT_FOUND_ERROR\n\n if (ssg404) {\n try {\n let mod: any\n ;({ page: Component, styleSheets, mod } = await this.fetchComponent(\n '/404'\n ))\n\n // TODO: should we tolerate these props missing and still render the\n // page instead of falling back to _error?\n if (mod && mod.__N_SSG) {\n props = await this._getStaticData(\n this.pageLoader.getDataHref('/404', '/404', true, this.locale)\n )\n }\n } catch (_err) {\n // non-fatal fallback to _error\n }\n }\n\n if (\n typeof Component! === 'undefined' ||\n typeof styleSheets! === 'undefined'\n ) {\n ;({ page: Component, styleSheets } = await this.fetchComponent(\n '/_error'\n ))\n }\n\n const routeInfo: CompletePrivateRouteInfo = {\n props,\n Component,\n styleSheets,\n err: ssg404 ? undefined : err,\n error: ssg404 ? undefined : err,\n }\n\n if (!routeInfo.props) {\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\n return routeInfo\n } catch (routeInfoErr) {\n return this.handleRouteInfoError(\n routeInfoErr,\n pathname,\n query,\n as,\n routeProps,\n true\n )\n }\n }\n\n async getRouteInfo(\n route: string,\n pathname: string,\n query: any,\n as: string,\n routeProps: RouteProperties\n ): Promise<PrivateRouteInfo> {\n try {\n const existingRouteInfo: PrivateRouteInfo | undefined = this.components[\n route\n ]\n if (routeProps.shallow && existingRouteInfo && this.route === route) {\n return existingRouteInfo\n }\n\n const cachedRouteInfo: CompletePrivateRouteInfo | undefined =\n existingRouteInfo && 'initial' in existingRouteInfo\n ? undefined\n : existingRouteInfo\n const routeInfo: CompletePrivateRouteInfo = cachedRouteInfo\n ? cachedRouteInfo\n : await this.fetchComponent(route).then((res) => ({\n Component: res.page,\n styleSheets: res.styleSheets,\n __N_SSG: res.mod.__N_SSG,\n __N_SSP: res.mod.__N_SSP,\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 delBasePath(as),\n __N_SSG,\n this.locale\n )\n }\n\n const props = await this._getData<CompletePrivateRouteInfo>(() =>\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\n routeInfo.props = props\n this.components[route] = routeInfo\n return routeInfo\n } catch (err) {\n return this.handleRouteInfoError(err, pathname, query, as, routeProps)\n }\n }\n\n set(\n route: string,\n pathname: string,\n query: ParsedUrlQuery,\n as: string,\n data: PrivateRouteInfo\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 _resolveHref(parsedHref: UrlObject, pages: string[], applyBasePath = true) {\n const { pathname } = parsedHref\n const cleanPathname = removePathTrailingSlash(\n denormalizePagePath(applyBasePath ? delBasePath(pathname!) : pathname!)\n )\n\n if (cleanPathname === '/404' || cleanPathname === '/_error') {\n return parsedHref\n }\n\n // handle resolving href for dynamic routes\n if (!pages.includes(cleanPathname!)) {\n // eslint-disable-next-line array-callback-return\n pages.some((page) => {\n if (\n isDynamicRoute(page) &&\n getRouteRegex(page).re.test(cleanPathname!)\n ) {\n parsedHref.pathname = applyBasePath ? addBasePath(page) : page\n return true\n }\n })\n }\n parsedHref.pathname = removePathTrailingSlash(parsedHref.pathname!)\n return parsedHref\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 let parsed = parseRelativeUrl(url)\n\n let { pathname } = parsed\n\n if (process.env.__NEXT_I18N_SUPPORT) {\n if (options.locale === false) {\n pathname = normalizeLocalePath!(pathname, this.locales).pathname\n parsed.pathname = pathname\n url = formatWithValidation(parsed)\n\n let parsedAs = parseRelativeUrl(asPath)\n const localePathResult = normalizeLocalePath!(\n parsedAs.pathname,\n this.locales\n )\n parsedAs.pathname = localePathResult.pathname\n options.locale = localePathResult.detectedLocale || this.defaultLocale\n asPath = formatWithValidation(parsedAs)\n }\n }\n\n const pages = await this.pageLoader.getPageList()\n\n parsed = this._resolveHref(parsed, pages, false) as typeof parsed\n\n if (parsed.pathname !== pathname) {\n pathname = parsed.pathname\n url = formatWithValidation(parsed)\n }\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._isSsg(url).then((isSsg: boolean) => {\n return isSsg\n ? this._getStaticData(\n this.pageLoader.getDataHref(\n url,\n asPath,\n true,\n typeof options.locale !== 'undefined'\n ? options.locale\n : this.locale\n )\n )\n : false\n }),\n this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route),\n ])\n }\n\n async fetchComponent(route: string): Promise<GoodPageCache> {\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 as AppComponent)\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, routeProps: RouteProperties): void {\n if (this.clc) {\n Router.events.emit(\n 'routeChangeError',\n buildCancellationError(),\n as,\n routeProps\n )\n this.clc()\n this.clc = null\n }\n }\n\n notify(data: PrivateRouteInfo): Promise<void> {\n return this.sub(data, this.components['/_app'].Component as AppComponent)\n }\n}\n"]},"metadata":{},"sourceType":"script"}