1class CollectionScrollPosition{constructor(){this.lastClickedItemHrefKey="collectionScrollPosition-lastClickedItemHref",this.lastClickedItemHref=sessionStorage.getItem(this.lastClickedItemHrefKey),this.lastVisitedUrlsKey="collectionScrollPosition-lastVisitedCollectionUrl",this.lastVisitedUrls=sessionStorage.getItem(this.lastVisitedUrlsKey),this.currentUrl=this.urlToPathName(window.location.href),this.init()}init(){this.currentUrl.includes("/collections/")?this.handleCollectionTemplate():this.currentUrl.includes("/products/")?this.handleProductTemplate():this.clearData()}handleCollectionTemplate(){this.updateLastVisistedUrls(this.currentUrl),"scrollRestoration"in history&&(history.scrollRestoration="manual"),this.lastVisitedCollectionUrl===this.currentUrl&&this.clearData(),this.restoreScrollPosition(),this.captureScrollPosition()}handleProductTemplate(){this.updateLastVisistedUrls(this.currentUrl)}restoreScrollPosition(){this.lastClickedItemHref&&this.lastClickedItemHref!=="undefined"&&document.querySelector(`a[href="${this.lastClickedItemHref}"]`)?.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})}captureScrollPosition(){window.addEventListener("click",e=>{const targetElement=e.target;if(targetElement.getAttribute("href"))this.lastClickedItemHref=targetElement.getAttribute("href");else{const closestAnchor=targetElement.closest("a");closestAnchor&&closestAnchor.getAttribute("href")&&(this.lastClickedItemHref=closestAnchor.getAttribute("href"))}}),window.addEventListener("beforeunload",()=>{sessionStorage.setItem(this.lastClickedItemHrefKey,this.lastClickedItemHref?.toString())})}updateLastVisistedUrls(url){const array=this.lastVisitedUrls?[...JSON.parse(this.lastVisitedUrls)]:[];array.push(url);const lastItem=array[array.length-1],secondToLastItem=array[array.length-2];lastItem===secondToLastItem?this.clearData():lastItem?.includes("/collections/")&&secondToLastItem?.includes("/collections/")?this.clearData():sessionStorage.setItem(this.lastVisitedUrlsKey,JSON.stringify(array))}clearData(){sessionStorage.removeItem(this.lastClickedItemHrefKey),sessionStorage.removeItem(this.lastVisitedUrlsKey),this.lastClickedItemHref=null,this.lastVisitedUrls=null}urlToPathName(url){return new URL(url).pathname}}document.addEventListener("DOMContentLoaded",()=>{window.BAO.collectionScrollPosition=new CollectionScrollPosition}); 2//# sourceMappingURL=/cdn/shop/t/291/assets/collection-scroll-position.js.map?v=45414018988964468051761906978
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.