/**
 * Sector Default Workflows
 *
 * Defines 1-2 default WhatsApp conversation workflows for each of the 12 sectors.
 * These are auto-seeded into a new organization during provisioning by
 * `lib/services/workflow-seeder.service.ts` and can be edited from the dashboard.
 *
 * Each workflow extends the base AI agent prompt with:
 *   - Trigger keywords / intent that activate it
 *   - Extra system-prompt instructions
 *   - A list of fields to collect from the customer
 *   - Optional bilingual confirmation message
 *
 * Arabic text uses authentic Qatari dialect (شنو, أبي, زين, وايد) where natural.
 */

import type { SectorKey } from "@/lib/config/industry-sector-map";

// ── Types ────────────────────────────────────────────────────────────────

export interface DefaultWorkflowField {
  key: string;
  labelEn: string;
  labelAr: string;
  type: "text" | "number" | "date" | "time" | "select" | "phone" | "email";
  required: boolean;
  options?: string[];
}

export interface DefaultWorkflow {
  name: string;
  description: string;
  triggerKeywords: string[];
  triggerIntent?: string;
  systemPromptAddition: string;
  collectFields: DefaultWorkflowField[];
  confirmationMessageEn?: string;
  confirmationMessageAr?: string;
  priority: number;
  language: "en" | "ar" | "both";
}

// ── Default Workflows by Sector ──────────────────────────────────────────

export const SECTOR_DEFAULT_WORKFLOWS: Record<SectorKey, DefaultWorkflow[]> = {
  // ── Health & Care ─────────────────────────────────────────────────────
  health_care: [
    {
      name: "Appointment Booking",
      description: "Guide patients through booking a medical appointment",
      triggerKeywords: [
        "book",
        "appointment",
        "schedule",
        "doctor",
        "clinic",
        "حجز",
        "موعد",
        "احجز",
        "دكتور",
        "عيادة",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "Guide the patient through booking a medical appointment. Ask which doctor or specialist they want to see, the symptom or reason for the visit, whether this is a new patient visit or a follow-up, and their preferred date and time. Be empathetic — they may be unwell.",
      collectFields: [
        {
          key: "doctor",
          labelEn: "Doctor / Specialist",
          labelAr: "الطبيب / الأخصائي",
          type: "text",
          required: false,
        },
        {
          key: "reason",
          labelEn: "Reason for visit",
          labelAr: "سبب الزيارة",
          type: "text",
          required: true,
        },
        {
          key: "visitType",
          labelEn: "Visit type",
          labelAr: "نوع الزيارة",
          type: "select",
          required: false,
          options: ["new", "follow-up"],
        },
        {
          key: "date",
          labelEn: "Preferred date",
          labelAr: "التاريخ المفضل",
          type: "date",
          required: true,
        },
        {
          key: "time",
          labelEn: "Preferred time",
          labelAr: "الوقت المفضل",
          type: "time",
          required: true,
        },
      ],
      confirmationMessageEn:
        "Your appointment request has been received. We will confirm shortly.",
      confirmationMessageAr:
        "تم استلام طلب الموعد. بنأكد لك قريباً إن شاء الله.",
      priority: 10,
      language: "both",
    },
    {
      name: "Appointment Status Check",
      description: "Help patients check or modify an existing appointment",
      triggerKeywords: [
        "my appointment",
        "check appointment",
        "reschedule",
        "cancel appointment",
        "موعدي",
        "تأجيل",
        "إلغاء الموعد",
      ],
      triggerIntent: "check_status",
      systemPromptAddition:
        "The patient is asking about an existing appointment. Look up their bookings by phone, show upcoming visits, and ask whether they want to reschedule, cancel, or just confirm the time. Be reassuring.",
      collectFields: [
        {
          key: "action",
          labelEn: "What would you like to do?",
          labelAr: "شنو تبي تسوي؟",
          type: "select",
          required: true,
          options: ["confirm", "reschedule", "cancel"],
        },
        {
          key: "newDate",
          labelEn: "New preferred date",
          labelAr: "التاريخ الجديد",
          type: "date",
          required: false,
        },
        {
          key: "newTime",
          labelEn: "New preferred time",
          labelAr: "الوقت الجديد",
          type: "time",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Got it — we will update your appointment and confirm shortly.",
      confirmationMessageAr: "تمام، بنحدّث موعدك ونأكد لك قريب.",
      priority: 8,
      language: "both",
    },
  ],

  // ── Beauty & Wellness ─────────────────────────────────────────────────
  beauty_wellness: [
    {
      name: "Service Booking",
      description: "Guide customers through booking a salon or spa service",
      triggerKeywords: [
        "book",
        "appointment",
        "haircut",
        "color",
        "facial",
        "massage",
        "manicure",
        "حجز",
        "قص",
        "صبغة",
        "فيشل",
        "مساج",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "Guide the customer through booking a beauty or wellness service. Ask which service they want (haircut, color, facial, massage, etc.), preferred stylist or therapist if they have one, whether they have allergies or sensitivities, and the date and time they prefer.",
      collectFields: [
        {
          key: "service",
          labelEn: "Service",
          labelAr: "الخدمة",
          type: "text",
          required: true,
        },
        {
          key: "stylist",
          labelEn: "Preferred stylist / therapist",
          labelAr: "المختص المفضل",
          type: "text",
          required: false,
        },
        {
          key: "allergies",
          labelEn: "Allergies or sensitivities",
          labelAr: "حساسية أو ملاحظات",
          type: "text",
          required: false,
        },
        {
          key: "date",
          labelEn: "Preferred date",
          labelAr: "التاريخ المفضل",
          type: "date",
          required: true,
        },
        {
          key: "time",
          labelEn: "Preferred time",
          labelAr: "الوقت المفضل",
          type: "time",
          required: true,
        },
      ],
      confirmationMessageEn:
        "Your booking request has been received. We will confirm your slot shortly.",
      confirmationMessageAr: "تم استلام حجزك، بنأكد لك الموعد عن قريب.",
      priority: 10,
      language: "both",
    },
    {
      name: "Service Cancellation",
      description: "Handle salon / spa cancellation requests politely",
      triggerKeywords: [
        "cancel",
        "cant come",
        "can't make it",
        "إلغاء",
        "ما أقدر أجي",
        "ألغي",
      ],
      triggerIntent: "amend_appointment",
      systemPromptAddition:
        "The customer wants to cancel a salon / spa booking. Confirm which appointment, ask the reason (optional, for service quality feedback), and offer to reschedule before cancelling outright.",
      collectFields: [
        {
          key: "appointmentDate",
          labelEn: "Appointment date",
          labelAr: "تاريخ الموعد",
          type: "date",
          required: true,
        },
        {
          key: "reason",
          labelEn: "Reason (optional)",
          labelAr: "السبب (اختياري)",
          type: "text",
          required: false,
        },
        {
          key: "rebookLater",
          labelEn: "Would you like to rebook?",
          labelAr: "تبي تحجز موعد ثاني؟",
          type: "select",
          required: false,
          options: ["yes", "no"],
        },
      ],
      confirmationMessageEn:
        "Your request has been received. The team will follow up shortly.",
      confirmationMessageAr: "وصلنا طلبك، فريقنا بيتواصل معاك قريب.",
      priority: 7,
      language: "both",
    },
  ],

  // ── Food, Hospitality & Stays ─────────────────────────────────────────
  food_hospitality: [
    {
      name: "Table Reservation",
      description: "Guide customers through booking a restaurant table",
      triggerKeywords: [
        "reservation",
        "reserve",
        "table",
        "book a table",
        "dinner",
        "lunch",
        "حجز طاولة",
        "حجز",
        "عشاء",
        "غداء",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "Guide the customer through booking a table. Ask for the number of guests, preferred date and time, indoor or outdoor seating, any dietary restrictions, and whether the reservation is for a special occasion.",
      collectFields: [
        {
          key: "partySize",
          labelEn: "Number of guests",
          labelAr: "عدد الضيوف",
          type: "number",
          required: true,
        },
        {
          key: "date",
          labelEn: "Date",
          labelAr: "التاريخ",
          type: "date",
          required: true,
        },
        {
          key: "time",
          labelEn: "Time",
          labelAr: "الوقت",
          type: "time",
          required: true,
        },
        {
          key: "seating",
          labelEn: "Seating preference",
          labelAr: "نوع الجلسة",
          type: "select",
          required: false,
          options: ["indoor", "outdoor", "no preference"],
        },
        {
          key: "occasion",
          labelEn: "Special occasion",
          labelAr: "مناسبة خاصة",
          type: "text",
          required: false,
        },
        {
          key: "dietaryNotes",
          labelEn: "Dietary restrictions",
          labelAr: "ملاحظات غذائية",
          type: "text",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Your reservation request has been received. We will confirm your table shortly.",
      confirmationMessageAr: "تم استلام طلب الحجز، بنأكد لك الطاولة عن قريب.",
      priority: 10,
      language: "both",
    },
    {
      name: "Catering / Group Inquiry",
      description: "Handle catering requests and large-group inquiries",
      triggerKeywords: [
        "catering",
        "private event",
        "group booking",
        "buffet",
        "بوفيه",
        "حجز جماعي",
        "ضيافة",
      ],
      triggerIntent: "quotation_request",
      systemPromptAddition:
        "The customer is asking about catering or a large group booking. Collect the event date, expected headcount, venue, cuisine preferences, and budget range so the team can prepare a quote.",
      collectFields: [
        {
          key: "eventDate",
          labelEn: "Event date",
          labelAr: "تاريخ المناسبة",
          type: "date",
          required: true,
        },
        {
          key: "headcount",
          labelEn: "Expected number of guests",
          labelAr: "عدد الضيوف المتوقع",
          type: "number",
          required: true,
        },
        {
          key: "venue",
          labelEn: "Venue / address",
          labelAr: "المكان / العنوان",
          type: "text",
          required: false,
        },
        {
          key: "cuisine",
          labelEn: "Cuisine preference",
          labelAr: "نوع المطبخ",
          type: "text",
          required: false,
        },
        {
          key: "budget",
          labelEn: "Budget per person",
          labelAr: "الميزانية للشخص",
          type: "text",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Thanks! Our events team will prepare a quote and reach out shortly.",
      confirmationMessageAr:
        "شكراً، فريق المناسبات بيجهّز لك عرض سعر ويتواصل معاك قريب.",
      priority: 7,
      language: "both",
    },
  ],

  // ── Retail & Services ─────────────────────────────────────────────────
  retail_services: [
    {
      name: "Product Consultation",
      description: "Schedule a product consultation or store visit",
      triggerKeywords: [
        "consultation",
        "product",
        "demo",
        "store visit",
        "appointment",
        "استشارة",
        "زيارة المعرض",
        "موعد",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "Guide the customer through booking a product consultation or store visit. Ask which product or category they are interested in, their budget range, and a preferred date / time for the consultation.",
      collectFields: [
        {
          key: "productInterest",
          labelEn: "Product / category of interest",
          labelAr: "المنتج أو الفئة",
          type: "text",
          required: true,
        },
        {
          key: "budget",
          labelEn: "Budget range",
          labelAr: "الميزانية",
          type: "text",
          required: false,
        },
        {
          key: "date",
          labelEn: "Preferred date",
          labelAr: "التاريخ المفضل",
          type: "date",
          required: true,
        },
        {
          key: "time",
          labelEn: "Preferred time",
          labelAr: "الوقت المفضل",
          type: "time",
          required: true,
        },
      ],
      confirmationMessageEn:
        "Your consultation request has been received. We will confirm shortly.",
      confirmationMessageAr: "تم استلام طلب الاستشارة، بنأكد لك قريب.",
      priority: 10,
      language: "both",
    },
    {
      name: "Order Status Inquiry",
      description: "Help customers check the status of an order",
      triggerKeywords: [
        "order",
        "delivery",
        "shipment",
        "where is my",
        "tracking",
        "طلبي",
        "توصيل",
        "وين طلبي",
      ],
      triggerIntent: "check_status",
      systemPromptAddition:
        "The customer is asking about the status of an existing order. Ask for the order number or the phone number used at checkout, and the date the order was placed.",
      collectFields: [
        {
          key: "orderNumber",
          labelEn: "Order number",
          labelAr: "رقم الطلب",
          type: "text",
          required: false,
        },
        {
          key: "orderDate",
          labelEn: "Order date",
          labelAr: "تاريخ الطلب",
          type: "date",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Thanks — we will look up your order and get back to you shortly.",
      confirmationMessageAr: "شكراً، بنشيك على طلبك ونرد عليك قريب.",
      priority: 6,
      language: "both",
    },
  ],

  // ── Property & Facilities ─────────────────────────────────────────────
  property_facilities: [
    {
      name: "Viewing Request",
      description: "Schedule a property viewing",
      triggerKeywords: [
        "viewing",
        "see the property",
        "visit",
        "tour",
        "apartment",
        "villa",
        "معاينة",
        "زيارة",
        "شقة",
        "فيلا",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "The customer wants to view a property. Ask which property or listing they are interested in, whether they want to rent or buy, their budget, and the date / time they prefer to visit.",
      collectFields: [
        {
          key: "propertyId",
          labelEn: "Property / listing",
          labelAr: "العقار / الإعلان",
          type: "text",
          required: true,
        },
        {
          key: "intent",
          labelEn: "Rent or buy",
          labelAr: "إيجار أو شراء",
          type: "select",
          required: true,
          options: ["rent", "buy"],
        },
        {
          key: "budget",
          labelEn: "Budget",
          labelAr: "الميزانية",
          type: "text",
          required: false,
        },
        {
          key: "date",
          labelEn: "Preferred viewing date",
          labelAr: "تاريخ المعاينة",
          type: "date",
          required: true,
        },
        {
          key: "time",
          labelEn: "Preferred viewing time",
          labelAr: "وقت المعاينة",
          type: "time",
          required: true,
        },
      ],
      confirmationMessageEn:
        "Your viewing request has been received. An agent will confirm shortly.",
      confirmationMessageAr: "تم استلام طلب المعاينة، الوكيل بيأكد لك قريب.",
      priority: 10,
      language: "both",
    },
    {
      name: "Maintenance Request",
      description: "Log a maintenance or facilities request",
      triggerKeywords: [
        "maintenance",
        "broken",
        "leak",
        "ac not working",
        "repair",
        "صيانة",
        "خراب",
        "تسريب",
        "تكييف",
      ],
      triggerIntent: "general",
      systemPromptAddition:
        "The customer is reporting a maintenance issue. Collect the unit / property address, a description of the issue, urgency level, and a window when the technician can visit.",
      collectFields: [
        {
          key: "unit",
          labelEn: "Unit / address",
          labelAr: "الوحدة / العنوان",
          type: "text",
          required: true,
        },
        {
          key: "issue",
          labelEn: "Describe the issue",
          labelAr: "اشرح المشكلة",
          type: "text",
          required: true,
        },
        {
          key: "urgency",
          labelEn: "Urgency",
          labelAr: "مستوى الإلحاح",
          type: "select",
          required: true,
          options: ["low", "medium", "high", "emergency"],
        },
        {
          key: "visitWindow",
          labelEn: "Preferred visit window",
          labelAr: "وقت الزيارة المناسب",
          type: "text",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Your maintenance request has been logged. The team will reach out shortly.",
      confirmationMessageAr: "تم تسجيل طلب الصيانة، الفريق بيتواصل معاك قريب.",
      priority: 8,
      language: "both",
    },
  ],

  // ── Mobility & Automotive ─────────────────────────────────────────────
  mobility_automotive: [
    {
      name: "Vehicle Rental Inquiry",
      description: "Handle vehicle rental requests",
      triggerKeywords: [
        "rent",
        "rental",
        "car",
        "vehicle",
        "suv",
        "إيجار",
        "سيارة",
        "تأجير",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "Guide the customer through a vehicle rental inquiry. Ask which vehicle type or model they want, pickup and return dates, pickup location, and whether they need a driver or extras (insurance, child seat, GPS).",
      collectFields: [
        {
          key: "vehicleType",
          labelEn: "Vehicle type / model",
          labelAr: "نوع السيارة / الموديل",
          type: "text",
          required: true,
        },
        {
          key: "pickupDate",
          labelEn: "Pickup date",
          labelAr: "تاريخ الاستلام",
          type: "date",
          required: true,
        },
        {
          key: "returnDate",
          labelEn: "Return date",
          labelAr: "تاريخ التسليم",
          type: "date",
          required: true,
        },
        {
          key: "pickupLocation",
          labelEn: "Pickup location",
          labelAr: "مكان الاستلام",
          type: "text",
          required: true,
        },
        {
          key: "withDriver",
          labelEn: "With driver?",
          labelAr: "مع سائق؟",
          type: "select",
          required: false,
          options: ["yes", "no"],
        },
        {
          key: "extras",
          labelEn: "Extras (insurance, GPS, child seat)",
          labelAr: "إضافات",
          type: "text",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Your rental request has been received. We will confirm availability shortly.",
      confirmationMessageAr: "تم استلام طلب الإيجار، بنأكد لك التوفر قريب.",
      priority: 10,
      language: "both",
    },
    {
      name: "Service & Repair Booking",
      description: "Book a vehicle service or repair appointment",
      triggerKeywords: [
        "service",
        "oil change",
        "repair",
        "workshop",
        "صيانة",
        "زيت",
        "ورشة",
        "تصليح",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "The customer wants to book a vehicle service or repair. Ask for the make, model, year, the issue or service needed, and the preferred drop-off date.",
      collectFields: [
        {
          key: "make",
          labelEn: "Make",
          labelAr: "الماركة",
          type: "text",
          required: true,
        },
        {
          key: "model",
          labelEn: "Model",
          labelAr: "الموديل",
          type: "text",
          required: true,
        },
        {
          key: "year",
          labelEn: "Year",
          labelAr: "السنة",
          type: "number",
          required: false,
        },
        {
          key: "issue",
          labelEn: "Issue / service needed",
          labelAr: "المشكلة / نوع الصيانة",
          type: "text",
          required: true,
        },
        {
          key: "dropOffDate",
          labelEn: "Drop-off date",
          labelAr: "تاريخ التسليم",
          type: "date",
          required: true,
        },
      ],
      confirmationMessageEn:
        "Your service request has been received. We will confirm a slot shortly.",
      confirmationMessageAr: "تم استلام طلب الصيانة، بنأكد لك الموعد قريب.",
      priority: 8,
      language: "both",
    },
  ],

  // ── Home Services & Trades ────────────────────────────────────────────
  home_services_trades: [
    {
      name: "Service Request",
      description: "Schedule a home service visit",
      triggerKeywords: [
        "plumber",
        "electrician",
        "cleaning",
        "ac",
        "pest",
        "سباك",
        "كهربائي",
        "تنظيف",
        "تكييف",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "The customer needs a home service. Ask which service is needed, a description of the work, the location / address, and the preferred visit date and time window.",
      collectFields: [
        {
          key: "serviceType",
          labelEn: "Service type",
          labelAr: "نوع الخدمة",
          type: "text",
          required: true,
        },
        {
          key: "description",
          labelEn: "Describe the work needed",
          labelAr: "اشرح الشغل المطلوب",
          type: "text",
          required: true,
        },
        {
          key: "address",
          labelEn: "Address",
          labelAr: "العنوان",
          type: "text",
          required: true,
        },
        {
          key: "date",
          labelEn: "Preferred date",
          labelAr: "التاريخ المفضل",
          type: "date",
          required: true,
        },
        {
          key: "timeWindow",
          labelEn: "Preferred time window",
          labelAr: "الفترة المفضلة",
          type: "text",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Your service request has been received. A technician will be assigned shortly.",
      confirmationMessageAr: "تم استلام طلبك، بنخصص لك فني قريب إن شاء الله.",
      priority: 10,
      language: "both",
    },
    {
      name: "Quotation Request",
      description: "Collect details for a home services quote",
      triggerKeywords: [
        "quote",
        "estimate",
        "how much",
        "price",
        "تسعيرة",
        "كم السعر",
        "عرض سعر",
      ],
      triggerIntent: "quotation_request",
      systemPromptAddition:
        "The customer is requesting a quote for a job. Collect the service type, scope of work, property size if relevant, and the timeline so the team can prepare an accurate estimate.",
      collectFields: [
        {
          key: "serviceType",
          labelEn: "Service type",
          labelAr: "نوع الخدمة",
          type: "text",
          required: true,
        },
        {
          key: "scope",
          labelEn: "Scope of work",
          labelAr: "نطاق العمل",
          type: "text",
          required: true,
        },
        {
          key: "propertySize",
          labelEn: "Property size",
          labelAr: "حجم العقار",
          type: "text",
          required: false,
        },
        {
          key: "timeline",
          labelEn: "Timeline",
          labelAr: "الجدول الزمني",
          type: "text",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Thanks! We will prepare a quote and send it shortly.",
      confirmationMessageAr: "شكراً، بنجهز لك العرض ونرسله لك قريب.",
      priority: 7,
      language: "both",
    },
  ],

  // ── Education ─────────────────────────────────────────────────────────
  education: [
    {
      name: "Course Enrollment",
      description: "Guide students through enrolling in a course",
      triggerKeywords: [
        "enroll",
        "enrol",
        "course",
        "class",
        "register",
        "تسجيل",
        "دورة",
        "كورس",
        "حصة",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "The customer wants to enroll in a course or class. Ask which course / program they are interested in, the student's name and age (if a minor), level / experience, and preferred schedule.",
      collectFields: [
        {
          key: "course",
          labelEn: "Course / program",
          labelAr: "الدورة / البرنامج",
          type: "text",
          required: true,
        },
        {
          key: "studentName",
          labelEn: "Student name",
          labelAr: "اسم الطالب",
          type: "text",
          required: true,
        },
        {
          key: "studentAge",
          labelEn: "Student age",
          labelAr: "عمر الطالب",
          type: "number",
          required: false,
        },
        {
          key: "level",
          labelEn: "Current level",
          labelAr: "المستوى الحالي",
          type: "text",
          required: false,
        },
        {
          key: "schedule",
          labelEn: "Preferred schedule",
          labelAr: "الجدول المفضل",
          type: "text",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Your enrollment request has been received. The admissions team will contact you shortly.",
      confirmationMessageAr:
        "تم استلام طلب التسجيل، فريق القبول بيتواصل معاك قريب.",
      priority: 10,
      language: "both",
    },
    {
      name: "Trial Class Request",
      description: "Schedule a free trial class",
      triggerKeywords: [
        "trial",
        "free class",
        "try",
        "demo",
        "تجريبي",
        "حصة تجريبية",
        "مجاني",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "The customer wants to try a free trial class. Ask which course / class they want to try, the student's name and age, and a preferred date / time.",
      collectFields: [
        {
          key: "course",
          labelEn: "Course / class",
          labelAr: "الدورة / الحصة",
          type: "text",
          required: true,
        },
        {
          key: "studentName",
          labelEn: "Student name",
          labelAr: "اسم الطالب",
          type: "text",
          required: true,
        },
        {
          key: "studentAge",
          labelEn: "Student age",
          labelAr: "عمر الطالب",
          type: "number",
          required: false,
        },
        {
          key: "date",
          labelEn: "Preferred date",
          labelAr: "التاريخ المفضل",
          type: "date",
          required: true,
        },
        {
          key: "time",
          labelEn: "Preferred time",
          labelAr: "الوقت المفضل",
          type: "time",
          required: true,
        },
      ],
      confirmationMessageEn:
        "Your trial class request has been received. We will confirm a slot shortly.",
      confirmationMessageAr:
        "تم استلام طلب الحصة التجريبية، بنأكد لك الموعد قريب.",
      priority: 8,
      language: "both",
    },
  ],

  // ── Events & Venues ───────────────────────────────────────────────────
  events_venues: [
    {
      name: "Venue Inquiry",
      description: "Handle inquiries about venue availability and pricing",
      triggerKeywords: [
        "venue",
        "hall",
        "wedding",
        "event",
        "party",
        "conference",
        "قاعة",
        "حفل",
        "زفاف",
        "مناسبة",
        "مؤتمر",
      ],
      triggerIntent: "quotation_request",
      systemPromptAddition:
        "The customer is asking about a venue for an event. Collect the event type, expected number of guests, preferred date(s), required setup (catering, AV, decoration), and budget if they are willing to share.",
      collectFields: [
        {
          key: "eventType",
          labelEn: "Event type",
          labelAr: "نوع المناسبة",
          type: "text",
          required: true,
        },
        {
          key: "guestCount",
          labelEn: "Expected number of guests",
          labelAr: "عدد الضيوف المتوقع",
          type: "number",
          required: true,
        },
        {
          key: "eventDate",
          labelEn: "Preferred event date",
          labelAr: "التاريخ المفضل",
          type: "date",
          required: true,
        },
        {
          key: "setup",
          labelEn: "Required setup (catering, AV, decor)",
          labelAr: "المتطلبات (ضيافة، صوتيات، ديكور)",
          type: "text",
          required: false,
        },
        {
          key: "budget",
          labelEn: "Budget",
          labelAr: "الميزانية",
          type: "text",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Thanks! Our events team will check availability and reach out shortly.",
      confirmationMessageAr:
        "شكراً، فريق المناسبات بيشيك على التوفر ويتواصل معاك قريب.",
      priority: 10,
      language: "both",
    },
    {
      name: "Site Visit Booking",
      description: "Schedule a venue site visit",
      triggerKeywords: [
        "site visit",
        "see the venue",
        "tour",
        "visit",
        "زيارة",
        "معاينة القاعة",
        "أشوف المكان",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "The customer wants to visit the venue in person. Confirm which venue (if there are multiple), the date and time of the visit, and how many people will join the tour.",
      collectFields: [
        {
          key: "venue",
          labelEn: "Venue",
          labelAr: "المكان",
          type: "text",
          required: false,
        },
        {
          key: "date",
          labelEn: "Visit date",
          labelAr: "تاريخ الزيارة",
          type: "date",
          required: true,
        },
        {
          key: "time",
          labelEn: "Visit time",
          labelAr: "وقت الزيارة",
          type: "time",
          required: true,
        },
        {
          key: "groupSize",
          labelEn: "Number of visitors",
          labelAr: "عدد الزوار",
          type: "number",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Your site visit request has been received. We will confirm shortly.",
      confirmationMessageAr: "تم استلام طلب الزيارة، بنأكد لك قريب.",
      priority: 8,
      language: "both",
    },
  ],

  // ── Pet Services ──────────────────────────────────────────────────────
  pet_services: [
    {
      name: "Pet Appointment Booking",
      description: "Schedule a pet grooming, vet, or boarding appointment",
      triggerKeywords: [
        "appointment",
        "vet",
        "grooming",
        "boarding",
        "dog",
        "cat",
        "موعد",
        "بيطري",
        "قص شعر",
        "حلاقة",
        "كلب",
        "قطة",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "The customer wants to book an appointment for their pet. Ask the pet's name, species and breed, age, the service needed (vet checkup, vaccination, grooming, boarding), and the preferred date / time.",
      collectFields: [
        {
          key: "petName",
          labelEn: "Pet name",
          labelAr: "اسم الحيوان",
          type: "text",
          required: true,
        },
        {
          key: "species",
          labelEn: "Species",
          labelAr: "النوع",
          type: "select",
          required: true,
          options: ["dog", "cat", "bird", "rabbit", "other"],
        },
        {
          key: "breed",
          labelEn: "Breed",
          labelAr: "السلالة",
          type: "text",
          required: false,
        },
        {
          key: "age",
          labelEn: "Age (years)",
          labelAr: "العمر (سنوات)",
          type: "number",
          required: false,
        },
        {
          key: "service",
          labelEn: "Service needed",
          labelAr: "الخدمة المطلوبة",
          type: "text",
          required: true,
        },
        {
          key: "date",
          labelEn: "Preferred date",
          labelAr: "التاريخ المفضل",
          type: "date",
          required: true,
        },
        {
          key: "time",
          labelEn: "Preferred time",
          labelAr: "الوقت المفضل",
          type: "time",
          required: true,
        },
      ],
      confirmationMessageEn:
        "Your pet appointment request has been received. We will confirm shortly.",
      confirmationMessageAr: "تم استلام موعد الحيوان، بنأكد لك قريب.",
      priority: 10,
      language: "both",
    },
    {
      name: "Boarding Inquiry",
      description: "Handle pet boarding / hotel inquiries",
      triggerKeywords: [
        "boarding",
        "pet hotel",
        "stay",
        "leave my dog",
        "فندق حيوانات",
        "إقامة",
      ],
      triggerIntent: "quotation_request",
      systemPromptAddition:
        "The customer is asking about pet boarding. Ask the pet's species and size, the check-in / check-out dates, vaccination status, and any special needs (medication, diet).",
      collectFields: [
        {
          key: "species",
          labelEn: "Species",
          labelAr: "النوع",
          type: "text",
          required: true,
        },
        {
          key: "size",
          labelEn: "Size",
          labelAr: "الحجم",
          type: "select",
          required: false,
          options: ["small", "medium", "large"],
        },
        {
          key: "checkInDate",
          labelEn: "Check-in date",
          labelAr: "تاريخ الدخول",
          type: "date",
          required: true,
        },
        {
          key: "checkOutDate",
          labelEn: "Check-out date",
          labelAr: "تاريخ الخروج",
          type: "date",
          required: true,
        },
        {
          key: "vaccinated",
          labelEn: "Up to date on vaccinations?",
          labelAr: "التطعيمات محدّثة؟",
          type: "select",
          required: false,
          options: ["yes", "no", "not sure"],
        },
        {
          key: "specialNeeds",
          labelEn: "Special needs (diet, medication)",
          labelAr: "احتياجات خاصة",
          type: "text",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Your boarding request has been received. We will confirm availability shortly.",
      confirmationMessageAr: "تم استلام طلب الإقامة، بنأكد لك التوفر قريب.",
      priority: 7,
      language: "both",
    },
  ],

  // ── Nonprofit & Community ─────────────────────────────────────────────
  nonprofit_community: [
    {
      name: "Program Registration",
      description: "Register participants for community programs",
      triggerKeywords: [
        "register",
        "join",
        "program",
        "workshop",
        "event",
        "تسجيل",
        "أنضم",
        "برنامج",
        "ورشة",
        "فعالية",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "The customer wants to register for a community program or workshop. Collect the program name, the participant's name and age, contact info, and any accessibility needs.",
      collectFields: [
        {
          key: "programName",
          labelEn: "Program / workshop name",
          labelAr: "اسم البرنامج / الورشة",
          type: "text",
          required: true,
        },
        {
          key: "participantName",
          labelEn: "Participant name",
          labelAr: "اسم المشارك",
          type: "text",
          required: true,
        },
        {
          key: "participantAge",
          labelEn: "Participant age",
          labelAr: "عمر المشارك",
          type: "number",
          required: false,
        },
        {
          key: "accessibility",
          labelEn: "Accessibility needs",
          labelAr: "احتياجات إمكانية الوصول",
          type: "text",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Your registration has been received. We will confirm your spot shortly.",
      confirmationMessageAr: "تم استلام التسجيل، بنأكد لك مكانك قريب.",
      priority: 10,
      language: "both",
    },
    {
      name: "Volunteer Signup",
      description: "Collect details from prospective volunteers",
      triggerKeywords: [
        "volunteer",
        "help",
        "donate time",
        "تطوع",
        "أتطوع",
        "مساعدة",
      ],
      triggerIntent: "general",
      systemPromptAddition:
        "The customer wants to volunteer. Ask their name, areas of interest, available days / hours, and any relevant skills or experience.",
      collectFields: [
        {
          key: "interestArea",
          labelEn: "Area of interest",
          labelAr: "مجال الاهتمام",
          type: "text",
          required: true,
        },
        {
          key: "availability",
          labelEn: "Available days / hours",
          labelAr: "الأوقات المتاحة",
          type: "text",
          required: true,
        },
        {
          key: "skills",
          labelEn: "Skills / experience",
          labelAr: "المهارات / الخبرة",
          type: "text",
          required: false,
        },
      ],
      confirmationMessageEn:
        "Thanks for offering to volunteer! Our team will reach out shortly.",
      confirmationMessageAr: "شكراً لك على رغبتك بالتطوع، الفريق بيتواصل معاك قريب.",
      priority: 7,
      language: "both",
    },
  ],

  // ── Public Sector ─────────────────────────────────────────────────────
  public_sector: [
    {
      name: "Service Appointment",
      description: "Book a public service appointment",
      triggerKeywords: [
        "appointment",
        "service",
        "document",
        "permit",
        "license",
        "موعد",
        "خدمة",
        "وثيقة",
        "تصريح",
        "رخصة",
      ],
      triggerIntent: "booking_request",
      systemPromptAddition:
        "The citizen wants to book a public service appointment. Ask which service they need, their national ID or reference number if applicable, and a preferred date and time. Be formal and respectful.",
      collectFields: [
        {
          key: "serviceType",
          labelEn: "Service type",
          labelAr: "نوع الخدمة",
          type: "text",
          required: true,
        },
        {
          key: "referenceNumber",
          labelEn: "Reference / ID number",
          labelAr: "الرقم المرجعي / الهوية",
          type: "text",
          required: false,
        },
        {
          key: "date",
          labelEn: "Preferred date",
          labelAr: "التاريخ المفضل",
          type: "date",
          required: true,
        },
        {
          key: "time",
          labelEn: "Preferred time",
          labelAr: "الوقت المفضل",
          type: "time",
          required: true,
        },
      ],
      confirmationMessageEn:
        "Your appointment request has been received. We will confirm shortly.",
      confirmationMessageAr: "تم استلام طلب الموعد، بنأكد لك قريب.",
      priority: 10,
      language: "both",
    },
    {
      name: "Document Inquiry",
      description: "Handle inquiries about required documents and procedures",
      triggerKeywords: [
        "documents",
        "what do i need",
        "requirements",
        "procedure",
        "وثائق",
        "شو أحتاج",
        "متطلبات",
        "إجراءات",
      ],
      triggerIntent: "company_query",
      systemPromptAddition:
        "The citizen is asking about required documents or procedures. Use the knowledge base to answer accurately. If you don't have the information, ask which exact service they need it for and offer to escalate to a human officer.",
      collectFields: [
        {
          key: "serviceType",
          labelEn: "Service type",
          labelAr: "نوع الخدمة",
          type: "text",
          required: true,
        },
      ],
      confirmationMessageEn:
        "Thanks — we will share the requirements shortly.",
      confirmationMessageAr: "شكراً، بنشارك معاك المتطلبات قريب.",
      priority: 6,
      language: "both",
    },
  ],
};

// ── Helpers ──────────────────────────────────────────────────────────────

/**
 * Resolve the default workflows for a sector. Falls back to retail_services
 * for unknown sectors so we always have at least one workflow available.
 */
export function getDefaultWorkflows(sector: SectorKey): DefaultWorkflow[] {
  return (
    SECTOR_DEFAULT_WORKFLOWS[sector] ??
    SECTOR_DEFAULT_WORKFLOWS.retail_services ??
    []
  );
}
