"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { memo } from "react";
import { cn } from "@stigmer/theme";
import { formatTimestamp } from "../format-utils.js";
/**
 * Filtered event log for a single task. Shows the raw event timeline
 * for debugging — sequence number, timestamp, event type.
 */
export const EventLogTab = memo(function EventLogTab({ events, className }) {
    if (events.length === 0) {
        return (_jsx("p", { className: cn("text-xs text-muted-foreground py-4 text-center", className), children: "No events recorded for this task" }));
    }
    return (_jsx("div", { className: cn("flex flex-col text-xs", className), role: "list", "aria-label": "Task events", children: events.map((evt) => (_jsxs("div", { className: "flex items-baseline gap-2 border-b border-border/50 px-1 py-1.5 last:border-b-0", role: "listitem", children: [_jsxs("span", { className: "shrink-0 tabular-nums text-[10px] text-muted-foreground", children: ["#", String(evt.sequenceNumber)] }), _jsx("span", { className: "min-w-0 flex-1 truncate text-foreground", children: formatPayloadLabel(evt) }), _jsx("span", { className: "shrink-0 tabular-nums text-[10px] text-muted-foreground", children: formatTimestamp(evt.occurredAt) })] }, evt.eventId))) }));
});
function formatPayloadLabel(evt) {
    const p = evt.payload;
    switch (p.case) {
        case "taskStarted":
            return p.value.attemptNumber > 1
                ? `Task started (attempt ${p.value.attemptNumber})`
                : "Task started";
        case "taskCompleted":
            return "Task completed";
        case "taskFailed":
            return p.value.willRetry ? "Task failed (will retry)" : "Task failed";
        case "taskSkipped":
            return `Task skipped${p.value.reason ? `: ${p.value.reason}` : ""}`;
        case "taskRetrying":
            return `Retrying → attempt ${p.value.nextAttempt}`;
        case "agentCallStarted":
            return `Agent call started: ${p.value.agentSlug}`;
        case "agentCallProgress":
            return `Agent progress: ${p.value.messagesCount} msgs, ${p.value.toolCallsCount} tools`;
        case "agentCallCompleted":
            return p.value.error ? "Agent call failed" : "Agent call completed";
        case "approvalRequested":
            return "Approval requested";
        case "approvalResolved":
            return `Approval resolved by ${p.value.resolvedBy}`;
        case "artifactCreated":
            return `Artifact: ${p.value.displayName}`;
        default:
            return p.case ?? "Unknown event";
    }
}
//# sourceMappingURL=EventLogTab.js.map