import { MedalDisplay } from '@/lib/display-objects/MedalDisplay';
import { Icon } from '@/ui/Icon';
import { Text } from '@/ui/Text';
import { Crown, Medal } from 'lucide-react';
import React from 'react';

interface RankMedalProps {
  rank: number;
  size?: 'sm' | 'md' | 'lg';
  showIcon?: boolean;
}

export function RankMedal({ rank, size = 'md', showIcon = true }: RankMedalProps) {
  const isTop3 = rank <= 3;
  const variant = MedalDisplay.getVariant(rank);
  
  const sizePx = {
    sm: '1.75rem',
    md: '2rem',
    lg: '2.5rem',
  };

  const textSizeMap = {
    sm: 'xs',
    md: 'xs',
    lg: 'sm',
  } as const;

  const iconSize = {
    sm: 3,
    md: 3.5,
    lg: 4.5,
  };

  return (
    <div 
      style={{ 
        display: 'flex', 
        alignItems: 'center', 
        justifyContent: 'center', 
        borderRadius: '9999px', 
        border: '1px solid var(--ui-color-border-default)',
        height: sizePx[size],
        width: sizePx[size],
        backgroundColor: 'var(--ui-color-bg-surface-muted)'
      }}
    >
      {isTop3 && showIcon ? (
        <Icon icon={rank === 1 ? Crown : Medal} size={iconSize[size]} intent={variant as any} />
      ) : (
        <Text weight="bold" size={textSizeMap[size]} variant={variant as any}>{rank}</Text>
      )}
    </div>
  );
}
