import { TagVariant as a } from "../../../../internal/Tag/types.js";
const i = (e) => e === "Active", r = (e) => e === "Repaid", o = (e) => e === "Active" ? "capital.overview.grants.item.amounts.remaining" : "capital.overview.grants.item.amounts.requestedFunds", c = (e) => e.status === "Active" ? e.remainingTotalAmount : e.grantAmount, u = ({ status: e, missingActions: s }, t) => {
  switch (e) {
    case "Active":
      return;
    case "Failed":
      return "capital.overview.grants.common.statuses.failed";
    case "Pending":
      return !t && s?.length ? "capital.overview.grants.common.statuses.actionNeeded" : "capital.overview.grants.common.statuses.pending";
    case "Repaid":
      return "capital.overview.grants.common.statuses.fullyRepaid";
    case "Revoked":
      return "capital.overview.grants.common.statuses.revoked";
    case "WrittenOff":
      return "capital.overview.grants.common.statuses.writtenOff";
  }
}, d = ({ status: e, missingActions: s }, t) => {
  switch (e) {
    case "Failed":
      return a.ERROR;
    case "Pending":
      return !t && s?.length ? a.WARNING : a.DEFAULT;
    case "Repaid":
      return a.LIGHT;
    case "Revoked":
    case "WrittenOff":
      return a.WARNING;
    default:
      return a.DEFAULT;
  }
}, l = (e) => {
  const s = /* @__PURE__ */ new Date(), t = /* @__PURE__ */ new Date();
  return t.setDate(s.getDate() + e), t;
}, m = ({ status: e, missingActions: s }, t) => {
  switch (e) {
    case "Pending":
      return !t && s?.length ? void 0 : "capital.overview.grants.common.statuses.pending.description.awaitingFunds";
    case "Failed":
      return "capital.overview.grants.common.statuses.failed.description";
    case "WrittenOff":
      return "capital.overview.grants.common.statuses.writtenOff.description";
    case "Revoked":
      return "capital.overview.grants.common.statuses.revoked.description";
    default:
      return;
  }
}, g = (e, s) => {
  const t = e.status === "Active", n = e.status === "Pending";
  return {
    amount: c(e),
    amountLabelKey: o(e.status),
    hasAlerts: n,
    hasDetails: i(e.status),
    hasUnscheduledRepaymentDetails: t && !!e.unscheduledRepaymentAccounts?.length,
    // The grant revocation account details is currently not ready to be rendered.
    // A future iteration of this component might include revocation account details.
    // Only then should the following line be uncommented.
    //
    // hasRevocationDetails: isGrantActive && grant.revocationAccount !== undefined,
    isAmountColorSecondary: !t,
    isBackgroundFilled: r(e.status),
    isGrantIdVisible: !t,
    isLabelColorSecondary: t,
    isProgressBarVisible: t,
    repaymentPeriodEndDate: l(e.repaymentPeriodLeft),
    statusKey: u(e, s),
    statusTagVariant: d(e, s),
    statusTooltipKey: m(e, s)
  };
};
export {
  g as getGrantConfig,
  m as getStatusTooltipKey
};
