@braze/web-sdk 4.10.1 → 5.0.1

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 (202) hide show
  1. package/index.d.ts +26 -111
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +8 -1
  4. package/shared-lib/encoding-utils.js +12 -1
  5. package/shared-lib/event-types.js +34 -1
  6. package/shared-lib/guid.js +10 -1
  7. package/shared-lib/indexed-db-adapter.js +352 -1
  8. package/shared-lib/logger.js +38 -1
  9. package/shared-lib/supported-options.js +26 -1
  10. package/shared-lib/types.js +1 -1
  11. package/src/Card/card-manager-factory.js +14 -1
  12. package/src/Card/card-manager.js +78 -1
  13. package/src/Card/display/card-display.js +138 -1
  14. package/src/Card/index.js +6 -1
  15. package/src/Card/log-card-click.js +11 -1
  16. package/src/Card/log-card-dismissal.js +11 -1
  17. package/src/Card/log-card-impressions.js +13 -1
  18. package/src/Card/log-content-card-click.js +4 -1
  19. package/src/Card/log-content-card-impressions.js +4 -1
  20. package/src/Card/models/captioned-image.js +33 -1
  21. package/src/Card/models/card.js +197 -1
  22. package/src/Card/models/classic-card.js +32 -1
  23. package/src/Card/models/control-card.js +23 -1
  24. package/src/Card/models/image-only.js +31 -1
  25. package/src/Card/models/index.js +5 -1
  26. package/src/Card/types.js +1 -1
  27. package/src/Card/util/card-factory.js +104 -1
  28. package/src/ContentCards/content-cards-provider-factory.js +20 -1
  29. package/src/ContentCards/content-cards-provider.js +391 -1
  30. package/src/ContentCards/content-cards.js +24 -1
  31. package/src/ContentCards/get-cached-content-cards.js +5 -1
  32. package/src/ContentCards/index.js +7 -1
  33. package/src/ContentCards/request-content-cards-refresh.js +5 -1
  34. package/src/ContentCards/subscribe-to-content-cards-updates.js +17 -1
  35. package/src/ContentCards/types.js +1 -1
  36. package/src/ContentCards/ui/hide-content-cards.js +8 -1
  37. package/src/ContentCards/ui/show-content-cards.js +77 -1
  38. package/src/ContentCards/ui/toggle-content-cards.js +8 -1
  39. package/src/Core/add-sdk-metadata.js +26 -1
  40. package/src/Core/braze-sdk-metadata.js +10 -1
  41. package/src/Core/change-user.js +17 -1
  42. package/src/Core/destroy.js +5 -1
  43. package/src/Core/device-properties.js +9 -1
  44. package/src/Core/disable-sdk.js +15 -1
  45. package/src/Core/enable-sdk.js +11 -1
  46. package/src/Core/get-device-id.js +13 -1
  47. package/src/Core/get-user.js +4 -1
  48. package/src/Core/handle-braze-action.js +87 -1
  49. package/src/Core/index.js +23 -1
  50. package/src/Core/initialize.js +4 -1
  51. package/src/Core/is-disabled.js +4 -1
  52. package/src/Core/log-custom-event.js +38 -1
  53. package/src/Core/log-purchase.js +245 -1
  54. package/src/Core/open-session.js +25 -1
  55. package/src/Core/remove-all-subscriptions.js +4 -1
  56. package/src/Core/remove-subscription.js +4 -1
  57. package/src/Core/request-immediate-data-flush.js +6 -1
  58. package/src/Core/set-logger.js +4 -1
  59. package/src/Core/set-sdk-authentication-signature.js +8 -1
  60. package/src/Core/subscribe-to-sdk-authentication-failures.js +6 -1
  61. package/src/Core/toggle-logging.js +4 -1
  62. package/src/Core/types.js +1 -1
  63. package/src/Core/wipe-data.js +16 -1
  64. package/src/FeatureFlags/feature-flag-factory.js +24 -1
  65. package/src/FeatureFlags/feature-flag.js +64 -1
  66. package/src/FeatureFlags/feature-flags-provider-factory.js +19 -1
  67. package/src/FeatureFlags/feature-flags-provider.js +145 -1
  68. package/src/FeatureFlags/get-all-feature-flags.js +12 -1
  69. package/src/FeatureFlags/get-feature-flag.js +10 -1
  70. package/src/FeatureFlags/index.js +6 -1
  71. package/src/FeatureFlags/log-feature-flag-impression.js +23 -1
  72. package/src/FeatureFlags/refresh-feature-flags.js +9 -1
  73. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +9 -1
  74. package/src/FeatureFlags/types.js +1 -1
  75. package/src/Feed/feed-provider-factory.js +18 -1
  76. package/src/Feed/feed-provider.js +90 -1
  77. package/src/Feed/feed.js +20 -1
  78. package/src/Feed/get-cached-feed.js +5 -1
  79. package/src/Feed/index.js +8 -1
  80. package/src/Feed/log-feed-displayed.js +7 -1
  81. package/src/Feed/request-feed-refresh.js +5 -1
  82. package/src/Feed/subscribe-to-feed-updates.js +5 -1
  83. package/src/Feed/types.js +1 -1
  84. package/src/Feed/ui/hide-feed.js +7 -1
  85. package/src/Feed/ui/show-feed.js +96 -1
  86. package/src/Feed/ui/toggle-feed.js +8 -1
  87. package/src/InAppMessage/defer-in-app-message.js +13 -1
  88. package/src/InAppMessage/display/get-animation-effect.js +19 -1
  89. package/src/InAppMessage/display/html-message-to-html.js +243 -1
  90. package/src/InAppMessage/display/in-app-message-to-html.js +188 -1
  91. package/src/InAppMessage/display/modal-utils.js +73 -1
  92. package/src/InAppMessage/get-deferred-in-app-message.js +5 -1
  93. package/src/InAppMessage/in-app-message-factory.js +166 -1
  94. package/src/InAppMessage/in-app-message-manager-factory.js +16 -1
  95. package/src/InAppMessage/in-app-message-manager.js +248 -1
  96. package/src/InAppMessage/index.js +16 -1
  97. package/src/InAppMessage/log-in-app-message-button-click.js +27 -1
  98. package/src/InAppMessage/log-in-app-message-click.js +19 -1
  99. package/src/InAppMessage/log-in-app-message-html-click.js +23 -1
  100. package/src/InAppMessage/log-in-app-message-impression.js +13 -1
  101. package/src/InAppMessage/models/control-message.js +11 -1
  102. package/src/InAppMessage/models/full-screen-message.js +105 -1
  103. package/src/InAppMessage/models/html-message.js +68 -1
  104. package/src/InAppMessage/models/in-app-message-button.js +47 -1
  105. package/src/InAppMessage/models/in-app-message.js +382 -1
  106. package/src/InAppMessage/models/modal-message.js +101 -1
  107. package/src/InAppMessage/models/slide-up-message.js +84 -1
  108. package/src/InAppMessage/models/templated-in-app-message.js +19 -1
  109. package/src/InAppMessage/subscribe-to-in-app-message.js +10 -1
  110. package/src/InAppMessage/types.js +1 -1
  111. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +15 -1
  112. package/src/InAppMessage/ui/show-in-app-message.js +181 -1
  113. package/src/InAppMessage/utils/in-app-message-utils.js +1 -1
  114. package/src/Push/index.js +5 -1
  115. package/src/Push/is-push-blocked.js +5 -1
  116. package/src/Push/is-push-permission-granted.js +5 -1
  117. package/src/Push/is-push-supported.js +5 -1
  118. package/src/Push/push-manager-factory.js +30 -1
  119. package/src/Push/push-manager.js +387 -1
  120. package/src/Push/request-push-permission.js +9 -1
  121. package/src/Push/types.js +1 -1
  122. package/src/Push/unregister-push.js +5 -1
  123. package/src/Push/utils/push-utils.js +36 -1
  124. package/src/User/index.js +1 -1
  125. package/src/User/types.js +1 -1
  126. package/src/User/user-manager.js +73 -1
  127. package/src/User/user.js +302 -1
  128. package/src/common/base-feed.js +29 -1
  129. package/src/common/base-provider.js +6 -1
  130. package/src/common/constants.js +14 -1
  131. package/src/common/event-logger.js +31 -1
  132. package/src/common/feed-display.js +210 -1
  133. package/src/common/translations.js +148 -1
  134. package/src/common/types.js +1 -1
  135. package/src/index.js +9 -1
  136. package/src/l10n/l10n-manager-factory.js +22 -1
  137. package/src/l10n/l10n-manager.js +25 -1
  138. package/src/l10n/types.js +1 -1
  139. package/src/managers/auth-manager.js +51 -1
  140. package/src/managers/braze-instance.js +322 -1
  141. package/src/managers/device-manager.js +85 -1
  142. package/src/managers/network-manager.js +256 -1
  143. package/src/managers/server-config-manager.js +108 -1
  144. package/src/managers/session-manager.js +75 -1
  145. package/src/managers/storage-manager-factory.js +42 -1
  146. package/src/managers/storage-manager.js +426 -1
  147. package/src/managers/subscription-manager.js +28 -1
  148. package/src/managers/types.js +1 -1
  149. package/src/models/backend-errors.js +8 -1
  150. package/src/models/braze-event.js +47 -1
  151. package/src/models/braze-sdk-metadata.js +10 -1
  152. package/src/models/device.js +18 -1
  153. package/src/models/identifier.js +19 -1
  154. package/src/models/push-token.js +27 -1
  155. package/src/models/request-result.js +8 -1
  156. package/src/models/server-config.js +48 -1
  157. package/src/models/types.js +1 -1
  158. package/src/request-controller.js +311 -1
  159. package/src/triggers/models/custom-event-data.js +14 -1
  160. package/src/triggers/models/custom-event-property-data.js +21 -1
  161. package/src/triggers/models/filter-set.js +55 -1
  162. package/src/triggers/models/filter.js +102 -1
  163. package/src/triggers/models/in-app-message-click-data.js +25 -1
  164. package/src/triggers/models/purchase-data.js +14 -1
  165. package/src/triggers/models/purchase-property-data.js +21 -1
  166. package/src/triggers/models/push-click-data.js +15 -1
  167. package/src/triggers/models/trigger-condition.js +105 -1
  168. package/src/triggers/models/trigger-events.js +8 -1
  169. package/src/triggers/models/trigger.js +122 -1
  170. package/src/triggers/triggers-provider-factory.js +34 -1
  171. package/src/triggers/triggers-provider.js +326 -1
  172. package/src/triggers/types.js +1 -1
  173. package/src/types.js +1 -1
  174. package/src/ui/js/attach-css.js +13 -1
  175. package/src/ui/js/feed-css.js +12 -1
  176. package/src/ui/js/iam-css.js +12 -1
  177. package/src/ui/js/index.js +3 -1
  178. package/src/ui/js/load-font-awesome.js +13 -1
  179. package/src/util/base-device-parser.js +14 -1
  180. package/src/util/braze-actions.js +84 -1
  181. package/src/util/browser-detector.js +84 -1
  182. package/src/util/client-hints-parser.js +66 -1
  183. package/src/util/code-utils.js +100 -1
  184. package/src/util/color-utils.js +29 -1
  185. package/src/util/component-utils.js +26 -1
  186. package/src/util/date-utils.js +28 -1
  187. package/src/util/deprecation-utils.js +5 -1
  188. package/src/util/device-constants.js +13 -1
  189. package/src/util/dom-utils.js +91 -1
  190. package/src/util/error-utils.js +2 -1
  191. package/src/util/key-codes.js +1 -1
  192. package/src/util/math.js +5 -1
  193. package/src/util/net.js +71 -1
  194. package/src/util/request-header-utils.js +46 -1
  195. package/src/util/string-utils.js +22 -1
  196. package/src/util/types.js +1 -1
  197. package/src/util/url-utils.js +20 -1
  198. package/src/util/user-agent-parser.js +80 -1
  199. package/src/util/validation-utils.js +217 -1
  200. package/src/util/window-utils.js +34 -1
  201. package/src/Card/models/banner.js +0 -1
  202. package/src/ContentCards/log-content-cards-displayed.js +0 -1
@@ -1 +1,105 @@
1
- import Qt from"./custom-event-data.js";import Zt from"./custom-event-property-data.js";import Yt from"./filter-set.js";import si from"./in-app-message-click-data.js";import rs from"./purchase-data.js";import is from"./purchase-property-data.js";import lr from"./push-click-data.js";import tt from"./trigger-events.js";import r from"../../../shared-lib/braze-shared-lib.js";import{getErrorMessage as ei}from"../../util/error-utils.js";export default class ri{constructor(e,t){this.type=e,this.data=t,this.type=e,this.data=t}ec(e,t){return ri.rc[this.type]===e&&(null==this.data||this.data.Bl(t))}static Bu(e,t){let s=null;try{s=window.atob(e)}catch(t){return r.j.info("Failed to unencode analytics id "+e+": "+ei(t)),!1}return t===s.split("_")[0]}static fromJson(e){const t=e.type;let r=null;switch(t){case ri.Wr.OPEN:case ri.Wr.zs:break;case ri.Wr.Rr:r=rs.fromJson(e.data);break;case ri.Wr.sc:r=is.fromJson(e.data);break;case ri.Wr.zr:r=lr.fromJson(e.data);break;case ri.Wr.$e:r=Qt.fromJson(e.data);break;case ri.Wr.ac:r=Zt.fromJson(e.data);break;case ri.Wr.ro:r=si.fromJson(e.data)}return new ri(t,r)}ss(){return{t:this.type,d:this.data?this.data.ss():null}}static Yn(e){let t,r=null;switch(e.t){case ri.Wr.OPEN:case ri.Wr.zs:break;case ri.Wr.Rr:r=new rs(e.d);break;case ri.Wr.sc:t=e.d||{},r=new is(t.id,Yt.Yn(t.pf||[]));break;case ri.Wr.zr:r=new lr(e.d);break;case ri.Wr.$e:r=new Qt(e.d);break;case ri.Wr.ac:t=e.d||{},r=new Zt(t.e,Yt.Yn(t.pf||[]));break;case ri.Wr.ro:r=new si(e.d)}return new ri(e.t,r)}}ri.Wr={OPEN:"open",Rr:"purchase",sc:"purchase_property",zr:"push_click",$e:"custom_event",ac:"custom_event_property",ro:"iam_click",zs:"test"},ri.rc={},ri.rc[ri.Wr.OPEN]=tt.OPEN,ri.rc[ri.Wr.Rr]=tt.Rr,ri.rc[ri.Wr.sc]=tt.Rr,ri.rc[ri.Wr.zr]=tt.zr,ri.rc[ri.Wr.$e]=tt.$e,ri.rc[ri.Wr.ac]=tt.$e,ri.rc[ri.Wr.ro]=tt.ro,ri.rc[ri.Wr.zs]=tt.zs;
1
+ import Qt from "./custom-event-data.js";
2
+ import Yt from "./custom-event-property-data.js";
3
+ import Wt from "./filter-set.js";
4
+ import si from "./in-app-message-click-data.js";
5
+ import rs from "./purchase-data.js";
6
+ import is from "./purchase-property-data.js";
7
+ import sr from "./push-click-data.js";
8
+ import tt from "./trigger-events.js";
9
+ import r from "../../../shared-lib/braze-shared-lib.js";
10
+ import { getErrorMessage as ei } from "../../util/error-utils.js";
11
+ export default class ri {
12
+ constructor(e, t) {
13
+ (this.type = e), (this.data = t), (this.type = e), (this.data = t);
14
+ }
15
+ ec(e, t) {
16
+ return ri.rc[this.type] === e && (null == this.data || this.data.Bl(t));
17
+ }
18
+ static Bu(e, t) {
19
+ let s = null;
20
+ try {
21
+ s = window.atob(e);
22
+ } catch (t) {
23
+ return (
24
+ r.j.info("Failed to unencode analytics id " + e + ": " + ei(t)), !1
25
+ );
26
+ }
27
+ return t === s.split("_")[0];
28
+ }
29
+ static fromJson(e) {
30
+ const t = e.type;
31
+ let r = null;
32
+ switch (t) {
33
+ case ri.Wr.OPEN:
34
+ case ri.Wr.vt:
35
+ break;
36
+ case ri.Wr.Rr:
37
+ r = rs.fromJson(e.data);
38
+ break;
39
+ case ri.Wr.sc:
40
+ r = is.fromJson(e.data);
41
+ break;
42
+ case ri.Wr.zr:
43
+ r = sr.fromJson(e.data);
44
+ break;
45
+ case ri.Wr.$e:
46
+ r = Qt.fromJson(e.data);
47
+ break;
48
+ case ri.Wr.ac:
49
+ r = Yt.fromJson(e.data);
50
+ break;
51
+ case ri.Wr.ro:
52
+ r = si.fromJson(e.data);
53
+ }
54
+ return new ri(t, r);
55
+ }
56
+ tt() {
57
+ return { t: this.type, d: this.data ? this.data.tt() : null };
58
+ }
59
+ static Yn(e) {
60
+ let t,
61
+ r = null;
62
+ switch (e.t) {
63
+ case ri.Wr.OPEN:
64
+ case ri.Wr.vt:
65
+ break;
66
+ case ri.Wr.Rr:
67
+ r = new rs(e.d);
68
+ break;
69
+ case ri.Wr.sc:
70
+ (t = e.d || {}), (r = new is(t.id, Wt.Yn(t.pf || [])));
71
+ break;
72
+ case ri.Wr.zr:
73
+ r = new sr(e.d);
74
+ break;
75
+ case ri.Wr.$e:
76
+ r = new Qt(e.d);
77
+ break;
78
+ case ri.Wr.ac:
79
+ (t = e.d || {}), (r = new Yt(t.e, Wt.Yn(t.pf || [])));
80
+ break;
81
+ case ri.Wr.ro:
82
+ r = new si(e.d);
83
+ }
84
+ return new ri(e.t, r);
85
+ }
86
+ }
87
+ (ri.Wr = {
88
+ OPEN: "open",
89
+ Rr: "purchase",
90
+ sc: "purchase_property",
91
+ zr: "push_click",
92
+ $e: "custom_event",
93
+ ac: "custom_event_property",
94
+ ro: "iam_click",
95
+ vt: "test",
96
+ }),
97
+ (ri.rc = {}),
98
+ (ri.rc[ri.Wr.OPEN] = tt.OPEN),
99
+ (ri.rc[ri.Wr.Rr] = tt.Rr),
100
+ (ri.rc[ri.Wr.sc] = tt.Rr),
101
+ (ri.rc[ri.Wr.zr] = tt.zr),
102
+ (ri.rc[ri.Wr.$e] = tt.$e),
103
+ (ri.rc[ri.Wr.ac] = tt.$e),
104
+ (ri.rc[ri.Wr.ro] = tt.ro),
105
+ (ri.rc[ri.Wr.vt] = tt.vt);
@@ -1 +1,8 @@
1
- export default{OPEN:"open",Rr:"purchase",zr:"push_click",$e:"custom_event",ro:"iam_click",zs:"test"};
1
+ export default {
2
+ OPEN: "open",
3
+ Rr: "purchase",
4
+ zr: "push_click",
5
+ $e: "custom_event",
6
+ ro: "iam_click",
7
+ vt: "test",
8
+ };
@@ -1 +1,122 @@
1
- import{dateFromUnixTimestamp as l,rehydrateDateAfterJsonization as w}from"../../util/date-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";import ri from"./trigger-condition.js";import{validateValueIsFromEnum as H}from"../../util/code-utils.js";export default class mt{constructor(t,i=[],s,e,r=0,h,l,o=0,n=mt.Ju,a,u,d){this.id=t,this.Vu=i,this.startTime=s,this.endTime=e,this.priority=r,this.type=h,this.data=l,this.Gu=o,this.Ku=n,this.sn=a,this.Ou=u,this.Qu=d,this.id=t,this.Vu=i||[],void 0===s&&(s=null),this.startTime=s,void 0===e&&(e=null),this.endTime=e,this.priority=r||0,this.type=h,this.Gu=o||0,null==a&&(a=1e3*(this.Gu+30)),this.sn=a,this.data=l,null!=n&&(this.Ku=n),this.Ou=u,this.Qu=d||null}Uu(t){return null==this.Qu||this.Ku!==mt.Ju&&t-this.Qu>=1e3*this.Ku}Wu(t){this.Qu=t}Xu(t){const i=t+1e3*this.Gu;return Math.max(i-(new Date).valueOf(),0)}Yu(t){const i=(new Date).valueOf()-t,s=null==t||isNaN(i)||null==this.sn||i<this.sn;return s||r.j.info(`Trigger action ${this.type} is no longer eligible for display - fired ${i}ms ago and has a timeout of ${this.sn}ms.`),!s}static fromJson(t){const i=t.id,s=[];for(let i=0;i<t.trigger_condition.length;i++)s.push(ri.fromJson(t.trigger_condition[i]));const e=l(t.start_time),r=l(t.end_time),h=t.priority,o=t.type,n=t.delay,a=t.re_eligibility,u=t.timeout,d=t.data,m=t.min_seconds_since_last_trigger;return H(mt.Wr,o,"Could not construct Trigger from server data","Trigger.Types")?new mt(i,s,e,r,h,o,d,n,a,u,m):null}ss(){const t=[];for(let i=0;i<this.Vu.length;i++)t.push(this.Vu[i].ss());return{i:this.id,c:t,s:this.startTime,e:this.endTime,p:this.priority,t:this.type,da:this.data,d:this.Gu,r:this.Ku,tm:this.sn,ss:this.Ou,ld:this.Qu}}static Yn(t){const i=[],s=t.c||[];for(let t=0;t<s.length;t++)i.push(ri.Yn(s[t]));return new mt(t.i,i,w(t.s),w(t.e),t.p,t.t,t.da,t.d,t.r,t.tm,t.ss,t.ld)}}mt.Wr={Vr:"inapp",Zu:"templated_iam"},mt.Ju=-1;
1
+ import {
2
+ dateFromUnixTimestamp as l,
3
+ rehydrateDateAfterJsonization as w,
4
+ } from "../../util/date-utils.js";
5
+ import r from "../../../shared-lib/braze-shared-lib.js";
6
+ import ri from "./trigger-condition.js";
7
+ import { validateValueIsFromEnum as G } from "../../util/code-utils.js";
8
+ export default class pt {
9
+ constructor(t, i = [], s, e, r = 0, h, l, o = 0, n = pt.Ju, a, u, d) {
10
+ (this.id = t),
11
+ (this.Vu = i),
12
+ (this.startTime = s),
13
+ (this.endTime = e),
14
+ (this.priority = r),
15
+ (this.type = h),
16
+ (this.data = l),
17
+ (this.Gu = o),
18
+ (this.Ku = n),
19
+ (this.sn = a),
20
+ (this.Ou = u),
21
+ (this.Qu = d),
22
+ (this.id = t),
23
+ (this.Vu = i || []),
24
+ void 0 === s && (s = null),
25
+ (this.startTime = s),
26
+ void 0 === e && (e = null),
27
+ (this.endTime = e),
28
+ (this.priority = r || 0),
29
+ (this.type = h),
30
+ (this.Gu = o || 0),
31
+ null == a && (a = 1e3 * (this.Gu + 30)),
32
+ (this.sn = a),
33
+ (this.data = l),
34
+ null != n && (this.Ku = n),
35
+ (this.Ou = u),
36
+ (this.Qu = d || null);
37
+ }
38
+ Uu(t) {
39
+ return (
40
+ null == this.Qu || (this.Ku !== pt.Ju && t - this.Qu >= 1e3 * this.Ku)
41
+ );
42
+ }
43
+ Wu(t) {
44
+ this.Qu = t;
45
+ }
46
+ Xu(t) {
47
+ const i = t + 1e3 * this.Gu;
48
+ return Math.max(i - new Date().valueOf(), 0);
49
+ }
50
+ Yu(t) {
51
+ const i = new Date().valueOf() - t,
52
+ s = null == t || isNaN(i) || null == this.sn || i < this.sn;
53
+ return (
54
+ s ||
55
+ r.j.info(
56
+ `Trigger action ${this.type} is no longer eligible for display - fired ${i}ms ago and has a timeout of ${this.sn}ms.`,
57
+ ),
58
+ !s
59
+ );
60
+ }
61
+ static fromJson(t) {
62
+ const i = t.id,
63
+ s = [];
64
+ for (let i = 0; i < t.trigger_condition.length; i++)
65
+ s.push(ri.fromJson(t.trigger_condition[i]));
66
+ const e = l(t.start_time),
67
+ r = l(t.end_time),
68
+ h = t.priority,
69
+ o = t.type,
70
+ n = t.delay,
71
+ a = t.re_eligibility,
72
+ u = t.timeout,
73
+ d = t.data,
74
+ m = t.min_seconds_since_last_trigger;
75
+ return G(
76
+ pt.Wr,
77
+ o,
78
+ "Could not construct Trigger from server data",
79
+ "Trigger.Types",
80
+ )
81
+ ? new pt(i, s, e, r, h, o, d, n, a, u, m)
82
+ : null;
83
+ }
84
+ tt() {
85
+ const t = [];
86
+ for (let i = 0; i < this.Vu.length; i++) t.push(this.Vu[i].tt());
87
+ return {
88
+ i: this.id,
89
+ c: t,
90
+ s: this.startTime,
91
+ e: this.endTime,
92
+ p: this.priority,
93
+ t: this.type,
94
+ da: this.data,
95
+ d: this.Gu,
96
+ r: this.Ku,
97
+ tm: this.sn,
98
+ ss: this.Ou,
99
+ ld: this.Qu,
100
+ };
101
+ }
102
+ static Yn(t) {
103
+ const i = [],
104
+ s = t.c || [];
105
+ for (let t = 0; t < s.length; t++) i.push(ri.Yn(s[t]));
106
+ return new pt(
107
+ t.i,
108
+ i,
109
+ w(t.s),
110
+ w(t.e),
111
+ t.p,
112
+ t.t,
113
+ t.da,
114
+ t.d,
115
+ t.r,
116
+ t.tm,
117
+ t.ss,
118
+ t.ld,
119
+ );
120
+ }
121
+ }
122
+ (pt.Wr = { Vr: "inapp", Zu: "templated_iam" }), (pt.Ju = -1);
@@ -1 +1,34 @@
1
- import se from"../InAppMessage/in-app-message-manager-factory.js";import e,{OPTIONS as L}from"../managers/braze-instance.js";import gr from"./triggers-provider.js";export const TriggersProviderFactory={t:!1,provider:null,er:()=>(TriggersProviderFactory.o(),TriggersProviderFactory.provider||TriggersProviderFactory.rg(),TriggersProviderFactory.provider),rg:()=>{if(!TriggersProviderFactory.provider){const r=e.nn(L.No);TriggersProviderFactory.provider=new gr(null!=r?r:30,se.m().Ze(),e.l(),e.cr(),se.m()),e.dr(TriggersProviderFactory.provider)}},o:()=>{TriggersProviderFactory.t||(TriggersProviderFactory.rg(),e.g(TriggersProviderFactory),TriggersProviderFactory.t=!0)},destroy:()=>{TriggersProviderFactory.provider=null,TriggersProviderFactory.t=!1}};
1
+ import se from "../InAppMessage/in-app-message-manager-factory.js";
2
+ import e, { OPTIONS as L } from "../managers/braze-instance.js";
3
+ import gr from "./triggers-provider.js";
4
+ export const TriggersProviderFactory = {
5
+ t: !1,
6
+ provider: null,
7
+ er: () => (
8
+ TriggersProviderFactory.o(),
9
+ TriggersProviderFactory.provider || TriggersProviderFactory.rg(),
10
+ TriggersProviderFactory.provider
11
+ ),
12
+ rg: () => {
13
+ if (!TriggersProviderFactory.provider) {
14
+ const r = e.nn(L.No);
15
+ (TriggersProviderFactory.provider = new gr(
16
+ null != r ? r : 30,
17
+ se.m().Ze(),
18
+ e.l(),
19
+ e.cr(),
20
+ se.m(),
21
+ )),
22
+ e.dr(TriggersProviderFactory.provider);
23
+ }
24
+ },
25
+ o: () => {
26
+ TriggersProviderFactory.t ||
27
+ (TriggersProviderFactory.rg(),
28
+ e.g(TriggersProviderFactory),
29
+ (TriggersProviderFactory.t = !0));
30
+ },
31
+ destroy: () => {
32
+ (TriggersProviderFactory.provider = null), (TriggersProviderFactory.t = !1);
33
+ },
34
+ };
@@ -1 +1,326 @@
1
- import y from"../common/base-provider.js";import{newInAppMessageFromJson as pt}from"../InAppMessage/in-app-message-factory.js";import be from"../models/braze-event.js";import{InAppMessage}from"../InAppMessage/index.js";import{isArray as p,isEqual as ii,validateValueIsFromEnum as H}from"../util/code-utils.js";import{STORAGE_KEYS as i}from"../managers/storage-manager.js";import wt from"../InAppMessage/models/templated-in-app-message.js";import mt from"./models/trigger.js";import tt from"./models/trigger-events.js";import r from"../../shared-lib/braze-shared-lib.js";export default class gr extends y{constructor(t,i,s,e,r){super(),this.tg=t,this.yt=i,this.u=s,this.ki=e,this.ig=r,this.tg=t,this.yt=i,this.u=s,this.ki=e,this.ig=r,this.sg=[],this.eg=[],this.hg=null,this.ng={},this.og={},this.triggers=[],this.ag=0,this.lg(),this.gg()}fg(){if(this.u){this.hg=this.u.v(i.k.iE)||this.hg,this.ng=this.u.v(i.k.aE)||this.ng,this.og=this.u.v(i.k.nE)||this.og;for(let t=0;t<this.triggers.length;t++){const i=this.triggers[t];i.id&&null!=this.og[i.id]&&i.Wu(this.og[i.id])}}}lg(){if(!this.u)return;this.ag=this.u.v(i.k.oE)||0;const t=this.u.v(i.k.rE)||[],s=[];for(let i=0;i<t.length;i++)s.push(mt.Yn(t[i]));this.triggers=s,this.fg()}gg(){const t=this,s=function(i,s,e,r,h){return function(){t.cg(i,s,e,r,h)}},e={};for(const t of this.triggers)t.id&&(e[t.id]=t);let r=!1;for(let t=0;t<this.triggers.length;t++){const i=this.triggers[t];if(i.id&&null!=this.ng[i.id]){const t=this.ng[i.id],h=[];for(let r=0;r<t.length;r++){const n=t[r],o=i.Xu(n.Zr||0);if(o>0){let t,r;h.push(n),null!=n.ug&&(t=n.ug),null!=n.dg&&be.TE(n.dg)&&(r=be.Yn(n.dg));const a=[];if(n.pg&&p(n.pg))for(let t=0;t<n.pg.length;t++){const i=e[n.pg[t]];null!=i&&a.push(i)}this.eg.push(window.setTimeout(s(i,n.Zr||0,t,r,a),o))}}this.ng[i.id].length>h.length&&(this.ng[i.id]=h,r=!0,0===this.ng[i.id].length&&delete this.ng[i.id])}}r&&this.u&&this.u.D(i.k.aE,this.ng)}mg(){if(!this.u)return;const t=[];for(let i=0;i<this.triggers.length;i++)t.push(this.triggers[i].ss());this.ag=(new Date).valueOf(),this.u.D(i.k.rE,t),this.u.D(i.k.oE,this.ag)}bg(){if(!this.u)return;(this.u.v(i.k.oE)||0)>this.ag?this.lg():this.fg()}Ts(t){let s=!1;if(null!=t&&t.triggers){this.ig.mn(),this.fg();const e={},h={};this.triggers=[];for(let i=0;i<t.triggers.length;i++){const r=mt.fromJson(t.triggers[i]);if(r){r.id&&null!=this.og[r.id]&&(r.Wu(this.og[r.id]),e[r.id]=this.og[r.id]),r.id&&null!=this.ng[r.id]&&(h[r.id]=this.ng[r.id]);for(let t=0;t<r.Vu.length;t++)if(r.Vu[t].ec(tt.zs,null)){s=!0;break}this.triggers.push(r)}}ii(this.og,e)||(this.og=e,this.u&&this.u.D(i.k.nE,this.og)),ii(this.ng,h)||(this.ng=h,this.u&&this.u.D(i.k.aE,this.ng)),this.mg(),s&&(r.j.info("Trigger with test condition found, firing test."),this.be(tt.zs)),this.be(tt.OPEN);const n=this.sg;let o;this.sg=[];for(let t=0;t<n.length;t++)o=Array.prototype.slice.call(n[t]),this.be(...o)}}cg(t,i,s,e,h){const n=e=>{this.fg();const h=(new Date).valueOf();if(!t.Yu(i))return!1===navigator.onLine&&t.type===mt.Wr.Vr&&e.imageUrl?(r.j.info(`Not showing ${t.type} trigger action ${t.id} due to offline state.`),void this.ig.Ji(t.id,InAppMessage.Ie.Uh)):void(t.Uu(h)&&this.wg(t,h,s)?0===this.yt.tc()?r.j.info(`Not displaying trigger ${t.id} because neither automaticallyShowInAppMessages() nor subscribeToInAppMessage() were called.`):(this.yt.Et([e]),this.yg(t,h)):r.j.info(`Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`));t.type===mt.Wr.Zu?this.ig.Ji(t.id,InAppMessage.Ie.Qr):this.ig.Ji(t.id,InAppMessage.Ie.bh)},o=()=>{this.fg();const n=h.pop();if(null!=n)if(this.Tg(n,i,s,e,h),n.Yu(i)){let t=`Server aborted in-app message display, but the timeout on fallback trigger ${n.id} has already elapsed.`;h.length>0&&(t+=" Continuing to fall back."),r.j.info(t),this.ig.Ji(n.id,InAppMessage.Ie.bh),o()}else{r.j.info(`Server aborted in-app message display. Falling back to lower priority ${n.type} trigger action ${t.id}.`);const o=1e3*n.Gu-((new Date).valueOf()-i);o>0?this.eg.push(window.setTimeout((()=>{this.cg(n,i,s,e,h)}),o)):this.cg(n,i,s,e,h)}};let a,l,g;switch(t.type){case mt.Wr.Vr:if(a=pt(t.data),null==a){r.j.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.ig.Ji(t.id,InAppMessage.Ie.Xr);break}if(l=this.ig.Mr(a),l){r.j.error(l),o();break}n(a);break;case mt.Wr.Zu:if(g=wt.fromJson(t.data,n,o,i,t.sn||0),null==g){r.j.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.ig.Ji(t.id,InAppMessage.Ie.Xr);break}this.ig.Hr(g,s,e);break;default:r.j.error(`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`),this.ig.Ji(t.id,InAppMessage.Ie.Xr)}}be(t,i=null,s){if(!H(tt,t,"Cannot fire trigger action.","TriggerEvents"))return;if(this.ki&&this.ki.Du())return r.j.info("Trigger sync is currently in progress, awaiting sync completion before firing trigger event."),void this.sg.push(arguments);this.bg();const e=(new Date).valueOf(),h=e-(this.hg||0);let n=!0,o=!0;const a=[];for(let s=0;s<this.triggers.length;s++){const r=this.triggers[s],h=e+1e3*r.Gu;if(r.Uu(h)&&(null==r.startTime||r.startTime.valueOf()<=e)&&(null==r.endTime||r.endTime.valueOf()>=e)){let s=!1;for(let e=0;e<r.Vu.length;e++)if(r.Vu[e].ec(t,i)){s=!0;break}s&&(n=!1,this.wg(r,h,t)&&(o=!1,a.push(r)))}}if(n)return void r.j.info(`Trigger event ${t} did not match any trigger conditions.`);if(o)return void r.j.info(`Ignoring ${t} trigger event because a trigger was displayed ${h/1e3}s ago.`);a.sort(((t,i)=>t.priority-i.priority));const l=a.pop();null!=l&&(r.j.info(`Firing ${l.type} trigger action ${l.id} from trigger event ${t}.`),this.Tg(l,e,t,s,a),0===l.Gu?this.cg(l,e,t,s,a):this.eg.push(window.setTimeout((()=>{this.cg(l,e,t,s,a)}),1e3*l.Gu)))}changeUser(t=!1){if(this.triggers=[],this.u&&this.u.ni(i.k.rE),!t){this.sg=[],this.hg=null,this.og={},this.ng={};for(let t=0;t<this.eg.length;t++)clearTimeout(this.eg[t]);this.eg=[],this.u&&(this.u.ni(i.k.iE),this.u.ni(i.k.nE),this.u.ni(i.k.aE))}}clearData(){this.triggers=[],this.hg=null,this.og={},this.ng={};for(let t=0;t<this.eg.length;t++)clearTimeout(this.eg[t]);this.eg=[]}wg(t,i,s){if(null==this.hg)return!0;if(s===tt.zs)return r.j.info("Ignoring minimum interval between trigger because it is a test type."),!0;let e=t.Ou;return null==e&&(e=this.tg),i-this.hg>=1e3*e}Tg(t,s,e,r,h){this.fg(),t.id&&(this.ng[t.id]=this.ng[t.id]||[]);const n={};let o;n.Zr=s,n.ug=e,null!=r&&(o=r.ss()),n.dg=o;const a=[];for(const t of h)t.id&&a.push(t.id);n.pg=a,t.id&&this.ng[t.id].push(n),this.u&&this.u.D(i.k.aE,this.ng)}yg(t,s){this.fg(),t.Wu(s),this.hg=s,t.id&&(this.og[t.id]=s),this.u&&(this.u.D(i.k.iE,s),this.u.D(i.k.nE,this.og))}}
1
+ import y from "../common/base-provider.js";
2
+ import { newInAppMessageFromJson as lt } from "../InAppMessage/in-app-message-factory.js";
3
+ import ue from "../models/braze-event.js";
4
+ import { InAppMessage } from "../InAppMessage/index.js";
5
+ import {
6
+ isArray as p,
7
+ isEqual as ii,
8
+ validateValueIsFromEnum as G,
9
+ } from "../util/code-utils.js";
10
+ import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
11
+ import wt from "../InAppMessage/models/templated-in-app-message.js";
12
+ import pt from "./models/trigger.js";
13
+ import tt from "./models/trigger-events.js";
14
+ import r from "../../shared-lib/braze-shared-lib.js";
15
+ export default class gr extends y {
16
+ constructor(t, i, s, e, r) {
17
+ super(),
18
+ (this.tg = t),
19
+ (this.Bt = i),
20
+ (this.u = s),
21
+ (this.ki = e),
22
+ (this.ig = r),
23
+ (this.tg = t),
24
+ (this.Bt = i),
25
+ (this.u = s),
26
+ (this.ki = e),
27
+ (this.ig = r),
28
+ (this.sg = []),
29
+ (this.eg = []),
30
+ (this.hg = null),
31
+ (this.ng = {}),
32
+ (this.og = {}),
33
+ (this.triggers = []),
34
+ (this.ag = 0),
35
+ this.lg(),
36
+ this.gg();
37
+ }
38
+ fg() {
39
+ if (this.u) {
40
+ (this.hg = this.u.v(i.k.iE) || this.hg),
41
+ (this.ng = this.u.v(i.k.aE) || this.ng),
42
+ (this.og = this.u.v(i.k.nE) || this.og);
43
+ for (let t = 0; t < this.triggers.length; t++) {
44
+ const i = this.triggers[t];
45
+ i.id && null != this.og[i.id] && i.Wu(this.og[i.id]);
46
+ }
47
+ }
48
+ }
49
+ lg() {
50
+ if (!this.u) return;
51
+ this.ag = this.u.v(i.k.oE) || 0;
52
+ const t = this.u.v(i.k.rE) || [],
53
+ s = [];
54
+ for (let i = 0; i < t.length; i++) s.push(pt.Yn(t[i]));
55
+ (this.triggers = s), this.fg();
56
+ }
57
+ gg() {
58
+ const t = this,
59
+ s = function (i, s, e, r, h) {
60
+ return function () {
61
+ t.cg(i, s, e, r, h);
62
+ };
63
+ },
64
+ e = {};
65
+ for (const t of this.triggers) t.id && (e[t.id] = t);
66
+ let r = !1;
67
+ for (let t = 0; t < this.triggers.length; t++) {
68
+ const i = this.triggers[t];
69
+ if (i.id && null != this.ng[i.id]) {
70
+ const t = this.ng[i.id],
71
+ h = [];
72
+ for (let r = 0; r < t.length; r++) {
73
+ const n = t[r],
74
+ o = i.Xu(n.Zr || 0);
75
+ if (o > 0) {
76
+ let t, r;
77
+ h.push(n),
78
+ null != n.ug && (t = n.ug),
79
+ null != n.dg && ue.TE(n.dg) && (r = ue.Yn(n.dg));
80
+ const a = [];
81
+ if (n.pg && p(n.pg))
82
+ for (let t = 0; t < n.pg.length; t++) {
83
+ const i = e[n.pg[t]];
84
+ null != i && a.push(i);
85
+ }
86
+ this.eg.push(window.setTimeout(s(i, n.Zr || 0, t, r, a), o));
87
+ }
88
+ }
89
+ this.ng[i.id].length > h.length &&
90
+ ((this.ng[i.id] = h),
91
+ (r = !0),
92
+ 0 === this.ng[i.id].length && delete this.ng[i.id]);
93
+ }
94
+ }
95
+ r && this.u && this.u.D(i.k.aE, this.ng);
96
+ }
97
+ mg() {
98
+ if (!this.u) return;
99
+ const t = [];
100
+ for (let i = 0; i < this.triggers.length; i++)
101
+ t.push(this.triggers[i].tt());
102
+ (this.ag = new Date().valueOf()),
103
+ this.u.D(i.k.rE, t),
104
+ this.u.D(i.k.oE, this.ag);
105
+ }
106
+ bg() {
107
+ if (!this.u) return;
108
+ (this.u.v(i.k.oE) || 0) > this.ag ? this.lg() : this.fg();
109
+ }
110
+ Ss(t) {
111
+ let s = !1;
112
+ if (null != t && t.triggers) {
113
+ this.ig.mn(), this.fg();
114
+ const e = {},
115
+ h = {};
116
+ this.triggers = [];
117
+ for (let i = 0; i < t.triggers.length; i++) {
118
+ const r = pt.fromJson(t.triggers[i]);
119
+ if (r) {
120
+ r.id &&
121
+ null != this.og[r.id] &&
122
+ (r.Wu(this.og[r.id]), (e[r.id] = this.og[r.id])),
123
+ r.id && null != this.ng[r.id] && (h[r.id] = this.ng[r.id]);
124
+ for (let t = 0; t < r.Vu.length; t++)
125
+ if (r.Vu[t].ec(tt.vt, null)) {
126
+ s = !0;
127
+ break;
128
+ }
129
+ this.triggers.push(r);
130
+ }
131
+ }
132
+ ii(this.og, e) || ((this.og = e), this.u && this.u.D(i.k.nE, this.og)),
133
+ ii(this.ng, h) || ((this.ng = h), this.u && this.u.D(i.k.aE, this.ng)),
134
+ this.mg(),
135
+ s &&
136
+ (r.j.info("Trigger with test condition found, firing test."),
137
+ this.be(tt.vt)),
138
+ this.be(tt.OPEN);
139
+ const n = this.sg;
140
+ let o;
141
+ this.sg = [];
142
+ for (let t = 0; t < n.length; t++)
143
+ (o = Array.prototype.slice.call(n[t])), this.be(...o);
144
+ }
145
+ }
146
+ cg(t, i, s, e, h) {
147
+ const n = (e) => {
148
+ this.fg();
149
+ const h = new Date().valueOf();
150
+ if (!t.Yu(i))
151
+ return !1 === navigator.onLine && t.type === pt.Wr.Vr && e.imageUrl
152
+ ? (r.j.info(
153
+ `Not showing ${t.type} trigger action ${t.id} due to offline state.`,
154
+ ),
155
+ void this.ig.Ji(t.id, InAppMessage.Ie.Uh))
156
+ : void (t.Uu(h) && this.wg(t, h, s)
157
+ ? 0 === this.Bt.tc()
158
+ ? r.j.info(
159
+ `Not displaying trigger ${t.id} because neither automaticallyShowInAppMessages() nor subscribeToInAppMessage() were called.`,
160
+ )
161
+ : (this.Bt.Dt([e]), this.yg(t, h))
162
+ : r.j.info(
163
+ `Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`,
164
+ ));
165
+ t.type === pt.Wr.Zu
166
+ ? this.ig.Ji(t.id, InAppMessage.Ie.Qr)
167
+ : this.ig.Ji(t.id, InAppMessage.Ie.bh);
168
+ },
169
+ o = () => {
170
+ this.fg();
171
+ const n = h.pop();
172
+ if (null != n)
173
+ if ((this.Tg(n, i, s, e, h), n.Yu(i))) {
174
+ let t = `Server aborted in-app message display, but the timeout on fallback trigger ${n.id} has already elapsed.`;
175
+ h.length > 0 && (t += " Continuing to fall back."),
176
+ r.j.info(t),
177
+ this.ig.Ji(n.id, InAppMessage.Ie.bh),
178
+ o();
179
+ } else {
180
+ r.j.info(
181
+ `Server aborted in-app message display. Falling back to lower priority ${n.type} trigger action ${t.id}.`,
182
+ );
183
+ const o = 1e3 * n.Gu - (new Date().valueOf() - i);
184
+ o > 0
185
+ ? this.eg.push(
186
+ window.setTimeout(() => {
187
+ this.cg(n, i, s, e, h);
188
+ }, o),
189
+ )
190
+ : this.cg(n, i, s, e, h);
191
+ }
192
+ };
193
+ let a, l, g;
194
+ switch (t.type) {
195
+ case pt.Wr.Vr:
196
+ if (((a = lt(t.data)), null == a)) {
197
+ r.j.error(
198
+ `Could not parse trigger data for trigger ${t.id}, ignoring.`,
199
+ ),
200
+ this.ig.Ji(t.id, InAppMessage.Ie.Xr);
201
+ break;
202
+ }
203
+ if (((l = this.ig.Mr(a)), l)) {
204
+ r.j.error(l), o();
205
+ break;
206
+ }
207
+ n(a);
208
+ break;
209
+ case pt.Wr.Zu:
210
+ if (((g = wt.fromJson(t.data, n, o, i, t.sn || 0)), null == g)) {
211
+ r.j.error(
212
+ `Could not parse trigger data for trigger ${t.id}, ignoring.`,
213
+ ),
214
+ this.ig.Ji(t.id, InAppMessage.Ie.Xr);
215
+ break;
216
+ }
217
+ this.ig.Hr(g, s, e);
218
+ break;
219
+ default:
220
+ r.j.error(
221
+ `Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`,
222
+ ),
223
+ this.ig.Ji(t.id, InAppMessage.Ie.Xr);
224
+ }
225
+ }
226
+ be(t, i = null, s) {
227
+ if (!G(tt, t, "Cannot fire trigger action.", "TriggerEvents")) return;
228
+ if (this.ki && this.ki.Du())
229
+ return (
230
+ r.j.info(
231
+ "Trigger sync is currently in progress, awaiting sync completion before firing trigger event.",
232
+ ),
233
+ void this.sg.push(arguments)
234
+ );
235
+ this.bg();
236
+ const e = new Date().valueOf(),
237
+ h = e - (this.hg || 0);
238
+ let n = !0,
239
+ o = !0;
240
+ const a = [];
241
+ for (let s = 0; s < this.triggers.length; s++) {
242
+ const r = this.triggers[s],
243
+ h = e + 1e3 * r.Gu;
244
+ if (
245
+ r.Uu(h) &&
246
+ (null == r.startTime || r.startTime.valueOf() <= e) &&
247
+ (null == r.endTime || r.endTime.valueOf() >= e)
248
+ ) {
249
+ let s = !1;
250
+ for (let e = 0; e < r.Vu.length; e++)
251
+ if (r.Vu[e].ec(t, i)) {
252
+ s = !0;
253
+ break;
254
+ }
255
+ s && ((n = !1), this.wg(r, h, t) && ((o = !1), a.push(r)));
256
+ }
257
+ }
258
+ if (n)
259
+ return void r.j.info(
260
+ `Trigger event ${t} did not match any trigger conditions.`,
261
+ );
262
+ if (o)
263
+ return void r.j.info(
264
+ `Ignoring ${t} trigger event because a trigger was displayed ${
265
+ h / 1e3
266
+ }s ago.`,
267
+ );
268
+ a.sort((t, i) => t.priority - i.priority);
269
+ const l = a.pop();
270
+ null != l &&
271
+ (r.j.info(
272
+ `Firing ${l.type} trigger action ${l.id} from trigger event ${t}.`,
273
+ ),
274
+ this.Tg(l, e, t, s, a),
275
+ 0 === l.Gu
276
+ ? this.cg(l, e, t, s, a)
277
+ : this.eg.push(
278
+ window.setTimeout(() => {
279
+ this.cg(l, e, t, s, a);
280
+ }, 1e3 * l.Gu),
281
+ ));
282
+ }
283
+ changeUser(t = !1) {
284
+ if (((this.triggers = []), this.u && this.u.ni(i.k.rE), !t)) {
285
+ (this.sg = []), (this.hg = null), (this.og = {}), (this.ng = {});
286
+ for (let t = 0; t < this.eg.length; t++) clearTimeout(this.eg[t]);
287
+ (this.eg = []),
288
+ this.u && (this.u.ni(i.k.iE), this.u.ni(i.k.nE), this.u.ni(i.k.aE));
289
+ }
290
+ }
291
+ clearData() {
292
+ (this.triggers = []), (this.hg = null), (this.og = {}), (this.ng = {});
293
+ for (let t = 0; t < this.eg.length; t++) clearTimeout(this.eg[t]);
294
+ this.eg = [];
295
+ }
296
+ wg(t, i, s) {
297
+ if (null == this.hg) return !0;
298
+ if (s === tt.vt)
299
+ return (
300
+ r.j.info(
301
+ "Ignoring minimum interval between trigger because it is a test type.",
302
+ ),
303
+ !0
304
+ );
305
+ let e = t.Ou;
306
+ return null == e && (e = this.tg), i - this.hg >= 1e3 * e;
307
+ }
308
+ Tg(t, s, e, r, h) {
309
+ this.fg(), t.id && (this.ng[t.id] = this.ng[t.id] || []);
310
+ const n = {};
311
+ let o;
312
+ (n.Zr = s), (n.ug = e), null != r && (o = r.tt()), (n.dg = o);
313
+ const a = [];
314
+ for (const t of h) t.id && a.push(t.id);
315
+ (n.pg = a),
316
+ t.id && this.ng[t.id].push(n),
317
+ this.u && this.u.D(i.k.aE, this.ng);
318
+ }
319
+ yg(t, s) {
320
+ this.fg(),
321
+ t.Wu(s),
322
+ (this.hg = s),
323
+ t.id && (this.og[t.id] = s),
324
+ this.u && (this.u.D(i.k.iE, s), this.u.D(i.k.nE, this.og));
325
+ }
326
+ }
@@ -1 +1 @@
1
- export{};
1
+ export {};
package/src/types.js CHANGED
@@ -1 +1 @@
1
- export{};
1
+ export {};
@@ -1 +1,13 @@
1
- import e,{OPTIONS as L}from"../../managers/braze-instance.js";export function attachCSS(n,t,o){const c=n||document.querySelector("head"),s=`ab-${t}-css-definitions-${"4.10.1".replace(/\./g,"-")}`;if(!c)return;const a=c.ownerDocument||document;if(null==a.getElementById(s)){const n=a.createElement("style");n.innerHTML=o||"",n.id=s;const t=e.nn(L.po);null!=t&&n.setAttribute("nonce",t),c.appendChild(n)}}
1
+ import e, { OPTIONS as L } from "../../managers/braze-instance.js";
2
+ export function attachCSS(n, t, o) {
3
+ const c = n || document.querySelector("head"),
4
+ s = `ab-${t}-css-definitions-${"5.0.1".replace(/\./g, "-")}`;
5
+ if (!c) return;
6
+ const a = c.ownerDocument || document;
7
+ if (null == a.getElementById(s)) {
8
+ const n = a.createElement("style");
9
+ (n.innerHTML = o || ""), (n.id = s);
10
+ const t = e.nn(L.po);
11
+ null != t && n.setAttribute("nonce", t), c.appendChild(n);
12
+ }
13
+ }
@@ -1 +1,12 @@
1
- import{attachCSS as Ie}from"./attach-css.js";import{loadFontAwesome as Ne}from"./load-font-awesome.js";export function attachFeedCSS(t){Ie(t,"feed","{{FEED_CSS_INCLUSION}}")}export function setupFeedUI(){attachFeedCSS(),Ne()}
1
+ import { attachCSS as Ce } from "./attach-css.js";
2
+ import { loadFontAwesome as Ie } from "./load-font-awesome.js";
3
+ export function attachFeedCSS(t) {
4
+ Ce(
5
+ t,
6
+ "feed",
7
+ "body>.ab-feed{position:fixed;top:0;right:0;bottom:0;width:421px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}body>.ab-feed .ab-feed-body{position:absolute;top:0;left:0;right:0;border:none;border-left:1px solid #d0d0d0;padding-top:70px;min-height:100%}body>.ab-feed .ab-initial-spinner{float:none}body>.ab-feed .ab-no-cards-message{position:absolute;width:100%;margin-left:-20px;top:40%}.ab-feed{-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:0 1px 7px 1px rgba(66,82,113,.15);-moz-box-shadow:0 1px 7px 1px rgba(66,82,113,.15);box-shadow:0 1px 7px 1px rgba(66,82,113,.15);width:402px;background-color:#eee;font-family:'Helvetica Neue Light','Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:13px;line-height:130%;letter-spacing:normal;overflow-y:auto;overflow-x:visible;z-index:9011;-webkit-overflow-scrolling:touch}.ab-feed :focus,.ab-feed:focus{outline:0}.ab-feed .ab-feed-body{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;border:1px solid #d0d0d0;border-top:none;padding:20px 20px 0 20px}.ab-feed.ab-effect-slide{-webkit-transform:translateX(450px);-moz-transform:translateX(450px);-ms-transform:translateX(450px);transform:translateX(450px);-webkit-transition:transform .5s ease-in-out;-moz-transition:transform .5s ease-in-out;-o-transition:transform .5s ease-in-out;transition:transform .5s ease-in-out}.ab-feed.ab-effect-slide.ab-show{-webkit-transform:translateX(0);-moz-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}.ab-feed.ab-effect-slide.ab-hide{-webkit-transform:translateX(450px);-moz-transform:translateX(450px);-ms-transform:translateX(450px);transform:translateX(450px)}.ab-feed .ab-card{position:relative;-webkit-box-shadow:0 2px 3px 0 rgba(178,178,178,.5);-moz-box-shadow:0 2px 3px 0 rgba(178,178,178,.5);box-shadow:0 2px 3px 0 rgba(178,178,178,.5);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;width:100%;border:1px solid #d0d0d0;margin-bottom:20px;overflow:hidden;background-color:#fff;-webkit-transition:height .4s ease-in-out,margin .4s ease-in-out;-moz-transition:height .4s ease-in-out,margin .4s ease-in-out;-o-transition:height .4s ease-in-out,margin .4s ease-in-out;transition:height .4s ease-in-out,margin .4s ease-in-out}.ab-feed .ab-card .ab-pinned-indicator{position:absolute;right:0;top:0;margin-right:-1px;width:0;height:0;border-style:solid;border-width:0 24px 24px 0;border-color:transparent #1676d0 transparent transparent}.ab-feed .ab-card .ab-pinned-indicator .fa-star{position:absolute;right:-21px;top:2px;font-size:9px;color:#fff}.ab-feed .ab-card.ab-effect-card.ab-hide{-webkit-transition:all .5s ease-in-out;-moz-transition:all .5s ease-in-out;-o-transition:all .5s ease-in-out;transition:all .5s ease-in-out}.ab-feed .ab-card.ab-effect-card.ab-hide.ab-swiped-left{-webkit-transform:translateX(-450px);-moz-transform:translateX(-450px);-ms-transform:translateX(-450px);transform:translateX(-450px)}.ab-feed .ab-card.ab-effect-card.ab-hide.ab-swiped-right{-webkit-transform:translateX(450px);-moz-transform:translateX(450px);-ms-transform:translateX(450px);transform:translateX(450px)}.ab-feed .ab-card.ab-effect-card.ab-hide:not(.ab-swiped-left):not(.ab-swiped-right){opacity:0}.ab-feed .ab-card .ab-close-button{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;background-color:transparent;background-size:15px;border:none;width:15px;min-width:15px;height:15px;cursor:pointer;display:block;font-size:15px;line-height:0;padding-top:15px;padding-right:15px;padding-left:15px;padding-bottom:15px;position:absolute;right:0;top:0;z-index:9021;opacity:0;-webkit-transition:.5s;-moz-transition:.5s;-o-transition:.5s;transition:.5s}.ab-feed .ab-card .ab-close-button svg{-webkit-transition:.2s ease;-moz-transition:.2s ease;-o-transition:.2s ease;transition:.2s ease;fill:#9b9b9b;height:auto;width:100%}.ab-feed .ab-card .ab-close-button svg.ab-chevron{display:none}.ab-feed .ab-card .ab-close-button:active{background-color:transparent}.ab-feed .ab-card .ab-close-button:focus{background-color:transparent}.ab-feed .ab-card .ab-close-button:hover{background-color:transparent}.ab-feed .ab-card .ab-close-button:hover svg{fill-opacity:.8}.ab-feed .ab-card .ab-close-button:hover{opacity:1}.ab-feed .ab-card .ab-close-button:focus{opacity:1}.ab-feed .ab-card a{float:none;color:inherit;text-decoration:none}.ab-feed .ab-card a:hover{text-decoration:underline}.ab-feed .ab-card .ab-image-area{float:none;display:inline-block;vertical-align:top;line-height:0;overflow:hidden;width:100%;-webkit-box-sizing:initial;-moz-box-sizing:initial;box-sizing:initial}.ab-feed .ab-card .ab-image-area img{float:none;height:auto;width:100%}.ab-feed .ab-card.ab-image-only .ab-card-body{display:none}.ab-feed .ab-card .ab-card-body{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:inline-block;width:100%;position:relative}.ab-feed .ab-card .ab-unread-indicator{position:absolute;bottom:0;margin-right:-1px;width:100%;height:5px;background-color:#1676d0}.ab-feed .ab-card .ab-unread-indicator.read{background-color:transparent}.ab-feed .ab-card .ab-title{float:none;letter-spacing:0;margin:0;font-weight:700;font-family:'Helvetica Neue Light','Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;display:block;overflow:hidden;word-wrap:break-word;text-overflow:ellipsis;font-size:18px;line-height:130%;padding:20px 25px 0 25px}.ab-feed .ab-card .ab-description{float:none;color:#545454;padding:15px 25px 20px 25px;word-wrap:break-word;white-space:pre-wrap}.ab-feed .ab-card .ab-description.ab-no-title{padding-top:20px}.ab-feed .ab-card .ab-url-area{float:none;color:#1676d0;margin-top:12px;font-family:'Helvetica Neue Light','Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif}.ab-feed .ab-card.ab-classic-card .ab-card-body{min-height:40px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.ab-feed .ab-card.ab-classic-card.with-image .ab-card-body{min-height:100px;padding-left:72px}.ab-feed .ab-card.ab-classic-card.with-image .ab-image-area{width:60px;height:60px;padding:20px 0 25px 25px;position:absolute}.ab-feed .ab-card.ab-classic-card.with-image .ab-image-area img{-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;max-width:100%;max-height:100%;width:auto;height:auto}.ab-feed .ab-card.ab-classic-card.with-image .ab-title{background-color:transparent;font-size:16px}.ab-feed .ab-card.ab-classic-card.with-image .ab-description{padding-top:10px}.ab-feed .ab-card.ab-control-card{height:0;width:0;margin:0;border:0}.ab-feed .ab-feed-buttons-wrapper{float:none;position:relative;background-color:#282828;height:50px;-webkit-box-shadow:0 2px 3px 0 rgba(178,178,178,.5);-moz-box-shadow:0 2px 3px 0 rgba(178,178,178,.5);box-shadow:0 2px 3px 0 rgba(178,178,178,.5);z-index:1}.ab-feed .ab-feed-buttons-wrapper .ab-close-button,.ab-feed .ab-feed-buttons-wrapper .ab-refresh-button{float:none;cursor:pointer;color:#fff;font-size:18px;padding:16px;-webkit-transition:.2s;-moz-transition:.2s;-o-transition:.2s;transition:.2s}.ab-feed .ab-feed-buttons-wrapper .ab-close-button:hover,.ab-feed .ab-feed-buttons-wrapper .ab-refresh-button:hover{font-size:22px}.ab-feed .ab-feed-buttons-wrapper .ab-close-button{float:right}.ab-feed .ab-feed-buttons-wrapper .ab-close-button:hover{padding-top:12px;padding-right:14px}.ab-feed .ab-feed-buttons-wrapper .ab-refresh-button{padding-left:17px}.ab-feed .ab-feed-buttons-wrapper .ab-refresh-button:hover{padding-top:13px;padding-left:14px}.ab-feed .ab-no-cards-message{text-align:center;margin-bottom:20px}@media (max-width:600px){body>.ab-feed{width:100%}}",
8
+ );
9
+ }
10
+ export function setupFeedUI() {
11
+ attachFeedCSS(), Ie();
12
+ }