@braze/web-sdk 5.5.0 → 5.6.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 (183) hide show
  1. package/index.d.ts +109 -7
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +1 -1
  4. package/shared-lib/event-types.js +33 -31
  5. package/shared-lib/guid.js +3 -3
  6. package/shared-lib/indexed-db-adapter.js +20 -20
  7. package/shared-lib/logger.js +18 -18
  8. package/shared-lib/supported-options.js +24 -24
  9. package/src/Banner/banner-factory.js +14 -0
  10. package/src/Banner/banner-provider-factory.js +19 -0
  11. package/src/Banner/banner-provider.js +198 -0
  12. package/src/Banner/banner.js +30 -0
  13. package/src/Banner/display/banner-to-html.js +57 -0
  14. package/src/Banner/display/destroy-banner-html.js +7 -0
  15. package/src/Banner/display/detect-banner-impressions.js +28 -0
  16. package/src/Banner/get-all-banners.js +13 -0
  17. package/src/Banner/get-banner.js +19 -0
  18. package/src/Banner/index.js +7 -0
  19. package/src/Banner/log-banner-click.js +22 -0
  20. package/src/Banner/log-banner-impressions.js +31 -0
  21. package/src/Banner/request-banners-refresh.js +35 -0
  22. package/src/Banner/subscribe-to-banners-updates.js +23 -0
  23. package/src/Banner/types.js +1 -0
  24. package/src/Banner/ui/insert-banner.js +24 -0
  25. package/src/Card/card-manager-factory.js +10 -10
  26. package/src/Card/card-manager.js +54 -52
  27. package/src/Card/display/card-display.js +77 -91
  28. package/src/Card/log-card-click.js +6 -6
  29. package/src/Card/log-card-dismissal.js +6 -5
  30. package/src/Card/log-card-impressions.js +11 -11
  31. package/src/Card/models/captioned-image.js +21 -21
  32. package/src/Card/models/card.js +99 -99
  33. package/src/Card/models/classic-card.js +21 -21
  34. package/src/Card/models/control-card.js +11 -11
  35. package/src/Card/models/image-only.js +19 -19
  36. package/src/Card/util/card-factory.js +58 -58
  37. package/src/ContentCards/content-cards-provider-factory.js +14 -14
  38. package/src/ContentCards/content-cards-provider.js +261 -263
  39. package/src/ContentCards/content-cards.js +5 -5
  40. package/src/ContentCards/get-cached-content-cards.js +3 -3
  41. package/src/ContentCards/request-content-cards-refresh.js +4 -4
  42. package/src/ContentCards/subscribe-to-content-cards-updates.js +13 -13
  43. package/src/ContentCards/ui/hide-content-cards.js +7 -7
  44. package/src/ContentCards/ui/show-content-cards.js +52 -52
  45. package/src/ContentCards/ui/toggle-content-cards.js +4 -4
  46. package/src/Core/add-sdk-metadata.js +9 -9
  47. package/src/Core/change-user.js +14 -14
  48. package/src/Core/destroy.js +3 -3
  49. package/src/Core/disable-sdk.js +13 -13
  50. package/src/Core/enable-sdk.js +9 -9
  51. package/src/Core/get-device-id.js +10 -10
  52. package/src/Core/get-user.js +2 -2
  53. package/src/Core/handle-braze-action.js +53 -53
  54. package/src/Core/initialize.js +2 -2
  55. package/src/Core/is-disabled.js +2 -2
  56. package/src/Core/is-initialized.js +2 -2
  57. package/src/Core/log-custom-event.js +27 -27
  58. package/src/Core/log-purchase.js +38 -38
  59. package/src/Core/open-session.js +18 -18
  60. package/src/Core/remove-all-subscriptions.js +2 -2
  61. package/src/Core/remove-subscription.js +3 -3
  62. package/src/Core/request-immediate-data-flush.js +5 -5
  63. package/src/Core/set-logger.js +2 -2
  64. package/src/Core/set-sdk-authentication-signature.js +6 -6
  65. package/src/Core/subscribe-to-sdk-authentication-failures.js +5 -5
  66. package/src/Core/toggle-logging.js +2 -2
  67. package/src/Core/wipe-data.js +10 -10
  68. package/src/FeatureFlags/feature-flag-factory.js +13 -13
  69. package/src/FeatureFlags/feature-flag.js +10 -10
  70. package/src/FeatureFlags/feature-flags-provider-factory.js +13 -14
  71. package/src/FeatureFlags/feature-flags-provider.js +118 -116
  72. package/src/FeatureFlags/get-all-feature-flags.js +10 -10
  73. package/src/FeatureFlags/get-feature-flag.js +9 -9
  74. package/src/FeatureFlags/log-feature-flag-impression.js +18 -18
  75. package/src/FeatureFlags/refresh-feature-flags.js +6 -6
  76. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +9 -9
  77. package/src/Feed/feed-provider-factory.js +12 -12
  78. package/src/Feed/feed-provider.js +59 -59
  79. package/src/Feed/feed.js +4 -4
  80. package/src/Feed/get-cached-feed.js +3 -3
  81. package/src/Feed/log-feed-displayed.js +5 -5
  82. package/src/Feed/request-feed-refresh.js +3 -3
  83. package/src/Feed/subscribe-to-feed-updates.js +4 -4
  84. package/src/Feed/ui/hide-feed.js +5 -5
  85. package/src/Feed/ui/show-feed.js +53 -53
  86. package/src/Feed/ui/toggle-feed.js +4 -4
  87. package/src/InAppMessage/defer-in-app-message.js +9 -9
  88. package/src/InAppMessage/display/html-message-display-utils.js +18 -164
  89. package/src/InAppMessage/display/html-message-to-html.js +55 -62
  90. package/src/InAppMessage/display/in-app-message-to-html.js +74 -74
  91. package/src/InAppMessage/display/modal-utils.js +17 -17
  92. package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
  93. package/src/InAppMessage/in-app-message-factory.js +61 -61
  94. package/src/InAppMessage/in-app-message-manager-factory.js +9 -9
  95. package/src/InAppMessage/in-app-message-manager.js +158 -156
  96. package/src/InAppMessage/log-in-app-message-button-click.js +16 -16
  97. package/src/InAppMessage/log-in-app-message-click.js +11 -11
  98. package/src/InAppMessage/log-in-app-message-html-click.js +15 -15
  99. package/src/InAppMessage/log-in-app-message-impression.js +6 -6
  100. package/src/InAppMessage/models/control-message.js +15 -8
  101. package/src/InAppMessage/models/full-screen-message.js +34 -34
  102. package/src/InAppMessage/models/html-message.js +23 -23
  103. package/src/InAppMessage/models/in-app-message-button.js +10 -10
  104. package/src/InAppMessage/models/in-app-message.js +155 -155
  105. package/src/InAppMessage/models/modal-message.js +33 -33
  106. package/src/InAppMessage/models/slide-up-message.js +35 -35
  107. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  108. package/src/InAppMessage/subscribe-to-in-app-message.js +3 -3
  109. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +6 -6
  110. package/src/InAppMessage/ui/show-in-app-message.js +103 -103
  111. package/src/Push/is-push-blocked.js +2 -2
  112. package/src/Push/is-push-permission-granted.js +2 -2
  113. package/src/Push/is-push-supported.js +2 -2
  114. package/src/Push/push-manager-factory.js +25 -25
  115. package/src/Push/push-manager.js +176 -176
  116. package/src/Push/request-push-permission.js +8 -8
  117. package/src/Push/unregister-push.js +4 -4
  118. package/src/Push/utils/push-utils.js +4 -4
  119. package/src/User/user-manager.js +38 -38
  120. package/src/User/user.js +95 -92
  121. package/src/common/base-feed.js +9 -9
  122. package/src/common/base-provider.js +2 -2
  123. package/src/common/constants.js +1 -0
  124. package/src/common/detect-impression.js +18 -0
  125. package/src/common/event-logger.js +22 -22
  126. package/src/common/feed-display.js +53 -53
  127. package/src/index.js +1 -0
  128. package/src/l10n/l10n-manager-factory.js +15 -15
  129. package/src/l10n/l10n-manager.js +4 -4
  130. package/src/managers/auth-manager.js +38 -38
  131. package/src/managers/braze-instance.js +212 -212
  132. package/src/managers/device-manager.js +30 -30
  133. package/src/managers/network-manager.js +234 -235
  134. package/src/managers/server-config-manager.js +99 -83
  135. package/src/managers/session-manager.js +46 -50
  136. package/src/managers/storage-manager-factory.js +13 -13
  137. package/src/managers/storage-manager.js +182 -180
  138. package/src/managers/subscription-manager.js +12 -12
  139. package/src/managers/utils.js +4 -4
  140. package/src/models/backend-errors.js +5 -5
  141. package/src/models/braze-event.js +9 -9
  142. package/src/models/device.js +2 -2
  143. package/src/models/identifier.js +15 -15
  144. package/src/models/push-token.js +10 -10
  145. package/src/models/request-result.js +4 -4
  146. package/src/models/server-config.js +38 -34
  147. package/src/request-controller.js +228 -228
  148. package/src/triggers/models/custom-event-data.js +5 -5
  149. package/src/triggers/models/custom-event-property-data.js +6 -6
  150. package/src/triggers/models/filter-set.js +10 -10
  151. package/src/triggers/models/filter.js +66 -66
  152. package/src/triggers/models/in-app-message-click-data.js +10 -10
  153. package/src/triggers/models/purchase-data.js +2 -2
  154. package/src/triggers/models/purchase-property-data.js +6 -6
  155. package/src/triggers/models/push-click-data.js +5 -5
  156. package/src/triggers/models/trigger-condition.js +46 -46
  157. package/src/triggers/models/trigger-events.js +4 -4
  158. package/src/triggers/models/trigger.js +33 -33
  159. package/src/triggers/triggers-provider-factory.js +16 -16
  160. package/src/triggers/triggers-provider.js +156 -154
  161. package/src/ui/js/attach-css.js +7 -7
  162. package/src/ui/js/banner-css.js +11 -0
  163. package/src/ui/js/feed-css.js +4 -4
  164. package/src/ui/js/iam-css.js +4 -4
  165. package/src/ui/js/index.js +1 -0
  166. package/src/ui/js/load-font-awesome.js +8 -8
  167. package/src/util/base-device-parser.js +9 -9
  168. package/src/util/braze-actions.js +32 -32
  169. package/src/util/browser-detector.js +27 -27
  170. package/src/util/client-hints-parser.js +9 -9
  171. package/src/util/code-utils.js +5 -5
  172. package/src/util/component-utils.js +5 -5
  173. package/src/util/deprecation-utils.js +3 -3
  174. package/src/util/device-constants.js +1 -1
  175. package/src/util/dom-utils.js +13 -13
  176. package/src/util/html-display-utils.js +158 -0
  177. package/src/util/key-codes.js +1 -1
  178. package/src/util/net.js +21 -21
  179. package/src/util/request-header-utils.js +31 -30
  180. package/src/util/string-utils.js +2 -2
  181. package/src/util/user-agent-parser.js +9 -9
  182. package/src/util/validation-utils.js +89 -85
  183. package/src/util/window-utils.js +3 -3
@@ -1,357 +1,356 @@
1
1
  import Xt from "../models/backend-errors.js";
2
2
  import ve from "../models/braze-event.js";
3
3
  import {
4
- convertMsToSeconds as h,
4
+ convertMsToSeconds as L,
5
5
  convertSecondsToMs as Kt,
6
6
  } from "../util/date-utils.js";
7
- import t from "../common/event-logger.js";
8
- import { isArray as j, isEqual as ii } from "../util/code-utils.js";
9
- import { logger as r, EventTypes as i } from "../../shared-lib/index.js";
10
- import { STORAGE_KEYS as o } from "./storage-manager.js";
11
- import D from "../util/request-header-utils.js";
7
+ import c from "../common/event-logger.js";
8
+ import { isArray as w, isEqual as ii } from "../util/code-utils.js";
9
+ import { logger as N, EventTypes as d } from "../../shared-lib/index.js";
10
+ import { STORAGE_KEYS as t } from "./storage-manager.js";
11
+ import h from "../util/request-header-utils.js";
12
12
  import { LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as Ht } from "../common/constants.js";
13
13
  import { getAlias as Yt } from "./utils.js";
14
14
  export default class Pt {
15
15
  constructor(t, e, i, s, r, n, o, h, a, u, l, c) {
16
- (this.on = t),
17
- (this.u = e),
18
- (this.Ko = i),
19
- (this.yt = s),
20
- (this.oi = r),
21
- (this.qt = n),
22
- (this.rn = o),
23
- (this.Go = h),
24
- (this.Bo = a),
25
- (this.Vo = u),
16
+ (this.wn = t),
17
+ (this.C = e),
18
+ (this.Yh = i),
19
+ (this.As = s),
20
+ (this.T = r),
21
+ (this.B = n),
22
+ (this.yn = o),
23
+ (this.Xh = h),
24
+ (this.Vh = a),
25
+ (this.$h = u),
26
26
  (this.appVersion = l),
27
- (this.Xh = c),
28
- (this.Hh = (t) => (null == t ? "" : `${t} `)),
29
- (this.on = t),
30
- (this.u = e),
31
- (this.Ko = i),
32
- (this.yt = s),
33
- (this.oi = r),
34
- (this.qt = n),
35
- (this.rn = o),
36
- (this.Go = h),
37
- (this.Bo = a),
38
- (this.Vo = u),
27
+ (this.$a = c),
28
+ (this.Za = (t) => (null == t ? "" : `${t} `)),
29
+ (this.wn = t),
30
+ (this.C = e),
31
+ (this.Yh = i),
32
+ (this.As = s),
33
+ (this.T = r),
34
+ (this.B = n),
35
+ (this.yn = o),
36
+ (this.Xh = h),
37
+ (this.Vh = a),
38
+ (this.$h = u),
39
39
  (this.appVersion = l),
40
- (this.Xh = c),
41
- (this.Yh = ["npm"]);
40
+ (this.$a = c),
41
+ (this.Ru = ["npm"]);
42
42
  }
43
- $s(t, e = !1, i = !1) {
44
- const s = this.on.ce(!i),
45
- r = s.Mr(),
46
- n = this.u.j(o.C.Fa);
47
- ii(n, r) || (t.device = r),
48
- (t.api_key = this.rn),
49
- (t.time = h(new Date().valueOf(), !0));
50
- const a = this.u.j(o.C.Jh) || [],
51
- u = this.u.j(o.C.Qh) || "";
43
+ H(e, i = !1, s = !1) {
44
+ const r = this.wn.ce(!s),
45
+ n = r.Zr(),
46
+ o = this.C.ps(t.bs.Xa);
47
+ ii(o, n) || (e.device = n),
48
+ (e.api_key = this.yn),
49
+ (e.time = L(new Date().valueOf(), !0));
50
+ const h = this.C.ps(t.bs.qu) || [],
51
+ a = this.C.ps(t.bs.Au) || "";
52
52
  if (
53
- (this.Yh.length > 0 &&
54
- (!ii(a, this.Yh) || u !== this.oi.xi()) &&
55
- (t.sdk_metadata = this.Yh),
56
- (t.sdk_version = this.Bo),
57
- this.Vo && (t.sdk_flavor = this.Vo),
58
- (t.app_version = this.appVersion),
59
- (t.app_version_code = this.Xh),
60
- (t.device_id = s.id),
61
- e)
53
+ (this.Ru.length > 0 &&
54
+ (!ii(h, this.Ru) || a !== this.T.Ss()) &&
55
+ (e.sdk_metadata = this.Ru),
56
+ (e.sdk_version = this.Vh),
57
+ this.$h && (e.sdk_flavor = this.$h),
58
+ (e.app_version = this.appVersion),
59
+ (e.app_version_code = this.$a),
60
+ (e.device_id = r.id),
61
+ i)
62
62
  ) {
63
- const e = this.yt.getUserId();
64
- null != e && (t.user_id = e);
63
+ const t = this.As.getUserId();
64
+ null != t && (e.user_id = t);
65
65
  }
66
- if (!t.user_id && !this.Ko.Fh()) {
67
- const e = Yt(this.u);
68
- e && (t.alias = e);
66
+ if (!e.user_id && !this.Yh.jh()) {
67
+ const t = Yt(this.C);
68
+ t && (e.alias = t);
69
69
  }
70
- return t;
70
+ return e;
71
71
  }
72
- Qs(e, s, n) {
73
- const o = s.auth_error,
74
- h = s.error;
75
- if (!o && !h) return !0;
76
- if (o) {
77
- let t;
78
- this.Ko.Bh();
79
- const i = { errorCode: o.error_code };
80
- for (const t of n)
81
- j(t) && "X-Braze-Auth-Signature" === t[0] && (i.signature = t[1]);
82
- e.respond_with && e.respond_with.user_id
83
- ? (i.userId = e.respond_with.user_id)
84
- : e.user_id && (i.userId = e.user_id);
85
- const s = o.reason;
72
+ ts(t, e, i) {
73
+ const s = e.auth_error,
74
+ r = e.error;
75
+ if (!s && !r) return !0;
76
+ if (s) {
77
+ let e;
78
+ this.Yh.Jh();
79
+ const r = { errorCode: s.error_code };
80
+ for (const t of i)
81
+ w(t) && "X-Braze-Auth-Signature" === t[0] && (r.signature = t[1]);
82
+ t.respond_with && t.respond_with.user_id
83
+ ? (r.userId = t.respond_with.user_id)
84
+ : t.user_id && (r.userId = t.user_id);
85
+ const n = s.reason;
86
86
  return (
87
- s
88
- ? ((i.reason = s), (t = `due to ${s}`))
89
- : (t = `with error code ${o.error_code}.`),
90
- this.Ko.Fh() ||
91
- (t +=
87
+ n
88
+ ? ((r.reason = n), (e = `due to ${n}`))
89
+ : (e = `with error code ${s.error_code}.`),
90
+ this.Yh.jh() ||
91
+ (e +=
92
92
  ' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
93
- r.error(`SDK Authentication failed ${t}`),
94
- this.Zh(e.events || [], e.attributes || []),
95
- this.Ko.qh(i),
93
+ N.error(`SDK Authentication failed ${e}`),
94
+ this.Du(t.events || [], t.attributes || []),
95
+ this.Yh.Gh(r),
96
96
  !1
97
97
  );
98
98
  }
99
- if (h) {
100
- let n,
101
- o = h;
102
- switch (o) {
103
- case Xt.Ra:
99
+ if (r) {
100
+ let i,
101
+ s = r;
102
+ switch (s) {
103
+ case Xt.Tu:
104
104
  return (
105
- (n = "Received successful response with empty body."),
106
- t.q(i.Ls, { e: n }),
107
- r.info(n),
105
+ (i = "Received successful response with empty body."),
106
+ c.ds(d.Li, { e: i }),
107
+ N.info(i),
108
108
  !1
109
109
  );
110
- case Xt.Ba:
110
+ case Xt.ku:
111
111
  return (
112
- (n = "Received successful response with invalid JSON"),
113
- t.q(i.Ls, { e: n + ": " + s.response }),
114
- r.info(n),
112
+ (i = "Received successful response with invalid JSON"),
113
+ c.ds(d.Li, { e: i + ": " + e.response }),
114
+ N.info(i),
115
115
  !1
116
116
  );
117
- case Xt.Na:
118
- o = `The API key "${e.api_key}" is invalid for the baseUrl ${this.Go}`;
117
+ case Xt.Su:
118
+ s = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Xh}`;
119
119
  break;
120
- case Xt.Xa:
121
- o =
120
+ case Xt.Bu:
121
+ s =
122
122
  "Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
123
123
  break;
124
- case Xt.$a:
125
- o = "No device identifier. Please contact support@braze.com";
124
+ case Xt.wu:
125
+ s = "No device identifier. Please contact support@braze.com";
126
126
  }
127
- r.error("Backend error: " + o);
127
+ N.error("Backend error: " + s);
128
128
  }
129
129
  return !1;
130
130
  }
131
- La(t, e, i, s) {
131
+ zu(t, e, i, s) {
132
132
  return !!((t && 0 !== t.length) || (e && 0 !== e.length) || i || s);
133
133
  }
134
- Ea(t, e, i, s, r = !1) {
134
+ ju(t, e, i, s, r = !1) {
135
135
  const n = [],
136
136
  o = (t) => t || "",
137
- h = o(this.yt.getUserId());
138
- let a = this.Ir(t, e);
139
- const u = [],
140
- l = [];
141
- let c,
142
- d = null;
137
+ a = o(this.As.getUserId());
138
+ let u = this.Yr(t, e);
139
+ const l = [],
140
+ c = [];
141
+ let d,
142
+ f = null;
143
143
  if (i.length > 0) {
144
144
  const t = [];
145
145
  for (const e of i) {
146
- if (((c = e.Mr()), this.Ko.Fh())) {
147
- if (h && !c.user_id) {
148
- d || (d = {}), d.events || (d.events = []), d.events.push(c);
146
+ if (((d = e.Zr()), this.Yh.jh())) {
147
+ if (a && !d.user_id) {
148
+ f || (f = {}), f.events || (f.events = []), f.events.push(d);
149
149
  continue;
150
150
  }
151
- if (o(c.user_id) !== h) {
152
- l.push(c);
151
+ if (o(d.user_id) !== a) {
152
+ c.push(d);
153
153
  continue;
154
154
  }
155
155
  }
156
- t.push(c);
156
+ t.push(d);
157
157
  }
158
- t.length > 0 && (a.events = t);
158
+ t.length > 0 && (u.events = t);
159
159
  }
160
160
  if (s.length > 0) {
161
161
  const t = [];
162
162
  for (const e of s)
163
- e && (this.Ko.Fh() && o(e.user_id) !== h ? u.push(e) : t.push(e));
164
- t.length > 0 && (a.attributes = t);
163
+ e && (this.Yh.jh() && o(e.user_id) !== a ? l.push(e) : t.push(e));
164
+ t.length > 0 && (u.attributes = t);
165
165
  }
166
- if ((this.Zh(l, u), (a = this.$s(a, !0, r)), d)) {
167
- d = this.$s(d, !1, r);
168
- const t = { requestData: d, headers: this.Ps(d, D._s.Ka) };
166
+ if ((this.Du(c, l), (u = this.H(u, !0, r)), f)) {
167
+ f = this.H(f, !1, r);
168
+ const t = { requestData: f, headers: this.J(f, h.O.Xu) };
169
169
  n.push(t);
170
170
  }
171
- if (a && !this.La(a.events, a.attributes, t, e)) return d ? n : null;
172
- const f = { requestData: a, headers: this.Ps(a, D._s.Ka) };
173
- return n.push(f), n;
171
+ if (u && !this.zu(u.events, u.attributes, t, e)) return f ? n : null;
172
+ const m = { requestData: u, headers: this.J(u, h.O.Xu) };
173
+ return n.push(m), n;
174
174
  }
175
- Zh(t, e) {
175
+ Du(t, e) {
176
176
  if (t) {
177
177
  const e = [];
178
178
  for (const i of t) {
179
179
  const t = ve.fromJson(i);
180
180
  (t.time = Kt(t.time)), e.push(t);
181
181
  }
182
- this.u.zo(e);
182
+ this.C.Eo(e);
183
183
  }
184
- if (e) for (const t of e) this.u.Pa(t);
184
+ if (e) for (const t of e) this.C.$u(t);
185
185
  }
186
- Ys(t, e) {
186
+ rs(t, e) {
187
187
  let i = "HTTP error ";
188
- null != t && (i += t + " "), (i += e), r.error(i);
188
+ null != t && (i += t + " "), (i += e), N.error(i);
189
189
  }
190
- qr(e) {
191
- return t.q(i.Ua, { n: e });
190
+ zr(t) {
191
+ return c.ds(d.Mu, { n: t });
192
192
  }
193
- Ir(t, e, i) {
193
+ Yr(t, e, i) {
194
194
  const s = {};
195
195
  t && (s.feed = !0), e && (s.triggers = !0);
196
- const r = null != i ? i : this.yt.getUserId();
197
- if ((r && (s.user_id = r), !s.user_id && !this.Ko.Fh())) {
198
- const t = Yt(this.u);
196
+ const r = null != i ? i : this.As.getUserId();
197
+ if ((r && (s.user_id = r), !s.user_id && !this.Yh.jh())) {
198
+ const t = Yt(this.C);
199
199
  t && (s.alias = t);
200
200
  }
201
- return (s.config = { config_time: this.qt.hi() }), { respond_with: s };
201
+ return (s.config = { config_time: this.B.Es() }), { respond_with: s };
202
202
  }
203
- Ha(t) {
203
+ Lu(t) {
204
204
  const e = new Date().valueOf();
205
205
  let i = Ht.toString();
206
- const s = D.Wa(this.u, t);
206
+ const s = h.Eu(this.C, t);
207
207
  if (-1 !== s) {
208
208
  i = (e - s).toString();
209
209
  }
210
210
  return i;
211
211
  }
212
- Ps(t, e, i = !1) {
213
- const s = [["X-Braze-Api-Key", this.rn]],
214
- r = this.Ha(e);
215
- s.push(["X-Braze-Last-Req-Ms-Ago", r]);
216
- const n = D.Ya(this.u, e).toString();
217
- s.push(["X-Braze-Req-Attempt", n]);
218
- let h = !1;
212
+ J(e, i, s = !1) {
213
+ const r = [["X-Braze-Api-Key", this.yn]],
214
+ n = this.Lu(i);
215
+ r.push(["X-Braze-Last-Req-Ms-Ago", n]);
216
+ const o = h.Fu(this.C, i).toString();
217
+ r.push(["X-Braze-Req-Attempt", o]);
218
+ let a = !1;
219
219
  if (
220
- (null != t.respond_with &&
221
- t.respond_with.triggers &&
222
- (s.push(["X-Braze-TriggersRequest", "true"]), (h = !0)),
223
- null != t.respond_with &&
224
- t.respond_with.feed &&
225
- (s.push(["X-Braze-FeedRequest", "true"]), (h = !0)),
226
- e === D._s.Xs)
220
+ (null != e.respond_with &&
221
+ e.respond_with.triggers &&
222
+ (r.push(["X-Braze-TriggersRequest", "true"]), (a = !0)),
223
+ null != e.respond_with &&
224
+ e.respond_with.feed &&
225
+ (r.push(["X-Braze-FeedRequest", "true"]), (a = !0)),
226
+ i === h.O.Pi)
227
227
  ) {
228
- s.push(["X-Braze-ContentCardsRequest", "true"]);
229
- let t = this.u.j(o.C.xs);
230
- (t && i) || ((t = 0), this.u.I(o.C.xs, t)),
231
- s.push(["BRAZE-SYNC-RETRY-COUNT", t.toString()]),
232
- (h = !0);
228
+ r.push(["X-Braze-ContentCardsRequest", "true"]);
229
+ let e = this.C.ps(t.bs.Fi);
230
+ (e && s) || ((e = 0), this.C.js(t.bs.Fi, e)),
231
+ r.push(["BRAZE-SYNC-RETRY-COUNT", e.toString()]),
232
+ (a = !0);
233
233
  }
234
234
  if (
235
- (e === D._s.Ri &&
236
- (s.push(["X-Braze-FeatureFlagsRequest", "true"]), (h = !0)),
237
- h && s.push(["X-Braze-DataRequest", "true"]),
238
- this.Ko.Fh())
235
+ (i === h.O.De &&
236
+ (r.push(["X-Braze-FeatureFlagsRequest", "true"]), (a = !0)),
237
+ a && r.push(["X-Braze-DataRequest", "true"]),
238
+ this.Yh.jh())
239
239
  ) {
240
- const t = this.Ko.kh();
241
- null != t && s.push(["X-Braze-Auth-Signature", t]);
240
+ const t = this.Yh.xh();
241
+ null != t && r.push(["X-Braze-Auth-Signature", t]);
242
242
  }
243
- return s;
243
+ return r;
244
244
  }
245
- Ja(t, e, i, s) {
245
+ Ku(t, e, i, s) {
246
246
  window.setTimeout(() => {
247
- r.info(`Retrying rate limited ${this.Hh(s)}SDK request.`),
248
- this.Gs(e, i, s);
247
+ N.info(`Retrying rate limited ${this.Za(s)}SDK request.`),
248
+ this.V(e, i, s);
249
249
  }, t);
250
250
  }
251
- Gs(t, e, i, s) {
252
- if (!this.Qa(i))
251
+ V(e, i, s, r) {
252
+ if (!this.Iu(s))
253
253
  return (
254
- r.info(`${this.Hh(i)}SDK request being rate limited.`),
255
- void ("function" == typeof s && s())
254
+ N.info(`${this.Za(s)}SDK request being rate limited.`),
255
+ void ("function" == typeof r && r())
256
256
  );
257
- const n = this.Va();
258
- if (!n.Za)
257
+ const n = this.Pu();
258
+ if (!n.Uu)
259
259
  return (
260
- r.info(
261
- `${this.Hh(
262
- i,
260
+ N.info(
261
+ `${this.Za(
262
+ s,
263
263
  )}SDK request being rate limited. Request will be retried in ${Math.trunc(
264
- n.au / 1e3,
264
+ n.Ou / 1e3,
265
265
  )} seconds.`,
266
266
  ),
267
- void this.Ja(n.au, t, e, i)
267
+ void this.Ku(n.Ou, e, i, s)
268
268
  );
269
- this.u.I(o.C.du, new Date().valueOf());
270
- const h = t.device;
271
- h && h.os_version instanceof Promise
272
- ? h.os_version.then((i) => {
273
- (t.device.os_version = i), e(n.fu);
269
+ this.C.js(t.bs.xu, new Date().valueOf());
270
+ const o = e.device;
271
+ o && o.os_version instanceof Promise
272
+ ? o.os_version.then((t) => {
273
+ (e.device.os_version = t), i(n.Gu);
274
274
  })
275
- : e(n.fu);
275
+ : i(n.Gu);
276
276
  }
277
- vu(t) {
278
- var e;
279
- null === (e = this.u) || void 0 === e || e.I(o.C.Ru, t);
277
+ Hu(e) {
278
+ var i;
279
+ null === (i = this.C) || void 0 === i || i.js(t.bs._u, e);
280
280
  }
281
- gu(t, e) {
282
- let i = this.pu();
283
- null == i && (i = {}), (i[t] = e), this.u.I(o.C.bu, i);
281
+ Wu(e, i) {
282
+ let s = this.Yu();
283
+ null == s && (s = {}), (s[e] = i), this.C.js(t.bs.Ju, s);
284
284
  }
285
- qu() {
286
- var t;
287
- return null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.Ru);
285
+ Qu() {
286
+ var e;
287
+ return null === (e = this.C) || void 0 === e ? void 0 : e.ps(t.bs._u);
288
288
  }
289
- pu() {
290
- var t;
291
- return null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.bu);
289
+ Yu() {
290
+ var e;
291
+ return null === (e = this.C) || void 0 === e ? void 0 : e.ps(t.bs.Ju);
292
292
  }
293
- Au(t, e, i, s, r = "") {
293
+ Vu(t, e, i, s, r = "") {
294
294
  let n;
295
295
  if (r) {
296
- const t = this.pu();
296
+ const t = this.Yu();
297
297
  n = null == t || isNaN(t[r]) ? e : t[r];
298
- } else (n = this.qu()), (null == n || isNaN(n)) && (n = e);
298
+ } else (n = this.Qu()), (null == n || isNaN(n)) && (n = e);
299
299
  const o = (t - s) / 1e3;
300
300
  return (n = Math.min(n + o / i, e)), n;
301
301
  }
302
- Du(t, e) {
302
+ Zu(t, e) {
303
303
  return Math.max(0, (1 - t) * e * 1e3);
304
304
  }
305
- Tu(t, e = "") {
306
- var i, s, r, n, h;
307
- const a = { Za: !0, fu: -1, au: 0 };
308
- if ((null == t && (t = !0), !t && !e)) return a;
309
- let u,
310
- l,
311
- c = null;
312
- if (t) c = null === (i = this.u) || void 0 === i ? void 0 : i.j(o.C.du);
305
+ tl(e, i = "") {
306
+ var s, r, n, o, a;
307
+ const u = { Uu: !0, Gu: -1, Ou: 0 };
308
+ if ((null == e && (e = !0), !e && !i)) return u;
309
+ let l,
310
+ c,
311
+ d = null;
312
+ if (e) d = null === (s = this.C) || void 0 === s ? void 0 : s.ps(t.bs.xu);
313
313
  else {
314
- const t = D.ku(this.u);
315
- if (null == t || null == t[e]) return a;
316
- c = t[e];
314
+ const t = h.el(this.C);
315
+ if (null == t || null == t[i]) return u;
316
+ d = t[i];
317
317
  }
318
- if (null == c || isNaN(c)) return a;
318
+ if (null == d || isNaN(d)) return u;
319
319
  if (
320
- (t
321
- ? ((u =
322
- (null === (s = this.qt) || void 0 === s ? void 0 : s.Cu()) || -1),
323
- (l =
324
- (null === (r = this.qt) || void 0 === r ? void 0 : r.Su()) || -1))
325
- : ((u =
326
- (null === (n = this.qt) || void 0 === n ? void 0 : n.Bu(e)) || -1),
327
- (l =
328
- (null === (h = this.qt) || void 0 === h ? void 0 : h.wu(e)) || -1)),
329
- -1 === u || -1 === l)
320
+ (e
321
+ ? ((l =
322
+ (null === (r = this.B) || void 0 === r ? void 0 : r.il()) || -1),
323
+ (c = (null === (n = this.B) || void 0 === n ? void 0 : n.sl()) || -1))
324
+ : ((l =
325
+ (null === (o = this.B) || void 0 === o ? void 0 : o.rl(i)) || -1),
326
+ (c =
327
+ (null === (a = this.B) || void 0 === a ? void 0 : a.ol(i)) || -1)),
328
+ -1 === l || -1 === c)
330
329
  )
331
- return a;
332
- const d = new Date().valueOf();
333
- let f = this.Au(d, u, l, c, e);
334
- return f < 1
335
- ? ((a.Za = !1), (a.au = this.Du(f, l)), a)
336
- : ((f = Math.trunc(f) - 1),
337
- (a.fu = f),
338
- t ? this.vu(f) : this.gu(e, f),
339
- a);
330
+ return u;
331
+ const f = new Date().valueOf();
332
+ let m = this.Vu(f, l, c, d, i);
333
+ return m < 1
334
+ ? ((u.Uu = !1), (u.Ou = this.Zu(m, c)), u)
335
+ : ((m = Math.trunc(m) - 1),
336
+ (u.Gu = m),
337
+ e ? this.Hu(m) : this.Wu(i, m),
338
+ u);
340
339
  }
341
- Va() {
342
- return this.Tu(!0);
340
+ Pu() {
341
+ return this.tl(!0);
343
342
  }
344
- Qa(t) {
345
- const e = this.Tu(!1, t);
346
- return !(e && !e.Za);
343
+ Iu(t) {
344
+ const e = this.tl(!1, t);
345
+ return !(e && !e.Uu);
347
346
  }
348
- Vs() {
349
- this.Ko.Vs();
347
+ es() {
348
+ this.Yh.es();
350
349
  }
351
- Os() {
352
- return this.Go;
350
+ Z() {
351
+ return this.Xh;
353
352
  }
354
353
  addSdkMetadata(t) {
355
- for (const e of t) -1 === this.Yh.indexOf(e) && this.Yh.push(e);
354
+ for (const e of t) -1 === this.Ru.indexOf(e) && this.Ru.push(e);
356
355
  }
357
356
  }