import{__exports as e}from"../../../../_virtual/route-loader.js_commonjs-exports";import t from"../../node_modules/@babel/runtime/helpers/interopRequireDefault.js";import"../next-server/lib/router/utils/get-asset-path-from-route.js";import"./request-idle-callback.js";import{__exports as r}from"../../../../_virtual/get-asset-path-from-route.js_commonjs-exports";import{__exports as o}from"../../../../_virtual/request-idle-callback.js_commonjs-exports";var n=t;e.__esModule=!0,e.markAssetError=a,e.isAssetError=function(e){return e&&u in e},e.getClientBuildManifest=m,e.default=void 0;var s=n(r),i=o;function l(e,t,r){let o,n=t.get(e);if(n)return"future"in n?n.future:Promise.resolve(n);const s=new Promise((e=>{o=e}));return t.set(e,n={resolve:o,future:s}),r?r().then((e=>(o(e),e))):s}const c=function(e){try{return e=document.createElement("link"),!!window.MSInputMethodContext&&!!document.documentMode||e.relList.supports("prefetch")}catch(e){return!1}}();const u=Symbol("ASSET_LOAD_ERROR");function a(e){return Object.defineProperty(e,u,{})}function p(e,t,r){return new Promise(((o,n)=>{let s=!1;e.then((e=>{s=!0,o(e)})).catch(n),(0,i.requestIdleCallback)((()=>setTimeout((()=>{s||n(r)}),t)))}))}function m(){if(self.__BUILD_MANIFEST)return Promise.resolve(self.__BUILD_MANIFEST);return p(new Promise((e=>{const t=self.__BUILD_MANIFEST_CB;self.__BUILD_MANIFEST_CB=()=>{e(self.__BUILD_MANIFEST),t&&t()}})),3800,a(new Error("Failed to load client build manifest")))}function d(e,t){return"development"===process.env.NODE_ENV?Promise.resolve({scripts:[e+"/_next/static/chunks/pages"+encodeURI((0,s.default)(t,".js"))],css:[]}):m().then((r=>{if(!(t in r))throw a(new Error(`Failed to lookup route: ${t}`));const o=r[t].map((t=>e+"/_next/"+encodeURI(t)));return{scripts:o.filter((e=>e.endsWith(".js"))),css:o.filter((e=>e.endsWith(".css")))}}))}var f=function(e){const t=new Map,r=new Map,o=new Map,n=new Map;function s(e){let t=r.get(e);return t||(document.querySelector(`script[src^="${e}"]`)?Promise.resolve():(r.set(e,t=function(e,t){return new Promise(((r,o)=>{(t=document.createElement("script")).onload=r,t.onerror=()=>o(a(new Error(`Failed to load script: ${e}`))),t.crossOrigin=process.env.__NEXT_CROSS_ORIGIN,t.src=e,document.body.appendChild(t)}))}(e)),t))}function u(e){let t=o.get(e);return t||(o.set(e,t=fetch(e).then((t=>{if(!t.ok)throw new Error(`Failed to load stylesheet: ${e}`);return t.text().then((t=>({href:e,content:t})))})).catch((e=>{throw a(e)}))),t)}return{whenEntrypoint:e=>l(e,t),onEntrypoint(e,r){Promise.resolve(r).then((e=>e())).then((e=>({component:e&&e.default||e,exports:e})),(e=>({error:e}))).then((r=>{const o=t.get(e);t.set(e,r),o&&"resolve"in o&&o.resolve(r)}))},loadRoute(r,o){return l(r,n,(()=>p(d(e,r).then((({scripts:e,css:o})=>Promise.all([t.has(r)?[]:Promise.all(e.map(s)),Promise.all(o.map(u))]))).then((e=>this.whenEntrypoint(r).then((t=>({entrypoint:t,styles:e[1]}))))),3800,a(new Error(`Route did not complete loading: ${r}`))).then((({entrypoint:e,styles:t})=>{const r=Object.assign({styles:t},e);return"error"in e?e:r})).catch((e=>{if(o)throw e;return{error:e}}))))},prefetch(t){let r;return(r=navigator.connection)&&(r.saveData||/2g/.test(r.effectiveType))?Promise.resolve():d(e,t).then((e=>Promise.all(c?e.scripts.map((e=>{return t=e,r="script",new Promise(((e,n)=>{if(document.querySelector(`link[rel="prefetch"][href^="${t}"]`))return e();o=document.createElement("link"),r&&(o.as=r),o.rel="prefetch",o.crossOrigin=process.env.__NEXT_CROSS_ORIGIN,o.onload=e,o.onerror=n,o.href=t,document.head.appendChild(o)}));var t,r,o})):[]))).then((()=>{(0,i.requestIdleCallback)((()=>this.loadRoute(t,!0).catch((()=>{}))))})).catch((()=>{}))}}};e.default=f;
//# sourceMappingURL=route-loader.js.map
