var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
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 React from 'react';
import classnames from 'classnames';
import i18n from 'ui-i18n';
import Popover from '@mui/material/Popover';
import { InfoIcon } from '../InfoIcon';
import { SearchInput } from '../SearchInput';
import { useCssVariableStyles } from '../hooks/useCssVariableStyles/useCssVariableStyles';
import { useTheme } from '@mui/styles';
import styles from './SelectionPopup.module.css';
export var SelectionPopup = function (_a) {
    var _b;
    var title = _a.title, className = _a.className, onSearch = _a.onSearch, hideSearchInput = _a.hideSearchInput, inputPlaceholder = _a.inputPlaceholder, _c = _a.headerPlacement, headerPlacement = _c === void 0 ? 'top' : _c, containerWidth = _a.containerWidth, _d = _a.containerHeight, containerHeight = _d === void 0 ? 553 : _d, searchInputOnKeyDown = _a.searchInputOnKeyDown, children = _a.children, searchInputRef = _a.searchInputRef, _e = _a.anchorOrigin, anchorOrigin = _e === void 0 ? {
        vertical: 'top',
        horizontal: 'right'
    } : _e, _f = _a.transformOrigin, transformOrigin = _f === void 0 ? {
        vertical: 'top',
        horizontal: 'right'
    } : _f, additionalInfo = _a.additionalInfo, toolbar = _a.toolbar, otherProps = __rest(_a, ["title", "className", "onSearch", "hideSearchInput", "inputPlaceholder", "headerPlacement", "containerWidth", "containerHeight", "searchInputOnKeyDown", "children", "searchInputRef", "anchorOrigin", "transformOrigin", "additionalInfo", "toolbar"]);
    var currentTheme = useTheme();
    var variableStyles = useCssVariableStyles({
        '--container-height': "".concat(containerHeight, "px")
    });
    var header = (React.createElement(React.Fragment, null,
        toolbar,
        title && !toolbar && (React.createElement("div", { className: styles.header },
            title,
            additionalInfo && React.createElement(InfoIcon, { className: styles.infoIcon, tooltipTitle: additionalInfo }))),
        !hideSearchInput && (React.createElement(SearchInput, { onSearch: onSearch, autofocus: true, onKeyDown: searchInputOnKeyDown, inputRef: searchInputRef, classes: { root: styles.searchInputContainer }, placeholder: inputPlaceholder || i18n.text('Search & add attributes'), height: 40 }))));
    return (React.createElement(Popover, __assign({ anchorOrigin: anchorOrigin, transformOrigin: transformOrigin, "data-mui-color-scheme": (_b = currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.palette) === null || _b === void 0 ? void 0 : _b.mode }, otherProps),
        React.createElement("div", { className: classnames(styles.container, className), style: __assign(__assign({}, variableStyles), { width: containerWidth }) },
            headerPlacement === 'top' && header,
            React.createElement("div", { className: styles.list }, children),
            headerPlacement === 'bottom' && header)));
};
