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

const FROM = "pangsha";
const TO = "dhaka";

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

export default function PangshaToDhakaPage() {
  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: "Pangsha", toStation: "Dhaka", banglaFrom: "পাংশা", banglaTo: "ঢাকা", distance: "170 km", duration: "4-5 hrs", availableTrains: count, url: `${SITE_INFO.url}/pangsha-to-dhaka` }),
    getRouteFAQSchema({ fromStation: "Pangsha", toStation: "Dhaka", availableTrains: count, duration: "4-5 hrs", distance: "170 km" }),
  ];

  return (
    <>
      {schemas.map((s, i) => (
        <script key={i} type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(s) }} />
      ))}
      <TrainRouteClient fromStation="pangsha" toStation="dhaka" banglaFrom="পাংশা" banglaTo="ঢাকা" distance="170 km" duration="4-5 hrs" />
    </>
  );
}
