"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ModeSwitcher = void 0;
var react_1 = __importDefault(require("react"));
var classnames_1 = __importDefault(require("classnames"));
var Button_1 = __importDefault(require("@mui/material/Button"));
var ButtonGroup_1 = __importDefault(require("@mui/material/ButtonGroup"));
var withTooltip_1 = require("../HOCs/withTooltip");
var styles_1 = require("./styles");
var ButtonWithTooltip = (0, withTooltip_1.withTooltip)(Button_1.default);
var ModeSwitcher = function (_a) {
    var className = _a.className, _b = _a.classes, classes = _b === void 0 ? {} : _b, _c = _a.modes, modes = _c === void 0 ? [] : _c, modeId = _a.modeId, onChange = _a.onChange;
    var styles = (0, styles_1.useStyles)();
    var getChangeModeHandler = function (newMode) { return function () { return onChange(newMode); }; };
    return (react_1.default.createElement(ButtonGroup_1.default, { className: (0, classnames_1.default)(styles.root, className) }, modes.map(function (_a) {
        var _b;
        var id = _a.id, title = _a.title, tooltipTitle = _a.tooltipTitle, Icon = _a.Icon, disabled = _a.disabled;
        return (react_1.default.createElement(ButtonWithTooltip, { disabled: disabled, showForDisabled: disabled && !!tooltipTitle, key: String(id), className: (0, classnames_1.default)(styles.button, (_b = {}, _b[styles.current] = modeId === id, _b), classes.button), tooltipTitle: tooltipTitle, onClick: getChangeModeHandler(id), "data-reltio-id": "reltio-search-mode-".concat(id) },
            Icon && react_1.default.createElement(Icon, { className: styles.icon }),
            title && react_1.default.createElement("div", { className: styles.title }, title)));
    })));
};
exports.ModeSwitcher = ModeSwitcher;
