@zonos/elements 1.3.288 → 1.3.289

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/cjs/{cart-CV4buPlT.js → cart-WLQb2hbe.js} +1 -1
  2. package/dist/cjs/{collect-jzWKzrV7.js → collect-B92uIdsY.js} +2 -2
  3. package/dist/cjs/{getMissingRequiredShippingFields-r5vYIqoX.js → getMissingRequiredShippingFields-5w62gTIB.js} +1 -1
  4. package/dist/cjs/{hasInclusivePrice-BZMQohG9.js → hasInclusivePrice-hmV0Inld.js} +1 -1
  5. package/dist/cjs/index.cjs.js +8 -9
  6. package/dist/cjs/{invoice-CHw-mJdS.js → invoice-Bal1mqYR.js} +2 -2
  7. package/dist/cjs/{localization-CxXsmxs5.js → localization-C5HPlCNK.js} +191 -68
  8. package/dist/cjs/{paypal-BLuHeOJH.js → paypal-o164C26_.js} +2 -2
  9. package/dist/cjs/{placeTestOrder-VK_CMeq0.js → placeTestOrder-C7tAipav.js} +2 -2
  10. package/dist/cjs/{renderCheckoutCurrency-CC4CAy-a.js → renderCheckoutCurrency-Bpx-vrTQ.js} +2 -2
  11. package/dist/cjs/{shouldShowLanguageSelect-Bj_jKWPK.js → shouldShowLanguageSelect-CtwkMt8b.js} +1 -1
  12. package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +7 -7
  13. package/dist/cjs/zonos-address-display_2.cjs.entry.js +1 -1
  14. package/dist/cjs/zonos-address_4.cjs.entry.js +4 -4
  15. package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +3 -3
  16. package/dist/cjs/zonos-card_5.cjs.entry.js +4 -4
  17. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +9 -9
  18. package/dist/cjs/zonos-checkout.cjs.entry.js +6 -6
  19. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +2 -2
  20. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +8 -8
  21. package/dist/cjs/zonos-collect.cjs.entry.js +4 -4
  22. package/dist/cjs/zonos-controller.cjs.entry.js +4 -4
  23. package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
  24. package/dist/cjs/zonos-country-select_4.cjs.entry.js +2 -2
  25. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
  26. package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
  27. package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +4 -4
  28. package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +8 -8
  29. package/dist/cjs/zonos-invoice.cjs.entry.js +4 -4
  30. package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
  31. package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +3 -3
  32. package/dist/cjs/zonos-stripe-input.cjs.entry.js +1 -1
  33. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.js +1 -1
  34. package/dist/collection/components/checkout/zonos-collect/zonos-collect-payment/zonos-collect-payment.js +1 -1
  35. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-payment/zonos-invoice-payment.js +1 -1
  36. package/dist/collection/components/common/zonos-stripe-input/zonos-stripe-input.js +1 -1
  37. package/dist/collection/components/main/zonos-controller.js +2 -2
  38. package/dist/collection/components/paypal/zonos-paypal-payment.js +1 -2
  39. package/dist/collection/components/store/hello/localization.js +69 -34
  40. package/dist/collection/components/stripe/zonos-address/zonos-address.js +2 -2
  41. package/dist/collection/components/stripe/zonos-custom-address/zonos-address-suggestions/zonos-address-suggestions.js +2 -3
  42. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +2 -2
  43. package/dist/collection/components/stripe/zonos-link-authentication/zonos-link-authentication.js +0 -1
  44. package/dist/collection/components/utils/api/getLocalization.js +2 -2
  45. package/dist/collection/components/utils/checkout/isShippableCountry.js +2 -4
  46. package/dist/collection/components/utils/checkout/watchBigcommerceDomesticCheckout.js +1 -0
  47. package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +2 -0
  48. package/dist/collection/components/utils/formatDate.js +1 -3
  49. package/dist/collection/components/utils/getOverridenZCountry.js +3 -5
  50. package/dist/collection/components/utils/hello/countryOverrideStorage.js +49 -0
  51. package/dist/collection/components/utils/hello/getZCountryUrlParam.js +5 -9
  52. package/dist/collection/components/utils/hello/isCountryCode.js +1 -0
  53. package/dist/collection/components/utils/hello/isCountryInShippingZone.js +8 -0
  54. package/dist/collection/components/utils/hello/reconcileRememberedCountryOverride.js +37 -0
  55. package/dist/collection/components/utils/hello/shouldShowHelloWidget.js +27 -20
  56. package/dist/collection/environment.js +0 -1
  57. package/dist/collection/scripts/_stripe.js +0 -2
  58. package/dist/collection/scripts/_zonosBase.js +1 -1
  59. package/dist/collection/types/generated/graphql.frontend.types.js +218 -63
  60. package/dist/collection/types/generated/graphql.internal.types.js +643 -147
  61. package/dist/collection/utils/formattedCloudflareApiUrl.js +1 -0
  62. package/dist/collection/utils/generateCloudflareDeployUrl.js +5 -2
  63. package/dist/esm/{cart-ekBk_gxV.js → cart-BDc4RTBJ.js} +1 -1
  64. package/dist/esm/{collect-33rMINDo.js → collect-NRCK3t-M.js} +2 -2
  65. package/dist/esm/{getMissingRequiredShippingFields-u1nhQzJ1.js → getMissingRequiredShippingFields-D-B-N1NH.js} +1 -1
  66. package/dist/esm/{hasInclusivePrice-CAVXi310.js → hasInclusivePrice-Bti4iudO.js} +1 -1
  67. package/dist/esm/index.js +8 -9
  68. package/dist/esm/{invoice-BNDWuVsD.js → invoice-DsvQvu4a.js} +2 -2
  69. package/dist/esm/{localization-AOqYXGdP.js → localization-Bs6hVcKV.js} +191 -69
  70. package/dist/esm/{paypal-CW1D2XqZ.js → paypal-BqyEZS_u.js} +2 -2
  71. package/dist/esm/{placeTestOrder-nhmsLLOA.js → placeTestOrder-x3xwMAnW.js} +2 -2
  72. package/dist/esm/{renderCheckoutCurrency-BQANmZyM.js → renderCheckoutCurrency-DIBdWKN1.js} +2 -2
  73. package/dist/esm/{shouldShowLanguageSelect-BQFCXouB.js → shouldShowLanguageSelect-Bb9sbQ41.js} +1 -1
  74. package/dist/esm/zonos-address-completion-dialog_7.entry.js +7 -7
  75. package/dist/esm/zonos-address-display_2.entry.js +1 -1
  76. package/dist/esm/zonos-address_4.entry.js +4 -4
  77. package/dist/esm/zonos-airwallex-payment.entry.js +3 -3
  78. package/dist/esm/zonos-card_5.entry.js +4 -4
  79. package/dist/esm/zonos-cart-items_12.entry.js +9 -9
  80. package/dist/esm/zonos-checkout.entry.js +6 -6
  81. package/dist/esm/zonos-collect-cart-items_3.entry.js +2 -2
  82. package/dist/esm/zonos-collect-finish_6.entry.js +8 -8
  83. package/dist/esm/zonos-collect.entry.js +4 -4
  84. package/dist/esm/zonos-controller.entry.js +4 -4
  85. package/dist/esm/zonos-country-flag.entry.js +1 -1
  86. package/dist/esm/zonos-country-select_4.entry.js +2 -2
  87. package/dist/esm/zonos-hello-dialog.entry.js +2 -2
  88. package/dist/esm/zonos-hello.entry.js +1 -1
  89. package/dist/esm/zonos-invoice-cart-items_2.entry.js +4 -4
  90. package/dist/esm/zonos-invoice-finish_5.entry.js +8 -8
  91. package/dist/esm/zonos-invoice.entry.js +4 -4
  92. package/dist/esm/zonos-language-select_2.entry.js +1 -1
  93. package/dist/esm/zonos-policy-consent_2.entry.js +3 -3
  94. package/dist/esm/zonos-stripe-input.entry.js +1 -1
  95. package/dist/esm-es5/{cart-ekBk_gxV.js → cart-BDc4RTBJ.js} +1 -1
  96. package/dist/esm-es5/{collect-33rMINDo.js → collect-NRCK3t-M.js} +1 -1
  97. package/dist/esm-es5/{getMissingRequiredShippingFields-u1nhQzJ1.js → getMissingRequiredShippingFields-D-B-N1NH.js} +1 -1
  98. package/dist/esm-es5/{hasInclusivePrice-CAVXi310.js → hasInclusivePrice-Bti4iudO.js} +1 -1
  99. package/dist/esm-es5/index.js +6 -8
  100. package/dist/esm-es5/{invoice-BNDWuVsD.js → invoice-DsvQvu4a.js} +1 -1
  101. package/dist/esm-es5/{localization-AOqYXGdP.js → localization-Bs6hVcKV.js} +74 -68
  102. package/dist/esm-es5/{paypal-CW1D2XqZ.js → paypal-BqyEZS_u.js} +1 -1
  103. package/dist/esm-es5/{placeTestOrder-nhmsLLOA.js → placeTestOrder-x3xwMAnW.js} +1 -1
  104. package/dist/esm-es5/{renderCheckoutCurrency-BQANmZyM.js → renderCheckoutCurrency-DIBdWKN1.js} +1 -1
  105. package/dist/esm-es5/{shouldShowLanguageSelect-BQFCXouB.js → shouldShowLanguageSelect-Bb9sbQ41.js} +1 -1
  106. package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +3 -3
  107. package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
  108. package/dist/esm-es5/zonos-address_4.entry.js +2 -2
  109. package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
  110. package/dist/esm-es5/zonos-card_5.entry.js +2 -2
  111. package/dist/esm-es5/zonos-cart-items_12.entry.js +2 -2
  112. package/dist/esm-es5/zonos-checkout.entry.js +4 -4
  113. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  114. package/dist/esm-es5/zonos-collect-finish_6.entry.js +2 -2
  115. package/dist/esm-es5/zonos-collect.entry.js +1 -1
  116. package/dist/esm-es5/zonos-controller.entry.js +3 -3
  117. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  118. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  119. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  120. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  121. package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
  122. package/dist/esm-es5/zonos-invoice-finish_5.entry.js +2 -2
  123. package/dist/esm-es5/zonos-invoice.entry.js +1 -1
  124. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  125. package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
  126. package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
  127. package/dist/scripts/index.js +1 -1
  128. package/dist/scripts/loadZonos.js +1 -1
  129. package/dist/scripts/zonos.js +1 -1
  130. package/dist/types/components/store/hello/localization.d.ts +2 -1
  131. package/dist/types/components/utils/api/getLocalization.d.ts +3 -1
  132. package/dist/types/components/utils/getOverridenZCountry.d.ts +2 -3
  133. package/dist/types/components/utils/hello/countryOverrideStorage.d.ts +5 -0
  134. package/dist/types/components/utils/hello/isCountryCode.d.ts +2 -0
  135. package/dist/types/components/utils/hello/isCountryInShippingZone.d.ts +2 -0
  136. package/dist/types/components/utils/hello/reconcileRememberedCountryOverride.d.ts +18 -0
  137. package/dist/types/components/utils/hello/shouldShowHelloWidget.d.ts +8 -4
  138. package/dist/types/types/generated/graphql.frontend.types.d.ts +41 -52
  139. package/dist/types/types/generated/graphql.frontend.types.ts +226 -114
  140. package/dist/types/types/generated/graphql.internal.types.d.ts +231 -94
  141. package/dist/types/types/generated/graphql.internal.types.ts +712 -245
  142. package/dist/types/utils/formattedCloudflareApiUrl.d.ts +1 -0
  143. package/dist/types/utils/generateCloudflareDeployUrl.d.ts +5 -2
  144. package/dist/zonos-elements/index.esm.js +1 -1
  145. package/dist/zonos-elements/p-02628b9f.entry.js +1 -0
  146. package/dist/zonos-elements/{p-04cc0dac.system.entry.js → p-02ff6f8b.system.entry.js} +38 -38
  147. package/dist/zonos-elements/p-037d3688.entry.js +1 -0
  148. package/dist/zonos-elements/{p-02ef0f99.system.entry.js → p-03fbe813.system.entry.js} +1 -1
  149. package/dist/zonos-elements/{p-5a631080.system.entry.js → p-0ff26236.system.entry.js} +1 -1
  150. package/dist/zonos-elements/{p-f2cedbcd.system.entry.js → p-163b81c0.system.entry.js} +6 -6
  151. package/dist/zonos-elements/{p-e9320825.entry.js → p-18021e6b.entry.js} +1 -1
  152. package/dist/zonos-elements/{p-dcdbc610.system.entry.js → p-22fab1ba.system.entry.js} +1 -1
  153. package/dist/zonos-elements/{p-b14819ab.system.entry.js → p-2466b5f0.system.entry.js} +1 -1
  154. package/dist/zonos-elements/{p-daf9fa07.system.entry.js → p-317d4665.system.entry.js} +19 -19
  155. package/dist/zonos-elements/{p-d55b9664.system.entry.js → p-36559431.system.entry.js} +17 -17
  156. package/dist/zonos-elements/{p-f27317d3.system.entry.js → p-3cc27e0e.system.entry.js} +1 -1
  157. package/dist/zonos-elements/{p-891b47d7.entry.js → p-3d536086.entry.js} +1 -1
  158. package/dist/zonos-elements/{p-a38e62cc.entry.js → p-3e59d41c.entry.js} +1 -1
  159. package/dist/zonos-elements/{p-64e7bc5b.entry.js → p-4625058a.entry.js} +1 -1
  160. package/dist/zonos-elements/{p-5024df2d.system.entry.js → p-56159b7c.system.entry.js} +60 -60
  161. package/dist/zonos-elements/p-5e074243.entry.js +1 -0
  162. package/dist/zonos-elements/{p-9818f823.entry.js → p-5eb82be3.entry.js} +1 -1
  163. package/dist/zonos-elements/{p-cf5688f7.entry.js → p-628a0f7f.entry.js} +1 -1
  164. package/dist/zonos-elements/{p-5d3079e8.entry.js → p-635341d6.entry.js} +1 -1
  165. package/dist/zonos-elements/{p-d4c4a00e.entry.js → p-68e0180a.entry.js} +1 -1
  166. package/dist/zonos-elements/{p-6b0afaa7.entry.js → p-6c6c65f0.entry.js} +1 -1
  167. package/dist/zonos-elements/{p-04bfcd72.system.entry.js → p-72b6a006.system.entry.js} +18 -18
  168. package/dist/zonos-elements/{p-4973f8d8.system.entry.js → p-8cac7911.system.entry.js} +8 -8
  169. package/dist/zonos-elements/p-97f848f6.entry.js +1 -0
  170. package/dist/zonos-elements/p-9H2p9XKE.js +1 -0
  171. package/dist/zonos-elements/{p-CJCoACvU.js → p-B6X55m0b.js} +2 -2
  172. package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
  173. package/dist/zonos-elements/{p-D31lQiWo.system.js → p-BybDGrH4.system.js} +4 -4
  174. package/dist/zonos-elements/{p-DTgv0QpG.js → p-CGkdA4pY.js} +1 -1
  175. package/dist/zonos-elements/{p-D5AtAlJx.system.js → p-CH6tsv9B.system.js} +1 -1
  176. package/dist/zonos-elements/{p-CYdt69j5.system.js → p-CQyFoOXW.system.js} +23 -23
  177. package/dist/zonos-elements/{p-B2EZRfoq.system.js → p-CVQ7-7E2.system.js} +18 -18
  178. package/dist/zonos-elements/{p-DIJaXkiE.system.js → p-Cd9xIgx7.system.js} +111 -105
  179. package/dist/zonos-elements/{p-CQqNJo0D.system.js → p-ClUEwqZW.system.js} +4 -4
  180. package/dist/zonos-elements/{p-DkpYo2Fs.js → p-CpvnCfKt.js} +1 -1
  181. package/dist/zonos-elements/p-CtKp6AQ4.js +1 -0
  182. package/dist/zonos-elements/{p-DGsEWFDU.system.js → p-CuhGrJBA.system.js} +1 -1
  183. package/dist/zonos-elements/{p-D-DawUYF.system.js → p-D2fOB4Wn.system.js} +1 -1
  184. package/dist/zonos-elements/{p-BtMauqj_.system.js → p-D4WI0B6-.system.js} +6 -8
  185. package/dist/zonos-elements/{p-CKTIJ2Gr.js → p-DdpeA8cH.js} +1 -1
  186. package/dist/zonos-elements/p-DkirvyAh.js +1 -0
  187. package/dist/zonos-elements/{p-DHwpNxG9.js → p-DqEtY53c.js} +1 -1
  188. package/dist/zonos-elements/{p-DjuFsKLG.js → p-MHVIIOVE.js} +1 -1
  189. package/dist/zonos-elements/{p-DPW1yXt9.system.js → p-NL_Eiq6m.system.js} +65 -65
  190. package/dist/zonos-elements/{p-Dj-O6VfM.system.js → p-UM1aYZBV.system.js} +2 -2
  191. package/dist/zonos-elements/p-a6354d15.entry.js +1 -0
  192. package/dist/zonos-elements/{p-8cd3f1e2.entry.js → p-b78bab27.entry.js} +1 -1
  193. package/dist/zonos-elements/{p-f6ba59f6.system.entry.js → p-b88e521e.system.entry.js} +14 -14
  194. package/dist/zonos-elements/{p-450ed170.system.entry.js → p-b96666ca.system.entry.js} +3 -3
  195. package/dist/zonos-elements/{p-39c8a898.entry.js → p-c090cc60.entry.js} +1 -1
  196. package/dist/zonos-elements/{p-cadf6b63.system.entry.js → p-c4713ff1.system.entry.js} +10 -10
  197. package/dist/zonos-elements/{p-ea8790aa.entry.js → p-c5f17bad.entry.js} +1 -1
  198. package/dist/zonos-elements/{p-f57495dc.entry.js → p-cc17a230.entry.js} +1 -1
  199. package/dist/zonos-elements/{p-7ae48e31.entry.js → p-cf53f67a.entry.js} +1 -1
  200. package/dist/zonos-elements/{p-7a5d2211.system.entry.js → p-d261f27c.system.entry.js} +15 -15
  201. package/dist/zonos-elements/{p-e101d722.system.entry.js → p-d451d5bc.system.entry.js} +4 -4
  202. package/dist/zonos-elements/{p-d33dfc78.system.entry.js → p-d9527bd7.system.entry.js} +35 -35
  203. package/dist/zonos-elements/{p-f6e0aeba.system.entry.js → p-e126e9bd.system.entry.js} +176 -176
  204. package/dist/zonos-elements/{p-e284d329.entry.js → p-e582ae2a.entry.js} +1 -1
  205. package/dist/zonos-elements/{p-5562a955.system.entry.js → p-e9a3bc27.system.entry.js} +1 -1
  206. package/dist/zonos-elements/{p-844a743a.entry.js → p-f44631d5.entry.js} +1 -1
  207. package/dist/zonos-elements/{p-5836d426.system.entry.js → p-fcfac62f.system.entry.js} +1 -1
  208. package/dist/zonos-elements/p-opB7B9YB.js +1 -0
  209. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  210. package/package.json +12 -11
  211. package/dist/zonos-elements/p-2ba738ec.entry.js +0 -1
  212. package/dist/zonos-elements/p-4a54f664.entry.js +0 -1
  213. package/dist/zonos-elements/p-6f742021.entry.js +0 -1
  214. package/dist/zonos-elements/p-89ddab88.entry.js +0 -1
  215. package/dist/zonos-elements/p-C19J2XSh.js +0 -1
  216. package/dist/zonos-elements/p-LypTHRUC.js +0 -1
  217. package/dist/zonos-elements/p-adfee3a3.entry.js +0 -1
  218. package/dist/zonos-elements/p-lGLcGvEA.js +0 -1
  219. package/dist/zonos-elements/p-pfIceXbY.js +0 -1
@@ -12,8 +12,12 @@ import { getShippingZones } from "../../utils/api/getShippingZones";
12
12
  import { removeBigcommerceCartShipping } from "../../utils/checkout/removeBigcommerceCartShipping";
13
13
  import { getSupportedLanguages } from "../../utils/getSupportedLanguages";
14
14
  import { handleFetch } from "../../utils/handleFetch";
15
+ import { getCountryOverrideStorage, migrateCountryOverrideStorage, setCountryOverrideStorage, } from "../../utils/hello/countryOverrideStorage";
15
16
  import { currencyDisplay } from "../../utils/hello/currencyConversion/currencyDisplay";
16
17
  import { getCurrencyCode } from "../../utils/hello/currencyConversion/getCurrencyCode";
18
+ import { getZCountryUrlParam } from "../../utils/hello/getZCountryUrlParam";
19
+ import { isCountryInShippingZone } from "../../utils/hello/isCountryInShippingZone";
20
+ import { reconcileRememberedCountryOverride } from "../../utils/hello/reconcileRememberedCountryOverride";
17
21
  import { setZCountryUrlParam } from "../../utils/hello/setZCountryUrlParam";
18
22
  import { log } from "../../utils/logging/log";
19
23
  import { logError } from "../../utils/logging/logError";
@@ -124,19 +128,23 @@ const getNewLocalization = async ({ isInitializing, }) => {
124
128
  }
125
129
  };
126
130
  const getCustomMessages = async () => {
127
- log(`Getting custom messages for ${localizationStore.selectedCountryCode}`);
128
- if (!localizationStore.selectedCountryCode || !zonosStore.storeId) {
131
+ const countryCode = localizationStore.selectedCountryCode;
132
+ log(`Getting custom messages for ${countryCode}`);
133
+ if (!countryCode || !zonosStore.storeId) {
129
134
  return;
130
135
  }
131
136
  const localeMessages = await getLocaleMessages({
132
- countryCode: localizationStore.selectedCountryCode,
137
+ countryCode,
133
138
  localeTo: localizationStore.selectedLocale,
134
139
  storeId: zonosStore.storeId,
135
140
  });
141
+ if (localizationStore.selectedCountryCode !== countryCode) {
142
+ return;
143
+ }
136
144
  const allMessages = localeMessages.flatMap(x => {
137
145
  var _a;
138
146
  return {
139
- countryCode: localizationStore.selectedCountryCode,
147
+ countryCode,
140
148
  message: (_a = x.countryCodesPageMessageLinks.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message.textTo,
141
149
  pageName: x.pageName,
142
150
  };
@@ -179,17 +187,19 @@ const getValidLocale = (locale) => {
179
187
  log(`Locale ${locale} is not offered, falling back to ${fallback === null || fallback === void 0 ? void 0 : fallback.code}`);
180
188
  return (fallback === null || fallback === void 0 ? void 0 : fallback.code) || 'en';
181
189
  };
182
- const localizationStoreUpdateSelectedCountryCode = ({ isInitializing, newSelectedCountryCode, }) => {
183
- var _a, _b, _c;
190
+ const syncSelectedCountryToPage = (selectedCountryCode) => {
191
+ var _a;
192
+ setZCountryUrlParam(selectedCountryCode);
193
+ (_a = document
194
+ .querySelector('zonos-hello')) === null || _a === void 0 ? void 0 : _a.setAttribute('z-country', selectedCountryCode);
195
+ };
196
+ const localizationStoreUpdateSelectedCountryCode = ({ isInitializing, newSelectedCountryCode, persistOverride, }) => {
197
+ var _a;
184
198
  log(`Updating selected country code to ${newSelectedCountryCode}`);
185
199
  const isFirstTime = !localizationStore.selectedCountryCode;
186
200
  localizationStore.selectedCountryCode = getValidCountryCode(newSelectedCountryCode);
187
- const { selectedCountryCode, shippingZoneCountries } = localizationStore;
188
- const isShippableCountry = !!shippingZoneCountries &&
189
- !!selectedCountryCode &&
190
- !!shippingZoneCountries[selectedCountryCode] &&
191
- // Make sure the country is not in the disabled countries list
192
- !zonosStore.disabledCountries.includes(selectedCountryCode);
201
+ const { selectedCountryCode } = localizationStore;
202
+ const isShippableCountry = isCountryInShippingZone(selectedCountryCode);
193
203
  // update shippable country
194
204
  localizationStore.isShippableCountry = isShippableCountry;
195
205
  log(`${localizationStore.selectedCountryCode} is a shippable country: ${localizationStore.isShippableCountry}`);
@@ -212,9 +222,10 @@ const localizationStoreUpdateSelectedCountryCode = ({ isInitializing, newSelecte
212
222
  return;
213
223
  }
214
224
  const currencyCode = getCurrencyCode(selectedCountryCode);
215
- // Only trigger callback onCountryChange if the country code has been set before
216
- if (!isFirstTime) {
217
- // Trigger callback onCountryChange
225
+ const shouldPersistOverride = persistOverride !== null && persistOverride !== void 0 ? persistOverride : !isInitializing;
226
+ // Only trigger onCountryChange after init — the first apply, and any
227
+ // reconcile fallback during init, are not shopper-selected changes.
228
+ if (!isFirstTime && !isInitializing) {
218
229
  (_a = zonosStore.onCountryChange) === null || _a === void 0 ? void 0 : _a.call(zonosStore, {
219
230
  countryCode: selectedCountryCode,
220
231
  currencyCode,
@@ -244,27 +255,24 @@ const localizationStoreUpdateSelectedCountryCode = ({ isInitializing, newSelecte
244
255
  localizationStore.countryLandedCost = null;
245
256
  localizationStore.inclusivePricingConfigurations = [];
246
257
  currencyDisplay();
258
+ }
259
+ else {
260
+ localizationStore.targetCurrency = currencyCode;
261
+ // Init may apply a remembered country that reconcile then discards. Fetch
262
+ // exchange rates once after reconcile for the final country instead.
247
263
  if (!isInitializing) {
248
- void getCustomMessages();
264
+ void getNewLocalization({ isInitializing: false });
249
265
  }
250
- // Clear session so the next visit falls back to geolocation, but keep
251
- // the current shopper's explicit selection visible in the URL (so a
252
- // same-tab reload still honors it) and on the hello element.
253
- window.sessionStorage.removeItem('zonos--country');
254
- setZCountryUrlParam(selectedCountryCode);
255
- (_b = document
256
- .querySelector('zonos-hello')) === null || _b === void 0 ? void 0 : _b.setAttribute('z-country', selectedCountryCode);
257
- return;
258
266
  }
259
- localizationStore.targetCurrency = currencyCode;
260
- void getNewLocalization({ isInitializing: isInitializing });
261
267
  if (!isInitializing) {
262
268
  void getCustomMessages();
263
269
  }
264
- window.sessionStorage.setItem('zonos--country', selectedCountryCode);
265
- setZCountryUrlParam(selectedCountryCode);
266
- (_c = document
267
- .querySelector('zonos-hello')) === null || _c === void 0 ? void 0 : _c.setAttribute('z-country', selectedCountryCode);
270
+ if (shouldPersistOverride) {
271
+ setCountryOverrideStorage(selectedCountryCode);
272
+ }
273
+ if (!isInitializing) {
274
+ syncSelectedCountryToPage(selectedCountryCode);
275
+ }
268
276
  };
269
277
  const initHelloCountryList = (allCountries) => {
270
278
  var _a, _b, _c, _d, _e, _f;
@@ -343,12 +351,25 @@ const localizationStoreUpdateSelectedLocale = (requestedLocale) => {
343
351
  localizationStore.selectedLocale = newSelectedLocale;
344
352
  translationStoreUpdateLanguage(newSelectedLocale);
345
353
  void updateCheckoutSessionLanguage();
346
- void getCustomMessages();
354
+ if (localizationStore.localizationLoaded) {
355
+ void getCustomMessages();
356
+ }
347
357
  };
348
358
  const initLocalizationStore = async () => {
349
359
  var _a;
360
+ migrateCountryOverrideStorage();
361
+ const urlCountryAtLoad = getZCountryUrlParam();
362
+ const storedCountryAtLoad = getCountryOverrideStorage();
363
+ const shouldPrefetchGeo = !!storedCountryAtLoad && !urlCountryAtLoad;
350
364
  // all countries from countries.json, shipping zone and localization
351
- const [allCountries, shippingZoneCountries, localization] = await Promise.all([getCountries(), getShippingZones(), getLocalization()]);
365
+ const [allCountries, shippingZoneCountries, localization, geoLocalization] = await Promise.all([
366
+ getCountries(),
367
+ getShippingZones(),
368
+ getLocalization(),
369
+ shouldPrefetchGeo
370
+ ? getLocalization({ ignoreCountryOverride: true })
371
+ : Promise.resolve(undefined),
372
+ ]);
352
373
  // Filter countries to only include countries in the shipping zone
353
374
  const filteredCountries = shippingZoneCountries === null || shippingZoneCountries === void 0 ? void 0 : shippingZoneCountries.reduce((acc, countryCode) => {
354
375
  const countryInfo = allCountries === null || allCountries === void 0 ? void 0 : allCountries[countryCode];
@@ -367,7 +388,7 @@ const initLocalizationStore = async () => {
367
388
  // update selected country code in store
368
389
  localizationStoreUpdateSelectedCountryCode({
369
390
  isInitializing: true,
370
- newSelectedCountryCode: country || null,
391
+ newSelectedCountryCode: country || storedCountryAtLoad,
371
392
  });
372
393
  // use locale from params if it exists, otherwise use locale from localization
373
394
  const overrideLocale = getOverrideLocale();
@@ -389,10 +410,24 @@ const initLocalizationStore = async () => {
389
410
  newSelectedCountryCode: 'CA',
390
411
  });
391
412
  }
413
+ const fallbackCountry = await reconcileRememberedCountryOverride({
414
+ geoCountry: geoLocalization === null || geoLocalization === void 0 ? void 0 : geoLocalization.country,
415
+ urlCountryAtLoad,
416
+ });
417
+ if (fallbackCountry) {
418
+ localizationStoreUpdateSelectedCountryCode({
419
+ isInitializing: true,
420
+ newSelectedCountryCode: fallbackCountry,
421
+ });
422
+ }
423
+ if (localizationStore.selectedCountryCode) {
424
+ syncSelectedCountryToPage(localizationStore.selectedCountryCode);
425
+ }
426
+ void getCustomMessages();
427
+ void getNewLocalization({ isInitializing: true });
392
428
  if (!localizationStore.localizationLoaded) {
393
429
  localizationStore.localizationLoaded = true;
394
430
  void removeBigcommerceCartShipping();
395
- // shouldShowHelloWidget is false because localization is not loaded yet
396
431
  void toggleBigcommerceNativeCurrencySelector();
397
432
  }
398
433
  };
@@ -357,11 +357,11 @@ export class ZonosAddress {
357
357
  this.isAddressFilled = true;
358
358
  }
359
359
  // this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
360
- return (h(Host, { key: '9b7a5340b839d63c64da03639bdfda5a11a5c25e', class: classes([
360
+ return (h(Host, { key: '302dafde973c4bf2d847640d8f0e064d88f350f8', class: classes([
361
361
  'zonos--address',
362
362
  'zonos--elements',
363
363
  `zonos--${this.type}-address`,
364
- ]) }, this.titleText && (h("zonos-text", { key: '23739f6a48e5698372df2d53098dea6ad1c0559a', class: "zonos--title", type: "semiBoldLabel" }, this.titleText)), h("slot", { key: 'dea4b437eedaad2af2f6bbe3a1e2ae4f0706aa13', name: "below-title" }), this.renderCompanyNameInput(), this.renderTaxIdInput(), this.renderShortAddressCodeInput(), h("div", { key: 'b4be684977a632371b9b6ff4587ccdd7bacc8c67', class: "zonos--address-component" })));
364
+ ]) }, this.titleText && (h("zonos-text", { key: '706204604ad32eed710e38adbe8133b3384044eb', class: "zonos--title", type: "semiBoldLabel" }, this.titleText)), h("slot", { key: '0edc4c5d6c3ff965be6edbf680acaed892c71a16', name: "below-title" }), this.renderCompanyNameInput(), this.renderTaxIdInput(), this.renderShortAddressCodeInput(), h("div", { key: '6aa6e4e86a76f1081c5af1f2b5f3282dfd91f3c5', class: "zonos--address-component" })));
365
365
  }
366
366
  static get is() { return "zonos-address"; }
367
367
  static get encapsulation() { return "scoped"; }
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  import { h, Host, } from "@stencil/core";
3
2
  import { classes } from "../../../utils/classes";
4
3
  import { getBorderRadius } from "../../../utils/getBorderRadius";
@@ -78,9 +77,9 @@ export class ZonosAddressSuggestions {
78
77
  return segments;
79
78
  }
80
79
  render() {
81
- return (h(Host, { key: '9de4179f1bd0057ac71d6b9ed646c034035382f7', class: "zonos--address-suggestions", role: "group", style: {
80
+ return (h(Host, { key: '34018ecc951c0335041e24102329eb83a8d68439', class: "zonos--address-suggestions", role: "group", style: {
82
81
  '--zonos--border-radius': getBorderRadius(),
83
- } }, h("ul", { key: '62fa5ed92fafcdd641f9a7eb36e36e62309c9f52', "aria-label": "Suggestions", class: "wrapper", role: "listbox" }, !!this.localSuggestions.length && (h("li", { key: '27c61b5693720d0b33a75385841476787f92b884', "aria-selected": false, class: "powered-by option", role: "option" }, h("div", { key: 'fea9f2e8f65cd50fdf28fc45e18beb8976320f0d', class: "powered-by-container" }, h("zonos-text", { key: '1fec46f543e3673433b6924f7dca1cbd84e0ef16', type: "caption" }, "Suggestions powered by"), h("zonos-text", { key: '7b3fd93c18d4320522d61e07278f5388d14c8bbb', type: "semiBoldLabel" }, "Google")), h("zonos-button", { key: '61a8362ab0514a78dd71eaa9bd638dc8b50e2a9c', "aria-label": "Clear suggestions", icon: h("zonos-icon", { content: RemoveIcon }), noBackground: true, onClick: () => {
82
+ } }, h("ul", { key: '80433831c875845e57225a1317c430e2626edf9a', "aria-label": "Suggestions", class: "wrapper", role: "listbox" }, !!this.localSuggestions.length && (h("li", { key: '3510ef51b56b1cb0a36334e842792bccc2daeca5', "aria-selected": false, class: "powered-by option", role: "option" }, h("div", { key: '72773af6f9c7e0644ebc5239e4bf585bba6e164a', class: "powered-by-container" }, h("zonos-text", { key: '7fabccbe33cbc8d037dfd25f6e5b0a5bdaf97b2f', type: "caption" }, "Suggestions powered by"), h("zonos-text", { key: '2d88a3b8d7369a44e910ec60f5c7ac0c3f0ce801', type: "semiBoldLabel" }, "Google")), h("zonos-button", { key: '74315c248cc84617d854a3b51d0bad8300c6b762', "aria-label": "Clear suggestions", icon: h("zonos-icon", { content: RemoveIcon }), noBackground: true, onClick: () => {
84
83
  this.localSuggestions = [];
85
84
  } }))), this.localSuggestions.map(suggestion => (
86
85
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events
@@ -933,10 +933,10 @@ export class ZonosAddress {
933
933
  this.country = localizationStore.selectedCountryCode;
934
934
  }
935
935
  // this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
936
- return (h(Host, { key: 'b4e39a6e92e646f98c0061bf3de8e028c9285556', class: classes([
936
+ return (h(Host, { key: '9d178094ee341623633d1e3822bd79f254a27e51', class: classes([
937
937
  'zonos--address zonos--elements',
938
938
  `zonos--${this.type}-address`,
939
- ]) }, h("zonos-text", { key: '28d21737c78a1b8125c5170c67f214e3f39939ff', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), h("slot", { key: '97357f001b27197b8648d6158b786b153c31a7ba', name: "below-title" }), this.renderCompanyNameInput(), this.renderTaxIdInput(), this.renderShortAddressCodeInput(), this.renderCustomAddressForm()));
939
+ ]) }, h("zonos-text", { key: 'c36b4ce9b63cce95664894fd8929ffe15807a22a', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), h("slot", { key: '661eab7074f99b6dca52d5f7f546cfbd29322fbf', name: "below-title" }), this.renderCompanyNameInput(), this.renderTaxIdInput(), this.renderShortAddressCodeInput(), this.renderCustomAddressForm()));
940
940
  }
941
941
  static get is() { return "zonos-custom-address"; }
942
942
  static get encapsulation() { return "scoped"; }
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  import { h, Host, } from "@stencil/core";
3
2
  import { cartStore } from "../../store/checkout/cart";
4
3
  import { stripeStore, stripeStoreOnChange, } from "../../store/checkout/stripe";
@@ -1,8 +1,8 @@
1
1
  import { getOverridenZCountry } from "../getOverridenZCountry";
2
2
  import { handleFetch } from "../handleFetch";
3
- export const getLocalization = async () => {
3
+ export const getLocalization = async ({ ignoreCountryOverride = false, } = {}) => {
4
4
  try {
5
- const zCountry = getOverridenZCountry();
5
+ const zCountry = ignoreCountryOverride ? null : getOverridenZCountry();
6
6
  const searchParams = new URLSearchParams();
7
7
  if (zCountry) {
8
8
  searchParams.set('zCountry', zCountry);
@@ -1,18 +1,16 @@
1
1
  import { localizationStore } from "../../store/hello/localization";
2
- import { zonosStore } from "../../store/zonosStore";
2
+ import { isCountryInShippingZone } from "../hello/isCountryInShippingZone";
3
3
  import { log } from "../logging/log";
4
4
  export const isShippableCountry = (showLog = true,
5
5
  /**
6
6
  * If provided, will check if the country is shippable based on the provided country code instead of the Hello selected country code
7
7
  */
8
8
  providedCountryCode) => {
9
- var _a;
10
9
  if (!localizationStore.localizationLoaded) {
11
10
  return false;
12
11
  }
13
12
  if (providedCountryCode) {
14
- const isProvidedCountryCodeShippableCountry = !!((_a = localizationStore.shippingZoneCountries) === null || _a === void 0 ? void 0 : _a[providedCountryCode]) &&
15
- !zonosStore.disabledCountries.includes(providedCountryCode);
13
+ const isProvidedCountryCodeShippableCountry = isCountryInShippingZone(providedCountryCode);
16
14
  if (showLog && !isProvidedCountryCodeShippableCountry) {
17
15
  log(`Checkout: ${providedCountryCode} is not a shippable country: ${isProvidedCountryCodeShippableCountry}`);
18
16
  }
@@ -48,6 +48,7 @@ export const watchBigcommerceDomesticCheckout = ({ domesticRedirectedBtnSelector
48
48
  localizationStoreUpdateSelectedCountryCode({
49
49
  isInitializing: false,
50
50
  newSelectedCountryCode: shippingCountry,
51
+ persistOverride: false,
51
52
  });
52
53
  // do nothing if the country is still domestic
53
54
  if (!isShippableCountry(false)) {
@@ -80,6 +80,7 @@ const checkLoggedInUserShippingAddress = async ({ onInternationalCheckoutSelecte
80
80
  localizationStoreUpdateSelectedCountryCode({
81
81
  isInitializing: false,
82
82
  newSelectedCountryCode: countryCode,
83
+ persistOverride: false,
83
84
  });
84
85
  // Save the shipping address to session storage for the international checkout
85
86
  stripeStoreSaveDomesticShippingSession({
@@ -163,6 +164,7 @@ export const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedi
163
164
  localizationStoreUpdateSelectedCountryCode({
164
165
  isInitializing: false,
165
166
  newSelectedCountryCode: shippingCountry,
167
+ persistOverride: false,
166
168
  });
167
169
  const shippingAddress = {
168
170
  address1: '',
@@ -1,6 +1,4 @@
1
- export const formatDate = ({ date,
2
- // eslint-disable-next-line sort-keys/sort-keys-fix
3
- formatOptions = {
1
+ export const formatDate = ({ date, formatOptions = {
4
2
  dateStyle: 'full',
5
3
  }, }) => {
6
4
  // format date to 'Wednesday, May 15, 2024'
@@ -1,11 +1,9 @@
1
+ import { getCountryOverrideStorage } from "./hello/countryOverrideStorage";
1
2
  import { getZCountryUrlParam } from "./hello/getZCountryUrlParam";
2
3
  /**
3
- * Retrieve the zCountry from the URL or session storage.
4
+ * Retrieve the shopper country override from the URL or remembered storage.
4
5
  */
5
6
  export const getOverridenZCountry = () => {
6
7
  const currentUrl = new URL(window.location.href);
7
- // load and use country from session storage when zCountry query param is not present
8
- const countryLoadedSession = window.sessionStorage.getItem('zonos--country');
9
- const zCountry = getZCountryUrlParam(currentUrl.searchParams) || countryLoadedSession;
10
- return zCountry;
8
+ return (getZCountryUrlParam(currentUrl.searchParams) || getCountryOverrideStorage());
11
9
  };
@@ -0,0 +1,49 @@
1
+ import { isCountryCode } from "./isCountryCode";
2
+ const COUNTRY_OVERRIDE_KEY = 'zonos--country';
3
+ const withBlockedStorage = (run) => {
4
+ try {
5
+ run();
6
+ }
7
+ catch (_a) {
8
+ // localStorage/sessionStorage can throw in blocked-storage contexts
9
+ // (Safari private mode, cross-origin iframes).
10
+ }
11
+ };
12
+ const clearSessionOverride = () => {
13
+ window.sessionStorage.removeItem(COUNTRY_OVERRIDE_KEY);
14
+ };
15
+ const readStoredCountry = (storage) => {
16
+ try {
17
+ const value = storage.getItem(COUNTRY_OVERRIDE_KEY);
18
+ if (!value || !isCountryCode(value)) {
19
+ return null;
20
+ }
21
+ return value;
22
+ }
23
+ catch (_a) {
24
+ return null;
25
+ }
26
+ };
27
+ export const getCountryOverrideStorage = () => {
28
+ var _a;
29
+ return (_a = readStoredCountry(window.localStorage)) !== null && _a !== void 0 ? _a : readStoredCountry(window.sessionStorage);
30
+ };
31
+ export const migrateCountryOverrideStorage = () => {
32
+ withBlockedStorage(() => {
33
+ if (readStoredCountry(window.localStorage)) {
34
+ clearSessionOverride();
35
+ }
36
+ });
37
+ };
38
+ export const setCountryOverrideStorage = (countryCode) => {
39
+ withBlockedStorage(() => {
40
+ window.localStorage.setItem(COUNTRY_OVERRIDE_KEY, countryCode);
41
+ clearSessionOverride();
42
+ });
43
+ };
44
+ export const clearCountryOverrideStorage = () => {
45
+ withBlockedStorage(() => {
46
+ window.localStorage.removeItem(COUNTRY_OVERRIDE_KEY);
47
+ clearSessionOverride();
48
+ });
49
+ };
@@ -1,16 +1,12 @@
1
- const validateCountryCode = (countryCode) => {
2
- // Check that the country is two characters and is upper case
3
- if (countryCode && /^[A-Z]{2}$/.test(countryCode)) {
4
- return countryCode;
5
- }
6
- return null;
7
- };
1
+ import { isCountryCode } from "./isCountryCode";
8
2
  export const getZCountryUrlParam = (urlParams) => {
9
3
  const urlSearchParams = new URLSearchParams(urlParams || window.location.search);
10
4
  const getCountryParam = (param) => {
11
5
  const country = urlSearchParams.get(param);
12
- // Check that the country is two characters and is upper case
13
- return validateCountryCode(country);
6
+ if (country && isCountryCode(country)) {
7
+ return country;
8
+ }
9
+ return null;
14
10
  };
15
11
  const zCountry = getCountryParam('zCountry');
16
12
  // Fallback to legacy 'country'
@@ -0,0 +1 @@
1
+ export const isCountryCode = (value) => /^[A-Z]{2}$/.test(value);
@@ -0,0 +1,8 @@
1
+ import { localizationStore } from "../../store/hello/localization";
2
+ import { zonosStore } from "../../store/zonosStore";
3
+ export const isCountryInShippingZone = (countryCode) => {
4
+ var _a;
5
+ return !!countryCode &&
6
+ !!((_a = localizationStore.shippingZoneCountries) === null || _a === void 0 ? void 0 : _a[countryCode]) &&
7
+ !zonosStore.disabledCountries.includes(countryCode);
8
+ };
@@ -0,0 +1,37 @@
1
+ import { getLocalization } from "../api/getLocalization";
2
+ import { clearCountryOverrideStorage, getCountryOverrideStorage, } from "./countryOverrideStorage";
3
+ import { getHelloWidgetVisibility } from "./shouldShowHelloWidget";
4
+ /**
5
+ * Drop a remembered Hello country when widgetVisibility would hide the
6
+ * widget for it, then fall back to geo.
7
+ *
8
+ * Does not mutate the localization store — the caller applies the returned
9
+ * country. Pass `geoCountry` when init already fetched IP localization so
10
+ * discard does not wait on a second round trip. Pass `urlCountryAtLoad`
11
+ * from the URL as it was at page load (before init writes `zCountry` for
12
+ * URL_PARAM merchants). Do not omit it after a live URL write — the
13
+ * default is `null`, not the current URL. Storage is cleared when geo
14
+ * succeeds, or when a load-time URL country won and the stored country
15
+ * would be hidden.
16
+ */
17
+ export const reconcileRememberedCountryOverride = async ({ geoCountry, urlCountryAtLoad = null, } = {}) => {
18
+ const storedCountry = getCountryOverrideStorage();
19
+ if (!storedCountry) {
20
+ return null;
21
+ }
22
+ if (getHelloWidgetVisibility(false, storedCountry)) {
23
+ return null;
24
+ }
25
+ if (urlCountryAtLoad) {
26
+ clearCountryOverrideStorage();
27
+ return null;
28
+ }
29
+ const country = geoCountry !== undefined
30
+ ? geoCountry
31
+ : (await getLocalization({ ignoreCountryOverride: true })).country;
32
+ if (!country) {
33
+ return null;
34
+ }
35
+ clearCountryOverrideStorage();
36
+ return country;
37
+ };
@@ -1,35 +1,25 @@
1
1
  import { localizationStore } from "../../store/hello/localization";
2
2
  import { zonosStore } from "../../store/zonosStore";
3
+ import { isCountryInShippingZone } from "./isCountryInShippingZone";
3
4
  import { log } from "../logging/log";
4
5
  /**
5
- * Whether the Hello widget should be shown for the current shopper. This is the
6
- * single source of truth for Hello's visibility decision — the `zonos-hello`
7
- * component renders by it, and other features (e.g. BigCommerce cart shipping
8
- * cleanup) gate on it so their behavior stays in lockstep with what the shopper
9
- * actually sees.
10
- *
11
- * Resolves the configured `widgetVisibility` behavior (with the deprecated
12
- * `showForCountries` override) against the selected country and shipping-zone
13
- * state, then applies the include/exclude country overrides.
14
- *
15
- * @param showLog - emit a debug log when the shopper is not in a shipping zone.
16
- * Defaults to `true`; pass `false` from non-rendering callers to avoid log
17
- * noise.
6
+ * Visibility rules for Hello, ignoring whether localization has finished
7
+ * loading. Used during init reconcile before `localizationLoaded` is set.
8
+ * Pass `countryCode` to evaluate a remembered country instead of the
9
+ * currently selected one.
18
10
  */
19
- export const shouldShowHelloWidget = (showLog = true) => {
11
+ export const getHelloWidgetVisibility = (showLog = true, countryCode = localizationStore.selectedCountryCode) => {
20
12
  var _a, _b;
21
- if (!localizationStore.localizationLoaded) {
22
- return false;
23
- }
24
13
  const { countryDisplayRules, showForCountries } = zonosStore.helloSettings;
25
14
  const visibilityRules = countryDisplayRules === null || countryDisplayRules === void 0 ? void 0 : countryDisplayRules.widgetVisibility;
26
- const selectedCountry = localizationStore.selectedCountryCode;
15
+ const selectedCountry = countryCode;
16
+ const isShippableCountry = isCountryInShippingZone(countryCode);
27
17
  // Resolve behavior: deprecated showForCountries overrides widgetVisibility.behavior
28
18
  // If showForCountries is an array of country codes, treat as legacy explicit list
29
19
  const behavior = Array.isArray(showForCountries)
30
20
  ? showForCountries
31
21
  : (showForCountries !== null && showForCountries !== void 0 ? showForCountries : visibilityRules === null || visibilityRules === void 0 ? void 0 : visibilityRules.behavior);
32
- if (showLog && !localizationStore.isShippableCountry) {
22
+ if (showLog && !isShippableCountry) {
33
23
  log(`Hello: not shippable country - Show for countries: ${behavior}`);
34
24
  }
35
25
  // Legacy: explicit list of country codes from deprecated showForCountries
@@ -43,7 +33,7 @@ export const shouldShowHelloWidget = (showLog = true) => {
43
33
  }
44
34
  else {
45
35
  // Default: ONLY_SHIPPABLE
46
- isVisible = localizationStore.isShippableCountry;
36
+ isVisible = isShippableCountry;
47
37
  }
48
38
  // Apply includedCountries — force show the widget for these countries
49
39
  if (!isVisible &&
@@ -59,3 +49,20 @@ export const shouldShowHelloWidget = (showLog = true) => {
59
49
  }
60
50
  return isVisible;
61
51
  };
52
+ /**
53
+ * Whether the Hello widget should be shown for the current shopper. This is the
54
+ * single source of truth for Hello's visibility decision — the `zonos-hello`
55
+ * component renders by it, and other features (e.g. BigCommerce cart shipping
56
+ * cleanup) gate on it so their behavior stays in lockstep with what the shopper
57
+ * actually sees.
58
+ *
59
+ * @param showLog - emit a debug log when the shopper is not in a shipping zone.
60
+ * Defaults to `true`; pass `false` from non-rendering callers to avoid log
61
+ * noise.
62
+ */
63
+ export const shouldShowHelloWidget = (showLog = true) => {
64
+ if (!localizationStore.localizationLoaded) {
65
+ return false;
66
+ }
67
+ return getHelloWidgetVisibility(showLog);
68
+ };
@@ -78,7 +78,6 @@ export const env = createEnv({
78
78
  },
79
79
  // eslint-disable-next-line sort-keys/sort-keys-fix
80
80
  client: envClient,
81
- // eslint-disable-next-line sort-keys/sort-keys-fix
82
81
  runtimeEnvStrict: {
83
82
  NEXT_PUBLIC_FLAG_URL: process.env.NEXT_PUBLIC_FLAG_URL,
84
83
  NEXT_PUBLIC_RELEASE_DATE: new Date().getTime().toString(),
@@ -77,7 +77,6 @@ export const zonosStripeLoadScript = (params) => {
77
77
  });
78
78
  return stripePromise;
79
79
  };
80
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
80
  const registerWrapper = (stripe, startTime) => {
82
81
  if (!stripe || !stripe._registerWrapper) {
83
82
  return;
@@ -92,7 +91,6 @@ export const initStripe = (maybeStripe, args, startTime) => {
92
91
  registerWrapper(stripe, startTime);
93
92
  return stripe;
94
93
  };
95
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
96
94
  export const validateLoadParams = (params) => {
97
95
  const errorMessage = `invalid load parameters; expected object of shape
98
96
 
@@ -90,7 +90,7 @@ Zonos.init = async (params) => {
90
90
  // Expose the checkout cart callbacks on the global so Stripe loading can be
91
91
  // gated on whether at least one of them is configured.
92
92
  _a.createCartId = checkoutSettings === null || checkoutSettings === void 0 ? void 0 : checkoutSettings.createCartId;
93
- // eslint-disable-next-line deprecation/deprecation -- intentionally mirror the (deprecated) callback so Stripe loading can be gated on it
93
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- intentionally mirror the (deprecated) callback so Stripe loading can be gated on it
94
94
  _a.buildCartDetail = checkoutSettings === null || checkoutSettings === void 0 ? void 0 : checkoutSettings.buildCartDetail;
95
95
  if (_a.doneInit) {
96
96
  // do nothing if zonos is already initialized