@zonos/elements 1.3.254 → 1.3.255

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 (147) hide show
  1. package/dist/cjs/{cart-77640463.js → cart-4ef52500.js} +1 -1
  2. package/dist/cjs/{hasInclusivePrice-e93c64fd.js → hasInclusivePrice-4419d03e.js} +1 -1
  3. package/dist/cjs/index.cjs.js +7 -7
  4. package/dist/cjs/{invoice-211ef96c.js → invoice-3494b21e.js} +2 -2
  5. package/dist/cjs/{isCollectMobileTablet-14fb5ab4.js → isCollectMobileTablet-92955ce6.js} +2 -2
  6. package/dist/cjs/{localization-be7afc1b.js → localization-75f4ec05.js} +3 -0
  7. package/dist/cjs/{paypal-c61ef042.js → paypal-cc3a730b.js} +2 -2
  8. package/dist/cjs/{placeTestOrder-0f7477c8.js → placeTestOrder-13901275.js} +2 -2
  9. package/dist/cjs/{renderCheckoutCurrency-1ac02803.js → renderCheckoutCurrency-0003992c.js} +2 -2
  10. package/dist/cjs/zonos-address-display_8.cjs.entry.js +2 -2
  11. package/dist/cjs/zonos-address_4.cjs.entry.js +2 -2
  12. package/dist/cjs/zonos-card_5.cjs.entry.js +3 -3
  13. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +6 -6
  14. package/dist/cjs/zonos-checkout.cjs.entry.js +3 -3
  15. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +2 -2
  16. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +6 -6
  17. package/dist/cjs/zonos-collect.cjs.entry.js +4 -4
  18. package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
  19. package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
  20. package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
  21. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
  22. package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
  23. package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +4 -4
  24. package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +6 -6
  25. package/dist/cjs/zonos-invoice.cjs.entry.js +4 -4
  26. package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
  27. package/dist/cjs/zonos-store-credit.cjs.entry.js +3 -3
  28. package/dist/collection/components/store/hello/localization.js +3 -0
  29. package/dist/esm/{cart-394c9ddb.js → cart-f4e43d1a.js} +1 -1
  30. package/dist/esm/{hasInclusivePrice-f0322e1c.js → hasInclusivePrice-0439b7f4.js} +1 -1
  31. package/dist/esm/index.js +7 -7
  32. package/dist/esm/{invoice-5ae81ae5.js → invoice-3d8f3fa8.js} +2 -2
  33. package/dist/esm/{isCollectMobileTablet-15b668d6.js → isCollectMobileTablet-0402aa32.js} +2 -2
  34. package/dist/esm/{localization-0ebc8356.js → localization-026da80b.js} +3 -0
  35. package/dist/esm/{paypal-b6fa3ec3.js → paypal-07bd6b7c.js} +2 -2
  36. package/dist/esm/{placeTestOrder-5756cbc3.js → placeTestOrder-39de11f4.js} +2 -2
  37. package/dist/esm/{renderCheckoutCurrency-5f3e06ea.js → renderCheckoutCurrency-743f7c77.js} +2 -2
  38. package/dist/esm/zonos-address-display_8.entry.js +2 -2
  39. package/dist/esm/zonos-address_4.entry.js +2 -2
  40. package/dist/esm/zonos-card_5.entry.js +3 -3
  41. package/dist/esm/zonos-cart-items_12.entry.js +6 -6
  42. package/dist/esm/zonos-checkout.entry.js +3 -3
  43. package/dist/esm/zonos-collect-cart-items_3.entry.js +2 -2
  44. package/dist/esm/zonos-collect-finish_6.entry.js +6 -6
  45. package/dist/esm/zonos-collect.entry.js +4 -4
  46. package/dist/esm/zonos-controller.entry.js +2 -2
  47. package/dist/esm/zonos-country-flag.entry.js +1 -1
  48. package/dist/esm/zonos-country-select_4.entry.js +1 -1
  49. package/dist/esm/zonos-hello-dialog.entry.js +2 -2
  50. package/dist/esm/zonos-hello.entry.js +1 -1
  51. package/dist/esm/zonos-invoice-cart-items_2.entry.js +4 -4
  52. package/dist/esm/zonos-invoice-finish_5.entry.js +6 -6
  53. package/dist/esm/zonos-invoice.entry.js +4 -4
  54. package/dist/esm/zonos-language-select_2.entry.js +1 -1
  55. package/dist/esm/zonos-store-credit.entry.js +3 -3
  56. package/dist/esm-es5/{cart-394c9ddb.js → cart-f4e43d1a.js} +1 -1
  57. package/dist/esm-es5/{hasInclusivePrice-f0322e1c.js → hasInclusivePrice-0439b7f4.js} +1 -1
  58. package/dist/esm-es5/index.js +1 -1
  59. package/dist/esm-es5/{invoice-5ae81ae5.js → invoice-3d8f3fa8.js} +1 -1
  60. package/dist/esm-es5/{isCollectMobileTablet-15b668d6.js → isCollectMobileTablet-0402aa32.js} +1 -1
  61. package/dist/esm-es5/{localization-0ebc8356.js → localization-026da80b.js} +1 -1
  62. package/dist/esm-es5/{paypal-b6fa3ec3.js → paypal-07bd6b7c.js} +2 -2
  63. package/dist/esm-es5/{placeTestOrder-5756cbc3.js → placeTestOrder-39de11f4.js} +1 -1
  64. package/dist/esm-es5/{renderCheckoutCurrency-5f3e06ea.js → renderCheckoutCurrency-743f7c77.js} +1 -1
  65. package/dist/esm-es5/zonos-address-display_8.entry.js +1 -1
  66. package/dist/esm-es5/zonos-address_4.entry.js +1 -1
  67. package/dist/esm-es5/zonos-card_5.entry.js +1 -1
  68. package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
  69. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  70. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  71. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  72. package/dist/esm-es5/zonos-collect.entry.js +1 -1
  73. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  74. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  75. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  76. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  77. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  78. package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
  79. package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
  80. package/dist/esm-es5/zonos-invoice.entry.js +1 -1
  81. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  82. package/dist/esm-es5/zonos-store-credit.entry.js +1 -1
  83. package/dist/scripts/index.js +1 -1
  84. package/dist/scripts/loadZonos.js +1 -1
  85. package/dist/scripts/zonos.js +1 -1
  86. package/dist/zonos-elements/index.esm.js +1 -1
  87. package/dist/zonos-elements/{p-efa69c89.entry.js → p-0649737d.entry.js} +1 -1
  88. package/dist/zonos-elements/{p-dcef3647.system.js → p-06b4aa32.system.js} +1 -1
  89. package/dist/zonos-elements/{p-09d7a5cb.system.js → p-0aa1c8c2.system.js} +1 -1
  90. package/dist/zonos-elements/{p-cc9620e5.system.entry.js → p-0d4af7e9.system.entry.js} +1 -1
  91. package/dist/zonos-elements/{p-92d91395.system.entry.js → p-12f480c9.system.entry.js} +1 -1
  92. package/dist/zonos-elements/{p-27fad55a.system.js → p-16a80e3c.system.js} +1 -1
  93. package/dist/zonos-elements/{p-615b5d13.entry.js → p-1bdac1d3.entry.js} +1 -1
  94. package/dist/zonos-elements/p-1ed9ef0b.js +1 -0
  95. package/dist/zonos-elements/{p-97fb5ad5.entry.js → p-231edcca.entry.js} +1 -1
  96. package/dist/zonos-elements/{p-a5fb864a.system.entry.js → p-274a5d11.system.entry.js} +1 -1
  97. package/dist/zonos-elements/{p-daaaa8f1.system.entry.js → p-27e41b44.system.entry.js} +1 -1
  98. package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
  99. package/dist/zonos-elements/{p-3d757163.entry.js → p-2affd4e6.entry.js} +1 -1
  100. package/dist/zonos-elements/p-2b10f633.system.js +1 -0
  101. package/dist/zonos-elements/{p-95f7f2a0.entry.js → p-2baa21b1.entry.js} +1 -1
  102. package/dist/zonos-elements/{p-cf69bcc4.system.js → p-31d1b874.system.js} +1 -1
  103. package/dist/zonos-elements/{p-93dec11b.entry.js → p-33fc0c8f.entry.js} +1 -1
  104. package/dist/zonos-elements/{p-b37a85f0.system.entry.js → p-3730d555.system.entry.js} +1 -1
  105. package/dist/zonos-elements/{p-a1e23675.system.entry.js → p-3814aac3.system.entry.js} +1 -1
  106. package/dist/zonos-elements/{p-13041752.js → p-3ac97c01.js} +1 -1
  107. package/dist/zonos-elements/{p-8abeab5a.entry.js → p-3e03b2e8.entry.js} +1 -1
  108. package/dist/zonos-elements/{p-321e7920.system.js → p-50aac43c.system.js} +1 -1
  109. package/dist/zonos-elements/{p-bdaf2a38.entry.js → p-5359ba71.entry.js} +1 -1
  110. package/dist/zonos-elements/{p-8dfa0bb8.system.entry.js → p-5678c5b5.system.entry.js} +1 -1
  111. package/dist/zonos-elements/{p-b49b8da4.system.entry.js → p-568c5700.system.entry.js} +1 -1
  112. package/dist/zonos-elements/p-5e3e5e3e.system.js +1 -0
  113. package/dist/zonos-elements/{p-0da3cc62.system.entry.js → p-66758e30.system.entry.js} +1 -1
  114. package/dist/zonos-elements/{p-a95ac160.entry.js → p-6ce8374e.entry.js} +1 -1
  115. package/dist/zonos-elements/p-768430fe.js +1 -0
  116. package/dist/zonos-elements/{p-4f23732f.js → p-835c0bd4.js} +1 -1
  117. package/dist/zonos-elements/{p-d65cfa9b.system.entry.js → p-9b12f023.system.entry.js} +1 -1
  118. package/dist/zonos-elements/{p-07ca3347.system.entry.js → p-9d9792b9.system.entry.js} +1 -1
  119. package/dist/zonos-elements/{p-fce715f1.system.entry.js → p-9e98a256.system.entry.js} +1 -1
  120. package/dist/zonos-elements/{p-c1ae7391.system.entry.js → p-a1835bae.system.entry.js} +1 -1
  121. package/dist/zonos-elements/{p-2c2e5ee6.entry.js → p-a6cc56ba.entry.js} +1 -1
  122. package/dist/zonos-elements/{p-fbccfa3e.system.js → p-aabb921f.system.js} +1 -1
  123. package/dist/zonos-elements/{p-57b27c60.js → p-af83f0c2.js} +1 -1
  124. package/dist/zonos-elements/{p-1162b685.entry.js → p-b20c7f8c.entry.js} +1 -1
  125. package/dist/zonos-elements/{p-4a38ea5e.system.entry.js → p-b45538a7.system.entry.js} +1 -1
  126. package/dist/zonos-elements/{p-4df85216.entry.js → p-b6c78f82.entry.js} +1 -1
  127. package/dist/zonos-elements/p-b84be447.js +1 -0
  128. package/dist/zonos-elements/{p-29f7950c.js → p-c398711f.js} +1 -1
  129. package/dist/zonos-elements/{p-a0ac3ca2.system.entry.js → p-cc364b26.system.entry.js} +1 -1
  130. package/dist/zonos-elements/{p-a5adc047.system.entry.js → p-d168be79.system.entry.js} +1 -1
  131. package/dist/zonos-elements/{p-d8610393.entry.js → p-d2bba4dc.entry.js} +1 -1
  132. package/dist/zonos-elements/{p-c6047442.system.entry.js → p-d397560e.system.entry.js} +1 -1
  133. package/dist/zonos-elements/{p-8efb79ab.entry.js → p-d938fb86.entry.js} +1 -1
  134. package/dist/zonos-elements/{p-620ba943.js → p-dafafa07.js} +1 -1
  135. package/dist/zonos-elements/{p-c2121663.system.entry.js → p-db0b35a2.system.entry.js} +1 -1
  136. package/dist/zonos-elements/{p-11d6de1a.entry.js → p-db993fdb.entry.js} +1 -1
  137. package/dist/zonos-elements/{p-2bdc2206.entry.js → p-e12f7a97.entry.js} +1 -1
  138. package/dist/zonos-elements/{p-920d9189.entry.js → p-f888db89.entry.js} +1 -1
  139. package/dist/zonos-elements/{p-2c9c750e.system.js → p-f9705736.system.js} +1 -1
  140. package/dist/zonos-elements/{p-9ff90151.entry.js → p-fbe22363.entry.js} +1 -1
  141. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  142. package/package.json +1 -1
  143. package/dist/zonos-elements/p-0dd5a4b8.system.js +0 -1
  144. package/dist/zonos-elements/p-1282495f.system.js +0 -1
  145. package/dist/zonos-elements/p-2b118454.js +0 -1
  146. package/dist/zonos-elements/p-ac353826.js +0 -1
  147. package/dist/zonos-elements/p-ca19a10a.js +0 -1
@@ -1 +1 @@
1
- import{c as e,z as t}from"./p-058f6124.js";import{s as o,l as n,e as r,t as s,f as i,b as a}from"./p-13041752.js";import{l as d,b as l}from"./p-0a377722.js";import{h as c,l as u,f as m,g as v,a as p,s as h,j as y}from"./p-41dd1cb8.js";import{i as f}from"./p-67897a0d.js";import{g as w}from"./p-f830f800.js";const g=async()=>{if(!o.checkoutSessionId)return{errors:[{message:"No checkout session id found"}],json:null};const e=new URLSearchParams;e.set("checkoutSessionId",o.checkoutSessionId);const{errors:t,json:n}=await c(`/api/zonos-elements/get-checkout-session?${e.toString()}`);return{errors:t,json:n}},{reset:b,state:S}=e((()=>({amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:!1,isEnabled:!1,orderIdCreated:null,remainingBalance:null,useFullBalance:!0}))),C=()=>{b()},O=e=>{d("Store credit balance from session","info",e),S.availableBalance=e},A=async()=>{var e,t;const{errors:o,json:n}=await g();if(o.length||!n)return void u("Failed to refresh store credit balance");const r=null!==(t=null===(e=n.checkoutSession.customerProfile)||void 0===e?void 0:e.storeCreditBalance)&&void 0!==t?t:null;O(r)},I=async()=>{var e;const t=o.checkoutSessionId;if(!t){const e="No checkout session found";return u(e),S.error=e,{error:e,success:!1}}d("Applying store credit","info",{checkoutSessionId:t}),S.isApplying=!0,S.error=null;try{const{errors:o,json:n}=await c("/api/zonos-elements/store-credit/apply",{body:{checkoutSessionId:t},method:"POST"});if(o.length>0||!n){const t=(null===(e=o[0])||void 0===e?void 0:e.message)||"Failed to apply store credit";return u(t),S.error=t,S.isApplying=!1,{error:t,success:!1}}return S.appliedAmount=n.amountApplied,S.remainingBalance=n.remainingBalance,S.isApplying=!1,d("Store credit applied","info",{amountApplied:n.amountApplied,remainingBalance:n.remainingBalance}),{error:null,success:!0}}catch(e){const t=e instanceof Error?e.message:"Failed to apply store credit";return u(t),S.error=t,S.isApplying=!1,{error:t,success:!1}}},k=e=>{S.isEnabled=e,S.error=null,e||(S.amountToApply=null)},N=e=>{if(null===e)return S.amountToApply=null,void(S.error=null);e<=0?S.error="Amount must be greater than zero":null!==S.availableBalance&&e>S.availableBalance?S.error="Amount exceeds available balance":e>we.total+(we.storeCredit||0)?S.error="Amount exceeds order total":(S.error=null,S.amountToApply=e)},T=e=>{if(S.useFullBalance=e,S.error=null,e&&null!==S.availableBalance){const e=Math.min(S.availableBalance,we.total+(we.storeCredit||0));S.amountToApply=e}else e||(S.amountToApply=null)},j=()=>S.isEnabled&&null!==S.availableBalance?S.useFullBalance?Math.min(S.availableBalance,we.total+(we.storeCredit||0)):S.amountToApply||0:0,E=()=>null!==S.amountToApply&&S.amountToApply>0&&we.storeCredit>0&&we.total<=0,P=async()=>{var e,t,n;const r=o.checkoutSessionId;if(!r){const e="No checkout session found";return u(e),S.error=e,{error:e,orderId:null,success:!1}}d("Creating store credit order","info",{checkoutSessionId:r});try{const{errors:o,json:s}=await c("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:r},method:"POST"});if(o.length>0||!s){const t=(null===(e=o[0])||void 0===e?void 0:e.message)||"Failed to create store credit order";return u(t),S.error=t,{error:t,orderId:null,success:!1}}const i=(null===(n=null===(t=s.checkoutSessionStoreCreditOrderCreate)||void 0===t?void 0:t.order)||void 0===n?void 0:n.id)||null;return S.orderIdCreated=i,d("Store credit order created","info",{orderId:i}),{error:null,orderId:i,success:!0}}catch(e){const t=e instanceof Error?e.message:"Failed to create store credit order";return u(t),S.error=t,{error:t,orderId:null,success:!1}}},D=({firstName:e,lastName:t,name:o})=>{var n;if(!o&&!e&&!t)return{firstName:"",lastName:""};const r=(null==o?void 0:o.split(/\s+/))||[];return{firstName:(null==e?void 0:e.trim())||(null===(n=r[0])||void 0===n?void 0:n.trim())||"",lastName:(null==t?void 0:t.trim())||r.slice(1).join(" ").trim()||""}},L=({currentAddress:e,translatedAddress:t})=>{var o,n,r,s,i,a;const{city:d,country:l,line1:c,line2:u,postal_code:m,state:v}=e.value.address,p=e.value.name||[e.value.firstName,e.value.lastName].join(" ");return{city:(null===(o=t.city)||void 0===o?void 0:o[d])||d,country:l,line1:(null===(n=t.line1)||void 0===n?void 0:n[c])||c,line2:(null===(r=t.line2)||void 0===r?void 0:r[u||""])||u||"",name:(null===(s=t.name)||void 0===s?void 0:s[p])||p,phone:e.value.phone||"",postal_code:(null===(i=t.postal_code)||void 0===i?void 0:i[m])||m,state:(null===(a=t.state)||void 0===a?void 0:a[v])||v}},x=e=>{var t;const s="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),i=q.stripeLinkEventData,a=q.stripeAddressEventData,d=q.stripeShippingSameAsBilling?q.stripeAddressEventData:q.stripeBillingAddressEventData;if(!a||!d)throw new Error("Missing stripe address data");const l=L({currentAddress:a,translatedAddress:q.translatedAddress.address}),{firstName:c,lastName:u}=D({name:l.name}),m=L({currentAddress:d,translatedAddress:q.translatedAddress.address}),{firstName:v,lastName:p}=D({name:m.name}),h=r()||"US";return{billingAddress:{addressLine1:m.line1,addressLine2:m.line2||"",city:m.city,country:m.country,postalCode:m.postal_code,state:m.state},billingContact:{firstName:v,lastName:p,phone:m.phone},cartCurrencyCode:null===(t=we.items[0])||void 0===t?void 0:t.currencyCode,cartId:e,checkoutSessionCountry:h||n.selectedCountryCode||void 0,checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:q.companyName,email:null==i?void 0:i.value.email,firstName:c,lastName:u,phone:l.phone},isTest:!!s,landedCostAdjustments:we.promoCode?[{amount:0,productId:null,promoCode:we.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:q.shortAddressCode,shipToTaxId:q.taxId,shippingAddress:{addressLine1:l.line1,addressLine2:l.line2,city:l.city,country:l.country,postalCode:l.postal_code,state:l.state}}},R=()=>{const e="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),t=q.stripeLinkEventData,n=q.stripeAddressEventData,r=q.stripeShippingSameAsBilling?q.stripeAddressEventData:q.stripeBillingAddressEventData;if(d({stripeAddressData:n,stripeBillingAddressData:r},"info"),!n||!r)throw new Error("Missing stripe address data");const s=L({currentAddress:n,translatedAddress:q.translatedAddress.address}),{firstName:i,lastName:a}=D({name:s.name}),l=L({currentAddress:r,translatedAddress:q.translatedAddress.address}),{firstName:c,lastName:u}=D({name:l.name}),m=we.adjustments.map((e=>({amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}))),v=we.promoCode?[{amount:0,productId:null,promoCode:we.promoCode,sku:null,type:"PROMO_CODE"},...m]:m;return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{firstName:c,lastName:u,phone:l.phone},checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:q.companyName,email:null==t?void 0:t.value.email,firstName:i,lastName:a,phone:s.phone},isTest:e,items:we.items,landedCostAdjustments:v,shipToShortAddressCode:q.shortAddressCode,shipToTaxId:q.taxId,shippingAddress:{addressLine1:s.line1,addressLine2:s.line2,city:s.city,country:s.country,postalCode:s.postal_code,state:s.state}}};const z=async e=>{const o=window.Zonos.cartId;if(!o)return await(async e=>{var o;const n=t.checkoutSettings.buildLandedCost;if(n){const e=await(async e=>{var t,o,n,r,s;const i=R(),a=await e({billingAddress:i.billingAddress,billingContact:i.billingContact,checkoutSessionId:i.checkoutSessionId,contact:i.contact,landedCostAdjustments:i.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:i.shippingAddress,zonosApiRoute:m.vercel},{promoCode:we.promoCode});if(!a||!(null===(t=a.checkoutSessionWorkflow)||void 0===t?void 0:t.length)&&(null===(o=a.errors)||void 0===o?void 0:o.length))throw new Error(`Failed to build landed cost: ${(null===(r=null===(n=null==a?void 0:a.errors)||void 0===n?void 0:n[0])||void 0===r?void 0:r.message)||"Unknown error"}`);const{errors:d,json:l}=await c("/api/zonos-elements/validate-landed-cost",{body:a,headers:{"Content-Type":"application/json"},method:"POST"});if(!l||d.length)throw new Error(`Invalid landed cost object: ${(null===(s=d.find(Boolean))||void 0===s?void 0:s.message)||"Unknown error"}`);return a})(n);return e}const{errors:r,json:s}=await c("/api/zonos-elements/calculate-landed-cost",{body:R(),method:"POST",signal:null==e?void 0:e.signal});if(r.length||!s){if("The user aborted a request."===(null===(o=r[0])||void 0===o?void 0:o.message))throw new Error("The landed cost calculation request was aborted to initiate a new one.");if(r.forEach((e=>{console.warn(`Error calculating landed cost: ${e.message}`)})),!s)throw new Error("Failed to calculate landed cost");return s}return s})(e);const n=await(async({abortController:e,cartId:t})=>{var o,n,r,s,i;const{errors:a,json:d}=await c("/api/zonos-elements/cart-calculate-landed-cost",{body:x(t),method:"POST",signal:null==e?void 0:e.signal});if(a.length||!d){const e="string"==typeof(null===(o=a[0])||void 0===o?void 0:o.message)&&("The user aborted a request."===(null===(n=a[0])||void 0===n?void 0:n.message)||(null===(r=a[0])||void 0===r?void 0:r.message.includes("signal is aborted"))||(null===(s=a[0])||void 0===s?void 0:s.message.includes("The operation was aborted"))||(null===(i=a[0])||void 0===i?void 0:i.message.includes("Fetch is aborted")));throw new Error(e?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost")}return d})({abortController:e,cartId:o}),{cartWorkflow:r}=n,s=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(n,["cartWorkflow"]);return Object.assign(Object.assign({},s),{itemCreateWorkflow:r.items})},U=async({checkoutSessionId:e,eventName:o,metadata:r})=>{var s,i;const a=Date.now(),d=[...window.Zonos.trackEventLogs];window.Zonos.trackEventLogs.push({checkoutSessionId:e,eventCreated:a,eventName:o});const u=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!(null===(s=window.Zonos)||void 0===s?void 0:s.zonosQaUrl)||!!(null===(i=window.Zonos)||void 0===i?void 0:i.debug);if((v()||p()||u)&&!window.Zonos.zonosConversionTest)return;const m=n.selectedCountryCode,y=t.organizationId;if(!e)return void h({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No checkout session id found`],metadata:{allLogs:l,checkoutSessionId:e,eventName:o,metadata:r,organizationId:y,trackEventLogs:d}});y||h({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No organization id found`],metadata:{allLogs:l,checkoutSessionId:e,eventName:o,metadata:r,organizationId:y,trackEventLogs:d}});const f={checkoutSessionId:e,countryCode:m,eventCreated:a,eventName:o,metadata:Object.assign(Object.assign({},r),{trackEventLogs:d}),organizationId:y};await c("/api/zonos-elements/track-conversion-event",{body:f,method:"POST"})},_=({address:e,invalidAdddressList:t})=>{if(!e)return;if(!t)return;const o={};return t.city&&(o.city=e.city),t.line1&&(o.line1=e.line1),t.line2&&(o.line2=e.line2),t.postal_code&&(o.postal_code=e.postal_code),t.state&&(o.state=e.state),t.name&&(o.name=e.name),Object.keys(o).length?o:void 0},B=e=>e.sort(((e,t)=>e.amount-t.amount)),F=async()=>{var e;const{errors:t,json:o}=await g();return t.length||!o?(u("Failed to retrieve checkout session info before confirming payment ",t),h({endpoint:"validateCheckoutSession",errors:t.map((e=>e.message)),metadata:{allLogs:l}}),{errorMessage:s("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:!1}):(null===(e=o.checkoutSession.landedCost)||void 0===e?void 0:e.id)?{errorMessage:"",valid:!0}:(u("Landed cost is not found in the checkout session before confirming payment."),h({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:l}}),{errorMessage:s('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:!1})},J=({theme:e})=>{const o={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:t.appearance.fontSizeInputValue?`${t.appearance.fontSizeInputValue}px`:void 0,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:t.appearance.fontSizeInputLabel?`${t.appearance.fontSizeInputLabel}px`:void 0},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};return"DARK"===e?Object.assign(Object.assign({},o),{".Action":Object.assign(Object.assign({},o[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},o[".PickerItem--new"]),{color:"white"})}):o},M=({borderStyle:e,theme:t})=>"DARK"===t?{borderRadius:w({overrideBorderStyle:e}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"}:{borderRadius:w({overrideBorderStyle:e}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"},{onChange:W,reset:$,state:q}=e((()=>({checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:!1,isFetchingLandedCost:!1,isFetchingSession:!1,partyBillingId:null,partyShippingId:null,shortAddressCode:"",shouldInventoryRefund:!1,shouldRenderPayInUsdButton:!1,skipPaymentIntent:"0"!==new URLSearchParams(window.location.search).get("skipPaymentIntent"),stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:!0,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}))),Y=()=>{window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")},H=e=>{window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))},K=()=>{const e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return y(e)},G=async e=>{var o,r;const s=q.clientSecret;if(!q.stripe)return void d("Skip. Stripe is not initialized");const i=(({clientSecret:e,overrideBorderRadius:o,overridePrimaryColor:r,overrideSecondaryColor:s,overrideTheme:i,paypalEnabled:a})=>{const d=r||t.appearance.colorPrimary,l=s||t.appearance.colorSecondary,c=(window.Zonos.isCollect||window.Zonos.isInvoice?"DARK"===t.appearance.theme:d&&f(d))?"night":"flat",u="DARK"===i?"night":"flat",m=a?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},J({theme:i||"LIGHT"})),theme:i?u:c,variables:Object.assign(Object.assign({},M({borderStyle:o,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:e||void 0,customerSessionClientSecret:q.stripeCustomerSessionClientSecret||void 0,externalPaymentMethodTypes:[...m],locale:n.selectedLocale}})({clientSecret:s,overrideBorderRadius:null==e?void 0:e.overrideBorderRadius,overridePrimaryColor:null==e?void 0:e.overridePrimaryColor,overrideSecondaryColor:null==e?void 0:e.overrideSecondaryColor,overrideTheme:null==e?void 0:e.overrideTheme,paypalEnabled:null==e?void 0:e.paypalEnabled}),a=JSON.stringify(i)===JSON.stringify(q.stripeElementsOptions);if(!q.stripeElements||!q.stripeElementsForBillingAddress)return q.stripeElementsForBillingAddress=null===(o=q.stripe)||void 0===o?void 0:o.elements(i),d("Stripe elements for billing address initialized"),q.stripeElements=null===(r=q.stripe)||void 0===r?void 0:r.elements(i),q.stripeElementsOptions=i,void d("Stripe elements initialized");a||(q.stripeElements.update(i),q.stripeElementsForBillingAddress.update(i),q.stripeElementsOptions=i,q.stripeElements.fetchUpdates()),d("Stripe elements updated")},V=()=>{sessionStorage.removeItem("zonos--client-secret"),$(),q.stripe=window.Zonos.stripe},Z=({address:e,firstName:t,lastName:n,name:r,phone:s})=>{const{firstName:i,lastName:a}=D({firstName:t,lastName:n,name:r});return i&&a||h({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,firstName:t,lastName:n,name:r}}),s||h({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,phone:s}}),{city:e.city,country:e.country,firstName:i,lastName:a,line1:e.line1,line2:e.line2,phone:s||"",postal_code:e.postal_code,state:e.state}},Q=async()=>{var e,t,n,r;if(!(null===(e=q.stripeAddressEventData)||void 0===e?void 0:e.complete)||!q.stripeShippingSameAsBilling&&!(null===(t=q.stripeBillingAddressEventData)||void 0===t?void 0:t.complete)||!q.stripeBillingAddressEventData)return{partiesCreated:!1};if(!we.landedCostData)return{partiesCreated:!1};const s=null===(n=we.landedCostData.find(Boolean))||void 0===n?void 0:n.landedCost.rootId;if(!s)return h({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId}}),{partiesCreated:!1};const i=(()=>{var e,t,o,n,r,s,i,a;const d=null===(e=we.partiesData.find((e=>"DESTINATION"===e.type)))||void 0===e?void 0:e.id,l=null===(t=we.partiesData.find((e=>"PAYOR"===e.type)))||void 0===t?void 0:t.id;if(!d||!l)return!1;if(q.partyShippingId!==d||q.partyBillingId!==l)return!0;const c=JSON.stringify(null===(o=q.stripeLinkUsedWhenFetchingLC)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=q.stripeLinkEventData)||void 0===n?void 0:n.value),u=JSON.stringify(null===(r=q.stripeAddressUsedWhenAsyncAddressUpdate)||void 0===r?void 0:r.value)!==JSON.stringify(null===(s=q.stripeAddressEventData)||void 0===s?void 0:s.value),m=!q.stripeShippingSameAsBilling&&JSON.stringify(null===(i=q.stripeBillingAddressUsedWhenAsyncAddressUpdate)||void 0===i?void 0:i.value)!==JSON.stringify(null===(a=q.stripeBillingAddressEventData)||void 0===a?void 0:a.value);return c||u||m||q.taxIdUsedWhenAsyncAddressUpdate!==q.taxId||q.companyNameUsedWhenAsyncAddressUpdate!==q.companyName})();if(!i)return{partiesCreated:!1};const a=Z({address:q.stripeAddressEventData.value.address,firstName:q.stripeAddressEventData.value.firstName,lastName:q.stripeAddressEventData.value.lastName,name:q.stripeAddressEventData.value.name,phone:q.stripeAddressEventData.value.phone}),d=q.stripeShippingSameAsBilling?a:Z({address:q.stripeBillingAddressEventData.value.address,firstName:q.stripeBillingAddressEventData.value.firstName,lastName:q.stripeBillingAddressEventData.value.lastName,name:q.stripeBillingAddressEventData.value.name,phone:q.stripeBillingAddressEventData.value.phone}),m="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:v,json:p}=await c("/api/zonos-elements/create-parties",{body:{address:a,billingAddress:d,companyName:q.companyName,email:(null===(r=q.stripeLinkEventData)||void 0===r?void 0:r.value.email)||"",isTest:m,rootId:s,shortAddressCode:q.shortAddressCode,taxId:q.taxId},method:"POST"});return v.length||!p?(u("Error occurs when creating parties",JSON.stringify(v,null,2)),h({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,errors:v,json:p}}),{partiesCreated:!1}):(q.companyNameUsedWhenAsyncAddressUpdate=q.companyName,q.stripeAddressUsedWhenAsyncAddressUpdate=q.stripeAddressEventData,q.stripeBillingAddressUsedWhenAsyncAddressUpdate=q.stripeBillingAddressEventData,q.taxIdUsedWhenAsyncAddressUpdate=q.taxId,q.partyBillingId=p.billToPartyId,q.partyShippingId=p.shipToPartyId,we.partiesData=we.partiesData.map((e=>"DESTINATION"===e.type&&e.id!==p.shipToPartyId?Object.assign(Object.assign({},e),{id:p.shipToPartyId}):"PAYOR"===e.type&&e.id!==p.billToPartyId?Object.assign(Object.assign({},e),{id:p.billToPartyId}):e)),{partiesCreated:!0})},X=e=>({countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}),ee=async e=>{var n,r,s,i;const a=(null==e?void 0:e.retries)||0,l=!!(null==e?void 0:e.applyingPromocode),c=(()=>{var e;const t=we.landedCostData&&(null===(e=we.landedCostData.find(Boolean))||void 0===e?void 0:e.subtotals.items)!==we.subtotal,o=(()=>{var e,t;const o=JSON.stringify(null===(e=q.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=q.stripeLinkEventData)||void 0===t?void 0:t.value),n=q.stripeAddressEventData&&JSON.stringify(X(q.stripeAddressEventData.value))!==JSON.stringify(q.stripeAddressUsedWhenFetchingLC),r=!q.stripeShippingSameAsBilling&&q.stripeBillingAddressEventData&&JSON.stringify(X(q.stripeBillingAddressEventData.value))!==JSON.stringify(q.stripeBillingAddressUsedWhenFetchingLC);return o||n||r})();return d("isPrefetchInfoOutdated","info",{isAddressOutdated:o}),!we.landedCostData&&!q.isFetchingLandedCost||o||t})();if(!(()=>{var e,o,n,r;const s=!!(null===(e=q.stripeLinkEventData)||void 0===e?void 0:e.complete),i=!!(null===(o=q.stripeAddressEventData)||void 0===o?void 0:o.complete),a=q.stripeShippingSameAsBilling?i:!!(null===(n=q.stripeBillingAddressEventData)||void 0===n?void 0:n.complete),d=(e=>{var o,n;const r=null===(o=t.genericSettings)||void 0===o?void 0:o.countryFields,s=null===(n=t.genericSettings)||void 0===n?void 0:n.stripeCountryFieldLabels;return"stripe"===we.addressFormRenderType&&(s&&e in s?s[e]:null)||(r&&e in r?r[e]:null)})((null===(r=q.stripeAddressEventData)||void 0===r?void 0:r.value.address.country)||"US");return!!(i&&a&&s)||(d&&q.stripeAddressEventData?s&&q.stripeAddressEventData.value.firstName&&q.stripeAddressEventData.value.lastName&&q.stripeAddressEventData.value.address.line1.length>0&&(!d.stateRequired||d.stateRequired&&q.stripeAddressEventData.value.address.state.length>0)&&(!d.zipRequired||d.zipRequired&&q.stripeAddressEventData.value.address.postal_code.length>=3)&&q.stripeAddressEventData.value.phone&&q.stripeAddressEventData.value.phone.length>0:i&&a&&s)})())return{isRequestNotReady:!0};if(c&&(null===(n=q.fetchingLandedCostAbortController)||void 0===n||n.abort(),q.fetchingLandedCostAbortController=null),!c&&!l)return{isRequestNotReady:!1};a?(q.isFetchingLandedCost=!1,setTimeout((()=>{q.isFetchingLandedCost=!0}),300)):q.isFetchingLandedCost=!0,q.stripeAddressEventData&&(q.stripeAddressUsedWhenFetchingLC={countryCode:q.stripeAddressEventData.value.address.country,postalCode:q.stripeAddressEventData.value.address.postal_code,state:q.stripeAddressEventData.value.address.state}),q.stripeBillingAddressEventData&&(q.stripeBillingAddressUsedWhenFetchingLC={countryCode:q.stripeBillingAddressEventData.value.address.country,postalCode:q.stripeBillingAddressEventData.value.address.postal_code,state:q.stripeBillingAddressEventData.value.address.state}),q.stripeLinkEventData&&(q.stripeLinkUsedWhenFetchingLC=Object.assign({},q.stripeLinkEventData));try{xe(),await(async()=>{var e;const t=new AbortController;q.fetchingLandedCostAbortController=t,xe();const{checkoutSessionWorkflow:n,errors:r,itemCreateWorkflow:s,landedCostCalculateWorkflow:i,partyCreateWorkflow:a,shipmentRatingCalculateWorkflow:d}=await z(t);we.customQuotingError=(null===(e=null==r?void 0:r.find((e=>{var t;return"CUSTOM"===(null===(t=e.extensions)||void 0===t?void 0:t.ruleMessageType)})))||void 0===e?void 0:e.message)||null,we.shippingData=B((null==d?void 0:d.filter(Boolean))||[]),Ce(s),q.fetchingLandedCostAbortController=null,we.partiesData=(null==a?void 0:a.filter(Boolean))||[],we.landedCostData=(null==n?void 0:n.map((e=>{const t=null==i?void 0:i.find((t=>(null==t?void 0:t.id)===e.landedCostId));return t?Object.assign(Object.assign({},e),{landedCost:t}):null})).filter(Boolean))||[],(null==n?void 0:n.length)&&U({checkoutSessionId:o.checkoutSessionId,eventName:"checkout_quoteReceived"});const l=we.promoCodeApplied&&!we.landedCostData.find((e=>{var t;return null===(t=e.landedCost.appliedAdjustments)||void 0===t?void 0:t.find((e=>"PROMO_CODE"===e.type))}));we.promoCodeError=l,l||sessionStorage.setItem("zonos--promo-code",we.promoCode)})();const e=null===(r=we.shippingData)||void 0===r?void 0:r.find(Boolean),t=null===(s=we.landedCostData)||void 0===s?void 0:s.find((t=>t.landedCost.shipmentRating.id===(null==e?void 0:e.id))),n=t?t.subtotals:null;n&&ke({method:(null==t?void 0:t.landedCost.method)||"DDP",subtotals:n})}catch(t){if(we.landedCostData=[],we.shippingData=[],t instanceof Error&&t.message&&!["The landed cost calculation request was aborted to initiate a new one."].includes(t.message)){if(a<1)return await ee(Object.assign(Object.assign({},e),{retries:(a||0)+1})),{isRequestNotReady:!1};const o=null===(i=q.stripeAddressEventData)||void 0===i?void 0:i.value;h({endpoint:`Failed to fetch landed cost (${a} retries)`,errors:[t.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:o}})}u(t)}return q.isFetchingLandedCost=!1,{isRequestNotReady:!1}},te=async()=>{var e,t;await ee({applyingPromocode:!0}),"payment"===we.step&&ze(),await Q();const o=null===(e=we.shippingData)||void 0===e?void 0:e.find(Boolean),n=null===(t=we.landedCostData)||void 0===t?void 0:t.find((e=>e.landedCost.id===(null==o?void 0:o.id)));o&&n&&await Pe({applySubtotalsOnly:!1,landedCostId:n.landedCostId,selectedShippingOption:o})},oe=()=>{we.promoCode="",sessionStorage.removeItem("zonos--promo-code"),we.promoCodeError=!1,we.promoCodeApplied=!1},ne=async()=>{"payment"===we.step&&ze(),oe(),await te()},re=e=>{let t=[],o=!0;const n=window.Zonos.isCollect,r=window.Zonos.isInvoice;switch(e){case"succeeded":t=[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.")],(n||r)&&(t=[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.")]),o=!1;break;case"requires_capture":case"processing":t=[s("Payment processing. We'll update you when payment is received.")],o=!1;break;case"requires_payment_method":t=[s("Payment failed. Please try another payment method.")],n&&(t=[s("Payment failed. Please reload the page and try another payment method.")]);break;case"requires_action":o=!1,t=[s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")];default:t=[s("Something went wrong.")]}return{isError:o,messages:t}},se=async()=>{var e,o;const{onInventoryCheck:n}=t.checkoutSettings,r=!!(null===(o=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===o?void 0:o.value);if(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&r){const{errors:e,json:t}=await c("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"});return e.length||!t?(u("Error occurs when handling inventory refund","warn",JSON.stringify(e)),null):t.available&&204!==t.status?t.available||200===t.status?(q.shouldInventoryRefund=!0,null):null: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("function"!=typeof n)return null;try{return await n({items:we.items},{translate:s,zonosApiRoute:m.vercel})}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw h({endpoint:"onInventoryCheck",errors:[`cartId: ${window.Zonos.cartId} - ${t}`],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:we.items}}),e}},ie=async()=>{var e,t;const o=!!(null===(t=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===t?void 0:t.value);window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o&&await c("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})},ae=async({clientSecret:e,storybookForceStatus:t})=>{if(t){const{isError:e,messages:o}=re(t);return{error:e,messages:o}}const o=e||q.clientSecret;if(!q.stripe||!o)return u("Failed to retrieve payment intent. Stripe is not initialized"),{error:!0,message:[s("Something went wrong.")]};const{paymentIntent:n}=await q.stripe.retrievePaymentIntent(o),r=null==n?void 0:n.status,{isError:i,messages:a}=re(r);return{amount:null==n?void 0:n.amount,currency:null==n?void 0:n.currency,error:i,messages:a,paymentIntentId:null==n?void 0:n.id,paymentMethod:null==n?void 0:n.payment_method,status:r}},de=async e=>{var t,n;const r=!!(null===(t=q.stripePaymentEventData)||void 0===t?void 0:t.complete),i=q.stripeElements,a=q.stripe,l=q.clientSecret;if(q.customErrorMessage=null,!(null===(n=we.selectedLandedCost)||void 0===n?void 0:n.landedCost.id)&&!(null==e?void 0:e.noLandedCostCheck))throw new Error("Attempted to confirm the payment when no landed cost is found in store");const c=await F();if(!c.valid)throw q.customErrorMessage=c.errorMessage,new Error(c.errorMessage);const u=o.checkoutSessionId;if(a&&i&&r&&l&&u){const e=new URL(window.location.href);e.searchParams.set("payment_intent_client_secret",l),e.searchParams.set("zonosCheckoutSessionId",u),U({checkoutSessionId:u,eventName:"checkout_paymentInfoCompleted"});const{error:t,paymentIntent:o}=await a.confirmPayment({confirmParams:{return_url:e.toString()},elements:i,redirect:"if_required"});if(d("Payment intent confirmed","info",{error:t,paymentIntent:o}),"requires_action"===(null==o?void 0:o.status))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(t){if("card_error"===t.type||"validation_error"===t.type)throw new Error(t.message);if("invalid_request_error"===t.type&&"payment_intent_unexpected_state"===t.code)return;throw new Error("An unexpected error occurred.")}if("requires_payment_method"===o.status)throw new Error(s("Payment failed. Please try another payment method."))}},le=()=>{var e;const t=we.items.reduce(((e,t)=>e+t.amount*t.quantity),0),r=o.enabledVariantTestKeys||[];return{adjustmentsAmount:we.adjustments.reduce(((e,t)=>e+t.amount),0),cartId:window.Zonos.cartId,currency:(null===(e=we.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",customerAuthenticationToken:we.customerAuthenticationToken||void 0,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:t,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:n.selectedCountryCode,skipPaymentIntent:q.skipPaymentIntent,varianceTestInput:r}},ce=async()=>{var e;if(!o.checkoutSessionId)return h({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:l,cartId:window.Zonos.cartId}}),void Ie({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")});const{errors:t,json:n}=await c("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:o.checkoutSessionId},method:"POST"}),r=null===(e=null==n?void 0:n.checkoutSessionPaymentIntentCreate)||void 0===e?void 0:e.clientSecret;if(t.length||!r)return u("Error occurs when getting payment intent",JSON.stringify(t,null,2)),h({endpoint:"Error creating payment intent",errors:t.map((e=>e.message)),metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,clientSecret:r}}),void Ie({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")});Te(n.checkoutSessionPaymentIntentCreate)},ue=async()=>{var e,t;if(!n.targetCurrency)return u("Failed to create checkout session - missing localizationStore.targetCurrency"),!1;q.isFetchingSession=!0;const o=le();d("Checkout session body","info",o);const{errors:r,json:s}=await c("/api/zonos-elements/create-checkout-session",{body:o,method:"POST"});if(q.isFetchingSession=!1,r.length||!s){const t=null===(e=r.find((e=>e.message)))||void 0===e?void 0:e.message;if(Array.isArray(t)&&t.some((e=>"Cart is expired."===e.message)))throw new Error("Cart is expired.");return u("Error occurred when creating checkout session",JSON.stringify(r,null,2)),!1}const i=s.checkoutSessionCreate;return Te(i),ke({method:(null===(t=i.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:i.subtotals}),d("Exchange rate updated for cart items (checkout session create)","info",we.exchangeRate),d("done-init-checkout-session"),!0},me=async()=>{const e=o.checkoutSessionId;if(!e)return u("Failed to update checkout session base currency"),!1;if("LOCAL"===t.checkoutSettings.allowedSettlementCurrencies)return d('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency'),!0;const{json:n}=await c("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:q.checkoutSettlementCurrency},method:"POST"}),r=null==n?void 0:n.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;return n&&r===q.checkoutSettlementCurrency?(d(`Updated checkout session to settlement currency "${r}".`),!0):(u("Failed to update checkout session base currency"),!1)},ve=async({adjustmentsAmount:e,cartId:t,currency:r,id:s,itemsAmount:i,landedCostId:a,presentmentCountryCode:d,storeCreditApplication:l})=>{const m=o.enabledVariantTestKeys||[],{errors:v,json:p}=await c("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:e,billToPartyId:q.partyBillingId,cartId:t,currency:r,customerAuthenticationToken:we.customerAuthenticationToken||void 0,id:s,itemsAmount:i,landedCostId:a,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:d,shipToPartyId:q.partyShippingId,skipPaymentIntent:q.skipPaymentIntent,storeCreditApplication:l,varianceTestInput:m},method:"POST"});return v.length||!p?(u("Error occurs when updating checkout session",JSON.stringify(v,null,2)),{errors:v,json:p}):{errors:[],json:p}},pe=({currentAddress:e,translatedAddressResult:t})=>{const o={};if(!t)return o;const{city:n,line1:r,line2:s,name:i,postal_code:a,state:d}=t;return e.city&&n&&(o.city={[e.city]:n}),e.line1&&r&&(o.line1={[e.line1]:r}),e.line2&&s&&(o.line2={[e.line2]:s}),e.postal_code&&a&&(o.postal_code={[e.postal_code]:a}),e.state&&d&&(o.state={[e.state]:d}),e.name&&i&&(o.name={[e.name]:i}),o},he=async({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t})=>{var o,n,r,s;const i=(({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:o,stripeBillingAddressEventData:n,stripeShippingSameAsBilling:r})=>{const s=!!(null==o?void 0:o.complete);if(!s||!(r?s:null==n?void 0:n.complete))return null;if(!e&&!t)return null;const i=o.value,a=(null==n?void 0:n.value)||null,{firstName:d,lastName:l}=D({firstName:i.firstName,lastName:i.lastName,name:i.name}),c=`${d} ${l}`,{firstName:u,lastName:m}=D({firstName:null==a?void 0:a.firstName,lastName:null==a?void 0:a.lastName,name:(null==a?void 0:a.name)||""}),v=u&&m?`${u} ${m}`:"",p=i.address,h=null==a?void 0:a.address;return{address:_({address:Object.assign(Object.assign({},p),{name:c}),invalidAdddressList:e}),billingAddress:r?void 0:_({address:h?Object.assign(Object.assign({},h),{name:v}):null,invalidAdddressList:t}),destinationCountry:p.country}})({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:q.stripeAddressEventData,stripeBillingAddressEventData:q.stripeBillingAddressEventData,stripeShippingSameAsBilling:q.stripeShippingSameAsBilling});if(!i)return void(q.translatedAddress={address:{},billingAddress:{}});const a=(()=>{var e,t,o,n;const r=JSON.stringify(null===(e=q.stripeAddressUsedWhenValidatingAddress)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=q.stripeAddressEventData)||void 0===t?void 0:t.value),s=!q.stripeShippingSameAsBilling&&JSON.stringify(null===(o=q.stripeBillingAddressEventData)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=q.stripeBillingAddressUsedWhenValidatingAddress)||void 0===n?void 0:n.value);return r||s})();if(!a)return;const{errors:d,json:l}=await c("/api/zonos-elements/validate-address",{body:i,method:"POST"});if(d.length||!l)return u("Error occurs when translating address to latin",JSON.stringify(d,null,2)),void(q.translatedAddress={address:{},billingAddress:{}});q.stripeAddressUsedWhenValidatingAddress=q.stripeAddressEventData,q.stripeBillingAddressUsedWhenValidatingAddress=q.stripeBillingAddressEventData;const m=null===(o=q.stripeAddressEventData)||void 0===o?void 0:o.value.address,v=null===(n=q.stripeBillingAddressEventData)||void 0===n?void 0:n.value.address;q.translatedAddress={address:m?pe({currentAddress:Object.assign(Object.assign({},m),{name:null===(r=q.stripeAddressEventData)||void 0===r?void 0:r.value.name}),translatedAddressResult:l.address||null}):{},billingAddress:q.stripeShippingSameAsBilling?{}:pe({currentAddress:Object.assign(Object.assign({},v),{name:null===(s=q.stripeBillingAddressEventData)||void 0===s?void 0:s.value.name}),translatedAddressResult:l.billingAddress||null})}};W("clientSecret",(e=>{e&&q.stripe&&sessionStorage.setItem("zonos--client-secret",e),e||sessionStorage.removeItem("zonos--client-secret")}));const{onChange:ye,reset:fe,state:we}=e((()=>({addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:!1,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:!1,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:!1,isSelectedShippingGuarantee:!1,isStagingMode:p(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:!1,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:!1,step:"customer-info",storeCredit:0,subtotal:0,tabItems:{"customer-info":{index:1,isDone:!1,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:!1,label:"Shipping",value:"shipping"},payment:{index:3,isDone:!1,label:"Payment",value:"payment"}},total:0}))),ge=e=>{switch(e){case"DAYS":return s("days");case"WEEKS":return s("weeks");default:return s("business days")}},be=e=>{var t;const o=null===(t=e.shippingProfile)||void 0===t?void 0:t.transitTime;return(null==o?void 0:o.min)&&(null==o?void 0:o.max)&&(null==o?void 0:o.type)?{maxTransit:o.max,minTransit:o.min,unit:ge(o.type)}:null},Se=({item1:e,item2:t})=>!(!e||!t)&&(t.sku&&e.sku&&e.sku===t.sku||t.description&&e.description&&e.description===t.description||e.name&&t.name&&e.name===t.name),Ce=e=>{d("Checking item restrictions");const t=e.map((e=>{if(!e.restriction)return null;const{restriction:t}=e,o=we.items.find((t=>Se({item1:t,item2:e})));return Object.assign(Object.assign({matchedItem:o},e),{restriction:t})})).filter(Boolean);return we.restrictedItems=t,we.items=we.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!!t.find((t=>Se({item1:t,item2:e})))}))),{cartItems:we.items,restrictedItems:t}};let Oe=null;const Ae=()=>{o.checkoutSessionId=null,Oe&&(clearTimeout(Oe),Oe=null),C(),fe()},Ie=({messages:e,title:t})=>{Ae(),V(),we.step="error",we.error={messages:e,title:t}},ke=({dutiesTaxesFeesEstimate:e,method:t,subtotals:o})=>{var n;we.exchangeRate=o.exchangeRate,we.adjustmentTotal=o.adjustments,we.dutiesTaxesFees="DAP"===t?null:o.landedCostTotal,we.storeCredit=null!==(n=o.storeCredit)&&void 0!==n?n:0,we.subtotal=o.items,we.total=o.total,we.currency=o.presentmentCurrencyCode,we.dutiesTaxesFeesEstimate=e||null},Ne=()=>!!we.items.filter((e=>e.amount>0)).find((e=>!e.isRestricted)),Te=e=>{var t,n,r,s,c,u,m;q.clientSecret=e.clientSecret,q.stripeCustomerSessionClientSecret=e.customerSessionClientSecret,q.customerProfile=e.customerProfile,we.checkoutSession=e,O(null!==(n=null===(t=e.customerProfile)||void 0===t?void 0:t.storeCreditBalance)&&void 0!==n?n:null),e.id||h({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:l,checkoutSession:e}}),e.id&&(o.checkoutSessionId=e.id);const v=i(e.varianceTestResults||[]);a(v);const p=(null===(c=null===(s=null===(r=we.checkoutSession)||void 0===r?void 0:r.metadata)||void 0===s?void 0:s.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===c?void 0:c.value)||(null===(m=null===(u=window.Zonos.cartData)||void 0===u?void 0:u.metadata.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===m?void 0:m.value)||null;p&&(d(`Found externalConfirmationPageURL: ${p}`),we.externalConfirmationPageURL=p)},je=async({adjustmentsAmount:e,cartId:t,currency:r,dutiesTaxesFeesEstimate:i,itemsAmount:a,landedCostId:l,shouldInitSessionOnFailure:c})=>{var m;if(l&&we.selectedLandedCost&&(ke({dutiesTaxesFeesEstimate:i,method:we.landedCostMethod,subtotals:we.selectedLandedCost.subtotals}),d("Exchange rate updated for cart items (landed cost subtotal)","info",we.exchangeRate)),!o.checkoutSessionId)return d("Could not update cart total without checkout session id","info"),!1;const{errors:v,json:p}=await ve({adjustmentsAmount:e,billToPartyId:q.partyBillingId,cartId:t,currency:r,id:o.checkoutSessionId,itemsAmount:a,landedCostId:l,presentmentCountryCode:n.selectedCountryCode,shipToPartyId:q.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});if(v.length>0||!p){if(u("Error occurs when updating checkout session."),c){d("Initiating checkout session on failure","info");const e=await ue();return d(`stripeStoreInitCheckoutSession: ${e}`),!!e||(Ie({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")}),!1)}return!1}return l||(ke({method:(null===(m=p.checkoutSessionUpdate.landedCost)||void 0===m?void 0:m.method)||"DDP",subtotals:p.checkoutSessionUpdate.subtotals}),d("Exchange rate updated for cart items (checkout session update)","info",we.exchangeRate)),Te(p.checkoutSessionUpdate),!0},Ee=e=>{var o,n,r;return"DAP"===e.method&&(null===(n=null===(o=t.genericSettings)||void 0===o?void 0:o.domesticCountries)||void 0===n?void 0:n.includes((null===(r=q.stripeAddressEventData)||void 0===r?void 0:r.value.address.country)||"US"))||"DAP"===e.method&&e.remittance.length&&"ZONOS"===e.landedCostGuaranteeCode?"DDP":e.method},Pe=async({applySubtotalsOnly:e,landedCostId:n,selectedShippingOption:r})=>{var s,i,a,l,c,u,m,v,p,h,y;d("Updating selected shipping option","info",{landedCostId:n,selectedShippingOption:r}),we.selectedShippingOption=r;const f=be(we.selectedShippingOption);if(f){const{maxTransit:e,minTransit:t,unit:o}=f;we.selectedShippingOptionTransitTime=`${t}-${e} ${o}`}else we.selectedShippingOptionTransitTime="";const w=null===(s=we.landedCostData)||void 0===s?void 0:s.find((e=>e.landedCostId===n));if(we.selectedLandedCost=w||null,!w)return!1;const g=((null===(i=w.landedCost.amountSubtotals)||void 0===i?void 0:i.landedCostTotal)||0)*w.subtotals.exchangeRate.rate;g&&d(`DAP quote, using estimate: ${g}`,"info"),we.landedCostMethod=Ee(w.landedCost),we.shipping=w.subtotals.shipping;const b="ZONOS"===(null===(a=null==w?void 0:w.landedCost)||void 0===a?void 0:a.landedCostGuaranteeCode),S=!!(null===(c=null===(l=null==w?void 0:w.landedCost)||void 0===l?void 0:l.deMinimis)||void 0===c?void 0:c.find((e=>["DUTY","TAX"].includes(e.type)&&"ABOVE"===e.threshold)));we.isSelectedShippingAboveDeminimis=S,we.isSelectedShippingGuarantee=b;let C=!1;e?(ke({dutiesTaxesFeesEstimate:g,method:we.landedCostMethod,subtotals:w.subtotals}),d("Exchange rate updated for cart items (landed cost subtotal)","info",we.exchangeRate),C=!0):C=await je({adjustmentsAmount:we.adjustmentTotal,billToPartyId:q.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:g,landedCostId:null===(u=w.landedCost)||void 0===u?void 0:u.id,shipToPartyId:q.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});const O=null===(m=we.items.find(Boolean))||void 0===m?void 0:m.currencyCode,A=(null===(v=q.stripeAddressEventData)||void 0===v?void 0:v.value.address.country)||"US";return q.shouldRenderPayInUsdButton="USD"===O&&"LOCAL_AND_USD"===t.checkoutSettings.allowedSettlementCurrencies&&"USD"!==(null===(p=we.checkoutSession)||void 0===p?void 0:p.subtotals.presentmentCurrencyCode)&&!!(null===(y=null===(h=t.genericSettings)||void 0===h?void 0:h.usdSettlementCountryEnabled)||void 0===y?void 0:y.includes(A)),C},De=({isPreview:e,sessionTimeout:t})=>{if(e)return;const o=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout"),n=o&&!isNaN(parseInt(o,10))?parseInt(o,10):t;d(`==START CHECKOUT TIMEOUT - ${n}==`),we.checkoutTimeoutInterval=setTimeout((()=>{we.checkoutSessionTimeoutShow=!0}),n)},Le=()=>{we.checkoutTimeoutInterval&&(clearTimeout(we.checkoutTimeoutInterval),we.checkoutTimeoutInterval=null)},xe=()=>{we.items=we.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1}))),we.restrictedItems=[]},Re=async({adjustments:e,cartItems:t,landedCostId:n,shouldInitSessionOnFailure:r=!0})=>{var s;we.adjustments=e,we.items=t.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1})));const i=null===(s=t.find(Boolean))||void 0===s?void 0:s.currencyCode,a=t.reduce(((e,t)=>e+t.amount*t.quantity),0),d=e.reduce(((e,t)=>e+t.amount),0);i&&a&&(we.currency=i,q.isFetchingSession=!0,await je({adjustmentsAmount:d,billToPartyId:q.partyBillingId,cartId:window.Zonos.cartId,currency:i,dutiesTaxesFeesEstimate:0,itemsAmount:a,landedCostId:n,shipToPartyId:q.partyShippingId,shouldInitSessionOnFailure:r,varianceTestInput:o.enabledVariantTestKeys||[]}),q.isFetchingSession=!1)},ze=()=>{"shipping"===we.step?(we.step="customer-info",we.tabItems=Object.assign(Object.assign({},we.tabItems),{"customer-info":Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!1})})):"payment"===we.step?(we.step="shipping",we.tabItems=Object.assign(Object.assign({},we.tabItems),{shipping:Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!1})})):"finish"===we.step&&(we.step="payment",we.tabItems=Object.assign(Object.assign({},we.tabItems),{payment:Object.assign(Object.assign({},we.tabItems.payment),{isDone:!1})}))},Ue=()=>{"customer-info"===we.step?(we.step="shipping",we.tabItems=Object.assign(Object.assign({},we.tabItems),{"customer-info":Object.assign(Object.assign({},we.tabItems["customer-info"]),{isDone:!0})})):"shipping"===we.step?(we.step="payment",we.tabItems=Object.assign(Object.assign({},we.tabItems),{shipping:Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!0})})):"payment"===we.step&&(we.step="finish")},_e=()=>{we.step="customer-info",we.tabItems=Object.assign(Object.assign({},we.tabItems),{"customer-info":Object.assign(Object.assign({},we.tabItems["customer-info"]),{isDone:!1}),payment:Object.assign(Object.assign({},we.tabItems.payment),{isDone:!1}),shipping:Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!1})}),we.selectedShippingOption=null,we.isSelectedShippingAboveDeminimis=!1,we.isSelectedShippingGuarantee=!1,we.selectedShippingOptionTransitTime="",we.dutiesTaxesFees=0,we.dutiesTaxesFeesEstimate=0,we.shipping=0,we.total=we.subtotal},Be=()=>{Oe&&clearTimeout(Oe),Oe=setTimeout((()=>{Oe=null,(async()=>{var e,t;if(!o.checkoutSessionId)return void d("Could not update store credit without checkout session id","info");const r=we.selectedLandedCost,s=we.currency||(null===(e=we.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",i=we.adjustments.reduce(((e,t)=>e+t.amount),0),a=we.items.reduce(((e,t)=>e+t.amount*t.quantity),0),{errors:l,json:c}=await ve({adjustmentsAmount:i,cartId:window.Zonos.cartId,currency:s,id:o.checkoutSessionId,itemsAmount:a,landedCostId:null==r?void 0:r.landedCostId,presentmentCountryCode:n.selectedCountryCode,storeCreditApplication:S.isEnabled&&null!==S.amountToApply?S.useFullBalance?{mode:"FULL"}:{amount:S.amountToApply,mode:"PARTIAL"}:{mode:"NONE"}});l.length>0||!c?u("Error updating checkout session with store credit"):(ke({method:(null===(t=c.checkoutSessionUpdate.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:c.checkoutSessionUpdate.subtotals}),Te(c.checkoutSessionUpdate))})()}),300)};export{de as A,ie as B,V as C,ye as D,W as E,j as F,Z as G,Pe as H,Ne as I,te as J,ne as K,oe as L,re as M,S as N,C as O,he as P,D as Q,Q as R,be as S,Ee as T,B as U,k as V,T as W,Be as X,N as Y,A as Z,H as a,q as b,ae as c,we as d,Re as e,Ae as f,_e as g,Le as h,G as i,ue as j,ce as k,De as l,le as m,Ie as n,Y as o,Te as p,ee as q,Ue as r,K as s,U as t,me as u,se as v,I as w,E as x,F as y,P as z}
1
+ import{c as e,z as t}from"./p-058f6124.js";import{s as o,l as n,e as r,t as s,f as i,b as a}from"./p-3ac97c01.js";import{l as d,b as l}from"./p-0a377722.js";import{h as c,l as u,f as m,g as v,a as p,s as h,j as y}from"./p-41dd1cb8.js";import{i as f}from"./p-67897a0d.js";import{g as w}from"./p-f830f800.js";const g=async()=>{if(!o.checkoutSessionId)return{errors:[{message:"No checkout session id found"}],json:null};const e=new URLSearchParams;e.set("checkoutSessionId",o.checkoutSessionId);const{errors:t,json:n}=await c(`/api/zonos-elements/get-checkout-session?${e.toString()}`);return{errors:t,json:n}},{reset:b,state:S}=e((()=>({amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:!1,isEnabled:!1,orderIdCreated:null,remainingBalance:null,useFullBalance:!0}))),C=()=>{b()},O=e=>{d("Store credit balance from session","info",e),S.availableBalance=e},A=async()=>{var e,t;const{errors:o,json:n}=await g();if(o.length||!n)return void u("Failed to refresh store credit balance");const r=null!==(t=null===(e=n.checkoutSession.customerProfile)||void 0===e?void 0:e.storeCreditBalance)&&void 0!==t?t:null;O(r)},I=async()=>{var e;const t=o.checkoutSessionId;if(!t){const e="No checkout session found";return u(e),S.error=e,{error:e,success:!1}}d("Applying store credit","info",{checkoutSessionId:t}),S.isApplying=!0,S.error=null;try{const{errors:o,json:n}=await c("/api/zonos-elements/store-credit/apply",{body:{checkoutSessionId:t},method:"POST"});if(o.length>0||!n){const t=(null===(e=o[0])||void 0===e?void 0:e.message)||"Failed to apply store credit";return u(t),S.error=t,S.isApplying=!1,{error:t,success:!1}}return S.appliedAmount=n.amountApplied,S.remainingBalance=n.remainingBalance,S.isApplying=!1,d("Store credit applied","info",{amountApplied:n.amountApplied,remainingBalance:n.remainingBalance}),{error:null,success:!0}}catch(e){const t=e instanceof Error?e.message:"Failed to apply store credit";return u(t),S.error=t,S.isApplying=!1,{error:t,success:!1}}},k=e=>{S.isEnabled=e,S.error=null,e||(S.amountToApply=null)},N=e=>{if(null===e)return S.amountToApply=null,void(S.error=null);e<=0?S.error="Amount must be greater than zero":null!==S.availableBalance&&e>S.availableBalance?S.error="Amount exceeds available balance":e>we.total+(we.storeCredit||0)?S.error="Amount exceeds order total":(S.error=null,S.amountToApply=e)},T=e=>{if(S.useFullBalance=e,S.error=null,e&&null!==S.availableBalance){const e=Math.min(S.availableBalance,we.total+(we.storeCredit||0));S.amountToApply=e}else e||(S.amountToApply=null)},j=()=>S.isEnabled&&null!==S.availableBalance?S.useFullBalance?Math.min(S.availableBalance,we.total+(we.storeCredit||0)):S.amountToApply||0:0,E=()=>null!==S.amountToApply&&S.amountToApply>0&&we.storeCredit>0&&we.total<=0,P=async()=>{var e,t,n;const r=o.checkoutSessionId;if(!r){const e="No checkout session found";return u(e),S.error=e,{error:e,orderId:null,success:!1}}d("Creating store credit order","info",{checkoutSessionId:r});try{const{errors:o,json:s}=await c("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:r},method:"POST"});if(o.length>0||!s){const t=(null===(e=o[0])||void 0===e?void 0:e.message)||"Failed to create store credit order";return u(t),S.error=t,{error:t,orderId:null,success:!1}}const i=(null===(n=null===(t=s.checkoutSessionStoreCreditOrderCreate)||void 0===t?void 0:t.order)||void 0===n?void 0:n.id)||null;return S.orderIdCreated=i,d("Store credit order created","info",{orderId:i}),{error:null,orderId:i,success:!0}}catch(e){const t=e instanceof Error?e.message:"Failed to create store credit order";return u(t),S.error=t,{error:t,orderId:null,success:!1}}},D=({firstName:e,lastName:t,name:o})=>{var n;if(!o&&!e&&!t)return{firstName:"",lastName:""};const r=(null==o?void 0:o.split(/\s+/))||[];return{firstName:(null==e?void 0:e.trim())||(null===(n=r[0])||void 0===n?void 0:n.trim())||"",lastName:(null==t?void 0:t.trim())||r.slice(1).join(" ").trim()||""}},L=({currentAddress:e,translatedAddress:t})=>{var o,n,r,s,i,a;const{city:d,country:l,line1:c,line2:u,postal_code:m,state:v}=e.value.address,p=e.value.name||[e.value.firstName,e.value.lastName].join(" ");return{city:(null===(o=t.city)||void 0===o?void 0:o[d])||d,country:l,line1:(null===(n=t.line1)||void 0===n?void 0:n[c])||c,line2:(null===(r=t.line2)||void 0===r?void 0:r[u||""])||u||"",name:(null===(s=t.name)||void 0===s?void 0:s[p])||p,phone:e.value.phone||"",postal_code:(null===(i=t.postal_code)||void 0===i?void 0:i[m])||m,state:(null===(a=t.state)||void 0===a?void 0:a[v])||v}},x=e=>{var t;const s="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),i=q.stripeLinkEventData,a=q.stripeAddressEventData,d=q.stripeShippingSameAsBilling?q.stripeAddressEventData:q.stripeBillingAddressEventData;if(!a||!d)throw new Error("Missing stripe address data");const l=L({currentAddress:a,translatedAddress:q.translatedAddress.address}),{firstName:c,lastName:u}=D({name:l.name}),m=L({currentAddress:d,translatedAddress:q.translatedAddress.address}),{firstName:v,lastName:p}=D({name:m.name}),h=r()||"US";return{billingAddress:{addressLine1:m.line1,addressLine2:m.line2||"",city:m.city,country:m.country,postalCode:m.postal_code,state:m.state},billingContact:{firstName:v,lastName:p,phone:m.phone},cartCurrencyCode:null===(t=we.items[0])||void 0===t?void 0:t.currencyCode,cartId:e,checkoutSessionCountry:h||n.selectedCountryCode||void 0,checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:q.companyName,email:null==i?void 0:i.value.email,firstName:c,lastName:u,phone:l.phone},isTest:!!s,landedCostAdjustments:we.promoCode?[{amount:0,productId:null,promoCode:we.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:q.shortAddressCode,shipToTaxId:q.taxId,shippingAddress:{addressLine1:l.line1,addressLine2:l.line2,city:l.city,country:l.country,postalCode:l.postal_code,state:l.state}}},R=()=>{const e="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),t=q.stripeLinkEventData,n=q.stripeAddressEventData,r=q.stripeShippingSameAsBilling?q.stripeAddressEventData:q.stripeBillingAddressEventData;if(d({stripeAddressData:n,stripeBillingAddressData:r},"info"),!n||!r)throw new Error("Missing stripe address data");const s=L({currentAddress:n,translatedAddress:q.translatedAddress.address}),{firstName:i,lastName:a}=D({name:s.name}),l=L({currentAddress:r,translatedAddress:q.translatedAddress.address}),{firstName:c,lastName:u}=D({name:l.name}),m=we.adjustments.map((e=>({amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}))),v=we.promoCode?[{amount:0,productId:null,promoCode:we.promoCode,sku:null,type:"PROMO_CODE"},...m]:m;return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{firstName:c,lastName:u,phone:l.phone},checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:q.companyName,email:null==t?void 0:t.value.email,firstName:i,lastName:a,phone:s.phone},isTest:e,items:we.items,landedCostAdjustments:v,shipToShortAddressCode:q.shortAddressCode,shipToTaxId:q.taxId,shippingAddress:{addressLine1:s.line1,addressLine2:s.line2,city:s.city,country:s.country,postalCode:s.postal_code,state:s.state}}};const z=async e=>{const o=window.Zonos.cartId;if(!o)return await(async e=>{var o;const n=t.checkoutSettings.buildLandedCost;if(n){const e=await(async e=>{var t,o,n,r,s;const i=R(),a=await e({billingAddress:i.billingAddress,billingContact:i.billingContact,checkoutSessionId:i.checkoutSessionId,contact:i.contact,landedCostAdjustments:i.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:i.shippingAddress,zonosApiRoute:m.vercel},{promoCode:we.promoCode});if(!a||!(null===(t=a.checkoutSessionWorkflow)||void 0===t?void 0:t.length)&&(null===(o=a.errors)||void 0===o?void 0:o.length))throw new Error(`Failed to build landed cost: ${(null===(r=null===(n=null==a?void 0:a.errors)||void 0===n?void 0:n[0])||void 0===r?void 0:r.message)||"Unknown error"}`);const{errors:d,json:l}=await c("/api/zonos-elements/validate-landed-cost",{body:a,headers:{"Content-Type":"application/json"},method:"POST"});if(!l||d.length)throw new Error(`Invalid landed cost object: ${(null===(s=d.find(Boolean))||void 0===s?void 0:s.message)||"Unknown error"}`);return a})(n);return e}const{errors:r,json:s}=await c("/api/zonos-elements/calculate-landed-cost",{body:R(),method:"POST",signal:null==e?void 0:e.signal});if(r.length||!s){if("The user aborted a request."===(null===(o=r[0])||void 0===o?void 0:o.message))throw new Error("The landed cost calculation request was aborted to initiate a new one.");if(r.forEach((e=>{console.warn(`Error calculating landed cost: ${e.message}`)})),!s)throw new Error("Failed to calculate landed cost");return s}return s})(e);const n=await(async({abortController:e,cartId:t})=>{var o,n,r,s,i;const{errors:a,json:d}=await c("/api/zonos-elements/cart-calculate-landed-cost",{body:x(t),method:"POST",signal:null==e?void 0:e.signal});if(a.length||!d){const e="string"==typeof(null===(o=a[0])||void 0===o?void 0:o.message)&&("The user aborted a request."===(null===(n=a[0])||void 0===n?void 0:n.message)||(null===(r=a[0])||void 0===r?void 0:r.message.includes("signal is aborted"))||(null===(s=a[0])||void 0===s?void 0:s.message.includes("The operation was aborted"))||(null===(i=a[0])||void 0===i?void 0:i.message.includes("Fetch is aborted")));throw new Error(e?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost")}return d})({abortController:e,cartId:o}),{cartWorkflow:r}=n,s=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(n,["cartWorkflow"]);return Object.assign(Object.assign({},s),{itemCreateWorkflow:r.items})},U=async({checkoutSessionId:e,eventName:o,metadata:r})=>{var s,i;const a=Date.now(),d=[...window.Zonos.trackEventLogs];window.Zonos.trackEventLogs.push({checkoutSessionId:e,eventCreated:a,eventName:o});const u=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!(null===(s=window.Zonos)||void 0===s?void 0:s.zonosQaUrl)||!!(null===(i=window.Zonos)||void 0===i?void 0:i.debug);if((v()||p()||u)&&!window.Zonos.zonosConversionTest)return;const m=n.selectedCountryCode,y=t.organizationId;if(!e)return void h({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No checkout session id found`],metadata:{allLogs:l,checkoutSessionId:e,eventName:o,metadata:r,organizationId:y,trackEventLogs:d}});y||h({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No organization id found`],metadata:{allLogs:l,checkoutSessionId:e,eventName:o,metadata:r,organizationId:y,trackEventLogs:d}});const f={checkoutSessionId:e,countryCode:m,eventCreated:a,eventName:o,metadata:Object.assign(Object.assign({},r),{trackEventLogs:d}),organizationId:y};await c("/api/zonos-elements/track-conversion-event",{body:f,method:"POST"})},_=({address:e,invalidAdddressList:t})=>{if(!e)return;if(!t)return;const o={};return t.city&&(o.city=e.city),t.line1&&(o.line1=e.line1),t.line2&&(o.line2=e.line2),t.postal_code&&(o.postal_code=e.postal_code),t.state&&(o.state=e.state),t.name&&(o.name=e.name),Object.keys(o).length?o:void 0},B=e=>e.sort(((e,t)=>e.amount-t.amount)),F=async()=>{var e;const{errors:t,json:o}=await g();return t.length||!o?(u("Failed to retrieve checkout session info before confirming payment ",t),h({endpoint:"validateCheckoutSession",errors:t.map((e=>e.message)),metadata:{allLogs:l}}),{errorMessage:s("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:!1}):(null===(e=o.checkoutSession.landedCost)||void 0===e?void 0:e.id)?{errorMessage:"",valid:!0}:(u("Landed cost is not found in the checkout session before confirming payment."),h({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:l}}),{errorMessage:s('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:!1})},J=({theme:e})=>{const o={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:t.appearance.fontSizeInputValue?`${t.appearance.fontSizeInputValue}px`:void 0,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:t.appearance.fontSizeInputLabel?`${t.appearance.fontSizeInputLabel}px`:void 0},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};return"DARK"===e?Object.assign(Object.assign({},o),{".Action":Object.assign(Object.assign({},o[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},o[".PickerItem--new"]),{color:"white"})}):o},M=({borderStyle:e,theme:t})=>"DARK"===t?{borderRadius:w({overrideBorderStyle:e}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"}:{borderRadius:w({overrideBorderStyle:e}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"},{onChange:W,reset:$,state:q}=e((()=>({checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:!1,isFetchingLandedCost:!1,isFetchingSession:!1,partyBillingId:null,partyShippingId:null,shortAddressCode:"",shouldInventoryRefund:!1,shouldRenderPayInUsdButton:!1,skipPaymentIntent:"0"!==new URLSearchParams(window.location.search).get("skipPaymentIntent"),stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:!0,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}))),Y=()=>{window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")},H=e=>{window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))},K=()=>{const e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return y(e)},G=async e=>{var o,r;const s=q.clientSecret;if(!q.stripe)return void d("Skip. Stripe is not initialized");const i=(({clientSecret:e,overrideBorderRadius:o,overridePrimaryColor:r,overrideSecondaryColor:s,overrideTheme:i,paypalEnabled:a})=>{const d=r||t.appearance.colorPrimary,l=s||t.appearance.colorSecondary,c=(window.Zonos.isCollect||window.Zonos.isInvoice?"DARK"===t.appearance.theme:d&&f(d))?"night":"flat",u="DARK"===i?"night":"flat",m=a?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},J({theme:i||"LIGHT"})),theme:i?u:c,variables:Object.assign(Object.assign({},M({borderStyle:o,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:e||void 0,customerSessionClientSecret:q.stripeCustomerSessionClientSecret||void 0,externalPaymentMethodTypes:[...m],locale:n.selectedLocale}})({clientSecret:s,overrideBorderRadius:null==e?void 0:e.overrideBorderRadius,overridePrimaryColor:null==e?void 0:e.overridePrimaryColor,overrideSecondaryColor:null==e?void 0:e.overrideSecondaryColor,overrideTheme:null==e?void 0:e.overrideTheme,paypalEnabled:null==e?void 0:e.paypalEnabled}),a=JSON.stringify(i)===JSON.stringify(q.stripeElementsOptions);if(!q.stripeElements||!q.stripeElementsForBillingAddress)return q.stripeElementsForBillingAddress=null===(o=q.stripe)||void 0===o?void 0:o.elements(i),d("Stripe elements for billing address initialized"),q.stripeElements=null===(r=q.stripe)||void 0===r?void 0:r.elements(i),q.stripeElementsOptions=i,void d("Stripe elements initialized");a||(q.stripeElements.update(i),q.stripeElementsForBillingAddress.update(i),q.stripeElementsOptions=i,q.stripeElements.fetchUpdates()),d("Stripe elements updated")},V=()=>{sessionStorage.removeItem("zonos--client-secret"),$(),q.stripe=window.Zonos.stripe},Z=({address:e,firstName:t,lastName:n,name:r,phone:s})=>{const{firstName:i,lastName:a}=D({firstName:t,lastName:n,name:r});return i&&a||h({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,firstName:t,lastName:n,name:r}}),s||h({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,phone:s}}),{city:e.city,country:e.country,firstName:i,lastName:a,line1:e.line1,line2:e.line2,phone:s||"",postal_code:e.postal_code,state:e.state}},Q=async()=>{var e,t,n,r;if(!(null===(e=q.stripeAddressEventData)||void 0===e?void 0:e.complete)||!q.stripeShippingSameAsBilling&&!(null===(t=q.stripeBillingAddressEventData)||void 0===t?void 0:t.complete)||!q.stripeBillingAddressEventData)return{partiesCreated:!1};if(!we.landedCostData)return{partiesCreated:!1};const s=null===(n=we.landedCostData.find(Boolean))||void 0===n?void 0:n.landedCost.rootId;if(!s)return h({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId}}),{partiesCreated:!1};const i=(()=>{var e,t,o,n,r,s,i,a;const d=null===(e=we.partiesData.find((e=>"DESTINATION"===e.type)))||void 0===e?void 0:e.id,l=null===(t=we.partiesData.find((e=>"PAYOR"===e.type)))||void 0===t?void 0:t.id;if(!d||!l)return!1;if(q.partyShippingId!==d||q.partyBillingId!==l)return!0;const c=JSON.stringify(null===(o=q.stripeLinkUsedWhenFetchingLC)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=q.stripeLinkEventData)||void 0===n?void 0:n.value),u=JSON.stringify(null===(r=q.stripeAddressUsedWhenAsyncAddressUpdate)||void 0===r?void 0:r.value)!==JSON.stringify(null===(s=q.stripeAddressEventData)||void 0===s?void 0:s.value),m=!q.stripeShippingSameAsBilling&&JSON.stringify(null===(i=q.stripeBillingAddressUsedWhenAsyncAddressUpdate)||void 0===i?void 0:i.value)!==JSON.stringify(null===(a=q.stripeBillingAddressEventData)||void 0===a?void 0:a.value);return c||u||m||q.taxIdUsedWhenAsyncAddressUpdate!==q.taxId||q.companyNameUsedWhenAsyncAddressUpdate!==q.companyName})();if(!i)return{partiesCreated:!1};const a=Z({address:q.stripeAddressEventData.value.address,firstName:q.stripeAddressEventData.value.firstName,lastName:q.stripeAddressEventData.value.lastName,name:q.stripeAddressEventData.value.name,phone:q.stripeAddressEventData.value.phone}),d=q.stripeShippingSameAsBilling?a:Z({address:q.stripeBillingAddressEventData.value.address,firstName:q.stripeBillingAddressEventData.value.firstName,lastName:q.stripeBillingAddressEventData.value.lastName,name:q.stripeBillingAddressEventData.value.name,phone:q.stripeBillingAddressEventData.value.phone}),m="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:v,json:p}=await c("/api/zonos-elements/create-parties",{body:{address:a,billingAddress:d,companyName:q.companyName,email:(null===(r=q.stripeLinkEventData)||void 0===r?void 0:r.value.email)||"",isTest:m,rootId:s,shortAddressCode:q.shortAddressCode,taxId:q.taxId},method:"POST"});return v.length||!p?(u("Error occurs when creating parties",JSON.stringify(v,null,2)),h({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,errors:v,json:p}}),{partiesCreated:!1}):(q.companyNameUsedWhenAsyncAddressUpdate=q.companyName,q.stripeAddressUsedWhenAsyncAddressUpdate=q.stripeAddressEventData,q.stripeBillingAddressUsedWhenAsyncAddressUpdate=q.stripeBillingAddressEventData,q.taxIdUsedWhenAsyncAddressUpdate=q.taxId,q.partyBillingId=p.billToPartyId,q.partyShippingId=p.shipToPartyId,we.partiesData=we.partiesData.map((e=>"DESTINATION"===e.type&&e.id!==p.shipToPartyId?Object.assign(Object.assign({},e),{id:p.shipToPartyId}):"PAYOR"===e.type&&e.id!==p.billToPartyId?Object.assign(Object.assign({},e),{id:p.billToPartyId}):e)),{partiesCreated:!0})},X=e=>({countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}),ee=async e=>{var n,r,s,i;const a=(null==e?void 0:e.retries)||0,l=!!(null==e?void 0:e.applyingPromocode),c=(()=>{var e;const t=we.landedCostData&&(null===(e=we.landedCostData.find(Boolean))||void 0===e?void 0:e.subtotals.items)!==we.subtotal,o=(()=>{var e,t;const o=JSON.stringify(null===(e=q.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=q.stripeLinkEventData)||void 0===t?void 0:t.value),n=q.stripeAddressEventData&&JSON.stringify(X(q.stripeAddressEventData.value))!==JSON.stringify(q.stripeAddressUsedWhenFetchingLC),r=!q.stripeShippingSameAsBilling&&q.stripeBillingAddressEventData&&JSON.stringify(X(q.stripeBillingAddressEventData.value))!==JSON.stringify(q.stripeBillingAddressUsedWhenFetchingLC);return o||n||r})();return d("isPrefetchInfoOutdated","info",{isAddressOutdated:o}),!we.landedCostData&&!q.isFetchingLandedCost||o||t})();if(!(()=>{var e,o,n,r;const s=!!(null===(e=q.stripeLinkEventData)||void 0===e?void 0:e.complete),i=!!(null===(o=q.stripeAddressEventData)||void 0===o?void 0:o.complete),a=q.stripeShippingSameAsBilling?i:!!(null===(n=q.stripeBillingAddressEventData)||void 0===n?void 0:n.complete),d=(e=>{var o,n;const r=null===(o=t.genericSettings)||void 0===o?void 0:o.countryFields,s=null===(n=t.genericSettings)||void 0===n?void 0:n.stripeCountryFieldLabels;return"stripe"===we.addressFormRenderType&&(s&&e in s?s[e]:null)||(r&&e in r?r[e]:null)})((null===(r=q.stripeAddressEventData)||void 0===r?void 0:r.value.address.country)||"US");return!!(i&&a&&s)||(d&&q.stripeAddressEventData?s&&q.stripeAddressEventData.value.firstName&&q.stripeAddressEventData.value.lastName&&q.stripeAddressEventData.value.address.line1.length>0&&(!d.stateRequired||d.stateRequired&&q.stripeAddressEventData.value.address.state.length>0)&&(!d.zipRequired||d.zipRequired&&q.stripeAddressEventData.value.address.postal_code.length>=3)&&q.stripeAddressEventData.value.phone&&q.stripeAddressEventData.value.phone.length>0:i&&a&&s)})())return{isRequestNotReady:!0};if(c&&(null===(n=q.fetchingLandedCostAbortController)||void 0===n||n.abort(),q.fetchingLandedCostAbortController=null),!c&&!l)return{isRequestNotReady:!1};a?(q.isFetchingLandedCost=!1,setTimeout((()=>{q.isFetchingLandedCost=!0}),300)):q.isFetchingLandedCost=!0,q.stripeAddressEventData&&(q.stripeAddressUsedWhenFetchingLC={countryCode:q.stripeAddressEventData.value.address.country,postalCode:q.stripeAddressEventData.value.address.postal_code,state:q.stripeAddressEventData.value.address.state}),q.stripeBillingAddressEventData&&(q.stripeBillingAddressUsedWhenFetchingLC={countryCode:q.stripeBillingAddressEventData.value.address.country,postalCode:q.stripeBillingAddressEventData.value.address.postal_code,state:q.stripeBillingAddressEventData.value.address.state}),q.stripeLinkEventData&&(q.stripeLinkUsedWhenFetchingLC=Object.assign({},q.stripeLinkEventData));try{xe(),await(async()=>{var e;const t=new AbortController;q.fetchingLandedCostAbortController=t,xe();const{checkoutSessionWorkflow:n,errors:r,itemCreateWorkflow:s,landedCostCalculateWorkflow:i,partyCreateWorkflow:a,shipmentRatingCalculateWorkflow:d}=await z(t);we.customQuotingError=(null===(e=null==r?void 0:r.find((e=>{var t;return"CUSTOM"===(null===(t=e.extensions)||void 0===t?void 0:t.ruleMessageType)})))||void 0===e?void 0:e.message)||null,we.shippingData=B((null==d?void 0:d.filter(Boolean))||[]),Ce(s),q.fetchingLandedCostAbortController=null,we.partiesData=(null==a?void 0:a.filter(Boolean))||[],we.landedCostData=(null==n?void 0:n.map((e=>{const t=null==i?void 0:i.find((t=>(null==t?void 0:t.id)===e.landedCostId));return t?Object.assign(Object.assign({},e),{landedCost:t}):null})).filter(Boolean))||[],(null==n?void 0:n.length)&&U({checkoutSessionId:o.checkoutSessionId,eventName:"checkout_quoteReceived"});const l=we.promoCodeApplied&&!we.landedCostData.find((e=>{var t;return null===(t=e.landedCost.appliedAdjustments)||void 0===t?void 0:t.find((e=>"PROMO_CODE"===e.type))}));we.promoCodeError=l,l||sessionStorage.setItem("zonos--promo-code",we.promoCode)})();const e=null===(r=we.shippingData)||void 0===r?void 0:r.find(Boolean),t=null===(s=we.landedCostData)||void 0===s?void 0:s.find((t=>t.landedCost.shipmentRating.id===(null==e?void 0:e.id))),n=t?t.subtotals:null;n&&ke({method:(null==t?void 0:t.landedCost.method)||"DDP",subtotals:n})}catch(t){if(we.landedCostData=[],we.shippingData=[],t instanceof Error&&t.message&&!["The landed cost calculation request was aborted to initiate a new one."].includes(t.message)){if(a<1)return await ee(Object.assign(Object.assign({},e),{retries:(a||0)+1})),{isRequestNotReady:!1};const o=null===(i=q.stripeAddressEventData)||void 0===i?void 0:i.value;h({endpoint:`Failed to fetch landed cost (${a} retries)`,errors:[t.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:o}})}u(t)}return q.isFetchingLandedCost=!1,{isRequestNotReady:!1}},te=async()=>{var e,t;await ee({applyingPromocode:!0}),"payment"===we.step&&ze(),await Q();const o=null===(e=we.shippingData)||void 0===e?void 0:e.find(Boolean),n=null===(t=we.landedCostData)||void 0===t?void 0:t.find((e=>e.landedCost.id===(null==o?void 0:o.id)));o&&n&&await Pe({applySubtotalsOnly:!1,landedCostId:n.landedCostId,selectedShippingOption:o})},oe=()=>{we.promoCode="",sessionStorage.removeItem("zonos--promo-code"),we.promoCodeError=!1,we.promoCodeApplied=!1},ne=async()=>{"payment"===we.step&&ze(),oe(),await te()},re=e=>{let t=[],o=!0;const n=window.Zonos.isCollect,r=window.Zonos.isInvoice;switch(e){case"succeeded":t=[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.")],(n||r)&&(t=[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.")]),o=!1;break;case"requires_capture":case"processing":t=[s("Payment processing. We'll update you when payment is received.")],o=!1;break;case"requires_payment_method":t=[s("Payment failed. Please try another payment method.")],n&&(t=[s("Payment failed. Please reload the page and try another payment method.")]);break;case"requires_action":o=!1,t=[s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")];default:t=[s("Something went wrong.")]}return{isError:o,messages:t}},se=async()=>{var e,o;const{onInventoryCheck:n}=t.checkoutSettings,r=!!(null===(o=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===o?void 0:o.value);if(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&r){const{errors:e,json:t}=await c("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"});return e.length||!t?(u("Error occurs when handling inventory refund","warn",JSON.stringify(e)),null):t.available&&204!==t.status?t.available||200===t.status?(q.shouldInventoryRefund=!0,null):null: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("function"!=typeof n)return null;try{return await n({items:we.items},{translate:s,zonosApiRoute:m.vercel})}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw h({endpoint:"onInventoryCheck",errors:[`cartId: ${window.Zonos.cartId} - ${t}`],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:we.items}}),e}},ie=async()=>{var e,t;const o=!!(null===(t=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===t?void 0:t.value);window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o&&await c("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})},ae=async({clientSecret:e,storybookForceStatus:t})=>{if(t){const{isError:e,messages:o}=re(t);return{error:e,messages:o}}const o=e||q.clientSecret;if(!q.stripe||!o)return u("Failed to retrieve payment intent. Stripe is not initialized"),{error:!0,message:[s("Something went wrong.")]};const{paymentIntent:n}=await q.stripe.retrievePaymentIntent(o),r=null==n?void 0:n.status,{isError:i,messages:a}=re(r);return{amount:null==n?void 0:n.amount,currency:null==n?void 0:n.currency,error:i,messages:a,paymentIntentId:null==n?void 0:n.id,paymentMethod:null==n?void 0:n.payment_method,status:r}},de=async e=>{var t,n;const r=!!(null===(t=q.stripePaymentEventData)||void 0===t?void 0:t.complete),i=q.stripeElements,a=q.stripe,l=q.clientSecret;if(q.customErrorMessage=null,!(null===(n=we.selectedLandedCost)||void 0===n?void 0:n.landedCost.id)&&!(null==e?void 0:e.noLandedCostCheck))throw new Error("Attempted to confirm the payment when no landed cost is found in store");const c=await F();if(!c.valid)throw q.customErrorMessage=c.errorMessage,new Error(c.errorMessage);const u=o.checkoutSessionId;if(a&&i&&r&&l&&u){const e=new URL(window.location.href);e.searchParams.set("payment_intent_client_secret",l),e.searchParams.set("zonosCheckoutSessionId",u),U({checkoutSessionId:u,eventName:"checkout_paymentInfoCompleted"});const{error:t,paymentIntent:o}=await a.confirmPayment({confirmParams:{return_url:e.toString()},elements:i,redirect:"if_required"});if(d("Payment intent confirmed","info",{error:t,paymentIntent:o}),"requires_action"===(null==o?void 0:o.status))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(t){if("card_error"===t.type||"validation_error"===t.type)throw new Error(t.message);if("invalid_request_error"===t.type&&"payment_intent_unexpected_state"===t.code)return;throw new Error("An unexpected error occurred.")}if("requires_payment_method"===o.status)throw new Error(s("Payment failed. Please try another payment method."))}},le=()=>{var e;const t=we.items.reduce(((e,t)=>e+t.amount*t.quantity),0),r=o.enabledVariantTestKeys||[];return{adjustmentsAmount:we.adjustments.reduce(((e,t)=>e+t.amount),0),cartId:window.Zonos.cartId,currency:(null===(e=we.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",customerAuthenticationToken:we.customerAuthenticationToken||void 0,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:t,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:n.selectedCountryCode,skipPaymentIntent:q.skipPaymentIntent,varianceTestInput:r}},ce=async()=>{var e;if(!o.checkoutSessionId)return h({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:l,cartId:window.Zonos.cartId}}),void Ie({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")});const{errors:t,json:n}=await c("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:o.checkoutSessionId},method:"POST"}),r=null===(e=null==n?void 0:n.checkoutSessionPaymentIntentCreate)||void 0===e?void 0:e.clientSecret;if(t.length||!r)return u("Error occurs when getting payment intent",JSON.stringify(t,null,2)),h({endpoint:"Error creating payment intent",errors:t.map((e=>e.message)),metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,clientSecret:r}}),void Ie({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")});Te(n.checkoutSessionPaymentIntentCreate)},ue=async()=>{var e,t;if(!n.targetCurrency)return u("Failed to create checkout session - missing localizationStore.targetCurrency"),!1;q.isFetchingSession=!0;const o=le();d("Checkout session body","info",o);const{errors:r,json:s}=await c("/api/zonos-elements/create-checkout-session",{body:o,method:"POST"});if(q.isFetchingSession=!1,r.length||!s){const t=null===(e=r.find((e=>e.message)))||void 0===e?void 0:e.message;if(Array.isArray(t)&&t.some((e=>"Cart is expired."===e.message)))throw new Error("Cart is expired.");return u("Error occurred when creating checkout session",JSON.stringify(r,null,2)),!1}const i=s.checkoutSessionCreate;return Te(i),ke({method:(null===(t=i.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:i.subtotals}),d("Exchange rate updated for cart items (checkout session create)","info",we.exchangeRate),d("done-init-checkout-session"),!0},me=async()=>{const e=o.checkoutSessionId;if(!e)return u("Failed to update checkout session base currency"),!1;if("LOCAL"===t.checkoutSettings.allowedSettlementCurrencies)return d('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency'),!0;const{json:n}=await c("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:q.checkoutSettlementCurrency},method:"POST"}),r=null==n?void 0:n.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;return n&&r===q.checkoutSettlementCurrency?(d(`Updated checkout session to settlement currency "${r}".`),!0):(u("Failed to update checkout session base currency"),!1)},ve=async({adjustmentsAmount:e,cartId:t,currency:r,id:s,itemsAmount:i,landedCostId:a,presentmentCountryCode:d,storeCreditApplication:l})=>{const m=o.enabledVariantTestKeys||[],{errors:v,json:p}=await c("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:e,billToPartyId:q.partyBillingId,cartId:t,currency:r,customerAuthenticationToken:we.customerAuthenticationToken||void 0,id:s,itemsAmount:i,landedCostId:a,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:d,shipToPartyId:q.partyShippingId,skipPaymentIntent:q.skipPaymentIntent,storeCreditApplication:l,varianceTestInput:m},method:"POST"});return v.length||!p?(u("Error occurs when updating checkout session",JSON.stringify(v,null,2)),{errors:v,json:p}):{errors:[],json:p}},pe=({currentAddress:e,translatedAddressResult:t})=>{const o={};if(!t)return o;const{city:n,line1:r,line2:s,name:i,postal_code:a,state:d}=t;return e.city&&n&&(o.city={[e.city]:n}),e.line1&&r&&(o.line1={[e.line1]:r}),e.line2&&s&&(o.line2={[e.line2]:s}),e.postal_code&&a&&(o.postal_code={[e.postal_code]:a}),e.state&&d&&(o.state={[e.state]:d}),e.name&&i&&(o.name={[e.name]:i}),o},he=async({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t})=>{var o,n,r,s;const i=(({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:o,stripeBillingAddressEventData:n,stripeShippingSameAsBilling:r})=>{const s=!!(null==o?void 0:o.complete);if(!s||!(r?s:null==n?void 0:n.complete))return null;if(!e&&!t)return null;const i=o.value,a=(null==n?void 0:n.value)||null,{firstName:d,lastName:l}=D({firstName:i.firstName,lastName:i.lastName,name:i.name}),c=`${d} ${l}`,{firstName:u,lastName:m}=D({firstName:null==a?void 0:a.firstName,lastName:null==a?void 0:a.lastName,name:(null==a?void 0:a.name)||""}),v=u&&m?`${u} ${m}`:"",p=i.address,h=null==a?void 0:a.address;return{address:_({address:Object.assign(Object.assign({},p),{name:c}),invalidAdddressList:e}),billingAddress:r?void 0:_({address:h?Object.assign(Object.assign({},h),{name:v}):null,invalidAdddressList:t}),destinationCountry:p.country}})({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:q.stripeAddressEventData,stripeBillingAddressEventData:q.stripeBillingAddressEventData,stripeShippingSameAsBilling:q.stripeShippingSameAsBilling});if(!i)return void(q.translatedAddress={address:{},billingAddress:{}});const a=(()=>{var e,t,o,n;const r=JSON.stringify(null===(e=q.stripeAddressUsedWhenValidatingAddress)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=q.stripeAddressEventData)||void 0===t?void 0:t.value),s=!q.stripeShippingSameAsBilling&&JSON.stringify(null===(o=q.stripeBillingAddressEventData)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=q.stripeBillingAddressUsedWhenValidatingAddress)||void 0===n?void 0:n.value);return r||s})();if(!a)return;const{errors:d,json:l}=await c("/api/zonos-elements/validate-address",{body:i,method:"POST"});if(d.length||!l)return u("Error occurs when translating address to latin",JSON.stringify(d,null,2)),void(q.translatedAddress={address:{},billingAddress:{}});q.stripeAddressUsedWhenValidatingAddress=q.stripeAddressEventData,q.stripeBillingAddressUsedWhenValidatingAddress=q.stripeBillingAddressEventData;const m=null===(o=q.stripeAddressEventData)||void 0===o?void 0:o.value.address,v=null===(n=q.stripeBillingAddressEventData)||void 0===n?void 0:n.value.address;q.translatedAddress={address:m?pe({currentAddress:Object.assign(Object.assign({},m),{name:null===(r=q.stripeAddressEventData)||void 0===r?void 0:r.value.name}),translatedAddressResult:l.address||null}):{},billingAddress:q.stripeShippingSameAsBilling?{}:pe({currentAddress:Object.assign(Object.assign({},v),{name:null===(s=q.stripeBillingAddressEventData)||void 0===s?void 0:s.value.name}),translatedAddressResult:l.billingAddress||null})}};W("clientSecret",(e=>{e&&q.stripe&&sessionStorage.setItem("zonos--client-secret",e),e||sessionStorage.removeItem("zonos--client-secret")}));const{onChange:ye,reset:fe,state:we}=e((()=>({addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:!1,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:!1,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:!1,isSelectedShippingGuarantee:!1,isStagingMode:p(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:!1,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:!1,step:"customer-info",storeCredit:0,subtotal:0,tabItems:{"customer-info":{index:1,isDone:!1,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:!1,label:"Shipping",value:"shipping"},payment:{index:3,isDone:!1,label:"Payment",value:"payment"}},total:0}))),ge=e=>{switch(e){case"DAYS":return s("days");case"WEEKS":return s("weeks");default:return s("business days")}},be=e=>{var t;const o=null===(t=e.shippingProfile)||void 0===t?void 0:t.transitTime;return(null==o?void 0:o.min)&&(null==o?void 0:o.max)&&(null==o?void 0:o.type)?{maxTransit:o.max,minTransit:o.min,unit:ge(o.type)}:null},Se=({item1:e,item2:t})=>!(!e||!t)&&(t.sku&&e.sku&&e.sku===t.sku||t.description&&e.description&&e.description===t.description||e.name&&t.name&&e.name===t.name),Ce=e=>{d("Checking item restrictions");const t=e.map((e=>{if(!e.restriction)return null;const{restriction:t}=e,o=we.items.find((t=>Se({item1:t,item2:e})));return Object.assign(Object.assign({matchedItem:o},e),{restriction:t})})).filter(Boolean);return we.restrictedItems=t,we.items=we.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!!t.find((t=>Se({item1:t,item2:e})))}))),{cartItems:we.items,restrictedItems:t}};let Oe=null;const Ae=()=>{o.checkoutSessionId=null,Oe&&(clearTimeout(Oe),Oe=null),C(),fe()},Ie=({messages:e,title:t})=>{Ae(),V(),we.step="error",we.error={messages:e,title:t}},ke=({dutiesTaxesFeesEstimate:e,method:t,subtotals:o})=>{var n;we.exchangeRate=o.exchangeRate,we.adjustmentTotal=o.adjustments,we.dutiesTaxesFees="DAP"===t?null:o.landedCostTotal,we.storeCredit=null!==(n=o.storeCredit)&&void 0!==n?n:0,we.subtotal=o.items,we.total=o.total,we.currency=o.presentmentCurrencyCode,we.dutiesTaxesFeesEstimate=e||null},Ne=()=>!!we.items.filter((e=>e.amount>0)).find((e=>!e.isRestricted)),Te=e=>{var t,n,r,s,c,u,m;q.clientSecret=e.clientSecret,q.stripeCustomerSessionClientSecret=e.customerSessionClientSecret,q.customerProfile=e.customerProfile,we.checkoutSession=e,O(null!==(n=null===(t=e.customerProfile)||void 0===t?void 0:t.storeCreditBalance)&&void 0!==n?n:null),e.id||h({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:l,checkoutSession:e}}),e.id&&(o.checkoutSessionId=e.id);const v=i(e.varianceTestResults||[]);a(v);const p=(null===(c=null===(s=null===(r=we.checkoutSession)||void 0===r?void 0:r.metadata)||void 0===s?void 0:s.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===c?void 0:c.value)||(null===(m=null===(u=window.Zonos.cartData)||void 0===u?void 0:u.metadata.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===m?void 0:m.value)||null;p&&(d(`Found externalConfirmationPageURL: ${p}`),we.externalConfirmationPageURL=p)},je=async({adjustmentsAmount:e,cartId:t,currency:r,dutiesTaxesFeesEstimate:i,itemsAmount:a,landedCostId:l,shouldInitSessionOnFailure:c})=>{var m;if(l&&we.selectedLandedCost&&(ke({dutiesTaxesFeesEstimate:i,method:we.landedCostMethod,subtotals:we.selectedLandedCost.subtotals}),d("Exchange rate updated for cart items (landed cost subtotal)","info",we.exchangeRate)),!o.checkoutSessionId)return d("Could not update cart total without checkout session id","info"),!1;const{errors:v,json:p}=await ve({adjustmentsAmount:e,billToPartyId:q.partyBillingId,cartId:t,currency:r,id:o.checkoutSessionId,itemsAmount:a,landedCostId:l,presentmentCountryCode:n.selectedCountryCode,shipToPartyId:q.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});if(v.length>0||!p){if(u("Error occurs when updating checkout session."),c){d("Initiating checkout session on failure","info");const e=await ue();return d(`stripeStoreInitCheckoutSession: ${e}`),!!e||(Ie({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")}),!1)}return!1}return l||(ke({method:(null===(m=p.checkoutSessionUpdate.landedCost)||void 0===m?void 0:m.method)||"DDP",subtotals:p.checkoutSessionUpdate.subtotals}),d("Exchange rate updated for cart items (checkout session update)","info",we.exchangeRate)),Te(p.checkoutSessionUpdate),!0},Ee=e=>{var o,n,r;return"DAP"===e.method&&(null===(n=null===(o=t.genericSettings)||void 0===o?void 0:o.domesticCountries)||void 0===n?void 0:n.includes((null===(r=q.stripeAddressEventData)||void 0===r?void 0:r.value.address.country)||"US"))||"DAP"===e.method&&e.remittance.length&&"ZONOS"===e.landedCostGuaranteeCode?"DDP":e.method},Pe=async({applySubtotalsOnly:e,landedCostId:n,selectedShippingOption:r})=>{var s,i,a,l,c,u,m,v,p,h,y;d("Updating selected shipping option","info",{landedCostId:n,selectedShippingOption:r}),we.selectedShippingOption=r;const f=be(we.selectedShippingOption);if(f){const{maxTransit:e,minTransit:t,unit:o}=f;we.selectedShippingOptionTransitTime=`${t}-${e} ${o}`}else we.selectedShippingOptionTransitTime="";const w=null===(s=we.landedCostData)||void 0===s?void 0:s.find((e=>e.landedCostId===n));if(we.selectedLandedCost=w||null,!w)return!1;const g=((null===(i=w.landedCost.amountSubtotals)||void 0===i?void 0:i.landedCostTotal)||0)*w.subtotals.exchangeRate.rate;g&&d(`DAP quote, using estimate: ${g}`,"info"),we.landedCostMethod=Ee(w.landedCost),we.shipping=w.subtotals.shipping;const b="ZONOS"===(null===(a=null==w?void 0:w.landedCost)||void 0===a?void 0:a.landedCostGuaranteeCode),S=!!(null===(c=null===(l=null==w?void 0:w.landedCost)||void 0===l?void 0:l.deMinimis)||void 0===c?void 0:c.find((e=>["DUTY","TAX"].includes(e.type)&&"ABOVE"===e.threshold)));we.isSelectedShippingAboveDeminimis=S,we.isSelectedShippingGuarantee=b;let C=!1;e?(ke({dutiesTaxesFeesEstimate:g,method:we.landedCostMethod,subtotals:w.subtotals}),d("Exchange rate updated for cart items (landed cost subtotal)","info",we.exchangeRate),C=!0):C=await je({adjustmentsAmount:we.adjustmentTotal,billToPartyId:q.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:g,landedCostId:null===(u=w.landedCost)||void 0===u?void 0:u.id,shipToPartyId:q.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});const O=null===(m=we.items.find(Boolean))||void 0===m?void 0:m.currencyCode,A=(null===(v=q.stripeAddressEventData)||void 0===v?void 0:v.value.address.country)||"US";return q.shouldRenderPayInUsdButton="USD"===O&&"LOCAL_AND_USD"===t.checkoutSettings.allowedSettlementCurrencies&&"USD"!==(null===(p=we.checkoutSession)||void 0===p?void 0:p.subtotals.presentmentCurrencyCode)&&!!(null===(y=null===(h=t.genericSettings)||void 0===h?void 0:h.usdSettlementCountryEnabled)||void 0===y?void 0:y.includes(A)),C},De=({isPreview:e,sessionTimeout:t})=>{if(e)return;const o=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout"),n=o&&!isNaN(parseInt(o,10))?parseInt(o,10):t;d(`==START CHECKOUT TIMEOUT - ${n}==`),we.checkoutTimeoutInterval=setTimeout((()=>{we.checkoutSessionTimeoutShow=!0}),n)},Le=()=>{we.checkoutTimeoutInterval&&(clearTimeout(we.checkoutTimeoutInterval),we.checkoutTimeoutInterval=null)},xe=()=>{we.items=we.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1}))),we.restrictedItems=[]},Re=async({adjustments:e,cartItems:t,landedCostId:n,shouldInitSessionOnFailure:r=!0})=>{var s;we.adjustments=e,we.items=t.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1})));const i=null===(s=t.find(Boolean))||void 0===s?void 0:s.currencyCode,a=t.reduce(((e,t)=>e+t.amount*t.quantity),0),d=e.reduce(((e,t)=>e+t.amount),0);i&&a&&(we.currency=i,q.isFetchingSession=!0,await je({adjustmentsAmount:d,billToPartyId:q.partyBillingId,cartId:window.Zonos.cartId,currency:i,dutiesTaxesFeesEstimate:0,itemsAmount:a,landedCostId:n,shipToPartyId:q.partyShippingId,shouldInitSessionOnFailure:r,varianceTestInput:o.enabledVariantTestKeys||[]}),q.isFetchingSession=!1)},ze=()=>{"shipping"===we.step?(we.step="customer-info",we.tabItems=Object.assign(Object.assign({},we.tabItems),{"customer-info":Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!1})})):"payment"===we.step?(we.step="shipping",we.tabItems=Object.assign(Object.assign({},we.tabItems),{shipping:Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!1})})):"finish"===we.step&&(we.step="payment",we.tabItems=Object.assign(Object.assign({},we.tabItems),{payment:Object.assign(Object.assign({},we.tabItems.payment),{isDone:!1})}))},Ue=()=>{"customer-info"===we.step?(we.step="shipping",we.tabItems=Object.assign(Object.assign({},we.tabItems),{"customer-info":Object.assign(Object.assign({},we.tabItems["customer-info"]),{isDone:!0})})):"shipping"===we.step?(we.step="payment",we.tabItems=Object.assign(Object.assign({},we.tabItems),{shipping:Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!0})})):"payment"===we.step&&(we.step="finish")},_e=()=>{we.step="customer-info",we.tabItems=Object.assign(Object.assign({},we.tabItems),{"customer-info":Object.assign(Object.assign({},we.tabItems["customer-info"]),{isDone:!1}),payment:Object.assign(Object.assign({},we.tabItems.payment),{isDone:!1}),shipping:Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!1})}),we.selectedShippingOption=null,we.isSelectedShippingAboveDeminimis=!1,we.isSelectedShippingGuarantee=!1,we.selectedShippingOptionTransitTime="",we.dutiesTaxesFees=0,we.dutiesTaxesFeesEstimate=0,we.shipping=0,we.total=we.subtotal},Be=()=>{Oe&&clearTimeout(Oe),Oe=setTimeout((()=>{Oe=null,(async()=>{var e,t;if(!o.checkoutSessionId)return void d("Could not update store credit without checkout session id","info");const r=we.selectedLandedCost,s=we.currency||(null===(e=we.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",i=we.adjustments.reduce(((e,t)=>e+t.amount),0),a=we.items.reduce(((e,t)=>e+t.amount*t.quantity),0),{errors:l,json:c}=await ve({adjustmentsAmount:i,cartId:window.Zonos.cartId,currency:s,id:o.checkoutSessionId,itemsAmount:a,landedCostId:null==r?void 0:r.landedCostId,presentmentCountryCode:n.selectedCountryCode,storeCreditApplication:S.isEnabled&&null!==S.amountToApply?S.useFullBalance?{mode:"FULL"}:{amount:S.amountToApply,mode:"PARTIAL"}:{mode:"NONE"}});l.length>0||!c?u("Error updating checkout session with store credit"):(ke({method:(null===(t=c.checkoutSessionUpdate.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:c.checkoutSessionUpdate.subtotals}),Te(c.checkoutSessionUpdate))})()}),300)};export{de as A,ie as B,V as C,ye as D,W as E,j as F,Z as G,Pe as H,Ne as I,te as J,ne as K,oe as L,re as M,S as N,C as O,he as P,D as Q,Q as R,be as S,Ee as T,B as U,k as V,T as W,Be as X,N as Y,A as Z,H as a,q as b,ae as c,we as d,Re as e,Ae as f,_e as g,Le as h,G as i,ue as j,ce as k,De as l,le as m,Ie as n,Y as o,Te as p,ee as q,Ue as r,K as s,U as t,me as u,se as v,I as w,E as x,F as y,P as z}
@@ -1 +1 @@
1
- System.register(["./p-7261e245.system.js","./p-fbccfa3e.system.js","./p-cf69bcc4.system.js","./p-0dd5a4b8.system.js","./p-23e7c655.system.js","./p-27fad55a.system.js","./p-45bd8072.system.js","./p-ac30b7a8.system.js","./p-d938f42f.system.js","./p-01174496.system.js","./p-d18a2b2c.system.js","./p-7501c637.system.js"],(function(o){"use strict";var t,s,e,n,i,a,c,l,r;return{setters:[function(o){t=o.r;s=o.h;e=o.a},function(o){n=o.d},function(o){i=o.t},function(o){a=o.r},function(o){c=o.c},function(o){l=o.c},function(o){r=o.r},function(){},function(){},function(){},function(){},function(){}],execute:function(){var h=":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--cart-table{width:100%;border:none;border-collapse:collapse;overflow:auto;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column{padding:8px;padding-left:0;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column:last-child{text-align:right;padding-right:0}:host .zonos--cart-table .zonos--column:first-child{padding-left:0;width:50px}:host .zonos--cart-table .zonos--cart-item-link{text-align:left}:host .zonos--cart-table .zonos--cart-item-created-at{text-align:right}:host .zonos--cart-table td{vertical-align:middle}:host .zonos--cart-item-price zonos-text{white-space:nowrap}:host(.mobile) table{margin-top:16px}:host(.mobile) table td{vertical-align:top}";var f=h;var d=o("zonos_invoice_cart_items",function(){function o(o){t(this,o);this.isMobile=false;this.errorImages=[];this.locale=null}o.prototype.componentWillLoad=function(){var o=navigator.language;this.locale=o};o.prototype.render=function(){var o=this;var t=n.items.filter((function(o){return!o.isRestricted}));return s(e,{key:"33a10486833e881dd8405984cfc59611b064bef5",class:c(["zonos--invoice-cart-items zonos--elements",this.isMobile&&"mobile"])},s("table",{key:"c6c3a6017050cc385bc5944e83ca8db1f2564884",class:"zonos--cart-table"},s("tbody",{key:"6a232dbdf2e6e6c58b65d6360c9190d720c7dc1f"},t.map((function(t){var e,n,c,l;var r=(n=(e=t.attributes)===null||e===void 0?void 0:e.find((function(o){return o.key==="invoiceId"||o.key==="INVOICE_ID"})))===null||n===void 0?void 0:n.value;var h=(l=(c=t.attributes)===null||c===void 0?void 0:c.find((function(o){return o.key==="invoiceCreatedAt"})))===null||l===void 0?void 0:l.value;var f=h&&o.locale?new Date(h).toLocaleDateString(o.locale,{day:"numeric",month:"long",year:"numeric"}):null;var d=r?"https://dashboard.zonos.com/billing/invoices/".concat(r):null;return s("tr",{class:"zonos--invoice-cart-item"},s("td",{class:"zonos--column zonos--cart-item-title"},s("zonos-text",{type:"semiBoldLabel"},i("Invoice:"))),s("td",{class:"zonos--column zonos--cart-item-link"},d&&r&&s("zonos-link",{href:d},r),o.isMobile&&s("zonos-text",{type:"caption"},f)),s("td",{class:"zonos--column zonos--cart-item-created-at"},!o.isMobile&&s("zonos-text",{type:"label"},f)),s("td",{class:"zonos--column zonos--cart-item-price"},s("zonos-text",{type:"label"},a({amount:t.amount,isForeign:false}))))})))))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});return o}());d.style=f;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{position:-webkit-sticky;position:sticky;bottom:60px}:host .zonos--invoice-table{width:100%;border:none;border-collapse:collapse;overflow:auto;font-size:var(--zonos-elements-font-size-base)}:host .zonos--invoice-table .zonos--column{padding:8px 8px;vertical-align:top}:host .zonos--invoice-table .zonos--column:last-child{text-align:right;padding-right:0}:host .zonos--invoice-table .zonos--column:first-child{width:60px;max-width:100px}:host .zonos--title-with-icon{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:8px}:host .zonos--invoice-subtotal-price{text-align:right}:host .zonos--invoice-subtotal-price zonos-text{white-space:nowrap}:host .zonos--invoice-total .zonos--column{padding:16px 0}:host .zonos--invoice-total .zonos--invoice-subtotal-title,:host .zonos--invoice-total .zonos--invoice-subtotal-price{border-top:1px solid var(--zonos-elements-gray-200)}:host .zonos--invoice-subtotal-price zonos-text,:host .zonos--invoice-pay-total zonos-text{white-space:nowrap}:host(.mobile){position:relative;bottom:0}";var m=b;var u=o("zonos_invoice_subtotal",function(){function o(o){t(this,o);this.isMobile=false}o.prototype.render=function(){return s(e,{key:"99eaf74026ee26cc11ab78adf57f1b7eb55309d3",class:c(["zonos--invoice-subtotal zonos--elements",this.isMobile&&"mobile"])},s("table",{key:"a3f9a029a979fd4afeaee02c55a49c4e6547e483",class:"zonos--invoice-table"},s("tr",{key:"bf8594623c4eb7492899647fbe3bc4fa0a8b1973",class:"zonos--row zonos--invoice-total"},s("td",{key:"b967b527461161244479ff8ac5ae40bdbd7f2b38",class:"zonos--column"}),s("td",{key:"4af6f40176c19c0aad1109a8be722a2b41fc66e9",class:"zonos--column zonos--invoice-subtotal-title"},s("zonos-text",{key:"0b01c51ddabd61c0abaf8214e05db2fe6a650941",type:"semiBoldLabel"},i("Payment total"))),s("td",{key:"00109c0948f0110c478643461a0a70a7cc2441ba",class:"zonos--column zonos--invoice-subtotal-price"},r({content:s("zonos-text",{type:"semiBoldLabel"},a({amount:l.amountTotalDue||0,isForeign:true})),isLoading:l.isFetchingPayorInfo,skeletonHeight:"14px",skeletonWidth:"150px"})))))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});return o}());u.style=m}}}));
1
+ System.register(["./p-7261e245.system.js","./p-aabb921f.system.js","./p-31d1b874.system.js","./p-5e3e5e3e.system.js","./p-23e7c655.system.js","./p-16a80e3c.system.js","./p-45bd8072.system.js","./p-ac30b7a8.system.js","./p-d938f42f.system.js","./p-01174496.system.js","./p-d18a2b2c.system.js","./p-7501c637.system.js"],(function(o){"use strict";var t,s,e,n,i,a,c,l,r;return{setters:[function(o){t=o.r;s=o.h;e=o.a},function(o){n=o.d},function(o){i=o.t},function(o){a=o.r},function(o){c=o.c},function(o){l=o.c},function(o){r=o.r},function(){},function(){},function(){},function(){},function(){}],execute:function(){var h=":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--cart-table{width:100%;border:none;border-collapse:collapse;overflow:auto;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column{padding:8px;padding-left:0;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column:last-child{text-align:right;padding-right:0}:host .zonos--cart-table .zonos--column:first-child{padding-left:0;width:50px}:host .zonos--cart-table .zonos--cart-item-link{text-align:left}:host .zonos--cart-table .zonos--cart-item-created-at{text-align:right}:host .zonos--cart-table td{vertical-align:middle}:host .zonos--cart-item-price zonos-text{white-space:nowrap}:host(.mobile) table{margin-top:16px}:host(.mobile) table td{vertical-align:top}";var f=h;var d=o("zonos_invoice_cart_items",function(){function o(o){t(this,o);this.isMobile=false;this.errorImages=[];this.locale=null}o.prototype.componentWillLoad=function(){var o=navigator.language;this.locale=o};o.prototype.render=function(){var o=this;var t=n.items.filter((function(o){return!o.isRestricted}));return s(e,{key:"33a10486833e881dd8405984cfc59611b064bef5",class:c(["zonos--invoice-cart-items zonos--elements",this.isMobile&&"mobile"])},s("table",{key:"c6c3a6017050cc385bc5944e83ca8db1f2564884",class:"zonos--cart-table"},s("tbody",{key:"6a232dbdf2e6e6c58b65d6360c9190d720c7dc1f"},t.map((function(t){var e,n,c,l;var r=(n=(e=t.attributes)===null||e===void 0?void 0:e.find((function(o){return o.key==="invoiceId"||o.key==="INVOICE_ID"})))===null||n===void 0?void 0:n.value;var h=(l=(c=t.attributes)===null||c===void 0?void 0:c.find((function(o){return o.key==="invoiceCreatedAt"})))===null||l===void 0?void 0:l.value;var f=h&&o.locale?new Date(h).toLocaleDateString(o.locale,{day:"numeric",month:"long",year:"numeric"}):null;var d=r?"https://dashboard.zonos.com/billing/invoices/".concat(r):null;return s("tr",{class:"zonos--invoice-cart-item"},s("td",{class:"zonos--column zonos--cart-item-title"},s("zonos-text",{type:"semiBoldLabel"},i("Invoice:"))),s("td",{class:"zonos--column zonos--cart-item-link"},d&&r&&s("zonos-link",{href:d},r),o.isMobile&&s("zonos-text",{type:"caption"},f)),s("td",{class:"zonos--column zonos--cart-item-created-at"},!o.isMobile&&s("zonos-text",{type:"label"},f)),s("td",{class:"zonos--column zonos--cart-item-price"},s("zonos-text",{type:"label"},a({amount:t.amount,isForeign:false}))))})))))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});return o}());d.style=f;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{position:-webkit-sticky;position:sticky;bottom:60px}:host .zonos--invoice-table{width:100%;border:none;border-collapse:collapse;overflow:auto;font-size:var(--zonos-elements-font-size-base)}:host .zonos--invoice-table .zonos--column{padding:8px 8px;vertical-align:top}:host .zonos--invoice-table .zonos--column:last-child{text-align:right;padding-right:0}:host .zonos--invoice-table .zonos--column:first-child{width:60px;max-width:100px}:host .zonos--title-with-icon{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:8px}:host .zonos--invoice-subtotal-price{text-align:right}:host .zonos--invoice-subtotal-price zonos-text{white-space:nowrap}:host .zonos--invoice-total .zonos--column{padding:16px 0}:host .zonos--invoice-total .zonos--invoice-subtotal-title,:host .zonos--invoice-total .zonos--invoice-subtotal-price{border-top:1px solid var(--zonos-elements-gray-200)}:host .zonos--invoice-subtotal-price zonos-text,:host .zonos--invoice-pay-total zonos-text{white-space:nowrap}:host(.mobile){position:relative;bottom:0}";var m=b;var u=o("zonos_invoice_subtotal",function(){function o(o){t(this,o);this.isMobile=false}o.prototype.render=function(){return s(e,{key:"99eaf74026ee26cc11ab78adf57f1b7eb55309d3",class:c(["zonos--invoice-subtotal zonos--elements",this.isMobile&&"mobile"])},s("table",{key:"a3f9a029a979fd4afeaee02c55a49c4e6547e483",class:"zonos--invoice-table"},s("tr",{key:"bf8594623c4eb7492899647fbe3bc4fa0a8b1973",class:"zonos--row zonos--invoice-total"},s("td",{key:"b967b527461161244479ff8ac5ae40bdbd7f2b38",class:"zonos--column"}),s("td",{key:"4af6f40176c19c0aad1109a8be722a2b41fc66e9",class:"zonos--column zonos--invoice-subtotal-title"},s("zonos-text",{key:"0b01c51ddabd61c0abaf8214e05db2fe6a650941",type:"semiBoldLabel"},i("Payment total"))),s("td",{key:"00109c0948f0110c478643461a0a70a7cc2441ba",class:"zonos--column zonos--invoice-subtotal-price"},r({content:s("zonos-text",{type:"semiBoldLabel"},a({amount:l.amountTotalDue||0,isForeign:true})),isLoading:l.isFetchingPayorInfo,skeletonHeight:"14px",skeletonWidth:"150px"})))))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});return o}());u.style=m}}}));
@@ -1 +1 @@
1
- import{r as o,h as e,a as t,g as s}from"./p-ce75b047.js";import{d as i}from"./p-908f13ae.js";import{l,i as n,t as r,g as h,j as a,k as d,m as c,n as m,d as p}from"./p-13041752.js";import{z as g,g as w,m as f}from"./p-058f6124.js";import{c as z}from"./p-b4b7f705.js";import{h as u,l as b}from"./p-41dd1cb8.js";import{g as v}from"./p-5883217a.js";import{l as x}from"./p-0a377722.js";const y=o=>{const e=null==o?void 0:o.replace("www.","").replace("https://","");return e&&new RegExp(e).test(window.location.href)},k=()=>{var o,e;const{productAddToCartElementSelector:t,productDescriptionElementSelector:s,productTitleElementSelector:i,restrictionBehavior:l}=g.helloSettings;i&&s||x("Hello could not check item restrictions - must provide title and description selectors.");const r=i&&n(i)&&document.querySelectorAll(i)||[],h=s&&n(s)&&document.querySelectorAll(s)||[];if(r.length!==h.length)return x("Hello could not check item restrictions - Title and description selectors do not match"),[];const a="RESTRICT_AND_BLOCK"===l,d=a&&t&&n(t)&&document.querySelectorAll(t)||[];a&&d.length!==h.length&&x('Hello could not disable "Add to cart" buttons - Title and add to cart selectors do not match');const c=[];for(let t=0;t<r.length;t++){const s=r[t],i=h[t];if(s&&i){const l={cartButtonNode:d[t]||null,description:(null===(o=i.textContent)||void 0===o?void 0:o.trim())||"",title:(null===(e=s.textContent)||void 0===e?void 0:e.trim())||""};c.push(l)}}return c},L=class{constructor(e){o(this,e),this.showPeekMessage=!1,this.zonosStoreHelloSettings=g.helloSettings,this.showDialog=!1,this.peekMessage="",this.initialUrl="",this.allRestrictedItems=[],this.allFoundProducts=[],this.productsOnPage=[],this.isHelloWidgetRendered=!1,this.isMobile=!1,this.getHelloPeekMessage=o=>{if(("productDetail"===g.currentHelloPage||"productList"===g.currentHelloPage)&&this.allRestrictedItems.length){const o=r("click to learn more");return`${r("productDetail"===g.currentHelloPage?"Restricted item":"Restricted items found")} - ${o}`}switch(g.currentHelloPage){case"cart":return r("Prepay duties and taxes at checkout");case"productList":case"productDetail":return r("See duty and tax thresholds");default:return r("Welcome to [storeName]",{storeName:o})}},this.enableShowPeekMessage=()=>{this.peekMessage&&(this.showPeekMessage=!0)},this.getNewItemRestrictions=async o=>"productDetail"!==g.currentHelloPage&&"productList"!==g.currentHelloPage||"DISABLED"===g.helloSettings.restrictionBehavior?[]:await(async o=>{if(!o.length)return[];const{selectedCountryCode:e}=l;if(!e)return b("Hello could not check item restrictions - No country code selected"),[];const t=o.map((o=>({description:o.description,name:o.title})));return(await(async({items:o,shipFrom:e,shipTo:t})=>{var s;const i={items:o,shipFrom:e,shipTo:t},{errors:l,json:n}=await u("/api/zonos-elements/check-item-restrictions",{body:i,method:"POST"});return l.length||!n?(b(`Error fetching item restrictions: ${null===(s=l.find(Boolean))||void 0===s?void 0:s.message}`),[]):n.filter(Boolean)})({items:t,shipFrom:"AD",shipTo:e})).map((o=>{var e;const s=(null===(e=t.filter((e=>e.description===o.itemDescription)).find(Boolean))||void 0===e?void 0:e.name)||"";return Object.assign(Object.assign({},o),{name:s})}))})(o),this.triggerShowPeekMessage=()=>{this.peekMessage=this.getHelloPeekMessage(g.organizationName);const{peekMessageBehavior:o,peekMessageDelay:e}=g.helloSettings;"ENABLED"===o&&setTimeout((()=>{this.enableShowPeekMessage(),this.allRestrictedItems.some((o=>this.productsOnPage.some((e=>e.description===o.itemDescription))))||setTimeout((()=>{this.showPeekMessage=!1}),3e3)}),1e3*e)},this.disableAddToCartButtons=()=>{this.productsOnPage.length&&this.productsOnPage.forEach((o=>{var e,t;this.allRestrictedItems.some((e=>e.itemDescription===o.description))?null===(e=o.cartButtonNode)||void 0===e||e.setAttribute("disabled","disabled"):null===(t=o.cartButtonNode)||void 0===t||t.removeAttribute("disabled")}))},this.handleItemRestrictions=async()=>{this.productsOnPage=k();const o=this.productsOnPage.filter((o=>!this.allFoundProducts.some((e=>e.title===o.title)))),e=await this.getNewItemRestrictions(o);this.allRestrictedItems.push(...e),this.allFoundProducts.push(...o),this.disableAddToCartButtons()},this.reloadHelloData=async()=>{await this.handleItemRestrictions(),this.triggerShowPeekMessage()},this.handleProductCountChange=i((()=>{const{productTitleElementSelector:o}=g.helloSettings;if(o){const o=k();if(this.allFoundProducts.length!==o.length&&window.location.href===this.initialUrl){if(!this.allFoundProducts.length)return;this.reloadHelloData()}}}),1e3),this.watchProductCountChange=()=>{var o;const e=new MutationObserver(this.handleProductCountChange);e.observe(document.body,{childList:!0,subtree:!0}),null===(o=this.observerWatcher)||void 0===o||o.push(e)},this.watchPriceChange=()=>{var o;const e=new MutationObserver((()=>{this.displayCurrency()}));e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),null===(o=this.observerWatcher)||void 0===o||o.push(e)},this.updateHelloOnPageChange=()=>{this.watchProductCountChange(),setInterval((()=>{if(window.location.href!==this.initialUrl){const o=this.initialUrl&&new URL(this.initialUrl);(o&&h(o.searchParams))!==l.selectedCountryCode&&(this.allFoundProducts=[],this.allRestrictedItems=[],this.productsOnPage=[]),this.initialUrl=window.location.href,g.currentHelloPage=(()=>{const{cartUrlPattern:o,homepageUrlPattern:e,productDetailUrlPattern:t,productListUrlPattern:s}=g.helloSettings;return y(o)?"cart":y(t)?"productDetail":y(s)?"productList":y(e)?"home":""})();const e=new URL(window.location.href);if(!h(e.searchParams))return void a(l.selectedCountryCode);this.reloadHelloData()}}),1e3)},this.changeShowDialog=o=>{this.showDialog=o},this.shouldAnimateLeftDesktop=()=>{const o=this.helloRef&&getComputedStyle(this.helloRef).position;if(this.helloRef&&"relative"===o)return v(this.helloRef)},this.shouldRenderHello=(o=!0)=>{if(!l.localizationLoaded)return!1;const{showForCountries:e}=g.helloSettings;return o&&(l.isShippableCountry||x(`Hello: not shippable country - Show for countries: ${e}`)),"ONLY_SHIPPABLE"===e?l.isShippableCountry:"ALL"===e||(null==e?void 0:e.includes(l.selectedCountryCode||""))}}showDialogHandler(o){var e;if(o){const o=null===(e=this.helloElement)||void 0===e?void 0:e.parentElement;o&&o.parentElement===document.body&&(o.style.zIndex="2147483647",document.body.appendChild(o))}}async getCountryList(){return l.helloCountryList}componentWillLoad(){const o=setInterval((async()=>{this.helloRef&&g.loadedConfig&&(this.helloRef.setAttribute("data-zonos-hello-loaded",""),this.updateHelloOnPageChange(),this.watchPriceChange(),this.handleAppearanceSettingsOverrideChange(),clearInterval(o))}),100)}disconnectedCallback(){var o;null===(o=this.observerWatcher)||void 0===o||o.forEach((o=>o.disconnect()))}async displayCurrency(){"DISABLED"!==g.helloSettings.currencyBehavior&&(l.exchangeRate?d():x("Could not display currency. Exchange rate and format data is not available.","warn"))}async convertAndFormat(o){return c(o)}async convert(o){return m(o)}async format(o){return p({amount:o})}async openHelloDialog(o){this.changeShowDialog(o)}handleResize(){this.isMobile=window.innerWidth<=768}handleHelloWidgetInitializedState({countryCode:o,currencyCode:e}){var t,s;this.isHelloWidgetRendered||l.selectedCountryCode&&"function"==typeof g.helloSettings.onInitSuccess&&(this.isHelloWidgetRendered=!0,null===(s=(t=g.helloSettings).onInitSuccess)||void 0===s||s.call(t,{countryCode:o,currencyCode:e}))}getHelloLocation(){const o=this.mobileLocationOverride||g.helloSettings.mobileLocation,e=g.helloSettings.desktopLocation,t=this.isMobile;if(!0===t)return{isMobileWindow:t,isOnLeft:this.animateFromLeftOverride||(null==o?void 0:o.includes("LEFT")),isOnTop:null==o?void 0:o.includes("TOP"),shouldFloat:!!o};{const o=!g.helloSettings.anchorElementSelector&&!!e;return{isMobileWindow:t,isOnLeft:this.animateFromLeftOverride||(null==e?void 0:e.includes("LEFT"))||this.shouldAnimateLeftDesktop(),isOnTop:null==e?void 0:e.includes("TOP"),shouldFloat:o}}}handleAppearanceSettingsOverrideChange(){var o;(null===(o=this.appearanceSettingsOverride)||void 0===o?void 0:o.theme)&&(this.appearanceSettingsOverride.theme=w(this.appearanceSettingsOverride.theme))}componentDidLoad(){this.isMobile=window.innerWidth<=768}render(){var o,s;if(null===(o=g.helloSettings.excludedUrlPatterns)||void 0===o?void 0:o.some((o=>o&&new RegExp(o).test(window.location.href))))return x("Hello is excluded on this url","warn"),null;const{selectedCountryCode:i,targetCurrency:n}=l,{isOnLeft:r,isOnTop:h,shouldFloat:a}=this.getHelloLocation(),d=f(g.appearance,this.appearanceSettingsOverride||null),{theme:c}=d,m=null===(s=this.allRestrictedItems)||void 0===s?void 0:s.filter((o=>this.productsOnPage.some((e=>e.description===o.itemDescription))));this.peekMessage=this.getHelloPeekMessage(g.organizationName);const p=this.shouldRenderHello()&&!!i;return p&&!this.isHelloWidgetRendered&&this.handleHelloWidgetInitializedState({countryCode:i,currencyCode:n}),e(t,{class:"zonos--hello zonos--elements","data-theme":c},p&&e("div",{class:z(["zonos--hello-wrapper",a&&"zonos--hello-widget-float"])},e("button",{class:z(["zonos--hello-widget",this.showPeekMessage&&"zonos--hello-show-peek-message",this.mobileLocationOverride&&"zonos--hello-mobile-override",r&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",h&&"zonos--hello-widget-top",!!this.allRestrictedItems.length&&"zonos--hello-has-restrictions",a&&"zonos--hello-widget-float"]),onClick:()=>{this.changeShowDialog(!this.showDialog)},onMouseEnter:()=>this.enableShowPeekMessage(),onMouseLeave:()=>this.showPeekMessage=!1,ref:o=>o&&(this.helloRef=o),type:"button"},e("zonos-text",{class:"zonos--hello-message"},this.peekMessage),i&&e("div",{class:"zonos--hello-country-flag-wrapper"},e("zonos-country-flag",{class:"zonos--hello-country-flag",countryCode:i}))),e("div",{class:z(["zonos--hello-dialog-wrapper",this.mobileLocationOverride&&"zonos--hello-dialog-wrapper-mobile-override",r&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",h&&"zonos--hello-widget-top",a&&"zonos--hello-widget-float"]),style:{height:this.showDialog?"fit-content":"0px"}},e("zonos-hello-dialog",{animateFromLeftOverride:this.animateFromLeftOverride,appearanceSettings:d,isOpen:this.showDialog,mobileLocationOverride:this.mobileLocationOverride,restrictedItems:m,setIsOpen:this.changeShowDialog}))))}get helloElement(){return s(this)}static get watchers(){return{showDialog:["showDialogHandler"],appearanceSettingsOverride:["handleAppearanceSettingsOverrideChange"]}}};L.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{display:inline-block}:host .zonos--hello-wrapper{position:relative}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper-mobile-override{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media (max-width: 768px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}}@media screen and (min-width: 769px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px;width:auto;height:auto;z-index:1001}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}}:host .zonos--hello-widget{-webkit-transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);padding:6px;border-radius:30px;background:var(--zonos-elements-page-background);font-size:var(--zonos-elements-font-size-s);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;cursor:pointer;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;position:relative;z-index:1000}:host .zonos--hello-widget>.zonos--hello-message{-ms-flex-order:0;order:0;max-width:0;height:100%;white-space:nowrap;-webkit-transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);overflow:hidden;color:var(--zonos-elements-text-color);position:absolute;background:var(--zonos-elements-page-background);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top-left-radius:30px;border-bottom-left-radius:30px;left:0;-webkit-transform:translateX(calc(-100% + 16px));transform:translateX(calc(-100% + 16px));width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border-top:var(--zonos-elements-border);border-bottom:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-has-restrictions{background:var(--zonos-elements-red-100);border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-has-restrictions>.zonos--hello-message{background:var(--zonos-elements-red-100);color:var(--zonos-elements-red-800);font-weight:500}:host .zonos--hello-widget.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-show-peek-message{max-width:100vw;width:100%}:host .zonos--hello-widget.zonos--hello-show-peek-message>.zonos--hello-message{max-width:100vw;padding:0 6px;padding-right:16px;border:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-show-peek-message:not(.zonos--hello-widget-animate-from-left)>.zonos--hello-message{border-right:none}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{border-left:0}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:16px;padding-right:6px;border-left:none}:host .zonos--hello-widget.zonos--hello-widget-animate-from-left>.zonos--hello-message{-ms-flex-order:1;order:1;-webkit-transform:translateX(calc(100% - 16px));transform:translateX(calc(100% - 16px));right:0;left:auto;border-top-right-radius:30px;border-bottom-right-radius:30px}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper .zonos--hello-country-flag{height:18px;width:18px;position:relative;overflow:hidden;border-radius:30px;-webkit-box-shadow:var(--zonos-elements-v3-shadow-medium);box-shadow:var(--zonos-elements-v3-shadow-medium);z-index:10;justify-self:center}:host .zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}";export{L as zonos_hello}
1
+ import{r as o,h as e,a as t,g as s}from"./p-ce75b047.js";import{d as i}from"./p-908f13ae.js";import{l,i as n,t as r,g as h,j as a,k as d,m as c,n as m,d as p}from"./p-3ac97c01.js";import{z as g,g as w,m as f}from"./p-058f6124.js";import{c as z}from"./p-b4b7f705.js";import{h as u,l as b}from"./p-41dd1cb8.js";import{g as v}from"./p-5883217a.js";import{l as x}from"./p-0a377722.js";const y=o=>{const e=null==o?void 0:o.replace("www.","").replace("https://","");return e&&new RegExp(e).test(window.location.href)},k=()=>{var o,e;const{productAddToCartElementSelector:t,productDescriptionElementSelector:s,productTitleElementSelector:i,restrictionBehavior:l}=g.helloSettings;i&&s||x("Hello could not check item restrictions - must provide title and description selectors.");const r=i&&n(i)&&document.querySelectorAll(i)||[],h=s&&n(s)&&document.querySelectorAll(s)||[];if(r.length!==h.length)return x("Hello could not check item restrictions - Title and description selectors do not match"),[];const a="RESTRICT_AND_BLOCK"===l,d=a&&t&&n(t)&&document.querySelectorAll(t)||[];a&&d.length!==h.length&&x('Hello could not disable "Add to cart" buttons - Title and add to cart selectors do not match');const c=[];for(let t=0;t<r.length;t++){const s=r[t],i=h[t];if(s&&i){const l={cartButtonNode:d[t]||null,description:(null===(o=i.textContent)||void 0===o?void 0:o.trim())||"",title:(null===(e=s.textContent)||void 0===e?void 0:e.trim())||""};c.push(l)}}return c},L=class{constructor(e){o(this,e),this.showPeekMessage=!1,this.zonosStoreHelloSettings=g.helloSettings,this.showDialog=!1,this.peekMessage="",this.initialUrl="",this.allRestrictedItems=[],this.allFoundProducts=[],this.productsOnPage=[],this.isHelloWidgetRendered=!1,this.isMobile=!1,this.getHelloPeekMessage=o=>{if(("productDetail"===g.currentHelloPage||"productList"===g.currentHelloPage)&&this.allRestrictedItems.length){const o=r("click to learn more");return`${r("productDetail"===g.currentHelloPage?"Restricted item":"Restricted items found")} - ${o}`}switch(g.currentHelloPage){case"cart":return r("Prepay duties and taxes at checkout");case"productList":case"productDetail":return r("See duty and tax thresholds");default:return r("Welcome to [storeName]",{storeName:o})}},this.enableShowPeekMessage=()=>{this.peekMessage&&(this.showPeekMessage=!0)},this.getNewItemRestrictions=async o=>"productDetail"!==g.currentHelloPage&&"productList"!==g.currentHelloPage||"DISABLED"===g.helloSettings.restrictionBehavior?[]:await(async o=>{if(!o.length)return[];const{selectedCountryCode:e}=l;if(!e)return b("Hello could not check item restrictions - No country code selected"),[];const t=o.map((o=>({description:o.description,name:o.title})));return(await(async({items:o,shipFrom:e,shipTo:t})=>{var s;const i={items:o,shipFrom:e,shipTo:t},{errors:l,json:n}=await u("/api/zonos-elements/check-item-restrictions",{body:i,method:"POST"});return l.length||!n?(b(`Error fetching item restrictions: ${null===(s=l.find(Boolean))||void 0===s?void 0:s.message}`),[]):n.filter(Boolean)})({items:t,shipFrom:"AD",shipTo:e})).map((o=>{var e;const s=(null===(e=t.filter((e=>e.description===o.itemDescription)).find(Boolean))||void 0===e?void 0:e.name)||"";return Object.assign(Object.assign({},o),{name:s})}))})(o),this.triggerShowPeekMessage=()=>{this.peekMessage=this.getHelloPeekMessage(g.organizationName);const{peekMessageBehavior:o,peekMessageDelay:e}=g.helloSettings;"ENABLED"===o&&setTimeout((()=>{this.enableShowPeekMessage(),this.allRestrictedItems.some((o=>this.productsOnPage.some((e=>e.description===o.itemDescription))))||setTimeout((()=>{this.showPeekMessage=!1}),3e3)}),1e3*e)},this.disableAddToCartButtons=()=>{this.productsOnPage.length&&this.productsOnPage.forEach((o=>{var e,t;this.allRestrictedItems.some((e=>e.itemDescription===o.description))?null===(e=o.cartButtonNode)||void 0===e||e.setAttribute("disabled","disabled"):null===(t=o.cartButtonNode)||void 0===t||t.removeAttribute("disabled")}))},this.handleItemRestrictions=async()=>{this.productsOnPage=k();const o=this.productsOnPage.filter((o=>!this.allFoundProducts.some((e=>e.title===o.title)))),e=await this.getNewItemRestrictions(o);this.allRestrictedItems.push(...e),this.allFoundProducts.push(...o),this.disableAddToCartButtons()},this.reloadHelloData=async()=>{await this.handleItemRestrictions(),this.triggerShowPeekMessage()},this.handleProductCountChange=i((()=>{const{productTitleElementSelector:o}=g.helloSettings;if(o){const o=k();if(this.allFoundProducts.length!==o.length&&window.location.href===this.initialUrl){if(!this.allFoundProducts.length)return;this.reloadHelloData()}}}),1e3),this.watchProductCountChange=()=>{var o;const e=new MutationObserver(this.handleProductCountChange);e.observe(document.body,{childList:!0,subtree:!0}),null===(o=this.observerWatcher)||void 0===o||o.push(e)},this.watchPriceChange=()=>{var o;const e=new MutationObserver((()=>{this.displayCurrency()}));e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),null===(o=this.observerWatcher)||void 0===o||o.push(e)},this.updateHelloOnPageChange=()=>{this.watchProductCountChange(),setInterval((()=>{if(window.location.href!==this.initialUrl){const o=this.initialUrl&&new URL(this.initialUrl);(o&&h(o.searchParams))!==l.selectedCountryCode&&(this.allFoundProducts=[],this.allRestrictedItems=[],this.productsOnPage=[]),this.initialUrl=window.location.href,g.currentHelloPage=(()=>{const{cartUrlPattern:o,homepageUrlPattern:e,productDetailUrlPattern:t,productListUrlPattern:s}=g.helloSettings;return y(o)?"cart":y(t)?"productDetail":y(s)?"productList":y(e)?"home":""})();const e=new URL(window.location.href);if(!h(e.searchParams))return void a(l.selectedCountryCode);this.reloadHelloData()}}),1e3)},this.changeShowDialog=o=>{this.showDialog=o},this.shouldAnimateLeftDesktop=()=>{const o=this.helloRef&&getComputedStyle(this.helloRef).position;if(this.helloRef&&"relative"===o)return v(this.helloRef)},this.shouldRenderHello=(o=!0)=>{if(!l.localizationLoaded)return!1;const{showForCountries:e}=g.helloSettings;return o&&(l.isShippableCountry||x(`Hello: not shippable country - Show for countries: ${e}`)),"ONLY_SHIPPABLE"===e?l.isShippableCountry:"ALL"===e||(null==e?void 0:e.includes(l.selectedCountryCode||""))}}showDialogHandler(o){var e;if(o){const o=null===(e=this.helloElement)||void 0===e?void 0:e.parentElement;o&&o.parentElement===document.body&&(o.style.zIndex="2147483647",document.body.appendChild(o))}}async getCountryList(){return l.helloCountryList}componentWillLoad(){const o=setInterval((async()=>{this.helloRef&&g.loadedConfig&&(this.helloRef.setAttribute("data-zonos-hello-loaded",""),this.updateHelloOnPageChange(),this.watchPriceChange(),this.handleAppearanceSettingsOverrideChange(),clearInterval(o))}),100)}disconnectedCallback(){var o;null===(o=this.observerWatcher)||void 0===o||o.forEach((o=>o.disconnect()))}async displayCurrency(){"DISABLED"!==g.helloSettings.currencyBehavior&&(l.exchangeRate?d():x("Could not display currency. Exchange rate and format data is not available.","warn"))}async convertAndFormat(o){return c(o)}async convert(o){return m(o)}async format(o){return p({amount:o})}async openHelloDialog(o){this.changeShowDialog(o)}handleResize(){this.isMobile=window.innerWidth<=768}handleHelloWidgetInitializedState({countryCode:o,currencyCode:e}){var t,s;this.isHelloWidgetRendered||l.selectedCountryCode&&"function"==typeof g.helloSettings.onInitSuccess&&(this.isHelloWidgetRendered=!0,null===(s=(t=g.helloSettings).onInitSuccess)||void 0===s||s.call(t,{countryCode:o,currencyCode:e}))}getHelloLocation(){const o=this.mobileLocationOverride||g.helloSettings.mobileLocation,e=g.helloSettings.desktopLocation,t=this.isMobile;if(!0===t)return{isMobileWindow:t,isOnLeft:this.animateFromLeftOverride||(null==o?void 0:o.includes("LEFT")),isOnTop:null==o?void 0:o.includes("TOP"),shouldFloat:!!o};{const o=!g.helloSettings.anchorElementSelector&&!!e;return{isMobileWindow:t,isOnLeft:this.animateFromLeftOverride||(null==e?void 0:e.includes("LEFT"))||this.shouldAnimateLeftDesktop(),isOnTop:null==e?void 0:e.includes("TOP"),shouldFloat:o}}}handleAppearanceSettingsOverrideChange(){var o;(null===(o=this.appearanceSettingsOverride)||void 0===o?void 0:o.theme)&&(this.appearanceSettingsOverride.theme=w(this.appearanceSettingsOverride.theme))}componentDidLoad(){this.isMobile=window.innerWidth<=768}render(){var o,s;if(null===(o=g.helloSettings.excludedUrlPatterns)||void 0===o?void 0:o.some((o=>o&&new RegExp(o).test(window.location.href))))return x("Hello is excluded on this url","warn"),null;const{selectedCountryCode:i,targetCurrency:n}=l,{isOnLeft:r,isOnTop:h,shouldFloat:a}=this.getHelloLocation(),d=f(g.appearance,this.appearanceSettingsOverride||null),{theme:c}=d,m=null===(s=this.allRestrictedItems)||void 0===s?void 0:s.filter((o=>this.productsOnPage.some((e=>e.description===o.itemDescription))));this.peekMessage=this.getHelloPeekMessage(g.organizationName);const p=this.shouldRenderHello()&&!!i;return p&&!this.isHelloWidgetRendered&&this.handleHelloWidgetInitializedState({countryCode:i,currencyCode:n}),e(t,{class:"zonos--hello zonos--elements","data-theme":c},p&&e("div",{class:z(["zonos--hello-wrapper",a&&"zonos--hello-widget-float"])},e("button",{class:z(["zonos--hello-widget",this.showPeekMessage&&"zonos--hello-show-peek-message",this.mobileLocationOverride&&"zonos--hello-mobile-override",r&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",h&&"zonos--hello-widget-top",!!this.allRestrictedItems.length&&"zonos--hello-has-restrictions",a&&"zonos--hello-widget-float"]),onClick:()=>{this.changeShowDialog(!this.showDialog)},onMouseEnter:()=>this.enableShowPeekMessage(),onMouseLeave:()=>this.showPeekMessage=!1,ref:o=>o&&(this.helloRef=o),type:"button"},e("zonos-text",{class:"zonos--hello-message"},this.peekMessage),i&&e("div",{class:"zonos--hello-country-flag-wrapper"},e("zonos-country-flag",{class:"zonos--hello-country-flag",countryCode:i}))),e("div",{class:z(["zonos--hello-dialog-wrapper",this.mobileLocationOverride&&"zonos--hello-dialog-wrapper-mobile-override",r&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",h&&"zonos--hello-widget-top",a&&"zonos--hello-widget-float"]),style:{height:this.showDialog?"fit-content":"0px"}},e("zonos-hello-dialog",{animateFromLeftOverride:this.animateFromLeftOverride,appearanceSettings:d,isOpen:this.showDialog,mobileLocationOverride:this.mobileLocationOverride,restrictedItems:m,setIsOpen:this.changeShowDialog}))))}get helloElement(){return s(this)}static get watchers(){return{showDialog:["showDialogHandler"],appearanceSettingsOverride:["handleAppearanceSettingsOverrideChange"]}}};L.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{display:inline-block}:host .zonos--hello-wrapper{position:relative}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper-mobile-override{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media (max-width: 768px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}}@media screen and (min-width: 769px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px;width:auto;height:auto;z-index:1001}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}}:host .zonos--hello-widget{-webkit-transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);padding:6px;border-radius:30px;background:var(--zonos-elements-page-background);font-size:var(--zonos-elements-font-size-s);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;cursor:pointer;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;position:relative;z-index:1000}:host .zonos--hello-widget>.zonos--hello-message{-ms-flex-order:0;order:0;max-width:0;height:100%;white-space:nowrap;-webkit-transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);overflow:hidden;color:var(--zonos-elements-text-color);position:absolute;background:var(--zonos-elements-page-background);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top-left-radius:30px;border-bottom-left-radius:30px;left:0;-webkit-transform:translateX(calc(-100% + 16px));transform:translateX(calc(-100% + 16px));width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border-top:var(--zonos-elements-border);border-bottom:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-has-restrictions{background:var(--zonos-elements-red-100);border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-has-restrictions>.zonos--hello-message{background:var(--zonos-elements-red-100);color:var(--zonos-elements-red-800);font-weight:500}:host .zonos--hello-widget.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-show-peek-message{max-width:100vw;width:100%}:host .zonos--hello-widget.zonos--hello-show-peek-message>.zonos--hello-message{max-width:100vw;padding:0 6px;padding-right:16px;border:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-show-peek-message:not(.zonos--hello-widget-animate-from-left)>.zonos--hello-message{border-right:none}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{border-left:0}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:16px;padding-right:6px;border-left:none}:host .zonos--hello-widget.zonos--hello-widget-animate-from-left>.zonos--hello-message{-ms-flex-order:1;order:1;-webkit-transform:translateX(calc(100% - 16px));transform:translateX(calc(100% - 16px));right:0;left:auto;border-top-right-radius:30px;border-bottom-right-radius:30px}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper .zonos--hello-country-flag{height:18px;width:18px;position:relative;overflow:hidden;border-radius:30px;-webkit-box-shadow:var(--zonos-elements-v3-shadow-medium);box-shadow:var(--zonos-elements-v3-shadow-medium);z-index:10;justify-self:center}:host .zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}";export{L as zonos_hello}
@@ -1 +1 @@
1
- import{r as o,e as t,h as s,a as e}from"./p-ce75b047.js";import{d as a}from"./p-620ba943.js";import{c as n}from"./p-9581bffb.js";import{f as i}from"./p-058f6124.js";import{c as r}from"./p-b4b7f705.js";import{s as h}from"./p-96d77739.js";import"./p-13041752.js";import"./p-41dd1cb8.js";import"./p-0a377722.js";import"./p-67897a0d.js";import"./p-f830f800.js";const l=class{constructor(t){o(this,t),this.errorImages=[]}render(){const o=t("./assets/empty-item.jpeg"),i=a.items.filter((o=>!o.isRestricted));return s(e,{key:"2f5507537492851b67a5204ab68ce2f938899f23",class:"zonos--collect-cart-items zonos--elements"},s("table",{key:"e648cda9d4c111ecde60291f420178e4e4230b50",class:"zonos--cart-table"},s("tbody",{key:"b266291e61d0df5c0ea3ae8240a3bfb6147edbb4"},i.map((t=>{const e=t.imageUrl,a=n(t.name);return s("tr",{class:"zonos--collect-cart-item"},s("td",{class:"zonos--column zonos--cart-item-image"},e&&!this.errorImages.includes(e)?s("img",{alt:t.name,onError:()=>{this.errorImages=[...this.errorImages,e]},src:t.imageUrl,style:{"min-width":"40px"},width:40}):s("img",{alt:t.name,src:o,width:40})),s("td",{class:"zonos--column zonos--cart-item-name"},s("div",null,a.map((o=>s("zonos-text",{type:"semiBoldLabel"},o))))))})))))}static get assetsDirs(){return["assets"]}};l.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--cart-table{width:100%;border:none;border-collapse:collapse;overflow:auto;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column{padding:8px;padding-left:0;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column:first-child{width:48px}:host .zonos--cart-table td{vertical-align:middle}:host .zonos--cart-item-price zonos-text{white-space:nowrap}:host img{min-width:40px;margin-top:6px;-webkit-box-shadow:0 0 0 1px rgba(110, 110, 120, 0.1), 0 1px 2px 0 rgba(10, 10, 11, 0.06), 0 1px 3px 0 rgba(10, 10, 11, 0.1);box-shadow:0 0 0 1px rgba(110, 110, 120, 0.1), 0 1px 2px 0 rgba(10, 10, 11, 0.06), 0 1px 3px 0 rgba(10, 10, 11, 0.1);border-radius:10px}";const c=class{constructor(t){o(this,t),this.spacing=24}render(){return s(e,{key:"443aa77bfbf4c0c84c33d0ef7652caec001968c3",style:{"--spacing":`${this.spacing}px`,"--zonos--font-family":i()}},s("slot",{key:"3366df34b9f0f3549e556cff1e47878c2f6cd124"}))}};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{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;gap:var(--spacing, 24px)}";const m=class{constructor(t){o(this,t),this.skeletonWidth="100%",this.skeletonHeight="14px"}render(){return s(e,{key:"096e505180d901c1523567f89cdbcca7869a0895",class:r(["zonos--elements zonos--skeleton"]),style:h({"--zonos--skeleton-height":this.skeletonHeight,"--zonos--skeleton-width":this.skeletonWidth})})}};m.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{display:inline-block;background:var(--zonos-elements-gray-200);border-radius:var(--zonos-elements-radius-12);width:var(--zonos--skeleton-width);height:var(--zonos--skeleton-height);min-height:var(--zonos--skeleton-height);max-width:100%}";export{l as zonos_collect_cart_items,c as zonos_h_stack,m as zonos_skeleton}
1
+ import{r as o,e as t,h as s,a as e}from"./p-ce75b047.js";import{d as a}from"./p-dafafa07.js";import{c as n}from"./p-9581bffb.js";import{f as i}from"./p-058f6124.js";import{c as r}from"./p-b4b7f705.js";import{s as h}from"./p-96d77739.js";import"./p-3ac97c01.js";import"./p-41dd1cb8.js";import"./p-0a377722.js";import"./p-67897a0d.js";import"./p-f830f800.js";const l=class{constructor(t){o(this,t),this.errorImages=[]}render(){const o=t("./assets/empty-item.jpeg"),i=a.items.filter((o=>!o.isRestricted));return s(e,{key:"2f5507537492851b67a5204ab68ce2f938899f23",class:"zonos--collect-cart-items zonos--elements"},s("table",{key:"e648cda9d4c111ecde60291f420178e4e4230b50",class:"zonos--cart-table"},s("tbody",{key:"b266291e61d0df5c0ea3ae8240a3bfb6147edbb4"},i.map((t=>{const e=t.imageUrl,a=n(t.name);return s("tr",{class:"zonos--collect-cart-item"},s("td",{class:"zonos--column zonos--cart-item-image"},e&&!this.errorImages.includes(e)?s("img",{alt:t.name,onError:()=>{this.errorImages=[...this.errorImages,e]},src:t.imageUrl,style:{"min-width":"40px"},width:40}):s("img",{alt:t.name,src:o,width:40})),s("td",{class:"zonos--column zonos--cart-item-name"},s("div",null,a.map((o=>s("zonos-text",{type:"semiBoldLabel"},o))))))})))))}static get assetsDirs(){return["assets"]}};l.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--cart-table{width:100%;border:none;border-collapse:collapse;overflow:auto;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column{padding:8px;padding-left:0;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column:first-child{width:48px}:host .zonos--cart-table td{vertical-align:middle}:host .zonos--cart-item-price zonos-text{white-space:nowrap}:host img{min-width:40px;margin-top:6px;-webkit-box-shadow:0 0 0 1px rgba(110, 110, 120, 0.1), 0 1px 2px 0 rgba(10, 10, 11, 0.06), 0 1px 3px 0 rgba(10, 10, 11, 0.1);box-shadow:0 0 0 1px rgba(110, 110, 120, 0.1), 0 1px 2px 0 rgba(10, 10, 11, 0.06), 0 1px 3px 0 rgba(10, 10, 11, 0.1);border-radius:10px}";const c=class{constructor(t){o(this,t),this.spacing=24}render(){return s(e,{key:"443aa77bfbf4c0c84c33d0ef7652caec001968c3",style:{"--spacing":`${this.spacing}px`,"--zonos--font-family":i()}},s("slot",{key:"3366df34b9f0f3549e556cff1e47878c2f6cd124"}))}};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{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;gap:var(--spacing, 24px)}";const m=class{constructor(t){o(this,t),this.skeletonWidth="100%",this.skeletonHeight="14px"}render(){return s(e,{key:"096e505180d901c1523567f89cdbcca7869a0895",class:r(["zonos--elements zonos--skeleton"]),style:h({"--zonos--skeleton-height":this.skeletonHeight,"--zonos--skeleton-width":this.skeletonWidth})})}};m.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{display:inline-block;background:var(--zonos-elements-gray-200);border-radius:var(--zonos-elements-radius-12);width:var(--zonos--skeleton-width);height:var(--zonos--skeleton-height);min-height:var(--zonos--skeleton-height);max-width:100%}";export{l as zonos_collect_cart_items,c as zonos_h_stack,m as zonos_skeleton}
@@ -1 +1 @@
1
- import{r as o,h as s,a as t,g as i}from"./p-ce75b047.js";import{l as n}from"./p-13041752.js";import{f as a}from"./p-058f6124.js";import{c as e}from"./p-b4b7f705.js";import"./p-41dd1cb8.js";import"./p-0a377722.js";const h=class{constructor(s){o(this,s),this.countryCode=n.selectedCountryCode}render(){if(!this.el.shadowRoot||!this.countryCode)return null;const o=`https://zonos-store-assets.s3.amazonaws.com/images/elements-flags/${this.countryCode}.svg`,i=a();return s(t,{class:"zonos--elements",style:this.size?{"--zonos--font-family":i,height:`${this.size}px`,width:`${this.size}px`}:{"--zonos--font-family":i}},s("div",{class:e(["flag-container"])},s("div",{class:"flag-icon",style:{backgroundImage:`url(${o})`}})))}get el(){return i(this)}};h.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{display:-ms-inline-flexbox;display:inline-flex}:host .flag-container{position:relative;overflow:hidden;width:100%;height:100%}:host .flag-icon{position:absolute;top:0;left:0;width:100%;height:100%;background-position:center;background-repeat:no-repeat;background-size:cover}";export{h as zonos_country_flag}
1
+ import{r as o,h as s,a as t,g as i}from"./p-ce75b047.js";import{l as a}from"./p-3ac97c01.js";import{f as n}from"./p-058f6124.js";import{c as e}from"./p-b4b7f705.js";import"./p-41dd1cb8.js";import"./p-0a377722.js";const h=class{constructor(s){o(this,s),this.countryCode=a.selectedCountryCode}render(){if(!this.el.shadowRoot||!this.countryCode)return null;const o=`https://zonos-store-assets.s3.amazonaws.com/images/elements-flags/${this.countryCode}.svg`,i=n();return s(t,{class:"zonos--elements",style:this.size?{"--zonos--font-family":i,height:`${this.size}px`,width:`${this.size}px`}:{"--zonos--font-family":i}},s("div",{class:e(["flag-container"])},s("div",{class:"flag-icon",style:{backgroundImage:`url(${o})`}})))}get el(){return i(this)}};h.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{display:-ms-inline-flexbox;display:inline-flex}:host .flag-container{position:relative;overflow:hidden;width:100%;height:100%}:host .flag-icon{position:absolute;top:0;left:0;width:100%;height:100%;background-position:center;background-repeat:no-repeat;background-size:cover}";export{h as zonos_country_flag}
@@ -1 +1 @@
1
- System.register(["./p-cf69bcc4.system.js"],(function(n){"use strict";var t;return{setters:[function(n){t=n.l}],execute:function(){var r=n("D","gkjqw123");var u=n("T","Kq93wqw3");var i=n("h",(function(){var n;return(n=t.inclusivePricingConfigurations)===null||n===void 0?void 0:n.some((function(n){var t,i;return((t=n.configurations[r])===null||t===void 0?void 0:t.status)==="ENABLED"||((i=n.configurations[u])===null||i===void 0?void 0:i.status)==="ENABLED"}))}))}}}));
1
+ System.register(["./p-31d1b874.system.js"],(function(n){"use strict";var t;return{setters:[function(n){t=n.l}],execute:function(){var r=n("D","gkjqw123");var u=n("T","Kq93wqw3");var i=n("h",(function(){var n;return(n=t.inclusivePricingConfigurations)===null||n===void 0?void 0:n.some((function(n){var t,i;return((t=n.configurations[r])===null||t===void 0?void 0:t.status)==="ENABLED"||((i=n.configurations[u])===null||i===void 0?void 0:i.status)==="ENABLED"}))}))}}}));
@@ -1 +1 @@
1
- import{r as t,h as o,a as s,g as e,d as a}from"./p-ce75b047.js";import{f as n}from"./p-058f6124.js";import{c as i}from"./p-b4b7f705.js";import{g as r}from"./p-f830f800.js";import{b as h,t as c}from"./p-620ba943.js";import{s as l}from"./p-13041752.js";import{l as p}from"./p-41dd1cb8.js";import{d,e as m}from"./p-29f7950c.js";import{l as y}from"./p-0a377722.js";import"./p-67897a0d.js";import"./p-def2d465.js";import"./p-4f7d64f6.js";const f=class{constructor(o){t(this,o),this.borderRadius=6,this.spacing="24px"}render(){const t=this.backgroundColor?`var(--zonos-elements-${this.backgroundColor})`:"transparent",e=r({customRoundRadius:`${this.borderRadius}px`,overrideBorderStyle:"ROUNDED"});return o(s,{key:"8832966776c626c783e771fb7f9a773d2539e07f",style:{"--zonos--font-family":n()}},o("div",{key:"89c9af9275ca5b01f658081fefb7756bfcbf6d58",class:i(["styled-card"]),style:{"--zonos--background-color":t,"--zonos--border-radius":e,padding:this.spacing}},this.label&&o("header",{key:"3da688655c5a9af66397525d02224dbc431d00d0",class:"card-header",style:{padding:this.spacing}},o("zonos-text",{key:"8e9524d26e5a0a7e3149b4008efd02b5a7b9ebc6",type:"subheader"},this.label),o("h-stack",{key:"f7298bbb158686b03b2a09f5d6c089c0f4d144c4",spacing:8},this.actions)),o("slot",{key:"24888347ff25ffd21b416da4f5aae493f8044638"}),(this.footerActions||this.footerContent)&&o("footer",{key:"b6792e7345b87e9407585ed4558c7327ea3eab36",class:"card-footer",style:{height:this.footerHeight?`${this.footerHeight}px`:"auto",padding:this.spacing}},o("div",{key:"70ccde8e9b1988db1ba477efea5b44e812a7514d"},this.footerContent),o("h-stack",{key:"4e48425e9db7031d779da7061f0b2d92b27869a0",spacing:8},this.footerActions))))}};f.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 .styled-card{border:var(--zonos-elements-border);border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-6));padding:var(--spacing, 24px);text-align:left;background-color:var(--zonos--background-color);overflow:hidden}:host .styled-card hr{margin-left:calc(var(--spacing, 24px) * -1);margin-right:calc(var(--spacing, 24px) * -1)}:host .styled-card .card-header{margin:calc(var(--spacing, 24px) * -1);padding:var(--spacing, 24px);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;margin-bottom:var(--spacing, 24px);border-bottom:var(--zonos-elements-border);height:65px;line-height:65px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}:host .styled-card .card-header h5{margin-bottom:0;-ms-flex:1;flex:1}:host .styled-card .card-footer{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between;margin:calc(var(--spacing, 24px) * -1);padding:var(--spacing, 24px);border-top:var(--zonos-elements-border);background:var(--zonos-elements-surface-color-secondary);margin-top:var(--spacing, 24px);border-bottom-left-radius:var(--zonos-elements-radius-8);border-bottom-right-radius:var(--zonos-elements-radius-8);height:var(--footerHeight)}";const z=class{constructor(o){t(this,o),this.theme="LIGHT"}render(){return this.el.shadowRoot?(this.el.shadowRoot.innerHTML="DARK"===this.theme?'<svg width="536" height="200" viewBox="0 0 536 200" fill="none" xmlns="http://www.w3.org/2000/svg">\n<mask id="mask0_3739_19124" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="536" height="200">\n<rect width="536" height="200" fill="url(#paint0_radial_3739_19124)"/>\n</mask>\n<g mask="url(#mask0_3739_19124)">\n<rect x="0.5" y="0.5" width="117" height="63" rx="9.5" stroke="white" stroke-opacity="0.08"/>\n<rect x="126.5" y="0.5" width="117" height="63" rx="9.5" stroke="white" stroke-opacity="0.08"/>\n<rect x="252.5" y="0.5" width="117" height="63" rx="9.5" stroke="white" stroke-opacity="0.08"/>\n<rect x="378.5" y="0.5" width="117" height="63" rx="9.5" stroke="white" stroke-opacity="0.08"/>\n<rect x="504.5" y="0.5" width="31" height="63" rx="9.5" stroke="white" stroke-opacity="0.08"/>\n<rect y="96" width="124" height="8" rx="4" fill="white" fill-opacity="0.08"/>\n<rect x="0.5" y="112.5" width="535" height="39" rx="7.5" stroke="white" stroke-opacity="0.08"/>\n<rect x="0.5" y="160.5" width="263" height="39" rx="7.5" stroke="white" stroke-opacity="0.08"/>\n<rect x="272.5" y="160.5" width="263" height="39" rx="7.5" stroke="white" stroke-opacity="0.08"/>\n</g>\n<defs>\n<radialGradient id="paint0_radial_3739_19124" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(268 100) rotate(90) scale(100 268)">\n<stop offset="0.25" stop-color="white" stop-opacity="0"/>\n<stop offset="0.75" stop-color="white"/>\n</radialGradient>\n</defs>\n</svg>\n':'<svg width="536" height="200" viewBox="0 0 536 200" fill="none" xmlns="http://www.w3.org/2000/svg">\n<mask id="mask0_3739_19125" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="536" height="200">\n<rect width="536" height="200" fill="url(#paint0_radial_3739_19125)"/>\n</mask>\n<g mask="url(#mask0_3739_19125)">\n<rect x="0.5" y="0.5" width="117" height="63" rx="9.5" stroke="black" stroke-opacity="0.08"/>\n<rect x="126.5" y="0.5" width="117" height="63" rx="9.5" stroke="black" stroke-opacity="0.08"/>\n<rect x="252.5" y="0.5" width="117" height="63" rx="9.5" stroke="black" stroke-opacity="0.08"/>\n<rect x="378.5" y="0.5" width="117" height="63" rx="9.5" stroke="black" stroke-opacity="0.08"/>\n<rect x="504.5" y="0.5" width="31" height="63" rx="9.5" stroke="black" stroke-opacity="0.08"/>\n<rect y="96" width="124" height="8" rx="4" fill="black" fill-opacity="0.08"/>\n<rect x="0.5" y="112.5" width="535" height="39" rx="7.5" stroke="black" stroke-opacity="0.08"/>\n<rect x="0.5" y="160.5" width="263" height="39" rx="7.5" stroke="black" stroke-opacity="0.08"/>\n<rect x="272.5" y="160.5" width="263" height="39" rx="7.5" stroke="black" stroke-opacity="0.08"/>\n</g>\n<defs>\n<radialGradient id="paint0_radial_3739_19125" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(268 100) rotate(90) scale(100 268)">\n<stop offset="0.25" stop-color="white" stop-opacity="0"/>\n<stop offset="0.75" stop-color="white"/>\n</radialGradient>\n</defs>\n</svg>\n',o(s,{class:"zonos--elements",style:{"--zonos--font-family":n(),"--zonos--height":"100%","--zonos--width":"100%"}},o("zonos-text",{type:"semiBoldLabel"},this.emptyStateText))):null}get el(){return e(this)}};z.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{display:-ms-inline-flexbox;display:inline-flex;position:relative}:host zonos-text{position:absolute;left:0;right:0;bottom:0;top:0;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}:host svg{width:var(--zonos--width);height:var(--zonos--height)}";const g=class{constructor(o){t(this,o),this.notificationArray=[]}async showNotification(t){const o=`id-${Math.random().toString(36).substring(2,9)}`,s=Object.assign(Object.assign({},t),{id:o,timeout:t.timeout||5e3,transitionClass:"",type:t.type||"success"});this.notificationArray=[...this.notificationArray,s],setTimeout((()=>{this.updateTransitionClass({id:o,transitionClass:"show"})}),50),setTimeout((()=>{this.removeNotification(o)}),s.timeout)}updateTransitionClass({id:t,transitionClass:o}){this.notificationArray=this.notificationArray.map((s=>s.id===t?Object.assign(Object.assign({},s),{transitionClass:o}):s))}removeNotification(t){this.updateTransitionClass({id:t,transitionClass:""}),setTimeout((()=>{this.notificationArray=this.notificationArray.filter((o=>o.id!==t))}),300)}render(){return o(s,{key:"6a790a39afc037ae56f8a53dc89c3fa899b2d659",class:i(["zonos--elements zonos--notification"]),style:{"--zonos--border-radius":r(),"--zonos--font-family":n()}},o("div",{key:"32245a784f2322fb69a65b491648a30a84b0b3d3",class:"zonos--notification-items"},this.notificationArray.map((t=>o("div",{"aria-hidden":"true",class:i(["zonos--notification-item",t.type,t.transitionClass]),key:t.id,onClick:()=>{this.removeNotification(t.id)}},o("zonos-text",{textColor:"gray-0"},t.message))))))}};g.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{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--notification-items{position:fixed;z-index:9999999999;bottom:24px;gap:8px;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column}:host .zonos--notification-item{cursor:pointer;-webkit-transition:all 0.3s ease;transition:all 0.3s ease;padding:8px;border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-6));opacity:0;-ms-flex-negative:0.0001;flex-shrink:0.0001;-webkit-transform:translateY(100%);transform:translateY(100%)}:host .zonos--notification-item+:host .zonos--notification-item{margin-top:8px}:host .zonos--notification-item.show{opacity:1;-webkit-transform:translateY(0);transform:translateY(0);-ms-flex-positive:1000;flex-grow:1000}:host .zonos--notification-item.success{background-color:var(--zonos-elements-green-700)}:host .zonos--notification-item.error{background-color:var(--zonos-elements-red-700)}:host .zonos--notification-item.warning{background-color:var(--zonos-elements-orange-700)}";const b=class{constructor(o){t(this,o),this.stripe=h.stripe,this.stripeElements=h.stripeElements,this.isPaymentInfoFilled=!1,this.trackingSent=!1}watchIsPaymentInfoFilled(){var t;this.isPaymentInfoFilled&&!this.trackingSent&&(c({checkoutSessionId:l.checkoutSessionId,eventName:"checkout_paymentInfoFilled",metadata:{paymentMethod:null===(t=h.stripePaymentEventData)||void 0===t?void 0:t.value.type}}),this.trackingSent=!0)}async watchInitStripe(){var t;if(!this.stripeElements)return;await this.stripeElements.fetchUpdates();const o=h.stripePaymentElement||this.stripeElements.create("payment",{defaultValues:{billingDetails:{address:{country:null===(t=h.stripeAddressEventData)||void 0===t?void 0:t.value.address.country}}},layout:"tabs"}),s=this.el.querySelector(".zonos--payment-component");s?(o.mount(s),o.on("change",(t=>{t.complete&&(this.isPaymentInfoFilled=!0),h.stripePaymentEventData=t})),h.stripePaymentElement=o):p("Cannot find container element for paymentElement")}componentDidLoad(){this.watchInitStripe()}render(){return o(s,{key:"1fb61e01184d3a0b2dc079ae468e96175d9f6518",class:"zonos--payment zonos--elements"},this.titleText&&o("zonos-text",{key:"3860ff7fc2656ff045ce09c0de2e14aa7a22e194",class:"zonos--title",type:"semiBoldLabel"},this.titleText),o("div",{key:"3cabad9c095f2eeba8cfc464374ca9abfc2af5ee",class:"zonos--payment-component"}),o("div",{key:"9e2b13a0d8131a5513f99e2a6436ca3c5f03d7cf",class:"zonos--payment-paypal-container"}))}get el(){return e(this)}static get watchers(){return{isPaymentInfoFilled:["watchIsPaymentInfoFilled"],stripeElements:["watchInitStripe"],stripe:["watchInitStripe"]}}};b.style=".sc-zonos-payment-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-payment-h *.sc-zonos-payment{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-payment-h img.sc-zonos-payment{max-width:100%}.sc-zonos-payment-h dl.sc-zonos-payment,.sc-zonos-payment-h dd.sc-zonos-payment,.sc-zonos-payment-h h1.sc-zonos-payment,.sc-zonos-payment-h h2.sc-zonos-payment,.sc-zonos-payment-h h3.sc-zonos-payment,.sc-zonos-payment-h h4.sc-zonos-payment,.sc-zonos-payment-h h5.sc-zonos-payment,.sc-zonos-payment-h h6.sc-zonos-payment,.sc-zonos-payment-h hr.sc-zonos-payment,.sc-zonos-payment-h figure.sc-zonos-payment,.sc-zonos-payment-h p.sc-zonos-payment,.sc-zonos-payment-h pre.sc-zonos-payment{margin:0}.sc-zonos-payment-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-payment-h .zonos--title.sc-zonos-payment{margin-bottom:16px}.sc-zonos-payment-h .zonos--payment-component.sc-zonos-payment{margin-bottom:4px}";const x=class{constructor(o){t(this,o),this.paypalSessionDone=a(this,"paypalSessionDone",7),this.paypalSessionFail=a(this,"paypalSessionFail",7),this.storeUnsubscribeList=[]}async loadPaypal(){if(!window.Zonos.paypal)return void y("Paypal is not available");const t=d({onPaypalFail:()=>{y("onPaypalFail"),this.paypalSessionFail.emit()},onPaypalSessionDone:({orderId:t})=>{y("onPaypalSessionDone","info",{orderId:t}),this.paypalSessionDone.emit({orderId:t})}});if(!(null==t?void 0:t.length))return void y("There are no paypal buttons available");const o=this.el.querySelector(".zonos--payment-paypal-container");o?t.forEach((async t=>{await t.render(o)})):y("Cannot find container element for paypal buttons")}componentWillLoad(){this.storeUnsubscribeList=[m("paypal",this.loadPaypal.bind(this))]}componentDidLoad(){this.loadPaypal()}disconnectedCallback(){this.storeUnsubscribeList.forEach((t=>t()))}render(){return o(s,{key:"35387382aaa81e3f8e025e8f3503be41b86e2355",class:"zonos--paypal-payment zonos--elements"},o("div",{key:"34fad15dee67d8b913071a59d35b1c2317d4d3a0",class:"zonos--payment-paypal-container"}))}get el(){return e(this)}};x.style=".sc-zonos-paypal-payment-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-paypal-payment-h *.sc-zonos-paypal-payment{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-paypal-payment-h img.sc-zonos-paypal-payment{max-width:100%}.sc-zonos-paypal-payment-h dl.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h dd.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h h1.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h h2.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h h3.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h h4.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h h5.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h h6.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h hr.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h figure.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h p.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h pre.sc-zonos-paypal-payment{margin:0}.sc-zonos-paypal-payment-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-paypal-payment-h{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column}";export{f as zonos_card,z as zonos_empty_state_payment,g as zonos_notification,b as zonos_payment,x as zonos_paypal_payment}
1
+ import{r as t,h as o,a as s,g as e,d as a}from"./p-ce75b047.js";import{f as n}from"./p-058f6124.js";import{c as i}from"./p-b4b7f705.js";import{g as r}from"./p-f830f800.js";import{b as h,t as c}from"./p-dafafa07.js";import{s as l}from"./p-3ac97c01.js";import{l as p}from"./p-41dd1cb8.js";import{d,e as m}from"./p-c398711f.js";import{l as y}from"./p-0a377722.js";import"./p-67897a0d.js";import"./p-def2d465.js";import"./p-4f7d64f6.js";const f=class{constructor(o){t(this,o),this.borderRadius=6,this.spacing="24px"}render(){const t=this.backgroundColor?`var(--zonos-elements-${this.backgroundColor})`:"transparent",e=r({customRoundRadius:`${this.borderRadius}px`,overrideBorderStyle:"ROUNDED"});return o(s,{key:"8832966776c626c783e771fb7f9a773d2539e07f",style:{"--zonos--font-family":n()}},o("div",{key:"89c9af9275ca5b01f658081fefb7756bfcbf6d58",class:i(["styled-card"]),style:{"--zonos--background-color":t,"--zonos--border-radius":e,padding:this.spacing}},this.label&&o("header",{key:"3da688655c5a9af66397525d02224dbc431d00d0",class:"card-header",style:{padding:this.spacing}},o("zonos-text",{key:"8e9524d26e5a0a7e3149b4008efd02b5a7b9ebc6",type:"subheader"},this.label),o("h-stack",{key:"f7298bbb158686b03b2a09f5d6c089c0f4d144c4",spacing:8},this.actions)),o("slot",{key:"24888347ff25ffd21b416da4f5aae493f8044638"}),(this.footerActions||this.footerContent)&&o("footer",{key:"b6792e7345b87e9407585ed4558c7327ea3eab36",class:"card-footer",style:{height:this.footerHeight?`${this.footerHeight}px`:"auto",padding:this.spacing}},o("div",{key:"70ccde8e9b1988db1ba477efea5b44e812a7514d"},this.footerContent),o("h-stack",{key:"4e48425e9db7031d779da7061f0b2d92b27869a0",spacing:8},this.footerActions))))}};f.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 .styled-card{border:var(--zonos-elements-border);border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-6));padding:var(--spacing, 24px);text-align:left;background-color:var(--zonos--background-color);overflow:hidden}:host .styled-card hr{margin-left:calc(var(--spacing, 24px) * -1);margin-right:calc(var(--spacing, 24px) * -1)}:host .styled-card .card-header{margin:calc(var(--spacing, 24px) * -1);padding:var(--spacing, 24px);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;margin-bottom:var(--spacing, 24px);border-bottom:var(--zonos-elements-border);height:65px;line-height:65px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}:host .styled-card .card-header h5{margin-bottom:0;-ms-flex:1;flex:1}:host .styled-card .card-footer{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between;margin:calc(var(--spacing, 24px) * -1);padding:var(--spacing, 24px);border-top:var(--zonos-elements-border);background:var(--zonos-elements-surface-color-secondary);margin-top:var(--spacing, 24px);border-bottom-left-radius:var(--zonos-elements-radius-8);border-bottom-right-radius:var(--zonos-elements-radius-8);height:var(--footerHeight)}";const z=class{constructor(o){t(this,o),this.theme="LIGHT"}render(){return this.el.shadowRoot?(this.el.shadowRoot.innerHTML="DARK"===this.theme?'<svg width="536" height="200" viewBox="0 0 536 200" fill="none" xmlns="http://www.w3.org/2000/svg">\n<mask id="mask0_3739_19124" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="536" height="200">\n<rect width="536" height="200" fill="url(#paint0_radial_3739_19124)"/>\n</mask>\n<g mask="url(#mask0_3739_19124)">\n<rect x="0.5" y="0.5" width="117" height="63" rx="9.5" stroke="white" stroke-opacity="0.08"/>\n<rect x="126.5" y="0.5" width="117" height="63" rx="9.5" stroke="white" stroke-opacity="0.08"/>\n<rect x="252.5" y="0.5" width="117" height="63" rx="9.5" stroke="white" stroke-opacity="0.08"/>\n<rect x="378.5" y="0.5" width="117" height="63" rx="9.5" stroke="white" stroke-opacity="0.08"/>\n<rect x="504.5" y="0.5" width="31" height="63" rx="9.5" stroke="white" stroke-opacity="0.08"/>\n<rect y="96" width="124" height="8" rx="4" fill="white" fill-opacity="0.08"/>\n<rect x="0.5" y="112.5" width="535" height="39" rx="7.5" stroke="white" stroke-opacity="0.08"/>\n<rect x="0.5" y="160.5" width="263" height="39" rx="7.5" stroke="white" stroke-opacity="0.08"/>\n<rect x="272.5" y="160.5" width="263" height="39" rx="7.5" stroke="white" stroke-opacity="0.08"/>\n</g>\n<defs>\n<radialGradient id="paint0_radial_3739_19124" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(268 100) rotate(90) scale(100 268)">\n<stop offset="0.25" stop-color="white" stop-opacity="0"/>\n<stop offset="0.75" stop-color="white"/>\n</radialGradient>\n</defs>\n</svg>\n':'<svg width="536" height="200" viewBox="0 0 536 200" fill="none" xmlns="http://www.w3.org/2000/svg">\n<mask id="mask0_3739_19125" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="536" height="200">\n<rect width="536" height="200" fill="url(#paint0_radial_3739_19125)"/>\n</mask>\n<g mask="url(#mask0_3739_19125)">\n<rect x="0.5" y="0.5" width="117" height="63" rx="9.5" stroke="black" stroke-opacity="0.08"/>\n<rect x="126.5" y="0.5" width="117" height="63" rx="9.5" stroke="black" stroke-opacity="0.08"/>\n<rect x="252.5" y="0.5" width="117" height="63" rx="9.5" stroke="black" stroke-opacity="0.08"/>\n<rect x="378.5" y="0.5" width="117" height="63" rx="9.5" stroke="black" stroke-opacity="0.08"/>\n<rect x="504.5" y="0.5" width="31" height="63" rx="9.5" stroke="black" stroke-opacity="0.08"/>\n<rect y="96" width="124" height="8" rx="4" fill="black" fill-opacity="0.08"/>\n<rect x="0.5" y="112.5" width="535" height="39" rx="7.5" stroke="black" stroke-opacity="0.08"/>\n<rect x="0.5" y="160.5" width="263" height="39" rx="7.5" stroke="black" stroke-opacity="0.08"/>\n<rect x="272.5" y="160.5" width="263" height="39" rx="7.5" stroke="black" stroke-opacity="0.08"/>\n</g>\n<defs>\n<radialGradient id="paint0_radial_3739_19125" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(268 100) rotate(90) scale(100 268)">\n<stop offset="0.25" stop-color="white" stop-opacity="0"/>\n<stop offset="0.75" stop-color="white"/>\n</radialGradient>\n</defs>\n</svg>\n',o(s,{class:"zonos--elements",style:{"--zonos--font-family":n(),"--zonos--height":"100%","--zonos--width":"100%"}},o("zonos-text",{type:"semiBoldLabel"},this.emptyStateText))):null}get el(){return e(this)}};z.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{display:-ms-inline-flexbox;display:inline-flex;position:relative}:host zonos-text{position:absolute;left:0;right:0;bottom:0;top:0;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}:host svg{width:var(--zonos--width);height:var(--zonos--height)}";const g=class{constructor(o){t(this,o),this.notificationArray=[]}async showNotification(t){const o=`id-${Math.random().toString(36).substring(2,9)}`,s=Object.assign(Object.assign({},t),{id:o,timeout:t.timeout||5e3,transitionClass:"",type:t.type||"success"});this.notificationArray=[...this.notificationArray,s],setTimeout((()=>{this.updateTransitionClass({id:o,transitionClass:"show"})}),50),setTimeout((()=>{this.removeNotification(o)}),s.timeout)}updateTransitionClass({id:t,transitionClass:o}){this.notificationArray=this.notificationArray.map((s=>s.id===t?Object.assign(Object.assign({},s),{transitionClass:o}):s))}removeNotification(t){this.updateTransitionClass({id:t,transitionClass:""}),setTimeout((()=>{this.notificationArray=this.notificationArray.filter((o=>o.id!==t))}),300)}render(){return o(s,{key:"6a790a39afc037ae56f8a53dc89c3fa899b2d659",class:i(["zonos--elements zonos--notification"]),style:{"--zonos--border-radius":r(),"--zonos--font-family":n()}},o("div",{key:"32245a784f2322fb69a65b491648a30a84b0b3d3",class:"zonos--notification-items"},this.notificationArray.map((t=>o("div",{"aria-hidden":"true",class:i(["zonos--notification-item",t.type,t.transitionClass]),key:t.id,onClick:()=>{this.removeNotification(t.id)}},o("zonos-text",{textColor:"gray-0"},t.message))))))}};g.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{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--notification-items{position:fixed;z-index:9999999999;bottom:24px;gap:8px;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column}:host .zonos--notification-item{cursor:pointer;-webkit-transition:all 0.3s ease;transition:all 0.3s ease;padding:8px;border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-6));opacity:0;-ms-flex-negative:0.0001;flex-shrink:0.0001;-webkit-transform:translateY(100%);transform:translateY(100%)}:host .zonos--notification-item+:host .zonos--notification-item{margin-top:8px}:host .zonos--notification-item.show{opacity:1;-webkit-transform:translateY(0);transform:translateY(0);-ms-flex-positive:1000;flex-grow:1000}:host .zonos--notification-item.success{background-color:var(--zonos-elements-green-700)}:host .zonos--notification-item.error{background-color:var(--zonos-elements-red-700)}:host .zonos--notification-item.warning{background-color:var(--zonos-elements-orange-700)}";const b=class{constructor(o){t(this,o),this.stripe=h.stripe,this.stripeElements=h.stripeElements,this.isPaymentInfoFilled=!1,this.trackingSent=!1}watchIsPaymentInfoFilled(){var t;this.isPaymentInfoFilled&&!this.trackingSent&&(c({checkoutSessionId:l.checkoutSessionId,eventName:"checkout_paymentInfoFilled",metadata:{paymentMethod:null===(t=h.stripePaymentEventData)||void 0===t?void 0:t.value.type}}),this.trackingSent=!0)}async watchInitStripe(){var t;if(!this.stripeElements)return;await this.stripeElements.fetchUpdates();const o=h.stripePaymentElement||this.stripeElements.create("payment",{defaultValues:{billingDetails:{address:{country:null===(t=h.stripeAddressEventData)||void 0===t?void 0:t.value.address.country}}},layout:"tabs"}),s=this.el.querySelector(".zonos--payment-component");s?(o.mount(s),o.on("change",(t=>{t.complete&&(this.isPaymentInfoFilled=!0),h.stripePaymentEventData=t})),h.stripePaymentElement=o):p("Cannot find container element for paymentElement")}componentDidLoad(){this.watchInitStripe()}render(){return o(s,{key:"1fb61e01184d3a0b2dc079ae468e96175d9f6518",class:"zonos--payment zonos--elements"},this.titleText&&o("zonos-text",{key:"3860ff7fc2656ff045ce09c0de2e14aa7a22e194",class:"zonos--title",type:"semiBoldLabel"},this.titleText),o("div",{key:"3cabad9c095f2eeba8cfc464374ca9abfc2af5ee",class:"zonos--payment-component"}),o("div",{key:"9e2b13a0d8131a5513f99e2a6436ca3c5f03d7cf",class:"zonos--payment-paypal-container"}))}get el(){return e(this)}static get watchers(){return{isPaymentInfoFilled:["watchIsPaymentInfoFilled"],stripeElements:["watchInitStripe"],stripe:["watchInitStripe"]}}};b.style=".sc-zonos-payment-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-payment-h *.sc-zonos-payment{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-payment-h img.sc-zonos-payment{max-width:100%}.sc-zonos-payment-h dl.sc-zonos-payment,.sc-zonos-payment-h dd.sc-zonos-payment,.sc-zonos-payment-h h1.sc-zonos-payment,.sc-zonos-payment-h h2.sc-zonos-payment,.sc-zonos-payment-h h3.sc-zonos-payment,.sc-zonos-payment-h h4.sc-zonos-payment,.sc-zonos-payment-h h5.sc-zonos-payment,.sc-zonos-payment-h h6.sc-zonos-payment,.sc-zonos-payment-h hr.sc-zonos-payment,.sc-zonos-payment-h figure.sc-zonos-payment,.sc-zonos-payment-h p.sc-zonos-payment,.sc-zonos-payment-h pre.sc-zonos-payment{margin:0}.sc-zonos-payment-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-payment-h .zonos--title.sc-zonos-payment{margin-bottom:16px}.sc-zonos-payment-h .zonos--payment-component.sc-zonos-payment{margin-bottom:4px}";const x=class{constructor(o){t(this,o),this.paypalSessionDone=a(this,"paypalSessionDone",7),this.paypalSessionFail=a(this,"paypalSessionFail",7),this.storeUnsubscribeList=[]}async loadPaypal(){if(!window.Zonos.paypal)return void y("Paypal is not available");const t=d({onPaypalFail:()=>{y("onPaypalFail"),this.paypalSessionFail.emit()},onPaypalSessionDone:({orderId:t})=>{y("onPaypalSessionDone","info",{orderId:t}),this.paypalSessionDone.emit({orderId:t})}});if(!(null==t?void 0:t.length))return void y("There are no paypal buttons available");const o=this.el.querySelector(".zonos--payment-paypal-container");o?t.forEach((async t=>{await t.render(o)})):y("Cannot find container element for paypal buttons")}componentWillLoad(){this.storeUnsubscribeList=[m("paypal",this.loadPaypal.bind(this))]}componentDidLoad(){this.loadPaypal()}disconnectedCallback(){this.storeUnsubscribeList.forEach((t=>t()))}render(){return o(s,{key:"35387382aaa81e3f8e025e8f3503be41b86e2355",class:"zonos--paypal-payment zonos--elements"},o("div",{key:"34fad15dee67d8b913071a59d35b1c2317d4d3a0",class:"zonos--payment-paypal-container"}))}get el(){return e(this)}};x.style=".sc-zonos-paypal-payment-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-paypal-payment-h *.sc-zonos-paypal-payment{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-paypal-payment-h img.sc-zonos-paypal-payment{max-width:100%}.sc-zonos-paypal-payment-h dl.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h dd.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h h1.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h h2.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h h3.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h h4.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h h5.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h h6.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h hr.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h figure.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h p.sc-zonos-paypal-payment,.sc-zonos-paypal-payment-h pre.sc-zonos-paypal-payment{margin:0}.sc-zonos-paypal-payment-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-paypal-payment-h{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column}";export{f as zonos_card,z as zonos_empty_state_payment,g as zonos_notification,b as zonos_payment,x as zonos_paypal_payment}