import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Textarea } from "../../../../components/ui/textarea";
import { cn } from "../../../../lib/utils";
import { PlaceholderInput, } from "../../../../components/ui/PlaceholderInput";
import { hasPromptPlaceholders } from "../agentPromptPlaceholders";
export function AgentPromptInputArea({ activePlaceholderInput, prompt, hideBottomControls, effectiveIsFocused, readOnly, inputPlaceholder, isSubmitting, placeholderInputRef, promptPlaceholderInputRef, textareaRef, onFilledChange, onActivePlaceholderComplete, onActivePlaceholderCancel, onPromptPlaceholderComplete, onPromptPlaceholderCancel, onPromptChange, onKeyDown, onPaste, onFocus, onBlur, reserveBottomControlsSpace, attachmentsContent, inputSurface = "default", dropHandlers, }) {
    const isDragOver = dropHandlers?.isDragOver ?? false;
    const isFlatSurface = inputSurface === "flat";
    const textareaPaddingTop = isFlatSurface ? 0 : 12;
    const textareaPaddingBottom = 8;
    // The space for the controls overlaid on the bottom of the input must live
    // on the non-scrolling wrapper: a textarea paints scrolled text through its
    // own padding, so padding there would let text slide under the controls.
    const reservedControlsSpace = reserveBottomControlsSpace ? 42 : 0;
    if (activePlaceholderInput) {
        return (_jsx(PlaceholderInput, { ref: placeholderInputRef, text: activePlaceholderInput.text, showButtons: hideBottomControls, buttonsClassName: hideBottomControls ? "justify-end" : "", onFilledChange: onFilledChange, onComplete: onActivePlaceholderComplete, onCancel: onActivePlaceholderCancel }));
    }
    if (hasPromptPlaceholders(prompt)) {
        return (_jsx(PlaceholderInput, { ref: promptPlaceholderInputRef, text: prompt, showButtons: hideBottomControls, buttonsClassName: hideBottomControls ? "justify-end" : "", onFilledChange: onFilledChange, onComplete: onPromptPlaceholderComplete, onCancel: onPromptPlaceholderCancel }));
    }
    const textareaStyle = {
        ...(effectiveIsFocused
            ? { viewTransitionName: "assistant-chat-input" }
            : {}),
        paddingBottom: `${textareaPaddingBottom}px`,
        // Cap the content at eight lines plus the textarea's own padding.
        maxHeight: `calc(8lh + ${textareaPaddingTop + textareaPaddingBottom}px)`,
        // With the controls space reserved on the wrapper, the textarea itself
        // only needs to fit its content (field-sizing: content grows it), so a
        // single line is enough as the minimum.
        ...(reserveBottomControlsSpace
            ? {
                minHeight: `calc(1lh + ${textareaPaddingTop + textareaPaddingBottom}px)`,
            }
            : {}),
    };
    return (_jsx("div", { className: cn("flex items-stretch gap-2", !isFlatSurface && "mx-2"), children: _jsxs("div", { className: cn("relative min-w-0 flex-1 transition-shadow", isFlatSurface ? "rounded-none" : "rounded-[10px]", isDragOver && "ring-highlight-100 ring-2 ring-offset-1"), onDragOver: dropHandlers?.onDragOver, onDragEnter: dropHandlers?.onDragEnter, onDragLeave: dropHandlers?.onDragLeave, onDrop: dropHandlers?.onDrop, children: [_jsxs("div", { className: cn("bg-neutral-grey-5 overflow-hidden", !isFlatSurface && "border-border-default rounded-[10px] border"), style: reservedControlsSpace
                        ? { paddingBottom: `${reservedControlsSpace}px` }
                        : undefined, children: [_jsx(Textarea, { ref: textareaRef, style: textareaStyle, value: prompt, onChange: (event) => onPromptChange(event.target.value), onKeyDown: onKeyDown, onPaste: onPaste, onFocus: onFocus, onBlur: onBlur, placeholder: readOnly
                                ? "Read-only access - ask the owner for Full access to chat with this agent."
                                : inputPlaceholder, className: cn("agent-prompt-scrollbar min-w-0 max-w-full resize-none overflow-x-hidden overflow-y-auto overscroll-contain border-0 text-[13px] shadow-none focus-visible:shadow-none focus-visible:ring-0", !reserveBottomControlsSpace && "min-h-[86px]", isFlatSurface ? "px-0 pt-0" : "px-3 pt-3"), "data-testid": "agent-terminal-prompt", disabled: isSubmitting || readOnly, readOnly: !effectiveIsFocused, title: !effectiveIsFocused
                                ? "Editing in another pane - click here to take over"
                                : undefined }), attachmentsContent] }), isDragOver && (_jsx("div", { className: "bg-highlight-10/70 text-highlight-100 pointer-events-none absolute inset-0 flex items-center justify-center rounded-[10px] text-xs font-medium", children: "Drop to add to context or upload" }))] }) }));
}
//# sourceMappingURL=AgentPromptInputArea.js.map