@braze/web-sdk
Version:
Braze SDK for web sites and other JS platforms.
23 lines (22 loc) • 726 B
JavaScript
import { logger as N } from "../../shared-lib/index.js";
import { BANNERS_DISABLED_MESSAGE as v } from "../common/constants.js";
import r from "../managers/braze-instance.js";
import i from "./banner-provider-factory.js";
export function getBannerIfNotExpired(n, r) {
const e = n[r];
if (!e) return null;
const t = e.Gt,
o = new Date().valueOf();
return -1 !== t && 1e3 * t < o
? (N.info(`Banner with ID: ${e.id} and placement ID: ${r} has expired.`),
null)
: e;
}
export function getBanner(n) {
var e;
if (!r.rr()) return;
!1 === (null === (e = r.v()) || void 0 === e ? void 0 : e.zt()) && N.error(v);
const t = i.m();
if (!t.L()) return null;
return getBannerIfNotExpired(t.dt(), n);
}