PageSourceSearch

https://boldbeanco.com/cdn/shop/t/106/assets/exclusive-loyalty-content.js?v=14917558626147172141788857924

js boldbeanco.com collected 2026-09-25 19:44:39 UTC 15,088 bytes, 29 lines download raw bytes

1typeof window.recipeSwiperInitialised>"u"&&(window.recipeSwiperInitialised=!1,window.merchSwiperInitialised=!1);const openReadMoreOverlay=(overlayContainers,targetProductName)=>{overlayContainers.forEach(overlayContainer=>{overlayContainer.dataset.productName==targetProductName&&(overlayContainer.querySelector(".loyalty-product__read-more-overlay").style.display="block",overlayContainer.querySelector(".loyalty-product__read-more-overlay-bg").style.display="block")})},bindReadMoreOverlays=()=>{const readMoreContainers=document.querySelectorAll(".loyalty-product-card__read-more-container");if(readMoreContainers){const overlayContainers=document.querySelectorAll(".skio-loyalty-rewards__product-overlays .loyalty-product__read-more-overlay-container");overlayContainers&&(readMoreContainers.forEach(readMoreContainer=>{const trigger=readMoreContainer.querySelector(".loyalty-product-card__read-more-trigger");if(trigger){const targetProductName=trigger.dataset.productTitle;if(targetProductName){trigger.addEventListener("click",()=>{openReadMoreOverlay=openReadMoreOverlay(overlayContainers,targetProductName)});const cardContainer=trigger.closest(".loyalty-product-card");if(cardContainer){const productCardImage=cardContainer.querySelector(".loyalty-product-card__image");productCardImage&&productCardImage.addEventListener("click",()=>{openReadMoreOverlay=openReadMoreOverlay(overlayContainers,targetProductName)});const productTitle=cardContainer.querySelector(".loyalty-product-card__content-header-title");productTitle&&productTitle.addEventListener("click",()=>{openReadMoreOverlay=openReadMoreOverlay(overlayContainers,targetProductName)})}}}}),overlayContainers.forEach(overlayContainer=>{const overlay=overlayContainer.querySelector(".loyalty-product__read-more-overlay"),overlayBg=overlayContainer.querySelector(".loyalty-product__read-more-overlay-bg");if(overlay&&overlayBg){overlayBg.addEventListener("click",()=>{overlayBg.style.display="none",overlay.style.display="none"});const closeButton=overlay.querySelector(".loyalty-product__read-more-overlay-close");closeButton&&closeButton.addEventListener("click",()=>{overlayBg.style.display="none",overlay.style.display="none"})}}))}};class SkioSDK{constructor({domain,debug}={domain:null,debug:!1}){this.domain=domain,this.debug=debug,this.storefrontUser={id:null,idToken:null,accessToken:null,refreshToken:null,firstName:null,lastName:null,createdAt:null,email:null},this.localStorageKeys={idToken:null,accessToken:null,refreshToken:null},this.clientId=null,this.init()}init(){if(this.log("Initializing Skio"),!this.domain){this.debug=!0,this.error("Domain is required");return}this.checkLogin()}checkLogin(){for(const[key,value]of Object.entries(window.localStorage))key==="storefrontUserFirstName"&&(this.storefrontUser.firstName=JSON.parse(value)),key==="storefrontUserLastName"&&(this.storefrontUser.lastName=JSON.parse(value)),key==="storefrontUserEmail"&&(this.storefrontUser.email=JSON.parse(value)),key.includes("CognitoIdentityServiceProvider")&&(key.includes("idToken")&&(this.localStorageKeys.idToken=key,this.storefrontUser.idToken=value),key.includes("accessToken")&&(this.localStorageKeys.accessToken=key,this.storefrontUser.accessToken=value),key.includes("refreshToken")&&(this.localStorageKeys.refreshToken=key,this.storefrontUser.refreshToken=value),this.clientId=key.split(".")[1]);return this.storefrontUser.id=JSON.parse(window.localStorage.getItem("storefrontUserId")),!!this.storefrontUser.idToken}log(...args){this.debug&&(args.unshift("%c[SkioSDK]","color: #8770f2;"),console.log.apply(console,args))}error(...args){this.debug&&(args.unshift("%c [SkioSDK]","color: #ff0000"),console.error.apply(console,args))}isCustomerLoggedIntoShopify(){return!!window.ShopifyAnalytics?.meta?.page?.customer_id}isCustomerLoggedIntoSkio(){return!!this.storefrontUser.id}async getNewToken(){let data={AuthFlow:"REFRESH_TOKEN_AUTH",AuthParameters:{REFRESH_TOKEN:this.storefrontUser.refreshToken},ClientId:this.clientId};try{const responseData=await(await fetch("https://cognito-idp.us-west-2.amazonaws.com/",{method:"POST",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"AWSCognitoIdentityProvi
1derService.InitiateAuth"},body:JSON.stringify(data)})).json(),accessToken=responseData.AuthenticationResult.AccessToken,idToken=responseData.AuthenticationResult.IdToken;return this.storefrontUser.accessToken=accessToken,this.storefrontUser.idToken=idToken,window.localStorage.setItem(this.localStorageKeys.accessToken,accessToken),window.localStorage.setItem(this.localStorageKeys.idToken,idToken),!0}catch(error){throw error}}async request(data){if(!this.storefrontUser.idToken){this.error("User is not logged in");return}try{let responseData=await(await fetch("https://graphql.skio.com/v1/graphql",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+this.storefrontUser.idToken,userpoolid:"us-west-2_ky2hNEMAZ",region:"us-west-2"},body:JSON.stringify(data)})).json();if(responseData.errors){if(responseData.errors[0].message=="Invalid response from authorization hook"||responseData.errors[0].message=="Authentication hook unauthorized this request")return this.log("Auth Error: refreshing tokens..."),await this.getNewToken(this.clientId,this.storefrontUser.refreshToken),await this.request(data);throw responseData.errors}return responseData}catch(error){throw error}}async getCreditBalance(){this.log("Fetching credit balance information...");try{const response=await fetch("https://api.skio.com/storefront-v2-http/get-credit-balance",{method:"POST",body:JSON.stringify({token:this.storefrontUser.idToken,region:"us-west-2",userPoolId:"us-west-2_ky2hNEMAZ"})}),data=await response.json();if(!response.ok){if(data.msg=="jwt expired")return this.log("JWT expired, refreshing tokens..."),await this.getNewToken(),await this.getCreditBalance();throw new Error(`Failed to get credit balance ${data.msg}`)}return data}catch(error){throw error}}async getSiteCreditRewards(){this.log("Fetching site credit rewards information...");try{const response=await fetch("https://api.skio.com/storefront-v2-http/get-site-credit-rewards",{method:"POST",body:JSON.stringify({domain:this.domain})}),data=await response.json();if(!response.ok){if(data.msg=="jwt expired")return this.log("JWT expired, refreshing tokens..."),await this.getNewToken(),await this.get
1SiteCreditRewards();throw new Error("Failed to get site credit rewards")}return data}catch(error){throw error}}async getCustomerRewardState(){this.log("Fetching customer reward state information...");try{const response=await fetch("https://api.skio.com/storefront-v2-http/get-customer-reward-state",{method:"POST",body:JSON.stringify({token:this.storefrontUser.idToken,region:"us-west-2",userPoolId:"us-west-2_ky2hNEMAZ"})}),data=await response.json();if(!response.ok){if(data.msg=="jwt expired")return this.log("JWT expired, refreshing tokens..."),await this.getNewToken(),await this.getCustomerRewardState();throw new Error("Failed to get customer reward state")}return data}catch(error){throw error}}async getSiteTierRewards(){this.log("Fetching site tier rewards information...");try{const response=await fetch("https://api.skio.com/storefront-v2-http/get-site-tier-rewards",{method:"POST",body:JSON.stringify({domain:this.domain,email:this.storefrontUser.email})}),data=await response.json();if(!response.ok){if(data.msg=="jwt expired")return this.log("JWT expired, refreshing tokens..."),await this.getNewToken(),await this.get
1SiteTierRewards();throw new Error("Failed to get site tier rewards")}return data}catch(error){throw error}}async getCustomerInformation(){this.log("Fetching customer information...");const data={query:`
2      query getCustomerInformation($id: uuid!) {
3        StorefrontUserByPk(id: $id) {
4          id
5          firstName
6          lastName
7          email
8          createdAt
9        }
10      }`,variables:{id:this.storefrontUser.id}};try{const response=await this.request(data),{data:{StorefrontUserByPk}}=response;if(!StorefrontUserByPk)throw new Error("Failed to get customer information");return StorefrontUserByPk}catch(error){throw error}}async getReferralCode(){this.log("Fetching customer referral code...");const data={query:`
11      query getReferralCode($id: uuid!) {
12        StorefrontUserByPk(id: $id) {
13          id
14          ReferralDiscountCodes {
15            referralCode
16          }
17        }
18      }`,variables:{id:this.storefrontUser.id}};try{const response=await this.request(data),{data:{StorefrontUserByPk}}=response;if(!StorefrontUserByPk)throw new Error("Failed to get customer referral code");return StorefrontUserByPk}catch(error){throw error}}}window.SkioSDK?console.error("SkioSDK is already defined!"):window.SkioSDK=SkioSDK;class ExclusiveLoyaltyContent extends HTMLElement{constructor(){super(),this.skio=new SkioSDK({domain:window.Shopify.shop,debug:!0}),this.tierNames=[],this.render()}static get observedAttributes(){return["tier-names"]}renderSwiper(targetSwiper,navLeft=!1,navRight=!1){if(targetSwiper){let swiperConfig={slidesPerView:1.3,spaceBetween:16,loop:!1,breakpoints:{1024:{spaceBetween:24,slidesPerView:4}}};navLeft&&navRight&&(swiperConfig.navigation={nextEl:navRight,prevEl:navLeft});const swiperInstance=new Swiper(targetSwiper,swiperConfig)}else console.log("targetSwiper not provided to function - unable to initiate this swiper.")}renderSwipers(){if(window.recipeSwiperInitialised===!1){const recipeSwiperExclusiveContent=document.querySelector("exclusive-loyalty-content.loyalty-content-recipes .active-skio-content");if(recipeSwiperExclusiveContent){const recipeSwiper=recipeSwiperExclusiveContent.querySelector(".swiper"),navigationWrapper=document.querySelector(".skio-loyalty-rewards-section__recipes-header__header-navigation");if(recipeSwiper){const navLeft=navigationWrapper?.querySelector(".skio-loyalty-rewards-section__recipes-header__header-navigation-left"),navRight=navigationWrapper?.querySelector(".skio-loyalty-rewards-section__recipes-header__header-navigation-right");navLeft&&navRight?this.renderSwiper(recipeSwiper,navLeft,navRight):this.renderSwiper(recipeSwiper)}else this.renderSwiper(recipeSwiper)}}if(window.merchSwiperInitialised===!1){const merchSwiperExclusiveContent=document.querySelector("exclusive-loyalty-content.loyalty-content-gifts .active-skio-content");if(merchSwiperExclusiveContent){const merchSwiper=merchSwiperExclusiveContent.querySelector(".swiper"),navigationWrapper=document.querySelector(".skio-loyalty-rewards-section__gifts-header__header-navigation");if(merchSwiper){const navLeft=navigationWrapper?.querySelector(".skio-loyalty-rewards-section__gifts-header__header-navigation-left"),navRight=navigationWrapper?.querySelector(".skio-loyalty-rewards-section__gifts-header__header-navigation-right");navLeft&&navRight?this.renderSwiper(merchSwiper,navLeft,navRight):this.renderSwiper(merchSwiper)}else this.renderSwiper(merchSwiper)}}}attributeChangedCallback(name,oldValue,newValue){name==="tier-names"&&(this.tierNames=newValue.split(",").map(tier=>tier.trim()),this.updateContentVisibility())}connectedCallback(){this.updateContentVisibility()}async updateContentVisibility(){const contentWrapper=this.querySelector(".content-wrapper");if(contentWrapper&&(contentWrapper.style.display="none"),!this.skio.checkLogin()){console.log("not logged in"),this.showFallbackContent();return}console.log("skio:",this.skio);try{const currentTier=(await this.skio.getSiteTierRewards()).userTierName||"";if(this.tierNames.forEach(tier=>{const tierContent=this.querySelector(`[data-tier="${tier}"]`);tierContent&&(tierContent.style.display="none")}),currentTier&&this.tierNames.includes(currentTier)){const currentTierContent=this.querySelector(`[data-tier="${currentTier}"]`);currentTierContent?(currentTierContent.style.display="block",contentWrapper.style.display="block",currentTierContent.classList.add("active-skio-content"),this.renderSwipers()):this.show
18FallbackContent()}else this.showFallbackContent()}catch(error){console.error("Error updating content visibility:",error),this.showFallbackContent()}}showFallbackContent(){const fallbackContent=this.querySelector('[data-tier="fallback"]'),contentWrapper=this.querySelector(".content-wrapper");fallbackContent&&(fallbackContent.style.display="block",contentWrapper.style.display="block",fallbackContent.classList.add("active-skio-content"),this.renderSwipers())}render(){const style=document.createElement("style");style.textContent=`
19      :host {
20        display: block;
21      }
22      .content-wrapper {
23        display: none;
24      }
25      [data-tier] {
26        display: none;
27      }      
28    `;const contentWrapper=document.createElement("div");contentWrapper.className="content-wrapper",this.appendChild(style),this.appendChild(contentWrapper)}}const hackInCustomSection=()=>{const targetPath="/a/account/loyalty";let lastPath=location.pathname;const initLoyaltyLogic=()=>{const target=document.querySelector(".loyalty-overview");if(target&&!target.dataset.enhanced&&!document.querySelector(".skio-custom-section")){const createdEls=[],nextOrderSectionContent=document.querySelector("#skio-next-order-section");if(nextOrderSectionContent){const nextOrderEl=document.createElement("div");nextOrderEl.classList.add("skio-loyalty-next-order","skio-custom-section"),nextOrderEl.innerHTML=nextOrderSectionContent?JSON.parse(nextOrderSectionContent.textContent):"",target.append(nextOrderEl),createdEls.push(nextOrderEl),target.dataset.enhanced="true"}const exclusiveRescipesContent=document.querySelector("#skio-exclusive-recipes-section");if(exclusiveRescipesContent){const exRecipesEl=document.createElement("div");exRecipesEl.classList.add("skio-loyalty-exclusive-recipes","skio-custom-section"),exRecipesEl.innerHTML=exclusiveRescipesContent?JSON.parse(exclusiveRescipesContent.textContent):"",target.append(exRecipesEl),createdEls.push(exRecipesEl),target.dataset.enhanced="true"}let runCount=0;const maxRuns=50,watchdogInterval=setInterval(()=>{const customSection2=document.querySelector(".skio-custom-section"),loyaltyOverview=document.querySelector(".loyalty-overview");!customSection2&&loyaltyOverview&&createdEls.forEach(el=>loyaltyOverview.append(el.cloneNode(!0))),runCount++,runCount>maxRuns&&clearInterval(watchdogInterval)},200)}},checkRouteChange=()=>{const currentPath=location.pathname;currentPath!==lastPath&&(lastPath=currentPath,currentPath===targetPath&&insertCustomSection())},insertCustomSection=()=>{const interval=setInterval(()=>{document.querySelector(".loyalty-overview")&&(initLoyaltyLogic(),clearInterval(interval))},300)};setInterval(checkRouteChange,300),location.pathname===targetPath&&insertCustomSection()};document.addEventListener("DOMContentLoaded",function(){document.querySelector(".skio-loyalty-rewards-section")&&customElements.define("exclusive-loyalty-content",ExclusiveLoyaltyContent),window.location.pathname.includes("/a/")&&hackInCustomSection(),bindReadMoreOverlays()});
29//# sourceMappingURL=/cdn/shop/t/106/assets/exclusive-loyalty-content.js.map?v=14917558626147172141788857924

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.