import type { TierId } from "@/lib/types/pricing";

export interface FeatureRow {
  en: string;
  ar: string;
  availability: TierId[];
}

export const FEATURE_MATRIX: FeatureRow[] = [
  {
    en: "AI Agent",
    ar: "وكيل ذكي",
    availability: ["tier1", "tier2", "tier3", "tier4", "tier5"],
  },
  {
    en: "Auto Booking",
    ar: "حجز آلي",
    availability: ["tier1", "tier2", "tier3", "tier4", "tier5"],
  },
  {
    en: "Dashboard",
    ar: "لوحة تحكم",
    availability: ["tier1", "tier2", "tier3", "tier4", "tier5"],
  },
  {
    en: "Quotations",
    ar: "عروض أسعار",
    availability: ["tier2", "tier3", "tier4", "tier5"],
  },
  {
    en: "CRM",
    ar: "إدارة علاقات",
    availability: ["tier2", "tier3", "tier4", "tier5"],
  },
  {
    en: "Deposits",
    ar: "مقدمات",
    availability: ["tier2", "tier3", "tier4", "tier5"],
  },
  {
    en: "Multi-Staff",
    ar: "موظفين متعددين",
    availability: ["tier3", "tier4", "tier5"],
  },
  {
    en: "Voice AI",
    ar: "ذكاء صوتي",
    availability: ["tier3", "tier4", "tier5"],
  },
  {
    en: "Recurring Appointments",
    ar: "مواعيد متكررة",
    availability: ["tier3", "tier4", "tier5"],
  },
  {
    en: "Social Management",
    ar: "إدارة التواصل",
    availability: ["tier4", "tier5"],
  },
  {
    en: "Trend Analysis",
    ar: "تحليل اتجاهات",
    availability: ["tier4", "tier5"],
  },
  { en: "Lead Generation", ar: "توليد عملاء", availability: ["tier5"] },
  { en: "Lead Scoring", ar: "تقييم عملاء", availability: ["tier5"] },
  {
    en: "White-Label Options",
    ar: "خيارات العلامة البيضاء",
    availability: ["tier5"],
  },
  { en: "24/7 Support", ar: "دعم على مدار الساعة", availability: ["tier5"] },
];

/**
 * Helper to check if a feature is available for a tier
 */
export function isFeatureAvailable(featureEn: string, tierId: TierId): boolean {
  const feature = FEATURE_MATRIX.find((f) => f.en === featureEn);
  return feature?.availability.includes(tierId) ?? false;
}
