"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _lodashEs = require("lodash-es");
var _classnames = _interopRequireDefault(require("classnames"));
var _faXmark = require("@fortawesome/free-solid-svg-icons/faXmark");
var _fontAwesomeIcon = require("../../font-awesome-icon");
var _button = require("../../button");
var _tooltip = require("../../tooltip");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function MultiSelectLabel({
  value,
  onDelete,
  disabled = false,
  tooltip,
  isReadOnlyItem = false,
  isInvalid = false,
  removeLabelText
}) {
  const key = (0, _lodashEs.uniqueId)('remove-');
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_tooltip.Tooltip, {
    content: tooltip,
    children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
      className: (0, _classnames.default)('multi-select-label', {
        disabled,
        'is-invalid': isInvalid
      }),
      "test-id": "multi-select-label",
      id: key,
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
        className: "label-name",
        "test-id": "multi-select-label-name",
        children: value
      }), !(isReadOnlyItem || disabled) && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
        type: _button.BUTTON_TYPES.BUTTON,
        className: "button command remove-button",
        onClick: () => onDelete(value),
        "test-id": "remove-button",
        "aria-label": removeLabelText,
        "data-id": value,
        disabled: disabled,
        "aria-labelledby": key,
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
          icon: _faXmark.faXmark
        })
      })]
    })
  });
}
var _default = exports.default = MultiSelectLabel;