"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { memo } from "react";
import { ExecutionPhase } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
import { cn } from "@stigmer/theme";
import { Tabs } from "../../tabs/Tabs";
import { ExecutionPhaseBadge } from "../../execution/ExecutionPhaseBadge";
import { useSessionArtifacts } from "../useSessionArtifacts";
import { useSessionWriteBacks } from "../useSessionWriteBacks";
import { useSessionUsage } from "../useSessionUsage";
import { useSessionInspector } from "./useSessionInspector";
import { PlanTab } from "./PlanTab";
import { ChangesTab } from "./ChangesTab";
import { ArtifactsTab } from "./ArtifactsTab";
import { UsageTab } from "./UsageTab";
import { InspectTab } from "./InspectTab";
import { SetupTab } from "./SetupTab";
import { WorkspaceTab } from "./WorkspaceTab";
/**
 * Tabbed right-side inspector panel for agent sessions.
 *
 * Displays an always-visible run-status header (phase badge) above
 * contextual tabs: Plan, Changes, Artifacts, Usage, and Inspect
 * (when a thread item is selected).
 *
 * Mirrors the `ExecutionInspector` architecture from the workflow
 * view — same `Tabs` primitive, same tab-FSM behavior hook, same
 * contextual visibility pattern.
 *
 * `React.memo`'d to prevent re-renders from parent layout changes
 * that don't affect inspector data.
 *
 * All visual properties flow through `--stgm-*` tokens. Zero
 * Console/Next/Tauri dependencies (DD-004).
 */
export const SessionInspector = memo(function SessionInspector({ displayExecution, allExecutions, org, selectedItem, onApplied, sessionConfig, workspaceConfig, className, }) {
    const phase = displayExecution?.status?.phase ??
        ExecutionPhase.EXECUTION_PHASE_UNSPECIFIED;
    const { hasWriteBacks, writeBackCount } = useSessionWriteBacks(allExecutions);
    const { hasArtifacts, artifactCount } = useSessionArtifacts(allExecutions);
    const { hasUsage } = useSessionUsage(allExecutions);
    const { tabs, activeTab, onTabChange } = useSessionInspector({
        phase: phase === ExecutionPhase.EXECUTION_PHASE_UNSPECIFIED ? null : phase,
        hasWriteBacks,
        writeBackCount,
        hasArtifacts,
        artifactCount,
        hasUsage,
        selectedItem,
    });
    return (_jsxs("div", { className: cn("flex h-full flex-col", className), children: [_jsx("div", { className: "flex items-center gap-2 border-b border-border px-3 py-2.5", children: phase !== ExecutionPhase.EXECUTION_PHASE_UNSPECIFIED ? (_jsx(ExecutionPhaseBadge, { phase: phase })) : (_jsx("span", { className: "text-xs text-muted-foreground", children: "No execution" })) }), _jsx(Tabs, { tabs: tabs, activeTab: activeTab, onTabChange: onTabChange, "aria-label": "Session details", className: "min-h-0 flex-1", children: _jsxs("div", { className: "h-full min-h-0 overflow-y-auto px-3 py-3", children: [activeTab === "workspace" && workspaceConfig && (_jsx(WorkspaceTab, { ...workspaceConfig })), activeTab === "configure" && sessionConfig && (_jsx(SetupTab, { ...sessionConfig })), activeTab === "plan" && (_jsx(PlanTab, { execution: displayExecution })), activeTab === "changes" && (_jsx(ChangesTab, { executions: allExecutions })), activeTab === "artifacts" && (_jsx(ArtifactsTab, { executions: allExecutions, org: org, onApplied: onApplied })), activeTab === "usage" && (_jsx(UsageTab, { executions: allExecutions })), activeTab === "inspect" && (_jsx(InspectTab, { selectedItem: selectedItem }))] }) })] }));
});
//# sourceMappingURL=SessionInspector.js.map