// import { createShowMoreLess } from './utils/show-more-less';

var Wick = Wick || {};

Wick.Overlay = (function () {
    var filterMobile = $('.filter-results_mobile');
    $('#open-overlay').click(function (event) {
        event.preventDefault();
        $('body').addClass('is-filters-visible');
        filterMobile.toggleClass('show');
    });

    $('#close-overlay, .filter-results__btn-close').click(function (event) {
        event.preventDefault();
        if (filterMobile.hasClass('show')) {
            $('body').removeClass('is-filters-visible');
            filterMobile.removeClass('show');
        }
    });

    $('.filter-results_desktop .filter__item input[type="checkbox"]').click(function () {
        $(this).closest('form').submit();
    });
})();

Wick.SearchFilter = (function () {
    const SEL = {
        CATEGORY: '.category-filter',
        FILTER_MOBILE: '.filter-results_mobile',
        OPEN: '.filter-modal-cta',
        CLOSE: '.close',
        FILTER_RESULT: '.filter-results_desktop',
        DESKTOP_CHECKBOX: '.filter-results_desktop .filter__item input[type="checkbox"]',
        BODY_ACTIVE: 'is-filters-visible',
    };

    // removed show more/show less logic from frontend (will be implemented on backend)
    // const SRPShowMoreLess = createShowMoreLess({
    //     excludeGroup: ($group) => $group.hasClass(SEL.CATEGORY),
    // });

    // const $fm = $(SEL.FILTER_MOBILE);
    // SRPShowMoreLess.init($(SEL.FILTER_RESULT));
    // SRPShowMoreLess.init($fm);

    $(SEL.OPEN).on('click', function (event) {
        event.preventDefault();
        // removed show more/show less logic from frontend (will be implemented on backend)
        // SRPShowMoreLess.init($fm);
        // SRPShowMoreLess.resetAll($fm);
    });

    $(document).on('click', SEL.CLOSE, function (event) {
        event.preventDefault();
        // removed show more/show less logic from frontend (will be implemented on backend)
        // SRPShowMoreLess.resetAll($fm);
    });

    $(document).on('click', SEL.DESKTOP_CHECKBOX, function () {
        $(this).closest('form').submit();
    });
})();
