import { defineComponent, createVNode } from 'vue';
import '../../../utils/index.mjs';
import useConfigInject from '../../config-provider/src/hooks/useConfigInject.mjs';
import SingleNumber from './SingleNumber.mjs';
import { scrollNumberProps } from './props.mjs';
import { classNames } from '../../../utils/dom/class.mjs';
import { filterEmpty } from '../../../utils/vue/props.mjs';
import { cloneElement } from '../../../utils/vue/vnode.mjs';

var ScrollNumber = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "ScrollNumber",
  inheritAttrs: false,
  props: scrollNumberProps(),
  setup(props, {
    attrs,
    slots
  }) {
    const {
      prefixCls
    } = useConfigInject("scroll-number", props);
    return () => {
      var _a;
      const {
        count,
        title,
        component: Tag = "sup",
        class: className,
        style,
        ...restProps
      } = {
        ...props,
        ...attrs
      };
      const newProps = {
        ...restProps,
        style,
        "data-show": props.show,
        "class": classNames(prefixCls.value, className),
        "title": title
      };
      let numberNodes = count;
      if (count && Number(count) % 1 === 0) {
        const numberList = String(count).split("");
        numberNodes = numberList.map((num, i) => {
          return createVNode(SingleNumber, {
            "prefixCls": prefixCls.value,
            "count": Number(count),
            "value": num,
            "key": numberList.length - i
          }, null);
        });
      }
      if (style && style.borderColor) {
        newProps.style = {
          ...style,
          boxShadow: `0 0 0 1px ${style.borderColor} inset`
        };
      }
      const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
      if (children && children.length) {
        return cloneElement(children, {
          class: classNames(`${prefixCls.value}-custom-component`)
        }, false);
      }
      return createVNode(Tag, newProps, {
        default: () => [numberNodes]
      });
    };
  }
});

export { ScrollNumber as default };
//# sourceMappingURL=ScrollNumber.mjs.map
