@braze/web-sdk 5.3.1 → 5.4.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.d.ts +20 -4
- package/package.json +1 -1
- package/shared-lib/event-types.js +10 -10
- package/shared-lib/indexed-db-adapter.js +1 -1
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +9 -8
- package/src/Card/display/card-display.js +59 -58
- package/src/Core/index.js +1 -0
- package/src/Core/is-initialized.js +4 -0
- package/src/InAppMessage/display/html-message-display-utils.js +172 -0
- package/src/InAppMessage/display/html-message-to-html.js +54 -219
- package/src/InAppMessage/display/in-app-message-to-html.js +78 -76
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +4 -4
- package/src/InAppMessage/in-app-message-manager.js +56 -56
- package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/full-screen-message.js +2 -2
- package/src/InAppMessage/models/html-message.js +2 -2
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +26 -26
- package/src/InAppMessage/models/modal-message.js +2 -2
- package/src/InAppMessage/models/slide-up-message.js +4 -4
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +47 -45
- package/src/InAppMessage/utils/in-app-message-utils.js +1 -18
- package/src/Push/is-push-blocked.js +2 -2
- package/src/Push/is-push-permission-granted.js +2 -2
- package/src/Push/is-push-supported.js +2 -2
- package/src/Push/push-manager-factory.js +2 -1
- package/src/Push/push-manager.js +80 -92
- package/src/Push/utils/push-utils.js +12 -12
- package/src/User/user-manager.js +3 -3
- package/src/User/user.js +19 -19
- package/src/common/event-logger.js +4 -4
- package/src/common/feed-display.js +25 -24
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +15 -5
- package/src/managers/auth-manager.js +1 -1
- package/src/managers/braze-instance.js +54 -52
- package/src/managers/device-manager.js +19 -19
- package/src/managers/network-manager.js +100 -100
- package/src/managers/server-config-manager.js +7 -7
- package/src/managers/session-manager.js +4 -4
- package/src/managers/storage-manager-factory.js +4 -4
- package/src/managers/storage-manager.js +18 -18
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +10 -10
- package/src/models/device.js +3 -3
- package/src/models/server-config.js +7 -7
- package/src/request-controller.js +77 -77
- package/src/triggers/models/custom-event-data.js +2 -2
- package/src/triggers/models/custom-event-property-data.js +4 -4
- package/src/triggers/models/filter-set.js +3 -3
- package/src/triggers/models/filter.js +9 -9
- package/src/triggers/models/in-app-message-click-data.js +8 -8
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/push-click-data.js +3 -3
- package/src/triggers/models/trigger-condition.js +39 -39
- package/src/triggers/models/trigger.js +12 -12
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +15 -15
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +1 -1
- package/src/ui/js/iam-css.js +1 -1
- package/src/util/base-device-parser.js +7 -7
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +21 -21
- package/src/util/client-hints-parser.js +3 -3
- package/src/util/component-utils.js +15 -14
- package/src/util/date-utils.js +2 -2
- package/src/util/dom-utils.js +3 -3
- package/src/util/net.js +2 -2
- package/src/util/request-header-utils.js +8 -8
- package/src/util/user-agent-parser.js +3 -3
- package/src/util/validation-utils.js +17 -17
- package/src/util/window-utils.js +1 -1
|
@@ -1,237 +1,72 @@
|
|
|
1
1
|
import X from "../../util/browser-detector.js";
|
|
2
|
-
import { logInAppMessageHtmlClick } from "../log-in-app-message-html-click.js";
|
|
3
|
-
import { getUser as ro } from "../../Core/get-user.js";
|
|
4
2
|
import { InAppMessage } from "../index.js";
|
|
5
|
-
import { keys as to } from "../../util/code-utils.js";
|
|
6
3
|
import { OperatingSystems as Y } from "../../util/device-constants.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export default function at(t, o, n, s, i, u) {
|
|
4
|
+
import {
|
|
5
|
+
applyNonceToDynamicallyCreatedTags as lt,
|
|
6
|
+
buildBrazeBridge as ct,
|
|
7
|
+
buildHtmlClickHandler as at,
|
|
8
|
+
} from "./html-message-display-utils.js";
|
|
9
|
+
export default function dt(t, e, n, o, s, l) {
|
|
14
10
|
const c = document.createElement("iframe");
|
|
15
11
|
c.setAttribute("title", "Modal Message"),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} else logInAppMessageHtmlClick(t, i, o || void 0);
|
|
36
|
-
return r.stopPropagation(), !1;
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
m = (t, e, o) => {
|
|
40
|
-
const n = `([\\w]+)\\s*=\\s*document.createElement\\(['"]${o}['"]\\)`,
|
|
41
|
-
r = t.match(new RegExp(n));
|
|
42
|
-
if (r) {
|
|
43
|
-
const o = `${r[1]}.setAttribute("nonce", "${e}")`;
|
|
44
|
-
return `${t.slice(0, r.index + r[0].length)};${o};${t.slice(
|
|
45
|
-
r.index + r[0].length,
|
|
46
|
-
)}`;
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
};
|
|
12
|
+
s && (c.style.zIndex = (s + 1).toString());
|
|
13
|
+
let r = null;
|
|
14
|
+
if (null != l) {
|
|
15
|
+
(r = document.createElement("html")), (r.innerHTML = t.message || "");
|
|
16
|
+
const e = r.getElementsByTagName("style");
|
|
17
|
+
for (let t = 0; t < e.length; t++) e[t].setAttribute("nonce", l);
|
|
18
|
+
const n = r.getElementsByTagName("script");
|
|
19
|
+
for (let t = 0; t < n.length; t++) {
|
|
20
|
+
n[t].setAttribute("nonce", l),
|
|
21
|
+
(n[t].innerHTML = n[t].innerHTML.replace(
|
|
22
|
+
/<style>/g,
|
|
23
|
+
`<style nonce='${l}'>`,
|
|
24
|
+
));
|
|
25
|
+
const e = lt(n[t].innerHTML, l, "script");
|
|
26
|
+
e && (n[t].innerHTML = e);
|
|
27
|
+
const o = lt(n[t].innerHTML, l, "style");
|
|
28
|
+
o && (n[t].innerHTML = o);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
50
31
|
if (
|
|
51
|
-
((c.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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 n = m(o[t].innerHTML, u, "style");
|
|
67
|
-
n && (o[t].innerHTML = n);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const i = c.contentWindow;
|
|
71
|
-
i.focus();
|
|
72
|
-
const l = i.document.querySelector("html");
|
|
73
|
-
l && ((l.innerHTML = s ? s.innerHTML : t.message || ""), ct(l));
|
|
74
|
-
const f = i.document.getElementsByTagName("head")[0];
|
|
75
|
-
if (null != f) {
|
|
76
|
-
if (t.Ce()) {
|
|
32
|
+
((c.srcdoc = r ? r.innerHTML : t.message || ""),
|
|
33
|
+
(c.onload = () => {
|
|
34
|
+
const s = c.contentWindow;
|
|
35
|
+
s.focus();
|
|
36
|
+
const r = s.document.getElementsByTagName("head")[0];
|
|
37
|
+
if (null != r) {
|
|
38
|
+
if (t.ve()) {
|
|
77
39
|
const e = document.createElement("style");
|
|
78
40
|
(e.innerHTML = t.css || ""),
|
|
79
|
-
(e.id = t.
|
|
80
|
-
null !=
|
|
81
|
-
|
|
41
|
+
(e.id = t.we() || ""),
|
|
42
|
+
null != l && e.setAttribute("nonce", l),
|
|
43
|
+
r.appendChild(e);
|
|
82
44
|
}
|
|
83
|
-
const e =
|
|
84
|
-
null != e && (e.setAttribute("target", "_parent"),
|
|
45
|
+
const e = s.document.createElement("base");
|
|
46
|
+
null != e && (e.setAttribute("target", "_parent"), r.appendChild(e));
|
|
85
47
|
}
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
closeMessage: function () {
|
|
90
|
-
t.Ae(c);
|
|
91
|
-
},
|
|
92
|
-
logClick: function () {
|
|
93
|
-
logInAppMessageHtmlClick(t, ...arguments);
|
|
94
|
-
},
|
|
95
|
-
display: {},
|
|
96
|
-
web: {},
|
|
97
|
-
},
|
|
98
|
-
requestPushPermission = function () {
|
|
99
|
-
return function () {
|
|
100
|
-
const t = arguments;
|
|
101
|
-
import("../../Push/request-push-permission.js").then((o) => {
|
|
102
|
-
e.so()
|
|
103
|
-
? o.requestPushPermission(...Array.prototype.slice.call(t))
|
|
104
|
-
: r.error(_);
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
},
|
|
108
|
-
g = {
|
|
109
|
-
requestImmediateDataFlush: function () {
|
|
110
|
-
const t = arguments;
|
|
111
|
-
import("../../Core/request-immediate-data-flush.js").then(
|
|
112
|
-
({ requestImmediateDataFlush: requestImmediateDataFlush }) => {
|
|
113
|
-
e.so()
|
|
114
|
-
? requestImmediateDataFlush(...Array.prototype.slice.call(t))
|
|
115
|
-
: r.error(_);
|
|
116
|
-
},
|
|
117
|
-
);
|
|
118
|
-
},
|
|
119
|
-
logCustomEvent: function () {
|
|
120
|
-
const t = arguments;
|
|
121
|
-
import("../../Core/log-custom-event.js").then(
|
|
122
|
-
({ logCustomEvent: logCustomEvent }) => {
|
|
123
|
-
if (!e.so()) return void r.error(_);
|
|
124
|
-
logCustomEvent(...Array.prototype.slice.call(t));
|
|
125
|
-
},
|
|
126
|
-
);
|
|
127
|
-
},
|
|
128
|
-
logPurchase: function () {
|
|
129
|
-
const t = arguments;
|
|
130
|
-
import("../../Core/log-purchase.js").then(
|
|
131
|
-
({ logPurchase: logPurchase }) => {
|
|
132
|
-
if (!e.so()) return void r.error(_);
|
|
133
|
-
logPurchase(...Array.prototype.slice.call(t));
|
|
134
|
-
},
|
|
135
|
-
);
|
|
136
|
-
},
|
|
137
|
-
unregisterPush: function () {
|
|
138
|
-
const t = arguments;
|
|
139
|
-
import("../../Push/unregister-push.js").then(
|
|
140
|
-
({ unregisterPush: unregisterPush }) => {
|
|
141
|
-
e.so()
|
|
142
|
-
? unregisterPush(...Array.prototype.slice.call(t))
|
|
143
|
-
: r.error(_);
|
|
144
|
-
},
|
|
145
|
-
);
|
|
146
|
-
},
|
|
147
|
-
requestPushPermission: requestPushPermission(),
|
|
148
|
-
changeUser: function () {
|
|
149
|
-
const t = arguments;
|
|
150
|
-
import("../../Core/change-user.js").then(
|
|
151
|
-
({ changeUser: changeUser }) => {
|
|
152
|
-
if (!e.so()) return void r.error(_);
|
|
153
|
-
changeUser(...Array.prototype.slice.call(t));
|
|
154
|
-
},
|
|
155
|
-
);
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
h = function (t) {
|
|
159
|
-
return function () {
|
|
160
|
-
g[t](...Array.prototype.slice.call(arguments));
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
for (const t of to(g)) p[t] = h(t);
|
|
164
|
-
const b = [
|
|
165
|
-
"setFirstName",
|
|
166
|
-
"setLastName",
|
|
167
|
-
"setEmail",
|
|
168
|
-
"setGender",
|
|
169
|
-
"setDateOfBirth",
|
|
170
|
-
"setCountry",
|
|
171
|
-
"setHomeCity",
|
|
172
|
-
"setEmailNotificationSubscriptionType",
|
|
173
|
-
"setLanguage",
|
|
174
|
-
"addAlias",
|
|
175
|
-
"setPushNotificationSubscriptionType",
|
|
176
|
-
"setPhoneNumber",
|
|
177
|
-
"setCustomUserAttribute",
|
|
178
|
-
"addToCustomAttributeArray",
|
|
179
|
-
"removeFromCustomAttributeArray",
|
|
180
|
-
"incrementCustomUserAttribute",
|
|
181
|
-
"setCustomLocationAttribute",
|
|
182
|
-
"addToSubscriptionGroup",
|
|
183
|
-
"removeFromSubscriptionGroup",
|
|
184
|
-
],
|
|
185
|
-
y = function (t) {
|
|
186
|
-
return function () {
|
|
187
|
-
const e = ro();
|
|
188
|
-
e && e[t](...Array.prototype.slice.call(arguments));
|
|
189
|
-
};
|
|
190
|
-
},
|
|
191
|
-
A = {};
|
|
192
|
-
for (let t = 0; t < b.length; t++) A[b[t]] = y(b[t]);
|
|
193
|
-
p.getUser = function () {
|
|
194
|
-
return A;
|
|
195
|
-
};
|
|
196
|
-
const j = { showFeed: o },
|
|
197
|
-
C = function (e) {
|
|
198
|
-
return function () {
|
|
199
|
-
const o = arguments;
|
|
200
|
-
t.Ae(c, function () {
|
|
201
|
-
j[e](...Array.prototype.slice.call(o));
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
},
|
|
205
|
-
v = p.display;
|
|
206
|
-
for (const t of to(j)) v[t] = C(t);
|
|
207
|
-
const P = { registerAppboyPushMessages: requestPushPermission() },
|
|
208
|
-
w = function (t) {
|
|
209
|
-
return function () {
|
|
210
|
-
P[t](...Array.prototype.slice.call(arguments));
|
|
211
|
-
};
|
|
212
|
-
},
|
|
213
|
-
E = p.web;
|
|
214
|
-
for (const t of to(P)) E[t] = w(t);
|
|
48
|
+
const i = s.document.getElementsByTagName("title");
|
|
49
|
+
i && i.length > 0 && c.setAttribute("title", i[0].textContent || "");
|
|
50
|
+
const a = ct(t, c, e);
|
|
215
51
|
if (
|
|
216
|
-
((
|
|
52
|
+
((s.appboyBridge = a), (s.brazeBridge = a), t.xe !== InAppMessage.Be.Me)
|
|
217
53
|
) {
|
|
218
|
-
const
|
|
219
|
-
for (let
|
|
220
|
-
const
|
|
221
|
-
for (let
|
|
54
|
+
const e = s.document.getElementsByTagName("a");
|
|
55
|
+
for (let n = 0; n < e.length; n++) e[n].onclick = at(t, c, e[n], o);
|
|
56
|
+
const n = s.document.getElementsByTagName("button");
|
|
57
|
+
for (let e = 0; e < n.length; e++) n[e].onclick = at(t, c, n[e], o);
|
|
222
58
|
}
|
|
223
|
-
const
|
|
224
|
-
if (null !=
|
|
225
|
-
t.
|
|
59
|
+
const d = s.document.body;
|
|
60
|
+
if (null != d) {
|
|
61
|
+
t.Ce() && (d.id = t.htmlId || "");
|
|
226
62
|
const e = document.createElement("hidden");
|
|
227
|
-
(e.onclick =
|
|
63
|
+
(e.onclick = a.closeMessage),
|
|
228
64
|
(e.className = "ab-programmatic-close-button"),
|
|
229
|
-
|
|
65
|
+
d.appendChild(e);
|
|
230
66
|
}
|
|
231
|
-
|
|
67
|
+
s.dispatchEvent(new CustomEvent("ab.BridgeReady")),
|
|
232
68
|
-1 !== c.className.indexOf("ab-start-hidden") &&
|
|
233
|
-
((c.className = c.className.replace("ab-start-hidden", "")), n(c))
|
|
234
|
-
document.activeElement !== c && c.focus();
|
|
69
|
+
((c.className = c.className.replace("ab-start-hidden", "")), n(c));
|
|
235
70
|
}),
|
|
236
71
|
(c.className =
|
|
237
72
|
"ab-in-app-message ab-start-hidden ab-html-message ab-modal-interactions"),
|
|
@@ -239,8 +74,8 @@ export default function at(t, o, n, s, i, u) {
|
|
|
239
74
|
) {
|
|
240
75
|
const e = document.createElement("div");
|
|
241
76
|
return (
|
|
242
|
-
(e.className = "ab-ios-scroll-wrapper"), e.appendChild(c), (t.
|
|
77
|
+
(e.className = "ab-ios-scroll-wrapper"), e.appendChild(c), (t.Re = e), e
|
|
243
78
|
);
|
|
244
79
|
}
|
|
245
|
-
return (t.
|
|
80
|
+
return (t.Re = c), c;
|
|
246
81
|
}
|
|
@@ -13,57 +13,58 @@ import ModalMessage from "../models/modal-message.js";
|
|
|
13
13
|
import SlideUpMessage from "../models/slide-up-message.js";
|
|
14
14
|
import { logInAppMessageClick } from "../log-in-app-message-click.js";
|
|
15
15
|
import { _handleBrazeAction as u } from "../../Core/handle-braze-action.js";
|
|
16
|
-
import
|
|
16
|
+
import dt from "./html-message-to-html.js";
|
|
17
17
|
import le from "./modal-utils.js";
|
|
18
18
|
import { logger as r, Guid as p } from "../../../shared-lib/index.js";
|
|
19
|
-
export default function ce(e, o, a, t, n, s, i, l = document.body) {
|
|
19
|
+
export default function ce(e, o, a, t, n, s, i, l = document.body, b = "ltr") {
|
|
20
20
|
if (((e.ke = document.activeElement), e instanceof HtmlMessage))
|
|
21
|
-
return
|
|
22
|
-
const
|
|
23
|
-
let
|
|
24
|
-
const
|
|
25
|
-
(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
return dt(e, o, a, n, s, i);
|
|
22
|
+
const g = (function (e, o, a, t, n, s, i = document.body, m = "ltr") {
|
|
23
|
+
let l = null;
|
|
24
|
+
const c = document.createElement("div");
|
|
25
|
+
(c.dir = m),
|
|
26
|
+
(c.className = "ab-in-app-message ab-start-hidden ab-background"),
|
|
27
|
+
s && (c.style.zIndex = (s + 1).toString()),
|
|
28
|
+
e.$e() &&
|
|
29
|
+
((c.className += " ab-modal-interactions"),
|
|
30
|
+
c.setAttribute("tabindex", "-1")),
|
|
31
|
+
e.ve() ||
|
|
32
|
+
((c.style.color = ie(e.textColor)),
|
|
33
|
+
(c.style.backgroundColor = ie(e.backgroundColor)),
|
|
34
|
+
ne(e.backgroundColor) && (c.className += " ab-no-shadow"));
|
|
35
|
+
const b = () => {
|
|
36
|
+
-1 !== c.className.indexOf("ab-start-hidden") &&
|
|
37
|
+
((c.className = c.className.replace("ab-start-hidden", "")),
|
|
37
38
|
document.querySelectorAll(".ab-iam-img-loading").length > 0
|
|
38
39
|
? t(
|
|
39
40
|
`Cannot show in-app message ${e.message} because another message is being shown.`,
|
|
40
|
-
InAppMessage.
|
|
41
|
+
InAppMessage.Le.ze,
|
|
41
42
|
)
|
|
42
|
-
: a(
|
|
43
|
+
: a(c));
|
|
43
44
|
},
|
|
44
|
-
|
|
45
|
+
g = (o = !0) => {
|
|
45
46
|
let a = document.querySelectorAll(".ab-iam-root");
|
|
46
47
|
(a && 0 !== a.length) || (a = i.querySelectorAll(".ab-iam-root")),
|
|
47
48
|
a &&
|
|
48
49
|
a.length > 0 &&
|
|
49
50
|
(a[0].classList.remove("ab-iam-img-loading"),
|
|
50
|
-
|
|
51
|
+
l && (clearTimeout(l), (l = null)),
|
|
51
52
|
o
|
|
52
|
-
?
|
|
53
|
+
? b()
|
|
53
54
|
: r.error(
|
|
54
55
|
`Cannot show in-app message ${e.message} because the image failed to load.`,
|
|
55
56
|
));
|
|
56
57
|
};
|
|
57
58
|
e.imageStyle === InAppMessage.ImageStyle.GRAPHIC &&
|
|
58
|
-
(
|
|
59
|
+
(c.className += " graphic"),
|
|
59
60
|
e.orientation === InAppMessage.Orientation.LANDSCAPE &&
|
|
60
|
-
(
|
|
61
|
+
(c.className += " landscape"),
|
|
61
62
|
null != e.buttons &&
|
|
62
63
|
0 === e.buttons.length &&
|
|
63
64
|
(e.clickAction !== InAppMessage.ClickAction.NONE &&
|
|
64
|
-
(
|
|
65
|
-
(
|
|
66
|
-
e.
|
|
65
|
+
(c.className += " ab-clickable"),
|
|
66
|
+
(c.onclick = (a) => (
|
|
67
|
+
e.Cr(c, () => {
|
|
67
68
|
logInAppMessageClick(e),
|
|
68
69
|
e.clickAction === InAppMessage.ClickAction.URI
|
|
69
70
|
? u(
|
|
@@ -76,57 +77,58 @@ export default function ce(e, o, a, t, n, s, i, l = document.body) {
|
|
|
76
77
|
a.stopPropagation(),
|
|
77
78
|
!1
|
|
78
79
|
)));
|
|
79
|
-
const
|
|
80
|
+
const f = d(
|
|
80
81
|
"Close Message",
|
|
81
|
-
e.
|
|
82
|
+
e.ve() ? void 0 : ie(e.closeButtonColor),
|
|
82
83
|
() => {
|
|
83
|
-
e.
|
|
84
|
+
e.Cr(c);
|
|
84
85
|
},
|
|
86
|
+
m,
|
|
85
87
|
);
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
let
|
|
92
|
-
const
|
|
93
|
-
if (((
|
|
88
|
+
c.appendChild(f), s && (f.style.zIndex = (s + 2).toString());
|
|
89
|
+
const h = document.createElement("div");
|
|
90
|
+
(h.className = "ab-message-text"), (h.dir = m);
|
|
91
|
+
const j = (e.messageAlignment || e.qe).toLowerCase();
|
|
92
|
+
h.className += " " + j + "-aligned";
|
|
93
|
+
let w = !1;
|
|
94
|
+
const v = document.createElement("div");
|
|
95
|
+
if (((v.className = "ab-image-area"), e.imageUrl)) {
|
|
94
96
|
if (e.cropType === InAppMessage.CropType.CENTER_CROP) {
|
|
95
97
|
const o = document.createElement("span");
|
|
96
98
|
(o.className = "ab-center-cropped-img"),
|
|
97
99
|
(o.style.backgroundImage = "url(" + e.imageUrl + ")"),
|
|
98
100
|
o.setAttribute("role", "img"),
|
|
99
101
|
o.setAttribute("aria-label", "Modal Image"),
|
|
100
|
-
e.
|
|
101
|
-
|
|
102
|
+
e.Ae(o),
|
|
103
|
+
v.appendChild(o);
|
|
102
104
|
} else {
|
|
103
105
|
const o = document.createElement("img");
|
|
104
106
|
if (
|
|
105
107
|
(o.setAttribute("src", e.imageUrl),
|
|
106
|
-
e.
|
|
108
|
+
e.Ae(o),
|
|
107
109
|
0 === document.querySelectorAll(".ab-iam-img-loading").length)
|
|
108
110
|
) {
|
|
109
|
-
|
|
111
|
+
w = !0;
|
|
110
112
|
const e = document.querySelectorAll(".ab-iam-root");
|
|
111
113
|
e && e.length > 0 && e[0].classList.add("ab-iam-img-loading"),
|
|
112
|
-
(
|
|
113
|
-
|
|
114
|
+
(l = window.setTimeout(() => {
|
|
115
|
+
g(!1);
|
|
114
116
|
}, 6e4)),
|
|
115
117
|
(o.onload = () => {
|
|
116
|
-
|
|
118
|
+
g();
|
|
117
119
|
}),
|
|
118
120
|
(o.onerror = () => {
|
|
119
|
-
|
|
121
|
+
g(!1);
|
|
120
122
|
});
|
|
121
123
|
}
|
|
122
|
-
|
|
124
|
+
v.appendChild(o);
|
|
123
125
|
}
|
|
124
|
-
|
|
126
|
+
c.appendChild(v), (h.className += " ab-with-image");
|
|
125
127
|
} else if (e.icon) {
|
|
126
|
-
|
|
128
|
+
v.className += " ab-icon-area";
|
|
127
129
|
const o = document.createElement("span");
|
|
128
130
|
(o.className = "ab-icon"),
|
|
129
|
-
e.
|
|
131
|
+
e.ve() ||
|
|
130
132
|
((o.style.backgroundColor = ie(e.iconBackgroundColor)),
|
|
131
133
|
(o.style.color = ie(e.iconColor)));
|
|
132
134
|
const a = document.createElement("i");
|
|
@@ -134,55 +136,55 @@ export default function ce(e, o, a, t, n, s, i, l = document.body) {
|
|
|
134
136
|
a.appendChild(document.createTextNode(e.icon)),
|
|
135
137
|
a.setAttribute("aria-hidden", "true"),
|
|
136
138
|
o.appendChild(a),
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
(
|
|
139
|
+
v.appendChild(o),
|
|
140
|
+
c.appendChild(v),
|
|
141
|
+
(h.className += " ab-with-icon");
|
|
140
142
|
}
|
|
141
|
-
if ((oe(
|
|
143
|
+
if ((oe(h, "touchstart"), e.header && e.header.length > 0)) {
|
|
142
144
|
const o = document.createElement("h1");
|
|
143
|
-
(o.className = "ab-message-header"), (e.
|
|
145
|
+
(o.className = "ab-message-header"), (e.De = p.W()), (o.id = e.De);
|
|
144
146
|
const a = (
|
|
145
147
|
e.headerAlignment || InAppMessage.TextAlignment.CENTER
|
|
146
148
|
).toLowerCase();
|
|
147
149
|
(o.className += " " + a + "-aligned"),
|
|
148
|
-
e.
|
|
150
|
+
e.ve() || (o.style.color = ie(e.headerTextColor)),
|
|
149
151
|
o.appendChild(document.createTextNode(e.header)),
|
|
150
|
-
|
|
152
|
+
h.appendChild(o);
|
|
151
153
|
}
|
|
152
|
-
return
|
|
153
|
-
})(e, o, a, t, n, s, l);
|
|
154
|
+
return h.appendChild(e.Ge()), c.appendChild(h), w || b(), (e.Re = c), c;
|
|
155
|
+
})(e, o, a, t, n, s, l, b);
|
|
154
156
|
if (e instanceof FullScreenMessage || e instanceof ModalMessage) {
|
|
155
157
|
const a = e instanceof FullScreenMessage ? "ab-fullscreen" : "ab-modal";
|
|
156
|
-
(
|
|
157
|
-
le.
|
|
158
|
-
le.
|
|
159
|
-
le.
|
|
158
|
+
(g.className += ` ${a} ab-centered`),
|
|
159
|
+
le.He(e, o, g, n),
|
|
160
|
+
le.Je(g),
|
|
161
|
+
le.Ke(e.De, g);
|
|
160
162
|
} else if (e instanceof SlideUpMessage) {
|
|
161
|
-
|
|
162
|
-
const o =
|
|
163
|
+
g.className += " ab-slideup";
|
|
164
|
+
const o = g.getElementsByClassName("ab-close-button")[0];
|
|
163
165
|
if (null != o) {
|
|
164
166
|
const a = ae(
|
|
165
167
|
"0 0 11.38 19.44",
|
|
166
168
|
"M11.38 9.72l-9.33 9.72L0 17.3l7.27-7.58L0 2.14 2.05 0l9.33 9.72z",
|
|
167
|
-
e.
|
|
169
|
+
e.ve() ? void 0 : ie(e.closeButtonColor),
|
|
168
170
|
);
|
|
169
171
|
a.setAttribute("class", "ab-chevron"), o.appendChild(a);
|
|
170
172
|
}
|
|
171
173
|
let a, t;
|
|
172
|
-
c(
|
|
173
|
-
(
|
|
174
|
+
c(g, m.U, (e) => {
|
|
175
|
+
(g.className += " ab-swiped-left"),
|
|
174
176
|
null != o && null != o.onclick && o.onclick(e);
|
|
175
177
|
}),
|
|
176
|
-
c(
|
|
177
|
-
(
|
|
178
|
+
c(g, m.V, (e) => {
|
|
179
|
+
(g.className += " ab-swiped-right"),
|
|
178
180
|
null != o && null != o.onclick && o.onclick(e);
|
|
179
181
|
}),
|
|
180
182
|
e.slideFrom === InAppMessage.SlideFrom.TOP
|
|
181
|
-
? ((a = m.
|
|
182
|
-
: ((a = m.
|
|
183
|
-
c(
|
|
184
|
-
(
|
|
183
|
+
? ((a = m.Oe), (t = " ab-swiped-up"))
|
|
184
|
+
: ((a = m.Qe), (t = " ab-swiped-down")),
|
|
185
|
+
c(g, a, (e) => {
|
|
186
|
+
(g.className += t), null != o && null != o.onclick && o.onclick(e);
|
|
185
187
|
});
|
|
186
188
|
}
|
|
187
|
-
return
|
|
189
|
+
return g;
|
|
188
190
|
}
|
|
@@ -3,9 +3,9 @@ import { _handleBrazeAction as u } from "../../Core/handle-braze-action.js";
|
|
|
3
3
|
import { logInAppMessageButtonClick } from "../log-in-app-message-button-click.js";
|
|
4
4
|
import { toRgba as ie } from "../../util/color-utils.js";
|
|
5
5
|
import { addPassiveEventListener as oe } from "../../util/dom-utils.js";
|
|
6
|
-
import { KeyCodes as
|
|
6
|
+
import { KeyCodes as mt } from "../../util/key-codes.js";
|
|
7
7
|
const le = {
|
|
8
|
-
|
|
8
|
+
Je: (t) => {
|
|
9
9
|
const o = t.querySelectorAll(
|
|
10
10
|
".ab-close-button, .ab-message-text, .ab-message-button",
|
|
11
11
|
);
|
|
@@ -16,7 +16,7 @@ const le = {
|
|
|
16
16
|
s = o[o.length - 1];
|
|
17
17
|
t.addEventListener("keydown", (o) => {
|
|
18
18
|
const a = document.activeElement;
|
|
19
|
-
o.keyCode ===
|
|
19
|
+
o.keyCode === mt.lo &&
|
|
20
20
|
(o.shiftKey || (a !== s && a !== t)
|
|
21
21
|
? !o.shiftKey ||
|
|
22
22
|
(a !== e && a !== t) ||
|
|
@@ -25,20 +25,20 @@ const le = {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
|
-
|
|
28
|
+
Ke: (t, o) => {
|
|
29
29
|
o.setAttribute("role", "dialog"),
|
|
30
30
|
o.setAttribute("aria-modal", "true"),
|
|
31
31
|
o.setAttribute("aria-label", "Modal Message"),
|
|
32
32
|
t && o.setAttribute("aria-labelledby", t);
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
He: (t, o, e, s) => {
|
|
35
35
|
if (t.buttons && t.buttons.length > 0) {
|
|
36
36
|
const a = document.createElement("div");
|
|
37
37
|
(a.className = "ab-message-buttons"), e.appendChild(a);
|
|
38
38
|
const l = e.getElementsByClassName("ab-message-text")[0];
|
|
39
39
|
null != l && (l.className += " ab-with-buttons");
|
|
40
40
|
const n = (a) => (l) => (
|
|
41
|
-
t.
|
|
41
|
+
t.Cr(e, () => {
|
|
42
42
|
logInAppMessageButtonClick(a, t),
|
|
43
43
|
a.clickAction === InAppMessage.ClickAction.URI
|
|
44
44
|
? u(
|
|
@@ -60,7 +60,7 @@ const le = {
|
|
|
60
60
|
let l = e.text;
|
|
61
61
|
"" === e.text && (l = " "),
|
|
62
62
|
s.appendChild(document.createTextNode(l)),
|
|
63
|
-
t.
|
|
63
|
+
t.ve() ||
|
|
64
64
|
((s.style.backgroundColor = ie(e.backgroundColor)),
|
|
65
65
|
(s.style.color = ie(e.textColor)),
|
|
66
66
|
(s.style.borderColor = ie(e.borderColor))),
|
|
@@ -47,7 +47,7 @@ export function newInAppMessageFromJson(e) {
|
|
|
47
47
|
((q = void 0), (B = void 0));
|
|
48
48
|
const C = e.message_extras;
|
|
49
49
|
let D;
|
|
50
|
-
if (o === ModalMessage.it || o === InAppMessage.
|
|
50
|
+
if (o === ModalMessage.it || o === InAppMessage.Be.Ue)
|
|
51
51
|
D = new ModalMessage(
|
|
52
52
|
s,
|
|
53
53
|
n,
|
|
@@ -138,8 +138,8 @@ export function newInAppMessageFromJson(e) {
|
|
|
138
138
|
else {
|
|
139
139
|
if (
|
|
140
140
|
o !== HtmlMessage.it &&
|
|
141
|
-
o !== InAppMessage.
|
|
142
|
-
o !== InAppMessage.
|
|
141
|
+
o !== InAppMessage.Be.Me &&
|
|
142
|
+
o !== InAppMessage.Be.Ve
|
|
143
143
|
)
|
|
144
144
|
return void r.error("Ignoring message with unknown type " + o);
|
|
145
145
|
{
|
|
@@ -148,7 +148,7 @@ export function newInAppMessageFromJson(e) {
|
|
|
148
148
|
(D.trusted = e.trusted || !1);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
return (D.
|
|
151
|
+
return (D.xe = o), D;
|
|
152
152
|
}
|
|
153
153
|
export function buttonsFromSerializedInAppMessage(e) {
|
|
154
154
|
const o = [];
|