import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}

/**
 * Format a number as currency with the specified locale and currency code
 * @param value - The number to format
 * @param locale - The locale to use for formatting (defaults to 'en-US')
 * @param currency - The currency code to use (defaults to 'USD')
 * @returns Formatted currency string
 */
export function formatCurrency(
  value: number | null | undefined,
  locale: string = 'en-US',
  currency: string = 'USD'
): string {
  if (value === null || value === undefined) {
    return '$0.00';
  }

  return new Intl.NumberFormat(locale, {
    style: 'currency',
    currency: currency,
    minimumFractionDigits: 2,
    maximumFractionDigits: 2,
  }).format(value);
}
