"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import * as React from "react";
import { ExternalLink } from "lucide-react";
import { cn } from "@open-mercato/shared/lib/utils";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { Tag } from "../../primitives/tag.js";
function RecordCardShell({
  kindLabel,
  kindIcon,
  title,
  subtitle,
  status,
  href,
  id,
  leading,
  children,
  className,
  dataKind
}) {
  const t = useT();
  return /* @__PURE__ */ jsxs(
    "div",
    {
      "data-ai-record-card": dataKind ?? kindLabel.toLowerCase(),
      "data-record-id": id,
      className: cn(
        "group/record relative my-2 flex flex-col gap-3 rounded-lg border border-border bg-card p-3 text-card-foreground shadow-sm transition-colors",
        href ? "hover:border-primary/40 hover:bg-accent/40" : "",
        className
      ),
      children: [
        /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
          leading ? /* @__PURE__ */ jsx("div", { className: "shrink-0", children: leading }) : /* @__PURE__ */ jsx("div", { className: "flex size-9 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary", "aria-hidden": true, children: kindIcon }),
          /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
            /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
              /* @__PURE__ */ jsx("span", { className: "text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: kindLabel }),
              status ? /* @__PURE__ */ jsx(Tag, { variant: status.variant, dot: true, children: status.label }) : null
            ] }),
            /* @__PURE__ */ jsxs("div", { className: "mt-0.5 flex items-start gap-2", children: [
              /* @__PURE__ */ jsx("h4", { className: "min-w-0 flex-1 truncate text-sm font-semibold leading-snug text-foreground", children: href ? /* @__PURE__ */ jsx(
                "a",
                {
                  href,
                  target: "_blank",
                  rel: "noopener noreferrer",
                  className: "outline-none hover:underline focus-visible:underline",
                  children: title
                }
              ) : title }),
              href ? /* @__PURE__ */ jsx(
                "a",
                {
                  href,
                  target: "_blank",
                  rel: "noopener noreferrer",
                  className: "shrink-0 rounded-md p-1 text-muted-foreground hover:text-foreground",
                  "aria-label": t("ai_assistant.chat.records.openRecord", "Open record"),
                  children: /* @__PURE__ */ jsx(ExternalLink, { className: "size-3.5", "aria-hidden": true })
                }
              ) : null
            ] }),
            subtitle ? /* @__PURE__ */ jsx("div", { className: "mt-0.5 truncate text-xs text-muted-foreground", children: subtitle }) : null
          ] })
        ] }),
        children ? /* @__PURE__ */ jsx("div", { className: "text-xs text-foreground", children }) : null
      ]
    }
  );
}
function KeyValueList({ items }) {
  if (items.length === 0) return null;
  return /* @__PURE__ */ jsx("dl", { className: "grid grid-cols-[minmax(80px,auto)_1fr] gap-x-3 gap-y-1", children: items.map((item, idx) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
    /* @__PURE__ */ jsx("dt", { className: "truncate text-[11px] uppercase tracking-wide text-muted-foreground", children: item.label }),
    /* @__PURE__ */ jsx("dd", { className: "min-w-0 truncate text-foreground", children: item.value })
  ] }, `${item.label}-${idx}`)) });
}
function TagRow({ tags }) {
  if (tags.length === 0) return null;
  return /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: tags.map((tag, idx) => /* @__PURE__ */ jsx(Tag, { variant: "brand", children: tag }, `${tag}-${idx}`)) });
}
function statusToTagVariant(status) {
  if (!status) return "neutral";
  const s = String(status).toLowerCase().trim();
  if (s === "won" || s === "win" || s === "active" || s === "completed" || s === "done" || s === "paid" || s === "success" || s === "closed_won" || s === "closed-won")
    return "success";
  if (s === "lost" || s === "failed" || s === "cancelled" || s === "canceled" || s === "overdue" || s === "closed_lost" || s === "closed-lost")
    return "error";
  if (s === "pending" || s === "in_progress" || s === "in progress" || s === "open" || s === "qualified")
    return "info";
  if (s === "at_risk" || s === "at risk" || s === "review" || s === "follow_up")
    return "warning";
  if (s === "draft" || s === "archived" || s === "inactive")
    return "neutral";
  return "info";
}
export {
  KeyValueList,
  RecordCardShell,
  TagRow,
  statusToTagVariant
};
//# sourceMappingURL=RecordCardShell.js.map
