(function ($, document, window, viewport) {
    'use strict';

    // PLUGIN CLASS
    // ============
    const SearchTogglePluginClass = {

        toggleSearch: function() {
            $(document).find('.et-header-main-search').toggleClass('d-flex');
        },

        /**
         * @this {PluginBase & SearchTogglePluginClass}
         * @param {HTMLElement} element
         * @param {Object} options
         */
        init: function (element, options) {
            // Note this plugin registers on body, but actually listens to events on document
            $(document).on('toggle-search.et', (event) => {
                this.toggleSearch();
            })
            $('[data-toggle-search]').on('click', (event) => {
                this.toggleSearch();
            })
        },
    };

    // REGISTER AND ADD THE PLUGIN
    // ===========================
    if (!window.easytemplate && !window.easytemplate.PluginManager) {
        throw Error('Cannot initialize Easytemplate Plugin. plugin-manager.js has to be loaded first!');
    }

    /** @type {PluginManager} manager */
    const manager = window.easytemplate.PluginManager;
    manager.addPlugin('body', SearchTogglePluginClass, 'etSearchTogglePlugin');
})(jQuery, document, window, ResponsiveBootstrapToolkit);