"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { Info } from "lucide-react";
import { useT } from "@open-mercato/shared/lib/i18n/context";
function HighlightItem({ label, value, href, hint }) {
  const display = typeof value === "string" && value.trim().length ? value.trim() : "\u2014";
  return /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
    /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: [
      label,
      hint && display === "\u2014" ? /* @__PURE__ */ jsx("span", { title: hint, className: "cursor-help", children: /* @__PURE__ */ jsx(Info, { className: "h-3 w-3" }) }) : null
    ] }),
    href && display !== "\u2014" ? /* @__PURE__ */ jsx("a", { href, className: "text-sm font-medium text-primary underline-offset-2 hover:underline", children: display }) : /* @__PURE__ */ jsx("div", { className: "text-sm font-medium", children: display })
  ] });
}
function formatNextInteraction(at, name) {
  if (!at) return null;
  const date = new Date(at);
  if (Number.isNaN(date.getTime())) return null;
  const formatted = date.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
  return name && name.trim().length ? `${formatted} \u2014 ${name.trim()}` : formatted;
}
function CompanyHighlightsSummary({ data }) {
  const t = useT();
  const { company } = data;
  const isLegacy = data.interactionMode !== "canonical";
  const nextInteractionHint = isLegacy ? t("customers.companies.detail.highlights.nextInteractionLegacyHint", "Available when unified interactions are enabled. Create tasks with a due date to see the next planned interaction.") : t("customers.companies.detail.highlights.nextInteractionHint", "Shows the nearest planned interaction. Create a task with a due date to populate this.");
  return /* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2 xl:grid-cols-4", children: [
    /* @__PURE__ */ jsx(
      HighlightItem,
      {
        label: t("customers.companies.detail.highlights.primaryEmail", "Email"),
        value: company.primaryEmail,
        href: company.primaryEmail ? `mailto:${company.primaryEmail}` : void 0
      }
    ),
    /* @__PURE__ */ jsx(
      HighlightItem,
      {
        label: t("customers.companies.detail.highlights.primaryPhone", "Phone"),
        value: company.primaryPhone != null ? String(company.primaryPhone) : null,
        href: company.primaryPhone ? `tel:${company.primaryPhone}` : void 0
      }
    ),
    /* @__PURE__ */ jsx(
      HighlightItem,
      {
        label: t("customers.companies.detail.highlights.status", "Status"),
        value: company.status
      }
    ),
    /* @__PURE__ */ jsx(
      HighlightItem,
      {
        label: t("customers.companies.detail.highlights.nextInteraction", "Next interaction"),
        value: formatNextInteraction(company.nextInteractionAt, company.nextInteractionName),
        hint: nextInteractionHint
      }
    )
  ] });
}
function PersonHighlightsSummary({ data }) {
  const t = useT();
  const { person, company } = data;
  const isLegacy = data.interactionMode !== "canonical";
  const nextInteractionHint = isLegacy ? t("customers.people.detail.highlights.nextInteractionLegacyHint", "Available when unified interactions are enabled. Create tasks with a due date to see the next planned interaction.") : t("customers.people.detail.highlights.nextInteractionHint", "Shows the nearest planned interaction. Create a task with a due date to populate this.");
  return /* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2 xl:grid-cols-5", children: [
    /* @__PURE__ */ jsx(
      HighlightItem,
      {
        label: t("customers.people.detail.highlights.primaryEmail", "Email"),
        value: person.primaryEmail,
        href: person.primaryEmail ? `mailto:${person.primaryEmail}` : void 0
      }
    ),
    /* @__PURE__ */ jsx(
      HighlightItem,
      {
        label: t("customers.people.detail.highlights.primaryPhone", "Phone"),
        value: person.primaryPhone != null ? String(person.primaryPhone) : null,
        href: person.primaryPhone ? `tel:${person.primaryPhone}` : void 0
      }
    ),
    /* @__PURE__ */ jsx(
      HighlightItem,
      {
        label: t("customers.people.detail.highlights.status", "Status"),
        value: person.status
      }
    ),
    /* @__PURE__ */ jsx(
      HighlightItem,
      {
        label: t("customers.people.detail.highlights.nextInteraction", "Next interaction"),
        value: formatNextInteraction(person.nextInteractionAt, person.nextInteractionName),
        hint: nextInteractionHint
      }
    ),
    /* @__PURE__ */ jsx(
      HighlightItem,
      {
        label: t("customers.people.detail.highlights.company", "Company"),
        value: company?.displayName
      }
    )
  ] });
}
export {
  CompanyHighlightsSummary,
  PersonHighlightsSummary
};
//# sourceMappingURL=CustomerFormHighlights.js.map
