mindtools="undefined"==typeof mindtools?{}:mindtools,mindtools.global=void 0===mindtools.global?{}:mindtools.global,"undefined"==typeof $&&"undefined"!=typeof jQuery&&($=jQuery);var isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function GlobalSearch(e){this.setNav(e),this.globalSearch()}GlobalSearch.prototype=function(e){var o={setNav:function(e){if("object"!=typeof e)throw new Error("Invalid argument passed to ComponentSearch.setNav. Expected object got "+typeof e);if("function"!=typeof e.closeDrawer)throw new Error("Invalid argument passed to ComponentSearch.setNav. "+typeof e+" does not have required method");this.nav=e},globalSearch:function(){var o=this,a=function(a,t,n){return function(s){if(s.preventDefault(),o.nav.closeDrawer(e("li.expanded ul")),a.removeClass("as-width"),""===t.val())if(e(this).hasClass("active")){if(""!=t.val()){a.attr("action",""!=a.attr("action")?a.attr("action"):"/pages/search"),t.prop("readonly",!0),e(this).prop("disabled",!0);var r=e(".search-form-wrapper .js-progress-indicator");r.length&&!isSafari&&r.addClass("loader"),a.submit()}}else t.show().focus(),a.css("width","100%"),n.fadeIn(500),e(this).addClass("active");else a.submit()}},t=function(o,a,t){return function(){o.val("").hide(),e("#search-suggestions-container").remove(),a.removeClass("active"),e(this).hide(),t.addClass("as-width").removeAttr("style")}},n=function(o,a,t){return function(){var n=a.val();0!==n.length?n.length>2&&(mindtools.tools.ajax("/search/autocomplete?prefix="+n).done=function(n){for(var s=JSON.parse(n.response),r=(e(".mt-x.close",o).is(":visible"),e('<ul id="search-suggestions-container">')),i=0;i<s.length;i++){var c=e('<li class="search-suggestion">');c.text(s[i]._source.rm_heading),c.on("click",function(){a.val(e(this).text()).focus(),r.remove(),a.prop("readonly",!0),t.prop("disabled",!0);var n=e(".search-form-wrapper .js-progress-indicator");n.length&&!isSafari&&n.addClass("loader"),o.submit()}),c.appendTo(r)}e("#search-suggestions-container").remove(),r.css({position:"absolute",cursor:"pointer","z-index:":"1"}),o.append(r)}):e("#search-suggestions-container").remove()}},s=function(e,o){return function(a){var t=a.keyCode?a.keyCode:a.which;27==t&&e.click(),13==t&&o.click()}},r=e("form#global-search"),i=r.find("button.search"),c=r.find("input").attr("autocomplete","off"),l=r.find(".close");i.on("click",a(r,c,l)),l.on("click",t(c,i,r)),r.on("keydown",s(l,i)),r.on("keyup",n(r,c,i)),c.focus(function(){e(".js-nav-search.search-variant").css("width","100%")}),c.blur(function(){0===c.val().length&&e(".js-nav-search.search-variant").css("width","50%")});var d=e("form.global-search-mobile"),h=d.find("button.search"),u=d.find("input").attr("autocomplete","off"),f=d.find(".close");h.on("click",a(d,u,f)),f.on("click",t(u,h,d)),d.on("keydown",s(f,h)),d.on("keyup",n(d,u,h))},resetSearch:function(){var o=e("form.global-search"),a=o.find("button.search"),t=o.find("input"),n=o.find("button.close");t.hide(),a.removeClass("active"),n.hide(),o.addClass("as-width").removeAttr("style")}};return o}($||jQuery);var loadSearch=function(){mindtools.global.nav?mindtools.global.search=new GlobalSearch(mindtools.global.nav):setTimeout(loadSearch,500)};loadSearch();