@braze/web-sdk 4.0.5 → 4.0.6

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 (54) hide show
  1. package/index.d.ts +1 -1
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +1 -1
  4. package/shared-lib/encoding-utils.js +1 -1
  5. package/shared-lib/event-types.js +1 -1
  6. package/shared-lib/indexed-db-adapter.js +1 -1
  7. package/shared-lib/logger.js +1 -1
  8. package/shared-lib/supported-options.js +1 -1
  9. package/src/InAppMessage/in-app-message-manager.js +1 -1
  10. package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
  11. package/src/InAppMessage/log-in-app-message-click.js +1 -1
  12. package/src/InAppMessage/log-in-app-message-html-click.js +1 -1
  13. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  14. package/src/InAppMessage/models/in-app-message-button.js +1 -1
  15. package/src/InAppMessage/models/in-app-message.js +1 -1
  16. package/src/InAppMessage/models/modal-message.js +1 -1
  17. package/src/InAppMessage/models/slide-up-message.js +1 -1
  18. package/src/InAppMessage/models/templated-in-app-message.js +1 -1
  19. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  20. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +1 -1
  21. package/src/InAppMessage/ui/show-in-app-message.js +1 -1
  22. package/src/Push/is-push-blocked.js +1 -1
  23. package/src/Push/is-push-permission-granted.js +1 -1
  24. package/src/Push/is-push-supported.js +1 -1
  25. package/src/Push/push-manager-factory.js +1 -1
  26. package/src/Push/push-manager.js +1 -1
  27. package/src/Push/request-push-permission.js +1 -1
  28. package/src/Push/unregister-push.js +1 -1
  29. package/src/User/user-manager.js +1 -1
  30. package/src/User/user.js +1 -1
  31. package/src/common/base-feed.js +1 -1
  32. package/src/common/feed-display.js +1 -1
  33. package/src/managers/braze-instance.js +1 -1
  34. package/src/managers/network-manager.js +1 -1
  35. package/src/managers/server-config-manager.js +1 -1
  36. package/src/managers/storage-manager.js +1 -1
  37. package/src/managers/subscription-manager.js +1 -1
  38. package/src/models/braze-event.js +1 -1
  39. package/src/models/device.js +1 -1
  40. package/src/models/identifier.js +1 -1
  41. package/src/models/push-token.js +1 -1
  42. package/src/models/server-config.js +1 -1
  43. package/src/request-controller.js +1 -1
  44. package/src/triggers/models/filter-set.js +1 -1
  45. package/src/triggers/models/filter.js +1 -1
  46. package/src/triggers/models/trigger-condition.js +1 -1
  47. package/src/triggers/models/trigger.js +1 -1
  48. package/src/triggers/triggers-provider-factory.js +1 -1
  49. package/src/triggers/triggers-provider.js +1 -1
  50. package/src/ui/js/attach-css.js +1 -1
  51. package/src/util/braze-actions.js +1 -1
  52. package/src/util/key-codes.js +1 -1
  53. package/src/util/validation-utils.js +1 -1
  54. package/src/util/window-utils.js +1 -1
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Type definitions for @braze/web-sdk v4.0.5
2
+ * Type definitions for @braze/web-sdk v4.0.6
3
3
  * Project: https://github.com/braze-inc/braze-web-sdk
4
4
  * (c) Braze, Inc. 2022 - http://braze.com
5
5
  * License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braze/web-sdk",
3
- "version": "4.0.5",
3
+ "version": "4.0.6",
4
4
  "description": "Braze SDK for web sites and other JS platforms.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1 +1 @@
1
- import je from"./encoding-utils.js";import{EventTypes as ve,InternalEventTypes as De}from"./event-types.js";import Be from"./guid.js";import Ae from"./indexed-db-adapter.js";import Ge from"./logger.js";import Oe from"./supported-options.js";const r={_n:je,A:ve,qr:De,nt:Be,qt:Ae,Ft:Ae.ep,D:Ge,Uo:Oe};export default r;
1
+ import je from"./encoding-utils.js";import{EventTypes as ve,InternalEventTypes as De}from"./event-types.js";import Be from"./guid.js";import Ae from"./indexed-db-adapter.js";import Ge from"./logger.js";import Oe from"./supported-options.js";const r={Nn:je,A:ve,qr:De,nt:Be,qt:Ae,Ft:Ae.ep,D:Ge,Uo:Oe};export default r;
@@ -1 +1 @@
1
- const je={Dn:function(t){const r=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=atob(r),o=new Uint8Array(n.length);for(let t=0;t<n.length;++t)o[t]=n.charCodeAt(t);return o}};export default je;
1
+ const je={_n:function(t){const r=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=atob(r),o=new Uint8Array(n.length);for(let t=0;t<n.length;++t)o[t]=n.charCodeAt(t);return o}};export default je;
@@ -1 +1 @@
1
- const ve={CustomEvent:"ce",Pr:"p",Sl:"pc",oc:"ca",Ra:"i",ha:"ie",T:"cci",W:"ccic",_:"ccc",L:"ccd",Wh:"ss",bh:"se",Pe:"si",qe:"sc",Oe:"sbc",Ne:"sfe",ro:"iec",vl:"lr",yl:"uae",U:"ci",F:"cc",Al:"lcaa",$l:"lcar",Xr:"inc",Yr:"add",Qr:"rem",Wr:"set",Cl:"sgu"},De={Fr:"feed_displayed",cc:"content_cards_displayed"};export{ve as EventTypes,De as InternalEventTypes};
1
+ const ve={CustomEvent:"ce",Pr:"p",Sl:"pc",oc:"ca",Ra:"i",ha:"ie",T:"cci",W:"ccic",_:"ccc",L:"ccd",Wh:"ss",bh:"se",Je:"si",Re:"sc",He:"sbc",Pe:"sfe",ro:"iec",vl:"lr",yl:"uae",U:"ci",F:"cc",Al:"lcaa",$l:"lcar",Qr:"inc",Wr:"add",Yr:"rem",Vr:"set",Cl:"sgu"},De={Fr:"feed_displayed",cc:"content_cards_displayed"};export{ve as EventTypes,De as InternalEventTypes};
@@ -1 +1 @@
1
- export default class Ae{constructor(t,e){this.td="undefined"==typeof window?self:window,this.ed=t,this.nd=e}od(){if("indexedDB"in this.td)return this.td.indexedDB}rd(){try{if(null==this.od())return!1;if(this.od().open("Braze IndexedDB Support Test"),"undefined"!=typeof window){const t=window.chrome||window.browser||window.msBrowser;if(t&&t.runtime&&t.runtime.id)return this.nd.info("Not using IndexedDB for storage because we are running inside an extension"),!1}return!0}catch(t){return this.nd.info("Not using IndexedDB for storage due to following error: "+t),!1}}dd(t,e){const n=this.od().open(this.ed.sd,this.ed.VERSION);if(null==n)return"function"==typeof e&&e(),!1;const o=this;return n.onupgradeneeded=t=>{o.nd.info("Upgrading indexedDB "+o.ed.sd+" to v"+o.ed.VERSION+"...");const e=t.target.result;for(const t in o.ed.Pt)o.ed.Pt.hasOwnProperty(t)&&!e.objectStoreNames.contains(o.ed.Pt[t])&&e.createObjectStore(o.ed.Pt[t])},n.onsuccess=n=>{const i=n.target.result;i.onversionchange=()=>{i.close(),"function"==typeof e&&e(),o.nd.error("Needed to close the database unexpectedly because of an upgrade in another tab")},t(i)},n.onerror=t=>(o.nd.info("Could not open indexedDB "+o.ed.sd+" v"+o.ed.VERSION+": "+t.target.errorCode),"function"==typeof e&&e(),!0),!0}setItem(t,e,n,o,i){if(!this.rd())return"function"==typeof i&&i(),!1;const r=this;return this.dd((d=>{if(!d.objectStoreNames.contains(t))return r.nd.error("Could not store object "+e+" in "+t+" on indexedDB "+r.ed.sd+" - "+t+" is not a valid objectStore"),void("function"==typeof i&&i());const s=d.transaction([t],"readwrite").objectStore(t).put(n,e);s.onerror=()=>{r.nd.error("Could not store object "+e+" in "+t+" on indexedDB "+r.ed.sd),"function"==typeof i&&i()},s.onsuccess=()=>{"function"==typeof o&&o()}}),i)}getItem(t,e,n){if(!this.rd())return!1;const o=this;return this.dd((i=>{if(!i.objectStoreNames.contains(t))return void o.nd.error("Could not retrieve object "+e+" in "+t+" on indexedDB "+o.ed.sd+" - "+t+" is not a valid objectStore");const r=i.transaction([t],"readonly").objectStore(t).get(e);r.onerror=()=>{o.nd.error("Could not retrieve object "+e+" in "+t+" on indexedDB "+o.ed.sd)},r.onsuccess=t=>{const e=t.target.result;null!=e&&n(e)}}))}hr(t,e,n){if(!this.rd())return"function"==typeof n&&n(),!1;const o=this;return this.dd((i=>{if(!i.objectStoreNames.contains(t))return o.nd.error("Could not retrieve last record from "+t+" on indexedDB "+o.ed.sd+" - "+t+" is not a valid objectStore"),void("function"==typeof n&&n());const r=i.transaction([t],"readonly").objectStore(t).openCursor(null,"prev");r.onerror=()=>{o.nd.error("Could not open cursor for "+t+" on indexedDB "+o.ed.sd),"function"==typeof n&&n()},r.onsuccess=t=>{const o=t.target.result;null!=o&&null!=o.value&&null!=o.key?e(o.key,o.value):"function"==typeof n&&n()}}),n)}br(t,e){if(!this.rd())return!1;const n=this;return this.dd((o=>{if(!o.objectStoreNames.contains(t))return void n.nd.error("Could not delete record "+e+" from "+t+" on indexedDB "+n.ed.sd+" - "+t+" is not a valid objectStore");o.transaction([t],"readwrite").objectStore(t).delete(e).onerror=()=>{n.nd.error("Could not delete record "+e+" from "+t+" on indexedDB "+n.ed.sd)}}))}Jt(t,e){if(!this.rd())return!1;const n=this;return this.dd((o=>{if(!o.objectStoreNames.contains(t))return void n.nd.error("Could not retrieve objects from "+t+" on indexedDB "+n.ed.sd+" - "+t+" is not a valid objectStore");const i=o.transaction([t],"readwrite").objectStore(t),r=i.openCursor(),d=[];r.onerror=()=>{d.length>0?(n.nd.info("Cursor closed midway through for "+t+" on indexedDB "+n.ed.sd),e(d)):n.nd.error("Could not open cursor for "+t+" on indexedDB "+n.ed.sd)},r.onsuccess=t=>{const n=t.target.result;if(null!=n){if(null!=n.value&&null!=n.key){i.delete(n.key).onsuccess=()=>{d.push(n.value)}}n.continue()}else d.length>0&&e(d)}}))}clearData(){if(!this.rd())return!1;const t=[];for(const e in this.ed.Pt)this.ed.Pt.hasOwnProperty(e)&&this.ed.Pt[e]!==this.ed.Pt.oe&&t.push(this.ed.Pt[e]);const e=this;return this.dd((function(n){const o=n.transaction(t,"readwrite");for(let n=0;n<t.length;n++){const i=t[n];o.objectStore(i).clear().onerror=function(){e.nd.error("Could not clear "+this.source.name+" on indexedDB "+e.ed.sd)}}o.onerror=function(){e.nd.error("Could not clear object stores on indexedDB "+e.ed.sd)}}))}}Ae.ep={xt:{sd:"AppboyServiceWorkerAsyncStorage",VERSION:6,Pt:{jl:"data",jr:"pushClicks",Nr:"pushSubscribed",ud:"fallbackDevice",Mt:"cardUpdates",oe:"optOut",$r:"pendingData",Kn:"sdkAuthenticationSignature"},se:1}};
1
+ export default class Ae{constructor(t,e){this.td="undefined"==typeof window?self:window,this.ed=t,this.nd=e}od(){if("indexedDB"in this.td)return this.td.indexedDB}rd(){try{if(null==this.od())return!1;if(this.od().open("Braze IndexedDB Support Test"),"undefined"!=typeof window){const t=window.chrome||window.browser||window.msBrowser;if(t&&t.runtime&&t.runtime.id)return this.nd.info("Not using IndexedDB for storage because we are running inside an extension"),!1}return!0}catch(t){return this.nd.info("Not using IndexedDB for storage due to following error: "+t),!1}}dd(t,e){const n=this.od().open(this.ed.sd,this.ed.VERSION);if(null==n)return"function"==typeof e&&e(),!1;const o=this;return n.onupgradeneeded=t=>{o.nd.info("Upgrading indexedDB "+o.ed.sd+" to v"+o.ed.VERSION+"...");const e=t.target.result;for(const t in o.ed.Pt)o.ed.Pt.hasOwnProperty(t)&&!e.objectStoreNames.contains(o.ed.Pt[t])&&e.createObjectStore(o.ed.Pt[t])},n.onsuccess=n=>{const i=n.target.result;i.onversionchange=()=>{i.close(),"function"==typeof e&&e(),o.nd.error("Needed to close the database unexpectedly because of an upgrade in another tab")},t(i)},n.onerror=t=>(o.nd.info("Could not open indexedDB "+o.ed.sd+" v"+o.ed.VERSION+": "+t.target.errorCode),"function"==typeof e&&e(),!0),!0}setItem(t,e,n,o,i){if(!this.rd())return"function"==typeof i&&i(),!1;const r=this;return this.dd((d=>{if(!d.objectStoreNames.contains(t))return r.nd.error("Could not store object "+e+" in "+t+" on indexedDB "+r.ed.sd+" - "+t+" is not a valid objectStore"),void("function"==typeof i&&i());const s=d.transaction([t],"readwrite").objectStore(t).put(n,e);s.onerror=()=>{r.nd.error("Could not store object "+e+" in "+t+" on indexedDB "+r.ed.sd),"function"==typeof i&&i()},s.onsuccess=()=>{"function"==typeof o&&o()}}),i)}getItem(t,e,n){if(!this.rd())return!1;const o=this;return this.dd((i=>{if(!i.objectStoreNames.contains(t))return void o.nd.error("Could not retrieve object "+e+" in "+t+" on indexedDB "+o.ed.sd+" - "+t+" is not a valid objectStore");const r=i.transaction([t],"readonly").objectStore(t).get(e);r.onerror=()=>{o.nd.error("Could not retrieve object "+e+" in "+t+" on indexedDB "+o.ed.sd)},r.onsuccess=t=>{const e=t.target.result;null!=e&&n(e)}}))}hr(t,e,n){if(!this.rd())return"function"==typeof n&&n(),!1;const o=this;return this.dd((i=>{if(!i.objectStoreNames.contains(t))return o.nd.error("Could not retrieve last record from "+t+" on indexedDB "+o.ed.sd+" - "+t+" is not a valid objectStore"),void("function"==typeof n&&n());const r=i.transaction([t],"readonly").objectStore(t).openCursor(null,"prev");r.onerror=()=>{o.nd.error("Could not open cursor for "+t+" on indexedDB "+o.ed.sd),"function"==typeof n&&n()},r.onsuccess=t=>{const o=t.target.result;null!=o&&null!=o.value&&null!=o.key?e(o.key,o.value):"function"==typeof n&&n()}}),n)}br(t,e){if(!this.rd())return!1;const n=this;return this.dd((o=>{if(!o.objectStoreNames.contains(t))return void n.nd.error("Could not delete record "+e+" from "+t+" on indexedDB "+n.ed.sd+" - "+t+" is not a valid objectStore");o.transaction([t],"readwrite").objectStore(t).delete(e).onerror=()=>{n.nd.error("Could not delete record "+e+" from "+t+" on indexedDB "+n.ed.sd)}}))}Jt(t,e){if(!this.rd())return!1;const n=this;return this.dd((o=>{if(!o.objectStoreNames.contains(t))return void n.nd.error("Could not retrieve objects from "+t+" on indexedDB "+n.ed.sd+" - "+t+" is not a valid objectStore");const i=o.transaction([t],"readwrite").objectStore(t),r=i.openCursor(),d=[];r.onerror=()=>{d.length>0?(n.nd.info("Cursor closed midway through for "+t+" on indexedDB "+n.ed.sd),e(d)):n.nd.error("Could not open cursor for "+t+" on indexedDB "+n.ed.sd)},r.onsuccess=t=>{const n=t.target.result;if(null!=n){if(null!=n.value&&null!=n.key){i.delete(n.key).onsuccess=()=>{d.push(n.value)}}n.continue()}else d.length>0&&e(d)}}))}clearData(){if(!this.rd())return!1;const t=[];for(const e in this.ed.Pt)this.ed.Pt.hasOwnProperty(e)&&this.ed.Pt[e]!==this.ed.Pt.oe&&t.push(this.ed.Pt[e]);const e=this;return this.dd((function(n){const o=n.transaction(t,"readwrite");for(let n=0;n<t.length;n++){const i=t[n];o.objectStore(i).clear().onerror=function(){e.nd.error("Could not clear "+this.source.name+" on indexedDB "+e.ed.sd)}}o.onerror=function(){e.nd.error("Could not clear object stores on indexedDB "+e.ed.sd)}}))}}Ae.ep={xt:{sd:"AppboyServiceWorkerAsyncStorage",VERSION:6,Pt:{jl:"data",jr:"pushClicks",Mr:"pushSubscribed",ud:"fallbackDevice",Mt:"cardUpdates",oe:"optOut",$r:"pendingData",Kn:"sdkAuthenticationSignature"},se:1}};
@@ -1 +1 @@
1
- const Ge={init:function(n){void 0===n&&void 0!==Ge.zg||(Ge.zg=!!n),Ge.Dg||(Ge.Dg=!0)},destroy:function(){Ge.Dg=!1,Ge.zg=void 0,Ge.nd=void 0},setLogger:function(n){"function"==typeof n?(Ge.init(),Ge.nd=n):Ge.info("Ignoring setLogger call since logger is not a function")},toggleLogging:function(){Ge.init(),Ge.zg?(console.log("Disabling Braze logging"),Ge.zg=!1):(console.log("Enabled Braze logging"),Ge.zg=!0)},info:function(n){if(Ge.zg){const o="Braze: "+n;null!=Ge.nd?Ge.nd(o):console.log(o)}},warn:function(n){if(Ge.zg){const o="Braze SDK Warning: "+n+" (v4.0.5)";null!=Ge.nd?Ge.nd(o):console.warn(o)}},error:function(n){if(Ge.zg){const o="Braze SDK Error: "+n+" (v4.0.5)";null!=Ge.nd?Ge.nd(o):console.error(o)}}};export default Ge;
1
+ const Ge={init:function(n){void 0===n&&void 0!==Ge.zg||(Ge.zg=!!n),Ge.Dg||(Ge.Dg=!0)},destroy:function(){Ge.Dg=!1,Ge.zg=void 0,Ge.nd=void 0},setLogger:function(n){"function"==typeof n?(Ge.init(),Ge.nd=n):Ge.info("Ignoring setLogger call since logger is not a function")},toggleLogging:function(){Ge.init(),Ge.zg?(console.log("Disabling Braze logging"),Ge.zg=!1):(console.log("Enabled Braze logging"),Ge.zg=!0)},info:function(n){if(Ge.zg){const o="Braze: "+n;null!=Ge.nd?Ge.nd(o):console.log(o)}},warn:function(n){if(Ge.zg){const o="Braze SDK Warning: "+n+" (v4.0.6)";null!=Ge.nd?Ge.nd(o):console.warn(o)}},error:function(n){if(Ge.zg){const o="Braze SDK Error: "+n+" (v4.0.6)";null!=Ge.nd?Ge.nd(o):console.error(o)}}};export default Ge;
@@ -1 +1 @@
1
- export default{Vn:"allowCrawlerActivity",$n:"baseUrl",Yn:"noCookies",Xn:"devicePropertyAllowlist",ra:"disablePushTokenMaintenance",Zn:"enableLogging",ho:"enableSdkAuthentication",ta:"manageServiceWorkerExternally",po:"minimumIntervalBetweenTriggerActionsInSeconds",Eo:"sessionTimeoutInSeconds",_o:"appVersion",ea:"serviceWorkerLocation",na:"safariWebsitePushId",zn:"localization",ao:"contentSecurityNonce",Io:"enableHtmlInAppMessages",Ao:"allowUserSuppliedJavascript",no:"inAppMessageZIndex",lo:"openInAppMessagesInNewTab",en:"openNewsFeedCardsInNewTab",Ri:"requireExplicitInAppMessageDismissal",So:"doNotLoadFontAwesome",No:"sdkFlavor",tn:"openCardsInNewTab"};
1
+ export default{Vn:"allowCrawlerActivity",$n:"baseUrl",Yn:"noCookies",Xn:"devicePropertyAllowlist",ra:"disablePushTokenMaintenance",Zn:"enableLogging",ho:"enableSdkAuthentication",ta:"manageServiceWorkerExternally",po:"minimumIntervalBetweenTriggerActionsInSeconds",Eo:"sessionTimeoutInSeconds",_o:"appVersion",ea:"serviceWorkerLocation",na:"safariWebsitePushId",zn:"localization",ao:"contentSecurityNonce",Io:"enableHtmlInAppMessages",Ao:"allowUserSuppliedJavascript",no:"inAppMessageZIndex",lo:"openInAppMessagesInNewTab",en:"openNewsFeedCardsInNewTab",bi:"requireExplicitInAppMessageDismissal",So:"doNotLoadFontAwesome",No:"sdkFlavor",tn:"openCardsInNewTab"};
@@ -1 +1 @@
1
- import b from"../util/net.js";import e from"../managers/braze-instance.js";import ControlMessage from"./models/control-message.js";import HtmlMessage from"./models/html-message.js";import InAppMessage from"./models/in-app-message.js";import InAppMessageButton from"./models/in-app-message-button.js";import s from"../common/event-logger.js";import{newInAppMessageFromJson as it}from"./in-app-message-factory.js";import{randomInclusive as lt}from"../util/math.js";import t from"../models/request-result.js";import r from"../../shared-lib/braze-shared-lib.js";import u from"../managers/subscription-manager.js";import ut from"../triggers/models/trigger.js";import{validateValueIsFromEnum as K}from"../util/code-utils.js";import{BRAZE_ACTION_URI_REGEX as P}from"../util/validation-utils.js";import{containsPushPrimerBrazeAction as pt,containsUnknownBrazeAction as mt,getDecodedBrazeAction as O,ineligibleBrazeActionURLErrorMessage as ct,INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as gt}from"../util/braze-actions.js";export default class ge{constructor(t,s,i,r){this.jt=t,this.j=s,this.h=i,this.v=r,this.Xs=new u,e.Ut(this.Xs),this.Ys=1e3,this.Zs=6e4}De(){return this.Xs}_e(t){return this.Xs.Et(t)}Se(){return this.Be}Ee(t){this.Be=t}Fe(e,i){if(!K(InAppMessage.Ge,i,`${i} is not a valid in-app message display failure`,"InAppMessage.DisplayFailures"))return new t;const n={trigger_ids:[e],error_code:i};return s.G(r.A.Ne,n)}G(e,i,n,o){const a=new t;let l;if(e instanceof ControlMessage)l={trigger_ids:[e.triggerId]};else{if(i===r.A.qe||e instanceof HtmlMessage&&i===r.A.Oe){if(!e.k(o))return r.D.info("This in-app message has already received a click. Ignoring analytics event."),a}else if(i===r.A.Pe){if(!e.R())return r.D.info("This in-app message has already received an impression. Ignoring analytics event."),a}l=this.Re(e)}return null==l?a:(null!=n&&(l.bid=n),s.G(i,l))}He(e,i){const n=new t;if(!e.k())return r.D.info("This in-app message button has already received a click. Ignoring analytics event."),n;const o=this.Re(i);return null==o?n:e.id===InAppMessageButton.Je?(r.D.info("This in-app message button does not have a tracking id. Not logging event to Braze servers."),n):(null!=e.id&&(o.bid=e.id),s.G(r.A.Oe,o))}async Ke(t){if(!(t instanceof InAppMessage))return;const s=async t=>{const s=O(t);if(mt(s))return ct(gt.Qe,"In-App Message");if(pt(s)){const t=(await import("../Push/push-manager-factory.js")).default.getPushManager();if(null!=t&&!t.Ue())return ct(gt.Ve,"In-App Message")}},e=t.buttons;for(const t of e)if(t.clickAction===InAppMessage.ClickAction.URI&&P.test(t.uri))return s(t.uri);return t.clickAction===InAppMessage.ClickAction.URI&&P.test(t.uri)?s(t.uri):void 0}We(t,s,e,i){let n=this.jt.Xe(!1,!1);n=this.jt.Ls(n),n.template={trigger_id:t.triggerId,trigger_event_type:s},null!=e&&(n.template.data=e.Ye());const o=this.jt.Ns(n);this.jt.As(n,(()=>{b.Fs({url:`${this.jt.Js()}/template/`,data:n,headers:o,S:async s=>{if(!this.jt.qs(n,s,o))return this.Fe(t.triggerId,InAppMessage.Ge.Ze),void("function"==typeof t.si&&t.si());if(this.jt.Es(),null==s||null==s.templated_message)return void this.Fe(t.triggerId,InAppMessage.Ge.Ze);const e=s.templated_message;if(e.type!==ut.ii.ei)return void this.Fe(t.triggerId,InAppMessage.Ge.ri);const i=it(e.data);if(null==i)return void this.Fe(t.triggerId,InAppMessage.Ge.ri);let a=await this.Ke(i);if(a)return r.D.error(a),void("function"==typeof t.si&&t.si());"function"==typeof t.ni?t.ni(i):this.Fe(t.triggerId,InAppMessage.Ge.Ze)},error:r=>{let n=`getting user personalization for message ${t.triggerId}`;if((new Date).valueOf()-t.oi>t.ai)this.Fe(t.triggerId,InAppMessage.Ge.Ze);else{const r=Math.min(t.ai,this.Zs),o=this.Ys;null==i&&(i=o);const a=Math.min(r,lt(o,3*i));n+=`. Retrying in ${a} ms`,setTimeout((()=>{this.We(t,s,e,a)}),a)}this.jt.Ms(r,n)}})}))}Re(t){if(null==t.triggerId)return r.D.info("The in-app message has no analytics id. Not logging event to Braze servers."),null;const s={};return null!=t.triggerId&&(s.trigger_ids=[t.triggerId]),s}}
1
+ import b from"../util/net.js";import e from"../managers/braze-instance.js";import ControlMessage from"./models/control-message.js";import HtmlMessage from"./models/html-message.js";import InAppMessage from"./models/in-app-message.js";import InAppMessageButton from"./models/in-app-message-button.js";import s from"../common/event-logger.js";import{newInAppMessageFromJson as it}from"./in-app-message-factory.js";import{randomInclusive as lt}from"../util/math.js";import t from"../models/request-result.js";import r from"../../shared-lib/braze-shared-lib.js";import u from"../managers/subscription-manager.js";import ut from"../triggers/models/trigger.js";import{validateValueIsFromEnum as K}from"../util/code-utils.js";import{BRAZE_ACTION_URI_REGEX as P}from"../util/validation-utils.js";import{containsPushPrimerBrazeAction as pt,containsUnknownBrazeAction as mt,getDecodedBrazeAction as O,ineligibleBrazeActionURLErrorMessage as ct,INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as gt}from"../util/braze-actions.js";export default class ge{constructor(t,s,i,r){this.jt=t,this.j=s,this.h=i,this.v=r,this.De=new u,e.Ut(this.De),this._e=1e3,this.Se=6e4}Be(){return this.De}Ee(t){return this.De.Et(t)}Fe(){return this.Ge}Ne(t){this.Ge=t}qe(e,i){if(!K(InAppMessage.Oe,i,`${i} is not a valid in-app message display failure`,"InAppMessage.DisplayFailures"))return new t;const n={trigger_ids:[e],error_code:i};return s.G(r.A.Pe,n)}G(e,i,n,o){const a=new t;let l;if(e instanceof ControlMessage)l={trigger_ids:[e.triggerId]};else{if(i===r.A.Re||e instanceof HtmlMessage&&i===r.A.He){if(!e.k(o))return r.D.info("This in-app message has already received a click. Ignoring analytics event."),a}else if(i===r.A.Je){if(!e.R())return r.D.info("This in-app message has already received an impression. Ignoring analytics event."),a}l=this.Ke(e)}return null==l?a:(null!=n&&(l.bid=n),s.G(i,l))}Qe(e,i){const n=new t;if(!e.k())return r.D.info("This in-app message button has already received a click. Ignoring analytics event."),n;const o=this.Ke(i);return null==o?n:e.id===InAppMessageButton.Ue?(r.D.info("This in-app message button does not have a tracking id. Not logging event to Braze servers."),n):(null!=e.id&&(o.bid=e.id),s.G(r.A.He,o))}async Ve(t){if(!(t instanceof InAppMessage))return;const e=async t=>{const e=O(t);return mt(e)?ct(gt.We,"In-App Message"):pt(e)?import("../Push/push-manager-factory.js").then((t=>{const e=t.default.Xe();if(null!=e&&!e.Ye())return ct(gt.Ze,"In-App Message")})):void 0},s=t.buttons;let i;for(const t of s)if(t.clickAction===InAppMessage.ClickAction.URI&&P.test(t.uri)&&(i=await e(t.uri),i))return i;return t.clickAction===InAppMessage.ClickAction.URI&&P.test(t.uri)?e(t.uri):void 0}Xs(t,e,s,i){let n=this.jt.Ys(!1,!1);n=this.jt.Ls(n),n.template={trigger_id:t.triggerId,trigger_event_type:e},null!=s&&(n.template.data=s.Zs());const o=this.jt.Ns(n);this.jt.As(n,(()=>{b.Fs({url:`${this.jt.Js()}/template/`,data:n,headers:o,S:async e=>{if(!this.jt.qs(n,e,o))return this.qe(t.triggerId,InAppMessage.Oe.ei),void("function"==typeof t.si&&t.si());if(this.jt.Es(),null==e||null==e.templated_message)return void this.qe(t.triggerId,InAppMessage.Oe.ei);const s=e.templated_message;if(s.type!==ut.ri.ii)return void this.qe(t.triggerId,InAppMessage.Oe.ni);const i=it(s.data);if(null==i)return void this.qe(t.triggerId,InAppMessage.Oe.ni);let a=await this.Ve(i);if(a)return r.D.error(a),void("function"==typeof t.si&&t.si());"function"==typeof t.oi?t.oi(i):this.qe(t.triggerId,InAppMessage.Oe.ei)},error:r=>{let n=`getting user personalization for message ${t.triggerId}`;if((new Date).valueOf()-t.ai>t.li)this.qe(t.triggerId,InAppMessage.Oe.ei);else{const r=Math.min(t.li,this.Se),o=this._e;null==i&&(i=o);const a=Math.min(r,lt(o,3*i));n+=`. Retrying in ${a} ms`,setTimeout((()=>{this.Xs(t,e,s,a)}),a)}this.jt.Ms(r,n)}})}))}Ke(t){if(null==t.triggerId)return r.D.info("The in-app message has no analytics id. Not logging event to Braze servers."),null;const e={};return null!=t.triggerId&&(e.trigger_ids=[t.triggerId]),e}}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as rr}from"../common/constants.js";import InAppMessage from"./models/in-app-message.js";import InAppMessageButton from"./models/in-app-message-button.js";import pe from"./in-app-message-manager-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import Q from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";export function logInAppMessageButtonClick(t,o){if(!e.rr())return!1;if(!(t instanceof InAppMessageButton))return r.D.error("button must be an InAppMessageButton object"),!1;if(!(o instanceof InAppMessage))return r.D.error(rr),!1;const s=pe.m().He(t,o);if(s.S)for(let r=0;r<s.ve.length;r++)V.er().je(Q.Ar,[o.triggerId,t.id],s.ve[r]);return s.S}
1
+ import e from"../managers/braze-instance.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as rr}from"../common/constants.js";import InAppMessage from"./models/in-app-message.js";import InAppMessageButton from"./models/in-app-message-button.js";import pe from"./in-app-message-manager-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import Q from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";export function logInAppMessageButtonClick(t,o){if(!e.rr())return!1;if(!(t instanceof InAppMessageButton))return r.D.error("button must be an InAppMessageButton object"),!1;if(!(o instanceof InAppMessage))return r.D.error(rr),!1;const s=pe.m().Qe(t,o);if(s.S)for(let r=0;r<s.ve.length;r++)V.er().je(Q.Ar,[o.triggerId,t.id],s.ve[r]);return s.S}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import InAppMessage from"./models/in-app-message.js";import pe from"./in-app-message-manager-factory.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as rr}from"../common/constants.js";import r from"../../shared-lib/braze-shared-lib.js";import Q from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";export function logInAppMessageClick(o){if(!e.rr())return!1;if(!(o instanceof InAppMessage))return r.D.error(rr),!1;const s=pe.m().G(o,r.A.qe);if(s)for(let r=0;r<s.ve.length;r++)V.er().je(Q.Ar,[o.triggerId],s.ve[r]);return s.S}
1
+ import e from"../managers/braze-instance.js";import InAppMessage from"./models/in-app-message.js";import pe from"./in-app-message-manager-factory.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as rr}from"../common/constants.js";import r from"../../shared-lib/braze-shared-lib.js";import Q from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";export function logInAppMessageClick(o){if(!e.rr())return!1;if(!(o instanceof InAppMessage))return r.D.error(rr),!1;const s=pe.m().G(o,r.A.Re);if(s)for(let r=0;r<s.ve.length;r++)V.er().je(Q.Ar,[o.triggerId],s.ve[r]);return s.S}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import HtmlMessage from"./models/html-message.js";import pe from"./in-app-message-manager-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import Q from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";export function logInAppMessageHtmlClick(s,t,o){if(!e.rr())return!1;if(!(s instanceof HtmlMessage))return r.D.error("inAppMessage argument to logInAppMessageHtmlClick must be an HtmlMessage object."),!1;let m=r.A.qe;null!=t&&(m=r.A.Oe);const i=pe.m().G(s,m,t,o);if(i.S)for(let r=0;r<i.ve.length;r++)V.er().je(Q.Ar,[s.triggerId,t],i.ve[r]);return i.S}
1
+ import e from"../managers/braze-instance.js";import HtmlMessage from"./models/html-message.js";import pe from"./in-app-message-manager-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import Q from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";export function logInAppMessageHtmlClick(s,t,o){if(!e.rr())return!1;if(!(s instanceof HtmlMessage))return r.D.error("inAppMessage argument to logInAppMessageHtmlClick must be an HtmlMessage object."),!1;let m=r.A.Re;null!=t&&(m=r.A.He);const i=pe.m().G(s,m,t,o);if(i.S)for(let r=0;r<i.ve.length;r++)V.er().je(Q.Ar,[s.triggerId,t],i.ve[r]);return i.S}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import ControlMessage from"./models/control-message.js";import InAppMessage from"./models/in-app-message.js";import pe from"./in-app-message-manager-factory.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as rr}from"../common/constants.js";import r from"../../shared-lib/braze-shared-lib.js";export function logInAppMessageImpression(o){if(!e.rr())return!1;if(!(o instanceof InAppMessage||o instanceof ControlMessage))return r.D.error(rr),!1;const s=o instanceof ControlMessage?r.A.ro:r.A.Pe;return pe.m().G(o,s).S}
1
+ import e from"../managers/braze-instance.js";import ControlMessage from"./models/control-message.js";import InAppMessage from"./models/in-app-message.js";import pe from"./in-app-message-manager-factory.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as rr}from"../common/constants.js";import r from"../../shared-lib/braze-shared-lib.js";export function logInAppMessageImpression(o){if(!e.rr())return!1;if(!(o instanceof InAppMessage||o instanceof ControlMessage))return r.D.error(rr),!1;const s=o instanceof ControlMessage?r.A.ro:r.A.Je;return pe.m().G(o,s).S}
@@ -1 +1 @@
1
- import InAppMessage from"./in-app-message.js";import u from"../../managers/subscription-manager.js";export default class InAppMessageButton{constructor(s,t,i,r,e,h,n){this.text=s||"",this.backgroundColor=t||InAppMessage.ci.hi,this.textColor=i||InAppMessage.ci.mi,this.borderColor=r||this.backgroundColor,this.clickAction=e||InAppMessage.ClickAction.NONE,this.uri=h,null==n&&(n=InAppMessageButton.Je),this.id=n,this.nl=!1,this.lt=new u}subscribeToClickedEvent(s){return this.lt.Et(s)}removeSubscription(s){this.lt.removeSubscription(s)}removeAllSubscriptions(){this.lt.removeAllSubscriptions()}k(){return!this.nl&&(this.nl=!0,this.lt.Nt(),!0)}static fromJson(s){return new InAppMessageButton(s.text,s.bg_color,s.text_color,s.border_color,s.click_action,s.uri,s.id)}}InAppMessageButton.Je=-1;
1
+ import InAppMessage from"./in-app-message.js";import u from"../../managers/subscription-manager.js";export default class InAppMessageButton{constructor(s,t,i,r,e,h,n){this.text=s||"",this.backgroundColor=t||InAppMessage.ci.hi,this.textColor=i||InAppMessage.ci.mi,this.borderColor=r||this.backgroundColor,this.clickAction=e||InAppMessage.ClickAction.NONE,this.uri=h,null==n&&(n=InAppMessageButton.Ue),this.id=n,this.nl=!1,this.lt=new u}subscribeToClickedEvent(s){return this.lt.Et(s)}removeSubscription(s){this.lt.removeSubscription(s)}removeAllSubscriptions(){this.lt.removeAllSubscriptions()}k(){return!this.nl&&(this.nl=!0,this.lt.Nt(),!0)}static fromJson(s){return new InAppMessageButton(s.text,s.bg_color,s.text_color,s.border_color,s.click_action,s.uri,s.id)}}InAppMessageButton.Ue=-1;
@@ -1 +1 @@
1
- import e,{OPTIONS as D}from"../../managers/braze-instance.js";import et from"../../util/browser-detector.js";import{clickElement as ht,supportsPassive as Et}from"../../util/dom-utils.js";import{KeyCodes as at}from"../../util/key-codes.js";import u from"../../managers/subscription-manager.js";export default class InAppMessage{constructor(t,s,i,e,h,n,r,o,l,E,T,a,m,c,I,A,N,_,L,d,O,S,D,M,R,b,P,C,U){this.message=t,this.messageAlignment=s||InAppMessage.TextAlignment.CENTER,this.duration=E||5e3,this.slideFrom=i||InAppMessage.SlideFrom.BOTTOM,this.extras=e||{},this.triggerId=h,this.clickAction=n||InAppMessage.ClickAction.NONE,this.uri=r,this.openTarget=o||InAppMessage.OpenTarget.NONE,this.dismissType=l||InAppMessage.DismissType.AUTO_DISMISS,this.icon=T,this.imageUrl=a,this.imageStyle=m||InAppMessage.ImageStyle.TOP,this.iconColor=c||InAppMessage.ci.mi,this.iconBackgroundColor=I||InAppMessage.ci.hi,this.backgroundColor=A||InAppMessage.ci.mi,this.textColor=N||InAppMessage.ci.li,this.closeButtonColor=_||InAppMessage.ci.Ei,this.animateIn=L,null==this.animateIn&&(this.animateIn=!0),this.animateOut=d,null==this.animateOut&&(this.animateOut=!0),this.header=O,this.headerAlignment=S||InAppMessage.TextAlignment.CENTER,this.headerTextColor=D||InAppMessage.ci.li,this.frameColor=M||InAppMessage.ci.ui,this.buttons=R||[],this.cropType=b||InAppMessage.CropType.FIT_CENTER,this.orientation=P,this.htmlId=C,this.css=U,this.Ti=!1,this.nl=!1,this.Ii=!1,this.lt=new u,this.Ai=new u}subscribeToClickedEvent(t){return this.lt.Et(t)}subscribeToDismissedEvent(t){return this.Ai.Et(t)}removeSubscription(t){this.lt.removeSubscription(t),this.Ai.removeSubscription(t)}removeAllSubscriptions(){this.lt.removeAllSubscriptions(),this.Ai.removeAllSubscriptions()}closeMessage(){this.on(this.mn)}we(){return!0}ll(){return this.we()}an(){return null!=this.htmlId&&this.htmlId.length>4}sn(){return this.an()&&null!=this.css&&this.css.length>0}rn(){if(this.an()&&this.sn())return this.htmlId+"-css"}R(){return!this.Ti&&(this.Ti=!0,!0)}k(){return!this.nl&&(this.nl=!0,this.lt.Nt(),!0)}J(){return!this.Ii&&(this.Ii=!0,this.Ai.Nt(),!0)}Ni(t){if(t&&t.parentNode){let s=t.closest(".ab-iam-root");if(null==s&&(s=t),this.we()&&null!=s.parentNode){const t=s.parentNode.classList;t&&t.contains(InAppMessage._i)&&t.remove(InAppMessage._i),document.body.removeEventListener("touchmove",InAppMessage.Li)}s.className=s.className.replace(InAppMessage.di,InAppMessage._)}return this.animateOut}on(t,s){if(null==t)return;let i;this.mn=null,i=-1===t.className.indexOf("ab-in-app-message")?t.getElementsByClassName("ab-in-app-message")[0]:t;let e=!1;i&&(e=this.Ni(i));const h=document.body;if(null!=h)var n=h.scrollTop;const r=()=>{if(t&&t.parentNode){let s=t.closest(".ab-iam-root");null==s&&(s=t),s.parentNode&&s.parentNode.removeChild(s)}if(null!=this.rn()){const t=document.getElementById(this.rn());t&&t.parentNode&&t.parentNode.removeChild(t)}null!=h&&"Safari"===et.browser&&(h.scrollTop=n),s?s():this.J()};e?setTimeout(r,InAppMessage.Oi):r(),this.he&&this.he.focus()}Me(){return document.createTextNode(this.message)}xe(t){let s="";this.message||this.header||!this.we()||(s="Modal Image"),t.setAttribute("alt",s)}static Li(t){t.targetTouches&&t.targetTouches.length>1||t.target.classList&&t.target.classList.contains("ab-message-text")&&t.target.scrollHeight>t.target.clientHeight||document.querySelector(`.${InAppMessage._i}`)&&t.preventDefault()}Si(t){this.we()&&null!=t.parentNode&&this.orientation!==InAppMessage.Orientation.LANDSCAPE&&(null!=t.parentNode.classList&&t.parentNode.classList.add(InAppMessage._i),document.body.addEventListener("touchmove",InAppMessage.Li,!!Et()&&{passive:!1})),t.className+=" "+InAppMessage.di}static Di(t){if(t.keyCode===at.Mi&&!e.nn(D.Ri)&&document.querySelectorAll(".ab-modal-interactions").length>0){const t=document.getElementsByClassName("ab-html-message");let s=!1;for(let i=0;i<t.length;i++){const e=t[i].contentWindow.document.getElementsByClassName("ab-programmatic-close-button")[0];null!=e&&(ht(e),s=!0)}if(!s){const t=document.querySelectorAll(".ab-modal-interactions > .ab-close-button")[0];null!=t&&ht(t)}}}bi(){this.Pi||e.nn(D.Ri)||(document.addEventListener("keydown",InAppMessage.Di,!1),e.Ci((()=>{document.removeEventListener("keydown",InAppMessage.Di)})),this.Pi=!0)}}InAppMessage.ci={li:4281545523,mi:4294967295,hi:4278219733,Ui:4293914607,pi:4283782485,ui:3224580915,Ei:4288387995},InAppMessage.Ge={fi:"hd",gi:"ias",Hi:"of",Fi:"do",ri:"umt",Ze:"tf",Bi:"te"},InAppMessage.SlideFrom={TOP:"TOP",BOTTOM:"BOTTOM"},InAppMessage.ClickAction={NEWS_FEED:"NEWS_FEED",URI:"URI",NONE:"NONE"},InAppMessage.DismissType={AUTO_DISMISS:"AUTO_DISMISS",MANUAL:"SWIPE"},InAppMessage.OpenTarget={NONE:"NONE",BLANK:"BLANK"},InAppMessage.ImageStyle={TOP:"TOP",GRAPHIC:"GRAPHIC"},InAppMessage.Orientation={PORTRAIT:"PORTRAIT",LANDSCAPE:"LANDSCAPE"},InAppMessage.TextAlignment={START:"START",CENTER:"CENTER",END:"END"},InAppMessage.CropType={CENTER_CROP:"CENTER_CROP",FIT_CENTER:"FIT_CENTER"},InAppMessage.es={vi:"SLIDEUP",Gi:"MODAL",ye:"MODAL_STYLED",Tr:"FULL",el:"WEB_HTML",cn:"HTML"},InAppMessage.Oi=500,InAppMessage.Wi=200,InAppMessage.di="ab-show",InAppMessage.ki="ab-hide",InAppMessage._i="ab-pause-scrolling";
1
+ import e,{OPTIONS as D}from"../../managers/braze-instance.js";import et from"../../util/browser-detector.js";import{clickElement as ht,supportsPassive as Et}from"../../util/dom-utils.js";import{KeyCodes as at}from"../../util/key-codes.js";import u from"../../managers/subscription-manager.js";export default class InAppMessage{constructor(t,s,i,e,h,n,r,o,l,E,T,a,m,c,I,A,N,_,L,d,O,S,D,M,R,b,P,C,U){this.message=t,this.messageAlignment=s||InAppMessage.TextAlignment.CENTER,this.duration=E||5e3,this.slideFrom=i||InAppMessage.SlideFrom.BOTTOM,this.extras=e||{},this.triggerId=h,this.clickAction=n||InAppMessage.ClickAction.NONE,this.uri=r,this.openTarget=o||InAppMessage.OpenTarget.NONE,this.dismissType=l||InAppMessage.DismissType.AUTO_DISMISS,this.icon=T,this.imageUrl=a,this.imageStyle=m||InAppMessage.ImageStyle.TOP,this.iconColor=c||InAppMessage.ci.mi,this.iconBackgroundColor=I||InAppMessage.ci.hi,this.backgroundColor=A||InAppMessage.ci.mi,this.textColor=N||InAppMessage.ci.Ei,this.closeButtonColor=_||InAppMessage.ci.ui,this.animateIn=L,null==this.animateIn&&(this.animateIn=!0),this.animateOut=d,null==this.animateOut&&(this.animateOut=!0),this.header=O,this.headerAlignment=S||InAppMessage.TextAlignment.CENTER,this.headerTextColor=D||InAppMessage.ci.Ei,this.frameColor=M||InAppMessage.ci.Ti,this.buttons=R||[],this.cropType=b||InAppMessage.CropType.FIT_CENTER,this.orientation=P,this.htmlId=C,this.css=U,this.Ii=!1,this.nl=!1,this.Ai=!1,this.lt=new u,this.Ni=new u}subscribeToClickedEvent(t){return this.lt.Et(t)}subscribeToDismissedEvent(t){return this.Ni.Et(t)}removeSubscription(t){this.lt.removeSubscription(t),this.Ni.removeSubscription(t)}removeAllSubscriptions(){this.lt.removeAllSubscriptions(),this.Ni.removeAllSubscriptions()}closeMessage(){this.on(this.mn)}we(){return!0}ll(){return this.we()}an(){return null!=this.htmlId&&this.htmlId.length>4}sn(){return this.an()&&null!=this.css&&this.css.length>0}rn(){if(this.an()&&this.sn())return this.htmlId+"-css"}R(){return!this.Ii&&(this.Ii=!0,!0)}k(){return!this.nl&&(this.nl=!0,this.lt.Nt(),!0)}J(){return!this.Ai&&(this.Ai=!0,this.Ni.Nt(),!0)}_i(t){if(t&&t.parentNode){let s=t.closest(".ab-iam-root");if(null==s&&(s=t),this.we()&&null!=s.parentNode){const t=s.parentNode.classList;t&&t.contains(InAppMessage.Li)&&t.remove(InAppMessage.Li),document.body.removeEventListener("touchmove",InAppMessage.di)}s.className=s.className.replace(InAppMessage.Oi,InAppMessage._)}return this.animateOut}on(t,s){if(null==t)return;let i;this.mn=null,i=-1===t.className.indexOf("ab-in-app-message")?t.getElementsByClassName("ab-in-app-message")[0]:t;let e=!1;i&&(e=this._i(i));const h=document.body;if(null!=h)var n=h.scrollTop;const r=()=>{if(t&&t.parentNode){let s=t.closest(".ab-iam-root");null==s&&(s=t),s.parentNode&&s.parentNode.removeChild(s)}if(null!=this.rn()){const t=document.getElementById(this.rn());t&&t.parentNode&&t.parentNode.removeChild(t)}null!=h&&"Safari"===et.browser&&(h.scrollTop=n),s?s():this.J()};e?setTimeout(r,InAppMessage.Si):r(),this.he&&this.he.focus()}Me(){return document.createTextNode(this.message)}xe(t){let s="";this.message||this.header||!this.we()||(s="Modal Image"),t.setAttribute("alt",s)}static di(t){t.targetTouches&&t.targetTouches.length>1||t.target.classList&&t.target.classList.contains("ab-message-text")&&t.target.scrollHeight>t.target.clientHeight||document.querySelector(`.${InAppMessage.Li}`)&&t.preventDefault()}Di(t){this.we()&&null!=t.parentNode&&this.orientation!==InAppMessage.Orientation.LANDSCAPE&&(null!=t.parentNode.classList&&t.parentNode.classList.add(InAppMessage.Li),document.body.addEventListener("touchmove",InAppMessage.di,!!Et()&&{passive:!1})),t.className+=" "+InAppMessage.Oi}static Mi(t){if(t.keyCode===at.Ri&&!e.nn(D.bi)&&document.querySelectorAll(".ab-modal-interactions").length>0){const t=document.getElementsByClassName("ab-html-message");let s=!1;for(let i=0;i<t.length;i++){const e=t[i].contentWindow.document.getElementsByClassName("ab-programmatic-close-button")[0];null!=e&&(ht(e),s=!0)}if(!s){const t=document.querySelectorAll(".ab-modal-interactions > .ab-close-button")[0];null!=t&&ht(t)}}}Pi(){this.Ci||e.nn(D.bi)||(document.addEventListener("keydown",InAppMessage.Mi,!1),e.Ui((()=>{document.removeEventListener("keydown",InAppMessage.Mi)})),this.Ci=!0)}}InAppMessage.ci={Ei:4281545523,mi:4294967295,hi:4278219733,pi:4293914607,fi:4283782485,Ti:3224580915,ui:4288387995},InAppMessage.Oe={gi:"hd",Hi:"ias",Fi:"of",Bi:"do",ni:"umt",ei:"tf",vi:"te"},InAppMessage.SlideFrom={TOP:"TOP",BOTTOM:"BOTTOM"},InAppMessage.ClickAction={NEWS_FEED:"NEWS_FEED",URI:"URI",NONE:"NONE"},InAppMessage.DismissType={AUTO_DISMISS:"AUTO_DISMISS",MANUAL:"SWIPE"},InAppMessage.OpenTarget={NONE:"NONE",BLANK:"BLANK"},InAppMessage.ImageStyle={TOP:"TOP",GRAPHIC:"GRAPHIC"},InAppMessage.Orientation={PORTRAIT:"PORTRAIT",LANDSCAPE:"LANDSCAPE"},InAppMessage.TextAlignment={START:"START",CENTER:"CENTER",END:"END"},InAppMessage.CropType={CENTER_CROP:"CENTER_CROP",FIT_CENTER:"FIT_CENTER"},InAppMessage.es={Gi:"SLIDEUP",Wi:"MODAL",ye:"MODAL_STYLED",Tr:"FULL",el:"WEB_HTML",cn:"HTML"},InAppMessage.Si=500,InAppMessage.ki=200,InAppMessage.Oi="ab-show",InAppMessage.wi="ab-hide",InAppMessage.Li="ab-pause-scrolling";
@@ -1 +1 @@
1
- import InAppMessage from"./in-app-message.js";export default class ModalMessage extends InAppMessage{constructor(e,t,r,s,n,l,o,u,a,p,d,i,m,c,f,g,x,j,v,A,T,b,h,k,q,w,y){super(e,t,null,r,s,n,l,o,u=u||InAppMessage.DismissType.MANUAL,a,p,d,i,m,c,f,g,x,j,v,A,T,b,h,k,q=q||InAppMessage.CropType.FIT_CENTER,void 0,w,y)}get ke(){return InAppMessage.TextAlignment.CENTER}}ModalMessage.es=InAppMessage.es.Gi;
1
+ import InAppMessage from"./in-app-message.js";export default class ModalMessage extends InAppMessage{constructor(e,t,r,s,n,l,o,u,a,p,d,i,m,c,f,g,x,j,v,A,T,b,h,k,q,w,y){super(e,t,null,r,s,n,l,o,u=u||InAppMessage.DismissType.MANUAL,a,p,d,i,m,c,f,g,x,j,v,A,T,b,h,k,q=q||InAppMessage.CropType.FIT_CENTER,void 0,w,y)}get ke(){return InAppMessage.TextAlignment.CENTER}}ModalMessage.es=InAppMessage.es.Wi;
@@ -1 +1 @@
1
- import InAppMessage from"./in-app-message.js";import{DOMUtils as dt}from"../../util/dom-utils.js";export default class SlideUpMessage extends InAppMessage{constructor(t,e,o,s,n,i,r,d,u,a,p,l,m,c,v,x,g,f,h,I,M){x=x||InAppMessage.ci.pi,v=v||InAppMessage.ci.Ui,super(t,e=e||InAppMessage.TextAlignment.START,o,s,n,i,r,d,u,a,p,l,null,m,c,v,x,g,f,h,void 0,void 0,void 0,void 0,void 0,void 0,void 0,I,M)}we(){return!1}get ke(){return InAppMessage.TextAlignment.START}Me(){const t=document.createElement("span");return t.appendChild(document.createTextNode(this.message)),t}Si(t){const e=t.getElementsByClassName("ab-in-app-message")[0];dt.eo(e,!0,!0)||(this.slideFrom===InAppMessage.SlideFrom.TOP?e.style.top="0px":e.style.bottom="0px"),super.Si(t)}}SlideUpMessage.es=InAppMessage.es.vi;
1
+ import InAppMessage from"./in-app-message.js";import{DOMUtils as dt}from"../../util/dom-utils.js";export default class SlideUpMessage extends InAppMessage{constructor(t,e,o,s,n,i,r,d,u,a,p,l,m,c,v,x,g,f,h,I,M){x=x||InAppMessage.ci.fi,v=v||InAppMessage.ci.pi,super(t,e=e||InAppMessage.TextAlignment.START,o,s,n,i,r,d,u,a,p,l,null,m,c,v,x,g,f,h,void 0,void 0,void 0,void 0,void 0,void 0,void 0,I,M)}we(){return!1}get ke(){return InAppMessage.TextAlignment.START}Me(){const t=document.createElement("span");return t.appendChild(document.createTextNode(this.message)),t}Di(t){const e=t.getElementsByClassName("ab-in-app-message")[0];dt.eo(e,!0,!0)||(this.slideFrom===InAppMessage.SlideFrom.TOP?e.style.top="0px":e.style.bottom="0px"),super.Di(t)}}SlideUpMessage.es=InAppMessage.es.Gi;
@@ -1 +1 @@
1
- export default class ft{constructor(t,s,l,n,i){this.triggerId=t,this.ni=s,this.si=l,this.oi=n,this.ai=i}static fromJson(t,s,l,n,i){return null==t||null==t.trigger_id?null:new ft(t.trigger_id,s,l,n,i)}}
1
+ export default class ft{constructor(t,s,l,n,i){this.triggerId=t,this.oi=s,this.si=l,this.ai=n,this.li=i}static fromJson(t,s,l,n,i){return null==t||null==t.trigger_id?null:new ft(t.trigger_id,s,l,n,i)}}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import pe from"./in-app-message-manager-factory.js";export function subscribeToInAppMessage(n){if(e.rr())return"function"!=typeof n?null:pe.m()._e((function(r){return n(r[0]),r.slice(1)}))}
1
+ import e from"../managers/braze-instance.js";import pe from"./in-app-message-manager-factory.js";export function subscribeToInAppMessage(n){if(e.rr())return"function"!=typeof n?null:pe.m().Ee((function(r){return n(r[0]),r.slice(1)}))}
@@ -1 +1 @@
1
- import pe from"../in-app-message-manager-factory.js";import e from"../../managers/braze-instance.js";import{setupInAppMessageUI as ss}from"../../ui/js/index.js";import{showInAppMessage}from"./show-in-app-message.js";import{subscribeToInAppMessage}from"../subscribe-to-in-app-message.js";export function automaticallyShowInAppMessages(){if(!e.rr())return;ss();const s=pe.m();if(null==s.Se()){const r=subscribeToInAppMessage((s=>showInAppMessage(s)));s.Ee(r)}return s.Se()}
1
+ import pe from"../in-app-message-manager-factory.js";import e from"../../managers/braze-instance.js";import{setupInAppMessageUI as ss}from"../../ui/js/index.js";import{showInAppMessage}from"./show-in-app-message.js";import{subscribeToInAppMessage}from"../subscribe-to-in-app-message.js";export function automaticallyShowInAppMessages(){if(!e.rr())return;ss();const s=pe.m();if(null==s.Fe()){const r=subscribeToInAppMessage((s=>showInAppMessage(s)));s.Ne(r)}return s.Fe()}
@@ -1 +1 @@
1
- import e,{OPTIONS as D}from"../../managers/braze-instance.js";import ControlMessage from"../models/control-message.js";import HtmlMessage from"../models/html-message.js";import InAppMessage from"../models/in-app-message.js";import SlideUpMessage from"../models/slide-up-message.js";import pe from"../in-app-message-manager-factory.js";import se from"../display/get-animation-effect.js";import ce from"../display/in-app-message-to-html.js";import{logInAppMessageImpression}from"../log-in-app-message-impression.js";import{ORIENTATION as le,WindowUtils as G}from"../../util/window-utils.js";import{isURIJavascriptOrData as j}from"../../util/url-utils.js";import{KeyCodes as at}from"../../util/key-codes.js";import{setupInAppMessageUI as ss}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";import{toRgba as ne}from"../../util/color-utils.js";export function showInAppMessage(t,s,o){if(!e.rr())return;if(ss(),null==t)return!1;if(t instanceof ControlMessage)return r.D.info("User received control for a multivariate test, logging to Braze servers."),logInAppMessageImpression(t),!0;if(!(t instanceof InAppMessage))return!1;const i=pe.m();t.bi();const n=t instanceof HtmlMessage;if(n&&!t.trusted&&!e.tr())return r.D.error('HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.'),i.Fe(t.triggerId,InAppMessage.Ge.fi),!1;if(null==s&&(s=document.body),t.we()){if(s.querySelectorAll(".ab-modal-interactions").length>0)return r.D.info(`Cannot show in-app message ${t.message} because another message is being shown.`),i.Fe(t.triggerId,InAppMessage.Ge.gi),!1}if(G.so()){const e=G.io();if(e===le.PORTRAIT&&t.orientation===InAppMessage.Orientation.LANDSCAPE||e===le.LANDSCAPE&&t.orientation===InAppMessage.Orientation.PORTRAIT){const s=e===le.PORTRAIT?"portrait":"landscape",o=t.orientation===InAppMessage.Orientation.PORTRAIT?"portrait":"landscape";return r.D.info(`Not showing ${o} in-app message ${t.message} because the screen is currently ${s}`),i.Fe(t.triggerId,InAppMessage.Ge.Hi),!1}}if(!e.tr()){let e=!1;if(t.buttons&&t.buttons.length>0){const s=t.buttons;for(let t=0;t<s.length;t++)if(s[t].clickAction===InAppMessage.ClickAction.URI){const o=s[t].uri;e=j(o)}}else t.clickAction===InAppMessage.ClickAction.URI&&(e=j(t.uri));if(e)return r.D.error('Javascript click actions are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these actions.'),i.Fe(t.triggerId,InAppMessage.Ge.fi),!1}const a=document.createElement("div");if(a.className="ab-iam-root v3",a.className+=se(t),a.setAttribute("role","complementary"),t.an()&&(a.id=t.htmlId),e.nn(D.no)&&(a.style.zIndex=e.nn(D.no)+1),s.appendChild(a),t.sn()){const s=document.createElement("style");s.innerHTML=t.css,s.id=t.rn(),null!=e.nn(D.ao)&&s.setAttribute("nonce",e.nn(D.ao)),document.getElementsByTagName("head")[0].appendChild(s)}const l=t instanceof SlideUpMessage,m=ce(t,(()=>{import("../../Feed/ui/show-feed.js").then((e=>e.showFeed()))}),(s=>{if(t.we()&&t.ll()){const o=document.createElement("div");if(o.className="ab-page-blocker",t.sn()||(o.style.backgroundColor=ne(t.frameColor)),e.nn(D.no)&&(o.style.zIndex=e.nn(D.no)),a.appendChild(o),!e.nn(D.Ri)){const e=(new Date).valueOf();o.onclick=o=>{(new Date).valueOf()-e>InAppMessage.Wi&&(t.on(s),o.stopPropagation())}}a.appendChild(s),s.focus(),t.Si(a)}else if(l){const e=document.querySelectorAll(".ab-slideup");let o=null;for(let t=e.length-1;t>=0;t--)if(e[t]!==s){o=e[t];break}if(t.slideFrom===InAppMessage.SlideFrom.TOP){let e=0;null!=o&&(e=o.offsetTop+o.offsetHeight),s.style.top=Math.max(e,0)+"px"}else{let e=0;null!=o&&(e=(window.innerHeight||document.documentElement.clientHeight)-o.offsetTop),s.style.bottom=Math.max(e,0)+"px"}}else if(n&&!e.nn(D.Ri)){const e=t;s.contentWindow.addEventListener("keydown",(function(t){t.keyCode===at.Mi&&e.closeMessage()}))}logInAppMessageImpression(t),t.dismissType===InAppMessage.DismissType.AUTO_DISMISS&&setTimeout((()=>{a.contains(s)&&t.on(s)}),t.duration),"function"==typeof o&&o()}),e.nn(D.lo),e.nn(D.no),e.nn(D.ao));return(n||l)&&(a.appendChild(m),t.Si(a)),!0}
1
+ import e,{OPTIONS as D}from"../../managers/braze-instance.js";import ControlMessage from"../models/control-message.js";import HtmlMessage from"../models/html-message.js";import InAppMessage from"../models/in-app-message.js";import SlideUpMessage from"../models/slide-up-message.js";import pe from"../in-app-message-manager-factory.js";import se from"../display/get-animation-effect.js";import ce from"../display/in-app-message-to-html.js";import{logInAppMessageImpression}from"../log-in-app-message-impression.js";import{ORIENTATION as le,WindowUtils as G}from"../../util/window-utils.js";import{isURIJavascriptOrData as j}from"../../util/url-utils.js";import{KeyCodes as at}from"../../util/key-codes.js";import{setupInAppMessageUI as ss}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";import{toRgba as ne}from"../../util/color-utils.js";export function showInAppMessage(t,s,o){if(!e.rr())return;if(ss(),null==t)return!1;if(t instanceof ControlMessage)return r.D.info("User received control for a multivariate test, logging to Braze servers."),logInAppMessageImpression(t),!0;if(!(t instanceof InAppMessage))return!1;const i=pe.m();t.Pi();const n=t instanceof HtmlMessage;if(n&&!t.trusted&&!e.tr())return r.D.error('HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.'),i.qe(t.triggerId,InAppMessage.Oe.gi),!1;if(null==s&&(s=document.body),t.we()){if(s.querySelectorAll(".ab-modal-interactions").length>0)return r.D.info(`Cannot show in-app message ${t.message} because another message is being shown.`),i.qe(t.triggerId,InAppMessage.Oe.Hi),!1}if(G.so()){const e=G.io();if(e===le.PORTRAIT&&t.orientation===InAppMessage.Orientation.LANDSCAPE||e===le.LANDSCAPE&&t.orientation===InAppMessage.Orientation.PORTRAIT){const s=e===le.PORTRAIT?"portrait":"landscape",o=t.orientation===InAppMessage.Orientation.PORTRAIT?"portrait":"landscape";return r.D.info(`Not showing ${o} in-app message ${t.message} because the screen is currently ${s}`),i.qe(t.triggerId,InAppMessage.Oe.Fi),!1}}if(!e.tr()){let e=!1;if(t.buttons&&t.buttons.length>0){const s=t.buttons;for(let t=0;t<s.length;t++)if(s[t].clickAction===InAppMessage.ClickAction.URI){const o=s[t].uri;e=j(o)}}else t.clickAction===InAppMessage.ClickAction.URI&&(e=j(t.uri));if(e)return r.D.error('Javascript click actions are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these actions.'),i.qe(t.triggerId,InAppMessage.Oe.gi),!1}const a=document.createElement("div");if(a.className="ab-iam-root v3",a.className+=se(t),a.setAttribute("role","complementary"),t.an()&&(a.id=t.htmlId),e.nn(D.no)&&(a.style.zIndex=e.nn(D.no)+1),s.appendChild(a),t.sn()){const s=document.createElement("style");s.innerHTML=t.css,s.id=t.rn(),null!=e.nn(D.ao)&&s.setAttribute("nonce",e.nn(D.ao)),document.getElementsByTagName("head")[0].appendChild(s)}const l=t instanceof SlideUpMessage,m=ce(t,(()=>{import("../../Feed/ui/show-feed.js").then((e=>e.showFeed()))}),(s=>{if(t.we()&&t.ll()){const o=document.createElement("div");if(o.className="ab-page-blocker",t.sn()||(o.style.backgroundColor=ne(t.frameColor)),e.nn(D.no)&&(o.style.zIndex=e.nn(D.no)),a.appendChild(o),!e.nn(D.bi)){const e=(new Date).valueOf();o.onclick=o=>{(new Date).valueOf()-e>InAppMessage.ki&&(t.on(s),o.stopPropagation())}}a.appendChild(s),s.focus(),t.Di(a)}else if(l){const e=document.querySelectorAll(".ab-slideup");let o=null;for(let t=e.length-1;t>=0;t--)if(e[t]!==s){o=e[t];break}if(t.slideFrom===InAppMessage.SlideFrom.TOP){let e=0;null!=o&&(e=o.offsetTop+o.offsetHeight),s.style.top=Math.max(e,0)+"px"}else{let e=0;null!=o&&(e=(window.innerHeight||document.documentElement.clientHeight)-o.offsetTop),s.style.bottom=Math.max(e,0)+"px"}}else if(n&&!e.nn(D.bi)){const e=t;s.contentWindow.addEventListener("keydown",(function(t){t.keyCode===at.Ri&&e.closeMessage()}))}logInAppMessageImpression(t),t.dismissType===InAppMessage.DismissType.AUTO_DISMISS&&setTimeout((()=>{a.contains(s)&&t.on(s)}),t.duration),"function"==typeof o&&o()}),e.nn(D.lo),e.nn(D.no),e.nn(D.ao));return(n||l)&&(a.appendChild(m),t.Di(a)),!0}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import or from"./push-manager-factory.js";export function isPushBlocked(){if(e.rr())return or.Br().isPushBlocked()}
1
+ import e from"../managers/braze-instance.js";import or from"./push-manager-factory.js";export function isPushBlocked(){if(e.rr())return or.Xe().isPushBlocked()}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import or from"./push-manager-factory.js";export function isPushPermissionGranted(){if(e.rr())return or.Br().isPushPermissionGranted()}
1
+ import e from"../managers/braze-instance.js";import or from"./push-manager-factory.js";export function isPushPermissionGranted(){if(e.rr())return or.Xe().isPushPermissionGranted()}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import or from"./push-manager-factory.js";export function isPushSupported(){if(e.rr())return or.Br().isPushSupported()}
1
+ import e from"../managers/braze-instance.js";import or from"./push-manager-factory.js";export function isPushSupported(){if(e.rr())return or.Xe().isPushSupported()}
@@ -1 +1 @@
1
- import e,{OPTIONS as D}from"../managers/braze-instance.js";import aa from"./push-manager.js";const or={t:!1,pushManager:null,Br:()=>(or.o(),or.pushManager||(or.pushManager=new aa(e.gr(),e.aa(),e.ce(),e.Js(),e.nn(D.ea),e.nn(D.na),e.ir(),e.nn(D.ra),e.nn(D.ta),e.l())),or.pushManager),o:()=>{or.t||(e.u(or),or.t=!0)},destroy:()=>{or.pushManager=null,or.t=!1}};export default or;
1
+ import e,{OPTIONS as D}from"../managers/braze-instance.js";import aa from"./push-manager.js";const or={t:!1,pushManager:null,Xe:()=>(or.o(),or.pushManager||(or.pushManager=new aa(e.gr(),e.aa(),e.ce(),e.Js(),e.nn(D.ea),e.nn(D.na),e.ir(),e.nn(D.ra),e.nn(D.ta),e.l())),or.pushManager),o:()=>{or.t||(e.u(or),or.t=!0)},destroy:()=>{or.pushManager=null,or.t=!1}};export default or;
@@ -1 +1 @@
1
- import{isArray as p,isEqual as ii}from"../util/code-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";import{WindowUtils as G}from"../util/window-utils.js";export default class aa{constructor(i,e,t,s,n,r,o,u,h,a){this.wi=i,this.yi=e,this.ji=t,this.xi=s+"/safari/"+e,this.zi=n||"/service-worker.js",this.Vi=r,this.wt=o,this.qi=u||!1,this.Yi=h||!1,this.h=a,this.Ji="serviceWorker"in navigator&&"undefined"!=typeof ServiceWorkerRegistration&&"showNotification"in ServiceWorkerRegistration.prototype&&"PushManager"in window,this.Ki="safari"in window&&"pushNotification"in window.safari&&"function"==typeof window.safari.pushNotification.permission&&"function"==typeof window.safari.pushNotification.requestPermission}Qi(){return this.Yi}isPushSupported(){return this.Ji||this.Ki}isPushBlocked(){const i=this.isPushSupported()&&"Notification"in window&&null!=window.Notification&&null!=window.Notification.permission&&"denied"===window.Notification.permission,e=this.isPushSupported()&&(!("Notification"in window)||null==window.Notification);return i||e}isPushPermissionGranted(){return this.isPushSupported()&&"Notification"in window&&null!=window.Notification&&null!=window.Notification.permission&&"granted"===window.Notification.permission}Ue(){return!this.isPushBlocked()&&this.isPushSupported()&&!this.isPushPermissionGranted()}Xi(i,e,t,s,n){i.unsubscribe().then((i=>{i?this.Zi(e,t,s,n):(r.D.error("Failed to unsubscribe device from push."),"function"==typeof n&&n(!1))})).catch((i=>{r.D.error("Push unsubscription error: "+i),"function"==typeof n&&n(!1)}))}$i(i,e,t){const s=(i=>{if("string"==typeof i)return i;if(0!==i.endpoint.indexOf("https://android.googleapis.com/gcm/send"))return i.endpoint;let e=i.endpoint;return i.hn&&-1===i.endpoint.indexOf(i.hn)&&(e=i.endpoint+"/"+i.hn),e})(i);let n=null,r=null;if(null!=i.getKey)try{n=btoa(String.fromCharCode.apply(null,new Uint8Array(i.getKey("p256dh")))),r=btoa(String.fromCharCode.apply(null,new Uint8Array(i.getKey("auth"))))}catch(i){if("invalid arguments"!==i.message)throw i}const o=(i=>{let e;return i.options&&(e=i.options.applicationServerKey)&&e.byteLength&&e.byteLength>0?btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_"):null})(i);this.wi.dn(s,t,n,r,o),s&&"function"==typeof e&&e(s,n,r)}fn(){this.wi.pn(!0)}wn(i,e){this.wi.pn(!1),r.D.info(i),"function"==typeof e&&e(!1)}bn(i,e,t,s){if("default"===e.permission)try{window.safari.pushNotification.requestPermission(this.xi,i,{api_key:this.yi,device_id:this.ji.te().id},(e=>{"granted"===e.permission&&this.wi.setPushNotificationSubscriptionType(User.NotificationSubscriptionTypes.OPTED_IN),this.bn(i,e,t,s)}))}catch(i){this.wn("Could not request permission for push: "+i,s)}else"denied"===e.permission?this.wn("The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",s):"granted"===e.permission&&(r.D.info("Device successfully subscribed to push."),this.$i(e.deviceToken,t,new Date))}gn(i,e,t){const s=s=>{switch(s){case"granted":return void("function"==typeof i&&i());case"default":return void("function"==typeof e&&e());case"denied":return void("function"==typeof t&&t());default:r.D.error("Received unexpected permission result "+s)}};let n=!1;const o=window.Notification.requestPermission((i=>{n&&s(i)}));o?o.then((i=>{s(i)})):n=!0}Zi(i,e,t,s){const n={userVisibleOnly:!0};null!=e&&(n.applicationServerKey=e),i.pushManager.subscribe(n).then((i=>{r.D.info("Device successfully subscribed to push."),this.$i(i,t,new Date)})).catch((i=>{this.isPushBlocked()?(r.D.info("Permission for push notifications was denied."),"function"==typeof s&&s(!1)):r.D.error("Push subscription failed: "+i)}))}yn(){return this.qi?navigator.serviceWorker.getRegistration():navigator.serviceWorker.register(this.zi).then((()=>navigator.serviceWorker.ready.then((i=>(i&&"function"==typeof i.update&&i.update().catch((i=>{r.D.info("ServiceWorker update failed: "+i)})),i)))))}vn(i){this.qi||(i.unregister(),r.D.info("Service worker successfully unregistered."))}subscribe(i,e){if(this.isPushSupported()){if(this.Ji){if(!this.qi&&null!=window.location){let i=this.zi;-1===i.indexOf(window.location.host)&&(i=window.location.host+i),-1===i.indexOf(window.location.protocol)&&(i=window.location.protocol+"//"+i);const e=i.substr(0,i.lastIndexOf("/")+1);if(0!==G.Pn().indexOf(e))return void r.D.error("Cannot subscribe to push from a path higher than the service worker location (tried to subscribe from "+window.location.pathname+" but service worker is at "+i+")")}if(this.isPushBlocked())return void this.wn("Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",e);if(this.wt&&!this.wt.kn()&&0===this.wt.Gs())return r.D.info("Waiting for VAPID key from server config before subscribing to push."),void this.wt.Sn((()=>{this.subscribe(i,e)}));const t=()=>{r.D.info("Permission for push notifications was denied."),"function"==typeof e&&e(!1)},s=()=>{let i="Permission for push notifications was ignored.";this.isPushBlocked()&&(i+=" The browser has automatically blocked further permission requests for a period (probably 1 week)."),r.D.info(i),"function"==typeof e&&e(!0)},n=this.isPushPermissionGranted(),u=()=>{n||this.wi.setPushNotificationSubscriptionType(User.NotificationSubscriptionTypes.OPTED_IN),this.yn().then((t=>{if(null==t)return r.D.error("No service worker registration. Set the `manageServiceWorkerExternally` initialization option to false or ensure that your service worker is registered before calling registerPush."),void("function"==typeof e&&e());t.pushManager.getSubscription().then((s=>{let n=null;if(this.wt&&null!=this.wt.kn()&&(n=r._n.Dn(this.wt.kn())),s){let u=null,h=null;const a=this.h.I(o.q.Nn);if(a&&!p(a)){let i;try{i=ei.An(a).Wn}catch(e){i=null}null==i||isNaN(i.getTime())||0===i.getTime()||(u=i,h=new Date(u),h.setMonth(u.getMonth()+6))}null!=n&&s.options&&s.options.applicationServerKey&&s.options.applicationServerKey.byteLength&&s.options.applicationServerKey.byteLength>0&&!ii(n,new Uint8Array(s.options.applicationServerKey))?(s.options.applicationServerKey.byteLength>12?r.D.info("Device was already subscribed to push using a different VAPID provider, creating new subscription."):r.D.info("Attempting to upgrade a gcm_sender_id-based push registration to VAPID - depending on the browser this may or may not result in the same gcm_sender_id-based subscription."),this.Xi(s,t,n,i,e)):s.expirationTime&&new Date(s.expirationTime)<=(new Date).valueOf()?(r.D.info("Push subscription is expired, creating new subscription."),this.Xi(s,t,n,i,e)):a&&p(a)?this.Xi(s,t,n,i,e):null==h?(r.D.info("No push subscription creation date found, creating new subscription."),this.Xi(s,t,n,i,e)):h<=(new Date).valueOf()?(r.D.info("Push subscription older than 6 months, creating new subscription."),this.Xi(s,t,n,i,e)):(r.D.info("Device already subscribed to push, sending existing subscription to backend."),this.$i(s,i,u))}else this.Zi(t,n,i,e)})).catch((i=>{r.D.error("Error checking current push subscriptions: "+i)}))})).catch((i=>{r.D.error("ServiceWorker registration failed: "+i)}))};this.gn(u,s,t)}else if(this.Ki){if(null==this.Vi||""===this.Vi)return void r.D.error("You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari");const t=window.safari.pushNotification.permission(this.Vi);this.bn(this.Vi,t,i,e)}}else r.D.info(this.jn)}unsubscribe(i,e){this.isPushSupported()?this.Ji?navigator.serviceWorker.getRegistration().then((t=>{t&&t.pushManager.getSubscription().then((s=>{s&&(this.fn(),s.unsubscribe().then((s=>{s?(r.D.info("Device successfully unsubscribed from push."),"function"==typeof i&&i()):(r.D.error("Failed to unsubscribe device from push."),"function"==typeof e&&e()),this.vn(t)})).catch((i=>{r.D.error("Push unsubscription error: "+i),"function"==typeof e&&e()})))})).catch((i=>{r.D.error("Error unsubscribing from push: "+i),"function"==typeof e&&e()}))})):this.Ki&&(this.fn(),r.D.info("Device unsubscribed from push."),"function"==typeof i&&i()):r.D.info(this.jn)}}aa.jn="Push notifications are not supported in this browser.";
1
+ import{isArray as p,isEqual as ii}from"../util/code-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";import{WindowUtils as G}from"../util/window-utils.js";export default class aa{constructor(i,e,t,s,n,r,o,u,h,a){this.yi=i,this.ji=e,this.xi=t,this.zi=s+"/safari/"+e,this.Vi=n||"/service-worker.js",this.qi=r,this.wt=o,this.Yi=u||!1,this.Ji=h||!1,this.h=a,this.Ki="serviceWorker"in navigator&&"undefined"!=typeof ServiceWorkerRegistration&&"showNotification"in ServiceWorkerRegistration.prototype&&"PushManager"in window,this.Qi="safari"in window&&"pushNotification"in window.safari&&"function"==typeof window.safari.pushNotification.permission&&"function"==typeof window.safari.pushNotification.requestPermission}Xi(){return this.Ji}isPushSupported(){return this.Ki||this.Qi}isPushBlocked(){const i=this.isPushSupported()&&"Notification"in window&&null!=window.Notification&&null!=window.Notification.permission&&"denied"===window.Notification.permission,e=this.isPushSupported()&&(!("Notification"in window)||null==window.Notification);return i||e}isPushPermissionGranted(){return this.isPushSupported()&&"Notification"in window&&null!=window.Notification&&null!=window.Notification.permission&&"granted"===window.Notification.permission}Ye(){return!this.isPushBlocked()&&this.isPushSupported()&&!this.isPushPermissionGranted()}Zi(i,e,t,s,n){i.unsubscribe().then((i=>{i?this.$i(e,t,s,n):(r.D.error("Failed to unsubscribe device from push."),"function"==typeof n&&n(!1))})).catch((i=>{r.D.error("Push unsubscription error: "+i),"function"==typeof n&&n(!1)}))}hn(i,e,t){const s=(i=>{if("string"==typeof i)return i;if(0!==i.endpoint.indexOf("https://android.googleapis.com/gcm/send"))return i.endpoint;let e=i.endpoint;return i.dn&&-1===i.endpoint.indexOf(i.dn)&&(e=i.endpoint+"/"+i.dn),e})(i);let n=null,r=null;if(null!=i.getKey)try{n=btoa(String.fromCharCode.apply(null,new Uint8Array(i.getKey("p256dh")))),r=btoa(String.fromCharCode.apply(null,new Uint8Array(i.getKey("auth"))))}catch(i){if("invalid arguments"!==i.message)throw i}const o=(i=>{let e;return i.options&&(e=i.options.applicationServerKey)&&e.byteLength&&e.byteLength>0?btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_"):null})(i);this.yi.fn(s,t,n,r,o),s&&"function"==typeof e&&e(s,n,r)}pn(){this.yi.wn(!0)}bn(i,e){this.yi.wn(!1),r.D.info(i),"function"==typeof e&&e(!1)}gn(i,e,t,s){if("default"===e.permission)try{window.safari.pushNotification.requestPermission(this.zi,i,{api_key:this.ji,device_id:this.xi.te().id},(e=>{"granted"===e.permission&&this.yi.setPushNotificationSubscriptionType(User.NotificationSubscriptionTypes.OPTED_IN),this.gn(i,e,t,s)}))}catch(i){this.bn("Could not request permission for push: "+i,s)}else"denied"===e.permission?this.bn("The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",s):"granted"===e.permission&&(r.D.info("Device successfully subscribed to push."),this.hn(e.deviceToken,t,new Date))}yn(i,e,t){const s=s=>{switch(s){case"granted":return void("function"==typeof i&&i());case"default":return void("function"==typeof e&&e());case"denied":return void("function"==typeof t&&t());default:r.D.error("Received unexpected permission result "+s)}};let n=!1;const o=window.Notification.requestPermission((i=>{n&&s(i)}));o?o.then((i=>{s(i)})):n=!0}$i(i,e,t,s){const n={userVisibleOnly:!0};null!=e&&(n.applicationServerKey=e),i.pushManager.subscribe(n).then((i=>{r.D.info("Device successfully subscribed to push."),this.hn(i,t,new Date)})).catch((i=>{this.isPushBlocked()?(r.D.info("Permission for push notifications was denied."),"function"==typeof s&&s(!1)):r.D.error("Push subscription failed: "+i)}))}vn(){return this.Yi?navigator.serviceWorker.getRegistration():navigator.serviceWorker.register(this.Vi).then((()=>navigator.serviceWorker.ready.then((i=>(i&&"function"==typeof i.update&&i.update().catch((i=>{r.D.info("ServiceWorker update failed: "+i)})),i)))))}Pn(i){this.Yi||(i.unregister(),r.D.info("Service worker successfully unregistered."))}subscribe(i,e){if(this.isPushSupported()){if(this.Ki){if(!this.Yi&&null!=window.location){let i=this.Vi;-1===i.indexOf(window.location.host)&&(i=window.location.host+i),-1===i.indexOf(window.location.protocol)&&(i=window.location.protocol+"//"+i);const e=i.substr(0,i.lastIndexOf("/")+1);if(0!==G.kn().indexOf(e))return void r.D.error("Cannot subscribe to push from a path higher than the service worker location (tried to subscribe from "+window.location.pathname+" but service worker is at "+i+")")}if(this.isPushBlocked())return void this.bn("Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",e);if(this.wt&&!this.wt.Sn()&&0===this.wt.Gs())return r.D.info("Waiting for VAPID key from server config before subscribing to push."),void this.wt.Dn((()=>{this.subscribe(i,e)}));const t=()=>{r.D.info("Permission for push notifications was denied."),"function"==typeof e&&e(!1)},s=()=>{let i="Permission for push notifications was ignored.";this.isPushBlocked()&&(i+=" The browser has automatically blocked further permission requests for a period (probably 1 week)."),r.D.info(i),"function"==typeof e&&e(!0)},n=this.isPushPermissionGranted(),u=()=>{n||this.yi.setPushNotificationSubscriptionType(User.NotificationSubscriptionTypes.OPTED_IN),this.vn().then((t=>{if(null==t)return r.D.error("No service worker registration. Set the `manageServiceWorkerExternally` initialization option to false or ensure that your service worker is registered before calling registerPush."),void("function"==typeof e&&e());t.pushManager.getSubscription().then((s=>{let n=null;if(this.wt&&null!=this.wt.Sn()&&(n=r.Nn._n(this.wt.Sn())),s){let u=null,h=null;const a=this.h.I(o.q.Wn);if(a&&!p(a)){let i;try{i=ei.jn(a).An}catch(e){i=null}null==i||isNaN(i.getTime())||0===i.getTime()||(u=i,h=new Date(u),h.setMonth(u.getMonth()+6))}null!=n&&s.options&&s.options.applicationServerKey&&s.options.applicationServerKey.byteLength&&s.options.applicationServerKey.byteLength>0&&!ii(n,new Uint8Array(s.options.applicationServerKey))?(s.options.applicationServerKey.byteLength>12?r.D.info("Device was already subscribed to push using a different VAPID provider, creating new subscription."):r.D.info("Attempting to upgrade a gcm_sender_id-based push registration to VAPID - depending on the browser this may or may not result in the same gcm_sender_id-based subscription."),this.Zi(s,t,n,i,e)):s.expirationTime&&new Date(s.expirationTime)<=(new Date).valueOf()?(r.D.info("Push subscription is expired, creating new subscription."),this.Zi(s,t,n,i,e)):a&&p(a)?this.Zi(s,t,n,i,e):null==h?(r.D.info("No push subscription creation date found, creating new subscription."),this.Zi(s,t,n,i,e)):h<=(new Date).valueOf()?(r.D.info("Push subscription older than 6 months, creating new subscription."),this.Zi(s,t,n,i,e)):(r.D.info("Device already subscribed to push, sending existing subscription to backend."),this.hn(s,i,u))}else this.$i(t,n,i,e)})).catch((i=>{r.D.error("Error checking current push subscriptions: "+i)}))})).catch((i=>{r.D.error("ServiceWorker registration failed: "+i)}))};this.yn(u,s,t)}else if(this.Qi){if(null==this.qi||""===this.qi)return void r.D.error("You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari");const t=window.safari.pushNotification.permission(this.qi);this.gn(this.qi,t,i,e)}}else r.D.info(this.Un)}unsubscribe(i,e){this.isPushSupported()?this.Ki?navigator.serviceWorker.getRegistration().then((t=>{t&&t.pushManager.getSubscription().then((s=>{s&&(this.pn(),s.unsubscribe().then((s=>{s?(r.D.info("Device successfully unsubscribed from push."),"function"==typeof i&&i()):(r.D.error("Failed to unsubscribe device from push."),"function"==typeof e&&e()),this.Pn(t)})).catch((i=>{r.D.error("Push unsubscription error: "+i),"function"==typeof e&&e()})))})).catch((i=>{r.D.error("Error unsubscribing from push: "+i),"function"==typeof e&&e()}))})):this.Qi&&(this.pn(),r.D.info("Device unsubscribed from push."),"function"==typeof i&&i()):r.D.info(this.Un)}}aa.Un="Push notifications are not supported in this browser.";
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import or from"./push-manager-factory.js";export function requestPushPermission(r,n){if(e.rr())return or.Br().subscribe(((n,o,t)=>{e.mr().requestImmediateDataFlush(),"function"==typeof r&&r(n,o,t)}),n)}
1
+ import e from"../managers/braze-instance.js";import or from"./push-manager-factory.js";export function requestPushPermission(r,n){if(e.rr())return or.Xe().subscribe(((n,o,t)=>{e.mr().requestImmediateDataFlush(),"function"==typeof r&&r(n,o,t)}),n)}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import or from"./push-manager-factory.js";export function unregisterPush(r,n){if(e.rr())return or.Br().unsubscribe(r,n)}
1
+ import e from"../managers/braze-instance.js";import or from"./push-manager-factory.js";export function unregisterPush(r,n){if(e.rr())return or.Xe().unsubscribe(r,n)}
@@ -1 +1 @@
1
- import _t from"../models/identifier.js";import{getByteLength as U}from"../util/string-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";export default class bt{constructor(t,s){this.wt=t,this.h=s}getUserId(){const t=this.h._r(o.Cr.Ur);if(null==t)return null;let s=t.Ir,i=U(s);if(i>User.ee){for(;i>User.ee;)s=s.slice(0,s.length-1),i=U(s);t.Ir=s,this.h.Lr(o.Cr.Ur,t)}return s}Er(t){const s=null==this.getUserId();this.h.Lr(o.Cr.Ur,new _t(t)),s&&this.h.Gr(t)}setCustomUserAttribute(t,s){if(this.wt.Hr(t))return r.D.info('Custom Attribute "'+t+'" is blocklisted, ignoring.'),!1;const i={};return i[t]=s,this.Jr(User.Kr,i,!0)}Jr(t,s,i,e){const u=this.h.Mr(this.getUserId(),t,s);return!e&&u&&r.D.info(`Logged${i?" custom":""} attribute ${t} with value ${s}`),u}dn(t,s,i,e,u){this.Jr("push_token",t,!1,!0),this.Jr("custom_push_public_key",i,!1,!0),this.Jr("custom_push_user_auth",e,!1,!0),this.Jr("custom_push_vapid_public_key",u,!1,!0);const h=r.Ft.xt,n=new r.qt(h,r.D),l=new ei(t,s,i,e,u);this.h.B(o.q.Nn,l.ss()),n.setItem(h.Pt.Nr,h.se,!0)}pn(t){if(this.Jr("push_token",null,!1,!0),this.Jr("custom_push_public_key",null,!1,!0),this.Jr("custom_push_user_auth",null,!1,!0),this.Jr("custom_push_vapid_public_key",null,!1,!0),t){const t=r.Ft.xt,s=new r.qt(t,r.D);this.h.B(o.q.Nn,!1),s.setItem(t.Pt.Nr,t.se,!1)}}}
1
+ import _t from"../models/identifier.js";import{getByteLength as U}from"../util/string-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";export default class bt{constructor(t,s){this.wt=t,this.h=s}getUserId(){const t=this.h._r(o.Cr.Ur);if(null==t)return null;let s=t.Ir,i=U(s);if(i>User.ee){for(;i>User.ee;)s=s.slice(0,s.length-1),i=U(s);t.Ir=s,this.h.Lr(o.Cr.Ur,t)}return s}Br(t){const s=null==this.getUserId();this.h.Lr(o.Cr.Ur,new _t(t)),s&&this.h.Er(t)}setCustomUserAttribute(t,s){if(this.wt.Gr(t))return r.D.info('Custom Attribute "'+t+'" is blocklisted, ignoring.'),!1;const i={};return i[t]=s,this.Hr(User.Jr,i,!0)}Hr(t,s,i,e){const u=this.h.Kr(this.getUserId(),t,s);return!e&&u&&r.D.info(`Logged${i?" custom":""} attribute ${t} with value ${s}`),u}fn(t,s,i,e,u){this.Hr("push_token",t,!1,!0),this.Hr("custom_push_public_key",i,!1,!0),this.Hr("custom_push_user_auth",e,!1,!0),this.Hr("custom_push_vapid_public_key",u,!1,!0);const h=r.Ft.xt,n=new r.qt(h,r.D),l=new ei(t,s,i,e,u);this.h.B(o.q.Wn,l.ss()),n.setItem(h.Pt.Mr,h.se,!0)}wn(t){if(this.Hr("push_token",null,!1,!0),this.Hr("custom_push_public_key",null,!1,!0),this.Hr("custom_push_user_auth",null,!1,!0),this.Hr("custom_push_vapid_public_key",null,!1,!0),t){const t=r.Ft.xt,s=new r.qt(t,r.D);this.h.B(o.q.Wn,!1),s.setItem(t.Pt.Mr,t.se,!1)}}}
package/src/User/user.js CHANGED
@@ -1 +1 @@
1
- import{isArray as p,isDate as yt,validateValueIsFromEnum as K}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"../util/date-utils.js";import{isValidEmail as vt,validateCustomString as X,validateStandardString as R}from"../util/validation-utils.js";export default class User{constructor(t,e){this.v=t,this.Is=e}getUserId(t){null==t&&r.D.error("getUserId must be supplied with a callback. e.g., braze.getUser().getUserId(function(userId) {console.log('the user id is ' + userId)})"),"function"==typeof t&&t(this.v.getUserId())}addAlias(t,e){return!R(t,"add alias","the alias",!1)||t.length<=0?(r.D.error("addAlias requires a non-empty alias"),!1):!R(e,"add alias","the label",!1)||e.length<=0?(r.D.error("addAlias requires a non-empty label"),!1):this.Is.Sr(t,e).S}setFirstName(t){return!!R(t,"set first name","the firstName",!0)&&this.v.Jr("first_name",t)}setLastName(t){return!!R(t,"set last name","the lastName",!0)&&this.v.Jr("last_name",t)}setEmail(t){return null===t||vt(t)?this.v.Jr("email",t):(r.D.error(`Cannot set email address - "${t}" did not pass RFC-5322 validation.`),!1)}setGender(t){return"string"==typeof t&&(t=t.toLowerCase()),!(null!==t&&!K(User.Genders,t,`Gender "${t}" is not a valid gender.`,"User.Genders"))&&this.v.Jr("gender",t)}setDateOfBirth(t,e,s){return null===t&&null===e&&null===s?this.v.Jr("dob",null):(t=parseInt(t),e=parseInt(e),s=parseInt(s),isNaN(t)||isNaN(e)||isNaN(s)||e>12||e<1||s>31||s<1?(r.D.error("Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);"),!1):this.v.Jr("dob",`${t}-${e}-${s}`))}setCountry(t){return!!R(t,"set country","the country",!0)&&this.v.Jr("country",t)}setHomeCity(t){return!!R(t,"set home city","the homeCity",!0)&&this.v.Jr("home_city",t)}setLanguage(t){return!!R(t,"set language","the language",!0)&&this.v.Jr("language",t)}setEmailNotificationSubscriptionType(t){return!!K(User.NotificationSubscriptionTypes,t,`Email notification setting "${t}" is not a valid subscription type.`,"User.NotificationSubscriptionTypes")&&this.v.Jr("email_subscribe",t)}setPushNotificationSubscriptionType(t){return!!K(User.NotificationSubscriptionTypes,t,`Push notification setting "${t}" is not a valid subscription type.`,"User.NotificationSubscriptionTypes")&&this.v.Jr("push_subscribe",t)}setPhoneNumber(t){return!!R(t,"set phone number","the phoneNumber",!0)&&(null===t||t.match(User.Or)?this.v.Jr("phone",t):(r.D.error(`Cannot set phone number - "${t}" did not pass validation.`),!1))}setLastKnownLocation(t,e,s,i,n){return null==t||null==e?(r.D.error("Cannot set last-known location - latitude and longitude are required."),!1):(t=parseFloat(t),e=parseFloat(e),null!=s&&(s=parseFloat(s)),null!=i&&(i=parseFloat(i)),null!=n&&(n=parseFloat(n)),isNaN(t)||isNaN(e)||null!=s&&isNaN(s)||null!=i&&isNaN(i)||null!=n&&isNaN(n)?(r.D.error("Cannot set last-known location - all supplied parameters must be numeric."),!1):t>90||t<-90||e>180||e<-180?(r.D.error("Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively."),!1):null!=s&&s<0||null!=n&&n<0?(r.D.error("Cannot set last-known location - accuracy and altitudeAccuracy may not be negative."),!1):this.Is.setLastKnownLocation(this.v.getUserId(),t,e,i,s,n).S)}setCustomUserAttribute(t,e){if(!X(t,"set custom user attribute","the given key"))return!1;const s=typeof e,i=yt(e),n=p(e);if("number"!==s&&"boolean"!==s&&!i&&!n&&null!==e&&!X(e,`set custom user attribute "${t}"`,"the given value"))return!1;if(i&&(e=Nt(e)),n){for(let s=0;s<e.length;s++){const r=e[s];if(!X(r,`set custom user attribute "${t}"`,"the element in the given array"))return!1}return this.Is.Vr(r.A.Wr,t,e).S}return this.v.setCustomUserAttribute(t,e)}addToCustomAttributeArray(t,e){return!!X(t,"add to custom user attribute array","the given key")&&(!(null!=e&&!X(e,"add to custom user attribute array","the given value"))&&this.Is.Vr(r.A.Yr,t,e).S)}removeFromCustomAttributeArray(t,e){return!!X(t,"remove from custom user attribute array","the given key")&&(!(null!=e&&!X(e,"remove from custom user attribute array","the given value"))&&this.Is.Vr(r.A.Qr,t,e).S)}incrementCustomUserAttribute(t,e){if(!X(t,"increment custom user attribute","the given key"))return!1;null==e&&(e=1);const s=parseInt(e);return isNaN(s)||s!==parseFloat(e)?(r.D.error(`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`),!1):this.Is.Vr(r.A.Xr,t,s).S}setCustomLocationAttribute(t,e,s){return!!X(t,"set custom location attribute","the given key")&&((null!==e||null!==s)&&(e=parseFloat(e),s=parseFloat(s),isNaN(e)||e>90||e<-90||isNaN(s)||s>180||s<-180)?(r.D.error("Received invalid values for latitude and/or longitude. Latitude and longitude are bounded by ±90 and ±180 respectively, or must both be null for removal."),!1):this.Is.Zr(t,e,s).S)}addToSubscriptionGroup(t){return!R(t,"add user to subscription group","subscription group ID",!1)||t.length<=0?(r.D.error("addToSubscriptionGroup requires a non-empty subscription group ID"),!1):this.Is.Cn(t,User.In.SUBSCRIBED).S}removeFromSubscriptionGroup(t){return!R(t,"remove user from subscription group","subscription group ID",!1)||t.length<=0?(r.D.error("removeFromSubscriptionGroup requires a non-empty subscription group ID"),!1):this.Is.Cn(t,User.In.UNSUBSCRIBED).S}dn(t,e,s,r,i){this.v.dn(t,e,s,r,i),this.Is.Un()}pn(t){this.v.pn(t)}}User.Or=/^[0-9 .\\(\\)\\+\\-]+$/,User.Genders={MALE:"m",FEMALE:"f",OTHER:"o",UNKNOWN:"u",NOT_APPLICABLE:"n",PREFER_NOT_TO_SAY:"p"},User.NotificationSubscriptionTypes={OPTED_IN:"opted_in",SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},User.In={SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},User.En="user_id",User.Kr="custom",User.ee=997;
1
+ import{isArray as p,isDate as yt,validateValueIsFromEnum as K}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"../util/date-utils.js";import{isValidEmail as vt,validateCustomString as X,validateStandardString as R}from"../util/validation-utils.js";export default class User{constructor(t,e){this.v=t,this.Is=e}getUserId(t){null==t&&r.D.error("getUserId must be supplied with a callback. e.g., braze.getUser().getUserId(function(userId) {console.log('the user id is ' + userId)})"),"function"==typeof t&&t(this.v.getUserId())}addAlias(t,e){return!R(t,"add alias","the alias",!1)||t.length<=0?(r.D.error("addAlias requires a non-empty alias"),!1):!R(e,"add alias","the label",!1)||e.length<=0?(r.D.error("addAlias requires a non-empty label"),!1):this.Is.Nr(t,e).S}setFirstName(t){return!!R(t,"set first name","the firstName",!0)&&this.v.Hr("first_name",t)}setLastName(t){return!!R(t,"set last name","the lastName",!0)&&this.v.Hr("last_name",t)}setEmail(t){return null===t||vt(t)?this.v.Hr("email",t):(r.D.error(`Cannot set email address - "${t}" did not pass RFC-5322 validation.`),!1)}setGender(t){return"string"==typeof t&&(t=t.toLowerCase()),!(null!==t&&!K(User.Genders,t,`Gender "${t}" is not a valid gender.`,"User.Genders"))&&this.v.Hr("gender",t)}setDateOfBirth(t,e,s){return null===t&&null===e&&null===s?this.v.Hr("dob",null):(t=parseInt(t),e=parseInt(e),s=parseInt(s),isNaN(t)||isNaN(e)||isNaN(s)||e>12||e<1||s>31||s<1?(r.D.error("Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);"),!1):this.v.Hr("dob",`${t}-${e}-${s}`))}setCountry(t){return!!R(t,"set country","the country",!0)&&this.v.Hr("country",t)}setHomeCity(t){return!!R(t,"set home city","the homeCity",!0)&&this.v.Hr("home_city",t)}setLanguage(t){return!!R(t,"set language","the language",!0)&&this.v.Hr("language",t)}setEmailNotificationSubscriptionType(t){return!!K(User.NotificationSubscriptionTypes,t,`Email notification setting "${t}" is not a valid subscription type.`,"User.NotificationSubscriptionTypes")&&this.v.Hr("email_subscribe",t)}setPushNotificationSubscriptionType(t){return!!K(User.NotificationSubscriptionTypes,t,`Push notification setting "${t}" is not a valid subscription type.`,"User.NotificationSubscriptionTypes")&&this.v.Hr("push_subscribe",t)}setPhoneNumber(t){return!!R(t,"set phone number","the phoneNumber",!0)&&(null===t||t.match(User.Sr)?this.v.Hr("phone",t):(r.D.error(`Cannot set phone number - "${t}" did not pass validation.`),!1))}setLastKnownLocation(t,e,s,i,n){return null==t||null==e?(r.D.error("Cannot set last-known location - latitude and longitude are required."),!1):(t=parseFloat(t),e=parseFloat(e),null!=s&&(s=parseFloat(s)),null!=i&&(i=parseFloat(i)),null!=n&&(n=parseFloat(n)),isNaN(t)||isNaN(e)||null!=s&&isNaN(s)||null!=i&&isNaN(i)||null!=n&&isNaN(n)?(r.D.error("Cannot set last-known location - all supplied parameters must be numeric."),!1):t>90||t<-90||e>180||e<-180?(r.D.error("Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively."),!1):null!=s&&s<0||null!=n&&n<0?(r.D.error("Cannot set last-known location - accuracy and altitudeAccuracy may not be negative."),!1):this.Is.setLastKnownLocation(this.v.getUserId(),t,e,i,s,n).S)}setCustomUserAttribute(t,e){if(!X(t,"set custom user attribute","the given key"))return!1;const s=typeof e,i=yt(e),n=p(e);if("number"!==s&&"boolean"!==s&&!i&&!n&&null!==e&&!X(e,`set custom user attribute "${t}"`,"the given value"))return!1;if(i&&(e=Nt(e)),n){for(let s=0;s<e.length;s++){const r=e[s];if(!X(r,`set custom user attribute "${t}"`,"the element in the given array"))return!1}return this.Is.Or(r.A.Vr,t,e).S}return this.v.setCustomUserAttribute(t,e)}addToCustomAttributeArray(t,e){return!!X(t,"add to custom user attribute array","the given key")&&(!(null!=e&&!X(e,"add to custom user attribute array","the given value"))&&this.Is.Or(r.A.Wr,t,e).S)}removeFromCustomAttributeArray(t,e){return!!X(t,"remove from custom user attribute array","the given key")&&(!(null!=e&&!X(e,"remove from custom user attribute array","the given value"))&&this.Is.Or(r.A.Yr,t,e).S)}incrementCustomUserAttribute(t,e){if(!X(t,"increment custom user attribute","the given key"))return!1;null==e&&(e=1);const s=parseInt(e);return isNaN(s)||s!==parseFloat(e)?(r.D.error(`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`),!1):this.Is.Or(r.A.Qr,t,s).S}setCustomLocationAttribute(t,e,s){return!!X(t,"set custom location attribute","the given key")&&((null!==e||null!==s)&&(e=parseFloat(e),s=parseFloat(s),isNaN(e)||e>90||e<-90||isNaN(s)||s>180||s<-180)?(r.D.error("Received invalid values for latitude and/or longitude. Latitude and longitude are bounded by ±90 and ±180 respectively, or must both be null for removal."),!1):this.Is.Xr(t,e,s).S)}addToSubscriptionGroup(t){return!R(t,"add user to subscription group","subscription group ID",!1)||t.length<=0?(r.D.error("addToSubscriptionGroup requires a non-empty subscription group ID"),!1):this.Is.Zr(t,User.Cn.SUBSCRIBED).S}removeFromSubscriptionGroup(t){return!R(t,"remove user from subscription group","subscription group ID",!1)||t.length<=0?(r.D.error("removeFromSubscriptionGroup requires a non-empty subscription group ID"),!1):this.Is.Zr(t,User.Cn.UNSUBSCRIBED).S}fn(t,e,s,r,i){this.v.fn(t,e,s,r,i),this.Is.In()}wn(t){this.v.wn(t)}}User.Sr=/^[0-9 .\\(\\)\\+\\-]+$/,User.Genders={MALE:"m",FEMALE:"f",OTHER:"o",UNKNOWN:"u",NOT_APPLICABLE:"n",PREFER_NOT_TO_SAY:"p"},User.NotificationSubscriptionTypes={OPTED_IN:"opted_in",SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},User.Cn={SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},User.En="user_id",User.Jr="custom",User.ee=997;
@@ -1 +1 @@
1
- import{ControlCard}from"../Card/index.js";export const FEED_ANIMATION_DURATION=500;export default class x{constructor(e,r){this.cards=e,this.lastUpdated=r}getUnreadCardCount(){let e=0;for(const r of this.cards)r.viewed||r instanceof ControlCard||e++;return e}dr(){throw new Error("Must be implemented in a subclass")}logCardImpressions(){throw new Error("Must be implemented in subclass")}logCardClick(){throw new Error("Must be implemented in subclass")}sr(){throw new Error("Must be implemented in subclass")}}x.ur=6e4,x.Oi=500,x.uo=1e4;
1
+ import{ControlCard}from"../Card/index.js";export const FEED_ANIMATION_DURATION=500;export default class x{constructor(e,r){this.cards=e,this.lastUpdated=r}getUnreadCardCount(){let e=0;for(const r of this.cards)r.viewed||r instanceof ControlCard||e++;return e}dr(){throw new Error("Must be implemented in a subclass")}logCardImpressions(){throw new Error("Must be implemented in subclass")}logCardClick(){throw new Error("Must be implemented in subclass")}sr(){throw new Error("Must be implemented in subclass")}}x.ur=6e4,x.Si=500,x.uo=1e4;
@@ -1 +1 @@
1
- import x from"./base-feed.js";import{bottomHadImpression as de,getCardId as fe,impressOnBottom as be,impressOnTop as ye,markCardAsRead as Fe,topHadImpression as Te}from"../Card/display/card-display.js";import{bottomIsInView as he,topIsInView as _e}from"../util/dom-utils.js";import{Card,ControlCard}from"../Card/index.js";import{cardToHtml as xe}from"../Card/display/card-display.js";import{isArray as p}from"../util/code-utils.js";import{KeyCodes as at}from"../util/key-codes.js";import Ee from"../l10n/l10n-manager-factory.js";import{removeSubscription}from"../Core/remove-subscription.js";import r from"../../shared-lib/braze-shared-lib.js";import{BRAZE_ACTION_URI_REGEX as P}from"../util/validation-utils.js";import{INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as gt,ineligibleBrazeActionURLErrorMessage as ct,getDecodedBrazeAction as O,containsUnknownBrazeAction as mt}from"../util/braze-actions.js";export const LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE="data-last-requested-refresh";export const _SUBSCRIPTION_ID_DATA_ATTRIBUTE="data-update-subscription-id";export function destroyFeedHtml(e){e&&(e.className=e.className.replace("ab-show","ab-hide"),setTimeout((()=>{e&&e.parentNode&&e.parentNode.removeChild(e)}),x.Oi));const t=e.getAttribute("data-update-subscription-id");null!=t&&removeSubscription(t)}export function _generateFeedBody(e,t){const o=document.createElement("div");if(o.className="ab-feed-body",o.setAttribute("aria-label","Feed"),o.setAttribute("role","feed"),null==e.lastUpdated){const e=document.createElement("div");e.className="ab-no-cards-message";const t=document.createElement("i");t.className="fa fa-spinner fa-spin fa-4x ab-initial-spinner",e.appendChild(t),o.appendChild(e)}else{let s=!1;const logCardClick=t=>{e.logCardClick(t)};for(const n of e.cards){const a=n instanceof ControlCard;!a||e.dr()?(o.appendChild(xe(n,logCardClick,t)),s=s||!a):r.D.error("Received a control card for a legacy news feed. Control cards are only supported with content cards.")}if(!s){const e=document.createElement("div");e.className="ab-no-cards-message",e.innerHTML=Ee.m().get("NO_CARDS_MESSAGE"),e.setAttribute("role","article"),o.appendChild(e)}}return o}export function detectFeedImpressions(e,t){if(null!=t){const o=[],r=t.querySelectorAll(".ab-card");e.do||(e.do={});for(let t=0;t<r.length;t++){const s=fe(r[t]);if(e.do[s])continue;let n=Te(r[t]),a=de(r[t]);const i=n,d=a,f=_e(r[t]),c=he(r[t]);if(!n&&f&&(n=!0,ye(r[t])),!a&&c&&(a=!0,be(r[t])),n&&a){if(f||c||Fe(r[t]),i&&d)continue;for(const t of e.cards)if(t.id===s){e.do[t.id]=!0,o.push(t);break}}}o.length>0&&e.logCardImpressions(o)}}export function refreshFeed(e,t){t.setAttribute("aria-busy","true");const o=t.querySelectorAll(".ab-refresh-button")[0];null!=o&&(o.className+=" fa-spin");const r=(new Date).valueOf().toString();t.setAttribute("data-last-requested-refresh",r),setTimeout((()=>{if(t.getAttribute("data-last-requested-refresh")===r){const e=t.querySelectorAll(".fa-spin");for(let t=0;t<e.length;t++)e[t].className=e[t].className.replace(/fa-spin/g,"");const o=t.querySelectorAll(".ab-initial-spinner")[0];if(null!=o){const e=document.createElement("span");e.innerHTML=Ee.m().get("FEED_TIMEOUT_MESSAGE"),o.parentNode.appendChild(e),o.parentNode.removeChild(o)}"true"===t.getAttribute("aria-busy")&&t.setAttribute("aria-busy","false")}}),x.uo),e.sr()}export function feedToHtml(e,t){const o=document.createElement("div");o.className="ab-feed ab-hide ab-effect-slide",o.setAttribute("role","dialog"),o.setAttribute("aria-label","Feed"),o.setAttribute("tabindex","-1");const r=document.createElement("div");r.className="ab-feed-buttons-wrapper",r.setAttribute("role","group"),o.appendChild(r);const s=document.createElement("i");s.className="fa fa-times ab-close-button",s.setAttribute("aria-label","Close Feed"),s.setAttribute("tabindex","0"),s.setAttribute("role","button");const n=e=>{destroyFeedHtml(o),e.stopPropagation()};s.addEventListener("keydown",(e=>{e.keyCode!==at.fo&&e.keyCode!==at.co||n(e)})),s.onclick=n;const a=document.createElement("i");a.className="fa fa-refresh ab-refresh-button",null==e.lastUpdated&&(a.className+=" fa-spin"),a.setAttribute("aria-label","Refresh Feed"),a.setAttribute("tabindex","0"),a.setAttribute("role","button");const i=t=>{refreshFeed(e,o),t.stopPropagation()};return a.addEventListener("keydown",(e=>{e.keyCode!==at.fo&&e.keyCode!==at.co||i(e)})),a.onclick=i,r.appendChild(a),r.appendChild(s),o.appendChild(_generateFeedBody(e,t)),o.onscroll=()=>{detectFeedImpressions(e,o)},o}export function updateFeedCards(e,t,o,s,n){if(!p(t))return;const a=[];for(const e of t)if(e instanceof Card){if(e.url&&P.test(e.url)){let t=O(e.url);if(mt(t)){r.D.error(ct(gt.Qe,"Content Card"));continue}}a.push(e)}if(e.cards=a,e.lastUpdated=o,null!=s)if(s.setAttribute("aria-busy","false"),null==e.lastUpdated)destroyFeedHtml(s);else{const t=s.querySelectorAll(".ab-feed-body")[0];if(null!=t){const o=_generateFeedBody(e,n);t.parentNode.replaceChild(o,t),detectFeedImpressions(e,o.parentNode)}}}export function registerFeedSubscriptionId(e,t){t.setAttribute("data-update-subscription-id",e)}
1
+ import x from"./base-feed.js";import{bottomHadImpression as de,getCardId as fe,impressOnBottom as be,impressOnTop as ye,markCardAsRead as Fe,topHadImpression as Te}from"../Card/display/card-display.js";import{bottomIsInView as he,topIsInView as _e}from"../util/dom-utils.js";import{Card,ControlCard}from"../Card/index.js";import{cardToHtml as xe}from"../Card/display/card-display.js";import{isArray as p}from"../util/code-utils.js";import{KeyCodes as at}from"../util/key-codes.js";import Ee from"../l10n/l10n-manager-factory.js";import{removeSubscription}from"../Core/remove-subscription.js";import r from"../../shared-lib/braze-shared-lib.js";import{BRAZE_ACTION_URI_REGEX as P}from"../util/validation-utils.js";import{INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as gt,ineligibleBrazeActionURLErrorMessage as ct,getDecodedBrazeAction as O,containsUnknownBrazeAction as mt}from"../util/braze-actions.js";export const LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE="data-last-requested-refresh";export const _SUBSCRIPTION_ID_DATA_ATTRIBUTE="data-update-subscription-id";export function destroyFeedHtml(e){e&&(e.className=e.className.replace("ab-show","ab-hide"),setTimeout((()=>{e&&e.parentNode&&e.parentNode.removeChild(e)}),x.Si));const t=e.getAttribute("data-update-subscription-id");null!=t&&removeSubscription(t)}export function _generateFeedBody(e,t){const o=document.createElement("div");if(o.className="ab-feed-body",o.setAttribute("aria-label","Feed"),o.setAttribute("role","feed"),null==e.lastUpdated){const e=document.createElement("div");e.className="ab-no-cards-message";const t=document.createElement("i");t.className="fa fa-spinner fa-spin fa-4x ab-initial-spinner",e.appendChild(t),o.appendChild(e)}else{let s=!1;const logCardClick=t=>{e.logCardClick(t)};for(const n of e.cards){const a=n instanceof ControlCard;!a||e.dr()?(o.appendChild(xe(n,logCardClick,t)),s=s||!a):r.D.error("Received a control card for a legacy news feed. Control cards are only supported with content cards.")}if(!s){const e=document.createElement("div");e.className="ab-no-cards-message",e.innerHTML=Ee.m().get("NO_CARDS_MESSAGE"),e.setAttribute("role","article"),o.appendChild(e)}}return o}export function detectFeedImpressions(e,t){if(null!=t){const o=[],r=t.querySelectorAll(".ab-card");e.do||(e.do={});for(let t=0;t<r.length;t++){const s=fe(r[t]);if(e.do[s])continue;let n=Te(r[t]),a=de(r[t]);const i=n,d=a,f=_e(r[t]),c=he(r[t]);if(!n&&f&&(n=!0,ye(r[t])),!a&&c&&(a=!0,be(r[t])),n&&a){if(f||c||Fe(r[t]),i&&d)continue;for(const t of e.cards)if(t.id===s){e.do[t.id]=!0,o.push(t);break}}}o.length>0&&e.logCardImpressions(o)}}export function refreshFeed(e,t){t.setAttribute("aria-busy","true");const o=t.querySelectorAll(".ab-refresh-button")[0];null!=o&&(o.className+=" fa-spin");const r=(new Date).valueOf().toString();t.setAttribute("data-last-requested-refresh",r),setTimeout((()=>{if(t.getAttribute("data-last-requested-refresh")===r){const e=t.querySelectorAll(".fa-spin");for(let t=0;t<e.length;t++)e[t].className=e[t].className.replace(/fa-spin/g,"");const o=t.querySelectorAll(".ab-initial-spinner")[0];if(null!=o){const e=document.createElement("span");e.innerHTML=Ee.m().get("FEED_TIMEOUT_MESSAGE"),o.parentNode.appendChild(e),o.parentNode.removeChild(o)}"true"===t.getAttribute("aria-busy")&&t.setAttribute("aria-busy","false")}}),x.uo),e.sr()}export function feedToHtml(e,t){const o=document.createElement("div");o.className="ab-feed ab-hide ab-effect-slide",o.setAttribute("role","dialog"),o.setAttribute("aria-label","Feed"),o.setAttribute("tabindex","-1");const r=document.createElement("div");r.className="ab-feed-buttons-wrapper",r.setAttribute("role","group"),o.appendChild(r);const s=document.createElement("i");s.className="fa fa-times ab-close-button",s.setAttribute("aria-label","Close Feed"),s.setAttribute("tabindex","0"),s.setAttribute("role","button");const n=e=>{destroyFeedHtml(o),e.stopPropagation()};s.addEventListener("keydown",(e=>{e.keyCode!==at.fo&&e.keyCode!==at.co||n(e)})),s.onclick=n;const a=document.createElement("i");a.className="fa fa-refresh ab-refresh-button",null==e.lastUpdated&&(a.className+=" fa-spin"),a.setAttribute("aria-label","Refresh Feed"),a.setAttribute("tabindex","0"),a.setAttribute("role","button");const i=t=>{refreshFeed(e,o),t.stopPropagation()};return a.addEventListener("keydown",(e=>{e.keyCode!==at.fo&&e.keyCode!==at.co||i(e)})),a.onclick=i,r.appendChild(a),r.appendChild(s),o.appendChild(_generateFeedBody(e,t)),o.onscroll=()=>{detectFeedImpressions(e,o)},o}export function updateFeedCards(e,t,o,s,n){if(!p(t))return;const a=[];for(const e of t)if(e instanceof Card){if(e.url&&P.test(e.url)){let t=O(e.url);if(mt(t)){r.D.error(ct(gt.We,"Content Card"));continue}}a.push(e)}if(e.cards=a,e.lastUpdated=o,null!=s)if(s.setAttribute("aria-busy","false"),null==e.lastUpdated)destroyFeedHtml(s);else{const t=s.querySelectorAll(".ab-feed-body")[0];if(null!=t){const o=_generateFeedBody(e,n);t.parentNode.replaceChild(o,t),detectFeedImpressions(e,o.parentNode)}}}export function registerFeedSubscriptionId(e,t){t.setAttribute("data-update-subscription-id",e)}
@@ -1 +1 @@
1
- import St from"./auth-manager.js";import C from"../common/base-provider.js";import et from"../util/browser-detector.js";import It from"./device-manager.js";import DeviceProperties from"../Core/device-properties.js";import{isArray as p,keys as Y,validateValueIsFromEnum as K,values as At}from"../util/code-utils.js";import{logDeprecationWarning as y}from"../util/deprecation-utils.js";import wt from"./network-manager.js";import Tt from"../request-controller.js";import Ot from"./server-config-manager.js";import Ct from"./session-manager.js";import r from"../../shared-lib/braze-shared-lib.js";import A,{STORAGE_KEYS as o}from"./storage-manager.js";import Lt from"./storage-manager-factory.js";import u from"./subscription-manager.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";import bt from"../User/user-manager.js";import{User}from"../User/index.js";import{parseQueryStringKeyValues as st}from"../util/url-utils.js";import{WindowUtils as G}from"../util/window-utils.js";const D={Vn:"allowCrawlerActivity",$n:"baseUrl",Yn:"noCookies",Xn:"devicePropertyAllowlist",ra:"disablePushTokenMaintenance",Zn:"enableLogging",ho:"enableSdkAuthentication",ta:"manageServiceWorkerExternally",po:"minimumIntervalBetweenTriggerActionsInSeconds",Eo:"sessionTimeoutInSeconds",_o:"appVersion",ea:"serviceWorkerLocation",na:"safariWebsitePushId",zn:"localization",ao:"contentSecurityNonce",Io:"enableHtmlInAppMessages",Ao:"allowUserSuppliedJavascript",no:"inAppMessageZIndex",lo:"openInAppMessagesInNewTab",tn:"openCardsInNewTab",en:"openNewsFeedCardsInNewTab",Ri:"requireExplicitInAppMessageDismissal",So:"doNotLoadFontAwesome",No:"sdkFlavor"};class Pt{constructor(){this.wo=!1,this.To=!1,this.Oo=new u,this.vo=new u,this.Co={},this.Lo=[],this.Po=[],this.Xs=[],this.Ro="4.0.5"}Mo(t){this.Oo.Et(t)}Ci(t){this.vo.Et(t)}initialize(t,i){if(this.yo())return r.D.info("Braze has already been initialized with an API key."),!0;this.Co=i||{};let s=this.nn(D.Zn);const e=st(G.Pn());if(e&&"true"===e.brazeLogging&&(s=!0),r.D.init(s),r.D.info(`Initialization Options: ${JSON.stringify(this.Co,null,2)}`),null==t||""===t||"string"!=typeof t)return r.D.error("Braze requires a valid API key to be initialized."),!1;this.yi=t;let n=this.nn(D.$n);if(null==n||""===n||"string"!=typeof n)return r.D.error("Braze requires a valid baseUrl to be initialized."),!1;if(n=n.replace(/(\.[a-z]+)[^\.]*$/i,"$1/api/v3"),0!==n.indexOf("http")&&(n="https://"+n),this.Do=n,et.jo&&!this.nn(D.Vn))return r.D.info("Ignoring activity from crawler bot "+navigator.userAgent),this.To=!0,!1;const a=this.nn(Pt.Yn)||!1;if(this.h=Lt.zo(t,a),new A.ne(null,!0).lr(o.ae))return r.D.info("Ignoring all activity due to previous opt out"),this.To=!0,!1;for(const t of Y(this.Co))-1===At(r.Uo).indexOf(t)&&r.D.warn(`Ignoring unknown initialization option '${t}'.`);const h=["mparticle","wordpress","tealium"];if(null!=this.nn(D.No)){const t=this.nn(D.No);-1!==h.indexOf(t)?this.Bo=t:r.D.error("Invalid sdk flavor passed: "+t)}let l=this.nn(r.Uo.Xn);if(null!=l)if(p(l)){const t=[];for(let i=0;i<l.length;i++)K(DeviceProperties,l[i],"devicePropertyAllowlist contained an invalid value.","DeviceProperties")&&t.push(l[i]);l=t}else r.D.error("devicePropertyAllowlist must be an array. Defaulting to all properties."),l=null;this.ji=new It(this.h,l),this.wt=new Ot(this.h),this.v=new bt(this.wt,this.h),this.j=new Ct(this.h,this.v,this.wt,this.nn(D.Eo));const c=new u;return this.Wo=new St(this.h,this.nn(D.ho),c),this.Ut(c),this.jt=new wt(this.ji,this.h,this.Wo,this.v,this.j,this.wt,this.yi,this.Do,this.Ro,this.Bo,this.nn(D._o)),this.Is=new Tt(this.yi,this.Do,this.j,this.ji,this.v,this.wt,this.h,(t=>{if(this.yo())for(const i of this.re())i._s(t)}),this.Wo,this.jt),this.Is.initialize(),r.D.info(`Initialized for the Braze backend at "${this.nn(D.$n)}" with API key "${this.yi}".`),null!=this.nn(D.Io)&&y("enableHtmlInAppMessages","initialization option","allowUserSuppliedJavascript"),V.init(),this.Oo.Nt(this.Co),this.wo=!0,!0}destroy(t){if(r.D.destroy(),this.yo()){this.vo.Nt(),this.vo.removeAllSubscriptions();for(const t of this.Lo)t.destroy();this.Lo=[];for(const t of this.Po)t.clearData(!1);this.Po=[],this.removeAllSubscriptions(),this.Xs=[],this.Is.destroy(),this.Is=null,this.Wo=null,this.ji=null,this.jt=null,this.wt=null,this.j=null,this.v=null,this.Co={},this.Bo=void 0,this.wo=!1,this.To=!1,t&&(this.h=null)}}rr(){if(this.Vo())return!1;if(!this.yo())throw new Error("Braze must be initialized before calling methods.");return!0}aa(){return this.yi}ti(){return this.Wo}Js(){return this.Do}ce(){return this.ji}nr(){return this.jt}nn(t){return this.Co[t]}re(){return this.Po}mr(){return this.Is}ir(){return this.wt}g(){return this.j}l(){return this.h}gr(){if(this.v&&this.Is)return new User(this.v,this.Is)}p(){return this.v}tr(){return!0===this.nn(D.Ao)||!0===this.nn(D.Io)}u(t){let i=!1;for(const s of this.Lo)s===t&&(i=!0);i||this.Lo.push(t)}ar(t){let i=!1;for(const s of this.Po)s.constructor===t.constructor&&(i=!0);t instanceof C&&!i&&this.Po.push(t)}Ut(t){t instanceof u&&this.Xs.push(t)}removeAllSubscriptions(){if(this.rr())for(const t of this.Xs)t.removeAllSubscriptions()}removeSubscription(t){if(this.rr())for(const i of this.Xs)i.removeSubscription(t)}le(t){this.To=t}yo(){return this.wo}Vo(){return this.To}}const e=new Pt;export{e as default,Pt as BrazeSdkInstance,D as OPTIONS};
1
+ import St from"./auth-manager.js";import C from"../common/base-provider.js";import et from"../util/browser-detector.js";import It from"./device-manager.js";import DeviceProperties from"../Core/device-properties.js";import{isArray as p,keys as Y,validateValueIsFromEnum as K,values as At}from"../util/code-utils.js";import{logDeprecationWarning as y}from"../util/deprecation-utils.js";import wt from"./network-manager.js";import Tt from"../request-controller.js";import Ot from"./server-config-manager.js";import Ct from"./session-manager.js";import r from"../../shared-lib/braze-shared-lib.js";import A,{STORAGE_KEYS as o}from"./storage-manager.js";import Lt from"./storage-manager-factory.js";import u from"./subscription-manager.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";import bt from"../User/user-manager.js";import{User}from"../User/index.js";import{parseQueryStringKeyValues as st}from"../util/url-utils.js";import{WindowUtils as G}from"../util/window-utils.js";const D={Vn:"allowCrawlerActivity",$n:"baseUrl",Yn:"noCookies",Xn:"devicePropertyAllowlist",ra:"disablePushTokenMaintenance",Zn:"enableLogging",ho:"enableSdkAuthentication",ta:"manageServiceWorkerExternally",po:"minimumIntervalBetweenTriggerActionsInSeconds",Eo:"sessionTimeoutInSeconds",_o:"appVersion",ea:"serviceWorkerLocation",na:"safariWebsitePushId",zn:"localization",ao:"contentSecurityNonce",Io:"enableHtmlInAppMessages",Ao:"allowUserSuppliedJavascript",no:"inAppMessageZIndex",lo:"openInAppMessagesInNewTab",tn:"openCardsInNewTab",en:"openNewsFeedCardsInNewTab",bi:"requireExplicitInAppMessageDismissal",So:"doNotLoadFontAwesome",No:"sdkFlavor"};class Pt{constructor(){this.wo=!1,this.To=!1,this.Oo=new u,this.vo=new u,this.Co={},this.Lo=[],this.Po=[],this.De=[],this.Ro="4.0.6"}Mo(t){this.Oo.Et(t)}Ui(t){this.vo.Et(t)}initialize(t,i){if(this.yo())return r.D.info("Braze has already been initialized with an API key."),!0;this.Co=i||{};let s=this.nn(D.Zn);const e=st(G.kn());if(e&&"true"===e.brazeLogging&&(s=!0),r.D.init(s),r.D.info(`Initialization Options: ${JSON.stringify(this.Co,null,2)}`),null==t||""===t||"string"!=typeof t)return r.D.error("Braze requires a valid API key to be initialized."),!1;this.ji=t;let n=this.nn(D.$n);if(null==n||""===n||"string"!=typeof n)return r.D.error("Braze requires a valid baseUrl to be initialized."),!1;if(n=n.replace(/(\.[a-z]+)[^\.]*$/i,"$1/api/v3"),0!==n.indexOf("http")&&(n="https://"+n),this.Do=n,et.jo&&!this.nn(D.Vn))return r.D.info("Ignoring activity from crawler bot "+navigator.userAgent),this.To=!0,!1;const a=this.nn(Pt.Yn)||!1;if(this.h=Lt.zo(t,a),new A.ne(null,!0).lr(o.ae))return r.D.info("Ignoring all activity due to previous opt out"),this.To=!0,!1;for(const t of Y(this.Co))-1===At(r.Uo).indexOf(t)&&r.D.warn(`Ignoring unknown initialization option '${t}'.`);const h=["mparticle","wordpress","tealium"];if(null!=this.nn(D.No)){const t=this.nn(D.No);-1!==h.indexOf(t)?this.Bo=t:r.D.error("Invalid sdk flavor passed: "+t)}let l=this.nn(r.Uo.Xn);if(null!=l)if(p(l)){const t=[];for(let i=0;i<l.length;i++)K(DeviceProperties,l[i],"devicePropertyAllowlist contained an invalid value.","DeviceProperties")&&t.push(l[i]);l=t}else r.D.error("devicePropertyAllowlist must be an array. Defaulting to all properties."),l=null;this.xi=new It(this.h,l),this.wt=new Ot(this.h),this.v=new bt(this.wt,this.h),this.j=new Ct(this.h,this.v,this.wt,this.nn(D.Eo));const c=new u;return this.Wo=new St(this.h,this.nn(D.ho),c),this.Ut(c),this.jt=new wt(this.xi,this.h,this.Wo,this.v,this.j,this.wt,this.ji,this.Do,this.Ro,this.Bo,this.nn(D._o)),this.Is=new Tt(this.ji,this.Do,this.j,this.xi,this.v,this.wt,this.h,(t=>{if(this.yo())for(const i of this.re())i._s(t)}),this.Wo,this.jt),this.Is.initialize(),r.D.info(`Initialized for the Braze backend at "${this.nn(D.$n)}" with API key "${this.ji}".`),null!=this.nn(D.Io)&&y("enableHtmlInAppMessages","initialization option","allowUserSuppliedJavascript"),V.init(),this.Oo.Nt(this.Co),this.wo=!0,!0}destroy(t){if(r.D.destroy(),this.yo()){this.vo.Nt(),this.vo.removeAllSubscriptions();for(const t of this.Lo)t.destroy();this.Lo=[];for(const t of this.Po)t.clearData(!1);this.Po=[],this.removeAllSubscriptions(),this.De=[],this.Is.destroy(),this.Is=null,this.Wo=null,this.xi=null,this.jt=null,this.wt=null,this.j=null,this.v=null,this.Co={},this.Bo=void 0,this.wo=!1,this.To=!1,t&&(this.h=null)}}rr(){if(this.Vo())return!1;if(!this.yo())throw new Error("Braze must be initialized before calling methods.");return!0}aa(){return this.ji}ti(){return this.Wo}Js(){return this.Do}ce(){return this.xi}nr(){return this.jt}nn(t){return this.Co[t]}re(){return this.Po}mr(){return this.Is}ir(){return this.wt}g(){return this.j}l(){return this.h}gr(){if(this.v&&this.Is)return new User(this.v,this.Is)}p(){return this.v}tr(){return!0===this.nn(D.Ao)||!0===this.nn(D.Io)}u(t){let i=!1;for(const s of this.Lo)s===t&&(i=!0);i||this.Lo.push(t)}ar(t){let i=!1;for(const s of this.Po)s.constructor===t.constructor&&(i=!0);t instanceof C&&!i&&this.Po.push(t)}Ut(t){t instanceof u&&this.De.push(t)}removeAllSubscriptions(){if(this.rr())for(const t of this.De)t.removeAllSubscriptions()}removeSubscription(t){if(this.rr())for(const i of this.De)i.removeSubscription(t)}le(t){this.To=t}yo(){return this.wo}Vo(){return this.To}}const e=new Pt;export{e as default,Pt as BrazeSdkInstance,D as OPTIONS};
@@ -1 +1 @@
1
- import Rt from"../models/backend-errors.js";import ue from"../models/braze-event.js";import{convertMsToSeconds as l,convertSecondsToMs as qt}from"../util/date-utils.js";import s from"../common/event-logger.js";import{isArray as p,isEqual as ii}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"./storage-manager.js";export default class wt{constructor(t,e,s,i,r,o,n,a,h,u,c){this.ji=t,this.h=e,this.Wo=s,this.v=i,this.j=r,this.wt=o,this.yi=n,this.Do=a,this.Ro=h,this.Bo=u,this.Xo=c,this.$o=["npm"]}Ls(t,e){const s=this.ji.te(),i=s.Ye(),r=this.h.I(o.q.Ho);ii(r,i)||(t.device=i),t.api_key=this.yi,t.time=l((new Date).valueOf(),!0);const n=this.h.I(o.q.Yo)||[],a=this.h.I(o.q.Zo)||"";if(this.$o.length>0&&(!ii(n,this.$o)||a!==this.j.sa())&&(t.sdk_metadata=this.$o),t.sdk_version=this.Ro,this.Bo&&(t.sdk_flavor=this.Bo),t.app_version=this.Xo,t.device_id=s.id,e){const e=this.v.getUserId();null!=e&&(t.user_id=e)}return t}qs(t,e,i){const o=e.auth_error,n=e.error;if(!o&&!n)return!0;if(o){let e;this.Wo.Qn();const s={errorCode:o.error_code};for(const t of i)p(t)&&"X-Braze-Auth-Signature"===t[0]&&(s.signature=t[1]);t.respond_with&&t.respond_with.user_id?s.userId=t.respond_with.user_id:t.user_id&&(s.userId=t.user_id);const n=o.reason;return n?(s.reason=n,e=`due to ${n}`):e=`with error code ${o.error_code}.`,this.Wo.Gn()||(e+=' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),r.D.error(`SDK Authentication failed ${e}`),this.ia(t.events,t.attributes),this.Wo.Mn(s),!1}if(n){let i=n;switch(i){case Rt.oa:const o="Received successful response with empty body.";return s.G(r.A.ha,{e:o}),r.D.info(o),!1;case Rt.ua:const n="Received successful response with invalid JSON";return s.G(r.A.ha,{e:n+": "+e.response}),r.D.info(n),!1;case Rt.ca:i=`The API key "${t.api_key}" is invalid for the baseUrl ${this.Do}`;break;case Rt.la:i="Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";break;case Rt.fa:i="No device identifier. Please contact support@braze.com"}r.D.error("Backend error: "+i)}return!1}ma(t,e,s,i){return!!(t&&0!==t.length||e&&0!==e.length||s||i)}pa(t,e,s,i){const r=[],o=t=>t||"",n=o(this.v.getUserId());let a,h,u,c,l=this.Xe(t,e);if(s.length>0){const t=[];for(const e of s){if(a=e.Ye(),this.Wo.Gn()){if(n&&!a.user_id){c||(c={},c.events=[]),c.events.push(a);continue}if(o(a.user_id)!==n){h||(h=[]),h.push(a);continue}}t.push(a)}t.length>0&&(l.events=t)}if(i.length>0){const t=[];for(const e of i)this.Wo.Gn()&&o(e.user_id)!==n?(u||(u=[]),u.push(e)):t.push(e);t.length>0&&(l.attributes=t)}if(this.ia(h,u),l=this.Ls(l,!0),c){c=this.Ls(c,!1);const t={requestData:c,headers:this.Ns(c)};r.push(t)}if(l&&!this.ma(l.events,l.attributes,t,e))return c?r:null;const f={requestData:l,headers:this.Ns(l)};return r.push(f),r}ia(t,e){if(t){const e=[];for(const s of t){const t=ue.fromJson(s);t.time=qt(t.time),e.push(t)}this.h.bo(e)}if(e)for(const t of e)this.h.ba(t)}Ms(t,e){let s="HTTP error ";null!=t&&(s+=t+" "),s+=e,r.D.error(s)}yr(t){return s.G(r.A.Ra,{n:t})}Xe(t,e,s){const i={};t&&(i.feed=!0),e&&(i.triggers=!0);const r=null!=s?s:this.v.getUserId();return r&&(i.user_id=r),i.config={config_time:this.wt.Gs()},{respond_with:i}}Ns(t,e){const s=[["X-Braze-Api-Key",this.yi]];let i=!1;if(null!=t.respond_with&&t.respond_with.triggers&&(s.push(["X-Braze-TriggersRequest","true"]),i=!0),null!=t.respond_with&&t.respond_with.feed&&(s.push(["X-Braze-FeedRequest","true"]),i=!0),e&&(s.push(["X-Braze-ContentCardsRequest","true"]),i=!0),i&&s.push(["X-Braze-DataRequest","true"]),this.Wo.Gn()){const t=this.Wo.Hn();null!=t&&s.push(["X-Braze-Auth-Signature",t])}return s}As(t,e){const s=t.device;s&&s.os_version instanceof Promise?s.os_version.then((s=>{t.device.os_version=s,e()})):e()}Es(){this.Wo.Es()}Js(){return this.Do}addSdkMetadata(t){for(const e of t)-1===this.$o.indexOf(e)&&this.$o.push(e)}}
1
+ import Rt from"../models/backend-errors.js";import ue from"../models/braze-event.js";import{convertMsToSeconds as l,convertSecondsToMs as qt}from"../util/date-utils.js";import s from"../common/event-logger.js";import{isArray as p,isEqual as ii}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"./storage-manager.js";export default class wt{constructor(t,e,s,i,r,o,n,a,h,u,c){this.xi=t,this.h=e,this.Wo=s,this.v=i,this.j=r,this.wt=o,this.ji=n,this.Do=a,this.Ro=h,this.Bo=u,this.Xo=c,this.$o=["npm"]}Ls(t,e){const s=this.xi.te(),i=s.Zs(),r=this.h.I(o.q.Ho);ii(r,i)||(t.device=i),t.api_key=this.ji,t.time=l((new Date).valueOf(),!0);const n=this.h.I(o.q.Yo)||[],a=this.h.I(o.q.Zo)||"";if(this.$o.length>0&&(!ii(n,this.$o)||a!==this.j.sa())&&(t.sdk_metadata=this.$o),t.sdk_version=this.Ro,this.Bo&&(t.sdk_flavor=this.Bo),t.app_version=this.Xo,t.device_id=s.id,e){const e=this.v.getUserId();null!=e&&(t.user_id=e)}return t}qs(t,e,i){const o=e.auth_error,n=e.error;if(!o&&!n)return!0;if(o){let e;this.Wo.Qn();const s={errorCode:o.error_code};for(const t of i)p(t)&&"X-Braze-Auth-Signature"===t[0]&&(s.signature=t[1]);t.respond_with&&t.respond_with.user_id?s.userId=t.respond_with.user_id:t.user_id&&(s.userId=t.user_id);const n=o.reason;return n?(s.reason=n,e=`due to ${n}`):e=`with error code ${o.error_code}.`,this.Wo.Gn()||(e+=' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),r.D.error(`SDK Authentication failed ${e}`),this.ia(t.events,t.attributes),this.Wo.Mn(s),!1}if(n){let i=n;switch(i){case Rt.oa:const o="Received successful response with empty body.";return s.G(r.A.ha,{e:o}),r.D.info(o),!1;case Rt.ua:const n="Received successful response with invalid JSON";return s.G(r.A.ha,{e:n+": "+e.response}),r.D.info(n),!1;case Rt.ca:i=`The API key "${t.api_key}" is invalid for the baseUrl ${this.Do}`;break;case Rt.la:i="Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";break;case Rt.fa:i="No device identifier. Please contact support@braze.com"}r.D.error("Backend error: "+i)}return!1}ma(t,e,s,i){return!!(t&&0!==t.length||e&&0!==e.length||s||i)}pa(t,e,s,i){const r=[],o=t=>t||"",n=o(this.v.getUserId());let a,h,u,c,l=this.Ys(t,e);if(s.length>0){const t=[];for(const e of s){if(a=e.Zs(),this.Wo.Gn()){if(n&&!a.user_id){c||(c={},c.events=[]),c.events.push(a);continue}if(o(a.user_id)!==n){h||(h=[]),h.push(a);continue}}t.push(a)}t.length>0&&(l.events=t)}if(i.length>0){const t=[];for(const e of i)this.Wo.Gn()&&o(e.user_id)!==n?(u||(u=[]),u.push(e)):t.push(e);t.length>0&&(l.attributes=t)}if(this.ia(h,u),l=this.Ls(l,!0),c){c=this.Ls(c,!1);const t={requestData:c,headers:this.Ns(c)};r.push(t)}if(l&&!this.ma(l.events,l.attributes,t,e))return c?r:null;const f={requestData:l,headers:this.Ns(l)};return r.push(f),r}ia(t,e){if(t){const e=[];for(const s of t){const t=ue.fromJson(s);t.time=qt(t.time),e.push(t)}this.h.bo(e)}if(e)for(const t of e)this.h.ba(t)}Ms(t,e){let s="HTTP error ";null!=t&&(s+=t+" "),s+=e,r.D.error(s)}yr(t){return s.G(r.A.Ra,{n:t})}Ys(t,e,s){const i={};t&&(i.feed=!0),e&&(i.triggers=!0);const r=null!=s?s:this.v.getUserId();return r&&(i.user_id=r),i.config={config_time:this.wt.Gs()},{respond_with:i}}Ns(t,e){const s=[["X-Braze-Api-Key",this.ji]];let i=!1;if(null!=t.respond_with&&t.respond_with.triggers&&(s.push(["X-Braze-TriggersRequest","true"]),i=!0),null!=t.respond_with&&t.respond_with.feed&&(s.push(["X-Braze-FeedRequest","true"]),i=!0),e&&(s.push(["X-Braze-ContentCardsRequest","true"]),i=!0),i&&s.push(["X-Braze-DataRequest","true"]),this.Wo.Gn()){const t=this.Wo.Hn();null!=t&&s.push(["X-Braze-Auth-Signature",t])}return s}As(t,e){const s=t.device;s&&s.os_version instanceof Promise?s.os_version.then((s=>{t.device.os_version=s,e()})):e()}Es(){this.Wo.Es()}Js(){return this.Do}addSdkMetadata(t){for(const e of t)-1===this.$o.indexOf(e)&&this.$o.push(e)}}
@@ -1 +1 @@
1
- import{STORAGE_KEYS as o}from"./storage-manager.js";import u from"./subscription-manager.js";import jt from"../models/server-config.js";export default class Ot{constructor(t){this.h=t,this.sh=new u,this.eh=new u,this.ih=null}rh(){if(null==this.ih){const t=this.h.I(o.q.nh);this.ih=null!=t?jt.An(t):new jt}return this.ih}Gs(){return this.rh().hh}lh(t){if(null!=t&&null!=t.config){const s=t.config;if(s.time>this.rh().hh){const t=new jt(s.time,s.events_blacklist,s.attributes_blacklist,s.purchases_blacklist,s.messaging_session_timeout,s.vapid_public_key,s.content_cards);let e=!1;null!=t.oh&&this.kn()!==t.oh&&(e=!0);let i=!1;null!=t.uh.enabled&&this.Bs()!==t.uh.enabled&&(i=!0),this.ih=t,this.h.B(o.q.nh,t.ss()),e&&this.sh.Nt(),i&&this.eh.Nt()}}}Sn(t){let s=this.sh.Et(t);return this.ah&&this.sh.removeSubscription(this.ah),this.ah=s,s}Rs(t){return this.eh.Et(t)}ge(t){return-1!==this.rh().gh.indexOf(t)}Hr(t){return-1!==this.rh().mh.indexOf(t)}Dr(t){return-1!==this.rh().fh.indexOf(t)}dh(){return this.rh().ph}kn(){return this.rh().oh}Bs(){return this.rh().uh.enabled||!1}}
1
+ import{STORAGE_KEYS as o}from"./storage-manager.js";import u from"./subscription-manager.js";import jt from"../models/server-config.js";export default class Ot{constructor(t){this.h=t,this.sh=new u,this.eh=new u,this.ih=null}rh(){if(null==this.ih){const t=this.h.I(o.q.nh);this.ih=null!=t?jt.jn(t):new jt}return this.ih}Gs(){return this.rh().hh}lh(t){if(null!=t&&null!=t.config){const s=t.config;if(s.time>this.rh().hh){const t=new jt(s.time,s.events_blacklist,s.attributes_blacklist,s.purchases_blacklist,s.messaging_session_timeout,s.vapid_public_key,s.content_cards);let e=!1;null!=t.oh&&this.Sn()!==t.oh&&(e=!0);let i=!1;null!=t.uh.enabled&&this.Bs()!==t.uh.enabled&&(i=!0),this.ih=t,this.h.B(o.q.nh,t.ss()),e&&this.sh.Nt(),i&&this.eh.Nt()}}}Dn(t){let s=this.sh.Et(t);return this.ah&&this.sh.removeSubscription(this.ah),this.ah=s,s}Rs(t){return this.eh.Et(t)}ge(t){return-1!==this.rh().gh.indexOf(t)}Gr(t){return-1!==this.rh().mh.indexOf(t)}Dr(t){return-1!==this.rh().fh.indexOf(t)}dh(){return this.rh().ph}Sn(){return this.rh().oh}Bs(){return this.rh().uh.enabled||!1}}
@@ -1 +1 @@
1
- import et from"../util/browser-detector.js";import ue from"../models/braze-event.js";import _t from"../models/identifier.js";import{isArray as p,keys as Y,validateValueIsFromEnum as K,values as At}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{User}from"../User/index.js";export const STORAGE_KEYS={Cr:{Ur:"ab.storage.userId",Go:"ab.storage.deviceId",Dh:"ab.storage.sessionId"},q:{ga:"ab.test",Ta:"ab.storage.events",Aa:"ab.storage.attributes",Oa:"ab.storage.attributes.anonymous_user",Ho:"ab.storage.device",Yo:"ab.storage.sdk_metadata",Zo:"ab.storage.session_id_for_cached_metadata",Nn:"ab.storage.pushToken",Ks:"ab.storage.newsFeed",Qs:"ab.storage.lastNewsFeedRefresh",P:"ab.storage.cardImpressions",nh:"ab.storage.serverConfig",Ia:"ab.storage.triggers",Ka:"ab.storage.triggers.ts",Ch:"ab.storage.messagingSessionStart",Wt:"ab.storage.cc",Cs:"ab.storage.ccLastFullSync",ws:"ab.storage.ccLastCardUpdated",$:"ab.storage.ccClicks",O:"ab.storage.ccImpressions",K:"ab.storage.ccDismissals",Ya:"ab.storage.lastDisplayedTriggerTimesById",Da:"ab.storage.lastDisplayedTriggerTime",Ga:"ab.storage.triggerFireInstancesById",Jn:"ab.storage.signature"},ae:"ab.optOut"};export default class A{constructor(t,e){this.va=t,this.Na=e}Lr(t,e){let s=e;null!=e&&e instanceof _t&&(s=e.ss()),this.va.store(t,s)}Ma(t){const e=this._r(t);null!=e&&(e._h=(new Date).valueOf(),this.Lr(t,e))}_r(t){return _t.An(this.va.lr(t))}qh(t){this.va.remove(t)}bo(t){if(null==t||0===t.length)return!1;p(t)||(t=[t]);let e=this.Na.lr(STORAGE_KEYS.q.Ta);null!=e&&p(e)||(e=[]);for(let s=0;s<t.length;s++)e.push(t[s].ss());return this.Na.store(STORAGE_KEYS.q.Ta,e)}Hh(t){return null!=t&&this.bo([t])}Ca(){let t=this.Na.lr(STORAGE_KEYS.q.Ta);this.Na.remove(STORAGE_KEYS.q.Ta),null==t&&(t=[]);const e=[];let s=!1,o=null;if(p(t))for(let s=0;s<t.length;s++)ue.ya(t[s])?e.push(ue.An(t[s])):o=s;else s=!0;if(s||null!=o){let n="Stored events could not be deserialized as Events";s&&(n+=", was "+Object.prototype.toString.call(t)+" not an array"),null!=o&&(n+=", value at index "+o+" does not look like an event"),n+=", serialized values were of type "+typeof t+": "+JSON.stringify(t),e.push(new ue(null,r.A.ha,(new Date).valueOf(),null,{e:n}))}return e}B(t,e){return!!K(STORAGE_KEYS.q,t,"StorageManager cannot store object.","STORAGE_KEYS.OBJECTS")&&this.Na.store(t,e)}I(t){return!!K(STORAGE_KEYS.q,t,"StorageManager cannot retrieve object.","STORAGE_KEYS.OBJECTS")&&this.Na.lr(t)}$s(t){return!!K(STORAGE_KEYS.q,t,"StorageManager cannot remove object.","STORAGE_KEYS.OBJECTS")&&(this.Na.remove(t),!0)}clearData(){const t=Y(STORAGE_KEYS.Cr),e=Y(STORAGE_KEYS.q);for(let e=0;e<t.length;e++){const s=t[e];this.va.remove(STORAGE_KEYS.Cr[s])}for(let t=0;t<e.length;t++){const s=e[t];this.Na.remove(STORAGE_KEYS.q[s])}}Ua(t){return t||STORAGE_KEYS.q.Oa}ba(t){let e=this.Na.lr(STORAGE_KEYS.q.Aa);null==e&&(e={});const s=this.Ua(t[User.En]);for(let r in t)r===User.En||null!=e[s]&&null!=e[s][r]||this.Mr(t[User.En],r,t[r])}Mr(t,e,s){let r=this.Na.lr(STORAGE_KEYS.q.Aa);null==r&&(r={});const o=this.Ua(t);let n=r[o];if(null==n&&(n={},null!=t&&(n[User.En]=t)),e===User.Kr){null==n[e]&&(n[e]={});for(let t in s)n[e][t]=s[t]}else n[e]=s;return r[o]=n,this.Na.store(STORAGE_KEYS.q.Aa,r)}Ba(){const t=this.Na.lr(STORAGE_KEYS.q.Aa);this.Na.remove(STORAGE_KEYS.q.Aa);const e=[];for(let s in t)null!=t[s]&&e.push(t[s]);return e}Gr(t){const e=this.Na.lr(STORAGE_KEYS.q.Aa);if(null!=e){const s=this.Ua(null),r=e[s];null!=r&&(e[s]=void 0,this.Na.store(STORAGE_KEYS.q.Aa,e),r[User.En]=t,this.ba(r))}const s=this._r(STORAGE_KEYS.Cr.Dh);let r=null;null!=s&&(r=s.Ir);const o=this.Ca();if(null!=o)for(let e=0;e<o.length;e++){const s=o[e];null==s.userId&&s.sessionId==r&&(s.userId=t),this.Hh(s)}}Fa(){return this.Na.La}}A.wa=class{constructor(t){this.yi=t,this.La=et.Pa()?3:10}xa(t){return t+"."+this.yi}store(t,e){const s={v:e};try{return localStorage.setItem(this.xa(t),JSON.stringify(s)),!0}catch(t){return r.D.info("Storage failure: "+t.message),!1}}lr(t){try{const e=JSON.parse(localStorage.getItem(this.xa(t)));return null==e?null:e.v}catch(t){return r.D.info("Storage retrieval failure: "+t.message),null}}remove(t){try{localStorage.removeItem(this.xa(t))}catch(t){return r.D.info("Storage removal failure: "+t.message),!1}}};A.ne=class{constructor(t,e){this.yi=t,this.Ja=this.ka(),this.za=576e3,this.Qa=!!e}xa(t){return null!=this.yi?t+"."+this.yi:t}ka(){let t=0,e=document.location.hostname;const s=e.split("."),r="ab._gd";for(;t<s.length-1&&-1===document.cookie.indexOf(r+"="+r);)t++,e="."+s.slice(-1-t).join("."),document.cookie=r+"="+r+";domain="+e+";";return document.cookie=r+"=;expires="+new Date(0).toGMTString()+";domain="+e+";",e}ie(){const t=new Date;return t.setTime(t.getTime()+60*this.za*1e3),t.getFullYear()}Va(){const t=At(STORAGE_KEYS.Cr),e=document.cookie.split(";");for(let s=0;s<e.length;s++){let r=e[s];for(;" "===r.charAt(0);)r=r.substring(1);let o=!1;for(let e=0;e<t.length;e++)if(0===r.indexOf(t[e])){o=!0;break}if(o){const t=r.split("=")[0];-1===t.indexOf("."+this.yi)&&this.Ha(t)}}}store(t,e){this.Va();const s=new Date;s.setTime(s.getTime()+60*this.za*1e3);const o="expires="+s.toUTCString(),n="domain="+this.Ja;let i;i=this.Qa?e:encodeURIComponent(JSON.stringify(e));const a=this.xa(t)+"="+i+";"+o+";"+n+";path=/";return a.length>=4093?(r.D.info("Storage failure: string is "+a.length+" chars which is too large to store as a cookie."),!1):(document.cookie=a,!0)}lr(t){const e=[],s=this.xa(t)+"=",o=document.cookie.split(";");for(let n=0;n<o.length;n++){let i=o[n];for(;" "===i.charAt(0);)i=i.substring(1);if(0===i.indexOf(s))try{let t;t=this.Qa?i.substring(s.length,i.length):JSON.parse(decodeURIComponent(i.substring(s.length,i.length))),e.push(t)}catch(e){return r.D.info("Storage retrieval failure: "+e.message),this.remove(t),null}}return e.length>0?e[e.length-1]:null}remove(t){this.Ha(this.xa(t))}Ha(t){const e=t+"=;expires="+new Date(0).toGMTString();document.cookie=e,document.cookie=e+";path=/";const s=e+";domain="+this.Ja;document.cookie=s,document.cookie=s+";path=/"}};A._a=class{constructor(){this.Wa={},this.Xa=5242880,this.La=3}store(t,e){const s={value:e},o=this.qa(e);return o>this.Xa?(r.D.info("Storage failure: object is ≈"+o+" bytes which is greater than the max of "+this.Xa),!1):(this.Wa[t]=s,!0)}qa(t){const e=[],s=[t];let r=0;for(;s.length;){const t=s.pop();if("boolean"==typeof t)r+=4;else if("string"==typeof t)r+=2*t.length;else if("number"==typeof t)r+=8;else if("object"==typeof t&&-1===e.indexOf(t)){e.push(t);for(let e in t)s.push(t[e])}}return r}lr(t){const e=this.Wa[t];return null==e?null:e.value}remove(t){this.Wa[t]=null}};A.Ea=class{constructor(t,e,s){this.Za=[],e&&this.Za.push(new A.ne(t)),s&&this.Za.push(new A.wa(t)),this.Za.push(new A._a(t))}store(t,e){let s=!0;for(let r=0;r<this.Za.length;r++)s=this.Za[r].store(t,e)&&s;return s}lr(t){for(let e=0;e<this.Za.length;e++){const s=this.Za[e].lr(t);if(null!=s)return s}return null}remove(t){for(let e=0;e<this.Za.length;e++)this.Za[e].remove(t)}};
1
+ import et from"../util/browser-detector.js";import ue from"../models/braze-event.js";import _t from"../models/identifier.js";import{isArray as p,keys as Y,validateValueIsFromEnum as K,values as At}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{User}from"../User/index.js";export const STORAGE_KEYS={Cr:{Ur:"ab.storage.userId",Go:"ab.storage.deviceId",Dh:"ab.storage.sessionId"},q:{ga:"ab.test",Ta:"ab.storage.events",Aa:"ab.storage.attributes",Oa:"ab.storage.attributes.anonymous_user",Ho:"ab.storage.device",Yo:"ab.storage.sdk_metadata",Zo:"ab.storage.session_id_for_cached_metadata",Wn:"ab.storage.pushToken",Ks:"ab.storage.newsFeed",Qs:"ab.storage.lastNewsFeedRefresh",P:"ab.storage.cardImpressions",nh:"ab.storage.serverConfig",Ia:"ab.storage.triggers",Ka:"ab.storage.triggers.ts",Ch:"ab.storage.messagingSessionStart",Wt:"ab.storage.cc",Cs:"ab.storage.ccLastFullSync",ws:"ab.storage.ccLastCardUpdated",$:"ab.storage.ccClicks",O:"ab.storage.ccImpressions",K:"ab.storage.ccDismissals",Ya:"ab.storage.lastDisplayedTriggerTimesById",Da:"ab.storage.lastDisplayedTriggerTime",Ga:"ab.storage.triggerFireInstancesById",Jn:"ab.storage.signature"},ae:"ab.optOut"};export default class A{constructor(t,e){this.va=t,this.Na=e}Lr(t,e){let s=e;null!=e&&e instanceof _t&&(s=e.ss()),this.va.store(t,s)}Ma(t){const e=this._r(t);null!=e&&(e._h=(new Date).valueOf(),this.Lr(t,e))}_r(t){return _t.jn(this.va.lr(t))}qh(t){this.va.remove(t)}bo(t){if(null==t||0===t.length)return!1;p(t)||(t=[t]);let e=this.Na.lr(STORAGE_KEYS.q.Ta);null!=e&&p(e)||(e=[]);for(let s=0;s<t.length;s++)e.push(t[s].ss());return this.Na.store(STORAGE_KEYS.q.Ta,e)}Hh(t){return null!=t&&this.bo([t])}Ca(){let t=this.Na.lr(STORAGE_KEYS.q.Ta);this.Na.remove(STORAGE_KEYS.q.Ta),null==t&&(t=[]);const e=[];let s=!1,o=null;if(p(t))for(let s=0;s<t.length;s++)ue.ya(t[s])?e.push(ue.jn(t[s])):o=s;else s=!0;if(s||null!=o){let n="Stored events could not be deserialized as Events";s&&(n+=", was "+Object.prototype.toString.call(t)+" not an array"),null!=o&&(n+=", value at index "+o+" does not look like an event"),n+=", serialized values were of type "+typeof t+": "+JSON.stringify(t),e.push(new ue(null,r.A.ha,(new Date).valueOf(),null,{e:n}))}return e}B(t,e){return!!K(STORAGE_KEYS.q,t,"StorageManager cannot store object.","STORAGE_KEYS.OBJECTS")&&this.Na.store(t,e)}I(t){return!!K(STORAGE_KEYS.q,t,"StorageManager cannot retrieve object.","STORAGE_KEYS.OBJECTS")&&this.Na.lr(t)}$s(t){return!!K(STORAGE_KEYS.q,t,"StorageManager cannot remove object.","STORAGE_KEYS.OBJECTS")&&(this.Na.remove(t),!0)}clearData(){const t=Y(STORAGE_KEYS.Cr),e=Y(STORAGE_KEYS.q);for(let e=0;e<t.length;e++){const s=t[e];this.va.remove(STORAGE_KEYS.Cr[s])}for(let t=0;t<e.length;t++){const s=e[t];this.Na.remove(STORAGE_KEYS.q[s])}}Ua(t){return t||STORAGE_KEYS.q.Oa}ba(t){let e=this.Na.lr(STORAGE_KEYS.q.Aa);null==e&&(e={});const s=this.Ua(t[User.En]);for(let r in t)r===User.En||null!=e[s]&&null!=e[s][r]||this.Kr(t[User.En],r,t[r])}Kr(t,e,s){let r=this.Na.lr(STORAGE_KEYS.q.Aa);null==r&&(r={});const o=this.Ua(t);let n=r[o];if(null==n&&(n={},null!=t&&(n[User.En]=t)),e===User.Jr){null==n[e]&&(n[e]={});for(let t in s)n[e][t]=s[t]}else n[e]=s;return r[o]=n,this.Na.store(STORAGE_KEYS.q.Aa,r)}Ba(){const t=this.Na.lr(STORAGE_KEYS.q.Aa);this.Na.remove(STORAGE_KEYS.q.Aa);const e=[];for(let s in t)null!=t[s]&&e.push(t[s]);return e}Er(t){const e=this.Na.lr(STORAGE_KEYS.q.Aa);if(null!=e){const s=this.Ua(null),r=e[s];null!=r&&(e[s]=void 0,this.Na.store(STORAGE_KEYS.q.Aa,e),r[User.En]=t,this.ba(r))}const s=this._r(STORAGE_KEYS.Cr.Dh);let r=null;null!=s&&(r=s.Ir);const o=this.Ca();if(null!=o)for(let e=0;e<o.length;e++){const s=o[e];null==s.userId&&s.sessionId==r&&(s.userId=t),this.Hh(s)}}Fa(){return this.Na.La}}A.wa=class{constructor(t){this.ji=t,this.La=et.Pa()?3:10}xa(t){return t+"."+this.ji}store(t,e){const s={v:e};try{return localStorage.setItem(this.xa(t),JSON.stringify(s)),!0}catch(t){return r.D.info("Storage failure: "+t.message),!1}}lr(t){try{const e=JSON.parse(localStorage.getItem(this.xa(t)));return null==e?null:e.v}catch(t){return r.D.info("Storage retrieval failure: "+t.message),null}}remove(t){try{localStorage.removeItem(this.xa(t))}catch(t){return r.D.info("Storage removal failure: "+t.message),!1}}};A.ne=class{constructor(t,e){this.ji=t,this.Ja=this.ka(),this.za=576e3,this.Qa=!!e}xa(t){return null!=this.ji?t+"."+this.ji:t}ka(){let t=0,e=document.location.hostname;const s=e.split("."),r="ab._gd";for(;t<s.length-1&&-1===document.cookie.indexOf(r+"="+r);)t++,e="."+s.slice(-1-t).join("."),document.cookie=r+"="+r+";domain="+e+";";return document.cookie=r+"=;expires="+new Date(0).toGMTString()+";domain="+e+";",e}ie(){const t=new Date;return t.setTime(t.getTime()+60*this.za*1e3),t.getFullYear()}Va(){const t=At(STORAGE_KEYS.Cr),e=document.cookie.split(";");for(let s=0;s<e.length;s++){let r=e[s];for(;" "===r.charAt(0);)r=r.substring(1);let o=!1;for(let e=0;e<t.length;e++)if(0===r.indexOf(t[e])){o=!0;break}if(o){const t=r.split("=")[0];-1===t.indexOf("."+this.ji)&&this.Ha(t)}}}store(t,e){this.Va();const s=new Date;s.setTime(s.getTime()+60*this.za*1e3);const o="expires="+s.toUTCString(),n="domain="+this.Ja;let i;i=this.Qa?e:encodeURIComponent(JSON.stringify(e));const a=this.xa(t)+"="+i+";"+o+";"+n+";path=/";return a.length>=4093?(r.D.info("Storage failure: string is "+a.length+" chars which is too large to store as a cookie."),!1):(document.cookie=a,!0)}lr(t){const e=[],s=this.xa(t)+"=",o=document.cookie.split(";");for(let n=0;n<o.length;n++){let i=o[n];for(;" "===i.charAt(0);)i=i.substring(1);if(0===i.indexOf(s))try{let t;t=this.Qa?i.substring(s.length,i.length):JSON.parse(decodeURIComponent(i.substring(s.length,i.length))),e.push(t)}catch(e){return r.D.info("Storage retrieval failure: "+e.message),this.remove(t),null}}return e.length>0?e[e.length-1]:null}remove(t){this.Ha(this.xa(t))}Ha(t){const e=t+"=;expires="+new Date(0).toGMTString();document.cookie=e,document.cookie=e+";path=/";const s=e+";domain="+this.Ja;document.cookie=s,document.cookie=s+";path=/"}};A._a=class{constructor(){this.Wa={},this.Xa=5242880,this.La=3}store(t,e){const s={value:e},o=this.qa(e);return o>this.Xa?(r.D.info("Storage failure: object is ≈"+o+" bytes which is greater than the max of "+this.Xa),!1):(this.Wa[t]=s,!0)}qa(t){const e=[],s=[t];let r=0;for(;s.length;){const t=s.pop();if("boolean"==typeof t)r+=4;else if("string"==typeof t)r+=2*t.length;else if("number"==typeof t)r+=8;else if("object"==typeof t&&-1===e.indexOf(t)){e.push(t);for(let e in t)s.push(t[e])}}return r}lr(t){const e=this.Wa[t];return null==e?null:e.value}remove(t){this.Wa[t]=null}};A.Ea=class{constructor(t,e,s){this.Za=[],e&&this.Za.push(new A.ne(t)),s&&this.Za.push(new A.wa(t)),this.Za.push(new A._a(t))}store(t,e){let s=!0;for(let r=0;r<this.Za.length;r++)s=this.Za[r].store(t,e)&&s;return s}lr(t){for(let e=0;e<this.Za.length;e++){const s=this.Za[e].lr(t);if(null!=s)return s}return null}remove(t){for(let e=0;e<this.Za.length;e++)this.Za[e].remove(t)}};
@@ -1 +1 @@
1
- import r from"../../shared-lib/braze-shared-lib.js";export default class u{constructor(){this.Xs={}}Et(t){if("function"!=typeof t)return null;const i=r.nt.et();return this.Xs[i]=t,i}removeSubscription(t){delete this.Xs[t]}removeAllSubscriptions(){this.Xs={}}Nt(t){const i=[];for(let r in this.Xs)i.push(this.Xs[r](t));return i}}
1
+ import r from"../../shared-lib/braze-shared-lib.js";export default class u{constructor(){this.De={}}Et(t){if("function"!=typeof t)return null;const i=r.nt.et();return this.De[i]=t,i}removeSubscription(t){delete this.De[t]}removeAllSubscriptions(){this.De={}}Nt(t){const i=[];for(let r in this.De)i.push(this.De[r](t));return i}}
@@ -1 +1 @@
1
- import{isObject as Jt}from"../util/code-utils.js";import{convertMsToSeconds as l,timestampOrNow as Vt}from"../util/date-utils.js";export default class ue{constructor(t,i,s,r,e){this.userId=t,this.type=i,this.time=Vt(s),this.sessionId=r,this.data=e}Ye(){const t={name:this.type,time:l(this.time),data:this.data||{},session_id:this.sessionId};return null!=this.userId&&(t.user_id=this.userId),t}ss(){return{u:this.userId,t:this.type,ts:this.time,s:this.sessionId,d:this.data}}static fromJson(t){return new ue(t.user_id,t.name,t.time,t.session_id,t.data)}static ya(t){return null!=t&&Jt(t)&&null!=t.t&&""!==t.t}static An(t){return new ue(t.u,t.t,t.ts,t.s,t.d)}}
1
+ import{isObject as Jt}from"../util/code-utils.js";import{convertMsToSeconds as l,timestampOrNow as Vt}from"../util/date-utils.js";export default class ue{constructor(t,i,s,r,e){this.userId=t,this.type=i,this.time=Vt(s),this.sessionId=r,this.data=e}Zs(){const t={name:this.type,time:l(this.time),data:this.data||{},session_id:this.sessionId};return null!=this.userId&&(t.user_id=this.userId),t}ss(){return{u:this.userId,t:this.type,ts:this.time,s:this.sessionId,d:this.data}}static fromJson(t){return new ue(t.user_id,t.name,t.time,t.session_id,t.data)}static ya(t){return null!=t&&Jt(t)&&null!=t.t&&""!==t.t}static jn(t){return new ue(t.u,t.t,t.ts,t.s,t.d)}}
@@ -1 +1 @@
1
- import DeviceProperties from"../Core/device-properties.js";export default class Ie{constructor(s){this.id=s}Ye(){const s={};return null!=this[DeviceProperties.BROWSER]&&(s.browser=this[DeviceProperties.BROWSER]),null!=this[DeviceProperties.BROWSER_VERSION]&&(s.browser_version=this[DeviceProperties.BROWSER_VERSION]),null!=this[DeviceProperties.OS]&&(s.os_version=this[DeviceProperties.OS]),null!=this[DeviceProperties.RESOLUTION]&&(s.resolution=this[DeviceProperties.RESOLUTION]),null!=this[DeviceProperties.LANGUAGE]&&(s.locale=this[DeviceProperties.LANGUAGE]),null!=this[DeviceProperties.TIME_ZONE]&&(s.time_zone=this[DeviceProperties.TIME_ZONE]),null!=this[DeviceProperties.USER_AGENT]&&(s.user_agent=this[DeviceProperties.USER_AGENT]),s}}
1
+ import DeviceProperties from"../Core/device-properties.js";export default class Ie{constructor(s){this.id=s}Zs(){const s={};return null!=this[DeviceProperties.BROWSER]&&(s.browser=this[DeviceProperties.BROWSER]),null!=this[DeviceProperties.BROWSER_VERSION]&&(s.browser_version=this[DeviceProperties.BROWSER_VERSION]),null!=this[DeviceProperties.OS]&&(s.os_version=this[DeviceProperties.OS]),null!=this[DeviceProperties.RESOLUTION]&&(s.resolution=this[DeviceProperties.RESOLUTION]),null!=this[DeviceProperties.LANGUAGE]&&(s.locale=this[DeviceProperties.LANGUAGE]),null!=this[DeviceProperties.TIME_ZONE]&&(s.time_zone=this[DeviceProperties.TIME_ZONE]),null!=this[DeviceProperties.USER_AGENT]&&(s.user_agent=this[DeviceProperties.USER_AGENT]),s}}
@@ -1 +1 @@
1
- import r from"../../shared-lib/braze-shared-lib.js";export default class _t{constructor(t,e,s){null==t&&(t=r.nt.et()),s=parseInt(s),(isNaN(s)||0===s)&&(s=(new Date).valueOf()),this.Ir=t,this.xh=s,this._h=(new Date).valueOf(),this.Nh=e}ss(){return{g:this.Ir,e:this.Nh,c:this.xh,l:this._h}}static An(t){if(null==t||null==t.g)return null;const e=new _t(t.g,t.e,t.c);return e._h=t.l,e}}
1
+ import r from"../../shared-lib/braze-shared-lib.js";export default class _t{constructor(t,e,s){null==t&&(t=r.nt.et()),s=parseInt(s),(isNaN(s)||0===s)&&(s=(new Date).valueOf()),this.Ir=t,this.xh=s,this._h=(new Date).valueOf(),this.Nh=e}ss(){return{g:this.Ir,e:this.Nh,c:this.xh,l:this._h}}static jn(t){if(null==t||null==t.g)return null;const e=new _t(t.g,t.e,t.c);return e._h=t.l,e}}
@@ -1 +1 @@
1
- import{rehydrateDateAfterJsonization as w}from"../util/date-utils.js";export default class ei{constructor(t,i,l,s,u){this.endpoint=t||null,this.Wn=i||null,this.publicKey=l||null,this.tl=s||null,this.oh=u||null}ss(){return{e:this.endpoint,c:this.Wn,p:this.publicKey,u:this.tl,v:this.oh}}static An(t){return new ei(t.e,w(t.c),t.p,t.u,t.v)}}
1
+ import{rehydrateDateAfterJsonization as w}from"../util/date-utils.js";export default class ei{constructor(t,i,l,s,u){this.endpoint=t||null,this.An=i||null,this.publicKey=l||null,this.tl=s||null,this.oh=u||null}ss(){return{e:this.endpoint,c:this.An,p:this.publicKey,u:this.tl,v:this.oh}}static jn(t){return new ei(t.e,w(t.c),t.p,t.u,t.v)}}
@@ -1 +1 @@
1
- export default class jt{constructor(t,s,i,h,l,e,r){this.hh=t||0,this.gh=s||[],this.mh=i||[],this.fh=h||[],this.ph=l,null!=l&&""!==l||(this.ph=null),this.oh=e||null,this.uh=r||{}}ss(){return{s:"4.0.5",l:this.hh,e:this.gh,a:this.mh,p:this.fh,m:this.ph,v:this.oh,c:this.uh}}static An(t){let s=t.l;return"4.0.5"!==t.s&&(s=0),new jt(s,t.e,t.a,t.p,t.m,t.v,t.c)}}
1
+ export default class jt{constructor(t,s,i,h,l,e,r){this.hh=t||0,this.gh=s||[],this.mh=i||[],this.fh=h||[],this.ph=l,null!=l&&""!==l||(this.ph=null),this.oh=e||null,this.uh=r||{}}ss(){return{s:"4.0.6",l:this.hh,e:this.gh,a:this.mh,p:this.fh,m:this.ph,v:this.oh,c:this.uh}}static jn(t){let s=t.l;return"4.0.6"!==t.s&&(s=0),new jt(s,t.e,t.a,t.p,t.m,t.v,t.c)}}
@@ -1 +1 @@
1
- import b from"./util/net.js";import ue from"./models/braze-event.js";import s from"./common/event-logger.js";import{randomInclusive as lt}from"./util/math.js";import t from"./models/request-result.js";import r from"../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"./managers/storage-manager.js";import u from"./managers/subscription-manager.js";export default class Tt{constructor(t,s,i,e,n,l,h,o,r,a){this.yi=t,this.Do=s,this.sl=0,this.il=h.Fa(),this.hl=null,this.j=i,this.ji=e,this.v=n,this.wt=l,this.h=h,this.Wo=r,this.jt=a,this.ol=o,this.rl=new u,this.ul=50}al(t,s){return!t&&!s&&this.Wo.Rn()>=this.ul}cl(t){let s=this.j.Eh();if(t.length>0){const i=this.v.getUserId();for(const e of t){const t=!e.userId&&!i||e.userId===i;e.type===r.A.Wh&&t&&(s=!0)}}return s}dl(t,s,i,e,n,l,h){null==i&&(i=!0),i&&this.ml();const u=this.h.Ca(),a=this.h.Ba();let c=!1;const d=(t,s)=>{let h=!1;b.Fs({url:this.Do+"/data/",data:t,headers:s,S:i=>{null!=t.respond_with&&t.respond_with.triggers&&(this.sl=Math.max(this.sl-1,0)),this.jt.qs(t,i,s)?(this.Wo.Es(),this.wt.lh(i),null!=t.respond_with&&t.respond_with.user_id!=this.v.getUserId()||(null!=t.device&&this.h.B(o.q.Ho,t.device),null!=t.sdk_metadata&&(this.h.B(o.q.Yo,t.sdk_metadata),this.h.B(o.q.Zo,this.j.sa())),this.ol(i),"function"==typeof e&&e())):i.auth_error&&(h=!0)},error:()=>{null!=t.respond_with&&t.respond_with.triggers&&(this.sl=Math.max(this.sl-1,0)),this.jt.ia(t.events,t.attributes),"function"==typeof n&&n()},fl:t=>{if("function"==typeof l&&l(t),i&&!c){if(t&&!h)this.gl();else{let t=this.hl;(null==t||t<1e3*this.il)&&(t=1e3*this.il),this.gl(Math.min(3e5,lt(1e3*this.il,3*t)))}c=!0}}})},m=this.cl(u),f=s||m;if(this.al(h,m))return void r.D.info("Declining to flush data due to 50 consecutive authentication failures");if(i&&!this.jt.ma(u,a,t,f))return this.gl(),void("function"==typeof l&&l(!0));const g=this.jt.pa(t,f,u,a);f&&this.sl++;let p=!1;if(g)for(const t of g)this.jt.As(t.requestData,(()=>d(t.requestData,t.headers))),p=!0;this.Wo.Gn()&&i&&!p?this.gl():m&&(r.D.info("Invoking new session subscriptions"),this.rl.Nt())}bl(){return this.sl>0}gl(t){this.kl||(null==t&&(t=1e3*this.il),this.ml(),this.wl=setTimeout((()=>{if(document.hidden){const t="visibilitychange",s=()=>{document.hidden||(document.removeEventListener(t,s,!1),this.dl())};document.addEventListener(t,s,!1)}else this.dl()}),t),this.hl=t)}ml(){null!=this.wl&&(clearTimeout(this.wl),this.wl=null)}initialize(){this.kl=!1,this.gl()}destroy(){this.rl.removeAllSubscriptions(),this.Wo.On(),this.ml(),this.kl=!0,this.dl(null,null,!1),this.wl=null}cr(t){return this.rl.Et(t)}openSession(){const t=this.j.sa()!==this.j.mo();t&&(this.h.Ma(o.Cr.Go),this.h.Ma(o.Cr.Ur)),this.dl(null,!1,null,null,null),this.Un(),t&&import("./Push/push-manager-factory.js").then((t=>{if(this.kl)return;const s=t.default.Br();if(null!=s&&(s.isPushPermissionGranted()||s.isPushBlocked())){const t=()=>{s.Qi()?r.D.info("Push token maintenance is disabled, not refreshing token for backend."):s.subscribe()},i=(s,i)=>{i&&t()},e=()=>{const s=this.h.I(o.q.Nn);(null==s||s)&&t()},n=r.Ft.xt;new r.qt(n,r.D).hr(n.Pt.Nr,i,e)}}))}changeUser(t,s,i){const e=this.v.getUserId();if(e!==t){this.j.kh(),null!=e&&this.dl(null,!1,null,null,null),this.v.Er(t),i?this.Wo.setSdkAuthenticationSignature(i):this.Wo.Ln();for(let t=0;t<s.length;t++)s[t].changeUser(null==e);null!=e&&this.h.$s(o.q.P),this.h.$s(o.q.Ho),this.openSession(),r.D.info('Changed user to "'+t+'".')}else{let s="Doing nothing.";i&&this.Wo.Hn()!==i&&(this.Wo.setSdkAuthenticationSignature(i),s="Updated SDK authentication signature"),r.D.info(`Current user is already ${t}. ${s}`)}}requestImmediateDataFlush(t){this.ml(),this.j.mo(),this.dl(null,null,null,null,null,t,!0)}requestFeedRefresh(){this.j.mo(),this.dl(!0)}zr(t,s){this.j.mo(),r.D.info("Requesting explicit trigger refresh."),this.dl(null,!0,null,t,s)}Sr(t,i){const e=r.A.yl,n={a:t,l:i},l=s.G(e,n);return l&&r.D.info(`Logged alias ${t} with label ${i}`),l}Vr(i,e,n){if(this.wt.Hr(e))return r.D.info(`Custom Attribute "${e}" is blocklisted, ignoring.`),new t;const l={key:e,value:n},h=s.G(i,l);return h&&r.D.info(`Logged custom attribute: ${e} with value: ${n}`),h}setLastKnownLocation(t,i,e,n,l,h){const o={latitude:i,longitude:e};null!=n&&(o.altitude=n),null!=l&&(o.ll_accuracy=l),null!=h&&(o.alt_accuracy=h);const u=s.G(r.A.vl,o,t);return u&&r.D.info(`Set user last known location as ${JSON.stringify(o,null,2)}`),u}kr(t,s){const i=this.j.mo();return new ue(this.v.getUserId(),r.A.Sl,t,i,{cid:s})}Un(){const t=r.Ft.xt;new r.qt(t,r.D).setItem(t.Pt.jl,1,{baseUrl:this.Do,data:{api_key:this.yi,device_id:this.ji.te().id},userId:this.v.getUserId(),sdkAuthEnabled:this.Wo.Gn()})}wr(t){for(const s of t)if(s.api_key===this.yi)this.jt.ia(s.events,s.attributes);else{const t=r.Ft.xt;new r.qt(t,r.D).setItem(t.Pt.$r,r.nt.et(),s)}}Zr(i,e,n){if(this.wt.Hr(i))return r.D.info(`Custom Attribute "${i}" is blocklisted, ignoring.`),new t;let l,h;return null===e&&null===n?(l=r.A.$l,h={key:i}):(l=r.A.Al,h={key:i,latitude:e,longitude:n}),s.G(l,h)}Cn(t,i){const e={group_id:t,status:i};return s.G(r.A.Cl,e)}}
1
+ import b from"./util/net.js";import ue from"./models/braze-event.js";import s from"./common/event-logger.js";import{randomInclusive as lt}from"./util/math.js";import t from"./models/request-result.js";import r from"../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"./managers/storage-manager.js";import u from"./managers/subscription-manager.js";export default class Tt{constructor(t,s,i,e,n,l,h,o,r,a){this.ji=t,this.Do=s,this.sl=0,this.il=h.Fa(),this.hl=null,this.j=i,this.xi=e,this.v=n,this.wt=l,this.h=h,this.Wo=r,this.jt=a,this.ol=o,this.rl=new u,this.ul=50}al(t,s){return!t&&!s&&this.Wo.Rn()>=this.ul}cl(t){let s=this.j.Eh();if(t.length>0){const i=this.v.getUserId();for(const e of t){const t=!e.userId&&!i||e.userId===i;e.type===r.A.Wh&&t&&(s=!0)}}return s}dl(t,s,i,e,n,l,h){null==i&&(i=!0),i&&this.ml();const u=this.h.Ca(),a=this.h.Ba();let c=!1;const d=(t,s)=>{let h=!1;b.Fs({url:this.Do+"/data/",data:t,headers:s,S:i=>{null!=t.respond_with&&t.respond_with.triggers&&(this.sl=Math.max(this.sl-1,0)),this.jt.qs(t,i,s)?(this.Wo.Es(),this.wt.lh(i),null!=t.respond_with&&t.respond_with.user_id!=this.v.getUserId()||(null!=t.device&&this.h.B(o.q.Ho,t.device),null!=t.sdk_metadata&&(this.h.B(o.q.Yo,t.sdk_metadata),this.h.B(o.q.Zo,this.j.sa())),this.ol(i),"function"==typeof e&&e())):i.auth_error&&(h=!0)},error:()=>{null!=t.respond_with&&t.respond_with.triggers&&(this.sl=Math.max(this.sl-1,0)),this.jt.ia(t.events,t.attributes),"function"==typeof n&&n()},fl:t=>{if("function"==typeof l&&l(t),i&&!c){if(t&&!h)this.gl();else{let t=this.hl;(null==t||t<1e3*this.il)&&(t=1e3*this.il),this.gl(Math.min(3e5,lt(1e3*this.il,3*t)))}c=!0}}})},m=this.cl(u),f=s||m;if(this.al(h,m))return void r.D.info("Declining to flush data due to 50 consecutive authentication failures");if(i&&!this.jt.ma(u,a,t,f))return this.gl(),void("function"==typeof l&&l(!0));const g=this.jt.pa(t,f,u,a);f&&this.sl++;let p=!1;if(g)for(const t of g)this.jt.As(t.requestData,(()=>d(t.requestData,t.headers))),p=!0;this.Wo.Gn()&&i&&!p?this.gl():m&&(r.D.info("Invoking new session subscriptions"),this.rl.Nt())}bl(){return this.sl>0}gl(t){this.kl||(null==t&&(t=1e3*this.il),this.ml(),this.wl=setTimeout((()=>{if(document.hidden){const t="visibilitychange",s=()=>{document.hidden||(document.removeEventListener(t,s,!1),this.dl())};document.addEventListener(t,s,!1)}else this.dl()}),t),this.hl=t)}ml(){null!=this.wl&&(clearTimeout(this.wl),this.wl=null)}initialize(){this.kl=!1,this.gl()}destroy(){this.rl.removeAllSubscriptions(),this.Wo.On(),this.ml(),this.kl=!0,this.dl(null,null,!1),this.wl=null}cr(t){return this.rl.Et(t)}openSession(){const t=this.j.sa()!==this.j.mo();t&&(this.h.Ma(o.Cr.Go),this.h.Ma(o.Cr.Ur)),this.dl(null,!1,null,null,null),this.In(),t&&import("./Push/push-manager-factory.js").then((t=>{if(this.kl)return;const s=t.default.Xe();if(null!=s&&(s.isPushPermissionGranted()||s.isPushBlocked())){const t=()=>{s.Xi()?r.D.info("Push token maintenance is disabled, not refreshing token for backend."):s.subscribe()},i=(s,i)=>{i&&t()},e=()=>{const s=this.h.I(o.q.Wn);(null==s||s)&&t()},n=r.Ft.xt;new r.qt(n,r.D).hr(n.Pt.Mr,i,e)}}))}changeUser(t,s,i){const e=this.v.getUserId();if(e!==t){this.j.kh(),null!=e&&this.dl(null,!1,null,null,null),this.v.Br(t),i?this.Wo.setSdkAuthenticationSignature(i):this.Wo.Ln();for(let t=0;t<s.length;t++)s[t].changeUser(null==e);null!=e&&this.h.$s(o.q.P),this.h.$s(o.q.Ho),this.openSession(),r.D.info('Changed user to "'+t+'".')}else{let s="Doing nothing.";i&&this.Wo.Hn()!==i&&(this.Wo.setSdkAuthenticationSignature(i),s="Updated SDK authentication signature"),r.D.info(`Current user is already ${t}. ${s}`)}}requestImmediateDataFlush(t){this.ml(),this.j.mo(),this.dl(null,null,null,null,null,t,!0)}requestFeedRefresh(){this.j.mo(),this.dl(!0)}zr(t,s){this.j.mo(),r.D.info("Requesting explicit trigger refresh."),this.dl(null,!0,null,t,s)}Nr(t,i){const e=r.A.yl,n={a:t,l:i},l=s.G(e,n);return l&&r.D.info(`Logged alias ${t} with label ${i}`),l}Or(i,e,n){if(this.wt.Gr(e))return r.D.info(`Custom Attribute "${e}" is blocklisted, ignoring.`),new t;const l={key:e,value:n},h=s.G(i,l);return h&&r.D.info(`Logged custom attribute: ${e} with value: ${n}`),h}setLastKnownLocation(t,i,e,n,l,h){const o={latitude:i,longitude:e};null!=n&&(o.altitude=n),null!=l&&(o.ll_accuracy=l),null!=h&&(o.alt_accuracy=h);const u=s.G(r.A.vl,o,t);return u&&r.D.info(`Set user last known location as ${JSON.stringify(o,null,2)}`),u}kr(t,s){const i=this.j.mo();return new ue(this.v.getUserId(),r.A.Sl,t,i,{cid:s})}In(){const t=r.Ft.xt;new r.qt(t,r.D).setItem(t.Pt.jl,1,{baseUrl:this.Do,data:{api_key:this.ji,device_id:this.xi.te().id},userId:this.v.getUserId(),sdkAuthEnabled:this.Wo.Gn()})}wr(t){for(const s of t)if(s.api_key===this.ji)this.jt.ia(s.events,s.attributes);else{const t=r.Ft.xt;new r.qt(t,r.D).setItem(t.Pt.$r,r.nt.et(),s)}}Xr(i,e,n){if(this.wt.Gr(i))return r.D.info(`Custom Attribute "${i}" is blocklisted, ignoring.`),new t;let l,h;return null===e&&null===n?(l=r.A.$l,h={key:i}):(l=r.A.Al,h={key:i,latitude:e,longitude:n}),s.G(l,h)}Zr(t,i){const e={group_id:t,status:i};return s.G(r.A.Cl,e)}}
@@ -1 +1 @@
1
- import kt from"./filter.js";import{isArray as p}from"../../util/code-utils.js";export default class Bt{constructor(t){this.filters=t}zl(t){let r=!0;for(let e=0;e<this.filters.length;e++){const o=this.filters[e];let s=!1;for(let r=0;r<o.length;r++)if(o[r].zl(t)){s=!0;break}if(!s){r=!1;break}}return r}static fromJson(t){if(null==t||!p(t))return null;const r=[];for(let e=0;e<t.length;e++){const o=[],s=t[e];for(let t=0;t<s.length;t++)o.push(kt.fromJson(s[t]));r.push(o)}return new Bt(r)}ss(){const t=[];for(let r=0;r<this.filters.length;r++){const e=this.filters[r],o=[];for(let t=0;t<e.length;t++)o.push(e[t].ss());t.push(o)}return t}static An(t){const r=[];for(let e=0;e<t.length;e++){const o=[],s=t[e];for(let t=0;t<s.length;t++)o.push(kt.An(s[t]));r.push(o)}return new Bt(r)}}
1
+ import kt from"./filter.js";import{isArray as p}from"../../util/code-utils.js";export default class Bt{constructor(t){this.filters=t}zl(t){let r=!0;for(let e=0;e<this.filters.length;e++){const o=this.filters[e];let s=!1;for(let r=0;r<o.length;r++)if(o[r].zl(t)){s=!0;break}if(!s){r=!1;break}}return r}static fromJson(t){if(null==t||!p(t))return null;const r=[];for(let e=0;e<t.length;e++){const o=[],s=t[e];for(let t=0;t<s.length;t++)o.push(kt.fromJson(s[t]));r.push(o)}return new Bt(r)}ss(){const t=[];for(let r=0;r<this.filters.length;r++){const e=this.filters[r],o=[];for(let t=0;t<e.length;t++)o.push(e[t].ss());t.push(o)}return t}static jn(t){const r=[];for(let e=0;e<t.length;e++){const o=[],s=t[e];for(let t=0;t<s.length;t++)o.push(kt.jn(s[t]));r.push(o)}return new Bt(r)}}
@@ -1 +1 @@
1
- import{isDate as yt}from"../../util/code-utils.js";import{convertMsToSeconds as l,dateFromUnixTimestamp as h,secondsAgo as Ht,secondsInTheFuture as Ut}from"../../util/date-utils.js";export default class kt{constructor(t,s,e,i){this.El=t,this.Tl=s,this.comparator=e,this._l=i,this.Tl===kt.Ml.Nl&&this.comparator!==kt.Hl.Rl&&this.comparator!==kt.Hl.Ll&&this.comparator!==kt.Hl.Il&&this.comparator!==kt.Hl.Ol&&(this._l=h(this._l))}zl(t){let s=null;switch(null!=t&&(s=t[this.El]),this.comparator){case kt.Hl.Ul:return null!=s&&s.valueOf()===this._l.valueOf();case kt.Hl.Dl:return null==s||s.valueOf()!==this._l.valueOf();case kt.Hl.Ql:return typeof s==typeof this._l&&s>this._l;case kt.Hl.Rl:return this.Tl===kt.Ml.Nl?null!=s&&yt(s)&&Ht(s)<=this._l:typeof s==typeof this._l&&s>=this._l;case kt.Hl.Xl:return typeof s==typeof this._l&&s<this._l;case kt.Hl.Ll:return this.Tl===kt.Ml.Nl?null!=s&&yt(s)&&Ht(s)>=this._l:typeof s==typeof this._l&&s<=this._l;case kt.Hl.Gl:return null!=s&&"string"==typeof s&&typeof s==typeof this._l&&null!=s.match(this._l);case kt.Hl.Fl:return null!=s;case kt.Hl.Jl:return null==s;case kt.Hl.Il:return null!=s&&yt(s)&&Ut(s)<this._l;case kt.Hl.Ol:return null!=s&&yt(s)&&Ut(s)>this._l;case kt.Hl.Vl:return null==s||typeof s!=typeof this._l||"string"!=typeof s||null==s.match(this._l)}return!1}static fromJson(t){return new kt(t.property_key,t.property_type,t.comparator,t.property_value)}ss(){let t=this._l;return yt(this._l)&&(t=l(t.valueOf())),{k:this.El,t:this.Tl,c:this.comparator,v:t}}static An(t){return new kt(t.k,t.t,t.c,t.v)}}kt.Hl={Ul:1,Dl:2,Ql:3,Rl:4,Xl:5,Ll:6,Gl:10,Fl:11,Jl:12,Il:15,Ol:16,Vl:17},kt.Ml={ql:"boolean",Kl:"number",Pl:"string",Nl:"date"};
1
+ import{isDate as yt}from"../../util/code-utils.js";import{convertMsToSeconds as l,dateFromUnixTimestamp as h,secondsAgo as Ht,secondsInTheFuture as Ut}from"../../util/date-utils.js";export default class kt{constructor(t,s,e,i){this.El=t,this.Tl=s,this.comparator=e,this._l=i,this.Tl===kt.Ml.Nl&&this.comparator!==kt.Hl.Rl&&this.comparator!==kt.Hl.Ll&&this.comparator!==kt.Hl.Il&&this.comparator!==kt.Hl.Ol&&(this._l=h(this._l))}zl(t){let s=null;switch(null!=t&&(s=t[this.El]),this.comparator){case kt.Hl.Ul:return null!=s&&s.valueOf()===this._l.valueOf();case kt.Hl.Dl:return null==s||s.valueOf()!==this._l.valueOf();case kt.Hl.Ql:return typeof s==typeof this._l&&s>this._l;case kt.Hl.Rl:return this.Tl===kt.Ml.Nl?null!=s&&yt(s)&&Ht(s)<=this._l:typeof s==typeof this._l&&s>=this._l;case kt.Hl.Xl:return typeof s==typeof this._l&&s<this._l;case kt.Hl.Ll:return this.Tl===kt.Ml.Nl?null!=s&&yt(s)&&Ht(s)>=this._l:typeof s==typeof this._l&&s<=this._l;case kt.Hl.Gl:return null!=s&&"string"==typeof s&&typeof s==typeof this._l&&null!=s.match(this._l);case kt.Hl.Fl:return null!=s;case kt.Hl.Jl:return null==s;case kt.Hl.Il:return null!=s&&yt(s)&&Ut(s)<this._l;case kt.Hl.Ol:return null!=s&&yt(s)&&Ut(s)>this._l;case kt.Hl.Vl:return null==s||typeof s!=typeof this._l||"string"!=typeof s||null==s.match(this._l)}return!1}static fromJson(t){return new kt(t.property_key,t.property_type,t.comparator,t.property_value)}ss(){let t=this._l;return yt(this._l)&&(t=l(t.valueOf())),{k:this.El,t:this.Tl,c:this.comparator,v:t}}static jn(t){return new kt(t.k,t.t,t.c,t.v)}}kt.Hl={Ul:1,Dl:2,Ql:3,Rl:4,Xl:5,Ll:6,Gl:10,Fl:11,Jl:12,Il:15,Ol:16,Vl:17},kt.Ml={ql:"boolean",Kl:"number",Pl:"string",Nl:"date"};
@@ -1 +1 @@
1
- import xt from"./custom-event-data.js";import Mt from"./custom-event-property-data.js";import Bt from"./filter-set.js";import Ft from"./in-app-message-click-data.js";import Gt from"./purchase-data.js";import Kt from"./purchase-property-data.js";import Qt from"./push-click-data.js";import Q from"./trigger-events.js";import r from"../../../shared-lib/braze-shared-lib.js";export default class Dt{constructor(e,t){this.type=e,this.data=t}$a(e,t){return Dt.ec[this.type]===e&&(null==this.data||this.data.zl(t))}static Zl(e,t){let a=null;try{a=window.atob(e)}catch(t){return r.D.info("Failed to unencode analytics id "+e+": "+t.message),!1}return t===a.split("_")[0]}static fromJson(e){const t=e.type;let r;switch(t){case Dt.tc.OPEN:r=null;break;case Dt.tc.Rr:r=Gt.fromJson(e.data);break;case Dt.tc.rc:r=Kt.fromJson(e.data);break;case Dt.tc.vr:r=Qt.fromJson(e.data);break;case Dt.tc.be:r=xt.fromJson(e.data);break;case Dt.tc.ac:r=Mt.fromJson(e.data);break;case Dt.tc.Ar:r=Ft.fromJson(e.data);break;case Dt.tc.ks:r=null}return new Dt(t,r)}ss(){return{t:this.type,d:this.data?this.data.ss():null}}static An(e){let t,r;switch(e.t){case Dt.tc.OPEN:t=null;break;case Dt.tc.Rr:t=new Gt(e.d);break;case Dt.tc.rc:r=e.d||{},t=new Kt(r.id,Bt.An(r.pf||[]));break;case Dt.tc.vr:t=new Qt(e.d);break;case Dt.tc.be:t=new xt(e.d);break;case Dt.tc.ac:r=e.d||{},t=new Mt(r.e,Bt.An(r.pf||[]));break;case Dt.tc.Ar:t=new Ft(e.d);break;case Dt.tc.ks:t=null}return new Dt(e.t,t)}}Dt.tc={OPEN:"open",Rr:"purchase",rc:"purchase_property",vr:"push_click",be:"custom_event",ac:"custom_event_property",Ar:"iam_click",ks:"test"},Dt.ec={},Dt.ec[Dt.tc.OPEN]=Q.OPEN,Dt.ec[Dt.tc.Rr]=Q.Rr,Dt.ec[Dt.tc.rc]=Q.Rr,Dt.ec[Dt.tc.vr]=Q.vr,Dt.ec[Dt.tc.be]=Q.be,Dt.ec[Dt.tc.ac]=Q.be,Dt.ec[Dt.tc.Ar]=Q.Ar,Dt.ec[Dt.tc.ks]=Q.ks;
1
+ import xt from"./custom-event-data.js";import Mt from"./custom-event-property-data.js";import Bt from"./filter-set.js";import Ft from"./in-app-message-click-data.js";import Gt from"./purchase-data.js";import Kt from"./purchase-property-data.js";import Qt from"./push-click-data.js";import Q from"./trigger-events.js";import r from"../../../shared-lib/braze-shared-lib.js";export default class Dt{constructor(e,t){this.type=e,this.data=t}$a(e,t){return Dt.ec[this.type]===e&&(null==this.data||this.data.zl(t))}static Zl(e,t){let a=null;try{a=window.atob(e)}catch(t){return r.D.info("Failed to unencode analytics id "+e+": "+t.message),!1}return t===a.split("_")[0]}static fromJson(e){const t=e.type;let r;switch(t){case Dt.tc.OPEN:r=null;break;case Dt.tc.Rr:r=Gt.fromJson(e.data);break;case Dt.tc.rc:r=Kt.fromJson(e.data);break;case Dt.tc.vr:r=Qt.fromJson(e.data);break;case Dt.tc.be:r=xt.fromJson(e.data);break;case Dt.tc.ac:r=Mt.fromJson(e.data);break;case Dt.tc.Ar:r=Ft.fromJson(e.data);break;case Dt.tc.ks:r=null}return new Dt(t,r)}ss(){return{t:this.type,d:this.data?this.data.ss():null}}static jn(e){let t,r;switch(e.t){case Dt.tc.OPEN:t=null;break;case Dt.tc.Rr:t=new Gt(e.d);break;case Dt.tc.rc:r=e.d||{},t=new Kt(r.id,Bt.jn(r.pf||[]));break;case Dt.tc.vr:t=new Qt(e.d);break;case Dt.tc.be:t=new xt(e.d);break;case Dt.tc.ac:r=e.d||{},t=new Mt(r.e,Bt.jn(r.pf||[]));break;case Dt.tc.Ar:t=new Ft(e.d);break;case Dt.tc.ks:t=null}return new Dt(e.t,t)}}Dt.tc={OPEN:"open",Rr:"purchase",rc:"purchase_property",vr:"push_click",be:"custom_event",ac:"custom_event_property",Ar:"iam_click",ks:"test"},Dt.ec={},Dt.ec[Dt.tc.OPEN]=Q.OPEN,Dt.ec[Dt.tc.Rr]=Q.Rr,Dt.ec[Dt.tc.rc]=Q.Rr,Dt.ec[Dt.tc.vr]=Q.vr,Dt.ec[Dt.tc.be]=Q.be,Dt.ec[Dt.tc.ac]=Q.be,Dt.ec[Dt.tc.Ar]=Q.Ar,Dt.ec[Dt.tc.ks]=Q.ks;
@@ -1 +1 @@
1
- import{dateFromUnixTimestamp as h,rehydrateDateAfterJsonization as w}from"../../util/date-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";import Dt from"./trigger-condition.js";import{validateValueIsFromEnum as K}from"../../util/code-utils.js";export default class ut{constructor(t,i,s,e,r,l,o,n,h,a,u,d){this.id=t,this.Th=i||[],void 0===s&&(s=null),this.startTime=s,void 0===e&&(e=null),this.endTime=e,this.priority=r||0,this.type=l,this.Ph=n||0,null==a&&(a=1e3*(this.Ph+30)),this.ai=a,this.data=o,null==h&&(h=ut.yh),this.Ah=h,this.Ih=u,this.$h=d||null}Mh(t){return null==this.$h||this.Ah!==ut.yh&&t-this.$h>=1e3*this.Ah}Bh(t){this.$h=t}Jh(t){const i=t+1e3*this.Ph;return Math.max(i-(new Date).valueOf(),0)}Lh(t){const i=(new Date).valueOf()-t,s=null==t||isNaN(i)||null==this.ai||i<this.ai;return s||r.D.info(`Trigger action ${this.type} is no longer eligible for display - fired ${i}ms ago and has a timeout of ${this.ai}ms.`),!s}static fromJson(t){const i=t.id,s=[];for(let i=0;i<t.trigger_condition.length;i++)s.push(Dt.fromJson(t.trigger_condition[i]));const e=h(t.start_time),r=h(t.end_time),l=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 K(ut.ii,o,"Could not construct Trigger from server data","Trigger.Types")?new ut(i,s,e,r,l,o,d,n,a,u,m):null}ss(){const t=[];for(let i=0;i<this.Th.length;i++)t.push(this.Th[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.Ph,r:this.Ah,tm:this.ai,ss:this.Ih,ld:this.$h}}static An(t){const i=[];for(let s=0;s<t.c.length;s++)i.push(Dt.An(t.c[s]));return new ut(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)}}ut.yh=-1,ut.ii={ei:"inapp",Rh:"templated_iam"};
1
+ import{dateFromUnixTimestamp as h,rehydrateDateAfterJsonization as w}from"../../util/date-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";import Dt from"./trigger-condition.js";import{validateValueIsFromEnum as K}from"../../util/code-utils.js";export default class ut{constructor(t,i,s,e,r,l,o,n,h,a,u,d){this.id=t,this.Th=i||[],void 0===s&&(s=null),this.startTime=s,void 0===e&&(e=null),this.endTime=e,this.priority=r||0,this.type=l,this.Ph=n||0,null==a&&(a=1e3*(this.Ph+30)),this.li=a,this.data=o,null==h&&(h=ut.yh),this.Ah=h,this.Ih=u,this.$h=d||null}Mh(t){return null==this.$h||this.Ah!==ut.yh&&t-this.$h>=1e3*this.Ah}Bh(t){this.$h=t}Jh(t){const i=t+1e3*this.Ph;return Math.max(i-(new Date).valueOf(),0)}Lh(t){const i=(new Date).valueOf()-t,s=null==t||isNaN(i)||null==this.li||i<this.li;return s||r.D.info(`Trigger action ${this.type} is no longer eligible for display - fired ${i}ms ago and has a timeout of ${this.li}ms.`),!s}static fromJson(t){const i=t.id,s=[];for(let i=0;i<t.trigger_condition.length;i++)s.push(Dt.fromJson(t.trigger_condition[i]));const e=h(t.start_time),r=h(t.end_time),l=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 K(ut.ri,o,"Could not construct Trigger from server data","Trigger.Types")?new ut(i,s,e,r,l,o,d,n,a,u,m):null}ss(){const t=[];for(let i=0;i<this.Th.length;i++)t.push(this.Th[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.Ph,r:this.Ah,tm:this.li,ss:this.Ih,ld:this.$h}}static jn(t){const i=[];for(let s=0;s<t.c.length;s++)i.push(Dt.jn(t.c[s]));return new ut(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)}}ut.yh=-1,ut.ri={ii:"inapp",Rh:"templated_iam"};
@@ -1 +1 @@
1
- import pe from"../InAppMessage/in-app-message-manager-factory.js";import e,{OPTIONS as D}from"../managers/braze-instance.js";import ir from"./triggers-provider.js";export const TriggersProviderFactory={t:!1,provider:null,er:()=>(TriggersProviderFactory.init(),TriggersProviderFactory.provider),rg:()=>{if(!TriggersProviderFactory.provider){const r=e.nn(D.po);TriggersProviderFactory.provider=new ir(null!=r?r:30,pe.m().De(),e.l(),e.mr(),pe.m()),e.ar(TriggersProviderFactory.provider)}},init:()=>{TriggersProviderFactory.t||(TriggersProviderFactory.rg(),e.u(TriggersProviderFactory),TriggersProviderFactory.t=!0)},destroy:()=>{TriggersProviderFactory.provider=null,TriggersProviderFactory.t=!1}};
1
+ import pe from"../InAppMessage/in-app-message-manager-factory.js";import e,{OPTIONS as D}from"../managers/braze-instance.js";import ir from"./triggers-provider.js";export const TriggersProviderFactory={t:!1,provider:null,er:()=>(TriggersProviderFactory.init(),TriggersProviderFactory.provider),rg:()=>{if(!TriggersProviderFactory.provider){const r=e.nn(D.po);TriggersProviderFactory.provider=new ir(null!=r?r:30,pe.m().Be(),e.l(),e.mr(),pe.m()),e.ar(TriggersProviderFactory.provider)}},init:()=>{TriggersProviderFactory.t||(TriggersProviderFactory.rg(),e.u(TriggersProviderFactory),TriggersProviderFactory.t=!0)},destroy:()=>{TriggersProviderFactory.provider=null,TriggersProviderFactory.t=!1}};
@@ -1 +1 @@
1
- import C from"../common/base-provider.js";import{newInAppMessageFromJson as it}from"../InAppMessage/in-app-message-factory.js";import ue from"../models/braze-event.js";import{InAppMessage}from"../InAppMessage/index.js";import{isArray as p,isEqual as ii,validateValueIsFromEnum as K}from"../util/code-utils.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import ft from"../InAppMessage/models/templated-in-app-message.js";import ut from"./models/trigger.js";import Q from"./models/trigger-events.js";import r from"../../shared-lib/braze-shared-lib.js";export default class ir extends C{constructor(t,i,s,e,r){super(),this.Oh=t,this.vt=i,this.h=s,this.Is=e,this.Uh=r,this.Kh=[],this.Qh=[],this.Vh=null,this.Xh={},this.Yh={},this.Zh(),this.tg()}ig(){this.Vh=this.h.I(o.q.Da)||this.Vh,this.Xh=this.h.I(o.q.Ga)||this.Xh,this.Yh=this.h.I(o.q.Ya)||this.Yh;for(let t=0;t<this.sg.length;t++){const i=this.sg[t];null!=this.Yh[i.id]&&i.Bh(this.Yh[i.id])}}Zh(){this.eg=this.h.I(o.q.Ka)||0;const t=this.h.I(o.q.Ia)||[],i=[];for(let s=0;s<t.length;s++)i.push(ut.An(t[s]));this.sg=i,this.ig()}tg(){const t=this,i=function(i,s,e,r,h){return function(){t.hg(i,s,e,r,h)}},s={};for(let t=0;t<this.sg.length;t++)s[this.sg[t].id]=this.sg[t];let e=!1;for(let t=0;t<this.sg.length;t++){const r=this.sg[t];if(null!=this.Xh[r.id]){const t=this.Xh[r.id],h=[];for(let e=0;e<t.length;e++){const o=t[e],n=r.Jh(o.oi);if(n>0){let t,e;h.push(o),null!=o.og&&(t=o.og),null!=o.ng&&ue.ya(o.ng)&&(e=ue.An(o.ng));const l=[];if(p(o.lg))for(let t=0;t<o.lg.length;t++){const i=s[o.lg[t]];null!=i&&l.push(i)}this.Qh.push(setTimeout(i(r,o.oi,t,e,l),n))}}this.Xh[r.id].length>h.length&&(this.Xh[r.id]=h,e=!0,0===this.Xh[r.id].length&&delete this.Xh[r.id])}}e&&this.h.B(o.q.Ga,this.Xh)}ag(){const t=[];for(let i=0;i<this.sg.length;i++)t.push(this.sg[i].ss());this.eg=(new Date).valueOf(),this.h.B(o.q.Ia,t),this.h.B(o.q.Ka,this.eg)}gg(){(this.h.I(o.q.Ka)||0)>this.eg?this.Zh():this.ig()}_s(t){let i=!1;if(null!=t&&t.triggers){this.ig();const s={},e={};this.sg=[];for(let r=0;r<t.triggers.length;r++){const h=ut.fromJson(t.triggers[r]);null!=this.Yh[h.id]&&(h.Bh(this.Yh[h.id]),s[h.id]=this.Yh[h.id]),null!=this.Xh[h.id]&&(e[h.id]=this.Xh[h.id]);for(let t=0;t<h.Th.length;t++)if(h.Th[t].$a(Q.ks,null)){i=!0;break}null!=h&&this.sg.push(h)}ii(this.Yh,s)||(this.Yh=s,this.h.B(o.q.Ya,this.Yh)),ii(this.Xh,e)||(this.Xh=e,this.h.B(o.q.Ga,this.Xh)),this.ag(),i&&(r.D.info("Trigger with test condition found, firing test."),this.je(Q.ks)),this.je(Q.OPEN);const h=this.Kh;this.Kh=[];for(let t=0;t<h.length;t++)this.je.apply(this,h[t])}}async hg(t,i,s,e,h){const o=e=>{this.ig();const h=(new Date).valueOf();if(!t.Lh(i))return!1===navigator.onLine&&t.type===ut.ii.ei&&e.imageUrl?(r.D.info(`Not showing ${t.type} trigger action ${t.id} due to offline state.`),void this.Uh.Fe(t.id,InAppMessage.Ge.Fi)):void(t.Mh(h)&&this.fg(t,h,s)?(this.vt.Nt([e]),this.cg(t,h)):r.D.info(`Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`));t.type===ut.ii.Rh?this.Uh.Fe(t.id,InAppMessage.Ge.Ze):this.Uh.Fe(t.id,InAppMessage.Ge.Bi)},n=()=>{this.ig();const o=h.pop();if(null!=o)if(this.ug(o,i,s,e,h),o.Lh(i)){let t=`Server aborted in-app message display, but the timeout on fallback trigger ${o.id} has already elapsed.`;h.length>0&&(t+=" Continuing to fall back."),r.D.info(t),this.Uh.Fe(o.id,InAppMessage.Ge.Bi),n()}else{r.D.info(`Server aborted in-app message display. Falling back to lower priority ${o.type} trigger action ${t.id}.`);const n=1e3*o.Ph-((new Date).valueOf()-i);n>0?this.Qh.push(setTimeout((()=>{this.hg(o,i,s,e,h)}),n)):this.hg(o,i,s,e,h)}};switch(t.type){case ut.ii.ei:const h=it(t.data);if(null==h){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Uh.Fe(t.id,InAppMessage.Ge.ri);break}let l=await this.Uh.Ke(h);if(l){r.D.error(l),n();break}o(h);break;case ut.ii.Rh:const a=ft.fromJson(t.data,o,n,i,t.ai);if(null==a){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Uh.Fe(t.id,InAppMessage.Ge.ri);break}this.Uh.We(a,s,e);break;default:r.D.error(`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`),this.Uh.Fe(t.id,InAppMessage.Ge.ri)}}je(t,i,s){if(!K(Q,t,"Cannot fire trigger action.","TriggerEvents"))return;if(this.Is.bl())return r.D.info("Trigger sync is currently in progress, awaiting sync completion before firing trigger event."),void this.Kh.push(arguments);this.gg();const e=(new Date).valueOf(),h=e-this.Vh;let o=!0,n=!0;const l=[];for(let s=0;s<this.sg.length;s++){const r=this.sg[s],h=e+1e3*r.Ph;if(r.Mh(h)&&(null==r.startTime||r.startTime<=e)&&(null==r.endTime||r.endTime>=e)){let s=!1;for(let e=0;e<r.Th.length;e++)if(r.Th[e].$a(t,i)){s=!0;break}s&&(o=!1,this.fg(r,h,t)&&(n=!1,l.push(r)))}}if(o)return void r.D.info(`Trigger event ${t} did not match any trigger conditions.`);if(n)return void r.D.info(`Ignoring ${t} trigger event because a trigger was displayed ${h/1e3}s ago.`);l.sort(((t,i)=>t.priority-i.priority));const a=l.pop();null!=a&&(r.D.info(`Firing ${a.type} trigger action ${a.id} from trigger event ${t}.`),this.ug(a,e,t,s,l),0===a.Ph?this.hg(a,e,t,s,l):this.Qh.push(setTimeout((()=>{this.hg(a,e,t,s,l)}),1e3*a.Ph)))}changeUser(t){if(this.sg=[],this.h.$s(o.q.Ia),!t){this.Kh=[],this.Vh=null,this.Yh={},this.Xh={};for(let t=0;t<this.Qh.length;t++)clearTimeout(this.Qh[t]);this.Qh=[],this.h.$s(o.q.Da),this.h.$s(o.q.Ya),this.h.$s(o.q.Ga)}}clearData(){this.sg=[],this.Vh=null,this.Yh={},this.Xh={};for(let t=0;t<this.Qh.length;t++)clearTimeout(this.Qh[t]);this.Qh=[]}fg(t,i,s){if(null==this.Vh)return!0;if(s===Q.ks)return r.D.info("Ignoring minimum interval between trigger because it is a test type."),!0;let e=t.Ih;return null==e&&(e=this.Oh),i-this.Vh>=1e3*e}ug(t,i,s,e,r){this.ig(),this.Xh[t.id]=this.Xh[t.id]||[];const h={};let n;h.oi=i,h.og=s,null!=e&&(n=e.ss()),h.ng=n;const l=[];for(let t=0;t<r.length;t++)l.push(r[t].id);h.lg=l,this.Xh[t.id].push(h),this.h.B(o.q.Ga,this.Xh)}cg(t,i){this.ig(),t.Bh(i),this.Vh=i,this.h.B(o.q.Da,i),this.Yh[t.id]=i,this.h.B(o.q.Ya,this.Yh)}}
1
+ import C from"../common/base-provider.js";import{newInAppMessageFromJson as it}from"../InAppMessage/in-app-message-factory.js";import ue from"../models/braze-event.js";import{InAppMessage}from"../InAppMessage/index.js";import{isArray as p,isEqual as ii,validateValueIsFromEnum as K}from"../util/code-utils.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import ft from"../InAppMessage/models/templated-in-app-message.js";import ut from"./models/trigger.js";import Q from"./models/trigger-events.js";import r from"../../shared-lib/braze-shared-lib.js";export default class ir extends C{constructor(t,i,s,e,r){super(),this.Oh=t,this.vt=i,this.h=s,this.Is=e,this.Uh=r,this.Kh=[],this.Qh=[],this.Vh=null,this.Xh={},this.Yh={},this.Zh(),this.tg()}ig(){this.Vh=this.h.I(o.q.Da)||this.Vh,this.Xh=this.h.I(o.q.Ga)||this.Xh,this.Yh=this.h.I(o.q.Ya)||this.Yh;for(let t=0;t<this.sg.length;t++){const i=this.sg[t];null!=this.Yh[i.id]&&i.Bh(this.Yh[i.id])}}Zh(){this.eg=this.h.I(o.q.Ka)||0;const t=this.h.I(o.q.Ia)||[],i=[];for(let s=0;s<t.length;s++)i.push(ut.jn(t[s]));this.sg=i,this.ig()}tg(){const t=this,i=function(i,s,e,r,h){return function(){t.hg(i,s,e,r,h)}},s={};for(let t=0;t<this.sg.length;t++)s[this.sg[t].id]=this.sg[t];let e=!1;for(let t=0;t<this.sg.length;t++){const r=this.sg[t];if(null!=this.Xh[r.id]){const t=this.Xh[r.id],h=[];for(let e=0;e<t.length;e++){const o=t[e],n=r.Jh(o.ai);if(n>0){let t,e;h.push(o),null!=o.og&&(t=o.og),null!=o.ng&&ue.ya(o.ng)&&(e=ue.jn(o.ng));const l=[];if(p(o.lg))for(let t=0;t<o.lg.length;t++){const i=s[o.lg[t]];null!=i&&l.push(i)}this.Qh.push(setTimeout(i(r,o.ai,t,e,l),n))}}this.Xh[r.id].length>h.length&&(this.Xh[r.id]=h,e=!0,0===this.Xh[r.id].length&&delete this.Xh[r.id])}}e&&this.h.B(o.q.Ga,this.Xh)}ag(){const t=[];for(let i=0;i<this.sg.length;i++)t.push(this.sg[i].ss());this.eg=(new Date).valueOf(),this.h.B(o.q.Ia,t),this.h.B(o.q.Ka,this.eg)}gg(){(this.h.I(o.q.Ka)||0)>this.eg?this.Zh():this.ig()}_s(t){let i=!1;if(null!=t&&t.triggers){this.ig();const s={},e={};this.sg=[];for(let r=0;r<t.triggers.length;r++){const h=ut.fromJson(t.triggers[r]);null!=this.Yh[h.id]&&(h.Bh(this.Yh[h.id]),s[h.id]=this.Yh[h.id]),null!=this.Xh[h.id]&&(e[h.id]=this.Xh[h.id]);for(let t=0;t<h.Th.length;t++)if(h.Th[t].$a(Q.ks,null)){i=!0;break}null!=h&&this.sg.push(h)}ii(this.Yh,s)||(this.Yh=s,this.h.B(o.q.Ya,this.Yh)),ii(this.Xh,e)||(this.Xh=e,this.h.B(o.q.Ga,this.Xh)),this.ag(),i&&(r.D.info("Trigger with test condition found, firing test."),this.je(Q.ks)),this.je(Q.OPEN);const h=this.Kh;this.Kh=[];for(let t=0;t<h.length;t++)this.je.apply(this,h[t])}}async hg(t,i,s,e,h){const o=e=>{this.ig();const h=(new Date).valueOf();if(!t.Lh(i))return!1===navigator.onLine&&t.type===ut.ri.ii&&e.imageUrl?(r.D.info(`Not showing ${t.type} trigger action ${t.id} due to offline state.`),void this.Uh.qe(t.id,InAppMessage.Oe.Bi)):void(t.Mh(h)&&this.fg(t,h,s)?(this.vt.Nt([e]),this.cg(t,h)):r.D.info(`Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`));t.type===ut.ri.Rh?this.Uh.qe(t.id,InAppMessage.Oe.ei):this.Uh.qe(t.id,InAppMessage.Oe.vi)},n=()=>{this.ig();const o=h.pop();if(null!=o)if(this.ug(o,i,s,e,h),o.Lh(i)){let t=`Server aborted in-app message display, but the timeout on fallback trigger ${o.id} has already elapsed.`;h.length>0&&(t+=" Continuing to fall back."),r.D.info(t),this.Uh.qe(o.id,InAppMessage.Oe.vi),n()}else{r.D.info(`Server aborted in-app message display. Falling back to lower priority ${o.type} trigger action ${t.id}.`);const n=1e3*o.Ph-((new Date).valueOf()-i);n>0?this.Qh.push(setTimeout((()=>{this.hg(o,i,s,e,h)}),n)):this.hg(o,i,s,e,h)}};switch(t.type){case ut.ri.ii:const h=it(t.data);if(null==h){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.ni);break}let l=await this.Uh.Ve(h);if(l){r.D.error(l),n();break}o(h);break;case ut.ri.Rh:const a=ft.fromJson(t.data,o,n,i,t.li);if(null==a){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.ni);break}this.Uh.Xs(a,s,e);break;default:r.D.error(`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.ni)}}je(t,i,s){if(!K(Q,t,"Cannot fire trigger action.","TriggerEvents"))return;if(this.Is.bl())return r.D.info("Trigger sync is currently in progress, awaiting sync completion before firing trigger event."),void this.Kh.push(arguments);this.gg();const e=(new Date).valueOf(),h=e-this.Vh;let o=!0,n=!0;const l=[];for(let s=0;s<this.sg.length;s++){const r=this.sg[s],h=e+1e3*r.Ph;if(r.Mh(h)&&(null==r.startTime||r.startTime<=e)&&(null==r.endTime||r.endTime>=e)){let s=!1;for(let e=0;e<r.Th.length;e++)if(r.Th[e].$a(t,i)){s=!0;break}s&&(o=!1,this.fg(r,h,t)&&(n=!1,l.push(r)))}}if(o)return void r.D.info(`Trigger event ${t} did not match any trigger conditions.`);if(n)return void r.D.info(`Ignoring ${t} trigger event because a trigger was displayed ${h/1e3}s ago.`);l.sort(((t,i)=>t.priority-i.priority));const a=l.pop();null!=a&&(r.D.info(`Firing ${a.type} trigger action ${a.id} from trigger event ${t}.`),this.ug(a,e,t,s,l),0===a.Ph?this.hg(a,e,t,s,l):this.Qh.push(setTimeout((()=>{this.hg(a,e,t,s,l)}),1e3*a.Ph)))}changeUser(t){if(this.sg=[],this.h.$s(o.q.Ia),!t){this.Kh=[],this.Vh=null,this.Yh={},this.Xh={};for(let t=0;t<this.Qh.length;t++)clearTimeout(this.Qh[t]);this.Qh=[],this.h.$s(o.q.Da),this.h.$s(o.q.Ya),this.h.$s(o.q.Ga)}}clearData(){this.sg=[],this.Vh=null,this.Yh={},this.Xh={};for(let t=0;t<this.Qh.length;t++)clearTimeout(this.Qh[t]);this.Qh=[]}fg(t,i,s){if(null==this.Vh)return!0;if(s===Q.ks)return r.D.info("Ignoring minimum interval between trigger because it is a test type."),!0;let e=t.Ih;return null==e&&(e=this.Oh),i-this.Vh>=1e3*e}ug(t,i,s,e,r){this.ig(),this.Xh[t.id]=this.Xh[t.id]||[];const h={};let n;h.ai=i,h.og=s,null!=e&&(n=e.ss()),h.ng=n;const l=[];for(let t=0;t<r.length;t++)l.push(r[t].id);h.lg=l,this.Xh[t.id].push(h),this.h.B(o.q.Ga,this.Xh)}cg(t,i){this.ig(),t.Bh(i),this.Vh=i,this.h.B(o.q.Da,i),this.Yh[t.id]=i,this.h.B(o.q.Ya,this.Yh)}}
@@ -1 +1 @@
1
- import e,{OPTIONS as D}from"../../managers/braze-instance.js";export function attachCSS(n,t,o){const c=n||document.querySelector("head"),s=`ab-${t}-css-definitions-${"4.0.5".replace(/\./g,"-")}`,a=c.ownerDocument||document;if(null==a.getElementById(s)){const n=a.createElement("style");n.innerHTML=o,n.id=s;const t=e.nn(D.ao);null!=t&&n.setAttribute("nonce",t),c.appendChild(n)}}
1
+ import e,{OPTIONS as D}from"../../managers/braze-instance.js";export function attachCSS(n,t,o){const c=n||document.querySelector("head"),s=`ab-${t}-css-definitions-${"4.0.6".replace(/\./g,"-")}`,a=c.ownerDocument||document;if(null==a.getElementById(s)){const n=a.createElement("style");n.innerHTML=o,n.id=s;const t=e.nn(D.ao);null!=t&&n.setAttribute("nonce",t),c.appendChild(n)}}
@@ -1 +1 @@
1
- import r from"../../shared-lib/braze-shared-lib.js";import{decodeBrazeActions as Zt}from"./string-utils.js";import{BRAZE_ACTION_URI_REGEX as P,isValidBrazeActionType as $t,isValidBrazeActionJson as F}from"./validation-utils.js";export const BRAZE_ACTIONS={types:{ue:"container",logCustomEvent:"logCustomEvent",setEmailNotificationSubscriptionType:"setEmailNotificationSubscriptionType",setPushNotificationSubscriptionType:"setPushNotificationSubscriptionType",setCustomUserAttribute:"setCustomUserAttribute",requestPushPermission:"requestPushPermission",addToSubscriptionGroup:"addToSubscriptionGroup",removeFromSubscriptionGroup:"removeFromSubscriptionGroup",addToCustomAttributeArray:"addToCustomAttributeArray",removeFromCustomAttributeArray:"removeFromCustomAttributeArray",de:"openLink",pe:"openLinkInWebView"},properties:{type:"type",me:"steps",fe:"args"}};export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES={Qe:"unknownBrazeAction",Ve:"noPushPrompt"};export const ineligibleBrazeActionURLErrorMessage=(t,o)=>{switch(t){case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Qe:return`${o} contains an unknown braze action type and will not be displayed.`;case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Ve:return`${o} contains a push prompt braze action, but is not eligible for a push prompt. Ignoring.`;default:return""}};export function getDecodedBrazeAction(t){try{let o=t.match(P)[0].length;const e=t.substring(o);if(o>t.length-1||!e)return void r.D.error(`Did not find base64 encoded brazeAction in url to process : ${t}`);const n=Zt(e);return n?JSON.parse(n):void r.D.error(`Failed to decode base64 encoded brazeAction: ${e}`)}catch(o){return void r.D.error(`Failed to process brazeAction URL ${t} : ${o.message}`)}}function to(t,o){let r=!1;for(const e of o)if(r=r||t(e),r)return!0;return!1}export function containsUnknownBrazeAction(t){try{const o=t[BRAZE_ACTIONS.properties.type];return o===BRAZE_ACTIONS.types.ue?to(containsUnknownBrazeAction,t[BRAZE_ACTIONS.properties.me]):!$t(o)}catch(t){return!0}}export function containsPushPrimerBrazeAction(t){if(!F(t))return!1;const o=t[BRAZE_ACTIONS.properties.type];return o===BRAZE_ACTIONS.types.ue?to(containsPushPrimerBrazeAction,t[BRAZE_ACTIONS.properties.me]):o===BRAZE_ACTIONS.types.requestPushPermission}
1
+ import r from"../../shared-lib/braze-shared-lib.js";import{decodeBrazeActions as Zt}from"./string-utils.js";import{BRAZE_ACTION_URI_REGEX as P,isValidBrazeActionType as $t,isValidBrazeActionJson as F}from"./validation-utils.js";export const BRAZE_ACTIONS={types:{ue:"container",logCustomEvent:"logCustomEvent",setEmailNotificationSubscriptionType:"setEmailNotificationSubscriptionType",setPushNotificationSubscriptionType:"setPushNotificationSubscriptionType",setCustomUserAttribute:"setCustomUserAttribute",requestPushPermission:"requestPushPermission",addToSubscriptionGroup:"addToSubscriptionGroup",removeFromSubscriptionGroup:"removeFromSubscriptionGroup",addToCustomAttributeArray:"addToCustomAttributeArray",removeFromCustomAttributeArray:"removeFromCustomAttributeArray",de:"openLink",pe:"openLinkInWebView"},properties:{type:"type",me:"steps",fe:"args"}};export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES={We:"unknownBrazeAction",Ze:"noPushPrompt"};export const ineligibleBrazeActionURLErrorMessage=(t,o)=>{switch(t){case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.We:return`${o} contains an unknown braze action type and will not be displayed.`;case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Ze:return`${o} contains a push prompt braze action, but is not eligible for a push prompt. Ignoring.`;default:return""}};export function getDecodedBrazeAction(t){try{let o=t.match(P)[0].length;const e=t.substring(o);if(o>t.length-1||!e)return void r.D.error(`Did not find base64 encoded brazeAction in url to process : ${t}`);const n=Zt(e);return n?JSON.parse(n):void r.D.error(`Failed to decode base64 encoded brazeAction: ${e}`)}catch(o){return void r.D.error(`Failed to process brazeAction URL ${t} : ${o.message}`)}}function to(t,o){let r=!1;for(const e of o)if(r=r||t(e),r)return!0;return!1}export function containsUnknownBrazeAction(t){try{const o=t[BRAZE_ACTIONS.properties.type];return o===BRAZE_ACTIONS.types.ue?to(containsUnknownBrazeAction,t[BRAZE_ACTIONS.properties.me]):!$t(o)}catch(t){return!0}}export function containsPushPrimerBrazeAction(t){if(!F(t))return!1;const o=t[BRAZE_ACTIONS.properties.type];return o===BRAZE_ACTIONS.types.ue?to(containsPushPrimerBrazeAction,t[BRAZE_ACTIONS.properties.me]):o===BRAZE_ACTIONS.types.requestPushPermission}
@@ -1 +1 @@
1
- export const KeyCodes={fo:32,oo:9,co:13,Mi:27};
1
+ export const KeyCodes={fo:32,oo:9,co:13,Ri:27};
@@ -1 +1 @@
1
- import{isArray as p,isDate as yt,isObject as Jt,keys as Y}from"./code-utils.js";import{getByteLength as U}from"./string-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"./date-utils.js";import{BRAZE_ACTIONS as J}from"./braze-actions.js";export const CUSTOM_DATA_REGEX=/^[^\x00-\x1F\x22]+$/;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 BRAZE_ACTION_URI_REGEX=/^brazeActions:\/\/v\d+\//;export function _validatePropertyType(e){const t=typeof e;return null==e||"number"===t||"boolean"===t||yt(e)||"string"===t}export function _validateNestedProperties(e,t){if(p(e)&&p(t)){for(let r=0;r<e.length&&r<t.length;r++)if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}else{if(!Jt(e))return _validatePropertyType(e);for(const r of Y(e))if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}return!0}export function _validateEventPropertyValue(e,t,n,o){let i;return i=Jt(e)||p(e)?_validateNestedProperties(e,t):_validatePropertyType(e),i||r.D.error(`Cannot ${n} because ${o} "${e}" is invalid.`),i}export function validateStandardString(e,t,n,o){const i="string"==typeof e||null===e&&o;return i||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),i}export function validateCustomString(e,t,n){const o=null!=e&&"string"==typeof e&&(""===e||e.match(CUSTOM_DATA_REGEX));return o||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),o}export function validateCustomProperties(e,t,n,o,i){if(null==e&&(e={}),"object"!=typeof e||p(e))return r.D.error(`${t} requires that ${n} be an object. Ignoring ${i}.`),[!1,null];const a=JSON.stringify(e);if(U(a)>51200)return r.D.error(`Could not ${o} because ${n} was greater than the max size of 50KB.`),[!1,null];let s;try{s=JSON.parse(a)}catch(e){return r.D.error(`Could not ${o} because ${n} did not contain valid JSON.`),[!1,null]}for(let t in e){if(!validateCustomString(t,o,`the ${i} property name`))return[!1,null];const r=e[t];if(null==r){delete e[t],delete s[t];continue}yt(r)&&(s[t]=Nt(r));if(!_validateEventPropertyValue(r,s[t],o,`the ${i} property "${t}"`))return[!1,null]}return[!0,s]}export function isValidEmail(e){return"string"==typeof e&&null!=e.toLowerCase().match(EMAIL_ADDRESS_REGEX)}export function isValidBrazeActionJson(e){if(!(J.properties.type in e))return!1;switch(e[J.properties.type]){case J.types.ue:if(J.properties.me in e)return!0;break;case J.types.logCustomEvent:case J.types.setEmailNotificationSubscriptionType:case J.types.setPushNotificationSubscriptionType:case J.types.setCustomUserAttribute:case J.types.addToSubscriptionGroup:case J.types.removeFromSubscriptionGroup:case J.types.addToCustomAttributeArray:case J.types.removeFromCustomAttributeArray:case J.types.de:case J.types.pe:if(J.properties.fe in e)return!0;break;case J.types.requestPushPermission:return!0;default:return!1}return!1}export function isValidBrazeActionType(e){return"string"==typeof e&&J.types[e]}
1
+ import{isArray as p,isDate as yt,isObject as Jt,keys as Y}from"./code-utils.js";import{getByteLength as U}from"./string-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"./date-utils.js";import{BRAZE_ACTIONS as J}from"./braze-actions.js";export const CUSTOM_DATA_REGEX=/^[^\x00-\x1F\x22]+$/;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 BRAZE_ACTION_URI_REGEX=/^brazeActions:\/\/v\d+\//;export function _validatePropertyType(e){const t=typeof e;return null==e||"number"===t||"boolean"===t||yt(e)||"string"===t}export function _validateNestedProperties(e,t){if(p(e)&&p(t)){for(let r=0;r<e.length&&r<t.length;r++)if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}else{if(!Jt(e))return _validatePropertyType(e);for(const r of Y(e))if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}return!0}export function _validateEventPropertyValue(e,t,n,o){let i;return i=Jt(e)||p(e)?_validateNestedProperties(e,t):_validatePropertyType(e),i||r.D.error(`Cannot ${n} because ${o} "${e}" is invalid.`),i}export function validateStandardString(e,t,n,o){const i="string"==typeof e||null===e&&o;return i||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),i}export function validateCustomString(e,t,n){const o=null!=e&&"string"==typeof e&&(""===e||e.match(CUSTOM_DATA_REGEX));return o||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),o}export function validateCustomProperties(e,t,n,o,i){if(null==e&&(e={}),"object"!=typeof e||p(e))return r.D.error(`${t} requires that ${n} be an object. Ignoring ${i}.`),[!1,null];const a=JSON.stringify(e);if(U(a)>51200)return r.D.error(`Could not ${o} because ${n} was greater than the max size of 50KB.`),[!1,null];let s;try{s=JSON.parse(a)}catch(e){return r.D.error(`Could not ${o} because ${n} did not contain valid JSON.`),[!1,null]}for(let t in e){if(!validateCustomString(t,o,`the ${i} property name`))return[!1,null];const r=e[t];if(null==r){delete e[t],delete s[t];continue}yt(r)&&(s[t]=Nt(r));if(!_validateEventPropertyValue(r,s[t],o,`the ${i} property "${t}"`))return[!1,null]}return[!0,s]}export function isValidEmail(e){return"string"==typeof e&&null!=e.toLowerCase().match(EMAIL_ADDRESS_REGEX)}export function isValidBrazeActionJson(e){if(!(J.properties.type in e))return!1;switch(e[J.properties.type]){case J.types.ue:if(J.properties.me in e)return!0;break;case J.types.logCustomEvent:case J.types.setEmailNotificationSubscriptionType:case J.types.setPushNotificationSubscriptionType:case J.types.setCustomUserAttribute:case J.types.addToSubscriptionGroup:case J.types.removeFromSubscriptionGroup:case J.types.addToCustomAttributeArray:case J.types.removeFromCustomAttributeArray:case J.types.de:case J.types.pe:if(J.properties.fe in e)return!0;break;case J.types.requestPushPermission:return!0;default:return!1}return!1}export function isValidBrazeActionType(e){let t=!1;return Object.keys(J.types).forEach((r=>{J.types[r]!==e.toString()||(t=!0)})),t}
@@ -1 +1 @@
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;if("screen"in window){let n=window.screen.orientation||screen.mozOrientation||screen.msOrientation;return null!=n&&"object"==typeof n&&(n=n.type),"landscape-primary"===n||"landscape-secondary"===n?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT}return ORIENTATION.PORTRAIT}export function _openUri(n,e,r){e||null!=r&&r.metaKey?window.open(n):window.location=n}export function _getCurrentUrl(){return window.location.href}export const WindowUtils={openUri:_openUri,so:_isPhone,io:_getOrientation,Pn:_getCurrentUrl};
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;if("screen"in window){let n=window.screen.orientation||screen.mozOrientation||screen.msOrientation;return null!=n&&"object"==typeof n&&(n=n.type),"landscape-primary"===n||"landscape-secondary"===n?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT}return ORIENTATION.PORTRAIT}export function _openUri(n,e,r){e||null!=r&&r.metaKey?window.open(n):window.location=n}export function _getCurrentUrl(){return window.location.href}export const WindowUtils={openUri:_openUri,so:_isPhone,io:_getOrientation,kn:_getCurrentUrl};