import { WrappingSelect } from "./wrapping-select.js";
/**
 * Maximum number of option rows visible in the WrappingSelect window. Lifted here from
 * `preview-pane.ts` so the cap travels with the option-list owner.
 */
export const MAX_VISIBLE_OPTIONS = 10;
/**
 * Sole owner of the option list's interactive state. Wraps a single
 * `WrappingSelect`. Implements `StatefulView<OptionListViewProps>`:
 * `setProps` is the only mutator; render output reflects the last props
 * received.
 */
export class OptionListView {
    constructor(config) {
        // Reserve a slot for the chat row in the WrappingSelect's number-padding so
        // the column width is identical whether or not the user navigates into chat
        // (chat row uses items.length + 1).
        this.select = new WrappingSelect(config.items, Math.min(config.items.length, MAX_VISIBLE_OPTIONS), config.theme, {
            numberStartOffset: 0,
            totalItemsForNumbering: config.items.length + 1,
        });
    }
    setProps(props) {
        this.select.setSelectedIndex(props.selectedIndex);
        this.select.setFocused(props.focused);
        this.select.setConfirmedIndex(props.confirmed?.index, props.confirmed?.labelOverride);
        this.select.setInputBuffer(props.inputBuffer);
    }
    handleInput(_data) { }
    invalidate() {
        this.select.invalidate();
    }
    render(width) {
        return this.select.render(width);
    }
}
//# sourceMappingURL=option-list-view.js.map