import { a as readMainFacts, i as listCustomerSlugs } from "./customer-dir-CkMMXhb0.js";
import { n as findDuplicateClusters, r as normalizeDomain } from "./identity-_uZ3Lbr2.js";
//#region src/core/hygiene.ts
async function scanHygiene(dataDir) {
	const issues = [];
	for (const slug of listCustomerSlugs(dataDir)) {
		const facts = await readMainFacts(dataDir, slug).catch(() => null);
		if (!facts) continue;
		if (!facts.domain && !facts.email) issues.push({
			type: "missing_contact",
			slug,
			detail: "No domain or email"
		});
		if (facts.domain && /^https?:\/\/|^www\./i.test(facts.domain)) issues.push({
			type: "format_domain",
			slug,
			field: "domain",
			detail: `Domain not normalized: ${facts.domain}`,
			suggestedFix: normalizeDomain(facts.domain)
		});
		if (facts.email && !facts.email.includes("@")) issues.push({
			type: "format_email",
			slug,
			field: "email",
			detail: `Email missing '@': ${facts.email}`
		});
	}
	for (const cluster of await findDuplicateClusters(dataDir)) for (const slug of cluster.slugs) issues.push({
		type: "duplicate",
		slug,
		detail: `Shares canonical domain '${cluster.key}' with: ${cluster.slugs.filter((s) => s !== slug).join(", ")}`
	});
	return issues;
}
//#endregion
export { scanHygiene };

//# sourceMappingURL=hygiene-DzQPnc6P.js.map