1const ReferralProgram={selectors:{parent:{selector:"#referral-modal",type:"single",scope:"document"},referralModal:{selector:"#referral-modal",type:"single",scope:"document"},referralMessage:{selector:"h2",type:"single",scope:"parent"},referrerNameEl:{selector:"#referrer-name",type:"single",scope:"document"},closeReferralBtns:{selector:".icon-close",type:"all",scope:"parent"},selfReferralModal:{selector:"#self-referral-modal",type:"single",scope:"document"},errorModal:{selector:"#error-modal",type:"single",scope:"document"}},init:async function(customerOrdersCount){Utility.fetchEls(this.selectors,this),this.urlParams=new URLSearchParams(window.location.search),this.referralCode=this.urlParams.get("referralCode"),this.referralModalClosed=sessionStorage.getItem("referralModalClosed"),this.referrerName="",this.validReferral=!1,this.fingerprint=await this.getFingerPrint(),this.referralCode&&(await this.getReferralData(),this.validReferral?(sessionStorage.setItem("referralCode",this.referralCode),customerOrdersCount==0&&this.addCartAttribute(),this.referralModalClosed||this.initReferralModal()):this.selfReferral?(this.selfReferralModal.style.display="flex",this.referralModal.style.display="none"):!this.validReferral&&!this.selfReferral&&(this.errorModal.style.display="flex",this.referralModal.style.display="none")),this.closeReferralBtns.forEach(btn=>{btn.onclick=function(){btn.closest(".referral-modal").style.display="none",sessionStorage.setItem("referralModalClosed","true")}})},getFingerPrint:async function(){return(await(await FingerprintJS.load()).get()).visitorId},getReferralData:async function(){try{const response=await fetch(`https://api.selkirk.com/functions/v1/p1/selkirksport/user/validateReferralCode?referralCode=${encodeURIComponent(this.referralCode)}&fingerprint=${this.fingerprint}`);if(!response.ok)throw new Error(`Network response was not ok: ${response.status}`);const data=await response.json(),refInfo=data?.data||{};refInfo.valid?(this.validReferral=!0,this.referrerName=refInfo.firstName||"",this.referrerEmail=refInfo.email||"",this.referrerPhone=refInfo.phone||""):(this.validReferral=!1,this.selfReferral=!!refInfo.selfReferral,console.error("Referral code not valid:",data))}catch(error){this.validReferral=!1,this.selfReferral=!1,console.error("Error validating referral code:",error)}},addCartAttribute:async function(){try{const cart=await(await fetch("/cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:{referralCode:this.referralCode,referrerName:this.referrerName,referrerEmail:this.referrerEmail,referrerPhone:this.referrerPhone}})})).json()}catch(error){console.error("Error updating cart:",error)}},initReferralModal:function(){const{referralModal,referrerNameEl,referralMessage}=this;referralModal.style.display="flex",this.referrerName?referrerNameEl.textContent=this.referrerName:referralMessage.textContent="You were referred!"}}; 2//# sourceMappingURL=/cdn/shop/t/642/assets/referral-scripts.js.map?v=164182623358937456431782948858
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.