const c = {
  sec: 1e3,
  min: 6e4,
  hour: 36e5,
  day: 864e5,
  month: 2592e6,
  year: 31104e6
}, u = [
  "year",
  "month",
  "day",
  "hour",
  "min",
  "sec"
];
function h(n, o = "year") {
  let t = n;
  const i = {
    year: 0,
    month: 0,
    day: 0,
    hour: 0,
    min: 0,
    sec: 0
  }, a = u.indexOf(o);
  for (let r = a; r < u.length; r++) {
    const s = u[r], e = Math.floor(t / c[s]);
    i[s] = e, t %= c[s];
  }
  return i;
}
function m(n, o) {
  const t = n.split("|");
  return t.length === 1 ? `${o} ${n}` : `${o} ${o > 1 ? t[1].trim() : t[0].trim()}`;
}
function y(n, o) {
  const t = o.ap.timeAgo, i = {
    s: t.second,
    m: t.minute,
    h: t.hour,
    d: t.days,
    M: t.months,
    y: t.years
  }, { unit: a, count: r, type: s } = n;
  let e = i[n.unit], l = !0;
  if (a === "s" && n.count < 10 ? (e = t.justNow, l = !1) : a === "d" && r === 1 ? (e = s === "ago" ? t.yesterday : t.tomorrow, l = !1) : a === "M" && r === 1 ? (e = s === "ago" ? t.lastMonth : t.nextMonth, l = !1) : a === "y" && r === 1 && (e = s === "ago" ? t.lastYear : t.nextYear, l = !1), !l)
    return e;
  const f = s === "ago" ? t.ago : t.late;
  return e = `${m(e, r)} ${f}`, o.name === "zh-cn" && (e = e.replace(/\s+/g, "")), e;
}
export {
  h as formatDuration,
  m as getCountWord,
  y as getTimeAgoStr
};
