import { r as reactExports, U as jsxRuntimeExports } from "./worker-entry-ScJyyKL-.js";
import { u as useDynamicSeo, S as SiteLayout, a as SectionHeading } from "./useDynamicSeo-BdCqOywQ.js";
import { s as supabase } from "./client-Dez4i5AL.js";
import { P as Play } from "./play-DAiUBpkR.js";
import { X } from "./x-D4p4UALn.js";
import "node:events";
import "node:async_hooks";
import "node:stream/web";
import "node:stream";
import "./router-DeIlR9yC.js";
import "./createLucideIcon-CzafGoM5.js";
function getEmbedUrl(url, type) {
  if (type === "youtube") {
    const m = url.match(/(?:youtu\.be\/|youtube\.com\/(?:watch\?v=|embed\/|shorts\/))([\w-]+)/);
    if (m) return `https://www.youtube.com/embed/${m[1]}?autoplay=1`;
  }
  if (type === "vimeo") {
    const m = url.match(/vimeo\.com\/(\d+)/);
    if (m) return `https://player.vimeo.com/video/${m[1]}?autoplay=1`;
  }
  return url;
}
function getThumb(r) {
  if (r.thumbnail_url) return r.thumbnail_url;
  if (r.video_type === "youtube") {
    const m = r.video_url.match(/(?:youtu\.be\/|youtube\.com\/(?:watch\?v=|embed\/|shorts\/))([\w-]+)/);
    if (m) return `https://i.ytimg.com/vi/${m[1]}/maxresdefault.jpg`;
  }
  return null;
}
function TVPage() {
  useDynamicSeo("/luxxen-tv");
  const [releases, setReleases] = reactExports.useState([]);
  const [active, setActive] = reactExports.useState(null);
  reactExports.useEffect(() => {
    supabase.from("tv_releases").select("*").eq("published", true).order("featured", {
      ascending: false
    }).order("release_date", {
      ascending: false,
      nullsFirst: false
    }).then(({
      data
    }) => setReleases(data ?? []));
  }, []);
  const featured = releases.find((r) => r.featured) ?? releases[0];
  const rest = featured ? releases.filter((r) => r.id !== featured.id) : [];
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(SiteLayout, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx("section", { className: "py-20 md:py-28", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "container mx-auto px-5 md:px-10", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(SectionHeading, { eyebrow: "Luxxen TV", title: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
        "Originals, releases & ",
        /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "italic text-gradient-gold", children: "behind the lens." })
      ] }), description: "Press play. Our in-house channel features short films, branded content and the stories behind our productions." }),
      !featured && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "py-32 text-center text-muted-foreground", children: "New releases dropping soon. Stay tuned." }),
      featured && /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { onClick: () => setActive(featured), className: "block w-full mt-16 group relative aspect-video overflow-hidden bg-onyx hover-lift", children: [
        getThumb(featured) ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: getThumb(featured), alt: featured.title, className: "w-full h-full object-cover transition-transform duration-700 group-hover:scale-105" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full h-full bg-gradient-to-br from-onyx to-background" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute inset-0 bg-gradient-to-t from-background via-background/40 to-transparent" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-20 h-20 md:w-24 md:h-24 rounded-full bg-gold/90 backdrop-blur flex items-center justify-center group-hover:scale-110 transition-transform duration-500 shadow-gold", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Play, { className: "w-8 h-8 md:w-10 md:h-10 text-primary-foreground ml-1", fill: "currentColor" }) }) }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute bottom-0 left-0 right-0 p-6 md:p-10 text-left", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs uppercase tracking-widest text-gold mb-2", children: "Featured Release" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-display text-3xl md:text-5xl text-foreground", children: featured.title }),
          featured.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-3 text-muted-foreground max-w-2xl line-clamp-2", children: featured.description })
        ] })
      ] }),
      rest.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid md:grid-cols-2 lg:grid-cols-3 gap-6 mt-12", children: rest.map((r) => /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { onClick: () => setActive(r), className: "group text-left", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative aspect-video overflow-hidden bg-onyx hover-lift", children: [
          getThumb(r) ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: getThumb(r), alt: r.title, className: "w-full h-full object-cover transition-transform duration-700 group-hover:scale-105", loading: "lazy" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full h-full bg-gradient-to-br from-onyx to-background" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute inset-0 bg-background/30 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Play, { className: "w-12 h-12 text-gold", fill: "currentColor" }) })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-display text-xl mt-4 text-foreground group-hover:text-gold transition-colors", children: r.title }),
        r.release_date && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground mt-1", children: new Date(r.release_date).toLocaleDateString("en-US", {
          month: "long",
          year: "numeric"
        }) })
      ] }, r.id)) })
    ] }) }),
    active && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "fixed inset-0 z-[60] bg-background/95 backdrop-blur-md flex items-center justify-center p-4", onClick: () => setActive(null), children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "absolute top-6 right-6 w-10 h-10 border border-border hover:border-gold text-foreground flex items-center justify-center", onClick: () => setActive(null), "aria-label": "Close", children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, {}) }),
      /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full max-w-6xl aspect-video bg-onyx", onClick: (e) => e.stopPropagation(), children: active.video_type === "uploaded" ? /* @__PURE__ */ jsxRuntimeExports.jsx("video", { src: active.video_url, controls: true, autoPlay: true, className: "w-full h-full" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("iframe", { src: getEmbedUrl(active.video_url, active.video_type), title: active.title, allow: "autoplay; encrypted-media; fullscreen", allowFullScreen: true, className: "w-full h-full" }) })
    ] })
  ] });
}
export {
  TVPage as component
};
