"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.Review = void 0;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _i18n = require("../i18n");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var getHeading = function getHeading(heading, headingLevel) {
  var Heading = "h".concat(headingLevel) || "h3";
  if (heading) {
    return /*#__PURE__*/_react.default.createElement(Heading, {
      className: "ds-c-review__heading"
    }, heading);
  }
};

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