"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { cn } from "@open-mercato/shared/lib/utils";
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger
} from "@open-mercato/ui/primitives/accordion";
import { Badge } from "@open-mercato/ui/primitives/badge";
const LOG_LEVEL_BADGE_VARIANT = {
  info: "info",
  warn: "warning",
  warning: "warning",
  error: "error",
  debug: "neutral"
};
function LogLevelBadge({ level, label, className }) {
  const key = typeof level === "string" ? level.toLowerCase() : "";
  const variant = LOG_LEVEL_BADGE_VARIANT[key] ?? "secondary";
  return /* @__PURE__ */ jsx(Badge, { variant, className, "data-log-level": key || void 0, children: label ?? level });
}
function LogList({ entries, emptyMessage, className }) {
  if (entries.length === 0) {
    return emptyMessage ? /* @__PURE__ */ jsx("p", { className: cn("py-4 text-sm text-muted-foreground", className), "data-slot": "log-list-empty", children: emptyMessage }) : null;
  }
  return /* @__PURE__ */ jsx(
    Accordion,
    {
      type: "single",
      collapsible: true,
      className: cn("space-y-2", className),
      "data-slot": "log-list",
      children: entries.map((entry) => /* @__PURE__ */ jsxs(AccordionItem, { value: entry.id, "data-log-entry-id": entry.id, children: [
        /* @__PURE__ */ jsx(AccordionTrigger, { triggerIcon: "chevron", children: /* @__PURE__ */ jsxs("span", { className: "grid w-full items-center gap-3 sm:grid-cols-[10rem_5rem_minmax(0,1fr)]", children: [
          /* @__PURE__ */ jsx("span", { className: "truncate whitespace-nowrap text-xs text-muted-foreground sm:text-sm", children: entry.time }),
          /* @__PURE__ */ jsx("span", { className: "justify-self-start", children: /* @__PURE__ */ jsx(LogLevelBadge, { level: entry.level, label: entry.levelLabel }) }),
          /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate text-left text-sm font-normal", children: entry.message })
        ] }) }),
        /* @__PURE__ */ jsx(AccordionContent, { children: entry.body })
      ] }, entry.id))
    }
  );
}
export {
  LogLevelBadge,
  LogList
};
//# sourceMappingURL=LogList.js.map
