import { clsx, type ClassValue } from "clsx" import { twMerge } from "tailwind-merge" export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } /** * Sanitise an order's `contact_name` for display. * * The field is populated by an LLM during email intake and historically * contains incidental whitespace from the model output (newlines, trailing * spaces, lone "\n" strings, etc.). The list-page render uses a * truthy-check on the raw field, so a stray "\n" produces a dangling * separator dot with no actual name — visually a "miss" even though * the field is non-empty. * * This helper trims, normalises internal whitespace, and returns "" * for any falsy / whitespace-only input. The caller can then keep the * existing `displayContact && ...` pattern and get a * clean render. Search/export code that wants the raw value should keep * reading `order.contact_name` directly. */ export function displayContactName(raw: string | null | undefined): string { if (typeof raw !== "string") return ""; // Collapse any whitespace run (including \n) to a single space, then // trim. Mirrors the kind of clean the AI insights post-processor does // for names — it's cheap and deterministic. return raw.replace(/\s+/g, " ").trim(); }