!function(s){"use strict";s(document).ready(function(){var n,e,t,i,r,a;n=s(".woocommerce-product-search"),e=s(".ajax-search .woocommerce-product-search .search-field"),t=s(".ajax-search-result"),i=wp.template("ajax-live-search-template"),r=s(".input-dropdown-inner"),a=s("> .list-wrapper",r),s("body").on("click",function(){t.hide(),a.slideUp(100),r.removeClass("dd-shown")}),s(".input-dropdown-inner > a").on("click",function(e){return e.preventDefault(),r.hasClass("dd-shown")?(r.removeClass("dd-shown"),a.slideUp(100)):(r.addClass("dd-shown"),a.slideDown(100)),t.hide(),!1}),s(".input-dropdown-inner > .list-wrapper").on("click","a",function(e){e.preventDefault();var n=s(this).data("val"),e=s(this).text();s(".input-dropdown-inner > .list-wrapper").find(".current-item").removeClass("current-item"),s(this).parent().addClass("current-item"),0!=n?a.find("ul:not(.children) > li:first-child").show():0==n&&a.find("ul:not(.children) > li:first-child").hide(),s(".input-dropdown-inner > a span").text(e),s(".input-dropdown-inner > select").val(n).trigger("cat_selected"),a.slideUp(100),r.removeClass("dd-shown")}),s(".input-dropdown-inner > select").change(function(){var e=s(this).val(),n=s(this).find("option:selected").text();s(".input-dropdown-inner > .list-wrapper").find(".current-item").removeClass("current-item"),s(this).parent().addClass("current-item"),0!=e?a.find("ul:not(.children) > li:first-child").show():0==e&&a.find("ul:not(.children) > li:first-child").hide(),s(".input-dropdown-inner > a span").text(n)}),e.length&&e.keyup(function(){var e;2<this.value.length?(e=s('select[name="product_cat"]',n).val(),s.ajax({url:naturisAjax.ajaxurl,type:"post",data:{action:"naturis_ajax_search_products",query:this.value,product_cat:e},beforeSend:function(){n.addClass("loading")},success:function(e){n.removeClass("loading");e=s.parseJSON(e);t.empty(),t.show(),s.each(e,function(e,n){t.append(i({url:n.url,title:n.value,img:n.img,price:n.price}))})}})):t.hide()}).on("click",function(e){e.stopPropagation()}).on("focus",function(e){a.slideUp(100),r.removeClass("dd-shown"),2<this.value.length&&t.show()})})}(jQuery);