(e=>{"function"==typeof define&&define.amd?define("quicksearch",e):e()})(function(){jQuery(function(t){t(".quick-search-instance").each(function(e,s){var n={};n.el=t(this),n.input=n.el.find('input[name="search_keywords"]'),n.default=n.el.find(".default-results"),n.results=n.el.find(".ajax-results"),n.spinner=n.el.find(".loader-bg"),n.view_all=n.el.find(".all-results"),n.no_results=n.el.find(".no-results"),n.last_request=null,n.input.on("input",MyListing.Helpers.debounce(function(e){i(n)},250)).trigger("input"),"always"===n.el.data("focus")?n.el.find(".header-search").addClass("is-focused"):n.el.on("focusin",function(){n.el.find(".header-search").addClass("is-focused")}).on("focusout",function(){n.el.find(".header-search").removeClass("is-focused")})});var i=function(s){var e;s.spinner.hide(),s.results.hide(),s.view_all.hide(),s.no_results.hide(),s.input.val()&&s.input.val().trim()?(s.default.hide(),s.spinner.show(),e=t.param({action:"mylisting_quick_search",security:CASE27.ajax_nonce,s:s.input.val().trim()}),t.ajax({url:CASE27.mylisting_ajax_url,type:"GET",dataType:"json",data:e,beforeSend:function(e){s.last_request&&s.last_request.abort(),s.last_request=e},success:function(e){if(s.spinner.hide(),!e.content.trim().length)return s.no_results.show();s.results.html(e.content).show(),s.view_all.show()}})):(s.last_request&&s.last_request.abort(),s.last_request=null,s.default.show())}})});
