@zonos/elements 1.3.229 → 1.3.231

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 (237) hide show
  1. package/dist/cjs/{buildCartItemsByTempCart-309fcebf.js → buildCartItemsByTempCart-edddbf4b.js} +1 -0
  2. package/dist/cjs/{cart-ad82a680.js → cart-9b519566.js} +6 -2
  3. package/dist/cjs/hasInclusivePrice-12605be9.js +24 -0
  4. package/dist/cjs/index.cjs.js +7 -7
  5. package/dist/cjs/{localization-31e3dfe3.js → localization-38af974b.js} +118 -30
  6. package/dist/cjs/{paypal-88b5e878.js → paypal-e8fa2302.js} +3 -3
  7. package/dist/cjs/{placeTestOrder-6aefbf9c.js → placeTestOrder-6388881f.js} +11 -7
  8. package/dist/cjs/{renderFallback-87c908ad.js → renderFallback-bb2c4bce.js} +2 -2
  9. package/dist/cjs/{translationStore-b8b25e9d.js → translationStore-f2d5eae9.js} +420 -360
  10. package/dist/cjs/zonos-address_11.cjs.entry.js +21 -5
  11. package/dist/cjs/zonos-cart-items_13.cjs.entry.js +73 -13
  12. package/dist/cjs/zonos-checkout.cjs.entry.js +9 -6
  13. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +3 -3
  14. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +6 -6
  15. package/dist/cjs/zonos-collect.cjs.entry.js +6 -6
  16. package/dist/cjs/zonos-confirm-dialog_2.cjs.entry.js +1 -1
  17. package/dist/cjs/zonos-controller.cjs.entry.js +12 -5
  18. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  19. package/dist/cjs/zonos-country-select_4.cjs.entry.js +9 -6
  20. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +4 -4
  21. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +55 -45
  22. package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
  23. package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
  24. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.js +68 -7
  25. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +1 -1
  26. package/dist/collection/components/checkout/zonos-checkout/zonos-review/zonos-review.js +2 -1
  27. package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +7 -4
  28. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +54 -43
  29. package/dist/collection/components/main/zonos-controller.js +5 -2
  30. package/dist/collection/components/store/hello/localization.js +47 -16
  31. package/dist/collection/components/store/translationStore/strings.arabic.js +21 -18
  32. package/dist/collection/components/store/translationStore/strings.base.js +21 -18
  33. package/dist/collection/components/store/translationStore/strings.chinese.js +21 -18
  34. package/dist/collection/components/store/translationStore/strings.danish.js +21 -18
  35. package/dist/collection/components/store/translationStore/strings.dutch.js +21 -18
  36. package/dist/collection/components/store/translationStore/strings.french.js +21 -18
  37. package/dist/collection/components/store/translationStore/strings.german.js +21 -18
  38. package/dist/collection/components/store/translationStore/strings.hebrew.js +21 -18
  39. package/dist/collection/components/store/translationStore/strings.indonesian.js +21 -18
  40. package/dist/collection/components/store/translationStore/strings.italian.js +21 -18
  41. package/dist/collection/components/store/translationStore/strings.japanese.js +21 -18
  42. package/dist/collection/components/store/translationStore/strings.korean.js +21 -18
  43. package/dist/collection/components/store/translationStore/strings.norwegian.js +21 -18
  44. package/dist/collection/components/store/translationStore/strings.polish.js +21 -18
  45. package/dist/collection/components/store/translationStore/strings.portuguese.js +21 -18
  46. package/dist/collection/components/store/translationStore/strings.russian.js +21 -18
  47. package/dist/collection/components/store/translationStore/strings.spanish.js +21 -18
  48. package/dist/collection/components/store/translationStore/strings.swedish.js +21 -18
  49. package/dist/collection/components/store/translationStore/strings.turkish.js +21 -18
  50. package/dist/collection/components/store/translationStore/strings.vietnamese.js +21 -18
  51. package/dist/collection/components/stripe/zonos-link-authentication/zonos-link-authentication.js +18 -2
  52. package/dist/collection/components/utils/api/buildCartItemsByTempCart.js +1 -0
  53. package/dist/collection/components/utils/api/{getInclusivePricing.js → getInclusivePriceConfigurations.js} +1 -1
  54. package/dist/collection/components/utils/api/getLocalization.js +2 -5
  55. package/dist/collection/components/utils/api/getZonosSettings.js +5 -0
  56. package/dist/collection/components/utils/api/prepCalculateLandedCost.js +6 -0
  57. package/dist/collection/components/utils/checkout/renderCheckoutCurrency.js +10 -5
  58. package/dist/collection/components/utils/checkout/watchBigcommerceDomesticCheckout.js +4 -1
  59. package/dist/collection/components/utils/getOverridenZCountry.js +11 -0
  60. package/dist/collection/components/utils/hasInclusivePrice.js +10 -0
  61. package/dist/collection/components/utils/hello/currencyConversion/applyInclusiveEffectiveRate.js +10 -0
  62. package/dist/collection/components/utils/hello/currencyConversion/applyInclusivePrice.js +39 -0
  63. package/dist/collection/components/utils/hello/currencyConversion/calculateInclusivePrice.js +32 -0
  64. package/dist/collection/components/utils/hello/currencyConversion/defaultCurrencyConverter.js +11 -6
  65. package/dist/collection/constants/key.js +9 -0
  66. package/dist/collection/types/InclusivePricing.js +1 -0
  67. package/dist/collection/types/generated/graphql.internal.types.js +87 -3
  68. package/dist/collection/types/index.js +1 -0
  69. package/dist/collection/utils/performBlurCurrency.js +38 -5
  70. package/dist/esm/{buildCartItemsByTempCart-c4488f73.js → buildCartItemsByTempCart-a117f75d.js} +1 -0
  71. package/dist/esm/{cart-c74f9aaa.js → cart-bc0e1598.js} +6 -2
  72. package/dist/esm/hasInclusivePrice-706cc09d.js +20 -0
  73. package/dist/esm/index.js +7 -7
  74. package/dist/esm/{localization-106476cb.js → localization-53f67640.js} +117 -31
  75. package/dist/esm/{paypal-bf3a2bdd.js → paypal-3a6a048d.js} +3 -3
  76. package/dist/esm/{placeTestOrder-891295e8.js → placeTestOrder-917731cf.js} +11 -7
  77. package/dist/esm/{renderFallback-ce0e238a.js → renderFallback-cd0e40d9.js} +2 -2
  78. package/dist/esm/{translationStore-766b7521.js → translationStore-d241dcf7.js} +420 -360
  79. package/dist/esm/zonos-address_11.entry.js +21 -5
  80. package/dist/esm/zonos-cart-items_13.entry.js +73 -13
  81. package/dist/esm/zonos-checkout.entry.js +9 -6
  82. package/dist/esm/zonos-collect-cart-items_3.entry.js +3 -3
  83. package/dist/esm/zonos-collect-finish_6.entry.js +6 -6
  84. package/dist/esm/zonos-collect.entry.js +6 -6
  85. package/dist/esm/zonos-confirm-dialog_2.entry.js +1 -1
  86. package/dist/esm/zonos-controller.entry.js +12 -5
  87. package/dist/esm/zonos-country-flag.entry.js +2 -2
  88. package/dist/esm/zonos-country-select_4.entry.js +9 -6
  89. package/dist/esm/zonos-empty-state-payment_4.entry.js +4 -4
  90. package/dist/esm/zonos-hello-dialog.entry.js +55 -45
  91. package/dist/esm/zonos-hello.entry.js +2 -2
  92. package/dist/esm/zonos-language-select_2.entry.js +2 -2
  93. package/dist/esm-es5/buildCartItemsByTempCart-a117f75d.js +1 -0
  94. package/dist/esm-es5/cart-bc0e1598.js +1 -0
  95. package/dist/esm-es5/hasInclusivePrice-706cc09d.js +1 -0
  96. package/dist/esm-es5/index.js +1 -1
  97. package/dist/esm-es5/localization-53f67640.js +1 -0
  98. package/dist/esm-es5/{paypal-bf3a2bdd.js → paypal-3a6a048d.js} +1 -1
  99. package/dist/esm-es5/placeTestOrder-917731cf.js +1 -0
  100. package/dist/esm-es5/{renderFallback-ce0e238a.js → renderFallback-cd0e40d9.js} +1 -1
  101. package/dist/esm-es5/translationStore-d241dcf7.js +1 -0
  102. package/dist/esm-es5/zonos-address_11.entry.js +1 -1
  103. package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
  104. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  105. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  106. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  107. package/dist/esm-es5/zonos-collect.entry.js +1 -1
  108. package/dist/esm-es5/zonos-confirm-dialog_2.entry.js +1 -1
  109. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  110. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  111. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  112. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  113. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  114. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  115. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  116. package/dist/scripts/blurCurrencyOnInit.js +1 -1
  117. package/dist/scripts/index.d.ts +39 -6
  118. package/dist/scripts/index.js +1 -1
  119. package/dist/scripts/loadZonos.js +1 -1
  120. package/dist/scripts/zonos.js +1 -1
  121. package/dist/types/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.d.ts +2 -0
  122. package/dist/types/components/hello/zonos-hello-dialog/zonos-hello-dialog.d.ts +1 -1
  123. package/dist/types/components/store/checkout/cart.d.ts +3 -0
  124. package/dist/types/components/store/hello/localization.d.ts +14 -3
  125. package/dist/types/components/store/translationStore/strings.arabic.d.ts +18 -15
  126. package/dist/types/components/store/translationStore/strings.base.d.ts +18 -15
  127. package/dist/types/components/store/translationStore/strings.chinese.d.ts +18 -15
  128. package/dist/types/components/store/translationStore/strings.danish.d.ts +18 -15
  129. package/dist/types/components/store/translationStore/strings.dutch.d.ts +18 -15
  130. package/dist/types/components/store/translationStore/strings.french.d.ts +18 -15
  131. package/dist/types/components/store/translationStore/strings.german.d.ts +18 -15
  132. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +18 -15
  133. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +18 -15
  134. package/dist/types/components/store/translationStore/strings.italian.d.ts +18 -15
  135. package/dist/types/components/store/translationStore/strings.japanese.d.ts +18 -15
  136. package/dist/types/components/store/translationStore/strings.korean.d.ts +18 -15
  137. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +18 -15
  138. package/dist/types/components/store/translationStore/strings.polish.d.ts +18 -15
  139. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +18 -15
  140. package/dist/types/components/store/translationStore/strings.russian.d.ts +18 -15
  141. package/dist/types/components/store/translationStore/strings.spanish.d.ts +18 -15
  142. package/dist/types/components/store/translationStore/strings.swedish.d.ts +18 -15
  143. package/dist/types/components/store/translationStore/strings.turkish.d.ts +18 -15
  144. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +18 -15
  145. package/dist/types/components/utils/api/getInclusivePriceConfigurations.d.ts +2 -0
  146. package/dist/types/components/utils/getOverridenZCountry.d.ts +5 -0
  147. package/dist/types/components/utils/hasInclusivePrice.d.ts +1 -0
  148. package/dist/types/components/utils/hello/currencyConversion/applyInclusiveEffectiveRate.d.ts +1 -0
  149. package/dist/types/components/utils/hello/currencyConversion/applyInclusivePrice.d.ts +1 -0
  150. package/dist/types/components/utils/hello/currencyConversion/calculateInclusivePrice.d.ts +27 -0
  151. package/dist/types/constants/key.d.ts +9 -0
  152. package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +5 -0
  153. package/dist/types/types/InclusivePricing.d.ts +13 -0
  154. package/dist/types/types/checkout/api/CalculateLandedCost.d.ts +1 -0
  155. package/dist/types/types/checkout/api/NormalizedTempCart.d.ts +6 -0
  156. package/dist/types/types/generated/graphql.internal.types.d.ts +192 -51
  157. package/dist/types/types/generated/graphql.internal.types.ts +229 -50
  158. package/dist/types/types/index.d.ts +1 -0
  159. package/dist/types/types/utils/ZonosSettings.d.ts +2 -0
  160. package/dist/types/utils/performBlurCurrency.d.ts +12 -0
  161. package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
  162. package/dist/zonos-elements/index.esm.js +1 -1
  163. package/dist/zonos-elements/{p-c89e9d56.system.js → p-0047fecf.system.js} +1 -1
  164. package/dist/zonos-elements/{p-bd373de0.system.entry.js → p-0bc8e55c.system.entry.js} +1 -1
  165. package/dist/zonos-elements/{p-964a4d85.js → p-2008df67.js} +1 -1
  166. package/dist/zonos-elements/{p-2db90c99.system.entry.js → p-22338b4a.system.entry.js} +1 -1
  167. package/dist/zonos-elements/{p-3d2925c5.system.entry.js → p-2eaa5013.system.entry.js} +1 -1
  168. package/dist/zonos-elements/{p-288f5a5b.system.entry.js → p-304bdbc2.system.entry.js} +1 -1
  169. package/dist/zonos-elements/p-30981f80.entry.js +1 -0
  170. package/dist/zonos-elements/{p-69451a50.system.js → p-398d9022.system.js} +1 -1
  171. package/dist/zonos-elements/p-3a242dfc.system.js +1 -0
  172. package/dist/zonos-elements/{p-5608ac9d.entry.js → p-3eda5c2c.entry.js} +1 -1
  173. package/dist/zonos-elements/p-3f0ca5f9.js +1 -0
  174. package/dist/zonos-elements/{p-23f6a2fb.system.entry.js → p-3f35b8b1.system.entry.js} +1 -1
  175. package/dist/zonos-elements/{p-de984173.system.js → p-419c292c.system.js} +1 -1
  176. package/dist/zonos-elements/{p-7a97e1cf.system.entry.js → p-4697f061.system.entry.js} +1 -1
  177. package/dist/zonos-elements/p-4f5be8f0.entry.js +1 -0
  178. package/dist/zonos-elements/p-516a9666.system.js +1 -0
  179. package/dist/zonos-elements/p-55c6ff14.system.entry.js +1 -0
  180. package/dist/zonos-elements/p-6d563f33.system.entry.js +1 -0
  181. package/dist/zonos-elements/{p-9c728733.system.js → p-7730879e.system.js} +1 -1
  182. package/dist/zonos-elements/p-7920d79c.system.js +1 -0
  183. package/dist/zonos-elements/p-7c96a585.js +1 -0
  184. package/dist/zonos-elements/p-81b357f7.system.js +1 -1
  185. package/dist/zonos-elements/{p-29c80a34.js → p-83666056.js} +1 -1
  186. package/dist/zonos-elements/{p-2b84039a.entry.js → p-91fa43ef.entry.js} +1 -1
  187. package/dist/zonos-elements/p-9a444a82.system.entry.js +1 -0
  188. package/dist/zonos-elements/p-9bdad585.system.entry.js +1 -0
  189. package/dist/zonos-elements/p-abc0fb80.js +1 -0
  190. package/dist/zonos-elements/{p-b0a75761.entry.js → p-ac26a931.entry.js} +1 -1
  191. package/dist/zonos-elements/p-bb707dfd.system.js +1 -0
  192. package/dist/zonos-elements/{p-10894d36.entry.js → p-bc963b03.entry.js} +1 -1
  193. package/dist/zonos-elements/p-c0e080e3.js +1 -0
  194. package/dist/zonos-elements/p-c20429ea.entry.js +1 -0
  195. package/dist/zonos-elements/p-c28da00e.entry.js +1 -0
  196. package/dist/zonos-elements/p-c9be03e0.entry.js +1 -0
  197. package/dist/zonos-elements/{p-6c8e4f01.system.entry.js → p-cb70de13.system.entry.js} +1 -1
  198. package/dist/zonos-elements/p-cec35a21.entry.js +1 -0
  199. package/dist/zonos-elements/{p-cf56b990.entry.js → p-d15cd138.entry.js} +1 -1
  200. package/dist/zonos-elements/{p-6f1024de.system.entry.js → p-d852d6da.system.entry.js} +1 -1
  201. package/dist/zonos-elements/p-d9486c57.entry.js +1 -0
  202. package/dist/zonos-elements/p-db73c11a.entry.js +1 -0
  203. package/dist/zonos-elements/{p-203c7fda.js → p-e27a9450.js} +1 -1
  204. package/dist/zonos-elements/{p-76f924b3.entry.js → p-ede9e968.entry.js} +1 -1
  205. package/dist/zonos-elements/p-ee8fcde6.js +1 -0
  206. package/dist/zonos-elements/p-f688d7a4.system.js +1 -0
  207. package/dist/zonos-elements/{p-236e0144.system.entry.js → p-ff1722d0.system.entry.js} +1 -1
  208. package/dist/zonos-elements/p-ff522088.system.entry.js +1 -0
  209. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  210. package/package.json +3 -3
  211. package/dist/esm-es5/buildCartItemsByTempCart-c4488f73.js +0 -1
  212. package/dist/esm-es5/cart-c74f9aaa.js +0 -1
  213. package/dist/esm-es5/localization-106476cb.js +0 -1
  214. package/dist/esm-es5/placeTestOrder-891295e8.js +0 -1
  215. package/dist/esm-es5/translationStore-766b7521.js +0 -1
  216. package/dist/types/components/utils/api/getInclusivePricing.d.ts +0 -6
  217. package/dist/zonos-elements/p-053a042e.entry.js +0 -1
  218. package/dist/zonos-elements/p-0d3767ec.entry.js +0 -1
  219. package/dist/zonos-elements/p-1d15662c.js +0 -1
  220. package/dist/zonos-elements/p-21b251f0.system.entry.js +0 -1
  221. package/dist/zonos-elements/p-225a61c4.system.entry.js +0 -1
  222. package/dist/zonos-elements/p-462f8857.entry.js +0 -1
  223. package/dist/zonos-elements/p-57ee34aa.system.entry.js +0 -1
  224. package/dist/zonos-elements/p-595668d7.system.js +0 -1
  225. package/dist/zonos-elements/p-62803534.entry.js +0 -1
  226. package/dist/zonos-elements/p-6497ce22.entry.js +0 -1
  227. package/dist/zonos-elements/p-65db3219.entry.js +0 -1
  228. package/dist/zonos-elements/p-94853366.system.entry.js +0 -1
  229. package/dist/zonos-elements/p-9972941a.entry.js +0 -1
  230. package/dist/zonos-elements/p-ad7be556.system.entry.js +0 -1
  231. package/dist/zonos-elements/p-b4fe3604.system.js +0 -1
  232. package/dist/zonos-elements/p-b8293509.js +0 -1
  233. package/dist/zonos-elements/p-c3c3cd98.js +0 -1
  234. package/dist/zonos-elements/p-cdaf52f4.system.js +0 -1
  235. package/dist/zonos-elements/p-cef1e888.system.js +0 -1
  236. package/dist/zonos-elements/p-eea0d8af.js +0 -1
  237. package/dist/zonos-elements/p-f4085c23.entry.js +0 -1
@@ -1 +0,0 @@
1
- import{e as r}from"./p-1d15662c.js";import{d as o,s}from"./p-c3c3cd98.js";import{l as n,h as i}from"./p-41dd1cb8.js";const e=({amount:s,isForeign:n})=>{var i,e;const t=(null===(i=r.exchangeRate)||void 0===i?void 0:i.rate)||1,d=r.currency;if((null===(e=r.items[0])||void 0===e?void 0:e.currencyCode)===d)return o({amount:s,currency:d});const a=r.displayBaseCurrency,c=(()=>{var o,s;return r.displayBaseCurrency&&(null===(o=r.exchangeRate)||void 0===o?void 0:o.sourceCurrencyCode)?null===(s=r.exchangeRate)||void 0===s?void 0:s.sourceCurrencyCode:r.currency})();return o(n?{amount:a?s/t:s,currency:c}:{amount:a?s:s*t,currency:c})},t=async()=>{var o,e;const t=null===(o=r.partiesData.find((r=>"DESTINATION"===r.type)))||void 0===o?void 0:o.id,d=null===(e=r.partiesData.find((r=>"PAYOR"===r.type)))||void 0===e?void 0:e.id,a=s.checkoutSessionId;if(!a||!d||!t)return n("Missing required data",{billToPartyId:d,checkoutSessionId:a,shipToPartyId:t}),{errors:["Missing required data"],json:null};const c={billToPartyId:d,checkoutSessionId:a,shipToPartyId:t},{errors:u,json:l}=await i("/api/zonos-elements/place-test-order",{body:c,method:"POST"});return u.length||!l?(n("Error occurs when placing test order",u),{errors:u.map((r=>r.message)),json:null}):{errors:[],json:l}};export{t as p,e as r}
@@ -1 +0,0 @@
1
- import{c as e,z as n}from"./p-7af39c98.js";import{j as o,h as t,l as r}from"./p-41dd1cb8.js";import{a,l as s}from"./p-0a377722.js";import{a as c}from"./p-eea0d8af.js";const i=e=>{return!!(n=e).find((e=>e.testKey in a))||s("No available test key found in response","info",{response:n}),n.find((e=>e.testKey in a))?e.filter((e=>{var n;const o=a[e.testKey]&&!e.selectedVariantKey,t=e.selectedVariantKey&&!!(null===(n=a[e.testKey])||void 0===n?void 0:n.availableVariants.includes(e.selectedVariantKey));return o||t})).map((e=>Object.assign(Object.assign({},e),{expiresAt:e.expiresAt||Date.now()+l,selectedVariantKey:e.selectedVariantKey||null}))):[];var n},l=864e5,{onChange:u,state:d}=e({checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id"),enabledVariantTestKeys:o(localStorage.getItem("zonos--enabled-variant-test-keys"))});u("enabledVariantTestKeys",(()=>{var e;(null===(e=d.enabledVariantTestKeys)||void 0===e?void 0:e.length)?localStorage.setItem("zonos--enabled-variant-test-keys",JSON.stringify(d.enabledVariantTestKeys)):localStorage.removeItem("zonos--enabled-variant-test-keys")})),u("checkoutSessionId",(()=>{d.checkoutSessionId?sessionStorage.setItem("zonos--checkout-session-id",d.checkoutSessionId):sessionStorage.removeItem("zonos--checkout-session-id")}));const y=e=>{d.enabledVariantTestKeys=i(e)},m=async()=>{try{const{errors:e,json:n}=await t("/api/zonos-elements/get-countries",{method:"GET"});return e.length||!n?null:n}catch(e){return null}},w={exchangeRate:{rate:1,targetFormat:{currencyCode:"USD",decimalDelimiter:".",scale:2,symbol:"$",symbolLocation:"before",thousandsDelimiter:","}},maxAge:null},v=e=>{const n=new URLSearchParams(e||window.location.search),o=e=>{return(o=n.get(e))&&/^[A-Z]{2}$/.test(o)?o:null;var o},t=o("zCountry"),r=o("country"),a=o("customerCountry");return t||r||a},g=async()=>{try{const e=new URL(window.location.href),n=window.sessionStorage.getItem("zonos--country"),o=v(e.searchParams)||n,r=new URLSearchParams;o&&r.set("zCountry",o);const{errors:a,json:s}=await t(`/api/zonos-elements/localization?${r.toString()}`);return a.length||!s?{country:null,locale:null}:{country:s.country,locale:s.locale}}catch(e){return{country:null,locale:null}}},p=async()=>{var e,n,o;if(null===(e=window.Zonos.cartSettings)||void 0===e?void 0:e.shippingZones)return window.Zonos.cartSettings.shippingZones.flatMap((e=>null==e?void 0:e.countryCodes)).filter(Boolean);const{errors:a,json:s}=await t("/api/zonos-elements/shipping-zones");return a.length||!s?(r(`Error fetching shipping zones: ${null===(n=a.find(Boolean))||void 0===n?void 0:n.message}`),null):(null===(o=null==s?void 0:s.shippingZones)||void 0===o?void 0:o.flatMap((e=>null==e?void 0:e.countryCodes)).filter(Boolean))||null},f=e=>{const{exchangeRate:n}=E;if(!n||!e||isNaN(e))return e;const o=(e*n.rate).toFixed((null==n?void 0:n.targetFormat.scale)||2);return Number(o)},h=({amount:e,currency:o})=>{if(isNaN(e)||0!==e&&!e)return"";const t=n.overrideCurrencyFormat,{exchangeRate:r}=E,a=o||E.targetCurrency;if("function"==typeof t)return t({amount:e,currencyCode:a,numberFormat:({amount:e})=>(({amount:e,currency:n,targetFormat:o})=>{const t=n||E.targetCurrency,r=(null==o?void 0:o.scale)||2,a=-1!==window.navigator.userAgent.indexOf("MSIE "),s="object"==typeof Intl&&Intl&&"function"==typeof Intl.NumberFormat;return a||!s?Number(e).toFixed(r).replace(".","|dec|").replace(",",(null==o?void 0:o.thousandsDelimiter)||"").replace("|dec|",(null==o?void 0:o.decimalDelimiter)||""):new Intl.NumberFormat(window.navigator.language,{currency:t,currencyDisplay:"code",minimumFractionDigits:r,style:"currency"}).format(e).replace(new RegExp(`${t}\\s+`),"")})({amount:e,currency:a,targetFormat:(null==r?void 0:r.targetFormat)||null})});const{targetFormat:s}=r||{};if(!s||!r)return`${e.toFixed(2)} ${a}`;const c=s.scale||2,i=-1!==window.navigator.userAgent.indexOf("MSIE "),l="object"==typeof Intl&&Intl&&"function"==typeof Intl.NumberFormat;if(i||!l)return`${Number(e).toFixed(c).replace(".","|dec|").replace(",",s.thousandsDelimiter||"").replace("|dec|",s.decimalDelimiter||"")}${"USD"!==s.currencyCode?` ${s.currencyCode}`:""}`;const u=(null==t?void 0:t.currencyDisplay)||"symbol",d=new Intl.NumberFormat(window.navigator.language,{currency:a,currencyDisplay:u,minimumFractionDigits:c,style:"currency"}).format(e);return"code"===u?`${d.replace(new RegExp(`${a}\\s+`),"")} ${a}`:d},C=e=>{const n=f(e);return h({amount:n})},z=e=>{try{document.createDocumentFragment().querySelector(e)}catch(e){return!1}return!0},b="z--blur",S=async()=>{const e=window.zonosBlurCurrencyOnInitIntervalId;e&&(await new Promise((e=>setTimeout(e,500))),clearInterval(e),document.querySelectorAll(`.${b}`).forEach((e=>{e.classList.remove(b)})),window.zonosBlurCurrencyOnInitIntervalId=void 0)},$=({currencySelector:e})=>{e&&document.querySelectorAll([e].filter(Boolean).join(",")).forEach((e=>{e.classList.add(b)}))},A=()=>{if("undefined"==typeof window)return;if(window.zonosBlurCurrencyOnInitIntervalId)return;$({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});const e=setInterval((()=>{$({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})}),10);window.zonosBlurCurrencyOnInitIntervalId=e,setTimeout((()=>{S()}),7e3)},j=()=>{const{currencyElementSelector:e}=n.helloSettings,o=(e=>{const n=e||".money";if(!z(n))return r(`Currency element selector "${n}" is not valid.`),null;const o=document.querySelectorAll(n);return o.length?Array.from(o):(s(`No currency elements found with selector "${n}"`,"warn"),null)})(e);(null==o?void 0:o.length)&&(E.exchangeRate?o.forEach((e=>{(e=>{var o;const t=(e=>{var n;const o=e.getAttribute("data-domestic"),t=e.getAttribute("data-zintl"),r=null===(n=e.textContent)||void 0===n?void 0:n.replace(/[^\d.-]/g,"");return r?!o||e.textContent!==t&&t?(e.setAttribute("data-domestic",r),parseFloat(r)):parseFloat(o):null})(e);if(!t||isNaN(t))return;const r=e.getAttribute("data-zintl"),a=parseFloat(e.getAttribute("data-zrate")||"1"),s=e.getAttribute("data-zcountry-code"),c=(null===(o=E.exchangeRate)||void 0===o?void 0:o.rate)||1;if(E.exchangeRate&&E.targetCurrency===E.exchangeRate.targetFormat.currencyCode&&(e.textContent!==r||c!==a||s!==E.selectedCountryCode)){A();const o="function"==typeof n.currencyConverter&&n.currencyConverter({convert:f,convertAndFormat:C,currencyCode:E.targetCurrency,format:e=>h({amount:e}),originalAmount:t,selector:e})||C(t);o!==e.textContent&&(e.textContent=o),e.setAttribute("data-zrate",c.toString()),e.setAttribute("data-zintl",o),e.setAttribute("data-zcountry-code",E.selectedCountryCode||"")}S()})(e)})):r("Could not display currency. Exchange rate and format data is not available."))},x=()=>{"DISABLED"===n.helloSettings.currencyBehavior||window.Zonos.isLegacyCheckout?S():j()},L=e=>{if(!e)return;const o=new URLSearchParams(window.location.search);if(o.has("zCountry")||"URL_PARAM"===n.helloSettings.countryOverrideBehavior){o.set("zCountry",e);const n=`${window.location.pathname}?${o.toString()}`;window.history.replaceState(window.history.state,document.title,n)}},{onChange:I,state:E}=e({countryLandedCost:null,customMessages:[],exchangeRate:null,helloCountryList:null,inclusivePricing:null,isDisabledCountry:!0,isShippableCountry:!1,localizationLoaded:!1,selectedCountryCode:null,selectedLocale:"en",shippingZoneCountries:null,targetCurrency:"USD"}),N=async e=>{const{exchangeRate:o,maxAge:a}=await(async({country:e,isGuaranteed:n,sourceCurrency:o,targetCurrency:a})=>{var s;if(o===a&&!n)return w;const c=new URLSearchParams;c.set("sourceCurrency",o),c.set("targetCurrency",a),c.set("isGuaranteed",String(n)),c.set("country",e||"");const{errors:i,json:l}=await t(`/api/zonos-elements/exchange-rates?${c.toString()}`);if(i.length||!l)return r(`Error fetching country landed cost: ${null===(s=i.find(Boolean))||void 0===s?void 0:s.message}`),w;const{rate:u,targetFormat:d}=l.exchangeRateCreate,y=l.maxAge;return u?(sessionStorage.setItem(e+"_rate",JSON.stringify(u)),{exchangeRate:{rate:u,targetFormat:d},maxAge:y}):w})({country:E.selectedCountryCode,isGuaranteed:e,sourceCurrency:n.sourceCurrency,targetCurrency:E.targetCurrency});return o&&(E.exchangeRate=o,x()),{maxAge:a}},D=e=>E.selectedCountryCode&&e.includes(E.selectedCountryCode)?E.selectedCountryCode:"CA",R=({isGuaranteed:e,maxAge:n})=>{E.exchangeRateTimeout&&clearTimeout(E.exchangeRateTimeout),E.exchangeRateTimeout=setTimeout((async()=>{const{maxAge:n}=await N(e);R({isGuaranteed:e,maxAge:n})}),1e3*(n||300))},k=e=>{var o,a;s(`Updating selected country code to ${e}`);const c=!E.selectedCountryCode;var i;E.selectedCountryCode="UK"===(i=e)?"GB":i;const{selectedCountryCode:l,shippingZoneCountries:u}=E,d=!(!u||!l||!u[l]||n.disabledCountries.includes(l));E.isShippableCountry=d,s(`${E.selectedCountryCode} is a shippable country: ${E.isShippableCountry}`);const y=!!l&&n.disabledCountries.includes(l);if(E.isDisabledCountry=y,s(`${E.selectedCountryCode} is a disabled country: ${E.isDisabledCountry}`),E.isShippableCountry?document.body.classList.add("z-intl"):document.body.classList.remove("z-intl"),!l)return;const m=(e=>{var n;const o=null===(n=E.shippingZoneCountries)||void 0===n?void 0:n[e];return o?o.currencyCode:null})(l);c||null===(o=n.onCountryChange)||void 0===o||o.call(n,{countryCode:l,currencyCode:m,isShippableCountry:d}),m&&(E.targetCurrency=m,(async()=>{var e;s("get new localization store");const{isDisabledCountry:o,isShippableCountry:a,selectedCountryCode:c}=E;if("DISABLED"===n.helloSettings.currencyBehavior||!a||o||!c)return;const i="ENABLED"===n.checkoutSettings.visibilityStatus;A();const{maxAge:l}=await N(i);R({isGuaranteed:i,maxAge:l}),window.Zonos.isLegacyCheckout?s("Skipping country landed cost and inclusive pricing requests, because this is a legacy checkout"):(E.countryLandedCost=await(async e=>{var n;if(!e)return null;const o=`/api/zonos-elements/country-landed-cost/${e}`,{errors:a,json:s}=await t(o);return a.length||!s?(r(`Error fetching country landed cost: ${null===(n=a.find(Boolean))||void 0===n?void 0:n.message}`),null):s||null})(E.selectedCountryCode),E.inclusivePricing=(null===(e=await(async e=>{var n;if(!e)return null;const{errors:o,json:a}=await t(`/api/zonos-elements/inclusive-prices/${e}`);return o.length||!a?(r(`Error fetching country inclusive price setting: ${null===(n=o.find(Boolean))||void 0===n?void 0:n.message}`),null):a||null})(c))||void 0===e?void 0:e.setting)||null,E.inclusivePricing&&s(`Inclusive price setting found for this country (${c}) ${JSON.stringify(E.inclusivePricing,null,2)}`))})(),window.sessionStorage.setItem("zonos--country",l),L(l),null===(a=document.querySelector("zonos-hello"))||void 0===a||a.setAttribute("z-country",l))},B=e=>{E.selectedLocale=e,c(e),(async()=>{if(!d.checkoutSessionId)return null;const{errors:e,json:n}=await t("/api/zonos-elements/update-checkout-session-metadata",{body:{id:d.checkoutSessionId,metadata:[{key:"language",value:E.selectedLocale}]},method:"POST"});(e.length||!n)&&r("Error occurs when updating checkout session",JSON.stringify(e,null,2))})(),(async()=>{if(s(`Getting custom messages for ${E.selectedCountryCode}`),!E.selectedCountryCode||!n.storeId)return;const e=(await(async({countryCode:e,localeTo:n,storeId:o})=>{var a;const s=new URLSearchParams;s.set("countryCode",e),s.set("storeId",o.toString()),n&&s.set("localeTo",n);const{errors:c,json:i}=await t(`/api/zonos-elements/locale-messages?${s.toString()}`);return c.length||!i?(r("Error fetching exchange rate",null===(a=c.find(Boolean))||void 0===a?void 0:a.message),[]):i.locale_countryCodesPage})({countryCode:E.selectedCountryCode,localeTo:E.selectedLocale,storeId:n.storeId})).flatMap((e=>{var n;return{countryCode:E.selectedCountryCode,message:null===(n=e.countryCodesPageMessageLinks.find(Boolean))||void 0===n?void 0:n.message.textTo,pageName:e.pageName}}));E.customMessages=e})()},F=async()=>{const[e,o,t]=await Promise.all([m(),p(),g()]),r=null==o?void 0:o.reduce(((n,o)=>{const t=null==e?void 0:e[o];return t?Object.assign(Object.assign({},n),{[o]:t}):n}),{});E.shippingZoneCountries=r||null,(e=>{const o=n.helloSettings.showCountryList,t=E.shippingZoneCountries;E.helloCountryList=o&&"ONLY_SHIPPABLE"!==o?"ALL"!==o?o.reduce(((n,o)=>{const t=null==e?void 0:e[o];return t?Object.assign(Object.assign({},n),{[o]:t}):n}),{}):e:t})(e||{});const{country:a,locale:c}=t;s(`Country code from localization: ${a}`),s(`Locale from localization: ${c}`),k(a);const i=new URL(window.location.href).searchParams.get("zonosLocale");B(i||c||"en"),!E.selectedCountryCode&&["dev.storybook.elements","dev.elements","dev.demo.elements","dev.dashboard"].some((e=>window.location.origin.includes(e)))&&k("CA"),E.localizationLoaded=!0};export{l as V,k as a,y as b,I as c,h as d,F as e,i as f,v as g,L as h,z as i,x as j,C as k,E as l,f as m,D as n,u as o,B as p,d as s}
@@ -1 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(e,n,t,r){function o(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,i){function a(e){try{d(r.next(e))}catch(e){i(e)}}function s(e){try{d(r["throw"](e))}catch(e){i(e)}}function d(e){e.done?t(e.value):o(e.value).then(a,s)}d((r=r.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return d([e,n])}}function d(s){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(r=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;o=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1];i=s;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(s);break}if(i[2])t.ops.pop();t.trys.pop();continue}s=n.call(e,t)}catch(e){s=[6,e];o=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,t){if(t||arguments.length===2)for(var r=0,o=n.length,i;r<o;r++){if(i||!(r in n)){if(!i)i=Array.prototype.slice.call(n,0,r);i[r]=n[r]}}return e.concat(i||Array.prototype.slice.call(n))};System.register(["./p-89c5164b.system.js","./p-cef1e888.system.js","./p-b4fe3604.system.js","./p-01174496.system.js","./p-d938f42f.system.js","./p-24e26a2c.system.js","./p-433d76b4.system.js"],(function(e){"use strict";var n,t,r,o,i,a,s,d,u,l,c,v,f,m,p,h,w,g;return{setters:[function(e){n=e.z;t=e.c},function(e){r=e.s;o=e.l;i=e.f;a=e.b},function(e){s=e.t},function(e){d=e.f;u=e.h;l=e.g;c=e.a;v=e.s;f=e.l;m=e.j},function(e){p=e.l;h=e.b},function(e){w=e.i},function(e){g=e.g}],execute:function(){var y=this;var b=e("K",(function(e){var n=e.firstName,t=e.lastName,r=e.name;var o;if(!r&&!n&&!t){return{firstName:"",lastName:""}}var i=(r===null||r===void 0?void 0:r.split(/\s+/))||[];var a=(n===null||n===void 0?void 0:n.trim())||((o=i[0])===null||o===void 0?void 0:o.trim())||"";var s=(t===null||t===void 0?void 0:t.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}}));var _=function(e){var n=e.currentAddress,t=e.translatedAddress;var r,o,i,a,s,d;var u=n.value.address,l=u.city,c=u.country,v=u.line1,f=u.line2,m=u.postal_code,p=u.state;var h=n.value.name||[n.value.firstName,n.value.lastName].join(" ");return{city:((r=t.city)===null||r===void 0?void 0:r[l])||l,country:c,line1:((o=t.line1)===null||o===void 0?void 0:o[v])||v,line2:((i=t.line2)===null||i===void 0?void 0:i[f||""])||f||"",name:((a=t.name)===null||a===void 0?void 0:a[h])||h,phone:n.value.phone||"",postal_code:((s=t.postal_code)===null||s===void 0?void 0:s[m])||m,state:((d=t.state)===null||d===void 0?void 0:d[p])||p}};var S=function(e){var n;var t=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var o=F.stripeLinkEventData;var i=F.stripeAddressEventData;var a=F.stripeShippingSameAsBilling?F.stripeAddressEventData:F.stripeBillingAddressEventData;if(!i||!a){throw new Error("Missing stripe address data")}var s=_({currentAddress:i,translatedAddress:F.translatedAddress.address});var d=b({name:s.name}),u=d.firstName,l=d.lastName;var c=_({currentAddress:a,translatedAddress:F.translatedAddress.address});var v=b({name:c.name}),f=v.firstName,m=v.lastName;return{billingAddress:{addressLine1:c.line1,addressLine2:c.line2||"",city:c.city,country:c.country,postalCode:c.postal_code,state:c.state},billingContact:{firstName:f,lastName:m,phone:c.phone},cartCurrencyCode:(n=Se.items[0])===null||n===void 0?void 0:n.currencyCode,cartId:e,checkoutSessionId:r.checkoutSessionId||"",contact:{companyName:F.companyName,email:o===null||o===void 0?void 0:o.value.email,firstName:u,lastName:l,phone:s.phone},isTest:!!t,landedCostAdjustments:Se.promoCode?[{amount:0,productId:null,promoCode:Se.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToTaxId:F.taxId,shippingAddress:{addressLine1:s.line1,addressLine2:s.line2,city:s.city,country:s.country,postalCode:s.postal_code,state:s.state}}};var O=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var n=F.stripeLinkEventData;var t=F.stripeAddressEventData;var o=F.stripeShippingSameAsBilling?F.stripeAddressEventData:F.stripeBillingAddressEventData;p({stripeAddressData:t,stripeBillingAddressData:o},"info");if(!t||!o){throw new Error("Missing stripe address data")}var i=_({currentAddress:t,translatedAddress:F.translatedAddress.address});var a=b({name:i.name}),s=a.firstName,d=a.lastName;var u=_({currentAddress:o,translatedAddress:F.translatedAddress.address});var l=b({name:u.name}),c=l.firstName,v=l.lastName;var f=Se.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var m=Se.promoCode?__spreadArray([{amount:0,productId:null,promoCode:Se.promoCode,sku:null,type:"PROMO_CODE"}],f,true):f;return{billingAddress:{addressLine1:u.line1,addressLine2:u.line2||"",city:u.city,country:u.country,postalCode:u.postal_code,state:u.state},billingContact:{firstName:c,lastName:v,phone:u.phone},checkoutSessionId:r.checkoutSessionId||"",contact:{companyName:F.companyName,email:n===null||n===void 0?void 0:n.value.email,firstName:s,lastName:d,phone:i.phone},isTest:e,items:Se.items,landedCostAdjustments:m,shipToTaxId:F.taxId,shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}}};var C=function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,r,o,i,a,s,l,c,v;return __generator(this,(function(f){switch(f.label){case 0:a=O();return[4,e({billingAddress:a.billingAddress,billingContact:a.billingContact,checkoutSessionId:a.checkoutSessionId,contact:a.contact,landedCostAdjustments:a.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:a.shippingAddress,zonosApiRoute:d["vercel"]})];case 1:s=f.sent();if(!s||!((n=s.checkoutSessionWorkflow)===null||n===void 0?void 0:n.length)&&((t=s.errors)===null||t===void 0?void 0:t.length)){throw new Error("Failed to build landed cost: ".concat(((o=(r=s===null||s===void 0?void 0:s.errors)===null||r===void 0?void 0:r[0])===null||o===void 0?void 0:o.message)||"Unknown error"))}return[4,u("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:l=f.sent(),c=l.errors,v=l.json;if(!v||c.length){throw new Error("Invalid landed cost object: ".concat(((i=c.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2,s]}}))}))};var k=function(e){return __awaiter(y,void 0,void 0,(function(){var t,r,o,i,a,s,d;return __generator(this,(function(l){switch(l.label){case 0:r=n.checkoutSettings.buildLandedCost;if(!r)return[3,2];return[4,C(r)];case 1:o=l.sent();return[2,o];case 2:return[4,u("/api/zonos-elements/calculate-landed-cost",{body:O(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:i=l.sent(),a=i.errors,s=i.json;if(a.length||!s){d=((t=a[0])===null||t===void 0?void 0:t.message)==="The user aborted a request.";if(d){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}a.forEach((function(e){console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2,s]}return[2,s]}}))}))};var A=function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,r,o,i,a,s,d,l,c;var v=e.abortController,f=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4,u("/api/zonos-elements/cart-calculate-landed-cost",{body:S(f),method:"POST",signal:v===null||v===void 0?void 0:v.signal})];case 1:a=e.sent(),s=a.errors,d=a.json;if(s.length||!d){l=typeof((n=s[0])===null||n===void 0?void 0:n.message)==="string"&&(((t=s[0])===null||t===void 0?void 0:t.message)==="The user aborted a request."||((r=s[0])===null||r===void 0?void 0:r.message.includes("signal is aborted"))||((o=s[0])===null||o===void 0?void 0:o.message.includes("The operation was aborted"))||((i=s[0])===null||i===void 0?void 0:i.message.includes("Fetch is aborted")));c=l?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(c)}return[2,d]}}))}))};var I=undefined&&undefined.__rest||function(e,n){var t={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0)t[r]=e[r];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++){if(n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o]))t[r[o]]=e[r[o]]}return t};var T=function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,r,o,i;return __generator(this,(function(a){switch(a.label){case 0:n=window.Zonos.cartId;if(!!n)return[3,2];return[4,k(e)];case 1:t=a.sent();return[2,t];case 2:return[4,A({abortController:e,cartId:n})];case 3:r=a.sent(),o=r.cartWorkflow,i=I(r,["cartWorkflow"]);return[2,Object.assign(Object.assign({},i),{itemCreateWorkflow:o.items})]}}))}))};var E=e("t",(function(e){return __awaiter(y,[e],void 0,(function(e){var t,r,i,a,s,d,f,m,p;var w=e.checkoutSessionId,g=e.eventName,y=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:i=Date.now();a=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:w,eventCreated:i,eventName:g});s=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!((t=window.Zonos)===null||t===void 0?void 0:t.zonosQaUrl)||!!((r=window.Zonos)===null||r===void 0?void 0:r.debug);d=l()||c();if((d||s)&&!window.Zonos.zonosConversionTest){return[2]}f=o.selectedCountryCode;m=n.organizationId;if(!w){void v({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No checkout session id found')],metadata:{allLogs:h,checkoutSessionId:w,eventName:g,metadata:y,organizationId:m,trackEventLogs:a}});return[2]}if(!m){void v({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No organization id found')],metadata:{allLogs:h,checkoutSessionId:w,eventName:g,metadata:y,organizationId:m,trackEventLogs:a}})}p={checkoutSessionId:w,countryCode:f,eventCreated:i,eventName:g,metadata:Object.assign(Object.assign({},y),{trackEventLogs:a}),organizationId:m};return[4,u("/api/zonos-elements/track-conversion-event",{body:p,method:"POST"})];case 1:e.sent();return[2]}}))}))}));var N=function(e){var n=e.address,t=e.invalidAdddressList;if(!n){return}if(!t){return}var r={};if(t.city){r.city=n.city}if(t.line1){r.line1=n.line1}if(t.line2){r.line2=n.line2}if(t.postal_code){r.postal_code=n.postal_code}if(t.state){r.state=n.state}if(t.name){r.name=n.name}return Object.keys(r).length?r:undefined};var j=function(e){var n=e.addressInvalidCharactersList,t=e.billingAddressInvalidCharactersList,r=e.stripeAddressEventData,o=e.stripeBillingAddressEventData,i=e.stripeShippingSameAsBilling;var a=!!(r===null||r===void 0?void 0:r.complete);var s=i?a:!!(o===null||o===void 0?void 0:o.complete);if(!a||!s){return null}if(!n&&!t){return null}var d=r.value;var u=(o===null||o===void 0?void 0:o.value)||null;var l=b({firstName:d.firstName,lastName:d.lastName,name:d.name}),c=l.firstName,v=l.lastName;var f="".concat(c," ").concat(v);var m=b({firstName:u===null||u===void 0?void 0:u.firstName,lastName:u===null||u===void 0?void 0:u.lastName,name:(u===null||u===void 0?void 0:u.name)||""}),p=m.firstName,h=m.lastName;var w=p&&h?"".concat(p," ").concat(h):"";var g=d.address;var y=u===null||u===void 0?void 0:u.address;return{address:N({address:Object.assign(Object.assign({},g),{name:f}),invalidAdddressList:n}),billingAddress:!i?N({address:y?Object.assign(Object.assign({},y),{name:w}):null,invalidAdddressList:t}):undefined,destinationCountry:g.country}};var P=e("O",(function(e){var n=e.sort((function(e,n){return e.amount-n.amount}));return n}));var D=function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,o;return __generator(this,(function(i){switch(i.label){case 0:if(!r.checkoutSessionId){return[2,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",r.checkoutSessionId);return[4,u("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:n=i.sent(),t=n.errors,o=n.json;return[2,{errors:t,json:o}]}}))}))};var L=e("A",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,r;return __generator(this,(function(o){switch(o.label){case 0:return[4,D()];case 1:n=o.sent(),t=n.errors,r=n.json;if(t.length||!r){f("Failed to retrieve checkout session info before confirming payment ",t);void v({endpoint:"validateCheckoutSession",errors:t.map((function(e){return e.message})),metadata:{allLogs:h}});return[2,{errorMessage:s("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}if(!((e=r.checkoutSession.landedCost)===null||e===void 0?void 0:e.id)){f("Landed cost is not found in the checkout session before confirming payment.");void v({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:h}});return[2,{errorMessage:s('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:false}]}return[2,{errorMessage:"",valid:true}]}}))}))}));var x=function(e){var t=e.theme;var r={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:n.appearance.fontSizeInputValue?"".concat(n.appearance.fontSizeInputValue,"px"):undefined,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:n.appearance.fontSizeInputLabel?"".concat(n.appearance.fontSizeInputLabel,"px"):undefined},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};switch(t){case"DARK":{return Object.assign(Object.assign({},r),{".Action":Object.assign(Object.assign({},r[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},r[".PickerItem--new"]),{color:"white"})})}default:return r}};var R=function(e){var n=e.borderStyle,t=e.theme;switch(t){case"DARK":return{borderRadius:g({overrideBorderStyle:n}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:g({overrideBorderStyle:n}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var U=t((function(){return{checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:false,isFetchingLandedCost:false,isFetchingSession:false,partyBillingId:null,partyShippingId:null,shouldInventoryRefund:false,shouldRenderPayInUsdButton:false,skipPaymentIntent:new URLSearchParams(window.location.search).get("skipPaymentIntent")==="0"?false:true,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:true,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}})),z=U.onChange,B=U.reset,F=U.state;e({B:z,c:F});var J=function(e){var t=e.clientSecret,r=e.overrideBorderRadius,i=e.overridePrimaryColor,a=e.overrideSecondaryColor,s=e.overrideTheme,d=e.paypalEnabled;var u=i||n.appearance.colorPrimary;var l=a||n.appearance.colorSecondary;var c=u&&w(u)?"night":"flat";var v=s==="DARK"?"night":"flat";var f=d?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},x({theme:s||"LIGHT"})),theme:s?v:c,variables:Object.assign(Object.assign({},R({borderStyle:r,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:t||undefined,customerSessionClientSecret:F.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],f,true),locale:o.selectedLocale}};var M=e("a",(function(){window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")}));var q=e("b",(function(e){window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))}));var W=e("s",(function(){var e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return m(e)}));var Y=e("i",(function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,r,o,i;return __generator(this,(function(a){r=F.clientSecret;if(!F.stripe){p("Skip. Stripe is not initialized");return[2]}o=J({clientSecret:r,overrideBorderRadius:e===null||e===void 0?void 0:e.overrideBorderRadius,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideSecondaryColor:e===null||e===void 0?void 0:e.overrideSecondaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme,paypalEnabled:e===null||e===void 0?void 0:e.paypalEnabled});i=JSON.stringify(o)===JSON.stringify(F.stripeElementsOptions);if(!F.stripeElements||!F.stripeElementsForBillingAddress){F.stripeElementsForBillingAddress=(n=F.stripe)===null||n===void 0?void 0:n.elements(o);p("Stripe elements for billing address initialized");F.stripeElements=(t=F.stripe)===null||t===void 0?void 0:t.elements(o);F.stripeElementsOptions=o;p("Stripe elements initialized");return[2]}if(!i){F.stripeElements.update(o);F.stripeElementsForBillingAddress.update(o);F.stripeElementsOptions=o;void F.stripeElements.fetchUpdates()}p("Stripe elements updated");return[2]}))}))}));var H=e("y",(function(){sessionStorage.removeItem("zonos--client-secret");B();F.stripe=window.Zonos.stripe}));var K=function(){var e,n,t,r;var o=JSON.stringify((e=F.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=F.stripeAddressEventData)===null||n===void 0?void 0:n.value);var i=!F.stripeShippingSameAsBilling&&JSON.stringify((t=F.stripeBillingAddressEventData)===null||t===void 0?void 0:t.value)!==JSON.stringify((r=F.stripeBillingAddressUsedWhenValidatingAddress)===null||r===void 0?void 0:r.value);return o||i};var G=function(){var e,n,t,r,o,i;var a=JSON.stringify((e=F.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=F.stripeLinkEventData)===null||n===void 0?void 0:n.value);var s=JSON.stringify((t=F.stripeAddressUsedWhenAsyncAddressUpdate)===null||t===void 0?void 0:t.value)!==JSON.stringify((r=F.stripeAddressEventData)===null||r===void 0?void 0:r.value);var d=!F.stripeShippingSameAsBilling&&JSON.stringify((o=F.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||o===void 0?void 0:o.value)!==JSON.stringify((i=F.stripeBillingAddressEventData)===null||i===void 0?void 0:i.value);var u=F.taxIdUsedWhenAsyncAddressUpdate!==F.taxId;var l=F.companyNameUsedWhenAsyncAddressUpdate!==F.companyName;return a||s||d||u||l};var V=e("C",(function(e){var n=e.address,t=e.firstName,o=e.lastName,i=e.name,a=e.phone;var s=b({firstName:t,lastName:o,name:i}),d=s.firstName,u=s.lastName;if(!d||!u){void v({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,firstName:t,lastName:o,name:i}})}if(!a){void v({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,phone:a}})}return{city:n.city,country:n.country,firstName:d,lastName:u,line1:n.line1,line2:n.line2,phone:a||"",postal_code:n.postal_code,state:n.state}}));var Z=e("L",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,o,i,a,s,d,l,c,m,p;return __generator(this,(function(w){switch(w.label){case 0:if(!((e=F.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!F.stripeShippingSameAsBilling&&!((n=F.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete)||!F.stripeBillingAddressEventData){return[2,{partiesCreated:false}]}if(!Se.landedCostData){return[2,{partiesCreated:false}]}i=(t=Se.landedCostData.find(Boolean))===null||t===void 0?void 0:t.landedCost.rootId;if(!i){void v({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId}});return[2,{partiesCreated:false}]}a=G();if(!a){return[2,{partiesCreated:false}]}s=V({address:F.stripeAddressEventData.value.address,firstName:F.stripeAddressEventData.value.firstName,lastName:F.stripeAddressEventData.value.lastName,name:F.stripeAddressEventData.value.name,phone:F.stripeAddressEventData.value.phone});d=F.stripeShippingSameAsBilling?s:V({address:F.stripeBillingAddressEventData.value.address,firstName:F.stripeBillingAddressEventData.value.firstName,lastName:F.stripeBillingAddressEventData.value.lastName,name:F.stripeBillingAddressEventData.value.name,phone:F.stripeBillingAddressEventData.value.phone});l=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,u("/api/zonos-elements/create-parties",{body:{address:s,billingAddress:d,companyName:F.companyName,email:((o=F.stripeLinkEventData)===null||o===void 0?void 0:o.value.email)||"",isTest:l,rootId:i,taxId:F.taxId},method:"POST"})];case 1:c=w.sent(),m=c.errors,p=c.json;if(m.length||!p){f("Error occurs when creating parties",JSON.stringify(m,null,2));void v({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,errors:m,json:p}});return[2,{partiesCreated:false}]}F.companyNameUsedWhenAsyncAddressUpdate=F.companyName;F.stripeAddressUsedWhenAsyncAddressUpdate=F.stripeAddressEventData;F.stripeBillingAddressUsedWhenAsyncAddressUpdate=F.stripeBillingAddressEventData;F.taxIdUsedWhenAsyncAddressUpdate=F.taxId;F.partyBillingId=p.billToPartyId;F.partyShippingId=p.shipToPartyId;return[2,{partiesCreated:true}]}}))}))}));var Q=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var X=function(){var e,n;var t=JSON.stringify((e=F.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=F.stripeLinkEventData)===null||n===void 0?void 0:n.value);var r=F.stripeAddressEventData&&JSON.stringify(Q(F.stripeAddressEventData.value))!==JSON.stringify(F.stripeAddressUsedWhenFetchingLC);var o=!F.stripeShippingSameAsBilling&&F.stripeBillingAddressEventData&&JSON.stringify(Q(F.stripeBillingAddressEventData.value))!==JSON.stringify(F.stripeBillingAddressUsedWhenFetchingLC);return t||r||o};var $=function(){var e;var n=Se.landedCostData&&((e=Se.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==Se.subtotal;var t=X();p("isPrefetchInfoOutdated","info",{isAddressOutdated:t});return!Se.landedCostData&&!F.isFetchingLandedCost||t||n};var ee=function(e){var t,r;var o=(t=n.genericSettings)===null||t===void 0?void 0:t.countryFields;var i=(r=n.genericSettings)===null||r===void 0?void 0:r.stripeCountryFieldLabels;var a=i&&e in i?i[e]:null;var s=o&&e in o?o[e]:null;if(Se.addressFormRenderType==="stripe"){return a||s}return s};var ne=function(){var e,n,t,r;var o=!!((e=F.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((n=F.stripeAddressEventData)===null||n===void 0?void 0:n.complete);var a=F.stripeShippingSameAsBilling?i:!!((t=F.stripeBillingAddressEventData)===null||t===void 0?void 0:t.complete);var s=((r=F.stripeAddressEventData)===null||r===void 0?void 0:r.value.address.country)||"US";var d=ee(s);if(i&&a&&o){return true}if(!d||!F.stripeAddressEventData){return i&&a&&o}var u=F.stripeAddressEventData.value.address.line1.length>0;var l=F.stripeAddressEventData.value.firstName&&F.stripeAddressEventData.value.lastName;var c=!d.stateRequired||d.stateRequired&&F.stripeAddressEventData.value.address.state.length>0;var v=!d.zipRequired||d.zipRequired&&F.stripeAddressEventData.value.address.postal_code.length>=3;var f=F.stripeAddressEventData.value.phone&&F.stripeAddressEventData.value.phone.length>0;return o&&l&&u&&c&&v&&f};var te=function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,o,i,a,s,d,u,l,c;return __generator(this,(function(v){switch(v.label){case 0:n=new AbortController;F.fetchingLandedCostAbortController=n;ze();return[4,T(n)];case 1:t=v.sent(),o=t.checkoutSessionWorkflow,i=t.errors,a=t.itemCreateWorkflow,s=t.landedCostCalculateWorkflow,d=t.partyCreateWorkflow,u=t.shipmentRatingCalculateWorkflow;Se.customQuotingError=((e=i===null||i===void 0?void 0:i.find((function(e){var n;return((n=e.extensions)===null||n===void 0?void 0:n.ruleMessageType)==="CUSTOM"})))===null||e===void 0?void 0:e.message)||null;Se.shippingData=P((u===null||u===void 0?void 0:u.filter(Boolean))||[]);Ae(a);F.fetchingLandedCostAbortController=null;Se.partiesData=(d===null||d===void 0?void 0:d.filter(Boolean))||[];Se.landedCostData=(o===null||o===void 0?void 0:o.map((function(e){var n=s===null||s===void 0?void 0:s.find((function(n){return(n===null||n===void 0?void 0:n.id)===e.landedCostId}));if(!n){return null}return Object.assign(Object.assign({},e),{landedCost:n})})).filter(Boolean))||[];l=r.checkoutSessionId;if(o===null||o===void 0?void 0:o.length){void E({checkoutSessionId:l,eventName:"checkout_quoteReceived"})}c=Se.promoCodeApplied&&!Se.landedCostData.find((function(e){var n;return(n=e.landedCost.appliedAdjustments)===null||n===void 0?void 0:n.find((function(e){return e.type==="PROMO_CODE"}))}));Se.promoCodeError=c;if(!c){sessionStorage.setItem("zonos--promo-code",Se.promoCode)}return[2]}}))}))};var re=e("q",(function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,r,o,i,a,s,d,u,l,c,m,p,h;return __generator(this,(function(w){switch(w.label){case 0:i=(e===null||e===void 0?void 0:e.retries)||0;a=!!(e===null||e===void 0?void 0:e.applyingPromocode);s=$();d=ne();if(!d){return[2,{isRequestNotReady:true}]}if(s){(n=F.fetchingLandedCostAbortController)===null||n===void 0?void 0:n.abort();F.fetchingLandedCostAbortController=null}if(!s&&!a){return[2,{isRequestNotReady:false}]}if(i){F.isFetchingLandedCost=false;setTimeout((function(){F.isFetchingLandedCost=true}),300)}else{F.isFetchingLandedCost=true}if(F.stripeAddressEventData){F.stripeAddressUsedWhenFetchingLC={countryCode:F.stripeAddressEventData.value.address.country,postalCode:F.stripeAddressEventData.value.address.postal_code,state:F.stripeAddressEventData.value.address.state}}if(F.stripeBillingAddressEventData){F.stripeBillingAddressUsedWhenFetchingLC={countryCode:F.stripeBillingAddressEventData.value.address.country,postalCode:F.stripeBillingAddressEventData.value.address.postal_code,state:F.stripeBillingAddressEventData.value.address.state}}if(F.stripeLinkEventData){F.stripeLinkUsedWhenFetchingLC=Object.assign({},F.stripeLinkEventData)}w.label=1;case 1:w.trys.push([1,3,,7]);ze();return[4,te()];case 2:w.sent();u=(t=Se.shippingData)===null||t===void 0?void 0:t.find(Boolean);l=(r=Se.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCost.shipmentRating.id===(u===null||u===void 0?void 0:u.id)}));c=!!l?l.subtotals:null;if(c){Ee({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:c})}return[3,7];case 3:m=w.sent();Se.landedCostData=[];Se.shippingData=[];p=["The landed cost calculation request was aborted to initiate a new one."];if(!(m instanceof Error&&m.message&&!p.includes(m.message)))return[3,6];if(!(i<1))return[3,5];return[4,re(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:w.sent();return[2,{isRequestNotReady:false}];case 5:h=(o=F.stripeAddressEventData)===null||o===void 0?void 0:o.value;void v({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[m.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:h}});w.label=6;case 6:f(m);return[3,7];case 7:F.isFetchingLandedCost=false;return[2,{isRequestNotReady:false}]}}))}))}));var oe=e("F",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,r;return __generator(this,(function(o){switch(o.label){case 0:return[4,re({applyingPromocode:true})];case 1:o.sent();if(Se.step==="payment"){Je()}return[4,Z()];case 2:o.sent();t=(e=Se.shippingData)===null||e===void 0?void 0:e.find(Boolean);r=(n=Se.landedCostData)===null||n===void 0?void 0:n.find((function(e){return e.landedCost.id===(t===null||t===void 0?void 0:t.id)}));if(!t||!r){return[2]}return[4,Le({applySubtotalsOnly:false,landedCostId:r.landedCostId,selectedShippingOption:t})];case 3:o.sent();return[2]}}))}))}));var ie=e("H",(function(){Se.promoCode="";sessionStorage.removeItem("zonos--promo-code");Se.promoCodeError=false;Se.promoCodeApplied=false}));var ae=e("G",(function(){return __awaiter(y,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:if(Se.step==="payment"){Je()}ie();return[4,oe()];case 1:e.sent();return[2]}}))}))}));var se=e("I",(function(e){var n=[];var t=true;var r=window.Zonos.isCollect;switch(e){case"succeeded":{n=[s("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"",s("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")];if(r){n=[s("Thank you for submitting your payment. We appreciate your prompt attention."),"",s("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]}t=false;break}case"requires_capture":case"processing":{n=[s("Payment processing. We'll update you when payment is received.")];t=false;break}case"requires_payment_method":{n=[s("Payment failed. Please try another payment method.")];if(r){n=[s("Payment failed. Please reload the page and try another payment method.")]}break}case"requires_action":{t=false;n=[s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{n=[s("Something went wrong.")];break}}return{isError:t,messages:n}}));var de=e("v",(function(){return __awaiter(y,void 0,void 0,(function(){var e,t,r,o,i,a,d,l,c,l;return __generator(this,(function(m){switch(m.label){case 0:r=n.checkoutSettings.onInventoryCheck;o=!!((t=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||t===void 0?void 0:t.value);if(!(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o))return[3,2];return[4,u("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:i=m.sent(),a=i.errors,d=i.json;if(a.length||!d){f("Error occurs when handling inventory refund","warn",JSON.stringify(a));return[2,null]}if(!d.available||d.status===204){return[2,s("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(d.available||d.status===200){F.shouldInventoryRefund=true;return[2,null]}return[2,null];case 2:if(typeof r!=="function"){return[2,null]}m.label=3;case 3:m.trys.push([3,5,,6]);return[4,r({items:Se.items})];case 4:l=m.sent();return[2,l];case 5:c=m.sent();l=c instanceof Error?c.message:"Unknown error";void v({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(l)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:Se.items}});throw c;case 6:return[2]}}))}))}));var ue=e("x",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t;return __generator(this,(function(r){switch(r.label){case 0:t=!!((n=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||n===void 0?void 0:n.value);if(!window.Zonos.isLegacyCheckout||!window.Zonos.cartData||!t){return[2]}return[4,u("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:r.sent();return[2]}}))}))}));var le=e("d",(function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,r,o,i,a,d,u,l;var c=e.clientSecret,v=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(v){n=se(v),t=n.isError,r=n.messages;return[2,{error:t,messages:r}]}o=c||F.clientSecret;if(!F.stripe||!o){f("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[s("Something went wrong.")]}]}return[4,F.stripe.retrievePaymentIntent(o)];case 1:i=e.sent().paymentIntent;a=i===null||i===void 0?void 0:i.status;d=se(a),u=d.isError,l=d.messages;return[2,{error:u,messages:l,paymentIntentId:i===null||i===void 0?void 0:i.id,paymentMethod:i===null||i===void 0?void 0:i.payment_method,status:a}]}}))}))}));var ce=e("w",(function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,o,i,a,d,u,l,c,v,f,m;return __generator(this,(function(h){switch(h.label){case 0:o=!!((n=F.stripePaymentEventData)===null||n===void 0?void 0:n.complete);i=F.stripeElements;a=F.stripe;d=F.clientSecret;F.customErrorMessage=null;if(!((t=Se.selectedLandedCost)===null||t===void 0?void 0:t.landedCost.id)&&!(e===null||e===void 0?void 0:e.noLandedCostCheck)){throw new Error("Attempted to confirm the payment when no landed cost is found in store")}return[4,L()];case 1:u=h.sent();if(!u.valid){F.customErrorMessage=u.errorMessage;throw new Error(u.errorMessage)}l=r.checkoutSessionId;if(!(a&&i&&o&&d&&l))return[3,3];c=new URL(window.location.href);c.searchParams.set("payment_intent_client_secret",d);c.searchParams.set("zonosCheckoutSessionId",l);void E({checkoutSessionId:l,eventName:"checkout_paymentInfoCompleted"});return[4,a.confirmPayment({confirmParams:{return_url:c.toString()},elements:i,redirect:"if_required"})];case 2:v=h.sent(),f=v.error,m=v.paymentIntent;p("Payment intent confirmed","info",{error:f,paymentIntent:m});if((m===null||m===void 0?void 0:m.status)==="requires_action"){throw new Error(s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."))}if(f){if(f.type==="card_error"||f.type==="validation_error"){throw new Error(f.message)}if(f.type==="invalid_request_error"){if(f.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}if(m.status==="requires_payment_method"){throw new Error(s("Payment failed. Please try another payment method."))}h.label=3;case 3:return[2]}}))}))}));var ve=e("n",(function(){var e;var n=Se.items.reduce((function(e,n){return e+n.amount*n.quantity}),0);var t=r.enabledVariantTestKeys||[];var i={adjustmentsAmount:Se.adjustments.reduce((function(e,n){return e+n.amount}),0),cartId:window.Zonos.cartId,currency:((e=Se.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:Se.customerAuthenticationToken||undefined,isCollect:window.Zonos.isCollect,itemsAmount:n,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:o.selectedCountryCode,skipPaymentIntent:F.skipPaymentIntent,varianceTestInput:t};return i}));var fe=e("l",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:if(!r.checkoutSessionId){void v({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:h,cartId:window.Zonos.cartId}});Te({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});return[2]}return[4,u("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:r.checkoutSessionId},method:"POST"})];case 1:n=a.sent(),t=n.errors,o=n.json;i=(e=o===null||o===void 0?void 0:o.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(t.length||!i){f("Error occurs when getting payment intent",JSON.stringify(t,null,2));void v({endpoint:"Error creating payment intent",errors:t.map((function(e){return e.message})),metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,clientSecret:i}});Te({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});return[2]}je(o.checkoutSessionPaymentIntentCreate);return[2]}}))}))}));var me=e("k",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,r,i,a,s,d;return __generator(this,(function(l){switch(l.label){case 0:if(!o.targetCurrency){f("Failed to create checkout session - missing localizationStore.targetCurrency");return[2,false]}F.isFetchingSession=true;t=ve();p("Checkout session body","info",t);return[4,u("/api/zonos-elements/create-checkout-session",{body:t,method:"POST"})];case 1:r=l.sent(),i=r.errors,a=r.json;F.isFetchingSession=false;if(i.length||!a){s=(e=i.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;if(Array.isArray(s)&&s.some((function(e){return e.message==="Cart is expired."}))){throw new Error("Cart is expired.")}f("Error occurred when creating checkout session",JSON.stringify(i,null,2));return[2,false]}d=a.checkoutSessionCreate;je(d);Ee({method:((n=d.landedCost)===null||n===void 0?void 0:n.method)||"DDP",subtotals:d.subtotals});p("Exchange rate updated for cart items (checkout session create)","info",Se.exchangeRate);p("done-init-checkout-session");return[2,true]}}))}))}));var pe=e("u",(function(){return __awaiter(y,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(i){switch(i.label){case 0:e=r.checkoutSessionId;if(!e){f("Failed to update checkout session base currency");return[2,false]}if(n.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){p('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2,true]}return[4,u("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:F.checkoutSettlementCurrency},method:"POST"})];case 1:t=i.sent().json;o=t===null||t===void 0?void 0:t.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;if(!t||o!==F.checkoutSettlementCurrency){f("Failed to update checkout session base currency");return[2,false]}p('Updated checkout session to settlement currency "'.concat(o,'".'));return[2,true]}}))}))}));var he=function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,i,a;var s=e.adjustmentsAmount,d=e.cartId,l=e.currency,c=e.id,v=e.itemsAmount,m=e.landedCostId,p=e.presentmentCountryCode;return __generator(this,(function(e){switch(e.label){case 0:n=r.enabledVariantTestKeys||[];return[4,u("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:s,billToPartyId:F.partyBillingId,cartId:d,currency:l,customerAuthenticationToken:Se.customerAuthenticationToken||undefined,id:c,itemsAmount:v,landedCostId:m,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:p,shipToPartyId:F.partyShippingId,skipPaymentIntent:F.skipPaymentIntent,varianceTestInput:n},method:"POST"})];case 1:t=e.sent(),i=t.errors,a=t.json;if(i.length||!a){f("Error occurs when updating checkout session",JSON.stringify(i,null,2));return[2,{errors:i,json:a}]}return[2,{errors:[],json:a}]}}))}))};var we=function(e){var n,t,r,o,i,a;var s=e.currentAddress,d=e.translatedAddressResult;var u={};if(!d){return u}var l=d.city,c=d.line1,v=d.line2,f=d.name,m=d.postal_code,p=d.state;if(s.city&&l){u.city=(n={},n[s.city]=l,n)}if(s.line1&&c){u.line1=(t={},t[s.line1]=c,t)}if(s.line2&&v){u.line2=(r={},r[s.line2]=v,r)}if(s.postal_code&&m){u.postal_code=(o={},o[s.postal_code]=m,o)}if(s.state&&p){u.state=(i={},i[s.state]=p,i)}if(s.name&&f){u.name=(a={},a[s.name]=f,a)}return u};var ge=e("J",(function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,r,o,i,a,s,d,l,c,v;var m=e.addressInvalidCharactersList,p=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=j({addressInvalidCharactersList:m,billingAddressInvalidCharactersList:p,stripeAddressEventData:F.stripeAddressEventData,stripeBillingAddressEventData:F.stripeBillingAddressEventData,stripeShippingSameAsBilling:F.stripeShippingSameAsBilling});if(!i){F.translatedAddress={address:{},billingAddress:{}};return[2]}a=K();if(!a){return[2]}return[4,u("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),d=s.errors,l=s.json;if(d.length||!l){f("Error occurs when translating address to latin",JSON.stringify(d,null,2));F.translatedAddress={address:{},billingAddress:{}};return[2]}F.stripeAddressUsedWhenValidatingAddress=F.stripeAddressEventData;F.stripeBillingAddressUsedWhenValidatingAddress=F.stripeBillingAddressEventData;c=(n=F.stripeAddressEventData)===null||n===void 0?void 0:n.value.address;v=(t=F.stripeBillingAddressEventData)===null||t===void 0?void 0:t.value.address;F.translatedAddress={address:c?we({currentAddress:Object.assign(Object.assign({},c),{name:(r=F.stripeAddressEventData)===null||r===void 0?void 0:r.value.name}),translatedAddressResult:l.address||null}):{},billingAddress:!F.stripeShippingSameAsBilling?we({currentAddress:Object.assign(Object.assign({},v),{name:(o=F.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:l.billingAddress||null}):{}};return[2]}}))}))}));z("clientSecret",(function(e){if(e&&F.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var ye=t((function(){return{addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:false,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:false,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,isStagingMode:c(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:false,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:false,step:"customer-info",subtotal:0,tabItems:{"customer-info":{index:1,isDone:false,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:false,label:"Shipping",value:"shipping"},payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),be=ye.onChange,_e=ye.reset,Se=ye.state;e({z:be,e:Se});var Oe=function(e){switch(e){case"DAYS":return s("days");case"WEEKS":return s("weeks");case"BUSINESS_DAYS":default:return s("business days")}};var Ce=e("M",(function(e){var n;var t=(n=e.shippingProfile)===null||n===void 0?void 0:n.transitTime;if(!(t===null||t===void 0?void 0:t.min)||!(t===null||t===void 0?void 0:t.max)||!(t===null||t===void 0?void 0:t.type)){return null}return{maxTransit:t.max,minTransit:t.min,unit:Oe(t.type)}}));var ke=function(e){var n=e.item1,t=e.item2;if(!n||!t){return false}return t.sku&&n.sku&&n.sku===t.sku||t.description&&n.description&&n.description===t.description||n.name&&t.name&&n.name===t.name};var Ae=function(e){p("Checking item restrictions");var n=e.map((function(e){if(!e.restriction){return null}var n=e.restriction;var t=Se.items.find((function(n){return ke({item1:n,item2:e})}));return Object.assign(Object.assign({matchedItem:t},e),{restriction:n})})).filter(Boolean);Se.restrictedItems=n;Se.items=Se.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!n.find((function(n){return ke({item1:n,item2:e})}))})}));return{cartItems:Se.items,restrictedItems:n}};var Ie=e("g",(function(){r.checkoutSessionId=null;_e()}));var Te=e("o",(function(e){var n=e.messages,t=e.title;Ie();H();Se.step="error";Se.error={messages:n,title:t}}));var Ee=function(e){var n=e.dutiesTaxesFeesEstimate,t=e.method,r=e.subtotals;Se.exchangeRate=r.exchangeRate;Se.adjustmentTotal=r.adjustments;Se.dutiesTaxesFees=t==="DAP"?null:r.landedCostTotal;Se.subtotal=r.items;Se.total=r.total;Se.currency=r.presentmentCurrencyCode;Se.dutiesTaxesFeesEstimate=n||null};var Ne=e("E",(function(){var e=Se.items.filter((function(e){return e.amount>0}));return!!e.find((function(e){return!e.isRestricted}))}));var je=e("p",(function(e){var n,t,o,s,d;F.clientSecret=e.clientSecret;F.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;F.customerProfile=e.customerProfile;Se.checkoutSession=e;if(!e.id){void v({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:h,checkoutSession:e}})}if(e.id){r.checkoutSessionId=e.id}var u=i(e.varianceTestResults||[]);a(u);var l=((o=(t=(n=Se.checkoutSession)===null||n===void 0?void 0:n.metadata)===null||t===void 0?void 0:t.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||o===void 0?void 0:o.value)||((d=(s=window.Zonos.cartData)===null||s===void 0?void 0:s.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||d===void 0?void 0:d.value)||null;if(l){p("Found externalConfirmationPageURL: ".concat(l));Se.externalConfirmationPageURL=l}}));var Pe=function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,i,a,d,u;var l=e.adjustmentsAmount,c=e.cartId,v=e.currency,m=e.dutiesTaxesFeesEstimate,h=e.itemsAmount,w=e.landedCostId,g=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(w&&Se.selectedLandedCost){t=Se.selectedLandedCost.subtotals;Ee({dutiesTaxesFeesEstimate:m,method:Se.landedCostMethod,subtotals:t});p("Exchange rate updated for cart items (landed cost subtotal)","info",Se.exchangeRate)}if(!r.checkoutSessionId){p("Could not update cart total without checkout session id","info");return[2,false]}return[4,he({adjustmentsAmount:l,billToPartyId:F.partyBillingId,cartId:c,currency:v,id:r.checkoutSessionId,itemsAmount:h,landedCostId:w,presentmentCountryCode:o.selectedCountryCode,shipToPartyId:F.partyShippingId,varianceTestInput:r.enabledVariantTestKeys||[]})];case 1:i=e.sent(),a=i.errors,d=i.json;if(!(a.length>0||!d))return[3,4];f("Error occurs when updating checkout session.");if(!g)return[3,3];p("Initiating checkout session on failure","info");return[4,me()];case 2:u=e.sent();p("stripeStoreInitCheckoutSession: ".concat(u));if(!u){Te({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});return[2,false]}return[2,true];case 3:return[2,false];case 4:if(!w){Ee({method:((n=d.checkoutSessionUpdate.landedCost)===null||n===void 0?void 0:n.method)||"DDP",subtotals:d.checkoutSessionUpdate.subtotals});p("Exchange rate updated for cart items (checkout session update)","info",Se.exchangeRate)}je(d.checkoutSessionUpdate);return[2,true]}}))}))};var De=e("N",(function(e){var t,r,o;if(e.method==="DAP"&&((r=(t=n.genericSettings)===null||t===void 0?void 0:t.domesticCountries)===null||r===void 0?void 0:r.includes(((o=F.stripeAddressEventData)===null||o===void 0?void 0:o.value.address.country)||"US"))){return"DDP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var Le=e("D",(function(e){return __awaiter(y,[e],void 0,(function(e){var t,o,i,a,s,d,u,l,c,v,f,m,h,w,g,y,b,_,S,O,C,k,A,I,T;var E=e.applySubtotalsOnly,N=e.landedCostId,j=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:p("Updating selected shipping option","info",{landedCostId:N,selectedShippingOption:j});Se.selectedShippingOption=j;m=Ce(Se.selectedShippingOption);if(m){h=m.maxTransit,w=m.minTransit,g=m.unit;Se.selectedShippingOptionTransitTime="".concat(w,"-").concat(h," ").concat(g)}else{Se.selectedShippingOptionTransitTime=""}y=(t=Se.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCostId===N}));Se.selectedLandedCost=y||null;if(!y){return[2,false]}b=((o=y.landedCost.amountSubtotals)===null||o===void 0?void 0:o.landedCostTotal)||0;_=y.subtotals.exchangeRate.rate;S=b*_;if(S){p("DAP quote, using estimate: ".concat(S),"info")}Se.landedCostMethod=De(y.landedCost);Se.shipping=y.subtotals.shipping;O=((i=y===null||y===void 0?void 0:y.landedCost)===null||i===void 0?void 0:i.landedCostGuaranteeCode)==="ZONOS";C=!!((s=(a=y===null||y===void 0?void 0:y.landedCost)===null||a===void 0?void 0:a.deMinimis)===null||s===void 0?void 0:s.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));Se.isSelectedShippingAboveDeminimis=C;Se.isSelectedShippingGuarantee=O;k=false;if(!E)return[3,1];A=y.subtotals;Ee({dutiesTaxesFeesEstimate:S,method:Se.landedCostMethod,subtotals:A});p("Exchange rate updated for cart items (landed cost subtotal)","info",Se.exchangeRate);k=true;return[3,3];case 1:return[4,Pe({adjustmentsAmount:Se.adjustmentTotal,billToPartyId:F.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:S,landedCostId:(d=y.landedCost)===null||d===void 0?void 0:d.id,shipToPartyId:F.partyShippingId,varianceTestInput:r.enabledVariantTestKeys||[]})];case 2:k=e.sent();e.label=3;case 3:I=(u=Se.items.find(Boolean))===null||u===void 0?void 0:u.currencyCode;T=((l=F.stripeAddressEventData)===null||l===void 0?void 0:l.value.address.country)||"US";F.shouldRenderPayInUsdButton=I==="USD"&&n.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((c=Se.checkoutSession)===null||c===void 0?void 0:c.subtotals.presentmentCurrencyCode)!=="USD"&&!!((f=(v=n.genericSettings)===null||v===void 0?void 0:v.usdSettlementCountryEnabled)===null||f===void 0?void 0:f.includes(T));return[2,k]}}))}))}));var xe=e("m",(function(e){var n=e.isPreview,t=e.sessionTimeout;if(n){return}var r=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var o=r&&!isNaN(parseInt(r,10))?parseInt(r,10):t;p("==START CHECKOUT TIMEOUT - ".concat(o,"=="));Se.checkoutTimeoutInterval=setTimeout((function(){Se.checkoutSessionTimeoutShow=true}),o)}));var Re=e("j",(function(){if(Se.checkoutTimeoutInterval){clearTimeout(Se.checkoutTimeoutInterval);Se.checkoutTimeoutInterval=null}}));var Ue=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var ze=function(){Se.items=Se.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));Se.restrictedItems=[]};var Be=e("f",(function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,o,i;var a=e.adjustments,s=e.cartItems,d=e.landedCostId,u=e.shouldInitSessionOnFailure,l=u===void 0?true:u;return __generator(this,(function(e){switch(e.label){case 0:Se.adjustments=a;Se.items=Ue(s);t=(n=s.find(Boolean))===null||n===void 0?void 0:n.currencyCode;o=s.reduce((function(e,n){return e+n.amount*n.quantity}),0);i=a.reduce((function(e,n){return e+n.amount}),0);if(!t||!o){return[2]}Se.currency=t;F.isFetchingSession=true;return[4,Pe({adjustmentsAmount:i,billToPartyId:F.partyBillingId,cartId:window.Zonos.cartId,currency:t,dutiesTaxesFeesEstimate:0,itemsAmount:o,landedCostId:d,shipToPartyId:F.partyShippingId,shouldInitSessionOnFailure:l,varianceTestInput:r.enabledVariantTestKeys||[]})];case 1:e.sent();F.isFetchingSession=false;return[2]}}))}))}));var Fe=function(){Se.selectedShippingOption=null;Se.isSelectedShippingAboveDeminimis=false;Se.isSelectedShippingGuarantee=false;Se.selectedShippingOptionTransitTime="";Se.dutiesTaxesFees=0;Se.dutiesTaxesFeesEstimate=0;Se.shipping=0;Se.total=Se.subtotal};var Je=function(){if(Se.step==="shipping"){Se.step="customer-info";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{"customer-info":Object.assign(Object.assign({},Se.tabItems.shipping),{isDone:false})})}else if(Se.step==="payment"){Se.step="shipping";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{shipping:Object.assign(Object.assign({},Se.tabItems.shipping),{isDone:false})})}else if(Se.step==="finish"){Se.step="payment";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{payment:Object.assign(Object.assign({},Se.tabItems.payment),{isDone:false})})}};var Me=e("r",(function(){if(Se.step==="customer-info"){Se.step="shipping";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{"customer-info":Object.assign(Object.assign({},Se.tabItems["customer-info"]),{isDone:true})})}else if(Se.step==="shipping"){Se.step="payment";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{shipping:Object.assign(Object.assign({},Se.tabItems.shipping),{isDone:true})})}else if(Se.step==="payment"){Se.step="finish"}}));var qe=e("h",(function(){Se.step="customer-info";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{"customer-info":Object.assign(Object.assign({},Se.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},Se.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},Se.tabItems.shipping),{isDone:false})});Fe()}))}}}));
@@ -1 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(n,r,e,t){function o(n){return n instanceof e?n:new e((function(r){r(n)}))}return new(e||(e=Promise))((function(e,i){function a(n){try{c(t.next(n))}catch(n){i(n)}}function u(n){try{c(t["throw"](n))}catch(n){i(n)}}function c(n){n.done?e(n.value):o(n.value).then(a,u)}c((t=t.apply(n,r||[])).next())}))};var __generator=this&&this.__generator||function(n,r){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(n){return function(r){return c([n,r])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(e=0)),e)try{if(t=1,o&&(i=u[0]&2?o["return"]:u[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;if(o=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:e.label++;return{value:u[1],done:false};case 5:e.label++;o=u[1];u=[0];continue;case 7:u=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){e.label=u[1];break}if(u[0]===6&&e.label<i[1]){e.label=i[1];i=u;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(u);break}if(i[2])e.ops.pop();e.trys.pop();continue}u=r.call(n,e)}catch(n){u=[6,n];o=0}finally{t=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-89c5164b.system.js","./p-01174496.system.js","./p-d938f42f.system.js","./p-b4fe3604.system.js"],(function(n){"use strict";var r,e,t,o,i,a,u,c;return{setters:[function(n){r=n.c;e=n.z},function(n){t=n.j;o=n.h;i=n.l},function(n){a=n.a;u=n.l},function(n){c=n.a}],execute:function(){var s=this;var l=function(n){var r=!!n.find((function(n){return n.testKey in a}));if(!r){u("No available test key found in response","info",{response:n})}return!!n.find((function(n){return n.testKey in a}))};var v=n("f",(function(n){if(!l(n)){return[]}return n.filter((function(n){var r;var e=a[n.testKey]&&!n.selectedVariantKey;var t=n.selectedVariantKey&&!!((r=a[n.testKey])===null||r===void 0?void 0:r["availableVariants"].includes(n.selectedVariantKey));return e||t})).map((function(n){return Object.assign(Object.assign({},n),{expiresAt:n.expiresAt||Date.now()+d,selectedVariantKey:n.selectedVariantKey||null})}))}));var d=n("V",60*60*24*1e3);var f=r({checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id"),enabledVariantTestKeys:t(localStorage.getItem("zonos--enabled-variant-test-keys"))}),w=f.onChange,y=f.state;n({o:w,s:y});w("enabledVariantTestKeys",(function(){var n;if(!((n=y.enabledVariantTestKeys)===null||n===void 0?void 0:n.length)){localStorage.removeItem("zonos--enabled-variant-test-keys");return}localStorage.setItem("zonos--enabled-variant-test-keys",JSON.stringify(y.enabledVariantTestKeys))}));w("checkoutSessionId",(function(){if(!y.checkoutSessionId){sessionStorage.removeItem("zonos--checkout-session-id");return}sessionStorage.setItem("zonos--checkout-session-id",y.checkoutSessionId)}));var m=n("b",(function(n){y.enabledVariantTestKeys=v(n)}));var h=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e,t;return __generator(this,(function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);return[4,o("/api/zonos-elements/get-countries",{method:"GET"})];case 1:n=i.sent(),r=n.errors,e=n.json;if(r.length||!e){return[2,null]}return[2,e];case 2:t=i.sent();return[2,null];case 3:return[2]}}))}))};var g=function(n){return __awaiter(s,void 0,void 0,(function(){var r,e,t,a,u;return __generator(this,(function(c){switch(c.label){case 0:if(!n){return[2,null]}e="/api/zonos-elements/country-landed-cost/".concat(n);return[4,o(e)];case 1:t=c.sent(),a=t.errors,u=t.json;if(a.length||!u){i("Error fetching country landed cost: ".concat((r=a.find(Boolean))===null||r===void 0?void 0:r.message));return[2,null]}return[2,u||null]}}))}))};var _={exchangeRate:{rate:1,targetFormat:{currencyCode:"USD",decimalDelimiter:".",scale:2,symbol:"$",symbolLocation:"before",thousandsDelimiter:","}},maxAge:null};var p=function(n){return __awaiter(s,[n],void 0,(function(n){var r,e,t,a,u,c,s,l,v,d;var f=n.country,w=n.isGuaranteed,y=n.sourceCurrency,m=n.targetCurrency;return __generator(this,(function(n){switch(n.label){case 0:if(y===m&&!w){return[2,_]}e=new URLSearchParams;e.set("sourceCurrency",y);e.set("targetCurrency",m);e.set("isGuaranteed",String(w));e.set("country",f||"");return[4,o("/api/zonos-elements/exchange-rates?".concat(e.toString()))];case 1:t=n.sent(),a=t.errors,u=t.json;if(a.length||!u){i("Error fetching country landed cost: ".concat((r=a.find(Boolean))===null||r===void 0?void 0:r.message));return[2,_]}c=u.exchangeRateCreate,s=c.rate,l=c.targetFormat;v=u.maxAge;if(s){sessionStorage.setItem(f+"_rate",JSON.stringify(s));d={rate:s,targetFormat:l};return[2,{exchangeRate:d,maxAge:v}]}return[2,_]}}))}))};var b=function(n){return __awaiter(s,void 0,void 0,(function(){var r,e,t,a;return __generator(this,(function(u){switch(u.label){case 0:if(!n){return[2,null]}return[4,o("/api/zonos-elements/inclusive-prices/".concat(n))];case 1:e=u.sent(),t=e.errors,a=e.json;if(t.length||!a){i("Error fetching country inclusive price setting: ".concat((r=t.find(Boolean))===null||r===void 0?void 0:r.message));return[2,null]}return[2,a||null]}}))}))};var z=function(n){return __awaiter(s,[n],void 0,(function(n){var r,e,t,a,u;var c=n.countryCode,s=n.localeTo,l=n.storeId;return __generator(this,(function(n){switch(n.label){case 0:e=new URLSearchParams;e.set("countryCode",c);e.set("storeId",l.toString());if(s){e.set("localeTo",s)}return[4,o("/api/zonos-elements/locale-messages?".concat(e.toString()))];case 1:t=n.sent(),a=t.errors,u=t.json;if(a.length||!u){i("Error fetching exchange rate",(r=a.find(Boolean))===null||r===void 0?void 0:r.message);return[2,[]]}return[2,u.locale_countryCodesPage]}}))}))};var S=function(n){if(n&&/^[A-Z]{2}$/.test(n)){return n}return null};var C=n("g",(function(n){var r=new URLSearchParams(n||window.location.search);var e=function(n){var e=r.get(n);return S(e)};var t=e("zCountry");var o=e("country");var i=e("customerCountry");return t||o||i}));var L=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e,t,i,a,u,c;return __generator(this,(function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);n=new URL(window.location.href);r=window.sessionStorage.getItem("zonos--country");e=C(n.searchParams)||r;t=new URLSearchParams;if(e){t.set("zCountry",e)}return[4,o("/api/zonos-elements/localization?".concat(t.toString()))];case 1:i=s.sent(),a=i.errors,u=i.json;if(a.length||!u){return[2,{country:null,locale:null}]}return[2,{country:u.country,locale:u.locale}];case 2:c=s.sent();return[2,{country:null,locale:null}];case 3:return[2]}}))}))};var k=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e,t,a,u,c;return __generator(this,(function(s){switch(s.label){case 0:if((n=window.Zonos.cartSettings)===null||n===void 0?void 0:n.shippingZones){return[2,window.Zonos.cartSettings.shippingZones.flatMap((function(n){return n===null||n===void 0?void 0:n.countryCodes})).filter(Boolean)]}return[4,o("/api/zonos-elements/shipping-zones")];case 1:t=s.sent(),a=t.errors,u=t.json;if(a.length||!u){i("Error fetching shipping zones: ".concat((r=a.find(Boolean))===null||r===void 0?void 0:r.message));return[2,null]}c=(e=u===null||u===void 0?void 0:u.shippingZones)===null||e===void 0?void 0:e.flatMap((function(n){return n===null||n===void 0?void 0:n.countryCodes})).filter(Boolean);return[2,c||null]}}))}))};var I=n("m",(function(n){var r=$.exchangeRate;if(!r||!n||isNaN(n)){return n}var e=(r===null||r===void 0?void 0:r.targetFormat.scale)||2;var t=n*r.rate;var o=t.toFixed(e);return Number(o)}));var A=function(n){var r=n.amount,e=n.currency,t=n.targetFormat;var o=e||$.targetCurrency;var i=(t===null||t===void 0?void 0:t.scale)||2;var a=window.navigator.userAgent.indexOf("MSIE ")!==-1;var u=typeof Intl==="object"&&Intl&&typeof Intl.NumberFormat==="function";if(a||!u){var c=Number(r).toFixed(i).replace(".","|dec|").replace(",",(t===null||t===void 0?void 0:t.thousandsDelimiter)||"").replace("|dec|",(t===null||t===void 0?void 0:t.decimalDelimiter)||"");return c}var s=new Intl.NumberFormat(window.navigator.language,{currency:o,currencyDisplay:"code",minimumFractionDigits:i,style:"currency"}).format(r);return s.replace(new RegExp("".concat(o,"\\s+")),"")};var E=n("d",(function(n){var r=n.amount,t=n.currency;if(isNaN(r)||r!==0&&!r){return""}var o=e.overrideCurrencyFormat;var i=$.exchangeRate;var a=t||$.targetCurrency;if(typeof o==="function"){return o({amount:r,currencyCode:a,numberFormat:function(n){var r=n.amount;return A({amount:r,currency:a,targetFormat:(i===null||i===void 0?void 0:i.targetFormat)||null})}})}var u=(i||{}).targetFormat;if(!u||!i){return"".concat(r.toFixed(2)," ").concat(a)}var c=u.scale||2;var s=window.navigator.userAgent.indexOf("MSIE ")!==-1;var l=typeof Intl==="object"&&Intl&&typeof Intl.NumberFormat==="function";if(s||!l){var v=Number(r).toFixed(c).replace(".","|dec|").replace(",",u.thousandsDelimiter||"").replace("|dec|",u.decimalDelimiter||"");var d="".concat(v).concat(u.currencyCode!=="USD"?" ".concat(u.currencyCode):"");return d}var f=(o===null||o===void 0?void 0:o.currencyDisplay)||"symbol";var w=new Intl.NumberFormat(window.navigator.language,{currency:a,currencyDisplay:f,minimumFractionDigits:c,style:"currency"}).format(r);var y=f==="code"?"".concat(w.replace(new RegExp("".concat(a,"\\s+")),"")," ").concat(a):w;return y}));var N=n("k",(function(n){var r=I(n);var e=E({amount:r});return e}));var x=n("i",(function(n){try{document.createDocumentFragment().querySelector(n)}catch(n){return false}return true}));var D=function(n){var r=n||".money";if(!x(r)){i('Currency element selector "'.concat(r,'" is not valid.'));return null}var e=document.querySelectorAll(r);if(!e.length){u('No currency elements found with selector "'.concat(r,'"'),"warn");return null}return Array.from(e)};var j=function(n){var r;var e=n.getAttribute("data-domestic");var t=n.getAttribute("data-zintl");var o=(r=n.textContent)===null||r===void 0?void 0:r.replace(/[^\d.-]/g,"");if(!o){return null}if(!e||n.textContent!==t&&t){n.setAttribute("data-domestic",o);return parseFloat(o)}return parseFloat(e)};var B=7e3;var R="z--blur";var P=function(){return __awaiter(s,void 0,void 0,(function(){var n,r;return __generator(this,(function(e){switch(e.label){case 0:n=window.zonosBlurCurrencyOnInitIntervalId;if(!n){return[2]}return[4,new Promise((function(n){return setTimeout(n,500)}))];case 1:e.sent();clearInterval(n);r=document.querySelectorAll(".".concat(R));r.forEach((function(n){n.classList.remove(R)}));window.zonosBlurCurrencyOnInitIntervalId=undefined;return[2]}}))}))};var U=function(n){var r=n.currencySelector;if(!r){return}var e=document.querySelectorAll([r].filter(Boolean).join(","));e.forEach((function(n){n.classList.add(R)}))};var O=function(){if(typeof window==="undefined"){return}if(window.zonosBlurCurrencyOnInitIntervalId){return}U({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});var n=setInterval((function(){U({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})}),10);window.zonosBlurCurrencyOnInitIntervalId=n;setTimeout((function(){void P()}),B)};var T=function(n){var r;var t=j(n);if(!t||isNaN(t)){return}var o=n.getAttribute("data-zintl");var i=parseFloat(n.getAttribute("data-zrate")||"1");var a=n.getAttribute("data-zcountry-code");var u=$.exchangeRate&&$.targetCurrency===$.exchangeRate.targetFormat.currencyCode;var c=((r=$.exchangeRate)===null||r===void 0?void 0:r.rate)||1;if(u&&(n.textContent!==o||c!==i||a!==$.selectedCountryCode)){O();var s=typeof e.currencyConverter==="function"&&e.currencyConverter({convert:I,convertAndFormat:N,currencyCode:$.targetCurrency,format:function(n){return E({amount:n})},originalAmount:t,selector:n});var l=s||N(t);if(l!==n.textContent){n.textContent=l}n.setAttribute("data-zrate",c.toString());n.setAttribute("data-zintl",l);n.setAttribute("data-zcountry-code",$.selectedCountryCode||"")}void P()};var F=function(){var n=e.helloSettings.currencyElementSelector;var r=D(n);if(!(r===null||r===void 0?void 0:r.length)){return}if(!$.exchangeRate){i("Could not display currency. Exchange rate and format data is not available.");return}r.forEach((function(n){T(n)}))};var G=n("j",(function(){if(e.helloSettings.currencyBehavior==="DISABLED"||window.Zonos.isLegacyCheckout){void P();return}F()}));var J=function(n){var r;var e=(r=$.shippingZoneCountries)===null||r===void 0?void 0:r[n];if(e){return e.currencyCode}return null};var K=n("h",(function(n){if(!n){return}var r=new URLSearchParams(window.location.search);var t=r.has("zCountry")||e.helloSettings.countryOverrideBehavior==="URL_PARAM";if(t){r.set("zCountry",n);var o="".concat(window.location.pathname,"?").concat(r.toString());window.history.replaceState(window.history.state,document.title,o)}}));var M=r({countryLandedCost:null,customMessages:[],exchangeRate:null,helloCountryList:null,inclusivePricing:null,isDisabledCountry:true,isShippableCountry:false,localizationLoaded:false,selectedCountryCode:null,selectedLocale:"en",shippingZoneCountries:null,targetCurrency:"USD"}),V=M.dispose,Z=M.onChange,$=M.state;n({c:Z,l:$});var q=function(n){return __awaiter(s,void 0,void 0,(function(){var r,t,o;return __generator(this,(function(i){switch(i.label){case 0:return[4,p({country:$.selectedCountryCode,isGuaranteed:n,sourceCurrency:e.sourceCurrency,targetCurrency:$.targetCurrency})];case 1:r=i.sent(),t=r.exchangeRate,o=r.maxAge;if(t){$.exchangeRate=t;G()}return[2,{maxAge:o}]}}))}))};var H="CA";var Y=n("n",(function(n){if($.selectedCountryCode&&n.includes($.selectedCountryCode)){return $.selectedCountryCode}return H}));var Q=function(n){var r=n.isGuaranteed,e=n.maxAge;if($.exchangeRateTimeout){clearTimeout($.exchangeRateTimeout)}var t=5*60;var o=e||t;$.exchangeRateTimeout=setTimeout((function(){return __awaiter(s,void 0,void 0,(function(){var n;return __generator(this,(function(e){switch(e.label){case 0:return[4,q(r)];case 1:n=e.sent().maxAge;Q({isGuaranteed:r,maxAge:n});return[2]}}))}))}),o*1e3)};var W=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,t,o,i,a,c,s;return __generator(this,(function(l){switch(l.label){case 0:u("get new localization store");r=$.isDisabledCountry,t=$.isShippableCountry,o=$.selectedCountryCode;if(e.helloSettings.currencyBehavior==="DISABLED"||!t||r||!o){return[2]}i=e.checkoutSettings.visibilityStatus==="ENABLED";O();return[4,q(i)];case 1:a=l.sent().maxAge;Q({isGuaranteed:i,maxAge:a});if(!!window.Zonos.isLegacyCheckout)return[3,4];c=$;return[4,g($.selectedCountryCode)];case 2:c.countryLandedCost=l.sent();s=$;return[4,b(o)];case 3:s.inclusivePricing=((n=l.sent())===null||n===void 0?void 0:n.setting)||null;if($.inclusivePricing){u("Inclusive price setting found for this country (".concat(o,") ").concat(JSON.stringify($.inclusivePricing,null,2)))}return[3,5];case 4:u("Skipping country landed cost and inclusive pricing requests, because this is a legacy checkout");l.label=5;case 5:return[2]}}))}))};var X=function(){return __awaiter(s,void 0,void 0,(function(){var n,r;return __generator(this,(function(t){switch(t.label){case 0:u("Getting custom messages for ".concat($.selectedCountryCode));if(!$.selectedCountryCode||!e.storeId){return[2]}return[4,z({countryCode:$.selectedCountryCode,localeTo:$.selectedLocale,storeId:e.storeId})];case 1:n=t.sent();r=n.flatMap((function(n){var r;return{countryCode:$.selectedCountryCode,message:(r=n.countryCodesPageMessageLinks.find(Boolean))===null||r===void 0?void 0:r.message.textTo,pageName:n.pageName}}));$.customMessages=r;return[2]}}))}))};var nn=function(){var n=new URL(window.location.href);var r=n.searchParams.get("zonosLocale");return r};var rn=function(){if($.isShippableCountry){document.body.classList.add("z-intl")}else{document.body.classList.remove("z-intl")}};var en=function(n){if(n==="UK"){return"GB"}return n};var tn=n("a",(function(n){var r,t;u("Updating selected country code to ".concat(n));var o=!$.selectedCountryCode;$.selectedCountryCode=en(n);var i=$.selectedCountryCode,a=$.shippingZoneCountries;var c=!!a&&!!i&&!!a[i]&&!e.disabledCountries.includes(i);$.isShippableCountry=c;u("".concat($.selectedCountryCode," is a shippable country: ").concat($.isShippableCountry));var s=!!i&&e.disabledCountries.includes(i);$.isDisabledCountry=s;u("".concat($.selectedCountryCode," is a disabled country: ").concat($.isDisabledCountry));rn();if(!i){return}var l=J(i);if(!o){(r=e.onCountryChange)===null||r===void 0?void 0:r.call(e,{countryCode:i,currencyCode:l,isShippableCountry:c})}if(!l){return}$.targetCurrency=l;void W();window.sessionStorage.setItem("zonos--country",i);K(i);(t=document.querySelector("zonos-hello"))===null||t===void 0?void 0:t.setAttribute("z-country",i)}));var on=function(n){var r=e.helloSettings.showCountryList;var t=$.shippingZoneCountries;if(!r||r==="ONLY_SHIPPABLE"){$.helloCountryList=t;return}if(r==="ALL"){$.helloCountryList=n;return}$.helloCountryList=r.reduce((function(r,e){var t;var o=n===null||n===void 0?void 0:n[e];return o?Object.assign(Object.assign({},r),(t={},t[e]=o,t)):r}),{})};var an=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e;return __generator(this,(function(t){switch(t.label){case 0:if(!y.checkoutSessionId){return[2,null]}return[4,o("/api/zonos-elements/update-checkout-session-metadata",{body:{id:y.checkoutSessionId,metadata:[{key:"language",value:$.selectedLocale}]},method:"POST"})];case 1:n=t.sent(),r=n.errors,e=n.json;if(r.length||!e){i("Error occurs when updating checkout session",JSON.stringify(r,null,2));return[2,{errors:r,json:e}]}return[2,{errors:[],json:e}]}}))}))};var un=n("p",(function(n){$.selectedLocale=n;c(n);void an();void X()}));var cn=n("e",(function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e,t,o,i,a,c,s;return __generator(this,(function(l){switch(l.label){case 0:return[4,Promise.all([h(),k(),L()])];case 1:n=l.sent(),r=n[0],e=n[1],t=n[2];o=e===null||e===void 0?void 0:e.reduce((function(n,e){var t;var o=r===null||r===void 0?void 0:r[e];return o?Object.assign(Object.assign({},n),(t={},t[e]=o,t)):n}),{});$.shippingZoneCountries=o||null;on(r||{});i=t.country,a=t.locale;u("Country code from localization: ".concat(i));u("Locale from localization: ".concat(a));tn(i);c=nn();un(c||a||"en");s=["dev.storybook.elements","dev.elements","dev.demo.elements","dev.dashboard"];if(!$.selectedCountryCode&&s.some((function(n){return window.location.origin.includes(n)}))){tn("CA")}$.localizationLoaded=true;return[2]}}))}))}))}}}));