export type PredictionTheme = "boy" | "girl";

function normalizeText(value: string) {
  return value
    .trim()
    .toLowerCase()
    .normalize("NFD")
    .replace(/[\u0300-\u036f]/g, "");
}

export function getThemeFromSexValue(value: string | null | undefined): PredictionTheme | null {
  if (!value) {
    return null;
  }

  const normalized = normalizeText(value);

  if (normalized === "fille" || normalized === "girl") {
    return "girl";
  }

  if (normalized === "garcon" || normalized === "boy") {
    return "boy";
  }

  return null;
}