"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import * as React from "react";
import { Activity, Building2, History, NotebookPen, Paperclip, Users } from "lucide-react";
import { cn } from "@open-mercato/shared/lib/utils";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { Button } from "@open-mercato/ui/primitives/button";
const SUPPORTED_TAB_IDS = /* @__PURE__ */ new Set(["activities", "people", "companies", "notes", "files", "changelog"]);
function resolveLegacyTab(tab) {
  if (!tab) return "activities";
  return SUPPORTED_TAB_IDS.has(tab) ? tab : "activities";
}
function CountBadge({ count }) {
  if (count <= 0) return null;
  return /* @__PURE__ */ jsx("span", { className: "ml-1.5 rounded-sm bg-muted px-1.5 py-px text-xs font-semibold leading-none text-muted-foreground", children: count > 999 ? "999+" : count });
}
function NewBadge() {
  return /* @__PURE__ */ jsx("span", { className: "ml-1.5 rounded-sm bg-muted px-1.5 py-px text-xs font-semibold leading-none text-muted-foreground", children: "NEW" });
}
function DealDetailTabs({
  activeTab,
  onTabChange,
  injectedTabs = [],
  peopleCount = 0,
  companiesCount = 0,
  children
}) {
  const t = useT();
  const builtInTabs = React.useMemo(
    () => [
      {
        id: "activities",
        label: t("customers.deals.detail.tabs.activities", "Activities"),
        icon: /* @__PURE__ */ jsx(Activity, { className: "size-4" })
      },
      {
        id: "people",
        label: t("customers.deals.detail.tabs.people", "People"),
        icon: /* @__PURE__ */ jsx(Users, { className: "size-4" }),
        badge: /* @__PURE__ */ jsx(CountBadge, { count: peopleCount })
      },
      {
        id: "companies",
        label: t("customers.deals.detail.tabs.companies", "Companies"),
        icon: /* @__PURE__ */ jsx(Building2, { className: "size-4" }),
        badge: /* @__PURE__ */ jsx(CountBadge, { count: companiesCount })
      },
      {
        id: "notes",
        label: t("customers.deals.detail.tabs.notes", "Notes"),
        icon: /* @__PURE__ */ jsx(NotebookPen, { className: "size-4" })
      },
      {
        id: "files",
        label: t("customers.deals.detail.tabs.files", "Files"),
        icon: /* @__PURE__ */ jsx(Paperclip, { className: "size-4" })
      },
      {
        id: "changelog",
        label: t("customers.deals.detail.tabs.changelog", "Changelog"),
        icon: /* @__PURE__ */ jsx(History, { className: "size-4" }),
        badge: /* @__PURE__ */ jsx(NewBadge, {})
      }
    ],
    [companiesCount, peopleCount, t]
  );
  const allTabs = React.useMemo(
    () => [
      ...builtInTabs,
      ...injectedTabs.map((tab) => ({
        id: tab.id,
        label: tab.label
      }))
    ],
    [builtInTabs, injectedTabs]
  );
  return /* @__PURE__ */ jsxs("div", { children: [
    /* @__PURE__ */ jsx("div", { className: "border-b border-border", role: "tablist", "aria-label": t("customers.deals.detail.tabs.label", "Deal detail sections"), children: /* @__PURE__ */ jsx("nav", { className: "-mb-px flex gap-7 overflow-x-auto", role: "presentation", children: allTabs.map((tab) => {
      const isActive = activeTab === tab.id;
      return /* @__PURE__ */ jsxs(
        Button,
        {
          type: "button",
          variant: "ghost",
          size: "sm",
          role: "tab",
          "aria-selected": isActive,
          onClick: () => onTabChange(tab.id),
          className: cn(
            "h-auto shrink-0 rounded-none border-b-2 px-3 py-2.5 hover:bg-transparent",
            isActive ? "border-foreground text-foreground font-semibold" : "border-transparent text-muted-foreground hover:text-foreground"
          ),
          children: [
            tab.icon ? /* @__PURE__ */ jsx("span", { className: "mr-1.5", children: tab.icon }) : null,
            tab.label,
            tab.badge
          ]
        },
        tab.id
      );
    }) }) }),
    /* @__PURE__ */ jsx("div", { className: "pt-5", role: "tabpanel", children })
  ] });
}
export {
  DealDetailTabs,
  resolveLegacyTab
};
//# sourceMappingURL=DealDetailTabs.js.map
