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

export const metadata = {
  title: "Kushtia to Dhaka Train Schedule 2026 | কুষ্টিয়া থেকে ঢাকা ট্রেনের সময়সূচী | Ticket Price & Booking",
  description:
    "Kushtia to Dhaka train schedule, ticket price, and time table 2026. Trains from Kushtia Court station via Padma Bridge. Book tickets online. কুষ্টিয়া থেকে ঢাকা ট্রেনের সময়সূচী ও ভাড়া।",
  keywords: [
    "kushtia to dhaka train",
    "kushtia to dhaka train schedule",
    "kushtia to dhaka ticket price",
    "kushtia to dhaka train time",
    "কুষ্টিয়া থেকে ঢাকা ট্রেন",
    "kushtia dhaka train",
    "kushtia court station train",
    "kushtia dhaka train schedule 2026",
  ],
  openGraph: {
    title: "Kushtia to Dhaka Train Schedule 2026 | Trains of Rajbari",
    description: "Complete Kushtia Court to Dhaka train schedule with ticket prices, booking info, and route details.",
    url: `${SITE_INFO.url}/kushtia-to-dhaka`,
    images: [{ url: "/logo.png" }],
  },
  alternates: { canonical: `${SITE_INFO.url}/kushtia-to-dhaka` },
};

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

  const schemas = [
    getTrainRouteSchema({
      fromStation: "Kushtia Court",
      toStation: "Dhaka",
      banglaFrom: "কুষ্টিয়া কোর্ট",
      banglaTo: "ঢাকা",
      distance: "200 km",
      duration: "4-5 hours",
      availableTrains: availableTrains.length,
      url: `${SITE_INFO.url}/kushtia-to-dhaka`,
    }),
    getRouteFAQSchema({
      fromStation: "Kushtia Court",
      toStation: "Dhaka",
      availableTrains: availableTrains.length,
      duration: "4-5 hours",
      distance: "200 km",
    }),
  ];

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