"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _faChevronRight = require("@fortawesome/free-solid-svg-icons/faChevronRight");
var _fontAwesomeIcon = require("../font-awesome-icon");
var _truncateWithTooltip = require("../truncate-with-tooltip");
var _tooltip = require("../tooltip");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const DropdownItemTitle = ({
  option,
  isMultiLevelHandler = false
}) => {
  const {
    iconClass,
    icon,
    title,
    subtext,
    testId,
    tooltipPlacement,
    tooltipText,
    tooltipDocsLink,
    tooltipTestId,
    key
  } = option;
  const props = {
    tooltipText,
    tooltipPlacement: tooltipPlacement || _tooltip.TOOLTIP_PLACEMENT_TYPES.RIGHT,
    tooltipDelayType: _tooltip.TOOLTIP_DELAY_TYPES.SLOW,
    tooltipDocsLink,
    tooltipTestId
  };
  const itemTitle = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    "test-id": testId ? `menu-item-title-${testId}` : '',
    children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
      className: (0, _classnames.default)('drop-item-title-content', {
        'with-multilevel-handler': isMultiLevelHandler
      }),
      children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
        icon: icon,
        className: "drop-icon"
      }), iconClass && /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
        className: `drop-icon ${iconClass}`
      }), title, isMultiLevelHandler && /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
        icon: _faChevronRight.faChevronRight,
        className: "multilevel-handler"
      })]
    })
  });
  const itemSubText = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    "test-id": testId ? `menu-item-subtext-${testId}` : '',
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
      className: "menu-item-subtext",
      children: subtext
    })
  });
  const withTruncatableText = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [/*#__PURE__*/(0, _react.createElement)(_truncateWithTooltip.TruncateWithTooltip, {
      ...props,
      key: key
    }, itemTitle), subtext && /*#__PURE__*/(0, _react.createElement)(_truncateWithTooltip.TruncateWithTooltip, {
      ...props,
      tooltipTestId: `${tooltipTestId}-subtext`,
      key: `${key}-subtext`
    }, itemSubText)]
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: (0, _classnames.default)('drop-item-content-wrap', {
      'has-icon': icon || iconClass
    }),
    children: !!tooltipText ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
      children: [itemTitle, subtext && itemSubText]
    }) : withTruncatableText
  });
};
var _default = exports.default = DropdownItemTitle;