@zonos/elements 1.3.227 → 1.3.228

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 (176) hide show
  1. package/dist/cjs/{cart-af017ac3.js → cart-ad82a680.js} +2 -2
  2. package/dist/cjs/index.cjs.js +7 -7
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{localization-21030292.js → localization-31e3dfe3.js} +1 -1
  5. package/dist/cjs/{paypal-2b22f0f5.js → paypal-88b5e878.js} +3 -3
  6. package/dist/cjs/{placeTestOrder-9cde1ca4.js → placeTestOrder-6aefbf9c.js} +2 -2
  7. package/dist/cjs/{renderFallback-9300dbaf.js → renderFallback-87c908ad.js} +2 -2
  8. package/dist/cjs/{translationStore-ce2c700d.js → translationStore-b8b25e9d.js} +240 -0
  9. package/dist/cjs/zonos-address_11.cjs.entry.js +3 -3
  10. package/dist/cjs/{zonos-cart-items_12.cjs.entry.js → zonos-cart-items_13.cjs.entry.js} +23 -5
  11. package/dist/cjs/zonos-checkout.cjs.entry.js +26 -15
  12. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +3 -3
  13. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +6 -6
  14. package/dist/cjs/zonos-collect.cjs.entry.js +5 -5
  15. package/dist/cjs/zonos-confirm-dialog_2.cjs.entry.js +1 -1
  16. package/dist/cjs/zonos-controller.cjs.entry.js +3 -3
  17. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  18. package/dist/cjs/zonos-country-select_4.cjs.entry.js +2 -2
  19. package/dist/cjs/zonos-elements.cjs.js +1 -1
  20. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +4 -4
  21. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
  22. package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
  23. package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
  24. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +25 -13
  25. package/dist/collection/components/store/translationStore/strings.arabic.js +12 -0
  26. package/dist/collection/components/store/translationStore/strings.base.js +12 -0
  27. package/dist/collection/components/store/translationStore/strings.chinese.js +12 -0
  28. package/dist/collection/components/store/translationStore/strings.danish.js +12 -0
  29. package/dist/collection/components/store/translationStore/strings.dutch.js +12 -0
  30. package/dist/collection/components/store/translationStore/strings.french.js +12 -0
  31. package/dist/collection/components/store/translationStore/strings.german.js +12 -0
  32. package/dist/collection/components/store/translationStore/strings.hebrew.js +12 -0
  33. package/dist/collection/components/store/translationStore/strings.indonesian.js +12 -0
  34. package/dist/collection/components/store/translationStore/strings.italian.js +12 -0
  35. package/dist/collection/components/store/translationStore/strings.japanese.js +12 -0
  36. package/dist/collection/components/store/translationStore/strings.korean.js +12 -0
  37. package/dist/collection/components/store/translationStore/strings.norwegian.js +12 -0
  38. package/dist/collection/components/store/translationStore/strings.polish.js +12 -0
  39. package/dist/collection/components/store/translationStore/strings.portuguese.js +12 -0
  40. package/dist/collection/components/store/translationStore/strings.russian.js +12 -0
  41. package/dist/collection/components/store/translationStore/strings.spanish.js +12 -0
  42. package/dist/collection/components/store/translationStore/strings.swedish.js +12 -0
  43. package/dist/collection/components/store/translationStore/strings.turkish.js +12 -0
  44. package/dist/collection/components/store/translationStore/strings.vietnamese.js +12 -0
  45. package/dist/esm/{cart-11b87221.js → cart-c74f9aaa.js} +3 -3
  46. package/dist/esm/index.js +7 -7
  47. package/dist/esm/loader.js +1 -1
  48. package/dist/esm/{localization-9320a65d.js → localization-106476cb.js} +1 -1
  49. package/dist/esm/{paypal-338a4350.js → paypal-bf3a2bdd.js} +3 -3
  50. package/dist/esm/{placeTestOrder-d28f33c2.js → placeTestOrder-891295e8.js} +2 -2
  51. package/dist/esm/{renderFallback-28ef3364.js → renderFallback-ce0e238a.js} +2 -2
  52. package/dist/esm/{translationStore-7eebaa41.js → translationStore-766b7521.js} +240 -0
  53. package/dist/esm/zonos-address_11.entry.js +3 -3
  54. package/dist/esm/{zonos-cart-items_12.entry.js → zonos-cart-items_13.entry.js} +23 -6
  55. package/dist/esm/zonos-checkout.entry.js +27 -16
  56. package/dist/esm/zonos-collect-cart-items_3.entry.js +3 -3
  57. package/dist/esm/zonos-collect-finish_6.entry.js +6 -6
  58. package/dist/esm/zonos-collect.entry.js +5 -5
  59. package/dist/esm/zonos-confirm-dialog_2.entry.js +1 -1
  60. package/dist/esm/zonos-controller.entry.js +3 -3
  61. package/dist/esm/zonos-country-flag.entry.js +2 -2
  62. package/dist/esm/zonos-country-select_4.entry.js +2 -2
  63. package/dist/esm/zonos-elements.js +1 -1
  64. package/dist/esm/zonos-empty-state-payment_4.entry.js +4 -4
  65. package/dist/esm/zonos-hello-dialog.entry.js +2 -2
  66. package/dist/esm/zonos-hello.entry.js +2 -2
  67. package/dist/esm/zonos-language-select_2.entry.js +2 -2
  68. package/dist/esm-es5/{cart-11b87221.js → cart-c74f9aaa.js} +1 -1
  69. package/dist/esm-es5/index.js +1 -1
  70. package/dist/esm-es5/loader.js +1 -1
  71. package/dist/esm-es5/{localization-9320a65d.js → localization-106476cb.js} +1 -1
  72. package/dist/esm-es5/{paypal-338a4350.js → paypal-bf3a2bdd.js} +1 -1
  73. package/dist/esm-es5/placeTestOrder-891295e8.js +1 -0
  74. package/dist/esm-es5/{renderFallback-28ef3364.js → renderFallback-ce0e238a.js} +1 -1
  75. package/dist/esm-es5/translationStore-766b7521.js +1 -0
  76. package/dist/esm-es5/zonos-address_11.entry.js +1 -1
  77. package/dist/esm-es5/{zonos-cart-items_12.entry.js → zonos-cart-items_13.entry.js} +1 -1
  78. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  79. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  80. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  81. package/dist/esm-es5/zonos-collect.entry.js +1 -1
  82. package/dist/esm-es5/zonos-confirm-dialog_2.entry.js +1 -1
  83. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  84. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  85. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  86. package/dist/esm-es5/zonos-elements.js +1 -1
  87. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  88. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  89. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  90. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  91. package/dist/scripts/index.d.ts +10 -0
  92. package/dist/scripts/index.js +1 -1
  93. package/dist/scripts/loadZonos.js +1 -1
  94. package/dist/scripts/zonos.js +1 -1
  95. package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +5 -4
  96. package/dist/types/components/store/translationStore/strings.arabic.d.ts +12 -0
  97. package/dist/types/components/store/translationStore/strings.base.d.ts +12 -0
  98. package/dist/types/components/store/translationStore/strings.chinese.d.ts +12 -0
  99. package/dist/types/components/store/translationStore/strings.danish.d.ts +12 -0
  100. package/dist/types/components/store/translationStore/strings.dutch.d.ts +12 -0
  101. package/dist/types/components/store/translationStore/strings.french.d.ts +12 -0
  102. package/dist/types/components/store/translationStore/strings.german.d.ts +12 -0
  103. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +12 -0
  104. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +12 -0
  105. package/dist/types/components/store/translationStore/strings.italian.d.ts +12 -0
  106. package/dist/types/components/store/translationStore/strings.japanese.d.ts +12 -0
  107. package/dist/types/components/store/translationStore/strings.korean.d.ts +12 -0
  108. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +12 -0
  109. package/dist/types/components/store/translationStore/strings.polish.d.ts +12 -0
  110. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +12 -0
  111. package/dist/types/components/store/translationStore/strings.russian.d.ts +12 -0
  112. package/dist/types/components/store/translationStore/strings.spanish.d.ts +12 -0
  113. package/dist/types/components/store/translationStore/strings.swedish.d.ts +12 -0
  114. package/dist/types/components/store/translationStore/strings.turkish.d.ts +12 -0
  115. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +12 -0
  116. package/dist/types/types/generated/graphql.internal.types.d.ts +21 -0
  117. package/dist/types/types/generated/graphql.internal.types.ts +7 -0
  118. package/dist/types/types/utils/ZonosSettings.d.ts +4 -0
  119. package/dist/zonos-elements/index.esm.js +1 -1
  120. package/dist/zonos-elements/{p-19305aa8.entry.js → p-053a042e.entry.js} +1 -1
  121. package/dist/zonos-elements/{p-4ce3489a.entry.js → p-10894d36.entry.js} +1 -1
  122. package/dist/zonos-elements/p-1865e33b.system.entry.js +1 -0
  123. package/dist/zonos-elements/{p-1c5ba523.js → p-1d15662c.js} +1 -1
  124. package/dist/zonos-elements/{p-0260fd13.js → p-203c7fda.js} +1 -1
  125. package/dist/zonos-elements/{p-e00e5d64.system.entry.js → p-21b251f0.system.entry.js} +1 -1
  126. package/dist/zonos-elements/{p-2657f099.system.entry.js → p-225a61c4.system.entry.js} +1 -1
  127. package/dist/zonos-elements/{p-4004c838.system.entry.js → p-236e0144.system.entry.js} +1 -1
  128. package/dist/zonos-elements/{p-9e03a145.system.entry.js → p-23f6a2fb.system.entry.js} +1 -1
  129. package/dist/zonos-elements/{p-bfc0fc85.system.entry.js → p-288f5a5b.system.entry.js} +1 -1
  130. package/dist/zonos-elements/{p-1ef793d0.entry.js → p-2b84039a.entry.js} +1 -1
  131. package/dist/zonos-elements/{p-04c1dc63.system.entry.js → p-2db90c99.system.entry.js} +1 -1
  132. package/dist/zonos-elements/{p-290715a7.system.js → p-33bd80d2.system.js} +1 -1
  133. package/dist/zonos-elements/p-35c247d9.entry.js +1 -0
  134. package/dist/zonos-elements/{p-ba334962.system.entry.js → p-3d2925c5.system.entry.js} +1 -1
  135. package/dist/zonos-elements/{p-ae3e4f2b.entry.js → p-462f8857.entry.js} +1 -1
  136. package/dist/zonos-elements/{p-1868a283.entry.js → p-5608ac9d.entry.js} +1 -1
  137. package/dist/zonos-elements/{p-0b6a3a09.system.entry.js → p-57ee34aa.system.entry.js} +1 -1
  138. package/dist/zonos-elements/{p-d531b524.system.js → p-595668d7.system.js} +1 -1
  139. package/dist/zonos-elements/{p-67787bd4.entry.js → p-62803534.entry.js} +1 -1
  140. package/dist/zonos-elements/p-6497ce22.entry.js +1 -0
  141. package/dist/zonos-elements/{p-6092af05.entry.js → p-65db3219.entry.js} +1 -1
  142. package/dist/zonos-elements/{p-7cee0e68.system.entry.js → p-6c8e4f01.system.entry.js} +1 -1
  143. package/dist/zonos-elements/{p-1b9cc0e2.system.entry.js → p-6f1024de.system.entry.js} +1 -1
  144. package/dist/zonos-elements/{p-0a92e3fd.entry.js → p-76f924b3.entry.js} +1 -1
  145. package/dist/zonos-elements/{p-375994d1.system.entry.js → p-7a97e1cf.system.entry.js} +1 -1
  146. package/dist/zonos-elements/p-81b357f7.system.js +1 -1
  147. package/dist/zonos-elements/{p-4dfe97ad.js → p-964a4d85.js} +2 -2
  148. package/dist/zonos-elements/{p-2616ba72.entry.js → p-9972941a.entry.js} +1 -1
  149. package/dist/zonos-elements/{p-bcf11c99.system.entry.js → p-ad7be556.system.entry.js} +1 -1
  150. package/dist/zonos-elements/{p-cb0e6468.entry.js → p-b0a75761.entry.js} +1 -1
  151. package/dist/zonos-elements/p-b4fe3604.system.js +1 -0
  152. package/dist/zonos-elements/p-b8293509.js +1 -0
  153. package/dist/zonos-elements/{p-873b6185.system.entry.js → p-bd373de0.system.entry.js} +1 -1
  154. package/dist/zonos-elements/{p-7eb8e2d4.js → p-c3c3cd98.js} +1 -1
  155. package/dist/zonos-elements/{p-0ec82d78.system.js → p-c89e9d56.system.js} +1 -1
  156. package/dist/zonos-elements/{p-725605f6.system.js → p-cdaf52f4.system.js} +1 -1
  157. package/dist/zonos-elements/{p-b5b3f908.system.js → p-cef1e888.system.js} +1 -1
  158. package/dist/zonos-elements/{p-e60b988c.entry.js → p-cf56b990.entry.js} +1 -1
  159. package/dist/zonos-elements/{p-112c6453.system.js → p-de984173.system.js} +1 -1
  160. package/dist/zonos-elements/p-eea0d8af.js +1 -0
  161. package/dist/zonos-elements/{p-252fa1da.entry.js → p-f4085c23.entry.js} +1 -1
  162. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  163. package/package.json +1 -1
  164. package/dist/cjs/zonos-link.cjs.entry.js +0 -24
  165. package/dist/esm/zonos-link.entry.js +0 -20
  166. package/dist/esm-es5/placeTestOrder-d28f33c2.js +0 -1
  167. package/dist/esm-es5/translationStore-7eebaa41.js +0 -1
  168. package/dist/esm-es5/zonos-link.entry.js +0 -1
  169. package/dist/zonos-elements/p-02667a58.entry.js +0 -1
  170. package/dist/zonos-elements/p-0d82e1fd.entry.js +0 -1
  171. package/dist/zonos-elements/p-182da73f.system.js +0 -1
  172. package/dist/zonos-elements/p-5c43ecdf.system.entry.js +0 -1
  173. package/dist/zonos-elements/p-820ad058.js +0 -1
  174. package/dist/zonos-elements/p-a800965d.system.entry.js +0 -1
  175. package/dist/zonos-elements/p-cc599cd9.entry.js +0 -1
  176. package/dist/zonos-elements/p-d42b5113.js +0 -1
@@ -0,0 +1 @@
1
+ import{e as r}from"./p-1d15662c.js";import{d as o,s}from"./p-c3c3cd98.js";import{l as n,h as i}from"./p-41dd1cb8.js";const e=({amount:s,isForeign:n})=>{var i,e;const t=(null===(i=r.exchangeRate)||void 0===i?void 0:i.rate)||1,d=r.currency;if((null===(e=r.items[0])||void 0===e?void 0:e.currencyCode)===d)return o({amount:s,currency:d});const a=r.displayBaseCurrency,c=(()=>{var o,s;return r.displayBaseCurrency&&(null===(o=r.exchangeRate)||void 0===o?void 0:o.sourceCurrencyCode)?null===(s=r.exchangeRate)||void 0===s?void 0:s.sourceCurrencyCode:r.currency})();return o(n?{amount:a?s/t:s,currency:c}:{amount:a?s:s*t,currency:c})},t=async()=>{var o,e;const t=null===(o=r.partiesData.find((r=>"DESTINATION"===r.type)))||void 0===o?void 0:o.id,d=null===(e=r.partiesData.find((r=>"PAYOR"===r.type)))||void 0===e?void 0:e.id,a=s.checkoutSessionId;if(!a||!d||!t)return n("Missing required data",{billToPartyId:d,checkoutSessionId:a,shipToPartyId:t}),{errors:["Missing required data"],json:null};const c={billToPartyId:d,checkoutSessionId:a,shipToPartyId:t},{errors:u,json:l}=await i("/api/zonos-elements/place-test-order",{body:c,method:"POST"});return u.length||!l?(n("Error occurs when placing test order",u),{errors:u.map((r=>r.message)),json:null}):{errors:[],json:l}};export{t as p,e as r}
@@ -1 +1 @@
1
- System.register(["./p-5fc34563.system.js","./p-182da73f.system.js","./p-89c5164b.system.js","./p-23e7c655.system.js","./p-433d76b4.system.js","./p-d938f42f.system.js"],(function(o){"use strict";var e,t,n,s,i,a,r,l,c,d,h;return{setters:[function(o){e=o.r;t=o.c;n=o.h;s=o.H;i=o.a},function(o){a=o.t},function(o){r=o.g;l=o.f;c=o.z},function(o){d=o.c},function(o){h=o.g},function(){}],execute:function(){var f='<svg color="var(--zonos-elements-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z" data-is-secondary-color="true" fill="var(--zonos-elements-red-400)"></path>\n <path d="M12.75 9a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0V9Zm0 5.5a.75.75 0 0 0-1.5 0v.5a.75.75 0 0 0 1.5 0v-.5Z" fill="currentColor"></path>\n</svg>';var p='<svg color="var(--zonos-elements-blue-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z" data-is-secondary-color="true" fill="var(--zonos-elements-blue-400)"></path>\n <path d="M10.25 10.25a1.75 1.75 0 1 1 2.431 1.613c-.616.26-1.431.885-1.431 1.887a.75.75 0 0 0 1.5 0c0-.053.02-.128.108-.228.092-.104.236-.205.408-.278A3.25 3.25 0 1 0 8.75 10.25a.75.75 0 0 0 1.5 0Zm2.5 5.75a.75.75 0 0 0-1.5 0v.25a.75.75 0 0 0 1.5 0V16Z" fill="currentColor"></path>\n</svg>';var u='<svg color="var(--zonos-elements-orange-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M14.46 5.492c-1.014-2.027-3.906-2.027-4.92 0L4.276 16.02c-.914 1.83.416 3.98 2.46 3.98h10.528c2.044 0 3.374-2.151 2.46-3.98L14.46 5.492Z" data-is-secondary-color="true" fill="var(--zonos-elements-orange-400)"></path>\n <path d="M12.75 10a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0V10Zm0 5.5a.75.75 0 0 0-1.5 0v.5a.75.75 0 0 0 1.5 0v-.5Z" fill="currentColor"></path>\n</svg>';var m=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--backdrop,:host .zonos--confirm-layout{opacity:0;z-index:-999;visibility:hidden;-webkit-transition:opacity 0.3s, visibility 0.3s;transition:opacity 0.3s, visibility 0.3s}:host .zonos--backdrop{width:100vw;height:100vh;left:0;top:0;background:var(--zonos-elements-backdrop-color);position:fixed}:host .zonos--confirm-layout{width:100vw;height:100vh;left:0;top:0;position:fixed;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;color:var(--zonos-elements-text-color)}:host .zonos--confirm-dialog{position:relative;background:var(--zonos-elements-gray-0);max-width:90vw;max-height:90vh;width:var(--zonos--dialog-width);border-radius:var(--zonos--border-radius, 10px);outline:none;-webkit-box-shadow:var(--zonos-elements-v3-shadow-xxl);box-shadow:var(--zonos-elements-v3-shadow-xxl);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}:host .wrapper{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:24px;gap:24px}:host .icon-wrapper{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;height:40px;width:40px;border-radius:50%;background:var(--zonos-elements-blue-100)}:host .warn .icon-wrapper{background:var(--zonos-elements-orange-100)}:host .danger .icon-wrapper{background:var(--zonos-elements-red-100)}:host .footer{display:-ms-flexbox;display:flex;width:100%;gap:8px}:host .footer zonos-button{-ms-flex:1;flex:1}:host .content{display:-ms-flexbox;display:flex;gap:8px;-ms-flex-direction:column;flex-direction:column}:host .content zonos-text{text-align:center}:host(.open) .zonos--confirm-layout,:host(.open) .zonos--backdrop{visibility:visible}:host(.open) .zonos--backdrop{z-index:2147483009;opacity:0.65}:host(.open) .zonos--confirm-layout{opacity:1;z-index:2147483010;-webkit-transform:scale(1);transform:scale(1)}";var b=m;var v=o("zonos_confirm_dialog",function(){function o(o){var n=this;e(this,o);this.confirmClicked=t(this,"confirmClicked",7);this.cancelClicked=t(this,"cancelClicked",7);this.dialogTitle=a("Are you sure?");this.dialogIntent="info";this.dialogSubtitle=null;this.dialogWidth=350;this.dialogType="confirm";this.isMobile=false;this.noClickOutside=false;this.clickOutsideDialogHandler=function(o){if(o.target===o.currentTarget&&!n.noClickOutside){n.closeDialogHandler()}}}o.prototype.handleKeyDown=function(o){if(o.key==="Escape"){this.closeDialogHandler()}};o.prototype.focusDialog=function(){var o=this;if(this.dialogOpen){setTimeout((function(){var e,t;(t=(e=o.el.shadowRoot)===null||e===void 0?void 0:e.querySelector(".zonos--backdrop"))===null||t===void 0?void 0:t.focus()}),100)}};o.prototype.confirmDialogHandler=function(){if(!this.dialogOpen){return}this.confirmClicked.emit()};o.prototype.closeDialogHandler=function(){if(!this.dialogOpen){return}this.cancelClicked.emit()};o.prototype.renderIcon=function(){switch(this.dialogIntent){case"info":return n("zonos-icon",{content:p,iconColor:"blue-800"});case"danger":return n("zonos-icon",{content:f,iconColor:"red-800"});case"warn":return n("zonos-icon",{content:u,iconColor:"orange-800"})}};o.prototype.getButtonConfirmVariant=function(){switch(this.dialogIntent){case"warn":return"warning";case"danger":return"danger";default:return"primary"}};o.prototype.render=function(){var o=this;this.focusDialog();var e=h();var t=r(c.appearance.theme);return n(s,{key:"c9eabf497f7e23ae201e6310e5ecb9f0d7068294",class:d([this.dialogOpen&&"open","zonos--elements"]),"data-dialog-type":this.dialogType,"data-theme":t,style:{"--zonos--border-radius":e,"--zonos--dialog-width":"".concat(this.dialogWidth,"px"),"--zonos--font-family":l()}},n("div",{key:"a9a525bfe764bf93e8725d9a00c069455de72ed6",class:"zonos--backdrop",tabIndex:-1}),n("div",{key:"072ab68e501618b640ffce6c6e8e96096966e09d",class:d(["zonos--confirm-layout",this.dialogIntent]),onClick:function(e){return o.clickOutsideDialogHandler(e)}},n("div",{key:"3ab415f1cbc2bc36af01d67b279e732480de8685",class:"zonos--confirm-dialog",onBlur:function(){o.focusDialog()}},n("div",{key:"a1d99558318371c0e5ee95a9578a6de31a6fc27a",class:"wrapper"},n("div",{key:"3fd7fbc90c430a3e1496e5b0347947c1929aa6ed",class:"icon-wrapper"},this.renderIcon()),n("div",{key:"5584080e0f0a5a756b0cc2ac761e0e18c864afcd",class:"content"},n("div",{key:"4a2070c137636193d05ded090fea26f05aada887",class:"title"},n("zonos-text",{key:"ab4c773f4af1271f5615a28f6a6193460330f16b",type:"subheader"},this.dialogTitle)),this.dialogSubtitle&&n("div",{key:"05a445dc37e754c99ea6727ae2bf861d42d5c2c4",class:"subtitle"},n("zonos-text",{key:"a7563f9fd3b405653487542e1b7a1f6aeab01893",textColor:"gray-800"},this.dialogSubtitle))),n("div",{key:"812e9e43fdb6d10ed62da8138e344b0243ca5c34",class:"footer"},this.dialogType==="confirm"&&n("zonos-button",{key:"07d7dc9d1a4bca9cb1ee420a4fed82e9fc513bd9",backgroundColor:"gray-0",class:"cancel-button",onClick:function(){return o.closeDialogHandler()},size:"lg",withBoxShadow:true},this.dialogCancelBtnText||a("Cancel")),n("zonos-button",{key:"b607a5244dc39869b6d40cd361d9dee4686858a7",class:"confirm-button",onClick:function(){return o.confirmDialogHandler()},size:"lg",variant:this.getButtonConfirmVariant()},this.dialogConfirmBtnText))))))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(o.prototype,"el",{get:function(){return i(this)},enumerable:false,configurable:true});return o}());v.style=b;var y=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{position:fixed;inset:0;z-index:2147483010;pointer-events:none;display:block}:host .zonos--loading-overlay{position:fixed;inset:0;width:100vw;height:100vh;background:var(--zonos-elements-backdrop-color);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;opacity:0;visibility:hidden;-webkit-transition:opacity 0.3s ease, visibility 0.3s ease;transition:opacity 0.3s ease, visibility 0.3s ease;z-index:2147483010}:host(.zonos--open){pointer-events:auto}:host(.zonos--open) .zonos--loading-overlay{opacity:0.65;visibility:visible}";var x=y;var g=o("zonos_loading_overlay",function(){function o(o){e(this,o);this.open=false;this.size=40}o.prototype.render=function(){return n(s,{key:"1eb7313add29219032d8301abaf55ace726a3309",class:d(["zonos--elements",this.open&&"zonos--open"])},n("div",{key:"df9960e78817a9a98006fed7e87c5441f220f496",class:"zonos--loading-overlay"},n("zonos-spinner",{key:"32795fe2c626add5d2f53032ea9b5b8d528bef38",size:this.size,spinnerColor:this.spinnerColor})))};return o}());g.style=x}}}));
1
+ System.register(["./p-5fc34563.system.js","./p-b4fe3604.system.js","./p-89c5164b.system.js","./p-23e7c655.system.js","./p-433d76b4.system.js","./p-d938f42f.system.js"],(function(o){"use strict";var e,t,n,s,i,a,r,l,c,d,h;return{setters:[function(o){e=o.r;t=o.c;n=o.h;s=o.H;i=o.a},function(o){a=o.t},function(o){r=o.g;l=o.f;c=o.z},function(o){d=o.c},function(o){h=o.g},function(){}],execute:function(){var f='<svg color="var(--zonos-elements-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z" data-is-secondary-color="true" fill="var(--zonos-elements-red-400)"></path>\n <path d="M12.75 9a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0V9Zm0 5.5a.75.75 0 0 0-1.5 0v.5a.75.75 0 0 0 1.5 0v-.5Z" fill="currentColor"></path>\n</svg>';var p='<svg color="var(--zonos-elements-blue-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z" data-is-secondary-color="true" fill="var(--zonos-elements-blue-400)"></path>\n <path d="M10.25 10.25a1.75 1.75 0 1 1 2.431 1.613c-.616.26-1.431.885-1.431 1.887a.75.75 0 0 0 1.5 0c0-.053.02-.128.108-.228.092-.104.236-.205.408-.278A3.25 3.25 0 1 0 8.75 10.25a.75.75 0 0 0 1.5 0Zm2.5 5.75a.75.75 0 0 0-1.5 0v.25a.75.75 0 0 0 1.5 0V16Z" fill="currentColor"></path>\n</svg>';var u='<svg color="var(--zonos-elements-orange-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M14.46 5.492c-1.014-2.027-3.906-2.027-4.92 0L4.276 16.02c-.914 1.83.416 3.98 2.46 3.98h10.528c2.044 0 3.374-2.151 2.46-3.98L14.46 5.492Z" data-is-secondary-color="true" fill="var(--zonos-elements-orange-400)"></path>\n <path d="M12.75 10a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0V10Zm0 5.5a.75.75 0 0 0-1.5 0v.5a.75.75 0 0 0 1.5 0v-.5Z" fill="currentColor"></path>\n</svg>';var b=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--backdrop,:host .zonos--confirm-layout{opacity:0;z-index:-999;visibility:hidden;-webkit-transition:opacity 0.3s, visibility 0.3s;transition:opacity 0.3s, visibility 0.3s}:host .zonos--backdrop{width:100vw;height:100vh;left:0;top:0;background:var(--zonos-elements-backdrop-color);position:fixed}:host .zonos--confirm-layout{width:100vw;height:100vh;left:0;top:0;position:fixed;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;color:var(--zonos-elements-text-color)}:host .zonos--confirm-dialog{position:relative;background:var(--zonos-elements-gray-0);max-width:90vw;max-height:90vh;width:var(--zonos--dialog-width);border-radius:var(--zonos--border-radius, 10px);outline:none;-webkit-box-shadow:var(--zonos-elements-v3-shadow-xxl);box-shadow:var(--zonos-elements-v3-shadow-xxl);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}:host .wrapper{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:24px;gap:24px}:host .icon-wrapper{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;height:40px;width:40px;border-radius:50%;background:var(--zonos-elements-blue-100)}:host .warn .icon-wrapper{background:var(--zonos-elements-orange-100)}:host .danger .icon-wrapper{background:var(--zonos-elements-red-100)}:host .footer{display:-ms-flexbox;display:flex;width:100%;gap:8px}:host .footer zonos-button{-ms-flex:1;flex:1}:host .content{display:-ms-flexbox;display:flex;gap:8px;-ms-flex-direction:column;flex-direction:column}:host .content zonos-text{text-align:center}:host(.open) .zonos--confirm-layout,:host(.open) .zonos--backdrop{visibility:visible}:host(.open) .zonos--backdrop{z-index:2147483009;opacity:0.65}:host(.open) .zonos--confirm-layout{opacity:1;z-index:2147483010;-webkit-transform:scale(1);transform:scale(1)}";var m=b;var v=o("zonos_confirm_dialog",function(){function o(o){var n=this;e(this,o);this.confirmClicked=t(this,"confirmClicked",7);this.cancelClicked=t(this,"cancelClicked",7);this.dialogTitle=a("Are you sure?");this.dialogIntent="info";this.dialogSubtitle=null;this.dialogWidth=350;this.dialogType="confirm";this.isMobile=false;this.noClickOutside=false;this.clickOutsideDialogHandler=function(o){if(o.target===o.currentTarget&&!n.noClickOutside){n.closeDialogHandler()}}}o.prototype.handleKeyDown=function(o){if(o.key==="Escape"){this.closeDialogHandler()}};o.prototype.focusDialog=function(){var o=this;if(this.dialogOpen){setTimeout((function(){var e,t;(t=(e=o.el.shadowRoot)===null||e===void 0?void 0:e.querySelector(".zonos--backdrop"))===null||t===void 0?void 0:t.focus()}),100)}};o.prototype.confirmDialogHandler=function(){if(!this.dialogOpen){return}this.confirmClicked.emit()};o.prototype.closeDialogHandler=function(){if(!this.dialogOpen){return}this.cancelClicked.emit()};o.prototype.renderIcon=function(){switch(this.dialogIntent){case"info":return n("zonos-icon",{content:p,iconColor:"blue-800"});case"danger":return n("zonos-icon",{content:f,iconColor:"red-800"});case"warn":return n("zonos-icon",{content:u,iconColor:"orange-800"})}};o.prototype.getButtonConfirmVariant=function(){switch(this.dialogIntent){case"warn":return"warning";case"danger":return"danger";default:return"primary"}};o.prototype.render=function(){var o=this;this.focusDialog();var e=h();var t=r(c.appearance.theme);return n(s,{key:"c9eabf497f7e23ae201e6310e5ecb9f0d7068294",class:d([this.dialogOpen&&"open","zonos--elements"]),"data-dialog-type":this.dialogType,"data-theme":t,style:{"--zonos--border-radius":e,"--zonos--dialog-width":"".concat(this.dialogWidth,"px"),"--zonos--font-family":l()}},n("div",{key:"a9a525bfe764bf93e8725d9a00c069455de72ed6",class:"zonos--backdrop",tabIndex:-1}),n("div",{key:"072ab68e501618b640ffce6c6e8e96096966e09d",class:d(["zonos--confirm-layout",this.dialogIntent]),onClick:function(e){return o.clickOutsideDialogHandler(e)}},n("div",{key:"3ab415f1cbc2bc36af01d67b279e732480de8685",class:"zonos--confirm-dialog",onBlur:function(){o.focusDialog()}},n("div",{key:"a1d99558318371c0e5ee95a9578a6de31a6fc27a",class:"wrapper"},n("div",{key:"3fd7fbc90c430a3e1496e5b0347947c1929aa6ed",class:"icon-wrapper"},this.renderIcon()),n("div",{key:"5584080e0f0a5a756b0cc2ac761e0e18c864afcd",class:"content"},n("div",{key:"4a2070c137636193d05ded090fea26f05aada887",class:"title"},n("zonos-text",{key:"ab4c773f4af1271f5615a28f6a6193460330f16b",type:"subheader"},this.dialogTitle)),this.dialogSubtitle&&n("div",{key:"05a445dc37e754c99ea6727ae2bf861d42d5c2c4",class:"subtitle"},n("zonos-text",{key:"a7563f9fd3b405653487542e1b7a1f6aeab01893",textColor:"gray-800"},this.dialogSubtitle))),n("div",{key:"812e9e43fdb6d10ed62da8138e344b0243ca5c34",class:"footer"},this.dialogType==="confirm"&&n("zonos-button",{key:"07d7dc9d1a4bca9cb1ee420a4fed82e9fc513bd9",backgroundColor:"gray-0",class:"cancel-button",onClick:function(){return o.closeDialogHandler()},size:"lg",withBoxShadow:true},this.dialogCancelBtnText||a("Cancel")),n("zonos-button",{key:"b607a5244dc39869b6d40cd361d9dee4686858a7",class:"confirm-button",onClick:function(){return o.confirmDialogHandler()},size:"lg",variant:this.getButtonConfirmVariant()},this.dialogConfirmBtnText))))))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(o.prototype,"el",{get:function(){return i(this)},enumerable:false,configurable:true});return o}());v.style=m;var y=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{position:fixed;inset:0;z-index:2147483010;pointer-events:none;display:block}:host .zonos--loading-overlay{position:fixed;inset:0;width:100vw;height:100vh;background:var(--zonos-elements-backdrop-color);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;opacity:0;visibility:hidden;-webkit-transition:opacity 0.3s ease, visibility 0.3s ease;transition:opacity 0.3s ease, visibility 0.3s ease;z-index:2147483010}:host(.zonos--open){pointer-events:auto}:host(.zonos--open) .zonos--loading-overlay{opacity:0.65;visibility:visible}";var x=y;var g=o("zonos_loading_overlay",function(){function o(o){e(this,o);this.open=false;this.size=40}o.prototype.render=function(){return n(s,{key:"1eb7313add29219032d8301abaf55ace726a3309",class:d(["zonos--elements",this.open&&"zonos--open"])},n("div",{key:"df9960e78817a9a98006fed7e87c5441f220f496",class:"zonos--loading-overlay"},n("zonos-spinner",{key:"32795fe2c626add5d2f53032ea9b5b8d528bef38",size:this.size,spinnerColor:this.spinnerColor})))};return o}());g.style=x}}}));
@@ -1 +1 @@
1
- import{c as e,z as n}from"./p-7af39c98.js";import{j as o,h as t,l as r}from"./p-41dd1cb8.js";import{a,l as s}from"./p-0a377722.js";import{a as c}from"./p-d42b5113.js";const i=e=>{return!!(n=e).find((e=>e.testKey in a))||s("No available test key found in response","info",{response:n}),n.find((e=>e.testKey in a))?e.filter((e=>{var n;const o=a[e.testKey]&&!e.selectedVariantKey,t=e.selectedVariantKey&&!!(null===(n=a[e.testKey])||void 0===n?void 0:n.availableVariants.includes(e.selectedVariantKey));return o||t})).map((e=>Object.assign(Object.assign({},e),{expiresAt:e.expiresAt||Date.now()+l,selectedVariantKey:e.selectedVariantKey||null}))):[];var n},l=864e5,{onChange:u,state:d}=e({checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id"),enabledVariantTestKeys:o(localStorage.getItem("zonos--enabled-variant-test-keys"))});u("enabledVariantTestKeys",(()=>{var e;(null===(e=d.enabledVariantTestKeys)||void 0===e?void 0:e.length)?localStorage.setItem("zonos--enabled-variant-test-keys",JSON.stringify(d.enabledVariantTestKeys)):localStorage.removeItem("zonos--enabled-variant-test-keys")})),u("checkoutSessionId",(()=>{d.checkoutSessionId?sessionStorage.setItem("zonos--checkout-session-id",d.checkoutSessionId):sessionStorage.removeItem("zonos--checkout-session-id")}));const y=e=>{d.enabledVariantTestKeys=i(e)},m=async()=>{try{const{errors:e,json:n}=await t("/api/zonos-elements/get-countries",{method:"GET"});return e.length||!n?null:n}catch(e){return null}},w={exchangeRate:{rate:1,targetFormat:{currencyCode:"USD",decimalDelimiter:".",scale:2,symbol:"$",symbolLocation:"before",thousandsDelimiter:","}},maxAge:null},v=e=>{const n=new URLSearchParams(e||window.location.search),o=e=>{return(o=n.get(e))&&/^[A-Z]{2}$/.test(o)?o:null;var o},t=o("zCountry"),r=o("country"),a=o("customerCountry");return t||r||a},g=async()=>{try{const e=new URL(window.location.href),n=window.sessionStorage.getItem("zonos--country"),o=v(e.searchParams)||n,r=new URLSearchParams;o&&r.set("zCountry",o);const{errors:a,json:s}=await t(`/api/zonos-elements/localization?${r.toString()}`);return a.length||!s?{country:null,locale:null}:{country:s.country,locale:s.locale}}catch(e){return{country:null,locale:null}}},p=async()=>{var e,n,o;if(null===(e=window.Zonos.cartSettings)||void 0===e?void 0:e.shippingZones)return window.Zonos.cartSettings.shippingZones.flatMap((e=>null==e?void 0:e.countryCodes)).filter(Boolean);const{errors:a,json:s}=await t("/api/zonos-elements/shipping-zones");return a.length||!s?(r(`Error fetching shipping zones: ${null===(n=a.find(Boolean))||void 0===n?void 0:n.message}`),null):(null===(o=null==s?void 0:s.shippingZones)||void 0===o?void 0:o.flatMap((e=>null==e?void 0:e.countryCodes)).filter(Boolean))||null},f=e=>{const{exchangeRate:n}=E;if(!n||!e||isNaN(e))return e;const o=(e*n.rate).toFixed((null==n?void 0:n.targetFormat.scale)||2);return Number(o)},h=({amount:e,currency:o})=>{if(isNaN(e)||0!==e&&!e)return"";const t=n.overrideCurrencyFormat,{exchangeRate:r}=E,a=o||E.targetCurrency;if("function"==typeof t)return t({amount:e,currencyCode:a,numberFormat:({amount:e})=>(({amount:e,currency:n,targetFormat:o})=>{const t=n||E.targetCurrency,r=(null==o?void 0:o.scale)||2,a=-1!==window.navigator.userAgent.indexOf("MSIE "),s="object"==typeof Intl&&Intl&&"function"==typeof Intl.NumberFormat;return a||!s?Number(e).toFixed(r).replace(".","|dec|").replace(",",(null==o?void 0:o.thousandsDelimiter)||"").replace("|dec|",(null==o?void 0:o.decimalDelimiter)||""):new Intl.NumberFormat(window.navigator.language,{currency:t,currencyDisplay:"code",minimumFractionDigits:r,style:"currency"}).format(e).replace(new RegExp(`${t}\\s+`),"")})({amount:e,currency:a,targetFormat:(null==r?void 0:r.targetFormat)||null})});const{targetFormat:s}=r||{};if(!s||!r)return`${e.toFixed(2)} ${a}`;const c=s.scale||2,i=-1!==window.navigator.userAgent.indexOf("MSIE "),l="object"==typeof Intl&&Intl&&"function"==typeof Intl.NumberFormat;if(i||!l)return`${Number(e).toFixed(c).replace(".","|dec|").replace(",",s.thousandsDelimiter||"").replace("|dec|",s.decimalDelimiter||"")}${"USD"!==s.currencyCode?` ${s.currencyCode}`:""}`;const u=(null==t?void 0:t.currencyDisplay)||"symbol",d=new Intl.NumberFormat(window.navigator.language,{currency:a,currencyDisplay:u,minimumFractionDigits:c,style:"currency"}).format(e);return"code"===u?`${d.replace(new RegExp(`${a}\\s+`),"")} ${a}`:d},C=e=>{const n=f(e);return h({amount:n})},z=e=>{try{document.createDocumentFragment().querySelector(e)}catch(e){return!1}return!0},b="z--blur",S=async()=>{const e=window.zonosBlurCurrencyOnInitIntervalId;e&&(await new Promise((e=>setTimeout(e,500))),clearInterval(e),document.querySelectorAll(`.${b}`).forEach((e=>{e.classList.remove(b)})),window.zonosBlurCurrencyOnInitIntervalId=void 0)},$=({currencySelector:e})=>{e&&document.querySelectorAll([e].filter(Boolean).join(",")).forEach((e=>{e.classList.add(b)}))},A=()=>{if("undefined"==typeof window)return;if(window.zonosBlurCurrencyOnInitIntervalId)return;$({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});const e=setInterval((()=>{$({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})}),10);window.zonosBlurCurrencyOnInitIntervalId=e,setTimeout((()=>{S()}),7e3)},j=()=>{const{currencyElementSelector:e}=n.helloSettings,o=(e=>{const n=e||".money";if(!z(n))return r(`Currency element selector "${n}" is not valid.`),null;const o=document.querySelectorAll(n);return o.length?Array.from(o):(s(`No currency elements found with selector "${n}"`,"warn"),null)})(e);(null==o?void 0:o.length)&&(E.exchangeRate?o.forEach((e=>{(e=>{var o;const t=(e=>{var n;const o=e.getAttribute("data-domestic"),t=e.getAttribute("data-zintl"),r=null===(n=e.textContent)||void 0===n?void 0:n.replace(/[^\d.-]/g,"");return r?!o||e.textContent!==t&&t?(e.setAttribute("data-domestic",r),parseFloat(r)):parseFloat(o):null})(e);if(!t||isNaN(t))return;const r=e.getAttribute("data-zintl"),a=parseFloat(e.getAttribute("data-zrate")||"1"),s=e.getAttribute("data-zcountry-code"),c=(null===(o=E.exchangeRate)||void 0===o?void 0:o.rate)||1;if(E.exchangeRate&&E.targetCurrency===E.exchangeRate.targetFormat.currencyCode&&(e.textContent!==r||c!==a||s!==E.selectedCountryCode)){A();const o="function"==typeof n.currencyConverter&&n.currencyConverter({convert:f,convertAndFormat:C,currencyCode:E.targetCurrency,format:e=>h({amount:e}),originalAmount:t,selector:e})||C(t);o!==e.textContent&&(e.textContent=o),e.setAttribute("data-zrate",c.toString()),e.setAttribute("data-zintl",o),e.setAttribute("data-zcountry-code",E.selectedCountryCode||"")}S()})(e)})):r("Could not display currency. Exchange rate and format data is not available."))},x=()=>{"DISABLED"===n.helloSettings.currencyBehavior||window.Zonos.isLegacyCheckout?S():j()},L=e=>{if(!e)return;const o=new URLSearchParams(window.location.search);if(o.has("zCountry")||"URL_PARAM"===n.helloSettings.countryOverrideBehavior){o.set("zCountry",e);const n=`${window.location.pathname}?${o.toString()}`;window.history.replaceState(window.history.state,document.title,n)}},{onChange:I,state:E}=e({countryLandedCost:null,customMessages:[],exchangeRate:null,helloCountryList:null,inclusivePricing:null,isDisabledCountry:!0,isShippableCountry:!1,localizationLoaded:!1,selectedCountryCode:null,selectedLocale:"en",shippingZoneCountries:null,targetCurrency:"USD"}),N=async e=>{const{exchangeRate:o,maxAge:a}=await(async({country:e,isGuaranteed:n,sourceCurrency:o,targetCurrency:a})=>{var s;if(o===a&&!n)return w;const c=new URLSearchParams;c.set("sourceCurrency",o),c.set("targetCurrency",a),c.set("isGuaranteed",String(n)),c.set("country",e||"");const{errors:i,json:l}=await t(`/api/zonos-elements/exchange-rates?${c.toString()}`);if(i.length||!l)return r(`Error fetching country landed cost: ${null===(s=i.find(Boolean))||void 0===s?void 0:s.message}`),w;const{rate:u,targetFormat:d}=l.exchangeRateCreate,y=l.maxAge;return u?(sessionStorage.setItem(e+"_rate",JSON.stringify(u)),{exchangeRate:{rate:u,targetFormat:d},maxAge:y}):w})({country:E.selectedCountryCode,isGuaranteed:e,sourceCurrency:n.sourceCurrency,targetCurrency:E.targetCurrency});return o&&(E.exchangeRate=o,x()),{maxAge:a}},D=e=>E.selectedCountryCode&&e.includes(E.selectedCountryCode)?E.selectedCountryCode:"CA",R=({isGuaranteed:e,maxAge:n})=>{E.exchangeRateTimeout&&clearTimeout(E.exchangeRateTimeout),E.exchangeRateTimeout=setTimeout((async()=>{const{maxAge:n}=await N(e);R({isGuaranteed:e,maxAge:n})}),1e3*(n||300))},k=e=>{var o,a;s(`Updating selected country code to ${e}`);const c=!E.selectedCountryCode;var i;E.selectedCountryCode="UK"===(i=e)?"GB":i;const{selectedCountryCode:l,shippingZoneCountries:u}=E,d=!(!u||!l||!u[l]||n.disabledCountries.includes(l));E.isShippableCountry=d,s(`${E.selectedCountryCode} is a shippable country: ${E.isShippableCountry}`);const y=!!l&&n.disabledCountries.includes(l);if(E.isDisabledCountry=y,s(`${E.selectedCountryCode} is a disabled country: ${E.isDisabledCountry}`),E.isShippableCountry?document.body.classList.add("z-intl"):document.body.classList.remove("z-intl"),!l)return;const m=(e=>{var n;const o=null===(n=E.shippingZoneCountries)||void 0===n?void 0:n[e];return o?o.currencyCode:null})(l);c||null===(o=n.onCountryChange)||void 0===o||o.call(n,{countryCode:l,currencyCode:m,isShippableCountry:d}),m&&(E.targetCurrency=m,(async()=>{var e;s("get new localization store");const{isDisabledCountry:o,isShippableCountry:a,selectedCountryCode:c}=E;if("DISABLED"===n.helloSettings.currencyBehavior||!a||o||!c)return;const i="ENABLED"===n.checkoutSettings.visibilityStatus;A();const{maxAge:l}=await N(i);R({isGuaranteed:i,maxAge:l}),window.Zonos.isLegacyCheckout?s("Skipping country landed cost and inclusive pricing requests, because this is a legacy checkout"):(E.countryLandedCost=await(async e=>{var n;if(!e)return null;const o=`/api/zonos-elements/country-landed-cost/${e}`,{errors:a,json:s}=await t(o);return a.length||!s?(r(`Error fetching country landed cost: ${null===(n=a.find(Boolean))||void 0===n?void 0:n.message}`),null):s||null})(E.selectedCountryCode),E.inclusivePricing=(null===(e=await(async e=>{var n;if(!e)return null;const{errors:o,json:a}=await t(`/api/zonos-elements/inclusive-prices/${e}`);return o.length||!a?(r(`Error fetching country inclusive price setting: ${null===(n=o.find(Boolean))||void 0===n?void 0:n.message}`),null):a||null})(c))||void 0===e?void 0:e.setting)||null,E.inclusivePricing&&s(`Inclusive price setting found for this country (${c}) ${JSON.stringify(E.inclusivePricing,null,2)}`))})(),window.sessionStorage.setItem("zonos--country",l),L(l),null===(a=document.querySelector("zonos-hello"))||void 0===a||a.setAttribute("z-country",l))},B=e=>{E.selectedLocale=e,c(e),(async()=>{if(!d.checkoutSessionId)return null;const{errors:e,json:n}=await t("/api/zonos-elements/update-checkout-session-metadata",{body:{id:d.checkoutSessionId,metadata:[{key:"language",value:E.selectedLocale}]},method:"POST"});(e.length||!n)&&r("Error occurs when updating checkout session",JSON.stringify(e,null,2))})(),(async()=>{if(s(`Getting custom messages for ${E.selectedCountryCode}`),!E.selectedCountryCode||!n.storeId)return;const e=(await(async({countryCode:e,localeTo:n,storeId:o})=>{var a;const s=new URLSearchParams;s.set("countryCode",e),s.set("storeId",o.toString()),n&&s.set("localeTo",n);const{errors:c,json:i}=await t(`/api/zonos-elements/locale-messages?${s.toString()}`);return c.length||!i?(r("Error fetching exchange rate",null===(a=c.find(Boolean))||void 0===a?void 0:a.message),[]):i.locale_countryCodesPage})({countryCode:E.selectedCountryCode,localeTo:E.selectedLocale,storeId:n.storeId})).flatMap((e=>{var n;return{countryCode:E.selectedCountryCode,message:null===(n=e.countryCodesPageMessageLinks.find(Boolean))||void 0===n?void 0:n.message.textTo,pageName:e.pageName}}));E.customMessages=e})()},F=async()=>{const[e,o,t]=await Promise.all([m(),p(),g()]),r=null==o?void 0:o.reduce(((n,o)=>{const t=null==e?void 0:e[o];return t?Object.assign(Object.assign({},n),{[o]:t}):n}),{});E.shippingZoneCountries=r||null,(e=>{const o=n.helloSettings.showCountryList,t=E.shippingZoneCountries;E.helloCountryList=o&&"ONLY_SHIPPABLE"!==o?"ALL"!==o?o.reduce(((n,o)=>{const t=null==e?void 0:e[o];return t?Object.assign(Object.assign({},n),{[o]:t}):n}),{}):e:t})(e||{});const{country:a,locale:c}=t;s(`Country code from localization: ${a}`),s(`Locale from localization: ${c}`),k(a);const i=new URL(window.location.href).searchParams.get("zonosLocale");B(i||c||"en"),!E.selectedCountryCode&&["dev.storybook.elements","dev.elements","dev.demo.elements","dev.dashboard"].some((e=>window.location.origin.includes(e)))&&k("CA"),E.localizationLoaded=!0};export{l as V,k as a,y as b,I as c,h as d,F as e,i as f,v as g,L as h,z as i,x as j,C as k,E as l,f as m,D as n,u as o,B as p,d as s}
1
+ import{c as e,z as n}from"./p-7af39c98.js";import{j as o,h as t,l as r}from"./p-41dd1cb8.js";import{a,l as s}from"./p-0a377722.js";import{a as c}from"./p-eea0d8af.js";const i=e=>{return!!(n=e).find((e=>e.testKey in a))||s("No available test key found in response","info",{response:n}),n.find((e=>e.testKey in a))?e.filter((e=>{var n;const o=a[e.testKey]&&!e.selectedVariantKey,t=e.selectedVariantKey&&!!(null===(n=a[e.testKey])||void 0===n?void 0:n.availableVariants.includes(e.selectedVariantKey));return o||t})).map((e=>Object.assign(Object.assign({},e),{expiresAt:e.expiresAt||Date.now()+l,selectedVariantKey:e.selectedVariantKey||null}))):[];var n},l=864e5,{onChange:u,state:d}=e({checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id"),enabledVariantTestKeys:o(localStorage.getItem("zonos--enabled-variant-test-keys"))});u("enabledVariantTestKeys",(()=>{var e;(null===(e=d.enabledVariantTestKeys)||void 0===e?void 0:e.length)?localStorage.setItem("zonos--enabled-variant-test-keys",JSON.stringify(d.enabledVariantTestKeys)):localStorage.removeItem("zonos--enabled-variant-test-keys")})),u("checkoutSessionId",(()=>{d.checkoutSessionId?sessionStorage.setItem("zonos--checkout-session-id",d.checkoutSessionId):sessionStorage.removeItem("zonos--checkout-session-id")}));const y=e=>{d.enabledVariantTestKeys=i(e)},m=async()=>{try{const{errors:e,json:n}=await t("/api/zonos-elements/get-countries",{method:"GET"});return e.length||!n?null:n}catch(e){return null}},w={exchangeRate:{rate:1,targetFormat:{currencyCode:"USD",decimalDelimiter:".",scale:2,symbol:"$",symbolLocation:"before",thousandsDelimiter:","}},maxAge:null},v=e=>{const n=new URLSearchParams(e||window.location.search),o=e=>{return(o=n.get(e))&&/^[A-Z]{2}$/.test(o)?o:null;var o},t=o("zCountry"),r=o("country"),a=o("customerCountry");return t||r||a},g=async()=>{try{const e=new URL(window.location.href),n=window.sessionStorage.getItem("zonos--country"),o=v(e.searchParams)||n,r=new URLSearchParams;o&&r.set("zCountry",o);const{errors:a,json:s}=await t(`/api/zonos-elements/localization?${r.toString()}`);return a.length||!s?{country:null,locale:null}:{country:s.country,locale:s.locale}}catch(e){return{country:null,locale:null}}},p=async()=>{var e,n,o;if(null===(e=window.Zonos.cartSettings)||void 0===e?void 0:e.shippingZones)return window.Zonos.cartSettings.shippingZones.flatMap((e=>null==e?void 0:e.countryCodes)).filter(Boolean);const{errors:a,json:s}=await t("/api/zonos-elements/shipping-zones");return a.length||!s?(r(`Error fetching shipping zones: ${null===(n=a.find(Boolean))||void 0===n?void 0:n.message}`),null):(null===(o=null==s?void 0:s.shippingZones)||void 0===o?void 0:o.flatMap((e=>null==e?void 0:e.countryCodes)).filter(Boolean))||null},f=e=>{const{exchangeRate:n}=E;if(!n||!e||isNaN(e))return e;const o=(e*n.rate).toFixed((null==n?void 0:n.targetFormat.scale)||2);return Number(o)},h=({amount:e,currency:o})=>{if(isNaN(e)||0!==e&&!e)return"";const t=n.overrideCurrencyFormat,{exchangeRate:r}=E,a=o||E.targetCurrency;if("function"==typeof t)return t({amount:e,currencyCode:a,numberFormat:({amount:e})=>(({amount:e,currency:n,targetFormat:o})=>{const t=n||E.targetCurrency,r=(null==o?void 0:o.scale)||2,a=-1!==window.navigator.userAgent.indexOf("MSIE "),s="object"==typeof Intl&&Intl&&"function"==typeof Intl.NumberFormat;return a||!s?Number(e).toFixed(r).replace(".","|dec|").replace(",",(null==o?void 0:o.thousandsDelimiter)||"").replace("|dec|",(null==o?void 0:o.decimalDelimiter)||""):new Intl.NumberFormat(window.navigator.language,{currency:t,currencyDisplay:"code",minimumFractionDigits:r,style:"currency"}).format(e).replace(new RegExp(`${t}\\s+`),"")})({amount:e,currency:a,targetFormat:(null==r?void 0:r.targetFormat)||null})});const{targetFormat:s}=r||{};if(!s||!r)return`${e.toFixed(2)} ${a}`;const c=s.scale||2,i=-1!==window.navigator.userAgent.indexOf("MSIE "),l="object"==typeof Intl&&Intl&&"function"==typeof Intl.NumberFormat;if(i||!l)return`${Number(e).toFixed(c).replace(".","|dec|").replace(",",s.thousandsDelimiter||"").replace("|dec|",s.decimalDelimiter||"")}${"USD"!==s.currencyCode?` ${s.currencyCode}`:""}`;const u=(null==t?void 0:t.currencyDisplay)||"symbol",d=new Intl.NumberFormat(window.navigator.language,{currency:a,currencyDisplay:u,minimumFractionDigits:c,style:"currency"}).format(e);return"code"===u?`${d.replace(new RegExp(`${a}\\s+`),"")} ${a}`:d},C=e=>{const n=f(e);return h({amount:n})},z=e=>{try{document.createDocumentFragment().querySelector(e)}catch(e){return!1}return!0},b="z--blur",S=async()=>{const e=window.zonosBlurCurrencyOnInitIntervalId;e&&(await new Promise((e=>setTimeout(e,500))),clearInterval(e),document.querySelectorAll(`.${b}`).forEach((e=>{e.classList.remove(b)})),window.zonosBlurCurrencyOnInitIntervalId=void 0)},$=({currencySelector:e})=>{e&&document.querySelectorAll([e].filter(Boolean).join(",")).forEach((e=>{e.classList.add(b)}))},A=()=>{if("undefined"==typeof window)return;if(window.zonosBlurCurrencyOnInitIntervalId)return;$({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});const e=setInterval((()=>{$({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})}),10);window.zonosBlurCurrencyOnInitIntervalId=e,setTimeout((()=>{S()}),7e3)},j=()=>{const{currencyElementSelector:e}=n.helloSettings,o=(e=>{const n=e||".money";if(!z(n))return r(`Currency element selector "${n}" is not valid.`),null;const o=document.querySelectorAll(n);return o.length?Array.from(o):(s(`No currency elements found with selector "${n}"`,"warn"),null)})(e);(null==o?void 0:o.length)&&(E.exchangeRate?o.forEach((e=>{(e=>{var o;const t=(e=>{var n;const o=e.getAttribute("data-domestic"),t=e.getAttribute("data-zintl"),r=null===(n=e.textContent)||void 0===n?void 0:n.replace(/[^\d.-]/g,"");return r?!o||e.textContent!==t&&t?(e.setAttribute("data-domestic",r),parseFloat(r)):parseFloat(o):null})(e);if(!t||isNaN(t))return;const r=e.getAttribute("data-zintl"),a=parseFloat(e.getAttribute("data-zrate")||"1"),s=e.getAttribute("data-zcountry-code"),c=(null===(o=E.exchangeRate)||void 0===o?void 0:o.rate)||1;if(E.exchangeRate&&E.targetCurrency===E.exchangeRate.targetFormat.currencyCode&&(e.textContent!==r||c!==a||s!==E.selectedCountryCode)){A();const o="function"==typeof n.currencyConverter&&n.currencyConverter({convert:f,convertAndFormat:C,currencyCode:E.targetCurrency,format:e=>h({amount:e}),originalAmount:t,selector:e})||C(t);o!==e.textContent&&(e.textContent=o),e.setAttribute("data-zrate",c.toString()),e.setAttribute("data-zintl",o),e.setAttribute("data-zcountry-code",E.selectedCountryCode||"")}S()})(e)})):r("Could not display currency. Exchange rate and format data is not available."))},x=()=>{"DISABLED"===n.helloSettings.currencyBehavior||window.Zonos.isLegacyCheckout?S():j()},L=e=>{if(!e)return;const o=new URLSearchParams(window.location.search);if(o.has("zCountry")||"URL_PARAM"===n.helloSettings.countryOverrideBehavior){o.set("zCountry",e);const n=`${window.location.pathname}?${o.toString()}`;window.history.replaceState(window.history.state,document.title,n)}},{onChange:I,state:E}=e({countryLandedCost:null,customMessages:[],exchangeRate:null,helloCountryList:null,inclusivePricing:null,isDisabledCountry:!0,isShippableCountry:!1,localizationLoaded:!1,selectedCountryCode:null,selectedLocale:"en",shippingZoneCountries:null,targetCurrency:"USD"}),N=async e=>{const{exchangeRate:o,maxAge:a}=await(async({country:e,isGuaranteed:n,sourceCurrency:o,targetCurrency:a})=>{var s;if(o===a&&!n)return w;const c=new URLSearchParams;c.set("sourceCurrency",o),c.set("targetCurrency",a),c.set("isGuaranteed",String(n)),c.set("country",e||"");const{errors:i,json:l}=await t(`/api/zonos-elements/exchange-rates?${c.toString()}`);if(i.length||!l)return r(`Error fetching country landed cost: ${null===(s=i.find(Boolean))||void 0===s?void 0:s.message}`),w;const{rate:u,targetFormat:d}=l.exchangeRateCreate,y=l.maxAge;return u?(sessionStorage.setItem(e+"_rate",JSON.stringify(u)),{exchangeRate:{rate:u,targetFormat:d},maxAge:y}):w})({country:E.selectedCountryCode,isGuaranteed:e,sourceCurrency:n.sourceCurrency,targetCurrency:E.targetCurrency});return o&&(E.exchangeRate=o,x()),{maxAge:a}},D=e=>E.selectedCountryCode&&e.includes(E.selectedCountryCode)?E.selectedCountryCode:"CA",R=({isGuaranteed:e,maxAge:n})=>{E.exchangeRateTimeout&&clearTimeout(E.exchangeRateTimeout),E.exchangeRateTimeout=setTimeout((async()=>{const{maxAge:n}=await N(e);R({isGuaranteed:e,maxAge:n})}),1e3*(n||300))},k=e=>{var o,a;s(`Updating selected country code to ${e}`);const c=!E.selectedCountryCode;var i;E.selectedCountryCode="UK"===(i=e)?"GB":i;const{selectedCountryCode:l,shippingZoneCountries:u}=E,d=!(!u||!l||!u[l]||n.disabledCountries.includes(l));E.isShippableCountry=d,s(`${E.selectedCountryCode} is a shippable country: ${E.isShippableCountry}`);const y=!!l&&n.disabledCountries.includes(l);if(E.isDisabledCountry=y,s(`${E.selectedCountryCode} is a disabled country: ${E.isDisabledCountry}`),E.isShippableCountry?document.body.classList.add("z-intl"):document.body.classList.remove("z-intl"),!l)return;const m=(e=>{var n;const o=null===(n=E.shippingZoneCountries)||void 0===n?void 0:n[e];return o?o.currencyCode:null})(l);c||null===(o=n.onCountryChange)||void 0===o||o.call(n,{countryCode:l,currencyCode:m,isShippableCountry:d}),m&&(E.targetCurrency=m,(async()=>{var e;s("get new localization store");const{isDisabledCountry:o,isShippableCountry:a,selectedCountryCode:c}=E;if("DISABLED"===n.helloSettings.currencyBehavior||!a||o||!c)return;const i="ENABLED"===n.checkoutSettings.visibilityStatus;A();const{maxAge:l}=await N(i);R({isGuaranteed:i,maxAge:l}),window.Zonos.isLegacyCheckout?s("Skipping country landed cost and inclusive pricing requests, because this is a legacy checkout"):(E.countryLandedCost=await(async e=>{var n;if(!e)return null;const o=`/api/zonos-elements/country-landed-cost/${e}`,{errors:a,json:s}=await t(o);return a.length||!s?(r(`Error fetching country landed cost: ${null===(n=a.find(Boolean))||void 0===n?void 0:n.message}`),null):s||null})(E.selectedCountryCode),E.inclusivePricing=(null===(e=await(async e=>{var n;if(!e)return null;const{errors:o,json:a}=await t(`/api/zonos-elements/inclusive-prices/${e}`);return o.length||!a?(r(`Error fetching country inclusive price setting: ${null===(n=o.find(Boolean))||void 0===n?void 0:n.message}`),null):a||null})(c))||void 0===e?void 0:e.setting)||null,E.inclusivePricing&&s(`Inclusive price setting found for this country (${c}) ${JSON.stringify(E.inclusivePricing,null,2)}`))})(),window.sessionStorage.setItem("zonos--country",l),L(l),null===(a=document.querySelector("zonos-hello"))||void 0===a||a.setAttribute("z-country",l))},B=e=>{E.selectedLocale=e,c(e),(async()=>{if(!d.checkoutSessionId)return null;const{errors:e,json:n}=await t("/api/zonos-elements/update-checkout-session-metadata",{body:{id:d.checkoutSessionId,metadata:[{key:"language",value:E.selectedLocale}]},method:"POST"});(e.length||!n)&&r("Error occurs when updating checkout session",JSON.stringify(e,null,2))})(),(async()=>{if(s(`Getting custom messages for ${E.selectedCountryCode}`),!E.selectedCountryCode||!n.storeId)return;const e=(await(async({countryCode:e,localeTo:n,storeId:o})=>{var a;const s=new URLSearchParams;s.set("countryCode",e),s.set("storeId",o.toString()),n&&s.set("localeTo",n);const{errors:c,json:i}=await t(`/api/zonos-elements/locale-messages?${s.toString()}`);return c.length||!i?(r("Error fetching exchange rate",null===(a=c.find(Boolean))||void 0===a?void 0:a.message),[]):i.locale_countryCodesPage})({countryCode:E.selectedCountryCode,localeTo:E.selectedLocale,storeId:n.storeId})).flatMap((e=>{var n;return{countryCode:E.selectedCountryCode,message:null===(n=e.countryCodesPageMessageLinks.find(Boolean))||void 0===n?void 0:n.message.textTo,pageName:e.pageName}}));E.customMessages=e})()},F=async()=>{const[e,o,t]=await Promise.all([m(),p(),g()]),r=null==o?void 0:o.reduce(((n,o)=>{const t=null==e?void 0:e[o];return t?Object.assign(Object.assign({},n),{[o]:t}):n}),{});E.shippingZoneCountries=r||null,(e=>{const o=n.helloSettings.showCountryList,t=E.shippingZoneCountries;E.helloCountryList=o&&"ONLY_SHIPPABLE"!==o?"ALL"!==o?o.reduce(((n,o)=>{const t=null==e?void 0:e[o];return t?Object.assign(Object.assign({},n),{[o]:t}):n}),{}):e:t})(e||{});const{country:a,locale:c}=t;s(`Country code from localization: ${a}`),s(`Locale from localization: ${c}`),k(a);const i=new URL(window.location.href).searchParams.get("zonosLocale");B(i||c||"en"),!E.selectedCountryCode&&["dev.storybook.elements","dev.elements","dev.demo.elements","dev.dashboard"].some((e=>window.location.origin.includes(e)))&&k("CA"),E.localizationLoaded=!0};export{l as V,k as a,y as b,I as c,h as d,F as e,i as f,v as g,L as h,z as i,x as j,C as k,E as l,f as m,D as n,u as o,B as p,d as s}
@@ -1,4 +1,4 @@
1
- var __awaiter=this&&this.__awaiter||function(n,r,e,t){function o(n){return n instanceof e?n:new e((function(r){r(n)}))}return new(e||(e=Promise))((function(e,i){function a(n){try{c(t.next(n))}catch(n){i(n)}}function u(n){try{c(t["throw"](n))}catch(n){i(n)}}function c(n){n.done?e(n.value):o(n.value).then(a,u)}c((t=t.apply(n,r||[])).next())}))};var __generator=this&&this.__generator||function(n,r){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(n){return function(r){return c([n,r])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(e=0)),e)try{if(t=1,o&&(i=u[0]&2?o["return"]:u[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;if(o=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:e.label++;return{value:u[1],done:false};case 5:e.label++;o=u[1];u=[0];continue;case 7:u=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){e.label=u[1];break}if(u[0]===6&&e.label<i[1]){e.label=i[1];i=u;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(u);break}if(i[2])e.ops.pop();e.trys.pop();continue}u=r.call(n,e)}catch(n){u=[6,n];o=0}finally{t=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-89c5164b.system.js","./p-725605f6.system.js","./p-b5b3f908.system.js","./p-182da73f.system.js","./p-01174496.system.js","./p-24e26a2c.system.js","./p-d938f42f.system.js"],(function(n){"use strict";var r,e,t,o,i,a,u,c,s,l,d,f,v,p,y,w;return{setters:[function(n){r=n.z;e=n.c},function(n){t=n.t;o=n.z;i=n.c;a=n.e;u=n.v;c=n.r;s=n.j},function(n){l=n.s},function(n){d=n.t},function(n){f=n.h;v=n.l;p=n.j},function(n){y=n.t},function(n){w=n.l}],execute:function(){var h=this;
1
+ var __awaiter=this&&this.__awaiter||function(n,r,e,t){function o(n){return n instanceof e?n:new e((function(r){r(n)}))}return new(e||(e=Promise))((function(e,i){function a(n){try{c(t.next(n))}catch(n){i(n)}}function u(n){try{c(t["throw"](n))}catch(n){i(n)}}function c(n){n.done?e(n.value):o(n.value).then(a,u)}c((t=t.apply(n,r||[])).next())}))};var __generator=this&&this.__generator||function(n,r){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(n){return function(r){return c([n,r])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(e=0)),e)try{if(t=1,o&&(i=u[0]&2?o["return"]:u[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;if(o=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:e.label++;return{value:u[1],done:false};case 5:e.label++;o=u[1];u=[0];continue;case 7:u=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){e.label=u[1];break}if(u[0]===6&&e.label<i[1]){e.label=i[1];i=u;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(u);break}if(i[2])e.ops.pop();e.trys.pop();continue}u=r.call(n,e)}catch(n){u=[6,n];o=0}finally{t=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-89c5164b.system.js","./p-cdaf52f4.system.js","./p-cef1e888.system.js","./p-b4fe3604.system.js","./p-01174496.system.js","./p-24e26a2c.system.js","./p-d938f42f.system.js"],(function(n){"use strict";var r,e,t,o,i,a,u,c,s,l,d,f,v,p,y,w;return{setters:[function(n){r=n.z;e=n.c},function(n){t=n.t;o=n.A;i=n.c;a=n.e;u=n.v;c=n.r;s=n.j},function(n){l=n.s},function(n){d=n.t},function(n){f=n.h;v=n.l;p=n.j},function(n){y=n.t},function(n){w=n.l}],execute:function(){var h=this;
2
2
  /*!
3
3
  * paypal-js v8.1.0 (2024-06-07T16:55:00.122Z)
4
4
  * Copyright 2020-present, PayPal, Inc. All rights reserved.
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,n,t,r){function o(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,i){function a(e){try{d(r.next(e))}catch(e){i(e)}}function s(e){try{d(r["throw"](e))}catch(e){i(e)}}function d(e){e.done?t(e.value):o(e.value).then(a,s)}d((r=r.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return d([e,n])}}function d(s){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(r=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;o=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1];i=s;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(s);break}if(i[2])t.ops.pop();t.trys.pop();continue}s=n.call(e,t)}catch(e){s=[6,e];o=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,t){if(t||arguments.length===2)for(var r=0,o=n.length,i;r<o;r++){if(i||!(r in n)){if(!i)i=Array.prototype.slice.call(n,0,r);i[r]=n[r]}}return e.concat(i||Array.prototype.slice.call(n))};System.register(["./p-89c5164b.system.js","./p-b5b3f908.system.js","./p-182da73f.system.js","./p-01174496.system.js","./p-d938f42f.system.js","./p-24e26a2c.system.js","./p-433d76b4.system.js"],(function(e){"use strict";var n,t,r,o,i,a,s,d,u,l,c,v,f,m,p,h,w,g;return{setters:[function(e){n=e.z;t=e.c},function(e){r=e.s;o=e.l;i=e.f;a=e.b},function(e){s=e.t},function(e){d=e.f;u=e.h;l=e.g;c=e.a;v=e.s;f=e.l;m=e.j},function(e){p=e.l;h=e.b},function(e){w=e.i},function(e){g=e.g}],execute:function(){var y=this;var b=e("J",(function(e){var n=e.firstName,t=e.lastName,r=e.name;var o;if(!r&&!n&&!t){return{firstName:"",lastName:""}}var i=(r===null||r===void 0?void 0:r.split(/\s+/))||[];var a=(n===null||n===void 0?void 0:n.trim())||((o=i[0])===null||o===void 0?void 0:o.trim())||"";var s=(t===null||t===void 0?void 0:t.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}}));var _=function(e){var n=e.currentAddress,t=e.translatedAddress;var r,o,i,a,s,d;var u=n.value.address,l=u.city,c=u.country,v=u.line1,f=u.line2,m=u.postal_code,p=u.state;var h=n.value.name||[n.value.firstName,n.value.lastName].join(" ");return{city:((r=t.city)===null||r===void 0?void 0:r[l])||l,country:c,line1:((o=t.line1)===null||o===void 0?void 0:o[v])||v,line2:((i=t.line2)===null||i===void 0?void 0:i[f||""])||f||"",name:((a=t.name)===null||a===void 0?void 0:a[h])||h,phone:n.value.phone||"",postal_code:((s=t.postal_code)===null||s===void 0?void 0:s[m])||m,state:((d=t.state)===null||d===void 0?void 0:d[p])||p}};var S=function(e){var n;var t=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var o=F.stripeLinkEventData;var i=F.stripeAddressEventData;var a=F.stripeShippingSameAsBilling?F.stripeAddressEventData:F.stripeBillingAddressEventData;if(!i||!a){throw new Error("Missing stripe address data")}var s=_({currentAddress:i,translatedAddress:F.translatedAddress.address});var d=b({name:s.name}),u=d.firstName,l=d.lastName;var c=_({currentAddress:a,translatedAddress:F.translatedAddress.address});var v=b({name:c.name}),f=v.firstName,m=v.lastName;return{billingAddress:{addressLine1:c.line1,addressLine2:c.line2||"",city:c.city,country:c.country,postalCode:c.postal_code,state:c.state},billingContact:{firstName:f,lastName:m,phone:c.phone},cartCurrencyCode:(n=Se.items[0])===null||n===void 0?void 0:n.currencyCode,cartId:e,checkoutSessionId:r.checkoutSessionId||"",contact:{companyName:F.companyName,email:o===null||o===void 0?void 0:o.value.email,firstName:u,lastName:l,phone:s.phone},isTest:!!t,landedCostAdjustments:Se.promoCode?[{amount:0,productId:null,promoCode:Se.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToTaxId:F.taxId,shippingAddress:{addressLine1:s.line1,addressLine2:s.line2,city:s.city,country:s.country,postalCode:s.postal_code,state:s.state}}};var O=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var n=F.stripeLinkEventData;var t=F.stripeAddressEventData;var o=F.stripeShippingSameAsBilling?F.stripeAddressEventData:F.stripeBillingAddressEventData;p({stripeAddressData:t,stripeBillingAddressData:o},"info");if(!t||!o){throw new Error("Missing stripe address data")}var i=_({currentAddress:t,translatedAddress:F.translatedAddress.address});var a=b({name:i.name}),s=a.firstName,d=a.lastName;var u=_({currentAddress:o,translatedAddress:F.translatedAddress.address});var l=b({name:u.name}),c=l.firstName,v=l.lastName;var f=Se.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var m=Se.promoCode?__spreadArray([{amount:0,productId:null,promoCode:Se.promoCode,sku:null,type:"PROMO_CODE"}],f,true):f;return{billingAddress:{addressLine1:u.line1,addressLine2:u.line2||"",city:u.city,country:u.country,postalCode:u.postal_code,state:u.state},billingContact:{firstName:c,lastName:v,phone:u.phone},checkoutSessionId:r.checkoutSessionId||"",contact:{companyName:F.companyName,email:n===null||n===void 0?void 0:n.value.email,firstName:s,lastName:d,phone:i.phone},isTest:e,items:Se.items,landedCostAdjustments:m,shipToTaxId:F.taxId,shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}}};var C=function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,r,o,i,a,s,l,c,v;return __generator(this,(function(f){switch(f.label){case 0:a=O();return[4,e({billingAddress:a.billingAddress,billingContact:a.billingContact,checkoutSessionId:a.checkoutSessionId,contact:a.contact,landedCostAdjustments:a.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:a.shippingAddress,zonosApiRoute:d["vercel"]})];case 1:s=f.sent();if(!s||!((n=s.checkoutSessionWorkflow)===null||n===void 0?void 0:n.length)&&((t=s.errors)===null||t===void 0?void 0:t.length)){throw new Error("Failed to build landed cost: ".concat(((o=(r=s===null||s===void 0?void 0:s.errors)===null||r===void 0?void 0:r[0])===null||o===void 0?void 0:o.message)||"Unknown error"))}return[4,u("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:l=f.sent(),c=l.errors,v=l.json;if(!v||c.length){throw new Error("Invalid landed cost object: ".concat(((i=c.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2,s]}}))}))};var k=function(e){return __awaiter(y,void 0,void 0,(function(){var t,r,o,i,a,s,d;return __generator(this,(function(l){switch(l.label){case 0:r=n.checkoutSettings.buildLandedCost;if(!r)return[3,2];return[4,C(r)];case 1:o=l.sent();return[2,o];case 2:return[4,u("/api/zonos-elements/calculate-landed-cost",{body:O(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:i=l.sent(),a=i.errors,s=i.json;if(a.length||!s){d=((t=a[0])===null||t===void 0?void 0:t.message)==="The user aborted a request.";if(d){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}a.forEach((function(e){console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2,s]}return[2,s]}}))}))};var A=function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,r,o,i,a,s,d,l,c;var v=e.abortController,f=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4,u("/api/zonos-elements/cart-calculate-landed-cost",{body:S(f),method:"POST",signal:v===null||v===void 0?void 0:v.signal})];case 1:a=e.sent(),s=a.errors,d=a.json;if(s.length||!d){l=typeof((n=s[0])===null||n===void 0?void 0:n.message)==="string"&&(((t=s[0])===null||t===void 0?void 0:t.message)==="The user aborted a request."||((r=s[0])===null||r===void 0?void 0:r.message.includes("signal is aborted"))||((o=s[0])===null||o===void 0?void 0:o.message.includes("The operation was aborted"))||((i=s[0])===null||i===void 0?void 0:i.message.includes("Fetch is aborted")));c=l?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(c)}return[2,d]}}))}))};var I=undefined&&undefined.__rest||function(e,n){var t={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0)t[r]=e[r];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++){if(n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o]))t[r[o]]=e[r[o]]}return t};var T=function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,r,o,i;return __generator(this,(function(a){switch(a.label){case 0:n=window.Zonos.cartId;if(!!n)return[3,2];return[4,k(e)];case 1:t=a.sent();return[2,t];case 2:return[4,A({abortController:e,cartId:n})];case 3:r=a.sent(),o=r.cartWorkflow,i=I(r,["cartWorkflow"]);return[2,Object.assign(Object.assign({},i),{itemCreateWorkflow:o.items})]}}))}))};var E=e("t",(function(e){return __awaiter(y,[e],void 0,(function(e){var t,r,i,a,s,d,f,m,p;var w=e.checkoutSessionId,g=e.eventName,y=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:i=Date.now();a=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:w,eventCreated:i,eventName:g});s=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!((t=window.Zonos)===null||t===void 0?void 0:t.zonosQaUrl)||!!((r=window.Zonos)===null||r===void 0?void 0:r.debug);d=l()||c();if((d||s)&&!window.Zonos.zonosConversionTest){return[2]}f=o.selectedCountryCode;m=n.organizationId;if(!w){void v({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No checkout session id found')],metadata:{allLogs:h,checkoutSessionId:w,eventName:g,metadata:y,organizationId:m,trackEventLogs:a}});return[2]}if(!m){void v({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No organization id found')],metadata:{allLogs:h,checkoutSessionId:w,eventName:g,metadata:y,organizationId:m,trackEventLogs:a}})}p={checkoutSessionId:w,countryCode:f,eventCreated:i,eventName:g,metadata:Object.assign(Object.assign({},y),{trackEventLogs:a}),organizationId:m};return[4,u("/api/zonos-elements/track-conversion-event",{body:p,method:"POST"})];case 1:e.sent();return[2]}}))}))}));var N=function(e){var n=e.address,t=e.invalidAdddressList;if(!n){return}if(!t){return}var r={};if(t.city){r.city=n.city}if(t.line1){r.line1=n.line1}if(t.line2){r.line2=n.line2}if(t.postal_code){r.postal_code=n.postal_code}if(t.state){r.state=n.state}if(t.name){r.name=n.name}return Object.keys(r).length?r:undefined};var j=function(e){var n=e.addressInvalidCharactersList,t=e.billingAddressInvalidCharactersList,r=e.stripeAddressEventData,o=e.stripeBillingAddressEventData,i=e.stripeShippingSameAsBilling;var a=!!(r===null||r===void 0?void 0:r.complete);var s=i?a:!!(o===null||o===void 0?void 0:o.complete);if(!a||!s){return null}if(!n&&!t){return null}var d=r.value;var u=(o===null||o===void 0?void 0:o.value)||null;var l=b({firstName:d.firstName,lastName:d.lastName,name:d.name}),c=l.firstName,v=l.lastName;var f="".concat(c," ").concat(v);var m=b({firstName:u===null||u===void 0?void 0:u.firstName,lastName:u===null||u===void 0?void 0:u.lastName,name:(u===null||u===void 0?void 0:u.name)||""}),p=m.firstName,h=m.lastName;var w=p&&h?"".concat(p," ").concat(h):"";var g=d.address;var y=u===null||u===void 0?void 0:u.address;return{address:N({address:Object.assign(Object.assign({},g),{name:f}),invalidAdddressList:n}),billingAddress:!i?N({address:y?Object.assign(Object.assign({},y),{name:w}):null,invalidAdddressList:t}):undefined,destinationCountry:g.country}};var P=e("O",(function(e){var n=e.sort((function(e,n){return e.amount-n.amount}));return n}));var D=function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,o;return __generator(this,(function(i){switch(i.label){case 0:if(!r.checkoutSessionId){return[2,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",r.checkoutSessionId);return[4,u("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:n=i.sent(),t=n.errors,o=n.json;return[2,{errors:t,json:o}]}}))}))};var L=e("z",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,r;return __generator(this,(function(o){switch(o.label){case 0:return[4,D()];case 1:n=o.sent(),t=n.errors,r=n.json;if(t.length||!r){f("Failed to retrieve checkout session info before confirming payment ",t);void v({endpoint:"validateCheckoutSession",errors:t.map((function(e){return e.message})),metadata:{allLogs:h}});return[2,{errorMessage:s("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}if(!((e=r.checkoutSession.landedCost)===null||e===void 0?void 0:e.id)){f("Landed cost is not found in the checkout session before confirming payment.");void v({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:h}});return[2,{errorMessage:s('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:false}]}return[2,{errorMessage:"",valid:true}]}}))}))}));var x=function(e){var t=e.theme;var r={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:n.appearance.fontSizeInputValue?"".concat(n.appearance.fontSizeInputValue,"px"):undefined,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:n.appearance.fontSizeInputLabel?"".concat(n.appearance.fontSizeInputLabel,"px"):undefined},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};switch(t){case"DARK":{return Object.assign(Object.assign({},r),{".Action":Object.assign(Object.assign({},r[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},r[".PickerItem--new"]),{color:"white"})})}default:return r}};var R=function(e){var n=e.borderStyle,t=e.theme;switch(t){case"DARK":return{borderRadius:g({overrideBorderStyle:n}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:g({overrideBorderStyle:n}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var U=t((function(){return{checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:false,isFetchingLandedCost:false,isFetchingSession:false,partyBillingId:null,partyShippingId:null,shouldInventoryRefund:false,shouldRenderPayInUsdButton:false,skipPaymentIntent:new URLSearchParams(window.location.search).get("skipPaymentIntent")==="0"?false:true,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:true,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}})),z=U.onChange,B=U.reset,F=U.state;e({A:z,c:F});var J=function(e){var t=e.clientSecret,r=e.overrideBorderRadius,i=e.overridePrimaryColor,a=e.overrideSecondaryColor,s=e.overrideTheme,d=e.paypalEnabled;var u=i||n.appearance.colorPrimary;var l=a||n.appearance.colorSecondary;var c=u&&w(u)?"night":"flat";var v=s==="DARK"?"night":"flat";var f=d?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},x({theme:s||"LIGHT"})),theme:s?v:c,variables:Object.assign(Object.assign({},R({borderStyle:r,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:t||undefined,customerSessionClientSecret:F.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],f,true),locale:o.selectedLocale}};var M=e("a",(function(){window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")}));var q=e("b",(function(e){window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))}));var W=e("s",(function(){var e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return m(e)}));var Y=e("i",(function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,r,o,i;return __generator(this,(function(a){r=F.clientSecret;if(!F.stripe){p("Skip. Stripe is not initialized");return[2]}o=J({clientSecret:r,overrideBorderRadius:e===null||e===void 0?void 0:e.overrideBorderRadius,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideSecondaryColor:e===null||e===void 0?void 0:e.overrideSecondaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme,paypalEnabled:e===null||e===void 0?void 0:e.paypalEnabled});i=JSON.stringify(o)===JSON.stringify(F.stripeElementsOptions);if(!F.stripeElements||!F.stripeElementsForBillingAddress){F.stripeElementsForBillingAddress=(n=F.stripe)===null||n===void 0?void 0:n.elements(o);p("Stripe elements for billing address initialized");F.stripeElements=(t=F.stripe)===null||t===void 0?void 0:t.elements(o);F.stripeElementsOptions=o;p("Stripe elements initialized");return[2]}if(!i){F.stripeElements.update(o);F.stripeElementsForBillingAddress.update(o);F.stripeElementsOptions=o;void F.stripeElements.fetchUpdates()}p("Stripe elements updated");return[2]}))}))}));var H=e("y",(function(){sessionStorage.removeItem("zonos--client-secret");B();F.stripe=window.Zonos.stripe}));var K=function(){var e,n,t,r;var o=JSON.stringify((e=F.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=F.stripeAddressEventData)===null||n===void 0?void 0:n.value);var i=!F.stripeShippingSameAsBilling&&JSON.stringify((t=F.stripeBillingAddressEventData)===null||t===void 0?void 0:t.value)!==JSON.stringify((r=F.stripeBillingAddressUsedWhenValidatingAddress)===null||r===void 0?void 0:r.value);return o||i};var G=function(){var e,n,t,r,o,i;var a=JSON.stringify((e=F.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=F.stripeLinkEventData)===null||n===void 0?void 0:n.value);var s=JSON.stringify((t=F.stripeAddressUsedWhenAsyncAddressUpdate)===null||t===void 0?void 0:t.value)!==JSON.stringify((r=F.stripeAddressEventData)===null||r===void 0?void 0:r.value);var d=!F.stripeShippingSameAsBilling&&JSON.stringify((o=F.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||o===void 0?void 0:o.value)!==JSON.stringify((i=F.stripeBillingAddressEventData)===null||i===void 0?void 0:i.value);var u=F.taxIdUsedWhenAsyncAddressUpdate!==F.taxId;var l=F.companyNameUsedWhenAsyncAddressUpdate!==F.companyName;return a||s||d||u||l};var V=e("B",(function(e){var n=e.address,t=e.firstName,o=e.lastName,i=e.name,a=e.phone;var s=b({firstName:t,lastName:o,name:i}),d=s.firstName,u=s.lastName;if(!d||!u){void v({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,firstName:t,lastName:o,name:i}})}if(!a){void v({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,phone:a}})}return{city:n.city,country:n.country,firstName:d,lastName:u,line1:n.line1,line2:n.line2,phone:a||"",postal_code:n.postal_code,state:n.state}}));var Z=e("L",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,o,i,a,s,d,l,c,m,p;return __generator(this,(function(w){switch(w.label){case 0:if(!((e=F.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!F.stripeShippingSameAsBilling&&!((n=F.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete)||!F.stripeBillingAddressEventData){return[2,{partiesCreated:false}]}if(!Se.landedCostData){return[2,{partiesCreated:false}]}i=(t=Se.landedCostData.find(Boolean))===null||t===void 0?void 0:t.landedCost.rootId;if(!i){void v({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId}});return[2,{partiesCreated:false}]}a=G();if(!a){return[2,{partiesCreated:false}]}s=V({address:F.stripeAddressEventData.value.address,firstName:F.stripeAddressEventData.value.firstName,lastName:F.stripeAddressEventData.value.lastName,name:F.stripeAddressEventData.value.name,phone:F.stripeAddressEventData.value.phone});d=F.stripeShippingSameAsBilling?s:V({address:F.stripeBillingAddressEventData.value.address,firstName:F.stripeBillingAddressEventData.value.firstName,lastName:F.stripeBillingAddressEventData.value.lastName,name:F.stripeBillingAddressEventData.value.name,phone:F.stripeBillingAddressEventData.value.phone});l=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,u("/api/zonos-elements/create-parties",{body:{address:s,billingAddress:d,companyName:F.companyName,email:((o=F.stripeLinkEventData)===null||o===void 0?void 0:o.value.email)||"",isTest:l,rootId:i,taxId:F.taxId},method:"POST"})];case 1:c=w.sent(),m=c.errors,p=c.json;if(m.length||!p){f("Error occurs when creating parties",JSON.stringify(m,null,2));void v({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,errors:m,json:p}});return[2,{partiesCreated:false}]}F.companyNameUsedWhenAsyncAddressUpdate=F.companyName;F.stripeAddressUsedWhenAsyncAddressUpdate=F.stripeAddressEventData;F.stripeBillingAddressUsedWhenAsyncAddressUpdate=F.stripeBillingAddressEventData;F.taxIdUsedWhenAsyncAddressUpdate=F.taxId;F.partyBillingId=p.billToPartyId;F.partyShippingId=p.shipToPartyId;return[2,{partiesCreated:true}]}}))}))}));var Q=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var X=function(){var e,n;var t=JSON.stringify((e=F.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=F.stripeLinkEventData)===null||n===void 0?void 0:n.value);var r=F.stripeAddressEventData&&JSON.stringify(Q(F.stripeAddressEventData.value))!==JSON.stringify(F.stripeAddressUsedWhenFetchingLC);var o=!F.stripeShippingSameAsBilling&&F.stripeBillingAddressEventData&&JSON.stringify(Q(F.stripeBillingAddressEventData.value))!==JSON.stringify(F.stripeBillingAddressUsedWhenFetchingLC);return t||r||o};var $=function(){var e;var n=Se.landedCostData&&((e=Se.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==Se.subtotal;var t=X();p("isPrefetchInfoOutdated","info",{isAddressOutdated:t});return!Se.landedCostData&&!F.isFetchingLandedCost||t||n};var ee=function(e){var t,r;var o=(t=n.genericSettings)===null||t===void 0?void 0:t.countryFields;var i=(r=n.genericSettings)===null||r===void 0?void 0:r.stripeCountryFieldLabels;var a=i&&e in i?i[e]:null;var s=o&&e in o?o[e]:null;if(Se.addressFormRenderType==="stripe"){return a||s}return s};var ne=function(){var e,n,t,r;var o=!!((e=F.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((n=F.stripeAddressEventData)===null||n===void 0?void 0:n.complete);var a=F.stripeShippingSameAsBilling?i:!!((t=F.stripeBillingAddressEventData)===null||t===void 0?void 0:t.complete);var s=((r=F.stripeAddressEventData)===null||r===void 0?void 0:r.value.address.country)||"US";var d=ee(s);if(i&&a&&o){return true}if(!d||!F.stripeAddressEventData){return i&&a&&o}var u=F.stripeAddressEventData.value.address.line1.length>0;var l=F.stripeAddressEventData.value.firstName&&F.stripeAddressEventData.value.lastName;var c=!d.stateRequired||d.stateRequired&&F.stripeAddressEventData.value.address.state.length>0;var v=!d.zipRequired||d.zipRequired&&F.stripeAddressEventData.value.address.postal_code.length>=3;var f=F.stripeAddressEventData.value.phone&&F.stripeAddressEventData.value.phone.length>0;return o&&l&&u&&c&&v&&f};var te=function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,o,i,a,s,d,u,l,c;return __generator(this,(function(v){switch(v.label){case 0:n=new AbortController;F.fetchingLandedCostAbortController=n;ze();return[4,T(n)];case 1:t=v.sent(),o=t.checkoutSessionWorkflow,i=t.errors,a=t.itemCreateWorkflow,s=t.landedCostCalculateWorkflow,d=t.partyCreateWorkflow,u=t.shipmentRatingCalculateWorkflow;Se.customQuotingError=((e=i===null||i===void 0?void 0:i.find((function(e){var n;return((n=e.extensions)===null||n===void 0?void 0:n.ruleMessageType)==="CUSTOM"})))===null||e===void 0?void 0:e.message)||null;Se.shippingData=P((u===null||u===void 0?void 0:u.filter(Boolean))||[]);Ae(a);F.fetchingLandedCostAbortController=null;Se.partiesData=(d===null||d===void 0?void 0:d.filter(Boolean))||[];Se.landedCostData=(o===null||o===void 0?void 0:o.map((function(e){var n=s===null||s===void 0?void 0:s.find((function(n){return(n===null||n===void 0?void 0:n.id)===e.landedCostId}));if(!n){return null}return Object.assign(Object.assign({},e),{landedCost:n})})).filter(Boolean))||[];l=r.checkoutSessionId;if(o===null||o===void 0?void 0:o.length){void E({checkoutSessionId:l,eventName:"checkout_quoteReceived"})}c=Se.promoCodeApplied&&!Se.landedCostData.find((function(e){var n;return(n=e.landedCost.appliedAdjustments)===null||n===void 0?void 0:n.find((function(e){return e.type==="PROMO_CODE"}))}));Se.promoCodeError=c;if(!c){sessionStorage.setItem("zonos--promo-code",Se.promoCode)}return[2]}}))}))};var re=e("q",(function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,r,o,i,a,s,d,u,l,c,m,p,h;return __generator(this,(function(w){switch(w.label){case 0:i=(e===null||e===void 0?void 0:e.retries)||0;a=!!(e===null||e===void 0?void 0:e.applyingPromocode);s=$();d=ne();if(!d){return[2,{isRequestNotReady:true}]}if(s){(n=F.fetchingLandedCostAbortController)===null||n===void 0?void 0:n.abort();F.fetchingLandedCostAbortController=null}if(!s&&!a){return[2,{isRequestNotReady:false}]}if(i){F.isFetchingLandedCost=false;setTimeout((function(){F.isFetchingLandedCost=true}),300)}else{F.isFetchingLandedCost=true}if(F.stripeAddressEventData){F.stripeAddressUsedWhenFetchingLC={countryCode:F.stripeAddressEventData.value.address.country,postalCode:F.stripeAddressEventData.value.address.postal_code,state:F.stripeAddressEventData.value.address.state}}if(F.stripeBillingAddressEventData){F.stripeBillingAddressUsedWhenFetchingLC={countryCode:F.stripeBillingAddressEventData.value.address.country,postalCode:F.stripeBillingAddressEventData.value.address.postal_code,state:F.stripeBillingAddressEventData.value.address.state}}if(F.stripeLinkEventData){F.stripeLinkUsedWhenFetchingLC=Object.assign({},F.stripeLinkEventData)}w.label=1;case 1:w.trys.push([1,3,,7]);ze();return[4,te()];case 2:w.sent();u=(t=Se.shippingData)===null||t===void 0?void 0:t.find(Boolean);l=(r=Se.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCost.shipmentRating.id===(u===null||u===void 0?void 0:u.id)}));c=!!l?l.subtotals:null;if(c){Ee({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:c})}return[3,7];case 3:m=w.sent();Se.landedCostData=[];Se.shippingData=[];p=["The landed cost calculation request was aborted to initiate a new one."];if(!(m instanceof Error&&m.message&&!p.includes(m.message)))return[3,6];if(!(i<1))return[3,5];return[4,re(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:w.sent();return[2,{isRequestNotReady:false}];case 5:h=(o=F.stripeAddressEventData)===null||o===void 0?void 0:o.value;void v({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[m.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:h}});w.label=6;case 6:f(m);return[3,7];case 7:F.isFetchingLandedCost=false;return[2,{isRequestNotReady:false}]}}))}))}));var oe=e("E",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,r;return __generator(this,(function(o){switch(o.label){case 0:return[4,re({applyingPromocode:true})];case 1:o.sent();if(Se.step==="payment"){Je()}return[4,Z()];case 2:o.sent();t=(e=Se.shippingData)===null||e===void 0?void 0:e.find(Boolean);r=(n=Se.landedCostData)===null||n===void 0?void 0:n.find((function(e){return e.landedCost.id===(t===null||t===void 0?void 0:t.id)}));if(!t||!r){return[2]}return[4,Le({applySubtotalsOnly:false,landedCostId:r.landedCostId,selectedShippingOption:t})];case 3:o.sent();return[2]}}))}))}));var ie=e("G",(function(){Se.promoCode="";sessionStorage.removeItem("zonos--promo-code");Se.promoCodeError=false;Se.promoCodeApplied=false}));var ae=e("F",(function(){return __awaiter(y,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:if(Se.step==="payment"){Je()}ie();return[4,oe()];case 1:e.sent();return[2]}}))}))}));var se=e("H",(function(e){var n=[];var t=true;var r=window.Zonos.isCollect;switch(e){case"succeeded":{n=[s("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"",s("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")];if(r){n=[s("Thank you for submitting your payment. We appreciate your prompt attention."),"",s("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]}t=false;break}case"requires_capture":case"processing":{n=[s("Payment processing. We'll update you when payment is received.")];t=false;break}case"requires_payment_method":{n=[s("Payment failed. Please try another payment method.")];if(r){n=[s("Payment failed. Please reload the page and try another payment method.")]}break}case"requires_action":{t=false;n=[s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{n=[s("Something went wrong.")];break}}return{isError:t,messages:n}}));var de=e("v",(function(){return __awaiter(y,void 0,void 0,(function(){var e,t,r,o,i,a,d,l,c,l;return __generator(this,(function(m){switch(m.label){case 0:r=n.checkoutSettings.onInventoryCheck;o=!!((t=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||t===void 0?void 0:t.value);if(!(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o))return[3,2];return[4,u("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:i=m.sent(),a=i.errors,d=i.json;if(a.length||!d){f("Error occurs when handling inventory refund","warn",JSON.stringify(a));return[2,null]}if(!d.available||d.status===204){return[2,s("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(d.available||d.status===200){F.shouldInventoryRefund=true;return[2,null]}return[2,null];case 2:if(typeof r!=="function"){return[2,null]}m.label=3;case 3:m.trys.push([3,5,,6]);return[4,r({items:Se.items})];case 4:l=m.sent();return[2,l];case 5:c=m.sent();l=c instanceof Error?c.message:"Unknown error";void v({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(l)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:Se.items}});throw c;case 6:return[2]}}))}))}));var ue=e("x",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t;return __generator(this,(function(r){switch(r.label){case 0:t=!!((n=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||n===void 0?void 0:n.value);if(!window.Zonos.isLegacyCheckout||!window.Zonos.cartData||!t){return[2]}return[4,u("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:r.sent();return[2]}}))}))}));var le=e("d",(function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,r,o,i,a,d,u,l;var c=e.clientSecret,v=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(v){n=se(v),t=n.isError,r=n.messages;return[2,{error:t,messages:r}]}o=c||F.clientSecret;if(!F.stripe||!o){f("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[s("Something went wrong.")]}]}return[4,F.stripe.retrievePaymentIntent(o)];case 1:i=e.sent().paymentIntent;a=i===null||i===void 0?void 0:i.status;d=se(a),u=d.isError,l=d.messages;return[2,{error:u,messages:l,paymentIntentId:i===null||i===void 0?void 0:i.id,paymentMethod:i===null||i===void 0?void 0:i.payment_method,status:a}]}}))}))}));var ce=e("w",(function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,o,i,a,d,u,l,c,v,f,m;return __generator(this,(function(h){switch(h.label){case 0:o=!!((n=F.stripePaymentEventData)===null||n===void 0?void 0:n.complete);i=F.stripeElements;a=F.stripe;d=F.clientSecret;F.customErrorMessage=null;if(!((t=Se.selectedLandedCost)===null||t===void 0?void 0:t.landedCost.id)&&!(e===null||e===void 0?void 0:e.noLandedCostCheck)){throw new Error("Attempted to confirm the payment when no landed cost is found in store")}return[4,L()];case 1:u=h.sent();if(!u.valid){F.customErrorMessage=u.errorMessage;throw new Error(u.errorMessage)}l=r.checkoutSessionId;if(!(a&&i&&o&&d&&l))return[3,3];c=new URL(window.location.href);c.searchParams.set("payment_intent_client_secret",d);c.searchParams.set("zonosCheckoutSessionId",l);void E({checkoutSessionId:l,eventName:"checkout_paymentInfoCompleted"});return[4,a.confirmPayment({confirmParams:{return_url:c.toString()},elements:i,redirect:"if_required"})];case 2:v=h.sent(),f=v.error,m=v.paymentIntent;p("Payment intent confirmed","info",{error:f,paymentIntent:m});if((m===null||m===void 0?void 0:m.status)==="requires_action"){throw new Error(s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."))}if(f){if(f.type==="card_error"||f.type==="validation_error"){throw new Error(f.message)}if(f.type==="invalid_request_error"){if(f.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}if(m.status==="requires_payment_method"){throw new Error(s("Payment failed. Please try another payment method."))}h.label=3;case 3:return[2]}}))}))}));var ve=e("n",(function(){var e;var n=Se.items.reduce((function(e,n){return e+n.amount*n.quantity}),0);var t=r.enabledVariantTestKeys||[];var i={adjustmentsAmount:Se.adjustments.reduce((function(e,n){return e+n.amount}),0),cartId:window.Zonos.cartId,currency:((e=Se.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:Se.customerAuthenticationToken||undefined,isCollect:window.Zonos.isCollect,itemsAmount:n,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:o.selectedCountryCode,skipPaymentIntent:F.skipPaymentIntent,varianceTestInput:t};return i}));var fe=e("l",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:if(!r.checkoutSessionId){void v({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:h,cartId:window.Zonos.cartId}});Te({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});return[2]}return[4,u("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:r.checkoutSessionId},method:"POST"})];case 1:n=a.sent(),t=n.errors,o=n.json;i=(e=o===null||o===void 0?void 0:o.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(t.length||!i){f("Error occurs when getting payment intent",JSON.stringify(t,null,2));void v({endpoint:"Error creating payment intent",errors:t.map((function(e){return e.message})),metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,clientSecret:i}});Te({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});return[2]}je(o.checkoutSessionPaymentIntentCreate);return[2]}}))}))}));var me=e("k",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,r,i,a,s,d;return __generator(this,(function(l){switch(l.label){case 0:if(!o.targetCurrency){f("Failed to create checkout session - missing localizationStore.targetCurrency");return[2,false]}F.isFetchingSession=true;t=ve();p("Checkout session body","info",t);return[4,u("/api/zonos-elements/create-checkout-session",{body:t,method:"POST"})];case 1:r=l.sent(),i=r.errors,a=r.json;F.isFetchingSession=false;if(i.length||!a){s=(e=i.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;if(Array.isArray(s)&&s.some((function(e){return e.message==="Cart is expired."}))){throw new Error("Cart is expired.")}f("Error occurred when creating checkout session",JSON.stringify(i,null,2));return[2,false]}d=a.checkoutSessionCreate;je(d);Ee({method:((n=d.landedCost)===null||n===void 0?void 0:n.method)||"DDP",subtotals:d.subtotals});p("Exchange rate updated for cart items (checkout session create)","info",Se.exchangeRate);p("done-init-checkout-session");return[2,true]}}))}))}));var pe=e("u",(function(){return __awaiter(y,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(i){switch(i.label){case 0:e=r.checkoutSessionId;if(!e){f("Failed to update checkout session base currency");return[2,false]}if(n.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){p('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2,true]}return[4,u("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:F.checkoutSettlementCurrency},method:"POST"})];case 1:t=i.sent().json;o=t===null||t===void 0?void 0:t.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;if(!t||o!==F.checkoutSettlementCurrency){f("Failed to update checkout session base currency");return[2,false]}p('Updated checkout session to settlement currency "'.concat(o,'".'));return[2,true]}}))}))}));var he=function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,i,a;var s=e.adjustmentsAmount,d=e.cartId,l=e.currency,c=e.id,v=e.itemsAmount,m=e.landedCostId,p=e.presentmentCountryCode;return __generator(this,(function(e){switch(e.label){case 0:n=r.enabledVariantTestKeys||[];return[4,u("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:s,billToPartyId:F.partyBillingId,cartId:d,currency:l,customerAuthenticationToken:Se.customerAuthenticationToken||undefined,id:c,itemsAmount:v,landedCostId:m,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:p,shipToPartyId:F.partyShippingId,skipPaymentIntent:F.skipPaymentIntent,varianceTestInput:n},method:"POST"})];case 1:t=e.sent(),i=t.errors,a=t.json;if(i.length||!a){f("Error occurs when updating checkout session",JSON.stringify(i,null,2));return[2,{errors:i,json:a}]}return[2,{errors:[],json:a}]}}))}))};var we=function(e){var n,t,r,o,i,a;var s=e.currentAddress,d=e.translatedAddressResult;var u={};if(!d){return u}var l=d.city,c=d.line1,v=d.line2,f=d.name,m=d.postal_code,p=d.state;if(s.city&&l){u.city=(n={},n[s.city]=l,n)}if(s.line1&&c){u.line1=(t={},t[s.line1]=c,t)}if(s.line2&&v){u.line2=(r={},r[s.line2]=v,r)}if(s.postal_code&&m){u.postal_code=(o={},o[s.postal_code]=m,o)}if(s.state&&p){u.state=(i={},i[s.state]=p,i)}if(s.name&&f){u.name=(a={},a[s.name]=f,a)}return u};var ge=e("I",(function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,r,o,i,a,s,d,l,c,v;var m=e.addressInvalidCharactersList,p=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=j({addressInvalidCharactersList:m,billingAddressInvalidCharactersList:p,stripeAddressEventData:F.stripeAddressEventData,stripeBillingAddressEventData:F.stripeBillingAddressEventData,stripeShippingSameAsBilling:F.stripeShippingSameAsBilling});if(!i){F.translatedAddress={address:{},billingAddress:{}};return[2]}a=K();if(!a){return[2]}return[4,u("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),d=s.errors,l=s.json;if(d.length||!l){f("Error occurs when translating address to latin",JSON.stringify(d,null,2));F.translatedAddress={address:{},billingAddress:{}};return[2]}F.stripeAddressUsedWhenValidatingAddress=F.stripeAddressEventData;F.stripeBillingAddressUsedWhenValidatingAddress=F.stripeBillingAddressEventData;c=(n=F.stripeAddressEventData)===null||n===void 0?void 0:n.value.address;v=(t=F.stripeBillingAddressEventData)===null||t===void 0?void 0:t.value.address;F.translatedAddress={address:c?we({currentAddress:Object.assign(Object.assign({},c),{name:(r=F.stripeAddressEventData)===null||r===void 0?void 0:r.value.name}),translatedAddressResult:l.address||null}):{},billingAddress:!F.stripeShippingSameAsBilling?we({currentAddress:Object.assign(Object.assign({},v),{name:(o=F.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:l.billingAddress||null}):{}};return[2]}}))}))}));z("clientSecret",(function(e){if(e&&F.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var ye=t((function(){return{addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:false,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:false,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,isStagingMode:c(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:false,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:false,step:"customer-info",subtotal:0,tabItems:{"customer-info":{index:1,isDone:false,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:false,label:"Shipping",value:"shipping"},payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),be=ye.onChange,_e=ye.reset,Se=ye.state;e({K:be,e:Se});var Oe=function(e){switch(e){case"DAYS":return s("days");case"WEEKS":return s("weeks");case"BUSINESS_DAYS":default:return s("business days")}};var Ce=e("M",(function(e){var n;var t=(n=e.shippingProfile)===null||n===void 0?void 0:n.transitTime;if(!(t===null||t===void 0?void 0:t.min)||!(t===null||t===void 0?void 0:t.max)||!(t===null||t===void 0?void 0:t.type)){return null}return{maxTransit:t.max,minTransit:t.min,unit:Oe(t.type)}}));var ke=function(e){var n=e.item1,t=e.item2;if(!n||!t){return false}return t.sku&&n.sku&&n.sku===t.sku||t.description&&n.description&&n.description===t.description||n.name&&t.name&&n.name===t.name};var Ae=function(e){p("Checking item restrictions");var n=e.map((function(e){if(!e.restriction){return null}var n=e.restriction;var t=Se.items.find((function(n){return ke({item1:n,item2:e})}));return Object.assign(Object.assign({matchedItem:t},e),{restriction:n})})).filter(Boolean);Se.restrictedItems=n;Se.items=Se.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!n.find((function(n){return ke({item1:n,item2:e})}))})}));return{cartItems:Se.items,restrictedItems:n}};var Ie=e("g",(function(){r.checkoutSessionId=null;_e()}));var Te=e("o",(function(e){var n=e.messages,t=e.title;Ie();H();Se.step="error";Se.error={messages:n,title:t}}));var Ee=function(e){var n=e.dutiesTaxesFeesEstimate,t=e.method,r=e.subtotals;Se.exchangeRate=r.exchangeRate;Se.adjustmentTotal=r.adjustments;Se.dutiesTaxesFees=t==="DAP"?null:r.landedCostTotal;Se.subtotal=r.items;Se.total=r.total;Se.currency=r.presentmentCurrencyCode;Se.dutiesTaxesFeesEstimate=n||null};var Ne=e("D",(function(){var e=Se.items.filter((function(e){return e.amount>0}));return!!e.find((function(e){return!e.isRestricted}))}));var je=e("p",(function(e){var n,t,o,s,d;F.clientSecret=e.clientSecret;F.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;F.customerProfile=e.customerProfile;Se.checkoutSession=e;if(!e.id){void v({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:h,checkoutSession:e}})}if(e.id){r.checkoutSessionId=e.id}var u=i(e.varianceTestResults||[]);a(u);var l=((o=(t=(n=Se.checkoutSession)===null||n===void 0?void 0:n.metadata)===null||t===void 0?void 0:t.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||o===void 0?void 0:o.value)||((d=(s=window.Zonos.cartData)===null||s===void 0?void 0:s.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||d===void 0?void 0:d.value)||null;if(l){p("Found externalConfirmationPageURL: ".concat(l));Se.externalConfirmationPageURL=l}}));var Pe=function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,i,a,d,u;var l=e.adjustmentsAmount,c=e.cartId,v=e.currency,m=e.dutiesTaxesFeesEstimate,h=e.itemsAmount,w=e.landedCostId,g=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(w&&Se.selectedLandedCost){t=Se.selectedLandedCost.subtotals;Ee({dutiesTaxesFeesEstimate:m,method:Se.landedCostMethod,subtotals:t});p("Exchange rate updated for cart items (landed cost subtotal)","info",Se.exchangeRate)}if(!r.checkoutSessionId){p("Could not update cart total without checkout session id","info");return[2,false]}return[4,he({adjustmentsAmount:l,billToPartyId:F.partyBillingId,cartId:c,currency:v,id:r.checkoutSessionId,itemsAmount:h,landedCostId:w,presentmentCountryCode:o.selectedCountryCode,shipToPartyId:F.partyShippingId,varianceTestInput:r.enabledVariantTestKeys||[]})];case 1:i=e.sent(),a=i.errors,d=i.json;if(!(a.length>0||!d))return[3,4];f("Error occurs when updating checkout session.");if(!g)return[3,3];p("Initiating checkout session on failure","info");return[4,me()];case 2:u=e.sent();p("stripeStoreInitCheckoutSession: ".concat(u));if(!u){Te({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});return[2,false]}return[2,true];case 3:return[2,false];case 4:if(!w){Ee({method:((n=d.checkoutSessionUpdate.landedCost)===null||n===void 0?void 0:n.method)||"DDP",subtotals:d.checkoutSessionUpdate.subtotals});p("Exchange rate updated for cart items (checkout session update)","info",Se.exchangeRate)}je(d.checkoutSessionUpdate);return[2,true]}}))}))};var De=e("N",(function(e){var t,r,o;if(e.method==="DAP"&&((r=(t=n.genericSettings)===null||t===void 0?void 0:t.domesticCountries)===null||r===void 0?void 0:r.includes(((o=F.stripeAddressEventData)===null||o===void 0?void 0:o.value.address.country)||"US"))){return"DDP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var Le=e("C",(function(e){return __awaiter(y,[e],void 0,(function(e){var t,o,i,a,s,d,u,l,c,v,f,m,h,w,g,y,b,_,S,O,C,k,A,I,T;var E=e.applySubtotalsOnly,N=e.landedCostId,j=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:p("Updating selected shipping option","info",{landedCostId:N,selectedShippingOption:j});Se.selectedShippingOption=j;m=Ce(Se.selectedShippingOption);if(m){h=m.maxTransit,w=m.minTransit,g=m.unit;Se.selectedShippingOptionTransitTime="".concat(w,"-").concat(h," ").concat(g)}else{Se.selectedShippingOptionTransitTime=""}y=(t=Se.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCostId===N}));Se.selectedLandedCost=y||null;if(!y){return[2,false]}b=((o=y.landedCost.amountSubtotals)===null||o===void 0?void 0:o.landedCostTotal)||0;_=y.subtotals.exchangeRate.rate;S=b*_;if(S){p("DAP quote, using estimate: ".concat(S),"info")}Se.landedCostMethod=De(y.landedCost);Se.shipping=y.subtotals.shipping;O=((i=y===null||y===void 0?void 0:y.landedCost)===null||i===void 0?void 0:i.landedCostGuaranteeCode)==="ZONOS";C=!!((s=(a=y===null||y===void 0?void 0:y.landedCost)===null||a===void 0?void 0:a.deMinimis)===null||s===void 0?void 0:s.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));Se.isSelectedShippingAboveDeminimis=C;Se.isSelectedShippingGuarantee=O;k=false;if(!E)return[3,1];A=y.subtotals;Ee({dutiesTaxesFeesEstimate:S,method:Se.landedCostMethod,subtotals:A});p("Exchange rate updated for cart items (landed cost subtotal)","info",Se.exchangeRate);k=true;return[3,3];case 1:return[4,Pe({adjustmentsAmount:Se.adjustmentTotal,billToPartyId:F.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:S,landedCostId:(d=y.landedCost)===null||d===void 0?void 0:d.id,shipToPartyId:F.partyShippingId,varianceTestInput:r.enabledVariantTestKeys||[]})];case 2:k=e.sent();e.label=3;case 3:I=(u=Se.items.find(Boolean))===null||u===void 0?void 0:u.currencyCode;T=((l=F.stripeAddressEventData)===null||l===void 0?void 0:l.value.address.country)||"US";F.shouldRenderPayInUsdButton=I==="USD"&&n.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((c=Se.checkoutSession)===null||c===void 0?void 0:c.subtotals.presentmentCurrencyCode)!=="USD"&&!!((f=(v=n.genericSettings)===null||v===void 0?void 0:v.usdSettlementCountryEnabled)===null||f===void 0?void 0:f.includes(T));return[2,k]}}))}))}));var xe=e("m",(function(e){var n=e.isPreview,t=e.sessionTimeout;if(n){return}var r=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var o=r&&!isNaN(parseInt(r,10))?parseInt(r,10):t;p("==START CHECKOUT TIMEOUT - ".concat(o,"=="));Se.checkoutTimeoutInterval=setTimeout((function(){Se.checkoutSessionTimeoutShow=true}),o)}));var Re=e("j",(function(){if(Se.checkoutTimeoutInterval){clearTimeout(Se.checkoutTimeoutInterval);Se.checkoutTimeoutInterval=null}}));var Ue=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var ze=function(){Se.items=Se.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));Se.restrictedItems=[]};var Be=e("f",(function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,o,i;var a=e.adjustments,s=e.cartItems,d=e.landedCostId,u=e.shouldInitSessionOnFailure,l=u===void 0?true:u;return __generator(this,(function(e){switch(e.label){case 0:Se.adjustments=a;Se.items=Ue(s);t=(n=s.find(Boolean))===null||n===void 0?void 0:n.currencyCode;o=s.reduce((function(e,n){return e+n.amount*n.quantity}),0);i=a.reduce((function(e,n){return e+n.amount}),0);if(!t||!o){return[2]}Se.currency=t;F.isFetchingSession=true;return[4,Pe({adjustmentsAmount:i,billToPartyId:F.partyBillingId,cartId:window.Zonos.cartId,currency:t,dutiesTaxesFeesEstimate:0,itemsAmount:o,landedCostId:d,shipToPartyId:F.partyShippingId,shouldInitSessionOnFailure:l,varianceTestInput:r.enabledVariantTestKeys||[]})];case 1:e.sent();F.isFetchingSession=false;return[2]}}))}))}));var Fe=function(){Se.selectedShippingOption=null;Se.isSelectedShippingAboveDeminimis=false;Se.isSelectedShippingGuarantee=false;Se.selectedShippingOptionTransitTime="";Se.dutiesTaxesFees=0;Se.dutiesTaxesFeesEstimate=0;Se.shipping=0;Se.total=Se.subtotal};var Je=function(){if(Se.step==="shipping"){Se.step="customer-info";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{"customer-info":Object.assign(Object.assign({},Se.tabItems.shipping),{isDone:false})})}else if(Se.step==="payment"){Se.step="shipping";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{shipping:Object.assign(Object.assign({},Se.tabItems.shipping),{isDone:false})})}else if(Se.step==="finish"){Se.step="payment";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{payment:Object.assign(Object.assign({},Se.tabItems.payment),{isDone:false})})}};var Me=e("r",(function(){if(Se.step==="customer-info"){Se.step="shipping";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{"customer-info":Object.assign(Object.assign({},Se.tabItems["customer-info"]),{isDone:true})})}else if(Se.step==="shipping"){Se.step="payment";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{shipping:Object.assign(Object.assign({},Se.tabItems.shipping),{isDone:true})})}else if(Se.step==="payment"){Se.step="finish"}}));var qe=e("h",(function(){Se.step="customer-info";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{"customer-info":Object.assign(Object.assign({},Se.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},Se.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},Se.tabItems.shipping),{isDone:false})});Fe()}))}}}));
1
+ var __awaiter=this&&this.__awaiter||function(e,n,t,r){function o(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,i){function a(e){try{d(r.next(e))}catch(e){i(e)}}function s(e){try{d(r["throw"](e))}catch(e){i(e)}}function d(e){e.done?t(e.value):o(e.value).then(a,s)}d((r=r.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return d([e,n])}}function d(s){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(r=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;o=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1];i=s;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(s);break}if(i[2])t.ops.pop();t.trys.pop();continue}s=n.call(e,t)}catch(e){s=[6,e];o=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,t){if(t||arguments.length===2)for(var r=0,o=n.length,i;r<o;r++){if(i||!(r in n)){if(!i)i=Array.prototype.slice.call(n,0,r);i[r]=n[r]}}return e.concat(i||Array.prototype.slice.call(n))};System.register(["./p-89c5164b.system.js","./p-cef1e888.system.js","./p-b4fe3604.system.js","./p-01174496.system.js","./p-d938f42f.system.js","./p-24e26a2c.system.js","./p-433d76b4.system.js"],(function(e){"use strict";var n,t,r,o,i,a,s,d,u,l,c,v,f,m,p,h,w,g;return{setters:[function(e){n=e.z;t=e.c},function(e){r=e.s;o=e.l;i=e.f;a=e.b},function(e){s=e.t},function(e){d=e.f;u=e.h;l=e.g;c=e.a;v=e.s;f=e.l;m=e.j},function(e){p=e.l;h=e.b},function(e){w=e.i},function(e){g=e.g}],execute:function(){var y=this;var b=e("K",(function(e){var n=e.firstName,t=e.lastName,r=e.name;var o;if(!r&&!n&&!t){return{firstName:"",lastName:""}}var i=(r===null||r===void 0?void 0:r.split(/\s+/))||[];var a=(n===null||n===void 0?void 0:n.trim())||((o=i[0])===null||o===void 0?void 0:o.trim())||"";var s=(t===null||t===void 0?void 0:t.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}}));var _=function(e){var n=e.currentAddress,t=e.translatedAddress;var r,o,i,a,s,d;var u=n.value.address,l=u.city,c=u.country,v=u.line1,f=u.line2,m=u.postal_code,p=u.state;var h=n.value.name||[n.value.firstName,n.value.lastName].join(" ");return{city:((r=t.city)===null||r===void 0?void 0:r[l])||l,country:c,line1:((o=t.line1)===null||o===void 0?void 0:o[v])||v,line2:((i=t.line2)===null||i===void 0?void 0:i[f||""])||f||"",name:((a=t.name)===null||a===void 0?void 0:a[h])||h,phone:n.value.phone||"",postal_code:((s=t.postal_code)===null||s===void 0?void 0:s[m])||m,state:((d=t.state)===null||d===void 0?void 0:d[p])||p}};var S=function(e){var n;var t=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var o=F.stripeLinkEventData;var i=F.stripeAddressEventData;var a=F.stripeShippingSameAsBilling?F.stripeAddressEventData:F.stripeBillingAddressEventData;if(!i||!a){throw new Error("Missing stripe address data")}var s=_({currentAddress:i,translatedAddress:F.translatedAddress.address});var d=b({name:s.name}),u=d.firstName,l=d.lastName;var c=_({currentAddress:a,translatedAddress:F.translatedAddress.address});var v=b({name:c.name}),f=v.firstName,m=v.lastName;return{billingAddress:{addressLine1:c.line1,addressLine2:c.line2||"",city:c.city,country:c.country,postalCode:c.postal_code,state:c.state},billingContact:{firstName:f,lastName:m,phone:c.phone},cartCurrencyCode:(n=Se.items[0])===null||n===void 0?void 0:n.currencyCode,cartId:e,checkoutSessionId:r.checkoutSessionId||"",contact:{companyName:F.companyName,email:o===null||o===void 0?void 0:o.value.email,firstName:u,lastName:l,phone:s.phone},isTest:!!t,landedCostAdjustments:Se.promoCode?[{amount:0,productId:null,promoCode:Se.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToTaxId:F.taxId,shippingAddress:{addressLine1:s.line1,addressLine2:s.line2,city:s.city,country:s.country,postalCode:s.postal_code,state:s.state}}};var O=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var n=F.stripeLinkEventData;var t=F.stripeAddressEventData;var o=F.stripeShippingSameAsBilling?F.stripeAddressEventData:F.stripeBillingAddressEventData;p({stripeAddressData:t,stripeBillingAddressData:o},"info");if(!t||!o){throw new Error("Missing stripe address data")}var i=_({currentAddress:t,translatedAddress:F.translatedAddress.address});var a=b({name:i.name}),s=a.firstName,d=a.lastName;var u=_({currentAddress:o,translatedAddress:F.translatedAddress.address});var l=b({name:u.name}),c=l.firstName,v=l.lastName;var f=Se.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var m=Se.promoCode?__spreadArray([{amount:0,productId:null,promoCode:Se.promoCode,sku:null,type:"PROMO_CODE"}],f,true):f;return{billingAddress:{addressLine1:u.line1,addressLine2:u.line2||"",city:u.city,country:u.country,postalCode:u.postal_code,state:u.state},billingContact:{firstName:c,lastName:v,phone:u.phone},checkoutSessionId:r.checkoutSessionId||"",contact:{companyName:F.companyName,email:n===null||n===void 0?void 0:n.value.email,firstName:s,lastName:d,phone:i.phone},isTest:e,items:Se.items,landedCostAdjustments:m,shipToTaxId:F.taxId,shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}}};var C=function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,r,o,i,a,s,l,c,v;return __generator(this,(function(f){switch(f.label){case 0:a=O();return[4,e({billingAddress:a.billingAddress,billingContact:a.billingContact,checkoutSessionId:a.checkoutSessionId,contact:a.contact,landedCostAdjustments:a.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:a.shippingAddress,zonosApiRoute:d["vercel"]})];case 1:s=f.sent();if(!s||!((n=s.checkoutSessionWorkflow)===null||n===void 0?void 0:n.length)&&((t=s.errors)===null||t===void 0?void 0:t.length)){throw new Error("Failed to build landed cost: ".concat(((o=(r=s===null||s===void 0?void 0:s.errors)===null||r===void 0?void 0:r[0])===null||o===void 0?void 0:o.message)||"Unknown error"))}return[4,u("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:l=f.sent(),c=l.errors,v=l.json;if(!v||c.length){throw new Error("Invalid landed cost object: ".concat(((i=c.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2,s]}}))}))};var k=function(e){return __awaiter(y,void 0,void 0,(function(){var t,r,o,i,a,s,d;return __generator(this,(function(l){switch(l.label){case 0:r=n.checkoutSettings.buildLandedCost;if(!r)return[3,2];return[4,C(r)];case 1:o=l.sent();return[2,o];case 2:return[4,u("/api/zonos-elements/calculate-landed-cost",{body:O(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:i=l.sent(),a=i.errors,s=i.json;if(a.length||!s){d=((t=a[0])===null||t===void 0?void 0:t.message)==="The user aborted a request.";if(d){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}a.forEach((function(e){console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2,s]}return[2,s]}}))}))};var A=function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,r,o,i,a,s,d,l,c;var v=e.abortController,f=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4,u("/api/zonos-elements/cart-calculate-landed-cost",{body:S(f),method:"POST",signal:v===null||v===void 0?void 0:v.signal})];case 1:a=e.sent(),s=a.errors,d=a.json;if(s.length||!d){l=typeof((n=s[0])===null||n===void 0?void 0:n.message)==="string"&&(((t=s[0])===null||t===void 0?void 0:t.message)==="The user aborted a request."||((r=s[0])===null||r===void 0?void 0:r.message.includes("signal is aborted"))||((o=s[0])===null||o===void 0?void 0:o.message.includes("The operation was aborted"))||((i=s[0])===null||i===void 0?void 0:i.message.includes("Fetch is aborted")));c=l?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(c)}return[2,d]}}))}))};var I=undefined&&undefined.__rest||function(e,n){var t={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0)t[r]=e[r];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++){if(n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o]))t[r[o]]=e[r[o]]}return t};var T=function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,r,o,i;return __generator(this,(function(a){switch(a.label){case 0:n=window.Zonos.cartId;if(!!n)return[3,2];return[4,k(e)];case 1:t=a.sent();return[2,t];case 2:return[4,A({abortController:e,cartId:n})];case 3:r=a.sent(),o=r.cartWorkflow,i=I(r,["cartWorkflow"]);return[2,Object.assign(Object.assign({},i),{itemCreateWorkflow:o.items})]}}))}))};var E=e("t",(function(e){return __awaiter(y,[e],void 0,(function(e){var t,r,i,a,s,d,f,m,p;var w=e.checkoutSessionId,g=e.eventName,y=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:i=Date.now();a=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:w,eventCreated:i,eventName:g});s=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!((t=window.Zonos)===null||t===void 0?void 0:t.zonosQaUrl)||!!((r=window.Zonos)===null||r===void 0?void 0:r.debug);d=l()||c();if((d||s)&&!window.Zonos.zonosConversionTest){return[2]}f=o.selectedCountryCode;m=n.organizationId;if(!w){void v({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No checkout session id found')],metadata:{allLogs:h,checkoutSessionId:w,eventName:g,metadata:y,organizationId:m,trackEventLogs:a}});return[2]}if(!m){void v({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No organization id found')],metadata:{allLogs:h,checkoutSessionId:w,eventName:g,metadata:y,organizationId:m,trackEventLogs:a}})}p={checkoutSessionId:w,countryCode:f,eventCreated:i,eventName:g,metadata:Object.assign(Object.assign({},y),{trackEventLogs:a}),organizationId:m};return[4,u("/api/zonos-elements/track-conversion-event",{body:p,method:"POST"})];case 1:e.sent();return[2]}}))}))}));var N=function(e){var n=e.address,t=e.invalidAdddressList;if(!n){return}if(!t){return}var r={};if(t.city){r.city=n.city}if(t.line1){r.line1=n.line1}if(t.line2){r.line2=n.line2}if(t.postal_code){r.postal_code=n.postal_code}if(t.state){r.state=n.state}if(t.name){r.name=n.name}return Object.keys(r).length?r:undefined};var j=function(e){var n=e.addressInvalidCharactersList,t=e.billingAddressInvalidCharactersList,r=e.stripeAddressEventData,o=e.stripeBillingAddressEventData,i=e.stripeShippingSameAsBilling;var a=!!(r===null||r===void 0?void 0:r.complete);var s=i?a:!!(o===null||o===void 0?void 0:o.complete);if(!a||!s){return null}if(!n&&!t){return null}var d=r.value;var u=(o===null||o===void 0?void 0:o.value)||null;var l=b({firstName:d.firstName,lastName:d.lastName,name:d.name}),c=l.firstName,v=l.lastName;var f="".concat(c," ").concat(v);var m=b({firstName:u===null||u===void 0?void 0:u.firstName,lastName:u===null||u===void 0?void 0:u.lastName,name:(u===null||u===void 0?void 0:u.name)||""}),p=m.firstName,h=m.lastName;var w=p&&h?"".concat(p," ").concat(h):"";var g=d.address;var y=u===null||u===void 0?void 0:u.address;return{address:N({address:Object.assign(Object.assign({},g),{name:f}),invalidAdddressList:n}),billingAddress:!i?N({address:y?Object.assign(Object.assign({},y),{name:w}):null,invalidAdddressList:t}):undefined,destinationCountry:g.country}};var P=e("O",(function(e){var n=e.sort((function(e,n){return e.amount-n.amount}));return n}));var D=function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,o;return __generator(this,(function(i){switch(i.label){case 0:if(!r.checkoutSessionId){return[2,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",r.checkoutSessionId);return[4,u("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:n=i.sent(),t=n.errors,o=n.json;return[2,{errors:t,json:o}]}}))}))};var L=e("A",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,r;return __generator(this,(function(o){switch(o.label){case 0:return[4,D()];case 1:n=o.sent(),t=n.errors,r=n.json;if(t.length||!r){f("Failed to retrieve checkout session info before confirming payment ",t);void v({endpoint:"validateCheckoutSession",errors:t.map((function(e){return e.message})),metadata:{allLogs:h}});return[2,{errorMessage:s("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}if(!((e=r.checkoutSession.landedCost)===null||e===void 0?void 0:e.id)){f("Landed cost is not found in the checkout session before confirming payment.");void v({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:h}});return[2,{errorMessage:s('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:false}]}return[2,{errorMessage:"",valid:true}]}}))}))}));var x=function(e){var t=e.theme;var r={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:n.appearance.fontSizeInputValue?"".concat(n.appearance.fontSizeInputValue,"px"):undefined,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:n.appearance.fontSizeInputLabel?"".concat(n.appearance.fontSizeInputLabel,"px"):undefined},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};switch(t){case"DARK":{return Object.assign(Object.assign({},r),{".Action":Object.assign(Object.assign({},r[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},r[".PickerItem--new"]),{color:"white"})})}default:return r}};var R=function(e){var n=e.borderStyle,t=e.theme;switch(t){case"DARK":return{borderRadius:g({overrideBorderStyle:n}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:g({overrideBorderStyle:n}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var U=t((function(){return{checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:false,isFetchingLandedCost:false,isFetchingSession:false,partyBillingId:null,partyShippingId:null,shouldInventoryRefund:false,shouldRenderPayInUsdButton:false,skipPaymentIntent:new URLSearchParams(window.location.search).get("skipPaymentIntent")==="0"?false:true,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:true,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}})),z=U.onChange,B=U.reset,F=U.state;e({B:z,c:F});var J=function(e){var t=e.clientSecret,r=e.overrideBorderRadius,i=e.overridePrimaryColor,a=e.overrideSecondaryColor,s=e.overrideTheme,d=e.paypalEnabled;var u=i||n.appearance.colorPrimary;var l=a||n.appearance.colorSecondary;var c=u&&w(u)?"night":"flat";var v=s==="DARK"?"night":"flat";var f=d?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},x({theme:s||"LIGHT"})),theme:s?v:c,variables:Object.assign(Object.assign({},R({borderStyle:r,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:t||undefined,customerSessionClientSecret:F.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],f,true),locale:o.selectedLocale}};var M=e("a",(function(){window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")}));var q=e("b",(function(e){window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))}));var W=e("s",(function(){var e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return m(e)}));var Y=e("i",(function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,r,o,i;return __generator(this,(function(a){r=F.clientSecret;if(!F.stripe){p("Skip. Stripe is not initialized");return[2]}o=J({clientSecret:r,overrideBorderRadius:e===null||e===void 0?void 0:e.overrideBorderRadius,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideSecondaryColor:e===null||e===void 0?void 0:e.overrideSecondaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme,paypalEnabled:e===null||e===void 0?void 0:e.paypalEnabled});i=JSON.stringify(o)===JSON.stringify(F.stripeElementsOptions);if(!F.stripeElements||!F.stripeElementsForBillingAddress){F.stripeElementsForBillingAddress=(n=F.stripe)===null||n===void 0?void 0:n.elements(o);p("Stripe elements for billing address initialized");F.stripeElements=(t=F.stripe)===null||t===void 0?void 0:t.elements(o);F.stripeElementsOptions=o;p("Stripe elements initialized");return[2]}if(!i){F.stripeElements.update(o);F.stripeElementsForBillingAddress.update(o);F.stripeElementsOptions=o;void F.stripeElements.fetchUpdates()}p("Stripe elements updated");return[2]}))}))}));var H=e("y",(function(){sessionStorage.removeItem("zonos--client-secret");B();F.stripe=window.Zonos.stripe}));var K=function(){var e,n,t,r;var o=JSON.stringify((e=F.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=F.stripeAddressEventData)===null||n===void 0?void 0:n.value);var i=!F.stripeShippingSameAsBilling&&JSON.stringify((t=F.stripeBillingAddressEventData)===null||t===void 0?void 0:t.value)!==JSON.stringify((r=F.stripeBillingAddressUsedWhenValidatingAddress)===null||r===void 0?void 0:r.value);return o||i};var G=function(){var e,n,t,r,o,i;var a=JSON.stringify((e=F.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=F.stripeLinkEventData)===null||n===void 0?void 0:n.value);var s=JSON.stringify((t=F.stripeAddressUsedWhenAsyncAddressUpdate)===null||t===void 0?void 0:t.value)!==JSON.stringify((r=F.stripeAddressEventData)===null||r===void 0?void 0:r.value);var d=!F.stripeShippingSameAsBilling&&JSON.stringify((o=F.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||o===void 0?void 0:o.value)!==JSON.stringify((i=F.stripeBillingAddressEventData)===null||i===void 0?void 0:i.value);var u=F.taxIdUsedWhenAsyncAddressUpdate!==F.taxId;var l=F.companyNameUsedWhenAsyncAddressUpdate!==F.companyName;return a||s||d||u||l};var V=e("C",(function(e){var n=e.address,t=e.firstName,o=e.lastName,i=e.name,a=e.phone;var s=b({firstName:t,lastName:o,name:i}),d=s.firstName,u=s.lastName;if(!d||!u){void v({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,firstName:t,lastName:o,name:i}})}if(!a){void v({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,phone:a}})}return{city:n.city,country:n.country,firstName:d,lastName:u,line1:n.line1,line2:n.line2,phone:a||"",postal_code:n.postal_code,state:n.state}}));var Z=e("L",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,o,i,a,s,d,l,c,m,p;return __generator(this,(function(w){switch(w.label){case 0:if(!((e=F.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!F.stripeShippingSameAsBilling&&!((n=F.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete)||!F.stripeBillingAddressEventData){return[2,{partiesCreated:false}]}if(!Se.landedCostData){return[2,{partiesCreated:false}]}i=(t=Se.landedCostData.find(Boolean))===null||t===void 0?void 0:t.landedCost.rootId;if(!i){void v({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId}});return[2,{partiesCreated:false}]}a=G();if(!a){return[2,{partiesCreated:false}]}s=V({address:F.stripeAddressEventData.value.address,firstName:F.stripeAddressEventData.value.firstName,lastName:F.stripeAddressEventData.value.lastName,name:F.stripeAddressEventData.value.name,phone:F.stripeAddressEventData.value.phone});d=F.stripeShippingSameAsBilling?s:V({address:F.stripeBillingAddressEventData.value.address,firstName:F.stripeBillingAddressEventData.value.firstName,lastName:F.stripeBillingAddressEventData.value.lastName,name:F.stripeBillingAddressEventData.value.name,phone:F.stripeBillingAddressEventData.value.phone});l=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,u("/api/zonos-elements/create-parties",{body:{address:s,billingAddress:d,companyName:F.companyName,email:((o=F.stripeLinkEventData)===null||o===void 0?void 0:o.value.email)||"",isTest:l,rootId:i,taxId:F.taxId},method:"POST"})];case 1:c=w.sent(),m=c.errors,p=c.json;if(m.length||!p){f("Error occurs when creating parties",JSON.stringify(m,null,2));void v({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,errors:m,json:p}});return[2,{partiesCreated:false}]}F.companyNameUsedWhenAsyncAddressUpdate=F.companyName;F.stripeAddressUsedWhenAsyncAddressUpdate=F.stripeAddressEventData;F.stripeBillingAddressUsedWhenAsyncAddressUpdate=F.stripeBillingAddressEventData;F.taxIdUsedWhenAsyncAddressUpdate=F.taxId;F.partyBillingId=p.billToPartyId;F.partyShippingId=p.shipToPartyId;return[2,{partiesCreated:true}]}}))}))}));var Q=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var X=function(){var e,n;var t=JSON.stringify((e=F.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=F.stripeLinkEventData)===null||n===void 0?void 0:n.value);var r=F.stripeAddressEventData&&JSON.stringify(Q(F.stripeAddressEventData.value))!==JSON.stringify(F.stripeAddressUsedWhenFetchingLC);var o=!F.stripeShippingSameAsBilling&&F.stripeBillingAddressEventData&&JSON.stringify(Q(F.stripeBillingAddressEventData.value))!==JSON.stringify(F.stripeBillingAddressUsedWhenFetchingLC);return t||r||o};var $=function(){var e;var n=Se.landedCostData&&((e=Se.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==Se.subtotal;var t=X();p("isPrefetchInfoOutdated","info",{isAddressOutdated:t});return!Se.landedCostData&&!F.isFetchingLandedCost||t||n};var ee=function(e){var t,r;var o=(t=n.genericSettings)===null||t===void 0?void 0:t.countryFields;var i=(r=n.genericSettings)===null||r===void 0?void 0:r.stripeCountryFieldLabels;var a=i&&e in i?i[e]:null;var s=o&&e in o?o[e]:null;if(Se.addressFormRenderType==="stripe"){return a||s}return s};var ne=function(){var e,n,t,r;var o=!!((e=F.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((n=F.stripeAddressEventData)===null||n===void 0?void 0:n.complete);var a=F.stripeShippingSameAsBilling?i:!!((t=F.stripeBillingAddressEventData)===null||t===void 0?void 0:t.complete);var s=((r=F.stripeAddressEventData)===null||r===void 0?void 0:r.value.address.country)||"US";var d=ee(s);if(i&&a&&o){return true}if(!d||!F.stripeAddressEventData){return i&&a&&o}var u=F.stripeAddressEventData.value.address.line1.length>0;var l=F.stripeAddressEventData.value.firstName&&F.stripeAddressEventData.value.lastName;var c=!d.stateRequired||d.stateRequired&&F.stripeAddressEventData.value.address.state.length>0;var v=!d.zipRequired||d.zipRequired&&F.stripeAddressEventData.value.address.postal_code.length>=3;var f=F.stripeAddressEventData.value.phone&&F.stripeAddressEventData.value.phone.length>0;return o&&l&&u&&c&&v&&f};var te=function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,o,i,a,s,d,u,l,c;return __generator(this,(function(v){switch(v.label){case 0:n=new AbortController;F.fetchingLandedCostAbortController=n;ze();return[4,T(n)];case 1:t=v.sent(),o=t.checkoutSessionWorkflow,i=t.errors,a=t.itemCreateWorkflow,s=t.landedCostCalculateWorkflow,d=t.partyCreateWorkflow,u=t.shipmentRatingCalculateWorkflow;Se.customQuotingError=((e=i===null||i===void 0?void 0:i.find((function(e){var n;return((n=e.extensions)===null||n===void 0?void 0:n.ruleMessageType)==="CUSTOM"})))===null||e===void 0?void 0:e.message)||null;Se.shippingData=P((u===null||u===void 0?void 0:u.filter(Boolean))||[]);Ae(a);F.fetchingLandedCostAbortController=null;Se.partiesData=(d===null||d===void 0?void 0:d.filter(Boolean))||[];Se.landedCostData=(o===null||o===void 0?void 0:o.map((function(e){var n=s===null||s===void 0?void 0:s.find((function(n){return(n===null||n===void 0?void 0:n.id)===e.landedCostId}));if(!n){return null}return Object.assign(Object.assign({},e),{landedCost:n})})).filter(Boolean))||[];l=r.checkoutSessionId;if(o===null||o===void 0?void 0:o.length){void E({checkoutSessionId:l,eventName:"checkout_quoteReceived"})}c=Se.promoCodeApplied&&!Se.landedCostData.find((function(e){var n;return(n=e.landedCost.appliedAdjustments)===null||n===void 0?void 0:n.find((function(e){return e.type==="PROMO_CODE"}))}));Se.promoCodeError=c;if(!c){sessionStorage.setItem("zonos--promo-code",Se.promoCode)}return[2]}}))}))};var re=e("q",(function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,r,o,i,a,s,d,u,l,c,m,p,h;return __generator(this,(function(w){switch(w.label){case 0:i=(e===null||e===void 0?void 0:e.retries)||0;a=!!(e===null||e===void 0?void 0:e.applyingPromocode);s=$();d=ne();if(!d){return[2,{isRequestNotReady:true}]}if(s){(n=F.fetchingLandedCostAbortController)===null||n===void 0?void 0:n.abort();F.fetchingLandedCostAbortController=null}if(!s&&!a){return[2,{isRequestNotReady:false}]}if(i){F.isFetchingLandedCost=false;setTimeout((function(){F.isFetchingLandedCost=true}),300)}else{F.isFetchingLandedCost=true}if(F.stripeAddressEventData){F.stripeAddressUsedWhenFetchingLC={countryCode:F.stripeAddressEventData.value.address.country,postalCode:F.stripeAddressEventData.value.address.postal_code,state:F.stripeAddressEventData.value.address.state}}if(F.stripeBillingAddressEventData){F.stripeBillingAddressUsedWhenFetchingLC={countryCode:F.stripeBillingAddressEventData.value.address.country,postalCode:F.stripeBillingAddressEventData.value.address.postal_code,state:F.stripeBillingAddressEventData.value.address.state}}if(F.stripeLinkEventData){F.stripeLinkUsedWhenFetchingLC=Object.assign({},F.stripeLinkEventData)}w.label=1;case 1:w.trys.push([1,3,,7]);ze();return[4,te()];case 2:w.sent();u=(t=Se.shippingData)===null||t===void 0?void 0:t.find(Boolean);l=(r=Se.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCost.shipmentRating.id===(u===null||u===void 0?void 0:u.id)}));c=!!l?l.subtotals:null;if(c){Ee({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:c})}return[3,7];case 3:m=w.sent();Se.landedCostData=[];Se.shippingData=[];p=["The landed cost calculation request was aborted to initiate a new one."];if(!(m instanceof Error&&m.message&&!p.includes(m.message)))return[3,6];if(!(i<1))return[3,5];return[4,re(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:w.sent();return[2,{isRequestNotReady:false}];case 5:h=(o=F.stripeAddressEventData)===null||o===void 0?void 0:o.value;void v({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[m.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:h}});w.label=6;case 6:f(m);return[3,7];case 7:F.isFetchingLandedCost=false;return[2,{isRequestNotReady:false}]}}))}))}));var oe=e("F",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,r;return __generator(this,(function(o){switch(o.label){case 0:return[4,re({applyingPromocode:true})];case 1:o.sent();if(Se.step==="payment"){Je()}return[4,Z()];case 2:o.sent();t=(e=Se.shippingData)===null||e===void 0?void 0:e.find(Boolean);r=(n=Se.landedCostData)===null||n===void 0?void 0:n.find((function(e){return e.landedCost.id===(t===null||t===void 0?void 0:t.id)}));if(!t||!r){return[2]}return[4,Le({applySubtotalsOnly:false,landedCostId:r.landedCostId,selectedShippingOption:t})];case 3:o.sent();return[2]}}))}))}));var ie=e("H",(function(){Se.promoCode="";sessionStorage.removeItem("zonos--promo-code");Se.promoCodeError=false;Se.promoCodeApplied=false}));var ae=e("G",(function(){return __awaiter(y,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:if(Se.step==="payment"){Je()}ie();return[4,oe()];case 1:e.sent();return[2]}}))}))}));var se=e("I",(function(e){var n=[];var t=true;var r=window.Zonos.isCollect;switch(e){case"succeeded":{n=[s("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"",s("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")];if(r){n=[s("Thank you for submitting your payment. We appreciate your prompt attention."),"",s("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]}t=false;break}case"requires_capture":case"processing":{n=[s("Payment processing. We'll update you when payment is received.")];t=false;break}case"requires_payment_method":{n=[s("Payment failed. Please try another payment method.")];if(r){n=[s("Payment failed. Please reload the page and try another payment method.")]}break}case"requires_action":{t=false;n=[s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{n=[s("Something went wrong.")];break}}return{isError:t,messages:n}}));var de=e("v",(function(){return __awaiter(y,void 0,void 0,(function(){var e,t,r,o,i,a,d,l,c,l;return __generator(this,(function(m){switch(m.label){case 0:r=n.checkoutSettings.onInventoryCheck;o=!!((t=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||t===void 0?void 0:t.value);if(!(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o))return[3,2];return[4,u("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:i=m.sent(),a=i.errors,d=i.json;if(a.length||!d){f("Error occurs when handling inventory refund","warn",JSON.stringify(a));return[2,null]}if(!d.available||d.status===204){return[2,s("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(d.available||d.status===200){F.shouldInventoryRefund=true;return[2,null]}return[2,null];case 2:if(typeof r!=="function"){return[2,null]}m.label=3;case 3:m.trys.push([3,5,,6]);return[4,r({items:Se.items})];case 4:l=m.sent();return[2,l];case 5:c=m.sent();l=c instanceof Error?c.message:"Unknown error";void v({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(l)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:Se.items}});throw c;case 6:return[2]}}))}))}));var ue=e("x",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t;return __generator(this,(function(r){switch(r.label){case 0:t=!!((n=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||n===void 0?void 0:n.value);if(!window.Zonos.isLegacyCheckout||!window.Zonos.cartData||!t){return[2]}return[4,u("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:r.sent();return[2]}}))}))}));var le=e("d",(function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,r,o,i,a,d,u,l;var c=e.clientSecret,v=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(v){n=se(v),t=n.isError,r=n.messages;return[2,{error:t,messages:r}]}o=c||F.clientSecret;if(!F.stripe||!o){f("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[s("Something went wrong.")]}]}return[4,F.stripe.retrievePaymentIntent(o)];case 1:i=e.sent().paymentIntent;a=i===null||i===void 0?void 0:i.status;d=se(a),u=d.isError,l=d.messages;return[2,{error:u,messages:l,paymentIntentId:i===null||i===void 0?void 0:i.id,paymentMethod:i===null||i===void 0?void 0:i.payment_method,status:a}]}}))}))}));var ce=e("w",(function(e){return __awaiter(y,void 0,void 0,(function(){var n,t,o,i,a,d,u,l,c,v,f,m;return __generator(this,(function(h){switch(h.label){case 0:o=!!((n=F.stripePaymentEventData)===null||n===void 0?void 0:n.complete);i=F.stripeElements;a=F.stripe;d=F.clientSecret;F.customErrorMessage=null;if(!((t=Se.selectedLandedCost)===null||t===void 0?void 0:t.landedCost.id)&&!(e===null||e===void 0?void 0:e.noLandedCostCheck)){throw new Error("Attempted to confirm the payment when no landed cost is found in store")}return[4,L()];case 1:u=h.sent();if(!u.valid){F.customErrorMessage=u.errorMessage;throw new Error(u.errorMessage)}l=r.checkoutSessionId;if(!(a&&i&&o&&d&&l))return[3,3];c=new URL(window.location.href);c.searchParams.set("payment_intent_client_secret",d);c.searchParams.set("zonosCheckoutSessionId",l);void E({checkoutSessionId:l,eventName:"checkout_paymentInfoCompleted"});return[4,a.confirmPayment({confirmParams:{return_url:c.toString()},elements:i,redirect:"if_required"})];case 2:v=h.sent(),f=v.error,m=v.paymentIntent;p("Payment intent confirmed","info",{error:f,paymentIntent:m});if((m===null||m===void 0?void 0:m.status)==="requires_action"){throw new Error(s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."))}if(f){if(f.type==="card_error"||f.type==="validation_error"){throw new Error(f.message)}if(f.type==="invalid_request_error"){if(f.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}if(m.status==="requires_payment_method"){throw new Error(s("Payment failed. Please try another payment method."))}h.label=3;case 3:return[2]}}))}))}));var ve=e("n",(function(){var e;var n=Se.items.reduce((function(e,n){return e+n.amount*n.quantity}),0);var t=r.enabledVariantTestKeys||[];var i={adjustmentsAmount:Se.adjustments.reduce((function(e,n){return e+n.amount}),0),cartId:window.Zonos.cartId,currency:((e=Se.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:Se.customerAuthenticationToken||undefined,isCollect:window.Zonos.isCollect,itemsAmount:n,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:o.selectedCountryCode,skipPaymentIntent:F.skipPaymentIntent,varianceTestInput:t};return i}));var fe=e("l",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:if(!r.checkoutSessionId){void v({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:h,cartId:window.Zonos.cartId}});Te({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});return[2]}return[4,u("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:r.checkoutSessionId},method:"POST"})];case 1:n=a.sent(),t=n.errors,o=n.json;i=(e=o===null||o===void 0?void 0:o.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(t.length||!i){f("Error occurs when getting payment intent",JSON.stringify(t,null,2));void v({endpoint:"Error creating payment intent",errors:t.map((function(e){return e.message})),metadata:{allLogs:h,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,clientSecret:i}});Te({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});return[2]}je(o.checkoutSessionPaymentIntentCreate);return[2]}}))}))}));var me=e("k",(function(){return __awaiter(y,void 0,void 0,(function(){var e,n,t,r,i,a,s,d;return __generator(this,(function(l){switch(l.label){case 0:if(!o.targetCurrency){f("Failed to create checkout session - missing localizationStore.targetCurrency");return[2,false]}F.isFetchingSession=true;t=ve();p("Checkout session body","info",t);return[4,u("/api/zonos-elements/create-checkout-session",{body:t,method:"POST"})];case 1:r=l.sent(),i=r.errors,a=r.json;F.isFetchingSession=false;if(i.length||!a){s=(e=i.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;if(Array.isArray(s)&&s.some((function(e){return e.message==="Cart is expired."}))){throw new Error("Cart is expired.")}f("Error occurred when creating checkout session",JSON.stringify(i,null,2));return[2,false]}d=a.checkoutSessionCreate;je(d);Ee({method:((n=d.landedCost)===null||n===void 0?void 0:n.method)||"DDP",subtotals:d.subtotals});p("Exchange rate updated for cart items (checkout session create)","info",Se.exchangeRate);p("done-init-checkout-session");return[2,true]}}))}))}));var pe=e("u",(function(){return __awaiter(y,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(i){switch(i.label){case 0:e=r.checkoutSessionId;if(!e){f("Failed to update checkout session base currency");return[2,false]}if(n.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){p('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2,true]}return[4,u("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:F.checkoutSettlementCurrency},method:"POST"})];case 1:t=i.sent().json;o=t===null||t===void 0?void 0:t.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;if(!t||o!==F.checkoutSettlementCurrency){f("Failed to update checkout session base currency");return[2,false]}p('Updated checkout session to settlement currency "'.concat(o,'".'));return[2,true]}}))}))}));var he=function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,i,a;var s=e.adjustmentsAmount,d=e.cartId,l=e.currency,c=e.id,v=e.itemsAmount,m=e.landedCostId,p=e.presentmentCountryCode;return __generator(this,(function(e){switch(e.label){case 0:n=r.enabledVariantTestKeys||[];return[4,u("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:s,billToPartyId:F.partyBillingId,cartId:d,currency:l,customerAuthenticationToken:Se.customerAuthenticationToken||undefined,id:c,itemsAmount:v,landedCostId:m,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:p,shipToPartyId:F.partyShippingId,skipPaymentIntent:F.skipPaymentIntent,varianceTestInput:n},method:"POST"})];case 1:t=e.sent(),i=t.errors,a=t.json;if(i.length||!a){f("Error occurs when updating checkout session",JSON.stringify(i,null,2));return[2,{errors:i,json:a}]}return[2,{errors:[],json:a}]}}))}))};var we=function(e){var n,t,r,o,i,a;var s=e.currentAddress,d=e.translatedAddressResult;var u={};if(!d){return u}var l=d.city,c=d.line1,v=d.line2,f=d.name,m=d.postal_code,p=d.state;if(s.city&&l){u.city=(n={},n[s.city]=l,n)}if(s.line1&&c){u.line1=(t={},t[s.line1]=c,t)}if(s.line2&&v){u.line2=(r={},r[s.line2]=v,r)}if(s.postal_code&&m){u.postal_code=(o={},o[s.postal_code]=m,o)}if(s.state&&p){u.state=(i={},i[s.state]=p,i)}if(s.name&&f){u.name=(a={},a[s.name]=f,a)}return u};var ge=e("J",(function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,r,o,i,a,s,d,l,c,v;var m=e.addressInvalidCharactersList,p=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=j({addressInvalidCharactersList:m,billingAddressInvalidCharactersList:p,stripeAddressEventData:F.stripeAddressEventData,stripeBillingAddressEventData:F.stripeBillingAddressEventData,stripeShippingSameAsBilling:F.stripeShippingSameAsBilling});if(!i){F.translatedAddress={address:{},billingAddress:{}};return[2]}a=K();if(!a){return[2]}return[4,u("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),d=s.errors,l=s.json;if(d.length||!l){f("Error occurs when translating address to latin",JSON.stringify(d,null,2));F.translatedAddress={address:{},billingAddress:{}};return[2]}F.stripeAddressUsedWhenValidatingAddress=F.stripeAddressEventData;F.stripeBillingAddressUsedWhenValidatingAddress=F.stripeBillingAddressEventData;c=(n=F.stripeAddressEventData)===null||n===void 0?void 0:n.value.address;v=(t=F.stripeBillingAddressEventData)===null||t===void 0?void 0:t.value.address;F.translatedAddress={address:c?we({currentAddress:Object.assign(Object.assign({},c),{name:(r=F.stripeAddressEventData)===null||r===void 0?void 0:r.value.name}),translatedAddressResult:l.address||null}):{},billingAddress:!F.stripeShippingSameAsBilling?we({currentAddress:Object.assign(Object.assign({},v),{name:(o=F.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:l.billingAddress||null}):{}};return[2]}}))}))}));z("clientSecret",(function(e){if(e&&F.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var ye=t((function(){return{addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:false,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:false,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,isStagingMode:c(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:false,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:false,step:"customer-info",subtotal:0,tabItems:{"customer-info":{index:1,isDone:false,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:false,label:"Shipping",value:"shipping"},payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),be=ye.onChange,_e=ye.reset,Se=ye.state;e({z:be,e:Se});var Oe=function(e){switch(e){case"DAYS":return s("days");case"WEEKS":return s("weeks");case"BUSINESS_DAYS":default:return s("business days")}};var Ce=e("M",(function(e){var n;var t=(n=e.shippingProfile)===null||n===void 0?void 0:n.transitTime;if(!(t===null||t===void 0?void 0:t.min)||!(t===null||t===void 0?void 0:t.max)||!(t===null||t===void 0?void 0:t.type)){return null}return{maxTransit:t.max,minTransit:t.min,unit:Oe(t.type)}}));var ke=function(e){var n=e.item1,t=e.item2;if(!n||!t){return false}return t.sku&&n.sku&&n.sku===t.sku||t.description&&n.description&&n.description===t.description||n.name&&t.name&&n.name===t.name};var Ae=function(e){p("Checking item restrictions");var n=e.map((function(e){if(!e.restriction){return null}var n=e.restriction;var t=Se.items.find((function(n){return ke({item1:n,item2:e})}));return Object.assign(Object.assign({matchedItem:t},e),{restriction:n})})).filter(Boolean);Se.restrictedItems=n;Se.items=Se.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!n.find((function(n){return ke({item1:n,item2:e})}))})}));return{cartItems:Se.items,restrictedItems:n}};var Ie=e("g",(function(){r.checkoutSessionId=null;_e()}));var Te=e("o",(function(e){var n=e.messages,t=e.title;Ie();H();Se.step="error";Se.error={messages:n,title:t}}));var Ee=function(e){var n=e.dutiesTaxesFeesEstimate,t=e.method,r=e.subtotals;Se.exchangeRate=r.exchangeRate;Se.adjustmentTotal=r.adjustments;Se.dutiesTaxesFees=t==="DAP"?null:r.landedCostTotal;Se.subtotal=r.items;Se.total=r.total;Se.currency=r.presentmentCurrencyCode;Se.dutiesTaxesFeesEstimate=n||null};var Ne=e("E",(function(){var e=Se.items.filter((function(e){return e.amount>0}));return!!e.find((function(e){return!e.isRestricted}))}));var je=e("p",(function(e){var n,t,o,s,d;F.clientSecret=e.clientSecret;F.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;F.customerProfile=e.customerProfile;Se.checkoutSession=e;if(!e.id){void v({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:h,checkoutSession:e}})}if(e.id){r.checkoutSessionId=e.id}var u=i(e.varianceTestResults||[]);a(u);var l=((o=(t=(n=Se.checkoutSession)===null||n===void 0?void 0:n.metadata)===null||t===void 0?void 0:t.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||o===void 0?void 0:o.value)||((d=(s=window.Zonos.cartData)===null||s===void 0?void 0:s.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||d===void 0?void 0:d.value)||null;if(l){p("Found externalConfirmationPageURL: ".concat(l));Se.externalConfirmationPageURL=l}}));var Pe=function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,i,a,d,u;var l=e.adjustmentsAmount,c=e.cartId,v=e.currency,m=e.dutiesTaxesFeesEstimate,h=e.itemsAmount,w=e.landedCostId,g=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(w&&Se.selectedLandedCost){t=Se.selectedLandedCost.subtotals;Ee({dutiesTaxesFeesEstimate:m,method:Se.landedCostMethod,subtotals:t});p("Exchange rate updated for cart items (landed cost subtotal)","info",Se.exchangeRate)}if(!r.checkoutSessionId){p("Could not update cart total without checkout session id","info");return[2,false]}return[4,he({adjustmentsAmount:l,billToPartyId:F.partyBillingId,cartId:c,currency:v,id:r.checkoutSessionId,itemsAmount:h,landedCostId:w,presentmentCountryCode:o.selectedCountryCode,shipToPartyId:F.partyShippingId,varianceTestInput:r.enabledVariantTestKeys||[]})];case 1:i=e.sent(),a=i.errors,d=i.json;if(!(a.length>0||!d))return[3,4];f("Error occurs when updating checkout session.");if(!g)return[3,3];p("Initiating checkout session on failure","info");return[4,me()];case 2:u=e.sent();p("stripeStoreInitCheckoutSession: ".concat(u));if(!u){Te({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});return[2,false]}return[2,true];case 3:return[2,false];case 4:if(!w){Ee({method:((n=d.checkoutSessionUpdate.landedCost)===null||n===void 0?void 0:n.method)||"DDP",subtotals:d.checkoutSessionUpdate.subtotals});p("Exchange rate updated for cart items (checkout session update)","info",Se.exchangeRate)}je(d.checkoutSessionUpdate);return[2,true]}}))}))};var De=e("N",(function(e){var t,r,o;if(e.method==="DAP"&&((r=(t=n.genericSettings)===null||t===void 0?void 0:t.domesticCountries)===null||r===void 0?void 0:r.includes(((o=F.stripeAddressEventData)===null||o===void 0?void 0:o.value.address.country)||"US"))){return"DDP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var Le=e("D",(function(e){return __awaiter(y,[e],void 0,(function(e){var t,o,i,a,s,d,u,l,c,v,f,m,h,w,g,y,b,_,S,O,C,k,A,I,T;var E=e.applySubtotalsOnly,N=e.landedCostId,j=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:p("Updating selected shipping option","info",{landedCostId:N,selectedShippingOption:j});Se.selectedShippingOption=j;m=Ce(Se.selectedShippingOption);if(m){h=m.maxTransit,w=m.minTransit,g=m.unit;Se.selectedShippingOptionTransitTime="".concat(w,"-").concat(h," ").concat(g)}else{Se.selectedShippingOptionTransitTime=""}y=(t=Se.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCostId===N}));Se.selectedLandedCost=y||null;if(!y){return[2,false]}b=((o=y.landedCost.amountSubtotals)===null||o===void 0?void 0:o.landedCostTotal)||0;_=y.subtotals.exchangeRate.rate;S=b*_;if(S){p("DAP quote, using estimate: ".concat(S),"info")}Se.landedCostMethod=De(y.landedCost);Se.shipping=y.subtotals.shipping;O=((i=y===null||y===void 0?void 0:y.landedCost)===null||i===void 0?void 0:i.landedCostGuaranteeCode)==="ZONOS";C=!!((s=(a=y===null||y===void 0?void 0:y.landedCost)===null||a===void 0?void 0:a.deMinimis)===null||s===void 0?void 0:s.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));Se.isSelectedShippingAboveDeminimis=C;Se.isSelectedShippingGuarantee=O;k=false;if(!E)return[3,1];A=y.subtotals;Ee({dutiesTaxesFeesEstimate:S,method:Se.landedCostMethod,subtotals:A});p("Exchange rate updated for cart items (landed cost subtotal)","info",Se.exchangeRate);k=true;return[3,3];case 1:return[4,Pe({adjustmentsAmount:Se.adjustmentTotal,billToPartyId:F.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:S,landedCostId:(d=y.landedCost)===null||d===void 0?void 0:d.id,shipToPartyId:F.partyShippingId,varianceTestInput:r.enabledVariantTestKeys||[]})];case 2:k=e.sent();e.label=3;case 3:I=(u=Se.items.find(Boolean))===null||u===void 0?void 0:u.currencyCode;T=((l=F.stripeAddressEventData)===null||l===void 0?void 0:l.value.address.country)||"US";F.shouldRenderPayInUsdButton=I==="USD"&&n.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((c=Se.checkoutSession)===null||c===void 0?void 0:c.subtotals.presentmentCurrencyCode)!=="USD"&&!!((f=(v=n.genericSettings)===null||v===void 0?void 0:v.usdSettlementCountryEnabled)===null||f===void 0?void 0:f.includes(T));return[2,k]}}))}))}));var xe=e("m",(function(e){var n=e.isPreview,t=e.sessionTimeout;if(n){return}var r=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var o=r&&!isNaN(parseInt(r,10))?parseInt(r,10):t;p("==START CHECKOUT TIMEOUT - ".concat(o,"=="));Se.checkoutTimeoutInterval=setTimeout((function(){Se.checkoutSessionTimeoutShow=true}),o)}));var Re=e("j",(function(){if(Se.checkoutTimeoutInterval){clearTimeout(Se.checkoutTimeoutInterval);Se.checkoutTimeoutInterval=null}}));var Ue=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var ze=function(){Se.items=Se.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));Se.restrictedItems=[]};var Be=e("f",(function(e){return __awaiter(y,[e],void 0,(function(e){var n,t,o,i;var a=e.adjustments,s=e.cartItems,d=e.landedCostId,u=e.shouldInitSessionOnFailure,l=u===void 0?true:u;return __generator(this,(function(e){switch(e.label){case 0:Se.adjustments=a;Se.items=Ue(s);t=(n=s.find(Boolean))===null||n===void 0?void 0:n.currencyCode;o=s.reduce((function(e,n){return e+n.amount*n.quantity}),0);i=a.reduce((function(e,n){return e+n.amount}),0);if(!t||!o){return[2]}Se.currency=t;F.isFetchingSession=true;return[4,Pe({adjustmentsAmount:i,billToPartyId:F.partyBillingId,cartId:window.Zonos.cartId,currency:t,dutiesTaxesFeesEstimate:0,itemsAmount:o,landedCostId:d,shipToPartyId:F.partyShippingId,shouldInitSessionOnFailure:l,varianceTestInput:r.enabledVariantTestKeys||[]})];case 1:e.sent();F.isFetchingSession=false;return[2]}}))}))}));var Fe=function(){Se.selectedShippingOption=null;Se.isSelectedShippingAboveDeminimis=false;Se.isSelectedShippingGuarantee=false;Se.selectedShippingOptionTransitTime="";Se.dutiesTaxesFees=0;Se.dutiesTaxesFeesEstimate=0;Se.shipping=0;Se.total=Se.subtotal};var Je=function(){if(Se.step==="shipping"){Se.step="customer-info";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{"customer-info":Object.assign(Object.assign({},Se.tabItems.shipping),{isDone:false})})}else if(Se.step==="payment"){Se.step="shipping";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{shipping:Object.assign(Object.assign({},Se.tabItems.shipping),{isDone:false})})}else if(Se.step==="finish"){Se.step="payment";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{payment:Object.assign(Object.assign({},Se.tabItems.payment),{isDone:false})})}};var Me=e("r",(function(){if(Se.step==="customer-info"){Se.step="shipping";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{"customer-info":Object.assign(Object.assign({},Se.tabItems["customer-info"]),{isDone:true})})}else if(Se.step==="shipping"){Se.step="payment";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{shipping:Object.assign(Object.assign({},Se.tabItems.shipping),{isDone:true})})}else if(Se.step==="payment"){Se.step="finish"}}));var qe=e("h",(function(){Se.step="customer-info";Se.tabItems=Object.assign(Object.assign({},Se.tabItems),{"customer-info":Object.assign(Object.assign({},Se.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},Se.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},Se.tabItems.shipping),{isDone:false})});Fe()}))}}}));
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(n,r,e,t){function o(n){return n instanceof e?n:new e((function(r){r(n)}))}return new(e||(e=Promise))((function(e,i){function a(n){try{c(t.next(n))}catch(n){i(n)}}function u(n){try{c(t["throw"](n))}catch(n){i(n)}}function c(n){n.done?e(n.value):o(n.value).then(a,u)}c((t=t.apply(n,r||[])).next())}))};var __generator=this&&this.__generator||function(n,r){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(n){return function(r){return c([n,r])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(e=0)),e)try{if(t=1,o&&(i=u[0]&2?o["return"]:u[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;if(o=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:e.label++;return{value:u[1],done:false};case 5:e.label++;o=u[1];u=[0];continue;case 7:u=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){e.label=u[1];break}if(u[0]===6&&e.label<i[1]){e.label=i[1];i=u;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(u);break}if(i[2])e.ops.pop();e.trys.pop();continue}u=r.call(n,e)}catch(n){u=[6,n];o=0}finally{t=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-89c5164b.system.js","./p-01174496.system.js","./p-d938f42f.system.js","./p-182da73f.system.js"],(function(n){"use strict";var r,e,t,o,i,a,u,c;return{setters:[function(n){r=n.c;e=n.z},function(n){t=n.j;o=n.h;i=n.l},function(n){a=n.a;u=n.l},function(n){c=n.a}],execute:function(){var s=this;var l=function(n){var r=!!n.find((function(n){return n.testKey in a}));if(!r){u("No available test key found in response","info",{response:n})}return!!n.find((function(n){return n.testKey in a}))};var v=n("f",(function(n){if(!l(n)){return[]}return n.filter((function(n){var r;var e=a[n.testKey]&&!n.selectedVariantKey;var t=n.selectedVariantKey&&!!((r=a[n.testKey])===null||r===void 0?void 0:r["availableVariants"].includes(n.selectedVariantKey));return e||t})).map((function(n){return Object.assign(Object.assign({},n),{expiresAt:n.expiresAt||Date.now()+d,selectedVariantKey:n.selectedVariantKey||null})}))}));var d=n("V",60*60*24*1e3);var f=r({checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id"),enabledVariantTestKeys:t(localStorage.getItem("zonos--enabled-variant-test-keys"))}),w=f.onChange,y=f.state;n({o:w,s:y});w("enabledVariantTestKeys",(function(){var n;if(!((n=y.enabledVariantTestKeys)===null||n===void 0?void 0:n.length)){localStorage.removeItem("zonos--enabled-variant-test-keys");return}localStorage.setItem("zonos--enabled-variant-test-keys",JSON.stringify(y.enabledVariantTestKeys))}));w("checkoutSessionId",(function(){if(!y.checkoutSessionId){sessionStorage.removeItem("zonos--checkout-session-id");return}sessionStorage.setItem("zonos--checkout-session-id",y.checkoutSessionId)}));var m=n("b",(function(n){y.enabledVariantTestKeys=v(n)}));var h=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e,t;return __generator(this,(function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);return[4,o("/api/zonos-elements/get-countries",{method:"GET"})];case 1:n=i.sent(),r=n.errors,e=n.json;if(r.length||!e){return[2,null]}return[2,e];case 2:t=i.sent();return[2,null];case 3:return[2]}}))}))};var g=function(n){return __awaiter(s,void 0,void 0,(function(){var r,e,t,a,u;return __generator(this,(function(c){switch(c.label){case 0:if(!n){return[2,null]}e="/api/zonos-elements/country-landed-cost/".concat(n);return[4,o(e)];case 1:t=c.sent(),a=t.errors,u=t.json;if(a.length||!u){i("Error fetching country landed cost: ".concat((r=a.find(Boolean))===null||r===void 0?void 0:r.message));return[2,null]}return[2,u||null]}}))}))};var _={exchangeRate:{rate:1,targetFormat:{currencyCode:"USD",decimalDelimiter:".",scale:2,symbol:"$",symbolLocation:"before",thousandsDelimiter:","}},maxAge:null};var p=function(n){return __awaiter(s,[n],void 0,(function(n){var r,e,t,a,u,c,s,l,v,d;var f=n.country,w=n.isGuaranteed,y=n.sourceCurrency,m=n.targetCurrency;return __generator(this,(function(n){switch(n.label){case 0:if(y===m&&!w){return[2,_]}e=new URLSearchParams;e.set("sourceCurrency",y);e.set("targetCurrency",m);e.set("isGuaranteed",String(w));e.set("country",f||"");return[4,o("/api/zonos-elements/exchange-rates?".concat(e.toString()))];case 1:t=n.sent(),a=t.errors,u=t.json;if(a.length||!u){i("Error fetching country landed cost: ".concat((r=a.find(Boolean))===null||r===void 0?void 0:r.message));return[2,_]}c=u.exchangeRateCreate,s=c.rate,l=c.targetFormat;v=u.maxAge;if(s){sessionStorage.setItem(f+"_rate",JSON.stringify(s));d={rate:s,targetFormat:l};return[2,{exchangeRate:d,maxAge:v}]}return[2,_]}}))}))};var b=function(n){return __awaiter(s,void 0,void 0,(function(){var r,e,t,a;return __generator(this,(function(u){switch(u.label){case 0:if(!n){return[2,null]}return[4,o("/api/zonos-elements/inclusive-prices/".concat(n))];case 1:e=u.sent(),t=e.errors,a=e.json;if(t.length||!a){i("Error fetching country inclusive price setting: ".concat((r=t.find(Boolean))===null||r===void 0?void 0:r.message));return[2,null]}return[2,a||null]}}))}))};var z=function(n){return __awaiter(s,[n],void 0,(function(n){var r,e,t,a,u;var c=n.countryCode,s=n.localeTo,l=n.storeId;return __generator(this,(function(n){switch(n.label){case 0:e=new URLSearchParams;e.set("countryCode",c);e.set("storeId",l.toString());if(s){e.set("localeTo",s)}return[4,o("/api/zonos-elements/locale-messages?".concat(e.toString()))];case 1:t=n.sent(),a=t.errors,u=t.json;if(a.length||!u){i("Error fetching exchange rate",(r=a.find(Boolean))===null||r===void 0?void 0:r.message);return[2,[]]}return[2,u.locale_countryCodesPage]}}))}))};var S=function(n){if(n&&/^[A-Z]{2}$/.test(n)){return n}return null};var C=n("g",(function(n){var r=new URLSearchParams(n||window.location.search);var e=function(n){var e=r.get(n);return S(e)};var t=e("zCountry");var o=e("country");var i=e("customerCountry");return t||o||i}));var L=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e,t,i,a,u,c;return __generator(this,(function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);n=new URL(window.location.href);r=window.sessionStorage.getItem("zonos--country");e=C(n.searchParams)||r;t=new URLSearchParams;if(e){t.set("zCountry",e)}return[4,o("/api/zonos-elements/localization?".concat(t.toString()))];case 1:i=s.sent(),a=i.errors,u=i.json;if(a.length||!u){return[2,{country:null,locale:null}]}return[2,{country:u.country,locale:u.locale}];case 2:c=s.sent();return[2,{country:null,locale:null}];case 3:return[2]}}))}))};var k=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e,t,a,u,c;return __generator(this,(function(s){switch(s.label){case 0:if((n=window.Zonos.cartSettings)===null||n===void 0?void 0:n.shippingZones){return[2,window.Zonos.cartSettings.shippingZones.flatMap((function(n){return n===null||n===void 0?void 0:n.countryCodes})).filter(Boolean)]}return[4,o("/api/zonos-elements/shipping-zones")];case 1:t=s.sent(),a=t.errors,u=t.json;if(a.length||!u){i("Error fetching shipping zones: ".concat((r=a.find(Boolean))===null||r===void 0?void 0:r.message));return[2,null]}c=(e=u===null||u===void 0?void 0:u.shippingZones)===null||e===void 0?void 0:e.flatMap((function(n){return n===null||n===void 0?void 0:n.countryCodes})).filter(Boolean);return[2,c||null]}}))}))};var I=n("m",(function(n){var r=$.exchangeRate;if(!r||!n||isNaN(n)){return n}var e=(r===null||r===void 0?void 0:r.targetFormat.scale)||2;var t=n*r.rate;var o=t.toFixed(e);return Number(o)}));var A=function(n){var r=n.amount,e=n.currency,t=n.targetFormat;var o=e||$.targetCurrency;var i=(t===null||t===void 0?void 0:t.scale)||2;var a=window.navigator.userAgent.indexOf("MSIE ")!==-1;var u=typeof Intl==="object"&&Intl&&typeof Intl.NumberFormat==="function";if(a||!u){var c=Number(r).toFixed(i).replace(".","|dec|").replace(",",(t===null||t===void 0?void 0:t.thousandsDelimiter)||"").replace("|dec|",(t===null||t===void 0?void 0:t.decimalDelimiter)||"");return c}var s=new Intl.NumberFormat(window.navigator.language,{currency:o,currencyDisplay:"code",minimumFractionDigits:i,style:"currency"}).format(r);return s.replace(new RegExp("".concat(o,"\\s+")),"")};var E=n("d",(function(n){var r=n.amount,t=n.currency;if(isNaN(r)||r!==0&&!r){return""}var o=e.overrideCurrencyFormat;var i=$.exchangeRate;var a=t||$.targetCurrency;if(typeof o==="function"){return o({amount:r,currencyCode:a,numberFormat:function(n){var r=n.amount;return A({amount:r,currency:a,targetFormat:(i===null||i===void 0?void 0:i.targetFormat)||null})}})}var u=(i||{}).targetFormat;if(!u||!i){return"".concat(r.toFixed(2)," ").concat(a)}var c=u.scale||2;var s=window.navigator.userAgent.indexOf("MSIE ")!==-1;var l=typeof Intl==="object"&&Intl&&typeof Intl.NumberFormat==="function";if(s||!l){var v=Number(r).toFixed(c).replace(".","|dec|").replace(",",u.thousandsDelimiter||"").replace("|dec|",u.decimalDelimiter||"");var d="".concat(v).concat(u.currencyCode!=="USD"?" ".concat(u.currencyCode):"");return d}var f=(o===null||o===void 0?void 0:o.currencyDisplay)||"symbol";var w=new Intl.NumberFormat(window.navigator.language,{currency:a,currencyDisplay:f,minimumFractionDigits:c,style:"currency"}).format(r);var y=f==="code"?"".concat(w.replace(new RegExp("".concat(a,"\\s+")),"")," ").concat(a):w;return y}));var N=n("k",(function(n){var r=I(n);var e=E({amount:r});return e}));var x=n("i",(function(n){try{document.createDocumentFragment().querySelector(n)}catch(n){return false}return true}));var D=function(n){var r=n||".money";if(!x(r)){i('Currency element selector "'.concat(r,'" is not valid.'));return null}var e=document.querySelectorAll(r);if(!e.length){u('No currency elements found with selector "'.concat(r,'"'),"warn");return null}return Array.from(e)};var j=function(n){var r;var e=n.getAttribute("data-domestic");var t=n.getAttribute("data-zintl");var o=(r=n.textContent)===null||r===void 0?void 0:r.replace(/[^\d.-]/g,"");if(!o){return null}if(!e||n.textContent!==t&&t){n.setAttribute("data-domestic",o);return parseFloat(o)}return parseFloat(e)};var B=7e3;var R="z--blur";var P=function(){return __awaiter(s,void 0,void 0,(function(){var n,r;return __generator(this,(function(e){switch(e.label){case 0:n=window.zonosBlurCurrencyOnInitIntervalId;if(!n){return[2]}return[4,new Promise((function(n){return setTimeout(n,500)}))];case 1:e.sent();clearInterval(n);r=document.querySelectorAll(".".concat(R));r.forEach((function(n){n.classList.remove(R)}));window.zonosBlurCurrencyOnInitIntervalId=undefined;return[2]}}))}))};var U=function(n){var r=n.currencySelector;if(!r){return}var e=document.querySelectorAll([r].filter(Boolean).join(","));e.forEach((function(n){n.classList.add(R)}))};var O=function(){if(typeof window==="undefined"){return}if(window.zonosBlurCurrencyOnInitIntervalId){return}U({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});var n=setInterval((function(){U({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})}),10);window.zonosBlurCurrencyOnInitIntervalId=n;setTimeout((function(){void P()}),B)};var T=function(n){var r;var t=j(n);if(!t||isNaN(t)){return}var o=n.getAttribute("data-zintl");var i=parseFloat(n.getAttribute("data-zrate")||"1");var a=n.getAttribute("data-zcountry-code");var u=$.exchangeRate&&$.targetCurrency===$.exchangeRate.targetFormat.currencyCode;var c=((r=$.exchangeRate)===null||r===void 0?void 0:r.rate)||1;if(u&&(n.textContent!==o||c!==i||a!==$.selectedCountryCode)){O();var s=typeof e.currencyConverter==="function"&&e.currencyConverter({convert:I,convertAndFormat:N,currencyCode:$.targetCurrency,format:function(n){return E({amount:n})},originalAmount:t,selector:n});var l=s||N(t);if(l!==n.textContent){n.textContent=l}n.setAttribute("data-zrate",c.toString());n.setAttribute("data-zintl",l);n.setAttribute("data-zcountry-code",$.selectedCountryCode||"")}void P()};var F=function(){var n=e.helloSettings.currencyElementSelector;var r=D(n);if(!(r===null||r===void 0?void 0:r.length)){return}if(!$.exchangeRate){i("Could not display currency. Exchange rate and format data is not available.");return}r.forEach((function(n){T(n)}))};var G=n("j",(function(){if(e.helloSettings.currencyBehavior==="DISABLED"||window.Zonos.isLegacyCheckout){void P();return}F()}));var J=function(n){var r;var e=(r=$.shippingZoneCountries)===null||r===void 0?void 0:r[n];if(e){return e.currencyCode}return null};var K=n("h",(function(n){if(!n){return}var r=new URLSearchParams(window.location.search);var t=r.has("zCountry")||e.helloSettings.countryOverrideBehavior==="URL_PARAM";if(t){r.set("zCountry",n);var o="".concat(window.location.pathname,"?").concat(r.toString());window.history.replaceState(window.history.state,document.title,o)}}));var M=r({countryLandedCost:null,customMessages:[],exchangeRate:null,helloCountryList:null,inclusivePricing:null,isDisabledCountry:true,isShippableCountry:false,localizationLoaded:false,selectedCountryCode:null,selectedLocale:"en",shippingZoneCountries:null,targetCurrency:"USD"}),V=M.dispose,Z=M.onChange,$=M.state;n({c:Z,l:$});var q=function(n){return __awaiter(s,void 0,void 0,(function(){var r,t,o;return __generator(this,(function(i){switch(i.label){case 0:return[4,p({country:$.selectedCountryCode,isGuaranteed:n,sourceCurrency:e.sourceCurrency,targetCurrency:$.targetCurrency})];case 1:r=i.sent(),t=r.exchangeRate,o=r.maxAge;if(t){$.exchangeRate=t;G()}return[2,{maxAge:o}]}}))}))};var H="CA";var Y=n("n",(function(n){if($.selectedCountryCode&&n.includes($.selectedCountryCode)){return $.selectedCountryCode}return H}));var Q=function(n){var r=n.isGuaranteed,e=n.maxAge;if($.exchangeRateTimeout){clearTimeout($.exchangeRateTimeout)}var t=5*60;var o=e||t;$.exchangeRateTimeout=setTimeout((function(){return __awaiter(s,void 0,void 0,(function(){var n;return __generator(this,(function(e){switch(e.label){case 0:return[4,q(r)];case 1:n=e.sent().maxAge;Q({isGuaranteed:r,maxAge:n});return[2]}}))}))}),o*1e3)};var W=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,t,o,i,a,c,s;return __generator(this,(function(l){switch(l.label){case 0:u("get new localization store");r=$.isDisabledCountry,t=$.isShippableCountry,o=$.selectedCountryCode;if(e.helloSettings.currencyBehavior==="DISABLED"||!t||r||!o){return[2]}i=e.checkoutSettings.visibilityStatus==="ENABLED";O();return[4,q(i)];case 1:a=l.sent().maxAge;Q({isGuaranteed:i,maxAge:a});if(!!window.Zonos.isLegacyCheckout)return[3,4];c=$;return[4,g($.selectedCountryCode)];case 2:c.countryLandedCost=l.sent();s=$;return[4,b(o)];case 3:s.inclusivePricing=((n=l.sent())===null||n===void 0?void 0:n.setting)||null;if($.inclusivePricing){u("Inclusive price setting found for this country (".concat(o,") ").concat(JSON.stringify($.inclusivePricing,null,2)))}return[3,5];case 4:u("Skipping country landed cost and inclusive pricing requests, because this is a legacy checkout");l.label=5;case 5:return[2]}}))}))};var X=function(){return __awaiter(s,void 0,void 0,(function(){var n,r;return __generator(this,(function(t){switch(t.label){case 0:u("Getting custom messages for ".concat($.selectedCountryCode));if(!$.selectedCountryCode||!e.storeId){return[2]}return[4,z({countryCode:$.selectedCountryCode,localeTo:$.selectedLocale,storeId:e.storeId})];case 1:n=t.sent();r=n.flatMap((function(n){var r;return{countryCode:$.selectedCountryCode,message:(r=n.countryCodesPageMessageLinks.find(Boolean))===null||r===void 0?void 0:r.message.textTo,pageName:n.pageName}}));$.customMessages=r;return[2]}}))}))};var nn=function(){var n=new URL(window.location.href);var r=n.searchParams.get("zonosLocale");return r};var rn=function(){if($.isShippableCountry){document.body.classList.add("z-intl")}else{document.body.classList.remove("z-intl")}};var en=function(n){if(n==="UK"){return"GB"}return n};var tn=n("a",(function(n){var r,t;u("Updating selected country code to ".concat(n));var o=!$.selectedCountryCode;$.selectedCountryCode=en(n);var i=$.selectedCountryCode,a=$.shippingZoneCountries;var c=!!a&&!!i&&!!a[i]&&!e.disabledCountries.includes(i);$.isShippableCountry=c;u("".concat($.selectedCountryCode," is a shippable country: ").concat($.isShippableCountry));var s=!!i&&e.disabledCountries.includes(i);$.isDisabledCountry=s;u("".concat($.selectedCountryCode," is a disabled country: ").concat($.isDisabledCountry));rn();if(!i){return}var l=J(i);if(!o){(r=e.onCountryChange)===null||r===void 0?void 0:r.call(e,{countryCode:i,currencyCode:l,isShippableCountry:c})}if(!l){return}$.targetCurrency=l;void W();window.sessionStorage.setItem("zonos--country",i);K(i);(t=document.querySelector("zonos-hello"))===null||t===void 0?void 0:t.setAttribute("z-country",i)}));var on=function(n){var r=e.helloSettings.showCountryList;var t=$.shippingZoneCountries;if(!r||r==="ONLY_SHIPPABLE"){$.helloCountryList=t;return}if(r==="ALL"){$.helloCountryList=n;return}$.helloCountryList=r.reduce((function(r,e){var t;var o=n===null||n===void 0?void 0:n[e];return o?Object.assign(Object.assign({},r),(t={},t[e]=o,t)):r}),{})};var an=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e;return __generator(this,(function(t){switch(t.label){case 0:if(!y.checkoutSessionId){return[2,null]}return[4,o("/api/zonos-elements/update-checkout-session-metadata",{body:{id:y.checkoutSessionId,metadata:[{key:"language",value:$.selectedLocale}]},method:"POST"})];case 1:n=t.sent(),r=n.errors,e=n.json;if(r.length||!e){i("Error occurs when updating checkout session",JSON.stringify(r,null,2));return[2,{errors:r,json:e}]}return[2,{errors:[],json:e}]}}))}))};var un=n("p",(function(n){$.selectedLocale=n;c(n);void an();void X()}));var cn=n("e",(function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e,t,o,i,a,c,s;return __generator(this,(function(l){switch(l.label){case 0:return[4,Promise.all([h(),k(),L()])];case 1:n=l.sent(),r=n[0],e=n[1],t=n[2];o=e===null||e===void 0?void 0:e.reduce((function(n,e){var t;var o=r===null||r===void 0?void 0:r[e];return o?Object.assign(Object.assign({},n),(t={},t[e]=o,t)):n}),{});$.shippingZoneCountries=o||null;on(r||{});i=t.country,a=t.locale;u("Country code from localization: ".concat(i));u("Locale from localization: ".concat(a));tn(i);c=nn();un(c||a||"en");s=["dev.storybook.elements","dev.elements","dev.demo.elements","dev.dashboard"];if(!$.selectedCountryCode&&s.some((function(n){return window.location.origin.includes(n)}))){tn("CA")}$.localizationLoaded=true;return[2]}}))}))}))}}}));
1
+ var __awaiter=this&&this.__awaiter||function(n,r,e,t){function o(n){return n instanceof e?n:new e((function(r){r(n)}))}return new(e||(e=Promise))((function(e,i){function a(n){try{c(t.next(n))}catch(n){i(n)}}function u(n){try{c(t["throw"](n))}catch(n){i(n)}}function c(n){n.done?e(n.value):o(n.value).then(a,u)}c((t=t.apply(n,r||[])).next())}))};var __generator=this&&this.__generator||function(n,r){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(n){return function(r){return c([n,r])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(e=0)),e)try{if(t=1,o&&(i=u[0]&2?o["return"]:u[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;if(o=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:e.label++;return{value:u[1],done:false};case 5:e.label++;o=u[1];u=[0];continue;case 7:u=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){e.label=u[1];break}if(u[0]===6&&e.label<i[1]){e.label=i[1];i=u;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(u);break}if(i[2])e.ops.pop();e.trys.pop();continue}u=r.call(n,e)}catch(n){u=[6,n];o=0}finally{t=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-89c5164b.system.js","./p-01174496.system.js","./p-d938f42f.system.js","./p-b4fe3604.system.js"],(function(n){"use strict";var r,e,t,o,i,a,u,c;return{setters:[function(n){r=n.c;e=n.z},function(n){t=n.j;o=n.h;i=n.l},function(n){a=n.a;u=n.l},function(n){c=n.a}],execute:function(){var s=this;var l=function(n){var r=!!n.find((function(n){return n.testKey in a}));if(!r){u("No available test key found in response","info",{response:n})}return!!n.find((function(n){return n.testKey in a}))};var v=n("f",(function(n){if(!l(n)){return[]}return n.filter((function(n){var r;var e=a[n.testKey]&&!n.selectedVariantKey;var t=n.selectedVariantKey&&!!((r=a[n.testKey])===null||r===void 0?void 0:r["availableVariants"].includes(n.selectedVariantKey));return e||t})).map((function(n){return Object.assign(Object.assign({},n),{expiresAt:n.expiresAt||Date.now()+d,selectedVariantKey:n.selectedVariantKey||null})}))}));var d=n("V",60*60*24*1e3);var f=r({checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id"),enabledVariantTestKeys:t(localStorage.getItem("zonos--enabled-variant-test-keys"))}),w=f.onChange,y=f.state;n({o:w,s:y});w("enabledVariantTestKeys",(function(){var n;if(!((n=y.enabledVariantTestKeys)===null||n===void 0?void 0:n.length)){localStorage.removeItem("zonos--enabled-variant-test-keys");return}localStorage.setItem("zonos--enabled-variant-test-keys",JSON.stringify(y.enabledVariantTestKeys))}));w("checkoutSessionId",(function(){if(!y.checkoutSessionId){sessionStorage.removeItem("zonos--checkout-session-id");return}sessionStorage.setItem("zonos--checkout-session-id",y.checkoutSessionId)}));var m=n("b",(function(n){y.enabledVariantTestKeys=v(n)}));var h=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e,t;return __generator(this,(function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);return[4,o("/api/zonos-elements/get-countries",{method:"GET"})];case 1:n=i.sent(),r=n.errors,e=n.json;if(r.length||!e){return[2,null]}return[2,e];case 2:t=i.sent();return[2,null];case 3:return[2]}}))}))};var g=function(n){return __awaiter(s,void 0,void 0,(function(){var r,e,t,a,u;return __generator(this,(function(c){switch(c.label){case 0:if(!n){return[2,null]}e="/api/zonos-elements/country-landed-cost/".concat(n);return[4,o(e)];case 1:t=c.sent(),a=t.errors,u=t.json;if(a.length||!u){i("Error fetching country landed cost: ".concat((r=a.find(Boolean))===null||r===void 0?void 0:r.message));return[2,null]}return[2,u||null]}}))}))};var _={exchangeRate:{rate:1,targetFormat:{currencyCode:"USD",decimalDelimiter:".",scale:2,symbol:"$",symbolLocation:"before",thousandsDelimiter:","}},maxAge:null};var p=function(n){return __awaiter(s,[n],void 0,(function(n){var r,e,t,a,u,c,s,l,v,d;var f=n.country,w=n.isGuaranteed,y=n.sourceCurrency,m=n.targetCurrency;return __generator(this,(function(n){switch(n.label){case 0:if(y===m&&!w){return[2,_]}e=new URLSearchParams;e.set("sourceCurrency",y);e.set("targetCurrency",m);e.set("isGuaranteed",String(w));e.set("country",f||"");return[4,o("/api/zonos-elements/exchange-rates?".concat(e.toString()))];case 1:t=n.sent(),a=t.errors,u=t.json;if(a.length||!u){i("Error fetching country landed cost: ".concat((r=a.find(Boolean))===null||r===void 0?void 0:r.message));return[2,_]}c=u.exchangeRateCreate,s=c.rate,l=c.targetFormat;v=u.maxAge;if(s){sessionStorage.setItem(f+"_rate",JSON.stringify(s));d={rate:s,targetFormat:l};return[2,{exchangeRate:d,maxAge:v}]}return[2,_]}}))}))};var b=function(n){return __awaiter(s,void 0,void 0,(function(){var r,e,t,a;return __generator(this,(function(u){switch(u.label){case 0:if(!n){return[2,null]}return[4,o("/api/zonos-elements/inclusive-prices/".concat(n))];case 1:e=u.sent(),t=e.errors,a=e.json;if(t.length||!a){i("Error fetching country inclusive price setting: ".concat((r=t.find(Boolean))===null||r===void 0?void 0:r.message));return[2,null]}return[2,a||null]}}))}))};var z=function(n){return __awaiter(s,[n],void 0,(function(n){var r,e,t,a,u;var c=n.countryCode,s=n.localeTo,l=n.storeId;return __generator(this,(function(n){switch(n.label){case 0:e=new URLSearchParams;e.set("countryCode",c);e.set("storeId",l.toString());if(s){e.set("localeTo",s)}return[4,o("/api/zonos-elements/locale-messages?".concat(e.toString()))];case 1:t=n.sent(),a=t.errors,u=t.json;if(a.length||!u){i("Error fetching exchange rate",(r=a.find(Boolean))===null||r===void 0?void 0:r.message);return[2,[]]}return[2,u.locale_countryCodesPage]}}))}))};var S=function(n){if(n&&/^[A-Z]{2}$/.test(n)){return n}return null};var C=n("g",(function(n){var r=new URLSearchParams(n||window.location.search);var e=function(n){var e=r.get(n);return S(e)};var t=e("zCountry");var o=e("country");var i=e("customerCountry");return t||o||i}));var L=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e,t,i,a,u,c;return __generator(this,(function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);n=new URL(window.location.href);r=window.sessionStorage.getItem("zonos--country");e=C(n.searchParams)||r;t=new URLSearchParams;if(e){t.set("zCountry",e)}return[4,o("/api/zonos-elements/localization?".concat(t.toString()))];case 1:i=s.sent(),a=i.errors,u=i.json;if(a.length||!u){return[2,{country:null,locale:null}]}return[2,{country:u.country,locale:u.locale}];case 2:c=s.sent();return[2,{country:null,locale:null}];case 3:return[2]}}))}))};var k=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e,t,a,u,c;return __generator(this,(function(s){switch(s.label){case 0:if((n=window.Zonos.cartSettings)===null||n===void 0?void 0:n.shippingZones){return[2,window.Zonos.cartSettings.shippingZones.flatMap((function(n){return n===null||n===void 0?void 0:n.countryCodes})).filter(Boolean)]}return[4,o("/api/zonos-elements/shipping-zones")];case 1:t=s.sent(),a=t.errors,u=t.json;if(a.length||!u){i("Error fetching shipping zones: ".concat((r=a.find(Boolean))===null||r===void 0?void 0:r.message));return[2,null]}c=(e=u===null||u===void 0?void 0:u.shippingZones)===null||e===void 0?void 0:e.flatMap((function(n){return n===null||n===void 0?void 0:n.countryCodes})).filter(Boolean);return[2,c||null]}}))}))};var I=n("m",(function(n){var r=$.exchangeRate;if(!r||!n||isNaN(n)){return n}var e=(r===null||r===void 0?void 0:r.targetFormat.scale)||2;var t=n*r.rate;var o=t.toFixed(e);return Number(o)}));var A=function(n){var r=n.amount,e=n.currency,t=n.targetFormat;var o=e||$.targetCurrency;var i=(t===null||t===void 0?void 0:t.scale)||2;var a=window.navigator.userAgent.indexOf("MSIE ")!==-1;var u=typeof Intl==="object"&&Intl&&typeof Intl.NumberFormat==="function";if(a||!u){var c=Number(r).toFixed(i).replace(".","|dec|").replace(",",(t===null||t===void 0?void 0:t.thousandsDelimiter)||"").replace("|dec|",(t===null||t===void 0?void 0:t.decimalDelimiter)||"");return c}var s=new Intl.NumberFormat(window.navigator.language,{currency:o,currencyDisplay:"code",minimumFractionDigits:i,style:"currency"}).format(r);return s.replace(new RegExp("".concat(o,"\\s+")),"")};var E=n("d",(function(n){var r=n.amount,t=n.currency;if(isNaN(r)||r!==0&&!r){return""}var o=e.overrideCurrencyFormat;var i=$.exchangeRate;var a=t||$.targetCurrency;if(typeof o==="function"){return o({amount:r,currencyCode:a,numberFormat:function(n){var r=n.amount;return A({amount:r,currency:a,targetFormat:(i===null||i===void 0?void 0:i.targetFormat)||null})}})}var u=(i||{}).targetFormat;if(!u||!i){return"".concat(r.toFixed(2)," ").concat(a)}var c=u.scale||2;var s=window.navigator.userAgent.indexOf("MSIE ")!==-1;var l=typeof Intl==="object"&&Intl&&typeof Intl.NumberFormat==="function";if(s||!l){var v=Number(r).toFixed(c).replace(".","|dec|").replace(",",u.thousandsDelimiter||"").replace("|dec|",u.decimalDelimiter||"");var d="".concat(v).concat(u.currencyCode!=="USD"?" ".concat(u.currencyCode):"");return d}var f=(o===null||o===void 0?void 0:o.currencyDisplay)||"symbol";var w=new Intl.NumberFormat(window.navigator.language,{currency:a,currencyDisplay:f,minimumFractionDigits:c,style:"currency"}).format(r);var y=f==="code"?"".concat(w.replace(new RegExp("".concat(a,"\\s+")),"")," ").concat(a):w;return y}));var N=n("k",(function(n){var r=I(n);var e=E({amount:r});return e}));var x=n("i",(function(n){try{document.createDocumentFragment().querySelector(n)}catch(n){return false}return true}));var D=function(n){var r=n||".money";if(!x(r)){i('Currency element selector "'.concat(r,'" is not valid.'));return null}var e=document.querySelectorAll(r);if(!e.length){u('No currency elements found with selector "'.concat(r,'"'),"warn");return null}return Array.from(e)};var j=function(n){var r;var e=n.getAttribute("data-domestic");var t=n.getAttribute("data-zintl");var o=(r=n.textContent)===null||r===void 0?void 0:r.replace(/[^\d.-]/g,"");if(!o){return null}if(!e||n.textContent!==t&&t){n.setAttribute("data-domestic",o);return parseFloat(o)}return parseFloat(e)};var B=7e3;var R="z--blur";var P=function(){return __awaiter(s,void 0,void 0,(function(){var n,r;return __generator(this,(function(e){switch(e.label){case 0:n=window.zonosBlurCurrencyOnInitIntervalId;if(!n){return[2]}return[4,new Promise((function(n){return setTimeout(n,500)}))];case 1:e.sent();clearInterval(n);r=document.querySelectorAll(".".concat(R));r.forEach((function(n){n.classList.remove(R)}));window.zonosBlurCurrencyOnInitIntervalId=undefined;return[2]}}))}))};var U=function(n){var r=n.currencySelector;if(!r){return}var e=document.querySelectorAll([r].filter(Boolean).join(","));e.forEach((function(n){n.classList.add(R)}))};var O=function(){if(typeof window==="undefined"){return}if(window.zonosBlurCurrencyOnInitIntervalId){return}U({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});var n=setInterval((function(){U({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})}),10);window.zonosBlurCurrencyOnInitIntervalId=n;setTimeout((function(){void P()}),B)};var T=function(n){var r;var t=j(n);if(!t||isNaN(t)){return}var o=n.getAttribute("data-zintl");var i=parseFloat(n.getAttribute("data-zrate")||"1");var a=n.getAttribute("data-zcountry-code");var u=$.exchangeRate&&$.targetCurrency===$.exchangeRate.targetFormat.currencyCode;var c=((r=$.exchangeRate)===null||r===void 0?void 0:r.rate)||1;if(u&&(n.textContent!==o||c!==i||a!==$.selectedCountryCode)){O();var s=typeof e.currencyConverter==="function"&&e.currencyConverter({convert:I,convertAndFormat:N,currencyCode:$.targetCurrency,format:function(n){return E({amount:n})},originalAmount:t,selector:n});var l=s||N(t);if(l!==n.textContent){n.textContent=l}n.setAttribute("data-zrate",c.toString());n.setAttribute("data-zintl",l);n.setAttribute("data-zcountry-code",$.selectedCountryCode||"")}void P()};var F=function(){var n=e.helloSettings.currencyElementSelector;var r=D(n);if(!(r===null||r===void 0?void 0:r.length)){return}if(!$.exchangeRate){i("Could not display currency. Exchange rate and format data is not available.");return}r.forEach((function(n){T(n)}))};var G=n("j",(function(){if(e.helloSettings.currencyBehavior==="DISABLED"||window.Zonos.isLegacyCheckout){void P();return}F()}));var J=function(n){var r;var e=(r=$.shippingZoneCountries)===null||r===void 0?void 0:r[n];if(e){return e.currencyCode}return null};var K=n("h",(function(n){if(!n){return}var r=new URLSearchParams(window.location.search);var t=r.has("zCountry")||e.helloSettings.countryOverrideBehavior==="URL_PARAM";if(t){r.set("zCountry",n);var o="".concat(window.location.pathname,"?").concat(r.toString());window.history.replaceState(window.history.state,document.title,o)}}));var M=r({countryLandedCost:null,customMessages:[],exchangeRate:null,helloCountryList:null,inclusivePricing:null,isDisabledCountry:true,isShippableCountry:false,localizationLoaded:false,selectedCountryCode:null,selectedLocale:"en",shippingZoneCountries:null,targetCurrency:"USD"}),V=M.dispose,Z=M.onChange,$=M.state;n({c:Z,l:$});var q=function(n){return __awaiter(s,void 0,void 0,(function(){var r,t,o;return __generator(this,(function(i){switch(i.label){case 0:return[4,p({country:$.selectedCountryCode,isGuaranteed:n,sourceCurrency:e.sourceCurrency,targetCurrency:$.targetCurrency})];case 1:r=i.sent(),t=r.exchangeRate,o=r.maxAge;if(t){$.exchangeRate=t;G()}return[2,{maxAge:o}]}}))}))};var H="CA";var Y=n("n",(function(n){if($.selectedCountryCode&&n.includes($.selectedCountryCode)){return $.selectedCountryCode}return H}));var Q=function(n){var r=n.isGuaranteed,e=n.maxAge;if($.exchangeRateTimeout){clearTimeout($.exchangeRateTimeout)}var t=5*60;var o=e||t;$.exchangeRateTimeout=setTimeout((function(){return __awaiter(s,void 0,void 0,(function(){var n;return __generator(this,(function(e){switch(e.label){case 0:return[4,q(r)];case 1:n=e.sent().maxAge;Q({isGuaranteed:r,maxAge:n});return[2]}}))}))}),o*1e3)};var W=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,t,o,i,a,c,s;return __generator(this,(function(l){switch(l.label){case 0:u("get new localization store");r=$.isDisabledCountry,t=$.isShippableCountry,o=$.selectedCountryCode;if(e.helloSettings.currencyBehavior==="DISABLED"||!t||r||!o){return[2]}i=e.checkoutSettings.visibilityStatus==="ENABLED";O();return[4,q(i)];case 1:a=l.sent().maxAge;Q({isGuaranteed:i,maxAge:a});if(!!window.Zonos.isLegacyCheckout)return[3,4];c=$;return[4,g($.selectedCountryCode)];case 2:c.countryLandedCost=l.sent();s=$;return[4,b(o)];case 3:s.inclusivePricing=((n=l.sent())===null||n===void 0?void 0:n.setting)||null;if($.inclusivePricing){u("Inclusive price setting found for this country (".concat(o,") ").concat(JSON.stringify($.inclusivePricing,null,2)))}return[3,5];case 4:u("Skipping country landed cost and inclusive pricing requests, because this is a legacy checkout");l.label=5;case 5:return[2]}}))}))};var X=function(){return __awaiter(s,void 0,void 0,(function(){var n,r;return __generator(this,(function(t){switch(t.label){case 0:u("Getting custom messages for ".concat($.selectedCountryCode));if(!$.selectedCountryCode||!e.storeId){return[2]}return[4,z({countryCode:$.selectedCountryCode,localeTo:$.selectedLocale,storeId:e.storeId})];case 1:n=t.sent();r=n.flatMap((function(n){var r;return{countryCode:$.selectedCountryCode,message:(r=n.countryCodesPageMessageLinks.find(Boolean))===null||r===void 0?void 0:r.message.textTo,pageName:n.pageName}}));$.customMessages=r;return[2]}}))}))};var nn=function(){var n=new URL(window.location.href);var r=n.searchParams.get("zonosLocale");return r};var rn=function(){if($.isShippableCountry){document.body.classList.add("z-intl")}else{document.body.classList.remove("z-intl")}};var en=function(n){if(n==="UK"){return"GB"}return n};var tn=n("a",(function(n){var r,t;u("Updating selected country code to ".concat(n));var o=!$.selectedCountryCode;$.selectedCountryCode=en(n);var i=$.selectedCountryCode,a=$.shippingZoneCountries;var c=!!a&&!!i&&!!a[i]&&!e.disabledCountries.includes(i);$.isShippableCountry=c;u("".concat($.selectedCountryCode," is a shippable country: ").concat($.isShippableCountry));var s=!!i&&e.disabledCountries.includes(i);$.isDisabledCountry=s;u("".concat($.selectedCountryCode," is a disabled country: ").concat($.isDisabledCountry));rn();if(!i){return}var l=J(i);if(!o){(r=e.onCountryChange)===null||r===void 0?void 0:r.call(e,{countryCode:i,currencyCode:l,isShippableCountry:c})}if(!l){return}$.targetCurrency=l;void W();window.sessionStorage.setItem("zonos--country",i);K(i);(t=document.querySelector("zonos-hello"))===null||t===void 0?void 0:t.setAttribute("z-country",i)}));var on=function(n){var r=e.helloSettings.showCountryList;var t=$.shippingZoneCountries;if(!r||r==="ONLY_SHIPPABLE"){$.helloCountryList=t;return}if(r==="ALL"){$.helloCountryList=n;return}$.helloCountryList=r.reduce((function(r,e){var t;var o=n===null||n===void 0?void 0:n[e];return o?Object.assign(Object.assign({},r),(t={},t[e]=o,t)):r}),{})};var an=function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e;return __generator(this,(function(t){switch(t.label){case 0:if(!y.checkoutSessionId){return[2,null]}return[4,o("/api/zonos-elements/update-checkout-session-metadata",{body:{id:y.checkoutSessionId,metadata:[{key:"language",value:$.selectedLocale}]},method:"POST"})];case 1:n=t.sent(),r=n.errors,e=n.json;if(r.length||!e){i("Error occurs when updating checkout session",JSON.stringify(r,null,2));return[2,{errors:r,json:e}]}return[2,{errors:[],json:e}]}}))}))};var un=n("p",(function(n){$.selectedLocale=n;c(n);void an();void X()}));var cn=n("e",(function(){return __awaiter(s,void 0,void 0,(function(){var n,r,e,t,o,i,a,c,s;return __generator(this,(function(l){switch(l.label){case 0:return[4,Promise.all([h(),k(),L()])];case 1:n=l.sent(),r=n[0],e=n[1],t=n[2];o=e===null||e===void 0?void 0:e.reduce((function(n,e){var t;var o=r===null||r===void 0?void 0:r[e];return o?Object.assign(Object.assign({},n),(t={},t[e]=o,t)):n}),{});$.shippingZoneCountries=o||null;on(r||{});i=t.country,a=t.locale;u("Country code from localization: ".concat(i));u("Locale from localization: ".concat(a));tn(i);c=nn();un(c||a||"en");s=["dev.storybook.elements","dev.elements","dev.demo.elements","dev.dashboard"];if(!$.selectedCountryCode&&s.some((function(n){return window.location.origin.includes(n)}))){tn("CA")}$.localizationLoaded=true;return[2]}}))}))}))}}}));
@@ -1 +1 @@
1
- import{r as e,h as o,H as s}from"./p-b30c2ad9.js";import{p as t,l as a}from"./p-7eb8e2d4.js";import{t as n}from"./p-d42b5113.js";import{f as l}from"./p-7af39c98.js";import{l as i}from"./p-97aceb11.js";import"./p-41dd1cb8.js";import"./p-0a377722.js";const c=class{constructor(o){e(this,o),this.handleOnClose=()=>{},this.languageSelected=e=>{t(e),this.handleOnClose()}}render(){const{selectedLocale:e}=a;return o(s,{key:"232674c6f35113c6ad3f1094e6e6d4128b4d4c02",class:"zonos--elements",style:{"--zonos--font-family":l()}},o("div",{key:"014d1364e165e4ee4e9cf304791fc10fdfb6d87c",class:"zonos--language-select"},o("zonos-select-dialog-header",{key:"65b454467b033cd061ab08693e857eed75c76511",handleOnClose:()=>this.handleOnClose(),label:n("Select a language")}),o("div",{key:"6ea8fca0b44ada24b9b2b84e22584ba1a7459dc4",class:"zonos--language-select-content"},i.map((s=>o("button",{class:"zonos--language-select-button",onClick:()=>this.languageSelected(s.code)},o("zonos-text",{textColor:"gray-800"},s.translatedLabel),s.code===e&&o("zonos-icon",{content:'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M7.99996 2.6665C5.05444 2.6665 2.66663 5.05432 2.66663 7.99984C2.66663 10.9454 5.05444 13.3332 7.99996 13.3332C10.9455 13.3332 13.3333 10.9454 13.3333 7.99984C13.3333 5.05432 10.9455 2.6665 7.99996 2.6665Z" fill="#AFF8C3"/>\n<path fill-rule="evenodd" clip-rule="evenodd" d="M10.1403 6.10535C10.3582 6.27488 10.3975 6.58902 10.228 6.80699L8.01055 9.65797C7.76436 9.97449 7.29646 10.0036 7.01291 9.72008L5.81307 8.52024C5.61781 8.32498 5.61781 8.0084 5.81307 7.81314C6.00833 7.61787 6.32492 7.61787 6.52018 7.81314L7.45301 8.74597L9.43862 6.19305C9.60815 5.97508 9.92229 5.93581 10.1403 6.10535Z" fill="#246627"/>\n</svg>\n',size:16})))))))}};c.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--language-select{width:100%}:host .zonos--language-select .zonos--language-select-content{display:grid;grid-template-columns:repeat(3, minmax(-webkit-max-content, 1fr));grid-template-columns:repeat(3, minmax(max-content, 1fr));padding:16px;padding-top:0px}:host .zonos--language-select .zonos--language-select-content .zonos--language-select-button{display:-ms-flexbox;display:flex;padding:8px;gap:4px;-ms-flex-align:center;align-items:center;border-radius:var(--zonos-elements-radius-4);cursor:pointer;width:100%;border:none;background:none}:host .zonos--language-select .zonos--language-select-content .zonos--language-select-button:hover{background:var(--zonos-elements-gray-100)}@media (max-width: 400px){:host .zonos--language-select .zonos--language-select-content{grid-template-columns:1fr 1fr}}";const d=class{constructor(o){e(this,o),this.handleOnClose=()=>{},this.label=""}render(){return o(s,{key:"cc65559ef7867bbd8e7990556b50434faa0a905c",class:"zonos--elements",style:{"--zonos--font-family":l()}},o("zonos-v-stack",{key:"77c280b12744520b4a172193f88798aa53d33eb7",class:"zonos--select-dialog-header-wrapper",spacing:8},o("div",{key:"eaba9d1e50f71f23e330e989521d2156a617b22d",class:"zonos--select-dialog-header"},o("zonos-text",{key:"ddddc6b5bca87cf44cbc7428d402f44c67422cb6",type:"boldLabel"},this.label),o("zonos-button",{key:"313e3955ba8bafc9a1b36b4c1c8f99e975fb8dd3",class:"zonos--close-button",icon:o("zonos-icon",{"aria-label":"Close select dialog",content:'<svg xmlns="https://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path fill="#C5C6CA" fill-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" clip-rule="evenodd"/><path fill="#4D505A" fill-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" clip-rule="evenodd"/></svg>',size:20}),noBackground:!0,onClick:()=>this.handleOnClose()})),o("slot",{key:"9af2821c22f3e37d52b6f03bf544fcaca1c0ed7b"})))}};d.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--select-dialog-header-wrapper{position:-webkit-sticky;position:sticky;top:0;background:var(--zonos-elements-surface-color);padding:16px}:host .zonos--select-dialog-header-wrapper .zonos--select-dialog-header{position:relative;-ms-flex-pack:justify;justify-content:space-between;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}";export{c as zonos_language_select,d as zonos_select_dialog_header}
1
+ import{r as e,h as o,H as s}from"./p-b30c2ad9.js";import{p as t,l as a}from"./p-c3c3cd98.js";import{t as n}from"./p-eea0d8af.js";import{f as l}from"./p-7af39c98.js";import{l as i}from"./p-97aceb11.js";import"./p-41dd1cb8.js";import"./p-0a377722.js";const c=class{constructor(o){e(this,o),this.handleOnClose=()=>{},this.languageSelected=e=>{t(e),this.handleOnClose()}}render(){const{selectedLocale:e}=a;return o(s,{key:"232674c6f35113c6ad3f1094e6e6d4128b4d4c02",class:"zonos--elements",style:{"--zonos--font-family":l()}},o("div",{key:"014d1364e165e4ee4e9cf304791fc10fdfb6d87c",class:"zonos--language-select"},o("zonos-select-dialog-header",{key:"65b454467b033cd061ab08693e857eed75c76511",handleOnClose:()=>this.handleOnClose(),label:n("Select a language")}),o("div",{key:"6ea8fca0b44ada24b9b2b84e22584ba1a7459dc4",class:"zonos--language-select-content"},i.map((s=>o("button",{class:"zonos--language-select-button",onClick:()=>this.languageSelected(s.code)},o("zonos-text",{textColor:"gray-800"},s.translatedLabel),s.code===e&&o("zonos-icon",{content:'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M7.99996 2.6665C5.05444 2.6665 2.66663 5.05432 2.66663 7.99984C2.66663 10.9454 5.05444 13.3332 7.99996 13.3332C10.9455 13.3332 13.3333 10.9454 13.3333 7.99984C13.3333 5.05432 10.9455 2.6665 7.99996 2.6665Z" fill="#AFF8C3"/>\n<path fill-rule="evenodd" clip-rule="evenodd" d="M10.1403 6.10535C10.3582 6.27488 10.3975 6.58902 10.228 6.80699L8.01055 9.65797C7.76436 9.97449 7.29646 10.0036 7.01291 9.72008L5.81307 8.52024C5.61781 8.32498 5.61781 8.0084 5.81307 7.81314C6.00833 7.61787 6.32492 7.61787 6.52018 7.81314L7.45301 8.74597L9.43862 6.19305C9.60815 5.97508 9.92229 5.93581 10.1403 6.10535Z" fill="#246627"/>\n</svg>\n',size:16})))))))}};c.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--language-select{width:100%}:host .zonos--language-select .zonos--language-select-content{display:grid;grid-template-columns:repeat(3, minmax(-webkit-max-content, 1fr));grid-template-columns:repeat(3, minmax(max-content, 1fr));padding:16px;padding-top:0px}:host .zonos--language-select .zonos--language-select-content .zonos--language-select-button{display:-ms-flexbox;display:flex;padding:8px;gap:4px;-ms-flex-align:center;align-items:center;border-radius:var(--zonos-elements-radius-4);cursor:pointer;width:100%;border:none;background:none}:host .zonos--language-select .zonos--language-select-content .zonos--language-select-button:hover{background:var(--zonos-elements-gray-100)}@media (max-width: 400px){:host .zonos--language-select .zonos--language-select-content{grid-template-columns:1fr 1fr}}";const d=class{constructor(o){e(this,o),this.handleOnClose=()=>{},this.label=""}render(){return o(s,{key:"cc65559ef7867bbd8e7990556b50434faa0a905c",class:"zonos--elements",style:{"--zonos--font-family":l()}},o("zonos-v-stack",{key:"77c280b12744520b4a172193f88798aa53d33eb7",class:"zonos--select-dialog-header-wrapper",spacing:8},o("div",{key:"eaba9d1e50f71f23e330e989521d2156a617b22d",class:"zonos--select-dialog-header"},o("zonos-text",{key:"ddddc6b5bca87cf44cbc7428d402f44c67422cb6",type:"boldLabel"},this.label),o("zonos-button",{key:"313e3955ba8bafc9a1b36b4c1c8f99e975fb8dd3",class:"zonos--close-button",icon:o("zonos-icon",{"aria-label":"Close select dialog",content:'<svg xmlns="https://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path fill="#C5C6CA" fill-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" clip-rule="evenodd"/><path fill="#4D505A" fill-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" clip-rule="evenodd"/></svg>',size:20}),noBackground:!0,onClick:()=>this.handleOnClose()})),o("slot",{key:"9af2821c22f3e37d52b6f03bf544fcaca1c0ed7b"})))}};d.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--select-dialog-header-wrapper{position:-webkit-sticky;position:sticky;top:0;background:var(--zonos-elements-surface-color);padding:16px}:host .zonos--select-dialog-header-wrapper .zonos--select-dialog-header{position:relative;-ms-flex-pack:justify;justify-content:space-between;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}";export{c as zonos_language_select,d as zonos_select_dialog_header}
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(n,e,t,i){function r(n){return n instanceof t?n:new t((function(e){e(n)}))}return new(t||(t=Promise))((function(t,o){function a(n){try{d(i.next(n))}catch(n){o(n)}}function u(n){try{d(i["throw"](n))}catch(n){o(n)}}function d(n){n.done?t(n.value):r(n.value).then(a,u)}d((i=i.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,r,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(n){return function(e){return d([n,e])}}function d(u){if(i)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(t=0)),t)try{if(i=1,r&&(o=u[0]&2?r["return"]:u[0]?r["throw"]||((o=r["return"])&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;if(r=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:t.label++;return{value:u[1],done:false};case 5:t.label++;r=u[1];u=[0];continue;case 7:u=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){t.label=u[1];break}if(u[0]===6&&t.label<o[1]){t.label=o[1];o=u;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(u);break}if(o[2])t.ops.pop();t.trys.pop();continue}u=e.call(n,t)}catch(n){u=[6,n];r=0}finally{i=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-89c5164b.system.js","./p-725605f6.system.js","./p-b5b3f908.system.js","./p-01174496.system.js","./p-d938f42f.system.js","./p-5fc34563.system.js"],(function(n){"use strict";var e,t,i,r,o,a,u,d,s,l,c,f;return{setters:[function(n){e=n.c;t=n.z},function(n){i=n.c;r=n.B;o=n.e;a=n.C},function(n){u=n.s},function(n){d=n.h;s=n.s;l=n.l},function(n){c=n.b},function(n){f=n.h}],execute:function(){var v=this;var p=e((function(){return{amountDutyTaxFeeTotal:null,amountTotalPaid:null,isFetchingShippingInfo:true,landedCostShortId:null,originCompanyName:null,partyBillingId:null,shippingAddress:null}})),h=p.reset,w=p.state;n("e",w);var m=n("b",(function(n){return __awaiter(v,[n],void 0,(function(n){var e,i,r,a,u,l,c,f,v,p,h,_,y;var C=n.landedCostId,g=n.retries,I=g===void 0?5:g;return __generator(this,(function(n){switch(n.label){case 0:w.isFetchingShippingInfo=true;return[4,d("/api/zonos-elements/collect/get-shipping-info-by-lc-id",{body:{landedCostId:C},method:"POST"})];case 1:p=n.sent();if(!p.errors.length)return[3,4];if(!(I>0))return[3,3];return[4,new Promise((function(n){return setTimeout(n,1e3)}))];case 2:n.sent();return[2,m({landedCostId:C,retries:I-1})];case 3:return[2,null];case 4:w.landedCostShortId=((e=p.json)===null||e===void 0?void 0:e.landedCostShortId)||null;w.isFetchingShippingInfo=false;w.shippingAddress=((i=p.json)===null||i===void 0?void 0:i.shipping)||null;h=(r=o.checkoutSession)===null||r===void 0?void 0:r.landedCost;_=(a=o.checkoutSession)===null||a===void 0?void 0:a.subtotals;y=(((u=h===null||h===void 0?void 0:h.amountSubtotals)===null||u===void 0?void 0:u.shipping)||0)+(((l=h===null||h===void 0?void 0:h.amountSubtotals)===null||l===void 0?void 0:l.items)||0);w.amountTotalPaid=y*(((c=_===null||_===void 0?void 0:_.exchangeRate)===null||c===void 0?void 0:c.rate)||1);w.amountDutyTaxFeeTotal=((_===null||_===void 0?void 0:_.duties)||0)+((_===null||_===void 0?void 0:_.taxes)||0)+((_===null||_===void 0?void 0:_.fees)||0);w.originCompanyName=((v=(f=p.json)===null||f===void 0?void 0:f.origin)===null||v===void 0?void 0:v.companyName)||null;if(w.amountTotalPaid===0){void s({endpoint:"COLLECT_NO_TOTAL_PAID",errors:[],metadata:{landedCostId:C,organizationId:t.organizationId}})}return[2]}}))}))}));var _=n("d",(function(){return __awaiter(v,void 0,void 0,(function(){var n,e,t,a,f,v,p,h,m,_;return __generator(this,(function(y){switch(y.label){case 0:if(!((n=i.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete)){return[2,{partiesCreated:false}]}f=(t=(e=o.checkoutSession)===null||e===void 0?void 0:e.landedCost)===null||t===void 0?void 0:t.rootId;if(!f){void s({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:u.checkoutSessionId}});return[2,{partiesCreated:false}]}if(!u.checkoutSessionId){void s({endpoint:"COLLECT_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:c,cartId:window.Zonos.cartId,landedCostRootId:f}});return[2,{partiesCreated:false}]}v=r({address:i.stripeBillingAddressEventData.value.address,firstName:i.stripeBillingAddressEventData.value.firstName,lastName:i.stripeBillingAddressEventData.value.lastName,name:i.stripeBillingAddressEventData.value.name,phone:i.stripeBillingAddressEventData.value.phone});p=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,d("/api/zonos-elements/create-billing-party",{body:{billingAddress:v,checkoutSessionId:u.checkoutSessionId,companyName:i.companyName,email:((a=i.stripeLinkEventData)===null||a===void 0?void 0:a.value.email)||"",isTest:p,rootId:f},method:"POST"})];case 1:h=y.sent(),m=h.errors,_=h.json;if(m.length||!_){l("Error occurs when creating billing party",JSON.stringify(m,null,2));void s({endpoint:"COLLECT_BILLING_PARTY_CREATE_FAILED",errors:["[COLLECT] Failed to create billing party"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:u.checkoutSessionId,errors:m,json:_}});return[2,{partiesCreated:false}]}w.partyBillingId=_.billToPartyId;return[2,{partiesCreated:true}]}}))}))}));var y=n("c",(function(n){return __awaiter(v,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=n.landedCost;if(!e){return[2,false]}o.landedCostData=[Object.assign(Object.assign({},n),{landedCost:Object.assign({},e),landedCostId:e.id})];return[2,a({applySubtotalsOnly:true,landedCostId:e.id,selectedShippingOption:e.shipmentRating})]}))}))}));var C=1024;var g=768;var I=n("a",(function(n){return n||window.innerWidth<C&&window.innerWidth>=g}));var b=n("i",(function(n){return n||window.innerWidth<g}));var T=n("r",(function(n){var e=n.content,t=n.isLoading,i=n.skeletonHeight,r=n.skeletonWidth;if(t){return f("zonos-skeleton",{skeletonHeight:i,skeletonWidth:r})}return e}))}}}));
1
+ var __awaiter=this&&this.__awaiter||function(n,e,t,i){function r(n){return n instanceof t?n:new t((function(e){e(n)}))}return new(t||(t=Promise))((function(t,o){function a(n){try{d(i.next(n))}catch(n){o(n)}}function u(n){try{d(i["throw"](n))}catch(n){o(n)}}function d(n){n.done?t(n.value):r(n.value).then(a,u)}d((i=i.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,r,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(n){return function(e){return d([n,e])}}function d(u){if(i)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(t=0)),t)try{if(i=1,r&&(o=u[0]&2?r["return"]:u[0]?r["throw"]||((o=r["return"])&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;if(r=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:t.label++;return{value:u[1],done:false};case 5:t.label++;r=u[1];u=[0];continue;case 7:u=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){t.label=u[1];break}if(u[0]===6&&t.label<o[1]){t.label=o[1];o=u;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(u);break}if(o[2])t.ops.pop();t.trys.pop();continue}u=e.call(n,t)}catch(n){u=[6,n];r=0}finally{i=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-89c5164b.system.js","./p-cdaf52f4.system.js","./p-cef1e888.system.js","./p-01174496.system.js","./p-d938f42f.system.js","./p-5fc34563.system.js"],(function(n){"use strict";var e,t,i,r,o,a,u,d,s,l,c,f;return{setters:[function(n){e=n.c;t=n.z},function(n){i=n.c;r=n.C;o=n.e;a=n.D},function(n){u=n.s},function(n){d=n.h;s=n.s;l=n.l},function(n){c=n.b},function(n){f=n.h}],execute:function(){var v=this;var p=e((function(){return{amountDutyTaxFeeTotal:null,amountTotalPaid:null,isFetchingShippingInfo:true,landedCostShortId:null,originCompanyName:null,partyBillingId:null,shippingAddress:null}})),h=p.reset,w=p.state;n("e",w);var m=n("b",(function(n){return __awaiter(v,[n],void 0,(function(n){var e,i,r,a,u,l,c,f,v,p,h,_,y;var C=n.landedCostId,g=n.retries,I=g===void 0?5:g;return __generator(this,(function(n){switch(n.label){case 0:w.isFetchingShippingInfo=true;return[4,d("/api/zonos-elements/collect/get-shipping-info-by-lc-id",{body:{landedCostId:C},method:"POST"})];case 1:p=n.sent();if(!p.errors.length)return[3,4];if(!(I>0))return[3,3];return[4,new Promise((function(n){return setTimeout(n,1e3)}))];case 2:n.sent();return[2,m({landedCostId:C,retries:I-1})];case 3:return[2,null];case 4:w.landedCostShortId=((e=p.json)===null||e===void 0?void 0:e.landedCostShortId)||null;w.isFetchingShippingInfo=false;w.shippingAddress=((i=p.json)===null||i===void 0?void 0:i.shipping)||null;h=(r=o.checkoutSession)===null||r===void 0?void 0:r.landedCost;_=(a=o.checkoutSession)===null||a===void 0?void 0:a.subtotals;y=(((u=h===null||h===void 0?void 0:h.amountSubtotals)===null||u===void 0?void 0:u.shipping)||0)+(((l=h===null||h===void 0?void 0:h.amountSubtotals)===null||l===void 0?void 0:l.items)||0);w.amountTotalPaid=y*(((c=_===null||_===void 0?void 0:_.exchangeRate)===null||c===void 0?void 0:c.rate)||1);w.amountDutyTaxFeeTotal=((_===null||_===void 0?void 0:_.duties)||0)+((_===null||_===void 0?void 0:_.taxes)||0)+((_===null||_===void 0?void 0:_.fees)||0);w.originCompanyName=((v=(f=p.json)===null||f===void 0?void 0:f.origin)===null||v===void 0?void 0:v.companyName)||null;if(w.amountTotalPaid===0){void s({endpoint:"COLLECT_NO_TOTAL_PAID",errors:[],metadata:{landedCostId:C,organizationId:t.organizationId}})}return[2]}}))}))}));var _=n("d",(function(){return __awaiter(v,void 0,void 0,(function(){var n,e,t,a,f,v,p,h,m,_;return __generator(this,(function(y){switch(y.label){case 0:if(!((n=i.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete)){return[2,{partiesCreated:false}]}f=(t=(e=o.checkoutSession)===null||e===void 0?void 0:e.landedCost)===null||t===void 0?void 0:t.rootId;if(!f){void s({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:u.checkoutSessionId}});return[2,{partiesCreated:false}]}if(!u.checkoutSessionId){void s({endpoint:"COLLECT_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:c,cartId:window.Zonos.cartId,landedCostRootId:f}});return[2,{partiesCreated:false}]}v=r({address:i.stripeBillingAddressEventData.value.address,firstName:i.stripeBillingAddressEventData.value.firstName,lastName:i.stripeBillingAddressEventData.value.lastName,name:i.stripeBillingAddressEventData.value.name,phone:i.stripeBillingAddressEventData.value.phone});p=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,d("/api/zonos-elements/create-billing-party",{body:{billingAddress:v,checkoutSessionId:u.checkoutSessionId,companyName:i.companyName,email:((a=i.stripeLinkEventData)===null||a===void 0?void 0:a.value.email)||"",isTest:p,rootId:f},method:"POST"})];case 1:h=y.sent(),m=h.errors,_=h.json;if(m.length||!_){l("Error occurs when creating billing party",JSON.stringify(m,null,2));void s({endpoint:"COLLECT_BILLING_PARTY_CREATE_FAILED",errors:["[COLLECT] Failed to create billing party"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:u.checkoutSessionId,errors:m,json:_}});return[2,{partiesCreated:false}]}w.partyBillingId=_.billToPartyId;return[2,{partiesCreated:true}]}}))}))}));var y=n("c",(function(n){return __awaiter(v,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=n.landedCost;if(!e){return[2,false]}o.landedCostData=[Object.assign(Object.assign({},n),{landedCost:Object.assign({},e),landedCostId:e.id})];return[2,a({applySubtotalsOnly:true,landedCostId:e.id,selectedShippingOption:e.shipmentRating})]}))}))}));var C=1024;var g=768;var I=n("a",(function(n){return n||window.innerWidth<C&&window.innerWidth>=g}));var b=n("i",(function(n){return n||window.innerWidth<g}));var T=n("r",(function(n){var e=n.content,t=n.isLoading,i=n.skeletonHeight,r=n.skeletonWidth;if(t){return f("zonos-skeleton",{skeletonHeight:i,skeletonWidth:r})}return e}))}}}));