import { trainData } from "@/data";
import { getTrainRouteSchema, getRouteFAQSchema, SITE_INFO } from "@/lib/schemas";
import RajbariToDhakaClient from "./RajbariToDhakaClient";

export const metadata = {
  title: "Rajbari to Dhaka Train Schedule 2026 | রাজবাড়ী থেকে ঢাকা ট্রেনের সময়সূচী | Ticket Price & Booking",
  description:
    "Rajbari to Dhaka train schedule, ticket price, and time table 2026. Multiple trains daily including Sundarban Express, Benapole Express. Book tickets online. রাজবাড়ী থেকে ঢাকা ট্রেনের সময়সূচী ও ভাড়া।",
  keywords: [
    "rajbari to dhaka train",
    "rajbari to dhaka train schedule",
    "rajbari to dhaka ticket price",
    "rajbari to dhaka train time",
    "রাজবাড়ী থেকে ঢাকা ট্রেন",
    "rajbari dhaka train",
    "dhaka train from rajbari",
    "sundarban express rajbari to dhaka",
    "benapole express schedule",
  ],
  openGraph: {
    title: "Rajbari to Dhaka Train Schedule 2026 | Trains of Rajbari",
    description:
      "Complete Rajbari to Dhaka train schedule with ticket prices, booking info, and route details.",
    url: `${SITE_INFO.url}/rajbari-to-dhaka`,
    images: [{ url: "/logo.png" }],
  },
  alternates: {
    canonical: `${SITE_INFO.url}/rajbari-to-dhaka`,
  },
};

export default function RajbariToDhakaPage() {
  const availableTrains = trainData.filter((t) => {
    const routes = t.data.routes;
    const sourceIndex = routes.findIndex(
      (r) => r.city.toLowerCase().replace(/_/g, "") === "rajbari"
    );
    const destIndex = routes.findIndex(
      (r) => r.city.toLowerCase().replace(/_/g, "") === "dhaka"
    );
    return sourceIndex !== -1 && destIndex !== -1 && destIndex > sourceIndex;
  });

  const schemas = [
    getTrainRouteSchema({
      fromStation: "Rajbari",
      toStation: "Dhaka",
      banglaFrom: "রাজবাড়ী",
      banglaTo: "ঢাকা",
      distance: "150 km",
      duration: "3-4 hours",
      availableTrains: availableTrains.length,
      url: `${SITE_INFO.url}/rajbari-to-dhaka`,
    }),
    getRouteFAQSchema({
      fromStation: "Rajbari",
      toStation: "Dhaka",
      availableTrains: availableTrains.length,
      duration: "3-4 hours",
      distance: "150 km",
    }),
  ];

  return (
    <>
      {schemas.map((schema, i) => (
        <script
          key={i}
          type="application/ld+json"
          dangerouslySetInnerHTML={{ __html: JSON.stringify(schema) }}
        />
      ))}
      <RajbariToDhakaClient />
    </>
  );
}
