"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useCommentAdImpression = void 0;
var _react = require("react");
var _AdEngine = _interopRequireDefault(require("../../core/engines/AdEngine"));
var _useCustomRankingGlobalFeed = require("./useCustomRankingGlobalFeed");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const useCommentAdImpression = () => {
  const [commentsView, setCommentsView] = (0, _react.useState)([]);
  const handleViewChange = (0, _react.useCallback)(({
    viewableItems
  }) => {
    setCommentsView([...viewableItems]);
  }, []);
  (0, _react.useEffect)(() => {
    if (commentsView.length > 0) {
      for (const viewableComment of commentsView) {
        if ((0, _useCustomRankingGlobalFeed.isAmityAd)(viewableComment.item)) {
          _AdEngine.default.instance.markSeen(viewableComment.item, 'comment');
        }
      }
    }
  }, [commentsView]);
  return {
    handleViewChange
  };
};
exports.useCommentAdImpression = useCommentAdImpression;
//# sourceMappingURL=useCommentAdImpression.js.map