"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useHint = useHint;
var _react = _interopRequireDefault(require("react"));
var _Hint = require("./Hint");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
 * Hook that takes the props for a form field component, extracts the props relevant
 * to the Hint, and conditionally renders the hint if it is needed.
 */
function useHint(props) {
  var hint = props.hint,
    inversed = props.inversed,
    requirementLabel = props.requirementLabel;
  var hintElement;
  var hintId;
  if (hint || requirementLabel) {
    var _props$hintId;
    hintId = (_props$hintId = props.hintId) !== null && _props$hintId !== void 0 ? _props$hintId : "".concat(props.id, "__hint");
    hintElement = /*#__PURE__*/_react.default.createElement(_Hint.Hint, {
      requirementLabel: requirementLabel,
      inversed: inversed,
      id: hintId
    }, hint);
  }
  return {
    hintId: hintId,
    hintElement: hintElement
  };
}