import { c as normalizeOptionalString } from "./string-coerce-DKw2K5wM.js";
import { t as formatCliCommand } from "./command-format-BwDuXB2Y.js";
import { l as normalizeStringEntries } from "./string-normalization-B8G0vlWE.js";
import { t as note } from "./note-Daxss21Z.js";
//#region src/commands/doctor-command-owner.ts
function resolveConfiguredCommandOwners(cfg) {
	const owners = cfg.commands?.ownerAllowFrom;
	if (!Array.isArray(owners)) return [];
	return normalizeStringEntries(owners.map((entry) => String(entry ?? "")));
}
function hasConfiguredCommandOwners(cfg) {
	return resolveConfiguredCommandOwners(cfg).length > 0;
}
function formatCommandOwnerFromChannelSender(params) {
	const id = normalizeOptionalString(params.id);
	if (!id) return null;
	const separatorIndex = id.indexOf(":");
	if (separatorIndex > 0) {
		if (id.slice(0, separatorIndex).toLowerCase() === String(params.channel).toLowerCase()) return id;
	}
	return `${params.channel}:${id}`;
}
function noteCommandOwnerHealth(cfg) {
	if (hasConfiguredCommandOwners(cfg)) return;
	note([
		"No command owner is configured.",
		"A command owner is the human operator account allowed to run owner-only commands and approve dangerous actions, including /diagnostics, /export-trajectory, /config, and exec approvals.",
		"DM pairing only lets someone talk to the bot; it does not make that sender the owner for privileged commands.",
		`Fix: set commands.ownerAllowFrom to your channel user id, for example ${formatCliCommand("nodmix config set commands.ownerAllowFrom '[\"telegram:123456789\"]'")}`,
		"Restart the gateway after changing this if it is already running."
	].join("\n"), "Command owner");
}
//#endregion
export { hasConfiguredCommandOwners as n, noteCommandOwnerHealth as r, formatCommandOwnerFromChannelSender as t };
