@zonos/elements 1.5.1 → 1.5.2

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 (229) hide show
  1. package/dist/cjs/{cart-CiXlehwQ.js → cart-BJpqPdFU.js} +13 -13
  2. package/dist/cjs/{collect-Drr8fY-q.js → collect-CyUttsvB.js} +3 -3
  3. package/dist/cjs/{getMissingRequiredShippingFields-DI6qF1z3.js → getMissingRequiredShippingFields-DEbNbRAZ.js} +1 -1
  4. package/dist/cjs/{handleFetch-DQLhurnE.js → handleFetch-DVfjFTYO.js} +181 -71
  5. package/dist/cjs/{hasInclusivePrice-84KS94yH.js → hasInclusivePrice-CEPf3_FG.js} +1 -1
  6. package/dist/cjs/index.cjs.js +104 -12
  7. package/dist/cjs/{invoice-5hVfSXpb.js → invoice-DzRkkpLu.js} +3 -3
  8. package/dist/cjs/{localization-B2mjW0Xa.js → localization-BhNVhLZs.js} +24 -48
  9. package/dist/cjs/{paypal-pd8Nz_R_.js → paypal-DCSqbdjW.js} +4 -4
  10. package/dist/cjs/{placeTestOrder-DrI8rD9o.js → placeTestOrder-Bkip4PUT.js} +3 -3
  11. package/dist/cjs/{renderCheckoutCurrency-u5q8YdUb.js → renderCheckoutCurrency-BDvEZ3Hv.js} +2 -2
  12. package/dist/cjs/{shouldShowLanguageSelect-gBg4KeTQ.js → shouldShowLanguageSelect-NOVWOU53.js} +1 -1
  13. package/dist/cjs/{submitGtag-Rc-S3PnH.js → submitGtag-D4sB7w4z.js} +1 -1
  14. package/dist/cjs/{taxIdFields-BrIaPTcd.js → taxIdFields-e4OCgr8K.js} +2 -2
  15. package/dist/cjs/{updateCheckoutSessionAttributes-d0IKpwW8.js → updateCheckoutSessionAttributes-KxwcsKhM.js} +1 -1
  16. package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +5 -5
  17. package/dist/cjs/zonos-address-display_2.cjs.entry.js +2 -2
  18. package/dist/cjs/zonos-address_4.cjs.entry.js +4 -4
  19. package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +4 -4
  20. package/dist/cjs/zonos-card_5.cjs.entry.js +5 -5
  21. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +18 -18
  22. package/dist/cjs/zonos-checkout.cjs.entry.js +9 -9
  23. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +3 -3
  24. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +9 -9
  25. package/dist/cjs/zonos-collect.cjs.entry.js +6 -6
  26. package/dist/cjs/zonos-controller.cjs.entry.js +6 -6
  27. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  28. package/dist/cjs/zonos-country-select_4.cjs.entry.js +3 -3
  29. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +3 -3
  30. package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
  31. package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +5 -5
  32. package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +9 -9
  33. package/dist/cjs/zonos-invoice.cjs.entry.js +6 -6
  34. package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
  35. package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +4 -4
  36. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +8 -7
  37. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +4 -3
  38. package/dist/collection/components/main/zonos-controller.js +3 -2
  39. package/dist/collection/components/store/checkout/cart.js +3 -2
  40. package/dist/collection/components/store/checkout/stripe.js +10 -9
  41. package/dist/collection/components/store/storageStore.js +7 -6
  42. package/dist/collection/components/utils/__tests__/helpers/blockStorage.js +24 -0
  43. package/dist/collection/components/utils/api/getExchangeRate.js +2 -1
  44. package/dist/collection/components/utils/handleFetch.js +19 -9
  45. package/dist/collection/components/utils/hello/countryOverrideStorage.js +17 -40
  46. package/dist/collection/components/utils/logging/installConstructorCapture.js +58 -0
  47. package/dist/collection/components/utils/logging/reportBlockedStorage.js +34 -0
  48. package/dist/collection/components/utils/logging/sendErrorLog.js +8 -1
  49. package/dist/collection/components/utils/logging/startZonosInit.js +35 -0
  50. package/dist/collection/components/utils/logging/thrownMessage.js +16 -0
  51. package/dist/collection/components/utils/safeStorage.js +39 -0
  52. package/dist/collection/scripts/_getZonosQaUrl.js +3 -2
  53. package/dist/collection/scripts/_zonosBase.js +6 -2
  54. package/dist/collection/types/generated/graphql.frontend.types.js +0 -16
  55. package/dist/collection/types/generated/graphql.internal.types.js +215 -1
  56. package/dist/esm/{cart-DmJkjiDE.js → cart-BS5mSI8x.js} +13 -13
  57. package/dist/esm/{collect-BV5GTPmh.js → collect-B9ZxDDl7.js} +3 -3
  58. package/dist/esm/{getMissingRequiredShippingFields-DljgpDZe.js → getMissingRequiredShippingFields-BkEV865q.js} +1 -1
  59. package/dist/esm/{handleFetch-D5GYDF-O.js → handleFetch-BFVO7oAR.js} +178 -72
  60. package/dist/esm/{hasInclusivePrice-DhGXpH2D.js → hasInclusivePrice-zSvDReDb.js} +1 -1
  61. package/dist/esm/index.js +104 -12
  62. package/dist/esm/{invoice-CO-iqlni.js → invoice-6iTuS6ek.js} +3 -3
  63. package/dist/esm/{localization-DHM91diu.js → localization-CXHiWcJp.js} +24 -48
  64. package/dist/esm/{paypal-BfW5aLJw.js → paypal-BE_NVBoy.js} +4 -4
  65. package/dist/esm/{placeTestOrder-CyWUFhxD.js → placeTestOrder-BXA9K9Iy.js} +3 -3
  66. package/dist/esm/{renderCheckoutCurrency-B31ZNkUv.js → renderCheckoutCurrency-KMa4HlAf.js} +2 -2
  67. package/dist/esm/{shouldShowLanguageSelect-DwSfSHar.js → shouldShowLanguageSelect-BI_ApEsQ.js} +1 -1
  68. package/dist/esm/{submitGtag-BEFrutel.js → submitGtag-C5xzFHjG.js} +1 -1
  69. package/dist/esm/{taxIdFields-ByEYfsO5.js → taxIdFields-BUKnHMaL.js} +2 -2
  70. package/dist/esm/{updateCheckoutSessionAttributes-B0bQH0uw.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
  71. package/dist/esm/zonos-address-completion-dialog_7.entry.js +5 -5
  72. package/dist/esm/zonos-address-display_2.entry.js +2 -2
  73. package/dist/esm/zonos-address_4.entry.js +4 -4
  74. package/dist/esm/zonos-airwallex-payment.entry.js +4 -4
  75. package/dist/esm/zonos-card_5.entry.js +5 -5
  76. package/dist/esm/zonos-cart-items_12.entry.js +18 -18
  77. package/dist/esm/zonos-checkout.entry.js +9 -9
  78. package/dist/esm/zonos-collect-cart-items_3.entry.js +3 -3
  79. package/dist/esm/zonos-collect-finish_6.entry.js +9 -9
  80. package/dist/esm/zonos-collect.entry.js +6 -6
  81. package/dist/esm/zonos-controller.entry.js +6 -6
  82. package/dist/esm/zonos-country-flag.entry.js +2 -2
  83. package/dist/esm/zonos-country-select_4.entry.js +3 -3
  84. package/dist/esm/zonos-hello-dialog.entry.js +3 -3
  85. package/dist/esm/zonos-hello.entry.js +2 -2
  86. package/dist/esm/zonos-invoice-cart-items_2.entry.js +5 -5
  87. package/dist/esm/zonos-invoice-finish_5.entry.js +9 -9
  88. package/dist/esm/zonos-invoice.entry.js +6 -6
  89. package/dist/esm/zonos-language-select_2.entry.js +2 -2
  90. package/dist/esm/zonos-policy-consent_2.entry.js +4 -4
  91. package/dist/esm-es5/{cart-DmJkjiDE.js → cart-BS5mSI8x.js} +58 -58
  92. package/dist/esm-es5/{collect-BV5GTPmh.js → collect-B9ZxDDl7.js} +1 -1
  93. package/dist/esm-es5/{getMissingRequiredShippingFields-DljgpDZe.js → getMissingRequiredShippingFields-BkEV865q.js} +1 -1
  94. package/dist/esm-es5/handleFetch-BFVO7oAR.js +73 -0
  95. package/dist/esm-es5/{hasInclusivePrice-DhGXpH2D.js → hasInclusivePrice-zSvDReDb.js} +1 -1
  96. package/dist/esm-es5/index.js +26 -8
  97. package/dist/esm-es5/{invoice-CO-iqlni.js → invoice-6iTuS6ek.js} +1 -1
  98. package/dist/esm-es5/{localization-DHM91diu.js → localization-CXHiWcJp.js} +6 -9
  99. package/dist/esm-es5/{paypal-BfW5aLJw.js → paypal-BE_NVBoy.js} +1 -1
  100. package/dist/esm-es5/{placeTestOrder-CyWUFhxD.js → placeTestOrder-BXA9K9Iy.js} +1 -1
  101. package/dist/esm-es5/{renderCheckoutCurrency-B31ZNkUv.js → renderCheckoutCurrency-KMa4HlAf.js} +2 -2
  102. package/dist/esm-es5/{shouldShowLanguageSelect-DwSfSHar.js → shouldShowLanguageSelect-BI_ApEsQ.js} +1 -1
  103. package/dist/esm-es5/{submitGtag-BEFrutel.js → submitGtag-C5xzFHjG.js} +1 -1
  104. package/dist/esm-es5/{taxIdFields-ByEYfsO5.js → taxIdFields-BUKnHMaL.js} +2 -2
  105. package/dist/esm-es5/{updateCheckoutSessionAttributes-B0bQH0uw.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
  106. package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +1 -1
  107. package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
  108. package/dist/esm-es5/zonos-address_4.entry.js +1 -1
  109. package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
  110. package/dist/esm-es5/zonos-card_5.entry.js +6 -6
  111. package/dist/esm-es5/zonos-cart-items_12.entry.js +127 -127
  112. package/dist/esm-es5/zonos-checkout.entry.js +3 -3
  113. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  114. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  115. package/dist/esm-es5/zonos-collect.entry.js +6 -6
  116. package/dist/esm-es5/zonos-controller.entry.js +5 -5
  117. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  118. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  119. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  120. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  121. package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
  122. package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
  123. package/dist/esm-es5/zonos-invoice.entry.js +3 -3
  124. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  125. package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
  126. package/dist/scripts/index.d.ts +6 -0
  127. package/dist/scripts/index.js +1 -1
  128. package/dist/scripts/loadZonos.js +1 -1
  129. package/dist/scripts/zonos.js +1 -1
  130. package/dist/types/components/utils/__tests__/helpers/blockStorage.d.ts +3 -0
  131. package/dist/types/components/utils/logging/installConstructorCapture.d.ts +20 -0
  132. package/dist/types/components/utils/logging/reportBlockedStorage.d.ts +16 -0
  133. package/dist/types/components/utils/logging/startZonosInit.d.ts +5 -0
  134. package/dist/types/components/utils/logging/thrownMessage.d.ts +1 -0
  135. package/dist/types/components/utils/safeStorage.d.ts +4 -0
  136. package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +5 -0
  137. package/dist/types/types/generated/graphql.frontend.types.d.ts +0 -22
  138. package/dist/types/types/generated/graphql.frontend.types.ts +0 -51
  139. package/dist/types/types/generated/graphql.internal.types.d.ts +270 -1
  140. package/dist/types/types/generated/graphql.internal.types.ts +341 -1
  141. package/dist/zonos-elements/index.esm.js +1 -1
  142. package/dist/zonos-elements/{p-8fa6cfff.entry.js → p-08b01c96.entry.js} +1 -1
  143. package/dist/zonos-elements/{p-3e705c9b.entry.js → p-0909ef77.entry.js} +1 -1
  144. package/dist/zonos-elements/{p-2b63865a.system.entry.js → p-13015d34.system.entry.js} +1 -1
  145. package/dist/zonos-elements/{p-2d513aa3.entry.js → p-13d5b2f9.entry.js} +1 -1
  146. package/dist/zonos-elements/{p-46a839d2.system.entry.js → p-150047b3.system.entry.js} +16 -16
  147. package/dist/zonos-elements/{p-6e691736.entry.js → p-1986cc37.entry.js} +1 -1
  148. package/dist/zonos-elements/{p-vTIygnHq.system.js → p-1OG3IJgY.system.js} +1 -1
  149. package/dist/zonos-elements/{p-189cc594.system.entry.js → p-30bf4700.system.entry.js} +1 -1
  150. package/dist/zonos-elements/{p-4917b74d.entry.js → p-3466bcba.entry.js} +1 -1
  151. package/dist/zonos-elements/{p-12b24ebb.entry.js → p-383343c7.entry.js} +1 -1
  152. package/dist/zonos-elements/{p-5585db86.system.entry.js → p-3a506614.system.entry.js} +36 -36
  153. package/dist/zonos-elements/{p-46b9f0cf.entry.js → p-43c0ebe9.entry.js} +1 -1
  154. package/dist/zonos-elements/{p-84e76348.entry.js → p-4b65f192.entry.js} +1 -1
  155. package/dist/zonos-elements/{p-216a908d.system.entry.js → p-573a4e7c.system.entry.js} +6 -6
  156. package/dist/zonos-elements/{p-1fda4aec.system.entry.js → p-5a296dbc.system.entry.js} +87 -87
  157. package/dist/zonos-elements/{p-960070d0.system.entry.js → p-68325c5a.system.entry.js} +4 -4
  158. package/dist/zonos-elements/{p-53eac12f.system.entry.js → p-6db7317a.system.entry.js} +13 -13
  159. package/dist/zonos-elements/{p-1199baef.system.entry.js → p-709d1561.system.entry.js} +1 -1
  160. package/dist/zonos-elements/p-71d29603.entry.js +1 -0
  161. package/dist/zonos-elements/{p-064d8829.system.entry.js → p-7214c953.system.entry.js} +23 -23
  162. package/dist/zonos-elements/{p-65817880.entry.js → p-7fe83919.entry.js} +1 -1
  163. package/dist/zonos-elements/p-8ac26831.entry.js +1 -0
  164. package/dist/zonos-elements/{p-cccaad60.system.entry.js → p-8f9f859f.system.entry.js} +9 -9
  165. package/dist/zonos-elements/{p-f5f95990.system.entry.js → p-96b250d8.system.entry.js} +14 -14
  166. package/dist/zonos-elements/{p-678b9214.entry.js → p-97729873.entry.js} +1 -1
  167. package/dist/zonos-elements/{p-f3d9a380.system.entry.js → p-9b3668a4.system.entry.js} +144 -144
  168. package/dist/zonos-elements/{p-d8f375da.system.entry.js → p-9df31243.system.entry.js} +1 -1
  169. package/dist/zonos-elements/p-BI6VAB5B.js +1 -0
  170. package/dist/zonos-elements/p-BJFa5RwX.js +1 -0
  171. package/dist/zonos-elements/p-BJ_kE5rM.js +1 -0
  172. package/dist/zonos-elements/{p-XoQH3S7Z.system.js → p-BKUlQxBd.system.js} +1 -1
  173. package/dist/zonos-elements/{p-DprOoI2W.system.js → p-BUfCTQXY.system.js} +154 -154
  174. package/dist/zonos-elements/{p-CBUz18kA.system.js → p-BnQyot7Y.system.js} +23 -23
  175. package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
  176. package/dist/zonos-elements/{p-CMo3ZweU.js → p-C-zdj7MK.js} +1 -1
  177. package/dist/zonos-elements/{p-iAIzUA4k.js → p-C5fs3rIR.js} +1 -1
  178. package/dist/zonos-elements/{p-D1e9zNDA.js → p-CJmWr75U.js} +1 -1
  179. package/dist/zonos-elements/{p-Dtu_Japy.system.js → p-CMneHjck.system.js} +39 -39
  180. package/dist/zonos-elements/p-CP7KnfR3.system.js +245 -0
  181. package/dist/zonos-elements/p-CVRbGFV3.js +1 -0
  182. package/dist/zonos-elements/p-Cl5yV0ak.js +1 -0
  183. package/dist/zonos-elements/{p-CGNVm52g.system.js → p-Cp1IAJvW.system.js} +5 -5
  184. package/dist/zonos-elements/{p-6vSUiBfr.system.js → p-D-Lnf8mS.system.js} +50 -53
  185. package/dist/zonos-elements/p-D0DkOoAw.system.js +73 -0
  186. package/dist/zonos-elements/p-D4xpkSsK.js +1 -0
  187. package/dist/zonos-elements/p-DATNIakn.js +1 -0
  188. package/dist/zonos-elements/{p-CbhN65lj.system.js → p-DC1OPJDq.system.js} +1 -1
  189. package/dist/zonos-elements/{p-CHKKvuiz.js → p-DKnphvmJ.js} +1 -1
  190. package/dist/zonos-elements/{p-ojtNq-r5.system.js → p-DXlojp_Y.system.js} +1 -1
  191. package/dist/zonos-elements/{p-C9XLkmmb.system.js → p-DrS-0mk7.system.js} +1 -1
  192. package/dist/zonos-elements/{p-DpwmHU8R.js → p-DrbN3rPL.js} +2 -2
  193. package/dist/zonos-elements/{p-BrQ8n8NS.system.js → p-Dv5a-V6w.system.js} +3 -3
  194. package/dist/zonos-elements/{p-55813e9f.system.entry.js → p-a3c147d2.system.entry.js} +3 -3
  195. package/dist/zonos-elements/{p-DiMEP3mh.js → p-aK18R41t.js} +1 -1
  196. package/dist/zonos-elements/p-af4ad54b.entry.js +1 -0
  197. package/dist/zonos-elements/{p-1e6db427.entry.js → p-af741506.entry.js} +1 -1
  198. package/dist/zonos-elements/{p-2ca826b9.system.entry.js → p-b540c636.system.entry.js} +1 -1
  199. package/dist/zonos-elements/{p-636b71d4.entry.js → p-bac94956.entry.js} +1 -1
  200. package/dist/zonos-elements/{p-941a95a1.system.entry.js → p-bb1b414a.system.entry.js} +5 -5
  201. package/dist/zonos-elements/{p-e7fdb2c9.entry.js → p-bfa9e32a.entry.js} +1 -1
  202. package/dist/zonos-elements/p-cf6bf7a4.entry.js +1 -0
  203. package/dist/zonos-elements/p-dJcbnNlE.system.js +7 -0
  204. package/dist/zonos-elements/{p-7dc7f328.entry.js → p-db40b9c3.entry.js} +1 -1
  205. package/dist/zonos-elements/{p-d3345b2c.entry.js → p-dd003161.entry.js} +1 -1
  206. package/dist/zonos-elements/{p-ef5344ea.entry.js → p-e374aaa4.entry.js} +1 -1
  207. package/dist/zonos-elements/{p-6410fa11.system.entry.js → p-e43470f7.system.entry.js} +22 -22
  208. package/dist/zonos-elements/{p-fda89981.system.entry.js → p-ebc7ea54.system.entry.js} +3 -3
  209. package/dist/zonos-elements/{p-1cc42a98.system.entry.js → p-f2ed52bc.system.entry.js} +16 -16
  210. package/dist/zonos-elements/p-gEViRqvf.js +1 -0
  211. package/dist/zonos-elements/{p-DgUrB-1a.system.js → p-yv7ekcdG.system.js} +2 -2
  212. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  213. package/package.json +1 -1
  214. package/dist/esm-es5/handleFetch-D5GYDF-O.js +0 -60
  215. package/dist/zonos-elements/p-107f287b.entry.js +0 -1
  216. package/dist/zonos-elements/p-25eb99d4.entry.js +0 -1
  217. package/dist/zonos-elements/p-8f9d8795.entry.js +0 -1
  218. package/dist/zonos-elements/p-BMPYH-LT.js +0 -1
  219. package/dist/zonos-elements/p-C70h5mKA.js +0 -1
  220. package/dist/zonos-elements/p-CTiqplrr.js +0 -1
  221. package/dist/zonos-elements/p-Ch1w0Lr7.js +0 -1
  222. package/dist/zonos-elements/p-D1SmY_fZ.js +0 -1
  223. package/dist/zonos-elements/p-D6xXnsM_.js +0 -1
  224. package/dist/zonos-elements/p-DE4a-QD5.js +0 -1
  225. package/dist/zonos-elements/p-DQrMfUzi.system.js +0 -227
  226. package/dist/zonos-elements/p-DZdkJHK9.system.js +0 -7
  227. package/dist/zonos-elements/p-U33isUJG.js +0 -1
  228. package/dist/zonos-elements/p-ebe157b5.entry.js +0 -1
  229. package/dist/zonos-elements/p-zVLAvre1.system.js +0 -60
@@ -1,43 +1,43 @@
1
- var __awaiter=this&&this.__awaiter||function(e,r,n,t){function o(e){return e instanceof n?e:new n((function(r){r(e)}))}return new(n||(n=Promise))((function(n,i){function a(e){try{u(t.next(e))}catch(e){i(e)}}function s(e){try{u(t["throw"](e))}catch(e){i(e)}}function u(e){e.done?n(e.value):o(e.value).then(a,s)}u((t=t.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(n=0)),n)try{if(t=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:n.label++;return{value:s[1],done:false};case 5:n.label++;o=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1];i=s;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(s);break}if(i[2])n.ops.pop();n.trys.pop();continue}s=r.call(e,n)}catch(e){s=[6,e];o=0}finally{t=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,r,n){if(n||arguments.length===2)for(var t=0,o=r.length,i;t<o;t++){if(i||!(t in r)){if(!i)i=Array.prototype.slice.call(r,0,t);i[t]=r[t]}}return e.concat(i||Array.prototype.slice.call(r))};System.register(["./p-DTgUqgwV.system.js","./p-6vSUiBfr.system.js","./p-CzKlS3E-.system.js","./p-DsBuZ6ob.system.js","./p-BbgqQIHv.system.js","./p-zVLAvre1.system.js","./p-DW-fW8yR.system.js","./p-zsTASoh2.system.js"],(function(e){"use strict";var r,n,t,o,i,a,s,u,d,l,c,v,f,p,m,h,y,w,g,b,S,_,O,A;return{setters:[function(e){r=e.c;n=e.z;t=e.e},function(e){o=e.s;i=e.t;a=e.m;s=e.l;u=e.f;d=e.e},function(e){l=e.b;c=e.e},function(e){v=e.e;f=e.i},function(e){p=e.l;m=e.b},function(e){h=e.h;y=e.l;w=e.f;g=e.g;b=e.a;S=e.s;_=e.j},function(e){O=e.i},function(e){A=e.g}],execute:function(){var C=this;var k=e("g",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(i){switch(i.label){case 0:if(!o.checkoutSessionId){return[2/*return*/,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",o.checkoutSessionId);return[4/*yield*/,h("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:r=i.sent(),n=r.errors,t=r.json;return[2/*return*/,{errors:n,json:t}]}}))}))}));var I=r((function(){return{amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:false,isEnabled:false,orderIdCreated:null,remainingBalance:null,useFullBalance:true}})),T=I.reset,P=I.state;e("R",P);
1
+ var __awaiter=this&&this.__awaiter||function(e,r,n,t){function o(e){return e instanceof n?e:new n((function(r){r(e)}))}return new(n||(n=Promise))((function(n,i){function a(e){try{u(t.next(e))}catch(e){i(e)}}function s(e){try{u(t["throw"](e))}catch(e){i(e)}}function u(e){e.done?n(e.value):o(e.value).then(a,s)}u((t=t.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(n=0)),n)try{if(t=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:n.label++;return{value:s[1],done:false};case 5:n.label++;o=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1];i=s;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(s);break}if(i[2])n.ops.pop();n.trys.pop();continue}s=r.call(e,n)}catch(e){s=[6,e];o=0}finally{t=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,r,n){if(n||arguments.length===2)for(var t=0,o=r.length,i;t<o;t++){if(i||!(t in r)){if(!i)i=Array.prototype.slice.call(r,0,t);i[t]=r[t]}}return e.concat(i||Array.prototype.slice.call(r))};System.register(["./p-DTgUqgwV.system.js","./p-D-Lnf8mS.system.js","./p-CzKlS3E-.system.js","./p-DsBuZ6ob.system.js","./p-BbgqQIHv.system.js","./p-D0DkOoAw.system.js","./p-DW-fW8yR.system.js","./p-zsTASoh2.system.js"],(function(e){"use strict";var r,n,t,o,i,a,s,u,d,l,c,v,f,p,m,h,y,w,g,b,_,S,O,A,C,k,I;return{setters:[function(e){r=e.c;n=e.z;t=e.e},function(e){o=e.s;i=e.t;a=e.m;s=e.l;u=e.f;d=e.e},function(e){l=e.b;c=e.e},function(e){v=e.e;f=e.i},function(e){p=e.l;m=e.b},function(e){h=e.h;y=e.l;w=e.f;g=e.g;b=e.a;_=e.s;S=e.c;O=e.e;A=e.b;C=e.j},function(e){k=e.i},function(e){I=e.g}],execute:function(){var T=this;var P=e("g",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(i){switch(i.label){case 0:if(!o.checkoutSessionId){return[2/*return*/,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",o.checkoutSessionId);return[4/*yield*/,h("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:r=i.sent(),n=r.errors,t=r.json;return[2/*return*/,{errors:n,json:t}]}}))}))}));var E=r((function(){return{amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:false,isEnabled:false,orderIdCreated:null,remainingBalance:null,useFullBalance:true}})),N=E.reset,j=E.state;e("R",j);
2
2
  /**
3
3
  * Reset store credit store to initial state
4
- */var E=e("S",(function(){T()}));
4
+ */var D=e("S",(function(){N()}));
5
5
  /**
6
6
  * Set the available balance from the checkout session's customerProfile.storeCreditBalance
7
- */var N=function(e){p("Store credit balance from session","info",e);P.availableBalance=e};
7
+ */var L=function(e){p("Store credit balance from session","info",e);j.availableBalance=e};
8
8
  /**
9
9
  * Re-fetch the store credit balance from the checkout session.
10
10
  * Called when the payment step loads to ensure the balance is fresh.
11
- */var j=e("a7",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:return[4/*yield*/,k()];case 1:n=a.sent(),t=n.errors,o=n.json;if(t.length||!o){y("Failed to refresh store credit balance");return[2/*return*/]}i=(r=(e=o.checkoutSession.customerProfile)===null||e===void 0?void 0:e.storeCreditBalance)!==null&&r!==void 0?r:null;N(i);return[2/*return*/]}}))}))}));
11
+ */var x=e("a7",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:return[4/*yield*/,P()];case 1:n=a.sent(),t=n.errors,o=n.json;if(t.length||!o){y("Failed to refresh store credit balance");return[2/*return*/]}i=(r=(e=o.checkoutSession.customerProfile)===null||e===void 0?void 0:e.storeCreditBalance)!==null&&r!==void 0?r:null;L(i);return[2/*return*/]}}))}))}));
12
12
  /**
13
13
  * Apply store credit to the checkout session.
14
14
  * This must be called BEFORE payment confirmation.
15
15
  * The amount/mode are already set via checkout session update with storeCreditApplication.
16
- */var D=e("A",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r,n,t,i,a,s,u,s;return __generator(this,(function(d){switch(d.label){case 0:r=o.checkoutSessionId;if(!r){n="No checkout session found";y(n);P.error=n;return[2/*return*/,{error:n,success:false}]}p("Applying store credit","info",{checkoutSessionId:r});P.isApplying=true;P.error=null;d.label=1;case 1:d.trys.push([1,3,,4]);return[4/*yield*/,h("/api/zonos-elements/store-credit/apply",{body:{checkoutSessionId:r},method:"POST"})];case 2:t=d.sent(),i=t.errors,a=t.json;if(i.length>0||!a){s=((e=i[0])===null||e===void 0?void 0:e.message)||"Failed to apply store credit";y(s);P.error=s;P.isApplying=false;return[2/*return*/,{error:s,success:false}]}P.appliedAmount=a.amountApplied;P.remainingBalance=a.remainingBalance;P.isApplying=false;p("Store credit applied","info",{amountApplied:a.amountApplied,remainingBalance:a.remainingBalance});return[2/*return*/,{error:null,success:true}];case 3:u=d.sent();s=u instanceof Error?u.message:"Failed to apply store credit";y(s);P.error=s;P.isApplying=false;return[2/*return*/,{error:s,success:false}];case 4:return[2/*return*/]}}))}))}));
16
+ */var R=e("A",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,i,a,s,u,s;return __generator(this,(function(d){switch(d.label){case 0:r=o.checkoutSessionId;if(!r){n="No checkout session found";y(n);j.error=n;return[2/*return*/,{error:n,success:false}]}p("Applying store credit","info",{checkoutSessionId:r});j.isApplying=true;j.error=null;d.label=1;case 1:d.trys.push([1,3,,4]);return[4/*yield*/,h("/api/zonos-elements/store-credit/apply",{body:{checkoutSessionId:r},method:"POST"})];case 2:t=d.sent(),i=t.errors,a=t.json;if(i.length>0||!a){s=((e=i[0])===null||e===void 0?void 0:e.message)||"Failed to apply store credit";y(s);j.error=s;j.isApplying=false;return[2/*return*/,{error:s,success:false}]}j.appliedAmount=a.amountApplied;j.remainingBalance=a.remainingBalance;j.isApplying=false;p("Store credit applied","info",{amountApplied:a.amountApplied,remainingBalance:a.remainingBalance});return[2/*return*/,{error:null,success:true}];case 3:u=d.sent();s=u instanceof Error?u.message:"Failed to apply store credit";y(s);j.error=s;j.isApplying=false;return[2/*return*/,{error:s,success:false}];case 4:return[2/*return*/]}}))}))}));
17
17
  /**
18
18
  * Enable or disable store credit usage.
19
19
  * When enabling, defaults to full balance mode.
20
20
  * When disabling, clears the amount.
21
- */var L=e("a3",(function(e){P.isEnabled=e;P.error=null;if(!e){P.amountToApply=null}}));
21
+ */var U=e("a3",(function(e){j.isEnabled=e;j.error=null;if(!e){j.amountToApply=null}}));
22
22
  /**
23
23
  * Set the amount of store credit to apply
24
24
  * Validates against available balance and cart total
25
- */var x=e("a6",(function(e){if(e===null){P.amountToApply=null;P.error=null;return}
25
+ */var z=e("a6",(function(e){if(e===null){j.amountToApply=null;j.error=null;return}
26
26
  // Validate amount
27
- if(e<=0){P.error="Amount must be greater than zero";return}if(P.availableBalance!==null&&e>P.availableBalance){P.error="Amount exceeds available balance";return}var r=or.total+(or.storeCredit||0);if(e>r){P.error="Amount exceeds order total";return}P.error=null;P.amountToApply=e}));
27
+ if(e<=0){j.error="Amount must be greater than zero";return}if(j.availableBalance!==null&&e>j.availableBalance){j.error="Amount exceeds available balance";return}var r=sr.total+(sr.storeCredit||0);if(e>r){j.error="Amount exceeds order total";return}j.error=null;j.amountToApply=e}));
28
28
  /**
29
29
  * Toggle whether to use full balance or custom amount.
30
30
  * When switching to custom mode, clears the applied amount so the user
31
31
  * must explicitly apply via the Apply button.
32
- */var R=e("a4",(function(e){P.useFullBalance=e;P.error=null;if(e&&P.availableBalance!==null){var r=or.total+(or.storeCredit||0);var n=Math.min(P.availableBalance,r);P.amountToApply=n}else if(!e){P.amountToApply=null}}));
32
+ */var B=e("a4",(function(e){j.useFullBalance=e;j.error=null;if(e&&j.availableBalance!==null){var r=sr.total+(sr.storeCredit||0);var n=Math.min(j.availableBalance,r);j.amountToApply=n}else if(!e){j.amountToApply=null}}));
33
33
  /**
34
34
  * Get the storeCreditApplication input for checkout session update.
35
35
  * Sends mode: 'NONE' when store credit is not being used to clear any
36
36
  * previously applied store credit on the backend.
37
- */var U=function(){if(!P.isEnabled||P.amountToApply===null){return{mode:"NONE"}}if(P.useFullBalance){return{mode:"FULL"}}return{amount:P.amountToApply,mode:"PARTIAL"}};
37
+ */var F=function(){if(!j.isEnabled||j.amountToApply===null){return{mode:"NONE"}}if(j.useFullBalance){return{mode:"FULL"}}return{amount:j.amountToApply,mode:"PARTIAL"}};
38
38
  /**
39
39
  * Get the effective amount to apply based on settings
40
- */var z=e("K",(function(){if(!P.isEnabled||P.availableBalance===null){return 0}if(P.useFullBalance){return Math.min(P.availableBalance,or.total+(or.storeCredit||0))}return P.amountToApply||0}));
40
+ */var q=e("K",(function(){if(!j.isEnabled||j.availableBalance===null){return 0}if(j.useFullBalance){return Math.min(j.availableBalance,sr.total+(sr.storeCredit||0))}return j.amountToApply||0}));
41
41
  /**
42
42
  * Check whether the effective store credit amount covers the full order total.
43
43
  * When true, the Stripe/PayPal payment flow should be skipped and
@@ -46,18 +46,18 @@ if(e<=0){P.error="Amount must be greater than zero";return}if(P.availableBalance
46
46
  * Relies on the backend's computed `cartStore.total` (remaining amount to pay
47
47
  * after store credit) rather than a client-side comparison, which avoids issues
48
48
  * with currency mismatches or rounding.
49
- */var B=e("B",(function(){
49
+ */var J=e("B",(function(){
50
50
  // Only consider full coverage after the backend has confirmed store credit
51
51
  // was applied (cartStore.storeCredit > 0) and the remaining total is 0.
52
- return P.amountToApply!==null&&P.amountToApply>0&&or.storeCredit>0&&or.total<=0}));
52
+ return j.amountToApply!==null&&j.amountToApply>0&&sr.storeCredit>0&&sr.total<=0}));
53
53
  /**
54
54
  * Create an order paid entirely by store credit.
55
55
  * Should only be called when `storeCreditStoreCoversFullAmount()` is true.
56
- */var F=e("D",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r,n,t,i,a,s,u,d,l,c,d;return __generator(this,(function(v){switch(v.label){case 0:t=o.checkoutSessionId;if(!t){i="No checkout session found";y(i);P.error=i;return[2/*return*/,{error:i,orderId:null,success:false}]}p("Creating store credit order","info",{checkoutSessionId:t});v.label=1;case 1:v.trys.push([1,3,,4]);return[4/*yield*/,h("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:t},method:"POST"})];case 2:a=v.sent(),s=a.errors,u=a.json;if(s.length>0||!u){d=((e=s[0])===null||e===void 0?void 0:e.message)||"Failed to create store credit order";y(d);P.error=d;return[2/*return*/,{error:d,orderId:null,success:false}]}l=((n=(r=u.checkoutSessionStoreCreditOrderCreate)===null||r===void 0?void 0:r.order)===null||n===void 0?void 0:n.id)||null;P.orderIdCreated=l;p("Store credit order created","info",{orderId:l});return[2/*return*/,{error:null,orderId:l,success:true}];case 3:c=v.sent();d=c instanceof Error?c.message:"Failed to create store credit order";y(d);P.error=d;return[2/*return*/,{error:d,orderId:null,success:false}];case 4:return[2/*return*/]}}))}))}));var q=["termsAndConditions","privacyPolicy","refundPolicy","shippingPolicy","warrantyPolicy"];
56
+ */var M=e("D",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,i,a,s,u,d,l,c,d;return __generator(this,(function(v){switch(v.label){case 0:t=o.checkoutSessionId;if(!t){i="No checkout session found";y(i);j.error=i;return[2/*return*/,{error:i,orderId:null,success:false}]}p("Creating store credit order","info",{checkoutSessionId:t});v.label=1;case 1:v.trys.push([1,3,,4]);return[4/*yield*/,h("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:t},method:"POST"})];case 2:a=v.sent(),s=a.errors,u=a.json;if(s.length>0||!u){d=((e=s[0])===null||e===void 0?void 0:e.message)||"Failed to create store credit order";y(d);j.error=d;return[2/*return*/,{error:d,orderId:null,success:false}]}l=((n=(r=u.checkoutSessionStoreCreditOrderCreate)===null||r===void 0?void 0:r.order)===null||n===void 0?void 0:n.id)||null;j.orderIdCreated=l;p("Store credit order created","info",{orderId:l});return[2/*return*/,{error:null,orderId:l,success:true}];case 3:c=v.sent();d=c instanceof Error?c.message:"Failed to create store credit order";y(d);j.error=d;return[2/*return*/,{error:d,orderId:null,success:false}];case 4:return[2/*return*/]}}))}))}));var W=["termsAndConditions","privacyPolicy","refundPolicy","shippingPolicy","warrantyPolicy"];
57
57
  // Reuses the lowercase `'Privacy policy'` key already translated in 19 locales
58
58
  // (also used by the checkout footer) — the other four are new keys that follow
59
59
  // the same lowercase convention for visual consistency in the joined consent line.
60
- var J={privacyPolicy:"Privacy policy",refundPolicy:"Refund policy",shippingPolicy:"Shipping policy",termsAndConditions:"Terms and conditions",warrantyPolicy:"Warranty policy"};var M=r({accepted:false,acceptedAt:null,locked:false,showError:false}),W=M.reset,Y=M.state;e({p:W,G:Y});
60
+ var Y={privacyPolicy:"Privacy policy",refundPolicy:"Refund policy",shippingPolicy:"Shipping policy",termsAndConditions:"Terms and conditions",warrantyPolicy:"Warranty policy"};var H=r({accepted:false,acceptedAt:null,locked:false,showError:false}),K=H.reset,G=H.state;e({p:K,G:G});
61
61
  /**
62
62
  * Returns the list of policies the merchant has configured (non-empty link).
63
63
  * Policies are returned in a fixed display order so the rendered list is
@@ -68,68 +68,68 @@ var J={privacyPolicy:"Privacy policy",refundPolicy:"Refund policy",shippingPolic
68
68
  * Reads from `zonosStore.checkoutSettings` (not `window.Zonos.cartSettings`)
69
69
  * so the consent UI works when zonos-elements is consumed via the npm package,
70
70
  * where `cartSettings` is not populated.
71
- */var H=e("a2",(function(){var e=n.checkoutSettings.merchantPolicyLinks;if(!e){return[]}return q.reduce((function(r,n){var t,o;var a=(o=(t=e[n])===null||t===void 0?void 0:t.link)===null||o===void 0?void 0:o.trim();if(!a||!/^https?:\/\//i.test(a)){return r}r.push({key:n,name:i(J[n]),url:a});return r}),[])}));var K=e("y",(function(){return H().length>0}));
71
+ */var V=e("a2",(function(){var e=n.checkoutSettings.merchantPolicyLinks;if(!e){return[]}return W.reduce((function(r,n){var t,o;var a=(o=(t=e[n])===null||t===void 0?void 0:t.link)===null||o===void 0?void 0:o.trim();if(!a||!/^https?:\/\//i.test(a)){return r}r.push({key:n,name:i(Y[n]),url:a});return r}),[])}));var Z=e("y",(function(){return V().length>0}));
72
72
  /**
73
73
  * Checks if the tax ID input should be rendered based on the company name and country code.
74
- */var V=function(e){var r=e.companyName,n=e.countryCode,t=e.shouldRequirePeruTaxId;if(l({countryCode:n,shouldRequirePeruTaxId:t})){return true}
74
+ */var Q=function(e){var r=e.companyName,n=e.countryCode,t=e.shouldRequirePeruTaxId;if(l({countryCode:n,shouldRequirePeruTaxId:t})){return true}
75
75
  // Only show the tax ID input if the country is in the EU and the company name is provided
76
76
  if(v.includes(n)){return r.trim().length>0}
77
77
  // If country require tax id, show the input
78
78
  return f(n)};
79
- /** Whether the field is showing, and which of this country's types is selected. */var G=e("V",(function(e){var r=e.companyName,n=e.countryCode,t=e.shouldRequirePeruTaxId,o=e.taxIdType;var i;var a=c({countryCode:n,shouldRequirePeruTaxId:t});var s=(i=a===null||a===void 0?void 0:a.find((function(e){return e.value===o})))!==null&&i!==void 0?i:null;var u=V({companyName:r,countryCode:n,shouldRequirePeruTaxId:t});return{rendered:u,selectedType:s,
79
+ /** Whether the field is showing, and which of this country's types is selected. */var X=e("V",(function(e){var r=e.companyName,n=e.countryCode,t=e.shouldRequirePeruTaxId,o=e.taxIdType;var i;var a=c({countryCode:n,shouldRequirePeruTaxId:t});var s=(i=a===null||a===void 0?void 0:a.find((function(e){return e.value===o})))!==null&&i!==void 0?i:null;var u=Q({companyName:r,countryCode:n,shouldRequirePeruTaxId:t});return{rendered:u,selectedType:s,
80
80
  // A multi-type country sends a number only after the shopper picks a type.
81
81
  send:u&&(!a||!!s),typeOptions:a}}));
82
- /** Tax id to send for the destination, or null while the field is hidden. */var Z=function(e){var r=G({companyName:we.companyName,countryCode:e,shouldRequirePeruTaxId:t(),taxIdType:we.taxIdType}),n=r.selectedType,o=r.send;if(!o){return null}return Object.assign({taxId:we.taxId},n?{taxIdType:n.value}:{})};
82
+ /** Tax id to send for the destination, or null while the field is hidden. */var $=function(e){var r=X({companyName:_e.companyName,countryCode:e,shouldRequirePeruTaxId:t(),taxIdType:_e.taxIdType}),n=r.selectedType,o=r.send;if(!o){return null}return Object.assign({taxId:_e.taxId},n?{taxIdType:n.value}:{})};
83
83
  /**
84
84
  * Extract first name and last name from the name string
85
85
  * If first name and last name are provided, use them
86
86
  * If name is provided, extract and return the first and last name from the name string
87
87
  * If neither are provided, return an empty object
88
- */var Q=e("U",(function(e){var r=e.firstName,n=e.lastName,t=e.name;var o;if(!t&&!r&&!n){return{firstName:"",lastName:""}}
88
+ */var ee=e("U",(function(e){var r=e.firstName,n=e.lastName,t=e.name;var o;if(!t&&!r&&!n){return{firstName:"",lastName:""}}
89
89
  // Use first name and last name if they are provided
90
- var i=(t===null||t===void 0?void 0:t.split(/\s+/))||[];var a=(r===null||r===void 0?void 0:r.trim())||((o=i[0])===null||o===void 0?void 0:o.trim())||"";var s=(n===null||n===void 0?void 0:n.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}}));var X=function(e){var r=Z(e);if(!r){return{}}return Object.assign({shipToTaxId:r.taxId},r.taxIdType?{shipToTaxIdType:r.taxIdType}:{})};
90
+ var i=(t===null||t===void 0?void 0:t.split(/\s+/))||[];var a=(r===null||r===void 0?void 0:r.trim())||((o=i[0])===null||o===void 0?void 0:o.trim())||"";var s=(n===null||n===void 0?void 0:n.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}}));var re=function(e){var r=$(e);if(!r){return{}}return Object.assign({shipToTaxId:r.taxId},r.taxIdType?{shipToTaxIdType:r.taxIdType}:{})};
91
91
  /**
92
92
  * Extract value from translated object
93
- */var $=function(e){var r=e.currentAddress,n=e.translatedAddress;var t,o,i,a,s,u;var d=r.value.address,l=d.city,c=d.country,v=d.line1,f=d.line2,p=d.postal_code,m=d.state;var h=r.value.name||[r.value.firstName,r.value.lastName].join(" ");return{city:((t=n.city)===null||t===void 0?void 0:t[l])||l,country:c,line1:((o=n.line1)===null||o===void 0?void 0:o[v])||v,line2:((i=n.line2)===null||i===void 0?void 0:i[f||""])||f||"",name:((a=n.name)===null||a===void 0?void 0:a[h])||h,phone:r.value.phone||"",postal_code:((s=n.postal_code)===null||s===void 0?void 0:s[p])||p,state:((u=n.state)===null||u===void 0?void 0:u[m])||m}};
93
+ */var ne=function(e){var r=e.currentAddress,n=e.translatedAddress;var t,o,i,a,s,u;var d=r.value.address,l=d.city,c=d.country,v=d.line1,f=d.line2,p=d.postal_code,m=d.state;var h=r.value.name||[r.value.firstName,r.value.lastName].join(" ");return{city:((t=n.city)===null||t===void 0?void 0:t[l])||l,country:c,line1:((o=n.line1)===null||o===void 0?void 0:o[v])||v,line2:((i=n.line2)===null||i===void 0?void 0:i[f||""])||f||"",name:((a=n.name)===null||a===void 0?void 0:a[h])||h,phone:r.value.phone||"",postal_code:((s=n.postal_code)===null||s===void 0?void 0:s[p])||p,state:((u=n.state)===null||u===void 0?void 0:u[m])||m}};
94
94
  /**
95
95
  * Similar to prepCalculateLandedCost except it only uses cart ID
96
- */var ee=function(e){var r;var n=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";
96
+ */var te=function(e){var r;var n=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";
97
97
  // maybe we don't need email now for prefetch the landed cost
98
- var t=we.stripeLinkEventData;var i=we.stripeAddressEventData;var s=we.stripeShippingSameAsBilling?we.stripeAddressEventData:we.stripeBillingAddressEventData;if(!i||!s){throw new Error("Missing stripe address data")}
98
+ var t=_e.stripeLinkEventData;var i=_e.stripeAddressEventData;var s=_e.stripeShippingSameAsBilling?_e.stripeAddressEventData:_e.stripeBillingAddressEventData;if(!i||!s){throw new Error("Missing stripe address data")}
99
99
  // Attempt to get translated address if available
100
- var u=$({currentAddress:i,translatedAddress:we.translatedAddress.address});var d=Q({name:u.name}),l=d.firstName,c=d.lastName;var v=$({currentAddress:s,translatedAddress:we.translatedAddress.address});var f=Q({name:v.name}),p=f.firstName,m=f.lastName;var h=a()||"US";var y=X(u.country);return Object.assign(Object.assign({billingAddress:{addressLine1:v.line1,addressLine2:v.line2||"",city:v.city,country:v.country,postalCode:v.postal_code,state:v.state},billingContact:{
100
+ var u=ne({currentAddress:i,translatedAddress:_e.translatedAddress.address});var d=ee({name:u.name}),l=d.firstName,c=d.lastName;var v=ne({currentAddress:s,translatedAddress:_e.translatedAddress.address});var f=ee({name:v.name}),p=f.firstName,m=f.lastName;var h=a()||"US";var y=re(u.country);return Object.assign(Object.assign({billingAddress:{addressLine1:v.line1,addressLine2:v.line2||"",city:v.city,country:v.country,postalCode:v.postal_code,state:v.state},billingContact:{
101
101
  // firstName and lastName should be valid now since stripe only mark
102
102
  // the address as complete when both fields are filled.
103
103
  firstName:p,lastName:m,phone:v.phone},
104
104
  // Use the first item's currency code
105
- cartCurrencyCode:(r=or.items[0])===null||r===void 0?void 0:r.currencyCode,cartId:e,checkoutSessionCountry:h,checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:we.companyName,email:t===null||t===void 0?void 0:t.value.email,
105
+ cartCurrencyCode:(r=sr.items[0])===null||r===void 0?void 0:r.currencyCode,cartId:e,checkoutSessionCountry:h,checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:_e.companyName,email:t===null||t===void 0?void 0:t.value.email,
106
106
  // firstName and lastName should be valid now since stripe only mark
107
107
  // the address as complete when both fields are filled.
108
- firstName:l,lastName:c,phone:u.phone},isTest:!!n,landedCostAdjustments:or.promoCode?[{amount:0,productId:null,promoCode:or.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:we.shortAddressCode},y),{shippingAddress:{addressLine1:u.line1,addressLine2:u.line2,city:u.city,country:u.country,postalCode:u.postal_code,state:u.state}})};var re=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";
108
+ firstName:l,lastName:c,phone:u.phone},isTest:!!n,landedCostAdjustments:sr.promoCode?[{amount:0,productId:null,promoCode:sr.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:_e.shortAddressCode},y),{shippingAddress:{addressLine1:u.line1,addressLine2:u.line2,city:u.city,country:u.country,postalCode:u.postal_code,state:u.state}})};var oe=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";
109
109
  // maybe we don't need email now for prefetch the landed cost
110
- var r=we.stripeLinkEventData;var n=we.stripeAddressEventData;var t=we.stripeShippingSameAsBilling?we.stripeAddressEventData:we.stripeBillingAddressEventData;p({stripeAddressData:n,stripeBillingAddressData:t},"info");if(!n||!t){throw new Error("Missing stripe address data")}
110
+ var r=_e.stripeLinkEventData;var n=_e.stripeAddressEventData;var t=_e.stripeShippingSameAsBilling?_e.stripeAddressEventData:_e.stripeBillingAddressEventData;p({stripeAddressData:n,stripeBillingAddressData:t},"info");if(!n||!t){throw new Error("Missing stripe address data")}
111
111
  // Attempt to get translated address if available
112
- var i=$({currentAddress:n,translatedAddress:we.translatedAddress.address});var a=Q({name:i.name}),s=a.firstName,u=a.lastName;var d=$({currentAddress:t,translatedAddress:we.translatedAddress.address});var l=Q({name:d.name}),c=l.firstName,v=l.lastName;var f=or.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var m=or.promoCode?__spreadArray([{amount:0,productId:null,promoCode:or.promoCode,sku:null,type:"PROMO_CODE"}],f,true):f;var h=X(i.country);return Object.assign(Object.assign({billingAddress:{addressLine1:d.line1,addressLine2:d.line2||"",city:d.city,country:d.country,postalCode:d.postal_code,state:d.state},billingContact:{
112
+ var i=ne({currentAddress:n,translatedAddress:_e.translatedAddress.address});var a=ee({name:i.name}),s=a.firstName,u=a.lastName;var d=ne({currentAddress:t,translatedAddress:_e.translatedAddress.address});var l=ee({name:d.name}),c=l.firstName,v=l.lastName;var f=sr.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var m=sr.promoCode?__spreadArray([{amount:0,productId:null,promoCode:sr.promoCode,sku:null,type:"PROMO_CODE"}],f,true):f;var h=re(i.country);return Object.assign(Object.assign({billingAddress:{addressLine1:d.line1,addressLine2:d.line2||"",city:d.city,country:d.country,postalCode:d.postal_code,state:d.state},billingContact:{
113
113
  // firstName and lastName should be valid now since stripe only mark
114
114
  // the address as complete when both fields are filled.
115
- firstName:c,lastName:v,phone:d.phone},checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:we.companyName,email:r===null||r===void 0?void 0:r.value.email,
115
+ firstName:c,lastName:v,phone:d.phone},checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:_e.companyName,email:r===null||r===void 0?void 0:r.value.email,
116
116
  // firstName and lastName should be valid now since stripe only mark
117
117
  // the address as complete when both fields are filled.
118
- firstName:s,lastName:u,phone:i.phone},isTest:e,items:or.items,landedCostAdjustments:m,shipToShortAddressCode:we.shortAddressCode},h),{shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}})};var ne=function(e){return __awaiter(C,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l;return __generator(this,(function(c){switch(c.label){case 0:a=re();return[4/*yield*/,e({billingAddress:a.billingAddress,billingContact:a.billingContact,checkoutSessionId:a.checkoutSessionId,contact:a.contact,landedCostAdjustments:a.landedCostAdjustments,
118
+ firstName:s,lastName:u,phone:i.phone},isTest:e,items:sr.items,landedCostAdjustments:m,shipToShortAddressCode:_e.shortAddressCode},h),{shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}})};var ie=function(e){return __awaiter(T,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l;return __generator(this,(function(c){switch(c.label){case 0:a=oe();return[4/*yield*/,e({billingAddress:a.billingAddress,billingContact:a.billingContact,checkoutSessionId:a.checkoutSessionId,contact:a.contact,landedCostAdjustments:a.landedCostAdjustments,
119
119
  // zonosApiKey should always be available
120
- publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:a.shippingAddress,zonosApiRoute:w["vercel"]},{promoCode:or.promoCode})];case 1:s=c.sent();if(!s||
120
+ publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:a.shippingAddress,zonosApiRoute:w["vercel"]},{promoCode:sr.promoCode})];case 1:s=c.sent();if(!s||
121
121
  // Only show errors if there are no rate back (checkoutSessionWorkflow) and there are errors
122
- !((r=s.checkoutSessionWorkflow)===null||r===void 0?void 0:r.length)&&((n=s.errors)===null||n===void 0?void 0:n.length)){throw new Error("Failed to build landed cost: ".concat(((o=(t=s===null||s===void 0?void 0:s.errors)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.message)||"Unknown error"))}return[4/*yield*/,h("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:u=c.sent(),d=u.errors,l=u.json;if(!l||d.length){throw new Error("Invalid landed cost object: ".concat(((i=d.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2/*return*/,s]}}))}))};var te=function(e){return __awaiter(C,void 0,void 0,(function(){var r,t,o,i,a,s,u;return __generator(this,(function(d){switch(d.label){case 0:t=n.checkoutSettings.buildLandedCost;if(!t)return[3/*break*/,2];return[4/*yield*/,ne(t)];case 1:o=d.sent();return[2/*return*/,o];case 2:return[4/*yield*/,h("/api/zonos-elements/calculate-landed-cost",{body:re(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:i=d.sent(),a=i.errors,s=i.json;if(a.length||!s){u=((r=a[0])===null||r===void 0?void 0:r.message)==="The user aborted a request.";if(u){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}
122
+ !((r=s.checkoutSessionWorkflow)===null||r===void 0?void 0:r.length)&&((n=s.errors)===null||n===void 0?void 0:n.length)){throw new Error("Failed to build landed cost: ".concat(((o=(t=s===null||s===void 0?void 0:s.errors)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.message)||"Unknown error"))}return[4/*yield*/,h("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:u=c.sent(),d=u.errors,l=u.json;if(!l||d.length){throw new Error("Invalid landed cost object: ".concat(((i=d.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2/*return*/,s]}}))}))};var ae=function(e){return __awaiter(T,void 0,void 0,(function(){var r,t,o,i,a,s,u;return __generator(this,(function(d){switch(d.label){case 0:t=n.checkoutSettings.buildLandedCost;if(!t)return[3/*break*/,2];return[4/*yield*/,ie(t)];case 1:o=d.sent();return[2/*return*/,o];case 2:return[4/*yield*/,h("/api/zonos-elements/calculate-landed-cost",{body:oe(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:i=d.sent(),a=i.errors,s=i.json;if(a.length||!s){u=((r=a[0])===null||r===void 0?void 0:r.message)==="The user aborted a request.";if(u){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}
123
123
  // We want to show any successful quotes even if there are errors
124
124
  a.forEach((function(e){
125
125
  // eslint-disable-next-line no-console
126
- console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2/*return*/,s]}return[2/*return*/,s]}}))}))};var oe=function(e){return __awaiter(C,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l;var c=e.abortController,v=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4/*yield*/,h("/api/zonos-elements/cart-calculate-landed-cost",{body:ee(v),method:"POST",signal:c===null||c===void 0?void 0:c.signal})];case 1:a=e.sent(),s=a.errors,u=a.json;if(s.length||!u){d=typeof((r=s[0])===null||r===void 0?void 0:r.message)==="string"&&(((n=s[0])===null||n===void 0?void 0:n.message)==="The user aborted a request."||((t=s[0])===null||t===void 0?void 0:t.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")));l=d?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(l)}return[2/*return*/,u]}}))}))};var ie=undefined&&undefined.__rest||function(e,r){var n={};for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0)n[t]=e[t];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++){if(r.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o]))n[t[o]]=e[t[o]]}return n};var ae=function(e){return __awaiter(C,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:r=window.Zonos.cartId;if(!!r)return[3/*break*/,2];return[4/*yield*/,te(e)];case 1:n=a.sent();return[2/*return*/,n];case 2:return[4/*yield*/,oe({abortController:e,cartId:r})];case 3:t=a.sent(),o=t.cartWorkflow,i=ie(t,["cartWorkflow"]);return[2/*return*/,Object.assign(Object.assign({},i),{itemCreateWorkflow:o.items})]}}))}))};var se=e("t",(function(e){return __awaiter(C,[e],void 0,(function(e){var r,t,o,i,a,u,d,l,c;var v=e.checkoutSessionId,f=e.eventName,p=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:o=Date.now();i=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:v,eventCreated:o,eventName:f});a=
126
+ console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2/*return*/,s]}return[2/*return*/,s]}}))}))};var se=function(e){return __awaiter(T,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l;var c=e.abortController,v=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4/*yield*/,h("/api/zonos-elements/cart-calculate-landed-cost",{body:te(v),method:"POST",signal:c===null||c===void 0?void 0:c.signal})];case 1:a=e.sent(),s=a.errors,u=a.json;if(s.length||!u){d=typeof((r=s[0])===null||r===void 0?void 0:r.message)==="string"&&(((n=s[0])===null||n===void 0?void 0:n.message)==="The user aborted a request."||((t=s[0])===null||t===void 0?void 0:t.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")));l=d?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(l)}return[2/*return*/,u]}}))}))};var ue=undefined&&undefined.__rest||function(e,r){var n={};for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0)n[t]=e[t];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++){if(r.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o]))n[t[o]]=e[t[o]]}return n};var de=function(e){return __awaiter(T,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:r=window.Zonos.cartId;if(!!r)return[3/*break*/,2];return[4/*yield*/,ae(e)];case 1:n=a.sent();return[2/*return*/,n];case 2:return[4/*yield*/,se({abortController:e,cartId:r})];case 3:t=a.sent(),o=t.cartWorkflow,i=ue(t,["cartWorkflow"]);return[2/*return*/,Object.assign(Object.assign({},i),{itemCreateWorkflow:o.items})]}}))}))};var le=e("t",(function(e){return __awaiter(T,[e],void 0,(function(e){var r,t,o,i,a,u,d,l,c;var v=e.checkoutSessionId,f=e.eventName,p=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:o=Date.now();i=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:v,eventCreated:o,eventName:f});a=
127
127
  // if the url includes zonos.com and not hosted checkout (checkout.zonos.com), it means we are on the development site (dashboard, preview zonos domain or main zonos.com)
128
128
  window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!((r=window.Zonos)===null||r===void 0?void 0:r.zonosQaUrl)||!!((t=window.Zonos)===null||t===void 0?void 0:t.debug);u=g()||b();if((u||a)&&
129
129
  // if found, it means we want to test the conversion event in development site, or test mode and staging mode
130
- !window.Zonos.zonosConversionTest){return[2/*return*/]}d=s.selectedCountryCode;l=n.organizationId;if(!v){void S({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(f,'" - No checkout session id found')],metadata:{allLogs:m,checkoutSessionId:v,eventName:f,metadata:p,organizationId:l,trackEventLogs:i}});
130
+ !window.Zonos.zonosConversionTest){return[2/*return*/]}d=s.selectedCountryCode;l=n.organizationId;if(!v){void _({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(f,'" - No checkout session id found')],metadata:{allLogs:m,checkoutSessionId:v,eventName:f,metadata:p,organizationId:l,trackEventLogs:i}});
131
131
  // checkoutSessionId is required for tracking conversion events to work properly
132
- return[2/*return*/]}if(!l){void S({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(f,'" - No organization id found')],metadata:{allLogs:m,checkoutSessionId:v,eventName:f,metadata:p,organizationId:l,trackEventLogs:i}})}c={checkoutSessionId:v,countryCode:d,eventCreated:o,eventName:f,metadata:Object.assign(Object.assign({},p),{trackEventLogs:i}),organizationId:l};return[4/*yield*/,h("/api/zonos-elements/track-conversion-event",{body:c,method:"POST"})];case 1:e.sent();return[2/*return*/]}}))}))}));
132
+ return[2/*return*/]}if(!l){void _({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(f,'" - No organization id found')],metadata:{allLogs:m,checkoutSessionId:v,eventName:f,metadata:p,organizationId:l,trackEventLogs:i}})}c={checkoutSessionId:v,countryCode:d,eventCreated:o,eventName:f,metadata:Object.assign(Object.assign({},p),{trackEventLogs:i}),organizationId:l};return[4/*yield*/,h("/api/zonos-elements/track-conversion-event",{body:c,method:"POST"})];case 1:e.sent();return[2/*return*/]}}))}))}));
133
133
  /**
134
134
  * This function generates an object that contains the fields of an address that have invalid characters.
135
135
  *
@@ -138,7 +138,7 @@ return[2/*return*/]}if(!l){void S({endpoint:"trackConversionEventMetric",errors:
138
138
  * @param {ReturnType<typeof containsNonLatinChars> | null} params.invalidAdddressList - The list of address fields that contain invalid characters.
139
139
  *
140
140
  * @returns {Partial<Address> | undefined} - An object that contains the fields of the address that have invalid characters. If no fields have invalid characters, the function returns undefined.
141
- */var ue=function(e){var r=e.address,n=e.invalidAdddressList;if(!r){return}
141
+ */var ce=function(e){var r=e.address,n=e.invalidAdddressList;if(!r){return}
142
142
  // if there are no invalid characters, return an empty object
143
143
  if(!n){return}var t={};if(n.city){t.city=r.city}if(n.line1){t.line1=r.line1}if(n.line2){t.line2=r.line2}if(n.postal_code){t.postal_code=r.postal_code}if(n.state){t.state=r.state}if(n.name){t.name=r.name}
144
144
  // return null if there are no fields to exclude
@@ -156,136 +156,136 @@ return Object.keys(t).length?t:undefined};
156
156
  * @param {boolean} params.stripeShippingSameAsBilling - A flag indicating whether the shipping address is the same as the billing address.
157
157
  *
158
158
  * @returns {ValidateAddressRequest | null} - An object that contains the address fields that have invalid characters, the destination country, and the first and last name. If the conditions are not met, the function returns null.
159
- */var de=function(e){var r=e.addressInvalidCharactersList,n=e.billingAddressInvalidCharactersList,t=e.stripeAddressEventData,o=e.stripeBillingAddressEventData,i=e.stripeShippingSameAsBilling;var a=!!(t===null||t===void 0?void 0:t.complete);var s=i?a:!!(o===null||o===void 0?void 0:o.complete);
159
+ */var ve=function(e){var r=e.addressInvalidCharactersList,n=e.billingAddressInvalidCharactersList,t=e.stripeAddressEventData,o=e.stripeBillingAddressEventData,i=e.stripeShippingSameAsBilling;var a=!!(t===null||t===void 0?void 0:t.complete);var s=i?a:!!(o===null||o===void 0?void 0:o.complete);
160
160
  // only translate if both address and billing address are ready
161
161
  if(!a||!s){return null}
162
162
  // only translate if there are invalid characters
163
163
  if(!r&&!n){return null}var u=t.value;var d=(o===null||o===void 0?void 0:o.value)||null;
164
164
  // Returns undefined if the name is Latin so it won't be included in the request body
165
- var l=Q({firstName:u.firstName,lastName:u.lastName,name:u.name}),c=l.firstName,v=l.lastName;var f="".concat(c," ").concat(v);var p=Q({firstName:d===null||d===void 0?void 0:d.firstName,lastName:d===null||d===void 0?void 0:d.lastName,name:(d===null||d===void 0?void 0:d.name)||""}),m=p.firstName,h=p.lastName;var y=m&&h?"".concat(m," ").concat(h):"";var w=u.address;var g=d===null||d===void 0?void 0:d.address;return{address:ue({address:Object.assign(Object.assign({},w),{name:f}),invalidAdddressList:r}),
165
+ var l=ee({firstName:u.firstName,lastName:u.lastName,name:u.name}),c=l.firstName,v=l.lastName;var f="".concat(c," ").concat(v);var p=ee({firstName:d===null||d===void 0?void 0:d.firstName,lastName:d===null||d===void 0?void 0:d.lastName,name:(d===null||d===void 0?void 0:d.name)||""}),m=p.firstName,h=p.lastName;var y=m&&h?"".concat(m," ").concat(h):"";var w=u.address;var g=d===null||d===void 0?void 0:d.address;return{address:ce({address:Object.assign(Object.assign({},w),{name:f}),invalidAdddressList:r}),
166
166
  // only include billing address if it's different from the shipping address
167
- billingAddress:!i?ue({address:g?Object.assign(Object.assign({},g),{name:y}):null,invalidAdddressList:n}):undefined,destinationCountry:w.country}};
167
+ billingAddress:!i?ce({address:g?Object.assign(Object.assign({},g),{name:y}):null,invalidAdddressList:n}):undefined,destinationCountry:w.country}};
168
168
  /**
169
169
  * Sorts service levels with lower cost first
170
- */var le=e("a0",(function(e){var r=e.sort((function(e,r){return e.amount-r.amount}));return r}));
170
+ */var fe=e("a0",(function(e){var r=e.sort((function(e,r){return e.amount-r.amount}));return r}));
171
171
  /**
172
172
  * Validate checkout session before confirming payment
173
- */var ce=e("C",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r,n,t,o,a;return __generator(this,(function(s){switch(s.label){case 0:return[4/*yield*/,k()];case 1:n=s.sent(),t=n.errors,o=n.json;if(t.length||!o){y("Failed to retrieve checkout session info before confirming payment ",t);void S({endpoint:"validateCheckoutSession",errors:t.map((function(e){return e.message})),metadata:{allLogs:m}});return[2/*return*/,{errorMessage:i("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}a=!!(((e=o.checkoutSession.order)===null||e===void 0?void 0:e.id)&&!o.checkoutSession.completedAt);if(!a&&!((r=o.checkoutSession.landedCost)===null||r===void 0?void 0:r.id)){y("Landed cost is not found in the checkout session before confirming payment.");void S({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:m}});return[2/*return*/,{errorMessage:i('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:false}]}return[2/*return*/,{errorMessage:"",valid:true}]}}))}))}));var ve=function(e){var r=e.theme;var t={".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,
173
+ */var pe=e("C",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,o,a;return __generator(this,(function(s){switch(s.label){case 0:return[4/*yield*/,P()];case 1:n=s.sent(),t=n.errors,o=n.json;if(t.length||!o){y("Failed to retrieve checkout session info before confirming payment ",t);void _({endpoint:"validateCheckoutSession",errors:t.map((function(e){return e.message})),metadata:{allLogs:m}});return[2/*return*/,{errorMessage:i("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}a=!!(((e=o.checkoutSession.order)===null||e===void 0?void 0:e.id)&&!o.checkoutSession.completedAt);if(!a&&!((r=o.checkoutSession.landedCost)===null||r===void 0?void 0:r.id)){y("Landed cost is not found in the checkout session before confirming payment.");void _({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:m}});return[2/*return*/,{errorMessage:i('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:false}]}return[2/*return*/,{errorMessage:"",valid:true}]}}))}))}));var me=function(e){var r=e.theme;var t={".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,
174
174
  // need to reset everything and the paddingTop to default, otherwise the paddingTop will not be updated.
175
175
  padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",
176
176
  // any value here will be add up to the default paddingTop (20px).
177
- 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(r){case"DARK":{return Object.assign(Object.assign({},t),{".Action":Object.assign(Object.assign({},t[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},t[".PickerItem--new"]),{color:"white"})})}default:return t}};var fe=function(e){var r=e.borderStyle,n=e.theme;switch(n){case"DARK":return{borderRadius:A({overrideBorderStyle:r}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:A({overrideBorderStyle:r}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var pe={Airwallex:"AIRWALLEX",Paypal:"PAYPAL",Stripe:"STRIPE"};var me=r((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,shortAddressCode:"",shouldInventoryRefund:false,shouldRenderPayInUsdButton:false,
177
+ 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(r){case"DARK":{return Object.assign(Object.assign({},t),{".Action":Object.assign(Object.assign({},t[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},t[".PickerItem--new"]),{color:"white"})})}default:return t}};var he=function(e){var r=e.borderStyle,n=e.theme;switch(n){case"DARK":return{borderRadius:I({overrideBorderStyle:r}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:I({overrideBorderStyle:r}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var ye={Airwallex:"AIRWALLEX",Paypal:"PAYPAL",Stripe:"STRIPE"};var we=r((function(){return{checkoutSettlementCurrency:"USD",clientSecret:S("session","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,shortAddressCode:"",shouldInventoryRefund:false,shouldRenderPayInUsdButton:false,
178
178
  /**
179
179
  * Default to skip payment intent, only create payment intent when "skipPaymentIntent" in url's query params is set "0"
180
180
  * @default true
181
181
  */
182
- 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:"",taxIdType:"",taxIdTypeUsedWhenAsyncAddressUpdate:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}})),he=me.onChange,ye=me.reset,we=me.state;e({J:he,b:we});var ge=function(e){var r=e.clientSecret,t=e.overrideBorderRadius,o=e.overridePrimaryColor,i=e.overrideSecondaryColor,a=e.overrideTheme,u=e.paypalEnabled;var d=o||n.appearance.colorPrimary;var l=i||n.appearance.colorSecondary;var c=window.Zonos.isCollect||window.Zonos.isInvoice?n.appearance.theme==="DARK":d&&O(d);var v=c?"night":"flat";
182
+ 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:"",taxIdType:"",taxIdTypeUsedWhenAsyncAddressUpdate:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}})),ge=we.onChange,be=we.reset,_e=we.state;e({J:ge,b:_e});var Se=function(e){var r=e.clientSecret,t=e.overrideBorderRadius,o=e.overridePrimaryColor,i=e.overrideSecondaryColor,a=e.overrideTheme,u=e.paypalEnabled;var d=o||n.appearance.colorPrimary;var l=i||n.appearance.colorSecondary;var c=window.Zonos.isCollect||window.Zonos.isInvoice?n.appearance.theme==="DARK":d&&k(d);var v=c?"night":"flat";
183
183
  // if overrideTheme is provided, use it. Otherwise, use theme based on primary color
184
184
  var f=a==="DARK"?"night":"flat";var p=u?["external_paypal"]:[];
185
185
  // If client secret is Stripe format, use it
186
- var m=(r===null||r===void 0?void 0:r.includes("_secret_"))?r:undefined;return{appearance:{labels:"floating",rules:Object.assign({},ve({theme:a||"LIGHT"})),
186
+ var m=(r===null||r===void 0?void 0:r.includes("_secret_"))?r:undefined;return{appearance:{labels:"floating",rules:Object.assign({},me({theme:a||"LIGHT"})),
187
187
  // get contrast theme color base on primary color
188
- theme:a?f:v,variables:Object.assign(Object.assign({},fe({borderStyle:t,theme:"LIGHT"})),{
188
+ theme:a?f:v,variables:Object.assign(Object.assign({},he({borderStyle:t,theme:"LIGHT"})),{
189
189
  // use the button background color for input glow color
190
190
  colorPrimary:l})},
191
191
  // Client secret can be undefined since we will load other elements that doesn't require client secret first, then load client secret and render one that requires it later
192
- clientSecret:m,customerSessionClientSecret:we.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],p,true),locale:s.selectedLocale}};var be=e("u",(function(){window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")}));
192
+ clientSecret:m,customerSessionClientSecret:_e.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],p,true),locale:s.selectedLocale}};var Oe=e("u",(function(){A("session","zonos--bigcommerce-domestic-checkout-shipping")}));
193
193
  // Save shipping address to session storage
194
- var Se=e("a",(function(e){window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))}));var _e=e("s",(function(){var e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return _(e)}));var Oe=e("i",(function(e){return __awaiter(C,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){t=we.clientSecret;if(!we.stripe){p("Skip. Stripe is not initialized");return[2/*return*/]}o=ge({clientSecret:t,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(we.stripeElementsOptions);if(!we.stripeElements||!we.stripeElementsForBillingAddress){
194
+ var Ae=e("a",(function(e){O("session","zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))}));var Ce=e("s",(function(){var e=S("session","zonos--bigcommerce-domestic-checkout-shipping");return C(e)}));var ke=e("i",(function(e){return __awaiter(T,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){t=_e.clientSecret;if(!_e.stripe){p("Skip. Stripe is not initialized");return[2/*return*/]}o=Se({clientSecret:t,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(_e.stripeElementsOptions);if(!_e.stripeElements||!_e.stripeElementsForBillingAddress){
195
195
  // init stripe elements for billing address
196
- we.stripeElementsForBillingAddress=(r=we.stripe)===null||r===void 0?void 0:r.elements(o);p("Stripe elements for billing address initialized");
196
+ _e.stripeElementsForBillingAddress=(r=_e.stripe)===null||r===void 0?void 0:r.elements(o);p("Stripe elements for billing address initialized");
197
197
  // init stripe elements if it doesn't exist
198
- we.stripeElements=(n=we.stripe)===null||n===void 0?void 0:n.elements(o);
198
+ _e.stripeElements=(n=_e.stripe)===null||n===void 0?void 0:n.elements(o);
199
199
  // save stripe elements options for later comparison
200
- we.stripeElementsOptions=o;p("Stripe elements initialized");return[2/*return*/]}if(!i){
200
+ _e.stripeElementsOptions=o;p("Stripe elements initialized");return[2/*return*/]}if(!i){
201
201
  // update elements with new option if it already exists
202
- we.stripeElements.update(o);
202
+ _e.stripeElements.update(o);
203
203
  // update elements for stripe billing address
204
- we.stripeElementsForBillingAddress.update(o);
204
+ _e.stripeElementsForBillingAddress.update(o);
205
205
  // save stripe elements options for later comparison
206
- we.stripeElementsOptions=o;void we.stripeElements.fetchUpdates()}p("Stripe elements updated");return[2/*return*/]}))}))}));var Ae=e("H",(function(){
206
+ _e.stripeElementsOptions=o;void _e.stripeElements.fetchUpdates()}p("Stripe elements updated");return[2/*return*/]}))}))}));var Ie=e("H",(function(){
207
207
  // clean clientSecret so that we can start the new one.
208
- sessionStorage.removeItem("zonos--client-secret");
208
+ A("session","zonos--client-secret");
209
209
  // cleanup stripe elements
210
- ye();
210
+ be();
211
211
  // set stripe back to window.Zonos.stripe
212
- we.stripe=window.Zonos.stripe}));var Ce=function(){var e,r,n,t;var o=JSON.stringify((e=we.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=we.stripeAddressEventData)===null||r===void 0?void 0:r.value);var i=!we.stripeShippingSameAsBilling&&JSON.stringify((n=we.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=we.stripeBillingAddressUsedWhenValidatingAddress)===null||t===void 0?void 0:t.value);return o||i};var ke=function(){var e,r,n,t,o,i,a,s;
212
+ _e.stripe=window.Zonos.stripe}));var Te=function(){var e,r,n,t;var o=JSON.stringify((e=_e.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=_e.stripeAddressEventData)===null||r===void 0?void 0:r.value);var i=!_e.stripeShippingSameAsBilling&&JSON.stringify((n=_e.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=_e.stripeBillingAddressUsedWhenValidatingAddress)===null||t===void 0?void 0:t.value);return o||i};var Pe=function(){var e,r,n,t,o,i,a,s;
213
213
  /**
214
214
  * If user updates the address after prefetching the landed cost, should always create and attach
215
215
  * @caveat this will cause the scenario goes wrong after prefetching landed cost, with the current logic, it won't create party because nothing change after the prefetch happened
216
- */var u=(e=or.partiesData.find((function(e){return e.type==="DESTINATION"})))===null||e===void 0?void 0:e.id;var d=(r=or.partiesData.find((function(e){return e.type==="PAYOR"})))===null||r===void 0?void 0:r.id;
216
+ */var u=(e=sr.partiesData.find((function(e){return e.type==="DESTINATION"})))===null||e===void 0?void 0:e.id;var d=(r=sr.partiesData.find((function(e){return e.type==="PAYOR"})))===null||r===void 0?void 0:r.id;
217
217
  // If haven't prefetched landed cost, there is no need to update address async
218
218
  if(!u||!d){return false}
219
219
  // If we don't have landed cost parties data, should way
220
- if(we.partyShippingId!==u||we.partyBillingId!==d){return true}var l=JSON.stringify((n=we.stripeLinkUsedWhenFetchingLC)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=we.stripeLinkEventData)===null||t===void 0?void 0:t.value);var c=JSON.stringify((o=we.stripeAddressUsedWhenAsyncAddressUpdate)===null||o===void 0?void 0:o.value)!==JSON.stringify((i=we.stripeAddressEventData)===null||i===void 0?void 0:i.value);var v=!we.stripeShippingSameAsBilling&&JSON.stringify((a=we.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||a===void 0?void 0:a.value)!==JSON.stringify((s=we.stripeBillingAddressEventData)===null||s===void 0?void 0:s.value);var f=we.taxIdUsedWhenAsyncAddressUpdate!==we.taxId||we.taxIdTypeUsedWhenAsyncAddressUpdate!==we.taxIdType;var p=we.companyNameUsedWhenAsyncAddressUpdate!==we.companyName;return l||c||v||f||p};var Ie=e("a1",(function(e){var r=e.address,n=e.firstName,t=e.lastName,i=e.name,a=e.phone;var s=Q({firstName:n,lastName:t,name:i}),u=s.firstName,d=s.lastName;if(!u||!d){void S({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,firstName:n,lastName:t,name:i}})}if(!a){void S({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,phone:a}})}return{city:r.city,country:r.country,firstName:u,lastName:d,line1:r.line1,line2:r.line2,phone:a||"",postal_code:r.postal_code,state:r.state}}));var Te=e("Y",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r,n,t,i,a,s,u,d,l,c,v,f,p;return __generator(this,(function(w){switch(w.label){case 0:if(!((e=we.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!we.stripeShippingSameAsBilling&&!((r=we.stripeBillingAddressEventData)===null||r===void 0?void 0:r.complete)||!we.stripeBillingAddressEventData){return[2/*return*/,{partiesCreated:false}]}
220
+ if(_e.partyShippingId!==u||_e.partyBillingId!==d){return true}var l=JSON.stringify((n=_e.stripeLinkUsedWhenFetchingLC)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=_e.stripeLinkEventData)===null||t===void 0?void 0:t.value);var c=JSON.stringify((o=_e.stripeAddressUsedWhenAsyncAddressUpdate)===null||o===void 0?void 0:o.value)!==JSON.stringify((i=_e.stripeAddressEventData)===null||i===void 0?void 0:i.value);var v=!_e.stripeShippingSameAsBilling&&JSON.stringify((a=_e.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||a===void 0?void 0:a.value)!==JSON.stringify((s=_e.stripeBillingAddressEventData)===null||s===void 0?void 0:s.value);var f=_e.taxIdUsedWhenAsyncAddressUpdate!==_e.taxId||_e.taxIdTypeUsedWhenAsyncAddressUpdate!==_e.taxIdType;var p=_e.companyNameUsedWhenAsyncAddressUpdate!==_e.companyName;return l||c||v||f||p};var Ee=e("a1",(function(e){var r=e.address,n=e.firstName,t=e.lastName,i=e.name,a=e.phone;var s=ee({firstName:n,lastName:t,name:i}),u=s.firstName,d=s.lastName;if(!u||!d){void _({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,firstName:n,lastName:t,name:i}})}if(!a){void _({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,phone:a}})}return{city:r.city,country:r.country,firstName:u,lastName:d,line1:r.line1,line2:r.line2,phone:a||"",postal_code:r.postal_code,state:r.state}}));var Ne=e("Y",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,i,a,s,u,d,l,c,v,f,p;return __generator(this,(function(w){switch(w.label){case 0:if(!((e=_e.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!_e.stripeShippingSameAsBilling&&!((r=_e.stripeBillingAddressEventData)===null||r===void 0?void 0:r.complete)||!_e.stripeBillingAddressEventData){return[2/*return*/,{partiesCreated:false}]}
221
221
  // If there is no landed cost data, no need to create parties
222
- if(!or.landedCostData){return[2/*return*/,{partiesCreated:false}]}a=(n=or.landedCostData.find(Boolean))===null||n===void 0?void 0:n.landedCost.rootId;if(!a){
222
+ if(!sr.landedCostData){return[2/*return*/,{partiesCreated:false}]}a=(n=sr.landedCostData.find(Boolean))===null||n===void 0?void 0:n.landedCost.rootId;if(!a){
223
223
  // do nothing if we don't have selected landed cost
224
- void S({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId}});return[2/*return*/,{partiesCreated:false}]}s=ke();if(!s){return[2/*return*/,{partiesCreated:false}]}u=Ie({address:we.stripeAddressEventData.value.address,firstName:we.stripeAddressEventData.value.firstName,lastName:we.stripeAddressEventData.value.lastName,name:we.stripeAddressEventData.value.name,phone:we.stripeAddressEventData.value.phone});d=we.stripeShippingSameAsBilling?u:Ie({address:we.stripeBillingAddressEventData.value.address,firstName:we.stripeBillingAddressEventData.value.firstName,lastName:we.stripeBillingAddressEventData.value.lastName,name:we.stripeBillingAddressEventData.value.name,phone:we.stripeBillingAddressEventData.value.phone});l=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";c=Z(u.country);return[4/*yield*/,h("/api/zonos-elements/create-parties",{body:Object.assign({address:u,billingAddress:d,companyName:we.companyName,email:((t=we.stripeLinkEventData)===null||t===void 0?void 0:t.value.email)||"",isTest:l,rootId:a,shortAddressCode:we.shortAddressCode,taxId:(i=c===null||c===void 0?void 0:c.taxId)!==null&&i!==void 0?i:""},(c===null||c===void 0?void 0:c.taxIdType)?{taxIdType:c.taxIdType}:{}),method:"POST"})];case 1:v=w.sent(),f=v.errors,p=v.json;if(f.length||!p){y("Error occurs when creating parties",JSON.stringify(f,null,2));void S({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,errors:f,json:p}});return[2/*return*/,{partiesCreated:false}]}we.companyNameUsedWhenAsyncAddressUpdate=we.companyName;we.stripeAddressUsedWhenAsyncAddressUpdate=we.stripeAddressEventData;we.stripeBillingAddressUsedWhenAsyncAddressUpdate=we.stripeBillingAddressEventData;we.taxIdTypeUsedWhenAsyncAddressUpdate=we.taxIdType;we.taxIdUsedWhenAsyncAddressUpdate=we.taxId;we.partyBillingId=p.billToPartyId;we.partyShippingId=p.shipToPartyId;
224
+ void _({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId}});return[2/*return*/,{partiesCreated:false}]}s=Pe();if(!s){return[2/*return*/,{partiesCreated:false}]}u=Ee({address:_e.stripeAddressEventData.value.address,firstName:_e.stripeAddressEventData.value.firstName,lastName:_e.stripeAddressEventData.value.lastName,name:_e.stripeAddressEventData.value.name,phone:_e.stripeAddressEventData.value.phone});d=_e.stripeShippingSameAsBilling?u:Ee({address:_e.stripeBillingAddressEventData.value.address,firstName:_e.stripeBillingAddressEventData.value.firstName,lastName:_e.stripeBillingAddressEventData.value.lastName,name:_e.stripeBillingAddressEventData.value.name,phone:_e.stripeBillingAddressEventData.value.phone});l=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";c=$(u.country);return[4/*yield*/,h("/api/zonos-elements/create-parties",{body:Object.assign({address:u,billingAddress:d,companyName:_e.companyName,email:((t=_e.stripeLinkEventData)===null||t===void 0?void 0:t.value.email)||"",isTest:l,rootId:a,shortAddressCode:_e.shortAddressCode,taxId:(i=c===null||c===void 0?void 0:c.taxId)!==null&&i!==void 0?i:""},(c===null||c===void 0?void 0:c.taxIdType)?{taxIdType:c.taxIdType}:{}),method:"POST"})];case 1:v=w.sent(),f=v.errors,p=v.json;if(f.length||!p){y("Error occurs when creating parties",JSON.stringify(f,null,2));void _({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,errors:f,json:p}});return[2/*return*/,{partiesCreated:false}]}_e.companyNameUsedWhenAsyncAddressUpdate=_e.companyName;_e.stripeAddressUsedWhenAsyncAddressUpdate=_e.stripeAddressEventData;_e.stripeBillingAddressUsedWhenAsyncAddressUpdate=_e.stripeBillingAddressEventData;_e.taxIdTypeUsedWhenAsyncAddressUpdate=_e.taxIdType;_e.taxIdUsedWhenAsyncAddressUpdate=_e.taxId;_e.partyBillingId=p.billToPartyId;_e.partyShippingId=p.shipToPartyId;
225
225
  // Update parties data with the new parties id
226
- or.partiesData=or.partiesData.map((function(e){if(e.type==="DESTINATION"&&e.id!==p.shipToPartyId){return Object.assign(Object.assign({},e),{id:p.shipToPartyId})}if(e.type==="PAYOR"&&e.id!==p.billToPartyId){return Object.assign(Object.assign({},e),{id:p.billToPartyId})}return e}));return[2/*return*/,{partiesCreated:true}]}}))}))}));
226
+ sr.partiesData=sr.partiesData.map((function(e){if(e.type==="DESTINATION"&&e.id!==p.shipToPartyId){return Object.assign(Object.assign({},e),{id:p.shipToPartyId})}if(e.type==="PAYOR"&&e.id!==p.billToPartyId){return Object.assign(Object.assign({},e),{id:p.billToPartyId})}return e}));return[2/*return*/,{partiesCreated:true}]}}))}))}));
227
227
  /**
228
228
  * Extract only the necessary address info for landed cost prefetch
229
- */var Pe=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var Ee=function(){var e,r;var n=JSON.stringify((e=we.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=we.stripeLinkEventData)===null||r===void 0?void 0:r.value);var t=we.stripeAddressEventData&&JSON.stringify(Pe(we.stripeAddressEventData.value))!==JSON.stringify(we.stripeAddressUsedWhenFetchingLC);var o=!we.stripeShippingSameAsBilling&&we.stripeBillingAddressEventData&&JSON.stringify(Pe(we.stripeBillingAddressEventData.value))!==JSON.stringify(we.stripeBillingAddressUsedWhenFetchingLC);return n||t||o};
229
+ */var je=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var De=function(){var e,r;var n=JSON.stringify((e=_e.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=_e.stripeLinkEventData)===null||r===void 0?void 0:r.value);var t=_e.stripeAddressEventData&&JSON.stringify(je(_e.stripeAddressEventData.value))!==JSON.stringify(_e.stripeAddressUsedWhenFetchingLC);var o=!_e.stripeShippingSameAsBilling&&_e.stripeBillingAddressEventData&&JSON.stringify(je(_e.stripeBillingAddressEventData.value))!==JSON.stringify(_e.stripeBillingAddressUsedWhenFetchingLC);return n||t||o};
230
230
  /**
231
231
  * Check if the address and email info used when fetching landed cost with the current email and address info are different
232
232
  * Purpose is to resend the request if the info used when fetching landed cost is different from the current info
233
- */var Ne=function(){var e;
233
+ */var Le=function(){var e;
234
234
  // Mark the landed cost is outdated since the item total amount has changed (items total didn't match with the cart subtotal)
235
- var r=or.landedCostData&&((e=or.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==or.subtotal;var n=Ee();p("isPrefetchInfoOutdated","info",{isAddressOutdated:n});
235
+ var r=sr.landedCostData&&((e=sr.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==sr.subtotal;var n=De();p("isPrefetchInfoOutdated","info",{isAddressOutdated:n});
236
236
  // if landed cost data is not available, we need to fetch it
237
- return!or.landedCostData&&!we.isFetchingLandedCost||n||r};var je=e("X",(function(e){var r,t;var o=(r=n.genericSettings)===null||r===void 0?void 0:r.countryFields;var i=(t=n.genericSettings)===null||t===void 0?void 0:t.stripeCountryFieldLabels;var a=i&&e in i?i[e]:null;var s=o&&e in o?o[e]:null;
237
+ return!sr.landedCostData&&!_e.isFetchingLandedCost||n||r};var xe=e("X",(function(e){var r,t;var o=(r=n.genericSettings)===null||r===void 0?void 0:r.countryFields;var i=(t=n.genericSettings)===null||t===void 0?void 0:t.stripeCountryFieldLabels;var a=i&&e in i?i[e]:null;var s=o&&e in o?o[e]:null;
238
238
  /**
239
239
  * If the address form is using Stripe component, use Stripe country field label if there is one, if not just use one from our countryFieldLabel data
240
240
  * stripeCountryFieldLabels is the list we collect from Stripe, and extract only country that state/zip is required and different from what we have in our countryFieldLabel data
241
- **/if(or.addressFormRenderType==="stripe"){return a||s}return s}));var De=function(){var e,r,n,t;var o=!!((e=we.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((r=we.stripeAddressEventData)===null||r===void 0?void 0:r.complete);var a=we.stripeShippingSameAsBilling?i:!!((n=we.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete);var s=((t=we.stripeAddressEventData)===null||t===void 0?void 0:t.value.address.country)||"US";var u=je(s);if(i&&a&&o){return true}
241
+ **/if(sr.addressFormRenderType==="stripe"){return a||s}return s}));var Re=function(){var e,r,n,t;var o=!!((e=_e.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((r=_e.stripeAddressEventData)===null||r===void 0?void 0:r.complete);var a=_e.stripeShippingSameAsBilling?i:!!((n=_e.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete);var s=((t=_e.stripeAddressEventData)===null||t===void 0?void 0:t.value.address.country)||"US";var u=xe(s);if(i&&a&&o){return true}
242
242
  // Only send landed cost request if the address is complete when we can't get the country field
243
- if(!u||!we.stripeAddressEventData){return i&&a&&o}var d=we.stripeAddressEventData.value.address.line1.length>0;var l=we.stripeAddressEventData.value.firstName&&we.stripeAddressEventData.value.lastName;var c=!u.stateRequired||u.stateRequired&&we.stripeAddressEventData.value.address.state.length>0;var v=!u.zipRequired||u.zipRequired&&we.stripeAddressEventData.value.address.postal_code.length>=3;var f=we.stripeAddressEventData.value.phone&&we.stripeAddressEventData.value.phone.length>0;return o&&l&&d&&c&&v&&f};var Le=function(){return __awaiter(C,void 0,void 0,(function(){var e,r,n,t,i,a,s,u,d,l,c;return __generator(this,(function(v){switch(v.label){case 0:r=new AbortController;we.fetchingLandedCostAbortController=r;
243
+ if(!u||!_e.stripeAddressEventData){return i&&a&&o}var d=_e.stripeAddressEventData.value.address.line1.length>0;var l=_e.stripeAddressEventData.value.firstName&&_e.stripeAddressEventData.value.lastName;var c=!u.stateRequired||u.stateRequired&&_e.stripeAddressEventData.value.address.state.length>0;var v=!u.zipRequired||u.zipRequired&&_e.stripeAddressEventData.value.address.postal_code.length>=3;var f=_e.stripeAddressEventData.value.phone&&_e.stripeAddressEventData.value.phone.length>0;return o&&l&&d&&c&&v&&f};var Ue=function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,i,a,s,u,d,l,c;return __generator(this,(function(v){switch(v.label){case 0:r=new AbortController;_e.fetchingLandedCostAbortController=r;
244
244
  // Reset cart items to non-restricted state and restricted item list
245
- _r();return[4/*yield*/,ae(r)];case 1:n=v.sent(),t=n.checkoutSessionWorkflow,i=n.errors,a=n.itemCreateWorkflow,s=n.landedCostCalculateWorkflow,u=n.partyCreateWorkflow,d=n.shipmentRatingCalculateWorkflow;
245
+ Cr();return[4/*yield*/,de(r)];case 1:n=v.sent(),t=n.checkoutSessionWorkflow,i=n.errors,a=n.itemCreateWorkflow,s=n.landedCostCalculateWorkflow,u=n.partyCreateWorkflow,d=n.shipmentRatingCalculateWorkflow;
246
246
  // Surface a custom "no quote" message when either a rule (ruleMessageType CUSTOM) or a country
247
247
  // constraint (source COUNTRY_CONSTRAINT) blocked shipment rating with an authored message.
248
- or.customQuotingError=((e=i===null||i===void 0?void 0:i.find((function(e){var r,n;return((r=e.extensions)===null||r===void 0?void 0:r.ruleMessageType)==="CUSTOM"||((n=e.extensions)===null||n===void 0?void 0:n.source)==="COUNTRY_CONSTRAINT"})))===null||e===void 0?void 0:e.message)||null;or.shippingData=le((d===null||d===void 0?void 0:d.filter(Boolean))||[]);
248
+ sr.customQuotingError=((e=i===null||i===void 0?void 0:i.find((function(e){var r,n;return((r=e.extensions)===null||r===void 0?void 0:r.ruleMessageType)==="CUSTOM"||((n=e.extensions)===null||n===void 0?void 0:n.source)==="COUNTRY_CONSTRAINT"})))===null||e===void 0?void 0:e.message)||null;sr.shippingData=fe((d===null||d===void 0?void 0:d.filter(Boolean))||[]);
249
249
  // check and update cart items with restrictions
250
- ur(a);
250
+ cr(a);
251
251
  // reset abort controller after we are done
252
- we.fetchingLandedCostAbortController=null;or.partiesData=(u===null||u===void 0?void 0:u.filter(Boolean))||[];
252
+ _e.fetchingLandedCostAbortController=null;sr.partiesData=(u===null||u===void 0?void 0:u.filter(Boolean))||[];
253
253
  // update cart store with landed cost info
254
- or.landedCostData=(t===null||t===void 0?void 0:t.map((function(e){var r=s===null||s===void 0?void 0:s.find((function(r){return(r===null||r===void 0?void 0:r.id)===e.landedCostId}));if(!r){return null}return Object.assign(Object.assign({},e),{landedCost:r})})).filter(Boolean))||[];l=o.checkoutSessionId;if(t===null||t===void 0?void 0:t.length){void se({checkoutSessionId:l,eventName:"checkout_quoteReceived"})}c=or.promoCodeApplied&&!or.landedCostData.find((function(e){var r;return(r=e.landedCost.appliedAdjustments)===null||r===void 0?void 0:r.find((function(e){return e.type==="PROMO_CODE"}))}));or.promoCodeError=c;
254
+ sr.landedCostData=(t===null||t===void 0?void 0:t.map((function(e){var r=s===null||s===void 0?void 0:s.find((function(r){return(r===null||r===void 0?void 0:r.id)===e.landedCostId}));if(!r){return null}return Object.assign(Object.assign({},e),{landedCost:r})})).filter(Boolean))||[];l=o.checkoutSessionId;if(t===null||t===void 0?void 0:t.length){void le({checkoutSessionId:l,eventName:"checkout_quoteReceived"})}c=sr.promoCodeApplied&&!sr.landedCostData.find((function(e){var r;return(r=e.landedCost.appliedAdjustments)===null||r===void 0?void 0:r.find((function(e){return e.type==="PROMO_CODE"}))}));sr.promoCodeError=c;
255
255
  // When promocode is valid, set promoCode to session storage so if user close the modal, we can still reapply for them
256
- if(!c){sessionStorage.setItem("zonos--promo-code",or.promoCode)}return[2/*return*/]}}))}))};var xe=e("w",(function(e){return __awaiter(C,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l,c,v,f,p;return __generator(this,(function(m){switch(m.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=Ne();u=De();
256
+ if(!c){O("session","zonos--promo-code",sr.promoCode)}return[2/*return*/]}}))}))};var ze=e("w",(function(e){return __awaiter(T,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l,c,v,f,p;return __generator(this,(function(m){switch(m.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=Le();u=Re();
257
257
  // Should not do anything if the address is not ready to request landed cost
258
258
  if(!u){return[2/*return*/,{isRequestNotReady:true}]}if(s){
259
259
  // if the info used when fetching landed cost is different from the current info, abort the previous request
260
- (r=we.fetchingLandedCostAbortController)===null||r===void 0?void 0:r.abort();we.fetchingLandedCostAbortController=null}
260
+ (r=_e.fetchingLandedCostAbortController)===null||r===void 0?void 0:r.abort();_e.fetchingLandedCostAbortController=null}
261
261
  // Do not fetch if we are not ready or data is not outdated
262
262
  if(!s&&!a){return[2/*return*/,{isRequestNotReady:false}]}
263
263
  // If there is retries, stop loading for a moment and then showing the spinner again (this is just so customer can see that checkout is doing something and not stuck)
264
- if(i){we.isFetchingLandedCost=false;setTimeout((function(){we.isFetchingLandedCost=true}),300)}else{we.isFetchingLandedCost=true}if(we.stripeAddressEventData){we.stripeAddressUsedWhenFetchingLC={countryCode:we.stripeAddressEventData.value.address.country,postalCode:we.stripeAddressEventData.value.address.postal_code,state:we.stripeAddressEventData.value.address.state}}if(we.stripeBillingAddressEventData){we.stripeBillingAddressUsedWhenFetchingLC={countryCode:we.stripeBillingAddressEventData.value.address.country,postalCode:we.stripeBillingAddressEventData.value.address.postal_code,state:we.stripeBillingAddressEventData.value.address.state}}if(we.stripeLinkEventData){we.stripeLinkUsedWhenFetchingLC=Object.assign({},we.stripeLinkEventData)}m.label=1;case 1:m.trys.push([1,3,,7]);
264
+ if(i){_e.isFetchingLandedCost=false;setTimeout((function(){_e.isFetchingLandedCost=true}),300)}else{_e.isFetchingLandedCost=true}if(_e.stripeAddressEventData){_e.stripeAddressUsedWhenFetchingLC={countryCode:_e.stripeAddressEventData.value.address.country,postalCode:_e.stripeAddressEventData.value.address.postal_code,state:_e.stripeAddressEventData.value.address.state}}if(_e.stripeBillingAddressEventData){_e.stripeBillingAddressUsedWhenFetchingLC={countryCode:_e.stripeBillingAddressEventData.value.address.country,postalCode:_e.stripeBillingAddressEventData.value.address.postal_code,state:_e.stripeBillingAddressEventData.value.address.state}}if(_e.stripeLinkEventData){_e.stripeLinkUsedWhenFetchingLC=Object.assign({},_e.stripeLinkEventData)}m.label=1;case 1:m.trys.push([1,3,,7]);
265
265
  // Reset cart items to non-restricted state and restricted item list
266
- _r();
266
+ Cr();
267
267
  // fetch and apply landed cost
268
- return[4/*yield*/,Le()];case 2:
268
+ return[4/*yield*/,Ue()];case 2:
269
269
  // fetch and apply landed cost
270
- m.sent();d=(n=or.shippingData)===null||n===void 0?void 0:n.find(Boolean);l=(t=or.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCost.shipmentRating.id===(d===null||d===void 0?void 0:d.id)}));c=!!l?l.subtotals:null;if(c){
270
+ m.sent();d=(n=sr.shippingData)===null||n===void 0?void 0:n.find(Boolean);l=(t=sr.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCost.shipmentRating.id===(d===null||d===void 0?void 0:d.id)}));c=!!l?l.subtotals:null;if(c){
271
271
  // prefetch landed cost will not update shipping and taxes since we haven't selected shipping method yet
272
- vr({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:c})}return[3/*break*/,7];case 3:v=m.sent();
272
+ mr({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:c})}return[3/*break*/,7];case 3:v=m.sent();
273
273
  // default to empty array if we failed to fetch landed cost, so we can show the error message
274
- or.landedCostData=[];or.shippingData=[];f=["The landed cost calculation request was aborted to initiate a new one."];if(!(v instanceof Error&&v.message&&!f.includes(v.message)))return[3/*break*/,6];if(!(i<1))return[3/*break*/,5];
274
+ sr.landedCostData=[];sr.shippingData=[];f=["The landed cost calculation request was aborted to initiate a new one."];if(!(v instanceof Error&&v.message&&!f.includes(v.message)))return[3/*break*/,6];if(!(i<1))return[3/*break*/,5];
275
275
  // retry fetching landed cost one more time
276
- return[4/*yield*/,xe(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:
276
+ return[4/*yield*/,ze(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:
277
277
  // retry fetching landed cost one more time
278
- m.sent();return[2/*return*/,{isRequestNotReady:false}];case 5:p=(o=we.stripeAddressEventData)===null||o===void 0?void 0:o.value;void S({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[v.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:p}});m.label=6;case 6:y(v);return[3/*break*/,7];case 7:we.isFetchingLandedCost=false;return[2/*return*/,{isRequestNotReady:false}]}}))}))}));var Re=e("N",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(o){switch(o.label){case 0:return[4/*yield*/,xe({applyingPromocode:true})];case 1:o.sent();
278
+ m.sent();return[2/*return*/,{isRequestNotReady:false}];case 5:p=(o=_e.stripeAddressEventData)===null||o===void 0?void 0:o.value;void _({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[v.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:p}});m.label=6;case 6:y(v);return[3/*break*/,7];case 7:_e.isFetchingLandedCost=false;return[2/*return*/,{isRequestNotReady:false}]}}))}))}));var Be=e("N",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(o){switch(o.label){case 0:return[4/*yield*/,ze({applyingPromocode:true})];case 1:o.sent();
279
279
  // Go back to shipping step if we are in payment step so user can reselect shipping method
280
- if(or.step==="payment"){Cr()}
280
+ if(sr.step==="payment"){Tr()}
281
281
  // async update address with new root id from the new quote
282
- return[4/*yield*/,Te()];case 2:
282
+ return[4/*yield*/,Ne()];case 2:
283
283
  // async update address with new root id from the new quote
284
- o.sent();n=(e=or.shippingData)===null||e===void 0?void 0:e.find(Boolean);t=(r=or.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCost.id===(n===null||n===void 0?void 0:n.id)}));if(!n||!t){return[2/*return*/]}return[4/*yield*/,wr({applySubtotalsOnly:false,landedCostId:t.landedCostId,selectedShippingOption:n})];case 3:o.sent();return[2/*return*/]}}))}))}));var Ue=e("P",(function(){or.promoCode="";sessionStorage.removeItem("zonos--promo-code");
284
+ o.sent();n=(e=sr.shippingData)===null||e===void 0?void 0:e.find(Boolean);t=(r=sr.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCost.id===(n===null||n===void 0?void 0:n.id)}));if(!n||!t){return[2/*return*/]}return[4/*yield*/,_r({applySubtotalsOnly:false,landedCostId:t.landedCostId,selectedShippingOption:n})];case 3:o.sent();return[2/*return*/]}}))}))}));var Fe=e("P",(function(){sr.promoCode="";A("session","zonos--promo-code");
285
285
  // reset promocode error state
286
- or.promoCodeError=false;or.promoCodeApplied=false}));var ze=e("O",(function(){return __awaiter(C,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:
286
+ sr.promoCodeError=false;sr.promoCodeApplied=false}));var qe=e("O",(function(){return __awaiter(T,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:
287
287
  // Go back to shipping step if we are in payment step so user can reselect shipping method
288
- if(or.step==="payment"){Cr()}Ue();return[4/*yield*/,Re()];case 1:e.sent();return[2/*return*/]}}))}))}));var Be=e("Q",(function(e){var r=[];var n=true;var t=window.Zonos.isCollect;var o=window.Zonos.isInvoice;
288
+ if(sr.step==="payment"){Tr()}Fe();return[4/*yield*/,Be()];case 1:e.sent();return[2/*return*/]}}))}))}));var Je=e("Q",(function(e){var r=[];var n=true;var t=window.Zonos.isCollect;var o=window.Zonos.isInvoice;
289
289
  // Inspect the PaymentIntent `status` to indicate the status of the payment
290
290
  // to your customer.
291
291
 
@@ -296,23 +296,23 @@ if(or.step==="payment"){Cr()}Ue();return[4/*yield*/,Re()];case 1:e.sent();return
296
296
  switch(e){case"succeeded":{r=[i("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."),"",i("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(t||o){r=[i("Thank you for submitting your payment. We appreciate your prompt attention."),"",i("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.")]}n=false;break}case"requires_capture":case"processing":{r=[i("Payment processing. We'll update you when payment is received.")];n=false;break}case"requires_payment_method":{r=[i("Payment failed. Please try another payment method.")];if(t){r=[i("Payment failed. Please reload the page and try another payment method.")]}break}case"requires_action":{n=false;r=[i("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{r=[i("Something went wrong.")];break}}return{isError:n,messages:r}}));
297
297
  /**
298
298
  * Handle inventory check and returns error message if the callback provided.
299
- */var Fe=e("n",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r,t,o,a,s,u,d,l,d;return __generator(this,(function(c){switch(c.label){case 0:t=n.checkoutSettings.onInventoryCheck;o=!!((r=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||r===void 0?void 0:r.value);if(!(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o))return[3/*break*/,2];return[4/*yield*/,h("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:a=c.sent(),s=a.errors,u=a.json;if(s.length||!u){y("Error occurs when handling inventory refund","warn",JSON.stringify(s));return[2/*return*/,null]}
299
+ */var Me=e("n",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,t,o,a,s,u,d,l,d;return __generator(this,(function(c){switch(c.label){case 0:t=n.checkoutSettings.onInventoryCheck;o=!!((r=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||r===void 0?void 0:r.value);if(!(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o))return[3/*break*/,2];return[4/*yield*/,h("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:a=c.sent(),s=a.errors,u=a.json;if(s.length||!u){y("Error occurs when handling inventory refund","warn",JSON.stringify(s));return[2/*return*/,null]}
300
300
  // Proceed if the item is available
301
- if(!u.available||u.status===204){return[2/*return*/,i("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(u.available||u.status===200){we.shouldInventoryRefund=true;return[2/*return*/,null]}return[2/*return*/,null];case 2:if(typeof t!=="function"){return[2/*return*/,null]}c.label=3;case 3:c.trys.push([3,5,,6]);return[4/*yield*/,t({items:or.items},{translate:i,zonosApiRoute:w["vercel"]})];case 4:d=c.sent();return[2/*return*/,d];case 5:l=c.sent();d=l instanceof Error?l.message:"Unknown error";void S({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(d)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:or.items}});throw l;case 6:return[2/*return*/]}}))}))}));
301
+ if(!u.available||u.status===204){return[2/*return*/,i("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(u.available||u.status===200){_e.shouldInventoryRefund=true;return[2/*return*/,null]}return[2/*return*/,null];case 2:if(typeof t!=="function"){return[2/*return*/,null]}c.label=3;case 3:c.trys.push([3,5,,6]);return[4/*yield*/,t({items:sr.items},{translate:i,zonosApiRoute:w["vercel"]})];case 4:d=c.sent();return[2/*return*/,d];case 5:l=c.sent();d=l instanceof Error?l.message:"Unknown error";void _({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(d)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:sr.items}});throw l;case 6:return[2/*return*/]}}))}))}));
302
302
  /**
303
303
  * Handle inventory check and returns error message if the callback provided.
304
- */var qe=e("F",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r,n;return __generator(this,(function(t){switch(t.label){case 0:n=!!((r=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||r===void 0?void 0:r.value);
304
+ */var We=e("F",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n;return __generator(this,(function(t){switch(t.label){case 0:n=!!((r=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||r===void 0?void 0:r.value);
305
305
  // inventory refund is only available for legacy checkout and store has referenceId in metadata
306
306
  if(!window.Zonos.isLegacyCheckout||!window.Zonos.cartData||!n){return[2/*return*/]}
307
307
  // handle inventory check on legacy checkout
308
308
  return[4/*yield*/,h("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:
309
309
  // handle inventory check on legacy checkout
310
- t.sent();return[2/*return*/]}}))}))}));var Je=e("c",(function(e){return __awaiter(C,[e],void 0,(function(e){var r,n,t,o,a,s,u,d,l;var c=e.clientSecret,v=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(v){r=Be(v),n=r.isError,t=r.messages;return[2/*return*/,{error:n,messages:t}]}o=c||we.clientSecret;if(!we.stripe||!o){y("Failed to retrieve payment intent. Stripe is not initialized");return[2/*return*/,{error:true,message:[i("Something went wrong.")]}]}
310
+ t.sent();return[2/*return*/]}}))}))}));var Ye=e("c",(function(e){return __awaiter(T,[e],void 0,(function(e){var r,n,t,o,a,s,u,d,l;var c=e.clientSecret,v=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(v){r=Je(v),n=r.isError,t=r.messages;return[2/*return*/,{error:n,messages:t}]}o=c||_e.clientSecret;if(!_e.stripe||!o){y("Failed to retrieve payment intent. Stripe is not initialized");return[2/*return*/,{error:true,message:[i("Something went wrong.")]}]}
311
311
  // A client secret that isn't a Stripe payment intent secret (e.g. an Airwallex
312
312
  // secret) can't be evaluated by Stripe. Do not treat it as a successful Stripe
313
313
  // payment — return an error so callers don't run success analytics / order
314
314
  // polling off a secret Stripe never confirmed.
315
- if(!o.includes("_secret_")){return[2/*return*/,{error:true,messages:[i("Something went wrong.")]}]}return[4/*yield*/,we.stripe.retrievePaymentIntent(o)];case 1:a=e.sent().paymentIntent;s=a===null||a===void 0?void 0:a.status;u=Be(s),d=u.isError,l=u.messages;return[2/*return*/,{amount:a===null||a===void 0?void 0:a.amount,currency:a===null||a===void 0?void 0:a.currency,error:d,messages:l,paymentIntentId:a===null||a===void 0?void 0:a.id,paymentMethod:a===null||a===void 0?void 0:a.payment_method,status:s}]}}))}))}));var Me=e("E",(function(e){return __awaiter(C,void 0,void 0,(function(){var r,n,t,a,s,u,d,l,c,v,f,m;return __generator(this,(function(h){switch(h.label){case 0:t=!!((r=we.stripePaymentEventData)===null||r===void 0?void 0:r.complete);a=we.stripeElements;s=we.stripe;u=we.clientSecret;we.customErrorMessage=null;if(!((n=or.selectedLandedCost)===null||n===void 0?void 0:n.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/*yield*/,ce()];case 1:d=h.sent();if(!d.valid){we.customErrorMessage=d.errorMessage;throw new Error(d.errorMessage)}l=o.checkoutSessionId;if(!(s&&a&&t&&u&&l))return[3/*break*/,3];c=new URL(window.location.href);c.searchParams.set("payment_intent_client_secret",u);c.searchParams.set("zonosCheckoutSessionId",l);void se({checkoutSessionId:l,eventName:"checkout_paymentInfoCompleted"});return[4/*yield*/,s.confirmPayment({confirmParams:{return_url:c.toString()},elements:a,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(i("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"){
315
+ if(!o.includes("_secret_")){return[2/*return*/,{error:true,messages:[i("Something went wrong.")]}]}return[4/*yield*/,_e.stripe.retrievePaymentIntent(o)];case 1:a=e.sent().paymentIntent;s=a===null||a===void 0?void 0:a.status;u=Je(s),d=u.isError,l=u.messages;return[2/*return*/,{amount:a===null||a===void 0?void 0:a.amount,currency:a===null||a===void 0?void 0:a.currency,error:d,messages:l,paymentIntentId:a===null||a===void 0?void 0:a.id,paymentMethod:a===null||a===void 0?void 0:a.payment_method,status:s}]}}))}))}));var He=e("E",(function(e){return __awaiter(T,void 0,void 0,(function(){var r,n,t,a,s,u,d,l,c,v,f,m;return __generator(this,(function(h){switch(h.label){case 0:t=!!((r=_e.stripePaymentEventData)===null||r===void 0?void 0:r.complete);a=_e.stripeElements;s=_e.stripe;u=_e.clientSecret;_e.customErrorMessage=null;if(!((n=sr.selectedLandedCost)===null||n===void 0?void 0:n.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/*yield*/,pe()];case 1:d=h.sent();if(!d.valid){_e.customErrorMessage=d.errorMessage;throw new Error(d.errorMessage)}l=o.checkoutSessionId;if(!(s&&a&&t&&u&&l))return[3/*break*/,3];c=new URL(window.location.href);c.searchParams.set("payment_intent_client_secret",u);c.searchParams.set("zonosCheckoutSessionId",l);void le({checkoutSessionId:l,eventName:"checkout_paymentInfoCompleted"});return[4/*yield*/,s.confirmPayment({confirmParams:{return_url:c.toString()},elements:a,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(i("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"){
316
316
  // PaymentIntent was canceled or expired, or status is `require_capture`.
317
317
  // don't throw error here because we will reset the checkout session last step
318
318
  return[2/*return*/]}}throw new Error("An unexpected error occurred.")}if(m.status==="requires_payment_method"){
@@ -325,42 +325,42 @@ throw new Error(i("Payment failed. Please try another payment method."))}h.label
325
325
  *
326
326
  * The recorded value captures which policies were shown, the URLs the buyer
327
327
  * agreed to, the active locale, and the snapshotted acceptance timestamp.
328
- */var We=function(){if(!Y.accepted){return null}var e=H();if(!e.length){return null}return{key:"merchantPolicyConsent",value:JSON.stringify({
328
+ */var Ke=function(){if(!G.accepted){return null}var e=V();if(!e.length){return null}return{key:"merchantPolicyConsent",value:JSON.stringify({
329
329
  // Use the timestamp snapshotted when the buyer first accepted, so any
330
330
  // later session-metadata update keeps the original moment of consent
331
331
  // for audit purposes. Fall back to "now" as a safety net for the
332
332
  // unlikely case the store value was cleared between accept and write.
333
- acceptedAt:Y.acceptedAt||(new Date).toISOString(),locale:s.selectedLocale,policies:e.reduce((function(e,r){e[r.key]=r.url;return e}),{})})}};
333
+ acceptedAt:G.acceptedAt||(new Date).toISOString(),locale:s.selectedLocale,policies:e.reduce((function(e,r){e[r.key]=r.url;return e}),{})})}};
334
334
  /**
335
335
  * Allow overriding the checkout session payment processor via a `paymentProcessor`
336
336
  * URL query param (e.g. `?paymentProcessor=AIRWALLEX`). The processor is normally
337
337
  * determined server-side by the billing company; this override is primarily used
338
338
  * for testing. Returns `undefined` when the param is missing or not a valid
339
339
  * processor.
340
- */var Ye=function(){var e=new URLSearchParams(window.location.search).get("paymentProcessor");var r=function(e){return Object.values(pe).some((function(r){return r===e}))};return e&&r(e)?e:undefined};var He=e("q",(function(){var e;var r=or.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);var n=o.enabledVariantTestKeys||[];var t={adjustmentsAmount:or.adjustments.reduce((function(e,r){return e+r.amount}),0),cartId:window.Zonos.cartId,currency:((e=or.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:or.customerAuthenticationToken||undefined,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:r,metadata:[{key:"language",value:s.selectedLocale}],paymentProcessor:Ye(),presentmentCountryCode:s.selectedCountryCode,skipPaymentIntent:we.skipPaymentIntent,varianceTestInput:n};return t}));var Ke=e("l",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r,n,t,a;return __generator(this,(function(s){switch(s.label){case 0:if(!o.checkoutSessionId){
340
+ */var Ge=function(){var e=new URLSearchParams(window.location.search).get("paymentProcessor");var r=function(e){return Object.values(ye).some((function(r){return r===e}))};return e&&r(e)?e:undefined};var Ve=e("q",(function(){var e;var r=sr.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);var n=o.enabledVariantTestKeys||[];var t={adjustmentsAmount:sr.adjustments.reduce((function(e,r){return e+r.amount}),0),cartId:window.Zonos.cartId,currency:((e=sr.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:sr.customerAuthenticationToken||undefined,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:r,metadata:[{key:"language",value:s.selectedLocale}],paymentProcessor:Ge(),presentmentCountryCode:s.selectedCountryCode,skipPaymentIntent:_e.skipPaymentIntent,varianceTestInput:n};return t}));var Ze=e("l",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,a;return __generator(this,(function(s){switch(s.label){case 0:if(!o.checkoutSessionId){
341
341
  // We want to log the error anytime we fail to create a checkout session
342
- void S({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:m,cartId:window.Zonos.cartId}});cr({messages:[i("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:i("Error creating Checkout")});return[2/*return*/]}return[4/*yield*/,h("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:o.checkoutSessionId},method:"POST"})];case 1:r=s.sent(),n=r.errors,t=r.json;a=(e=t===null||t===void 0?void 0:t.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(n.length||!a){y("Error occurs when getting payment intent",JSON.stringify(n,null,2));
342
+ void _({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:m,cartId:window.Zonos.cartId}});pr({messages:[i("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:i("Error creating Checkout")});return[2/*return*/]}return[4/*yield*/,h("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:o.checkoutSessionId},method:"POST"})];case 1:r=s.sent(),n=r.errors,t=r.json;a=(e=t===null||t===void 0?void 0:t.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(n.length||!a){y("Error occurs when getting payment intent",JSON.stringify(n,null,2));
343
343
  // We want to log the error anytime we fail to create a payment intent
344
- void S({endpoint:"Error creating payment intent",errors:n.map((function(e){return e.message})),metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,clientSecret:a}});cr({messages:[i("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:i("Error creating Checkout")});return[2/*return*/]}
344
+ void _({endpoint:"Error creating payment intent",errors:n.map((function(e){return e.message})),metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,clientSecret:a}});pr({messages:[i("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:i("Error creating Checkout")});return[2/*return*/]}
345
345
  // update cart store checkout session with updated from checkout session payment intent creation call so the checkout session and payment intent are in sync
346
- mr(t.checkoutSessionPaymentIntentCreate);return[2/*return*/]}}))}))}));
346
+ wr(t.checkoutSessionPaymentIntentCreate);return[2/*return*/]}}))}))}));
347
347
  /**
348
348
  * Init checkout session
349
349
  * @returns {boolean} whether or not the checkout session is successfully created
350
- */var Ve=e("k",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r,n,t,o,i,a,u;return __generator(this,(function(d){switch(d.label){case 0:if(!s.targetCurrency){y("Failed to create checkout session - missing localizationStore.targetCurrency");return[2/*return*/,false]}we.isFetchingSession=true;n=He();p("Checkout session body","info",n);return[4/*yield*/,h("/api/zonos-elements/create-checkout-session",{body:n,method:"POST"})];case 1:t=d.sent(),o=t.errors,i=t.json;we.isFetchingSession=false;if(o.length||!i){a=(e=o.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;
350
+ */var Qe=e("k",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,o,i,a,u;return __generator(this,(function(d){switch(d.label){case 0:if(!s.targetCurrency){y("Failed to create checkout session - missing localizationStore.targetCurrency");return[2/*return*/,false]}_e.isFetchingSession=true;n=Ve();p("Checkout session body","info",n);return[4/*yield*/,h("/api/zonos-elements/create-checkout-session",{body:n,method:"POST"})];case 1:t=d.sent(),o=t.errors,i=t.json;_e.isFetchingSession=false;if(o.length||!i){a=(e=o.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;
351
351
  // check if the error is related to expired cart and thow error so we can show error message accordingly
352
352
  if(Array.isArray(a)&&a.some((function(e){return e.message==="Cart is expired."}))){throw new Error("Cart is expired.")}y("Error occurred when creating checkout session",JSON.stringify(o,null,2));return[2/*return*/,false]}u=i.checkoutSessionCreate;
353
353
  // update cart store with updated information
354
- mr(u);vr({method:((r=u.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.subtotals});p("Exchange rate updated for cart items (checkout session create)","info",or.exchangeRate);p("done-init-checkout-session");return[2/*return*/,true]}}))}))}));var Ge=e("z",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r,t;return __generator(this,(function(i){switch(i.label){case 0:e=o.checkoutSessionId;
354
+ wr(u);mr({method:((r=u.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.subtotals});p("Exchange rate updated for cart items (checkout session create)","info",sr.exchangeRate);p("done-init-checkout-session");return[2/*return*/,true]}}))}))}));var Xe=e("z",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,t;return __generator(this,(function(i){switch(i.label){case 0:e=o.checkoutSessionId;
355
355
  // Checkout session id should be available at this point
356
356
  if(!e){y("Failed to update checkout session base currency");return[2/*return*/,false]}
357
357
  // Only update checkout session currency if setting is enabled
358
- if(n.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){p('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2/*return*/,true]}return[4/*yield*/,h("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:we.checkoutSettlementCurrency},method:"POST"})];case 1:r=i.sent().json;t=r===null||r===void 0?void 0:r.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;
358
+ if(n.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){p('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2/*return*/,true]}return[4/*yield*/,h("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:_e.checkoutSettlementCurrency},method:"POST"})];case 1:r=i.sent().json;t=r===null||r===void 0?void 0:r.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;
359
359
  // S
360
- if(!r||t!==we.checkoutSettlementCurrency){y("Failed to update checkout session base currency");return[2/*return*/,false]}p('Updated checkout session to settlement currency "'.concat(t,'".'));return[2/*return*/,true]}}))}))}));
360
+ if(!r||t!==_e.checkoutSettlementCurrency){y("Failed to update checkout session base currency");return[2/*return*/,false]}p('Updated checkout session to settlement currency "'.concat(t,'".'));return[2/*return*/,true]}}))}))}));
361
361
  /**
362
362
  * Update checkout session. Use for updating amount with landed cost id, or update session when cart items change
363
- */var Ze=function(e){return __awaiter(C,[e],void 0,(function(e){var r,n,t,i;var a=e.adjustmentsAmount,u=e.cartId,d=e.currency,l=e.id,c=e.itemsAmount,v=e.landedCostId,f=e.presentmentCountryCode,p=e.storeCreditApplication;return __generator(this,(function(e){switch(e.label){case 0:r=o.enabledVariantTestKeys||[];return[4/*yield*/,h("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:a,billToPartyId:we.partyBillingId,cartId:u,currency:d,customerAuthenticationToken:or.customerAuthenticationToken||undefined,id:l,itemsAmount:c,landedCostId:v,metadata:[{key:"language",value:s.selectedLocale}],presentmentCountryCode:f,shipToPartyId:we.partyShippingId,skipPaymentIntent:we.skipPaymentIntent,storeCreditApplication:p,varianceTestInput:r},method:"POST"})];case 1:n=e.sent(),t=n.errors,i=n.json;if(t.length||!i){y("Error occurs when updating checkout session",JSON.stringify(t,null,2));return[2/*return*/,{errors:t,json:i}]}return[2/*return*/,{errors:[],json:i}]}}))}))};
363
+ */var $e=function(e){return __awaiter(T,[e],void 0,(function(e){var r,n,t,i;var a=e.adjustmentsAmount,u=e.cartId,d=e.currency,l=e.id,c=e.itemsAmount,v=e.landedCostId,f=e.presentmentCountryCode,p=e.storeCreditApplication;return __generator(this,(function(e){switch(e.label){case 0:r=o.enabledVariantTestKeys||[];return[4/*yield*/,h("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:a,billToPartyId:_e.partyBillingId,cartId:u,currency:d,customerAuthenticationToken:sr.customerAuthenticationToken||undefined,id:l,itemsAmount:c,landedCostId:v,metadata:[{key:"language",value:s.selectedLocale}],presentmentCountryCode:f,shipToPartyId:_e.partyShippingId,skipPaymentIntent:_e.skipPaymentIntent,storeCreditApplication:p,varianceTestInput:r},method:"POST"})];case 1:n=e.sent(),t=n.errors,i=n.json;if(t.length||!i){y("Error occurs when updating checkout session",JSON.stringify(t,null,2));return[2/*return*/,{errors:t,json:i}]}return[2/*return*/,{errors:[],json:i}]}}))}))};
364
364
  /**
365
365
  * Pushes the buyer's policy consent into the checkout session's metadata via the
366
366
  * dedicated metadata-only mutation. Called from the payment continue handler so
@@ -370,7 +370,7 @@ if(!r||t!==we.checkoutSettlementCurrency){y("Failed to update checkout session b
370
370
  * because this fires at the end of the payment phase, when we don't want to
371
371
  * touch landed-cost / cart / party state. No-op when no policies are configured,
372
372
  * when consent hasn't been accepted, or when there is no active session ID.
373
- */var Qe=e("T",(function(){return __awaiter(C,void 0,void 0,(function(){var e,r;return __generator(this,(function(n){switch(n.label){case 0:e=We();if(!e){return[2/*return*/,{errors:[]}]}if(!o.checkoutSessionId){return[2/*return*/,{errors:[]}]}return[4/*yield*/,h("/api/zonos-elements/update-checkout-session-metadata",{body:{id:o.checkoutSessionId,metadata:[e]},method:"POST"})];case 1:r=n.sent().errors;if(r.length){
373
+ */var er=e("T",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r;return __generator(this,(function(n){switch(n.label){case 0:e=Ke();if(!e){return[2/*return*/,{errors:[]}]}if(!o.checkoutSessionId){return[2/*return*/,{errors:[]}]}return[4/*yield*/,h("/api/zonos-elements/update-checkout-session-metadata",{body:{id:o.checkoutSessionId,metadata:[e]},method:"POST"})];case 1:r=n.sent().errors;if(r.length){
374
374
  // Surface failures loudly so we have observability on consent records that
375
375
  // didn't persist — callers don't block payment, but the failure is logged.
376
376
  y("Failed to record merchant policy consent on checkout session",JSON.stringify(r,null,2));return[2/*return*/,{errors:r.map((function(e){return e.message||"Unknown error"}))}]}return[2/*return*/,{errors:[]}]}}))}))}));
@@ -384,7 +384,7 @@ y("Failed to record merchant policy consent on checkout session",JSON.stringify(
384
384
  * @param {Address} params.translatedAddressResult - The translated address result.
385
385
  *
386
386
  * @returns {TranslatedAddress} - An object containing the translated address. Each field is an object with the current address's field value as the key and the translated address's field value as the value.
387
- */var Xe=function(e){var r,n,t,o,i,a;var s=e.currentAddress,u=e.translatedAddressResult;var d={};if(!u){return d}var l=u.city,c=u.line1,v=u.line2,f=u.name,p=u.postal_code,m=u.state;
387
+ */var rr=function(e){var r,n,t,o,i,a;var s=e.currentAddress,u=e.translatedAddressResult;var d={};if(!u){return d}var l=u.city,c=u.line1,v=u.line2,f=u.name,p=u.postal_code,m=u.state;
388
388
  // If we have translated address, add it to the translated address object
389
389
  if(s.city&&l){d.city=(r={},r[s.city]=l,r)}if(s.line1&&c){d.line1=(n={},n[s.line1]=c,n)}if(s.line2&&v){d.line2=(t={},t[s.line2]=v,t)}if(s.postal_code&&p){d.postal_code=(o={},o[s.postal_code]=p,o)}if(s.state&&m){d.state=(i={},i[s.state]=m,i)}if(s.name&&f){d.name=(a={},a[s.name]=f,a)}return d};
390
390
  /**
@@ -397,17 +397,17 @@ if(s.city&&l){d.city=(r={},r[s.city]=l,r)}if(s.line1&&c){d.line1=(n={},n[s.line1
397
397
  * @param {Object} params - The parameters for the function.
398
398
  * @param {ReturnType<typeof containsNonLatinChars> | null} params.addressInvalidCharactersList - The list of address fields that contain invalid characters.
399
399
  * @param {ReturnType<typeof containsNonLatinChars> | null} params.billingAddressInvalidCharactersList - The list of billing address fields that contain invalid characters.
400
- */var $e=e("W",(function(e){return __awaiter(C,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l,c;var v=e.addressInvalidCharactersList,f=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=de({addressInvalidCharactersList:v,billingAddressInvalidCharactersList:f,stripeAddressEventData:we.stripeAddressEventData,stripeBillingAddressEventData:we.stripeBillingAddressEventData,stripeShippingSameAsBilling:we.stripeShippingSameAsBilling});if(!i){
400
+ */var nr=e("W",(function(e){return __awaiter(T,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l,c;var v=e.addressInvalidCharactersList,f=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=ve({addressInvalidCharactersList:v,billingAddressInvalidCharactersList:f,stripeAddressEventData:_e.stripeAddressEventData,stripeBillingAddressEventData:_e.stripeBillingAddressEventData,stripeShippingSameAsBilling:_e.stripeShippingSameAsBilling});if(!i){
401
401
  // reset translated address if we don't have any address to translate
402
- we.translatedAddress={address:{},billingAddress:{}};return[2/*return*/]}a=Ce();if(!a){return[2/*return*/]}return[4/*yield*/,h("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),u=s.errors,d=s.json;if(u.length||!d){y("Error occurs when translating address to latin",JSON.stringify(u,null,2));
402
+ _e.translatedAddress={address:{},billingAddress:{}};return[2/*return*/]}a=Te();if(!a){return[2/*return*/]}return[4/*yield*/,h("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),u=s.errors,d=s.json;if(u.length||!d){y("Error occurs when translating address to latin",JSON.stringify(u,null,2));
403
403
  // reset translated address if we Failed to translate and let user manually fix it
404
- we.translatedAddress={address:{},billingAddress:{}};return[2/*return*/]}
404
+ _e.translatedAddress={address:{},billingAddress:{}};return[2/*return*/]}
405
405
  // Set current address to the store so we can compare it later to determine if we need to re-translate the address
406
- we.stripeAddressUsedWhenValidatingAddress=we.stripeAddressEventData;we.stripeBillingAddressUsedWhenValidatingAddress=we.stripeBillingAddressEventData;l=(r=we.stripeAddressEventData)===null||r===void 0?void 0:r.value.address;c=(n=we.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value.address;
406
+ _e.stripeAddressUsedWhenValidatingAddress=_e.stripeAddressEventData;_e.stripeBillingAddressUsedWhenValidatingAddress=_e.stripeBillingAddressEventData;l=(r=_e.stripeAddressEventData)===null||r===void 0?void 0:r.value.address;c=(n=_e.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value.address;
407
407
  // Set the translated address to the store so we can populate it to the address element for user to update
408
- we.translatedAddress={address:l?Xe({currentAddress:Object.assign(Object.assign({},l),{name:(t=we.stripeAddressEventData)===null||t===void 0?void 0:t.value.name}),translatedAddressResult:d.address||null}):{},billingAddress:!we.stripeShippingSameAsBilling?Xe({currentAddress:Object.assign(Object.assign({},c),{name:(o=we.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:d.billingAddress||null}):{}};return[2/*return*/]}}))}))}));he("clientSecret",(function(e){
408
+ _e.translatedAddress={address:l?rr({currentAddress:Object.assign(Object.assign({},l),{name:(t=_e.stripeAddressEventData)===null||t===void 0?void 0:t.value.name}),translatedAddressResult:d.address||null}):{},billingAddress:!_e.stripeShippingSameAsBilling?rr({currentAddress:Object.assign(Object.assign({},c),{name:(o=_e.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:d.billingAddress||null}):{}};return[2/*return*/]}}))}))}));ge("clientSecret",(function(e){
409
409
  // update stripe elements when client secret changes
410
- if(e&&we.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));
410
+ if(e&&_e.stripe){O("session","zonos--client-secret",e)}if(!e){A("session","zonos--client-secret")}}));
411
411
  /**
412
412
  * EU 3-EUR cutover (05CHECK-893): when shipping to an EU country with a POSTAL
413
413
  * service level whose DAP landed cost has remittance available, we keep treating
@@ -416,38 +416,38 @@ if(e&&we.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){session
416
416
  * estimated and paid on delivery.
417
417
  *
418
418
  * @see [[cartStoreGetMethod]] for the DAP/DDP conversion this guards.
419
- */var er=e("M",(function(e){var r=e.deliveryType,n=e.landedCost,t=e.shipToCountry;return n.method==="DAP"&&r==="POSTAL"&&n.remittance.length>0&&!!t&&v.includes(t)}));var rr=r((function(){return{addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:false,checkoutTimeoutInterval:null,currency:"USD",customMessage:[],customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:false,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,isStagingMode:b(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",
419
+ */var tr=e("M",(function(e){var r=e.deliveryType,n=e.landedCost,t=e.shipToCountry;return n.method==="DAP"&&r==="POSTAL"&&n.remittance.length>0&&!!t&&v.includes(t)}));var or=r((function(){return{addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:false,checkoutTimeoutInterval:null,currency:"USD",customMessage:[],customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:false,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,isStagingMode:b(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:S("session","zonos--promo-code")||"",
420
420
  // When user clicked applied button, save promocode into session storage for later use. So if session has promocode, applied button is clicked
421
- promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:false,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:false,step:"customer-info",storeCredit:0,subtotal:0,tabItems:{"customer-info":{index:1,isDone:false,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:false,label:"Shipping",value:"shipping"},
421
+ promoCodeApplied:!!S("session","zonos--promo-code"),promoCodeError:false,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:false,step:"customer-info",storeCredit:0,subtotal:0,tabItems:{"customer-info":{index:1,isDone:false,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:false,label:"Shipping",value:"shipping"},
422
422
  // eslint-disable-next-line sort-keys/sort-keys-fix
423
- payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),nr=rr.onChange,tr=rr.reset,or=rr.state;e({I:nr,d:or});var ir=function(e){switch(e){case"DAYS":return i("days");case"WEEKS":return i("weeks");case"BUSINESS_DAYS":default:return i("business days")}};
423
+ payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),ir=or.onChange,ar=or.reset,sr=or.state;e({I:ir,d:sr});var ur=function(e){switch(e){case"DAYS":return i("days");case"WEEKS":return i("weeks");case"BUSINESS_DAYS":default:return i("business days")}};
424
424
  /**
425
425
  * Format shipping transit info to be displayed on UI
426
426
  * @returns
427
427
  * - expectedDate: Thursday, Aug 12
428
428
  * - maxTransit: 5
429
429
  * - minTransit: 3
430
- */var ar=e("_",(function(e){var r;var n=(r=e.shippingProfile)===null||r===void 0?void 0:r.transitTime;
430
+ */var dr=e("_",(function(e){var r;var n=(r=e.shippingProfile)===null||r===void 0?void 0:r.transitTime;
431
431
  // Don't care about falsy 0 values because this is international shipping and 0 days is not feasible
432
- if(!(n===null||n===void 0?void 0:n.min)||!(n===null||n===void 0?void 0:n.max)||!(n===null||n===void 0?void 0:n.type)){return null}return{maxTransit:n.max,minTransit:n.min,unit:ir(n.type)}}));var sr=function(e){var r=e.item1,n=e.item2;if(!r||!n){return false}return n.sku&&r.sku&&r.sku===n.sku||n.description&&r.description&&r.description===n.description||r.name&&n.name&&r.name===n.name};
432
+ if(!(n===null||n===void 0?void 0:n.min)||!(n===null||n===void 0?void 0:n.max)||!(n===null||n===void 0?void 0:n.type)){return null}return{maxTransit:n.max,minTransit:n.min,unit:ur(n.type)}}));var lr=function(e){var r=e.item1,n=e.item2;if(!r||!n){return false}return n.sku&&r.sku&&r.sku===n.sku||n.description&&r.description&&r.description===n.description||r.name&&n.name&&r.name===n.name};
433
433
  /**
434
434
  * Check and set restricted items in cart
435
- */var ur=function(e){p("Checking item restrictions");var r=e.map((function(e){if(!e.restriction){return null}var r=e.restriction;var n=or.items.find((function(r){return sr({item1:r,item2:e})}));return Object.assign(Object.assign({matchedItem:n},e),{restriction:r})})).filter(Boolean);or.restrictedItems=r;
435
+ */var cr=function(e){p("Checking item restrictions");var r=e.map((function(e){if(!e.restriction){return null}var r=e.restriction;var n=sr.items.find((function(r){return lr({item1:r,item2:e})}));return Object.assign(Object.assign({matchedItem:n},e),{restriction:r})})).filter(Boolean);sr.restrictedItems=r;
436
436
  // remove items that are restricted from cart
437
- or.items=or.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!r.find((function(r){return sr({item1:r,item2:e})}))})}));return{cartItems:or.items,restrictedItems:r}};var dr=null;var lr=e("f",(function(){o.checkoutSessionId=null;
437
+ sr.items=sr.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!r.find((function(r){return lr({item1:r,item2:e})}))})}));return{cartItems:sr.items,restrictedItems:r}};var vr=null;var fr=e("f",(function(){o.checkoutSessionId=null;
438
438
  // clear pending store credit debounce timer
439
- if(dr){clearTimeout(dr);dr=null}
439
+ if(vr){clearTimeout(vr);vr=null}
440
440
  // reset store credit store
441
- E();
441
+ D();
442
442
  // reset cart store
443
- tr()}));var cr=e("r",(function(e){var r=e.messages,n=e.title;lr();Ae();or.step="error";or.error={messages:r,title:n}}));var vr=function(e){var r=e.dutiesTaxesFeesEstimate,n=e.method,t=e.subtotals;var o;
443
+ ar()}));var pr=e("r",(function(e){var r=e.messages,n=e.title;fr();Ie();sr.step="error";sr.error={messages:r,title:n}}));var mr=function(e){var r=e.dutiesTaxesFeesEstimate,n=e.method,t=e.subtotals;var o;
444
444
  // update exchange rate so we can use it to display cart items
445
- or.exchangeRate=t.exchangeRate;or.adjustmentTotal=t.adjustments;or.dutiesTaxesFees=n==="DAP"?null:t.landedCostTotal;or.storeCredit=(o=t.storeCredit)!==null&&o!==void 0?o:0;or.subtotal=t.items;or.total=t.total;or.currency=t.presentmentCurrencyCode;or.dutiesTaxesFeesEstimate=r||null};
445
+ sr.exchangeRate=t.exchangeRate;sr.adjustmentTotal=t.adjustments;sr.dutiesTaxesFees=n==="DAP"?null:t.landedCostTotal;sr.storeCredit=(o=t.storeCredit)!==null&&o!==void 0?o:0;sr.subtotal=t.items;sr.total=t.total;sr.currency=t.presentmentCurrencyCode;sr.dutiesTaxesFeesEstimate=r||null};
446
446
  /**
447
447
  * Detect if there are any items in cart that are not restricted and have positive amount, exclude negative amount items
448
- */var fr=e("L",(function(){
448
+ */var hr=e("L",(function(){
449
449
  // filter all items with positive amount
450
- var e=or.items.filter((function(e){return e.amount>0}));
450
+ var e=sr.items.filter((function(e){return e.amount>0}));
451
451
  // only check restricted status for items with positive amount
452
452
  // if there is no item restricted found => all items are restricted
453
453
  return!!e.find((function(e){return!e.isRestricted}))}));
@@ -458,71 +458,71 @@ return!!e.find((function(e){return!e.isRestricted}))}));
458
458
  * Single source of truth for this detection — previously duplicated inline
459
459
  * at each call site, which let one of them (the forceDialogOpen/preview init
460
460
  * path) miss it entirely.
461
- */var pr=e("m",(function(){var e,r;return!!(((r=(e=or.checkoutSession)===null||e===void 0?void 0:e.order)===null||r===void 0?void 0:r.id)&&!or.checkoutSession.completedAt)}));var mr=e("v",(function(e){var r,n,t,i,a,s,l;
461
+ */var yr=e("m",(function(){var e,r;return!!(((r=(e=sr.checkoutSession)===null||e===void 0?void 0:e.order)===null||r===void 0?void 0:r.id)&&!sr.checkoutSession.completedAt)}));var wr=e("v",(function(e){var r,n,t,i,a,s,l;
462
462
  // update stripe store with updated information
463
- we.clientSecret=e.clientSecret;we.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;we.customerProfile=e.customerProfile;or.checkoutSession=e;
463
+ _e.clientSecret=e.clientSecret;_e.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;_e.customerProfile=e.customerProfile;sr.checkoutSession=e;
464
464
  // Populate store credit balance from checkout session customer profile
465
- N((n=(r=e.customerProfile)===null||r===void 0?void 0:r.storeCreditBalance)!==null&&n!==void 0?n:null);if(!e.id){
465
+ L((n=(r=e.customerProfile)===null||r===void 0?void 0:r.storeCreditBalance)!==null&&n!==void 0?n:null);if(!e.id){
466
466
  // Log error to track down the issue
467
- void S({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:m,checkoutSession:e}})}
467
+ void _({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:m,checkoutSession:e}})}
468
468
  // Only update checkout session id if it's not empty
469
469
  if(e.id){o.checkoutSessionId=e.id}
470
470
  // Filter the response to only include test keys that we support and then save it to the session
471
471
  var c=u(e.varianceTestResults||[]);d(c);
472
472
  // Check if there is a redirect URL in the metadata to override
473
- var v=((a=(i=(t=or.checkoutSession)===null||t===void 0?void 0:t.metadata)===null||i===void 0?void 0:i.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||a===void 0?void 0:a.value)||(
473
+ var v=((a=(i=(t=sr.checkoutSession)===null||t===void 0?void 0:t.metadata)===null||i===void 0?void 0:i.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||a===void 0?void 0:a.value)||(
474
474
  // Sometimes externalConfirmationPageURL is not in checkoutSession create/update, check if there is a redirect URL in the cart metadata to override
475
- (l=(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||l===void 0?void 0:l.value)||null;if(v){p("Found externalConfirmationPageURL: ".concat(v));or.externalConfirmationPageURL=v}}));var hr=function(e){return __awaiter(C,[e],void 0,(function(e){var r,n,t,a,u,d;var l=e.adjustmentsAmount,c=e.cartId,v=e.currency,f=e.dutiesTaxesFeesEstimate,m=e.itemsAmount,h=e.landedCostId,w=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(h&&or.selectedLandedCost){n=or.selectedLandedCost.subtotals;vr({dutiesTaxesFeesEstimate:f,method:or.landedCostMethod,subtotals:n});p("Exchange rate updated for cart items (landed cost subtotal)","info",or.exchangeRate)}
475
+ (l=(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||l===void 0?void 0:l.value)||null;if(v){p("Found externalConfirmationPageURL: ".concat(v));sr.externalConfirmationPageURL=v}}));var gr=function(e){return __awaiter(T,[e],void 0,(function(e){var r,n,t,a,u,d;var l=e.adjustmentsAmount,c=e.cartId,v=e.currency,f=e.dutiesTaxesFeesEstimate,m=e.itemsAmount,h=e.landedCostId,w=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(h&&sr.selectedLandedCost){n=sr.selectedLandedCost.subtotals;mr({dutiesTaxesFeesEstimate:f,method:sr.landedCostMethod,subtotals:n});p("Exchange rate updated for cart items (landed cost subtotal)","info",sr.exchangeRate)}
476
476
  // update checkout session
477
- if(!o.checkoutSessionId){p("Could not update cart total without checkout session id","info");return[2/*return*/,false]}return[4/*yield*/,Ze({adjustmentsAmount:l,cartId:c,currency:v,id:o.checkoutSessionId,itemsAmount:m,landedCostId:h,presentmentCountryCode:s.selectedCountryCode})];case 1:t=e.sent(),a=t.errors,u=t.json;if(!(a.length>0||!u))return[3/*break*/,4];y("Error occurs when updating checkout session.");if(!w)return[3/*break*/,3];p("Initiating checkout session on failure","info");return[4/*yield*/,Ve()];case 2:d=e.sent();p("stripeStoreInitCheckoutSession: ".concat(d));if(!d){cr({messages:[i("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:i("Error creating Checkout")});return[2/*return*/,false]}return[2/*return*/,true];case 3:return[2/*return*/,false];case 4:if(!h){
477
+ if(!o.checkoutSessionId){p("Could not update cart total without checkout session id","info");return[2/*return*/,false]}return[4/*yield*/,$e({adjustmentsAmount:l,cartId:c,currency:v,id:o.checkoutSessionId,itemsAmount:m,landedCostId:h,presentmentCountryCode:s.selectedCountryCode})];case 1:t=e.sent(),a=t.errors,u=t.json;if(!(a.length>0||!u))return[3/*break*/,4];y("Error occurs when updating checkout session.");if(!w)return[3/*break*/,3];p("Initiating checkout session on failure","info");return[4/*yield*/,Qe()];case 2:d=e.sent();p("stripeStoreInitCheckoutSession: ".concat(d));if(!d){pr({messages:[i("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:i("Error creating Checkout")});return[2/*return*/,false]}return[2/*return*/,true];case 3:return[2/*return*/,false];case 4:if(!h){
478
478
  // This is when we first open the checkout modal and we just want to get info from the old cart session.
479
479
  // use subtotals from checkout session to update cart total
480
- vr({method:((r=u.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.checkoutSessionUpdate.subtotals});p("Exchange rate updated for cart items (checkout session update)","info",or.exchangeRate)}mr(u.checkoutSessionUpdate);return[2/*return*/,true]}}))}))};
480
+ mr({method:((r=u.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.checkoutSessionUpdate.subtotals});p("Exchange rate updated for cart items (checkout session update)","info",sr.exchangeRate)}wr(u.checkoutSessionUpdate);return[2/*return*/,true]}}))}))};
481
481
  /**
482
482
  * For some service levels, the landed cost that's DAP and we do remittance on behalf of the merchant, these landed cost should be treated as DDP
483
- */var yr=e("$",(function(e,r){var t,o,i,a;
483
+ */var br=e("$",(function(e,r){var t,o,i,a;
484
484
  // If the landed cost is DAP and the country is domestic, then treat it as DDP since no duty or fee is due at the door
485
- if(e.method==="DAP"&&((o=(t=n.genericSettings)===null||t===void 0?void 0:t.domesticCountries)===null||o===void 0?void 0:o.includes(((i=we.stripeAddressEventData)===null||i===void 0?void 0:i.value.address.country)||"US"))){return"DDP"}
485
+ if(e.method==="DAP"&&((o=(t=n.genericSettings)===null||t===void 0?void 0:t.domesticCountries)===null||o===void 0?void 0:o.includes(((i=_e.stripeAddressEventData)===null||i===void 0?void 0:i.value.address.country)||"US"))){return"DDP"}
486
486
  // EU 3-EUR cutover (05CHECK-893): keep EU POSTAL remittance quotes as DAP so
487
487
  // the shopper is told duties are paid upon delivery, even though we remit.
488
- if(er({deliveryType:r,landedCost:e,shipToCountry:(a=we.stripeAddressEventData)===null||a===void 0?void 0:a.value.address.country})){return"DAP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var wr=e("Z",(function(e){return __awaiter(C,[e],void 0,(function(e){var r,t,o,i,a,s,u,d,l,c,v,f,m,h,y,w,g,b,S,_,O,A,C,k,I,T;var P=e.applySubtotalsOnly,E=e.landedCostId,N=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:p("Updating selected shipping option","info",{landedCostId:E,selectedShippingOption:N});or.selectedShippingOption=N;m=ar(or.selectedShippingOption);if(m){h=m.maxTransit,y=m.minTransit,w=m.unit;or.selectedShippingOptionTransitTime="".concat(y,"-").concat(h," ").concat(w)}else{or.selectedShippingOptionTransitTime=""}g=(r=or.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCostId===E}));
488
+ if(tr({deliveryType:r,landedCost:e,shipToCountry:(a=_e.stripeAddressEventData)===null||a===void 0?void 0:a.value.address.country})){return"DAP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var _r=e("Z",(function(e){return __awaiter(T,[e],void 0,(function(e){var r,t,o,i,a,s,u,d,l,c,v,f,m,h,y,w,g,b,_,S,O,A,C,k,I,T;var P=e.applySubtotalsOnly,E=e.landedCostId,N=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:p("Updating selected shipping option","info",{landedCostId:E,selectedShippingOption:N});sr.selectedShippingOption=N;m=dr(sr.selectedShippingOption);if(m){h=m.maxTransit,y=m.minTransit,w=m.unit;sr.selectedShippingOptionTransitTime="".concat(y,"-").concat(h," ").concat(w)}else{sr.selectedShippingOptionTransitTime=""}g=(r=sr.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCostId===E}));
489
489
  // save selected landed cost for later use
490
- or.selectedLandedCost=g||null;if(!g){
490
+ sr.selectedLandedCost=g||null;if(!g){
491
491
  // do nothing if we can't find landed cost for selected shipping option
492
- return[2/*return*/,false]}b=((t=g.landedCost.amountSubtotals)===null||t===void 0?void 0:t.landedCostTotal)||0;S=g.subtotals.exchangeRate.rate;_=b*S;if(_){p("DAP quote, using estimate: ".concat(_),"info")}or.landedCostMethod=yr(g.landedCost,(o=N.shippingProfile)===null||o===void 0?void 0:o.serviceLevel.deliveryType);
492
+ return[2/*return*/,false]}b=((t=g.landedCost.amountSubtotals)===null||t===void 0?void 0:t.landedCostTotal)||0;_=g.subtotals.exchangeRate.rate;S=b*_;if(S){p("DAP quote, using estimate: ".concat(S),"info")}sr.landedCostMethod=br(g.landedCost,(o=N.shippingProfile)===null||o===void 0?void 0:o.serviceLevel.deliveryType);
493
493
  // update shipping value and dutiesTaxFees on selectedShippingOption change
494
- or.shipping=g.subtotals.shipping;O=((i=g===null||g===void 0?void 0:g.landedCost)===null||i===void 0?void 0:i.landedCostGuaranteeCode)==="ZONOS";A=!!((s=(a=g===null||g===void 0?void 0:g.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"})));or.isSelectedShippingAboveDeminimis=A;or.isSelectedShippingGuarantee=O;C=false;if(!P)return[3/*break*/,1];k=g.subtotals;vr({dutiesTaxesFeesEstimate:_,method:or.landedCostMethod,subtotals:k});p("Exchange rate updated for cart items (landed cost subtotal)","info",or.exchangeRate);C=true;return[3/*break*/,3];case 1:return[4/*yield*/,hr({adjustmentsAmount:or.adjustmentTotal,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:_,landedCostId:(u=g.landedCost)===null||u===void 0?void 0:u.id})];case 2:
494
+ sr.shipping=g.subtotals.shipping;O=((i=g===null||g===void 0?void 0:g.landedCost)===null||i===void 0?void 0:i.landedCostGuaranteeCode)==="ZONOS";A=!!((s=(a=g===null||g===void 0?void 0:g.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"})));sr.isSelectedShippingAboveDeminimis=A;sr.isSelectedShippingGuarantee=O;C=false;if(!P)return[3/*break*/,1];k=g.subtotals;mr({dutiesTaxesFeesEstimate:S,method:sr.landedCostMethod,subtotals:k});p("Exchange rate updated for cart items (landed cost subtotal)","info",sr.exchangeRate);C=true;return[3/*break*/,3];case 1:return[4/*yield*/,gr({adjustmentsAmount:sr.adjustmentTotal,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:S,landedCostId:(u=g.landedCost)===null||u===void 0?void 0:u.id})];case 2:
495
495
  // update session with selected landed cost
496
- C=e.sent();e.label=3;case 3:I=(d=or.items.find(Boolean))===null||d===void 0?void 0:d.currencyCode;T=((l=we.stripeAddressEventData)===null||l===void 0?void 0:l.value.address.country)||"US";
496
+ C=e.sent();e.label=3;case 3:I=(d=sr.items.find(Boolean))===null||d===void 0?void 0:d.currencyCode;T=((l=_e.stripeAddressEventData)===null||l===void 0?void 0:l.value.address.country)||"US";
497
497
  // Only show pay in USD button if item's currency is in USD, the setting is enabled and the order presentment currency is not USD, also only in USD settlement ship to country list
498
- we.shouldRenderPayInUsdButton=I==="USD"&&n.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((c=or.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/*return*/,C]}}))}))}));var gr=e("o",(function(e){var r=e.isPreview,n=e.sessionTimeout;
498
+ _e.shouldRenderPayInUsdButton=I==="USD"&&n.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((c=sr.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/*return*/,C]}}))}))}));var Sr=e("o",(function(e){var r=e.isPreview,n=e.sessionTimeout;
499
499
  // do nothing if in preview mode
500
500
  if(r){return}var t=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var o=
501
501
  // timeout query is mainly for testing purpose
502
- t&&!isNaN(parseInt(t,10))?parseInt(t,10):n;p("==START CHECKOUT TIMEOUT - ".concat(o,"=="));or.checkoutTimeoutInterval=setTimeout((function(){or.checkoutSessionTimeoutShow=true}),o)}));var br=e("j",(function(){if(or.checkoutTimeoutInterval){clearTimeout(or.checkoutTimeoutInterval);or.checkoutTimeoutInterval=null}}));var Sr=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var _r=function(){
502
+ t&&!isNaN(parseInt(t,10))?parseInt(t,10):n;p("==START CHECKOUT TIMEOUT - ".concat(o,"=="));sr.checkoutTimeoutInterval=setTimeout((function(){sr.checkoutSessionTimeoutShow=true}),o)}));var Or=e("j",(function(){if(sr.checkoutTimeoutInterval){clearTimeout(sr.checkoutTimeoutInterval);sr.checkoutTimeoutInterval=null}}));var Ar=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var Cr=function(){
503
503
  // mark all items as not restricted
504
- or.items=or.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));or.restrictedItems=[]};var Or=e("e",(function(e){return __awaiter(C,[e],void 0,(function(e){var r,n,t,o;var i=e.adjustments,a=e.cartItems,s=e.landedCostId,u=e.shouldInitSessionOnFailure,d=u===void 0?true:u;return __generator(this,(function(e){switch(e.label){case 0:
504
+ sr.items=sr.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));sr.restrictedItems=[]};var kr=e("e",(function(e){return __awaiter(T,[e],void 0,(function(e){var r,n,t,o;var i=e.adjustments,a=e.cartItems,s=e.landedCostId,u=e.shouldInitSessionOnFailure,d=u===void 0?true:u;return __generator(this,(function(e){switch(e.label){case 0:
505
505
  // Update adjustments and items
506
- or.adjustments=i;or.items=Sr(a);n=(r=a.find(Boolean))===null||r===void 0?void 0:r.currencyCode;t=a.reduce((function(e,r){return e+r.amount*r.quantity}),0);o=i.reduce((function(e,r){return e+r.amount}),0);if(!n||!t){
506
+ sr.adjustments=i;sr.items=Ar(a);n=(r=a.find(Boolean))===null||r===void 0?void 0:r.currencyCode;t=a.reduce((function(e,r){return e+r.amount*r.quantity}),0);o=i.reduce((function(e,r){return e+r.amount}),0);if(!n||!t){
507
507
  // do nothing if we can't get currency or total
508
- return[2/*return*/]}or.currency=n;
508
+ return[2/*return*/]}sr.currency=n;
509
509
  // set loading state here because this is the first load checkout session when we already have checkout session id stored
510
- we.isFetchingSession=true;return[4/*yield*/,hr({adjustmentsAmount:o,cartId:window.Zonos.cartId,currency:n,dutiesTaxesFeesEstimate:0,itemsAmount:t,landedCostId:s,shouldInitSessionOnFailure:d})];case 1:e.sent();we.isFetchingSession=false;return[2/*return*/]}}))}))}));var Ar=function(){or.selectedShippingOption=null;or.isSelectedShippingAboveDeminimis=false;or.isSelectedShippingGuarantee=false;or.selectedShippingOptionTransitTime="";or.dutiesTaxesFees=0;or.dutiesTaxesFeesEstimate=0;or.shipping=0;
510
+ _e.isFetchingSession=true;return[4/*yield*/,gr({adjustmentsAmount:o,cartId:window.Zonos.cartId,currency:n,dutiesTaxesFeesEstimate:0,itemsAmount:t,landedCostId:s,shouldInitSessionOnFailure:d})];case 1:e.sent();_e.isFetchingSession=false;return[2/*return*/]}}))}))}));var Ir=function(){sr.selectedShippingOption=null;sr.isSelectedShippingAboveDeminimis=false;sr.isSelectedShippingGuarantee=false;sr.selectedShippingOptionTransitTime="";sr.dutiesTaxesFees=0;sr.dutiesTaxesFeesEstimate=0;sr.shipping=0;
511
511
  // reset total to subtotal
512
- or.total=or.subtotal};var Cr=function(){if(or.step==="shipping"){or.step="customer-info";
512
+ sr.total=sr.subtotal};var Tr=function(){if(sr.step==="shipping"){sr.step="customer-info";
513
513
  // set shipping step to done
514
- or.tabItems=Object.assign(Object.assign({},or.tabItems),{"customer-info":Object.assign(Object.assign({},or.tabItems.shipping),{isDone:false})})}else if(or.step==="payment"){or.step="shipping";
514
+ sr.tabItems=Object.assign(Object.assign({},sr.tabItems),{"customer-info":Object.assign(Object.assign({},sr.tabItems.shipping),{isDone:false})})}else if(sr.step==="payment"){sr.step="shipping";
515
515
  // set shipping step to done
516
- or.tabItems=Object.assign(Object.assign({},or.tabItems),{shipping:Object.assign(Object.assign({},or.tabItems.shipping),{isDone:false})})}else if(or.step==="finish"){or.step="payment";
516
+ sr.tabItems=Object.assign(Object.assign({},sr.tabItems),{shipping:Object.assign(Object.assign({},sr.tabItems.shipping),{isDone:false})})}else if(sr.step==="finish"){sr.step="payment";
517
517
  // set shipping step to done
518
- or.tabItems=Object.assign(Object.assign({},or.tabItems),{payment:Object.assign(Object.assign({},or.tabItems.payment),{isDone:false})})}};var kr=e("x",(function(){if(or.step==="customer-info"){or.step="shipping";
518
+ sr.tabItems=Object.assign(Object.assign({},sr.tabItems),{payment:Object.assign(Object.assign({},sr.tabItems.payment),{isDone:false})})}};var Pr=e("x",(function(){if(sr.step==="customer-info"){sr.step="shipping";
519
519
  // set customer-info step to done
520
- or.tabItems=Object.assign(Object.assign({},or.tabItems),{"customer-info":Object.assign(Object.assign({},or.tabItems["customer-info"]),{isDone:true})})}else if(or.step==="shipping"){or.step="payment";
520
+ sr.tabItems=Object.assign(Object.assign({},sr.tabItems),{"customer-info":Object.assign(Object.assign({},sr.tabItems["customer-info"]),{isDone:true})})}else if(sr.step==="shipping"){sr.step="payment";
521
521
  // set shipping step to done
522
- or.tabItems=Object.assign(Object.assign({},or.tabItems),{shipping:Object.assign(Object.assign({},or.tabItems.shipping),{isDone:true})})}else if(or.step==="payment"){or.step="finish"}}));var Ir=e("h",(function(){or.step="customer-info";or.tabItems=Object.assign(Object.assign({},or.tabItems),{"customer-info":Object.assign(Object.assign({},or.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},or.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},or.tabItems.shipping),{isDone:false})});Ar()}));var Tr=function(){return __awaiter(C,void 0,void 0,(function(){var e,r,n,t,i,a,u,d,l;return __generator(this,(function(c){switch(c.label){case 0:if(!o.checkoutSessionId){p("Could not update store credit without checkout session id","info");return[2/*return*/]}n=or.selectedLandedCost;t=or.currency||((e=or.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"";i=or.adjustments.reduce((function(e,r){return e+r.amount}),0);a=or.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);return[4/*yield*/,Ze({adjustmentsAmount:i,cartId:window.Zonos.cartId,currency:t,id:o.checkoutSessionId,itemsAmount:a,landedCostId:n===null||n===void 0?void 0:n.landedCostId,presentmentCountryCode:s.selectedCountryCode,storeCreditApplication:U()})];case 1:u=c.sent(),d=u.errors,l=u.json;if(d.length>0||!l){y("Error updating checkout session with store credit");return[2/*return*/]}
522
+ sr.tabItems=Object.assign(Object.assign({},sr.tabItems),{shipping:Object.assign(Object.assign({},sr.tabItems.shipping),{isDone:true})})}else if(sr.step==="payment"){sr.step="finish"}}));var Er=e("h",(function(){sr.step="customer-info";sr.tabItems=Object.assign(Object.assign({},sr.tabItems),{"customer-info":Object.assign(Object.assign({},sr.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},sr.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},sr.tabItems.shipping),{isDone:false})});Ir()}));var Nr=function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,i,a,u,d,l;return __generator(this,(function(c){switch(c.label){case 0:if(!o.checkoutSessionId){p("Could not update store credit without checkout session id","info");return[2/*return*/]}n=sr.selectedLandedCost;t=sr.currency||((e=sr.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"";i=sr.adjustments.reduce((function(e,r){return e+r.amount}),0);a=sr.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);return[4/*yield*/,$e({adjustmentsAmount:i,cartId:window.Zonos.cartId,currency:t,id:o.checkoutSessionId,itemsAmount:a,landedCostId:n===null||n===void 0?void 0:n.landedCostId,presentmentCountryCode:s.selectedCountryCode,storeCreditApplication:F()})];case 1:u=c.sent(),d=u.errors,l=u.json;if(d.length>0||!l){y("Error updating checkout session with store credit");return[2/*return*/]}
523
523
  // Apply updated subtotals from the response
524
- vr({method:((r=l.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:l.checkoutSessionUpdate.subtotals});mr(l.checkoutSessionUpdate);return[2/*return*/]}}))}))};
524
+ mr({method:((r=l.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:l.checkoutSessionUpdate.subtotals});wr(l.checkoutSessionUpdate);return[2/*return*/]}}))}))};
525
525
  /**
526
526
  * Update the checkout session with the current store credit selection.
527
527
  * Debounced to prevent multiple rapid requests when store changes cascade.
528
- */var Pr=e("a5",(function(){if(dr){clearTimeout(dr)}dr=setTimeout((function(){dr=null;void Tr()}),300)}))}}}));
528
+ */var jr=e("a5",(function(){if(vr){clearTimeout(vr)}vr=setTimeout((function(){vr=null;void Nr()}),300)}))}}}));