@braze/web-sdk 3.4.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -11
- package/index.d.ts +490 -513
- package/package.json +8 -7
- package/shared-lib/braze-shared-lib.js +1 -0
- package/shared-lib/encoding-utils.js +1 -0
- package/shared-lib/event-types.js +1 -0
- package/shared-lib/guid.js +1 -0
- package/shared-lib/indexed-db-adapter.js +1 -0
- package/shared-lib/logger.js +1 -0
- package/shared-lib/supported-options.js +1 -0
- package/src/Card/card-manager-factory.js +1 -0
- package/src/Card/card-manager.js +1 -0
- package/src/Card/display/card-display.js +1 -0
- package/src/Card/index.js +1 -0
- package/src/Card/log-card-click.js +1 -0
- package/src/Card/log-card-dismissal.js +1 -0
- package/src/Card/log-card-impressions.js +1 -0
- package/src/Card/models/banner.js +1 -0
- package/src/Card/models/captioned-image.js +1 -0
- package/src/Card/models/card.js +1 -0
- package/src/Card/models/classic-card.js +1 -0
- package/src/Card/models/control-card.js +1 -0
- package/src/Card/models/index.js +1 -0
- package/src/Card/util/card-factory.js +1 -0
- package/src/ContentCards/content-cards-provider-factory.js +1 -0
- package/src/ContentCards/content-cards-provider.js +1 -0
- package/src/ContentCards/content-cards.js +1 -0
- package/src/ContentCards/get-cached-content-cards.js +1 -0
- package/src/ContentCards/index.js +1 -0
- package/src/ContentCards/log-content-cards-displayed.js +1 -0
- package/src/ContentCards/request-content-cards-refresh.js +1 -0
- package/src/ContentCards/subscribe-to-content-cards-updates.js +1 -0
- package/src/ContentCards/ui/hide-content-cards.js +1 -0
- package/src/ContentCards/ui/show-content-cards.js +1 -0
- package/src/ContentCards/ui/toggle-content-cards.js +1 -0
- package/src/Core/add-sdk-metadata.js +1 -0
- package/src/Core/braze-sdk-metadata.js +1 -0
- package/src/Core/change-user.js +1 -0
- package/src/Core/destroy.js +1 -0
- package/src/Core/device-properties.js +1 -0
- package/src/Core/disable-sdk.js +1 -0
- package/src/Core/enable-sdk.js +1 -0
- package/src/Core/get-device-id.js +1 -0
- package/src/Core/get-user.js +1 -0
- package/src/Core/handle-braze-action.js +1 -0
- package/src/Core/index.js +1 -0
- package/src/Core/initialize.js +1 -0
- package/src/Core/is-disabled.js +1 -0
- package/src/Core/log-custom-event.js +1 -0
- package/src/Core/log-purchase.js +1 -0
- package/src/Core/open-session.js +1 -0
- package/src/Core/remove-all-subscriptions.js +1 -0
- package/src/Core/remove-subscription.js +1 -0
- package/src/Core/request-immediate-data-flush.js +1 -0
- package/src/Core/set-logger.js +1 -0
- package/src/Core/set-sdk-authentication-signature.js +1 -0
- package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -0
- package/src/Core/toggle-logging.js +1 -0
- package/src/Core/wipe-data.js +1 -0
- package/src/Feed/feed-provider-factory.js +1 -0
- package/src/Feed/feed-provider.js +1 -0
- package/src/Feed/feed.js +1 -0
- package/src/Feed/get-cached-feed.js +1 -0
- package/src/Feed/index.js +1 -0
- package/src/Feed/log-feed-displayed.js +1 -0
- package/src/Feed/request-feed-refresh.js +1 -0
- package/src/Feed/subscribe-to-feed-updates.js +1 -0
- package/src/Feed/ui/hide-feed.js +1 -0
- package/src/Feed/ui/show-feed.js +1 -0
- package/src/Feed/ui/toggle-feed.js +1 -0
- package/src/InAppMessage/display/get-animation-effect.js +1 -0
- package/src/InAppMessage/display/html-message-to-html.js +1 -0
- package/src/InAppMessage/display/in-app-message-to-html.js +1 -0
- package/src/InAppMessage/display/modal-utils.js +1 -0
- package/src/InAppMessage/in-app-message-factory.js +1 -0
- package/src/InAppMessage/in-app-message-manager-factory.js +1 -0
- package/src/InAppMessage/in-app-message-manager.js +1 -0
- package/src/InAppMessage/index.js +1 -0
- package/src/InAppMessage/log-in-app-message-button-click.js +1 -0
- package/src/InAppMessage/log-in-app-message-click.js +1 -0
- package/src/InAppMessage/log-in-app-message-html-click.js +1 -0
- package/src/InAppMessage/log-in-app-message-impression.js +1 -0
- package/src/InAppMessage/models/control-message.js +1 -0
- package/src/InAppMessage/models/full-screen-message.js +1 -0
- package/src/InAppMessage/models/html-message.js +1 -0
- package/src/InAppMessage/models/in-app-message-button.js +1 -0
- package/src/InAppMessage/models/in-app-message.js +1 -0
- package/src/InAppMessage/models/modal-message.js +1 -0
- package/src/InAppMessage/models/slide-up-message.js +1 -0
- package/src/InAppMessage/models/templated-in-app-message.js +1 -0
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -0
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +1 -0
- package/src/InAppMessage/ui/show-in-app-message.js +1 -0
- package/src/Push/index.js +1 -0
- package/src/Push/is-push-blocked.js +1 -0
- package/src/Push/is-push-permission-granted.js +1 -0
- package/src/Push/is-push-supported.js +1 -0
- package/src/Push/push-manager-factory.js +1 -0
- package/src/Push/push-manager.js +1 -0
- package/src/Push/request-push-permission.js +1 -0
- package/src/Push/unregister-push.js +1 -0
- package/src/User/index.js +1 -0
- package/src/User/user-manager.js +1 -0
- package/src/User/user.js +1 -0
- package/src/common/base-feed.js +1 -0
- package/src/common/base-provider.js +1 -0
- package/src/common/constants.js +1 -0
- package/src/common/event-logger.js +1 -0
- package/src/common/feed-display.js +1 -0
- package/src/common/translations.js +1 -0
- package/src/index.js +1 -0
- package/src/l10n/l10n-manager-factory.js +1 -0
- package/src/l10n/l10n-manager.js +1 -0
- package/src/managers/auth-manager.js +1 -0
- package/src/managers/braze-instance.js +1 -0
- package/src/managers/device-manager.js +1 -0
- package/src/managers/network-manager.js +1 -0
- package/src/managers/server-config-manager.js +1 -0
- package/src/managers/session-manager.js +1 -0
- package/src/managers/storage-manager-factory.js +1 -0
- package/src/managers/storage-manager.js +1 -0
- package/src/managers/subscription-manager.js +1 -0
- package/src/models/backend-errors.js +1 -0
- package/src/models/braze-event.js +1 -0
- package/src/models/braze-sdk-metadata.js +1 -0
- package/src/models/device.js +1 -0
- package/src/models/identifier.js +1 -0
- package/src/models/push-token.js +1 -0
- package/src/models/request-result.js +1 -0
- package/src/models/server-config.js +1 -0
- package/src/request-controller.js +1 -0
- package/src/triggers/models/custom-event-data.js +1 -0
- package/src/triggers/models/custom-event-property-data.js +1 -0
- package/src/triggers/models/filter-set.js +1 -0
- package/src/triggers/models/filter.js +1 -0
- package/src/triggers/models/in-app-message-click-data.js +1 -0
- package/src/triggers/models/purchase-data.js +1 -0
- package/src/triggers/models/purchase-property-data.js +1 -0
- package/src/triggers/models/push-click-data.js +1 -0
- package/src/triggers/models/trigger-condition.js +1 -0
- package/src/triggers/models/trigger-events.js +1 -0
- package/src/triggers/models/trigger.js +1 -0
- package/src/triggers/triggers-provider-factory.js +1 -0
- package/src/triggers/triggers-provider.js +1 -0
- package/src/ui/js/attach-css.js +1 -0
- package/src/ui/js/feed-css.js +1 -0
- package/src/ui/js/iam-css.js +1 -0
- package/src/ui/js/index.js +1 -0
- package/src/ui/js/load-font-awesome.js +1 -0
- package/src/util/base-device-parser.js +1 -0
- package/src/util/braze-actions.js +1 -0
- package/src/util/browser-detector.js +1 -0
- package/src/util/client-hints-parser.js +1 -0
- package/src/util/code-utils.js +1 -0
- package/src/util/color-utils.js +1 -0
- package/src/util/component-utils.js +1 -0
- package/src/util/date-utils.js +1 -0
- package/src/util/deprecation-utils.js +1 -0
- package/src/util/device-constants.js +1 -0
- package/src/util/dom-utils.js +1 -0
- package/src/util/key-codes.js +1 -0
- package/src/util/math.js +1 -0
- package/src/util/net.js +1 -0
- package/src/util/string-utils.js +1 -0
- package/src/util/url-utils.js +1 -0
- package/src/util/user-agent-parser.js +1 -0
- package/src/util/validation-utils.js +1 -0
- package/src/util/window-utils.js +1 -0
- package/appboy.min.js +0 -275
package/package.json
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@braze/web-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Braze SDK for web sites and other JS platforms.",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/
|
|
11
|
+
"url": "https://github.com/braze-inc/braze-web-sdk.git"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"Appboy",
|
|
15
15
|
"Braze"
|
|
16
16
|
],
|
|
17
17
|
"author": "Braze, Inc",
|
|
18
|
-
"license": "SEE LICENSE IN https://github.com/
|
|
18
|
+
"license": "SEE LICENSE IN https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE",
|
|
19
19
|
"bugs": {
|
|
20
|
-
"url": "https://github.com/
|
|
20
|
+
"url": "https://github.com/braze-inc/braze-web-sdk/issues"
|
|
21
21
|
},
|
|
22
|
-
"homepage": "https://github.com/
|
|
22
|
+
"homepage": "https://github.com/braze-inc/braze-web-sdk#readme",
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|
|
25
|
-
}
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": false
|
|
26
27
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import je from"./encoding-utils.js";import{EventTypes as ve,InternalEventTypes as De}from"./event-types.js";import Ee from"./guid.js";import Be from"./indexed-db-adapter.js";import Ae from"./logger.js";import Ge from"./supported-options.js";const r={Nn:je,A:ve,lr:De,nt:Ee,qt:Be,Ft:Be.ep,D:Ae,Ro:Ge};export default r;
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const ve={CustomEvent:"ce",Pr:"p",Sl:"pc",ec:"ca",la:"i",Vo:"ie",T:"cci",W:"ccic",_:"ccc",L:"ccd",Wh:"ss",bh:"se",Ke:"si",He:"sc",Je:"sbc",Re:"sfe",nc:"iec",vl:"lr",yl:"uae",U:"ci",F:"cc",Al:"lcaa",$l:"lcar",Xr:"inc",Yr:"add",Qr:"rem",Wr:"set",Cl:"sgu"},De={qr:"feed_displayed",br:"content_cards_displayed"};export{ve as EventTypes,De as InternalEventTypes};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const Ee={et:()=>{const t=t=>{const e=(Math.random().toString(16)+"000000000").substr(2,8);return t?"-"+e.substr(0,4)+"-"+e.substr(4,4):e};return t()+t(!0)+t(!0)+t()}};export default Ee;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class Be{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)}gr(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)}}))}}Be.ep={xt:{sd:"AppboyServiceWorkerAsyncStorage",VERSION:6,Pt:{jl:"data",kr:"pushClicks",Nr:"pushSubscribed",ud:"fallbackDevice",Mt:"cardUpdates",oe:"optOut",yr:"pendingData",Ln:"sdkAuthenticationSignature"},se:1}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const Ae={init:function(n){void 0===n&&void 0!==Ae.zg||(Ae.zg=!!n),Ae.Dg||(Ae.Dg=!0)},destroy:function(){Ae.Dg=!1,Ae.zg=void 0,Ae.nd=void 0},setLogger:function(n){"function"==typeof n?(Ae.init(),Ae.nd=n):Ae.info("Ignoring setLogger call since logger is not a function")},toggleLogging:function(){Ae.init(),Ae.zg?(console.log("Disabling Braze logging"),Ae.zg=!1):(console.log("Enabled Braze logging"),Ae.zg=!0)},info:function(n){if(Ae.zg){const o="Braze: "+n;null!=Ae.nd?Ae.nd(o):console.log(o)}},warn:function(n){if(Ae.zg){const o="Braze SDK Warning: "+n+" (v4.0.0)";null!=Ae.nd?Ae.nd(o):console.warn(o)}},error:function(n){if(Ae.zg){const o="Braze SDK Error: "+n+" (v4.0.0)";null!=Ae.nd?Ae.nd(o):console.error(o)}}};export default Ae;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default{$n:"allowCrawlerActivity",ea:"baseUrl",Yn:"noCookies",Xn:"devicePropertyAllowlist",ta:"disablePushTokenMaintenance",Zn:"enableLogging",ho:"enableSdkAuthentication",ia:"manageServiceWorkerExternally",lo:"minimumIntervalBetweenTriggerActionsInSeconds",uo:"sessionTimeoutInSeconds",po:"appVersion",na:"serviceWorkerLocation",ra:"safariWebsitePushId",zn:"localization",yi:"contentSecurityNonce",co:"enableHtmlInAppMessages",mo:"allowUserSuppliedJavascript",vi:"inAppMessageZIndex",zi:"openInAppMessagesInNewTab",en:"openNewsFeedCardsInNewTab",Oi:"requireExplicitInAppMessageDismissal",Eo:"doNotLoadFontAwesome",_o:"sdkFlavor",tn:"openCardsInNewTab"};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import a from"./card-manager.js";import e from"../managers/braze-instance.js";const n={t:!1,i:null,m:()=>(n.o(),n.i||(n.i=new a(e.l(),e.g(),e.p())),n.i),o:()=>{n.t||(e.u(n),n.t=!0)},destroy:()=>{n.i=null,n.t=!1}};export default n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ControlCard}from"./models/index.js";import s from"../common/event-logger.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";export default class a{constructor(s,t,r){this.h=s,this.j=t,this.v=r}C(n,i){const e=new t;if(n.k(),null==n.url||""===n.url)return r.D.info(`Card ${n.id} has no url. Not logging click to Braze servers.`),e;if(i){const s=this.h.I(o.q.$)||{};s[n.id]=!0,this.h.B(o.q.$,s)}const l=this.N([n]);if(null==l)return e;const u=i?r.A._:r.A.F;return s.G(u,l)}H(n){const i=new t;if(!n.J())return r.D.info(`Card ${n.id} refused this dismissal. Ignoring analytics event.`),i;const e=this.h.I(o.q.K)||{};e[n.id]=!0,this.h.B(o.q.K,e);const l=this.N([n]);return null==l?i:s.G(r.A.L,l)}M(n,i){const e=new t(!0),l=[],u=[];let a;a=i?this.h.I(o.q.O)||{}:this.h.I(o.q.P)||{};for(const s of n)s.R(),s instanceof ControlCard?u.push(s):l.push(s),a[s.id]=!0;const c=this.N(l),h=this.N(u);if(null==c&&null==h)return e.S=!1,e;if(i?this.h.B(o.q.O,a):this.h.B(o.q.P,a),null!=c){const t=i?r.A.T:r.A.U,n=s.G(t,c);e.V(n)}if(null!=h&&i){const t=s.G(r.A.W,h);e.V(t)}return e}N(s){let t=null;for(let r=0;r<s.length;r++)null!=s[r].id&&""!==s[r].id&&(t=t||{},t.ids=t.ids||[],t.ids.push(s[r].id));return t}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createCloseButton as i}from"../../util/component-utils.js";import{detectSwipe as d,DIRECTIONS as c}from"../../util/dom-utils.js";import{_handleBrazeAction as m}from"../../Core/handle-braze-action.js";import{logCardDismissal}from"../index.js";import r from"../../../shared-lib/braze-shared-lib.js";export const TOP_IMPRESSION_DATA_ATTRIBUTE="data-ab-had-top-impression";export const BOTTOM_IMPRESSION_DATA_ATTRIBUTE="data-ab-had-bottom-impression";export function topHadImpression(t){return null!=t&&!!t.getAttribute("data-ab-had-top-impression")}export function impressOnTop(t){null!=t&&t.setAttribute("data-ab-had-top-impression",!0)}export function bottomHadImpression(t){return null!=t&&!!t.getAttribute("data-ab-had-bottom-impression")}export function impressOnBottom(t){null!=t&&t.setAttribute("data-ab-had-bottom-impression",!0)}export function markCardAsRead(t){if(null!=t){const o=t.querySelectorAll(".ab-unread-indicator")[0];null!=o&&(o.className+=" read")}}export function getCardId(t){return t.getAttribute("data-ab-card-id")}export function _setImageAltText(t,o){let a="";t.title||t.description||(a="Feed Image"),o.setAttribute("alt",a)}export function setCardHeight(t,o){const a=o.querySelectorAll(".ab-image-area");let e,n=0;a.length>0&&(n=a[0].offsetWidth);for(const o of t)if(e=o.X,e&&o.imageUrl&&!isNaN(o.aspectRatio)){const t=n/o.aspectRatio;t&&(e.style.height=`${t}px`)}}export function cardToHtml(t,logCardClick,o){const a=document.createElement("div");a.className="ab-card ab-effect-card "+t.Y,a.setAttribute("data-ab-card-id",t.id),a.setAttribute("role","article"),a.setAttribute("tabindex","0");const e=t.url&&""!==t.url,n=n=>(markCardAsRead(a),e&&(logCardClick(t),m(t.url,n,o)),!1);if(t.pinned){const t=document.createElement("div");t.className="ab-pinned-indicator";const o=document.createElement("i");o.className="fa fa-star",t.appendChild(o),a.appendChild(t)}if(t.imageUrl&&""!==t.imageUrl){const o=document.createElement("div");o.className="ab-image-area";const i=document.createElement("img");if(i.setAttribute("src",t.imageUrl),i.onload=()=>{a.style.height="auto"},_setImageAltText(t,i),o.appendChild(i),a.className+=" with-image",e&&!t.Z){const e=document.createElement("a");e.setAttribute("href",t.url),e.onclick=n,e.appendChild(o),a.appendChild(e)}else a.appendChild(o)}const s=document.createElement("div");if(s.className="ab-card-body",t.dismissible){t.tt=()=>logCardDismissal(t);const o=i("Dismiss Card",void 0,t.dismissCard.bind(t));a.appendChild(o),d(s,c.ot,(t=>{a.className+=" ab-swiped-left",o.onclick(t)})),d(s,c.at,(t=>{a.className+=" ab-swiped-right",o.onclick(t)}))}const u=t.title&&""!==t.title;if(u){const o=document.createElement("h1");if(o.className="ab-title",o.id=r.nt.et(),a.setAttribute("aria-labelledby",o.id),e){const a=document.createElement("a");a.setAttribute("href",t.url),a.onclick=n,a.appendChild(document.createTextNode(t.title)),o.appendChild(a)}else o.appendChild(document.createTextNode(t.title));s.appendChild(o)}const p=document.createElement("div");if(p.className=u?"ab-description":"ab-description ab-no-title",p.id=r.nt.et(),a.setAttribute("aria-describedby",p.id),p.appendChild(document.createTextNode(t.description)),e){const o=document.createElement("div");o.className="ab-url-area";const a=document.createElement("a");a.setAttribute("href",t.url),a.appendChild(document.createTextNode(t.linkText)),a.onclick=n,o.appendChild(a),p.appendChild(o)}s.appendChild(p),a.appendChild(s);const b=document.createElement("div");return b.className="ab-unread-indicator",t.viewed&&(b.className+=" read"),a.appendChild(b),t.X=a,a}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./models/index.js";export{logCardClick}from"./log-card-click.js";export{logCardDismissal}from"./log-card-dismissal.js";export{logCardImpressions}from"./log-card-impressions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Card}from"./models/index.js";import n from"./card-manager-factory.js";import{MUST_BE_CARD_WARNING_SUFFIX as f}from"../common/constants.js";import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";export function logCardClick(o,a){return!!e.rr()&&(o instanceof Card?n.m().C(o,a).S:(r.D.error("card "+f),!1))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Card}from"./models/index.js";import n from"./card-manager-factory.js";import{MUST_BE_CARD_WARNING_SUFFIX as f}from"../common/constants.js";import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";export function logCardDismissal(o){return!!e.rr()&&(o instanceof Card?n.m().H(o).S:(r.D.error("card "+f),!1))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Card}from"./models/index.js";import n from"./card-manager-factory.js";import e from"../managers/braze-instance.js";import{isArray as p}from"../util/code-utils.js";import{MUST_BE_CARD_WARNING_SUFFIX as f}from"../common/constants.js";import r from"../../shared-lib/braze-shared-lib.js";export function logCardImpressions(o,s){if(!e.rr())return!1;if(!p(o))return r.D.error("cards must be an array"),!1;for(const s of o)if(!(s instanceof Card))return r.D.error(`Each card in cards ${f}`),!1;return n.m().M(o,s).S}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Card from"./card.js";export default class Banner extends Card{constructor(s,t,i,h,r,e,n,l,a,o,u,c,d,p){super(s,t,null,i,null,h,r,e,n,l,a,o,u,c,d,p),this.Y="ab-banner",this.Z=!1}ss(){const s={};return s[Card.hs.ts]=Card.es.rs,s[Card.hs.ns]=this.id,s[Card.hs.ls]=this.viewed,s[Card.hs.os]=this.imageUrl,s[Card.hs.us]=this.updated,s[Card.hs.cs]=this.created,s[Card.hs.ds]=this.categories,s[Card.hs.ps]=this.expiresAt,s[Card.hs.URL]=this.url,s[Card.hs.bs]=this.linkText,s[Card.hs.fs]=this.aspectRatio,s[Card.hs.xs]=this.extras,s[Card.hs.js]=this.pinned,s[Card.hs.zs]=this.dismissible,s[Card.hs.gs]=this.clicked,s[Card.hs.ks]=this.test,s}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Card from"./card.js";export default class CaptionedImage extends Card{constructor(t,s,i,h,e,r,a,o,c,n,d,p,u,l,m,f){super(t,s,i,h,e,r,a,o,c,n,d,p,u,l,m,f),this.Y="ab-captioned-image",this.Z=!0}ss(){const t={};return t[Card.hs.ts]=Card.es.st,t[Card.hs.ns]=this.id,t[Card.hs.ls]=this.viewed,t[Card.hs.it]=this.title,t[Card.hs.os]=this.imageUrl,t[Card.hs.ht]=this.description,t[Card.hs.us]=this.updated,t[Card.hs.cs]=this.created,t[Card.hs.ds]=this.categories,t[Card.hs.ps]=this.expiresAt,t[Card.hs.URL]=this.url,t[Card.hs.bs]=this.linkText,t[Card.hs.fs]=this.aspectRatio,t[Card.hs.xs]=this.extras,t[Card.hs.js]=this.pinned,t[Card.hs.zs]=this.dismissible,t[Card.hs.gs]=this.clicked,t[Card.hs.ks]=this.test,t}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{convertMsToSeconds as l,dateFromUnixTimestamp as h}from"../../util/date-utils.js";import{FEED_ANIMATION_DURATION as E}from"../../common/constants.js";import u from"../../managers/subscription-manager.js";export default class Card{constructor(t,i,s,n,l,h,e,r,E,u,T,o,I,a,N,S){this.id=t,this.viewed=i||!1,this.title=s||"",this.imageUrl=n,this.description=l||"",this.created=h||null,this.updated=e||null,this.categories=r||[],this.expiresAt=E||null,this.url=u,this.linkText=T,o=parseFloat(o),this.aspectRatio=isNaN(o)?null:o,this.extras=I,this.pinned=a||!1,this.dismissible=N||!1,this.dismissed=!1,this.clicked=S||!1,this.test=!1,this.lt=null,this.rt=null}subscribeToClickedEvent(t){return this.ut().Et(t)}subscribeToDismissedEvent(t){return this.Tt().Et(t)}removeSubscription(t){this.ut().removeSubscription(t),this.Tt().removeSubscription(t)}removeAllSubscriptions(){this.ut().removeAllSubscriptions(),this.Tt().removeAllSubscriptions()}dismissCard(){if(this.dismissible&&!this.dismissed){this.tt&&this.tt(this);var t=this.X;t&&(t.style.height=t.offsetHeight+"px",t.className=t.className+" ab-hide",setTimeout((function(){t&&t.parentNode&&(t.style.height="0",t.style.margin="0",setTimeout((function(){t&&t.parentNode&&t.parentNode.removeChild(t)}),Card.It))}),E))}}ut(){return null==this.lt&&(this.lt=new u),this.lt}Tt(){return null==this.rt&&(this.rt=new u),this.rt}R(){this.viewed=!0}k(){this.viewed=!0,this.clicked=!0,this.ut().Nt()}J(){return!(!this.dismissible||this.dismissed)&&(this.dismissed=!0,this.Tt().Nt(),!0)}St(t){if(null==t||t[Card.ct.ns]!==this.id)return!0;if(t[Card.ct.At])return!1;if(null!=t[Card.ct.us]&&null!=this.updated&&t[Card.ct.us]<l(this.updated.valueOf()))return!0;if(t[Card.ct.ls]&&!this.viewed&&(this.viewed=!0),t[Card.ct.gs]&&!this.clicked&&(this.clicked=t[Card.ct.gs]),null!=t[Card.ct.it]&&(this.title=t[Card.ct.it]),null!=t[Card.ct.os]&&(this.imageUrl=t[Card.ct.os]),null!=t[Card.ct.ht]&&(this.description=t[Card.ct.ht]),null!=t[Card.ct.us]){const i=h(t[Card.ct.us]);null!=i&&(this.updated=i)}if(null!=t[Card.ct.ps]){let i;i=t[Card.ct.ps]===Card.Dt?null:h(t[Card.ct.ps]),this.expiresAt=i}if(null!=t[Card.ct.URL]&&(this.url=t[Card.ct.URL]),null!=t[Card.ct.bs]&&(this.linkText=t[Card.ct.bs]),null!=t[Card.ct.fs]){const i=parseFloat(t[Card.ct.fs]);this.aspectRatio=isNaN(i)?null:i}return null!=t[Card.ct.xs]&&(this.extras=t[Card.ct.xs]),null!=t[Card.ct.js]&&(this.pinned=t[Card.ct.js]),null!=t[Card.ct.zs]&&(this.dismissible=t[Card.ct.zs]),null!=t[Card.ct.ks]&&(this.test=t[Card.ct.ks]),!0}}Card.Dt=-1,Card.es={st:"captioned_image",Ct:"text_announcement",dt:"short_news",rs:"banner_image",Rt:"control"},Card.ct={ns:"id",ls:"v",zs:"db",At:"r",us:"ca",js:"p",ps:"ea",xs:"e",ts:"tp",os:"i",it:"tt",ht:"ds",URL:"u",bs:"dm",fs:"ar",gs:"cl",ks:"t"},Card.hs={ns:"id",ls:"v",zs:"db",cs:"cr",us:"ca",js:"p",ds:"t",ps:"ea",xs:"e",ts:"tp",os:"i",it:"tt",ht:"ds",URL:"u",bs:"dm",fs:"ar",gs:"cl",ks:"s"},Card._t={Lt:"ADVERTISING",Ot:"ANNOUNCEMENTS",bt:"NEWS",ft:"SOCIAL"},Card.It=400;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Card from"./card.js";export default class ClassicCard extends Card{constructor(s,t,i,h,r,c,e,a,o,d,l,n,u,p,f,m){super(s,t,i,h,r,c,e,a,o,d,l,n,u,p,f,m),this.Y="ab-classic-card",this.Z=!0}ss(){const s={};return s[Card.hs.ts]=Card.es.dt,s[Card.hs.ns]=this.id,s[Card.hs.ls]=this.viewed,s[Card.hs.it]=this.title,s[Card.hs.os]=this.imageUrl,s[Card.hs.ht]=this.description,s[Card.hs.us]=this.updated,s[Card.hs.cs]=this.created,s[Card.hs.ds]=this.categories,s[Card.hs.ps]=this.expiresAt,s[Card.hs.URL]=this.url,s[Card.hs.bs]=this.linkText,s[Card.hs.fs]=this.aspectRatio,s[Card.hs.xs]=this.extras,s[Card.hs.js]=this.pinned,s[Card.hs.zs]=this.dismissible,s[Card.hs.gs]=this.clicked,s[Card.hs.ks]=this.test,s}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Card from"./card.js";export default class ControlCard extends Card{constructor(l,t,s,n,u,i){super(l,t,null,null,null,null,s,null,n,null,null,null,u,i,null),this.Y="ab-control-card",this.Z=!1}ss(){const l={};return l[Card.hs.ts]=Card.es.Rt,l[Card.hs.ns]=this.id,l[Card.hs.ls]=this.viewed,l[Card.hs.us]=this.updated,l[Card.hs.ps]=this.expiresAt,l[Card.hs.xs]=this.extras,l[Card.hs.js]=this.pinned,l[Card.hs.ks]=this.test,l}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as Card}from"./card.js";export{default as Banner}from"./banner.js";export{default as CaptionedImage}from"./captioned-image.js";export{default as ClassicCard}from"./classic-card.js";export{default as ControlCard}from"./control-card.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Card,Banner,CaptionedImage,ClassicCard,ControlCard}from"../index.js";import{dateFromUnixTimestamp as h,rehydrateDateAfterJsonization as w}from"../../util/date-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";export function newCard(e,n,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x,F){let b;if(n===Card.es.Ct||n===Card.es.dt)b=new ClassicCard(e,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x);else if(n===Card.es.st)b=new CaptionedImage(e,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x);else if(n===Card.es.rs)b=new Banner(e,t,i,u,d,a,s,w,f,m,C,p,c,x);else{if(n!==Card.es.Rt)return r.D.error("Ignoring card with unknown type "+n),null;b=new ControlCard(e,t,d,s,C,p)}return F&&(b.test=F),b}export function newCardFromContentCardsJson(e){if(e[Card.ct.At])return null;const n=e[Card.ct.ns],r=e[Card.ct.ts],t=e[Card.ct.ls],o=e[Card.ct.it],i=e[Card.ct.os],l=e[Card.ct.ht],u=h(e[Card.ct.us]);let d;d=e[Card.ct.ps]===Card.Dt?null:h(e[Card.ct.ps]);return newCard(n,r,t,o,i,l,null,u,null,d,e[Card.ct.URL],e[Card.ct.bs],e[Card.ct.fs],e[Card.ct.xs],e[Card.ct.js],e[Card.ct.zs],e[Card.ct.gs],e[Card.ct.ks]||!1)}export function newCardFromFeedJson(e){return newCard(e.id,e.type,e.viewed,e.title,e.image,e.description,h(e.created),h(e.updated),e.categories,h(e.expires_at),e.url,e.domain,e.aspect_ratio,e.extras,!1,!1)}export function newCardFromSerializedValue(e){return newCard(e[Card.hs.ns],e[Card.hs.ts],e[Card.hs.ls],e[Card.hs.it],e[Card.hs.os],e[Card.hs.ht],w(e[Card.hs.cs]),w(e[Card.hs.us]),e[Card.hs.ds],w(e[Card.hs.ps]),e[Card.hs.URL],e[Card.hs.bs],e[Card.hs.fs],e[Card.hs.xs],e[Card.hs.js],e[Card.hs.zs],e[Card.hs.gs],e[Card.hs.ks]||!1)??void 0}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import v from"./content-cards-provider.js";const g={t:!1,provider:null,er:()=>(g.o(),g.provider||(g.provider=new v(e.p(),e.l(),e.ir(),e.tr(),e.nr()),e.ar(g.provider)),g.provider),o:()=>{g.t||(e.u(g),g.t=!0)},destroy:()=>{g.provider=null,g.t=!1}};export default g;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import b from"../util/net.js";import C from"../common/base-provider.js";import e from"../managers/braze-instance.js";import ContentCards from"./content-cards.js";import{dateFromUnixTimestamp as h}from"../util/date-utils.js";import{isURIJavascriptOrData as j}from"../util/url-utils.js";import{newCardFromContentCardsJson as S,newCardFromSerializedValue as _}from"../Card/util/card-factory.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 v extends C{constructor(t,s,i,h,n){super(),this.v=t,this.h=s,this.wt=i,this.gt=h,this.jt=n,this.vt=new u,e.Ut(this.vt),this.yt=0,this.kt=0,this.zt();const o=r.Ft.xt;new r.qt(o,r.D).Jt(o.Pt.Mt,(t=>{this.$t(t)}))}Bt(){return this.Gt}Ht(t){this.Gt=t}Kt(){return this.Qt}Vt(t){this.Qt=t}zt(){const t=this.h.I(o.q.Wt)||[],s=[];for(let i=0;i<t.length;i++){const e=_(t[i]);null!=e&&s.push(e)}this.Xt=this.Yt(this.Zt(s,!1)),this.yt=this.h.I(o.q.Cs)||this.yt,this.kt=this.h.I(o.q.ws)||this.kt}vs(t,s,i,e){let h;if(s){h=[];for(const t of this.Xt)t.test&&h.push(t)}else h=this.Xt.slice();for(let i=0;i<t.length;i++){const e=t[i];let r=null;for(let t=0;t<this.Xt.length;t++)if(e.id===this.Xt[t].id){r=this.Xt[t];break}if(s){const t=S(e);null!=r&&r.viewed&&(t.viewed=!0),null!=t&&h.push(t)}else if(null==r){const t=S(e);null!=t&&h.push(t)}else{if(!r.St(e))for(let t=0;t<h.length;t++)if(e.id===h[t].id){h.splice(t,1);break}}}this.Xt=this.Yt(this.Zt(h,s)),this.Ss(),this.yt=i||0,this.h.B(o.q.Cs,this.yt),this.kt=e||0,this.h.B(o.q.ws,this.kt)}_s(t){if(this.Us()&&null!=t&&t.cards){const s=t.full_sync;s||this.zt(),this.vs(t.cards,s,t.last_full_sync_at,t.last_card_updated_at),this.vt.Nt(this.ys(!0))}}$t(t){if(!this.Us())return;this.zt();const s=this.Xt.slice(),i=this.v.getUserId();for(let e=0;e<t.length;e++)if(i===t[e].userId||null==i&&null==t[e].userId){const i=t[e].card;let h=null;for(let t=0;t<this.Xt.length;t++)if(i.id===this.Xt[t].id){h=this.Xt[t];break}if(null==h){const t=S(i);null!=t&&s.push(t)}else{if(!h.St(i))for(let t=0;t<s.length;t++)if(i.id===s[t].id){s.splice(t,1);break}}}this.Xt=this.Yt(this.Zt(s,!1)),this.Ss(),this.vt.Nt(this.ys(!0))}Zt(t,s){const i=this.h.I(o.q.$)||{},e=this.h.I(o.q.O)||{},h=this.h.I(o.q.K)||{},r={},n={},a={};for(let s=0;s<t.length;s++)i[t[s].id]&&(t[s].clicked=!0,r[t[s].id]=!0),e[t[s].id]&&(t[s].viewed=!0,n[t[s].id]=!0),h[t[s].id]&&(t[s].dismissed=!0,a[t[s].id]=!0);return s&&(this.h.B(o.q.$,r),this.h.B(o.q.O,n),this.h.B(o.q.K,a)),t}Yt(t){const s=[],i=new Date,e=this.h.I(o.q.K)||{};let h=!1;for(let n=0;n<t.length;n++){const o=t[n].url;!this.gt&&o&&j(o)?r.D.error(`Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`):(null==t[n].expiresAt||t[n].expiresAt>=i)&&!t[n].dismissed?s.push(t[n]):(e[t[n].id]=!0,h=!0)}return h&&this.h.B(o.q.K,e),s}Ss(){const t=[];for(let s=0;s<this.Xt.length;s++)t.push(this.Xt[s].ss());this.h.B(o.q.Wt,t)}Ts(t,s){if(!this.Us())return void(this.Ds||(this.Ds=this.wt.Rs((()=>{this.Ts(t,s)}))));const i=this.jt.Ls({},!0);i.last_full_sync_at=this.yt,i.last_card_updated_at=this.kt;const e=this.jt.Ns(i,!0);this.jt.As(i,(()=>{b.Fs({url:this.jt.Js()+"/content_cards/sync",data:i,headers:e,S:h=>{this.jt.qs(i,h,e)?(this.jt.Es(),this._s(h),"function"==typeof t&&t()):"function"==typeof s&&s()},error:t=>{this.jt.Ms(t,"retrieving content cards"),"function"==typeof s&&s()}})}))}ys(t){t||this.zt();const s=this.Yt(this.Xt);s.sort(((t,s)=>t.pinned&&!s.pinned?-1:s.pinned&&!t.pinned?1:t.updated>s.updated?-1:s.updated>t.updated?1:0));let i=Math.max(this.kt||0,this.yt||0);return 0===i&&(i=void 0),this.h.I(o.q.ws)===this.kt&&void 0===i&&(i=this.kt),new ContentCards(s,h(i))}Ps(t){return this.vt.Et(t)}changeUser(t){t||(this.Xt=[],this.vt.Nt(new ContentCards(this.Xt.slice(),null)),this.h.$s(o.q.Wt),this.h.$s(o.q.$),this.h.$s(o.q.O),this.h.$s(o.q.K)),this.yt=0,this.kt=0,this.h.$s(o.q.Cs),this.h.$s(o.q.ws)}clearData(t){this.yt=0,this.kt=0,this.Xt=[],this.vt.Nt(new ContentCards(this.Xt.slice(),null)),t&&(this.h.$s(o.q.Wt),this.h.$s(o.q.$),this.h.$s(o.q.O),this.h.$s(o.q.K),this.h.$s(o.q.Cs),this.h.$s(o.q.ws))}Us(){return!!this.wt.Bs()||(0!==this.wt.Gs()&&this.Hs(),!1)}Hs(){this.vt.Nt(new ContentCards([],(new Date).valueOf())),this.h.$s(o.q.Wt)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import x from"../common/base-feed.js";import{logCardClick,logCardImpressions}from"../Card/index.js";import{requestContentCardsRefresh}from"./request-content-cards-refresh.js";export default class ContentCards extends x{constructor(r,e){super(r,e)}getUnviewedCardCount(){return super.getUnreadCardCount()}logCardImpressions(r){logCardImpressions(r,!0)}logCardClick(r){logCardClick(r,!0)}sr(){requestContentCardsRefresh()}dr(){return!0}}ContentCards.ur=6e4;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import g from"./content-cards-provider-factory.js";import e from"../managers/braze-instance.js";export function getCachedContentCards(){if(e.rr())return g.er().ys(!1)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as ContentCards}from"./content-cards.js";export{getCachedContentCards}from"./get-cached-content-cards.js";export{hideContentCards}from"./ui/hide-content-cards.js";export{logContentCardsDisplayed}from"./log-content-cards-displayed.js";export{requestContentCardsRefresh}from"./request-content-cards-refresh.js";export{showContentCards}from"./ui/show-content-cards.js";export{subscribeToContentCardsUpdates}from"./subscribe-to-content-cards-updates.js";export{toggleContentCards}from"./ui/toggle-content-cards.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";export function logContentCardsDisplayed(){if(e.rr())return e.nr().mr(r.lr.br).S}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import g from"./content-cards-provider-factory.js";export function requestContentCardsRefresh(r,t){if(e.rr())return g.er().Ts(r,t)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import g from"./content-cards-provider-factory.js";export function subscribeToContentCardsUpdates(r){if(!e.rr())return;const t=g.er(),n=t.Ps(r);if(!t.Kt()){const r=e.pr().cr((()=>{t.Ts()}));t.Vt(r)}return n}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../../managers/braze-instance.js";import{destroyFeedHtml as y}from"../../common/feed-display.js";export function hideContentCards(n){if(!e.rr())return;const o=document.querySelectorAll(".ab-feed");for(let e=0;e<o.length;e++)(null==n||null!=n&&o[e].parentNode===n)&&y(o[e])}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e,{OPTIONS as D}from"../../managers/braze-instance.js";import{ContentCards,logContentCardsDisplayed,subscribeToContentCardsUpdates}from"../index.js";import g from"../content-cards-provider-factory.js";import{destroyFeedHtml as y,detectFeedImpressions as T,feedToHtml as z,LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as N,refreshFeed as q,registerFeedSubscriptionId as I,updateFeedCards as L}from"../../common/feed-display.js";import{setCardHeight as M}from"../../Card/display/card-display.js";import{setupFeedUI as $}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";export function showContentCards(n,t){if(!e.rr())return;$();let o=!1;null==n&&(n=document.body,o=!0);const a=e.nn(D.tn)||e.nn(D.en)||!1;let i=g.er().ys(!1);"function"==typeof t&&L(i,t(i.cards.slice()),i.lastUpdated,null,a);const s=z(i,a),f=g.er();(null==i.lastUpdated||(new Date).valueOf()-i.lastUpdated.valueOf()>ContentCards.ur)&&(null==f.Bt()||(new Date).valueOf()-f.Bt()>ContentCards.ur)&&(r.D.info(`Cached content cards were older than max TTL of ${ContentCards.ur} ms, requesting an update from the server.`),q(i,s),f.Ht((new Date).valueOf()));const l=(new Date).valueOf(),c=subscribeToContentCardsUpdates((function(n){const e=s.querySelectorAll(".ab-refresh-button")[0];if(null!=e){let n=500;const t=parseInt(s.getAttribute(N));isNaN(t)?n-=(new Date).valueOf()-l:n-=(new Date).valueOf()-t,setTimeout((function(){e.className=e.className.replace(/fa-spin/g,"")}),Math.max(n,0))}let o=n.cards;"function"==typeof t&&(o=t(o.slice())),L(i,o,n.lastUpdated,s,a)}));I(c,s);const u=function(n){const t=n.querySelectorAll(".ab-feed");let e=null;for(let o=0;o<t.length;o++)t[o].parentNode===n&&(e=t[o]);null!=e?(y(e),e.parentNode.replaceChild(s,e)):n.appendChild(s),setTimeout((function(){s.className=s.className.replace("ab-hide","ab-show")}),0),o&&s.focus(),logContentCardsDisplayed(),T(i,s),M(i.cards,n)};var m;null!=n?u(n):window.onload=(m=window.onload,function(){"function"==typeof m&&m(),u(document.body)})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../../managers/braze-instance.js";import{hideContentCards,showContentCards}from"../index.js";export function toggleContentCards(n,o){e.rr()&&(document.querySelectorAll(".ab-feed").length>0?hideContentCards():showContentCards(n,o))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import k from"../managers/braze-instance.js";import BrazeSdkMetadata from"./braze-sdk-metadata.js";import{isArray as p,validateValueIsFromEnum as B}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";export function addSdkMetadata(a){if(k.rr()){if(!p(a))return r.D.error("Cannot set SDK metadata because metadata is not an array."),!1;for(const t of a)if(!B(BrazeSdkMetadata,t,"sdkMetadata contained an invalid value.","BrazeSdkMetadata"))return!1;return k.nr().addSdkMetadata(a),!0}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default{GOOGLE_TAG_MANAGER:"gg",MPARTICLE:"mp",SEGMENT:"sg",TEALIUM:"tl",MANUAL:"manu",NPM:"npm",CDN:"wcd",SHOPIFY:"shp"};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import{getByteLength as U}from"../util/string-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{User}from"../User/index.js";import{validateStandardString as R}from"../util/validation-utils.js";export function changeUser(s,i){return!!e.rr()&&(null==s||0===s.length||s!=s?(r.D.error("changeUser requires a non-empty userId."),!1):U(s)>User.ee?(r.D.error(`Rejected user id "${s}" because it is longer than ${User.ee} bytes.`),!1):!(null!=i&&!R(i,"set signature for new user","signature"))&&void e.pr().changeUser(s.toString(),e.re(),i))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";export function destroy(){r.D.info("Destroying Braze instance"),e.destroy(!0)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default{BROWSER:"browser",BROWSER_VERSION:"browserVersion",OS:"os",RESOLUTION:"resolution",LANGUAGE:"language",TIME_ZONE:"timeZone",USER_AGENT:"userAgent"};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";import K,{STORAGE_KEYS as o}from"../managers/storage-manager.js";export function disableSDK(){null!=e.pr()&&e.pr().requestImmediateDataFlush();const n=new K.ne(null,!0);n.store(o.ae,"This-cookie-will-expire-in-"+n.ie());const a=r.Ft.xt;new r.qt(a,r.D).setItem(a.Pt.oe,a.se,!0),e.destroy(!1),e.le(!0)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";import K,{STORAGE_KEYS as o}from"../managers/storage-manager.js";export function enableSDK(){new K.ne(null,!0).remove(o.ae);const a=r.Ft.xt;new r.qt(a,r.D).gr(a.Pt.oe,a.se),e.destroy(!1),e.le(!1)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";export function getDeviceId(i){e.rr()&&(null==i&&r.D.error("getDeviceId must be supplied with a callback. e.g., braze.getDeviceId(function(deviceId) {console.log('the device id is ' + deviceId)})"),"function"==typeof i&&i(e.ce().te().id))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";export function getUser(){if(e.rr())return e.jr()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"../../shared-lib/braze-shared-lib.js";import e from"../managers/braze-instance.js";import A from"../util/braze-actions.js";import{decodeBrazeActions as F}from"../util/string-utils.js";import{BRAZE_ACTION_URI_REGEX as J,isValidBrazeActionJson as O}from"../util/validation-utils.js";import{WindowUtils as P}from"../util/window-utils.js";import{getUser as G}from"./get-user.js";export function _handleBrazeAction(o,i,t){if(e.rr())if(J.test(o))try{let e=o.match(J)[0].length;const i=o.substring(e);if(e>o.length-1||!i)return void r.D.error(`Did not find base64 encoded brazeAction in url to process : ${o}`);const t=F(i);if(!t)return void r.D.error(`Failed to decode base64 encoded brazeAction: ${i}`);const s=async e=>{if(!O(e))return void r.D.error(`Decoded Braze Action json is invalid: ${JSON.stringify(e,null,2)}`);const o=e[A.properties.type];if(o===A.types.de)for(const r of e[A.properties.ue])s(r);else{const i=e[A.properties.fe];let t,s;switch(o){case A.types.logCustomEvent:t=await import("./log-custom-event.js"),t.logCustomEvent.apply(null,Array.prototype.slice.call(i));break;case A.types.requestPushPermission:t=await import("../Push/request-push-permission.js"),t.requestPushPermission();break;case A.types.setEmailNotificationSubscriptionType:case A.types.setPushNotificationSubscriptionType:case A.types.setCustomUserAttribute:case A.types.addToSubscriptionGroup:case A.types.removeFromSubscriptionGroup:case A.types.addToCustomAttributeArray:case A.types.removeFromCustomAttributeArray:s=G(),s[o].apply(s,Array.prototype.slice.call(i));break;case A.types.me:case A.types.pe:P.openUri.apply(null,Array.prototype.slice.call(i));break;default:r.D.info(`Ignoring unknown Braze Action: ${o}`)}}};s(JSON.parse(t))}catch(e){return void r.D.error(`Failed to process brazeAction URL ${o} : ${e.message}`)}else P.openUri(o,t,i)}export function handleBrazeAction(e,r){_handleBrazeAction(e,r)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{addSdkMetadata}from"./add-sdk-metadata.js";export{changeUser}from"./change-user.js";export{destroy}from"./destroy.js";export{default as BrazeSdkMetadata}from"./braze-sdk-metadata.js";export{default as DeviceProperties}from"./device-properties.js";export{disableSDK}from"./disable-sdk.js";export{enableSDK}from"./enable-sdk.js";export{getDeviceId}from"./get-device-id.js";export{getUser}from"./get-user.js";export{initialize}from"./initialize.js";export{isDisabled}from"./is-disabled.js";export{logCustomEvent}from"./log-custom-event.js";export{logPurchase}from"./log-purchase.js";export{openSession}from"./open-session.js";export{removeAllSubscriptions}from"./remove-all-subscriptions.js";export{removeSubscription}from"./remove-subscription.js";export{requestImmediateDataFlush}from"./request-immediate-data-flush.js";export{setLogger}from"./set-logger.js";export{setSdkAuthenticationSignature}from"./set-sdk-authentication-signature.js";export{subscribeToSdkAuthenticationFailures}from"./subscribe-to-sdk-authentication-failures.js";export{toggleLogging}from"./toggle-logging.js";export{wipeData}from"./wipe-data.js";export{handleBrazeAction}from"./handle-braze-action.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";export function initialize(i,n){return e.initialize(i,n)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import K,{STORAGE_KEYS as o}from"../managers/storage-manager.js";export function isDisabled(){return!!new K.ne(null,!0).wr(o.ae)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import s from"../common/event-logger.js";import r from"../../shared-lib/braze-shared-lib.js";import H from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as Q}from"../triggers/triggers-provider-factory.js";import{validateCustomProperties as V,validateCustomString as W}from"../util/validation-utils.js";export function logCustomEvent(t,o){if(!e.rr())return!1;if(null==t||t.length<=0)return r.D.error(`logCustomEvent requires a non-empty eventName, got "${t}". Ignoring event.`),!1;if(!W(t,"log custom event","the event name"))return!1;const[n,i]=V(o,"logCustomEvent","eventProperties",`log custom event "${t}"`,"event");if(!n)return!1;if(e.ir().ge(t))return r.D.info(`Custom Event "${t}" is blocklisted, ignoring.`),!1;const m=s.G(r.A.CustomEvent,{n:t,p:i});if(m.S){r.D.info(`Logged custom event "${t}".`);for(const e of m.ve)Q.er().je(H.be,[t,o],e)}return m.S}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import{MAX_PURCHASE_QUANTITY as Z}from"../common/constants.js";import r from"../../shared-lib/braze-shared-lib.js";import H from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as Q}from"../triggers/triggers-provider-factory.js";import{validateCustomProperties as V,validateCustomString as W}from"../util/validation-utils.js";import s from"../common/event-logger.js";export function logPurchase(o,i,t,n,D){if(!e.rr())return!1;if(null==t&&(t="USD"),null==n&&(n=1),null==o||o.length<=0)return r.D.error(`logPurchase requires a non-empty productId, got "${o}", ignoring.`),!1;if(!W(o,"log purchase","the purchase name"))return!1;let a=parseFloat(i);if(isNaN(a))return r.D.error(`logPurchase requires a numeric price, got ${i}, ignoring.`),!1;a=a.toFixed(2);const g=parseInt(n);if(isNaN(g))return r.D.error(`logPurchase requires an integer quantity, got ${n}, ignoring.`),!1;if(g<1||g>Z)return r.D.error(`logPurchase requires a quantity >1 and <${Z}, got ${g}, ignoring.`),!1;t=t.toUpperCase();if(-1===["AED","AFN","ALL","AMD","ANG","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BRL","BSD","BTC","BTN","BWP","BYR","BZD","CAD","CDF","CHF","CLF","CLP","CNY","COP","CRC","CUC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EEK","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GGP","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HRK","HTG","HUF","IDR","ILS","IMP","INR","IQD","IRR","ISK","JEP","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LTL","LVL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRO","MTL","MUR","MVR","MWK","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLL","SOS","SRD","STD","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VEF","VND","VUV","WST","XAF","XAG","XAU","XCD","XDR","XOF","XPD","XPF","XPT","YER","ZAR","ZMK","ZMW","ZWL"].indexOf(t))return r.D.error(`logPurchase requires a valid currencyCode, got ${t}, ignoring.`),!1;const[u,P]=V(D,"logPurchase","purchaseProperties",`log purchase "${o}"`,"purchase");if(!u)return!1;if(e.ir().Dr(o))return r.D.info(`Purchase "${o}" is blocklisted, ignoring.`),!1;const R=s.G(r.A.Pr,{pid:o,c:t,p:a,q:g,pr:P});if(R.S){r.D.info(`Logged ${g} purchase${g>1?"s":""} of "${o}" for ${t} ${a}.`);for(const r of R.ve)Q.er().je(H.Rr,[o,D],r)}return R.S}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";import H from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as Q}from"../triggers/triggers-provider-factory.js";export function openSession(){if(!e.rr())return;e.pr().openSession();const i=r.Ft.xt,o=new r.qt(i,r.D);o.hr(i.Pt.kr,(function(t,n){const s=n.lastClick,c=n.trackingString;r.D.info(`Firing push click trigger from ${c} push click at ${s}`);const g=e.pr().vr(s,c),f=function(){Q.er().je(H.zr,[c],g)};e.pr().$r(f,f),o.gr(i.Pt.kr,t)})),o.Jt(i.Pt.yr,(function(r){e.pr().Fr(r)}))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";export function removeAllSubscriptions(){e.rr()&&e.removeAllSubscriptions()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";export function removeSubscription(r){e.rr()&&e.removeSubscription(r)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";export function requestImmediateDataFlush(a){e.rr()&&e.pr().requestImmediateDataFlush(a)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"../../shared-lib/braze-shared-lib.js";export function setLogger(e){r.D.setLogger(e)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import{validateStandardString as R}from"../util/validation-utils.js";export function setSdkAuthenticationSignature(t){return!!e.rr()&&(!(""===t||!R(t,"set signature","signature",!1))&&(e.ti().setSdkAuthenticationSignature(t),!0))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";export function subscribeToSdkAuthenticationFailures(r){if(e.rr())return e.ti().subscribeToSdkAuthenticationFailures(r)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"../../shared-lib/braze-shared-lib.js";export function toggleLogging(){r.D.toggleLogging()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import{keys as X}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";export function wipeData(){if(null==e.l())throw new Error("Braze must be initialized before calling methods.");e.l().clearData();const o=X(r.Ft);for(let e=0;e<o.length;e++){const i=o[e],t=r.Ft[i];new r.qt(t,r.D).clearData()}if(e.rr())for(const r of e.re())r.clearData(!0)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import Y from"./feed-provider.js";const ee={t:!1,provider:null,er:()=>(ee.o(),ee.provider||(ee.provider=new Y(e.l(),e.pr()),e.ar(ee.provider)),ee.provider),o:()=>{ee.t||(e.u(ee),ee.t=!0)},destroy:()=>{ee.provider=null,ee.t=!1}};export default ee;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import C from"../common/base-provider.js";import e from"../managers/braze-instance.js";import Feed from"./feed.js";import{newCardFromFeedJson as tt,newCardFromSerializedValue as _}from"../Card/util/card-factory.js";import{rehydrateDateAfterJsonization as w}from"../util/date-utils.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import u from"../managers/subscription-manager.js";export default class Y extends C{constructor(t,s){super(),this.h=t,this.Is=s,this.vt=new u,e.Ut(this.vt),this.zt()}zt(){const t=this.h.I(o.q.Ks)||[],s=[];for(let i=0;i<t.length;i++){const e=_(t[i]);null!=e&&s.push(e)}this.Xt=s,this.Os=w(this.h.I(o.q.Qs))}Vs(t){const s=[];let i=null;const e=this.h.I(o.q.P)||{},r={};for(let h=0;h<t.length;h++){i=t[h];const o=tt(i);null!=o&&(e[o.id]&&(o.viewed=!0,r[o.id]=!0),s.push(o))}this.h.B(o.q.P,r),this.Xt=s,this.Ss(),this.Os=new Date,this.h.B(o.q.Qs,this.Os)}Ss(){const t=[];for(let s=0;s<this.Xt.length;s++)t.push(this.Xt[s].ss());this.h.B(o.q.Ks,t)}_s(t){null!=t&&t.feed&&(this.zt(),this.Vs(t.feed),this.vt.Nt(new Feed(this.Xt.slice(),this.Os)))}Ws(){this.zt();const t=[],s=new Date;for(let i=0;i<this.Xt.length;i++)(null==this.Xt[i].expiresAt||this.Xt[i].expiresAt>=s)&&t.push(this.Xt[i]);return new Feed(t,this.Os)}Ts(){this.Is.requestFeedRefresh()}Ps(t){return this.vt.Et(t)}clearData(t){null==t&&(t=!1),this.Xt=[],this.Os=null,t&&(this.h.$s(o.q.Ks),this.h.$s(o.q.Qs)),this.vt.Nt(new Feed(this.Xt.slice(),this.Os))}}
|
package/src/Feed/feed.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import x from"../common/base-feed.js";import{logCardClick,logCardImpressions}from"../Card/index.js";import{requestFeedRefresh}from"./request-feed-refresh.js";export default class Feed extends x{constructor(r,e){super(r,e)}logCardImpressions(r){logCardImpressions(r,!1)}logCardClick(r){logCardClick(r,!1)}sr(){requestFeedRefresh()}dr(){return!1}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import ee from"./feed-provider-factory.js";export function getCachedFeed(){if(e.rr())return ee.er().Ws()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as Feed}from"./feed.js";export{getCachedFeed}from"./get-cached-feed.js";export{destroyFeed}from"./ui/hide-feed.js";export{logFeedDisplayed}from"./log-feed-displayed.js";export{requestFeedRefresh}from"./request-feed-refresh.js";export{showFeed}from"./ui/show-feed.js";export{subscribeToFeedUpdates}from"./subscribe-to-feed-updates.js";export{toggleFeed}from"./ui/toggle-feed.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";export function logFeedDisplayed(){if(e.rr())return e.nr().mr(r.lr.qr).S}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import ee from"./feed-provider-factory.js";export function requestFeedRefresh(){if(e.rr())return ee.er().Ts()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import ee from"./feed-provider-factory.js";export function subscribeToFeedUpdates(r){if(e.rr())return ee.er().Ps(r)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../../managers/braze-instance.js";import{destroyFeedHtml as y}from"../../common/feed-display.js";export function destroyFeed(){if(!e.rr())return;const o=document.querySelectorAll(".ab-feed");for(let e=0;e<o.length;e++)y(o[e])}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e,{OPTIONS as D}from"../../managers/braze-instance.js";import{destroyFeedHtml as y,detectFeedImpressions as T,feedToHtml as z,LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as N,refreshFeed as q,registerFeedSubscriptionId as I,updateFeedCards as L}from"../../common/feed-display.js";import{Feed,logFeedDisplayed,subscribeToFeedUpdates}from"../index.js";import ee from"../feed-provider-factory.js";import{intersection as te}from"../../util/code-utils.js";import{setCardHeight as M}from"../../Card/display/card-display.js";import{setupFeedUI as $}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";export function showFeed(t,n,o){if(!e.rr())return;$();const s=(e,t)=>{if(null==t)return e;const n=[];for(let e=0;e<t.length;e++)n.push(t[e].toLowerCase());const o=[];for(let t=0;t<e.length;t++){const r=[];for(let n=0;n<e[t].categories.length;n++)r.push(e[t].categories[n].toLowerCase());te(r,n).length>0&&o.push(e[t])}return o},i=e.nn(D.tn)||e.nn(D.en)||!1;let l=!1;null==t&&(t=document.body,l=!0);let a=!1,f=null;null==n?(f=ee.er().Ws(),L(f,s(f.cards,o),f.lastUpdated,null,i),a=!0):f=new Feed(s(n,o),new Date);const u=z(f,i);if(a){(null==f.lastUpdated||(new Date).valueOf()-f.lastUpdated.valueOf()>Feed.ur)&&(r.D.info(`Cached feed was older than max TTL of ${Feed.ur} ms, requesting an update from the server.`),q(f,u));const e=(new Date).valueOf(),t=subscribeToFeedUpdates((function(t){const n=u.querySelectorAll(".ab-refresh-button")[0];if(null!=n){let t=500;const o=parseInt(u.getAttribute(N));isNaN(o)?t-=(new Date).valueOf()-e:t-=(new Date).valueOf()-o,setTimeout((function(){n.className=n.className.replace(/fa-spin/g,"")}),Math.max(t,0))}L(f,s(t.cards,o),t.lastUpdated,u,i)}));I(t,u)}const m=e=>{const t=e.querySelectorAll(".ab-feed");let n=null;for(let o=0;o<t.length;o++)t[o].parentNode===e&&(n=t[o]);null!=n?(y(n),n.parentNode.replaceChild(u,n)):e.appendChild(u),setTimeout((function(){u.className=u.className.replace("ab-hide","ab-show")}),0),l&&u.focus(),logFeedDisplayed(),T(f,u),M(f.cards,e)};var c;null!=t?m(t):window.onload=(c=window.onload,function(){"function"==typeof c&&c(),m(document.body)})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../../managers/braze-instance.js";import{destroyFeed,showFeed}from"../index.js";export function toggleFeed(o,n,r){e.rr()&&(document.querySelectorAll(".ab-feed").length>0?destroyFeed():showFeed(o,n,r))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{FullScreenMessage,HtmlMessage,ModalMessage,SlideUpMessage}from"../index.js";export default function ae(e){let t="";return e.animateIn&&(t+=" ab-animate-in"),e.animateOut&&(t+=" ab-animate-out"),e instanceof FullScreenMessage?t+=" ab-effect-fullscreen":e instanceof HtmlMessage?t+=" ab-effect-html":e instanceof ModalMessage?t+=" ab-effect-modal":e instanceof SlideUpMessage&&(t+=" ab-effect-slide"),t}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{attachInAppMessageCSS as nt}from"../../ui/js/iam-css.js";import et from"../../util/browser-detector.js";import{logInAppMessageHtmlClick}from"../index.js";import{getUser as G}from"../../Core/get-user.js";import{InAppMessage}from"../index.js";import{keys as X}from"../../util/code-utils.js";import{OperatingSystems as ot}from"../../util/device-constants.js";import{parseQueryStringKeyValues as st}from"../../util/url-utils.js";import{WindowUtils as P}from"../../util/window-utils.js";export default function rt(t,n,e,o,s,r){const i=document.createElement("iframe");i.setAttribute("title","Modal Message"),s&&(i.style.zIndex=s+1);const u=n=>{const e=n.getAttribute("href"),s=n.onclick;return r=>{if(null!=s&&"function"==typeof s&&!1===s())return;let u=st(e).abButtonId;if(null!=u&&""!==u||(u=n.getAttribute("id")),null!=e&&""!==e&&0!==e.indexOf("#")){const s="blank"===(n.getAttribute("target")||"").toLowerCase().replace("_",""),c=o||t.openTarget===InAppMessage.OpenTarget.BLANK||s,a=()=>{logInAppMessageHtmlClick(t,u,e),P.openUri(e,c,r)};c?a():t.on(i,a)}else logInAppMessageHtmlClick(t,u,e);return r.stopPropagation(),!1}},c=(t,n,e)=>{const o=`([\\w]+)\\s*=\\s*document.createElement\\(['"]${e}['"]\\)`,s=t.match(new RegExp(o));if(s){const e=`${s[1]}.setAttribute("nonce", "${n}")`;return`${t.slice(0,s.index+s[0].length)};${e};${t.slice(s.index+s[0].length)}`}return null};if(i.onload=()=>{let o=null;if(null!=r){o=document.createElement("html"),o.innerHTML=t.message;const n=o.getElementsByTagName("style");for(let t=0;t<n.length;t++)n[t].setAttribute("nonce",r);const e=o.getElementsByTagName("script");for(let t=0;t<e.length;t++){e[t].setAttribute("nonce",r),e[t].innerHTML=e[t].innerHTML.replace(/<style>/g,`<style nonce='${r}'>`);const n=c(e[t].innerHTML,r,"script");n&&(e[t].innerHTML=n);const o=c(e[t].innerHTML,r,"style");o&&(e[t].innerHTML=o)}}i.contentWindow.focus(),i.contentWindow.document.write(o?o.innerHTML:t.message);const s=i.contentWindow.document.getElementsByTagName("head")[0];if(null!=s){if(nt(s),t.sn()){const n=document.createElement("style");n.innerHTML=t.css,n.id=t.rn(),null!=r&&n.setAttribute("nonce",r),s.appendChild(n)}const n=i.contentWindow.document.createElement("base");n.setAttribute("target","_parent"),s.appendChild(n)}const a=i.contentWindow.document.getElementsByTagName("title");a.length>0&&i.setAttribute("title",a[0].textContent);const l={closeMessage:function(){t.on(i)},logClick:function(){const n=[t,...arguments];logInAppMessageHtmlClick.apply(t,Array.prototype.slice.call(n))},display:{},web:{}},requestPushPermission=function(){return function(){const t=arguments;import("../../Push/request-push-permission.js").then((n=>{n.requestPushPermission.apply(null,Array.prototype.slice.call(t))}))}},m={requestImmediateDataFlush:async function(){const t=arguments,n=await import("../../Core/request-immediate-data-flush.js");n.requestImmediateDataFlush.apply(null,Array.prototype.slice.call(t))},logCustomEvent:async function(){const t=arguments,n=await import("../../Core/log-custom-event.js");n.logCustomEvent.apply(null,Array.prototype.slice.call(t))},logPurchase:async function(){const t=arguments,n=await import("../../Core/log-purchase.js");n.logPurchase.apply(null,Array.prototype.slice.call(t))},unregisterPush:async function(){const t=arguments,n=await import("../../Push/unregister-push.js");n.unregisterPush.apply(null,Array.prototype.slice.call(t))},requestPushPermission:requestPushPermission()},f=function(t){return function(){m[t].apply(null,Array.prototype.slice.call(arguments))}};for(const t of X(m))l[t]=f(t);const d=["setFirstName","setLastName","setEmail","setGender","setDateOfBirth","setCountry","setHomeCity","setEmailNotificationSubscriptionType","setLanguage","addAlias","setPushNotificationSubscriptionType","setPhoneNumber","setCustomUserAttribute","addToCustomAttributeArray","removeFromCustomAttributeArray","incrementCustomUserAttribute","setCustomLocationAttribute","addToSubscriptionGroup","removeFromSubscriptionGroup"],p=function(t){return function(){const n=G();n[t].apply(n,Array.prototype.slice.call(arguments))}},y={};for(let t=0;t<d.length;t++)y[d[t]]=p(d[t]);l.getUser=function(){return y};const b={showFeed:n},h=function(n){return function(){const e=arguments;t.on(i,(function(){b[n].apply(null,Array.prototype.slice.call(e))}))}};for(const t of X(b))l.display[t]=h(t);const g={registerAppboyPushMessages:requestPushPermission()},A=function(t){return function(){g[t].apply(null,Array.prototype.slice.call(arguments))}};for(const t of X(g))l.web[t]=A(t);if(i.contentWindow.appboyBridge=l,i.contentWindow.brazeBridge=l,t.un!==InAppMessage.es.cn){const t=i.contentWindow.document.getElementsByTagName("a");for(let n=0;n<t.length;n++)t[n].onclick=u(t[n]);const n=i.contentWindow.document.getElementsByTagName("button");for(let t=0;t<n.length;t++)n[t].onclick=u(n[t])}const j=i.contentWindow.document.body;if(null!=j){t.an()&&(j.id=t.htmlId);const n=document.createElement("hidden");n.onclick=l.closeMessage,n.className="ab-programmatic-close-button",j.appendChild(n)}i.contentWindow.dispatchEvent(new CustomEvent("ab.BridgeReady")),-1!==i.className.indexOf("ab-start-hidden")&&(i.className=i.className.replace("ab-start-hidden",""),e(i)),document.activeElement!==i&&i.focus()},i.className="ab-in-app-message ab-start-hidden ab-html-message ab-modal-interactions",et.OS===ot.ln){const n=document.createElement("div");return n.className="ab-ios-scroll-wrapper",n.appendChild(i),t.mn=n,n}return t.mn=i,i}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{addPassiveEventListener as oe,buildSvg as ne,detectSwipe as d,DIRECTIONS as c}from"../../util/dom-utils.js";import{createCloseButton as i}from"../../util/component-utils.js";import{isTransparent as ie,toRgba as se}from"../../util/color-utils.js";import{FullScreenMessage,HtmlMessage,InAppMessage,logInAppMessageClick,ModalMessage,SlideUpMessage}from"../index.js";import{_handleBrazeAction as m}from"../../Core/handle-braze-action.js";import rt from"./html-message-to-html.js";import ce from"./modal-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";export default function re(e,t,o,a,n,s){if(e.he=document.activeElement,e instanceof HtmlMessage)return rt(e,t,o,a,n,s);const l=function(e,t,o,a,n){const s=document.createElement("div");s.className="ab-in-app-message ab-start-hidden ab-background",n&&(s.style.zIndex=n+1),e.we()&&(s.className+=" ab-modal-interactions",s.setAttribute("tabindex","-1")),e.sn()||(s.style.color=se(e.textColor),s.style.backgroundColor=se(e.backgroundColor),ie(e.backgroundColor)&&(s.className+=" ab-no-shadow"));const c=()=>{-1!==s.className.indexOf("ab-start-hidden")&&(s.className=s.className.replace("ab-start-hidden",""),o(s))};e.imageStyle===InAppMessage.ImageStyle.GRAPHIC&&(s.className+=" graphic"),e.orientation===InAppMessage.Orientation.LANDSCAPE&&(s.className+=" landscape"),0===e.buttons.length&&(e.clickAction!==InAppMessage.ClickAction.NONE&&(s.className+=" ab-clickable"),s.onclick=o=>(e.on(s,(()=>{logInAppMessageClick(e),e.clickAction===InAppMessage.ClickAction.URI?m(e.uri,o,a||e.openTarget===InAppMessage.OpenTarget.BLANK):e.clickAction===InAppMessage.ClickAction.NEWS_FEED&&t()})),o.stopPropagation(),!1));const d=i("Close Message",e.sn()?void 0:se(e.closeButtonColor),(()=>{e.on(s)}));s.appendChild(d),n&&(d.style.zIndex=n+2);const l=document.createElement("div");l.className="ab-message-text";const b=(e.messageAlignment||e.xe).toLowerCase();l.className+=" "+b+"-aligned";let u=!1;const f=document.createElement("div");if(f.className="ab-image-area",e.imageUrl){if(e.cropType===InAppMessage.CropType.CENTER_CROP){const t=document.createElement("span");t.className="ab-center-cropped-img",t.style.backgroundImage="url("+e.imageUrl+")",t.setAttribute("role","img"),t.setAttribute("aria-label","Modal Image"),e.ze(t),f.appendChild(t)}else{const t=document.createElement("img");t.setAttribute("src",e.imageUrl),e.ze(t),u=!0,t.onload=c,setTimeout(c,1e3),f.appendChild(t)}s.appendChild(f),l.className+=" ab-with-image"}else if(e.icon){f.className+=" ab-icon-area";const t=document.createElement("span");t.className="ab-icon",e.sn()||(t.style.backgroundColor=se(e.iconBackgroundColor),t.style.color=se(e.iconColor));const o=document.createElement("i");o.className="fa",o.appendChild(document.createTextNode(e.icon)),o.setAttribute("aria-hidden",!0),t.appendChild(o),f.appendChild(t),s.appendChild(f),l.className+=" ab-with-icon"}if(oe(l,"touchstart",(function(){})),e.header&&e.header.length>0){const t=document.createElement("h1");t.className="ab-message-header",e.Me=r.nt.et(),t.id=e.Me;const o=(e.headerAlignment||InAppMessage.TextAlignment.CENTER).toLowerCase();t.className+=" "+o+"-aligned",e.sn()||(t.style.color=se(e.headerTextColor)),t.appendChild(document.createTextNode(e.header)),l.appendChild(t)}return l.appendChild(e.ke()),s.appendChild(l),u||c(),e.mn=s,s}(e,t,o,a,n);if(e instanceof FullScreenMessage||e instanceof ModalMessage){const o=e instanceof FullScreenMessage?"ab-fullscreen":"ab-modal";l.className+=` ${o} ab-centered`,ce.Ce(e,t,l,a),ce.Le(l),ce.Ie(e.Me,l)}else if(e instanceof SlideUpMessage){l.className+=" ab-slideup";const t=l.getElementsByClassName("ab-close-button")[0];if(null!=t){const o=ne("0 0 11.38 19.44","M11.38 9.72l-9.33 9.72L0 17.3l7.27-7.58L0 2.14 2.05 0l9.33 9.72z",e.sn()?void 0:se(e.closeButtonColor));o.setAttribute("class","ab-chevron"),t.appendChild(o)}let o,a;d(l,c.ot,(e=>{l.className+=" ab-swiped-left",t.onclick(e)})),d(l,c.at,(e=>{l.className+=" ab-swiped-right",t.onclick(e)})),e.slideFrom===InAppMessage.SlideFrom.TOP?(o=c.Te,a=" ab-swiped-up"):(o=c.$e,a=" ab-swiped-down"),d(l,o,(e=>{l.className+=a,t.onclick(e)}))}return l}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{InAppMessage}from"../index.js";import{_handleBrazeAction as m}from"../../Core/handle-braze-action.js";import{logInAppMessageButtonClick}from"../log-in-app-message-button-click.js";import{toRgba as se}from"../../util/color-utils.js";import{addPassiveEventListener as oe}from"../../util/dom-utils.js";import{KeyCodes as at}from"../../util/key-codes.js";const ce={Le:t=>{const o=t.querySelectorAll(".ab-close-button, .ab-message-text, .ab-message-button");for(let t=0;t<o.length;t++)o[t].tabIndex=0;if(o.length>0){const e=o[0],s=o[o.length-1];t.addEventListener("keydown",(o=>{var a=document.activeElement;o.keyCode===at.oo&&(o.shiftKey||a!==s&&a!==t?!o.shiftKey||a!==e&&a!==t||(o.preventDefault(),s.focus()):(o.preventDefault(),e.focus()))}))}},Ie:(t,o)=>{o.setAttribute("role","dialog"),o.setAttribute("aria-modal",!0),o.setAttribute("aria-label","Modal Message"),t&&o.setAttribute("aria-labelledby",t)},Ce:(t,o,e,s)=>{if(t.buttons.length>0){const a=document.createElement("div");a.className="ab-message-buttons",e.appendChild(a);const n=e.getElementsByClassName("ab-message-text")[0];null!=n&&(n.className+=" ab-with-buttons");const l=a=>n=>(t.on(e,(()=>{logInAppMessageButtonClick(a,t),a.clickAction===InAppMessage.ClickAction.URI?m(a.uri,n,s||t.openTarget===InAppMessage.OpenTarget.BLANK):a.clickAction===InAppMessage.ClickAction.NEWS_FEED&&o()})),n.stopPropagation(),!1);for(let o=0;o<t.buttons.length;o++){const e=t.buttons[o],s=document.createElement("button");s.className="ab-message-button",s.setAttribute("type","button"),oe(s,"touchstart",(function(){}));let n=e.text;""===e.text&&(n=" "),s.appendChild(document.createTextNode(n)),t.sn()||(s.style.backgroundColor=se(e.backgroundColor),s.style.color=se(e.textColor),s.style.borderColor=se(e.borderColor)),s.onclick=l(e),a.appendChild(s)}}}};export default ce;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{InAppMessage,ControlMessage,FullScreenMessage,HtmlMessage,InAppMessageButton,ModalMessage,SlideUpMessage}from"./index.js";import r from"../../shared-lib/braze-shared-lib.js";export function newInAppMessageFromJson(e){if(e.is_control)return ControlMessage.fromJson(e);let n=e.type;null!=n&&(n=n.toUpperCase());const l=e.message,o=e.text_align_message,i=e.slide_from,t=e.extras,s=e.trigger_id,f=e.click_action,u=e.uri,w=e.open_target,d=e.message_close,m=e.duration,p=e.icon,a=e.image_url,c=e.image_style,g=e.icon_color,b=e.icon_bg_color,h=e.bg_color,v=e.text_color,j=e.close_btn_color,x=e.header,I=e.text_align_header,k=e.header_text_color,y=e.frame_color,z=[];let A=e.btns;null==A&&(A=[]);for(let e=0;e<A.length;e++)z.push(InAppMessageButton.fromJson(A[e]));const F=e.crop_type,J=e.orientation,M=e.animate_in,q=e.animate_out;let B,C=e.html_id,D=e.css;if(null!=C&&""!==C&&null!=D&&""!==D||(C=void 0,D=void 0),n===ModalMessage.es||n===InAppMessage.es.ye)B=new ModalMessage(l,o,t,s,f,u,w,d,m,p,a,c,g,b,h,v,j,M,q,x,I,k,y,z,F,C,D);else if(n===FullScreenMessage.es)B=new FullScreenMessage(l,o,t,s,f,u,w,d,m,p,a,c,g,b,h,v,j,M,q,x,I,k,y,z,F,J,C,D);else if(n===SlideUpMessage.es)B=new SlideUpMessage(l,o,i,t,s,f,u,w,d,m,p,a,g,b,h,v,j,M,q,C,D);else{if(n!==HtmlMessage.es&&n!==InAppMessage.es.cn)return void r.D.error("Ignoring message with unknown type "+n);{const n=e.message_fields;B=new HtmlMessage(l,t,s,d,m,M,q,y,C,D,n),B.trusted=e.trusted||!1}}return B.un=n,B}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import ge from"./in-app-message-manager.js";import e from"../managers/braze-instance.js";const me={Ae:null,t:!1,m:()=>(me.o(),me.Ae||(me.Ae=new ge(e.nr(),e.g(),e.l(),e.p())),me.Ae),o:()=>{me.t||(e.u(me),me.t=!0)},destroy:()=>{me.Ae=null,me.t=!1}};export default me;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import b from"../util/net.js";import e from"../managers/braze-instance.js";import{ControlMessage,HtmlMessage,InAppMessage,InAppMessageButton}from"./index.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 B}from"../util/code-utils.js";export default class ge{constructor(t,i,s,r){this.jt=t,this.j=i,this.h=s,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(!B(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.Re,n)}G(e,i,n,a){const o=new t;let l;if(e instanceof ControlMessage)l={trigger_ids:[e.triggerId]};else{if(i===r.A.He||e instanceof HtmlMessage&&i===r.A.Je){if(!e.k(a))return r.D.info("This in-app message has already received a click. Ignoring analytics event."),o}else if(i===r.A.Ke){if(!e.R())return r.D.info("This in-app message has already received an impression. Ignoring analytics event."),o}l=this.Pe(e)}return null==l?o:(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 a=this.Pe(i);return null==a?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&&(a.bid=e.id),s.G(r.A.Je,a))}Ve(t,e,i,s){let r=this.jt.We(!1,!1);r=this.jt.Ls(r),r.template={trigger_id:t.triggerId,trigger_event_type:e},null!=i&&(r.template.data=i.Xe());const n=this.jt.Ns(r);this.jt.As(r,(()=>{b.Fs({url:`${this.jt.Js()}/template/`,data:r,headers:n,S:e=>{if(!this.jt.qs(r,e,n))return this.qe(t.triggerId,InAppMessage.Oe.Ye),void("function"==typeof t.Ze&&t.Ze());if(this.jt.Es(),null==e||null==e.templated_message)return void this.qe(t.triggerId,InAppMessage.Oe.Ye);const i=e.templated_message;if(i.type!==ut.ii.ei)return void this.qe(t.triggerId,InAppMessage.Oe.si);const s=it(i.data);null!=s?"function"==typeof t.ri?t.ri(s):this.qe(t.triggerId,InAppMessage.Oe.Ye):this.qe(t.triggerId,InAppMessage.Oe.si)},error:r=>{let n=`getting user personalization for message ${t.triggerId}`;if((new Date).valueOf()-t.ni>t.ai)this.qe(t.triggerId,InAppMessage.Oe.Ye);else{const r=Math.min(t.ai,this.Se),a=this._e;null==s&&(s=a);const o=Math.min(r,lt(a,3*s));n+=`. Retrying in ${o} ms`,setTimeout((()=>{this.Ve(t,e,i,o)}),o)}this.jt.Ms(r,n)}})}))}Pe(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}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as InAppMessage}from"./models/in-app-message.js";export{default as InAppMessageButton}from"./models/in-app-message-button.js";export{default as ControlMessage}from"./models/control-message.js";export{default as FullScreenMessage}from"./models/full-screen-message.js";export{default as HtmlMessage}from"./models/html-message.js";export{default as ModalMessage}from"./models/modal-message.js";export{default as SlideUpMessage}from"./models/slide-up-message.js";export{automaticallyShowInAppMessages}from"./ui/automatically-show-in-app-messages.js";export{logInAppMessageButtonClick}from"./log-in-app-message-button-click.js";export{logInAppMessageClick}from"./log-in-app-message-click.js";export{logInAppMessageHtmlClick}from"./log-in-app-message-html-click.js";export{logInAppMessageImpression}from"./log-in-app-message-impression.js";export{showInAppMessage}from"./ui/show-in-app-message.js";export{subscribeToInAppMessage}from"./subscribe-to-in-app-message.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as rr}from"../common/constants.js";import{InAppMessage,InAppMessageButton}from"../InAppMessage/index.js";import me from"./in-app-message-manager-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import H from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as Q}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=me.m().Qe(t,o);if(s.S)for(let r=0;r<s.ve.length;r++)Q.er().je(H.Ar,[o.triggerId,t.id],s.ve[r]);return s.S}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import{InAppMessage}from"../InAppMessage/index.js";import me 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 H from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as Q}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=me.m().G(o,r.A.He);if(s)for(let r=0;r<s.ve.length;r++)Q.er().je(H.Ar,[o.triggerId],s.ve[r]);return s.S}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import{HtmlMessage}from"../InAppMessage/index.js";import me from"./in-app-message-manager-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import H from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as Q}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 i=r.A.He;null!=t&&(i=r.A.Je);const n=me.m().G(s,i,t,o);if(n.S)for(let r=0;r<n.ve.length;r++)Q.er().je(H.Ar,[s.triggerId,t],n.ve[r]);return n.S}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import{ControlMessage,InAppMessage}from"../InAppMessage/index.js";import me 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(n){if(!e.rr())return!1;if(!(n instanceof InAppMessage||n instanceof ControlMessage))return r.D.error(rr),!1;const s=n instanceof ControlMessage?r.A.W:r.A.Ke;return me.m().G(n,s).S}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class ControlMessage{constructor(t){this.triggerId=t}static fromJson(t){return new ControlMessage(t.trigger_id)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{InAppMessage}from"../index.js";export default class FullScreenMessage extends InAppMessage{constructor(e,t,r,n,l,s,u,o,d,x,a,c,f,i,m,p,g,j,A,T,b,h,k,q,v,w,y,z){o=o||InAppMessage.DismissType.MANUAL,w=w||InAppMessage.Orientation.PORTRAIT,super(e,t,null,r,n,l,s,u,o,d,x,a,c,f,i,m,p,g,j,A,T,b,h,k,q,v=v||InAppMessage.CropType.CENTER_CROP,w,y,z)}get xe(){return InAppMessage.TextAlignment.CENTER}}FullScreenMessage.es=InAppMessage.es.Tr;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{InAppMessage}from"../index.js";export default class HtmlMessage extends InAppMessage{constructor(l,n,u,e,s,a,t,i,r,o,m){e=e||InAppMessage.DismissType.MANUAL,null!=l&&l.length>0&&l.indexOf('"ab-in-app-message ab-html-message ab-email-capture"')>0&&l.indexOf('"ab-in-app-message ab-show ab-modal ab-effect-modal"')>0&&(a=!0,t=!0),super(l,null,null,n,u,null,null,null,e,s,null,null,null,null,null,null,null,null,a,t,null,null,null,i,void 0,void 0,void 0,r,o),this.messageFields=m}ll(){return!1}k(l){if(this.un===InAppMessage.es.nl){if(this.ul)return!1;this.ul=!0}return this.lt.Nt(l),!0}}HtmlMessage.es=InAppMessage.es.nl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{InAppMessage}from"../index.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.Ys.Xs,this.textColor=i||InAppMessage.Ys.Zs,this.borderColor=r||this.backgroundColor,this.clickAction=e||InAppMessage.ClickAction.NONE,this.uri=h,null==n&&(n=InAppMessageButton.Ue),this.id=n,this.ul=!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.ul&&(this.ul=!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;
|
|
@@ -0,0 +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.Ys.Zs,this.iconBackgroundColor=I||InAppMessage.Ys.Xs,this.backgroundColor=A||InAppMessage.Ys.Zs,this.textColor=N||InAppMessage.Ys.hi,this.closeButtonColor=_||InAppMessage.Ys.oi,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.Ys.hi,this.frameColor=M||InAppMessage.Ys.li,this.buttons=R||[],this.cropType=b||InAppMessage.CropType.FIT_CENTER,this.orientation=P,this.htmlId=C,this.css=U,this.Ei=!1,this.ul=!1,this.ui=!1,this.lt=new u,this.Ti=new u}subscribeToClickedEvent(t){return this.lt.Et(t)}subscribeToDismissedEvent(t){return this.Ti.Et(t)}removeSubscription(t){this.lt.removeSubscription(t),this.Ti.removeSubscription(t)}removeAllSubscriptions(){this.lt.removeAllSubscriptions(),this.Ti.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.Ei&&(this.Ei=!0,!0)}k(){return!this.ul&&(this.ul=!0,this.lt.Nt(),!0)}J(){return!this.ui&&(this.ui=!0,this.Ti.Nt(),!0)}mi(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.ci)&&t.remove(InAppMessage.ci),document.body.removeEventListener("touchmove",InAppMessage.Ii)}s.className=s.className.replace(InAppMessage.Ai,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.mi(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.Ni):r(),this.he&&this.he.focus()}ke(){return document.createTextNode(this.message)}ze(t){let s="";this.message||this.header||!this.we()||(s="Modal Image"),t.setAttribute("alt",s)}static Ii(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.ci}`)&&t.preventDefault()}_i(t){this.we()&&null!=t.parentNode&&this.orientation!==InAppMessage.Orientation.LANDSCAPE&&(null!=t.parentNode.classList&&t.parentNode.classList.add(InAppMessage.ci),document.body.addEventListener("touchmove",InAppMessage.Ii,!!Et()&&{passive:!1})),t.className+=" "+InAppMessage.Ai}static Li(t){if(t.keyCode===at.di&&!e.nn(D.Oi)&&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)}}}Si(){this.Di||e.nn(D.Oi)||(document.addEventListener("keydown",InAppMessage.Li,!1),e.Mi((()=>{document.removeEventListener("keydown",InAppMessage.Li)})),this.Di=!0)}}InAppMessage.Ys={hi:4281545523,Zs:4294967295,Xs:4278219733,Ri:4293914607,bi:4283782485,li:3224580915,oi:4288387995},InAppMessage.Oe={Pi:"hd",Ci:"ias",Ui:"of",pi:"do",si:"umt",Ye:"tf",fi:"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",Hi:"MODAL",ye:"MODAL_STYLED",Tr:"FULL",nl:"WEB_HTML",cn:"HTML"},InAppMessage.Ni=500,InAppMessage.Fi=200,InAppMessage.Ai="ab-show",InAppMessage.Bi="ab-hide",InAppMessage.ci="ab-pause-scrolling";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{InAppMessage}from"../index.js";export default class ModalMessage extends InAppMessage{constructor(e,t,r,n,l,o,s,u,d,i,x,a,c,f,m,p,g,j,v,A,T,b,h,k,q,w,y){super(e,t,null,r,n,l,o,s,u=u||InAppMessage.DismissType.MANUAL,d,i,x,a,c,f,m,p,g,j,v,A,T,b,h,k,q=q||InAppMessage.CropType.FIT_CENTER,void 0,w,y)}get xe(){return InAppMessage.TextAlignment.CENTER}}ModalMessage.es=InAppMessage.es.Hi;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{InAppMessage}from"../index.js";import{DOMUtils as dt}from"../../util/dom-utils.js";export default class SlideUpMessage extends InAppMessage{constructor(t,e,o,s,n,i,d,r,u,a,l,m,p,c,v,x,f,g,h,I,M){x=x||InAppMessage.Ys.bi,v=v||InAppMessage.Ys.Ri,super(t,e=e||InAppMessage.TextAlignment.START,o,s,n,i,d,r,u,a,l,m,null,p,c,v,x,f,g,h,void 0,void 0,void 0,void 0,void 0,void 0,void 0,I,M)}we(){return!1}get xe(){return InAppMessage.TextAlignment.START}ke(){const t=document.createElement("span");return t.appendChild(document.createTextNode(this.message)),t}_i(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._i(t)}}SlideUpMessage.es=InAppMessage.es.gi;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class ct{constructor(t,s,l,n,i){this.triggerId=t,this.ri=s,this.Ze=l,this.ni=n,this.ai=i}static fromJson(t,s,l,n,i){return null==t||null==t.trigger_id?null:new ct(t.trigger_id,s,l,n,i)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../managers/braze-instance.js";import me from"./in-app-message-manager-factory.js";export function subscribeToInAppMessage(n){if(e.rr())return"function"!=typeof n?null:me.m().Ee((function(r){return n(r[0]),r.slice(1)}))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import me from"../in-app-message-manager-factory.js";import e from"../../managers/braze-instance.js";import{setupInAppMessageUI as nr}from"../../ui/js/index.js";import{showInAppMessage,subscribeToInAppMessage}from"../index.js";export function automaticallyShowInAppMessages(){if(!e.rr())return;nr();const r=me.m();if(null==r.Fe()){const n=subscribeToInAppMessage((r=>showInAppMessage(r)));r.Ne(n)}return r.Fe()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e,{OPTIONS as D}from"../../managers/braze-instance.js";import{ControlMessage,HtmlMessage,InAppMessage,SlideUpMessage}from"../index.js";import me from"../in-app-message-manager-factory.js";import ae from"../display/get-animation-effect.js";import re from"../display/in-app-message-to-html.js";import{logInAppMessageImpression}from"../log-in-app-message-impression.js";import{ORIENTATION as le,WindowUtils as P}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 nr}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";import{toRgba as se}from"../../util/color-utils.js";export function showInAppMessage(t,i,o){if(!e.rr())return;if(nr(),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 s=me.m();t.Si();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.'),s.qe(t.triggerId,InAppMessage.Oe.Pi),!1;if(null==i&&(i=document.body),t.we()){if(i.querySelectorAll(".ab-modal-interactions").length>0)return r.D.info(`Cannot show in-app message ${t.message} because another message is being shown.`),s.qe(t.triggerId,InAppMessage.Oe.Ci),!1}if(P.ji()){const e=P.wi();if(e===le.PORTRAIT&&t.orientation===InAppMessage.Orientation.LANDSCAPE||e===le.LANDSCAPE&&t.orientation===InAppMessage.Orientation.PORTRAIT){const i=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 ${i}`),s.qe(t.triggerId,InAppMessage.Oe.Ui),!1}}if(!e.tr()){let e=!1;if(t.buttons&&t.buttons.length>0){const i=t.buttons;for(let t=0;t<i.length;t++)if(i[t].clickAction===InAppMessage.ClickAction.URI){const o=i[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.'),s.qe(t.triggerId,InAppMessage.Oe.Pi),!1}const a=document.createElement("div");if(a.className="ab-iam-root v3",a.className+=ae(t),a.setAttribute("role","complementary"),t.an()&&(a.id=t.htmlId),e.nn(D.vi)&&(a.style.zIndex=e.nn(D.vi)+1),i.appendChild(a),t.sn()){const i=document.createElement("style");i.innerHTML=t.css,i.id=t.rn(),null!=e.nn(D.yi)&&i.setAttribute("nonce",e.nn(D.yi)),document.getElementsByTagName("head")[0].appendChild(i)}const l=t instanceof SlideUpMessage,c=re(t,(()=>{import("../../Feed/ui/show-feed.js").then((e=>e.showFeed()))}),(i=>{if(t.we()&&t.ll()){const o=document.createElement("div");if(o.className="ab-page-blocker",t.sn()||(o.style.backgroundColor=se(t.frameColor)),e.nn(D.vi)&&(o.style.zIndex=e.nn(D.vi)),a.appendChild(o),!e.nn(D.Oi)){const e=(new Date).valueOf();o.onclick=o=>{(new Date).valueOf()-e>InAppMessage.Fi&&(t.on(i),o.stopPropagation())}}a.appendChild(i),i.focus(),t._i(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]!==i){o=e[t];break}if(t.slideFrom===InAppMessage.SlideFrom.TOP){let e=0;null!=o&&(e=o.offsetTop+o.offsetHeight),i.style.top=Math.max(e,0)+"px"}else{let e=0;null!=o&&(e=(window.innerHeight||document.documentElement.clientHeight)-o.offsetTop),i.style.bottom=Math.max(e,0)+"px"}}else if(n&&!e.nn(D.Oi)){const e=t;i.contentWindow.addEventListener("keydown",(function(t){t.keyCode===at.di&&e.closeMessage()}))}logInAppMessageImpression(t),t.dismissType===InAppMessage.DismissType.AUTO_DISMISS&&setTimeout((()=>{a.contains(i)&&t.on(i)}),t.duration),"function"==typeof o&&o()}),e.nn(D.zi),e.nn(D.vi),e.nn(D.yi));return(n||l)&&(a.appendChild(c),t._i(a)),!0}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{isPushBlocked}from"./is-push-blocked.js";export{isPushPermissionGranted}from"./is-push-permission-granted.js";export{isPushSupported}from"./is-push-supported.js";export{requestPushPermission}from"./request-push-permission.js";export{unregisterPush}from"./unregister-push.js";
|
|
@@ -0,0 +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()}
|
|
@@ -0,0 +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()}
|
|
@@ -0,0 +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()}
|
|
@@ -0,0 +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.jr(),e.aa(),e.ce(),e.nn(D.ea),e.nn(D.na),e.nn(D.ra),e.ir(),e.nn(D.ta),e.nn(D.ia),e.l())),or.pushManager),o:()=>{or.t||(e.u(or),or.t=!0)},destroy:()=>{or.pushManager=null,or.t=!1}};export default or;
|