import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/taggedTemplateLiteralLoose";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";

var _templateObject, _templateObject2;

import React from 'react';
import Link from 'next/link';
import styled from 'styled-components';
export var Button = (_ref) => {
  var {
    label,
    link,
    onClick,
    variant = 'primary',
    target,
    className,
    children,
    fullWidth,
    icon,
    iconPosition = 'right',
    bordered = false,
    small = false,
    withCrossOver = false,
    borderRadius
  } = _ref,
      rest = _objectWithoutPropertiesLoose(_ref, ["label", "link", "onClick", "variant", "target", "className", "children", "fullWidth", "icon", "iconPosition", "bordered", "small", "withCrossOver", "borderRadius"]);

  var getBorderRadius = () => {
    if (!borderRadius && fullWidth) {
      return 'small';
    }

    return borderRadius || 'large';
  };

  var attrs = {
    'data-btn': '',
    'data-variant': variant,
    'data-border-radius': getBorderRadius()
  };

  if (fullWidth) {
    attrs['data-fullwidth'] = '';
  }

  if (bordered) {
    attrs['data-bordered'] = '';
  }

  if (small) {
    attrs['data-small'] = '';
  }

  if (withCrossOver) {
    attrs['data-cross-over'] = '';
  }

  if (variant === 'disabled') {
    attrs['disabled'] = '';
  }

  var content = /*#__PURE__*/React.createElement(React.Fragment, null, iconPosition === 'left' && icon && /*#__PURE__*/React.createElement(IconWrapper, {
    position: "left"
  }, icon), children || label, iconPosition === 'right' && icon && /*#__PURE__*/React.createElement(IconWrapper, {
    position: "right"
  }, icon));

  if (link) {
    return /*#__PURE__*/React.createElement(Link, _extends({
      prefetch: false,
      href: link,
      passHref: true
    }, rest), /*#__PURE__*/React.createElement("a", _extends({
      className: className,
      target: target,
      onClick: !rest.disabled ? onClick : e => e.preventDefault()
    }, attrs), content));
  }

  return /*#__PURE__*/React.createElement(StyledButton, _extends({
    className: className,
    onClick: onClick
  }, attrs, rest), content);
};
var IconWrapper = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  width: 2rem;\n  height: 2rem;\n  position: absolute;\n  top: 1.2rem;\n\n  ", "\n\n  & svg, img {\n    width: 1.8rem;\n    max-height: 1.9rem;\n  }\n"])), props => props.position === 'right' ? 'right: 2.6rem; top: 1.4rem;' : 'left: 2.6rem;');
var StyledButton = styled.button(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose([""])));
//# sourceMappingURL=index.js.map