import { jsxs, jsx } from "react/jsx-runtime";
import { Link } from "@tanstack/react-router";
import { p as projectImage } from "./project-images-BkjwhtiA.js";
import { w as whatsappHref } from "./router-Dahr8H-r.js";
import * as React from "react";
import { useState } from "react";
import * as DialogPrimitive from "@radix-ui/react-dialog";
import { X } from "lucide-react";
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
import { L as LeadForm } from "./lead-form-Bx9NEbTG.js";
function cn(...inputs) {
  return twMerge(clsx(inputs));
}
const Dialog = DialogPrimitive.Root;
const DialogTrigger = DialogPrimitive.Trigger;
const DialogPortal = DialogPrimitive.Portal;
const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
  DialogPrimitive.Overlay,
  {
    ref,
    className: cn(
      "fixed inset-0 z-50 bg-black/80  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
      className
    ),
    ...props
  }
));
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
const DialogContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
  /* @__PURE__ */ jsx(DialogOverlay, {}),
  /* @__PURE__ */ jsxs(
    DialogPrimitive.Content,
    {
      ref,
      className: cn(
        "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",
        className
      ),
      ...props,
      children: [
        children,
        /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background cursor-pointer transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
          /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
          /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
        ] })
      ]
    }
  )
] }));
DialogContent.displayName = DialogPrimitive.Content.displayName;
const DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx("div", { className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className), ...props });
DialogHeader.displayName = "DialogHeader";
const DialogTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
  DialogPrimitive.Title,
  {
    ref,
    className: cn("text-lg font-semibold leading-none tracking-tight", className),
    ...props
  }
));
DialogTitle.displayName = DialogPrimitive.Title.displayName;
const DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
  DialogPrimitive.Description,
  {
    ref,
    className: cn("text-sm text-muted-foreground", className),
    ...props
  }
));
DialogDescription.displayName = DialogPrimitive.Description.displayName;
function LeadDialog({
  trigger,
  projectName,
  sourcePage,
  prefilledInterest
}) {
  const [open, setOpen] = useState(false);
  return /* @__PURE__ */ jsxs(Dialog, { open, onOpenChange: setOpen, children: [
    /* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: trigger }),
    /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[92vh] overflow-y-auto bg-white p-6 sm:max-w-md sm:p-8", children: [
      /* @__PURE__ */ jsxs(DialogHeader, { className: "text-left", children: [
        /* @__PURE__ */ jsx(DialogTitle, { className: "font-display text-xl font-bold text-navy sm:text-2xl", children: projectName ? `Download ${projectName} Brochure` : "Download Project Brochure" }),
        /* @__PURE__ */ jsx(DialogDescription, { className: "text-sm text-navy/75", children: "Share your details — the brochure, floor plans, and payment plan will be sent to you on WhatsApp within minutes." })
      ] }),
      /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
        LeadForm,
        {
          sourcePage,
          variant: "full",
          prefilledInterest,
          projectName,
          ctaLabel: "Download Brochure",
          onSuccess: () => setTimeout(() => setOpen(false), 1500)
        }
      ) })
    ] })
  ] });
}
function ProjectCard({ p }) {
  return /* @__PURE__ */ jsxs("div", { className: "group flex flex-col", children: [
    /* @__PURE__ */ jsxs(Link, { to: "/projects/$slug", params: { slug: p.slug }, className: "block", children: [
      /* @__PURE__ */ jsx("div", { className: "mb-5 aspect-[3/4] overflow-hidden bg-navy/5", children: /* @__PURE__ */ jsx(
        "img",
        {
          src: projectImage(p.slug, p.cover_image),
          alt: `${p.name} — ${p.location}`,
          loading: "lazy",
          width: 600,
          height: 800,
          className: "size-full object-cover transition-transform duration-700 group-hover:scale-105"
        }
      ) }),
      /* @__PURE__ */ jsx("h3", { className: "mb-1 font-display text-base font-bold transition-colors group-hover:text-gold sm:text-lg", children: p.name }),
      /* @__PURE__ */ jsx("p", { className: "mb-4 text-[11px] uppercase tracking-wider text-navy/70", children: p.location })
    ] }),
    /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-y-2 border-t border-navy/10 pt-4 text-[12px] font-medium sm:text-[11px]", children: [
      /* @__PURE__ */ jsx("span", { className: "text-navy/60", children: "From" }),
      /* @__PURE__ */ jsx("span", { className: "text-right text-navy", children: p.starting_price }),
      /* @__PURE__ */ jsx("span", { className: "text-navy/60", children: "Beds" }),
      /* @__PURE__ */ jsx("span", { className: "text-right text-navy", children: p.bedrooms }),
      /* @__PURE__ */ jsx("span", { className: "text-navy/60", children: "Handover" }),
      /* @__PURE__ */ jsx("span", { className: "text-right text-navy", children: p.handover_status })
    ] }),
    /* @__PURE__ */ jsxs("div", { className: "mt-5 flex gap-2", children: [
      /* @__PURE__ */ jsx(
        LeadDialog,
        {
          sourcePage: `/projects/${p.slug}`,
          projectName: p.name,
          prefilledInterest: p.property_type,
          trigger: /* @__PURE__ */ jsx(
            "button",
            {
              type: "button",
              className: "flex-1 border border-navy/20 px-3 py-3 text-center text-[11px] font-bold uppercase tracking-widest text-navy transition-colors hover:bg-navy hover:text-ivory sm:py-2.5 sm:text-[10px]",
              children: "Download Brochure"
            }
          )
        }
      ),
      /* @__PURE__ */ jsx(
        "a",
        {
          href: whatsappHref(`Hi, I'm interested in ${p.name} (${p.location}). Please share details.`),
          target: "_blank",
          rel: "noopener noreferrer",
          className: "grid size-11 shrink-0 place-items-center bg-[#25D366] text-white transition-transform hover:scale-105 sm:size-10",
          "aria-label": `WhatsApp about ${p.name}`,
          children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", className: "size-4", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487 1.7.733 2.504.794 3.404.667.547-.077 1.758-.718 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347Z" }) })
        }
      )
    ] })
  ] });
}
export {
  ProjectCard as P
};
