/**
 * Language mapping utility for AI prompts
 * Maps locale codes to full language names for AI instructions
 */

export const SUPPORTED_LOCALES = {
  tr: 'Turkish',
  en: 'English',
  de: 'German',
  ar: 'Arabic',
  zh: 'Chinese',
  es: 'Spanish',
  fr: 'French',
  it: 'Italian',
  ja: 'Japanese',
  ko: 'Korean',
  pt: 'Portuguese',
  ru: 'Russian',
} as const;

export type SupportedLocale = keyof typeof SUPPORTED_LOCALES;

/**
 * Get the full language name for AI prompts
 * @param locale - Locale code (e.g., 'tr', 'en')
 * @returns Full language name (e.g., 'Turkish', 'English')
 */
export function getLanguageName(locale?: string): string {
  if (!locale) return SUPPORTED_LOCALES.tr; // Default to Turkish

  const normalizedLocale = locale.toLowerCase() as SupportedLocale;
  return SUPPORTED_LOCALES[normalizedLocale] || SUPPORTED_LOCALES.en; // Fallback to English
}

/**
 * Get language instruction for AI prompts
 * @param locale - Locale code
 * @returns Formatted instruction for AI (e.g., "Write in Turkish")
 */
export function getLanguageInstruction(locale?: string): string {
  const language = getLanguageName(locale);
  return `Write in ${language}.`;
}

/**
 * Check if a locale is supported
 * @param locale - Locale code to check
 * @returns True if supported, false otherwise
 */
export function isSupportedLocale(locale: string): locale is SupportedLocale {
  return locale.toLowerCase() in SUPPORTED_LOCALES;
}
