@zonos/elements 1.3.5 → 1.3.7-alpha.0

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 (411) hide show
  1. package/dist/cjs/ILanguage-d247b45b.js +26 -0
  2. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  3. package/dist/cjs/{localization-d43e1540.js → cart-ecc80eb0.js} +1086 -2
  4. package/dist/cjs/{getBorderRadius-cd7ef574.js → getBorderRadius-834c321d.js} +8 -4
  5. package/dist/cjs/index.cjs.js +0 -21
  6. package/dist/cjs/{isDarkColor-5eda1323.js → isDarkColor-924e6a7a.js} +1 -1
  7. package/dist/cjs/loader.cjs.js +5 -3
  8. package/dist/cjs/{submitGtag-bd6e9b42.js → submitGtag-907e71d3.js} +3 -3
  9. package/dist/cjs/zonos-address_4.cjs.entry.js +301 -0
  10. package/dist/cjs/zonos-badge_2.cjs.entry.js +57 -0
  11. package/dist/cjs/zonos-banner.cjs.entry.js +4 -9
  12. package/dist/cjs/{zonos-button_2.cjs.entry.js → zonos-button_3.cjs.entry.js} +42 -15
  13. package/dist/cjs/zonos-card_2.cjs.entry.js +28 -14
  14. package/dist/cjs/{zonos-cart-items_10.cjs.entry.js → zonos-cart-items_9.cjs.entry.js} +98 -99
  15. package/dist/cjs/zonos-checkout.cjs.entry.js +25 -27
  16. package/dist/cjs/zonos-component.cjs.entry.js +2 -2
  17. package/dist/cjs/zonos-controller.cjs.entry.js +29 -30
  18. package/dist/cjs/zonos-country-flag.cjs.entry.js +42 -0
  19. package/dist/cjs/{zonos-country-flag_4.cjs.entry.js → zonos-country-select_3.cjs.entry.js} +31 -56
  20. package/dist/cjs/zonos-elements.cjs.js +6 -4
  21. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +29 -22
  22. package/dist/cjs/zonos-hello.cjs.entry.js +35 -33
  23. package/dist/cjs/zonos-logo.cjs.entry.js +32 -0
  24. package/dist/cjs/zonos-notification.cjs.entry.js +5 -6
  25. package/dist/cjs/zonos-payment.cjs.entry.js +6 -7
  26. package/dist/cjs/zonos-select-dialog-header_2.cjs.entry.js +45 -0
  27. package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +4 -4
  28. package/dist/cjs/zonos-text.cjs.entry.js +4 -6
  29. package/dist/cjs/{zonosStore-b88b5671.js → zonosStore-49d4c92a.js} +5 -5
  30. package/dist/collection/collection-manifest.json +6 -1
  31. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.js +1 -1
  32. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +13 -8
  33. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/assets/chevronDownIcon.svg +1 -0
  34. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/assets/globe.svg +3 -0
  35. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/assets/zonosIcon.svg +5 -0
  36. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/zonos-checkout-footer.css +126 -0
  37. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/zonos-checkout-footer.js +60 -0
  38. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.js +1 -1
  39. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.css +12 -21
  40. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +4 -5
  41. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.css +11 -1
  42. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +12 -4
  43. package/dist/collection/components/checkout/zonos-checkout/zonos-review/zonos-review.js +3 -3
  44. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +1 -1
  45. package/dist/collection/components/common/zonos-badge/zonos-badge.js +7 -26
  46. package/dist/collection/components/common/zonos-banner/zonos-banner.js +2 -25
  47. package/dist/collection/components/common/zonos-button/zonos-button.css +18 -0
  48. package/dist/collection/components/common/zonos-button/zonos-button.js +9 -28
  49. package/dist/collection/components/common/zonos-card/zonos-card.js +2 -20
  50. package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.css +82 -0
  51. package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.js +218 -0
  52. package/dist/collection/components/common/zonos-collapse/zonos-collapse.js +15 -2
  53. package/dist/collection/components/common/zonos-country-flag/zonos-country-flag.js +1 -20
  54. package/dist/collection/components/common/zonos-country-select/assets/greenCheckDuotone.svg +4 -0
  55. package/dist/collection/components/common/zonos-country-select/zonos-country-select.css +11 -10
  56. package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +7 -11
  57. package/dist/collection/components/common/zonos-custom-message/zonos-custom-message.js +2 -2
  58. package/dist/collection/components/common/zonos-dialog/zonos-dialog.js +3 -3
  59. package/dist/collection/components/common/zonos-icon/zonos-icon.js +4 -4
  60. package/dist/collection/components/common/zonos-language-select/assets/greenCheckDuotone.svg +4 -0
  61. package/dist/collection/components/common/zonos-language-select/zonos-language-select.css +61 -0
  62. package/dist/collection/components/common/zonos-language-select/zonos-language-select.js +58 -0
  63. package/dist/collection/components/common/zonos-logo/zonos-logo.js +2 -21
  64. package/dist/collection/components/common/zonos-notification/zonos-notification.js +3 -26
  65. package/dist/collection/components/common/zonos-select-dialog-header/assets/removeIcon.svg +1 -0
  66. package/dist/collection/components/common/zonos-select-dialog-header/zonos-select-dialog-header.css +45 -0
  67. package/dist/collection/components/common/zonos-select-dialog-header/zonos-select-dialog-header.js +68 -0
  68. package/dist/collection/components/common/zonos-shipping-rich-radio/zonos-shipping-rich-radio.js +1 -1
  69. package/dist/collection/components/common/zonos-spinner/zonos-spinner.js +4 -4
  70. package/dist/collection/components/common/zonos-text/zonos-text.js +4 -24
  71. package/dist/collection/components/common/zonos-tooltip/zonos-tooltip.css +55 -0
  72. package/dist/collection/components/common/zonos-tooltip/zonos-tooltip.js +72 -0
  73. package/dist/collection/components/common/zonos-v-stack/zonos-v-stack.js +2 -21
  74. package/dist/collection/components/component-template/zonos-component/zonos-component.js +1 -1
  75. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/assets/globe.svg +3 -0
  76. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.css +10 -0
  77. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.js +27 -5
  78. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.css +16 -2
  79. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +11 -5
  80. package/dist/collection/components/main/zonos-controller.js +1 -1
  81. package/dist/collection/components/store/checkout/stripe.js +31 -7
  82. package/dist/collection/components/store/hello/localization.js +32 -2
  83. package/dist/collection/components/store/translationStore/strings.arabic.js +18 -0
  84. package/dist/collection/components/store/translationStore/strings.base.js +18 -0
  85. package/dist/collection/components/store/translationStore/strings.chinese.js +18 -0
  86. package/dist/collection/components/store/translationStore/strings.danish.js +18 -0
  87. package/dist/collection/components/store/translationStore/strings.dutch.js +18 -0
  88. package/dist/collection/components/store/translationStore/strings.french.js +18 -0
  89. package/dist/collection/components/store/translationStore/strings.german.js +18 -0
  90. package/dist/collection/components/store/translationStore/strings.hebrew.js +18 -0
  91. package/dist/collection/components/store/translationStore/strings.indonesian.js +18 -0
  92. package/dist/collection/components/store/translationStore/strings.italian.js +18 -0
  93. package/dist/collection/components/store/translationStore/strings.japanese.js +18 -0
  94. package/dist/collection/components/store/translationStore/strings.korean.js +18 -0
  95. package/dist/collection/components/store/translationStore/strings.norwegian.js +18 -0
  96. package/dist/collection/components/store/translationStore/strings.polish.js +18 -0
  97. package/dist/collection/components/store/translationStore/strings.portuguese.js +18 -0
  98. package/dist/collection/components/store/translationStore/strings.russian.js +18 -0
  99. package/dist/collection/components/store/translationStore/strings.spanish.js +18 -0
  100. package/dist/collection/components/store/translationStore/strings.swedish.js +18 -0
  101. package/dist/collection/components/store/translationStore/strings.turkish.js +18 -0
  102. package/dist/collection/components/store/translationStore/strings.vietnamese.js +18 -0
  103. package/dist/collection/components/store/zonosStore.js +4 -4
  104. package/dist/collection/components/stripe/zonos-address/zonos-address.js +63 -24
  105. package/dist/collection/components/stripe/zonos-link-authentication/zonos-link-authentication.js +1 -1
  106. package/dist/collection/components/stripe/zonos-payment/zonos-payment.js +1 -1
  107. package/dist/collection/components/utils/api/prepCalculateLandedCost.js +19 -1
  108. package/dist/collection/components/utils/api/triggerBuildLandedCost.js +11 -5
  109. package/dist/collection/components/utils/getBorderRadius.js +7 -3
  110. package/dist/collection/types/ILanguage.js +22 -0
  111. package/dist/collection/types/generated/graphql.customer.types.js +19 -0
  112. package/dist/collection/types/index.js +0 -1
  113. package/dist/collection/types/styles/Color.js +9 -0
  114. package/dist/components/ILanguage.js +24 -0
  115. package/dist/components/getBorderRadius.js +7 -3
  116. package/dist/components/index.js +0 -1
  117. package/dist/components/isDarkColor.js +1 -1
  118. package/dist/components/{localization.js → stripe.js} +1070 -2
  119. package/dist/components/submitGtag.js +1 -1
  120. package/dist/components/zonos-address2.js +64 -26
  121. package/dist/components/zonos-badge2.js +8 -10
  122. package/dist/components/zonos-banner2.js +3 -9
  123. package/dist/components/zonos-button2.js +10 -12
  124. package/dist/components/zonos-card2.js +3 -5
  125. package/dist/components/zonos-cart-items2.js +1 -1
  126. package/dist/components/zonos-cart-subtotal2.js +14 -9
  127. package/dist/components/zonos-checkbox.d.ts +11 -0
  128. package/dist/components/zonos-checkbox.js +6 -0
  129. package/dist/components/zonos-checkbox2.js +87 -0
  130. package/dist/components/zonos-checkout-finish2.js +15 -7
  131. package/dist/components/zonos-checkout-footer.d.ts +11 -0
  132. package/dist/components/zonos-checkout-footer.js +6 -0
  133. package/dist/components/zonos-checkout-footer2.js +109 -0
  134. package/dist/components/zonos-checkout-payment2.js +2 -3
  135. package/dist/components/zonos-checkout.js +74 -52
  136. package/dist/components/zonos-collapse2.js +16 -3
  137. package/dist/components/zonos-component.js +1 -1
  138. package/dist/components/zonos-controller.js +3 -4
  139. package/dist/components/zonos-country-flag2.js +3 -5
  140. package/dist/components/zonos-country-select2.js +26 -19
  141. package/dist/components/zonos-custom-message2.js +3 -3
  142. package/dist/components/zonos-customer-info2.js +30 -11
  143. package/dist/components/zonos-dialog2.js +4 -4
  144. package/dist/components/zonos-hello-dialog-footer2.js +23 -10
  145. package/dist/components/zonos-hello-dialog2.js +41 -23
  146. package/dist/components/zonos-hello.js +31 -19
  147. package/dist/components/zonos-icon2.js +4 -4
  148. package/dist/components/zonos-language-select.d.ts +11 -0
  149. package/dist/components/zonos-language-select.js +6 -0
  150. package/dist/components/zonos-language-select2.js +87 -0
  151. package/dist/components/zonos-link-authentication2.js +2 -2
  152. package/dist/components/zonos-logo.js +44 -1
  153. package/dist/components/zonos-notification2.js +4 -6
  154. package/dist/components/zonos-payment2.js +2 -2
  155. package/dist/components/zonos-review2.js +4 -5
  156. package/dist/components/zonos-select-dialog-header.d.ts +11 -0
  157. package/dist/components/zonos-select-dialog-header.js +6 -0
  158. package/dist/components/zonos-select-dialog-header2.js +71 -0
  159. package/dist/components/zonos-shipping-rich-radio2.js +2 -2
  160. package/dist/components/zonos-shipping2.js +2 -3
  161. package/dist/components/zonos-spinner2.js +3 -3
  162. package/dist/components/zonos-text2.js +4 -7
  163. package/dist/components/zonos-tooltip.d.ts +11 -0
  164. package/dist/components/zonos-tooltip.js +6 -0
  165. package/dist/components/zonos-tooltip2.js +48 -0
  166. package/dist/components/zonos-v-stack2.js +4 -6
  167. package/dist/components/zonosStore.js +5 -5
  168. package/dist/esm/ILanguage-97790bee.js +24 -0
  169. package/dist/esm/app-globals-0f993ce5.js +3 -0
  170. package/dist/esm/{localization-5d83fde2.js → cart-2a0a6871.js} +1071 -3
  171. package/dist/esm/getBorderRadius-0c7dfcf0.js +20 -0
  172. package/dist/esm/index.js +1 -6
  173. package/dist/esm/{isDarkColor-8696cb70.js → isDarkColor-d0a57fd2.js} +1 -1
  174. package/dist/esm/loader.js +6 -4
  175. package/dist/esm/{submitGtag-776c5e10.js → submitGtag-a38aed23.js} +2 -2
  176. package/dist/esm/zonos-address_4.entry.js +294 -0
  177. package/dist/esm/zonos-badge_2.entry.js +52 -0
  178. package/dist/esm/zonos-banner.entry.js +4 -9
  179. package/dist/esm/{zonos-button_2.entry.js → zonos-button_3.entry.js} +42 -16
  180. package/dist/esm/zonos-card_2.entry.js +28 -14
  181. package/dist/esm/{zonos-cart-items_10.entry.js → zonos-cart-items_9.entry.js} +86 -86
  182. package/dist/esm/zonos-checkout.entry.js +11 -13
  183. package/dist/esm/zonos-component.entry.js +2 -2
  184. package/dist/esm/zonos-controller.entry.js +6 -7
  185. package/dist/esm/zonos-country-flag.entry.js +38 -0
  186. package/dist/esm/{zonos-country-flag_4.entry.js → zonos-country-select_3.entry.js} +31 -55
  187. package/dist/esm/zonos-elements.js +7 -5
  188. package/dist/esm/zonos-hello-dialog.entry.js +15 -8
  189. package/dist/esm/zonos-hello.entry.js +5 -3
  190. package/dist/esm/zonos-logo.entry.js +28 -0
  191. package/dist/esm/zonos-notification.entry.js +5 -6
  192. package/dist/esm/zonos-payment.entry.js +6 -7
  193. package/dist/esm/zonos-select-dialog-header_2.entry.js +40 -0
  194. package/dist/esm/zonos-shipping-rich-radio.entry.js +4 -4
  195. package/dist/esm/zonos-text.entry.js +4 -6
  196. package/dist/esm/{zonosStore-e59617f8.js → zonosStore-dec6bd7e.js} +5 -5
  197. package/dist/esm-es5/ILanguage-97790bee.js +1 -0
  198. package/dist/esm-es5/app-globals-0f993ce5.js +1 -0
  199. package/dist/esm-es5/cart-2a0a6871.js +1 -0
  200. package/dist/esm-es5/getBorderRadius-0c7dfcf0.js +1 -0
  201. package/dist/esm-es5/index.js +0 -1
  202. package/dist/esm-es5/{isDarkColor-8696cb70.js → isDarkColor-d0a57fd2.js} +1 -1
  203. package/dist/esm-es5/loader.js +1 -1
  204. package/dist/esm-es5/submitGtag-a38aed23.js +1 -0
  205. package/dist/esm-es5/zonos-address_4.entry.js +1 -0
  206. package/dist/esm-es5/zonos-badge_2.entry.js +1 -0
  207. package/dist/esm-es5/zonos-banner.entry.js +1 -1
  208. package/dist/esm-es5/zonos-button_3.entry.js +1 -0
  209. package/dist/esm-es5/zonos-card_2.entry.js +1 -1
  210. package/dist/esm-es5/zonos-cart-items_9.entry.js +1 -0
  211. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  212. package/dist/esm-es5/zonos-component.entry.js +1 -1
  213. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  214. package/dist/esm-es5/zonos-country-flag.entry.js +1 -0
  215. package/dist/esm-es5/zonos-country-select_3.entry.js +1 -0
  216. package/dist/esm-es5/zonos-elements.js +1 -1
  217. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  218. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  219. package/dist/esm-es5/zonos-logo.entry.js +1 -0
  220. package/dist/esm-es5/zonos-notification.entry.js +1 -1
  221. package/dist/esm-es5/zonos-payment.entry.js +1 -1
  222. package/dist/esm-es5/zonos-select-dialog-header_2.entry.js +1 -0
  223. package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
  224. package/dist/esm-es5/zonos-text.entry.js +1 -1
  225. package/dist/esm-es5/{zonosStore-e59617f8.js → zonosStore-dec6bd7e.js} +1 -1
  226. package/dist/scripts/insertTranslations.js +1 -0
  227. package/dist/scripts/loadZonos.js +1 -1
  228. package/dist/scripts/zonos.js +1 -1
  229. package/dist/scripts/zonosBase.js +1 -1
  230. package/dist/types/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.d.ts +2 -1
  231. package/dist/types/components/checkout/zonos-checkout/zonos-checkout-footer/zonos-checkout-footer.d.ts +7 -0
  232. package/dist/types/components/common/zonos-badge/zonos-badge.d.ts +1 -5
  233. package/dist/types/components/common/zonos-banner/zonos-banner.d.ts +0 -4
  234. package/dist/types/components/common/zonos-button/zonos-button.d.ts +1 -5
  235. package/dist/types/components/common/zonos-card/zonos-card.d.ts +0 -4
  236. package/dist/types/components/common/zonos-checkbox/zonos-checkbox.d.ts +42 -0
  237. package/dist/types/components/common/zonos-country-flag/zonos-country-flag.d.ts +0 -4
  238. package/dist/types/components/common/zonos-country-select/zonos-country-select.d.ts +1 -1
  239. package/dist/types/components/common/zonos-icon/zonos-icon.d.ts +1 -1
  240. package/dist/types/components/common/zonos-language-select/zonos-language-select.d.ts +9 -0
  241. package/dist/types/components/common/zonos-logo/zonos-logo.d.ts +0 -4
  242. package/dist/types/components/common/zonos-notification/zonos-notification.d.ts +0 -4
  243. package/dist/types/components/common/zonos-select-dialog-header/zonos-select-dialog-header.d.ts +12 -0
  244. package/dist/types/components/common/zonos-spinner/zonos-spinner.d.ts +1 -1
  245. package/dist/types/components/common/zonos-text/zonos-text.d.ts +1 -5
  246. package/dist/types/components/common/zonos-tooltip/zonos-tooltip.d.ts +12 -0
  247. package/dist/types/components/common/zonos-v-stack/zonos-v-stack.d.ts +0 -4
  248. package/dist/types/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.d.ts +5 -0
  249. package/dist/types/components/hello/zonos-hello-dialog/zonos-hello-dialog.d.ts +2 -0
  250. package/dist/types/components/store/checkout/stripe.d.ts +12 -0
  251. package/dist/types/components/store/hello/localization.d.ts +2 -1
  252. package/dist/types/components/store/translationStore/strings.arabic.d.ts +18 -0
  253. package/dist/types/components/store/translationStore/strings.base.d.ts +18 -0
  254. package/dist/types/components/store/translationStore/strings.chinese.d.ts +18 -0
  255. package/dist/types/components/store/translationStore/strings.danish.d.ts +18 -0
  256. package/dist/types/components/store/translationStore/strings.dutch.d.ts +18 -0
  257. package/dist/types/components/store/translationStore/strings.french.d.ts +18 -0
  258. package/dist/types/components/store/translationStore/strings.german.d.ts +18 -0
  259. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +18 -0
  260. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +18 -0
  261. package/dist/types/components/store/translationStore/strings.italian.d.ts +18 -0
  262. package/dist/types/components/store/translationStore/strings.japanese.d.ts +18 -0
  263. package/dist/types/components/store/translationStore/strings.korean.d.ts +18 -0
  264. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +18 -0
  265. package/dist/types/components/store/translationStore/strings.polish.d.ts +18 -0
  266. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +18 -0
  267. package/dist/types/components/store/translationStore/strings.russian.d.ts +18 -0
  268. package/dist/types/components/store/translationStore/strings.spanish.d.ts +18 -0
  269. package/dist/types/components/store/translationStore/strings.swedish.d.ts +18 -0
  270. package/dist/types/components/store/translationStore/strings.turkish.d.ts +18 -0
  271. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +18 -0
  272. package/dist/types/components/store/zonosStore.d.ts +1 -1
  273. package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +3 -0
  274. package/dist/types/components/utils/api/triggerBuildLandedCost.d.ts +18 -2
  275. package/dist/types/components/utils/changeDeepProperty.d.ts +1 -1
  276. package/dist/types/components/utils/changeDeepPropertyAtIndex.d.ts +1 -1
  277. package/dist/types/components/utils/getBorderRadius.d.ts +1 -1
  278. package/dist/types/components/utils/hello/currencyConversion/getLanguageCode.d.ts +1 -1
  279. package/dist/types/components.d.ts +242 -116
  280. package/dist/types/types/ICountryJson.d.ts +2 -1
  281. package/dist/types/types/ILanguage.d.ts +81 -0
  282. package/dist/types/types/checkout/CheckoutConfig.d.ts +3 -3
  283. package/dist/types/types/checkout/api/CalculateLandedCostRequest.d.ts +13 -0
  284. package/dist/types/types/generated/graphql.customer.types.d.ts +31 -4
  285. package/dist/types/types/generated/graphql.customer.types.ts +45 -4
  286. package/dist/types/types/generated/graphql.frontend.types.d.ts +5 -5
  287. package/dist/types/types/generated/graphql.frontend.types.ts +13 -3
  288. package/dist/types/types/index.d.ts +1 -1
  289. package/dist/types/types/styles/Color.d.ts +2 -0
  290. package/dist/zonos-elements/index.esm.js +0 -1
  291. package/dist/zonos-elements/p-0057e374.entry.js +1 -0
  292. package/dist/zonos-elements/{p-120df5be.system.entry.js → p-06652d87.system.entry.js} +1 -1
  293. package/dist/zonos-elements/p-066c5893.system.js +1 -0
  294. package/dist/zonos-elements/p-0c72fb79.system.entry.js +1 -0
  295. package/dist/zonos-elements/p-16ad90ca.js +1 -0
  296. package/dist/zonos-elements/p-1f85a98c.system.entry.js +1 -0
  297. package/dist/zonos-elements/p-290c3670.entry.js +1 -0
  298. package/dist/zonos-elements/p-2d2e1831.entry.js +1 -0
  299. package/dist/zonos-elements/p-2f1e1cbb.system.entry.js +1 -0
  300. package/dist/zonos-elements/p-33080cde.system.entry.js +1 -0
  301. package/dist/zonos-elements/{p-0024f8c2.js → p-34c03be2.js} +1 -1
  302. package/dist/zonos-elements/p-34efed1d.entry.js +1 -0
  303. package/dist/zonos-elements/p-375c472a.system.entry.js +1 -0
  304. package/dist/zonos-elements/p-50ea2036.system.js +1 -0
  305. package/dist/zonos-elements/p-549c181b.system.js +1 -0
  306. package/dist/zonos-elements/{p-be23cc91.system.entry.js → p-55970b10.system.entry.js} +1 -1
  307. package/dist/zonos-elements/p-561e44d6.entry.js +1 -0
  308. package/dist/zonos-elements/p-56ba5cbf.system.js +1 -0
  309. package/dist/zonos-elements/{p-dc09ca69.system.js → p-591eb6dd.system.js} +1 -1
  310. package/dist/zonos-elements/p-5b44abc8.system.js +1 -0
  311. package/dist/zonos-elements/p-5c4dc123.js +1 -0
  312. package/dist/zonos-elements/p-656c836b.entry.js +1 -0
  313. package/dist/zonos-elements/p-67737613.system.entry.js +1 -0
  314. package/dist/zonos-elements/p-79b910bf.system.entry.js +1 -0
  315. package/dist/zonos-elements/p-7d1d862f.system.entry.js +1 -0
  316. package/dist/zonos-elements/{p-5a0264e8.system.entry.js → p-88a55076.system.entry.js} +1 -1
  317. package/dist/zonos-elements/p-8aeb4679.system.entry.js +1 -0
  318. package/dist/zonos-elements/p-8d645a00.entry.js +1 -0
  319. package/dist/zonos-elements/p-9878a770.js +1 -0
  320. package/dist/zonos-elements/p-a219689f.entry.js +1 -0
  321. package/dist/zonos-elements/p-a3d72a33.entry.js +1 -0
  322. package/dist/zonos-elements/{p-aca66e4b.entry.js → p-a4de3fb2.entry.js} +1 -1
  323. package/dist/zonos-elements/p-a93c594f.entry.js +1 -0
  324. package/dist/zonos-elements/p-a95c034c.entry.js +1 -0
  325. package/dist/zonos-elements/p-abe7524f.system.js +1 -0
  326. package/dist/zonos-elements/p-afe40057.entry.js +1 -0
  327. package/dist/zonos-elements/p-b10ff468.entry.js +1 -0
  328. package/dist/zonos-elements/p-b6992dc2.system.entry.js +1 -0
  329. package/dist/zonos-elements/{p-af910392.js → p-bce46c41.js} +1 -1
  330. package/dist/zonos-elements/p-c56d4a44.entry.js +1 -0
  331. package/dist/zonos-elements/p-c7098c3b.entry.js +1 -0
  332. package/dist/zonos-elements/{p-ead79548.system.js → p-cbb1e700.system.js} +1 -1
  333. package/dist/zonos-elements/p-cc63a29f.system.entry.js +1 -0
  334. package/dist/zonos-elements/p-cd8bd5e9.system.entry.js +1 -0
  335. package/dist/zonos-elements/p-d36faf87.system.entry.js +1 -0
  336. package/dist/zonos-elements/p-dfd3edcf.entry.js +1 -0
  337. package/dist/zonos-elements/p-e1255160.js +1 -0
  338. package/dist/zonos-elements/p-e161a08c.entry.js +1 -0
  339. package/dist/zonos-elements/p-e2770968.system.entry.js +1 -0
  340. package/dist/zonos-elements/p-e2c6ad57.entry.js +1 -0
  341. package/dist/zonos-elements/{p-73174d0c.system.entry.js → p-e855966f.system.entry.js} +1 -1
  342. package/dist/zonos-elements/p-ea93943a.system.entry.js +1 -0
  343. package/dist/zonos-elements/{p-7f68c103.system.js → p-ec4d08b3.system.js} +1 -1
  344. package/dist/zonos-elements/{p-e8da4463.js → p-f455e08c.js} +1 -1
  345. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  346. package/dist/zonos-elements/zonos-elements.js +1 -1
  347. package/package.json +17 -18
  348. package/dist/cjs/cart-c1b0915c.js +0 -655
  349. package/dist/cjs/zonos-address_2.cjs.entry.js +0 -161
  350. package/dist/cjs/zonos-badge.cjs.entry.js +0 -38
  351. package/dist/cjs/zonos-icon.cjs.entry.js +0 -35
  352. package/dist/collection/components/common/zonos-country-select/assets/arrowLeftBlue.svg +0 -1
  353. package/dist/components/cart.js +0 -637
  354. package/dist/components/zonos-logo2.js +0 -48
  355. package/dist/esm/cart-7e7c7585.js +0 -637
  356. package/dist/esm/getBorderRadius-9e4cb3b1.js +0 -16
  357. package/dist/esm/zonos-address_2.entry.js +0 -156
  358. package/dist/esm/zonos-badge.entry.js +0 -34
  359. package/dist/esm/zonos-icon.entry.js +0 -31
  360. package/dist/esm-es5/cart-7e7c7585.js +0 -1
  361. package/dist/esm-es5/getBorderRadius-9e4cb3b1.js +0 -1
  362. package/dist/esm-es5/localization-5d83fde2.js +0 -1
  363. package/dist/esm-es5/submitGtag-776c5e10.js +0 -1
  364. package/dist/esm-es5/zonos-address_2.entry.js +0 -1
  365. package/dist/esm-es5/zonos-badge.entry.js +0 -1
  366. package/dist/esm-es5/zonos-button_2.entry.js +0 -1
  367. package/dist/esm-es5/zonos-cart-items_10.entry.js +0 -1
  368. package/dist/esm-es5/zonos-country-flag_4.entry.js +0 -1
  369. package/dist/esm-es5/zonos-icon.entry.js +0 -1
  370. package/dist/zonos-elements/p-027abb50.entry.js +0 -1
  371. package/dist/zonos-elements/p-09c5dc1b.system.entry.js +0 -1
  372. package/dist/zonos-elements/p-1156ae5d.system.entry.js +0 -1
  373. package/dist/zonos-elements/p-12ecf765.system.js +0 -1
  374. package/dist/zonos-elements/p-174239da.system.js +0 -1
  375. package/dist/zonos-elements/p-18e09138.system.entry.js +0 -1
  376. package/dist/zonos-elements/p-1c00ffea.system.entry.js +0 -1
  377. package/dist/zonos-elements/p-21793192.entry.js +0 -1
  378. package/dist/zonos-elements/p-2589a038.system.entry.js +0 -1
  379. package/dist/zonos-elements/p-28d7b75d.entry.js +0 -1
  380. package/dist/zonos-elements/p-31fa76da.entry.js +0 -1
  381. package/dist/zonos-elements/p-3319e4db.entry.js +0 -1
  382. package/dist/zonos-elements/p-357f0c61.entry.js +0 -1
  383. package/dist/zonos-elements/p-410045c5.system.entry.js +0 -1
  384. package/dist/zonos-elements/p-4d0861e9.system.js +0 -1
  385. package/dist/zonos-elements/p-54ef8ff3.entry.js +0 -1
  386. package/dist/zonos-elements/p-626b5a52.system.entry.js +0 -1
  387. package/dist/zonos-elements/p-6444a4b9.entry.js +0 -1
  388. package/dist/zonos-elements/p-65f4af1a.system.entry.js +0 -1
  389. package/dist/zonos-elements/p-661bc488.entry.js +0 -1
  390. package/dist/zonos-elements/p-6c47083f.entry.js +0 -1
  391. package/dist/zonos-elements/p-6d454281.entry.js +0 -1
  392. package/dist/zonos-elements/p-7748735d.entry.js +0 -1
  393. package/dist/zonos-elements/p-78886ed6.system.entry.js +0 -1
  394. package/dist/zonos-elements/p-8ebc0b64.js +0 -1
  395. package/dist/zonos-elements/p-a6f2e282.system.js +0 -1
  396. package/dist/zonos-elements/p-b035f9e5.system.js +0 -1
  397. package/dist/zonos-elements/p-b1ffb37b.entry.js +0 -1
  398. package/dist/zonos-elements/p-b58d2231.entry.js +0 -1
  399. package/dist/zonos-elements/p-bd02a65c.entry.js +0 -1
  400. package/dist/zonos-elements/p-bea31a7b.system.entry.js +0 -1
  401. package/dist/zonos-elements/p-cfe4a318.js +0 -1
  402. package/dist/zonos-elements/p-e4a2a1b0.system.entry.js +0 -1
  403. package/dist/zonos-elements/p-eb631432.system.entry.js +0 -1
  404. package/dist/zonos-elements/p-f2733cc7.js +0 -1
  405. package/dist/zonos-elements/p-f342e7c7.entry.js +0 -1
  406. package/dist/zonos-elements/p-f82e000f.system.entry.js +0 -1
  407. /package/dist/cjs/{index-3ead02fe.js → index-72767498.js} +0 -0
  408. /package/dist/esm/{index-81a199ef.js → index-b5be4dc3.js} +0 -0
  409. /package/dist/esm-es5/{index-81a199ef.js → index-b5be4dc3.js} +0 -0
  410. /package/dist/zonos-elements/{p-4d8545e1.js → p-58127116.js} +0 -0
  411. /package/dist/zonos-elements/{p-4d39efb6.system.js → p-d1ab0823.system.js} +0 -0
@@ -1,655 +0,0 @@
1
- 'use strict';
2
-
3
- const zonosStore = require('./zonosStore-b88b5671.js');
4
- const localization = require('./localization-d43e1540.js');
5
- const isDarkColor = require('./isDarkColor-5eda1323.js');
6
- const getBorderRadius = require('./getBorderRadius-cd7ef574.js');
7
-
8
- const prepCalculateLandedCost = () => {
9
- // maybe we don't need email now for prefetch the landed cost
10
- const stripeLinkData = stripeStore.stripeLinkEventData;
11
- const stripeAddressData = stripeStore.stripeAddressEventData;
12
- if (!stripeAddressData || !stripeAddressData.complete) {
13
- throw new Error('Missing stripe address data');
14
- }
15
- return {
16
- checkoutSessionId: cartStore.checkoutSessionId || '',
17
- contact: {
18
- email: (stripeLinkData === null || stripeLinkData === void 0 ? void 0 : stripeLinkData.value.email) || '',
19
- // firstName and lastName should be valid now since stripe only mark
20
- // the address as complete when both fields are filled.
21
- firstName: stripeAddressData.value.firstName || '',
22
- lastName: stripeAddressData.value.lastName || '',
23
- phone: stripeAddressData.value.phone || '',
24
- },
25
- items: cartStore.items.map(item => item),
26
- shippingAddress: {
27
- addressLine1: stripeAddressData.value.address.line1,
28
- addressLine2: stripeAddressData.value.address.line2 || '',
29
- city: stripeAddressData.value.address.city,
30
- country: stripeAddressData.value.address.country,
31
- postalCode: stripeAddressData.value.address.postal_code,
32
- state: stripeAddressData.value.address.state,
33
- },
34
- };
35
- };
36
-
37
- const triggerBuildLandedCost = async (buildLandedCost) => {
38
- var _a;
39
- const data = prepCalculateLandedCost();
40
- const landedCost = await buildLandedCost(data.checkoutSessionId, data.contact, data.shippingAddress);
41
- if (!landedCost) {
42
- throw new Error('Failed to build landed cost');
43
- }
44
- // Validate the landed cost object to make sure the returned value from buildLandedCost has a valid schema
45
- const { errors, json } = await localization.handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/validate-landed-cost`, {
46
- body: landedCost,
47
- headers: {
48
- 'Content-Type': 'application/json',
49
- },
50
- method: 'POST',
51
- });
52
- if (!json || errors.length) {
53
- throw new Error(`Invalid landed cost object: ${((_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error'}`);
54
- }
55
- return landedCost;
56
- };
57
-
58
- const calculateLandedCost = async (abortController) => {
59
- var _a;
60
- // If buildLandedCost callback is supplied, use that instead of our regular request to '/calculate-landed-cost'
61
- const buildLandedCost = zonosStore.zonosStore.checkoutSettings.buildLandedCost;
62
- if (buildLandedCost) {
63
- const json = await triggerBuildLandedCost(buildLandedCost);
64
- return json;
65
- }
66
- // request to get landed cost info
67
- const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/calculate-landed-cost`;
68
- const { errors, json } = await localization.handleFetch(url, {
69
- body: prepCalculateLandedCost(),
70
- method: 'POST',
71
- signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
72
- });
73
- if (errors.length || !json) {
74
- const isAbortedRequest = ((_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message) === 'The user aborted a request.';
75
- const errorMessage = isAbortedRequest
76
- ? 'The landed cost calculation request was aborted to initiate a new one.'
77
- : 'Failed to calculate landed cost';
78
- throw new Error(errorMessage);
79
- }
80
- return json;
81
- };
82
-
83
- const addressRuleStyle = ({ theme, }) => {
84
- switch (theme) {
85
- default:
86
- return {
87
- '.Input': {
88
- // need to reset everything and the paddingTop to default, otherwise the paddingTop will not be updated.
89
- padding: '0',
90
- paddingBottom: '8px',
91
- paddingLeft: '16px',
92
- paddingRight: '8px',
93
- // any value here will be add up to the default paddingTop (20px).
94
- paddingTop: '6px',
95
- },
96
- };
97
- }
98
- };
99
-
100
- const defaultVariable = ({ borderStyle, theme, }) => {
101
- switch (theme) {
102
- case 'DARK':
103
- return {
104
- borderRadius: getBorderRadius.getBorderRadius(borderStyle),
105
- colorBackground: '#101117',
106
- colorBackgroundText: '#C5C6CA',
107
- colorText: '#C5C6CA',
108
- colorTextPlaceholder: '#C5C6CA',
109
- };
110
- default:
111
- return {
112
- borderRadius: getBorderRadius.getBorderRadius(borderStyle),
113
- };
114
- }
115
- };
116
-
117
- const { onChange: onChange$1, reset: reset$1, state: stripeStore, } = zonosStore.createStore(() => ({
118
- clientSecret: sessionStorage.getItem('zonos--client-secret') || null,
119
- fetchingLandedCostAbordController: null,
120
- isFetchingLandedCost: false,
121
- isFetchingSession: false,
122
- stripe: null,
123
- stripeAddressElement: null,
124
- stripeAddressEventData: null,
125
- stripeAddressUsedWhenFetchingLC: null,
126
- stripeBillingAddressElement: null,
127
- stripeElements: null,
128
- stripeElementsOptions: null,
129
- stripeLinkElement: null,
130
- stripeLinkEventData: null,
131
- stripeLinkUsedWhenFetchingLC: null,
132
- stripePaymentElement: null,
133
- stripePaymentEventData: null,
134
- }));
135
- const getStripeOptions = ({ clientSecret, overrideBorderRaidus, overridePrimaryColor, overrideSecondaryColor, overrideTheme, }) => {
136
- const primaryColor = overridePrimaryColor || zonosStore.zonosStore.appearance.colorPrimary;
137
- const secondaryColor = overrideSecondaryColor || zonosStore.zonosStore.appearance.colorSecondary;
138
- const themeBasedColor = primaryColor && isDarkColor.isDarkColor(primaryColor) ? 'night' : 'flat';
139
- // if overrideTheme is provided, use it. Otherwise, use theme based on primary color
140
- const theme = overrideTheme === 'DARK' ? 'night' : 'flat';
141
- return {
142
- appearance: {
143
- labels: 'floating',
144
- rules: Object.assign({}, addressRuleStyle({ theme: 'LIGHT' })),
145
- // get contrast theme color base on primary color
146
- theme: overrideTheme ? theme : themeBasedColor,
147
- variables: Object.assign(Object.assign({}, defaultVariable({
148
- borderStyle: overrideBorderRaidus,
149
- theme: 'LIGHT',
150
- })), {
151
- // use the button background color for input glow color
152
- colorPrimary: secondaryColor }),
153
- },
154
- clientSecret,
155
- locale: localization.localizationStore.selectedLocale,
156
- };
157
- };
158
- const initStripeElements = async (props) => {
159
- var _a;
160
- const clientSecret = stripeStore.clientSecret;
161
- if (!stripeStore.stripe) {
162
- localization.log('Skip. Stripe is not initialized');
163
- return;
164
- }
165
- if (clientSecret) {
166
- const stripeOptions = getStripeOptions({
167
- clientSecret,
168
- overrideBorderRaidus: props === null || props === void 0 ? void 0 : props.overrideBorderRaidus,
169
- overridePrimaryColor: props === null || props === void 0 ? void 0 : props.overridePrimaryColor,
170
- overrideSecondaryColor: props === null || props === void 0 ? void 0 : props.overrideSecondaryColor,
171
- overrideTheme: props === null || props === void 0 ? void 0 : props.overrideTheme,
172
- });
173
- // compare with the previous options to see if we need to update
174
- const isSameOptions = JSON.stringify(stripeOptions) ===
175
- JSON.stringify(stripeStore.stripeElementsOptions);
176
- if (!stripeStore.stripeElements) {
177
- // init stripe elements if it doesn't exist
178
- stripeStore.stripeElements = (_a = stripeStore.stripe) === null || _a === void 0 ? void 0 : _a.elements(stripeOptions);
179
- // save stripe elements options for later comparison
180
- stripeStore.stripeElementsOptions = stripeOptions;
181
- localization.log('Stripe elements initialized');
182
- return;
183
- }
184
- if (!isSameOptions) {
185
- // update elements with new option if it already exists
186
- stripeStore.stripeElements.update(stripeOptions);
187
- // save stripe elements options for later comparison
188
- stripeStore.stripeElementsOptions = stripeOptions;
189
- }
190
- localization.log('Stripe elements initialized');
191
- }
192
- };
193
- const stripeStoreReset = () => {
194
- // clean clientSecret so that we can start the new one.
195
- sessionStorage.removeItem('zonos--client-secret');
196
- // cleanup stripe elements
197
- reset$1();
198
- // set stripe back to window.Zonos.stripe
199
- stripeStore.stripe = window.Zonos.stripe;
200
- };
201
- /**
202
- * Check if the address and email info used when fetching landed cost with the current email and address info are different
203
- * Purpose is to resend the request if the info used when fetching landed cost is different from the current info
204
- */
205
- const isPrefetchInfoOutdated = () => {
206
- var _a, _b, _c, _d;
207
- const hasAbortController = stripeStore.fetchingLandedCostAbordController;
208
- if (!hasAbortController) {
209
- // if there is no abort controller, this is a new request
210
- return false;
211
- }
212
- const isLinkDataDirty = JSON.stringify((_a = stripeStore.stripeLinkUsedWhenFetchingLC) === null || _a === void 0 ? void 0 : _a.value) !==
213
- JSON.stringify((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value);
214
- const isAddressDataDirty = JSON.stringify((_c = stripeStore.stripeAddressUsedWhenFetchingLC) === null || _c === void 0 ? void 0 : _c.value) !==
215
- JSON.stringify((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value);
216
- return isLinkDataDirty || isAddressDataDirty;
217
- };
218
- const stripeStorePrefetchLandedCost = async () => {
219
- var _a, _b, _c, _d;
220
- const stripeAddressReady = !!((_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.complete);
221
- const stripeLinkReady = !!((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.complete);
222
- const shouldRefetch = isPrefetchInfoOutdated();
223
- if (shouldRefetch) {
224
- // if the info used when fetching landed cost is different from the current info, abort the previous request
225
- (_c = stripeStore.fetchingLandedCostAbordController) === null || _c === void 0 ? void 0 : _c.abort();
226
- stripeStore.fetchingLandedCostAbordController = null;
227
- }
228
- // only fetch if we are not fetching or we need to refetch
229
- if (stripeAddressReady &&
230
- stripeLinkReady &&
231
- (shouldRefetch || !stripeStore.isFetchingLandedCost)) {
232
- stripeStore.isFetchingLandedCost = true;
233
- if (stripeStore.stripeAddressEventData) {
234
- stripeStore.stripeAddressUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeAddressEventData);
235
- }
236
- if (stripeStore.stripeLinkEventData) {
237
- stripeStore.stripeLinkUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeLinkEventData);
238
- }
239
- try {
240
- const abortController = new AbortController();
241
- stripeStore.fetchingLandedCostAbordController = abortController;
242
- const { checkoutSessionWorkflow, shipmentRatingCalculateWorkflow } = await calculateLandedCost(abortController);
243
- // reset abort controller after we are done
244
- stripeStore.fetchingLandedCostAbordController = null;
245
- // update cart store with landed cost info
246
- cartStore.landedCostData =
247
- (checkoutSessionWorkflow === null || checkoutSessionWorkflow === void 0 ? void 0 : checkoutSessionWorkflow.filter(Boolean)) || null;
248
- cartStore.shippingData =
249
- (shipmentRatingCalculateWorkflow === null || shipmentRatingCalculateWorkflow === void 0 ? void 0 : shipmentRatingCalculateWorkflow.filter(Boolean)) || null;
250
- // apply new subtotal and total, this is mainly to show items in the presentment currency
251
- const firstLandedCostData = (_d = cartStore.landedCostData) === null || _d === void 0 ? void 0 : _d.find(Boolean);
252
- const subtotals = !!firstLandedCostData
253
- ? firstLandedCostData.subtotals
254
- : null;
255
- if (subtotals) {
256
- // prefetch landed cost will not update shipping and taxes since we haven't selected shipping method yet
257
- cartStoreApplySubtotals({
258
- exchangeRate: subtotals.exchangeRate,
259
- items: subtotals.items,
260
- landedCostTotal: 0,
261
- presentmentCurrencyCode: subtotals.presentmentCurrencyCode,
262
- shipping: 0,
263
- total: subtotals.items,
264
- });
265
- }
266
- }
267
- catch (err) {
268
- localization.logError(err);
269
- }
270
- stripeStore.isFetchingLandedCost = false;
271
- }
272
- };
273
- const getStripeMessageBasedOnStatus = (status) => {
274
- let messages = [];
275
- let isError = true;
276
- // Inspect the PaymentIntent `status` to indicate the status of the payment
277
- // to your customer.
278
- //
279
- // Some payment methods will [immediately succeed or fail][0] upon
280
- // confirmation, while others will first enter a `processing` state.
281
- //
282
- // [0]: https://stripe.com/docs/payments/payment-methods#payment-notification
283
- switch (status) {
284
- case 'succeeded': {
285
- messages = [
286
- localization.translate('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.'),
287
- '',
288
- '',
289
- localization.translate("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."),
290
- ];
291
- isError = false;
292
- break;
293
- }
294
- case 'requires_capture':
295
- case 'processing': {
296
- messages = [
297
- localization.translate("Payment processing. We'll update you when payment is received."),
298
- ];
299
- isError = false;
300
- break;
301
- }
302
- case 'requires_payment_method': {
303
- messages = [
304
- localization.translate('Payment failed. Please try another payment method.'),
305
- ];
306
- break;
307
- }
308
- default: {
309
- messages = [localization.translate('Something went wrong.')];
310
- break;
311
- }
312
- }
313
- return {
314
- isError,
315
- messages,
316
- };
317
- };
318
- const stripeStoreRetrievePayment = async ({ clientSecret: _clientSecret, storybookForceStatus, }) => {
319
- if (storybookForceStatus) {
320
- // return status right away if we are in storybook mode
321
- const { isError, messages } = getStripeMessageBasedOnStatus(storybookForceStatus);
322
- return { error: isError, messages };
323
- }
324
- const clientSecret = _clientSecret || stripeStore.clientSecret;
325
- if (!stripeStore.stripe || !clientSecret) {
326
- localization.logError('Failed to retrieve payment intent. Stripe is not initialized');
327
- return { error: true, message: [localization.translate('Something went wrong.')] };
328
- }
329
- const { paymentIntent } = await stripeStore.stripe.retrievePaymentIntent(clientSecret);
330
- const status = paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status;
331
- const { isError, messages } = getStripeMessageBasedOnStatus(status);
332
- return { error: isError, messages };
333
- };
334
- const stripeStoreConfirmPayment = async () => {
335
- var _a, _b, _c;
336
- const stripePaymentReady = !!((_a = stripeStore.stripePaymentEventData) === null || _a === void 0 ? void 0 : _a.complete);
337
- const stripeElements = stripeStore.stripeElements;
338
- const stripe = stripeStore.stripe;
339
- const stripeClientSecret = stripeStore.clientSecret;
340
- if (stripe && stripeElements && stripePaymentReady && stripeClientSecret) {
341
- const { error } = await stripe.confirmPayment({
342
- confirmParams: {
343
- receipt_email: (_c = (_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.email,
344
- return_url: window.location.href,
345
- },
346
- elements: stripeElements,
347
- redirect: 'if_required',
348
- });
349
- if (error) {
350
- if (error.type === 'card_error' || error.type === 'validation_error') {
351
- throw new Error(error.message);
352
- }
353
- if (error.type === 'invalid_request_error') {
354
- if (error.code === 'payment_intent_unexpected_state') {
355
- // PaymentIntent was canceled or expired, or status is `require_capture`.
356
- // don't throw error here because we will reset the checkout session last step
357
- return;
358
- }
359
- }
360
- throw new Error('An unexpected error occurred.');
361
- }
362
- }
363
- };
364
- /**
365
- * Init checkout session
366
- * @returns {boolean} whether or not the checkout session is successfully created
367
- */
368
- const stripeStoreInitCheckoutSession = async () => {
369
- var _a;
370
- const total = cartStore.items.reduce((amount, item) => amount + item.amount * item.quantity, 0);
371
- if (!total || !localization.localizationStore.targetCurrency) {
372
- localization.logError('Fail to create checkout session - invalid total or currency');
373
- return false;
374
- }
375
- stripeStore.isFetchingSession = true;
376
- const { errors, json } = await localization.handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/create-checkout-session`, {
377
- body: {
378
- currency: ((_a = cartStore.items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode) || '',
379
- itemsAmount: total,
380
- presentmentCountryCode: localization.localizationStore.selectedCountryCode || null,
381
- },
382
- method: 'POST',
383
- });
384
- stripeStore.isFetchingSession = false;
385
- if (errors.length || !json) {
386
- localization.logError('Error occurs when creating checkout session', JSON.stringify(errors, null, 2));
387
- return false;
388
- }
389
- const result = json.checkoutSessionCreate;
390
- stripeStore.clientSecret = result.clientSecret;
391
- // update cart store with updated informations
392
- cartStore.checkoutSessionId = result.id;
393
- cartStoreApplySubtotals(Object.assign(Object.assign({}, result.subtotals), { landedCostTotal: 0, shipping: 0, total: result.subtotals.items }));
394
- localization.log('Exchange rate updated for cart items (checkout session create)', 'info', cartStore.exchangeRate);
395
- localization.log('done-init-checkout-session');
396
- return true;
397
- };
398
- /**
399
- * Update checkout session. Use for updating amount with landed cost id, or update session when cart items change
400
- */
401
- const stripeStoreUpdateCheckoutSession = async ({ currency, id, itemsAmount, landedCostId, presentmentCountryCode, }) => {
402
- // No need to set loading state here because this function will be called under the hood to update
403
- // landed cost id for the section.
404
- const { errors, json } = await localization.handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/update-checkout-session`, {
405
- body: {
406
- currency,
407
- id,
408
- itemsAmount,
409
- landedCostId,
410
- presentmentCountryCode,
411
- },
412
- method: 'POST',
413
- });
414
- if (errors.length || !json) {
415
- localization.logError('Error occurs when updating checkout session', JSON.stringify(errors, null, 2));
416
- return { errors, json };
417
- }
418
- return { errors: [], json };
419
- };
420
- onChange$1('clientSecret', clientSecret => {
421
- // update stripe elements when client secret changes
422
- if (clientSecret && stripeStore.stripe) {
423
- sessionStorage.setItem('zonos--client-secret', clientSecret);
424
- }
425
- if (!clientSecret) {
426
- sessionStorage.removeItem('zonos--client-secret');
427
- }
428
- });
429
-
430
- const formatDate = ({ date, formatOptions = { day: 'numeric', weekday: 'long', year: 'numeric' }, }) => {
431
- // format date to Thursday 3, 2023
432
- return new Intl.DateTimeFormat('en-US', formatOptions).format(date);
433
- };
434
-
435
- const getDaysDifference = (targetDate) => {
436
- const currentDate = new Date();
437
- const timeDifference = targetDate.getTime() - currentDate.getTime();
438
- const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); // Convert milliseconds to days
439
- return daysDifference;
440
- };
441
-
442
- const { onChange, reset, state: cartStore, } = zonosStore.createStore(() => ({
443
- checkoutSessionId: sessionStorage.getItem('zonos--checkout-session-id') || null,
444
- currency: 'USD',
445
- dutiesTaxFees: 0,
446
- error: null,
447
- exchangeRate: null,
448
- isSelectedShippingAboveDeminimis: false,
449
- isSelectedShippingGuarantee: false,
450
- items: [],
451
- landedCostData: null,
452
- selectedLandedCost: null,
453
- selectedShippingOption: null,
454
- selectedShippingOptionExpectedDate: '',
455
- selectedShippingOptionTransitTime: '',
456
- shipping: 0,
457
- shippingData: null,
458
- step: 'customer-info',
459
- subtotal: 0,
460
- total: 0,
461
- }));
462
- /**
463
- * Format shipping transit info to be displayed on UI
464
- * @returns
465
- * - expectedDate: Thursday, Aug 12
466
- * - maxTransit: 5
467
- * - minTransit: 3
468
- */
469
- const cartStoreGetShippingTransitInfo = (item) => {
470
- const minTransit = item.minTransitAt
471
- ? getDaysDifference(new Date(item.minTransitAt))
472
- : '';
473
- const maxTransit = item.maxTransitAt
474
- ? getDaysDifference(new Date(item.maxTransitAt))
475
- : '';
476
- const expectedDate = item.minTransitAt
477
- ? formatDate({
478
- date: new Date(item.minTransitAt),
479
- })
480
- : '';
481
- return {
482
- expectedDate,
483
- maxTransit,
484
- minTransit,
485
- };
486
- };
487
- const cartStoreReset = () => {
488
- sessionStorage.removeItem('zonos--checkout-session-id');
489
- // reset cart store
490
- reset();
491
- };
492
- const cartStoreUpdateToErrorState = ({ messages, title, }) => {
493
- cartStoreReset();
494
- stripeStoreReset();
495
- cartStore.step = 'error';
496
- cartStore.error = {
497
- messages,
498
- title,
499
- };
500
- };
501
- const cartStoreApplySubtotals = (subtotals) => {
502
- // update exchange rate so we can use it to display cart items
503
- cartStore.exchangeRate = subtotals.exchangeRate;
504
- cartStore.dutiesTaxFees = subtotals.landedCostTotal;
505
- cartStore.subtotal = subtotals.items;
506
- cartStore.total = subtotals.total;
507
- cartStore.currency = subtotals.presentmentCurrencyCode;
508
- };
509
- const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId, }) => {
510
- if (landedCostId && cartStore.selectedLandedCost) {
511
- // update cart total right away if we have landed cost id to avoid order total flickering
512
- const subtotals = cartStore.selectedLandedCost.subtotals;
513
- cartStoreApplySubtotals(subtotals);
514
- localization.log('Exchange rate updated for cart items (landed cost subtotal)', 'info', cartStore.exchangeRate);
515
- }
516
- // update checkout session
517
- if (!cartStore.checkoutSessionId) {
518
- localization.logError('Could not update cart total without checkout session id');
519
- return false;
520
- }
521
- const { json } = await stripeStoreUpdateCheckoutSession({
522
- currency,
523
- id: cartStore.checkoutSessionId,
524
- itemsAmount,
525
- landedCostId,
526
- presentmentCountryCode: localization.localizationStore.selectedCountryCode,
527
- });
528
- if (!json) {
529
- // do nothing if we can't get checkout session
530
- localization.logError('Error occurs when updating checkout session');
531
- cartStoreUpdateToErrorState({
532
- messages: [
533
- localization.translate("There's been an error updating your checkout session. Please reload and try again or contact support if the error persists"),
534
- ],
535
- title: localization.translate('Error updating Checkout'),
536
- });
537
- return false;
538
- }
539
- if (!landedCostId) {
540
- // This is when first open the checkout modal and we just want to get info from the old cart session.
541
- // use subtotals from checkout session to update cart total
542
- cartStoreApplySubtotals(json.checkoutSessionUpdate.subtotals);
543
- localization.log('Exchange rate updated for cart items (checkout session update)', 'info', cartStore.exchangeRate);
544
- }
545
- return true;
546
- };
547
- const cartStoreUpdateSelectedShippingOption = async (selectedShippingOption) => {
548
- var _a, _b, _c, _d, _e;
549
- cartStore.selectedShippingOption = selectedShippingOption;
550
- // update shipping transit info
551
- const { expectedDate, maxTransit, minTransit } = cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption);
552
- cartStore.selectedShippingOptionExpectedDate = expectedDate;
553
- cartStore.selectedShippingOptionTransitTime =
554
- minTransit && maxTransit
555
- ? `${minTransit}-${maxTransit}`
556
- : `${minTransit || maxTransit}`;
557
- const selectedLandedCost = (_a = cartStore.landedCostData) === null || _a === void 0 ? void 0 : _a.find(checkoutSessionPresentment => {
558
- var _a, _b, _c;
559
- return ((_b = (_a = checkoutSessionPresentment.landedCost) === null || _a === void 0 ? void 0 : _a.shipmentRating) === null || _b === void 0 ? void 0 : _b.id) ===
560
- ((_c = cartStore.selectedShippingOption) === null || _c === void 0 ? void 0 : _c.id);
561
- });
562
- // save selected landed cost for later use
563
- cartStore.selectedLandedCost = selectedLandedCost || null;
564
- if (!selectedLandedCost) {
565
- // do nothing if we can't find landed cost for selected shipping option
566
- return false;
567
- }
568
- // update shipping value and dutiesTaxFees on selectedShippingOption change
569
- cartStore.shipping = selectedLandedCost.subtotals.shipping;
570
- // update deminimis status
571
- const isGuarantee = ((_b = selectedLandedCost === null || selectedLandedCost === void 0 ? void 0 : selectedLandedCost.landedCost) === null || _b === void 0 ? void 0 : _b.landedCostGuaranteeCode) === 'ZONOS';
572
- // one item in deminimis with type of duty and tax has threshold value is "ABOVE"
573
- const isAboveDeminimis = !!((_d = (_c = selectedLandedCost === null || selectedLandedCost === void 0 ? void 0 : selectedLandedCost.landedCost) === null || _c === void 0 ? void 0 : _c.deMinimis) === null || _d === void 0 ? void 0 : _d.find(item => ['DUTY', 'TAX'].includes(item.type) && item.threshold === 'ABOVE'));
574
- cartStore.isSelectedShippingAboveDeminimis = isAboveDeminimis;
575
- cartStore.isSelectedShippingGuarantee = isGuarantee;
576
- // update session with selected landed cost
577
- const updateCalulateStatus = await cartStoreReCalculateTotal({
578
- landedCostId: (_e = selectedLandedCost.landedCost) === null || _e === void 0 ? void 0 : _e.id,
579
- });
580
- return updateCalulateStatus;
581
- };
582
- onChange('checkoutSessionId', () => {
583
- if (!cartStore.checkoutSessionId) {
584
- sessionStorage.removeItem('zonos--checkout-session-id');
585
- return;
586
- }
587
- sessionStorage.setItem('zonos--checkout-session-id', cartStore.checkoutSessionId);
588
- });
589
- const cartStoreUpdateItems = async (items) => {
590
- var _a;
591
- cartStore.items = items;
592
- const currency = (_a = items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode;
593
- const total = items.reduce((amt, item) => {
594
- return amt + item.amount * item.quantity;
595
- }, 0);
596
- if (!currency || !total) {
597
- // do nothing if we can't get currency or total
598
- return;
599
- }
600
- cartStore.currency = currency;
601
- // set loading state here because this is first load checkout session when we already have checkout session id stored
602
- stripeStore.isFetchingSession = true;
603
- await cartStoreReCalculateTotal({
604
- currency: currency,
605
- itemsAmount: total,
606
- });
607
- stripeStore.isFetchingSession = false;
608
- };
609
- const cartStoreResetSelectedShippingOption = () => {
610
- cartStore.selectedShippingOption = null;
611
- cartStore.isSelectedShippingAboveDeminimis = false;
612
- cartStore.isSelectedShippingGuarantee = false;
613
- cartStore.selectedShippingOptionExpectedDate = '';
614
- cartStore.selectedShippingOptionTransitTime = '';
615
- cartStore.shipping = 0;
616
- };
617
- const cartStoreNextStep = () => {
618
- if (cartStore.step === 'customer-info') {
619
- cartStore.step = 'shipping';
620
- }
621
- else if (cartStore.step === 'shipping') {
622
- cartStore.step = 'payment';
623
- }
624
- else if (cartStore.step === 'payment') {
625
- cartStore.step = 'finish';
626
- }
627
- };
628
- const cartStorePreviousStep = () => {
629
- if (cartStore.step === 'payment') {
630
- cartStore.step = 'shipping';
631
- }
632
- else if (cartStore.step === 'shipping') {
633
- cartStore.step = 'customer-info';
634
- // reset selected shipping option
635
- cartStoreResetSelectedShippingOption();
636
- }
637
- };
638
-
639
- exports.cartStore = cartStore;
640
- exports.cartStoreApplySubtotals = cartStoreApplySubtotals;
641
- exports.cartStoreGetShippingTransitInfo = cartStoreGetShippingTransitInfo;
642
- exports.cartStoreNextStep = cartStoreNextStep;
643
- exports.cartStorePreviousStep = cartStorePreviousStep;
644
- exports.cartStoreReCalculateTotal = cartStoreReCalculateTotal;
645
- exports.cartStoreReset = cartStoreReset;
646
- exports.cartStoreUpdateItems = cartStoreUpdateItems;
647
- exports.cartStoreUpdateSelectedShippingOption = cartStoreUpdateSelectedShippingOption;
648
- exports.cartStoreUpdateToErrorState = cartStoreUpdateToErrorState;
649
- exports.initStripeElements = initStripeElements;
650
- exports.stripeStore = stripeStore;
651
- exports.stripeStoreConfirmPayment = stripeStoreConfirmPayment;
652
- exports.stripeStoreInitCheckoutSession = stripeStoreInitCheckoutSession;
653
- exports.stripeStorePrefetchLandedCost = stripeStorePrefetchLandedCost;
654
- exports.stripeStoreReset = stripeStoreReset;
655
- exports.stripeStoreRetrievePayment = stripeStoreRetrievePayment;