!function(a){woodmartThemeModule.$document.on("wdShopPageInit",function(){woodmartThemeModule.ajaxSearch()}),a.each(["frontend/element_ready/wd_search.default"],function(a,b){woodmartThemeModule.wdElementorAddAction(b,function(){woodmartThemeModule.ajaxSearch()})}),woodmartThemeModule.ajaxSearch=function(){if(void 0!==a.fn.devbridgeAutocomplete){var b=function(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")};a("form.woodmart-ajax-search").each(function(){var c=a(this),d=parseInt(c.data("count")),e=parseInt(c.data("thumbnail")),f=parseInt(c.data("symbols_count")),g=c.find('[name="product_cat"]'),h=c.parent().find(".wd-dropdown-results > .wd-scroll-content"),i=c.data("post_type"),j=woodmart_settings.ajaxurl+"?action=woodmart_ajax_search",k=parseInt(c.data("price")),l=c.data("sku");d>0&&(j+="&number="+d),j+="&post_type="+i,h.on("click",".view-all-results",function(){c.submit()}),g.length&&""!==g.val()&&(j+="&product_cat="+g.val()),c.find('[type="text"]').on("focus",function(){var m=a(this);if(!m.hasClass("wd-search-inited")){if(m.devbridgeAutocomplete({serviceUrl:j,appendTo:h,minChars:f,onSelect:function(a){a.permalink.length>0&&(window.location.href=a.permalink)},onHide:function(){h.parent().removeClass("wd-opened")},onSearchStart:function(){c.addClass("search-loading")},beforeRender:function(b){a(b).find(".suggestion-divider-title").parent().addClass("suggestion-divider"),b[0].childElementCount>2&&a(b).append('
'+woodmart_settings.all_results+"
"),a(b).removeAttr("style")},onSearchComplete:function(){c.removeClass("search-loading"),woodmartThemeModule.$document.trigger("wood-images-loaded")},formatResult:function(a,c){"&"===c&&(c="&");var d="("+b(c)+")",f="";return a.divider&&(f+='
'+a.divider+"
"),e&&a.thumbnail&&(f+='
'+a.thumbnail+"
"),a.value&&(f+='
',f+='

'+a.value.replace(new RegExp(d,"gi"),"$1").replace(/<(\/?strong)>/g,"<$1>")+"

"),l&&a.sku&&(f+='

'+a.sku+"

"),k&&a.price&&(f+='

'+a.price+"

"),a.value&&(f+="
"),a.no_found&&(f=''+a.value+""),h.parent().addClass("wd-opened"),f}}),g.length){var n=c.find('[type="text"]').devbridgeAutocomplete(),o=woodmart_settings.ajaxurl+"?action=woodmart_ajax_search";d>0&&(o+="&number="+d),o+="&post_type="+i,g.on("cat_selected",function(){""!==g.val()?n.setOptions({serviceUrl:o+"&product_cat="+g.val()}):n.setOptions({serviceUrl:o}),n.hide(),n.onValueChange()})}m.addClass("wd-search-inited")}}),woodmartThemeModule.$document.on("click",function(b){var d=b.target;a(d).is(".wd-search-form")||a(d).parents().is(".wd-search-form")||c.find('[type="text"]').devbridgeAutocomplete("hide")}),a(".wd-dropdown-results > .wd-scroll-content").on("click",function(a){a.stopPropagation()})})}},a(document).ready(function(){woodmartThemeModule.ajaxSearch()})}(jQuery);