"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;exports.__esModule = true;exports.InputLayoutAsideIcon = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactIs = require("react-is");

var _utils = require("../../../lib/utils");

var _Emotion = require("../../../lib/theming/Emotion");
var _ThemeContext = require("../../../lib/theming/ThemeContext");


var _InputLayoutContext = require("./InputLayoutContext");
var _InputLayout = require("./InputLayout.styles");





var InputLayoutAsideIcon = exports.InputLayoutAsideIcon = function InputLayoutAsideIcon(_ref) {var _ref$icon = _ref.icon,icon = _ref$icon === void 0 ? null : _ref$icon,side = _ref.side;
  var theme = _react.default.useContext(_ThemeContext.ThemeContext);
  var _React$useContext = _react.default.useContext(_InputLayoutContext.InputLayoutContext),focused = _React$useContext.focused,disabled = _React$useContext.disabled,size = _React$useContext.size;

  var sizes = {
    small: parseInt(theme.inputIconSizeSmall),
    medium: parseInt(theme.inputIconSizeMedium),
    large: parseInt(theme.inputIconSizeLarge)
  };
  var gaps = {
    small: parseInt(theme.inputIconGapSmall),
    medium: parseInt(theme.inputIconGapMedium),
    large: parseInt(theme.inputIconGapLarge)
  };

  var _icon = icon instanceof Function ? icon() : icon;
  if ((0, _reactIs.isElement)(icon) && (0, _utils.isKonturIcon)(icon)) {var _icon$props$size;
    _icon = /*#__PURE__*/_react.default.cloneElement(icon, { size: (_icon$props$size = icon.props.size) != null ? _icon$props$size : sizes[size] });
  }

  var style = {};
  if (side) {
    if (side === 'right') {
      style.marginLeft = gaps[size];
    } else {
      style.marginRight = gaps[size];
    }
  }

  return _icon ? /*#__PURE__*/
  _react.default.createElement("span", {
    style: style,
    className: (0, _Emotion.cx)(
      _InputLayout.stylesLayout.aside(),
      _InputLayout.stylesLayout.icon(theme),
      focused && _InputLayout.stylesLayout.iconFocus(theme),
      disabled && _InputLayout.stylesLayout.iconDisabled(theme)
    ) },

  _icon
  ) :
  null;
};