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

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

const CDN_BASE = "https://yefranchisees.b-cdn.net/frontend"

export function withCDN(imagePath: string): string {
  if (!imagePath) return imagePath
  // If it already starts with http/https, return as-is
  if (imagePath.startsWith("http://") || imagePath.startsWith("https://")) {
    return imagePath
  }
  // Ensure the path starts with /
  const normalizedPath = imagePath.startsWith("/") ? imagePath : `/${imagePath}`
  return `${CDN_BASE}${normalizedPath}`
}
