"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ItemsBadge = ItemsBadge;
var _eui = require("@elastic/eui");
var _i18n = require("@kbn/i18n");
var _react = _interopRequireDefault(require("react"));
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */

function ItemsBadge({
  items = [],
  multipleItemsMessage = _i18n.i18n.translate('xpack.apm.itemsBadge.placeholder', {
    values: {
      itemsCount: items.length
    },
    defaultMessage: '{itemsCount, plural, one {1 item} other {# items}}'
  })
}) {
  if (items.length < 2) {
    return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, items.map(item => /*#__PURE__*/_react.default.createElement(_eui.EuiBadge, {
      color: "hollow",
      key: item
    }, item)));
  }
  return /*#__PURE__*/_react.default.createElement(_eui.EuiToolTip, {
    position: "right",
    content: items.map(item => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
      key: item
    }, item, /*#__PURE__*/_react.default.createElement("br", null)))
  }, /*#__PURE__*/_react.default.createElement(_eui.EuiBadge, null, multipleItemsMessage));
}