"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatbotConversationHistoryDropdown = void 0;
// ============================================================================
// Chatbot Header - Chatbot Conversation History Nav
// ============================================================================
const react_1 = __importDefault(require("react"));
// Import PatternFly components
const react_core_1 = require("@patternfly/react-core");
const ellipsis_v_icon_1 = __importDefault(require("@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon"));
const ChatbotConversationHistoryDropdown = ({ menuItems, menuClassName, onSelect, label }) => {
    const [isOpen, setIsOpen] = react_1.default.useState(false);
    const toggle = (toggleRef) => (react_1.default.createElement(react_core_1.Tooltip, { className: "pf-chatbot__tooltip", content: label !== null && label !== void 0 ? label : 'Conversation options', position: "bottom", 
        // prevents VO announcements of both aria label and tooltip
        aria: "none" },
        react_1.default.createElement(react_core_1.MenuToggle, { className: "pf-chatbot__history-actions", variant: "plain", "aria-label": label !== null && label !== void 0 ? label : 'Conversation options', ref: toggleRef, isExpanded: isOpen, onClick: () => setIsOpen(!isOpen), role: "menuitem" },
            react_1.default.createElement(ellipsis_v_icon_1.default, null))));
    return (react_1.default.createElement(react_core_1.Dropdown, { className: `pf-chatbot__selections ${menuClassName !== null && menuClassName !== void 0 ? menuClassName : ''}`, isOpen: isOpen, onSelect: (props) => {
            onSelect === null || onSelect === void 0 ? void 0 : onSelect(props);
            setIsOpen((prev) => !prev);
        }, onOpenChange: (isOpen) => setIsOpen(isOpen), popperProps: { position: 'right' }, shouldFocusToggleOnSelect: true, shouldFocusFirstItemOnOpen: true, toggle: toggle }, menuItems));
};
exports.ChatbotConversationHistoryDropdown = ChatbotConversationHistoryDropdown;
exports.default = exports.ChatbotConversationHistoryDropdown;
