'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _rollupPluginBabelHelpers = require('../../../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var TextArea_styles = require('../../TextArea.styles.js');
var IconInfoCircleOutline = require('../../../_Icon/Icons/IconInfoCircleOutline.js');
var TextArea_tokens = require('../../TextArea.tokens.js');
var react = require('../../../../utils/react.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);

var HintComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
  var hintText = _ref.hintText,
    isHintVisible = _ref.isHintVisible,
    hintTrigger = _ref.hintTrigger,
    hintTargetIcon = _ref.hintTargetIcon,
    hintPlacement = _ref.hintPlacement,
    hintHasArrow = _ref.hintHasArrow,
    hintOffset = _ref.hintOffset,
    hintWidth = _ref.hintWidth,
    hintContentLeft = _ref.hintContentLeft,
    isInnerLabel = _ref.isInnerLabel,
    size = _ref.size,
    handleHintShow = _ref.handleHintShow,
    handleHintHide = _ref.handleHintHide,
    handleHintClick = _ref.handleHintClick;
  var hintId = react.safeUseId();
  var getInfoIconSize = function getInfoIconSize() {
    if (!isInnerLabel || size === 'xs') {
      return 'xs';
    }
    return 's';
  };
  return /*#__PURE__*/React__default.default.createElement(TextArea_styles.Hint, {
    ref: ref,
    text: String(hintText),
    opened: isHintVisible,
    target: /*#__PURE__*/React__default.default.createElement(TextArea_styles.HintTargetWrapper, null, /*#__PURE__*/React__default.default.createElement(TextArea_styles.HintIconWrapper, _rollupPluginBabelHelpers.extends({
      id: hintId
    }, hintTrigger === 'hover' ? {
      onMouseEnter: handleHintShow,
      onMouseLeave: handleHintHide
    } : {
      onClick: handleHintClick
    }), hintTargetIcon || /*#__PURE__*/React__default.default.createElement(IconInfoCircleOutline.IconInfoCircleOutline, {
      size: getInfoIconSize(),
      color: "inherit",
      sizeCustomProperty: TextArea_tokens.tokens.hintCustomIconTargetSize
    }))),
    placement: hintPlacement,
    hasArrow: hintHasArrow,
    offset: hintOffset,
    minWidth: hintWidth,
    maxWidth: hintWidth,
    contentLeft: hintContentLeft,
    frame: hintId
  });
});

exports.HintComponent = HintComponent;
