import type { Composer } from 'vue-i18n'

import { Ban, CheckCircle2, Clock } from 'lucide-vue-next'
import { h } from 'vue'

import type { FacetedFilterOption } from '@/components/data-table/types'

import type { OnlineStatus } from './schema'

export function getUserStatuses(t: Composer['t']): FacetedFilterOption[] {
  return [
    {
      label: t('common.active'),
      value: 'active',
      icon: h(CheckCircle2),
    },
    {
      label: t('common.banned'),
      value: 'banned',
      icon: h(Ban),
    },
  ]
}

export function getOnlineStatuses(t: Composer['t']): (FacetedFilterOption & { style: string })[] {
  return [
    {
      label: t('common.online'),
      value: 'online',
      icon: h(CheckCircle2),
      style: 'bg-green-500/10 text-green-500',
    },
    {
      label: t('common.offline'),
      value: 'offline',
      icon: h(Clock),
      style: 'bg-gray-500/10 text-gray-500',
    },
    {
      label: t('common.banned'),
      value: 'banned',
      icon: h(Ban),
      style: 'bg-red-500/10 text-red-500',
    },
  ]
}

export function getOnlineStatusLabel(t: Composer['t'], status: OnlineStatus): string {
  const labels: Record<OnlineStatus, string> = {
    online: t('common.online'),
    offline: t('common.offline'),
    banned: t('common.banned'),
  }
  return labels[status] ?? status
}

export function getOnlineStatusVariant(status: OnlineStatus): 'default' | 'secondary' | 'destructive' {
  const variants: Record<OnlineStatus, 'default' | 'secondary' | 'destructive'> = {
    online: 'default',
    offline: 'secondary',
    banned: 'destructive',
  }
  return variants[status] ?? 'default'
}
