import { g as j, m as M, d as p, r as O, u as A, _ as y, i as N, bn as U, dZ as $, f as B, bm as P, bp as _, o as L } from "./index2.js"; import { createVNode as m, defineComponent as R, ref as D, onMounted as V, onUpdated as X, onBeforeUnmount as Y } from "vue"; import { S as Z } from "./index18.js"; const z = (t) => { const { value: n, formatter: e, precision: a, decimalSeparator: s, groupSeparator: u = "", prefixCls: r } = t; let c; if (typeof e == "function") c = e({ value: n }); else { const i = String(n), f = i.match(/^(-?)(\d*)(\.(\d+))?$/); if (!f) c = i; else { const d = f[1]; let o = f[2] || "0", l = f[4] || ""; o = o.replace(/\B(?=(\d{3})+(?!\d))/g, u), typeof a == "number" && (l = l.padEnd(a, "0").slice(0, a > 0 ? a : 0)), l && (l = `${s}${l}`), c = [m("span", { key: "int", class: `${r}-content-value-int` }, [d, o]), l && m("span", { key: "decimal", class: `${r}-content-value-decimal` }, [l])]; } } return m("span", { class: `${r}-content-value` }, [c]); }; z.displayName = "StatisticNumber"; const q = (t) => { const { componentCls: n, marginXXS: e, padding: a, colorTextDescription: s, statisticTitleFontSize: u, colorTextHeading: r, statisticContentFontSize: c, statisticFontFamily: i } = t; return { [`${n}`]: p(p({}, O(t)), { [`${n}-title`]: { marginBottom: e, color: s, fontSize: u }, [`${n}-skeleton`]: { paddingTop: a }, [`${n}-content`]: { color: r, fontSize: c, fontFamily: i, [`${n}-content-value`]: { display: "inline-block", direction: "ltr" }, [`${n}-content-prefix, ${n}-content-suffix`]: { display: "inline-block" }, [`${n}-content-prefix`]: { marginInlineEnd: e }, [`${n}-content-suffix`]: { marginInlineStart: e } } }) }; }, G = j("Statistic", (t) => { const { fontSizeHeading3: n, fontSize: e, fontFamily: a } = t, s = M(t, { statisticTitleFontSize: e, statisticContentFontSize: n, statisticFontFamily: a }); return [q(s)]; }), E = () => ({ prefixCls: String, decimalSeparator: String, groupSeparator: String, format: String, value: _([Number, String, Object]), valueStyle: { type: Object, default: void 0 }, valueRender: P(), formatter: B(), precision: Number, prefix: $(), suffix: $(), title: $(), loading: U() }), v = R({ compatConfig: { MODE: 3 }, name: "AStatistic", inheritAttrs: !1, props: N(E(), { decimalSeparator: ".", groupSeparator: ",", loading: !1 }), slots: Object, setup(t, n) { let { slots: e, attrs: a } = n; const { prefixCls: s, direction: u } = A("statistic", t), [r, c] = G(s); return () => { var i, f, d, o, l, g, S; const { value: H = 0, valueStyle: I, valueRender: T } = t, x = s.value, b = (i = t.title) !== null && i !== void 0 ? i : (f = e.title) === null || f === void 0 ? void 0 : f.call(e), h = (d = t.prefix) !== null && d !== void 0 ? d : (o = e.prefix) === null || o === void 0 ? void 0 : o.call(e), F = (l = t.suffix) !== null && l !== void 0 ? l : (g = e.suffix) === null || g === void 0 ? void 0 : g.call(e), k = (S = t.formatter) !== null && S !== void 0 ? S : e.formatter; let C = m(z, y({ "data-for-update": Date.now() }, p(p({}, t), { prefixCls: x, value: H, formatter: k })), null); return T && (C = T(C)), r(m("div", y(y({}, a), {}, { class: [x, { [`${x}-rtl`]: u.value === "rtl" }, a.class, c.value] }), [b && m("div", { class: `${x}-title` }, [b]), m(Z, { paragraph: !1, loading: t.loading }, { default: () => [m("div", { style: I, class: `${x}-content` }, [h && m("span", { class: `${x}-content-prefix` }, [h]), C, F && m("span", { class: `${x}-content-suffix` }, [F])])] })])); }; } }), J = [ ["Y", 1e3 * 60 * 60 * 24 * 365], ["M", 1e3 * 60 * 60 * 24 * 30], ["D", 1e3 * 60 * 60 * 24], ["H", 1e3 * 60 * 60], ["m", 1e3 * 60], ["s", 1e3], ["S", 1] // million seconds ]; function K(t, n) { let e = t; const a = /\[[^\]]*]/g, s = (n.match(a) || []).map((i) => i.slice(1, -1)), u = n.replace(a, "[]"), r = J.reduce((i, f) => { let [d, o] = f; if (i.includes(d)) { const l = Math.floor(e / o); return e -= l * o, i.replace(new RegExp(`${d}+`, "g"), (g) => { const S = g.length; return l.toString().padStart(S, "0"); }); } return i; }, u); let c = 0; return r.replace(a, () => { const i = s[c]; return c += 1, i; }); } function Q(t, n) { const { format: e = "" } = n, a = new Date(t).getTime(), s = Date.now(), u = Math.max(a - s, 0); return K(u, e); } const W = 1e3 / 30; function w(t) { return new Date(t).getTime(); } const tt = () => p(p({}, E()), { value: _([Number, String, Object]), format: String, onFinish: Function, onChange: Function }), et = R({ compatConfig: { MODE: 3 }, name: "AStatisticCountdown", props: N(tt(), { format: "HH:mm:ss" }), // emits: ['finish', 'change'], setup(t, n) { let { emit: e, slots: a } = n; const s = D(), u = D(), r = () => { const { value: o } = t; w(o) >= Date.now() ? c() : i(); }, c = () => { if (s.value) return; const o = w(t.value); s.value = setInterval(() => { u.value.$forceUpdate(), o > Date.now() && e("change", o - Date.now()), r(); }, W); }, i = () => { const { value: o } = t; s.value && (clearInterval(s.value), s.value = void 0, w(o) < Date.now() && e("finish")); }, f = (o) => { let { value: l, config: g } = o; const { format: S } = t; return Q(l, p(p({}, g), { format: S })); }, d = (o) => o; return V(() => { r(); }), X(() => { r(); }), Y(() => { i(); }), () => { const o = t.value; return m(v, y({ ref: u }, p(p({}, L(t, ["onFinish", "onChange"])), { value: o, valueRender: d, formatter: f })), a); }; } }); v.Countdown = et; v.install = function(t) { return t.component(v.name, v), t.component(v.Countdown.name, v.Countdown), t; }; const it = v.Countdown; export { it as S };