import{a as addQueryArgs}from"./add-query-args-0e2a8393.js";var _a;const lang=(null===(_a=window.scData)||void 0===_a?void 0:_a.locale)||navigator.language||(null===navigator||void 0===navigator?void 0:navigator.browserLanguage)||(navigator.languages||["en"])[0];let cachedCountryChoices=null;const countryDetailsCache=new Map,countryChoices=async()=>{var a,e,o,t;if(cachedCountryChoices)return cachedCountryChoices;const n=addQueryArgs("https://api.surecart.com/v1/public/atlas",{locale:lang}),r=await fetch(n),i=await r.json(),s=null===(a=(null==i?void 0:i.data)||[])||void 0===a?void 0:a.map((({code:a,name:e})=>({value:a,label:e})));return cachedCountryChoices=(null===(t=null===(o=null===(e=null===window||void 0===window?void 0:window.wp)||void 0===e?void 0:e.hooks)||void 0===o?void 0:o.applyFilters)||void 0===t?void 0:t.call(o,"surecart_address_countries",s))||s,cachedCountryChoices},getCountryDetails=async a=>{if(countryDetailsCache.has(a))return countryDetailsCache.get(a);const e=addQueryArgs(`https://api.surecart.com/v1/public/atlas/${a}`,{locale:lang}),o=await fetch(e),t=await o.json();return countryDetailsCache.set(a,t),t},getCountryRegions=async a=>{if(!a)return[];const e=await getCountryDetails(a);return((null==e?void 0:e.states)||[]).map((a=>({value:a.code,label:a.name})))};export{getCountryRegions as a,countryChoices as c,getCountryDetails as g};