"use strict";

exports.__esModule = true;
exports.SuggestionCtaWrapper = void 0;
var _react = require("react");
var _SuggestionsContext = require("./SuggestionsContext");
/**
 * Wrapper component that adds automatic CTA click reporting to the dealer BI service.
 *
 * Note: The child component must be clickable (accept an onClick prop).
 */
const SuggestionCtaWrapper = ({
  offerId,
  referredUrl,
  children
}) => {
  const {
    onOfferClicked
  } = (0, _SuggestionsContext.useSuggestionsContext)();
  return /*#__PURE__*/(0, _react.cloneElement)(children, {
    onClick: e => {
      onOfferClicked(offerId, referredUrl);
      children.props.onClick == null || children.props.onClick(e);
    }
  });
};
exports.SuggestionCtaWrapper = SuggestionCtaWrapper;
//# sourceMappingURL=SuggestionCtaWrapper.js.map