var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { useState } from 'react';
import { useAppSelector } from 'src/app/redux/store';
import Button from 'src/components/Button';
import CheckBox from 'src/components/CheckBox2/CheckBox';
import css from '../FilterBar.module.scss';
import Modal from 'src/components/Modal/ModalModule';
import { _cx } from 'src/utility/class';
var cx = _cx(css);
var Vivera = function (_a) {
    var filters = _a.filters, t = _a.t, onFilterApply = _a.onFilterApply, closeModal = _a.closeModal;
    var _b = filters.vivera, vivera = _b === void 0 ? false : _b;
    var _c = __read(useState("".concat(vivera)), 2), viv = _c[0], setViv = _c[1];
    var _d = __read(useState(false), 2), showModal = _d[0], setShowModal = _d[1];
    var modalsData = useAppSelector(function (state) { return state.config.config; }).modalsData;
    var modaldata = modalsData.find(function (item) { return item.id === 'vivera'; });
    var applyFilter = function () {
        onFilterApply('vivera', viv === 'true' ? true : false);
        closeModal();
    };
    return (_jsxs("div", { className: cx('form-group'), children: [_jsxs("label", { className: "filter-title", children: [" ", t.result_service_offered] }), _jsx(CheckBox, { checked: viv === 'true', onChange: function () {
                    setViv(viv === 'true' ? 'false' : 'true');
                }, label: t.result_vivera_label, name: "vivera", width: "100%", showInfoIcon: true, infoClickHandler: function () { return setShowModal(true); } }), _jsx("hr", {}), _jsxs("div", { className: "flex-space-between", children: [_jsx(Button, { type: "submit", styleType: "cancel", onClick: closeModal, children: t.result_sort_button_cancel }), _jsx(Button, { type: "submit", styleType: "normal", onClick: applyFilter, children: t.result_filter_button_apply })] }), showModal && (_jsx(Modal, { setShowModal: function () { return setShowModal(false); }, size: "sm", subTitle: modaldata === null || modaldata === void 0 ? void 0 : modaldata.title, description: modaldata === null || modaldata === void 0 ? void 0 : modaldata.description, closeButton: true, children: modaldata.image ? (_jsx("img", { width: '264px', style: { margin: '0px auto 24px auto' }, src: modaldata.image, alt: "" })) : (_jsx(_Fragment, {})) }))] }));
};
export default Vivera;
