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

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

/**
 * Absolute URL for a path on the current origin. Better Auth wants absolute
 * callback URLs so it doesn't have to infer the origin. Client-side only;
 * falls back to the raw path during SSR.
 */
export function absoluteUrl(path: string): string {
  return typeof window === "undefined"
    ? path
    : `${window.location.origin}${path}`;
}
