1function _typeof(a){"@babel/helpers - typeof";return _typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a2){return typeof a2}:function(a2){return a2&&typeof Symbol=="function"&&a2.constructor===Symbol&&a2!==Symbol.prototype?"symbol":typeof a2},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return _typeof(b)==="symbol"?b:b+""}function _toPrimitive(a,b){if(_typeof(a)!=="object"||a===null)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if(_typeof(d)!=="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(b==="string"?String:Number)(a)}function _get(){return _get=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(a,b,c){var d=_superPropBase(a,b);if(d){var e=Object.getOwnPropertyDescriptor(d,b);return e.get?e.get.call(3>arguments.length?a:c):e.value}},_get.apply(this,arguments)}function _superPropBase(a,b){for(;!Object.prototype.hasOwnProperty.call(a,b)&&(a=_getPrototypeOf(a),a!==null););return a}function _inherits(a,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a2,b2){return a2.__proto__=b2,a2},_setPrototypeOf(a,b)}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _possibleConstructorReturn(a,b){if(b&&(_typeof(b)==="object"||typeof b=="function"))return b;if(b!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(a)}function _assertThisInitialized(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _isNativeReflectConstruct(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a2){return a2.__proto__||Object.getPrototypeOf(a2)},_getPrototypeOf(a)}var PredictiveSearch=(function(a){function b(){var a2;return _classCallCheck(this,b),a2=c.call(this),a2.cachedResults={},a2.predictiveSearchResults=a2.querySelector("[data-predictive-search]"),a2.allPredictiveSearchInstances=document.querySelectorAll("predictive-search"),a2.isOpen=!1,a2.abortController=new AbortController,a2.searchTerm="",a2.setupEventListeners(),a2}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"setupEventListeners",value:function(){this.input.form.addEventListener("submit",this.onFormSubmit.bind(this)),this.input.addEventListener("focus",this.onFocus.bind(this)),this.addEventListener("focusout",this.onFocusOut.bind(this)),this.addEventListener("keyup",this.onKeyup.bind(this)),this.addEventListener("keydown",this.onKeydown.bind(this))}},{key:"getQuery",value:function(){return this.input.value.trim()}},{key:"onChange",value:function(){_get(_getPrototypeOf(b.prototype),"onChange",this).call(this);var a2=this.getQuery();if(!this.searchTerm||!a2.startsWith(this.searchTerm)){var c2;(c2=this.querySelector("#predictive-search-results-groups-wrapper"))===null||c2===void 0||c2.remove()}return this.updateSearchForTerm(this.searchTerm,a2),this.searchTerm=a2,this.searchTerm.length?void this.get
1SearchResults(this.searchTerm):void this.close(!0)}},{key:"onFormSubmit",value:function(a2){(!this.getQuery().length||this.querySelector('[aria-selected="true"] a'))&&a2.preventDefault()}},{key:"onFormReset",value:function(a2){_get(_getPrototypeOf(b.prototype),"onFormReset",this).call(this,a2),_get(_getPrototypeOf(b.prototype),"shouldResetForm",this).call(this)&&(this.searchTerm="",this.abortController.abort(),this.abortController=new AbortController,this.closeResults(!0))}},{key:"onFocus",value:function(){var a2=this.getQuery();a2.length&&(this.searchTerm===a2?this.getAttribute("results")==="true"?this.open():this.getSearchResults(this.searchTerm):this.onChange())}},{key:"onFocusOut",value:function(){var a2=this;setTimeout(function(){a2.contains(document.activeElement)||a2.close()})}},{key:"onKeyup",value:function(a2){switch(this.getQuery().length||this.close(!0),a2.preventDefault(),a2.code){case"ArrowUp":this.switchOption("up");break;case"ArrowDown":this.switchOption("down");break;case"Enter":this.selectOption()}}},{key:"onKeydown",value:function(a2){(a2.code==="ArrowUp"||a2.code==="ArrowDown")&&a2.preventDefault()}},{key:"updateSearchForTerm",value:function(a2,b2){var c2=this.querySelector("[data-predictive-search-search-for-text]"),d=c2==null?void 0:c2.innerText;if(d){if(1<d.match(new RegExp(a2,"g")).length)return;var e=d.replace(a2,b2);c2.innerText=e}}},{key:"switchOption",value:function(a2){if(this.getAttribute("open")){var b2=a2==="up",c2=this.querySelector('[aria-selected="true"]'),d=Array.from(this.querySelectorAll("li, button.predictive-search__item")).filter(function(a3){return a3.offsetParent!==null}),e=0;if(!b2||c2){for(var f=-1,g=0;f===-1&&g<=d.length;)d[g]===c2&&(f=g),g++;if(this.statusElement.textContent="",!b2&&c2?e=f===d.length-1?0:f+1:b2&&(e=f===0?d.length-1:f-1),e!==f){var h=d[e];h.setAttribute("aria-selected",!0),c2&&c2.setAttribute("aria-selected",!1),this.input.setAttribute("aria-activedescendant",h.id)}}}}},{key:"selectOption",value:function(){var a2=this.querySelector('[aria-selected="true"] a, button[aria-selected="true"]');a2&&a2.click()}},{key:"getSearchResults",value:function(a2){var b2=this,c2=a2.replace(" ","-").toLowerCase();if(this.setLiveRegionLoadingState(),this.cachedResults[c2]){this.renderSearchResults(this.cachedResults[c2]);var d=this.dispatchSearchUpdateEvent(a2);return void(d==null||d.resolve({totalCount:this.getTotalResultCount()}))}var e=this.dispatchSearchUpdateEvent(a2);fetch("".concat(routes.predictive_search_url,"?q=").concat(encodeURIComponent(a2),"§ion_id=predictive-search&resources[options][fields]=variants.sku,title,product_type,variants.title,vendor"),{signal:this.abortController.signal}).then(function(a3){if(!a3.ok){var c3=new Error(a3.status);throw b2.close(),c3}return a3.text()}).then(function(a3){var d2=new DOMParser().parseFromString(a3,"text/html").querySelector("#shopify-section-predictive-search").innerHTML;b2.allPredictiveSearchInstances.forEach(function(a4){a4.cachedResults[c2]=d2}),b2.renderSearchResults(d2),e==null||e.resolve({totalCount:b2.getTotalResultCount()})}).catch(function(a3){if((a3==null?void 0:a3.code)===20)return void(e==null||e.reject(a3));throw e==null||e.reject(a3),b2.close(),a3})}},{key:"getTotalResultCount",value:function(){var a2;return parseInt((a2=this.predictiveSearchResults.querySelector("[data-total-results]"))===null||a2===void 0?void 0:a2.dataset.totalResults)||0}},{key:"dispatchSearchUpdateEvent",value:function(a2){var b2=window.StandardEvents||{},c2=b2.SearchUpdateEvent;if(!c2)return null;var d=c2.createPromise();return this.dispatchEvent(new c2({search:{query:a2},promise:d.promise})),d}},{key:"setLiveRegionLoadingState",value:function(){this.statusElement=this.statusElement||this.querySelector(".predictive-search-status"),this.loadingText=this.loadingText||this.getAttribute("data-loading-text"),this.setLiveRegionText(this.loadingText),this.setAttribute("loading",!0)}},{key:"setLiveRegionText",value:function(a2){var b2=this;this.statusElement.setAttribute("aria-hidden","false"),this.statusElement.textContent=a2,setTimeout(function(){b2.statusElement.setAttribute("aria-hidden","true")},1e3)}},{key:"renderSearchResults",value:function(a2){this.predictiveSearchResults.innerHTML=a2,this.setAttribute("results",!0),this.setLiveRegionResults(),this.open()}},{key:"setLiveRegionResults",value:function(){var a2;this.removeAttribute("loading"),this.setLiveRegionText((a2=this.querySelector("[data-predictive-search-live-region-count-value]"))===null||a2===void 0?void 0:a2.textContent)}},{key:"getResultsMaxHeight",value:function(){var a2;return this.resultsMaxHeight=window.innerHeight-((a2=document.querySelector(".section-header"))===null||a2===void 0?void 0:a2.getBoundingClientRect().bottom),this.resultsMaxHeight}},{key:"open",value:function(){this.predictiveSearchResults.style.maxHeight=this.resultsMaxHeight||"".concat(this.getResultsMaxHeight(),"px"),this.setAttribute("open",!0),this.input.setAttribute("aria-expanded",!0),this.isOpen=!0}},{key:"close",value:function(){var a2=0<arguments.length&&arguments[0]!==void 0&&arguments[0];this.closeResults(a2),this.isOpen=!1}},{key:"closeResults",value:function(){var a2=0<arguments.length&&arguments[0]!==void 0&&arguments[0];a2&&(this.input.value="",this.removeAttribute("results"));var b2=this.querySelector('[aria-selected="true"]');b2&&b2.setAttribute("aria-selected",!1),this.input.setAttribute("aria-activedescendant",""),this.removeAttribute("loading"),this.removeAttribute("open"),this.input.setAttribute("aria-expanded",!1),this.resultsMaxHeight=!1,this.predictiveSearchResults.removeAttribute("style")}}]),b})(SearchForm);customElements.define("predictive-search",PredictiveSearch); 2//# sourceMappingURL=/cdn/shop/t/100/assets/predictive-search.js.map?v=93797631325758422491790755739
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.