@blotoutio/providers-blotout-wallet-sdk 0.58.1 → 0.60.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/index.cjs.js +48 -17
- package/index.js +48 -17
- package/index.mjs +48 -17
- package/package.json +1 -1
package/index.cjs.js
CHANGED
@@ -36,6 +36,7 @@ new Set([
|
|
36
36
|
|
37
37
|
const customAttributes = {
|
38
38
|
'--bw-primary': { type: 'color', defaultValue: '#000000' },
|
39
|
+
'--bw-title-color': { type: 'color', defaultValue: '#000000' },
|
39
40
|
'--bw-secondary': { type: 'color', defaultValue: '#4e647f' },
|
40
41
|
'--bw-background': { type: 'color', defaultValue: '#ffffff' },
|
41
42
|
'--bw-button-foreground': { type: 'color', defaultValue: '#ffffff' },
|
@@ -310,6 +311,13 @@ const cssVars = i$4 `
|
|
310
311
|
--bw-secondary,
|
311
312
|
${r$5(customAttributes['--bw-secondary'].defaultValue)}
|
312
313
|
);
|
314
|
+
--title-color: var(
|
315
|
+
--bw-title-color,
|
316
|
+
var(
|
317
|
+
--primary,
|
318
|
+
${r$5(customAttributes['--bw-title-color'].defaultValue)}
|
319
|
+
)
|
320
|
+
);
|
313
321
|
--background: var(
|
314
322
|
--bw-background,
|
315
323
|
${r$5(customAttributes['--bw-background'].defaultValue)}
|
@@ -421,6 +429,11 @@ const circleCross = (attrs) => b `<svg class=${attrs === null || attrs === void
|
|
421
429
|
* Sets the max-age for the dismissed popup cookie
|
422
430
|
*/
|
423
431
|
const DISMISSED_COOKIE_LIFETIME = 1800;
|
432
|
+
/**
|
433
|
+
* The delay applied when the page becomes visible before fetching expired carts
|
434
|
+
* and possibly displaying the popup
|
435
|
+
*/
|
436
|
+
const POPUP_IMPRESSION_DELAY = 1000;
|
424
437
|
const formatString = (str) => {
|
425
438
|
const parts = str.split(/<\s*br\s*\/?\s*>/);
|
426
439
|
return o(parts, x `<br />`);
|
@@ -439,10 +452,9 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
439
452
|
.then(() => flipIn(this.dialog));
|
440
453
|
};
|
441
454
|
this.onSubmit = async (ev) => {
|
442
|
-
var _a;
|
443
455
|
ev.preventDefault();
|
444
456
|
ev.stopPropagation();
|
445
|
-
const email =
|
457
|
+
const email = this.email.value.trim().toLowerCase();
|
446
458
|
try {
|
447
459
|
await this.transitionTo('loading');
|
448
460
|
if (email) {
|
@@ -457,8 +469,10 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
457
469
|
if (!response.ok) {
|
458
470
|
throw new Error(`Could not save email ${response.status}: ${await response.text()}`);
|
459
471
|
}
|
472
|
+
this.email.value = '';
|
473
|
+
this.hasEmail = true;
|
460
474
|
this.dispatchEvent(new CustomEvent('blotout-wallet-email-saved', { bubbles: true }));
|
461
|
-
window.edgetag('tag', '
|
475
|
+
window.edgetag('tag', 'CartRecovery_KeepCartEmailSaved', {}, {}, { destination: this.edgeURL });
|
462
476
|
}
|
463
477
|
if (this.lastExpiredCart) {
|
464
478
|
await this.storeApi.addItems(this.lastExpiredCart.items);
|
@@ -482,7 +496,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
482
496
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
483
497
|
}
|
484
498
|
// Send the request as beacon as there could be a immediate redirect in the next step
|
485
|
-
window.edgetag('tag', '
|
499
|
+
window.edgetag('tag', 'CartRecovery_CartRestored', {}, {}, { method: 'beacon' });
|
486
500
|
// Redirect to custom path
|
487
501
|
if (this.restoreRedirect) {
|
488
502
|
try {
|
@@ -502,7 +516,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
502
516
|
await this.transitionTo('restored');
|
503
517
|
delay(2000).then(() => {
|
504
518
|
if (this.state == 'restored') {
|
505
|
-
this.hideModal();
|
519
|
+
this.hideModal('restore');
|
506
520
|
}
|
507
521
|
});
|
508
522
|
}
|
@@ -517,13 +531,16 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
517
531
|
}
|
518
532
|
this.hideModal();
|
519
533
|
this.email.value = '';
|
520
|
-
if (this.state == 'ready' || this.state == 'failed') {
|
521
|
-
this.setDismissed();
|
522
|
-
}
|
523
534
|
};
|
524
535
|
this.onWrapperClick = (ev) => {
|
525
536
|
ev.stopPropagation();
|
526
537
|
};
|
538
|
+
this.onDialogClose = () => {
|
539
|
+
const action = this.dialog.returnValue;
|
540
|
+
if (!action && (this.state == 'ready' || this.state == 'failed')) {
|
541
|
+
this.setDismissed();
|
542
|
+
}
|
543
|
+
};
|
527
544
|
this.expiredCartContent = () => {
|
528
545
|
var _a, _b, _c, _d, _e;
|
529
546
|
return x `<form
|
@@ -605,6 +622,16 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
605
622
|
this.shadowRoot.adoptedStyleSheets.push(sheet);
|
606
623
|
this.isStylesheetInjected = true;
|
607
624
|
}
|
625
|
+
if (document.hidden) {
|
626
|
+
document.addEventListener('visibilitychange', () => this.initialize(), {
|
627
|
+
once: true,
|
628
|
+
});
|
629
|
+
}
|
630
|
+
else {
|
631
|
+
this.initialize();
|
632
|
+
}
|
633
|
+
}
|
634
|
+
async initialize() {
|
608
635
|
if (!this.userId) {
|
609
636
|
logger.error('No UserId set');
|
610
637
|
return;
|
@@ -612,6 +639,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
612
639
|
if (this.isPopUpDismissed) {
|
613
640
|
return;
|
614
641
|
}
|
642
|
+
await delay(POPUP_IMPRESSION_DELAY);
|
615
643
|
fetch(this.getUrl('/cart/expired'), {
|
616
644
|
method: 'GET',
|
617
645
|
headers: this.getHeaders(),
|
@@ -625,10 +653,8 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
625
653
|
this.hasEmail = result.email;
|
626
654
|
this.lastExpiredCart = result.carts[0];
|
627
655
|
if (result.carts && result.carts.length && !this.isPopUpDismissed) {
|
628
|
-
|
629
|
-
|
630
|
-
}, 1000);
|
631
|
-
window.edgetag('tag', 'WalletCartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
|
656
|
+
this.showModal();
|
657
|
+
window.edgetag('tag', 'CartRecovery_CartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
|
632
658
|
}
|
633
659
|
})
|
634
660
|
.catch(logger.error);
|
@@ -643,8 +669,8 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
643
669
|
body: JSON.stringify({ action: 'popupShown' }),
|
644
670
|
}).catch(logger.error);
|
645
671
|
}
|
646
|
-
hideModal() {
|
647
|
-
fadeOutToBottom(this.dialog).then(() => { var _a; return (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.close(); });
|
672
|
+
hideModal(action) {
|
673
|
+
fadeOutToBottom(this.dialog).then(() => { var _a; return (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.close(action); });
|
648
674
|
this.dispatchEvent(new CustomEvent('blotout-wallet-hidden', { bubbles: true }));
|
649
675
|
}
|
650
676
|
getHeaders(json = false) {
|
@@ -665,7 +691,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
665
691
|
return url;
|
666
692
|
}
|
667
693
|
async skipCarts() {
|
668
|
-
this.hideModal();
|
694
|
+
this.hideModal('skip');
|
669
695
|
await fetch(this.getUrl('/cart/skip'), {
|
670
696
|
method: 'POST',
|
671
697
|
headers: this.getHeaders(),
|
@@ -674,7 +700,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
674
700
|
if (!response.ok) {
|
675
701
|
throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
|
676
702
|
}
|
677
|
-
window.edgetag('tag', '
|
703
|
+
window.edgetag('tag', 'CartRecovery_CartDeclined', {}, {}, { destination: this.edgeURL });
|
678
704
|
this.lastExpiredCart = undefined;
|
679
705
|
})
|
680
706
|
.catch(logger.error);
|
@@ -683,7 +709,11 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
683
709
|
if (this.isPopUpDismissed) {
|
684
710
|
return T;
|
685
711
|
}
|
686
|
-
return x ` <dialog
|
712
|
+
return x ` <dialog
|
713
|
+
class="popup"
|
714
|
+
@click=${this.onDialogClick}
|
715
|
+
@close=${this.onDialogClose}
|
716
|
+
>
|
687
717
|
<div @click=${this.onWrapperClick}>
|
688
718
|
<div
|
689
719
|
class="centered"
|
@@ -768,6 +798,7 @@ BlotoutWallet.styles = [
|
|
768
798
|
font-size: 20px;
|
769
799
|
font-weight: bold;
|
770
800
|
line-height: 30px;
|
801
|
+
color: var(--title-color);
|
771
802
|
}
|
772
803
|
|
773
804
|
.text {
|
package/index.js
CHANGED
@@ -37,6 +37,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
37
37
|
|
38
38
|
const customAttributes = {
|
39
39
|
'--bw-primary': { type: 'color', defaultValue: '#000000' },
|
40
|
+
'--bw-title-color': { type: 'color', defaultValue: '#000000' },
|
40
41
|
'--bw-secondary': { type: 'color', defaultValue: '#4e647f' },
|
41
42
|
'--bw-background': { type: 'color', defaultValue: '#ffffff' },
|
42
43
|
'--bw-button-foreground': { type: 'color', defaultValue: '#ffffff' },
|
@@ -311,6 +312,13 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
311
312
|
--bw-secondary,
|
312
313
|
${r$5(customAttributes['--bw-secondary'].defaultValue)}
|
313
314
|
);
|
315
|
+
--title-color: var(
|
316
|
+
--bw-title-color,
|
317
|
+
var(
|
318
|
+
--primary,
|
319
|
+
${r$5(customAttributes['--bw-title-color'].defaultValue)}
|
320
|
+
)
|
321
|
+
);
|
314
322
|
--background: var(
|
315
323
|
--bw-background,
|
316
324
|
${r$5(customAttributes['--bw-background'].defaultValue)}
|
@@ -422,6 +430,11 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
422
430
|
* Sets the max-age for the dismissed popup cookie
|
423
431
|
*/
|
424
432
|
const DISMISSED_COOKIE_LIFETIME = 1800;
|
433
|
+
/**
|
434
|
+
* The delay applied when the page becomes visible before fetching expired carts
|
435
|
+
* and possibly displaying the popup
|
436
|
+
*/
|
437
|
+
const POPUP_IMPRESSION_DELAY = 1000;
|
425
438
|
const formatString = (str) => {
|
426
439
|
const parts = str.split(/<\s*br\s*\/?\s*>/);
|
427
440
|
return o(parts, x `<br />`);
|
@@ -440,10 +453,9 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
440
453
|
.then(() => flipIn(this.dialog));
|
441
454
|
};
|
442
455
|
this.onSubmit = async (ev) => {
|
443
|
-
var _a;
|
444
456
|
ev.preventDefault();
|
445
457
|
ev.stopPropagation();
|
446
|
-
const email =
|
458
|
+
const email = this.email.value.trim().toLowerCase();
|
447
459
|
try {
|
448
460
|
await this.transitionTo('loading');
|
449
461
|
if (email) {
|
@@ -458,8 +470,10 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
458
470
|
if (!response.ok) {
|
459
471
|
throw new Error(`Could not save email ${response.status}: ${await response.text()}`);
|
460
472
|
}
|
473
|
+
this.email.value = '';
|
474
|
+
this.hasEmail = true;
|
461
475
|
this.dispatchEvent(new CustomEvent('blotout-wallet-email-saved', { bubbles: true }));
|
462
|
-
window.edgetag('tag', '
|
476
|
+
window.edgetag('tag', 'CartRecovery_KeepCartEmailSaved', {}, {}, { destination: this.edgeURL });
|
463
477
|
}
|
464
478
|
if (this.lastExpiredCart) {
|
465
479
|
await this.storeApi.addItems(this.lastExpiredCart.items);
|
@@ -483,7 +497,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
483
497
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
484
498
|
}
|
485
499
|
// Send the request as beacon as there could be a immediate redirect in the next step
|
486
|
-
window.edgetag('tag', '
|
500
|
+
window.edgetag('tag', 'CartRecovery_CartRestored', {}, {}, { method: 'beacon' });
|
487
501
|
// Redirect to custom path
|
488
502
|
if (this.restoreRedirect) {
|
489
503
|
try {
|
@@ -503,7 +517,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
503
517
|
await this.transitionTo('restored');
|
504
518
|
delay(2000).then(() => {
|
505
519
|
if (this.state == 'restored') {
|
506
|
-
this.hideModal();
|
520
|
+
this.hideModal('restore');
|
507
521
|
}
|
508
522
|
});
|
509
523
|
}
|
@@ -518,13 +532,16 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
518
532
|
}
|
519
533
|
this.hideModal();
|
520
534
|
this.email.value = '';
|
521
|
-
if (this.state == 'ready' || this.state == 'failed') {
|
522
|
-
this.setDismissed();
|
523
|
-
}
|
524
535
|
};
|
525
536
|
this.onWrapperClick = (ev) => {
|
526
537
|
ev.stopPropagation();
|
527
538
|
};
|
539
|
+
this.onDialogClose = () => {
|
540
|
+
const action = this.dialog.returnValue;
|
541
|
+
if (!action && (this.state == 'ready' || this.state == 'failed')) {
|
542
|
+
this.setDismissed();
|
543
|
+
}
|
544
|
+
};
|
528
545
|
this.expiredCartContent = () => {
|
529
546
|
var _a, _b, _c, _d, _e;
|
530
547
|
return x `<form
|
@@ -606,6 +623,16 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
606
623
|
this.shadowRoot.adoptedStyleSheets.push(sheet);
|
607
624
|
this.isStylesheetInjected = true;
|
608
625
|
}
|
626
|
+
if (document.hidden) {
|
627
|
+
document.addEventListener('visibilitychange', () => this.initialize(), {
|
628
|
+
once: true,
|
629
|
+
});
|
630
|
+
}
|
631
|
+
else {
|
632
|
+
this.initialize();
|
633
|
+
}
|
634
|
+
}
|
635
|
+
async initialize() {
|
609
636
|
if (!this.userId) {
|
610
637
|
logger.error('No UserId set');
|
611
638
|
return;
|
@@ -613,6 +640,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
613
640
|
if (this.isPopUpDismissed) {
|
614
641
|
return;
|
615
642
|
}
|
643
|
+
await delay(POPUP_IMPRESSION_DELAY);
|
616
644
|
fetch(this.getUrl('/cart/expired'), {
|
617
645
|
method: 'GET',
|
618
646
|
headers: this.getHeaders(),
|
@@ -626,10 +654,8 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
626
654
|
this.hasEmail = result.email;
|
627
655
|
this.lastExpiredCart = result.carts[0];
|
628
656
|
if (result.carts && result.carts.length && !this.isPopUpDismissed) {
|
629
|
-
|
630
|
-
|
631
|
-
}, 1000);
|
632
|
-
window.edgetag('tag', 'WalletCartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
|
657
|
+
this.showModal();
|
658
|
+
window.edgetag('tag', 'CartRecovery_CartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
|
633
659
|
}
|
634
660
|
})
|
635
661
|
.catch(logger.error);
|
@@ -644,8 +670,8 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
644
670
|
body: JSON.stringify({ action: 'popupShown' }),
|
645
671
|
}).catch(logger.error);
|
646
672
|
}
|
647
|
-
hideModal() {
|
648
|
-
fadeOutToBottom(this.dialog).then(() => { var _a; return (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.close(); });
|
673
|
+
hideModal(action) {
|
674
|
+
fadeOutToBottom(this.dialog).then(() => { var _a; return (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.close(action); });
|
649
675
|
this.dispatchEvent(new CustomEvent('blotout-wallet-hidden', { bubbles: true }));
|
650
676
|
}
|
651
677
|
getHeaders(json = false) {
|
@@ -666,7 +692,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
666
692
|
return url;
|
667
693
|
}
|
668
694
|
async skipCarts() {
|
669
|
-
this.hideModal();
|
695
|
+
this.hideModal('skip');
|
670
696
|
await fetch(this.getUrl('/cart/skip'), {
|
671
697
|
method: 'POST',
|
672
698
|
headers: this.getHeaders(),
|
@@ -675,7 +701,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
675
701
|
if (!response.ok) {
|
676
702
|
throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
|
677
703
|
}
|
678
|
-
window.edgetag('tag', '
|
704
|
+
window.edgetag('tag', 'CartRecovery_CartDeclined', {}, {}, { destination: this.edgeURL });
|
679
705
|
this.lastExpiredCart = undefined;
|
680
706
|
})
|
681
707
|
.catch(logger.error);
|
@@ -684,7 +710,11 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
684
710
|
if (this.isPopUpDismissed) {
|
685
711
|
return T;
|
686
712
|
}
|
687
|
-
return x ` <dialog
|
713
|
+
return x ` <dialog
|
714
|
+
class="popup"
|
715
|
+
@click=${this.onDialogClick}
|
716
|
+
@close=${this.onDialogClose}
|
717
|
+
>
|
688
718
|
<div @click=${this.onWrapperClick}>
|
689
719
|
<div
|
690
720
|
class="centered"
|
@@ -769,6 +799,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
769
799
|
font-size: 20px;
|
770
800
|
font-weight: bold;
|
771
801
|
line-height: 30px;
|
802
|
+
color: var(--title-color);
|
772
803
|
}
|
773
804
|
|
774
805
|
.text {
|
package/index.mjs
CHANGED
@@ -34,6 +34,7 @@ new Set([
|
|
34
34
|
|
35
35
|
const customAttributes = {
|
36
36
|
'--bw-primary': { type: 'color', defaultValue: '#000000' },
|
37
|
+
'--bw-title-color': { type: 'color', defaultValue: '#000000' },
|
37
38
|
'--bw-secondary': { type: 'color', defaultValue: '#4e647f' },
|
38
39
|
'--bw-background': { type: 'color', defaultValue: '#ffffff' },
|
39
40
|
'--bw-button-foreground': { type: 'color', defaultValue: '#ffffff' },
|
@@ -308,6 +309,13 @@ const cssVars = i$4 `
|
|
308
309
|
--bw-secondary,
|
309
310
|
${r$5(customAttributes['--bw-secondary'].defaultValue)}
|
310
311
|
);
|
312
|
+
--title-color: var(
|
313
|
+
--bw-title-color,
|
314
|
+
var(
|
315
|
+
--primary,
|
316
|
+
${r$5(customAttributes['--bw-title-color'].defaultValue)}
|
317
|
+
)
|
318
|
+
);
|
311
319
|
--background: var(
|
312
320
|
--bw-background,
|
313
321
|
${r$5(customAttributes['--bw-background'].defaultValue)}
|
@@ -419,6 +427,11 @@ const circleCross = (attrs) => b `<svg class=${attrs === null || attrs === void
|
|
419
427
|
* Sets the max-age for the dismissed popup cookie
|
420
428
|
*/
|
421
429
|
const DISMISSED_COOKIE_LIFETIME = 1800;
|
430
|
+
/**
|
431
|
+
* The delay applied when the page becomes visible before fetching expired carts
|
432
|
+
* and possibly displaying the popup
|
433
|
+
*/
|
434
|
+
const POPUP_IMPRESSION_DELAY = 1000;
|
422
435
|
const formatString = (str) => {
|
423
436
|
const parts = str.split(/<\s*br\s*\/?\s*>/);
|
424
437
|
return o(parts, x `<br />`);
|
@@ -437,10 +450,9 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
437
450
|
.then(() => flipIn(this.dialog));
|
438
451
|
};
|
439
452
|
this.onSubmit = async (ev) => {
|
440
|
-
var _a;
|
441
453
|
ev.preventDefault();
|
442
454
|
ev.stopPropagation();
|
443
|
-
const email =
|
455
|
+
const email = this.email.value.trim().toLowerCase();
|
444
456
|
try {
|
445
457
|
await this.transitionTo('loading');
|
446
458
|
if (email) {
|
@@ -455,8 +467,10 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
455
467
|
if (!response.ok) {
|
456
468
|
throw new Error(`Could not save email ${response.status}: ${await response.text()}`);
|
457
469
|
}
|
470
|
+
this.email.value = '';
|
471
|
+
this.hasEmail = true;
|
458
472
|
this.dispatchEvent(new CustomEvent('blotout-wallet-email-saved', { bubbles: true }));
|
459
|
-
window.edgetag('tag', '
|
473
|
+
window.edgetag('tag', 'CartRecovery_KeepCartEmailSaved', {}, {}, { destination: this.edgeURL });
|
460
474
|
}
|
461
475
|
if (this.lastExpiredCart) {
|
462
476
|
await this.storeApi.addItems(this.lastExpiredCart.items);
|
@@ -480,7 +494,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
480
494
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
481
495
|
}
|
482
496
|
// Send the request as beacon as there could be a immediate redirect in the next step
|
483
|
-
window.edgetag('tag', '
|
497
|
+
window.edgetag('tag', 'CartRecovery_CartRestored', {}, {}, { method: 'beacon' });
|
484
498
|
// Redirect to custom path
|
485
499
|
if (this.restoreRedirect) {
|
486
500
|
try {
|
@@ -500,7 +514,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
500
514
|
await this.transitionTo('restored');
|
501
515
|
delay(2000).then(() => {
|
502
516
|
if (this.state == 'restored') {
|
503
|
-
this.hideModal();
|
517
|
+
this.hideModal('restore');
|
504
518
|
}
|
505
519
|
});
|
506
520
|
}
|
@@ -515,13 +529,16 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
515
529
|
}
|
516
530
|
this.hideModal();
|
517
531
|
this.email.value = '';
|
518
|
-
if (this.state == 'ready' || this.state == 'failed') {
|
519
|
-
this.setDismissed();
|
520
|
-
}
|
521
532
|
};
|
522
533
|
this.onWrapperClick = (ev) => {
|
523
534
|
ev.stopPropagation();
|
524
535
|
};
|
536
|
+
this.onDialogClose = () => {
|
537
|
+
const action = this.dialog.returnValue;
|
538
|
+
if (!action && (this.state == 'ready' || this.state == 'failed')) {
|
539
|
+
this.setDismissed();
|
540
|
+
}
|
541
|
+
};
|
525
542
|
this.expiredCartContent = () => {
|
526
543
|
var _a, _b, _c, _d, _e;
|
527
544
|
return x `<form
|
@@ -603,6 +620,16 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
603
620
|
this.shadowRoot.adoptedStyleSheets.push(sheet);
|
604
621
|
this.isStylesheetInjected = true;
|
605
622
|
}
|
623
|
+
if (document.hidden) {
|
624
|
+
document.addEventListener('visibilitychange', () => this.initialize(), {
|
625
|
+
once: true,
|
626
|
+
});
|
627
|
+
}
|
628
|
+
else {
|
629
|
+
this.initialize();
|
630
|
+
}
|
631
|
+
}
|
632
|
+
async initialize() {
|
606
633
|
if (!this.userId) {
|
607
634
|
logger.error('No UserId set');
|
608
635
|
return;
|
@@ -610,6 +637,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
610
637
|
if (this.isPopUpDismissed) {
|
611
638
|
return;
|
612
639
|
}
|
640
|
+
await delay(POPUP_IMPRESSION_DELAY);
|
613
641
|
fetch(this.getUrl('/cart/expired'), {
|
614
642
|
method: 'GET',
|
615
643
|
headers: this.getHeaders(),
|
@@ -623,10 +651,8 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
623
651
|
this.hasEmail = result.email;
|
624
652
|
this.lastExpiredCart = result.carts[0];
|
625
653
|
if (result.carts && result.carts.length && !this.isPopUpDismissed) {
|
626
|
-
|
627
|
-
|
628
|
-
}, 1000);
|
629
|
-
window.edgetag('tag', 'WalletCartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
|
654
|
+
this.showModal();
|
655
|
+
window.edgetag('tag', 'CartRecovery_CartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
|
630
656
|
}
|
631
657
|
})
|
632
658
|
.catch(logger.error);
|
@@ -641,8 +667,8 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
641
667
|
body: JSON.stringify({ action: 'popupShown' }),
|
642
668
|
}).catch(logger.error);
|
643
669
|
}
|
644
|
-
hideModal() {
|
645
|
-
fadeOutToBottom(this.dialog).then(() => { var _a; return (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.close(); });
|
670
|
+
hideModal(action) {
|
671
|
+
fadeOutToBottom(this.dialog).then(() => { var _a; return (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.close(action); });
|
646
672
|
this.dispatchEvent(new CustomEvent('blotout-wallet-hidden', { bubbles: true }));
|
647
673
|
}
|
648
674
|
getHeaders(json = false) {
|
@@ -663,7 +689,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
663
689
|
return url;
|
664
690
|
}
|
665
691
|
async skipCarts() {
|
666
|
-
this.hideModal();
|
692
|
+
this.hideModal('skip');
|
667
693
|
await fetch(this.getUrl('/cart/skip'), {
|
668
694
|
method: 'POST',
|
669
695
|
headers: this.getHeaders(),
|
@@ -672,7 +698,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
672
698
|
if (!response.ok) {
|
673
699
|
throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
|
674
700
|
}
|
675
|
-
window.edgetag('tag', '
|
701
|
+
window.edgetag('tag', 'CartRecovery_CartDeclined', {}, {}, { destination: this.edgeURL });
|
676
702
|
this.lastExpiredCart = undefined;
|
677
703
|
})
|
678
704
|
.catch(logger.error);
|
@@ -681,7 +707,11 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
681
707
|
if (this.isPopUpDismissed) {
|
682
708
|
return T;
|
683
709
|
}
|
684
|
-
return x ` <dialog
|
710
|
+
return x ` <dialog
|
711
|
+
class="popup"
|
712
|
+
@click=${this.onDialogClick}
|
713
|
+
@close=${this.onDialogClose}
|
714
|
+
>
|
685
715
|
<div @click=${this.onWrapperClick}>
|
686
716
|
<div
|
687
717
|
class="centered"
|
@@ -766,6 +796,7 @@ BlotoutWallet.styles = [
|
|
766
796
|
font-size: 20px;
|
767
797
|
font-weight: bold;
|
768
798
|
line-height: 30px;
|
799
|
+
color: var(--title-color);
|
769
800
|
}
|
770
801
|
|
771
802
|
.text {
|