import { PrismaClient } from "@prisma/client";

const db = new PrismaClient();

async function main() {
  // Seed subscription packages
  await db.subscriptionPackage.upsert({
    where: { slug: "academician" },
    update: {},
    create: {
      name: "Academician Plan",
      slug: "academician",
      description:
        "Full access to Journals and Scholarships. Read, write, and explore academic content.",
      priceUsd: 49.0,
      priceNgn: 75000.0,
      billingPeriod: "monthly",
      module: "academician",
      isActive: true,
      features: [
        "Unlimited journal reading",
        "Write & publish journal posts",
        "Scholarship full details & apply links",
        "Monthly newsletter",
        "Cancel anytime",
      ],
    },
  });

  await db.subscriptionPackage.upsert({
    where: { slug: "job_seeker" },
    update: {},
    create: {
      name: "Job Seeker Plan",
      slug: "job_seeker",
      description:
        "Apply for jobs, build your resume, and track applications. Get hired faster.",
      priceUsd: 49.0,
      priceNgn: 75000.0,
      billingPeriod: "monthly",
      module: "job_seeker",
      isActive: true,
      features: [
        "Apply to unlimited jobs",
        "Resume builder & PDF download",
        "Application status tracking",
        "Job alert notifications",
        "Cancel anytime",
      ],
    },
  });

  // Seed default site settings
  const defaultSettings = [
    { key: "stripe_mode", value: "sandbox" },
    { key: "stripe_live_secret_key", value: "" },
    { key: "stripe_live_publishable_key", value: "" },
    { key: "stripe_live_webhook_secret", value: "" },
    { key: "stripe_sandbox_secret_key", value: "" },
    { key: "stripe_sandbox_publishable_key", value: "" },
    { key: "stripe_sandbox_webhook_secret", value: "" },
    { key: "site_name", value: "KC Systems Limited" },
    { key: "whatsapp_number", value: "+60188721718" },
    { key: "whatsapp_enabled", value: "true" },
  ];

  for (const setting of defaultSettings) {
    await db.siteSetting.upsert({
      where: { key: setting.key },
      update: {},
      create: setting,
    });
  }

  // ─── SHOP: CATEGORIES ────────────────────────────────────────────────────────

  const electronics = await db.productCategory.upsert({
    where: { slug: "electronics" },
    update: {},
    create: { name: "Electronics", slug: "electronics" },
  });

  const books = await db.productCategory.upsert({
    where: { slug: "books" },
    update: {},
    create: { name: "Books", slug: "books" },
  });

  const fashion = await db.productCategory.upsert({
    where: { slug: "fashion" },
    update: {},
    create: { name: "Fashion", slug: "fashion" },
  });

  const homeAndLiving = await db.productCategory.upsert({
    where: { slug: "home-and-living" },
    update: {},
    create: { name: "Home & Living", slug: "home-and-living" },
  });

  const accessories = await db.productCategory.upsert({
    where: { slug: "accessories" },
    update: {},
    create: { name: "Accessories", slug: "accessories" },
  });

  // ─── SHOP: SLIDER ────────────────────────────────────────────────────────────

  await db.shopSlide.upsert({
    where: { id: "shop-slide-1" },
    update: {},
    create: {
      id: "shop-slide-1",
      imageUrl: "https://images.unsplash.com/photo-1607082348824-0a96f2a4b9da?w=1200&h=500&fit=crop",
      title: "New Collection 2026",
      subtitle: "Discover our latest products at unbeatable prices",
      ctaText: "Shop Now",
      ctaLink: "/shop",
      sortOrder: 1,
      isActive: true,
    },
  });

  await db.shopSlide.upsert({
    where: { id: "shop-slide-2" },
    update: {},
    create: {
      id: "shop-slide-2",
      imageUrl: "https://images.unsplash.com/photo-1523275335684-37898b6baf30?w=1200&h=500&fit=crop",
      title: "Premium Quality Products",
      subtitle: "Curated selection for modern living",
      ctaText: "Browse",
      ctaLink: "/shop?cat=electronics",
      sortOrder: 2,
      isActive: true,
    },
  });

  await db.shopSlide.upsert({
    where: { id: "shop-slide-3" },
    update: {},
    create: {
      id: "shop-slide-3",
      imageUrl: "https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=1200&h=500&fit=crop",
      title: "Special Offers",
      subtitle: "Up to 50% off on selected items",
      ctaText: "View Deals",
      ctaLink: "/shop",
      sortOrder: 3,
      isActive: true,
    },
  });

  // ─── SHOP: PRODUCTS ──────────────────────────────────────────────────────────

  // Product 1: Wireless Headphones (Featured)
  const headphones = await db.product.upsert({
    where: { slug: "wireless-noise-cancelling-headphones" },
    update: {},
    create: {
      name: "Wireless Noise-Cancelling Headphones",
      slug: "wireless-noise-cancelling-headphones",
      description: "Premium wireless headphones with active noise cancellation, 30-hour battery life, and superior sound quality. Perfect for travel, work, and entertainment.",
      price: 299.99,
      stock: 50,
      isFeatured: true,
      isActive: true,
      categoryId: electronics.id,
    },
  });

  await db.productImage.createMany({
    data: [
      {
        productId: headphones.id,
        url: "https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=800&h=800&fit=crop",
        isPrimary: true,
        sortOrder: 1,
      },
      {
        productId: headphones.id,
        url: "https://images.unsplash.com/photo-1484704849700-f032a568e944?w=800&h=800&fit=crop",
        isPrimary: false,
        sortOrder: 2,
      },
    ],
    skipDuplicates: true,
  });

  // Product 2: Smart Watch (Featured)
  const smartwatch = await db.product.upsert({
    where: { slug: "fitness-smart-watch-pro" },
    update: {},
    create: {
      name: "Fitness Smart Watch Pro",
      slug: "fitness-smart-watch-pro",
      description: "Track your fitness goals with this advanced smartwatch. Features heart rate monitoring, GPS, sleep tracking, and 7-day battery life.",
      price: 249.99,
      stock: 75,
      isFeatured: true,
      isActive: true,
      categoryId: electronics.id,
    },
  });

  await db.productImage.createMany({
    data: [
      {
        productId: smartwatch.id,
        url: "https://images.unsplash.com/photo-1523275335684-37898b6baf30?w=800&h=800&fit=crop",
        isPrimary: true,
        sortOrder: 1,
      },
    ],
    skipDuplicates: true,
  });

  // Product 3: Laptop Stand
  const laptopStand = await db.product.upsert({
    where: { slug: "aluminum-laptop-stand" },
    update: {},
    create: {
      name: "Aluminum Laptop Stand",
      slug: "aluminum-laptop-stand",
      description: "Ergonomic laptop stand made from premium aluminum. Improves posture and provides better cooling for your device.",
      price: 49.99,
      stock: 120,
      isFeatured: false,
      isActive: true,
      categoryId: accessories.id,
    },
  });

  await db.productImage.createMany({
    data: [
      {
        productId: laptopStand.id,
        url: "https://images.unsplash.com/photo-1527864550417-7fd91fc51a46?w=800&h=800&fit=crop",
        isPrimary: true,
        sortOrder: 1,
      },
    ],
    skipDuplicates: true,
  });

  // Product 4: Business Book (Featured)
  const businessBook = await db.product.upsert({
    where: { slug: "the-lean-startup-guide" },
    update: {},
    create: {
      name: "The Lean Startup Guide",
      slug: "the-lean-startup-guide",
      description: "Master the art of building successful startups with proven strategies and real-world examples. A must-read for entrepreneurs.",
      price: 29.99,
      stock: 200,
      isFeatured: true,
      isActive: true,
      categoryId: books.id,
    },
  });

  await db.productImage.createMany({
    data: [
      {
        productId: businessBook.id,
        url: "https://images.unsplash.com/photo-1544947950-fa07a98d237f?w=800&h=800&fit=crop",
        isPrimary: true,
        sortOrder: 1,
      },
    ],
    skipDuplicates: true,
  });

  // Product 5: Desk Lamp
  const deskLamp = await db.product.upsert({
    where: { slug: "led-desk-lamp-adjustable" },
    update: {},
    create: {
      name: "LED Desk Lamp - Adjustable",
      slug: "led-desk-lamp-adjustable",
      description: "Modern LED desk lamp with adjustable brightness and color temperature. USB charging port included. Perfect for studying or working.",
      price: 39.99,
      stock: 85,
      isFeatured: false,
      isActive: true,
      categoryId: homeAndLiving.id,
    },
  });

  await db.productImage.createMany({
    data: [
      {
        productId: deskLamp.id,
        url: "https://images.unsplash.com/photo-1513506003901-1e6a229e2d15?w=800&h=800&fit=crop",
        isPrimary: true,
        sortOrder: 1,
      },
    ],
    skipDuplicates: true,
  });

  // Product 6: Backpack (Featured)
  const backpack = await db.product.upsert({
    where: { slug: "waterproof-travel-backpack" },
    update: {},
    create: {
      name: "Waterproof Travel Backpack",
      slug: "waterproof-travel-backpack",
      description: "Durable waterproof backpack with laptop compartment, USB charging port, and anti-theft design. Ideal for travel and daily commute.",
      price: 79.99,
      stock: 60,
      isFeatured: true,
      isActive: true,
      categoryId: fashion.id,
    },
  });

  await db.productImage.createMany({
    data: [
      {
        productId: backpack.id,
        url: "https://images.unsplash.com/photo-1553062407-98eeb64c6a62?w=800&h=800&fit=crop",
        isPrimary: true,
        sortOrder: 1,
      },
    ],
    skipDuplicates: true,
  });

  // Product 7: Wireless Mouse
  const mouse = await db.product.upsert({
    where: { slug: "ergonomic-wireless-mouse" },
    update: {},
    create: {
      name: "Ergonomic Wireless Mouse",
      slug: "ergonomic-wireless-mouse",
      description: "Comfortable ergonomic design reduces wrist strain. Silent clicks, precision tracking, and long battery life.",
      price: 34.99,
      stock: 150,
      isFeatured: false,
      isActive: true,
      categoryId: accessories.id,
    },
  });

  await db.productImage.createMany({
    data: [
      {
        productId: mouse.id,
        url: "https://images.unsplash.com/photo-1527814050087-3793815479db?w=800&h=800&fit=crop",
        isPrimary: true,
        sortOrder: 1,
      },
    ],
    skipDuplicates: true,
  });

  // Product 8: Coffee Maker
  const coffeeMaker = await db.product.upsert({
    where: { slug: "programmable-coffee-maker" },
    update: {},
    create: {
      name: "Programmable Coffee Maker",
      slug: "programmable-coffee-maker",
      description: "Wake up to fresh coffee every morning. 12-cup capacity, programmable timer, and auto shut-off feature.",
      price: 89.99,
      stock: 40,
      isFeatured: false,
      isActive: true,
      categoryId: homeAndLiving.id,
    },
  });

  await db.productImage.createMany({
    data: [
      {
        productId: coffeeMaker.id,
        url: "https://images.unsplash.com/photo-1517668808822-9ebb02f2a0e6?w=800&h=800&fit=crop",
        isPrimary: true,
        sortOrder: 1,
      },
    ],
    skipDuplicates: true,
  });

  // Product 9: Portable Speaker
  const speaker = await db.product.upsert({
    where: { slug: "bluetooth-portable-speaker" },
    update: {},
    create: {
      name: "Bluetooth Portable Speaker",
      slug: "bluetooth-portable-speaker",
      description: "Waterproof portable speaker with 360° sound, 20-hour battery, and premium audio quality. Perfect for outdoor adventures.",
      price: 129.99,
      stock: 95,
      isFeatured: false,
      isActive: true,
      categoryId: electronics.id,
    },
  });

  await db.productImage.createMany({
    data: [
      {
        productId: speaker.id,
        url: "https://images.unsplash.com/photo-1608043152269-423dbba4e7e1?w=800&h=800&fit=crop",
        isPrimary: true,
        sortOrder: 1,
      },
    ],
    skipDuplicates: true,
  });

  // Product 10: Notebook Set
  const notebooks = await db.product.upsert({
    where: { slug: "premium-notebook-set" },
    update: {},
    create: {
      name: "Premium Notebook Set (3-Pack)",
      slug: "premium-notebook-set",
      description: "High-quality notebooks with dotted pages, elastic closure, and inner pocket. Perfect for journaling, notes, or sketching.",
      price: 24.99,
      stock: 180,
      isFeatured: false,
      isActive: true,
      categoryId: accessories.id,
    },
  });

  await db.productImage.createMany({
    data: [
      {
        productId: notebooks.id,
        url: "https://images.unsplash.com/photo-1531346878377-a5be20888e57?w=800&h=800&fit=crop",
        isPrimary: true,
        sortOrder: 1,
      },
    ],
    skipDuplicates: true,
  });

  // Product 11: Yoga Mat
  const yogaMat = await db.product.upsert({
    where: { slug: "eco-friendly-yoga-mat" },
    update: {},
    create: {
      name: "Eco-Friendly Yoga Mat",
      slug: "eco-friendly-yoga-mat",
      description: "Non-slip, extra-thick yoga mat made from sustainable materials. Includes carrying strap. Perfect for yoga, pilates, and fitness.",
      price: 45.99,
      stock: 70,
      isFeatured: false,
      isActive: true,
      categoryId: accessories.id,
    },
  });

  await db.productImage.createMany({
    data: [
      {
        productId: yogaMat.id,
        url: "https://images.unsplash.com/photo-1601925260368-ae2f83cf8b7f?w=800&h=800&fit=crop",
        isPrimary: true,
        sortOrder: 1,
      },
    ],
    skipDuplicates: true,
  });

  // Product 12: Wall Clock
  const wallClock = await db.product.upsert({
    where: { slug: "modern-minimalist-wall-clock" },
    update: {},
    create: {
      name: "Modern Minimalist Wall Clock",
      slug: "modern-minimalist-wall-clock",
      description: "Sleek, silent wall clock with minimalist design. Perfect for home or office. Battery operated.",
      price: 32.99,
      stock: 110,
      isFeatured: false,
      isActive: true,
      categoryId: homeAndLiving.id,
    },
  });

  await db.productImage.createMany({
    data: [
      {
        productId: wallClock.id,
        url: "https://images.unsplash.com/photo-1563861826100-9cb868fdbe1c?w=800&h=800&fit=crop",
        isPrimary: true,
        sortOrder: 1,
      },
    ],
    skipDuplicates: true,
  });

  // ─── JOURNAL: CATEGORIES ─────────────────────────────────────────────────────

  const aiML = await db.journalCategory.upsert({
    where: { slug: "ai-machine-learning" },
    update: {},
    create: { name: "AI & Machine Learning", slug: "ai-machine-learning" },
  });

  const dataScience = await db.journalCategory.upsert({
    where: { slug: "data-science" },
    update: {},
    create: { name: "Data Science", slug: "data-science" },
  });

  const education = await db.journalCategory.upsert({
    where: { slug: "education" },
    update: {},
    create: { name: "Education", slug: "education" },
  });

  const engineering = await db.journalCategory.upsert({
    where: { slug: "engineering" },
    update: {},
    create: { name: "Engineering", slug: "engineering" },
  });

  // ─── JOURNAL: SLIDER ─────────────────────────────────────────────────────────

  await db.journalSlide.upsert({
    where: { id: "journal-slide-1" },
    update: {},
    create: {
      id: "journal-slide-1",
      imageUrl: "https://images.unsplash.com/photo-1454165804869-f19d39f1ed9e?w=1200&h=500&fit=crop",
      title: "Latest Research Publications",
      subtitle: "Access peer-reviewed academic journals and research papers",
      ctaText: "Browse Journals",
      ctaLink: "/journal",
      sortOrder: 1,
      isActive: true,
    },
  });

  await db.journalSlide.upsert({
    where: { id: "journal-slide-2" },
    update: {},
    create: {
      id: "journal-slide-2",
      imageUrl: "https://images.unsplash.com/photo-1523050854058-8df90110c9f1?w=1200&h=500&fit=crop",
      title: "Advance Your Research",
      subtitle: "Collaborate with leading scholars worldwide",
      ctaText: "Learn More",
      ctaLink: "/journal",
      sortOrder: 2,
      isActive: true,
    },
  });

  // ─── JOURNAL: PUBLICATIONS ───────────────────────────────────────────────────

  await db.publication.upsert({
    where: { id: "pub-ieee" },
    update: {},
    create: {
      id: "pub-ieee",
      name: "IEEE Xplore",
      description: "Leading database for electrical engineering, computer science, and electronics",
      websiteUrl: "https://ieeexplore.ieee.org",
      isActive: true,
      sortOrder: 1,
    },
  });

  await db.publication.upsert({
    where: { id: "pub-sciencedirect" },
    update: {},
    create: {
      id: "pub-sciencedirect",
      name: "ScienceDirect",
      description: "Full-text scientific articles from journals and books",
      websiteUrl: "https://www.sciencedirect.com",
      isActive: true,
      sortOrder: 2,
    },
  });

  await db.publication.upsert({
    where: { id: "pub-springer" },
    update: {},
    create: {
      id: "pub-springer",
      name: "Springer",
      description: "Academic journals, books, and conference proceedings",
      websiteUrl: "https://www.springer.com",
      isActive: true,
      sortOrder: 3,
    },
  });

  await db.publication.upsert({
    where: { id: "pub-sage" },
    update: {},
    create: {
      id: "pub-sage",
      name: "SAGE Journals",
      description: "World-class research across social sciences and humanities",
      websiteUrl: "https://journals.sagepub.com",
      isActive: true,
      sortOrder: 4,
    },
  });

  // ─── JOURNAL: TESTIMONIALS ───────────────────────────────────────────────────

  await db.journalTestimonial.upsert({
    where: { id: "testimonial-1" },
    update: {},
    create: {
      id: "testimonial-1",
      name: "Dr. Sarah Johnson",
      position: "Professor of Computer Science",
      company: "MIT",
      content: "KC Systems has revolutionized how we access academic research. The platform is intuitive and the journal collection is comprehensive.",
      rating: 5,
      isActive: true,
    },
  });

  await db.journalTestimonial.upsert({
    where: { id: "testimonial-2" },
    update: {},
    create: {
      id: "testimonial-2",
      name: "Prof. Michael Chen",
      position: "Research Director",
      company: "Stanford University",
      content: "Outstanding resource for academics. The search functionality and citation tools have saved me countless hours.",
      rating: 5,
      isActive: true,
    },
  });

  await db.journalTestimonial.upsert({
    where: { id: "testimonial-3" },
    update: {},
    create: {
      id: "testimonial-3",
      name: "Dr. Emily Williams",
      position: "Senior Lecturer",
      company: "Oxford University",
      content: "A must-have platform for any serious researcher. The collaboration features are exceptional.",
      rating: 5,
      isActive: true,
    },
  });

  // Create a default admin user for journal authoring
  const adminUser = await db.user.upsert({
    where: { email: "admin@kc-systems.com" },
    update: {},
    create: {
      email: "admin@kc-systems.com",
      name: "KC Systems Admin",
      password: "$2a$10$K7L1OJ45/4Y2nIvhRVpCe.FSmhDdWoXehVzJptJ/op0lSsvqNu/1u", // "password"
      role: "admin",
      emailVerified: new Date(),
    },
  });

  // ─── TICKETS: COUNTRIES & CITIES ─────────────────────────────────────────────

  const tMalaysia = await db.ticketCountry.upsert({
    where: { slug: "malaysia" },
    update: {},
    create: { id: "tc-malaysia", slug: "malaysia", name: "Malaysia", isActive: true },
  });
  const tSingapore = await db.ticketCountry.upsert({
    where: { slug: "singapore" },
    update: {},
    create: { id: "tc-singapore", slug: "singapore", name: "Singapore", isActive: true },
  });
  const tUAE = await db.ticketCountry.upsert({
    where: { slug: "uae" },
    update: {},
    create: { id: "tc-uae", slug: "uae", name: "United Arab Emirates", isActive: true },
  });
  const tUK = await db.ticketCountry.upsert({
    where: { slug: "uk" },
    update: {},
    create: { id: "tc-uk", slug: "uk", name: "United Kingdom", isActive: true },
  });
  const tAustralia = await db.ticketCountry.upsert({
    where: { slug: "australia" },
    update: {},
    create: { id: "tc-australia", slug: "australia", name: "Australia", isActive: true },
  });
  const tJapan = await db.ticketCountry.upsert({
    where: { slug: "japan" },
    update: {},
    create: { id: "tc-japan", slug: "japan", name: "Japan", isActive: true },
  });
  const tTurkey = await db.ticketCountry.upsert({
    where: { slug: "turkey" },
    update: {},
    create: { id: "tc-turkey", slug: "turkey", name: "Turkey", isActive: true },
  });
  const tSaudiArabia = await db.ticketCountry.upsert({
    where: { slug: "saudi-arabia" },
    update: {},
    create: { id: "tc-saudi-arabia", slug: "saudi-arabia", name: "Saudi Arabia", isActive: true },
  });

  // Malaysia cities
  for (const [id, name, slug] of [
    ["tcy-kl",    "Kuala Lumpur", "kuala-lumpur"],
    ["tcy-pg",    "Penang",       "penang"],
    ["tcy-jb",    "Johor Bahru",  "johor-bahru"],
    ["tcy-kch",   "Kuching",      "kuching"],
    ["tcy-kk",    "Kota Kinabalu","kota-kinabalu"],
  ]) {
    await db.ticketCity.upsert({
      where: { countryId_slug: { countryId: tMalaysia.id, slug: slug as string } },
      update: {},
      create: { id, countryId: tMalaysia.id, name: name as string, slug: slug as string, isActive: true },
    });
  }

  // Singapore
  await db.ticketCity.upsert({
    where: { countryId_slug: { countryId: tSingapore.id, slug: "singapore" } },
    update: {},
    create: { id: "tcy-sg", countryId: tSingapore.id, name: "Singapore", slug: "singapore", isActive: true },
  });
  await db.ticketCity.upsert({
    where: { countryId_slug: { countryId: tSingapore.id, slug: "changi" } },
    update: {},
    create: { id: "tcy-changi", countryId: tSingapore.id, name: "Changi", slug: "changi", isActive: true },
  });

  // UAE
  for (const [id, name, slug] of [
    ["tcy-dubai",    "Dubai",       "dubai"],
    ["tcy-abudhabi", "Abu Dhabi",   "abu-dhabi"],
    ["tcy-sharjah",  "Sharjah",     "sharjah"],
  ]) {
    await db.ticketCity.upsert({
      where: { countryId_slug: { countryId: tUAE.id, slug: slug as string } },
      update: {},
      create: { id, countryId: tUAE.id, name: name as string, slug: slug as string, isActive: true },
    });
  }

  // UK
  for (const [id, name, slug] of [
    ["tcy-london",     "London",       "london"],
    ["tcy-manchester", "Manchester",   "manchester"],
    ["tcy-birmingham", "Birmingham",   "birmingham"],
  ]) {
    await db.ticketCity.upsert({
      where: { countryId_slug: { countryId: tUK.id, slug: slug as string } },
      update: {},
      create: { id, countryId: tUK.id, name: name as string, slug: slug as string, isActive: true },
    });
  }

  // Australia
  for (const [id, name, slug] of [
    ["tcy-sydney",    "Sydney",     "sydney"],
    ["tcy-melbourne", "Melbourne",  "melbourne"],
    ["tcy-brisbane",  "Brisbane",   "brisbane"],
    ["tcy-perth",     "Perth",      "perth"],
  ]) {
    await db.ticketCity.upsert({
      where: { countryId_slug: { countryId: tAustralia.id, slug: slug as string } },
      update: {},
      create: { id, countryId: tAustralia.id, name: name as string, slug: slug as string, isActive: true },
    });
  }

  // Japan
  for (const [id, name, slug] of [
    ["tcy-tokyo",  "Tokyo",  "tokyo"],
    ["tcy-osaka",  "Osaka",  "osaka"],
    ["tcy-kyoto",  "Kyoto",  "kyoto"],
  ]) {
    await db.ticketCity.upsert({
      where: { countryId_slug: { countryId: tJapan.id, slug: slug as string } },
      update: {},
      create: { id, countryId: tJapan.id, name: name as string, slug: slug as string, isActive: true },
    });
  }

  // Turkey
  for (const [id, name, slug] of [
    ["tcy-istanbul", "Istanbul", "istanbul"],
    ["tcy-ankara",   "Ankara",   "ankara"],
  ]) {
    await db.ticketCity.upsert({
      where: { countryId_slug: { countryId: tTurkey.id, slug: slug as string } },
      update: {},
      create: { id, countryId: tTurkey.id, name: name as string, slug: slug as string, isActive: true },
    });
  }

  // Saudi Arabia
  for (const [id, name, slug] of [
    ["tcy-jeddah",  "Jeddah",  "jeddah"],
    ["tcy-riyadh",  "Riyadh",  "riyadh"],
    ["tcy-makkah",  "Makkah",  "makkah"],
    ["tcy-madinah", "Madinah", "madinah"],
  ]) {
    await db.ticketCity.upsert({
      where: { countryId_slug: { countryId: tSaudiArabia.id, slug: slug as string } },
      update: {},
      create: { id, countryId: tSaudiArabia.id, name: name as string, slug: slug as string, isActive: true },
    });
  }

  // ─── TICKETS: SLIDES ─────────────────────────────────────────────────────────

  await db.ticketSlide.upsert({
    where: { id: "tslide-1" },
    update: {},
    create: {
      id: "tslide-1",
      imageUrl: "https://images.unsplash.com/photo-1436491865332-7a61a109cc05?w=1800&q=80",
      title: "Book International Flights Easily",
      subtitle: "Tell us your route and dates. Our team will manually source the best fare options for you.",
      ctaText: "Create Request",
      ctaLink: "#ticket-request",
      sortOrder: 1,
      isActive: true,
    },
  });

  await db.ticketSlide.upsert({
    where: { id: "tslide-2" },
    update: {},
    create: {
      id: "tslide-2",
      imageUrl: "https://images.unsplash.com/photo-1483450388369-9ed95738483c?w=1800&q=80",
      title: "One-Way or Return Ticket Requests",
      subtitle: "Choose your trip type, cities, and travel dates. We handle the rest from our admin desk.",
      ctaText: "Start Search",
      ctaLink: "#ticket-request",
      sortOrder: 2,
      isActive: true,
    },
  });

  await db.ticketSlide.upsert({
    where: { id: "tslide-3" },
    update: {},
    create: {
      id: "tslide-3",
      imageUrl: "https://images.unsplash.com/photo-1517479149777-5f3b1511d5ad?w=1800&q=80",
      title: "Human Support for Every Booking",
      subtitle: "No auto checkout. Every request is reviewed by our team and followed up by email.",
      ctaText: "Request Now",
      ctaLink: "#ticket-request",
      sortOrder: 3,
      isActive: true,
    },
  });

  // ─── TICKETS: SAMPLE REQUESTS ─────────────────────────────────────────────────

  await db.ticketRequest.upsert({
    where: { id: "treq-1" },
    update: {},
    create: {
      id: "treq-1",
      fromCountryId: tMalaysia.id,
      fromCityId: "tcy-kl",
      toCountryId: tUAE.id,
      toCityId: "tcy-dubai",
      tripType: "return_trip",
      departureDate: new Date("2026-07-15"),
      returnDate: new Date("2026-07-22"),
      passengers: 2,
      cabinClass: "economy",
      name: "Ahmad Fauzi",
      email: "ahmad@example.com",
      phone: "+60123456789",
      message: "Preferred non-stop flight. Window seats if possible.",
      status: "new",
    },
  });

  await db.ticketRequest.upsert({
    where: { id: "treq-2" },
    update: {},
    create: {
      id: "treq-2",
      fromCountryId: tMalaysia.id,
      fromCityId: "tcy-kl",
      toCountryId: tUK.id,
      toCityId: "tcy-london",
      tripType: "one_way",
      departureDate: new Date("2026-08-01"),
      passengers: 1,
      cabinClass: "business",
      name: "Siti Noraini",
      email: "siti@example.com",
      phone: "+60198765432",
      message: "Business class required. Need halal meal option.",
      status: "in_progress",
    },
  });

  await db.ticketRequest.upsert({
    where: { id: "treq-3" },
    update: {},
    create: {
      id: "treq-3",
      fromCountryId: tSaudiArabia.id,
      fromCityId: "tcy-jeddah",
      toCountryId: tMalaysia.id,
      toCityId: "tcy-kl",
      tripType: "return_trip",
      departureDate: new Date("2026-09-10"),
      returnDate: new Date("2026-09-25"),
      passengers: 4,
      cabinClass: "economy",
      name: "Hassan Al-Rashid",
      email: "hassan@example.com",
      phone: "+966501234567",
      message: "Family of 4 (2 adults, 2 children). Extra baggage needed.",
      status: "resolved",
    },
  });

  console.log("✅ Seed complete!");
  console.log("  - Subscription packages: 2");
  console.log("  - Site settings: 10");
  console.log("  - Product categories: 5");
  console.log("  - Shop slides: 3");
  console.log("  - Products: 12 (5 featured)");
  console.log("  - Product images: 13");
  console.log("  - Journal categories: 4");
  console.log("  - Journal slides: 2");
  console.log("  - Publications: 4");
  console.log("  - Testimonials: 3");
  console.log("  - Admin user created");
  console.log("  - Ticket countries: 8, cities: 25");
  console.log("  - Ticket slides: 3");
  console.log("  - Ticket sample requests: 3");
}

main()
  .catch(console.error)
  .finally(() => db.$disconnect());
