import Script from "next/script";

type IndraprasthaLawnSchemaProps = {
  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 IndraprasthaLawnSchema({
  data,
}: IndraprasthaLawnSchemaProps) {
  const pageUrl =
    data.canonicalUrl ||
    `${siteUrl}/lawns/indraprastha-lawn-royal-palace-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 Indraprasth Lawn?"
              ? "Indraprastha Lawn can comfortably accommodate 500+ guests, making it ideal for grand weddings, receptions, corporate events, and large celebrations."
              : faq.question === "What makes Indraprastha Lawn unique?"
                ? "Indraprastha Lawn features a Royal Rajwada-inspired ambience, spacious outdoor event space, and premium resort facilities, creating a grand setting for memorable celebrations."
                : faq.question ===
                    "Which events can be hosted at Indraprastha Lawn?"
                  ? "The venue is perfect for destination weddings, receptions, engagements, corporate events, exhibitions, cultural programs, and family celebrations."
                  : faq.question ===
                      "Is Indraprastha Lawn suitable for destination weddings?"
                    ? "Yes. Its large outdoor space, royal ambience, luxury accommodation, and resort amenities make it an excellent choice for destination weddings near Pune."
                    : faq.question ===
                        "Is accommodation available for guests?"
                      ? "Yes. Guests can stay at The Grand Heritage Resorts, which offers luxury villas, heritage rooms, and premium accommodation."
                      : faq.question ===
                          "Does the venue offer beautiful photography locations?"
                        ? "Yes. The Rajwada-inspired architecture, landscaped gardens, and open lawn create stunning backdrops for wedding and event photography."
                        : faq.question === "Is parking available?"
                          ? "Yes. The resort provides ample parking space for all guests attending weddings and events."
                          : faq.question ===
                              "Can multiple wedding functions be hosted here?"
                            ? "Yes. Indraprastha Lawn is suitable for engagement ceremonies, wedding receptions, destination weddings, and other pre-wedding celebrations."
                            : faq.question ===
                                "Is the venue suitable for corporate events?"
                              ? "Yes. The lawn is ideal for corporate gatherings, exhibitions, annual events, product launches, and large business functions."
                              : faq.question ===
                                  "How can I book Indraprastha Lawn?"
                                ? "Contact our event team to check availability, arrange a site visit, and receive a customized quotation for your wedding or special 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}#indraprastha-lawn`,
        },
        breadcrumb: {
          "@id": `${pageUrl}#breadcrumb`,
        },
        primaryImageOfPage: data.heroImage
          ? {
              "@type": "ImageObject",
              url: data.heroImage,
            }
          : undefined,
      },

      {
        "@type": "Place",
        "@id": `${pageUrl}#indraprastha-lawn`,
        name: "Indraprastha Lawn",
        description:
          "Indraprastha Lawn at The Grand Heritage Resorts is a spacious outdoor wedding and event venue near Pune, featuring a Royal Rajwada-inspired setting for grand weddings, receptions, corporate events and large celebrations.",
        url: pageUrl,
        image: [
          data.heroImage,
          data.overview,
          ...(data.gallery || []),
        ].filter(Boolean),
        maximumAttendeeCapacity: 500,
        floorSize: {
          "@type": "QuantitativeValue",
          value: 15000,
          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: "500+ guests",
          },
          {
            "@type": "PropertyValue",
            name: "Area",
            value: "15000 sq ft",
          },
          {
            "@type": "PropertyValue",
            name: "Setting",
            value: "Royal Rajwada-inspired outdoor venue",
          },
          {
            "@type": "PropertyValue",
            name: "Suitable For",
            value:
              "Destination weddings, receptions, engagements, corporate events, exhibitions, cultural programs and family celebrations",
          },
        ],
      },

      {
        "@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}#indraprastha-lawn`,
        },
      },

      {
        "@type": "ItemList",
        "@id": `${pageUrl}#event-types`,
        name: "Events at Indraprastha Lawn",
        itemListElement: [
          {
            "@type": "ListItem",
            position: 1,
            name: "Destination Weddings",
          },
          {
            "@type": "ListItem",
            position: 2,
            name: "Wedding Receptions",
          },
          {
            "@type": "ListItem",
            position: 3,
            name: "Engagement Ceremonies",
          },
          {
            "@type": "ListItem",
            position: 4,
            name: "Corporate Events",
          },
          {
            "@type": "ListItem",
            position: 5,
            name: "Exhibitions",
          },
          {
            "@type": "ListItem",
            position: 6,
            name: "Cultural Programs",
          },
          {
            "@type": "ListItem",
            position: 7,
            name: "Family Celebrations",
          },
        ],
      },

      {
        "@type": "ImageGallery",
        "@id": `${pageUrl}#gallery`,
        name: "Indraprastha 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: "Indraprastha Lawn",
            item: pageUrl,
          },
        ],
      },

      ...(faqEntities.length > 0
        ? [
            {
              "@type": "FAQPage",
              "@id": `${pageUrl}#faq`,
              mainEntity: faqEntities,
            },
          ]
        : []),
    ],
  };

  return (
    <Script
      id="indraprastha-lawn-schema"
      type="application/ld+json"
      dangerouslySetInnerHTML={{
        __html: JSON.stringify(schema),
      }}
    />
  );
}