import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
var _excluded = ["color", "size", "type", "children", "action", "transparent", "active", "border", "className", "title"];

var _ICON_SIZE;

import * as React from 'react';
import classNames from 'classnames';
import Icon, { ICON_COLOR } from '../icons/Icon';
import { __DEV__, invariant } from '../utils';
export var SIZE = {
  SMALL: 'small',
  NORMAL: 'normal'
};
var ICON_SIZE = (_ICON_SIZE = {}, _defineProperty(_ICON_SIZE, SIZE.SMALL, 24), _defineProperty(_ICON_SIZE, SIZE.NORMAL, 24), _ICON_SIZE);

// This component is deprecated
var IconAsButton = function IconAsButton(_ref) {
  var _classNames;

  var color = _ref.color,
      _ref$size = _ref.size,
      size = _ref$size === void 0 ? SIZE.NORMAL : _ref$size,
      type = _ref.type,
      children = _ref.children,
      action = _ref.action,
      transparent = _ref.transparent,
      active = _ref.active,
      border = _ref.border,
      className = _ref.className,
      title = _ref.title,
      props = _objectWithoutProperties(_ref, _excluded);

  if (__DEV__) {
    invariant(!(color !== null && color !== void 0 && color.includes('60')), 'Shade 60 is not supported on this deprecated component. Please use <Button iconOnly...></Button> instead.');
  }

  var buttonClass = classNames('sg-icon-as-button', (_classNames = {}, _defineProperty(_classNames, "sg-icon-as-button--".concat(String(color)), color), _defineProperty(_classNames, "sg-icon-as-button--".concat(size), size), _defineProperty(_classNames, 'sg-icon-as-button--with-border', border), _defineProperty(_classNames, 'sg-icon-as-button--action', action), _defineProperty(_classNames, 'sg-icon-as-button--action-active', action === true && active === true), _defineProperty(_classNames, 'sg-icon-as-button--transparent', transparent), _defineProperty(_classNames, 'sg-icon-as-button--transparent-active', transparent === true && active === true), _classNames), className);
  var content;

  if (type) {
    content = /*#__PURE__*/React.createElement(Icon, {
      type: type,
      color: ICON_COLOR.ADAPTIVE,
      size: ICON_SIZE[size],
      title: title
    });
  } else {
    content = children;
  }

  var RenderType = 'button';

  if (props.href !== undefined && props.href !== null && props.href !== '') {
    RenderType = 'a';
  }

  return /*#__PURE__*/React.createElement(RenderType, _extends({}, props, {
    role: "button",
    className: buttonClass
  }), /*#__PURE__*/React.createElement("div", {
    className: "sg-icon-as-button__hole"
  }, content || null));
};

export default IconAsButton;
export { TYPE, ICON_COLOR } from '../icons/Icon';