/**
 * Translation maps for content that comes from the backend in English.
 * Domain labels, primitive labels, level words, and timeline phrases.
 */

// Domain labels (backend sends these in English)
const DOMAIN_LABELS: Record<string, Record<string, string>> = {
  es: {
    'People/Service': 'Personas/Servicio',
    'Output/Product': 'Producto/Resultado',
    'Journey/Process': 'Proceso/Recorrido',
    'Environment': 'Entorno',
    'Value': 'Valor',
    'Meta': 'Confianza',
  },
};

// Primitive code → localized display label
const PRIMITIVE_LABELS: Record<string, Record<string, string>> = {
  en: {
    TASTE: 'Taste', CRAFT: 'Craft', FRESHNESS: 'Freshness', TEMPERATURE: 'Temperature',
    EFFECTIVENESS: 'Effectiveness', ACCURACY: 'Accuracy', CONDITION: 'Condition', CONSISTENCY: 'Consistency',
    MANNER: 'Manner/Attitude', COMPETENCE: 'Competence', ATTENTIVENESS: 'Attentiveness', COMMUNICATION: 'Communication',
    SPEED: 'Speed', FRICTION: 'Friction', RELIABILITY: 'Reliability', AVAILABILITY: 'Availability',
    CLEANLINESS: 'Cleanliness', COMFORT: 'Comfort', SAFETY: 'Safety', AMBIANCE: 'Ambiance',
    ACCESSIBILITY: 'Accessibility', DIGITAL_UX: 'Digital UX',
    PRICE_LEVEL: 'Price Level', PRICE_FAIRNESS: 'Price Fairness',
    PRICE_TRANSPARENCY: 'Price Transparency', VALUE_FOR_MONEY: 'Value for Money',
    HONESTY: 'Honesty', ETHICS: 'Ethics', PROMISES: 'Promises', ACKNOWLEDGMENT: 'Acknowledgment',
    RESPONSE_QUALITY: 'Response Quality', RECOVERY: 'Recovery',
    RETURN_INTENT: 'Return Intent', RECOMMEND: 'Recommendation',
    RECOGNITION: 'Recognition', UNMAPPED: 'Unmapped', NON_INFORMATIVE: 'Non-informative',
  },
  es: {
    TASTE: 'Sabor', CRAFT: 'Artesanía', FRESHNESS: 'Frescura', TEMPERATURE: 'Temperatura',
    EFFECTIVENESS: 'Efectividad', ACCURACY: 'Precisión', CONDITION: 'Condición', CONSISTENCY: 'Consistencia',
    MANNER: 'Trato/Actitud', COMPETENCE: 'Competencia', ATTENTIVENESS: 'Atención', COMMUNICATION: 'Comunicación',
    SPEED: 'Velocidad', FRICTION: 'Fricción', RELIABILITY: 'Confiabilidad', AVAILABILITY: 'Disponibilidad',
    CLEANLINESS: 'Limpieza', COMFORT: 'Comodidad', SAFETY: 'Seguridad', AMBIANCE: 'Ambiente',
    ACCESSIBILITY: 'Accesibilidad', DIGITAL_UX: 'Experiencia Digital',
    PRICE_LEVEL: 'Nivel de Precio', PRICE_FAIRNESS: 'Equidad de Precio',
    PRICE_TRANSPARENCY: 'Transparencia de Precio', VALUE_FOR_MONEY: 'Relación Calidad-Precio',
    HONESTY: 'Honestidad', ETHICS: 'Ética', PROMISES: 'Promesas', ACKNOWLEDGMENT: 'Reconocimiento',
    RESPONSE_QUALITY: 'Calidad de Respuesta', RECOVERY: 'Recuperación',
    RETURN_INTENT: 'Intención de Retorno', RECOMMEND: 'Recomendación',
    RECOGNITION: 'Reconocimiento', UNMAPPED: 'No Clasificado', NON_INFORMATIVE: 'No Informativo',
  },
};

// English theme labels → Spanish (backend sends human-readable labels)
const THEME_LABELS: Record<string, Record<string, string>> = {
  es: {
    'Taste': 'Sabor', 'Craft': 'Artesanía', 'Freshness': 'Frescura', 'Temperature': 'Temperatura',
    'Effectiveness': 'Efectividad', 'Accuracy': 'Precisión', 'Condition': 'Condición', 'Consistency': 'Consistencia',
    'Manner': 'Trato', 'Manner/Attitude': 'Trato/Actitud', 'Competence': 'Competencia',
    'Attentiveness': 'Atención', 'Communication': 'Comunicación',
    'Speed': 'Velocidad', 'Friction': 'Fricción', 'Reliability': 'Confiabilidad', 'Availability': 'Disponibilidad',
    'Cleanliness': 'Limpieza', 'Comfort': 'Comodidad', 'Safety': 'Seguridad', 'Ambiance': 'Ambiente',
    'Accessibility': 'Accesibilidad', 'Digital UX': 'Experiencia Digital',
    'Price Level': 'Nivel de Precio', 'Price Fairness': 'Equidad de Precio',
    'Price Transparency': 'Transparencia de Precio', 'Value for Money': 'Relación Calidad-Precio',
    'Honesty': 'Honestidad', 'Ethics': 'Ética', 'Promises': 'Promesas', 'Acknowledgment': 'Reconocimiento',
    'Response Quality': 'Calidad de Respuesta', 'Recovery': 'Recuperación',
    'Return Intent': 'Intención de Retorno', 'Recommend': 'Recomendación', 'Recommendation': 'Recomendación',
    'Recognition': 'Reconocimiento', 'Unmapped': 'No Clasificado', 'Non-informative': 'No Informativo',
  },
};

// Level words (high/medium/low → alto/medio/bajo)
const LEVEL_WORDS: Record<string, Record<string, string>> = {
  es: {
    high: 'alto', medium: 'medio', low: 'bajo',
    High: 'Alto', Medium: 'Medio', Low: 'Bajo',
  },
};

// Common timeline phrases
const TIMELINE_PHRASES: Record<string, Record<string, string>> = {
  es: {
    'This month': 'Este mes',
    'This quarter': 'Este trimestre',
    'This week': 'Esta semana',
    'Next month': 'Próximo mes',
    'Next quarter': 'Próximo trimestre',
    'Immediately': 'Inmediatamente',
    'Ongoing': 'Continuo',
  },
};

/** Translate a domain label (e.g., "People/Service" → "Personas/Servicio") */
export function translateDomain(label: string, locale: string): string {
  return DOMAIN_LABELS[locale]?.[label] ?? label;
}

/** Translate a primitive code to its localized display name */
export function translatePrimitive(code: string, locale: string): string {
  return PRIMITIVE_LABELS[locale]?.[code] ?? PRIMITIVE_LABELS.en?.[code] ?? code;
}

/** Translate a theme label (e.g., "Honesty" → "Honestidad") */
export function translateThemeLabel(label: string, locale: string): string {
  return THEME_LABELS[locale]?.[label] ?? label;
}

/** Translate a level word (e.g., "high" → "alto") */
export function translateLevel(level: string, locale: string): string {
  return LEVEL_WORDS[locale]?.[level] ?? level;
}

/** Translate a timeline phrase (e.g., "This month" → "Este mes") */
export function translateTimeline(timeline: string, locale: string): string {
  return TIMELINE_PHRASES[locale]?.[timeline] ?? timeline;
}
