79165.js 118 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944
  1. exports.id = 79165;
  2. exports.ids = [79165];
  3. exports.modules = {
  4. /***/ 96001:
  5. /***/ ((__unused_webpack_module, exports) => {
  6. "use strict";
  7. var __webpack_unused_export__;
  8. __webpack_unused_export__ = ({
  9. value: true
  10. });
  11. exports.Z = _asyncToGenerator;
  12. function _asyncToGenerator(fn) {
  13. return function() {
  14. var self = this, args = arguments;
  15. return new Promise(function(resolve, reject) {
  16. var gen = fn.apply(self, args);
  17. function _next(value) {
  18. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  19. }
  20. function _throw(err) {
  21. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  22. }
  23. _next(undefined);
  24. });
  25. };
  26. }
  27. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  28. try {
  29. var info = gen[key](arg);
  30. var value = info.value;
  31. } catch (error) {
  32. reject(error);
  33. return;
  34. }
  35. if (info.done) {
  36. resolve(value);
  37. } else {
  38. Promise.resolve(value).then(_next, _throw);
  39. }
  40. }
  41. /***/ }),
  42. /***/ 25550:
  43. /***/ ((__unused_webpack_module, exports) => {
  44. "use strict";
  45. var __webpack_unused_export__;
  46. __webpack_unused_export__ = ({
  47. value: true
  48. });
  49. exports.Z = _extends;
  50. function _extends() {
  51. return extends_.apply(this, arguments);
  52. }
  53. function extends_() {
  54. extends_ = Object.assign || function(target) {
  55. for(var i = 1; i < arguments.length; i++){
  56. var source = arguments[i];
  57. for(var key in source){
  58. if (Object.prototype.hasOwnProperty.call(source, key)) {
  59. target[key] = source[key];
  60. }
  61. }
  62. }
  63. return target;
  64. };
  65. return extends_.apply(this, arguments);
  66. }
  67. /***/ }),
  68. /***/ 40213:
  69. /***/ ((__unused_webpack_module, exports) => {
  70. "use strict";
  71. var __webpack_unused_export__;
  72. __webpack_unused_export__ = ({
  73. value: true
  74. });
  75. exports.Z = _interopRequireDefault;
  76. function _interopRequireDefault(obj) {
  77. return obj && obj.__esModule ? obj : {
  78. default: obj
  79. };
  80. }
  81. /***/ }),
  82. /***/ 95928:
  83. /***/ ((__unused_webpack_module, exports) => {
  84. "use strict";
  85. var __webpack_unused_export__;
  86. __webpack_unused_export__ = ({
  87. value: true
  88. });
  89. exports.Z = _interopRequireWildcard;
  90. function _interopRequireWildcard(obj, nodeInterop) {
  91. if (!nodeInterop && obj && obj.__esModule) {
  92. return obj;
  93. }
  94. if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
  95. return {
  96. default: obj
  97. };
  98. }
  99. var cache = _getRequireWildcardCache(nodeInterop);
  100. if (cache && cache.has(obj)) {
  101. return cache.get(obj);
  102. }
  103. var newObj = {};
  104. var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
  105. for(var key in obj){
  106. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  107. var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
  108. if (desc && (desc.get || desc.set)) {
  109. Object.defineProperty(newObj, key, desc);
  110. } else {
  111. newObj[key] = obj[key];
  112. }
  113. }
  114. }
  115. newObj.default = obj;
  116. if (cache) {
  117. cache.set(obj, newObj);
  118. }
  119. return newObj;
  120. }
  121. function _getRequireWildcardCache(nodeInterop1) {
  122. if (typeof WeakMap !== "function") return null;
  123. var cacheBabelInterop = new WeakMap();
  124. var cacheNodeInterop = new WeakMap();
  125. return (_getRequireWildcardCache = function(nodeInterop) {
  126. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  127. })(nodeInterop1);
  128. }
  129. /***/ }),
  130. /***/ 36969:
  131. /***/ ((__unused_webpack_module, exports) => {
  132. "use strict";
  133. var __webpack_unused_export__;
  134. __webpack_unused_export__ = ({
  135. value: true
  136. });
  137. exports.Z = _objectWithoutPropertiesLoose;
  138. function _objectWithoutPropertiesLoose(source, excluded) {
  139. if (source == null) return {};
  140. var target = {};
  141. var sourceKeys = Object.keys(source);
  142. var key, i;
  143. for(i = 0; i < sourceKeys.length; i++){
  144. key = sourceKeys[i];
  145. if (excluded.indexOf(key) >= 0) continue;
  146. target[key] = source[key];
  147. }
  148. return target;
  149. }
  150. /***/ }),
  151. /***/ 79165:
  152. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  153. module.exports = __webpack_require__(53892)
  154. /***/ }),
  155. /***/ 93378:
  156. /***/ ((module, exports, __webpack_require__) => {
  157. "use strict";
  158. Object.defineProperty(exports, "__esModule", ({
  159. value: true
  160. }));
  161. exports.addBasePath = addBasePath;
  162. var _addPathPrefix = __webpack_require__(11751);
  163. var _normalizeTrailingSlash = __webpack_require__(68641);
  164. const basePath = false || "";
  165. function addBasePath(path, required) {
  166. if (false) {}
  167. return (0, _normalizeTrailingSlash).normalizePathTrailingSlash((0, _addPathPrefix).addPathPrefix(path, basePath));
  168. }
  169. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  170. Object.defineProperty(exports.default, "__esModule", {
  171. value: true
  172. });
  173. Object.assign(exports.default, exports);
  174. module.exports = exports.default;
  175. } //# sourceMappingURL=add-base-path.js.map
  176. /***/ }),
  177. /***/ 32487:
  178. /***/ ((module, exports, __webpack_require__) => {
  179. "use strict";
  180. Object.defineProperty(exports, "__esModule", ({
  181. value: true
  182. }));
  183. exports.addLocale = void 0;
  184. var _normalizeTrailingSlash = __webpack_require__(68641);
  185. const addLocale = (path, ...args)=>{
  186. if (true) {
  187. return (0, _normalizeTrailingSlash).normalizePathTrailingSlash((__webpack_require__(93431).addLocale)(path, ...args));
  188. }
  189. return path;
  190. };
  191. exports.addLocale = addLocale;
  192. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  193. Object.defineProperty(exports.default, "__esModule", {
  194. value: true
  195. });
  196. Object.assign(exports.default, exports);
  197. module.exports = exports.default;
  198. } //# sourceMappingURL=add-locale.js.map
  199. /***/ }),
  200. /***/ 17747:
  201. /***/ ((module, exports, __webpack_require__) => {
  202. "use strict";
  203. Object.defineProperty(exports, "__esModule", ({
  204. value: true
  205. }));
  206. exports.detectDomainLocale = void 0;
  207. const detectDomainLocale = (...args)=>{
  208. if (true) {
  209. return (__webpack_require__(3539).detectDomainLocale)(...args);
  210. }
  211. };
  212. exports.detectDomainLocale = detectDomainLocale;
  213. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  214. Object.defineProperty(exports.default, "__esModule", {
  215. value: true
  216. });
  217. Object.assign(exports.default, exports);
  218. module.exports = exports.default;
  219. } //# sourceMappingURL=detect-domain-locale.js.map
  220. /***/ }),
  221. /***/ 51919:
  222. /***/ ((module, exports, __webpack_require__) => {
  223. "use strict";
  224. Object.defineProperty(exports, "__esModule", ({
  225. value: true
  226. }));
  227. exports.getDomainLocale = getDomainLocale;
  228. const basePath = false || "";
  229. function getDomainLocale(path, locale, locales, domainLocales) {
  230. if (true) {
  231. const normalizeLocalePath = (__webpack_require__(76099).normalizeLocalePath);
  232. const detectDomainLocale = (__webpack_require__(17747).detectDomainLocale);
  233. const target = locale || normalizeLocalePath(path, locales).detectedLocale;
  234. const domain = detectDomainLocale(domainLocales, undefined, target);
  235. if (domain) {
  236. const proto = `http${domain.http ? "" : "s"}://`;
  237. const finalLocale = target === domain.defaultLocale ? "" : `/${target}`;
  238. return `${proto}${domain.domain}${basePath}${finalLocale}${path}`;
  239. }
  240. return false;
  241. } else {}
  242. }
  243. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  244. Object.defineProperty(exports.default, "__esModule", {
  245. value: true
  246. });
  247. Object.assign(exports.default, exports);
  248. module.exports = exports.default;
  249. } //# sourceMappingURL=get-domain-locale.js.map
  250. /***/ }),
  251. /***/ 22992:
  252. /***/ ((module, exports, __webpack_require__) => {
  253. "use strict";
  254. Object.defineProperty(exports, "__esModule", ({
  255. value: true
  256. }));
  257. exports.hasBasePath = hasBasePath;
  258. var _pathHasPrefix = __webpack_require__(34567);
  259. const basePath = false || "";
  260. function hasBasePath(path) {
  261. return (0, _pathHasPrefix).pathHasPrefix(path, basePath);
  262. }
  263. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  264. Object.defineProperty(exports.default, "__esModule", {
  265. value: true
  266. });
  267. Object.assign(exports.default, exports);
  268. module.exports = exports.default;
  269. } //# sourceMappingURL=has-base-path.js.map
  270. /***/ }),
  271. /***/ 58696:
  272. /***/ ((module, exports) => {
  273. "use strict";
  274. Object.defineProperty(exports, "__esModule", ({
  275. value: true
  276. }));
  277. exports["default"] = initHeadManager;
  278. exports.isEqualNode = isEqualNode;
  279. exports.DOMAttributeNames = void 0;
  280. function initHeadManager() {
  281. return {
  282. mountedInstances: new Set(),
  283. updateHead: (head)=>{
  284. const tags = {};
  285. head.forEach((h)=>{
  286. if (// it won't be inlined. In this case revert to the original behavior
  287. h.type === "link" && h.props["data-optimized-fonts"]) {
  288. if (document.querySelector(`style[data-href="${h.props["data-href"]}"]`)) {
  289. return;
  290. } else {
  291. h.props.href = h.props["data-href"];
  292. h.props["data-href"] = undefined;
  293. }
  294. }
  295. const components = tags[h.type] || [];
  296. components.push(h);
  297. tags[h.type] = components;
  298. });
  299. const titleComponent = tags.title ? tags.title[0] : null;
  300. let title = "";
  301. if (titleComponent) {
  302. const { children } = titleComponent.props;
  303. title = typeof children === "string" ? children : Array.isArray(children) ? children.join("") : "";
  304. }
  305. if (title !== document.title) document.title = title;
  306. [
  307. "meta",
  308. "base",
  309. "link",
  310. "style",
  311. "script"
  312. ].forEach((type)=>{
  313. updateElements(type, tags[type] || []);
  314. });
  315. }
  316. };
  317. }
  318. const DOMAttributeNames = {
  319. acceptCharset: "accept-charset",
  320. className: "class",
  321. htmlFor: "for",
  322. httpEquiv: "http-equiv",
  323. noModule: "noModule"
  324. };
  325. exports.DOMAttributeNames = DOMAttributeNames;
  326. function reactElementToDOM({ type , props }) {
  327. const el = document.createElement(type);
  328. for(const p in props){
  329. if (!props.hasOwnProperty(p)) continue;
  330. if (p === "children" || p === "dangerouslySetInnerHTML") continue;
  331. // we don't render undefined props to the DOM
  332. if (props[p] === undefined) continue;
  333. const attr = DOMAttributeNames[p] || p.toLowerCase();
  334. if (type === "script" && (attr === "async" || attr === "defer" || attr === "noModule")) {
  335. el[attr] = !!props[p];
  336. } else {
  337. el.setAttribute(attr, props[p]);
  338. }
  339. }
  340. const { children , dangerouslySetInnerHTML } = props;
  341. if (dangerouslySetInnerHTML) {
  342. el.innerHTML = dangerouslySetInnerHTML.__html || "";
  343. } else if (children) {
  344. el.textContent = typeof children === "string" ? children : Array.isArray(children) ? children.join("") : "";
  345. }
  346. return el;
  347. }
  348. function isEqualNode(oldTag, newTag) {
  349. if (oldTag instanceof HTMLElement && newTag instanceof HTMLElement) {
  350. const nonce = newTag.getAttribute("nonce");
  351. // Only strip the nonce if `oldTag` has had it stripped. An element's nonce attribute will not
  352. // be stripped if there is no content security policy response header that includes a nonce.
  353. if (nonce && !oldTag.getAttribute("nonce")) {
  354. const cloneTag = newTag.cloneNode(true);
  355. cloneTag.setAttribute("nonce", "");
  356. cloneTag.nonce = nonce;
  357. return nonce === oldTag.nonce && oldTag.isEqualNode(cloneTag);
  358. }
  359. }
  360. return oldTag.isEqualNode(newTag);
  361. }
  362. function updateElements(type, components) {
  363. const headEl = document.getElementsByTagName("head")[0];
  364. const headCountEl = headEl.querySelector("meta[name=next-head-count]");
  365. if (false) {}
  366. const headCount = Number(headCountEl.content);
  367. const oldTags = [];
  368. for(let i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = (j == null ? void 0 : j.previousElementSibling) || null){
  369. var ref;
  370. if ((j == null ? void 0 : (ref = j.tagName) == null ? void 0 : ref.toLowerCase()) === type) {
  371. oldTags.push(j);
  372. }
  373. }
  374. const newTags = components.map(reactElementToDOM).filter((newTag)=>{
  375. for(let k = 0, len = oldTags.length; k < len; k++){
  376. const oldTag = oldTags[k];
  377. if (isEqualNode(oldTag, newTag)) {
  378. oldTags.splice(k, 1);
  379. return false;
  380. }
  381. }
  382. return true;
  383. });
  384. oldTags.forEach((t)=>{
  385. var ref;
  386. return (ref = t.parentNode) == null ? void 0 : ref.removeChild(t);
  387. });
  388. newTags.forEach((t)=>headEl.insertBefore(t, headCountEl));
  389. headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
  390. }
  391. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  392. Object.defineProperty(exports.default, "__esModule", {
  393. value: true
  394. });
  395. Object.assign(exports.default, exports);
  396. module.exports = exports.default;
  397. } //# sourceMappingURL=head-manager.js.map
  398. /***/ }),
  399. /***/ 53892:
  400. /***/ ((module, exports, __webpack_require__) => {
  401. "use strict";
  402. "client";
  403. Object.defineProperty(exports, "__esModule", ({
  404. value: true
  405. }));
  406. exports["default"] = void 0;
  407. var _interop_require_default = (__webpack_require__(40213)/* ["default"] */ .Z);
  408. var _object_without_properties_loose = (__webpack_require__(36969)/* ["default"] */ .Z);
  409. var _react = _interop_require_default(__webpack_require__(16689));
  410. var _router = __webpack_require__(42472);
  411. var _addLocale = __webpack_require__(32487);
  412. var _routerContext = __webpack_require__(24964);
  413. var _appRouterContext = __webpack_require__(3280);
  414. var _useIntersection = __webpack_require__(99879);
  415. var _getDomainLocale = __webpack_require__(51919);
  416. var _addBasePath = __webpack_require__(93378);
  417. "client";
  418. const prefetched = {};
  419. function prefetch(router, href, as, options) {
  420. if (true) return;
  421. if (!(0, _router).isLocalURL(href)) return;
  422. // Prefetch the JSON page if asked (only in the client)
  423. // We need to handle a prefetch error here since we may be
  424. // loading with priority which can reject but we don't
  425. // want to force navigation since this is only a prefetch
  426. Promise.resolve(router.prefetch(href, as, options)).catch((err)=>{
  427. if (false) {}
  428. });
  429. const curLocale = options && typeof options.locale !== "undefined" ? options.locale : router && router.locale;
  430. // Join on an invalid URI character
  431. prefetched[href + "%" + as + (curLocale ? "%" + curLocale : "")] = true;
  432. }
  433. function isModifiedEvent(event) {
  434. const { target } = event.currentTarget;
  435. return target && target !== "_self" || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.nativeEvent && event.nativeEvent.which === 2;
  436. }
  437. function linkClicked(e, router, href, as, replace, shallow, scroll, locale, isAppRouter, prefetchEnabled) {
  438. const { nodeName } = e.currentTarget;
  439. // anchors inside an svg have a lowercase nodeName
  440. const isAnchorNodeName = nodeName.toUpperCase() === "A";
  441. if (isAnchorNodeName && (isModifiedEvent(e) || !(0, _router).isLocalURL(href))) {
  442. // ignore click for browser’s default behavior
  443. return;
  444. }
  445. e.preventDefault();
  446. const navigate = ()=>{
  447. // If the router is an NextRouter instance it will have `beforePopState`
  448. if ("beforePopState" in router) {
  449. router[replace ? "replace" : "push"](href, as, {
  450. shallow,
  451. locale,
  452. scroll
  453. });
  454. } else {
  455. // If `beforePopState` doesn't exist on the router it's the AppRouter.
  456. const method = replace ? "replace" : "push";
  457. router[method](href, {
  458. forceOptimisticNavigation: !prefetchEnabled
  459. });
  460. }
  461. };
  462. if (isAppRouter) {
  463. // @ts-expect-error startTransition exists.
  464. _react.default.startTransition(navigate);
  465. } else {
  466. navigate();
  467. }
  468. }
  469. const Link = /*#__PURE__*/ _react.default.forwardRef(function LinkComponent(props, forwardedRef) {
  470. if (false) {}
  471. let children;
  472. const { href: hrefProp , as: asProp , children: childrenProp , prefetch: prefetchProp , passHref , replace , shallow , scroll , locale , onClick , onMouseEnter , onTouchStart , legacyBehavior =Boolean(false) !== true } = props, restProps = _object_without_properties_loose(props, [
  473. "href",
  474. "as",
  475. "children",
  476. "prefetch",
  477. "passHref",
  478. "replace",
  479. "shallow",
  480. "scroll",
  481. "locale",
  482. "onClick",
  483. "onMouseEnter",
  484. "onTouchStart",
  485. "legacyBehavior"
  486. ]);
  487. children = childrenProp;
  488. if (legacyBehavior && (typeof children === "string" || typeof children === "number")) {
  489. children = /*#__PURE__*/ _react.default.createElement("a", null, children);
  490. }
  491. const p = prefetchProp !== false;
  492. let router = _react.default.useContext(_routerContext.RouterContext);
  493. // TODO-APP: type error. Remove `as any`
  494. const appRouter = _react.default.useContext(_appRouterContext.AppRouterContext);
  495. if (appRouter) {
  496. router = appRouter;
  497. }
  498. const { href , as } = _react.default.useMemo(()=>{
  499. const [resolvedHref, resolvedAs] = (0, _router).resolveHref(router, hrefProp, true);
  500. return {
  501. href: resolvedHref,
  502. as: asProp ? (0, _router).resolveHref(router, asProp) : resolvedAs || resolvedHref
  503. };
  504. }, [
  505. router,
  506. hrefProp,
  507. asProp
  508. ]);
  509. const previousHref = _react.default.useRef(href);
  510. const previousAs = _react.default.useRef(as);
  511. // This will return the first child, if multiple are provided it will throw an error
  512. let child;
  513. if (legacyBehavior) {
  514. if (false) {} else {
  515. child = _react.default.Children.only(children);
  516. }
  517. }
  518. const childRef = legacyBehavior ? child && typeof child === "object" && child.ref : forwardedRef;
  519. const [setIntersectionRef, isVisible, resetVisible] = (0, _useIntersection).useIntersection({
  520. rootMargin: "200px"
  521. });
  522. const setRef = _react.default.useCallback((el)=>{
  523. // Before the link getting observed, check if visible state need to be reset
  524. if (previousAs.current !== as || previousHref.current !== href) {
  525. resetVisible();
  526. previousAs.current = as;
  527. previousHref.current = href;
  528. }
  529. setIntersectionRef(el);
  530. if (childRef) {
  531. if (typeof childRef === "function") childRef(el);
  532. else if (typeof childRef === "object") {
  533. childRef.current = el;
  534. }
  535. }
  536. }, [
  537. as,
  538. childRef,
  539. href,
  540. resetVisible,
  541. setIntersectionRef
  542. ]);
  543. _react.default.useEffect(()=>{
  544. const shouldPrefetch = isVisible && p && (0, _router).isLocalURL(href);
  545. const curLocale = typeof locale !== "undefined" ? locale : router && router.locale;
  546. const isPrefetched = prefetched[href + "%" + as + (curLocale ? "%" + curLocale : "")];
  547. if (shouldPrefetch && !isPrefetched) {
  548. prefetch(router, href, as, {
  549. locale: curLocale
  550. });
  551. }
  552. }, [
  553. as,
  554. href,
  555. isVisible,
  556. locale,
  557. p,
  558. router
  559. ]);
  560. const childProps = {
  561. ref: setRef,
  562. onClick: (e)=>{
  563. if (false) {}
  564. if (!legacyBehavior && typeof onClick === "function") {
  565. onClick(e);
  566. }
  567. if (legacyBehavior && child.props && typeof child.props.onClick === "function") {
  568. child.props.onClick(e);
  569. }
  570. if (!e.defaultPrevented) {
  571. linkClicked(e, router, href, as, replace, shallow, scroll, locale, Boolean(appRouter), p);
  572. }
  573. },
  574. onMouseEnter: (e)=>{
  575. if (!legacyBehavior && typeof onMouseEnter === "function") {
  576. onMouseEnter(e);
  577. }
  578. if (legacyBehavior && child.props && typeof child.props.onMouseEnter === "function") {
  579. child.props.onMouseEnter(e);
  580. }
  581. // Check for not prefetch disabled in page using appRouter
  582. if (!(!p && appRouter)) {
  583. if ((0, _router).isLocalURL(href)) {
  584. prefetch(router, href, as, {
  585. priority: true
  586. });
  587. }
  588. }
  589. },
  590. onTouchStart: (e)=>{
  591. if (!legacyBehavior && typeof onTouchStart === "function") {
  592. onTouchStart(e);
  593. }
  594. if (legacyBehavior && child.props && typeof child.props.onTouchStart === "function") {
  595. child.props.onTouchStart(e);
  596. }
  597. // Check for not prefetch disabled in page using appRouter
  598. if (!(!p && appRouter)) {
  599. if ((0, _router).isLocalURL(href)) {
  600. prefetch(router, href, as, {
  601. priority: true
  602. });
  603. }
  604. }
  605. }
  606. };
  607. // If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is
  608. // defined, we specify the current 'href', so that repetition is not needed by the user
  609. if (!legacyBehavior || passHref || child.type === "a" && !("href" in child.props)) {
  610. const curLocale = typeof locale !== "undefined" ? locale : router && router.locale;
  611. // we only render domain locales if we are currently on a domain locale
  612. // so that locale links are still visitable in development/preview envs
  613. const localeDomain = router && router.isLocaleDomain && (0, _getDomainLocale).getDomainLocale(as, curLocale, router.locales, router.domainLocales);
  614. childProps.href = localeDomain || (0, _addBasePath).addBasePath((0, _addLocale).addLocale(as, curLocale, router && router.defaultLocale));
  615. }
  616. return legacyBehavior ? /*#__PURE__*/ _react.default.cloneElement(child, childProps) : /*#__PURE__*/ _react.default.createElement("a", Object.assign({}, restProps, childProps), children);
  617. });
  618. var _default = Link;
  619. exports["default"] = _default;
  620. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  621. Object.defineProperty(exports.default, "__esModule", {
  622. value: true
  623. });
  624. Object.assign(exports.default, exports);
  625. module.exports = exports.default;
  626. } //# sourceMappingURL=link.js.map
  627. /***/ }),
  628. /***/ 76099:
  629. /***/ ((module, exports, __webpack_require__) => {
  630. "use strict";
  631. Object.defineProperty(exports, "__esModule", ({
  632. value: true
  633. }));
  634. exports.normalizeLocalePath = void 0;
  635. const normalizeLocalePath = (pathname, locales)=>{
  636. if (true) {
  637. return (__webpack_require__(34014).normalizeLocalePath)(pathname, locales);
  638. }
  639. return {
  640. pathname,
  641. detectedLocale: undefined
  642. };
  643. };
  644. exports.normalizeLocalePath = normalizeLocalePath;
  645. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  646. Object.defineProperty(exports.default, "__esModule", {
  647. value: true
  648. });
  649. Object.assign(exports.default, exports);
  650. module.exports = exports.default;
  651. } //# sourceMappingURL=normalize-locale-path.js.map
  652. /***/ }),
  653. /***/ 68641:
  654. /***/ ((module, exports, __webpack_require__) => {
  655. "use strict";
  656. Object.defineProperty(exports, "__esModule", ({
  657. value: true
  658. }));
  659. exports.normalizePathTrailingSlash = void 0;
  660. var _removeTrailingSlash = __webpack_require__(93297);
  661. var _parsePath = __webpack_require__(28854);
  662. const normalizePathTrailingSlash = (path)=>{
  663. if (!path.startsWith("/") || undefined) {
  664. return path;
  665. }
  666. const { pathname , query , hash } = (0, _parsePath).parsePath(path);
  667. if (false) {}
  668. return `${(0, _removeTrailingSlash).removeTrailingSlash(pathname)}${query}${hash}`;
  669. };
  670. exports.normalizePathTrailingSlash = normalizePathTrailingSlash;
  671. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  672. Object.defineProperty(exports.default, "__esModule", {
  673. value: true
  674. });
  675. Object.assign(exports.default, exports);
  676. module.exports = exports.default;
  677. } //# sourceMappingURL=normalize-trailing-slash.js.map
  678. /***/ }),
  679. /***/ 13811:
  680. /***/ ((module, exports, __webpack_require__) => {
  681. "use strict";
  682. Object.defineProperty(exports, "__esModule", ({
  683. value: true
  684. }));
  685. exports.removeBasePath = removeBasePath;
  686. var _hasBasePath = __webpack_require__(22992);
  687. const basePath = false || "";
  688. function removeBasePath(path) {
  689. if (false) {}
  690. path = path.slice(basePath.length);
  691. if (!path.startsWith("/")) path = `/${path}`;
  692. return path;
  693. }
  694. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  695. Object.defineProperty(exports.default, "__esModule", {
  696. value: true
  697. });
  698. Object.assign(exports.default, exports);
  699. module.exports = exports.default;
  700. } //# sourceMappingURL=remove-base-path.js.map
  701. /***/ }),
  702. /***/ 30550:
  703. /***/ ((module, exports, __webpack_require__) => {
  704. "use strict";
  705. Object.defineProperty(exports, "__esModule", ({
  706. value: true
  707. }));
  708. exports.removeLocale = removeLocale;
  709. var _parsePath = __webpack_require__(28854);
  710. function removeLocale(path, locale) {
  711. if (true) {
  712. const { pathname } = (0, _parsePath).parsePath(path);
  713. const pathLower = pathname.toLowerCase();
  714. const localeLower = locale == null ? void 0 : locale.toLowerCase();
  715. return locale && (pathLower.startsWith(`/${localeLower}/`) || pathLower === `/${localeLower}`) ? `${pathname.length === locale.length + 1 ? `/` : ``}${path.slice(locale.length + 1)}` : path;
  716. }
  717. return path;
  718. }
  719. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  720. Object.defineProperty(exports.default, "__esModule", {
  721. value: true
  722. });
  723. Object.assign(exports.default, exports);
  724. module.exports = exports.default;
  725. } //# sourceMappingURL=remove-locale.js.map
  726. /***/ }),
  727. /***/ 15248:
  728. /***/ ((module, exports) => {
  729. "use strict";
  730. Object.defineProperty(exports, "__esModule", ({
  731. value: true
  732. }));
  733. exports.cancelIdleCallback = exports.requestIdleCallback = void 0;
  734. const requestIdleCallback = typeof self !== "undefined" && self.requestIdleCallback && self.requestIdleCallback.bind(window) || function(cb) {
  735. let start = Date.now();
  736. return setTimeout(function() {
  737. cb({
  738. didTimeout: false,
  739. timeRemaining: function() {
  740. return Math.max(0, 50 - (Date.now() - start));
  741. }
  742. });
  743. }, 1);
  744. };
  745. exports.requestIdleCallback = requestIdleCallback;
  746. const cancelIdleCallback = typeof self !== "undefined" && self.cancelIdleCallback && self.cancelIdleCallback.bind(window) || function(id) {
  747. return clearTimeout(id);
  748. };
  749. exports.cancelIdleCallback = cancelIdleCallback;
  750. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  751. Object.defineProperty(exports.default, "__esModule", {
  752. value: true
  753. });
  754. Object.assign(exports.default, exports);
  755. module.exports = exports.default;
  756. } //# sourceMappingURL=request-idle-callback.js.map
  757. /***/ }),
  758. /***/ 73028:
  759. /***/ ((module, exports, __webpack_require__) => {
  760. "use strict";
  761. Object.defineProperty(exports, "__esModule", ({
  762. value: true
  763. }));
  764. exports.markAssetError = markAssetError;
  765. exports.isAssetError = isAssetError;
  766. exports.getClientBuildManifest = getClientBuildManifest;
  767. exports.createRouteLoader = createRouteLoader;
  768. var _interop_require_default = (__webpack_require__(40213)/* ["default"] */ .Z);
  769. var _getAssetPathFromRoute = _interop_require_default(__webpack_require__(29565));
  770. var _trustedTypes = __webpack_require__(65624);
  771. var _requestIdleCallback = __webpack_require__(15248);
  772. // 3.8s was arbitrarily chosen as it's what https://web.dev/interactive
  773. // considers as "Good" time-to-interactive. We must assume something went
  774. // wrong beyond this point, and then fall-back to a full page transition to
  775. // show the user something of value.
  776. const MS_MAX_IDLE_DELAY = 3800;
  777. function withFuture(key, map, generator) {
  778. let entry = map.get(key);
  779. if (entry) {
  780. if ("future" in entry) {
  781. return entry.future;
  782. }
  783. return Promise.resolve(entry);
  784. }
  785. let resolver;
  786. const prom = new Promise((resolve)=>{
  787. resolver = resolve;
  788. });
  789. map.set(key, entry = {
  790. resolve: resolver,
  791. future: prom
  792. });
  793. return generator ? generator() // eslint-disable-next-line no-sequences
  794. .then((value)=>(resolver(value), value)).catch((err)=>{
  795. map.delete(key);
  796. throw err;
  797. }) : prom;
  798. }
  799. function hasPrefetch(link) {
  800. try {
  801. link = document.createElement("link");
  802. return(// with relList.support
  803. !!window.MSInputMethodContext && !!document.documentMode || link.relList.supports("prefetch"));
  804. } catch (e) {
  805. return false;
  806. }
  807. }
  808. const canPrefetch = hasPrefetch();
  809. function prefetchViaDom(href, as, link) {
  810. return new Promise((res, rej)=>{
  811. const selector = `
  812. link[rel="prefetch"][href^="${href}"],
  813. link[rel="preload"][href^="${href}"],
  814. script[src^="${href}"]`;
  815. if (document.querySelector(selector)) {
  816. return res();
  817. }
  818. link = document.createElement("link");
  819. // The order of property assignment here is intentional:
  820. if (as) link.as = as;
  821. link.rel = `prefetch`;
  822. link.crossOrigin = undefined;
  823. link.onload = res;
  824. link.onerror = rej;
  825. // `href` should always be last:
  826. link.href = href;
  827. document.head.appendChild(link);
  828. });
  829. }
  830. const ASSET_LOAD_ERROR = Symbol("ASSET_LOAD_ERROR");
  831. function markAssetError(err) {
  832. return Object.defineProperty(err, ASSET_LOAD_ERROR, {});
  833. }
  834. function isAssetError(err) {
  835. return err && ASSET_LOAD_ERROR in err;
  836. }
  837. function appendScript(src, script) {
  838. return new Promise((resolve, reject)=>{
  839. script = document.createElement("script");
  840. // The order of property assignment here is intentional.
  841. // 1. Setup success/failure hooks in case the browser synchronously
  842. // executes when `src` is set.
  843. script.onload = resolve;
  844. script.onerror = ()=>reject(markAssetError(new Error(`Failed to load script: ${src}`)));
  845. // 2. Configure the cross-origin attribute before setting `src` in case the
  846. // browser begins to fetch.
  847. script.crossOrigin = undefined;
  848. // 3. Finally, set the source and inject into the DOM in case the child
  849. // must be appended for fetching to start.
  850. script.src = src;
  851. document.body.appendChild(script);
  852. });
  853. }
  854. // We wait for pages to be built in dev before we start the route transition
  855. // timeout to prevent an un-necessary hard navigation in development.
  856. let devBuildPromise;
  857. // Resolve a promise that times out after given amount of milliseconds.
  858. function resolvePromiseWithTimeout(p, ms, err) {
  859. return new Promise((resolve, reject)=>{
  860. let cancelled = false;
  861. p.then((r)=>{
  862. // Resolved, cancel the timeout
  863. cancelled = true;
  864. resolve(r);
  865. }).catch(reject);
  866. // We wrap these checks separately for better dead-code elimination in
  867. // production bundles.
  868. if (false) {}
  869. if (true) {
  870. (0, _requestIdleCallback).requestIdleCallback(()=>setTimeout(()=>{
  871. if (!cancelled) {
  872. reject(err);
  873. }
  874. }, ms));
  875. }
  876. });
  877. }
  878. function getClientBuildManifest() {
  879. if (self.__BUILD_MANIFEST) {
  880. return Promise.resolve(self.__BUILD_MANIFEST);
  881. }
  882. const onBuildManifest = new Promise((resolve)=>{
  883. // Mandatory because this is not concurrent safe:
  884. const cb = self.__BUILD_MANIFEST_CB;
  885. self.__BUILD_MANIFEST_CB = ()=>{
  886. resolve(self.__BUILD_MANIFEST);
  887. cb && cb();
  888. };
  889. });
  890. return resolvePromiseWithTimeout(onBuildManifest, MS_MAX_IDLE_DELAY, markAssetError(new Error("Failed to load client build manifest")));
  891. }
  892. function getFilesForRoute(assetPrefix, route) {
  893. if (false) {}
  894. return getClientBuildManifest().then((manifest)=>{
  895. if (!(route in manifest)) {
  896. throw markAssetError(new Error(`Failed to lookup route: ${route}`));
  897. }
  898. const allFiles = manifest[route].map((entry)=>assetPrefix + "/_next/" + encodeURI(entry));
  899. return {
  900. scripts: allFiles.filter((v)=>v.endsWith(".js")).map((v)=>(0, _trustedTypes).__unsafeCreateTrustedScriptURL(v)),
  901. css: allFiles.filter((v)=>v.endsWith(".css"))
  902. };
  903. });
  904. }
  905. function createRouteLoader(assetPrefix) {
  906. const entrypoints = new Map();
  907. const loadedScripts = new Map();
  908. const styleSheets = new Map();
  909. const routes = new Map();
  910. function maybeExecuteScript(src) {
  911. // With HMR we might need to "reload" scripts when they are
  912. // disposed and readded. Executing scripts twice has no functional
  913. // differences
  914. if (true) {
  915. let prom = loadedScripts.get(src.toString());
  916. if (prom) {
  917. return prom;
  918. }
  919. // Skip executing script if it's already in the DOM:
  920. if (document.querySelector(`script[src^="${src}"]`)) {
  921. return Promise.resolve();
  922. }
  923. loadedScripts.set(src.toString(), prom = appendScript(src));
  924. return prom;
  925. } else {}
  926. }
  927. function fetchStyleSheet(href) {
  928. let prom = styleSheets.get(href);
  929. if (prom) {
  930. return prom;
  931. }
  932. styleSheets.set(href, prom = fetch(href).then((res)=>{
  933. if (!res.ok) {
  934. throw new Error(`Failed to load stylesheet: ${href}`);
  935. }
  936. return res.text().then((text)=>({
  937. href: href,
  938. content: text
  939. }));
  940. }).catch((err)=>{
  941. throw markAssetError(err);
  942. }));
  943. return prom;
  944. }
  945. return {
  946. whenEntrypoint (route) {
  947. return withFuture(route, entrypoints);
  948. },
  949. onEntrypoint (route, execute) {
  950. (execute ? Promise.resolve().then(()=>execute()).then((exports1)=>({
  951. component: exports1 && exports1.default || exports1,
  952. exports: exports1
  953. }), (err)=>({
  954. error: err
  955. })) : Promise.resolve(undefined)).then((input)=>{
  956. const old = entrypoints.get(route);
  957. if (old && "resolve" in old) {
  958. if (input) {
  959. entrypoints.set(route, input);
  960. old.resolve(input);
  961. }
  962. } else {
  963. if (input) {
  964. entrypoints.set(route, input);
  965. } else {
  966. entrypoints.delete(route);
  967. }
  968. // when this entrypoint has been resolved before
  969. // the route is outdated and we want to invalidate
  970. // this cache entry
  971. routes.delete(route);
  972. }
  973. });
  974. },
  975. loadRoute (route, prefetch) {
  976. return withFuture(route, routes, ()=>{
  977. let devBuildPromiseResolve;
  978. if (false) {}
  979. return resolvePromiseWithTimeout(getFilesForRoute(assetPrefix, route).then(({ scripts , css })=>{
  980. return Promise.all([
  981. entrypoints.has(route) ? [] : Promise.all(scripts.map(maybeExecuteScript)),
  982. Promise.all(css.map(fetchStyleSheet)),
  983. ]);
  984. }).then((res)=>{
  985. return this.whenEntrypoint(route).then((entrypoint)=>({
  986. entrypoint,
  987. styles: res[1]
  988. }));
  989. }), MS_MAX_IDLE_DELAY, markAssetError(new Error(`Route did not complete loading: ${route}`))).then(({ entrypoint , styles })=>{
  990. const res = Object.assign({
  991. styles: styles
  992. }, entrypoint);
  993. return "error" in entrypoint ? entrypoint : res;
  994. }).catch((err)=>{
  995. if (prefetch) {
  996. // we don't want to cache errors during prefetch
  997. throw err;
  998. }
  999. return {
  1000. error: err
  1001. };
  1002. }).finally(()=>{
  1003. return devBuildPromiseResolve == null ? void 0 : devBuildPromiseResolve();
  1004. });
  1005. });
  1006. },
  1007. prefetch (route) {
  1008. // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
  1009. // License: Apache 2.0
  1010. let cn;
  1011. if (cn = navigator.connection) {
  1012. // Don't prefetch if using 2G or if Save-Data is enabled.
  1013. if (cn.saveData || /2g/.test(cn.effectiveType)) return Promise.resolve();
  1014. }
  1015. return getFilesForRoute(assetPrefix, route).then((output)=>Promise.all(canPrefetch ? output.scripts.map((script)=>prefetchViaDom(script.toString(), "script")) : [])).then(()=>{
  1016. (0, _requestIdleCallback).requestIdleCallback(()=>this.loadRoute(route, true).catch(()=>{}));
  1017. }).catch(()=>{});
  1018. }
  1019. };
  1020. }
  1021. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  1022. Object.defineProperty(exports.default, "__esModule", {
  1023. value: true
  1024. });
  1025. Object.assign(exports.default, exports);
  1026. module.exports = exports.default;
  1027. } //# sourceMappingURL=route-loader.js.map
  1028. /***/ }),
  1029. /***/ 95708:
  1030. /***/ ((module, exports, __webpack_require__) => {
  1031. "use strict";
  1032. "client";
  1033. Object.defineProperty(exports, "__esModule", ({
  1034. value: true
  1035. }));
  1036. exports.handleClientScriptLoad = handleClientScriptLoad;
  1037. exports.initScriptLoader = initScriptLoader;
  1038. exports["default"] = void 0;
  1039. var _extends = (__webpack_require__(25550)/* ["default"] */ .Z);
  1040. var _interop_require_wildcard = (__webpack_require__(95928)/* ["default"] */ .Z);
  1041. var _object_without_properties_loose = (__webpack_require__(36969)/* ["default"] */ .Z);
  1042. var _react = _interop_require_wildcard(__webpack_require__(16689));
  1043. var _headManagerContext = __webpack_require__(92796);
  1044. var _headManager = __webpack_require__(58696);
  1045. var _requestIdleCallback = __webpack_require__(15248);
  1046. "client";
  1047. const ScriptCache = new Map();
  1048. const LoadCache = new Set();
  1049. const ignoreProps = [
  1050. "onLoad",
  1051. "onReady",
  1052. "dangerouslySetInnerHTML",
  1053. "children",
  1054. "onError",
  1055. "strategy",
  1056. ];
  1057. const loadScript = (props)=>{
  1058. const { src , id , onLoad =()=>{} , onReady =null , dangerouslySetInnerHTML , children ="" , strategy ="afterInteractive" , onError , } = props;
  1059. const cacheKey = id || src;
  1060. // Script has already loaded
  1061. if (cacheKey && LoadCache.has(cacheKey)) {
  1062. return;
  1063. }
  1064. // Contents of this script are already loading/loaded
  1065. if (ScriptCache.has(src)) {
  1066. LoadCache.add(cacheKey);
  1067. // It is possible that multiple `next/script` components all have same "src", but has different "onLoad"
  1068. // This is to make sure the same remote script will only load once, but "onLoad" are executed in order
  1069. ScriptCache.get(src).then(onLoad, onError);
  1070. return;
  1071. }
  1072. /** Execute after the script first loaded */ const afterLoad = ()=>{
  1073. // Run onReady for the first time after load event
  1074. if (onReady) {
  1075. onReady();
  1076. }
  1077. // add cacheKey to LoadCache when load successfully
  1078. LoadCache.add(cacheKey);
  1079. };
  1080. const el = document.createElement("script");
  1081. const loadPromise = new Promise((resolve, reject)=>{
  1082. el.addEventListener("load", function(e) {
  1083. resolve();
  1084. if (onLoad) {
  1085. onLoad.call(this, e);
  1086. }
  1087. afterLoad();
  1088. });
  1089. el.addEventListener("error", function(e) {
  1090. reject(e);
  1091. });
  1092. }).catch(function(e) {
  1093. if (onError) {
  1094. onError(e);
  1095. }
  1096. });
  1097. if (dangerouslySetInnerHTML) {
  1098. el.innerHTML = dangerouslySetInnerHTML.__html || "";
  1099. afterLoad();
  1100. } else if (children) {
  1101. el.textContent = typeof children === "string" ? children : Array.isArray(children) ? children.join("") : "";
  1102. afterLoad();
  1103. } else if (src) {
  1104. el.src = src;
  1105. // do not add cacheKey into LoadCache for remote script here
  1106. // cacheKey will be added to LoadCache when it is actually loaded (see loadPromise above)
  1107. ScriptCache.set(src, loadPromise);
  1108. }
  1109. for (const [k, value] of Object.entries(props)){
  1110. if (value === undefined || ignoreProps.includes(k)) {
  1111. continue;
  1112. }
  1113. const attr = _headManager.DOMAttributeNames[k] || k.toLowerCase();
  1114. el.setAttribute(attr, value);
  1115. }
  1116. if (strategy === "worker") {
  1117. el.setAttribute("type", "text/partytown");
  1118. }
  1119. el.setAttribute("data-nscript", strategy);
  1120. document.body.appendChild(el);
  1121. };
  1122. function handleClientScriptLoad(props) {
  1123. const { strategy ="afterInteractive" } = props;
  1124. if (strategy === "lazyOnload") {
  1125. window.addEventListener("load", ()=>{
  1126. (0, _requestIdleCallback).requestIdleCallback(()=>loadScript(props));
  1127. });
  1128. } else {
  1129. loadScript(props);
  1130. }
  1131. }
  1132. function loadLazyScript(props) {
  1133. if (document.readyState === "complete") {
  1134. (0, _requestIdleCallback).requestIdleCallback(()=>loadScript(props));
  1135. } else {
  1136. window.addEventListener("load", ()=>{
  1137. (0, _requestIdleCallback).requestIdleCallback(()=>loadScript(props));
  1138. });
  1139. }
  1140. }
  1141. function addBeforeInteractiveToCache() {
  1142. const scripts = [
  1143. ...document.querySelectorAll('[data-nscript="beforeInteractive"]'),
  1144. ...document.querySelectorAll('[data-nscript="beforePageRender"]'),
  1145. ];
  1146. scripts.forEach((script)=>{
  1147. const cacheKey = script.id || script.getAttribute("src");
  1148. LoadCache.add(cacheKey);
  1149. });
  1150. }
  1151. function initScriptLoader(scriptLoaderItems) {
  1152. scriptLoaderItems.forEach(handleClientScriptLoad);
  1153. addBeforeInteractiveToCache();
  1154. }
  1155. function Script(props) {
  1156. const { id , src ="" , onLoad =()=>{} , onReady =null , strategy ="afterInteractive" , onError } = props, restProps = _object_without_properties_loose(props, [
  1157. "id",
  1158. "src",
  1159. "onLoad",
  1160. "onReady",
  1161. "strategy",
  1162. "onError"
  1163. ]);
  1164. // Context is available only during SSR
  1165. const { updateScripts , scripts , getIsSsr } = (0, _react).useContext(_headManagerContext.HeadManagerContext);
  1166. /**
  1167. * - First mount:
  1168. * 1. The useEffect for onReady executes
  1169. * 2. hasOnReadyEffectCalled.current is false, but the script hasn't loaded yet (not in LoadCache)
  1170. * onReady is skipped, set hasOnReadyEffectCalled.current to true
  1171. * 3. The useEffect for loadScript executes
  1172. * 4. hasLoadScriptEffectCalled.current is false, loadScript executes
  1173. * Once the script is loaded, the onLoad and onReady will be called by then
  1174. * [If strict mode is enabled / is wrapped in <OffScreen /> component]
  1175. * 5. The useEffect for onReady executes again
  1176. * 6. hasOnReadyEffectCalled.current is true, so entire effect is skipped
  1177. * 7. The useEffect for loadScript executes again
  1178. * 8. hasLoadScriptEffectCalled.current is true, so entire effect is skipped
  1179. *
  1180. * - Second mount:
  1181. * 1. The useEffect for onReady executes
  1182. * 2. hasOnReadyEffectCalled.current is false, but the script has already loaded (found in LoadCache)
  1183. * onReady is called, set hasOnReadyEffectCalled.current to true
  1184. * 3. The useEffect for loadScript executes
  1185. * 4. The script is already loaded, loadScript bails out
  1186. * [If strict mode is enabled / is wrapped in <OffScreen /> component]
  1187. * 5. The useEffect for onReady executes again
  1188. * 6. hasOnReadyEffectCalled.current is true, so entire effect is skipped
  1189. * 7. The useEffect for loadScript executes again
  1190. * 8. hasLoadScriptEffectCalled.current is true, so entire effect is skipped
  1191. */ const hasOnReadyEffectCalled = (0, _react).useRef(false);
  1192. (0, _react).useEffect(()=>{
  1193. const cacheKey = id || src;
  1194. if (!hasOnReadyEffectCalled.current) {
  1195. // Run onReady if script has loaded before but component is re-mounted
  1196. if (onReady && cacheKey && LoadCache.has(cacheKey)) {
  1197. onReady();
  1198. }
  1199. hasOnReadyEffectCalled.current = true;
  1200. }
  1201. }, [
  1202. onReady,
  1203. id,
  1204. src
  1205. ]);
  1206. const hasLoadScriptEffectCalled = (0, _react).useRef(false);
  1207. (0, _react).useEffect(()=>{
  1208. if (!hasLoadScriptEffectCalled.current) {
  1209. if (strategy === "afterInteractive") {
  1210. loadScript(props);
  1211. } else if (strategy === "lazyOnload") {
  1212. loadLazyScript(props);
  1213. }
  1214. hasLoadScriptEffectCalled.current = true;
  1215. }
  1216. }, [
  1217. props,
  1218. strategy
  1219. ]);
  1220. if (strategy === "beforeInteractive" || strategy === "worker") {
  1221. if (updateScripts) {
  1222. scripts[strategy] = (scripts[strategy] || []).concat([
  1223. _extends({
  1224. id,
  1225. src,
  1226. onLoad,
  1227. onReady,
  1228. onError
  1229. }, restProps),
  1230. ]);
  1231. updateScripts(scripts);
  1232. } else if (getIsSsr && getIsSsr()) {
  1233. // Script has already loaded during SSR
  1234. LoadCache.add(id || src);
  1235. } else if (getIsSsr && !getIsSsr()) {
  1236. loadScript(props);
  1237. }
  1238. }
  1239. return null;
  1240. }
  1241. Object.defineProperty(Script, "__nextScript", {
  1242. value: true
  1243. });
  1244. var _default = Script;
  1245. exports["default"] = _default;
  1246. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  1247. Object.defineProperty(exports.default, "__esModule", {
  1248. value: true
  1249. });
  1250. Object.assign(exports.default, exports);
  1251. module.exports = exports.default;
  1252. } //# sourceMappingURL=script.js.map
  1253. /***/ }),
  1254. /***/ 65624:
  1255. /***/ ((module, exports) => {
  1256. "use strict";
  1257. Object.defineProperty(exports, "__esModule", ({
  1258. value: true
  1259. }));
  1260. exports.__unsafeCreateTrustedScriptURL = __unsafeCreateTrustedScriptURL;
  1261. /**
  1262. * Stores the Trusted Types Policy. Starts as undefined and can be set to null
  1263. * if Trusted Types is not supported in the browser.
  1264. */ let policy;
  1265. /**
  1266. * Getter for the Trusted Types Policy. If it is undefined, it is instantiated
  1267. * here or set to null if Trusted Types is not supported in the browser.
  1268. */ function getPolicy() {
  1269. if (typeof policy === "undefined" && "undefined" !== "undefined") { var ref; }
  1270. return policy;
  1271. }
  1272. function __unsafeCreateTrustedScriptURL(url) {
  1273. var ref;
  1274. return ((ref = getPolicy()) == null ? void 0 : ref.createScriptURL(url)) || url;
  1275. }
  1276. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  1277. Object.defineProperty(exports.default, "__esModule", {
  1278. value: true
  1279. });
  1280. Object.assign(exports.default, exports);
  1281. module.exports = exports.default;
  1282. } //# sourceMappingURL=trusted-types.js.map
  1283. /***/ }),
  1284. /***/ 99879:
  1285. /***/ ((module, exports, __webpack_require__) => {
  1286. "use strict";
  1287. Object.defineProperty(exports, "__esModule", ({
  1288. value: true
  1289. }));
  1290. exports.useIntersection = useIntersection;
  1291. var _react = __webpack_require__(16689);
  1292. var _requestIdleCallback = __webpack_require__(15248);
  1293. const hasIntersectionObserver = typeof IntersectionObserver === "function";
  1294. const observers = new Map();
  1295. const idList = [];
  1296. function createObserver(options) {
  1297. const id = {
  1298. root: options.root || null,
  1299. margin: options.rootMargin || ""
  1300. };
  1301. const existing = idList.find((obj)=>obj.root === id.root && obj.margin === id.margin);
  1302. let instance;
  1303. if (existing) {
  1304. instance = observers.get(existing);
  1305. if (instance) {
  1306. return instance;
  1307. }
  1308. }
  1309. const elements = new Map();
  1310. const observer = new IntersectionObserver((entries)=>{
  1311. entries.forEach((entry)=>{
  1312. const callback = elements.get(entry.target);
  1313. const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
  1314. if (callback && isVisible) {
  1315. callback(isVisible);
  1316. }
  1317. });
  1318. }, options);
  1319. instance = {
  1320. id,
  1321. observer,
  1322. elements
  1323. };
  1324. idList.push(id);
  1325. observers.set(id, instance);
  1326. return instance;
  1327. }
  1328. function observe(element, callback, options) {
  1329. const { id , observer , elements } = createObserver(options);
  1330. elements.set(element, callback);
  1331. observer.observe(element);
  1332. return function unobserve() {
  1333. elements.delete(element);
  1334. observer.unobserve(element);
  1335. // Destroy observer when there's nothing left to watch:
  1336. if (elements.size === 0) {
  1337. observer.disconnect();
  1338. observers.delete(id);
  1339. const index = idList.findIndex((obj)=>obj.root === id.root && obj.margin === id.margin);
  1340. if (index > -1) {
  1341. idList.splice(index, 1);
  1342. }
  1343. }
  1344. };
  1345. }
  1346. function useIntersection({ rootRef , rootMargin , disabled }) {
  1347. const isDisabled = disabled || !hasIntersectionObserver;
  1348. const [visible, setVisible] = (0, _react).useState(false);
  1349. const [element, setElement] = (0, _react).useState(null);
  1350. (0, _react).useEffect(()=>{
  1351. if (hasIntersectionObserver) {
  1352. if (isDisabled || visible) return;
  1353. if (element && element.tagName) {
  1354. const unobserve = observe(element, (isVisible)=>isVisible && setVisible(isVisible), {
  1355. root: rootRef == null ? void 0 : rootRef.current,
  1356. rootMargin
  1357. });
  1358. return unobserve;
  1359. }
  1360. } else {
  1361. if (!visible) {
  1362. const idleCallback = (0, _requestIdleCallback).requestIdleCallback(()=>setVisible(true));
  1363. return ()=>(0, _requestIdleCallback).cancelIdleCallback(idleCallback);
  1364. }
  1365. }
  1366. }, [
  1367. element,
  1368. isDisabled,
  1369. rootMargin,
  1370. rootRef,
  1371. visible
  1372. ]);
  1373. const resetVisible = (0, _react).useCallback(()=>{
  1374. setVisible(false);
  1375. }, []);
  1376. return [
  1377. setElement,
  1378. visible,
  1379. resetVisible
  1380. ];
  1381. }
  1382. if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
  1383. Object.defineProperty(exports.default, "__esModule", {
  1384. value: true
  1385. });
  1386. Object.assign(exports.default, exports);
  1387. module.exports = exports.default;
  1388. } //# sourceMappingURL=use-intersection.js.map
  1389. /***/ }),
  1390. /***/ 42472:
  1391. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1392. "use strict";
  1393. Object.defineProperty(exports, "__esModule", ({
  1394. value: true
  1395. }));
  1396. exports.matchesMiddleware = matchesMiddleware;
  1397. exports.isLocalURL = isLocalURL;
  1398. exports.interpolateAs = interpolateAs;
  1399. exports.resolveHref = resolveHref;
  1400. exports.createKey = createKey;
  1401. exports["default"] = void 0;
  1402. var _async_to_generator = (__webpack_require__(96001)/* ["default"] */ .Z);
  1403. var _extends = (__webpack_require__(25550)/* ["default"] */ .Z);
  1404. var _interop_require_default = (__webpack_require__(40213)/* ["default"] */ .Z);
  1405. var _interop_require_wildcard = (__webpack_require__(95928)/* ["default"] */ .Z);
  1406. var _normalizeTrailingSlash = __webpack_require__(68641);
  1407. var _removeTrailingSlash = __webpack_require__(93297);
  1408. var _routeLoader = __webpack_require__(73028);
  1409. var _script = __webpack_require__(95708);
  1410. var _isError = _interop_require_wildcard(__webpack_require__(11497));
  1411. var _denormalizePagePath = __webpack_require__(64406);
  1412. var _normalizeLocalePath = __webpack_require__(34014);
  1413. var _mitt = _interop_require_default(__webpack_require__(78020));
  1414. var _utils = __webpack_require__(59232);
  1415. var _isDynamic = __webpack_require__(1428);
  1416. var _parseRelativeUrl = __webpack_require__(91292);
  1417. var _querystring = __webpack_require__(80979);
  1418. var _resolveRewrites = _interop_require_default(__webpack_require__(36052));
  1419. var _routeMatcher = __webpack_require__(84226);
  1420. var _routeRegex = __webpack_require__(95052);
  1421. var _formatUrl = __webpack_require__(23938);
  1422. var _detectDomainLocale = __webpack_require__(17747);
  1423. var _parsePath = __webpack_require__(28854);
  1424. var _addLocale = __webpack_require__(32487);
  1425. var _removeLocale = __webpack_require__(30550);
  1426. var _removeBasePath = __webpack_require__(13811);
  1427. var _addBasePath = __webpack_require__(93378);
  1428. var _hasBasePath = __webpack_require__(22992);
  1429. var _getNextPathnameInfo = __webpack_require__(35789);
  1430. var _formatNextPathnameInfo = __webpack_require__(10299);
  1431. var _compareStates = __webpack_require__(46220);
  1432. var _isBot = __webpack_require__(1897);
  1433. function buildCancellationError() {
  1434. return Object.assign(new Error("Route Cancelled"), {
  1435. cancelled: true
  1436. });
  1437. }
  1438. function matchesMiddleware(options) {
  1439. return _matchesMiddleware.apply(this, arguments);
  1440. }
  1441. function _matchesMiddleware() {
  1442. _matchesMiddleware = _async_to_generator(function*(options) {
  1443. const matchers = yield Promise.resolve(options.router.pageLoader.getMiddleware());
  1444. if (!matchers) return false;
  1445. const { pathname: asPathname } = (0, _parsePath).parsePath(options.asPath);
  1446. // remove basePath first since path prefix has to be in the order of `/${basePath}/${locale}`
  1447. const cleanedAs = (0, _hasBasePath).hasBasePath(asPathname) ? (0, _removeBasePath).removeBasePath(asPathname) : asPathname;
  1448. const asWithBasePathAndLocale = (0, _addBasePath).addBasePath((0, _addLocale).addLocale(cleanedAs, options.locale));
  1449. // Check only path match on client. Matching "has" should be done on server
  1450. // where we can access more info such as headers, HttpOnly cookie, etc.
  1451. return matchers.some((m)=>new RegExp(m.regexp).test(asWithBasePathAndLocale));
  1452. });
  1453. return _matchesMiddleware.apply(this, arguments);
  1454. }
  1455. function stripOrigin(url) {
  1456. const origin = (0, _utils).getLocationOrigin();
  1457. return url.startsWith(origin) ? url.substring(origin.length) : url;
  1458. }
  1459. function omit(object, keys) {
  1460. const omitted = {};
  1461. Object.keys(object).forEach((key)=>{
  1462. if (!keys.includes(key)) {
  1463. omitted[key] = object[key];
  1464. }
  1465. });
  1466. return omitted;
  1467. }
  1468. function isLocalURL(url) {
  1469. // prevent a hydration mismatch on href for url with anchor refs
  1470. if (!(0, _utils).isAbsoluteUrl(url)) return true;
  1471. try {
  1472. // absolute urls can be local if they are on the same origin
  1473. const locationOrigin = (0, _utils).getLocationOrigin();
  1474. const resolved = new URL(url, locationOrigin);
  1475. return resolved.origin === locationOrigin && (0, _hasBasePath).hasBasePath(resolved.pathname);
  1476. } catch (_) {
  1477. return false;
  1478. }
  1479. }
  1480. function interpolateAs(route, asPathname, query) {
  1481. let interpolatedRoute = "";
  1482. const dynamicRegex = (0, _routeRegex).getRouteRegex(route);
  1483. const dynamicGroups = dynamicRegex.groups;
  1484. const dynamicMatches = (asPathname !== route ? (0, _routeMatcher).getRouteMatcher(dynamicRegex)(asPathname) : "") || // Fall back to reading the values from the href
  1485. // TODO: should this take priority; also need to change in the router.
  1486. query;
  1487. interpolatedRoute = route;
  1488. const params = Object.keys(dynamicGroups);
  1489. if (!params.every((param)=>{
  1490. let value = dynamicMatches[param] || "";
  1491. const { repeat , optional } = dynamicGroups[param];
  1492. // support single-level catch-all
  1493. // TODO: more robust handling for user-error (passing `/`)
  1494. let replaced = `[${repeat ? "..." : ""}${param}]`;
  1495. if (optional) {
  1496. replaced = `${!value ? "/" : ""}[${replaced}]`;
  1497. }
  1498. if (repeat && !Array.isArray(value)) value = [
  1499. value
  1500. ];
  1501. return (optional || param in dynamicMatches) && // Interpolate group into data URL if present
  1502. (interpolatedRoute = interpolatedRoute.replace(replaced, repeat ? value.map(// path delimiter escaped since they are being inserted
  1503. // into the URL and we expect URL encoded segments
  1504. // when parsing dynamic route params
  1505. (segment)=>encodeURIComponent(segment)).join("/") : encodeURIComponent(value)) || "/");
  1506. })) {
  1507. interpolatedRoute = "" // did not satisfy all requirements
  1508. ;
  1509. // n.b. We ignore this error because we handle warning for this case in
  1510. // development in the `<Link>` component directly.
  1511. }
  1512. return {
  1513. params,
  1514. result: interpolatedRoute
  1515. };
  1516. }
  1517. function resolveHref(router, href, resolveAs) {
  1518. // we use a dummy base url for relative urls
  1519. let base;
  1520. let urlAsString = typeof href === "string" ? href : (0, _formatUrl).formatWithValidation(href);
  1521. // repeated slashes and backslashes in the URL are considered
  1522. // invalid and will never match a Next.js page/file
  1523. const urlProtoMatch = urlAsString.match(/^[a-zA-Z]{1,}:\/\//);
  1524. const urlAsStringNoProto = urlProtoMatch ? urlAsString.slice(urlProtoMatch[0].length) : urlAsString;
  1525. const urlParts = urlAsStringNoProto.split("?");
  1526. if ((urlParts[0] || "").match(/(\/\/|\\)/)) {
  1527. console.error(`Invalid href passed to next/router: ${urlAsString}, repeated forward-slashes (//) or backslashes \\ are not valid in the href`);
  1528. const normalizedUrl = (0, _utils).normalizeRepeatedSlashes(urlAsStringNoProto);
  1529. urlAsString = (urlProtoMatch ? urlProtoMatch[0] : "") + normalizedUrl;
  1530. }
  1531. // Return because it cannot be routed by the Next.js router
  1532. if (!isLocalURL(urlAsString)) {
  1533. return resolveAs ? [
  1534. urlAsString
  1535. ] : urlAsString;
  1536. }
  1537. try {
  1538. base = new URL(urlAsString.startsWith("#") ? router.asPath : router.pathname, "http://n");
  1539. } catch (_) {
  1540. // fallback to / for invalid asPath values e.g. //
  1541. base = new URL("/", "http://n");
  1542. }
  1543. try {
  1544. const finalUrl = new URL(urlAsString, base);
  1545. finalUrl.pathname = (0, _normalizeTrailingSlash).normalizePathTrailingSlash(finalUrl.pathname);
  1546. let interpolatedAs = "";
  1547. if ((0, _isDynamic).isDynamicRoute(finalUrl.pathname) && finalUrl.searchParams && resolveAs) {
  1548. const query = (0, _querystring).searchParamsToUrlQuery(finalUrl.searchParams);
  1549. const { result , params } = interpolateAs(finalUrl.pathname, finalUrl.pathname, query);
  1550. if (result) {
  1551. interpolatedAs = (0, _formatUrl).formatWithValidation({
  1552. pathname: result,
  1553. hash: finalUrl.hash,
  1554. query: omit(query, params)
  1555. });
  1556. }
  1557. }
  1558. // if the origin didn't change, it means we received a relative href
  1559. const resolvedHref = finalUrl.origin === base.origin ? finalUrl.href.slice(finalUrl.origin.length) : finalUrl.href;
  1560. return resolveAs ? [
  1561. resolvedHref,
  1562. interpolatedAs || resolvedHref
  1563. ] : resolvedHref;
  1564. } catch (_1) {
  1565. return resolveAs ? [
  1566. urlAsString
  1567. ] : urlAsString;
  1568. }
  1569. }
  1570. function prepareUrlAs(router, url, as) {
  1571. // If url and as provided as an object representation,
  1572. // we'll format them into the string version here.
  1573. let [resolvedHref, resolvedAs] = resolveHref(router, url, true);
  1574. const origin = (0, _utils).getLocationOrigin();
  1575. const hrefHadOrigin = resolvedHref.startsWith(origin);
  1576. const asHadOrigin = resolvedAs && resolvedAs.startsWith(origin);
  1577. resolvedHref = stripOrigin(resolvedHref);
  1578. resolvedAs = resolvedAs ? stripOrigin(resolvedAs) : resolvedAs;
  1579. const preparedUrl = hrefHadOrigin ? resolvedHref : (0, _addBasePath).addBasePath(resolvedHref);
  1580. const preparedAs = as ? stripOrigin(resolveHref(router, as)) : resolvedAs || resolvedHref;
  1581. return {
  1582. url: preparedUrl,
  1583. as: asHadOrigin ? preparedAs : (0, _addBasePath).addBasePath(preparedAs)
  1584. };
  1585. }
  1586. function resolveDynamicRoute(pathname, pages) {
  1587. const cleanPathname = (0, _removeTrailingSlash).removeTrailingSlash((0, _denormalizePagePath).denormalizePagePath(pathname));
  1588. if (cleanPathname === "/404" || cleanPathname === "/_error") {
  1589. return pathname;
  1590. }
  1591. // handle resolving href for dynamic routes
  1592. if (!pages.includes(cleanPathname)) {
  1593. // eslint-disable-next-line array-callback-return
  1594. pages.some((page)=>{
  1595. if ((0, _isDynamic).isDynamicRoute(page) && (0, _routeRegex).getRouteRegex(page).re.test(cleanPathname)) {
  1596. pathname = page;
  1597. return true;
  1598. }
  1599. });
  1600. }
  1601. return (0, _removeTrailingSlash).removeTrailingSlash(pathname);
  1602. }
  1603. function getMiddlewareData(source, response, options) {
  1604. const nextConfig = {
  1605. basePath: options.router.basePath,
  1606. i18n: {
  1607. locales: options.router.locales
  1608. },
  1609. trailingSlash: Boolean(false)
  1610. };
  1611. const rewriteHeader = response.headers.get("x-nextjs-rewrite");
  1612. let rewriteTarget = rewriteHeader || response.headers.get("x-nextjs-matched-path");
  1613. const matchedPath = response.headers.get("x-matched-path");
  1614. if (matchedPath && !rewriteTarget && !matchedPath.includes("__next_data_catchall") && !matchedPath.includes("/_error") && !matchedPath.includes("/404")) {
  1615. // leverage x-matched-path to detect next.config.js rewrites
  1616. rewriteTarget = matchedPath;
  1617. }
  1618. if (rewriteTarget) {
  1619. if (rewriteTarget.startsWith("/")) {
  1620. const parsedRewriteTarget = (0, _parseRelativeUrl).parseRelativeUrl(rewriteTarget);
  1621. const pathnameInfo = (0, _getNextPathnameInfo).getNextPathnameInfo(parsedRewriteTarget.pathname, {
  1622. nextConfig,
  1623. parseData: true
  1624. });
  1625. let fsPathname = (0, _removeTrailingSlash).removeTrailingSlash(pathnameInfo.pathname);
  1626. return Promise.all([
  1627. options.router.pageLoader.getPageList(),
  1628. (0, _routeLoader).getClientBuildManifest(),
  1629. ]).then(([pages, { __rewrites: rewrites }])=>{
  1630. let as = (0, _addLocale).addLocale(pathnameInfo.pathname, pathnameInfo.locale);
  1631. if ((0, _isDynamic).isDynamicRoute(as) || !rewriteHeader && pages.includes((0, _normalizeLocalePath).normalizeLocalePath((0, _removeBasePath).removeBasePath(as), options.router.locales).pathname)) {
  1632. const parsedSource = (0, _getNextPathnameInfo).getNextPathnameInfo((0, _parseRelativeUrl).parseRelativeUrl(source).pathname, {
  1633. parseData: true
  1634. });
  1635. as = (0, _addBasePath).addBasePath(parsedSource.pathname);
  1636. parsedRewriteTarget.pathname = as;
  1637. }
  1638. if (false) {} else if (!pages.includes(fsPathname)) {
  1639. const resolvedPathname = resolveDynamicRoute(fsPathname, pages);
  1640. if (resolvedPathname !== fsPathname) {
  1641. fsPathname = resolvedPathname;
  1642. }
  1643. }
  1644. const resolvedHref = !pages.includes(fsPathname) ? resolveDynamicRoute((0, _normalizeLocalePath).normalizeLocalePath((0, _removeBasePath).removeBasePath(parsedRewriteTarget.pathname), options.router.locales).pathname, pages) : fsPathname;
  1645. if ((0, _isDynamic).isDynamicRoute(resolvedHref)) {
  1646. const matches = (0, _routeMatcher).getRouteMatcher((0, _routeRegex).getRouteRegex(resolvedHref))(as);
  1647. Object.assign(parsedRewriteTarget.query, matches || {});
  1648. }
  1649. return {
  1650. type: "rewrite",
  1651. parsedAs: parsedRewriteTarget,
  1652. resolvedHref
  1653. };
  1654. });
  1655. }
  1656. const src = (0, _parsePath).parsePath(source);
  1657. const pathname = (0, _formatNextPathnameInfo).formatNextPathnameInfo(_extends({}, (0, _getNextPathnameInfo).getNextPathnameInfo(src.pathname, {
  1658. nextConfig,
  1659. parseData: true
  1660. }), {
  1661. defaultLocale: options.router.defaultLocale,
  1662. buildId: ""
  1663. }));
  1664. return Promise.resolve({
  1665. type: "redirect-external",
  1666. destination: `${pathname}${src.query}${src.hash}`
  1667. });
  1668. }
  1669. const redirectTarget = response.headers.get("x-nextjs-redirect");
  1670. if (redirectTarget) {
  1671. if (redirectTarget.startsWith("/")) {
  1672. const src1 = (0, _parsePath).parsePath(redirectTarget);
  1673. const pathname1 = (0, _formatNextPathnameInfo).formatNextPathnameInfo(_extends({}, (0, _getNextPathnameInfo).getNextPathnameInfo(src1.pathname, {
  1674. nextConfig,
  1675. parseData: true
  1676. }), {
  1677. defaultLocale: options.router.defaultLocale,
  1678. buildId: ""
  1679. }));
  1680. return Promise.resolve({
  1681. type: "redirect-internal",
  1682. newAs: `${pathname1}${src1.query}${src1.hash}`,
  1683. newUrl: `${pathname1}${src1.query}${src1.hash}`
  1684. });
  1685. }
  1686. return Promise.resolve({
  1687. type: "redirect-external",
  1688. destination: redirectTarget
  1689. });
  1690. }
  1691. return Promise.resolve({
  1692. type: "next"
  1693. });
  1694. }
  1695. function withMiddlewareEffects(options) {
  1696. return matchesMiddleware(options).then((matches)=>{
  1697. if (matches && options.fetchData) {
  1698. return options.fetchData().then((data)=>getMiddlewareData(data.dataHref, data.response, options).then((effect)=>({
  1699. dataHref: data.dataHref,
  1700. cacheKey: data.cacheKey,
  1701. json: data.json,
  1702. response: data.response,
  1703. text: data.text,
  1704. effect
  1705. }))).catch((_err)=>{
  1706. /**
  1707. * TODO: Revisit this in the future.
  1708. * For now we will not consider middleware data errors to be fatal.
  1709. * maybe we should revisit in the future.
  1710. */ return null;
  1711. });
  1712. }
  1713. return null;
  1714. });
  1715. }
  1716. const manualScrollRestoration = (/* unused pure expression or super */ null && ( false && 0));
  1717. const SSG_DATA_NOT_FOUND = Symbol("SSG_DATA_NOT_FOUND");
  1718. function fetchRetry(url, attempts, options) {
  1719. return fetch(url, {
  1720. // Cookies are required to be present for Next.js' SSG "Preview Mode".
  1721. // Cookies may also be required for `getServerSideProps`.
  1722. //
  1723. // > `fetch` won’t send cookies, unless you set the credentials init
  1724. // > option.
  1725. // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
  1726. //
  1727. // > For maximum browser compatibility when it comes to sending &
  1728. // > receiving cookies, always supply the `credentials: 'same-origin'`
  1729. // > option instead of relying on the default.
  1730. // https://github.com/github/fetch#caveats
  1731. credentials: "same-origin",
  1732. method: options.method || "GET",
  1733. headers: Object.assign({}, options.headers, {
  1734. "x-nextjs-data": "1"
  1735. })
  1736. }).then((response)=>{
  1737. return !response.ok && attempts > 1 && response.status >= 500 ? fetchRetry(url, attempts - 1, options) : response;
  1738. });
  1739. }
  1740. const backgroundCache = {};
  1741. function handleSmoothScroll(fn) {
  1742. const htmlElement = document.documentElement;
  1743. const existing = htmlElement.style.scrollBehavior;
  1744. htmlElement.style.scrollBehavior = "auto";
  1745. fn();
  1746. htmlElement.style.scrollBehavior = existing;
  1747. }
  1748. function tryToParseAsJSON(text) {
  1749. try {
  1750. return JSON.parse(text);
  1751. } catch (error) {
  1752. return null;
  1753. }
  1754. }
  1755. function fetchNextData({ dataHref , inflightCache , isPrefetch , hasMiddleware , isServerRender , parseJSON , persistCache , isBackground , unstable_skipClientCache }) {
  1756. const { href: cacheKey } = new URL(dataHref, window.location.href);
  1757. var ref1;
  1758. const getData = (params)=>{
  1759. return fetchRetry(dataHref, isServerRender ? 3 : 1, {
  1760. headers: isPrefetch ? {
  1761. purpose: "prefetch"
  1762. } : {},
  1763. method: (ref1 = params == null ? void 0 : params.method) != null ? ref1 : "GET"
  1764. }).then((response)=>{
  1765. if (response.ok && (params == null ? void 0 : params.method) === "HEAD") {
  1766. return {
  1767. dataHref,
  1768. response,
  1769. text: "",
  1770. json: {},
  1771. cacheKey
  1772. };
  1773. }
  1774. return response.text().then((text)=>{
  1775. if (!response.ok) {
  1776. /**
  1777. * When the data response is a redirect because of a middleware
  1778. * we do not consider it an error. The headers must bring the
  1779. * mapped location.
  1780. * TODO: Change the status code in the handler.
  1781. */ if (hasMiddleware && [
  1782. 301,
  1783. 302,
  1784. 307,
  1785. 308
  1786. ].includes(response.status)) {
  1787. return {
  1788. dataHref,
  1789. response,
  1790. text,
  1791. json: {},
  1792. cacheKey
  1793. };
  1794. }
  1795. if (!hasMiddleware && response.status === 404) {
  1796. var ref;
  1797. if ((ref = tryToParseAsJSON(text)) == null ? void 0 : ref.notFound) {
  1798. return {
  1799. dataHref,
  1800. json: {
  1801. notFound: SSG_DATA_NOT_FOUND
  1802. },
  1803. response,
  1804. text,
  1805. cacheKey
  1806. };
  1807. }
  1808. }
  1809. const error = new Error(`Failed to load static props`);
  1810. /**
  1811. * We should only trigger a server-side transition if this was
  1812. * caused on a client-side transition. Otherwise, we'd get into
  1813. * an infinite loop.
  1814. */ if (!isServerRender) {
  1815. (0, _routeLoader).markAssetError(error);
  1816. }
  1817. throw error;
  1818. }
  1819. return {
  1820. dataHref,
  1821. json: parseJSON ? tryToParseAsJSON(text) : null,
  1822. response,
  1823. text,
  1824. cacheKey
  1825. };
  1826. });
  1827. }).then((data)=>{
  1828. if (!persistCache || "production" !== "production" || data.response.headers.get("x-middleware-cache") === "no-cache") {
  1829. delete inflightCache[cacheKey];
  1830. }
  1831. return data;
  1832. }).catch((err)=>{
  1833. delete inflightCache[cacheKey];
  1834. throw err;
  1835. });
  1836. };
  1837. // when skipping client cache we wait to update
  1838. // inflight cache until successful data response
  1839. // this allows racing click event with fetching newer data
  1840. // without blocking navigation when stale data is available
  1841. if (unstable_skipClientCache && persistCache) {
  1842. return getData({}).then((data)=>{
  1843. inflightCache[cacheKey] = Promise.resolve(data);
  1844. return data;
  1845. });
  1846. }
  1847. if (inflightCache[cacheKey] !== undefined) {
  1848. return inflightCache[cacheKey];
  1849. }
  1850. return inflightCache[cacheKey] = getData(isBackground ? {
  1851. method: "HEAD"
  1852. } : {});
  1853. }
  1854. function createKey() {
  1855. return Math.random().toString(36).slice(2, 10);
  1856. }
  1857. function handleHardNavigation({ url , router }) {
  1858. // ensure we don't trigger a hard navigation to the same
  1859. // URL as this can end up with an infinite refresh
  1860. if (url === (0, _addBasePath).addBasePath((0, _addLocale).addLocale(router.asPath, router.locale))) {
  1861. throw new Error(`Invariant: attempted to hard navigate to the same URL ${url} ${location.href}`);
  1862. }
  1863. window.location.href = url;
  1864. }
  1865. const getCancelledHandler = ({ route , router })=>{
  1866. let cancelled = false;
  1867. const cancel = router.clc = ()=>{
  1868. cancelled = true;
  1869. };
  1870. const handleCancelled = ()=>{
  1871. if (cancelled) {
  1872. const error = new Error(`Abort fetching component for route: "${route}"`);
  1873. error.cancelled = true;
  1874. throw error;
  1875. }
  1876. if (cancel === router.clc) {
  1877. router.clc = null;
  1878. }
  1879. };
  1880. return handleCancelled;
  1881. };
  1882. class Router {
  1883. reload() {
  1884. window.location.reload();
  1885. }
  1886. /**
  1887. * Go back in history
  1888. */ back() {
  1889. window.history.back();
  1890. }
  1891. /**
  1892. * Performs a `pushState` with arguments
  1893. * @param url of the route
  1894. * @param as masks `url` for the browser
  1895. * @param options object you can define `shallow` and other options
  1896. */ push(url, as, options = {}) {
  1897. if (false) {}
  1898. ({ url , as } = prepareUrlAs(this, url, as));
  1899. return this.change("pushState", url, as, options);
  1900. }
  1901. /**
  1902. * Performs a `replaceState` with arguments
  1903. * @param url of the route
  1904. * @param as masks `url` for the browser
  1905. * @param options object you can define `shallow` and other options
  1906. */ replace(url, as, options = {}) {
  1907. ({ url , as } = prepareUrlAs(this, url, as));
  1908. return this.change("replaceState", url, as, options);
  1909. }
  1910. change(method, url, as, options, forcedScroll) {
  1911. var _this = this;
  1912. return _async_to_generator(function*() {
  1913. if (!isLocalURL(url)) {
  1914. handleHardNavigation({
  1915. url,
  1916. router: _this
  1917. });
  1918. return false;
  1919. }
  1920. // WARNING: `_h` is an internal option for handing Next.js client-side
  1921. // hydration. Your app should _never_ use this property. It may change at
  1922. // any time without notice.
  1923. const isQueryUpdating = options._h;
  1924. const shouldResolveHref = isQueryUpdating || options._shouldResolveHref || (0, _parsePath).parsePath(url).pathname === (0, _parsePath).parsePath(as).pathname;
  1925. const nextState = _extends({}, _this.state);
  1926. // for static pages with query params in the URL we delay
  1927. // marking the router ready until after the query is updated
  1928. // or a navigation has occurred
  1929. const readyStateChange = _this.isReady !== true;
  1930. _this.isReady = true;
  1931. const isSsr = _this.isSsr;
  1932. if (!isQueryUpdating) {
  1933. _this.isSsr = false;
  1934. }
  1935. // if a route transition is already in progress before
  1936. // the query updating is triggered ignore query updating
  1937. if (isQueryUpdating && _this.clc) {
  1938. return false;
  1939. }
  1940. const prevLocale = nextState.locale;
  1941. if (true) {
  1942. nextState.locale = options.locale === false ? _this.defaultLocale : options.locale || nextState.locale;
  1943. if (typeof options.locale === "undefined") {
  1944. options.locale = nextState.locale;
  1945. }
  1946. const parsedAs = (0, _parseRelativeUrl).parseRelativeUrl((0, _hasBasePath).hasBasePath(as) ? (0, _removeBasePath).removeBasePath(as) : as);
  1947. const localePathResult = (0, _normalizeLocalePath).normalizeLocalePath(parsedAs.pathname, _this.locales);
  1948. if (localePathResult.detectedLocale) {
  1949. nextState.locale = localePathResult.detectedLocale;
  1950. parsedAs.pathname = (0, _addBasePath).addBasePath(parsedAs.pathname);
  1951. as = (0, _formatUrl).formatWithValidation(parsedAs);
  1952. url = (0, _addBasePath).addBasePath((0, _normalizeLocalePath).normalizeLocalePath((0, _hasBasePath).hasBasePath(url) ? (0, _removeBasePath).removeBasePath(url) : url, _this.locales).pathname);
  1953. }
  1954. let didNavigate = false;
  1955. // we need to wrap this in the env check again since regenerator runtime
  1956. // moves this on its own due to the return
  1957. if (true) {
  1958. var ref;
  1959. // if the locale isn't configured hard navigate to show 404 page
  1960. if (!((ref = _this.locales) == null ? void 0 : ref.includes(nextState.locale))) {
  1961. parsedAs.pathname = (0, _addLocale).addLocale(parsedAs.pathname, nextState.locale);
  1962. handleHardNavigation({
  1963. url: (0, _formatUrl).formatWithValidation(parsedAs),
  1964. router: _this
  1965. });
  1966. // this was previously a return but was removed in favor
  1967. // of better dead code elimination with regenerator runtime
  1968. didNavigate = true;
  1969. }
  1970. }
  1971. const detectedDomain = (0, _detectDomainLocale).detectDomainLocale(_this.domainLocales, undefined, nextState.locale);
  1972. // we need to wrap this in the env check again since regenerator runtime
  1973. // moves this on its own due to the return
  1974. if (true) {
  1975. // if we are navigating to a domain locale ensure we redirect to the
  1976. // correct domain
  1977. if (!didNavigate && detectedDomain && _this.isLocaleDomain && self.location.hostname !== detectedDomain.domain) {
  1978. const asNoBasePath = (0, _removeBasePath).removeBasePath(as);
  1979. handleHardNavigation({
  1980. url: `http${detectedDomain.http ? "" : "s"}://${detectedDomain.domain}${(0, _addBasePath).addBasePath(`${nextState.locale === detectedDomain.defaultLocale ? "" : `/${nextState.locale}`}${asNoBasePath === "/" ? "" : asNoBasePath}` || "/")}`,
  1981. router: _this
  1982. });
  1983. // this was previously a return but was removed in favor
  1984. // of better dead code elimination with regenerator runtime
  1985. didNavigate = true;
  1986. }
  1987. }
  1988. if (didNavigate) {
  1989. return new Promise(()=>{});
  1990. }
  1991. }
  1992. // marking route changes as a navigation start entry
  1993. if (_utils.ST) {
  1994. performance.mark("routeChange");
  1995. }
  1996. const { shallow =false , scroll =true } = options;
  1997. const routeProps = {
  1998. shallow
  1999. };
  2000. if (_this._inFlightRoute && _this.clc) {
  2001. if (!isSsr) {
  2002. Router.events.emit("routeChangeError", buildCancellationError(), _this._inFlightRoute, routeProps);
  2003. }
  2004. _this.clc();
  2005. _this.clc = null;
  2006. }
  2007. as = (0, _addBasePath).addBasePath((0, _addLocale).addLocale((0, _hasBasePath).hasBasePath(as) ? (0, _removeBasePath).removeBasePath(as) : as, options.locale, _this.defaultLocale));
  2008. const cleanedAs = (0, _removeLocale).removeLocale((0, _hasBasePath).hasBasePath(as) ? (0, _removeBasePath).removeBasePath(as) : as, nextState.locale);
  2009. _this._inFlightRoute = as;
  2010. const localeChange = prevLocale !== nextState.locale;
  2011. // If the url change is only related to a hash change
  2012. // We should not proceed. We should only change the state.
  2013. if (!isQueryUpdating && _this.onlyAHashChange(cleanedAs) && !localeChange) {
  2014. nextState.asPath = cleanedAs;
  2015. Router.events.emit("hashChangeStart", as, routeProps);
  2016. // TODO: do we need the resolved href when only a hash change?
  2017. _this.changeState(method, url, as, _extends({}, options, {
  2018. scroll: false
  2019. }));
  2020. if (scroll) {
  2021. _this.scrollToHash(cleanedAs);
  2022. }
  2023. try {
  2024. yield _this.set(nextState, _this.components[nextState.route], null);
  2025. } catch (err) {
  2026. if ((0, _isError).default(err) && err.cancelled) {
  2027. Router.events.emit("routeChangeError", err, cleanedAs, routeProps);
  2028. }
  2029. throw err;
  2030. }
  2031. Router.events.emit("hashChangeComplete", as, routeProps);
  2032. return true;
  2033. }
  2034. let parsed = (0, _parseRelativeUrl).parseRelativeUrl(url);
  2035. let { pathname , query } = parsed;
  2036. // The build manifest needs to be loaded before auto-static dynamic pages
  2037. // get their query parameters to allow ensuring they can be parsed properly
  2038. // when rewritten to
  2039. let pages, rewrites;
  2040. try {
  2041. [pages, { __rewrites: rewrites }] = yield Promise.all([
  2042. _this.pageLoader.getPageList(),
  2043. (0, _routeLoader).getClientBuildManifest(),
  2044. _this.pageLoader.getMiddleware(),
  2045. ]);
  2046. } catch (err1) {
  2047. // If we fail to resolve the page list or client-build manifest, we must
  2048. // do a server-side transition:
  2049. handleHardNavigation({
  2050. url: as,
  2051. router: _this
  2052. });
  2053. return false;
  2054. }
  2055. // If asked to change the current URL we should reload the current page
  2056. // (not location.reload() but reload getInitialProps and other Next.js stuffs)
  2057. // We also need to set the method = replaceState always
  2058. // as this should not go into the history (That's how browsers work)
  2059. // We should compare the new asPath to the current asPath, not the url
  2060. if (!_this.urlIsNew(cleanedAs) && !localeChange) {
  2061. method = "replaceState";
  2062. }
  2063. // we need to resolve the as value using rewrites for dynamic SSG
  2064. // pages to allow building the data URL correctly
  2065. let resolvedAs = as;
  2066. // url and as should always be prefixed with basePath by this
  2067. // point by either next/link or router.push/replace so strip the
  2068. // basePath from the pathname to match the pages dir 1-to-1
  2069. pathname = pathname ? (0, _removeTrailingSlash).removeTrailingSlash((0, _removeBasePath).removeBasePath(pathname)) : pathname;
  2070. // we don't attempt resolve asPath when we need to execute
  2071. // middleware as the resolving will occur server-side
  2072. const isMiddlewareMatch = yield matchesMiddleware({
  2073. asPath: as,
  2074. locale: nextState.locale,
  2075. router: _this
  2076. });
  2077. if (options.shallow && isMiddlewareMatch) {
  2078. pathname = _this.pathname;
  2079. }
  2080. if (shouldResolveHref && pathname !== "/_error") {
  2081. options._shouldResolveHref = true;
  2082. if (false) {} else {
  2083. parsed.pathname = resolveDynamicRoute(pathname, pages);
  2084. if (parsed.pathname !== pathname) {
  2085. pathname = parsed.pathname;
  2086. parsed.pathname = (0, _addBasePath).addBasePath(pathname);
  2087. if (!isMiddlewareMatch) {
  2088. url = (0, _formatUrl).formatWithValidation(parsed);
  2089. }
  2090. }
  2091. }
  2092. }
  2093. if (!isLocalURL(as)) {
  2094. if (false) {}
  2095. handleHardNavigation({
  2096. url: as,
  2097. router: _this
  2098. });
  2099. return false;
  2100. }
  2101. resolvedAs = (0, _removeLocale).removeLocale((0, _removeBasePath).removeBasePath(resolvedAs), nextState.locale);
  2102. let route = (0, _removeTrailingSlash).removeTrailingSlash(pathname);
  2103. let routeMatch = false;
  2104. if ((0, _isDynamic).isDynamicRoute(route)) {
  2105. const parsedAs1 = (0, _parseRelativeUrl).parseRelativeUrl(resolvedAs);
  2106. const asPathname = parsedAs1.pathname;
  2107. const routeRegex = (0, _routeRegex).getRouteRegex(route);
  2108. routeMatch = (0, _routeMatcher).getRouteMatcher(routeRegex)(asPathname);
  2109. const shouldInterpolate = route === asPathname;
  2110. const interpolatedAs = shouldInterpolate ? interpolateAs(route, asPathname, query) : {};
  2111. if (!routeMatch || shouldInterpolate && !interpolatedAs.result) {
  2112. const missingParams = Object.keys(routeRegex.groups).filter((param)=>!query[param]);
  2113. if (missingParams.length > 0 && !isMiddlewareMatch) {
  2114. if (false) {}
  2115. throw new Error((shouldInterpolate ? `The provided \`href\` (${url}) value is missing query values (${missingParams.join(", ")}) to be interpolated properly. ` : `The provided \`as\` value (${asPathname}) is incompatible with the \`href\` value (${route}). `) + `Read more: https://nextjs.org/docs/messages/${shouldInterpolate ? "href-interpolation-failed" : "incompatible-href-as"}`);
  2116. }
  2117. } else if (shouldInterpolate) {
  2118. as = (0, _formatUrl).formatWithValidation(Object.assign({}, parsedAs1, {
  2119. pathname: interpolatedAs.result,
  2120. query: omit(query, interpolatedAs.params)
  2121. }));
  2122. } else {
  2123. // Merge params into `query`, overwriting any specified in search
  2124. Object.assign(query, routeMatch);
  2125. }
  2126. }
  2127. if (!isQueryUpdating) {
  2128. Router.events.emit("routeChangeStart", as, routeProps);
  2129. }
  2130. try {
  2131. var ref2, ref3;
  2132. let routeInfo = yield _this.getRouteInfo({
  2133. route,
  2134. pathname,
  2135. query,
  2136. as,
  2137. resolvedAs,
  2138. routeProps,
  2139. locale: nextState.locale,
  2140. isPreview: nextState.isPreview,
  2141. hasMiddleware: isMiddlewareMatch
  2142. });
  2143. if ("route" in routeInfo && isMiddlewareMatch) {
  2144. pathname = routeInfo.route || route;
  2145. route = pathname;
  2146. if (!routeProps.shallow) {
  2147. query = Object.assign({}, routeInfo.query || {}, query);
  2148. }
  2149. const cleanedParsedPathname = (0, _hasBasePath).hasBasePath(parsed.pathname) ? (0, _removeBasePath).removeBasePath(parsed.pathname) : parsed.pathname;
  2150. if (routeMatch && pathname !== cleanedParsedPathname) {
  2151. Object.keys(routeMatch).forEach((key)=>{
  2152. if (routeMatch && query[key] === routeMatch[key]) {
  2153. delete query[key];
  2154. }
  2155. });
  2156. }
  2157. if ((0, _isDynamic).isDynamicRoute(pathname)) {
  2158. const prefixedAs = !routeProps.shallow && routeInfo.resolvedAs ? routeInfo.resolvedAs : (0, _addBasePath).addBasePath((0, _addLocale).addLocale(new URL(as, location.href).pathname, nextState.locale), true);
  2159. let rewriteAs = prefixedAs;
  2160. if ((0, _hasBasePath).hasBasePath(rewriteAs)) {
  2161. rewriteAs = (0, _removeBasePath).removeBasePath(rewriteAs);
  2162. }
  2163. if (true) {
  2164. const localeResult = (0, _normalizeLocalePath).normalizeLocalePath(rewriteAs, _this.locales);
  2165. nextState.locale = localeResult.detectedLocale || nextState.locale;
  2166. rewriteAs = localeResult.pathname;
  2167. }
  2168. const routeRegex1 = (0, _routeRegex).getRouteRegex(pathname);
  2169. const curRouteMatch = (0, _routeMatcher).getRouteMatcher(routeRegex1)(rewriteAs);
  2170. if (curRouteMatch) {
  2171. Object.assign(query, curRouteMatch);
  2172. }
  2173. }
  2174. }
  2175. // If the routeInfo brings a redirect we simply apply it.
  2176. if ("type" in routeInfo) {
  2177. if (routeInfo.type === "redirect-internal") {
  2178. return _this.change(method, routeInfo.newUrl, routeInfo.newAs, options);
  2179. } else {
  2180. handleHardNavigation({
  2181. url: routeInfo.destination,
  2182. router: _this
  2183. });
  2184. return new Promise(()=>{});
  2185. }
  2186. }
  2187. let { error , props , __N_SSG , __N_SSP } = routeInfo;
  2188. const component = routeInfo.Component;
  2189. if (component && component.unstable_scriptLoader) {
  2190. const scripts = [].concat(component.unstable_scriptLoader());
  2191. scripts.forEach((script)=>{
  2192. (0, _script).handleClientScriptLoad(script.props);
  2193. });
  2194. }
  2195. // handle redirect on client-transition
  2196. if ((__N_SSG || __N_SSP) && props) {
  2197. if (props.pageProps && props.pageProps.__N_REDIRECT) {
  2198. // Use the destination from redirect without adding locale
  2199. options.locale = false;
  2200. const destination = props.pageProps.__N_REDIRECT;
  2201. // check if destination is internal (resolves to a page) and attempt
  2202. // client-navigation if it is falling back to hard navigation if
  2203. // it's not
  2204. if (destination.startsWith("/") && props.pageProps.__N_REDIRECT_BASE_PATH !== false) {
  2205. const parsedHref = (0, _parseRelativeUrl).parseRelativeUrl(destination);
  2206. parsedHref.pathname = resolveDynamicRoute(parsedHref.pathname, pages);
  2207. const { url: newUrl , as: newAs } = prepareUrlAs(_this, destination, destination);
  2208. return _this.change(method, newUrl, newAs, options);
  2209. }
  2210. handleHardNavigation({
  2211. url: destination,
  2212. router: _this
  2213. });
  2214. return new Promise(()=>{});
  2215. }
  2216. nextState.isPreview = !!props.__N_PREVIEW;
  2217. // handle SSG data 404
  2218. if (props.notFound === SSG_DATA_NOT_FOUND) {
  2219. let notFoundRoute;
  2220. try {
  2221. yield _this.fetchComponent("/404");
  2222. notFoundRoute = "/404";
  2223. } catch (_) {
  2224. notFoundRoute = "/_error";
  2225. }
  2226. routeInfo = yield _this.getRouteInfo({
  2227. route: notFoundRoute,
  2228. pathname: notFoundRoute,
  2229. query,
  2230. as,
  2231. resolvedAs,
  2232. routeProps: {
  2233. shallow: false
  2234. },
  2235. locale: nextState.locale,
  2236. isPreview: nextState.isPreview
  2237. });
  2238. if ("type" in routeInfo) {
  2239. throw new Error(`Unexpected middleware effect on /404`);
  2240. }
  2241. }
  2242. }
  2243. Router.events.emit("beforeHistoryChange", as, routeProps);
  2244. _this.changeState(method, url, as, options);
  2245. if (isQueryUpdating && pathname === "/_error" && ((ref2 = self.__NEXT_DATA__.props) == null ? void 0 : (ref3 = ref2.pageProps) == null ? void 0 : ref3.statusCode) === 500 && (props == null ? void 0 : props.pageProps)) {
  2246. // ensure statusCode is still correct for static 500 page
  2247. // when updating query information
  2248. props.pageProps.statusCode = 500;
  2249. }
  2250. var _route;
  2251. // shallow routing is only allowed for same page URL changes.
  2252. const isValidShallowRoute = options.shallow && nextState.route === ((_route = routeInfo.route) != null ? _route : route);
  2253. var _scroll;
  2254. const shouldScroll = (_scroll = options.scroll) != null ? _scroll : !options._h && !isValidShallowRoute;
  2255. const resetScroll = shouldScroll ? {
  2256. x: 0,
  2257. y: 0
  2258. } : null;
  2259. // the new state that the router gonna set
  2260. const upcomingRouterState = _extends({}, nextState, {
  2261. route,
  2262. pathname,
  2263. query,
  2264. asPath: cleanedAs,
  2265. isFallback: false
  2266. });
  2267. const upcomingScrollState = forcedScroll != null ? forcedScroll : resetScroll;
  2268. // for query updates we can skip it if the state is unchanged and we don't
  2269. // need to scroll
  2270. // https://github.com/vercel/next.js/issues/37139
  2271. const canSkipUpdating = options._h && !upcomingScrollState && !readyStateChange && !localeChange && (0, _compareStates).compareRouterStates(upcomingRouterState, _this.state);
  2272. if (!canSkipUpdating) {
  2273. yield _this.set(upcomingRouterState, routeInfo, upcomingScrollState).catch((e)=>{
  2274. if (e.cancelled) error = error || e;
  2275. else throw e;
  2276. });
  2277. if (error) {
  2278. if (!isQueryUpdating) {
  2279. Router.events.emit("routeChangeError", error, cleanedAs, routeProps);
  2280. }
  2281. throw error;
  2282. }
  2283. if (true) {
  2284. if (nextState.locale) {
  2285. document.documentElement.lang = nextState.locale;
  2286. }
  2287. }
  2288. if (!isQueryUpdating) {
  2289. Router.events.emit("routeChangeComplete", as, routeProps);
  2290. }
  2291. // A hash mark # is the optional last part of a URL
  2292. const hashRegex = /#.+$/;
  2293. if (shouldScroll && hashRegex.test(as)) {
  2294. _this.scrollToHash(as);
  2295. }
  2296. }
  2297. return true;
  2298. } catch (err11) {
  2299. if ((0, _isError).default(err11) && err11.cancelled) {
  2300. return false;
  2301. }
  2302. throw err11;
  2303. }
  2304. })();
  2305. }
  2306. changeState(method, url, as, options = {}) {
  2307. if (false) {}
  2308. if (method !== "pushState" || (0, _utils).getURL() !== as) {
  2309. this._shallow = options.shallow;
  2310. window.history[method]({
  2311. url,
  2312. as,
  2313. options,
  2314. __N: true,
  2315. key: this._key = method !== "pushState" ? this._key : createKey()
  2316. }, // Passing the empty string here should be safe against future changes to the method.
  2317. // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
  2318. "", as);
  2319. }
  2320. }
  2321. handleRouteInfoError(err, pathname, query, as, routeProps, loadErrorFail) {
  2322. var _this = this;
  2323. return _async_to_generator(function*() {
  2324. console.error(err);
  2325. if (err.cancelled) {
  2326. // bubble up cancellation errors
  2327. throw err;
  2328. }
  2329. if ((0, _routeLoader).isAssetError(err) || loadErrorFail) {
  2330. Router.events.emit("routeChangeError", err, as, routeProps);
  2331. // If we can't load the page it could be one of following reasons
  2332. // 1. Page doesn't exists
  2333. // 2. Page does exist in a different zone
  2334. // 3. Internal error while loading the page
  2335. // So, doing a hard reload is the proper way to deal with this.
  2336. handleHardNavigation({
  2337. url: as,
  2338. router: _this
  2339. });
  2340. // Changing the URL doesn't block executing the current code path.
  2341. // So let's throw a cancellation error stop the routing logic.
  2342. throw buildCancellationError();
  2343. }
  2344. try {
  2345. let props;
  2346. const { page: Component , styleSheets } = yield _this.fetchComponent("/_error");
  2347. const routeInfo = {
  2348. props,
  2349. Component,
  2350. styleSheets,
  2351. err,
  2352. error: err
  2353. };
  2354. if (!routeInfo.props) {
  2355. try {
  2356. routeInfo.props = yield _this.getInitialProps(Component, {
  2357. err,
  2358. pathname,
  2359. query
  2360. });
  2361. } catch (gipErr) {
  2362. console.error("Error in error page `getInitialProps`: ", gipErr);
  2363. routeInfo.props = {};
  2364. }
  2365. }
  2366. return routeInfo;
  2367. } catch (routeInfoErr) {
  2368. return _this.handleRouteInfoError((0, _isError).default(routeInfoErr) ? routeInfoErr : new Error(routeInfoErr + ""), pathname, query, as, routeProps, true);
  2369. }
  2370. })();
  2371. }
  2372. getRouteInfo({ route: requestedRoute , pathname , query , as , resolvedAs , routeProps , locale , hasMiddleware , isPreview , unstable_skipClientCache }) {
  2373. var _this = this;
  2374. return _async_to_generator(function*() {
  2375. /**
  2376. * This `route` binding can change if there's a rewrite
  2377. * so we keep a reference to the original requested route
  2378. * so we can store the cache for it and avoid re-requesting every time
  2379. * for shallow routing purposes.
  2380. */ let route = requestedRoute;
  2381. try {
  2382. var ref, ref4, ref5;
  2383. const handleCancelled = getCancelledHandler({
  2384. route,
  2385. router: _this
  2386. });
  2387. let existingInfo = _this.components[route];
  2388. if (routeProps.shallow && existingInfo && _this.route === route) {
  2389. return existingInfo;
  2390. }
  2391. if (hasMiddleware) {
  2392. existingInfo = undefined;
  2393. }
  2394. let cachedRouteInfo = existingInfo && !("initial" in existingInfo) && "production" !== "development" ? existingInfo : undefined;
  2395. const fetchNextDataParams = {
  2396. dataHref: _this.pageLoader.getDataHref({
  2397. href: (0, _formatUrl).formatWithValidation({
  2398. pathname,
  2399. query
  2400. }),
  2401. skipInterpolation: true,
  2402. asPath: resolvedAs,
  2403. locale
  2404. }),
  2405. hasMiddleware: true,
  2406. isServerRender: _this.isSsr,
  2407. parseJSON: true,
  2408. inflightCache: _this.sdc,
  2409. persistCache: !isPreview,
  2410. isPrefetch: false,
  2411. unstable_skipClientCache
  2412. };
  2413. const data = yield withMiddlewareEffects({
  2414. fetchData: ()=>fetchNextData(fetchNextDataParams),
  2415. asPath: resolvedAs,
  2416. locale: locale,
  2417. router: _this
  2418. });
  2419. handleCancelled();
  2420. if ((data == null ? void 0 : (ref = data.effect) == null ? void 0 : ref.type) === "redirect-internal" || (data == null ? void 0 : (ref4 = data.effect) == null ? void 0 : ref4.type) === "redirect-external") {
  2421. return data.effect;
  2422. }
  2423. if ((data == null ? void 0 : (ref5 = data.effect) == null ? void 0 : ref5.type) === "rewrite") {
  2424. route = (0, _removeTrailingSlash).removeTrailingSlash(data.effect.resolvedHref);
  2425. pathname = data.effect.resolvedHref;
  2426. query = _extends({}, query, data.effect.parsedAs.query);
  2427. resolvedAs = (0, _removeBasePath).removeBasePath((0, _normalizeLocalePath).normalizeLocalePath(data.effect.parsedAs.pathname, _this.locales).pathname);
  2428. // Check again the cache with the new destination.
  2429. existingInfo = _this.components[route];
  2430. if (routeProps.shallow && existingInfo && _this.route === route && !hasMiddleware) {
  2431. // If we have a match with the current route due to rewrite,
  2432. // we can copy the existing information to the rewritten one.
  2433. // Then, we return the information along with the matched route.
  2434. return _extends({}, existingInfo, {
  2435. route
  2436. });
  2437. }
  2438. }
  2439. if (route === "/api" || route.startsWith("/api/")) {
  2440. handleHardNavigation({
  2441. url: as,
  2442. router: _this
  2443. });
  2444. return new Promise(()=>{});
  2445. }
  2446. const routeInfo = cachedRouteInfo || (yield _this.fetchComponent(route).then((res)=>({
  2447. Component: res.page,
  2448. styleSheets: res.styleSheets,
  2449. __N_SSG: res.mod.__N_SSG,
  2450. __N_SSP: res.mod.__N_SSP
  2451. })));
  2452. if (false) {}
  2453. const shouldFetchData = routeInfo.__N_SSG || routeInfo.__N_SSP;
  2454. const { props , cacheKey } = yield _this._getData(_async_to_generator(function*() {
  2455. if (shouldFetchData) {
  2456. const { json , cacheKey: _cacheKey } = (data == null ? void 0 : data.json) ? data : yield fetchNextData({
  2457. dataHref: _this.pageLoader.getDataHref({
  2458. href: (0, _formatUrl).formatWithValidation({
  2459. pathname,
  2460. query
  2461. }),
  2462. asPath: resolvedAs,
  2463. locale
  2464. }),
  2465. isServerRender: _this.isSsr,
  2466. parseJSON: true,
  2467. inflightCache: _this.sdc,
  2468. persistCache: !isPreview,
  2469. isPrefetch: false,
  2470. unstable_skipClientCache
  2471. });
  2472. return {
  2473. cacheKey: _cacheKey,
  2474. props: json || {}
  2475. };
  2476. }
  2477. return {
  2478. headers: {},
  2479. cacheKey: "",
  2480. props: yield _this.getInitialProps(routeInfo.Component, {
  2481. pathname,
  2482. query,
  2483. asPath: as,
  2484. locale,
  2485. locales: _this.locales,
  2486. defaultLocale: _this.defaultLocale
  2487. })
  2488. };
  2489. }));
  2490. // Only bust the data cache for SSP routes although
  2491. // middleware can skip cache per request with
  2492. // x-middleware-cache: no-cache as well
  2493. if (routeInfo.__N_SSP && fetchNextDataParams.dataHref) {
  2494. delete _this.sdc[cacheKey];
  2495. }
  2496. // we kick off a HEAD request in the background
  2497. // when a non-prefetch request is made to signal revalidation
  2498. if (!_this.isPreview && routeInfo.__N_SSG && "production" !== "development") {
  2499. fetchNextData(Object.assign({}, fetchNextDataParams, {
  2500. isBackground: true,
  2501. persistCache: false,
  2502. inflightCache: backgroundCache
  2503. })).catch(()=>{});
  2504. }
  2505. props.pageProps = Object.assign({}, props.pageProps);
  2506. routeInfo.props = props;
  2507. routeInfo.route = route;
  2508. routeInfo.query = query;
  2509. routeInfo.resolvedAs = resolvedAs;
  2510. _this.components[route] = routeInfo;
  2511. return routeInfo;
  2512. } catch (err) {
  2513. return _this.handleRouteInfoError((0, _isError).getProperError(err), pathname, query, as, routeProps);
  2514. }
  2515. })();
  2516. }
  2517. set(state, data, resetScroll) {
  2518. this.state = state;
  2519. return this.sub(data, this.components["/_app"].Component, resetScroll);
  2520. }
  2521. /**
  2522. * Callback to execute before replacing router state
  2523. * @param cb callback to be executed
  2524. */ beforePopState(cb) {
  2525. this._bps = cb;
  2526. }
  2527. onlyAHashChange(as) {
  2528. if (!this.asPath) return false;
  2529. const [oldUrlNoHash, oldHash] = this.asPath.split("#");
  2530. const [newUrlNoHash, newHash] = as.split("#");
  2531. // Makes sure we scroll to the provided hash if the url/hash are the same
  2532. if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {
  2533. return true;
  2534. }
  2535. // If the urls are change, there's more than a hash change
  2536. if (oldUrlNoHash !== newUrlNoHash) {
  2537. return false;
  2538. }
  2539. // If the hash has changed, then it's a hash only change.
  2540. // This check is necessary to handle both the enter and
  2541. // leave hash === '' cases. The identity case falls through
  2542. // and is treated as a next reload.
  2543. return oldHash !== newHash;
  2544. }
  2545. scrollToHash(as) {
  2546. const [, hash = ""] = as.split("#");
  2547. // Scroll to top if the hash is just `#` with no value or `#top`
  2548. // To mirror browsers
  2549. if (hash === "" || hash === "top") {
  2550. handleSmoothScroll(()=>window.scrollTo(0, 0));
  2551. return;
  2552. }
  2553. // Decode hash to make non-latin anchor works.
  2554. const rawHash = decodeURIComponent(hash);
  2555. // First we check if the element by id is found
  2556. const idEl = document.getElementById(rawHash);
  2557. if (idEl) {
  2558. handleSmoothScroll(()=>idEl.scrollIntoView());
  2559. return;
  2560. }
  2561. // If there's no element with the id, we check the `name` property
  2562. // To mirror browsers
  2563. const nameEl = document.getElementsByName(rawHash)[0];
  2564. if (nameEl) {
  2565. handleSmoothScroll(()=>nameEl.scrollIntoView());
  2566. }
  2567. }
  2568. urlIsNew(asPath) {
  2569. return this.asPath !== asPath;
  2570. }
  2571. /**
  2572. * Prefetch page code, you may wait for the data during page rendering.
  2573. * This feature only works in production!
  2574. * @param url the href of prefetched page
  2575. * @param asPath the as path of the prefetched page
  2576. */ prefetch(url, asPath = url, options = {}) {
  2577. var _this = this;
  2578. return _async_to_generator(function*() {
  2579. if (false) {}
  2580. let parsed = (0, _parseRelativeUrl).parseRelativeUrl(url);
  2581. let { pathname , query } = parsed;
  2582. if (true) {
  2583. if (options.locale === false) {
  2584. pathname = (0, _normalizeLocalePath).normalizeLocalePath(pathname, _this.locales).pathname;
  2585. parsed.pathname = pathname;
  2586. url = (0, _formatUrl).formatWithValidation(parsed);
  2587. let parsedAs = (0, _parseRelativeUrl).parseRelativeUrl(asPath);
  2588. const localePathResult = (0, _normalizeLocalePath).normalizeLocalePath(parsedAs.pathname, _this.locales);
  2589. parsedAs.pathname = localePathResult.pathname;
  2590. options.locale = localePathResult.detectedLocale || _this.defaultLocale;
  2591. asPath = (0, _formatUrl).formatWithValidation(parsedAs);
  2592. }
  2593. }
  2594. const pages = yield _this.pageLoader.getPageList();
  2595. let resolvedAs = asPath;
  2596. const locale = typeof options.locale !== "undefined" ? options.locale || undefined : _this.locale;
  2597. if (false) {}
  2598. parsed.pathname = resolveDynamicRoute(parsed.pathname, pages);
  2599. if ((0, _isDynamic).isDynamicRoute(parsed.pathname)) {
  2600. pathname = parsed.pathname;
  2601. parsed.pathname = pathname;
  2602. Object.assign(query, (0, _routeMatcher).getRouteMatcher((0, _routeRegex).getRouteRegex(parsed.pathname))((0, _parsePath).parsePath(asPath).pathname) || {});
  2603. url = (0, _formatUrl).formatWithValidation(parsed);
  2604. }
  2605. // Prefetch is not supported in development mode because it would trigger on-demand-entries
  2606. if (false) {}
  2607. const route = (0, _removeTrailingSlash).removeTrailingSlash(pathname);
  2608. yield Promise.all([
  2609. _this.pageLoader._isSsg(route).then((isSsg)=>{
  2610. return isSsg ? fetchNextData({
  2611. dataHref: _this.pageLoader.getDataHref({
  2612. href: url,
  2613. asPath: resolvedAs,
  2614. locale: locale
  2615. }),
  2616. isServerRender: false,
  2617. parseJSON: true,
  2618. inflightCache: _this.sdc,
  2619. persistCache: !_this.isPreview,
  2620. isPrefetch: true,
  2621. unstable_skipClientCache: options.unstable_skipClientCache || options.priority && !!true
  2622. }).then(()=>false) : false;
  2623. }),
  2624. _this.pageLoader[options.priority ? "loadPage" : "prefetch"](route),
  2625. ]);
  2626. })();
  2627. }
  2628. fetchComponent(route) {
  2629. var _this = this;
  2630. return _async_to_generator(function*() {
  2631. const handleCancelled = getCancelledHandler({
  2632. route,
  2633. router: _this
  2634. });
  2635. try {
  2636. const componentResult = yield _this.pageLoader.loadPage(route);
  2637. handleCancelled();
  2638. return componentResult;
  2639. } catch (err) {
  2640. handleCancelled();
  2641. throw err;
  2642. }
  2643. })();
  2644. }
  2645. _getData(fn) {
  2646. let cancelled = false;
  2647. const cancel = ()=>{
  2648. cancelled = true;
  2649. };
  2650. this.clc = cancel;
  2651. return fn().then((data)=>{
  2652. if (cancel === this.clc) {
  2653. this.clc = null;
  2654. }
  2655. if (cancelled) {
  2656. const err = new Error("Loading initial props cancelled");
  2657. err.cancelled = true;
  2658. throw err;
  2659. }
  2660. return data;
  2661. });
  2662. }
  2663. _getFlightData(dataHref) {
  2664. // Do not cache RSC flight response since it's not a static resource
  2665. return fetchNextData({
  2666. dataHref,
  2667. isServerRender: true,
  2668. parseJSON: false,
  2669. inflightCache: this.sdc,
  2670. persistCache: false,
  2671. isPrefetch: false
  2672. }).then(({ text })=>({
  2673. data: text
  2674. }));
  2675. }
  2676. getInitialProps(Component, ctx) {
  2677. const { Component: App } = this.components["/_app"];
  2678. const AppTree = this._wrapApp(App);
  2679. ctx.AppTree = AppTree;
  2680. return (0, _utils).loadGetInitialProps(App, {
  2681. AppTree,
  2682. Component,
  2683. router: this,
  2684. ctx
  2685. });
  2686. }
  2687. get route() {
  2688. return this.state.route;
  2689. }
  2690. get pathname() {
  2691. return this.state.pathname;
  2692. }
  2693. get query() {
  2694. return this.state.query;
  2695. }
  2696. get asPath() {
  2697. return this.state.asPath;
  2698. }
  2699. get locale() {
  2700. return this.state.locale;
  2701. }
  2702. get isFallback() {
  2703. return this.state.isFallback;
  2704. }
  2705. get isPreview() {
  2706. return this.state.isPreview;
  2707. }
  2708. constructor(pathname1, query1, as1, { initialProps , pageLoader , App , wrapApp , Component , err , subscription , isFallback , locale , locales , defaultLocale , domainLocales , isPreview }){
  2709. // Server Data Cache
  2710. this.sdc = {};
  2711. this.isFirstPopStateEvent = true;
  2712. this._key = createKey();
  2713. this.onPopState = (e)=>{
  2714. const { isFirstPopStateEvent } = this;
  2715. this.isFirstPopStateEvent = false;
  2716. const state = e.state;
  2717. if (!state) {
  2718. // We get state as undefined for two reasons.
  2719. // 1. With older safari (< 8) and older chrome (< 34)
  2720. // 2. When the URL changed with #
  2721. //
  2722. // In the both cases, we don't need to proceed and change the route.
  2723. // (as it's already changed)
  2724. // But we can simply replace the state with the new changes.
  2725. // Actually, for (1) we don't need to nothing. But it's hard to detect that event.
  2726. // So, doing the following for (1) does no harm.
  2727. const { pathname , query } = this;
  2728. this.changeState("replaceState", (0, _formatUrl).formatWithValidation({
  2729. pathname: (0, _addBasePath).addBasePath(pathname),
  2730. query
  2731. }), (0, _utils).getURL());
  2732. return;
  2733. }
  2734. // __NA is used to identify if the history entry can be handled by the app-router.
  2735. if (state.__NA) {
  2736. window.location.reload();
  2737. return;
  2738. }
  2739. if (!state.__N) {
  2740. return;
  2741. }
  2742. // Safari fires popstateevent when reopening the browser.
  2743. if (isFirstPopStateEvent && this.locale === state.options.locale && state.as === this.asPath) {
  2744. return;
  2745. }
  2746. let forcedScroll;
  2747. const { url , as , options , key } = state;
  2748. if (false) {}
  2749. this._key = key;
  2750. const { pathname: pathname1 } = (0, _parseRelativeUrl).parseRelativeUrl(url);
  2751. // Make sure we don't re-render on initial load,
  2752. // can be caused by navigating back from an external site
  2753. if (this.isSsr && as === (0, _addBasePath).addBasePath(this.asPath) && pathname1 === (0, _addBasePath).addBasePath(this.pathname)) {
  2754. return;
  2755. }
  2756. // If the downstream application returns falsy, return.
  2757. // They will then be responsible for handling the event.
  2758. if (this._bps && !this._bps(state)) {
  2759. return;
  2760. }
  2761. this.change("replaceState", url, as, Object.assign({}, options, {
  2762. shallow: options.shallow && this._shallow,
  2763. locale: options.locale || this.defaultLocale,
  2764. // @ts-ignore internal value not exposed on types
  2765. _h: 0
  2766. }), forcedScroll);
  2767. };
  2768. // represents the current component key
  2769. const route = (0, _removeTrailingSlash).removeTrailingSlash(pathname1);
  2770. // set up the component cache (by route keys)
  2771. this.components = {};
  2772. // We should not keep the cache, if there's an error
  2773. // Otherwise, this cause issues when when going back and
  2774. // come again to the errored page.
  2775. if (pathname1 !== "/_error") {
  2776. this.components[route] = {
  2777. Component,
  2778. initial: true,
  2779. props: initialProps,
  2780. err,
  2781. __N_SSG: initialProps && initialProps.__N_SSG,
  2782. __N_SSP: initialProps && initialProps.__N_SSP
  2783. };
  2784. }
  2785. this.components["/_app"] = {
  2786. Component: App,
  2787. styleSheets: []
  2788. };
  2789. // Backwards compat for Router.router.events
  2790. // TODO: Should be remove the following major version as it was never documented
  2791. this.events = Router.events;
  2792. this.pageLoader = pageLoader;
  2793. // if auto prerendered and dynamic route wait to update asPath
  2794. // until after mount to prevent hydration mismatch
  2795. const autoExportDynamic = (0, _isDynamic).isDynamicRoute(pathname1) && self.__NEXT_DATA__.autoExport;
  2796. this.basePath = false || "";
  2797. this.sub = subscription;
  2798. this.clc = null;
  2799. this._wrapApp = wrapApp;
  2800. // make sure to ignore extra popState in safari on navigating
  2801. // back from external site
  2802. this.isSsr = true;
  2803. this.isLocaleDomain = false;
  2804. this.isReady = !!(self.__NEXT_DATA__.gssp || self.__NEXT_DATA__.gip || self.__NEXT_DATA__.appGip && !self.__NEXT_DATA__.gsp || !autoExportDynamic && !self.location.search && !false);
  2805. if (true) {
  2806. this.locales = locales;
  2807. this.defaultLocale = defaultLocale;
  2808. this.domainLocales = domainLocales;
  2809. this.isLocaleDomain = !!(0, _detectDomainLocale).detectDomainLocale(domainLocales, self.location.hostname);
  2810. }
  2811. this.state = {
  2812. route,
  2813. pathname: pathname1,
  2814. query: query1,
  2815. asPath: autoExportDynamic ? pathname1 : as1,
  2816. isPreview: !!isPreview,
  2817. locale: true ? locale : 0,
  2818. isFallback
  2819. };
  2820. this._initialMatchesMiddlewarePromise = Promise.resolve(false);
  2821. if (false) {}
  2822. }
  2823. }
  2824. Router.events = (0, _mitt).default();
  2825. exports["default"] = Router; //# sourceMappingURL=router.js.map
  2826. /***/ })
  2827. };
  2828. ;
  2829. //# sourceMappingURL=79165.js.map