"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import * as React from "react";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { FormHeader } from "@open-mercato/ui/backend/forms";
import { IconButton } from "@open-mercato/ui/primitives/icon-button";
import { Archive, ArchiveRestore, Forward, MailMinus, MailOpen, Reply, Trash2 } from "lucide-react";
import { PriorityBadge } from "../../utils/PriorityBadge.js";
function MainMessageHeader(props) {
  const t = useT();
  const menuActions = React.useMemo(() => [
    {
      id: "reply",
      label: t("messages.reply", "Reply"),
      icon: Reply,
      onSelect: props.onReply,
      disabled: props.actionsDisabled || !props.canReply
    },
    {
      id: "forward-all",
      label: t("messages.actions.forwardAll", "Forward all"),
      icon: Forward,
      onSelect: props.onForwardAll,
      disabled: props.actionsDisabled || !props.canForwardAll,
      loading: props.activeActionId === "forwardAll"
    },
    {
      id: "archive-conversation",
      label: props.conversationArchived ? t("messages.actions.unarchiveConversation", "Unarchive conversation") : t("messages.actions.archiveConversation", "Archive conversation"),
      icon: props.conversationArchived ? ArchiveRestore : Archive,
      onSelect: props.onToggleArchiveConversation,
      disabled: props.actionsDisabled,
      loading: props.activeActionId === "archiveConversation" || props.activeActionId === "unarchiveConversation"
    },
    {
      id: "mark-all-unread",
      label: props.conversationAllUnread ? t("messages.actions.markAllRead", "Mark all read") : t("messages.actions.markAllUnread", "Mark all unread"),
      icon: props.conversationAllUnread ? MailOpen : MailMinus,
      onSelect: props.onToggleReadConversation,
      disabled: props.actionsDisabled,
      loading: props.activeActionId === "markAllUnread" || props.activeActionId === "markAllRead"
    },
    {
      id: "delete-conversation",
      label: t("messages.actions.deleteConversation", "Delete conversation"),
      icon: Trash2,
      onSelect: props.onDeleteConversation,
      disabled: props.actionsDisabled,
      loading: props.activeActionId === "deleteConversation"
    }
  ], [
    props.actionsDisabled,
    props.canForwardAll,
    props.canReply,
    props.conversationArchived,
    props.conversationAllUnread,
    props.onToggleArchiveConversation,
    props.onDeleteConversation,
    props.onForwardAll,
    props.onToggleReadConversation,
    props.onReply,
    props.activeActionId,
    t
  ]);
  return /* @__PURE__ */ jsx(
    FormHeader,
    {
      mode: "detail",
      backHref: "/backend/messages",
      backLabel: t("messages.actions.backToList", "Back to messages"),
      title: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2", children: [
        /* @__PURE__ */ jsx("span", { className: "truncate", children: props.subject }),
        /* @__PURE__ */ jsx(PriorityBadge, { priority: props.priority })
      ] }),
      utilityActions: props.canReply ? /* @__PURE__ */ jsx(
        IconButton,
        {
          type: "button",
          variant: "outline",
          size: "default",
          "aria-label": t("messages.reply", "Reply"),
          onClick: props.onReply,
          disabled: props.actionsDisabled || !props.canReply,
          children: /* @__PURE__ */ jsx(Reply, { className: "h-4 w-4", "aria-hidden": true })
        }
      ) : void 0,
      menuTriggerMode: "icon",
      menuAriaLabel: t("messages.actions.conversationActions", "Conversation actions"),
      menuActions
    }
  );
}
export {
  MainMessageHeader
};
//# sourceMappingURL=MainMessageHeader.js.map
