import {
  StatusCell
} from "./chunk-DB6ANJBO.js";
import {
  i18n
} from "./chunk-ZZ4JC4WE.js";

// src/lib/promotions.ts
var promotionStatusMap = {
  ["ACTIVE" /* ACTIVE */]: ["green", i18n.t("statuses.active")],
  ["INACTIVE" /* INACTIVE */]: ["red", i18n.t("statuses.inactive")],
  ["DRAFT" /* DRAFT */]: ["grey", i18n.t("statuses.draft")],
  ["SCHEDULED" /* SCHEDULED */]: [
    "orange",
    `${i18n.t("promotions.fields.campaign")} ${i18n.t("statuses.scheduled")?.toLowerCase()}`
  ],
  ["EXPIRED" /* EXPIRED */]: [
    "red",
    `${i18n.t("promotions.fields.campaign")} ${i18n.t("statuses.expired")?.toLowerCase()}`
  ]
};
var getPromotionStatus = (promotion) => {
  const date = /* @__PURE__ */ new Date();
  const campaign = promotion.campaign;
  if (!campaign) {
    return promotionStatusMap[promotion.status.toUpperCase()];
  }
  if (campaign.starts_at && new Date(campaign.starts_at) > date) {
    return promotionStatusMap["SCHEDULED" /* SCHEDULED */];
  }
  const campaignBudget = campaign.budget;
  const overBudget = campaignBudget && campaignBudget.limit && campaignBudget.used > campaignBudget.limit;
  if (campaign.ends_at && new Date(campaign.ends_at) < date || overBudget) {
    return promotionStatusMap["EXPIRED" /* EXPIRED */];
  }
  return promotionStatusMap[promotion.status.toUpperCase()];
};

// src/components/table/table-cells/promotion/status-cell/status-cell.tsx
import { jsx } from "react/jsx-runtime";
var StatusCell2 = ({ promotion }) => {
  const [color, text] = getPromotionStatus(promotion);
  return /* @__PURE__ */ jsx(StatusCell, { color, children: text });
};

export {
  StatusCell2 as StatusCell
};
