import{t as e}from"./als-registry-BxXlcmpy.js";import{Q as t,Z as n}from"./cookie-serialize-CgV1qMZJ.js";import{c as r}from"./headers-CJ8zthei.js";function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var a={default:{revalidate:900,expire:4294967294},seconds:{stale:30,revalidate:1,expire:60},minutes:{stale:300,revalidate:60,expire:3600},hours:{stale:300,revalidate:3600,expire:86400},days:{stale:300,revalidate:86400,expire:604800},weeks:{stale:300,revalidate:604800,expire:2592e3},max:{stale:300,revalidate:2592e3,expire:31536e3}},o=Symbol.for(`vinext.cache.fallback`),s=globalThis,c=e(`vinext.cache.als`),l=s[o]??={actionRevalidationKind:0,pendingRevalidatedTags:new Set,pendingRevalidations:new Set,requestScopedCacheLife:null,unstableCacheObservations:new Map,unstableCacheRevalidation:`foreground`};function u(){return t()?n():c.getStore()??l}function d(){if(t()||c.getStore()!==void 0)return!0;let e=r();return e===`action`||e===`route-handler`}function f(e){if(!d())return!1;let t=u().pendingRevalidatedTags;return e.some(e=>t.has(e))}async function p(){let e=u(),t=!1,n;for(;e.pendingRevalidations.size>0;){let r=[...e.pendingRevalidations];e.pendingRevalidations.clear();let i=await Promise.allSettled(r);for(let e of i)e.status===`rejected`&&!t&&(t=!0,n=e.reason)}if(t)throw n}function m(e){let t=u();if(t.requestScopedCacheLife===null){t.requestScopedCacheLife={...e};return}e.stale!==void 0&&(t.requestScopedCacheLife.stale=t.requestScopedCacheLife.stale===void 0?e.stale:Math.min(t.requestScopedCacheLife.stale,e.stale)),e.revalidate!==void 0&&(t.requestScopedCacheLife.revalidate=t.requestScopedCacheLife.revalidate===void 0?e.revalidate:Math.min(t.requestScopedCacheLife.revalidate,e.revalidate)),e.expire!==void 0&&(t.requestScopedCacheLife.expire=t.requestScopedCacheLife.expire===void 0?e.expire:Math.min(t.requestScopedCacheLife.expire,e.expire))}function h(){let e=u().requestScopedCacheLife;return e===null?null:{...e}}function g(){let e=u(),t=e.requestScopedCacheLife;return e.requestScopedCacheLife=null,t}function _(){let e=u();return{consume(){let t=e.requestScopedCacheLife;return e.requestScopedCacheLife=null,t},peek(){let t=e.requestScopedCacheLife;return t===null?null:{...t}}}}function v(){return[...u().unstableCacheObservations.values()].sort((e,t)=>e.keyHash.localeCompare(t.keyHash))}export{h as a,a as c,f as i,i as l,g as n,v as o,p as r,m as s,_ as t};