"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ChatMessageHeader = void 0;
var _react = _interopRequireWildcard(require("react"));
var _dropdownMenu = require("../dropdown-menu");
var _avatar = require("../avatar");
var _truncateWithTooltip = require("../truncate-with-tooltip");
var _renderers = require("./renderers");
var _jsxRuntime = require("react/jsx-runtime");
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); }
function ChatMessageHeaderBase({
  timestamp,
  username,
  avatarUrl,
  options,
  itemKey,
  onSelect,
  optionsTriggerAriaLabel
}) {
  const isActionable = !!options?.length;
  const handleSelect = (0, _react.useCallback)(({
    key
  }) => {
    onSelect?.({
      itemKey,
      optionKey: key
    });
  }, [onSelect, itemKey]);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: "chat-item-header",
    children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
      className: "chat-item-metadata",
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_avatar.Avatar, {
        testId: "user-avatar",
        imageSrc: avatarUrl,
        callerName: username,
        isTooltipHidden: true
      }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
        className: "chat-item-description",
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_truncateWithTooltip.TruncateWithTooltip, {
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
            children: username
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
          children: timestamp
        })]
      })]
    }), isActionable && /*#__PURE__*/(0, _jsxRuntime.jsx)(_dropdownMenu.DropdownMenu, {
      options: options,
      placement: _dropdownMenu.DROPDOWN_MENU_PLACEMENT_TYPES.BOTTOM_END,
      triggerHideChevron: true,
      triggerDynamicContent: _renderers.getOptionsTriggerIcon,
      triggerIsIcon: true,
      triggerAriaLabelText: optionsTriggerAriaLabel,
      triggerButtonSize: "xs",
      onSelect: handleSelect,
      triggerClassName: "chat-item-menu"
    })]
  });
}
ChatMessageHeaderBase.displayName = 'ChatMessageHeader';
const ChatMessageHeader = exports.ChatMessageHeader = /*#__PURE__*/(0, _react.memo)(ChatMessageHeaderBase);