@zonos/elements 1.3.218 → 1.3.220

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 (395) hide show
  1. package/dist/cjs/buildCartItemsByTempCart-309fcebf.js +28 -0
  2. package/dist/cjs/{cart-c54d05ce.js → cart-9a9ae4b9.js} +90 -47
  3. package/dist/cjs/cleanHtmlMarkdown-577d0a77.js +999 -0
  4. package/dist/cjs/index.cjs.js +19 -9
  5. package/dist/cjs/isCollectMobileTablet-7a9413e3.js +175 -0
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/cjs/localization-0169b27d.js +738 -0
  8. package/dist/cjs/{paypal-d36b5dd1.js → paypal-9ee374a0.js} +12 -8
  9. package/dist/cjs/placeTestOrder-0dfff170.js +93 -0
  10. package/dist/cjs/{localization-ab7e1902.js → translationStore-0c67178f.js} +1023 -734
  11. package/dist/cjs/zonos-address_11.cjs.entry.js +116 -74
  12. package/dist/cjs/zonos-badge.cjs.entry.js +3 -3
  13. package/dist/cjs/{zonos-banner.cjs.entry.js → zonos-banner_2.cjs.entry.js} +40 -0
  14. package/dist/cjs/zonos-button_3.cjs.entry.js +3 -3
  15. package/dist/cjs/{zonos-cart-items_14.cjs.entry.js → zonos-cart-items_12.cjs.entry.js} +70 -1292
  16. package/dist/cjs/zonos-checkout.cjs.entry.js +25 -48
  17. package/dist/cjs/zonos-collapse.cjs.entry.js +2 -2
  18. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +92 -0
  19. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +811 -0
  20. package/dist/cjs/zonos-collect.cjs.entry.js +468 -0
  21. package/dist/cjs/zonos-component.cjs.entry.js +1 -1
  22. package/dist/cjs/zonos-confirm-dialog_2.cjs.entry.js +168 -0
  23. package/dist/cjs/zonos-controller.cjs.entry.js +84 -28
  24. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -1
  25. package/dist/cjs/zonos-country-select_4.cjs.entry.js +11 -10
  26. package/dist/cjs/zonos-elements.cjs.js +1 -1
  27. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +23 -5
  28. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +34 -33
  29. package/dist/cjs/zonos-hello.cjs.entry.js +8 -7
  30. package/dist/cjs/zonos-input.cjs.entry.js +4 -4
  31. package/dist/cjs/zonos-language-select_2.cjs.entry.js +6 -5
  32. package/dist/cjs/zonos-link.cjs.entry.js +1 -1
  33. package/dist/cjs/zonos-logo.cjs.entry.js +2 -2
  34. package/dist/cjs/zonos-stripe-input.cjs.entry.js +8 -5
  35. package/dist/cjs/zonos-text.cjs.entry.js +1 -1
  36. package/dist/cjs/zonos-toggle.cjs.entry.js +2 -2
  37. package/dist/cjs/zonos-tooltip.cjs.entry.js +2 -2
  38. package/dist/cjs/zonos-v-stack.cjs.entry.js +2 -2
  39. package/dist/collection/collection-manifest.json +10 -0
  40. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +2 -2
  41. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +5 -1
  42. package/dist/collection/components/checkout/zonos-collect/assets/ChevronDownIcon.svg +1 -0
  43. package/dist/collection/components/checkout/zonos-collect/zonos-collect-cart-items/assets/empty-item.jpeg +0 -0
  44. package/dist/collection/components/checkout/zonos-collect/zonos-collect-cart-items/zonos-collect-cart-items.css +60 -0
  45. package/dist/collection/components/checkout/zonos-collect/zonos-collect-cart-items/zonos-collect-cart-items.js +39 -0
  46. package/dist/collection/components/checkout/zonos-collect/zonos-collect-finish/assets/RemoveIcon.svg +1 -0
  47. package/dist/collection/components/checkout/zonos-collect/zonos-collect-finish/assets/SuccessIcon.svg +1 -0
  48. package/dist/collection/components/checkout/zonos-collect/zonos-collect-finish/zonos-collect-finish.css +90 -0
  49. package/dist/collection/components/checkout/zonos-collect/zonos-collect-finish/zonos-collect-finish.js +405 -0
  50. package/dist/collection/components/checkout/zonos-collect/zonos-collect-footer/assets/chevronDownIcon.svg +1 -0
  51. package/dist/collection/components/checkout/zonos-collect/zonos-collect-footer/assets/globe.svg +3 -0
  52. package/dist/collection/components/checkout/zonos-collect/zonos-collect-footer/assets/zonosIconDark.svg +10 -0
  53. package/dist/collection/components/checkout/zonos-collect/zonos-collect-footer/assets/zonosIconLight.svg +10 -0
  54. package/dist/collection/components/checkout/zonos-collect/zonos-collect-footer/assets/zonosWordmark.svg +7 -0
  55. package/dist/collection/components/checkout/zonos-collect/zonos-collect-footer/zonos-collect-footer.css +152 -0
  56. package/dist/collection/components/checkout/zonos-collect/zonos-collect-footer/zonos-collect-footer.js +164 -0
  57. package/dist/collection/components/checkout/zonos-collect/zonos-collect-order-details/assets/ChevronDownIcon.svg +1 -0
  58. package/dist/collection/components/checkout/zonos-collect/zonos-collect-order-details/assets/ChevronUpIcon.svg +1 -0
  59. package/dist/collection/components/checkout/zonos-collect/zonos-collect-order-details/zonos-collect-order-details.css +109 -0
  60. package/dist/collection/components/checkout/zonos-collect/zonos-collect-order-details/zonos-collect-order-details.js +194 -0
  61. package/dist/collection/components/checkout/zonos-collect/zonos-collect-payment/assets/CheckmarkLineIcon.svg +1 -0
  62. package/dist/collection/components/checkout/zonos-collect/zonos-collect-payment/assets/RemoveLineIcon.svg +1 -0
  63. package/dist/collection/components/checkout/zonos-collect/zonos-collect-payment/zonos-collect-payment.css +98 -0
  64. package/dist/collection/components/checkout/zonos-collect/zonos-collect-payment/zonos-collect-payment.js +369 -0
  65. package/dist/collection/components/checkout/zonos-collect/zonos-collect-review/zonos-collect-review.css +71 -0
  66. package/dist/collection/components/checkout/zonos-collect/zonos-collect-review/zonos-collect-review.js +151 -0
  67. package/dist/collection/components/checkout/zonos-collect/zonos-collect-subtotal/zonos-collect-subtotal.css +78 -0
  68. package/dist/collection/components/checkout/zonos-collect/zonos-collect-subtotal/zonos-collect-subtotal.js +115 -0
  69. package/dist/collection/components/checkout/zonos-collect/zonos-collect.css +349 -0
  70. package/dist/collection/components/checkout/zonos-collect/zonos-collect.js +547 -0
  71. package/dist/collection/components/common/zonos-badge/zonos-badge.js +3 -3
  72. package/dist/collection/components/common/zonos-button/zonos-button.js +3 -3
  73. package/dist/collection/components/common/zonos-card/zonos-card.js +4 -4
  74. package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.js +3 -3
  75. package/dist/collection/components/common/zonos-checkout-progress-tabs/zonos-checkout-progress-tabs.js +3 -3
  76. package/dist/collection/components/common/zonos-collapse/zonos-collapse.js +2 -2
  77. package/dist/collection/components/common/zonos-confirm-dialog/zonos-confirm-dialog.js +3 -3
  78. package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +3 -3
  79. package/dist/collection/components/common/zonos-custom-message/zonos-custom-message.js +2 -2
  80. package/dist/collection/components/common/zonos-dialog/zonos-dialog.js +3 -3
  81. package/dist/collection/components/common/zonos-h-stack/zonos-h-stack.css +38 -0
  82. package/dist/collection/components/common/zonos-h-stack/zonos-h-stack.js +63 -0
  83. package/dist/collection/components/common/zonos-input/zonos-input.js +4 -4
  84. package/dist/collection/components/common/zonos-language-select/zonos-language-select.js +2 -2
  85. package/dist/collection/components/common/zonos-link/zonos-link.js +1 -1
  86. package/dist/collection/components/common/zonos-loading-overlay/zonos-loading-overlay.js +1 -1
  87. package/dist/collection/components/common/zonos-logo/zonos-logo.js +2 -2
  88. package/dist/collection/components/common/zonos-rest-state/zonos-rest-state.js +3 -3
  89. package/dist/collection/components/common/zonos-select-dialog-header/zonos-select-dialog-header.js +2 -2
  90. package/dist/collection/components/common/zonos-skeleton/assets/RemoveLineIcon.svg +3 -0
  91. package/dist/collection/components/common/zonos-skeleton/zonos-skeleton.css +40 -0
  92. package/dist/collection/components/common/zonos-skeleton/zonos-skeleton.js +102 -0
  93. package/dist/collection/components/common/zonos-stripe-input/zonos-stripe-input.js +8 -5
  94. package/dist/collection/components/common/zonos-stripe-phone-input/zonos-stripe-phone-input.js +5 -5
  95. package/dist/collection/components/common/zonos-stripe-select/zonos-stripe-select.js +5 -5
  96. package/dist/collection/components/common/zonos-text/zonos-text.css +1 -0
  97. package/dist/collection/components/common/zonos-toggle/zonos-toggle.js +2 -2
  98. package/dist/collection/components/common/zonos-tooltip/zonos-tooltip.js +2 -2
  99. package/dist/collection/components/common/zonos-v-stack/zonos-v-stack.js +2 -2
  100. package/dist/collection/components/common/zonos-virtual-scroll/zonos-virtual-scroll.js +2 -2
  101. package/dist/collection/components/component-template/zonos-component/zonos-component.js +1 -1
  102. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.js +2 -2
  103. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +4 -4
  104. package/dist/collection/components/main/zonos-controller.js +91 -25
  105. package/dist/collection/components/paypal/zonos-paypal-payment.js +13 -2
  106. package/dist/collection/components/store/checkout/cart.js +36 -15
  107. package/dist/collection/components/store/checkout/collect.js +160 -0
  108. package/dist/collection/components/store/checkout/paypal.js +4 -2
  109. package/dist/collection/components/store/checkout/stripe.js +31 -12
  110. package/dist/collection/components/store/translationStore/strings.arabic.js +51 -0
  111. package/dist/collection/components/store/translationStore/strings.base.js +51 -0
  112. package/dist/collection/components/store/translationStore/strings.chinese.js +51 -0
  113. package/dist/collection/components/store/translationStore/strings.danish.js +51 -0
  114. package/dist/collection/components/store/translationStore/strings.dutch.js +51 -0
  115. package/dist/collection/components/store/translationStore/strings.french.js +51 -0
  116. package/dist/collection/components/store/translationStore/strings.german.js +51 -0
  117. package/dist/collection/components/store/translationStore/strings.hebrew.js +51 -0
  118. package/dist/collection/components/store/translationStore/strings.indonesian.js +51 -0
  119. package/dist/collection/components/store/translationStore/strings.italian.js +51 -0
  120. package/dist/collection/components/store/translationStore/strings.japanese.js +51 -0
  121. package/dist/collection/components/store/translationStore/strings.korean.js +51 -0
  122. package/dist/collection/components/store/translationStore/strings.norwegian.js +51 -0
  123. package/dist/collection/components/store/translationStore/strings.polish.js +51 -0
  124. package/dist/collection/components/store/translationStore/strings.portuguese.js +51 -0
  125. package/dist/collection/components/store/translationStore/strings.russian.js +51 -0
  126. package/dist/collection/components/store/translationStore/strings.spanish.js +51 -0
  127. package/dist/collection/components/store/translationStore/strings.swedish.js +51 -0
  128. package/dist/collection/components/store/translationStore/strings.turkish.js +51 -0
  129. package/dist/collection/components/store/translationStore/strings.vietnamese.js +51 -0
  130. package/dist/collection/components/store/translationStore.js +2 -1
  131. package/dist/collection/components/stripe/zonos-address/zonos-address.js +35 -18
  132. package/dist/collection/components/stripe/zonos-custom-address/zonos-address-suggestions/zonos-address-suggestions.js +2 -2
  133. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +2 -2
  134. package/dist/collection/components/stripe/zonos-link-authentication/zonos-link-authentication.js +29 -4
  135. package/dist/collection/components/stripe/zonos-payment/zonos-payment.js +9 -1
  136. package/dist/collection/components/utils/checkout/initCollect.js +15 -0
  137. package/dist/collection/components/utils/checkout/isCollectMobileTablet.js +10 -0
  138. package/dist/collection/components/utils/checkout/renderCheckoutCurrency.js +10 -1
  139. package/dist/collection/components/utils/renderFallback.js +7 -0
  140. package/dist/collection/scripts/_getZonosQaUrl.js +5 -1
  141. package/dist/collection/scripts/_zonosBase.js +7 -1
  142. package/dist/collection/types/checkout/api/PartyInfo.js +1 -0
  143. package/dist/collection/types/generated/graphql.internal.types.js +113 -0
  144. package/dist/collection/types/index.js +1 -0
  145. package/dist/esm/buildCartItemsByTempCart-c4488f73.js +26 -0
  146. package/dist/esm/{cart-bb0ee971.js → cart-b2dd578c.js} +68 -27
  147. package/dist/esm/cleanHtmlMarkdown-b5b18743.js +997 -0
  148. package/dist/esm/index.js +19 -9
  149. package/dist/esm/isCollectMobileTablet-7f9a5e2b.js +168 -0
  150. package/dist/esm/loader.js +1 -1
  151. package/dist/esm/localization-d7125e4e.js +719 -0
  152. package/dist/esm/{paypal-bd4520eb.js → paypal-555bbf1e.js} +7 -4
  153. package/dist/esm/placeTestOrder-2d67c1a9.js +90 -0
  154. package/dist/esm/{localization-d8326254.js → translationStore-13502f49.js} +1023 -718
  155. package/dist/esm/zonos-address_11.entry.js +85 -43
  156. package/dist/esm/zonos-badge.entry.js +3 -3
  157. package/dist/esm/{zonos-banner.entry.js → zonos-banner_2.entry.js} +40 -1
  158. package/dist/esm/zonos-button_3.entry.js +3 -3
  159. package/dist/esm/{zonos-cart-items_14.entry.js → zonos-cart-items_12.entry.js} +20 -1240
  160. package/dist/esm/zonos-checkout.entry.js +6 -29
  161. package/dist/esm/zonos-collapse.entry.js +2 -2
  162. package/dist/esm/zonos-collect-cart-items_3.entry.js +86 -0
  163. package/dist/esm/zonos-collect-finish_6.entry.js +802 -0
  164. package/dist/esm/zonos-collect.entry.js +464 -0
  165. package/dist/esm/zonos-component.entry.js +1 -1
  166. package/dist/esm/zonos-confirm-dialog_2.entry.js +163 -0
  167. package/dist/esm/zonos-controller.entry.js +84 -28
  168. package/dist/esm/zonos-country-flag.entry.js +2 -1
  169. package/dist/esm/zonos-country-select_4.entry.js +11 -10
  170. package/dist/esm/zonos-elements.js +1 -1
  171. package/dist/esm/zonos-empty-state-payment_4.entry.js +23 -5
  172. package/dist/esm/zonos-hello-dialog.entry.js +6 -5
  173. package/dist/esm/zonos-hello.entry.js +2 -1
  174. package/dist/esm/zonos-input.entry.js +4 -4
  175. package/dist/esm/zonos-language-select_2.entry.js +6 -5
  176. package/dist/esm/zonos-link.entry.js +1 -1
  177. package/dist/esm/zonos-logo.entry.js +2 -2
  178. package/dist/esm/zonos-stripe-input.entry.js +9 -6
  179. package/dist/esm/zonos-text.entry.js +1 -1
  180. package/dist/esm/zonos-toggle.entry.js +2 -2
  181. package/dist/esm/zonos-tooltip.entry.js +2 -2
  182. package/dist/esm/zonos-v-stack.entry.js +2 -2
  183. package/dist/esm-es5/buildCartItemsByTempCart-c4488f73.js +1 -0
  184. package/dist/esm-es5/cart-b2dd578c.js +1 -0
  185. package/dist/esm-es5/cleanHtmlMarkdown-b5b18743.js +1 -0
  186. package/dist/esm-es5/index.js +1 -1
  187. package/dist/esm-es5/isCollectMobileTablet-7f9a5e2b.js +1 -0
  188. package/dist/esm-es5/loader.js +1 -1
  189. package/dist/esm-es5/localization-d7125e4e.js +1 -0
  190. package/dist/esm-es5/paypal-555bbf1e.js +17 -0
  191. package/dist/esm-es5/placeTestOrder-2d67c1a9.js +1 -0
  192. package/dist/esm-es5/translationStore-13502f49.js +1 -0
  193. package/dist/esm-es5/zonos-address_11.entry.js +1 -1
  194. package/dist/esm-es5/zonos-badge.entry.js +1 -1
  195. package/dist/esm-es5/zonos-banner_2.entry.js +1 -0
  196. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  197. package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -0
  198. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  199. package/dist/esm-es5/zonos-collapse.entry.js +1 -1
  200. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -0
  201. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -0
  202. package/dist/esm-es5/zonos-collect.entry.js +1 -0
  203. package/dist/esm-es5/zonos-component.entry.js +1 -1
  204. package/dist/esm-es5/zonos-confirm-dialog_2.entry.js +1 -0
  205. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  206. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  207. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  208. package/dist/esm-es5/zonos-elements.js +1 -1
  209. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  210. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  211. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  212. package/dist/esm-es5/zonos-input.entry.js +1 -1
  213. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  214. package/dist/esm-es5/zonos-link.entry.js +1 -1
  215. package/dist/esm-es5/zonos-logo.entry.js +1 -1
  216. package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
  217. package/dist/esm-es5/zonos-text.entry.js +1 -1
  218. package/dist/esm-es5/zonos-toggle.entry.js +1 -1
  219. package/dist/esm-es5/zonos-tooltip.entry.js +1 -1
  220. package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
  221. package/dist/scripts/index.d.ts +470 -2
  222. package/dist/scripts/index.js +1 -1
  223. package/dist/scripts/loadZonos.js +1 -1
  224. package/dist/scripts/zonos.js +1 -1
  225. package/dist/types/components/checkout/zonos-collect/zonos-collect-cart-items/zonos-collect-cart-items.d.ts +4 -0
  226. package/dist/types/components/checkout/zonos-collect/zonos-collect-finish/zonos-collect-finish.d.ts +50 -0
  227. package/dist/types/components/checkout/zonos-collect/zonos-collect-footer/zonos-collect-footer.d.ts +25 -0
  228. package/dist/types/components/checkout/zonos-collect/zonos-collect-order-details/zonos-collect-order-details.d.ts +29 -0
  229. package/dist/types/components/checkout/zonos-collect/zonos-collect-payment/zonos-collect-payment.d.ts +62 -0
  230. package/dist/types/components/checkout/zonos-collect/zonos-collect-review/zonos-collect-review.d.ts +22 -0
  231. package/dist/types/components/checkout/zonos-collect/zonos-collect-subtotal/zonos-collect-subtotal.d.ts +10 -0
  232. package/dist/types/components/checkout/zonos-collect/zonos-collect.d.ts +86 -0
  233. package/dist/types/components/common/zonos-h-stack/zonos-h-stack.d.ts +9 -0
  234. package/dist/types/components/common/zonos-skeleton/zonos-skeleton.d.ts +17 -0
  235. package/dist/types/components/main/zonos-controller.d.ts +5 -0
  236. package/dist/types/components/paypal/zonos-paypal-payment.d.ts +3 -0
  237. package/dist/types/components/store/checkout/cart.d.ts +23 -3
  238. package/dist/types/components/store/checkout/collect.d.ts +21 -0
  239. package/dist/types/components/store/checkout/paypal.d.ts +4 -3
  240. package/dist/types/components/store/checkout/stripe.d.ts +6 -2
  241. package/dist/types/components/store/translationStore/strings.arabic.d.ts +51 -0
  242. package/dist/types/components/store/translationStore/strings.base.d.ts +51 -0
  243. package/dist/types/components/store/translationStore/strings.chinese.d.ts +51 -0
  244. package/dist/types/components/store/translationStore/strings.danish.d.ts +51 -0
  245. package/dist/types/components/store/translationStore/strings.dutch.d.ts +51 -0
  246. package/dist/types/components/store/translationStore/strings.french.d.ts +51 -0
  247. package/dist/types/components/store/translationStore/strings.german.d.ts +51 -0
  248. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +51 -0
  249. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +51 -0
  250. package/dist/types/components/store/translationStore/strings.italian.d.ts +51 -0
  251. package/dist/types/components/store/translationStore/strings.japanese.d.ts +51 -0
  252. package/dist/types/components/store/translationStore/strings.korean.d.ts +51 -0
  253. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +51 -0
  254. package/dist/types/components/store/translationStore/strings.polish.d.ts +51 -0
  255. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +51 -0
  256. package/dist/types/components/store/translationStore/strings.russian.d.ts +51 -0
  257. package/dist/types/components/store/translationStore/strings.spanish.d.ts +51 -0
  258. package/dist/types/components/store/translationStore/strings.swedish.d.ts +51 -0
  259. package/dist/types/components/store/translationStore/strings.turkish.d.ts +51 -0
  260. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +51 -0
  261. package/dist/types/components/store/translationStore.d.ts +2 -1
  262. package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +1 -2
  263. package/dist/types/components/stripe/zonos-link-authentication/zonos-link-authentication.d.ts +3 -1
  264. package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
  265. package/dist/types/components/utils/checkout/initCollect.d.ts +1 -0
  266. package/dist/types/components/utils/checkout/isCollectMobileTablet.d.ts +4 -0
  267. package/dist/types/components/utils/renderFallback.d.ts +6 -0
  268. package/dist/types/components.d.ts +401 -2
  269. package/dist/types/scripts/_zonosBase.d.ts +5 -0
  270. package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +5 -0
  271. package/dist/types/types/checkout/api/CheckoutSession.d.ts +9 -1
  272. package/dist/types/types/checkout/api/CreateParty.d.ts +24 -0
  273. package/dist/types/types/checkout/api/NormalizedTempCart.d.ts +6 -1
  274. package/dist/types/types/checkout/api/PartyInfo.d.ts +24 -0
  275. package/dist/types/types/generated/graphql.frontend.types.d.ts +1 -1
  276. package/dist/types/types/generated/graphql.frontend.types.ts +1 -1
  277. package/dist/types/types/generated/graphql.internal.types.d.ts +616 -5
  278. package/dist/types/types/generated/graphql.internal.types.ts +626 -6
  279. package/dist/types/types/index.d.ts +1 -0
  280. package/dist/zonos-elements/index.esm.js +1 -1
  281. package/dist/zonos-elements/{p-7b5de646.entry.js → p-02667a58.entry.js} +1 -1
  282. package/dist/zonos-elements/p-031d646e.system.js +1 -0
  283. package/dist/zonos-elements/p-0e07e1d6.entry.js +1 -0
  284. package/dist/zonos-elements/p-0ef2a242.js +1 -0
  285. package/dist/zonos-elements/p-126087a2.system.entry.js +1 -0
  286. package/dist/zonos-elements/{p-c7d5d45d.entry.js → p-14f9bc8c.entry.js} +1 -1
  287. package/dist/zonos-elements/p-27d9abab.js +1 -0
  288. package/dist/zonos-elements/p-2813d72e.system.js +1 -0
  289. package/dist/zonos-elements/p-295d9c07.system.entry.js +1 -0
  290. package/dist/zonos-elements/p-29c80a34.js +1 -0
  291. package/dist/zonos-elements/p-2a6c964d.js +1 -0
  292. package/dist/zonos-elements/p-2b3c7c77.system.entry.js +1 -0
  293. package/dist/zonos-elements/p-2b8897d1.system.entry.js +1 -0
  294. package/dist/zonos-elements/{p-544c173a.system.entry.js → p-30432622.system.entry.js} +1 -1
  295. package/dist/zonos-elements/p-3462e9e4.system.entry.js +1 -0
  296. package/dist/zonos-elements/p-372c2fc5.entry.js +1 -0
  297. package/dist/zonos-elements/p-3c1b1be1.system.entry.js +1 -0
  298. package/dist/zonos-elements/p-40a4266f.js +1 -0
  299. package/dist/zonos-elements/{p-47ffacd8.system.entry.js → p-421dfb66.system.entry.js} +1 -1
  300. package/dist/zonos-elements/{p-288761b1.system.entry.js → p-4f8563ad.system.entry.js} +1 -1
  301. package/dist/zonos-elements/p-52d35358.system.entry.js +1 -0
  302. package/dist/zonos-elements/p-567f7de7.entry.js +1 -0
  303. package/dist/zonos-elements/p-5d9410da.entry.js +1 -0
  304. package/dist/zonos-elements/p-637b22ee.system.entry.js +1 -0
  305. package/dist/zonos-elements/p-63a42823.entry.js +1 -0
  306. package/dist/zonos-elements/p-69451a50.system.js +1 -0
  307. package/dist/zonos-elements/p-6b3a0874.entry.js +1 -0
  308. package/dist/zonos-elements/p-73c1e91f.js +1 -0
  309. package/dist/zonos-elements/p-759ef3ca.entry.js +1 -0
  310. package/dist/zonos-elements/p-79d8c3f3.system.entry.js +1 -0
  311. package/dist/zonos-elements/{p-3f31901f.entry.js → p-7c4e7651.entry.js} +1 -1
  312. package/dist/zonos-elements/{p-1c45cd15.entry.js → p-7d2d2c94.entry.js} +1 -1
  313. package/dist/zonos-elements/{p-1ac8bfbb.system.entry.js → p-7e5bd9af.system.entry.js} +1 -1
  314. package/dist/zonos-elements/p-7ecbb2cb.entry.js +1 -0
  315. package/dist/zonos-elements/p-81b357f7.system.js +1 -1
  316. package/dist/zonos-elements/p-82e88a33.system.js +1 -0
  317. package/dist/zonos-elements/p-849b47aa.entry.js +1 -0
  318. package/dist/zonos-elements/p-8dd47520.system.entry.js +1 -0
  319. package/dist/zonos-elements/p-932600b7.js +1 -0
  320. package/dist/zonos-elements/p-960e0ab1.system.entry.js +1 -0
  321. package/dist/zonos-elements/p-9c5b8239.system.js +1 -0
  322. package/dist/zonos-elements/{p-d55aec11.system.entry.js → p-9fdd3264.system.entry.js} +1 -1
  323. package/dist/zonos-elements/p-a08a005d.entry.js +1 -0
  324. package/dist/zonos-elements/p-a10de7fb.entry.js +1 -0
  325. package/dist/zonos-elements/p-a49b5e7f.system.entry.js +1 -0
  326. package/dist/zonos-elements/{p-62813488.entry.js → p-a5b0a636.entry.js} +1 -1
  327. package/dist/zonos-elements/p-a61a9b65.system.entry.js +1 -0
  328. package/dist/zonos-elements/{p-d6fa2dc2.entry.js → p-a77ed1b9.entry.js} +1 -1
  329. package/dist/zonos-elements/{p-eeb01de6.system.entry.js → p-a800965d.system.entry.js} +1 -1
  330. package/dist/zonos-elements/p-b2ae8eb7.system.js +1 -0
  331. package/dist/zonos-elements/p-b3d5bcf9.entry.js +1 -0
  332. package/dist/zonos-elements/{p-da4c01da.system.entry.js → p-b669050d.system.entry.js} +1 -1
  333. package/dist/zonos-elements/p-b9e9b82f.system.entry.js +1 -0
  334. package/dist/zonos-elements/{p-714c28b1.system.entry.js → p-ba18c5f5.system.entry.js} +1 -1
  335. package/dist/zonos-elements/p-bbf48b31.entry.js +1 -0
  336. package/dist/zonos-elements/{p-77666360.entry.js → p-c4b3c878.entry.js} +1 -1
  337. package/dist/zonos-elements/p-c7b57886.js +17 -0
  338. package/dist/zonos-elements/p-c803753e.entry.js +1 -0
  339. package/dist/zonos-elements/{p-e640e8b8.entry.js → p-cbb01de9.entry.js} +1 -1
  340. package/dist/zonos-elements/p-ce15d62d.system.js +1 -0
  341. package/dist/zonos-elements/p-d291e964.system.entry.js +1 -0
  342. package/dist/zonos-elements/p-d3485a03.system.js +1 -0
  343. package/dist/zonos-elements/{p-59eaebe3.system.entry.js → p-de626806.system.entry.js} +1 -1
  344. package/dist/zonos-elements/p-e5388438.system.entry.js +1 -0
  345. package/dist/zonos-elements/p-e77b6e42.entry.js +1 -0
  346. package/dist/zonos-elements/p-ea8aff21.system.js +17 -0
  347. package/dist/zonos-elements/{p-7ab62a26.system.entry.js → p-eb6a35ce.system.entry.js} +1 -1
  348. package/dist/zonos-elements/{p-92cc26b7.system.entry.js → p-ee6f8c02.system.entry.js} +1 -1
  349. package/dist/zonos-elements/{p-a98b1e8d.entry.js → p-efa6203f.entry.js} +1 -1
  350. package/dist/zonos-elements/{p-edc77ea1.entry.js → p-f4fa8720.entry.js} +1 -1
  351. package/dist/zonos-elements/{p-ebaaaee9.entry.js → p-fa90adb8.entry.js} +1 -1
  352. package/dist/zonos-elements/p-fe7e2dc4.entry.js +1 -0
  353. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  354. package/package.json +1 -1
  355. package/dist/cjs/zonos-card.cjs.entry.js +0 -49
  356. package/dist/esm/zonos-card.entry.js +0 -45
  357. package/dist/esm-es5/cart-bb0ee971.js +0 -1
  358. package/dist/esm-es5/localization-d8326254.js +0 -1
  359. package/dist/esm-es5/paypal-bd4520eb.js +0 -17
  360. package/dist/esm-es5/zonos-banner.entry.js +0 -1
  361. package/dist/esm-es5/zonos-card.entry.js +0 -1
  362. package/dist/esm-es5/zonos-cart-items_14.entry.js +0 -1
  363. package/dist/zonos-elements/p-043f57e8.system.entry.js +0 -1
  364. package/dist/zonos-elements/p-0631d2b9.js +0 -1
  365. package/dist/zonos-elements/p-0a6ac265.system.js +0 -1
  366. package/dist/zonos-elements/p-0f041dc5.system.entry.js +0 -1
  367. package/dist/zonos-elements/p-1432a217.system.entry.js +0 -1
  368. package/dist/zonos-elements/p-1b51b738.system.entry.js +0 -1
  369. package/dist/zonos-elements/p-3a1513ae.system.entry.js +0 -1
  370. package/dist/zonos-elements/p-3b8d11dd.entry.js +0 -1
  371. package/dist/zonos-elements/p-4333afcb.entry.js +0 -1
  372. package/dist/zonos-elements/p-4d0d89da.system.entry.js +0 -1
  373. package/dist/zonos-elements/p-5dd9cb44.system.entry.js +0 -1
  374. package/dist/zonos-elements/p-605a21ac.entry.js +0 -1
  375. package/dist/zonos-elements/p-674981ad.system.js +0 -1
  376. package/dist/zonos-elements/p-6d090b53.entry.js +0 -1
  377. package/dist/zonos-elements/p-73c8c551.system.entry.js +0 -1
  378. package/dist/zonos-elements/p-795d223d.entry.js +0 -1
  379. package/dist/zonos-elements/p-8218ff62.system.entry.js +0 -1
  380. package/dist/zonos-elements/p-82f80c8a.entry.js +0 -1
  381. package/dist/zonos-elements/p-88f7256d.js +0 -1
  382. package/dist/zonos-elements/p-8b083884.entry.js +0 -1
  383. package/dist/zonos-elements/p-a449940d.entry.js +0 -1
  384. package/dist/zonos-elements/p-a5a4ad2f.entry.js +0 -1
  385. package/dist/zonos-elements/p-a5d45585.system.entry.js +0 -1
  386. package/dist/zonos-elements/p-a751e819.system.entry.js +0 -1
  387. package/dist/zonos-elements/p-ad556be6.entry.js +0 -1
  388. package/dist/zonos-elements/p-b4792af0.entry.js +0 -1
  389. package/dist/zonos-elements/p-b9ff6458.entry.js +0 -1
  390. package/dist/zonos-elements/p-d3dbae8c.system.js +0 -1
  391. package/dist/zonos-elements/p-ebb9b902.system.js +0 -17
  392. package/dist/zonos-elements/p-ef1ce617.system.entry.js +0 -1
  393. package/dist/zonos-elements/p-ef75da6f.js +0 -17
  394. package/dist/zonos-elements/p-f3dbe934.entry.js +0 -1
  395. package/dist/zonos-elements/p-f741407e.system.entry.js +0 -1
@@ -0,0 +1,738 @@
1
+ 'use strict';
2
+
3
+ const zonosStore = require('./zonosStore-f8ee56aa.js');
4
+ const handleFetch = require('./handleFetch-45f35cac.js');
5
+ const VarianceTest = require('./VarianceTest-0cb1e118.js');
6
+ const translationStore = require('./translationStore-0c67178f.js');
7
+
8
+ /**
9
+ * Check if the response contains at least one available test key that we support
10
+ */
11
+ const hasAtLeastOneAvailableTestKey = (rawResponse) => {
12
+ const hasAvailableTestKey = !!rawResponse.find(item => item.testKey in VarianceTest.availableTestKeys);
13
+ if (!hasAvailableTestKey) {
14
+ handleFetch.log('No available test key found in response', 'info', {
15
+ response: rawResponse,
16
+ });
17
+ }
18
+ return !!rawResponse.find(item => item.testKey in VarianceTest.availableTestKeys);
19
+ };
20
+
21
+ /**
22
+ * Filter the response to only include test keys and variants key that we support
23
+ */
24
+ const filterValidTests = (testKeys) => {
25
+ // Type guard the response to ensure it matches the expected structure
26
+ if (!hasAtLeastOneAvailableTestKey(testKeys)) {
27
+ return [];
28
+ }
29
+ // Filter the response to only include test keys that we support
30
+ return testKeys
31
+ .filter(item => {
32
+ var _a;
33
+ const isTestKeyValidButNoSelectedVariantKey = VarianceTest.availableTestKeys[item.testKey] && !item.selectedVariantKey;
34
+ const validTestKeyWithSelectedVariantKey = item.selectedVariantKey &&
35
+ !!((_a = VarianceTest.availableTestKeys[item.testKey]) === null || _a === void 0 ? void 0 : _a['availableVariants'].includes(item.selectedVariantKey));
36
+ return (isTestKeyValidButNoSelectedVariantKey ||
37
+ validTestKeyWithSelectedVariantKey);
38
+ })
39
+ .map(item => (Object.assign(Object.assign({}, item), { expiresAt: item.expiresAt || Date.now() + VARIANT_TEST_KEY_EXPIRATION, selectedVariantKey: item.selectedVariantKey || null })));
40
+ };
41
+
42
+ /**
43
+ * Expiration time for variant test keys in milliseconds
44
+ * @default 1 day
45
+ */
46
+ const VARIANT_TEST_KEY_EXPIRATION = 60 * 60 * 24 * 1000;
47
+ const { onChange: storageStoreOnChange, state: storageStore } = zonosStore.createStore({
48
+ checkoutSessionId: sessionStorage.getItem('zonos--checkout-session-id'),
49
+ enabledVariantTestKeys: handleFetch.jsonParse(localStorage.getItem('zonos--enabled-variant-test-keys')),
50
+ });
51
+ storageStoreOnChange('enabledVariantTestKeys', () => {
52
+ var _a;
53
+ // This should be set in localStorage so we don't have multiple tests for the same user in short period of time
54
+ if (!((_a = storageStore.enabledVariantTestKeys) === null || _a === void 0 ? void 0 : _a.length)) {
55
+ localStorage.removeItem('zonos--enabled-variant-test-keys');
56
+ return;
57
+ }
58
+ localStorage.setItem('zonos--enabled-variant-test-keys', JSON.stringify(storageStore.enabledVariantTestKeys));
59
+ });
60
+ storageStoreOnChange('checkoutSessionId', () => {
61
+ if (!storageStore.checkoutSessionId) {
62
+ sessionStorage.removeItem('zonos--checkout-session-id');
63
+ return;
64
+ }
65
+ sessionStorage.setItem('zonos--checkout-session-id', storageStore.checkoutSessionId);
66
+ });
67
+ const storageStoreSetEnabledVariantTestKeys = (testKeys) => {
68
+ storageStore.enabledVariantTestKeys = filterValidTests(testKeys);
69
+ };
70
+
71
+ const getCountries = async () => {
72
+ try {
73
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/get-countries', {
74
+ method: 'GET',
75
+ });
76
+ if (errors.length || !json) {
77
+ return null;
78
+ }
79
+ return json;
80
+ }
81
+ catch (_a) {
82
+ return null;
83
+ }
84
+ };
85
+
86
+ const getCountryLandedCost = async (countryCode) => {
87
+ var _a;
88
+ if (!countryCode) {
89
+ return null;
90
+ }
91
+ const url = `/api/zonos-elements/country-landed-cost/${countryCode}`;
92
+ const { errors, json } = await handleFetch.handleFetch(url);
93
+ if (errors.length || !json) {
94
+ handleFetch.logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
95
+ return null;
96
+ }
97
+ return json || null;
98
+ };
99
+
100
+ const defaultUsExchangeRate = {
101
+ exchangeRate: {
102
+ rate: 1,
103
+ targetFormat: {
104
+ currencyCode: 'USD',
105
+ decimalDelimiter: '.',
106
+ scale: 2,
107
+ symbol: '$',
108
+ symbolLocation: 'before',
109
+ thousandsDelimiter: ',',
110
+ },
111
+ },
112
+ maxAge: null,
113
+ };
114
+ const getExchangeRate = async ({ country, isGuaranteed, sourceCurrency, targetCurrency, }) => {
115
+ var _a;
116
+ // If source currency matches target currency (US -> US) and is not a guaranteed rate, return default exchange rate so we still format properly.
117
+ if (sourceCurrency === targetCurrency && !isGuaranteed) {
118
+ return defaultUsExchangeRate;
119
+ }
120
+ const searchParams = new URLSearchParams();
121
+ searchParams.set('sourceCurrency', sourceCurrency);
122
+ searchParams.set('targetCurrency', targetCurrency);
123
+ searchParams.set('isGuaranteed', String(isGuaranteed));
124
+ searchParams.set('country', country || '');
125
+ const { errors, json } = await handleFetch.handleFetch(`/api/zonos-elements/exchange-rates?${searchParams.toString()}`);
126
+ if (errors.length || !json) {
127
+ handleFetch.logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
128
+ return defaultUsExchangeRate;
129
+ }
130
+ const { rate, targetFormat } = json.exchangeRateCreate;
131
+ const maxAge = json.maxAge;
132
+ if (rate) {
133
+ sessionStorage.setItem(country + '_rate', JSON.stringify(rate));
134
+ const exchangeRate = { rate, targetFormat };
135
+ return { exchangeRate, maxAge };
136
+ }
137
+ return defaultUsExchangeRate;
138
+ };
139
+
140
+ const getInclusivePricing = async (countryCode) => {
141
+ var _a;
142
+ if (!countryCode) {
143
+ return null;
144
+ }
145
+ const { errors, json } = await handleFetch.handleFetch(`/api/zonos-elements/inclusive-prices/${countryCode}`);
146
+ if (errors.length || !json) {
147
+ handleFetch.logError(`Error fetching country inclusive price setting: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
148
+ return null;
149
+ }
150
+ return json || null;
151
+ };
152
+
153
+ const getLocaleMessages = async ({ countryCode, localeTo, storeId, }) => {
154
+ var _a;
155
+ const searchParams = new URLSearchParams();
156
+ searchParams.set('countryCode', countryCode);
157
+ searchParams.set('storeId', storeId.toString());
158
+ if (localeTo) {
159
+ searchParams.set('localeTo', localeTo);
160
+ }
161
+ const { errors, json } = await handleFetch.handleFetch(`/api/zonos-elements/locale-messages?${searchParams.toString()}`);
162
+ if (errors.length || !json) {
163
+ handleFetch.logError('Error fetching exchange rate', (_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message);
164
+ return [];
165
+ }
166
+ return json.locale_countryCodesPage;
167
+ };
168
+
169
+ const validateCountryCode = (countryCode) => {
170
+ // Check that the country is two characters and is upper case
171
+ if (countryCode && /^[A-Z]{2}$/.test(countryCode)) {
172
+ return countryCode;
173
+ }
174
+ return null;
175
+ };
176
+ const getZCountryUrlParam = (urlParams) => {
177
+ const urlSearchParams = new URLSearchParams(urlParams || window.location.search);
178
+ const getCountryParam = (param) => {
179
+ const country = urlSearchParams.get(param);
180
+ // Check that the country is two characters and is upper case
181
+ return validateCountryCode(country);
182
+ };
183
+ const zCountry = getCountryParam('zCountry');
184
+ // Fallback to legacy 'country'
185
+ const fallback = getCountryParam('country');
186
+ // Fallback to customerCountry
187
+ const secondFallback = getCountryParam('customerCountry');
188
+ return zCountry || fallback || secondFallback;
189
+ };
190
+
191
+ const getLocalization = async () => {
192
+ try {
193
+ const currentUrl = new URL(window.location.href);
194
+ // load and use country from session storage when zCountry query param is not present
195
+ const countryLoadedSession = window.sessionStorage.getItem('zonos--country');
196
+ const zCountry = getZCountryUrlParam(currentUrl.searchParams) || countryLoadedSession;
197
+ const searchParams = new URLSearchParams();
198
+ if (zCountry) {
199
+ searchParams.set('zCountry', zCountry);
200
+ }
201
+ const { errors, json } = await handleFetch.handleFetch(`/api/zonos-elements/localization?${searchParams.toString()}`);
202
+ if (errors.length || !json) {
203
+ return { country: null, locale: null };
204
+ }
205
+ return {
206
+ country: json.country,
207
+ locale: json.locale,
208
+ };
209
+ }
210
+ catch (_a) {
211
+ return { country: null, locale: null };
212
+ }
213
+ };
214
+
215
+ const getShippingZones = async () => {
216
+ var _a, _b, _c;
217
+ if ((_a = window.Zonos.cartSettings) === null || _a === void 0 ? void 0 : _a.shippingZones) {
218
+ return window.Zonos.cartSettings.shippingZones
219
+ .flatMap(zone => zone === null || zone === void 0 ? void 0 : zone.countryCodes)
220
+ .filter(Boolean);
221
+ }
222
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/shipping-zones');
223
+ if (errors.length || !json) {
224
+ handleFetch.logError(`Error fetching shipping zones: ${(_b = errors.find(Boolean)) === null || _b === void 0 ? void 0 : _b.message}`);
225
+ return null;
226
+ }
227
+ const shippingZones = (_c = json === null || json === void 0 ? void 0 : json.shippingZones) === null || _c === void 0 ? void 0 : _c.flatMap(zone => zone === null || zone === void 0 ? void 0 : zone.countryCodes).filter(Boolean);
228
+ return shippingZones || null;
229
+ };
230
+
231
+ const currencyConvert = (value) => {
232
+ // TODO(potentially): Bring over the code for vanity checks
233
+ const { exchangeRate } = localizationStore;
234
+ if (!exchangeRate || !value || isNaN(value)) {
235
+ return value;
236
+ }
237
+ const minimumFractionDigits = (exchangeRate === null || exchangeRate === void 0 ? void 0 : exchangeRate.targetFormat.scale) || 2;
238
+ const convertedValue = value * exchangeRate.rate;
239
+ const fixedValue = convertedValue.toFixed(minimumFractionDigits);
240
+ return Number(fixedValue);
241
+ };
242
+
243
+ /**
244
+ * This function only to format the number in
245
+ * @returns
246
+ */
247
+ const numberFormat = ({ amount, currency, targetFormat, }) => {
248
+ const targetCurrency = currency || localizationStore.targetCurrency;
249
+ const minimumFractionDigits = (targetFormat === null || targetFormat === void 0 ? void 0 : targetFormat.scale) || 2;
250
+ const isIE = window.navigator.userAgent.indexOf('MSIE ') !== -1;
251
+ const numberFormatExists = typeof Intl === 'object' && Intl && typeof Intl.NumberFormat === 'function';
252
+ if (isIE || !numberFormatExists) {
253
+ // use native number formatting if it's IE.
254
+ const formattedNumber = Number(amount)
255
+ .toFixed(minimumFractionDigits)
256
+ .replace('.', '|dec|')
257
+ .replace(',', (targetFormat === null || targetFormat === void 0 ? void 0 : targetFormat.thousandsDelimiter) || '')
258
+ .replace('|dec|', (targetFormat === null || targetFormat === void 0 ? void 0 : targetFormat.decimalDelimiter) || '');
259
+ return formattedNumber;
260
+ }
261
+ const formatedNumber = new Intl.NumberFormat(window.navigator.language, {
262
+ currency: targetCurrency,
263
+ currencyDisplay: 'code',
264
+ minimumFractionDigits: minimumFractionDigits,
265
+ style: 'currency',
266
+ }).format(amount);
267
+ return formatedNumber.replace(new RegExp(`${targetCurrency}\\s+`), '');
268
+ };
269
+
270
+ const currencyFormat = ({ amount, currency, }) => {
271
+ if (isNaN(amount) || (amount !== 0 && !amount)) {
272
+ return '';
273
+ }
274
+ const overrideCurrencyFormat = zonosStore.zonosStore.overrideCurrencyFormat;
275
+ const { exchangeRate } = localizationStore;
276
+ const targetCurrency = currency || localizationStore.targetCurrency;
277
+ // Use user-defined currency format
278
+ if (typeof overrideCurrencyFormat === 'function') {
279
+ return overrideCurrencyFormat({
280
+ amount: amount,
281
+ currencyCode: targetCurrency,
282
+ numberFormat: ({ amount: _amount }) => numberFormat({
283
+ amount: _amount,
284
+ currency: targetCurrency,
285
+ targetFormat: (exchangeRate === null || exchangeRate === void 0 ? void 0 : exchangeRate.targetFormat) || null,
286
+ }),
287
+ });
288
+ }
289
+ const { targetFormat } = exchangeRate || {};
290
+ if (!targetFormat || !exchangeRate) {
291
+ // Return the amount as a string if no exchange rate is available
292
+ return `${amount.toFixed(2)} ${targetCurrency}`;
293
+ }
294
+ const minimumFractionDigits = targetFormat.scale || 2;
295
+ const isIE = window.navigator.userAgent.indexOf('MSIE ') !== -1;
296
+ const numberFormatExists = typeof Intl === 'object' && Intl && typeof Intl.NumberFormat === 'function';
297
+ if (isIE || !numberFormatExists) {
298
+ // use native number formatting if it's IE.
299
+ const formattedNumber = Number(amount)
300
+ .toFixed(minimumFractionDigits)
301
+ .replace('.', '|dec|')
302
+ .replace(',', targetFormat.thousandsDelimiter || '')
303
+ .replace('|dec|', targetFormat.decimalDelimiter || '');
304
+ const result = `${formattedNumber}${targetFormat.currencyCode !== 'USD' ? ` ${targetFormat.currencyCode}` : ''}`;
305
+ return result;
306
+ }
307
+ const currencyDisplay = (overrideCurrencyFormat === null || overrideCurrencyFormat === void 0 ? void 0 : overrideCurrencyFormat.currencyDisplay) || 'symbol';
308
+ const formattedNumber = new Intl.NumberFormat(window.navigator.language, {
309
+ currency: targetCurrency,
310
+ currencyDisplay,
311
+ minimumFractionDigits: minimumFractionDigits,
312
+ style: 'currency',
313
+ }).format(amount);
314
+ // Move currency code to the end of the string if currencyDisplay is 'code'
315
+ const result = currencyDisplay === 'code'
316
+ ? `${formattedNumber.replace(new RegExp(`${targetCurrency}\\s+`), '')} ${targetCurrency}`
317
+ : formattedNumber;
318
+ return result;
319
+ };
320
+
321
+ const currencyConvertAndFormat = (value) => {
322
+ const convertedValue = currencyConvert(value);
323
+ const formattedValue = currencyFormat({ amount: convertedValue });
324
+ return formattedValue;
325
+ };
326
+
327
+ /**
328
+ * Check if selector user pass is valid
329
+ * @example
330
+ * isValidSelector('div') // true
331
+ * isValidSelector('div + >>> span') // false
332
+ */
333
+ const isValidSelector = (selector) => {
334
+ try {
335
+ // this will error out if the selector is invalid in the DOM
336
+ document.createDocumentFragment().querySelector(selector);
337
+ }
338
+ catch (_a) {
339
+ return false;
340
+ }
341
+ return true;
342
+ };
343
+
344
+ const getCurrencyElements = (selector) => {
345
+ const currencySelector = selector || '.money';
346
+ if (!isValidSelector(currencySelector)) {
347
+ handleFetch.logError(`Currency element selector "${currencySelector}" is not valid.`);
348
+ return null;
349
+ }
350
+ const currencyElements = document.querySelectorAll(currencySelector);
351
+ if (!currencyElements.length) {
352
+ handleFetch.log(`No currency elements found with selector "${currencySelector}"`, 'warn');
353
+ return null;
354
+ }
355
+ // return array of currency elements instead of a NodeList
356
+ return Array.from(currencyElements);
357
+ };
358
+
359
+ const getInitialElementAmount = (element) => {
360
+ var _a;
361
+ const domesticValue = element.getAttribute('data-domestic');
362
+ const intlValue = element.getAttribute('data-zintl');
363
+ // Only keep numbers, decimal, and hyphens
364
+ const cleanedText = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.replace(/[^\d.-]/g, '');
365
+ if (!cleanedText) {
366
+ return null;
367
+ }
368
+ // If the element has no data-domestic attribute, or the text content is different from the data-zintl attribute, set the data-domestic attribute
369
+ if (!domesticValue || (element.textContent !== intlValue && intlValue)) {
370
+ // Store the original value on the element once, and international on every new conversion
371
+ element.setAttribute('data-domestic', cleanedText);
372
+ return parseFloat(cleanedText);
373
+ }
374
+ return parseFloat(domesticValue);
375
+ };
376
+
377
+ const convertCurrency = (element) => {
378
+ var _a;
379
+ const amount = getInitialElementAmount(element);
380
+ if (!amount || isNaN(amount)) {
381
+ return;
382
+ }
383
+ const currentIntlValue = element.getAttribute('data-zintl');
384
+ // get rate
385
+ const currentIntlRateValue = parseFloat(element.getAttribute('data-zrate') || '1');
386
+ const currentCountryValue = element.getAttribute('data-zcountry-code');
387
+ // do nothing if the target currency is the same
388
+ const isExchangeRateReady = localizationStore.exchangeRate &&
389
+ localizationStore.targetCurrency ===
390
+ localizationStore.exchangeRate.targetFormat.currencyCode;
391
+ const rate = ((_a = localizationStore.exchangeRate) === null || _a === void 0 ? void 0 : _a.rate) || 1;
392
+ // if the current value on the element is different from the current intl value, update the data-zintl attribute
393
+ if (isExchangeRateReady &&
394
+ // Update currency if the value is not yet formatted
395
+ (element.textContent !== currentIntlValue ||
396
+ // Update rate when new rate is available
397
+ rate !== currentIntlRateValue ||
398
+ // Update currency when the country code changes
399
+ currentCountryValue !== localizationStore.selectedCountryCode)) {
400
+ const customizedCurrencyFormat = typeof zonosStore.zonosStore.currencyConverter === 'function' &&
401
+ zonosStore.zonosStore.currencyConverter({
402
+ convert: currencyConvert,
403
+ convertAndFormat: currencyConvertAndFormat,
404
+ currencyCode: localizationStore.targetCurrency,
405
+ format: (value) => currencyFormat({ amount: value }),
406
+ originalAmount: amount,
407
+ selector: element,
408
+ });
409
+ // default to the currencyConvertAndFormat if the currencyConverter function does not return a value, or invalid value. This is to make sure we don't break the merchant's price.
410
+ const observedFormattedValue = customizedCurrencyFormat || currencyConvertAndFormat(amount);
411
+ if (observedFormattedValue !== element.textContent) {
412
+ // Only set textContent if the value has changed, this is to prevent it redrawing the element if the value is the same
413
+ element.textContent = observedFormattedValue;
414
+ }
415
+ // save the new rate to the data-zrate attribute
416
+ element.setAttribute('data-zrate', rate.toString());
417
+ // save the new value to the data-zintl attribute
418
+ element.setAttribute('data-zintl', observedFormattedValue);
419
+ element.setAttribute('data-zcountry-code', localizationStore.selectedCountryCode || '');
420
+ }
421
+ };
422
+ const defaultCurrencyConverter = () => {
423
+ const { currencyElementSelector } = zonosStore.zonosStore.helloSettings;
424
+ const currencyElements = getCurrencyElements(currencyElementSelector);
425
+ // do nothing if none of the currency elements are found
426
+ if (!(currencyElements === null || currencyElements === void 0 ? void 0 : currencyElements.length)) {
427
+ return;
428
+ }
429
+ if (!localizationStore.exchangeRate) {
430
+ handleFetch.logError('Could not display currency. Exchange rate and format data is not available.');
431
+ return;
432
+ }
433
+ currencyElements.forEach(element => {
434
+ // convert the currency and save the formatted value to the data-zintl attribute
435
+ convertCurrency(element);
436
+ });
437
+ };
438
+
439
+ const currencyDisplay = () => {
440
+ if (zonosStore.zonosStore.helloSettings.currencyBehavior === 'DISABLED' ||
441
+ window.Zonos.isLegacyCheckout) {
442
+ return;
443
+ }
444
+ defaultCurrencyConverter();
445
+ };
446
+
447
+ const getCurrencyCode = (code) => {
448
+ var _a;
449
+ const countryInShippingZone = (_a = localizationStore.shippingZoneCountries) === null || _a === void 0 ? void 0 : _a[code];
450
+ if (countryInShippingZone) {
451
+ return countryInShippingZone.currencyCode;
452
+ }
453
+ return null;
454
+ };
455
+
456
+ const setZCountryUrlParam = (selectedCountryCode) => {
457
+ if (!selectedCountryCode) {
458
+ return;
459
+ }
460
+ const urlSearchParams = new URLSearchParams(window.location.search);
461
+ // Only append zCountry if it's already in the URL or the countryOverrideBehavior is URL_PARAM
462
+ const shouldAppendParam = urlSearchParams.has('zCountry') ||
463
+ zonosStore.zonosStore.helloSettings.countryOverrideBehavior === 'URL_PARAM';
464
+ if (shouldAppendParam) {
465
+ // Only append zCountry if it's not already in the URL
466
+ urlSearchParams.set('zCountry', selectedCountryCode);
467
+ const newUrl = `${window.location.pathname}?${urlSearchParams.toString()}`;
468
+ /**
469
+ * Setting the state to null in window.history.replaceState can cause issues with rendering when using next/link and pressing the back button.
470
+ * @ref https://github.com/vercel/next.js/issues/33233#issuecomment-1052349396
471
+ **/
472
+ window.history.replaceState(window.history.state, document.title, newUrl);
473
+ }
474
+ };
475
+
476
+ const { dispose: localizationDispose, onChange: localizationStoreOnChange, state: localizationStore, } = zonosStore.createStore({
477
+ countryLandedCost: null,
478
+ customMessages: [],
479
+ exchangeRate: null,
480
+ helloCountryList: null,
481
+ inclusivePricing: null,
482
+ isDisabledCountry: true,
483
+ isShippableCountry: false,
484
+ localizationLoaded: false,
485
+ selectedCountryCode: null,
486
+ selectedLocale: 'en',
487
+ shippingZoneCountries: null,
488
+ targetCurrency: 'USD',
489
+ });
490
+ const triggerGetExchangeRate = async (isGuaranteed) => {
491
+ const { exchangeRate, maxAge } = await getExchangeRate({
492
+ country: localizationStore.selectedCountryCode,
493
+ isGuaranteed,
494
+ sourceCurrency: zonosStore.zonosStore.sourceCurrency,
495
+ targetCurrency: localizationStore.targetCurrency,
496
+ });
497
+ if (exchangeRate) {
498
+ localizationStore.exchangeRate = exchangeRate;
499
+ currencyDisplay();
500
+ }
501
+ return { maxAge };
502
+ };
503
+ /**
504
+ * CHORE: This is mostly for legacy checkout as the country param is not guaranteed.
505
+ */
506
+ const DEFAULT_COUNTRY_CODE_LEGACY_CHECKOUT = 'CA';
507
+ const getFallbackDefaultCountryCode = (allowedCountries) => {
508
+ if (localizationStore.selectedCountryCode &&
509
+ allowedCountries.includes(localizationStore.selectedCountryCode)) {
510
+ return localizationStore.selectedCountryCode;
511
+ }
512
+ // Don't check if it is allowed. If it is not allowed it will fallback to Albania (first option).
513
+ return DEFAULT_COUNTRY_CODE_LEGACY_CHECKOUT;
514
+ };
515
+ // This recursive function is for users who step away from their computer and come back needing a new exchange rate
516
+ const startExchangeRateTimeout = ({ isGuaranteed, maxAge, }) => {
517
+ if (localizationStore.exchangeRateTimeout) {
518
+ clearTimeout(localizationStore.exchangeRateTimeout);
519
+ }
520
+ // maxAge comes in seconds, convert to milliseconds
521
+ const defaultMaxAge = 5 * 60;
522
+ const maxAgeToUse = maxAge || defaultMaxAge;
523
+ // Recursively set timeouts to get new exchange rates when the current one expires
524
+ localizationStore.exchangeRateTimeout = setTimeout(async () => {
525
+ const { maxAge: newMaxAge } = await triggerGetExchangeRate(isGuaranteed);
526
+ startExchangeRateTimeout({ isGuaranteed, maxAge: newMaxAge });
527
+ }, maxAgeToUse * 1000);
528
+ };
529
+ const getNewLocalization = async () => {
530
+ var _a;
531
+ handleFetch.log('get new localization store');
532
+ const { isDisabledCountry, isShippableCountry, selectedCountryCode } = localizationStore;
533
+ if (!window.Zonos.isLegacyCheckout) {
534
+ // These requests are only needed for Hello, so we can skip them for legacy checkout
535
+ localizationStore.countryLandedCost = await getCountryLandedCost(localizationStore.selectedCountryCode);
536
+ localizationStore.inclusivePricing =
537
+ ((_a = (await getInclusivePricing(selectedCountryCode))) === null || _a === void 0 ? void 0 : _a.setting) || null;
538
+ if (localizationStore.inclusivePricing) {
539
+ handleFetch.log(`Inclusive price setting found for this country (${selectedCountryCode}) ${JSON.stringify(localizationStore.inclusivePricing, null, 2)}`);
540
+ }
541
+ }
542
+ else {
543
+ handleFetch.log('Skipping country landed cost and inclusive pricing requests, because this is a legacy checkout');
544
+ }
545
+ if (zonosStore.zonosStore.helloSettings.currencyBehavior === 'DISABLED' ||
546
+ !isShippableCountry ||
547
+ isDisabledCountry ||
548
+ !selectedCountryCode) {
549
+ return;
550
+ }
551
+ const isGuaranteed = zonosStore.zonosStore.checkoutSettings.visibilityStatus === 'ENABLED';
552
+ const { maxAge } = await triggerGetExchangeRate(isGuaranteed);
553
+ startExchangeRateTimeout({ isGuaranteed, maxAge });
554
+ };
555
+ const getCustomMessages = async () => {
556
+ handleFetch.log(`Getting custom messages for ${localizationStore.selectedCountryCode}`);
557
+ if (!localizationStore.selectedCountryCode || !zonosStore.zonosStore.storeId) {
558
+ return;
559
+ }
560
+ const localeMessages = await getLocaleMessages({
561
+ countryCode: localizationStore.selectedCountryCode,
562
+ localeTo: localizationStore.selectedLocale,
563
+ storeId: zonosStore.zonosStore.storeId,
564
+ });
565
+ const allMessages = localeMessages.flatMap(x => {
566
+ var _a;
567
+ return {
568
+ countryCode: localizationStore.selectedCountryCode,
569
+ message: (_a = x.countryCodesPageMessageLinks.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message.textTo,
570
+ pageName: x.pageName,
571
+ };
572
+ });
573
+ localizationStore.customMessages = allMessages;
574
+ };
575
+ const getOverrideLocale = () => {
576
+ const currentUrl = new URL(window.location.href);
577
+ const zonosLocale = currentUrl.searchParams.get('zonosLocale');
578
+ return zonosLocale;
579
+ };
580
+ const addInternationalHideClass = () => {
581
+ if (localizationStore.isShippableCountry) {
582
+ document.body.classList.add('z-intl');
583
+ }
584
+ else {
585
+ document.body.classList.remove('z-intl');
586
+ }
587
+ };
588
+ const getValidCountryCode = (countryCode) => {
589
+ if (countryCode === 'UK') {
590
+ return 'GB';
591
+ }
592
+ return countryCode;
593
+ };
594
+ const localizationStoreUpdateSelectedCountryCode = (newSelectedCountryCode) => {
595
+ var _a, _b;
596
+ handleFetch.log(`Updating selected country code to ${newSelectedCountryCode}`);
597
+ const isFirstTime = !localizationStore.selectedCountryCode;
598
+ localizationStore.selectedCountryCode = getValidCountryCode(newSelectedCountryCode);
599
+ const { selectedCountryCode, shippingZoneCountries } = localizationStore;
600
+ const isShippableCountry = !!shippingZoneCountries &&
601
+ !!selectedCountryCode &&
602
+ !!shippingZoneCountries[selectedCountryCode] &&
603
+ // Make sure the country is not in the disabled countries list
604
+ !zonosStore.zonosStore.disabledCountries.includes(selectedCountryCode);
605
+ // update shippable country
606
+ localizationStore.isShippableCountry = isShippableCountry;
607
+ handleFetch.log(`${localizationStore.selectedCountryCode} is a shippable country: ${localizationStore.isShippableCountry}`);
608
+ const isDisabledCountry = !!selectedCountryCode &&
609
+ zonosStore.zonosStore.disabledCountries.includes(selectedCountryCode);
610
+ localizationStore.isDisabledCountry = isDisabledCountry;
611
+ handleFetch.log(`${localizationStore.selectedCountryCode} is a disabled country: ${localizationStore.isDisabledCountry}`);
612
+ addInternationalHideClass();
613
+ if (!selectedCountryCode) {
614
+ return;
615
+ }
616
+ const currencyCode = getCurrencyCode(selectedCountryCode);
617
+ // Only trigger callback onCountryChange if the country code has been set before
618
+ if (!isFirstTime) {
619
+ // Trigger callback onCountryChange
620
+ (_a = zonosStore.zonosStore.onCountryChange) === null || _a === void 0 ? void 0 : _a.call(zonosStore.zonosStore, {
621
+ countryCode: selectedCountryCode,
622
+ currencyCode,
623
+ isShippableCountry: isShippableCountry,
624
+ });
625
+ }
626
+ if (!currencyCode) {
627
+ return;
628
+ }
629
+ localizationStore.targetCurrency = currencyCode;
630
+ void getNewLocalization();
631
+ // Save the country code to session storage for later use
632
+ window.sessionStorage.setItem('zonos--country', selectedCountryCode);
633
+ // Update the URL query param with the new country code
634
+ setZCountryUrlParam(selectedCountryCode);
635
+ (_b = document
636
+ .querySelector('zonos-hello')) === null || _b === void 0 ? void 0 : _b.setAttribute('z-country', selectedCountryCode);
637
+ };
638
+ const initHelloCountryList = (allCountries) => {
639
+ const showCountryList = zonosStore.zonosStore.helloSettings.showCountryList;
640
+ const hellCountryList = localizationStore.shippingZoneCountries;
641
+ if (!showCountryList || showCountryList === 'ONLY_SHIPPABLE') {
642
+ // just use the shipping zone countries
643
+ localizationStore.helloCountryList = hellCountryList;
644
+ return;
645
+ }
646
+ if (showCountryList === 'ALL') {
647
+ localizationStore.helloCountryList = allCountries;
648
+ return;
649
+ }
650
+ // get all active countries in the showCountryList
651
+ localizationStore.helloCountryList = showCountryList.reduce((acc, countryCode) => {
652
+ const countryInfo = allCountries === null || allCountries === void 0 ? void 0 : allCountries[countryCode];
653
+ return countryInfo
654
+ ? Object.assign(Object.assign({}, acc), { [countryCode]: countryInfo }) : acc;
655
+ }, {});
656
+ };
657
+ const updateCheckoutSessionLanguage = async () => {
658
+ if (!storageStore.checkoutSessionId) {
659
+ return null;
660
+ }
661
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/update-checkout-session-metadata', {
662
+ body: {
663
+ id: storageStore.checkoutSessionId,
664
+ metadata: [
665
+ // This is being used from the backend to determine the language of the checkout session
666
+ {
667
+ key: 'language',
668
+ value: localizationStore.selectedLocale,
669
+ },
670
+ ],
671
+ },
672
+ method: 'POST',
673
+ });
674
+ if (errors.length || !json) {
675
+ handleFetch.logError('Error occurs when updating checkout session', JSON.stringify(errors, null, 2));
676
+ return { errors, json };
677
+ }
678
+ return { errors: [], json };
679
+ };
680
+ const localizationStoreUpdateSelectedLocale = (newSelectedLocale) => {
681
+ localizationStore.selectedLocale = newSelectedLocale;
682
+ translationStore.translationStoreUpdateLanguage(newSelectedLocale);
683
+ void updateCheckoutSessionLanguage();
684
+ void getCustomMessages();
685
+ };
686
+ const initLocalizationStore = async () => {
687
+ // all countries from countries.json, shipping zone and localization
688
+ const [allCountries, shippingZoneCountries, localization] = await Promise.all([getCountries(), getShippingZones(), getLocalization()]);
689
+ // Filter countries to only include countries in the shipping zone
690
+ const filteredCountries = shippingZoneCountries === null || shippingZoneCountries === void 0 ? void 0 : shippingZoneCountries.reduce((acc, countryCode) => {
691
+ const countryInfo = allCountries === null || allCountries === void 0 ? void 0 : allCountries[countryCode];
692
+ return countryInfo
693
+ ? Object.assign(Object.assign({}, acc), { [countryCode]: countryInfo }) : acc;
694
+ }, {});
695
+ localizationStore.shippingZoneCountries = filteredCountries || null;
696
+ // Initialize the country list for the hello widget
697
+ initHelloCountryList(allCountries || {});
698
+ const { country, locale } = localization;
699
+ handleFetch.log(`Country code from localization: ${country}`);
700
+ handleFetch.log(`Locale from localization: ${locale}`);
701
+ // update selected country code in store
702
+ localizationStoreUpdateSelectedCountryCode(country);
703
+ // use locale from params if it exists, otherwise use locale from localization
704
+ const overrideLocale = getOverrideLocale();
705
+ localizationStoreUpdateSelectedLocale(overrideLocale || locale || 'en');
706
+ const devSites = [
707
+ 'dev.storybook.elements',
708
+ 'dev.elements',
709
+ 'dev.demo.elements',
710
+ 'dev.dashboard',
711
+ ];
712
+ // If the country code is not set, set it to the US for development (vercel can't get geo country in dev)
713
+ if (!localizationStore.selectedCountryCode &&
714
+ devSites.some(site => window.location.origin.includes(site))) {
715
+ // update selected country code in store
716
+ localizationStoreUpdateSelectedCountryCode('CA');
717
+ }
718
+ localizationStore.localizationLoaded = true;
719
+ };
720
+
721
+ exports.VARIANT_TEST_KEY_EXPIRATION = VARIANT_TEST_KEY_EXPIRATION;
722
+ exports.currencyConvert = currencyConvert;
723
+ exports.currencyConvertAndFormat = currencyConvertAndFormat;
724
+ exports.currencyDisplay = currencyDisplay;
725
+ exports.currencyFormat = currencyFormat;
726
+ exports.filterValidTests = filterValidTests;
727
+ exports.getFallbackDefaultCountryCode = getFallbackDefaultCountryCode;
728
+ exports.getZCountryUrlParam = getZCountryUrlParam;
729
+ exports.initLocalizationStore = initLocalizationStore;
730
+ exports.isValidSelector = isValidSelector;
731
+ exports.localizationStore = localizationStore;
732
+ exports.localizationStoreOnChange = localizationStoreOnChange;
733
+ exports.localizationStoreUpdateSelectedCountryCode = localizationStoreUpdateSelectedCountryCode;
734
+ exports.localizationStoreUpdateSelectedLocale = localizationStoreUpdateSelectedLocale;
735
+ exports.setZCountryUrlParam = setZCountryUrlParam;
736
+ exports.storageStore = storageStore;
737
+ exports.storageStoreOnChange = storageStoreOnChange;
738
+ exports.storageStoreSetEnabledVariantTestKeys = storageStoreSetEnabledVariantTestKeys;