@braze/web-sdk 5.4.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 +64 -58
  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 +111 -105
  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 +260 -262
  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 +24 -24
  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 +231 -232
  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,139 +1,125 @@
1
- import { createCloseButton as d } from "../../util/component-utils.js";
2
- import { detectSwipe as c, DIRECTIONS as m } from "../../util/dom-utils.js";
3
- import { _handleBrazeAction as u } from "../../Core/handle-braze-action.js";
1
+ import { createCloseButton as T } from "../../util/component-utils.js";
2
+ import { detectSwipe as H, DIRECTIONS as R } from "../../util/dom-utils.js";
3
+ import { _handleBrazeAction as F } from "../../Core/handle-braze-action.js";
4
4
  import { logCardDismissal } from "../index.js";
5
- import { Guid as p } from "../../../shared-lib/index.js";
6
- export const TOP_IMPRESSION_DATA_ATTRIBUTE = "data-ab-had-top-impression";
7
- export const BOTTOM_IMPRESSION_DATA_ATTRIBUTE = "data-ab-had-bottom-impression";
8
- export function topHadImpression(t) {
9
- return null != t && !!t.getAttribute("data-ab-had-top-impression");
10
- }
11
- export function impressOnTop(t) {
12
- null != t && t.setAttribute("data-ab-had-top-impression", "true");
13
- }
14
- export function bottomHadImpression(t) {
15
- return null != t && !!t.getAttribute("data-ab-had-bottom-impression");
16
- }
17
- export function impressOnBottom(t) {
18
- null != t && t.setAttribute("data-ab-had-bottom-impression", "true");
19
- }
5
+ import { Guid as G } from "../../../shared-lib/index.js";
20
6
  export function markCardAsRead(t) {
21
7
  if (null != t) {
22
- const o = t.querySelectorAll(".ab-unread-indicator")[0];
23
- null != o && (o.className += " read");
8
+ const e = t.querySelectorAll(".ab-unread-indicator")[0];
9
+ null != e && (e.className += " read");
24
10
  }
25
11
  }
26
12
  export function getCardId(t) {
27
13
  return t.getAttribute("data-ab-card-id");
28
14
  }
29
- export function _setImageAltText(t, o) {
30
- let e = "";
31
- t.title || t.description || (e = "Feed Image"), o.setAttribute("alt", e);
15
+ export function _setImageAltText(t, e) {
16
+ let o = "";
17
+ t.title || t.description || (o = "Feed Image"), e.setAttribute("alt", o);
32
18
  }
33
- export function setCardHeight(t, o) {
34
- const e = o.querySelectorAll(".ab-image-area");
19
+ export function setCardHeight(t, e) {
20
+ const o = e.querySelectorAll(".ab-image-area");
35
21
  let a,
36
- n = 0;
37
- e.length > 0 && (n = e[0].offsetWidth);
38
- for (const o of t)
39
- if (((a = o.T), a && o.imageUrl && "number" == typeof o.aspectRatio)) {
40
- const t = n / o.aspectRatio;
22
+ i = 0;
23
+ o.length > 0 && (i = o[0].offsetWidth);
24
+ for (const e of t)
25
+ if (((a = e.bt), a && e.imageUrl && "number" == typeof e.aspectRatio)) {
26
+ const t = i / e.aspectRatio;
41
27
  t && (a.style.height = `${t}px`);
42
28
  }
43
29
  }
44
- export function cardToHtml(t, logCardClick, o, e = "ltr") {
30
+ export function cardToHtml(t, logCardClick, e, o = "ltr") {
45
31
  const a = document.createElement("div");
46
- (a.dir = e),
47
- (a.className = "ab-card ab-effect-card " + t._),
32
+ (a.dir = o),
33
+ (a.className = "ab-card ab-effect-card " + t.At),
48
34
  t.id &&
49
35
  (a.setAttribute("data-ab-card-id", t.id), a.setAttribute("id", t.id)),
50
36
  a.setAttribute("role", "article"),
51
37
  a.setAttribute("tabindex", "0");
52
- let n = "",
53
- i = !1;
54
- t.url && "" !== t.url && ((n = t.url), (i = !0));
55
- const r = (e) => (markCardAsRead(a), i && (logCardClick(t), u(n, o, e)), !1);
38
+ let i = "",
39
+ n = !1;
40
+ t.url && "" !== t.url && ((i = t.url), (n = !0));
41
+ const d = (o) => (markCardAsRead(a), n && (logCardClick(t), F(i, e, o)), !1);
56
42
  if (t.pinned) {
57
43
  const t = document.createElement("div");
58
44
  t.className = "ab-pinned-indicator";
59
- const o = document.createElement("i");
60
- (o.className = "fa fa-star"), t.appendChild(o), a.appendChild(t);
45
+ const e = document.createElement("i");
46
+ (e.className = "fa fa-star"), t.appendChild(e), a.appendChild(t);
61
47
  }
62
48
  if (t.imageUrl && "" !== t.imageUrl) {
63
- const o = document.createElement("div");
64
- (o.dir = e), (o.className = "ab-image-area");
65
- const d = document.createElement("img");
49
+ const e = document.createElement("div");
50
+ (e.dir = o), (e.className = "ab-image-area");
51
+ const r = document.createElement("img");
66
52
  if (
67
- (d.setAttribute("src", t.imageUrl),
68
- (d.onload = () => {
53
+ (r.setAttribute("src", t.imageUrl),
54
+ (r.onload = () => {
69
55
  a.style.height = "auto";
70
56
  }),
71
- _setImageAltText(t, d),
72
- o.appendChild(d),
57
+ _setImageAltText(t, r),
58
+ e.appendChild(r),
73
59
  (a.className += " with-image"),
74
- i && !t.S)
60
+ n && !t.Tt)
75
61
  ) {
76
62
  const t = document.createElement("a");
77
- t.setAttribute("href", n),
78
- (t.onclick = r),
79
- t.appendChild(o),
63
+ t.setAttribute("href", i),
64
+ (t.onclick = d),
65
+ t.appendChild(e),
80
66
  a.appendChild(t);
81
- } else a.appendChild(o);
67
+ } else a.appendChild(e);
82
68
  }
83
- const s = document.createElement("div");
84
- if (((s.className = "ab-card-body"), (s.dir = e), t.dismissible)) {
69
+ const r = document.createElement("div");
70
+ if (((r.className = "ab-card-body"), (r.dir = o), t.dismissible)) {
85
71
  t.logCardDismissal = () => logCardDismissal(t);
86
- const o = d("Dismiss Card", void 0, t.dismissCard.bind(t), e);
87
- a.appendChild(o),
88
- c(s, m.U, (t) => {
89
- (a.className += " ab-swiped-left"), o.onclick(t);
72
+ const e = T("Dismiss Card", void 0, t.dismissCard.bind(t), o);
73
+ a.appendChild(e),
74
+ H(r, R.kt, (t) => {
75
+ (a.className += " ab-swiped-left"), e.onclick(t);
90
76
  }),
91
- c(s, m.V, (t) => {
92
- (a.className += " ab-swiped-right"), o.onclick(t);
77
+ H(r, R.Ht, (t) => {
78
+ (a.className += " ab-swiped-right"), e.onclick(t);
93
79
  });
94
80
  }
95
- let l = "",
96
- b = !1;
97
- if ((t.title && "" !== t.title && ((l = t.title), (b = !0)), b)) {
81
+ let c = "",
82
+ s = !1;
83
+ if ((t.title && "" !== t.title && ((c = t.title), (s = !0)), s)) {
98
84
  const t = document.createElement("h1");
99
85
  if (
100
86
  ((t.className = "ab-title"),
101
- (t.id = p.W()),
87
+ (t.id = G.Rt()),
102
88
  a.setAttribute("aria-labelledby", t.id),
103
- i)
89
+ n)
104
90
  ) {
105
- const o = document.createElement("a");
106
- o.setAttribute("href", n),
107
- (o.onclick = r),
108
- o.appendChild(document.createTextNode(l)),
109
- t.appendChild(o);
110
- } else t.appendChild(document.createTextNode(l));
111
- s.appendChild(t);
91
+ const e = document.createElement("a");
92
+ e.setAttribute("href", i),
93
+ (e.onclick = d),
94
+ e.appendChild(document.createTextNode(c)),
95
+ t.appendChild(e);
96
+ } else t.appendChild(document.createTextNode(c));
97
+ r.appendChild(t);
112
98
  }
113
- const f = document.createElement("div");
99
+ const m = document.createElement("div");
114
100
  if (
115
- ((f.className = b ? "ab-description" : "ab-description ab-no-title"),
116
- (f.id = p.W()),
117
- a.setAttribute("aria-describedby", f.id),
118
- t.description && f.appendChild(document.createTextNode(t.description)),
119
- i)
101
+ ((m.className = s ? "ab-description" : "ab-description ab-no-title"),
102
+ (m.id = G.Rt()),
103
+ a.setAttribute("aria-describedby", m.id),
104
+ t.description && m.appendChild(document.createTextNode(t.description)),
105
+ n)
120
106
  ) {
121
- const o = document.createElement("div");
122
- o.className = "ab-url-area";
123
- const e = document.createElement("a");
124
- e.setAttribute("href", n),
125
- t.linkText && e.appendChild(document.createTextNode(t.linkText)),
126
- (e.onclick = r),
127
- o.appendChild(e),
128
- f.appendChild(o);
107
+ const e = document.createElement("div");
108
+ e.className = "ab-url-area";
109
+ const o = document.createElement("a");
110
+ o.setAttribute("href", i),
111
+ t.linkText && o.appendChild(document.createTextNode(t.linkText)),
112
+ (o.onclick = d),
113
+ e.appendChild(o),
114
+ m.appendChild(e);
129
115
  }
130
- s.appendChild(f), a.appendChild(s);
131
- const x = document.createElement("div");
116
+ r.appendChild(m), a.appendChild(r);
117
+ const u = document.createElement("div");
132
118
  return (
133
- (x.className = "ab-unread-indicator"),
134
- t.viewed && (x.className += " read"),
135
- a.appendChild(x),
136
- (t.T = a),
119
+ (u.className = "ab-unread-indicator"),
120
+ t.viewed && (u.className += " read"),
121
+ a.appendChild(u),
122
+ (t.bt = a),
137
123
  a
138
124
  );
139
125
  }
@@ -1,11 +1,11 @@
1
1
  import { Card } from "./models/index.js";
2
- import n from "./card-manager-factory.js";
3
- import { MUST_BE_CARD_WARNING_SUFFIX as f } from "../common/constants.js";
4
- import e from "../managers/braze-instance.js";
5
- import { logger as r } from "../../shared-lib/index.js";
2
+ import _ from "./card-manager-factory.js";
3
+ import { MUST_BE_CARD_WARNING_SUFFIX as K } from "../common/constants.js";
4
+ import r from "../managers/braze-instance.js";
5
+ import { logger as N } from "../../shared-lib/index.js";
6
6
  export function logCardClick(o, m) {
7
7
  return (
8
- !!e.X() &&
9
- (o instanceof Card ? n.m().h(o, m).L : (r.error("card " + f), !1))
8
+ !!r.rr() &&
9
+ (o instanceof Card ? _.ea().logClick(o, m).ss : (N.error("card " + K), !1))
10
10
  );
11
11
  }
@@ -1,10 +1,11 @@
1
1
  import { Card } from "./models/index.js";
2
- import n from "./card-manager-factory.js";
3
- import { MUST_BE_CARD_WARNING_SUFFIX as f } from "../common/constants.js";
4
- import e from "../managers/braze-instance.js";
5
- import { logger as r } from "../../shared-lib/index.js";
2
+ import _ from "./card-manager-factory.js";
3
+ import { MUST_BE_CARD_WARNING_SUFFIX as K } from "../common/constants.js";
4
+ import r from "../managers/braze-instance.js";
5
+ import { logger as N } from "../../shared-lib/index.js";
6
6
  export function logCardDismissal(o) {
7
7
  return (
8
- !!e.X() && (o instanceof Card ? n.m().B(o).L : (r.error("card " + f), !1))
8
+ !!r.rr() &&
9
+ (o instanceof Card ? _.ea().ct(o).ss : (N.error("card " + K), !1))
9
10
  );
10
11
  }
@@ -1,13 +1,13 @@
1
1
  import { Card } from "./models/index.js";
2
- import n from "./card-manager-factory.js";
3
- import e from "../managers/braze-instance.js";
4
- import { isArray as j } from "../util/code-utils.js";
5
- import { MUST_BE_CARD_WARNING_SUFFIX as f } from "../common/constants.js";
6
- import { logger as r } from "../../shared-lib/index.js";
7
- export function logCardImpressions(o, s) {
8
- if (!e.X()) return !1;
9
- if (!j(o)) return r.error("cards must be an array"), !1;
10
- for (const n of o)
11
- if (!(n instanceof Card)) return r.error(`Each card in cards ${f}`), !1;
12
- return n.m().G(o, s).L;
2
+ import _ from "./card-manager-factory.js";
3
+ import r from "../managers/braze-instance.js";
4
+ import { isArray as w } from "../util/code-utils.js";
5
+ import { MUST_BE_CARD_WARNING_SUFFIX as K } from "../common/constants.js";
6
+ import { logger as N } from "../../shared-lib/index.js";
7
+ export function logCardImpressions(o, n) {
8
+ if (!r.rr()) return !1;
9
+ if (!w(o)) return N.error("cards must be an array"), !1;
10
+ for (const r of o)
11
+ if (!(r instanceof Card)) return N.error(`Each card in cards ${K}`), !1;
12
+ return _.ea().jt(o, n).ss;
13
13
  }
@@ -2,31 +2,31 @@ import Card from "./card.js";
2
2
  export default class CaptionedImage extends Card {
3
3
  constructor(t, s, i, h, e, r, a, o, c, n, d, p, u, l, m, f) {
4
4
  super(t, s, i, h, e, r, a, o, c, n, d, p, u, l, m, f),
5
- (this._ = "ab-captioned-image"),
6
- (this.S = !0),
5
+ (this.At = "ab-captioned-image"),
6
+ (this.Tt = !0),
7
7
  (this.test = !1);
8
8
  }
9
- Y() {
9
+ Bs() {
10
10
  const t = {};
11
11
  return (
12
- (t[Card.tt.Z] = Card.it.st),
13
- (t[Card.tt.ht] = this.id),
14
- (t[Card.tt.et] = this.viewed),
15
- (t[Card.tt.rt] = this.title),
16
- (t[Card.tt.ot] = this.imageUrl),
17
- (t[Card.tt.ct] = this.description),
18
- (t[Card.tt.nt] = this.updated),
19
- (t[Card.tt.dt] = this.created),
20
- (t[Card.tt.ut] = this.categories),
21
- (t[Card.tt.lt] = this.expiresAt),
22
- (t[Card.tt.URL] = this.url),
23
- (t[Card.tt.ft] = this.linkText),
24
- (t[Card.tt.xt] = this.aspectRatio),
25
- (t[Card.tt.bt] = this.extras),
26
- (t[Card.tt.gt] = this.pinned),
27
- (t[Card.tt.jt] = this.dismissible),
28
- (t[Card.tt.zt] = this.clicked),
29
- (t[Card.tt.kt] = this.test),
12
+ (t[Card.qt.zt] = Card.Dt.Bt),
13
+ (t[Card.qt.Et] = this.id),
14
+ (t[Card.qt.Ft] = this.viewed),
15
+ (t[Card.qt.Gt] = this.title),
16
+ (t[Card.qt.Jt] = this.imageUrl),
17
+ (t[Card.qt.Kt] = this.description),
18
+ (t[Card.qt.Lt] = this.updated),
19
+ (t[Card.qt.Mt] = this.created),
20
+ (t[Card.qt.Nt] = this.categories),
21
+ (t[Card.qt.Ot] = this.expiresAt),
22
+ (t[Card.qt.URL] = this.url),
23
+ (t[Card.qt.Pt] = this.linkText),
24
+ (t[Card.qt.Qt] = this.aspectRatio),
25
+ (t[Card.qt.St] = this.extras),
26
+ (t[Card.qt.Ut] = this.pinned),
27
+ (t[Card.qt.Vt] = this.dismissible),
28
+ (t[Card.qt.Wt] = this.clicked),
29
+ (t[Card.qt.Xt] = this.test),
30
30
  t
31
31
  );
32
32
  }
@@ -1,18 +1,18 @@
1
1
  import {
2
- convertMsToSeconds as h,
3
- dateFromUnixTimestamp as l,
2
+ convertMsToSeconds as L,
3
+ dateFromUnixTimestamp as O,
4
4
  } from "../../util/date-utils.js";
5
- import { FEED_ANIMATION_DURATION as E } from "../../common/constants.js";
6
- import T from "../../managers/subscription-manager.js";
7
- import r from "../../../shared-lib/logger.js";
5
+ import { FEED_ANIMATION_DURATION as P } from "../../common/constants.js";
6
+ import u from "../../managers/subscription-manager.js";
7
+ import N from "../../../shared-lib/logger.js";
8
8
  export default class Card {
9
- constructor(t, i, s, h, l, n, e, r, u, E, o, T, I, a, N, c) {
9
+ constructor(t, i, s, h, n, l, e, r, u, E, o, T, I, a, c, N) {
10
10
  (this.id = t),
11
11
  (this.viewed = i),
12
12
  (this.title = s),
13
13
  (this.imageUrl = h),
14
- (this.description = l),
15
- (this.created = n),
14
+ (this.description = n),
15
+ (this.created = l),
16
16
  (this.updated = e),
17
17
  (this.categories = r),
18
18
  (this.expiresAt = u),
@@ -21,14 +21,14 @@ export default class Card {
21
21
  (this.aspectRatio = T),
22
22
  (this.extras = I),
23
23
  (this.pinned = a),
24
- (this.dismissible = N),
25
- (this.clicked = c),
24
+ (this.dismissible = c),
25
+ (this.clicked = N),
26
26
  (this.id = t),
27
27
  (this.viewed = i || !1),
28
28
  (this.title = s || ""),
29
29
  (this.imageUrl = h),
30
- (this.description = l || ""),
31
- (this.created = n || null),
30
+ (this.description = n || ""),
31
+ (this.created = l || null),
32
32
  (this.updated = e || null),
33
33
  (this.categories = r || []),
34
34
  (this.expiresAt = u || null),
@@ -40,30 +40,31 @@ export default class Card {
40
40
  (this.aspectRatio = isNaN(T) ? null : T)),
41
41
  (this.extras = I || {}),
42
42
  (this.pinned = a || !1),
43
- (this.dismissible = N || !1),
43
+ (this.dismissible = c || !1),
44
44
  (this.dismissed = !1),
45
- (this.clicked = c || !1),
45
+ (this.clicked = N || !1),
46
46
  (this.isControl = !1),
47
47
  (this.test = !1),
48
- (this.Et = null),
49
- (this.Tt = null);
48
+ (this._t = null),
49
+ (this.Yt = null),
50
+ (this.Zt = null);
50
51
  }
51
52
  subscribeToClickedEvent(t) {
52
- return this.Nt().It(t);
53
+ return this.ti().Ns(t);
53
54
  }
54
55
  subscribeToDismissedEvent(t) {
55
- return this.St().It(t);
56
+ return this.ii().Ns(t);
56
57
  }
57
58
  removeSubscription(t) {
58
- this.Nt().removeSubscription(t), this.St().removeSubscription(t);
59
+ this.ti().removeSubscription(t), this.ii().removeSubscription(t);
59
60
  }
60
61
  removeAllSubscriptions() {
61
- this.Nt().removeAllSubscriptions(), this.St().removeAllSubscriptions();
62
+ this.ti().removeAllSubscriptions(), this.ii().removeAllSubscriptions();
62
63
  }
63
64
  dismissCard() {
64
65
  if (!this.dismissible || this.dismissed) return;
65
66
  "function" == typeof this.logCardDismissal && this.logCardDismissal();
66
- let t = this.T;
67
+ let t = this.bt;
67
68
  !t && this.id && (t = document.getElementById(this.id)),
68
69
  t &&
69
70
  ((t.style.height = t.offsetHeight + "px"),
@@ -75,123 +76,128 @@ export default class Card {
75
76
  (t.style.margin = "0"),
76
77
  setTimeout(function () {
77
78
  t && t.parentNode && t.parentNode.removeChild(t);
78
- }, Card.At));
79
- }, E));
79
+ }, Card.si));
80
+ }, P));
80
81
  }
81
- Nt() {
82
- return null == this.Et && (this.Et = new T()), this.Et;
82
+ ti() {
83
+ return null == this._t && (this._t = new u()), this._t;
83
84
  }
84
- St() {
85
- return null == this.Tt && (this.Tt = new T()), this.Tt;
85
+ ii() {
86
+ return null == this.Yt && (this.Yt = new u()), this.Yt;
86
87
  }
87
- K() {
88
- this.viewed = !0;
88
+ wt() {
89
+ const t = new Date().valueOf();
90
+ return (
91
+ !(null != this.Zt && t - this.Zt < Card.hi) &&
92
+ ((this.Zt = t), (this.viewed = !0), !0)
93
+ );
89
94
  }
90
- p() {
91
- (this.viewed = !0), (this.clicked = !0), this.Nt().Dt();
95
+ rt() {
96
+ (this.viewed = !0), (this.clicked = !0), this.ti().X();
92
97
  }
93
- N() {
98
+ ft() {
94
99
  return (
95
100
  !(!this.dismissible || this.dismissed) &&
96
- ((this.dismissed = !0), this.St().Dt(), !0)
101
+ ((this.dismissed = !0), this.ii().X(), !0)
97
102
  );
98
103
  }
99
- Ct(t) {
100
- if (null == t || t[Card.Rt.ht] !== this.id) return !0;
101
- if (t[Card.Rt.Lt]) return !1;
104
+ ni(t) {
105
+ if (null == t || t[Card.li.Et] !== this.id) return !0;
106
+ if (t[Card.li.ei]) return !1;
102
107
  if (
103
- null != t[Card.Rt.nt] &&
108
+ null != t[Card.li.Lt] &&
104
109
  null != this.updated &&
105
- parseInt(t[Card.Rt.nt]) < h(this.updated.valueOf())
110
+ parseInt(t[Card.li.Lt]) < L(this.updated.valueOf())
106
111
  )
107
112
  return !0;
108
113
  if (
109
- (t[Card.Rt.et] && !this.viewed && (this.viewed = !0),
110
- t[Card.Rt.zt] && !this.clicked && (this.clicked = t[Card.Rt.zt]),
111
- null != t[Card.Rt.rt] && (this.title = t[Card.Rt.rt]),
112
- null != t[Card.Rt.ot] && (this.imageUrl = t[Card.Rt.ot]),
113
- null != t[Card.Rt.ct] && (this.description = t[Card.Rt.ct]),
114
- null != t[Card.Rt.nt])
114
+ (t[Card.li.Ft] && !this.viewed && (this.viewed = !0),
115
+ t[Card.li.Wt] && !this.clicked && (this.clicked = t[Card.li.Wt]),
116
+ null != t[Card.li.Gt] && (this.title = t[Card.li.Gt]),
117
+ null != t[Card.li.Jt] && (this.imageUrl = t[Card.li.Jt]),
118
+ null != t[Card.li.Kt] && (this.description = t[Card.li.Kt]),
119
+ null != t[Card.li.Lt])
115
120
  ) {
116
- const i = l(t[Card.Rt.nt]);
121
+ const i = O(t[Card.li.Lt]);
117
122
  null != i && (this.updated = i);
118
123
  }
119
- if (null != t[Card.Rt.lt]) {
124
+ if (null != t[Card.li.Ot]) {
120
125
  let i;
121
- (i = t[Card.Rt.lt] === Card._t ? null : l(t[Card.Rt.lt])),
126
+ (i = t[Card.li.Ot] === Card.ri ? null : O(t[Card.li.Ot])),
122
127
  (this.expiresAt = i);
123
128
  }
124
129
  if (
125
- (null != t[Card.Rt.URL] && (this.url = t[Card.Rt.URL]),
126
- null != t[Card.Rt.ft] && (this.linkText = t[Card.Rt.ft]),
127
- null != t[Card.Rt.xt])
130
+ (null != t[Card.li.URL] && (this.url = t[Card.li.URL]),
131
+ null != t[Card.li.Pt] && (this.linkText = t[Card.li.Pt]),
132
+ null != t[Card.li.Qt])
128
133
  ) {
129
- const i = parseFloat(t[Card.Rt.xt].toString());
134
+ const i = parseFloat(t[Card.li.Qt].toString());
130
135
  this.aspectRatio = isNaN(i) ? null : i;
131
136
  }
132
137
  return (
133
- null != t[Card.Rt.bt] && (this.extras = t[Card.Rt.bt]),
134
- null != t[Card.Rt.gt] && (this.pinned = t[Card.Rt.gt]),
135
- null != t[Card.Rt.jt] && (this.dismissible = t[Card.Rt.jt]),
136
- null != t[Card.Rt.kt] && (this.test = t[Card.Rt.kt]),
138
+ null != t[Card.li.St] && (this.extras = t[Card.li.St]),
139
+ null != t[Card.li.Ut] && (this.pinned = t[Card.li.Ut]),
140
+ null != t[Card.li.Vt] && (this.dismissible = t[Card.li.Vt]),
141
+ null != t[Card.li.Xt] && (this.test = t[Card.li.Xt]),
137
142
  !0
138
143
  );
139
144
  }
140
- Y() {
141
- r.error("Must be implemented in a subclass");
145
+ Bs() {
146
+ N.error("Must be implemented in a subclass");
142
147
  }
143
148
  }
144
- (Card._t = -1),
145
- (Card.Rt = {
146
- ht: "id",
147
- et: "v",
148
- jt: "db",
149
- Lt: "r",
150
- nt: "ca",
151
- gt: "p",
152
- lt: "ea",
153
- bt: "e",
154
- Z: "tp",
155
- ot: "i",
156
- rt: "tt",
157
- ct: "ds",
149
+ (Card.ri = -1),
150
+ (Card.li = {
151
+ Et: "id",
152
+ Ft: "v",
153
+ Vt: "db",
154
+ ei: "r",
155
+ Lt: "ca",
156
+ Ut: "p",
157
+ Ot: "ea",
158
+ St: "e",
159
+ zt: "tp",
160
+ Jt: "i",
161
+ Gt: "tt",
162
+ Kt: "ds",
158
163
  URL: "u",
159
- ft: "dm",
160
- xt: "ar",
161
- zt: "cl",
162
- kt: "t",
164
+ Pt: "dm",
165
+ Qt: "ar",
166
+ Wt: "cl",
167
+ Xt: "t",
163
168
  }),
164
- (Card.it = {
165
- st: "captioned_image",
166
- Ot: "text_announcement",
167
- Mt: "short_news",
168
- Pt: "banner_image",
169
- Ut: "control",
169
+ (Card.Dt = {
170
+ Bt: "captioned_image",
171
+ ui: "text_announcement",
172
+ Ei: "short_news",
173
+ oi: "banner_image",
174
+ Ti: "control",
170
175
  }),
171
- (Card.tt = {
172
- ht: "id",
173
- et: "v",
174
- jt: "db",
175
- dt: "cr",
176
- nt: "ca",
177
- gt: "p",
178
- ut: "t",
179
- lt: "ea",
180
- bt: "e",
181
- Z: "tp",
182
- ot: "i",
183
- rt: "tt",
184
- ct: "ds",
176
+ (Card.qt = {
177
+ Et: "id",
178
+ Ft: "v",
179
+ Vt: "db",
180
+ Mt: "cr",
181
+ Lt: "ca",
182
+ Ut: "p",
183
+ Nt: "t",
184
+ Ot: "ea",
185
+ St: "e",
186
+ zt: "tp",
187
+ Jt: "i",
188
+ Gt: "tt",
189
+ Kt: "ds",
185
190
  URL: "u",
186
- ft: "dm",
187
- xt: "ar",
188
- zt: "cl",
189
- kt: "s",
191
+ Pt: "dm",
192
+ Qt: "ar",
193
+ Wt: "cl",
194
+ Xt: "s",
190
195
  }),
191
- (Card.Gt = {
192
- Xt: "ADVERTISING",
193
- vt: "ANNOUNCEMENTS",
194
- Vt: "NEWS",
195
- Wt: "SOCIAL",
196
+ (Card.Ii = {
197
+ ai: "ADVERTISING",
198
+ ci: "ANNOUNCEMENTS",
199
+ Ni: "NEWS",
200
+ mi: "SOCIAL",
196
201
  }),
197
- (Card.At = 400);
202
+ (Card.si = 400),
203
+ (Card.hi = 1e4);