"use client"; import * as React from "react"; import { cn } from "./lib/utils"; export interface CountdownV2Props extends React.HTMLAttributes { targetDate?: Date; label?: string; } function diff(target: Date): [number, number, number, number] { const ms = Math.max(0, target.getTime() - Date.now()); const d = Math.floor(ms / 86400000); const h = Math.floor((ms % 86400000) / 3600000); const m = Math.floor((ms % 3600000) / 60000); const s = Math.floor((ms % 60000) / 1000); return [d, h, m, s]; } /** Countdown v2 with flip cards and live tick. */ export function CountdownV2({ targetDate, label = "Doors open in", className, ...props }: CountdownV2Props) { const target = React.useMemo(() => targetDate ?? new Date(Date.now() + 2 * 86400000 + 3600000), [targetDate]); const [now, setNow] = React.useState(() => diff(target)); React.useEffect(() => { const t = setInterval(() => setNow(diff(target)), 1000); return () => clearInterval(t); }, [target]); const units = [["Days", now[0]], ["Hrs", now[1]], ["Min", now[2]], ["Sec", now[3]]] as const; return (

{label}

{units.map(([u, v]) => (

{String(v).padStart(2, "0")}

{u}

))}
); }