PageSourceSearch

https://aiayu.com/cdn/shop/t/10/assets/hello-retail-search.js?v=118761618411169399451777026001

js aiayu.com collected 2026-09-25 18:42:17 UTC 5,046 bytes, 2 lines download raw bytes

1(function(){"use strict";function HelloRetailSearchOverlay(){this.api=new window.HelloRetailAPI,this.inputEl=document.querySelector('#predictive-search-form input[name="q"]'),this.resultsEl=document.querySelector("#header-predictive-search .hr-search-results"),this._debounceTimer=null,this._recomGen=0,this._lastSuccessfulSearchQuery=null}HelloRetailSearchOverlay.prototype._syncPlaceholder=function(){var mobile=this.inputEl.dataset.placeholderMobile,desktop=this.inputEl.dataset.placeholderDesktop;!mobile&&!desktop||(this.inputEl.placeholder=window.matchMedia("(min-width: 1000px)").matches?desktop||mobile:mobile||desktop)},HelloRetailSearchOverlay.prototype.init=function(){if(!(!this.inputEl||!this.resultsEl)){this._syncPlaceholder(),window.addEventListener("resize",this._syncPlaceholder.bind(this)),this.inputEl.addEventListener("input",this._onInput.bind(this));var form=this.inputEl.form;form&&form.addEventListener("submit",this._onPredictiveFormSubmit.bind(this));var dialogEl=this.inputEl.closest("header-search");dialogEl&&(dialogEl.addEventListener("dialog:after-show",function(){this.inputEl.value.trim()||this._fetch("*")}.bind(this)),dialogEl.addEventListener("dialog:after-hide",function(){this.resultsEl.innerHTML="",this.inputEl.value="",this._lastSuccessfulSearchQuery=null,clearTimeout(this._debounceTimer)}.bind(this)))}},HelloRetailSearchOverlay.prototype._onPredictiveFormSubmit=function(){!this.inputEl.value.trim()&&this._lastSuccessfulSearchQuery==="*"&&(this.inputEl.value="*")},HelloRetailSearchOverlay.prototype._onInput=function(){clearTimeout(this._debounceTimer);var query=this.inputEl.value.trim();if(!query){this._debounceTimer=setTimeout(this._fetch.bind(this,"*"),280);return}this._debounceTimer=setTimeout(this._fetch.bind(this,query),280)},HelloRetailSearchOverlay.prototype._fetch=function(query){var self=this;this._recomGen++,this.api.search(query).then(function(data){self._render(data,query)}).catch(function(e){console.error("[HR Search] Error:",e.message)})},HelloRetailSearchOverlay.prototype._render=function(data,query){var H=window.HelloRetailHelpers,products=data&&data.result?data.result:[];if(!products.length){this._lastSuccessfulSearchQuery=null,query!=="*"&&(this.resultsEl.innerHTML='<p class="predictive-search__no-results text-lg">No results for &ldquo;'+H.escapeHtml(query)+"&rdquo;</p>",this._fetchRecoms(query,!1));return}var grid=H.cloneTemplate("hr-search-results-tpl");if(grid){if(query!=="*"){var tpl=document.getElementById("hr-search-results-tpl"),labelEl=grid.querySelector('[data-hr-slot="resultsLabel"]'),totalCount=data&&data.product_results||products.length;labelEl&&(labelEl.textContent=(tpl&&tpl.dataset.productsLabel||"Products")+" ("+totalCount+")"),totalCount>6&&grid.querySelectorAll(".hr-view-all").forEach(function(btn){btn.removeAttribute("hidden")})}var self=this,cardsContainer=grid.querySelector('[data-hr-slot="cardsContainer"]');products.forEach(function(product){var card=self._renderProductCard(product);card&&cardsContainer.appendChild(card)}),this.resultsEl.innerHTML="",this.resultsEl.appendChild(grid),this._lastSuccessfulSearchQuery=query,query!=="*"&&this._fetchRecoms(query,!0)}},HelloRetailSearchOverlay.prototype._renderProductCard=function(product){var H=window.HelloRetailHelpers,card=H.cloneTemplate("hr-product-card-tpl");return card?(H.fillSlots(card,H.CARD_SLOT_FILLERS,product),card):null},HelloRetailSearchOverlay.prototype._fetchRecoms=function(query,hasResults){var settings=window.themeVariables&&window.themeVariables.settings,key=hasResults?settings&&settings.hrSearchRelatedKey:settings&&settings.hrSearchPopularKey;if(key){var self=this,gen=this._recomGen;this.api.loadRecom(key).then(function(recom){if(self._recomGen===gen){var products=recom&&recom.products;if(!(!products||!products.length)){var tpl=document.getElementById("hr-search-recoms-tpl"),label=hasResults?tpl&&tpl.dataset.youMightLike||"You might also like":tpl&&tpl.dataset.popularProducts||"Popular products";self._renderRecoms(products,label)}}}).catch(function(e){console.error("[HR Search] Recom error:",e.message)})}},HelloRetailSearchOverlay.prototype._renderRecoms=function(products,label){var H=window.HelloRetailHelpers,section=H.cloneTemplate("hr-search-recoms-tpl");if(section){var labelEl=section.querySelector('[data-hr-slot="recomsLabel"]'),container=section.querySelector('[data-hr-slot="recomsContainer"]');labelEl&&(labelEl.textContent=label);var self=this;
1products.forEach(function(product){var card=self._renderProductCard(product);card&&container.appendChild(card)}),this.resultsEl.appendChild(section)}},document.addEventListener("DOMContentLoaded",function(){if(!window.HelloRetailAPI||!window.HelloRetailHelpers){console.warn("[HR Search] hello-retail-helpers.js and hello-retail-api.js must load before hello-retail-search.js");return}new HelloRetailSearchOverlay().init()}),window.HelloRetailSearchOverlay=HelloRetailSearchOverlay})();
2//# sourceMappingURL=/cdn/shop/t/10/assets/hello-retail-search.js.map?v=118761618411169399451777026001

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.