import Script from "next/script";

type PeshwaLawnSchemaProps = {
  data: {
    slug: string;
    title: string;
    metaTitle?: string;
    metaDescription?: string;
    canonicalUrl?: string;
    heroImage?: string;
    overview?: string;
    gallery?: string[];
    faqs?: {
      question: string;
      answer: React.ReactNode;
    }[];
  };
};

const siteUrl = "https://www.thegrandheritageresorts.com";

const resortLogo =
  "https://pub-b0bc1a7c71a54576bbf43595e30e6188.r2.dev/images/hero/the-grand-heritage-resorts-logo.png";

const resortAddress = {
  "@type": "PostalAddress",
  addressLocality: "Kasari, Shikrapur",
  addressRegion: "Maharashtra",
  addressCountry: "IN",
};

const resortGeo = {
  "@type": "GeoCoordinates",
  latitude: 18.708709,
  longitude: 74.179304,
};

export function PeshwaLawnSchema({
  data,
}: PeshwaLawnSchemaProps) {
  const pageUrl =
    data.canonicalUrl ||
    `${siteUrl}/lawns/peshwa-lawn-in-pune`;

  const faqEntities =
    data.faqs?.map((faq) => ({
      "@type": "Question",
      name: faq.question,
      acceptedAnswer: {
        "@type": "Answer",
        text: typeof faq.answer === "string"
          ? faq.answer
          : faq.question === "What is the capacity of Peshwa Lawn?"
            ? "Peshwa Lawn can comfortably accommodate up to 300 guests, making it ideal for intimate weddings, receptions, engagements, and private celebrations."
            : faq.question === "What makes Peshwa Lawn unique?"
              ? "Peshwa Lawn features a replica of the iconic Shaniwar Wada, along with Datta Mandir and Radha Krishna Mandir, offering a unique heritage-inspired setting for weddings and traditional ceremonies."
              : faq.question === "Are traditional wedding rituals possible at Peshwa Lawn?"
                ? "Yes. The nearby Datta Mandir and Radha Krishna Mandir provide a peaceful setting for traditional wedding rituals, blessings, and ceremonies."
                : faq.question === "Does Peshwa Lawn have a heritage-inspired wedding backdrop?"
                  ? "Yes. Peshwa Lawn features a replica of the iconic Shaniwar Wada, creating a unique heritage-inspired backdrop for wedding ceremonies, receptions, and memorable photography."
                  : faq.question === "Why choose Peshwa Lawn for your wedding near Pune?"
                    ? "Peshwa Lawn combines a Shaniwar Wada replica, beautiful open-air surroundings, temple access, premium resort accommodation, and modern event facilities, making it one of the most unique wedding lawns near Pune."
                    : faq.question === "How can I book Peshwa Lawn?"
                      ? "Simply contact The Grand Heritage Resorts to check availability, schedule a venue visit, and receive a customized quotation for your wedding or event. Call 74472 74472 or 74477 84778, or email booking@thegrandheritageresorts.com."
                      : "",
      },
    })) || [];

  const schema = {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "WebPage",
        "@id": `${pageUrl}#webpage`,
        url: pageUrl,
        name: data.metaTitle || data.title,
        description: data.metaDescription,
        isPartOf: {
          "@id": `${siteUrl}#website`,
        },
        about: {
          "@id": `${pageUrl}#peshwa-lawn`,
        },
        breadcrumb: {
          "@id": `${pageUrl}#breadcrumb`,
        },
        primaryImageOfPage: data.heroImage
          ? {
              "@type": "ImageObject",
              url: data.heroImage,
            }
          : undefined,
      },

      {
        "@type": "Place",
        "@id": `${pageUrl}#peshwa-lawn`,
        name: "Peshwa Lawn",
        description:
          "Peshwa Lawn at The Grand Heritage Resorts is a heritage-inspired outdoor wedding and event venue in Pune featuring a replica of the iconic Shaniwar Wada.",
        url: pageUrl,
        image: [
          data.heroImage,
          data.overview,
          ...(data.gallery || []),
        ].filter(Boolean),
        maximumAttendeeCapacity: 300,
        floorSize: {
          "@type": "QuantitativeValue",
          value: 7000,
          unitCode: "FTK",
        },
        address: resortAddress,
        geo: resortGeo,
        containedInPlace: {
          "@id": `${siteUrl}#resort`,
        },
        additionalProperty: [
          {
            "@type": "PropertyValue",
            name: "Venue Type",
            value: "Outdoor Wedding and Event Lawn",
          },
          {
            "@type": "PropertyValue",
            name: "Capacity",
            value: "Up to 300 guests",
          },
          {
            "@type": "PropertyValue",
            name: "Area",
            value: "7000 sq ft",
          },
          {
            "@type": "PropertyValue",
            name: "Heritage Feature",
            value: "Replica of Shaniwar Wada",
          },
          {
            "@type": "PropertyValue",
            name: "Suitable For",
            value:
              "Weddings, receptions, engagements, Haldi, Mehendi, birthday celebrations, anniversaries, corporate events and family gatherings",
          },
        ],
      },

      {
        "@type": "Resort",
        "@id": `${siteUrl}#resort`,
        name: "The Grand Heritage Resorts",
        url: siteUrl,
        logo: {
          "@type": "ImageObject",
          url: resortLogo,
        },
        image: resortLogo,
        telephone: [
          "+91 74472 74472",
          "+91 74477 84778",
        ],
        email: "booking@thegrandheritageresorts.com",
        address: resortAddress,
        geo: resortGeo,
        areaServed: [
          {
            "@type": "City",
            name: "Pune",
          },
          {
            "@type": "Place",
            name: "Shikrapur",
          },
          {
            "@type": "Place",
            name: "Ranjangaon MIDC",
          },
        ],
        hasPart: {
          "@id": `${pageUrl}#peshwa-lawn`,
        },
      },

      {
        "@type": "ItemList",
        "@id": `${pageUrl}#event-types`,
        name: "Events at Peshwa Lawn",
        itemListElement: [
          {
            "@type": "ListItem",
            position: 1,
            name: "Weddings",
          },
          {
            "@type": "ListItem",
            position: 2,
            name: "Wedding Receptions",
          },
          {
            "@type": "ListItem",
            position: 3,
            name: "Engagement Ceremonies",
          },
          {
            "@type": "ListItem",
            position: 4,
            name: "Haldi Ceremony",
          },
          {
            "@type": "ListItem",
            position: 5,
            name: "Mehendi Ceremony",
          },
          {
            "@type": "ListItem",
            position: 6,
            name: "Birthday Celebrations",
          },
          {
            "@type": "ListItem",
            position: 7,
            name: "Anniversary Celebrations",
          },
          {
            "@type": "ListItem",
            position: 8,
            name: "Corporate Events",
          },
          {
            "@type": "ListItem",
            position: 9,
            name: "Family Gatherings",
          },
        ],
      },

      {
        "@type": "ImageGallery",
        "@id": `${pageUrl}#gallery`,
        name: "Peshwa Lawn Gallery",
        image: (data.gallery || []).map((image) => ({
          "@type": "ImageObject",
          contentUrl: image,
        })),
      },

      {
        "@type": "BreadcrumbList",
        "@id": `${pageUrl}#breadcrumb`,
        itemListElement: [
          {
            "@type": "ListItem",
            position: 1,
            name: "Home",
            item: siteUrl,
          },
          {
            "@type": "ListItem",
            position: 2,
            name: "Lawns",
            item: `${siteUrl}/best-lawn-in-pune`,
          },
          {
            "@type": "ListItem",
            position: 3,
            name: "Peshwa Lawn",
            item: pageUrl,
          },
        ],
      },

      ...(faqEntities.length > 0
        ? [
            {
              "@type": "FAQPage",
              "@id": `${pageUrl}#faq`,
              mainEntity: faqEntities,
            },
          ]
        : []),
    ],
  };

  return (
    <Script
      id="peshwa-lawn-schema"
      type="application/ld+json"
      dangerouslySetInnerHTML={{
        __html: JSON.stringify(schema),
      }}
    />
  );
}