{"release_id":"01a2309f-d47d-0000-29bc-a17a97e31fa5","chunk_id":"01a2309f-d598-7d81-bae3-05f697051527","file":"Buz-neUC.mjs","mappings":"qTASA,IAAIA,EAAU,EAId,MAAMC,EAAY,IAElB,eAAsBC,EAAaC,EAA+C,CACjFH,IACA,GAAI,CACH,MAAMG,EAAA,CACP,QAAA,CACC,WAAW,IAAMH,IAAWC,CAAS,CACtC,CACD,CAGO,SAASG,GAA8B,CAC7C,OAAOJ,EAAU,CAClB,CCpBA,IAAIK,EAAQ,GAGL,SAASC,GAA4B,CAC3CD,EAAQ,EACT,CAGA,MAAME,EAA0B,GAAK,IAI9B,SAASC,GAA+B,CAE9C,OADY,YAAY,mBAAmB,YAAY,EAAE,CAAC,GAC9C,OAAS,SAAW,SAAW,OAC5C,CAKO,SAASC,EACfC,EACAC,EAAM,KAAK,MACXC,EAAkD,CAAE,MAAAP,EAAO,MAAOA,EAAQ,QAAUG,EAAA,GAC1E,CACV,OAAII,EAAM,MAAc,GACpBA,EAAM,QAAU,SAAiB,GAC9BF,IAAe,QAAaC,EAAMD,EAAaH,CACvD","names":["running","LINGER_MS","inBackground","reload","isBackgroundReload","inApp","markInAppNavigation","DOCUMENT_RESTORE_MAX_MS","documentStart","mayRestoreList","capturedAt","now","state"],"sources":["../../../../../../src/lib/background-reload.ts","../../../../../../src/lib/page-lifetime.ts"],"sourcesContent":["/**\n * RAT-679: a page-data reload nobody asked for. The auth client announces the\n * session again (SIGNED_IN) every time the tab becomes visible, and the root\n * layout answers with invalidateAll(). On most pages that is a harmless\n * refresh. On the feed it used to swap the whole list under the viewer, and now\n * that a seen post doesn't come back, the one they were reading would be gone\n * for good — so the feed keeps its list through such a reload and offers the new\n * posts instead.\n */\nlet running = 0;\n\n/** The flag outlives the promise by a moment: a component's effect sees the new\n *  data in a microtask of its own, which can run after the reload resolved. */\nconst LINGER_MS = 150;\n\nexport async function inBackground(reload: () => Promise<unknown>): Promise<void> {\n\trunning++;\n\ttry {\n\t\tawait reload();\n\t} finally {\n\t\tsetTimeout(() => running--, LINGER_MS);\n\t}\n}\n\n/** Whether the data arriving now is from such a reload. Read it synchronously. */\nexport function isBackgroundReload(): boolean {\n\treturn running > 0;\n}\n","/**\n * RAT-679: how this document came to be, for pages that keep a SvelteKit\n * snapshot. SvelteKit restores a snapshot not only on back/forward inside the\n * app but also on a document load of the same history entry: a reload, or the\n * phone bringing back a tab it had thrown away. There \"where I left off\" is the\n * wrong answer for a feed — someone who reloads asks for what's new.\n */\nlet inApp = false;\n\n/** The root layout calls this on every navigation but the first. */\nexport function markInAppNavigation(): void {\n\tinApp = true;\n}\n\n/** Older than this, a list brought back by a document load is stale news. */\nconst DOCUMENT_RESTORE_MAX_MS = 10 * 60_000;\n\nexport type DocumentStart = 'reload' | 'other';\n\nexport function documentStart(): DocumentStart {\n\tconst nav = performance.getEntriesByType?.('navigation')[0] as PerformanceNavigationTiming | undefined;\n\treturn nav?.type === 'reload' ? 'reload' : 'other';\n}\n\n/** Whether a list captured at `capturedAt` may be put back now.\n *  Back/forward inside the app: always. A document load: never on a reload, else\n *  only while it is fresh (coming back from an external page). */\nexport function mayRestoreList(\n\tcapturedAt: number | undefined,\n\tnow = Date.now(),\n\tstate: { inApp: boolean; start: DocumentStart } = { inApp, start: inApp ? 'other' : documentStart() }\n): boolean {\n\tif (state.inApp) return true;\n\tif (state.start === 'reload') return false;\n\treturn capturedAt !== undefined && now - capturedAt < DOCUMENT_RESTORE_MAX_MS;\n}\n"],"version":3}