"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _css2 = require("@emotion/css");

var _css3 = _interopRequireDefault(_css2);

var _core = require("@emotion/core");

var _react = require("react");

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _gatsby = require("gatsby");

var _md = require("react-icons/md");

var _BaseButton = require("../../skeletons/BaseButton");

var _button = require("../../../theme/styles/button");

var _button2 = _interopRequireDefault(_button);

var _options = require("../../../utils/options");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": 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(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(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; }

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

var Button = function Button(_ref) {
  var children = _ref.children,
      cssStyles = _ref.styles,
      loading = _ref.loading,
      _ref$LoadingIcon = _ref.LoadingIcon,
      LoadingIcon = _ref$LoadingIcon === void 0 ? _md.MdRefresh : _ref$LoadingIcon,
      _ref$size = _ref.size,
      size = _ref$size === void 0 ? "L" : _ref$size,
      _ref$tone = _ref.tone,
      tone = _ref$tone === void 0 ? "BRAND" : _ref$tone,
      _ref$variant = _ref.variant,
      variant = _ref$variant === void 0 ? "PRIMARY" : _ref$variant,
      rest = _objectWithoutProperties(_ref, ["children", "styles", "loading", "LoadingIcon", "size", "tone", "variant"]);

  var DefaultIcon = variant === "PRIMARY" && _md.MdArrowForward;
  return (0, _core.jsx)(_BaseButton.BaseButton, Object.assign({
    css:
    /*#__PURE__*/
    (0, _css3["default"])(_objectSpread({}, _button2["default"].base({
      loading: loading
    }), {}, _button2["default"].sizes[size], {}, _button2["default"].variants[variant]({
      tone: tone
    }), {}, cssStyles), "label:Button;" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21wb25lbnRzL2NvcmUvQnV0dG9uL0J1dHRvbi5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUE4Qk0iLCJmaWxlIjoiLi4vLi4vLi4vLi4vc3JjL2NvbXBvbmVudHMvY29yZS9CdXR0b24vQnV0dG9uLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLyoqIEBqc3gganN4ICovXG5pbXBvcnQgeyBqc3gsIGtleWZyYW1lcyB9IGZyb20gXCJAZW1vdGlvbi9jb3JlXCJcbmltcG9ydCBSZWFjdCwgeyBGcmFnbWVudCB9IGZyb20gXCJyZWFjdFwiXG5pbXBvcnQgUHJvcFR5cGVz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G9hZGluZ31cbiAgICAgIExvYWRpbmdJY29uPXtMb2FkaW5nSWNvbn1cbiAgICAgIHsuLi5yZXN0fVxuICAgID5cbiAgICAgIHtjaGlsZHJlbn1cbiAgICA8L0Jhc2VCdXR0b24+XG4gIClcbn1cblxuQnV0dG9uLnByb3BUeXBlcyA9IHtcbiAgc2l6ZTogUHJvcFR5cGVzLm9uZU9mKFtgTGAsIGBNYCwgYFhMYCwgYFNgXSksXG59XG5cbmV4cG9ydCBkZWZhdWx0IEJ1dHRvblxuIl19 */")),
    DefaultIcon: DefaultIcon,
    loading: loading,
    LoadingIcon: LoadingIcon
  }, rest), children);
};

Button.propTypes = {
  size: _propTypes2["default"].oneOf(["L", "M", "XL", "S"])
};
exports["default"] = Button;