"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { cn } from "@stigmer/theme";
import { HARNESS_META } from "../../models/harness";
/**
 * Persistent session configuration panel (Configure tab) — shows agent,
 * MCP servers, skills, run config, and session variables.
 *
 * Workspace management has moved to the dedicated Workspace tab.
 *
 * When mutation callbacks are provided via `mutations`, items render
 * inline remove/reconfigure affordances. When callbacks are absent,
 * sections render read-only (backward compatible, DD-011).
 *
 * All visual properties flow through `--stgm-*` tokens (DD-005).
 */
export function SetupTab({ agentRef, isDefaultAgent, mcpServerUsages, skillRefs, sessionVariables, harness, executionTarget, modelId, mutations, }) {
    const hasSessionVars = sessionVariables != null && !sessionVariables.isEmpty;
    return (_jsxs("div", { className: "flex flex-col gap-5", children: [_jsx(RunConfigSection, { harness: harness, executionTarget: executionTarget, modelId: modelId }), _jsx(AgentSection, { agentRef: agentRef, isDefaultAgent: isDefaultAgent, onRemove: mutations?.onRemoveAgent }), _jsx(McpSection, { mcpServerUsages: mcpServerUsages, onRemove: mutations?.onRemoveMcp }), _jsx(SkillsSection, { skillRefs: skillRefs, onRemove: mutations?.onRemoveSkill }), hasSessionVars && (_jsx(SessionVarsSection, { entries: sessionVariables.entries }))] }));
}
// ---------------------------------------------------------------------------
// Shared section primitives
// ---------------------------------------------------------------------------
function SectionHeading({ children }) {
    return (_jsx("h3", { className: "text-[0.65rem] font-semibold uppercase tracking-wider text-muted-foreground", children: children }));
}
function EmptyHint({ children }) {
    return (_jsx("p", { className: "text-xs text-muted-foreground/70", children: children }));
}
function ItemPill({ children, className: cls }) {
    return (_jsx("span", { className: cn("inline-flex items-center gap-1.5 rounded-md bg-muted-subtle px-2 py-1 text-xs text-foreground", cls), children: children }));
}
function RemoveButton({ onClick, label }) {
    return (_jsx("button", { type: "button", onClick: onClick, className: "shrink-0 text-muted-foreground hover:text-destructive transition-colors", "aria-label": label, children: _jsx(XIcon, {}) }));
}
// ---------------------------------------------------------------------------
// Run config
// ---------------------------------------------------------------------------
function RunConfigSection({ harness, executionTarget, modelId, }) {
    return (_jsxs("section", { className: "flex flex-col gap-1.5", children: [_jsx(SectionHeading, { children: "Run Config" }), _jsxs("div", { className: "flex flex-wrap gap-1.5", children: [_jsxs(ItemPill, { children: [_jsx("span", { className: "text-muted-foreground", children: "Harness" }), HARNESS_META[harness]?.label ?? harness] }), modelId && (_jsxs(ItemPill, { children: [_jsx("span", { className: "text-muted-foreground", children: "Model" }), modelId] })), executionTarget && (_jsxs(ItemPill, { children: [_jsx("span", { className: "text-muted-foreground", children: "Target" }), executionTarget === "local" ? "Local" : "Cloud"] }))] })] }));
}
// ---------------------------------------------------------------------------
// Agent
// ---------------------------------------------------------------------------
function AgentSection({ agentRef, isDefaultAgent, onRemove, }) {
    return (_jsxs("section", { className: "flex flex-col gap-1.5", children: [_jsx(SectionHeading, { children: "Agent" }), agentRef ? (_jsxs("div", { className: "flex items-center gap-1.5", children: [_jsxs(ItemPill, { children: [agentRef.slug, onRemove && !isDefaultAgent && (_jsx(RemoveButton, { onClick: onRemove, label: `Remove agent ${agentRef.slug}` }))] }), isDefaultAgent && (_jsx("span", { className: "rounded bg-primary/10 px-1.5 py-0.5 text-[0.6rem] font-medium text-primary", children: "default" }))] })) : (_jsx(EmptyHint, { children: "No agent selected \u2014 using platform default." }))] }));
}
// ---------------------------------------------------------------------------
// MCP Servers
// ---------------------------------------------------------------------------
function McpSection({ mcpServerUsages, onRemove, }) {
    return (_jsxs("section", { className: "flex flex-col gap-1.5", children: [_jsxs(SectionHeading, { children: ["MCP Servers", mcpServerUsages.length > 0 && (_jsxs("span", { className: "ml-1 text-muted-foreground/60", children: ["(", mcpServerUsages.length, ")"] }))] }), mcpServerUsages.length > 0 ? (_jsx("div", { className: "flex flex-col gap-1", children: mcpServerUsages.map((usage) => {
                    const slug = usage.mcpServerRef.slug;
                    const enabledCount = usage.enabledTools?.length;
                    return (_jsxs(ItemPill, { children: [_jsx("span", { children: slug }), enabledCount != null && enabledCount > 0 && (_jsxs("span", { className: "text-muted-foreground", children: [enabledCount, " tool", enabledCount !== 1 ? "s" : ""] })), onRemove && (_jsx(RemoveButton, { onClick: () => onRemove(usage.mcpServerRef), label: `Remove MCP server ${slug}` }))] }, `${usage.mcpServerRef.org}/${slug}`));
                }) })) : (_jsx(EmptyHint, { children: "No MCP servers attached." }))] }));
}
// ---------------------------------------------------------------------------
// Skills
// ---------------------------------------------------------------------------
function SkillsSection({ skillRefs, onRemove, }) {
    return (_jsxs("section", { className: "flex flex-col gap-1.5", children: [_jsxs(SectionHeading, { children: ["Skills", skillRefs.length > 0 && (_jsxs("span", { className: "ml-1 text-muted-foreground/60", children: ["(", skillRefs.length, ")"] }))] }), skillRefs.length > 0 ? (_jsx("div", { className: "flex flex-wrap gap-1.5", children: skillRefs.map((ref) => (_jsxs(ItemPill, { children: [ref.slug, onRemove && (_jsx(RemoveButton, { onClick: () => onRemove(ref), label: `Remove skill ${ref.slug}` }))] }, `${ref.org}/${ref.slug}`))) })) : (_jsx(EmptyHint, { children: "No skills attached." }))] }));
}
// ---------------------------------------------------------------------------
// Session Variables (ephemeral, only shown when entries exist)
// ---------------------------------------------------------------------------
function SessionVarsSection({ entries, }) {
    return (_jsxs("section", { className: "flex flex-col gap-1.5", children: [_jsxs(SectionHeading, { children: ["Session Variables", _jsx("span", { className: "ml-1 font-normal normal-case tracking-normal text-muted-foreground/60", children: "(next message only)" })] }), _jsx("div", { className: "flex flex-col gap-1", children: entries.map((entry) => (_jsxs(ItemPill, { children: [_jsx("span", { className: "font-medium", children: entry.key || "(unnamed)" }), entry.isSecret ? (_jsx("span", { className: "text-muted-foreground", children: "********" })) : (_jsx("span", { className: "max-w-[140px] truncate text-muted-foreground", children: entry.value }))] }, entry.id))) })] }));
}
// ---------------------------------------------------------------------------
// Inline SVG icons (SDK independence — no lucide dependency)
// ---------------------------------------------------------------------------
function XIcon() {
    return (_jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: "M4 4L10 10M10 4L4 10" }) }));
}
//# sourceMappingURL=SetupTab.js.map