"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.Review = void 0;
var _classnames = _interopRequireDefault(require("classnames"));
var _i18n = require("../i18n");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const getHeading = (heading, headingLevel) => {
  const Heading = `h${headingLevel}` || `h3`;
  if (heading) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(Heading, {
      className: "ds-c-review__heading",
      children: heading
    });
  }
};

/**
 * For information about how and when to use this component,
 * [refer to its full documentation page](https://design.cms.gov/components/review/).
 */
const Review = props => {
  const handleClick = event => {
    if (props.onEditClick) {
      props.onEditClick(event, props.editHref);
    }
  };
  const classes = (0, _classnames.default)('ds-c-review', props.className);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: classes,
    children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
      className: "ds-c-review__content",
      children: [getHeading(props.heading, props.headingLevel), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        className: "ds-c-review__body",
        children: props.children
      })]
    }), props.editContent, !props.editContent && props.editHref && /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
      onClick: handleClick,
      href: props.editHref,
      "aria-label": props.editAriaLabel,
      children: props.editText ?? (0, _i18n.t)('review.editText')
    })]
  });
};
exports.Review = Review;
Review.defaultProps = {
  headingLevel: '3'
};
var _default = exports.default = Review;