import { defineComponent, createVNode, mergeProps } from 'vue';
import Skeleton from '../skeleton/Skeleton.mjs';
import '../hooks/index.mjs';
import { someType, functionType, anyType, vNodeType, booleanType } from '../_util/type.mjs';
import initDefaultProps from '../_util/props-util/initDefaultProps.mjs';
import useStyle from './style/index.mjs';
import StatisticNumber from './Number.mjs';
import useConfigInject from '../config-provider/hooks/useConfigInject.mjs';

const statisticProps = () => ({
  prefixCls: String,
  decimalSeparator: String,
  groupSeparator: String,
  format: String,
  value: someType([Number, String, Object]),
  valueStyle: {
    type: Object,
    default: void 0
  },
  valueRender: functionType(),
  formatter: anyType(),
  precision: Number,
  prefix: vNodeType(),
  suffix: vNodeType(),
  title: vNodeType(),
  loading: booleanType()
});
var Statistic = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "AStatistic",
  inheritAttrs: false,
  props: initDefaultProps(statisticProps(), {
    decimalSeparator: ".",
    groupSeparator: ",",
    loading: false
  }),
  slots: Object,
  setup(props, {
    slots,
    attrs
  }) {
    const {
      prefixCls,
      direction
    } = useConfigInject("statistic", props);
    const [wrapSSR, hashId] = useStyle(prefixCls);
    return () => {
      var _a, _b, _c, _d, _e, _f, _g;
      const {
        value = 0,
        valueStyle,
        valueRender
      } = props;
      const pre = prefixCls.value;
      const title = (_b = props.title) != null ? _b : (_a = slots.title) == null ? void 0 : _a.call(slots);
      const prefix = (_d = props.prefix) != null ? _d : (_c = slots.prefix) == null ? void 0 : _c.call(slots);
      const suffix = (_f = props.suffix) != null ? _f : (_e = slots.suffix) == null ? void 0 : _e.call(slots);
      const formatter = (_g = props.formatter) != null ? _g : slots.formatter;
      let valueNode = createVNode(StatisticNumber, mergeProps({
        "data-for-update": Date.now()
      }, {
        ...props,
        prefixCls: pre,
        value,
        formatter
      }), null);
      if (valueRender)
        valueNode = valueRender(valueNode);
      return wrapSSR(createVNode("div", mergeProps(attrs, {
        "class": [pre, {
          [`${pre}-rtl`]: direction.value === "rtl"
        }, attrs.class, hashId.value]
      }), [title && createVNode("div", {
        "class": `${pre}-title`
      }, [title]), createVNode(Skeleton, {
        "paragraph": false,
        "loading": props.loading
      }, {
        default: () => [createVNode("div", {
          "style": valueStyle,
          "class": `${pre}-content`
        }, [prefix && createVNode("span", {
          "class": `${pre}-content-prefix`
        }, [prefix]), valueNode, suffix && createVNode("span", {
          "class": `${pre}-content-suffix`
        }, [suffix])])]
      })]));
    };
  }
});

export { Statistic as default, statisticProps };
//# sourceMappingURL=Statistic.mjs.map
