import { format } from "date-fns";
import { es, enUS } from "date-fns/locale";
const locales = {
  es,
  en: enUS
};
function formatDate(date, locale = "es", formatStr = "PPP") {
  const dateObj = typeof date === "string" ? new Date(date) : date;
  return format(dateObj, formatStr, { locale: locales[locale] });
}
function formatDateTime(date, locale = "es") {
  const dateObj = typeof date === "string" ? new Date(date) : date;
  return format(dateObj, "PPP p", { locale: locales[locale] });
}
function formatRelativeTime(date, locale = "es") {
  const dateObj = typeof date === "string" ? new Date(date) : date;
  return format(dateObj, "PPp", { locale: locales[locale] });
}
function formatNumber(number, locale = "es", options) {
  return new Intl.NumberFormat(locale === "es" ? "es-ES" : "en-US", options).format(number);
}
function formatCurrency(amount, locale = "es", currency = "USD") {
  return new Intl.NumberFormat(locale === "es" ? "es-ES" : "en-US", {
    style: "currency",
    currency
  }).format(amount);
}
function formatPercentage(value, locale = "es") {
  return new Intl.NumberFormat(locale === "es" ? "es-ES" : "en-US", {
    style: "percent",
    minimumFractionDigits: 0,
    maximumFractionDigits: 1
  }).format(value / 100);
}
export {
  formatCurrency,
  formatDate,
  formatDateTime,
  formatNumber,
  formatPercentage,
  formatRelativeTime
};
