var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import { jsx as _jsx } from "react/jsx-runtime";
import { useState } from 'react';
import { Tooltip, Dropdown, MenuToggle, Icon } from '@patternfly/react-core';
import EllipsisIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
export const ChatbotHeaderOptionsDropdown = (_a) => {
    var { className, children, onSelect, tooltipProps, menuToggleAriaLabel = 'Chatbot options', isCompact, toggleProps } = _a, props = __rest(_a, ["className", "children", "onSelect", "tooltipProps", "menuToggleAriaLabel", "isCompact", "toggleProps"]);
    const [isOptionsMenuOpen, setIsOptionsMenuOpen] = useState(false);
    const toggle = (toggleRef) => (_jsx(Tooltip, Object.assign({ className: "pf-chatbot__tooltip", content: "Chatbot options", position: "bottom", 
        // prevents VO announcements of both aria label and tooltip
        aria: "none" }, tooltipProps, { children: _jsx(MenuToggle, Object.assign({ className: `pf-chatbot__button--toggle-options ${isCompact ? 'pf-m-compact' : ''}`, variant: "plain", "aria-label": menuToggleAriaLabel, ref: toggleRef, icon: _jsx(Icon, { size: isCompact ? 'lg' : 'xl', isInline: true, children: _jsx(EllipsisIcon, {}) }), isExpanded: isOptionsMenuOpen, onClick: () => setIsOptionsMenuOpen(!isOptionsMenuOpen), size: isCompact ? 'sm' : undefined }, toggleProps)) })));
    return (_jsx(Dropdown, Object.assign({ className: `pf-chatbot__options ${className !== null && className !== void 0 ? className : ''}`, isOpen: isOptionsMenuOpen, onSelect: (e, value) => {
            onSelect && onSelect(e, value);
            setIsOptionsMenuOpen(false);
        }, onOpenChange: (isOpen) => setIsOptionsMenuOpen(isOpen), popperProps: { position: 'right', preventOverflow: true, appendTo: 'inline' }, shouldFocusToggleOnSelect: true, shouldFocusFirstItemOnOpen: true, toggle: toggle }, props, { children: children })));
};
export default ChatbotHeaderOptionsDropdown;
