import { defineComponent as f, toRef as r, computed as a, openBlock as d, createElementBlock as g, normalizeClass as _, unref as m, toDisplayString as v } from "vue";
import y from "dayjs";
import "../config-provider/index.mjs";
import D from "./style/index.mjs";
import h from "./useTimeAgo.mjs";
import { getTimeAgoStr as B } from "./utils.mjs";
import { useLocale as S } from "../config-provider/hooks/use-locale.mjs";
import { useNamespace as T } from "../config-provider/hooks/use-namespace.mjs";
const Y = ["title"], H = /* @__PURE__ */ f({
  name: "TimeAgo",
  __name: "index",
  props: {
    value: {
      default: Date.now()
    },
    title: {
      type: [String, Object, Boolean],
      default: !0
    },
    interval: {
      type: [Boolean, Number],
      default: 1e4
    },
    customFormat: {}
  },
  setup(s) {
    const e = s, {
      locale: n
    } = S(), {
      b: l
    } = T("time-ago"), i = D("time-ago"), u = h(r(e, "value"), Date.now(), r(e, "interval")), c = a(() => {
      const t = u.value;
      return e.customFormat ? e.customFormat(t) : B(t, n.value);
    }), p = a(() => {
      const t = e.title;
      if (t === !1)
        return;
      if (typeof t == "string")
        return t;
      const o = t === !0 ? "YYYY-MM-DD HH:mm:ss" : t.format;
      return y(e.value).format(o);
    });
    return (t, o) => (d(), g("span", {
      title: p.value,
      class: _([m(l)(), m(i)])
    }, v(c.value), 11, Y));
  }
});
export {
  H as default
};
