import type { Locale } from "./site";

export function librarySegment(locale: Locale) {
  return locale === "fr" ? "bibliotheque" : "knowledge";
}

export function libraryPath(locale: Locale, slug?: string) {
  const base = `/${locale}/${librarySegment(locale)}/`;
  return slug ? `${base}${slug}/` : base;
}

export function isLibrarySegment(value: string) {
  return value === "bibliotheque" || value === "knowledge";
}

const articleTranslations = [
  { fr: "comment-choisir-agence-communication-fes", en: "how-to-choose-marketing-agency-fez" },
  { fr: "services-agence-communication-entreprise", en: "marketing-agency-services" },
  { fr: "importance-video-strategie-marketing", en: "video-marketing-strategy" },
  { fr: "seo-local-google-fes", en: "local-seo-google-fez" },
  { fr: "prix-agence-communication-maroc", en: "marketing-agency-cost-morocco" },
  { fr: "personal-branding-visibilite-clients", en: "personal-branding-visibility-clients" },
] as const;

export function localizedLibraryArticlePath(
  sourceLocale: Locale,
  sourceSlug: string,
  targetLocale: Locale,
) {
  if (targetLocale === "ar") return libraryPath("ar");
  const translation = articleTranslations.find((entry) => entry[sourceLocale === "fr" ? "fr" : "en"] === sourceSlug);
  return translation ? libraryPath(targetLocale, translation[targetLocale]) : libraryPath(targetLocale);
}
