@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,91 @@
1
- import r from"../../shared-lib/braze-shared-lib.js";import{getErrorMessage as ei}from"./error-utils.js";export function _isInView(t,n=!1,e=!1,s=!1){if(null==t)return!1;n=n||!1,e=e||!1;const i=t.getBoundingClientRect();return null!=i&&((i.top>=0&&i.top<=(window.innerHeight||document.documentElement.clientHeight)||!n)&&(i.left>=0||!s)&&(i.bottom>=0&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)||!e)&&(i.right<=(window.innerWidth||document.documentElement.clientWidth)||!s))}export const DOMUtils={lc:null,no:_isInView};export const DIRECTIONS={Oe:"up",Qe:"down",W:"left",X:"right"};export function supportsPassive(){if(null==DOMUtils.lc){DOMUtils.lc=!1;try{const t=Object.defineProperty({},"passive",{get:()=>{DOMUtils.lc=!0}});window.addEventListener("testPassive",(()=>{}),t),window.removeEventListener("testPassive",(()=>{}),t)}catch(t){r.j.error(ei(t))}}return DOMUtils.lc}export function addPassiveEventListener(t,n,e=(()=>{})){t.addEventListener(n,e,!!supportsPassive()&&{passive:!0})}export function topIsInView(t){return DOMUtils.no(t,!0,!1,!1)}export function bottomIsInView(t){return DOMUtils.no(t,!1,!0,!1)}export function clickElement(t){if(t.onclick){const n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),t.onclick.apply(t,[n])}}export function detectSwipe(t,n,e){let s=null,i=null;addPassiveEventListener(t,"touchstart",(t=>{s=t.touches[0].clientX,i=t.touches[0].clientY})),addPassiveEventListener(t,"touchmove",(o=>{if(null==s||null==i)return;const l=s-o.touches[0].clientX,r=i-o.touches[0].clientY;Math.abs(l)>Math.abs(r)&&Math.abs(l)>=25?((l>0&&n===DIRECTIONS.W||l<0&&n===DIRECTIONS.X)&&e(o),s=null,i=null):Math.abs(r)>=25&&((r>0&&n===DIRECTIONS.Oe&&t.scrollTop===t.scrollHeight-t.offsetHeight||r<0&&n===DIRECTIONS.Qe&&0===t.scrollTop)&&e(o),s=null,i=null)}))}export function buildSvg(t,n,e){const s="http://www.w3.org/2000/svg",i=document.createElementNS(s,"svg");i.setAttribute("viewBox",t),i.setAttribute("xmlns",s);const o=document.createElementNS(s,"path");return o.setAttribute("d",n),null!=e&&o.setAttribute("fill",e),i.appendChild(o),i}
1
+ import r from "../../shared-lib/braze-shared-lib.js";
2
+ import { getErrorMessage as ei } from "./error-utils.js";
3
+ export function _isInView(t, n = !1, e = !1, s = !1) {
4
+ if (null == t) return !1;
5
+ (n = n || !1), (e = e || !1);
6
+ const i = t.getBoundingClientRect();
7
+ return (
8
+ null != i &&
9
+ ((i.top >= 0 &&
10
+ i.top <= (window.innerHeight || document.documentElement.clientHeight)) ||
11
+ !n) &&
12
+ (i.left >= 0 || !s) &&
13
+ ((i.bottom >= 0 &&
14
+ i.bottom <=
15
+ (window.innerHeight || document.documentElement.clientHeight)) ||
16
+ !e) &&
17
+ (i.right <= (window.innerWidth || document.documentElement.clientWidth) ||
18
+ !s)
19
+ );
20
+ }
21
+ export const DOMUtils = { oc: null, no: _isInView };
22
+ export const DIRECTIONS = { Oe: "up", Qe: "down", W: "left", X: "right" };
23
+ export function supportsPassive() {
24
+ if (null == DOMUtils.oc) {
25
+ DOMUtils.oc = !1;
26
+ try {
27
+ const t = Object.defineProperty({}, "passive", {
28
+ get: () => {
29
+ DOMUtils.oc = !0;
30
+ },
31
+ });
32
+ window.addEventListener("testPassive", () => {}, t),
33
+ window.removeEventListener("testPassive", () => {}, t);
34
+ } catch (t) {
35
+ r.j.error(ei(t));
36
+ }
37
+ }
38
+ return DOMUtils.oc;
39
+ }
40
+ export function addPassiveEventListener(t, n, e = () => {}) {
41
+ t.addEventListener(n, e, !!supportsPassive() && { passive: !0 });
42
+ }
43
+ export function topIsInView(t) {
44
+ return DOMUtils.no(t, !0, !1, !1);
45
+ }
46
+ export function bottomIsInView(t) {
47
+ return DOMUtils.no(t, !1, !0, !1);
48
+ }
49
+ export function clickElement(t) {
50
+ if (t.onclick) {
51
+ const n = document.createEvent("MouseEvents");
52
+ n.initEvent("click", !0, !0), t.onclick.apply(t, [n]);
53
+ }
54
+ }
55
+ export function detectSwipe(t, n, e) {
56
+ let s = null,
57
+ i = null;
58
+ addPassiveEventListener(t, "touchstart", (t) => {
59
+ (s = t.touches[0].clientX), (i = t.touches[0].clientY);
60
+ }),
61
+ addPassiveEventListener(t, "touchmove", (o) => {
62
+ if (null == s || null == i) return;
63
+ const l = s - o.touches[0].clientX,
64
+ r = i - o.touches[0].clientY;
65
+ Math.abs(l) > Math.abs(r) && Math.abs(l) >= 25
66
+ ? (((l > 0 && n === DIRECTIONS.W) || (l < 0 && n === DIRECTIONS.X)) &&
67
+ e(o),
68
+ (s = null),
69
+ (i = null))
70
+ : Math.abs(r) >= 25 &&
71
+ (((r > 0 &&
72
+ n === DIRECTIONS.Oe &&
73
+ t.scrollTop === t.scrollHeight - t.offsetHeight) ||
74
+ (r < 0 && n === DIRECTIONS.Qe && 0 === t.scrollTop)) &&
75
+ e(o),
76
+ (s = null),
77
+ (i = null));
78
+ });
79
+ }
80
+ export function buildSvg(t, n, e) {
81
+ const s = "http://www.w3.org/2000/svg",
82
+ i = document.createElementNS(s, "svg");
83
+ i.setAttribute("viewBox", t), i.setAttribute("xmlns", s);
84
+ const o = document.createElementNS(s, "path");
85
+ return (
86
+ o.setAttribute("d", n),
87
+ null != e && o.setAttribute("fill", e),
88
+ i.appendChild(o),
89
+ i
90
+ );
91
+ }
@@ -1 +1,2 @@
1
- export const getErrorMessage=r=>r instanceof Error?r.message:String(r);
1
+ export const getErrorMessage = (r) =>
2
+ r instanceof Error ? r.message : String(r);
@@ -1 +1 @@
1
- export const KeyCodes={Fo:32,oo:9,To:13,_h:27};
1
+ export const KeyCodes = { Fo: 32, oo: 9, To: 13, _h: 27 };
package/src/util/math.js CHANGED
@@ -1 +1,5 @@
1
- export const randomInclusive=(t,a)=>(t=Math.ceil(t),a=Math.floor(a),Math.floor(Math.random()*(a-t+1))+t);
1
+ export const randomInclusive = (t, a) => (
2
+ (t = Math.ceil(t)),
3
+ (a = Math.floor(a)),
4
+ Math.floor(Math.random() * (a - t + 1)) + t
5
+ );
package/src/util/net.js CHANGED
@@ -1 +1,71 @@
1
- import r from"../../shared-lib/braze-shared-lib.js";import qt from"../models/backend-errors.js";import{getErrorMessage as ei}from"./error-utils.js";const C={Xs:t=>{let e,o;try{const s=()=>{r.j.error("This browser does not have any supported ajax options!")};let n=!1;if(window.XMLHttpRequest&&(n=!0),!n)return void s();e=new XMLHttpRequest;const i=()=>{"function"==typeof t.error&&t.error(e.status),"function"==typeof t.ei&&t.ei(!1)};e.onload=()=>{let o=!1;if(4===e.readyState)if(o=e.status>=200&&e.status<300||304===e.status,o){if("function"==typeof t.O){let o,r;try{o=JSON.parse(e.responseText),r=e.getAllResponseHeaders()}catch(o){const s={error:""===e.responseText?qt.Vh:qt.Zh,response:e.responseText};(0,t.O)(s,r)}o&&t.O(o,r)}"function"==typeof t.ei&&t.ei(!0)}else i()},e.onerror=()=>{i()},e.ontimeout=()=>{i()},o=JSON.stringify(t.data),e.open("POST",t.url,!0),e.setRequestHeader("Content-type","application/json"),e.setRequestHeader("X-Requested-With","XMLHttpRequest");const f=t.headers||[];for(const t of f)e.setRequestHeader(t[0],t[1]);e.send(o)}catch(t){r.j.error(`Network request error: ${ei(t)}`)}}};export const readResponseHeaders=t=>{const e={},o=t.toString().split("\r\n");if(!o)return e;let r,s;for(const t of o)t&&(r=t.slice(0,t.indexOf(":")).toLowerCase().trim(),s=t.slice(t.indexOf(":")+1).trim(),e[r]=s);return e};export default C;
1
+ import r from "../../shared-lib/braze-shared-lib.js";
2
+ import qt from "../models/backend-errors.js";
3
+ import { getErrorMessage as ei } from "./error-utils.js";
4
+ const C = {
5
+ Xs: (t) => {
6
+ let e, o;
7
+ try {
8
+ const s = () => {
9
+ r.j.error("This browser does not have any supported ajax options!");
10
+ };
11
+ let n = !1;
12
+ if ((window.XMLHttpRequest && (n = !0), !n)) return void s();
13
+ e = new XMLHttpRequest();
14
+ const i = () => {
15
+ "function" == typeof t.error && t.error(e.status),
16
+ "function" == typeof t.ei && t.ei(!1);
17
+ };
18
+ (e.onload = () => {
19
+ let o = !1;
20
+ if (4 === e.readyState)
21
+ if (
22
+ ((o = (e.status >= 200 && e.status < 300) || 304 === e.status), o)
23
+ ) {
24
+ if ("function" == typeof t.O) {
25
+ let o, r;
26
+ try {
27
+ (o = JSON.parse(e.responseText)),
28
+ (r = e.getAllResponseHeaders());
29
+ } catch (o) {
30
+ const s = {
31
+ error: "" === e.responseText ? qt.Vh : qt.Zh,
32
+ response: e.responseText,
33
+ };
34
+ (0, t.O)(s, r);
35
+ }
36
+ o && t.O(o, r);
37
+ }
38
+ "function" == typeof t.ei && t.ei(!0);
39
+ } else i();
40
+ }),
41
+ (e.onerror = () => {
42
+ i();
43
+ }),
44
+ (e.ontimeout = () => {
45
+ i();
46
+ }),
47
+ (o = JSON.stringify(t.data)),
48
+ e.open("POST", t.url, !0),
49
+ e.setRequestHeader("Content-type", "application/json"),
50
+ e.setRequestHeader("X-Requested-With", "XMLHttpRequest");
51
+ const f = t.headers || [];
52
+ for (const t of f) e.setRequestHeader(t[0], t[1]);
53
+ e.send(o);
54
+ } catch (t) {
55
+ r.j.error(`Network request error: ${ei(t)}`);
56
+ }
57
+ },
58
+ };
59
+ export const readResponseHeaders = (t) => {
60
+ const e = {},
61
+ o = t.toString().split("\r\n");
62
+ if (!o) return e;
63
+ let r, s;
64
+ for (const t of o)
65
+ t &&
66
+ ((r = t.slice(0, t.indexOf(":")).toLowerCase().trim()),
67
+ (s = t.slice(t.indexOf(":") + 1).trim()),
68
+ (e[r] = s));
69
+ return e;
70
+ };
71
+ export default C;
@@ -1 +1,46 @@
1
- import{REQUEST_ATTEMPT_DEFAULT as Ae}from"../common/constants.js";import{STORAGE_KEYS as i}from"../managers/storage-manager.js";const T={Os:{Na:"d",Ks:"cc",Si:"ff",Lr:"t"},rm:e=>{if(e)return e.v(i.k.EE)},sm:e=>{if(e)return e.v(i.k.lE)},nm:(e,t)=>{e&&e.D(i.k.EE,t)},um:(e,t)=>{e&&e.D(i.k.lE,t)},La:(e,t)=>{if(!e||!t)return-1;const r=T.rm(e);if(null==r)return-1;const s=r[t];return null==s||isNaN(s)?-1:s},Wa:(e,t)=>{let r=Ae;if(!e||!t)return r;const s=T.sm(e);return null==s?r:(r=s[t],null==r||isNaN(r)?Ae:r)},Ws:(e,t,r)=>{if(!e||!t)return;let s=T.rm(e);null==s&&(s={}),s[t]=r,T.nm(e,s)},si:(e,t,r)=>{if(!e||!t)return;let s=T.sm(e);null==s&&(s={}),s[t]=r,T.um(e,s)},hi:(e,t)=>{if(!e||!t)return;const r=T.Wa(e,t);T.si(e,t,r+1)}};export default T;
1
+ import { REQUEST_ATTEMPT_DEFAULT as Ae } from "../common/constants.js";
2
+ import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
3
+ const T = {
4
+ Os: { Na: "d", Ks: "cc", Si: "ff", Lr: "t" },
5
+ rm: (e) => {
6
+ if (e) return e.v(i.k.EE);
7
+ },
8
+ sm: (e) => {
9
+ if (e) return e.v(i.k.lE);
10
+ },
11
+ nm: (e, t) => {
12
+ e && e.D(i.k.EE, t);
13
+ },
14
+ um: (e, t) => {
15
+ e && e.D(i.k.lE, t);
16
+ },
17
+ La: (e, t) => {
18
+ if (!e || !t) return -1;
19
+ const r = T.rm(e);
20
+ if (null == r) return -1;
21
+ const s = r[t];
22
+ return null == s || isNaN(s) ? -1 : s;
23
+ },
24
+ Wa: (e, t) => {
25
+ let r = Ae;
26
+ if (!e || !t) return r;
27
+ const s = T.sm(e);
28
+ return null == s ? r : ((r = s[t]), null == r || isNaN(r) ? Ae : r);
29
+ },
30
+ Ws: (e, t, r) => {
31
+ if (!e || !t) return;
32
+ let s = T.rm(e);
33
+ null == s && (s = {}), (s[t] = r), T.nm(e, s);
34
+ },
35
+ si: (e, t, r) => {
36
+ if (!e || !t) return;
37
+ let s = T.sm(e);
38
+ null == s && (s = {}), (s[t] = r), T.um(e, s);
39
+ },
40
+ hi: (e, t) => {
41
+ if (!e || !t) return;
42
+ const r = T.Wa(e, t);
43
+ T.si(e, t, r + 1);
44
+ },
45
+ };
46
+ export default T;
@@ -1 +1,22 @@
1
- import r from"../../shared-lib/braze-shared-lib.js";export function getByteLength(t){let e=t.length;for(let r=t.length-1;r>=0;r--){const n=t.charCodeAt(r);n>127&&n<=2047?e++:n>2047&&n<=65535&&(e+=2),n>=56320&&n<=57343&&r--}return e}export function decodeBrazeActions(t){try{t=t.replace(/-/g,"+").replace(/_/g,"/");const e=window.atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);const n=new Uint16Array(r.buffer);return String.fromCharCode(...n)}catch(t){return r.j.error("Unable to decode Base64: "+t),null}}
1
+ import r from "../../shared-lib/braze-shared-lib.js";
2
+ export function getByteLength(t) {
3
+ let e = t.length;
4
+ for (let r = t.length - 1; r >= 0; r--) {
5
+ const n = t.charCodeAt(r);
6
+ n > 127 && n <= 2047 ? e++ : n > 2047 && n <= 65535 && (e += 2),
7
+ n >= 56320 && n <= 57343 && r--;
8
+ }
9
+ return e;
10
+ }
11
+ export function decodeBrazeActions(t) {
12
+ try {
13
+ t = t.replace(/-/g, "+").replace(/_/g, "/");
14
+ const e = window.atob(t),
15
+ r = new Uint8Array(e.length);
16
+ for (let t = 0; t < e.length; t++) r[t] = e.charCodeAt(t);
17
+ const n = new Uint16Array(r.buffer);
18
+ return String.fromCharCode(...n);
19
+ } catch (t) {
20
+ return r.j.error("Unable to decode Base64: " + t), null;
21
+ }
22
+ }
package/src/util/types.js CHANGED
@@ -1 +1 @@
1
- export{};
1
+ export {};
@@ -1 +1,20 @@
1
- export function parseQueryStringKeyValues(t){null==t&&(t="");const r=t.split("?").slice(1).join("?"),n={};if(null!=r){const t=r.split("&");for(let r=0;r<t.length;r++){const a=t[r].split("=");""!==a[0]&&(n[a[0]]=a[1])}}return n}export function isURIJavascriptOrData(t){return!(!t||0!==(t=t.toString().toLowerCase()).lastIndexOf("javascript:",0)&&0!==t.lastIndexOf("data:",0))}
1
+ export function parseQueryStringKeyValues(t) {
2
+ null == t && (t = "");
3
+ const r = t.split("?").slice(1).join("?"),
4
+ n = {};
5
+ if (null != r) {
6
+ const t = r.split("&");
7
+ for (let r = 0; r < t.length; r++) {
8
+ const a = t[r].split("=");
9
+ "" !== a[0] && (n[a[0]] = a[1]);
10
+ }
11
+ }
12
+ return n;
13
+ }
14
+ export function isURIJavascriptOrData(t) {
15
+ return !(
16
+ !t ||
17
+ (0 !== (t = t.toString().toLowerCase()).lastIndexOf("javascript:", 0) &&
18
+ 0 !== t.lastIndexOf("data:", 0))
19
+ );
20
+ }
@@ -1 +1,80 @@
1
- import ge from"./base-device-parser.js";import{Browsers as oi,OperatingSystems as W}from"./device-constants.js";export default class ai extends ge{constructor(){super(),this.rd=ai.ic(navigator.userAgent||"")}tf(){return this.rd[0]||"Unknown Browser"}ef(){return this.rd[1]||"Unknown Version"}Ta(r){for(let n=0;n<r.length;n++){const e=r[n].string;let i=ai.rf(e,r[n]);if(i)return i===W.kg&&navigator.maxTouchPoints>1&&(i=W.de),Promise.resolve(i)}return Promise.resolve(navigator.platform)}static ic(r){let n,e=r.match(/(samsungbrowser|tizen|roku|konqueror|icab|crios|opera|ucbrowser|chrome|safari|firefox|camino|msie|trident(?=\/))\/?\s*(\.?\d+(\.\d+)*)/i)||[];if(e[1]&&/trident/i.test(e[1]))return n=/\brv[ :]+(\.?\d+(\.\d+)*)/g.exec(r)||[],[oi.oc,n[1]||""];if(-1!==r.indexOf("(Web0S; Linux/SmartTV)"))return["LG Smart TV",null];if(-1!==r.indexOf("CrKey"))return["Chromecast",null];if(-1!==r.indexOf("BRAVIA")||-1!==r.indexOf("SonyCEBrowser")||-1!==r.indexOf("SonyDTV"))return["Sony Smart TV",null];if(-1!==r.indexOf("PhilipsTV"))return["Philips Smart TV",null];if(r.match(/\b(Roku)\b/))return["Roku",null];if(r.match(/\bAFTM\b/))return["Amazon Fire Stick",null];if(e[1]===oi.pE&&(n=r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/),null!=n))return n=n.slice(1),n[0]=n[0].replace("OPR",oi.FE),n[0]=n[0].replace("EdgA",oi.xE),"Edg"===n[0]&&(n[0]=oi.xE),[n[0],n[1]];if(e[1]===oi.Bg&&(n=r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/),null!=n))return n=n.slice(1),n[0]=n[0].replace("EdgiOS",oi.xE),[n[0],n[1]];if(e=e[2]?[e[1],e[2]]:[null,null],e[0]===oi.Bg&&null!=(n=r.match(/version\/(\.?\d+(\.\d+)*)/i))&&e.splice(1,1,n[1]),null!=(n=r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/))&&e.splice(1,1,n[2]),e[0]===oi.FE&&null!=(n=r.match(/mini\/(\.?\d+(\.\d+)*)/i)))return["Opera Mini",n[1]||""];if(e[0]){const r=e[0].toLowerCase();"msie"===r&&(e[0]=oi.oc),"crios"===r&&(e[0]=oi.pE),"tizen"===r&&(e[0]="Samsung Smart TV",e[1]=null),"samsungbrowser"===r&&(e[0]="Samsung Browser")}return e}}
1
+ import ge from "./base-device-parser.js";
2
+ import { Browsers as oi, OperatingSystems as V } from "./device-constants.js";
3
+ export default class ai extends ge {
4
+ constructor() {
5
+ super(), (this.rd = ai.ic(navigator.userAgent || ""));
6
+ }
7
+ tf() {
8
+ return this.rd[0] || "Unknown Browser";
9
+ }
10
+ ef() {
11
+ return this.rd[1] || "Unknown Version";
12
+ }
13
+ Ta(r) {
14
+ for (let n = 0; n < r.length; n++) {
15
+ const e = r[n].string;
16
+ let i = ai.rf(e, r[n]);
17
+ if (i)
18
+ return (
19
+ i === V.kg && navigator.maxTouchPoints > 1 && (i = V.de),
20
+ Promise.resolve(i)
21
+ );
22
+ }
23
+ return Promise.resolve(navigator.platform);
24
+ }
25
+ static ic(r) {
26
+ let n,
27
+ e =
28
+ r.match(
29
+ /(samsungbrowser|tizen|roku|konqueror|icab|crios|opera|ucbrowser|chrome|safari|firefox|camino|msie|trident(?=\/))\/?\s*(\.?\d+(\.\d+)*)/i,
30
+ ) || [];
31
+ if (-1 !== r.indexOf("(Web0S; Linux/SmartTV)"))
32
+ return ["LG Smart TV", null];
33
+ if (-1 !== r.indexOf("CrKey")) return ["Chromecast", null];
34
+ if (
35
+ -1 !== r.indexOf("BRAVIA") ||
36
+ -1 !== r.indexOf("SonyCEBrowser") ||
37
+ -1 !== r.indexOf("SonyDTV")
38
+ )
39
+ return ["Sony Smart TV", null];
40
+ if (-1 !== r.indexOf("PhilipsTV")) return ["Philips Smart TV", null];
41
+ if (r.match(/\b(Roku)\b/)) return ["Roku", null];
42
+ if (r.match(/\bAFTM\b/)) return ["Amazon Fire Stick", null];
43
+ if (
44
+ e[1] === oi.rO &&
45
+ ((n = r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/)),
46
+ null != n)
47
+ )
48
+ return (
49
+ (n = n.slice(1)),
50
+ (n[0] = n[0].replace("OPR", oi.oO)),
51
+ (n[0] = n[0].replace("EdgA", oi.eO)),
52
+ "Edg" === n[0] && (n[0] = oi.eO),
53
+ [n[0], n[1]]
54
+ );
55
+ if (
56
+ e[1] === oi.Bg &&
57
+ ((n = r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/)), null != n)
58
+ )
59
+ return (
60
+ (n = n.slice(1)), (n[0] = n[0].replace("EdgiOS", oi.eO)), [n[0], n[1]]
61
+ );
62
+ if (
63
+ ((e = e[2] ? [e[1], e[2]] : [null, null]),
64
+ e[0] === oi.Bg &&
65
+ null != (n = r.match(/version\/(\.?\d+(\.\d+)*)/i)) &&
66
+ e.splice(1, 1, n[1]),
67
+ null != (n = r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/)) &&
68
+ e.splice(1, 1, n[2]),
69
+ e[0] === oi.oO && null != (n = r.match(/mini\/(\.?\d+(\.\d+)*)/i)))
70
+ )
71
+ return ["Opera Mini", n[1] || ""];
72
+ if (e[0]) {
73
+ const r = e[0].toLowerCase();
74
+ "crios" === r && (e[0] = oi.rO),
75
+ "tizen" === r && ((e[0] = "Samsung Smart TV"), (e[1] = null)),
76
+ "samsungbrowser" === r && (e[0] = "Samsung Browser");
77
+ }
78
+ return e;
79
+ }
80
+ }
@@ -1 +1,217 @@
1
- import{isArray as p,isDate as yt,isObject as Nt,keys as oo}from"./code-utils.js";import{getByteLength as U}from"./string-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as $t}from"./date-utils.js";import{BRAZE_ACTIONS as _}from"./braze-actions.js";import{SET_CUSTOM_USER_ATTRIBUTE_STRING as Ft}from"../common/constants.js";export const CUSTOM_DATA_REGEX=/^[^\x00-\x1F\x22]+$/;export const CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX=/[$.]/;export const CUSTOM_ATTRIBUTE_RESERVED_OPERATORS=["$add","$update","$remove","$identifier_key","$identifier_value","$new_object","$time"];export const EMAIL_ADDRESS_REGEX=new RegExp(/^.+@.+\..+$/);export const CUSTOM_PROPERTIES_MAX_SIZE_BYTES=51200;export const CUSTOM_PROPERTIES_MAX_SIZE_STRING="50KB";export const CUSTOM_ATTRIBUTES_MAX_SIZE_BYTES=76800;export const CUSTOM_ATTRIBUTES_MAX_SIZE_STRING="75KB";export const CUSTOM_ATTRIBUTE_MAX_DEPTH=50;export const BRAZE_ACTION_URI_REGEX=/^brazeActions:\/\/v\d+\//;export function validateCustomString(t,e,n){const o=null!=t&&"string"==typeof t&&(""===t||null!=t.match(CUSTOM_DATA_REGEX));return o||r.j.error(`Cannot ${e} because ${n} "${t}" is invalid.`),o}export function validateCustomAttributeKey(t){return null!=t&&t.match(CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX)&&-1===CUSTOM_ATTRIBUTE_RESERVED_OPERATORS.indexOf(t)&&r.j.warn("Custom attribute keys cannot contain '$' or '.'"),validateCustomString(t,"set custom user attribute","the given key")}export function validatePropertyType(t){const e=typeof t;return null==t||"number"===e||"boolean"===e||yt(t)||"string"===e}export function _validateNestedProperties(t,e,n){const o=-1!==n;if(o&&n>50)return r.j.error("Nested attributes cannot be more than 50 levels deep."),!1;const i=o?n+1:-1;if(p(t)&&p(e)){for(let r=0;r<t.length&&r<e.length;r++)if(yt(t[r])&&(e[r]=$t(t[r])),!_validateNestedProperties(t[r],e[r],i))return!1}else{if(!Nt(t))return validatePropertyType(t);for(const r of oo(t)){const n=t[r];if(o&&!validateCustomAttributeKey(r))return!1;if(yt(n)){e[r]=$t(n)}if(!_validateNestedProperties(n,e[r],i))return!1}}return!0}export function _validateEventPropertyValue(t,e,n,o,i){let a;return a=Nt(t)||p(t)?_validateNestedProperties(t,e,i?1:-1):validatePropertyType(t),a||r.j.error(`Cannot ${n} because ${o} "${t}" is invalid.`),a}export function validateStandardString(t,e,n,o=!1){const i="string"==typeof t||null===t&&o;return i||r.j.error(`Cannot ${e} because ${n} "${t}" is invalid.`),i}export function validateCustomProperties(t,e,n,o,i){if(null==t&&(t={}),"object"!=typeof t||p(t))return r.j.error(`${e} requires that ${n} be an object. Ignoring ${i}.`),[!1,null];let a,s;e===Ft?(a=76800,s="75KB"):(a=51200,s="50KB");const u=JSON.stringify(t);if(U(u)>a)return r.j.error(`Could not ${o} because ${n} was greater than the max size of ${s}.`),[!1,null];let l;try{l=JSON.parse(u)}catch(t){return r.j.error(`Could not ${o} because ${n} did not contain valid JSON.`),[!1,null]}for(const r in t){if(e===Ft&&!validateCustomAttributeKey(r))return[!1,null];if(!validateCustomString(r,o,`the ${i} property name`))return[!1,null];const n=t[r];if(e!==Ft&&null==n){delete t[r],delete l[r];continue}yt(n)&&(l[r]=$t(n));if(!_validateEventPropertyValue(n,l[r],o,`the ${i} property "${r}"`,e===Ft))return[!1,null]}return[!0,l]}export function validateCustomAttributeArrayType(t,e){let n=!1,o=!1;const i=()=>{r.j.error("Custom attribute arrays must be either string arrays or object arrays.")};for(const r of e)if("string"==typeof r){if(o)return i(),[!1,!1];if(!validateCustomString(r,`set custom user attribute "${t}"`,"the element in the given array"))return[!1,!1];n=!0}else{if(!Nt(r))return i(),[!1,!1];if(n)return i(),[!1,!1];if(!validateCustomProperties(r,Ft,"attribute value",`set custom user attribute "${t}"`,"custom user attribute"))return[!1,!1];o=!0}return[n,o]}export function isValidEmail(t){return"string"==typeof t&&null!=t.toLowerCase().match(EMAIL_ADDRESS_REGEX)}export function isValidBrazeActionJson(t){if(!(_.properties.type in t))return!1;switch(t[_.properties.type]){case _.types.ue:if(_.properties.me in t)return!0;break;case _.types.logCustomEvent:case _.types.setEmailNotificationSubscriptionType:case _.types.setPushNotificationSubscriptionType:case _.types.setCustomUserAttribute:case _.types.addToSubscriptionGroup:case _.types.removeFromSubscriptionGroup:case _.types.addToCustomAttributeArray:case _.types.removeFromCustomAttributeArray:case _.types.pe:case _.types.je:if(_.properties.le in t)return!0;break;case _.types.requestPushPermission:return!0;default:return!1}return!1}export function isValidBrazeActionType(t){let e=!1;return Object.keys(_.types).forEach((r=>{_.types[r]!==t.toString()||(e=!0)})),e}
1
+ import {
2
+ isArray as p,
3
+ isDate as yt,
4
+ isObject as Nt,
5
+ keys as oo,
6
+ } from "./code-utils.js";
7
+ import { getByteLength as U } from "./string-utils.js";
8
+ import r from "../../shared-lib/braze-shared-lib.js";
9
+ import { toValidBackendTimeString as $t } from "./date-utils.js";
10
+ import { BRAZE_ACTIONS as _ } from "./braze-actions.js";
11
+ import { SET_CUSTOM_USER_ATTRIBUTE_STRING as Ft } from "../common/constants.js";
12
+ export const CUSTOM_DATA_REGEX = /^[^\x00-\x1F\x22]+$/;
13
+ export const CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX = /[$.]/;
14
+ export const CUSTOM_ATTRIBUTE_RESERVED_OPERATORS = [
15
+ "$add",
16
+ "$update",
17
+ "$remove",
18
+ "$identifier_key",
19
+ "$identifier_value",
20
+ "$new_object",
21
+ "$time",
22
+ ];
23
+ export const EMAIL_ADDRESS_REGEX = new RegExp(/^.+@.+\..+$/);
24
+ export const CUSTOM_PROPERTIES_MAX_SIZE_BYTES = 51200;
25
+ export const CUSTOM_PROPERTIES_MAX_SIZE_STRING = "50KB";
26
+ export const CUSTOM_ATTRIBUTES_MAX_SIZE_BYTES = 76800;
27
+ export const CUSTOM_ATTRIBUTES_MAX_SIZE_STRING = "75KB";
28
+ export const CUSTOM_ATTRIBUTE_MAX_DEPTH = 50;
29
+ export const BRAZE_ACTION_URI_REGEX = /^brazeActions:\/\/v\d+\//;
30
+ export function validateCustomString(t, e, n) {
31
+ const o =
32
+ null != t &&
33
+ "string" == typeof t &&
34
+ ("" === t || null != t.match(CUSTOM_DATA_REGEX));
35
+ return o || r.j.error(`Cannot ${e} because ${n} "${t}" is invalid.`), o;
36
+ }
37
+ export function validateCustomAttributeKey(t) {
38
+ return (
39
+ null != t &&
40
+ t.match(CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX) &&
41
+ -1 === CUSTOM_ATTRIBUTE_RESERVED_OPERATORS.indexOf(t) &&
42
+ r.j.warn("Custom attribute keys cannot contain '$' or '.'"),
43
+ validateCustomString(t, "set custom user attribute", "the given key")
44
+ );
45
+ }
46
+ export function validatePropertyType(t) {
47
+ const e = typeof t;
48
+ return (
49
+ null == t || "number" === e || "boolean" === e || yt(t) || "string" === e
50
+ );
51
+ }
52
+ export function _validateNestedProperties(t, e, n) {
53
+ const o = -1 !== n;
54
+ if (o && n > 50)
55
+ return (
56
+ r.j.error("Nested attributes cannot be more than 50 levels deep."), !1
57
+ );
58
+ const i = o ? n + 1 : -1;
59
+ if (p(t) && p(e)) {
60
+ for (let r = 0; r < t.length && r < e.length; r++)
61
+ if (
62
+ (yt(t[r]) && (e[r] = $t(t[r])),
63
+ !_validateNestedProperties(t[r], e[r], i))
64
+ )
65
+ return !1;
66
+ } else {
67
+ if (!Nt(t)) return validatePropertyType(t);
68
+ for (const r of oo(t)) {
69
+ const n = t[r];
70
+ if (o && !validateCustomAttributeKey(r)) return !1;
71
+ if (yt(n)) {
72
+ e[r] = $t(n);
73
+ }
74
+ if (!_validateNestedProperties(n, e[r], i)) return !1;
75
+ }
76
+ }
77
+ return !0;
78
+ }
79
+ export function _validateEventPropertyValue(t, e, n, o, i) {
80
+ let a;
81
+ return (
82
+ (a =
83
+ Nt(t) || p(t)
84
+ ? _validateNestedProperties(t, e, i ? 1 : -1)
85
+ : validatePropertyType(t)),
86
+ a || r.j.error(`Cannot ${n} because ${o} "${t}" is invalid.`),
87
+ a
88
+ );
89
+ }
90
+ export function validateStandardString(t, e, n, o = !1) {
91
+ const i = "string" == typeof t || (null === t && o);
92
+ return i || r.j.error(`Cannot ${e} because ${n} "${t}" is invalid.`), i;
93
+ }
94
+ export function validateCustomProperties(t, e, n, o, i) {
95
+ if ((null == t && (t = {}), "object" != typeof t || p(t)))
96
+ return (
97
+ r.j.error(`${e} requires that ${n} be an object. Ignoring ${i}.`),
98
+ [!1, null]
99
+ );
100
+ let a, s;
101
+ e === Ft ? ((a = 76800), (s = "75KB")) : ((a = 51200), (s = "50KB"));
102
+ const u = JSON.stringify(t);
103
+ if (U(u) > a)
104
+ return (
105
+ r.j.error(
106
+ `Could not ${o} because ${n} was greater than the max size of ${s}.`,
107
+ ),
108
+ [!1, null]
109
+ );
110
+ let l;
111
+ try {
112
+ l = JSON.parse(u);
113
+ } catch (t) {
114
+ return (
115
+ r.j.error(`Could not ${o} because ${n} did not contain valid JSON.`),
116
+ [!1, null]
117
+ );
118
+ }
119
+ for (const r in t) {
120
+ if (e === Ft && !validateCustomAttributeKey(r)) return [!1, null];
121
+ if (!validateCustomString(r, o, `the ${i} property name`))
122
+ return [!1, null];
123
+ const n = t[r];
124
+ if (e !== Ft && null == n) {
125
+ delete t[r], delete l[r];
126
+ continue;
127
+ }
128
+ yt(n) && (l[r] = $t(n));
129
+ if (
130
+ !_validateEventPropertyValue(
131
+ n,
132
+ l[r],
133
+ o,
134
+ `the ${i} property "${r}"`,
135
+ e === Ft,
136
+ )
137
+ )
138
+ return [!1, null];
139
+ }
140
+ return [!0, l];
141
+ }
142
+ export function validateCustomAttributeArrayType(t, e) {
143
+ let n = !1,
144
+ o = !1;
145
+ const i = () => {
146
+ r.j.error(
147
+ "Custom attribute arrays must be either string arrays or object arrays.",
148
+ );
149
+ };
150
+ for (const r of e)
151
+ if ("string" == typeof r) {
152
+ if (o) return i(), [!1, !1];
153
+ if (
154
+ !validateCustomString(
155
+ r,
156
+ `set custom user attribute "${t}"`,
157
+ "the element in the given array",
158
+ )
159
+ )
160
+ return [!1, !1];
161
+ n = !0;
162
+ } else {
163
+ if (!Nt(r)) return i(), [!1, !1];
164
+ if (n) return i(), [!1, !1];
165
+ if (
166
+ !validateCustomProperties(
167
+ r,
168
+ Ft,
169
+ "attribute value",
170
+ `set custom user attribute "${t}"`,
171
+ "custom user attribute",
172
+ )
173
+ )
174
+ return [!1, !1];
175
+ o = !0;
176
+ }
177
+ return [n, o];
178
+ }
179
+ export function isValidEmail(t) {
180
+ return (
181
+ "string" == typeof t && null != t.toLowerCase().match(EMAIL_ADDRESS_REGEX)
182
+ );
183
+ }
184
+ export function isValidBrazeActionJson(t) {
185
+ if (!(_.properties.type in t)) return !1;
186
+ switch (t[_.properties.type]) {
187
+ case _.types.ue:
188
+ if (_.properties.me in t) return !0;
189
+ break;
190
+ case _.types.logCustomEvent:
191
+ case _.types.setEmailNotificationSubscriptionType:
192
+ case _.types.setPushNotificationSubscriptionType:
193
+ case _.types.setCustomUserAttribute:
194
+ case _.types.addToSubscriptionGroup:
195
+ case _.types.removeFromSubscriptionGroup:
196
+ case _.types.addToCustomAttributeArray:
197
+ case _.types.removeFromCustomAttributeArray:
198
+ case _.types.pe:
199
+ case _.types.je:
200
+ if (_.properties.le in t) return !0;
201
+ break;
202
+ case _.types.requestPushPermission:
203
+ return !0;
204
+ default:
205
+ return !1;
206
+ }
207
+ return !1;
208
+ }
209
+ export function isValidBrazeActionType(t) {
210
+ let e = !1;
211
+ return (
212
+ Object.keys(_.types).forEach((r) => {
213
+ _.types[r] !== t.toString() || (e = !0);
214
+ }),
215
+ e
216
+ );
217
+ }
@@ -1 +1,34 @@
1
- export const ORIENTATION={PORTRAIT:0,LANDSCAPE:1};export function _isPhone(){return screen.width<=600}export function _getOrientation(){if("orientation"in window)return 90===Math.abs(window.orientation)||270===window.orientation?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT;const n=window;if("screen"in n){let e=n.screen.orientation||screen.mozOrientation||screen.msOrientation;return null!=e&&"object"==typeof e&&(e=e.type),"landscape-primary"===e||"landscape-secondary"===e?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT}return ORIENTATION.PORTRAIT}export function _openUri(n,e,t){n&&(e||null!=t&&t.metaKey?window.open(n):window.location=n)}export function _getCurrentUrl(){return window.location.href}export const WindowUtils={openUri:_openUri,ao:_isPhone,mo:_getOrientation,Cn:_getCurrentUrl};
1
+ export const ORIENTATION = { PORTRAIT: 0, LANDSCAPE: 1 };
2
+ export function _isPhone() {
3
+ return screen.width <= 600;
4
+ }
5
+ export function _getOrientation() {
6
+ if ("orientation" in window)
7
+ return 90 === Math.abs(window.orientation) || 270 === window.orientation
8
+ ? ORIENTATION.LANDSCAPE
9
+ : ORIENTATION.PORTRAIT;
10
+ const n = window;
11
+ if ("screen" in n) {
12
+ let e =
13
+ n.screen.orientation || screen.mozOrientation || screen.msOrientation;
14
+ return (
15
+ null != e && "object" == typeof e && (e = e.type),
16
+ "landscape-primary" === e || "landscape-secondary" === e
17
+ ? ORIENTATION.LANDSCAPE
18
+ : ORIENTATION.PORTRAIT
19
+ );
20
+ }
21
+ return ORIENTATION.PORTRAIT;
22
+ }
23
+ export function _openUri(n, e, t) {
24
+ n && (e || (null != t && t.metaKey) ? window.open(n) : (window.location = n));
25
+ }
26
+ export function _getCurrentUrl() {
27
+ return window.location.href;
28
+ }
29
+ export const WindowUtils = {
30
+ openUri: _openUri,
31
+ ao: _isPhone,
32
+ mo: _getOrientation,
33
+ Cn: _getCurrentUrl,
34
+ };
@@ -1 +0,0 @@
1
- import Card from"./card.js";export default class Banner extends Card{constructor(s,t,i,h,r,e,n,a,l,o,u,c,b,d){super(s,t,null,i,null,h,r,e,n,a,l,o,u,c,b,d),this.U="ab-banner ab-image-only",this.V=!1,this.test=!1}ss(){const s={};return s[Card.hs.ts]=Card.es.rs,s[Card.hs.ns]=this.id,s[Card.hs.ls]=this.viewed,s[Card.hs.os]=this.imageUrl,s[Card.hs.us]=this.updated,s[Card.hs.cs]=this.created,s[Card.hs.bs]=this.categories,s[Card.hs.ds]=this.expiresAt,s[Card.hs.URL]=this.url,s[Card.hs.ps]=this.linkText,s[Card.hs.fs]=this.aspectRatio,s[Card.hs.xs]=this.extras,s[Card.hs.gs]=this.pinned,s[Card.hs.js]=this.dismissible,s[Card.hs.ys]=this.clicked,s[Card.hs.zs]=this.test,s}}
@@ -1 +0,0 @@
1
- import e from"../managers/braze-instance.js";import{logDeprecationWarning as z}from"../util/deprecation-utils.js";export function logContentCardsDisplayed(){if(e.rr())return z("logContentCardsDisplayed","method"),!0}