'use client';

import { ArrowDown } from 'lucide-react';

import { cn } from '@djangocfg/ui-core/lib';

export interface JumpToLatestProps {
  visible?: boolean;
  unreadCount?: number;
  onClick?: () => void;
  className?: string;
}

export function JumpToLatest({ visible, unreadCount = 0, onClick, className }: JumpToLatestProps) {
  if (!visible) return null;
  return (
    <button
      type="button"
      onClick={onClick}
      aria-live="polite"
      className={cn(
        'pointer-events-auto inline-flex items-center gap-1.5 rounded-full border border-border bg-background px-3 py-1 text-xs shadow-md hover:bg-accent',
        className,
      )}
    >
      <ArrowDown aria-hidden className="size-3.5" />
      {unreadCount > 0 ? `${unreadCount} new` : 'Jump to latest'}
    </button>
  );
}
