@braze/web-sdk 5.9.1 → 6.0.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.
Files changed (159) hide show
  1. package/index.d.ts +109 -253
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +1 -1
  4. package/shared-lib/event-types.js +24 -26
  5. package/shared-lib/guid.js +2 -2
  6. package/shared-lib/indexed-db-adapter.js +19 -19
  7. package/shared-lib/logger.js +2 -2
  8. package/shared-lib/supported-options.js +21 -22
  9. package/src/Banner/display/banner-to-html.js +13 -25
  10. package/src/Banner/display/destroy-banner-html.js +2 -2
  11. package/src/Banner/display/detect-banner-impressions.js +11 -11
  12. package/src/Banner/index.js +0 -1
  13. package/src/Banner/request-banners-refresh.js +8 -8
  14. package/src/Banner/subscribe-to-banners-updates.js +2 -2
  15. package/src/Banner/ui/insert-banner.js +7 -7
  16. package/src/Card/card-manager.js +35 -37
  17. package/src/Card/display/card-display.js +76 -74
  18. package/src/Card/index.js +0 -2
  19. package/src/Card/log-card-dismissal.js +2 -2
  20. package/src/Card/log-content-card-click.js +9 -2
  21. package/src/Card/log-content-card-impressions.js +11 -2
  22. package/src/Card/models/captioned-image.js +20 -20
  23. package/src/Card/models/card.js +110 -104
  24. package/src/Card/models/classic-card.js +20 -20
  25. package/src/Card/models/control-card.js +14 -14
  26. package/src/Card/models/image-only.js +19 -20
  27. package/src/Card/util/card-factory.js +57 -78
  28. package/src/ContentCards/content-cards-provider-factory.js +10 -10
  29. package/src/ContentCards/content-cards-provider.js +109 -109
  30. package/src/ContentCards/content-cards.js +21 -13
  31. package/src/ContentCards/get-cached-content-cards.js +2 -2
  32. package/src/ContentCards/request-content-cards-refresh.js +2 -2
  33. package/src/ContentCards/subscribe-to-content-cards-updates.js +5 -5
  34. package/src/ContentCards/ui/hide-content-cards.js +5 -5
  35. package/src/ContentCards/ui/show-content-cards.js +34 -34
  36. package/src/Core/add-sdk-metadata.js +2 -2
  37. package/src/Core/change-user.js +7 -7
  38. package/src/Core/disable-sdk.js +6 -6
  39. package/src/Core/enable-sdk.js +5 -5
  40. package/src/Core/get-user.js +1 -1
  41. package/src/Core/handle-braze-action.js +7 -7
  42. package/src/Core/is-disabled.js +2 -2
  43. package/src/Core/is-initialized.js +1 -1
  44. package/src/Core/log-custom-event.js +9 -9
  45. package/src/Core/log-purchase.js +7 -7
  46. package/src/Core/open-session.js +12 -12
  47. package/src/Core/request-immediate-data-flush.js +1 -1
  48. package/src/Core/set-sdk-authentication-signature.js +2 -2
  49. package/src/Core/wipe-data.js +7 -7
  50. package/src/FeatureFlags/feature-flag-factory.js +7 -7
  51. package/src/FeatureFlags/feature-flag.js +6 -6
  52. package/src/FeatureFlags/feature-flags-provider-factory.js +9 -9
  53. package/src/FeatureFlags/feature-flags-provider.js +1 -1
  54. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  55. package/src/FeatureFlags/get-feature-flag.js +2 -2
  56. package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
  57. package/src/FeatureFlags/refresh-feature-flags.js +2 -2
  58. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
  59. package/src/InAppMessage/defer-in-app-message.js +1 -1
  60. package/src/InAppMessage/display/html-message-to-html.js +37 -37
  61. package/src/InAppMessage/display/in-app-message-to-html.js +139 -133
  62. package/src/InAppMessage/display/modal-utils.js +39 -41
  63. package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
  64. package/src/InAppMessage/in-app-message-factory.js +22 -14
  65. package/src/InAppMessage/in-app-message-manager.js +90 -88
  66. package/src/InAppMessage/log-in-app-message-button-click.js +5 -5
  67. package/src/InAppMessage/log-in-app-message-click.js +5 -5
  68. package/src/InAppMessage/log-in-app-message-html-click.js +5 -5
  69. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  70. package/src/InAppMessage/models/control-message.js +2 -2
  71. package/src/InAppMessage/models/full-screen-message.js +40 -34
  72. package/src/InAppMessage/models/html-message.js +23 -21
  73. package/src/InAppMessage/models/in-app-message-button.js +2 -2
  74. package/src/InAppMessage/models/in-app-message.js +137 -133
  75. package/src/InAppMessage/models/modal-message.js +39 -33
  76. package/src/InAppMessage/models/slide-up-message.js +36 -30
  77. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  78. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  79. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  80. package/src/InAppMessage/ui/show-in-app-message.js +56 -62
  81. package/src/Push/is-push-blocked.js +2 -2
  82. package/src/Push/is-push-permission-granted.js +2 -2
  83. package/src/Push/is-push-supported.js +2 -2
  84. package/src/Push/push-manager-factory.js +8 -8
  85. package/src/Push/push-manager.js +90 -90
  86. package/src/Push/request-push-permission.js +1 -1
  87. package/src/Push/utils/push-utils.js +25 -15
  88. package/src/User/user-manager.js +14 -14
  89. package/src/User/user.js +55 -55
  90. package/src/common/content-cards-display.js +211 -0
  91. package/src/common/event-logger.js +6 -6
  92. package/src/index.js +0 -1
  93. package/src/l10n/l10n-manager-factory.js +9 -9
  94. package/src/l10n/l10n-manager.js +6 -6
  95. package/src/managers/auth-manager.js +27 -27
  96. package/src/managers/braze-instance.js +136 -137
  97. package/src/managers/device-manager.js +22 -22
  98. package/src/managers/network-manager.js +180 -183
  99. package/src/managers/server-config-manager.js +63 -63
  100. package/src/managers/session-manager.js +34 -34
  101. package/src/managers/storage-manager-factory.js +11 -11
  102. package/src/managers/storage-manager.js +139 -141
  103. package/src/managers/subscription-manager.js +3 -3
  104. package/src/managers/utils.js +1 -1
  105. package/src/models/backend-errors.js +5 -5
  106. package/src/models/braze-event.js +15 -15
  107. package/src/models/device.js +3 -3
  108. package/src/models/identifier.js +13 -13
  109. package/src/models/push-token.js +12 -12
  110. package/src/models/request-result.js +2 -2
  111. package/src/models/server-config.js +29 -29
  112. package/src/request-controller.js +175 -174
  113. package/src/triggers/models/custom-event-data.js +6 -6
  114. package/src/triggers/models/custom-event-property-data.js +7 -7
  115. package/src/triggers/models/filter-set.js +8 -8
  116. package/src/triggers/models/filter.js +45 -45
  117. package/src/triggers/models/in-app-message-click-data.js +3 -3
  118. package/src/triggers/models/purchase-data.js +1 -1
  119. package/src/triggers/models/purchase-property-data.js +4 -4
  120. package/src/triggers/models/push-click-data.js +1 -1
  121. package/src/triggers/models/trigger-condition.js +47 -47
  122. package/src/triggers/models/trigger-events.js +3 -3
  123. package/src/triggers/models/trigger.js +15 -15
  124. package/src/triggers/triggers-provider-factory.js +4 -4
  125. package/src/triggers/triggers-provider.js +44 -44
  126. package/src/ui/js/attach-css.js +3 -3
  127. package/src/ui/js/banner-css.js +1 -1
  128. package/src/ui/js/iam-css.js +1 -1
  129. package/src/ui/js/load-font-awesome.js +2 -2
  130. package/src/util/base-device-parser.js +4 -4
  131. package/src/util/braze-actions.js +8 -14
  132. package/src/util/browser-detector.js +12 -12
  133. package/src/util/client-hints-parser.js +3 -3
  134. package/src/util/component-utils.js +14 -14
  135. package/src/util/device-constants.js +1 -1
  136. package/src/util/dom-utils.js +6 -6
  137. package/src/util/html-display-utils.js +37 -37
  138. package/src/util/key-codes.js +1 -1
  139. package/src/util/net.js +1 -1
  140. package/src/util/request-header-utils.js +17 -17
  141. package/src/util/user-agent-parser.js +4 -4
  142. package/src/util/validation-utils.js +20 -20
  143. package/src/util/window-utils.js +1 -1
  144. package/src/Card/log-card-click.js +0 -11
  145. package/src/Card/log-card-impressions.js +0 -13
  146. package/src/Feed/feed-provider-factory.js +0 -18
  147. package/src/Feed/feed-provider.js +0 -90
  148. package/src/Feed/feed.js +0 -20
  149. package/src/Feed/get-cached-feed.js +0 -5
  150. package/src/Feed/index.js +0 -8
  151. package/src/Feed/log-feed-displayed.js +0 -7
  152. package/src/Feed/request-feed-refresh.js +0 -5
  153. package/src/Feed/subscribe-to-feed-updates.js +0 -5
  154. package/src/Feed/types.js +0 -1
  155. package/src/Feed/ui/hide-feed.js +0 -7
  156. package/src/Feed/ui/show-feed.js +0 -96
  157. package/src/Feed/ui/toggle-feed.js +0 -8
  158. package/src/common/base-feed.js +0 -29
  159. package/src/common/feed-display.js +0 -211
@@ -7,9 +7,9 @@ export function automaticallyShowInAppMessages() {
7
7
  if (!r.rr()) return;
8
8
  ss();
9
9
  const s = se.ea();
10
- if (null == s.Hi()) {
10
+ if (null == s.Pi()) {
11
11
  const r = subscribeToInAppMessage((s) => showInAppMessage(s));
12
- s.Ji(r);
12
+ s.Gi(r);
13
13
  }
14
- return s.Hi();
14
+ return s.Pi();
15
15
  }
@@ -1,24 +1,23 @@
1
- import r, { OPTIONS as w } from "../../managers/braze-instance.js";
1
+ import r, { OPTIONS as z } from "../../managers/braze-instance.js";
2
2
  import ControlMessage from "../models/control-message.js";
3
3
  import HtmlMessage from "../models/html-message.js";
4
4
  import InAppMessage from "../models/in-app-message.js";
5
5
  import SlideUpMessage from "../models/slide-up-message.js";
6
6
  import me from "../display/get-animation-effect.js";
7
- import de from "../display/in-app-message-to-html.js";
7
+ import le from "../display/in-app-message-to-html.js";
8
8
  import { logInAppMessageImpression } from "../log-in-app-message-impression.js";
9
9
  import {
10
- ORIENTATION as fe,
10
+ ORIENTATION as pe,
11
11
  WindowUtils as no,
12
12
  } from "../../util/window-utils.js";
13
- import { isURIJavascriptOrData as Y } from "../../util/url-utils.js";
14
- import { KeyCodes as bt } from "../../util/key-codes.js";
13
+ import { isURIJavascriptOrData as tt } from "../../util/url-utils.js";
14
+ import { KeyCodes as ie } from "../../util/key-codes.js";
15
15
  import { setupInAppMessageUI as ss } from "../../ui/js/index.js";
16
16
  import { logger as N } from "../../../shared-lib/index.js";
17
- import { toRgba as le } from "../../util/color-utils.js";
18
- import { BRAZE_MUST_BE_INITIALIZED_ERROR as p } from "../../common/constants.js";
19
- import { isIFrame as It } from "../utils/in-app-message-utils.js";
20
- import ge from "../../l10n/l10n-manager-factory.js";
21
- export function showInAppMessage(e, t, o) {
17
+ import { toRgba as ae } from "../../util/color-utils.js";
18
+ import { isIFrame as At } from "../utils/in-app-message-utils.js";
19
+ import fe from "../../l10n/l10n-manager-factory.js";
20
+ export function showInAppMessage(e, t, s) {
22
21
  if (!r.rr()) return;
23
22
  if ((ss(), null == e)) return !1;
24
23
  if (e instanceof ControlMessage)
@@ -31,9 +30,9 @@ export function showInAppMessage(e, t, o) {
31
30
  );
32
31
  if (!(e instanceof InAppMessage)) return !1;
33
32
  if (e.constructor === InAppMessage) return !1;
34
- e.Lh();
35
- const s = e instanceof HtmlMessage;
36
- if (s && !e.trusted && !r.tr())
33
+ e._h();
34
+ const o = e instanceof HtmlMessage;
35
+ if (o && !e.trusted && !r.tr())
37
36
  return (
38
37
  N.error(
39
38
  'HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.',
@@ -52,19 +51,19 @@ export function showInAppMessage(e, t, o) {
52
51
  if (no.Uo()) {
53
52
  const t = no.No();
54
53
  if (
55
- (t === fe.PORTRAIT &&
54
+ (t === pe.PORTRAIT &&
56
55
  e.orientation === InAppMessage.Orientation.LANDSCAPE) ||
57
- (t === fe.LANDSCAPE &&
56
+ (t === pe.LANDSCAPE &&
58
57
  e.orientation === InAppMessage.Orientation.PORTRAIT)
59
58
  ) {
60
- const o = t === fe.PORTRAIT ? "portrait" : "landscape",
61
- s =
59
+ const s = t === pe.PORTRAIT ? "portrait" : "landscape",
60
+ o =
62
61
  e.orientation === InAppMessage.Orientation.PORTRAIT
63
62
  ? "portrait"
64
63
  : "landscape";
65
64
  return (
66
65
  N.info(
67
- `Not showing ${s} in-app message ${e.message} because the screen is currently ${o}`,
66
+ `Not showing ${o} in-app message ${e.message} because the screen is currently ${s}`,
68
67
  ),
69
68
  !1
70
69
  );
@@ -73,13 +72,13 @@ export function showInAppMessage(e, t, o) {
73
72
  if (!r.tr()) {
74
73
  let t = !1;
75
74
  if (e.buttons && e.buttons.length > 0) {
76
- const o = e.buttons;
77
- for (let e = 0; e < o.length; e++)
78
- if (o[e].clickAction === InAppMessage.ClickAction.URI) {
79
- const s = o[e].uri;
80
- t = Y(s);
75
+ const s = e.buttons;
76
+ for (let e = 0; e < s.length; e++)
77
+ if (s[e].clickAction === InAppMessage.ClickAction.URI) {
78
+ const o = s[e].uri;
79
+ t = tt(o);
81
80
  }
82
- } else e.clickAction === InAppMessage.ClickAction.URI && (t = Y(e.uri));
81
+ } else e.clickAction === InAppMessage.ClickAction.URI && (t = tt(e.uri));
83
82
  if (t)
84
83
  return (
85
84
  N.error(
@@ -92,69 +91,64 @@ export function showInAppMessage(e, t, o) {
92
91
  if (
93
92
  ((i.className = "ab-iam-root v3"),
94
93
  (i.className += me(e)),
95
- i.setAttribute("role", "complementary"),
96
- e.ho() && (i.id = e.htmlId),
97
- r.ee(w.Go) && (i.style.zIndex = (r.ee(w.Go) + 1).toString()),
94
+ e.language && !o && (i.lang = e.language),
95
+ e.jo() && (i.id = e.htmlId),
96
+ r.ee(z.Ko) && (i.style.zIndex = (r.ee(z.Ko) + 1).toString()),
98
97
  t.appendChild(i),
99
98
  e.lo())
100
99
  ) {
101
100
  const t = document.createElement("style");
102
101
  (t.innerHTML = e.css),
103
102
  (t.id = e.do()),
104
- null != r.ee(w.er) && t.setAttribute("nonce", r.ee(w.er)),
103
+ null != r.ee(z.er) && t.setAttribute("nonce", r.ee(z.er)),
105
104
  document.getElementsByTagName("head")[0].appendChild(t);
106
105
  }
107
106
  const n = e instanceof SlideUpMessage,
108
- a = de(
107
+ a = le(
109
108
  e,
110
- () => {
111
- import("../../Feed/ui/show-feed.js").then((e) => {
112
- r.nn() ? e.showFeed() : N.error(p);
113
- });
114
- },
115
109
  (t) => {
116
110
  if (e.vo() && e.Po()) {
117
- const o = document.createElement("div");
111
+ const s = document.createElement("div");
118
112
  if (
119
- ((o.className = "ab-page-blocker"),
120
- e.lo() || (o.style.backgroundColor = le(e.frameColor)),
121
- r.ee(w.Go) && (o.style.zIndex = r.ee(w.Go).toString()),
122
- i.appendChild(o),
123
- !r.ee(w.mh))
113
+ ((s.className = "ab-page-blocker"),
114
+ e.lo() || (s.style.backgroundColor = ae(e.frameColor)),
115
+ r.ee(z.Ko) && (s.style.zIndex = r.ee(z.Ko).toString()),
116
+ i.appendChild(s),
117
+ !r.ee(z.Lh))
124
118
  ) {
125
- const s = new Date().valueOf();
126
- o.onclick = (o) => {
127
- new Date().valueOf() - s > InAppMessage.ph &&
128
- (e.ll(t), o.stopPropagation());
119
+ const o = new Date().valueOf();
120
+ s.onclick = (s) => {
121
+ new Date().valueOf() - o > InAppMessage.Ph &&
122
+ (e.ll(t), s.stopPropagation());
129
123
  };
130
124
  }
131
125
  i.appendChild(t), t.focus(), e.Ah(i);
132
126
  } else if (n) {
133
- const o = document.querySelectorAll(".ab-slideup");
134
- let s = null;
135
- for (let e = o.length - 1; e >= 0; e--)
136
- if (o[e] !== t) {
137
- s = o[e];
127
+ const s = document.querySelectorAll(".ab-slideup");
128
+ let o = null;
129
+ for (let e = s.length - 1; e >= 0; e--)
130
+ if (s[e] !== t) {
131
+ o = s[e];
138
132
  break;
139
133
  }
140
134
  if (e.slideFrom === InAppMessage.SlideFrom.TOP) {
141
135
  let e = 0;
142
- null != s && (e = s.offsetTop + s.offsetHeight),
136
+ null != o && (e = o.offsetTop + o.offsetHeight),
143
137
  (t.style.top = Math.max(e, 0) + "px");
144
138
  } else {
145
139
  let e = 0;
146
- null != s &&
140
+ null != o &&
147
141
  (e =
148
142
  (window.innerHeight || document.documentElement.clientHeight) -
149
- s.offsetTop),
143
+ o.offsetTop),
150
144
  (t.style.bottom = Math.max(e, 0) + "px");
151
145
  }
152
- } else if (s && !r.ee(w.mh)) {
153
- const o = e;
154
- It(t) &&
146
+ } else if (o && !r.ee(z.Lh)) {
147
+ const s = e;
148
+ At(t) &&
155
149
  t.contentWindow &&
156
150
  t.contentWindow.addEventListener("keydown", function (e) {
157
- e.keyCode === bt._h && o.closeMessage();
151
+ e.keyCode === ie.Oh && s.closeMessage();
158
152
  });
159
153
  }
160
154
  logInAppMessageImpression(e),
@@ -162,16 +156,16 @@ export function showInAppMessage(e, t, o) {
162
156
  setTimeout(() => {
163
157
  i.contains(t) && e.ll(t);
164
158
  }, e.duration),
165
- "function" == typeof o && o();
159
+ "function" == typeof s && s();
166
160
  },
167
161
  (e) => {
168
162
  N.info(e);
169
163
  },
170
- r.ee(w.Ko),
171
- r.ee(w.Go),
172
- r.ee(w.er),
164
+ r.ee(z.Qo),
165
+ r.ee(z.Ko),
166
+ r.ee(z.er),
173
167
  t,
174
- ge.ea().Oo(),
168
+ fe.ea().Ro(),
175
169
  );
176
- return (s || n) && (i.appendChild(a), e.Ah(i)), !0;
170
+ return (o || n) && (i.appendChild(a), e.Ah(i)), !0;
177
171
  }
@@ -1,5 +1,5 @@
1
1
  import r from "../managers/braze-instance.js";
2
- import vt from "./utils/push-utils.js";
2
+ import yt from "./utils/push-utils.js";
3
3
  export function isPushBlocked() {
4
- if (r.rr()) return vt.isPushBlocked();
4
+ if (r.rr()) return yt.isPushBlocked();
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import r from "../managers/braze-instance.js";
2
- import vt from "./utils/push-utils.js";
2
+ import yt from "./utils/push-utils.js";
3
3
  export function isPushPermissionGranted() {
4
- if (r.rr()) return vt.isPushPermissionGranted();
4
+ if (r.rr()) return yt.isPushPermissionGranted();
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import r from "../managers/braze-instance.js";
2
- import vt from "./utils/push-utils.js";
2
+ import yt from "./utils/push-utils.js";
3
3
  export function isPushSupported() {
4
- if (r.rr()) return vt.isPushSupported();
4
+ if (r.rr()) return yt.isPushSupported();
5
5
  }
@@ -1,4 +1,4 @@
1
- import r, { OPTIONS as w } from "../managers/braze-instance.js";
1
+ import r, { OPTIONS as z } from "../managers/braze-instance.js";
2
2
  import na from "./push-manager.js";
3
3
  const ra = {
4
4
  l: !1,
@@ -7,16 +7,16 @@ const ra = {
7
7
  ra.p(),
8
8
  ra.aa ||
9
9
  (ra.aa = new na(
10
- r.mr(),
11
- r.Ma(),
10
+ r.gr(),
11
+ r.ba(),
12
12
  r.ue(),
13
13
  r.Z(),
14
- r.ee(w._a),
15
- r.ee(w.Aa),
16
- r.ee(w.Ba),
14
+ r.ee(z.Ma),
15
+ r.ee(z._a),
16
+ r.ee(z.ka),
17
17
  r.v(),
18
- r.ee(w.Ca),
19
- r.ee(w.Da),
18
+ r.ee(z.qa),
19
+ r.ee(z.Aa),
20
20
  r.j(),
21
21
  )),
22
22
  ra.aa
@@ -1,43 +1,43 @@
1
- import { isArray as z, isEqual as ii } from "../util/code-utils.js";
1
+ import { isArray as D, isEqual as ii } from "../util/code-utils.js";
2
2
  import ti from "../models/push-token.js";
3
3
  import { logger as N, EncodingUtils as ei } from "../../shared-lib/index.js";
4
4
  import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
5
5
  import { User } from "../User/index.js";
6
- import vt from "./utils/push-utils.js";
6
+ import yt from "./utils/push-utils.js";
7
7
  import { getErrorMessage as si } from "../util/error-utils.js";
8
8
  export default class na {
9
9
  constructor(i, t, e, s, r, n, o, u, a, h, c) {
10
- (this.un = i),
11
- (this.an = t),
12
- (this.hn = e),
13
- (this.cn = r),
14
- (this.fn = n),
15
- (this.ln = o),
10
+ (this.sn = i),
11
+ (this.on = t),
12
+ (this.un = e),
13
+ (this.an = r),
14
+ (this.hn = n),
15
+ (this.cn = o),
16
16
  (this.B = u),
17
- (this.dn = a),
18
- (this.pn = h),
17
+ (this.fn = a),
18
+ (this.ln = h),
19
19
  (this.C = c),
20
- (this.un = i),
21
- (this.an = t),
22
- (this.hn = e),
23
- (this.bn = s + "/safari/" + t),
24
- (this.cn = r || "/service-worker.js"),
25
- (this.ln = o),
20
+ (this.sn = i),
21
+ (this.on = t),
22
+ (this.un = e),
23
+ (this.dn = s + "/safari/" + t),
24
+ (this.an = r || "/service-worker.js"),
25
+ (this.cn = o),
26
26
  (this.B = u),
27
- (this.dn = a || !1),
28
- (this.pn = h || !1),
27
+ (this.fn = a || !1),
28
+ (this.ln = h || !1),
29
29
  (this.C = c),
30
- (this.yn = vt.mn()),
31
- (this.gn = vt.vn());
30
+ (this.pn = yt.bn()),
31
+ (this.yn = yt.mn());
32
32
  }
33
- wn() {
34
- return this.pn;
33
+ gn() {
34
+ return this.ln;
35
35
  }
36
- kn(i, t, e, s, r) {
36
+ vn(i, t, e, s, r) {
37
37
  i.unsubscribe()
38
38
  .then((i) => {
39
39
  i
40
- ? this.Pn(t, e, s, r)
40
+ ? this.wn(t, e, s, r)
41
41
  : (N.error("Failed to unsubscribe device from push."),
42
42
  "function" == typeof r && r(!1));
43
43
  })
@@ -46,7 +46,7 @@ export default class na {
46
46
  "function" == typeof r && r(!1);
47
47
  });
48
48
  }
49
- Dn(i, t, e) {
49
+ kn(i, t, e) {
50
50
  var s;
51
51
  const r = ((i) => {
52
52
  if ("string" == typeof i) return i;
@@ -55,9 +55,9 @@ export default class na {
55
55
  let t = i.endpoint;
56
56
  const e = i;
57
57
  return (
58
- e.Sn &&
59
- -1 === i.endpoint.indexOf(e.Sn) &&
60
- (t = i.endpoint + "/" + e.Sn),
58
+ e.Pn &&
59
+ -1 === i.endpoint.indexOf(e.Pn) &&
60
+ (t = i.endpoint + "/" + e.Pn),
61
61
  t
62
62
  );
63
63
  })(i);
@@ -84,53 +84,53 @@ export default class na {
84
84
  .replace(/\//g, "_")
85
85
  : null;
86
86
  })(u);
87
- null === (s = this.un) || void 0 === s || s.An(r, t, n, o, a),
87
+ null === (s = this.sn) || void 0 === s || s.Dn(r, t, n, o, a),
88
88
  r && "function" == typeof e && e(r, n, o);
89
89
  }
90
- jn() {
90
+ Sn() {
91
91
  var i;
92
- null === (i = this.un) || void 0 === i || i.xn(!0);
92
+ null === (i = this.sn) || void 0 === i || i.An(!0);
93
93
  }
94
- Nn(i, t) {
94
+ jn(i, t) {
95
95
  var e;
96
- null === (e = this.un) || void 0 === e || e.xn(!1),
96
+ null === (e = this.sn) || void 0 === e || e.An(!1),
97
97
  N.info(i),
98
98
  "function" == typeof t && t(!1);
99
99
  }
100
- Un(i, t, e, s) {
100
+ xn(i, t, e, s) {
101
101
  var r;
102
102
  if ("default" === t.permission)
103
103
  try {
104
104
  window.safari.pushNotification.requestPermission(
105
- this.bn,
105
+ this.dn,
106
106
  i,
107
107
  {
108
- api_key: this.an,
108
+ api_key: this.on,
109
109
  device_id:
110
- (null === (r = this.hn) || void 0 === r ? void 0 : r.ve().id) ||
110
+ (null === (r = this.un) || void 0 === r ? void 0 : r.ve().id) ||
111
111
  "",
112
112
  },
113
113
  (t) => {
114
114
  "granted" === t.permission &&
115
- this.un &&
116
- this.un.setPushNotificationSubscriptionType(
115
+ this.sn &&
116
+ this.sn.setPushNotificationSubscriptionType(
117
117
  User.NotificationSubscriptionTypes.OPTED_IN,
118
118
  ),
119
- this.Un(i, t, e, s);
119
+ this.xn(i, t, e, s);
120
120
  },
121
121
  );
122
122
  } catch (i) {
123
- this.Nn("Could not request permission for push: " + i, s);
123
+ this.jn("Could not request permission for push: " + i, s);
124
124
  }
125
125
  else
126
126
  "denied" === t.permission
127
- ? this.Nn(
127
+ ? this.jn(
128
128
  "The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",
129
129
  s,
130
130
  )
131
131
  : "granted" === t.permission &&
132
132
  (N.info("Device successfully subscribed to push."),
133
- this.Dn(t.deviceToken, new Date(), e));
133
+ this.kn(t.deviceToken, new Date(), e));
134
134
  }
135
135
  requestPermission(i, t, e) {
136
136
  const s = (s) => {
@@ -159,27 +159,27 @@ export default class na {
159
159
  : (r = !0);
160
160
  }
161
161
  }
162
- Pn(i, t, e, s) {
162
+ wn(i, t, e, s) {
163
163
  const r = { userVisibleOnly: !0 };
164
164
  null != t && (r.applicationServerKey = t),
165
165
  i.pushManager
166
166
  .subscribe(r)
167
167
  .then((i) => {
168
168
  N.info("Device successfully subscribed to push."),
169
- this.Dn(i, new Date(), e);
169
+ this.kn(i, new Date(), e);
170
170
  })
171
171
  .catch((i) => {
172
- vt.isPushBlocked()
172
+ yt.isPushBlocked()
173
173
  ? (N.info("Permission for push notifications was denied."),
174
174
  "function" == typeof s && s(!1))
175
175
  : (N.error("Push subscription failed: " + i),
176
176
  "function" == typeof s && s(!0));
177
177
  });
178
178
  }
179
- Wn() {
180
- if (this.dn) return navigator.serviceWorker.getRegistration(this.cn);
181
- const i = this.fn ? { scope: this.fn } : void 0;
182
- return navigator.serviceWorker.register(this.cn, i).then(() =>
179
+ Nn() {
180
+ if (this.fn) return navigator.serviceWorker.getRegistration(this.an);
181
+ const i = this.hn ? { scope: this.hn } : void 0;
182
+ return navigator.serviceWorker.register(this.an, i).then(() =>
183
183
  navigator.serviceWorker.ready.then(
184
184
  (i) => (
185
185
  i &&
@@ -192,32 +192,32 @@ export default class na {
192
192
  ),
193
193
  );
194
194
  }
195
- _n(i) {
196
- this.dn ||
195
+ Un(i) {
196
+ this.fn ||
197
197
  (i.unregister(), N.info("Service worker successfully unregistered."));
198
198
  }
199
199
  subscribe(i, t) {
200
- if (!vt.isPushSupported())
201
- return N.info(na.Tn), void ("function" == typeof t && t(!1));
202
- if (this.yn) {
203
- if (!this.dn && null != window.location) {
204
- let i = this.cn;
200
+ if (!yt.isPushSupported())
201
+ return N.info(na.Wn), void ("function" == typeof t && t(!1));
202
+ if (this.pn) {
203
+ if (!this.fn && null != window.location) {
204
+ let i = this.an;
205
205
  -1 === i.indexOf(window.location.host) &&
206
206
  (i = window.location.host + i),
207
207
  -1 === i.indexOf(window.location.protocol) &&
208
208
  (i = window.location.protocol + "//" + i);
209
209
  }
210
- if (vt.isPushBlocked())
211
- return void this.Nn(
210
+ if (yt.isPushBlocked())
211
+ return void this.jn(
212
212
  "Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
213
213
  t,
214
214
  );
215
- if (this.B && !this.B.In() && 0 === this.B.Et())
215
+ if (this.B && !this.B._n() && 0 === this.B.Et())
216
216
  return (
217
217
  N.info(
218
218
  "Waiting for VAPID key from server config before subscribing to push.",
219
219
  ),
220
- void this.B.Vn(() => {
220
+ void this.B.Tn(() => {
221
221
  this.subscribe(i, t);
222
222
  })
223
223
  );
@@ -227,20 +227,20 @@ export default class na {
227
227
  },
228
228
  r = () => {
229
229
  let i = "Permission for push notifications was ignored.";
230
- vt.isPushBlocked() &&
230
+ yt.isPushBlocked() &&
231
231
  (i +=
232
232
  " The browser has automatically blocked further permission requests for a period (probably 1 week)."),
233
233
  N.info(i),
234
234
  "function" == typeof t && t(!0);
235
235
  },
236
- n = vt.isPushPermissionGranted(),
236
+ n = yt.isPushPermissionGranted(),
237
237
  o = () => {
238
238
  !n &&
239
- this.un &&
240
- this.un.setPushNotificationSubscriptionType(
239
+ this.sn &&
240
+ this.sn.setPushNotificationSubscriptionType(
241
241
  User.NotificationSubscriptionTypes.OPTED_IN,
242
242
  ),
243
- this.Wn()
243
+ this.Nn()
244
244
  .then((e) => {
245
245
  if (null == e)
246
246
  return (
@@ -258,16 +258,16 @@ export default class na {
258
258
  (null !=
259
259
  (null === (n = this.B) || void 0 === n
260
260
  ? void 0
261
- : n.In()) && (o = ei.qn(this.B.In())),
261
+ : n._n()) && (o = ei.In(this.B._n())),
262
262
  r)
263
263
  ) {
264
264
  let n,
265
265
  u = null,
266
266
  a = null;
267
- if ((this.C && (n = this.C.ft(s.gt.zn)), n && !z(n))) {
267
+ if ((this.C && (n = this.C.ft(s.gt.Vn)), n && !D(n))) {
268
268
  let i;
269
269
  try {
270
- i = ti.Rn(n).En;
270
+ i = ti.zn(n).qn;
271
271
  } catch (t) {
272
272
  i = null;
273
273
  }
@@ -291,31 +291,31 @@ export default class na {
291
291
  : N.info(
292
292
  "Attempting to upgrade a gcm_sender_id-based push registration to VAPID - depending on the browser this may or may not result in the same gcm_sender_id-based subscription.",
293
293
  ),
294
- this.kn(r, e, o, i, t))
294
+ this.vn(r, e, o, i, t))
295
295
  : r.expirationTime &&
296
296
  new Date(r.expirationTime).valueOf() <=
297
297
  new Date().valueOf()
298
298
  ? (N.info(
299
299
  "Push subscription is expired, creating new subscription.",
300
300
  ),
301
- this.kn(r, e, o, i, t))
302
- : n && z(n)
303
- ? this.kn(r, e, o, i, t)
301
+ this.vn(r, e, o, i, t))
302
+ : n && D(n)
303
+ ? this.vn(r, e, o, i, t)
304
304
  : null == a
305
305
  ? (N.info(
306
306
  "No push subscription creation date found, creating new subscription.",
307
307
  ),
308
- this.kn(r, e, o, i, t))
308
+ this.vn(r, e, o, i, t))
309
309
  : a.valueOf() <= new Date().valueOf()
310
310
  ? (N.info(
311
311
  "Push subscription older than 6 months, creating new subscription.",
312
312
  ),
313
- this.kn(r, e, o, i, t))
313
+ this.vn(r, e, o, i, t))
314
314
  : (N.info(
315
315
  "Device already subscribed to push, sending existing subscription to backend.",
316
316
  ),
317
- this.Dn(r, u, i));
318
- } else this.Pn(e, o, i, t);
317
+ this.kn(r, u, i));
318
+ } else this.wn(e, o, i, t);
319
319
  })
320
320
  .catch((i) => {
321
321
  N.error("Error checking current push subscriptions: " + i);
@@ -326,29 +326,29 @@ export default class na {
326
326
  });
327
327
  };
328
328
  this.requestPermission(o, r, e);
329
- } else if (this.gn) {
330
- if (null == this.ln || "" === this.ln)
329
+ } else if (this.yn) {
330
+ if (null == this.cn || "" === this.cn)
331
331
  return (
332
332
  N.error(
333
333
  "You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari",
334
334
  ),
335
335
  void ("function" == typeof t && t(!0))
336
336
  );
337
- const e = window.safari.pushNotification.permission(this.ln);
338
- this.Un(this.ln, e, i, t);
337
+ const e = window.safari.pushNotification.permission(this.cn);
338
+ this.xn(this.cn, e, i, t);
339
339
  }
340
340
  }
341
341
  unsubscribe(i, t) {
342
- if (!vt.isPushSupported())
343
- return N.info(na.Tn), void ("function" == typeof t && t());
344
- this.yn
345
- ? navigator.serviceWorker.getRegistration(this.cn).then((e) => {
342
+ if (!yt.isPushSupported())
343
+ return N.info(na.Wn), void ("function" == typeof t && t());
344
+ this.pn
345
+ ? navigator.serviceWorker.getRegistration(this.an).then((e) => {
346
346
  e
347
347
  ? e.pushManager
348
348
  .getSubscription()
349
349
  .then((s) => {
350
350
  s
351
- ? (this.jn(),
351
+ ? (this.Sn(),
352
352
  s
353
353
  .unsubscribe()
354
354
  .then((s) => {
@@ -361,7 +361,7 @@ export default class na {
361
361
  "Failed to unsubscribe device from push.",
362
362
  ),
363
363
  "function" == typeof t && t()),
364
- this._n(e);
364
+ this.Un(e);
365
365
  })
366
366
  .catch((i) => {
367
367
  N.error("Push unsubscription error: " + i),
@@ -377,10 +377,10 @@ export default class na {
377
377
  : (N.info("Device already unsubscribed from push."),
378
378
  "function" == typeof i && i());
379
379
  })
380
- : this.gn &&
381
- (this.jn(),
380
+ : this.yn &&
381
+ (this.Sn(),
382
382
  N.info("Device unsubscribed from push."),
383
383
  "function" == typeof i && i());
384
384
  }
385
385
  }
386
- na.Tn = "Push notifications are not supported in this browser.";
386
+ na.Wn = "Push notifications are not supported in this browser.";