import * as _vue from "vue";

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import { inject } from 'vue';
import PropTypes from '../_util/vue-types';
import { getComponent, initDefaultProps } from '../_util/props-util';
import { ConfigConsumerProps } from '../config-provider';
import StatisticNumber from './Number';
export var StatisticProps = {
  prefixCls: PropTypes.string,
  decimalSeparator: PropTypes.string,
  groupSeparator: PropTypes.string,
  format: PropTypes.string,
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]),
  valueStyle: PropTypes.any,
  valueRender: PropTypes.any,
  formatter: PropTypes.any,
  precision: PropTypes.number,
  prefix: PropTypes.any,
  suffix: PropTypes.any,
  title: PropTypes.any,
  onFinish: PropTypes.func
};
export default {
  name: 'AStatistic',
  props: initDefaultProps(StatisticProps, {
    decimalSeparator: '.',
    groupSeparator: ','
  }),
  setup: function setup() {
    return {
      configProvider: inject('configProvider', ConfigConsumerProps)
    };
  },
  render: function render() {
    var _this$$props = this.$props,
        customizePrefixCls = _this$$props.prefixCls,
        _this$$props$value = _this$$props.value,
        value = _this$$props$value === void 0 ? 0 : _this$$props$value,
        valueStyle = _this$$props.valueStyle,
        valueRender = _this$$props.valueRender;
    var getPrefixCls = this.configProvider.getPrefixCls;
    var prefixCls = getPrefixCls('statistic', customizePrefixCls);
    var title = getComponent(this, 'title');
    var prefix = getComponent(this, 'prefix');
    var suffix = getComponent(this, 'suffix');
    var formatter = getComponent(this, 'formatter', {}, false);

    var props = _objectSpread(_objectSpread({}, this.$props), {}, {
      prefixCls: prefixCls,
      value: value,
      formatter: formatter
    });

    var valueNode = _vue.createVNode(StatisticNumber, props, null);

    if (valueRender) {
      valueNode = valueRender(valueNode);
    }

    return _vue.createVNode("div", {
      "class": prefixCls
    }, [title && _vue.createVNode("div", {
      "class": "".concat(prefixCls, "-title")
    }, [title]), _vue.createVNode("div", {
      "style": valueStyle,
      "class": "".concat(prefixCls, "-content")
    }, [prefix && _vue.createVNode("span", {
      "class": "".concat(prefixCls, "-content-prefix")
    }, [prefix]), valueNode, suffix && _vue.createVNode("span", {
      "class": "".concat(prefixCls, "-content-suffix")
    }, [suffix])])]);
  }
};