import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ArrowRight, Lightbulb, MessageSquarePlus, X } from "lucide-react";
/**
 * Dismissible hint banner rendered above the prompt input. The agent emits an agent:suggestion
 * websocket (via the suggest-action tool); this renders it with an action button that either
 * starts a fresh chat on the same profile or switches to the suggested profile.
 */
export function AgentSuggestionBanner({ suggestion, agent, activeProfile, onDismiss, onSwitchProfile, }) {
    if (!suggestion) {
        return null;
    }
    const isSwitch = suggestion.kind === "switch-profile";
    const targetName = suggestion.targetProfileName?.trim();
    const actionDisabled = isSwitch
        ? !suggestion.targetProfileId
        : !activeProfile;
    const actionLabel = isSwitch
        ? targetName
            ? `Switch to ${targetName}`
            : "Switch profile"
        : "Start new chat";
    const handleAction = () => {
        if (isSwitch) {
            if (suggestion.targetProfileId) {
                onSwitchProfile(suggestion.targetProfileId);
            }
            return;
        }
        // Start a fresh chat on the same profile (new agent, empty transcript). When the agent
        // supplied a suggested opening prompt, hand it over to pre-fill the new chat's composer.
        if (activeProfile) {
            const initialPrompt = suggestion.initialPrompt?.trim() || undefined;
            window.dispatchEvent(new CustomEvent("editor:createAgentWithProfile", {
                detail: { profile: activeProfile, initialPrompt },
            }));
        }
        onDismiss();
    };
    return (_jsx("div", { className: "border-feedback-blue bg-feedback-blue-light text-feedback-blue mx-3 mb-2 rounded border p-3 text-[11px] select-text", "data-testid": "agent-suggestion-banner", "data-suggestion-kind": suggestion.kind, "data-agent-id": agent?.id, children: _jsxs("div", { className: "flex items-start gap-2", children: [_jsx(Lightbulb, { className: "text-feedback-blue mt-0.5 h-4 w-4 shrink-0", strokeWidth: 1.5 }), _jsxs("div", { className: "flex-1", children: [suggestion.reason ? (_jsx("div", { className: "mb-2", children: suggestion.reason })) : null, _jsxs("button", { type: "button", className: "border-feedback-blue badge-pad hover:bg-feedback-blue-light inline-flex items-center gap-1 rounded border bg-white disabled:cursor-not-allowed disabled:opacity-50", onClick: handleAction, disabled: actionDisabled, "data-testid": "agent-suggestion-action", children: [isSwitch ? (_jsx(ArrowRight, { size: 12, strokeWidth: 1.5 })) : (_jsx(MessageSquarePlus, { size: 12, strokeWidth: 1.5 })), actionLabel] })] }), _jsx("button", { type: "button", "aria-label": "Dismiss suggestion", className: "text-feedback-blue/70 hover:text-feedback-blue shrink-0", onClick: onDismiss, "data-testid": "agent-suggestion-dismiss", children: _jsx(X, { size: 14, strokeWidth: 1.5 }) })] }) }));
}
//# sourceMappingURL=AgentSuggestionBanner.js.map