import * as _vue from "vue";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

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 PropTypes from '../_util/vue-types';
import { ConfigConsumerProps } from '../config-provider';
import { getComponent } from '../_util/props-util';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import DefaultEmptyImg from './empty';
import SimpleEmptyImg from './simple';
export var TransferLocale = function TransferLocale() {
  return {
    description: PropTypes.string
  };
};
export var EmptyProps = function EmptyProps() {
  return {
    prefixCls: PropTypes.string,
    image: PropTypes.any,
    description: PropTypes.any,
    imageStyle: PropTypes.object
  };
};
var Empty = {
  name: 'AEmpty',
  props: _objectSpread({}, EmptyProps()),
  methods: {
    renderEmpty: function renderEmpty(contentLocale) {
      var _image$type;

      var _this$$props = this.$props,
          customizePrefixCls = _this$$props.prefixCls,
          imageStyle = _this$$props.imageStyle;
      var prefixCls = ConfigConsumerProps.getPrefixCls('empty', customizePrefixCls);

      var image = getComponent(this, 'image') || _vue.createVNode(DefaultEmptyImg, null, null);

      var description = getComponent(this, 'description');
      var des = typeof description !== 'undefined' ? description : contentLocale.description;
      var alt = typeof des === 'string' ? des : 'empty';

      var cls = _defineProperty({}, prefixCls, true);

      var imageNode = null;

      if (typeof image === 'string') {
        imageNode = _vue.createVNode("img", {
          "alt": alt,
          "src": image
        }, null);
      } else if (_typeof(image) === 'object' && ((_image$type = image.type) === null || _image$type === void 0 ? void 0 : _image$type.PRESENTED_IMAGE_SIMPLE)) {
        var Image = image;
        imageNode = _vue.createVNode(Image, null, null);
        cls["".concat(prefixCls, "-normal")] = true;
      } else {
        imageNode = image;
      }

      return _vue.createVNode("div", {
        "class": cls
      }, [_vue.createVNode("div", {
        "class": "".concat(prefixCls, "-image"),
        "style": imageStyle
      }, [imageNode]), des && _vue.createVNode("p", {
        "class": "".concat(prefixCls, "-description")
      }, [des]), this.$slots.default && _vue.createVNode("div", {
        "class": "".concat(prefixCls, "-footer")
      }, [this.$slots.default()])]);
    }
  },
  render: function render() {
    return _vue.createVNode(LocaleReceiver, {
      "componentName": "Empty",
      "children": this.renderEmpty
    }, null);
  }
};
Empty.PRESENTED_IMAGE_DEFAULT = DefaultEmptyImg;
Empty.PRESENTED_IMAGE_SIMPLE = SimpleEmptyImg;
/* istanbul ignore next */

Empty.install = function (app) {
  app.component(Empty.name, Empty);
};

export default Empty;