import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["onRender"];
import React, { useEffect } from 'react';
import { ElementName, IconType } from '../../../../../constants';
import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
import { BaseBadgeElement, toBadgeProps } from '../common';
var CommentCountElement = function CommentCountElement(props) {
  var _context$commentCount;
  var context = useFlexibleUiContext();
  var data = context ? toBadgeProps((_context$commentCount = context.commentCount) === null || _context$commentCount === void 0 ? void 0 : _context$commentCount.toString()) : null;
  var _ref = props || {},
    onRender = _ref.onRender,
    restProps = _objectWithoutProperties(_ref, _excluded);
  useEffect(function () {
    onRender === null || onRender === void 0 || onRender(!!data);
  }, [data, onRender]);
  return data ? /*#__PURE__*/React.createElement(BaseBadgeElement, _extends({
    icon: IconType.Comment
  }, data, restProps, {
    name: ElementName.CommentCount
  })) : null;
};
export default CommentCountElement;