import { init_paths_state, resolveStateDir } from "../../../config/paths-state.js";
import { init_paths, resolveConfigPath } from "../../../config/paths.js";
import { collectDoctorResults } from "../../../cli/commands/doctor/flow.js";
//#region src/gateway/hono/routes/doctor.ts
init_paths();
init_paths_state();
function registerDoctorRoutes(authenticated, _deps) {
	authenticated.get("/api/doctor", async (c) => {
		const deep = c.req.query("deep") === "true";
		const security = c.req.query("security") === "true";
		const results = await collectDoctorResults({
			configPath: process.env.XOPC_CONFIG_PATH || resolveConfigPath(),
			stateDir: resolveStateDir(),
			options: {
				fix: false,
				json: true,
				deep,
				security
			}
		});
		return c.json({
			ok: results.every((r) => r.status !== "fail"),
			checks: results.map((r) => ({
				id: r.id,
				label: r.label,
				status: r.status,
				message: r.message,
				hints: r.hints,
				fixed: r.fixed ?? false,
				...r.findings ? { findings: r.findings } : {}
			}))
		});
	});
}
//#endregion
export { registerDoctorRoutes };

//# sourceMappingURL=doctor.js.map