export function summarizeItems<T extends { name?: string }>(
  items: T[] | undefined,
  fallback: string
): string {
  if (!items || items.length === 0) {
    return fallback;
  }

  const [primary, ...rest] = items;
  const summary = primary?.name || fallback;
  const additionalCount = rest.filter(Boolean).length;
  if (additionalCount > 0) {
    return `${summary} +${additionalCount} more`;
  }

  return summary;
}
