@zonos/elements 1.3.279 → 1.3.280
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/{cart-e8bc11a3.js → cart-0fa312a5.js} +1 -1
- package/dist/cjs/{collect-e6485168.js → collect-f9c4ca7c.js} +2 -2
- package/dist/cjs/formatStringWithLinks-c25b4018.js +24 -0
- package/dist/cjs/{hasInclusivePrice-798ce42d.js → hasInclusivePrice-95431bca.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{invoice-dff7ec81.js → invoice-ce757565.js} +2 -2
- package/dist/cjs/isSameHostCheckoutLink-6148cabb.js +28 -0
- package/dist/cjs/{localization-90650d7d.js → localization-7fded969.js} +40 -40
- package/dist/cjs/{paypal-77bd640c.js → paypal-57ab3ab6.js} +2 -2
- package/dist/cjs/{placeTestOrder-7767d119.js → placeTestOrder-35e0d3bd.js} +2 -2
- package/dist/cjs/{renderCheckoutCurrency-66377cf5.js → renderCheckoutCurrency-41d48407.js} +2 -2
- package/dist/cjs/zonos-address-display_8.cjs.entry.js +2 -2
- package/dist/cjs/zonos-address_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +3 -3
- package/dist/cjs/zonos-card_5.cjs.entry.js +3 -3
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +19 -7
- package/dist/cjs/zonos-checkout.cjs.entry.js +189 -13
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +2 -2
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +6 -6
- package/dist/cjs/zonos-collect.cjs.entry.js +4 -4
- package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
- package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +3 -2
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +4 -3
- package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +4 -4
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +6 -6
- package/dist/cjs/zonos-invoice.cjs.entry.js +4 -4
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +3 -3
- package/dist/collection/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.js +13 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +36 -2
- package/dist/collection/components/store/translationStore/strings.arabic.js +2 -2
- package/dist/collection/components/store/translationStore/strings.base.js +2 -2
- package/dist/collection/components/store/translationStore/strings.chinese.js +2 -2
- package/dist/collection/components/store/translationStore/strings.danish.js +2 -2
- package/dist/collection/components/store/translationStore/strings.dutch.js +2 -2
- package/dist/collection/components/store/translationStore/strings.french.js +2 -2
- package/dist/collection/components/store/translationStore/strings.german.js +2 -2
- package/dist/collection/components/store/translationStore/strings.hebrew.js +2 -2
- package/dist/collection/components/store/translationStore/strings.indonesian.js +2 -2
- package/dist/collection/components/store/translationStore/strings.italian.js +2 -2
- package/dist/collection/components/store/translationStore/strings.japanese.js +2 -2
- package/dist/collection/components/store/translationStore/strings.korean.js +2 -2
- package/dist/collection/components/store/translationStore/strings.norwegian.js +2 -2
- package/dist/collection/components/store/translationStore/strings.polish.js +2 -2
- package/dist/collection/components/store/translationStore/strings.portuguese.js +2 -2
- package/dist/collection/components/store/translationStore/strings.russian.js +2 -2
- package/dist/collection/components/store/translationStore/strings.spanish.js +2 -2
- package/dist/collection/components/store/translationStore/strings.swedish.js +2 -2
- package/dist/collection/components/store/translationStore/strings.turkish.js +2 -2
- package/dist/collection/components/store/translationStore/strings.vietnamese.js +2 -2
- package/dist/collection/components/utils/checkout/buildBigcommerceRedirectUrl.js +6 -1
- package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +144 -7
- package/dist/collection/components/utils/formatStringWithLinks.js +12 -6
- package/dist/collection/components/utils/isSameHostCheckoutLink.js +24 -0
- package/dist/collection/types/generated/graphql.internal.types.js +84 -0
- package/dist/esm/{cart-8b8dc79f.js → cart-4699e6ab.js} +2 -2
- package/dist/esm/{collect-f4965586.js → collect-24cc2e12.js} +2 -2
- package/dist/esm/formatStringWithLinks-0d48f183.js +22 -0
- package/dist/esm/{hasInclusivePrice-1589fef9.js → hasInclusivePrice-f81ddcd6.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/{invoice-b7a1fb14.js → invoice-575dc93d.js} +2 -2
- package/dist/esm/isSameHostCheckoutLink-c1b88ab7.js +26 -0
- package/dist/esm/{localization-d49867ed.js → localization-da2f407f.js} +40 -40
- package/dist/esm/{paypal-da551105.js → paypal-d4436abd.js} +2 -2
- package/dist/esm/{placeTestOrder-4309b170.js → placeTestOrder-d87b2c6a.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-0ed221ac.js → renderCheckoutCurrency-08526996.js} +2 -2
- package/dist/esm/zonos-address-display_8.entry.js +2 -2
- package/dist/esm/zonos-address_4.entry.js +2 -2
- package/dist/esm/zonos-airwallex-payment.entry.js +3 -3
- package/dist/esm/zonos-card_5.entry.js +3 -3
- package/dist/esm/zonos-cart-items_12.entry.js +19 -7
- package/dist/esm/zonos-checkout.entry.js +189 -13
- package/dist/esm/zonos-collect-cart-items_3.entry.js +2 -2
- package/dist/esm/zonos-collect-finish_6.entry.js +6 -6
- package/dist/esm/zonos-collect.entry.js +4 -4
- package/dist/esm/zonos-controller.entry.js +2 -2
- package/dist/esm/zonos-country-flag.entry.js +1 -1
- package/dist/esm/zonos-country-select_4.entry.js +3 -2
- package/dist/esm/zonos-hello-dialog.entry.js +4 -3
- package/dist/esm/zonos-hello.entry.js +1 -1
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +4 -4
- package/dist/esm/zonos-invoice-finish_5.entry.js +6 -6
- package/dist/esm/zonos-invoice.entry.js +4 -4
- package/dist/esm/zonos-language-select_2.entry.js +1 -1
- package/dist/esm/zonos-policy-consent_2.entry.js +3 -3
- package/dist/esm-es5/{cart-8b8dc79f.js → cart-4699e6ab.js} +1 -1
- package/dist/esm-es5/{collect-f4965586.js → collect-24cc2e12.js} +1 -1
- package/dist/esm-es5/formatStringWithLinks-0d48f183.js +1 -0
- package/dist/esm-es5/{hasInclusivePrice-1589fef9.js → hasInclusivePrice-f81ddcd6.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{invoice-b7a1fb14.js → invoice-575dc93d.js} +1 -1
- package/dist/esm-es5/isSameHostCheckoutLink-c1b88ab7.js +1 -0
- package/dist/esm-es5/localization-da2f407f.js +1 -0
- package/dist/esm-es5/{paypal-da551105.js → paypal-d4436abd.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-4309b170.js → placeTestOrder-d87b2c6a.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-0ed221ac.js → renderCheckoutCurrency-08526996.js} +1 -1
- package/dist/esm-es5/zonos-address-display_8.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 +1 -1
- package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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/store/translationStore/strings.arabic.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.base.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.chinese.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.danish.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.dutch.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.french.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.german.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.hebrew.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.indonesian.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.italian.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.japanese.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.korean.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.norwegian.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.polish.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.portuguese.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.russian.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.spanish.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.swedish.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.turkish.d.ts +1 -1
- package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +1 -1
- package/dist/types/components/utils/isSameHostCheckoutLink.d.ts +14 -0
- package/dist/types/types/generated/graphql.internal.types.d.ts +84 -0
- package/dist/types/types/generated/graphql.internal.types.ts +85 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-02065a08.system.js → p-016b5bde.system.js} +1 -1
- package/dist/zonos-elements/{p-6fae9835.system.entry.js → p-0adab1d5.system.entry.js} +1 -1
- package/dist/zonos-elements/p-0d2f81ce.system.js +1 -0
- package/dist/zonos-elements/p-11206fe2.js +1 -0
- package/dist/zonos-elements/{p-0402af0d.entry.js → p-12452213.entry.js} +1 -1
- package/dist/zonos-elements/{p-5827c868.entry.js → p-19f4e77a.entry.js} +1 -1
- package/dist/zonos-elements/{p-2aecc055.entry.js → p-1bb85ff1.entry.js} +1 -1
- package/dist/zonos-elements/{p-5c76ef2a.js → p-275fa2da.js} +1 -1
- package/dist/zonos-elements/{p-8b42245d.entry.js → p-28b1c189.entry.js} +1 -1
- package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
- package/dist/zonos-elements/p-2b97f7ed.js +1 -0
- package/dist/zonos-elements/{p-647438d6.system.js → p-2dbdf883.system.js} +1 -1
- package/dist/zonos-elements/{p-5afea02c.system.entry.js → p-3068247c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-7614ea6f.system.entry.js → p-362215b6.system.entry.js} +1 -1
- package/dist/zonos-elements/p-39e2642f.js +1 -0
- package/dist/zonos-elements/p-3f8f4c78.js +1 -0
- package/dist/zonos-elements/{p-d5945ddc.entry.js → p-3f90cb36.entry.js} +1 -1
- package/dist/zonos-elements/{p-1b963905.system.js → p-40a0c1d3.system.js} +1 -1
- package/dist/zonos-elements/{p-abf61f6f.system.entry.js → p-43a14674.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d7cb9ef6.system.entry.js → p-46f88c11.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-998f9df5.system.entry.js → p-564c7bb5.system.entry.js} +1 -1
- package/dist/zonos-elements/p-5b54f10c.entry.js +1 -0
- package/dist/zonos-elements/p-6197aa73.system.entry.js +1 -0
- package/dist/zonos-elements/{p-b36205f4.entry.js → p-6451537c.entry.js} +1 -1
- package/dist/zonos-elements/p-65fe75e1.entry.js +1 -0
- package/dist/zonos-elements/{p-5bc43687.system.entry.js → p-66223935.system.entry.js} +1 -1
- package/dist/zonos-elements/p-67426156.system.js +1 -0
- package/dist/zonos-elements/{p-2654556b.js → p-67b2e46c.js} +1 -1
- package/dist/zonos-elements/p-6bea1787.entry.js +1 -0
- package/dist/zonos-elements/{p-cd41b16b.system.entry.js → p-7237ec6f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0745e440.entry.js → p-72c1bd64.entry.js} +1 -1
- package/dist/zonos-elements/p-75da4ba0.entry.js +1 -0
- package/dist/zonos-elements/{p-3f380c8f.system.js → p-788a16bb.system.js} +1 -1
- package/dist/zonos-elements/p-79b6070a.js +1 -0
- package/dist/zonos-elements/{p-77fa437c.entry.js → p-807e7ebc.entry.js} +1 -1
- package/dist/zonos-elements/{p-43815edd.system.entry.js → p-81c4f04a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8bd37d3b.entry.js → p-85796e67.entry.js} +1 -1
- package/dist/zonos-elements/p-94329e56.js +1 -0
- package/dist/zonos-elements/{p-ed676ad1.system.entry.js → p-944148db.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a8c79850.js → p-96e7b465.js} +1 -1
- package/dist/zonos-elements/{p-32278945.system.js → p-a30f03d6.system.js} +1 -1
- package/dist/zonos-elements/{p-ac59f5c1.system.entry.js → p-a5afcea1.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-293183c1.system.entry.js → p-a7f0e824.system.entry.js} +1 -1
- package/dist/zonos-elements/p-aff7112b.entry.js +1 -0
- package/dist/zonos-elements/p-b05da593.system.entry.js +1 -0
- package/dist/zonos-elements/p-b330e451.system.js +1 -0
- package/dist/zonos-elements/{p-12a08423.system.entry.js → p-b6049eef.system.entry.js} +1 -1
- package/dist/zonos-elements/p-b6cd6e62.system.entry.js +1 -0
- package/dist/zonos-elements/{p-7365e22c.system.js → p-b8c019b9.system.js} +1 -1
- package/dist/zonos-elements/p-c2014d57.system.entry.js +1 -0
- package/dist/zonos-elements/{p-ee434a71.entry.js → p-c4a479ad.entry.js} +1 -1
- package/dist/zonos-elements/{p-4e6e9a3c.system.entry.js → p-cf0c8c77.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-f44a3338.entry.js → p-db9cb522.entry.js} +1 -1
- package/dist/zonos-elements/{p-9beb2624.entry.js → p-dbd5be5d.entry.js} +1 -1
- package/dist/zonos-elements/p-dff1d3be.entry.js +1 -0
- package/dist/zonos-elements/{p-7e8aba66.system.entry.js → p-ec53c436.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-74ebd766.js → p-f3759c70.js} +1 -1
- package/dist/zonos-elements/{p-5e09c22d.system.js → p-f55a2352.system.js} +1 -1
- package/dist/zonos-elements/{p-8d87e748.entry.js → p-fc2d5dd9.entry.js} +1 -1
- package/dist/zonos-elements/p-fd2d4d04.system.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +3 -3
- package/dist/cjs/formatStringWithLinks-52341fc7.js +0 -17
- package/dist/esm/formatStringWithLinks-9e819405.js +0 -15
- package/dist/esm-es5/formatStringWithLinks-9e819405.js +0 -1
- package/dist/esm-es5/localization-d49867ed.js +0 -1
- package/dist/zonos-elements/p-21d925d7.entry.js +0 -1
- package/dist/zonos-elements/p-2d6557ee.system.js +0 -1
- package/dist/zonos-elements/p-32704baa.js +0 -1
- package/dist/zonos-elements/p-3cf22558.entry.js +0 -1
- package/dist/zonos-elements/p-45e1c33b.entry.js +0 -1
- package/dist/zonos-elements/p-5d3ea491.system.entry.js +0 -1
- package/dist/zonos-elements/p-6b4ef7e0.entry.js +0 -1
- package/dist/zonos-elements/p-73d3fa61.entry.js +0 -1
- package/dist/zonos-elements/p-7522ec43.js +0 -1
- package/dist/zonos-elements/p-9fab45aa.system.js +0 -1
- package/dist/zonos-elements/p-a87561b8.js +0 -1
- package/dist/zonos-elements/p-c209e36d.js +0 -1
- package/dist/zonos-elements/p-d7bda14d.js +0 -1
- package/dist/zonos-elements/p-d93991c3.system.entry.js +0 -1
- package/dist/zonos-elements/p-e6165cc2.system.js +0 -1
- package/dist/zonos-elements/p-eb9369b9.system.entry.js +0 -1
- package/dist/zonos-elements/p-f3a73132.entry.js +0 -1
- package/dist/zonos-elements/p-ffbf87c8.system.entry.js +0 -1
|
@@ -1 +1 @@
|
|
|
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;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}}};import{c as createStore,z as zonosStore}from"./zonosStore-b7d3f9b0.js";import{t as translate,l as localizationStore,s as storageStore}from"./localization-d49867ed.js";import{l as logError$1,h as handleFetch,s as sendErrorLog}from"./handleFetch-a844cac1.js";import{l as log,b as allLogs}from"./VarianceTest-572cecf5.js";import{b as stripeStore,K as stripeStoreBuildAddressForPartyCreate,d as cartStore,L as cartStoreUpdateSelectedShippingOption}from"./cart-8b8dc79f.js";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);if(t)_defineProperties(e,t);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(r&&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);if(r){n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))}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||{});var UNKNOWN_VALUE="airTracker_unknown";var DEFAULT_CONFIG={appName:UNKNOWN_VALUE,appVersion:UNKNOWN_VALUE,env:"staging",isWebappContainer:false,delay:2e3,errorRepeatTime:3,enableErrorMonitoring:false,assetSpeedMonitoringWhiteList:[],enableDetectPageChange:false,enableRecordPageRetention:false,hideSearchParams:false,useSessionStorageForSessionId:false,assetSpeedMonitoringWhiteListByMFE:{}};var DEFAULT_COMMON_DATA={appName:UNKNOWN_VALUE,env:"staging",sessionId:UNKNOWN_VALUE,deviceId:UNKNOWN_VALUE};var isJSON=function(e){if(!e){return false}if(/^\s*$/.test(e))return false;e=e.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@");e=e.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]");e=e.replace(/(?:^|:|,)(?:\s*\[)+/g,"");return/^[\],:{}\s]*$/.test(e)};var safeReplacer=function(){var e=new WeakSet;return function(r,t){if(_instanceof(t,Error)){return"Error.message: ".concat(t.message," \n Error.stack: ").concat(t.stack)}if((typeof t==="undefined"?"undefined":_type_of(t))==="object"&&t!==null){if(e.has(t)){return"[Circular ".concat(r||"root","]")}e.add(t)}if(typeof t==="function"){return"function"}if((typeof t==="undefined"?"undefined":_type_of(t))==="symbol"){return"symbol"}if(typeof t==="undefined"){return null}return t}};var safeStringify=function(e){if(typeof e==="string"){return e}try{if(_instanceof(e,Error)){return(JSON.stringify(e,safeReplacer())||"undefined").replace(/"/gim,"")}return JSON.stringify(e,safeReplacer())}catch(e){return'{"error":"error happen when airTracker stringify"}'}};var request=function(e){var r=e.method,t=r===void 0?"post":r,n=e.url,i=e.data,o=e.success,a=e.fail;if(!isJSON(i)){return}var s=new XMLHttpRequest;s.addEventListener("readystatechange",(function(){if(s.readyState===4){if(s.status>=400||s.status===0){a===null||a===void 0?void 0:a(s.response)}else{o===null||o===void 0?void 0:o(s.response)}}}));s.open(t,n);s.setRequestHeader("Content-Type","application/json");s.send(i)};var lifeCycleEventName={onInit:"onInit",onConfigInit:"onConfigInit",onConfigUpdated:"onConfigUpdated",onCommonDataInit:"onCommonDataInit",onCommonUpdated:"onCommonUpdated",onPageChange:"onPageChange",onDestroy:"onDestroy,"};var DEVICE_ID_STORAGE_KEY="AIR_ANALYTICS_DEVICE_ID";var SESSION_ID_STORAGE_KEY="AIR_ANALYTICS_SESSION_ID";var RISK_DEVICE_ID_STORAGE_KEY="AWX_RISK_ID";var loggingServiceUrl=function(e){if(e=="prod"){return"https://o11y.airwallex.com/airtracker/logs"}if(e=="demo"){return"https://o11y-demo.airwallex.com/airtracker/logs"}return"https://o11y-staging.airwallex.com/airtracker/logs"};var loggingServiceMetricsUrl=function(e){if(e=="prod"){return"https://o11y.airwallex.com/airtracker/metrics"}if(e=="demo"){return"https://o11y-demo.airwallex.com/airtracker/metrics"}return"https://o11y-staging.airwallex.com/airtracker/metrics"};var generateUId=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=Math.random()*16|0;var t=e==="x"?r:r&3|8;return t.toString(16)}));return e};var getMFEName=function(e){var r,t,n;if(e.config.getMFEName){return e.config.getMFEName()}return((n=location)===null||n===void 0?void 0:(t=n.pathname)===null||t===void 0?void 0:(r=t.split("/"))===null||r===void 0?void 0:r[2])||"unknown"};var getSessionId=function(){try{var e=window.sessionStorage.getItem(SESSION_ID_STORAGE_KEY);if(!e){e=generateUId();window.sessionStorage.setItem(SESSION_ID_STORAGE_KEY,e)}return e}catch(e){return generateUId()}};var getDeviceId=function(){try{var e=window.localStorage.getItem(DEVICE_ID_STORAGE_KEY);if(!e){e=generateUId();window.localStorage.setItem(DEVICE_ID_STORAGE_KEY,e)}return e}catch(e){}};var getRiskDeviceId=function(){try{var e=window.localStorage.getItem(RISK_DEVICE_ID_STORAGE_KEY);return e||void 0}catch(e){}};var getNetworkType=function(){var e;var r="";var t=navigator.userAgent.match(/NetType\/(\w+)/);if(t){var n;n=_sliced_to_array(t,2),r=n[1]}else if((e=navigator)===null||e===void 0?void 0:e.connection){var i,o,a,s;r=((o=navigator)===null||o===void 0?void 0:(i=o.connection)===null||i===void 0?void 0:i.effectiveType)||((s=navigator)===null||s===void 0?void 0:(a=s.connection)===null||a===void 0?void 0:a.type)}if(!r){r="unknown"}return parseNetType(r)};var parseNetType=function(e){e=String(e).toLowerCase();if(e.indexOf("4g")>=0)return"net4g";if(e.indexOf("wifi")>=0)return"wifi";if(e.indexOf("5g")>=0)return"net5g";if(e.indexOf("3g")>=0)return"net3g";if(e.indexOf("2g")>=0)return"net2g";return"unknown"};var canUseResourceTiming=function e(){return typeof window.performance!=="undefined"&&typeof window.performance.clearResourceTimings==="function"&&typeof window.performance.getEntriesByType==="function"&&typeof window.performance.now==="function"};var formatUrl=function(e){if(typeof e==="string"){var r=e.split("?")[0]||"";return r.slice(0,200)}return e};var getQueryString=function(e){if(typeof e==="string"){return e.split("?")[1]||""}return e};var urlIsHttps=function(e){var r=typeof e==="string"&&e.startsWith("//");return r?typeof location!=="undefined"&&location.protocol==="https:":/^https/.test(e)};var getReportVal=function(e,r){if(typeof e==="number"){return e}if(typeof e==="string"){return e}return r?"":-1};var checkIfInWhiteList=function(e,r){var t;var n=false;if(!r.config.isWebappContainer){n=checkIfInWhiteListHelper(e,r.config.assetSpeedMonitoringWhiteList);return n}var i=getMFEName(r);return n||checkIfInWhiteListHelper(e,(t=r.config.assetSpeedMonitoringWhiteListByMFE)===null||t===void 0?void 0:t[i])};var checkIfInWhiteListHelper=function(e,r){if(!(r===null||r===void 0?void 0:r.length)){return false}for(var t=0;t<r.length;t++){var n=r[t];if(_instanceof(n,RegExp)&&n.test(e)){return true}if(typeof n=="string"&&e.includes(n)){return true}}return false};var roundSubtract=function(e,r){var t=100;return Math.round((e-r)*t)/t};var sendNormalLogPipe=function(e){return function(r){var t,n;var i=getMFEName(e);var o=e.config.isWebappContainer?_object_spread({},e.commonData||{},((t=e.MFECommonDataMap)===null||t===void 0?void 0:t[i])||{}):e.commonData;var a=Array.isArray(r)?r:[r];if(a.length===0){return}var s={commonData:o,data:a};var u=safeStringify(s);var l={method:"post",url:loggingServiceUrl(e.commonData.env),data:u};if(typeof((n=navigator)===null||n===void 0?void 0:n.sendBeacon)==="function"){var c=navigator.sendBeacon(l.url,u);if(!c){request(l)}}else{request(l)}}};var sendMetricsLogPipe=function(e){return function(r){var t,n;var i=getMFEName(e);var o=e.config.isWebappContainer?_object_spread({},e.commonData||{},((t=e.MFECommonDataMap)===null||t===void 0?void 0:t[i])||{}):e.commonData;var a={commonData:o,data:Array.isArray(r)?r:[r]};var s=safeStringify(a);var u={method:"post",url:loggingServiceMetricsUrl(e.commonData.env),data:s};if(typeof((n=navigator)===null||n===void 0?void 0:n.sendBeacon)==="function"){var l=navigator.sendBeacon(u.url,s);if(!l){request(u)}}else{request(u)}}};var throttlePipe=function(e,r){var t;var n=[];var i=e.config;window.addEventListener("beforeunload",(function(){if(n.length>0){e.immediateSendPipe(n.splice(0,n.length));t&&clearTimeout(t)}}));return function(o,a){n.push(o);e.lifeCycle.on(lifeCycleEventName.onCommonUpdated,(function(){if(n.length>0){a===null||a===void 0?void 0:a(n.splice(0,n.length));e.lifeCycle.remove(lifeCycleEventName.onCommonUpdated);t&&clearTimeout(t)}}));if(r&&n.length>=r){a===null||a===void 0?void 0:a(n.splice(0,n.length));t&&clearTimeout(t);return}t&&clearTimeout(t);t=setTimeout((function(){t=null;if(n.length>0){a===null||a===void 0?void 0:a(n.splice(0,n.length));e.lifeCycle.remove(lifeCycleEventName.onCommonUpdated)}}),i.delay)}};var errorLogLimitPipe=function(e){var r={};return function(t,n){var i=typeof e.config.errorRepeatTime==="number"?e.config.errorRepeatTime:5;if(i===0){return n===null||n===void 0?void 0:n(t)}n===null||n===void 0?void 0:n(t.filter((function(e){if(e.severity=="autoDetectError"){r[e.error]=r[e.error]||0;r[e.error]+=1;if(r[e.error]>i){return false}return true}return true})))}};var noop=function(){};var createPipeline=function(e){if(!e||!e.reduce||!e.length){throw new TypeError("createPipeline need at least one function param")}if(e.length===1){return function(r,t){e[0](r,t||noop)}}return e.reduce((function(e,r){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:noop;return e(t,(function(e){return r===null||r===void 0?void 0:r(e,n)}))}}))};var EventEmitter=function(){function e(){var r=this;_class_call_check(this,e);this.emit=function(e,t){if(!r)return;var n=r.eventsList[e];var i;if(n===null||n===void 0?void 0:n.length){n=n.slice();for(var o=0;o<n.length;o++){i=n[o];try{var a=i.callback.apply(r,[t]);if(1===i.type){r.remove(e,i.callback)}if(false===a){break}}catch(e){throw e}}}return r};this.eventsList={}}_create_class(e,[{key:"indexOf",value:function e(r,t){for(var n=0;n<r.length;n++){if(r[n].callback===t){return n}}return-1}},{key:"on",value:function e(r,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!this)return;var i=this.eventsList[r];if(!i){this.eventsList[r]=[];i=this.eventsList[r]}if(this.indexOf(i,t)===-1){var o={name:r,type:n||0,callback:t};i.push(o);return this}return this}},{key:"one",value:function e(r,t){this.on(r,t,1)}},{key:"remove",value:function e(r,t){if(!this)return;var n=this.eventsList[r];if(!n){return null}if(!t){try{delete this.eventsList[r]}catch(e){}return null}if(n.length){var i=this.indexOf(n,t);n.splice(i,1)}return this}},{key:"clear",value:function e(){this.eventsList={}}}]);return e}();var AirTrackerPlugin=function(){function e(r){_class_call_check(this,e);this.name="";this.isInit=false;this.name=r.name;this.option=r}_create_class(e,[{key:"patch",value:function e(r){if(!this.isInit){var t,n;this.isInit=true;(n=this.option)===null||n===void 0?void 0:(t=n.setUp)===null||t===void 0?void 0:t.call(this.option,r)}}},{key:"uninstall",value:function e(){var r,t;(t=this.option)===null||t===void 0?void 0:(r=t.destroy)===null||r===void 0?void 0:r.apply(this);this.isInit=false}}]);return e}();var airTracker;var onError=function(e){var r="".concat(safeStringify(e.message)||""," @ (").concat(safeStringify(e.filename)||"",":").concat(e.lineno||0,":").concat(e.colno||0,")\n").concat(safeStringify(e.error||""));airTracker.normalLogPipeLine({severity:"autoDetectError",eventName:"windowOnError",extraInfo:{error:r}})};var unhandledrejectionHandler=function(e){var r=e&&safeStringify(e.reason);airTracker.normalLogPipeLine({severity:"autoDetectError",eventName:"promiseError",extraInfo:{error:r}})};var errorHandler=function(e){var r=(e===null||e===void 0?void 0:e.target)||(e===null||e===void 0?void 0:e.srcElement);if(!r){return}var t=(r===null||r===void 0?void 0:r.src)||(r===null||r===void 0?void 0:r.href);var n=r.tagName;var i="unknown";if(typeof t==="string"&&n){if(window.location.href.indexOf(t)>-1){return}if(/\.js$/.test(t)){i="script"}else if(/\.css$/.test(t)){i="css"}else{switch(n.toLowerCase()){case"script":i="script";break;case"link":i="css";break;case"img":i="image";break;case"audio":case"video":i="media";break;default:return}}airTracker.normalLogPipeLine({severity:"autoDetectError",eventName:"staticFileLoadError",extraInfo:{staticFileType:i,error:"".concat(n," load fail: ").concat(t)}})}};var errorDetectionPlugin=new AirTrackerPlugin({name:"errorDetectionPlugin",setUp:function(e){airTracker=e;window.addEventListener("error",onError);window.addEventListener("unhandledrejection",unhandledrejectionHandler);window.document.addEventListener("error",errorHandler,true)},destroy:function(){window.removeEventListener("unhandledrejection",unhandledrejectionHandler);window.document.removeEventListener("error",errorHandler,true);window.removeEventListener("error",onError)}});var ASSETS_INITIATOR_TYPE=["img","css","script","link","audio","video","iframe"];var COLLECTED_ENTRY_TYPE="resource";var generateSpeedLog=function(e){var r=e.name;return{url:formatUrl(r),method:"get",duration:Number(e.duration.toFixed(2)),type:"static",isHttps:urlIsHttps(r),urlQuery:getQueryString(r),domainLookup:getReportVal(e.domainLookupEnd-e.domainLookupStart),connectTime:getReportVal(e.connectEnd-e.connectStart)}};var publishSpeedLogs=function(e,r){for(var t=0,n=e.length;t<n;t++){var i=e[t];if(ASSETS_INITIATOR_TYPE.indexOf(i.initiatorType)!==-1&&checkIfInWhiteList(i.name,r)){r.normalLogPipeLine({severity:"performance",eventName:"assets_speed",extraInfo:{log:generateSpeedLog(i)}})}}};var interval;var observer;var assetSpeedPlugin=new AirTrackerPlugin({name:"assetsSpeedPlugin",setUp:function(e){if(!canUseResourceTiming())return;var r=0;window.performance.onresourcetimingbufferfull=function(){r=0;window.performance.clearResourceTimings()};if(typeof window.PerformanceObserver==="function"){publishSpeedLogs(window.performance.getEntriesByType(COLLECTED_ENTRY_TYPE),e);observer=new window.PerformanceObserver((function(r){publishSpeedLogs(r.getEntries(),e)}));observer.observe({entryTypes:[COLLECTED_ENTRY_TYPE]})}else{interval=setInterval((function(){var t=window.performance.getEntriesByType(COLLECTED_ENTRY_TYPE);var n=t.slice(r);r=t.length;publishSpeedLogs(n,e)}),3e3)}},destroy:function(){observer===null||observer===void 0?void 0:observer.disconnect();interval&&clearInterval(interval)}});var observer2;var onPageChangePlugin=new AirTrackerPlugin({name:"onPageChangePlugin",setUp:function(){var e=_async_to_generator((function(e){var r,t,n,i,o;return _ts_generator(this,(function(a){t=(r=location)===null||r===void 0?void 0:r.href;n=document.querySelector("body");i=function(r){var t=r.prevHref;var n,i,o,a,s;e.normalLogPipeLine({severity:"autoDetectEvent",eventName:"onPageChange",extraInfo:{prevHref:t,href:((n=location)===null||n===void 0?void 0:n.href)||"",hostname:(i=location)===null||i===void 0?void 0:i.hostname,pathName:(o=location)===null||o===void 0?void 0:o.pathname,protocol:(a=location)===null||a===void 0?void 0:a.protocol,search:(s=location)===null||s===void 0?void 0:s.search}})};i({prevHref:""});observer2=new MutationObserver((function(){if(location.href!==t){var e=t;t=location.href;i({prevHref:e})}}));o={subtree:true,childList:true};observer2.observe(n||document,o);return[2]}))}));return function(r){return e.apply(this,arguments)}}(),destroy:function(){observer2===null||observer2===void 0?void 0:observer2.disconnect()}});var observer3;var onPageRetentionPlugin=new AirTrackerPlugin({name:"onPageRetentionPlugin",setUp:function(){var e=_async_to_generator((function(e){var r,t,n,i,o,a,s;return _ts_generator(this,(function(u){if(typeof document.visibilityState==="undefined"){return[2]}t=(r=location)===null||r===void 0?void 0:r.href;n=document.querySelector("body");o=function(){i=Date.now()};o();document.addEventListener("visibilitychange",(function(){if(document.visibilityState==="hidden"){a({href:location.href,leftReason:"visibilityChange"})}else if(document.visibilityState==="visible"){o()}}));window.addEventListener("beforeunload",(function(){a({href:location.href,sendImmediate:true,leftReason:"pageClose"})}));a=function(r){var t=r.href,n=r.sendImmediate,o=r.leftReason;if(!i){return}var a=Date.now()-i;if(a===0){return}i=void 0;var s={severity:"autoDetectEvent",eventName:"onPageRetention",extraInfo:{href:t,duration:a,leftReason:o}};if(n){e.ImmediatePipeline(s);return}e.normalLogPipeLine(s)};observer3=new MutationObserver((function(){if(location.href!==t){var e=t;t=location.href;a({href:e,leftReason:"nextPage"});o()}}));s={subtree:true,childList:true};observer3.observe(n||document,s);return[2]}))}));return function(r){return e.apply(this,arguments)}}(),destroy:function(){observer3===null||observer3===void 0?void 0:observer3.disconnect()}});var generateRandomId=function(){return Date.now().toString(36)+Math.random().toString(36).substring(2,15)};var checkIfInWhiteList2=function(e,r){var t=[/^https?:\/\/[^\/]*\.airwallex\.com($|\/)/];var n=[/authenticate\/heartbeat/,/papluginlogs\/.*/,/airtracker\/.*/,/o11y(-staging|-demo)?\.airwallex\.com/,/\.(png|jpe?g|gif|svg|ico|webp|avif|css|js|json|woff2?|ttf|eot|map|txt|csv|xml)(\?.*)?(#.*)?$/i];if(n.some((function(r){return r.test(e)}))){return false}return checkIfInWhiteListHelper(e,r||t)};var findMainEntry=function(e){var r=e.startTime,t=e.endTime,n=e.entries;if(n.length===0){return void 0}if(n.length===1){return n[0]}var i=n.filter((function(e){return e.startTime>=r&&t&&e.responseEnd<=t})).sort((function(e,r){return e.startTime-r.startTime}));return i===null||i===void 0?void 0:i[0]};var round2Decimal=function(e){return Math.round(e*100)/100};var processPerformanceEntry=function(e){var r=e.startTime,t=e.duration,n=e.responseStart,i=e.connectEnd,o=e.connectStart,a=e.domainLookupEnd,s=e.domainLookupStart,u=e.requestStart,l=e.secureConnectionStart,c=e.redirectEnd,d=e.redirectStart,f=e.responseStatus,v=e.responseEnd,p=e.encodedBodySize,m=e.decodedBodySize,_=e.transferSize,h=e.deliveryType,y=e.initiatorType;return{startTime:round2Decimal(r),totalDuration:round2Decimal(t),timeToFirstByte:roundSubtract(n,r),tcpDuration:roundSubtract(i,o),dnsDuration:roundSubtract(a,s),tlsDuration:roundSubtract(u,l),redirectDuration:roundSubtract(c,d),responseDuration:roundSubtract(v,n),encodeResponseSize:p,decodeResponseSize:m,transferSize:_,deliveryType:h,statusCode:f,initiatorType:y}};var getPayload=function(e,r){var t=e.url,n=e.method,i=e.errorType,o=e.errorDetail;var a=findMainEntry(e);var s=new URL(t,window.location.href),u=s.href,l=s.protocol;var c=a?processPerformanceEntry(a):{};var d={severity:"autoDetectEvent",eventName:"httpClientMetrics",extraInfo:_object_spread(_object_spread_props(_object_spread({httpUrl:u,method:n,scheme:l},i&&{errorType:i},o&&{errorDetail:o},c),{statusCode:(c===null||c===void 0?void 0:c.statusCode)||(e===null||e===void 0?void 0:e.responseStatus),startTime:(c===null||c===void 0?void 0:c.startTime)||(e===null||e===void 0?void 0:e.startTime),initiatorType:(c===null||c===void 0?void 0:c.initiatorType)||(e===null||e===void 0?void 0:e.initiatorType)}),r)};return d};var isGraphQLError=function(e){return e&&(typeof e==="undefined"?"undefined":_type_of(e))==="object"&&"errors"in e&&Array.isArray(e.errors)&&e.errors.every((function(e){return e&&(typeof e==="undefined"?"undefined":_type_of(e))==="object"&&"message"in e}))};var API_PERFORMANCE_QUEUE="awx_airtracker_api_performance_queue";var API_PERFORMANCE_PLUGIN_LOADED="awx_airtracker_api_performance_plugin_loaded";var OBSERVER_WAIT_TIME_MS=300;var TIMEOUT_WAIT_TIME_MS=1e4;var globalObject=typeof window!=="undefined"?window:typeof global!=="undefined"?global:{};globalObject[API_PERFORMANCE_QUEUE]=globalObject[API_PERFORMANCE_QUEUE]||[];var handlePayloadAndSendLog=function(e,r,t){setTimeout((function(){var n=getPayload(e,t);r.observerPipeline(n);globalObject[API_PERFORMANCE_QUEUE]=globalObject[API_PERFORMANCE_QUEUE].filter((function(r){return r.id!==e.id}))}),OBSERVER_WAIT_TIME_MS)};var handleTimeout=function(e,r){setTimeout((function(){var t=globalObject[API_PERFORMANCE_QUEUE].find((function(r){return r.id===e}));if(!t){return}var n=getPayload(t,{exceptionType:"timeout-without-response"});r.observerPipeline(n);globalObject[API_PERFORMANCE_QUEUE]=globalObject[API_PERFORMANCE_QUEUE].filter((function(r){return r.id!==e}))}),TIMEOUT_WAIT_TIME_MS)};var injectXMLHttpRequest=function(e){var r=XMLHttpRequest.prototype.open;var t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function t(n,i,o,a,s){try{var u;var l=generateRandomId();this.__requestId=l;var c=_instanceof(i,URL)?i.href:new URL(i,window.location.href).href;if(!checkIfInWhiteList2(c,(u=e.config)===null||u===void 0?void 0:u.enableRecordAPIPerformanceWhitelist)){return r.call(this,n,i,o!==null&&o!==void 0?o:true,a,s)}var d={id:l,startTime:performance.now(),method:n,url:c,entries:[],initiatorType:"xmlhttprequest"};globalObject[API_PERFORMANCE_QUEUE].push(d);handleTimeout(l,e);return r.call(this,n,i,o!==null&&o!==void 0?o:true,a,s)}catch(t){e.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Inject XHR open error",error:t}});return r.call(this,n,i,o!==null&&o!==void 0?o:true,a,s)}};XMLHttpRequest.prototype.send=function r(){var n=this;for(var i=arguments.length,o=new Array(i),a=0;a<i;a++){o[a]=arguments[a]}try{var s=globalObject[API_PERFORMANCE_QUEUE].find((function(e){return e.id===n.__requestId}));if(!s){return t.apply(this,o)}var u=this;this.addEventListener("loadend",_async_to_generator((function(){var r,t,n,i,o,a,l;return _ts_generator(this,(function(c){switch(c.label){case 0:r=performance.now();t=r-s.startTime;n=u.status;if(n===0){return[2]}s.endTime=r;s.duration=t;s.responseStatus=n;c.label=1;case 1:c.trys.push([1,6,,7]);if(!(u.responseType===""||u.responseType==="text"))return[3,2];i=u.responseText;return[3,5];case 2:if(!(u.responseType==="json"))return[3,3];i=u.response;return[3,5];case 3:if(!(u.responseType==="blob"))return[3,5];o=u.response;if(!((o===null||o===void 0?void 0:o.type)==="application/json"))return[3,5];return[4,o.text()];case 4:i=c.sent();c.label=5;case 5:a=i&&typeof i==="string"?JSON.parse(i):i;if(a&&isGraphQLError(a)){s.errorType="graphqlError";s.errorDetail=a.errors}return[3,7];case 6:l=c.sent();e.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Parse response body error in XHR",url:s===null||s===void 0?void 0:s.url,error:l}});return[3,7];case 7:handlePayloadAndSendLog(s,e);return[2]}}))})));this.addEventListener("error",(function(){handlePayloadAndSendLog(s,e,{exceptionType:"network-error"})}));this.addEventListener("abort",(function(){handlePayloadAndSendLog(s,e,{exceptionType:"abort-error"})}));this.addEventListener("timeout",(function(){handlePayloadAndSendLog(s,e,{exceptionType:"timeout-error"})}));return t.apply(this,o)}catch(r){e.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"InjectXHR send error",error:r}});throw r}}};var injectFetch=function(e){var r=window.fetch;window.fetch=_async_to_generator((function(){var t,n,i,o,a,s,u,l,c,d,f,v,p,m,_,h;var y=arguments;return _ts_generator(this,(function(g){switch(g.label){case 0:for(t=y.length,n=new Array(t),i=0;i<t;i++){n[i]=y[i]}s=new URL(_instanceof(n[0],Request)?n[0].url:String(n[0]),window.location.href).href;if(!!checkIfInWhiteList2(s,(o=e.config)===null||o===void 0?void 0:o.enableRecordAPIPerformanceWhitelist))return[3,2];return[4,r.apply(this,n)];case 1:return[2,g.sent()];case 2:g.trys.push([2,9,,10]);l=performance.now();c=generateRandomId();a={id:c,startTime:l,method:((u=_instanceof(n[0],Request)?n[0]:n[1])===null||u===void 0?void 0:u.method)||"GET",url:s,entries:[],initiatorType:"fetch"};globalObject[API_PERFORMANCE_QUEUE].push(a);handleTimeout(c,e);return[4,r.apply(this,n)];case 3:d=g.sent();f=performance.now();a.endTime=f;a.duration=f-l;a.responseStatus=d.status;v=d.clone();g.label=4;case 4:g.trys.push([4,7,,8]);if(!v.ok)return[3,6];return[4,v.json()];case 5:p=g.sent();if(p&&isGraphQLError(p)){a.errorType="graphqlError";a.errorDetail=p.errors}g.label=6;case 6:return[3,8];case 7:m=g.sent();e.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Parse response body error in fetch",url:a===null||a===void 0?void 0:a.url,error:m}});return[3,8];case 8:handlePayloadAndSendLog(a,e);return[2,d];case 9:_=g.sent();if(a&&a.id&&globalObject[API_PERFORMANCE_QUEUE].find((function(e){return e.id===(a===null||a===void 0?void 0:a.id)}))){h="fetch-error";if(_instanceof(_,TypeError)){h="network-error"}else if(_instanceof(_,DOMException)&&_.name==="AbortError"){h="abort-error"}handlePayloadAndSendLog(a,e,{exceptionType:h})}else{e.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Inject fetch error",error:_}})}throw _;case 10:return[2]}}))}))};var setUpAPIPerformancePlugin=function(e){var r;injectXMLHttpRequest(e);injectFetch(e);if((r=window)===null||r===void 0?void 0:r.PerformanceObserver){var t=new window.PerformanceObserver((function(e){var r=e.getEntries();r.forEach((function(e){var r=e;if(r.initiatorType==="fetch"||r.initiatorType==="xmlhttprequest"){var t=globalObject[API_PERFORMANCE_QUEUE].filter((function(e){return e.url===r.name}));t.forEach((function(e){e.entries.push(r)}))}}))}));t.observe({entryTypes:["resource"],buffered:true})}else{e.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{error:"PerformanceObserver Not Supported"}})}};var apiPerformancePlugin=new AirTrackerPlugin({name:"apiPerformancePlugin",setUp:function(){var e=_async_to_generator((function(e){var r,t;return _ts_generator(this,(function(n){if(globalObject[API_PERFORMANCE_PLUGIN_LOADED]){return[2]}if(((r=e.config)===null||r===void 0?void 0:r.enableRecordAPIPerformance)&&Math.random()<(((t=e.config)===null||t===void 0?void 0:t.enableRecordAPIPerformancePercentage)||0)){globalObject[API_PERFORMANCE_PLUGIN_LOADED]=true;setUpAPIPerformancePlugin(e)}return[2]}))}));return function(r){return e.apply(this,arguments)}}()});var SDK_VERSION="3.1.0";var AirTracker=function(){function e(r){var t=this;var n=r.config,i=r.plugins,o=i===void 0?[]:i;_class_call_check(this,e);this.config=DEFAULT_CONFIG;this.lifeCycle=new EventEmitter;this.plugins=[];this._commonData=DEFAULT_COMMON_DATA;this._MFECommonDataMap={};this.timeMap={};this.packedDataConvert=function(e){var r=e.severity,n=e.eventName,i=e.extraInfo;var o,a;var s=_object_spread({severity:r,eventName:n,currentHref:t.config.hideSearchParams?(((o=location)===null||o===void 0?void 0:o.href)||"").split("?")[0]||"":((a=location)===null||a===void 0?void 0:a.href)||""},i);if(t.config.isWebappContainer){s.MFEName=getMFEName(t)}return s};this.normalPipelineObj=createPipeline([throttlePipe(this,8),errorLogLimitPipe(this),sendNormalLogPipe(this)]);this.observerPipelineObj=createPipeline([throttlePipe(this,8),sendMetricsLogPipe(this)]);this.immediateSendPipe=sendNormalLogPipe(this);this.observerPipeline=function(e){var r=e.severity,n=e.eventName,i=e.extraInfo;var o=t.packedDataConvert({severity:r,eventName:n,extraInfo:i});return t.observerPipelineObj(o)};this.normalLogPipeLine=function(e){var r=e.severity,n=e.eventName,i=e.extraInfo;var o=t.packedDataConvert({severity:r,eventName:n,extraInfo:i});if(t.config.disableThrottle){return t.immediateSendPipe(o)}else{return t.normalPipelineObj(o)}};this.ImmediatePipeline=function(e){var r=e.severity,n=e.eventName,i=e.extraInfo;var o=t.packedDataConvert({severity:r,eventName:n,extraInfo:i});return t.immediateSendPipe(o)};this.plugins=_to_consumable_array(o);this.setConfig(n);this.initCommonData(n);this.lifeCycle.emit(lifeCycleEventName.onInit);if(n.enableErrorMonitoring){this.plugins.push(errorDetectionPlugin)}if((n===null||n===void 0?void 0:n.assetSpeedMonitoringWhiteList)&&n.assetSpeedMonitoringWhiteList.length>0||n.isWebappContainer){this.plugins.push(assetSpeedPlugin)}if(n===null||n===void 0?void 0:n.enableDetectPageChange){this.plugins.push(onPageChangePlugin)}if(n===null||n===void 0?void 0:n.enableRecordPageRetention){this.plugins.push(onPageRetentionPlugin)}if((n===null||n===void 0?void 0:n.enableRecordAPIPerformance)&&(n===null||n===void 0?void 0:n.enableRecordAPIPerformancePercentage)&&n.enableRecordAPIPerformancePercentage>0&&n.enableRecordAPIPerformancePercentage<=1){this.plugins.push(apiPerformancePlugin)}this.installPlugins()}_create_class(e,[{key:"installPlugins",value:function e(){var r=this;this.plugins.forEach((function(e){e.patch(r)}))}},{key:"commonData",get:function e(){return this._commonData}},{key:"MFECommonDataMap",get:function e(){return this._MFECommonDataMap}},{key:"initCommonData",value:function e(r){this._commonData.sessionId=r.useSessionStorageForSessionId?getSessionId():generateUId();this._commonData.deviceId=getDeviceId()||UNKNOWN_VALUE;this._commonData.riskDeviceId=getRiskDeviceId();this._commonData.networkType=getNetworkType()||"unknown";this._commonData.env=r.env||this._commonData.env;this._commonData.accountId=r.accountId||UNKNOWN_VALUE;this._commonData.appVersion=r.appVersion;this._commonData.appName=r.appName;this._commonData.sdkVersion=SDK_VERSION;this.lifeCycle.emit(lifeCycleEventName.onCommonDataInit,this.commonData)}},{key:"updateCommonDataBasedOnConfig",value:function e(r){this.lifeCycle.emit(lifeCycleEventName.onCommonUpdated,this._commonData);this._commonData.env=r.env||this._commonData.env;this._commonData.appName=r.appName||this._commonData.appName;this._commonData.env=r.env||this._commonData.env;this._commonData.accountId=r.accountId||this._commonData.accountId;this._commonData.appVersion=r.appVersion||this._commonData.appVersion}},{key:"updateCommonData",value:function e(r){this.lifeCycle.emit(lifeCycleEventName.onCommonUpdated,this._commonData);this._commonData=_object_spread({},this._commonData,r)}},{key:"removeCommonDataByKey",value:function e(r){var t=this;this.lifeCycle.emit(lifeCycleEventName.onCommonUpdated,this._commonData);setTimeout((function(){r.forEach((function(e){delete t._commonData[e]}))}),1e3)}},{key:"addToMFECommonData",value:function e(r){var t=r.MFEName,n=r.MFECommonData;var i;if(!this.config.isWebappContainer){return}if(!t||!n){return}this._MFECommonDataMap=_object_spread_props(_object_spread({},this._MFECommonDataMap||{}),_define_property({},t,_object_spread({},((i=this._MFECommonDataMap)===null||i===void 0?void 0:i[t])||{},n)))}},{key:"setConfig",value:function e(r){var t=this;if(this.config.isWebappContainer){return}var n=function(e,r){t.config[e]=r};Object.entries(r).forEach((function(e){var r=_sliced_to_array(e,2),t=r[0],i=r[1];if((typeof i==="undefined"?"undefined":_type_of(i))!==void 0){n(t,i)}}));this.lifeCycle.emit(lifeCycleEventName.onConfigInit,this.config);this.updateCommonDataBasedOnConfig(r)}},{key:"verbose",value:function e(r,t){this.normalLogPipeLine({severity:"verbose",eventName:r,extraInfo:t})}},{key:"httpLog",value:function e(r,t){this.normalLogPipeLine({severity:"http",eventName:r,extraInfo:t})}},{key:"info",value:function e(r,t){this.normalLogPipeLine({severity:"info",eventName:r,extraInfo:t})}},{key:"warn",value:function e(r,t){this.normalLogPipeLine({severity:"warn",eventName:r,extraInfo:t})}},{key:"error",value:function e(r,t){console.error("error",r);this.normalLogPipeLine({severity:"error",eventName:r,extraInfo:t})}},{key:"businessLog",value:function e(r,t){this.normalLogPipeLine({severity:"info",eventName:r,extraInfo:_object_spread_props(_object_spread({},t),{isBusinessLog:true})})}},{key:"reportDuration",value:function e(r,t,n){if(typeof r!=="string"){console.warn("reportDuration: eventName (first param) must be a string");return}if(typeof t!=="number"){console.warn("reportDuration: duration (second param) must be number");return}if(t<0||t>6e4){console.warn("reportDuration: duration (second param) must between 0 and 60000");return}this.normalLogPipeLine({severity:"speed",eventName:r,extraInfo:_object_spread({duration:t},n)})}},{key:"getTimerKey",value:function e(r){var t=getMFEName(this);return this.config.isWebappContainer?"".concat(t,"_").concat(r):r}},{key:"timeStart",value:function e(r){if(typeof r!=="string"){console.warn("time: first param must be a string");return}if(this.timeMap[this.getTimerKey(r)]){console.warn("Timer ".concat(r," already exists"))}this.timeMap[this.getTimerKey(r)]=Date.now()}},{key:"timeEnd",value:function e(r,t){if(typeof r!=="string"){console.warn("timeEnd: first param must be a string");return}if(this.timeMap[this.getTimerKey(r)]){var n=Date.now()-this.timeMap[this.getTimerKey(r)]+(t||0);this.normalLogPipeLine({severity:"speed",eventName:r,extraInfo:{duration:n}});delete this.timeMap[this.getTimerKey(r)]}else{console.warn("Timer key :".concat(r," does not exist"))}}},{key:"addToAssetSpeedWhiteListByMFE",value:function e(r){var t=r.MFEName,n=r.whiteList;var i;if(!this.config.isWebappContainer){return}if(!t||!(n===null||n===void 0?void 0:n.length)){return}if(!this.config.assetSpeedMonitoringWhiteListByMFE){this.config.assetSpeedMonitoringWhiteListByMFE={}}if(!((i=this.config.assetSpeedMonitoringWhiteListByMFE)===null||i===void 0?void 0:i[t])){this.config.assetSpeedMonitoringWhiteListByMFE=_object_spread_props(_object_spread({},this.config.assetSpeedMonitoringWhiteListByMFE),_define_property({},t,n))}else{var o;var a,s;(s=this.config.assetSpeedMonitoringWhiteListByMFE)===null||s===void 0?void 0:(a=s[t])===null||a===void 0?void 0:(o=a).push.apply(o,_to_consumable_array(n))}}},{key:"destroy",value:function e(){if(this.config.isWebappContainer){return}this.plugins.forEach((function(e){e.uninstall()}))}}]);return e}();var src_default=AirTracker;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(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())}))}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){if(t||arguments.length===2)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 name="@airwallex/components-sdk";var version="1.30.2";var main="./lib/index.js";var module="./lib/index.mjs";var types="./lib/index.d.ts";var files=["lib/**"];var license="MIT";var scripts={"load-types":"node ./load-types.js && yarn prettier -w src/types/*d.ts",prebuild:"yarn clean",build:"yarn rollup --config",postbuild:"yarn bundle-types","bundle-types":"dts-bundle-generator -o ./lib/index.d.ts ./src/index.ts",clean:"rm -rf dist lib",lint:'eslint "src/**/*.ts*"',test:"jest",sonar:"sonar-scanner",release:"semantic-release","lint-stage":"lint-staged",prepare:"husky"};var prettier={semi:true,singleQuote:true,printWidth:80,trailingComma:"all"};var publishConfig={access:"public"};var devDependencies={"@babel/preset-typescript":"^7.18.6","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^11.1.6","@semantic-release/changelog":"^5.0.1","@semantic-release/commit-analyzer":"^8.0.1","@semantic-release/git":"^9.0.0","@semantic-release/gitlab":"^6.1.0","@semantic-release/release-notes-generator":"^9.0.0","@swc/core":"^1.3.46","@types/jest":"^29.5.0","@typescript-eslint/eslint-plugin":"^5.57.0","@typescript-eslint/parser":"^5.57.0","dts-bundle-generator":"^9.0.0",eslint:"^7.23.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^5.1.3",husky:"^9.0.11",jest:"^29.5.0","jest-environment-jsdom":"^29.5.0","lint-staged":"^15.2.7",prettier:"^3.3.2",rollup:"^4.9.6","semantic-release":"^17.3.8","sonarqube-scanner":"^3.0.1","ts-jest":"^29.0.5","ts-loader":"^9.5.1",tslib:"^2.6.2",typescript:"^4.5.2"};var dependencies={"@airwallex/airtracker":"^3.0.0"};var packageJson={name:name,version:version,main:main,module:module,types:types,files:files,license:license,scripts:scripts,prettier:prettier,"lint-staged":{"src/**/*.{ts,tsx}":["yarn lint"],"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}":"prettier --write"},publishConfig:publishConfig,devDependencies:devDependencies,dependencies:dependencies};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=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"};var ELEMENT_TO_SDK={kyc:"kyc",paymentsKyb:"paymentsKyb",kycRfi:"rfi",transactionRfi:"rfi",paymentEnablementRfi:"rfi",lendingRfi:"rfi",mrmRfi:"rfi",payoutForm:"payouts",beneficiaryForm:"payouts",hpp:"payments",cvc:"payments",card:"payments",expiry:"payments",dropIn:"payments",cardNumber:"payments",applePayButton:"payments",googlePayButton:"payments",krCardNumber:"payments",krCardIdentifier:"payments",krCardExpiry:"payments",krCardPswFirstTwo:"payments",scaSetup:"sca",scaVerify:"sca",scaManagement:"sca",taxForm:"taxForm",embeddedCheckout:"billing"};var ELEMENT_GROUP_TO_ELEMENT={payments:["hpp","cvc","card","expiry","dropIn","cardNumber","applePayButton","googlePayButton","krCardNumber","krCardIdentifier","krCardExpiry","krCardPswFirstTwo"],payouts:["payoutForm","beneficiaryForm"],onboarding:["kyc","paymentsKyb"],risk:["scaSetup","scaVerify","scaManagement","transactionRfi","kycRfi","paymentEnablementRfi","lendingRfi","mrmRfi"],billing:["embeddedCheckout"]};var SDK_DEPENDENCIES={billing:["payments"]};var DOMAIN_FUNCTIONS_NAMESPACES=["payments","sca"];var InvalidStaticResourceError=function(e){__extends(r,e);function r(r){var t=e.call(this,r)||this;t.code="INVALID_STATIC_RESOURCE_ERROR";return t}return r}(Error);var timestamp=Date.now();var isElementGroup=function(e){return Object.keys(ELEMENT_GROUP_TO_ELEMENT).includes(e)};var sleep=function(e){if(e===void 0){e=500}return new Promise((function(r){return window.setTimeout(r,e)}))};var getSDKByElementName=function(e){return ELEMENT_TO_SDK[e]};var getHost=function(e,r){var t=e===PAYMENTS?PA_STATIC_HOST:STATIC_HOST;return t[r]||t.prod};var getSDKsByEnabledElements=function(e){var r=e.reduce((function(e,r){return e.concat(isElementGroup(r)?ELEMENT_GROUP_TO_ELEMENT[r]:r)}),[]);return Array.from(new Set(r)).map((function(e){return{elementName:e,sdkName:getSDKByElementName(e)}}))};var getFunctionsByEnabledElements=function(e){return Array.from(new Set(getSDKsByEnabledElements(e).map((function(e){var r=e.sdkName;return r})).filter((function(e){return DOMAIN_FUNCTIONS_NAMESPACES.includes(e)}))))};var getWindowSDKInstanceName=function(e){return e==="payments"?"payment":e};var getSDKUrl=function(e){var r=e.name,t=e.env,n=t===void 0?ENV.prod:t;var i=getHost(r,n);var o=SDK_URL_MAPPING[r];if(!o){logError("[components-sdk] Element static resource not found",{sdkName:r});throw new InvalidStaticResourceError("Element ".concat(r," static resource URL is invalid."))}return"".concat(i).concat(o,"?ts=").concat(timestamp)};var getFunctionsInstanceWithNamespace=function(){return DOMAIN_FUNCTIONS_NAMESPACES.reduce((function(e,r){var t;return __assign(__assign({},e),(t={},t[r]=window._AirwallexSDKs.__controller__.internalSDKs[r],t))}),{})};var getSDKDependencies=function(e){return SDK_DEPENDENCIES[e]||[]};var now=function(){return Math.floor(performance.now())};var createScript=function(e){var r=document.createElement("script");r.src=e;r.type="module";var t=document.head||document.body;t.appendChild(r);return r};var MAX_RETRY_COUNT=3;var loadScript=function(e){return __awaiter(void 0,void 0,void 0,(function(){var r,t;return __generator(this,(function(n){switch(n.label){case 0:if(typeof window==="undefined"){throw new Error("Please load script in browser environment")}r=0;t=function(){return __awaiter(void 0,void 0,void 0,(function(){var t,n,i;return __generator(this,(function(o){t=now();if(r>0&&e.includes("?ts=")){n=new URL(e,window.location.href);n.searchParams.set("ts","".concat(Date.now()));e=n.toString()}i=createScript(e);return[2,new Promise((function(n,o){i.addEventListener("load",(function(){var i=now();logInfo("[components-sdk] SDK script loaded",{scriptUrl:e,start:t,latency:i-t,end:i,retryCount:r});n(true)}));i.addEventListener("error",(function(n){i.remove();console.error(n);var a=now();logError("[components-sdk] Failed to load script",{scriptUrl:e,error:n,start:t,latency:a-t,end:a,retryCount:r});o(new LoadScriptError("Failed to load Airwallex SDK scripts: ".concat(e)))}))}))]}))}))};n.label=1;case 1:if(!(r<MAX_RETRY_COUNT))return[3,7];n.label=2;case 2:n.trys.push([2,4,,6]);return[4,t()];case 3:return[2,n.sent()];case 4:n.sent();r++;return[4,sleep()];case 5:n.sent();return[3,6];case 6:return[3,1];case 7:logError("[components-sdk] Failed to load script after retry",{scriptUrl:e,retryCount:r});throw new LoadScriptError("Failed to load Airwallex SDK scripts: ".concat(e))}}))}))};var InstanceNotFoundError=function(e){__extends(r,e);function r(r){var t=e.call(this,r)||this;t.code="INSTANCE_NOT_FOUND_ERROR";return t}return r}(Error);var initPromise$1;var promiseMap=new Map;var getLoadScriptPromise=function(e){var r=e.env,t=e.scriptName;var n=getSDKUrl({name:t,env:r});var i=promiseMap.get(t);if(i){return i}var o=loadScript(n);promiseMap.set(t,o);return o};var loadSDKWithDependencies=function(e){var r=e.env,t=e.scriptName;return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(n){switch(n.label){case 0:e=getSDKDependencies(t);if(!(e.length>0))return[3,2];return[4,Promise.all(e.map((function(e){return getLoadScriptPromise({env:r,scriptName:e})})))];case 1:n.sent();n.label=2;case 2:return[2,getLoadScriptPromise({env:r,scriptName:t})]}}))}))};var init=function(e){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(r){if(typeof window==="undefined"){throw new Error("Please call the `init()` function in a browser environment.")}initializeAirTracker(e.env,e.clientId);logInfo("[components-sdk] SDK init start",{options:maskPII(e),start:now()});initPromise$1=new Promise((function(r,t){var n;var i=__assign(__assign({},e),{env:e.env&&ENV[e.env]?e.env:ENV.prod});window.AirwallexComponentsSDK.__env__=i.env;var o=getLoadScriptPromise({env:i.env,scriptName:SDK_CONTROLLER}).then((function(){return window._AirwallexSDKs.__controller__.init(i)}));var a=(n=e.enabledElements)!==null&&n!==void 0?n:[];var s=getFunctionsByEnabledElements(a);var u=s.map((function(e){return getLoadScriptPromise({env:i.env,scriptName:e}).then((function(){return o})).then((function(){var r=window._AirwallexSDKs[getWindowSDKInstanceName(e)];if(!r){logError("[components-sdk] SDK instance not found",{functionsNamespace:e,windowSDKInstanceName:getWindowSDKInstanceName(e)});throw new InstanceNotFoundError("SDK instance not found")}return window._AirwallexSDKs.__controller__.registerFunctions({functionsNamespace:e,instance:r})}))}));var l=getSDKsByEnabledElements(a);var c=l.map((function(e){var r=e.sdkName,t=e.elementName;return loadSDKWithDependencies({scriptName:r,env:i.env}).then((function(){return o})).then((function(){var e=window._AirwallexSDKs[getWindowSDKInstanceName(r)];if(!e){logError("[components-sdk] SDK instance not found",{sdkName:r,windowSDKInstanceName:getWindowSDKInstanceName(r)});throw new InstanceNotFoundError("SDK instance not found")}return window._AirwallexSDKs.__controller__.registerElement({sdkName:r,elementName:t,instance:e})}))}));Promise.all(__spreadArray(__spreadArray([o],u,true),c,true)).then((function(){logInfo("[components-sdk] SDK initialized",{options:maskPII(e),start:now()});r(getFunctionsInstanceWithNamespace())}))["catch"]((function(e){if(!e.code){logError("[components-sdk] Unexpected errors when init",{error:e})}t(e)}))}));return[2,initPromise$1]}))}))};var createElement=function(e,r){return __awaiter(void 0,void 0,void 0,(function(){var t,n,i,o,a;return __generator(this,(function(s){switch(s.label){case 0:if(!e){throw new Error("Element type is missing. Please specify a valid element.")}logInfo("[components-sdk] SDK createElement start",{elementName:e,options:maskPII(r),timestamp:now()});if(!initPromise$1){logWarning("[components-sdk] Did not call init before createElement");throw new Error("Please initialize the Element before creating it.")}return[4,initPromise$1];case 1:s.sent();t=getSDKByElementName(e);if(!t){throw new Error("`createElement()` with type `".concat(e,"` is not supported. Please specify a valid Element type."))}n=now();s.label=2;case 2:s.trys.push([2,6,,7]);return[4,loadSDKWithDependencies({scriptName:t,env:window.AirwallexComponentsSDK.__env__||ENV.prod})];case 3:s.sent();return[4,window._AirwallexSDKs.__controller__.registerElement({sdkName:t,elementName:e,instance:window._AirwallexSDKs[getWindowSDKInstanceName(t)]})];case 4:s.sent();return[4,window._AirwallexSDKs.__controller__.createElement(e,r)];case 5:i=s.sent();o=now();logInfo("[components-sdk] SDK createElement being called",{elementName:e,options:maskPII(r),start:n,latency:o-n,end:o});return[3,7];case 6:a=s.sent();if(!a.code){logError("[components-sdk] Unexpected errors when createElement",{error:a})}else{throw a}return[3,7];case 7:return[2,i]}}))}))};var PREFETCH_SCRIPT_LIST=[SDK_CONTROLLER,PAYMENTS];var prefetchScripts=function(){PREFETCH_SCRIPT_LIST.forEach((function(e){var r=getSDKUrl({name:e,env:ENV.prod});var t=document.createElement("link");t.href=r;t.rel="modulepreload";t.as="script";var n=document.head||document.body;n.appendChild(t)}))};var isNode=typeof document==="undefined"||typeof window==="undefined";if(!isNode){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",prefetchScripts)}else{prefetchScripts()}}if(typeof window!=="undefined"){if(!window.AirwallexComponentsSDK){Object.defineProperties(window,{AirwallexComponentsSDK:{value:{},writable:false},_AirwallexSDKs:{value:{},writable:false}})}window.AirwallexComponentsSDK.init=init;window.AirwallexComponentsSDK.createElement=createElement}var _l=createStore((function(){return{clientSecret:null,currency:null,hasPaymentError:false,isReady:false,paymentConfirmed:false,paymentIntentId:null}})),airwallexStoreOnChange=_l.onChange,airwallexStoreReset=_l.reset,airwallexStore=_l.state;var airwallexStoreSetFromSession=function(e){if(e.paymentProcessor!=="AIRWALLEX"){return false}if(e.clientSecret){airwallexStore.clientSecret=e.clientSecret}if(e.paymentIntentId){airwallexStore.paymentIntentId=e.paymentIntentId}if(!airwallexStore.clientSecret){logError$1("Airwallex checkout session is missing the client secret");return false}return true};var airwallexLocaleByCode={ar:"ar",da:"da",de:"de",en:"en",es:"es",fr:"fr",id:"id",it:"it",ja:"ja",ko:"ko",nl:"nl",pl:"pl",pt:"pt",ru:"ru",sv:"sv",zh:"zh"};var airwallexStoreGetLocale=function(e){return airwallexLocaleByCode[e]||"en"};var initPromise=null;var airwallexStoreInitSdk=function(){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(r){if(airwallexStore.isReady){return[2,true]}if(!initPromise){e=(!zonosStore.zonosMode||zonosStore.zonosMode==="production")&&zonosStore.checkoutSettings.mode==="LIVE";initPromise=init({enabledElements:["payments"],env:e?"prod":"demo",locale:airwallexStoreGetLocale(localizationStore.selectedLocale)}).then((function(){airwallexStore.isReady=true;log("Airwallex SDK initialized");return true})).catch((function(e){logError$1(e);initPromise=null;return false}))}return[2,initPromise]}))}))};var airwallexPaidStatuses=["SUCCEEDED","REQUIRES_CAPTURE","PENDING_REVIEW","PENDING"];var airwallexStoreIsPaidStatus=function(e){return!!e&&airwallexPaidStatuses.includes(e)};var airwallexStoreMessageBasedOnStatus=function(e){switch(e){case"SUCCEEDED":{return{isError:false,messages:[translate("Thank you for submitting your payment. We appreciate your prompt attention."),"",translate("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]}}case"PENDING":case"PENDING_REVIEW":case"REQUIRES_CAPTURE":{return{isError:false,messages:[translate("Payment processing. We'll update you when payment is received.")]}}case"REQUIRES_CUSTOMER_ACTION":{return{isError:false,messages:[translate("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}}case"CANCELLED":case"REQUIRES_PAYMENT_METHOD":{return{isError:true,messages:[translate("Payment failed. Please reload the page and try another payment method.")]}}default:{return{isError:true,messages:[translate("Something went wrong.")]}}}};var airwallexStoreRetrievePaymentIntent=function(e){return __awaiter(void 0,void 0,void 0,(function(){var r,t,n;return __generator(this,(function(i){switch(i.label){case 0:return[4,handleFetch("/api/zonos-elements/collect/airwallex-payment-intent",{body:{paymentIntentId:e},method:"POST"})];case 1:r=i.sent(),t=r.errors,n=r.json;if(t.length||!n){logError$1("Failed to retrieve Airwallex payment intent",t);return[2,{status:null}]}return[2,{status:n.airwallexPaymentIntent.status}]}}))}))};var _m=createStore((function(){return{amountDutyTaxFeeTotal:null,amountTotalPaid:null,collectLogoUrl:null,isFetchingShippingInfo:true,landedCostShortId:null,originCompanyName:null,partyBillingId:null,paymentProcessor:null,shippingAddress:null}})),collectStoreReset=_m.reset,collectStore=_m.state;var collectStoreInitShippingInfo=function(e){return __awaiter(void 0,[e],void 0,(function(e){var r,t,n,i,o,a,s,u,l,c,d,f,v,p;var m=e.landedCostId,_=e.retries,h=_===void 0?5:_;return __generator(this,(function(e){switch(e.label){case 0:collectStore.isFetchingShippingInfo=true;return[4,handleFetch("/api/zonos-elements/collect/get-shipping-info-by-lc-id",{body:{landedCostId:m},method:"POST"})];case 1:d=e.sent();if(!d.errors.length)return[3,4];if(!(h>0))return[3,3];return[4,new Promise((function(e){return setTimeout(e,1e3)}))];case 2:e.sent();return[2,collectStoreInitShippingInfo({landedCostId:m,retries:h-1})];case 3:return[2,null];case 4:collectStore.landedCostShortId=((r=d.json)===null||r===void 0?void 0:r.landedCostShortId)||null;collectStore.isFetchingShippingInfo=false;collectStore.shippingAddress=((t=d.json)===null||t===void 0?void 0:t.shipping)||null;f=(n=cartStore.checkoutSession)===null||n===void 0?void 0:n.landedCost;v=(i=cartStore.checkoutSession)===null||i===void 0?void 0:i.subtotals;p=(((o=f===null||f===void 0?void 0:f.amountSubtotals)===null||o===void 0?void 0:o.shipping)||0)+(((a=f===null||f===void 0?void 0:f.amountSubtotals)===null||a===void 0?void 0:a.items)||0);collectStore.amountTotalPaid=p*(((s=v===null||v===void 0?void 0:v.exchangeRate)===null||s===void 0?void 0:s.rate)||1);collectStore.amountDutyTaxFeeTotal=((v===null||v===void 0?void 0:v.duties)||0)+((v===null||v===void 0?void 0:v.taxes)||0)+((v===null||v===void 0?void 0:v.fees)||0);collectStore.originCompanyName=((l=(u=d.json)===null||u===void 0?void 0:u.origin)===null||l===void 0?void 0:l.companyName)||null;collectStore.collectLogoUrl=((c=d.json)===null||c===void 0?void 0:c.collectLogoUrl)||null;if(collectStore.amountTotalPaid===0){void sendErrorLog({endpoint:"COLLECT_NO_TOTAL_PAID",errors:[],metadata:{landedCostId:m,organizationId:zonosStore.organizationId}})}return[2]}}))}))};var collectStoreAsyncAddressUpdate=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,r,t,n,i,o,a,s,u,l;return __generator(this,(function(c){switch(c.label){case 0:if(!((e=stripeStore.stripeBillingAddressEventData)===null||e===void 0?void 0:e.complete)){return[2,{partiesCreated:false}]}i=(t=(r=cartStore.checkoutSession)===null||r===void 0?void 0:r.landedCost)===null||t===void 0?void 0:t.rootId;if(!i){void sendErrorLog({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId}});return[2,{partiesCreated:false}]}if(!storageStore.checkoutSessionId){void sendErrorLog({endpoint:"COLLECT_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,landedCostRootId:i}});return[2,{partiesCreated:false}]}o=stripeStoreBuildAddressForPartyCreate({address:stripeStore.stripeBillingAddressEventData.value.address,firstName:stripeStore.stripeBillingAddressEventData.value.firstName,lastName:stripeStore.stripeBillingAddressEventData.value.lastName,name:stripeStore.stripeBillingAddressEventData.value.name,phone:stripeStore.stripeBillingAddressEventData.value.phone});a=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,handleFetch("/api/zonos-elements/create-billing-party",{body:{billingAddress:o,checkoutSessionId:storageStore.checkoutSessionId,companyName:stripeStore.companyName,email:((n=stripeStore.stripeLinkEventData)===null||n===void 0?void 0:n.value.email)||"",isTest:a,rootId:i},method:"POST"})];case 1:s=c.sent(),u=s.errors,l=s.json;if(u.length||!l){logError$1("Error occurs when creating billing party",JSON.stringify(u,null,2));void sendErrorLog({endpoint:"COLLECT_BILLING_PARTY_CREATE_FAILED",errors:["[COLLECT] Failed to create billing party"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,errors:u,json:l}});return[2,{partiesCreated:false}]}collectStore.partyBillingId=l.billToPartyId;return[2,{partiesCreated:true}]}}))}))};var collectStoreUpdateSelectedShippingOption=function(e){return __awaiter(void 0,void 0,void 0,(function(){var r;return __generator(this,(function(t){r=e.landedCost;if(!r){return[2,false]}cartStore.landedCostData=[Object.assign(Object.assign({},e),{landedCost:Object.assign({},r),landedCostId:r.id})];return[2,cartStoreUpdateSelectedShippingOption({applySubtotalsOnly:true,landedCostId:r.id,selectedShippingOption:r.shipmentRating})]}))}))};export{airwallexStoreSetFromSession as a,airwallexStore as b,collectStore as c,airwallexStoreRetrievePaymentIntent as d,airwallexStoreIsPaidStatus as e,airwallexStoreInitSdk as f,collectStoreUpdateSelectedShippingOption as g,collectStoreInitShippingInfo as h,collectStoreAsyncAddressUpdate as i,airwallexStoreMessageBasedOnStatus as j,airwallexStoreReset as k,createElement as l,airwallexStoreGetLocale as m,airwallexStoreOnChange as n};
|
|
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;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}}};import{c as createStore,z as zonosStore}from"./zonosStore-b7d3f9b0.js";import{t as translate,l as localizationStore,s as storageStore}from"./localization-da2f407f.js";import{l as logError$1,h as handleFetch,s as sendErrorLog}from"./handleFetch-a844cac1.js";import{l as log,b as allLogs}from"./VarianceTest-572cecf5.js";import{b as stripeStore,K as stripeStoreBuildAddressForPartyCreate,d as cartStore,L as cartStoreUpdateSelectedShippingOption}from"./cart-4699e6ab.js";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);if(t)_defineProperties(e,t);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(r&&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);if(r){n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))}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||{});var UNKNOWN_VALUE="airTracker_unknown";var DEFAULT_CONFIG={appName:UNKNOWN_VALUE,appVersion:UNKNOWN_VALUE,env:"staging",isWebappContainer:false,delay:2e3,errorRepeatTime:3,enableErrorMonitoring:false,assetSpeedMonitoringWhiteList:[],enableDetectPageChange:false,enableRecordPageRetention:false,hideSearchParams:false,useSessionStorageForSessionId:false,assetSpeedMonitoringWhiteListByMFE:{}};var DEFAULT_COMMON_DATA={appName:UNKNOWN_VALUE,env:"staging",sessionId:UNKNOWN_VALUE,deviceId:UNKNOWN_VALUE};var isJSON=function(e){if(!e){return false}if(/^\s*$/.test(e))return false;e=e.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@");e=e.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]");e=e.replace(/(?:^|:|,)(?:\s*\[)+/g,"");return/^[\],:{}\s]*$/.test(e)};var safeReplacer=function(){var e=new WeakSet;return function(r,t){if(_instanceof(t,Error)){return"Error.message: ".concat(t.message," \n Error.stack: ").concat(t.stack)}if((typeof t==="undefined"?"undefined":_type_of(t))==="object"&&t!==null){if(e.has(t)){return"[Circular ".concat(r||"root","]")}e.add(t)}if(typeof t==="function"){return"function"}if((typeof t==="undefined"?"undefined":_type_of(t))==="symbol"){return"symbol"}if(typeof t==="undefined"){return null}return t}};var safeStringify=function(e){if(typeof e==="string"){return e}try{if(_instanceof(e,Error)){return(JSON.stringify(e,safeReplacer())||"undefined").replace(/"/gim,"")}return JSON.stringify(e,safeReplacer())}catch(e){return'{"error":"error happen when airTracker stringify"}'}};var request=function(e){var r=e.method,t=r===void 0?"post":r,n=e.url,i=e.data,o=e.success,a=e.fail;if(!isJSON(i)){return}var s=new XMLHttpRequest;s.addEventListener("readystatechange",(function(){if(s.readyState===4){if(s.status>=400||s.status===0){a===null||a===void 0?void 0:a(s.response)}else{o===null||o===void 0?void 0:o(s.response)}}}));s.open(t,n);s.setRequestHeader("Content-Type","application/json");s.send(i)};var lifeCycleEventName={onInit:"onInit",onConfigInit:"onConfigInit",onConfigUpdated:"onConfigUpdated",onCommonDataInit:"onCommonDataInit",onCommonUpdated:"onCommonUpdated",onPageChange:"onPageChange",onDestroy:"onDestroy,"};var DEVICE_ID_STORAGE_KEY="AIR_ANALYTICS_DEVICE_ID";var SESSION_ID_STORAGE_KEY="AIR_ANALYTICS_SESSION_ID";var RISK_DEVICE_ID_STORAGE_KEY="AWX_RISK_ID";var loggingServiceUrl=function(e){if(e=="prod"){return"https://o11y.airwallex.com/airtracker/logs"}if(e=="demo"){return"https://o11y-demo.airwallex.com/airtracker/logs"}return"https://o11y-staging.airwallex.com/airtracker/logs"};var loggingServiceMetricsUrl=function(e){if(e=="prod"){return"https://o11y.airwallex.com/airtracker/metrics"}if(e=="demo"){return"https://o11y-demo.airwallex.com/airtracker/metrics"}return"https://o11y-staging.airwallex.com/airtracker/metrics"};var generateUId=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=Math.random()*16|0;var t=e==="x"?r:r&3|8;return t.toString(16)}));return e};var getMFEName=function(e){var r,t,n;if(e.config.getMFEName){return e.config.getMFEName()}return((n=location)===null||n===void 0?void 0:(t=n.pathname)===null||t===void 0?void 0:(r=t.split("/"))===null||r===void 0?void 0:r[2])||"unknown"};var getSessionId=function(){try{var e=window.sessionStorage.getItem(SESSION_ID_STORAGE_KEY);if(!e){e=generateUId();window.sessionStorage.setItem(SESSION_ID_STORAGE_KEY,e)}return e}catch(e){return generateUId()}};var getDeviceId=function(){try{var e=window.localStorage.getItem(DEVICE_ID_STORAGE_KEY);if(!e){e=generateUId();window.localStorage.setItem(DEVICE_ID_STORAGE_KEY,e)}return e}catch(e){}};var getRiskDeviceId=function(){try{var e=window.localStorage.getItem(RISK_DEVICE_ID_STORAGE_KEY);return e||void 0}catch(e){}};var getNetworkType=function(){var e;var r="";var t=navigator.userAgent.match(/NetType\/(\w+)/);if(t){var n;n=_sliced_to_array(t,2),r=n[1]}else if((e=navigator)===null||e===void 0?void 0:e.connection){var i,o,a,s;r=((o=navigator)===null||o===void 0?void 0:(i=o.connection)===null||i===void 0?void 0:i.effectiveType)||((s=navigator)===null||s===void 0?void 0:(a=s.connection)===null||a===void 0?void 0:a.type)}if(!r){r="unknown"}return parseNetType(r)};var parseNetType=function(e){e=String(e).toLowerCase();if(e.indexOf("4g")>=0)return"net4g";if(e.indexOf("wifi")>=0)return"wifi";if(e.indexOf("5g")>=0)return"net5g";if(e.indexOf("3g")>=0)return"net3g";if(e.indexOf("2g")>=0)return"net2g";return"unknown"};var canUseResourceTiming=function e(){return typeof window.performance!=="undefined"&&typeof window.performance.clearResourceTimings==="function"&&typeof window.performance.getEntriesByType==="function"&&typeof window.performance.now==="function"};var formatUrl=function(e){if(typeof e==="string"){var r=e.split("?")[0]||"";return r.slice(0,200)}return e};var getQueryString=function(e){if(typeof e==="string"){return e.split("?")[1]||""}return e};var urlIsHttps=function(e){var r=typeof e==="string"&&e.startsWith("//");return r?typeof location!=="undefined"&&location.protocol==="https:":/^https/.test(e)};var getReportVal=function(e,r){if(typeof e==="number"){return e}if(typeof e==="string"){return e}return r?"":-1};var checkIfInWhiteList=function(e,r){var t;var n=false;if(!r.config.isWebappContainer){n=checkIfInWhiteListHelper(e,r.config.assetSpeedMonitoringWhiteList);return n}var i=getMFEName(r);return n||checkIfInWhiteListHelper(e,(t=r.config.assetSpeedMonitoringWhiteListByMFE)===null||t===void 0?void 0:t[i])};var checkIfInWhiteListHelper=function(e,r){if(!(r===null||r===void 0?void 0:r.length)){return false}for(var t=0;t<r.length;t++){var n=r[t];if(_instanceof(n,RegExp)&&n.test(e)){return true}if(typeof n=="string"&&e.includes(n)){return true}}return false};var roundSubtract=function(e,r){var t=100;return Math.round((e-r)*t)/t};var sendNormalLogPipe=function(e){return function(r){var t,n;var i=getMFEName(e);var o=e.config.isWebappContainer?_object_spread({},e.commonData||{},((t=e.MFECommonDataMap)===null||t===void 0?void 0:t[i])||{}):e.commonData;var a=Array.isArray(r)?r:[r];if(a.length===0){return}var s={commonData:o,data:a};var u=safeStringify(s);var l={method:"post",url:loggingServiceUrl(e.commonData.env),data:u};if(typeof((n=navigator)===null||n===void 0?void 0:n.sendBeacon)==="function"){var c=navigator.sendBeacon(l.url,u);if(!c){request(l)}}else{request(l)}}};var sendMetricsLogPipe=function(e){return function(r){var t,n;var i=getMFEName(e);var o=e.config.isWebappContainer?_object_spread({},e.commonData||{},((t=e.MFECommonDataMap)===null||t===void 0?void 0:t[i])||{}):e.commonData;var a={commonData:o,data:Array.isArray(r)?r:[r]};var s=safeStringify(a);var u={method:"post",url:loggingServiceMetricsUrl(e.commonData.env),data:s};if(typeof((n=navigator)===null||n===void 0?void 0:n.sendBeacon)==="function"){var l=navigator.sendBeacon(u.url,s);if(!l){request(u)}}else{request(u)}}};var throttlePipe=function(e,r){var t;var n=[];var i=e.config;window.addEventListener("beforeunload",(function(){if(n.length>0){e.immediateSendPipe(n.splice(0,n.length));t&&clearTimeout(t)}}));return function(o,a){n.push(o);e.lifeCycle.on(lifeCycleEventName.onCommonUpdated,(function(){if(n.length>0){a===null||a===void 0?void 0:a(n.splice(0,n.length));e.lifeCycle.remove(lifeCycleEventName.onCommonUpdated);t&&clearTimeout(t)}}));if(r&&n.length>=r){a===null||a===void 0?void 0:a(n.splice(0,n.length));t&&clearTimeout(t);return}t&&clearTimeout(t);t=setTimeout((function(){t=null;if(n.length>0){a===null||a===void 0?void 0:a(n.splice(0,n.length));e.lifeCycle.remove(lifeCycleEventName.onCommonUpdated)}}),i.delay)}};var errorLogLimitPipe=function(e){var r={};return function(t,n){var i=typeof e.config.errorRepeatTime==="number"?e.config.errorRepeatTime:5;if(i===0){return n===null||n===void 0?void 0:n(t)}n===null||n===void 0?void 0:n(t.filter((function(e){if(e.severity=="autoDetectError"){r[e.error]=r[e.error]||0;r[e.error]+=1;if(r[e.error]>i){return false}return true}return true})))}};var noop=function(){};var createPipeline=function(e){if(!e||!e.reduce||!e.length){throw new TypeError("createPipeline need at least one function param")}if(e.length===1){return function(r,t){e[0](r,t||noop)}}return e.reduce((function(e,r){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:noop;return e(t,(function(e){return r===null||r===void 0?void 0:r(e,n)}))}}))};var EventEmitter=function(){function e(){var r=this;_class_call_check(this,e);this.emit=function(e,t){if(!r)return;var n=r.eventsList[e];var i;if(n===null||n===void 0?void 0:n.length){n=n.slice();for(var o=0;o<n.length;o++){i=n[o];try{var a=i.callback.apply(r,[t]);if(1===i.type){r.remove(e,i.callback)}if(false===a){break}}catch(e){throw e}}}return r};this.eventsList={}}_create_class(e,[{key:"indexOf",value:function e(r,t){for(var n=0;n<r.length;n++){if(r[n].callback===t){return n}}return-1}},{key:"on",value:function e(r,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!this)return;var i=this.eventsList[r];if(!i){this.eventsList[r]=[];i=this.eventsList[r]}if(this.indexOf(i,t)===-1){var o={name:r,type:n||0,callback:t};i.push(o);return this}return this}},{key:"one",value:function e(r,t){this.on(r,t,1)}},{key:"remove",value:function e(r,t){if(!this)return;var n=this.eventsList[r];if(!n){return null}if(!t){try{delete this.eventsList[r]}catch(e){}return null}if(n.length){var i=this.indexOf(n,t);n.splice(i,1)}return this}},{key:"clear",value:function e(){this.eventsList={}}}]);return e}();var AirTrackerPlugin=function(){function e(r){_class_call_check(this,e);this.name="";this.isInit=false;this.name=r.name;this.option=r}_create_class(e,[{key:"patch",value:function e(r){if(!this.isInit){var t,n;this.isInit=true;(n=this.option)===null||n===void 0?void 0:(t=n.setUp)===null||t===void 0?void 0:t.call(this.option,r)}}},{key:"uninstall",value:function e(){var r,t;(t=this.option)===null||t===void 0?void 0:(r=t.destroy)===null||r===void 0?void 0:r.apply(this);this.isInit=false}}]);return e}();var airTracker;var onError=function(e){var r="".concat(safeStringify(e.message)||""," @ (").concat(safeStringify(e.filename)||"",":").concat(e.lineno||0,":").concat(e.colno||0,")\n").concat(safeStringify(e.error||""));airTracker.normalLogPipeLine({severity:"autoDetectError",eventName:"windowOnError",extraInfo:{error:r}})};var unhandledrejectionHandler=function(e){var r=e&&safeStringify(e.reason);airTracker.normalLogPipeLine({severity:"autoDetectError",eventName:"promiseError",extraInfo:{error:r}})};var errorHandler=function(e){var r=(e===null||e===void 0?void 0:e.target)||(e===null||e===void 0?void 0:e.srcElement);if(!r){return}var t=(r===null||r===void 0?void 0:r.src)||(r===null||r===void 0?void 0:r.href);var n=r.tagName;var i="unknown";if(typeof t==="string"&&n){if(window.location.href.indexOf(t)>-1){return}if(/\.js$/.test(t)){i="script"}else if(/\.css$/.test(t)){i="css"}else{switch(n.toLowerCase()){case"script":i="script";break;case"link":i="css";break;case"img":i="image";break;case"audio":case"video":i="media";break;default:return}}airTracker.normalLogPipeLine({severity:"autoDetectError",eventName:"staticFileLoadError",extraInfo:{staticFileType:i,error:"".concat(n," load fail: ").concat(t)}})}};var errorDetectionPlugin=new AirTrackerPlugin({name:"errorDetectionPlugin",setUp:function(e){airTracker=e;window.addEventListener("error",onError);window.addEventListener("unhandledrejection",unhandledrejectionHandler);window.document.addEventListener("error",errorHandler,true)},destroy:function(){window.removeEventListener("unhandledrejection",unhandledrejectionHandler);window.document.removeEventListener("error",errorHandler,true);window.removeEventListener("error",onError)}});var ASSETS_INITIATOR_TYPE=["img","css","script","link","audio","video","iframe"];var COLLECTED_ENTRY_TYPE="resource";var generateSpeedLog=function(e){var r=e.name;return{url:formatUrl(r),method:"get",duration:Number(e.duration.toFixed(2)),type:"static",isHttps:urlIsHttps(r),urlQuery:getQueryString(r),domainLookup:getReportVal(e.domainLookupEnd-e.domainLookupStart),connectTime:getReportVal(e.connectEnd-e.connectStart)}};var publishSpeedLogs=function(e,r){for(var t=0,n=e.length;t<n;t++){var i=e[t];if(ASSETS_INITIATOR_TYPE.indexOf(i.initiatorType)!==-1&&checkIfInWhiteList(i.name,r)){r.normalLogPipeLine({severity:"performance",eventName:"assets_speed",extraInfo:{log:generateSpeedLog(i)}})}}};var interval;var observer;var assetSpeedPlugin=new AirTrackerPlugin({name:"assetsSpeedPlugin",setUp:function(e){if(!canUseResourceTiming())return;var r=0;window.performance.onresourcetimingbufferfull=function(){r=0;window.performance.clearResourceTimings()};if(typeof window.PerformanceObserver==="function"){publishSpeedLogs(window.performance.getEntriesByType(COLLECTED_ENTRY_TYPE),e);observer=new window.PerformanceObserver((function(r){publishSpeedLogs(r.getEntries(),e)}));observer.observe({entryTypes:[COLLECTED_ENTRY_TYPE]})}else{interval=setInterval((function(){var t=window.performance.getEntriesByType(COLLECTED_ENTRY_TYPE);var n=t.slice(r);r=t.length;publishSpeedLogs(n,e)}),3e3)}},destroy:function(){observer===null||observer===void 0?void 0:observer.disconnect();interval&&clearInterval(interval)}});var observer2;var onPageChangePlugin=new AirTrackerPlugin({name:"onPageChangePlugin",setUp:function(){var e=_async_to_generator((function(e){var r,t,n,i,o;return _ts_generator(this,(function(a){t=(r=location)===null||r===void 0?void 0:r.href;n=document.querySelector("body");i=function(r){var t=r.prevHref;var n,i,o,a,s;e.normalLogPipeLine({severity:"autoDetectEvent",eventName:"onPageChange",extraInfo:{prevHref:t,href:((n=location)===null||n===void 0?void 0:n.href)||"",hostname:(i=location)===null||i===void 0?void 0:i.hostname,pathName:(o=location)===null||o===void 0?void 0:o.pathname,protocol:(a=location)===null||a===void 0?void 0:a.protocol,search:(s=location)===null||s===void 0?void 0:s.search}})};i({prevHref:""});observer2=new MutationObserver((function(){if(location.href!==t){var e=t;t=location.href;i({prevHref:e})}}));o={subtree:true,childList:true};observer2.observe(n||document,o);return[2]}))}));return function(r){return e.apply(this,arguments)}}(),destroy:function(){observer2===null||observer2===void 0?void 0:observer2.disconnect()}});var observer3;var onPageRetentionPlugin=new AirTrackerPlugin({name:"onPageRetentionPlugin",setUp:function(){var e=_async_to_generator((function(e){var r,t,n,i,o,a,s;return _ts_generator(this,(function(u){if(typeof document.visibilityState==="undefined"){return[2]}t=(r=location)===null||r===void 0?void 0:r.href;n=document.querySelector("body");o=function(){i=Date.now()};o();document.addEventListener("visibilitychange",(function(){if(document.visibilityState==="hidden"){a({href:location.href,leftReason:"visibilityChange"})}else if(document.visibilityState==="visible"){o()}}));window.addEventListener("beforeunload",(function(){a({href:location.href,sendImmediate:true,leftReason:"pageClose"})}));a=function(r){var t=r.href,n=r.sendImmediate,o=r.leftReason;if(!i){return}var a=Date.now()-i;if(a===0){return}i=void 0;var s={severity:"autoDetectEvent",eventName:"onPageRetention",extraInfo:{href:t,duration:a,leftReason:o}};if(n){e.ImmediatePipeline(s);return}e.normalLogPipeLine(s)};observer3=new MutationObserver((function(){if(location.href!==t){var e=t;t=location.href;a({href:e,leftReason:"nextPage"});o()}}));s={subtree:true,childList:true};observer3.observe(n||document,s);return[2]}))}));return function(r){return e.apply(this,arguments)}}(),destroy:function(){observer3===null||observer3===void 0?void 0:observer3.disconnect()}});var generateRandomId=function(){return Date.now().toString(36)+Math.random().toString(36).substring(2,15)};var checkIfInWhiteList2=function(e,r){var t=[/^https?:\/\/[^\/]*\.airwallex\.com($|\/)/];var n=[/authenticate\/heartbeat/,/papluginlogs\/.*/,/airtracker\/.*/,/o11y(-staging|-demo)?\.airwallex\.com/,/\.(png|jpe?g|gif|svg|ico|webp|avif|css|js|json|woff2?|ttf|eot|map|txt|csv|xml)(\?.*)?(#.*)?$/i];if(n.some((function(r){return r.test(e)}))){return false}return checkIfInWhiteListHelper(e,r||t)};var findMainEntry=function(e){var r=e.startTime,t=e.endTime,n=e.entries;if(n.length===0){return void 0}if(n.length===1){return n[0]}var i=n.filter((function(e){return e.startTime>=r&&t&&e.responseEnd<=t})).sort((function(e,r){return e.startTime-r.startTime}));return i===null||i===void 0?void 0:i[0]};var round2Decimal=function(e){return Math.round(e*100)/100};var processPerformanceEntry=function(e){var r=e.startTime,t=e.duration,n=e.responseStart,i=e.connectEnd,o=e.connectStart,a=e.domainLookupEnd,s=e.domainLookupStart,u=e.requestStart,l=e.secureConnectionStart,c=e.redirectEnd,d=e.redirectStart,f=e.responseStatus,v=e.responseEnd,p=e.encodedBodySize,m=e.decodedBodySize,_=e.transferSize,h=e.deliveryType,y=e.initiatorType;return{startTime:round2Decimal(r),totalDuration:round2Decimal(t),timeToFirstByte:roundSubtract(n,r),tcpDuration:roundSubtract(i,o),dnsDuration:roundSubtract(a,s),tlsDuration:roundSubtract(u,l),redirectDuration:roundSubtract(c,d),responseDuration:roundSubtract(v,n),encodeResponseSize:p,decodeResponseSize:m,transferSize:_,deliveryType:h,statusCode:f,initiatorType:y}};var getPayload=function(e,r){var t=e.url,n=e.method,i=e.errorType,o=e.errorDetail;var a=findMainEntry(e);var s=new URL(t,window.location.href),u=s.href,l=s.protocol;var c=a?processPerformanceEntry(a):{};var d={severity:"autoDetectEvent",eventName:"httpClientMetrics",extraInfo:_object_spread(_object_spread_props(_object_spread({httpUrl:u,method:n,scheme:l},i&&{errorType:i},o&&{errorDetail:o},c),{statusCode:(c===null||c===void 0?void 0:c.statusCode)||(e===null||e===void 0?void 0:e.responseStatus),startTime:(c===null||c===void 0?void 0:c.startTime)||(e===null||e===void 0?void 0:e.startTime),initiatorType:(c===null||c===void 0?void 0:c.initiatorType)||(e===null||e===void 0?void 0:e.initiatorType)}),r)};return d};var isGraphQLError=function(e){return e&&(typeof e==="undefined"?"undefined":_type_of(e))==="object"&&"errors"in e&&Array.isArray(e.errors)&&e.errors.every((function(e){return e&&(typeof e==="undefined"?"undefined":_type_of(e))==="object"&&"message"in e}))};var API_PERFORMANCE_QUEUE="awx_airtracker_api_performance_queue";var API_PERFORMANCE_PLUGIN_LOADED="awx_airtracker_api_performance_plugin_loaded";var OBSERVER_WAIT_TIME_MS=300;var TIMEOUT_WAIT_TIME_MS=1e4;var globalObject=typeof window!=="undefined"?window:typeof global!=="undefined"?global:{};globalObject[API_PERFORMANCE_QUEUE]=globalObject[API_PERFORMANCE_QUEUE]||[];var handlePayloadAndSendLog=function(e,r,t){setTimeout((function(){var n=getPayload(e,t);r.observerPipeline(n);globalObject[API_PERFORMANCE_QUEUE]=globalObject[API_PERFORMANCE_QUEUE].filter((function(r){return r.id!==e.id}))}),OBSERVER_WAIT_TIME_MS)};var handleTimeout=function(e,r){setTimeout((function(){var t=globalObject[API_PERFORMANCE_QUEUE].find((function(r){return r.id===e}));if(!t){return}var n=getPayload(t,{exceptionType:"timeout-without-response"});r.observerPipeline(n);globalObject[API_PERFORMANCE_QUEUE]=globalObject[API_PERFORMANCE_QUEUE].filter((function(r){return r.id!==e}))}),TIMEOUT_WAIT_TIME_MS)};var injectXMLHttpRequest=function(e){var r=XMLHttpRequest.prototype.open;var t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function t(n,i,o,a,s){try{var u;var l=generateRandomId();this.__requestId=l;var c=_instanceof(i,URL)?i.href:new URL(i,window.location.href).href;if(!checkIfInWhiteList2(c,(u=e.config)===null||u===void 0?void 0:u.enableRecordAPIPerformanceWhitelist)){return r.call(this,n,i,o!==null&&o!==void 0?o:true,a,s)}var d={id:l,startTime:performance.now(),method:n,url:c,entries:[],initiatorType:"xmlhttprequest"};globalObject[API_PERFORMANCE_QUEUE].push(d);handleTimeout(l,e);return r.call(this,n,i,o!==null&&o!==void 0?o:true,a,s)}catch(t){e.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Inject XHR open error",error:t}});return r.call(this,n,i,o!==null&&o!==void 0?o:true,a,s)}};XMLHttpRequest.prototype.send=function r(){var n=this;for(var i=arguments.length,o=new Array(i),a=0;a<i;a++){o[a]=arguments[a]}try{var s=globalObject[API_PERFORMANCE_QUEUE].find((function(e){return e.id===n.__requestId}));if(!s){return t.apply(this,o)}var u=this;this.addEventListener("loadend",_async_to_generator((function(){var r,t,n,i,o,a,l;return _ts_generator(this,(function(c){switch(c.label){case 0:r=performance.now();t=r-s.startTime;n=u.status;if(n===0){return[2]}s.endTime=r;s.duration=t;s.responseStatus=n;c.label=1;case 1:c.trys.push([1,6,,7]);if(!(u.responseType===""||u.responseType==="text"))return[3,2];i=u.responseText;return[3,5];case 2:if(!(u.responseType==="json"))return[3,3];i=u.response;return[3,5];case 3:if(!(u.responseType==="blob"))return[3,5];o=u.response;if(!((o===null||o===void 0?void 0:o.type)==="application/json"))return[3,5];return[4,o.text()];case 4:i=c.sent();c.label=5;case 5:a=i&&typeof i==="string"?JSON.parse(i):i;if(a&&isGraphQLError(a)){s.errorType="graphqlError";s.errorDetail=a.errors}return[3,7];case 6:l=c.sent();e.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Parse response body error in XHR",url:s===null||s===void 0?void 0:s.url,error:l}});return[3,7];case 7:handlePayloadAndSendLog(s,e);return[2]}}))})));this.addEventListener("error",(function(){handlePayloadAndSendLog(s,e,{exceptionType:"network-error"})}));this.addEventListener("abort",(function(){handlePayloadAndSendLog(s,e,{exceptionType:"abort-error"})}));this.addEventListener("timeout",(function(){handlePayloadAndSendLog(s,e,{exceptionType:"timeout-error"})}));return t.apply(this,o)}catch(r){e.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"InjectXHR send error",error:r}});throw r}}};var injectFetch=function(e){var r=window.fetch;window.fetch=_async_to_generator((function(){var t,n,i,o,a,s,u,l,c,d,f,v,p,m,_,h;var y=arguments;return _ts_generator(this,(function(g){switch(g.label){case 0:for(t=y.length,n=new Array(t),i=0;i<t;i++){n[i]=y[i]}s=new URL(_instanceof(n[0],Request)?n[0].url:String(n[0]),window.location.href).href;if(!!checkIfInWhiteList2(s,(o=e.config)===null||o===void 0?void 0:o.enableRecordAPIPerformanceWhitelist))return[3,2];return[4,r.apply(this,n)];case 1:return[2,g.sent()];case 2:g.trys.push([2,9,,10]);l=performance.now();c=generateRandomId();a={id:c,startTime:l,method:((u=_instanceof(n[0],Request)?n[0]:n[1])===null||u===void 0?void 0:u.method)||"GET",url:s,entries:[],initiatorType:"fetch"};globalObject[API_PERFORMANCE_QUEUE].push(a);handleTimeout(c,e);return[4,r.apply(this,n)];case 3:d=g.sent();f=performance.now();a.endTime=f;a.duration=f-l;a.responseStatus=d.status;v=d.clone();g.label=4;case 4:g.trys.push([4,7,,8]);if(!v.ok)return[3,6];return[4,v.json()];case 5:p=g.sent();if(p&&isGraphQLError(p)){a.errorType="graphqlError";a.errorDetail=p.errors}g.label=6;case 6:return[3,8];case 7:m=g.sent();e.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Parse response body error in fetch",url:a===null||a===void 0?void 0:a.url,error:m}});return[3,8];case 8:handlePayloadAndSendLog(a,e);return[2,d];case 9:_=g.sent();if(a&&a.id&&globalObject[API_PERFORMANCE_QUEUE].find((function(e){return e.id===(a===null||a===void 0?void 0:a.id)}))){h="fetch-error";if(_instanceof(_,TypeError)){h="network-error"}else if(_instanceof(_,DOMException)&&_.name==="AbortError"){h="abort-error"}handlePayloadAndSendLog(a,e,{exceptionType:h})}else{e.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Inject fetch error",error:_}})}throw _;case 10:return[2]}}))}))};var setUpAPIPerformancePlugin=function(e){var r;injectXMLHttpRequest(e);injectFetch(e);if((r=window)===null||r===void 0?void 0:r.PerformanceObserver){var t=new window.PerformanceObserver((function(e){var r=e.getEntries();r.forEach((function(e){var r=e;if(r.initiatorType==="fetch"||r.initiatorType==="xmlhttprequest"){var t=globalObject[API_PERFORMANCE_QUEUE].filter((function(e){return e.url===r.name}));t.forEach((function(e){e.entries.push(r)}))}}))}));t.observe({entryTypes:["resource"],buffered:true})}else{e.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{error:"PerformanceObserver Not Supported"}})}};var apiPerformancePlugin=new AirTrackerPlugin({name:"apiPerformancePlugin",setUp:function(){var e=_async_to_generator((function(e){var r,t;return _ts_generator(this,(function(n){if(globalObject[API_PERFORMANCE_PLUGIN_LOADED]){return[2]}if(((r=e.config)===null||r===void 0?void 0:r.enableRecordAPIPerformance)&&Math.random()<(((t=e.config)===null||t===void 0?void 0:t.enableRecordAPIPerformancePercentage)||0)){globalObject[API_PERFORMANCE_PLUGIN_LOADED]=true;setUpAPIPerformancePlugin(e)}return[2]}))}));return function(r){return e.apply(this,arguments)}}()});var SDK_VERSION="3.1.0";var AirTracker=function(){function e(r){var t=this;var n=r.config,i=r.plugins,o=i===void 0?[]:i;_class_call_check(this,e);this.config=DEFAULT_CONFIG;this.lifeCycle=new EventEmitter;this.plugins=[];this._commonData=DEFAULT_COMMON_DATA;this._MFECommonDataMap={};this.timeMap={};this.packedDataConvert=function(e){var r=e.severity,n=e.eventName,i=e.extraInfo;var o,a;var s=_object_spread({severity:r,eventName:n,currentHref:t.config.hideSearchParams?(((o=location)===null||o===void 0?void 0:o.href)||"").split("?")[0]||"":((a=location)===null||a===void 0?void 0:a.href)||""},i);if(t.config.isWebappContainer){s.MFEName=getMFEName(t)}return s};this.normalPipelineObj=createPipeline([throttlePipe(this,8),errorLogLimitPipe(this),sendNormalLogPipe(this)]);this.observerPipelineObj=createPipeline([throttlePipe(this,8),sendMetricsLogPipe(this)]);this.immediateSendPipe=sendNormalLogPipe(this);this.observerPipeline=function(e){var r=e.severity,n=e.eventName,i=e.extraInfo;var o=t.packedDataConvert({severity:r,eventName:n,extraInfo:i});return t.observerPipelineObj(o)};this.normalLogPipeLine=function(e){var r=e.severity,n=e.eventName,i=e.extraInfo;var o=t.packedDataConvert({severity:r,eventName:n,extraInfo:i});if(t.config.disableThrottle){return t.immediateSendPipe(o)}else{return t.normalPipelineObj(o)}};this.ImmediatePipeline=function(e){var r=e.severity,n=e.eventName,i=e.extraInfo;var o=t.packedDataConvert({severity:r,eventName:n,extraInfo:i});return t.immediateSendPipe(o)};this.plugins=_to_consumable_array(o);this.setConfig(n);this.initCommonData(n);this.lifeCycle.emit(lifeCycleEventName.onInit);if(n.enableErrorMonitoring){this.plugins.push(errorDetectionPlugin)}if((n===null||n===void 0?void 0:n.assetSpeedMonitoringWhiteList)&&n.assetSpeedMonitoringWhiteList.length>0||n.isWebappContainer){this.plugins.push(assetSpeedPlugin)}if(n===null||n===void 0?void 0:n.enableDetectPageChange){this.plugins.push(onPageChangePlugin)}if(n===null||n===void 0?void 0:n.enableRecordPageRetention){this.plugins.push(onPageRetentionPlugin)}if((n===null||n===void 0?void 0:n.enableRecordAPIPerformance)&&(n===null||n===void 0?void 0:n.enableRecordAPIPerformancePercentage)&&n.enableRecordAPIPerformancePercentage>0&&n.enableRecordAPIPerformancePercentage<=1){this.plugins.push(apiPerformancePlugin)}this.installPlugins()}_create_class(e,[{key:"installPlugins",value:function e(){var r=this;this.plugins.forEach((function(e){e.patch(r)}))}},{key:"commonData",get:function e(){return this._commonData}},{key:"MFECommonDataMap",get:function e(){return this._MFECommonDataMap}},{key:"initCommonData",value:function e(r){this._commonData.sessionId=r.useSessionStorageForSessionId?getSessionId():generateUId();this._commonData.deviceId=getDeviceId()||UNKNOWN_VALUE;this._commonData.riskDeviceId=getRiskDeviceId();this._commonData.networkType=getNetworkType()||"unknown";this._commonData.env=r.env||this._commonData.env;this._commonData.accountId=r.accountId||UNKNOWN_VALUE;this._commonData.appVersion=r.appVersion;this._commonData.appName=r.appName;this._commonData.sdkVersion=SDK_VERSION;this.lifeCycle.emit(lifeCycleEventName.onCommonDataInit,this.commonData)}},{key:"updateCommonDataBasedOnConfig",value:function e(r){this.lifeCycle.emit(lifeCycleEventName.onCommonUpdated,this._commonData);this._commonData.env=r.env||this._commonData.env;this._commonData.appName=r.appName||this._commonData.appName;this._commonData.env=r.env||this._commonData.env;this._commonData.accountId=r.accountId||this._commonData.accountId;this._commonData.appVersion=r.appVersion||this._commonData.appVersion}},{key:"updateCommonData",value:function e(r){this.lifeCycle.emit(lifeCycleEventName.onCommonUpdated,this._commonData);this._commonData=_object_spread({},this._commonData,r)}},{key:"removeCommonDataByKey",value:function e(r){var t=this;this.lifeCycle.emit(lifeCycleEventName.onCommonUpdated,this._commonData);setTimeout((function(){r.forEach((function(e){delete t._commonData[e]}))}),1e3)}},{key:"addToMFECommonData",value:function e(r){var t=r.MFEName,n=r.MFECommonData;var i;if(!this.config.isWebappContainer){return}if(!t||!n){return}this._MFECommonDataMap=_object_spread_props(_object_spread({},this._MFECommonDataMap||{}),_define_property({},t,_object_spread({},((i=this._MFECommonDataMap)===null||i===void 0?void 0:i[t])||{},n)))}},{key:"setConfig",value:function e(r){var t=this;if(this.config.isWebappContainer){return}var n=function(e,r){t.config[e]=r};Object.entries(r).forEach((function(e){var r=_sliced_to_array(e,2),t=r[0],i=r[1];if((typeof i==="undefined"?"undefined":_type_of(i))!==void 0){n(t,i)}}));this.lifeCycle.emit(lifeCycleEventName.onConfigInit,this.config);this.updateCommonDataBasedOnConfig(r)}},{key:"verbose",value:function e(r,t){this.normalLogPipeLine({severity:"verbose",eventName:r,extraInfo:t})}},{key:"httpLog",value:function e(r,t){this.normalLogPipeLine({severity:"http",eventName:r,extraInfo:t})}},{key:"info",value:function e(r,t){this.normalLogPipeLine({severity:"info",eventName:r,extraInfo:t})}},{key:"warn",value:function e(r,t){this.normalLogPipeLine({severity:"warn",eventName:r,extraInfo:t})}},{key:"error",value:function e(r,t){console.error("error",r);this.normalLogPipeLine({severity:"error",eventName:r,extraInfo:t})}},{key:"businessLog",value:function e(r,t){this.normalLogPipeLine({severity:"info",eventName:r,extraInfo:_object_spread_props(_object_spread({},t),{isBusinessLog:true})})}},{key:"reportDuration",value:function e(r,t,n){if(typeof r!=="string"){console.warn("reportDuration: eventName (first param) must be a string");return}if(typeof t!=="number"){console.warn("reportDuration: duration (second param) must be number");return}if(t<0||t>6e4){console.warn("reportDuration: duration (second param) must between 0 and 60000");return}this.normalLogPipeLine({severity:"speed",eventName:r,extraInfo:_object_spread({duration:t},n)})}},{key:"getTimerKey",value:function e(r){var t=getMFEName(this);return this.config.isWebappContainer?"".concat(t,"_").concat(r):r}},{key:"timeStart",value:function e(r){if(typeof r!=="string"){console.warn("time: first param must be a string");return}if(this.timeMap[this.getTimerKey(r)]){console.warn("Timer ".concat(r," already exists"))}this.timeMap[this.getTimerKey(r)]=Date.now()}},{key:"timeEnd",value:function e(r,t){if(typeof r!=="string"){console.warn("timeEnd: first param must be a string");return}if(this.timeMap[this.getTimerKey(r)]){var n=Date.now()-this.timeMap[this.getTimerKey(r)]+(t||0);this.normalLogPipeLine({severity:"speed",eventName:r,extraInfo:{duration:n}});delete this.timeMap[this.getTimerKey(r)]}else{console.warn("Timer key :".concat(r," does not exist"))}}},{key:"addToAssetSpeedWhiteListByMFE",value:function e(r){var t=r.MFEName,n=r.whiteList;var i;if(!this.config.isWebappContainer){return}if(!t||!(n===null||n===void 0?void 0:n.length)){return}if(!this.config.assetSpeedMonitoringWhiteListByMFE){this.config.assetSpeedMonitoringWhiteListByMFE={}}if(!((i=this.config.assetSpeedMonitoringWhiteListByMFE)===null||i===void 0?void 0:i[t])){this.config.assetSpeedMonitoringWhiteListByMFE=_object_spread_props(_object_spread({},this.config.assetSpeedMonitoringWhiteListByMFE),_define_property({},t,n))}else{var o;var a,s;(s=this.config.assetSpeedMonitoringWhiteListByMFE)===null||s===void 0?void 0:(a=s[t])===null||a===void 0?void 0:(o=a).push.apply(o,_to_consumable_array(n))}}},{key:"destroy",value:function e(){if(this.config.isWebappContainer){return}this.plugins.forEach((function(e){e.uninstall()}))}}]);return e}();var src_default=AirTracker;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(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())}))}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){if(t||arguments.length===2)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 name="@airwallex/components-sdk";var version="1.30.2";var main="./lib/index.js";var module="./lib/index.mjs";var types="./lib/index.d.ts";var files=["lib/**"];var license="MIT";var scripts={"load-types":"node ./load-types.js && yarn prettier -w src/types/*d.ts",prebuild:"yarn clean",build:"yarn rollup --config",postbuild:"yarn bundle-types","bundle-types":"dts-bundle-generator -o ./lib/index.d.ts ./src/index.ts",clean:"rm -rf dist lib",lint:'eslint "src/**/*.ts*"',test:"jest",sonar:"sonar-scanner",release:"semantic-release","lint-stage":"lint-staged",prepare:"husky"};var prettier={semi:true,singleQuote:true,printWidth:80,trailingComma:"all"};var publishConfig={access:"public"};var devDependencies={"@babel/preset-typescript":"^7.18.6","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^11.1.6","@semantic-release/changelog":"^5.0.1","@semantic-release/commit-analyzer":"^8.0.1","@semantic-release/git":"^9.0.0","@semantic-release/gitlab":"^6.1.0","@semantic-release/release-notes-generator":"^9.0.0","@swc/core":"^1.3.46","@types/jest":"^29.5.0","@typescript-eslint/eslint-plugin":"^5.57.0","@typescript-eslint/parser":"^5.57.0","dts-bundle-generator":"^9.0.0",eslint:"^7.23.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^5.1.3",husky:"^9.0.11",jest:"^29.5.0","jest-environment-jsdom":"^29.5.0","lint-staged":"^15.2.7",prettier:"^3.3.2",rollup:"^4.9.6","semantic-release":"^17.3.8","sonarqube-scanner":"^3.0.1","ts-jest":"^29.0.5","ts-loader":"^9.5.1",tslib:"^2.6.2",typescript:"^4.5.2"};var dependencies={"@airwallex/airtracker":"^3.0.0"};var packageJson={name:name,version:version,main:main,module:module,types:types,files:files,license:license,scripts:scripts,prettier:prettier,"lint-staged":{"src/**/*.{ts,tsx}":["yarn lint"],"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}":"prettier --write"},publishConfig:publishConfig,devDependencies:devDependencies,dependencies:dependencies};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=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"};var ELEMENT_TO_SDK={kyc:"kyc",paymentsKyb:"paymentsKyb",kycRfi:"rfi",transactionRfi:"rfi",paymentEnablementRfi:"rfi",lendingRfi:"rfi",mrmRfi:"rfi",payoutForm:"payouts",beneficiaryForm:"payouts",hpp:"payments",cvc:"payments",card:"payments",expiry:"payments",dropIn:"payments",cardNumber:"payments",applePayButton:"payments",googlePayButton:"payments",krCardNumber:"payments",krCardIdentifier:"payments",krCardExpiry:"payments",krCardPswFirstTwo:"payments",scaSetup:"sca",scaVerify:"sca",scaManagement:"sca",taxForm:"taxForm",embeddedCheckout:"billing"};var ELEMENT_GROUP_TO_ELEMENT={payments:["hpp","cvc","card","expiry","dropIn","cardNumber","applePayButton","googlePayButton","krCardNumber","krCardIdentifier","krCardExpiry","krCardPswFirstTwo"],payouts:["payoutForm","beneficiaryForm"],onboarding:["kyc","paymentsKyb"],risk:["scaSetup","scaVerify","scaManagement","transactionRfi","kycRfi","paymentEnablementRfi","lendingRfi","mrmRfi"],billing:["embeddedCheckout"]};var SDK_DEPENDENCIES={billing:["payments"]};var DOMAIN_FUNCTIONS_NAMESPACES=["payments","sca"];var InvalidStaticResourceError=function(e){__extends(r,e);function r(r){var t=e.call(this,r)||this;t.code="INVALID_STATIC_RESOURCE_ERROR";return t}return r}(Error);var timestamp=Date.now();var isElementGroup=function(e){return Object.keys(ELEMENT_GROUP_TO_ELEMENT).includes(e)};var sleep=function(e){if(e===void 0){e=500}return new Promise((function(r){return window.setTimeout(r,e)}))};var getSDKByElementName=function(e){return ELEMENT_TO_SDK[e]};var getHost=function(e,r){var t=e===PAYMENTS?PA_STATIC_HOST:STATIC_HOST;return t[r]||t.prod};var getSDKsByEnabledElements=function(e){var r=e.reduce((function(e,r){return e.concat(isElementGroup(r)?ELEMENT_GROUP_TO_ELEMENT[r]:r)}),[]);return Array.from(new Set(r)).map((function(e){return{elementName:e,sdkName:getSDKByElementName(e)}}))};var getFunctionsByEnabledElements=function(e){return Array.from(new Set(getSDKsByEnabledElements(e).map((function(e){var r=e.sdkName;return r})).filter((function(e){return DOMAIN_FUNCTIONS_NAMESPACES.includes(e)}))))};var getWindowSDKInstanceName=function(e){return e==="payments"?"payment":e};var getSDKUrl=function(e){var r=e.name,t=e.env,n=t===void 0?ENV.prod:t;var i=getHost(r,n);var o=SDK_URL_MAPPING[r];if(!o){logError("[components-sdk] Element static resource not found",{sdkName:r});throw new InvalidStaticResourceError("Element ".concat(r," static resource URL is invalid."))}return"".concat(i).concat(o,"?ts=").concat(timestamp)};var getFunctionsInstanceWithNamespace=function(){return DOMAIN_FUNCTIONS_NAMESPACES.reduce((function(e,r){var t;return __assign(__assign({},e),(t={},t[r]=window._AirwallexSDKs.__controller__.internalSDKs[r],t))}),{})};var getSDKDependencies=function(e){return SDK_DEPENDENCIES[e]||[]};var now=function(){return Math.floor(performance.now())};var createScript=function(e){var r=document.createElement("script");r.src=e;r.type="module";var t=document.head||document.body;t.appendChild(r);return r};var MAX_RETRY_COUNT=3;var loadScript=function(e){return __awaiter(void 0,void 0,void 0,(function(){var r,t;return __generator(this,(function(n){switch(n.label){case 0:if(typeof window==="undefined"){throw new Error("Please load script in browser environment")}r=0;t=function(){return __awaiter(void 0,void 0,void 0,(function(){var t,n,i;return __generator(this,(function(o){t=now();if(r>0&&e.includes("?ts=")){n=new URL(e,window.location.href);n.searchParams.set("ts","".concat(Date.now()));e=n.toString()}i=createScript(e);return[2,new Promise((function(n,o){i.addEventListener("load",(function(){var i=now();logInfo("[components-sdk] SDK script loaded",{scriptUrl:e,start:t,latency:i-t,end:i,retryCount:r});n(true)}));i.addEventListener("error",(function(n){i.remove();console.error(n);var a=now();logError("[components-sdk] Failed to load script",{scriptUrl:e,error:n,start:t,latency:a-t,end:a,retryCount:r});o(new LoadScriptError("Failed to load Airwallex SDK scripts: ".concat(e)))}))}))]}))}))};n.label=1;case 1:if(!(r<MAX_RETRY_COUNT))return[3,7];n.label=2;case 2:n.trys.push([2,4,,6]);return[4,t()];case 3:return[2,n.sent()];case 4:n.sent();r++;return[4,sleep()];case 5:n.sent();return[3,6];case 6:return[3,1];case 7:logError("[components-sdk] Failed to load script after retry",{scriptUrl:e,retryCount:r});throw new LoadScriptError("Failed to load Airwallex SDK scripts: ".concat(e))}}))}))};var InstanceNotFoundError=function(e){__extends(r,e);function r(r){var t=e.call(this,r)||this;t.code="INSTANCE_NOT_FOUND_ERROR";return t}return r}(Error);var initPromise$1;var promiseMap=new Map;var getLoadScriptPromise=function(e){var r=e.env,t=e.scriptName;var n=getSDKUrl({name:t,env:r});var i=promiseMap.get(t);if(i){return i}var o=loadScript(n);promiseMap.set(t,o);return o};var loadSDKWithDependencies=function(e){var r=e.env,t=e.scriptName;return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(n){switch(n.label){case 0:e=getSDKDependencies(t);if(!(e.length>0))return[3,2];return[4,Promise.all(e.map((function(e){return getLoadScriptPromise({env:r,scriptName:e})})))];case 1:n.sent();n.label=2;case 2:return[2,getLoadScriptPromise({env:r,scriptName:t})]}}))}))};var init=function(e){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(r){if(typeof window==="undefined"){throw new Error("Please call the `init()` function in a browser environment.")}initializeAirTracker(e.env,e.clientId);logInfo("[components-sdk] SDK init start",{options:maskPII(e),start:now()});initPromise$1=new Promise((function(r,t){var n;var i=__assign(__assign({},e),{env:e.env&&ENV[e.env]?e.env:ENV.prod});window.AirwallexComponentsSDK.__env__=i.env;var o=getLoadScriptPromise({env:i.env,scriptName:SDK_CONTROLLER}).then((function(){return window._AirwallexSDKs.__controller__.init(i)}));var a=(n=e.enabledElements)!==null&&n!==void 0?n:[];var s=getFunctionsByEnabledElements(a);var u=s.map((function(e){return getLoadScriptPromise({env:i.env,scriptName:e}).then((function(){return o})).then((function(){var r=window._AirwallexSDKs[getWindowSDKInstanceName(e)];if(!r){logError("[components-sdk] SDK instance not found",{functionsNamespace:e,windowSDKInstanceName:getWindowSDKInstanceName(e)});throw new InstanceNotFoundError("SDK instance not found")}return window._AirwallexSDKs.__controller__.registerFunctions({functionsNamespace:e,instance:r})}))}));var l=getSDKsByEnabledElements(a);var c=l.map((function(e){var r=e.sdkName,t=e.elementName;return loadSDKWithDependencies({scriptName:r,env:i.env}).then((function(){return o})).then((function(){var e=window._AirwallexSDKs[getWindowSDKInstanceName(r)];if(!e){logError("[components-sdk] SDK instance not found",{sdkName:r,windowSDKInstanceName:getWindowSDKInstanceName(r)});throw new InstanceNotFoundError("SDK instance not found")}return window._AirwallexSDKs.__controller__.registerElement({sdkName:r,elementName:t,instance:e})}))}));Promise.all(__spreadArray(__spreadArray([o],u,true),c,true)).then((function(){logInfo("[components-sdk] SDK initialized",{options:maskPII(e),start:now()});r(getFunctionsInstanceWithNamespace())}))["catch"]((function(e){if(!e.code){logError("[components-sdk] Unexpected errors when init",{error:e})}t(e)}))}));return[2,initPromise$1]}))}))};var createElement=function(e,r){return __awaiter(void 0,void 0,void 0,(function(){var t,n,i,o,a;return __generator(this,(function(s){switch(s.label){case 0:if(!e){throw new Error("Element type is missing. Please specify a valid element.")}logInfo("[components-sdk] SDK createElement start",{elementName:e,options:maskPII(r),timestamp:now()});if(!initPromise$1){logWarning("[components-sdk] Did not call init before createElement");throw new Error("Please initialize the Element before creating it.")}return[4,initPromise$1];case 1:s.sent();t=getSDKByElementName(e);if(!t){throw new Error("`createElement()` with type `".concat(e,"` is not supported. Please specify a valid Element type."))}n=now();s.label=2;case 2:s.trys.push([2,6,,7]);return[4,loadSDKWithDependencies({scriptName:t,env:window.AirwallexComponentsSDK.__env__||ENV.prod})];case 3:s.sent();return[4,window._AirwallexSDKs.__controller__.registerElement({sdkName:t,elementName:e,instance:window._AirwallexSDKs[getWindowSDKInstanceName(t)]})];case 4:s.sent();return[4,window._AirwallexSDKs.__controller__.createElement(e,r)];case 5:i=s.sent();o=now();logInfo("[components-sdk] SDK createElement being called",{elementName:e,options:maskPII(r),start:n,latency:o-n,end:o});return[3,7];case 6:a=s.sent();if(!a.code){logError("[components-sdk] Unexpected errors when createElement",{error:a})}else{throw a}return[3,7];case 7:return[2,i]}}))}))};var PREFETCH_SCRIPT_LIST=[SDK_CONTROLLER,PAYMENTS];var prefetchScripts=function(){PREFETCH_SCRIPT_LIST.forEach((function(e){var r=getSDKUrl({name:e,env:ENV.prod});var t=document.createElement("link");t.href=r;t.rel="modulepreload";t.as="script";var n=document.head||document.body;n.appendChild(t)}))};var isNode=typeof document==="undefined"||typeof window==="undefined";if(!isNode){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",prefetchScripts)}else{prefetchScripts()}}if(typeof window!=="undefined"){if(!window.AirwallexComponentsSDK){Object.defineProperties(window,{AirwallexComponentsSDK:{value:{},writable:false},_AirwallexSDKs:{value:{},writable:false}})}window.AirwallexComponentsSDK.init=init;window.AirwallexComponentsSDK.createElement=createElement}var _l=createStore((function(){return{clientSecret:null,currency:null,hasPaymentError:false,isReady:false,paymentConfirmed:false,paymentIntentId:null}})),airwallexStoreOnChange=_l.onChange,airwallexStoreReset=_l.reset,airwallexStore=_l.state;var airwallexStoreSetFromSession=function(e){if(e.paymentProcessor!=="AIRWALLEX"){return false}if(e.clientSecret){airwallexStore.clientSecret=e.clientSecret}if(e.paymentIntentId){airwallexStore.paymentIntentId=e.paymentIntentId}if(!airwallexStore.clientSecret){logError$1("Airwallex checkout session is missing the client secret");return false}return true};var airwallexLocaleByCode={ar:"ar",da:"da",de:"de",en:"en",es:"es",fr:"fr",id:"id",it:"it",ja:"ja",ko:"ko",nl:"nl",pl:"pl",pt:"pt",ru:"ru",sv:"sv",zh:"zh"};var airwallexStoreGetLocale=function(e){return airwallexLocaleByCode[e]||"en"};var initPromise=null;var airwallexStoreInitSdk=function(){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(r){if(airwallexStore.isReady){return[2,true]}if(!initPromise){e=(!zonosStore.zonosMode||zonosStore.zonosMode==="production")&&zonosStore.checkoutSettings.mode==="LIVE";initPromise=init({enabledElements:["payments"],env:e?"prod":"demo",locale:airwallexStoreGetLocale(localizationStore.selectedLocale)}).then((function(){airwallexStore.isReady=true;log("Airwallex SDK initialized");return true})).catch((function(e){logError$1(e);initPromise=null;return false}))}return[2,initPromise]}))}))};var airwallexPaidStatuses=["SUCCEEDED","REQUIRES_CAPTURE","PENDING_REVIEW","PENDING"];var airwallexStoreIsPaidStatus=function(e){return!!e&&airwallexPaidStatuses.includes(e)};var airwallexStoreMessageBasedOnStatus=function(e){switch(e){case"SUCCEEDED":{return{isError:false,messages:[translate("Thank you for submitting your payment. We appreciate your prompt attention."),"",translate("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]}}case"PENDING":case"PENDING_REVIEW":case"REQUIRES_CAPTURE":{return{isError:false,messages:[translate("Payment processing. We'll update you when payment is received.")]}}case"REQUIRES_CUSTOMER_ACTION":{return{isError:false,messages:[translate("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}}case"CANCELLED":case"REQUIRES_PAYMENT_METHOD":{return{isError:true,messages:[translate("Payment failed. Please reload the page and try another payment method.")]}}default:{return{isError:true,messages:[translate("Something went wrong.")]}}}};var airwallexStoreRetrievePaymentIntent=function(e){return __awaiter(void 0,void 0,void 0,(function(){var r,t,n;return __generator(this,(function(i){switch(i.label){case 0:return[4,handleFetch("/api/zonos-elements/collect/airwallex-payment-intent",{body:{paymentIntentId:e},method:"POST"})];case 1:r=i.sent(),t=r.errors,n=r.json;if(t.length||!n){logError$1("Failed to retrieve Airwallex payment intent",t);return[2,{status:null}]}return[2,{status:n.airwallexPaymentIntent.status}]}}))}))};var _m=createStore((function(){return{amountDutyTaxFeeTotal:null,amountTotalPaid:null,collectLogoUrl:null,isFetchingShippingInfo:true,landedCostShortId:null,originCompanyName:null,partyBillingId:null,paymentProcessor:null,shippingAddress:null}})),collectStoreReset=_m.reset,collectStore=_m.state;var collectStoreInitShippingInfo=function(e){return __awaiter(void 0,[e],void 0,(function(e){var r,t,n,i,o,a,s,u,l,c,d,f,v,p;var m=e.landedCostId,_=e.retries,h=_===void 0?5:_;return __generator(this,(function(e){switch(e.label){case 0:collectStore.isFetchingShippingInfo=true;return[4,handleFetch("/api/zonos-elements/collect/get-shipping-info-by-lc-id",{body:{landedCostId:m},method:"POST"})];case 1:d=e.sent();if(!d.errors.length)return[3,4];if(!(h>0))return[3,3];return[4,new Promise((function(e){return setTimeout(e,1e3)}))];case 2:e.sent();return[2,collectStoreInitShippingInfo({landedCostId:m,retries:h-1})];case 3:return[2,null];case 4:collectStore.landedCostShortId=((r=d.json)===null||r===void 0?void 0:r.landedCostShortId)||null;collectStore.isFetchingShippingInfo=false;collectStore.shippingAddress=((t=d.json)===null||t===void 0?void 0:t.shipping)||null;f=(n=cartStore.checkoutSession)===null||n===void 0?void 0:n.landedCost;v=(i=cartStore.checkoutSession)===null||i===void 0?void 0:i.subtotals;p=(((o=f===null||f===void 0?void 0:f.amountSubtotals)===null||o===void 0?void 0:o.shipping)||0)+(((a=f===null||f===void 0?void 0:f.amountSubtotals)===null||a===void 0?void 0:a.items)||0);collectStore.amountTotalPaid=p*(((s=v===null||v===void 0?void 0:v.exchangeRate)===null||s===void 0?void 0:s.rate)||1);collectStore.amountDutyTaxFeeTotal=((v===null||v===void 0?void 0:v.duties)||0)+((v===null||v===void 0?void 0:v.taxes)||0)+((v===null||v===void 0?void 0:v.fees)||0);collectStore.originCompanyName=((l=(u=d.json)===null||u===void 0?void 0:u.origin)===null||l===void 0?void 0:l.companyName)||null;collectStore.collectLogoUrl=((c=d.json)===null||c===void 0?void 0:c.collectLogoUrl)||null;if(collectStore.amountTotalPaid===0){void sendErrorLog({endpoint:"COLLECT_NO_TOTAL_PAID",errors:[],metadata:{landedCostId:m,organizationId:zonosStore.organizationId}})}return[2]}}))}))};var collectStoreAsyncAddressUpdate=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,r,t,n,i,o,a,s,u,l;return __generator(this,(function(c){switch(c.label){case 0:if(!((e=stripeStore.stripeBillingAddressEventData)===null||e===void 0?void 0:e.complete)){return[2,{partiesCreated:false}]}i=(t=(r=cartStore.checkoutSession)===null||r===void 0?void 0:r.landedCost)===null||t===void 0?void 0:t.rootId;if(!i){void sendErrorLog({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId}});return[2,{partiesCreated:false}]}if(!storageStore.checkoutSessionId){void sendErrorLog({endpoint:"COLLECT_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,landedCostRootId:i}});return[2,{partiesCreated:false}]}o=stripeStoreBuildAddressForPartyCreate({address:stripeStore.stripeBillingAddressEventData.value.address,firstName:stripeStore.stripeBillingAddressEventData.value.firstName,lastName:stripeStore.stripeBillingAddressEventData.value.lastName,name:stripeStore.stripeBillingAddressEventData.value.name,phone:stripeStore.stripeBillingAddressEventData.value.phone});a=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,handleFetch("/api/zonos-elements/create-billing-party",{body:{billingAddress:o,checkoutSessionId:storageStore.checkoutSessionId,companyName:stripeStore.companyName,email:((n=stripeStore.stripeLinkEventData)===null||n===void 0?void 0:n.value.email)||"",isTest:a,rootId:i},method:"POST"})];case 1:s=c.sent(),u=s.errors,l=s.json;if(u.length||!l){logError$1("Error occurs when creating billing party",JSON.stringify(u,null,2));void sendErrorLog({endpoint:"COLLECT_BILLING_PARTY_CREATE_FAILED",errors:["[COLLECT] Failed to create billing party"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,errors:u,json:l}});return[2,{partiesCreated:false}]}collectStore.partyBillingId=l.billToPartyId;return[2,{partiesCreated:true}]}}))}))};var collectStoreUpdateSelectedShippingOption=function(e){return __awaiter(void 0,void 0,void 0,(function(){var r;return __generator(this,(function(t){r=e.landedCost;if(!r){return[2,false]}cartStore.landedCostData=[Object.assign(Object.assign({},e),{landedCost:Object.assign({},r),landedCostId:r.id})];return[2,cartStoreUpdateSelectedShippingOption({applySubtotalsOnly:true,landedCostId:r.id,selectedShippingOption:r.shipmentRating})]}))}))};export{airwallexStoreSetFromSession as a,airwallexStore as b,collectStore as c,airwallexStoreRetrievePaymentIntent as d,airwallexStoreIsPaidStatus as e,airwallexStoreInitSdk as f,collectStoreUpdateSelectedShippingOption as g,collectStoreInitShippingInfo as h,collectStoreAsyncAddressUpdate as i,airwallexStoreMessageBasedOnStatus as j,airwallexStoreReset as k,createElement as l,airwallexStoreGetLocale as m,airwallexStoreOnChange as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as isSameHostCheckoutLink}from"./isSameHostCheckoutLink-c1b88ab7.js";var formatStringWithLinks=function(r){var t=/\[([^\]]+)\]\((https?:\/\/[^\s\)]+)\)|(https?:\/\/[^\s]+)/g;var n=r.replace(t,(function(r,t,n,o){var i;var e=n||o;var s=!!((i=window.Zonos)===null||i===void 0?void 0:i.isBigCommerce)&&isSameHostCheckoutLink(e)?"_self":"_blank";var a=n?t:o;return'<zonos-link href="'.concat(e,'" target="').concat(s,'" rel="noopener noreferrer">').concat(a,"</zonos-link>")}));return n};export{formatStringWithLinks as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as localizationStore}from"./localization-
|
|
1
|
+
import{l as localizationStore}from"./localization-da2f407f.js";var DUTY_KEY="gkjqw123";var TAXES_KEY="Kq93wqw3";var hasInclusivePrice=function(){var i;return(i=localizationStore.inclusivePricingConfigurations)===null||i===void 0?void 0:i.some((function(i){var o,a;return((o=i.configurations[DUTY_KEY])===null||o===void 0?void 0:o.status)==="ENABLED"||((a=i.configurations[TAXES_KEY])===null||a===void 0?void 0:a.status)==="ENABLED"}))};export{DUTY_KEY as D,TAXES_KEY as T,hasInclusivePrice as h};
|
package/dist/esm-es5/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,n,o,t){function r(e){return e instanceof o?e:new o((function(n){n(e)}))}return new(o||(o=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function s(e){try{c(t["throw"](e))}catch(e){i(e)}}function c(e){e.done?o(e.value):r(e.value).then(a,s)}c((t=t.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,r,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return c([e,n])}}function c(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)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:o.label++;return{value:s[1],done:false};case 5:o.label++;r=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=n.call(e,o)}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,n,o){if(o||arguments.length===2)for(var t=0,r=n.length,i;t<r;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{c as createCustomEvent}from"./createCustomEvent-58159025.js";import{g as getGenericSettingsOverride,I as IframeService}from"./getGenericSettingsOverride-0bc3e118.js";import{l as log}from"./VarianceTest-572cecf5.js";export{a as availableTestKeys}from"./VarianceTest-572cecf5.js";import{g as getIsTestMode,a as getIsStagingMode,h as handleFetch,l as logError}from"./handleFetch-a844cac1.js";import{g as getAbandonedCartRenewTokenValue,_ as _getIsValidCartId,c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector}from"./CheckoutConfig-724d7bae.js";export{c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-724d7bae.js";export{c as countryRequireShortAddressCode}from"./ShortAddressCode-7620e622.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./TaxId-50d72254.js";var checkIfLoadVersionDomain=function(e){var n=e.loadScriptSrc;if(!n){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var t=["qa.js.zonos.com"];var r=new URL(n).origin;var i=o.some((function(e){return r.includes(e)}));var a=t.some((function(e){return r.includes(e)}));return{currentLoadScriptUrl:r,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(e){var n=fallbackList.indexOf(e);var o=fallbackList[n+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n,o,t,r,i;return __generator(this,(function(a){switch(a.label){case 0:e=getIsTestMode();n=getIsStagingMode();if(!e&&!n||!window.Zonos.zonosApiKey){return[2,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");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,null]}return[4,handleFetch("/api/get-test-public-credential")];case 1:o=a.sent(),t=o.errors,r=o.json;if(t.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);return[2,null]}i=r.publicCredential;if(!i){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2,i]}}))}))};var extractZonosQaUrl=function(e){if(!e){return null}var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t=/[^a-zA-Z0-9-_]+/.test(o);if(!!t){return null}return o};var getZonosQaUrl=function(){var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=extractZonosQaUrl(window.location.href);var o="https://v1.3.279.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-"))){return o}if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var t="preview.js.zonos.com";var r="https://".concat(n,".").concat(t);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements script"),"warn");void fetch(r).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(r,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var n=window.location.pathname;var o="".concat(n,"?").concat(e.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return r};var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;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 n=0;n<e.length;n++){var o=e[n];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(n);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(o);return o};var zonosStripeLoadScript=function(e){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(n,o){if(typeof window==="undefined"||typeof document==="undefined"){n(null);return}if(window.Stripe&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){n(window.Stripe);return}try{var t=zonosStripeFindScript();if(t&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!t){t=injectScript(e)}t===null||t===void 0?void 0:t.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));t===null||t===void 0?void 0:t.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(e){o(e);return}}));return stripePromise$1};var registerWrapper=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var initStripe=function(e,n,o){if(e===null){return null}var t=e.apply(undefined,n);registerWrapper(t,o);return t};var hasCheckoutCartCallback=function(){var e,n;return typeof window!=="undefined"&&(typeof((e=window.Zonos)===null||e===void 0?void 0:e.createCartId)==="function"||typeof((n=window.Zonos)===null||n===void 0?void 0:n.buildCartDetail)==="function")};var stripePromise=Promise.resolve().then((function(){if(!hasCheckoutCartCallback()){return null}return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(e){if(!loadCalled){console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r;return __generator(this,(function(i){switch(i.label){case 0:loadCalled=true;o=Date.now();return[4,stripePromise];case 1:if(!((n=i.sent())!==null&&n!==void 0))return[3,2];r=n;return[3,4];case 2:return[4,zonosStripeLoadScript(null)];case 3:r=i.sent();i.label=4;case 4:t=r;return[2,initStripe(t,e,o)]}}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var n=e.get(TEMP_CART_ID_QUERY_PARAM);return n};var getCartInfoById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,o,t,r,i,a,s,c,u;var d=e.cartId,l=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=getIsTestMode();o=getGenericSettingsOverride();t=getAbandonedCartRenewTokenValue()||undefined;r=new URLSearchParams;if(o.overrideShouldEnabledCustomAddress){r.set("overrideShouldEnabledCustomAddress",o.overrideShouldEnabledCustomAddress)}return[4,handleFetch("/api/zonos-elements/get-cart?".concat(r.toString()),{body:{isTestMode:n,renewCartExpirationToken:t,tempCartUUID:d},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:i=e.sent(),a=i.errors,s=i.json,c=i.zonosMode;u=!s||a.length;if(!(u&&l))return[3,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:l});return[4,new Promise((function(e){return setTimeout(e,500)}))];case 2:e.sent();return[2,getCartInfoById({cartId:d,retries:l-1})];case 3:if(u){return[2,null]}return[2,Object.assign(Object.assign({},s),{zonosMode:c})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r;return __generator(this,(function(i){switch(i.label){case 0:n=_getIsValidCartId(e),o=n.isDgsCartId,t=n.isLegacyCartId;if(!t&&!o){logError("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,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,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;window.Zonos.zonosMode=r.zonosMode;return[2,{cartData:r.cartData,settings:r.settings,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),o=n.currentLoadScriptUrl,t=n.isWhiteListed;if(t){return o}return null}();var startLoadTime=Date.now();var ZONOS_URL="https://v1.3.279.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.279";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.279";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.279";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;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="1783027606083";Zonos.isLegacyCheckout=false;Zonos.googleAnalyticId=null;Zonos.googleAnalyticReady=false;Zonos.facebookPixelId=null;Zonos.facebookPixelReady=false;Zonos.startLoadTime=startLoadTime;Zonos.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.overrideUseCustomAddressForm=false;Zonos.isCollect=false;Zonos.isInvoice=false;Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.3.279");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 n,o,t,r,i,a,s,c,u,d,l,f,v,m,_;return __generator(this,(function(p){switch(p.label){case 0:n=e.appearance,o=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,c=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();_a.createCartId=o===null||o===void 0?void 0:o.createCartId;_a.buildCartDetail=o===null||o===void 0?void 0:o.buildCartDetail;if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=c;_a.storeId=s;if(typeof window!=="undefined"&&window.parent===window){_a.googleAnalyticReady=true;_a.facebookPixelReady=true}if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");u=getZonosQaUrl();if(u&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(u," ======"),"info");d=document.createElement("script");d.src="".concat(u,"/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;void window.Zonos.init(e)}));d.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(u))}));window.isZonosPreview=true;return[2]}if(!c&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_a.cartData&&_a.cartId))return[3,2];log("Initialize cart data");return[4,setupCartDataWithSettings(_a.cartId)];case 1:l=p.sent();if(!l){logError("Failed to get cart data");return[2]}_a.cartData=l.cartData;_a.zonosApiKey=l.zonosApiKey;_a.cartSettings=l.settings;p.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=p.sent();if(f){_a.zonosApiKey=f}p.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;if(m){log("Cart data or stripe client secret is available, inject hidden button and trigger checkout");_=document.createElement("button");_.style.display="none";_.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(_)}log("init zonos");_a.restoreNativeBrowserFunctions();_a.injectCustomScriptForHostedCheckout();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectCheckoutInternationalButton();_a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.injectCheckoutInternationalButton=function(){if(!document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector))){var e=document.createElement("button");e.id=checkoutHiddenInternationalBtnSelector;e.style.display="none";document.body.appendChild(e)}};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var o=n.find((function(e){return e.key==="customHeaderScript"}));var t=n.find((function(e){return e.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!o&&!t){log("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(o){log("Injecting custom header script");var r=document.createElement("script");r.textContent=o.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(n){e=document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector));setTimeout((function(){if(e){e.dispatchEvent(createCustomEvent("click"))}}),10);return[2]}))}))};Zonos.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};Zonos.showNotification=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.showNotification(e))};Zonos.updateOrganizationName=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};Zonos.disablePlaceOrderButtons=function(e){var n=e.autoEnable,o=n===void 0?true:n,t=e.config,r=e.disable,i=e.placeOrderButtonSelector;var a;if((a=t.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var c=function(e){var n=e.target;if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};s.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){return}if(r){e.setAttribute("disabled","true");e.addEventListener("click",c)}else{e.removeAttribute("disabled");e.removeEventListener("click",c)}}));if(o&&r){setTimeout((function(){s.forEach((function(e){e.removeAttribute("disabled");e.removeEventListener("click",c)}))}),5e3)}}};Zonos.restoreNativeBrowserFunctions=function(){var e;var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var o="zonos---native-browser";var t=document.querySelector("iframe#".concat(o));if(!t){t=document.createElement("iframe");t.id=o;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)}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 n=e.config;var o,t;if(document.querySelector("zonos-controller")){return}if((o=n.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var r=n.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r})}));i.observe(document.body,{childList:true,subtree:true})}if((t=n.checkoutSettings)===null||t===void 0?void 0:t.alwaysTriggerInternationalCheckoutSelector){var a=n.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}var s=document.createElement("zonos-controller");s.config=n;s.zonosApiKey=_a.zonosApiKey||"";s.addEventListener("stripeInitEvent",(function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o;return __generator(this,(function(t){switch(t.label){case 0:n=e.detail;log("loading Stripe");return[4,zonosLoadStripe(n.publishableKey)];case 1:o=t.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;if(window.Zonos.isCollect){void s.initCollectElement(o)}else if(window.Zonos.isInvoice){void s.initInvoiceElement(o)}else{void s.initCheckoutElement(o)}return[2]}}))}))}));document.body.appendChild(s);_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectScript=function(e){var n=e.cdnType,o=e.isModule,t=e.theRestUrl;var r=_a.getZonosUrl(n);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;var c=document.createElement("script");if(!!o){c.type="module"}else{c.noModule=true}c.src=i;c.crossOrigin="anonymous";c.onerror=function(){logError("Failed to load ".concat(c.src));var e=getNextFallbackUrl(n);if(!e){return}_a.injectScript({cdnType:e,isModule:o,theRestUrl:t})};s.appendChild(c)};Zonos.getZonosUrl=function(e){var n=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}};if(_a.isNpm){var o=getZonosQaUrl();return o||n()}return n()};Zonos.injectZonosCdn=function(){_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_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 n=e.cdnType,o=e.theRestUrl;var t=_a.getZonosUrl(n);var r=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");r.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var e=getNextFallbackUrl(n);if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:o})};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}_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 n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(GOOGLE_FONT_URL,'"]'));for(var o=0;o<n.length;o++){var t=n[o];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 n=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=GOOGLE_FONT_URL;n.appendChild(o);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");n.appendChild(t);log("Zonos font injected!")};Zonos.setupGoogleFont=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};Zonos.injectSupportGoogleFont=function(e){var n;log("[FONT] injecting ".concat(e));var o=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var t=document.head||document.body;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(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;t.appendChild(i);log("[FONT] ".concat(o," 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,checkoutSessionAttributeKeys,checkoutSessionImmutableAttributeKeys,checkoutSessionMutableAttributeKeys};
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,n,o,t){function r(e){return e instanceof o?e:new o((function(n){n(e)}))}return new(o||(o=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function s(e){try{c(t["throw"](e))}catch(e){i(e)}}function c(e){e.done?o(e.value):r(e.value).then(a,s)}c((t=t.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,r,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return c([e,n])}}function c(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)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:o.label++;return{value:s[1],done:false};case 5:o.label++;r=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=n.call(e,o)}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,n,o){if(o||arguments.length===2)for(var t=0,r=n.length,i;t<r;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{c as createCustomEvent}from"./createCustomEvent-58159025.js";import{g as getGenericSettingsOverride,I as IframeService}from"./getGenericSettingsOverride-0bc3e118.js";import{l as log}from"./VarianceTest-572cecf5.js";export{a as availableTestKeys}from"./VarianceTest-572cecf5.js";import{g as getIsTestMode,a as getIsStagingMode,h as handleFetch,l as logError}from"./handleFetch-a844cac1.js";import{g as getAbandonedCartRenewTokenValue,_ as _getIsValidCartId,c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector}from"./CheckoutConfig-724d7bae.js";export{c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-724d7bae.js";export{c as countryRequireShortAddressCode}from"./ShortAddressCode-7620e622.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./TaxId-50d72254.js";var checkIfLoadVersionDomain=function(e){var n=e.loadScriptSrc;if(!n){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var t=["qa.js.zonos.com"];var r=new URL(n).origin;var i=o.some((function(e){return r.includes(e)}));var a=t.some((function(e){return r.includes(e)}));return{currentLoadScriptUrl:r,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(e){var n=fallbackList.indexOf(e);var o=fallbackList[n+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n,o,t,r,i;return __generator(this,(function(a){switch(a.label){case 0:e=getIsTestMode();n=getIsStagingMode();if(!e&&!n||!window.Zonos.zonosApiKey){return[2,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");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,null]}return[4,handleFetch("/api/get-test-public-credential")];case 1:o=a.sent(),t=o.errors,r=o.json;if(t.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);return[2,null]}i=r.publicCredential;if(!i){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2,i]}}))}))};var extractZonosQaUrl=function(e){if(!e){return null}var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t=/[^a-zA-Z0-9-_]+/.test(o);if(!!t){return null}return o};var getZonosQaUrl=function(){var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=extractZonosQaUrl(window.location.href);var o="https://v1.3.280.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-"))){return o}if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var t="preview.js.zonos.com";var r="https://".concat(n,".").concat(t);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements script"),"warn");void fetch(r).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(r,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var n=window.location.pathname;var o="".concat(n,"?").concat(e.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return r};var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;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 n=0;n<e.length;n++){var o=e[n];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(n);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(o);return o};var zonosStripeLoadScript=function(e){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(n,o){if(typeof window==="undefined"||typeof document==="undefined"){n(null);return}if(window.Stripe&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){n(window.Stripe);return}try{var t=zonosStripeFindScript();if(t&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!t){t=injectScript(e)}t===null||t===void 0?void 0:t.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));t===null||t===void 0?void 0:t.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(e){o(e);return}}));return stripePromise$1};var registerWrapper=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var initStripe=function(e,n,o){if(e===null){return null}var t=e.apply(undefined,n);registerWrapper(t,o);return t};var hasCheckoutCartCallback=function(){var e,n;return typeof window!=="undefined"&&(typeof((e=window.Zonos)===null||e===void 0?void 0:e.createCartId)==="function"||typeof((n=window.Zonos)===null||n===void 0?void 0:n.buildCartDetail)==="function")};var stripePromise=Promise.resolve().then((function(){if(!hasCheckoutCartCallback()){return null}return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(e){if(!loadCalled){console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r;return __generator(this,(function(i){switch(i.label){case 0:loadCalled=true;o=Date.now();return[4,stripePromise];case 1:if(!((n=i.sent())!==null&&n!==void 0))return[3,2];r=n;return[3,4];case 2:return[4,zonosStripeLoadScript(null)];case 3:r=i.sent();i.label=4;case 4:t=r;return[2,initStripe(t,e,o)]}}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var n=e.get(TEMP_CART_ID_QUERY_PARAM);return n};var getCartInfoById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,o,t,r,i,a,s,c,u;var d=e.cartId,l=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=getIsTestMode();o=getGenericSettingsOverride();t=getAbandonedCartRenewTokenValue()||undefined;r=new URLSearchParams;if(o.overrideShouldEnabledCustomAddress){r.set("overrideShouldEnabledCustomAddress",o.overrideShouldEnabledCustomAddress)}return[4,handleFetch("/api/zonos-elements/get-cart?".concat(r.toString()),{body:{isTestMode:n,renewCartExpirationToken:t,tempCartUUID:d},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:i=e.sent(),a=i.errors,s=i.json,c=i.zonosMode;u=!s||a.length;if(!(u&&l))return[3,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:l});return[4,new Promise((function(e){return setTimeout(e,500)}))];case 2:e.sent();return[2,getCartInfoById({cartId:d,retries:l-1})];case 3:if(u){return[2,null]}return[2,Object.assign(Object.assign({},s),{zonosMode:c})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r;return __generator(this,(function(i){switch(i.label){case 0:n=_getIsValidCartId(e),o=n.isDgsCartId,t=n.isLegacyCartId;if(!t&&!o){logError("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,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,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;window.Zonos.zonosMode=r.zonosMode;return[2,{cartData:r.cartData,settings:r.settings,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),o=n.currentLoadScriptUrl,t=n.isWhiteListed;if(t){return o}return null}();var startLoadTime=Date.now();var ZONOS_URL="https://v1.3.280.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.280";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.280";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.280";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;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="1783609436334";Zonos.isLegacyCheckout=false;Zonos.googleAnalyticId=null;Zonos.googleAnalyticReady=false;Zonos.facebookPixelId=null;Zonos.facebookPixelReady=false;Zonos.startLoadTime=startLoadTime;Zonos.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.overrideUseCustomAddressForm=false;Zonos.isCollect=false;Zonos.isInvoice=false;Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.3.280");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 n,o,t,r,i,a,s,c,u,d,l,f,v,m,_;return __generator(this,(function(p){switch(p.label){case 0:n=e.appearance,o=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,c=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();_a.createCartId=o===null||o===void 0?void 0:o.createCartId;_a.buildCartDetail=o===null||o===void 0?void 0:o.buildCartDetail;if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=c;_a.storeId=s;if(typeof window!=="undefined"&&window.parent===window){_a.googleAnalyticReady=true;_a.facebookPixelReady=true}if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");u=getZonosQaUrl();if(u&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(u," ======"),"info");d=document.createElement("script");d.src="".concat(u,"/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;void window.Zonos.init(e)}));d.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(u))}));window.isZonosPreview=true;return[2]}if(!c&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_a.cartData&&_a.cartId))return[3,2];log("Initialize cart data");return[4,setupCartDataWithSettings(_a.cartId)];case 1:l=p.sent();if(!l){logError("Failed to get cart data");return[2]}_a.cartData=l.cartData;_a.zonosApiKey=l.zonosApiKey;_a.cartSettings=l.settings;p.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=p.sent();if(f){_a.zonosApiKey=f}p.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;if(m){log("Cart data or stripe client secret is available, inject hidden button and trigger checkout");_=document.createElement("button");_.style.display="none";_.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(_)}log("init zonos");_a.restoreNativeBrowserFunctions();_a.injectCustomScriptForHostedCheckout();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectCheckoutInternationalButton();_a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.injectCheckoutInternationalButton=function(){if(!document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector))){var e=document.createElement("button");e.id=checkoutHiddenInternationalBtnSelector;e.style.display="none";document.body.appendChild(e)}};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var o=n.find((function(e){return e.key==="customHeaderScript"}));var t=n.find((function(e){return e.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!o&&!t){log("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(o){log("Injecting custom header script");var r=document.createElement("script");r.textContent=o.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(n){e=document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector));setTimeout((function(){if(e){e.dispatchEvent(createCustomEvent("click"))}}),10);return[2]}))}))};Zonos.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};Zonos.showNotification=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.showNotification(e))};Zonos.updateOrganizationName=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};Zonos.disablePlaceOrderButtons=function(e){var n=e.autoEnable,o=n===void 0?true:n,t=e.config,r=e.disable,i=e.placeOrderButtonSelector;var a;if((a=t.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var c=function(e){var n=e.target;if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};s.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){return}if(r){e.setAttribute("disabled","true");e.addEventListener("click",c)}else{e.removeAttribute("disabled");e.removeEventListener("click",c)}}));if(o&&r){setTimeout((function(){s.forEach((function(e){e.removeAttribute("disabled");e.removeEventListener("click",c)}))}),5e3)}}};Zonos.restoreNativeBrowserFunctions=function(){var e;var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var o="zonos---native-browser";var t=document.querySelector("iframe#".concat(o));if(!t){t=document.createElement("iframe");t.id=o;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)}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 n=e.config;var o,t;if(document.querySelector("zonos-controller")){return}if((o=n.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var r=n.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r})}));i.observe(document.body,{childList:true,subtree:true})}if((t=n.checkoutSettings)===null||t===void 0?void 0:t.alwaysTriggerInternationalCheckoutSelector){var a=n.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}var s=document.createElement("zonos-controller");s.config=n;s.zonosApiKey=_a.zonosApiKey||"";s.addEventListener("stripeInitEvent",(function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o;return __generator(this,(function(t){switch(t.label){case 0:n=e.detail;log("loading Stripe");return[4,zonosLoadStripe(n.publishableKey)];case 1:o=t.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;if(window.Zonos.isCollect){void s.initCollectElement(o)}else if(window.Zonos.isInvoice){void s.initInvoiceElement(o)}else{void s.initCheckoutElement(o)}return[2]}}))}))}));document.body.appendChild(s);_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectScript=function(e){var n=e.cdnType,o=e.isModule,t=e.theRestUrl;var r=_a.getZonosUrl(n);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;var c=document.createElement("script");if(!!o){c.type="module"}else{c.noModule=true}c.src=i;c.crossOrigin="anonymous";c.onerror=function(){logError("Failed to load ".concat(c.src));var e=getNextFallbackUrl(n);if(!e){return}_a.injectScript({cdnType:e,isModule:o,theRestUrl:t})};s.appendChild(c)};Zonos.getZonosUrl=function(e){var n=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}};if(_a.isNpm){var o=getZonosQaUrl();return o||n()}return n()};Zonos.injectZonosCdn=function(){_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_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 n=e.cdnType,o=e.theRestUrl;var t=_a.getZonosUrl(n);var r=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");r.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var e=getNextFallbackUrl(n);if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:o})};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}_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 n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(GOOGLE_FONT_URL,'"]'));for(var o=0;o<n.length;o++){var t=n[o];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 n=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=GOOGLE_FONT_URL;n.appendChild(o);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");n.appendChild(t);log("Zonos font injected!")};Zonos.setupGoogleFont=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};Zonos.injectSupportGoogleFont=function(e){var n;log("[FONT] injecting ".concat(e));var o=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var t=document.head||document.body;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(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;t.appendChild(i);log("[FONT] ".concat(o," 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,checkoutSessionAttributeKeys,checkoutSessionImmutableAttributeKeys,checkoutSessionMutableAttributeKeys};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,r,t,o){function n(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,i){function a(e){try{d(o.next(e))}catch(e){i(e)}}function s(e){try{d(o["throw"](e))}catch(e){i(e)}}function d(e){e.done?t(e.value):n(e.value).then(a,s)}d((o=o.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return d([e,r])}}function d(s){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(o=1,n&&(i=s[0]&2?n["return"]:s[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;if(n=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;n=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1];i=s;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(s);break}if(i[2])t.ops.pop();t.trys.pop();continue}s=r.call(e,t)}catch(e){s=[6,e];n=0}finally{o=i=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-b7d3f9b0.js";import{b as stripeStore,K as stripeStoreBuildAddressForPartyCreate,d as cartStore,L as cartStoreUpdateSelectedShippingOption}from"./cart-
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,r,t,o){function n(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,i){function a(e){try{d(o.next(e))}catch(e){i(e)}}function s(e){try{d(o["throw"](e))}catch(e){i(e)}}function d(e){e.done?t(e.value):n(e.value).then(a,s)}d((o=o.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return d([e,r])}}function d(s){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(o=1,n&&(i=s[0]&2?n["return"]:s[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;if(n=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;n=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1];i=s;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(s);break}if(i[2])t.ops.pop();t.trys.pop();continue}s=r.call(e,t)}catch(e){s=[6,e];n=0}finally{o=i=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-b7d3f9b0.js";import{b as stripeStore,K as stripeStoreBuildAddressForPartyCreate,d as cartStore,L as cartStoreUpdateSelectedShippingOption}from"./cart-4699e6ab.js";import{s as storageStore}from"./localization-da2f407f.js";import{h as handleFetch,s as sendErrorLog,l as logError}from"./handleFetch-a844cac1.js";import{b as allLogs}from"./VarianceTest-572cecf5.js";var _e=createStore((function(){return{amountTotalDue:null,isFetchingPayorInfo:true,landedCostShortId:null,partyBillingId:null,payorAddress:null}})),invoiceStoreReset=_e.reset,invoiceStore=_e.state;var invoiceStoreInitShippingInfo=function(e){return __awaiter(void 0,[e],void 0,(function(e){var r,t,o,n,i;var a=e.landedCostId,s=e.retries,d=s===void 0?5:s;return __generator(this,(function(e){switch(e.label){case 0:invoiceStore.isFetchingPayorInfo=true;return[4,handleFetch("/api/zonos-elements/invoice/get-payor-info-by-lc-id",{body:{landedCostId:a},method:"POST"})];case 1:n=e.sent();if(!n.errors.length)return[3,4];if(!(d>0))return[3,3];return[4,new Promise((function(e){return setTimeout(e,1e3)}))];case 2:e.sent();return[2,invoiceStoreInitShippingInfo({landedCostId:a,retries:d-1})];case 3:return[2,null];case 4:invoiceStore.landedCostShortId=((r=n.json)===null||r===void 0?void 0:r.landedCostShortId)||null;invoiceStore.isFetchingPayorInfo=false;invoiceStore.payorAddress=((t=n.json)===null||t===void 0?void 0:t.payor)||null;i=(o=cartStore.checkoutSession)===null||o===void 0?void 0:o.subtotals;invoiceStore.amountTotalDue=(i===null||i===void 0?void 0:i.items)||0;if(invoiceStore.amountTotalDue===0){void sendErrorLog({endpoint:"INVOICE_NO_TOTAL_DUE",errors:[],metadata:{landedCostId:a,organizationId:zonosStore.organizationId}})}return[2]}}))}))};var invoiceStoreAsyncAddressUpdate=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,r,t,o,n,i,a,s,d,c;return __generator(this,(function(l){switch(l.label){case 0:if(!((e=stripeStore.stripeBillingAddressEventData)===null||e===void 0?void 0:e.complete)){return[2,{partiesCreated:false}]}n=(t=(r=cartStore.checkoutSession)===null||r===void 0?void 0:r.landedCost)===null||t===void 0?void 0:t.rootId;if(!n){void sendErrorLog({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId}});return[2,{partiesCreated:false}]}if(!storageStore.checkoutSessionId){void sendErrorLog({endpoint:"INVOICE_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,landedCostRootId:n}});return[2,{partiesCreated:false}]}i=stripeStoreBuildAddressForPartyCreate({address:stripeStore.stripeBillingAddressEventData.value.address,firstName:stripeStore.stripeBillingAddressEventData.value.firstName,lastName:stripeStore.stripeBillingAddressEventData.value.lastName,name:stripeStore.stripeBillingAddressEventData.value.name,phone:stripeStore.stripeBillingAddressEventData.value.phone});a=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,handleFetch("/api/zonos-elements/create-billing-party",{body:{billingAddress:i,checkoutSessionId:storageStore.checkoutSessionId,companyName:stripeStore.companyName,email:((o=stripeStore.stripeLinkEventData)===null||o===void 0?void 0:o.value.email)||"",isTest:a,rootId:n},method:"POST"})];case 1:s=l.sent(),d=s.errors,c=s.json;if(d.length||!c){logError("Error occurs when creating billing party",JSON.stringify(d,null,2));void sendErrorLog({endpoint:"INVOICE_BILLING_PARTY_CREATE_FAILED",errors:["[INVOICE] Failed to create billing party"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,errors:d,json:c}});return[2,{partiesCreated:false}]}invoiceStore.partyBillingId=c.billToPartyId;return[2,{partiesCreated:true}]}}))}))};var invoiceStoreUpdateSelectedShippingOption=function(e){return __awaiter(void 0,void 0,void 0,(function(){var r;return __generator(this,(function(t){r=e.landedCost;if(!r){return[2,false]}cartStore.landedCostData=[Object.assign(Object.assign({},e),{landedCost:Object.assign({},r),landedCostId:r.id})];return[2,cartStoreUpdateSelectedShippingOption({applySubtotalsOnly:true,landedCostId:r.id,selectedShippingOption:r.shipmentRating})]}))}))};export{invoiceStoreInitShippingInfo as a,invoiceStoreAsyncAddressUpdate as b,invoiceStore as c,invoiceStoreUpdateSelectedShippingOption as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var isSameHostCheckoutLink=function(t){try{var e=new URL(t,window.location.href);var n=e.pathname.replace(/\/+$/,"");return e.hostname===window.location.hostname&&n==="/checkout"}catch(t){return false}};export{isSameHostCheckoutLink as i};
|