"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _bem = require("@zarm-design/bem");

var React = _interopRequireWildcard(require("react"));

var _configProvider = require("../config-provider");

var Badge = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var _ref;

  var className = props.className,
      shape = props.shape,
      bordered = props.bordered,
      text = props.text,
      children = props.children,
      restProps = (0, _objectWithoutProperties2.default)(props, ["className", "shape", "bordered", "text", "children"]);

  var _React$useContext = React.useContext(_configProvider.ConfigContext),
      prefixCls = _React$useContext.prefixCls;

  var bem = (0, _bem.createBEM)('badge', {
    prefixCls: prefixCls
  });
  var cls = bem([(_ref = {}, (0, _defineProperty2.default)(_ref, "".concat(shape), !!shape), (0, _defineProperty2.default)(_ref, "sup", !!children), (0, _defineProperty2.default)(_ref, "bordered", bordered), _ref), className]);
  return /*#__PURE__*/React.createElement("span", (0, _extends2.default)({
    ref: ref,
    className: cls
  }, restProps), children, /*#__PURE__*/React.createElement("sup", {
    className: bem('content')
  }, shape !== 'dot' && text));
});
Badge.displayName = 'Badge';
Badge.defaultProps = {
  shape: 'dot'
};
var _default = Badge;
exports.default = _default;