"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { Button } from "@open-mercato/ui/primitives/button";
import { formatDateTime } from "../utils.js";
function MessageDetailActionsSection(props) {
  const t = useT();
  if (!props.messageActions.length) return null;
  return /* @__PURE__ */ jsxs("section", { className: "space-y-3 border-l pl-4 py-2", children: [
    /* @__PURE__ */ jsx("h2", { className: "text-base font-semibold", children: t("messages.actions.title", "Actions") }),
    props.ActionsComponent ? /* @__PURE__ */ jsx(
      props.ActionsComponent,
      {
        message: {
          id: props.detail.id,
          type: props.detail.type,
          actionData: {
            ...props.detail.actionData ?? {},
            actions: props.messageActions
          },
          actionTaken: props.detail.actionTaken ?? null
        },
        onExecuteAction: props.onExecuteActionById,
        isExecuting: props.executingActionId !== null,
        executingActionId: props.executingActionId
      }
    ) : /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: props.messageActions.map((action) => /* @__PURE__ */ jsx(
      Button,
      {
        type: "button",
        variant: action.variant ?? "default",
        disabled: Boolean(props.detail.actionTaken) || props.executingActionId !== null,
        onClick: () => void props.onExecuteAction(action),
        children: props.executingActionId === action.id ? t("messages.actions.executing", "Executing...") : t(action.labelKey || action.label, action.label)
      },
      action.id
    )) }),
    props.detail.actionTaken ? /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
      t("messages.actions.taken", "Action taken"),
      ": ",
      props.detail.actionTaken,
      " (",
      formatDateTime(props.detail.actionTakenAt),
      ")"
    ] }) : null
  ] });
}
export {
  MessageDetailActionsSection
};
//# sourceMappingURL=actions-panel.js.map
