// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/js/front.js?ver=3.4.0 
'use strict';
var woof_redirect = ''; //if we use redirect attribute in shortcode [woof]
var woof_reset_btn_action = false;
var woof_additional_fields = {};
jQuery(function () {
    try {
        woof_current_values = JSON.parse(woof_current_values);
    } catch (e) {
        woof_current_values = null;
    }
    if (woof_current_values == null || woof_current_values.length == 0) {
        woof_current_values = {};
    }
});

//***
if (typeof woof_lang_custom == 'undefined') {
    var woof_lang_custom = {}; /*!!important*/
}
if (typeof woof_ext_filter_titles != 'undefined') {
    woof_lang_custom = Object.assign(
            {},
            woof_lang_custom,
            woof_ext_filter_titles
            );
}

jQuery(function ($) {
    jQuery('body').append(
            '<div id="woof_html_buffer" class="woof_info_popup" style="display: none;"></div>'
            );
    //http://stackoverflow.com/questions/2389540/jquery-hasparent
    jQuery.extend(jQuery.fn, {
        within: function (pSelector) {
            // Returns a subset of items using jQuery.filter
            return this.filter(function () {
                // Return truthy/falsey based on presence in parent
                return jQuery(this).closest(pSelector).length;
            });
        },
    });

    //fix for swoof shortcode [woof_form_builder] (one form on one page)
    let forms = document.querySelectorAll('.woof[data-slug]');
    if (forms.length) {
        forms.forEach((f) => {
            if (f.dataset.slug.length > 0) {
                swoof_search_slug = f.dataset.slug;
            }
        });
    }

    //+++

    if (jQuery('#woof_results_by_ajax').length > 0) {
        woof_is_ajax = 1;
    }

    //listening attributes in shortcode [woof]
    woof_autosubmit = parseInt(jQuery('.woof').eq(0).data('autosubmit'), 10);
    woof_ajax_redraw = parseInt(jQuery('.woof').eq(0).data('ajax-redraw'), 10);

    //+++

    woof_ext_init_functions = JSON.parse(woof_ext_init_functions);

    //fix for native woo price range
    woof_init_native_woo_price_filter();

    jQuery('body').on('price_slider_change', function (event, min, max) {
        if (
                woof_autosubmit &&
                !woof_show_price_search_button &&
                jQuery('.price_slider_wrapper').length < 3
                ) {
            jQuery('.woof .widget_price_filter form').trigger('submit');
        } else {
            var min_price = jQuery(this)
                    .find('.price_slider_amount #min_price')
                    .val();
            var max_price = jQuery(this)
                    .find('.price_slider_amount #max_price')
                    .val();
            woof_current_values.min_price = min_price;
            woof_current_values.max_price = max_price;
        }
    });

    jQuery('body').on('change', '.woof_price_filter_dropdown', function () {
        var val = jQuery(this).val();
        if (parseInt(val, 10) == -1) {
            delete woof_current_values.min_price;
            delete woof_current_values.max_price;
        } else {
            var val = val.split('-');
            woof_current_values.min_price = val[0];
            woof_current_values.max_price = val[1];
        }

        if (woof_autosubmit || jQuery(this).within('.woof').length == 0) {
            woof_submit_link(woof_get_submit_link());
        }
    });

    //change value in textinput price filter if WOOCS is installed
    woof_recount_text_price_filter();
    //+++
    jQuery('body').on('change', '.woof_price_filter_txt', function () {
        var from = parseInt(
                jQuery(this).parent().find('.woof_price_filter_txt_from').val(),
                10
                );
        var to = parseInt(
                jQuery(this).parent().find('.woof_price_filter_txt_to').val(),
                10
                );

        if (to < from || from < 0) {
            delete woof_current_values.min_price;
            delete woof_current_values.max_price;
        } else {
            if (typeof woocs_current_currency !== 'undefined') {
                from = Math.ceil(
                        from / parseFloat(woocs_current_currency.rate)
                        );
                to = Math.ceil(to / parseFloat(woocs_current_currency.rate));
            }

            woof_current_values.min_price = from;
            woof_current_values.max_price = to;
        }

        if (woof_autosubmit || jQuery(this).within('.woof').length == 0) {
            woof_submit_link(woof_get_submit_link());
        }
    });

    //***

    jQuery('body').on('click', '.woof_open_hidden_li_btn', function () {
        var state = jQuery(this).data('state');
        var type = jQuery(this).data('type');

        if (state == 'closed') {
            jQuery(this)
                    .parents('.woof_list')
                    .find('.woof_hidden_term')
                    .addClass('woof_hidden_term2');
            jQuery(this)
                    .parents('.woof_list')
                    .find('.woof_hidden_term')
                    .removeClass('woof_hidden_term');
            if (type == 'image') {
                jQuery(this)
                        .find('img')
                        .attr('src', jQuery(this).data('opened'));
            } else {
                jQuery(this).html(jQuery(this).data('opened'));
            }

            jQuery(this).data('state', 'opened');
        } else {
            jQuery(this)
                    .parents('.woof_list')
                    .find('.woof_hidden_term2')
                    .addClass('woof_hidden_term');
            jQuery(this)
                    .parents('.woof_list')
                    .find('.woof_hidden_term2')
                    .removeClass('woof_hidden_term2');

            if (type == 'image') {
                jQuery(this)
                        .find('img')
                        .attr('src', jQuery(this).data('closed'));
            } else {
                jQuery(this).text(jQuery(this).data('closed'));
            }

            jQuery(this).data('state', 'closed');
        }

        return false;
    });
    //open hidden block
    woof_open_hidden_li();

    //*** woocommerce native "AVERAGE RATING" widget synchronizing
    jQuery('.widget_rating_filter li.wc-layered-nav-rating a').on(
            'click',
            function () {
                var is_chosen = jQuery(this).parent().hasClass('chosen');
                var parsed_url = woof_parse_url(jQuery(this).attr('href'));
                var rate = 0;
                if (parsed_url.query !== undefined) {
                    if (parsed_url.query.indexOf('min_rating') !== -1) {
                        var arrayOfStrings = parsed_url.query.split('min_rating=');
                        rate = parseInt(arrayOfStrings[1], 10);
                    }
                }
                jQuery(this).parents('ul').find('li').removeClass('chosen');
                if (is_chosen) {
                    delete woof_current_values.min_rating;
                } else {
                    woof_current_values.min_rating = rate;
                    jQuery(this).parent().addClass('chosen');
                }

                woof_submit_link(woof_get_submit_link());

                return false;
            }
    );

    //WOOF start filtering button action
    jQuery('body').on('click', '.woof_start_filtering_btn', function () {
        var shortcode = jQuery(this).parents('.woof').data('shortcode');
        jQuery(this).html(woof_lang_loading);
        jQuery(this).addClass('woof_start_filtering_btn2');
        jQuery(this).removeClass('woof_start_filtering_btn');
        //redrawing [woof ajax_redraw=1] only
        var data = {
            action: 'woof_draw_products',
            page: 1,
            shortcode: 'woof_nothing', //we do not need get any products, seacrh form data only
            woof_shortcode: shortcode,
            nonce_filter: woof_front_nonce,
        };

        jQuery.post(woof_ajaxurl, data, function (content) {
            content = JSON.parse(content);
            jQuery('div.woof_redraw_zone').replaceWith(
                    jQuery(content.form).find('.woof_redraw_zone')
                    );
            woof_mass_reinit();
            woof_init_tooltip();
        });

        return false;
    });

    //***

    window.addEventListener('pageshow', function (event) {
        var woof_check_history =
                event.persisted ||
                (typeof window.performance != 'undefined' &&
                        window.performance.navigation.type === 2);
        if (woof_check_history) {
            woof_hide_info_popup();
            woof_submit_link_locked = false;
        }
    });

    var str = window.location.href;
    window.onpopstate = function (event) {
        try {
            if (Object.keys(woof_current_values).length) {
                var temp = str.split('?');
                var get1 = '';
                if (temp[1] != undefined) {
                    get1 = temp[1].split('#');
                }
                var str2 = window.location.href;
                var temp2 = str2.split('?');
                if (temp2[1] == undefined) {
                    //return false;
                    var get2 = {0: '', 1: ''};
                } else {
                    var get2 = temp2[1].split('#');
                }

                if (get2[0] != get1[0]) {
                    woof_show_info_popup(woof_lang_loading);
                    window.location.reload();
                }
                return false;
            }
        } catch (e) {
            console.log(e);
        }
    };
    //***

    //ion-slider price range slider
    woof_init_ion_sliders();

    //***

    woof_init_show_auto_form();
    woof_init_hide_auto_form();

    //***
    woof_remove_empty_elements();
    woof_unblur_filter();

    woof_init_search_form();
    woof_init_pagination();
    woof_init_orderby();
    woof_init_reset_button();
    woof_init_beauty_scroll();
    //+++
    woof_draw_products_top_panel();
    woof_shortcode_observer();

    //tooltip
    woof_init_tooltip();

    //mobile filter
    woof_init_mobile_filter();

    //+++
    //if we use redirect attribute in shortcode [woof is_ajax=0]
    //not for ajax, for redirect mode only
    if (!woof_is_ajax) {
        woof_redirect_init();
    }

    woof_init_toggles();
});

//if we use redirect attribute in shortcode [woof is_ajax=0]
//not for ajax, for redirect mode only
function woof_redirect_init() {
    try {
        if (jQuery('.woof').length) {
            //https://wordpress.org/support/topic/javascript-error-in-frontjs?replies=1
            if (undefined !== jQuery('.woof').val()) {
                woof_redirect = jQuery('.woof').eq(0).data('redirect'); //default value
                if (woof_redirect.length > 0) {
                    woof_shop_page = woof_current_page_link = woof_redirect;
                }
                return woof_redirect;
            }
        }
    } catch (e) {
        console.log(e);
    }
}

function woof_init_orderby() {
    jQuery('body').on('submit', 'form.woocommerce-ordering', function () {
        /* woo3.3 */
        if (!jQuery('#is_woo_shortcode').length) {
            return false;
        }
        /* +++ */
    });
    jQuery('body').on(
            'change',
            'form.woocommerce-ordering select.orderby',
            function () {
                /* woo3.3 */
                if (!jQuery('#is_woo_shortcode').length) {
                    woof_current_values.orderby = jQuery(this).val();
                    woof_ajax_page_num = 1;
                    woof_submit_link(woof_get_submit_link(), 0);
                    return false;
                }
                /* +++ */
            }
    );
}

function woof_init_reset_button() {
    jQuery('body').on('click', '.woof_reset_search_form', function () {
        //var link = jQuery(this).data('link');
        woof_ajax_page_num = 1;
        woof_ajax_redraw = 0;
        woof_reset_btn_action = true;
        if (woof_is_permalink) {
            woof_current_values = {};
            woof_submit_link(woof_get_submit_link().split('page/')[0]);
        } else {
            var link = woof_shop_page;
            if (woof_current_values.hasOwnProperty('page_id')) {
                link =
                        location.protocol +
                        '//' +
                        location.host +
                        '/?page_id=' +
                        woof_current_values.page_id;
                woof_current_values = {page_id: woof_current_values.page_id};
                woof_get_submit_link();
            }
            //***
            woof_submit_link(link);
            if (woof_is_ajax) {
                history.pushState({}, '', link);
                if (woof_current_values.hasOwnProperty('page_id')) {
                    woof_current_values = {
                        page_id: woof_current_values.page_id,
                    };
                } else {
                    woof_current_values = {};
                }
            }
        }
        return false;
    });
}

function woof_init_pagination() {
    if (woof_is_ajax === 1) {
        //jQuery('.woocommerce-pagination ul.page-numbers a.page-numbers').life('click', function () {
        jQuery('body').on(
                'click',
                '.woocommerce-pagination a.page-numbers',
                function () {
                    var l = jQuery(this).attr('href');

                    if (woof_ajax_first_done) {
                        //wp-admin/admin-ajax.php?paged=2
                        var res = l.split('paged=');
                        if (typeof res[1] !== 'undefined') {
                            woof_ajax_page_num = parseInt(res[1]);
                        } else {
                            woof_ajax_page_num = 1;
                        }
                        var res2 = l.split('product-page=');
                        if (typeof res2[1] !== 'undefined') {
                            woof_ajax_page_num = parseInt(res2[1]);
                        }
                    } else {
                        var res = l.split('page/');
                        if (typeof res[1] !== 'undefined') {
                            woof_ajax_page_num = parseInt(res[1]);
                        } else {
                            woof_ajax_page_num = 1;
                        }
                        var res2 = l.split('product-page=');
                        if (typeof res2[1] !== 'undefined') {
                            woof_ajax_page_num = parseInt(res2[1]);
                        }
                    }

                    //+++

                    {
                        woof_submit_link(woof_get_submit_link(), 0);
                    }

                    return false;
                }
        );
    }
}

function woof_init_search_form() {
    woof_init_checkboxes();
    woof_init_mselects();
    woof_init_radios();
    woof_price_filter_radio_init();
    woof_init_selects();

    //for extensions
    if (woof_ext_init_functions !== null) {
        jQuery.each(woof_ext_init_functions, function (type, func) {
            eval(func + '()');
        });
    }

    //+++
    jQuery('.woof_submit_search_form').on('click', function () {
        if (woof_ajax_redraw) {
            //[woof redirect="http://test-all/" autosubmit=1 ajax_redraw=1 is_ajax=1 tax_only="locations" by_only="none"]
            woof_ajax_redraw = 0;
            woof_is_ajax = 0;
        }
        //***
        woof_submit_link(woof_get_submit_link());
        return false;
    });

    //***
    jQuery('ul.woof_childs_list').parent('li').addClass('woof_childs_list_li');

    //***

    woof_remove_class_widget();
    woof_checkboxes_slide();

    document.dispatchEvent(
            new CustomEvent('woof_init_search_form', {detail: {}})
            );
}

var woof_submit_link_locked = false;
function woof_submit_link(link, ajax_redraw) {
    if (woof_submit_link_locked) {
        return;
    }
    if (typeof WoofTurboMode != 'undefined') {
        WoofTurboMode.woof_submit_link(link);

        return;
    }
    if (typeof ajax_redraw == 'undefined') {
        ajax_redraw = woof_ajax_redraw;
    }

    woof_submit_link_locked = true;

    woof_show_info_popup(woof_lang_loading);

    if (woof_is_ajax === 1 && !ajax_redraw) {
        woof_ajax_first_done = true;
        var data = {
            action: 'woof_draw_products',
            link: link,
            page: woof_ajax_page_num,
            shortcode: jQuery('#woof_results_by_ajax').data('shortcode'),
            woof_shortcode: jQuery('div.woof').data('shortcode'),
            nonce_filter: woof_front_nonce,
        };

        jQuery.post(woof_ajaxurl, data, function (content) {
            content = JSON.parse(content);

            woof_before_ajax_form_redrawing();

            if (jQuery('.woof_results_by_ajax_shortcode').length) {
                if (typeof content.products != 'undefined') {
                    jQuery('#woof_results_by_ajax').replaceWith(
                            content.products
                            );

                    /* compatibility found products count*/
                    var found_count = jQuery('.woof_found_count');
                    jQuery(found_count).show();
                    if (found_count.length > 0) {
                        var count_prod = jQuery('#woof_results_by_ajax').data(
                                'count'
                                );
                        if (typeof count_prod != 'undefined') {
                            jQuery(found_count).text(count_prod);
                        }
                    }
                }
            } else {
                if (typeof content.products != 'undefined') {
                    jQuery('.woof_shortcode_output').replaceWith(
                            content.products
                            );
                }
            }
            if (typeof content.additional_fields != 'undefined') {
                jQuery.each(
                        content.additional_fields,
                        function (selector, html_data) {
                            if (
                                    typeof woof_additional_fields[selector] ==
                                    'undefined'
                                    ) {
                                woof_additional_fields[selector] = jQuery(selector);
                            }
                            jQuery(selector).replaceWith(html_data);
                        }
                );
                //draw old  values
                jQuery.each(
                        woof_additional_fields,
                        function (selector, html_data_old) {
                            if (
                                    typeof content.additional_fields[selector] ==
                                    'undefined'
                                    ) {
                                jQuery(selector).replaceWith(html_data_old);
                            }
                        }
                );
            }

            jQuery('div.woof_redraw_zone').replaceWith(
                    jQuery(content.form).find('.woof_redraw_zone')
                    );
            woof_draw_products_top_panel();
            woof_mass_reinit();
            woof_submit_link_locked = false;
            //removing id woof_results_by_ajax - multi in ajax mode sometimes
            //when uses shorcode woof_products in ajax and in settings try ajaxify shop is Yes
            jQuery.each(
                    jQuery('#woof_results_by_ajax'),
                    function (index, item) {
                        if (index == 0) {
                            return;
                        }

                        jQuery(item).removeAttr('id');
                    }
            );
            /*mobile  behavior*/
            //jQuery('.woof_hide_mobile_filter').trigger('click');
            jQuery('.woof').removeClass('woof_show_filter_for_mobile');

            //infinite scroll
            woof_infinite();
            //*** script after ajax loading here
            woof_js_after_ajax_done();
            //***  change  link  in button "add to cart"
            woof_change_link_addtocart();

            /*tooltip*/
            woof_init_tooltip();

            document.dispatchEvent(
                    new CustomEvent('woof-ajax-form-redrawing', {
                        detail: {
                            link: link,
                        },
                    })
                    );
        });
    } else {
        if (ajax_redraw) {
            //redrawing [woof ajax_redraw=1] only
            var data = {
                action: 'woof_draw_products',
                link: link,
                page: 1,
                shortcode: 'woof_nothing', //we do not need get any products, seacrh form data only
                woof_shortcode: jQuery('div.woof').eq(0).data('shortcode'),
                nonce_filter: woof_front_nonce,
            };
            jQuery.post(woof_ajaxurl, data, function (content) {
                woof_before_ajax_form_redrawing();

                content = JSON.parse(content);
                jQuery('div.woof_redraw_zone').replaceWith(
                        jQuery(content.form).find('.woof_redraw_zone')
                        );
                woof_mass_reinit();
                woof_submit_link_locked = false;
                /*tooltip*/
                woof_init_tooltip();

                document.dispatchEvent(
                        new CustomEvent('woof-ajax-form-redrawing', {
                            detail: {
                                link: link,
                            },
                        })
                        );
            });
        } else {
            // Delay redirect to avoid conflicts with other scripts (Kadence, etc.)
            //https://pluginus.net/support/topic/text-search-shortcode-enter-key-reloads-page-instead-of-redirecting-to-shop-page
            setTimeout(() => {
                window.location = link;
            }, 100);
            woof_show_info_popup(woof_lang_loading);
        }
    }
}

function woof_remove_empty_elements() {
    // lets check for empty drop-downs
    jQuery.each(jQuery('.woof_container select'), function (index, select) {
        var size = jQuery(select).find('option').length;
        if (size === 0) {
            jQuery(select).parents('.woof_container').remove();
        }
    });
    //+++
    // lets check for empty checkboxes, radio, color conatiners
    jQuery.each(jQuery('ul.woof_list'), function (index, ch) {
        var size = jQuery(ch).find('li').length;
        if (size === 0) {
            jQuery(ch).parents('.woof_container').remove();
        }
    });
    jQuery.each(jQuery('.woof_container .woof_list_sd'), function (index, ch) {
        var size = jQuery(ch).find('.woof-sd-ie').length;
        if (size === 0) {
            jQuery(ch).parents('.woof_container').remove();
        }
    });
}

function woof_get_submit_link() {
    //filter woof_current_values values

    if (woof_is_ajax) {
        woof_current_values.page = woof_ajax_page_num;
    }
    //+++
    if (Object.keys(woof_current_values).length > 0) {
        jQuery.each(woof_current_values, function (index, value) {
            if (index == swoof_search_slug) {
                delete woof_current_values[index];
            }
            if (index == 's') {
                delete woof_current_values[index];
            }
            if (index == 'product') {
                //for single product page (when no permalinks)
                delete woof_current_values[index];
            }
            if (index == 'really_curr_tax') {
                delete woof_current_values[index];
            }
        });
    }

    //***
    if (Object.keys(woof_current_values).length === 2) {
        if (
                'min_price' in woof_current_values &&
                'max_price' in woof_current_values
                ) {
            woof_current_page_link = woof_current_page_link.replace(
                    new RegExp(/page\/(\d+)/),
                    ''
                    );
            var l =
                    woof_current_page_link +
                    '?min_price=' +
                    woof_current_values.min_price +
                    '&max_price=' +
                    woof_current_values.max_price;
            if (woof_is_ajax) {
                history.pushState({}, '', l);
            }
            return l;
        }
    }

    //***

    if (Object.keys(woof_current_values).length === 0) {
        if (woof_is_ajax) {
            history.pushState({}, '', woof_current_page_link);
        }
        return woof_current_page_link;
    }
    //+++
    if (Object.keys(woof_really_curr_tax).length > 0) {
        woof_current_values['really_curr_tax'] =
                woof_really_curr_tax.term_id + '-' + woof_really_curr_tax.taxonomy;
    }
    //+++
    var link = woof_current_page_link + '?' + swoof_search_slug + '=1';

    //just for the case when no permalinks enabled
    if (!woof_is_permalink) {
        if (woof_redirect.length > 0) {
            link = woof_redirect + '?' + swoof_search_slug + '=1';
            if (woof_current_values.hasOwnProperty('page_id')) {
                delete woof_current_values.page_id;
            }
        } else {
            link =
                    location.protocol +
                    '//' +
                    location.host +
                    '?' +
                    swoof_search_slug +
                    '=1';
        }
    }

    //any trash for different sites, useful for quick support
    var woof_exclude_accept_array = ['path'];

    if (Object.keys(woof_current_values).length > 0) {
        jQuery.each(woof_current_values, function (index, value) {
            if (index == 'page' && woof_is_ajax) {
                index = 'paged'; //for right pagination if copy/paste this link and send somebody another by email for example
            }
            if (index == 'product-page') {
                return;
            }

            //http://dev.products-filter.com/?swoof=1&woof_author=3&woof_sku&woof_text=single
            //avoid links where values is empty
            if (typeof value !== 'undefined') {
                if (
                        (typeof value && value.length > 0) ||
                        typeof value == 'number'
                        ) {
                    if (
                            jQuery.inArray(index, woof_exclude_accept_array) == -1
                            ) {
                        link = link + '&' + index + '=' + value;
                    }
                }
            }
        });
    }

    //+++
    //remove wp pagination like 'page/2'
    link = link.replace(new RegExp(/page\/(\d+)/), '');
    if (woof_is_ajax) {
        history.pushState({}, '', link);
    }

    return link;
}

function woof_show_info_popup(text) {
    if (woof_overlay_skin == 'default') {
        jQuery('#woof_html_buffer').text(text);
        jQuery('#woof_html_buffer').fadeTo(200, 0.9);
    } else {
        //http://jxnblk.com/loading/
        switch (woof_overlay_skin) {
            case 'loading-balls':
            case 'loading-bars':
            case 'loading-bubbles':
            case 'loading-cubes':
            case 'loading-cylon':
            case 'loading-spin':
            case 'loading-spinning-bubbles':
            case 'loading-spokes':
                jQuery('body').plainOverlay('show', {
                    progress: function () {
                        //img style should be inlined
                        return jQuery(
                                '<div id="woof_svg_load_container"><img style="height: 100%; width: 100%" src="' +
                                woof_link +
                                'img/loading-master/' +
                                woof_overlay_skin +
                                '.svg" alt=""></div>'
                                );
                    },
                });
                break;
            default:
                jQuery('body').plainOverlay('show', {duration: -1});
                break;
        }
    }
}

function woof_hide_info_popup() {
    if (woof_overlay_skin == 'default') {
        window.setTimeout(function () {
            jQuery('#woof_html_buffer').fadeOut(400);
        }, 200);
    } else {
        jQuery('body').plainOverlay('hide');
    }
}

function woof_draw_products_top_panel() {
    if (woof_is_ajax) {
        jQuery('#woof_results_by_ajax')
                .prev('.woof_products_top_panel')
                .remove();
    }

    var panel = jQuery('.woof_products_top_panel');

    panel.html('');
    if (Object.keys(woof_current_values).length > 0) {
        panel.show();
        panel.html('<ul></ul>');
        panel.find('ul').attr('class', 'woof_products_top_panel_ul');
        var is_price_in = false;
        //lets show this on the panel

        jQuery.each(woof_current_values, function (index, value) {
            //lets filter data for the panel

            if (
                    jQuery.inArray(index, woof_accept_array) == -1 &&
                    jQuery.inArray(index.replace('rev_', ''), woof_accept_array) ==
                    -1
                    ) {
                return;
            }

            //***

            if ((index == 'min_price' || index == 'max_price') && is_price_in) {
                return;
            }

            if (
                    (index == 'min_price' || index == 'max_price') &&
                    !is_price_in
                    ) {
                is_price_in = true;
                index = 'price';
                value = woof_lang_pricerange;
            }

            //tax slider  fix
            var is_range = false;
            var range_txt = jQuery(
                    "input[data-anchor='woof_n_" + index + "_all_range']"
                    ).val();

            if (typeof range_txt != 'undefined') {
                is_range = true;
            }

            //+++
            value = value.toString().trim();
            if (value.search(',')) {
                value = value.split(',');
            }
            //+++
            if (!is_range) {
                jQuery.each(value, function (i, v) {
                    if (index == 'page') {
                        return;
                    }

                    if (index == 'post_type') {
                        return;
                    }

                    var txt = v;
                    if (index == 'orderby') {
                        if (woof_lang[v] !== undefined) {
                            txt = woof_lang.orderby + ': ' + woof_lang[v];
                        } else {
                            txt = woof_lang.orderby + ': ' + v;
                        }
                    } else if (index == 'perpage') {
                        txt = woof_lang.perpage;
                    } else if (index == 'price') {
                        txt = woof_lang.pricerange;
                    } else {
                        var is_in_custom = false;
                        if (Object.keys(woof_lang_custom).length > 0) {
                            jQuery.each(woof_lang_custom, function (i, tt) {
                                if (i == index) {
                                    is_in_custom = true;
                                    txt = tt;
                                    if (index == 'woof_sku') {
                                        txt += ' ' + v; //because search by SKU can by more than 1 value
                                    }
                                }
                            });
                        }
                        if (!is_in_custom) {
                            try {
                                txt = jQuery(
                                        "input[data-anchor='woof_n_" +
                                        index +
                                        '_' +
                                        v +
                                        "']"
                                        ).val();
                            } catch (e) {
                                console.log(e);
                            }

                            if (typeof txt === 'undefined') {
                                txt = v;
                            }
                        }
                    }

                    if (typeof woof_filter_titles[index] != 'undefined') {
                        var cont_item = panel.find(
                                'ul.woof_products_top_panel_ul li ul[data-container=' +
                                index +
                                ']'
                                );

                        if (cont_item.length) {
                            cont_item.append(
                                    jQuery('<li>').append(
                                    jQuery('<a>')
                                    .attr('href', '')
                                    .attr('data-tax', index)
                                    .attr('data-slug', v)
                                    .attr('rel', 'nofollow')
                                    .append(
                                            jQuery('<span>')
                                            .attr(
                                                    'class',
                                                    'woof_remove_ppi'
                                                    )
                                            .append(txt)
                                            )
                                    )
                                    );
                        } else {
                            panel.find('ul.woof_products_top_panel_ul').append(
                                    jQuery('<li>').append(
                                    jQuery('<ul>')
                                    .attr('data-container', index)
                                    .append(
                                            jQuery('<li>').text(
                                            woof_filter_titles[index] + ':'
                                            )
                                            )
                                    .append(
                                            jQuery('<li>').append(
                                            jQuery('<a>')
                                            .attr('href', '')
                                            .attr('data-tax', index)
                                            .attr('data-slug', v)
                                            .attr('rel', 'nofollow')
                                            .append(
                                                    jQuery('<span>')
                                                    .attr(
                                                            'class',
                                                            'woof_remove_ppi'
                                                            )
                                                    .append(txt)
                                                    )
                                            )
                                            )
                                    )
                                    );
                        }
                    } else {
                        panel
                                .find('ul.woof_products_top_panel_ul')
                                .append(
                                        jQuery('<li>').append(
                                        jQuery('<a>')
                                        .attr('href', '')
                                        .attr('data-tax', index)
                                        .attr('data-slug', v)
                                        .attr('rel', 'nofollow')
                                        .append(
                                                jQuery('<span>')
                                                .attr(
                                                        'class',
                                                        'woof_remove_ppi'
                                                        )
                                                .append(txt)
                                                )
                                        )
                                        );
                    }
                });
            } else {
                if (typeof woof_filter_titles[index] != 'undefined') {
                    var cont_item = panel.find(
                            'ul.woof_products_top_panel_ul li ul[data-container=' +
                            index +
                            ']'
                            );

                    if (cont_item.length) {
                        cont_item.append(
                                jQuery('<li>').append(
                                jQuery('<a>')
                                .attr('href', '')
                                .attr('data-tax', index)
                                .attr('data-slug', 'all_range')
                                .attr('rel', 'nofollow')
                                .append(
                                        jQuery('<span>')
                                        .attr('class', 'woof_remove_ppi')
                                        .append(range_txt)
                                        )
                                )
                                );
                    } else {
                        panel.find('ul.woof_products_top_panel_ul').append(
                                jQuery('<li>').append(
                                jQuery('<ul>')
                                .attr('data-container', index)
                                .append(
                                        jQuery('<li>').text(
                                        woof_filter_titles[index] + ':'
                                        )
                                        )
                                .append(
                                        jQuery('<li>').append(
                                        jQuery('<a>')
                                        .attr('href', '')
                                        .attr('data-tax', index)
                                        .attr('data-slug', 'all_range')
                                        .attr('rel', 'nofollow')
                                        .append(
                                                jQuery('<span>')
                                                .attr(
                                                        'class',
                                                        'woof_remove_ppi'
                                                        )
                                                .append(range_txt)
                                                )
                                        )
                                        )
                                )
                                );
                    }
                } else {
                    panel
                            .find('ul.woof_products_top_panel_ul')
                            .append(
                                    jQuery('<li>').append(
                                    jQuery('<a>')
                                    .attr('href', '')
                                    .attr('data-tax', index)
                                    .attr('data-slug', 'all_range')
                                    .attr('rel', 'nofollow')
                                    .append(
                                            jQuery('<span>')
                                            .attr('class', 'woof_remove_ppi')
                                            .append(range_txt)
                                            )
                                    )
                                    );
                }
            }
        });
    }

    if (
            jQuery(panel).find('li').length == 0 ||
            !jQuery('.woof_products_top_panel').length
            ) {
        panel.hide();
    } else {
        panel
                .find('ul.woof_products_top_panel_ul')
                .prepend(
                        jQuery('<li>').append(
                        jQuery('<button>')
                        .attr('class', 'woof_reset_button_2')
                        .append(woof_lang.clear_all)
                        )
                        );
    }

    jQuery('.woof_reset_button_2').on('click', function () {
        woof_ajax_page_num = 1;
        woof_ajax_redraw = 0;
        woof_reset_btn_action = true;

        if (woof_is_permalink) {
            woof_current_values = {};
            woof_submit_link(woof_get_submit_link().split('page/')[0]);
        } else {
            var link = woof_shop_page;
            if (woof_current_values.hasOwnProperty('page_id')) {
                link =
                        location.protocol +
                        '//' +
                        location.host +
                        '/?page_id=' +
                        woof_current_values.page_id;
                woof_current_values = {page_id: woof_current_values.page_id};
                woof_get_submit_link();
            }
            //***
            woof_submit_link(link);
            if (woof_is_ajax) {
                history.pushState({}, '', link);
                if (woof_current_values.hasOwnProperty('page_id')) {
                    woof_current_values = {
                        page_id: woof_current_values.page_id,
                    };
                } else {
                    woof_current_values = {};
                }
            }
        }
        return false;
    });
    //+++
    jQuery('.woof_remove_ppi')
            .parent()
            .on('click', function (event) {
                event.preventDefault();
                var tax = jQuery(this).data('tax');
                var name = jQuery(this).data('slug');

                //***

                if (name == 'all_range') {
                    delete woof_current_values[tax];
                } else if (tax != 'price') {
                    var values = woof_current_values[tax];
                    values = values.split(',');
                    var tmp = [];
                    jQuery.each(values, function (index, value) {
                        if (value != name) {
                            tmp.push(value);
                        }
                    });
                    values = tmp;

                    if (values.length) {
                        woof_current_values[tax] = values.join(',');
                    } else {
                        delete woof_current_values[tax];
                    }
                } else {
                    delete woof_current_values['min_price'];
                    delete woof_current_values['max_price'];
                }
                woof_ajax_page_num = 1;
                woof_reset_btn_action = true;
                {
                    woof_submit_link(woof_get_submit_link());
                }
                jQuery('.woof_products_top_panel')
                        .find("[data-tax='" + tax + "'][href='" + name + "']")
                        .hide(333);
                return false;
            });
}

//control conditions if proucts shortcode uses on the page
function woof_shortcode_observer() {
    var redirect = true;
    if (
            jQuery('.woof_shortcode_output').length ||
            (jQuery('.woocommerce .products, .woocommerce .products-loop').length &&
                    !jQuery('.single-product').length)
            ) {
        redirect = false;
    }
    if (jQuery('.woocommerce .woocommerce-info').length) {
        redirect = false;
    }
    if (typeof woof_not_redirect !== 'undefined' && woof_not_redirect == 1) {
        redirect = false;
    }

    if (jQuery('.woot-data-table').length) {
        redirect = false;
    }

    if (!redirect) {
        woof_current_page_link =
                location.protocol + '//' + location.host + location.pathname;
    }

    if (jQuery('#woof_results_by_ajax').length) {
        woof_is_ajax = 1;
    }
}

function woof_init_beauty_scroll() {
    if (woof_use_beauty_scroll) {
        try {
            var anchor =
                    '.woof_section_scrolled, .woof_sid_auto_shortcode .woof_container';
            jQuery('' + anchor).addClass('woof_use_beauty_scroll');
        } catch (e) {
            console.log(e);
        }
    }
}

//just for inbuilt price range widget
function woof_remove_class_widget() {
    jQuery('.woof_container_inner').find('.widget').removeClass('widget');
}

function woof_init_show_auto_form() {
    jQuery('.woof_show_auto_form').off('click');

    if (jQuery('.woof_show_auto_form.woof_btn').length) {
        jQuery('.woof_btn_default').remove();
    }

    jQuery('.woof_show_auto_form').on('click', function () {
        var _this = this;
        jQuery(_this)
                .addClass('woof_hide_auto_form')
                .removeClass('woof_show_auto_form');
        jQuery(_this)
                .parent()
                .find('.woof_auto_show')
                .show()
                .animate(
                        {
                            height:
                                    jQuery(_this)
                                    .parent()
                                    .find('.woof_auto_show_indent')
                                    .height() +
                                    20 +
                                    'px',
                            opacity: 0.96,
                        },
                        377,
                        function () {
                            woof_init_hide_auto_form();
                            jQuery(_this)
                                    .parent()
                                    .find('.woof_auto_show')
                                    .removeClass('woof_overflow_hidden');
                            jQuery(_this)
                                    .parent()
                                    .find('.woof_auto_show_indent')
                                    .removeClass('woof_overflow_hidden');
                            jQuery(_this)
                                    .parent()
                                    .find('.woof_auto_show')
                                    .height('auto');
                        }
                );

        return false;
    });
}

//for woof_auto_show closing on blank place click
document.addEventListener('click', function (e) {
    let opened = document.querySelectorAll('.woof_auto_show');
    let target = e.target;
    let close = !target.classList.contains('woof_sid');
    if (close) {
        close = !target.closest('.woof_sid');
    }

    //this close btn self
    if (target.classList.contains('woof_show_auto_form')) {
        return true;
    }

    if (close && Array.from(opened).length > 0) {
        Array.from(opened).forEach(function (item) {
            if (item.parentNode.querySelector('.woof_hide_auto_form')) {
                item.parentNode.querySelector('.woof_hide_auto_form').click();
            }
        });
    }

    return true;
});

function woof_init_hide_auto_form() {
    jQuery('.woof_hide_auto_form').off('click');
    jQuery('.woof_hide_auto_form').on('click', function () {
        var _this = this;
        jQuery(_this)
                .addClass('woof_show_auto_form')
                .removeClass('woof_hide_auto_form');
        jQuery(_this)
                .parent()
                .find('.woof_auto_show')
                .show()
                .animate(
                        {
                            height: '1px',
                            opacity: 0,
                        },
                        377,
                        function () {
                            jQuery(_this)
                                    .parent()
                                    .find('.woof_auto_show')
                                    .addClass('woof_overflow_hidden');
                            jQuery(_this)
                                    .parent()
                                    .find('.woof_auto_show_indent')
                                    .addClass('woof_overflow_hidden');
                            woof_init_show_auto_form();
                        }
                );

        return false;
    });
}

//if we have mode - child checkboxes closed - append openers buttons by js
function woof_checkboxes_slide() {
    if (woof_checkboxes_slide_flag) {
        var childs = jQuery('ul.woof_childs_list');
        if (childs.length) {
            jQuery.each(childs, function (index, ul) {
                if (jQuery(ul).parents('.woof_no_close_childs').length) {
                    return;
                }
                if (jQuery(ul).find('input').length == 0) {
                    return;
                }

                var span_class = 'woof_is_closed';
                if (woof_supports_html5_storage()) {
                    //test mode  from 06.11.2017
                    var preulstate = localStorage.getItem(
                            jQuery(ul).closest('li').attr('class')
                            );
                    if (preulstate && preulstate == 'woof_is_opened') {
                        var span_class = 'woof_is_opened';
                        jQuery(ul).show();
                    }
                    jQuery(ul)
                            .parent('li')
                            .children('label')
                            .after(
                                    '<a href="javascript:void(0);" rel="nofollow" class="woof_childs_list_opener" title="' +
                                    woof_lang.list_opener +
                                    '" ><span class="' +
                                    span_class +
                                    '"></span></a>'
                                    );
                    //++
                } else {
                    if (
                            jQuery(ul)
                            .find('input[type=checkbox],input[type=radio]')
                            .is(':checked')
                            ) {
                        jQuery(ul).show();
                        span_class = 'woof_is_opened';
                    }
                    jQuery(ul)
                            .parent('li')
                            .children('label')
                            .after(
                                    '<a href="javascript:void(0);" rel="nofollow" class="woof_childs_list_opener" title="' +
                                    woof_lang.list_opener +
                                    '" ><span class="' +
                                    span_class +
                                    '"></span></a>'
                                    );
                }
            });

            jQuery.each(
                    jQuery('a.woof_childs_list_opener span'),
                    function (index, a) {
                        jQuery(a).on('click', function () {
                            var span = jQuery(this);
                            var this_ = jQuery(this).parent(
                                    '.woof_childs_list_opener'
                                    );
                            if (span.hasClass('woof_is_closed')) {
                                //lets open
                                jQuery(this_)
                                        .parent()
                                        .find('ul.woof_childs_list')
                                        .first()
                                        .show(333);
                                span.removeClass('woof_is_closed');
                                span.addClass('woof_is_opened');
                            } else {
                                //lets close
                                jQuery(this_)
                                        .parent()
                                        .find('ul.woof_childs_list')
                                        .first()
                                        .hide(333);
                                span.removeClass('woof_is_opened');
                                span.addClass('woof_is_closed');
                            }

                            if (woof_supports_html5_storage()) {
                                //test mode  from 06.11.2017
                                var ullabel = jQuery(this_)
                                        .closest('li')
                                        .attr('class');
                                var ullstate = jQuery(this_)
                                        .children('span')
                                        .attr('class');
                                localStorage.setItem(ullabel, ullstate);
                            }
                            return false;
                        });
                    }
            );
        }
    }
}

function woof_init_ion_sliders() {
    jQuery.each(jQuery('.woof_range_slider'), function (index, input) {
        try {
            jQuery(input).ionRangeSlider({
                min: jQuery(input).data('min'),
                max: jQuery(input).data('max'),
                from: jQuery(input).data('min-now'),
                to: jQuery(input).data('max-now'),
                type: 'double',
                prefix: jQuery(input).data('slider-prefix'),
                postfix: jQuery(input).data('slider-postfix'),
                prettify: true,
                prettify_separator: jQuery(input).data('thousand-separator'),
                prettify_enabled: true,
                hideMinMax: false,
                hideFromTo: false,
                grid: true,
                step: jQuery(input).data('step'),
                onFinish: function (ui) {
                    var tax = jQuery(input).data('taxes');

                    woof_current_values.min_price =
                            parseFloat(ui.from, 10) / tax;
                    woof_current_values.max_price = parseFloat(ui.to, 10) / tax;
                    //woocs adaptation
                    if (typeof woocs_current_currency !== 'undefined') {
                        woof_current_values.min_price =
                                woof_current_values.min_price /
                                parseFloat(woocs_current_currency.rate);
                        woof_current_values.max_price =
                                woof_current_values.max_price /
                                parseFloat(woocs_current_currency.rate);
                    }
                    //***
                    woof_ajax_page_num = 1;
                    if (
                            woof_autosubmit ||
                            jQuery(input).within('.woof').length == 0
                            ) {
                        woof_submit_link(woof_get_submit_link());
                    }
                    return false;
                },
                onChange: function (data) {
                    if (jQuery('.woof_price_filter_txt')) {
                        var tax = jQuery(input).data('taxes');

                        jQuery('.woof_price_filter_txt_from').val(
                                parseInt(data.from, 10) / tax
                                );
                        jQuery('.woof_price_filter_txt_to').val(
                                parseInt(data.to, 10) / tax
                                );
                        //woocs adaptation
                        if (typeof woocs_current_currency !== 'undefined') {
                            jQuery('.woof_price_filter_txt_from').val(
                                    Math.ceil(
                                            jQuery(
                                                    '.woof_price_filter_txt_from'
                                                    ).val() /
                                            parseFloat(woocs_current_currency.rate)
                                            )
                                    );
                            jQuery('.woof_price_filter_txt_to').val(
                                    Math.ceil(
                                            jQuery('.woof_price_filter_txt_to').val() /
                                            parseFloat(woocs_current_currency.rate)
                                            )
                                    );
                        }
                    }
                },
            });
        } catch (e) {
        }
    });
}

function woof_init_native_woo_price_filter() {
    jQuery('.widget_price_filter form').off('submit');
    jQuery('.widget_price_filter form').on('submit', function () {
        var min_price = jQuery(this)
                .find('.price_slider_amount #min_price')
                .val();
        var max_price = jQuery(this)
                .find('.price_slider_amount #max_price')
                .val();
        woof_current_values.min_price = min_price;
        woof_current_values.max_price = max_price;
        woof_ajax_page_num = 1;
        // if (woof_autosubmit) {
        //comment next code row to avoid endless ajax requests
        woof_submit_link(woof_get_submit_link());
        // }
        return false;
    });
}

//we need after ajax redrawing of the search form
function woof_reinit_native_woo_price_filter() {
    // woocommerce_price_slider_params is required to continue, ensure the object exists
    if (typeof woocommerce_price_slider_params === 'undefined') {
        return false;
    }

    // Get markup ready for slider
    jQuery('input#min_price, input#max_price').hide();
    jQuery('.price_slider, .price_label').show();

    // Price slider uses jquery ui
    var min_price = jQuery('.price_slider_amount #min_price').data('min'),
            max_price = jQuery('.price_slider_amount #max_price').data('max'),
            current_min_price = parseInt(min_price, 10),
            current_max_price = parseInt(max_price, 10);

    if (woof_current_values.hasOwnProperty('min_price')) {
        current_min_price = parseInt(woof_current_values.min_price, 10);
        current_max_price = parseInt(woof_current_values.max_price, 10);
    } else {
        if (woocommerce_price_slider_params.min_price) {
            current_min_price = parseInt(
                    woocommerce_price_slider_params.min_price,
                    10
                    );
        }
        if (woocommerce_price_slider_params.max_price) {
            current_max_price = parseInt(
                    woocommerce_price_slider_params.max_price,
                    10
                    );
        }
    }

    //***

    var currency_symbol = woocommerce_price_slider_params.currency_symbol;
    if (typeof currency_symbol == 'undefined') {
        currency_symbol =
                woocommerce_price_slider_params.currency_format_symbol;
    }

    jQuery(document.body).on(
            'price_slider_create price_slider_slide',
            function (event, min, max) {
                if (typeof woocs_current_currency !== 'undefined') {
                    var label_min = min;
                    var label_max = max;
                    if (typeof currency_symbol == 'undefined') {
                        currency_symbol = woocs_current_currency.symbol;
                    }

                    if (woocs_current_currency.rate !== 1) {
                        label_min = Math.ceil(
                                label_min * parseFloat(woocs_current_currency.rate)
                                );
                        label_max = Math.ceil(
                                label_max * parseFloat(woocs_current_currency.rate)
                                );
                    }

                    //+++
                    label_min = woof_front_number_format(label_min, 2, '.', ',');
                    label_max = woof_front_number_format(label_max, 2, '.', ',');
                    if (
                            jQuery.inArray(
                                    woocs_current_currency.name,
                                    woocs_array_no_cents
                                    ) ||
                            woocs_current_currency.hide_cents == 1
                            ) {
                        label_min = label_min.replace('.00', '');
                        label_max = label_max.replace('.00', '');
                    }
                    //+++

                    if (woocs_current_currency.position === 'left') {
                        jQuery('.price_slider_amount span.from').html(
                                currency_symbol + label_min
                                );
                        jQuery('.price_slider_amount span.to').html(
                                currency_symbol + label_max
                                );
                    } else if (woocs_current_currency.position === 'left_space') {
                        jQuery('.price_slider_amount span.from').html(
                                currency_symbol + ' ' + label_min
                                );
                        jQuery('.price_slider_amount span.to').html(
                                currency_symbol + ' ' + label_max
                                );
                    } else if (woocs_current_currency.position === 'right') {
                        jQuery('.price_slider_amount span.from').html(
                                label_min + currency_symbol
                                );
                        jQuery('.price_slider_amount span.to').html(
                                label_max + currency_symbol
                                );
                    } else if (woocs_current_currency.position === 'right_space') {
                        jQuery('.price_slider_amount span.from').html(
                                label_min + ' ' + currency_symbol
                                );
                        jQuery('.price_slider_amount span.to').html(
                                label_max + ' ' + currency_symbol
                                );
                    }
                } else {
                    if (woocommerce_price_slider_params.currency_pos === 'left') {
                        jQuery('.price_slider_amount span.from').html(
                                currency_symbol + min
                                );
                        jQuery('.price_slider_amount span.to').html(
                                currency_symbol + max
                                );
                    } else if (
                            woocommerce_price_slider_params.currency_pos ===
                            'left_space'
                            ) {
                        jQuery('.price_slider_amount span.from').html(
                                currency_symbol + ' ' + min
                                );
                        jQuery('.price_slider_amount span.to').html(
                                currency_symbol + ' ' + max
                                );
                    } else if (
                            woocommerce_price_slider_params.currency_pos === 'right'
                            ) {
                        jQuery('.price_slider_amount span.from').html(
                                min + currency_symbol
                                );
                        jQuery('.price_slider_amount span.to').html(
                                max + currency_symbol
                                );
                    } else if (
                            woocommerce_price_slider_params.currency_pos ===
                            'right_space'
                            ) {
                        jQuery('.price_slider_amount span.from').html(
                                min + ' ' + currency_symbol
                                );
                        jQuery('.price_slider_amount span.to').html(
                                max + ' ' + currency_symbol
                                );
                    }
                }

                jQuery(document.body).trigger('price_slider_updated', [min, max]);
            }
    );

    jQuery('.price_slider').slider({
        range: true,
        animate: true,
        min: min_price,
        max: max_price,
        values: [current_min_price, current_max_price],
        create: function () {
            jQuery('.price_slider_amount #min_price').val(current_min_price);
            jQuery('.price_slider_amount #max_price').val(current_max_price);

            jQuery(document.body).trigger('price_slider_create', [
                current_min_price,
                current_max_price,
            ]);
        },
        slide: function (event, ui) {
            jQuery('input#min_price').val(ui.values[0]);
            jQuery('input#max_price').val(ui.values[1]);

            jQuery(document.body).trigger('price_slider_slide', [
                ui.values[0],
                ui.values[1],
            ]);
        },
        change: function (event, ui) {
            jQuery(document.body).trigger('price_slider_change', [
                ui.values[0],
                ui.values[1],
            ]);
        },
    });

    //***
    woof_init_native_woo_price_filter();
}

function woof_mass_reinit() {
    woof_remove_empty_elements();
    woof_open_hidden_li();
    woof_init_search_form();
    woof_hide_info_popup();
    woof_init_beauty_scroll();
    woof_init_ion_sliders();
    woof_reinit_native_woo_price_filter(); //native woo price range slider reinit
    woof_recount_text_price_filter();
    woof_draw_products_top_panel();
    woof_unblur_filter();
}
function woof_unblur_filter() {
    jQuery('.woof_redraw_zone.woof_blur_redraw_zone').removeClass(
            'woof_blur_redraw_zone'
            );
}

function woof_recount_text_price_filter() {
    //change value in textinput price filter if WOOCS is installed
    if (typeof woocs_current_currency !== 'undefined') {
        jQuery.each(
                jQuery('.woof_price_filter_txt_from, .woof_price_filter_txt_to'),
                function (i, item) {
                    jQuery(this).val(Math.ceil(jQuery(this).data('value')));
                }
        );
    }
}

function woof_init_toggles() {
    jQuery('body').off('click', '.woof_front_toggle');
    jQuery('body').on('click', '.woof_front_toggle', function () {
        if (jQuery(this).data('condition') == 'opened') {
            jQuery(this).removeClass('woof_front_toggle_opened');
            jQuery(this).addClass('woof_front_toggle_closed');
            jQuery(this).data('condition', 'closed');

            if (woof_toggle_type == 'text') {
                jQuery(this).text(woof_toggle_closed_text);
            } else {
                jQuery(this).find('img').prop('src', woof_toggle_closed_image);
            }
        } else {
            jQuery(this).addClass('woof_front_toggle_opened');
            jQuery(this).removeClass('woof_front_toggle_closed');
            jQuery(this).data('condition', 'opened');
            if (woof_toggle_type == 'text') {
                jQuery(this).text(woof_toggle_opened_text);
            } else {
                jQuery(this).find('img').prop('src', woof_toggle_opened_image);
            }
        }

        jQuery(this)
                .parents('.woof_container_inner')
                .find('.woof_block_html_items')
                .slideToggle(500);

        /* fix  for chosen*/
        var is_chosen_here = jQuery(this)
                .parents('.woof_container_inner')
                .find('.chosen-container');
        if (
                is_chosen_here.length &&
                jQuery(this).hasClass('woof_front_toggle_opened')
                ) {
            jQuery(this)
                    .parents('.woof_container_inner')
                    .find('select')
                    .chosen('destroy')
                    .trigger('liszt:updated');
            jQuery(this)
                    .parents('.woof_container_inner')
                    .find('select')
                    .chosen(/*{disable_search_threshold: 10}*/);
        }
        if (jQuery(this).hasClass('woof_front_toggle_opened')) {
            woof_reinit_selects();
        }

        return false;
    });
}

//for "Show more" blocks
function woof_open_hidden_li() {
    if (jQuery('.woof_open_hidden_li_btn').length > 0) {
        jQuery.each(jQuery('.woof_open_hidden_li_btn'), function (i, b) {
            if (
                    jQuery(b)
                    .parents('ul')
                    .find(
                            'li.woof_hidden_term input[type=checkbox],li.woof_hidden_term input[type=radio]'
                            )
                    .is(':checked')
                    ) {
                jQuery(b).trigger('click');
            }
        });
    }
}

//http://stackoverflow.com/questions/814613/how-to-read-get-data-from-a-url-using-javascript
function $_woof_GET(q, s) {
    s = s ? s : window.location.search;
    var re = new RegExp('&' + q + '=([^&]*)', 'i');
    return (s = s.replace(/^\?/, '&').match(re)) ? (s = s[1]) : (s = '');
}

function woof_parse_url(url) {
    var pattern = RegExp(
            '^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?'
            );
    var matches = url.match(pattern);
    return {
        scheme: matches[2],
        authority: matches[4],
        path: matches[5],
        query: matches[7],
        fragment: matches[9],
    };
}

//      woof price radio;
function woof_price_filter_radio_init() {
    if (icheck_skin != 'none') {
        jQuery('.woof_price_filter_radio').iCheck('destroy');

        let icheck_selector = '.woof_price_filter_radio';
        let skin = jQuery(icheck_selector)
                .parents('.woof_redraw_zone')
                .eq(0)
                .data('icheck-skin');
        if (skin) {
            skin = skin.split('_');
            jQuery(icheck_selector).iCheck({
                radioClass: 'iradio_' + skin[0] + '-' + skin[1],
            });
        } else {
            jQuery(icheck_selector).iCheck({
                radioClass:
                        'iradio_' + icheck_skin.skin + '-' + icheck_skin.color,
            });
        }

        //***

        jQuery('.woof_price_filter_radio')
                .siblings('div')
                .removeClass('checked');

        jQuery('.woof_price_filter_radio').off('ifChecked');
        jQuery('.woof_price_filter_radio').on('ifChecked', function (event) {
            jQuery(this).attr('checked', true);
            jQuery('.woof_radio_price_reset').removeClass(
                    'woof_radio_term_reset_visible'
                    );
            jQuery(this)
                    .parents('.woof_list')
                    .find('.woof_radio_price_reset')
                    .removeClass('woof_radio_term_reset_visible');
            jQuery(this)
                    .parents('.woof_list')
                    .find('.woof_radio_price_reset')
                    .hide();
            jQuery(this)
                    .parents('li')
                    .eq(0)
                    .find('.woof_radio_price_reset')
                    .eq(0)
                    .addClass('woof_radio_term_reset_visible');
            var val = jQuery(this).val();
            if (parseInt(val, 10) == -1) {
                delete woof_current_values.min_price;
                delete woof_current_values.max_price;
                jQuery(this).removeAttr('checked');
                jQuery(this)
                        .siblings('.woof_radio_price_reset')
                        .removeClass('woof_radio_term_reset_visible');
            } else {
                var val = val.split('-');
                woof_current_values.min_price = val[0];
                woof_current_values.max_price = val[1];
                jQuery(this)
                        .siblings('.woof_radio_price_reset')
                        .addClass('woof_radio_term_reset_visible');
                jQuery(this).attr('checked', true);
            }
            if (woof_autosubmit || jQuery(this).within('.woof').length == 0) {
                woof_submit_link(woof_get_submit_link());
            }
        });
    } else {
        jQuery('body').on('change', '.woof_price_filter_radio', function () {
            var val = jQuery(this).val();
            jQuery('.woof_radio_price_reset').removeClass(
                    'woof_radio_term_reset_visible'
                    );
            if (parseInt(val, 10) == -1) {
                delete woof_current_values.min_price;
                delete woof_current_values.max_price;
                jQuery(this).removeAttr('checked');
                jQuery(this)
                        .siblings('.woof_radio_price_reset')
                        .removeClass('woof_radio_term_reset_visible');
            } else {
                var val = val.split('-');
                woof_current_values.min_price = val[0];
                woof_current_values.max_price = val[1];
                jQuery(this)
                        .siblings('.woof_radio_price_reset')
                        .addClass('woof_radio_term_reset_visible');
                jQuery(this).attr('checked', true);
            }
            if (woof_autosubmit || jQuery(this).within('.woof').length == 0) {
                woof_submit_link(woof_get_submit_link());
            }
        });
    }
    //***
    jQuery('.woof_radio_price_reset').on('click', function () {
        delete woof_current_values.min_price;
        delete woof_current_values.max_price;
        jQuery(this).siblings('div').removeClass('checked');
        jQuery(this)
                .parents('.woof_list')
                .find('input[type=radio]')
                .removeAttr('checked');

        jQuery(this).removeClass('woof_radio_term_reset_visible');
        if (woof_autosubmit) {
            woof_submit_link(woof_get_submit_link());
        }
        return false;
    });
}
//    END  woof price radio;

function woof_serialize(serializedString) {
    var str = decodeURI(serializedString);
    var pairs = str.split('&');
    var obj = {},
            p,
            idx,
            val;
    for (var i = 0, n = pairs.length; i < n; i++) {
        p = pairs[i].split('=');
        idx = p[0];

        if (idx.indexOf('[]') == idx.length - 2) {
            // Eh um vetor
            var ind = idx.substring(0, idx.length - 2);
            if (obj[ind] === undefined) {
                obj[ind] = [];
            }
            obj[ind].push(p[1]);
        } else {
            obj[idx] = p[1];
        }
    }
    return obj;
}

//compatibility with YITH Infinite Scrolling
function woof_infinite() {
    if (typeof yith_infs_premium !== 'undefined' && yith_infs_premium.options) {
        woof_change_ajax_next_link();
        return false;
    }

    if (typeof yith_infs === 'undefined') {
        return;
    }

    //***
    var infinite_scroll1 = {
        //'nextSelector': ".woof_infinity .nav-links .next",
        nextSelector: '.woocommerce-pagination li .next',
        navSelector: yith_infs.navSelector,
        itemSelector: yith_infs.itemSelector,
        contentSelector: yith_infs.contentSelector,
        loader: '<img src="' + yith_infs.loader + '">',
        is_shop: yith_infs.shop,
    };
    woof_change_ajax_next_link();
    jQuery(window).off('yith_infs_start'),
            jQuery(yith_infs.contentSelector).yit_infinitescroll(infinite_scroll1);
}

function woof_change_ajax_next_link() {
    if (!jQuery('.woocommerce-pagination li .next').length) {
        return false;
    }
    var curr_l = window.location.href;
    var curr_link = curr_l.split('?');
    var get = '';
    if (curr_link[1] != undefined) {
        var temp = woof_serialize(curr_link[1]);
        delete temp['paged'];
        get = decodeURIComponent(jQuery.param(temp));
    }

    var page_link = jQuery('.woocommerce-pagination li .next').attr('href');

    if (page_link == undefined) {
        page_link = curr_link + 'page/1/';
    }

    var ajax_link = page_link.split('?');
    var page = '';
    if (ajax_link[1] != undefined) {
        var temp1 = woof_serialize(ajax_link[1]);
        if (temp1['paged'] != undefined) {
            page = '/page/' + temp1['paged'] + '/';
        }
    }

    page_link = curr_link[0].replace(/\/$/, '') + page + '?' + get;

    jQuery('.woocommerce-pagination li .next').attr('href', page_link);
}
//End infinity scroll

//fix  if woof - is ajax  and  cart - is redirect
function woof_change_link_addtocart() {
    if (!woof_is_ajax) {
        return;
    }
    jQuery('.add_to_cart_button').each(function (i, elem) {
        var link = jQuery(elem).attr('href');
        if (link) {
            var link_items = link.split('?');
            var site_link_items = window.location.href.split('?');
            if (link_items[1] != undefined) {
                link = site_link_items[0] + '?' + link_items[1];
                jQuery(elem).attr('href', link);
            }
        }
    });
}
//https://github.com/kvz/phpjs/blob/master/functions/strings/number_format.js
function woof_front_number_format(number, decimals, dec_point, thousands_sep) {
    number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
    var n = !isFinite(+number) ? 0 : +number,
            prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
            sep = typeof thousands_sep === 'undefined' ? ',' : thousands_sep,
            dec = typeof dec_point === 'undefined' ? '.' : dec_point,
            s = '',
            toFixedFix = function (n, prec) {
                var k = Math.pow(10, prec);
                return '' + (Math.round(n * k) / k).toFixed(prec);
            };
    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {
        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');
    }
    return s.join(dec);
}

//additional function to check local storage
function woof_supports_html5_storage() {
    if (typeof woof_save_state_checkbox !== 'undefined' && woof_save_state_checkbox === 0) {
        return false;
    }
    try {
        return 'localStorage' in window && window['localStorage'] !== null;
    } catch (e) {
        return false;
    }
}

function woof_init_tooltip() {
    var tooltips = jQuery('.woof_tooltip_header');

    if (tooltips.length) {
        jQuery(tooltips).tooltipster({
            theme: 'tooltipster-noir',
            side: 'right',
            trigger: 'click',
        });
    }
}
function woof_before_ajax_form_redrawing() {
    if (woof_select_type == 'selectwoo') {
        try {
            jQuery('select.woof_mselect').selectWoo('destroy');
            jQuery('select.woof_meta_mselect').selectWoo('destroy');
        } catch (e) {
            return false;
        }
    }
}
function woof_reinit_selects() {
    if (woof_select_type == 'chosen') {
        try {
            jQuery('select.woof_select, select.woof_mselect')
                    .chosen('destroy')
                    .trigger('liszt:updated');
            jQuery(
                    'select.woof_select, select.woof_mselect'
                    ).chosen(/*{disable_search_threshold: 10}*/);
            jQuery('select.woof_meta_select, select.woof_meta_mselect')
                    .chosen('destroy')
                    .trigger('liszt:updated');
            jQuery(
                    'select.woof_meta_select, select.woof_meta_mselect'
                    ).chosen(/*{disable_search_threshold: 10}*/);
        } catch (e) {
        }
    } else if (woof_select_type == 'selectwoo') {
        try {
            jQuery('select.woof_select, select.woof_mselect').selectWoo(
                    'destroy'
                    );
            jQuery('select.woof_select, select.woof_mselect').selectWoo();
            jQuery(
                    'select.woof_meta_select, select.woof_meta_mselect'
                    ).selectWoo('destroy');
            jQuery(
                    'select.woof_meta_select, select.woof_meta_mselect'
                    ).selectWoo();
        } catch (e) {
        }
    }
}
function woof_init_mobile_filter() {
    var show_btn = jQuery('.woof_show_mobile_filter');
    var show_btn_container = jQuery('.woof_show_mobile_filter_container');
    var def_container = jQuery(woof_m_b_container);
    if (!show_btn_container.length) {
        show_btn_container = def_container;
    }
    if (show_btn && show_btn_container) {
        jQuery(show_btn_container).append(show_btn);
    }

    jQuery('.woof_show_mobile_filter').on('click', function (e) {
        var sid = jQuery(this).data('sid');

        if (jQuery('.woof.woof_sid_front_builder').length > 0) {
            //front builder adaptation
            sid = 'front_builder';
            jQuery('.woof.woof_sid_' + sid).toggleClass(
                    'woof_show_filter_for_mobile'
                    );
        } else {
            jQuery('.woof.woof_sid_' + sid).toggleClass(
                    'woof_show_filter_for_mobile'
                    );
        }

        setTimeout(function () {
            try {
                jQuery('.woof.woof_sid_' + sid)
                        .find('select.woof_mselect')
                        .chosen('destroy');
                jQuery('.woof.woof_sid_' + sid)
                        .find('select.woof_select')
                        .chosen('destroy');
                jQuery('.woof.woof_sid_' + sid)
                        .find('select.woof_mselect')
                        .chosen();
                jQuery('.woof.woof_sid_' + sid)
                        .find('select.woof_select')
                        .chosen();
            } catch (e) {
                //***
            }
        }, 300);
    });

    jQuery('.woof_hide_mobile_filter').on('click', function (e) {
        jQuery(this)
                .parents('.woof')
                .toggleClass('woof_show_filter_for_mobile');
    });
};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/js/html_types/radio.js?ver=3.4.0 
"use strict";
function woof_init_radios() {
    if (icheck_skin != 'none') {
        jQuery('.woof_radio_term').iCheck('destroy');

        let skin = jQuery('.woof_radio_term').parents('.woof_redraw_zone').eq(0).data('icheck-skin');
        if (skin) {
            skin = skin.split('_');
            jQuery('.woof_radio_term').iCheck({
                radioClass: 'iradio_' + skin[0] + '-' + skin[1]
            });
        } else {
            jQuery('.woof_radio_term').iCheck({
                radioClass: 'iradio_' + icheck_skin.skin + '-' + icheck_skin.color
            });
        }


        jQuery('.woof_radio_term').off('ifChecked');
        jQuery('.woof_radio_term').on('ifChecked', function (event) {
            jQuery(this).attr("checked", true);
            jQuery(this).parents('.woof_list').find('.woof_radio_term_reset').removeClass('woof_radio_term_reset_visible');
            jQuery(this).parents('.woof_list').find('.woof_radio_term_reset').hide();
            jQuery(this).parents('li').eq(0).find('.woof_radio_term_reset').eq(0).addClass('woof_radio_term_reset_visible');
            var slug = jQuery(this).data('slug');
            var name = jQuery(this).attr('name');
            var term_id = jQuery(this).data('term-id');
            woof_radio_direct_search(term_id, name, slug);
        });

        //***



    } else {
        jQuery('.woof_radio_term').on('change', function (event) {
            jQuery(this).attr("checked", true);
            var slug = jQuery(this).data('slug');
            var name = jQuery(this).attr('name');
            var term_id = jQuery(this).data('term-id');

            jQuery(this).parents('.woof_list').find('.woof_radio_term_reset').removeClass('woof_radio_term_reset_visible');
            jQuery(this).parents('.woof_list').find('.woof_radio_term_reset').hide();
            jQuery(this).parents('li').eq(0).find('.woof_radio_term_reset').eq(0).addClass('woof_radio_term_reset_visible');

            woof_radio_direct_search(term_id, name, slug);
        });
    }

    //***

    jQuery('.woof_radio_term_reset').on('click', function () {
        woof_radio_direct_search(jQuery(this).data('term-id'), jQuery(this).attr('data-name'), 0);
        jQuery(this).parents('.woof_list').find('.checked').removeClass('checked');
        jQuery(this).parents('.woof_list').find('input[type=radio]').removeAttr('checked');
        //jQuery(this).remove();
        jQuery(this).removeClass('woof_radio_term_reset_visible');
        return false;
    });
}


function woof_radio_direct_search(term_id, name, slug) {

    jQuery.each(woof_current_values, function (index, value) {
        if (index == name) {
            delete woof_current_values[name];
            return;
        }
    });

    if (slug != 0) {
        woof_current_values[name] = slug;
        jQuery('a.woof_radio_term_reset_' + term_id).hide();
        jQuery('woof_radio_term_' + term_id).filter(':checked').parents('li').find('a.woof_radio_term_reset').show();
        jQuery('woof_radio_term_' + term_id).parents('ul.woof_list').find('label').css({'fontWeight': 'normal'});
        jQuery('woof_radio_term_' + term_id).filter(':checked').parents('li').find('label.woof_radio_label_' + slug).css({'fontWeight': 'bold'});
    } else {
        jQuery('a.woof_radio_term_reset_' + term_id).hide();
        jQuery('woof_radio_term_' + term_id).attr('checked', false);
        jQuery('woof_radio_term_' + term_id).parent().removeClass('checked');
        jQuery('woof_radio_term_' + term_id).parents('ul.woof_list').find('label').css({'fontWeight': 'normal'});
    }

    woof_ajax_page_num = 1;
    if (woof_autosubmit) {
        woof_submit_link(woof_get_submit_link());
    }
};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/js/html_types/checkbox.js?ver=3.4.0 
"use strict";
function woof_init_checkboxes() {
    if (icheck_skin != 'none') {

        jQuery('.woof_checkbox_term').iCheck('destroy');

        let icheck_selector = '.woof_checkbox_term';
        let skin = jQuery(icheck_selector).parents('.woof_redraw_zone').eq(0).data('icheck-skin');
        if (skin) {
            skin = skin.split('_');
            jQuery(icheck_selector).iCheck({
                checkboxClass: 'icheckbox_' + skin[0] + '-' + skin[1]
            });
        } else {
            jQuery(icheck_selector).iCheck({
                checkboxClass: 'icheckbox_' + icheck_skin.skin + '-' + icheck_skin.color
            });
        }

        jQuery('.woof_checkbox_term').off('ifChecked');
        jQuery('.woof_checkbox_term').on('ifChecked', function (event) {
            jQuery(this).attr("checked", true);
	//jQuery(".woof_select_radio_check input").attr('disabled', 'disabled');
            woof_checkbox_process_data(this, true);
        });

        jQuery('.woof_checkbox_term').off('ifUnchecked');
        jQuery('.woof_checkbox_term').on('ifUnchecked', function (event) {
            jQuery(this).attr("checked", false);
            woof_checkbox_process_data(this, false);
        });

        //this script should be, because another way wrong way of working if to click on the label
        jQuery('.woof_checkbox_label').off();
        jQuery('label.woof_checkbox_label').on('click', function () {
            if (jQuery(this).prev().find('.woof_checkbox_term').is(':disabled')) {
                return false;
            }
            // if (jQuery(this).prev().find('.woof_checkbox_term').is(':checked')) {
            if (typeof jQuery(this).prev().find('.woof_checkbox_term').attr('checked') != 'undefined') {
                jQuery(this).prev().find('.woof_checkbox_term').trigger('ifUnchecked');
                jQuery(this).prev().removeClass('checked');
            } else {
                jQuery(this).prev().find('.woof_checkbox_term').trigger('ifChecked');
                jQuery(this).prev().addClass('checked');
            }


        });
        //***

    } else {

        jQuery('.woof_checkbox_term').on('change', function (event) {
            if (jQuery(this).is(':checked')) {
                jQuery(this).attr("checked", true);
                woof_checkbox_process_data(this, true);
            } else {
                jQuery(this).attr("checked", false);
                woof_checkbox_process_data(this, false);
            }
        });
    }
}
function woof_checkbox_process_data(_this, is_checked) {
    var tax = jQuery(_this).data('tax');
    var name = jQuery(_this).attr('name');
    var term_id = jQuery(_this).data('term-id');

    woof_checkbox_direct_search(term_id, name, tax, is_checked);
}
function woof_checkbox_direct_search(term_id, name, tax, is_checked) {

    var values = '';
    var checked = true;
    if (is_checked) {
        if (tax in woof_current_values) {
            woof_current_values[tax] = woof_current_values[tax] + ',' + name;
        } else {
            woof_current_values[tax] = name;
        }
        checked = true;
    } else {
        values = woof_current_values[tax];

        values = values.split(',');
        var tmp = [];
        jQuery.each(values, function (index, value) {
            if (value != name) {
                tmp.push(value);
            }
        });
        values = tmp;
        if (values.length) {
            woof_current_values[tax] = values.join(',');
        } else {
            delete woof_current_values[tax];
        }
        checked = false;
    }
    jQuery('.woof_checkbox_term_' + term_id).attr('checked', checked);
    woof_ajax_page_num = 1;

    if (woof_autosubmit) {
        woof_submit_link(woof_get_submit_link());
    }

};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/js/html_types/select.js?ver=3.4.0 
"use strict";
function woof_init_selects() {
    
    if (woof_select_type == 'chosen') {
	jQuery("select.woof_select, select.woof_price_filter_dropdown").chosen();
    } else if (woof_select_type == 'selectwoo') {
	jQuery("select.woof_select, select.woof_price_filter_dropdown").selectWoo();
    }

    jQuery('.woof_select').change(function () {
        var slug = jQuery(this).val();
        var name = jQuery(this).attr('name');
        woof_select_direct_search(this, name, slug);
    });

    var containers = jQuery('.woof_hide_empty_container');
    jQuery.each(containers, function(i, item){
	var selector= jQuery(item).val();
	if(selector){
	    jQuery(selector).hide();
	}
	
    });
    
}

function woof_select_direct_search(_this, name, slug) {

    jQuery.each(woof_current_values, function (index, value) {
        if (index == name) {
            delete woof_current_values[name];
            return;
        }
    });

    if (slug != 0) {
        woof_current_values[name] = slug;
    }

    woof_ajax_page_num = 1;
    if (woof_autosubmit || jQuery(_this).within('.woof').length == 0) {
        woof_submit_link(woof_get_submit_link());
    }

};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/js/html_types/mselect.js?ver=3.4.0 
"use strict";
function woof_init_mselects() {
    if (woof_select_type == 'chosen') {
        jQuery('select.woof_mselect').chosen();
    } else if (woof_select_type == 'selectwoo') {
        try {
            jQuery('select.woof_mselect').selectWoo();
        } catch (e) {
            console.log(e);
        }
    }

    jQuery('.woof_mselect').change(function (a) {
        var slug = jQuery(this).val();
        var name = jQuery(this).attr('name');

        //fix for multiselect if in chosen mode remove options
        if (woof_select_type == 'chosen') {
            var vals = jQuery(this).chosen().val();
            jQuery('.woof_mselect[name=' + name + '] option:selected').removeAttr("selected");
            jQuery('.woof_mselect[name=' + name + '] option').each(function (i, option) {
                var v = jQuery(this).val();
                if (jQuery.inArray(v, vals) !== -1) {
                    jQuery(this).prop("selected", true);
                }
            });
        }

        woof_mselect_direct_search(name, slug);
        return true;
    });
    var containers = jQuery('.woof_hide_empty_container_ms');
    jQuery.each(containers, function (i, item) {
        var selector = jQuery(item).val();
        if (selector) {
            jQuery(selector).hide();
        }

    });
}

function woof_mselect_direct_search(name, slug) {
    //mode with Filter button
    var values = [];
    jQuery('.woof_mselect[name=' + name + '] option:selected').each(function (i, v) {
        values.push(jQuery(this).val());
    });

    //duplicates removing
    //http://stackoverflow.com/questions/9229645/remove-duplicates-from-javascript-array
    values = values.filter(function (item, pos) {
        return values.indexOf(item) == pos;
    });

    values = values.join(',');
    if (values.length) {
        woof_current_values[name] = values;
    } else {
        delete woof_current_values[name];
    }

    woof_ajax_page_num = 1;
    if (woof_autosubmit) {
        woof_submit_link(woof_get_submit_link());
    }
};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/by_author/js/by_author.js?ver=3.4.0 
"use strict";

function woof_init_author() {
	if (icheck_skin != 'none') {

		jQuery( '.woof_checkbox_author' ).iCheck( 'destroy' );

		let icheck_selector = '.woof_checkbox_author';
		let skin            = jQuery( icheck_selector ).parents( '.woof_redraw_zone' ).eq( 0 ).data( 'icheck-skin' );
		if (skin) {
			skin = skin.split( '_' );
			jQuery( icheck_selector ).iCheck(
				{
					checkboxClass: 'icheckbox_' + skin[0] + '-' + skin[1]
				}
			);
		} else {
			jQuery( icheck_selector ).iCheck(
				{
					checkboxClass: 'icheckbox_' + icheck_skin.skin + '-' + icheck_skin.color
				}
			);
		}

		// +++

		jQuery( '.woof_checkbox_author' ).on(
			'ifChecked',
			function (event) {
				jQuery( this ).attr( "checked", true );

				woof_current_values.woof_author = get_current_checked( this );
				woof_ajax_page_num              = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			}
		);

		jQuery( '.woof_checkbox_author' ).on(
			'ifUnchecked',
			function (event) {
				jQuery( this ).attr( "checked", false );
				jQuery( this ).removeAttr( "checked" );

				woof_current_values.woof_author = get_current_checked( this );
				woof_ajax_page_num              = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			}
		);

	} else {
		jQuery( '.woof_checkbox_author' ).on(
			'change',
			function (event) {

				if (jQuery( this ).is( ':checked' )) {
					jQuery( this ).attr( "checked", true );
					woof_current_values.woof_author = get_current_checked( this );
					woof_ajax_page_num              = 1;
					if (woof_autosubmit) {
						woof_submit_link( woof_get_submit_link() );
					}
				} else {
					jQuery( this ).attr( "checked", false );
					woof_current_values.woof_author = get_current_checked( this );
					woof_ajax_page_num              = 1;
					if (woof_autosubmit) {
						woof_submit_link( woof_get_submit_link() );
					}
				}
			}
		);
	}

	function get_current_checked(_this) {
		var values = [];
		jQuery( _this ).parents( '.woof_authors' ).find( '.woof_checkbox_author' ).each(
			function (i, el) {
				if (jQuery( this ).attr( "checked" ) == 'checked') {
					values.push( jQuery( this ).val() );

				}

			}
		);

		values = values.filter( (v, i, a) => a.indexOf( v ) === i );
		return values.join( ',' );
	}

};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/by_backorder/js/by_backorder.js?ver=3.4.0 
"use strict";
function woof_init_onbackorder() {
	if (icheck_skin != 'none') {

		jQuery( '.woof_checkbox_onbackorder' ).iCheck( 'destroy' );

		let icheck_selector = '.woof_checkbox_onbackorder';
		let skin            = jQuery( icheck_selector ).parents( '.woof_redraw_zone' ).eq( 0 ).data( 'icheck-skin' );
		if (skin) {
			skin = skin.split( '_' );
			jQuery( icheck_selector ).iCheck(
				{
					checkboxClass: 'icheckbox_' + skin[0] + '-' + skin[1]
				}
			);
		} else {
			jQuery( icheck_selector ).iCheck(
				{
					checkboxClass: 'icheckbox_' + icheck_skin.skin + '-' + icheck_skin.color
				}
			);
		}

		jQuery( '.woof_checkbox_onbackorder' ).on(
			'ifChecked',
			function (event) {
				jQuery( this ).attr( "checked", true );
				woof_current_values.backorder = 'onbackorder';
				woof_ajax_page_num            = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			}
		);

		jQuery( '.woof_checkbox_onbackorder' ).on(
			'ifUnchecked',
			function (event) {
				jQuery( this ).attr( "onbackorder", false );
				delete woof_current_values.backorder;
				woof_ajax_page_num = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			}
		);

	} else {
		jQuery( '.woof_checkbox_onbackorder' ).on(
			'change',
			function (event) {
				if (jQuery( this ).is( ':checked' )) {
					jQuery( this ).attr( "checked", true );
					woof_current_values.backorder = 'onbackorder';
					woof_ajax_page_num            = 1;
					if (woof_autosubmit) {
						woof_submit_link( woof_get_submit_link() );
					}
				} else {
					jQuery( this ).attr( "checked", false );
					delete woof_current_values.backorder;
					woof_ajax_page_num = 1;
					if (woof_autosubmit) {
						woof_submit_link( woof_get_submit_link() );
					}
				}
			}
		);
	}

	// +++

	jQuery( '.woof_checkbox_onbackorder_as_switcher' ).on(
		'change',
		function (event) {
			if (jQuery( this ).is( ':checked' )) {
				jQuery( this ).attr( "checked", true );
				woof_current_values.backorder = 'onbackorder';
				woof_ajax_page_num            = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			} else {
				jQuery( this ).attr( "checked", false );
				delete woof_current_values.backorder;
				woof_ajax_page_num = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			}
		}
	);
};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/by_instock/js/by_instock.js?ver=3.4.0 
"use strict";
function woof_init_instock() {
	if (icheck_skin != 'none') {

		jQuery( '.woof_checkbox_instock' ).iCheck( 'destroy' );

		let icheck_selector = '.woof_checkbox_instock';
		let skin            = jQuery( icheck_selector ).parents( '.woof_redraw_zone' ).eq( 0 ).data( 'icheck-skin' );
		if (skin) {
			skin = skin.split( '_' );
			jQuery( icheck_selector ).iCheck(
				{
					checkboxClass: 'icheckbox_' + skin[0] + '-' + skin[1]
				}
			);
		} else {
			jQuery( icheck_selector ).iCheck(
				{
					checkboxClass: 'icheckbox_' + icheck_skin.skin + '-' + icheck_skin.color
				}
			);
		}

		jQuery( '.woof_checkbox_instock, .woof_checkbox_instock2' ).on(
			'ifChecked',
			function (event) {
				jQuery( this ).attr( "checked", true );
				woof_current_values.stock = 'instock';
				woof_ajax_page_num        = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			}
		);

		jQuery( '.woof_checkbox_instock, .woof_checkbox_instock2' ).on(
			'ifUnchecked',
			function (event) {
				jQuery( this ).attr( "checked", false );
				delete woof_current_values.stock;
				woof_ajax_page_num = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			}
		);
	} else {
		jQuery( '.woof_checkbox_instock' ).on(
			'change',
			function (event) {
				if (jQuery( this ).is( ':checked' )) {
					jQuery( this ).attr( "checked", true );
					woof_current_values.stock = 'instock';
					woof_ajax_page_num        = 1;
					if (woof_autosubmit) {
						woof_submit_link( woof_get_submit_link() );
					}
				} else {
					jQuery( this ).attr( "checked", false );
					delete woof_current_values.stock;
					woof_ajax_page_num = 1;
					if (woof_autosubmit) {
						woof_submit_link( woof_get_submit_link() );
					}
				}
			}
		);
	}

	// +++

	jQuery( '.woof_checkbox_instock_as_switcher' ).on(
		'change',
		function (event) {
			if (jQuery( this ).is( ':checked' )) {
				jQuery( this ).attr( "checked", true );
				woof_current_values.stock = 'instock';
				woof_ajax_page_num        = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			} else {
				jQuery( this ).attr( "checked", false );
				delete woof_current_values.stock;
				woof_ajax_page_num = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			}
		}
	);
};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/by_onsales/js/by_onsales.js?ver=3.4.0 
"use strict";
function woof_init_onsales() {

	if (icheck_skin != 'none') {

		jQuery( '.woof_checkbox_sales' ).iCheck( 'destroy' );

		let icheck_selector = '.woof_checkbox_sales';
		let skin            = jQuery( icheck_selector ).parents( '.woof_redraw_zone' ).eq( 0 ).data( 'icheck-skin' );
		if (skin) {
			skin = skin.split( '_' );
			jQuery( icheck_selector ).iCheck(
				{
					checkboxClass: 'icheckbox_' + skin[0] + '-' + skin[1]
				}
			);
		} else {
			jQuery( icheck_selector ).iCheck(
				{
					checkboxClass: 'icheckbox_' + icheck_skin.skin + '-' + icheck_skin.color
				}
			);
		}

		jQuery( '.woof_checkbox_sales' ).on(
			'ifChecked',
			function (event) {
				jQuery( this ).attr( "checked", true );
				woof_current_values.onsales = 'salesonly';
				woof_ajax_page_num          = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			}
		);

		jQuery( '.woof_checkbox_sales' ).on(
			'ifUnchecked',
			function (event) {
				jQuery( this ).attr( "checked", false );
				delete woof_current_values.onsales;
				woof_ajax_page_num = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			}
		);

	} else {

		jQuery( '.woof_checkbox_sales' ).on(
			'change',
			function (event) {
				if (jQuery( this ).is( ':checked' )) {
					jQuery( this ).attr( "checked", true );
					woof_current_values.onsales = 'salesonly';
					woof_ajax_page_num          = 1;
					if (woof_autosubmit) {
						woof_submit_link( woof_get_submit_link() );
					}
				} else {
					jQuery( this ).attr( "checked", false );
					delete woof_current_values.onsales;
					woof_ajax_page_num = 1;
					if (woof_autosubmit) {
						woof_submit_link( woof_get_submit_link() );
					}
				}
			}
		);
	}

	// +++

	jQuery( '.woof_checkbox_sales_as_switcher' ).on(
		'change',
		function (event) {
			if (jQuery( this ).is( ':checked' )) {
				jQuery( this ).attr( "checked", true );
				woof_current_values.onsales = 'salesonly';
				woof_ajax_page_num          = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			} else {
				jQuery( this ).attr( "checked", false );
				delete woof_current_values.onsales;
				woof_ajax_page_num = 1;
				if (woof_autosubmit) {
					woof_submit_link( woof_get_submit_link() );
				}
			}
		}
	);
};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/by_sku/js/by_sku.js?ver=3.4.0 
"use strict";
var woof_sku_do_submit = false;
function woof_init_sku() {
	woof_sku_check_reset();
	jQuery( '.woof_show_sku_search' ).keyup(
		function (e) {

			let parent                      = this.parentNode;
			let woof_sku_autocomplete       = parseInt( parent.dataset.autocomplete );
			let woof_sku_autocomplete_items = parseInt( parent.dataset.autocomplete_items );

			var val = jQuery( this ).val();
			val     = val.replace( ' ', '' );
			var uid = jQuery( this ).data( 'uid' );

			if (e.keyCode == 13) {
				woof_sku_do_submit = true;
				woof_sku_direct_search( 'woof_sku', val );
				return true;
			}

			// save new word into woof_current_values
			if (woof_autosubmit) {
				woof_current_values['woof_sku'] = val;
			} else {
				woof_sku_direct_search( 'woof_sku', val );
			}

			// if (woof_is_mobile == 1) {
			if (val.length > 0) {
				jQuery( '.woof_sku_search_go.' + uid ).show( 222 );
				jQuery( '.woof_sku_search_reset.' + uid ).show( 222 );
			} else {
				jQuery( '.woof_sku_search_go.' + uid ).hide();
				jQuery( '.woof_sku_search_reset.' + uid ).hide();
			}
			// }

			// http://easyautocomplete.com/examples
			if (val.length >= 3 && woof_sku_autocomplete) {
				var input_id = jQuery( this ).attr( 'id' );
				var nonce    = jQuery( '.woof_sku_search_nonce' ).val()
				var options  = {
					url: function (phrase) {
						return woof_ajaxurl;
					},
					//theme: "square",
					getValue: function (element) {
						return element.name;
					},
					ajaxSettings: {
						dataType: "json",
						method: "POST",
						data: {
							action: "woof_sku_autocomplete",
							dataType: "json",
							woof_sku_search_nonce: nonce
						}
					},
					preparePostData: function (data) {
						data.phrase = jQuery( "#" + input_id ).val();
						return data;
					},
					template: {
						type: "description",
						fields: {

							description: "type"
						}
					},
					list: {
						maxNumberOfElements: woof_sku_autocomplete_items,
						onChooseEvent: function () {
							woof_sku_do_submit = true;
							woof_sku_direct_search( 'woof_sku', jQuery( "#" + input_id ).val() );
							return true;
						},
						showAnimation: {
							type: "fade", // normal|slide|fade
							time: 333,
							callback: function () {
							}
						},
						hideAnimation: {
							type: "slide", // normal|slide|fade
							time: 333,
							callback: function () {
							}
						}

					},
					requestDelay: 400
				};
				try {
					jQuery( "#" + input_id ).easyAutocomplete( options );
				} catch (e) {
					console.log( e );
				}
				jQuery( "#" + input_id ).focus();
			}
		}
	);
	// +++
	jQuery( 'body' ).on(
		'click',
		'.woof_sku_search_go',
		function () {
			var uid            = jQuery( this ).data( 'uid' );
			woof_sku_do_submit = true;
			var val            = jQuery( '.woof_show_sku_search.' + uid ).val();
			val                = val.replace( ' ', '' );
			woof_sku_direct_search( 'woof_sku', val );
		}
	);
	jQuery( 'body' ).on(
		'click',
		'.woof_sku_search_reset',
		function () {
			var uid = jQuery( this ).data( 'uid' );
			jQuery( '.woof_show_sku_search.' + uid ).val( "" );
			if (typeof woof_current_values['woof_sku'] != 'undefined') {
				delete woof_current_values['woof_sku'];
			}
			woof_sku_check_reset();

			let woof_sku_reset_behavior = parseInt( this.dataset.reset_behavior );

			if (woof_sku_reset_behavior) {
				woof_submit_link( woof_get_submit_link() );
			}
		}
	);
}

function woof_sku_check_reset() {
	var all_sku = jQuery( '.woof_show_sku_search' );
	jQuery.each(
		all_sku,
		function (index, input) {
			var val = jQuery( input ).val();
			var uid = jQuery( input ).data( 'uid' );
			if (val.length > 0) {
				jQuery( '.woof_sku_search_reset.' + uid ).show( 222 );
			} else {
				jQuery( '.woof_sku_search_reset.' + uid ).hide();
			}
		}
	);
}

function woof_sku_direct_search(name, slug) {

	jQuery.each(
		woof_current_values,
		function (index, value) {
			if (index == name) {
				delete woof_current_values[name];
				return;
			}
		}
	);

	if (slug != 0) {
		woof_current_values[name] = slug;
	}

	woof_ajax_page_num = 1;
	if (woof_autosubmit || woof_sku_do_submit) {
		woof_sku_do_submit = false;
		woof_submit_link( woof_get_submit_link() );
	}
};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/by_text/assets/js/front.js?ver=3.4.0 
'use strict';

function woof_init_text(){
	(function ($) {
		let sparams = (new URL( window.location.href )).searchParams;

		let data = {
			// s: typeof sparams.get('woof_text') !== 'undefined' ? sparams.get('woof_text') : ''
		};

		data = {...data, ...woof_husky_txt.default_data};
		delete data.page;// fix to avoid pagination breaking

		[].forEach.call(
			$.querySelectorAll( 'input.woof_husky_txt-input' ),
			function (input) {
				let txt = jQuery( input ).val();
				data.s  = txt;
				new HuskyText( input, data );
			}
		);

		// init default wp search as HuskyText - to options - TODO
		if (false) {
			if ($.querySelectorAll( 'form[role=search] input[type=search]' ).length) {

				[].forEach.call(
					$.querySelectorAll( 'form[role=search] input[type=search]' ),
					function (input) {

						if (input.classList.contains( 'husky-input' )) {
							return;// already defined
						}

						if (input.closest( 'form[role=search]' ).querySelector( 'input[type=submit]' )) {
							input.closest( 'form[role=search]' ).querySelector( 'input[type=submit]' ).remove();
						}

						let clone = input.cloneNode( true );// trick - reset theme actions
						input.insertAdjacentElement( 'afterend', clone );
						input.remove();

						new HuskyText( clone, data );
					}
				);

			}
		}
	})( document );
};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/color/js/html_types/color.js?ver=3.4.0 
"use strict";
function woof_init_colors() {
	// http://jsfiddle.net/jtbowden/xP2Ns/
	jQuery( '.woof_color_term' ).each(
		function () {

			var color = jQuery( this ).data( 'color' );
			var img   = jQuery( this ).data( 'img' );

			var bg = '';
			if (img && img.length > 0) {
				bg = 'background: url(' + img + ')';
			} else {
				bg = 'background:' + color + ' !important';
			}

			var span = jQuery( '<span style="' + bg + '" class="' + jQuery( this ).attr( 'type' ) + ' ' + jQuery( this ).attr( 'class' ) + '" title=""></span>' ).on( 'click', woof_color_do_check ).mousedown( woof_color_do_down ).mouseup( woof_color_do_up );
			if (jQuery( this ).is( ':checked' )) {
				span.addClass( 'checked' );
			}
			jQuery( this ).wrap( span ).hide();
			jQuery( this ).after( '<span class="woof_color_checked"></span>' );// for checking
		}
	);

	function woof_color_do_check() {
		var is_checked = false;
		var radio      = false;
		if (jQuery( this ).parents( ".woof_list_color" ).data( "type" ) == "radio") {
			radio = true;
		}
		if (radio) {
			var elements = jQuery( this ).parents( ".woof_list_color" ).find( ".woof_color_term" );
			jQuery( elements ).removeClass( 'checked' );
			jQuery( elements ).children().prop( "checked", false );
		}

		if (jQuery( this ).hasClass( 'checked' )) {
			jQuery( this ).removeClass( 'checked' );
			jQuery( this ).children().prop( "checked", false );
		} else {
			jQuery( this ).addClass( 'checked' );
			jQuery( this ).children().prop( "checked", true );
			is_checked = true;
		}

		woof_color_process_data( this, is_checked,radio );
	}

	function woof_color_do_down() {
		jQuery( this ).addClass( 'clicked' );
	}

	function woof_color_do_up() {
		jQuery( this ).removeClass( 'clicked' );
	}
}

function woof_color_process_data(_this, is_checked, radio) {
	var tax     = jQuery( _this ).find( 'input[type=checkbox]' ).data( 'tax' );
	var name    = jQuery( _this ).find( 'input[type=checkbox]' ).attr( 'name' );
	var term_id = jQuery( _this ).find( 'input[type=checkbox]' ).data( 'term-id' );
	woof_color_direct_search( term_id, name, tax, is_checked, radio );
}

function woof_color_direct_search(term_id, name, tax, is_checked, radio) {

	var values  = '';
	var checked = true;
	if (is_checked) {
		if ( ! radio) {
			if (tax in woof_current_values) {
				woof_current_values[tax] = woof_current_values[tax] + ',' + name;
			} else {
				woof_current_values[tax] = name;
			}
		} else {
			woof_current_values[tax] = name;
		}
		checked = true;
	} else {
		if ( ! radio) {
			values  = woof_current_values[tax];
			values  = values.split( ',' );
			var tmp = [];
			jQuery.each(
				values,
				function (index, value) {
					if (value != name) {
						tmp.push( value );
					}
				}
			);
			values = tmp;
			if (values.length) {
				woof_current_values[tax] = values.join( ',' );
			} else {
				delete woof_current_values[tax];
			}
		} else {
			delete woof_current_values[tax];
		}
		checked = false;
	}
	jQuery( '.woof_color_term_' + term_id ).attr( 'checked', checked );
	woof_ajax_page_num = 1;
	if (woof_autosubmit) {
		woof_submit_link( woof_get_submit_link() );
	}
};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/image/js/html_types/image.js?ver=3.4.0 
"use strict";
function woof_init_image() {
	// http://jsfiddle.net/jtbowden/xP2Ns/
	jQuery( '.woof_image_term' ).each(
		function () {
			var image  = jQuery( this ).data( 'image' );
			var styles = jQuery( this ).data( 'styles' );
			if (image.length > 0) {
				styles += '; background-image: url(' + image + '); ';
			} else {
				styles += '; background-color: #ffffff;';
			}

			var span = jQuery( '<span style="' + styles + '" class="' + jQuery( this ).attr( 'type' ) + ' ' + jQuery( this ).attr( 'class' ) + '" title=""></span>' ).on( 'click',woof_image_do_check ).mousedown( woof_image_do_down ).mouseup( woof_image_do_up );
			if (jQuery( this ).is( ':checked' )) {
				span.addClass( 'checked' );
			}
			jQuery( this ).wrap( span ).hide();
			jQuery( this ).after( '<span class="woof_image_checked"></span>' );// for checking
		}
	);

	function woof_image_do_check() {
		var is_checked = false;
		var radio      = false;
		if (jQuery( this ).parents( ".woof_list_image" ).data( "type" ) == "radio") {
			radio = true;
		}
		if (radio) {
			var elements = jQuery( this ).parents( ".woof_list_image" ).find( ".woof_image_term" );
			jQuery( elements ).removeClass( 'checked' );
			jQuery( elements ).children().prop( "checked", false );
		}

		if (jQuery( this ).hasClass( 'checked' )) {
			jQuery( this ).removeClass( 'checked' );
			jQuery( this ).children().prop( "checked", false );
		} else {
			jQuery( this ).addClass( 'checked' );
			jQuery( this ).children().prop( "checked", true );
			is_checked = true;
		}

		woof_image_process_data( this, is_checked,radio );
	}

	function woof_image_do_down() {
		jQuery( this ).addClass( 'clicked' );
	}

	function woof_image_do_up() {
		jQuery( this ).removeClass( 'clicked' );
	}
}

function woof_image_process_data(_this, is_checked,radio) {
	var tax     = jQuery( _this ).find( 'input[type=checkbox]' ).data( 'tax' );
	var name    = jQuery( _this ).find( 'input[type=checkbox]' ).attr( 'name' );
	var term_id = jQuery( _this ).find( 'input[type=checkbox]' ).data( 'term-id' );
	woof_image_direct_search( term_id, name, tax, is_checked,radio );
}

function woof_image_direct_search(term_id, name, tax, is_checked,radio) {

	var values  = '';
	var checked = true;
	if (is_checked) {
		if ( ! radio) {
			if (tax in woof_current_values) {
				woof_current_values[tax] = woof_current_values[tax] + ',' + name;
			} else {
				woof_current_values[tax] = name;
			}
		} else {
			woof_current_values[tax] = name;
		}

		checked = true;
	} else {
		if ( ! radio) {
			values  = woof_current_values[tax];
			values  = values.split( ',' );
			var tmp = [];
			jQuery.each(
				values,
				function (index, value) {
					if (value != name) {
						tmp.push( value );
					}
				}
			);
			values = tmp;
			if (values.length) {
				woof_current_values[tax] = values.join( ',' );
			} else {
				delete woof_current_values[tax];
			}
		} else {
			delete woof_current_values[tax];
		}

		checked = false;
	}
	jQuery( '.woof_image_term_' + term_id ).attr( 'checked', checked );
	woof_ajax_page_num = 1;
	if (woof_autosubmit) {
		woof_submit_link( woof_get_submit_link() );
	}
};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/label/js/html_types/label.js?ver=3.4.0 
"use strict";
function woof_init_labels() {
	jQuery( '.woof_label_term' ).on(
		'click',
		function () {

			var checkbox = jQuery( this ).find( 'input.woof_label_term' ).eq( 0 );

			if (jQuery( checkbox ).is( ':checked' )) {
				jQuery( checkbox ).attr( "checked", false );
				jQuery( this ).removeClass( "checked" );
				woof_label_process_data( checkbox, false );
			} else {
				jQuery( checkbox ).attr( "checked", true );
				jQuery( this ).addClass( "checked" );
				woof_label_process_data( checkbox, true );
			}
		}
	);
}
function woof_label_process_data(_this, is_checked) {
	var tax     = jQuery( _this ).data( 'tax' );
	var name    = jQuery( _this ).attr( 'name' );
	var term_id = jQuery( _this ).data( 'term-id' );
	woof_label_direct_search( term_id, name, tax, is_checked );
}
function woof_label_direct_search(term_id, name, tax, is_checked) {
	var values  = '';
	var checked = true;
	if (is_checked) {
		if (tax in woof_current_values) {
			woof_current_values[tax] = woof_current_values[tax] + ',' + name;
		} else {
			woof_current_values[tax] = name;
		}
		checked = true;
	} else {
		values  = woof_current_values[tax];
		values  = values.split( ',' );
		var tmp = [];
		jQuery.each(
			values,
			function (index, value) {
				if (value != name) {
					tmp.push( value );
				}
			}
		);
		values = tmp;
		if (values.length) {
			woof_current_values[tax] = values.join( ',' );
		} else {
			delete woof_current_values[tax];
		}
		checked = false;
	}
	jQuery( '.woof_label_term_' + term_id ).attr( 'checked', checked );
	woof_ajax_page_num = 1;
	if (woof_autosubmit) {
		woof_submit_link( woof_get_submit_link() );
	}
};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/sections/js/sections.js?ver=3.4.0 
"use strict";
function woof_sections_html_items() {

    var sections = jQuery('.woof_section_tab');
    var request = woof_current_values.replace(/(\\)/, '');
    request = JSON.parse(request);

    jQuery.each(sections, function (e, item) {
        var _this = this;
        jQuery.each(request, function (k, val) {

            var selected = jQuery(_this).find(".woof_container_" + k);
            if (jQuery(selected).length) {
                if (!jQuery(_this).prev('label').prev("input:checked").length) {
                    jQuery(_this).prev('label').trigger('click');
                }

            }
        });


    });
    
    woof_sections_check_empty_items();

}

function woof_sections_check_empty_items(){
    var sections = jQuery('.woof_section_tab');
    jQuery.each(sections, function (e, item) {
	setTimeout(function(){ 	 
	    var filters = jQuery(item).find('.woof_container');
	    var hidden_filter = 0;
	    jQuery.each(filters, function (e, filter) {
		if (jQuery(filter).is(":hidden")){
		    hidden_filter++;
		}
	    });
	    if(filters.length == hidden_filter || filters.length == 0){
		jQuery(item).prev('.woof_section_tab_label').hide();
		jQuery(item).hide();
	    }
	}, 1500);	

    });
}
document.addEventListener('woof-ajax-form-redrawing', (e) => {     
    woof_sections_check_empty_items();
});

woof_sections_html_items();
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/select_hierarchy/js/html_types/select_hierarchy.js?ver=3.4.0 
"use strict";
function woof_init_select_hierarchy() {

};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/select_radio_check/js/html_types/select_radio_check.js?ver=3.4.0 
"use strict";

jQuery(function ($) {
    $(document).on('click', function (e) {
        if (!$(e.target).parents().hasClass("woof_select_radio_check")) {
            $(".woof_select_radio_check dd ul").hide(200);
            $(".woof_select_radio_check_opened").removeClass('woof_select_radio_check_opened');
        }
    });
});


function woof_init_select_radio_check() {
    jQuery(".woof_select_radio_check dt a.woof_select_radio_check_opener").on('click', function () {
        var _this = this;
        jQuery.each(jQuery(".woof_select_radio_check_opener"), function (i, sel) {
            if (sel !== _this) {
                jQuery(this).parents('.woof_select_radio_check').find("dd ul").hide();
                jQuery(this).parents('.woof_select_radio_check').find('.woof_select_radio_check_opened').removeClass('woof_select_radio_check_opened');
            }
        });


        //+++
        jQuery(this).parents('.woof_select_radio_check').find("dd ul").slideToggle(200);
        if (jQuery(this).parent().hasClass('woof_select_radio_check_opened')) {
            jQuery(this).parent().removeClass('woof_select_radio_check_opened');
        } else {
            jQuery(this).parent().addClass('woof_select_radio_check_opened');
        }
    });

    //+++

    if (Object.keys(woof_current_values).length > 0) {
        jQuery.each(woof_current_values, function (index, value) {

            if (!jQuery('.woof_hida_' + index).length) {
                return;
            }

            value = value.toString().trim();
            if (value.search(',')) {
                value = value.split(',');
            }
            //+++
            var txt_results = new Array();
            var v_results = new Array();
            jQuery.each(value, function (i, v) {
                var txt = v;
                var is_in_custom = false;
                if (Object.keys(woof_lang_custom).length > 0) {
                    jQuery.each(woof_lang_custom, function (i, tt) {
                        if (i == index) {
                            is_in_custom = true;
                            txt = tt;
                        }
                    });
                }

                if (!is_in_custom) {
                    try {
                        txt = jQuery("input[data-anchor='woof_n_" + index + '_' + v + "']").val();
                    } catch (e) {
                        console.log(e);
                    }

                    if (typeof txt === 'undefined')
                    {
                        txt = v;
                    }
                }

                txt_results.push(txt);
                v_results.push(v);

            });

            if (txt_results.length) {
                jQuery('.woof_hida_' + index).addClass('woof_hida_small');
                jQuery('.woof_hida_' + index).html('<div class="woof_products_top_panel2"></div>');
                var panel = jQuery('.woof_hida_' + index).find('.woof_products_top_panel2');
                panel.show();
                panel.html('<ul></ul>');
                jQuery.each(txt_results, function (i, txt) {
                    panel.find('ul').append(
                            jQuery('<li>').append(
                            jQuery('<a>').attr('href', "").attr('data-tax', index).attr('data-slug', v_results[i]).append(
                            jQuery('<span>').attr('class', 'woof_remove_ppi').append(txt)
                            )));
                });

            } else {
                jQuery('.woof_hida_' + index).removeClass('woof_hida_small');
                jQuery('.woof_hida_' + index).html(jQuery('.woof_hida_' + index).data('title'));
            }

        });

    }

    //***

    jQuery.each(jQuery('.woof_mutliSelect'), function (i, txt) {
        if (parseInt(jQuery(this).data('height'), 10) > 0) {
            jQuery(this).find('ul.woof_list:first-child').eq(0).css('max-height', jQuery(this).data('height'));
        } else {
            jQuery(this).find('ul.woof_list:first-child').eq(0).css('max-height', 100);
        }
    });


};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/slider/js/html_types/slider.js?ver=3.4.0 
"use strict";
function woof_init_sliders() {
    jQuery.each(jQuery('.woof_taxrange_slider'), function (index, input) {
	
      try {	    
	    var slags = jQuery(input).data('slags').split(',');
	    var type = jQuery(input).data('type');
            var tax = jQuery(input).data('tax');
	    var skin = jQuery(input).data('skin');
            var current = String(jQuery(input).data('current')).split(',');
            var from_index = 0, to_index = slags.length - 1;

            //***
            if (current.length > 0 && slags.length > 0) {
                jQuery.each(slags, function (index, v) {
                    if (v.toLowerCase() == current[0].toLowerCase()) {
                        from_index = index;
                    }
                    if (v.toLowerCase() == current[current.length - 1].toLowerCase()) {
                        to_index = index;
                    }
                });
            } else {
                to_index = parseInt(jQuery(input).data('max'), 10) - 1;
            }
	    
	    if (jQuery(input).data('current') && slags.length > 0 && 'single' == type) {
		from_index = to_index;
		to_index = 0;
	    }
	    

            jQuery(input).ionRangeSlider({
                decorate_both: false,
                values_separator: "",
                from: from_index,
                to: to_index,
                //min_interval: 1,
                //type: 'double',
		type: type,
                prefix: '',
                postfix: '',
                prettify: true,
                hideMinMax: false,
                hideFromTo: false,
                grid: true,
                step: 1,
                onFinish: function (ui) {
                    //*** range
		    if ('single' == type) {
			woof_current_values[tax] = (slags.slice(0, ui.from+1)).join(',');
		    } else {
			woof_current_values[tax] = (slags.slice(ui.from, ui.to + 1)).join(',');
		    }
                    
		    
                    woof_ajax_page_num = 1;
                    if (woof_autosubmit) {
                        woof_submit_link(woof_get_submit_link());
                    }

                    woof_update_tax_slider(input);
                    return false;
                },
                onChange: function (ui) {
		       
                    woof_update_tax_slider(input);
                },
                onRedraw: function (ui) {
		    woof_update_tax_slider(input);
                }
            });

            woof_update_tax_slider(input);

        } catch (e) {

        }
    });

    //***

    jQuery('.woof_hide_slider').parent('.woof_block_html_items').parent('.woof_container_inner').parent('.woof_container_slider').remove();
}



function woof_update_tax_slider( input) {

    var step = 1;

    if (jQuery(input).data('grid_step') != undefined) {
        step = parseInt(jQuery(input).data('grid_step'));
        if (step == 0) {
            return false;
        }
    }
    var lbls = jQuery(input).prev('span').find(".irs-grid-text");
    var i = 0;
    for (i = 1; i < jQuery(lbls).length - 1; i++) {

        if (i % step == 0 && step != -1) {
            jQuery(lbls[i]).css('visibility', 'visible');
        } else {
            jQuery(lbls[i]).css('visibility', 'hidden');
        }

    }

};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/ext/smart_designer/js/front.js?ver=3.4.0 
document.addEventListener('woof_init_search_form', function () {
    woof_sd_slide_list();
});

function woof_sd_slide_list() {
    if (woof_checkboxes_slide_flag) {
        let childs = jQuery('.woof-sd-ie-childs');

        if (childs.length) {
            jQuery.each(childs, function (index, child) {
                if (jQuery(child).parents('.woof_no_close_childs').length) {
                    return;
                }

                let span_class = 'woof_is_closed';

                if (woof_supports_html5_storage()) {
                    let preulstate = localStorage.getItem(
                        jQuery(child).prev().attr('class')
                    );

                    if (preulstate && preulstate === 'woof_is_opened') {
                        span_class = 'woof_is_opened';
                        jQuery(child).show();
                    } else {
                        if (
                            jQuery(child)
                                .find('input[type=checkbox],input[type=radio]')
                                .is(':checked')
                        ) {
                            jQuery(child).show();
                            span_class = 'woof_is_opened';
                        } else {
                            jQuery(child).hide();
                        }
                    }
                }

                jQuery(child)
                    .prev()
                    .find('woof-sd-list-opener')
                    .html(
                        '<a href="javascript:void(0);" rel="nofollow" class="woof_childs_list_opener" ><span class="' +
                            span_class +
                            '"></span></a>'
                    );
            });

            jQuery.each(
                jQuery('woof-sd-list-opener a.woof_childs_list_opener span'),
                function (index, a) {
                    jQuery(a).on('click', function () {
                        let span = jQuery(this);
                        let this_ = span.parent();

                        if (span.hasClass('woof_is_closed')) {
                            //lets open
                            jQuery(this_)
                                .closest('.woof-sd-ie')
                                .next()
                                .show(333);
                            span.removeClass('woof_is_closed');
                            span.addClass('woof_is_opened');
                        } else {
                            //lets close
                            jQuery(this_)
                                .closest('.woof-sd-ie')
                                .next()
                                .hide(333);
                            span.removeClass('woof_is_opened');
                            span.addClass('woof_is_closed');
                        }

                        if (woof_supports_html5_storage()) {
                            let ullabel = jQuery(this_)
                                .closest('.woof-sd-ie')
                                .attr('class');
                            let ullstate = jQuery(this_)
                                .children('span')
                                .attr('class');
                            localStorage.setItem(ullabel, ullstate);
                        }

                        return false;
                    });
                }
            );
        }
    }
};
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce-products-filter/js/chosen/chosen.jquery.js?ver=3.4.0 
/*!
Chosen, a Select Box Enhancer for jQuery and Prototype
by Patrick Filler for Harvest, http://getharvest.com

Version WOOF Custom
Full source at https://github.com/harvesthq/chosen
Copyright (c) Harvest http://getharvest.com

MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
This file is generated by `grunt build`, do not edit it by hand.
*/

"use strict";

(function() {
  var $, AbstractChosen, Chosen, SelectParser,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  SelectParser = (function() {
    function SelectParser() {
      this.options_index = 0;
      this.parsed = [];
    }

    SelectParser.prototype.add_node = function(child) {
      if (child.nodeName.toUpperCase() === "OPTGROUP") {
        return this.add_group(child);
      } else {
        return this.add_option(child);
      }
    };

    SelectParser.prototype.add_group = function(group) {
      var group_position, i, len, option, ref, results1;
      group_position = this.parsed.length;
      this.parsed.push({
        array_index: group_position,
        group: true,
        label: group.label,
        title: group.title ? group.title : void 0,
        children: 0,
        disabled: group.disabled,
        classes: group.className
      });
      ref = group.childNodes;
      results1 = [];
      for (i = 0, len = ref.length; i < len; i++) {
        option = ref[i];
        results1.push(this.add_option(option, group_position, group.disabled));
      }
      return results1;
    };

    SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
      if (option.nodeName.toUpperCase() === "OPTION") {
        if (option.text !== "") {
          if (group_position != null) {
            this.parsed[group_position].children += 1;
          }
          this.parsed.push({
            array_index: this.parsed.length,
            options_index: this.options_index,
            value: option.value,
            text: option.text,
            html: option.innerHTML,
            title: option.title ? option.title : void 0,
            selected: option.selected,
            disabled: group_disabled === true ? group_disabled : option.disabled,
            group_array_index: group_position,
            group_label: group_position != null ? this.parsed[group_position].label : null,
            classes: option.className,
            style: option.style.cssText
          });
        } else {
          this.parsed.push({
            array_index: this.parsed.length,
            options_index: this.options_index,
            empty: true
          });
        }
        return this.options_index += 1;
      }
    };

    return SelectParser;

  })();

  SelectParser.select_to_array = function(select) {
    var child, i, len, parser, ref;
    parser = new SelectParser();
    ref = select.childNodes;
    for (i = 0, len = ref.length; i < len; i++) {
      child = ref[i];
      parser.add_node(child);
    }
    return parser.parsed;
  };

  AbstractChosen = (function() {
    function AbstractChosen(form_field, options1) {
      this.form_field = form_field;
      this.options = options1 != null ? options1 : {};
      this.label_click_handler = bind(this.label_click_handler, this);
      if (!AbstractChosen.browser_is_supported()) {
        return;
      }
      this.is_multiple = this.form_field.multiple;
      this.set_default_text();
      this.set_default_values();
      this.setup();
      this.set_up_html();
      this.register_observers();
      this.on_ready();
    }

    AbstractChosen.prototype.set_default_values = function() {
      this.click_test_action = (function(_this) {
        return function(evt) {
          return _this.test_active_click(evt);
        };
      })(this);
      this.activate_action = (function(_this) {
        return function(evt) {
          return _this.activate_field(evt);
        };
      })(this);
      this.active_field = false;
      this.mouse_on_container = false;
      this.results_showing = false;
      this.result_highlighted = null;
      this.is_rtl = this.options.rtl || /\bchosen-rtl\b/.test(this.form_field.className);
      this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
      this.disable_search_threshold = this.options.disable_search_threshold || 0;
      this.disable_search = this.options.disable_search || false;
      this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
      this.group_search = this.options.group_search != null ? this.options.group_search : true;
      this.search_contains = this.options.search_contains || false;
      this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true;
      this.max_selected_options = this.options.max_selected_options || Infinity;
      this.inherit_select_classes = this.options.inherit_select_classes || false;
      this.display_selected_options = this.options.display_selected_options != null ? this.options.display_selected_options : true;
      this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true;
      this.include_group_label_in_selected = this.options.include_group_label_in_selected || false;
      this.max_shown_results = this.options.max_shown_results || Number.POSITIVE_INFINITY;
      this.case_sensitive_search = this.options.case_sensitive_search || false;
      return this.hide_results_on_select = this.options.hide_results_on_select != null ? this.options.hide_results_on_select : true;
    };

    AbstractChosen.prototype.set_default_text = function() {
      if (this.form_field.getAttribute("data-placeholder")) {
        this.default_text = this.form_field.getAttribute("data-placeholder");
      } else if (this.is_multiple) {
        this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text;
      } else {
        this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
      }
      this.default_text = this.escape_html(this.default_text);
      return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
    };

    AbstractChosen.prototype.choice_label = function(item) {
      if (this.include_group_label_in_selected && (item.group_label != null)) {
        return "<b class='group-name'>" + (this.escape_html(item.group_label)) + "</b>" + item.html;
      } else {
        return item.html;
      }
    };

    AbstractChosen.prototype.mouse_enter = function() {
      return this.mouse_on_container = true;
    };

    AbstractChosen.prototype.mouse_leave = function() {
      return this.mouse_on_container = false;
    };

    AbstractChosen.prototype.input_focus = function(evt) {
      if (this.is_multiple) {
        if (!this.active_field) {
          return setTimeout(((function(_this) {
            return function() {
              return _this.container_mousedown();
            };
          })(this)), 50);
        }
      } else {
        if (!this.active_field) {
          return this.activate_field();
        }
      }
    };

    AbstractChosen.prototype.input_blur = function(evt) {
      if (!this.mouse_on_container) {
        this.active_field = false;
        return setTimeout(((function(_this) {
          return function() {
            return _this.blur_test();
          };
        })(this)), 100);
      }
    };

    AbstractChosen.prototype.label_click_handler = function(evt) {
      if (this.is_multiple) {
        return this.container_mousedown(evt);
      } else {
        return this.activate_field();
      }
    };

    AbstractChosen.prototype.results_option_build = function(options) {
      var content, data, data_content, i, len, ref, shown_results;
      content = '';
      shown_results = 0;
      ref = this.results_data;
      for (i = 0, len = ref.length; i < len; i++) {
        data = ref[i];
        data_content = '';
        if (data.group) {
          data_content = this.result_add_group(data);
        } else {
          data_content = this.result_add_option(data);
        }
        if (data_content !== '') {
          shown_results++;
          content += data_content;
        }
        if (options != null ? options.first : void 0) {
          if (data.selected && this.is_multiple) {
            this.choice_build(data);
          } else if (data.selected && !this.is_multiple) {
            this.single_set_selected_text(this.choice_label(data));
          }
        }
        if (shown_results >= this.max_shown_results) {
          break;
        }
      }
      return content;
    };

    AbstractChosen.prototype.result_add_option = function(option) {
      var classes, option_el;
      if (!option.search_match) {
        return '';
      }
      if (!this.include_option_in_results(option)) {
        return '';
      }
      classes = [];
      if (!option.disabled && !(option.selected && this.is_multiple)) {
        classes.push("active-result");
      }
      if (option.disabled && !(option.selected && this.is_multiple)) {
        classes.push("disabled-result");
      }
      if (option.selected) {
        classes.push("result-selected");
      }
      if (option.group_array_index != null) {
        classes.push("group-option");
      }
      if (option.classes !== "") {
        classes.push(option.classes);
      }
      option_el = document.createElement("li");
      option_el.className = classes.join(" ");
      if (option.style) {
        option_el.style.cssText = option.style;
      }
      option_el.setAttribute("data-option-array-index", option.array_index);
      option_el.innerHTML = option.highlighted_html || option.html;
      if (option.title) {
        option_el.title = option.title;
      }
      return this.outerHTML(option_el);
    };

    AbstractChosen.prototype.result_add_group = function(group) {
      var classes, group_el;
      if (!(group.search_match || group.group_match)) {
        return '';
      }
      if (!(group.active_options > 0)) {
        return '';
      }
      classes = [];
      classes.push("group-result");
      if (group.classes) {
        classes.push(group.classes);
      }
      group_el = document.createElement("li");
      group_el.className = classes.join(" ");
      group_el.innerHTML = group.highlighted_html || this.escape_html(group.label);
      if (group.title) {
        group_el.title = group.title;
      }
      return this.outerHTML(group_el);
    };

    AbstractChosen.prototype.results_update_field = function() {
      this.set_default_text();
      if (!this.is_multiple) {
        this.results_reset_cleanup();
      }
      this.result_clear_highlight();
      this.results_build();
      if (this.results_showing) {
        return this.winnow_results();
      }
    };

    AbstractChosen.prototype.reset_single_select_options = function() {
      var i, len, ref, result, results1;
      ref = this.results_data;
      results1 = [];
      for (i = 0, len = ref.length; i < len; i++) {
        result = ref[i];
        if (result.selected) {
          results1.push(result.selected = false);
        } else {
          results1.push(void 0);
        }
      }
      return results1;
    };

    AbstractChosen.prototype.results_toggle = function() {
      if (this.results_showing) {
        return this.results_hide();
      } else {
        return this.results_show();
      }
    };

    AbstractChosen.prototype.results_search = function(evt) {
      if (this.results_showing) {
        return this.winnow_results();
      } else {
        return this.results_show();
      }
    };

    AbstractChosen.prototype.winnow_results = function(options) {
      var escapedQuery, fix, i, len, option, prefix, query, ref, regex, results, results_group, search_match, startpos, suffix, text;
      this.no_results_clear();
      results = 0;
      query = this.get_search_text();
      escapedQuery = query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
      regex = this.get_search_regex(escapedQuery);
      ref = this.results_data;
      for (i = 0, len = ref.length; i < len; i++) {
        option = ref[i];
        option.search_match = false;
        results_group = null;
        search_match = null;
        option.highlighted_html = '';
        if (this.include_option_in_results(option)) {
          if (option.group) {
            option.group_match = false;
            option.active_options = 0;
          }
          if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
            results_group = this.results_data[option.group_array_index];
            if (results_group.active_options === 0 && results_group.search_match) {
              results += 1;
            }
            results_group.active_options += 1;
          }
          text = option.group ? option.label : option.text;
          if (!(option.group && !this.group_search)) {
            search_match = this.search_string_match(text, regex);
            option.search_match = search_match != null;
            if (option.search_match && !option.group) {
              results += 1;
            }
            if (option.search_match) {
              if (query.length) {
                startpos = search_match.index;
                prefix = text.slice(0, startpos);
                fix = text.slice(startpos, startpos + query.length);
                suffix = text.slice(startpos + query.length);
                option.highlighted_html = (this.escape_html(prefix)) + "<em>" + (this.escape_html(fix)) + "</em>" + (this.escape_html(suffix));
              }
              if (results_group != null) {
                results_group.group_match = true;
              }
            } else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) {
              option.search_match = true;
            }
          }
        }
      }
      this.result_clear_highlight();
      if (results < 1 && query.length) {
        this.update_results_content("");
        return this.no_results(query);
      } else {
        this.update_results_content(this.results_option_build());
        if (!(options != null ? options.skip_highlight : void 0)) {
          return this.winnow_results_set_highlight();
        }
      }
    };

    AbstractChosen.prototype.get_search_regex = function(escaped_search_string) {
      var regex_flag, regex_string;
      regex_string = this.search_contains ? escaped_search_string : "(^|\\s|\\b)" + escaped_search_string + "[^\\s]*";
      if (!(this.enable_split_word_search || this.search_contains)) {
        regex_string = "^" + regex_string;
      }
      regex_flag = this.case_sensitive_search ? "" : "i";
      return new RegExp(regex_string, regex_flag);
    };

    AbstractChosen.prototype.search_string_match = function(search_string, regex) {
      var match;
      match = regex.exec(search_string);
      if (!this.search_contains && (match != null ? match[1] : void 0)) {
        match.index += 1;
      }
      return match;
    };

    AbstractChosen.prototype.choices_count = function() {
      var i, len, option, ref;
      if (this.selected_option_count != null) {
        return this.selected_option_count;
      }
      this.selected_option_count = 0;
      ref = this.form_field.options;
      for (i = 0, len = ref.length; i < len; i++) {
        option = ref[i];
        if (option.selected) {
          this.selected_option_count += 1;
        }
      }
      return this.selected_option_count;
    };

    AbstractChosen.prototype.choices_click = function(evt) {
      evt.preventDefault();
      this.activate_field();
      if (!(this.results_showing || this.is_disabled)) {
        return this.results_show();
      }
    };

    AbstractChosen.prototype.keydown_checker = function(evt) {
      var ref, stroke;
      stroke = (ref = evt.which) != null ? ref : evt.keyCode;
      this.search_field_scale();
      if (stroke !== 8 && this.pending_backstroke) {
        this.clear_backstroke();
      }
      switch (stroke) {
        case 8:
          this.backstroke_length = this.get_search_field_value().length;
          break;
        case 9:
          if (this.results_showing && !this.is_multiple) {
            this.result_select(evt);
          }
          this.mouse_on_container = false;
          break;
        case 13:
          if (this.results_showing) {
            evt.preventDefault();
          }
          break;
        case 27:
          if (this.results_showing) {
            evt.preventDefault();
          }
          break;
        case 32:
          if (this.disable_search) {
            evt.preventDefault();
          }
          break;
        case 38:
          evt.preventDefault();
          this.keyup_arrow();
          break;
        case 40:
          evt.preventDefault();
          this.keydown_arrow();
          break;
      }
    };

    AbstractChosen.prototype.keyup_checker = function(evt) {
      var ref, stroke;
      stroke = (ref = evt.which) != null ? ref : evt.keyCode;
      this.search_field_scale();
      switch (stroke) {
        case 8:
          if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
            this.keydown_backstroke();
          } else if (!this.pending_backstroke) {
            this.result_clear_highlight();
            this.results_search();
          }
          break;
        case 13:
          evt.preventDefault();
          if (this.results_showing) {
            this.result_select(evt);
          }
          break;
        case 27:
          if (this.results_showing) {
            this.results_hide();
          }
          break;
        case 9:
        case 16:
        case 17:
        case 18:
        case 38:
        case 40:
        case 91:
          break;
        default:
          this.results_search();
          break;
      }
    };

    AbstractChosen.prototype.clipboard_event_checker = function(evt) {
      if (this.is_disabled) {
        return;
      }
      return setTimeout(((function(_this) {
        return function() {
          return _this.results_search();
        };
      })(this)), 50);
    };

    AbstractChosen.prototype.container_width = function() {
      if (this.options.width != null) {
        return this.options.width;
      } else {
        return this.form_field.offsetWidth + "px";
      }
    };

    AbstractChosen.prototype.include_option_in_results = function(option) {
      if (this.is_multiple && (!this.display_selected_options && option.selected)) {
        return false;
      }
      if (!this.display_disabled_options && option.disabled) {
        return false;
      }
      if (option.empty) {
        return false;
      }
      return true;
    };

    AbstractChosen.prototype.search_results_touchstart = function(evt) {
      this.touch_started = true;
      return this.search_results_mouseover(evt);
    };

    AbstractChosen.prototype.search_results_touchmove = function(evt) {
      this.touch_started = false;
      return this.search_results_mouseout(evt);
    };

    AbstractChosen.prototype.search_results_touchend = function(evt) {
      if (this.touch_started) {
        return this.search_results_mouseup(evt);
      }
    };

    AbstractChosen.prototype.outerHTML = function(element) {
      var tmp;
      if (element.outerHTML) {
        return element.outerHTML;
      }
      tmp = document.createElement("div");
      tmp.appendChild(element);
      return tmp.innerHTML;
    };

    AbstractChosen.prototype.get_single_html = function() {
      return "<a class=\"chosen-single chosen-default\">\n  <span>" + this.default_text + "</span>\n  <div><b></b></div>\n</a>\n<div class=\"chosen-drop\">\n  <div class=\"chosen-search\">\n    <input class=\"chosen-search-input\" type=\"text\" autocomplete=\"off\" />\n  </div>\n  <ul class=\"chosen-results\"></ul>\n</div>";
    };

    AbstractChosen.prototype.get_multi_html = function() {
      return "<ul class=\"chosen-choices\">\n  <li class=\"search-field\">\n    <input class=\"chosen-search-input\" type=\"text\" autocomplete=\"off\" value=\"" + this.default_text + "\" />\n  </li>\n</ul>\n<div class=\"chosen-drop\">\n  <ul class=\"chosen-results\"></ul>\n</div>";
    };

    AbstractChosen.prototype.get_no_results_html = function(terms) {
      return "<li class=\"no-results\">\n  " + this.results_none_found + " <span>" + (this.escape_html(terms)) + "</span>\n</li>";
    };

    AbstractChosen.browser_is_supported = function() {
      if ("Microsoft Internet Explorer" === window.navigator.appName) {
        return document.documentMode >= 8;
      }
      if (/iP(od|hone)/i.test(window.navigator.userAgent) || /IEMobile/i.test(window.navigator.userAgent) || /Windows Phone/i.test(window.navigator.userAgent) || /BlackBerry/i.test(window.navigator.userAgent) || /BB10/i.test(window.navigator.userAgent) || /Android.*Mobile/i.test(window.navigator.userAgent)) {
        //return false;
      }
      return true;
    };

    AbstractChosen.default_multiple_text = "Select Some Options";

    AbstractChosen.default_single_text = "Select an Option";

    AbstractChosen.default_no_result_text = "No results match";

    return AbstractChosen;

  })();

  $ = jQuery;

  $.fn.extend({
    chosen: function(options) {
      if (!AbstractChosen.browser_is_supported()) {
        return this;
      }
      return this.each(function(input_field) {
        var $this, chosen;
        $this = $(this);
        chosen = $this.data('chosen');
        if (options === 'destroy') {
          if (chosen instanceof Chosen) {
            chosen.destroy();
          }
          return;
        }
        if (!(chosen instanceof Chosen)) {
          $this.data('chosen', new Chosen(this, options));
        }
      });
    }
  });

  Chosen = (function(superClass) {
    extend(Chosen, superClass);

    function Chosen() {
      return Chosen.__super__.constructor.apply(this, arguments);
    }

    Chosen.prototype.setup = function() {
      this.form_field_jq = $(this.form_field);
      return this.current_selectedIndex = this.form_field.selectedIndex;
    };

    Chosen.prototype.set_up_html = function() {
      var container_classes, container_props;
      container_classes = ["chosen-container"];
      container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
      if (this.inherit_select_classes && this.form_field.className) {
        container_classes.push(this.form_field.className);
      }
      if (this.is_rtl) {
        container_classes.push("chosen-rtl");
      }
      container_props = {
        'class': container_classes.join(' '),
        'title': this.form_field.title
      };
      if (this.form_field.id.length) {
        container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
      }
      this.container = $("<div />", container_props);
      this.container.width(this.container_width());
      if (this.is_multiple) {
        this.container.html(this.get_multi_html());
      } else {
        this.container.html(this.get_single_html());
      }
      this.form_field_jq.hide().after(this.container);
      this.dropdown = this.container.find('div.chosen-drop').first();
      this.search_field = this.container.find('input').first();
      this.search_results = this.container.find('ul.chosen-results').first();
      this.search_field_scale();
      this.search_no_results = this.container.find('li.no-results').first();
      if (this.is_multiple) {
        this.search_choices = this.container.find('ul.chosen-choices').first();
        this.search_container = this.container.find('li.search-field').first();
      } else {
        this.search_container = this.container.find('div.chosen-search').first();
        this.selected_item = this.container.find('.chosen-single').first();
      }
      this.results_build();
      this.set_tab_index();
      return this.set_label_behavior();
    };

    Chosen.prototype.on_ready = function() {
      return this.form_field_jq.trigger("chosen:ready", {
        chosen: this
      });
    };

    Chosen.prototype.register_observers = function() {
      this.container.on('touchstart.chosen', (function(_this) {
        return function(evt) {
          _this.container_mousedown(evt);
        };
      })(this));
      this.container.on('touchend.chosen', (function(_this) {
        return function(evt) {
          _this.container_mouseup(evt);
        };
      })(this));
      this.container.on('mousedown.chosen', (function(_this) {
        return function(evt) {
          _this.container_mousedown(evt);
        };
      })(this));
      this.container.on('mouseup.chosen', (function(_this) {
        return function(evt) {
          _this.container_mouseup(evt);
        };
      })(this));
      this.container.on('mouseenter.chosen', (function(_this) {
        return function(evt) {
          _this.mouse_enter(evt);
        };
      })(this));
      this.container.on('mouseleave.chosen', (function(_this) {
        return function(evt) {
          _this.mouse_leave(evt);
        };
      })(this));
      this.search_results.on('mouseup.chosen', (function(_this) {
        return function(evt) {
          _this.search_results_mouseup(evt);
        };
      })(this));
      this.search_results.on('mouseover.chosen', (function(_this) {
        return function(evt) {
          _this.search_results_mouseover(evt);
        };
      })(this));
      this.search_results.on('mouseout.chosen', (function(_this) {
        return function(evt) {
          _this.search_results_mouseout(evt);
        };
      })(this));
      this.search_results.on('mousewheel.chosen DOMMouseScroll.chosen', (function(_this) {
        return function(evt) {
          _this.search_results_mousewheel(evt);
        };
      })(this));
      this.search_results.on('touchstart.chosen', (function(_this) {
        return function(evt) {
          _this.search_results_touchstart(evt);
        };
      })(this));
      this.search_results.on('touchmove.chosen', (function(_this) {
        return function(evt) {
          _this.search_results_touchmove(evt);
        };
      })(this));
      this.search_results.on('touchend.chosen', (function(_this) {
        return function(evt) {
          _this.search_results_touchend(evt);
        };
      })(this));
      this.form_field_jq.on("chosen:updated.chosen", (function(_this) {
        return function(evt) {
          _this.results_update_field(evt);
        };
      })(this));
      this.form_field_jq.on("chosen:activate.chosen", (function(_this) {
        return function(evt) {
          _this.activate_field(evt);
        };
      })(this));
      this.form_field_jq.on("chosen:open.chosen", (function(_this) {
        return function(evt) {
          _this.container_mousedown(evt);
        };
      })(this));
      this.form_field_jq.on("chosen:close.chosen", (function(_this) {
        return function(evt) {
          _this.close_field(evt);
        };
      })(this));
      this.search_field.on('blur.chosen', (function(_this) {
        return function(evt) {
          _this.input_blur(evt);
        };
      })(this));
      this.search_field.on('keyup.chosen', (function(_this) {
        return function(evt) {
          _this.keyup_checker(evt);
        };
      })(this));
      this.search_field.on('keydown.chosen', (function(_this) {
        return function(evt) {
          _this.keydown_checker(evt);
        };
      })(this));
      this.search_field.on('focus.chosen', (function(_this) {
        return function(evt) {
          _this.input_focus(evt);
        };
      })(this));
      this.search_field.on('cut.chosen', (function(_this) {
        return function(evt) {
          _this.clipboard_event_checker(evt);
        };
      })(this));
      this.search_field.on('paste.chosen', (function(_this) {
        return function(evt) {
          _this.clipboard_event_checker(evt);
        };
      })(this));
      if (this.is_multiple) {
        return this.search_choices.on('click.chosen', (function(_this) {
          return function(evt) {
            _this.choices_click(evt);
          };
        })(this));
      } else {
        return this.container.on('click.chosen', function(evt) {
          evt.preventDefault();
        });
      }
    };

    Chosen.prototype.destroy = function() {
      $(this.container[0].ownerDocument).off('click.chosen', this.click_test_action);
      if (this.form_field_label.length > 0) {
        this.form_field_label.off('click.chosen');
      }
      if (this.search_field[0].tabIndex) {
        this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
      }
      this.container.remove();
      this.form_field_jq.removeData('chosen');
      return this.form_field_jq.show();
    };

    Chosen.prototype.search_field_disabled = function() {
      this.is_disabled = this.form_field.disabled || this.form_field_jq.parents('fieldset').is(':disabled');
      this.container.toggleClass('chosen-disabled', this.is_disabled);
      this.search_field[0].disabled = this.is_disabled;
      if (!this.is_multiple) {
        this.selected_item.off('focus.chosen', this.activate_field);
      }
      if (this.is_disabled) {
        return this.close_field();
      } else if (!this.is_multiple) {
        return this.selected_item.on('focus.chosen', this.activate_field);
      }
    };

    Chosen.prototype.container_mousedown = function(evt) {
      var ref;
      if (this.is_disabled) {
        return;
      }
      if (evt && ((ref = evt.type) === 'mousedown' || ref === 'touchstart') && !this.results_showing) {
        evt.preventDefault();
      }
      if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
        if (!this.active_field) {
          if (this.is_multiple) {
            this.search_field.val("");
          }
          $(this.container[0].ownerDocument).on('click.chosen', this.click_test_action);
          this.results_show();
        } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
          evt.preventDefault();
          this.results_toggle();
        }
        return this.activate_field();
      }
    };

    Chosen.prototype.container_mouseup = function(evt) {
      if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
        return this.results_reset(evt);
      }
    };

    Chosen.prototype.search_results_mousewheel = function(evt) {
      var delta;
      if (evt.originalEvent) {
        delta = evt.originalEvent.deltaY || -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
      }
      if (delta != null) {
        evt.preventDefault();
        if (evt.type === 'DOMMouseScroll') {
          delta = delta * 40;
        }
        return this.search_results.scrollTop(delta + this.search_results.scrollTop());
      }
    };

    Chosen.prototype.blur_test = function(evt) {
      if (!this.active_field && this.container.hasClass("chosen-container-active")) {
        return this.close_field();
      }
    };

    Chosen.prototype.close_field = function() {
      $(this.container[0].ownerDocument).off("click.chosen", this.click_test_action);
      this.active_field = false;
      this.results_hide();
      this.container.removeClass("chosen-container-active");
      this.clear_backstroke();
      this.show_search_field_default();
      this.search_field_scale();
      return this.search_field.blur();
    };

    Chosen.prototype.activate_field = function() {
      if (this.is_disabled) {
        return;
      }
      this.container.addClass("chosen-container-active");
      this.active_field = true;
      this.search_field.val(this.search_field.val());
      return this.search_field.focus();
    };

    Chosen.prototype.test_active_click = function(evt) {
      var active_container;
      active_container = $(evt.target).closest('.chosen-container');
      if (active_container.length && this.container[0] === active_container[0]) {
        return this.active_field = true;
      } else {
        return this.close_field();
      }
    };

    Chosen.prototype.results_build = function() {
      this.parsing = true;
      this.selected_option_count = null;
      this.results_data = SelectParser.select_to_array(this.form_field);
      if (this.is_multiple) {
        this.search_choices.find("li.search-choice").remove();
      } else {
        this.single_set_selected_text();
        if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
          this.search_field[0].readOnly = true;
          this.container.addClass("chosen-container-single-nosearch");
        } else {
          this.search_field[0].readOnly = false;
          this.container.removeClass("chosen-container-single-nosearch");
        }
      }
      this.update_results_content(this.results_option_build({
        first: true
      }));
      this.search_field_disabled();
      this.show_search_field_default();
      this.search_field_scale();
      return this.parsing = false;
    };

    Chosen.prototype.result_do_highlight = function(el) {
      var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
      if (el.length) {
        this.result_clear_highlight();
        this.result_highlight = el;
        this.result_highlight.addClass("highlighted");
        maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
        visible_top = this.search_results.scrollTop();
        visible_bottom = maxHeight + visible_top;
        high_top = this.result_highlight.position().top + this.search_results.scrollTop();
        high_bottom = high_top + this.result_highlight.outerHeight();
        if (high_bottom >= visible_bottom) {
          return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
        } else if (high_top < visible_top) {
          return this.search_results.scrollTop(high_top);
        }
      }
    };

    Chosen.prototype.result_clear_highlight = function() {
      if (this.result_highlight) {
        this.result_highlight.removeClass("highlighted");
      }
      return this.result_highlight = null;
    };

    Chosen.prototype.results_show = function() {
      if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
        this.form_field_jq.trigger("chosen:maxselected", {
          chosen: this
        });
        return false;
      }
      this.container.addClass("chosen-with-drop");
      this.results_showing = true;
      this.search_field.focus();
      this.search_field.val(this.get_search_field_value());
      this.winnow_results();
      return this.form_field_jq.trigger("chosen:showing_dropdown", {
        chosen: this
      });
    };

    Chosen.prototype.update_results_content = function(content) {
      return this.search_results.html(content);
    };

    Chosen.prototype.results_hide = function() {
      if (this.results_showing) {
        this.result_clear_highlight();
        this.container.removeClass("chosen-with-drop");
        this.form_field_jq.trigger("chosen:hiding_dropdown", {
          chosen: this
        });
      }
      return this.results_showing = false;
    };

    Chosen.prototype.set_tab_index = function(el) {
      var ti;
      if (this.form_field.tabIndex) {
        ti = this.form_field.tabIndex;
        this.form_field.tabIndex = -1;
        return this.search_field[0].tabIndex = ti;
      }
    };

    Chosen.prototype.set_label_behavior = function() {
      this.form_field_label = this.form_field_jq.parents("label");
      if (!this.form_field_label.length && this.form_field.id.length) {
        this.form_field_label = $("label[for='" + this.form_field.id + "']");
      }
      if (this.form_field_label.length > 0) {
        return this.form_field_label.on('click.chosen', this.label_click_handler);
      }
    };

    Chosen.prototype.show_search_field_default = function() {
      if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
        this.search_field.val(this.default_text);
        return this.search_field.addClass("default");
      } else {
        this.search_field.val("");
        return this.search_field.removeClass("default");
      }
    };

    Chosen.prototype.search_results_mouseup = function(evt) {
      var target;
      target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
      if (target.length) {
        this.result_highlight = target;
        this.result_select(evt);
        return this.search_field.focus();
      }
    };

    Chosen.prototype.search_results_mouseover = function(evt) {
      var target;
      target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
      if (target) {
        return this.result_do_highlight(target);
      }
    };

    Chosen.prototype.search_results_mouseout = function(evt) {
      if ($(evt.target).hasClass("active-result") || $(evt.target).parents('.active-result').first()) {
        return this.result_clear_highlight();
      }
    };

    Chosen.prototype.choice_build = function(item) {
      var choice, close_link;
      choice = $('<li />', {
        "class": "search-choice"
      }).html("<span>" + (this.choice_label(item)) + "</span>");
      if (item.disabled) {
        choice.addClass('search-choice-disabled');
      } else {
        close_link = $('<a />', {
          "class": 'search-choice-close',
          'data-option-array-index': item.array_index
        });
        close_link.on('click.chosen', (function(_this) {
          return function(evt) {
            return _this.choice_destroy_link_click(evt);
          };
        })(this));
        choice.append(close_link);
      }
      return this.search_container.before(choice);
    };

    Chosen.prototype.choice_destroy_link_click = function(evt) {
      evt.preventDefault();
      evt.stopPropagation();
      if (!this.is_disabled) {
        return this.choice_destroy($(evt.target));
      }
    };

    Chosen.prototype.choice_destroy = function(link) {
      if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) {
        if (this.active_field) {
          this.search_field.focus();
        } else {
          this.show_search_field_default();
        }
        if (this.is_multiple && this.choices_count() > 0 && this.get_search_field_value().length < 1) {
          this.results_hide();
        }
        link.parents('li').first().remove();
        return this.search_field_scale();
      }
    };

    Chosen.prototype.results_reset = function() {
      this.reset_single_select_options();
      this.form_field.options[0].selected = true;
      this.single_set_selected_text();
      this.show_search_field_default();
      this.results_reset_cleanup();
      this.trigger_form_field_change();
      if (this.active_field) {
        return this.results_hide();
      }
    };

    Chosen.prototype.results_reset_cleanup = function() {
      this.current_selectedIndex = this.form_field.selectedIndex;
      return this.selected_item.find("abbr").remove();
    };

    Chosen.prototype.result_select = function(evt) {
      var high, item;
      if (this.result_highlight) {
        high = this.result_highlight;
        this.result_clear_highlight();
        if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
          this.form_field_jq.trigger("chosen:maxselected", {
            chosen: this
          });
          return false;
        }
        if (this.is_multiple) {
          high.removeClass("active-result");
        } else {
          this.reset_single_select_options();
        }
        high.addClass("result-selected");
        item = this.results_data[high[0].getAttribute("data-option-array-index")];
        item.selected = true;
        this.form_field.options[item.options_index].selected = true;
        this.selected_option_count = null;
        if (this.is_multiple) {
          this.choice_build(item);
        } else {
          this.single_set_selected_text(this.choice_label(item));
        }
        if (this.is_multiple && (!this.hide_results_on_select || (evt.metaKey || evt.ctrlKey))) {
          if (evt.metaKey || evt.ctrlKey) {
            this.winnow_results({
              skip_highlight: true
            });
          } else {
            this.search_field.val("");
            this.winnow_results();
          }
        } else {
          this.results_hide();
          this.show_search_field_default();
        }
        if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
          this.trigger_form_field_change({
            selected: this.form_field.options[item.options_index].value
          });
        }
        this.current_selectedIndex = this.form_field.selectedIndex;
        evt.preventDefault();
        return this.search_field_scale();
      }
    };

    Chosen.prototype.single_set_selected_text = function(text) {
      if (text == null) {
        text = this.default_text;
      }
      if (text === this.default_text) {
        this.selected_item.addClass("chosen-default");
      } else {
        this.single_deselect_control_build();
        this.selected_item.removeClass("chosen-default");
      }
      return this.selected_item.find("span").html(text);
    };

    Chosen.prototype.result_deselect = function(pos) {
      var result_data;
      result_data = this.results_data[pos];
      if (!this.form_field.options[result_data.options_index].disabled) {
        result_data.selected = false;
        this.form_field.options[result_data.options_index].selected = false;
        this.selected_option_count = null;
        this.result_clear_highlight();
        if (this.results_showing) {
          this.winnow_results();
        }
        this.trigger_form_field_change({
          deselected: this.form_field.options[result_data.options_index].value
        });
        this.search_field_scale();
        return true;
      } else {
        return false;
      }
    };

    Chosen.prototype.single_deselect_control_build = function() {
      if (!this.allow_single_deselect) {
        return;
      }
      if (!this.selected_item.find("abbr").length) {
        this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
      }
      return this.selected_item.addClass("chosen-single-with-deselect");
    };

    Chosen.prototype.get_search_field_value = function() {
      return this.search_field.val();
    };

    Chosen.prototype.get_search_text = function() {
      return this.get_search_field_value().trim();
    };

    Chosen.prototype.escape_html = function(text) {
      return $('<div/>').text(text).html();
    };

    Chosen.prototype.winnow_results_set_highlight = function() {
      var do_high, selected_results;
      selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
      do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
      if (do_high != null) {
        return this.result_do_highlight(do_high);
      }
    };

    Chosen.prototype.no_results = function(terms) {
      var no_results_html;
      no_results_html = this.get_no_results_html(terms);
      this.search_results.append(no_results_html);
      return this.form_field_jq.trigger("chosen:no_results", {
        chosen: this
      });
    };

    Chosen.prototype.no_results_clear = function() {
      return this.search_results.find(".no-results").remove();
    };

    Chosen.prototype.keydown_arrow = function() {
      var next_sib;
      if (this.results_showing && this.result_highlight) {
        next_sib = this.result_highlight.nextAll("li.active-result").first();
        if (next_sib) {
          return this.result_do_highlight(next_sib);
        }
      } else {
        return this.results_show();
      }
    };

    Chosen.prototype.keyup_arrow = function() {
      var prev_sibs;
      if (!this.results_showing && !this.is_multiple) {
        return this.results_show();
      } else if (this.result_highlight) {
        prev_sibs = this.result_highlight.prevAll("li.active-result");
        if (prev_sibs.length) {
          return this.result_do_highlight(prev_sibs.first());
        } else {
          if (this.choices_count() > 0) {
            this.results_hide();
          }
          return this.result_clear_highlight();
        }
      }
    };

    Chosen.prototype.keydown_backstroke = function() {
      var next_available_destroy;
      if (this.pending_backstroke) {
        this.choice_destroy(this.pending_backstroke.find("a").first());
        return this.clear_backstroke();
      } else {
        next_available_destroy = this.search_container.siblings("li.search-choice").last();
        if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) {
          this.pending_backstroke = next_available_destroy;
          if (this.single_backstroke_delete) {
            return this.keydown_backstroke();
          } else {
            return this.pending_backstroke.addClass("search-choice-focus");
          }
        }
      }
    };

    Chosen.prototype.clear_backstroke = function() {
      if (this.pending_backstroke) {
        this.pending_backstroke.removeClass("search-choice-focus");
      }
      return this.pending_backstroke = null;
    };

    Chosen.prototype.search_field_scale = function() {
      var div, i, len, style, style_block, styles, width;
      if (!this.is_multiple) {
        return;
      }
      style_block = {
        position: 'absolute',
        left: '-1000px',
        top: '-1000px',
        display: 'none',
        whiteSpace: 'pre'
      };
      styles = ['fontSize', 'fontStyle', 'fontWeight', 'fontFamily', 'lineHeight', 'textTransform', 'letterSpacing'];
      for (i = 0, len = styles.length; i < len; i++) {
        style = styles[i];
        style_block[style] = this.search_field.css(style);
      }
      div = $('<div />').css(style_block);
      div.text(this.get_search_field_value());
      $('body').append(div);
      width = div.width() + 25;
      div.remove();
      if (this.container.is(':visible')) {
        width = Math.min(this.container.outerWidth() - 10, width);
      }
      return this.search_field.width(width);
    };

    Chosen.prototype.trigger_form_field_change = function(extra) {
      this.form_field_jq.trigger("input", extra);
      return this.form_field_jq.trigger("change", extra);
    };

    return Chosen;

  })(AbstractChosen);

}).call(this);
// source --> https://www.needmystyle.com/wp-includes/js/jquery/ui/core.min.js?ver=1.13.3 
/*! jQuery UI - v1.13.3 - 2024-04-26
* https://jqueryui.com
* Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-patch.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js
* Copyright jQuery Foundation and other contributors; Licensed MIT */
!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(x){"use strict";var t,e,i,n,W,C,o,s,r,l,a,h,u;function E(t,e,i){return[parseFloat(t[0])*(a.test(t[0])?e/100:1),parseFloat(t[1])*(a.test(t[1])?i/100:1)]}function L(t,e){return parseInt(x.css(t,e),10)||0}function N(t){return null!=t&&t===t.window}x.ui=x.ui||{},x.ui.version="1.13.3",
/*!
 * jQuery UI :data 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 */
x.extend(x.expr.pseudos,{data:x.expr.createPseudo?x.expr.createPseudo(function(e){return function(t){return!!x.data(t,e)}}):function(t,e,i){return!!x.data(t,i[3])}}),
/*!
 * jQuery UI Disable Selection 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 */
x.fn.extend({disableSelection:(t="onselectstart"in document.createElement("div")?"selectstart":"mousedown",function(){return this.on(t+".ui-disableSelection",function(t){t.preventDefault()})}),enableSelection:function(){return this.off(".ui-disableSelection")}}),
/*!
 * jQuery UI Focusable 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 */
x.ui.focusable=function(t,e){var i,n,o,s=t.nodeName.toLowerCase();return"area"===s?(o=(i=t.parentNode).name,!(!t.href||!o||"map"!==i.nodeName.toLowerCase())&&0<(i=x("img[usemap='#"+o+"']")).length&&i.is(":visible")):(/^(input|select|textarea|button|object)$/.test(s)?(n=!t.disabled)&&(o=x(t).closest("fieldset")[0])&&(n=!o.disabled):n="a"===s&&t.href||e,n&&x(t).is(":visible")&&function(t){var e=t.css("visibility");for(;"inherit"===e;)t=t.parent(),e=t.css("visibility");return"visible"===e}(x(t)))},x.extend(x.expr.pseudos,{focusable:function(t){return x.ui.focusable(t,null!=x.attr(t,"tabindex"))}}),x.fn._form=function(){return"string"==typeof this[0].form?this.closest("form"):x(this[0].form)},
/*!
 * jQuery UI Form Reset Mixin 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 */
x.ui.formResetMixin={_formResetHandler:function(){var e=x(this);setTimeout(function(){var t=e.data("ui-form-reset-instances");x.each(t,function(){this.refresh()})})},_bindFormResetHandler:function(){var t;this.form=this.element._form(),this.form.length&&((t=this.form.data("ui-form-reset-instances")||[]).length||this.form.on("reset.ui-form-reset",this._formResetHandler),t.push(this),this.form.data("ui-form-reset-instances",t))},_unbindFormResetHandler:function(){var t;this.form.length&&((t=this.form.data("ui-form-reset-instances")).splice(x.inArray(this,t),1),t.length?this.form.data("ui-form-reset-instances",t):this.form.removeData("ui-form-reset-instances").off("reset.ui-form-reset"))}},x.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),
/*!
 * jQuery UI Support for jQuery core 1.8.x and newer 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 *
 */
x.expr.pseudos||(x.expr.pseudos=x.expr[":"]),x.uniqueSort||(x.uniqueSort=x.unique),x.escapeSelector||(e=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g,i=function(t,e){return e?"\0"===t?"�":t.slice(0,-1)+"\\"+t.charCodeAt(t.length-1).toString(16)+" ":"\\"+t},x.escapeSelector=function(t){return(t+"").replace(e,i)}),x.fn.even&&x.fn.odd||x.fn.extend({even:function(){return this.filter(function(t){return t%2==0})},odd:function(){return this.filter(function(t){return t%2==1})}}),
/*!
 * jQuery UI Keycode 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 */
x.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},
/*!
 * jQuery UI Labels 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 */
x.fn.labels=function(){var t,e,i;return this.length?this[0].labels&&this[0].labels.length?this.pushStack(this[0].labels):(e=this.eq(0).parents("label"),(t=this.attr("id"))&&(i=(i=this.eq(0).parents().last()).add((i.length?i:this).siblings()),t="label[for='"+x.escapeSelector(t)+"']",e=e.add(i.find(t).addBack(t))),this.pushStack(e)):this.pushStack([])},x.ui.plugin={add:function(t,e,i){var n,o=x.ui[t].prototype;for(n in i)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([e,i[n]])},call:function(t,e,i,n){var o,s=t.plugins[e];if(s&&(n||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(o=0;o<s.length;o++)t.options[s[o][0]]&&s[o][1].apply(t.element,i)}},
/*!
 * jQuery UI Position 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 *
 * https://api.jqueryui.com/position/
 */
W=Math.max,C=Math.abs,o=/left|center|right/,s=/top|center|bottom/,r=/[\+\-]\d+(\.[\d]+)?%?/,l=/^\w+/,a=/%$/,h=x.fn.position,x.position={scrollbarWidth:function(){var t,e,i;return void 0!==n?n:(i=(e=x("<div style='display:block;position:absolute;width:200px;height:200px;overflow:hidden;'><div style='height:300px;width:auto;'></div></div>")).children()[0],x("body").append(e),t=i.offsetWidth,e.css("overflow","scroll"),t===(i=i.offsetWidth)&&(i=e[0].clientWidth),e.remove(),n=t-i)},getScrollInfo:function(t){var e=t.isWindow||t.isDocument?"":t.element.css("overflow-x"),i=t.isWindow||t.isDocument?"":t.element.css("overflow-y"),e="scroll"===e||"auto"===e&&t.width<t.element[0].scrollWidth;return{width:"scroll"===i||"auto"===i&&t.height<t.element[0].scrollHeight?x.position.scrollbarWidth():0,height:e?x.position.scrollbarWidth():0}},getWithinInfo:function(t){var e=x(t||window),i=N(e[0]),n=!!e[0]&&9===e[0].nodeType;return{element:e,isWindow:i,isDocument:n,offset:!i&&!n?x(t).offset():{left:0,top:0},scrollLeft:e.scrollLeft(),scrollTop:e.scrollTop(),width:e.outerWidth(),height:e.outerHeight()}}},x.fn.position=function(f){var c,d,p,g,m,v,y,w,b,_,t,e;return f&&f.of?(v="string"==typeof(f=x.extend({},f)).of?x(document).find(f.of):x(f.of),y=x.position.getWithinInfo(f.within),w=x.position.getScrollInfo(y),b=(f.collision||"flip").split(" "),_={},e=9===(e=(t=v)[0]).nodeType?{width:t.width(),height:t.height(),offset:{top:0,left:0}}:N(e)?{width:t.width(),height:t.height(),offset:{top:t.scrollTop(),left:t.scrollLeft()}}:e.preventDefault?{width:0,height:0,offset:{top:e.pageY,left:e.pageX}}:{width:t.outerWidth(),height:t.outerHeight(),offset:t.offset()},v[0].preventDefault&&(f.at="left top"),d=e.width,p=e.height,m=x.extend({},g=e.offset),x.each(["my","at"],function(){var t,e,i=(f[this]||"").split(" ");(i=1===i.length?o.test(i[0])?i.concat(["center"]):s.test(i[0])?["center"].concat(i):["center","center"]:i)[0]=o.test(i[0])?i[0]:"center",i[1]=s.test(i[1])?i[1]:"center",t=r.exec(i[0]),e=r.exec(i[1]),_[this]=[t?t[0]:0,e?e[0]:0],f[this]=[l.exec(i[0])[0],l.exec(i[1])[0]]}),1===b.length&&(b[1]=b[0]),"right"===f.at[0]?m.left+=d:"center"===f.at[0]&&(m.left+=d/2),"bottom"===f.at[1]?m.top+=p:"center"===f.at[1]&&(m.top+=p/2),c=E(_.at,d,p),m.left+=c[0],m.top+=c[1],this.each(function(){var i,t,r=x(this),l=r.outerWidth(),a=r.outerHeight(),e=L(this,"marginLeft"),n=L(this,"marginTop"),o=l+e+L(this,"marginRight")+w.width,s=a+n+L(this,"marginBottom")+w.height,h=x.extend({},m),u=E(_.my,r.outerWidth(),r.outerHeight());"right"===f.my[0]?h.left-=l:"center"===f.my[0]&&(h.left-=l/2),"bottom"===f.my[1]?h.top-=a:"center"===f.my[1]&&(h.top-=a/2),h.left+=u[0],h.top+=u[1],i={marginLeft:e,marginTop:n},x.each(["left","top"],function(t,e){x.ui.position[b[t]]&&x.ui.position[b[t]][e](h,{targetWidth:d,targetHeight:p,elemWidth:l,elemHeight:a,collisionPosition:i,collisionWidth:o,collisionHeight:s,offset:[c[0]+u[0],c[1]+u[1]],my:f.my,at:f.at,within:y,elem:r})}),f.using&&(t=function(t){var e=g.left-h.left,i=e+d-l,n=g.top-h.top,o=n+p-a,s={target:{element:v,left:g.left,top:g.top,width:d,height:p},element:{element:r,left:h.left,top:h.top,width:l,height:a},horizontal:i<0?"left":0<e?"right":"center",vertical:o<0?"top":0<n?"bottom":"middle"};d<l&&C(e+i)<d&&(s.horizontal="center"),p<a&&C(n+o)<p&&(s.vertical="middle"),W(C(e),C(i))>W(C(n),C(o))?s.important="horizontal":s.important="vertical",f.using.call(this,t,s)}),r.offset(x.extend(h,{using:t}))})):h.apply(this,arguments)},x.ui.position={fit:{left:function(t,e){var i,n=e.within,o=n.isWindow?n.scrollLeft:n.offset.left,n=n.width,s=t.left-e.collisionPosition.marginLeft,r=o-s,l=s+e.collisionWidth-n-o;n<e.collisionWidth?0<r&&l<=0?(i=t.left+r+e.collisionWidth-n-o,t.left+=r-i):t.left=!(0<l&&r<=0)&&l<r?o+n-e.collisionWidth:o:0<r?t.left+=r:0<l?t.left-=l:t.left=W(t.left-s,t.left)},top:function(t,e){var i,n=e.within,n=n.isWindow?n.scrollTop:n.offset.top,o=e.within.height,s=t.top-e.collisionPosition.marginTop,r=n-s,l=s+e.collisionHeight-o-n;o<e.collisionHeight?0<r&&l<=0?(i=t.top+r+e.collisionHeight-o-n,t.top+=r-i):t.top=!(0<l&&r<=0)&&l<r?n+o-e.collisionHeight:n:0<r?t.top+=r:0<l?t.top-=l:t.top=W(t.top-s,t.top)}},flip:{left:function(t,e){var i=e.within,n=i.offset.left+i.scrollLeft,o=i.width,i=i.isWindow?i.scrollLeft:i.offset.left,s=t.left-e.collisionPosition.marginLeft,r=s-i,s=s+e.collisionWidth-o-i,l="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,a="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,h=-2*e.offset[0];r<0?((o=t.left+l+a+h+e.collisionWidth-o-n)<0||o<C(r))&&(t.left+=l+a+h):0<s&&(0<(n=t.left-e.collisionPosition.marginLeft+l+a+h-i)||C(n)<s)&&(t.left+=l+a+h)},top:function(t,e){var i=e.within,n=i.offset.top+i.scrollTop,o=i.height,i=i.isWindow?i.scrollTop:i.offset.top,s=t.top-e.collisionPosition.marginTop,r=s-i,s=s+e.collisionHeight-o-i,l="top"===e.my[1]?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,a="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,h=-2*e.offset[1];r<0?((o=t.top+l+a+h+e.collisionHeight-o-n)<0||o<C(r))&&(t.top+=l+a+h):0<s&&(0<(n=t.top-e.collisionPosition.marginTop+l+a+h-i)||C(n)<s)&&(t.top+=l+a+h)}},flipfit:{left:function(){x.ui.position.flip.left.apply(this,arguments),x.ui.position.fit.left.apply(this,arguments)},top:function(){x.ui.position.flip.top.apply(this,arguments),x.ui.position.fit.top.apply(this,arguments)}}},x.ui.safeActiveElement=function(e){var i;try{i=e.activeElement}catch(t){i=e.body}return i=(i=i||e.body).nodeName?i:e.body},x.ui.safeBlur=function(t){t&&"body"!==t.nodeName.toLowerCase()&&x(t).trigger("blur")},
/*!
 * jQuery UI Scroll Parent 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 */
x.fn.scrollParent=function(t){var e=this.css("position"),i="absolute"===e,n=t?/(auto|scroll|hidden)/:/(auto|scroll)/,t=this.parents().filter(function(){var t=x(this);return(!i||"static"!==t.css("position"))&&n.test(t.css("overflow")+t.css("overflow-y")+t.css("overflow-x"))}).eq(0);return"fixed"!==e&&t.length?t:x(this[0].ownerDocument||document)},
/*!
 * jQuery UI Tabbable 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 */
x.extend(x.expr.pseudos,{tabbable:function(t){var e=x.attr(t,"tabindex"),i=null!=e;return(!i||0<=e)&&x.ui.focusable(t,i)}}),
/*!
 * jQuery UI Unique ID 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 */
x.fn.extend({uniqueId:(u=0,function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++u)})}),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&x(this).removeAttr("id")})}});
/*!
 * jQuery UI Widget 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 */
var f,c=0,d=Array.prototype.hasOwnProperty,p=Array.prototype.slice;x.cleanData=(f=x.cleanData,function(t){for(var e,i,n=0;null!=(i=t[n]);n++)(e=x._data(i,"events"))&&e.remove&&x(i).triggerHandler("remove");f(t)}),x.widget=function(t,i,e){var n,o,s,r={},l=t.split(".")[0],a=l+"-"+(t=t.split(".")[1]);return e||(e=i,i=x.Widget),Array.isArray(e)&&(e=x.extend.apply(null,[{}].concat(e))),x.expr.pseudos[a.toLowerCase()]=function(t){return!!x.data(t,a)},x[l]=x[l]||{},n=x[l][t],o=x[l][t]=function(t,e){if(!this||!this._createWidget)return new o(t,e);arguments.length&&this._createWidget(t,e)},x.extend(o,n,{version:e.version,_proto:x.extend({},e),_childConstructors:[]}),(s=new i).options=x.widget.extend({},s.options),x.each(e,function(e,n){function o(){return i.prototype[e].apply(this,arguments)}function s(t){return i.prototype[e].apply(this,t)}r[e]="function"!=typeof n?n:function(){var t,e=this._super,i=this._superApply;return this._super=o,this._superApply=s,t=n.apply(this,arguments),this._super=e,this._superApply=i,t}}),o.prototype=x.widget.extend(s,{widgetEventPrefix:n&&s.widgetEventPrefix||t},r,{constructor:o,namespace:l,widgetName:t,widgetFullName:a}),n?(x.each(n._childConstructors,function(t,e){var i=e.prototype;x.widget(i.namespace+"."+i.widgetName,o,e._proto)}),delete n._childConstructors):i._childConstructors.push(o),x.widget.bridge(t,o),o},x.widget.extend=function(t){for(var e,i,n=p.call(arguments,1),o=0,s=n.length;o<s;o++)for(e in n[o])i=n[o][e],d.call(n[o],e)&&void 0!==i&&(x.isPlainObject(i)?t[e]=x.isPlainObject(t[e])?x.widget.extend({},t[e],i):x.widget.extend({},i):t[e]=i);return t},x.widget.bridge=function(s,e){var r=e.prototype.widgetFullName||s;x.fn[s]=function(i){var t="string"==typeof i,n=p.call(arguments,1),o=this;return t?this.length||"instance"!==i?this.each(function(){var t,e=x.data(this,r);return"instance"===i?(o=e,!1):e?"function"!=typeof e[i]||"_"===i.charAt(0)?x.error("no such method '"+i+"' for "+s+" widget instance"):(t=e[i].apply(e,n))!==e&&void 0!==t?(o=t&&t.jquery?o.pushStack(t.get()):t,!1):void 0:x.error("cannot call methods on "+s+" prior to initialization; attempted to call method '"+i+"'")}):o=void 0:(n.length&&(i=x.widget.extend.apply(null,[i].concat(n))),this.each(function(){var t=x.data(this,r);t?(t.option(i||{}),t._init&&t._init()):x.data(this,r,new e(i,this))})),o}},x.Widget=function(){},x.Widget._childConstructors=[],x.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{classes:{},disabled:!1,create:null},_createWidget:function(t,e){e=x(e||this.defaultElement||this)[0],this.element=x(e),this.uuid=c++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=x(),this.hoverable=x(),this.focusable=x(),this.classesElementLookup={},e!==this&&(x.data(e,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===e&&this.destroy()}}),this.document=x(e.style?e.ownerDocument:e.document||e),this.window=x(this.document[0].defaultView||this.document[0].parentWindow)),this.options=x.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:x.noop,_create:x.noop,_init:x.noop,destroy:function(){var i=this;this._destroy(),x.each(this.classesElementLookup,function(t,e){i._removeClass(e,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:x.noop,widget:function(){return this.element},option:function(t,e){var i,n,o,s=t;if(0===arguments.length)return x.widget.extend({},this.options);if("string"==typeof t)if(s={},t=(i=t.split(".")).shift(),i.length){for(n=s[t]=x.widget.extend({},this.options[t]),o=0;o<i.length-1;o++)n[i[o]]=n[i[o]]||{},n=n[i[o]];if(t=i.pop(),1===arguments.length)return void 0===n[t]?null:n[t];n[t]=e}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];s[t]=e}return this._setOptions(s),this},_setOptions:function(t){for(var e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(t){var e,i,n;for(e in t)n=this.classesElementLookup[e],t[e]!==this.options.classes[e]&&n&&n.length&&(i=x(n.get()),this._removeClass(n,e),i.addClass(this._classes({element:i,keys:e,classes:t,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(o){var s=[],r=this;function t(t,e){for(var i,n=0;n<t.length;n++)i=r.classesElementLookup[t[n]]||x(),i=o.add?(function(){var i=[];o.element.each(function(t,e){x.map(r.classesElementLookup,function(t){return t}).some(function(t){return t.is(e)})||i.push(e)}),r._on(x(i),{remove:"_untrackClassesElement"})}(),x(x.uniqueSort(i.get().concat(o.element.get())))):x(i.not(o.element).get()),r.classesElementLookup[t[n]]=i,s.push(t[n]),e&&o.classes[t[n]]&&s.push(o.classes[t[n]])}return(o=x.extend({element:this.element,classes:this.options.classes||{}},o)).keys&&t(o.keys.match(/\S+/g)||[],!0),o.extra&&t(o.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(i){var n=this;x.each(n.classesElementLookup,function(t,e){-1!==x.inArray(i.target,e)&&(n.classesElementLookup[t]=x(e.not(i.target).get()))}),this._off(x(i.target))},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,n){var o="string"==typeof t||null===t,e={extra:o?e:i,keys:o?t:e,element:o?this.element:t,add:n="boolean"==typeof n?n:i};return e.element.toggleClass(this._classes(e),n),this},_on:function(o,s,t){var r,l=this;"boolean"!=typeof o&&(t=s,s=o,o=!1),t?(s=r=x(s),this.bindings=this.bindings.add(s)):(t=s,s=this.element,r=this.widget()),x.each(t,function(t,e){function i(){if(o||!0!==l.options.disabled&&!x(this).hasClass("ui-state-disabled"))return("string"==typeof e?l[e]:e).apply(l,arguments)}"string"!=typeof e&&(i.guid=e.guid=e.guid||i.guid||x.guid++);var t=t.match(/^([\w:-]*)\s*(.*)$/),n=t[1]+l.eventNamespace,t=t[2];t?r.on(n,t,i):s.on(n,i)})},_off:function(t,e){e=(e||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.off(e),this.bindings=x(this.bindings.not(t).get()),this.focusable=x(this.focusable.not(t).get()),this.hoverable=x(this.hoverable.not(t).get())},_delay:function(t,e){var i=this;return setTimeout(function(){return("string"==typeof t?i[t]:t).apply(i,arguments)},e||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){this._addClass(x(t.currentTarget),null,"ui-state-hover")},mouseleave:function(t){this._removeClass(x(t.currentTarget),null,"ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){this._addClass(x(t.currentTarget),null,"ui-state-focus")},focusout:function(t){this._removeClass(x(t.currentTarget),null,"ui-state-focus")}})},_trigger:function(t,e,i){var n,o,s=this.options[t];if(i=i||{},(e=x.Event(e)).type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),e.target=this.element[0],o=e.originalEvent)for(n in o)n in e||(e[n]=o[n]);return this.element.trigger(e,i),!("function"==typeof s&&!1===s.apply(this.element[0],[e].concat(i))||e.isDefaultPrevented())}},x.each({show:"fadeIn",hide:"fadeOut"},function(s,r){x.Widget.prototype["_"+s]=function(e,t,i){var n,o=(t="string"==typeof t?{effect:t}:t)?!0!==t&&"number"!=typeof t&&t.effect||r:s;"number"==typeof(t=t||{})?t={duration:t}:!0===t&&(t={}),n=!x.isEmptyObject(t),t.complete=i,t.delay&&e.delay(t.delay),n&&x.effects&&x.effects.effect[o]?e[s](t):o!==s&&e[o]?e[o](t.duration,t.easing,i):e.queue(function(t){x(this)[s](),i&&i.call(e[0]),t()})}})});
// source --> https://www.needmystyle.com/wp-includes/js/jquery/ui/mouse.min.js?ver=1.13.3 
/*!
 * jQuery UI Mouse 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 */
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","../ie","../version","../widget"],e):e(jQuery)}(function(o){"use strict";var n=!1;return o(document).on("mouseup",function(){n=!1}),o.widget("ui.mouse",{version:"1.13.3",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.on("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).on("click."+this.widgetName,function(e){if(!0===o.data(e.target,t.widgetName+".preventClickEvent"))return o.removeData(e.target,t.widgetName+".preventClickEvent"),e.stopImmediatePropagation(),!1}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){var t,i,s;if(!n)return this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),i=1===(this._mouseDownEvent=e).which,s=!("string"!=typeof(t=this).options.cancel||!e.target.nodeName)&&o(e.target).closest(this.options.cancel).length,i&&!s&&this._mouseCapture(e)&&(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){t.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=!1!==this._mouseStart(e),!this._mouseStarted)?e.preventDefault():(!0===o.data(e.target,this.widgetName+".preventClickEvent")&&o.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return t._mouseMove(e)},this._mouseUpDelegate=function(e){return t._mouseUp(e)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),n=!0)),!0},_mouseMove:function(e){if(this._mouseMoved){if(o.ui.ie&&(!document.documentMode||document.documentMode<9)&&!e.button)return this._mouseUp(e);if(!e.which)if(e.originalEvent.altKey||e.originalEvent.ctrlKey||e.originalEvent.metaKey||e.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=!1!==this._mouseStart(this._mouseDownEvent,e),this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&o.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,n=!1,e.preventDefault()},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})});
// source --> https://www.needmystyle.com/wp-includes/js/jquery/ui/slider.min.js?ver=1.13.3 
/*!
 * jQuery UI Slider 1.13.3
 * https://jqueryui.com
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license.
 * https://jquery.org/license
 */
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./mouse","../keycode","../version","../widget"],e):e(jQuery)}(function(o){"use strict";return o.widget("ui.slider",o.ui.mouse,{version:"1.13.3",widgetEventPrefix:"slide",options:{animate:!1,classes:{"ui-slider":"ui-corner-all","ui-slider-handle":"ui-corner-all","ui-slider-range":"ui-corner-all ui-widget-header"},distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null,change:null,slide:null,start:null,stop:null},numPages:5,_create:function(){this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this._calculateNewMax(),this._addClass("ui-slider ui-slider-"+this.orientation,"ui-widget ui-widget-content"),this._refresh(),this._animateOff=!1},_refresh:function(){this._createRange(),this._createHandles(),this._setupEvents(),this._refreshValue()},_createHandles:function(){var e,t=this.options,i=this.element.find(".ui-slider-handle"),s=[],a=t.values&&t.values.length||1;for(i.length>a&&(i.slice(a).remove(),i=i.slice(0,a)),e=i.length;e<a;e++)s.push("<span tabindex='0'></span>");this.handles=i.add(o(s.join("")).appendTo(this.element)),this._addClass(this.handles,"ui-slider-handle","ui-state-default"),this.handle=this.handles.eq(0),this.handles.each(function(e){o(this).data("ui-slider-handle-index",e).attr("tabIndex",0)})},_createRange:function(){var e=this.options;e.range?(!0===e.range&&(e.values?e.values.length&&2!==e.values.length?e.values=[e.values[0],e.values[0]]:Array.isArray(e.values)&&(e.values=e.values.slice(0)):e.values=[this._valueMin(),this._valueMin()]),this.range&&this.range.length?(this._removeClass(this.range,"ui-slider-range-min ui-slider-range-max"),this.range.css({left:"",bottom:""})):(this.range=o("<div>").appendTo(this.element),this._addClass(this.range,"ui-slider-range")),"min"!==e.range&&"max"!==e.range||this._addClass(this.range,"ui-slider-range-"+e.range)):(this.range&&this.range.remove(),this.range=null)},_setupEvents:function(){this._off(this.handles),this._on(this.handles,this._handleEvents),this._hoverable(this.handles),this._focusable(this.handles)},_destroy:function(){this.handles.remove(),this.range&&this.range.remove(),this._mouseDestroy()},_mouseCapture:function(e){var i,s,a,n,t,h,l=this,u=this.options;return!u.disabled&&(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),t={x:e.pageX,y:e.pageY},i=this._normValueFromMouse(t),s=this._valueMax()-this._valueMin()+1,this.handles.each(function(e){var t=Math.abs(i-l.values(e));(t<s||s===t&&(e===l._lastChangedValue||l.values(e)===u.min))&&(s=t,a=o(this),n=e)}),!1!==this._start(e,n))&&(this._mouseSliding=!0,this._handleIndex=n,this._addClass(a,null,"ui-state-active"),a.trigger("focus"),t=a.offset(),h=!o(e.target).parents().addBack().is(".ui-slider-handle"),this._clickOffset=h?{left:0,top:0}:{left:e.pageX-t.left-a.width()/2,top:e.pageY-t.top-a.height()/2-(parseInt(a.css("borderTopWidth"),10)||0)-(parseInt(a.css("borderBottomWidth"),10)||0)+(parseInt(a.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(e,n,i),this._animateOff=!0)},_mouseStart:function(){return!0},_mouseDrag:function(e){var t={x:e.pageX,y:e.pageY},t=this._normValueFromMouse(t);return this._slide(e,this._handleIndex,t),!1},_mouseStop:function(e){return this._removeClass(this.handles,null,"ui-state-active"),this._mouseSliding=!1,this._stop(e,this._handleIndex),this._change(e,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1},_detectOrientation:function(){this.orientation="vertical"===this.options.orientation?"vertical":"horizontal"},_normValueFromMouse:function(e){var t,e="horizontal"===this.orientation?(t=this.elementSize.width,e.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(t=this.elementSize.height,e.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),e=e/t;return(e=1<e?1:e)<0&&(e=0),"vertical"===this.orientation&&(e=1-e),t=this._valueMax()-this._valueMin(),e=this._valueMin()+e*t,this._trimAlignValue(e)},_uiHash:function(e,t,i){var s={handle:this.handles[e],handleIndex:e,value:void 0!==t?t:this.value()};return this._hasMultipleValues()&&(s.value=void 0!==t?t:this.values(e),s.values=i||this.values()),s},_hasMultipleValues:function(){return this.options.values&&this.options.values.length},_start:function(e,t){return this._trigger("start",e,this._uiHash(t))},_slide:function(e,t,i){var s,a=this.value(),n=this.values();this._hasMultipleValues()&&(s=this.values(t?0:1),a=this.values(t),2===this.options.values.length&&!0===this.options.range&&(i=0===t?Math.min(s,i):Math.max(s,i)),n[t]=i),i!==a&&!1!==this._trigger("slide",e,this._uiHash(t,i,n))&&(this._hasMultipleValues()?this.values(t,i):this.value(i))},_stop:function(e,t){this._trigger("stop",e,this._uiHash(t))},_change:function(e,t){this._keySliding||this._mouseSliding||(this._lastChangedValue=t,this._trigger("change",e,this._uiHash(t)))},value:function(e){if(!arguments.length)return this._value();this.options.value=this._trimAlignValue(e),this._refreshValue(),this._change(null,0)},values:function(e,t){var i,s,a;if(1<arguments.length)this.options.values[e]=this._trimAlignValue(t),this._refreshValue(),this._change(null,e);else{if(!arguments.length)return this._values();if(!Array.isArray(e))return this._hasMultipleValues()?this._values(e):this.value();for(i=this.options.values,s=e,a=0;a<i.length;a+=1)i[a]=this._trimAlignValue(s[a]),this._change(null,a);this._refreshValue()}},_setOption:function(e,t){var i,s=0;switch("range"===e&&!0===this.options.range&&("min"===t?(this.options.value=this._values(0),this.options.values=null):"max"===t&&(this.options.value=this._values(this.options.values.length-1),this.options.values=null)),Array.isArray(this.options.values)&&(s=this.options.values.length),this._super(e,t),e){case"orientation":this._detectOrientation(),this._removeClass("ui-slider-horizontal ui-slider-vertical")._addClass("ui-slider-"+this.orientation),this._refreshValue(),this.options.range&&this._refreshRange(t),this.handles.css("horizontal"===t?"bottom":"left","");break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":for(this._animateOff=!0,this._refreshValue(),i=s-1;0<=i;i--)this._change(null,i);this._animateOff=!1;break;case"step":case"min":case"max":this._animateOff=!0,this._calculateNewMax(),this._refreshValue(),this._animateOff=!1;break;case"range":this._animateOff=!0,this._refresh(),this._animateOff=!1}},_setOptionDisabled:function(e){this._super(e),this._toggleClass(null,"ui-state-disabled",!!e)},_value:function(){var e=this.options.value;return this._trimAlignValue(e)},_values:function(e){var t,i;if(arguments.length)return e=this.options.values[e],this._trimAlignValue(e);if(this._hasMultipleValues()){for(t=this.options.values.slice(),i=0;i<t.length;i+=1)t[i]=this._trimAlignValue(t[i]);return t}return[]},_trimAlignValue:function(e){var t,i;return e<=this._valueMin()?this._valueMin():e>=this._valueMax()?this._valueMax():(t=0<this.options.step?this.options.step:1,i=e-(e=(e-this._valueMin())%t),2*Math.abs(e)>=t&&(i+=0<e?t:-t),parseFloat(i.toFixed(5)))},_calculateNewMax:function(){var e=this.options.max,t=this._valueMin(),i=this.options.step;(e=Math.round((e-t)/i)*i+t)>this.options.max&&(e-=i),this.max=parseFloat(e.toFixed(this._precision()))},_precision:function(){var e=this._precisionOf(this.options.step);return e=null!==this.options.min?Math.max(e,this._precisionOf(this.options.min)):e},_precisionOf:function(e){var e=e.toString(),t=e.indexOf(".");return-1===t?0:e.length-t-1},_valueMin:function(){return this.options.min},_valueMax:function(){return this.max},_refreshRange:function(e){"vertical"===e&&this.range.css({width:"",left:""}),"horizontal"===e&&this.range.css({height:"",bottom:""})},_refreshValue:function(){var t,i,e,s,a,n=this.options.range,h=this.options,l=this,u=!this._animateOff&&h.animate,r={};this._hasMultipleValues()?this.handles.each(function(e){i=(l.values(e)-l._valueMin())/(l._valueMax()-l._valueMin())*100,r["horizontal"===l.orientation?"left":"bottom"]=i+"%",o(this).stop(1,1)[u?"animate":"css"](r,h.animate),!0===l.options.range&&("horizontal"===l.orientation?(0===e&&l.range.stop(1,1)[u?"animate":"css"]({left:i+"%"},h.animate),1===e&&l.range[u?"animate":"css"]({width:i-t+"%"},{queue:!1,duration:h.animate})):(0===e&&l.range.stop(1,1)[u?"animate":"css"]({bottom:i+"%"},h.animate),1===e&&l.range[u?"animate":"css"]({height:i-t+"%"},{queue:!1,duration:h.animate}))),t=i}):(e=this.value(),s=this._valueMin(),a=this._valueMax(),i=a!==s?(e-s)/(a-s)*100:0,r["horizontal"===this.orientation?"left":"bottom"]=i+"%",this.handle.stop(1,1)[u?"animate":"css"](r,h.animate),"min"===n&&"horizontal"===this.orientation&&this.range.stop(1,1)[u?"animate":"css"]({width:i+"%"},h.animate),"max"===n&&"horizontal"===this.orientation&&this.range.stop(1,1)[u?"animate":"css"]({width:100-i+"%"},h.animate),"min"===n&&"vertical"===this.orientation&&this.range.stop(1,1)[u?"animate":"css"]({height:i+"%"},h.animate),"max"===n&&"vertical"===this.orientation&&this.range.stop(1,1)[u?"animate":"css"]({height:100-i+"%"},h.animate))},_handleEvents:{keydown:function(e){var t,i,s,a=o(e.target).data("ui-slider-handle-index");switch(e.keyCode){case o.ui.keyCode.HOME:case o.ui.keyCode.END:case o.ui.keyCode.PAGE_UP:case o.ui.keyCode.PAGE_DOWN:case o.ui.keyCode.UP:case o.ui.keyCode.RIGHT:case o.ui.keyCode.DOWN:case o.ui.keyCode.LEFT:if(e.preventDefault(),this._keySliding||(this._keySliding=!0,this._addClass(o(e.target),null,"ui-state-active"),!1!==this._start(e,a)))break;return}switch(s=this.options.step,t=i=this._hasMultipleValues()?this.values(a):this.value(),e.keyCode){case o.ui.keyCode.HOME:i=this._valueMin();break;case o.ui.keyCode.END:i=this._valueMax();break;case o.ui.keyCode.PAGE_UP:i=this._trimAlignValue(t+(this._valueMax()-this._valueMin())/this.numPages);break;case o.ui.keyCode.PAGE_DOWN:i=this._trimAlignValue(t-(this._valueMax()-this._valueMin())/this.numPages);break;case o.ui.keyCode.UP:case o.ui.keyCode.RIGHT:if(t===this._valueMax())return;i=this._trimAlignValue(t+s);break;case o.ui.keyCode.DOWN:case o.ui.keyCode.LEFT:if(t===this._valueMin())return;i=this._trimAlignValue(t-s)}this._slide(e,a,i)},keyup:function(e){var t=o(e.target).data("ui-slider-handle-index");this._keySliding&&(this._keySliding=!1,this._stop(e,t),this._change(e,t),this._removeClass(o(e.target),null,"ui-state-active"))}}})});
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce/assets/js/jquery-ui-touch-punch/jquery-ui-touch-punch.min.js?ver=10.9.3 
/*!
 * jQuery UI Touch Punch 0.2.3
 *
 * Copyright 2011–2014, Dave Furfero
 * Dual licensed under the MIT or GPL Version 2 licenses.
 *
 * Depends:
 *  jquery.ui.widget.js
 *  jquery.ui.mouse.js
 */
!function(t){if(t.support.touch="ontouchend"in document,t.support.touch){var o,e=t.ui.mouse.prototype,u=e._mouseInit,n=e._mouseDestroy;e._touchStart=function(t){!o&&this._mouseCapture(t.originalEvent.changedTouches[0])&&(o=!0,this._touchMoved=!1,c(t,"mouseover"),c(t,"mousemove"),c(t,"mousedown"))},e._touchMove=function(t){o&&(this._touchMoved=!0,c(t,"mousemove"))},e._touchEnd=function(t){o&&(c(t,"mouseup"),c(t,"mouseout"),this._touchMoved||c(t,"click"),o=!1)},e._mouseInit=function(){this.element.on({touchstart:t.proxy(this,"_touchStart"),touchmove:t.proxy(this,"_touchMove"),touchend:t.proxy(this,"_touchEnd")}),u.call(this)},e._mouseDestroy=function(){this.element.off({touchstart:t.proxy(this,"_touchStart"),touchmove:t.proxy(this,"_touchMove"),touchend:t.proxy(this,"_touchEnd")}),n.call(this)}}function c(t,o){if(!(t.originalEvent.touches.length>1)){t.preventDefault();var e=t.originalEvent.changedTouches[0],u=document.createEvent("MouseEvents");u.initMouseEvent(o,!0,!0,window,1,e.screenX,e.screenY,e.clientX,e.clientY,!1,!1,!1,!1,0,null),t.target.dispatchEvent(u)}}}(jQuery);
// source --> https://www.needmystyle.com/wp-content/plugins/woocommerce/assets/js/accounting/accounting.min.js?ver=0.4.2 
/*!
 * accounting.js v0.4.2
 * Copyright 2014 Open Exchange Rates
 *
 * Freely distributable under the MIT license.
 * Portions of accounting.js are inspired or borrowed from underscore.js
 *
 * Full details and documentation:
 * http://openexchangerates.github.io/accounting.js/
 */
!function(n,r){var e={version:"0.4.1",settings:{currency:{symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3},number:{precision:0,grouping:3,thousand:",",decimal:"."}}},t=Array.prototype.map,o=Array.isArray,a=Object.prototype.toString;function i(n){return!!(""===n||n&&n.charCodeAt&&n.substr)}function u(n){return o?o(n):"[object Array]"===a.call(n)}function c(n){return n&&"[object Object]"===a.call(n)}function s(n,r){var e;for(e in n=n||{},r=r||{})r.hasOwnProperty(e)&&null==n[e]&&(n[e]=r[e]);return n}function f(n,r,e){var o,a,i=[];if(!n)return i;if(t&&n.map===t)return n.map(r,e);for(o=0,a=n.length;o<a;o++)i[o]=r.call(e,n[o],o,n);return i}function p(n,r){return n=Math.round(Math.abs(n)),isNaN(n)?r:n}function l(n){var r=e.settings.currency.format;return"function"==typeof n&&(n=n()),i(n)&&n.match("%v")?{pos:n,neg:n.replace("-","").replace("%v","-%v"),zero:n}:n&&n.pos&&n.pos.match("%v")?n:i(r)?e.settings.currency.format={pos:r,neg:r.replace("%v","-%v"),zero:r}:r}var m,d=e.unformat=e.parse=function(n,r){if(u(n))return f(n,function(n){return d(n,r)});if("number"==typeof(n=n||0))return n;r=r||e.settings.number.decimal;var t=new RegExp("[^0-9-"+r+"]",["g"]),o=parseFloat((""+n).replace(/\((.*)\)/,"-$1").replace(t,"").replace(r,"."));return isNaN(o)?0:o},g=e.toFixed=function(n,r){r=p(r,e.settings.number.precision);var t=Math.pow(10,r);return(Math.round(e.unformat(n)*t)/t).toFixed(r)},h=e.formatNumber=e.format=function(n,r,t,o){if(u(n))return f(n,function(n){return h(n,r,t,o)});n=d(n);var a=s(c(r)?r:{precision:r,thousand:t,decimal:o},e.settings.number),i=p(a.precision),l=n<0?"-":"",m=parseInt(g(Math.abs(n||0),i),10)+"",y=m.length>3?m.length%3:0;return l+(y?m.substr(0,y)+a.thousand:"")+m.substr(y).replace(/(\d{3})(?=\d)/g,"$1"+a.thousand)+(i?a.decimal+g(Math.abs(n),i).split(".")[1]:"")},y=e.formatMoney=function(n,r,t,o,a,i){if(u(n))return f(n,function(n){return y(n,r,t,o,a,i)});n=d(n);var m=s(c(r)?r:{symbol:r,precision:t,thousand:o,decimal:a,format:i},e.settings.currency),g=l(m.format);return(n>0?g.pos:n<0?g.neg:g.zero).replace("%s",m.symbol).replace("%v",h(Math.abs(n),p(m.precision),m.thousand,m.decimal))};e.formatColumn=function(n,r,t,o,a,m){if(!n)return[];var g=s(c(r)?r:{symbol:r,precision:t,thousand:o,decimal:a,format:m},e.settings.currency),y=l(g.format),b=y.pos.indexOf("%s")<y.pos.indexOf("%v"),v=0;return f(f(n,function(n,r){if(u(n))return e.formatColumn(n,g);var t=((n=d(n))>0?y.pos:n<0?y.neg:y.zero).replace("%s",g.symbol).replace("%v",h(Math.abs(n),p(g.precision),g.thousand,g.decimal));return t.length>v&&(v=t.length),t}),function(n,r){return i(n)&&n.length<v?b?n.replace(g.symbol,g.symbol+new Array(v-n.length+1).join(" ")):new Array(v-n.length+1).join(" ")+n:n})},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=e),exports.accounting=e):"function"==typeof define&&define.amd?define([],function(){return e}):(e.noConflict=(m=n.accounting,function(){return n.accounting=m,e.noConflict=void 0,e}),n.accounting=e)}(this);