@braze/web-sdk 4.10.0 → 4.10.1
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.d.ts +9 -9
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +1 -8
- package/shared-lib/encoding-utils.js +1 -12
- package/shared-lib/event-types.js +1 -34
- package/shared-lib/guid.js +1 -10
- package/shared-lib/indexed-db-adapter.js +1 -352
- package/shared-lib/logger.js +1 -38
- package/shared-lib/supported-options.js +1 -27
- package/shared-lib/types.js +1 -1
- package/src/Card/card-manager-factory.js +1 -14
- package/src/Card/card-manager.js +1 -78
- package/src/Card/display/card-display.js +1 -138
- package/src/Card/index.js +1 -6
- package/src/Card/log-card-click.js +1 -11
- package/src/Card/log-card-dismissal.js +1 -11
- package/src/Card/log-card-impressions.js +1 -13
- package/src/Card/log-content-card-click.js +1 -4
- package/src/Card/log-content-card-impressions.js +1 -4
- package/src/Card/models/banner.js +1 -31
- package/src/Card/models/captioned-image.js +1 -33
- package/src/Card/models/card.js +1 -196
- package/src/Card/models/classic-card.js +1 -32
- package/src/Card/models/control-card.js +1 -23
- package/src/Card/models/image-only.js +1 -32
- package/src/Card/models/index.js +1 -6
- package/src/Card/types.js +1 -1
- package/src/Card/util/card-factory.js +1 -104
- package/src/ContentCards/content-cards-provider-factory.js +1 -20
- package/src/ContentCards/content-cards-provider.js +1 -391
- package/src/ContentCards/content-cards.js +1 -24
- package/src/ContentCards/get-cached-content-cards.js +1 -5
- package/src/ContentCards/index.js +1 -8
- package/src/ContentCards/log-content-cards-displayed.js +1 -5
- package/src/ContentCards/request-content-cards-refresh.js +1 -5
- package/src/ContentCards/subscribe-to-content-cards-updates.js +1 -17
- package/src/ContentCards/types.js +1 -1
- package/src/ContentCards/ui/hide-content-cards.js +1 -8
- package/src/ContentCards/ui/show-content-cards.js +1 -77
- package/src/ContentCards/ui/toggle-content-cards.js +1 -8
- package/src/Core/add-sdk-metadata.js +1 -26
- package/src/Core/braze-sdk-metadata.js +1 -10
- package/src/Core/change-user.js +1 -17
- package/src/Core/destroy.js +1 -5
- package/src/Core/device-properties.js +1 -9
- package/src/Core/disable-sdk.js +1 -15
- package/src/Core/enable-sdk.js +1 -11
- package/src/Core/get-device-id.js +1 -13
- package/src/Core/get-user.js +1 -4
- package/src/Core/handle-braze-action.js +1 -87
- package/src/Core/index.js +1 -23
- package/src/Core/initialize.js +1 -4
- package/src/Core/is-disabled.js +1 -4
- package/src/Core/log-custom-event.js +1 -38
- package/src/Core/log-purchase.js +1 -245
- package/src/Core/open-session.js +1 -25
- package/src/Core/remove-all-subscriptions.js +1 -4
- package/src/Core/remove-subscription.js +1 -4
- package/src/Core/request-immediate-data-flush.js +1 -6
- package/src/Core/set-logger.js +1 -4
- package/src/Core/set-sdk-authentication-signature.js +1 -8
- package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -6
- package/src/Core/toggle-logging.js +1 -4
- package/src/Core/types.js +1 -1
- package/src/Core/wipe-data.js +1 -16
- package/src/FeatureFlags/feature-flag-factory.js +1 -24
- package/src/FeatureFlags/feature-flag.js +1 -64
- package/src/FeatureFlags/feature-flags-provider-factory.js +1 -19
- package/src/FeatureFlags/feature-flags-provider.js +1 -145
- package/src/FeatureFlags/get-all-feature-flags.js +1 -12
- package/src/FeatureFlags/get-feature-flag.js +1 -12
- package/src/FeatureFlags/index.js +1 -6
- package/src/FeatureFlags/log-feature-flag-impression.js +1 -23
- package/src/FeatureFlags/refresh-feature-flags.js +1 -9
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -9
- package/src/FeatureFlags/types.js +1 -1
- package/src/Feed/feed-provider-factory.js +1 -18
- package/src/Feed/feed-provider.js +1 -90
- package/src/Feed/feed.js +1 -20
- package/src/Feed/get-cached-feed.js +1 -5
- package/src/Feed/index.js +1 -8
- package/src/Feed/log-feed-displayed.js +1 -7
- package/src/Feed/request-feed-refresh.js +1 -5
- package/src/Feed/subscribe-to-feed-updates.js +1 -5
- package/src/Feed/types.js +1 -1
- package/src/Feed/ui/hide-feed.js +1 -7
- package/src/Feed/ui/show-feed.js +1 -96
- package/src/Feed/ui/toggle-feed.js +1 -8
- package/src/InAppMessage/defer-in-app-message.js +1 -13
- package/src/InAppMessage/display/get-animation-effect.js +1 -19
- package/src/InAppMessage/display/html-message-to-html.js +1 -244
- package/src/InAppMessage/display/in-app-message-to-html.js +1 -188
- package/src/InAppMessage/display/modal-utils.js +1 -73
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -5
- package/src/InAppMessage/in-app-message-factory.js +1 -166
- package/src/InAppMessage/in-app-message-manager-factory.js +1 -16
- package/src/InAppMessage/in-app-message-manager.js +1 -248
- package/src/InAppMessage/index.js +1 -16
- package/src/InAppMessage/log-in-app-message-button-click.js +1 -27
- package/src/InAppMessage/log-in-app-message-click.js +1 -19
- package/src/InAppMessage/log-in-app-message-html-click.js +1 -23
- package/src/InAppMessage/log-in-app-message-impression.js +1 -13
- package/src/InAppMessage/models/control-message.js +1 -11
- package/src/InAppMessage/models/full-screen-message.js +1 -105
- package/src/InAppMessage/models/html-message.js +1 -68
- package/src/InAppMessage/models/in-app-message-button.js +1 -47
- package/src/InAppMessage/models/in-app-message.js +1 -382
- package/src/InAppMessage/models/modal-message.js +1 -101
- package/src/InAppMessage/models/slide-up-message.js +1 -84
- package/src/InAppMessage/models/templated-in-app-message.js +1 -19
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -10
- package/src/InAppMessage/types.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +1 -15
- package/src/InAppMessage/ui/show-in-app-message.js +1 -181
- package/src/InAppMessage/utils/in-app-message-utils.js +1 -1
- package/src/Push/index.js +1 -5
- package/src/Push/is-push-blocked.js +1 -5
- package/src/Push/is-push-permission-granted.js +1 -5
- package/src/Push/is-push-supported.js +1 -5
- package/src/Push/push-manager-factory.js +1 -30
- package/src/Push/push-manager.js +1 -387
- package/src/Push/request-push-permission.js +1 -9
- package/src/Push/types.js +1 -1
- package/src/Push/unregister-push.js +1 -5
- package/src/Push/utils/push-utils.js +1 -36
- package/src/User/index.js +1 -1
- package/src/User/types.js +1 -1
- package/src/User/user-manager.js +1 -73
- package/src/User/user.js +1 -302
- package/src/common/base-feed.js +1 -28
- package/src/common/base-provider.js +1 -6
- package/src/common/constants.js +1 -14
- package/src/common/event-logger.js +1 -31
- package/src/common/feed-display.js +1 -210
- package/src/common/translations.js +1 -148
- package/src/common/types.js +1 -1
- package/src/index.js +1 -9
- package/src/l10n/l10n-manager-factory.js +1 -22
- package/src/l10n/l10n-manager.js +1 -25
- package/src/l10n/types.js +1 -1
- package/src/managers/auth-manager.js +1 -51
- package/src/managers/braze-instance.js +1 -331
- package/src/managers/device-manager.js +1 -85
- package/src/managers/network-manager.js +1 -256
- package/src/managers/server-config-manager.js +1 -108
- package/src/managers/session-manager.js +1 -75
- package/src/managers/storage-manager-factory.js +1 -42
- package/src/managers/storage-manager.js +1 -419
- package/src/managers/subscription-manager.js +1 -28
- package/src/managers/types.js +1 -1
- package/src/models/backend-errors.js +1 -8
- package/src/models/braze-event.js +1 -47
- package/src/models/braze-sdk-metadata.js +1 -10
- package/src/models/device.js +1 -18
- package/src/models/identifier.js +1 -19
- package/src/models/push-token.js +1 -27
- package/src/models/request-result.js +1 -8
- package/src/models/server-config.js +1 -48
- package/src/models/types.js +1 -1
- package/src/request-controller.js +1 -311
- package/src/triggers/models/custom-event-data.js +1 -14
- package/src/triggers/models/custom-event-property-data.js +1 -21
- package/src/triggers/models/filter-set.js +1 -55
- package/src/triggers/models/filter.js +1 -102
- package/src/triggers/models/in-app-message-click-data.js +1 -25
- package/src/triggers/models/purchase-data.js +1 -14
- package/src/triggers/models/purchase-property-data.js +1 -21
- package/src/triggers/models/push-click-data.js +1 -15
- package/src/triggers/models/trigger-condition.js +1 -105
- package/src/triggers/models/trigger-events.js +1 -8
- package/src/triggers/models/trigger.js +1 -122
- package/src/triggers/triggers-provider-factory.js +1 -34
- package/src/triggers/triggers-provider.js +1 -326
- package/src/triggers/types.js +1 -1
- package/src/types.js +1 -1
- package/src/ui/js/attach-css.js +1 -13
- package/src/ui/js/feed-css.js +1 -12
- package/src/ui/js/iam-css.js +1 -12
- package/src/ui/js/index.js +1 -3
- package/src/ui/js/load-font-awesome.js +1 -13
- package/src/util/base-device-parser.js +1 -14
- package/src/util/braze-actions.js +1 -84
- package/src/util/browser-detector.js +1 -84
- package/src/util/client-hints-parser.js +1 -66
- package/src/util/code-utils.js +1 -100
- package/src/util/color-utils.js +1 -29
- package/src/util/component-utils.js +1 -26
- package/src/util/date-utils.js +1 -28
- package/src/util/deprecation-utils.js +1 -5
- package/src/util/device-constants.js +1 -14
- package/src/util/dom-utils.js +1 -91
- package/src/util/error-utils.js +1 -2
- package/src/util/key-codes.js +1 -1
- package/src/util/math.js +1 -5
- package/src/util/net.js +1 -71
- package/src/util/request-header-utils.js +1 -46
- package/src/util/string-utils.js +1 -22
- package/src/util/types.js +1 -1
- package/src/util/url-utils.js +1 -20
- package/src/util/user-agent-parser.js +1 -85
- package/src/util/validation-utils.js +1 -217
- package/src/util/window-utils.js +1 -34
package/src/Feed/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
package/src/Feed/ui/hide-feed.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import e from
|
|
2
|
-
import { destroyFeedHtml as k } from "../../common/feed-display.js";
|
|
3
|
-
export function destroyFeed() {
|
|
4
|
-
if (!e.rr()) return;
|
|
5
|
-
const o = document.querySelectorAll(".ab-feed");
|
|
6
|
-
for (let e = 0; e < o.length; e++) k(o[e]);
|
|
7
|
-
}
|
|
1
|
+
import e from"../../managers/braze-instance.js";import{destroyFeedHtml as k}from"../../common/feed-display.js";export function destroyFeed(){if(!e.rr())return;const o=document.querySelectorAll(".ab-feed");for(let e=0;e<o.length;e++)k(o[e])}
|
package/src/Feed/ui/show-feed.js
CHANGED
|
@@ -1,96 +1 @@
|
|
|
1
|
-
import e,
|
|
2
|
-
import {
|
|
3
|
-
destroyFeedHtml as k,
|
|
4
|
-
detectFeedImpressions as q,
|
|
5
|
-
feedToHtml as I,
|
|
6
|
-
LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as M,
|
|
7
|
-
refreshFeed as $,
|
|
8
|
-
registerFeedSubscriptionId as A,
|
|
9
|
-
updateFeedCards as B,
|
|
10
|
-
} from "../../common/feed-display.js";
|
|
11
|
-
import { Feed, logFeedDisplayed, subscribeToFeedUpdates } from "../index.js";
|
|
12
|
-
import ie from "../feed-provider-factory.js";
|
|
13
|
-
import { intersection as te } from "../../util/code-utils.js";
|
|
14
|
-
import { setCardHeight as F } from "../../Card/display/card-display.js";
|
|
15
|
-
import { setupFeedUI as G } from "../../ui/js/index.js";
|
|
16
|
-
import r from "../../../shared-lib/braze-shared-lib.js";
|
|
17
|
-
export function showFeed(t, n, o) {
|
|
18
|
-
if (!e.rr()) return;
|
|
19
|
-
G();
|
|
20
|
-
const s = (e, t) => {
|
|
21
|
-
if (null == t) return e;
|
|
22
|
-
const n = [];
|
|
23
|
-
for (let e = 0; e < t.length; e++) n.push(t[e].toLowerCase());
|
|
24
|
-
const o = [];
|
|
25
|
-
for (let t = 0; t < e.length; t++) {
|
|
26
|
-
const r = [],
|
|
27
|
-
s = e[t].categories || [];
|
|
28
|
-
for (let e = 0; e < s.length; e++) r.push(s[e].toLowerCase());
|
|
29
|
-
te(r, n).length > 0 && o.push(e[t]);
|
|
30
|
-
}
|
|
31
|
-
return o;
|
|
32
|
-
},
|
|
33
|
-
i = e.nn(L.tn) || e.nn(L.en) || !1;
|
|
34
|
-
let l = !1;
|
|
35
|
-
null == t && ((t = document.body), (l = !0));
|
|
36
|
-
let a,
|
|
37
|
-
f = !1;
|
|
38
|
-
null == n
|
|
39
|
-
? ((a = ie.er().Hi()),
|
|
40
|
-
B(a, s(a.cards, o), a.lastUpdated, null, i),
|
|
41
|
-
(f = !0))
|
|
42
|
-
: (a = new Feed(s(n, o), new Date()));
|
|
43
|
-
const u = I(a, i, l);
|
|
44
|
-
if (f) {
|
|
45
|
-
(null == a.lastUpdated ||
|
|
46
|
-
new Date().valueOf() - a.lastUpdated.valueOf() > Feed.mr) &&
|
|
47
|
-
(r.j.info(
|
|
48
|
-
`Cached feed was older than max TTL of ${Feed.mr} ms, requesting an update from the server.`,
|
|
49
|
-
),
|
|
50
|
-
$(a, u));
|
|
51
|
-
const e = new Date().valueOf(),
|
|
52
|
-
t = subscribeToFeedUpdates(function (t) {
|
|
53
|
-
const n = u.querySelectorAll(".ab-refresh-button")[0];
|
|
54
|
-
if (null != n) {
|
|
55
|
-
let t = 500;
|
|
56
|
-
t -= new Date().valueOf() - e;
|
|
57
|
-
const o = u.getAttribute(M);
|
|
58
|
-
if (o) {
|
|
59
|
-
const e = parseInt(o);
|
|
60
|
-
isNaN(e) || (t -= new Date().valueOf() - e);
|
|
61
|
-
}
|
|
62
|
-
setTimeout(
|
|
63
|
-
function () {
|
|
64
|
-
n.className = n.className.replace(/fa-spin/g, "");
|
|
65
|
-
},
|
|
66
|
-
Math.max(t, 0),
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
B(a, s(t.cards, o), t.lastUpdated, u, i);
|
|
70
|
-
});
|
|
71
|
-
A(t, u);
|
|
72
|
-
}
|
|
73
|
-
const d = (e) => {
|
|
74
|
-
const t = e.querySelectorAll(".ab-feed");
|
|
75
|
-
let n = null;
|
|
76
|
-
for (let o = 0; o < t.length; o++) t[o].parentNode === e && (n = t[o]);
|
|
77
|
-
null != n
|
|
78
|
-
? (k(n), n.parentNode && n.parentNode.replaceChild(u, n))
|
|
79
|
-
: e.appendChild(u),
|
|
80
|
-
setTimeout(function () {
|
|
81
|
-
u.className = u.className.replace("ab-hide", "ab-show");
|
|
82
|
-
}, 0),
|
|
83
|
-
l && u.focus(),
|
|
84
|
-
logFeedDisplayed(),
|
|
85
|
-
q(a, u),
|
|
86
|
-
a && F(a.cards, e);
|
|
87
|
-
};
|
|
88
|
-
var m;
|
|
89
|
-
null != t
|
|
90
|
-
? d(t)
|
|
91
|
-
: (window.onload =
|
|
92
|
-
((m = window.onload),
|
|
93
|
-
function () {
|
|
94
|
-
"function" == typeof m && m(new Event("oldLoad")), d(document.body);
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
1
|
+
import e,{OPTIONS as L}from"../../managers/braze-instance.js";import{destroyFeedHtml as k,detectFeedImpressions as q,feedToHtml as I,LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as M,refreshFeed as $,registerFeedSubscriptionId as A,updateFeedCards as B}from"../../common/feed-display.js";import{Feed,logFeedDisplayed,subscribeToFeedUpdates}from"../index.js";import ie from"../feed-provider-factory.js";import{intersection as te}from"../../util/code-utils.js";import{setCardHeight as F}from"../../Card/display/card-display.js";import{setupFeedUI as G}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";export function showFeed(t,n,o){if(!e.rr())return;G();const s=(e,t)=>{if(null==t)return e;const n=[];for(let e=0;e<t.length;e++)n.push(t[e].toLowerCase());const o=[];for(let t=0;t<e.length;t++){const r=[],s=e[t].categories||[];for(let e=0;e<s.length;e++)r.push(s[e].toLowerCase());te(r,n).length>0&&o.push(e[t])}return o},i=e.nn(L.tn)||e.nn(L.en)||!1;let l=!1;null==t&&(t=document.body,l=!0);let a,f=!1;null==n?(a=ie.er().Hi(),B(a,s(a.cards,o),a.lastUpdated,null,i),f=!0):a=new Feed(s(n,o),new Date);const u=I(a,i,l);if(f){(null==a.lastUpdated||(new Date).valueOf()-a.lastUpdated.valueOf()>Feed.mr)&&(r.j.info(`Cached feed was older than max TTL of ${Feed.mr} ms, requesting an update from the server.`),$(a,u));const e=(new Date).valueOf(),t=subscribeToFeedUpdates((function(t){const n=u.querySelectorAll(".ab-refresh-button")[0];if(null!=n){let t=500;t-=(new Date).valueOf()-e;const o=u.getAttribute(M);if(o){const e=parseInt(o);isNaN(e)||(t-=(new Date).valueOf()-e)}setTimeout((function(){n.className=n.className.replace(/fa-spin/g,"")}),Math.max(t,0))}B(a,s(t.cards,o),t.lastUpdated,u,i)}));A(t,u)}const d=e=>{const t=e.querySelectorAll(".ab-feed");let n=null;for(let o=0;o<t.length;o++)t[o].parentNode===e&&(n=t[o]);null!=n?(k(n),n.parentNode&&n.parentNode.replaceChild(u,n)):e.appendChild(u),setTimeout((function(){u.className=u.className.replace("ab-hide","ab-show")}),0),l&&u.focus(),logFeedDisplayed(),q(a,u),a&&F(a.cards,e)};var m;null!=t?d(t):window.onload=(m=window.onload,function(){"function"==typeof m&&m(new Event("oldLoad")),d(document.body)})}
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import e from
|
|
2
|
-
import { destroyFeed, showFeed } from "../index.js";
|
|
3
|
-
export function toggleFeed(o, n, r) {
|
|
4
|
-
e.rr() &&
|
|
5
|
-
(document.querySelectorAll(".ab-feed").length > 0
|
|
6
|
-
? destroyFeed()
|
|
7
|
-
: showFeed(o, n, r));
|
|
8
|
-
}
|
|
1
|
+
import e from"../../managers/braze-instance.js";import{destroyFeed,showFeed}from"../index.js";export function toggleFeed(o,n,r){e.rr()&&(document.querySelectorAll(".ab-feed").length>0?destroyFeed():showFeed(o,n,r))}
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
import InAppMessage from "./models/in-app-message.js";
|
|
2
|
-
import e from "../managers/braze-instance.js";
|
|
3
|
-
import ControlMessage from "./models/control-message.js";
|
|
4
|
-
import r from "../../shared-lib/braze-shared-lib.js";
|
|
5
|
-
import se from "./in-app-message-manager-factory.js";
|
|
6
|
-
export function deferInAppMessage(s) {
|
|
7
|
-
if (e.rr())
|
|
8
|
-
return s instanceof ControlMessage
|
|
9
|
-
? (r.j.info("Not deferring since this is a ControlMessage."), !1)
|
|
10
|
-
: s instanceof InAppMessage
|
|
11
|
-
? se.m().he(s)
|
|
12
|
-
: (r.j.info("Not an instance of InAppMessage, ignoring."), !1);
|
|
13
|
-
}
|
|
1
|
+
import InAppMessage from"./models/in-app-message.js";import e from"../managers/braze-instance.js";import ControlMessage from"./models/control-message.js";import r from"../../shared-lib/braze-shared-lib.js";import se from"./in-app-message-manager-factory.js";export function deferInAppMessage(s){if(e.rr())return s instanceof ControlMessage?(r.j.info("Not deferring since this is a ControlMessage."),!1):s instanceof InAppMessage?se.m().he(s):(r.j.info("Not an instance of InAppMessage, ignoring."),!1)}
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
import FullScreenMessage from
|
|
2
|
-
import HtmlMessage from "../models/html-message.js";
|
|
3
|
-
import ModalMessage from "../models/modal-message.js";
|
|
4
|
-
import SlideUpMessage from "../models/slide-up-message.js";
|
|
5
|
-
export default function me(e) {
|
|
6
|
-
let s = "";
|
|
7
|
-
return (
|
|
8
|
-
e.animateIn && (s += " ab-animate-in"),
|
|
9
|
-
e.animateOut && (s += " ab-animate-out"),
|
|
10
|
-
e instanceof FullScreenMessage
|
|
11
|
-
? (s += " ab-effect-fullscreen")
|
|
12
|
-
: e instanceof HtmlMessage
|
|
13
|
-
? (s += " ab-effect-html")
|
|
14
|
-
: e instanceof ModalMessage
|
|
15
|
-
? (s += " ab-effect-modal")
|
|
16
|
-
: e instanceof SlideUpMessage && (s += " ab-effect-slide"),
|
|
17
|
-
s
|
|
18
|
-
);
|
|
19
|
-
}
|
|
1
|
+
import FullScreenMessage from"../models/full-screen-message.js";import HtmlMessage from"../models/html-message.js";import ModalMessage from"../models/modal-message.js";import SlideUpMessage from"../models/slide-up-message.js";export default function me(e){let s="";return e.animateIn&&(s+=" ab-animate-in"),e.animateOut&&(s+=" ab-animate-out"),e instanceof FullScreenMessage?s+=" ab-effect-fullscreen":e instanceof HtmlMessage?s+=" ab-effect-html":e instanceof ModalMessage?s+=" ab-effect-modal":e instanceof SlideUpMessage&&(s+=" ab-effect-slide"),s}
|
|
@@ -1,244 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import V from "../../util/browser-detector.js";
|
|
3
|
-
import { logInAppMessageHtmlClick } from "../log-in-app-message-html-click.js";
|
|
4
|
-
import { getUser as ee } from "../../Core/get-user.js";
|
|
5
|
-
import { InAppMessage } from "../index.js";
|
|
6
|
-
import { keys as oo } from "../../util/code-utils.js";
|
|
7
|
-
import { OperatingSystems as W } from "../../util/device-constants.js";
|
|
8
|
-
import { parseQueryStringKeyValues as ct } from "../../util/url-utils.js";
|
|
9
|
-
import { WindowUtils as Z } from "../../util/window-utils.js";
|
|
10
|
-
import e from "../../managers/braze-instance.js";
|
|
11
|
-
import r from "../../../shared-lib/braze-shared-lib.js";
|
|
12
|
-
import { BRAZE_MUST_BE_INITIALIZED_ERROR as P } from "../../common/constants.js";
|
|
13
|
-
export default function at(t, o, n, s, i, u) {
|
|
14
|
-
const c = document.createElement("iframe");
|
|
15
|
-
c.setAttribute("title", "Modal Message"),
|
|
16
|
-
i && (c.style.zIndex = (i + 1).toString());
|
|
17
|
-
const a = (e) => {
|
|
18
|
-
const o = e.getAttribute("href"),
|
|
19
|
-
r = e.onclick;
|
|
20
|
-
return (n) => {
|
|
21
|
-
if (null != r && "function" == typeof r && !1 === r.bind(e)(n)) return;
|
|
22
|
-
let i = ct(o).abButtonId;
|
|
23
|
-
if (
|
|
24
|
-
((null != i && "" !== i) || (i = e.getAttribute("id") || void 0),
|
|
25
|
-
null != o && "" !== o && 0 !== o.indexOf("#"))
|
|
26
|
-
) {
|
|
27
|
-
const r =
|
|
28
|
-
"blank" ===
|
|
29
|
-
(e.getAttribute("target") || "").toLowerCase().replace("_", ""),
|
|
30
|
-
u = s || t.openTarget === InAppMessage.OpenTarget.BLANK || r,
|
|
31
|
-
a = () => {
|
|
32
|
-
logInAppMessageHtmlClick(t, i, o), Z.openUri(o, u, n);
|
|
33
|
-
};
|
|
34
|
-
u ? a() : t.ye(c, a);
|
|
35
|
-
} else logInAppMessageHtmlClick(t, i, o || void 0);
|
|
36
|
-
return n.stopPropagation(), !1;
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
m = (t, e, o) => {
|
|
40
|
-
const r = `([\\w]+)\\s*=\\s*document.createElement\\(['"]${o}['"]\\)`,
|
|
41
|
-
n = t.match(new RegExp(r));
|
|
42
|
-
if (n) {
|
|
43
|
-
const o = `${n[1]}.setAttribute("nonce", "${e}")`;
|
|
44
|
-
return `${t.slice(0, n.index + n[0].length)};${o};${t.slice(
|
|
45
|
-
n.index + n[0].length,
|
|
46
|
-
)}`;
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
};
|
|
50
|
-
if (
|
|
51
|
-
((c.onload = () => {
|
|
52
|
-
let s = null;
|
|
53
|
-
if (null != u) {
|
|
54
|
-
(s = document.createElement("html")), (s.innerHTML = t.message || "");
|
|
55
|
-
const e = s.getElementsByTagName("style");
|
|
56
|
-
for (let t = 0; t < e.length; t++) e[t].setAttribute("nonce", u);
|
|
57
|
-
const o = s.getElementsByTagName("script");
|
|
58
|
-
for (let t = 0; t < o.length; t++) {
|
|
59
|
-
o[t].setAttribute("nonce", u),
|
|
60
|
-
(o[t].innerHTML = o[t].innerHTML.replace(
|
|
61
|
-
/<style>/g,
|
|
62
|
-
`<style nonce='${u}'>`,
|
|
63
|
-
));
|
|
64
|
-
const e = m(o[t].innerHTML, u, "script");
|
|
65
|
-
e && (o[t].innerHTML = e);
|
|
66
|
-
const r = m(o[t].innerHTML, u, "style");
|
|
67
|
-
r && (o[t].innerHTML = r);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const i = c.contentWindow;
|
|
71
|
-
i.focus(), i.document.write(s ? s.innerHTML : t.message || "");
|
|
72
|
-
const l = i.document.getElementsByTagName("head")[0];
|
|
73
|
-
if (null != l) {
|
|
74
|
-
if ((ut(l), t.Ae())) {
|
|
75
|
-
const e = document.createElement("style");
|
|
76
|
-
(e.innerHTML = t.css || ""),
|
|
77
|
-
(e.id = t.Ce() || ""),
|
|
78
|
-
null != u && e.setAttribute("nonce", u),
|
|
79
|
-
l.appendChild(e);
|
|
80
|
-
}
|
|
81
|
-
const e = i.document.createElement("base");
|
|
82
|
-
null != e && (e.setAttribute("target", "_parent"), l.appendChild(e));
|
|
83
|
-
}
|
|
84
|
-
const f = i.document.getElementsByTagName("title");
|
|
85
|
-
f && f.length > 0 && c.setAttribute("title", f[0].textContent || "");
|
|
86
|
-
const d = {
|
|
87
|
-
closeMessage: function () {
|
|
88
|
-
t.ye(c);
|
|
89
|
-
},
|
|
90
|
-
logClick: function () {
|
|
91
|
-
logInAppMessageHtmlClick(t, ...arguments);
|
|
92
|
-
},
|
|
93
|
-
display: {},
|
|
94
|
-
web: {},
|
|
95
|
-
},
|
|
96
|
-
requestPushPermission = function () {
|
|
97
|
-
return function () {
|
|
98
|
-
const t = arguments;
|
|
99
|
-
import("../../Push/request-push-permission.js").then((o) => {
|
|
100
|
-
e.fe()
|
|
101
|
-
? o.requestPushPermission(...Array.prototype.slice.call(t))
|
|
102
|
-
: r.j.error(P);
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
},
|
|
106
|
-
p = {
|
|
107
|
-
requestImmediateDataFlush: function () {
|
|
108
|
-
const t = arguments;
|
|
109
|
-
import("../../Core/request-immediate-data-flush.js").then(
|
|
110
|
-
({ requestImmediateDataFlush: requestImmediateDataFlush }) => {
|
|
111
|
-
e.fe()
|
|
112
|
-
? requestImmediateDataFlush(...Array.prototype.slice.call(t))
|
|
113
|
-
: r.j.error(P);
|
|
114
|
-
},
|
|
115
|
-
);
|
|
116
|
-
},
|
|
117
|
-
logCustomEvent: function () {
|
|
118
|
-
const t = arguments;
|
|
119
|
-
import("../../Core/log-custom-event.js").then(
|
|
120
|
-
({ logCustomEvent: logCustomEvent }) => {
|
|
121
|
-
if (!e.fe()) return void r.j.error(P);
|
|
122
|
-
logCustomEvent(...Array.prototype.slice.call(t));
|
|
123
|
-
},
|
|
124
|
-
);
|
|
125
|
-
},
|
|
126
|
-
logPurchase: function () {
|
|
127
|
-
const t = arguments;
|
|
128
|
-
import("../../Core/log-purchase.js").then(
|
|
129
|
-
({ logPurchase: logPurchase }) => {
|
|
130
|
-
if (!e.fe()) return void r.j.error(P);
|
|
131
|
-
logPurchase(...Array.prototype.slice.call(t));
|
|
132
|
-
},
|
|
133
|
-
);
|
|
134
|
-
},
|
|
135
|
-
unregisterPush: function () {
|
|
136
|
-
const t = arguments;
|
|
137
|
-
import("../../Push/unregister-push.js").then(
|
|
138
|
-
({ unregisterPush: unregisterPush }) => {
|
|
139
|
-
e.fe()
|
|
140
|
-
? unregisterPush(...Array.prototype.slice.call(t))
|
|
141
|
-
: r.j.error(P);
|
|
142
|
-
},
|
|
143
|
-
);
|
|
144
|
-
},
|
|
145
|
-
requestPushPermission: requestPushPermission(),
|
|
146
|
-
changeUser: function () {
|
|
147
|
-
const t = arguments;
|
|
148
|
-
import("../../Core/change-user.js").then(
|
|
149
|
-
({ changeUser: changeUser }) => {
|
|
150
|
-
if (!e.fe()) return void r.j.error(P);
|
|
151
|
-
changeUser(...Array.prototype.slice.call(t));
|
|
152
|
-
},
|
|
153
|
-
);
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
h = function (t) {
|
|
157
|
-
return function () {
|
|
158
|
-
p[t](...Array.prototype.slice.call(arguments));
|
|
159
|
-
};
|
|
160
|
-
};
|
|
161
|
-
for (const t of oo(p)) d[t] = h(t);
|
|
162
|
-
const b = [
|
|
163
|
-
"setFirstName",
|
|
164
|
-
"setLastName",
|
|
165
|
-
"setEmail",
|
|
166
|
-
"setGender",
|
|
167
|
-
"setDateOfBirth",
|
|
168
|
-
"setCountry",
|
|
169
|
-
"setHomeCity",
|
|
170
|
-
"setEmailNotificationSubscriptionType",
|
|
171
|
-
"setLanguage",
|
|
172
|
-
"addAlias",
|
|
173
|
-
"setPushNotificationSubscriptionType",
|
|
174
|
-
"setPhoneNumber",
|
|
175
|
-
"setCustomUserAttribute",
|
|
176
|
-
"addToCustomAttributeArray",
|
|
177
|
-
"removeFromCustomAttributeArray",
|
|
178
|
-
"incrementCustomUserAttribute",
|
|
179
|
-
"setCustomLocationAttribute",
|
|
180
|
-
"addToSubscriptionGroup",
|
|
181
|
-
"removeFromSubscriptionGroup",
|
|
182
|
-
],
|
|
183
|
-
g = function (t) {
|
|
184
|
-
return function () {
|
|
185
|
-
const e = ee();
|
|
186
|
-
e && e[t](...Array.prototype.slice.call(arguments));
|
|
187
|
-
};
|
|
188
|
-
},
|
|
189
|
-
y = {};
|
|
190
|
-
for (let t = 0; t < b.length; t++) y[b[t]] = g(b[t]);
|
|
191
|
-
d.getUser = function () {
|
|
192
|
-
return y;
|
|
193
|
-
};
|
|
194
|
-
const A = { showFeed: o },
|
|
195
|
-
j = function (e) {
|
|
196
|
-
return function () {
|
|
197
|
-
const o = arguments;
|
|
198
|
-
t.ye(c, function () {
|
|
199
|
-
A[e](...Array.prototype.slice.call(o));
|
|
200
|
-
});
|
|
201
|
-
};
|
|
202
|
-
},
|
|
203
|
-
C = d.display;
|
|
204
|
-
for (const t of oo(A)) C[t] = j(t);
|
|
205
|
-
const v = { registerAppboyPushMessages: requestPushPermission() },
|
|
206
|
-
w = function (t) {
|
|
207
|
-
return function () {
|
|
208
|
-
v[t](...Array.prototype.slice.call(arguments));
|
|
209
|
-
};
|
|
210
|
-
},
|
|
211
|
-
E = d.web;
|
|
212
|
-
for (const t of oo(v)) E[t] = w(t);
|
|
213
|
-
if (
|
|
214
|
-
((i.appboyBridge = d), (i.brazeBridge = d), t.Pe !== InAppMessage.qe.Ee)
|
|
215
|
-
) {
|
|
216
|
-
const t = i.document.getElementsByTagName("a");
|
|
217
|
-
for (let e = 0; e < t.length; e++) t[e].onclick = a(t[e]);
|
|
218
|
-
const e = i.document.getElementsByTagName("button");
|
|
219
|
-
for (let t = 0; t < e.length; t++) e[t].onclick = a(e[t]);
|
|
220
|
-
}
|
|
221
|
-
const $ = i.document.body;
|
|
222
|
-
if (null != $) {
|
|
223
|
-
t.Ne() && ($.id = t.htmlId || "");
|
|
224
|
-
const e = document.createElement("hidden");
|
|
225
|
-
(e.onclick = d.closeMessage),
|
|
226
|
-
(e.className = "ab-programmatic-close-button"),
|
|
227
|
-
$.appendChild(e);
|
|
228
|
-
}
|
|
229
|
-
i.dispatchEvent(new CustomEvent("ab.BridgeReady")),
|
|
230
|
-
-1 !== c.className.indexOf("ab-start-hidden") &&
|
|
231
|
-
((c.className = c.className.replace("ab-start-hidden", "")), n(c)),
|
|
232
|
-
document.activeElement !== c && c.focus();
|
|
233
|
-
}),
|
|
234
|
-
(c.className =
|
|
235
|
-
"ab-in-app-message ab-start-hidden ab-html-message ab-modal-interactions"),
|
|
236
|
-
V.OS === W.de)
|
|
237
|
-
) {
|
|
238
|
-
const e = document.createElement("div");
|
|
239
|
-
return (
|
|
240
|
-
(e.className = "ab-ios-scroll-wrapper"), e.appendChild(c), (t.Me = e), e
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
return (t.Me = c), c;
|
|
244
|
-
}
|
|
1
|
+
import{attachInAppMessageCSS as ut}from"../../ui/js/iam-css.js";import V from"../../util/browser-detector.js";import{logInAppMessageHtmlClick}from"../log-in-app-message-html-click.js";import{getUser as ee}from"../../Core/get-user.js";import{InAppMessage}from"../index.js";import{keys as oo}from"../../util/code-utils.js";import{OperatingSystems as W}from"../../util/device-constants.js";import{parseQueryStringKeyValues as ct}from"../../util/url-utils.js";import{WindowUtils as Z}from"../../util/window-utils.js";import e from"../../managers/braze-instance.js";import r from"../../../shared-lib/braze-shared-lib.js";import{BRAZE_MUST_BE_INITIALIZED_ERROR as P}from"../../common/constants.js";export default function at(t,o,n,s,i,u){const c=document.createElement("iframe");c.setAttribute("title","Modal Message"),i&&(c.style.zIndex=(i+1).toString());const a=e=>{const o=e.getAttribute("href"),r=e.onclick;return n=>{if(null!=r&&"function"==typeof r&&!1===r.bind(e)(n))return;let i=ct(o).abButtonId;if(null!=i&&""!==i||(i=e.getAttribute("id")||void 0),null!=o&&""!==o&&0!==o.indexOf("#")){const r="blank"===(e.getAttribute("target")||"").toLowerCase().replace("_",""),u=s||t.openTarget===InAppMessage.OpenTarget.BLANK||r,a=()=>{logInAppMessageHtmlClick(t,i,o),Z.openUri(o,u,n)};u?a():t.ye(c,a)}else logInAppMessageHtmlClick(t,i,o||void 0);return n.stopPropagation(),!1}},m=(t,e,o)=>{const r=`([\\w]+)\\s*=\\s*document.createElement\\(['"]${o}['"]\\)`,n=t.match(new RegExp(r));if(n){const o=`${n[1]}.setAttribute("nonce", "${e}")`;return`${t.slice(0,n.index+n[0].length)};${o};${t.slice(n.index+n[0].length)}`}return null};if(c.onload=()=>{let s=null;if(null!=u){s=document.createElement("html"),s.innerHTML=t.message||"";const e=s.getElementsByTagName("style");for(let t=0;t<e.length;t++)e[t].setAttribute("nonce",u);const o=s.getElementsByTagName("script");for(let t=0;t<o.length;t++){o[t].setAttribute("nonce",u),o[t].innerHTML=o[t].innerHTML.replace(/<style>/g,`<style nonce='${u}'>`);const e=m(o[t].innerHTML,u,"script");e&&(o[t].innerHTML=e);const r=m(o[t].innerHTML,u,"style");r&&(o[t].innerHTML=r)}}const i=c.contentWindow;i.focus(),i.document.write(s?s.innerHTML:t.message||"");const l=i.document.getElementsByTagName("head")[0];if(null!=l){if(ut(l),t.Ae()){const e=document.createElement("style");e.innerHTML=t.css||"",e.id=t.Ce()||"",null!=u&&e.setAttribute("nonce",u),l.appendChild(e)}const e=i.document.createElement("base");null!=e&&(e.setAttribute("target","_parent"),l.appendChild(e))}const f=i.document.getElementsByTagName("title");f&&f.length>0&&c.setAttribute("title",f[0].textContent||"");const d={closeMessage:function(){t.ye(c)},logClick:function(){logInAppMessageHtmlClick(t,...arguments)},display:{},web:{}},requestPushPermission=function(){return function(){const t=arguments;import("../../Push/request-push-permission.js").then((o=>{e.fe()?o.requestPushPermission(...Array.prototype.slice.call(t)):r.j.error(P)}))}},p={requestImmediateDataFlush:function(){const t=arguments;import("../../Core/request-immediate-data-flush.js").then((({requestImmediateDataFlush:requestImmediateDataFlush})=>{e.fe()?requestImmediateDataFlush(...Array.prototype.slice.call(t)):r.j.error(P)}))},logCustomEvent:function(){const t=arguments;import("../../Core/log-custom-event.js").then((({logCustomEvent:logCustomEvent})=>{if(!e.fe())return void r.j.error(P);logCustomEvent(...Array.prototype.slice.call(t))}))},logPurchase:function(){const t=arguments;import("../../Core/log-purchase.js").then((({logPurchase:logPurchase})=>{if(!e.fe())return void r.j.error(P);logPurchase(...Array.prototype.slice.call(t))}))},unregisterPush:function(){const t=arguments;import("../../Push/unregister-push.js").then((({unregisterPush:unregisterPush})=>{e.fe()?unregisterPush(...Array.prototype.slice.call(t)):r.j.error(P)}))},requestPushPermission:requestPushPermission(),changeUser:function(){const t=arguments;import("../../Core/change-user.js").then((({changeUser:changeUser})=>{if(!e.fe())return void r.j.error(P);changeUser(...Array.prototype.slice.call(t))}))}},h=function(t){return function(){p[t](...Array.prototype.slice.call(arguments))}};for(const t of oo(p))d[t]=h(t);const b=["setFirstName","setLastName","setEmail","setGender","setDateOfBirth","setCountry","setHomeCity","setEmailNotificationSubscriptionType","setLanguage","addAlias","setPushNotificationSubscriptionType","setPhoneNumber","setCustomUserAttribute","addToCustomAttributeArray","removeFromCustomAttributeArray","incrementCustomUserAttribute","setCustomLocationAttribute","addToSubscriptionGroup","removeFromSubscriptionGroup"],g=function(t){return function(){const e=ee();e&&e[t](...Array.prototype.slice.call(arguments))}},y={};for(let t=0;t<b.length;t++)y[b[t]]=g(b[t]);d.getUser=function(){return y};const A={showFeed:o},j=function(e){return function(){const o=arguments;t.ye(c,(function(){A[e](...Array.prototype.slice.call(o))}))}},C=d.display;for(const t of oo(A))C[t]=j(t);const v={registerAppboyPushMessages:requestPushPermission()},w=function(t){return function(){v[t](...Array.prototype.slice.call(arguments))}},E=d.web;for(const t of oo(v))E[t]=w(t);if(i.appboyBridge=d,i.brazeBridge=d,t.Pe!==InAppMessage.qe.Ee){const t=i.document.getElementsByTagName("a");for(let e=0;e<t.length;e++)t[e].onclick=a(t[e]);const e=i.document.getElementsByTagName("button");for(let t=0;t<e.length;t++)e[t].onclick=a(e[t])}const $=i.document.body;if(null!=$){t.Ne()&&($.id=t.htmlId||"");const e=document.createElement("hidden");e.onclick=d.closeMessage,e.className="ab-programmatic-close-button",$.appendChild(e)}i.dispatchEvent(new CustomEvent("ab.BridgeReady")),-1!==c.className.indexOf("ab-start-hidden")&&(c.className=c.className.replace("ab-start-hidden",""),n(c)),document.activeElement!==c&&c.focus()},c.className="ab-in-app-message ab-start-hidden ab-html-message ab-modal-interactions",V.OS===W.de){const e=document.createElement("div");return e.className="ab-ios-scroll-wrapper",e.appendChild(c),t.Me=e,e}return t.Me=c,c}
|
|
@@ -1,188 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
addPassiveEventListener as oe,
|
|
3
|
-
buildSvg as ae,
|
|
4
|
-
detectSwipe as d,
|
|
5
|
-
DIRECTIONS as c,
|
|
6
|
-
} from "../../util/dom-utils.js";
|
|
7
|
-
import { createCloseButton as o } from "../../util/component-utils.js";
|
|
8
|
-
import { isTransparent as ne, toRgba as le } from "../../util/color-utils.js";
|
|
9
|
-
import FullScreenMessage from "../models/full-screen-message.js";
|
|
10
|
-
import HtmlMessage from "../models/html-message.js";
|
|
11
|
-
import InAppMessage from "../models/in-app-message.js";
|
|
12
|
-
import ModalMessage from "../models/modal-message.js";
|
|
13
|
-
import SlideUpMessage from "../models/slide-up-message.js";
|
|
14
|
-
import { logInAppMessageClick } from "../log-in-app-message-click.js";
|
|
15
|
-
import { _handleBrazeAction as m } from "../../Core/handle-braze-action.js";
|
|
16
|
-
import at from "./html-message-to-html.js";
|
|
17
|
-
import ce from "./modal-utils.js";
|
|
18
|
-
import r from "../../../shared-lib/braze-shared-lib.js";
|
|
19
|
-
export default function de(e, a, t, n, s, i, l, u = document.body) {
|
|
20
|
-
if (((e.ke = document.activeElement), e instanceof HtmlMessage))
|
|
21
|
-
return at(e, a, t, s, i, l);
|
|
22
|
-
const b = (function (e, a, t, n, s, i, l = document.body) {
|
|
23
|
-
let c = null;
|
|
24
|
-
const d = document.createElement("div");
|
|
25
|
-
(d.className = "ab-in-app-message ab-start-hidden ab-background"),
|
|
26
|
-
i && (d.style.zIndex = (i + 1).toString()),
|
|
27
|
-
e.xe() &&
|
|
28
|
-
((d.className += " ab-modal-interactions"),
|
|
29
|
-
d.setAttribute("tabindex", "-1")),
|
|
30
|
-
e.Ae() ||
|
|
31
|
-
((d.style.color = le(e.textColor)),
|
|
32
|
-
(d.style.backgroundColor = le(e.backgroundColor)),
|
|
33
|
-
ne(e.backgroundColor) && (d.className += " ab-no-shadow"));
|
|
34
|
-
const u = () => {
|
|
35
|
-
-1 !== d.className.indexOf("ab-start-hidden") &&
|
|
36
|
-
((d.className = d.className.replace("ab-start-hidden", "")),
|
|
37
|
-
document.querySelectorAll(".ab-iam-img-loading").length > 0
|
|
38
|
-
? n(
|
|
39
|
-
`Cannot show in-app message ${e.message} because another message is being shown.`,
|
|
40
|
-
InAppMessage.Ie.Le,
|
|
41
|
-
)
|
|
42
|
-
: t(d));
|
|
43
|
-
},
|
|
44
|
-
b = (o = !0) => {
|
|
45
|
-
let a = document.querySelectorAll(".ab-iam-root");
|
|
46
|
-
(a && 0 !== a.length) || (a = l.querySelectorAll(".ab-iam-root")),
|
|
47
|
-
a &&
|
|
48
|
-
a.length > 0 &&
|
|
49
|
-
(a[0].classList.remove("ab-iam-img-loading"),
|
|
50
|
-
c && (clearTimeout(c), (c = null)),
|
|
51
|
-
o
|
|
52
|
-
? u()
|
|
53
|
-
: r.j.error(
|
|
54
|
-
`Cannot show in-app message ${e.message} because the image failed to load.`,
|
|
55
|
-
));
|
|
56
|
-
};
|
|
57
|
-
e.imageStyle === InAppMessage.ImageStyle.GRAPHIC &&
|
|
58
|
-
(d.className += " graphic"),
|
|
59
|
-
e.orientation === InAppMessage.Orientation.LANDSCAPE &&
|
|
60
|
-
(d.className += " landscape"),
|
|
61
|
-
null != e.buttons &&
|
|
62
|
-
0 === e.buttons.length &&
|
|
63
|
-
(e.clickAction !== InAppMessage.ClickAction.NONE &&
|
|
64
|
-
(d.className += " ab-clickable"),
|
|
65
|
-
(d.onclick = (o) => (
|
|
66
|
-
e.ye(d, () => {
|
|
67
|
-
logInAppMessageClick(e),
|
|
68
|
-
e.clickAction === InAppMessage.ClickAction.URI
|
|
69
|
-
? m(
|
|
70
|
-
e.uri || "",
|
|
71
|
-
s || e.openTarget === InAppMessage.OpenTarget.BLANK,
|
|
72
|
-
o,
|
|
73
|
-
)
|
|
74
|
-
: e.clickAction === InAppMessage.ClickAction.NEWS_FEED && a();
|
|
75
|
-
}),
|
|
76
|
-
o.stopPropagation(),
|
|
77
|
-
!1
|
|
78
|
-
)));
|
|
79
|
-
const p = o(
|
|
80
|
-
"Close Message",
|
|
81
|
-
e.Ae() ? void 0 : le(e.closeButtonColor),
|
|
82
|
-
() => {
|
|
83
|
-
e.ye(d);
|
|
84
|
-
},
|
|
85
|
-
);
|
|
86
|
-
d.appendChild(p), i && (p.style.zIndex = (i + 2).toString());
|
|
87
|
-
const g = document.createElement("div");
|
|
88
|
-
g.className = "ab-message-text";
|
|
89
|
-
const f = (e.messageAlignment || e.Te).toLowerCase();
|
|
90
|
-
g.className += " " + f + "-aligned";
|
|
91
|
-
let h = !1;
|
|
92
|
-
const j = document.createElement("div");
|
|
93
|
-
if (((j.className = "ab-image-area"), e.imageUrl)) {
|
|
94
|
-
if (e.cropType === InAppMessage.CropType.CENTER_CROP) {
|
|
95
|
-
const o = document.createElement("span");
|
|
96
|
-
(o.className = "ab-center-cropped-img"),
|
|
97
|
-
(o.style.backgroundImage = "url(" + e.imageUrl + ")"),
|
|
98
|
-
o.setAttribute("role", "img"),
|
|
99
|
-
o.setAttribute("aria-label", "Modal Image"),
|
|
100
|
-
e.Be(o),
|
|
101
|
-
j.appendChild(o);
|
|
102
|
-
} else {
|
|
103
|
-
const o = document.createElement("img");
|
|
104
|
-
if (
|
|
105
|
-
(o.setAttribute("src", e.imageUrl),
|
|
106
|
-
e.Be(o),
|
|
107
|
-
0 === document.querySelectorAll(".ab-iam-img-loading").length)
|
|
108
|
-
) {
|
|
109
|
-
h = !0;
|
|
110
|
-
const e = document.querySelectorAll(".ab-iam-root");
|
|
111
|
-
e && e.length > 0 && e[0].classList.add("ab-iam-img-loading"),
|
|
112
|
-
(c = window.setTimeout(() => {
|
|
113
|
-
b(!1);
|
|
114
|
-
}, 6e4)),
|
|
115
|
-
(o.onload = () => {
|
|
116
|
-
b();
|
|
117
|
-
}),
|
|
118
|
-
(o.onerror = () => {
|
|
119
|
-
b(!1);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
j.appendChild(o);
|
|
123
|
-
}
|
|
124
|
-
d.appendChild(j), (g.className += " ab-with-image");
|
|
125
|
-
} else if (e.icon) {
|
|
126
|
-
j.className += " ab-icon-area";
|
|
127
|
-
const o = document.createElement("span");
|
|
128
|
-
(o.className = "ab-icon"),
|
|
129
|
-
e.Ae() ||
|
|
130
|
-
((o.style.backgroundColor = le(e.iconBackgroundColor)),
|
|
131
|
-
(o.style.color = le(e.iconColor)));
|
|
132
|
-
const a = document.createElement("i");
|
|
133
|
-
(a.className = "fa"),
|
|
134
|
-
a.appendChild(document.createTextNode(e.icon)),
|
|
135
|
-
a.setAttribute("aria-hidden", "true"),
|
|
136
|
-
o.appendChild(a),
|
|
137
|
-
j.appendChild(o),
|
|
138
|
-
d.appendChild(j),
|
|
139
|
-
(g.className += " ab-with-icon");
|
|
140
|
-
}
|
|
141
|
-
if ((oe(g, "touchstart"), e.header && e.header.length > 0)) {
|
|
142
|
-
const o = document.createElement("h1");
|
|
143
|
-
(o.className = "ab-message-header"), (e.De = r.Z.Y()), (o.id = e.De);
|
|
144
|
-
const a = (
|
|
145
|
-
e.headerAlignment || InAppMessage.TextAlignment.CENTER
|
|
146
|
-
).toLowerCase();
|
|
147
|
-
(o.className += " " + a + "-aligned"),
|
|
148
|
-
e.Ae() || (o.style.color = le(e.headerTextColor)),
|
|
149
|
-
o.appendChild(document.createTextNode(e.header)),
|
|
150
|
-
g.appendChild(o);
|
|
151
|
-
}
|
|
152
|
-
return g.appendChild(e.Ge()), d.appendChild(g), h || u(), (e.Me = d), d;
|
|
153
|
-
})(e, a, t, n, s, i, u);
|
|
154
|
-
if (e instanceof FullScreenMessage || e instanceof ModalMessage) {
|
|
155
|
-
const o = e instanceof FullScreenMessage ? "ab-fullscreen" : "ab-modal";
|
|
156
|
-
(b.className += ` ${o} ab-centered`),
|
|
157
|
-
ce.He(e, a, b, s),
|
|
158
|
-
ce.Je(b),
|
|
159
|
-
ce.Ke(e.De, b);
|
|
160
|
-
} else if (e instanceof SlideUpMessage) {
|
|
161
|
-
b.className += " ab-slideup";
|
|
162
|
-
const o = b.getElementsByClassName("ab-close-button")[0];
|
|
163
|
-
if (null != o) {
|
|
164
|
-
const a = ae(
|
|
165
|
-
"0 0 11.38 19.44",
|
|
166
|
-
"M11.38 9.72l-9.33 9.72L0 17.3l7.27-7.58L0 2.14 2.05 0l9.33 9.72z",
|
|
167
|
-
e.Ae() ? void 0 : le(e.closeButtonColor),
|
|
168
|
-
);
|
|
169
|
-
a.setAttribute("class", "ab-chevron"), o.appendChild(a);
|
|
170
|
-
}
|
|
171
|
-
let a, t;
|
|
172
|
-
d(b, c.W, (e) => {
|
|
173
|
-
(b.className += " ab-swiped-left"),
|
|
174
|
-
null != o && null != o.onclick && o.onclick(e);
|
|
175
|
-
}),
|
|
176
|
-
d(b, c.X, (e) => {
|
|
177
|
-
(b.className += " ab-swiped-right"),
|
|
178
|
-
null != o && null != o.onclick && o.onclick(e);
|
|
179
|
-
}),
|
|
180
|
-
e.slideFrom === InAppMessage.SlideFrom.TOP
|
|
181
|
-
? ((a = c.Oe), (t = " ab-swiped-up"))
|
|
182
|
-
: ((a = c.Qe), (t = " ab-swiped-down")),
|
|
183
|
-
d(b, a, (e) => {
|
|
184
|
-
(b.className += t), null != o && null != o.onclick && o.onclick(e);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
return b;
|
|
188
|
-
}
|
|
1
|
+
import{addPassiveEventListener as oe,buildSvg as ae,detectSwipe as d,DIRECTIONS as c}from"../../util/dom-utils.js";import{createCloseButton as o}from"../../util/component-utils.js";import{isTransparent as ne,toRgba as le}from"../../util/color-utils.js";import FullScreenMessage from"../models/full-screen-message.js";import HtmlMessage from"../models/html-message.js";import InAppMessage from"../models/in-app-message.js";import ModalMessage from"../models/modal-message.js";import SlideUpMessage from"../models/slide-up-message.js";import{logInAppMessageClick}from"../log-in-app-message-click.js";import{_handleBrazeAction as m}from"../../Core/handle-braze-action.js";import at from"./html-message-to-html.js";import ce from"./modal-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";export default function de(e,a,t,n,s,i,l,u=document.body){if(e.ke=document.activeElement,e instanceof HtmlMessage)return at(e,a,t,s,i,l);const b=function(e,a,t,n,s,i,l=document.body){let c=null;const d=document.createElement("div");d.className="ab-in-app-message ab-start-hidden ab-background",i&&(d.style.zIndex=(i+1).toString()),e.xe()&&(d.className+=" ab-modal-interactions",d.setAttribute("tabindex","-1")),e.Ae()||(d.style.color=le(e.textColor),d.style.backgroundColor=le(e.backgroundColor),ne(e.backgroundColor)&&(d.className+=" ab-no-shadow"));const u=()=>{-1!==d.className.indexOf("ab-start-hidden")&&(d.className=d.className.replace("ab-start-hidden",""),document.querySelectorAll(".ab-iam-img-loading").length>0?n(`Cannot show in-app message ${e.message} because another message is being shown.`,InAppMessage.Ie.Le):t(d))},b=(o=!0)=>{let a=document.querySelectorAll(".ab-iam-root");a&&0!==a.length||(a=l.querySelectorAll(".ab-iam-root")),a&&a.length>0&&(a[0].classList.remove("ab-iam-img-loading"),c&&(clearTimeout(c),c=null),o?u():r.j.error(`Cannot show in-app message ${e.message} because the image failed to load.`))};e.imageStyle===InAppMessage.ImageStyle.GRAPHIC&&(d.className+=" graphic"),e.orientation===InAppMessage.Orientation.LANDSCAPE&&(d.className+=" landscape"),null!=e.buttons&&0===e.buttons.length&&(e.clickAction!==InAppMessage.ClickAction.NONE&&(d.className+=" ab-clickable"),d.onclick=o=>(e.ye(d,(()=>{logInAppMessageClick(e),e.clickAction===InAppMessage.ClickAction.URI?m(e.uri||"",s||e.openTarget===InAppMessage.OpenTarget.BLANK,o):e.clickAction===InAppMessage.ClickAction.NEWS_FEED&&a()})),o.stopPropagation(),!1));const p=o("Close Message",e.Ae()?void 0:le(e.closeButtonColor),(()=>{e.ye(d)}));d.appendChild(p),i&&(p.style.zIndex=(i+2).toString());const g=document.createElement("div");g.className="ab-message-text";const f=(e.messageAlignment||e.Te).toLowerCase();g.className+=" "+f+"-aligned";let h=!1;const j=document.createElement("div");if(j.className="ab-image-area",e.imageUrl){if(e.cropType===InAppMessage.CropType.CENTER_CROP){const o=document.createElement("span");o.className="ab-center-cropped-img",o.style.backgroundImage="url("+e.imageUrl+")",o.setAttribute("role","img"),o.setAttribute("aria-label","Modal Image"),e.Be(o),j.appendChild(o)}else{const o=document.createElement("img");if(o.setAttribute("src",e.imageUrl),e.Be(o),0===document.querySelectorAll(".ab-iam-img-loading").length){h=!0;const e=document.querySelectorAll(".ab-iam-root");e&&e.length>0&&e[0].classList.add("ab-iam-img-loading"),c=window.setTimeout((()=>{b(!1)}),6e4),o.onload=()=>{b()},o.onerror=()=>{b(!1)}}j.appendChild(o)}d.appendChild(j),g.className+=" ab-with-image"}else if(e.icon){j.className+=" ab-icon-area";const o=document.createElement("span");o.className="ab-icon",e.Ae()||(o.style.backgroundColor=le(e.iconBackgroundColor),o.style.color=le(e.iconColor));const a=document.createElement("i");a.className="fa",a.appendChild(document.createTextNode(e.icon)),a.setAttribute("aria-hidden","true"),o.appendChild(a),j.appendChild(o),d.appendChild(j),g.className+=" ab-with-icon"}if(oe(g,"touchstart"),e.header&&e.header.length>0){const o=document.createElement("h1");o.className="ab-message-header",e.De=r.Z.Y(),o.id=e.De;const a=(e.headerAlignment||InAppMessage.TextAlignment.CENTER).toLowerCase();o.className+=" "+a+"-aligned",e.Ae()||(o.style.color=le(e.headerTextColor)),o.appendChild(document.createTextNode(e.header)),g.appendChild(o)}return g.appendChild(e.Ge()),d.appendChild(g),h||u(),e.Me=d,d}(e,a,t,n,s,i,u);if(e instanceof FullScreenMessage||e instanceof ModalMessage){const o=e instanceof FullScreenMessage?"ab-fullscreen":"ab-modal";b.className+=` ${o} ab-centered`,ce.He(e,a,b,s),ce.Je(b),ce.Ke(e.De,b)}else if(e instanceof SlideUpMessage){b.className+=" ab-slideup";const o=b.getElementsByClassName("ab-close-button")[0];if(null!=o){const a=ae("0 0 11.38 19.44","M11.38 9.72l-9.33 9.72L0 17.3l7.27-7.58L0 2.14 2.05 0l9.33 9.72z",e.Ae()?void 0:le(e.closeButtonColor));a.setAttribute("class","ab-chevron"),o.appendChild(a)}let a,t;d(b,c.W,(e=>{b.className+=" ab-swiped-left",null!=o&&null!=o.onclick&&o.onclick(e)})),d(b,c.X,(e=>{b.className+=" ab-swiped-right",null!=o&&null!=o.onclick&&o.onclick(e)})),e.slideFrom===InAppMessage.SlideFrom.TOP?(a=c.Oe,t=" ab-swiped-up"):(a=c.Qe,t=" ab-swiped-down"),d(b,a,(e=>{b.className+=t,null!=o&&null!=o.onclick&&o.onclick(e)}))}return b}
|