"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { Phone, Mail, Users, StickyNote, Clock, ArrowUpRight, ChevronRight } from "lucide-react";
import { Button } from "@open-mercato/ui/primitives/button";
import { formatRelativeTime } from "@open-mercato/shared/lib/time";
function interactionIcon(type) {
  switch (type) {
    case "call":
      return /* @__PURE__ */ jsx(Phone, { className: "size-4" });
    case "email":
      return /* @__PURE__ */ jsx(Mail, { className: "size-4" });
    case "meeting":
      return /* @__PURE__ */ jsx(Users, { className: "size-4" });
    case "note":
      return /* @__PURE__ */ jsx(StickyNote, { className: "size-4" });
    default:
      return /* @__PURE__ */ jsx(Clock, { className: "size-4" });
  }
}
function RecentActivityWidget({ interactions, t }) {
  return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-5", children: [
    /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxs("h3", { className: "flex items-center gap-2 text-sm font-semibold text-foreground", children: [
      /* @__PURE__ */ jsx(Clock, { className: "size-4" }),
      t("customers.companies.dashboard.recentActivity", "Recent activity"),
      /* @__PURE__ */ jsx("span", { className: "text-xs font-normal text-muted-foreground", children: t("customers.companies.dashboard.last7days", "last 7 days") })
    ] }) }),
    /* @__PURE__ */ jsxs("div", { className: "mt-3 divide-y", children: [
      interactions.map((interaction) => {
        const date = interaction.occurredAt ?? interaction.scheduledAt;
        return /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 py-3 first:pt-0 last:pb-0", children: [
          /* @__PURE__ */ jsx("div", { className: "mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground", children: interactionIcon(interaction.interactionType) }),
          /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
            /* @__PURE__ */ jsx("p", { className: "text-sm text-foreground", children: interaction.title || interaction.interactionType }),
            /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: interaction.authorName && /* @__PURE__ */ jsx("span", { children: interaction.authorName }) })
          ] }),
          /* @__PURE__ */ jsxs("div", { className: "shrink-0 text-right", children: [
            /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: date ? formatRelativeTime(date) : "\u2014" }),
            /* @__PURE__ */ jsx(ArrowUpRight, { className: "ml-auto mt-1 size-3.5 text-muted-foreground" })
          ] })
        ] }, interaction.id);
      }),
      interactions.length === 0 && /* @__PURE__ */ jsx("p", { className: "py-3 text-sm text-muted-foreground", children: t("customers.companies.dashboard.noActivity", "No recent activity") })
    ] }),
    interactions.length > 0 && /* @__PURE__ */ jsx("div", { className: "mt-3 border-t pt-3", children: /* @__PURE__ */ jsxs(Button, { type: "button", variant: "link", size: "sm", className: "h-auto p-0 text-xs", children: [
      t("customers.companies.dashboard.seeAllActivity", "See all {{count}} activities", { count: String(interactions.length) }),
      /* @__PURE__ */ jsx(ChevronRight, { className: "ml-0.5 size-3" })
    ] }) })
  ] });
}
export {
  RecentActivityWidget
};
//# sourceMappingURL=RecentActivityWidget.js.map
