"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { AlertTriangle } from "lucide-react";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { translateWithFallback } from "@open-mercato/shared/lib/i18n/translate";
function CurrencyBreakdownTable({
  rows,
  baseCurrencyCode,
  missingRateCurrencies
}) {
  const t = useT();
  const base = baseCurrencyCode?.toUpperCase() ?? null;
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col bg-card px-6", children: [
    /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 pt-5 pb-2", children: [
      /* @__PURE__ */ jsx("span", { className: "text-overline font-semibold uppercase tracking-wider text-muted-foreground", children: translateWithFallback(t, "customers.deals.kanban.currencyBreakdown.colCurrency", "Currency") }),
      /* @__PURE__ */ jsx("span", { className: "flex-1", "aria-hidden": "true" }),
      /* @__PURE__ */ jsx("span", { className: "text-overline font-semibold uppercase tracking-wider text-muted-foreground", children: translateWithFallback(
        t,
        "customers.deals.kanban.currencyBreakdown.colNativeTotal",
        "Native total"
      ) }),
      /* @__PURE__ */ jsx("span", { className: "pl-6 text-overline font-semibold uppercase tracking-wider text-muted-foreground", children: translateWithFallback(t, "customers.deals.kanban.currencyBreakdown.colDeals", "Deals") })
    ] }),
    /* @__PURE__ */ jsx("div", { className: "border-b border-border", "aria-hidden": "true" }),
    /* @__PURE__ */ jsx("ul", { className: "flex flex-col", children: rows.map((row) => {
      const code = row.currency.toUpperCase();
      const isBase = base !== null && code === base;
      const isMissingRate = missingRateCurrencies.includes(row.currency);
      return /* @__PURE__ */ jsxs(
        "li",
        {
          className: "flex items-center gap-1 border-b border-border py-2.5 last:border-b-0",
          children: [
            /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 text-sm font-semibold leading-normal text-foreground", children: [
              isMissingRate ? /* @__PURE__ */ jsx(
                AlertTriangle,
                {
                  className: "size-3.5 text-status-warning-icon",
                  "aria-hidden": "true"
                }
              ) : null,
              /* @__PURE__ */ jsx("span", { children: code }),
              isBase ? (
                // text-[9px] is an intentional Figma exception for the BASE badge (node 1251:671).
                // See CurrencyFilterPopover for the same rationale — both share the badge.
                /* @__PURE__ */ jsx("span", { className: "inline-flex items-center rounded-sm bg-brand-violet/10 px-1.5 py-px text-[9px] font-bold uppercase leading-normal tracking-wider text-brand-violet", children: translateWithFallback(t, "customers.deals.kanban.currencyBreakdown.basePill", "BASE") })
              ) : null
            ] }),
            /* @__PURE__ */ jsx("span", { className: "flex-1", "aria-hidden": "true" }),
            /* @__PURE__ */ jsx("span", { className: "text-sm font-semibold leading-normal text-foreground tabular-nums", children: formatAmount(row.total) }),
            /* @__PURE__ */ jsx("span", { className: "pl-6 text-sm font-normal leading-normal text-muted-foreground tabular-nums", children: row.count })
          ]
        },
        row.currency
      );
    }) })
  ] });
}
function formatAmount(amount) {
  return new Intl.NumberFormat(void 0, {
    style: "decimal",
    maximumFractionDigits: 0,
    useGrouping: true
  }).format(Math.round(amount));
}
var CurrencyBreakdownTable_default = CurrencyBreakdownTable;
export {
  CurrencyBreakdownTable,
  CurrencyBreakdownTable_default as default
};
//# sourceMappingURL=CurrencyBreakdownTable.js.map
