import { r as stylePromptTitle } from "./prompt-style-mpRhXk_G.js";
import { intro, outro } from "@clack/prompts";
//#region src/flows/doctor-health.ts
const intro$1 = (message) => intro(stylePromptTitle(message) ?? message);
const outro$1 = (message) => outro(stylePromptTitle(message) ?? message);
async function doctorCommand(runtime, options = {}) {
	const effectiveRuntime = runtime ?? (await import("./runtime-BwOCNZYU.js")).defaultRuntime;
	const envSnapshot = { ...process.env };
	const { createDoctorPrompter } = await import("./doctor-prompter-CKTtg0oK.js");
	const { printWizardHeader } = await import("./onboard-helpers-2vObC8BT.js");
	const prompter = createDoctorPrompter({
		runtime: effectiveRuntime,
		options
	});
	printWizardHeader(effectiveRuntime);
	intro$1("OpenClaw 诊断");
	const { resolveOpenClawPackageRoot } = await import("./openclaw-root-DNGl9uDX.js");
	const root = await resolveOpenClawPackageRoot({
		moduleUrl: import.meta.url,
		argv1: process.argv[1],
		cwd: process.cwd()
	});
	const { maybeOfferUpdateBeforeDoctor } = await import("./doctor-update-DiwHj625.js");
	if ((await maybeOfferUpdateBeforeDoctor({
		runtime: effectiveRuntime,
		options,
		root,
		confirm: (p) => prompter.confirm(p),
		outro: outro$1
	})).handled) return;
	const { maybeRepairUiProtocolFreshness } = await import("./doctor-ui-ZHgRrEeX.js");
	const { noteSourceInstallIssues } = await import("./doctor-install-CBCPmSZQ.js");
	const { noteStartupOptimizationHints } = await import("./doctor-platform-notes-BVMIYiT8.js");
	await maybeRepairUiProtocolFreshness(effectiveRuntime, prompter);
	noteSourceInstallIssues(root);
	noteStartupOptimizationHints();
	const { loadAndMaybeMigrateDoctorConfig } = await import("./doctor-config-flow-BZWs16OW.js");
	const configResult = await loadAndMaybeMigrateDoctorConfig({
		options,
		confirm: (p) => prompter.confirm(p),
		runtime: effectiveRuntime,
		prompter
	});
	const { CONFIG_PATH } = await import("./config/config.js");
	const ctx = {
		runtime: effectiveRuntime,
		options,
		prompter,
		configResult,
		cfg: configResult.cfg,
		cfgForPersistence: structuredClone(configResult.cfg),
		sourceConfigValid: configResult.sourceConfigValid ?? true,
		configPath: configResult.path ?? CONFIG_PATH,
		env: envSnapshot
	};
	const { runDoctorHealthContributions } = await import("./doctor-health-contributions-BzjfqZVP.js");
	await runDoctorHealthContributions(ctx);
	outro$1("诊断完成。");
}
//#endregion
export { doctorCommand };
