define("search","init",function(){var e,t="usearch"+Date.now(),n={},a=90,s="desktop"==Device.type?150:300,i={suggests:{activeClass:"suggest__item_active",showOnFocus:!0,hideEmpty:!0,inputActiveClass:!1},"default":{activeClass:!1,showOnFocus:!1,hideEmpty:!1,inputActiveClass:!1}},r=Class({Static:{recheck:function(){e||(e=setTimeout(function(){$(function(){e=null,$(".js-usearch_parent").each(function(){var e,a,s=$(this);s.data(t)||(e=s.find(".js-usearch"),e.length||(e=s.find(".js-usearch_input_wrap .text-input")),e.length||(e=s.find(".js-usearch_input_wrap .js-search__input")),a=e.data("type")||s.data("type"),n[a]&&s.data(t,new r(e)))})})},0))},register:function(e,t){n[e]=t,this.recheck()}},Constructor:function(e){var t,r,l,o,c,h,p,g,u,d=this;d.el=e,d.parent=e.findClass("js-usearch_parent"),t=$.extend({selList:".js-usearch_list",selWrap:".js-usearch_list_wrap",selEmpty:".js-usearch_empty"},d.parent.data(),e.data()),d.cfg=$.extend({length:0},n[t.type],{apiMethod:t.apiMethod,apiData:t.apiData}),d.type=t.type,d.list=d.parent.find(d.cfg.selList||t.selList),d.wrap=d.parent.find(d.cfg.selWrap||t.selWrap),d.empty=d.parent.find(d.cfg.selEmpty||t.selEmpty),d.wrap.length||(d.wrap=d.list),"object"==typeof d.cfg.render?d.render=$.extend(i[t.type||"default"],d.cfg.render):"string"==typeof d.cfg.render&&(d.render=i[t.render||d.cfg.render||"default"]),d.render="object"==typeof d.cfg.render?d.cfg.render:i[d.cfg.render||"default"],r=function(e){var t=$.trim(d.el.val());h||o!=t&&(o=t,h=!0),h&&d.cancelApi(),!e&&Date.now()-c<=a||h&&(d.search(t),o=t,h=!1)},d.list.on("click",".js-usearch_result_val",function(e){e.preventDefault();var t=$(this);d.el.val(t.data("value")).trigger("change"),t.data("hide")&&t.trigger("closeSearch")}),o="",c=0,h=!1,u=!1,e.on("focus",function(){l&&clearInterval(l),l=setInterval(r,s),d.toggleList(),p&&clearTimeout(p),g=null}).on("blur",function(){clearInterval(l),r(!0),l=null,g&&Date.now()-g.time<100&&$(g.el).click(),d.render.showOnFocus&&d.showList(!1),g=null}).on("input",function(){c=Date.now(),r()}).on("keydown",function(e){!d.cfg.enter||e.keyCode!=Spaces.KEYS.ENTER&&e.keyCode!=Spaces.KEYS.MAC_ENTER?e.keyCode==Spaces.KEYS.ESC?d.render.showOnFocus&&d.showList(!1):(e.keyCode==Spaces.KEYS.UP||e.keyCode==Spaces.KEYS.DOWN)&&d.toggleList():(e.preventDefault(),r(!0))}),d.parent.on("clearSearchForm",function(){r(!0)}).on("closeSearch",function(){d.cfg.hideEmpty&&(d.list.html(""),d.toggleList())}).on("click",".js-search__submit",function(e){e.preventDefault(),r(!0),d.el.focus()}),d.render.activeClass&&d.list.length&&(d.list.itemsSelector({activeClass:d.render.activeClass,keydownArea:d.el}),d.list.on("click",">*",function(e){e.preventDefault()}),d.list.on("highlight",">*",function(){g={el:this,time:Date.now()}})),d.el.is(":focus")&&d.el.blur().focus()},search:function(e){var t,n,a=this,s=a.cfg;return a.cancelApi(),s.hideEmpty&&(!e.length||e.length<a.cfg.length)?(a.list.html(""),void a.toggleList()):a.cfg.length&&a.cfg.length>e.length&&(!a.cfg.allowEmpty||e.length)?void 0:(t=$.extend({},s.apiData),n="function"==typeof s.apiMethod?s.apiMethod.call(a,[]):s.apiMethod,s.onBeforeSend&&s.onBeforeSend.call(a,e,t),t[s.param]=e,s.doSearch?(a.toggleLoading(!0),void(a.last_api_request=s.doSearch({query:e,method:n,api_data:t,onSuccess:function(){a.toggleLoading(!1)},onError:function(e){a.toggleLoading(!1),Spaces.showError(e)},list:a.list}))):(a.toggleLoading(!0),void(a.last_api_request=Spaces.api(n,t,function(t){if(a.toggleLoading(!1),s.noapi||0==t.code){if(s.onResult&&s.onResult.call(a,t,e),s.onRender)s.onRender.call(a,a.list,t,e);else{var n=t[s.results];n.join&&(n=n.join("")),a.list.html(n)}a.toggleList()}else Spaces.showApiError(t)},{retry:10,onError:function(e){a.toggleLoading(!1),Spaces.showError(e)}}))))},cancelApi:function(){var e=this;Spaces.cancelApi(e.last_api_request),e.parent.removeClass("search__loading")},toggleLoading:function(e){var t=this;t.parent.toggleClass("search__loading",e)},showList:function(e){var t=this;t.list.length&&(t.wrap.toggle(!!e),t.render.inputActiveClass&&t.el.parent().toggleClass(t.render.inputActiveClass,!!e),Spaces.fixHeight(t.wrap))},toggleList:function(){var e=this;e.list.length&&(e.render.showOnFocus||!e.empty.length?(Spaces.fixHeight(e.wrap),e.showList(e.list.children().length)):e.list.children().length?(e.empty.hide(),e.list.show()):(e.empty.show(),e.list.hide()))}});window.UniversalSearch=r,define("search","onRequire",function(){r.recheck()})});define("select_item","init",function(){var e="_select_item_"+Date.now();$.fn.itemsSelector=function(t){function n(){return c.children(t.activeSelector)}function i(e){c.children(t.activeSelector).removeClass(t.activeClass),e&&e.toggleClass(t.activeClass,!e.data("no_highlight")).trigger("highlight")}function a(e){var n,a,o=c.children(),s=c.children("."+t.activeClass);s.length?(a=s.index(),a=e>0?a+1<o.length?a+1:0:a-1>=0?a-1:o.length-1,n=$(o[a])):n=e>0?o.first():o.last(),n[0]!=s[0]&&i(n)}var c=this.first();return!c.length||c.data(e)?this:(c.data(e,!0),t=$.extend({activeClass:"active",keydownArea:c},t),t.activeSelector=t.activeSelector||"."+t.activeClass,t.keydownArea.on("keydown",function(e){var t,i=e.keyCode;i==Spaces.KEYS.ENTER||i==Spaces.KEYS.MAC_ENTER?(t=n(),t.length&&(e.preventDefault(),n().click())):(i==Spaces.KEYS.UP||i==Spaces.KEYS.DOWN)&&(e.preventDefault(),a(i==Spaces.KEYS.UP?-1:1))}).on("focus",function(){i()}),void c.on("touchmove mouseenter mousedown touchstart",">*",function(){i($(this))}).on("mouseleave",">*",function(){i()}))}});