import _extends from '@babel/runtime/helpers/extends';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import 'core-js/modules/es.array.concat.js';
import 'core-js/modules/es.object.keys.js';
import React__default from 'react';
import PropTypes from 'prop-types';
import warning from 'warning';
import icons from '../../utils/bundledIcons.js';

var _excluded = ["icon", "renderIconByName", "title", "color", "width", "height", "className", "testId"];
var propTypes = {
  /** the name of the icon to render */
  icon: PropTypes.string,
  /** callback function that returns an react node based on the name of the icon */
  renderIconByName: PropTypes.func,
  title: PropTypes.string.isRequired,
  color: PropTypes.string.isRequired,
  width: PropTypes.number,
  height: PropTypes.number,
  testId: PropTypes.string
};
var defaultProps = {
  testId: 'card-icon',
  icon: undefined,
  renderIconByName: undefined,
  height: 16,
  width: 16
};

/** This component calls out to our renderIconByName callback function with the icon name OR fails over to our legacy card icons from our legacy icon bundle */
/* We test the implementation and do not want to trigger this console in our test logs */
/* istanbul ignore next */
var CardIcon = function CardIcon(_ref) {
  var icon = _ref.icon,
    renderIconByName = _ref.renderIconByName,
    title = _ref.title,
    color = _ref.color,
    width = _ref.width,
    height = _ref.height,
    className = _ref.className,
    testId = _ref.testId,
    rest = _objectWithoutProperties(_ref, _excluded);
  if (!renderIconByName && !icons[icon]) {
    warning(false, "You have not passed a renderIconByName function, and your icon name '".concat(icon, "' is not in our legacy icon bundle: ").concat(JSON.stringify(Object.keys(icons)), " so we will default to our 'help' icon.")) ;
  }
  var Icon = icons[icon] || icons.help;
  return icon ? renderIconByName ? renderIconByName(icon, {
    title: title,
    className: className,
    fill: color,
    width: width,
    height: height,
    tabIndex: '0',
    'data-testid': testId
  }) : /*#__PURE__*/React__default.createElement(Icon, _extends({}, rest, {
    className: className,
    fill: color,
    width: width,
    height: height,
    title: title,
    "aria-label": title,
    "data-testid": testId
  })) : null;
};
CardIcon.propTypes = propTypes;
CardIcon.defaultProps = defaultProps;
CardIcon.__docgenInfo = {
  "description": "This component calls out to our renderIconByName callback function with the icon name OR fails over to our legacy card icons from our legacy icon bundle",
  "methods": [],
  "displayName": "CardIcon",
  "props": {
    "testId": {
      "defaultValue": {
        "value": "'card-icon'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "icon": {
      "defaultValue": {
        "value": "undefined",
        "computed": true
      },
      "description": "the name of the icon to render",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "renderIconByName": {
      "defaultValue": {
        "value": "undefined",
        "computed": true
      },
      "description": "callback function that returns an react node based on the name of the icon",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "height": {
      "defaultValue": {
        "value": "16",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "number"
      },
      "required": false
    },
    "width": {
      "defaultValue": {
        "value": "16",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "number"
      },
      "required": false
    },
    "title": {
      "description": "",
      "type": {
        "name": "string"
      },
      "required": true
    },
    "color": {
      "description": "",
      "type": {
        "name": "string"
      },
      "required": true
    }
  }
};
var CardIcon$1 = CardIcon;

export { CardIcon$1 as default };
