"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import * as React from "react";
import { Heart, EyeOff } from "lucide-react";
import { cn } from "@open-mercato/shared/lib/utils";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { Badge } from "@open-mercato/ui/primitives/badge";
import { IconButton } from "@open-mercato/ui/primitives/icon-button";
import { computeHealthScore, HEALTH_BADGE_CLASSES, HEALTH_ICON_CLASSES } from "./healthScoreUtils.js";
function RelationshipHealthCard({ interactions, onHide }) {
  const t = useT();
  const health = React.useMemo(() => computeHealthScore(interactions), [interactions]);
  return /* @__PURE__ */ jsxs("div", { className: "group relative rounded-lg border bg-card p-5", children: [
    /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ jsxs("h3", { className: "flex items-center gap-2 text-sm font-semibold text-foreground", children: [
        /* @__PURE__ */ jsx(Heart, { className: cn("size-4", HEALTH_ICON_CLASSES[health.variant]) }),
        t("customers.companies.detail.health.title", "Relationship health")
      ] }),
      onHide && /* @__PURE__ */ jsx(
        IconButton,
        {
          type: "button",
          variant: "ghost",
          size: "xs",
          onClick: onHide,
          className: "opacity-0 transition-opacity group-hover:opacity-60",
          "aria-label": t("customers.companies.dashboard.hideTile", "Hide tile"),
          children: /* @__PURE__ */ jsx(EyeOff, { className: "size-3.5" })
        }
      )
    ] }),
    /* @__PURE__ */ jsx("div", { className: "mt-4 flex items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-2 text-center", children: [
      /* @__PURE__ */ jsxs("div", { className: "relative inline-flex items-center justify-center", children: [
        /* @__PURE__ */ jsx("span", { className: cn("text-4xl font-bold", HEALTH_ICON_CLASSES[health.variant]), children: health.score }),
        /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "/100" })
      ] }),
      /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Badge, { className: cn("text-xs", HEALTH_BADGE_CLASSES[health.variant]), children: t(`customers.companies.detail.health.${health.label}`, health.label) }) }),
      health.lastContactDays !== null && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
        t("customers.companies.detail.health.lastContact", "Last contact"),
        ": ",
        health.lastContactDays === 0 ? t("customers.health.today", "today") : t("customers.health.daysAgo", "{days} days ago", { days: health.lastContactDays })
      ] })
    ] }) })
  ] });
}
export {
  RelationshipHealthCard
};
//# sourceMappingURL=RelationshipHealthCard.js.map
