@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,r,t,n){function i(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n["throw"](e))}catch(e){o(e)}}function u(e){e.done?t(e.value):i(e.value).then(a,s)}u((n=n.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(n)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(n=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1];o=s;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(s);break}if(o[2])t.ops.pop();t.trys.pop();continue}s=r.call(e,t)}catch(e){s=[6,e];i=0}finally{n=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{c as createStore,z as zonosStore}from"./zonosStore-BXP9FvIt.js";import{t as translate,l as localizationStore,s as storageStore}from"./localization-
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,r,t,n){function i(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n["throw"](e))}catch(e){o(e)}}function u(e){e.done?t(e.value):i(e.value).then(a,s)}u((n=n.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(n)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(n=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1];o=s;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(s);break}if(o[2])t.ops.pop();t.trys.pop();continue}s=r.call(e,t)}catch(e){s=[6,e];i=0}finally{n=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{c as createStore,z as zonosStore}from"./zonosStore-BXP9FvIt.js";import{t as translate,l as localizationStore,s as storageStore}from"./localization-B5CRzthT.js";import{l as logError$1,h as handleFetch,s as sendErrorLog}from"./handleFetch-BFVO7oAR.js";import{l as log,b as allLogs}from"./VarianceTest-BJmZPrZl.js";import{h as cartStore,$ as cartStoreUpdateSelectedShippingOption,e as stripeStore,a3 as stripeStoreBuildAddressForPartyCreate}from"./cart-b84n0nhi.js";
|
|
2
2
|
// src/constant/common.ts
|
|
3
3
|
function _array_like_to_array(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function asyncGeneratorStep(e,r,t,n,i,o,a){try{var s=e[o](a);var u=s.value}catch(e){t(e);return}if(s.done){r(u)}else{Promise.resolve(u).then(n,i)}}function _async_to_generator(e){return function(){var r=this,t=arguments;return new Promise((function(n,i){var o=e.apply(r,t);function a(e){asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(undefined)}))}}function _class_call_check(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _create_class(e,r,t){if(r)_defineProperties(e.prototype,r);return e}function _define_property(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function _instanceof(e,r){if(r!=null&&typeof Symbol!=="undefined"&&r[Symbol.hasInstance]){return!!r[Symbol.hasInstance](e)}else{return e instanceof r}}function _iterable_to_array(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function _iterable_to_array_limit(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var i=true;var o=false;var a,s;try{for(t=t.call(e);!(i=(a=t.next()).done);i=true){n.push(a.value);if(n.length===r)break}}catch(e){o=true;s=e}finally{try{if(!i&&t["return"]!=null)t["return"]()}finally{if(o)throw s}}return n}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var n=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))}n.forEach((function(r){_define_property(e,r,t[r])}))}return e}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}function _object_spread_props(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _sliced_to_array(e,r){return _array_with_holes(e)||_iterable_to_array_limit(e,r)||_unsupported_iterable_to_array(e,r)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,r){if(!e)return;if(typeof e==="string")return _array_like_to_array(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor)t=e.constructor.name;if(t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _array_like_to_array(e,r)}function _ts_generator(e,r){var t,n,i,o,a={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(r){return u([e,r])}}function u(o){if(t)throw new TypeError("Generator is already executing.");while(a)try{if(t=1,n&&(i=o[0]&2?n["return"]:o[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;if(n=0,i)o=[o[0]&2,i.value];switch(o[0]){case 0:case 1:i=o;break;case 4:a.label++;return{value:o[1],done:false};case 5:a.label++;n=o[1];o=[0];continue;case 7:o=a.ops.pop();a.trys.pop();continue;default:if(!(i=a.trys,i=i.length>0&&i[i.length-1])&&(o[0]===6||o[0]===2)){a=0;continue}if(o[0]===3&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(o[0]===6&&a.label<i[1]){a.label=i[1];i=o;break}if(i&&a.label<i[2]){a.label=i[2];a.ops.push(o);break}if(i[2])a.ops.pop();a.trys.pop();continue}o=r.call(e,a)}catch(e){o=[6,e];n=0}finally{t=i=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}}var Environment=function(e){e["production"]="prod";e["demo"]="demo";e["staging"]="staging";return e}(Environment||{});
|
|
4
4
|
// src/constant/config.ts
|
|
@@ -96,7 +96,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
96
96
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
97
97
|
PERFORMANCE OF THIS SOFTWARE.
|
|
98
98
|
***************************************************************************** */
|
|
99
|
-
/* global Reflect, Promise, SuppressedError, Symbol */var extendStatics=function(e,r){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t))e[t]=r[t]};return extendStatics(e,r)};function __extends(e,r){if(typeof r!=="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");extendStatics(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}var __assign=function(){__assign=Object.assign||function e(r){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))r[o]=t[o]}return r};return __assign.apply(this,arguments)};function __awaiter(e,r,t,n){function i(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(r,t){function o(e){try{s(n.next(e))}catch(e){t(e)}}function a(e){try{s(n["throw"](e))}catch(e){t(e)}}function s(e){e.done?r(e.value):i(e.value).then(o,a)}s((n=n.apply(e,[])).next())}))}function __generator(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(n)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(n=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1];o=s;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(s);break}if(o[2])t.ops.pop();t.trys.pop();continue}s=r.call(e,t)}catch(e){s=[6,e];i=0}finally{n=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}}function __spreadArray(e,r,t){for(var n=0,i=r.length,o;n<i;n++){if(o||!(n in r)){if(!o)o=Array.prototype.slice.call(r,0,n);o[n]=r[n]}}return e.concat(o||Array.prototype.slice.call(r))}typeof SuppressedError==="function"?SuppressedError:function(e,r,t){var n=new Error(t);return n.name="SuppressedError",n.error=e,n.suppressed=r,n};var version="1.35.
|
|
99
|
+
/* global Reflect, Promise, SuppressedError, Symbol */var extendStatics=function(e,r){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t))e[t]=r[t]};return extendStatics(e,r)};function __extends(e,r){if(typeof r!=="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");extendStatics(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}var __assign=function(){__assign=Object.assign||function e(r){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))r[o]=t[o]}return r};return __assign.apply(this,arguments)};function __awaiter(e,r,t,n){function i(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(r,t){function o(e){try{s(n.next(e))}catch(e){t(e)}}function a(e){try{s(n["throw"](e))}catch(e){t(e)}}function s(e){e.done?r(e.value):i(e.value).then(o,a)}s((n=n.apply(e,[])).next())}))}function __generator(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(n)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(n=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1];o=s;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(s);break}if(o[2])t.ops.pop();t.trys.pop();continue}s=r.call(e,t)}catch(e){s=[6,e];i=0}finally{n=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}}function __spreadArray(e,r,t){for(var n=0,i=r.length,o;n<i;n++){if(o||!(n in r)){if(!o)o=Array.prototype.slice.call(r,0,n);o[n]=r[n]}}return e.concat(o||Array.prototype.slice.call(r))}typeof SuppressedError==="function"?SuppressedError:function(e,r,t){var n=new Error(t);return n.name="SuppressedError",n.error=e,n.suppressed=r,n};var version="1.35.2";var packageJson={version:version};var airTrackerENV={dev:Environment.staging,staging:Environment.staging,demo:Environment.demo,prod:Environment.production};var initializeAirTracker=function(e,r){if(e===void 0){e=Environment.production}if(!window._AirwallexSDKs.airTracker){window._AirwallexSDKs.airTracker=new src_default({config:{appName:"components-sdk",appVersion:packageJson.version,env:airTrackerENV[e]||Environment.production}});window._AirwallexSDKs.airTracker.updateCommonData({clientId:r})}return window._AirwallexSDKs.airTracker};var maskPII=function(e){if(typeof e!=="object"){return e}try{var r=JSON.parse(JSON.stringify(e));Object.keys(r).forEach((function(e){if(typeof e==="string"&&["auth","code"].some((function(r){return e.includes(r)}))){r[e]="***"}}));return r}catch(r){return e}};var logError=function(e,r){var t,n;(n=(t=window._AirwallexSDKs)===null||t===void 0?void 0:t.airTracker)===null||n===void 0?void 0:n.error(e,__assign(__assign({},r),{context:"components-sdk"}))};var logWarning=function(e,r){var t;(t=window._AirwallexSDKs.airTracker)===null||t===void 0?void 0:t.warn(e,__assign(__assign({},r),{context:"components-sdk"}))};var logInfo=function(e,r){var t;(t=window._AirwallexSDKs.airTracker)===null||t===void 0?void 0:t.info(e,__assign(__assign({},r),{context:"components-sdk"}))};var LoadScriptError=/** @class */function(e){__extends(r,e);function r(r){var t=e.call(this,r)||this;t.code="LOAD_SCRIPT_ERROR";return t}return r}(Error);var _a,_b;var ENV;(function(e){e["dev"]="dev";e["staging"]="staging";e["demo"]="demo";e["prod"]="prod";e["sandbox"]="sandbox"})(ENV||(ENV={}));var PA_STATIC_HOST=(_a={},_a[ENV.dev]="https://checkout-staging.airwallex.com",_a[ENV.staging]="https://checkout-staging.airwallex.com",_a[ENV.demo]="https://checkout-demo.airwallex.com",_a[ENV.prod]="https://checkout.airwallex.com",_a[ENV.sandbox]="https://checkout.sandbox.airwallex.com",_a);var STATIC_HOST=(_b={},_b[ENV.dev]="https://static-staging.airwallex.com",_b[ENV.staging]="https://static-staging.airwallex.com",_b[ENV.demo]="https://static-demo.airwallex.com",_b[ENV.prod]="https://static.airwallex.com",_b[ENV.sandbox]="https://static.sandbox.airwallex.com",_b);var SDK_CONTROLLER="sdkController";var PAYMENTS="payments";var SDK_URL_MAPPING={kyc:"/widgets/kyc/sdk/v1/index.js",rfi:"/widgets/kycRfi/sdk/v1/index.js",paymentsKyb:"/widgets/paymentsKyb/sdk/v1/index.js",sdkController:"/widgets/sdk-controller/sdk/v1/index.js",payouts:"/widgets/payouts/sdk/v1/index.js",payments:"/assets/elements.bundle.min.js",sca:"/hosted-sca/sdk/v1/index.js",taxForm:"/widgets/taxForm/sdk/v1/index.js",billing:"/widgets/checkout/sdk/v1/index.js",balance:"/widgets/embedded-balance/sdk/v1/index.js"};var ELEMENT_TO_SDK={
|
|
100
100
|
// legacy
|
|
101
101
|
kyc:"kyc",paymentsKyb:"paymentsKyb",
|
|
102
102
|
// rfi elements
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{W as extractName}from"./cart-b84n0nhi.js";
|
|
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`).
|
|
@@ -14,7 +14,7 @@ import{U as extractName}from"./cart-DmJkjiDE.js";
|
|
|
14
14
|
*
|
|
15
15
|
* Pure: the caller resolves `countryField` (via `getCountryField`) and passes it in, so
|
|
16
16
|
* this can be unit-tested without the stores.
|
|
17
|
-
*/var getMissingRequiredShippingFields=function(i){var e=i.countryField,a=i.event;var r,t,
|
|
17
|
+
*/var getMissingRequiredShippingFields=function(i){var e=i.countryField,a=i.event;var r,t,n;if(!a){return[]}var v=a.value;var l=[];
|
|
18
18
|
// Last name is always required for international shipping. Link's single name input
|
|
19
19
|
// often provides only a first name, leaving the extracted last name empty.
|
|
20
|
-
var
|
|
20
|
+
var o=extractName({firstName:v.firstName,lastName:v.lastName,name:v.name}).lastName;if(!o.trim()){l.push({key:"lastName"})}if((e===null||e===void 0?void 0:e.stateRequired)&&!((r=v.address.state)===null||r===void 0?void 0:r.trim())){l.push({key:"state"})}if((e===null||e===void 0?void 0:e.zipRequired)&&((n=(t=v.address.postal_code)===null||t===void 0?void 0:t.trim().length)!==null&&n!==void 0?n:0)<MIN_POSTAL_CODE_LENGTH){l.push({key:"postal_code"})}return l};export{MIN_POSTAL_CODE_LENGTH as M,getMissingRequiredShippingFields as g};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,n,r,t){function o(e){return e instanceof r?e:new r((function(n){n(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{u(t.next(e))}catch(e){i(e)}}function s(e){try{u(t["throw"](e))}catch(e){i(e)}}function u(e){e.done?r(e.value):o(e.value).then(a,s)}u((t=t.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return u([e,n])}}function u(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(r=0)),r)try{if(t=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;o=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){r.label=s[1];break}if(s[0]===6&&r.label<i[1]){r.label=i[1];i=s;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(s);break}if(i[2])r.ops.pop();r.trys.pop();continue}s=n.call(e,r)}catch(e){s=[6,e];o=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,r){if(r||arguments.length===2)for(var t=0,o=n.length,i;t<o;t++){if(i||!(t in n)){if(!i)i=Array.prototype.slice.call(n,0,t);i[t]=n[t]}}return e.concat(i||Array.prototype.slice.call(n))};import{l as log}from"./VarianceTest-BJmZPrZl.js";var fallbackApiType=["cloudflare","vercel"];var MAIN_BASE_API_TYPE=fallbackApiType[0];var fallbackApiList={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"};var MAIN_BASE_API=fallbackApiList[MAIN_BASE_API_TYPE];
|
|
2
|
+
/**
|
|
3
|
+
* Next available fallback api type
|
|
4
|
+
*/var getNextFallbackApiType=function(e){if(e===void 0){e=MAIN_BASE_API_TYPE}var n=fallbackApiType.indexOf(e);var r=fallbackApiType[n+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 postReleaseReportingDuration=1*3600*1e3;// 1 hour
|
|
9
|
+
var loggedHref=function(){var e=new URL(window.location.href);e.searchParams.delete("payment_intent");e.searchParams.delete("payment_intent_client_secret");e.searchParams.delete("redirect_status");return e.toString()};var sendErrorLog=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,r,t,o,i;var a=e.endpoint,s=e.errors,u=e.metadata,d=e.shouldPostReleaseErrorReporting;return __generator(this,(function(e){log("sendErrorLog","warn",a,u,s);if(d){n=Number(window.Zonos.releaseDate);r=(new Date).getTime();if(r-n>postReleaseReportingDuration){return[2/*return*/]}}t="userAgentData"in window.navigator?// userAgentData is not yet supported in all browsers
|
|
10
|
+
window.navigator.userAgentData:null;o={endpoint:a,errors:s,href:loggedHref(),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},u)};try{
|
|
11
|
+
// use native fetch because in handleFetch also calls sendErrorLog and it will possibly cause circular dependencies issue
|
|
12
|
+
void fetch("".concat(MAIN_BASE_API,"/api/zonos-elements/log-error"),{body:JSON.stringify(o),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){i=getNextFallbackApiType();if(!i){return[2/*return*/]}
|
|
13
|
+
// request to the fallback API if the first one fails
|
|
14
|
+
void fetch("".concat(fallbackApiList[i],"/api/zonos-elements/log-error"),{body:JSON.stringify(o),method:"POST"})}return[2/*return*/]}))}))};var thrownMessage=function(e,n){if(typeof e==="string"&&e){return e}if(e instanceof Error&&e.message){return e.message}if(typeof e==="object"&&e!==null&&"message"in e&&typeof e.message==="string"&&e.message){return e.message}return n};var logError=function(e){var n=[];for(var r=1;r<arguments.length;r++){n[r-1]=arguments[r]}log.apply(void 0,__spreadArray([e,"error"],n,false))};var reportedIds=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 reportBlockedStorage=function(e,n,r,t){if(typeof window.Zonos==="undefined"){return}var o="".concat(e,"\0").concat(n,"\0").concat(r);var i=reportedIds();if(i.has(o)){return}i.add(o);void sendErrorLog({endpoint:"storage://".concat(e,"/").concat(r),errors:[thrownMessage(t,"SecurityError")],metadata:{area:e,key:r,operation:n,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 storageFor=function(e){var n=e==="local"?window.localStorage:window.sessionStorage;if(!n){throw new DOMException("","SecurityError")}return n};var safeGetItem=function(e,n){try{return storageFor(e).getItem(n)}catch(r){reportBlockedStorage(e,"getItem",n,r);return null}};var safeRemoveItem=function(e,n){try{storageFor(e).removeItem(n)}catch(r){reportBlockedStorage(e,"removeItem",n,r)}};var safeSetItem=function(e,n,r){try{storageFor(e).setItem(n,r)}catch(r){reportBlockedStorage(e,"setItem",n,r)}};var getIsStagingMode=function(){return window.location.search.includes("zonosStagingMode=1")};var getIsTestMode=function(){var e;return((e=window.Zonos.zonosApiKey)===null||e===void 0?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};var jsonParse=function(e){if(typeof e==="string"){try{
|
|
26
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
27
|
+
var n=JSON.parse(e);return n}catch(e){return null}}return null};var checkoutBreakpoint=890;var isCheckoutMobile=function(e){return e||window.innerWidth<checkoutBreakpoint};var getNavigatorConnection=function(){var e="connection"in window.navigator?// connection is not yet supported in all browsers
|
|
28
|
+
window.navigator.connection:null;var n="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 t=e||n||r;return t};var getAdditionalLogMetadata=function(){var e="userAgentData"in window.navigator?// userAgentData is not yet supported in all browsers
|
|
31
|
+
window.navigator.userAgentData:null;var n=getNavigatorConnection();return{connectionDownlink:n===null||n===void 0?void 0:n.downlink,connectionEffectiveType:n===null||n===void 0?void 0:n.effectiveType,connectionRtt:n===null||n===void 0?void 0:n.rtt,connectionSaveData:n===null||n===void 0?void 0:n.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}};var blackListPaths=["/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 prepLoadTimeApiLog=function(e){var n=e.apiPath,r=e.apiType,t=e.loadTimeInternal,o=e.loadTimeTotal;if(blackListPaths.includes(n)){return}var i=o-t;
|
|
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=n.split("?")[0]||n;var s=getAdditionalLogMetadata();var u=typeof s.userAgent==="object"&&s.userAgent.mobile;var d={apiType:r,connectionType:s.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:isCheckoutMobile(u),loadTimeBrowserApi:i,loadTimeInternal:t,loadTimeTotal:o,metadata:Object.assign({},s),screenHeight:s.screenHeight,screenWidth:s.screenWidth,userAgent:typeof s.userAgent==="string"?s.userAgent:s.userAgent["brands"].map((function(e){return e.brand})).filter((function(e){return!/Not.*A.*Brand.*/.test(e)})).join(",")};window.Zonos.loadTimeApiInfoList.push(d)};var __rest=undefined&&undefined.__rest||function(e,n){var r={};for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0)r[t]=e[t];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++){if(n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o]))r[t[o]]=e[t[o]]}return r};var isGatewayStatus=function(e){return e===502||e===503||e===504};var getResponseBody=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,r,t;var o=e.response,i=e.shouldLog,a=i===void 0?true:i,s=e.shouldThrow,u=s===void 0?false:s;return __generator(this,(function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4/*yield*/,o.text()];case 1:n=e.sent();r=jsonParse(n);if(!r){throw new Error("Failed to parse content: ".concat(n))}return[2/*return*/,r];case 2:t=e.sent();if(u){throw t}if(a){
|
|
43
|
+
// eslint-disable-next-line
|
|
44
|
+
console.error(t)}return[2/*return*/,null];case 3:return[2/*return*/]}}))}))};var encodeString=function(e){try{
|
|
45
|
+
// encode the string, remove the "=" at the end of the encoded string
|
|
46
|
+
var n=btoa(e).replace(/=/g,"");return n}catch(n){
|
|
47
|
+
// return the reverse string if the encoding failed
|
|
48
|
+
return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}};var handleRequest=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,r,t,o,i,a,s,u,d,l,c,l,f,v,s,w,s;var p=e.basePathType,g=e.options,h=e.path;return __generator(this,(function(e){switch(e.label){case 0:r=window.Zonos.zonosQaUrlApi||fallbackApiList[p]||MAIN_BASE_API_TYPE;t=r+h;o=new URL(t);i=window.Zonos.cartId?"".concat(window.location.hostname,"-").concat(window.Zonos.cartId):window.location.hostname;o.searchParams.set("zToken",encodeString(i));e.label=1;case 1:e.trys.push([1,3,,4]);return[4/*yield*/,fetch(o.toString(),g)];case 2:n=e.sent();return[3/*break*/,4];case 3:a=e.sent();if(a instanceof Error){return[2/*return*/,{baseUrl:r,errors:[{message:a.message,type:"unknown"}],json:null,response:null,zonosMode:null}]}s="Failed to fetch";return[2/*return*/,{baseUrl:r,errors:[{message:s,type:"unknown"}],json:null,response:null,zonosMode:null}];case 4:u=n.headers.get("Zonos-Mode");d=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&&u&&d){window.Zonos.modeAlerted=true}if(!n.ok)return[3/*break*/,6];return[4/*yield*/,getResponseBody({response:n})];case 5:l=e.sent();return[2/*return*/,{baseUrl:r,errors:[],json:l,response:n,zonosMode:u}];case 6:c=n.status.toString();e.label=7;case 7:e.trys.push([7,9,,10]);return[4/*yield*/,getResponseBody({response:n,shouldThrow:true})];case 8:l=e.sent();
|
|
51
|
+
// Parse and access "errors" from the response if possible
|
|
52
|
+
if(l&&"errors"in l&&Array.isArray(l.errors)){f=l.errors;v=f.map((function(e){if(typeof e==="string"){return{message:e,type:c}}return e}));return[2/*return*/,{baseUrl:r,errors:v,json:null,response:n,zonosMode:u}]}s=JSON.stringify(l);return[2/*return*/,{baseUrl:r,errors:[{message:s,type:c}],json:null,response:n,zonosMode:u}];case 9:w=e.sent();s="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(c,": ").concat(s),type:c}],json:null,response:isGatewayStatus(n.status)?n:null,zonosMode:u}];case 10:return[2/*return*/]}}))}))};var handleRequestWithFallback=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,r,t,o,i,a,s,u,d,l,c,f,v,w,p,g,h,b,y,m,_,A;var k=e.basePathType,T=e.options,I=e.path;return __generator(this,(function(e){switch(e.label){case 0:o=I.startsWith("/api/bigcommerce");i=o?"vercel":k;a=performance.now();return[4/*yield*/,handleRequest({basePathType:i,options:T,path:I})];case 1:s=e.sent(),u=s.errors,d=s.response,l=__rest(s,["errors","response"]);c=performance.now();f=c-a;
|
|
57
|
+
// Send the load time api log
|
|
58
|
+
log("".concat(I," (").concat(f.toFixed(2),"ms)"),"info");v=d===null||d===void 0?void 0:d.headers.get("Zonos-Duration");
|
|
59
|
+
// Only record if the response status is 200, some endpoint will return 200 with error
|
|
60
|
+
if((d===null||d===void 0?void 0:d.status)===200){prepLoadTimeApiLog({apiPath:I,apiType:i,loadTimeInternal:v?Number(v):0,loadTimeTotal:f})}w=getNextFallbackApiType(i);p=u.find((function(e){var n=e.type;return n==="unknown"}));g=u.find((function(e){var n=e.message;return typeof n==="string"&&(n.includes("signal is aborted")||n.includes("The operation was aborted")||n.includes("Fetch is aborted"))}));h=d===null||d===void 0?void 0:d.status;b=h!==undefined&&isGatewayStatus(h);y=((n=T===null||T===void 0?void 0:T.method)!==null&&n!==void 0?n:"GET").toUpperCase()==="GET";m=!!p||h===404||h===500;_=m||b;A=w&&(m||b&&y);
|
|
61
|
+
// Should log the error if it's unknown error
|
|
62
|
+
if(_&&!g){void sendErrorLog({endpoint:fallbackApiList[i]+I,errors:u.map((function(e){var n=e.message;return"API: ".concat(n)})),metadata:{currentBasePath:i,nextFallbackApiType:w,requestHeaders:T===null||T===void 0?void 0:T.headers,requestPayload:jsonParse((r=T===null||T===void 0?void 0:T.body)===null||r===void 0?void 0:r.toString())||((t=T===null||T===void 0?void 0:T.body)===null||t===void 0?void 0:t.toString()),shouldCallFallback:A,status:d===null||d===void 0?void 0:d.status,statusText:d===null||d===void 0?void 0:d.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(A){log('=== "'.concat(I,'" failed to fetch, trying next fallback ').concat(w));return[2/*return*/,handleRequestWithFallback({basePathType:w,options:T,path:I})]}
|
|
65
|
+
// No more fallbacks, just return the result
|
|
66
|
+
return[2/*return*/,Object.assign({errors:u,response:d},l)]}}))}))};
|
|
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 handleFetch=function(e,n){return __awaiter(void 0,void 0,void 0,(function(){var r,t,o,i,a,s;return __generator(this,(function(u){r=__rest(n||{},[]);t=r.body?JSON.stringify(r.body):undefined;o=r.method||"GET";i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":getIsStagingMode()?"1":undefined,"Zonos-Test-Mode":getIsTestMode()?"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(i).forEach((function(e){return i[e]===undefined&&delete i[e]}));a=Object.assign(Object.assign({},r),{body:o==="GET"?undefined:t,headers:i,method:o});s=new URLSearchParams(window.location.search).get("useFallbackApi");return[2/*return*/,handleRequestWithFallback({basePathType:s||MAIN_BASE_API_TYPE,options:a,path:e})]}))}))};export{getIsStagingMode as a,safeRemoveItem as b,safeGetItem as c,getAdditionalLogMetadata as d,safeSetItem as e,fallbackApiList as f,getIsTestMode as g,handleFetch as h,isCheckoutMobile as i,jsonParse as j,logError as l,sendErrorLog as s,thrownMessage as t};
|
package/dist/esm-es5/index.js
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,n,
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,o,n,t){function r(e){return e instanceof n?e:new n((function(o){o(e)}))}return new(n||(n=Promise))((function(n,i){function a(e){try{u(t.next(e))}catch(e){i(e)}}function s(e){try{u(t["throw"](e))}catch(e){i(e)}}function u(e){e.done?n(e.value):r(e.value).then(a,s)}u((t=t.apply(e,o||[])).next())}))};var __generator=this&&this.__generator||function(e,o){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,r,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(o){return u([e,o])}}function u(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(n=0)),n)try{if(t=1,r&&(i=s[0]&2?r["return"]:s[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;if(r=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;r=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1];i=s;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(s);break}if(i[2])n.ops.pop();n.trys.pop();continue}s=o.call(e,n)}catch(e){s=[6,e];r=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,o,n){if(n||arguments.length===2)for(var t=0,r=o.length,i;t<r;t++){if(i||!(t in o)){if(!i)i=Array.prototype.slice.call(o,0,t);i[t]=o[t]}}return e.concat(i||Array.prototype.slice.call(o))};export{c as curpRegex,i as isMexicoTaxIdType,a as isPeruTaxIdType,p as peruTaxIdTypeFromValue,s as stripTaxIdSeparators}from"./taxIdRules-xYlx7ZXW.js";import{c as createCustomEvent}from"./createCustomEvent-XQfWgQLB.js";import{g as getGenericSettingsOverride,I as IframeService}from"./getGenericSettingsOverride-HeAZDwVW.js";import{t as thrownMessage,s as sendErrorLog,g as getIsTestMode,a as getIsStagingMode,h as handleFetch,l as logError,b as safeRemoveItem,c as safeGetItem}from"./handleFetch-BFVO7oAR.js";import{l as log}from"./VarianceTest-BJmZPrZl.js";export{a as availableTestKeys}from"./VarianceTest-BJmZPrZl.js";import{h as holdStripeForNativeCheckout,m as markBigCommerceHostChecked,i as isBigCommerceNativeCheckout}from"./_isBigCommerceNativeCheckout-Bb90IMVt.js";import{g as getAbandonedCartRenewTokenValue,_ as _getIsValidCartId,c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector}from"./CheckoutConfig-D5SpFsQJ.js";export{d as domesticRedirectedBtnSelector}from"./CheckoutConfig-D5SpFsQJ.js";export{c as countryRequireShortAddressCode}from"./ShortAddressCode-nJ6oI8-n.js";export{a as checkoutTaxIdTypeValues,c as countryRequireTaxId,e as euCountryCodes,i as isCountryRequireTaxId,p as peruTaxIdDigitLength,b as peruTaxIdFormatError,s as shipToTaxIdLabels,t as taxIdTypeOptions}from"./TaxId-DMIgN_sT.js";var constructorNotFound=/^Constructor for .+ was not found/;var constructorTag=/^Constructor for "?([^#"]+)#/;var recordConstructorFailure=function(e){var o;var n=thrownMessage(e,"");if(!n||!constructorNotFound.test(n)){return}if(typeof window.Zonos==="undefined"){return}var t=window.__zonosConstructorCapture;if(!t){return}var r=constructorTag.exec(n);var i=(o=r===null||r===void 0?void 0:r[1])!==null&&o!==void 0?o:"";if(t.reported.has(i)){return}t.reported.add(i);void sendErrorLog({endpoint:"stencil://constructor",errors:[n],metadata:{shape:"constructor-not-found",tag:i}})};
|
|
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 installConstructorCapture=function(){if(window.__zonosConstructorCapture){return}var e=function(e){recordConstructorFailure(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 o=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 n=0;n<arguments.length;n++){e[n]=arguments[n]}recordConstructorFailure(e[0]);o.apply(void 0,e)}};var reportInitRejection=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 sendErrorLog({endpoint:"zonos://init",errors:[thrownMessage(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 startZonosInit=function(e){var o;try{o=e()}catch(e){reportInitRejection(e);return}void o.catch((function(e){reportInitRejection(e)}))};
|
|
2
20
|
/**
|
|
3
21
|
* Get the load version and url based on the loadScriptSrc and version
|
|
4
22
|
* @returns
|
|
5
|
-
*/var checkIfLoadVersionDomain=function(e){var
|
|
23
|
+
*/var checkIfLoadVersionDomain=function(e){var o=e.loadScriptSrc;if(!o){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var n=[
|
|
6
24
|
// local domain
|
|
7
25
|
"dev.elements.zonos.com","dev.assets-checkout.zonos.com",
|
|
8
26
|
// any domain with prefix , no need to version it
|
|
@@ -12,7 +30,7 @@ var __awaiter=this&&this.__awaiter||function(e,n,o,t){function r(e){return e ins
|
|
|
12
30
|
// force load version for qa domain, this is to test the load version behavior
|
|
13
31
|
"qa.js.zonos.com"];
|
|
14
32
|
// get the domain that's used to load the loadZonos.js
|
|
15
|
-
var r=new URL(
|
|
33
|
+
var r=new URL(o).origin;var i=n.some((function(e){
|
|
16
34
|
// check if the current domain is in the white listed domains
|
|
17
35
|
return r.includes(e)}));var a=t.some((function(e){
|
|
18
36
|
// check if the current domain is in the force load version domains list
|
|
@@ -22,16 +40,16 @@ return r.includes(e)}));return{currentLoadScriptUrl:r,isForceLoadVersionDomain:a
|
|
|
22
40
|
* @param currentCdnType The current cdn type that want to get the next fallback url
|
|
23
41
|
*/var getNextFallbackUrl=function(e){
|
|
24
42
|
// get current index of the current fail cdn type in the fallback list
|
|
25
|
-
var
|
|
43
|
+
var o=fallbackList.indexOf(e);
|
|
26
44
|
// get the next fallback cdn type
|
|
27
|
-
var
|
|
45
|
+
var n=fallbackList[o+1];return n||null};
|
|
28
46
|
/**
|
|
29
47
|
* Attempt to get test public credential to window.Zonos.zonosApiKey if needed
|
|
30
|
-
*/var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n,
|
|
48
|
+
*/var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,o,n,t,r,i;return __generator(this,(function(a){switch(a.label){case 0:e=getIsTestMode();o=getIsStagingMode();
|
|
31
49
|
// Do nothing if the test mode is not enabled or the public credential
|
|
32
|
-
if(!e&&!
|
|
50
|
+
if(!e&&!o||!window.Zonos.zonosApiKey){return[2/*return*/,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");
|
|
33
51
|
// Try to get the test public credential if the test mode is enabled and the public credential key is not a test key
|
|
34
|
-
if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2/*return*/,null]}return[4/*yield*/,handleFetch("/api/get-test-public-credential")];case 1:
|
|
52
|
+
if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2/*return*/,null]}return[4/*yield*/,handleFetch("/api/get-test-public-credential")];case 1:n=a.sent(),t=n.errors,r=n.json;if(t.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);return[2/*return*/,null]}i=r.publicCredential;if(!i){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2/*return*/,null]}
|
|
35
53
|
// Set the test public credential to the window object
|
|
36
54
|
log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2/*return*/,i]}}))}))};
|
|
37
55
|
/**
|
|
@@ -45,7 +63,7 @@ log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");retu
|
|
|
45
63
|
* invalid: https://www.zonos.com/?zonosQaUrl=https://zonos-something
|
|
46
64
|
*/var extractZonosQaUrl=function(e){if(!e){return null}
|
|
47
65
|
// get params from url
|
|
48
|
-
var
|
|
66
|
+
var o=new URL(e).searchParams;var n=o.get("zonosQaUrl");if(!n){return null}var t=/[^a-zA-Z0-9-_]+/.test(n);if(!!t){return null}return n};
|
|
49
67
|
/**
|
|
50
68
|
* Get the Zonos QA URL and return it. Will remove `zonosQaUrl` from the url query if it doesn't exists.
|
|
51
69
|
*/var getZonosQaUrl=function(){
|
|
@@ -54,77 +72,84 @@ var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t
|
|
|
54
72
|
* When developing, if the script load is from `dev.elements.zonos.com`,
|
|
55
73
|
* it would load script from that same domain instead of loading from cdn
|
|
56
74
|
*/
|
|
57
|
-
var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var
|
|
75
|
+
var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var o=extractZonosQaUrl(window.location.href);var n="https://v1.5.3.js.zonos.com";
|
|
58
76
|
// when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
|
|
59
|
-
if(!
|
|
77
|
+
if(!o&&(n.includes("test.")||
|
|
60
78
|
// Vercel git domain
|
|
61
|
-
|
|
79
|
+
n.includes("test-"))){return n}
|
|
62
80
|
// when local demo app is running, it needs to use the local dev script unless the qaUrl is set
|
|
63
|
-
if(!
|
|
81
|
+
if(!o&&["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(!o){return null}
|
|
64
82
|
// If the qaUrl, use the dev-elements domain to forward the request to the dev server to quickly debug the issue
|
|
65
|
-
if(
|
|
83
|
+
if(o==="dev-elements"){return"https://dev.elements.zonos.com"}
|
|
66
84
|
// The worker alias selects the API host only. Scripts stay on the normal CDN.
|
|
67
|
-
if(
|
|
85
|
+
if(o==="worker"){return null}var t="preview.js.zonos.com";var r="https://".concat(o,".").concat(t);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements script"),"warn");
|
|
68
86
|
// request to the url and check if the request has an error
|
|
69
87
|
void fetch(r).then((function(){
|
|
70
88
|
// cleanup checkout session to avoid using the prod session in preview domain
|
|
71
|
-
|
|
89
|
+
safeRemoveItem("session","zonos--checkout-session-id");safeRemoveItem("session","zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(r,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));
|
|
72
90
|
// remove the zonosQaUrl param from url
|
|
73
|
-
var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var
|
|
91
|
+
var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var o=window.location.pathname;var n="".concat(o,"?").concat(e.toString());
|
|
74
92
|
/**
|
|
75
93
|
* Setting the state to null in window.history.replaceState can cause issues with rendering when using next/link and pressing the back button.
|
|
76
94
|
* @ref https://github.com/vercel/next.js/issues/33233#issuecomment-1052349396
|
|
77
|
-
**/window.history.replaceState(window.history.state,"",
|
|
95
|
+
**/window.history.replaceState(window.history.state,"",n);window.location.reload();return null}));return r};
|
|
78
96
|
/* eslint-disable no-console */
|
|
79
|
-
/** Loading stripe script extracted from stripe.js repository */var STRIPE_API_VERSION="2025-02-24.acacia";var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var V3_VERSION=3;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var
|
|
97
|
+
/** Loading stripe script extracted from stripe.js repository */var STRIPE_API_VERSION="2025-02-24.acacia";var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var V3_VERSION=3;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var o=0;o<e.length;o++){var n=e[o];if(!n){continue}if(!V3_URL_REGEX.test(n.src)){continue}return n}return null};var stripePromise$1=null;var injectScript=function(e){var o="";var n=document.createElement("script");n.src="".concat(V3_URL).concat(o);var t=document.head||document.body;if(!t){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}t.appendChild(n);return n};var zonosStripeLoadScript=function(e){
|
|
80
98
|
// Ensure that we only attempt to load Stripe.js at most once
|
|
81
|
-
if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(n
|
|
99
|
+
if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(o,n){if(typeof window==="undefined"||typeof document==="undefined"){
|
|
82
100
|
// Resolve to null when imported server side. This makes the module
|
|
83
101
|
// safe to import in an isomorphic code base.
|
|
84
|
-
|
|
102
|
+
o(null);return}if(window.Stripe){o(window.Stripe);return}try{var t=zonosStripeFindScript();if(t&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!t){t=injectScript()}t===null||t===void 0?void 0:t.addEventListener("load",(function(){if(window.Stripe){o(window.Stripe)}else{n(new Error("Stripe.js not available"))}}));t===null||t===void 0?void 0:t.addEventListener("error",(function(){n(new Error("Failed to load Stripe.js"))}))}catch(e){n(e);return}}));return stripePromise$1};var registerWrapper=function(e,o){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:o})};var getStripeVersion=function(e){if(!("version"in e)){return}var o=e.version;return typeof o==="number"||typeof o==="string"?o:undefined};var initStripe=function(e,o,n){if(e===null){return null}var t=o[0],r=o[1];var i=Object.assign({},r);var a=getStripeVersion(e);var s=typeof a==="string"&&a!==V3_VERSION.toString();if(s){delete i.apiVersion}else{i.apiVersion=STRIPE_API_VERSION}var u=e(t,i);registerWrapper(u,n);return u};
|
|
85
103
|
// Execute our own script injection after a tick to give users time to do their
|
|
86
104
|
// own script injection.
|
|
87
|
-
var hasCheckoutCartCallback=function(){var e,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
105
|
+
var hasCheckoutCartCallback=function(){var e,o;return typeof window!=="undefined"&&(typeof((e=window.Zonos)===null||e===void 0?void 0:e.createCartId)==="function"||typeof((o=window.Zonos)===null||o===void 0?void 0:o.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 loadStripeScript=function(){if(holdStripeForNativeCheckout()){return Promise.resolve(null)}return zonosStripeLoadScript(null)};var stripePromise=Promise.resolve().then((function(){
|
|
111
|
+
// Hello-only pages have no cart callback, so they skip the eager preload.
|
|
112
|
+
if(!hasCheckoutCartCallback()){return null}return loadStripeScript()}));var loadCalled=false;stripePromise.catch((function(e){if(!loadCalled){
|
|
91
113
|
// eslint-disable-next-line no-console
|
|
92
|
-
console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var
|
|
114
|
+
console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var o=0;o<arguments.length;o++){e[o]=arguments[o]}return __awaiter(void 0,void 0,void 0,(function(){var o,n,t,r;return __generator(this,(function(i){switch(i.label){case 0:loadCalled=true;n=Date.now();return[4/*yield*/,stripePromise];case 1:if(!((o=i.sent())!==null&&o!==void 0))return[3/*break*/,2];r=o;return[3/*break*/,4];case 2:return[4/*yield*/,loadStripeScript()];case 3:r=i.sent();i.label=4;case 4:t=r;return[2/*return*/,initStripe(t,e,n)]}}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";
|
|
93
115
|
/**
|
|
94
116
|
* Simple function to get the cart id from the query param.
|
|
95
|
-
*/var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var
|
|
117
|
+
*/var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var o=e.get(TEMP_CART_ID_QUERY_PARAM);return o};var getCartInfoById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var o,n,t,r,i,a,s,u,c;var d=e.cartId,l=e.retries;return __generator(this,(function(e){switch(e.label){case 0:o=getIsTestMode();n=getGenericSettingsOverride();t=getAbandonedCartRenewTokenValue()||undefined;r=new URLSearchParams;if(n.overrideShouldEnabledCustomAddress){r.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress)}return[4/*yield*/,handleFetch("/api/zonos-elements/get-cart?".concat(r.toString()),{body:{isTestMode:o,renewCartExpirationToken:t,tempCartUUID:d},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:i=e.sent(),a=i.errors,s=i.json,u=i.zonosMode;c=!s||a.length;if(!(c&&l))return[3/*break*/,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:l});
|
|
96
118
|
// wait 1 second before retrying
|
|
97
119
|
return[4/*yield*/,new Promise((function(e){return setTimeout(e,500)}))];case 2:
|
|
98
120
|
// wait 1 second before retrying
|
|
99
|
-
e.sent();return[2/*return*/,getCartInfoById({cartId:d,retries:l-1})];case 3:if(c){return[2/*return*/,null]}return[2/*return*/,Object.assign(Object.assign({},s),{zonosMode:u})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,
|
|
121
|
+
e.sent();return[2/*return*/,getCartInfoById({cartId:d,retries:l-1})];case 3:if(c){return[2/*return*/,null]}return[2/*return*/,Object.assign(Object.assign({},s),{zonosMode:u})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var o,n,t,r;return __generator(this,(function(i){switch(i.label){case 0:o=_getIsValidCartId(e),n=o.isDgsCartId,t=o.isLegacyCartId;if(!t&&!n){logError("[ZONOS - loadZonos] invalid cart id");return[2/*return*/,null]}return[4/*yield*/,getCartInfoById({cartId:e,retries:5})];case 1:r=i.sent();log("[ZONOS - loadZonos] getting temp cart data","info",r);if(!r){logError("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2/*return*/,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;window.Zonos.zonosMode=r.zonosMode;return[2/*return*/,{cartData:r.cartData,settings:r.settings,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var _a;
|
|
100
122
|
/**
|
|
101
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
|
|
102
|
-
*/var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var
|
|
124
|
+
*/var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var o=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),n=o.currentLoadScriptUrl,t=o.isWhiteListed;if(t){return n}return null}();var startLoadTime=Date.now();var ZONOS_URL="https://v1.5.3.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.5.3";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.5.3";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.5.3";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=/** @class */function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;
|
|
103
125
|
// if query 'zonosDebug=1' param from url, debug mode is on
|
|
104
|
-
Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Zonos.isBigCommerce=false;Zonos.releaseDate="
|
|
126
|
+
Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Zonos.isBigCommerce=false;Zonos.releaseDate="1794098254078";Zonos.isLegacyCheckout=false;Zonos.googleAnalyticId=null;Zonos.googleAnalyticReady=false;Zonos.facebookPixelId=null;Zonos.facebookPixelReady=false;Zonos.startLoadTime=startLoadTime;Zonos.domain=typeof window!=="undefined"?// domain that embeds the iframe
|
|
105
127
|
window.location!=window.parent.location&&document.referrer||
|
|
106
128
|
// current domain
|
|
107
129
|
document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.overrideUseCustomAddressForm=false;Zonos.isCollect=false;Zonos.isInvoice=false;
|
|
108
130
|
/**
|
|
109
131
|
* By default, the package will load from npm
|
|
110
|
-
*/Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.5.
|
|
132
|
+
*/Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.5.3");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.zonosMode=null;Zonos.IframeService=IframeService;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.loadTimeApiInfoList=[];Zonos.logIntervalId=null;Zonos.init=function(e){return __awaiter(void 0,void 0,void 0,(function(){var o,n,t,r,i,a,s,u,c,d,l,f,v,m,p;return __generator(this,(function(_){switch(_.label){case 0:installConstructorCapture();o=e.appearance,n=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,u=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();
|
|
111
133
|
// Expose the checkout cart callbacks on the global so Stripe loading can be
|
|
112
134
|
// gated on whether at least one of them is configured.
|
|
113
|
-
_a.createCartId=
|
|
135
|
+
_a.createCartId=n===null||n===void 0?void 0:n.createCartId;
|
|
114
136
|
// eslint-disable-next-line @typescript-eslint/no-deprecated -- intentionally mirror the (deprecated) callback so Stripe loading can be gated on it
|
|
115
|
-
_a.buildCartDetail=
|
|
137
|
+
_a.buildCartDetail=n===null||n===void 0?void 0:n.buildCartDetail;if(_a.doneInit){
|
|
116
138
|
// do nothing if zonos is already initialized
|
|
117
|
-
return[2/*return*/]}
|
|
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
|
+
markBigCommerceHostChecked();log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=u;_a.storeId=s;
|
|
118
143
|
// When not in iframe, providers are ready (gtag/fbq work directly). When in iframe, relay sets these after parent configures.
|
|
119
144
|
if(typeof window!=="undefined"&&window.parent===window){_a.googleAnalyticReady=true;_a.facebookPixelReady=true}if(!_a.isNpm)return[3/*break*/,4];log("====== ZONOS LOADING FROM NPM ======");c=getZonosQaUrl();
|
|
120
145
|
// if zonosQaUrl is available, inject the script from the zonosQaUrl and then call init again
|
|
121
146
|
if(c&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(c," ======"),"info");d=document.createElement("script");d.src="".concat(c,"/dist/scripts/zonos.js");document.head.appendChild(d);d.addEventListener("load",(function(){window.Zonos.isNpm=_a.isNpm;window.Zonos.isBigCommerce=_a.isBigCommerce;window.Zonos.isLegacyCheckout=_a.isLegacyCheckout;window.Zonos.zonosMode=_a.zonosMode;
|
|
122
147
|
// call init again after the script is loaded
|
|
123
|
-
|
|
148
|
+
startZonosInit((function(){return window.Zonos.init(e)}))}));d.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(c))}));
|
|
124
149
|
// Set so won't inject the preview script again
|
|
125
150
|
window.isZonosPreview=true;return[2/*return*/]}
|
|
126
151
|
// zonosApiKey is required if tempCartUUID in query params are not provided
|
|
127
|
-
if(!u&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2/*return*/]}if(!(!_a.cartData&&_a.cartId))return[3/*break*/,2];log("Initialize cart data");return[4/*yield*/,setupCartDataWithSettings(_a.cartId)];case 1:l=_.sent();if(!l){logError("Failed to get cart data");return[2/*return*/]}_a.cartData=l.cartData;_a.zonosApiKey=l.zonosApiKey;_a.cartSettings=l.settings;_.label=2;case 2:return[4/*yield*/,getWithTestPublicCredential()];case 3:f=_.sent();if(f){_a.zonosApiKey=f}_.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||
|
|
152
|
+
if(!u&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2/*return*/]}if(!(!_a.cartData&&_a.cartId))return[3/*break*/,2];log("Initialize cart data");return[4/*yield*/,setupCartDataWithSettings(_a.cartId)];case 1:l=_.sent();if(!l){logError("Failed to get cart data");return[2/*return*/]}_a.cartData=l.cartData;_a.zonosApiKey=l.zonosApiKey;_a.cartSettings=l.settings;_.label=2;case 2:return[4/*yield*/,getWithTestPublicCredential()];case 3:f=_.sent();if(f){_a.zonosApiKey=f}_.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||safeGetItem("session","zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;
|
|
128
153
|
// inject hidden button to body to trigger checkout right away if we have cartData or stripe client secret
|
|
129
154
|
if(m){log("Cart data or stripe client secret is available, inject hidden button and trigger checkout");p=document.createElement("button");p.style.display="none";p.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(p)}log("init zonos");_a.restoreNativeBrowserFunctions();
|
|
130
155
|
// inject custom script for hosted checkout if can find it in metadata
|
|
@@ -138,23 +163,23 @@ _a.injectFonts();
|
|
|
138
163
|
// inject checkout international button
|
|
139
164
|
_a.injectCheckoutInternationalButton();
|
|
140
165
|
// init zonos controller
|
|
141
|
-
_a.injectController({config:{appearance:
|
|
166
|
+
_a.injectController({config:{appearance:o,checkoutSettings:n,currencyConverter:t,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2/*return*/]}}))}))};
|
|
142
167
|
/**
|
|
143
168
|
* Inject the hidden international checkout button to trigger checkout regardless of shipping zones
|
|
144
169
|
*/Zonos.injectCheckoutInternationalButton=function(){if(!document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector))){
|
|
145
170
|
// inject the hidden international checkout button
|
|
146
|
-
var e=document.createElement("button");e.id=checkoutHiddenInternationalBtnSelector;e.style.display="none";document.body.appendChild(e)}};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var
|
|
171
|
+
var e=document.createElement("button");e.id=checkoutHiddenInternationalBtnSelector;e.style.display="none";document.body.appendChild(e)}};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var o=(e===null||e===void 0?void 0:e.metadata)||[];var n=o.find((function(e){return e.key==="customHeaderScript"}));var t=o.find((function(e){return e.key==="customFooterScript"}));
|
|
147
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
|
|
148
173
|
// Only inject the script if checkout is on Zonos hosted checkout and custom script is available
|
|
149
|
-
if(!window.Zonos.isLegacyCheckout||!
|
|
174
|
+
if(!window.Zonos.isLegacyCheckout||!n&&!t){log("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(n){log("Injecting custom header script");var r=document.createElement("script");r.textContent=n.value;document.head.appendChild(r)}if(t){log("Injecting custom footer script");var r=document.createElement("script");r.textContent=t.value;document.body.appendChild(r)}};Zonos.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};Zonos.triggerCheckoutInternational=function(){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(o){e=document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector));setTimeout((function(){if(e){e.dispatchEvent(createCustomEvent("click"))}}),10);return[2/*return*/]}))}))};
|
|
150
175
|
// Called openHelloDialog because the main use case is to simply open the dialog
|
|
151
|
-
Zonos.openHelloDialog=function(e){var
|
|
176
|
+
Zonos.openHelloDialog=function(e){var o=document.querySelector("zonos-hello");if(o){void o.openHelloDialog(e!==null&&e!==void 0?e:true)}};Zonos.showNotification=function(e){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.showNotification(e))};Zonos.updateOrganizationName=function(e){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.updateOrganizationName(e))};Zonos.disablePlaceOrderButtons=function(e){var o=e.autoEnable,n=o===void 0?true:o,t=e.config,r=e.disable,i=e.placeOrderButtonSelector;var a;
|
|
152
177
|
// if disablePlaceOrderButtonActivation is true, do nothing
|
|
153
178
|
if((a=t.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}
|
|
154
179
|
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
155
|
-
if(i){var s=document.querySelectorAll(i);var u=function(e){var
|
|
180
|
+
if(i){var s=document.querySelectorAll(i);var u=function(e){var o=e.target;
|
|
156
181
|
// prevent default and propagation when the item has disabled attribute
|
|
157
|
-
if(
|
|
182
|
+
if(o.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};s.forEach((function(e){var o=e.getAttribute("data-zonos-checkout-attached");if(o){
|
|
158
183
|
// do nothing if event is already attached
|
|
159
184
|
return}if(r){e.setAttribute("disabled","true");
|
|
160
185
|
// prevent the selector to perform default action when it's disabled
|
|
@@ -162,7 +187,7 @@ e.addEventListener("click",u)}else{e.removeAttribute("disabled");
|
|
|
162
187
|
// clean up the event listener
|
|
163
188
|
e.removeEventListener("click",u)}}));
|
|
164
189
|
// only auto enable if autoEnable is true and we are setting button disable
|
|
165
|
-
if(
|
|
190
|
+
if(n&&r){setTimeout((function(){
|
|
166
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)
|
|
167
192
|
s.forEach((function(e){e.removeAttribute("disabled");
|
|
168
193
|
// clean up the event listener if exists
|
|
@@ -173,55 +198,59 @@ e.removeEventListener("click",u)}))}),5e3)}}};
|
|
|
173
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.
|
|
174
199
|
*/Zonos.restoreNativeBrowserFunctions=function(){var e;
|
|
175
200
|
// If the URL parameter `useMerchantPolyfill=1` is present, keep the merchant's polyfills instead of restoring native browser functions.
|
|
176
|
-
var
|
|
201
|
+
var o=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(o){return}var n="zonos---native-browser";var t=document.querySelector("iframe#".concat(n));if(!t){
|
|
177
202
|
// add a hidden iframe
|
|
178
|
-
t=document.createElement("iframe");t.id=
|
|
203
|
+
t=document.createElement("iframe");t.id=n;t.style.display="none";t.style.opacity="0";t.style.position="absolute";t.style.top="-9999px";t.style.left="-9999px";t.style.width="1px";t.style.height="1px";t.style.border="none";t.style.overflow="hidden";t.style.visibility="hidden";document.body.appendChild(t)}
|
|
179
204
|
/**
|
|
180
205
|
* Override Array.from if the site is using the obsolete prototype.js (last updated 2015).
|
|
181
206
|
* If old browser is being used and Array.from is not available, just use Array from the prototype.js polyfill
|
|
182
|
-
*/var r=((e=t.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=r;document.body.removeChild(t)};Zonos.injectController=function(e){var
|
|
207
|
+
*/var r=((e=t.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=r;document.body.removeChild(t)};Zonos.injectController=function(e){var o=e.config;var n,t;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(!isBigCommerceNativeCheckout()){
|
|
183
212
|
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
184
|
-
if((o
|
|
213
|
+
if((n=o.checkoutSettings)===null||n===void 0?void 0:n.placeOrderButtonSelector){var r=o.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:o,disable:true,placeOrderButtonSelector:r});
|
|
185
214
|
// create a mutation observer to see if any new elements that match our selector is added to the DOM
|
|
186
|
-
var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:
|
|
215
|
+
var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:o,disable:true,placeOrderButtonSelector:r})}));i.observe(document.body,{childList:true,subtree:true})}
|
|
187
216
|
// if alwaysTriggerInternationalCheckoutSelector is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
188
|
-
if((t=
|
|
217
|
+
if((t=o.checkoutSettings)===null||t===void 0?void 0:t.alwaysTriggerInternationalCheckoutSelector){var a=o.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;_a.disablePlaceOrderButtons({config:o,disable:true,placeOrderButtonSelector:a});
|
|
189
218
|
// create a mutation observer to see if any new elements that match our selector is added to the DOM
|
|
190
|
-
var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:
|
|
219
|
+
var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:o,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}}var s=document.createElement("zonos-controller");s.config=o;s.zonosApiKey=_a.zonosApiKey||"";s.addEventListener("stripeInitEvent",(function(e){return __awaiter(void 0,void 0,void 0,(function(){var o,n;return __generator(this,(function(t){switch(t.label){case 0:o=e.detail;log("loading Stripe");return[4/*yield*/,zonosLoadStripe(o.publishableKey)];case 1:n=t.sent();if(!n){logError("API seems to be invalid or missing. Failed to load Stripe");return[2/*return*/]}window.Zonos.stripe=n;if(window.Zonos.isCollect){void s.initCollectElement(n)}else if(window.Zonos.isInvoice){void s.initInvoiceElement(n)}else{void s.initCheckoutElement(n)}return[2/*return*/]}}))}))}));document.body.appendChild(s);
|
|
191
220
|
// set zonos controller to be global
|
|
192
|
-
_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectScript=function(e){var
|
|
221
|
+
_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectScript=function(e){var o=e.cdnType,n=e.isModule,t=e.theRestUrl;var r=_a.getZonosUrl(o);var i="".concat(r,"/").concat(t);var a=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;
|
|
193
222
|
// init zonos elements when the zonosKey is valid
|
|
194
223
|
// inject esmodule cdn for zonos elements
|
|
195
|
-
var u=document.createElement("script");if(!!
|
|
224
|
+
var u=document.createElement("script");if(!!n){u.type="module"}else{u.noModule=true}u.src=i;u.crossOrigin="anonymous";u.onerror=function(){logError("Failed to load ".concat(u.src));var e=getNextFallbackUrl(o);
|
|
196
225
|
// if next fallback cdn type exists, inject the script with the next fallback cdn type
|
|
197
|
-
if(!e){return}_a.injectScript({cdnType:e,isModule:
|
|
226
|
+
if(!e){return}_a.injectScript({cdnType:e,isModule:n,theRestUrl:t})};s.appendChild(u)};
|
|
198
227
|
/**
|
|
199
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`.
|
|
200
|
-
*/Zonos.getZonosUrl=function(e){var
|
|
229
|
+
*/Zonos.getZonosUrl=function(e){var o=function(){switch(e){case"jsdelivr":return JS_DELIVR_ZONOS_URL;case"unpkg":return UNPKG_ZONOS_URL;case"cdnjs":return CDNJS_ZONOS_URL;case"vercel":return ZONOS_URL}};
|
|
201
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
|
|
202
|
-
if(_a.isNpm){var
|
|
231
|
+
if(_a.isNpm){var n=getZonosQaUrl();
|
|
203
232
|
// Default to hard coded domain if zonosQaUrl is not available
|
|
204
|
-
return o
|
|
233
|
+
return n||o()}return o()};Zonos.injectZonosCdn=function(){
|
|
205
234
|
// init zonos elements when the zonosKey is valid
|
|
206
235
|
// inject esmodule cdn for zonos elements
|
|
207
236
|
_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});
|
|
208
237
|
// inject non module cdn for zonos elements
|
|
209
|
-
_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(e){var
|
|
238
|
+
_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(e){var o=e.cdnType,n=e.theRestUrl;var t=_a.getZonosUrl(o);var r=document.head||document.body;
|
|
210
239
|
// inject preconnect css for zonos elements
|
|
211
240
|
var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");r.appendChild(i);
|
|
212
241
|
// inject css for zonos elements
|
|
213
|
-
var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(
|
|
242
|
+
var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(n);a.onerror=function(){logError("Failed to load ".concat(a.href));var e=getNextFallbackUrl(o);
|
|
214
243
|
// if the css failed to load, try to load the next fallback cdn if exists
|
|
215
|
-
if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:
|
|
244
|
+
if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:n})};r.appendChild(a)};Zonos.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){log("Zonos style links already injected","warn");return}
|
|
216
245
|
// inject css for zonos elements
|
|
217
|
-
_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){log("Inter font already loaded","warn");return}var
|
|
246
|
+
_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){log("Inter font already loaded","warn");return}var o=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(GOOGLE_FONT_URL,'"]'));for(var n=0;n<o.length;n++){var t=o[n];if(!t){continue}if(GOOGLE_FONT_REGEX.test(t.href)){continue}return t}return null};if(e()){log("Inter font already injected","warn");return}var o=document.head||document.body;
|
|
218
247
|
// inject font css for zonos elements
|
|
219
|
-
var
|
|
248
|
+
var n=document.createElement("link");n.rel="preconnect";n.href=GOOGLE_FONT_URL;o.appendChild(n);
|
|
220
249
|
// inject font css for zonos elements
|
|
221
|
-
var t=document.createElement("link");t.rel="stylesheet";t.href="".concat(GOOGLE_FONT_URL,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");
|
|
250
|
+
var t=document.createElement("link");t.rel="stylesheet";t.href="".concat(GOOGLE_FONT_URL,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");o.appendChild(t);log("Zonos font injected!")};
|
|
222
251
|
// apply font for zonos elements and inject font if needed
|
|
223
|
-
Zonos.setupGoogleFont=function(e){var
|
|
252
|
+
Zonos.setupGoogleFont=function(e){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.setupGoogleFont(e))};
|
|
224
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
|
|
225
|
-
Zonos.injectSupportGoogleFont=function(e){var
|
|
254
|
+
Zonos.injectSupportGoogleFont=function(e){var o;log("[FONT] injecting ".concat(e));var n=(o=e.match(/family=(.*?):/))===null||o===void 0?void 0:o[1];var t=document.head||document.body;
|
|
226
255
|
// inject font css for zonos elements
|
|
227
|
-
if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var r=document.createElement("link");r.rel="preconnect";r.href=GOOGLE_FONT_URL;t.appendChild(r)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){log("[FONT] ".concat(
|
|
256
|
+
if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var r=document.createElement("link");r.rel="preconnect";r.href=GOOGLE_FONT_URL;t.appendChild(r)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){log("[FONT] ".concat(n," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;t.appendChild(i);log("[FONT] ".concat(n," font injected!"))};var checkoutSessionMutableAttributeKeys=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"];var checkoutSessionImmutableAttributeKeys=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"];var checkoutSessionAttributeKeys=__spreadArray(__spreadArray([],checkoutSessionMutableAttributeKeys,true),checkoutSessionImmutableAttributeKeys,true);export{Zonos,checkoutHiddenBtnSelector,checkoutHiddenInternationalBtnSelector,checkoutSessionAttributeKeys,checkoutSessionImmutableAttributeKeys,checkoutSessionMutableAttributeKeys};
|