export const emergencyNotification =
  "⚠️ Emergency Alert: Due to heavy fog, all morning trains might be delayed by 30-60 minutes. Please check with the station master for live updates. Stay safe!";

export const trainTypes = [
  {
    id: 1,
    title: "Intercity Trains",
    description:
      "Fast, comfortable, and connecting major cities. The premium choice for long-distance travel.",
    vibe: "✨ Premium & Fast",
    icon: "🚅",
    color: "bg-blue-100 text-blue-700 border-blue-200",
  },
  {
    id: 2,
    title: "Mail/Express",
    description:
      "The lifeline of local commute, stopping at more stations to serve the community.",
    vibe: "🚋 Local & Connected",
    icon: "🚂",
    color: "bg-emerald-100 text-emerald-700 border-emerald-200",
  },
  {
    id: 3,
    title: "Commuter",
    description:
      "Frequent daily service for office goers and students. Always on time, always reliable.",
    vibe: "🏙️ Daily Hustle",
    icon: "🚆",
    color: "bg-purple-100 text-purple-700 border-purple-200",
  },
];

export const stations = [
  {
    id: "rajbari",
    name: "Rajbari Railway Station",
    description:
      "The central hub connecting the district to the rest of the country. A historic station with modern amenities.",
    image: "/stations/rajbari/1.jpg",
    badge: "Central Hub",
  },
  {
    id: "pangsha",
    name: "Pangsha Railway Station",
    description:
      "A vital station serving the western part of Rajbari. Known for its busy morning market commute.",
    image: "/stations/pangsha/1.jpg",
    badge: "Key Junction",
  },
  {
    id: "kalukhali",
    name: "Kalukhali Junction",
    description:
      "The connecting point for the Bhatiapara line. A scenic station surrounded by greenery.",
    image: "/stations/kalukhali/1.jpg",
    badge: "Scenic Stop",
  },
  {
    id: "pachuria",
    name: "Pachuria Junction Railway Station",
    description:
      "The connecting point for the Goalanda and Dhaka lines. A scenic station surrounded by greenery.",
    image: "/stations/pachuria/1.jpg",
    badge: "Scenic Stop",
  },
];

// Utility function to get station image with fallback to logo
export const getStationImage = (stationId) => {
  const stationImageMap = {
    rajbari: "/stations/rajbari/1.jpg",
    pangsha: "/stations/pangsha/1.jpg",
    kalukhali: "/stations/kalukhali/1.jpg",
    pachuria: "/stations/pachuria/1.jpg",
    goalondo_bazar: "/logo-circle.png",
    goalondo_ghat: "/logo-circle.png",
    surjanagar: "/logo-circle.png",
    belgachi: "/logo-circle.png",
  };

  return (
    stationImageMap[stationId.toLowerCase().replace(/_/g, "")] ||
    "/logo-circle.png"
  );
};

import trainData from "./trainData.json";

const getOffDay = (days) => {
  const allDays = ["Fri", "Sat", "Sun", "Mon", "Tue", "Wed", "Thu"];
  const offDays = allDays.filter((day) => !days.includes(day));
  return offDays.length > 0 ? offDays.join(", ") : "None";
};

export const rajbariStations = [
  "Dhaka",
  "Pachuria",
  "Rajbari",
  "Goalondo_Bazar",
  "Goalondo_Ghat",
  "Surjanagar",
  "Belgachi",
  "Kalukhali",
  "Pangsha",
  "Machpara",
  "Naliagram",
  "Arkandi",
  "Baharpur",
  "Ramdia",
  "Khankhanapur",
  "Boshontopur",
];

export { trainData };

// Build schedule for ALL stations in all train routes
export const schedule = trainData.flatMap((trainItem, index) => {
  const { data } = trainItem;
  const trainName = data.train_name
    .split("(")[0]
    .trim()
    .toLowerCase()
    .replace(/\b\w/g, (c) => c.toUpperCase());

  const trainNumberMatch = data.train_name.match(/\((\d+)\)/);
  const trainNumber = trainNumberMatch ? trainNumberMatch[1] : "";

  const slug = data.train_name
    .replace(/\s+/g, "-")
    .toLowerCase()
    .replace(/[()]/g, "");

  const offDay = getOffDay(data.days);

  // Generate entry for EVERY stop in the route
  return data.routes.map((stationStop, stopIndex) => {
    const stationId = stationStop.city.toLowerCase().replace(/_/g, "");
    const displayStationName = stationStop.city
      .replace(/_/g, " ")
      .replace(/\b\w/g, (c) => c.toUpperCase());

    const finalDestination = data.routes[data.routes.length - 1];
    const startStation = data.routes[0];

    const isTerminating = !stationStop.departure_time;
    const routeDisplay = isTerminating
      ? `${startStation.city.replace(/_/g, " ")} - ${displayStationName}`
      : `${displayStationName} - ${finalDestination.city.replace(/_/g, " ")}`;

    return {
      id: `${stationId}-${index}-${stopIndex}`,
      name: trainName,
      trainNumber: trainNumber,
      slug: slug,
      route: routeDisplay,
      departure: stationStop.departure_time
        ? stationStop.departure_time
          .replace(" am BST", " AM")
          .replace(" pm BST", " PM")
        : "Terminates",
      arrival: stationStop.arrival_time
        ? stationStop.arrival_time
          .replace(" am BST", " AM")
          .replace(" pm BST", " PM")
        : "Start",
      offDay: offDay,
      station: stationId,
    };
  });
});

// All unique stations from train data (for UI)
export const allStationsList = (() => {
  const citySet = new Map();
  trainData.forEach((train) => {
    train.data.routes.forEach((route) => {
      const id = route.city.toLowerCase().replace(/_/g, "");
      if (!citySet.has(id)) {
        const label = route.city.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
        citySet.set(id, { id, label });
      }
    });
  });
  return Array.from(citySet.values()).sort((a, b) => a.label.localeCompare(b.label));
})();

// Social Media Links
export const socialLinks = {
  facebookGroup: "https://www.facebook.com/groups/trainsofrajbari",
  facebookPage: "https://www.facebook.com/TrainSOfRajbari/",
  youtube: "https://www.youtube.com/@TrainSOfRajbari",
};

import trainImages from "./trainImages.json";

export const galleryItems = Object.entries(trainImages).flatMap(
  ([trainName, images]) =>
    images.map((src, index) => ({
      id: `${trainName.replace(/\s+/g, "-").toLowerCase()}-${index}`,
      src,
      alt: `${trainName} - Image ${index + 1}`,
      category: trainName,
    })),
);

export const videos = [
  {
    id: 1,
    title: "Raninagar Railway Station",
    videoId: "tuSCkMFpMmg",
    thumbnail: "https://img.youtube.com/vi/tuSCkMFpMmg/maxresdefault.jpg",
  },
  {
    id: 2,
    title: "Train Journey Experience",
    videoId: "R6Pd45E4JoA",
    thumbnail: "https://img.youtube.com/vi/R6Pd45E4JoA/maxresdefault.jpg",
  },
  {
    id: 3,
    title: "Train Short #1",
    videoId: "F-Xbt2vOHr0",
    thumbnail: "https://img.youtube.com/vi/F-Xbt2vOHr0/maxresdefault.jpg",
  },
  {
    id: 4,
    title: "Train Short #2",
    videoId: "7HrFQRYBkkE",
    thumbnail: "https://img.youtube.com/vi/7HrFQRYBkkE/maxresdefault.jpg",
  },
  {
    id: 5,
    title: "Rajbari Railway Journey",
    videoId: "PEQJ0t3qP3I",
    thumbnail: "https://img.youtube.com/vi/PEQJ0t3qP3I/maxresdefault.jpg",
  },
];

// Team Members
export const teamMembers = {
  founder: {
    name: "Ziaul Haque Pappu",
    role: "Founder",
    type: "founder",
    bio: "Founded Trains of Rajbari community in 2023 to connect railway enthusiasts.",
    image: "/team/pappu.jpg",
  },
  admins: [
    {
      name: "TI Tamim",
      role: "Admin Panel",
      type: "admin",
      bio: "Managing community operations and content moderation.",
      image: "/team/ti_tamim.jpg",
    },
    {
      name: "Rony Ahmed",
      role: "Admin Panel",
      type: "admin",
      bio: "Coordinating train schedules, updates and content moderation",
      image: "/team/rony_ahmed.jpg",
    },
    {
      name: "Rafiul Islam",
      role: "Admin Panel",
      type: "admin",
      bio: "Coordinating train schedules, updates and content moderation",
      image: "/team/rafiul_islam.jpg",
    },
    {
      name: "Abdul Hamid",
      role: "Admin Panel",
      type: "admin",
      bio: "Coordinating train schedules, updates and content moderation",
      image: "/team/abdul_hamid.jpg",
    },
    {
      name: "Md Robin",
      role: "Admin Panel",
      type: "admin",
      bio: "Coordinating train schedules, updates and content moderation",
      image: "/team/md_robin.jpg",
    },
    {
      name: "Md Rohan",
      role: "Admin Panel",
      type: "admin",
      bio: "Coordinating train schedules, updates and content moderation",
      image: "/team/md_rohan.jpg",
    },
    {
      name: "Nure Jannat Sujana",
      role: "Admin Panel",
      type: "admin",
      bio: "Coordinating train schedules, updates and content moderation",
      image: "/team/nure_jannat_sujana.jpg",
    },
    {
      name: "Abu Ishak",
      role: "Admin Panel",
      type: "admin",
      bio: "Coordinating train schedules, updates and content moderation",
      image: "/team/abu_ishak.jpg",
    },
    {
      name: "Tipu Sultan",
      role: "Admin Panel",
      type: "admin",
      bio: "Coordinating train schedules, updates and content moderation",
      image: "/team/tipu_sultan.jpg",
    },
    {
      name: "Topu Shaikh",
      role: "Admin Panel",
      type: "admin",
      bio: "Coordinating train schedules, updates and content moderation",
      image: "/team/topu_shaikh.jpg",
    },
    {
      name: "Serajul Islam Tuhin",
      role: "Admin Panel",
      type: "admin",
      bio: "Coordinating train schedules, updates and content moderation",
      image: "/team/serajul_islam_tuhin.jpg",
    },
  ],
  moderators: [
    // {
    //     name: "Moderator 1",
    //     role: "Moderator",
    //     type: "moderator",
    //     bio: "Assisting with community engagement and support.",
    //     image: "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Placeholder_view_vector.svg/330px-Placeholder_view_vector.svg.png"
    // },
  ],
};
