@zonos/elements 1.3.290 → 1.3.292
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-7DceSLKl.js → cart-B6Aty-21.js} +1 -1
- package/dist/cjs/{collect-C08DUE1L.js → collect-Oeo5tjN5.js} +2 -2
- package/dist/cjs/{getMissingRequiredShippingFields-Duz8xpmf.js → getMissingRequiredShippingFields-D03ICqss.js} +1 -1
- package/dist/cjs/{hasInclusivePrice-C-iyXqJ0.js → hasInclusivePrice-CPCoVeU3.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{invoice-DSuHUQpi.js → invoice-Cj8W7NW0.js} +2 -2
- package/dist/cjs/{localization-BJqYz_PB.js → localization-BzNeXeDe.js} +24 -15
- package/dist/cjs/{paypal-CZoctP9S.js → paypal-CuKshRmZ.js} +2 -2
- package/dist/cjs/{placeTestOrder-D7baFuaV.js → placeTestOrder-7czjwkjm.js} +2 -2
- package/dist/cjs/{renderCheckoutCurrency-Ca2HH1Gc.js → renderCheckoutCurrency-BH8t2b2x.js} +2 -2
- package/dist/cjs/{shouldShowLanguageSelect-FyTdz7U_.js → shouldShowLanguageSelect-yAbtCmd8.js} +1 -1
- package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +3 -3
- package/dist/cjs/zonos-address-display_2.cjs.entry.js +1 -1
- 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 +8 -8
- package/dist/cjs/zonos-checkout.cjs.entry.js +3 -3
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +2 -2
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +7 -7
- 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 +2 -2
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
- 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 +7 -7
- 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/store/hello/localization.js +4 -1
- package/dist/collection/components/utils/hello/countryOverrideStorage.js +20 -14
- package/dist/esm/{cart-Cleo1j5P.js → cart-BoQp8Ema.js} +1 -1
- package/dist/esm/{collect-CspdWIRo.js → collect-CdrR5OBy.js} +2 -2
- package/dist/esm/{getMissingRequiredShippingFields-B1IL1-gn.js → getMissingRequiredShippingFields-Ks6_tpjn.js} +1 -1
- package/dist/esm/{hasInclusivePrice-DKRplpLX.js → hasInclusivePrice-CbEfIhI5.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/{invoice-D49igPQ9.js → invoice-S1KahJ_Z.js} +2 -2
- package/dist/esm/{localization-BiL8bPsY.js → localization-BIh-4pc_.js} +24 -15
- package/dist/esm/{paypal-D4vWRxHJ.js → paypal-DNfvnuUU.js} +2 -2
- package/dist/esm/{placeTestOrder-BNmc5RCo.js → placeTestOrder-CQaMKFOg.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-BNbwijGo.js → renderCheckoutCurrency-C2Tw73uR.js} +2 -2
- package/dist/esm/{shouldShowLanguageSelect-B82gTfHz.js → shouldShowLanguageSelect-CCD7gpSY.js} +1 -1
- package/dist/esm/zonos-address-completion-dialog_7.entry.js +3 -3
- package/dist/esm/zonos-address-display_2.entry.js +1 -1
- 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 +8 -8
- package/dist/esm/zonos-checkout.entry.js +3 -3
- package/dist/esm/zonos-collect-cart-items_3.entry.js +2 -2
- package/dist/esm/zonos-collect-finish_6.entry.js +7 -7
- 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 +2 -2
- package/dist/esm/zonos-country-select_4.entry.js +2 -2
- package/dist/esm/zonos-hello-dialog.entry.js +2 -2
- 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 +7 -7
- 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-Cleo1j5P.js → cart-BoQp8Ema.js} +8 -8
- package/dist/esm-es5/{collect-CspdWIRo.js → collect-CdrR5OBy.js} +1 -1
- package/dist/esm-es5/{getMissingRequiredShippingFields-B1IL1-gn.js → getMissingRequiredShippingFields-Ks6_tpjn.js} +3 -3
- package/dist/esm-es5/{hasInclusivePrice-DKRplpLX.js → hasInclusivePrice-CbEfIhI5.js} +1 -1
- package/dist/esm-es5/index.js +4 -4
- package/dist/esm-es5/{invoice-D49igPQ9.js → invoice-S1KahJ_Z.js} +1 -1
- package/dist/esm-es5/{localization-BiL8bPsY.js → localization-BIh-4pc_.js} +13 -3
- package/dist/esm-es5/{paypal-D4vWRxHJ.js → paypal-DNfvnuUU.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-BNmc5RCo.js → placeTestOrder-CQaMKFOg.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-BNbwijGo.js → renderCheckoutCurrency-C2Tw73uR.js} +2 -2
- package/dist/esm-es5/{shouldShowLanguageSelect-B82gTfHz.js → shouldShowLanguageSelect-CCD7gpSY.js} +1 -1
- package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +1 -1
- package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
- package/dist/esm-es5/zonos-address_4.entry.js +1 -1
- package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
- package/dist/esm-es5/zonos-card_5.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +3 -3
- 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 +2 -2
- 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 +2 -2
- 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 +2 -0
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/store/checkout/cart.d.ts +2 -0
- package/dist/types/components/utils/hello/countryOverrideStorage.d.ts +1 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-0ee74bf3.system.entry.js → p-04bded81.system.entry.js} +22 -22
- package/dist/zonos-elements/{p-c3b02dbf.entry.js → p-06fe2939.entry.js} +1 -1
- package/dist/zonos-elements/{p-13d3a372.system.entry.js → p-0b81f8b9.system.entry.js} +14 -14
- package/dist/zonos-elements/{p-d6b72f6d.entry.js → p-0fca452b.entry.js} +1 -1
- package/dist/zonos-elements/{p-a571beaa.system.entry.js → p-11defdca.system.entry.js} +16 -16
- package/dist/zonos-elements/{p-fb869759.system.entry.js → p-17c7ea4a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9ef0f69e.system.entry.js → p-23352709.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-a5c25829.system.entry.js → p-249c1ee1.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-52d9fd3a.entry.js → p-34656e6c.entry.js} +1 -1
- package/dist/zonos-elements/{p-c4ad6d4b.entry.js → p-39ee1558.entry.js} +1 -1
- package/dist/zonos-elements/p-4679f0ec.entry.js +1 -0
- package/dist/zonos-elements/{p-23f6346b.system.entry.js → p-4806b264.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-3c800376.system.entry.js → p-5016d71b.system.entry.js} +59 -59
- package/dist/zonos-elements/{p-5f347f91.system.entry.js → p-51400242.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-35509b10.system.entry.js → p-5236c676.system.entry.js} +20 -20
- package/dist/zonos-elements/{p-ddca5ee1.entry.js → p-550d4eea.entry.js} +1 -1
- package/dist/zonos-elements/{p-481ecc23.system.entry.js → p-552fbde1.system.entry.js} +20 -20
- package/dist/zonos-elements/{p-1b77464d.system.entry.js → p-5b80aff2.system.entry.js} +13 -13
- package/dist/zonos-elements/{p-079af8c0.system.entry.js → p-69c3e367.system.entry.js} +9 -9
- package/dist/zonos-elements/{p-7d284341.system.entry.js → p-6abec43f.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-5df25a1a.entry.js → p-6c41b00c.entry.js} +1 -1
- package/dist/zonos-elements/{p-f37b8aaf.system.entry.js → p-6db7c0b1.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-990b49f2.entry.js → p-6e296228.entry.js} +1 -1
- package/dist/zonos-elements/{p-BDrM4x5N.js → p-7abqRc9V.js} +2 -2
- package/dist/zonos-elements/{p-ba510730.entry.js → p-82595838.entry.js} +1 -1
- package/dist/zonos-elements/{p-84c9ce16.entry.js → p-938fc1e4.entry.js} +1 -1
- package/dist/zonos-elements/{p-7ee2af6e.system.entry.js → p-9c33f7ed.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-DVITR-Eu.system.js → p-Be3Hpms1.system.js} +1 -1
- package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
- package/dist/zonos-elements/{p-BT9_ehlh.system.js → p-CEK_Wk6v.system.js} +1 -1
- package/dist/zonos-elements/p-CFbfEmjN.js +1 -0
- package/dist/zonos-elements/p-D-bZg-Pc.js +1 -0
- package/dist/zonos-elements/{p-CASTsiDR.system.js → p-D4MevhAL.system.js} +3 -3
- package/dist/zonos-elements/{p-tGJYTlGL.system.js → p-DI2vXnXc.system.js} +3 -3
- package/dist/zonos-elements/{p-Cpe_ISNt.system.js → p-DNc279vN.system.js} +27 -27
- package/dist/zonos-elements/{p-CEmXVahp.system.js → p-DOD2I44l.system.js} +92 -82
- package/dist/zonos-elements/{p-uuZUZPIm.system.js → p-DS-qw_qc.system.js} +10 -10
- package/dist/zonos-elements/p-DZ2mevDK.js +1 -0
- package/dist/zonos-elements/{p-CewmhMGk.js → p-DzLNk-Pf.js} +1 -1
- package/dist/zonos-elements/{p-DwkyNtpD.js → p-FRWZayxL.js} +1 -1
- package/dist/zonos-elements/p-Mrz_lnC1.js +1 -0
- package/dist/zonos-elements/{p-B_5RofQ9.system.js → p-XDxdMlQl.system.js} +23 -23
- package/dist/zonos-elements/{p-DYIisqF7.system.js → p-XqkqjeNV.system.js} +1 -1
- package/dist/zonos-elements/{p-4fd78ecf.system.entry.js → p-a40fd99b.system.entry.js} +9 -9
- package/dist/zonos-elements/{p-79ddb12a.system.entry.js → p-b2dd7f02.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-11bab88b.entry.js → p-b79036fc.entry.js} +1 -1
- package/dist/zonos-elements/{p-26295311.entry.js → p-bb3546c0.entry.js} +1 -1
- package/dist/zonos-elements/p-c1cbfdba.entry.js +1 -0
- package/dist/zonos-elements/{p-7e1050dd.system.entry.js → p-c3646ae6.system.entry.js} +15 -15
- package/dist/zonos-elements/{p-028e0500.entry.js → p-c47ce656.entry.js} +1 -1
- package/dist/zonos-elements/{p-34c5e145.entry.js → p-c5bab786.entry.js} +1 -1
- package/dist/zonos-elements/{p-234c202c.entry.js → p-c961caaf.entry.js} +1 -1
- package/dist/zonos-elements/{p-NJVOYjda.js → p-c9QtIdJX.js} +1 -1
- package/dist/zonos-elements/{p-Cuk0LLGQ.js → p-clDfq9AL.js} +1 -1
- package/dist/zonos-elements/{p-db75322d.entry.js → p-d168023b.entry.js} +1 -1
- package/dist/zonos-elements/{p-5b06f069.entry.js → p-db87b0dd.entry.js} +1 -1
- package/dist/zonos-elements/{p-dd8ca91e.entry.js → p-defc2d18.entry.js} +1 -1
- package/dist/zonos-elements/{p-0dca8a26.system.entry.js → p-e0e9cff5.system.entry.js} +26 -26
- package/dist/zonos-elements/p-f8b50aa0.entry.js +1 -0
- package/dist/zonos-elements/{p-tkSf-lrO.system.js → p-kaOxUR9u.system.js} +5 -5
- package/dist/zonos-elements/p-rVp8hgWw.js +1 -0
- package/dist/zonos-elements/{p-B5NDhB1w.system.js → p-y7PFdTUN.system.js} +4 -4
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-35539d3d.entry.js +0 -1
- package/dist/zonos-elements/p-BJzAgoqz.js +0 -1
- package/dist/zonos-elements/p-BKoLoalh.js +0 -1
- package/dist/zonos-elements/p-BaF00SfB.js +0 -1
- package/dist/zonos-elements/p-BtWDzGMx.js +0 -1
- package/dist/zonos-elements/p-CX_vfdWt.js +0 -1
- package/dist/zonos-elements/p-ab54d0a1.entry.js +0 -1
- package/dist/zonos-elements/p-ca3175d9.entry.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,r,n,t){function o(e){return e instanceof n?e:new n((function(r){r(e)}))}return new(n||(n=Promise))((function(n,i){function a(e){try{u(t.next(e))}catch(e){i(e)}}function s(e){try{u(t["throw"](e))}catch(e){i(e)}}function u(e){e.done?n(e.value):o(e.value).then(a,s)}u((t=t.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(n=0)),n)try{if(t=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;o=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1];i=s;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(s);break}if(i[2])n.ops.pop();n.trys.pop();continue}s=r.call(e,n)}catch(e){s=[6,e];o=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,r,n){if(n||arguments.length===2)for(var t=0,o=r.length,i;t<o;t++){if(i||!(t in r)){if(!i)i=Array.prototype.slice.call(r,0,t);i[t]=r[t]}}return e.concat(i||Array.prototype.slice.call(r))};System.register(["./p-BuU_p5DP.system.js","./p-
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,r,n,t){function o(e){return e instanceof n?e:new n((function(r){r(e)}))}return new(n||(n=Promise))((function(n,i){function a(e){try{u(t.next(e))}catch(e){i(e)}}function s(e){try{u(t["throw"](e))}catch(e){i(e)}}function u(e){e.done?n(e.value):o(e.value).then(a,s)}u((t=t.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(n=0)),n)try{if(t=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;o=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1];i=s;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(s);break}if(i[2])n.ops.pop();n.trys.pop();continue}s=r.call(e,n)}catch(e){s=[6,e];o=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,r,n){if(n||arguments.length===2)for(var t=0,o=r.length,i;t<o;t++){if(i||!(t in r)){if(!i)i=Array.prototype.slice.call(r,0,t);i[t]=r[t]}}return e.concat(i||Array.prototype.slice.call(r))};System.register(["./p-BuU_p5DP.system.js","./p-DOD2I44l.system.js","./p-BbgqQIHv.system.js","./p-zVLAvre1.system.js","./p-DW-fW8yR.system.js","./p-DQZncB2d.system.js","./p-Cby4EkFu.system.js"],(function(e){"use strict";var r,n,t,o,i,a,s,u,d,l,c,v,f,p,m,h,w,y,g,b;return{setters:[function(e){r=e.c;n=e.z},function(e){t=e.s;o=e.t;i=e.m;a=e.l;s=e.f;u=e.e},function(e){d=e.l;l=e.b},function(e){c=e.h;v=e.l;f=e.f;p=e.g;m=e.a;h=e.s;w=e.j},function(e){y=e.i},function(e){g=e.g},function(e){b=e.e}],execute:function(){var _=this;var S=e("g",(function(){return __awaiter(_,void 0,void 0,(function(){var e,r,n,o;return __generator(this,(function(i){switch(i.label){case 0:if(!t.checkoutSessionId){return[2/*return*/,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",t.checkoutSessionId);return[4/*yield*/,c("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:r=i.sent(),n=r.errors,o=r.json;return[2/*return*/,{errors:n,json:o}]}}))}))}));var O=r((function(){return{amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:false,isEnabled:false,orderIdCreated:null,remainingBalance:null,useFullBalance:true}})),A=O.reset,C=O.state;e("R",C);
|
|
2
2
|
/**
|
|
3
3
|
* Reset store credit store to initial state
|
|
4
4
|
*/var k=e("S",(function(){A()}));
|
|
@@ -104,15 +104,15 @@ var i=Y({currentAddress:n,translatedAddress:le.translatedAddress.address});var a
|
|
|
104
104
|
firstName:v,lastName:f,phone:l.phone},checkoutSessionId:t.checkoutSessionId||"",contact:{companyName:le.companyName,email:r===null||r===void 0?void 0:r.value.email,
|
|
105
105
|
// firstName and lastName should be valid now since stripe only mark
|
|
106
106
|
// the address as complete when both fields are filled.
|
|
107
|
-
firstName:s,lastName:u,phone:i.phone},isTest:e,items:Qe.items,landedCostAdjustments:m,shipToShortAddressCode:le.shortAddressCode,shipToTaxId:le.taxId,shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}}};var
|
|
107
|
+
firstName:s,lastName:u,phone:i.phone},isTest:e,items:Qe.items,landedCostAdjustments:m,shipToShortAddressCode:le.shortAddressCode,shipToTaxId:le.taxId,shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}}};var G=function(e){return __awaiter(_,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l;return __generator(this,(function(v){switch(v.label){case 0:a=K();return[4/*yield*/,e({billingAddress:a.billingAddress,billingContact:a.billingContact,checkoutSessionId:a.checkoutSessionId,contact:a.contact,landedCostAdjustments:a.landedCostAdjustments,
|
|
108
108
|
// zonosApiKey should always be available
|
|
109
109
|
publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:a.shippingAddress,zonosApiRoute:f["vercel"]},{promoCode:Qe.promoCode})];case 1:s=v.sent();if(!s||
|
|
110
110
|
// Only show errors if there are no rate back (checkoutSessionWorkflow) and there are errors
|
|
111
|
-
!((r=s.checkoutSessionWorkflow)===null||r===void 0?void 0:r.length)&&((n=s.errors)===null||n===void 0?void 0:n.length)){throw new Error("Failed to build landed cost: ".concat(((o=(t=s===null||s===void 0?void 0:s.errors)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.message)||"Unknown error"))}return[4/*yield*/,c("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:u=v.sent(),d=u.errors,l=u.json;if(!l||d.length){throw new Error("Invalid landed cost object: ".concat(((i=d.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2/*return*/,s]}}))}))};var
|
|
111
|
+
!((r=s.checkoutSessionWorkflow)===null||r===void 0?void 0:r.length)&&((n=s.errors)===null||n===void 0?void 0:n.length)){throw new Error("Failed to build landed cost: ".concat(((o=(t=s===null||s===void 0?void 0:s.errors)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.message)||"Unknown error"))}return[4/*yield*/,c("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:u=v.sent(),d=u.errors,l=u.json;if(!l||d.length){throw new Error("Invalid landed cost object: ".concat(((i=d.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2/*return*/,s]}}))}))};var V=function(e){return __awaiter(_,void 0,void 0,(function(){var r,t,o,i,a,s,u;return __generator(this,(function(d){switch(d.label){case 0:t=n.checkoutSettings.buildLandedCost;if(!t)return[3/*break*/,2];return[4/*yield*/,G(t)];case 1:o=d.sent();return[2/*return*/,o];case 2:return[4/*yield*/,c("/api/zonos-elements/calculate-landed-cost",{body:K(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:i=d.sent(),a=i.errors,s=i.json;if(a.length||!s){u=((r=a[0])===null||r===void 0?void 0:r.message)==="The user aborted a request.";if(u){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}
|
|
112
112
|
// We want to show any successful quotes even if there are errors
|
|
113
113
|
a.forEach((function(e){
|
|
114
114
|
// eslint-disable-next-line no-console
|
|
115
|
-
console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2/*return*/,s]}return[2/*return*/,s]}}))}))};var Q=function(e){return __awaiter(_,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l;var v=e.abortController,f=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4/*yield*/,c("/api/zonos-elements/cart-calculate-landed-cost",{body:H(f),method:"POST",signal:v===null||v===void 0?void 0:v.signal})];case 1:a=e.sent(),s=a.errors,u=a.json;if(s.length||!u){d=typeof((r=s[0])===null||r===void 0?void 0:r.message)==="string"&&(((n=s[0])===null||n===void 0?void 0:n.message)==="The user aborted a request."||((t=s[0])===null||t===void 0?void 0:t.message.includes("signal is aborted"))||((o=s[0])===null||o===void 0?void 0:o.message.includes("The operation was aborted"))||((i=s[0])===null||i===void 0?void 0:i.message.includes("Fetch is aborted")));l=d?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(l)}return[2/*return*/,u]}}))}))};var
|
|
115
|
+
console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2/*return*/,s]}return[2/*return*/,s]}}))}))};var Q=function(e){return __awaiter(_,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l;var v=e.abortController,f=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4/*yield*/,c("/api/zonos-elements/cart-calculate-landed-cost",{body:H(f),method:"POST",signal:v===null||v===void 0?void 0:v.signal})];case 1:a=e.sent(),s=a.errors,u=a.json;if(s.length||!u){d=typeof((r=s[0])===null||r===void 0?void 0:r.message)==="string"&&(((n=s[0])===null||n===void 0?void 0:n.message)==="The user aborted a request."||((t=s[0])===null||t===void 0?void 0:t.message.includes("signal is aborted"))||((o=s[0])===null||o===void 0?void 0:o.message.includes("The operation was aborted"))||((i=s[0])===null||i===void 0?void 0:i.message.includes("Fetch is aborted")));l=d?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(l)}return[2/*return*/,u]}}))}))};var Z=undefined&&undefined.__rest||function(e,r){var n={};for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0)n[t]=e[t];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++){if(r.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o]))n[t[o]]=e[t[o]]}return n};var X=function(e){return __awaiter(_,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:r=window.Zonos.cartId;if(!!r)return[3/*break*/,2];return[4/*yield*/,V(e)];case 1:n=a.sent();return[2/*return*/,n];case 2:return[4/*yield*/,Q({abortController:e,cartId:r})];case 3:t=a.sent(),o=t.cartWorkflow,i=Z(t,["cartWorkflow"]);return[2/*return*/,Object.assign(Object.assign({},i),{itemCreateWorkflow:o.items})]}}))}))};var $=e("t",(function(e){return __awaiter(_,[e],void 0,(function(e){var r,t,o,i,s,u,d,v,f;var w=e.checkoutSessionId,y=e.eventName,g=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:o=Date.now();i=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:w,eventCreated:o,eventName:y});s=
|
|
116
116
|
// if the url includes zonos.com and not hosted checkout (checkout.zonos.com), it means we are on the development site (dashboard, preview zonos domain or main zonos.com)
|
|
117
117
|
window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!((r=window.Zonos)===null||r===void 0?void 0:r.zonosQaUrl)||!!((t=window.Zonos)===null||t===void 0?void 0:t.debug);u=p()||m();if((u||s)&&
|
|
118
118
|
// if found, it means we want to test the conversion event in development site, or test mode and staging mode
|
|
@@ -231,7 +231,7 @@ return!Qe.landedCostData&&!le.isFetchingLandedCost||n||r};var Ae=e("W",(function
|
|
|
231
231
|
// Only send landed cost request if the address is complete when we can't get the country field
|
|
232
232
|
if(!u||!le.stripeAddressEventData){return i&&a&&o}var d=le.stripeAddressEventData.value.address.line1.length>0;var l=le.stripeAddressEventData.value.firstName&&le.stripeAddressEventData.value.lastName;var c=!u.stateRequired||u.stateRequired&&le.stripeAddressEventData.value.address.state.length>0;var v=!u.zipRequired||u.zipRequired&&le.stripeAddressEventData.value.address.postal_code.length>=3;var f=le.stripeAddressEventData.value.phone&&le.stripeAddressEventData.value.phone.length>0;return o&&l&&d&&c&&v&&f};var ke=function(){return __awaiter(_,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,d,l,c;return __generator(this,(function(v){switch(v.label){case 0:r=new AbortController;le.fetchingLandedCostAbortController=r;
|
|
233
233
|
// Reset cart items to non-restricted state and restricted item list
|
|
234
|
-
pr();return[4/*yield*/,
|
|
234
|
+
pr();return[4/*yield*/,X(r)];case 1:n=v.sent(),o=n.checkoutSessionWorkflow,i=n.errors,a=n.itemCreateWorkflow,s=n.landedCostCalculateWorkflow,u=n.partyCreateWorkflow,d=n.shipmentRatingCalculateWorkflow;
|
|
235
235
|
// Surface a custom "no quote" message when either a rule (ruleMessageType CUSTOM) or a country
|
|
236
236
|
// constraint (source COUNTRY_CONSTRAINT) blocked shipment rating with an authored message.
|
|
237
237
|
Qe.customQuotingError=((e=i===null||i===void 0?void 0:i.find((function(e){var r,n;return((r=e.extensions)===null||r===void 0?void 0:r.ruleMessageType)==="CUSTOM"||((n=e.extensions)===null||n===void 0?void 0:n.source)==="COUNTRY_CONSTRAINT"})))===null||e===void 0?void 0:e.message)||null;Qe.shippingData=ne((d===null||d===void 0?void 0:d.filter(Boolean))||[]);
|
|
@@ -409,16 +409,16 @@ if(e&&le.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){session
|
|
|
409
409
|
// When user clicked applied button, save promocode into session storage for later use. So if session has promocode, applied button is clicked
|
|
410
410
|
promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:false,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:false,step:"customer-info",storeCredit:0,subtotal:0,tabItems:{"customer-info":{index:1,isDone:false,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:false,label:"Shipping",value:"shipping"},
|
|
411
411
|
// eslint-disable-next-line sort-keys/sort-keys-fix
|
|
412
|
-
payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),
|
|
412
|
+
payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),Ge=Ke.onChange,Ve=Ke.reset,Qe=Ke.state;e({I:Ge,d:Qe});var Ze=function(e){switch(e){case"DAYS":return o("days");case"WEEKS":return o("weeks");case"BUSINESS_DAYS":default:return o("business days")}};
|
|
413
413
|
/**
|
|
414
414
|
* Format shipping transit info to be displayed on UI
|
|
415
415
|
* @returns
|
|
416
416
|
* - expectedDate: Thursday, Aug 12
|
|
417
417
|
* - maxTransit: 5
|
|
418
418
|
* - minTransit: 3
|
|
419
|
-
*/var
|
|
419
|
+
*/var Xe=e("Z",(function(e){var r;var n=(r=e.shippingProfile)===null||r===void 0?void 0:r.transitTime;
|
|
420
420
|
// Don't care about falsy 0 values because this is international shipping and 0 days is not feasible
|
|
421
|
-
if(!(n===null||n===void 0?void 0:n.min)||!(n===null||n===void 0?void 0:n.max)||!(n===null||n===void 0?void 0:n.type)){return null}return{maxTransit:n.max,minTransit:n.min,unit:
|
|
421
|
+
if(!(n===null||n===void 0?void 0:n.min)||!(n===null||n===void 0?void 0:n.max)||!(n===null||n===void 0?void 0:n.type)){return null}return{maxTransit:n.max,minTransit:n.min,unit:Ze(n.type)}}));var $e=function(e){var r=e.item1,n=e.item2;if(!r||!n){return false}return n.sku&&r.sku&&r.sku===n.sku||n.description&&r.description&&r.description===n.description||r.name&&n.name&&r.name===n.name};
|
|
422
422
|
/**
|
|
423
423
|
* Check and set restricted items in cart
|
|
424
424
|
*/var er=function(e){d("Checking item restrictions");var r=e.map((function(e){if(!e.restriction){return null}var r=e.restriction;var n=Qe.items.find((function(r){return $e({item1:r,item2:e})}));return Object.assign(Object.assign({matchedItem:n},e),{restriction:r})})).filter(Boolean);Qe.restrictedItems=r;
|
|
@@ -429,7 +429,7 @@ if(rr){clearTimeout(rr);rr=null}
|
|
|
429
429
|
// reset store credit store
|
|
430
430
|
k();
|
|
431
431
|
// reset cart store
|
|
432
|
-
|
|
432
|
+
Ve()}));var tr=e("r",(function(e){var r=e.messages,n=e.title;nr();he();Qe.step="error";Qe.error={messages:r,title:n}}));var or=function(e){var r=e.dutiesTaxesFeesEstimate,n=e.method,t=e.subtotals;var o;
|
|
433
433
|
// update exchange rate so we can use it to display cart items
|
|
434
434
|
Qe.exchangeRate=t.exchangeRate;Qe.adjustmentTotal=t.adjustments;Qe.dutiesTaxesFees=n==="DAP"?null:t.landedCostTotal;Qe.storeCredit=(o=t.storeCredit)!==null&&o!==void 0?o:0;Qe.subtotal=t.items;Qe.total=t.total;Qe.currency=t.presentmentCurrencyCode;Qe.dutiesTaxesFeesEstimate=r||null};
|
|
435
435
|
/**
|
|
@@ -474,7 +474,7 @@ or({method:((r=u.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.m
|
|
|
474
474
|
if(e.method==="DAP"&&((o=(t=n.genericSettings)===null||t===void 0?void 0:t.domesticCountries)===null||o===void 0?void 0:o.includes(((i=le.stripeAddressEventData)===null||i===void 0?void 0:i.value.address.country)||"US"))){return"DDP"}
|
|
475
475
|
// EU 3-EUR cutover (05CHECK-893): keep EU POSTAL remittance quotes as DAP so
|
|
476
476
|
// the shopper is told duties are paid upon delivery, even though we remit.
|
|
477
|
-
if(He({deliveryType:r,landedCost:e,shipToCountry:(a=le.stripeAddressEventData)===null||a===void 0?void 0:a.value.address.country})){return"DAP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var lr=e("Y",(function(e){return __awaiter(_,[e],void 0,(function(e){var r,t,o,i,a,s,u,l,c,v,f,p,m,h,w,y,g,b,_,S,O,A,C,k,I,T;var E=e.applySubtotalsOnly,P=e.landedCostId,N=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:d("Updating selected shipping option","info",{landedCostId:P,selectedShippingOption:N});Qe.selectedShippingOption=N;m=
|
|
477
|
+
if(He({deliveryType:r,landedCost:e,shipToCountry:(a=le.stripeAddressEventData)===null||a===void 0?void 0:a.value.address.country})){return"DAP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var lr=e("Y",(function(e){return __awaiter(_,[e],void 0,(function(e){var r,t,o,i,a,s,u,l,c,v,f,p,m,h,w,y,g,b,_,S,O,A,C,k,I,T;var E=e.applySubtotalsOnly,P=e.landedCostId,N=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:d("Updating selected shipping option","info",{landedCostId:P,selectedShippingOption:N});Qe.selectedShippingOption=N;m=Xe(Qe.selectedShippingOption);if(m){h=m.maxTransit,w=m.minTransit,y=m.unit;Qe.selectedShippingOptionTransitTime="".concat(w,"-").concat(h," ").concat(y)}else{Qe.selectedShippingOptionTransitTime=""}g=(r=Qe.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCostId===P}));
|
|
478
478
|
// save selected landed cost for later use
|
|
479
479
|
Qe.selectedLandedCost=g||null;if(!g){
|
|
480
480
|
// do nothing if we can't find landed cost for selected shipping option
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{U as e}from"./p-FRWZayxL.js";const a=3,l=({countryField:a,event:l})=>{var o,t,n;if(!l)return[];const{value:s}=l,i=[],{lastName:r}=e({firstName:s.firstName,lastName:s.lastName,name:s.name});return r.trim()||i.push({key:"lastName"}),(null==a?void 0:a.stateRequired)&&!(null===(o=s.address.state)||void 0===o?void 0:o.trim())&&i.push({key:"state"}),(null==a?void 0:a.zipRequired)&&(null!==(n=null===(t=s.address.postal_code)||void 0===t?void 0:t.trim().length)&&void 0!==n?n:0)<3&&i.push({key:"postal_code"}),i};export{a as M,l as g}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as n,z as e}from"./p-W82paT5F.js";import{t,l as r,s as i}from"./p-Cuk0LLGQ.js";import{l as o,h as a,s}from"./p-DE4a-QD5.js";import{l as u,b as c}from"./p-BJmZPrZl.js";import{d as l,Y as d,b as f,a0 as v}from"./p-DwkyNtpD.js";function m(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function p(n,e,t,r,i,o,a){try{var s=n[o](a),u=s.value}catch(n){return void t(n)}s.done?e(u):Promise.resolve(u).then(r,i)}function h(n){return function(){var e=this,t=arguments;return new Promise((function(r,i){var o=n.apply(e,t);function a(n){p(o,r,i,a,s,"next",n)}function s(n){p(o,r,i,a,s,"throw",n)}a(void 0)}))}}function y(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function w(n,e){return e&&function(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}(n.prototype,e),n}function g(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function b(n,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](n):n instanceof e}function k(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{},r=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})))),r.forEach((function(e){g(n,e,t[e])}))}return n}function x(n,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):function(n){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e.push.apply(e,t)}return e}(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})),n}function E(n,e){return function(n){if(Array.isArray(n))return n}(n)||function(n,e){var t=null==n?null:"undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(null!=t){var r,i,o=[],a=!0,s=!1;try{for(t=t.call(n);!(a=(r=t.next()).done)&&(o.push(r.value),o.length!==e);a=!0);}catch(n){s=!0,i=n}finally{try{a||null==t.return||t.return()}finally{if(s)throw i}}return o}}(n,e)||N(n,e)||function(){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 I(n){return function(n){if(Array.isArray(n))return m(n)}(n)||function(n){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}(n)||N(n)||function(){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 S(n){return n&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n}function N(n,e){if(n){if("string"==typeof n)return m(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);return"Object"===t&&n.constructor&&(t=n.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?m(n,e):void 0}}function C(n,e){var t,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&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}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(n,a)}catch(n){o=[6,n],r=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var D,T,P,R,O,j=function(n){return n.production="prod",n.demo="demo",n.staging="staging",n}(j||{}),_="airTracker_unknown",A={appName:_,appVersion:_,env:"staging",isWebappContainer:!1,delay:2e3,errorRepeatTime:3,enableErrorMonitoring:!1,assetSpeedMonitoringWhiteList:[],enableDetectPageChange:!1,enableRecordPageRetention:!1,hideSearchParams:!1,useSessionStorageForSessionId:!1,assetSpeedMonitoringWhiteListByMFE:{}},L={appName:_,env:"staging",sessionId:_,deviceId:_},U=function(){var n=new WeakSet;return function(e,t){if(b(t,Error))return"Error.message: ".concat(t.message," \n Error.stack: ").concat(t.stack);if("object"===(void 0===t?"undefined":S(t))&&null!==t){if(n.has(t))return"[Circular ".concat(e||"root","]");n.add(t)}return"function"==typeof t?"function":"symbol"===(void 0===t?"undefined":S(t))?"symbol":void 0===t?null:t}},F=function(n){if("string"==typeof n)return n;try{return b(n,Error)?(JSON.stringify(n,U())||"undefined").replace(/"/gim,""):JSON.stringify(n,U())}catch(n){return'{"error":"error happen when airTracker stringify"}'}},M=function(n){var e=n.method,t=void 0===e?"post":e,r=n.url,i=n.data,o=n.success,a=n.fail;if((s=i)&&!/^\s*$/.test(s)&&(s=(s=(s=s.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@")).replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]")).replace(/(?:^|:|,)(?:\s*\[)+/g,""),/^[\],:{}\s]*$/.test(s))){var s,u=new XMLHttpRequest;u.addEventListener("readystatechange",(function(){4===u.readyState&&(u.status>=400||0===u.status?null==a||a(u.response):null==o||o(u.response))})),u.open(t,r),u.setRequestHeader("Content-Type","application/json"),u.send(i)}},K="onCommonUpdated",H="AIR_ANALYTICS_DEVICE_ID",q="AIR_ANALYTICS_SESSION_ID",z=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(n){var e=16*Math.random()|0;return("x"===n?e:3&e|8).toString(16)}))},B=function(n){var e,t,r;return n.config.getMFEName?n.config.getMFEName():(null===(r=location)||void 0===r||null===(t=r.pathname)||void 0===t||null===(e=t.split("/"))||void 0===e?void 0:e[2])||"unknown"},W=function(n){return"string"==typeof n?n.split("?")[1]||"":n},X=function(n){return"string"==typeof n&&n.startsWith("//")?"undefined"!=typeof location&&"https:"===location.protocol:/^https/.test(n)},G=function(n){return"number"==typeof n||"string"==typeof n?n:-1},V=function(n,e){var t,r=!1;if(!e.config.isWebappContainer)return J(n,e.config.assetSpeedMonitoringWhiteList);var i=B(e);return r||J(n,null===(t=e.config.assetSpeedMonitoringWhiteListByMFE)||void 0===t?void 0:t[i])},J=function(n,e){if(!(null==e?void 0:e.length))return!1;for(var t=0;t<e.length;t++){var r=e[t];if(b(r,RegExp)&&r.test(n))return!0;if("string"==typeof r&&n.includes(r))return!0}return!1},Q=function(n,e){return Math.round(100*(n-e))/100},$=function(n){return function(e){var t,r,i=B(n),o=n.config.isWebappContainer?k({},n.commonData||{},(null===(t=n.MFECommonDataMap)||void 0===t?void 0:t[i])||{}):n.commonData,a=Array.isArray(e)?e:[e];if(0!==a.length){var s,u=F({commonData:o,data:a}),c={method:"post",url:(s=n.commonData.env,"prod"==s?"https://o11y.airwallex.com/airtracker/logs":"demo"==s?"https://o11y-demo.airwallex.com/airtracker/logs":"https://o11y-staging.airwallex.com/airtracker/logs"),data:u};"function"==typeof(null===(r=navigator)||void 0===r?void 0:r.sendBeacon)&&navigator.sendBeacon(c.url,u)||M(c)}}},Y=function(n){return function(e){var t,r,i,o=B(n),a={commonData:n.config.isWebappContainer?k({},n.commonData||{},(null===(t=n.MFECommonDataMap)||void 0===t?void 0:t[o])||{}):n.commonData,data:Array.isArray(e)?e:[e]},s=F(a),u={method:"post",url:(i=n.commonData.env,"prod"==i?"https://o11y.airwallex.com/airtracker/metrics":"demo"==i?"https://o11y-demo.airwallex.com/airtracker/metrics":"https://o11y-staging.airwallex.com/airtracker/metrics"),data:s};"function"==typeof(null===(r=navigator)||void 0===r?void 0:r.sendBeacon)&&navigator.sendBeacon(u.url,s)||M(u)}},Z=function(n,e){var t,r=[],i=n.config;return window.addEventListener("beforeunload",(function(){r.length>0&&(n.immediateSendPipe(r.splice(0,r.length)),t&&clearTimeout(t))})),function(o,a){if(r.push(o),n.lifeCycle.on(K,(function(){r.length>0&&(null==a||a(r.splice(0,r.length)),n.lifeCycle.remove(K),t&&clearTimeout(t))})),r.length>=e)return null==a||a(r.splice(0,r.length)),void(t&&clearTimeout(t));t&&clearTimeout(t),t=setTimeout((function(){t=null,r.length>0&&(null==a||a(r.splice(0,r.length)),n.lifeCycle.remove(K))}),i.delay)}},nn=function(){},en=function(n){if(!n||!n.reduce||!n.length)throw new TypeError("createPipeline need at least one function param");return 1===n.length?function(e,t){n[0](e,t||nn)}:n.reduce((function(n,e){return function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nn;return n(t,(function(n){return null==e?void 0:e(n,r)}))}}))},tn=function(){function n(){var e=this;y(this,n),this.emit=function(n,t){if(e){var r,i=e.eventsList[n];if(null==i?void 0:i.length){i=i.slice();for(var o=0;o<i.length;o++){r=i[o];try{var a=r.callback.apply(e,[t]);if(1===r.type&&e.remove(n,r.callback),!1===a)break}catch(n){throw n}}}return e}},this.eventsList={}}return w(n,[{key:"indexOf",value:function(n,e){for(var t=0;t<n.length;t++)if(n[t].callback===e)return t;return-1}},{key:"on",value:function(n,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(this){var r=this.eventsList[n];return r||(this.eventsList[n]=[],r=this.eventsList[n]),-1===this.indexOf(r,e)?(r.push({name:n,type:t||0,callback:e}),this):this}}},{key:"one",value:function(n,e){this.on(n,e,1)}},{key:"remove",value:function(n,e){if(this){var t=this.eventsList[n];if(!t)return null;if(!e){try{delete this.eventsList[n]}catch(n){}return null}if(t.length){var r=this.indexOf(t,e);t.splice(r,1)}return this}}},{key:"clear",value:function(){this.eventsList={}}}]),n}(),rn=function(){function n(e){y(this,n),this.name="",this.isInit=!1,this.name=e.name,this.option=e}return w(n,[{key:"patch",value:function(n){var e,t;this.isInit||(this.isInit=!0,null===(t=this.option)||void 0===t||null===(e=t.setUp)||void 0===e||e.call(this.option,n))}},{key:"uninstall",value:function(){var n,e;null===(e=this.option)||void 0===e||null===(n=e.destroy)||void 0===n||n.apply(this),this.isInit=!1}}]),n}(),on=function(n){var e="".concat(F(n.message)||""," @ (").concat(F(n.filename)||"",":").concat(n.lineno||0,":").concat(n.colno||0,")\n").concat(F(n.error||""));D.normalLogPipeLine({severity:"autoDetectError",eventName:"windowOnError",extraInfo:{error:e}})},an=function(n){var e=n&&F(n.reason);D.normalLogPipeLine({severity:"autoDetectError",eventName:"promiseError",extraInfo:{error:e}})},sn=function(n){var e=(null==n?void 0:n.target)||(null==n?void 0:n.srcElement);if(e){var t=(null==e?void 0:e.src)||(null==e?void 0:e.href),r=e.tagName,i="unknown";if("string"==typeof t&&r){if(window.location.href.indexOf(t)>-1)return;if(/\.js$/.test(t))i="script";else if(/\.css$/.test(t))i="css";else switch(r.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}D.normalLogPipeLine({severity:"autoDetectError",eventName:"staticFileLoadError",extraInfo:{staticFileType:i,error:"".concat(r," load fail: ").concat(t)}})}}},un=new rn({name:"errorDetectionPlugin",setUp:function(n){D=n,window.addEventListener("error",on),window.addEventListener("unhandledrejection",an),window.document.addEventListener("error",sn,!0)},destroy:function(){window.removeEventListener("unhandledrejection",an),window.document.removeEventListener("error",sn,!0),window.removeEventListener("error",on)}}),cn=["img","css","script","link","audio","video","iframe"],ln="resource",dn=function(n){var e,t=n.name;return{url:(e=t,"string"==typeof e?(e.split("?")[0]||"").slice(0,200):e),method:"get",duration:Number(n.duration.toFixed(2)),type:"static",isHttps:X(t),urlQuery:W(t),domainLookup:G(n.domainLookupEnd-n.domainLookupStart),connectTime:G(n.connectEnd-n.connectStart)}},fn=function(n,e){for(var t=0,r=n.length;t<r;t++){var i=n[t];-1!==cn.indexOf(i.initiatorType)&&V(i.name,e)&&e.normalLogPipeLine({severity:"performance",eventName:"assets_speed",extraInfo:{log:dn(i)}})}},vn=new rn({name:"assetsSpeedPlugin",setUp:function(n){if(void 0!==window.performance&&"function"==typeof window.performance.clearResourceTimings&&"function"==typeof window.performance.getEntriesByType&&"function"==typeof window.performance.now){var e=0;window.performance.onresourcetimingbufferfull=function(){e=0,window.performance.clearResourceTimings()},"function"==typeof window.PerformanceObserver?(fn(window.performance.getEntriesByType(ln),n),(P=new window.PerformanceObserver((function(e){fn(e.getEntries(),n)}))).observe({entryTypes:[ln]})):T=setInterval((function(){var t=window.performance.getEntriesByType(ln),r=t.slice(e);e=t.length,fn(r,n)}),3e3)}},destroy:function(){null==P||P.disconnect(),T&&clearInterval(T)}}),mn=new rn({name:"onPageChangePlugin",setUp:function(){var n=h((function(n){var e,t,r,i;return C(this,(function(){return t=null===(e=location)||void 0===e?void 0:e.href,r=document.querySelector("body"),i=function(e){var t,r,i,o,a;n.normalLogPipeLine({severity:"autoDetectEvent",eventName:"onPageChange",extraInfo:{prevHref:e.prevHref,href:(null===(t=location)||void 0===t?void 0:t.href)||"",hostname:null===(r=location)||void 0===r?void 0:r.hostname,pathName:null===(i=location)||void 0===i?void 0:i.pathname,protocol:null===(o=location)||void 0===o?void 0:o.protocol,search:null===(a=location)||void 0===a?void 0:a.search}})},i({prevHref:""}),(R=new MutationObserver((function(){if(location.href!==t){var n=t;t=location.href,i({prevHref:n})}}))).observe(r||document,{subtree:!0,childList:!0}),[2]}))}));return function(e){return n.apply(this,arguments)}}(),destroy:function(){null==R||R.disconnect()}}),pn=new rn({name:"onPageRetentionPlugin",setUp:function(){var n=h((function(n){var e,t,r,i,o,a;return C(this,(function(){return void 0===document.visibilityState||(t=null===(e=location)||void 0===e?void 0:e.href,r=document.querySelector("body"),(o=function(){i=Date.now()})(),document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState?a({href:location.href,leftReason:"visibilityChange"}):"visible"===document.visibilityState&&o()})),window.addEventListener("beforeunload",(function(){a({href:location.href,sendImmediate:!0,leftReason:"pageClose"})})),a=function(e){var t=e.href,r=e.sendImmediate,o=e.leftReason;if(i){var a=Date.now()-i;if(0!==a){i=void 0;var s={severity:"autoDetectEvent",eventName:"onPageRetention",extraInfo:{href:t,duration:a,leftReason:o}};r?n.ImmediatePipeline(s):n.normalLogPipeLine(s)}}},(O=new MutationObserver((function(){if(location.href!==t){var n=t;t=location.href,a({href:n,leftReason:"nextPage"}),o()}}))).observe(r||document,{subtree:!0,childList:!0})),[2]}))}));return function(e){return n.apply(this,arguments)}}(),destroy:function(){null==O||O.disconnect()}}),hn=function(){return Date.now().toString(36)+Math.random().toString(36).substring(2,15)},yn=function(n,e){return![/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].some((function(e){return e.test(n)}))&&J(n,e||[/^https?:\/\/[^\/]*\.airwallex\.com($|\/)/])},wn=function(n){return Math.round(100*n)/100},gn=function(n,e){var t,r,i,o,a,s,u,c,l,d,f,v,m,p,h,y,w,g,b,E=n.url,I=n.method,S=n.errorType,N=n.errorDetail,C=function(n){var e=n.startTime,t=n.endTime,r=n.entries;if(0!==r.length){if(1===r.length)return r[0];var i=r.filter((function(n){return n.startTime>=e&&t&&n.responseEnd<=t})).sort((function(n,e){return n.startTime-e.startTime}));return null==i?void 0:i[0]}}(n),D=new URL(E,window.location.href),T=D.href,P=D.protocol,R=C?(i=(t=C).duration,o=t.responseStart,a=t.connectEnd,s=t.connectStart,u=t.domainLookupEnd,c=t.domainLookupStart,l=t.requestStart,d=t.secureConnectionStart,f=t.redirectEnd,v=t.redirectStart,m=t.responseStatus,p=t.responseEnd,h=t.encodedBodySize,y=t.decodedBodySize,w=t.transferSize,g=t.deliveryType,b=t.initiatorType,{startTime:wn(r=t.startTime),totalDuration:wn(i),timeToFirstByte:Q(o,r),tcpDuration:Q(a,s),dnsDuration:Q(u,c),tlsDuration:Q(l,d),redirectDuration:Q(f,v),responseDuration:Q(p,o),encodeResponseSize:h,decodeResponseSize:y,transferSize:w,deliveryType:g,statusCode:m,initiatorType:b}):{};return{severity:"autoDetectEvent",eventName:"httpClientMetrics",extraInfo:k(x(k({httpUrl:T,method:I,scheme:P},S&&{errorType:S},N&&{errorDetail:N},R),{statusCode:(null==R?void 0:R.statusCode)||(null==n?void 0:n.responseStatus),startTime:(null==R?void 0:R.startTime)||(null==n?void 0:n.startTime),initiatorType:(null==R?void 0:R.initiatorType)||(null==n?void 0:n.initiatorType)}),e)}},bn=function(n){return n&&"object"===(void 0===n?"undefined":S(n))&&"errors"in n&&Array.isArray(n.errors)&&n.errors.every((function(n){return n&&"object"===(void 0===n?"undefined":S(n))&&"message"in n}))},kn="awx_airtracker_api_performance_queue",xn="awx_airtracker_api_performance_plugin_loaded",En="undefined"!=typeof window?window:"undefined"!=typeof global?global:{};En[kn]=En[kn]||[];var In=function(n,e,t){setTimeout((function(){var r=gn(n,t);e.observerPipeline(r),En[kn]=En[kn].filter((function(e){return e.id!==n.id}))}),300)},Sn=function(n,e){setTimeout((function(){var t=En[kn].find((function(e){return e.id===n}));if(t){var r=gn(t,{exceptionType:"timeout-without-response"});e.observerPipeline(r),En[kn]=En[kn].filter((function(e){return e.id!==n}))}}),1e4)},Nn=new rn({name:"apiPerformancePlugin",setUp:function(){var n=h((function(n){var e,t;return C(this,(function(){return En[xn]||(null===(e=n.config)||void 0===e?void 0:e.enableRecordAPIPerformance)&&Math.random()<((null===(t=n.config)||void 0===t?void 0:t.enableRecordAPIPerformancePercentage)||0)&&(En[xn]=!0,function(n){var e;(function(n){var e=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(t,r,i,o,a){try{var s,u=hn();this.__requestId=u;var c=b(r,URL)?r.href:new URL(r,window.location.href).href;if(!yn(c,null===(s=n.config)||void 0===s?void 0:s.enableRecordAPIPerformanceWhitelist))return e.call(this,t,r,null==i||i,o,a);var l={id:u,startTime:performance.now(),method:t,url:c,entries:[],initiatorType:"xmlhttprequest"};return En[kn].push(l),Sn(u,n),e.call(this,t,r,null==i||i,o,a)}catch(s){return n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Inject XHR open error",error:s}}),e.call(this,t,r,null==i||i,o,a)}},XMLHttpRequest.prototype.send=function(){for(var e=this,r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];try{var a=En[kn].find((function(n){return n.id===e.__requestId}));if(!a)return t.apply(this,i);var s=this;return this.addEventListener("loadend",h((function(){var e,t,r,i,o,u,c;return C(this,(function(l){switch(l.label){case 0:if(e=performance.now(),t=e-a.startTime,0===(r=s.status))return[2];a.endTime=e,a.duration=t,a.responseStatus=r,l.label=1;case 1:return l.trys.push([1,6,,7]),""!==s.responseType&&"text"!==s.responseType?[3,2]:(i=s.responseText,[3,5]);case 2:return"json"!==s.responseType?[3,3]:(i=s.response,[3,5]);case 3:return"blob"!==s.responseType||"application/json"!==(null==(o=s.response)?void 0:o.type)?[3,5]:[4,o.text()];case 4:i=l.sent(),l.label=5;case 5:return(u=i&&"string"==typeof i?JSON.parse(i):i)&&bn(u)&&(a.errorType="graphqlError",a.errorDetail=u.errors),[3,7];case 6:return c=l.sent(),n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Parse response body error in XHR",url:null==a?void 0:a.url,error:c}}),[3,7];case 7:return In(a,n),[2]}}))}))),this.addEventListener("error",(function(){In(a,n,{exceptionType:"network-error"})})),this.addEventListener("abort",(function(){In(a,n,{exceptionType:"abort-error"})})),this.addEventListener("timeout",(function(){In(a,n,{exceptionType:"timeout-error"})})),t.apply(this,i)}catch(e){throw n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"InjectXHR send error",error:e}}),e}}})(n),function(n){var e=window.fetch;window.fetch=h((function(){var t,r,i,o,a,s,u,c,l,d,f,v,m,p,h,y,w=arguments;return C(this,(function(g){switch(g.label){case 0:for(t=w.length,r=new Array(t),i=0;i<t;i++)r[i]=w[i];return s=new URL(b(r[0],Request)?r[0].url:String(r[0]),window.location.href).href,yn(s,null===(o=n.config)||void 0===o?void 0:o.enableRecordAPIPerformanceWhitelist)?[3,2]:[4,e.apply(this,r)];case 1:return[2,g.sent()];case 2:return g.trys.push([2,9,,10]),c=performance.now(),l=hn(),a={id:l,startTime:c,method:(null===(u=b(r[0],Request)?r[0]:r[1])||void 0===u?void 0:u.method)||"GET",url:s,entries:[],initiatorType:"fetch"},En[kn].push(a),Sn(l,n),[4,e.apply(this,r)];case 3:d=g.sent(),f=performance.now(),a.endTime=f,a.duration=f-c,a.responseStatus=d.status,v=d.clone(),g.label=4;case 4:return g.trys.push([4,7,,8]),v.ok?[4,v.json()]:[3,6];case 5:(m=g.sent())&&bn(m)&&(a.errorType="graphqlError",a.errorDetail=m.errors),g.label=6;case 6:return[3,8];case 7:return p=g.sent(),n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Parse response body error in fetch",url:null==a?void 0:a.url,error:p}}),[3,8];case 8:return In(a,n),[2,d];case 9:throw h=g.sent(),a&&a.id&&En[kn].find((function(n){return n.id===(null==a?void 0:a.id)}))?(y="fetch-error",b(h,TypeError)?y="network-error":b(h,DOMException)&&"AbortError"===h.name&&(y="abort-error"),In(a,n,{exceptionType:y})):n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Inject fetch error",error:h}}),h;case 10:return[2]}}))}))}(n),(null===(e=window)||void 0===e?void 0:e.PerformanceObserver)?new window.PerformanceObserver((function(n){n.getEntries().forEach((function(n){var e=n;"fetch"!==e.initiatorType&&"xmlhttprequest"!==e.initiatorType||En[kn].filter((function(n){return n.url===e.name})).forEach((function(n){n.entries.push(e)}))}))})).observe({entryTypes:["resource"],buffered:!0}):n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{error:"PerformanceObserver Not Supported"}})}(n)),[2]}))}));return function(e){return n.apply(this,arguments)}}()}),Cn=function(){function n(e){var t,r,i=this,o=e.config,a=e.plugins,s=void 0===a?[]:a;y(this,n),this.config=A,this.lifeCycle=new tn,this.plugins=[],this._commonData=L,this._MFECommonDataMap={},this.timeMap={},this.packedDataConvert=function(n){var e,t,r=n.extraInfo,o=k({severity:n.severity,eventName:n.eventName,currentHref:i.config.hideSearchParams?((null===(e=location)||void 0===e?void 0:e.href)||"").split("?")[0]||"":(null===(t=location)||void 0===t?void 0:t.href)||""},r);return i.config.isWebappContainer&&(o.MFEName=B(i)),o},this.normalPipelineObj=en([Z(this,8),(t=this,r={},function(n,e){var i="number"==typeof t.config.errorRepeatTime?t.config.errorRepeatTime:5;if(0===i)return null==e?void 0:e(n);null==e||e(n.filter((function(n){return"autoDetectError"!=n.severity||(r[n.error]=r[n.error]||0,r[n.error]+=1,!(r[n.error]>i))})))}),$(this)]),this.observerPipelineObj=en([Z(this,8),Y(this)]),this.immediateSendPipe=$(this),this.observerPipeline=function(n){var e=i.packedDataConvert({severity:n.severity,eventName:n.eventName,extraInfo:n.extraInfo});return i.observerPipelineObj(e)},this.normalLogPipeLine=function(n){var e=i.packedDataConvert({severity:n.severity,eventName:n.eventName,extraInfo:n.extraInfo});return i.config.disableThrottle?i.immediateSendPipe(e):i.normalPipelineObj(e)},this.ImmediatePipeline=function(n){var e=i.packedDataConvert({severity:n.severity,eventName:n.eventName,extraInfo:n.extraInfo});return i.immediateSendPipe(e)},this.plugins=I(s),this.setConfig(o),this.initCommonData(o),this.lifeCycle.emit("onInit"),o.enableErrorMonitoring&&this.plugins.push(un),((null==o?void 0:o.assetSpeedMonitoringWhiteList)&&o.assetSpeedMonitoringWhiteList.length>0||o.isWebappContainer)&&this.plugins.push(vn),(null==o?void 0:o.enableDetectPageChange)&&this.plugins.push(mn),(null==o?void 0:o.enableRecordPageRetention)&&this.plugins.push(pn),(null==o?void 0:o.enableRecordAPIPerformance)&&(null==o?void 0:o.enableRecordAPIPerformancePercentage)&&o.enableRecordAPIPerformancePercentage>0&&o.enableRecordAPIPerformancePercentage<=1&&this.plugins.push(Nn),this.installPlugins()}return w(n,[{key:"installPlugins",value:function(){var n=this;this.plugins.forEach((function(e){e.patch(n)}))}},{key:"commonData",get:function(){return this._commonData}},{key:"MFECommonDataMap",get:function(){return this._MFECommonDataMap}},{key:"initCommonData",value:function(n){this._commonData.sessionId=n.useSessionStorageForSessionId?function(){try{var n=window.sessionStorage.getItem(q);return n||(n=z(),window.sessionStorage.setItem(q,n)),n}catch(n){return z()}}():z(),this._commonData.deviceId=function(){try{var n=window.localStorage.getItem(H);return n||(n=z(),window.localStorage.setItem(H,n)),n}catch(n){}}()||_,this._commonData.riskDeviceId=function(){try{return window.localStorage.getItem("AWX_RISK_ID")||void 0}catch(n){}}(),this._commonData.networkType=function(){var n,e,t="",r=navigator.userAgent.match(/NetType\/(\w+)/);if(r)t=E(r,2)[1];else if(null===(n=navigator)||void 0===n?void 0:n.connection){var i,o,a,s;t=(null===(o=navigator)||void 0===o||null===(i=o.connection)||void 0===i?void 0:i.effectiveType)||(null===(s=navigator)||void 0===s||null===(a=s.connection)||void 0===a?void 0:a.type)}return t||(t="unknown"),e=t,(e=String(e).toLowerCase()).indexOf("4g")>=0?"net4g":e.indexOf("wifi")>=0?"wifi":e.indexOf("5g")>=0?"net5g":e.indexOf("3g")>=0?"net3g":e.indexOf("2g")>=0?"net2g":"unknown"}()||"unknown",this._commonData.env=n.env||this._commonData.env,this._commonData.accountId=n.accountId||_,this._commonData.appVersion=n.appVersion,this._commonData.appName=n.appName,this._commonData.sdkVersion="3.1.0",this.lifeCycle.emit("onCommonDataInit",this.commonData)}},{key:"updateCommonDataBasedOnConfig",value:function(n){this.lifeCycle.emit(K,this._commonData),this._commonData.env=n.env||this._commonData.env,this._commonData.appName=n.appName||this._commonData.appName,this._commonData.env=n.env||this._commonData.env,this._commonData.accountId=n.accountId||this._commonData.accountId,this._commonData.appVersion=n.appVersion||this._commonData.appVersion}},{key:"updateCommonData",value:function(n){this.lifeCycle.emit(K,this._commonData),this._commonData=k({},this._commonData,n)}},{key:"removeCommonDataByKey",value:function(n){var e=this;this.lifeCycle.emit(K,this._commonData),setTimeout((function(){n.forEach((function(n){delete e._commonData[n]}))}),1e3)}},{key:"addToMFECommonData",value:function(n){var e,t=n.MFEName,r=n.MFECommonData;this.config.isWebappContainer&&t&&r&&(this._MFECommonDataMap=x(k({},this._MFECommonDataMap||{}),g({},t,k({},(null===(e=this._MFECommonDataMap)||void 0===e?void 0:e[t])||{},r))))}},{key:"setConfig",value:function(n){var e=this;this.config.isWebappContainer||(Object.entries(n).forEach((function(n){var t=E(n,2),r=t[0],i=t[1];void 0!==(void 0===i?"undefined":S(i))&&function(n,t){e.config[n]=t}(r,i)})),this.lifeCycle.emit("onConfigInit",this.config),this.updateCommonDataBasedOnConfig(n))}},{key:"verbose",value:function(n,e){this.normalLogPipeLine({severity:"verbose",eventName:n,extraInfo:e})}},{key:"httpLog",value:function(n,e){this.normalLogPipeLine({severity:"http",eventName:n,extraInfo:e})}},{key:"info",value:function(n,e){this.normalLogPipeLine({severity:"info",eventName:n,extraInfo:e})}},{key:"warn",value:function(n,e){this.normalLogPipeLine({severity:"warn",eventName:n,extraInfo:e})}},{key:"error",value:function(n,e){console.error("error",n),this.normalLogPipeLine({severity:"error",eventName:n,extraInfo:e})}},{key:"businessLog",value:function(n,e){this.normalLogPipeLine({severity:"info",eventName:n,extraInfo:x(k({},e),{isBusinessLog:!0})})}},{key:"reportDuration",value:function(n,e,t){"string"==typeof n?"number"==typeof e?e<0||e>6e4?console.warn("reportDuration: duration (second param) must between 0 and 60000"):this.normalLogPipeLine({severity:"speed",eventName:n,extraInfo:k({duration:e},t)}):console.warn("reportDuration: duration (second param) must be number"):console.warn("reportDuration: eventName (first param) must be a string")}},{key:"getTimerKey",value:function(n){var e=B(this);return this.config.isWebappContainer?"".concat(e,"_").concat(n):n}},{key:"timeStart",value:function(n){"string"==typeof n?(this.timeMap[this.getTimerKey(n)]&&console.warn("Timer ".concat(n," already exists")),this.timeMap[this.getTimerKey(n)]=Date.now()):console.warn("time: first param must be a string")}},{key:"timeEnd",value:function(n,e){if("string"==typeof n)if(this.timeMap[this.getTimerKey(n)]){var t=Date.now()-this.timeMap[this.getTimerKey(n)]+(e||0);this.normalLogPipeLine({severity:"speed",eventName:n,extraInfo:{duration:t}}),delete this.timeMap[this.getTimerKey(n)]}else console.warn("Timer key :".concat(n," does not exist"));else console.warn("timeEnd: first param must be a string")}},{key:"addToAssetSpeedWhiteListByMFE",value:function(n){var e,t,r,i,o=n.MFEName,a=n.whiteList;this.config.isWebappContainer&&o&&(null==a?void 0:a.length)&&(this.config.assetSpeedMonitoringWhiteListByMFE||(this.config.assetSpeedMonitoringWhiteListByMFE={}),(null===(e=this.config.assetSpeedMonitoringWhiteListByMFE)||void 0===e?void 0:e[o])?null===(i=this.config.assetSpeedMonitoringWhiteListByMFE)||void 0===i||null===(r=i[o])||void 0===r||(t=r).push.apply(t,I(a)):this.config.assetSpeedMonitoringWhiteListByMFE=x(k({},this.config.assetSpeedMonitoringWhiteListByMFE),g({},o,a)))}},{key:"destroy",value:function(){this.config.isWebappContainer||this.plugins.forEach((function(n){n.uninstall()}))}}]),n}(),Dn=Cn,Tn=function(n,e){return Tn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,e){n.__proto__=e}||function(n,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t])},Tn(n,e)};function Pn(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=n}Tn(n,e),n.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t)}var Rn=function(){return Rn=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},Rn.apply(this,arguments)};function On(n,e,t,r){return new(t||(t=Promise))((function(e,i){function o(n){try{s(r.next(n))}catch(n){i(n)}}function a(n){try{s(r.throw(n))}catch(n){i(n)}}function s(n){var r;n.done?e(n.value):(r=n.value,r instanceof t?r:new t((function(n){n(r)}))).then(o,a)}s((r=r.apply(n,[])).next())}))}function jn(n,e){var t,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(t=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(n,a)}catch(n){s=[6,n],r=0}finally{t=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function _n(n,e){for(var t,r=0,i=e.length;r<i;r++)!t&&r in e||(t||(t=Array.prototype.slice.call(e,0,r)),t[r]=e[r]);return n.concat(t||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var An,Ln,Un,Fn={dev:j.staging,staging:j.staging,demo:j.demo,prod:j.production},Mn=function(n){if("object"!=typeof n)return n;try{var e=JSON.parse(JSON.stringify(n));return Object.keys(e).forEach((function(n){"string"==typeof n&&["auth","code"].some((function(e){return n.includes(e)}))&&(e[n]="***")})),e}catch(e){return n}},Kn=function(n,e){var t,r;null===(r=null===(t=window._AirwallexSDKs)||void 0===t?void 0:t.airTracker)||void 0===r||r.error(n,Rn(Rn({},e),{context:"components-sdk"}))},Hn=function(n,e){var t;null===(t=window._AirwallexSDKs.airTracker)||void 0===t||t.info(n,Rn(Rn({},e),{context:"components-sdk"}))},qn=function(n){function e(e){var t=n.call(this,e)||this;return t.code="LOAD_SCRIPT_ERROR",t}return Pn(e,n),e}(Error);!function(n){n.dev="dev",n.staging="staging",n.demo="demo",n.prod="prod",n.sandbox="sandbox"}(Un||(Un={}));var zn,Bn=((An={})[Un.dev]="https://checkout-staging.airwallex.com",An[Un.staging]="https://checkout-staging.airwallex.com",An[Un.demo]="https://checkout-demo.airwallex.com",An[Un.prod]="https://checkout.airwallex.com",An[Un.sandbox]="https://checkout.sandbox.airwallex.com",An),Wn=((Ln={})[Un.dev]="https://static-staging.airwallex.com",Ln[Un.staging]="https://static-staging.airwallex.com",Ln[Un.demo]="https://static-demo.airwallex.com",Ln[Un.prod]="https://static.airwallex.com",Ln[Un.sandbox]="https://static.sandbox.airwallex.com",Ln),Xn="sdkController",Gn="payments",Vn={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"},Jn={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"},Qn={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"]},$n={billing:["payments"]},Yn=["payments","sca","billing"],Zn=function(n){function e(e){var t=n.call(this,e)||this;return t.code="INVALID_STATIC_RESOURCE_ERROR",t}return Pn(e,n),e}(Error),ne=Date.now(),ee=function(n){return Jn[n]},te=function(n){var e=n.reduce((function(n,e){return n.concat((t=e,Object.keys(Qn).includes(t)?Qn[e]:e));var t}),[]);return Array.from(new Set(e)).map((function(n){return{elementName:n,sdkName:ee(n)}}))},re=function(n){return"payments"===n?"payment":n},ie=function(n){var e=n.name,t=n.env,r=function(n,e){var t=n===Gn?Bn:Wn;return t[e]||t.prod}(e,void 0===t?Un.prod:t),i=Vn[e];if(!i)throw Kn("[components-sdk] Element static resource not found",{sdkName:e}),new Zn("Element ".concat(e," static resource URL is invalid."));return"".concat(r).concat(i,"?ts=").concat(ne)},oe=function(){return Math.floor(performance.now())},ae=function(n){function e(e){var t=n.call(this,e)||this;return t.code="INSTANCE_NOT_FOUND_ERROR",t}return Pn(e,n),e}(Error),se=new Map,ue=function(n){var e=n.scriptName,t=ie({name:e,env:n.env}),r=se.get(e);if(r)return r;var i=function(n){return On(void 0,0,void 0,(function(){var e,t;return jn(this,(function(r){switch(r.label){case 0:if("undefined"==typeof window)throw new Error("Please load script in browser environment");e=0,t=function(){return On(void 0,0,void 0,(function(){var t,r,i;return jn(this,(function(){return t=oe(),e>0&&n.includes("?ts=")&&((r=new URL(n,window.location.href)).searchParams.set("ts","".concat(Date.now())),n=r.toString()),i=function(n){var e=document.createElement("script");return e.src=n,e.type="module",(document.head||document.body).appendChild(e),e}(n),[2,new Promise((function(r,o){i.addEventListener("load",(function(){var i=oe();Hn("[components-sdk] SDK script loaded",{scriptUrl:n,start:t,latency:i-t,end:i,retryCount:e}),r(!0)})),i.addEventListener("error",(function(r){i.remove(),console.error(r);var a=oe();Kn("[components-sdk] Failed to load script",{scriptUrl:n,error:r,start:t,latency:a-t,end:a,retryCount:e}),o(new qn("Failed to load Airwallex SDK scripts: ".concat(n)))}))}))]}))}))},r.label=1;case 1:if(!(e<3))return[3,7];r.label=2;case 2:return r.trys.push([2,4,,6]),[4,t()];case 3:return[2,r.sent()];case 4:return r.sent(),e++,[4,(void 0===i&&(i=500),new Promise((function(n){return window.setTimeout(n,i)})))];case 5:return r.sent(),[3,6];case 6:return[3,1];case 7:throw Kn("[components-sdk] Failed to load script after retry",{scriptUrl:n,retryCount:e}),new qn("Failed to load Airwallex SDK scripts: ".concat(n))}var i}))}))}(t);return se.set(e,i),i},ce=function(n){var e=n.env,t=n.scriptName;return On(void 0,0,void 0,(function(){var n;return jn(this,(function(r){switch(r.label){case 0:return(n=$n[t]||[]).length>0?[4,Promise.all(n.map((function(n){return ue({env:e,scriptName:n})})))]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2,ue({env:e,scriptName:t})]}}))}))},le=function(n){return On(void 0,0,void 0,(function(){return jn(this,(function(){if("undefined"==typeof window)throw new Error("Please call the `init()` function in a browser environment.");var e,t;return t=n.clientId,void 0===(e=n.env)&&(e=j.production),window._AirwallexSDKs.airTracker||(window._AirwallexSDKs.airTracker=new Dn({config:{appName:"components-sdk",appVersion:"1.35.0",env:Fn[e]||j.production}}),window._AirwallexSDKs.airTracker.updateCommonData({clientId:t})),window,Hn("[components-sdk] SDK init start",{options:Mn(n),start:oe()}),zn=new Promise((function(e,t){var r,i=Rn(Rn({},n),{env:n.env&&Un[n.env]?n.env:Un.prod});window.AirwallexComponentsSDK.__env__=i.env;var o=ue({env:i.env,scriptName:Xn}).then((function(){return window._AirwallexSDKs.__controller__.init(i)})),a=null!==(r=n.enabledElements)&&void 0!==r?r:[],s=function(n){return Array.from(new Set(te(n).map((function(n){return n.sdkName})).filter((function(n){return Yn.includes(n)}))))}(a),u=s.map((function(n){return ce({env:i.env,scriptName:n}).then((function(){return o})).then((function(){var e=window._AirwallexSDKs[re(n)];if(!e)throw Kn("[components-sdk] SDK instance not found",{functionsNamespace:n,windowSDKInstanceName:re(n)}),new ae("SDK instance not found");return window._AirwallexSDKs.__controller__.registerFunctions({functionsNamespace:n,instance:e})}))})),c=te(a).map((function(n){var e=n.sdkName,t=n.elementName;return ce({scriptName:e,env:i.env}).then((function(){return o})).then((function(){var n=window._AirwallexSDKs[re(e)];if(!n)throw Kn("[components-sdk] SDK instance not found",{sdkName:e,windowSDKInstanceName:re(e)}),new ae("SDK instance not found");return window._AirwallexSDKs.__controller__.registerElement({sdkName:e,elementName:t,instance:n})}))}));Promise.all(_n(_n([o],u),c)).then((function(){Hn("[components-sdk] SDK initialized",{options:Mn(n),start:oe()}),e(Yn.reduce((function(n,e){var t;return Rn(Rn({},n),((t={})[e]=window._AirwallexSDKs.__controller__.internalSDKs[e],t))}),{}))})).catch((function(n){n.code||Kn("[components-sdk] Unexpected errors when init",{error:n}),t(n)}))})),[2,zn]}))}))},de=function(n,e){return On(void 0,0,void 0,(function(){var t,r,i,o,a;return jn(this,(function(s){switch(s.label){case 0:if(!n)throw new Error("Element type is missing. Please specify a valid element.");if(Hn("[components-sdk] SDK createElement start",{elementName:n,options:Mn(e),timestamp:oe()}),!zn)throw function(){var n;null===(n=window._AirwallexSDKs.airTracker)||void 0===n||n.warn("[components-sdk] Did not call init before createElement",Rn(Rn({},void 0),{context:"components-sdk"}))}(),new Error("Please initialize the Element before creating it.");return[4,zn];case 1:if(s.sent(),!(t=ee(n)))throw new Error("`createElement()` with type `".concat(n,"` is not supported. Please specify a valid Element type."));r=oe(),s.label=2;case 2:return s.trys.push([2,6,,7]),[4,ce({scriptName:t,env:window.AirwallexComponentsSDK.__env__||Un.prod})];case 3:return s.sent(),[4,window._AirwallexSDKs.__controller__.registerElement({sdkName:t,elementName:n,instance:window._AirwallexSDKs[re(t)]})];case 4:return s.sent(),[4,window._AirwallexSDKs.__controller__.createElement(n,e)];case 5:return i=s.sent(),o=oe(),Hn("[components-sdk] SDK createElement being called",{elementName:n,options:Mn(e),start:r,latency:o-r,end:o}),[3,7];case 6:if((a=s.sent()).code)throw a;return Kn("[components-sdk] Unexpected errors when createElement",{error:a}),[3,7];case 7:return[2,i]}}))}))},fe=[Xn,Gn],ve=function(){fe.forEach((function(n){var e=ie({name:n,env:Un.prod}),t=document.createElement("link");t.href=e,t.rel="modulepreload",t.as="script",(document.head||document.body).appendChild(t)}))};"undefined"==typeof document||"undefined"==typeof window||("loading"===document.readyState?document.addEventListener("DOMContentLoaded",ve):ve()),"undefined"!=typeof window&&(window.AirwallexComponentsSDK||Object.defineProperties(window,{AirwallexComponentsSDK:{value:{},writable:!1},_AirwallexSDKs:{value:{},writable:!1}}),window.AirwallexComponentsSDK.init=le,window.AirwallexComponentsSDK.createElement=de);const{onChange:me,reset:pe,state:he}=n((()=>({clientSecret:null,currency:null,hasPaymentError:!1,isReady:!1,paymentConfirmed:!1,paymentIntentId:null}))),ye=n=>"AIRWALLEX"===n.paymentProcessor&&(n.clientSecret&&(he.clientSecret=n.clientSecret),n.paymentIntentId&&(he.paymentIntentId=n.paymentIntentId),!!he.clientSecret||(o("Airwallex checkout session is missing the client secret"),!1)),we={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"},ge=n=>we[n]||"en";let be=null;const ke=async()=>!!he.isReady||(be||(be=le({enabledElements:["payments"],env:e.zonosMode&&"production"!==e.zonosMode||"LIVE"!==e.checkoutSettings.mode?"demo":"prod",locale:ge(r.selectedLocale)}).then((()=>(he.isReady=!0,u("Airwallex SDK initialized"),!0))).catch((n=>(o(n),be=null,!1)))),be),xe=["SUCCEEDED","REQUIRES_CAPTURE","PENDING_REVIEW","PENDING"],Ee=n=>!!n&&xe.includes(n),Ie=n=>{switch(n){case"SUCCEEDED":return{isError:!1,messages:[t("Thank you for submitting your payment. We appreciate your prompt attention."),"",t("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:!1,messages:[t("Payment processing. We'll update you when payment is received.")]};case"REQUIRES_CUSTOMER_ACTION":return{isError:!1,messages:[t("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:!0,messages:[t("Payment failed. Please reload the page and try another payment method.")]};default:return{isError:!0,messages:[t("Something went wrong.")]}}},Se=async n=>{const{errors:e,json:t}=await a("/api/zonos-elements/collect/airwallex-payment-intent",{body:{paymentIntentId:n},method:"POST"});return e.length||!t?(o("Failed to retrieve Airwallex payment intent",e),{status:null}):{status:t.airwallexPaymentIntent.status}},{state:Ne}=n((()=>({amountDutyTaxFeeTotal:null,amountTotalPaid:null,collectLogoUrl:null,isFetchingShippingInfo:!0,landedCostShortId:null,originCompanyName:null,partyBillingId:null,paymentProcessor:null,shippingAddress:null}))),Ce=async({landedCostId:n,retries:t=5})=>{var r,i,o,u,c,d,f,v,m,p;Ne.isFetchingShippingInfo=!0;const h=await a("/api/zonos-elements/collect/get-shipping-info-by-lc-id",{body:{landedCostId:n},method:"POST"});if(h.errors.length)return t>0?(await new Promise((n=>setTimeout(n,1e3))),Ce({landedCostId:n,retries:t-1})):null;Ne.landedCostShortId=(null===(r=h.json)||void 0===r?void 0:r.landedCostShortId)||null,Ne.isFetchingShippingInfo=!1,Ne.shippingAddress=(null===(i=h.json)||void 0===i?void 0:i.shipping)||null;const y=null===(o=l.checkoutSession)||void 0===o?void 0:o.landedCost,w=null===(u=l.checkoutSession)||void 0===u?void 0:u.subtotals,g=((null===(c=null==y?void 0:y.amountSubtotals)||void 0===c?void 0:c.shipping)||0)+((null===(d=null==y?void 0:y.amountSubtotals)||void 0===d?void 0:d.items)||0);Ne.amountTotalPaid=g*((null===(f=null==w?void 0:w.exchangeRate)||void 0===f?void 0:f.rate)||1),Ne.amountDutyTaxFeeTotal=((null==w?void 0:w.duties)||0)+((null==w?void 0:w.taxes)||0)+((null==w?void 0:w.fees)||0),Ne.originCompanyName=(null===(m=null===(v=h.json)||void 0===v?void 0:v.origin)||void 0===m?void 0:m.companyName)||null,Ne.collectLogoUrl=(null===(p=h.json)||void 0===p?void 0:p.collectLogoUrl)||null,0===Ne.amountTotalPaid&&s({endpoint:"COLLECT_NO_TOTAL_PAID",errors:[],metadata:{landedCostId:n,organizationId:e.organizationId}})},De=async()=>{var n,e,t,r;if(!(null===(n=f.stripeBillingAddressEventData)||void 0===n?void 0:n.complete))return{partiesCreated:!1};const u=null===(t=null===(e=l.checkoutSession)||void 0===e?void 0:e.landedCost)||void 0===t?void 0:t.rootId;if(!u)return s({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:i.checkoutSessionId}}),{partiesCreated:!1};if(!i.checkoutSessionId)return s({endpoint:"COLLECT_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:c,cartId:window.Zonos.cartId,landedCostRootId:u}}),{partiesCreated:!1};const d=v({address:f.stripeBillingAddressEventData.value.address,firstName:f.stripeBillingAddressEventData.value.firstName,lastName:f.stripeBillingAddressEventData.value.lastName,name:f.stripeBillingAddressEventData.value.name,phone:f.stripeBillingAddressEventData.value.phone}),m="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:p,json:h}=await a("/api/zonos-elements/create-billing-party",{body:{billingAddress:d,checkoutSessionId:i.checkoutSessionId,companyName:f.companyName,email:(null===(r=f.stripeLinkEventData)||void 0===r?void 0:r.value.email)||"",isTest:m,rootId:u},method:"POST"});return p.length||!h?(o("Error occurs when creating billing party",JSON.stringify(p,null,2)),s({endpoint:"COLLECT_BILLING_PARTY_CREATE_FAILED",errors:["[COLLECT] Failed to create billing party"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:i.checkoutSessionId,errors:p,json:h}}),{partiesCreated:!1}):(Ne.partyBillingId=h.billToPartyId,{partiesCreated:!0})},Te=async n=>{const e=n.landedCost;return!!e&&(l.landedCostData=[Object.assign(Object.assign({},n),{landedCost:Object.assign({},e),landedCostId:e.id})],d({applySubtotalsOnly:!0,landedCostId:e.id,selectedShippingOption:e.shipmentRating}))};export{ye as a,he as b,Ne as c,Se as d,Ee as e,ke as f,Te as g,Ce as h,De as i,Ie as j,pe as k,de as l,ge as m,me as n}
|
|
1
|
+
import{c as n,z as e}from"./p-W82paT5F.js";import{t,l as r,s as i}from"./p-clDfq9AL.js";import{l as o,h as a,s}from"./p-DE4a-QD5.js";import{l as u,b as c}from"./p-BJmZPrZl.js";import{d as l,Y as d,b as f,a0 as v}from"./p-FRWZayxL.js";function m(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function p(n,e,t,r,i,o,a){try{var s=n[o](a),u=s.value}catch(n){return void t(n)}s.done?e(u):Promise.resolve(u).then(r,i)}function h(n){return function(){var e=this,t=arguments;return new Promise((function(r,i){var o=n.apply(e,t);function a(n){p(o,r,i,a,s,"next",n)}function s(n){p(o,r,i,a,s,"throw",n)}a(void 0)}))}}function y(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function w(n,e){return e&&function(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}(n.prototype,e),n}function g(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function b(n,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](n):n instanceof e}function k(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{},r=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})))),r.forEach((function(e){g(n,e,t[e])}))}return n}function x(n,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):function(n){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e.push.apply(e,t)}return e}(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})),n}function E(n,e){return function(n){if(Array.isArray(n))return n}(n)||function(n,e){var t=null==n?null:"undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(null!=t){var r,i,o=[],a=!0,s=!1;try{for(t=t.call(n);!(a=(r=t.next()).done)&&(o.push(r.value),o.length!==e);a=!0);}catch(n){s=!0,i=n}finally{try{a||null==t.return||t.return()}finally{if(s)throw i}}return o}}(n,e)||N(n,e)||function(){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 I(n){return function(n){if(Array.isArray(n))return m(n)}(n)||function(n){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}(n)||N(n)||function(){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 S(n){return n&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n}function N(n,e){if(n){if("string"==typeof n)return m(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);return"Object"===t&&n.constructor&&(t=n.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?m(n,e):void 0}}function C(n,e){var t,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&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}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(n,a)}catch(n){o=[6,n],r=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var T,D,P,R,O,j=function(n){return n.production="prod",n.demo="demo",n.staging="staging",n}(j||{}),_="airTracker_unknown",A={appName:_,appVersion:_,env:"staging",isWebappContainer:!1,delay:2e3,errorRepeatTime:3,enableErrorMonitoring:!1,assetSpeedMonitoringWhiteList:[],enableDetectPageChange:!1,enableRecordPageRetention:!1,hideSearchParams:!1,useSessionStorageForSessionId:!1,assetSpeedMonitoringWhiteListByMFE:{}},L={appName:_,env:"staging",sessionId:_,deviceId:_},U=function(){var n=new WeakSet;return function(e,t){if(b(t,Error))return"Error.message: ".concat(t.message," \n Error.stack: ").concat(t.stack);if("object"===(void 0===t?"undefined":S(t))&&null!==t){if(n.has(t))return"[Circular ".concat(e||"root","]");n.add(t)}return"function"==typeof t?"function":"symbol"===(void 0===t?"undefined":S(t))?"symbol":void 0===t?null:t}},F=function(n){if("string"==typeof n)return n;try{return b(n,Error)?(JSON.stringify(n,U())||"undefined").replace(/"/gim,""):JSON.stringify(n,U())}catch(n){return'{"error":"error happen when airTracker stringify"}'}},M=function(n){var e=n.method,t=void 0===e?"post":e,r=n.url,i=n.data,o=n.success,a=n.fail;if((s=i)&&!/^\s*$/.test(s)&&(s=(s=(s=s.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@")).replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]")).replace(/(?:^|:|,)(?:\s*\[)+/g,""),/^[\],:{}\s]*$/.test(s))){var s,u=new XMLHttpRequest;u.addEventListener("readystatechange",(function(){4===u.readyState&&(u.status>=400||0===u.status?null==a||a(u.response):null==o||o(u.response))})),u.open(t,r),u.setRequestHeader("Content-Type","application/json"),u.send(i)}},K="onCommonUpdated",q="AIR_ANALYTICS_DEVICE_ID",H="AIR_ANALYTICS_SESSION_ID",z=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(n){var e=16*Math.random()|0;return("x"===n?e:3&e|8).toString(16)}))},B=function(n){var e,t,r;return n.config.getMFEName?n.config.getMFEName():(null===(r=location)||void 0===r||null===(t=r.pathname)||void 0===t||null===(e=t.split("/"))||void 0===e?void 0:e[2])||"unknown"},W=function(n){return"string"==typeof n?n.split("?")[1]||"":n},X=function(n){return"string"==typeof n&&n.startsWith("//")?"undefined"!=typeof location&&"https:"===location.protocol:/^https/.test(n)},V=function(n){return"number"==typeof n||"string"==typeof n?n:-1},G=function(n,e){var t,r=!1;if(!e.config.isWebappContainer)return J(n,e.config.assetSpeedMonitoringWhiteList);var i=B(e);return r||J(n,null===(t=e.config.assetSpeedMonitoringWhiteListByMFE)||void 0===t?void 0:t[i])},J=function(n,e){if(!(null==e?void 0:e.length))return!1;for(var t=0;t<e.length;t++){var r=e[t];if(b(r,RegExp)&&r.test(n))return!0;if("string"==typeof r&&n.includes(r))return!0}return!1},$=function(n,e){return Math.round(100*(n-e))/100},Q=function(n){return function(e){var t,r,i=B(n),o=n.config.isWebappContainer?k({},n.commonData||{},(null===(t=n.MFECommonDataMap)||void 0===t?void 0:t[i])||{}):n.commonData,a=Array.isArray(e)?e:[e];if(0!==a.length){var s,u=F({commonData:o,data:a}),c={method:"post",url:(s=n.commonData.env,"prod"==s?"https://o11y.airwallex.com/airtracker/logs":"demo"==s?"https://o11y-demo.airwallex.com/airtracker/logs":"https://o11y-staging.airwallex.com/airtracker/logs"),data:u};"function"==typeof(null===(r=navigator)||void 0===r?void 0:r.sendBeacon)&&navigator.sendBeacon(c.url,u)||M(c)}}},Y=function(n){return function(e){var t,r,i,o=B(n),a={commonData:n.config.isWebappContainer?k({},n.commonData||{},(null===(t=n.MFECommonDataMap)||void 0===t?void 0:t[o])||{}):n.commonData,data:Array.isArray(e)?e:[e]},s=F(a),u={method:"post",url:(i=n.commonData.env,"prod"==i?"https://o11y.airwallex.com/airtracker/metrics":"demo"==i?"https://o11y-demo.airwallex.com/airtracker/metrics":"https://o11y-staging.airwallex.com/airtracker/metrics"),data:s};"function"==typeof(null===(r=navigator)||void 0===r?void 0:r.sendBeacon)&&navigator.sendBeacon(u.url,s)||M(u)}},Z=function(n,e){var t,r=[],i=n.config;return window.addEventListener("beforeunload",(function(){r.length>0&&(n.immediateSendPipe(r.splice(0,r.length)),t&&clearTimeout(t))})),function(o,a){if(r.push(o),n.lifeCycle.on(K,(function(){r.length>0&&(null==a||a(r.splice(0,r.length)),n.lifeCycle.remove(K),t&&clearTimeout(t))})),r.length>=e)return null==a||a(r.splice(0,r.length)),void(t&&clearTimeout(t));t&&clearTimeout(t),t=setTimeout((function(){t=null,r.length>0&&(null==a||a(r.splice(0,r.length)),n.lifeCycle.remove(K))}),i.delay)}},nn=function(){},en=function(n){if(!n||!n.reduce||!n.length)throw new TypeError("createPipeline need at least one function param");return 1===n.length?function(e,t){n[0](e,t||nn)}:n.reduce((function(n,e){return function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nn;return n(t,(function(n){return null==e?void 0:e(n,r)}))}}))},tn=function(){function n(){var e=this;y(this,n),this.emit=function(n,t){if(e){var r,i=e.eventsList[n];if(null==i?void 0:i.length){i=i.slice();for(var o=0;o<i.length;o++){r=i[o];try{var a=r.callback.apply(e,[t]);if(1===r.type&&e.remove(n,r.callback),!1===a)break}catch(n){throw n}}}return e}},this.eventsList={}}return w(n,[{key:"indexOf",value:function(n,e){for(var t=0;t<n.length;t++)if(n[t].callback===e)return t;return-1}},{key:"on",value:function(n,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(this){var r=this.eventsList[n];return r||(this.eventsList[n]=[],r=this.eventsList[n]),-1===this.indexOf(r,e)?(r.push({name:n,type:t||0,callback:e}),this):this}}},{key:"one",value:function(n,e){this.on(n,e,1)}},{key:"remove",value:function(n,e){if(this){var t=this.eventsList[n];if(!t)return null;if(!e){try{delete this.eventsList[n]}catch(n){}return null}if(t.length){var r=this.indexOf(t,e);t.splice(r,1)}return this}}},{key:"clear",value:function(){this.eventsList={}}}]),n}(),rn=function(){function n(e){y(this,n),this.name="",this.isInit=!1,this.name=e.name,this.option=e}return w(n,[{key:"patch",value:function(n){var e,t;this.isInit||(this.isInit=!0,null===(t=this.option)||void 0===t||null===(e=t.setUp)||void 0===e||e.call(this.option,n))}},{key:"uninstall",value:function(){var n,e;null===(e=this.option)||void 0===e||null===(n=e.destroy)||void 0===n||n.apply(this),this.isInit=!1}}]),n}(),on=function(n){var e="".concat(F(n.message)||""," @ (").concat(F(n.filename)||"",":").concat(n.lineno||0,":").concat(n.colno||0,")\n").concat(F(n.error||""));T.normalLogPipeLine({severity:"autoDetectError",eventName:"windowOnError",extraInfo:{error:e}})},an=function(n){var e=n&&F(n.reason);T.normalLogPipeLine({severity:"autoDetectError",eventName:"promiseError",extraInfo:{error:e}})},sn=function(n){var e=(null==n?void 0:n.target)||(null==n?void 0:n.srcElement);if(e){var t=(null==e?void 0:e.src)||(null==e?void 0:e.href),r=e.tagName,i="unknown";if("string"==typeof t&&r){if(window.location.href.indexOf(t)>-1)return;if(/\.js$/.test(t))i="script";else if(/\.css$/.test(t))i="css";else switch(r.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}T.normalLogPipeLine({severity:"autoDetectError",eventName:"staticFileLoadError",extraInfo:{staticFileType:i,error:"".concat(r," load fail: ").concat(t)}})}}},un=new rn({name:"errorDetectionPlugin",setUp:function(n){T=n,window.addEventListener("error",on),window.addEventListener("unhandledrejection",an),window.document.addEventListener("error",sn,!0)},destroy:function(){window.removeEventListener("unhandledrejection",an),window.document.removeEventListener("error",sn,!0),window.removeEventListener("error",on)}}),cn=["img","css","script","link","audio","video","iframe"],ln="resource",dn=function(n){var e,t=n.name;return{url:(e=t,"string"==typeof e?(e.split("?")[0]||"").slice(0,200):e),method:"get",duration:Number(n.duration.toFixed(2)),type:"static",isHttps:X(t),urlQuery:W(t),domainLookup:V(n.domainLookupEnd-n.domainLookupStart),connectTime:V(n.connectEnd-n.connectStart)}},fn=function(n,e){for(var t=0,r=n.length;t<r;t++){var i=n[t];-1!==cn.indexOf(i.initiatorType)&&G(i.name,e)&&e.normalLogPipeLine({severity:"performance",eventName:"assets_speed",extraInfo:{log:dn(i)}})}},vn=new rn({name:"assetsSpeedPlugin",setUp:function(n){if(void 0!==window.performance&&"function"==typeof window.performance.clearResourceTimings&&"function"==typeof window.performance.getEntriesByType&&"function"==typeof window.performance.now){var e=0;window.performance.onresourcetimingbufferfull=function(){e=0,window.performance.clearResourceTimings()},"function"==typeof window.PerformanceObserver?(fn(window.performance.getEntriesByType(ln),n),(P=new window.PerformanceObserver((function(e){fn(e.getEntries(),n)}))).observe({entryTypes:[ln]})):D=setInterval((function(){var t=window.performance.getEntriesByType(ln),r=t.slice(e);e=t.length,fn(r,n)}),3e3)}},destroy:function(){null==P||P.disconnect(),D&&clearInterval(D)}}),mn=new rn({name:"onPageChangePlugin",setUp:function(){var n=h((function(n){var e,t,r,i;return C(this,(function(){return t=null===(e=location)||void 0===e?void 0:e.href,r=document.querySelector("body"),i=function(e){var t,r,i,o,a;n.normalLogPipeLine({severity:"autoDetectEvent",eventName:"onPageChange",extraInfo:{prevHref:e.prevHref,href:(null===(t=location)||void 0===t?void 0:t.href)||"",hostname:null===(r=location)||void 0===r?void 0:r.hostname,pathName:null===(i=location)||void 0===i?void 0:i.pathname,protocol:null===(o=location)||void 0===o?void 0:o.protocol,search:null===(a=location)||void 0===a?void 0:a.search}})},i({prevHref:""}),(R=new MutationObserver((function(){if(location.href!==t){var n=t;t=location.href,i({prevHref:n})}}))).observe(r||document,{subtree:!0,childList:!0}),[2]}))}));return function(e){return n.apply(this,arguments)}}(),destroy:function(){null==R||R.disconnect()}}),pn=new rn({name:"onPageRetentionPlugin",setUp:function(){var n=h((function(n){var e,t,r,i,o,a;return C(this,(function(){return void 0===document.visibilityState||(t=null===(e=location)||void 0===e?void 0:e.href,r=document.querySelector("body"),(o=function(){i=Date.now()})(),document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState?a({href:location.href,leftReason:"visibilityChange"}):"visible"===document.visibilityState&&o()})),window.addEventListener("beforeunload",(function(){a({href:location.href,sendImmediate:!0,leftReason:"pageClose"})})),a=function(e){var t=e.href,r=e.sendImmediate,o=e.leftReason;if(i){var a=Date.now()-i;if(0!==a){i=void 0;var s={severity:"autoDetectEvent",eventName:"onPageRetention",extraInfo:{href:t,duration:a,leftReason:o}};r?n.ImmediatePipeline(s):n.normalLogPipeLine(s)}}},(O=new MutationObserver((function(){if(location.href!==t){var n=t;t=location.href,a({href:n,leftReason:"nextPage"}),o()}}))).observe(r||document,{subtree:!0,childList:!0})),[2]}))}));return function(e){return n.apply(this,arguments)}}(),destroy:function(){null==O||O.disconnect()}}),hn=function(){return Date.now().toString(36)+Math.random().toString(36).substring(2,15)},yn=function(n,e){return![/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].some((function(e){return e.test(n)}))&&J(n,e||[/^https?:\/\/[^\/]*\.airwallex\.com($|\/)/])},wn=function(n){return Math.round(100*n)/100},gn=function(n,e){var t,r,i,o,a,s,u,c,l,d,f,v,m,p,h,y,w,g,b,E=n.url,I=n.method,S=n.errorType,N=n.errorDetail,C=function(n){var e=n.startTime,t=n.endTime,r=n.entries;if(0!==r.length){if(1===r.length)return r[0];var i=r.filter((function(n){return n.startTime>=e&&t&&n.responseEnd<=t})).sort((function(n,e){return n.startTime-e.startTime}));return null==i?void 0:i[0]}}(n),T=new URL(E,window.location.href),D=T.href,P=T.protocol,R=C?(i=(t=C).duration,o=t.responseStart,a=t.connectEnd,s=t.connectStart,u=t.domainLookupEnd,c=t.domainLookupStart,l=t.requestStart,d=t.secureConnectionStart,f=t.redirectEnd,v=t.redirectStart,m=t.responseStatus,p=t.responseEnd,h=t.encodedBodySize,y=t.decodedBodySize,w=t.transferSize,g=t.deliveryType,b=t.initiatorType,{startTime:wn(r=t.startTime),totalDuration:wn(i),timeToFirstByte:$(o,r),tcpDuration:$(a,s),dnsDuration:$(u,c),tlsDuration:$(l,d),redirectDuration:$(f,v),responseDuration:$(p,o),encodeResponseSize:h,decodeResponseSize:y,transferSize:w,deliveryType:g,statusCode:m,initiatorType:b}):{};return{severity:"autoDetectEvent",eventName:"httpClientMetrics",extraInfo:k(x(k({httpUrl:D,method:I,scheme:P},S&&{errorType:S},N&&{errorDetail:N},R),{statusCode:(null==R?void 0:R.statusCode)||(null==n?void 0:n.responseStatus),startTime:(null==R?void 0:R.startTime)||(null==n?void 0:n.startTime),initiatorType:(null==R?void 0:R.initiatorType)||(null==n?void 0:n.initiatorType)}),e)}},bn=function(n){return n&&"object"===(void 0===n?"undefined":S(n))&&"errors"in n&&Array.isArray(n.errors)&&n.errors.every((function(n){return n&&"object"===(void 0===n?"undefined":S(n))&&"message"in n}))},kn="awx_airtracker_api_performance_queue",xn="awx_airtracker_api_performance_plugin_loaded",En="undefined"!=typeof window?window:"undefined"!=typeof global?global:{};En[kn]=En[kn]||[];var In=function(n,e,t){setTimeout((function(){var r=gn(n,t);e.observerPipeline(r),En[kn]=En[kn].filter((function(e){return e.id!==n.id}))}),300)},Sn=function(n,e){setTimeout((function(){var t=En[kn].find((function(e){return e.id===n}));if(t){var r=gn(t,{exceptionType:"timeout-without-response"});e.observerPipeline(r),En[kn]=En[kn].filter((function(e){return e.id!==n}))}}),1e4)},Nn=new rn({name:"apiPerformancePlugin",setUp:function(){var n=h((function(n){var e,t;return C(this,(function(){return En[xn]||(null===(e=n.config)||void 0===e?void 0:e.enableRecordAPIPerformance)&&Math.random()<((null===(t=n.config)||void 0===t?void 0:t.enableRecordAPIPerformancePercentage)||0)&&(En[xn]=!0,function(n){var e;(function(n){var e=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(t,r,i,o,a){try{var s,u=hn();this.__requestId=u;var c=b(r,URL)?r.href:new URL(r,window.location.href).href;if(!yn(c,null===(s=n.config)||void 0===s?void 0:s.enableRecordAPIPerformanceWhitelist))return e.call(this,t,r,null==i||i,o,a);var l={id:u,startTime:performance.now(),method:t,url:c,entries:[],initiatorType:"xmlhttprequest"};return En[kn].push(l),Sn(u,n),e.call(this,t,r,null==i||i,o,a)}catch(s){return n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Inject XHR open error",error:s}}),e.call(this,t,r,null==i||i,o,a)}},XMLHttpRequest.prototype.send=function(){for(var e=this,r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];try{var a=En[kn].find((function(n){return n.id===e.__requestId}));if(!a)return t.apply(this,i);var s=this;return this.addEventListener("loadend",h((function(){var e,t,r,i,o,u,c;return C(this,(function(l){switch(l.label){case 0:if(e=performance.now(),t=e-a.startTime,0===(r=s.status))return[2];a.endTime=e,a.duration=t,a.responseStatus=r,l.label=1;case 1:return l.trys.push([1,6,,7]),""!==s.responseType&&"text"!==s.responseType?[3,2]:(i=s.responseText,[3,5]);case 2:return"json"!==s.responseType?[3,3]:(i=s.response,[3,5]);case 3:return"blob"!==s.responseType||"application/json"!==(null==(o=s.response)?void 0:o.type)?[3,5]:[4,o.text()];case 4:i=l.sent(),l.label=5;case 5:return(u=i&&"string"==typeof i?JSON.parse(i):i)&&bn(u)&&(a.errorType="graphqlError",a.errorDetail=u.errors),[3,7];case 6:return c=l.sent(),n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Parse response body error in XHR",url:null==a?void 0:a.url,error:c}}),[3,7];case 7:return In(a,n),[2]}}))}))),this.addEventListener("error",(function(){In(a,n,{exceptionType:"network-error"})})),this.addEventListener("abort",(function(){In(a,n,{exceptionType:"abort-error"})})),this.addEventListener("timeout",(function(){In(a,n,{exceptionType:"timeout-error"})})),t.apply(this,i)}catch(e){throw n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"InjectXHR send error",error:e}}),e}}})(n),function(n){var e=window.fetch;window.fetch=h((function(){var t,r,i,o,a,s,u,c,l,d,f,v,m,p,h,y,w=arguments;return C(this,(function(g){switch(g.label){case 0:for(t=w.length,r=new Array(t),i=0;i<t;i++)r[i]=w[i];return s=new URL(b(r[0],Request)?r[0].url:String(r[0]),window.location.href).href,yn(s,null===(o=n.config)||void 0===o?void 0:o.enableRecordAPIPerformanceWhitelist)?[3,2]:[4,e.apply(this,r)];case 1:return[2,g.sent()];case 2:return g.trys.push([2,9,,10]),c=performance.now(),l=hn(),a={id:l,startTime:c,method:(null===(u=b(r[0],Request)?r[0]:r[1])||void 0===u?void 0:u.method)||"GET",url:s,entries:[],initiatorType:"fetch"},En[kn].push(a),Sn(l,n),[4,e.apply(this,r)];case 3:d=g.sent(),f=performance.now(),a.endTime=f,a.duration=f-c,a.responseStatus=d.status,v=d.clone(),g.label=4;case 4:return g.trys.push([4,7,,8]),v.ok?[4,v.json()]:[3,6];case 5:(m=g.sent())&&bn(m)&&(a.errorType="graphqlError",a.errorDetail=m.errors),g.label=6;case 6:return[3,8];case 7:return p=g.sent(),n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Parse response body error in fetch",url:null==a?void 0:a.url,error:p}}),[3,8];case 8:return In(a,n),[2,d];case 9:throw h=g.sent(),a&&a.id&&En[kn].find((function(n){return n.id===(null==a?void 0:a.id)}))?(y="fetch-error",b(h,TypeError)?y="network-error":b(h,DOMException)&&"AbortError"===h.name&&(y="abort-error"),In(a,n,{exceptionType:y})):n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Inject fetch error",error:h}}),h;case 10:return[2]}}))}))}(n),(null===(e=window)||void 0===e?void 0:e.PerformanceObserver)?new window.PerformanceObserver((function(n){n.getEntries().forEach((function(n){var e=n;"fetch"!==e.initiatorType&&"xmlhttprequest"!==e.initiatorType||En[kn].filter((function(n){return n.url===e.name})).forEach((function(n){n.entries.push(e)}))}))})).observe({entryTypes:["resource"],buffered:!0}):n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{error:"PerformanceObserver Not Supported"}})}(n)),[2]}))}));return function(e){return n.apply(this,arguments)}}()}),Cn=function(){function n(e){var t,r,i=this,o=e.config,a=e.plugins,s=void 0===a?[]:a;y(this,n),this.config=A,this.lifeCycle=new tn,this.plugins=[],this._commonData=L,this._MFECommonDataMap={},this.timeMap={},this.packedDataConvert=function(n){var e,t,r=n.extraInfo,o=k({severity:n.severity,eventName:n.eventName,currentHref:i.config.hideSearchParams?((null===(e=location)||void 0===e?void 0:e.href)||"").split("?")[0]||"":(null===(t=location)||void 0===t?void 0:t.href)||""},r);return i.config.isWebappContainer&&(o.MFEName=B(i)),o},this.normalPipelineObj=en([Z(this,8),(t=this,r={},function(n,e){var i="number"==typeof t.config.errorRepeatTime?t.config.errorRepeatTime:5;if(0===i)return null==e?void 0:e(n);null==e||e(n.filter((function(n){return"autoDetectError"!=n.severity||(r[n.error]=r[n.error]||0,r[n.error]+=1,!(r[n.error]>i))})))}),Q(this)]),this.observerPipelineObj=en([Z(this,8),Y(this)]),this.immediateSendPipe=Q(this),this.observerPipeline=function(n){var e=i.packedDataConvert({severity:n.severity,eventName:n.eventName,extraInfo:n.extraInfo});return i.observerPipelineObj(e)},this.normalLogPipeLine=function(n){var e=i.packedDataConvert({severity:n.severity,eventName:n.eventName,extraInfo:n.extraInfo});return i.config.disableThrottle?i.immediateSendPipe(e):i.normalPipelineObj(e)},this.ImmediatePipeline=function(n){var e=i.packedDataConvert({severity:n.severity,eventName:n.eventName,extraInfo:n.extraInfo});return i.immediateSendPipe(e)},this.plugins=I(s),this.setConfig(o),this.initCommonData(o),this.lifeCycle.emit("onInit"),o.enableErrorMonitoring&&this.plugins.push(un),((null==o?void 0:o.assetSpeedMonitoringWhiteList)&&o.assetSpeedMonitoringWhiteList.length>0||o.isWebappContainer)&&this.plugins.push(vn),(null==o?void 0:o.enableDetectPageChange)&&this.plugins.push(mn),(null==o?void 0:o.enableRecordPageRetention)&&this.plugins.push(pn),(null==o?void 0:o.enableRecordAPIPerformance)&&(null==o?void 0:o.enableRecordAPIPerformancePercentage)&&o.enableRecordAPIPerformancePercentage>0&&o.enableRecordAPIPerformancePercentage<=1&&this.plugins.push(Nn),this.installPlugins()}return w(n,[{key:"installPlugins",value:function(){var n=this;this.plugins.forEach((function(e){e.patch(n)}))}},{key:"commonData",get:function(){return this._commonData}},{key:"MFECommonDataMap",get:function(){return this._MFECommonDataMap}},{key:"initCommonData",value:function(n){this._commonData.sessionId=n.useSessionStorageForSessionId?function(){try{var n=window.sessionStorage.getItem(H);return n||(n=z(),window.sessionStorage.setItem(H,n)),n}catch(n){return z()}}():z(),this._commonData.deviceId=function(){try{var n=window.localStorage.getItem(q);return n||(n=z(),window.localStorage.setItem(q,n)),n}catch(n){}}()||_,this._commonData.riskDeviceId=function(){try{return window.localStorage.getItem("AWX_RISK_ID")||void 0}catch(n){}}(),this._commonData.networkType=function(){var n,e,t="",r=navigator.userAgent.match(/NetType\/(\w+)/);if(r)t=E(r,2)[1];else if(null===(n=navigator)||void 0===n?void 0:n.connection){var i,o,a,s;t=(null===(o=navigator)||void 0===o||null===(i=o.connection)||void 0===i?void 0:i.effectiveType)||(null===(s=navigator)||void 0===s||null===(a=s.connection)||void 0===a?void 0:a.type)}return t||(t="unknown"),e=t,(e=String(e).toLowerCase()).indexOf("4g")>=0?"net4g":e.indexOf("wifi")>=0?"wifi":e.indexOf("5g")>=0?"net5g":e.indexOf("3g")>=0?"net3g":e.indexOf("2g")>=0?"net2g":"unknown"}()||"unknown",this._commonData.env=n.env||this._commonData.env,this._commonData.accountId=n.accountId||_,this._commonData.appVersion=n.appVersion,this._commonData.appName=n.appName,this._commonData.sdkVersion="3.1.0",this.lifeCycle.emit("onCommonDataInit",this.commonData)}},{key:"updateCommonDataBasedOnConfig",value:function(n){this.lifeCycle.emit(K,this._commonData),this._commonData.env=n.env||this._commonData.env,this._commonData.appName=n.appName||this._commonData.appName,this._commonData.env=n.env||this._commonData.env,this._commonData.accountId=n.accountId||this._commonData.accountId,this._commonData.appVersion=n.appVersion||this._commonData.appVersion}},{key:"updateCommonData",value:function(n){this.lifeCycle.emit(K,this._commonData),this._commonData=k({},this._commonData,n)}},{key:"removeCommonDataByKey",value:function(n){var e=this;this.lifeCycle.emit(K,this._commonData),setTimeout((function(){n.forEach((function(n){delete e._commonData[n]}))}),1e3)}},{key:"addToMFECommonData",value:function(n){var e,t=n.MFEName,r=n.MFECommonData;this.config.isWebappContainer&&t&&r&&(this._MFECommonDataMap=x(k({},this._MFECommonDataMap||{}),g({},t,k({},(null===(e=this._MFECommonDataMap)||void 0===e?void 0:e[t])||{},r))))}},{key:"setConfig",value:function(n){var e=this;this.config.isWebappContainer||(Object.entries(n).forEach((function(n){var t=E(n,2),r=t[0],i=t[1];void 0!==(void 0===i?"undefined":S(i))&&function(n,t){e.config[n]=t}(r,i)})),this.lifeCycle.emit("onConfigInit",this.config),this.updateCommonDataBasedOnConfig(n))}},{key:"verbose",value:function(n,e){this.normalLogPipeLine({severity:"verbose",eventName:n,extraInfo:e})}},{key:"httpLog",value:function(n,e){this.normalLogPipeLine({severity:"http",eventName:n,extraInfo:e})}},{key:"info",value:function(n,e){this.normalLogPipeLine({severity:"info",eventName:n,extraInfo:e})}},{key:"warn",value:function(n,e){this.normalLogPipeLine({severity:"warn",eventName:n,extraInfo:e})}},{key:"error",value:function(n,e){console.error("error",n),this.normalLogPipeLine({severity:"error",eventName:n,extraInfo:e})}},{key:"businessLog",value:function(n,e){this.normalLogPipeLine({severity:"info",eventName:n,extraInfo:x(k({},e),{isBusinessLog:!0})})}},{key:"reportDuration",value:function(n,e,t){"string"==typeof n?"number"==typeof e?e<0||e>6e4?console.warn("reportDuration: duration (second param) must between 0 and 60000"):this.normalLogPipeLine({severity:"speed",eventName:n,extraInfo:k({duration:e},t)}):console.warn("reportDuration: duration (second param) must be number"):console.warn("reportDuration: eventName (first param) must be a string")}},{key:"getTimerKey",value:function(n){var e=B(this);return this.config.isWebappContainer?"".concat(e,"_").concat(n):n}},{key:"timeStart",value:function(n){"string"==typeof n?(this.timeMap[this.getTimerKey(n)]&&console.warn("Timer ".concat(n," already exists")),this.timeMap[this.getTimerKey(n)]=Date.now()):console.warn("time: first param must be a string")}},{key:"timeEnd",value:function(n,e){if("string"==typeof n)if(this.timeMap[this.getTimerKey(n)]){var t=Date.now()-this.timeMap[this.getTimerKey(n)]+(e||0);this.normalLogPipeLine({severity:"speed",eventName:n,extraInfo:{duration:t}}),delete this.timeMap[this.getTimerKey(n)]}else console.warn("Timer key :".concat(n," does not exist"));else console.warn("timeEnd: first param must be a string")}},{key:"addToAssetSpeedWhiteListByMFE",value:function(n){var e,t,r,i,o=n.MFEName,a=n.whiteList;this.config.isWebappContainer&&o&&(null==a?void 0:a.length)&&(this.config.assetSpeedMonitoringWhiteListByMFE||(this.config.assetSpeedMonitoringWhiteListByMFE={}),(null===(e=this.config.assetSpeedMonitoringWhiteListByMFE)||void 0===e?void 0:e[o])?null===(i=this.config.assetSpeedMonitoringWhiteListByMFE)||void 0===i||null===(r=i[o])||void 0===r||(t=r).push.apply(t,I(a)):this.config.assetSpeedMonitoringWhiteListByMFE=x(k({},this.config.assetSpeedMonitoringWhiteListByMFE),g({},o,a)))}},{key:"destroy",value:function(){this.config.isWebappContainer||this.plugins.forEach((function(n){n.uninstall()}))}}]),n}(),Tn=Cn,Dn=function(n,e){return Dn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,e){n.__proto__=e}||function(n,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t])},Dn(n,e)};function Pn(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=n}Dn(n,e),n.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t)}var Rn=function(){return Rn=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},Rn.apply(this,arguments)};function On(n,e,t,r){return new(t||(t=Promise))((function(e,i){function o(n){try{s(r.next(n))}catch(n){i(n)}}function a(n){try{s(r.throw(n))}catch(n){i(n)}}function s(n){var r;n.done?e(n.value):(r=n.value,r instanceof t?r:new t((function(n){n(r)}))).then(o,a)}s((r=r.apply(n,[])).next())}))}function jn(n,e){var t,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(t=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(n,a)}catch(n){s=[6,n],r=0}finally{t=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function _n(n,e){for(var t,r=0,i=e.length;r<i;r++)!t&&r in e||(t||(t=Array.prototype.slice.call(e,0,r)),t[r]=e[r]);return n.concat(t||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var An,Ln,Un,Fn={dev:j.staging,staging:j.staging,demo:j.demo,prod:j.production},Mn=function(n){if("object"!=typeof n)return n;try{var e=JSON.parse(JSON.stringify(n));return Object.keys(e).forEach((function(n){"string"==typeof n&&["auth","code"].some((function(e){return n.includes(e)}))&&(e[n]="***")})),e}catch(e){return n}},Kn=function(n,e){var t,r;null===(r=null===(t=window._AirwallexSDKs)||void 0===t?void 0:t.airTracker)||void 0===r||r.error(n,Rn(Rn({},e),{context:"components-sdk"}))},qn=function(n,e){var t;null===(t=window._AirwallexSDKs.airTracker)||void 0===t||t.info(n,Rn(Rn({},e),{context:"components-sdk"}))},Hn=function(n){function e(e){var t=n.call(this,e)||this;return t.code="LOAD_SCRIPT_ERROR",t}return Pn(e,n),e}(Error);!function(n){n.dev="dev",n.staging="staging",n.demo="demo",n.prod="prod",n.sandbox="sandbox"}(Un||(Un={}));var zn,Bn=((An={})[Un.dev]="https://checkout-staging.airwallex.com",An[Un.staging]="https://checkout-staging.airwallex.com",An[Un.demo]="https://checkout-demo.airwallex.com",An[Un.prod]="https://checkout.airwallex.com",An[Un.sandbox]="https://checkout.sandbox.airwallex.com",An),Wn=((Ln={})[Un.dev]="https://static-staging.airwallex.com",Ln[Un.staging]="https://static-staging.airwallex.com",Ln[Un.demo]="https://static-demo.airwallex.com",Ln[Un.prod]="https://static.airwallex.com",Ln[Un.sandbox]="https://static.sandbox.airwallex.com",Ln),Xn="sdkController",Vn="payments",Gn={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"},Jn={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"},$n={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"]},Qn={billing:["payments"]},Yn=["payments","sca","billing"],Zn=function(n){function e(e){var t=n.call(this,e)||this;return t.code="INVALID_STATIC_RESOURCE_ERROR",t}return Pn(e,n),e}(Error),ne=Date.now(),ee=function(n){return Jn[n]},te=function(n){var e=n.reduce((function(n,e){return n.concat((t=e,Object.keys($n).includes(t)?$n[e]:e));var t}),[]);return Array.from(new Set(e)).map((function(n){return{elementName:n,sdkName:ee(n)}}))},re=function(n){return"payments"===n?"payment":n},ie=function(n){var e=n.name,t=n.env,r=function(n,e){var t=n===Vn?Bn:Wn;return t[e]||t.prod}(e,void 0===t?Un.prod:t),i=Gn[e];if(!i)throw Kn("[components-sdk] Element static resource not found",{sdkName:e}),new Zn("Element ".concat(e," static resource URL is invalid."));return"".concat(r).concat(i,"?ts=").concat(ne)},oe=function(){return Math.floor(performance.now())},ae=function(n){function e(e){var t=n.call(this,e)||this;return t.code="INSTANCE_NOT_FOUND_ERROR",t}return Pn(e,n),e}(Error),se=new Map,ue=function(n){var e=n.scriptName,t=ie({name:e,env:n.env}),r=se.get(e);if(r)return r;var i=function(n){return On(void 0,0,void 0,(function(){var e,t;return jn(this,(function(r){switch(r.label){case 0:if("undefined"==typeof window)throw new Error("Please load script in browser environment");e=0,t=function(){return On(void 0,0,void 0,(function(){var t,r,i;return jn(this,(function(){return t=oe(),e>0&&n.includes("?ts=")&&((r=new URL(n,window.location.href)).searchParams.set("ts","".concat(Date.now())),n=r.toString()),i=function(n){var e=document.createElement("script");return e.src=n,e.type="module",(document.head||document.body).appendChild(e),e}(n),[2,new Promise((function(r,o){i.addEventListener("load",(function(){var i=oe();qn("[components-sdk] SDK script loaded",{scriptUrl:n,start:t,latency:i-t,end:i,retryCount:e}),r(!0)})),i.addEventListener("error",(function(r){i.remove(),console.error(r);var a=oe();Kn("[components-sdk] Failed to load script",{scriptUrl:n,error:r,start:t,latency:a-t,end:a,retryCount:e}),o(new Hn("Failed to load Airwallex SDK scripts: ".concat(n)))}))}))]}))}))},r.label=1;case 1:if(!(e<3))return[3,7];r.label=2;case 2:return r.trys.push([2,4,,6]),[4,t()];case 3:return[2,r.sent()];case 4:return r.sent(),e++,[4,(void 0===i&&(i=500),new Promise((function(n){return window.setTimeout(n,i)})))];case 5:return r.sent(),[3,6];case 6:return[3,1];case 7:throw Kn("[components-sdk] Failed to load script after retry",{scriptUrl:n,retryCount:e}),new Hn("Failed to load Airwallex SDK scripts: ".concat(n))}var i}))}))}(t);return se.set(e,i),i},ce=function(n){var e=n.env,t=n.scriptName;return On(void 0,0,void 0,(function(){var n;return jn(this,(function(r){switch(r.label){case 0:return(n=Qn[t]||[]).length>0?[4,Promise.all(n.map((function(n){return ue({env:e,scriptName:n})})))]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2,ue({env:e,scriptName:t})]}}))}))},le=function(n){return On(void 0,0,void 0,(function(){return jn(this,(function(){if("undefined"==typeof window)throw new Error("Please call the `init()` function in a browser environment.");var e,t;return t=n.clientId,void 0===(e=n.env)&&(e=j.production),window._AirwallexSDKs.airTracker||(window._AirwallexSDKs.airTracker=new Tn({config:{appName:"components-sdk",appVersion:"1.35.0",env:Fn[e]||j.production}}),window._AirwallexSDKs.airTracker.updateCommonData({clientId:t})),window,qn("[components-sdk] SDK init start",{options:Mn(n),start:oe()}),zn=new Promise((function(e,t){var r,i=Rn(Rn({},n),{env:n.env&&Un[n.env]?n.env:Un.prod});window.AirwallexComponentsSDK.__env__=i.env;var o=ue({env:i.env,scriptName:Xn}).then((function(){return window._AirwallexSDKs.__controller__.init(i)})),a=null!==(r=n.enabledElements)&&void 0!==r?r:[],s=function(n){return Array.from(new Set(te(n).map((function(n){return n.sdkName})).filter((function(n){return Yn.includes(n)}))))}(a),u=s.map((function(n){return ce({env:i.env,scriptName:n}).then((function(){return o})).then((function(){var e=window._AirwallexSDKs[re(n)];if(!e)throw Kn("[components-sdk] SDK instance not found",{functionsNamespace:n,windowSDKInstanceName:re(n)}),new ae("SDK instance not found");return window._AirwallexSDKs.__controller__.registerFunctions({functionsNamespace:n,instance:e})}))})),c=te(a).map((function(n){var e=n.sdkName,t=n.elementName;return ce({scriptName:e,env:i.env}).then((function(){return o})).then((function(){var n=window._AirwallexSDKs[re(e)];if(!n)throw Kn("[components-sdk] SDK instance not found",{sdkName:e,windowSDKInstanceName:re(e)}),new ae("SDK instance not found");return window._AirwallexSDKs.__controller__.registerElement({sdkName:e,elementName:t,instance:n})}))}));Promise.all(_n(_n([o],u),c)).then((function(){qn("[components-sdk] SDK initialized",{options:Mn(n),start:oe()}),e(Yn.reduce((function(n,e){var t;return Rn(Rn({},n),((t={})[e]=window._AirwallexSDKs.__controller__.internalSDKs[e],t))}),{}))})).catch((function(n){n.code||Kn("[components-sdk] Unexpected errors when init",{error:n}),t(n)}))})),[2,zn]}))}))},de=function(n,e){return On(void 0,0,void 0,(function(){var t,r,i,o,a;return jn(this,(function(s){switch(s.label){case 0:if(!n)throw new Error("Element type is missing. Please specify a valid element.");if(qn("[components-sdk] SDK createElement start",{elementName:n,options:Mn(e),timestamp:oe()}),!zn)throw function(){var n;null===(n=window._AirwallexSDKs.airTracker)||void 0===n||n.warn("[components-sdk] Did not call init before createElement",Rn(Rn({},void 0),{context:"components-sdk"}))}(),new Error("Please initialize the Element before creating it.");return[4,zn];case 1:if(s.sent(),!(t=ee(n)))throw new Error("`createElement()` with type `".concat(n,"` is not supported. Please specify a valid Element type."));r=oe(),s.label=2;case 2:return s.trys.push([2,6,,7]),[4,ce({scriptName:t,env:window.AirwallexComponentsSDK.__env__||Un.prod})];case 3:return s.sent(),[4,window._AirwallexSDKs.__controller__.registerElement({sdkName:t,elementName:n,instance:window._AirwallexSDKs[re(t)]})];case 4:return s.sent(),[4,window._AirwallexSDKs.__controller__.createElement(n,e)];case 5:return i=s.sent(),o=oe(),qn("[components-sdk] SDK createElement being called",{elementName:n,options:Mn(e),start:r,latency:o-r,end:o}),[3,7];case 6:if((a=s.sent()).code)throw a;return Kn("[components-sdk] Unexpected errors when createElement",{error:a}),[3,7];case 7:return[2,i]}}))}))},fe=[Xn,Vn],ve=function(){fe.forEach((function(n){var e=ie({name:n,env:Un.prod}),t=document.createElement("link");t.href=e,t.rel="modulepreload",t.as="script",(document.head||document.body).appendChild(t)}))};"undefined"==typeof document||"undefined"==typeof window||("loading"===document.readyState?document.addEventListener("DOMContentLoaded",ve):ve()),"undefined"!=typeof window&&(window.AirwallexComponentsSDK||Object.defineProperties(window,{AirwallexComponentsSDK:{value:{},writable:!1},_AirwallexSDKs:{value:{},writable:!1}}),window.AirwallexComponentsSDK.init=le,window.AirwallexComponentsSDK.createElement=de);const{onChange:me,reset:pe,state:he}=n((()=>({clientSecret:null,currency:null,hasPaymentError:!1,isReady:!1,paymentConfirmed:!1,paymentIntentId:null}))),ye=n=>"AIRWALLEX"===n.paymentProcessor&&(n.clientSecret&&(he.clientSecret=n.clientSecret),n.paymentIntentId&&(he.paymentIntentId=n.paymentIntentId),!!he.clientSecret||(o("Airwallex checkout session is missing the client secret"),!1)),we={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"},ge=n=>we[n]||"en";let be=null;const ke=async()=>!!he.isReady||(be||(be=le({enabledElements:["payments"],env:e.zonosMode&&"production"!==e.zonosMode||"LIVE"!==e.checkoutSettings.mode?"demo":"prod",locale:ge(r.selectedLocale)}).then((()=>(he.isReady=!0,u("Airwallex SDK initialized"),!0))).catch((n=>(o(n),be=null,!1)))),be),xe=["SUCCEEDED","REQUIRES_CAPTURE","PENDING_REVIEW","PENDING"],Ee=n=>!!n&&xe.includes(n),Ie=n=>{switch(n){case"SUCCEEDED":return{isError:!1,messages:[t("Thank you for submitting your payment. We appreciate your prompt attention."),"",t("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:!1,messages:[t("Payment processing. We'll update you when payment is received.")]};case"REQUIRES_CUSTOMER_ACTION":return{isError:!1,messages:[t("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:!0,messages:[t("Payment failed. Please reload the page and try another payment method.")]};default:return{isError:!0,messages:[t("Something went wrong.")]}}},Se=async n=>{const{errors:e,json:t}=await a("/api/zonos-elements/collect/airwallex-payment-intent",{body:{paymentIntentId:n},method:"POST"});return e.length||!t?(o("Failed to retrieve Airwallex payment intent",e),{status:null}):{status:t.airwallexPaymentIntent.status}},{state:Ne}=n((()=>({amountDutyTaxFeeTotal:null,amountTotalPaid:null,collectLogoUrl:null,isFetchingShippingInfo:!0,landedCostShortId:null,originCompanyName:null,partyBillingId:null,paymentProcessor:null,shippingAddress:null}))),Ce=async({landedCostId:n,retries:t=5})=>{var r,i,o,u,c,d,f,v,m,p;Ne.isFetchingShippingInfo=!0;const h=await a("/api/zonos-elements/collect/get-shipping-info-by-lc-id",{body:{landedCostId:n},method:"POST"});if(h.errors.length)return t>0?(await new Promise((n=>setTimeout(n,1e3))),Ce({landedCostId:n,retries:t-1})):null;Ne.landedCostShortId=(null===(r=h.json)||void 0===r?void 0:r.landedCostShortId)||null,Ne.isFetchingShippingInfo=!1,Ne.shippingAddress=(null===(i=h.json)||void 0===i?void 0:i.shipping)||null;const y=null===(o=l.checkoutSession)||void 0===o?void 0:o.landedCost,w=null===(u=l.checkoutSession)||void 0===u?void 0:u.subtotals,g=((null===(c=null==y?void 0:y.amountSubtotals)||void 0===c?void 0:c.shipping)||0)+((null===(d=null==y?void 0:y.amountSubtotals)||void 0===d?void 0:d.items)||0);Ne.amountTotalPaid=g*((null===(f=null==w?void 0:w.exchangeRate)||void 0===f?void 0:f.rate)||1),Ne.amountDutyTaxFeeTotal=((null==w?void 0:w.duties)||0)+((null==w?void 0:w.taxes)||0)+((null==w?void 0:w.fees)||0),Ne.originCompanyName=(null===(m=null===(v=h.json)||void 0===v?void 0:v.origin)||void 0===m?void 0:m.companyName)||null,Ne.collectLogoUrl=(null===(p=h.json)||void 0===p?void 0:p.collectLogoUrl)||null,0===Ne.amountTotalPaid&&s({endpoint:"COLLECT_NO_TOTAL_PAID",errors:[],metadata:{landedCostId:n,organizationId:e.organizationId}})},Te=async()=>{var n,e,t,r;if(!(null===(n=f.stripeBillingAddressEventData)||void 0===n?void 0:n.complete))return{partiesCreated:!1};const u=null===(t=null===(e=l.checkoutSession)||void 0===e?void 0:e.landedCost)||void 0===t?void 0:t.rootId;if(!u)return s({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:i.checkoutSessionId}}),{partiesCreated:!1};if(!i.checkoutSessionId)return s({endpoint:"COLLECT_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:c,cartId:window.Zonos.cartId,landedCostRootId:u}}),{partiesCreated:!1};const d=v({address:f.stripeBillingAddressEventData.value.address,firstName:f.stripeBillingAddressEventData.value.firstName,lastName:f.stripeBillingAddressEventData.value.lastName,name:f.stripeBillingAddressEventData.value.name,phone:f.stripeBillingAddressEventData.value.phone}),m="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:p,json:h}=await a("/api/zonos-elements/create-billing-party",{body:{billingAddress:d,checkoutSessionId:i.checkoutSessionId,companyName:f.companyName,email:(null===(r=f.stripeLinkEventData)||void 0===r?void 0:r.value.email)||"",isTest:m,rootId:u},method:"POST"});return p.length||!h?(o("Error occurs when creating billing party",JSON.stringify(p,null,2)),s({endpoint:"COLLECT_BILLING_PARTY_CREATE_FAILED",errors:["[COLLECT] Failed to create billing party"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:i.checkoutSessionId,errors:p,json:h}}),{partiesCreated:!1}):(Ne.partyBillingId=h.billToPartyId,{partiesCreated:!0})},De=async n=>{const e=n.landedCost;return!!e&&(l.landedCostData=[Object.assign(Object.assign({},n),{landedCost:Object.assign({},e),landedCostId:e.id})],d({applySubtotalsOnly:!0,landedCostId:e.id,selectedShippingOption:e.shipmentRating}))};export{ye as a,he as b,Ne as c,Se as d,Ee as e,ke as f,De as g,Ce as h,Te as i,Ie as j,pe as k,de as l,ge as m,me as n}
|