import C from "../../../classnames/index.mjs";
import * as s from "react";
function d(n) {
  let {
    prefixCls: a,
    value: o,
    current: r,
    offset: e = 0
  } = n, u;
  return e && (u = {
    position: "absolute",
    top: `${e}00%`,
    left: 0
  }), /* @__PURE__ */ s.createElement("span", {
    style: u,
    className: C(`${a}-only-unit`, {
      current: r
    })
  }, o);
}
function S(n, a, o) {
  let r = n, e = 0;
  for (; (r + 10) % 10 !== a; )
    r += o, e += o;
  return e;
}
function $(n) {
  const {
    prefixCls: a,
    count: o,
    value: r
  } = n, e = Number(r), u = Math.abs(o), [i, v] = s.useState(e), [y, g] = s.useState(u), N = () => {
    v(e), g(u);
  };
  s.useEffect(() => {
    const f = setTimeout(() => {
      N();
    }, 1e3);
    return () => {
      clearTimeout(f);
    };
  }, [e]);
  let l, c;
  if (i === e || Number.isNaN(e) || Number.isNaN(i))
    l = [/* @__PURE__ */ s.createElement(d, Object.assign({}, n, {
      key: e,
      current: !0
    }))], c = {
      transition: "none"
    };
  else {
    l = [];
    const f = e + 10, m = [];
    for (let t = e; t <= f; t += 1)
      m.push(t);
    const b = m.findIndex((t) => t % 10 === i);
    l = m.map((t, p) => {
      const x = t % 10;
      return /* @__PURE__ */ s.createElement(d, Object.assign({}, n, {
        key: t,
        value: x,
        offset: p - b,
        current: p === b
      }));
    });
    const E = y < u ? 1 : -1;
    c = {
      transform: `translateY(${-S(i, e, E)}00%)`
    };
  }
  return /* @__PURE__ */ s.createElement("span", {
    className: `${a}-only`,
    style: c,
    onTransitionEnd: N
  }, l);
}
export {
  $ as default
};
