const{platformURL:e}=(()=>{const{shop:e}=window.Shopify,t="birdygrace.myshopify.com"===e?"production":"development",{platform_url:n,storefront_api_token:o,storefront_api_version:a}={development:{platform_url:"https://platform.birdystaging.com/api",storefront_api_token:"a7cd863c8179b07652150b5bb739a07b",storefront_api_version:"2025-07"},production:{platform_url:"https://platform.birdygrey.com/api",storefront_api_token:"1a8f4e31c69ef2d8fe9c05d65c8c8f0e",storefront_api_version:"2025-07"}}[t];return{platformURL:n,storefrontApiAccessToken:o,storefrontApiVersion:a}})(),t=Date.now();let n,o;const a=e=>{const t=document.getElementById("signup-popup"),n=t.querySelector(".popup-window");e.target===n||n.contains(e.target)||e.target.classList.contains("ui-icon")||e.target.classList.contains("ui-datepicker-next")||e.target.classList.contains("ui-datepicker-prev")||e.target.classList.contains("ui-corner-all")||(!localStorage||localStorage.email&&"email"===localStorage.email||(localStorage.email="closed",localStorage.emailTime=Date.now()),t.style.display="none",document.getElementById("signup-popup").setAttribute("aria-hidden","true"),document.getElementById("signup-popup").setAttribute("aria-modal","false"),document.getElementById("website-content").setAttribute("aria-hidden","false"),document.querySelector("body").removeEventListener("click",a),window.removeEventListener("keydown",window.focusTrap),window.focusReturn.focus())},i=e=>{("Escape"===e.key||"Esc"===e.key||27===e.keyCode)&&r()};window.location.href.includes("utm_source=klaviyo")&&(localStorage.email="email",localStorage.emailTime=Date.now()),!window.location.pathname.includes("/cart")&&localStorage&&(!localStorage.email||"closed"===localStorage.email&&localStorage.emailTime&&Date.now()-localStorage.emailTime>2592e6)&&(document.getElementById("signup-popup").querySelectorAll("img").forEach((e=>{(new Image).src=e.src})),setTimeout((()=>{const e=document.getElementById("signup-popup");document.getElementById("screen-alerts").innerHTML="\n
Focus changed to email popup. You can close this popup to return to your previous focus point.
\n ",e.style.display="flex",e.setAttribute("aria-hidden","false"),e.setAttribute("aria-modal","true"),document.getElementById("website-content").setAttribute("aria-hidden","true"),n=Date.now(),window.toTrap=e,window.focusReturn=document.activeElement,e.focus(),window.addEventListener("keydown",i),window.addEventListener("keydown",window.focusTrap),setTimeout((()=>{e.style.opacity=1}),15),setTimeout((()=>{document.body.addEventListener("click",a)}),15),gtag({event:"email_popup_email_screen_viewed",eventID:getEventId(),eventData:{pagedTriggered:window.location.pathname}})}),2e3)),document.querySelectorAll('.radios input[name="wedding-role"]').forEach((e=>{e.addEventListener("change",(function(){localStorage&&(localStorage.role=this.value),o=this.value}))}));const r=()=>{const e=document.getElementById("signup-popup");!localStorage||localStorage.email&&"email"===localStorage.email||(localStorage.email="closed",localStorage.emailTime=Date.now()),e.style.display="none",document.getElementById("signup-popup").setAttribute("aria-hidden","true"),document.getElementById("signup-popup").setAttribute("aria-modal","false"),document.getElementById("website-content").setAttribute("aria-hidden","false"),document.querySelector("body").removeEventListener("click",a),window.removeEventListener("keydown",i),window.removeEventListener("keydown",window.focusTrap),window.focusReturn.focus()},l=e=>{e.currentTarget.classList.remove("check-validity"),e.currentTarget.labels[0].style.color="#464646",e.currentTarget.labels[0].style.opacity="0"};document.getElementById("CustomerEmail")?.addEventListener("input",l),document.getElementById("PhoneNumber")?.addEventListener("input",l),document.getElementById("WeddingDate")?.addEventListener("input",l);const s=a=>{const i=a.currentTarget,r=document.getElementById("CustomerEmail"),l=document.getElementById("WeddingDate"),d=document.getElementById("verify"),c=[];let u=!0;if((e=>/^(?=.*[@])(?=.*\.com)[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(e))(r.value)){const e=a.target.closest(".popup-content");e.classList.add("hidden"),e.nextElementSibling.classList.remove("hidden")}else r.classList.add("check-validity"),r.labels[0].style.color="var(--errorText)",r.labels[0].style.opacity="1",u=!1,c.push(r);var m;if(m=l.value,/^\d{4}[/-](0?[1-9]|1[012])[/-](0?[1-9]|[12][0-9]|3[01])$/.test(m)||""===l.value||(l.classList.add("check-validity"),l.labels[0].style.color="var(--errorText)",u=!1,c.push(l)),!u)return void c[0].focus();sessionStorage.setItem("customerEmail",r.value);const p={};p.email=r.value,p.bot=0,"bride"!==o&&"bridesmaid"!==o&&"groomsman"!==o&&"groom"!==o&&"just shopping"!==o||(p.role=o),""!==l.value&&(p.date=l.value),""!==d.value&&(p.bot="ROBOT"),p.initialTS=t,p.popupTS=n,p.submitTS=Date.now(),p.signupLocation="popup",a.currentTarget.innerText="SENDING",a.currentTarget.removeEventListener("click",s),a.currentTarget.removeEventListener("keydown",window.enterEvent),gtag({event:"email_popup_email_submitted",eventID:getEventId(),eventData:{roleSubmitted:p.role,weddingDateSubmitted:p.date,pagedTriggered:window.location.pathname}}),fetch(`${e}/v1/customer/signup`,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify(p)}).then((e=>e.json())).then((e=>{if(200!==e.status)return i.addEventListener("click",s),i.addEventListener("keydown",window.enterEvent),void(i.innerText="SIGN UP");i.parentElement.parentElement.parentElement.parentElement.querySelectorAll(".popup-content").forEach((e=>{const{style:t}=e;e.classList.contains("page-2")?(t.display="flex",e.focus()):t.display="none"})),localStorage.email="email",trackLead(p.email,{signup_location:"popup",list_id:"Hj8m3A"}),gtag({event:"email_popup_sms_screen_viewed",eventID:getEventId(),eventData:{pagedTriggered:window.location.pathname}})})).catch((()=>{i.addEventListener("click",s),i.addEventListener("keydown",window.enterEvent),i.innerText="SIGN UP"}))},d=document.getElementById("allowText");null!==d&&d.addEventListener("change",(function(){const e=this;e.checked&&e.classList.contains("need-validation")&&e.classList.remove("need-validation")}));const c=async o=>{const a=o.currentTarget,i=document.getElementById("PhoneNumber");document.getElementById("allowText");let r=!0;const l=i.value.replace(/-/g,"");if((e=>/^\d{10}$/.test(e))(l)&&""!==i.value||(r=!1),!r)return i.classList.add("check-validity"),i.labels[0].style.color="var(--errorText)",i.labels[0].style.opacity="1",void i.focus();const s=`+1${l}`,d={email:sessionStorage.getItem("customerEmail"),allowText:!0,phone:s,bot:0,initialTS:t,popupTS:n,submitTS:Date.now()};a.innerText="SENDING",a.removeEventListener("click",c),a.removeEventListener("keydown",window.enterEvent),gtag({event:"email_popup_sms_submitted",eventID:getEventId(),eventData:{pagedTriggered:window.location.pathname}});try{const t=await fetch(`${e}/v1/customer/sms`,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify(d)});if(!t.ok){const e=await t.json();return console.error("Failed reponse when submitting popup",e),a.addEventListener("click",c),a.addEventListener("keydown",window.enterEvent),void(a.innerText="SIGN UP")}localStorage.email="email";const n=a.closest(".popup-content");n.classList.add("hidden"),n.nextElementSibling.classList.remove("hidden")}catch(e){console.error("Error during SMS submission:",e),a.addEventListener("click",c),a.addEventListener("keydown",window.enterEvent),a.innerText="SIGN UP"}};document.querySelectorAll(".popup-submit").forEach((e=>{e.addEventListener("click",s),e.addEventListener("keydown",window.enterEvent)})),document.querySelectorAll(".popup-submit-phone").forEach((e=>{e.addEventListener("click",c),e.addEventListener("keydown",window.enterEvent)})),document.querySelectorAll(".close-button").forEach((e=>{e.addEventListener("click",r),e.addEventListener("keydown",window.enterEvent)})); //# sourceMappingURL=email-popup.min.js.map