1export default class AjaxRenderer{constructor({sections,onReplace,debug}={}){this.sections=sections||[],this.cachedSections=[],this.onReplace=onReplace,this.debug=!!debug}renderPage(basePath,newParams,updateURLHash=!0){const currentParams=new URLSearchParams(window.location.search),updatedParams=this.getUpdatedParams(currentParams,newParams),sectionRenders=this.sections.map(section=>{const url=`${basePath}?section_id=${section.sectionId}&${updatedParams.toString()}`,cachedSectionUrl=cachedSection=>cachedSection.url===url;return this.cachedSections.some(cachedSectionUrl)?this.renderSectionFromCache(cachedSectionUrl,section):this.renderSectionFromFetch(url,section)});return updateURLHash&&this.updateURLHash(updatedParams),Promise.all(sectionRenders)}renderSectionFromCache(url,section){const cachedSection=this.cachedSections.find(url);return this.log(`[AjaxRenderer] rendering from cache: url=${cachedSection.url}`),this.renderSection(cachedSection.html,section),Promise.resolve(section)}renderSectionFromFetch(url,section){return this.log(`[AjaxRenderer] redering from fetch: url=${url}`),new Promise((resolve,reject)=>{fetch(url).then(response=>response.text()).then(responseText=>{const html=responseText;this.cachedSections=[...this.cachedSections,{html,url}],this.renderSection(html,section),resolve(section)}).catch(err=>reject(err))})}renderSection(html,section){this.log(`[AjaxRenderer] rendering section: section=${JSON.stringify(section)}`);const newDom=new DOMParser().parseFromString(html,"text/html");if(this.onReplace)this.onReplace(newDom,section);else if(typeof section.nodeId=="string"){var newContentEl=newDom.getElementById(section.nodeId);if(!newContentEl)return;document.getElementById(section.nodeId).innerHTML=newContentEl.innerHTML}else section.nodeId.forEach(id=>{document.getElementById(id).innerHTML=newDom.getElementById(id).innerHTML});return section}getUpdatedParams(currentParams,newParams){const clone=new URLSearchParams(currentParams),preservedParams=["sort_by","q","options[prefix]","type"];for(const[key,value]of clone.entries())!newParams.getAll(key).includes(value)&&!preservedParams.includes(key)&&(clone.delete(key),key==="filter.v.price.gte"&&clone.delete("filter.v.price.lte"));for(const[key,value]of newParams.entries())!clone.getAll(key).includes(value)&&value!==""&&clone.append(key,value);return clone}updateURLHash(searchParams){history.pushState({},"",`${window.location.pathname}${searchParams&&"?".concat(searchParams)}`)}log(...args){this.debug&&console.log(...args)}} 2//# sourceMappingURL=/cdn/shop/t/59/assets/util.ajax-renderer.js.map?v=97870815632261419761777974956
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.