"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useHint = useHint;
var _Hint = require("./Hint");
var _jsxRuntime = require("preact/compat/jsx-runtime");
/**
 * 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) {
  const {
    hint,
    inversed,
    requirementLabel
  } = props;
  let hintElement;
  let hintId;
  if (hint || requirementLabel) {
    hintId = props.hintId ?? `${props.id}__hint`;
    hintElement = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Hint.Hint, {
      requirementLabel: requirementLabel,
      inversed: inversed,
      id: hintId,
      children: hint
    });
  }
  return {
    hintId,
    hintElement
  };
}