"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Hint = void 0;
var _classnames = _interopRequireDefault(require("classnames"));
var _jsxRuntime = require("preact/compat/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
 * Hints are used in conjunction with a Label to describe individual form fields
 * or fieldsets. They are built in to all form fields in the design system, but
 * they can also be used on their own to create custom fields.
 *
 * For information about how and when to use this component,
 * [refer to its full documentation page](https://design.cms.gov/components/hint/).
 */
const Hint = _ref => {
  let {
    children,
    className,
    id,
    inversed,
    requirementLabel,
    ...otherProps
  } = _ref;
  const hintClasses = (0, _classnames.default)('ds-c-hint', inversed && 'ds-c-hint--inverse', className);
  let hintPadding;
  if (requirementLabel && children) {
    if (typeof requirementLabel === 'string') {
      // Remove any existing spacing and punctuation
      requirementLabel = requirementLabel.trim().replace(/\.$/, '');
      // Add punctuation after the requirementLabel so it doesn't run into the hint
      requirementLabel = requirementLabel + '.';
    }

    // Add space between hint and preceding requirementLabel
    hintPadding = ' ';
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
    ...otherProps,
    id: id,
    className: hintClasses,
    children: [requirementLabel, hintPadding, children]
  });
};
exports.Hint = Hint;