"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireDefault(require("react"));
var _reactIntlNext = require("react-intl-next");
var _constants = require("../../../../../constants");
var _messages = require("../../../../../messages");
var _flexibleUiContext = require("../../../../../state/flexible-ui-context");
var _common = require("../common");
var AppliedToComponentsCountElement = function AppliedToComponentsCountElement(props) {
  var _useIntl = (0, _reactIntlNext.useIntl)(),
    formatMessage = _useIntl.formatMessage;
  var context = (0, _flexibleUiContext.useFlexibleUiContext)();
  if (
  // Check for null and undefined, render if it's 0.
  (context === null || context === void 0 ? void 0 : context.appliedToComponentsCount) === null || (context === null || context === void 0 ? void 0 : context.appliedToComponentsCount) === undefined) {
    return null;
  }
  var label = formatMessage(_messages.messages.compass_applied_components_count, {
    numberOfComponents: context.appliedToComponentsCount
  });
  return /*#__PURE__*/_react.default.createElement(_common.BaseBadgeElement, (0, _extends2.default)({
    icon: _constants.IconType.Component,
    label: label
  }, props));
};
var _default = exports.default = AppliedToComponentsCountElement;