import {
  DisplayIdCell
} from "./chunk-HB3BP55W.js";
import {
  DateCell,
  DateHeader
} from "./chunk-SYNUA6LQ.js";
import {
  getStylizedAmount
} from "./chunk-XCHKUSUU.js";

// src/hooks/table/columns/use-payout-table-columns.tsx
import { createColumnHelper } from "@tanstack/react-table";
import { useMemo } from "react";
import { useTranslation } from "react-i18next";
import { StatusBadge } from "@medusajs/ui";
import { jsx } from "react/jsx-runtime";
var columnHelper = createColumnHelper();
var payoutStatusColor = (status) => {
  switch (status) {
    case "paid":
      return "green";
    case "processing":
      return "orange";
    case "pending":
      return "grey";
    case "failed":
    case "canceled":
      return "red";
    default:
      return "grey";
  }
};
var usePayoutTableColumns = () => {
  const { t } = useTranslation();
  return useMemo(
    () => [
      columnHelper.accessor("display_id", {
        header: () => /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: t("payouts.payout") }) }),
        cell: ({ getValue }) => {
          const displayId = getValue();
          return /* @__PURE__ */ jsx(DisplayIdCell, { displayId });
        }
      }),
      columnHelper.accessor("created_at", {
        header: () => /* @__PURE__ */ jsx(DateHeader, {}),
        cell: ({ getValue }) => {
          const date = new Date(getValue());
          return /* @__PURE__ */ jsx(DateCell, { date });
        }
      }),
      columnHelper.accessor("status", {
        header: () => /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: t("fields.status") }) }),
        cell: ({ getValue }) => {
          const status = getValue();
          return /* @__PURE__ */ jsx(StatusBadge, { color: payoutStatusColor(status), children: t(`payouts.status.${status}`, {
            defaultValue: status.charAt(0).toUpperCase() + status.slice(1)
          }) });
        }
      }),
      columnHelper.accessor("amount", {
        header: () => /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: t("fields.amount") }) }),
        cell: ({ getValue, row }) => {
          const amount = getValue();
          const currencyCode = row.original.currency_code;
          return /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle txt-compact-small flex h-full w-full items-center overflow-hidden", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: getStylizedAmount(amount, currencyCode) }) });
        }
      })
    ],
    [t]
  );
};

export {
  usePayoutTableColumns
};
