export type PwaLang = "fa" | "en";

export const PWA_THEME_COLOR = "#FF107D";
export const PWA_BACKGROUND_COLOR = "#FF107D";
export const PWA_ID = "modstagram-pwa";
export const PWA_VERSION = "11";

export { resolvePwaLang, toPwaLang } from "@/lib/i18n/pwaLang";

const COPY = {
  fa: {
    name: "مدستاگرام",
    short_name: "مدستاگرام",
    description: "شبکه تخصصی مدل، عکاس و آرایشگر",
    lang: "fa",
    dir: "rtl" as const,
    installTitle: "نصب اپلیکیشن مدستاگرام",
    installDescription:
      "برای دسترسی سریع‌تر و تجربه شبیه اپ موبایل، مدستاگرام را روی گوشی یا سیستم خود نصب کنید.",
    installButton: "نصب اپلیکیشن",
    installing: "در حال نصب...",
    later: "بعداً",
    gotIt: "متوجه شدم",
    ok: "باشه",
    close: "بستن",
    iosSteps: [
      "دکمه Share (مربع با فلش) را در Safari بزنید.",
      "گزینه «Add to Home Screen» یا «افزودن به صفحه اصلی» را انتخاب کنید.",
      "در بالا «Add» یا «افزودن» را بزنید.",
    ],
  },
  en: {
    name: "Modstagram",
    short_name: "Modstagram",
    description: "Professional network for models, photographers and makeup artists",
    lang: "en",
    dir: "ltr" as const,
    installTitle: "Install Modstagram",
    installDescription:
      "Install Modstagram on your device for faster access and an app-like experience.",
    installButton: "Install app",
    installing: "Installing...",
    later: "Later",
    gotIt: "Got it",
    ok: "OK",
    close: "Close",
    iosSteps: [
      "Tap the Share button (square with arrow) in Safari.",
      "Choose “Add to Home Screen”.",
      "Tap “Add” in the top corner.",
    ],
  },
};

export function getPwaLabels(lang: PwaLang) {
  return COPY[lang];
}

export function buildWebManifest(lang: PwaLang) {
  const labels = getPwaLabels(lang);

  return {
    name: labels.name,
    short_name: labels.short_name,
    description: labels.description,
    lang: labels.lang,
    dir: labels.dir,
    scope: "/",
    start_url: `/?source=pwa&lang=${lang}`,
    id: PWA_ID,
    display: "standalone",
    display_override: ["standalone", "minimal-ui", "browser"],
    orientation: "portrait-primary",
    prefer_related_applications: false,
    theme_color: PWA_THEME_COLOR,
    background_color: PWA_BACKGROUND_COLOR,
    categories: ["social", "business"],
    icons: [
      {
        src: "/images/icons/192x192.png",
        sizes: "192x192",
        type: "image/png",
        purpose: "any",
      },
      {
        src: "/images/icons/256x256.png",
        sizes: "256x256",
        type: "image/png",
        purpose: "any",
      },
      {
        src: "/images/icons/512x512.png",
        sizes: "512x512",
        type: "image/png",
        purpose: "any",
      },
      {
        src: "/images/icons/maskable-192.png",
        sizes: "192x192",
        type: "image/png",
        purpose: "maskable",
      },
      {
        src: "/images/icons/maskable-512.png",
        sizes: "512x512",
        type: "image/png",
        purpose: "maskable",
      },
    ],
  };
}
