"use strict";

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 _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

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

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

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

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

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

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

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

var _BEM = require("../../../core/utils/BEM");

var _propTypes = _interopRequireDefault(require("prop-types"));

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) { (0, _defineProperty2["default"])(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 _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

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

// Style

/* istanbul ignore next */
if (typeof window !== 'undefined') require("./style.scss");

var Button = /*#__PURE__*/function (_Component) {
  (0, _inherits2["default"])(Button, _Component);

  var _super = _createSuper(Button);

  function Button(props) {
    (0, _classCallCheck2["default"])(this, Button);
    return _super.call(this, props, 'Button');
  }

  (0, _createClass2["default"])(Button, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          bem = _this$props.bem,
          children = _this$props.children,
          circular = _this$props.circular,
          className = _this$props.className,
          ghost = _this$props.ghost,
          size = _this$props.size,
          text = _this$props.text,
          type = _this$props.type,
          attrs = (0, _objectWithoutProperties2["default"])(_this$props, ["bem", "children", "circular", "className", "ghost", "size", "text", "type"]);
      var ButtonClasses = [this.bem(bem), "Button_".concat(size), className, circular && 'Button_circular', ghost && 'Button_ghost', text && 'Button_text'].filter(function (e) {
        return e;
      }).join(' ');
      return /*#__PURE__*/_react["default"].createElement(this.Tag, (0, _extends2["default"])({}, attrs, {
        className: ButtonClasses,
        type: type
      }), children);
    }
  }, {
    key: "Tag",
    get: function get() {
      return 'href' in this.props && this.props.href ? 'a' : 'button';
    }
  }]);
  return Button;
}(_BEM.Component);

exports["default"] = Button;
(0, _defineProperty2["default"])(Button, "propTypes", _objectSpread(_objectSpread({}, _BEM.Component.propTypes), {}, {
  circular: _propTypes["default"].bool,
  ghost: _propTypes["default"].bool,
  href: _propTypes["default"].string,
  size: _propTypes["default"].oneOf(['sm', 'md', 'lg']),
  text: _propTypes["default"].bool,
  type: _propTypes["default"].oneOf(['submit', 'reset', 'button'])
}));
(0, _defineProperty2["default"])(Button, "defaultProps", {
  size: 'md',
  type: 'button'
});