import { f as readStringValue } from "./string-coerce-LndEvhRk.js";
import { a as parseKlawManifestInstallBase, c as resolveKlawManifestOs, i as parseFrontmatterBool, l as resolveKlawManifestRequires, n as getFrontmatterString, o as resolveKlawManifestBlock, r as normalizeStringList, s as resolveKlawManifestInstall, t as applyKlawManifestInstallCommonFields, u as parseFrontmatterBlock } from "./frontmatter-DOtQljiJ.js";
//#region src/hooks/frontmatter.ts
function parseFrontmatter(content) {
	return parseFrontmatterBlock(content);
}
function parseInstallSpec(input) {
	const parsed = parseKlawManifestInstallBase(input, [
		"bundled",
		"npm",
		"git"
	]);
	if (!parsed) return;
	const { raw } = parsed;
	const spec = applyKlawManifestInstallCommonFields({ 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 resolveKlawMetadata(frontmatter) {
	const metadataObj = resolveKlawManifestBlock({ frontmatter });
	if (!metadataObj) return;
	const requires = resolveKlawManifestRequires(metadataObj);
	const install = resolveKlawManifestInstall(metadataObj, parseInstallSpec);
	const osRaw = resolveKlawManifestOs(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 { resolveKlawMetadata as i, resolveHookInvocationPolicy as n, resolveHookKey as r, parseFrontmatter as t };
