import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ChevronDown, ChevronUp } from "lucide-react";
import { formatAllowanceLabel, formatAllowanceSource, } from "../../agentMessageHelpers";
function AgentSettingsSection({ title, expanded, onExpandedChange, testId, children, }) {
    return (_jsxs("div", { children: [_jsxs("button", { type: "button", onClick: () => onExpandedChange(!expanded), className: "text-neutral-grey-100 hover:bg-neutral-grey-5/80 mb-0.5 flex w-full items-center justify-between rounded px-0.5 py-0.5 text-left text-[11px] font-medium", "aria-expanded": expanded, "data-testid": `${testId}-toggle`, children: [_jsx("span", { children: title }), expanded ? (_jsx(ChevronUp, { className: "text-neutral-grey-50 h-3 w-3 shrink-0", strokeWidth: 1.5 })) : (_jsx(ChevronDown, { className: "text-neutral-grey-50 h-3 w-3 shrink-0", strokeWidth: 1.5 }))] }), expanded ? children : null] }));
}
export function AgentAvailableToolsSection({ expanded, onExpandedChange, tools, loading, error, isLocalOnlyDraftAgent, }) {
    return (_jsxs(AgentSettingsSection, { title: `Available tools (${tools.length})`, expanded: expanded, onExpandedChange: onExpandedChange, testId: "agent-tools-section", children: [_jsx("div", { className: "border-border-default bg-neutral-grey-5/50 max-h-36 overflow-y-auto rounded border p-1", "data-testid": "agent-tools-section", children: loading ? (_jsx("div", { className: "text-neutral-grey-50 px-1 text-[10px]", children: "Loading available tools..." })) : tools.length > 0 ? (_jsxs("div", { className: "space-y-0.5", children: [isLocalOnlyDraftAgent ? (_jsx("div", { className: "text-neutral-grey-50 px-1 text-[10px]", children: "Preview based on the current profile, mode, and selected skills." })) : null, tools.map((toolName) => (_jsx("div", { className: "rounded px-1 py-0.5 transition-colors hover:bg-white/60", "data-testid": "agent-tool-row", title: toolName, children: _jsx("div", { className: "text-neutral-grey-100 truncate text-[10px]", children: toolName }) }, toolName)))] })) : (_jsx("div", { className: "text-neutral-grey-50 px-1 text-[10px]", children: isLocalOnlyDraftAgent
                        ? "No available tools for this profile and mode"
                        : "No available tools" })) }), error ? (_jsx("div", { className: "text-feedback-red mt-1 text-[10px]", children: error })) : null] }));
}
export function AgentAllowancesSection({ expanded, onExpandedChange, totalCount, loading, error, hasAnyAllowances, groups, isLocalOnlyDraftAgent, }) {
    return (_jsxs(AgentSettingsSection, { title: `Allowances (${totalCount})`, expanded: expanded, onExpandedChange: onExpandedChange, testId: "agent-allowances-section", children: [_jsx("div", { className: "border-border-default bg-neutral-grey-5/50 max-h-36 overflow-y-auto rounded border p-1", "data-testid": "agent-allowances-section", children: loading ? (_jsx("div", { className: "text-neutral-grey-50 px-1 text-[10px]", children: "Loading allowances..." })) : hasAnyAllowances ? (_jsxs("div", { className: "space-y-1", children: [isLocalOnlyDraftAgent ? (_jsx("div", { className: "text-neutral-grey-50 px-1 text-[10px]", children: "Preview based on the current profile." })) : null, groups.map((group) => group.rows.length > 0 ? (_jsxs("div", { className: "space-y-0.5", children: [_jsx("div", { className: "text-neutral-grey-50 px-1 text-[9px] font-medium tracking-wide", children: group.label }), group.rows.map((allowance, index) => {
                                    const sourceLabel = formatAllowanceSource(allowance.source);
                                    const pathLabel = "itemPath" in allowance
                                        ? allowance.itemPath
                                        : allowance.normalizedPath;
                                    return (_jsxs("div", { className: "rounded px-1 py-0.5 transition-colors hover:bg-white/60", "data-testid": `agent-allowance-row-${group.key}`, children: [_jsxs("div", { className: "flex items-baseline gap-1.5", children: [_jsx("div", { className: "text-neutral-grey-100 shrink-0 text-[10px] font-medium", children: allowance.operationType || "*" }), _jsx("div", { className: "text-neutral-grey-50 truncate text-[9px]", title: formatAllowanceLabel(allowance), children: pathLabel })] }), sourceLabel || allowance.grantedBy ? (_jsx("div", { className: "text-neutral-grey-50 truncate pl-6 text-[9px]", children: [sourceLabel, allowance.grantedBy]
                                                    .filter(Boolean)
                                                    .join(" \u00b7 ") })) : null] }, `${group.key}-${allowance.operationType}-${pathLabel}-${index}`));
                                })] }, group.key)) : null)] })) : (_jsx("div", { className: "text-neutral-grey-50 px-1 text-[10px]", children: isLocalOnlyDraftAgent
                        ? "No configured allowances for this profile"
                        : "No active allowances" })) }), error ? (_jsx("div", { className: "text-feedback-red mt-1 text-[10px]", children: error })) : null] }));
}
export function AgentSubscribedTriggersSection({ expanded, onExpandedChange, subscriptions, loading, error, isLocalOnlyDraftAgent, }) {
    return (_jsxs(AgentSettingsSection, { title: `Subscribed triggers (${subscriptions.length})`, expanded: expanded, onExpandedChange: onExpandedChange, testId: "agent-subscribed-triggers-section", children: [_jsx("div", { className: "border-border-default bg-neutral-grey-5/50 max-h-28 overflow-y-auto rounded border p-1", "data-testid": "agent-subscribed-triggers-section", children: loading ? (_jsx("div", { className: "text-neutral-grey-50 px-1 text-[10px]", children: "Loading subscribed triggers..." })) : subscriptions.length > 0 ? (_jsx("div", { className: "space-y-0.5", children: subscriptions.map((sub) => {
                        const filterText = (sub.filter || "").trim();
                        return (_jsxs("div", { className: "flex items-baseline gap-1.5 rounded px-1 py-0.5 transition-colors hover:bg-white/60", children: [_jsx("div", { className: "text-neutral-grey-100 shrink-0 text-[10px] font-medium", children: sub.triggerName }), filterText.length > 0 ? (_jsx("div", { className: "text-neutral-grey-50 truncate text-[9px]", title: filterText, children: filterText })) : null] }, sub.id));
                    }) })) : (_jsx("div", { className: "text-neutral-grey-50 px-1 text-[10px]", children: isLocalOnlyDraftAgent
                        ? "Subscribed triggers are shown after the agent is created"
                        : "No active trigger subscriptions" })) }), error ? (_jsx("div", { className: "text-feedback-red mt-1 text-[10px]", children: error })) : null] }));
}
//# sourceMappingURL=AgentSettingsSections.js.map