1!function(){async function e(){if(!function(){const e=document.cookie.split("; ").find(e=>e.startsWith("localization=")),t=e&&!e.includes("localization=US"),o=localStorage.getItem("has_visited_before"),n=localStorage.getItem("country_manually_set"),a=window.location.pathname.match(/^\/en-[a-z]{2}/);return!(t||o||n||a)}())return;const e=await async function(){try{const e=await fetch(window.Shopify.routes.root+"browsing_context_suggestions.json?country[enabled]=true"+`&country[exclude]=${window.Shopify.country}&language[enabled]=true`+`&language[exclude]=${window.Shopify.language}`);return await e.json()}catch(e){return null}}();if(e&&e.detected_values&&e.detected_values.country&&e.detected_values.country.handle){const t=e.detected_values.country.handle.toUpperCase();if(["US","CA","AU","NZ","MX"].includes(t)&&"US"!==t){const e=new Date;e.setTime(e.getTime()+31536e6),document.cookie=`_shopify_locale=${t}; expires=${e.toUTCString()}; path=/;`,document.cookie=`localization=${t}; expires=${e.toUTCString()}; path=/;`,localStorage.setItem("has_visited_before","true");const o=crypto.randomUUID(),n=`\n <form id="${o}" action="/localization" method="POST" hidden>\n <input name="_method" value="PUT" />\n <input name="country_code" value="${t}" />\n <input name="language_code" value="${window.Shopify.language||"en"}" />\n </form>\n `;return document.body.insertAdjacentHTML("beforeend",n),setTimeout(()=>{document.getElementById(o).submit()},100),!0}}return localStorage.setItem("has_visited_before","true"),!1}function t(){const e=window.location.pathname.match(/^\/en-([a-z]{2})/);if(e){const t=e[1].toUpperCase();if(!document.cookie.split("; ").find(e=>e.startsWith(`_shopify_locale=${t}`))){const e=new Date;e.setTime(e.getTime()+31536e6),document.cookie=`_shopify_locale=${t}; expires=${e.toUTCString()}; path=/;`,document.cookie=`localization=${t}; expires=${e.toUTCString()}; path=/;`}}}if("loading"===document.readyState?document.addEventListener("DOMContentLoaded",async()=>{await e(),t()}):e().then(t),window.preloadedCountryCode=function(){const e=document.cookie.split("; "),t=e.find(e=>e.startsWith("_shopify_locale=")),o=e.find(e=>e.startsWith("localization="));return t?t.split("=")[1]:o?o.split("=")[1]:null}(),window.preloadedCountryCode&&(document.referrer.includes("checkout")||document.referrer.includes("success"))){const e=window.location.pathname;(e.match(/^(\/en-[a-z]{2})/)?e.match(/^(\/en-[a-z]{2})/)[1]:"")!==({US:"",CA:"/en-ca",AU:"/en-au",NZ:"/en-nz",MX:"/en-mx"}[window.preloadedCountryCode]||"")&&localStorage.getItem("savedCart")&&localStorage.removeItem("savedCart")}window.updateCountrySelectorEarly=function(){if("complete"===document.readyState||"interactive"===document.readyState){const e=document.querySelectorAll("[data-custom-country-selector]");e.length>0&&e.forEach(e=>{const t=e.querySelector("[data-country-input]");window.preloadedCountryCode&&t&&window.preloadedCountryCode!==t.value&&(window.handleEarlyMarketSwitch(window.preloadedCountryCode,t.value),e.style.visibility="visible")})}},window.handleEarlyMarketSwitch=function(e,t){const o=window.location.pathname,n=o.match(/^(\/en-[a-z]{2})/)?o.match(/^(\/en-[a-z]{2})/)[1]:"",a={US:"",CA:"/en-ca",AU:"/en-au",NZ:"/en-nz",MX:"/en-mx"}[e]||"";if(n!==a&&(document.referrer.includes("checkout")||document.referrer.includes("success")||"/"===o||o.match(/^\/en-[a-z]{2}\/?$/))){(document.referrer.includes("checkout")||document.referrer.includes("success"))&&localStorage.getItem("savedCart")&&localStorage.removeItem("savedCart");let e="";""===a&&""!==n?e=o.replace(/^\/en-[a-z]{2}/,"")||"/":""!==a&&n!==a&&(e=a+(o.replace(/^\/en-[a-z]{2}/,"")||"/")),e&&(localStorage.getItem("savedCart")&&localStorage.removeItem("savedCart"),window.location.href=e)}},window.updateCountrySelectorEarly()}(),document.addEventListener("DOMContentLoaded",function(){class e{constructor(e){this.container=e,this.button=this.container.querySelector("[data-country-selector-toggle]"),this.dropdown=this.container.querySelector("[data-country-selector-dropdown]"),this.countryFlag=this.container.querySelector("[data-country-flag]"),this.countryCode=this.container.querySelector("[data-country-code]"),this.input=this.container.querySelector("[data-country-input]"),this.backdrop=this.container.querySelector("[data-country-selector-backdrop]"),this.isOpen=!1;const t=window.preloadedCountryCode||this.getCountryFromCookie();t&&this.input&&t!==this.input.value&&(this.input.value=t,this.updateSelectorDisplay(t),this.handleMarketSwitch(t)),this.container.addEventListener("countryManuallyChanged",()=>{localStorage.setItem("country_manually_set","true"),localStorage.setItem("has_visited_before","true")}),this.container.style.visibility="visible",this.button.addEventListener("click",this.handleButtonClick.bind(this)),document.addEventListener("mousedown",this.handleDocumentClick.bind(this)),document.addEventListener("keydown",this.handleKeyDown.bind(this)),document.addEventListener("keydown",this.handleKeyboardNavigation.bind(this)),this.backdrop&&this.backdrop.addEventListener("click",()=>{this.isOpen&&this.closeDropdown()}),this.dropdown.querySelectorAll(".country-grid-item").forEach(e
1=>{e.addEventListener("click",this.selectCountry.bind(this))}),this.handleUrlParams()}handleButtonClick(e){e.preventDefault(),e.stopPropagation(),this.isOpen?this.closeDropdown():this.openDropdown()}handleDocumentClick(e){this.isOpen&&!this.container.contains(e.target)&&this.closeDropdown()}handleKeyDown(e){"Escape"===e.key&&this.isOpen&&this.closeDropdown()}handleKeyboardNavigation(e){if(!this.isOpen)return;const t=Array.from(this.dropdown.querySelectorAll(".country-grid-item")),o=t.findIndex(e=>e===document.activeElement);switch(e.key){case"ArrowDown":e.preventDefault(),o<t.length-1?t[o+1].focus():t[0].focus();break;case"ArrowUp":e.preventDefault(),o>0?t[o-1].focus():t[t.length-1].focus();break;case"ArrowRight":e.preventDefault(),window.innerWidth>480&&o<t.length-1&&t[Math.min(o+(this.isMobileOrTouch()?1:4),t.length-1)].focus();break;case"ArrowLeft":e.preventDefault(),window.innerWidth>480&&o>0&&t[Math.max(o-(this.isMobileOrTouch()?1:4),0)].focus();break;case"Home":e.preventDefault(),t[0].focus();break;case"End":e.preventDefault(),t[t.length-1].focus();break;case"Enter":case" ":document.activeElement.classList.contains("country-grid-item")&&(e.preventDefault(),document.activeElement.click())}}handleUrlParams(){const e=new URLSearchParams(window.location.search).get("_country");if(e&&this.dropdown.querySelector(`.country-grid-item[data-value="${e}"]`)){this.input.value=e,this.updateSelectorDisplay(e),this.setCookie("localization",e),this.setCookie("_shopify_locale",e);const t=new URL(window.location.href);t.searchParams.delete("_country"),window.history.replaceState({},"",t)}}getCountryFromCookie(){const e=document.cookie.split("; "),t=e.find(e=>e.startsWith("_shopify_locale=")),o=e.find(e=>e.startsWith("localization="));if(t){const e=t.split("=")[1];return o?e!==o.split("=")[1]&&this.setCookie("localization",e):this.setCookie("localization",e),e}return o?o.split("=")[1]:null}updateSelectorDisplay(e){if(!e)return;const t=this.dropdown.querySelector(`.country-grid-item[data-value="${e}"]`);if(!t)return;const o=t.querySelector(".country-flag").innerHTML;this.countryFlag.innerHTML=o;const n=t.querySelector(".country").textContent;this.countryCode.textContent=n,this.dropdown.querySelectorAll(".country-grid-item").forEach(e=>{e===t?(e.setAttribute("aria-current","true"),e.setAttribute("aria-selected","true")):(e.removeAttribute("aria-current"),e.setAttribute("aria-selected","false"))})}openDropdown(){this.button.setAttribute("aria-expanded","true"),this.dropdown.classList.add("show"),this.isMobileOrTouch()&&this.backdrop.classList.add("show"),this.isOpen=!0,this.positionDropdown(),this.isMobileOrTouch()&&(document.body.style.overflow="hidden");const e=this.dropdown.querySelector('.country-grid-item[aria-selected="true"]');e&&setTimeout(()=>e.focus(),10)}closeDropdown(){this.isOpen=!1,this.button.setAttribute("aria-expanded","false"),this.dropdown.classList.remove("show"),this.backdrop.classList.remove("show"),document.body.style.overflow="",this.button.focus()}selectCountry(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget.getAttribute("data-value"),o=this.input.value;if(this.input.value=t,this.updateSelectorDisplay(t),this.setCookie("localization",t),this.setCookie("_shopify_locale",t),this.closeDropdown(),this.container.dispatchEvent(new CustomEvent("countryManuallyChanged",{detail:{from:o,to:t}})),o!==t){localStorage.getItem("savedCart")&&localStorage.removeItem("savedCart"),window.marketTransitionInProgress=!0,"US"===t&&fetch(`${window.theme.routes.cart}/clear.js`,{method:"POST",headers:{"Content-Type":"application/json"}}).catch(e=>{console.error("Error clearing cart:",e)}),this.button.classList.add("loading");const e=this.container.closest("form");e&&e.submit()}}positionDropdown(){this.isMobileOrTouch()||(this.dropdown.style.minWidth="300px",this.dropdown.style.position="absolute",this.dropdown.style.top="100%",this.dropdown.style.right="0",this.dropdown.style.left="auto")}setCookie(e,t){const o=new Date;o.setTime(o.getTime()+31536e6),document.cookie=`${e}=${t}; expires=${o.toUTCString()}; path=/;`}isMobileOrTouch(){const e=window.matchMedia("(pointer: coarse)").matches,t=window.innerWidth<=749;return e||t}handleMarketSwitch(e){const t=window.location.pathname,o=this.getCurrentLocalePath(),n=this.getLocalePathForCountry(e);if(o===n)return;let a=!1,i="";if(""===n&&""!==o){const e=t.replace(/^\/en-[a-z]{2}/,"")||"/";i=e,a=!0}else if(""!==n&&o!==n){const e=t.replace(/^\/en-[a-z]{2}/,"")||"/";i=n+e,a=!0}a&&i&&(localStorage.getItem("savedCart")&&localStorage.removeItem("savedCart"),setTimeout(()=>{window.location.href=i},100))}getCurrentLocalePath(){const e=window.location.pathname.match(/^(\/en-[a-z]{2})/);return e?e[1]:""}getLocalePathForCountry(e){return{US:"",CA:"/en-ca",AU:"/en-au",NZ:"/en-nz",MX:"/en-mx"}[e]||""}static handleContinueShopping(e){const t={US:"",CA:"/en-ca",AU:"/en-au",NZ:"/en-nz",MX:"/en-mx"}[this.getCurrentCountryFromCookie()]||"";let o=e;return t?o.startsWith(t)||(o=t+(o.startsWith("/")?o:"/"+o)):o=o.replace(/^\/en-[a-z]{2}/,"")||"/",o}static getCurrentCountryFromCookie(){const e=document.cookie.split("; "),t=e.find(e=>e.startsWith("_shopify_locale=")),o=e.find(e=>e.startsWith("localization="));return t?t.split("=")[1]:o?o.split("=")[1]:"US"}}!function(){const e=localStorage.getItem("savedCart");if(e)try{const t=JSON.parse(e),o=window.location.pathname,n=o.match(/^(\/en-[a-z]{2})/)?o.match(/^(\/en-[a-z]{2})/)[1]:"",a=t.market;if(void 0===a)return void localStorage.removeItem("savedCart");a!==n&&localStorage.removeItem("savedCart")}catch(e){console.error("Error checking cart market:",e),localStorage.removeItem("savedCart")}}(),document.querySelectorAll("[data-custom-country-selector]").forEach(t=>new e(t)),window.CountryLocalizationUtils={handleContinueShopping:e.handleContinueShopping,getCurrentCountry:e.getCurrentCountryFromCookie,isAutoDetectionEnabled:()=>!localStorage.getItem("country_manually_set"),resetAutoDetection(){localStorage.removeItem("has_visited_before"),localStorage.removeItem("country_manually_set")},getCurrentLocalePath(){const e=window.location.pathname.match(/^(\/en-[a-z]{2})/);return e?e[1]:""}}}); 2//# sourceMappingURL=country-localization.min.js.map
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.