{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "audit-log-table",
  "title": "Audit Log Table Block",
  "description": "An audit log with severity and actor filters, search, rows that open to show who did what from where plus a before and after diff, a live stream switch that slides new events in at the top and a JSON export of whatever is filtered.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/audit-log-table/audit-log-table.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type Severity = \"info\" | \"warning\" | \"critical\";\ntype Json = string | number | boolean | null | Json[] | { [k: string]: Json };\n\nexport interface AuditEvent {\n  id: string;\n  /** ISO timestamp, shown in UTC. */\n  time: string;\n  actor: { name: string; email?: string; kind?: \"user\" | \"api\" | \"system\" };\n  /** Dotted action name, e.g. member.role_updated */\n  action: string;\n  target: string;\n  severity: Severity;\n  ip?: string;\n  location?: string;\n  userAgent?: string;\n  before?: Record<string, Json> | null;\n  after?: Record<string, Json> | null;\n}\n\nexport interface AuditLogTableProps {\n  title?: string;\n  events?: AuditEvent[];\n  /** Start with the live stream on. */\n  live?: boolean;\n  /** Pull new events while live. Without it, demo events are generated. */\n  onPoll?: (since: string) => Promise<AuditEvent[]>;\n  /** Milliseconds between polls. */\n  interval?: number;\n  pageSize?: number;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.6)\", faint: \"rgba(245,244,241,0.36)\", card: \"#111111\", border: \"rgba(255,255,255,0.09)\", row: \"rgba(255,255,255,0.03)\", chip: \"rgba(255,255,255,0.06)\", on: \"#F5F4F1\", onText: \"#0A0A0A\", ring: \"rgba(245,244,241,0.6)\", code: \"#0B0B0B\", add: \"#4ADE80\", del: \"#F87171\", addBg: \"rgba(74,222,128,0.09)\", delBg: \"rgba(248,113,113,0.09)\", fresh: \"rgba(96,165,250,0.16)\", clear: \"rgba(96,165,250,0)\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.6)\", faint: \"rgba(10,10,10,0.4)\", card: \"#FFFFFF\", border: \"rgba(10,10,10,0.09)\", row: \"rgba(10,10,10,0.025)\", chip: \"rgba(10,10,10,0.05)\", on: \"#0A0A0A\", onText: \"#FAFAF8\", ring: \"rgba(10,10,10,0.5)\", code: \"#F6F6F3\", add: \"#15803D\", del: \"#DC2626\", addBg: \"rgba(21,128,61,0.08)\", delBg: \"rgba(220,38,38,0.07)\", fresh: \"rgba(37,99,235,0.12)\", clear: \"rgba(37,99,235,0)\" },\n};\nconst SEV: Record<Severity, { label: string; dark: string; light: string }> = {\n  info: { label: \"Info\", dark: \"#60A5FA\", light: \"#2563EB\" },\n  warning: { label: \"Warning\", dark: \"#FBBF24\", light: \"#B45309\" },\n  critical: { label: \"Critical\", dark: \"#F87171\", light: \"#DC2626\" },\n};\n\nconst PEOPLE = {\n  mara: { name: \"Mara Okafor\", email: \"mara@nexora.io\", kind: \"user\" as const },\n  daniel: { name: \"Daniel Reyes\", email: \"daniel@nexora.io\", kind: \"user\" as const },\n  lena: { name: \"Lena Brandt\", email: \"lena@nexora.io\", kind: \"user\" as const },\n  tomas: { name: \"Tomás Ferreira\", email: \"tomas@nexora.io\", kind: \"user\" as const },\n  ci: { name: \"ci-deploy\", email: \"token nx_live_…4f2c\", kind: \"api\" as const },\n  system: { name: \"System\", kind: \"system\" as const },\n};\nconst UA = \"Chrome 131 on macOS\";\nconst DEFAULT_EVENTS: AuditEvent[] = (\n  [\n    [0, PEOPLE.mara, \"member.role_updated\", \"Daniel Reyes\", \"warning\", \"81.214.62.10\", \"Berlin, DE\", { role: \"member\", projects: 3 }, { role: \"admin\", projects: 3 }],\n    [48, PEOPLE.ci, \"deployment.created\", \"web@4f2c91a\", \"info\", \"34.120.18.4\", \"us-east1\", null, { environment: \"production\", commit: \"4f2c91a\", duration_s: 74 }],\n    [131, PEOPLE.lena, \"auth.login_failed\", \"lena@nexora.io\", \"warning\", \"185.62.188.7\", \"Lisbon, PT\", null, { reason: \"wrong_password\", attempts: 3 }],\n    [260, PEOPLE.tomas, \"project.deleted\", \"Legacy CRM\", \"critical\", \"91.66.140.22\", \"Porto, PT\", { name: \"Legacy CRM\", status: \"archived\", members: 6 }, null],\n    [402, PEOPLE.mara, \"billing.plan_changed\", \"Nexora workspace\", \"info\", \"81.214.62.10\", \"Berlin, DE\", { plan: \"Team\", seats: 12, interval: \"monthly\" }, { plan: \"Business\", seats: 20, interval: \"yearly\" }],\n    [655, PEOPLE.daniel, \"settings.sso_enforced\", \"Workspace security\", \"warning\", \"77.12.4.190\", \"Madrid, ES\", { sso_required: false, allowed_domains: [\"nexora.io\"] }, { sso_required: true, allowed_domains: [\"nexora.io\", \"nexora.dev\"] }],\n    [901, PEOPLE.system, \"backup.completed\", \"postgres-main\", \"info\", undefined, \"eu-central-1\", null, { size_gb: 48.2, duration_s: 312 }],\n    [1240, PEOPLE.ci, \"api_key.created\", \"Analytics export\", \"warning\", \"34.120.18.4\", \"us-east1\", null, { scopes: [\"read:events\"], expires: \"2027-02-01\" }],\n    [1610, PEOPLE.daniel, \"webhook.updated\", \"hooks.nexora.io/billing\", \"info\", \"77.12.4.190\", \"Madrid, ES\", { events: [\"invoice.paid\"], active: true }, { events: [\"invoice.paid\", \"invoice.overdue\"], active: true }],\n    [2050, PEOPLE.lena, \"member.invited\", \"noor@kestrel.dev\", \"info\", \"185.62.188.7\", \"Lisbon, PT\", null, { role: \"viewer\", expires_in_days: 7 }],\n    [2730, PEOPLE.system, \"auth.session_revoked\", \"Tomás Ferreira\", \"critical\", undefined, \"eu-central-1\", { sessions: 4 }, { sessions: 0, reason: \"password_reset\" }],\n    [3300, PEOPLE.tomas, \"data.export_requested\", \"Customers (12,480 rows)\", \"warning\", \"91.66.140.22\", \"Porto, PT\", null, { format: \"csv\", fields: 14 }],\n    [4120, PEOPLE.mara, \"member.removed\", \"Jonah Pike\", \"warning\", \"81.214.62.10\", \"Berlin, DE\", { role: \"editor\", seats_used: 19 }, { seats_used: 18 }],\n    [5400, PEOPLE.daniel, \"auth.mfa_enabled\", \"daniel@nexora.io\", \"info\", \"77.12.4.190\", \"Madrid, ES\", { mfa: false }, { mfa: true, method: \"totp\" }],\n  ] as const\n).map(([ago, actor, action, target, severity, ip, location, before, after], i) => ({\n  id: `evt_${(9184 - i).toString(36)}`,\n  time: new Date(Date.parse(\"2026-11-01T14:32:08Z\") - ago * 1000).toISOString(),\n  actor,\n  action,\n  target,\n  severity,\n  ip,\n  location,\n  userAgent: actor.kind === \"user\" ? UA : actor.kind === \"api\" ? \"nexora-cli/2.4\" : undefined,\n  before: before as AuditEvent[\"before\"],\n  after: after as AuditEvent[\"after\"],\n}));\n\nconst LIVE: [keyof typeof PEOPLE, string, string, Severity, AuditEvent[\"after\"]][] = [\n  [\"lena\", \"auth.login_succeeded\", \"lena@nexora.io\", \"info\", { method: \"password\", mfa: true }],\n  [\"ci\", \"deployment.created\", \"api@9b1e07d\", \"info\", { environment: \"staging\", commit: \"9b1e07d\" }],\n  [\"daniel\", \"auth.login_failed\", \"daniel@nexora.io\", \"warning\", { reason: \"expired_code\", attempts: 1 }],\n  [\"mara\", \"document.shared\", \"Q4 board deck\", \"info\", { with: \"board@nexora.io\", access: \"view\" }],\n  [\"system\", \"auth.suspicious_login\", \"tomas@nexora.io\", \"critical\", { country: \"unknown\", blocked: true }],\n  [\"tomas\", \"project.created\", \"Partner portal\", \"info\", { visibility: \"private\" }],\n];\n\nconst MONTHS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\nconst clock = (iso: string) => iso.slice(11, 19);\nconst date = (iso: string) => `${Number(iso.slice(8, 10))} ${MONTHS[Number(iso.slice(5, 7)) - 1]}`;\n\nfunction diff(before: AuditEvent[\"before\"], after: AuditEvent[\"after\"]) {\n  const a = before ?? {};\n  const b = after ?? {};\n  const keys = Array.from(new Set([...Object.keys(a), ...Object.keys(b)]));\n  const out: { sign: \" \" | \"-\" | \"+\"; text: string }[] = [];\n  for (const k of keys) {\n    const x = k in a ? JSON.stringify(a[k]) : undefined;\n    const y = k in b ? JSON.stringify(b[k]) : undefined;\n    if (x === y) out.push({ sign: \" \", text: `${k}: ${x}` });\n    else {\n      if (x !== undefined) out.push({ sign: \"-\", text: `${k}: ${x}` });\n      if (y !== undefined) out.push({ sign: \"+\", text: `${k}: ${y}` });\n    }\n  }\n  return out;\n}\n\nexport function AuditLogTable({ title = \"Audit log\", events, live = true, onPoll, interval = 3200, pageSize = 10, theme = \"dark\", className }: AuditLogTableProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [list, setList] = React.useState<AuditEvent[]>(() => events ?? DEFAULT_EVENTS);\n  const [streaming, setStreaming] = React.useState(live);\n  const [sev, setSev] = React.useState<Severity[]>([]);\n  const [actor, setActor] = React.useState(\"all\");\n  const [q, setQ] = React.useState(\"\");\n  const [open, setOpen] = React.useState<string[]>([]);\n  const [shown, setShown] = React.useState(pageSize);\n  const [fresh, setFresh] = React.useState<string[]>([]);\n  // Visible column count, so the details row spans exactly the columns shown (hidden ones would become empty columns).\n  const [cols, setCols] = React.useState(6);\n  const measure = React.useCallback((el: HTMLElement | null) => {\n    if (!el) return;\n    const ro = new ResizeObserver(([entry]) => {\n      const w = entry.contentRect.width;\n      setCols(3 + (w >= 560 ? 1 : 0) + (w >= 720 ? 1 : 0) + (w >= 900 ? 1 : 0));\n    });\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n  const seq = React.useRef(0);\n  const latest = React.useRef(list[0]?.time ?? \"2026-11-01T14:32:08Z\");\n\n  React.useEffect(() => {\n    if (!streaming) return;\n    const t = setInterval(async () => {\n      let incoming: AuditEvent[];\n      if (onPoll) incoming = await onPoll(latest.current);\n      else {\n        const n = seq.current++;\n        const [who, action, target, severity, after] = LIVE[n % LIVE.length];\n        const actorObj = PEOPLE[who];\n        incoming = [\n          {\n            id: `evt_live_${n}`,\n            time: new Date(Date.parse(latest.current) + (6 + ((n * 13) % 29)) * 1000).toISOString(),\n            actor: actorObj,\n            action,\n            target,\n            severity,\n            ip: actorObj.kind === \"system\" ? undefined : `81.214.${60 + (n % 30)}.${10 + ((n * 7) % 200)}`,\n            location: actorObj.kind === \"system\" ? \"eu-central-1\" : \"Berlin, DE\",\n            userAgent: actorObj.kind === \"user\" ? UA : undefined,\n            before: null,\n            after,\n          },\n        ];\n      }\n      if (!incoming.length) return;\n      latest.current = incoming.reduce((m, e) => (e.time > m ? e.time : m), latest.current);\n      const ids = incoming.map((e) => e.id);\n      setList((v) => [...incoming, ...v].slice(0, 500));\n      setFresh((f) => [...f, ...ids]);\n      setTimeout(() => setFresh((f) => f.filter((id) => !ids.includes(id))), 2000);\n    }, interval);\n    return () => clearInterval(t);\n  }, [streaming, interval, onPoll]);\n\n  const actors = Array.from(new Map(list.map((e) => [e.actor.name, e.actor])).values()).sort((a, b) => a.name.localeCompare(b.name));\n  const query = q.trim().toLowerCase();\n  const base = list.filter((e) => (actor === \"all\" || e.actor.name === actor) && (!query || `${e.action} ${e.target} ${e.actor.name} ${e.ip ?? \"\"}`.toLowerCase().includes(query)));\n  const rows = base.filter((e) => !sev.length || sev.includes(e.severity));\n  const visible = rows.slice(0, shown);\n\n  const exportJson = () => {\n    const blob = new Blob([JSON.stringify(rows, null, 2)], { type: \"application/json\" });\n    const url = URL.createObjectURL(blob);\n    const a = document.createElement(\"a\");\n    a.href = url;\n    a.download = `audit-log-${(rows[0]?.time ?? latest.current).slice(0, 10)}.json`;\n    a.click();\n    setTimeout(() => URL.revokeObjectURL(url), 1000);\n  };\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.card } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const sevColor = (s: Severity) => SEV[s][theme];\n  const badge = (e: AuditEvent, cls?: string) => (\n    <span className={cn(\"inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[11.5px] font-medium whitespace-nowrap\", cls)} style={{ background: p.chip, color: sevColor(e.severity) }}>\n      <span className=\"h-1.5 w-1.5 rounded-full\" style={{ background: sevColor(e.severity) }} aria-hidden=\"true\" />\n      {SEV[e.severity].label}\n    </span>\n  );\n  const avatar = (a: AuditEvent[\"actor\"]) => (\n    <span className=\"flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-[10.5px] font-semibold\" style={{ background: p.chip, color: p.muted }} aria-hidden=\"true\">\n      {a.kind === \"api\" ? (\n        <svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n          <circle cx=\"8\" cy=\"15\" r=\"4\" />\n          <path d=\"m10.8 12.2 8.7-8.7M17 6l2.5 2.5M14.5 8.5 16.5 10.5\" />\n        </svg>\n      ) : a.kind === \"system\" ? (\n        <svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n          <rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"3\" />\n          <path d=\"M9 9h6v6H9z\" />\n        </svg>\n      ) : (\n        a.name\n          .split(\" \")\n          .map((w) => w[0])\n          .join(\"\")\n          .slice(0, 2)\n      )}\n    </span>\n  );\n\n  return (\n    <section ref={measure} className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"mx-auto max-w-6xl px-4 py-10 @[640px]:px-6 @[640px]:py-14\">\n        <div className=\"overflow-hidden rounded-2xl border\" style={{ background: p.card, borderColor: p.border }}>\n          {/* Header */}\n          <div className=\"flex flex-wrap items-center justify-between gap-3 border-b px-4 py-4 @[640px]:px-5\" style={{ borderColor: p.border }}>\n            <div className=\"flex min-w-0 items-center gap-3\">\n              <h2 className=\"m-0 text-[20px] font-semibold tracking-[-0.02em]\">{title}</h2>\n              <span className=\"flex items-center gap-1.5 text-[12px]\" style={{ color: streaming ? p.add : p.faint }} aria-live=\"polite\">\n                <span className=\"relative flex h-2 w-2\">\n                  {streaming && !reduce && <span className=\"absolute inline-flex h-full w-full animate-ping rounded-full opacity-60\" style={{ background: p.add }} />}\n                  <span className=\"relative inline-flex h-2 w-2 rounded-full\" style={{ background: streaming ? p.add : p.faint }} />\n                </span>\n                {streaming ? \"Live\" : \"Paused\"}\n              </span>\n            </div>\n            <div className=\"flex items-center gap-2\">\n              <button type=\"button\" role=\"switch\" aria-checked={streaming} onClick={() => setStreaming((s) => !s)} className={cn(\"flex h-8 cursor-pointer items-center gap-2 rounded-lg border px-2.5 text-[13px]\", focus)} style={{ borderColor: p.border, background: \"transparent\", color: p.text, ...ring }}>\n                <span className=\"relative h-4 w-7 rounded-full transition-colors\" style={{ background: streaming ? p.add : p.chip }} aria-hidden=\"true\">\n                  <motion.span className=\"absolute top-0.5 h-3 w-3 rounded-full\" style={{ background: streaming ? p.onText : p.muted }} initial={false} animate={{ left: streaming ? 14 : 2 }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 600, damping: 34 }} />\n                </span>\n                Live stream\n              </button>\n              <button type=\"button\" onClick={exportJson} disabled={!rows.length} className={cn(\"flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border-0 px-3 text-[13px] font-medium disabled:cursor-not-allowed disabled:opacity-40\", focus)} style={{ background: p.on, color: p.onText, ...ring }}>\n                <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                  <path d=\"M12 4v11m0 0-4-4m4 4 4-4M5 20h14\" />\n                </svg>\n                Export JSON\n              </button>\n            </div>\n          </div>\n\n          {/* Filters */}\n          <div className=\"flex flex-col gap-2.5 border-b px-4 py-3 @[720px]:flex-row @[720px]:items-center @[640px]:px-5\" style={{ borderColor: p.border }}>\n            <div className=\"flex flex-wrap gap-1.5\" role=\"group\" aria-label=\"Severity\">\n              {(Object.keys(SEV) as Severity[]).map((s) => {\n                const on = sev.includes(s);\n                const n = base.filter((e) => e.severity === s).length;\n                return (\n                  <button\n                    key={s}\n                    type=\"button\"\n                    aria-pressed={on}\n                    onClick={() => {\n                      setSev((v) => (on ? v.filter((x) => x !== s) : [...v, s]));\n                      setShown(pageSize);\n                    }}\n                    className={cn(\"flex h-8 cursor-pointer items-center gap-1.5 rounded-full border px-3 text-[12.5px]\", focus)}\n                    style={{ borderColor: on ? sevColor(s) : p.border, background: on ? p.chip : \"transparent\", color: on ? p.text : p.muted, ...ring }}\n                  >\n                    <span className=\"h-1.5 w-1.5 rounded-full\" style={{ background: sevColor(s) }} aria-hidden=\"true\" />\n                    {SEV[s].label}\n                    <span className=\"tabular-nums\" style={{ color: p.faint }}>\n                      {n}\n                    </span>\n                  </button>\n                );\n              })}\n            </div>\n            <div className=\"flex flex-1 gap-2 @[720px]:justify-end\">\n              <label className=\"sr-only\" htmlFor={`${uid}-actor`}>\n                Actor\n              </label>\n              <select id={`${uid}-actor`} value={actor} onChange={(e) => { setActor(e.target.value); setShown(pageSize); }} className={cn(\"h-8 min-w-0 shrink cursor-pointer rounded-lg border px-2 text-[13px]\", focus)} style={{ borderColor: p.border, background: p.card, color: p.text, ...ring }}>\n                <option value=\"all\">All actors</option>\n                {actors.map((a) => (\n                  <option key={a.name} value={a.name}>\n                    {a.name}\n                  </option>\n                ))}\n              </select>\n              <label className=\"relative min-w-0 flex-1 @[720px]:max-w-[240px]\">\n                <span className=\"sr-only\">Search events</span>\n                <svg className=\"pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\" style={{ color: p.faint }}>\n                  <circle cx=\"11\" cy=\"11\" r=\"7\" />\n                  <path d=\"m20 20-3.5-3.5\" />\n                </svg>\n                <input type=\"search\" value={q} onChange={(e) => { setQ(e.target.value); setShown(pageSize); }} placeholder=\"Action, target, IP\" className={cn(\"h-8 w-full rounded-lg border pr-2 pl-8 text-[13px]\", focus)} style={{ borderColor: p.border, background: p.card, color: p.text, ...ring }} />\n              </label>\n            </div>\n          </div>\n\n          {/* Table */}\n          <table className=\"w-full table-fixed border-collapse text-left text-[13.5px]\">\n            <caption className=\"sr-only\">\n              {title}, {rows.length} events, newest first. Times in UTC.\n            </caption>\n            <thead>\n              <tr className=\"text-[12px]\" style={{ color: p.faint, background: p.row }}>\n                <th scope=\"col\" className=\"w-[92px] py-2.5 pl-4 font-medium @[640px]:w-[112px] @[640px]:pl-5\">\n                  Time <span className=\"font-normal\">UTC</span>\n                </th>\n                <th scope=\"col\" className=\"hidden w-[200px] px-3 py-2.5 font-medium @[720px]:table-cell\">\n                  Actor\n                </th>\n                <th scope=\"col\" className=\"px-3 py-2.5 font-medium\">\n                  Event\n                </th>\n                <th scope=\"col\" className=\"hidden w-[110px] px-3 py-2.5 font-medium @[560px]:table-cell\">\n                  Severity\n                </th>\n                <th scope=\"col\" className=\"hidden w-[132px] px-3 py-2.5 font-medium @[900px]:table-cell\">\n                  IP address\n                </th>\n                <th scope=\"col\" className=\"w-11 pr-3\">\n                  <span className=\"sr-only\">Details</span>\n                </th>\n              </tr>\n            </thead>\n            <AnimatePresence initial={false}>\n              {visible.map((e) => {\n                const isOpen = open.includes(e.id);\n                const lines = diff(e.before, e.after);\n                const toggle = () => setOpen((v) => (isOpen ? v.filter((x) => x !== e.id) : [...v, e.id]));\n                return (\n                  <motion.tbody key={e.id} layout={reduce ? false : \"position\"} initial={reduce ? false : { opacity: 0, y: -8 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0 }} transition={{ duration: 0.25 }} className=\"border-t\" style={{ borderColor: p.border }}>\n                    <motion.tr\n                      initial={reduce || !fresh.includes(e.id) ? false : { backgroundColor: p.fresh }}\n                      animate={{ backgroundColor: isOpen ? p.row : p.clear }}\n                      transition={{ duration: 1.6 }}\n                      onClick={toggle}\n                      className=\"cursor-pointer\"\n                      style={{ boxShadow: e.severity === \"critical\" ? `inset 2px 0 0 ${sevColor(\"critical\")}` : undefined }}\n                    >\n                      <td className=\"py-3 pl-4 align-top @[640px]:pl-5\">\n                        <span className=\"block font-mono text-[12.5px] tabular-nums\">{clock(e.time)}</span>\n                        <span className=\"block text-[11.5px]\" style={{ color: p.faint }}>\n                          {date(e.time)}\n                        </span>\n                      </td>\n                      <td className=\"hidden px-3 py-3 align-top @[720px]:table-cell\">\n                        <span className=\"flex min-w-0 items-center gap-2\">\n                          {avatar(e.actor)}\n                          <span className=\"min-w-0\">\n                            <span className=\"block truncate font-medium\">{e.actor.name}</span>\n                            <span className=\"block truncate text-[11.5px]\" style={{ color: p.faint }}>\n                              {e.actor.email ?? \"Automated\"}\n                            </span>\n                          </span>\n                        </span>\n                      </td>\n                      <td className=\"min-w-0 px-3 py-3 align-top\">\n                        <code className=\"inline-block max-w-full truncate rounded px-1.5 py-0.5 font-mono text-[12px] align-top\" style={{ background: p.chip }}>\n                          {e.action}\n                        </code>\n                        <span className=\"mt-1 block truncate\" style={{ color: p.muted }}>\n                          {e.target}\n                        </span>\n                        <span className=\"mt-1 flex items-center gap-2 text-[11.5px] @[720px]:hidden\" style={{ color: p.faint }}>\n                          <span className=\"truncate\">{e.actor.name}</span>\n                          {badge(e, \"@[560px]:hidden\")}\n                        </span>\n                      </td>\n                      <td className=\"hidden px-3 py-3 align-top @[560px]:table-cell\">{badge(e)}</td>\n                      <td className=\"hidden px-3 py-3 align-top font-mono text-[12px] @[900px]:table-cell\" style={{ color: p.muted }}>\n                        {e.ip ?? \"—\"}\n                      </td>\n                      <td className=\"py-2 pr-3 align-top\">\n                        <button\n                          type=\"button\"\n                          aria-expanded={isOpen}\n                          aria-controls={`${uid}-${e.id}`}\n                          aria-label={`${isOpen ? \"Hide\" : \"Show\"} details for ${e.action} on ${e.target}`}\n                          onClick={(ev) => {\n                            ev.stopPropagation();\n                            toggle();\n                          }}\n                          className={cn(\"flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg border-0 bg-transparent\", focus)}\n                          style={{ color: p.muted, ...ring }}\n                        >\n                          <motion.svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" animate={{ rotate: isOpen ? 180 : 0 }} transition={{ duration: reduce ? 0 : 0.2 }}>\n                            <path d=\"m4 6 4 4 4-4\" />\n                          </motion.svg>\n                        </button>\n                      </td>\n                    </motion.tr>\n                    <tr>\n                      <td colSpan={cols} className=\"p-0\">\n                        <AnimatePresence initial={false}>\n                          {isOpen && (\n                            <motion.div id={`${uid}-${e.id}`} initial={reduce ? false : { height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={reduce ? undefined : { height: 0, opacity: 0 }} transition={{ duration: 0.22 }} className=\"overflow-hidden\" style={{ background: p.row }}>\n                              <div className=\"grid gap-4 px-4 pt-1 pb-4 @[640px]:px-5 @[720px]:grid-cols-[minmax(0,240px)_1fr]\">\n                                <dl className=\"m-0 grid grid-cols-[88px_1fr] gap-x-3 gap-y-1.5 text-[12.5px]\">\n                                  {(\n                                    [\n                                      [\"Actor\", `${e.actor.name}${e.actor.email ? ` · ${e.actor.email}` : \"\"}`],\n                                      [\"Severity\", SEV[e.severity].label],\n                                      [\"IP address\", e.ip ?? \"—\"],\n                                      [\"Location\", e.location ?? \"—\"],\n                                      [\"Client\", e.userAgent ?? \"—\"],\n                                      [\"Event ID\", e.id],\n                                      [\"Timestamp\", e.time],\n                                    ] as const\n                                  ).map(([k, v]) => (\n                                    <React.Fragment key={k}>\n                                      <dt style={{ color: p.faint }}>{k}</dt>\n                                      <dd className=\"m-0 min-w-0 break-words\" style={{ color: p.text }}>\n                                        {v}\n                                      </dd>\n                                    </React.Fragment>\n                                  ))}\n                                </dl>\n                                <div className=\"min-w-0\">\n                                  <p className=\"m-0 mb-1.5 text-[12px]\" style={{ color: p.faint }}>\n                                    {e.before && e.after ? \"Changes\" : e.before ? \"Removed\" : \"Details\"}\n                                  </p>\n                                  {lines.length ? (\n                                    <pre className=\"m-0 overflow-x-auto rounded-lg border py-2 font-mono text-[12px] leading-[1.7]\" style={{ background: p.code, borderColor: p.border }} aria-label=\"Before and after\">\n                                      {lines.map((l, i) => (\n                                        <span key={i} className=\"block px-3\" style={{ background: l.sign === \"+\" ? p.addBg : l.sign === \"-\" ? p.delBg : \"transparent\", color: l.sign === \"+\" ? p.add : l.sign === \"-\" ? p.del : p.muted }}>\n                                          <span className=\"inline-block w-4 select-none\" aria-label={l.sign === \"+\" ? \"added\" : l.sign === \"-\" ? \"removed\" : undefined}>\n                                            {l.sign}\n                                          </span>\n                                          {l.text}\n                                        </span>\n                                      ))}\n                                    </pre>\n                                  ) : (\n                                    <p className=\"m-0 text-[12.5px]\" style={{ color: p.muted }}>\n                                      No changes recorded.\n                                    </p>\n                                  )}\n                                </div>\n                              </div>\n                            </motion.div>\n                          )}\n                        </AnimatePresence>\n                      </td>\n                    </tr>\n                  </motion.tbody>\n                );\n              })}\n            </AnimatePresence>\n          </table>\n          {rows.length === 0 && (\n            <p className=\"m-0 px-5 py-12 text-center text-[14px]\" style={{ color: p.muted }}>\n              No events match these filters.\n            </p>\n          )}\n          <div className=\"flex items-center justify-between gap-3 border-t px-4 py-3 text-[12.5px] @[640px]:px-5\" style={{ borderColor: p.border, color: p.faint }}>\n            <span className=\"tabular-nums\">\n              Showing {visible.length} of {rows.length}\n            </span>\n            {rows.length > shown && (\n              <button type=\"button\" onClick={() => setShown((n) => n + pageSize)} className={cn(\"h-8 cursor-pointer rounded-lg border px-3 text-[13px]\", focus)} style={{ borderColor: p.border, background: \"transparent\", color: p.text, ...ring }}>\n                Load {Math.min(pageSize, rows.length - shown)} more\n              </button>\n            )}\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default AuditLogTable;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}