@active-reach/web-sdk 1.43.6 → 1.44.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/dist/aegis.min.js +1 -1
- package/dist/aegis.min.js.map +1 -1
- package/dist/chat/AegisChat.d.ts.map +1 -1
- package/dist/inapp/AegisInAppManager.d.ts +27 -0
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
- package/dist/inapp/font.d.ts +118 -11
- package/dist/inapp/font.d.ts.map +1 -1
- package/dist/inapp/renderPreview.d.ts.map +1 -1
- package/dist/inapp/renderers/card-template.d.ts +11 -5
- package/dist/inapp/renderers/card-template.d.ts.map +1 -1
- package/dist/inapp/renderers/carousel-cards.d.ts.map +1 -1
- package/dist/inapp/renderers/coachmark-tour.d.ts.map +1 -1
- package/dist/inapp/renderers/games.d.ts.map +1 -1
- package/dist/inapp/renderers/hero.d.ts +0 -16
- package/dist/inapp/renderers/hero.d.ts.map +1 -1
- package/dist/inapp/renderers/product-recommendation.d.ts.map +1 -1
- package/dist/inapp/renderers/progress-bar.d.ts.map +1 -1
- package/dist/inapp/renderers/reviews.d.ts +1 -1
- package/dist/inapp/renderers/reviews.d.ts.map +1 -1
- package/dist/inapp/renderers/sticky-bar.d.ts.map +1 -1
- package/dist/inapp/renderers/stories.d.ts.map +1 -1
- package/dist/inapp/renderers/video.d.ts.map +1 -1
- package/dist/index.js +312 -80
- package/dist/index.js.map +1 -1
- package/dist/integrations/react.d.ts.map +1 -1
- package/dist/runtime/AegisMessageRuntime.d.ts +6 -0
- package/dist/runtime/AegisMessageRuntime.d.ts.map +1 -1
- package/dist/triggers/IntentRuleEvaluator.d.ts.map +1 -1
- package/dist/widgets/AegisWidgetManager.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -360,15 +360,221 @@ function lucideSvg(name, opts = {}) {
|
|
|
360
360
|
}).join("");
|
|
361
361
|
return `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="${escapeAttr(color)}" stroke-width="${strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${cls} ${a11y}>${children}</svg>`;
|
|
362
362
|
}
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
363
|
+
const keywords = ["inherit", "system", "serif", "mono"];
|
|
364
|
+
const system_stacks = { "system": "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif", "serif": "Georgia, 'Times New Roman', serif", "mono": "ui-monospace, 'SF Mono', Menlo, monospace" };
|
|
365
|
+
const aliases = { "system-ui": "system", "-apple-system": "system", "georgia": "serif", "times new roman": "serif", "sf mono": "mono", "ui-monospace": "mono", "menlo": "mono", "monospace": "mono" };
|
|
366
|
+
const role_weights = { "body": [400, 500], "display": [600, 700] };
|
|
367
|
+
const google = [{ "name": "Urbanist", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "99.04%", "ascent_override": "95.93%", "descent_override": "25.24%", "line_gap_override": "0.00%" } }, { "name": "Inter", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "107.12%", "ascent_override": "90.44%", "descent_override": "22.52%", "line_gap_override": "0.00%" } }, { "name": "Poppins", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "112.16%", "ascent_override": "93.62%", "descent_override": "31.21%", "line_gap_override": "8.92%" } }, { "name": "DM Sans", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "104.53%", "ascent_override": "94.90%", "descent_override": "29.66%", "line_gap_override": "0.00%" } }, { "name": "Nunito", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "101.39%", "ascent_override": "99.71%", "descent_override": "34.82%", "line_gap_override": "0.00%" } }, { "name": "Montserrat", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "112.83%", "ascent_override": "85.79%", "descent_override": "22.25%", "line_gap_override": "0.00%" } }, { "name": "Roboto", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "99.78%", "ascent_override": "92.98%", "descent_override": "24.47%", "line_gap_override": "0.00%" } }, { "name": "Outfit", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "99.82%", "ascent_override": "100.18%", "descent_override": "26.05%", "line_gap_override": "0.00%" } }, { "name": "Playfair Display", "category": "serif", "fallback": { "local": "Times New Roman", "size_adjust": "111.26%", "ascent_override": "97.25%", "descent_override": "22.56%", "line_gap_override": "0.00%" } }, { "name": "Lora", "category": "serif", "fallback": { "local": "Times New Roman", "size_adjust": "115.20%", "ascent_override": "87.33%", "descent_override": "23.78%", "line_gap_override": "0.00%" } }];
|
|
368
|
+
const FONT_ALLOWLIST = {
|
|
369
|
+
keywords,
|
|
370
|
+
system_stacks,
|
|
371
|
+
aliases,
|
|
372
|
+
role_weights,
|
|
373
|
+
google
|
|
374
|
+
};
|
|
375
|
+
const BODY_FONT_STACK = "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif";
|
|
376
|
+
const SERIF_STACK = "Georgia, 'Times New Roman', serif";
|
|
377
|
+
const AEGIS_BODY_FONT_VAR = "--aegis-font-body";
|
|
378
|
+
const AEGIS_DISPLAY_FONT_VAR = "--aegis-font-display";
|
|
379
|
+
const ACS_DISPLAY_FONT_VAR = "--acs-font-display";
|
|
380
|
+
const ACS_BODY_FONT_VAR = "--acs-font-body";
|
|
381
|
+
const GOOGLE_FONTS = FONT_ALLOWLIST.google;
|
|
382
|
+
const KEYWORDS = FONT_ALLOWLIST.keywords;
|
|
383
|
+
const SYSTEM_STACKS = FONT_ALLOWLIST.system_stacks;
|
|
384
|
+
const ALIASES = FONT_ALLOWLIST.aliases;
|
|
385
|
+
const ROLE_WEIGHTS = FONT_ALLOWLIST.role_weights;
|
|
386
|
+
function fontFamilyCss(role) {
|
|
387
|
+
return `font-family:var(${role === "display" ? AEGIS_DISPLAY_FONT_VAR : AEGIS_BODY_FONT_VAR});`;
|
|
388
|
+
}
|
|
389
|
+
function findGoogleFont(value) {
|
|
390
|
+
const v = value.trim().toLowerCase();
|
|
391
|
+
return GOOGLE_FONTS.find((f) => f.name.toLowerCase() === v);
|
|
392
|
+
}
|
|
393
|
+
function normalizeFontValue(value) {
|
|
394
|
+
var _a;
|
|
395
|
+
if (typeof value !== "string") return null;
|
|
396
|
+
const first = value.split(",")[0].trim().replace(/^['"]|['"]$/g, "").trim();
|
|
397
|
+
if (!first) return null;
|
|
398
|
+
const v = first.toLowerCase();
|
|
399
|
+
if (KEYWORDS.includes(v)) return v;
|
|
400
|
+
if (ALIASES[v]) return ALIASES[v];
|
|
401
|
+
return ((_a = findGoogleFont(first)) == null ? void 0 : _a.name) ?? null;
|
|
402
|
+
}
|
|
403
|
+
function fallbackFamily(f) {
|
|
404
|
+
return `${f.name} Aegis Fallback`;
|
|
405
|
+
}
|
|
406
|
+
function fontValueToCss(value, host = "third_party") {
|
|
407
|
+
const canonical = normalizeFontValue(value);
|
|
408
|
+
if (!canonical) return null;
|
|
409
|
+
if (canonical === "inherit") return { css: "initial" };
|
|
410
|
+
if (SYSTEM_STACKS[canonical]) return { css: SYSTEM_STACKS[canonical] };
|
|
411
|
+
const f = findGoogleFont(canonical);
|
|
412
|
+
if (!f) return null;
|
|
413
|
+
const stack = f.category === "serif" ? SERIF_STACK : BODY_FONT_STACK;
|
|
414
|
+
if (host === "acs") return { css: `var(${acsFaceVar(f)}), ${stack}` };
|
|
415
|
+
return { css: `'${f.name}', '${fallbackFamily(f)}', ${stack}`, font: f };
|
|
416
|
+
}
|
|
417
|
+
function acsFaceVar(f) {
|
|
418
|
+
return `--acs-face-${f.name.toLowerCase().replace(/ /g, "-")}`;
|
|
419
|
+
}
|
|
420
|
+
function readRootVar(name) {
|
|
421
|
+
if (typeof document === "undefined" || typeof getComputedStyle !== "function") return "";
|
|
422
|
+
try {
|
|
423
|
+
return getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
|
424
|
+
} catch {
|
|
425
|
+
return "";
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
function detectFontHost(read = readRootVar) {
|
|
429
|
+
return read(ACS_BODY_FONT_VAR) ? "acs" : "third_party";
|
|
430
|
+
}
|
|
431
|
+
function resolveRootFonts(brand, read = readRootVar) {
|
|
432
|
+
const host = detectFontHost(read);
|
|
433
|
+
if (host === "acs") {
|
|
434
|
+
return {
|
|
435
|
+
host,
|
|
436
|
+
body: `var(${ACS_BODY_FONT_VAR})`,
|
|
437
|
+
display: read(ACS_DISPLAY_FONT_VAR) ? `var(${ACS_DISPLAY_FONT_VAR})` : `var(${ACS_BODY_FONT_VAR})`,
|
|
438
|
+
load: []
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
const load = [];
|
|
442
|
+
const pick = (role) => {
|
|
443
|
+
const served = fontValueToCss(role === "display" ? brand == null ? void 0 : brand.display : brand == null ? void 0 : brand.body);
|
|
444
|
+
if (!served) return null;
|
|
445
|
+
if (served.font) load.push({ font: served.font, role });
|
|
446
|
+
return served.css;
|
|
447
|
+
};
|
|
448
|
+
const body = pick("body");
|
|
449
|
+
const display = pick("display");
|
|
450
|
+
return { host, body, display, load };
|
|
451
|
+
}
|
|
452
|
+
const LINK_ID = "aegis-inapp-fonts";
|
|
453
|
+
const FALLBACK_STYLE_ID = "aegis-inapp-font-fallbacks";
|
|
454
|
+
const PRECONNECT_ORIGINS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
|
|
455
|
+
const requested = /* @__PURE__ */ new Map();
|
|
456
|
+
function googleFontsHref(families) {
|
|
457
|
+
const parts = [...families.keys()].sort((a, b) => a.localeCompare(b)).map((name) => {
|
|
458
|
+
const weights = [...families.get(name) ?? []].sort((a, b) => a - b);
|
|
459
|
+
return `family=${name.replace(/ /g, "+")}:wght@${weights.join(";")}`;
|
|
460
|
+
});
|
|
461
|
+
return `https://fonts.googleapis.com/css2?${parts.join("&")}&display=swap`;
|
|
462
|
+
}
|
|
463
|
+
function fallbackFaceCss(fonts) {
|
|
464
|
+
return fonts.map(
|
|
465
|
+
(f) => `@font-face{font-family:'${fallbackFamily(f)}';src:local('${f.fallback.local}');size-adjust:${f.fallback.size_adjust};ascent-override:${f.fallback.ascent_override};descent-override:${f.fallback.descent_override};line-gap-override:${f.fallback.line_gap_override};}`
|
|
466
|
+
).join("\n");
|
|
467
|
+
}
|
|
468
|
+
function ensurePreconnect() {
|
|
469
|
+
for (const origin of PRECONNECT_ORIGINS) {
|
|
470
|
+
if (document.head.querySelector(`link[rel="preconnect"][href="${origin}"]`)) continue;
|
|
471
|
+
const l = document.createElement("link");
|
|
472
|
+
l.rel = "preconnect";
|
|
473
|
+
l.href = origin;
|
|
474
|
+
if (origin.includes("gstatic")) l.crossOrigin = "anonymous";
|
|
475
|
+
document.head.appendChild(l);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
function loadFonts(loads, read = readRootVar) {
|
|
479
|
+
if (typeof document === "undefined" || loads.length === 0) return;
|
|
480
|
+
if (detectFontHost(read) === "acs") return;
|
|
481
|
+
let grew = false;
|
|
482
|
+
for (const { font, role } of loads) {
|
|
483
|
+
const known = findGoogleFont(font.name);
|
|
484
|
+
if (!known) continue;
|
|
485
|
+
const set = requested.get(known.name) ?? /* @__PURE__ */ new Set();
|
|
486
|
+
for (const w of ROLE_WEIGHTS[role]) {
|
|
487
|
+
if (!set.has(w)) {
|
|
488
|
+
set.add(w);
|
|
489
|
+
grew = true;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
requested.set(known.name, set);
|
|
493
|
+
}
|
|
494
|
+
if (!grew) return;
|
|
495
|
+
ensurePreconnect();
|
|
496
|
+
let style = document.getElementById(FALLBACK_STYLE_ID);
|
|
497
|
+
if (!style) {
|
|
498
|
+
style = document.createElement("style");
|
|
499
|
+
style.id = FALLBACK_STYLE_ID;
|
|
500
|
+
document.head.appendChild(style);
|
|
501
|
+
}
|
|
502
|
+
style.textContent = fallbackFaceCss(
|
|
503
|
+
[...requested.keys()].map((n) => findGoogleFont(n)).filter((f) => !!f)
|
|
504
|
+
);
|
|
505
|
+
let link = document.getElementById(LINK_ID);
|
|
506
|
+
if (!link) {
|
|
507
|
+
link = document.createElement("link");
|
|
508
|
+
link.id = LINK_ID;
|
|
509
|
+
link.rel = "stylesheet";
|
|
510
|
+
document.head.appendChild(link);
|
|
511
|
+
}
|
|
512
|
+
link.href = googleFontsHref(requested);
|
|
513
|
+
}
|
|
514
|
+
function applyRootFonts(brand, read = readRootVar) {
|
|
515
|
+
const r = resolveRootFonts(brand, read);
|
|
516
|
+
if (typeof document === "undefined") return r;
|
|
517
|
+
const root = document.documentElement.style;
|
|
518
|
+
if (r.body) root.setProperty(AEGIS_BODY_FONT_VAR, r.body);
|
|
519
|
+
else root.removeProperty(AEGIS_BODY_FONT_VAR);
|
|
520
|
+
if (r.display) root.setProperty(AEGIS_DISPLAY_FONT_VAR, r.display);
|
|
521
|
+
else root.removeProperty(AEGIS_DISPLAY_FONT_VAR);
|
|
522
|
+
loadFonts(r.load, read);
|
|
523
|
+
return r;
|
|
524
|
+
}
|
|
525
|
+
function campaignFontFamily(campaign) {
|
|
526
|
+
var _a;
|
|
527
|
+
const style = (_a = campaign == null ? void 0 : campaign.interactive_config) == null ? void 0 : _a.style;
|
|
528
|
+
if (style && typeof style === "object") {
|
|
529
|
+
const ff = style.fontFamily;
|
|
530
|
+
if (typeof ff === "string" && ff.trim()) return ff;
|
|
531
|
+
}
|
|
532
|
+
return void 0;
|
|
533
|
+
}
|
|
534
|
+
function campaignFontVarsCss(value, read = readRootVar) {
|
|
535
|
+
const served = fontValueToCss(value, detectFontHost(read));
|
|
536
|
+
if (!served) return "";
|
|
537
|
+
if (served.font) {
|
|
538
|
+
loadFonts(
|
|
539
|
+
[
|
|
540
|
+
{ font: served.font, role: "body" },
|
|
541
|
+
{ font: served.font, role: "display" }
|
|
542
|
+
],
|
|
543
|
+
read
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
return `${AEGIS_BODY_FONT_VAR}:${served.css};${AEGIS_DISPLAY_FONT_VAR}:${served.css};`;
|
|
547
|
+
}
|
|
548
|
+
const CAMPAIGN_SHEET_ID = "aegis-campaign-fonts";
|
|
549
|
+
const SAFE_ID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
550
|
+
function registerCampaignFonts(campaigns, read = readRootVar) {
|
|
551
|
+
const rules = [];
|
|
552
|
+
for (const c of campaigns) {
|
|
553
|
+
const id = typeof c.id === "string" ? c.id : "";
|
|
554
|
+
if (!SAFE_ID.test(id)) continue;
|
|
555
|
+
const decl = campaignFontVarsCss(campaignFontFamily(c), read);
|
|
556
|
+
if (decl) rules.push(`[data-campaign-id="${id}"]{${decl}}`);
|
|
557
|
+
}
|
|
558
|
+
const css = rules.join("\n");
|
|
559
|
+
if (typeof document === "undefined") return css;
|
|
560
|
+
let sheet = document.getElementById(CAMPAIGN_SHEET_ID);
|
|
561
|
+
if (!css) {
|
|
562
|
+
sheet == null ? void 0 : sheet.remove();
|
|
563
|
+
return css;
|
|
564
|
+
}
|
|
565
|
+
if (!sheet) {
|
|
566
|
+
sheet = document.createElement("style");
|
|
567
|
+
sheet.id = CAMPAIGN_SHEET_ID;
|
|
568
|
+
document.head.appendChild(sheet);
|
|
569
|
+
}
|
|
570
|
+
sheet.textContent = css;
|
|
571
|
+
return css;
|
|
572
|
+
}
|
|
573
|
+
function applyCampaignFonts(campaigns, read = readRootVar) {
|
|
574
|
+
var _a;
|
|
575
|
+
const brand = ((_a = campaigns.find((c) => c.brand_typography)) == null ? void 0 : _a.brand_typography) ?? null;
|
|
576
|
+
applyRootFonts(brand, read);
|
|
577
|
+
registerCampaignFonts(campaigns, read);
|
|
372
578
|
}
|
|
373
579
|
function npsBandFromScore(score) {
|
|
374
580
|
if (score <= 6) return "detractor";
|
|
@@ -449,16 +655,8 @@ const WEIGHT = {
|
|
|
449
655
|
const ICON_PX = { sm: 22, md: 30, lg: 40 };
|
|
450
656
|
const TEXT_PX = { sm: 11.5, md: 13, lg: 15 };
|
|
451
657
|
const RAIL_TILE_FLEX = "flex:0 0 clamp(150px, 15vw, 220px); scroll-snap-align:start;";
|
|
452
|
-
function sanitizeFontFamily(v) {
|
|
453
|
-
return v.replace(/[^a-zA-Z0-9 ,"'-]/g, "").slice(0, 120);
|
|
454
|
-
}
|
|
455
658
|
function resolveCardFont(ff) {
|
|
456
|
-
|
|
457
|
-
if (ff && ff.trim()) return sanitizeFontFamily(ff);
|
|
458
|
-
return IN_APP_FONT_STACK;
|
|
459
|
-
}
|
|
460
|
-
function ensureCardFontLoaded(resolvedFont) {
|
|
461
|
-
if (/urbanist/i.test(resolvedFont)) ensureInAppFont();
|
|
659
|
+
return `${campaignFontVarsCss(ff)}${fontFamilyCss("body")}`;
|
|
462
660
|
}
|
|
463
661
|
function interpolateTokens(s, ctx) {
|
|
464
662
|
if (!s || s.indexOf("{") === -1) return s;
|
|
@@ -1549,8 +1747,8 @@ function renderCardFromTemplate(card, opts) {
|
|
|
1549
1747
|
const muted = fg === "#ffffff" ? "rgba(255,255,255,0.72)" : "#6b7280";
|
|
1550
1748
|
const tile = document.createElement("div");
|
|
1551
1749
|
tile.setAttribute("data-aegis-reaction-anchor", "");
|
|
1552
|
-
const cardFont = resolveCardFont(frame.fontFamily);
|
|
1553
|
-
|
|
1750
|
+
const cardFont = resolveCardFont(campaignFontFamily(campaign) ?? frame.fontFamily);
|
|
1751
|
+
const displayFont = fontFamilyCss("display");
|
|
1554
1752
|
const radius = frame.radius !== void 0 ? `${parseInt(String(frame.radius), 10) || 12}px` : "12px";
|
|
1555
1753
|
const fLayout = frame.layout;
|
|
1556
1754
|
const dir = fLayout === "row" ? "row" : "column";
|
|
@@ -1559,7 +1757,7 @@ function renderCardFromTemplate(card, opts) {
|
|
|
1559
1757
|
tile.style.cssText = `
|
|
1560
1758
|
box-sizing:border-box; display:flex; flex-direction:${dir}; ${fLayout === "row" ? "align-items:center;" : ""} gap:${tileGap}px; position:relative;
|
|
1561
1759
|
color:${fg};
|
|
1562
|
-
${cardFont
|
|
1760
|
+
${cardFont}
|
|
1563
1761
|
background:${frame.bg ? sanitizeColor(frame.bg) : "#ffffff"};
|
|
1564
1762
|
border:1px solid ${frame.border ? sanitizeColor(frame.border) : "transparent"};
|
|
1565
1763
|
border-radius:${radius}; padding:8px;
|
|
@@ -1619,7 +1817,10 @@ function renderCardFromTemplate(card, opts) {
|
|
|
1619
1817
|
}
|
|
1620
1818
|
case "price": {
|
|
1621
1819
|
const node = paintPrice(card, el2, accent, ctx);
|
|
1622
|
-
if (node)
|
|
1820
|
+
if (node) {
|
|
1821
|
+
node.style.cssText += `${displayFont}font-variant-numeric:tabular-nums;`;
|
|
1822
|
+
container.appendChild(node);
|
|
1823
|
+
}
|
|
1623
1824
|
break;
|
|
1624
1825
|
}
|
|
1625
1826
|
case "title": {
|
|
@@ -1627,7 +1828,7 @@ function renderCardFromTemplate(card, opts) {
|
|
|
1627
1828
|
const t = document.createElement("div");
|
|
1628
1829
|
t.textContent = card.title;
|
|
1629
1830
|
const lines = el2.lines && el2.lines > 0 ? el2.lines : 2;
|
|
1630
|
-
t.style.cssText =
|
|
1831
|
+
t.style.cssText = `${displayFont}font-size:12.5px;font-weight:600;line-height:1.3;text-align:${el2.align ?? "left"};color:${el2.color ? sanitizeColor(el2.color) : fg};display:-webkit-box;-webkit-line-clamp:${lines};-webkit-box-orient:vertical;overflow:hidden;`;
|
|
1631
1832
|
container.appendChild(t);
|
|
1632
1833
|
break;
|
|
1633
1834
|
}
|
|
@@ -1798,7 +1999,6 @@ function renderCarouselCards(ctx) {
|
|
|
1798
1999
|
const loop = ic.loop !== false;
|
|
1799
2000
|
const layout = ic.rec_layout || "row";
|
|
1800
2001
|
addAnimationStyles();
|
|
1801
|
-
ensureInAppFont();
|
|
1802
2002
|
const bg = "#ffffff";
|
|
1803
2003
|
const fg = "#0f172a";
|
|
1804
2004
|
const accent = sanitizeColor(campaign.background_color || "#4169e1");
|
|
@@ -1809,7 +2009,7 @@ function renderCarouselCards(ctx) {
|
|
|
1809
2009
|
position: fixed; left: 0; right: 0; bottom: 0;
|
|
1810
2010
|
z-index: 99999; padding: 12px 12px 20px;
|
|
1811
2011
|
background: rgba(0,0,0,0.12); backdrop-filter: blur(8px);
|
|
1812
|
-
|
|
2012
|
+
${fontFamilyCss("body")}
|
|
1813
2013
|
animation: aegisSlideInFromBottom 0.3s ease-out;
|
|
1814
2014
|
`;
|
|
1815
2015
|
const card = document.createElement("div");
|
|
@@ -1993,7 +2193,7 @@ function renderStickyBar(ctx) {
|
|
|
1993
2193
|
position: fixed; ${positionCss}
|
|
1994
2194
|
background: ${bg}; color: ${fg};
|
|
1995
2195
|
padding: 10px 14px; z-index: 999998;
|
|
1996
|
-
|
|
2196
|
+
${fontFamilyCss("body")}
|
|
1997
2197
|
display: flex; align-items: center; gap: 12px; justify-content: center;
|
|
1998
2198
|
box-shadow: 0 ${position === "top" ? "2px" : "-2px"} 8px rgba(0,0,0,0.08);
|
|
1999
2199
|
`;
|
|
@@ -2081,14 +2281,14 @@ function buildProgressBar(ctx, inline) {
|
|
|
2081
2281
|
bar.style.cssText = inline ? `
|
|
2082
2282
|
background: ${bg}; color: ${fg};
|
|
2083
2283
|
padding: 10px 14px;
|
|
2084
|
-
|
|
2284
|
+
${fontFamilyCss("body")}
|
|
2085
2285
|
` : `
|
|
2086
2286
|
position: fixed; left: 12px; right: 12px; bottom: 12px;
|
|
2087
2287
|
max-width: 540px; margin: 0 auto;
|
|
2088
2288
|
background: ${bg}; color: ${fg}; border-radius: 12px;
|
|
2089
2289
|
padding: 10px 14px; z-index: 999997;
|
|
2090
2290
|
box-shadow: 0 8px 20px rgba(0,0,0,0.08);
|
|
2091
|
-
|
|
2291
|
+
${fontFamilyCss("body")}
|
|
2092
2292
|
animation: aegisSlideInFromBottom 0.3s ease-out;
|
|
2093
2293
|
`;
|
|
2094
2294
|
const label = document.createElement("div");
|
|
@@ -2357,7 +2557,7 @@ function renderCoachmarkTour(ctx) {
|
|
|
2357
2557
|
padding: 12px 14px; border-radius: 12px;
|
|
2358
2558
|
max-width: 260px;
|
|
2359
2559
|
box-shadow: 0 8px 24px rgba(0,0,0,0.25);
|
|
2360
|
-
|
|
2560
|
+
${fontFamilyCss("body")}
|
|
2361
2561
|
animation: aegisFadeIn 0.2s ease;
|
|
2362
2562
|
`;
|
|
2363
2563
|
const titleEl = document.createElement("div");
|
|
@@ -2467,7 +2667,6 @@ function renderProductRecommendation(ctx) {
|
|
|
2467
2667
|
const layout = ic.rec_layout || "grid";
|
|
2468
2668
|
const template = resolveGlobalTemplate(ic);
|
|
2469
2669
|
addAnimationStyles();
|
|
2470
|
-
ensureInAppFont();
|
|
2471
2670
|
const bg = "#ffffff";
|
|
2472
2671
|
const fg = "#0f172a";
|
|
2473
2672
|
const accent = sanitizeColor(campaign.background_color || "#4169e1");
|
|
@@ -2486,7 +2685,7 @@ function renderProductRecommendation(ctx) {
|
|
|
2486
2685
|
max-width: 560px; width: 100%; max-height: 80vh; overflow-y: auto;
|
|
2487
2686
|
border-radius: 20px 20px 0 0;
|
|
2488
2687
|
padding: 18px 16px 22px;
|
|
2489
|
-
|
|
2688
|
+
${fontFamilyCss("body")}
|
|
2490
2689
|
animation: aegisSlideInFromBottom 0.3s ease-out;
|
|
2491
2690
|
box-shadow: 0 -12px 30px rgba(0,0,0,0.12);
|
|
2492
2691
|
`;
|
|
@@ -2566,12 +2765,11 @@ function renderProductRecommendationInline(ctx, target) {
|
|
|
2566
2765
|
const fg = "#0f172a";
|
|
2567
2766
|
const accent = sanitizeColor(campaign.background_color || "#4169e1");
|
|
2568
2767
|
addAnimationStyles();
|
|
2569
|
-
ensureInAppFont();
|
|
2570
2768
|
const section = document.createElement("section");
|
|
2571
2769
|
section.className = "aegis-in-app-product-rec-inline";
|
|
2572
2770
|
section.setAttribute("data-campaign-id", campaign.id);
|
|
2573
2771
|
section.style.cssText = `
|
|
2574
|
-
|
|
2772
|
+
${fontFamilyCss("body")}
|
|
2575
2773
|
color: ${fg};
|
|
2576
2774
|
`;
|
|
2577
2775
|
if (campaign.title) {
|
|
@@ -2727,14 +2925,14 @@ function renderLauncherBar(ctx, cfg, target) {
|
|
|
2727
2925
|
padding: 14px 18px 16px 20px; scroll-padding-left: 20px;
|
|
2728
2926
|
background: ${surfaceBg}; backdrop-filter: blur(8px);
|
|
2729
2927
|
box-shadow: 0 -4px 16px rgba(0,0,0,0.08); scrollbar-width: none;
|
|
2730
|
-
|
|
2928
|
+
${fontFamilyCss("body")}
|
|
2731
2929
|
animation: aegisSlideInFromBottom 0.3s ease-out;
|
|
2732
2930
|
` : `
|
|
2733
2931
|
display: flex; gap: 16px; align-items: flex-start; overflow-x: auto;
|
|
2734
2932
|
padding: 12px 18px 12px 18px; scroll-padding-left: 18px;
|
|
2735
2933
|
background: ${surfaceBg}; ${cfg.branded ? "border-radius: 16px;" : ""}
|
|
2736
2934
|
scrollbar-width: none;
|
|
2737
|
-
|
|
2935
|
+
${fontFamilyCss("body")}
|
|
2738
2936
|
`;
|
|
2739
2937
|
cfg.groups.forEach((g, i) => bar.appendChild(buildGroupBubble(ctx, cfg, g, i, labelColor)));
|
|
2740
2938
|
if (floating) {
|
|
@@ -2855,7 +3053,7 @@ function openViewer(ctx, cfg, startGroupIndex, startFrameIndex = 0) {
|
|
|
2855
3053
|
overlay.style.cssText = `
|
|
2856
3054
|
position: fixed; inset: 0; z-index: 100000; background: #000;
|
|
2857
3055
|
display: flex; align-items: center; justify-content: center;
|
|
2858
|
-
|
|
3056
|
+
${fontFamilyCss("body")}
|
|
2859
3057
|
animation: aegisFadeIn 0.25s ease;
|
|
2860
3058
|
`;
|
|
2861
3059
|
const stage = document.createElement("div");
|
|
@@ -2985,7 +3183,7 @@ function openViewer(ctx, cfg, startGroupIndex, startFrameIndex = 0) {
|
|
|
2985
3183
|
if (f.title) {
|
|
2986
3184
|
const t = document.createElement("div");
|
|
2987
3185
|
t.textContent = f.title;
|
|
2988
|
-
t.style.cssText = "
|
|
3186
|
+
t.style.cssText = `${fontFamilyCss("display")} font-size: 21px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; margin-bottom: 6px; text-shadow: 0 1px 8px rgba(0,0,0,0.4);`;
|
|
2989
3187
|
copy.appendChild(t);
|
|
2990
3188
|
}
|
|
2991
3189
|
if (f.body) {
|
|
@@ -3151,7 +3349,7 @@ function openGameModal(ctx, className, maxWidth = 360) {
|
|
|
3151
3349
|
const overlay = document.createElement("div");
|
|
3152
3350
|
overlay.className = className;
|
|
3153
3351
|
overlay.setAttribute("data-campaign-id", campaign.id);
|
|
3154
|
-
overlay.style.cssText =
|
|
3352
|
+
overlay.style.cssText = `position:fixed;inset:0;z-index:100000;background:rgba(15,23,42,0.55);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;padding:16px;${fontFamilyCss("body")}animation:aegisFadeIn 0.25s ease;`;
|
|
3155
3353
|
const card = document.createElement("div");
|
|
3156
3354
|
card.style.cssText = `position:relative;width:100%;max-width:${maxWidth}px;max-height:88vh;overflow-y:auto;background:${bg};color:${fg};border-radius:20px;padding:24px 20px 20px;box-shadow:0 16px 48px rgba(0,0,0,0.22);animation:aegisScaleIn 0.3s ease;text-align:center;`;
|
|
3157
3355
|
let removed = false;
|
|
@@ -3176,7 +3374,7 @@ function openGameModal(ctx, className, maxWidth = 360) {
|
|
|
3176
3374
|
if (campaign.title) {
|
|
3177
3375
|
const t = document.createElement("div");
|
|
3178
3376
|
t.textContent = campaign.title;
|
|
3179
|
-
t.style.cssText = "font-
|
|
3377
|
+
t.style.cssText = `${fontFamilyCss("display")}font-size:18px;font-weight:800;letter-spacing:-0.01em;margin:2px 24px 4px;line-height:1.25;`;
|
|
3180
3378
|
card.appendChild(t);
|
|
3181
3379
|
}
|
|
3182
3380
|
if (campaign.body) {
|
|
@@ -3918,7 +4116,7 @@ function caption(ctx, accent, onCard) {
|
|
|
3918
4116
|
if (campaign.title) {
|
|
3919
4117
|
const t = document.createElement("div");
|
|
3920
4118
|
t.textContent = campaign.title;
|
|
3921
|
-
t.style.cssText =
|
|
4119
|
+
t.style.cssText = `${fontFamilyCss("display")}font-size:17px;font-weight:800;letter-spacing:-0.01em;line-height:1.2;${onCard ? "text-shadow:0 1px 8px rgba(0,0,0,0.4);" : ""}`;
|
|
3922
4120
|
box.appendChild(t);
|
|
3923
4121
|
}
|
|
3924
4122
|
if (campaign.body) {
|
|
@@ -3964,7 +4162,7 @@ function renderVideo(ctx) {
|
|
|
3964
4162
|
const overlay = document.createElement("div");
|
|
3965
4163
|
overlay.className = "aegis-in-app-video-overlay";
|
|
3966
4164
|
overlay.setAttribute("data-campaign-id", campaign.id);
|
|
3967
|
-
overlay.style.cssText =
|
|
4165
|
+
overlay.style.cssText = `position:fixed;inset:0;z-index:100000;background:rgba(15,23,42,0.6);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;padding:16px;${fontFamilyCss("body")}animation:aegisFadeIn 0.25s ease;`;
|
|
3968
4166
|
const card = document.createElement("div");
|
|
3969
4167
|
card.style.cssText = `position:relative;width:100%;max-width:${o.aspect === "9:16" ? 320 : 460}px;background:#fff;border-radius:18px;overflow:hidden;box-shadow:0 16px 48px rgba(0,0,0,0.28);animation:aegisScaleIn 0.3s ease;`;
|
|
3970
4168
|
const media = buildVideo(ctx, o.aspect, o.autoplay, o.loop);
|
|
@@ -4009,7 +4207,7 @@ function renderVideoInline(ctx, target) {
|
|
|
4009
4207
|
const banner = document.createElement("div");
|
|
4010
4208
|
banner.className = "aegis-in-app-video-banner";
|
|
4011
4209
|
banner.setAttribute("data-campaign-id", ctx.campaign.id);
|
|
4012
|
-
banner.style.cssText =
|
|
4210
|
+
banner.style.cssText = `width:100%;${fontFamilyCss("body")}`;
|
|
4013
4211
|
const media = buildVideo(ctx, o.aspect, o.autoplay, o.loop);
|
|
4014
4212
|
if (o.overlayCaption) {
|
|
4015
4213
|
const c = caption(ctx, o.accent, true);
|
|
@@ -4071,7 +4269,7 @@ function renderHeroInline(ctx, target) {
|
|
|
4071
4269
|
if (variant === "announcement_bar") {
|
|
4072
4270
|
const c = cards[0];
|
|
4073
4271
|
const bar = document.createElement("div");
|
|
4074
|
-
bar.style.cssText = `display:flex;align-items:center;justify-content:center;gap:10px;background:${accent};color:#fff;padding:8px 14px;font:600
|
|
4272
|
+
bar.style.cssText = `display:flex;align-items:center;justify-content:center;gap:10px;background:${accent};color:#fff;padding:8px 14px;font-weight:600;font-size:13px;line-height:1.3;${fontFamilyCss("body")}text-align:center;`;
|
|
4075
4273
|
bar.textContent = [cardHeadline(c), cardSub(c)].filter(Boolean).join(" · ");
|
|
4076
4274
|
const url = sanitizeUrl(cardUrl(c));
|
|
4077
4275
|
if (url && cardCta(c)) {
|
|
@@ -4149,14 +4347,14 @@ function renderHeroInline(ctx, target) {
|
|
|
4149
4347
|
if (h) {
|
|
4150
4348
|
const head = document.createElement("h2");
|
|
4151
4349
|
head.textContent = h;
|
|
4152
|
-
head.style.cssText =
|
|
4350
|
+
head.style.cssText = `margin:0;color:#fff;font-weight:800;font-size:24px;line-height:1.2;${fontFamilyCss("display")}letter-spacing:-0.02em;text-shadow:0 1px 8px rgba(0,0,0,0.35);max-width:90%;`;
|
|
4153
4351
|
content.appendChild(head);
|
|
4154
4352
|
}
|
|
4155
4353
|
const s = cardSub(c);
|
|
4156
4354
|
if (s) {
|
|
4157
4355
|
const sub = document.createElement("p");
|
|
4158
4356
|
sub.textContent = s;
|
|
4159
|
-
sub.style.cssText =
|
|
4357
|
+
sub.style.cssText = `margin:0;color:rgba(255,255,255,0.92);font-weight:500;font-size:14px;line-height:1.4;${fontFamilyCss("body")}text-shadow:0 1px 6px rgba(0,0,0,0.3);max-width:90%;`;
|
|
4160
4358
|
content.appendChild(sub);
|
|
4161
4359
|
}
|
|
4162
4360
|
const cta = cardCta(c);
|
|
@@ -4164,7 +4362,7 @@ function renderHeroInline(ctx, target) {
|
|
|
4164
4362
|
if (cta && chrome.cta_style !== "none") {
|
|
4165
4363
|
const btn = document.createElement("button");
|
|
4166
4364
|
btn.textContent = cta;
|
|
4167
|
-
btn.style.cssText = chrome.cta_style === "underline" ? `margin-top:6px;background:none;border:none;color:#fff;font:
|
|
4365
|
+
btn.style.cssText = chrome.cta_style === "underline" ? `margin-top:6px;background:none;border:none;color:#fff;font-weight:500;font-size:14px;${fontFamilyCss("body")}text-decoration:underline;cursor:pointer;padding:0;` : `margin-top:8px;background:${accent};color:#fff;border:none;border-radius:999px;padding:9px 18px;font-weight:500;font-size:13px;${fontFamilyCss("body")}cursor:pointer;box-shadow:0 4px 12px rgba(0,0,0,0.2);`;
|
|
4168
4366
|
btn.addEventListener("click", () => {
|
|
4169
4367
|
var _a;
|
|
4170
4368
|
trackEvent(campaign.id, "clicked", { stepId: `card_${i}` });
|
|
@@ -4912,7 +5110,7 @@ class AegisChat {
|
|
|
4912
5110
|
}
|
|
4913
5111
|
}
|
|
4914
5112
|
const CHAT_CSS = `
|
|
4915
|
-
.aegis-chat-root{position:fixed;bottom:20px;right:20px;z-index:2147483000
|
|
5113
|
+
.aegis-chat-root{position:fixed;bottom:20px;right:20px;z-index:2147483000;${fontFamilyCss("body")}}
|
|
4916
5114
|
.aegis-chat-root--bottom-left{left:20px;right:auto}
|
|
4917
5115
|
.aegis-chat-root--bottom-left .aegis-chat-panel{left:0;right:auto}
|
|
4918
5116
|
.aegis-chat-bubble-logo{width:34px;height:34px;border-radius:9999px;object-fit:cover}
|
|
@@ -5783,7 +5981,6 @@ const SORTS = [
|
|
|
5783
5981
|
];
|
|
5784
5982
|
function renderReviewsInline(ctx, target, creds) {
|
|
5785
5983
|
if (typeof document === "undefined" || !(creds == null ? void 0 : creds.apiHost) || !(creds == null ? void 0 : creds.writeKey)) return false;
|
|
5786
|
-
ensureInAppFont();
|
|
5787
5984
|
const ic = ctx.campaign.interactive_config || {};
|
|
5788
5985
|
const cfg = target.closest("[data-aegis-slot]") ?? target;
|
|
5789
5986
|
const accent = ctx.sanitizeColor(
|
|
@@ -5794,7 +5991,7 @@ function renderReviewsInline(ctx, target, creds) {
|
|
|
5794
5991
|
const productId = cfg.getAttribute("data-product-id") || ctx.campaign.product_id || null;
|
|
5795
5992
|
const state = { sort: "recent", withPhotos: false };
|
|
5796
5993
|
target.innerHTML = "";
|
|
5797
|
-
target.appendChild(el("div",
|
|
5994
|
+
target.appendChild(el("div", `${fontFamilyCss("body")}font-size:13px;color:#9ca3af;padding:10px 0;`, "Loading reviews…"));
|
|
5798
5995
|
function buildUrl() {
|
|
5799
5996
|
const url = new URL("/v1/reviews/public", creds.apiHost);
|
|
5800
5997
|
if (productId) url.searchParams.set("product_id", productId);
|
|
@@ -5960,7 +6157,7 @@ function renderReviewsInline(ctx, target, creds) {
|
|
|
5960
6157
|
target.innerHTML = "";
|
|
5961
6158
|
const root = el(
|
|
5962
6159
|
"section",
|
|
5963
|
-
|
|
6160
|
+
`${fontFamilyCss("body")}color:#111827;max-width:860px;margin:0 auto;-webkit-font-smoothing:antialiased;`
|
|
5964
6161
|
);
|
|
5965
6162
|
root.setAttribute("data-aegis-reviews", "true");
|
|
5966
6163
|
const summary = data.aggregate.ai_summary;
|
|
@@ -5998,7 +6195,7 @@ function renderReviewsInline(ctx, target, creds) {
|
|
|
5998
6195
|
if (data.aggregate.count === 0) return;
|
|
5999
6196
|
const root = el(
|
|
6000
6197
|
"section",
|
|
6001
|
-
|
|
6198
|
+
`${fontFamilyCss("body")}color:#111827;max-width:860px;margin:0 auto;border:1px solid #f0f1f3;border-radius:16px;padding:16px 18px;`
|
|
6002
6199
|
);
|
|
6003
6200
|
const line = el("div", "display:flex;align-items:center;gap:8px;");
|
|
6004
6201
|
const avg = data.aggregate.avg_rating ?? 0;
|
|
@@ -6030,12 +6227,11 @@ function renderReviewsInline(ctx, target, creds) {
|
|
|
6030
6227
|
}
|
|
6031
6228
|
function renderReviewsOverlay(ctx, creds) {
|
|
6032
6229
|
if (typeof document === "undefined" || !(creds == null ? void 0 : creds.apiHost) || !(creds == null ? void 0 : creds.writeKey)) return;
|
|
6033
|
-
ensureInAppFont();
|
|
6034
6230
|
const overlay = document.createElement("div");
|
|
6035
6231
|
overlay.setAttribute("data-campaign-id", ctx.campaign.id);
|
|
6036
6232
|
overlay.style.cssText = "position:fixed;inset:0;background:rgba(17,24,39,0.5);display:flex;align-items:flex-end;justify-content:center;z-index:99999;";
|
|
6037
6233
|
const sheet = document.createElement("div");
|
|
6038
|
-
sheet.style.cssText = `background:#fff;color:#111827;max-width:680px;width:100%;max-height:84vh;overflow-y:auto;border-radius:24px 24px 0 0;padding:18px 18px 28px
|
|
6234
|
+
sheet.style.cssText = `background:#fff;color:#111827;max-width:680px;width:100%;max-height:84vh;overflow-y:auto;border-radius:24px 24px 0 0;padding:18px 18px 28px;${fontFamilyCss("body")}box-shadow:0 -16px 40px rgba(0,0,0,0.14);`;
|
|
6039
6235
|
sheet.appendChild(el("div", "width:38px;height:4px;border-radius:999px;background:#e5e7eb;margin:0 auto 14px;"));
|
|
6040
6236
|
const bar = el("div", "display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;");
|
|
6041
6237
|
bar.appendChild(el("div", "font-weight:800;font-size:17px;", ctx.campaign.title || "Customer reviews"));
|
|
@@ -6603,6 +6799,12 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
6603
6799
|
if (config.productUrl) this.productUrl = config.productUrl;
|
|
6604
6800
|
this.getWorkspaceId = config.getWorkspaceId;
|
|
6605
6801
|
this.getCartState = config.getCartState;
|
|
6802
|
+
if (config.surface && _AegisInAppManager.KNOWN_SURFACES.has(config.surface)) {
|
|
6803
|
+
this.currentSurface = config.surface;
|
|
6804
|
+
}
|
|
6805
|
+
const screen = config.screen || config.surface;
|
|
6806
|
+
if (screen && screen !== "page_view") this.currentScreen = screen;
|
|
6807
|
+
if (config.locationId) this.currentLocationId = config.locationId;
|
|
6606
6808
|
}
|
|
6607
6809
|
emit(eventName, payload) {
|
|
6608
6810
|
const handlers = this.hooks.get(eventName);
|
|
@@ -6704,7 +6906,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
6704
6906
|
}
|
|
6705
6907
|
} catch {
|
|
6706
6908
|
}
|
|
6707
|
-
|
|
6909
|
+
applyRootFonts(null);
|
|
6708
6910
|
await this.refreshCampaigns();
|
|
6709
6911
|
if (this.enableSSE && this.organizationId) {
|
|
6710
6912
|
this.connectSSE();
|
|
@@ -6712,8 +6914,10 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
6712
6914
|
this.isInitialized = true;
|
|
6713
6915
|
if (this.pendingPreInitRefresh) {
|
|
6714
6916
|
this.pendingPreInitRefresh = false;
|
|
6715
|
-
this.
|
|
6716
|
-
|
|
6917
|
+
if (this.activeRequestKey() !== this.lastActiveRequestKey) {
|
|
6918
|
+
this.log("Re-fetching campaigns for surface/screen declared during init");
|
|
6919
|
+
void this.refreshCampaigns();
|
|
6920
|
+
}
|
|
6717
6921
|
}
|
|
6718
6922
|
if (typeof Notification !== "undefined" && Notification.permission === "granted" && this.propertyId) {
|
|
6719
6923
|
let alreadyHealed = false;
|
|
@@ -6820,6 +7024,11 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
6820
7024
|
}
|
|
6821
7025
|
this.refreshCampaigns();
|
|
6822
7026
|
}
|
|
7027
|
+
/** The page context a `/v1/in-app/active` request is built from now. */
|
|
7028
|
+
activeRequestKey() {
|
|
7029
|
+
const url = this.currentPageUrl() ?? "/";
|
|
7030
|
+
return [url, this.currentSurface ?? "", this.currentScreen ?? "", this.currentLocationId ?? ""].join("|");
|
|
7031
|
+
}
|
|
6823
7032
|
/**
|
|
6824
7033
|
* Qualifying-event refresh — schedule a debounced `refreshCampaigns()`
|
|
6825
7034
|
* call in response to a host-app SDK event (`aegis.page()`,
|
|
@@ -6863,6 +7072,10 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
6863
7072
|
this.log(`refreshOnEvent(${eventName}) before initialize — surface captured, refetch deferred to initialize()`);
|
|
6864
7073
|
return;
|
|
6865
7074
|
}
|
|
7075
|
+
if (isScreenDeclaration && this.lastActiveRequestKey !== void 0 && this.activeRequestKey() === this.lastActiveRequestKey) {
|
|
7076
|
+
this.log(`refreshOnEvent(${eventName}) — page context unchanged, no refetch`);
|
|
7077
|
+
return;
|
|
7078
|
+
}
|
|
6866
7079
|
if (this.refreshDebounceTimer) {
|
|
6867
7080
|
clearTimeout(this.refreshDebounceTimer);
|
|
6868
7081
|
}
|
|
@@ -7109,6 +7322,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7109
7322
|
}
|
|
7110
7323
|
async refreshCampaigns() {
|
|
7111
7324
|
const gen = this.lifecycleGen;
|
|
7325
|
+
let requestKey;
|
|
7112
7326
|
try {
|
|
7113
7327
|
const context = new URLSearchParams({
|
|
7114
7328
|
device_type: this.detectDeviceType(),
|
|
@@ -7127,6 +7341,8 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7127
7341
|
context.set("location_id", this.currentLocationId);
|
|
7128
7342
|
}
|
|
7129
7343
|
const url = `${this.apiHost}/v1/in-app/active?${context.toString()}`;
|
|
7344
|
+
requestKey = this.activeRequestKey();
|
|
7345
|
+
this.lastActiveRequestKey = requestKey;
|
|
7130
7346
|
const headers = {
|
|
7131
7347
|
"X-Aegis-Write-Key": this.writeKey,
|
|
7132
7348
|
"Content-Type": "application/json"
|
|
@@ -7162,6 +7378,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7162
7378
|
const payload = await response.json();
|
|
7163
7379
|
if (gen !== this.lifecycleGen) return;
|
|
7164
7380
|
this.campaigns = Array.isArray(payload) ? payload : [];
|
|
7381
|
+
applyCampaignFonts(this.campaigns);
|
|
7165
7382
|
this.processABAssignments(this.campaigns);
|
|
7166
7383
|
this.rehydrateSuppressionFromStorage();
|
|
7167
7384
|
this.log(`Fetched ${this.campaigns.length} campaigns`);
|
|
@@ -7174,6 +7391,9 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7174
7391
|
this.renderIntoAnchors();
|
|
7175
7392
|
this.renderTokenAnchors();
|
|
7176
7393
|
} catch (error) {
|
|
7394
|
+
if (requestKey !== void 0 && this.lastActiveRequestKey === requestKey) {
|
|
7395
|
+
this.lastActiveRequestKey = void 0;
|
|
7396
|
+
}
|
|
7177
7397
|
if (gen !== this.lifecycleGen) return;
|
|
7178
7398
|
this.emitError(error, { stage: "refresh-campaigns" });
|
|
7179
7399
|
this.log(`Error refreshing campaigns: ${error}`, "error");
|
|
@@ -8422,7 +8642,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
8422
8642
|
body.style.cssText = `padding: ${st.padY ?? 22}px ${st.padX ?? 20}px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px;`;
|
|
8423
8643
|
if (campaign.title) {
|
|
8424
8644
|
const t = document.createElement("div");
|
|
8425
|
-
t.style.cssText = `font-size: 18px; font-weight: 800; letter-spacing: -0.01em; text-align: center;
|
|
8645
|
+
t.style.cssText = `font-size: 18px; font-weight: 800; letter-spacing: -0.01em; text-align: center; ${fontFamilyCss("display")}`;
|
|
8426
8646
|
t.textContent = campaign.title;
|
|
8427
8647
|
body.appendChild(t);
|
|
8428
8648
|
}
|
|
@@ -8522,7 +8742,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
8522
8742
|
}
|
|
8523
8743
|
const tx = document.createElement("span");
|
|
8524
8744
|
tx.textContent = label;
|
|
8525
|
-
tx.style.cssText = `white-space: nowrap; line-height: 1.05; font-size: ${fontPx}px; font-weight: 900;
|
|
8745
|
+
tx.style.cssText = `white-space: nowrap; line-height: 1.05; font-size: ${fontPx}px; font-weight: 900; ${fontFamilyCss("display")} letter-spacing: 0.2px; text-transform: uppercase; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.65), 0 0 1px rgba(0,0,0,0.9); -webkit-font-smoothing: antialiased;`;
|
|
8526
8746
|
lab.appendChild(tx);
|
|
8527
8747
|
wheel.appendChild(lab);
|
|
8528
8748
|
});
|
|
@@ -8575,7 +8795,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
8575
8795
|
}
|
|
8576
8796
|
const btn = document.createElement("button");
|
|
8577
8797
|
btn.textContent = campaign.button_text || "Spin the wheel";
|
|
8578
|
-
btn.style.cssText = `padding: 9px 22px; border-radius: 999px; border: none; background: ${text}; color: ${bg}; font-size: 13px; font-weight: 700; letter-spacing: 0.2px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.20); transition: transform 0.15s, box-shadow 0.15s;
|
|
8798
|
+
btn.style.cssText = `padding: 9px 22px; border-radius: 999px; border: none; background: ${text}; color: ${bg}; font-size: 13px; font-weight: 700; letter-spacing: 0.2px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.20); transition: transform 0.15s, box-shadow 0.15s; ${fontFamilyCss("body")}`;
|
|
8579
8799
|
btn.addEventListener("mouseenter", () => {
|
|
8580
8800
|
if (btn.disabled) return;
|
|
8581
8801
|
btn.style.transform = "translateY(-1px)";
|
|
@@ -8672,7 +8892,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
8672
8892
|
eyebrow.style.cssText = "font-size: 13px; font-weight: 700; letter-spacing: 0.3px; opacity: 0.8;";
|
|
8673
8893
|
const big = document.createElement("div");
|
|
8674
8894
|
big.textContent = r.label;
|
|
8675
|
-
big.style.cssText = `font-size: 24px; font-weight: 900; letter-spacing: -0.02em;
|
|
8895
|
+
big.style.cssText = `font-size: 24px; font-weight: 900; letter-spacing: -0.02em; ${fontFamilyCss("display")}`;
|
|
8676
8896
|
ov.appendChild(eyebrow);
|
|
8677
8897
|
ov.appendChild(big);
|
|
8678
8898
|
if (r.code) {
|
|
@@ -9245,7 +9465,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
9245
9465
|
eb.style.cssText = "font-size: 12px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; opacity: 0.7;";
|
|
9246
9466
|
const big = document.createElement("div");
|
|
9247
9467
|
big.textContent = label;
|
|
9248
|
-
big.style.cssText = `font-size: 22px; font-weight: 900; letter-spacing: -0.02em;
|
|
9468
|
+
big.style.cssText = `font-size: 22px; font-weight: 900; letter-spacing: -0.02em; ${fontFamilyCss("display")}`;
|
|
9249
9469
|
ov.appendChild(eb);
|
|
9250
9470
|
ov.appendChild(big);
|
|
9251
9471
|
if (code) {
|
|
@@ -9827,7 +10047,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
9827
10047
|
iframe.style.cssText = `width: 100%; height: ${height}px; border: none; display: block; background: #fff; transform: translateZ(0); backface-visibility: hidden;`;
|
|
9828
10048
|
iframe.title = campaign.title || "In-app content";
|
|
9829
10049
|
const shim = "<script>window.aegis={close:function(){parent.postMessage({__aegis:'close'},'*')},track:function(e,p){parent.postMessage({__aegis:'track',event:e,payload:p},'*')},cta:function(u){parent.postMessage({__aegis:'cta',url:u},'*')},resize:function(h){parent.postMessage({__aegis:'resize',height:h},'*')}};<\/script>";
|
|
9830
|
-
iframe.srcdoc = '<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>' + brandVars + "html,body{margin:0;padding:0;font-family:
|
|
10050
|
+
iframe.srcdoc = '<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>' + brandVars + "html,body{margin:0;padding:0;font-family:" + BODY_FONT_STACK + ";}</style>" + shim + "</head><body>" + html + "</body></html>";
|
|
9831
10051
|
const onMsg = (e) => {
|
|
9832
10052
|
if (e.source !== iframe.contentWindow) return;
|
|
9833
10053
|
const d = e.data;
|
|
@@ -10372,7 +10592,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
10372
10592
|
};
|
|
10373
10593
|
const heading = (txt, big = false) => {
|
|
10374
10594
|
const t = document.createElement("div");
|
|
10375
|
-
t.style.cssText = `font-size: ${big ? 19 : 14}px; font-weight: ${big ? 800 : 600}; letter-spacing: -0.01em; line-height: 1.3; margin-bottom: ${big ? 6 : 14}px;
|
|
10595
|
+
t.style.cssText = `font-size: ${big ? 19 : 14}px; font-weight: ${big ? 800 : 600}; letter-spacing: -0.01em; line-height: 1.3; margin-bottom: ${big ? 6 : 14}px; ${fontFamilyCss("display")}`;
|
|
10376
10596
|
t.textContent = txt;
|
|
10377
10597
|
return t;
|
|
10378
10598
|
};
|
|
@@ -10787,7 +11007,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
10787
11007
|
display: flex;
|
|
10788
11008
|
align-items: center;
|
|
10789
11009
|
justify-content: space-between;
|
|
10790
|
-
|
|
11010
|
+
${fontFamilyCss("body")}
|
|
10791
11011
|
animation: ${atBottom ? "aegisSlideInFromBottom" : "aegisSlideDown"} 0.3s ease-out;
|
|
10792
11012
|
`;
|
|
10793
11013
|
banner.setAttribute("data-banner-position", atBottom ? "bottom" : "top");
|
|
@@ -10907,7 +11127,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
10907
11127
|
overflow: auto;
|
|
10908
11128
|
box-shadow: 0 16px 48px rgba(0,0,0,0.22);
|
|
10909
11129
|
animation: aegisScaleIn 0.3s ease-out;
|
|
10910
|
-
|
|
11130
|
+
${fontFamilyCss("body")}
|
|
10911
11131
|
`;
|
|
10912
11132
|
if (videoUrl) {
|
|
10913
11133
|
const mediaWrap = document.createElement("div");
|
|
@@ -11081,7 +11301,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
11081
11301
|
z-index: 1000001; display: flex; flex-direction: column; align-items: center;
|
|
11082
11302
|
justify-content: ${isBg ? "flex-end" : "center"}; padding: ${isBg ? "0" : "40px 20px"};
|
|
11083
11303
|
animation: aegisFadeIn 0.3s ease-out; overflow: hidden;
|
|
11084
|
-
|
|
11304
|
+
${fontFamilyCss("body")}
|
|
11085
11305
|
`;
|
|
11086
11306
|
if (isBg) {
|
|
11087
11307
|
const media = document.createElement("div");
|
|
@@ -11219,7 +11439,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
11219
11439
|
overflow: auto;
|
|
11220
11440
|
box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
|
|
11221
11441
|
animation: aegisSlideUp 0.3s ease-out;
|
|
11222
|
-
|
|
11442
|
+
${fontFamilyCss("body")}
|
|
11223
11443
|
`;
|
|
11224
11444
|
const grabber = document.createElement("div");
|
|
11225
11445
|
grabber.style.cssText = `width: 40px; height: 4px; border-radius: 2px; background: ${st.text}33; margin: 10px auto 0;`;
|
|
@@ -11364,7 +11584,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
11364
11584
|
width: 85%;
|
|
11365
11585
|
box-shadow: 0 16px 48px rgba(0,0,0,0.22);
|
|
11366
11586
|
animation: aegisScaleIn 0.2s ease-out;
|
|
11367
|
-
|
|
11587
|
+
${fontFamilyCss("body")}
|
|
11368
11588
|
overflow: hidden;
|
|
11369
11589
|
`;
|
|
11370
11590
|
const content = document.createElement("div");
|
|
@@ -11482,7 +11702,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
11482
11702
|
background: #000; border-radius: 14px; overflow: hidden;
|
|
11483
11703
|
box-shadow: 0 10px 30px rgba(0,0,0,0.38); z-index: 999999;
|
|
11484
11704
|
animation: ${slideAnim} 0.3s ease-out; transition: width 0.25s ease, border-radius 0.25s ease;
|
|
11485
|
-
|
|
11705
|
+
${fontFamilyCss("body")}
|
|
11486
11706
|
`;
|
|
11487
11707
|
const mediaWrap = document.createElement("div");
|
|
11488
11708
|
mediaWrap.style.cssText = "position: relative; width: 100%; background: #000; line-height: 0; aspect-ratio: 16 / 9;";
|
|
@@ -11633,7 +11853,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
11633
11853
|
position: fixed; ${cornerCss} width: ${cornerW}px; max-width: calc(100vw - ${gap * 2}px);
|
|
11634
11854
|
background: #000; border-radius: 14px; overflow: hidden;
|
|
11635
11855
|
box-shadow: 0 10px 30px rgba(0,0,0,0.38); z-index: 999999; transition: none;
|
|
11636
|
-
|
|
11856
|
+
${fontFamilyCss("body")}
|
|
11637
11857
|
`;
|
|
11638
11858
|
if (expandBtn) {
|
|
11639
11859
|
expandBtn.textContent = "⤢";
|
|
@@ -11653,7 +11873,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
11653
11873
|
width: ${theaterW}px; max-width: calc(100vw - ${gap * 2}px);
|
|
11654
11874
|
background: #000; border-radius: 16px; overflow: hidden;
|
|
11655
11875
|
box-shadow: 0 24px 60px rgba(0,0,0,0.55); z-index: 999999; transition: none;
|
|
11656
|
-
|
|
11876
|
+
${fontFamilyCss("body")}
|
|
11657
11877
|
`;
|
|
11658
11878
|
if (expandBtn) {
|
|
11659
11879
|
expandBtn.innerHTML = lucideSvg("x", { size: 16 });
|
|
@@ -11783,7 +12003,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
11783
12003
|
tooltip.style.cssText = `
|
|
11784
12004
|
position: absolute; z-index: 1000001; max-width: 280px; width: max-content;
|
|
11785
12005
|
background: ${bg}; color: ${textColor}; border-radius: 10px; padding: 14px 16px;
|
|
11786
|
-
box-shadow: 0 8px 24px rgba(0,0,0,0.18);
|
|
12006
|
+
box-shadow: 0 8px 24px rgba(0,0,0,0.18); ${fontFamilyCss("body")}
|
|
11787
12007
|
animation: aegisScaleIn 0.2s ease-out; pointer-events: auto;
|
|
11788
12008
|
`;
|
|
11789
12009
|
const arrow = document.createElement("div");
|
|
@@ -12557,6 +12777,7 @@ _AegisInAppManager.SERVED_DEDUP_PREFIX = "aegis_served_fired:";
|
|
|
12557
12777
|
_AegisInAppManager.JOURNEY_ACK_RETRY_MS = 2e3;
|
|
12558
12778
|
let AegisInAppManager = _AegisInAppManager;
|
|
12559
12779
|
function renderPreview(config, opts) {
|
|
12780
|
+
applyCampaignFonts([config, ...(opts == null ? void 0 : opts.coGroup) ?? []]);
|
|
12560
12781
|
document.querySelectorAll(
|
|
12561
12782
|
'[class^="aegis-in-app-"]'
|
|
12562
12783
|
).forEach((el2) => {
|
|
@@ -14149,7 +14370,7 @@ class AegisWidgetManager {
|
|
|
14149
14370
|
display: flex;
|
|
14150
14371
|
align-items: center;
|
|
14151
14372
|
gap: 12px;
|
|
14152
|
-
|
|
14373
|
+
${fontFamilyCss("body")}
|
|
14153
14374
|
font-weight: 600;
|
|
14154
14375
|
font-size: 14px;
|
|
14155
14376
|
animation: aegisBubbleIn 0.3s ease-out;
|
|
@@ -14210,7 +14431,7 @@ class AegisWidgetManager {
|
|
|
14210
14431
|
align-items: center;
|
|
14211
14432
|
gap: 12px;
|
|
14212
14433
|
max-width: 350px;
|
|
14213
|
-
|
|
14434
|
+
${fontFamilyCss("body")}
|
|
14214
14435
|
animation: aegisToastIn 0.3s ease-out;
|
|
14215
14436
|
`;
|
|
14216
14437
|
if (icon) {
|
|
@@ -14251,7 +14472,7 @@ class AegisWidgetManager {
|
|
|
14251
14472
|
z-index: 1000000;
|
|
14252
14473
|
padding: 32px;
|
|
14253
14474
|
overflow-y: auto;
|
|
14254
|
-
|
|
14475
|
+
${fontFamilyCss("body")}
|
|
14255
14476
|
animation: aegisSlideInRight 0.3s ease-out;
|
|
14256
14477
|
`;
|
|
14257
14478
|
const title = document.createElement("h2");
|
|
@@ -14382,7 +14603,7 @@ class AegisWidgetManager {
|
|
|
14382
14603
|
width: 90%;
|
|
14383
14604
|
overflow: hidden;
|
|
14384
14605
|
box-shadow: 0 10px 40px rgba(0,0,0,0.3);
|
|
14385
|
-
|
|
14606
|
+
${fontFamilyCss("body")}
|
|
14386
14607
|
animation: aegisScaleIn 0.3s ease-out;
|
|
14387
14608
|
`;
|
|
14388
14609
|
if (image_url) {
|
|
@@ -14626,7 +14847,7 @@ class AegisWidgetManager {
|
|
|
14626
14847
|
width: 90%;
|
|
14627
14848
|
padding: 40px;
|
|
14628
14849
|
box-shadow: 0 10px 40px rgba(0,0,0,0.3);
|
|
14629
|
-
|
|
14850
|
+
${fontFamilyCss("body")}
|
|
14630
14851
|
animation: aegisScaleIn 0.3s ease-out;
|
|
14631
14852
|
position: relative;
|
|
14632
14853
|
`;
|
|
@@ -14752,7 +14973,7 @@ class AegisWidgetManager {
|
|
|
14752
14973
|
padding: 40px;
|
|
14753
14974
|
box-shadow: 0 10px 40px rgba(0,0,0,0.3);
|
|
14754
14975
|
text-align: center;
|
|
14755
|
-
|
|
14976
|
+
${fontFamilyCss("body")}
|
|
14756
14977
|
animation: aegisScaleIn 0.3s ease-out;
|
|
14757
14978
|
position: relative;
|
|
14758
14979
|
`;
|
|
@@ -15161,7 +15382,7 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
|
|
|
15161
15382
|
this.initialized = false;
|
|
15162
15383
|
this.armedInAppTriggers = /* @__PURE__ */ new Set();
|
|
15163
15384
|
{
|
|
15164
|
-
const v = "1.
|
|
15385
|
+
const v = "1.44.0";
|
|
15165
15386
|
try {
|
|
15166
15387
|
globalThis.__AEGIS_SDK_VERSION__ = v;
|
|
15167
15388
|
} catch {
|
|
@@ -15227,7 +15448,12 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
|
|
|
15227
15448
|
// native) registers ONE `onAction` to handle add_to_cart/open_product/…;
|
|
15228
15449
|
// legacy `aegis:*` DOM events still fire for back-compat.
|
|
15229
15450
|
onAction: config.onAction,
|
|
15230
|
-
productUrl: config.productUrl
|
|
15451
|
+
productUrl: config.productUrl,
|
|
15452
|
+
// Page context known at build time: the FIRST /v1/in-app/active is
|
|
15453
|
+
// already scoped, so no page(surface) refetch (slot plan Phase 1).
|
|
15454
|
+
surface: config.surface,
|
|
15455
|
+
screen: config.screen,
|
|
15456
|
+
locationId: config.locationId
|
|
15231
15457
|
});
|
|
15232
15458
|
this.intentRuleEvaluator = new IntentRuleEvaluator();
|
|
15233
15459
|
if (config.governance) {
|
|
@@ -15299,6 +15525,12 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
|
|
|
15299
15525
|
/**
|
|
15300
15526
|
* Boots both managers in parallel. Safe to call multiple times — the
|
|
15301
15527
|
* second + subsequent calls are no-ops.
|
|
15528
|
+
*
|
|
15529
|
+
* In-app paint never waits on the widget config: `inApp.initialize()` paints
|
|
15530
|
+
* the slots as soon as ITS `/v1/in-app/active` returns; the returned promise
|
|
15531
|
+
* only resolves after both. So a host must not hold page context back until
|
|
15532
|
+
* this resolves — pass `surface` / `screen` in the config (or call `page()`
|
|
15533
|
+
* before `initialize()`) and the first fetch is already scoped.
|
|
15302
15534
|
*/
|
|
15303
15535
|
async initialize() {
|
|
15304
15536
|
var _a;
|