import { differenceInSeconds as d, differenceInMinutes as m, differenceInHours as M, differenceInDays as $ } from "date-fns";
function P(t) {
  const n = /* @__PURE__ */ new Date(), o = d(n, t), r = m(n, t), i = M(n, t), s = $(n, t);
  if (s > 0)
    return `${s}d`;
  if (i > 0) {
    const e = r - i * 60;
    return `${i}h${e > 0 ? `${e}m` : ""}`;
  }
  if (r > 0) {
    const e = o - r * 60;
    return `${r}m${e > 0 ? `${e}s` : ""}`;
  }
  return `${o}s`;
}
const u = {
  E: 10n ** 18n,
  EB: 10n ** 18n,
  P: 10n ** 15n,
  PB: 10n ** 15n,
  T: 10n ** 12n,
  TB: 10n ** 12n,
  G: 10n ** 9n,
  GB: 10n ** 9n,
  M: 10n ** 6n,
  MB: 10n ** 6n,
  k: 10n ** 3n,
  KB: 10n ** 3n,
  Ei: 2n ** 60n,
  Pi: 2n ** 50n,
  Ti: 2n ** 40n,
  Gi: 2n ** 30n,
  Mi: 2n ** 20n,
  Ki: 2n ** 10n,
  B: 1n
};
function E({
  from: t,
  to: n = "MB",
  round: o
}) {
  const i = /^(\d+(?:\.\d+)?)([EPTGMkEiPiTiGiMiKiB]*)$/.exec(t);
  if (!i)
    return "";
  const [, s, e] = i;
  let [f, c = ""] = s.split(".");
  c = c.padEnd(6, "0");
  const l = BigInt(f) * 10n ** 6n + BigInt(c), B = u[e] || 1n, a = u[n];
  return `${l * B / 10n ** 6n / a}${n}`;
}
export {
  E as c,
  P as f
};
