@zonos/elements 1.3.233 → 1.3.234

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 (413) hide show
  1. package/dist/cjs/{cart-bc615014.js → cart-22ced7cc.js} +33 -29
  2. package/dist/cjs/{shouldRenderTaxIdInput-9b8a8de1.js → containsNonLatinChars-2be5129b.js} +0 -23
  3. package/dist/cjs/{hasInclusivePrice-84145546.js → hasInclusivePrice-ca85cabd.js} +1 -1
  4. package/dist/cjs/index.cjs.js +11 -7
  5. package/dist/cjs/invoice-8fd4242c.js +151 -0
  6. package/dist/cjs/{renderFallback-c2576fbe.js → isCollectMobileTablet-7962c57f.js} +2 -11
  7. package/dist/cjs/isInvoiceMobileTablet-dde41e4e.js +15 -0
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/{translationStore-08d3ff9c.js → localization-8ef6250a.js} +1059 -1
  10. package/dist/cjs/{paypal-1d6f1a71.js → paypal-4a086f84.js} +7 -8
  11. package/dist/cjs/placeTestOrder-f25d08ee.js +45 -0
  12. package/dist/cjs/{placeTestOrder-a5469e40.js → renderCheckoutCurrency-5494e45b.js} +2 -42
  13. package/dist/cjs/renderFallback-78b54537.js +12 -0
  14. package/dist/cjs/shouldRenderTaxIdInput-eda13ef8.js +25 -0
  15. package/dist/cjs/throttle-7dd64984.js +76 -0
  16. package/dist/cjs/{zonos-address_11.cjs.entry.js → zonos-address-display_9.cjs.entry.js} +62 -668
  17. package/dist/cjs/zonos-address_4.cjs.entry.js +715 -0
  18. package/dist/cjs/zonos-badge.cjs.entry.js +3 -3
  19. package/dist/cjs/{zonos-banner_2.cjs.entry.js → zonos-banner.cjs.entry.js} +0 -40
  20. package/dist/cjs/zonos-button_3.cjs.entry.js +3 -3
  21. package/dist/cjs/{zonos-empty-state-payment_4.cjs.entry.js → zonos-card_5.cjs.entry.js} +44 -6
  22. package/dist/cjs/{zonos-cart-items_13.cjs.entry.js → zonos-cart-items_12.cjs.entry.js} +75 -92
  23. package/dist/cjs/zonos-checkout.cjs.entry.js +20 -21
  24. package/dist/cjs/zonos-collapse.cjs.entry.js +2 -2
  25. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +5 -6
  26. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +66 -65
  27. package/dist/cjs/zonos-collect.cjs.entry.js +25 -25
  28. package/dist/cjs/zonos-component.cjs.entry.js +1 -1
  29. package/dist/cjs/zonos-controller.cjs.entry.js +39 -10
  30. package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -2
  31. package/dist/cjs/zonos-country-select_4.cjs.entry.js +10 -11
  32. package/dist/cjs/zonos-elements.cjs.js +1 -1
  33. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +30 -31
  34. package/dist/cjs/zonos-hello.cjs.entry.js +7 -8
  35. package/dist/cjs/zonos-input.cjs.entry.js +4 -4
  36. package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +94 -0
  37. package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +686 -0
  38. package/dist/cjs/zonos-invoice.cjs.entry.js +466 -0
  39. package/dist/cjs/zonos-language-select_2.cjs.entry.js +5 -6
  40. package/dist/cjs/zonos-link.cjs.entry.js +24 -0
  41. package/dist/cjs/zonos-logo.cjs.entry.js +2 -2
  42. package/dist/cjs/zonos-stripe-input.cjs.entry.js +5 -5
  43. package/dist/cjs/zonos-toggle.cjs.entry.js +2 -2
  44. package/dist/cjs/zonos-tooltip.cjs.entry.js +2 -2
  45. package/dist/cjs/zonos-v-stack.cjs.entry.js +2 -2
  46. package/dist/collection/collection-manifest.json +8 -0
  47. package/dist/collection/components/checkout/zonos-invoice/assets/ChevronDownIcon.svg +1 -0
  48. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-cart-items/assets/empty-item.jpeg +0 -0
  49. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-cart-items/zonos-invoice-cart-items.css +72 -0
  50. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-cart-items/zonos-invoice-cart-items.js +87 -0
  51. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-finish/assets/RemoveIcon.svg +1 -0
  52. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-finish/assets/SuccessIcon.svg +1 -0
  53. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-finish/zonos-invoice-finish.css +90 -0
  54. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-finish/zonos-invoice-finish.js +405 -0
  55. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-footer/assets/chevronDownIcon.svg +1 -0
  56. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-footer/assets/globe.svg +3 -0
  57. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-footer/assets/zonosIconDark.svg +10 -0
  58. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-footer/assets/zonosIconLight.svg +10 -0
  59. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-footer/assets/zonosWordmark.svg +7 -0
  60. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-footer/zonos-invoice-footer.css +155 -0
  61. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-footer/zonos-invoice-footer.js +165 -0
  62. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-order-details/assets/ChevronDownIcon.svg +1 -0
  63. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-order-details/assets/ChevronUpIcon.svg +1 -0
  64. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-order-details/zonos-invoice-order-details.css +117 -0
  65. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-order-details/zonos-invoice-order-details.js +175 -0
  66. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-payment/assets/CheckmarkLineIcon.svg +1 -0
  67. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-payment/assets/RemoveLineIcon.svg +1 -0
  68. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-payment/zonos-invoice-payment.css +98 -0
  69. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-payment/zonos-invoice-payment.js +368 -0
  70. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-review/zonos-invoice-review.css +71 -0
  71. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-review/zonos-invoice-review.js +151 -0
  72. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-subtotal/zonos-invoice-subtotal.css +83 -0
  73. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-subtotal/zonos-invoice-subtotal.js +65 -0
  74. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice.css +350 -0
  75. package/dist/collection/components/checkout/zonos-invoice/zonos-invoice.js +545 -0
  76. package/dist/collection/components/common/zonos-badge/zonos-badge.js +3 -3
  77. package/dist/collection/components/common/zonos-button/zonos-button.js +3 -3
  78. package/dist/collection/components/common/zonos-card/zonos-card.js +4 -4
  79. package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.js +3 -3
  80. package/dist/collection/components/common/zonos-checkout-progress-tabs/zonos-checkout-progress-tabs.js +3 -3
  81. package/dist/collection/components/common/zonos-collapse/zonos-collapse.js +2 -2
  82. package/dist/collection/components/common/zonos-confirm-dialog/zonos-confirm-dialog.js +3 -3
  83. package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +3 -3
  84. package/dist/collection/components/common/zonos-custom-message/zonos-custom-message.js +2 -2
  85. package/dist/collection/components/common/zonos-dialog/zonos-dialog.js +3 -3
  86. package/dist/collection/components/common/zonos-h-stack/zonos-h-stack.js +2 -2
  87. package/dist/collection/components/common/zonos-input/zonos-input.js +4 -4
  88. package/dist/collection/components/common/zonos-language-select/zonos-language-select.js +2 -2
  89. package/dist/collection/components/common/zonos-link/zonos-link.js +1 -1
  90. package/dist/collection/components/common/zonos-loading-overlay/zonos-loading-overlay.js +1 -1
  91. package/dist/collection/components/common/zonos-logo/zonos-logo.js +2 -2
  92. package/dist/collection/components/common/zonos-rest-state/zonos-rest-state.js +3 -3
  93. package/dist/collection/components/common/zonos-select-dialog-header/zonos-select-dialog-header.js +2 -2
  94. package/dist/collection/components/common/zonos-skeleton/zonos-skeleton.js +1 -1
  95. package/dist/collection/components/common/zonos-stripe-input/zonos-stripe-input.js +5 -5
  96. package/dist/collection/components/common/zonos-stripe-phone-input/zonos-stripe-phone-input.js +5 -5
  97. package/dist/collection/components/common/zonos-stripe-select/zonos-stripe-select.js +5 -5
  98. package/dist/collection/components/common/zonos-toggle/zonos-toggle.js +2 -2
  99. package/dist/collection/components/common/zonos-tooltip/zonos-tooltip.js +2 -2
  100. package/dist/collection/components/common/zonos-v-stack/zonos-v-stack.js +2 -2
  101. package/dist/collection/components/common/zonos-virtual-scroll/zonos-virtual-scroll.js +2 -2
  102. package/dist/collection/components/component-template/zonos-component/zonos-component.js +1 -1
  103. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.js +2 -2
  104. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +4 -4
  105. package/dist/collection/components/main/zonos-controller.js +45 -4
  106. package/dist/collection/components/paypal/zonos-paypal-payment.js +1 -1
  107. package/dist/collection/components/store/checkout/invoice.js +148 -0
  108. package/dist/collection/components/store/checkout/stripe.js +8 -3
  109. package/dist/collection/components/store/translationStore/strings.arabic.js +9 -0
  110. package/dist/collection/components/store/translationStore/strings.base.js +9 -0
  111. package/dist/collection/components/store/translationStore/strings.chinese.js +9 -0
  112. package/dist/collection/components/store/translationStore/strings.danish.js +9 -0
  113. package/dist/collection/components/store/translationStore/strings.dutch.js +9 -0
  114. package/dist/collection/components/store/translationStore/strings.french.js +9 -0
  115. package/dist/collection/components/store/translationStore/strings.german.js +9 -0
  116. package/dist/collection/components/store/translationStore/strings.hebrew.js +9 -0
  117. package/dist/collection/components/store/translationStore/strings.indonesian.js +9 -0
  118. package/dist/collection/components/store/translationStore/strings.italian.js +9 -0
  119. package/dist/collection/components/store/translationStore/strings.japanese.js +9 -0
  120. package/dist/collection/components/store/translationStore/strings.korean.js +9 -0
  121. package/dist/collection/components/store/translationStore/strings.norwegian.js +9 -0
  122. package/dist/collection/components/store/translationStore/strings.polish.js +9 -0
  123. package/dist/collection/components/store/translationStore/strings.portuguese.js +9 -0
  124. package/dist/collection/components/store/translationStore/strings.russian.js +9 -0
  125. package/dist/collection/components/store/translationStore/strings.spanish.js +9 -0
  126. package/dist/collection/components/store/translationStore/strings.swedish.js +9 -0
  127. package/dist/collection/components/store/translationStore/strings.turkish.js +9 -0
  128. package/dist/collection/components/store/translationStore/strings.vietnamese.js +9 -0
  129. package/dist/collection/components/stripe/zonos-address/zonos-address.js +8 -5
  130. package/dist/collection/components/stripe/zonos-custom-address/zonos-address-suggestions/zonos-address-suggestions.js +2 -2
  131. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +2 -2
  132. package/dist/collection/components/stripe/zonos-payment/zonos-payment.js +1 -1
  133. package/dist/collection/components/utils/checkout/initInvoice.js +15 -0
  134. package/dist/collection/components/utils/checkout/isInvoiceMobileTablet.js +10 -0
  135. package/dist/collection/scripts/_zonosBase.js +4 -0
  136. package/dist/esm/{cart-14f305b3.js → cart-66aecbb3.js} +9 -5
  137. package/dist/esm/{shouldRenderTaxIdInput-8bc112bb.js → containsNonLatinChars-2d8810c3.js} +1 -23
  138. package/dist/esm/{hasInclusivePrice-0eda8ba9.js → hasInclusivePrice-2a1bf474.js} +1 -1
  139. package/dist/esm/index.js +11 -7
  140. package/dist/esm/invoice-c7452847.js +146 -0
  141. package/dist/esm/{renderFallback-dbf1e3ae.js → isCollectMobileTablet-921002b0.js} +3 -11
  142. package/dist/esm/isInvoiceMobileTablet-1f7b614e.js +12 -0
  143. package/dist/esm/loader.js +1 -1
  144. package/dist/esm/{translationStore-690c4e04.js → localization-04b05867.js} +1041 -2
  145. package/dist/esm/{paypal-fded8844.js → paypal-56564874.js} +2 -3
  146. package/dist/esm/placeTestOrder-6b9eda9e.js +43 -0
  147. package/dist/esm/{placeTestOrder-2250f719.js → renderCheckoutCurrency-cb808110.js} +3 -42
  148. package/dist/esm/renderFallback-3f010b48.js +10 -0
  149. package/dist/esm/shouldRenderTaxIdInput-d45ceeb4.js +23 -0
  150. package/dist/esm/throttle-ce2432ab.js +74 -0
  151. package/dist/esm/{zonos-address_11.entry.js → zonos-address-display_9.entry.js} +32 -636
  152. package/dist/esm/zonos-address_4.entry.js +708 -0
  153. package/dist/esm/zonos-badge.entry.js +3 -3
  154. package/dist/esm/{zonos-banner_2.entry.js → zonos-banner.entry.js} +1 -40
  155. package/dist/esm/zonos-button_3.entry.js +3 -3
  156. package/dist/esm/{zonos-empty-state-payment_4.entry.js → zonos-card_5.entry.js} +44 -7
  157. package/dist/esm/{zonos-cart-items_13.entry.js → zonos-cart-items_12.entry.js} +15 -31
  158. package/dist/esm/zonos-checkout.entry.js +3 -4
  159. package/dist/esm/zonos-collapse.entry.js +2 -2
  160. package/dist/esm/zonos-collect-cart-items_3.entry.js +5 -6
  161. package/dist/esm/zonos-collect-finish_6.entry.js +7 -6
  162. package/dist/esm/zonos-collect.entry.js +5 -5
  163. package/dist/esm/zonos-component.entry.js +1 -1
  164. package/dist/esm/zonos-controller.entry.js +39 -10
  165. package/dist/esm/zonos-country-flag.entry.js +1 -2
  166. package/dist/esm/zonos-country-select_4.entry.js +10 -11
  167. package/dist/esm/zonos-elements.js +1 -1
  168. package/dist/esm/zonos-hello-dialog.entry.js +6 -7
  169. package/dist/esm/zonos-hello.entry.js +1 -2
  170. package/dist/esm/zonos-input.entry.js +4 -4
  171. package/dist/esm/zonos-invoice-cart-items_2.entry.js +89 -0
  172. package/dist/esm/zonos-invoice-finish_5.entry.js +678 -0
  173. package/dist/esm/zonos-invoice.entry.js +462 -0
  174. package/dist/esm/zonos-language-select_2.entry.js +5 -6
  175. package/dist/esm/zonos-link.entry.js +20 -0
  176. package/dist/esm/zonos-logo.entry.js +2 -2
  177. package/dist/esm/zonos-stripe-input.entry.js +5 -5
  178. package/dist/esm/zonos-toggle.entry.js +2 -2
  179. package/dist/esm/zonos-tooltip.entry.js +2 -2
  180. package/dist/esm/zonos-v-stack.entry.js +2 -2
  181. package/dist/esm-es5/cart-66aecbb3.js +1 -0
  182. package/dist/esm-es5/containsNonLatinChars-2d8810c3.js +1 -0
  183. package/dist/esm-es5/{hasInclusivePrice-0eda8ba9.js → hasInclusivePrice-2a1bf474.js} +1 -1
  184. package/dist/esm-es5/index.js +1 -1
  185. package/dist/esm-es5/invoice-c7452847.js +1 -0
  186. package/dist/esm-es5/isCollectMobileTablet-921002b0.js +1 -0
  187. package/dist/esm-es5/isInvoiceMobileTablet-1f7b614e.js +1 -0
  188. package/dist/esm-es5/loader.js +1 -1
  189. package/dist/esm-es5/localization-04b05867.js +1 -0
  190. package/dist/esm-es5/{paypal-fded8844.js → paypal-56564874.js} +1 -1
  191. package/dist/esm-es5/placeTestOrder-6b9eda9e.js +1 -0
  192. package/dist/esm-es5/renderCheckoutCurrency-cb808110.js +1 -0
  193. package/dist/esm-es5/renderFallback-3f010b48.js +1 -0
  194. package/dist/esm-es5/shouldRenderTaxIdInput-d45ceeb4.js +1 -0
  195. package/dist/esm-es5/throttle-ce2432ab.js +1 -0
  196. package/dist/esm-es5/zonos-address-display_9.entry.js +1 -0
  197. package/dist/esm-es5/zonos-address_4.entry.js +1 -0
  198. package/dist/esm-es5/zonos-badge.entry.js +1 -1
  199. package/dist/esm-es5/zonos-banner.entry.js +1 -0
  200. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  201. package/dist/esm-es5/zonos-card_5.entry.js +1 -0
  202. package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -0
  203. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  204. package/dist/esm-es5/zonos-collapse.entry.js +1 -1
  205. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  206. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  207. package/dist/esm-es5/zonos-collect.entry.js +1 -1
  208. package/dist/esm-es5/zonos-component.entry.js +1 -1
  209. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  210. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  211. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  212. package/dist/esm-es5/zonos-elements.js +1 -1
  213. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  214. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  215. package/dist/esm-es5/zonos-input.entry.js +1 -1
  216. package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -0
  217. package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -0
  218. package/dist/esm-es5/zonos-invoice.entry.js +1 -0
  219. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  220. package/dist/esm-es5/zonos-link.entry.js +1 -0
  221. package/dist/esm-es5/zonos-logo.entry.js +1 -1
  222. package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
  223. package/dist/esm-es5/zonos-toggle.entry.js +1 -1
  224. package/dist/esm-es5/zonos-tooltip.entry.js +1 -1
  225. package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
  226. package/dist/scripts/index.d.ts +356 -0
  227. package/dist/scripts/index.js +1 -1
  228. package/dist/scripts/loadZonos.js +1 -1
  229. package/dist/scripts/zonos.js +1 -1
  230. package/dist/types/components/checkout/zonos-invoice/zonos-invoice-cart-items/zonos-invoice-cart-items.d.ts +10 -0
  231. package/dist/types/components/checkout/zonos-invoice/zonos-invoice-finish/zonos-invoice-finish.d.ts +50 -0
  232. package/dist/types/components/checkout/zonos-invoice/zonos-invoice-footer/zonos-invoice-footer.d.ts +25 -0
  233. package/dist/types/components/checkout/zonos-invoice/zonos-invoice-order-details/zonos-invoice-order-details.d.ts +28 -0
  234. package/dist/types/components/checkout/zonos-invoice/zonos-invoice-payment/zonos-invoice-payment.d.ts +62 -0
  235. package/dist/types/components/checkout/zonos-invoice/zonos-invoice-review/zonos-invoice-review.d.ts +22 -0
  236. package/dist/types/components/checkout/zonos-invoice/zonos-invoice-subtotal/zonos-invoice-subtotal.d.ts +7 -0
  237. package/dist/types/components/checkout/zonos-invoice/zonos-invoice.d.ts +86 -0
  238. package/dist/types/components/main/zonos-controller.d.ts +4 -0
  239. package/dist/types/components/store/checkout/invoice.d.ts +19 -0
  240. package/dist/types/components/store/translationStore/strings.arabic.d.ts +9 -0
  241. package/dist/types/components/store/translationStore/strings.base.d.ts +9 -0
  242. package/dist/types/components/store/translationStore/strings.chinese.d.ts +9 -0
  243. package/dist/types/components/store/translationStore/strings.danish.d.ts +9 -0
  244. package/dist/types/components/store/translationStore/strings.dutch.d.ts +9 -0
  245. package/dist/types/components/store/translationStore/strings.french.d.ts +9 -0
  246. package/dist/types/components/store/translationStore/strings.german.d.ts +9 -0
  247. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +9 -0
  248. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +9 -0
  249. package/dist/types/components/store/translationStore/strings.italian.d.ts +9 -0
  250. package/dist/types/components/store/translationStore/strings.japanese.d.ts +9 -0
  251. package/dist/types/components/store/translationStore/strings.korean.d.ts +9 -0
  252. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +9 -0
  253. package/dist/types/components/store/translationStore/strings.polish.d.ts +9 -0
  254. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +9 -0
  255. package/dist/types/components/store/translationStore/strings.russian.d.ts +9 -0
  256. package/dist/types/components/store/translationStore/strings.spanish.d.ts +9 -0
  257. package/dist/types/components/store/translationStore/strings.swedish.d.ts +9 -0
  258. package/dist/types/components/store/translationStore/strings.turkish.d.ts +9 -0
  259. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +9 -0
  260. package/dist/types/components/utils/checkout/initInvoice.d.ts +1 -0
  261. package/dist/types/components/utils/checkout/isInvoiceMobileTablet.d.ts +4 -0
  262. package/dist/types/components.d.ts +351 -0
  263. package/dist/types/scripts/_zonosBase.d.ts +5 -0
  264. package/dist/types/types/checkout/api/CheckoutSession.d.ts +4 -0
  265. package/dist/types/types/checkout/api/PartyInfo.d.ts +21 -0
  266. package/dist/zonos-elements/index.esm.js +1 -1
  267. package/dist/zonos-elements/p-00719e49.entry.js +1 -0
  268. package/dist/zonos-elements/p-01b0a2e2.js +1 -0
  269. package/dist/zonos-elements/p-01dada4e.js +1 -0
  270. package/dist/zonos-elements/p-0c64dbbb.js +1 -0
  271. package/dist/zonos-elements/p-0cd5bcb3.entry.js +1 -0
  272. package/dist/zonos-elements/p-0e82fcea.entry.js +1 -0
  273. package/dist/zonos-elements/p-10316d4d.system.entry.js +1 -0
  274. package/dist/zonos-elements/{p-0a90dd80.system.entry.js → p-121c60c1.system.entry.js} +1 -1
  275. package/dist/zonos-elements/{p-bf9d889f.entry.js → p-14314ad3.entry.js} +1 -1
  276. package/dist/zonos-elements/p-170314a3.js +1 -0
  277. package/dist/zonos-elements/p-17a09191.entry.js +1 -0
  278. package/dist/zonos-elements/p-18bc6c7a.entry.js +1 -0
  279. package/dist/zonos-elements/{p-a25428eb.system.js → p-18d20206.system.js} +2 -2
  280. package/dist/zonos-elements/p-1a30fe18.system.entry.js +1 -0
  281. package/dist/zonos-elements/{p-c7b658cb.entry.js → p-1c4d12f0.entry.js} +1 -1
  282. package/dist/zonos-elements/p-1f3549c6.js +1 -0
  283. package/dist/zonos-elements/p-2250e585.entry.js +1 -0
  284. package/dist/zonos-elements/p-248dd596.system.entry.js +1 -0
  285. package/dist/zonos-elements/{p-5f398c28.entry.js → p-264690d7.entry.js} +1 -1
  286. package/dist/zonos-elements/p-2670438c.system.js +1 -0
  287. package/dist/zonos-elements/p-27f6930b.js +1 -0
  288. package/dist/zonos-elements/{p-eea0eb57.system.entry.js → p-2f869f2c.system.entry.js} +1 -1
  289. package/dist/zonos-elements/p-30c661b3.system.entry.js +1 -0
  290. package/dist/zonos-elements/p-34bf7bbe.system.js +1 -0
  291. package/dist/zonos-elements/p-38913b2f.entry.js +1 -0
  292. package/dist/zonos-elements/p-3bec13dd.system.js +1 -0
  293. package/dist/zonos-elements/{p-00ec22b2.entry.js → p-43a22d85.entry.js} +1 -1
  294. package/dist/zonos-elements/p-44b50260.entry.js +1 -0
  295. package/dist/zonos-elements/p-48dc96f9.system.entry.js +1 -0
  296. package/dist/zonos-elements/p-4aa86184.system.entry.js +1 -0
  297. package/dist/zonos-elements/p-4d594c8e.system.js +1 -0
  298. package/dist/zonos-elements/p-4ffbb0d6.system.js +1 -0
  299. package/dist/zonos-elements/{p-452fb638.system.entry.js → p-5062dcf3.system.entry.js} +1 -1
  300. package/dist/zonos-elements/{p-c5cb2364.system.entry.js → p-57cee1b5.system.entry.js} +1 -1
  301. package/dist/zonos-elements/p-59a76f73.entry.js +1 -0
  302. package/dist/zonos-elements/{p-d556c6d1.system.entry.js → p-5afb9260.system.entry.js} +1 -1
  303. package/dist/zonos-elements/p-5e9b45f7.entry.js +1 -0
  304. package/dist/zonos-elements/{p-88ea9f82.entry.js → p-6626d240.entry.js} +1 -1
  305. package/dist/zonos-elements/p-6688473e.entry.js +1 -0
  306. package/dist/zonos-elements/p-6f23a26a.system.js +1 -0
  307. package/dist/zonos-elements/{p-82739127.js → p-73c737aa.js} +2 -2
  308. package/dist/zonos-elements/p-757d4c62.system.entry.js +1 -0
  309. package/dist/zonos-elements/p-7aa50ef2.entry.js +1 -0
  310. package/dist/zonos-elements/p-7e17667d.js +1 -0
  311. package/dist/zonos-elements/p-7e469c5c.entry.js +1 -0
  312. package/dist/zonos-elements/p-7f91617c.system.entry.js +1 -0
  313. package/dist/zonos-elements/p-81e3eb5b.js +1 -0
  314. package/dist/zonos-elements/p-82febf70.system.js +1 -0
  315. package/dist/zonos-elements/{p-770852bf.system.entry.js → p-836db369.system.entry.js} +1 -1
  316. package/dist/zonos-elements/p-83b3f824.system.entry.js +1 -0
  317. package/dist/zonos-elements/p-851011aa.system.entry.js +1 -0
  318. package/dist/zonos-elements/{p-936b54c1.entry.js → p-865536f0.entry.js} +1 -1
  319. package/dist/zonos-elements/{p-b1fd1ec2.system.entry.js → p-8792fef2.system.entry.js} +1 -1
  320. package/dist/zonos-elements/p-890bfc42.system.entry.js +1 -0
  321. package/dist/zonos-elements/{p-c288c6da.system.entry.js → p-89a5e936.system.entry.js} +1 -1
  322. package/dist/zonos-elements/p-8af188f8.system.js +1 -0
  323. package/dist/zonos-elements/p-8d3a62fb.entry.js +1 -0
  324. package/dist/zonos-elements/{p-00ac999f.system.entry.js → p-8dc025c7.system.entry.js} +1 -1
  325. package/dist/zonos-elements/p-944d00da.entry.js +1 -0
  326. package/dist/zonos-elements/p-9479f155.system.js +1 -0
  327. package/dist/zonos-elements/p-95dc475b.system.js +1 -0
  328. package/dist/zonos-elements/p-976afc17.system.js +1 -0
  329. package/dist/zonos-elements/p-97d56c21.system.entry.js +1 -0
  330. package/dist/zonos-elements/p-9b9bfb6d.entry.js +1 -0
  331. package/dist/zonos-elements/{p-55e2e4ed.entry.js → p-9f1bd9b8.entry.js} +1 -1
  332. package/dist/zonos-elements/p-9fa32fdf.js +1 -0
  333. package/dist/zonos-elements/p-a2a0bf4e.js +1 -0
  334. package/dist/zonos-elements/p-a610c24e.system.entry.js +1 -0
  335. package/dist/zonos-elements/{p-9b8750f3.entry.js → p-aedd3911.entry.js} +1 -1
  336. package/dist/zonos-elements/{p-db628e49.system.entry.js → p-b5c31ca4.system.entry.js} +1 -1
  337. package/dist/zonos-elements/p-ba456282.system.entry.js +1 -0
  338. package/dist/zonos-elements/{p-31af91f0.entry.js → p-bd603c1a.entry.js} +1 -1
  339. package/dist/zonos-elements/p-c2442878.system.js +1 -1
  340. package/dist/zonos-elements/p-dc5fb21c.js +1 -0
  341. package/dist/zonos-elements/p-dc94d7eb.js +1 -0
  342. package/dist/zonos-elements/p-e5e64e16.system.js +1 -0
  343. package/dist/zonos-elements/{p-540cec7e.system.entry.js → p-e9e6bea7.system.entry.js} +1 -1
  344. package/dist/zonos-elements/p-eb9ee025.system.js +1 -0
  345. package/dist/zonos-elements/p-ed8ae947.system.entry.js +1 -0
  346. package/dist/zonos-elements/p-f1d9dd4e.entry.js +1 -0
  347. package/dist/zonos-elements/p-f3962950.system.entry.js +1 -0
  348. package/dist/zonos-elements/p-f4e976ae.entry.js +1 -0
  349. package/dist/zonos-elements/p-f513b231.entry.js +1 -0
  350. package/dist/zonos-elements/p-f64207fa.system.entry.js +1 -0
  351. package/dist/zonos-elements/{p-31975752.entry.js → p-fa322dc1.entry.js} +1 -1
  352. package/dist/zonos-elements/p-fb9fb873.system.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/localization-39516612.js +0 -884
  356. package/dist/cjs/zonos-confirm-dialog_2.cjs.entry.js +0 -168
  357. package/dist/esm/localization-c5029ffc.js +0 -863
  358. package/dist/esm/zonos-confirm-dialog_2.entry.js +0 -163
  359. package/dist/esm-es5/cart-14f305b3.js +0 -1
  360. package/dist/esm-es5/localization-c5029ffc.js +0 -1
  361. package/dist/esm-es5/placeTestOrder-2250f719.js +0 -1
  362. package/dist/esm-es5/renderFallback-dbf1e3ae.js +0 -1
  363. package/dist/esm-es5/shouldRenderTaxIdInput-8bc112bb.js +0 -1
  364. package/dist/esm-es5/translationStore-690c4e04.js +0 -1
  365. package/dist/esm-es5/zonos-address_11.entry.js +0 -1
  366. package/dist/esm-es5/zonos-banner_2.entry.js +0 -1
  367. package/dist/esm-es5/zonos-cart-items_13.entry.js +0 -1
  368. package/dist/esm-es5/zonos-confirm-dialog_2.entry.js +0 -1
  369. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +0 -1
  370. package/dist/zonos-elements/p-03ff7b01.system.entry.js +0 -1
  371. package/dist/zonos-elements/p-100f6a88.system.entry.js +0 -1
  372. package/dist/zonos-elements/p-143d706b.entry.js +0 -1
  373. package/dist/zonos-elements/p-14d7489d.js +0 -1
  374. package/dist/zonos-elements/p-1bfae137.entry.js +0 -1
  375. package/dist/zonos-elements/p-1d5aa016.system.js +0 -1
  376. package/dist/zonos-elements/p-1eae4987.entry.js +0 -1
  377. package/dist/zonos-elements/p-23b45714.system.entry.js +0 -1
  378. package/dist/zonos-elements/p-2557b96b.js +0 -1
  379. package/dist/zonos-elements/p-2ca8b037.entry.js +0 -1
  380. package/dist/zonos-elements/p-2dbcecf4.entry.js +0 -1
  381. package/dist/zonos-elements/p-316f9052.system.entry.js +0 -1
  382. package/dist/zonos-elements/p-3185968f.entry.js +0 -1
  383. package/dist/zonos-elements/p-4e41143a.system.entry.js +0 -1
  384. package/dist/zonos-elements/p-52b87408.system.entry.js +0 -1
  385. package/dist/zonos-elements/p-561be3a2.system.js +0 -1
  386. package/dist/zonos-elements/p-5c680f72.js +0 -1
  387. package/dist/zonos-elements/p-5f77d19e.js +0 -1
  388. package/dist/zonos-elements/p-74ca7739.entry.js +0 -1
  389. package/dist/zonos-elements/p-767a31a8.system.js +0 -1
  390. package/dist/zonos-elements/p-78a6e775.system.js +0 -1
  391. package/dist/zonos-elements/p-7c705c76.system.js +0 -1
  392. package/dist/zonos-elements/p-81ba2820.system.entry.js +0 -1
  393. package/dist/zonos-elements/p-84078c57.system.js +0 -1
  394. package/dist/zonos-elements/p-8a23bbf5.js +0 -1
  395. package/dist/zonos-elements/p-905d2490.entry.js +0 -1
  396. package/dist/zonos-elements/p-93f2e1ee.system.entry.js +0 -1
  397. package/dist/zonos-elements/p-a0a4e43d.system.entry.js +0 -1
  398. package/dist/zonos-elements/p-a2819807.system.entry.js +0 -1
  399. package/dist/zonos-elements/p-a6e74856.entry.js +0 -1
  400. package/dist/zonos-elements/p-ae940a99.js +0 -1
  401. package/dist/zonos-elements/p-b7ea5f4f.system.entry.js +0 -1
  402. package/dist/zonos-elements/p-c0c458f7.system.entry.js +0 -1
  403. package/dist/zonos-elements/p-c1ecab92.entry.js +0 -1
  404. package/dist/zonos-elements/p-c50cc926.entry.js +0 -1
  405. package/dist/zonos-elements/p-cf765af3.system.js +0 -1
  406. package/dist/zonos-elements/p-e03e1a62.entry.js +0 -1
  407. package/dist/zonos-elements/p-e7874318.system.entry.js +0 -1
  408. package/dist/zonos-elements/p-e8949e7e.entry.js +0 -1
  409. package/dist/zonos-elements/p-ea0b5d10.system.js +0 -1
  410. package/dist/zonos-elements/p-eae3462c.entry.js +0 -1
  411. package/dist/zonos-elements/p-eeb1081e.js +0 -1
  412. package/dist/zonos-elements/p-f892595d.system.entry.js +0 -1
  413. package/dist/zonos-elements/p-fd3b46ee.entry.js +0 -1
@@ -1,863 +0,0 @@
1
- import { c as createStore, z as zonosStore } from './zonosStore-b434e436.js';
2
- import { j as jsonParse, h as handleFetch, l as logError } from './handleFetch-a844cac1.js';
3
- import { a as availableTestKeys, l as log } from './VarianceTest-572cecf5.js';
4
- import { a as translationStoreUpdateLanguage } from './translationStore-690c4e04.js';
5
-
6
- /**
7
- * Check if the response contains at least one available test key that we support
8
- */
9
- const hasAtLeastOneAvailableTestKey = (rawResponse) => {
10
- const hasAvailableTestKey = !!rawResponse.find(item => item.testKey in availableTestKeys);
11
- if (!hasAvailableTestKey) {
12
- log('No available test key found in response', 'info', {
13
- response: rawResponse,
14
- });
15
- }
16
- return !!rawResponse.find(item => item.testKey in availableTestKeys);
17
- };
18
-
19
- /**
20
- * Filter the response to only include test keys and variants key that we support
21
- */
22
- const filterValidTests = (testKeys) => {
23
- // Type guard the response to ensure it matches the expected structure
24
- if (!hasAtLeastOneAvailableTestKey(testKeys)) {
25
- return [];
26
- }
27
- // Filter the response to only include test keys that we support
28
- return testKeys
29
- .filter(item => {
30
- var _a;
31
- const isTestKeyValidButNoSelectedVariantKey = availableTestKeys[item.testKey] && !item.selectedVariantKey;
32
- const validTestKeyWithSelectedVariantKey = item.selectedVariantKey &&
33
- !!((_a = availableTestKeys[item.testKey]) === null || _a === void 0 ? void 0 : _a['availableVariants'].includes(item.selectedVariantKey));
34
- return (isTestKeyValidButNoSelectedVariantKey ||
35
- validTestKeyWithSelectedVariantKey);
36
- })
37
- .map(item => (Object.assign(Object.assign({}, item), { expiresAt: item.expiresAt || Date.now() + VARIANT_TEST_KEY_EXPIRATION, selectedVariantKey: item.selectedVariantKey || null })));
38
- };
39
-
40
- /**
41
- * Expiration time for variant test keys in milliseconds
42
- * @default 1 day
43
- */
44
- const VARIANT_TEST_KEY_EXPIRATION = 60 * 60 * 24 * 1000;
45
- const { onChange: storageStoreOnChange, state: storageStore } = createStore({
46
- checkoutSessionId: sessionStorage.getItem('zonos--checkout-session-id'),
47
- enabledVariantTestKeys: jsonParse(localStorage.getItem('zonos--enabled-variant-test-keys')),
48
- });
49
- storageStoreOnChange('enabledVariantTestKeys', () => {
50
- var _a;
51
- // This should be set in localStorage so we don't have multiple tests for the same user in short period of time
52
- if (!((_a = storageStore.enabledVariantTestKeys) === null || _a === void 0 ? void 0 : _a.length)) {
53
- localStorage.removeItem('zonos--enabled-variant-test-keys');
54
- return;
55
- }
56
- localStorage.setItem('zonos--enabled-variant-test-keys', JSON.stringify(storageStore.enabledVariantTestKeys));
57
- });
58
- storageStoreOnChange('checkoutSessionId', () => {
59
- if (!storageStore.checkoutSessionId) {
60
- sessionStorage.removeItem('zonos--checkout-session-id');
61
- return;
62
- }
63
- sessionStorage.setItem('zonos--checkout-session-id', storageStore.checkoutSessionId);
64
- });
65
- const storageStoreSetEnabledVariantTestKeys = (testKeys) => {
66
- storageStore.enabledVariantTestKeys = filterValidTests(testKeys);
67
- };
68
-
69
- const getCountries = async () => {
70
- try {
71
- const { errors, json } = await handleFetch('/api/zonos-elements/get-countries', {
72
- method: 'GET',
73
- });
74
- if (errors.length || !json) {
75
- return null;
76
- }
77
- return json;
78
- }
79
- catch (_a) {
80
- return null;
81
- }
82
- };
83
-
84
- const getCountryLandedCost = async (countryCode) => {
85
- var _a;
86
- if (!countryCode) {
87
- return null;
88
- }
89
- const url = `/api/zonos-elements/country-landed-cost/${countryCode}`;
90
- const { errors, json } = await handleFetch(url);
91
- if (errors.length || !json) {
92
- logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
93
- return null;
94
- }
95
- return json || null;
96
- };
97
-
98
- const defaultUsExchangeRate = {
99
- exchangeRate: {
100
- rate: 1,
101
- targetFormat: {
102
- currencyCode: 'USD',
103
- decimalDelimiter: '.',
104
- scale: 2,
105
- symbol: '$',
106
- symbolLocation: 'before',
107
- thousandsDelimiter: ',',
108
- },
109
- },
110
- maxAge: null,
111
- };
112
- const getExchangeRate = async ({ country, isGuaranteed, sourceCurrency, targetCurrency, }) => {
113
- var _a;
114
- // If source currency matches target currency (US -> US) and is not a guaranteed rate, return default exchange rate so we still format properly.
115
- if (sourceCurrency === targetCurrency && !isGuaranteed) {
116
- return defaultUsExchangeRate;
117
- }
118
- const searchParams = new URLSearchParams();
119
- searchParams.set('sourceCurrency', sourceCurrency);
120
- searchParams.set('targetCurrency', targetCurrency);
121
- searchParams.set('isGuaranteed', String(isGuaranteed));
122
- searchParams.set('country', country || '');
123
- const { errors, json } = await handleFetch(`/api/zonos-elements/exchange-rates?${searchParams.toString()}`);
124
- if (errors.length || !json) {
125
- logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
126
- return defaultUsExchangeRate;
127
- }
128
- const { rate, targetFormat } = json.exchangeRateCreate;
129
- const maxAge = json.maxAge;
130
- if (rate) {
131
- sessionStorage.setItem(country + '_rate', JSON.stringify(rate));
132
- const exchangeRate = { rate, targetFormat };
133
- return { exchangeRate, maxAge };
134
- }
135
- return defaultUsExchangeRate;
136
- };
137
-
138
- const getInclusivePriceConfigurations = async (countryCode) => {
139
- var _a;
140
- if (!countryCode) {
141
- return null;
142
- }
143
- const { errors, json } = await handleFetch(`/api/zonos-elements/inclusive-prices/${countryCode}`);
144
- if (errors.length || !json) {
145
- logError(`Error fetching country inclusive price setting: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
146
- return null;
147
- }
148
- return json || null;
149
- };
150
-
151
- const getLocaleMessages = async ({ countryCode, localeTo, storeId, }) => {
152
- var _a;
153
- const searchParams = new URLSearchParams();
154
- searchParams.set('countryCode', countryCode);
155
- searchParams.set('storeId', storeId.toString());
156
- if (localeTo) {
157
- searchParams.set('localeTo', localeTo);
158
- }
159
- const { errors, json } = await handleFetch(`/api/zonos-elements/locale-messages?${searchParams.toString()}`);
160
- if (errors.length || !json) {
161
- logError('Error fetching exchange rate', (_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message);
162
- return [];
163
- }
164
- return json.locale_countryCodesPage;
165
- };
166
-
167
- const validateCountryCode = (countryCode) => {
168
- // Check that the country is two characters and is upper case
169
- if (countryCode && /^[A-Z]{2}$/.test(countryCode)) {
170
- return countryCode;
171
- }
172
- return null;
173
- };
174
- const getZCountryUrlParam = (urlParams) => {
175
- const urlSearchParams = new URLSearchParams(urlParams || window.location.search);
176
- const getCountryParam = (param) => {
177
- const country = urlSearchParams.get(param);
178
- // Check that the country is two characters and is upper case
179
- return validateCountryCode(country);
180
- };
181
- const zCountry = getCountryParam('zCountry');
182
- // Fallback to legacy 'country'
183
- const fallback = getCountryParam('country');
184
- // Fallback to customerCountry
185
- const secondFallback = getCountryParam('customerCountry');
186
- return zCountry || fallback || secondFallback;
187
- };
188
-
189
- /**
190
- * Retrieve the zCountry from the URL or session storage.
191
- */
192
- const getOverridenZCountry = () => {
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
- return zCountry;
198
- };
199
-
200
- const getLocalization = async () => {
201
- try {
202
- const zCountry = getOverridenZCountry();
203
- const searchParams = new URLSearchParams();
204
- if (zCountry) {
205
- searchParams.set('zCountry', zCountry);
206
- }
207
- const { errors, json } = await handleFetch(`/api/zonos-elements/localization?${searchParams.toString()}`);
208
- if (errors.length || !json) {
209
- return { country: null, locale: null };
210
- }
211
- return {
212
- country: json.country,
213
- locale: json.locale,
214
- };
215
- }
216
- catch (_a) {
217
- return { country: null, locale: null };
218
- }
219
- };
220
-
221
- const getShippingZones = async () => {
222
- var _a, _b, _c;
223
- if ((_a = window.Zonos.cartSettings) === null || _a === void 0 ? void 0 : _a.shippingZones) {
224
- return window.Zonos.cartSettings.shippingZones
225
- .flatMap(zone => zone === null || zone === void 0 ? void 0 : zone.countryCodes)
226
- .filter(Boolean);
227
- }
228
- const { errors, json } = await handleFetch('/api/zonos-elements/shipping-zones');
229
- if (errors.length || !json) {
230
- logError(`Error fetching shipping zones: ${(_b = errors.find(Boolean)) === null || _b === void 0 ? void 0 : _b.message}`);
231
- return null;
232
- }
233
- 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);
234
- return shippingZones || null;
235
- };
236
-
237
- const applyInclusiveEffectiveRate = (amount) => {
238
- const inclusivePrice = localizationStore.inclusivePricingConfigurations.find(x => x.shipToCountry === localizationStore.selectedCountryCode);
239
- if (!inclusivePrice) {
240
- return amount;
241
- }
242
- const effectiveRate = inclusivePrice.effectiveRate;
243
- // Just multiply the amount by the effective rate to get the new amount for inclusive pricing
244
- return amount * (1 + effectiveRate);
245
- };
246
-
247
- const currencyConvert = (value) => {
248
- // TODO(potentially): Bring over the code for vanity checks
249
- const { exchangeRate } = localizationStore;
250
- if (!exchangeRate || !value || isNaN(value)) {
251
- return value;
252
- }
253
- const minimumFractionDigits = (exchangeRate === null || exchangeRate === void 0 ? void 0 : exchangeRate.targetFormat.scale) || 2;
254
- const convertedValue = value * exchangeRate.rate;
255
- const fixedValue = convertedValue.toFixed(minimumFractionDigits);
256
- return Number(fixedValue);
257
- };
258
-
259
- /**
260
- * This function only to format the number in
261
- * @returns
262
- */
263
- const numberFormat = ({ amount, currency, targetFormat, }) => {
264
- const targetCurrency = currency || localizationStore.targetCurrency;
265
- const minimumFractionDigits = (targetFormat === null || targetFormat === void 0 ? void 0 : targetFormat.scale) || 2;
266
- const isIE = window.navigator.userAgent.indexOf('MSIE ') !== -1;
267
- const numberFormatExists = typeof Intl === 'object' && Intl && typeof Intl.NumberFormat === 'function';
268
- if (isIE || !numberFormatExists) {
269
- // use native number formatting if it's IE.
270
- const formattedNumber = Number(amount)
271
- .toFixed(minimumFractionDigits)
272
- .replace('.', '|dec|')
273
- .replace(',', (targetFormat === null || targetFormat === void 0 ? void 0 : targetFormat.thousandsDelimiter) || '')
274
- .replace('|dec|', (targetFormat === null || targetFormat === void 0 ? void 0 : targetFormat.decimalDelimiter) || '');
275
- return formattedNumber;
276
- }
277
- const formatedNumber = new Intl.NumberFormat(window.navigator.language, {
278
- currency: targetCurrency,
279
- currencyDisplay: 'code',
280
- minimumFractionDigits: minimumFractionDigits,
281
- style: 'currency',
282
- }).format(amount);
283
- return formatedNumber.replace(new RegExp(`${targetCurrency}\\s+`), '');
284
- };
285
-
286
- const currencyFormat = ({ amount, currency, }) => {
287
- if (isNaN(amount) || (amount !== 0 && !amount)) {
288
- return '';
289
- }
290
- const overrideCurrencyFormat = zonosStore.overrideCurrencyFormat;
291
- const { exchangeRate } = localizationStore;
292
- const targetCurrency = currency || localizationStore.targetCurrency;
293
- // Use user-defined currency format
294
- if (typeof overrideCurrencyFormat === 'function') {
295
- return overrideCurrencyFormat({
296
- amount: amount,
297
- currencyCode: targetCurrency,
298
- numberFormat: ({ amount: _amount }) => numberFormat({
299
- amount: _amount,
300
- currency: targetCurrency,
301
- targetFormat: (exchangeRate === null || exchangeRate === void 0 ? void 0 : exchangeRate.targetFormat) || null,
302
- }),
303
- });
304
- }
305
- const { targetFormat } = exchangeRate || {};
306
- if (!targetFormat || !exchangeRate) {
307
- // Return the amount as a string if no exchange rate is available
308
- return `${amount.toFixed(2)} ${targetCurrency}`;
309
- }
310
- const minimumFractionDigits = targetFormat.scale || 2;
311
- const isIE = window.navigator.userAgent.indexOf('MSIE ') !== -1;
312
- const numberFormatExists = typeof Intl === 'object' && Intl && typeof Intl.NumberFormat === 'function';
313
- if (isIE || !numberFormatExists) {
314
- // use native number formatting if it's IE.
315
- const formattedNumber = Number(amount)
316
- .toFixed(minimumFractionDigits)
317
- .replace('.', '|dec|')
318
- .replace(',', targetFormat.thousandsDelimiter || '')
319
- .replace('|dec|', targetFormat.decimalDelimiter || '');
320
- const result = `${formattedNumber}${targetFormat.currencyCode !== 'USD' ? ` ${targetFormat.currencyCode}` : ''}`;
321
- return result;
322
- }
323
- const currencyDisplay = (overrideCurrencyFormat === null || overrideCurrencyFormat === void 0 ? void 0 : overrideCurrencyFormat.currencyDisplay) || 'symbol';
324
- const formattedNumber = new Intl.NumberFormat(window.navigator.language, {
325
- currency: targetCurrency,
326
- currencyDisplay,
327
- minimumFractionDigits: minimumFractionDigits,
328
- style: 'currency',
329
- }).format(amount);
330
- // Move currency code to the end of the string if currencyDisplay is 'code'
331
- const result = currencyDisplay === 'code'
332
- ? `${formattedNumber.replace(new RegExp(`${targetCurrency}\\s+`), '')} ${targetCurrency}`
333
- : formattedNumber;
334
- return result;
335
- };
336
-
337
- const currencyConvertAndFormat = (value) => {
338
- const convertedValue = currencyConvert(value);
339
- const formattedValue = currencyFormat({ amount: convertedValue });
340
- return formattedValue;
341
- };
342
-
343
- /**
344
- * Check if selector user pass is valid
345
- * @example
346
- * isValidSelector('div') // true
347
- * isValidSelector('div + >>> span') // false
348
- */
349
- const isValidSelector = (selector) => {
350
- try {
351
- // this will error out if the selector is invalid in the DOM
352
- document.createDocumentFragment().querySelector(selector);
353
- }
354
- catch (_a) {
355
- return false;
356
- }
357
- return true;
358
- };
359
-
360
- const getCurrencyElements = (selector) => {
361
- const currencySelector = selector || '.money';
362
- if (!isValidSelector(currencySelector)) {
363
- logError(`Currency element selector "${currencySelector}" is not valid.`);
364
- return null;
365
- }
366
- const currencyElements = document.querySelectorAll(currencySelector);
367
- if (!currencyElements.length) {
368
- log(`No currency elements found with selector "${currencySelector}"`, 'warn');
369
- return null;
370
- }
371
- // return array of currency elements instead of a NodeList
372
- return Array.from(currencyElements);
373
- };
374
-
375
- const getInitialElementAmount = (element) => {
376
- var _a;
377
- const domesticValue = element.getAttribute('data-domestic');
378
- const intlValue = element.getAttribute('data-zintl');
379
- // Only keep numbers, decimal, and hyphens
380
- const cleanedText = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.replace(/[^\d.-]/g, '');
381
- if (!cleanedText) {
382
- return null;
383
- }
384
- // If the element has no data-domestic attribute, or the text content is different from the data-zintl attribute, set the data-domestic attribute
385
- if (!domesticValue || (element.textContent !== intlValue && intlValue)) {
386
- // Store the original value on the element once, and international on every new conversion
387
- element.setAttribute('data-domestic', cleanedText);
388
- return parseFloat(cleanedText);
389
- }
390
- return parseFloat(domesticValue);
391
- };
392
-
393
- const BLUR_CURRENCY_DURATION = 7000;
394
- const BLUR_CURRENCY_CLASSNAME = 'z--blur';
395
- const removeBlurCurrency = async () => {
396
- const intervalId = window.zonosBlurCurrencyOnInitIntervalId;
397
- if (!intervalId) {
398
- // Do nothing if the interval is not set
399
- return;
400
- }
401
- // Wait a bit to make sure price is fully rendered in DOM
402
- await new Promise(resolve => setTimeout(resolve, 500));
403
- clearInterval(intervalId);
404
- const currencyElements = document.querySelectorAll(`.${BLUR_CURRENCY_CLASSNAME}`);
405
- currencyElements.forEach(element => {
406
- element.classList.remove(BLUR_CURRENCY_CLASSNAME);
407
- });
408
- window.zonosBlurCurrencyOnInitIntervalId = undefined;
409
- };
410
- /**
411
- * This function is used to remove the blur effect from a specific element. (combined with performBlurSpecificElement)
412
- * @returns void
413
- */
414
- const removeBlurSpecificElement = async ({ specificSelector, timeoutId, }) => {
415
- // Wait a bit to make sure price is fully rendered in DOM
416
- await new Promise(resolve => setTimeout(resolve, 500));
417
- if (timeoutId) {
418
- clearTimeout(timeoutId);
419
- }
420
- specificSelector.classList.remove(BLUR_CURRENCY_CLASSNAME);
421
- };
422
- const blurCurrencyElements = ({ currencySelector, specificSelector, }) => {
423
- // Do nothing if the currency selector is not provided or blurCurrencyOnInit is false
424
- if (!currencySelector && !specificSelector) {
425
- return;
426
- }
427
- if (specificSelector) {
428
- specificSelector.classList.add(BLUR_CURRENCY_CLASSNAME);
429
- }
430
- else {
431
- const currencyElements = document.querySelectorAll([currencySelector].filter(Boolean).join(','));
432
- currencyElements.forEach(element => {
433
- element.classList.add(BLUR_CURRENCY_CLASSNAME);
434
- });
435
- }
436
- };
437
- const performBlurSpecificElement = (specificSelector) => {
438
- if (typeof window === 'undefined') {
439
- return;
440
- }
441
- blurCurrencyElements({
442
- specificSelector,
443
- });
444
- // The blur will be removed as soon as we got the exchange rate back. But if the exchange rate is not available for some reason, the blur effect will be automatically removed after 10 seconds
445
- const timeoutId = setTimeout(() => {
446
- void removeBlurSpecificElement({
447
- specificSelector,
448
- timeoutId,
449
- });
450
- }, BLUR_CURRENCY_DURATION);
451
- return timeoutId;
452
- };
453
- const performBlurCurrency = () => {
454
- if (typeof window === 'undefined') {
455
- return;
456
- }
457
- // If the interval is already in progress, do nothing
458
- if (window.zonosBlurCurrencyOnInitIntervalId) {
459
- return;
460
- }
461
- blurCurrencyElements({
462
- currencySelector: window.zonosBlurCurrencyOnInitCurrencySelector,
463
- });
464
- // Add blur effect to the currency elements
465
- const intervalId = setInterval(() => {
466
- blurCurrencyElements({
467
- currencySelector: window.zonosBlurCurrencyOnInitCurrencySelector,
468
- });
469
- }, 10);
470
- window.zonosBlurCurrencyOnInitIntervalId = intervalId;
471
- // The blur will be removed as soon as we got the exchange rate back. But if the exchange rate is not available for some reason, the blur effect will be automatically removed after 10 seconds
472
- setTimeout(() => {
473
- void removeBlurCurrency();
474
- }, BLUR_CURRENCY_DURATION);
475
- };
476
-
477
- const convertCurrency = (element) => {
478
- var _a;
479
- const amount = getInitialElementAmount(element);
480
- if (!amount || isNaN(amount)) {
481
- return;
482
- }
483
- const currentIntlValue = element.getAttribute('data-zintl');
484
- // get rate
485
- const currentIntlRateValue = parseFloat(element.getAttribute('data-zrate') || '1');
486
- const currentCountryValue = element.getAttribute('data-zcountry-code');
487
- // do nothing if the target currency is the same
488
- const isExchangeRateReady = localizationStore.exchangeRate &&
489
- localizationStore.targetCurrency ===
490
- localizationStore.exchangeRate.targetFormat.currencyCode;
491
- const rate = ((_a = localizationStore.exchangeRate) === null || _a === void 0 ? void 0 : _a.rate) || 1;
492
- // if the current value on the element is different from the current intl value, update the data-zintl attribute
493
- if (isExchangeRateReady &&
494
- // Update currency if the value is not yet formatted
495
- (element.textContent !== currentIntlValue ||
496
- // Update rate when new rate is available
497
- rate !== currentIntlRateValue ||
498
- // Update currency when the country code changes
499
- currentCountryValue !== localizationStore.selectedCountryCode)) {
500
- // Hide the currency until DOM is ready to display the new value
501
- const timeoutId = performBlurSpecificElement(element);
502
- const appliedInclusivePrice = applyInclusiveEffectiveRate(amount);
503
- const customizedCurrencyFormat = typeof zonosStore.currencyConverter === 'function' &&
504
- zonosStore.currencyConverter({
505
- convert: currencyConvert,
506
- convertAndFormat: currencyConvertAndFormat,
507
- currencyCode: localizationStore.targetCurrency,
508
- format: (value) => currencyFormat({ amount: value }),
509
- originalAmount: appliedInclusivePrice,
510
- selector: element,
511
- });
512
- // 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.
513
- const observedFormattedValue = customizedCurrencyFormat ||
514
- currencyConvertAndFormat(appliedInclusivePrice);
515
- if (observedFormattedValue !== element.textContent) {
516
- // Only set textContent if the value has changed, this is to prevent it redrawing the element if the value is the same
517
- element.textContent = observedFormattedValue;
518
- }
519
- // save the new rate to the data-zrate attribute
520
- element.setAttribute('data-zrate', rate.toString());
521
- // save the new value to the data-zintl attribute
522
- element.setAttribute('data-zintl', observedFormattedValue);
523
- element.setAttribute('data-zcountry-code', localizationStore.selectedCountryCode || '');
524
- void removeBlurSpecificElement({
525
- specificSelector: element,
526
- timeoutId,
527
- });
528
- }
529
- };
530
- const defaultCurrencyConverter = () => {
531
- const { currencyElementSelector } = zonosStore.helloSettings;
532
- const currencyElements = getCurrencyElements(currencyElementSelector);
533
- // do nothing if none of the currency elements are found
534
- if (!(currencyElements === null || currencyElements === void 0 ? void 0 : currencyElements.length)) {
535
- return;
536
- }
537
- if (!localizationStore.exchangeRate) {
538
- logError('Could not display currency. Exchange rate and format data is not available.');
539
- return;
540
- }
541
- currencyElements.forEach(element => {
542
- // convert the currency and save the formatted value to the data-zintl attribute
543
- convertCurrency(element);
544
- });
545
- };
546
-
547
- const currencyDisplay = () => {
548
- if (zonosStore.helloSettings.currencyBehavior === 'DISABLED' ||
549
- window.Zonos.isLegacyCheckout) {
550
- void removeBlurCurrency();
551
- return;
552
- }
553
- defaultCurrencyConverter();
554
- };
555
-
556
- const getCurrencyCode = (code) => {
557
- var _a;
558
- const countryInShippingZone = (_a = localizationStore.shippingZoneCountries) === null || _a === void 0 ? void 0 : _a[code];
559
- if (countryInShippingZone) {
560
- return countryInShippingZone.currencyCode;
561
- }
562
- return null;
563
- };
564
-
565
- const setZCountryUrlParam = (selectedCountryCode) => {
566
- if (!selectedCountryCode) {
567
- return;
568
- }
569
- const urlSearchParams = new URLSearchParams(window.location.search);
570
- // Only append zCountry if it's already in the URL or the countryOverrideBehavior is URL_PARAM
571
- const shouldAppendParam = urlSearchParams.has('zCountry') ||
572
- zonosStore.helloSettings.countryOverrideBehavior === 'URL_PARAM';
573
- if (shouldAppendParam) {
574
- // Only append zCountry if it's not already in the URL
575
- urlSearchParams.set('zCountry', selectedCountryCode);
576
- const newUrl = `${window.location.pathname}?${urlSearchParams.toString()}`;
577
- /**
578
- * Setting the state to null in window.history.replaceState can cause issues with rendering when using next/link and pressing the back button.
579
- * @ref https://github.com/vercel/next.js/issues/33233#issuecomment-1052349396
580
- **/
581
- window.history.replaceState(window.history.state, document.title, newUrl);
582
- }
583
- };
584
-
585
- const { dispose: localizationDispose, onChange: localizationStoreOnChange, state: localizationStore, } = createStore({
586
- countryLandedCost: null,
587
- customMessages: [],
588
- exchangeRate: null,
589
- helloCountryList: null,
590
- inclusivePricingConfigurations: [],
591
- inclusivePricingIsFetching: false,
592
- isDisabledCountry: true,
593
- isShippableCountry: false,
594
- localizationLoaded: false,
595
- selectedCountryCode: null,
596
- selectedLocale: 'en',
597
- shippingZoneCountries: null,
598
- targetCurrency: 'USD',
599
- });
600
- const triggerGetExchangeRate = async (isGuaranteed) => {
601
- const { exchangeRate, maxAge } = await getExchangeRate({
602
- country: localizationStore.selectedCountryCode,
603
- isGuaranteed,
604
- sourceCurrency: zonosStore.sourceCurrency,
605
- targetCurrency: localizationStore.targetCurrency,
606
- });
607
- if (exchangeRate) {
608
- localizationStore.exchangeRate = exchangeRate;
609
- currencyDisplay();
610
- }
611
- return { maxAge };
612
- };
613
- /**
614
- * CHORE: This is mostly for legacy checkout as the country param is not guaranteed.
615
- */
616
- const DEFAULT_COUNTRY_CODE_LEGACY_CHECKOUT = 'CA';
617
- const getFallbackDefaultCountryCode = (allowedCountries) => {
618
- if (localizationStore.selectedCountryCode &&
619
- allowedCountries.includes(localizationStore.selectedCountryCode)) {
620
- return localizationStore.selectedCountryCode;
621
- }
622
- // Don't check if it is allowed. If it is not allowed it will fallback to Albania (first option).
623
- return DEFAULT_COUNTRY_CODE_LEGACY_CHECKOUT;
624
- };
625
- const refreshInclusivePricingConfigurations = async (countryCode) => {
626
- if (!countryCode) {
627
- return;
628
- }
629
- // These requests are only needed for Hello, so we can skip them for legacy checkout
630
- localizationStore.inclusivePricingIsFetching = true;
631
- const inclusivePricingConfigurations = await getInclusivePriceConfigurations(countryCode);
632
- localizationStore.inclusivePricingConfigurations =
633
- inclusivePricingConfigurations || [];
634
- localizationStore.inclusivePricingIsFetching = false;
635
- };
636
- // This recursive function is for users who step away from their computer and come back needing a new exchange rate
637
- const startExchangeRateTimeout = ({ isGuaranteed, maxAge, }) => {
638
- if (localizationStore.exchangeRateTimeout) {
639
- clearTimeout(localizationStore.exchangeRateTimeout);
640
- }
641
- // maxAge comes in seconds, convert to milliseconds
642
- const defaultMaxAge = 5 * 60;
643
- const maxAgeToUse = maxAge || defaultMaxAge;
644
- // Recursively set timeouts to get new exchange rates when the current one expires
645
- localizationStore.exchangeRateTimeout = setTimeout(async () => {
646
- // Refresh inclusive pricing configurations before getting a new exchange rate, so hello can use the new effective rate
647
- await refreshInclusivePricingConfigurations(localizationStore.selectedCountryCode);
648
- const { maxAge: newMaxAge } = await triggerGetExchangeRate(isGuaranteed);
649
- startExchangeRateTimeout({ isGuaranteed, maxAge: newMaxAge });
650
- }, maxAgeToUse * 1000);
651
- };
652
- const getNewLocalization = async ({ isInitializing, }) => {
653
- var _a, _b;
654
- log('get new localization store');
655
- const { isDisabledCountry, isShippableCountry, selectedCountryCode } = localizationStore;
656
- if (zonosStore.helloSettings.currencyBehavior === 'DISABLED' ||
657
- !isShippableCountry ||
658
- isDisabledCountry ||
659
- !selectedCountryCode) {
660
- return;
661
- }
662
- const isGuaranteed = zonosStore.checkoutSettings.visibilityStatus === 'ENABLED';
663
- // blur currency out before getting exchange rate
664
- performBlurCurrency();
665
- const { maxAge } = await triggerGetExchangeRate(isGuaranteed);
666
- startExchangeRateTimeout({ isGuaranteed, maxAge });
667
- if (isInitializing &&
668
- ((_a = window.Zonos.cartSettings) === null || _a === void 0 ? void 0 : _a.inclusivePriceConfigurations)) {
669
- localizationStore.inclusivePricingConfigurations =
670
- ((_b = window.Zonos.cartSettings) === null || _b === void 0 ? void 0 : _b.inclusivePriceConfigurations) || [];
671
- void removeBlurCurrency();
672
- }
673
- // These requests are only needed for Hello, so we can skip them for legacy checkout
674
- if (!window.Zonos.isLegacyCheckout) {
675
- localizationStore.inclusivePricingIsFetching = true;
676
- const [countryLandedCost] = await Promise.all([
677
- getCountryLandedCost(localizationStore.selectedCountryCode),
678
- refreshInclusivePricingConfigurations(localizationStore.selectedCountryCode),
679
- ]);
680
- localizationStore.countryLandedCost = countryLandedCost;
681
- // Remove blur effect after the currency is converted
682
- void removeBlurCurrency();
683
- }
684
- else {
685
- log('Skipping country landed cost and inclusive pricing requests, because this is a legacy checkout');
686
- }
687
- };
688
- const getCustomMessages = async () => {
689
- log(`Getting custom messages for ${localizationStore.selectedCountryCode}`);
690
- if (!localizationStore.selectedCountryCode || !zonosStore.storeId) {
691
- return;
692
- }
693
- const localeMessages = await getLocaleMessages({
694
- countryCode: localizationStore.selectedCountryCode,
695
- localeTo: localizationStore.selectedLocale,
696
- storeId: zonosStore.storeId,
697
- });
698
- const allMessages = localeMessages.flatMap(x => {
699
- var _a;
700
- return {
701
- countryCode: localizationStore.selectedCountryCode,
702
- message: (_a = x.countryCodesPageMessageLinks.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message.textTo,
703
- pageName: x.pageName,
704
- };
705
- });
706
- localizationStore.customMessages = allMessages;
707
- };
708
- const getOverrideLocale = () => {
709
- const currentUrl = new URL(window.location.href);
710
- const zonosLocale = currentUrl.searchParams.get('zonosLocale');
711
- return zonosLocale;
712
- };
713
- const addInternationalHideClass = () => {
714
- if (localizationStore.isShippableCountry) {
715
- document.body.classList.add('z-intl');
716
- }
717
- else {
718
- document.body.classList.remove('z-intl');
719
- }
720
- };
721
- const getValidCountryCode = (countryCode) => {
722
- if (countryCode === 'UK') {
723
- return 'GB';
724
- }
725
- return countryCode;
726
- };
727
- const localizationStoreUpdateSelectedCountryCode = ({ isInitializing, newSelectedCountryCode, }) => {
728
- var _a, _b;
729
- log(`Updating selected country code to ${newSelectedCountryCode}`);
730
- const isFirstTime = !localizationStore.selectedCountryCode;
731
- localizationStore.selectedCountryCode = getValidCountryCode(newSelectedCountryCode);
732
- const { selectedCountryCode, shippingZoneCountries } = localizationStore;
733
- const isShippableCountry = !!shippingZoneCountries &&
734
- !!selectedCountryCode &&
735
- !!shippingZoneCountries[selectedCountryCode] &&
736
- // Make sure the country is not in the disabled countries list
737
- !zonosStore.disabledCountries.includes(selectedCountryCode);
738
- // update shippable country
739
- localizationStore.isShippableCountry = isShippableCountry;
740
- log(`${localizationStore.selectedCountryCode} is a shippable country: ${localizationStore.isShippableCountry}`);
741
- const isDisabledCountry = !!selectedCountryCode &&
742
- zonosStore.disabledCountries.includes(selectedCountryCode);
743
- localizationStore.isDisabledCountry = isDisabledCountry;
744
- log(`${localizationStore.selectedCountryCode} is a disabled country: ${localizationStore.isDisabledCountry}`);
745
- addInternationalHideClass();
746
- if (!selectedCountryCode) {
747
- return;
748
- }
749
- const currencyCode = getCurrencyCode(selectedCountryCode);
750
- // Only trigger callback onCountryChange if the country code has been set before
751
- if (!isFirstTime) {
752
- // Trigger callback onCountryChange
753
- (_a = zonosStore.onCountryChange) === null || _a === void 0 ? void 0 : _a.call(zonosStore, {
754
- countryCode: selectedCountryCode,
755
- currencyCode,
756
- isShippableCountry: isShippableCountry,
757
- });
758
- }
759
- if (!currencyCode) {
760
- return;
761
- }
762
- localizationStore.targetCurrency = currencyCode;
763
- void getNewLocalization({ isInitializing: isInitializing });
764
- // Save the country code to session storage for later use
765
- window.sessionStorage.setItem('zonos--country', selectedCountryCode);
766
- // Update the URL query param with the new country code
767
- setZCountryUrlParam(selectedCountryCode);
768
- (_b = document
769
- .querySelector('zonos-hello')) === null || _b === void 0 ? void 0 : _b.setAttribute('z-country', selectedCountryCode);
770
- };
771
- const initHelloCountryList = (allCountries) => {
772
- const showCountryList = zonosStore.helloSettings.showCountryList;
773
- const hellCountryList = localizationStore.shippingZoneCountries;
774
- if (!showCountryList || showCountryList === 'ONLY_SHIPPABLE') {
775
- // just use the shipping zone countries
776
- localizationStore.helloCountryList = hellCountryList;
777
- return;
778
- }
779
- if (showCountryList === 'ALL') {
780
- localizationStore.helloCountryList = allCountries;
781
- return;
782
- }
783
- // get all active countries in the showCountryList
784
- localizationStore.helloCountryList = showCountryList.reduce((acc, countryCode) => {
785
- const countryInfo = allCountries === null || allCountries === void 0 ? void 0 : allCountries[countryCode];
786
- return countryInfo
787
- ? Object.assign(Object.assign({}, acc), { [countryCode]: countryInfo }) : acc;
788
- }, {});
789
- };
790
- const updateCheckoutSessionLanguage = async () => {
791
- if (!storageStore.checkoutSessionId) {
792
- return null;
793
- }
794
- const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session-metadata', {
795
- body: {
796
- id: storageStore.checkoutSessionId,
797
- metadata: [
798
- // This is being used from the backend to determine the language of the checkout session
799
- {
800
- key: 'language',
801
- value: localizationStore.selectedLocale,
802
- },
803
- ],
804
- },
805
- method: 'POST',
806
- });
807
- if (errors.length || !json) {
808
- logError('Error occurs when updating checkout session', JSON.stringify(errors, null, 2));
809
- return { errors, json };
810
- }
811
- return { errors: [], json };
812
- };
813
- const localizationStoreUpdateSelectedLocale = (newSelectedLocale) => {
814
- localizationStore.selectedLocale = newSelectedLocale;
815
- translationStoreUpdateLanguage(newSelectedLocale);
816
- void updateCheckoutSessionLanguage();
817
- void getCustomMessages();
818
- };
819
- const initLocalizationStore = async () => {
820
- var _a;
821
- // all countries from countries.json, shipping zone and localization
822
- const [allCountries, shippingZoneCountries, localization] = await Promise.all([getCountries(), getShippingZones(), getLocalization()]);
823
- // Filter countries to only include countries in the shipping zone
824
- const filteredCountries = shippingZoneCountries === null || shippingZoneCountries === void 0 ? void 0 : shippingZoneCountries.reduce((acc, countryCode) => {
825
- const countryInfo = allCountries === null || allCountries === void 0 ? void 0 : allCountries[countryCode];
826
- return countryInfo
827
- ? Object.assign(Object.assign({}, acc), { [countryCode]: countryInfo }) : acc;
828
- }, {});
829
- localizationStore.shippingZoneCountries = filteredCountries || null;
830
- localizationStore.inclusivePricingConfigurations =
831
- ((_a = window.Zonos.cartSettings) === null || _a === void 0 ? void 0 : _a.inclusivePriceConfigurations) || [];
832
- // Initialize the country list for the hello widget
833
- initHelloCountryList(allCountries || {});
834
- const { country, locale } = localization;
835
- log(`Country code from localization: ${country}`);
836
- log(`Locale from localization: ${locale}`);
837
- // update selected country code in store
838
- localizationStoreUpdateSelectedCountryCode({
839
- isInitializing: true,
840
- newSelectedCountryCode: country || null,
841
- });
842
- // use locale from params if it exists, otherwise use locale from localization
843
- const overrideLocale = getOverrideLocale();
844
- localizationStoreUpdateSelectedLocale(overrideLocale || locale || 'en');
845
- const devSites = [
846
- 'dev.storybook.elements',
847
- 'dev.elements',
848
- 'dev.demo.elements',
849
- 'dev.dashboard',
850
- ];
851
- // If the country code is not set, set it to the US for development (vercel can't get geo country in dev)
852
- if (!localizationStore.selectedCountryCode &&
853
- devSites.some(site => window.location.origin.includes(site))) {
854
- // update selected country code in store
855
- localizationStoreUpdateSelectedCountryCode({
856
- isInitializing: true,
857
- newSelectedCountryCode: 'CA',
858
- });
859
- }
860
- localizationStore.localizationLoaded = true;
861
- };
862
-
863
- export { VARIANT_TEST_KEY_EXPIRATION as V, localizationStoreUpdateSelectedCountryCode as a, storageStoreSetEnabledVariantTestKeys as b, localizationStoreOnChange as c, currencyFormat as d, getOverridenZCountry as e, filterValidTests as f, getZCountryUrlParam as g, initLocalizationStore as h, isValidSelector as i, setZCountryUrlParam as j, currencyDisplay as k, localizationStore as l, currencyConvertAndFormat as m, currencyConvert as n, applyInclusiveEffectiveRate as o, getFallbackDefaultCountryCode as p, storageStoreOnChange as q, localizationStoreUpdateSelectedLocale as r, storageStore as s };