import { d as readStringValue } from "./string-coerce-CIT1-v_a.js";
import { a as parseKaijiBotManifestInstallBase, c as resolveKaijiBotManifestOs, i as parseFrontmatterBool, l as resolveKaijiBotManifestRequires, n as getFrontmatterString, o as resolveKaijiBotManifestBlock, r as normalizeStringList, s as resolveKaijiBotManifestInstall, t as applyKaijiBotManifestInstallCommonFields, u as parseFrontmatterBlock } from "./frontmatter-ClznvVnZ.js";
//#region src/hooks/frontmatter.ts
function parseFrontmatter(content) {
	return parseFrontmatterBlock(content);
}
function parseInstallSpec(input) {
	const parsed = parseKaijiBotManifestInstallBase(input, [
		"bundled",
		"npm",
		"git"
	]);
	if (!parsed) return;
	const { raw } = parsed;
	const spec = applyKaijiBotManifestInstallCommonFields({ kind: parsed.kind }, parsed);
	if (typeof raw.package === "string") spec.package = raw.package;
	if (typeof raw.repository === "string") spec.repository = raw.repository;
	return spec;
}
function resolveKaijiBotMetadata(frontmatter) {
	const metadataObj = resolveKaijiBotManifestBlock({ frontmatter });
	if (!metadataObj) return;
	const requires = resolveKaijiBotManifestRequires(metadataObj);
	const install = resolveKaijiBotManifestInstall(metadataObj, parseInstallSpec);
	const osRaw = resolveKaijiBotManifestOs(metadataObj);
	const eventsRaw = normalizeStringList(metadataObj.events);
	return {
		always: typeof metadataObj.always === "boolean" ? metadataObj.always : void 0,
		emoji: readStringValue(metadataObj.emoji),
		homepage: readStringValue(metadataObj.homepage),
		hookKey: readStringValue(metadataObj.hookKey),
		export: readStringValue(metadataObj.export),
		os: osRaw.length > 0 ? osRaw : void 0,
		events: eventsRaw.length > 0 ? eventsRaw : [],
		requires,
		install: install.length > 0 ? install : void 0
	};
}
function resolveHookInvocationPolicy(frontmatter) {
	return { enabled: parseFrontmatterBool(getFrontmatterString(frontmatter, "enabled"), true) };
}
function resolveHookKey(hookName, entry) {
	return entry?.metadata?.hookKey ?? hookName;
}
//#endregion
export { resolveKaijiBotMetadata as i, resolveHookInvocationPolicy as n, resolveHookKey as r, parseFrontmatter as t };
