import{t as e}from"./als-registry-BxXlcmpy.js";var t=class extends Error{constructor(e,t){super(`Route ${e} used ${t} during prerendering but the render was aborted. This is expected when prerendering is cut short (e.g. due to a dynamic access).`),this.name=`HangingPromiseRejectionError`}},n=new WeakMap;function r(){}function i(e,i,a){if(e.aborted){let e=Promise.reject(new t(i,a));return e.catch(r),e}let o=new Promise((r,o)=>{let s=o.bind(null,new t(i,a)),c=n.get(e);if(c)c.push(s);else{let t=[s];n.set(e,t),e.addEventListener(`abort`,()=>{for(let e=0;e<t.length;e++)t[e]();t.length=0},{once:!0})}});return o.catch(r),o}var a=e(`vinext.pprFallbackShell.als`),o=e(`vinext.pprFallbackShell.cacheTaskStack.als`);function s(){}function c(e){let t=setTimeout(()=>{t=null,n=setTimeout(()=>{n=null,e()},0)},0),n=null;return()=>{t!==null&&(clearTimeout(t),t=null),n!==null&&(clearTimeout(n),n=null)}}function l(e){if(e.pendingCacheTasks!==0)return;let t=e.cacheReadyResolvers.splice(0);for(let e of t)e()}function u(e){e.pendingCacheTasks!==0||e.pendingCacheReadyCleanup!==null||(e.pendingCacheReadyCleanup=c(()=>{e.pendingCacheReadyCleanup=null,l(e),e.phase===`final`&&d(e)}))}function d(e){e.phase!==`final`||!e.isFinalRenderStarted||!e.hasDynamicBoundary||e.pendingCacheTasks>0||e.pendingCacheReadyCleanup!==null||e.isAbortScheduled||(e.isAbortScheduled=!0,e.pendingAbortCleanup=c(()=>{e.pendingAbortCleanup=null,e.isAbortScheduled=!1,e.phase===`final`&&e.hasDynamicBoundary&&e.pendingCacheTasks===0&&e.pendingCacheReadyCleanup===null&&!e.reactAbortController.signal.aborted&&(e.reactAbortController.abort(),e.abortController.abort())}))}function f(e,t){t.isPending&&(t.isPending=!1,t.epoch===e.cacheEpoch&&(e.pendingCacheTasks--,u(e)))}function p(e,t){!t.isPending||t.isIgnored||(t.isIgnored=!0,f(e,t))}function m(){return a.getStore()??null}function h(e,t){g(e),e.phase===`final`&&d(e);let n=i(e.abortController.signal,e.routePattern,t);return n.catch(s),n}function g(e){e.hasDynamicBoundary=!0;for(let t of o.getStore()??[])p(e,t);u(e)}function _(e){let t=m();return t===null?null:h(t,e)}export{h as n,m as r,_ as t};