//#region src/privacy.ts
const CONSENT_CATEGORIES = [
	"necessary",
	"analytics",
	"marketing",
	"preferences"
];
function generatePrivacyPolicy(input) {
	const lines = [
		`# Privacy Policy — ${input.siteName}`,
		"",
		`**Contact:** ${input.contactEmail}`
	];
	if (input.jurisdiction) lines.push("", `**Jurisdiction:** ${input.jurisdiction}`);
	lines.push("", "## Data We Collect", "");
	for (const item of input.dataCollected) lines.push(`- ${item}`);
	if (input.thirdParties?.length) {
		lines.push("", "## Third Parties", "");
		for (const tp of input.thirdParties) lines.push(`- **${tp.name}** — ${tp.purpose}`);
	}
	if (input.cookies?.length) {
		lines.push("", "## Cookies", "");
		for (const c of input.cookies) {
			const duration = c.durationDays !== void 0 ? ` (${c.durationDays} days)` : "";
			lines.push(`- **${c.name}** — ${c.purpose}${duration}`);
		}
	}
	return lines.join("\n");
}
function coerceBool(raw) {
	return raw === true;
}
function parseConsent(raw) {
	if (typeof raw !== "object" || raw === null) return null;
	const obj = raw;
	if (typeof obj.recordedAt !== "string" || typeof obj.version !== "string") return null;
	if (typeof obj.categories !== "object" || obj.categories === null) return null;
	const cats = obj.categories;
	const categories = {};
	for (const key of CONSENT_CATEGORIES) categories[key] = key in cats ? coerceBool(cats[key]) : false;
	categories.necessary = true;
	return {
		categories,
		recordedAt: obj.recordedAt,
		version: obj.version
	};
}
function defaultConsent() {
	return {
		categories: {
			necessary: true,
			analytics: false,
			marketing: false,
			preferences: false
		},
		recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
		version: "1"
	};
}
//#endregion
export { defaultConsent, generatePrivacyPolicy, parseConsent };
