import type { RuleVisibility } from "./ruleVisibility"; export type SharePerson = { email: string; initials: string; role: "owner" | "reader"; }; export type RuleShareSettings = { visibility: RuleVisibility; shareSlug: string | null; shareUrl: string; shareUrlDisplay: string | null; title: string; ownerEmail: string; ownerInitials: string; readers: SharePerson[]; copyEnabled: boolean; }; export function emailInitials(email: string): string { const local = email.split("@")[0] ?? ""; const ch = local.trim().charAt(0); return ch.length > 0 ? ch.toUpperCase() : "?"; } /** Owner is shown separately. List the first reader, then an overflow line. */ export function visibleShareReaders(readers: SharePerson[]): { shown: SharePerson[]; overflowCount: number; } { if (readers.length <= 1) { return { shown: readers, overflowCount: 0 }; } return { shown: readers.slice(0, 1), overflowCount: readers.length - 1 }; }