"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { StatusBadge } from "@open-mercato/ui/primitives/status-badge";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { domainStatusMap } from "./domainStatusMap.js";
function formatTime(value, fallback) {
  if (!value) return fallback;
  const date = new Date(value);
  if (Number.isNaN(date.getTime())) return fallback;
  return date.toLocaleString();
}
function DefaultStatusBadge({ mapping }) {
  const t = useT();
  const variant = domainStatusMap[mapping.status];
  const label = t(
    `customer_accounts.domainMapping.status.${mapping.status}`,
    mapping.status
  );
  const lastChecked = formatTime(
    mapping.lastDnsCheckAt,
    t("customer_accounts.domainMapping.autoVerify.checking", "Automatically checking every 5 minutes")
  );
  const showAutoCheck = mapping.status === "pending" || mapping.status === "dns_failed";
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
    /* @__PURE__ */ jsx(StatusBadge, { variant, dot: true, children: label }),
    mapping.lastDnsCheckAt ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("customer_accounts.domainMapping.autoVerify.lastChecked", "Last checked: {time}", {
      time: lastChecked
    }) }) : null,
    showAutoCheck ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("customer_accounts.domainMapping.autoVerify.nextCheck", "Next check in ~{minutes} minutes", {
      minutes: "5"
    }) }) : null
  ] });
}
var StatusBadgeSection_default = DefaultStatusBadge;
export {
  DefaultStatusBadge,
  StatusBadgeSection_default as default
};
//# sourceMappingURL=StatusBadgeSection.js.map
