"use strict";
var AdminFunctions = (function () {
    function toggleMenuVisibility(hideLargeMenu) {
        var contentContainer = $('#js-admin-content-container');
        var largeMenu = $('#js-menu-big');
        var smallMenu = $('#js-menu-small');
        var searchForm = $('#js-form-search');
        contentContainer.toggleClass('show-large-menu', !hideLargeMenu);
        largeMenu.toggleClass('hidden', hideLargeMenu);
        smallMenu.toggleClass('hidden', !hideLargeMenu);
        searchForm.toggleClass('menu-hide', hideLargeMenu);
        localStorage.setItem(hideLargeMenu ? 'menu_big' : 'menu_small', 'hidden');
        localStorage.removeItem(hideLargeMenu ? 'menu_small' : 'menu_big');
    }
    function debounce(func, wait, immediate) {
        var timeout = null;
        return function () {
            var args = [];
            for (var _i = 0; _i < arguments.length; _i++) {
                args[_i] = arguments[_i];
            }
            var context = this;
            var later = function () {
                timeout = null;
                if (!immediate)
                    func.apply(context, args);
            };
            var callNow = immediate && !timeout;
            if (timeout !== null) {
                clearTimeout(timeout);
            }
            timeout = setTimeout(later, wait);
            if (callNow)
                func.apply(context, args);
        };
    }
    function addProductToCategory(productId) {
        var statusElement = $('#status_' + productId);
        statusElement.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>');
        setTimeout(function () {
            statusElement.html('');
        }, 1000);
    }
    function searchSuggestions(inputSelector) {
        $(inputSelector).keyup(debounce(function () {
            $('#js-show-search').show();
        }, 300, false));
        $('body').click(function () {
            $('#js-show-search').hide();
        });
    }
    function markProductAsHot(productId) {
        var statusElement = $('#js-status-hottype-' + productId);
        statusElement.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>');
        setTimeout(function () {
            statusElement.html('');
        }, 1000);
    }
    return {
        toggleMenuVisibility: toggleMenuVisibility,
        addProductToCategory: addProductToCategory,
        searchSuggestions: searchSuggestions,
        markProductAsHot: markProductAsHot
    };
})();
