"use client";
import { useMemo } from "react";
import { deriveTaskDetail } from "./derive-task-detail";
/**
 * Data hook that derives rich per-task detail for the runtime inspector.
 *
 * Joins the event stream (for timeline data) with the execution status
 * snapshot (for full I/O) to produce a `TaskDetail` for the selected task.
 *
 * Returns `null` when `selectedTaskName` is null or no data exists for
 * the selected task.
 *
 * @example
 * ```tsx
 * const { detail } = useExecutionTaskDetail({
 *   selectedTaskName: "classify_input",
 *   events,
 *   taskStates,
 *   taskSnapshots: execution?.status?.tasks,
 * });
 * if (detail) {
 *   // Render tabs based on detail.input, detail.error, etc.
 * }
 * ```
 */
export function useExecutionTaskDetail(options) {
    const { selectedTaskName, events, taskStates, taskSnapshots } = options;
    const detail = useMemo(() => {
        if (!selectedTaskName)
            return null;
        const snapshot = taskSnapshots?.find((t) => t.taskName === selectedTaskName);
        const derived = taskStates.get(selectedTaskName);
        return deriveTaskDetail(selectedTaskName, events, snapshot, derived);
    }, [selectedTaskName, events, taskStates, taskSnapshots]);
    return { detail };
}
//# sourceMappingURL=useExecutionTaskDetail.js.map