export const AVAILABLE_LANGUAGES = [
  { code: 'AR', label: 'العربية' },
  { code: 'EN', label: 'English' },
  { code: 'FR', label: 'Français' },
  { code: 'ID', label: 'Bahasa Indonesia' },
]

export const TRANSLATION_STATUS_COLORS = {
  draft: 'bg-surface-tertiary text-text-secondary',
  pending_review: 'bg-amber-100 text-amber-700',
  approved: 'bg-emerald-100 text-emerald-700',
  rejected: 'bg-red-100 text-red-700',
  revision_requested: 'bg-orange-100 text-orange-700',
}

export function isTextSelected(text) {
  return text.is_selected === true || text.is_selected === 1
}

export function groupTextsByLanguage(texts) {
  const grouped = {}
  for (const text of texts) {
    if (!grouped[text.language_code]) grouped[text.language_code] = []
    grouped[text.language_code].push(text)
  }
  for (const code in grouped) {
    grouped[code].sort((a, b) => (a.option_number || 1) - (b.option_number || 1))
  }
  return grouped
}
