'use client';
import { useState } from 'react';
import { cn } from '@/lib/cn';
import { monogram } from '@/lib/profile';
/**
* Company logo with graceful degradation: tries each candidate URL in order (profile logo → icon → legacy), falls back
* to a monogram plate. Plain `
` (remote hosts are unknown, so `next/image` optimisation is not used); lazy by
* default, `referrerPolicy="no-referrer"` so third-party hosts do not learn which profile was viewed.
*/
export function CompanyLogo({ name, candidates, size = 40, className, priority = false, rounded = 'md' }: { name: string; candidates: string[]; size?: number; className?: string; priority?: boolean; rounded?: 'sm' | 'md' | 'lg' }) {
const [idx, setIdx] = useState(0);
const src = candidates[idx];
const radius = rounded === 'sm' ? 'rounded-[3px]' : rounded === 'lg' ? 'rounded-[10px]' : 'rounded-[6px]';
const style = { width: size, height: size };
if (!src) {
return (
{monogram(name)}
);
}
return (
{/* eslint-disable-next-line @next/next/no-img-element */}
setIdx((i) => i + 1)} />
);
}