import { dev, version } from '$app/env';
import { assets, immutable } from '$app/manifest';
import { installShell } from '@sailfork/client/sw';
// The signed-in app renders in the browser (ssr = false), so one cached page stands in for every app route: /settings
// and every /<owner>/... path, which is anything outside the site's own pages, git over HTTP and llms.txt files.
const site = new Set(['_app', 'about', 'account', 'api', 'benchmarks', 'caissons', 'contact', 'demo', 'explore', 'forgot-password', 'help', 'migrate', 'platform', 'reset-password', 'sign-in', 'sign-up']);
const appRoute = (path: string) => {
const parts = path.split('/').filter(Boolean);
const first = parts[0];
if (!first || site.has(first) || (parts.length === 1 && first.includes('.'))) return false;
return !/\.git(\/|$)/.test(path) && !path.endsWith('/llms.txt');
};
// Never precache what the app polls to detect a new deploy, or the update prompt would be answered from the cache.
const volatile = /\/_app\/(version\.json|env\.js)$/;
// Dev serves unhashed modules from Vite; caching them (or a shell) would hide edits.
if (!dev) {
installShell({
version,
assets: [...immutable, ...assets].map((a) => a.path).filter((path) => !volatile.test(path)),
shell: '/settings',
navigates: appRoute
});
}