import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";

/** Merge conditional + Tailwind classes (shadcn convention). */
export function cn(...inputs) {
    return twMerge(clsx(inputs));
}

/** Format a backend datetime string for display; '—' when missing/invalid. */
export function formatDateTime(value) {
    if (!value) return "—";
    const d = new Date(value);
    if (isNaN(d.getTime())) return "—";
    return d.toLocaleString(undefined, {
        year: "numeric",
        month: "short",
        day: "numeric",
        hour: "2-digit",
        minute: "2-digit",
    });
}
