"use client";
import React from "react";
import { CookieSettingsButton } from "@/components/shared/CookieSettingsButton";
export type NoticeSection = { id: string; title: string; body: string };
export type PublicNotice = {
version: number;
builtIn: boolean;
current: boolean;
publishedAt: string | null;
effectiveDate: string;
changeSummary: string | null;
sections: NoticeSection[];
versions: { version: number; publishedAt: string; changeSummary: string | null; requiresAcceptance: boolean }[];
};
// Email addresses, web addresses and bare "www." names in notice text become links.
const LINK_RE = /([\w.+-]+@[\w-]+\.[\w.]+|https?:\/\/[^\s)]+|www\.[\w-]+\.[\w.]+)/g;
function linkify(line: string) {
const parts = line.split(LINK_RE);
return parts.map((part, i) => {
if (i % 2 === 0) return part;
const href = part.includes("@") && !part.startsWith("http") ? `mailto:${part}` : part.startsWith("http") ? part : `https://${part}`;
return (
{part}
);
});
}
/** One section of the privacy notice: one paragraph per line, "• " lines as bullets. */
export function PrivacyNoticeSection({ section, first = false }: { section: NoticeSection; first?: boolean }) {
const lines = section.body.split("\n").filter(l => l.trim() !== "");
return (
{first ? (
{section.title}
) : (
{section.title}
)}
{/* Above the cookie section: the built-in "cookies" one, or one an admin wrote about cookies. */}
{/cookie/i.test(section.id) && (
Change my cookie choice
)}
{lines.map((line, i) =>
line.startsWith("• ") ? (