@zonos/elements 1.5.1 → 1.5.3
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.
- package/dist/cjs/_isBigCommerceNativeCheckout-3-xbKbAO.js +133 -0
- package/dist/cjs/{cart-CiXlehwQ.js → cart-C39TMSgB.js} +27 -13
- package/dist/cjs/{collect-Drr8fY-q.js → collect-lF9DenLk.js} +4 -4
- package/dist/cjs/{getMissingRequiredShippingFields-DI6qF1z3.js → getMissingRequiredShippingFields-svcnpumn.js} +1 -1
- package/dist/cjs/{handleFetch-DQLhurnE.js → handleFetch-DVfjFTYO.js} +181 -71
- package/dist/cjs/{hasInclusivePrice-84KS94yH.js → hasInclusivePrice-CEPf3_FG.js} +1 -1
- package/dist/cjs/index.cjs.js +158 -47
- package/dist/cjs/{invoice-5hVfSXpb.js → invoice-BD3pCr8P.js} +3 -3
- package/dist/cjs/{localization-B2mjW0Xa.js → localization-BhNVhLZs.js} +24 -48
- package/dist/cjs/{paypal-pd8Nz_R_.js → paypal-Bd1qmwiv.js} +4 -4
- package/dist/cjs/{placeTestOrder-DrI8rD9o.js → placeTestOrder-BMQRvX2q.js} +3 -3
- package/dist/cjs/{renderCheckoutCurrency-u5q8YdUb.js → renderCheckoutCurrency-DE2p8CT8.js} +2 -2
- package/dist/cjs/{shouldShowLanguageSelect-gBg4KeTQ.js → shouldShowLanguageSelect-NOVWOU53.js} +1 -1
- package/dist/cjs/{submitGtag-Rc-S3PnH.js → submitGtag-D4sB7w4z.js} +1 -1
- package/dist/cjs/{taxIdFields-BrIaPTcd.js → taxIdFields-BKbk2bhi.js} +2 -2
- package/dist/cjs/{updateCheckoutSessionAttributes-d0IKpwW8.js → updateCheckoutSessionAttributes-KxwcsKhM.js} +1 -1
- package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +6 -6
- package/dist/cjs/zonos-address-display_2.cjs.entry.js +2 -2
- package/dist/cjs/zonos-address_4.cjs.entry.js +4 -4
- package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +4 -4
- package/dist/cjs/zonos-card_5.cjs.entry.js +5 -5
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +18 -18
- package/dist/cjs/zonos-checkout.cjs.entry.js +48 -22
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +3 -3
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +9 -9
- package/dist/cjs/zonos-collect.cjs.entry.js +6 -6
- package/dist/cjs/zonos-controller.cjs.entry.js +65 -40
- package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +3 -3
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +3 -3
- package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +5 -5
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +9 -9
- package/dist/cjs/zonos-invoice.cjs.entry.js +6 -6
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
- package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +4 -4
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +8 -7
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +14 -4
- package/dist/collection/components/main/mountCheckoutWithoutStripe.js +12 -0
- package/dist/collection/components/main/zonos-controller.js +26 -10
- package/dist/collection/components/store/checkout/cart.js +3 -2
- package/dist/collection/components/store/checkout/stripe.js +23 -10
- package/dist/collection/components/store/storageStore.js +7 -6
- package/dist/collection/components/utils/__tests__/helpers/blockStorage.js +24 -0
- package/dist/collection/components/utils/api/getExchangeRate.js +2 -1
- package/dist/collection/components/utils/checkout/isBigCommerceCheckoutBypassEnabled.js +2 -1
- package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +32 -12
- package/dist/collection/components/utils/handleFetch.js +19 -9
- package/dist/collection/components/utils/hello/countryOverrideStorage.js +17 -40
- package/dist/collection/components/utils/logging/installConstructorCapture.js +58 -0
- package/dist/collection/components/utils/logging/reportBlockedStorage.js +34 -0
- package/dist/collection/components/utils/logging/sendErrorLog.js +8 -1
- package/dist/collection/components/utils/logging/startZonosInit.js +35 -0
- package/dist/collection/components/utils/logging/thrownMessage.js +16 -0
- package/dist/collection/components/utils/safeStorage.js +39 -0
- package/dist/collection/scripts/_bigcommerceCheckoutPath.js +16 -0
- package/dist/collection/scripts/_detectBigCommerceHost.js +12 -0
- package/dist/collection/scripts/_getZonosQaUrl.js +3 -2
- package/dist/collection/scripts/_isBigCommerceNativeCheckout.js +107 -0
- package/dist/collection/scripts/_loadStripe.js +15 -4
- package/dist/collection/scripts/_zonosBase.js +46 -33
- package/dist/collection/types/generated/graphql.frontend.types.js +0 -16
- package/dist/collection/types/generated/graphql.internal.types.js +215 -1
- package/dist/esm/_isBigCommerceNativeCheckout-Bb90IMVt.js +128 -0
- package/dist/esm/{cart-DmJkjiDE.js → cart-b84n0nhi.js} +26 -14
- package/dist/esm/{collect-BV5GTPmh.js → collect-B_AEVONL.js} +4 -4
- package/dist/esm/{getMissingRequiredShippingFields-DljgpDZe.js → getMissingRequiredShippingFields-EY10c34-.js} +1 -1
- package/dist/esm/{handleFetch-D5GYDF-O.js → handleFetch-BFVO7oAR.js} +178 -72
- package/dist/esm/{hasInclusivePrice-DhGXpH2D.js → hasInclusivePrice-DfEiyzw7.js} +1 -1
- package/dist/esm/index.js +158 -47
- package/dist/esm/{invoice-CO-iqlni.js → invoice-dQ0ONK5Q.js} +3 -3
- package/dist/esm/{localization-DHM91diu.js → localization-B5CRzthT.js} +25 -49
- package/dist/esm/{paypal-BfW5aLJw.js → paypal-CF_oM0B6.js} +4 -4
- package/dist/esm/{placeTestOrder-CyWUFhxD.js → placeTestOrder-BTpfyqPL.js} +3 -3
- package/dist/esm/{renderCheckoutCurrency-B31ZNkUv.js → renderCheckoutCurrency-CpeuDWx-.js} +2 -2
- package/dist/esm/{shouldShowLanguageSelect-DwSfSHar.js → shouldShowLanguageSelect-CJinx9-m.js} +1 -1
- package/dist/esm/{submitGtag-BEFrutel.js → submitGtag-C5xzFHjG.js} +1 -1
- package/dist/esm/{taxIdFields-ByEYfsO5.js → taxIdFields-BCyXnc9O.js} +2 -2
- package/dist/esm/{updateCheckoutSessionAttributes-B0bQH0uw.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
- package/dist/esm/zonos-address-completion-dialog_7.entry.js +6 -6
- package/dist/esm/zonos-address-display_2.entry.js +2 -2
- package/dist/esm/zonos-address_4.entry.js +4 -4
- package/dist/esm/zonos-airwallex-payment.entry.js +4 -4
- package/dist/esm/zonos-card_5.entry.js +5 -5
- package/dist/esm/zonos-cart-items_12.entry.js +18 -18
- package/dist/esm/zonos-checkout.entry.js +48 -22
- package/dist/esm/zonos-collect-cart-items_3.entry.js +3 -3
- package/dist/esm/zonos-collect-finish_6.entry.js +9 -9
- package/dist/esm/zonos-collect.entry.js +6 -6
- package/dist/esm/zonos-controller.entry.js +65 -40
- package/dist/esm/zonos-country-flag.entry.js +2 -2
- package/dist/esm/zonos-country-select_4.entry.js +3 -3
- package/dist/esm/zonos-hello-dialog.entry.js +3 -3
- package/dist/esm/zonos-hello.entry.js +2 -2
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +5 -5
- package/dist/esm/zonos-invoice-finish_5.entry.js +9 -9
- package/dist/esm/zonos-invoice.entry.js +6 -6
- package/dist/esm/zonos-language-select_2.entry.js +2 -2
- package/dist/esm/zonos-policy-consent_2.entry.js +4 -4
- package/dist/esm-es5/_isBigCommerceNativeCheckout-Bb90IMVt.js +40 -0
- package/dist/esm-es5/{cart-DmJkjiDE.js → cart-b84n0nhi.js} +59 -59
- package/dist/esm-es5/{collect-BV5GTPmh.js → collect-B_AEVONL.js} +2 -2
- package/dist/esm-es5/{getMissingRequiredShippingFields-DljgpDZe.js → getMissingRequiredShippingFields-EY10c34-.js} +3 -3
- package/dist/esm-es5/handleFetch-BFVO7oAR.js +73 -0
- package/dist/esm-es5/{hasInclusivePrice-DhGXpH2D.js → hasInclusivePrice-DfEiyzw7.js} +1 -1
- package/dist/esm-es5/index.js +94 -65
- package/dist/esm-es5/{invoice-CO-iqlni.js → invoice-dQ0ONK5Q.js} +1 -1
- package/dist/esm-es5/{localization-DHM91diu.js → localization-B5CRzthT.js} +7 -10
- package/dist/esm-es5/{paypal-BfW5aLJw.js → paypal-CF_oM0B6.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-CyWUFhxD.js → placeTestOrder-BTpfyqPL.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-B31ZNkUv.js → renderCheckoutCurrency-CpeuDWx-.js} +5 -5
- package/dist/esm-es5/{shouldShowLanguageSelect-DwSfSHar.js → shouldShowLanguageSelect-CJinx9-m.js} +1 -1
- package/dist/esm-es5/{submitGtag-BEFrutel.js → submitGtag-C5xzFHjG.js} +1 -1
- package/dist/esm-es5/{taxIdFields-ByEYfsO5.js → taxIdFields-BCyXnc9O.js} +1 -1
- package/dist/esm-es5/{updateCheckoutSessionAttributes-B0bQH0uw.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
- package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +2 -2
- package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
- package/dist/esm-es5/zonos-address_4.entry.js +1 -1
- package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
- package/dist/esm-es5/zonos-card_5.entry.js +6 -6
- package/dist/esm-es5/zonos-cart-items_12.entry.js +127 -127
- package/dist/esm-es5/zonos-checkout.entry.js +22 -11
- package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
- package/dist/esm-es5/zonos-collect.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +21 -12
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice.entry.js +3 -3
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
- package/dist/scripts/index.d.ts +22 -0
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/main/mountCheckoutWithoutStripe.d.ts +8 -0
- package/dist/types/components/store/checkout/stripe.d.ts +4 -1
- package/dist/types/components/utils/__tests__/helpers/blockStorage.d.ts +3 -0
- package/dist/types/components/utils/logging/installConstructorCapture.d.ts +20 -0
- package/dist/types/components/utils/logging/reportBlockedStorage.d.ts +16 -0
- package/dist/types/components/utils/logging/startZonosInit.d.ts +5 -0
- package/dist/types/components/utils/logging/thrownMessage.d.ts +1 -0
- package/dist/types/components/utils/safeStorage.d.ts +4 -0
- package/dist/types/scripts/_bigcommerceCheckoutPath.d.ts +12 -0
- package/dist/types/scripts/_detectBigCommerceHost.d.ts +5 -0
- package/dist/types/scripts/_isBigCommerceNativeCheckout.d.ts +21 -0
- package/dist/types/scripts/_zonosBase.d.ts +16 -0
- package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +5 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +0 -22
- package/dist/types/types/generated/graphql.frontend.types.ts +0 -51
- package/dist/types/types/generated/graphql.internal.types.d.ts +270 -1
- package/dist/types/types/generated/graphql.internal.types.ts +341 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-8fa6cfff.entry.js → p-02faff47.entry.js} +1 -1
- package/dist/zonos-elements/{p-216a908d.system.entry.js → p-0c68cbbb.system.entry.js} +2 -2
- package/dist/zonos-elements/{p-vTIygnHq.system.js → p-1OG3IJgY.system.js} +1 -1
- package/dist/zonos-elements/{p-960070d0.system.entry.js → p-1cd2d097.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-1e6db427.entry.js → p-255e411a.entry.js} +1 -1
- package/dist/zonos-elements/p-2c_UqKJL.system.js +7 -0
- package/dist/zonos-elements/{p-DprOoI2W.system.js → p-3AUMK-5E.system.js} +154 -154
- package/dist/zonos-elements/{p-d3345b2c.entry.js → p-3ee87d8b.entry.js} +1 -1
- package/dist/zonos-elements/{p-cccaad60.system.entry.js → p-42fa5694.system.entry.js} +10 -10
- package/dist/zonos-elements/p-49eaaab8.entry.js +1 -0
- package/dist/zonos-elements/{p-fda89981.system.entry.js → p-4ce4c49f.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-f3d9a380.system.entry.js → p-5622fc50.system.entry.js} +263 -252
- package/dist/zonos-elements/{p-5585db86.system.entry.js → p-59457fd9.system.entry.js} +73 -64
- package/dist/zonos-elements/{p-65817880.entry.js → p-66398133.entry.js} +1 -1
- package/dist/zonos-elements/{p-d8f375da.system.entry.js → p-674323ac.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-678b9214.entry.js → p-71d9a5b7.entry.js} +1 -1
- package/dist/zonos-elements/{p-189cc594.system.entry.js → p-81780f8f.system.entry.js} +2 -2
- package/dist/zonos-elements/{p-6e691736.entry.js → p-821b83a2.entry.js} +1 -1
- package/dist/zonos-elements/{p-1fda4aec.system.entry.js → p-877a82d2.system.entry.js} +94 -94
- package/dist/zonos-elements/p-8daec112.entry.js +1 -0
- package/dist/zonos-elements/{p-46a839d2.system.entry.js → p-93bc75fd.system.entry.js} +13 -13
- package/dist/zonos-elements/{p-2ca826b9.system.entry.js → p-976b3bf3.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-84e76348.entry.js → p-9a4947a5.entry.js} +1 -1
- package/dist/zonos-elements/p-9f7693bf.entry.js +1 -0
- package/dist/zonos-elements/p-BIJM2Kj-.js +1 -0
- package/dist/zonos-elements/p-BJFa5RwX.js +1 -0
- package/dist/zonos-elements/{p-6vSUiBfr.system.js → p-BOh4ifdL.system.js} +51 -54
- package/dist/zonos-elements/p-BZAX-HmS.js +1 -0
- package/dist/zonos-elements/p-Bb90IMVt.js +1 -0
- package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
- package/dist/zonos-elements/{p-CbhN65lj.system.js → p-BvoPE_nb.system.js} +1 -1
- package/dist/zonos-elements/{p-iAIzUA4k.js → p-C3E55OqH.js} +1 -1
- package/dist/zonos-elements/{p-CBUz18kA.system.js → p-C3gF3UV5.system.js} +23 -23
- package/dist/zonos-elements/{p-XoQH3S7Z.system.js → p-CD2ahEZn.system.js} +1 -1
- package/dist/zonos-elements/p-CEBBLbvF.js +1 -0
- package/dist/zonos-elements/{p-CGNVm52g.system.js → p-CEV0O_IQ.system.js} +5 -5
- package/dist/zonos-elements/{p-D1e9zNDA.js → p-CJmWr75U.js} +1 -1
- package/dist/zonos-elements/{p-DgUrB-1a.system.js → p-CZ-uYiCo.system.js} +1 -1
- package/dist/zonos-elements/p-Cn2xE-9t.system.js +256 -0
- package/dist/zonos-elements/p-CtvXi9wL.system.js +41 -0
- package/dist/zonos-elements/{p-BrQ8n8NS.system.js → p-Cw_Qnyow.system.js} +3 -3
- package/dist/zonos-elements/p-CzXNXgyI.js +1 -0
- package/dist/zonos-elements/p-D0DkOoAw.system.js +73 -0
- package/dist/zonos-elements/p-D9OPKqLg.js +1 -0
- package/dist/zonos-elements/{p-ojtNq-r5.system.js → p-DXlojp_Y.system.js} +1 -1
- package/dist/zonos-elements/{p-DpwmHU8R.js → p-Df62LRNs.js} +2 -2
- package/dist/zonos-elements/{p-CHKKvuiz.js → p-Lsqrpzc5.js} +1 -1
- package/dist/zonos-elements/{p-C9XLkmmb.system.js → p-YQFbWtjn.system.js} +1 -1
- package/dist/zonos-elements/p-a27f48e4.entry.js +1 -0
- package/dist/zonos-elements/{p-941a95a1.system.entry.js → p-a6bb296c.system.entry.js} +7 -7
- package/dist/zonos-elements/{p-2b63865a.system.entry.js → p-abb85879.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-12b24ebb.entry.js → p-b8653024.entry.js} +1 -1
- package/dist/zonos-elements/p-b9d7a3b6.entry.js +1 -0
- package/dist/zonos-elements/{p-f5f95990.system.entry.js → p-be067e12.system.entry.js} +15 -15
- package/dist/zonos-elements/p-bmrOH9oh.js +1 -0
- package/dist/zonos-elements/p-c185bc23.entry.js +1 -0
- package/dist/zonos-elements/{p-2d513aa3.entry.js → p-c6e78de2.entry.js} +1 -1
- package/dist/zonos-elements/{p-55813e9f.system.entry.js → p-ca97a1cd.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-3e705c9b.entry.js → p-cbb96382.entry.js} +1 -1
- package/dist/zonos-elements/{p-53eac12f.system.entry.js → p-dbf4d156.system.entry.js} +14 -14
- package/dist/zonos-elements/{p-6410fa11.system.entry.js → p-df240119.system.entry.js} +16 -16
- package/dist/zonos-elements/{p-1cc42a98.system.entry.js → p-e16e4db6.system.entry.js} +17 -17
- package/dist/zonos-elements/{p-064d8829.system.entry.js → p-eb016dd8.system.entry.js} +20 -20
- package/dist/zonos-elements/{p-1199baef.system.entry.js → p-eb5c67a0.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-ef5344ea.entry.js → p-ed8a7a7f.entry.js} +1 -1
- package/dist/zonos-elements/{p-4917b74d.entry.js → p-ef932fda.entry.js} +1 -1
- package/dist/zonos-elements/{p-e7fdb2c9.entry.js → p-f792ba5f.entry.js} +1 -1
- package/dist/zonos-elements/{p-DiMEP3mh.js → p-fZcKMzE-.js} +1 -1
- package/dist/zonos-elements/{p-CMo3ZweU.js → p-fdritVtG.js} +1 -1
- package/dist/zonos-elements/p-fffe6376.entry.js +1 -0
- package/dist/zonos-elements/p-gEViRqvf.js +1 -0
- package/dist/zonos-elements/{p-Dtu_Japy.system.js → p-v8IEjQ2z.system.js} +39 -39
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +10 -10
- package/dist/esm-es5/handleFetch-D5GYDF-O.js +0 -60
- package/dist/zonos-elements/p-107f287b.entry.js +0 -1
- package/dist/zonos-elements/p-25eb99d4.entry.js +0 -1
- package/dist/zonos-elements/p-46b9f0cf.entry.js +0 -1
- package/dist/zonos-elements/p-636b71d4.entry.js +0 -1
- package/dist/zonos-elements/p-7dc7f328.entry.js +0 -1
- package/dist/zonos-elements/p-8f9d8795.entry.js +0 -1
- package/dist/zonos-elements/p-BMPYH-LT.js +0 -1
- package/dist/zonos-elements/p-C70h5mKA.js +0 -1
- package/dist/zonos-elements/p-CTiqplrr.js +0 -1
- package/dist/zonos-elements/p-Ch1w0Lr7.js +0 -1
- package/dist/zonos-elements/p-D1SmY_fZ.js +0 -1
- package/dist/zonos-elements/p-D6xXnsM_.js +0 -1
- package/dist/zonos-elements/p-DE4a-QD5.js +0 -1
- package/dist/zonos-elements/p-DQrMfUzi.system.js +0 -227
- package/dist/zonos-elements/p-DZdkJHK9.system.js +0 -7
- package/dist/zonos-elements/p-U33isUJG.js +0 -1
- package/dist/zonos-elements/p-ebe157b5.entry.js +0 -1
- package/dist/zonos-elements/p-zVLAvre1.system.js +0 -60
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,n,t,r){function o(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,i){function u(e){try{s(r.next(e))}catch(e){i(e)}}function a(e){try{s(r["throw"](e))}catch(e){i(e)}}function s(e){e.done?t(e.value):o(e.value).then(u,a)}s((r=r.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,u=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return u.next=a(0),u["throw"]=a(1),u["return"]=a(2),typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(e){return function(n){return s([e,n])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(u&&(u=0,a[0]&&(t=0)),t)try{if(r=1,o&&(i=a[0]&2?o["return"]:a[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;if(o=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:t.label++;return{value:a[1],done:false};case 5:t.label++;o=a[1];a=[0];continue;case 7:a=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){t.label=a[1];break}if(a[0]===6&&t.label<i[1]){t.label=i[1];i=a;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(a);break}if(i[2])t.ops.pop();t.trys.pop();continue}a=n.call(e,t)}catch(e){a=[6,e];o=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,t){if(t||arguments.length===2)for(var r=0,o=n.length,i;r<o;r++){if(i||!(r in n)){if(!i)i=Array.prototype.slice.call(n,0,r);i[r]=n[r]}}return e.concat(i||Array.prototype.slice.call(n))};System.register(["./p-CzKlS3E-.system.js","./p-DBOI98r5.system.js","./p-CKhl__Kc.system.js","./p-D0DkOoAw.system.js","./p-BbgqQIHv.system.js","./p-CtvXi9wL.system.js","./p-smUku7Ku.system.js","./p-C29tlYn0.system.js","./p-DsBuZ6ob.system.js"],(function(e){"use strict";var n,t,r,o,i,u,a,s,c,d,l,f,v,w,m,p,h,y,O;return{setters:[function(n){e({curpRegex:n.c,isMexicoTaxIdType:n.i,isPeruTaxIdType:n.a,peruTaxIdTypeFromValue:n.p,stripTaxIdSeparators:n.s})},function(e){n=e.c},function(e){t=e.g;r=e.I},function(e){o=e.t;i=e.s;u=e.g;a=e.a;s=e.h;c=e.l;d=e.b;l=e.c},function(n){f=n.l;e("availableTestKeys",n.a)},function(e){v=e.h;w=e.m;m=e.i},function(n){p=n.g;h=n._;y=n.c;O=n.a;e({checkoutHiddenBtnSelector:n.c,checkoutHiddenInternationalBtnSelector:n.a,domesticRedirectedBtnSelector:n.d})},function(n){e("countryRequireShortAddressCode",n.c)},function(n){e({checkoutTaxIdTypeValues:n.a,countryRequireTaxId:n.c,euCountryCodes:n.e,isCountryRequireTaxId:n.i,peruTaxIdDigitLength:n.p,peruTaxIdFormatError:n.b,shipToTaxIdLabels:n.s,taxIdTypeOptions:n.t})}],execute:function(){var g=this;var S=/^Constructor for .+ was not found/;var b=/^Constructor for "?([^#"]+)#/;var _=function(e){var n;var t=o(e,"");if(!t||!S.test(t)){return}if(typeof window.Zonos==="undefined"){return}var r=window.__zonosConstructorCapture;if(!r){return}var u=b.exec(t);var a=(n=u===null||u===void 0?void 0:u[1])!==null&&n!==void 0?n:"";if(r.reported.has(a)){return}r.reported.add(a);void i({endpoint:"stencil://constructor",errors:[t],metadata:{shape:"constructor-not-found",tag:a}})};
|
|
2
|
+
/**
|
|
3
|
+
* Copy a missing-constructor failure onto the existing error log.
|
|
4
|
+
* Stencil catches `Constructor for "tag#mode" was not found` and passes that
|
|
5
|
+
* Error to `console.error`. One report is sent per tag, then the original
|
|
6
|
+
* console.error still runs. This does not request the chunk again.
|
|
7
|
+
*/var j=function(){if(window.__zonosConstructorCapture){return}var e=function(e){_(e.reason)};window.__zonosConstructorCapture={listener:e,reported:new Set};window.addEventListener("unhandledrejection",e);
|
|
8
|
+
// eslint-disable-next-line no-console -- Stencil reports the missing constructor here
|
|
9
|
+
var n=console.error.bind(console);
|
|
10
|
+
// eslint-disable-next-line no-console -- record the Stencil diagnostic, then forward it
|
|
11
|
+
console.error=function(){var e=[];for(var t=0;t<arguments.length;t++){e[t]=arguments[t]}_(e[0]);n.apply(void 0,e)}};var z=function(e){
|
|
12
|
+
// sendErrorLog prints only when zonosDebug is on. Keep the failure in the
|
|
13
|
+
// merchant console without leaving an unhandled rejection.
|
|
14
|
+
// eslint-disable-next-line no-console -- the page console is the support signal
|
|
15
|
+
console.error(e);if(typeof window.Zonos==="undefined"){return}void i({endpoint:"zonos://init",errors:[o(e,"Unknown init rejection")],metadata:{shape:"init-rejection"}})};
|
|
16
|
+
/**
|
|
17
|
+
* Run an init that the caller is not waiting on. The rejection is recorded
|
|
18
|
+
* and not rethrown, so startup does not become an unhandled rejection.
|
|
19
|
+
*/var k=function(e){var n;try{n=e()}catch(e){z(e);return}void n.catch((function(e){z(e)}))};
|
|
20
|
+
/**
|
|
21
|
+
* Get the load version and url based on the loadScriptSrc and version
|
|
22
|
+
* @returns
|
|
23
|
+
*/var I=function(e){var n=e.loadScriptSrc;if(!n){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var t=[
|
|
24
|
+
// local domain
|
|
25
|
+
"dev.elements.zonos.com","dev.assets-checkout.zonos.com",
|
|
26
|
+
// any domain with prefix , no need to version it
|
|
27
|
+
".js.zonos.com",
|
|
28
|
+
// vercel git domain
|
|
29
|
+
"zonos-elements-test-git","zonos-elements-git"];var r=[
|
|
30
|
+
// force load version for qa domain, this is to test the load version behavior
|
|
31
|
+
"qa.js.zonos.com"];
|
|
32
|
+
// get the domain that's used to load the loadZonos.js
|
|
33
|
+
var o=new URL(n).origin;var i=t.some((function(e){
|
|
34
|
+
// check if the current domain is in the white listed domains
|
|
35
|
+
return o.includes(e)}));var u=r.some((function(e){
|
|
36
|
+
// check if the current domain is in the force load version domains list
|
|
37
|
+
return o.includes(e)}));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:u,isWhiteListed:i}};var T=["jsdelivr","cdnjs","unpkg","vercel"];var N="jsdelivr";
|
|
38
|
+
/**
|
|
39
|
+
* Get the next cdn type in the fallback list
|
|
40
|
+
* @param currentCdnType The current cdn type that want to get the next fallback url
|
|
41
|
+
*/var A=function(e){
|
|
42
|
+
// get current index of the current fail cdn type in the fallback list
|
|
43
|
+
var n=T.indexOf(e);
|
|
44
|
+
// get the next fallback cdn type
|
|
45
|
+
var t=T[n+1];return t||null};
|
|
46
|
+
/**
|
|
47
|
+
* Attempt to get test public credential to window.Zonos.zonosApiKey if needed
|
|
48
|
+
*/var R=function(){return __awaiter(g,void 0,void 0,(function(){var e,n,t,r,o,i;return __generator(this,(function(d){switch(d.label){case 0:e=u();n=a();
|
|
49
|
+
// Do nothing if the test mode is not enabled or the public credential
|
|
50
|
+
if(!e&&!n||!window.Zonos.zonosApiKey){return[2/*return*/,null]}f("[ZONOS - loadZonos] Attempt test public credential","info");
|
|
51
|
+
// Try to get the test public credential if the test mode is enabled and the public credential key is not a test key
|
|
52
|
+
if(!!window.Zonos.zonosApiKey.includes("credential_test")){f("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2/*return*/,null]}return[4/*yield*/,s("/api/get-test-public-credential")];case 1:t=d.sent(),r=t.errors,o=t.json;if(r.length||!o){c("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r);return[2/*return*/,null]}i=o.publicCredential;if(!i){c("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2/*return*/,null]}
|
|
53
|
+
// Set the test public credential to the window object
|
|
54
|
+
f("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2/*return*/,i]}}))}))};
|
|
55
|
+
/**
|
|
56
|
+
* Extracts the zonosQaUrl from the url
|
|
57
|
+
*
|
|
58
|
+
* @param url - url to extract zonosQaUrl from
|
|
59
|
+
*
|
|
60
|
+
* **NOTE**: value of zonosQaUrl param should be without protocol, allowed characters are: a-z, A-Z, 0-9, -, _
|
|
61
|
+
* @example
|
|
62
|
+
* valid: https://www.zonos.com/?zonosQaUrl=some-feature-v988
|
|
63
|
+
* invalid: https://www.zonos.com/?zonosQaUrl=https://zonos-something
|
|
64
|
+
*/var Z=function(e){if(!e){return null}
|
|
65
|
+
// get params from url
|
|
66
|
+
var n=new URL(e).searchParams;var t=n.get("zonosQaUrl");if(!t){return null}var r=/[^a-zA-Z0-9-_]+/.test(t);if(!!r){return null}return t};
|
|
67
|
+
/**
|
|
68
|
+
* Get the Zonos QA URL and return it. Will remove `zonosQaUrl` from the url query if it doesn't exists.
|
|
69
|
+
*/var C=function(){
|
|
70
|
+
/**
|
|
71
|
+
* This is flag to force load cdn for testing purpose
|
|
72
|
+
* When developing, if the script load is from `dev.elements.zonos.com`,
|
|
73
|
+
* it would load script from that same domain instead of loading from cdn
|
|
74
|
+
*/
|
|
75
|
+
var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=Z(window.location.href);var t="https://v1.5.3.js.zonos.com";
|
|
76
|
+
// when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
|
|
77
|
+
if(!n&&(t.includes("test.")||
|
|
78
|
+
// Vercel git domain
|
|
79
|
+
t.includes("test-"))){return t}
|
|
80
|
+
// when local demo app is running, it needs to use the local dev script unless the qaUrl is set
|
|
81
|
+
if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!n){return null}
|
|
82
|
+
// If the qaUrl, use the dev-elements domain to forward the request to the dev server to quickly debug the issue
|
|
83
|
+
if(n==="dev-elements"){return"https://dev.elements.zonos.com"}
|
|
84
|
+
// The worker alias selects the API host only. Scripts stay on the normal CDN.
|
|
85
|
+
if(n==="worker"){return null}var r="preview.js.zonos.com";var o="https://".concat(n,".").concat(r);f("[ZONOS-WARNING] using '".concat(o,"' for loading elements script"),"warn");
|
|
86
|
+
// request to the url and check if the request has an error
|
|
87
|
+
void fetch(o).then((function(){
|
|
88
|
+
// cleanup checkout session to avoid using the prod session in preview domain
|
|
89
|
+
d("session","zonos--checkout-session-id");d("session","zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(o,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));
|
|
90
|
+
// remove the zonosQaUrl param from url
|
|
91
|
+
var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var n=window.location.pathname;var t="".concat(n,"?").concat(e.toString());
|
|
92
|
+
/**
|
|
93
|
+
* Setting the state to null in window.history.replaceState can cause issues with rendering when using next/link and pressing the back button.
|
|
94
|
+
* @ref https://github.com/vercel/next.js/issues/33233#issuecomment-1052349396
|
|
95
|
+
**/window.history.replaceState(window.history.state,"",t);window.location.reload();return null}));return o};
|
|
96
|
+
/* eslint-disable no-console */
|
|
97
|
+
/** Loading stripe script extracted from stripe.js repository */var E="2025-02-24.acacia";var L="https://js.stripe.com/v3";var U=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var P=3;var x="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var D=function(){var e=document.querySelectorAll('script[src^="'.concat(L,'"]'));for(var n=0;n<e.length;n++){var t=e[n];if(!t){continue}if(!U.test(t.src)){continue}return t}return null};var F=null;var M=function(e){var n="";var t=document.createElement("script");t.src="".concat(L).concat(n);var r=document.head||document.body;if(!r){c("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(t);return t};var B=function(e){
|
|
98
|
+
// Ensure that we only attempt to load Stripe.js at most once
|
|
99
|
+
if(F!==null){return F}F=new Promise((function(n,t){if(typeof window==="undefined"||typeof document==="undefined"){
|
|
100
|
+
// Resolve to null when imported server side. This makes the module
|
|
101
|
+
// safe to import in an isomorphic code base.
|
|
102
|
+
n(null);return}if(window.Stripe){n(window.Stripe);return}try{var r=D();if(r&&e){console.warn(x)}else if(!r){r=M()}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{t(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){t(new Error("Failed to load Stripe.js"))}))}catch(e){t(e);return}}));return F};var K=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var G=function(e){if(!("version"in e)){return}var n=e.version;return typeof n==="number"||typeof n==="string"?n:undefined};var V=function(e,n,t){if(e===null){return null}var r=n[0],o=n[1];var i=Object.assign({},o);var u=G(e);var a=typeof u==="string"&&u!==P.toString();if(a){delete i.apiVersion}else{i.apiVersion=E}var s=e(r,i);K(s,t);return s};
|
|
103
|
+
// Execute our own script injection after a tick to give users time to do their
|
|
104
|
+
// own script injection.
|
|
105
|
+
var q=function(){var e,n;return typeof window!=="undefined"&&(typeof((e=window.Zonos)===null||e===void 0?void 0:e.createCartId)==="function"||typeof((n=window.Zonos)===null||n===void 0?void 0:n.buildCartDetail)==="function")};
|
|
106
|
+
/**
|
|
107
|
+
* The only function that may inject Stripe.js. Native BigCommerce checkout
|
|
108
|
+
* returns null before `window.Stripe` is read or `js.stripe.com/v3` is added.
|
|
109
|
+
* Callers decide whether to ask for Stripe. They do not load it themselves.
|
|
110
|
+
*/var H=function(){if(v()){return Promise.resolve(null)}return B(null)};var W=Promise.resolve().then((function(){
|
|
111
|
+
// Hello-only pages have no cart callback, so they skip the eager preload.
|
|
112
|
+
if(!q()){return null}return H()}));var Q=false;W.catch((function(e){if(!Q){
|
|
113
|
+
// eslint-disable-next-line no-console
|
|
114
|
+
console.warn(e)}}));var Y=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(g,void 0,void 0,(function(){var n,t,r,o;return __generator(this,(function(i){switch(i.label){case 0:Q=true;t=Date.now();return[4/*yield*/,W];case 1:if(!((n=i.sent())!==null&&n!==void 0))return[3/*break*/,2];o=n;return[3/*break*/,4];case 2:return[4/*yield*/,H()];case 3:o=i.sent();i.label=4;case 4:r=o;return[2/*return*/,V(r,e,t)]}}))}))};var J="tempCartUUID";
|
|
115
|
+
/**
|
|
116
|
+
* Simple function to get the cart id from the query param.
|
|
117
|
+
*/var X=function(){var e=new URLSearchParams(window.location.search);var n=e.get(J);return n};var $=function(e){return __awaiter(g,[e],void 0,(function(e){var n,r,o,i,a,c,d,l,v;var w=e.cartId,m=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=u();r=t();o=p()||undefined;i=new URLSearchParams;if(r.overrideShouldEnabledCustomAddress){i.set("overrideShouldEnabledCustomAddress",r.overrideShouldEnabledCustomAddress)}return[4/*yield*/,s("/api/zonos-elements/get-cart?".concat(i.toString()),{body:{isTestMode:n,renewCartExpirationToken:o,tempCartUUID:w},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:a=e.sent(),c=a.errors,d=a.json,l=a.zonosMode;v=!d||c.length;if(!(v&&m))return[3/*break*/,3];f("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:m});
|
|
118
|
+
// wait 1 second before retrying
|
|
119
|
+
return[4/*yield*/,new Promise((function(e){return setTimeout(e,500)}))];case 2:
|
|
120
|
+
// wait 1 second before retrying
|
|
121
|
+
e.sent();return[2/*return*/,$({cartId:w,retries:m-1})];case 3:if(v){return[2/*return*/,null]}return[2/*return*/,Object.assign(Object.assign({},d),{zonosMode:l})]}}))}))};var ee=function(e){return __awaiter(g,void 0,void 0,(function(){var n,t,r,o;return __generator(this,(function(i){switch(i.label){case 0:n=h(e),t=n.isDgsCartId,r=n.isLegacyCartId;if(!r&&!t){c("[ZONOS - loadZonos] invalid cart id");return[2/*return*/,null]}return[4/*yield*/,$({cartId:e,retries:5})];case 1:o=i.sent();f("[ZONOS - loadZonos] getting temp cart data","info",o);if(!o){c("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2/*return*/,null]}window.Zonos.storeId=o.cartData.storeId;window.Zonos.zonosApiKey=o.cartData.credentialToken;window.Zonos.zonosMode=o.zonosMode;return[2/*return*/,{cartData:o.cartData,settings:o.settings,storeFavicon:o.storeFaviconUrl,storeId:o.cartData.storeId,storeLogo:o.storeLogoUrl,zonosApiKey:o.cartData.credentialToken}]}}))}))};var ne;
|
|
122
|
+
/**
|
|
123
|
+
* Get the load version and url based on the loadScriptSrc, if the domain that used to load `zonos.js` is in white listed domains, use currentLoadScriptUrl as the load url instead, if zonosQaUrl exists, it would also fall under the white listed domain
|
|
124
|
+
*/var te=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=I({loadScriptSrc:e===null||e===void 0?void 0:e.src}),t=n.currentLoadScriptUrl,r=n.isWhiteListed;if(r){return t}return null}();var re=Date.now();var oe="https://v1.5.3.js.zonos.com";var ie=te||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.5.3";var ue="https://unpkg.com/@zonos/elements@1.5.3";var ae="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.5.3";var se="https://fonts.googleapis.com";var ce=/^https:\/\/fonts\.googleapis\.com/;var de=/** @class */function(){function e(){}return e}();e("Zonos",de);ne=de;de.doneInit=false;de.cartSettings=null;
|
|
125
|
+
// if query 'zonosDebug=1' param from url, debug mode is on
|
|
126
|
+
de.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);de.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);de._paypalMockResponse=null;de.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;de.isBigCommerce=false;de.releaseDate="1794098254078";de.isLegacyCheckout=false;de.googleAnalyticId=null;de.googleAnalyticReady=false;de.facebookPixelId=null;de.facebookPixelReady=false;de.startLoadTime=re;de.domain=typeof window!=="undefined"?// domain that embeds the iframe
|
|
127
|
+
window.location!=window.parent.location&&document.referrer||
|
|
128
|
+
// current domain
|
|
129
|
+
document.location.hostname:"";de.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");de.overrideUseCustomAddressForm=false;de.isCollect=false;de.isInvoice=false;
|
|
130
|
+
/**
|
|
131
|
+
* By default, the package will load from npm
|
|
132
|
+
*/de.isNpm=true;de.zonosQaUrl=null;de.zonosQaUrlApi=null;de.trackEventLogs=[];de.version="v".concat("1.5.3");de.modeAlerted=false;de.cartData=null;de.paypal=null;de.zonosMode=null;de.IframeService=r;de.getCurrentTimestamp=function(){return(new Date).getTime()};de.zonosController=null;de.loadTimeApiInfoList=[];de.logIntervalId=null;de.init=function(e){return __awaiter(g,void 0,void 0,(function(){var n,t,r,o,i,u,a,s,d,v,m,p,h,O,g;return __generator(this,(function(S){switch(S.label){case 0:j();n=e.appearance,t=e.checkoutSettings,r=e.currencyConverter,o=e.helloSettings,i=e.onCountryChange,u=e.overrideCurrencyFormat,a=e.storeId,s=e.zonosApiKey;ne.cartId=X();
|
|
133
|
+
// Expose the checkout cart callbacks on the global so Stripe loading can be
|
|
134
|
+
// gated on whether at least one of them is configured.
|
|
135
|
+
ne.createCartId=t===null||t===void 0?void 0:t.createCartId;
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- intentionally mirror the (deprecated) callback so Stripe loading can be gated on it
|
|
137
|
+
ne.buildCartDetail=t===null||t===void 0?void 0:t.buildCartDetail;if(ne.doneInit){
|
|
138
|
+
// do nothing if zonos is already initialized
|
|
139
|
+
return[2/*return*/]}
|
|
140
|
+
// Host detection has already copied `isBigCommerce`. Settle the
|
|
141
|
+
// native-checkout answer once, before buttons or Stripe are touched.
|
|
142
|
+
w();f("====== ZONOS DEBUG MODE: on (".concat(ne.version,") ======"));ne.zonosApiKey=s;ne.storeId=a;
|
|
143
|
+
// When not in iframe, providers are ready (gtag/fbq work directly). When in iframe, relay sets these after parent configures.
|
|
144
|
+
if(typeof window!=="undefined"&&window.parent===window){ne.googleAnalyticReady=true;ne.facebookPixelReady=true}if(!ne.isNpm)return[3/*break*/,4];f("====== ZONOS LOADING FROM NPM ======");d=C();
|
|
145
|
+
// if zonosQaUrl is available, inject the script from the zonosQaUrl and then call init again
|
|
146
|
+
if(d&&!window.isZonosPreview){f('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(d," ======"),"info");v=document.createElement("script");v.src="".concat(d,"/dist/scripts/zonos.js");document.head.appendChild(v);v.addEventListener("load",(function(){window.Zonos.isNpm=ne.isNpm;window.Zonos.isBigCommerce=ne.isBigCommerce;window.Zonos.isLegacyCheckout=ne.isLegacyCheckout;window.Zonos.zonosMode=ne.zonosMode;
|
|
147
|
+
// call init again after the script is loaded
|
|
148
|
+
k((function(){return window.Zonos.init(e)}))}));v.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(d))}));
|
|
149
|
+
// Set so won't inject the preview script again
|
|
150
|
+
window.isZonosPreview=true;return[2/*return*/]}
|
|
151
|
+
// zonosApiKey is required if tempCartUUID in query params are not provided
|
|
152
|
+
if(!s&&!ne.cartId){c("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2/*return*/]}if(!(!ne.cartData&&ne.cartId))return[3/*break*/,2];f("Initialize cart data");return[4/*yield*/,ee(ne.cartId)];case 1:m=S.sent();if(!m){c("Failed to get cart data");return[2/*return*/]}ne.cartData=m.cartData;ne.zonosApiKey=m.zonosApiKey;ne.cartSettings=m.settings;S.label=2;case 2:return[4/*yield*/,R()];case 3:p=S.sent();if(p){ne.zonosApiKey=p}S.label=4;case 4:h=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||l("session","zonos--client-secret");O=ne.cartId&&ne.cartData||!!h;
|
|
153
|
+
// inject hidden button to body to trigger checkout right away if we have cartData or stripe client secret
|
|
154
|
+
if(O){f("Cart data or stripe client secret is available, inject hidden button and trigger checkout");g=document.createElement("button");g.style.display="none";g.id="".concat(y);document.body.appendChild(g)}f("init zonos");ne.restoreNativeBrowserFunctions();
|
|
155
|
+
// inject custom script for hosted checkout if can find it in metadata
|
|
156
|
+
ne.injectCustomScriptForHostedCheckout();
|
|
157
|
+
// inject zonos cdn
|
|
158
|
+
ne.injectZonosCdn();
|
|
159
|
+
// inject css for zonos elements
|
|
160
|
+
ne.injectZonosCss();
|
|
161
|
+
// inject fonts for zonos elements
|
|
162
|
+
ne.injectFonts();
|
|
163
|
+
// inject checkout international button
|
|
164
|
+
ne.injectCheckoutInternationalButton();
|
|
165
|
+
// init zonos controller
|
|
166
|
+
ne.injectController({config:{appearance:n,checkoutSettings:t,currencyConverter:r,helloSettings:o,onCountryChange:i,overrideCurrencyFormat:u}});ne.doneInit=true;return[2/*return*/]}}))}))};
|
|
167
|
+
/**
|
|
168
|
+
* Inject the hidden international checkout button to trigger checkout regardless of shipping zones
|
|
169
|
+
*/de.injectCheckoutInternationalButton=function(){if(!document.querySelector("#".concat(O))){
|
|
170
|
+
// inject the hidden international checkout button
|
|
171
|
+
var e=document.createElement("button");e.id=O;e.style.display="none";document.body.appendChild(e)}};de.injectCustomScriptForHostedCheckout=function(){var e=ne.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var t=n.find((function(e){return e.key==="customHeaderScript"}));var r=n.find((function(e){return e.key==="customFooterScript"}));
|
|
172
|
+
// googleAnalyticId / facebookPixelId are set by customHTML in checkoutSettings (e.g. <script>window.Zonos.googleAnalyticId = "G-XXX"; window.Zonos.facebookPixelId = "1234567890";<\/script>), injected by zonos-controller
|
|
173
|
+
// Only inject the script if checkout is on Zonos hosted checkout and custom script is available
|
|
174
|
+
if(!window.Zonos.isLegacyCheckout||!t&&!r){f("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(t){f("Injecting custom header script");var o=document.createElement("script");o.textContent=t.value;document.head.appendChild(o)}if(r){f("Injecting custom footer script");var o=document.createElement("script");o.textContent=r.value;document.body.appendChild(o)}};de.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};de.triggerCheckoutInternational=function(){return __awaiter(g,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=document.querySelector("#".concat(O));setTimeout((function(){if(e){e.dispatchEvent(n("click"))}}),10);return[2/*return*/]}))}))};
|
|
175
|
+
// Called openHelloDialog because the main use case is to simply open the dialog
|
|
176
|
+
de.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};de.showNotification=function(e){var n;void((n=ne.zonosController)===null||n===void 0?void 0:n.showNotification(e))};de.updateOrganizationName=function(e){var n;void((n=ne.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};de.disablePlaceOrderButtons=function(e){var n=e.autoEnable,t=n===void 0?true:n,r=e.config,o=e.disable,i=e.placeOrderButtonSelector;var u;
|
|
177
|
+
// if disablePlaceOrderButtonActivation is true, do nothing
|
|
178
|
+
if((u=r.checkoutSettings)===null||u===void 0?void 0:u.disablePlaceOrderButtonActivation){return}
|
|
179
|
+
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
180
|
+
if(i){var a=document.querySelectorAll(i);var s=function(e){var n=e.target;
|
|
181
|
+
// prevent default and propagation when the item has disabled attribute
|
|
182
|
+
if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};a.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){
|
|
183
|
+
// do nothing if event is already attached
|
|
184
|
+
return}if(o){e.setAttribute("disabled","true");
|
|
185
|
+
// prevent the selector to perform default action when it's disabled
|
|
186
|
+
e.addEventListener("click",s)}else{e.removeAttribute("disabled");
|
|
187
|
+
// clean up the event listener
|
|
188
|
+
e.removeEventListener("click",s)}}));
|
|
189
|
+
// only auto enable if autoEnable is true and we are setting button disable
|
|
190
|
+
if(t&&o){setTimeout((function(){
|
|
191
|
+
// release it if zonos is not initialized after 5 seconds (this is to prevent the place order button from being disabled forever due to api)
|
|
192
|
+
a.forEach((function(e){e.removeAttribute("disabled");
|
|
193
|
+
// clean up the event listener if exists
|
|
194
|
+
e.removeEventListener("click",s)}))}),5e3)}}};
|
|
195
|
+
/**
|
|
196
|
+
* Zonos elements and its dependencies are using the native browser functions.
|
|
197
|
+
* This function will restore the native browser functions that are overridden by the merchant's polyfills.
|
|
198
|
+
* If the URL parameter `useMerchantPolyfill=1` is present, keep the merchant's polyfills instead of restoring native browser functions. This allows testing checkout compatibility with merchant polyfills.
|
|
199
|
+
*/de.restoreNativeBrowserFunctions=function(){var e;
|
|
200
|
+
// If the URL parameter `useMerchantPolyfill=1` is present, keep the merchant's polyfills instead of restoring native browser functions.
|
|
201
|
+
var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var t="zonos---native-browser";var r=document.querySelector("iframe#".concat(t));if(!r){
|
|
202
|
+
// add a hidden iframe
|
|
203
|
+
r=document.createElement("iframe");r.id=t;r.style.display="none";r.style.opacity="0";r.style.position="absolute";r.style.top="-9999px";r.style.left="-9999px";r.style.width="1px";r.style.height="1px";r.style.border="none";r.style.overflow="hidden";r.style.visibility="hidden";document.body.appendChild(r)}
|
|
204
|
+
/**
|
|
205
|
+
* Override Array.from if the site is using the obsolete prototype.js (last updated 2015).
|
|
206
|
+
* If old browser is being used and Array.from is not available, just use Array from the prototype.js polyfill
|
|
207
|
+
*/var o=((e=r.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=o;document.body.removeChild(r)};de.injectController=function(e){var n=e.config;var t,r;if(document.querySelector("zonos-controller")){return}
|
|
208
|
+
// Native BigCommerce checkout never calls attachCheckout, which is what
|
|
209
|
+
// marks these buttons handled. Disabling them here would flicker the
|
|
210
|
+
// store's own buttons after every DOM mutation.
|
|
211
|
+
if(!m()){
|
|
212
|
+
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
213
|
+
if((t=n.checkoutSettings)===null||t===void 0?void 0:t.placeOrderButtonSelector){var o=n.checkoutSettings.placeOrderButtonSelector;ne.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:o});
|
|
214
|
+
// create a mutation observer to see if any new elements that match our selector is added to the DOM
|
|
215
|
+
var i=new MutationObserver((function(){ne.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:o})}));i.observe(document.body,{childList:true,subtree:true})}
|
|
216
|
+
// if alwaysTriggerInternationalCheckoutSelector is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
217
|
+
if((r=n.checkoutSettings)===null||r===void 0?void 0:r.alwaysTriggerInternationalCheckoutSelector){var u=n.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;ne.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:u});
|
|
218
|
+
// create a mutation observer to see if any new elements that match our selector is added to the DOM
|
|
219
|
+
var i=new MutationObserver((function(){ne.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:u})}));i.observe(document.body,{childList:true,subtree:true})}}var a=document.createElement("zonos-controller");a.config=n;a.zonosApiKey=ne.zonosApiKey||"";a.addEventListener("stripeInitEvent",(function(e){return __awaiter(g,void 0,void 0,(function(){var n,t;return __generator(this,(function(r){switch(r.label){case 0:n=e.detail;f("loading Stripe");return[4/*yield*/,Y(n.publishableKey)];case 1:t=r.sent();if(!t){c("API seems to be invalid or missing. Failed to load Stripe");return[2/*return*/]}window.Zonos.stripe=t;if(window.Zonos.isCollect){void a.initCollectElement(t)}else if(window.Zonos.isInvoice){void a.initInvoiceElement(t)}else{void a.initCheckoutElement(t)}return[2/*return*/]}}))}))}));document.body.appendChild(a);
|
|
220
|
+
// set zonos controller to be global
|
|
221
|
+
ne.zonosController=a;f("Zonos controller injected!")};de.injectScript=function(e){var n=e.cdnType,t=e.isModule,r=e.theRestUrl;var o=ne.getZonosUrl(n);var i="".concat(o,"/").concat(r);var u=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(u()){f('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var a=document.head||document.body;
|
|
222
|
+
// init zonos elements when the zonosKey is valid
|
|
223
|
+
// inject esmodule cdn for zonos elements
|
|
224
|
+
var s=document.createElement("script");if(!!t){s.type="module"}else{s.noModule=true}s.src=i;s.crossOrigin="anonymous";s.onerror=function(){c("Failed to load ".concat(s.src));var e=A(n);
|
|
225
|
+
// if next fallback cdn type exists, inject the script with the next fallback cdn type
|
|
226
|
+
if(!e){return}ne.injectScript({cdnType:e,isModule:t,theRestUrl:r})};a.appendChild(s)};
|
|
227
|
+
/**
|
|
228
|
+
* We now support loading Zonos via npm. For clients using npm, `zonosBase` will always load from the server side. Therefore, the `zonosLoadUrl` defined earlier won't work since it lacks access to client-side APIs such as `window` and `document`.
|
|
229
|
+
*/de.getZonosUrl=function(e){var n=function(){switch(e){case"jsdelivr":return ie;case"unpkg":return ue;case"cdnjs":return ae;case"vercel":return oe}};
|
|
230
|
+
// To ensure that sites using zonos-elements load the script from a specific domain when using npm, we need to check for zonosQaUrl and use it if available. Otherwise it will always load from the compiled versioned domain
|
|
231
|
+
if(ne.isNpm){var t=C();
|
|
232
|
+
// Default to hard coded domain if zonosQaUrl is not available
|
|
233
|
+
return t||n()}return n()};de.injectZonosCdn=function(){
|
|
234
|
+
// init zonos elements when the zonosKey is valid
|
|
235
|
+
// inject esmodule cdn for zonos elements
|
|
236
|
+
ne.injectScript({cdnType:N,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});
|
|
237
|
+
// inject non module cdn for zonos elements
|
|
238
|
+
ne.injectScript({cdnType:N,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});f("Zonos cdn script injected!")};de.injectStylesheet=function(e){var n=e.cdnType,t=e.theRestUrl;var r=ne.getZonosUrl(n);var o=document.head||document.body;
|
|
239
|
+
// inject preconnect css for zonos elements
|
|
240
|
+
var i=document.createElement("link");i.rel="preconnect";i.href="".concat(oe,"/");o.appendChild(i);
|
|
241
|
+
// inject css for zonos elements
|
|
242
|
+
var u=document.createElement("link");u.rel="stylesheet";u.href="".concat(r,"/").concat(t);u.onerror=function(){c("Failed to load ".concat(u.href));var e=A(n);
|
|
243
|
+
// if the css failed to load, try to load the next fallback cdn if exists
|
|
244
|
+
if(!e){return}ne.injectStylesheet({cdnType:e,theRestUrl:t})};o.appendChild(u)};de.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){f("Zonos style links already injected","warn");return}
|
|
245
|
+
// inject css for zonos elements
|
|
246
|
+
ne.injectStylesheet({cdnType:N,theRestUrl:"dist/zonos-elements/zonos-elements.css"});f("Zonos style css injected!")};de.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){f("Inter font already loaded","warn");return}var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(se,'"]'));for(var t=0;t<n.length;t++){var r=n[t];if(!r){continue}if(ce.test(r.href)){continue}return r}return null};if(e()){f("Inter font already injected","warn");return}var n=document.head||document.body;
|
|
247
|
+
// inject font css for zonos elements
|
|
248
|
+
var t=document.createElement("link");t.rel="preconnect";t.href=se;n.appendChild(t);
|
|
249
|
+
// inject font css for zonos elements
|
|
250
|
+
var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(se,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");n.appendChild(r);f("Zonos font injected!")};
|
|
251
|
+
// apply font for zonos elements and inject font if needed
|
|
252
|
+
de.setupGoogleFont=function(e){var n;void((n=ne.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};
|
|
253
|
+
// this function is to inject google font to the browser, not apply the font for zonos elements, to apply the font and inject font if needed, use `setupGoogleFont` instead
|
|
254
|
+
de.injectSupportGoogleFont=function(e){var n;f("[FONT] injecting ".concat(e));var t=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var r=document.head||document.body;
|
|
255
|
+
// inject font css for zonos elements
|
|
256
|
+
if(!document.querySelector('link[rel="preconnect"][href^="'.concat(se,'"]'))){var o=document.createElement("link");o.rel="preconnect";o.href=se;r.appendChild(o)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){f("[FONT] ".concat(t," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;r.appendChild(i);f("[FONT] ".concat(t," font injected!"))};var le=e("checkoutSessionMutableAttributeKeys",["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"]);var fe=e("checkoutSessionImmutableAttributeKeys",["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"]);var ve=e("checkoutSessionAttributeKeys",__spreadArray(__spreadArray([],le,true),fe,true))}}}));
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
System.register([],(function(n){"use strict";return{execute:function(){
|
|
2
|
+
/**
|
|
3
|
+
* Two checkout-path rules, kept together so they cannot drift in separate files.
|
|
4
|
+
*
|
|
5
|
+
* `pathContainsCheckout` is the broad rule for zBypass and address detection.
|
|
6
|
+
* It still matches paths such as `checkout-page`.
|
|
7
|
+
*
|
|
8
|
+
* `hasExactCheckoutSegment` is the strict rule for the Stripe.js skip. Only a
|
|
9
|
+
* segment exactly equal to `checkout` counts, so a slug does not drop the
|
|
10
|
+
* payment script.
|
|
11
|
+
*/
|
|
12
|
+
var e=n("p",(function(n){return n.includes("/checkout")}));var r=function(n){return n.split("/").some((function(n){return n==="checkout"}))};
|
|
13
|
+
/**
|
|
14
|
+
* Storefront signals BigCommerce sets before Zonos copies `isBigCommerce`.
|
|
15
|
+
* Shared by the loader script and the Stripe skip so the two cannot drift.
|
|
16
|
+
*/var u=function(){if(typeof window==="undefined"||typeof document==="undefined"){return false}return!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')};var i=function(){return r(window.location.pathname)};var t=function(){if(typeof window==="undefined"||!("Zonos"in window)){return undefined}return window.Zonos};var f=function(){var n;return((n=t())===null||n===void 0?void 0:n.isBigCommerce)===true};
|
|
17
|
+
/**
|
|
18
|
+
* The settled answer lives on `window.Zonos`, the object loadZonos.js,
|
|
19
|
+
* zonos.js, and the component bundle already share.
|
|
20
|
+
*
|
|
21
|
+
* A `true` result sticks for that pathname. A `false` result sticks once
|
|
22
|
+
* the path is not checkout, or once host detection has finished. A checkout
|
|
23
|
+
* path whose BigCommerce signals are not in the page yet stays unset, so a
|
|
24
|
+
* later signal can still settle it.
|
|
25
|
+
*/var d=function(){var n=t();if(n===undefined){return undefined}if(n.isBigCommerceNativeCheckoutPath!==window.location.pathname){return undefined}var e=n.isBigCommerceNativeCheckout;if(e===true||e===false){return e}return undefined};var o=function(n){var e=t();if(e!==undefined){e.isBigCommerceNativeCheckout=n;e.isBigCommerceNativeCheckoutPath=window.location.pathname}return n};
|
|
26
|
+
/**
|
|
27
|
+
* Call after `isBigCommerce` has been copied from host detection. Writes the
|
|
28
|
+
* settled boolean onto `window.Zonos` for this pathname.
|
|
29
|
+
*/var c=n("m",(function(){if(typeof window==="undefined"||typeof document==="undefined"){return}var n=t();if(n===undefined){return}var e=i()&&(u()||f());n.isBigCommerceNativeCheckout=e;n.isBigCommerceNativeCheckoutPath=window.location.pathname}));var a=function(){if(typeof window==="undefined"||typeof document==="undefined"){return false}var n=d();if(n!==undefined){return n}if(!i()){return o(false)}if(u()||f()){return o(true)}return undefined};
|
|
30
|
+
/**
|
|
31
|
+
* True when this document is BigCommerce native checkout.
|
|
32
|
+
* Stripe.js injection is owned by `loadStripeScript` in `_loadStripe.ts`.
|
|
33
|
+
* Other callers use this for a different job: skip `attachCheckout`, leave
|
|
34
|
+
* the store's buttons enabled, or hand a leftover domestic session to `/`.
|
|
35
|
+
* An undecided checkout path returns false and is not stored.
|
|
36
|
+
*/var w=n("i",(function(){return a()===true}));
|
|
37
|
+
/**
|
|
38
|
+
* True when Stripe.js must not be injected. An undecided checkout path
|
|
39
|
+
* holds the script until host detection finishes, instead of storing "not
|
|
40
|
+
* native checkout" and injecting v3 early.
|
|
41
|
+
*/var v=n("h",(function(){var n=a();if(n===undefined){return true}return n}))}}}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
System.register(["./p-
|
|
1
|
+
System.register(["./p-3AUMK-5E.system.js"],(function(e){"use strict";var t;return{setters:[function(e){t=e.W}],execute:function(){
|
|
2
2
|
/**
|
|
3
3
|
* Minimum number of characters we treat as a valid postal code. Mirrors the
|
|
4
4
|
* landed-cost readiness check in `stripe.ts` (`isAddressReadyToRequestLandedCost`).
|
|
@@ -15,7 +15,7 @@ var i=e("M",3);
|
|
|
15
15
|
*
|
|
16
16
|
* Pure: the caller resolves `countryField` (via `getCountryField`) and passes it in, so
|
|
17
17
|
* this can be unit-tested without the stores.
|
|
18
|
-
*/var
|
|
18
|
+
*/var n=e("g",(function(e){var n=e.countryField,r=e.event;var v,a,o;if(!r){return[]}var u=r.value;var l=[];
|
|
19
19
|
// Last name is always required for international shipping. Link's single name input
|
|
20
20
|
// often provides only a first name, leaving the extracted last name empty.
|
|
21
|
-
var s=t({firstName:u.firstName,lastName:u.lastName,name:u.name}).lastName;if(!s.trim()){l.push({key:"lastName"})}if((
|
|
21
|
+
var s=t({firstName:u.firstName,lastName:u.lastName,name:u.name}).lastName;if(!s.trim()){l.push({key:"lastName"})}if((n===null||n===void 0?void 0:n.stateRequired)&&!((v=u.address.state)===null||v===void 0?void 0:v.trim())){l.push({key:"state"})}if((n===null||n===void 0?void 0:n.zipRequired)&&((o=(a=u.address.postal_code)===null||a===void 0?void 0:a.trim().length)!==null&&o!==void 0?o:0)<i){l.push({key:"postal_code"})}return l}))}}}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,z as t,e as o}from"./p-CqB9AfBf.js";import{s as n,t as r,n as s,l as i,f as a,e as d}from"./p-D9OPKqLg.js";import{b as l,e as c}from"./p-Dwg61Ft_.js";import{e as u,i as m}from"./p-DMIgN_sT.js";import{l as p,b as v}from"./p-BJmZPrZl.js";import{h,l as y,f,g as w,a as g,s as b,c as C,e as S,b as O,j as A}from"./p-gEViRqvf.js";import{i as I}from"./p-YdrG78th.js";import{g as k}from"./p-r-YGHhLa.js";const T=async()=>{if(!n.checkoutSessionId)return{errors:[{message:"No checkout session id found"}],json:null};const e=new URLSearchParams;e.set("checkoutSessionId",n.checkoutSessionId);const{errors:t,json:o}=await h(`/api/zonos-elements/get-checkout-session?${e.toString()}`);return{errors:t,json:o}},{reset:N,state:j}=e((()=>({amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:!1,isEnabled:!1,orderIdCreated:null,remainingBalance:null,useFullBalance:!0}))),P=()=>{N()},E=e=>{p("Store credit balance from session","info",e),j.availableBalance=e},D=async()=>{var e,t;const{errors:o,json:n}=await T();if(o.length||!n)return void y("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;E(r)},L=async()=>{var e;const t=n.checkoutSessionId;if(!t){const e="No checkout session found";return y(e),j.error=e,{error:e,success:!1}}p("Applying store credit","info",{checkoutSessionId:t}),j.isApplying=!0,j.error=null;try{const{errors:o,json:n}=await h("/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 y(t),j.error=t,j.isApplying=!1,{error:t,success:!1}}return j.appliedAmount=n.amountApplied,j.remainingBalance=n.remainingBalance,j.isApplying=!1,p("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 y(t),j.error=t,j.isApplying=!1,{error:t,success:!1}}},x=e=>{j.isEnabled=e,j.error=null,e||(j.amountToApply=null)},R=e=>{if(null===e)return j.amountToApply=null,void(j.error=null);e<=0?j.error="Amount must be greater than zero":null!==j.availableBalance&&e>j.availableBalance?j.error="Amount exceeds available balance":e>We.total+(We.storeCredit||0)?j.error="Amount exceeds order total":(j.error=null,j.amountToApply=e)},_=e=>{if(j.useFullBalance=e,j.error=null,e&&null!==j.availableBalance){const e=Math.min(j.availableBalance,We.total+(We.storeCredit||0));j.amountToApply=e}else e||(j.amountToApply=null)},U=()=>j.isEnabled&&null!==j.availableBalance?j.useFullBalance?Math.min(j.availableBalance,We.total+(We.storeCredit||0)):j.amountToApply||0:0,z=()=>null!==j.amountToApply&&j.amountToApply>0&&We.storeCredit>0&&We.total<=0,B=async()=>{var e,t,o;const r=n.checkoutSessionId;if(!r){const e="No checkout session found";return y(e),j.error=e,{error:e,orderId:null,success:!1}}p("Creating store credit order","info",{checkoutSessionId:r});try{const{errors:n,json:s}=await h("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:r},method:"POST"});if(n.length>0||!s){const t=(null===(e=n[0])||void 0===e?void 0:e.message)||"Failed to create store credit order";return y(t),j.error=t,{error:t,orderId:null,success:!1}}const i=(null===(o=null===(t=s.checkoutSessionStoreCreditOrderCreate)||void 0===t?void 0:t.order)||void 0===o?void 0:o.id)||null;return j.orderIdCreated=i,p("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 y(t),j.error=t,{error:t,orderId:null,success:!1}}},F=["termsAndConditions","privacyPolicy","refundPolicy","shippingPolicy","warrantyPolicy"],q={privacyPolicy:"Privacy policy",refundPolicy:"Refund policy",shippingPolicy:"Shipping policy",termsAndConditions:"Terms and conditions",warrantyPolicy:"Warranty policy"},{reset:J,state:M}=e({accepted:!1,acceptedAt:null,locked:!1,showError:!1}),W=()=>{const e=t.checkoutSettings.merchantPolicyLinks;return e?F.reduce(((t,o)=>{var n,s;const i=null===(s=null===(n=e[o])||void 0===n?void 0:n.link)||void 0===s?void 0:s.trim();return i&&/^https?:\/\//i.test(i)?(t.push({key:o,name:r(q[o]),url:i}),t):t}),[]):[]},$=()=>W().length>0,Y=({companyName:e,countryCode:t,shouldRequirePeruTaxId:o,taxIdType:n})=>{var r;const s=c({countryCode:t,shouldRequirePeruTaxId:o}),i=null!==(r=null==s?void 0:s.find((e=>e.value===n)))&&void 0!==r?r:null,a=(({companyName:e,countryCode:t,shouldRequirePeruTaxId:o})=>!!l({countryCode:t,shouldRequirePeruTaxId:o})||(u.includes(t)?e.trim().length>0:m(t)))({companyName:e,countryCode:t,shouldRequirePeruTaxId:o});return{rendered:a,selectedType:i,send:a&&(!s||!!i),typeOptions:s}},H=e=>{const{selectedType:t,send:n}=Y({companyName:le.companyName,countryCode:e,shouldRequirePeruTaxId:o(),taxIdType:le.taxIdType});return n?Object.assign({taxId:le.taxId},t?{taxIdType:t.value}:{}):null},K=({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()||""}},G=e=>{const t=H(e);return t?Object.assign({shipToTaxId:t.taxId},t.taxIdType?{shipToTaxIdType:t.taxIdType}:{}):{}},V=({currentAddress:e,translatedAddress:t})=>{var o,n,r,s,i,a;const{city:d,country:l,line1:c,line2:u,postal_code:m,state:p}=e.value.address,v=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[v])||v,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[p])||p}},Z=e=>{var t;const o="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),r=le.stripeLinkEventData,i=le.stripeAddressEventData,a=le.stripeShippingSameAsBilling?le.stripeAddressEventData:le.stripeBillingAddressEventData;if(!i||!a)throw new Error("Missing stripe address data");const d=V({currentAddress:i,translatedAddress:le.translatedAddress.address}),{firstName:l,lastName:c}=K({name:d.name}),u=V({currentAddress:a,translatedAddress:le.translatedAddress.address}),{firstName:m,lastName:p}=K({name:u.name}),v=s()||"US",h=G(d.country);return Object.assign(Object.assign({billingAddress:{addressLine1:u.line1,addressLine2:u.line2||"",city:u.city,country:u.country,postalCode:u.postal_code,state:u.state},billingContact:{firstName:m,lastName:p,phone:u.phone},cartCurrencyCode:null===(t=We.items[0])||void 0===t?void 0:t.currencyCode,cartId:e,checkoutSessionCountry:v,checkoutSessionId:n.checkoutSessionId||"",contact:{companyName:le.companyName,email:null==r?void 0:r.value.email,firstName:l,lastName:c,phone:d.phone},isTest:!!o,landedCostAdjustments:We.promoCode?[{amount:0,productId:null,promoCode:We.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:le.shortAddressCode},h),{shippingAddress:{addressLine1:d.line1,addressLine2:d.line2,city:d.city,country:d.country,postalCode:d.postal_code,state:d.state}})},X=()=>{const e="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),t=le.stripeLinkEventData,o=le.stripeAddressEventData,r=le.stripeShippingSameAsBilling?le.stripeAddressEventData:le.stripeBillingAddressEventData;if(p({stripeAddressData:o,stripeBillingAddressData:r},"info"),!o||!r)throw new Error("Missing stripe address data");const s=V({currentAddress:o,translatedAddress:le.translatedAddress.address}),{firstName:i,lastName:a}=K({name:s.name}),d=V({currentAddress:r,translatedAddress:le.translatedAddress.address}),{firstName:l,lastName:c}=K({name:d.name}),u=We.adjustments.map((e=>({amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}))),m=We.promoCode?[{amount:0,productId:null,promoCode:We.promoCode,sku:null,type:"PROMO_CODE"},...u]:u,v=G(s.country);return Object.assign(Object.assign({billingAddress:{addressLine1:d.line1,addressLine2:d.line2||"",city:d.city,country:d.country,postalCode:d.postal_code,state:d.state},billingContact:{firstName:l,lastName:c,phone:d.phone},checkoutSessionId:n.checkoutSessionId||"",contact:{companyName:le.companyName,email:null==t?void 0:t.value.email,firstName:i,lastName:a,phone:s.phone},isTest:e,items:We.items,landedCostAdjustments:m,shipToShortAddressCode:le.shortAddressCode},v),{shippingAddress:{addressLine1:s.line1,addressLine2:s.line2,city:s.city,country:s.country,postalCode:s.postal_code,state:s.state}})};const Q=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=X(),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:f.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 h("/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 h("/api/zonos-elements/calculate-landed-cost",{body:X(),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 h("/api/zonos-elements/cart-calculate-landed-cost",{body:Z(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})},ee=async({checkoutSessionId:e,eventName:o,metadata:n})=>{var r,s;const a=Date.now(),d=[...window.Zonos.trackEventLogs];window.Zonos.trackEventLogs.push({checkoutSessionId:e,eventCreated:a,eventName:o});const l=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!(null===(r=window.Zonos)||void 0===r?void 0:r.zonosQaUrl)||!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug);if((w()||g()||l)&&!window.Zonos.zonosConversionTest)return;const c=i.selectedCountryCode,u=t.organizationId;if(!e)return void b({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No checkout session id found`],metadata:{allLogs:v,checkoutSessionId:e,eventName:o,metadata:n,organizationId:u,trackEventLogs:d}});u||b({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No organization id found`],metadata:{allLogs:v,checkoutSessionId:e,eventName:o,metadata:n,organizationId:u,trackEventLogs:d}});const m={checkoutSessionId:e,countryCode:c,eventCreated:a,eventName:o,metadata:Object.assign(Object.assign({},n),{trackEventLogs:d}),organizationId:u};await h("/api/zonos-elements/track-conversion-event",{body:m,method:"POST"})},te=({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},oe=e=>e.sort(((e,t)=>e.amount-t.amount)),ne=async()=>{var e,t;const{errors:o,json:n}=await T();return o.length||!n?(y("Failed to retrieve checkout session info before confirming payment ",o),b({endpoint:"validateCheckoutSession",errors:o.map((e=>e.message)),metadata:{allLogs:v}}),{errorMessage:r("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:!1}):(null===(e=n.checkoutSession.order)||void 0===e?void 0:e.id)&&!n.checkoutSession.completedAt||(null===(t=n.checkoutSession.landedCost)||void 0===t?void 0:t.id)?{errorMessage:"",valid:!0}:(y("Landed cost is not found in the checkout session before confirming payment."),b({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:v}}),{errorMessage:r('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:!1})},re=({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},se=({borderStyle:e,theme:t})=>"DARK"===t?{borderRadius:k({overrideBorderStyle:e}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"}:{borderRadius:k({overrideBorderStyle:e}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"},ie={Airwallex:"AIRWALLEX",Paypal:"PAYPAL",Stripe:"STRIPE"},{onChange:ae,reset:de,state:le}=e((()=>({checkoutSettlementCurrency:"USD",clientSecret:C("session","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:"",taxIdType:"",taxIdTypeUsedWhenAsyncAddressUpdate:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}))),ce="zonos--bc-domestic-session-redirected",ue=()=>{O("session",ce)},me=()=>"1"===C("session",ce),pe=()=>{S("session",ce,"1")},ve=()=>{O("session","zonos--bigcommerce-domestic-checkout-shipping"),ue()},he=e=>{ue(),S("session","zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))},ye=()=>{const e=C("session","zonos--bigcommerce-domestic-checkout-shipping");return A(e)},fe=async e=>{var o,n;const r=le.clientSecret;if(!le.stripe)return void p("Skip. Stripe is not initialized");const s=(({clientSecret:e,overrideBorderRadius:o,overridePrimaryColor:n,overrideSecondaryColor:r,overrideTheme:s,paypalEnabled:a})=>{const d=n||t.appearance.colorPrimary,l=r||t.appearance.colorSecondary,c=(window.Zonos.isCollect||window.Zonos.isInvoice?"DARK"===t.appearance.theme:d&&I(d))?"night":"flat",u="DARK"===s?"night":"flat",m=a?["external_paypal"]:[],p=(null==e?void 0:e.includes("_secret_"))?e:void 0;return{appearance:{labels:"floating",rules:Object.assign({},re({theme:s||"LIGHT"})),theme:s?u:c,variables:Object.assign(Object.assign({},se({borderStyle:o,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:p,customerSessionClientSecret:le.stripeCustomerSessionClientSecret||void 0,externalPaymentMethodTypes:[...m],locale:i.selectedLocale}})({clientSecret:r,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(s)===JSON.stringify(le.stripeElementsOptions);if(!le.stripeElements||!le.stripeElementsForBillingAddress)return le.stripeElementsForBillingAddress=null===(o=le.stripe)||void 0===o?void 0:o.elements(s),p("Stripe elements for billing address initialized"),le.stripeElements=null===(n=le.stripe)||void 0===n?void 0:n.elements(s),le.stripeElementsOptions=s,void p("Stripe elements initialized");a||(le.stripeElements.update(s),le.stripeElementsForBillingAddress.update(s),le.stripeElementsOptions=s,le.stripeElements.fetchUpdates()),p("Stripe elements updated")},we=()=>{O("session","zonos--client-secret"),de(),le.stripe=window.Zonos.stripe},ge=({address:e,firstName:t,lastName:o,name:r,phone:s})=>{const{firstName:i,lastName:a}=K({firstName:t,lastName:o,name:r});return i&&a||b({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId,firstName:t,lastName:o,name:r}}),s||b({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:n.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}},be=async()=>{var e,t,o,r,s;if(!(null===(e=le.stripeAddressEventData)||void 0===e?void 0:e.complete)||!le.stripeShippingSameAsBilling&&!(null===(t=le.stripeBillingAddressEventData)||void 0===t?void 0:t.complete)||!le.stripeBillingAddressEventData)return{partiesCreated:!1};if(!We.landedCostData)return{partiesCreated:!1};const i=null===(o=We.landedCostData.find(Boolean))||void 0===o?void 0:o.landedCost.rootId;if(!i)return b({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId}}),{partiesCreated:!1};const a=(()=>{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(le.partyShippingId!==d||le.partyBillingId!==l)return!0;const c=JSON.stringify(null===(o=le.stripeLinkUsedWhenFetchingLC)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=le.stripeLinkEventData)||void 0===n?void 0:n.value),u=JSON.stringify(null===(r=le.stripeAddressUsedWhenAsyncAddressUpdate)||void 0===r?void 0:r.value)!==JSON.stringify(null===(s=le.stripeAddressEventData)||void 0===s?void 0:s.value),m=!le.stripeShippingSameAsBilling&&JSON.stringify(null===(i=le.stripeBillingAddressUsedWhenAsyncAddressUpdate)||void 0===i?void 0:i.value)!==JSON.stringify(null===(a=le.stripeBillingAddressEventData)||void 0===a?void 0:a.value);return c||u||m||le.taxIdUsedWhenAsyncAddressUpdate!==le.taxId||le.taxIdTypeUsedWhenAsyncAddressUpdate!==le.taxIdType||le.companyNameUsedWhenAsyncAddressUpdate!==le.companyName})();if(!a)return{partiesCreated:!1};const d=ge({address:le.stripeAddressEventData.value.address,firstName:le.stripeAddressEventData.value.firstName,lastName:le.stripeAddressEventData.value.lastName,name:le.stripeAddressEventData.value.name,phone:le.stripeAddressEventData.value.phone}),l=le.stripeShippingSameAsBilling?d:ge({address:le.stripeBillingAddressEventData.value.address,firstName:le.stripeBillingAddressEventData.value.firstName,lastName:le.stripeBillingAddressEventData.value.lastName,name:le.stripeBillingAddressEventData.value.name,phone:le.stripeBillingAddressEventData.value.phone}),c="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),u=H(d.country),{errors:m,json:p}=await h("/api/zonos-elements/create-parties",{body:Object.assign({address:d,billingAddress:l,companyName:le.companyName,email:(null===(r=le.stripeLinkEventData)||void 0===r?void 0:r.value.email)||"",isTest:c,rootId:i,shortAddressCode:le.shortAddressCode,taxId:null!==(s=null==u?void 0:u.taxId)&&void 0!==s?s:""},(null==u?void 0:u.taxIdType)?{taxIdType:u.taxIdType}:{}),method:"POST"});return m.length||!p?(y("Error occurs when creating parties",JSON.stringify(m,null,2)),b({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId,errors:m,json:p}}),{partiesCreated:!1}):(le.companyNameUsedWhenAsyncAddressUpdate=le.companyName,le.stripeAddressUsedWhenAsyncAddressUpdate=le.stripeAddressEventData,le.stripeBillingAddressUsedWhenAsyncAddressUpdate=le.stripeBillingAddressEventData,le.taxIdTypeUsedWhenAsyncAddressUpdate=le.taxIdType,le.taxIdUsedWhenAsyncAddressUpdate=le.taxId,le.partyBillingId=p.billToPartyId,le.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})},Ce=e=>({countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}),Se=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)},Oe=async e=>{var t,o,r,s;const i=(null==e?void 0:e.retries)||0,a=!!(null==e?void 0:e.applyingPromocode),d=(()=>{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=le.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=le.stripeLinkEventData)||void 0===t?void 0:t.value),n=le.stripeAddressEventData&&JSON.stringify(Ce(le.stripeAddressEventData.value))!==JSON.stringify(le.stripeAddressUsedWhenFetchingLC),r=!le.stripeShippingSameAsBilling&&le.stripeBillingAddressEventData&&JSON.stringify(Ce(le.stripeBillingAddressEventData.value))!==JSON.stringify(le.stripeBillingAddressUsedWhenFetchingLC);return o||n||r})();return p("isPrefetchInfoOutdated","info",{isAddressOutdated:o}),!We.landedCostData&&!le.isFetchingLandedCost||o||t})(),l=(()=>{var e,t,o,n;const r=!!(null===(e=le.stripeLinkEventData)||void 0===e?void 0:e.complete),s=!!(null===(t=le.stripeAddressEventData)||void 0===t?void 0:t.complete),i=le.stripeShippingSameAsBilling?s:!!(null===(o=le.stripeBillingAddressEventData)||void 0===o?void 0:o.complete),a=(null===(n=le.stripeAddressEventData)||void 0===n?void 0:n.value.address.country)||"US",d=Se(a);return!!(s&&i&&r)||(d&&le.stripeAddressEventData?r&&le.stripeAddressEventData.value.firstName&&le.stripeAddressEventData.value.lastName&&le.stripeAddressEventData.value.address.line1.length>0&&(!d.stateRequired||d.stateRequired&&le.stripeAddressEventData.value.address.state.length>0)&&(!d.zipRequired||d.zipRequired&&le.stripeAddressEventData.value.address.postal_code.length>=3)&&le.stripeAddressEventData.value.phone&&le.stripeAddressEventData.value.phone.length>0:s&&i&&r)})();if(!l)return{isRequestNotReady:!0};if(d&&(null===(t=le.fetchingLandedCostAbortController)||void 0===t||t.abort(),le.fetchingLandedCostAbortController=null),!d&&!a)return{isRequestNotReady:!1};i?(le.isFetchingLandedCost=!1,setTimeout((()=>{le.isFetchingLandedCost=!0}),300)):le.isFetchingLandedCost=!0,le.stripeAddressEventData&&(le.stripeAddressUsedWhenFetchingLC={countryCode:le.stripeAddressEventData.value.address.country,postalCode:le.stripeAddressEventData.value.address.postal_code,state:le.stripeAddressEventData.value.address.state}),le.stripeBillingAddressEventData&&(le.stripeBillingAddressUsedWhenFetchingLC={countryCode:le.stripeBillingAddressEventData.value.address.country,postalCode:le.stripeBillingAddressEventData.value.address.postal_code,state:le.stripeBillingAddressEventData.value.address.state}),le.stripeLinkEventData&&(le.stripeLinkUsedWhenFetchingLC=Object.assign({},le.stripeLinkEventData));try{at(),await(async()=>{var e;const t=new AbortController;le.fetchingLandedCostAbortController=t,at();const{checkoutSessionWorkflow:o,errors:r,itemCreateWorkflow:s,landedCostCalculateWorkflow:i,partyCreateWorkflow:a,shipmentRatingCalculateWorkflow:d}=await Q(t);We.customQuotingError=(null===(e=null==r?void 0:r.find((e=>{var t,o;return"CUSTOM"===(null===(t=e.extensions)||void 0===t?void 0:t.ruleMessageType)||"COUNTRY_CONSTRAINT"===(null===(o=e.extensions)||void 0===o?void 0:o.source)})))||void 0===e?void 0:e.message)||null,We.shippingData=oe((null==d?void 0:d.filter(Boolean))||[]),Ke(s),le.fetchingLandedCostAbortController=null,We.partiesData=(null==a?void 0:a.filter(Boolean))||[],We.landedCostData=(null==o?void 0:o.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==o?void 0:o.length)&&ee({checkoutSessionId:n.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||S("session","zonos--promo-code",We.promoCode)})();const e=null===(o=We.shippingData)||void 0===o?void 0:o.find(Boolean),t=null===(r=We.landedCostData)||void 0===r?void 0:r.find((t=>t.landedCost.shipmentRating.id===(null==e?void 0:e.id))),s=t?t.subtotals:null;s&&Xe({method:(null==t?void 0:t.landedCost.method)||"DDP",subtotals:s})}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(i<1)return await Oe(Object.assign(Object.assign({},e),{retries:(i||0)+1})),{isRequestNotReady:!1};const o=null===(s=le.stripeAddressEventData)||void 0===s?void 0:s.value;b({endpoint:`Failed to fetch landed cost (${i} retries)`,errors:[t.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:o}})}y(t)}return le.isFetchingLandedCost=!1,{isRequestNotReady:!1}},Ae=async()=>{var e,t;await Oe({applyingPromocode:!0}),"payment"===We.step&<(),await be();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 rt({applySubtotalsOnly:!1,landedCostId:n.landedCostId,selectedShippingOption:o})},Ie=()=>{We.promoCode="",O("session","zonos--promo-code"),We.promoCodeError=!1,We.promoCodeApplied=!1},ke=async()=>{"payment"===We.step&<(),Ie(),await Ae()},Te=e=>{let t=[],o=!0;const n=window.Zonos.isCollect,s=window.Zonos.isInvoice;switch(e){case"succeeded":t=[r("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."),"",r("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||s)&&(t=[r("Thank you for submitting your payment. We appreciate your prompt attention."),"",r("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=[r("Payment processing. We'll update you when payment is received.")],o=!1;break;case"requires_payment_method":t=[r("Payment failed. Please try another payment method.")],n&&(t=[r("Payment failed. Please reload the page and try another payment method.")]);break;case"requires_action":o=!1,t=[r("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")];default:t=[r("Something went wrong.")]}return{isError:o,messages:t}},Ne=async()=>{var e,o;const{onInventoryCheck:n}=t.checkoutSettings,s=!!(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&&s){const{errors:e,json:t}=await h("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"});return e.length||!t?(y("Error occurs when handling inventory refund","warn",JSON.stringify(e)),null):t.available&&204!==t.status?t.available||200===t.status?(le.shouldInventoryRefund=!0,null):null:r("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:r,zonosApiRoute:f.vercel})}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw b({endpoint:"onInventoryCheck",errors:[`cartId: ${window.Zonos.cartId} - ${t}`],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:We.items}}),e}},je=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 h("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})},Pe=async({clientSecret:e,storybookForceStatus:t})=>{if(t){const{isError:e,messages:o}=Te(t);return{error:e,messages:o}}const o=e||le.clientSecret;if(!le.stripe||!o)return y("Failed to retrieve payment intent. Stripe is not initialized"),{error:!0,message:[r("Something went wrong.")]};if(!o.includes("_secret_"))return{error:!0,messages:[r("Something went wrong.")]};const{paymentIntent:n}=await le.stripe.retrievePaymentIntent(o),s=null==n?void 0:n.status,{isError:i,messages:a}=Te(s);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:s}},Ee=async e=>{var t,o;const s=!!(null===(t=le.stripePaymentEventData)||void 0===t?void 0:t.complete),i=le.stripeElements,a=le.stripe,d=le.clientSecret;if(le.customErrorMessage=null,!(null===(o=We.selectedLandedCost)||void 0===o?void 0:o.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 l=await ne();if(!l.valid)throw le.customErrorMessage=l.errorMessage,new Error(l.errorMessage);const c=n.checkoutSessionId;if(a&&i&&s&&d&&c){const e=new URL(window.location.href);e.searchParams.set("payment_intent_client_secret",d),e.searchParams.set("zonosCheckoutSessionId",c),ee({checkoutSessionId:c,eventName:"checkout_paymentInfoCompleted"});const{error:t,paymentIntent:o}=await a.confirmPayment({confirmParams:{return_url:e.toString()},elements:i,redirect:"if_required"});if(p("Payment intent confirmed","info",{error:t,paymentIntent:o}),"requires_action"===(null==o?void 0:o.status))throw new Error(r("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(r("Payment failed. Please try another payment method."))}},De=()=>{const e=new URLSearchParams(window.location.search).get("paymentProcessor");return e&&(t=e,Object.values(ie).some((e=>e===t)))?e:void 0;var t},Le=()=>{var e;const t=We.items.reduce(((e,t)=>e+t.amount*t.quantity),0),o=n.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:i.selectedLocale}],paymentProcessor:De(),presentmentCountryCode:i.selectedCountryCode,skipPaymentIntent:le.skipPaymentIntent,varianceTestInput:o}},xe=async()=>{var e;if(!n.checkoutSessionId)return b({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:v,cartId:window.Zonos.cartId}}),void Ze({messages:[r("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:r("Error creating Checkout")});const{errors:t,json:o}=await h("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:n.checkoutSessionId},method:"POST"}),s=null===(e=null==o?void 0:o.checkoutSessionPaymentIntentCreate)||void 0===e?void 0:e.clientSecret;if(t.length||!s)return y("Error occurs when getting payment intent",JSON.stringify(t,null,2)),b({endpoint:"Error creating payment intent",errors:t.map((e=>e.message)),metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId,clientSecret:s}}),void Ze({messages:[r("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:r("Error creating Checkout")});tt(o.checkoutSessionPaymentIntentCreate)},Re=async()=>{var e,t;if(!i.targetCurrency)return y("Failed to create checkout session - missing localizationStore.targetCurrency"),!1;le.isFetchingSession=!0;const o=Le();p("Checkout session body","info",o);const{errors:n,json:r}=await h("/api/zonos-elements/create-checkout-session",{body:o,method:"POST"});if(le.isFetchingSession=!1,n.length||!r){const t=null===(e=n.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 y("Error occurred when creating checkout session",JSON.stringify(n,null,2)),!1}const s=r.checkoutSessionCreate;return tt(s),Xe({method:(null===(t=s.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:s.subtotals}),p("Exchange rate updated for cart items (checkout session create)","info",We.exchangeRate),p("done-init-checkout-session"),!0},_e=async()=>{const e=n.checkoutSessionId;if(!e)return y("Failed to update checkout session base currency"),!1;if("LOCAL"===t.checkoutSettings.allowedSettlementCurrencies)return p('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency'),!0;const{json:o}=await h("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:le.checkoutSettlementCurrency},method:"POST"}),r=null==o?void 0:o.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;return o&&r===le.checkoutSettlementCurrency?(p(`Updated checkout session to settlement currency "${r}".`),!0):(y("Failed to update checkout session base currency"),!1)},Ue=async({adjustmentsAmount:e,cartId:t,currency:o,id:r,itemsAmount:s,landedCostId:a,presentmentCountryCode:d,storeCreditApplication:l})=>{const c=n.enabledVariantTestKeys||[],{errors:u,json:m}=await h("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:e,billToPartyId:le.partyBillingId,cartId:t,currency:o,customerAuthenticationToken:We.customerAuthenticationToken||void 0,id:r,itemsAmount:s,landedCostId:a,metadata:[{key:"language",value:i.selectedLocale}],presentmentCountryCode:d,shipToPartyId:le.partyShippingId,skipPaymentIntent:le.skipPaymentIntent,storeCreditApplication:l,varianceTestInput:c},method:"POST"});return u.length||!m?(y("Error occurs when updating checkout session",JSON.stringify(u,null,2)),{errors:u,json:m}):{errors:[],json:m}},ze=async()=>{const e=(()=>{if(!M.accepted)return null;const e=W();return e.length?{key:"merchantPolicyConsent",value:JSON.stringify({acceptedAt:M.acceptedAt||(new Date).toISOString(),locale:i.selectedLocale,policies:e.reduce(((e,t)=>(e[t.key]=t.url,e)),{})})}:null})();if(!e)return{errors:[]};if(!n.checkoutSessionId)return{errors:[]};const{errors:t}=await h("/api/zonos-elements/update-checkout-session-metadata",{body:{id:n.checkoutSessionId,metadata:[e]},method:"POST"});return t.length?(y("Failed to record merchant policy consent on checkout session",JSON.stringify(t,null,2)),{errors:t.map((e=>e.message||"Unknown error"))}):{errors:[]}},Be=({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},Fe=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}=K({firstName:i.firstName,lastName:i.lastName,name:i.name}),c=`${d} ${l}`,{firstName:u,lastName:m}=K({firstName:null==a?void 0:a.firstName,lastName:null==a?void 0:a.lastName,name:(null==a?void 0:a.name)||""}),p=u&&m?`${u} ${m}`:"",v=i.address,h=null==a?void 0:a.address;return{address:te({address:Object.assign(Object.assign({},v),{name:c}),invalidAdddressList:e}),billingAddress:r?void 0:te({address:h?Object.assign(Object.assign({},h),{name:p}):null,invalidAdddressList:t}),destinationCountry:v.country}})({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:le.stripeAddressEventData,stripeBillingAddressEventData:le.stripeBillingAddressEventData,stripeShippingSameAsBilling:le.stripeShippingSameAsBilling});if(!i)return void(le.translatedAddress={address:{},billingAddress:{}});const a=(()=>{var e,t,o,n;const r=JSON.stringify(null===(e=le.stripeAddressUsedWhenValidatingAddress)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=le.stripeAddressEventData)||void 0===t?void 0:t.value),s=!le.stripeShippingSameAsBilling&&JSON.stringify(null===(o=le.stripeBillingAddressEventData)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=le.stripeBillingAddressUsedWhenValidatingAddress)||void 0===n?void 0:n.value);return r||s})();if(!a)return;const{errors:d,json:l}=await h("/api/zonos-elements/validate-address",{body:i,method:"POST"});if(d.length||!l)return y("Error occurs when translating address to latin",JSON.stringify(d,null,2)),void(le.translatedAddress={address:{},billingAddress:{}});le.stripeAddressUsedWhenValidatingAddress=le.stripeAddressEventData,le.stripeBillingAddressUsedWhenValidatingAddress=le.stripeBillingAddressEventData;const c=null===(o=le.stripeAddressEventData)||void 0===o?void 0:o.value.address,u=null===(n=le.stripeBillingAddressEventData)||void 0===n?void 0:n.value.address;le.translatedAddress={address:c?Be({currentAddress:Object.assign(Object.assign({},c),{name:null===(r=le.stripeAddressEventData)||void 0===r?void 0:r.value.name}),translatedAddressResult:l.address||null}):{},billingAddress:le.stripeShippingSameAsBilling?{}:Be({currentAddress:Object.assign(Object.assign({},u),{name:null===(s=le.stripeBillingAddressEventData)||void 0===s?void 0:s.value.name}),translatedAddressResult:l.billingAddress||null})}};ae("clientSecret",(e=>{e&&le.stripe&&S("session","zonos--client-secret",e),e||O("session","zonos--client-secret")}));const qe=({deliveryType:e,landedCost:t,shipToCountry:o})=>"DAP"===t.method&&"POSTAL"===e&&t.remittance.length>0&&!!o&&u.includes(o),{onChange:Je,reset:Me,state:We}=e((()=>({addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:!1,checkoutTimeoutInterval:null,currency:"USD",customMessage:[],customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:!1,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:!1,isSelectedShippingGuarantee:!1,isStagingMode:g(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:C("session","zonos--promo-code")||"",promoCodeApplied:!!C("session","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}))),$e=e=>{switch(e){case"DAYS":return r("days");case"WEEKS":return r("weeks");default:return r("business days")}},Ye=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:$e(o.type)}:null},He=({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),Ke=e=>{p("Checking item restrictions");const t=e.map((e=>{if(!e.restriction)return null;const{restriction:t}=e,o=We.items.find((t=>He({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=>He({item1:t,item2:e})))}))),{cartItems:We.items,restrictedItems:t}};let Ge=null;const Ve=()=>{n.checkoutSessionId=null,Ge&&(clearTimeout(Ge),Ge=null),P(),Me()},Ze=({messages:e,title:t})=>{Ve(),we(),We.step="error",We.error={messages:e,title:t}},Xe=({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},Qe=()=>!!We.items.filter((e=>e.amount>0)).find((e=>!e.isRestricted)),et=()=>{var e,t;return!(!(null===(t=null===(e=We.checkoutSession)||void 0===e?void 0:e.order)||void 0===t?void 0:t.id)||We.checkoutSession.completedAt)},tt=e=>{var t,o,r,s,i,l,c;le.clientSecret=e.clientSecret,le.stripeCustomerSessionClientSecret=e.customerSessionClientSecret,le.customerProfile=e.customerProfile,We.checkoutSession=e,E(null!==(o=null===(t=e.customerProfile)||void 0===t?void 0:t.storeCreditBalance)&&void 0!==o?o:null),e.id||b({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:v,checkoutSession:e}}),e.id&&(n.checkoutSessionId=e.id);const u=a(e.varianceTestResults||[]);d(u);const m=(null===(i=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===i?void 0:i.value)||(null===(c=null===(l=window.Zonos.cartData)||void 0===l?void 0:l.metadata.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===c?void 0:c.value)||null;m&&(p(`Found externalConfirmationPageURL: ${m}`),We.externalConfirmationPageURL=m)},ot=async({adjustmentsAmount:e,cartId:t,currency:o,dutiesTaxesFeesEstimate:s,itemsAmount:a,landedCostId:d,shouldInitSessionOnFailure:l})=>{var c;if(d&&We.selectedLandedCost&&(Xe({dutiesTaxesFeesEstimate:s,method:We.landedCostMethod,subtotals:We.selectedLandedCost.subtotals}),p("Exchange rate updated for cart items (landed cost subtotal)","info",We.exchangeRate)),!n.checkoutSessionId)return p("Could not update cart total without checkout session id","info"),!1;const{errors:u,json:m}=await Ue({adjustmentsAmount:e,cartId:t,currency:o,id:n.checkoutSessionId,itemsAmount:a,landedCostId:d,presentmentCountryCode:i.selectedCountryCode});if(u.length>0||!m){if(y("Error occurs when updating checkout session."),l){p("Initiating checkout session on failure","info");const e=await Re();return p(`stripeStoreInitCheckoutSession: ${e}`),!!e||(Ze({messages:[r("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:r("Error creating Checkout")}),!1)}return!1}return d||(Xe({method:(null===(c=m.checkoutSessionUpdate.landedCost)||void 0===c?void 0:c.method)||"DDP",subtotals:m.checkoutSessionUpdate.subtotals}),p("Exchange rate updated for cart items (checkout session update)","info",We.exchangeRate)),tt(m.checkoutSessionUpdate),!0},nt=(e,o)=>{var n,r,s,i;return"DAP"===e.method&&(null===(r=null===(n=t.genericSettings)||void 0===n?void 0:n.domesticCountries)||void 0===r?void 0:r.includes((null===(s=le.stripeAddressEventData)||void 0===s?void 0:s.value.address.country)||"US"))?"DDP":qe({deliveryType:o,landedCost:e,shipToCountry:null===(i=le.stripeAddressEventData)||void 0===i?void 0:i.value.address.country})?"DAP":"DAP"===e.method&&e.remittance.length&&"ZONOS"===e.landedCostGuaranteeCode?"DDP":e.method},rt=async({applySubtotalsOnly:e,landedCostId:o,selectedShippingOption:n})=>{var r,s,i,a,d,l,c,u,m,v,h,y;p("Updating selected shipping option","info",{landedCostId:o,selectedShippingOption:n}),We.selectedShippingOption=n;const f=Ye(We.selectedShippingOption);if(f){const{maxTransit:e,minTransit:t,unit:o}=f;We.selectedShippingOptionTransitTime=`${t}-${e} ${o}`}else We.selectedShippingOptionTransitTime="";const w=null===(r=We.landedCostData)||void 0===r?void 0:r.find((e=>e.landedCostId===o));if(We.selectedLandedCost=w||null,!w)return!1;const g=((null===(s=w.landedCost.amountSubtotals)||void 0===s?void 0:s.landedCostTotal)||0)*w.subtotals.exchangeRate.rate;g&&p(`DAP quote, using estimate: ${g}`,"info"),We.landedCostMethod=nt(w.landedCost,null===(i=n.shippingProfile)||void 0===i?void 0:i.serviceLevel.deliveryType),We.shipping=w.subtotals.shipping;const b="ZONOS"===(null===(a=null==w?void 0:w.landedCost)||void 0===a?void 0:a.landedCostGuaranteeCode),C=!!(null===(l=null===(d=null==w?void 0:w.landedCost)||void 0===d?void 0:d.deMinimis)||void 0===l?void 0:l.find((e=>["DUTY","TAX"].includes(e.type)&&"ABOVE"===e.threshold)));We.isSelectedShippingAboveDeminimis=C,We.isSelectedShippingGuarantee=b;let S=!1;e?(Xe({dutiesTaxesFeesEstimate:g,method:We.landedCostMethod,subtotals:w.subtotals}),p("Exchange rate updated for cart items (landed cost subtotal)","info",We.exchangeRate),S=!0):S=await ot({adjustmentsAmount:We.adjustmentTotal,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:g,landedCostId:null===(c=w.landedCost)||void 0===c?void 0:c.id});const O=null===(u=We.items.find(Boolean))||void 0===u?void 0:u.currencyCode,A=(null===(m=le.stripeAddressEventData)||void 0===m?void 0:m.value.address.country)||"US";return le.shouldRenderPayInUsdButton="USD"===O&&"LOCAL_AND_USD"===t.checkoutSettings.allowedSettlementCurrencies&&"USD"!==(null===(v=We.checkoutSession)||void 0===v?void 0:v.subtotals.presentmentCurrencyCode)&&!!(null===(y=null===(h=t.genericSettings)||void 0===h?void 0:h.usdSettlementCountryEnabled)||void 0===y?void 0:y.includes(A)),S},st=({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;p(`==START CHECKOUT TIMEOUT - ${n}==`),We.checkoutTimeoutInterval=setTimeout((()=>{We.checkoutSessionTimeoutShow=!0}),n)},it=()=>{We.checkoutTimeoutInterval&&(clearTimeout(We.checkoutTimeoutInterval),We.checkoutTimeoutInterval=null)},at=()=>{We.items=We.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1}))),We.restrictedItems=[]},dt=async({adjustments:e,cartItems:t,landedCostId:o,shouldInitSessionOnFailure:n=!0})=>{var r;We.adjustments=e,We.items=t.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1})));const s=null===(r=t.find(Boolean))||void 0===r?void 0:r.currencyCode,i=t.reduce(((e,t)=>e+t.amount*t.quantity),0),a=e.reduce(((e,t)=>e+t.amount),0);s&&i&&(We.currency=s,le.isFetchingSession=!0,await ot({adjustmentsAmount:a,cartId:window.Zonos.cartId,currency:s,dutiesTaxesFeesEstimate:0,itemsAmount:i,landedCostId:o,shouldInitSessionOnFailure:n}),le.isFetchingSession=!1)},lt=()=>{"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})}))},ct=()=>{"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")},ut=()=>{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},mt=()=>{Ge&&clearTimeout(Ge),Ge=setTimeout((()=>{Ge=null,(async()=>{var e,t;if(!n.checkoutSessionId)return void p("Could not update store credit without checkout session id","info");const o=We.selectedLandedCost,r=We.currency||(null===(e=We.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",s=We.adjustments.reduce(((e,t)=>e+t.amount),0),a=We.items.reduce(((e,t)=>e+t.amount*t.quantity),0),{errors:d,json:l}=await Ue({adjustmentsAmount:s,cartId:window.Zonos.cartId,currency:r,id:n.checkoutSessionId,itemsAmount:a,landedCostId:null==o?void 0:o.landedCostId,presentmentCountryCode:i.selectedCountryCode,storeCreditApplication:j.isEnabled&&null!==j.amountToApply?j.useFullBalance?{mode:"FULL"}:{amount:j.amountToApply,mode:"PARTIAL"}:{mode:"NONE"}});d.length>0||!l?y("Error updating checkout session with store credit"):(Xe({method:(null===(t=l.checkoutSessionUpdate.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:l.checkoutSessionUpdate.subtotals}),tt(l.checkoutSessionUpdate))})()}),300)};export{rt as $,$ as A,_e as B,L as C,z as D,ne as E,B as F,Ee as G,je as H,M as I,we as J,Je as K,ae as L,U as M,Qe as N,qe as O,Ae as P,ke as Q,Ie as R,Te as S,j as T,P as U,ze as V,K as W,Y as X,Fe as Y,Se as Z,be as _,me as a,Ye as a0,nt as a1,oe as a2,ge as a3,W as a4,x as a5,_ as a6,mt as a7,R as a8,D as a9,ve as b,pe as c,he as d,le as e,Pe as f,T as g,We as h,fe as i,dt as j,Ve as k,ut as l,it as m,Re as n,xe as o,J as p,et as q,Ne as r,ye as s,st as t,ee as u,Le as v,Ze as w,tt as x,Oe as y,ct as z}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(n,e,r,o){function t(n){return n instanceof r?n:new r((function(e){e(n)}))}return new(r||(r=Promise))((function(r,i){function a(n){try{s(o.next(n))}catch(n){i(n)}}function u(n){try{s(o["throw"](n))}catch(n){i(n)}}function s(n){n.done?r(n.value):t(n.value).then(a,u)}s((o=o.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,t,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=u(0),a["throw"]=u(1),a["return"]=u(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(n){return function(e){return s([n,e])}}function s(u){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(r=0)),r)try{if(o=1,t&&(i=u[0]&2?t["return"]:u[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,u[1])).done)return i;if(t=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:r.label++;return{value:u[1],done:false};case 5:r.label++;t=u[1];u=[0];continue;case 7:u=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){r.label=u[1];break}if(u[0]===6&&r.label<i[1]){r.label=i[1];i=u;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(u);break}if(i[2])r.ops.pop();r.trys.pop();continue}u=e.call(n,r)}catch(n){u=[6,n];t=0}finally{o=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(n,e,r){if(r||arguments.length===2)for(var o=0,t=e.length,i;o<t;o++){if(i||!(o in e)){if(!i)i=Array.prototype.slice.call(e,0,o);i[o]=e[o]}}return n.concat(i||Array.prototype.slice.call(e))};System.register(["./p-BbgqQIHv.system.js"],(function(n){"use strict";var e;return{setters:[function(n){e=n.l}],execute:function(){var r=this;var o=["cloudflare","vercel"];var t=o[0];var i=n("f",{cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"});var a=i[t];
|
|
2
|
+
/**
|
|
3
|
+
* Next available fallback api type
|
|
4
|
+
*/var u=function(n){if(n===void 0){n=t}var e=o.indexOf(n);var r=o[e+1];if(!r){return null}return r};
|
|
5
|
+
/**
|
|
6
|
+
* This is the time in milliseconds after release time that we will start sending error logs to the new API
|
|
7
|
+
* @default 1 hour
|
|
8
|
+
*/var s=1*3600*1e3;// 1 hour
|
|
9
|
+
var c=function(){var n=new URL(window.location.href);n.searchParams.delete("payment_intent");n.searchParams.delete("payment_intent_client_secret");n.searchParams.delete("redirect_status");return n.toString()};var d=n("s",(function(n){return __awaiter(r,[n],void 0,(function(n){var r,o,t,d,l;var f=n.endpoint,v=n.errors,w=n.metadata,p=n.shouldPostReleaseErrorReporting;return __generator(this,(function(n){e("sendErrorLog","warn",f,w,v);if(p){r=Number(window.Zonos.releaseDate);o=(new Date).getTime();if(o-r>s){return[2/*return*/]}}t="userAgentData"in window.navigator?// userAgentData is not yet supported in all browsers
|
|
10
|
+
window.navigator.userAgentData:null;d={endpoint:f,errors:v,href:c(),metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:t&&t.brands.length>0?t:window.navigator.userAgent},w)};try{
|
|
11
|
+
// use native fetch because in handleFetch also calls sendErrorLog and it will possibly cause circular dependencies issue
|
|
12
|
+
void fetch("".concat(a,"/api/zonos-elements/log-error"),{body:JSON.stringify(d),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(n){l=u();if(!l){return[2/*return*/]}
|
|
13
|
+
// request to the fallback API if the first one fails
|
|
14
|
+
void fetch("".concat(i[l],"/api/zonos-elements/log-error"),{body:JSON.stringify(d),method:"POST"})}return[2/*return*/]}))}))}));var l=n("t",(function(n,e){if(typeof n==="string"&&n){return n}if(n instanceof Error&&n.message){return n.message}if(typeof n==="object"&&n!==null&&"message"in n&&typeof n.message==="string"&&n.message){return n.message}return e}));var f=n("l",(function(n){var r=[];for(var o=1;o<arguments.length;o++){r[o-1]=arguments[o]}e.apply(void 0,__spreadArray([n,"error"],r,false))}));var v=function(){if(!window.__zonosReportedBlockedStorage){window.__zonosReportedBlockedStorage=new Set}return window.__zonosReportedBlockedStorage};
|
|
15
|
+
/**
|
|
16
|
+
* Record a blocked storage read or write on the existing error log.
|
|
17
|
+
* A throw before `window.Zonos` exists is swallowed and does not use up
|
|
18
|
+
* the per-page dedupe slot, so the later startup read can still report it.
|
|
19
|
+
*/var w=function(n,e,r,o){if(typeof window.Zonos==="undefined"){return}var t="".concat(n,"\0").concat(e,"\0").concat(r);var i=v();if(i.has(t)){return}i.add(t);void d({endpoint:"storage://".concat(n,"/").concat(r),errors:[l(o,"SecurityError")],metadata:{area:n,key:r,operation:e,shape:"blocked-storage"}})};
|
|
20
|
+
/**
|
|
21
|
+
* Touch `window.localStorage` / `window.sessionStorage` inside the try.
|
|
22
|
+
* Safari throws SecurityError on the getter itself when storage is blocked.
|
|
23
|
+
* A missing storage object is the same failure: calling `getItem` on it
|
|
24
|
+
* would report a TypeError instead of blocked storage.
|
|
25
|
+
*/var p=function(n){var e=n==="local"?window.localStorage:window.sessionStorage;if(!e){throw new DOMException("","SecurityError")}return e};var h=n("c",(function(n,e){try{return p(n).getItem(e)}catch(r){w(n,"getItem",e,r);return null}}));var y=n("b",(function(n,e){try{p(n).removeItem(e)}catch(r){w(n,"removeItem",e,r)}}));var b=n("e",(function(n,e,r){try{p(n).setItem(e,r)}catch(r){w(n,"setItem",e,r)}}));var m=n("a",(function(){return window.location.search.includes("zonosStagingMode=1")}));var g=n("g",(function(){var n;return((n=window.Zonos.zonosApiKey)===null||n===void 0?void 0:n.includes("test"))||window.location.search.includes("zonosTestMode=1")}));var _=n("j",(function(n){if(typeof n==="string"){try{
|
|
26
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
27
|
+
var e=JSON.parse(n);return e}catch(n){return null}}return null}));var T=890;var j=n("i",(function(n){return n||window.innerWidth<T}));var k=function(){var n="connection"in window.navigator?// connection is not yet supported in all browsers
|
|
28
|
+
window.navigator.connection:null;var e="mozConnection"in window.navigator?// mozConnection is not yet supported in all browsers
|
|
29
|
+
window.navigator.mozConnection:null;var r="webkitConnection"in window.navigator?// webkitConnection is not yet supported in all browsers
|
|
30
|
+
window.navigator.webkitConnection:null;var o=n||e||r;return o};var O=n("d",(function(){var n="userAgentData"in window.navigator?// userAgentData is not yet supported in all browsers
|
|
31
|
+
window.navigator.userAgentData:null;var e=k();return{connectionDownlink:e===null||e===void 0?void 0:e.downlink,connectionEffectiveType:e===null||e===void 0?void 0:e.effectiveType,connectionRtt:e===null||e===void 0?void 0:e.rtt,connectionSaveData:e===null||e===void 0?void 0:e.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:n&&n.brands.length>0?n:window.navigator.userAgent}}));var z=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"];
|
|
32
|
+
/**
|
|
33
|
+
* Prepares the load time api log for the given API call to send to the server later
|
|
34
|
+
* This function is used to prepare the load time api log for the given API call.
|
|
35
|
+
* It adds the load time api log to the loadTimeApiInfoList.
|
|
36
|
+
*/var S=function(n){var e=n.apiPath,r=n.apiType,o=n.loadTimeInternal,t=n.loadTimeTotal;if(z.includes(e)){return}var i=t-o;
|
|
37
|
+
// No need to record if the browser API load time is negative (cached)
|
|
38
|
+
if(i<0){return}
|
|
39
|
+
// e.g. /api/zonos-elements/log-script-load?zonosDebug=1 -> /api/zonos-elements/log-script-load
|
|
40
|
+
var a=e.split("?")[0]||e;var u=O();var s=typeof u.userAgent==="object"&&u.userAgent.mobile;var c={apiType:r,connectionType:u.connectionEffectiveType,href:a,isHostedCheckout:window.Zonos.isLegacyCheckout,
|
|
41
|
+
// Use the isMobileAgent to determine if the checkout is mobile, if it's not availabe, use the logic from isCheckoutMobile
|
|
42
|
+
isMobile:j(s),loadTimeBrowserApi:i,loadTimeInternal:o,loadTimeTotal:t,metadata:Object.assign({},u),screenHeight:u.screenHeight,screenWidth:u.screenWidth,userAgent:typeof u.userAgent==="string"?u.userAgent:u.userAgent["brands"].map((function(n){return n.brand})).filter((function(n){return!/Not.*A.*Brand.*/.test(n)})).join(",")};window.Zonos.loadTimeApiInfoList.push(c)};var A=undefined&&undefined.__rest||function(n,e){var r={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)&&e.indexOf(o)<0)r[o]=n[o];if(n!=null&&typeof Object.getOwnPropertySymbols==="function")for(var t=0,o=Object.getOwnPropertySymbols(n);t<o.length;t++){if(e.indexOf(o[t])<0&&Object.prototype.propertyIsEnumerable.call(n,o[t]))r[o[t]]=n[o[t]]}return r};var E=function(n){return n===502||n===503||n===504};var M=function(n){return __awaiter(r,[n],void 0,(function(n){var e,r,o;var t=n.response,i=n.shouldLog,a=i===void 0?true:i,u=n.shouldThrow,s=u===void 0?false:u;return __generator(this,(function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4/*yield*/,t.text()];case 1:e=n.sent();r=_(e);if(!r){throw new Error("Failed to parse content: ".concat(e))}return[2/*return*/,r];case 2:o=n.sent();if(s){throw o}if(a){
|
|
43
|
+
// eslint-disable-next-line
|
|
44
|
+
console.error(o)}return[2/*return*/,null];case 3:return[2/*return*/]}}))}))};var P=function(n){try{
|
|
45
|
+
// encode the string, remove the "=" at the end of the encoded string
|
|
46
|
+
var e=btoa(n).replace(/=/g,"");return e}catch(e){
|
|
47
|
+
// return the reverse string if the encoding failed
|
|
48
|
+
return n.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}};var I=function(n){return __awaiter(r,[n],void 0,(function(n){var e,r,o,a,u,s,c,d,l,f,v,f,w,p,c,h,c;var y=n.basePathType,b=n.options,m=n.path;return __generator(this,(function(n){switch(n.label){case 0:r=window.Zonos.zonosQaUrlApi||i[y]||t;o=r+m;a=new URL(o);u=window.Zonos.cartId?"".concat(window.location.hostname,"-").concat(window.Zonos.cartId):window.location.hostname;a.searchParams.set("zToken",P(u));n.label=1;case 1:n.trys.push([1,3,,4]);return[4/*yield*/,fetch(a.toString(),b)];case 2:e=n.sent();return[3/*break*/,4];case 3:s=n.sent();if(s instanceof Error){return[2/*return*/,{baseUrl:r,errors:[{message:s.message,type:"unknown"}],json:null,response:null,zonosMode:null}]}c="Failed to fetch";return[2/*return*/,{baseUrl:r,errors:[{message:c,type:"unknown"}],json:null,response:null,zonosMode:null}];case 4:d=e.headers.get("Zonos-Mode");l=window.Zonos.zonosQaUrl;
|
|
49
|
+
// We only want to alert once if the user is in preview mode and it's also using production environment
|
|
50
|
+
if(!window.Zonos.modeAlerted&&d&&l){window.Zonos.modeAlerted=true}if(!e.ok)return[3/*break*/,6];return[4/*yield*/,M({response:e})];case 5:f=n.sent();return[2/*return*/,{baseUrl:r,errors:[],json:f,response:e,zonosMode:d}];case 6:v=e.status.toString();n.label=7;case 7:n.trys.push([7,9,,10]);return[4/*yield*/,M({response:e,shouldThrow:true})];case 8:f=n.sent();
|
|
51
|
+
// Parse and access "errors" from the response if possible
|
|
52
|
+
if(f&&"errors"in f&&Array.isArray(f.errors)){w=f.errors;p=w.map((function(n){if(typeof n==="string"){return{message:n,type:v}}return n}));return[2/*return*/,{baseUrl:r,errors:p,json:null,response:e,zonosMode:d}]}c=JSON.stringify(f);return[2/*return*/,{baseUrl:r,errors:[{message:c,type:v}],json:null,response:e,zonosMode:d}];case 9:h=n.sent();c="Unknown error";
|
|
53
|
+
// A gateway HTML or empty body still carries a status a GET can fail over
|
|
54
|
+
// on. Other non-JSON statuses, including 404 and 500, keep the previous
|
|
55
|
+
// null response so they do not fail over.
|
|
56
|
+
return[2/*return*/,{baseUrl:r,errors:[{message:"".concat(v,": ").concat(c),type:v}],json:null,response:E(e.status)?e:null,zonosMode:d}];case 10:return[2/*return*/]}}))}))};var U=function(n){return __awaiter(r,[n],void 0,(function(n){var r,o,t,a,s,c,l,f,v,w,p,h,y,b,m,g,T,j,k,O,z,M;var P=n.basePathType,Z=n.options,C=n.path;return __generator(this,(function(n){switch(n.label){case 0:a=C.startsWith("/api/bigcommerce");s=a?"vercel":P;c=performance.now();return[4/*yield*/,I({basePathType:s,options:Z,path:C})];case 1:l=n.sent(),f=l.errors,v=l.response,w=A(l,["errors","response"]);p=performance.now();h=p-c;
|
|
57
|
+
// Send the load time api log
|
|
58
|
+
e("".concat(C," (").concat(h.toFixed(2),"ms)"),"info");y=v===null||v===void 0?void 0:v.headers.get("Zonos-Duration");
|
|
59
|
+
// Only record if the response status is 200, some endpoint will return 200 with error
|
|
60
|
+
if((v===null||v===void 0?void 0:v.status)===200){S({apiPath:C,apiType:s,loadTimeInternal:y?Number(y):0,loadTimeTotal:h})}b=u(s);m=f.find((function(n){var e=n.type;return e==="unknown"}));g=f.find((function(n){var e=n.message;return typeof e==="string"&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted"))}));T=v===null||v===void 0?void 0:v.status;j=T!==undefined&&E(T);k=((r=Z===null||Z===void 0?void 0:Z.method)!==null&&r!==void 0?r:"GET").toUpperCase()==="GET";O=!!m||T===404||T===500;z=O||j;M=b&&(O||j&&k);
|
|
61
|
+
// Should log the error if it's unknown error
|
|
62
|
+
if(z&&!g){void d({endpoint:i[s]+C,errors:f.map((function(n){var e=n.message;return"API: ".concat(e)})),metadata:{currentBasePath:s,nextFallbackApiType:b,requestHeaders:Z===null||Z===void 0?void 0:Z.headers,requestPayload:_((o=Z===null||Z===void 0?void 0:Z.body)===null||o===void 0?void 0:o.toString())||((t=Z===null||Z===void 0?void 0:Z.body)===null||t===void 0?void 0:t.toString()),shouldCallFallback:M,status:v===null||v===void 0?void 0:v.status,statusText:v===null||v===void 0?void 0:v.statusText},
|
|
63
|
+
// When the error is unknown, error reporting should be enabled for period of time after release, so we can monitor the error.
|
|
64
|
+
shouldPostReleaseErrorReporting:true})}if(M){e('=== "'.concat(C,'" failed to fetch, trying next fallback ').concat(b));return[2/*return*/,U({basePathType:b,options:Z,path:C})]}
|
|
65
|
+
// No more fallbacks, just return the result
|
|
66
|
+
return[2/*return*/,Object.assign({errors:f,response:v},w)]}}))}))};
|
|
67
|
+
/**
|
|
68
|
+
* Fetch request and will request to fallback API when the first one fails
|
|
69
|
+
* @param path Path name of the request (e.g. /api/something/com).
|
|
70
|
+
* @param _opts fetch options
|
|
71
|
+
*/var Z=n("h",(function(n,e){return __awaiter(r,void 0,void 0,(function(){var r,o,i,a,u,s;return __generator(this,(function(c){r=A(e||{},[]);o=r.body?JSON.stringify(r.body):undefined;i=r.method||"GET";a=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":m()?"1":undefined,"Zonos-Test-Mode":g()?"1":undefined,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers);
|
|
72
|
+
// filter all underfined headers
|
|
73
|
+
Object.keys(a).forEach((function(n){return a[n]===undefined&&delete a[n]}));u=Object.assign(Object.assign({},r),{body:i==="GET"?undefined:o,headers:a,method:i});s=new URLSearchParams(window.location.search).get("useFallbackApi");return[2/*return*/,U({basePathType:s||t,options:u,path:n})]}))}))}))}}}));
|