import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; import { formatDistanceToNowStrict } from "date-fns"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } export function timeAgo(date: Date | string | number | null | undefined) { if (!date) return ""; const d = new Date(date); const diff = Date.now() - d.getTime(); if (diff < 60_000) return "just now"; return formatDistanceToNowStrict(d, { addSuffix: false }) .replace(" seconds", "s") .replace(" second", "s") .replace(" minutes", "m") .replace(" minute", "m") .replace(" hours", "h") .replace(" hour", "h") .replace(" days", "d") .replace(" day", "d") .replace(" months", "mo") .replace(" month", "mo") .replace(" years", "y") .replace(" year", "y"); } export function formatSalary(min?: number | null, max?: number | null, text?: string | null) { const k = (n: number) => (n >= 1000 ? `$${Math.round(n / 1000)}k` : `$${n}`); if (min && max && max >= min) return `${k(min)} – ${k(max)}`; if (min) return `${k(min)}+`; if (max) return `Up to ${k(max)}`; return text?.trim() || ""; } export function stripHtml(html: string) { return html .replace(/<\s*(br|\/p|\/div|\/li|\/h[1-6])\s*\/?>/gi, "\n") .replace(/