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

const FROM = "kalukhali";
const TO = "dhaka";

export const metadata = {
  title: "Kalukhali to Dhaka Train Schedule & Ticket Price | কালুখালী থেকে ঢাকা",
  description: "Kalukhali to Dhaka train schedule, ticket price, and time table. Check all trains from Kalukhali to Dhaka. কালুখালী থেকে ঢাকা ট্রেনের সময়সূচী।",
  keywords: ["Kalukhali to Dhaka train", "Kalukhali to Dhaka train schedule", "Kalukhali to Dhaka ticket price", "কালুখালী থেকে ঢাকা", "trains of rajbari", "bangladesh railway schedule"],
  openGraph: {
    title: "Kalukhali to Dhaka Train Schedule | Trains of Rajbari",
    description: "Complete Kalukhali to Dhaka train schedule with ticket prices and route details.",
    url: `${SITE_INFO.url}/kalukhali-to-dhaka`,
  },
  alternates: { canonical: `${SITE_INFO.url}/kalukhali-to-dhaka` },
};

export default function KalukhaliToDhakaPage() {
  const count = trainData.filter((t) => {
    const routes = t.data.routes;
    const s = routes.findIndex((r) => r.city.toLowerCase().replace(/_/g, "") === FROM);
    const d = routes.findIndex((r) => r.city.toLowerCase().replace(/_/g, "") === TO);
    return d !== -1 && d > s;
  }).length;

  const schemas = [
    getTrainRouteSchema({ fromStation: "Kalukhali", toStation: "Dhaka", banglaFrom: "কালুখালী", banglaTo: "ঢাকা", distance: "160 km", duration: "4 hrs", availableTrains: count, url: `${SITE_INFO.url}/kalukhali-to-dhaka` }),
    getRouteFAQSchema({ fromStation: "Kalukhali", toStation: "Dhaka", availableTrains: count, duration: "4 hrs", distance: "160 km" }),
  ];

  return (
    <>
      {schemas.map((s, i) => (
        <script key={i} type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(s) }} />
      ))}
      <TrainRouteClient fromStation="kalukhali" toStation="dhaka" banglaFrom="কালুখালী" banglaTo="ঢাকা" distance="160 km" duration="4 hrs" />
    </>
  );
}
