'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var classNames = require('../_util/classNames.js');
var index = require('../_util/vue-types/index.js');
var vnode = require('../_util/vnode.js');
require('../hooks/index.js');
var index$1 = require('../_util/props-util/index.js');
var SingleNumber = require('./SingleNumber.js');
var useConfigInject = require('../config-provider/hooks/useConfigInject.js');

function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
}
const scrollNumberProps = {
  prefixCls: String,
  count: index.default.any,
  component: String,
  title: index.default.any,
  show: Boolean
};
var ScrollNumber = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "ScrollNumber",
  inheritAttrs: false,
  props: scrollNumberProps,
  setup(props, {
    attrs,
    slots
  }) {
    const {
      prefixCls
    } = useConfigInject.default("scroll-number", props);
    return () => {
      var _a;
      const {
        prefixCls: customizePrefixCls,
        count,
        title,
        show,
        component: Tag = "sup",
        class: className,
        style,
        ...restProps
      } = {
        ...props,
        ...attrs
      };
      const newProps = {
        ...restProps,
        style,
        "data-show": props.show,
        "class": classNames.default(prefixCls.value, className),
        "title": title
      };
      let numberNodes = count;
      if (count && Number(count) % 1 === 0) {
        const numberList = String(count).split("");
        numberNodes = numberList.map((num, i) => vue.createVNode(SingleNumber.default, {
          "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 = index$1.filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
      if (children && children.length) {
        return vnode.cloneElement(children, {
          class: classNames.default(`${prefixCls.value}-custom-component`)
        }, false);
      }
      return vue.createVNode(Tag, newProps, _isSlot(numberNodes) ? numberNodes : {
        default: () => [numberNodes]
      });
    };
  }
});

exports.default = ScrollNumber;
//# sourceMappingURL=ScrollNumber.js.map
