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 const userStatuses: FacetedFilterOption[] = [
  {
    label: '正常',
    value: 'active',
    icon: h(CheckCircle2),
  },
  {
    label: '封禁',
    value: 'banned',
    icon: h(Ban),
  },
]

export const onlineStatuses: (FacetedFilterOption & { style: string })[] = [
  {
    label: '在线',
    value: 'online',
    icon: h(CheckCircle2),
    style: 'bg-green-500/10 text-green-500',
  },
  {
    label: '离线',
    value: 'offline',
    icon: h(Clock),
    style: 'bg-gray-500/10 text-gray-500',
  },
  {
    label: '封禁',
    value: 'banned',
    icon: h(Ban),
    style: 'bg-red-500/10 text-red-500',
  },
]

export function getOnlineStatusLabel(status: OnlineStatus): string {
  const labels: Record<OnlineStatus, string> = {
    online: '在线',
    offline: '离线',
    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'
}
