@zonos/elements 1.4.1 → 1.5.0
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/index.cjs.js +7 -7
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +66 -3
- package/dist/cjs/zonos-checkout.cjs.entry.js +97 -10
- package/dist/collection/components/checkout/zonos-checkout/zonos-cart-items/zonos-cart-items.css +10 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-cart-items/zonos-cart-items.js +6 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +7 -10
- package/dist/collection/components/utils/checkout/isBigCommerceCheckoutBypassEnabled.js +74 -0
- package/dist/collection/components/utils/checkout/isHostedVsNativeTestAllowed.js +13 -0
- package/dist/collection/components/utils/checkout/itemCustomization.js +53 -0
- package/dist/collection/components/utils/checkout/parseItemCustomizations.js +6 -0
- package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +8 -0
- package/dist/collection/types/checkout/itemCustomization.js +1 -0
- package/dist/collection/types/index.js +1 -0
- package/dist/esm/index.js +7 -7
- package/dist/esm/zonos-cart-items_12.entry.js +66 -3
- package/dist/esm/zonos-checkout.entry.js +97 -10
- package/dist/esm-es5/index.js +4 -4
- package/dist/esm-es5/zonos-cart-items_12.entry.js +23 -10
- package/dist/esm-es5/zonos-checkout.entry.js +44 -19
- package/dist/scripts/index.d.ts +14 -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/utils/checkout/isBigCommerceCheckoutBypassEnabled.d.ts +11 -0
- package/dist/types/components/utils/checkout/isHostedVsNativeTestAllowed.d.ts +11 -0
- package/dist/types/components/utils/checkout/itemCustomization.d.ts +23 -0
- package/dist/types/components/utils/checkout/parseItemCustomizations.d.ts +7 -0
- package/dist/types/types/checkout/CheckoutConfig.d.ts +14 -0
- package/dist/types/types/checkout/itemCustomization.d.ts +4 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-30b3c9d3.entry.js +1 -0
- package/dist/zonos-elements/p-5873ab8e.entry.js +1 -0
- package/dist/zonos-elements/{p-5236c676.system.entry.js → p-7f031592.system.entry.js} +84 -59
- package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
- package/dist/zonos-elements/{p-DPZSD7Kg.system.js → p-CXxvn4GX.system.js} +4 -4
- package/dist/zonos-elements/{p-5016d71b.system.entry.js → p-d82fd8a9.system.entry.js} +68 -54
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/item-customization.d.ts +25 -0
- package/item-customization.js +52 -0
- package/package.json +7 -4
- package/dist/zonos-elements/p-34656e6c.entry.js +0 -1
- package/dist/zonos-elements/p-f8b50aa0.entry.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,o,t,n){function r(e){return e instanceof t?e:new t((function(o){o(e)}))}return new(t||(t=Promise))((function(t,i){function s(e){try{a(n.next(e))}catch(e){i(e)}}function c(e){try{a(n["throw"](e))}catch(e){i(e)}}function a(e){e.done?t(e.value):r(e.value).then(s,c)}a((n=n.apply(e,o||[])).next())}))};var __generator=this&&this.__generator||function(e,o){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,r,i,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=c(0),s["throw"]=c(1),s["return"]=c(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(e){return function(o){return a([e,o])}}function a(c){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,c[0]&&(t=0)),t)try{if(n=1,r&&(i=c[0]&2?r["return"]:c[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;if(r=0,i)c=[c[0]&2,i.value];switch(c[0]){case 0:case 1:i=c;break;case 4:t.label++;return{value:c[1],done:false};case 5:t.label++;r=c[1];c=[0];continue;case 7:c=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){t.label=c[1];break}if(c[0]===6&&t.label<i[1]){t.label=i[1];i=c;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(c);break}if(i[2])t.ops.pop();t.trys.pop();continue}c=o.call(e,t)}catch(e){c=[6,e];r=0}finally{n=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,o,t){if(t||arguments.length===2)for(var n=0,r=o.length,i;n<r;n++){if(i||!(n in o)){if(!i)i=Array.prototype.slice.call(o,0,n);i[n]=o[n]}}return e.concat(i||Array.prototype.slice.call(o))};System.register(["./p-CIevpRv_.system.js","./p-DS-qw_qc.system.js","./p-XDxdMlQl.system.js","./p-DOD2I44l.system.js","./p-BuU_p5DP.system.js","./p-BDopxBpR.system.js","./p-zVLAvre1.system.js","./p-CBx5nYet.system.js","./p-BbgqQIHv.system.js","./p-smUku7Ku.system.js","./p-C2j7R11h.system.js","./p-DBOI98r5.system.js","./p-DQZncB2d.system.js","./p-DW-fW8yR.system.js","./p-BNtWsPPP.system.js","./p-0D0aCMu6.system.js","./p-Cby4EkFu.system.js","./p-B3GRrRtL.system.js","./p-DoEHepOc.system.js","./p-BGktDPwA.system.js","./p-8PPEbm_0.system.js"],(function(e){"use strict";var o,t,n,r,i,s,c,a,u,d,l,f,h,v,m,p,g,w,z,k,y,b,_,C,x,S,I,T,A,O,B,E,
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,o,t,n){function r(e){return e instanceof t?e:new t((function(o){o(e)}))}return new(t||(t=Promise))((function(t,i){function s(e){try{a(n.next(e))}catch(e){i(e)}}function c(e){try{a(n["throw"](e))}catch(e){i(e)}}function a(e){e.done?t(e.value):r(e.value).then(s,c)}a((n=n.apply(e,o||[])).next())}))};var __generator=this&&this.__generator||function(e,o){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,r,i,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=c(0),s["throw"]=c(1),s["return"]=c(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(e){return function(o){return a([e,o])}}function a(c){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,c[0]&&(t=0)),t)try{if(n=1,r&&(i=c[0]&2?r["return"]:c[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;if(r=0,i)c=[c[0]&2,i.value];switch(c[0]){case 0:case 1:i=c;break;case 4:t.label++;return{value:c[1],done:false};case 5:t.label++;r=c[1];c=[0];continue;case 7:c=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){t.label=c[1];break}if(c[0]===6&&t.label<i[1]){t.label=i[1];i=c;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(c);break}if(i[2])t.ops.pop();t.trys.pop();continue}c=o.call(e,t)}catch(e){c=[6,e];r=0}finally{n=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,o,t){if(t||arguments.length===2)for(var n=0,r=o.length,i;n<r;n++){if(i||!(n in o)){if(!i)i=Array.prototype.slice.call(o,0,n);i[n]=o[n]}}return e.concat(i||Array.prototype.slice.call(o))};System.register(["./p-CIevpRv_.system.js","./p-DS-qw_qc.system.js","./p-XDxdMlQl.system.js","./p-DOD2I44l.system.js","./p-BuU_p5DP.system.js","./p-BDopxBpR.system.js","./p-zVLAvre1.system.js","./p-CBx5nYet.system.js","./p-BbgqQIHv.system.js","./p-smUku7Ku.system.js","./p-C2j7R11h.system.js","./p-DBOI98r5.system.js","./p-DQZncB2d.system.js","./p-DW-fW8yR.system.js","./p-BNtWsPPP.system.js","./p-0D0aCMu6.system.js","./p-Cby4EkFu.system.js","./p-B3GRrRtL.system.js","./p-DoEHepOc.system.js","./p-BGktDPwA.system.js","./p-8PPEbm_0.system.js"],(function(e){"use strict";var o,t,n,r,i,s,c,a,u,d,l,f,h,v,m,p,g,w,z,k,y,b,_,C,x,S,I,T,A,O,B,P,E,U,D,L,N,j,R,F,M,H,Z,K,G,V,Q,W,Y,q,J,X,$,ee,oe,te,ne,re,ie,se,ce,ae,ue,de,le,fe,he,ve,me,pe,ge,we,ze,ke,ye,be,_e,Ce,xe,Se,Ie,Te,Ae,Oe,Be,Pe;return{setters:[function(e){o=e.r;t=e.h;n=e.F;r=e.a},function(e){i=e.s;s=e.a;c=e.b;a=e.i;u=e.c;d=e.g;l=e.d;f=e.e;h=e.f;v=e.p;m=e.h;p=e.j;g=e.k;w=e.l;z=e.m;k=e.n;y=e.o;b=e.t;_=e.q;C=e.r;x=e.u;S=e.v;I=e.w;T=e.x;A=e.y;O=e.z;B=e.A;P=e.B;E=e.C;U=e.D;D=e.E;L=e.F;N=e.G;j=e.H;R=e.I;F=e.J;M=e.K},function(e){H=e.p;Z=e.s;K=e.a;G=e.b},function(e){V=e.f;Q=e.a;W=e.b;Y=e.i;q=e.l;J=e.c;X=e.d;$=e.g;ee=e.s;oe=e.V;te=e.e;ne=e.t;re=e.h;ie=e.j},function(e){se=e.z;ce=e.g;ae=e.m},function(e){ue=e.b},function(e){de=e.h;le=e.g;fe=e.j;he=e.l;ve=e.b;me=e.s;pe=e.a;ge=e.i},function(e){we=e.u},function(e){ze=e.l;ke=e.g;ye=e.b},function(e){be=e._;_e=e.c;Ce=e.d;xe=e.a;Se=e.g},function(e){Ie=e.c},function(e){Te=e.c},function(e){Ae=e.g},function(e){Oe=e.i},function(e){Be=e.s},function(e){Pe=e.R},null,null,null,null,null],execute:function(){var Ee=this;
|
|
2
2
|
/**
|
|
3
3
|
* Check if store discount is enabled
|
|
4
|
-
*/var
|
|
4
|
+
*/var Ue=function(){return __awaiter(Ee,void 0,void 0,(function(){var e,o,t;return __generator(this,(function(n){switch(n.label){case 0:return[4/*yield*/,de("/api/zonos-elements/get-store-discount-enabled-status")];case 1:e=n.sent(),o=e.errors,t=e.json;if(o.length||!(t===null||t===void 0?void 0:t.enabled)){return[2/*return*/,{enabled:false}]}return[2/*return*/,{enabled:true}]}}))}))};var De=function(e){return __awaiter(Ee,[e],void 0,(function(e){var o,t,n,r;var i=e.testKeys;return __generator(this,(function(e){switch(e.label){case 0:
|
|
5
5
|
// Do nothing if no test keys are provided
|
|
6
6
|
if(i.length===0){return[2/*return*/,null]}return[4/*yield*/,de("/api/zonos-elements/select-variance-test",{body:{testKeys:i},method:"POST"})];case 1:o=e.sent(),t=o.errors,n=o.json;if(t.length||!n){return[2/*return*/,null]}r=V(n);
|
|
7
7
|
// Filter the response to only include test keys that we support
|
|
@@ -50,7 +50,7 @@ if(t.get("zonosDebug")==="1"){o.searchParams.set("zonosDebug","1")}if(le()){o.se
|
|
|
50
50
|
/**
|
|
51
51
|
* Performs the actual fetch logic to determine if the customer
|
|
52
52
|
* belongs to a bypass group.
|
|
53
|
-
*/var He=function(e){return __awaiter(
|
|
53
|
+
*/var He=function(e){return __awaiter(Ee,void 0,void 0,(function(){var o,t,n,r,i,s,c,a,u,d,l,f;return __generator(this,(function(h){switch(h.label){case 0:
|
|
54
54
|
// Only relevant for BigCommerce stores — permanent no-op on other platforms
|
|
55
55
|
if(!window.Zonos.isBigCommerce){return[2/*return*/,{conclusive:true,result:Me}]}i=(o=se.genericSettings)===null||o===void 0?void 0:o.bigcommerceBypassCustomerGroupIds;if(!(i===null||i===void 0?void 0:i.length)){if(se.loadedConfig){
|
|
56
56
|
// Settings have finished loading and there are no bypass groups
|
|
@@ -77,7 +77,7 @@ return[2/*return*/,{conclusive:true,result:Me}]}l=i.includes(d);f={customerGroup
|
|
|
77
77
|
* Automatically invalidated when a fetch resolves to an inconclusive outcome,
|
|
78
78
|
* so subsequent callers retry (e.g. after the user adds an item to their
|
|
79
79
|
* cart or after settings finish loading).
|
|
80
|
-
*/var Ze=null;var
|
|
80
|
+
*/var Ze=null;var Ke=function(e){var o=He(e);var t=o.then((function(e){var o=e.conclusive,n=e.result;if(!o&&Ze===t){
|
|
81
81
|
// Invalidate cache so the next caller performs a fresh fetch.
|
|
82
82
|
Ze=null}return n}));Ze=t;return t};
|
|
83
83
|
/**
|
|
@@ -85,9 +85,9 @@ Ze=null}return n}));Ze=t;return t};
|
|
|
85
85
|
* Call this once during initialization (e.g. in `zonos-checkout.init()`).
|
|
86
86
|
* The fetch runs in the background; `checkBigCommerceBypassCustomerGroup`
|
|
87
87
|
* will await the result when needed.
|
|
88
|
-
*/var
|
|
88
|
+
*/var Ge=function(){var e;if(!window.Zonos.isBigCommerce){return}var o=(e=se.genericSettings)===null||e===void 0?void 0:e.bigcommerceBypassCustomerGroupIds;if(!(o===null||o===void 0?void 0:o.length)){return}
|
|
89
89
|
// Fire the fetch immediately; consumers will await the same promise
|
|
90
|
-
void
|
|
90
|
+
void Ke()};
|
|
91
91
|
/**
|
|
92
92
|
* Check if the current BigCommerce customer belongs to a customer group
|
|
93
93
|
* that should bypass Zonos Checkout.
|
|
@@ -102,7 +102,7 @@ void Ge()};
|
|
|
102
102
|
* always fetches fresh BigCommerce checkout data. Use this on the
|
|
103
103
|
* BigCommerce domestic checkout page when the shipping country changes,
|
|
104
104
|
* to ensure the customer group reflects the current checkout state.
|
|
105
|
-
*/var Ve=function(){var e=[];for(var o=0;o<arguments.length;o++){e[o]=arguments[o]}return __awaiter(
|
|
105
|
+
*/var Ve=function(){var e=[];for(var o=0;o<arguments.length;o++){e[o]=arguments[o]}return __awaiter(Ee,__spreadArray([],e,true),void 0,(function(e){if(e===void 0){e={}}return __generator(this,(function(o){if(e.forceRefresh||!Ze){return[2/*return*/,Ke(e.preFetched)]}return[2/*return*/,Ze]}))}))};var Qe={guestCheckoutType:null};
|
|
106
106
|
/**
|
|
107
107
|
* BigCommerce's `/checkouts/settings` values almost never change after a
|
|
108
108
|
* merchant's initial setup, so we persist the result in `localStorage` and
|
|
@@ -128,7 +128,7 @@ return null}};var Je=function(e,o){try{var t={expiresAt:Date.now()+We,guestCheck
|
|
|
128
128
|
* Results are cached in `localStorage` for `CACHE_TTL_MS` so navigations
|
|
129
129
|
* inside the same store don't all pay the proxy round trip — the setting
|
|
130
130
|
* is merchant-level and rarely changes.
|
|
131
|
-
*/var Xe=function(){return __awaiter(
|
|
131
|
+
*/var Xe=function(){return __awaiter(Ee,void 0,void 0,(function(){var e,o,t,n,r,i,s;return __generator(this,(function(c){switch(c.label){case 0:if(!window.Zonos.isBigCommerce){return[2/*return*/,Qe]}o=(e=se.checkoutSettings.bigCommerceConfig)===null||e===void 0?void 0:e.storeHash;if(!o){ze("BigCommerce checkout settings: no storeHash provided — skipping fetch","info");return[2/*return*/,Qe]}t=qe(o);if(t){return[2/*return*/,t]}return[4/*yield*/,de("/api/bigcommerce/checkout-settings",{body:{storeHash:o},method:"POST"})];case 1:n=c.sent(),r=n.errors,i=n.json;if(r.length||!i){ze("BigCommerce checkout settings: proxy call failed, falling back to guest-allowed behavior","info");return[2/*return*/,Qe]}s={guestCheckoutType:i.guestCheckoutType};Je(o,s);return[2/*return*/,s]}}))}))};var $e={redirectUrl:null,shouldForceLogin:false};
|
|
132
132
|
/**
|
|
133
133
|
* Session cache for the merchant-level "does BC require login?" answer.
|
|
134
134
|
* Hitting `/checkouts/settings` on every checkout open would add a visible
|
|
@@ -167,7 +167,7 @@ if(eo===e){eo=null}return false}));eo=e}return eo};
|
|
|
167
167
|
* Returning a `redirectUrl` is an instruction, not an action: callers drive
|
|
168
168
|
* the navigation themselves so they can short-circuit any UI state (loading
|
|
169
169
|
* overlays, dialog open flags) before `window.location.href` flips.
|
|
170
|
-
*/var no=function(){var e=[];for(var o=0;o<arguments.length;o++){e[o]=arguments[o]}return __awaiter(
|
|
170
|
+
*/var no=function(){var e=[];for(var o=0;o<arguments.length;o++){e[o]=arguments[o]}return __awaiter(Ee,__spreadArray([],e,true),void 0,(function(e){var o,t,n,r,i;var s=e===void 0?{}:e,c=s.preFetched;return __generator(this,(function(e){switch(e.label){case 0:if(!window.Zonos.isBigCommerce){return[2/*return*/,$e]}return[4/*yield*/,oo()];case 1:o=e.sent();if(!o){return[2/*return*/,$e]}if(!c)return[3/*break*/,2];n=c.checkoutId;return[3/*break*/,4];case 2:return[4/*yield*/,Q()];case 3:n=e.sent();e.label=4;case 4:t=n;if(!t){
|
|
171
171
|
// No active cart — nothing to protect. Force-login only matters once
|
|
172
172
|
// the shopper has a cart we're about to carry into Zonos checkout.
|
|
173
173
|
return[2/*return*/,$e]}if(!c)return[3/*break*/,5];i=c.checkout;return[3/*break*/,7];case 5:return[4/*yield*/,W(t)];case 6:i=e.sent();e.label=7;case 7:r=i;if(!r){
|
|
@@ -233,23 +233,48 @@ state:e.stateOrProvinceCode||e.stateOrProvince||""},email:o,name:t,phone:e.phone
|
|
|
233
233
|
for(var h=0,v=__spreadArray(__spreadArray([],d,true),u,true);h<v.length;h++){var m=v[h];var p=ao(m,a);if(!p){continue}if(!s(p.address.country)){continue}var g=uo(p);if(l.has(g)){continue}l.add(g);f.push(p)}if(!c){return f}
|
|
234
234
|
// Stable-sort the survivors so addresses matching the currently-selected
|
|
235
235
|
// country come first while everything else keeps its original order.
|
|
236
|
-
return f.map((function(e,o){return{index:o,option:e}})).sort((function(e,o){var t=e.option.address.country===c;var n=o.option.address.country===c;if(t===n){return e.index-o.index}return t?-1:1})).map((function(e){return e.option}))};var fo=function(e){if(e===void 0){e=true}if(!q.localizationLoaded){return true}if(q.isDisabledCountry){if(e){ze("Checkout: disabled country")}return true}return false};
|
|
236
|
+
return f.map((function(e,o){return{index:o,option:e}})).sort((function(e,o){var t=e.option.address.country===c;var n=o.option.address.country===c;if(t===n){return e.index-o.index}return t?-1:1})).map((function(e){return e.option}))};var fo=function(e){if(e===void 0){e=true}if(!q.localizationLoaded){return true}if(q.isDisabledCountry){if(e){ze("Checkout: disabled country")}return true}return false};
|
|
237
|
+
/**
|
|
238
|
+
* BigCommerce checkout depends on storefront callbacks (clear cart, inventory).
|
|
239
|
+
* The hosted variant leaves the storefront, so the test does not apply there.
|
|
240
|
+
*/var ho=function(e){var o=e.createCartId,t=e.enabledTestKeys,n=e.isBigCommerce;if(n){return false}if(typeof o!=="function"){return false}return t.includes("hosted_vs_native")};var vo=function(e,
|
|
237
241
|
/**
|
|
238
242
|
* If provided, will check if the country is shippable based on the provided country code instead of the Hello selected country code
|
|
239
243
|
*/
|
|
240
244
|
o){if(e===void 0){e=true}if(!q.localizationLoaded){return false}if(o){var t=J(o);if(e&&!t){ze("Checkout: ".concat(o," is not a shippable country: ").concat(t))}return t}
|
|
241
245
|
// if localization is loaded and the localization is not a shippable country, keep the original click event
|
|
242
|
-
if(!q.isShippableCountry){if(e){ze("Checkout: not shippable country")}return false}return true};var
|
|
246
|
+
if(!q.isShippableCountry){if(e){ze("Checkout: not shippable country")}return false}return true};var mo=["1","true","yes"];
|
|
247
|
+
/**
|
|
248
|
+
* Page-load result of reading the checkout `zBypass` query. Later calls on the
|
|
249
|
+
* same checkout URL reuse this so stripping the parameter does not change the
|
|
250
|
+
* answer.
|
|
251
|
+
*/var po=null;var go=function(){return window.location.pathname.includes("/checkout")};var wo=function(e){if(e===null){return false}return mo.includes(e.trim().toLowerCase())};
|
|
252
|
+
/**
|
|
253
|
+
* True only when zonos-settings set
|
|
254
|
+
* `checkoutSettings.plugins.bigcommerce.allowBypassQuery` to `true`.
|
|
255
|
+
*/var zo=function(){var e,o;return((o=(e=se.checkoutSettings.plugins)===null||e===void 0?void 0:e.bigcommerce)===null||o===void 0?void 0:o.allowBypassQuery)===true};
|
|
256
|
+
/**
|
|
257
|
+
* Read an accepted `zBypass` query on the checkout page once, then remove it
|
|
258
|
+
* from the URL. A later call on that same URL returns the same answer.
|
|
259
|
+
*/var ko=function(){var e=window.location,o=e.pathname,t=e.search;if(po&&po.pathname===o&&po.search===t){return po.enabled}var n=new URLSearchParams(t);var r=wo(n.get("zBypass"));if(!r){po={enabled:false,pathname:o,search:t};return false}n.delete("zBypass");var i=n.toString();var s=window.location.hash||"";var c="".concat(o).concat(i?"?".concat(i):"").concat(s);window.history.replaceState(window.history.state,document.title,c);var a=zo();po={enabled:a,pathname:o,search:window.location.search};return a};
|
|
260
|
+
/**
|
|
261
|
+
* True when this BigCommerce checkout page should skip address detection.
|
|
262
|
+
* That is only when zonos-settings allows the `zBypass` query and this
|
|
263
|
+
* checkout URL has an accepted value. Storefront pages are never bypassed, so
|
|
264
|
+
* the query stays in the URL until checkout. The query is removed once, and
|
|
265
|
+
* later calls on that checkout URL keep the same answer. Nothing is written
|
|
266
|
+
* to storage.
|
|
267
|
+
*/var yo=function(){var e;if(!((e=window.Zonos)===null||e===void 0?void 0:e.isBigCommerce)||!go()){return false}return ko()};var bo='select[name="shippingAddress.countryCode"]';
|
|
243
268
|
/**
|
|
244
269
|
* Native BigCommerce shipping-step "Continue" button. Clicking it commits the
|
|
245
270
|
* selected shipping address and advances to the payment step.
|
|
246
|
-
*/var
|
|
271
|
+
*/var _o="#checkout-shipping-continue, #checkout-billing-continue, #checkout-payment-continue";
|
|
247
272
|
/**
|
|
248
273
|
* Check if the logged-in user already has a shipping address on the checkout
|
|
249
274
|
* that is internationally shippable. If so, optionally prompt the user to
|
|
250
275
|
* confirm before saving the address to session and redirecting to the home
|
|
251
276
|
* page to open the international checkout.
|
|
252
|
-
*/var
|
|
277
|
+
*/var Co=function(e){return __awaiter(Ee,[e],void 0,(function(e){var o,t,n,r,i,c,a,u,d,l,f,h,v,m,p,g,w,z;var k=e.onInternationalCheckoutSelected,y=e.onLoggedInInternationalAddressDetected;return __generator(this,(function(e){switch(e.label){case 0:return[4/*yield*/,Q()];case 1:f=e.sent();if(!f){return[2/*return*/,"noAction"]}return[4/*yield*/,W(f)];case 2:h=e.sent();v={checkout:h,checkoutId:f};return[4/*yield*/,Ve({preFetched:v})];case 3:m=e.sent().shouldBypass;if(m){return[2/*return*/,"noAction"]}p=(t=(o=h===null||h===void 0?void 0:h.consignments)===null||o===void 0?void 0:o[0])===null||t===void 0?void 0:t.shippingAddress;if(!(p===null||p===void 0?void 0:p.countryCode)){return[2/*return*/,"noAction"]}g=p.countryCode;if(!vo(false,g)){return[2/*return*/,"noAction"]}ze(y?"Logged-in user has international shipping address: ".concat(g,", prompting user to choose checkout"):"Logged-in user has international shipping address: ".concat(g,", redirecting automatically (legacy behavior)"),"info");if(!y)return[3/*break*/,5];return[4/*yield*/,y()];case 4:w=e.sent();if(w==="stay"){ze("User opted to stay on BigCommerce native checkout despite international default address","info");return[2/*return*/,"optedOut"]}e.label=5;case 5:return[4/*yield*/,no({preFetched:v})];case 6:z=e.sent();if(z.shouldForceLogin&&z.redirectUrl){window.location.href=z.redirectUrl;return[2/*return*/,"redirected"]}if(!k)return[3/*break*/,8];return[4/*yield*/,k()];case 7:e.sent();e.label=8;case 8:
|
|
253
278
|
// Update localization store with the detected country
|
|
254
279
|
X({isInitializing:false,newSelectedCountryCode:g,persistOverride:false});
|
|
255
280
|
// Save the shipping address to session storage for the international checkout
|
|
@@ -261,15 +286,19 @@ window.location.href=Fe("/");return[2/*return*/,"redirected"]}}))}))};
|
|
|
261
286
|
/**
|
|
262
287
|
* Watch for changes in domestic checkout step. Redirects user to home page to open international checkout when user selects a country in the international shipping zone.
|
|
263
288
|
* @note Only works on default bigcommerce checkout page
|
|
264
|
-
*/var
|
|
289
|
+
*/var xo=function(e){var o=e.domesticRedirectedBtnSelector,t=e.onInternationalCheckoutSelected,n=e.onLoggedInInternationalAddressDetected,r=e.onShippingAddressSessionFound;if(!window.Zonos.isBigCommerce){return}
|
|
290
|
+
// Only the native checkout page skips address detection. Storefront pages
|
|
291
|
+
// still run the domestic-session handoff below, and they do not consume
|
|
292
|
+
// a `zBypass` query, so the parameter can survive until `/checkout`.
|
|
293
|
+
if(window.location.pathname.includes("/checkout")&&yo()){return}
|
|
265
294
|
/**
|
|
266
295
|
* Keep checking.
|
|
267
296
|
* @returns `true` if the caller should stop polling — either because the user
|
|
268
297
|
* is being redirected to Zonos international checkout, or because the
|
|
269
298
|
* logged-in customer is in a bypass group and should stay on BC checkout.
|
|
270
|
-
*/var c=function(e){return __awaiter(
|
|
299
|
+
*/var c=function(e){return __awaiter(Ee,void 0,void 0,(function(){var o,n,r,i,c,a,u,d,l,f;return __generator(this,(function(h){switch(h.label){case 0:n=document.querySelector(((o=se.genericSettings)===null||o===void 0?void 0:o.bigcommerceDomesticCheckoutCountrySelector)||bo);r=(n===null||n===void 0?void 0:n.value)||e;if(!r){
|
|
271
300
|
// do nothing if shipping country is not found
|
|
272
|
-
return[2/*return*/,"noAction"]}if(!
|
|
301
|
+
return[2/*return*/,"noAction"]}if(!vo(false,r)){
|
|
273
302
|
// do nothing if shipping country is not shippable
|
|
274
303
|
return[2/*return*/,"noAction"]}return[4/*yield*/,Q()];case 1:i=h.sent();if(!i)return[3/*break*/,3];return[4/*yield*/,W(i)];case 2:a=h.sent();return[3/*break*/,4];case 3:a=null;h.label=4;case 4:c=a;u={checkout:c,checkoutId:i};return[4/*yield*/,Ve({forceRefresh:true,preFetched:u})];case 5:d=h.sent().shouldBypass;if(d){
|
|
275
304
|
// Logged-in customer is in a bypass group — keep them on BC native
|
|
@@ -297,7 +326,7 @@ window.location.href=Fe("/");return[2/*return*/,"redirected"]}}))}))};
|
|
|
297
326
|
* checkout. Logged-in shoppers picking a saved address don't expose a
|
|
298
327
|
* country `<select>`, so read it from the active checkout consignment via the
|
|
299
328
|
* Storefront API; fall back to the `<select>` value when one is present.
|
|
300
|
-
*/var d=function(){return __awaiter(
|
|
329
|
+
*/var d=function(){return __awaiter(Ee,void 0,void 0,(function(){var e,o,t,n,r,i,s,c;return __generator(this,(function(a){switch(a.label){case 0:return[4/*yield*/,Q()];case 1:r=a.sent();if(!r)return[3/*break*/,3];return[4/*yield*/,W(r)];case 2:i=a.sent();s=(t=(o=(e=i===null||i===void 0?void 0:i.consignments)===null||e===void 0?void 0:e[0])===null||o===void 0?void 0:o.shippingAddress)===null||t===void 0?void 0:t.countryCode;if(s){return[2/*return*/,s]}a.label=3;case 3:c=document.querySelector(((n=se.genericSettings)===null||n===void 0?void 0:n.bigcommerceDomesticCheckoutCountrySelector)||bo);return[2/*return*/,(c===null||c===void 0?void 0:c.value)||null]}}))}))};
|
|
301
330
|
/**
|
|
302
331
|
* Req 2 (05CHECK-887): once a logged-in shopper with an international default
|
|
303
332
|
* address has chosen to "Stay on this page", we must still force them onto
|
|
@@ -312,7 +341,7 @@ window.location.href=Fe("/");return[2/*return*/,"redirected"]}}))}))};
|
|
|
312
341
|
* checkout. On any outcome other than a redirect — domestic, bypass group,
|
|
313
342
|
* or an unexpected error — replay the click so BigCommerce's own handler runs
|
|
314
343
|
* and the shopper is never left stuck on the shipping step.
|
|
315
|
-
*/var l=function(e,o){return __awaiter(
|
|
344
|
+
*/var l=function(e,o){return __awaiter(Ee,void 0,void 0,(function(){var t,n,r,i,s,u;return __generator(this,(function(l){switch(l.label){case 0:t=true;l.label=1;case 1:l.trys.push([1,9,,10]);n=null;l.label=2;case 2:l.trys.push([2,4,,5]);return[4/*yield*/,d()];case 3:n=l.sent();return[3/*break*/,5];case 4:r=l.sent();he("Error resolving selected shipping country on BC continue",r);return[3/*break*/,5];case 5:
|
|
316
345
|
// When the shopper is committing an international address we're about to
|
|
317
346
|
// save the domestic shipping session and redirect to `/`. Disconnect this
|
|
318
347
|
// /checkout-page observer first: otherwise its own session-detection
|
|
@@ -320,7 +349,7 @@ window.location.href=Fe("/");return[2/*return*/,"redirected"]}}))}))};
|
|
|
320
349
|
// open checkout locally, consuming and clearing the session before the
|
|
321
350
|
// navigation to `/` lands, leaving the redirect a no-op. (The `/` page
|
|
322
351
|
// runs its own fresh watcher to open checkout.)
|
|
323
|
-
if(n&&
|
|
352
|
+
if(n&&vo(false,n)){o.disconnect()}if(!n)return[3/*break*/,7];return[4/*yield*/,c(n)];case 6:s=l.sent();return[3/*break*/,8];case 7:s="noAction";l.label=8;case 8:i=s;
|
|
324
353
|
// `redirected` → the page is navigating to the Zonos international
|
|
325
354
|
// checkout, so don't replay. `bypass` / `noAction` → the shopper stays on
|
|
326
355
|
// BC native checkout, so fall through and replay the click.
|
|
@@ -341,7 +370,7 @@ he("Error handling BC continue international redirect",u);return[3/*break*/,10];
|
|
|
341
370
|
*/var f=function(e){if(u){return}u=true;document.addEventListener("click",(function(o){
|
|
342
371
|
// Programmatic replay for the domestic / bypass case — let BC's own
|
|
343
372
|
// handler run without interference.
|
|
344
|
-
if(a){return}var t=o.target;if(!(t instanceof Element)){return}var n=t.closest(
|
|
373
|
+
if(a){return}var t=o.target;if(!(t instanceof Element)){return}var n=t.closest(_o);if(!n){return}
|
|
345
374
|
// Block BC's native advance until we know whether the selected shipping
|
|
346
375
|
// country forces an international redirect. Capture phase +
|
|
347
376
|
// stopImmediatePropagation (done synchronously here, before the async
|
|
@@ -370,13 +399,13 @@ o.preventDefault();o.stopImmediatePropagation();void l(n,e)}),true)};var h=false
|
|
|
370
399
|
// `handleInternationalCheckoutSelected` (both consult the helper), so the
|
|
371
400
|
// top-level gate is redundant. `initBigCommerceBypassCheck()` is called on
|
|
372
401
|
// page load so those inner calls typically resolve against a warm cache.
|
|
373
|
-
var w=new MutationObserver((function(){return __awaiter(
|
|
402
|
+
var w=new MutationObserver((function(){return __awaiter(Ee,void 0,void 0,(function(){var e,s,a,u,d,l,z,k,y,b;var _=this;return __generator(this,(function(C){switch(C.label){case 0:s=document.querySelector(o);a=i();
|
|
374
403
|
// append a hidden button to the body if the shipping address session is found
|
|
375
404
|
if(!s&&a){u=document.createElement("button");u.style.display="none";u.id="zonos--domestic-redirected-checkout-button";document.body.appendChild(u);r===null||r===void 0?void 0:r(a);
|
|
376
405
|
// disconnect the observer after we found the shipping continue button
|
|
377
406
|
w.disconnect();return[2/*return*/]}d=window.location.pathname.includes("/checkout")&&window.Zonos.isBigCommerce;
|
|
378
407
|
// Should just disconnect the observer if it's not bigcommerce domestic checkout page
|
|
379
|
-
if(!d){w.disconnect();return[2/*return*/]}if(!(!p&&!m))return[3/*break*/,5];m=true;g=true;C.label=1;case 1:C.trys.push([1,3,4,5]);return[4/*yield*/,
|
|
408
|
+
if(!d){w.disconnect();return[2/*return*/]}if(!(!p&&!m))return[3/*break*/,5];m=true;g=true;C.label=1;case 1:C.trys.push([1,3,4,5]);return[4/*yield*/,Co({onInternationalCheckoutSelected:t,onLoggedInInternationalAddressDetected:n})];case 2:l=C.sent();if(l==="redirected"){w.disconnect();return[2/*return*/]}if(l==="optedOut"){
|
|
380
409
|
// User elected to stay on BC native checkout — don't prompt again
|
|
381
410
|
// for the rest of this session. Continue with the rest of the
|
|
382
411
|
// observer logic so the country-change watcher still fires when
|
|
@@ -385,7 +414,7 @@ p=true;
|
|
|
385
414
|
// Attach the "Continue" redirect hook now (once). Delegation on
|
|
386
415
|
// `document` keeps it working even after this observer disconnects
|
|
387
416
|
// when the country <select> path sets up its interval below.
|
|
388
|
-
f(w)}return[3/*break*/,5];case 3:z=C.sent();he("Error checking logged-in user shipping address",z);return[3/*break*/,5];case 4:m=false;g=false;return[7/*endfinally*/];case 5:k=document.querySelector(((e=se.genericSettings)===null||e===void 0?void 0:e.bigcommerceDomesticCheckoutCountrySelector)||
|
|
417
|
+
f(w)}return[3/*break*/,5];case 3:z=C.sent();he("Error checking logged-in user shipping address",z);return[3/*break*/,5];case 4:m=false;g=false;return[7/*endfinally*/];case 5:k=document.querySelector(((e=se.genericSettings)===null||e===void 0?void 0:e.bigcommerceDomesticCheckoutCountrySelector)||bo);
|
|
389
418
|
// Shouldn't do anything if it's not bigcommerce domestic checkout page
|
|
390
419
|
if(!k){
|
|
391
420
|
// do nothing if shipping country and the continue button is not found
|
|
@@ -402,27 +431,27 @@ if(h||g){return[2/*return*/]}h=true;t.label=1;case 1:t.trys.push([1,3,,4]);retur
|
|
|
402
431
|
// - the logged-in customer is in a bypass group (stay on BC checkout)
|
|
403
432
|
if(e==="redirected"||e==="bypass"){clearInterval(y);return[2/*return*/]}h=false;return[3/*break*/,4];case 3:o=t.sent();h=false;return[3/*break*/,4];case 4:return[2/*return*/]}}))}))}),1e3);b=setInterval((function(){var e;if(!window.bcStripeElements){clearInterval(b);return}var o=(e=window.bcStripeElements)===null||e===void 0?void 0:e.getElement("address");if(!o){return}clearInterval(b);o.on("change",(function(e){var o=e.value.address.country;if(o&&!g){void c(o)}}));
|
|
404
433
|
// we want to attacch event to addressElement as soon as it's loaded
|
|
405
|
-
}),500);return[2/*return*/]}}))}))}));w.observe(document.body,{childList:true,subtree:true})};var
|
|
434
|
+
}),500);return[2/*return*/]}}))}))}));w.observe(document.body,{childList:true,subtree:true})};var So=function(){var e=new URLSearchParams(window.location.search);ze("legacy urlParams","info",Object.fromEntries(e.entries()));var o=function(o){var t=e.get(o);if(!t||t==="undefined"){return""}return t};var t=
|
|
406
435
|
// fallback to selected country code if country is not provided
|
|
407
|
-
$(e)||q.selectedCountryCode||"US";var n=o("customerCity");var r=o("customerEmail");var i=o("customerAddress1");var s=o("customerAddress2");var c=o("customerName");var a=o("customerPhone");var u=o("customerZip");var d=o("customerState");var l=o("customerFirstName");var f=o("customerLastName");return{customerAddress1:i,customerAddress2:s,customerCity:n,customerCountry:t,customerEmail:r,customerFirstName:l,customerLastName:f,customerName:c,customerPhone:a,customerState:d,customerZip:u}};var
|
|
436
|
+
$(e)||q.selectedCountryCode||"US";var n=o("customerCity");var r=o("customerEmail");var i=o("customerAddress1");var s=o("customerAddress2");var c=o("customerName");var a=o("customerPhone");var u=o("customerZip");var d=o("customerState");var l=o("customerFirstName");var f=o("customerLastName");return{customerAddress1:i,customerAddress2:s,customerCity:n,customerCountry:t,customerEmail:r,customerFirstName:l,customerLastName:f,customerName:c,customerPhone:a,customerState:d,customerZip:u}};var Io=0;var To=function(){return __awaiter(Ee,void 0,void 0,(function(){var e,o;var t;return __generator(this,(function(n){switch(n.label){case 0:
|
|
408
437
|
// Don't send the log if there are no API calls to send
|
|
409
438
|
if(window.Zonos.loadTimeApiInfoList.length===0){return[2/*return*/]}ze("Sending bulk load time api log","info",{loadTimeApiInfoList:window.Zonos.loadTimeApiInfoList});e={data:__spreadArray([],window.Zonos.loadTimeApiInfoList,true),storeId:window.Zonos.storeId||0};
|
|
410
439
|
// Clear the list after sending the log successfully
|
|
411
440
|
window.Zonos.loadTimeApiInfoList.length=0;return[4/*yield*/,de("/api/zonos-elements/log-bulk-load-data",{body:e,method:"POST"})];case 1:o=n.sent().errors;if(o.length){
|
|
412
441
|
// If there are errors, add the logs back to the list so we can try again later
|
|
413
|
-
(t=window.Zonos.loadTimeApiInfoList).push.apply(t,e.data);
|
|
442
|
+
(t=window.Zonos.loadTimeApiInfoList).push.apply(t,e.data);Io++;if(Io>5&&window.Zonos.logIntervalId){
|
|
414
443
|
// If there are more than 3 failures, stop the interval
|
|
415
|
-
clearInterval(window.Zonos.logIntervalId)}}return[2/*return*/]}}))}))};var
|
|
444
|
+
clearInterval(window.Zonos.logIntervalId)}}return[2/*return*/]}}))}))};var Ao=function(){return __awaiter(Ee,void 0,void 0,(function(){var e,o;return __generator(this,(function(t){e=ke().elapsedTime;o={cache:"miss",eventName:"jsdelivr",flag:"LOG_CHECKOUT_FACADE_LOAD",href:window.location.href,loadTime:e,metadata:Object.assign({allLogs:ye},ve()),scriptLoadUrl:"checkoutFacade",storeId:window.Zonos.storeId||0};void de("/api/zonos-elements/log-script-load",{body:o,method:"POST"});return[2/*return*/]}))}))};var Oo=function(e){return __awaiter(Ee,[e],void 0,(function(e){var o;var t=e.loadTime;return __generator(this,(function(e){o={cache:"miss",eventName:"jsdelivr",flag:"LOG_NATIVE_CHECKOUT_LOAD",href:window.location.href,loadTime:t,metadata:Object.assign({allLogs:ye},ve()),scriptLoadUrl:"nativeCheckout",storeId:window.Zonos.storeId||0};void de("/api/zonos-elements/log-script-load",{body:o,method:"POST"});return[2/*return*/]}))}))};var Bo=function(e){return(e===null||e===void 0?void 0:e.filter((function(e){if(e.expiresAt&&e.expiresAt<Date.now()||!e.expiresAt){return false}return true})))||[]};var Po=function(e){var o;var t=(o=ee.enabledVariantTestKeys)===null||o===void 0?void 0:o.find((function(o){return o.testKey===e}));return(t===null||t===void 0?void 0:t.selectedVariantKey)||null};var Eo=function(e){return se.enabledVariantTestKeys.includes(e)};var Uo=function(e){var o=e.baseTestObj,t=e.mergeTestObj;return o.map((function(e){var o=e.testKey;
|
|
416
445
|
// We will attempt to get the enabled selection from localStorage first and only re-fetch if the testKeys are changed
|
|
417
|
-
var n=t.find((function(e){var t=e.testKey;return t===o}));return{expiresAt:(n===null||n===void 0?void 0:n.expiresAt)||Date.now()+oe,selectedVariantKey:(n===null||n===void 0?void 0:n.selectedVariantKey)||null,testKey:o}}))};var
|
|
446
|
+
var n=t.find((function(e){var t=e.testKey;return t===o}));return{expiresAt:(n===null||n===void 0?void 0:n.expiresAt)||Date.now()+oe,selectedVariantKey:(n===null||n===void 0?void 0:n.selectedVariantKey)||null,testKey:o}}))};var Do=function(e){return __awaiter(Ee,[e],void 0,(function(e){var o,t,n,r,i;var s=e.cartId,c=e.retries;return __generator(this,(function(e){switch(e.label){case 0:o=le();return[4/*yield*/,de("/api/zonos-elements/get-temp-cart",{body:{isTestMode:o,options:{noOnlineStoreSettings:true},tempCartUUID:s},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:t=e.sent(),n=t.errors,r=t.json;i=!r||n.length;if(!(i&&c))return[3/*break*/,3];ze("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:c});
|
|
418
447
|
// wait 1 second before retrying
|
|
419
448
|
return[4/*yield*/,new Promise((function(e){return setTimeout(e,500)}))];case 2:
|
|
420
449
|
// wait 1 second before retrying
|
|
421
|
-
e.sent();return[2/*return*/,
|
|
450
|
+
e.sent();return[2/*return*/,Do({cartId:s,retries:c-1})];case 3:if(i){return[2/*return*/,null]}return[2/*return*/,r]}}))}))};var Lo=function(e){return __awaiter(Ee,void 0,void 0,(function(){var o,t,n,r;return __generator(this,(function(i){switch(i.label){case 0:o=be(e),t=o.isDgsCartId,n=o.isLegacyCartId;if(!n&&!t){he("[ZONOS - loadZonos] invalid cart id");return[2/*return*/,null]}return[4/*yield*/,Do({cartId:e,retries:5})];case 1:r=i.sent();ze("[ZONOS - loadZonos] getting temp cart data","info",r);if(!r){he("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2/*return*/,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;return[2/*return*/,{cartData:r.cartData,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var No='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="https://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 4.5C2.25 3.25736 3.25736 2.25 4.5 2.25H13.5C14.7426 2.25 15.75 3.25736 15.75 4.5V10.5C15.75 11.7426 14.7426 12.75 13.5 12.75H8.25C8.01393 12.75 7.79164 12.8611 7.65 13.05L6.3 14.85C5.87508 15.4166 5.2082 15.75 4.5 15.75C3.25736 15.75 2.25 14.7426 2.25 13.5V4.5ZM4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5V13.5C3.75 13.9142 4.08579 14.25 4.5 14.25C4.73607 14.25 4.95836 14.1389 5.1 13.95L6.45 12.15C6.87492 11.5834 7.5418 11.25 8.25 11.25H13.5C13.9142 11.25 14.25 10.9142 14.25 10.5V4.5C14.25 4.08579 13.9142 3.75 13.5 3.75H4.5ZM5.25 6C5.25 5.58579 5.58579 5.25 6 5.25H12C12.4142 5.25 12.75 5.58579 12.75 6C12.75 6.41421 12.4142 6.75 12 6.75H6C5.58579 6.75 5.25 6.41421 5.25 6ZM5.25 9C5.25 8.58579 5.58579 8.25 6 8.25H8.25C8.66421 8.25 9 8.58579 9 9C9 9.41421 8.66421 9.75 8.25 9.75H6C5.58579 9.75 5.25 9.41421 5.25 9Z" fill="#4D505A"/>\n</svg>\n';var jo=function(){return".sc-zonos-checkout-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-checkout-h *.sc-zonos-checkout{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h{z-index:2147483647;position:fixed}.sc-zonos-checkout-h *.sc-zonos-checkout{-ms-scroll-chaining:none;overscroll-behavior:contain}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--zonos-elements-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:32px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--zonos--primary-color, var(--zonos-elements-gray-0));border-right:1px solid var(--zonos-elements-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--zonos-elements-gray-0)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--zonos-elements-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:24px;padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;position:relative}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 8px 8px}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:24px}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--right-actions.sc-zonos-checkout{position:absolute;right:24px;top:24px;z-index:2;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--wrapper.sc-zonos-checkout{overflow:auto;max-height:100%;position:relative}.sc-zonos-checkout-h .flex--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-checkout-h .zonos--logo-wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;gap:16px;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--logo-wrapper.sc-zonos-checkout>*.sc-zonos-checkout{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout img.sc-zonos-checkout{max-height:72px}.sc-zonos-checkout-h .zonos--checkout-default-message.sc-zonos-checkout{margin-left:76px;margin-bottom:8px}.zonos--close-button.sc-zonos-checkout{-ms-flex-item-align:start;align-self:flex-start}.preview.sc-zonos-checkout-h{min-width:500px;margin:auto;position:relative}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{border:var(--zonos-elements-border)}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{padding:32px}.hidden-mode.sc-zonos-checkout-h{height:0;opacity:0;pointer-events:none;position:absolute;visibility:hidden;width:0;z-index:-1}.mobile.sc-zonos-checkout-h{min-width:auto}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding:12px;padding-bottom:76px}@media (max-width: 768px){.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding-bottom:0}}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{-ms-flex-order:2;order:2;border-right:none}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex-order:1;order:1;padding-top:16px}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;border:var(--zonos-elements-border);border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-10));background-color:var(--zonos-elements-gray-50);padding:12px;margin-top:32px}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--review.sc-zonos-checkout{margin-bottom:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--cart-items.sc-zonos-checkout{margin-top:8px}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout zonos-checkout-footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{max-height:100%}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:auto}.mobile.sc-zonos-checkout-h .zonos--cart-subtotal.sc-zonos-checkout{margin:0}.iframed.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{-ms-scroll-chaining:chained;overscroll-behavior:auto}.zonos--processing-payment.sc-zonos-checkout-h{z-index:2147483646}"};
|
|
422
451
|
// 90 minutes
|
|
423
|
-
var
|
|
452
|
+
var Ro=90*60*1e3;
|
|
424
453
|
// 6 hours
|
|
425
|
-
var
|
|
454
|
+
var Fo=6*60*60*1e3;var Mo=e("zonos_checkout",/** @class */function(){function e(e){var t=this;o(this,e);this.storeUnsubscribeList=[];this.isRedirectAfterOrder=false;
|
|
426
455
|
/**
|
|
427
456
|
* Preview checkout without needing to click on the button. This would be useful for demo purpose
|
|
428
457
|
*/this.preview=false;
|
|
@@ -536,29 +565,25 @@ ee.checkoutSessionId=e;return[4/*yield*/,d()];case 1:o=s.sent(),t=o.errors,n=o.j
|
|
|
536
565
|
// treat every first-ever open as already paid, so both must be true.
|
|
537
566
|
if(r.completedAt&&r.order){void this.setToFinishStep("succeeded");return[2/*return*/,true]}if(!r.clientSecret)return[3/*break*/,3];return[4/*yield*/,u({clientSecret:r.clientSecret})];case 2:i=s.sent().status;if(i==="processing"||i==="succeeded"){c.clientSecret=r.clientSecret;void this.setToFinishStep(i);return[2/*return*/,true]}s.label=3;case 3:return[2/*return*/,false]}}))}))};this.initializeTestKeys=function(){
|
|
538
567
|
// cleanup expired test keys
|
|
539
|
-
ee.enabledVariantTestKeys=
|
|
568
|
+
ee.enabledVariantTestKeys=Bo(ee.enabledVariantTestKeys||[]);
|
|
540
569
|
// map existingSelection to the enabled variant test keys from database
|
|
541
570
|
var e=se.enabledVariantTestKeys.map((function(e){var o;
|
|
542
571
|
// We will attempt to get the enabled selection from localStorage first and only re-fetch if the testKeys are changed
|
|
543
|
-
var t=(o=ee.enabledVariantTestKeys)===null||o===void 0?void 0:o.find((function(o){var t=o.testKey;return t===e}));return{expiresAt:(t===null||t===void 0?void 0:t.expiresAt)||Date.now()+oe,selectedVariantKey:(t===null||t===void 0?void 0:t.selectedVariantKey)||null,testKey:e}}));te(e);return{allSelected:false}};this.shouldAllowHostedVsNativeTest=function(){
|
|
544
|
-
// This test is only applicable to checkout that's using createCartid callback
|
|
545
|
-
if(typeof se.checkoutSettings.createCartId!=="function"){return false}var e=se.enabledVariantTestKeys.includes("hosted_vs_native");
|
|
546
|
-
// Should not do anything if the test is not enabled
|
|
547
|
-
if(!e){return false}return true};
|
|
572
|
+
var t=(o=ee.enabledVariantTestKeys)===null||o===void 0?void 0:o.find((function(o){var t=o.testKey;return t===e}));return{expiresAt:(t===null||t===void 0?void 0:t.expiresAt)||Date.now()+oe,selectedVariantKey:(t===null||t===void 0?void 0:t.selectedVariantKey)||null,testKey:e}}));te(e);return{allSelected:false}};this.shouldAllowHostedVsNativeTest=function(){var e;return ho({createCartId:se.checkoutSettings.createCartId,enabledTestKeys:se.enabledVariantTestKeys,isBigCommerce:Boolean((e=window.Zonos)===null||e===void 0?void 0:e.isBigCommerce)})};
|
|
548
573
|
// Register test hosted vs native if needed to get the variant selection for this test
|
|
549
|
-
this.registerTestHostedVsNative=function(){return __awaiter(t,void 0,void 0,(function(){var e,o,t,n;return __generator(this,(function(r){switch(r.label){case 0:e=this.shouldAllowHostedVsNativeTest();if(!e){return[2/*return*/]}ze("[TEST] - Registering hosted vs native test");o=
|
|
574
|
+
this.registerTestHostedVsNative=function(){return __awaiter(t,void 0,void 0,(function(){var e,o,t,n;return __generator(this,(function(r){switch(r.label){case 0:e=this.shouldAllowHostedVsNativeTest();if(!e){return[2/*return*/]}ze("[TEST] - Registering hosted vs native test");o=Po("hosted_vs_native");
|
|
550
575
|
// No need to request variant test for this test if the test already has variant selected
|
|
551
|
-
if(o){ze("[TEST] - Hosted vs native test already has variant selected: ".concat(o));return[2/*return*/]}return[4/*yield*/,
|
|
576
|
+
if(o){ze("[TEST] - Hosted vs native test already has variant selected: ".concat(o));return[2/*return*/]}return[4/*yield*/,De({testKeys:["hosted_vs_native"]})];case 1:t=r.sent();
|
|
552
577
|
// Do not prevent user from proceeding if the test is not enabled or failed to get selection
|
|
553
|
-
if(!t){ze("[TEST] - Failed to get selection for hosted vs native test");return[2/*return*/]}n=
|
|
578
|
+
if(!t){ze("[TEST] - Failed to get selection for hosted vs native test");return[2/*return*/]}n=Uo({baseTestObj:ee.enabledVariantTestKeys||[],mergeTestObj:t});
|
|
554
579
|
// Set the selected variant to the storage store
|
|
555
580
|
te(n);return[2/*return*/]}}))}))};
|
|
556
581
|
// Handle hosted vs native test
|
|
557
|
-
this.handleHostedVsNative=function(){return __awaiter(t,void 0,void 0,(function(){var e,o,t,n,r,i,s,c;return __generator(this,(function(a){switch(a.label){case 0:o=this.shouldAllowHostedVsNativeTest();if(!o){return[2/*return*/,{redirected:false}]}t=
|
|
582
|
+
this.handleHostedVsNative=function(){return __awaiter(t,void 0,void 0,(function(){var e,o,t,n,r,i,s,c;return __generator(this,(function(a){switch(a.label){case 0:o=this.shouldAllowHostedVsNativeTest();if(!o){return[2/*return*/,{redirected:false}]}t=Po("hosted_vs_native");ze("[TEST] - hosted_vs_native: ".concat(t));
|
|
558
583
|
// This test is only applicable to checkout that's using createCartid callback
|
|
559
584
|
if(typeof se.checkoutSettings.createCartId!=="function"){ze("[TEST] - createCartId is not provided, skipping hosted vs native test");return[2/*return*/,{redirected:false}]}
|
|
560
585
|
// No need to do anything if the test is enabled for native
|
|
561
|
-
if(t!=="hosted"){ze("[TEST] - Hosted vs native test is enabled for native, skipping");return[2/*return*/,{redirected:false}]}if(!((e=se.genericSettings)===null||e===void 0?void 0:e.hostedCheckoutUrl)){ze("[TEST] - Hosted checkout URL is not provided");return[2/*return*/,{redirected:false}]}ze('"createCartId" is provided, start building cart');return[4/*yield*/,se.checkoutSettings.createCartId()];case 1:n=a.sent();i=null;if(typeof n==="object"){r=n.cartId;i=n.shippingData||null}else{r=n}s=
|
|
586
|
+
if(t!=="hosted"){ze("[TEST] - Hosted vs native test is enabled for native, skipping");return[2/*return*/,{redirected:false}]}if(!((e=se.genericSettings)===null||e===void 0?void 0:e.hostedCheckoutUrl)){ze("[TEST] - Hosted checkout URL is not provided");return[2/*return*/,{redirected:false}]}ze('"createCartId" is provided, start building cart');return[4/*yield*/,se.checkoutSettings.createCartId()];case 1:n=a.sent();i=null;if(typeof n==="object"){r=n.cartId;i=n.shippingData||null}else{r=n}s=So();c=Le(Object.assign(Object.assign({cartId:r,checkoutSessionId:ee.checkoutSessionId||undefined,hostedCheckoutUrl:se.genericSettings.hostedCheckoutUrl,isTestMode:le(),isVariantTest:true},s),i));ze("[TEST] - Redirecting to: ".concat(c));
|
|
562
587
|
// Open new page with the cart URL
|
|
563
588
|
window.open(c,"_blank");return[2/*return*/,{redirected:true}]}}))}))};this.formatDate=function(e){if(!e){return""}
|
|
564
589
|
// get date in 24/12/2024 format (without time)
|
|
@@ -572,7 +597,7 @@ var o=new Date(e);return o.toLocaleTimeString()};this.getCurrentLocalePageEnum=f
|
|
|
572
597
|
* forcing them to retype anything. Skips when an address has already been
|
|
573
598
|
* prefilled by another path (Stripe customer profile, merchant-provided
|
|
574
599
|
* `defaultAddress`, or the BC redirect's session-storage handoff).
|
|
575
|
-
*/this.prefillBigCommerceCustomerAddresses=function(){return __awaiter(t,void 0,void 0,(function(){var e,o,t,n;return __generator(this,(function(r){switch(r.label){case 0:if(!window.Zonos.isBigCommerce){return[2/*return*/]}if(this.defaultCustomerProfileAddress.length){return[2/*return*/]}e=Array.isArray(this.defaultAddress)&&this.defaultAddress.length>0||!Array.isArray(this.defaultAddress)&&typeof this.defaultAddress==="object"&&this.defaultAddress!==null;if(e){return[2/*return*/]}return[4/*yield*/,Q()];case 1:o=r.sent();if(!o){return[2/*return*/]}return[4/*yield*/,W(o)];case 2:t=r.sent();if(!Y(t)){return[2/*return*/]}n=lo(t,{isShippable:function(e){return
|
|
600
|
+
*/this.prefillBigCommerceCustomerAddresses=function(){return __awaiter(t,void 0,void 0,(function(){var e,o,t,n;return __generator(this,(function(r){switch(r.label){case 0:if(!window.Zonos.isBigCommerce){return[2/*return*/]}if(this.defaultCustomerProfileAddress.length){return[2/*return*/]}e=Array.isArray(this.defaultAddress)&&this.defaultAddress.length>0||!Array.isArray(this.defaultAddress)&&typeof this.defaultAddress==="object"&&this.defaultAddress!==null;if(e){return[2/*return*/]}return[4/*yield*/,Q()];case 1:o=r.sent();if(!o){return[2/*return*/]}return[4/*yield*/,W(o)];case 2:t=r.sent();if(!Y(t)){return[2/*return*/]}n=lo(t,{isShippable:function(e){return vo(false,e)},selectedCountryCode:q.selectedCountryCode||undefined});if(!n.length){return[2/*return*/]}
|
|
576
601
|
// Re-check after the awaits — another prefill path may have populated state
|
|
577
602
|
// while we were waiting on the network.
|
|
578
603
|
if(this.defaultCustomerProfileAddress.length){return[2/*return*/]}this.defaultCustomerProfileAddress=n;ze("Prefilled ".concat(String(n.length)," BigCommerce customer address(es) for logged-in shopper"),"info");return[2/*return*/]}}))}))};this.getDefaultAddress=function(){
|
|
@@ -601,7 +626,7 @@ if(!o){return}var t=e.searchParams.get("zonosCheckoutSessionId");if(t){ee.checko
|
|
|
601
626
|
// merge variant test input from url to storageStore.enabledVariantTestKeys
|
|
602
627
|
var n=ee.enabledVariantTestKeys||[];
|
|
603
628
|
// override the selected variant key if it's not "hosted" since we are in hosted checkout tab
|
|
604
|
-
if(window.Zonos.isLegacyCheckout){var r=
|
|
629
|
+
if(window.Zonos.isLegacyCheckout){var r=Po("hosted_vs_native");
|
|
605
630
|
// Set selected variant key "hosted" to enabledVariantTestKeys if it's not in enabledVariantTestKeys already
|
|
606
631
|
if(!r){n.push({expiresAt:Date.now()+oe,selectedVariantKey:"hosted",testKey:"hosted_vs_native"});te(n)}else{te(n.map((function(e){if(e.testKey==="hosted_vs_native"){return Object.assign(Object.assign({},e),{selectedVariantKey:"hosted"})}return e})))}}
|
|
607
632
|
// Remove query params from the url
|
|
@@ -641,7 +666,7 @@ this.useShippingDataFromCreateCartId(o.shippingData);l.customerAuthenticationTok
|
|
|
641
666
|
// Normalize against misbehaving merchant callbacks: only accept an
|
|
642
667
|
// array of strings, drop everything else so a bad value can't crash
|
|
643
668
|
// the renderer (`.filter(...)` would throw on non-arrays).
|
|
644
|
-
l.customMessage=Array.isArray(o.customMessage)?o.customMessage.filter((function(e){return typeof e==="string"})):[]}else{t=o}window.Zonos.cartId=t;return[4/*yield*/,
|
|
669
|
+
l.customMessage=Array.isArray(o.customMessage)?o.customMessage.filter((function(e){return typeof e==="string"})):[]}else{t=o}window.Zonos.cartId=t;return[4/*yield*/,Lo(t)];case 2:n=_.sent();r=n===null||n===void 0?void 0:n.cartData;if(!r){he("Failed to build cart, please try again.");return[2/*return*/,false]}window.Zonos.cartData=r;i=ue(r),s=i.adjustments,a=i.cartItems;return[4/*yield*/,f({adjustments:s,cartItems:a})];case 3:_.sent();return[3/*break*/,12];case 4:if(!window.Zonos.cartData)return[3/*break*/,9];ze("tempCartUUID is provided, start building cart");u=(e=window.Zonos.cartData.references)===null||e===void 0?void 0:e.checkoutSessionId;if(!u)return[3/*break*/,6];ze("Setting checkout session id from cart reference","info",u);return[4/*yield*/,this.recoverCompletedOrderModificationSession(u)];case 5:d=_.sent();if(d){
|
|
645
670
|
// Recovery routes straight to the finish step, bypassing the
|
|
646
671
|
// cartStoreUpdateItems call below that would normally clear this -
|
|
647
672
|
// without it, the finish screen would spin forever (dialogLoading
|
|
@@ -665,7 +690,7 @@ _.sent();k=se.checkoutSettings,y=k.successBehavior,b=k.successRedirectUrl;this.i
|
|
|
665
690
|
// to payment, same as the Collect flow does for its own cart type. Lives
|
|
666
691
|
// here (rather than at each buildCartAndInit call site) so every caller
|
|
667
692
|
// gets it, including the forceDialogOpen/preview init path.
|
|
668
|
-
if(z()){l.step="payment"}return[2/*return*/,true]}}))}))};e.prototype.reloadCheckoutSession=function(){window.location.reload()};e.prototype.handleOrderDuplication=function(){var e=fe(localStorage.getItem("zonos--placed-order-info"));if(!e){localStorage.removeItem("zonos--placed-order-info");return}var o=Date.now()-e.time;ze("=== Existing placed order info: ".concat(e.orderId," - ").concat(this.formatDate(e.time)," - elapsed in hh:ss format: ").concat(new Date(o).toISOString().substring(11,8)),"warn");var t=parseFloat(new URLSearchParams(window.location.search).get("zonosOverrideExpiredDuplication")||"0")||
|
|
693
|
+
if(z()){l.step="payment"}return[2/*return*/,true]}}))}))};e.prototype.reloadCheckoutSession=function(){window.location.reload()};e.prototype.handleOrderDuplication=function(){var e=fe(localStorage.getItem("zonos--placed-order-info"));if(!e){localStorage.removeItem("zonos--placed-order-info");return}var o=Date.now()-e.time;ze("=== Existing placed order info: ".concat(e.orderId," - ").concat(this.formatDate(e.time)," - elapsed in hh:ss format: ").concat(new Date(o).toISOString().substring(11,8)),"warn");var t=parseFloat(new URLSearchParams(window.location.search).get("zonosOverrideExpiredDuplication")||"0")||Fo;
|
|
669
694
|
// if the order is placed within 5 minutes, confirm with the user to proceed with the order duplication
|
|
670
695
|
if(o>t){ze("=== Existing placed order info is older than ".concat(t,"ms, cleaning localStorage"),"warn");
|
|
671
696
|
// remove the placed order info if it's older than 5 minutes and do nothing.
|
|
@@ -706,7 +731,7 @@ i.forEach((function(n){var r=n.getAttribute("data-zonos-checkout-attached");if(r
|
|
|
706
731
|
// do nothing if event is already attached
|
|
707
732
|
return}ze("attached event to button ".concat(o),"info",{button:n});n.addEventListener("click",(function(o){return __awaiter(e,void 0,void 0,(function(){var e,r,i,s,a,u,d,f,h,v,m,p,g,w,z,x,S,I,T,A;return __generator(this,(function(O){switch(O.label){case 0:i=performance.now();s=t&&n.matches(t);a=n.matches("#".concat(xe));u=n.matches("#".concat(Ce))||n.matches("#".concat(_e));
|
|
708
733
|
// Allow no country set for legacy facades. Otherwise enforce it being a shippable country and not disabled.
|
|
709
|
-
if(!window.Zonos.isLegacyCheckout&&(!
|
|
734
|
+
if(!window.Zonos.isLegacyCheckout&&(!vo()||fo())&&!s&&!a&&!u){return[2/*return*/]}o.preventDefault();o.stopPropagation();ze("zonos checkout button clicked");return[4/*yield*/,this.checkStripePaymentIntentStatus({triggeredButton:o.target})];case 1:d=O.sent().shouldAllowOrder;
|
|
710
735
|
// Only allow order to proceed if payment intent is not succeeded
|
|
711
736
|
if(!d){return[2/*return*/]}
|
|
712
737
|
/**
|
|
@@ -714,7 +739,7 @@ if(!d){return[2/*return*/]}
|
|
|
714
739
|
* Move the logic below checking Stripe payment state so we don't record the load time on page load and only do so when checkout modal is actually showed up.
|
|
715
740
|
*/if(!window.Zonos.logIntervalId){
|
|
716
741
|
// log the load time of all API calls every 2 seconds. This is to track the load time of all API calls for checkout user
|
|
717
|
-
window.Zonos.logIntervalId=setInterval((function(){void
|
|
742
|
+
window.Zonos.logIntervalId=setInterval((function(){void To()}),2e3)}if(!Eo("hosted_vs_native"))return[3/*break*/,4];this.isOverlayLoading=true;return[4/*yield*/,this.registerTestHostedVsNative()];case 2:O.sent();return[4/*yield*/,this.handleHostedVsNative()];case 3:f=O.sent().redirected;this.isOverlayLoading=false;
|
|
718
743
|
// Stop the process if the user is being redirected to the hosted checkout page
|
|
719
744
|
if(f){return[2/*return*/]}O.label=4;case 4:if(!window.Zonos.isBigCommerce)return[3/*break*/,7];return[4/*yield*/,Ve()];case 5:h=O.sent().shouldBypass;if(h){ze("Bypass customer group detected, redirecting to BigCommerce native checkout","info");
|
|
720
745
|
// Carry over zonosQaUrl / zonosTestMode so the BC native
|
|
@@ -733,9 +758,9 @@ p=ne("Unable to check inventory. Please try again.");return[3/*break*/,13];case
|
|
|
733
758
|
// and "Return to cart" resets the message + closes cleanly.
|
|
734
759
|
l.inventoryCheckErrorMessage=p;c.isFetchingSession=false;this.open=false;return[2/*return*/]}O.label=14;case 14:(e=window.opener)===null||e===void 0?void 0:e.postMessage({checkoutSessionId:ee.checkoutSessionId,type:"zonos-checkout-session-update"},"*");
|
|
735
760
|
// start the timer to validate the price
|
|
736
|
-
y({isPreview:this.preview,sessionTimeout:
|
|
761
|
+
y({isPreview:this.preview,sessionTimeout:Ro});Z({event:"zonos-checkout-start",metadata:{checkoutSessionId:ee.checkoutSessionId}});w=ee.checkoutSessionId;void b({checkoutSessionId:w,eventName:"checkout_open"});return[4/*yield*/,Ue()];case 15:z=O.sent().enabled;
|
|
737
762
|
// Hide discount input if there's no active discount configured for the store
|
|
738
|
-
l.shouldHideDiscountInput=!z;this.handleOrderDuplication();if(window.Zonos.isLegacyCheckout){void
|
|
763
|
+
l.shouldHideDiscountInput=!z;this.handleOrderDuplication();if(window.Zonos.isLegacyCheckout){void Ao()}else{x=performance.now();S=x-i;void Oo({loadTime:S})}this.recordCheckoutInfo();I=!!Se();if(I){this.markTheSessionAsAbandonedCart()}return[3/*break*/,17];case 16:T=O.sent();if(T instanceof Error){A=T.message;if(A==="Cart is expired."){this.isCartExpired=true}}
|
|
739
764
|
// stop loading
|
|
740
765
|
c.isFetchingSession=false;he(T);if(this.isCartExpired){c.isFetchingSession=true;return[2/*return*/]}
|
|
741
766
|
// We want to log the error anytime we fail to create a checkout session
|
|
@@ -775,7 +800,7 @@ l.isStagingMode=pe();
|
|
|
775
800
|
if(typeof this.overrideStagingMode!=="undefined"){l.isStagingMode=this.overrideStagingMode}
|
|
776
801
|
// Start fetching BigCommerce customer group on page load so the bypass
|
|
777
802
|
// result is ready by the time checkout opens or the BC watcher fires
|
|
778
|
-
|
|
803
|
+
Ge();
|
|
779
804
|
// Warm the BigCommerce `/checkouts/settings` fetch (merchant's
|
|
780
805
|
// `guest_checkout_type`) so force-login gating resolves instantly when
|
|
781
806
|
// the shopper clicks checkout — otherwise the first checkout open
|
|
@@ -795,7 +820,7 @@ this.handleBigcommerceInternationalResumeFlag();
|
|
|
795
820
|
// the prefill itself guards against overwriting other prefill sources.
|
|
796
821
|
void this.prefillBigCommerceCustomerAddresses();
|
|
797
822
|
// check if bigcommerce, if user enters the shipping address that's in the shipping zone at bigcommerce checkout
|
|
798
|
-
|
|
823
|
+
xo({domesticRedirectedBtnSelector:Ce,onInternationalCheckoutSelected:function(){return __awaiter(o,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:this.detectedDomesticCheckoutDialogOpen=true;
|
|
799
824
|
// wait for 2 secs
|
|
800
825
|
return[4/*yield*/,new Promise((function(e){return setTimeout(e,2e3)}))];case 1:
|
|
801
826
|
// wait for 2 secs
|
|
@@ -849,7 +874,7 @@ if(i&&l.addressFormRenderType==="stripe"){void me({endpoint:"ADDRESS_NOT_READY_A
|
|
|
849
874
|
// stop interval if the step is not customer-info
|
|
850
875
|
clearInterval(e);return}if(!c.isFetchingLandedCost){if(l.landedCostData){
|
|
851
876
|
// start init paypal with the presentment currency when landed cost is fetched
|
|
852
|
-
void
|
|
877
|
+
void G({currency:l.currency});
|
|
853
878
|
// only go to next step if landed cost data is ready
|
|
854
879
|
T()}u.submitLoading=false;if(e){clearInterval(e)}}};
|
|
855
880
|
// Immediately move to the next step
|
|
@@ -873,7 +898,7 @@ return[2/*return*/]}
|
|
|
873
898
|
// Close the dialog after the user confirms to proceed with the payment in USD
|
|
874
899
|
this.payInUsdConfirmDialogOpen=false;o=A();h.label=1;case 1:h.trys.push([1,,18,19]);
|
|
875
900
|
// reset paypal error message
|
|
876
|
-
|
|
901
|
+
K.paypalErrorMessage=null;
|
|
877
902
|
// reset error state
|
|
878
903
|
c.hasPaymentError=false;this.submitLoading=true;
|
|
879
904
|
// reset inventory check message
|
|
@@ -889,12 +914,12 @@ l.inventoryCheckErrorMessage=ne("Unable to check inventory. Please try again.");
|
|
|
889
914
|
// Don't proceed to payment if there's an error message
|
|
890
915
|
if(l.inventoryCheckErrorMessage){
|
|
891
916
|
// stop the submit loading state
|
|
892
|
-
this.submitLoading=false;return[2/*return*/]}i=M();if(!(i>0))return[3/*break*/,8];return[4/*yield*/,B()];case 7:s=h.sent();if(!s.success){c.hasPaymentError=true;c.customErrorMessage=s.error||ne("Unable to apply store credit. Please try again.");this.submitLoading=false;return[2/*return*/]}h.label=8;case 8:if(!
|
|
917
|
+
this.submitLoading=false;return[2/*return*/]}i=M();if(!(i>0))return[3/*break*/,8];return[4/*yield*/,B()];case 7:s=h.sent();if(!s.success){c.hasPaymentError=true;c.customErrorMessage=s.error||ne("Unable to apply store credit. Please try again.");this.submitLoading=false;return[2/*return*/]}h.label=8;case 8:if(!P())return[3/*break*/,14];h.label=9;case 9:h.trys.push([9,12,,13]);return[4/*yield*/,E()];case 10:a=h.sent();if(!a.valid){c.hasPaymentError=true;c.customErrorMessage=a.errorMessage;this.submitLoading=false;return[2/*return*/]}return[4/*yield*/,U()];case 11:u=h.sent();if(!u.success){c.hasPaymentError=true;c.customErrorMessage=u.error||ne("Unable to place order with store credit. Please try again.");this.submitLoading=false;return[2/*return*/]}T();p();return[3/*break*/,13];case 12:d=h.sent();he(d);Z({event:"zonos-checkout-payment-fail",metadata:{checkoutSessionId:ee.checkoutSessionId}});c.hasPaymentError=true;return[3/*break*/,13];case 13:this.submitLoading=false;return[2/*return*/];case 14:h.trys.push([14,16,,17]);
|
|
893
918
|
// Order-modification payment-only sessions skip the shipping step,
|
|
894
919
|
// so cartStore.selectedLandedCost is never populated — bypass the
|
|
895
920
|
// landed-cost guard the same way zonos-collect does for its own
|
|
896
921
|
// no-shipping-step flow.
|
|
897
|
-
return[4/*yield*/,
|
|
922
|
+
return[4/*yield*/,D({noLandedCostCheck:z()})];case 15:
|
|
898
923
|
// Order-modification payment-only sessions skip the shipping step,
|
|
899
924
|
// so cartStore.selectedLandedCost is never populated — bypass the
|
|
900
925
|
// landed-cost guard the same way zonos-collect does for its own
|
|
@@ -1006,11 +1031,11 @@ var I=this.getBaseCurrencySettlementInfo();var T=function(){
|
|
|
1006
1031
|
// add timestamp to logo url if it's preview mode so browser won't cache it on the dashboard setting
|
|
1007
1032
|
var o=e.preview?"".concat(m,"?timestamp=").concat(Date.now()):m;return t("div",{class:"zonos--logo"},o&&t("img",{alt:"".concat(se.organizationName," logo"),src:o}))};var A=le();var O=function(){var o=new URLSearchParams(window.location.search);var n=o.get("zonosQaUrl");var r=o.get("zonosDebug");var i=o.get("zonosE2ETest");var s=e.overrideStagingMode||pe();return t("zonos-v-stack",null,t("div",{class:"zonos--logo-wrapper"},T(),A&&t("zonos-badge",{badgeColor:"orange",size:"small"},ne("Test mode")),s&&t("zonos-badge",{badgeColor:"red",size:"small"},ne("Staging mode")),r==="1"&&t("zonos-badge",{badgeColor:"cyan",size:"small"},"debug"),n&&t("zonos-badge",{badgeColor:"purple",size:"small"},n),i&&t("zonos-badge",{badgeColor:"gray",size:"small"},"E2E Test")),!d&&t("zonos-checkout-progress-tabs",{backgroundColor:
|
|
1008
1033
|
// only use different contrast color when the secondary color is too off with the background in mobile
|
|
1009
|
-
e.isMobile?"--zonos-elements-gray-0":null}),S.map((function(e){return t("zonos-custom-message",{icon:
|
|
1034
|
+
e.isMobile?"--zonos-elements-gray-0":null}),S.map((function(e){return t("zonos-custom-message",{icon:No,message:e.message})})))};var B=function(){if(l.checkoutSessionTimeoutShow){return t("zonos-rest-state",{class:"zonos--session-timeout",restStateSubtitle:ne("Your checkout session has expired. Please reload the page to continue."),restStateTitle:ne("Session timed out"),restStateType:"Warning"},t("zonos-button",{onClick:function(){return e.reloadCheckoutSession()},variant:"primary"},ne("Reload")))}return t("div",{class:"zonos--content",style:{"--zonos--border-radius":Ae({overrideBorderStyle:p})}},l.step!=="finish"&&l.step!=="error"&&t(n,null,t("div",{class:"zonos--left","data-theme":y,style:Be({"--zonos--primary-color":!e.isMobile?h:undefined})},!e.isMobile&&O(),l.step==="customer-info"&&t("zonos-customer-info",{continueLoading:e.submitLoading,defaultAddress:e.getDefaultAddress(),isMobile:e.isMobile,onContinueClicked:function(){return e.handleCustomerInfoContinue()},submitBtnColor:b}),l.step==="shipping"&&t("zonos-shipping",{continueLoading:e.submitLoading,isMobile:e.isMobile,onContinueClicked:function(){return e.handleShippingContinue()},submitBtnColor:b}),l.step==="payment"&&t("zonos-checkout-payment",{continueLoading:e.submitLoading,isMobile:e.isMobile,onContinueClicked:function(){return __awaiter(e,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4/*yield*/,this.handleStripePaymentContinue()];case 1:e.sent();return[2/*return*/]}}))}))},submitBtnColor:b})),t("div",{class:"zonos--right","data-theme":w},e.isMobile&&O(),t("div",{class:"zonos--right-actions"},window.Zonos.showBaseForeign&&t("zonos-currency-toggle",null),!e.isLegacyCheckout&&t("zonos-button",{class:"zonos--close-button",icon:t("zonos-icon",{"aria-label":"Close checkout dialog",content:Pe}),noBackground:true,onClick:function(){return e.closeDialogHandler()}})),t("div",{class:"flex--wrapper"},t("div",{class:"zonos--wrapper"},t("zonos-review",{collapsed:e.collapseReviewMobile,mobile:e.isMobile,onClick:function(){
|
|
1010
1035
|
// do nothing if it's not mobile
|
|
1011
1036
|
if(!e.isMobile){return}e.collapseReviewMobile=!e.collapseReviewMobile}}),t("zonos-collapse",{
|
|
1012
1037
|
// only collapsible on mobile
|
|
1013
|
-
collapsed:e.collapseReviewMobile&&e.isMobile},t("zonos-cart-items",null),e.isMobile&&t("zonos-v-stack",{spacing:16},t("zonos-cart-subtotal",{submitBtnColor:b}),t("zonos-custom-message",{class:"zonos--checkout-default-message",icon:
|
|
1038
|
+
collapsed:e.collapseReviewMobile&&e.isMobile},t("zonos-cart-items",null),e.isMobile&&t("zonos-v-stack",{spacing:16},t("zonos-cart-subtotal",{submitBtnColor:b}),t("zonos-custom-message",{class:"zonos--checkout-default-message",icon:No,message:C})))),t("zonos-cart-restricted-items",null),!e.isMobile&&t("zonos-v-stack",{spacing:16},t("zonos-cart-subtotal",null),t("zonos-custom-message",{class:"zonos--checkout-default-message",icon:No,message:C}))))),(l.step==="finish"||l.step==="error")&&t("div",{class:"zonos--done","data-theme":w},t("div",{class:"zonos--header"},T(),!e.isRedirectAfterOrder&&t("zonos-button",{class:"zonos--close-button",icon:t("zonos-icon",{"aria-label":"Close checkout dialog",content:Pe}),noBackground:true,onClick:function(){return e.handleFinishClick()},theme:w})),t("zonos-checkout-finish",{borderRadius:p,onCloseClick:function(){return e.handleFinishClick()},overrideNotification:l.step==="error"&&!!l.error?Object.assign(Object.assign({},l.error),{type:"error"}):undefined,storybookForceStatus:e.storybookPaymentStatusOverride})),t("zonos-checkout-footer",{"data-theme":w,mobile:e.isMobile,
|
|
1014
1039
|
/**
|
|
1015
1040
|
* For this component, use slot instead of passing JSX through prop of other component. Because
|
|
1016
1041
|
* the click outside event will be triggered on and targeted to whichever component that it's attached to.
|
|
@@ -1040,4 +1065,4 @@ dialogOpen:this.isCartExpired,
|
|
|
1040
1065
|
// If dialog is in open state, the message should not be null
|
|
1041
1066
|
dialogSubtitle:ne("You are being sent back to the shop to re-add items to your cart."),dialogTitle:ne("Shopping cart expired"),dialogType:"alert",
|
|
1042
1067
|
// Mark user selected confirm to close the dialog
|
|
1043
|
-
onConfirmClicked:function(){return e.handleCartExpiredDialogConfirm()}}),t("zonos-loading-overlay",{open:this.isOverlayLoading}))};Object.defineProperty(e,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{appearanceSettingsOverride:[{appearanceSettingsOverrideChanged:0},{handleAppearanceSettingsOverrideChange:0}],overrideStagingMode:[{overrideStagingModeChanged:0}],mobile:[{handleMobileChange:0}],defaultAddress:[{handleAddressChange:0}],customerProfile:[{handleCustomerProfileChange:0}],clientSecret:[{handleClientSecretChange:0}],stripeCustomerSessionClientSecret:[{handleClientSecretChange:0}],open:[{handleOpenChange:0}]}},enumerable:false,configurable:true});return e}());
|
|
1068
|
+
onConfirmClicked:function(){return e.handleCartExpiredDialogConfirm()}}),t("zonos-loading-overlay",{open:this.isOverlayLoading}))};Object.defineProperty(e,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{appearanceSettingsOverride:[{appearanceSettingsOverrideChanged:0},{handleAppearanceSettingsOverrideChange:0}],overrideStagingMode:[{overrideStagingModeChanged:0}],mobile:[{handleMobileChange:0}],defaultAddress:[{handleAddressChange:0}],customerProfile:[{handleCustomerProfileChange:0}],clientSecret:[{handleClientSecretChange:0}],stripeCustomerSessionClientSecret:[{handleClientSecretChange:0}],open:[{handleOpenChange:0}]}},enumerable:false,configurable:true});return e}());Mo.style=jo()}}}));
|