1(function(){if(window.__dyRemoteProductCardLoaded)return;window.__dyRemoteProductCardLoaded=!0;class RemoteProductCard extends HTMLElement{constructor(){super(),this.requestToken=null,this.lastLoadedKey=null,this.cacheTtl=180*1e3,this.maxCacheEntries=30}static get observedAttributes(){return["handle","variant-id"]}connectedCallback(){this.children.length||(this.dataset.dyState="loading"),this.loadCard()}attributeChangedCallback(name,oldValue,newValue){!this.isConnected||oldValue===newValue||(name==="handle"||name==="variant-id")&&this.loadCard()}get handle(){var handle=this.sanitizeToken(this.getAttribute("handle"));if(handle&&this.looksLikeHandle(handle))return handle;var url=this.getAttribute("data-dy-url")||this.getAttribute("url")||"",parts=url.split("/products/");if(parts.length<2)return null;var derived=this.sanitizeToken(parts[1].split("?")[0].split("/")[0]);return derived&&this.looksLikeHandle(derived)?derived:null}looksLikeHandle(value){return/^[a-zA-Z0-9._-]+$/.test(value)}nameCandidate(){return this.sanitizeToken(this.getAttribute("handle"))||this.sanitizeToken(this.getAttribute("data-dy-url"))||this.sanitizeToken(this.getAttribute("data-dy-name"))}resolveHandleByName(name){window.__dyHandleByName||(window.__dyHandleByName=new Map);var cache=window.__dyHandleByName;if(cache.has(name))return cache.get(name);var rootPath=window.Shopify&&Shopify.routes&&Shopify.routes.root?Shopify.routes.root:"/";rootPath.slice(-1)!=="/"&&(rootPath+="/");var url=rootPath+"search/suggest.json?q="+encodeURIComponent(name)+"&resources[type]=product&resources[limit]=1",request=fetch(url,{credentials:"same-origin"}).then(response=>response.json()).then(data=>{var products=data&&data.resources&&data.resources.results&&data.resources.results.products;return products&&products.length?products[0].handle:null}).catch(()=>null);return cache.set(name,request),request}get variantId(){var variantId=this.sanitizeToken(this.getAttribute("variant-id")||this.getAttribute("variantId"));return variantId&&/^\d+$/.test(variantId)?variantId:null}get sectionEndpoint(){var explicit=this.getAttribute("section-id"),host=this.closest("[data-dy-card-section]"),hostEndpoint=host&&host.dataset.dyCardSection,enforce=host&&host.dataset.dyEnforce==="true";return explicit&&!enforce?explicit:hostEndpoint||explicit||"dy-remote-product-card"}sanitizeToken(value){return!value||(value=value.trim(),!value||value.indexOf("${")!==-1||value==="undefined")?null:value}buildUrl(handle){var rootPath=window.Shopify&&Shopify.routes&&Shopify.routes.root?Shopify.routes.root:"/";rootPath.slice(-1)!=="/"&&(rootPath+="/");var url=rootPath+"products/"+encodeURIComponent(handle)+"?variant="+encodeURIComponent(this.variantId||"")+"§ion_id="+encodeURIComponent(this.sectionEndpoint);return url}getCacheStore(){return window.__dyRemoteProductCardCache||(window.__dyRemoteProductCardCache=new Map),window.__dyRemoteProductCardCache}getInFlightStore(){return window.__dyRemoteProductCardInFlight||(window.__dyRemoteProductCardInFlight=new Map),window.__dyRemoteProductCardInFlight}extractRenderedMarkup(text){var html=new DOMParser().parseFromString(text,"text/html"),sectionWrapper=html.querySelector('[id^="shopify-section-"]');return sectionWrapper?sectionWrapper.innerHTML:html.body?html.body.innerHTML:text}setCachedMarkup(cacheKey,markup){if(markup){var cacheStore=this.getCacheStore(),now=Date.now();cacheStore.forEach((entry,key)=>{(!entry||entry.expiresAt<now)&&cacheStore.delete(key)}),cacheStore.set(cacheKey,{markup,expiresAt:now+this.cacheTtl}),cacheStore.size>this.maxCacheEntries&&cacheStore.delete(cacheStore.keys().next().value)}}getCachedMarkup(cacheKey){var cacheStore=this.getCacheStore(),cached=cacheStore.get(cacheKey);return cached?cached.expiresAt<Date.now()?(cacheStore.delete(cacheKey),null):cached.markup:null}renderCardMarkup(markup,requestKey){this.isConnected&&(this.innerHTML=markup,this.dataset.dyState="ready",this.applyVariantToLink(),this.lastLoadedKey=requestKey,this.dispatchEvent(new CustomEvent("remote-product-card:loaded",{bubbles:!0,detail:{handle:this.__resolvedHandle||this.handle,variantId:this.variantId||null}})))}applyVariantToLink(){if(this.variantId){var productLink=this.querySelector(".grid-product__link");if(productLink)try{var nextUrl=new URL(productLink.getAttribute("href"),window.location.origin);nextUrl.searchParams.set("variant",this.variantId),productLink.setAttribute("href",nextUrl.pathname+nextUrl.search+nextUrl.hash)}catch(error){console.error(error)}}}loadCard(){var handle=this.handle;if(handle){this.fetchCard(handle);return}var name=this.nameCandidate();if(!name){this.dataset.dyState="error";return}this.resolveHandleByName(name).then(resolved=>{this.isConnected&&(resolved?this.fetchCard(resolved):this.dataset.dyState="error")})}fetchCard(handle){this.__resolvedHandle=handle;var requestKey=handle+"::"+(this.variantId||"");if(!(this.lastLoadedKey===requestKey&&this.children.length)){var requestUrl=this.buildUrl(handle),fresh=this.hasAttribute("data-fresh"),inFlightKey=fresh?requestUrl+"::fresh":requestUrl;if(!fresh){var cachedMarkup=this.getCachedMarkup(requestUrl);if(cachedMarkup){this.renderCardMarkup(cachedMarkup,requestKey);return}}var token=Date.now()+"-"+Math.random();this.requestToken=token;
1var inFlightStore=this.getInFlightStore(),inFlightRequest=inFlightStore.get(inFlightKey);inFlightRequest||(inFlightRequest=fetch(requestUrl,{credentials:"same-origin",cache:fresh?"reload":"force-cache"}).then(response=>response.text()).then(text=>{var renderedMarkup=this.extractRenderedMarkup(text);return fresh||this.setCachedMarkup(requestUrl,renderedMarkup),inFlightStore.delete(inFlightKey),renderedMarkup}).catch(error=>{throw inFlightStore.delete(inFlightKey),error}),inFlightStore.set(inFlightKey,inFlightRequest)),inFlightRequest.then(renderedMarkup=>{this.requestToken===token&&this.renderCardMarkup(renderedMarkup,requestKey)}).catch(error=>{this.dataset.dyState="error",console.error(error)})}}}customElements.get("remote-product-card")||customElements.define("remote-product-card",RemoteProductCard)})(); 2//# sourceMappingURL=/cdn/shop/t/615/assets/dy-remote-product-card.js.map?v=49775258479886702071790289964
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.