PageSourceSearch

https://wearebraindead.com/cdn/shop/t/153/assets/predictive-search.js?v=125761655599445339261790286293

js wearebraindead.com collected 2026-10-02 03:44:24 UTC 8,497 bytes, 1 lines download raw bytes

vendor: 1,647 bytes, line 1
1!function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function n(e,n){if(n&&("object"===t(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(e)}function i(t){var e="function"==typeof Map?new Map:void 0;return i=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return r(t,arguments,u(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),s(i,t)},i(t)}function r(t,e,n){return r=o()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);var r=new(Function.bind.apply(t,i));return n&&s(r,n.prototype),r},r.apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}
1function s(t,e){return s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},s(t,e)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}var c=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&s(t,e)}(d,t);var i,r,c,a,l,h=(i=d,r=o(),function(){var t,e=u(i);if(r){var o=u(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return n(this,t)});function d(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,d),(t=h.call(this)).cachedResults={},t.input=t.querySelector('input[type="search"]'),t.predictiveSearchResults=t.querySelector("[data-predictive-search]"),t.statusElement=t.querySelector("[data-predictive-status]"),t.closeButton=t.querySelector("[data-close]"),t.isOpen=!1,t.setupEventListeners(),t}return c=d,a=[{key:"setupEventListeners",value:function(){var t,e=this;this.querySelector("form._search").addEventListener("submit",this.onFormSubmit.bind(this)),this.input.addEventListener("change",(function(t){setTimeout((function(){}),300)})),this.input.addEventListener("input",(function(t){setTimeout((function(){e.onChange(t)}),300)})),this.input.addEventListener("focus",this.onFocus.bind(this)),this.input.addEventListener("keyup",this.onChange.bind(this)),this.addEventListener("focusout",this.onFocusOut.bind(this)),this.addEventListener("keyup",this.onKeyup.bind(this)),this.addEventListener("keydown",this.onKeydown.bind(this)),null===(t=this.closeButton)||void 0===t||t.addEventListener("click",this.closeButtonEvent.bind(this))}},{key:"getQuery",value:function(){return this.input.value.trim()}},{key:"onChange",value:function(){var t=this.getQuery();t.length?this.getSearchResults(t):this.close(!0)}},{key:"onFormSubmit",value:function(t){this.getQuery().length&&!this.querySelector('[aria-selected="true"] a')||t.preventDefault()}},{key:"onFocus",value:function(){var t=this.getQuery();t.length&&("true"===this.getAttribute("results")?this.open():this.getSearchResults(t))}},{key:"onFocusOut",value:function(){var t=this;setTimeout((function(){t.contains(document.activeElement)||t.close()}))}},{key:"onKeyup",value:function(t){switch(this.getQuery().length||this.close(!0),t.preventDefault(),t.code){case"ArrowUp":this.switchOption("up");break;case"ArrowDown":this.switchOption("down");break;case"Enter":var e;this.selectOption()||(null===(e=document.querySelector("[data-search-all]"))||void 0===e||e.click(),this.triggerClose())}}},{key:"onKeydown",value:function(t){"ArrowUp"!==t.code&&"ArrowDown"!==t.code||t.preventDefault()}},{key:"switchOption",value:function(t){if(this.getAttribute("open")){var e="up"===t,n=this.querySelector('[aria-selected="true"]'),i=this.querySelectorAll("li"),r=this.querySelector("li");e&&!n||(this.statusElement.textContent="",!e&&n?r=n.nextElementSibling||i[0]:e&&(r=n.previousElementSibling||i[i.length-1]),r!==n&&(r.setAttribute("aria-selected",!0),n&&n.setAttribute("aria-selected",!1),this.setLiveRegionText(r.textContent),this.input.setAttribute("aria-activedescendant",r.id)))}}},{key:"selectOption",value:function(){var t=this.querySelector('[aria-selected="true"] a, [aria-selected="true"] button');return!!t&&(t.click(),!0)}},{key:"getSearchResults",value:function(t){var e=this,n=t.replace(" ","-").toLowerCase();this.setLiveRegionLoadingState(),this.updateHeight(),this.cachedResults[n]?this.renderSearchResults(this.cachedResults[n]):fetch("".concat(routes.predictive_search_url,"?q=").concat(encodeURIComponent(t),"&resources[type]=").concat(settings.search_mode,"&section_id=predictive-search")).then((function(t){if(!t.ok){var n=new Error(t.status);throw e.close(),n}return t.text()})).then((function(t){var i=(new DOMParser).parseFromString(t,"text/html").querySelector("#shopify-section-predictive-search").innerHTML;
1e.cachedResults[n]=i,e.renderSearchResults(i)})).catch((function(t){throw e.close(),t}))}},{key:"setLiveRegionLoadingState",value:function(){this.loadingText=this.loadingText||this.getAttribute("data-loading-text"),this.setLiveRegionText(this.loadingText),this.setAttribute("loading",!0)}},{key:"setLiveRegionText",value:function(t){var e=this;this.statusElement.setAttribute("aria-hidden","false"),this.statusElement.textContent=t,setTimeout((function(){e.statusElement.setAttribute("aria-hidden","true")}),1e3)}},{key:"renderSearchResults",value:function(t){var e=this;this.predictiveSearchResults.innerHTML=t,this.setAttribute("results",!0);var n=this.querySelectorAll("li");n&&n.length?document.querySelector("[data-search-all]").setAttribute("open",!0):document.querySelector("[data-search-all]").removeAttribute("open"),t&&setTimeout((function(){return e.updateHeight()}),100),this.setLiveRegionResults(),this.open()}},{key:"setLiveRegionResults",value:function(){this.removeAttribute("loading"),this.setLiveRegionText(this.querySelector("[data-predictive-search-live-region-count-value]").textContent)}},{key:"getResultsMaxHeight",value:function(){return window.matchMedia("(max-width: 768px)").matches?(this.resultsMaxHeight=window.innerHeight-document.getElementById("shopify-section-header-logo").getBoundingClientRect().height-220,this.resultsMaxHeight):(this.resultsMaxHeight=420,this.resultsMaxHeight)}},{key:"open",value:function(){this.predictiveSearchResults.style.maxHeight=this.resultsMaxHeight||"".concat(this.getResultsMaxHeight(),"px"),this.predictiveSearchResults.setAttribute("open",!0),this.setAttribute("open",!0),this.statusElement.setAttribute("open",!0),this.input.setAttribute("aria-expanded",!0),this.isOpen=!0}},{key:"closeButtonEvent",value:function(t){t.preventDefault(),this.close(!0)}},{key:"close",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t&&(this.input.value="",this.removeAttribute("results"));var e=this.querySelector('[aria-selected="true"]');e&&e.setAttribute("aria-selected",!1),this.input.setAttribute("aria-activedescendant",""),this.removeAttribute("open"),this.input.setAttribute("aria-expanded",!1),this.resultsMaxHeight=!1,this.isOpen=!1}},{key:"updateHeight",value:function(){var t;this.dataset.dropdownKey&&(null===(t=this.closest("dropdown-element"))||void 0===t||t.dispatchEvent(new CustomEvent("dropdownUpdate",{detail:{key:this.dataset.dropdownKey}})))}},{key:"triggerClose",value:function(){var t;null===(t=this.closest("dropdown-element"))||void 0===t||t.dispatchEvent(new CustomEvent("dropdownClose"))}}],a&&e(c.prototype,a),l&&e(c,l),Object.defineProperty(c,"prototype",{writable:!1}),d}(i(HTMLElement));customElements.define("predictive-search",c)}();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.