line-items
1 year ago
test
2 months ago
address.js
2 months ago
address.js.map
2 months ago
animate.js
3 years ago
animate.js.map
1 year ago
animation-registry.js
2 months ago
animation-registry.js.map
2 months ago
click.js
3 years ago
click.js.map
1 year ago
currency.js
2 years ago
currency.js.map
1 year ago
error.js
2 years ago
error.js.map
1 year ago
fetch.js
2 weeks ago
fetch.js.map
2 weeks ago
form-data.js
3 years ago
form-data.js.map
1 year ago
form.js
3 years ago
form.js.map
1 year ago
geo-permission.js
3 days ago
geo-permission.js.map
3 days ago
geolocation.js
3 days ago
geolocation.js.map
3 days ago
google-maps.js
2 months ago
google-maps.js.map
2 months ago
google.js
2 years ago
google.js.map
1 year ago
icon-library.js
3 years ago
icon-library.js.map
3 years ago
lazy.js
3 years ago
lazy.js.map
1 year ago
media.js
2 years ago
media.js.map
1 year ago
page-align.js
3 years ago
page-align.js.map
1 year ago
price.js
2 months ago
price.js.map
2 months ago
processor.js
3 years ago
processor.js.map
1 year ago
quantity.js
2 months ago
quantity.js.map
2 months ago
razorpay.js
2 months ago
razorpay.js.map
2 months ago
scroll.js
3 years ago
scroll.js.map
1 year ago
slot.js
3 years ago
slot.js.map
1 year ago
tax.js
1 year ago
tax.js.map
1 year ago
total.js
3 years ago
total.js.map
1 year ago
util.js
1 month ago
util.js.map
1 month ago
address.js
1 lines
| 1 | var _a;import{addQueryArgs}from"@wordpress/url";export const STATE_INCLUDED_COUNTRIES=["AU","BR","CA","CH","ES","HK","IE","IN","IT","JP","MY","MX","US"];export const POSTAL_CODE_EXCLUDED_COUNTRIES=["HK"];export const CITY_EXCLUDED_COUNTRIES=["SG"];import countries from"./countries.json";export const hasPostal=t=>!POSTAL_CODE_EXCLUDED_COUNTRIES.includes(t);export const hasCity=t=>!CITY_EXCLUDED_COUNTRIES.includes(t);export const hasState=t=>STATE_INCLUDED_COUNTRIES.includes(t);export const hasCompleteAddress=t=>{const{country:o,state:a}=t;return!!hasRequiredFields(t)&&(!hasState(o)||hasCorrectState(o,a))};export const hasCorrectState=(t,o)=>((null==countries?void 0:countries[t])||[]).some((({value:t})=>t===o));export const hasRequiredFields=({city:t,country:o,line_1:a,postal_code:e,state:s})=>!(!o||hasPostal(o)&&!e||hasCity(o)&&!t||hasState(o)&&!s||!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;export const countryChoices=async()=>{var t,o,a,e;if(cachedCountryChoices)return cachedCountryChoices;const s=addQueryArgs("https://api.surecart.com/v1/public/atlas",{locale:lang}),n=await fetch(s),r=await n.json(),l=null===(t=(null==r?void 0:r.data)||[])||void 0===t?void 0:t.map((({code:t,name:o})=>({value:t,label:o})));return cachedCountryChoices=(null===(e=null===(a=null===(o=null===window||void 0===window?void 0:window.wp)||void 0===o?void 0:o.hooks)||void 0===a?void 0:a.applyFilters)||void 0===e?void 0:e.call(a,"surecart_address_countries",l))||l,cachedCountryChoices};export const getCountryDetails=async t=>{if(countryDetailsCache.has(t))return countryDetailsCache.get(t);const o=addQueryArgs(`https://api.surecart.com/v1/public/atlas/${t}`,{locale:lang}),a=await fetch(o),e=await a.json();return countryDetailsCache.set(t,e),e};export const getCountryRegions=async t=>{if(!t)return[];const o=await getCountryDetails(t);return((null==o?void 0:o.states)||[]).map((t=>({value:t.code,label:t.name})))};export const isAddressComplete=t=>(null==t?void 0:t.country)&&(null==t?void 0:t.line_1)&&(!hasPostal(t.country)||(null==t?void 0:t.postal_code))&&(!hasCity(t.country)||(null==t?void 0:t.city))&&(!hasState(t.country)||(null==t?void 0:t.state));export const isAddressCompleteEnough=t=>(null==t?void 0:t.country)&&(!hasPostal(t.country)||(null==t?void 0:t.postal_code))&&(!hasCity(t.country)||(null==t?void 0:t.city))&&(!hasState(t.country)||(null==t?void 0:t.state)); |