import { Z as ensureMigrated, M as MigrationError } from './src-CidJbygh.js';

//#region src/lib/server/migration-status.ts
/**
* Shared on-disk migration detection for the launch flow.
*
* A cheap `ensureMigrated` DRY RUN (no lock, no backup, writes nothing) reports
* whether the home needs migrating before the user can safely continue, and
* surfaces the fail-loud UnrecognizedLayoutError/MigrationError as an attention
* state. Used by BOTH the splash page load (to render the migration card) and the
* launch-routing guard (to force the user onto /splash even when the stack is
* otherwise healthy) — one source of truth, no duplicated logic.
*/
function detectMigration(homeDir) {
	const lines = [];
	try {
		const report = ensureMigrated({
			homeDir,
			dryRun: true,
			log: (m) => lines.push(m)
		});
		if (!(report.applied.length > 0 || report.releaseApplied.length > 0)) return { status: "none" };
		return {
			status: "pending",
			from: report.from,
			to: report.to,
			applied: report.applied,
			releaseApplied: report.releaseApplied,
			notes: report.notes,
			lines
		};
	} catch (e) {
		if (e instanceof MigrationError) return {
			status: "error",
			message: e.message,
			guidance: e.guidance
		};
		throw e;
	}
}
/**
* True when a migration is pending OR the home can't be read — both are states
* that must land the user on /splash before they can use the assistant, even if
* the stack is running or a healthy remote is configured.
*/
function isMigrationBlocking(homeDir) {
	const s = detectMigration(homeDir);
	return s.status === "pending" || s.status === "error";
}

export { detectMigration as d, isMigrationBlocking as i };
//# sourceMappingURL=migration-status-a9KsTKSo.js.map
