"use strict";

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

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

var _badge = _interopRequireDefault(require("@alifd/next/lib/badge"));

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

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

var _classnames = _interopRequireDefault(require("classnames"));

var _excluded = ["prefix", "size", "count", "className", "overflowCount", "dot", "status"];

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

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; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

var Badge = /*#__PURE__*/function (_Component) {
  _inherits(Badge, _Component);

  var _super = _createSuper(Badge);

  function Badge() {
    _classCallCheck(this, Badge);

    return _super.apply(this, arguments);
  }

  _createClass(Badge, [{
    key: "render",
    value: function render() {
      var _cls2;

      var _this$props = this.props,
          _this$props$prefix = _this$props.prefix,
          prefix = _this$props$prefix === void 0 ? 'next-' : _this$props$prefix,
          _this$props$size = _this$props.size,
          size = _this$props$size === void 0 ? 'small' : _this$props$size,
          count = _this$props.count,
          className = _this$props.className,
          overflowCount = _this$props.overflowCount,
          dot = _this$props.dot,
          status = _this$props.status,
          otherProps = _objectWithoutProperties(_this$props, _excluded);

      var content;

      if (status && !dot) {
        var _cls;

        if (status === 'warning') {
          content = /*#__PURE__*/_react["default"].createElement("svg", {
            viewBox: "0 0 20 20",
            version: "1.1",
            xmlns: "http://www.w3.org/2000/svg",
            xmlnsXlink: "http://www.w3.org/1999/xlink"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "33.-\u2705-Badge-\u5FBD\u6807\u6570-*",
            stroke: "none",
            "stroke-width": "1",
            fill: "none",
            "fill-rule": "evenodd"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "Badge-\u5FBD\u6807\u6570",
            transform: "translate(-355.000000, -1098.000000)"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "\u72B6\u6001\u6837\u5F0F",
            transform: "translate(90.000000, 916.000000)"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "\u72B6\u6001\u6837\u5F0F-\u65F6\u95F4-\u9EC4\u8272",
            transform: "translate(237.000000, 182.000000)"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "Icon-/-Filled-/-Time-/-Time-/-20",
            transform: "translate(28.000000, 0.000000)"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "\u7F16\u7EC4",
            transform: "translate(1.250000, 1.250000)"
          }, /*#__PURE__*/_react["default"].createElement("path", {
            d: "M8.75,0 C13.5824916,0 17.5,3.91750844 17.5,8.75 C17.5,13.5824916 13.5824916,17.5 8.75,17.5 C3.91750844,17.5 0,13.5824916 0,8.75 C0,3.91750844 3.91750844,0 8.75,0 Z",
            id: "\u8DEF\u5F84",
            stroke: "#FFFFFF",
            fill: "#FFAB14"
          }), /*#__PURE__*/_react["default"].createElement("path", {
            d: "M8.75,4.125 C8.4294776,4.125 8.16530802,4.36627512 8.12920483,4.6771118 L8.125,4.75 L8.125,9.75 C8.125,9.92144129 8.19402821,10.0767602 8.30580764,10.1896797 L8.36513831,10.2424845 L8.41529131,10.2991748 L10.625,12.5088835 C10.8690777,12.7529612 11.2648058,12.7529612 11.5088835,12.5088835 C11.734186,12.283581 11.7515169,11.9290616 11.5608764,11.6838796 L11.5088835,11.625 L9.375,9.49125 L9.375,4.75 C9.375,4.40482203 9.09517797,4.125 8.75,4.125 Z",
            id: "\u5F62\u72B6",
            fill: "#FFFFFF"
          }))))))));
        } else if (status === 'error') {
          content = /*#__PURE__*/_react["default"].createElement("svg", {
            viewBox: "0 0 20 20",
            version: "1.1",
            xmlns: "http://www.w3.org/2000/svg",
            xmlnsXlink: "http://www.w3.org/1999/xlink"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "33.-\u2705-Badge-\u5FBD\u6807\u6570-*",
            stroke: "none",
            "stroke-width": "1",
            fill: "none",
            "fill-rule": "evenodd"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "Badge-\u5FBD\u6807\u6570",
            transform: "translate(-497.000000, -1097.000000)"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "\u72B6\u6001\u6837\u5F0F",
            transform: "translate(90.000000, 916.000000)"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "\u72B6\u6001\u6837\u5F0F-\u611F\u53F9\u53F7-\u7EA2\u8272",
            transform: "translate(379.000000, 181.000000)"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "Icon-/-Filled-/-Status-/-Warning-/-20",
            transform: "translate(28.000000, 0.000000)"
          }, /*#__PURE__*/_react["default"].createElement("path", {
            d: "M10,1.75 C12.2781746,1.75 14.3406746,2.6734127 15.8336309,4.16636906 C17.3265873,5.65932541 18.25,7.72182541 18.25,10 C18.25,12.2781746 17.3265873,14.3406746 15.8336309,15.8336309 C14.3406746,17.3265873 12.2781746,18.25 10,18.25 C7.72182541,18.25 5.65932541,17.3265873 4.16636906,15.8336309 C2.6734127,14.3406746 1.75,12.2781746 1.75,10 C1.75,7.72182541 2.6734127,5.65932541 4.16636906,4.16636906 C5.65932541,2.6734127 7.72182541,1.75 10,1.75 Z",
            id: "\u8DEF\u5F84",
            stroke: "#FFFFFF",
            fill: "#C82727"
          }), /*#__PURE__*/_react["default"].createElement("rect", {
            id: "\u77E9\u5F62",
            opacity: "0",
            x: "0",
            y: "0",
            width: "20",
            height: "20"
          }), /*#__PURE__*/_react["default"].createElement("path", {
            d: "M10,13.75 C9.65482203,13.75 9.375,14.029822 9.375,14.375 C9.375,14.720178 9.65482203,15 10,15 C10.345178,15 10.625,14.720178 10.625,14.375 C10.625,14.029822 10.345178,13.75 10,13.75 Z M10,5 C9.6794776,5 9.41530802,5.24127512 9.37920483,5.5521118 L9.375,5.625 L9.375,11.875 C9.375,12.220178 9.65482203,12.5 10,12.5 C10.3205224,12.5 10.584692,12.2587249 10.6207952,11.9478882 L10.625,11.875 L10.625,5.625 C10.625,5.27982203 10.345178,5 10,5 Z",
            id: "\u5F62\u72B6",
            fill: "#FFFFFF"
          })))))));
        } else {
          content = /*#__PURE__*/_react["default"].createElement("svg", {
            width: "20px",
            height: "20px",
            viewBox: "0 0 20 20",
            version: "1.1",
            xmlns: "http://www.w3.org/2000/svg",
            xmlnsXlink: "http://www.w3.org/1999/xlink"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "33.-\u2705-Badge-\u5FBD\u6807\u6570-*",
            stroke: "none",
            "stroke-width": "1",
            fill: "none",
            "fill-rule": "evenodd"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "Badge-\u5FBD\u6807\u6570",
            transform: "translate(-213.000000, -1098.000000)"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "\u72B6\u6001\u6837\u5F0F",
            transform: "translate(90.000000, 916.000000)"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "\u72B6\u6001\u6837\u5F0F-\u5BF9\u53F7-\u7EFF\u8272",
            transform: "translate(95.000000, 182.000000)"
          }, /*#__PURE__*/_react["default"].createElement("g", {
            id: "Icon-/-Filled-/-Status-/-Checkmark-/-20",
            transform: "translate(28.000000, 0.000000)"
          }, /*#__PURE__*/_react["default"].createElement("rect", {
            id: "\u77E9\u5F62",
            "fill-opacity": "0.01",
            fill: "#FFFFFF",
            x: "0",
            y: "0",
            width: "20",
            height: "20"
          }), /*#__PURE__*/_react["default"].createElement("path", {
            d: "M10,1.75 C12.2781746,1.75 14.3406746,2.6734127 15.8336309,4.16636906 C17.3265873,5.65932541 18.25,7.72182541 18.25,10 C18.25,12.2781746 17.3265873,14.3406746 15.8336309,15.8336309 C14.3406746,17.3265873 12.2781746,18.25 10,18.25 C7.72182541,18.25 5.65932541,17.3265873 4.16636906,15.8336309 C2.6734127,14.3406746 1.75,12.2781746 1.75,10 C1.75,7.72182541 2.6734127,5.65932541 4.16636906,4.16636906 C5.65932541,2.6734127 7.72182541,1.75 10,1.75 Z",
            id: "\u5F62\u72B6",
            stroke: "#FFFFFF",
            fill: "#29A64E"
          }), /*#__PURE__*/_react["default"].createElement("path", {
            d: "M15.1110435,6.43305826 C14.885741,6.20775579 14.5312216,6.19042483 14.2860396,6.38106538 L14.22716,6.43305826 L8.428125,12.23125 L6.06694174,9.87055826 C5.82286406,9.62648058 5.42713594,9.62648058 5.18305826,9.87055826 C4.95775579,10.0958607 4.94042483,10.4503801 5.13106538,10.6955622 L5.18305826,10.7544417 L7.83470869,13.4060922 C7.91531259,13.4866961 8.01245513,13.5406814 8.11478286,13.5681008 C8.33882106,13.7311019 8.64671595,13.7267665 8.8662934,13.5550945 L8.92385912,13.5041261 L15.1110435,7.31694174 C15.3551211,7.07286406 15.3551211,6.67713594 15.1110435,6.43305826 Z",
            id: "\u8DEF\u5F84",
            fill: "#FFFFFF"
          })))))));
        }

        return /*#__PURE__*/_react["default"].createElement(_badge["default"], _extends({
          content: content
        }, otherProps, {
          className: (0, _classnames["default"])((_cls = {
            className: className
          }, _defineProperty(_cls, "".concat(prefix, "badge-success"), status === 'success'), _defineProperty(_cls, "".concat(prefix, "badge-warning"), status === 'warning'), _defineProperty(_cls, "".concat(prefix, "badge-error"), status === 'error'), _cls))
        }));
      }

      return /*#__PURE__*/_react["default"].createElement(_badge["default"], _extends({}, this.props, {
        className: (0, _classnames["default"])((_cls2 = {
          className: className
        }, _defineProperty(_cls2, "".concat(prefix, "badge-medium"), size === 'medium'), _defineProperty(_cls2, "".concat(prefix, "badge-small"), size === 'small' || !size), _defineProperty(_cls2, "".concat(prefix, "badge-not-overflow"), !overflowCount && Number(count) < 10), _defineProperty(_cls2, "".concat(prefix, "badge-overflow"), overflowCount || Number(count) > 9), _defineProperty(_cls2, "".concat(prefix, "badge-success"), status === 'success'), _defineProperty(_cls2, "".concat(prefix, "badge-warning"), status === 'warning'), _defineProperty(_cls2, "".concat(prefix, "badge-error"), status === 'error'), _cls2))
      }));
    }
  }]);

  return Badge;
}(_react.Component);

var _default = _configProvider["default"].config(Badge);

exports["default"] = _default;