const l = (t, e = {}, r = "en") => {
  try {
    const n = typeof t == "string" || typeof t == "number" ? new Date(t) : t;
    if (isNaN(n.getTime()))
      return "Invalid Date";
    const o = {
      year: "numeric",
      month: "short",
      day: "numeric",
      ...e
    };
    return new Intl.DateTimeFormat(r, o).format(n);
  } catch {
    return "Invalid Date";
  }
}, d = (t, e = {}, r = "en") => {
  const n = {
    year: "numeric",
    month: "short",
    day: "numeric",
    hour: "numeric",
    minute: "2-digit",
    ...e
  };
  return l(t, n, r);
}, b = (t, e = {}, r = "en") => {
  const n = {
    hour: "numeric",
    minute: "2-digit",
    second: "2-digit",
    hour12: !0,
    ...e
  };
  return l(t, n, r);
}, h = (t, e = "en") => {
  try {
    const r = typeof t == "string" || typeof t == "number" ? new Date(t) : t;
    if (isNaN(r.getTime()))
      return "Invalid Date";
    const o = Math.floor(((/* @__PURE__ */ new Date()).getTime() - r.getTime()) / 1e3);
    if (o < 60)
      return "just now";
    const a = Math.floor(o / 60);
    if (a < 60)
      return `${a} minute${a === 1 ? "" : "s"} ago`;
    const s = Math.floor(a / 60);
    if (s < 24)
      return `${s} hour${s === 1 ? "" : "s"} ago`;
    const c = Math.floor(s / 24);
    if (c < 7)
      return `${c} day${c === 1 ? "" : "s"} ago`;
    const i = Math.floor(c / 7);
    if (i < 4)
      return `${i} week${i === 1 ? "" : "s"} ago`;
    const u = Math.floor(c / 30);
    if (u < 12)
      return `${u} month${u === 1 ? "" : "s"} ago`;
    const f = Math.floor(c / 365);
    return `${f} year${f === 1 ? "" : "s"} ago`;
  } catch {
    return "Invalid Date";
  }
}, M = (t) => {
  if (t < 0) return "0s";
  const e = Math.floor(t / 1e3), r = Math.floor(e / 60), n = Math.floor(r / 60), o = Math.floor(n / 24);
  return o > 0 ? `${o}d ${n % 24}h` : n > 0 ? `${n}h ${r % 60}m` : r > 0 ? `${r}m ${e % 60}s` : `${e}s`;
}, w = (t) => h(t), m = (t, e = {}, r = "en") => {
  try {
    return new Intl.NumberFormat(r, e).format(t);
  } catch {
    return t.toString();
  }
}, y = (t, e = "USD", r = "en") => m(t, {
  style: "currency",
  currency: e
}, r), C = (t, e = 1, r = "en") => m(t / 100, {
  style: "percent",
  minimumFractionDigits: e,
  maximumFractionDigits: e
}, r), N = (t) => {
  if (t === 0) return "0 B";
  const e = 1024, r = ["B", "KB", "MB", "GB", "TB"], n = Math.floor(Math.log(t) / Math.log(e));
  return `${Number.parseFloat((t / Math.pow(e, n)).toFixed(1))} ${r[n]}`;
}, D = (t, e = "en") => {
  if (Math.abs(t) < 1e3)
    return t.toString();
  try {
    return new Intl.NumberFormat(e, {
      notation: "compact",
      compactDisplay: "short"
    }).format(t);
  } catch {
    const n = ["", "K", "M", "B", "T"], o = Math.floor(Math.log(Math.abs(t)) / Math.log(1e3));
    return `${Number.parseFloat((t / Math.pow(1e3, o)).toFixed(1))}${n[o]}`;
  }
}, $ = (t, e) => [t, e].filter(Boolean).join(" "), I = (t) => t.split(" ").map((e) => e.charAt(0).toUpperCase()).slice(0, 2).join(""), T = (t) => t.firstName || t.lastName ? $(t.firstName, t.lastName) : t.username ? t.username : t.emailAddress ? t.emailAddress.split("@")[0] : "Unknown User", j = (t) => t.trim().toLowerCase(), A = (t, e = "national") => {
  const r = t.replace(/[^\d+]/g, "");
  if (r.length === 10) {
    const n = r.match(/^(\d{3})(\d{3})(\d{4})$/);
    if (n)
      switch (e) {
        case "international":
          return `+1 ${n[1]} ${n[2]} ${n[3]}`;
        case "e164":
          return `+1${r}`;
        case "national":
        default:
          return `(${n[1]}) ${n[2]}-${n[3]}`;
      }
  }
  if (r.length === 11 && r.startsWith("1")) {
    const o = r.substring(1).match(/^(\d{3})(\d{3})(\d{4})$/);
    if (o)
      switch (e) {
        case "international":
          return `+1 ${o[1]} ${o[2]} ${o[3]}`;
        case "e164":
          return `+${r}`;
        case "national":
        default:
          return `(${o[1]}) ${o[2]}-${o[3]}`;
      }
  }
  return r.startsWith("+") ? r : t;
}, B = (t) => {
  const [e, r] = t.split("@");
  if (!r) return t;
  if (e.length <= 3)
    return `${e[0]}***@${r}`;
  const n = e[0], o = e[e.length - 1], a = Math.max(3, e.length - 2);
  return `${n}${"*".repeat(a)}${o}@${r}`;
}, F = (t) => {
  const e = t.replace(/[^\d]/g, "");
  if (e.length >= 10) {
    const r = e.slice(-4);
    return `${"*".repeat(e.length - 4)}${r}`;
  }
  return t;
}, L = (t, e, r = "...") => t.length <= e ? t : t.substring(0, e - r.length) + r, g = (t, e, r = "...") => {
  if (t.length <= e) return t;
  const n = r.length, o = e - n, a = Math.ceil(o / 2), s = Math.floor(o / 2);
  return t.substring(0, a) + r + t.substring(t.length - s);
}, p = (t, e) => {
  switch (e) {
    case "camel":
      return t.replace(/(?:^\w|[A-Z]|\b\w)/g, (r, n) => n === 0 ? r.toLowerCase() : r.toUpperCase()).replace(/\s+/g, "");
    case "pascal":
      return t.replace(/(?:^\w|[A-Z]|\b\w)/g, (r) => r.toUpperCase()).replace(/\s+/g, "");
    case "snake":
      return t.replace(/\W+/g, " ").split(/ |\B(?=[A-Z])/).map((r) => r.toLowerCase()).join("_");
    case "kebab":
      return t.replace(/\W+/g, " ").split(/ |\B(?=[A-Z])/).map((r) => r.toLowerCase()).join("-");
    case "sentence":
      return t.charAt(0).toUpperCase() + t.slice(1).toLowerCase();
    case "title":
      return t.replace(/\w\S*/g, (r) => r.charAt(0).toUpperCase() + r.substr(1).toLowerCase());
    case "upper":
      return t.toUpperCase();
    case "lower":
      return t.toLowerCase();
    default:
      return t;
  }
}, U = (t) => t.length > 12 ? g(t, 12) : t, k = (t) => {
  if (t.length <= 8) return t;
  const e = t.substring(0, 4), r = t.substring(t.length - 4);
  return `${e}...${r}`;
}, O = (t) => [
  t.street,
  t.city,
  t.state && t.postalCode ? `${t.state} ${t.postalCode}` : t.state || t.postalCode,
  t.country
].filter(Boolean).join(", "), S = (t, e = {}) => {
  const { style: r = "long", type: n = "conjunction", locale: o = "en" } = e;
  if (t.length === 0) return "";
  if (t.length === 1) return t[0];
  try {
    return new Intl.DateTimeFormat(o, { style: r, type: n }).format(t);
  } catch {
    if (t.length === 2)
      return `${t[0]} ${n === "conjunction" ? "and" : "or"} ${t[1]}`;
    const a = t[t.length - 1], s = t.slice(0, -1), c = n === "conjunction" ? "and" : "or";
    return `${s.join(", ")}, ${c} ${a}`;
  }
}, R = (t, e = 2, r = 10) => {
  try {
    return JSON.stringify(t, null, e);
  } catch {
    return "[Circular Reference]";
  }
}, W = (t) => {
  try {
    return JSON.stringify(t);
  } catch {
    return "[Circular Reference]";
  }
}, P = (t) => {
  try {
    return new URL(t).hostname;
  } catch {
    return t;
  }
}, J = (t) => !t.startsWith("http://") && !t.startsWith("https://") ? `https://${t}` : t, Z = (t) => {
  const e = t.replace("#", "");
  return e.length === 3 ? `#${e.split("").map((r) => r + r).join("")}` : e.length === 6 ? `#${e}` : t;
}, z = (t, e, r) => `rgb(${Math.round(t)}, ${Math.round(e)}, ${Math.round(r)})`, E = (t, e, r, n) => `rgba(${Math.round(t)}, ${Math.round(e)}, ${Math.round(r)}, ${n})`, G = (t, e, r) => {
  const n = p(t, "sentence");
  switch (e) {
    case "required":
      return `${n} is required`;
    case "email":
      return `${n} must be a valid email address`;
    case "minLength":
      return `${n} must be at least ${r} characters`;
    case "maxLength":
      return `${n} must be no more than ${r} characters`;
    case "pattern":
      return `${n} format is invalid`;
    case "number":
      return `${n} must be a number`;
    case "min":
      return `${n} must be at least ${r}`;
    case "max":
      return `${n} must be no more than ${r}`;
    default:
      return `${n} is invalid`;
  }
};
function q(t) {
  switch (t) {
    case "left":
      return "text-left";
    case "center":
      return "text-center";
    case "right":
      return "text-right";
    default:
      return "text-left";
  }
}
const H = {
  // Date and time
  formatDate: l,
  formatDateTime: d,
  formatTime: b,
  formatRelativeTime: h,
  formatDuration: M,
  formatTimeAgo: w,
  // Numbers
  formatNumber: m,
  formatCurrency: y,
  formatPercentage: C,
  formatFileSize: N,
  formatCompactNumber: D,
  // Strings
  formatName: $,
  formatInitials: I,
  formatDisplayName: T,
  formatEmail: j,
  formatPhoneNumber: A,
  maskEmail: B,
  maskPhoneNumber: F,
  truncateText: L,
  truncateMiddle: g,
  formatTextCase: p,
  // IDs and tokens
  formatId: U,
  formatTokenPreview: k,
  // Addresses
  formatAddress: O,
  // Lists
  formatList: S,
  // JSON
  formatJSON: R,
  formatJSONCompact: W,
  // URLs
  formatDomain: P,
  formatURL: J,
  // Colors
  formatHexColor: Z,
  formatRGBColor: z,
  formatRGBAColor: E,
  // Validation
  formatValidationError: G
};
export {
  H as FormatUtils,
  O as formatAddress,
  D as formatCompactNumber,
  y as formatCurrency,
  l as formatDate,
  d as formatDateTime,
  T as formatDisplayName,
  P as formatDomain,
  M as formatDuration,
  j as formatEmail,
  N as formatFileSize,
  Z as formatHexColor,
  U as formatId,
  I as formatInitials,
  R as formatJSON,
  W as formatJSONCompact,
  S as formatList,
  $ as formatName,
  m as formatNumber,
  C as formatPercentage,
  A as formatPhoneNumber,
  E as formatRGBAColor,
  z as formatRGBColor,
  h as formatRelativeTime,
  p as formatTextCase,
  b as formatTime,
  w as formatTimeAgo,
  k as formatTokenPreview,
  J as formatURL,
  G as formatValidationError,
  q as getTitleAlignment,
  B as maskEmail,
  F as maskPhoneNumber,
  g as truncateMiddle,
  L as truncateText
};
//# sourceMappingURL=format.js.map
