@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 +0,0 @@
1
- import{c as e,z as t,e as o}from"./p-CqB9AfBf.js";import{s as n,t as r,m as s,l as i,f as a,e as d}from"./p-CTiqplrr.js";import{b as l,e as c}from"./p-Dwg61Ft_.js";import{e as u,i as m}from"./p-DMIgN_sT.js";import{l as p,b as v}from"./p-BJmZPrZl.js";import{h,l as y,f as w,g as f,a as g,s as b,j as S}from"./p-DE4a-QD5.js";import{i as C}from"./p-YdrG78th.js";import{g as O}from"./p-r-YGHhLa.js";const A=async()=>{if(!n.checkoutSessionId)return{errors:[{message:"No checkout session id found"}],json:null};const e=new URLSearchParams;e.set("checkoutSessionId",n.checkoutSessionId);const{errors:t,json:o}=await h(`/api/zonos-elements/get-checkout-session?${e.toString()}`);return{errors:t,json:o}},{reset:I,state:k}=e((()=>({amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:!1,isEnabled:!1,orderIdCreated:null,remainingBalance:null,useFullBalance:!0}))),T=()=>{I()},N=e=>{p("Store credit balance from session","info",e),k.availableBalance=e},j=async()=>{var e,t;const{errors:o,json:n}=await A();if(o.length||!n)return void y("Failed to refresh store credit balance");const r=null!==(t=null===(e=n.checkoutSession.customerProfile)||void 0===e?void 0:e.storeCreditBalance)&&void 0!==t?t:null;N(r)},P=async()=>{var e;const t=n.checkoutSessionId;if(!t){const e="No checkout session found";return y(e),k.error=e,{error:e,success:!1}}p("Applying store credit","info",{checkoutSessionId:t}),k.isApplying=!0,k.error=null;try{const{errors:o,json:n}=await h("/api/zonos-elements/store-credit/apply",{body:{checkoutSessionId:t},method:"POST"});if(o.length>0||!n){const t=(null===(e=o[0])||void 0===e?void 0:e.message)||"Failed to apply store credit";return y(t),k.error=t,k.isApplying=!1,{error:t,success:!1}}return k.appliedAmount=n.amountApplied,k.remainingBalance=n.remainingBalance,k.isApplying=!1,p("Store credit applied","info",{amountApplied:n.amountApplied,remainingBalance:n.remainingBalance}),{error:null,success:!0}}catch(e){const t=e instanceof Error?e.message:"Failed to apply store credit";return y(t),k.error=t,k.isApplying=!1,{error:t,success:!1}}},E=e=>{k.isEnabled=e,k.error=null,e||(k.amountToApply=null)},D=e=>{if(null===e)return k.amountToApply=null,void(k.error=null);e<=0?k.error="Amount must be greater than zero":null!==k.availableBalance&&e>k.availableBalance?k.error="Amount exceeds available balance":e>Ue.total+(Ue.storeCredit||0)?k.error="Amount exceeds order total":(k.error=null,k.amountToApply=e)},L=e=>{if(k.useFullBalance=e,k.error=null,e&&null!==k.availableBalance){const e=Math.min(k.availableBalance,Ue.total+(Ue.storeCredit||0));k.amountToApply=e}else e||(k.amountToApply=null)},x=()=>k.isEnabled&&null!==k.availableBalance?k.useFullBalance?Math.min(k.availableBalance,Ue.total+(Ue.storeCredit||0)):k.amountToApply||0:0,R=()=>null!==k.amountToApply&&k.amountToApply>0&&Ue.storeCredit>0&&Ue.total<=0,_=async()=>{var e,t,o;const r=n.checkoutSessionId;if(!r){const e="No checkout session found";return y(e),k.error=e,{error:e,orderId:null,success:!1}}p("Creating store credit order","info",{checkoutSessionId:r});try{const{errors:n,json:s}=await h("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:r},method:"POST"});if(n.length>0||!s){const t=(null===(e=n[0])||void 0===e?void 0:e.message)||"Failed to create store credit order";return y(t),k.error=t,{error:t,orderId:null,success:!1}}const i=(null===(o=null===(t=s.checkoutSessionStoreCreditOrderCreate)||void 0===t?void 0:t.order)||void 0===o?void 0:o.id)||null;return k.orderIdCreated=i,p("Store credit order created","info",{orderId:i}),{error:null,orderId:i,success:!0}}catch(e){const t=e instanceof Error?e.message:"Failed to create store credit order";return y(t),k.error=t,{error:t,orderId:null,success:!1}}},U=["termsAndConditions","privacyPolicy","refundPolicy","shippingPolicy","warrantyPolicy"],z={privacyPolicy:"Privacy policy",refundPolicy:"Refund policy",shippingPolicy:"Shipping policy",termsAndConditions:"Terms and conditions",warrantyPolicy:"Warranty policy"},{reset:B,state:F}=e({accepted:!1,acceptedAt:null,locked:!1,showError:!1}),q=()=>{const e=t.checkoutSettings.merchantPolicyLinks;return e?U.reduce(((t,o)=>{var n,s;const i=null===(s=null===(n=e[o])||void 0===n?void 0:n.link)||void 0===s?void 0:s.trim();return i&&/^https?:\/\//i.test(i)?(t.push({key:o,name:r(z[o]),url:i}),t):t}),[]):[]},J=()=>q().length>0,M=({companyName:e,countryCode:t,shouldRequirePeruTaxId:o,taxIdType:n})=>{var r;const s=c({countryCode:t,shouldRequirePeruTaxId:o}),i=null!==(r=null==s?void 0:s.find((e=>e.value===n)))&&void 0!==r?r:null,a=(({companyName:e,countryCode:t,shouldRequirePeruTaxId:o})=>!!l({countryCode:t,shouldRequirePeruTaxId:o})||(u.includes(t)?e.trim().length>0:m(t)))({companyName:e,countryCode:t,shouldRequirePeruTaxId:o});return{rendered:a,selectedType:i,send:a&&(!s||!!i),typeOptions:s}},W=e=>{const{selectedType:t,send:n}=M({companyName:ie.companyName,countryCode:e,shouldRequirePeruTaxId:o(),taxIdType:ie.taxIdType});return n?Object.assign({taxId:ie.taxId},t?{taxIdType:t.value}:{}):null},$=({firstName:e,lastName:t,name:o})=>{var n;if(!o&&!e&&!t)return{firstName:"",lastName:""};const r=(null==o?void 0:o.split(/\s+/))||[];return{firstName:(null==e?void 0:e.trim())||(null===(n=r[0])||void 0===n?void 0:n.trim())||"",lastName:(null==t?void 0:t.trim())||r.slice(1).join(" ").trim()||""}},Y=e=>{const t=W(e);return t?Object.assign({shipToTaxId:t.taxId},t.taxIdType?{shipToTaxIdType:t.taxIdType}:{}):{}},H=({currentAddress:e,translatedAddress:t})=>{var o,n,r,s,i,a;const{city:d,country:l,line1:c,line2:u,postal_code:m,state:p}=e.value.address,v=e.value.name||[e.value.firstName,e.value.lastName].join(" ");return{city:(null===(o=t.city)||void 0===o?void 0:o[d])||d,country:l,line1:(null===(n=t.line1)||void 0===n?void 0:n[c])||c,line2:(null===(r=t.line2)||void 0===r?void 0:r[u||""])||u||"",name:(null===(s=t.name)||void 0===s?void 0:s[v])||v,phone:e.value.phone||"",postal_code:(null===(i=t.postal_code)||void 0===i?void 0:i[m])||m,state:(null===(a=t.state)||void 0===a?void 0:a[p])||p}},K=e=>{var t;const o="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),r=ie.stripeLinkEventData,i=ie.stripeAddressEventData,a=ie.stripeShippingSameAsBilling?ie.stripeAddressEventData:ie.stripeBillingAddressEventData;if(!i||!a)throw new Error("Missing stripe address data");const d=H({currentAddress:i,translatedAddress:ie.translatedAddress.address}),{firstName:l,lastName:c}=$({name:d.name}),u=H({currentAddress:a,translatedAddress:ie.translatedAddress.address}),{firstName:m,lastName:p}=$({name:u.name}),v=s()||"US",h=Y(d.country);return Object.assign(Object.assign({billingAddress:{addressLine1:u.line1,addressLine2:u.line2||"",city:u.city,country:u.country,postalCode:u.postal_code,state:u.state},billingContact:{firstName:m,lastName:p,phone:u.phone},cartCurrencyCode:null===(t=Ue.items[0])||void 0===t?void 0:t.currencyCode,cartId:e,checkoutSessionCountry:v,checkoutSessionId:n.checkoutSessionId||"",contact:{companyName:ie.companyName,email:null==r?void 0:r.value.email,firstName:l,lastName:c,phone:d.phone},isTest:!!o,landedCostAdjustments:Ue.promoCode?[{amount:0,productId:null,promoCode:Ue.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:ie.shortAddressCode},h),{shippingAddress:{addressLine1:d.line1,addressLine2:d.line2,city:d.city,country:d.country,postalCode:d.postal_code,state:d.state}})},G=()=>{const e="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),t=ie.stripeLinkEventData,o=ie.stripeAddressEventData,r=ie.stripeShippingSameAsBilling?ie.stripeAddressEventData:ie.stripeBillingAddressEventData;if(p({stripeAddressData:o,stripeBillingAddressData:r},"info"),!o||!r)throw new Error("Missing stripe address data");const s=H({currentAddress:o,translatedAddress:ie.translatedAddress.address}),{firstName:i,lastName:a}=$({name:s.name}),d=H({currentAddress:r,translatedAddress:ie.translatedAddress.address}),{firstName:l,lastName:c}=$({name:d.name}),u=Ue.adjustments.map((e=>({amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}))),m=Ue.promoCode?[{amount:0,productId:null,promoCode:Ue.promoCode,sku:null,type:"PROMO_CODE"},...u]:u,v=Y(s.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:{firstName:l,lastName:c,phone:d.phone},checkoutSessionId:n.checkoutSessionId||"",contact:{companyName:ie.companyName,email:null==t?void 0:t.value.email,firstName:i,lastName:a,phone:s.phone},isTest:e,items:Ue.items,landedCostAdjustments:m,shipToShortAddressCode:ie.shortAddressCode},v),{shippingAddress:{addressLine1:s.line1,addressLine2:s.line2,city:s.city,country:s.country,postalCode:s.postal_code,state:s.state}})};const Z=async e=>{const o=window.Zonos.cartId;if(!o)return await(async e=>{var o;const n=t.checkoutSettings.buildLandedCost;if(n){const e=await(async e=>{var t,o,n,r,s;const i=G(),a=await e({billingAddress:i.billingAddress,billingContact:i.billingContact,checkoutSessionId:i.checkoutSessionId,contact:i.contact,landedCostAdjustments:i.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:i.shippingAddress,zonosApiRoute:w.vercel},{promoCode:Ue.promoCode});if(!a||!(null===(t=a.checkoutSessionWorkflow)||void 0===t?void 0:t.length)&&(null===(o=a.errors)||void 0===o?void 0:o.length))throw new Error(`Failed to build landed cost: ${(null===(r=null===(n=null==a?void 0:a.errors)||void 0===n?void 0:n[0])||void 0===r?void 0:r.message)||"Unknown error"}`);const{errors:d,json:l}=await h("/api/zonos-elements/validate-landed-cost",{body:a,headers:{"Content-Type":"application/json"},method:"POST"});if(!l||d.length)throw new Error(`Invalid landed cost object: ${(null===(s=d.find(Boolean))||void 0===s?void 0:s.message)||"Unknown error"}`);return a})(n);return e}const{errors:r,json:s}=await h("/api/zonos-elements/calculate-landed-cost",{body:G(),method:"POST",signal:null==e?void 0:e.signal});if(r.length||!s){if("The user aborted a request."===(null===(o=r[0])||void 0===o?void 0:o.message))throw new Error("The landed cost calculation request was aborted to initiate a new one.");if(r.forEach((e=>{console.warn(`Error calculating landed cost: ${e.message}`)})),!s)throw new Error("Failed to calculate landed cost");return s}return s})(e);const n=await(async({abortController:e,cartId:t})=>{var o,n,r,s,i;const{errors:a,json:d}=await h("/api/zonos-elements/cart-calculate-landed-cost",{body:K(t),method:"POST",signal:null==e?void 0:e.signal});if(a.length||!d){const e="string"==typeof(null===(o=a[0])||void 0===o?void 0:o.message)&&("The user aborted a request."===(null===(n=a[0])||void 0===n?void 0:n.message)||(null===(r=a[0])||void 0===r?void 0:r.message.includes("signal is aborted"))||(null===(s=a[0])||void 0===s?void 0:s.message.includes("The operation was aborted"))||(null===(i=a[0])||void 0===i?void 0:i.message.includes("Fetch is aborted")));throw new Error(e?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost")}return d})({abortController:e,cartId:o}),{cartWorkflow:r}=n,s=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(n,["cartWorkflow"]);return Object.assign(Object.assign({},s),{itemCreateWorkflow:r.items})},V=async({checkoutSessionId:e,eventName:o,metadata:n})=>{var r,s;const a=Date.now(),d=[...window.Zonos.trackEventLogs];window.Zonos.trackEventLogs.push({checkoutSessionId:e,eventCreated:a,eventName:o});const l=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!(null===(r=window.Zonos)||void 0===r?void 0:r.zonosQaUrl)||!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug);if((f()||g()||l)&&!window.Zonos.zonosConversionTest)return;const c=i.selectedCountryCode,u=t.organizationId;if(!e)return void b({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No checkout session id found`],metadata:{allLogs:v,checkoutSessionId:e,eventName:o,metadata:n,organizationId:u,trackEventLogs:d}});u||b({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No organization id found`],metadata:{allLogs:v,checkoutSessionId:e,eventName:o,metadata:n,organizationId:u,trackEventLogs:d}});const m={checkoutSessionId:e,countryCode:c,eventCreated:a,eventName:o,metadata:Object.assign(Object.assign({},n),{trackEventLogs:d}),organizationId:u};await h("/api/zonos-elements/track-conversion-event",{body:m,method:"POST"})},Q=({address:e,invalidAdddressList:t})=>{if(!e)return;if(!t)return;const o={};return t.city&&(o.city=e.city),t.line1&&(o.line1=e.line1),t.line2&&(o.line2=e.line2),t.postal_code&&(o.postal_code=e.postal_code),t.state&&(o.state=e.state),t.name&&(o.name=e.name),Object.keys(o).length?o:void 0},X=e=>e.sort(((e,t)=>e.amount-t.amount)),ee=async()=>{var e,t;const{errors:o,json:n}=await A();return o.length||!n?(y("Failed to retrieve checkout session info before confirming payment ",o),b({endpoint:"validateCheckoutSession",errors:o.map((e=>e.message)),metadata:{allLogs:v}}),{errorMessage:r("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:!1}):(null===(e=n.checkoutSession.order)||void 0===e?void 0:e.id)&&!n.checkoutSession.completedAt||(null===(t=n.checkoutSession.landedCost)||void 0===t?void 0:t.id)?{errorMessage:"",valid:!0}:(y("Landed cost is not found in the checkout session before confirming payment."),b({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:v}}),{errorMessage:r('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:!1})},te=({theme:e})=>{const o={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:t.appearance.fontSizeInputValue?`${t.appearance.fontSizeInputValue}px`:void 0,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:t.appearance.fontSizeInputLabel?`${t.appearance.fontSizeInputLabel}px`:void 0},".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"}};return"DARK"===e?Object.assign(Object.assign({},o),{".Action":Object.assign(Object.assign({},o[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},o[".PickerItem--new"]),{color:"white"})}):o},oe=({borderStyle:e,theme:t})=>"DARK"===t?{borderRadius:O({overrideBorderStyle:e}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"}:{borderRadius:O({overrideBorderStyle:e}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"},ne={Airwallex:"AIRWALLEX",Paypal:"PAYPAL",Stripe:"STRIPE"},{onChange:re,reset:se,state:ie}=e((()=>({checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:!1,isFetchingLandedCost:!1,isFetchingSession:!1,partyBillingId:null,partyShippingId:null,shortAddressCode:"",shouldInventoryRefund:!1,shouldRenderPayInUsdButton:!1,skipPaymentIntent:"0"!==new URLSearchParams(window.location.search).get("skipPaymentIntent"),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:!0,taxId:"",taxIdType:"",taxIdTypeUsedWhenAsyncAddressUpdate:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}))),ae=()=>{window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")},de=e=>{window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))},le=()=>{const e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return S(e)},ce=async e=>{var o,n;const r=ie.clientSecret;if(!ie.stripe)return void p("Skip. Stripe is not initialized");const s=(({clientSecret:e,overrideBorderRadius:o,overridePrimaryColor:n,overrideSecondaryColor:r,overrideTheme:s,paypalEnabled:a})=>{const d=n||t.appearance.colorPrimary,l=r||t.appearance.colorSecondary,c=(window.Zonos.isCollect||window.Zonos.isInvoice?"DARK"===t.appearance.theme:d&&C(d))?"night":"flat",u="DARK"===s?"night":"flat",m=a?["external_paypal"]:[],p=(null==e?void 0:e.includes("_secret_"))?e:void 0;return{appearance:{labels:"floating",rules:Object.assign({},te({theme:s||"LIGHT"})),theme:s?u:c,variables:Object.assign(Object.assign({},oe({borderStyle:o,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:p,customerSessionClientSecret:ie.stripeCustomerSessionClientSecret||void 0,externalPaymentMethodTypes:[...m],locale:i.selectedLocale}})({clientSecret:r,overrideBorderRadius:null==e?void 0:e.overrideBorderRadius,overridePrimaryColor:null==e?void 0:e.overridePrimaryColor,overrideSecondaryColor:null==e?void 0:e.overrideSecondaryColor,overrideTheme:null==e?void 0:e.overrideTheme,paypalEnabled:null==e?void 0:e.paypalEnabled}),a=JSON.stringify(s)===JSON.stringify(ie.stripeElementsOptions);if(!ie.stripeElements||!ie.stripeElementsForBillingAddress)return ie.stripeElementsForBillingAddress=null===(o=ie.stripe)||void 0===o?void 0:o.elements(s),p("Stripe elements for billing address initialized"),ie.stripeElements=null===(n=ie.stripe)||void 0===n?void 0:n.elements(s),ie.stripeElementsOptions=s,void p("Stripe elements initialized");a||(ie.stripeElements.update(s),ie.stripeElementsForBillingAddress.update(s),ie.stripeElementsOptions=s,ie.stripeElements.fetchUpdates()),p("Stripe elements updated")},ue=()=>{sessionStorage.removeItem("zonos--client-secret"),se(),ie.stripe=window.Zonos.stripe},me=({address:e,firstName:t,lastName:o,name:r,phone:s})=>{const{firstName:i,lastName:a}=$({firstName:t,lastName:o,name:r});return i&&a||b({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId,firstName:t,lastName:o,name:r}}),s||b({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId,phone:s}}),{city:e.city,country:e.country,firstName:i,lastName:a,line1:e.line1,line2:e.line2,phone:s||"",postal_code:e.postal_code,state:e.state}},pe=async()=>{var e,t,o,r,s;if(!(null===(e=ie.stripeAddressEventData)||void 0===e?void 0:e.complete)||!ie.stripeShippingSameAsBilling&&!(null===(t=ie.stripeBillingAddressEventData)||void 0===t?void 0:t.complete)||!ie.stripeBillingAddressEventData)return{partiesCreated:!1};if(!Ue.landedCostData)return{partiesCreated:!1};const i=null===(o=Ue.landedCostData.find(Boolean))||void 0===o?void 0:o.landedCost.rootId;if(!i)return b({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId}}),{partiesCreated:!1};const a=(()=>{var e,t,o,n,r,s,i,a;const d=null===(e=Ue.partiesData.find((e=>"DESTINATION"===e.type)))||void 0===e?void 0:e.id,l=null===(t=Ue.partiesData.find((e=>"PAYOR"===e.type)))||void 0===t?void 0:t.id;if(!d||!l)return!1;if(ie.partyShippingId!==d||ie.partyBillingId!==l)return!0;const c=JSON.stringify(null===(o=ie.stripeLinkUsedWhenFetchingLC)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=ie.stripeLinkEventData)||void 0===n?void 0:n.value),u=JSON.stringify(null===(r=ie.stripeAddressUsedWhenAsyncAddressUpdate)||void 0===r?void 0:r.value)!==JSON.stringify(null===(s=ie.stripeAddressEventData)||void 0===s?void 0:s.value),m=!ie.stripeShippingSameAsBilling&&JSON.stringify(null===(i=ie.stripeBillingAddressUsedWhenAsyncAddressUpdate)||void 0===i?void 0:i.value)!==JSON.stringify(null===(a=ie.stripeBillingAddressEventData)||void 0===a?void 0:a.value);return c||u||m||ie.taxIdUsedWhenAsyncAddressUpdate!==ie.taxId||ie.taxIdTypeUsedWhenAsyncAddressUpdate!==ie.taxIdType||ie.companyNameUsedWhenAsyncAddressUpdate!==ie.companyName})();if(!a)return{partiesCreated:!1};const d=me({address:ie.stripeAddressEventData.value.address,firstName:ie.stripeAddressEventData.value.firstName,lastName:ie.stripeAddressEventData.value.lastName,name:ie.stripeAddressEventData.value.name,phone:ie.stripeAddressEventData.value.phone}),l=ie.stripeShippingSameAsBilling?d:me({address:ie.stripeBillingAddressEventData.value.address,firstName:ie.stripeBillingAddressEventData.value.firstName,lastName:ie.stripeBillingAddressEventData.value.lastName,name:ie.stripeBillingAddressEventData.value.name,phone:ie.stripeBillingAddressEventData.value.phone}),c="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),u=W(d.country),{errors:m,json:p}=await h("/api/zonos-elements/create-parties",{body:Object.assign({address:d,billingAddress:l,companyName:ie.companyName,email:(null===(r=ie.stripeLinkEventData)||void 0===r?void 0:r.value.email)||"",isTest:c,rootId:i,shortAddressCode:ie.shortAddressCode,taxId:null!==(s=null==u?void 0:u.taxId)&&void 0!==s?s:""},(null==u?void 0:u.taxIdType)?{taxIdType:u.taxIdType}:{}),method:"POST"});return m.length||!p?(y("Error occurs when creating parties",JSON.stringify(m,null,2)),b({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId,errors:m,json:p}}),{partiesCreated:!1}):(ie.companyNameUsedWhenAsyncAddressUpdate=ie.companyName,ie.stripeAddressUsedWhenAsyncAddressUpdate=ie.stripeAddressEventData,ie.stripeBillingAddressUsedWhenAsyncAddressUpdate=ie.stripeBillingAddressEventData,ie.taxIdTypeUsedWhenAsyncAddressUpdate=ie.taxIdType,ie.taxIdUsedWhenAsyncAddressUpdate=ie.taxId,ie.partyBillingId=p.billToPartyId,ie.partyShippingId=p.shipToPartyId,Ue.partiesData=Ue.partiesData.map((e=>"DESTINATION"===e.type&&e.id!==p.shipToPartyId?Object.assign(Object.assign({},e),{id:p.shipToPartyId}):"PAYOR"===e.type&&e.id!==p.billToPartyId?Object.assign(Object.assign({},e),{id:p.billToPartyId}):e)),{partiesCreated:!0})},ve=e=>({countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}),he=e=>{var o,n;const r=null===(o=t.genericSettings)||void 0===o?void 0:o.countryFields,s=null===(n=t.genericSettings)||void 0===n?void 0:n.stripeCountryFieldLabels;return"stripe"===Ue.addressFormRenderType&&(s&&e in s?s[e]:null)||(r&&e in r?r[e]:null)},ye=async e=>{var t,o,r,s;const i=(null==e?void 0:e.retries)||0,a=!!(null==e?void 0:e.applyingPromocode),d=(()=>{var e;const t=Ue.landedCostData&&(null===(e=Ue.landedCostData.find(Boolean))||void 0===e?void 0:e.subtotals.items)!==Ue.subtotal,o=(()=>{var e,t;const o=JSON.stringify(null===(e=ie.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=ie.stripeLinkEventData)||void 0===t?void 0:t.value),n=ie.stripeAddressEventData&&JSON.stringify(ve(ie.stripeAddressEventData.value))!==JSON.stringify(ie.stripeAddressUsedWhenFetchingLC),r=!ie.stripeShippingSameAsBilling&&ie.stripeBillingAddressEventData&&JSON.stringify(ve(ie.stripeBillingAddressEventData.value))!==JSON.stringify(ie.stripeBillingAddressUsedWhenFetchingLC);return o||n||r})();return p("isPrefetchInfoOutdated","info",{isAddressOutdated:o}),!Ue.landedCostData&&!ie.isFetchingLandedCost||o||t})(),l=(()=>{var e,t,o,n;const r=!!(null===(e=ie.stripeLinkEventData)||void 0===e?void 0:e.complete),s=!!(null===(t=ie.stripeAddressEventData)||void 0===t?void 0:t.complete),i=ie.stripeShippingSameAsBilling?s:!!(null===(o=ie.stripeBillingAddressEventData)||void 0===o?void 0:o.complete),a=(null===(n=ie.stripeAddressEventData)||void 0===n?void 0:n.value.address.country)||"US",d=he(a);return!!(s&&i&&r)||(d&&ie.stripeAddressEventData?r&&ie.stripeAddressEventData.value.firstName&&ie.stripeAddressEventData.value.lastName&&ie.stripeAddressEventData.value.address.line1.length>0&&(!d.stateRequired||d.stateRequired&&ie.stripeAddressEventData.value.address.state.length>0)&&(!d.zipRequired||d.zipRequired&&ie.stripeAddressEventData.value.address.postal_code.length>=3)&&ie.stripeAddressEventData.value.phone&&ie.stripeAddressEventData.value.phone.length>0:s&&i&&r)})();if(!l)return{isRequestNotReady:!0};if(d&&(null===(t=ie.fetchingLandedCostAbortController)||void 0===t||t.abort(),ie.fetchingLandedCostAbortController=null),!d&&!a)return{isRequestNotReady:!1};i?(ie.isFetchingLandedCost=!1,setTimeout((()=>{ie.isFetchingLandedCost=!0}),300)):ie.isFetchingLandedCost=!0,ie.stripeAddressEventData&&(ie.stripeAddressUsedWhenFetchingLC={countryCode:ie.stripeAddressEventData.value.address.country,postalCode:ie.stripeAddressEventData.value.address.postal_code,state:ie.stripeAddressEventData.value.address.state}),ie.stripeBillingAddressEventData&&(ie.stripeBillingAddressUsedWhenFetchingLC={countryCode:ie.stripeBillingAddressEventData.value.address.country,postalCode:ie.stripeBillingAddressEventData.value.address.postal_code,state:ie.stripeBillingAddressEventData.value.address.state}),ie.stripeLinkEventData&&(ie.stripeLinkUsedWhenFetchingLC=Object.assign({},ie.stripeLinkEventData));try{et(),await(async()=>{var e;const t=new AbortController;ie.fetchingLandedCostAbortController=t,et();const{checkoutSessionWorkflow:o,errors:r,itemCreateWorkflow:s,landedCostCalculateWorkflow:i,partyCreateWorkflow:a,shipmentRatingCalculateWorkflow:d}=await Z(t);Ue.customQuotingError=(null===(e=null==r?void 0:r.find((e=>{var t,o;return"CUSTOM"===(null===(t=e.extensions)||void 0===t?void 0:t.ruleMessageType)||"COUNTRY_CONSTRAINT"===(null===(o=e.extensions)||void 0===o?void 0:o.source)})))||void 0===e?void 0:e.message)||null,Ue.shippingData=X((null==d?void 0:d.filter(Boolean))||[]),qe(s),ie.fetchingLandedCostAbortController=null,Ue.partiesData=(null==a?void 0:a.filter(Boolean))||[],Ue.landedCostData=(null==o?void 0:o.map((e=>{const t=null==i?void 0:i.find((t=>(null==t?void 0:t.id)===e.landedCostId));return t?Object.assign(Object.assign({},e),{landedCost:t}):null})).filter(Boolean))||[],(null==o?void 0:o.length)&&V({checkoutSessionId:n.checkoutSessionId,eventName:"checkout_quoteReceived"});const l=Ue.promoCodeApplied&&!Ue.landedCostData.find((e=>{var t;return null===(t=e.landedCost.appliedAdjustments)||void 0===t?void 0:t.find((e=>"PROMO_CODE"===e.type))}));Ue.promoCodeError=l,l||sessionStorage.setItem("zonos--promo-code",Ue.promoCode)})();const e=null===(o=Ue.shippingData)||void 0===o?void 0:o.find(Boolean),t=null===(r=Ue.landedCostData)||void 0===r?void 0:r.find((t=>t.landedCost.shipmentRating.id===(null==e?void 0:e.id))),s=t?t.subtotals:null;s&&$e({method:(null==t?void 0:t.landedCost.method)||"DDP",subtotals:s})}catch(t){if(Ue.landedCostData=[],Ue.shippingData=[],t instanceof Error&&t.message&&!["The landed cost calculation request was aborted to initiate a new one."].includes(t.message)){if(i<1)return await ye(Object.assign(Object.assign({},e),{retries:(i||0)+1})),{isRequestNotReady:!1};const o=null===(s=ie.stripeAddressEventData)||void 0===s?void 0:s.value;b({endpoint:`Failed to fetch landed cost (${i} retries)`,errors:[t.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:o}})}y(t)}return ie.isFetchingLandedCost=!1,{isRequestNotReady:!1}},we=async()=>{var e,t;await ye({applyingPromocode:!0}),"payment"===Ue.step&&ot(),await pe();const o=null===(e=Ue.shippingData)||void 0===e?void 0:e.find(Boolean),n=null===(t=Ue.landedCostData)||void 0===t?void 0:t.find((e=>e.landedCost.id===(null==o?void 0:o.id)));o&&n&&await Ve({applySubtotalsOnly:!1,landedCostId:n.landedCostId,selectedShippingOption:o})},fe=()=>{Ue.promoCode="",sessionStorage.removeItem("zonos--promo-code"),Ue.promoCodeError=!1,Ue.promoCodeApplied=!1},ge=async()=>{"payment"===Ue.step&&ot(),fe(),await we()},be=e=>{let t=[],o=!0;const n=window.Zonos.isCollect,s=window.Zonos.isInvoice;switch(e){case"succeeded":t=[r("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."),"",r("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.")],(n||s)&&(t=[r("Thank you for submitting your payment. We appreciate your prompt attention."),"",r("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.")]),o=!1;break;case"requires_capture":case"processing":t=[r("Payment processing. We'll update you when payment is received.")],o=!1;break;case"requires_payment_method":t=[r("Payment failed. Please try another payment method.")],n&&(t=[r("Payment failed. Please reload the page and try another payment method.")]);break;case"requires_action":o=!1,t=[r("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")];default:t=[r("Something went wrong.")]}return{isError:o,messages:t}},Se=async()=>{var e,o;const{onInventoryCheck:n}=t.checkoutSettings,s=!!(null===(o=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===o?void 0:o.value);if(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&s){const{errors:e,json:t}=await h("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"});return e.length||!t?(y("Error occurs when handling inventory refund","warn",JSON.stringify(e)),null):t.available&&204!==t.status?t.available||200===t.status?(ie.shouldInventoryRefund=!0,null):null:r("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")}if("function"!=typeof n)return null;try{return await n({items:Ue.items},{translate:r,zonosApiRoute:w.vercel})}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw b({endpoint:"onInventoryCheck",errors:[`cartId: ${window.Zonos.cartId} - ${t}`],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:Ue.items}}),e}},Ce=async()=>{var e,t;const o=!!(null===(t=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===t?void 0:t.value);window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o&&await h("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})},Oe=async({clientSecret:e,storybookForceStatus:t})=>{if(t){const{isError:e,messages:o}=be(t);return{error:e,messages:o}}const o=e||ie.clientSecret;if(!ie.stripe||!o)return y("Failed to retrieve payment intent. Stripe is not initialized"),{error:!0,message:[r("Something went wrong.")]};if(!o.includes("_secret_"))return{error:!0,messages:[r("Something went wrong.")]};const{paymentIntent:n}=await ie.stripe.retrievePaymentIntent(o),s=null==n?void 0:n.status,{isError:i,messages:a}=be(s);return{amount:null==n?void 0:n.amount,currency:null==n?void 0:n.currency,error:i,messages:a,paymentIntentId:null==n?void 0:n.id,paymentMethod:null==n?void 0:n.payment_method,status:s}},Ae=async e=>{var t,o;const s=!!(null===(t=ie.stripePaymentEventData)||void 0===t?void 0:t.complete),i=ie.stripeElements,a=ie.stripe,d=ie.clientSecret;if(ie.customErrorMessage=null,!(null===(o=Ue.selectedLandedCost)||void 0===o?void 0:o.landedCost.id)&&!(null==e?void 0:e.noLandedCostCheck))throw new Error("Attempted to confirm the payment when no landed cost is found in store");const l=await ee();if(!l.valid)throw ie.customErrorMessage=l.errorMessage,new Error(l.errorMessage);const c=n.checkoutSessionId;if(a&&i&&s&&d&&c){const e=new URL(window.location.href);e.searchParams.set("payment_intent_client_secret",d),e.searchParams.set("zonosCheckoutSessionId",c),V({checkoutSessionId:c,eventName:"checkout_paymentInfoCompleted"});const{error:t,paymentIntent:o}=await a.confirmPayment({confirmParams:{return_url:e.toString()},elements:i,redirect:"if_required"});if(p("Payment intent confirmed","info",{error:t,paymentIntent:o}),"requires_action"===(null==o?void 0:o.status))throw new Error(r("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."));if(t){if("card_error"===t.type||"validation_error"===t.type)throw new Error(t.message);if("invalid_request_error"===t.type&&"payment_intent_unexpected_state"===t.code)return;throw new Error("An unexpected error occurred.")}if("requires_payment_method"===o.status)throw new Error(r("Payment failed. Please try another payment method."))}},Ie=()=>{const e=new URLSearchParams(window.location.search).get("paymentProcessor");return e&&(t=e,Object.values(ne).some((e=>e===t)))?e:void 0;var t},ke=()=>{var e;const t=Ue.items.reduce(((e,t)=>e+t.amount*t.quantity),0),o=n.enabledVariantTestKeys||[];return{adjustmentsAmount:Ue.adjustments.reduce(((e,t)=>e+t.amount),0),cartId:window.Zonos.cartId,currency:(null===(e=Ue.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",customerAuthenticationToken:Ue.customerAuthenticationToken||void 0,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:t,metadata:[{key:"language",value:i.selectedLocale}],paymentProcessor:Ie(),presentmentCountryCode:i.selectedCountryCode,skipPaymentIntent:ie.skipPaymentIntent,varianceTestInput:o}},Te=async()=>{var e;if(!n.checkoutSessionId)return b({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:v,cartId:window.Zonos.cartId}}),void We({messages:[r("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:r("Error creating Checkout")});const{errors:t,json:o}=await h("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:n.checkoutSessionId},method:"POST"}),s=null===(e=null==o?void 0:o.checkoutSessionPaymentIntentCreate)||void 0===e?void 0:e.clientSecret;if(t.length||!s)return y("Error occurs when getting payment intent",JSON.stringify(t,null,2)),b({endpoint:"Error creating payment intent",errors:t.map((e=>e.message)),metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId,clientSecret:s}}),void We({messages:[r("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:r("Error creating Checkout")});Ke(o.checkoutSessionPaymentIntentCreate)},Ne=async()=>{var e,t;if(!i.targetCurrency)return y("Failed to create checkout session - missing localizationStore.targetCurrency"),!1;ie.isFetchingSession=!0;const o=ke();p("Checkout session body","info",o);const{errors:n,json:r}=await h("/api/zonos-elements/create-checkout-session",{body:o,method:"POST"});if(ie.isFetchingSession=!1,n.length||!r){const t=null===(e=n.find((e=>e.message)))||void 0===e?void 0:e.message;if(Array.isArray(t)&&t.some((e=>"Cart is expired."===e.message)))throw new Error("Cart is expired.");return y("Error occurred when creating checkout session",JSON.stringify(n,null,2)),!1}const s=r.checkoutSessionCreate;return Ke(s),$e({method:(null===(t=s.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:s.subtotals}),p("Exchange rate updated for cart items (checkout session create)","info",Ue.exchangeRate),p("done-init-checkout-session"),!0},je=async()=>{const e=n.checkoutSessionId;if(!e)return y("Failed to update checkout session base currency"),!1;if("LOCAL"===t.checkoutSettings.allowedSettlementCurrencies)return p('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency'),!0;const{json:o}=await h("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:ie.checkoutSettlementCurrency},method:"POST"}),r=null==o?void 0:o.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;return o&&r===ie.checkoutSettlementCurrency?(p(`Updated checkout session to settlement currency "${r}".`),!0):(y("Failed to update checkout session base currency"),!1)},Pe=async({adjustmentsAmount:e,cartId:t,currency:o,id:r,itemsAmount:s,landedCostId:a,presentmentCountryCode:d,storeCreditApplication:l})=>{const c=n.enabledVariantTestKeys||[],{errors:u,json:m}=await h("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:e,billToPartyId:ie.partyBillingId,cartId:t,currency:o,customerAuthenticationToken:Ue.customerAuthenticationToken||void 0,id:r,itemsAmount:s,landedCostId:a,metadata:[{key:"language",value:i.selectedLocale}],presentmentCountryCode:d,shipToPartyId:ie.partyShippingId,skipPaymentIntent:ie.skipPaymentIntent,storeCreditApplication:l,varianceTestInput:c},method:"POST"});return u.length||!m?(y("Error occurs when updating checkout session",JSON.stringify(u,null,2)),{errors:u,json:m}):{errors:[],json:m}},Ee=async()=>{const e=(()=>{if(!F.accepted)return null;const e=q();return e.length?{key:"merchantPolicyConsent",value:JSON.stringify({acceptedAt:F.acceptedAt||(new Date).toISOString(),locale:i.selectedLocale,policies:e.reduce(((e,t)=>(e[t.key]=t.url,e)),{})})}:null})();if(!e)return{errors:[]};if(!n.checkoutSessionId)return{errors:[]};const{errors:t}=await h("/api/zonos-elements/update-checkout-session-metadata",{body:{id:n.checkoutSessionId,metadata:[e]},method:"POST"});return t.length?(y("Failed to record merchant policy consent on checkout session",JSON.stringify(t,null,2)),{errors:t.map((e=>e.message||"Unknown error"))}):{errors:[]}},De=({currentAddress:e,translatedAddressResult:t})=>{const o={};if(!t)return o;const{city:n,line1:r,line2:s,name:i,postal_code:a,state:d}=t;return e.city&&n&&(o.city={[e.city]:n}),e.line1&&r&&(o.line1={[e.line1]:r}),e.line2&&s&&(o.line2={[e.line2]:s}),e.postal_code&&a&&(o.postal_code={[e.postal_code]:a}),e.state&&d&&(o.state={[e.state]:d}),e.name&&i&&(o.name={[e.name]:i}),o},Le=async({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t})=>{var o,n,r,s;const i=(({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:o,stripeBillingAddressEventData:n,stripeShippingSameAsBilling:r})=>{const s=!!(null==o?void 0:o.complete);if(!s||!(r?s:null==n?void 0:n.complete))return null;if(!e&&!t)return null;const i=o.value,a=(null==n?void 0:n.value)||null,{firstName:d,lastName:l}=$({firstName:i.firstName,lastName:i.lastName,name:i.name}),c=`${d} ${l}`,{firstName:u,lastName:m}=$({firstName:null==a?void 0:a.firstName,lastName:null==a?void 0:a.lastName,name:(null==a?void 0:a.name)||""}),p=u&&m?`${u} ${m}`:"",v=i.address,h=null==a?void 0:a.address;return{address:Q({address:Object.assign(Object.assign({},v),{name:c}),invalidAdddressList:e}),billingAddress:r?void 0:Q({address:h?Object.assign(Object.assign({},h),{name:p}):null,invalidAdddressList:t}),destinationCountry:v.country}})({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:ie.stripeAddressEventData,stripeBillingAddressEventData:ie.stripeBillingAddressEventData,stripeShippingSameAsBilling:ie.stripeShippingSameAsBilling});if(!i)return void(ie.translatedAddress={address:{},billingAddress:{}});const a=(()=>{var e,t,o,n;const r=JSON.stringify(null===(e=ie.stripeAddressUsedWhenValidatingAddress)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=ie.stripeAddressEventData)||void 0===t?void 0:t.value),s=!ie.stripeShippingSameAsBilling&&JSON.stringify(null===(o=ie.stripeBillingAddressEventData)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=ie.stripeBillingAddressUsedWhenValidatingAddress)||void 0===n?void 0:n.value);return r||s})();if(!a)return;const{errors:d,json:l}=await h("/api/zonos-elements/validate-address",{body:i,method:"POST"});if(d.length||!l)return y("Error occurs when translating address to latin",JSON.stringify(d,null,2)),void(ie.translatedAddress={address:{},billingAddress:{}});ie.stripeAddressUsedWhenValidatingAddress=ie.stripeAddressEventData,ie.stripeBillingAddressUsedWhenValidatingAddress=ie.stripeBillingAddressEventData;const c=null===(o=ie.stripeAddressEventData)||void 0===o?void 0:o.value.address,u=null===(n=ie.stripeBillingAddressEventData)||void 0===n?void 0:n.value.address;ie.translatedAddress={address:c?De({currentAddress:Object.assign(Object.assign({},c),{name:null===(r=ie.stripeAddressEventData)||void 0===r?void 0:r.value.name}),translatedAddressResult:l.address||null}):{},billingAddress:ie.stripeShippingSameAsBilling?{}:De({currentAddress:Object.assign(Object.assign({},u),{name:null===(s=ie.stripeBillingAddressEventData)||void 0===s?void 0:s.value.name}),translatedAddressResult:l.billingAddress||null})}};re("clientSecret",(e=>{e&&ie.stripe&&sessionStorage.setItem("zonos--client-secret",e),e||sessionStorage.removeItem("zonos--client-secret")}));const xe=({deliveryType:e,landedCost:t,shipToCountry:o})=>"DAP"===t.method&&"POSTAL"===e&&t.remittance.length>0&&!!o&&u.includes(o),{onChange:Re,reset:_e,state:Ue}=e((()=>({addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:!1,checkoutTimeoutInterval:null,currency:"USD",customMessage:[],customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:!1,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:!1,isSelectedShippingGuarantee:!1,isStagingMode:g(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:!1,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:!1,step:"customer-info",storeCredit:0,subtotal:0,tabItems:{"customer-info":{index:1,isDone:!1,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:!1,label:"Shipping",value:"shipping"},payment:{index:3,isDone:!1,label:"Payment",value:"payment"}},total:0}))),ze=e=>{switch(e){case"DAYS":return r("days");case"WEEKS":return r("weeks");default:return r("business days")}},Be=e=>{var t;const o=null===(t=e.shippingProfile)||void 0===t?void 0:t.transitTime;return(null==o?void 0:o.min)&&(null==o?void 0:o.max)&&(null==o?void 0:o.type)?{maxTransit:o.max,minTransit:o.min,unit:ze(o.type)}:null},Fe=({item1:e,item2:t})=>!(!e||!t)&&(t.sku&&e.sku&&e.sku===t.sku||t.description&&e.description&&e.description===t.description||e.name&&t.name&&e.name===t.name),qe=e=>{p("Checking item restrictions");const t=e.map((e=>{if(!e.restriction)return null;const{restriction:t}=e,o=Ue.items.find((t=>Fe({item1:t,item2:e})));return Object.assign(Object.assign({matchedItem:o},e),{restriction:t})})).filter(Boolean);return Ue.restrictedItems=t,Ue.items=Ue.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!!t.find((t=>Fe({item1:t,item2:e})))}))),{cartItems:Ue.items,restrictedItems:t}};let Je=null;const Me=()=>{n.checkoutSessionId=null,Je&&(clearTimeout(Je),Je=null),T(),_e()},We=({messages:e,title:t})=>{Me(),ue(),Ue.step="error",Ue.error={messages:e,title:t}},$e=({dutiesTaxesFeesEstimate:e,method:t,subtotals:o})=>{var n;Ue.exchangeRate=o.exchangeRate,Ue.adjustmentTotal=o.adjustments,Ue.dutiesTaxesFees="DAP"===t?null:o.landedCostTotal,Ue.storeCredit=null!==(n=o.storeCredit)&&void 0!==n?n:0,Ue.subtotal=o.items,Ue.total=o.total,Ue.currency=o.presentmentCurrencyCode,Ue.dutiesTaxesFeesEstimate=e||null},Ye=()=>!!Ue.items.filter((e=>e.amount>0)).find((e=>!e.isRestricted)),He=()=>{var e,t;return!(!(null===(t=null===(e=Ue.checkoutSession)||void 0===e?void 0:e.order)||void 0===t?void 0:t.id)||Ue.checkoutSession.completedAt)},Ke=e=>{var t,o,r,s,i,l,c;ie.clientSecret=e.clientSecret,ie.stripeCustomerSessionClientSecret=e.customerSessionClientSecret,ie.customerProfile=e.customerProfile,Ue.checkoutSession=e,N(null!==(o=null===(t=e.customerProfile)||void 0===t?void 0:t.storeCreditBalance)&&void 0!==o?o:null),e.id||b({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:v,checkoutSession:e}}),e.id&&(n.checkoutSessionId=e.id);const u=a(e.varianceTestResults||[]);d(u);const m=(null===(i=null===(s=null===(r=Ue.checkoutSession)||void 0===r?void 0:r.metadata)||void 0===s?void 0:s.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===i?void 0:i.value)||(null===(c=null===(l=window.Zonos.cartData)||void 0===l?void 0:l.metadata.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===c?void 0:c.value)||null;m&&(p(`Found externalConfirmationPageURL: ${m}`),Ue.externalConfirmationPageURL=m)},Ge=async({adjustmentsAmount:e,cartId:t,currency:o,dutiesTaxesFeesEstimate:s,itemsAmount:a,landedCostId:d,shouldInitSessionOnFailure:l})=>{var c;if(d&&Ue.selectedLandedCost&&($e({dutiesTaxesFeesEstimate:s,method:Ue.landedCostMethod,subtotals:Ue.selectedLandedCost.subtotals}),p("Exchange rate updated for cart items (landed cost subtotal)","info",Ue.exchangeRate)),!n.checkoutSessionId)return p("Could not update cart total without checkout session id","info"),!1;const{errors:u,json:m}=await Pe({adjustmentsAmount:e,cartId:t,currency:o,id:n.checkoutSessionId,itemsAmount:a,landedCostId:d,presentmentCountryCode:i.selectedCountryCode});if(u.length>0||!m){if(y("Error occurs when updating checkout session."),l){p("Initiating checkout session on failure","info");const e=await Ne();return p(`stripeStoreInitCheckoutSession: ${e}`),!!e||(We({messages:[r("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:r("Error creating Checkout")}),!1)}return!1}return d||($e({method:(null===(c=m.checkoutSessionUpdate.landedCost)||void 0===c?void 0:c.method)||"DDP",subtotals:m.checkoutSessionUpdate.subtotals}),p("Exchange rate updated for cart items (checkout session update)","info",Ue.exchangeRate)),Ke(m.checkoutSessionUpdate),!0},Ze=(e,o)=>{var n,r,s,i;return"DAP"===e.method&&(null===(r=null===(n=t.genericSettings)||void 0===n?void 0:n.domesticCountries)||void 0===r?void 0:r.includes((null===(s=ie.stripeAddressEventData)||void 0===s?void 0:s.value.address.country)||"US"))?"DDP":xe({deliveryType:o,landedCost:e,shipToCountry:null===(i=ie.stripeAddressEventData)||void 0===i?void 0:i.value.address.country})?"DAP":"DAP"===e.method&&e.remittance.length&&"ZONOS"===e.landedCostGuaranteeCode?"DDP":e.method},Ve=async({applySubtotalsOnly:e,landedCostId:o,selectedShippingOption:n})=>{var r,s,i,a,d,l,c,u,m,v,h,y;p("Updating selected shipping option","info",{landedCostId:o,selectedShippingOption:n}),Ue.selectedShippingOption=n;const w=Be(Ue.selectedShippingOption);if(w){const{maxTransit:e,minTransit:t,unit:o}=w;Ue.selectedShippingOptionTransitTime=`${t}-${e} ${o}`}else Ue.selectedShippingOptionTransitTime="";const f=null===(r=Ue.landedCostData)||void 0===r?void 0:r.find((e=>e.landedCostId===o));if(Ue.selectedLandedCost=f||null,!f)return!1;const g=((null===(s=f.landedCost.amountSubtotals)||void 0===s?void 0:s.landedCostTotal)||0)*f.subtotals.exchangeRate.rate;g&&p(`DAP quote, using estimate: ${g}`,"info"),Ue.landedCostMethod=Ze(f.landedCost,null===(i=n.shippingProfile)||void 0===i?void 0:i.serviceLevel.deliveryType),Ue.shipping=f.subtotals.shipping;const b="ZONOS"===(null===(a=null==f?void 0:f.landedCost)||void 0===a?void 0:a.landedCostGuaranteeCode),S=!!(null===(l=null===(d=null==f?void 0:f.landedCost)||void 0===d?void 0:d.deMinimis)||void 0===l?void 0:l.find((e=>["DUTY","TAX"].includes(e.type)&&"ABOVE"===e.threshold)));Ue.isSelectedShippingAboveDeminimis=S,Ue.isSelectedShippingGuarantee=b;let C=!1;e?($e({dutiesTaxesFeesEstimate:g,method:Ue.landedCostMethod,subtotals:f.subtotals}),p("Exchange rate updated for cart items (landed cost subtotal)","info",Ue.exchangeRate),C=!0):C=await Ge({adjustmentsAmount:Ue.adjustmentTotal,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:g,landedCostId:null===(c=f.landedCost)||void 0===c?void 0:c.id});const O=null===(u=Ue.items.find(Boolean))||void 0===u?void 0:u.currencyCode,A=(null===(m=ie.stripeAddressEventData)||void 0===m?void 0:m.value.address.country)||"US";return ie.shouldRenderPayInUsdButton="USD"===O&&"LOCAL_AND_USD"===t.checkoutSettings.allowedSettlementCurrencies&&"USD"!==(null===(v=Ue.checkoutSession)||void 0===v?void 0:v.subtotals.presentmentCurrencyCode)&&!!(null===(y=null===(h=t.genericSettings)||void 0===h?void 0:h.usdSettlementCountryEnabled)||void 0===y?void 0:y.includes(A)),C},Qe=({isPreview:e,sessionTimeout:t})=>{if(e)return;const o=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout"),n=o&&!isNaN(parseInt(o,10))?parseInt(o,10):t;p(`==START CHECKOUT TIMEOUT - ${n}==`),Ue.checkoutTimeoutInterval=setTimeout((()=>{Ue.checkoutSessionTimeoutShow=!0}),n)},Xe=()=>{Ue.checkoutTimeoutInterval&&(clearTimeout(Ue.checkoutTimeoutInterval),Ue.checkoutTimeoutInterval=null)},et=()=>{Ue.items=Ue.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1}))),Ue.restrictedItems=[]},tt=async({adjustments:e,cartItems:t,landedCostId:o,shouldInitSessionOnFailure:n=!0})=>{var r;Ue.adjustments=e,Ue.items=t.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1})));const s=null===(r=t.find(Boolean))||void 0===r?void 0:r.currencyCode,i=t.reduce(((e,t)=>e+t.amount*t.quantity),0),a=e.reduce(((e,t)=>e+t.amount),0);s&&i&&(Ue.currency=s,ie.isFetchingSession=!0,await Ge({adjustmentsAmount:a,cartId:window.Zonos.cartId,currency:s,dutiesTaxesFeesEstimate:0,itemsAmount:i,landedCostId:o,shouldInitSessionOnFailure:n}),ie.isFetchingSession=!1)},ot=()=>{"shipping"===Ue.step?(Ue.step="customer-info",Ue.tabItems=Object.assign(Object.assign({},Ue.tabItems),{"customer-info":Object.assign(Object.assign({},Ue.tabItems.shipping),{isDone:!1})})):"payment"===Ue.step?(Ue.step="shipping",Ue.tabItems=Object.assign(Object.assign({},Ue.tabItems),{shipping:Object.assign(Object.assign({},Ue.tabItems.shipping),{isDone:!1})})):"finish"===Ue.step&&(Ue.step="payment",Ue.tabItems=Object.assign(Object.assign({},Ue.tabItems),{payment:Object.assign(Object.assign({},Ue.tabItems.payment),{isDone:!1})}))},nt=()=>{"customer-info"===Ue.step?(Ue.step="shipping",Ue.tabItems=Object.assign(Object.assign({},Ue.tabItems),{"customer-info":Object.assign(Object.assign({},Ue.tabItems["customer-info"]),{isDone:!0})})):"shipping"===Ue.step?(Ue.step="payment",Ue.tabItems=Object.assign(Object.assign({},Ue.tabItems),{shipping:Object.assign(Object.assign({},Ue.tabItems.shipping),{isDone:!0})})):"payment"===Ue.step&&(Ue.step="finish")},rt=()=>{Ue.step="customer-info",Ue.tabItems=Object.assign(Object.assign({},Ue.tabItems),{"customer-info":Object.assign(Object.assign({},Ue.tabItems["customer-info"]),{isDone:!1}),payment:Object.assign(Object.assign({},Ue.tabItems.payment),{isDone:!1}),shipping:Object.assign(Object.assign({},Ue.tabItems.shipping),{isDone:!1})}),Ue.selectedShippingOption=null,Ue.isSelectedShippingAboveDeminimis=!1,Ue.isSelectedShippingGuarantee=!1,Ue.selectedShippingOptionTransitTime="",Ue.dutiesTaxesFees=0,Ue.dutiesTaxesFeesEstimate=0,Ue.shipping=0,Ue.total=Ue.subtotal},st=()=>{Je&&clearTimeout(Je),Je=setTimeout((()=>{Je=null,(async()=>{var e,t;if(!n.checkoutSessionId)return void p("Could not update store credit without checkout session id","info");const o=Ue.selectedLandedCost,r=Ue.currency||(null===(e=Ue.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",s=Ue.adjustments.reduce(((e,t)=>e+t.amount),0),a=Ue.items.reduce(((e,t)=>e+t.amount*t.quantity),0),{errors:d,json:l}=await Pe({adjustmentsAmount:s,cartId:window.Zonos.cartId,currency:r,id:n.checkoutSessionId,itemsAmount:a,landedCostId:null==o?void 0:o.landedCostId,presentmentCountryCode:i.selectedCountryCode,storeCreditApplication:k.isEnabled&&null!==k.amountToApply?k.useFullBalance?{mode:"FULL"}:{amount:k.amountToApply,mode:"PARTIAL"}:{mode:"NONE"}});d.length>0||!l?y("Error updating checkout session with store credit"):($e({method:(null===(t=l.checkoutSessionUpdate.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:l.checkoutSessionUpdate.subtotals}),Ke(l.checkoutSessionUpdate))})()}),300)};export{Ze as $,P as A,R as B,ee as C,_ as D,Ae as E,Ce as F,F as G,ue as H,Re as I,re as J,x as K,Ye as L,xe as M,we as N,ge as O,fe as P,be as Q,k as R,T as S,Ee as T,$ as U,M as V,Le as W,he as X,pe as Y,Ve as Z,Be as _,de as a,X as a0,me as a1,q as a2,E as a3,L as a4,st as a5,D as a6,j as a7,ie as b,Oe as c,Ue as d,tt as e,Me as f,A as g,rt as h,ce as i,Xe as j,Ne as k,Te as l,He as m,Se as n,Qe as o,B as p,ke as q,We as r,le as s,V as t,ae as u,Ke as v,ye as w,nt as x,J as y,je as z}
@@ -1 +0,0 @@
1
- import{d as s}from"./p-DW7I0zOF.js";import{h as t,l as e}from"./p-DE4a-QD5.js";const o={},a={},r=async({attributes:r,checkoutSessionId:i})=>{var u;if(o[i]||(o[i]=new Map),r.forEach((s=>{var t;s.value&&(null===(t=o[i])||void 0===t||t.set(s.key,s.value))})),r.length)return a[i]||(a[i]=(u=i,s((async()=>{var s,a;const r=Array.from((null===(s=o[u])||void 0===s?void 0:s.entries())||[]).map((([s,t])=>({key:s,value:t}))),{errors:i,json:n}=await t("/api/zonos-elements/update-checkout-session-attributes",{body:{attributes:r,id:u},method:"POST"});return i.length?(e("Error updating checkout session attributes",i),{success:!1}):(null===(a=o[u])||void 0===a||a.clear(),{success:!!(null==n?void 0:n.success)})}),1e3,{maxWait:5e3}))),a[i]()};export{r as u}