import { useEffect, useState, type ReactNode } from "react"; import type { EmailAddress } from "@/jmap/types"; import { avatarColor, initials } from "@/lib/address"; import { useContacts } from "@/store/contacts"; import { contactPhoto } from "@/lib/contacts"; export function Avatar({ who, size, className }: { who: EmailAddress | { name?: string | null; email?: string } | string | null | undefined; size?: "sm" | "lg" | "xl"; className?: string }) { const email = typeof who === "string" ? who : (who?.email ?? ""); const name = typeof who === "string" ? who : (who?.name ?? who?.email ?? ""); const photo = useContacts((s) => { if (!email || !s.loaded) return null; const c = s.lookupByEmail(email); return c && s.accountId ? contactPhoto(c, s.accountId) : null; }); return ( ); } export function Switch({ checked, onChange, label, hint, disabled }: { checked: boolean; onChange: (v: boolean) => void; label?: ReactNode; hint?: ReactNode; disabled?: boolean }) { const sw = (