// Puzzle theme definitions with Arabic names and icons

export const THEMES = [
  { key: 'mate', name: 'كش مات', nameEn: 'Checkmate', icon: '♚' },
  { key: 'short', name: 'قصيرة', nameEn: 'Short', icon: '⚡' },
  { key: 'long', name: 'طويلة', nameEn: 'Long', icon: '📏' },
  { key: 'sacrifice', name: 'تضحية', nameEn: 'Sacrifice', icon: '💥' },
  { key: 'fork', name: 'شوكة', nameEn: 'Fork', icon: '🔱' },
  { key: 'pin', name: 'تثبيت', nameEn: 'Pin', icon: '📌' },
  { key: 'skewer', name: 'سيخ', nameEn: 'Skewer', icon: '🗡️' },
  { key: 'back-rank', name: 'الصف الأخير', nameEn: 'Back Rank', icon: '🏰' },
  { key: 'discovery', name: 'كشف', nameEn: 'Discovered Attack', icon: '👁️' },
  { key: 'double-check', name: 'كشف مزدوج', nameEn: 'Double Check', icon: '⚔️' },
  { key: 'attack', name: 'هجوم', nameEn: 'Attack', icon: '⚔️' },
  { key: 'defense', name: 'دفاع', nameEn: 'Defense', icon: '🛡️' },
  { key: 'endgame', name: 'نهايات', nameEn: 'Endgame', icon: '🏁' },
  { key: 'promotion', name: 'ترقية', nameEn: 'Promotion', icon: '👑' },
  { key: 'trapped', name: 'محاصرة', nameEn: 'Trapped Piece', icon: '🪤' },
  { key: 'zugzwang', name: 'تسوغزوانغ', nameEn: 'Zugzwang', icon: '⏳' },
];

export function getThemeName(key, lang = 'ar') {
  const theme = THEMES.find(t => t.key === key);
  if (!theme) return key;
  return lang === 'ar' ? theme.name : theme.nameEn;
}

export function getThemeIcon(key) {
  const theme = THEMES.find(t => t.key === key);
  return theme?.icon || '♟';
}

export function parseThemes(themesStr) {
  if (!themesStr) return [];
  return themesStr.split(',').map(t => t.trim()).filter(Boolean);
}
