@braze/web-sdk 5.0.0 → 5.1.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 (158) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +12 -5
  3. package/package.json +1 -1
  4. package/shared-lib/encoding-utils.js +3 -3
  5. package/shared-lib/event-types.js +29 -29
  6. package/shared-lib/guid.js +3 -3
  7. package/shared-lib/index.js +6 -0
  8. package/shared-lib/indexed-db-adapter.js +70 -70
  9. package/shared-lib/logger.js +18 -18
  10. package/shared-lib/supported-options.js +21 -21
  11. package/src/Card/card-manager.js +43 -45
  12. package/src/Card/display/card-display.js +60 -60
  13. package/src/Card/log-card-click.js +4 -4
  14. package/src/Card/log-card-dismissal.js +2 -3
  15. package/src/Card/log-card-impressions.js +7 -7
  16. package/src/Card/models/captioned-image.js +21 -21
  17. package/src/Card/models/card.js +73 -73
  18. package/src/Card/models/classic-card.js +21 -21
  19. package/src/Card/models/control-card.js +11 -11
  20. package/src/Card/models/image-only.js +19 -19
  21. package/src/Card/util/card-factory.js +68 -68
  22. package/src/ContentCards/content-cards-provider-factory.js +3 -3
  23. package/src/ContentCards/content-cards-provider.js +255 -245
  24. package/src/ContentCards/content-cards.js +2 -2
  25. package/src/ContentCards/get-cached-content-cards.js +1 -1
  26. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  27. package/src/ContentCards/subscribe-to-content-cards-updates.js +6 -6
  28. package/src/ContentCards/ui/hide-content-cards.js +1 -1
  29. package/src/ContentCards/ui/show-content-cards.js +24 -24
  30. package/src/ContentCards/ui/toggle-content-cards.js +1 -1
  31. package/src/Core/add-sdk-metadata.js +21 -19
  32. package/src/Core/change-user.js +10 -10
  33. package/src/Core/destroy.js +2 -2
  34. package/src/Core/disable-sdk.js +11 -11
  35. package/src/Core/enable-sdk.js +7 -7
  36. package/src/Core/get-device-id.js +6 -6
  37. package/src/Core/get-user.js +1 -1
  38. package/src/Core/handle-braze-action.js +41 -41
  39. package/src/Core/is-disabled.js +2 -2
  40. package/src/Core/log-custom-event.js +15 -15
  41. package/src/Core/log-purchase.js +31 -37
  42. package/src/Core/open-session.js +12 -12
  43. package/src/Core/remove-all-subscriptions.js +1 -1
  44. package/src/Core/remove-subscription.js +1 -1
  45. package/src/Core/request-immediate-data-flush.js +1 -1
  46. package/src/Core/set-logger.js +2 -2
  47. package/src/Core/set-sdk-authentication-signature.js +3 -3
  48. package/src/Core/subscribe-to-sdk-authentication-failures.js +6 -4
  49. package/src/Core/toggle-logging.js +2 -2
  50. package/src/Core/wipe-data.js +9 -9
  51. package/src/FeatureFlags/feature-flag-factory.js +12 -12
  52. package/src/FeatureFlags/feature-flag.js +10 -10
  53. package/src/FeatureFlags/feature-flags-provider-factory.js +3 -2
  54. package/src/FeatureFlags/feature-flags-provider.js +108 -80
  55. package/src/FeatureFlags/get-all-feature-flags.js +5 -5
  56. package/src/FeatureFlags/get-feature-flag.js +6 -6
  57. package/src/FeatureFlags/log-feature-flag-impression.js +15 -13
  58. package/src/FeatureFlags/refresh-feature-flags.js +1 -1
  59. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +7 -4
  60. package/src/Feed/feed-provider-factory.js +2 -2
  61. package/src/Feed/feed-provider.js +44 -44
  62. package/src/Feed/feed.js +1 -1
  63. package/src/Feed/get-cached-feed.js +1 -1
  64. package/src/Feed/log-feed-displayed.js +4 -4
  65. package/src/Feed/request-feed-refresh.js +1 -1
  66. package/src/Feed/subscribe-to-feed-updates.js +1 -1
  67. package/src/Feed/ui/hide-feed.js +1 -1
  68. package/src/Feed/ui/show-feed.js +28 -28
  69. package/src/Feed/ui/toggle-feed.js +1 -1
  70. package/src/InAppMessage/defer-in-app-message.js +5 -5
  71. package/src/InAppMessage/display/html-message-to-html.js +54 -54
  72. package/src/InAppMessage/display/in-app-message-to-html.js +79 -79
  73. package/src/InAppMessage/display/modal-utils.js +8 -8
  74. package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
  75. package/src/InAppMessage/in-app-message-factory.js +49 -49
  76. package/src/InAppMessage/in-app-message-manager-factory.js +1 -1
  77. package/src/InAppMessage/in-app-message-manager.js +143 -138
  78. package/src/InAppMessage/log-in-app-message-button-click.js +12 -12
  79. package/src/InAppMessage/log-in-app-message-click.js +9 -9
  80. package/src/InAppMessage/log-in-app-message-html-click.js +12 -12
  81. package/src/InAppMessage/log-in-app-message-impression.js +6 -6
  82. package/src/InAppMessage/models/full-screen-message.js +33 -33
  83. package/src/InAppMessage/models/html-message.js +20 -20
  84. package/src/InAppMessage/models/in-app-message-button.js +6 -6
  85. package/src/InAppMessage/models/in-app-message.js +99 -99
  86. package/src/InAppMessage/models/modal-message.js +32 -32
  87. package/src/InAppMessage/models/slide-up-message.js +28 -28
  88. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  89. package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
  90. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
  91. package/src/InAppMessage/ui/show-in-app-message.js +81 -81
  92. package/src/Push/is-push-blocked.js +1 -1
  93. package/src/Push/is-push-permission-granted.js +1 -1
  94. package/src/Push/is-push-supported.js +1 -1
  95. package/src/Push/push-manager-factory.js +5 -5
  96. package/src/Push/push-manager.js +176 -173
  97. package/src/Push/request-push-permission.js +1 -1
  98. package/src/Push/unregister-push.js +1 -1
  99. package/src/Push/utils/push-utils.js +4 -4
  100. package/src/User/user-manager.js +29 -29
  101. package/src/User/user.js +72 -74
  102. package/src/common/base-feed.js +7 -7
  103. package/src/common/base-provider.js +1 -1
  104. package/src/common/constants.js +2 -0
  105. package/src/common/event-logger.js +21 -18
  106. package/src/common/feed-display.js +44 -44
  107. package/src/l10n/l10n-manager-factory.js +3 -3
  108. package/src/l10n/l10n-manager.js +7 -7
  109. package/src/managers/auth-manager.js +32 -32
  110. package/src/managers/braze-instance.js +188 -189
  111. package/src/managers/device-manager.js +28 -28
  112. package/src/managers/network-manager.js +189 -138
  113. package/src/managers/server-config-manager.js +69 -53
  114. package/src/managers/session-manager.js +34 -30
  115. package/src/managers/storage-manager-factory.js +16 -16
  116. package/src/managers/storage-manager.js +210 -188
  117. package/src/managers/subscription-manager.js +12 -12
  118. package/src/models/backend-errors.js +5 -5
  119. package/src/models/braze-event.js +3 -3
  120. package/src/models/device.js +2 -2
  121. package/src/models/identifier.js +34 -14
  122. package/src/models/push-token.js +8 -8
  123. package/src/models/request-result.js +3 -3
  124. package/src/models/server-config.js +32 -23
  125. package/src/request-controller.js +187 -180
  126. package/src/triggers/models/custom-event-data.js +7 -7
  127. package/src/triggers/models/custom-event-property-data.js +10 -10
  128. package/src/triggers/models/filter-set.js +13 -13
  129. package/src/triggers/models/filter.js +45 -45
  130. package/src/triggers/models/in-app-message-click-data.js +12 -12
  131. package/src/triggers/models/purchase-data.js +2 -2
  132. package/src/triggers/models/purchase-property-data.js +10 -10
  133. package/src/triggers/models/push-click-data.js +7 -7
  134. package/src/triggers/models/trigger-condition.js +57 -59
  135. package/src/triggers/models/trigger-events.js +4 -4
  136. package/src/triggers/models/trigger.js +38 -38
  137. package/src/triggers/triggers-provider-factory.js +4 -4
  138. package/src/triggers/triggers-provider.js +127 -130
  139. package/src/ui/js/attach-css.js +2 -2
  140. package/src/ui/js/iam-css.js +1 -1
  141. package/src/ui/js/load-font-awesome.js +1 -1
  142. package/src/util/base-device-parser.js +3 -3
  143. package/src/util/braze-actions.js +35 -35
  144. package/src/util/browser-detector.js +21 -21
  145. package/src/util/client-hints-parser.js +8 -8
  146. package/src/util/code-utils.js +2 -2
  147. package/src/util/component-utils.js +1 -1
  148. package/src/util/deprecation-utils.js +4 -4
  149. package/src/util/device-constants.js +1 -1
  150. package/src/util/dom-utils.js +18 -18
  151. package/src/util/key-codes.js +1 -1
  152. package/src/util/net.js +18 -18
  153. package/src/util/request-header-utils.js +39 -37
  154. package/src/util/string-utils.js +10 -10
  155. package/src/util/user-agent-parser.js +18 -18
  156. package/src/util/validation-utils.js +37 -39
  157. package/src/util/window-utils.js +3 -3
  158. package/shared-lib/braze-shared-lib.js +0 -8
@@ -5,309 +5,319 @@ import ContentCards from "./content-cards.js";
5
5
  import { dateFromUnixTimestamp as l } from "../util/date-utils.js";
6
6
  import { isURIJavascriptOrData as N } from "../util/url-utils.js";
7
7
  import {
8
- newCardFromContentCardsJson as j,
9
- newCardFromSerializedValue as R,
8
+ newCardFromContentCardsJson as R,
9
+ newCardFromSerializedValue as D,
10
10
  } from "../Card/util/card-factory.js";
11
- import r from "../../shared-lib/braze-shared-lib.js";
12
- import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
13
- import E from "../managers/subscription-manager.js";
11
+ import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
12
+ import T from "../managers/subscription-manager.js";
14
13
  import s from "../common/event-logger.js";
15
- import T from "../util/request-header-utils.js";
16
- import { randomInclusive as D } from "../util/math.js";
17
- import { MAX_ERROR_RETRIES_CONTENT_CARDS as S } from "../common/constants.js";
14
+ import S from "../util/request-header-utils.js";
15
+ import { randomInclusive as k } from "../util/math.js";
16
+ import { MAX_ERROR_RETRIES_CONTENT_CARDS as U } from "../common/constants.js";
17
+ import {
18
+ logger as r,
19
+ IndexedDBAdapter as A,
20
+ EventTypes as i,
21
+ } from "../../shared-lib/index.js";
18
22
  export default class v extends y {
19
23
  constructor(t, s, i, h, n) {
20
24
  super(),
21
25
  (this.wt = t),
22
26
  (this.u = s),
23
27
  (this.yt = i),
24
- (this.Jt = h),
25
- (this.$t = n),
28
+ (this.Ft = h),
29
+ (this.qt = n),
26
30
  (this.wt = t),
27
31
  (this.u = s),
28
32
  (this.yt = i),
29
- (this.Jt = h),
30
- (this.$t = n),
31
- (this.Bt = new E()),
32
- e.Ht(this.Bt),
33
- (this.Kt = 0),
34
- (this.Qt = 0),
33
+ (this.Ft = h),
34
+ (this.qt = n),
35
+ (this.Jt = new T()),
36
+ e.$t(this.Jt),
37
+ (this.Bt = 0),
38
+ (this.Ht = 0),
35
39
  (this.cards = []),
36
- this.Yt();
37
- const o = r.ts.Zt;
38
- new r.es(o, r.j).ss(o.rs.hs, (t) => {
39
- this.ns(t);
40
+ this.Kt();
41
+ const o = A.Yt.Qt;
42
+ new A(o, r).Zt(o.ss.ts, (t) => {
43
+ this.es(t);
40
44
  }),
45
+ (this.hs = null),
46
+ (this.rs = null),
47
+ (this.ns = null),
41
48
  (this.os = null),
42
49
  (this.ls = null),
43
- (this.us = null),
44
- (this.cs = null),
45
- (this.fs = null),
46
- (this.ds = 10),
47
- (this.ps = 0);
50
+ (this.us = 10),
51
+ (this.cs = 0);
48
52
  }
49
- Cs() {
50
- return this.os;
53
+ fs() {
54
+ return this.hs;
51
55
  }
52
- ws(t) {
53
- this.os = t;
56
+ ds(t) {
57
+ this.hs = t;
54
58
  }
55
- bs() {
56
- return this.ls;
59
+ ps() {
60
+ return this.rs;
57
61
  }
58
62
  vs(t) {
59
- this.ls = t;
63
+ this.rs = t;
60
64
  }
61
- Yt() {
65
+ Kt() {
62
66
  if (!this.u) return;
63
- const t = this.u.v(i.k.gs) || [],
67
+ const t = this.u.j(o.C.Cs) || [],
64
68
  s = [];
65
69
  for (let i = 0; i < t.length; i++) {
66
- const e = R(t[i]);
70
+ const e = D(t[i]);
67
71
  null != e && s.push(e);
68
72
  }
69
- (this.cards = this.ys(this.Ns(s, !1))),
70
- (this.Kt = this.u.v(i.k.js) || this.Kt),
71
- (this.Qt = this.u.v(i.k.Rs) || this.Qt);
73
+ (this.cards = this.ws(this.bs(s, !1))),
74
+ (this.Bt = this.u.j(o.C.gs) || this.Bt),
75
+ (this.Ht = this.u.j(o.C.ys) || this.Ht);
72
76
  }
73
- Ts(t, s = !1, e = 0, h = 0) {
74
- let r;
77
+ Ns(t, s = !1, i = 0, e = 0) {
78
+ let h;
75
79
  if (s) {
76
- r = [];
77
- for (const t of this.cards) t.test && r.push(t);
78
- } else r = this.cards.slice();
80
+ h = [];
81
+ for (const t of this.cards) t.test && h.push(t);
82
+ } else h = this.cards.slice();
79
83
  for (let i = 0; i < t.length; i++) {
80
84
  const e = t[i];
81
- let h = null;
85
+ let r = null;
82
86
  for (let t = 0; t < this.cards.length; t++)
83
87
  if (e.id === this.cards[t].id) {
84
- h = this.cards[t];
88
+ r = this.cards[t];
85
89
  break;
86
90
  }
87
91
  if (s) {
88
- const t = j(e);
89
- null != h && h.viewed && t && (t.viewed = !0), null != t && r.push(t);
90
- } else if (null == h) {
91
- const t = j(e);
92
- null != t && r.push(t);
92
+ const t = R(e);
93
+ null != r && r.viewed && t && (t.viewed = !0), null != t && h.push(t);
94
+ } else if (null == r) {
95
+ const t = R(e);
96
+ null != t && h.push(t);
93
97
  } else {
94
- if (!h.Ct(e))
95
- for (let t = 0; t < r.length; t++)
96
- if (e.id === r[t].id) {
97
- r.splice(t, 1);
98
+ if (!r.Ct(e))
99
+ for (let t = 0; t < h.length; t++)
100
+ if (e.id === h[t].id) {
101
+ h.splice(t, 1);
98
102
  break;
99
103
  }
100
104
  }
101
105
  }
102
- (this.cards = this.ys(this.Ns(r, s))),
103
- this.Ds(),
104
- (this.Kt = e),
105
- (this.Qt = h),
106
- this.u && (this.u.D(i.k.js, this.Kt), this.u.D(i.k.Rs, this.Qt));
106
+ (this.cards = this.ws(this.bs(h, s))),
107
+ this.js(),
108
+ (this.Bt = i),
109
+ (this.Ht = e),
110
+ this.u && (this.u.k(o.C.gs, this.Bt), this.u.k(o.C.ys, this.Ht));
107
111
  }
108
- Ss(t) {
109
- if (this.ks() && null != t && t.cards) {
110
- this.u && this.u.D(i.k.Us, e.As());
112
+ Rs(t) {
113
+ if (this.Ts() && null != t && t.cards) {
114
+ this.u && this.u.k(o.C.Ds, e.Ss());
111
115
  const s = t.full_sync;
112
- s || this.Yt(),
113
- this.Ts(t.cards, s, t.last_full_sync_at, t.last_card_updated_at),
114
- this.Bt.Dt(this.Ls(!0));
116
+ s || this.Kt(),
117
+ this.Ns(t.cards, s, t.last_full_sync_at, t.last_card_updated_at),
118
+ this.Jt.Dt(this.ks(!0));
115
119
  }
116
120
  }
117
- Fs(t) {
118
- this.u && this.u.D(i.k.zs, t);
121
+ Us(t) {
122
+ this.u && this.u.k(o.C.As, t);
119
123
  }
120
- Ms(t, e, h) {
121
- const n = () => {
122
- this.xs(e, h, !0);
124
+ Ls(t, e, h) {
125
+ const r = () => {
126
+ this.Fs(e, h, !0);
123
127
  },
124
- o = t ? b(t) : null;
128
+ n = t ? b(t) : null;
125
129
  let l;
126
- if ((this.Es(), !o || !o["retry-after"])) return void this.Fs(0);
127
- const a = o["retry-after"];
130
+ if ((this.xs(), !n || !n["retry-after"])) return void this.Us(0);
131
+ const a = n["retry-after"];
128
132
  if (isNaN(a) && !isNaN(Date.parse(a)))
129
- (l = Date.parse(a) - new Date().getTime()), l < 0 && n();
133
+ (l = Date.parse(a) - new Date().getTime()), l < 0 && r();
130
134
  else {
131
135
  if (isNaN(parseFloat(a.toString()))) {
132
136
  const t =
133
137
  "Received unexpected value for retry-after header in /sync response";
134
- return s.N(r.q.qs, { e: t + ": " + a }), void this.Fs(0);
138
+ return s.q(i.Ms, { e: t + ": " + a }), void this.Us(0);
135
139
  }
136
140
  l = 1e3 * parseFloat(a.toString());
137
141
  }
138
- this.us = window.setTimeout(() => {
139
- n();
142
+ this.ns = window.setTimeout(() => {
143
+ r();
140
144
  }, l);
141
145
  let u = 0;
142
- this.u && (u = this.u.v(i.k.zs)),
146
+ this.u && (u = this.u.j(o.C.As)),
143
147
  (null == u || isNaN(parseInt(u.toString()))) && (u = 0),
144
- this.Fs(parseInt(u.toString()) + 1);
148
+ this.Us(parseInt(u.toString()) + 1);
145
149
  }
146
- ns(t) {
147
- if (!this.ks()) return;
148
- this.Yt();
149
- const s = this.cards.slice();
150
- let i = null;
151
- this.wt && (i = this.wt.getUserId());
152
- for (let e = 0; e < t.length; e++)
153
- if (i === t[e].userId || (null == i && null == t[e].userId)) {
154
- const i = t[e].card;
150
+ es(t) {
151
+ var s;
152
+ if (!this.Ts()) return;
153
+ this.Kt();
154
+ const i = this.cards.slice();
155
+ let e = null;
156
+ e = null === (s = this.wt) || void 0 === s ? void 0 : s.getUserId();
157
+ for (let s = 0; s < t.length; s++)
158
+ if (e === t[s].userId || (null == e && null == t[s].userId)) {
159
+ const e = t[s].card;
155
160
  let h = null;
156
161
  for (let t = 0; t < this.cards.length; t++)
157
- if (i.id === this.cards[t].id) {
162
+ if (e.id === this.cards[t].id) {
158
163
  h = this.cards[t];
159
164
  break;
160
165
  }
161
166
  if (null == h) {
162
- const t = j(i);
163
- null != t && s.push(t);
167
+ const t = R(e);
168
+ null != t && i.push(t);
164
169
  } else {
165
- if (!h.Ct(i))
166
- for (let t = 0; t < s.length; t++)
167
- if (i.id === s[t].id) {
168
- s.splice(t, 1);
170
+ if (!h.Ct(e))
171
+ for (let t = 0; t < i.length; t++)
172
+ if (e.id === i[t].id) {
173
+ i.splice(t, 1);
169
174
  break;
170
175
  }
171
176
  }
172
177
  }
173
- (this.cards = this.ys(this.Ns(s, !1))), this.Ds(), this.Bt.Dt(this.Ls(!0));
178
+ (this.cards = this.ws(this.bs(i, !1))), this.js(), this.Jt.Dt(this.ks(!0));
174
179
  }
175
- Ns(t, s) {
176
- let e = {},
177
- h = {},
178
- r = {};
180
+ bs(t, s) {
181
+ let i = {},
182
+ e = {},
183
+ h = {};
179
184
  this.u &&
180
- ((e = this.u.v(i.k.C) || {}),
181
- (h = this.u.v(i.k.K) || {}),
182
- (r = this.u.v(i.k.G) || {}));
183
- const n = {},
184
- o = {},
185
+ ((i = this.u.j(o.C.v) || {}),
186
+ (e = this.u.j(o.C.H) || {}),
187
+ (h = this.u.j(o.C.A) || {}));
188
+ const r = {},
189
+ n = {},
185
190
  l = {};
186
191
  for (let s = 0; s < t.length; s++) {
187
- const i = t[s].id;
188
- i &&
189
- (e[i] && ((t[s].clicked = !0), (n[i] = !0)),
190
- h[i] && ((t[s].viewed = !0), (o[i] = !0)),
191
- r[i] && ((t[s].dismissed = !0), (l[i] = !0)));
192
+ const o = t[s].id;
193
+ o &&
194
+ (i[o] && ((t[s].clicked = !0), (r[o] = !0)),
195
+ e[o] && ((t[s].viewed = !0), (n[o] = !0)),
196
+ h[o] && ((t[s].dismissed = !0), (l[o] = !0)));
192
197
  }
193
198
  return (
194
199
  s &&
195
200
  this.u &&
196
- (this.u.D(i.k.C, n), this.u.D(i.k.K, o), this.u.D(i.k.G, l)),
201
+ (this.u.k(o.C.v, r), this.u.k(o.C.H, n), this.u.k(o.C.A, l)),
197
202
  t
198
203
  );
199
204
  }
200
- ys(t) {
205
+ ws(t) {
201
206
  const s = [],
202
- e = new Date();
203
- let h = {};
204
- this.u && (h = this.u.v(i.k.G) || {});
205
- let n = !1;
206
- for (let i = 0; i < t.length; i++) {
207
- const o = t[i].url;
208
- if (!this.Jt && o && N(o)) {
209
- r.j.error(
207
+ i = new Date();
208
+ let e = {};
209
+ this.u && (e = this.u.j(o.C.A) || {});
210
+ let h = !1;
211
+ for (let n = 0; n < t.length; n++) {
212
+ const o = t[n].url;
213
+ if (!this.Ft && o && N(o)) {
214
+ r.error(
210
215
  `Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`,
211
216
  );
212
217
  continue;
213
218
  }
214
- const l = t[i].expiresAt;
219
+ const l = t[n].expiresAt;
215
220
  let a = !0;
216
- if ((null != l && (a = l >= e), (a = a && !t[i].dismissed), a))
217
- s.push(t[i]);
221
+ if ((null != l && (a = l >= i), (a = a && !t[n].dismissed), a))
222
+ s.push(t[n]);
218
223
  else {
219
- const s = t[i].id;
220
- s && (h[s] = !0), (n = !0);
224
+ const s = t[n].id;
225
+ s && (e[s] = !0), (h = !0);
221
226
  }
222
227
  }
223
- return n && this.u && this.u.D(i.k.G, h), s;
228
+ return h && this.u && this.u.k(o.C.A, e), s;
224
229
  }
225
- Ds() {
226
- if (!this.u) return;
227
- const t = [];
228
- for (let s = 0; s < this.cards.length; s++) t.push(this.cards[s].tt());
229
- this.u.D(i.k.gs, t);
230
+ js() {
231
+ var t;
232
+ const s = [];
233
+ for (let t = 0; t < this.cards.length; t++) s.push(this.cards[t].Y());
234
+ null === (t = this.u) || void 0 === t || t.k(o.C.Cs, s);
230
235
  }
231
- Es() {
232
- this.us && (clearTimeout(this.us), (this.us = null));
236
+ xs() {
237
+ this.ns && (clearTimeout(this.ns), (this.ns = null));
233
238
  }
234
- Is() {
235
- null != this.cs && (clearTimeout(this.cs), (this.cs = null));
239
+ zs() {
240
+ null != this.os && (clearTimeout(this.os), (this.os = null));
236
241
  }
237
- Js(t = 1e3 * this.ds, s, i) {
238
- this.Is(),
239
- (this.cs = window.setTimeout(() => {
240
- this.xs(s, i, !0);
242
+ Es(t = 1e3 * this.us, s, i) {
243
+ this.zs(),
244
+ (this.os = window.setTimeout(() => {
245
+ this.Fs(s, i, !0);
241
246
  }, t)),
242
- (this.fs = t);
247
+ (this.ls = t);
243
248
  }
244
- xs(t, s, h = !1, n = !0) {
245
- var o;
246
- const l = this.$t,
247
- a = this.u;
248
- if (!l || !a) return void ("function" == typeof s && s());
249
- const u = !h;
250
- if ((u && (this.Es(), this.Fs(0)), !this.ks()))
249
+ Fs(t, s, i = !1, h = !0) {
250
+ var n, l;
251
+ const a = this.qt,
252
+ u = this.u;
253
+ if (!a || !u) return void ("function" == typeof s && s());
254
+ const c = !i;
255
+ if ((c && (this.xs(), this.Us(0)), !this.Ts()))
251
256
  return void (
252
- this.yt &&
253
- this.yt.Ps(() => {
254
- this.xs(t, s);
257
+ null === (n = this.yt) ||
258
+ void 0 === n ||
259
+ n.qs(() => {
260
+ this.Fs(t, s);
255
261
  })
256
262
  );
257
- let c = !0;
263
+ let f = !0;
258
264
  if (
259
- (u &&
260
- (null === (o = this.yt) || void 0 === o ? void 0 : o.$s()) &&
261
- (c = this._s()),
262
- !c)
265
+ (c &&
266
+ (null === (l = this.yt) || void 0 === l ? void 0 : l.Is()) &&
267
+ (f = this.Js()),
268
+ !f)
263
269
  )
264
- return void r.j.info("Content card sync being throttled.");
265
- n && this.Is();
266
- const f = l.Bs({}, !0);
267
- a.v(i.k.Us) !== e.As() && this.Gs(),
268
- (f.last_full_sync_at = this.Kt),
269
- (f.last_card_updated_at = this.Qt);
270
- const d = l.Hs(f, T.Os.Ks, h);
271
- let m = !1;
272
- l.Qs(f, () => {
273
- if (this.u) {
274
- const t = new Date().valueOf();
275
- u && this.u.D(i.k.Vs, t), T.Ws(this.u, T.Os.Ks, t);
276
- }
277
- C.Xs({
278
- url: l.Ys() + "/content_cards/sync",
279
- data: f,
280
- headers: d,
281
- O: (i, e) => {
282
- if (!l.Zs(f, i, d))
283
- return (m = !0), void ("function" == typeof s && s());
284
- l.ti(),
285
- this.Ms(e, t, s),
286
- this.Ss(i),
287
- (m = !1),
288
- T.si(this.u, T.Os.Ks, 1),
289
- "function" == typeof t && t();
290
- },
291
- error: (t) => {
292
- l.ii(t, "retrieving content cards"),
293
- (m = !0),
294
- "function" == typeof s && s();
295
- },
296
- ei: () => {
297
- if (m && n && !this.cs && this.ps + 1 < S) {
298
- T.hi(this.u, T.Os.Ks);
299
- let i = this.fs;
300
- (null == i || i < 1e3 * this.ds) && (i = 1e3 * this.ds),
301
- this.Js(Math.min(3e5, D(1e3 * this.ds, 3 * i)), t, s),
302
- (this.ps = this.ps + 1);
303
- }
304
- },
305
- });
306
- });
270
+ return void r.info("Content card sync being throttled.");
271
+ h && this.zs();
272
+ const d = a.Ps({}, !0);
273
+ u.j(o.C.Ds) !== e.Ss() && this.$s(),
274
+ (d.last_full_sync_at = this.Bt),
275
+ (d.last_card_updated_at = this.Ht);
276
+ const m = a._s(d, S.Gs.Bs, i);
277
+ let p = !1;
278
+ a.Hs(
279
+ d,
280
+ () => {
281
+ if (this.u) {
282
+ const t = new Date().valueOf();
283
+ c && this.u.k(o.C.Ks, t), S.Os(this.u, S.Gs.Bs, t);
284
+ }
285
+ C.Qs({
286
+ url: a.Vs() + "/content_cards/sync",
287
+ data: d,
288
+ headers: m,
289
+ L: (i, e) => {
290
+ if (!a.Ws(d, i, m))
291
+ return (p = !0), void ("function" == typeof s && s());
292
+ a.Xs(),
293
+ this.Ls(e, t, s),
294
+ this.Rs(i),
295
+ (p = !1),
296
+ S.Ys(this.u, S.Gs.Bs, 1),
297
+ "function" == typeof t && t();
298
+ },
299
+ error: (t) => {
300
+ a.Zs(t, "retrieving content cards"),
301
+ (p = !0),
302
+ "function" == typeof s && s();
303
+ },
304
+ ti: () => {
305
+ if (p && h && !this.os && this.cs + 1 < U) {
306
+ S.si(this.u, S.Gs.Bs);
307
+ let i = this.ls;
308
+ (null == i || i < 1e3 * this.us) && (i = 1e3 * this.us),
309
+ this.Es(Math.min(3e5, k(1e3 * this.us, 3 * i)), t, s),
310
+ (this.cs = this.cs + 1);
311
+ }
312
+ },
313
+ });
314
+ },
315
+ S.ii.Bs,
316
+ );
307
317
  }
308
- Ls(t) {
309
- t || this.Yt();
310
- const s = this.ys(this.cards);
318
+ ks(t) {
319
+ t || this.Kt();
320
+ const s = this.ws(this.cards);
311
321
  s.sort((t, s) =>
312
322
  t.pinned && !s.pinned
313
323
  ? -1
@@ -319,73 +329,73 @@ export default class v extends y {
319
329
  ? 1
320
330
  : 0,
321
331
  );
322
- let e = Math.max(this.Qt || 0, this.Kt || 0);
332
+ let i = Math.max(this.Ht || 0, this.Bt || 0);
323
333
  return (
324
- 0 === e && (e = void 0),
325
- this.u && this.u.v(i.k.Rs) === this.Qt && void 0 === e && (e = this.Qt),
326
- new ContentCards(s, l(e))
334
+ 0 === i && (i = void 0),
335
+ this.u && this.u.j(o.C.ys) === this.Ht && void 0 === i && (i = this.Ht),
336
+ new ContentCards(s, l(i))
327
337
  );
328
338
  }
329
- ri(t) {
330
- return this.Bt.It(t);
339
+ ei(t) {
340
+ return this.Jt.It(t);
331
341
  }
332
- Gs() {
333
- (this.Kt = 0),
334
- (this.Qt = 0),
335
- this.u && (this.u.ni(i.k.js), this.u.ni(i.k.Rs));
342
+ $s() {
343
+ (this.Bt = 0),
344
+ (this.Ht = 0),
345
+ this.u && (this.u.hi(o.C.gs), this.u.hi(o.C.ys));
336
346
  }
337
347
  changeUser(t) {
338
348
  t ||
339
349
  ((this.cards = []),
340
- this.Bt.Dt(new ContentCards(this.cards.slice(), null)),
350
+ this.Jt.Dt(new ContentCards(this.cards.slice(), null)),
341
351
  this.u &&
342
- (this.u.ni(i.k.gs),
343
- this.u.ni(i.k.C),
344
- this.u.ni(i.k.K),
345
- this.u.ni(i.k.G))),
346
- this.Gs();
352
+ (this.u.hi(o.C.Cs),
353
+ this.u.hi(o.C.v),
354
+ this.u.hi(o.C.H),
355
+ this.u.hi(o.C.A))),
356
+ this.$s();
347
357
  }
348
358
  clearData(t) {
349
- (this.Kt = 0),
350
- (this.Qt = 0),
359
+ (this.Bt = 0),
360
+ (this.Ht = 0),
351
361
  (this.cards = []),
352
- this.Bt.Dt(new ContentCards(this.cards.slice(), null)),
362
+ this.Jt.Dt(new ContentCards(this.cards.slice(), null)),
353
363
  t &&
354
364
  this.u &&
355
- (this.u.ni(i.k.gs),
356
- this.u.ni(i.k.C),
357
- this.u.ni(i.k.K),
358
- this.u.ni(i.k.G),
359
- this.u.ni(i.k.js),
360
- this.u.ni(i.k.Rs));
365
+ (this.u.hi(o.C.Cs),
366
+ this.u.hi(o.C.v),
367
+ this.u.hi(o.C.H),
368
+ this.u.hi(o.C.A),
369
+ this.u.hi(o.C.gs),
370
+ this.u.hi(o.C.ys));
361
371
  }
362
- ks() {
363
- return !(this.yt && !this.yt.oi()) || (0 !== this.yt.li() && this.ai(), !1);
372
+ Ts() {
373
+ return (
374
+ !!this.yt && (!!this.yt.ri() || (0 !== this.yt.ni() && this.oi(), !1))
375
+ );
364
376
  }
365
- ui(t) {
366
- this.u && this.u.D(i.k.ci, t);
377
+ li(t) {
378
+ this.u && this.u.k(o.C.ai, t);
367
379
  }
368
- fi() {
369
- return this.u ? this.u.v(i.k.ci) : null;
380
+ ui() {
381
+ return this.u ? this.u.j(o.C.ai) : null;
370
382
  }
371
- _s() {
372
- const t = this.u,
373
- s = this.yt;
374
- if (!t || !s) return !0;
375
- const e = t.v(i.k.Vs);
383
+ Js() {
384
+ var t, s, i;
385
+ const e = null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.Ks);
376
386
  if (null == e || isNaN(e)) return !0;
377
- const h = s.di(),
378
- r = s.mi();
387
+ const h = (null === (s = this.yt) || void 0 === s ? void 0 : s.ci()) || -1,
388
+ r = (null === (i = this.yt) || void 0 === i ? void 0 : i.fi()) || -1;
379
389
  if (-1 === h || -1 === r) return !0;
380
- let n = this.fi();
390
+ let n = this.ui();
381
391
  (null == n || isNaN(n)) && (n = h);
382
- const o = (new Date().valueOf() - e) / 1e3;
392
+ const l = (new Date().valueOf() - e) / 1e3;
383
393
  return (
384
- (n = Math.min(n + o / r, h)),
385
- !(n < 1) && ((n = Math.trunc(n) - 1), this.ui(n), !0)
394
+ (n = Math.min(n + l / r, h)),
395
+ !(n < 1) && ((n = Math.trunc(n) - 1), this.li(n), !0)
386
396
  );
387
397
  }
388
- ai() {
389
- this.Bt.Dt(new ContentCards([], new Date())), this.u && this.u.ni(i.k.gs);
398
+ oi() {
399
+ this.Jt.Dt(new ContentCards([], new Date())), this.u && this.u.hi(o.C.Cs);
390
400
  }
391
401
  }
@@ -17,8 +17,8 @@ export default class ContentCards extends x {
17
17
  sr() {
18
18
  requestContentCardsRefresh();
19
19
  }
20
- ur() {
20
+ dr() {
21
21
  return !0;
22
22
  }
23
23
  }
24
- ContentCards.mr = 6e4;
24
+ ContentCards.ur = 6e4;
@@ -1,5 +1,5 @@
1
1
  import g from "./content-cards-provider-factory.js";
2
2
  import e from "../managers/braze-instance.js";
3
3
  export function getCachedContentCards() {
4
- if (e.rr()) return g.er().Ls(!1);
4
+ if (e.X()) return g.rr().ks(!1);
5
5
  }