import type { Lang } from "@/lib/config";

// Category configuration
export const CATEGORIES = [
  {
    value: "product",
    label: "Product Launch",
    labelAr: "إطلاق منتج",
    color: "bg-blue-100 text-blue-700",
  },
  {
    value: "feature",
    label: "New Feature",
    labelAr: "ميزة جديدة",
    color: "bg-purple-100 text-purple-700",
  },
  {
    value: "service",
    label: "Service",
    labelAr: "خدمة",
    color: "bg-green-100 text-green-700",
  },
  {
    value: "event",
    label: "Event",
    labelAr: "حدث",
    color: "bg-amber-100 text-amber-700",
  },
  {
    value: "help",
    label: "Help/Support",
    labelAr: "مساعدة/دعم",
    color: "bg-pink-100 text-pink-700",
  },
  {
    value: "general",
    label: "General",
    labelAr: "عام",
    color: "bg-slate-100 text-slate-700",
  },
] as const;

export interface PublicWaitlist {
  id: string;
  title: string;
  titleAr: string | null;
  description: string | null;
  descriptionAr: string | null;
  category?: string;
  createdAt: string;
  signupCount: number;
  isSignedUp: boolean;
}

export interface MyWaitlist {
  id: string;
  title: string;
  titleAr: string | null;
  description: string | null;
  descriptionAr: string | null;
  category: string;
  isActive: boolean;
  isPublic: boolean;
  createdAt: string;
  updatedAt: string;
  signupCount: number;
  isOwner: boolean;
}

export interface WaitlistSignup {
  id: string;
  name: string;
  email: string;
  mobile: string;
  notes?: string | null;
  createdAt: string;
}

export interface WaitlistFormData {
  title: string;
  titleAr: string;
  description: string;
  descriptionAr: string;
  category: string;
  isPublic: boolean;
}

export interface SignupFormData {
  name: string;
  email: string;
  mobile: string;
}

export interface AddUserFormData {
  name: string;
  email: string;
  mobile: string;
  notes: string;
}

export interface WaitlistsPanelSession {
  user?: {
    name?: string | null;
    email?: string | null;
  } | null;
}

export type ViewMode = "browse" | "my-waitlists" | "view-signups" | "add-user";

// Translation strings interface
export interface WaitlistTranslations {
  // Page titles
  title: string;
  browseTab: string;
  myWaitlistsTab: string;
  subtitle: string;
  mySubtitle: string;

  // Empty states
  noWaitlists: string;
  noMyWaitlists: string;
  noSignups: string;

  // Actions
  createWaitlist: string;
  joinWaitlist: string;
  addUser: string;
  viewSignups: string;
  edit: string;
  delete: string;
  save: string;
  cancel: string;
  back: string;
  confirm: string;

  // Status
  alreadyJoined: string;
  signups: string;
  active: string;
  inactive: string;
  public: string;
  private: string;

  // Form labels
  titleLabel: string;
  titleArLabel: string;
  descriptionLabel: string;
  descriptionArLabel: string;
  categoryLabel: string;
  isPublicLabel: string;
  name: string;
  email: string;
  mobile: string;
  notes: string;

  // Messages
  successCreated: string;
  successUpdated: string;
  successDeleted: string;
  successSignup: string;
  successUserAdded: string;
  successUserRemoved: string;
  errorGeneric: string;
  alreadySignedUp: string;
  deleteConfirmTitle: string;
  deleteConfirmMessage: string;
  deleteUserConfirm: string;

  // Signups view
  signupsTitle: string;
  addedOn: string;
}

// Helper function to get category info
export function getCategoryInfo(categoryValue: string) {
  return CATEGORIES.find((c) => c.value === categoryValue) || CATEGORIES[5];
}

// Create translations based on language
export function createTranslations(lang: Lang): WaitlistTranslations {
  const isAr = lang === "ar";

  return {
    // Page titles
    title: isAr ? "قوائم الانتظار" : "Waitlists",
    browseTab: isAr ? "تصفح" : "Browse",
    myWaitlistsTab: isAr ? "قوائمي" : "My Waitlists",
    subtitle: isAr
      ? "سجّل لتكون أول من يعرف عن الميزات والخدمات الجديدة"
      : "Sign up to be first to know about new features and services",
    mySubtitle: isAr
      ? "أنشئ وأدر قوائم الانتظار الخاصة بك"
      : "Create and manage your own waitlists",

    // Empty states
    noWaitlists: isAr
      ? "لا توجد قوائم انتظار متاحة حاليًا"
      : "No waitlists available right now",
    noMyWaitlists: isAr
      ? "لم تنشئ أي قوائم انتظار بعد"
      : "You haven't created any waitlists yet",
    noSignups: isAr
      ? "لا يوجد مسجلين في هذه القائمة بعد"
      : "No signups yet for this waitlist",

    // Actions
    createWaitlist: isAr ? "إنشاء قائمة انتظار" : "Create Waitlist",
    joinWaitlist: isAr ? "انضم للقائمة" : "Join Waitlist",
    addUser: isAr ? "إضافة مستخدم" : "Add User",
    viewSignups: isAr ? "عرض المسجلين" : "View Signups",
    edit: isAr ? "تعديل" : "Edit",
    delete: isAr ? "حذف" : "Delete",
    save: isAr ? "حفظ" : "Save",
    cancel: isAr ? "إلغاء" : "Cancel",
    back: isAr ? "رجوع" : "Back",
    confirm: isAr ? "تأكيد" : "Confirm",

    // Status
    alreadyJoined: isAr ? "مسجّل" : "Joined",
    signups: isAr ? "مسجّل" : "signed up",
    active: isAr ? "نشط" : "Active",
    inactive: isAr ? "غير نشط" : "Inactive",
    public: isAr ? "عام" : "Public",
    private: isAr ? "خاص" : "Private",

    // Form labels
    titleLabel: isAr ? "العنوان" : "Title",
    titleArLabel: isAr ? "العنوان (بالعربية)" : "Title (Arabic)",
    descriptionLabel: isAr ? "الوصف" : "Description",
    descriptionArLabel: isAr ? "الوصف (بالعربية)" : "Description (Arabic)",
    categoryLabel: isAr ? "الفئة" : "Category",
    isPublicLabel: isAr ? "عام (مرئي للجميع)" : "Public (visible to everyone)",
    name: isAr ? "الاسم" : "Name",
    email: isAr ? "البريد الإلكتروني" : "Email",
    mobile: isAr ? "رقم الجوال" : "Mobile Number",
    notes: isAr ? "ملاحظات" : "Notes",

    // Messages
    successCreated: isAr
      ? "تم إنشاء القائمة بنجاح!"
      : "Waitlist created successfully!",
    successUpdated: isAr
      ? "تم تحديث القائمة بنجاح!"
      : "Waitlist updated successfully!",
    successDeleted: isAr
      ? "تم حذف القائمة بنجاح!"
      : "Waitlist deleted successfully!",
    successSignup: isAr ? "تم التسجيل بنجاح!" : "Successfully signed up!",
    successUserAdded: isAr
      ? "تم إضافة المستخدم بنجاح!"
      : "User added successfully!",
    successUserRemoved: isAr
      ? "تم حذف المستخدم بنجاح!"
      : "User removed successfully!",
    errorGeneric: isAr
      ? "حدث خطأ. حاول مرة أخرى."
      : "Something went wrong. Please try again.",
    alreadySignedUp: isAr
      ? "أنت مسجّل بالفعل في هذه القائمة"
      : "You are already signed up for this waitlist",
    deleteConfirmTitle: isAr ? "تأكيد الحذف" : "Confirm Delete",
    deleteConfirmMessage: isAr
      ? "هل أنت متأكد من حذف هذه القائمة؟ سيتم حذف جميع المسجلين أيضًا."
      : "Are you sure you want to delete this waitlist? All signups will also be deleted.",
    deleteUserConfirm: isAr
      ? "هل أنت متأكد من حذف هذا المستخدم من القائمة؟"
      : "Are you sure you want to remove this user from the waitlist?",

    // Signups view
    signupsTitle: isAr ? "المسجلين" : "Signups",
    addedOn: isAr ? "تاريخ التسجيل" : "Added on",
  };
}
