"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

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

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

var _reactFontawesome = _interopRequireDefault(require("react-fontawesome"));

var _styledComponents = _interopRequireDefault(require("styled-components"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

/**
 * A Font Awesome icon followed by a with a pseudo-element equivalent to a single space.
 */
const FontAwesomeWithSpace = (0, _styledComponents.default)(_reactFontawesome.default)`
  &::after {
    content: "";
    margin: 0 0.125em;
  }
`;
/**
 * Wrapper for the FontAwesome component that, if specified in the withSpace prop,
 * supports CSS spacing after the specified icon type, to replace the {' '} workaround,
 * and that should work for both left-to-right and right-to-left layouts.
 * Other props from FontAwesome are passed to that component.
 */

const Icon = ({
  fixedWidth = true,
  type,
  withSpace,
  ...props
}) => {
  const FontComponent = withSpace ? FontAwesomeWithSpace : _reactFontawesome.default;
  return /*#__PURE__*/_react.default.createElement(FontComponent, _extends({
    fixedWidth: fixedWidth,
    name: type
  }, props));
};

Icon.propTypes = {
  fixedWidth: _propTypes.default.bool,
  type: _propTypes.default.string.isRequired,
  withSpace: _propTypes.default.bool
};
var _default = Icon;
exports.default = _default;
module.exports = exports.default;

//# sourceMappingURL=icon.js