import { _ as __assign } from '../tslib.es6-faad35dc.js';
import { jsx } from 'react/jsx-runtime';
import { useState } from 'react';
import { styled } from '@mui/material/styles';
import MuiPopper from '@mui/material/Popper';
import MuiAutocomplete from '@mui/material/Autocomplete';
import MuiFade from '@mui/material/Fade';
import Icon from './Icon.js';
import TextField from './TextField.js';
import boxShadow from '../theme/boxShadow.js';
import '../icons/ArrowLeft.js';
import '../icons/ArrowRight.js';
import '../icons/CloseCircle.js';
import '../icons/InfoCircle.js';
import '../icons/ErrorCircle.js';
import '../icons/Attention.js';
import '../icons/HelpCircle.js';
import '../icons/Document.js';
import '../icons/DocumentText.js';
import '../icons/Lock.js';
import '../icons/Delete.js';
import '../icons/Users.js';
import '../icons/Stakefish.js';
import '../icons/Sound.js';
import '../icons/Beacon.js';
import '../icons/TriangleRight.js';
import '../icons/TriangleLeft.js';
import '../icons/TriangleUp.js';
import '../icons/TriangleDown.js';
import '../icons/Sent.js';
import '../icons/Download.js';
import '../icons/Faster.js';
import '../icons/Slower.js';
import '../icons/Usb.js';
import '../icons/Key.js';
import '../icons/Edit.js';
import '../icons/Expand.js';
import '../icons/Collapse.js';
import '../icons/Success.js';
import '../icons/SuccessCircle.js';
import '../icons/Fail.js';
import '../icons/Desktop.js';
import '../icons/Mobile.js';
import '../icons/Loading.js';
import '../icons/Upload.js';
import '../icons/Check.js';
import '../icons/ChevronLeft.js';
import '../icons/ChevronRight.js';
import '../icons/Plus.js';
import '../icons/Minus.js';
import '../icons/Globe.js';
import '../icons/Link.js';
import '../icons/Copy.js';
import '../icons/Medium.js';
import '../icons/Twitter.js';
import '../icons/Telegram.js';
import '../icons/Eth.js';
import '../icons/Sort.js';
import '../icons/Close.js';
import '../icons/DollarSign.js';
import '../icons/Search.js';
import '../icons/Range.js';
import '../icons/Instagram.js';
import '../icons/LinkedIn.js';
import '../icons/Reddit.js';
import '../icons/YouTube.js';
import '../icons/Chrome.js';
import '../icons/CloudConnect.js';
import '../icons/Update.js';
import '../icons/Menu.js';
import '../icons/Settings.js';
import '@mui/material/TextField';
import '../theme/colors.js';
import './EndAdornment.js';
import '@mui/material/Box';
import '@mui/material/InputAdornment';
import './Button.js';
import '../clsx.m-6243b874.js';
import '@mui/material/Button';
import './Input.js';
import '@mui/material/Input';

var StyledAutoComplete = styled(MuiAutocomplete)(function (_a) {
    var theme = _a.theme;
    return ({
        "& .MuiFormControl-root": {
            display: "flex"
        },
        "& .MuiInput-root": {
            fontSize: theme.typography.fontSizeS,
            padding: theme.spacing(2)
        },
        "& .MuiInputBase-adornedEnd": {
            paddingRight: theme.spacing(3) + " !important"
        }
    });
});
var StyledPopper = styled(MuiPopper)(function (_a) {
    var theme = _a.theme;
    return ({
        "& .MuiPaper-root": {
            boxShadow: boxShadow.lg,
            padding: theme.spacing(2)
        },
        "& .MuiAutocomplete-listbox": {
            padding: 0
        },
        "& .MuiAutocomplete-option": {
            padding: theme.spacing(2, 3),
            borderRadius: theme.borders.radius.sm,
            "&[data-focus=true], &[aria-selected=true]": {
                backgroundColor: theme.palette.gray.white + " !important"
            }
        }
    });
});
var AutocompleteDropdown = function (_a) {
    var _b = _a.id, id = _b === void 0 ? "autocompleteDropdown" : _b, options = _a.options, getOptionLabel = _a.getOptionLabel, renderOption = _a.renderOption, placeholder = _a.placeholder, onOpen = _a.onOpen, onClose = _a.onClose, onChange = _a.onChange, open = _a.open, value = _a.value, popperProps = _a.popperProps, textFieldProps = _a.textFieldProps;
    var _c = useState(false), isOpen = _c[0], setIsOpen = _c[1];
    return (jsx(StyledAutoComplete, { open: open, id: id, options: options, value: value, getOptionLabel: getOptionLabel, renderOption: renderOption, renderInput: function (params) { return (jsx(TextField, __assign({ ref: params.InputProps.ref, id: id + "-input" }, textFieldProps, { InputProps: __assign({ endAdornment: (jsx(Icon, { iconKey: "triangleUp", color: isOpen ? "primary" : "secondary", rotate: isOpen ? 0 : -180, size: "xs1" }, void 0)), placeholder: placeholder, inputProps: params.inputProps }, textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.InputProps) }), void 0)); }, onOpen: function (event) {
            if (onOpen) {
                onOpen(event);
            }
            setIsOpen(true);
        }, onClose: function (event, reason) {
            if (onClose) {
                onClose(event, reason);
            }
            setIsOpen(false);
        }, onChange: function (event, newValue, reason, details) {
            if (onChange) {
                onChange(event, newValue, reason, details);
            }
        }, freeSolo: true, PopperComponent: function (popperCompProps) {
            return (jsx(StyledPopper, __assign({}, popperCompProps, popperProps, { id: id + "-autocompletePopper", placement: "bottom", children: function () { return (jsx(MuiFade, __assign({ in: true }, { children: jsx("div", { children: popperCompProps.children }, void 0) }), void 0)); } }), void 0));
        } }, void 0));
};

export { AutocompleteDropdown as default };
