'use client';
import { jsx as _jsx } from "react/jsx-runtime";
/**
 * Deterministic per-author avatar: a colored circle with the author's
 * initials, hashed from the name so the color is stable across renders
 * and views without storing anything. Shared by the Dashboard activity
 * feed and the Pages/Posts list tables so an author always looks the
 * same everywhere.
 *
 * The palette is intentionally raw hex applied via inline style — the
 * design-system exception for truly dynamic values (see Dashboard.tsx
 * note). All swatches keep ≥4.5:1 contrast with white text.
 */
const AVATAR_COLORS = [
    '#7C3AED', // purple
    '#E11D48', // rose
    '#059669', // emerald
    '#0891B2', // cyan
    '#D97706', // amber
    '#4F46E5', // indigo
    '#DC2626', // red
];
function hashString(s) {
    let h = 0;
    for (let i = 0; i < s.length; i++)
        h = (h * 31 + s.charCodeAt(i)) | 0;
    return Math.abs(h);
}
export function authorAvatar(name) {
    const safe = (name ?? '').trim() || 'User';
    const parts = safe.split(/\s+/).filter(Boolean);
    const initials = parts.length >= 2
        ? `${parts[0][0]}${parts[parts.length - 1][0]}`.toUpperCase()
        : safe.slice(0, 2).toUpperCase();
    const color = AVATAR_COLORS[hashString(safe) % AVATAR_COLORS.length];
    return { color, initials };
}
export function AuthorAvatar({ name, size = 28, className = '', }) {
    const { color, initials } = authorAvatar(name);
    return (_jsx("span", { "aria-hidden": true, className: `inline-flex shrink-0 items-center justify-center rounded-full font-medium text-white ${className}`, style: {
            width: size,
            height: size,
            background: color,
            fontSize: Math.max(9, Math.round(size * 0.4)),
        }, children: initials }));
}
//# sourceMappingURL=AuthorAvatar.js.map