@active-reach/web-sdk 1.43.6 → 1.45.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.
Files changed (39) hide show
  1. package/README.md +39 -0
  2. package/dist/aegis.min.js +1 -1
  3. package/dist/aegis.min.js.map +1 -1
  4. package/dist/{analytics-C-Go3Pm5.mjs → analytics-CfEHNTzy.mjs} +1 -1
  5. package/dist/{analytics-C-Go3Pm5.mjs.map → analytics-CfEHNTzy.mjs.map} +1 -1
  6. package/dist/chat/AegisChat.d.ts.map +1 -1
  7. package/dist/inapp/AegisInAppManager.d.ts +55 -0
  8. package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
  9. package/dist/inapp/font.d.ts +118 -11
  10. package/dist/inapp/font.d.ts.map +1 -1
  11. package/dist/inapp/renderPreview.d.ts.map +1 -1
  12. package/dist/inapp/renderers/card-template.d.ts +15 -5
  13. package/dist/inapp/renderers/card-template.d.ts.map +1 -1
  14. package/dist/inapp/renderers/carousel-cards.d.ts.map +1 -1
  15. package/dist/inapp/renderers/coachmark-tour.d.ts.map +1 -1
  16. package/dist/inapp/renderers/games.d.ts.map +1 -1
  17. package/dist/inapp/renderers/hero.d.ts +0 -16
  18. package/dist/inapp/renderers/hero.d.ts.map +1 -1
  19. package/dist/inapp/renderers/product-recommendation.d.ts +1 -1
  20. package/dist/inapp/renderers/product-recommendation.d.ts.map +1 -1
  21. package/dist/inapp/renderers/progress-bar.d.ts.map +1 -1
  22. package/dist/inapp/renderers/reviews.d.ts +1 -1
  23. package/dist/inapp/renderers/reviews.d.ts.map +1 -1
  24. package/dist/inapp/renderers/sticky-bar.d.ts.map +1 -1
  25. package/dist/inapp/renderers/stories.d.ts.map +1 -1
  26. package/dist/inapp/renderers/video.d.ts.map +1 -1
  27. package/dist/inapp/slot-shells.d.ts +99 -0
  28. package/dist/inapp/slot-shells.d.ts.map +1 -0
  29. package/dist/inapp/slot-winners.d.ts +43 -0
  30. package/dist/inapp/slot-winners.d.ts.map +1 -0
  31. package/dist/index.js +680 -124
  32. package/dist/index.js.map +1 -1
  33. package/dist/integrations/react.d.ts.map +1 -1
  34. package/dist/react.js +1 -1
  35. package/dist/runtime/AegisMessageRuntime.d.ts +6 -0
  36. package/dist/runtime/AegisMessageRuntime.d.ts.map +1 -1
  37. package/dist/triggers/IntentRuleEvaluator.d.ts.map +1 -1
  38. package/dist/widgets/AegisWidgetManager.d.ts.map +1 -1
  39. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Storage, r as redactUrl, l as logger, A as Aegis } from "./analytics-C-Go3Pm5.mjs";
2
- import { B, E, N, R, U, m } from "./analytics-C-Go3Pm5.mjs";
1
+ import { S as Storage, r as redactUrl, l as logger, A as Aegis } from "./analytics-CfEHNTzy.mjs";
2
+ import { B, E, N, R, U, m } from "./analytics-CfEHNTzy.mjs";
3
3
  import { AegisWebPush } from "./push/AegisWebPush.js";
4
4
  function debounce(func, wait) {
5
5
  let timeoutId = null;
@@ -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 IN_APP_FONT_STACK = "'Urbanist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif";
364
- function ensureInAppFont() {
365
- if (typeof document === "undefined") return;
366
- if (document.getElementById("aegis-inapp-font-urbanist")) return;
367
- const link = document.createElement("link");
368
- link.id = "aegis-inapp-font-urbanist";
369
- link.rel = "stylesheet";
370
- link.href = "https://fonts.googleapis.com/css2?family=Urbanist:wght@400;500;600;700;800&display=swap";
371
- document.head.appendChild(link);
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
- if (ff === "inherit") return "";
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;
@@ -474,6 +672,21 @@ function interpolateTokens(s, ctx) {
474
672
  });
475
673
  }
476
674
  const ASPECT$2 = { "1/1": "1 / 1", "4/3": "4 / 3", "16/9": "16 / 9" };
675
+ const IMAGE_SIZE = {
676
+ "1/1": { width: 300, height: 300 },
677
+ "4/3": { width: 400, height: 300 },
678
+ "16/9": { width: 400, height: 225 }
679
+ };
680
+ function fadeInOnDecode(img) {
681
+ const decode = img.decode;
682
+ if (typeof decode !== "function") return;
683
+ img.style.opacity = "0";
684
+ img.style.transition = "opacity 0.2s ease";
685
+ const show = () => {
686
+ img.style.opacity = "1";
687
+ };
688
+ decode.call(img).then(show, show);
689
+ }
477
690
  const DEFAULT_CARD_TEMPLATE = {
478
691
  id: "clean",
479
692
  frame: { bg: "#ffffff", border: "#f1f1f3", radius: 14 },
@@ -1549,8 +1762,8 @@ function renderCardFromTemplate(card, opts) {
1549
1762
  const muted = fg === "#ffffff" ? "rgba(255,255,255,0.72)" : "#6b7280";
1550
1763
  const tile = document.createElement("div");
1551
1764
  tile.setAttribute("data-aegis-reaction-anchor", "");
1552
- const cardFont = resolveCardFont(frame.fontFamily);
1553
- ensureCardFontLoaded(cardFont);
1765
+ const cardFont = resolveCardFont(campaignFontFamily(campaign) ?? frame.fontFamily);
1766
+ const displayFont = fontFamilyCss("display");
1554
1767
  const radius = frame.radius !== void 0 ? `${parseInt(String(frame.radius), 10) || 12}px` : "12px";
1555
1768
  const fLayout = frame.layout;
1556
1769
  const dir = fLayout === "row" ? "row" : "column";
@@ -1559,7 +1772,7 @@ function renderCardFromTemplate(card, opts) {
1559
1772
  tile.style.cssText = `
1560
1773
  box-sizing:border-box; display:flex; flex-direction:${dir}; ${fLayout === "row" ? "align-items:center;" : ""} gap:${tileGap}px; position:relative;
1561
1774
  color:${fg};
1562
- ${cardFont ? `font-family:${cardFont};` : ""}
1775
+ ${cardFont}
1563
1776
  background:${frame.bg ? sanitizeColor(frame.bg) : "#ffffff"};
1564
1777
  border:1px solid ${frame.border ? sanitizeColor(frame.border) : "transparent"};
1565
1778
  border-radius:${radius}; padding:8px;
@@ -1596,10 +1809,15 @@ function renderCardFromTemplate(card, opts) {
1596
1809
  const safe = sanitizeUrl(card.image_url);
1597
1810
  if (safe) {
1598
1811
  const img = document.createElement("img");
1812
+ const size = IMAGE_SIZE[el2.aspect || "1/1"] || IMAGE_SIZE["1/1"];
1813
+ img.loading = "lazy";
1814
+ img.setAttribute("decoding", "async");
1815
+ img.setAttribute("width", String(size.width));
1816
+ img.setAttribute("height", String(size.height));
1599
1817
  img.src = safe;
1600
1818
  img.alt = "";
1601
- img.loading = "lazy";
1602
1819
  img.style.cssText = "width:100%;height:100%;object-fit:cover;display:block;";
1820
+ fadeInOnDecode(img);
1603
1821
  wrap.appendChild(img);
1604
1822
  }
1605
1823
  }
@@ -1619,7 +1837,10 @@ function renderCardFromTemplate(card, opts) {
1619
1837
  }
1620
1838
  case "price": {
1621
1839
  const node = paintPrice(card, el2, accent, ctx);
1622
- if (node) container.appendChild(node);
1840
+ if (node) {
1841
+ node.style.cssText += `${displayFont}font-variant-numeric:tabular-nums;`;
1842
+ container.appendChild(node);
1843
+ }
1623
1844
  break;
1624
1845
  }
1625
1846
  case "title": {
@@ -1627,7 +1848,7 @@ function renderCardFromTemplate(card, opts) {
1627
1848
  const t = document.createElement("div");
1628
1849
  t.textContent = card.title;
1629
1850
  const lines = el2.lines && el2.lines > 0 ? el2.lines : 2;
1630
- t.style.cssText = `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;`;
1851
+ 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
1852
  container.appendChild(t);
1632
1853
  break;
1633
1854
  }
@@ -1798,7 +2019,6 @@ function renderCarouselCards(ctx) {
1798
2019
  const loop = ic.loop !== false;
1799
2020
  const layout = ic.rec_layout || "row";
1800
2021
  addAnimationStyles();
1801
- ensureInAppFont();
1802
2022
  const bg = "#ffffff";
1803
2023
  const fg = "#0f172a";
1804
2024
  const accent = sanitizeColor(campaign.background_color || "#4169e1");
@@ -1809,7 +2029,7 @@ function renderCarouselCards(ctx) {
1809
2029
  position: fixed; left: 0; right: 0; bottom: 0;
1810
2030
  z-index: 99999; padding: 12px 12px 20px;
1811
2031
  background: rgba(0,0,0,0.12); backdrop-filter: blur(8px);
1812
- font-family: ${IN_APP_FONT_STACK};
2032
+ ${fontFamilyCss("body")}
1813
2033
  animation: aegisSlideInFromBottom 0.3s ease-out;
1814
2034
  `;
1815
2035
  const card = document.createElement("div");
@@ -1993,7 +2213,7 @@ function renderStickyBar(ctx) {
1993
2213
  position: fixed; ${positionCss}
1994
2214
  background: ${bg}; color: ${fg};
1995
2215
  padding: 10px 14px; z-index: 999998;
1996
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
2216
+ ${fontFamilyCss("body")}
1997
2217
  display: flex; align-items: center; gap: 12px; justify-content: center;
1998
2218
  box-shadow: 0 ${position === "top" ? "2px" : "-2px"} 8px rgba(0,0,0,0.08);
1999
2219
  `;
@@ -2081,14 +2301,14 @@ function buildProgressBar(ctx, inline) {
2081
2301
  bar.style.cssText = inline ? `
2082
2302
  background: ${bg}; color: ${fg};
2083
2303
  padding: 10px 14px;
2084
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
2304
+ ${fontFamilyCss("body")}
2085
2305
  ` : `
2086
2306
  position: fixed; left: 12px; right: 12px; bottom: 12px;
2087
2307
  max-width: 540px; margin: 0 auto;
2088
2308
  background: ${bg}; color: ${fg}; border-radius: 12px;
2089
2309
  padding: 10px 14px; z-index: 999997;
2090
2310
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
2091
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
2311
+ ${fontFamilyCss("body")}
2092
2312
  animation: aegisSlideInFromBottom 0.3s ease-out;
2093
2313
  `;
2094
2314
  const label = document.createElement("div");
@@ -2357,7 +2577,7 @@ function renderCoachmarkTour(ctx) {
2357
2577
  padding: 12px 14px; border-radius: 12px;
2358
2578
  max-width: 260px;
2359
2579
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
2360
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
2580
+ ${fontFamilyCss("body")}
2361
2581
  animation: aegisFadeIn 0.2s ease;
2362
2582
  `;
2363
2583
  const titleEl = document.createElement("div");
@@ -2467,7 +2687,6 @@ function renderProductRecommendation(ctx) {
2467
2687
  const layout = ic.rec_layout || "grid";
2468
2688
  const template = resolveGlobalTemplate(ic);
2469
2689
  addAnimationStyles();
2470
- ensureInAppFont();
2471
2690
  const bg = "#ffffff";
2472
2691
  const fg = "#0f172a";
2473
2692
  const accent = sanitizeColor(campaign.background_color || "#4169e1");
@@ -2486,7 +2705,7 @@ function renderProductRecommendation(ctx) {
2486
2705
  max-width: 560px; width: 100%; max-height: 80vh; overflow-y: auto;
2487
2706
  border-radius: 20px 20px 0 0;
2488
2707
  padding: 18px 16px 22px;
2489
- font-family: ${IN_APP_FONT_STACK};
2708
+ ${fontFamilyCss("body")}
2490
2709
  animation: aegisSlideInFromBottom 0.3s ease-out;
2491
2710
  box-shadow: 0 -12px 30px rgba(0,0,0,0.12);
2492
2711
  `;
@@ -2566,12 +2785,11 @@ function renderProductRecommendationInline(ctx, target) {
2566
2785
  const fg = "#0f172a";
2567
2786
  const accent = sanitizeColor(campaign.background_color || "#4169e1");
2568
2787
  addAnimationStyles();
2569
- ensureInAppFont();
2570
2788
  const section = document.createElement("section");
2571
2789
  section.className = "aegis-in-app-product-rec-inline";
2572
2790
  section.setAttribute("data-campaign-id", campaign.id);
2573
2791
  section.style.cssText = `
2574
- font-family: ${IN_APP_FONT_STACK};
2792
+ ${fontFamilyCss("body")}
2575
2793
  color: ${fg};
2576
2794
  `;
2577
2795
  if (campaign.title) {
@@ -2727,14 +2945,14 @@ function renderLauncherBar(ctx, cfg, target) {
2727
2945
  padding: 14px 18px 16px 20px; scroll-padding-left: 20px;
2728
2946
  background: ${surfaceBg}; backdrop-filter: blur(8px);
2729
2947
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08); scrollbar-width: none;
2730
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
2948
+ ${fontFamilyCss("body")}
2731
2949
  animation: aegisSlideInFromBottom 0.3s ease-out;
2732
2950
  ` : `
2733
2951
  display: flex; gap: 16px; align-items: flex-start; overflow-x: auto;
2734
2952
  padding: 12px 18px 12px 18px; scroll-padding-left: 18px;
2735
2953
  background: ${surfaceBg}; ${cfg.branded ? "border-radius: 16px;" : ""}
2736
2954
  scrollbar-width: none;
2737
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
2955
+ ${fontFamilyCss("body")}
2738
2956
  `;
2739
2957
  cfg.groups.forEach((g, i) => bar.appendChild(buildGroupBubble(ctx, cfg, g, i, labelColor)));
2740
2958
  if (floating) {
@@ -2855,7 +3073,7 @@ function openViewer(ctx, cfg, startGroupIndex, startFrameIndex = 0) {
2855
3073
  overlay.style.cssText = `
2856
3074
  position: fixed; inset: 0; z-index: 100000; background: #000;
2857
3075
  display: flex; align-items: center; justify-content: center;
2858
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
3076
+ ${fontFamilyCss("body")}
2859
3077
  animation: aegisFadeIn 0.25s ease;
2860
3078
  `;
2861
3079
  const stage = document.createElement("div");
@@ -2985,7 +3203,7 @@ function openViewer(ctx, cfg, startGroupIndex, startFrameIndex = 0) {
2985
3203
  if (f.title) {
2986
3204
  const t = document.createElement("div");
2987
3205
  t.textContent = f.title;
2988
- t.style.cssText = "font-family: 'Urbanist', system-ui, sans-serif; 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);";
3206
+ 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
3207
  copy.appendChild(t);
2990
3208
  }
2991
3209
  if (f.body) {
@@ -3151,7 +3369,7 @@ function openGameModal(ctx, className, maxWidth = 360) {
3151
3369
  const overlay = document.createElement("div");
3152
3370
  overlay.className = className;
3153
3371
  overlay.setAttribute("data-campaign-id", campaign.id);
3154
- 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;font-family:"Urbanist",system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;animation:aegisFadeIn 0.25s ease;';
3372
+ 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
3373
  const card = document.createElement("div");
3156
3374
  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
3375
  let removed = false;
@@ -3176,7 +3394,7 @@ function openGameModal(ctx, className, maxWidth = 360) {
3176
3394
  if (campaign.title) {
3177
3395
  const t = document.createElement("div");
3178
3396
  t.textContent = campaign.title;
3179
- t.style.cssText = "font-family:'Urbanist',system-ui,sans-serif;font-size:18px;font-weight:800;letter-spacing:-0.01em;margin:2px 24px 4px;line-height:1.25;";
3397
+ t.style.cssText = `${fontFamilyCss("display")}font-size:18px;font-weight:800;letter-spacing:-0.01em;margin:2px 24px 4px;line-height:1.25;`;
3180
3398
  card.appendChild(t);
3181
3399
  }
3182
3400
  if (campaign.body) {
@@ -3918,7 +4136,7 @@ function caption(ctx, accent, onCard) {
3918
4136
  if (campaign.title) {
3919
4137
  const t = document.createElement("div");
3920
4138
  t.textContent = campaign.title;
3921
- t.style.cssText = `font-family:'Urbanist',system-ui,sans-serif;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);" : ""}`;
4139
+ 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
4140
  box.appendChild(t);
3923
4141
  }
3924
4142
  if (campaign.body) {
@@ -3964,7 +4182,7 @@ function renderVideo(ctx) {
3964
4182
  const overlay = document.createElement("div");
3965
4183
  overlay.className = "aegis-in-app-video-overlay";
3966
4184
  overlay.setAttribute("data-campaign-id", campaign.id);
3967
- 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;font-family:"Urbanist",system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;animation:aegisFadeIn 0.25s ease;';
4185
+ 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
4186
  const card = document.createElement("div");
3969
4187
  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
4188
  const media = buildVideo(ctx, o.aspect, o.autoplay, o.loop);
@@ -4009,7 +4227,7 @@ function renderVideoInline(ctx, target) {
4009
4227
  const banner = document.createElement("div");
4010
4228
  banner.className = "aegis-in-app-video-banner";
4011
4229
  banner.setAttribute("data-campaign-id", ctx.campaign.id);
4012
- banner.style.cssText = 'width:100%;font-family:"Urbanist",system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;';
4230
+ banner.style.cssText = `width:100%;${fontFamilyCss("body")}`;
4013
4231
  const media = buildVideo(ctx, o.aspect, o.autoplay, o.loop);
4014
4232
  if (o.overlayCaption) {
4015
4233
  const c = caption(ctx, o.accent, true);
@@ -4031,6 +4249,13 @@ const ASPECT = { "16:9": "16 / 9", "4:3": "4 / 3", "21:9": "21 / 9" };
4031
4249
  const HERO_DESKTOP_RATIO = "8 / 3";
4032
4250
  const HERO_PHONE_RATIO = "1 / 1";
4033
4251
  const HERO_PHONE_MAX_WIDTH_PX = 767;
4252
+ const HERO_DESKTOP_SIZE = { width: 2400, height: 900 };
4253
+ const HERO_PHONE_SIZE = {
4254
+ "16:9": { width: 1920, height: 1080 },
4255
+ "4:3": { width: 1440, height: 1080 },
4256
+ "21:9": { width: 2520, height: 1080 },
4257
+ square: { width: 1080, height: 1080 }
4258
+ };
4034
4259
  function _injectHeroResponsiveCss() {
4035
4260
  if (typeof document === "undefined") return;
4036
4261
  if (document.getElementById("aegis-hero-style")) return;
@@ -4039,7 +4264,7 @@ function _injectHeroResponsiveCss() {
4039
4264
  style.textContent = `.aegis-hero-root{border-radius:16px;}.aegis-hero-auto{min-height:300px;}@media (max-width:${HERO_PHONE_MAX_WIDTH_PX}px){.aegis-hero-auto.aegis-hero-phone-square{min-height:0;aspect-ratio:${HERO_PHONE_RATIO};}}@media (min-width:${HERO_PHONE_MAX_WIDTH_PX + 1}px){.aegis-hero-root{border-radius:0;min-height:0;max-height:70vh;aspect-ratio:${HERO_DESKTOP_RATIO} !important;}}`;
4040
4265
  document.head.appendChild(style);
4041
4266
  }
4042
- function srcsetUrl(url) {
4267
+ function srcsetUrl$1(url) {
4043
4268
  return url.replace(/\s/g, "%20").replace(/,/g, "%2C");
4044
4269
  }
4045
4270
  function cardHeadline(c) {
@@ -4071,7 +4296,7 @@ function renderHeroInline(ctx, target) {
4071
4296
  if (variant === "announcement_bar") {
4072
4297
  const c = cards[0];
4073
4298
  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 13px/1.3 Inter,system-ui,sans-serif;text-align:center;`;
4299
+ 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
4300
  bar.textContent = [cardHeadline(c), cardSub(c)].filter(Boolean).join(" · ");
4076
4301
  const url = sanitizeUrl(cardUrl(c));
4077
4302
  if (url && cardCta(c)) {
@@ -4102,6 +4327,8 @@ function renderHeroInline(ctx, target) {
4102
4327
  track.style.cssText = "display:flex;height:100%;width:100%;transition:transform 0.5s ease;";
4103
4328
  root.appendChild(track);
4104
4329
  const overlayCss = chrome.overlay === "none" ? "" : chrome.overlay === "full-scrim" ? "background:linear-gradient(0deg,rgba(0,0,0,0.55),rgba(0,0,0,0.25));" : "background:linear-gradient(to top right,rgba(0,0,0,0.7),rgba(0,0,0,0.25) 45%,transparent);";
4330
+ const phoneSize = explicitRatio ? HERO_PHONE_SIZE[chrome.aspect_ratio] : hasPhoneImage ? HERO_PHONE_SIZE.square : void 0;
4331
+ const slideImgs = [];
4105
4332
  const justify = chrome.text_position === "center" ? "center" : "flex-end";
4106
4333
  const align = chrome.text_position === "bottom-left" || !chrome.text_position ? "flex-start" : "center";
4107
4334
  cards.forEach((c, i) => {
@@ -4109,7 +4336,7 @@ function renderHeroInline(ctx, target) {
4109
4336
  slide.style.cssText = "position:relative;flex:0 0 100%;width:100%;height:100%;min-height:inherit;background:#f1f5f9;";
4110
4337
  const videoUrl = c.video_url ? sanitizeUrl(c.video_url) ?? "" : "";
4111
4338
  const isVideo = !!videoUrl || c.media_type === "video";
4112
- const mediaUrl = isVideo ? videoUrl || sanitizeUrl(c.media_url ?? "") : sanitizeUrl(c.image_url ?? c.media_url ?? "") ?? (c.image_url_mobile ? sanitizeUrl(c.image_url_mobile) : null);
4339
+ const mediaUrl = isVideo ? videoUrl || sanitizeUrl(c.media_url ?? "") : sanitizeUrl(c.image_url || c.media_url || "") ?? (c.image_url_mobile ? sanitizeUrl(c.image_url_mobile) : null);
4113
4340
  if (mediaUrl) {
4114
4341
  if (isVideo) {
4115
4342
  const v = document.createElement("video");
@@ -4126,13 +4353,26 @@ function renderHeroInline(ctx, target) {
4126
4353
  if (phoneUrl) {
4127
4354
  const source = document.createElement("source");
4128
4355
  source.setAttribute("media", `(max-width:${HERO_PHONE_MAX_WIDTH_PX}px)`);
4129
- source.setAttribute("srcset", srcsetUrl(phoneUrl));
4356
+ source.setAttribute("srcset", srcsetUrl$1(phoneUrl));
4357
+ if (phoneSize) {
4358
+ source.setAttribute("width", String(phoneSize.width));
4359
+ source.setAttribute("height", String(phoneSize.height));
4360
+ }
4130
4361
  picture.appendChild(source);
4131
4362
  }
4132
4363
  const img = document.createElement("img");
4364
+ if (i === 0) {
4365
+ img.setAttribute("fetchpriority", "high");
4366
+ img.setAttribute("loading", "eager");
4367
+ } else {
4368
+ img.setAttribute("loading", "lazy");
4369
+ }
4370
+ img.setAttribute("width", String(HERO_DESKTOP_SIZE.width));
4371
+ img.setAttribute("height", String(HERO_DESKTOP_SIZE.height));
4133
4372
  img.src = mediaUrl;
4134
4373
  img.alt = "";
4135
- img.decoding = "async";
4374
+ img.setAttribute("decoding", "async");
4375
+ slideImgs[i] = img;
4136
4376
  img.style.cssText = "position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:center;display:block;";
4137
4377
  picture.appendChild(img);
4138
4378
  slide.appendChild(picture);
@@ -4149,14 +4389,14 @@ function renderHeroInline(ctx, target) {
4149
4389
  if (h) {
4150
4390
  const head = document.createElement("h2");
4151
4391
  head.textContent = h;
4152
- head.style.cssText = "margin:0;color:#fff;font:800 24px/1.2 Inter Tight,Inter,system-ui,sans-serif;letter-spacing:-0.02em;text-shadow:0 1px 8px rgba(0,0,0,0.35);max-width:90%;";
4392
+ 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
4393
  content.appendChild(head);
4154
4394
  }
4155
4395
  const s = cardSub(c);
4156
4396
  if (s) {
4157
4397
  const sub = document.createElement("p");
4158
4398
  sub.textContent = s;
4159
- sub.style.cssText = "margin:0;color:rgba(255,255,255,0.92);font:500 14px/1.4 Inter,system-ui,sans-serif;text-shadow:0 1px 6px rgba(0,0,0,0.3);max-width:90%;";
4399
+ 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
4400
  content.appendChild(sub);
4161
4401
  }
4162
4402
  const cta = cardCta(c);
@@ -4164,7 +4404,7 @@ function renderHeroInline(ctx, target) {
4164
4404
  if (cta && chrome.cta_style !== "none") {
4165
4405
  const btn = document.createElement("button");
4166
4406
  btn.textContent = cta;
4167
- btn.style.cssText = chrome.cta_style === "underline" ? `margin-top:6px;background:none;border:none;color:#fff;font:700 14px Inter,system-ui,sans-serif;text-decoration:underline;cursor:pointer;padding:0;` : `margin-top:8px;background:${accent};color:#fff;border:none;border-radius:999px;padding:9px 18px;font:700 13px Inter,system-ui,sans-serif;cursor:pointer;box-shadow:0 4px 12px rgba(0,0,0,0.2);`;
4407
+ 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
4408
  btn.addEventListener("click", () => {
4169
4409
  var _a;
4170
4410
  trackEvent(campaign.id, "clicked", { stepId: `card_${i}` });
@@ -4180,6 +4420,8 @@ function renderHeroInline(ctx, target) {
4180
4420
  const goto = (idx) => {
4181
4421
  activeIdx = (idx % cards.length + cards.length) % cards.length;
4182
4422
  track.style.transform = `translateX(-${activeIdx * 100}%)`;
4423
+ const next = slideImgs[(activeIdx + 1) % cards.length];
4424
+ if (next && next.getAttribute("loading") === "lazy") next.setAttribute("loading", "eager");
4183
4425
  dotEls.forEach((d, i) => {
4184
4426
  d.style.width = i === activeIdx ? "18px" : "6px";
4185
4427
  d.style.background = i === activeIdx ? accent : "rgba(255,255,255,0.7)";
@@ -4210,7 +4452,7 @@ function renderHeroInline(ctx, target) {
4210
4452
  trackEvent(campaign.id, "impression");
4211
4453
  return true;
4212
4454
  }
4213
- const STYLE_ID = "aegis-chat-styles";
4455
+ const STYLE_ID$1 = "aegis-chat-styles";
4214
4456
  const POLL_INTERVAL_MS = 5e3;
4215
4457
  let currentLauncher = null;
4216
4458
  function getCurrentLauncher() {
@@ -4904,15 +5146,15 @@ class AegisChat {
4904
5146
  if (this.debugMode) console.log("[AegisChat]", ...args);
4905
5147
  }
4906
5148
  injectStyles() {
4907
- if (typeof document === "undefined" || document.getElementById(STYLE_ID)) return;
5149
+ if (typeof document === "undefined" || document.getElementById(STYLE_ID$1)) return;
4908
5150
  const style = document.createElement("style");
4909
- style.id = STYLE_ID;
5151
+ style.id = STYLE_ID$1;
4910
5152
  style.textContent = CHAT_CSS;
4911
5153
  document.head.appendChild(style);
4912
5154
  }
4913
5155
  }
4914
5156
  const CHAT_CSS = `
4915
- .aegis-chat-root{position:fixed;bottom:20px;right:20px;z-index:2147483000;font-family:Inter,system-ui,-apple-system,sans-serif}
5157
+ .aegis-chat-root{position:fixed;bottom:20px;right:20px;z-index:2147483000;${fontFamilyCss("body")}}
4916
5158
  .aegis-chat-root--bottom-left{left:20px;right:auto}
4917
5159
  .aegis-chat-root--bottom-left .aegis-chat-panel{left:0;right:auto}
4918
5160
  .aegis-chat-bubble-logo{width:34px;height:34px;border-radius:9999px;object-fit:cover}
@@ -5783,7 +6025,6 @@ const SORTS = [
5783
6025
  ];
5784
6026
  function renderReviewsInline(ctx, target, creds) {
5785
6027
  if (typeof document === "undefined" || !(creds == null ? void 0 : creds.apiHost) || !(creds == null ? void 0 : creds.writeKey)) return false;
5786
- ensureInAppFont();
5787
6028
  const ic = ctx.campaign.interactive_config || {};
5788
6029
  const cfg = target.closest("[data-aegis-slot]") ?? target;
5789
6030
  const accent = ctx.sanitizeColor(
@@ -5794,7 +6035,7 @@ function renderReviewsInline(ctx, target, creds) {
5794
6035
  const productId = cfg.getAttribute("data-product-id") || ctx.campaign.product_id || null;
5795
6036
  const state = { sort: "recent", withPhotos: false };
5796
6037
  target.innerHTML = "";
5797
- target.appendChild(el("div", `font-family:${IN_APP_FONT_STACK};font-size:13px;color:#9ca3af;padding:10px 0;`, "Loading reviews…"));
6038
+ target.appendChild(el("div", `${fontFamilyCss("body")}font-size:13px;color:#9ca3af;padding:10px 0;`, "Loading reviews…"));
5798
6039
  function buildUrl() {
5799
6040
  const url = new URL("/v1/reviews/public", creds.apiHost);
5800
6041
  if (productId) url.searchParams.set("product_id", productId);
@@ -5960,7 +6201,7 @@ function renderReviewsInline(ctx, target, creds) {
5960
6201
  target.innerHTML = "";
5961
6202
  const root = el(
5962
6203
  "section",
5963
- `font-family:${IN_APP_FONT_STACK};color:#111827;max-width:860px;margin:0 auto;-webkit-font-smoothing:antialiased;`
6204
+ `${fontFamilyCss("body")}color:#111827;max-width:860px;margin:0 auto;-webkit-font-smoothing:antialiased;`
5964
6205
  );
5965
6206
  root.setAttribute("data-aegis-reviews", "true");
5966
6207
  const summary = data.aggregate.ai_summary;
@@ -5998,7 +6239,7 @@ function renderReviewsInline(ctx, target, creds) {
5998
6239
  if (data.aggregate.count === 0) return;
5999
6240
  const root = el(
6000
6241
  "section",
6001
- `font-family:${IN_APP_FONT_STACK};color:#111827;max-width:860px;margin:0 auto;border:1px solid #f0f1f3;border-radius:16px;padding:16px 18px;`
6242
+ `${fontFamilyCss("body")}color:#111827;max-width:860px;margin:0 auto;border:1px solid #f0f1f3;border-radius:16px;padding:16px 18px;`
6002
6243
  );
6003
6244
  const line = el("div", "display:flex;align-items:center;gap:8px;");
6004
6245
  const avg = data.aggregate.avg_rating ?? 0;
@@ -6030,12 +6271,11 @@ function renderReviewsInline(ctx, target, creds) {
6030
6271
  }
6031
6272
  function renderReviewsOverlay(ctx, creds) {
6032
6273
  if (typeof document === "undefined" || !(creds == null ? void 0 : creds.apiHost) || !(creds == null ? void 0 : creds.writeKey)) return;
6033
- ensureInAppFont();
6034
6274
  const overlay = document.createElement("div");
6035
6275
  overlay.setAttribute("data-campaign-id", ctx.campaign.id);
6036
6276
  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
6277
  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;font-family:${IN_APP_FONT_STACK};box-shadow:0 -16px 40px rgba(0,0,0,0.14);`;
6278
+ 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
6279
  sheet.appendChild(el("div", "width:38px;height:4px;border-radius:999px;background:#e5e7eb;margin:0 auto 14px;"));
6040
6280
  const bar = el("div", "display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;");
6041
6281
  bar.appendChild(el("div", "font-weight:800;font-size:17px;", ctx.campaign.title || "Customer reviews"));
@@ -6389,6 +6629,225 @@ function pageUrlRulesPass(rules, pageUrl) {
6389
6629
  }
6390
6630
  return true;
6391
6631
  }
6632
+ function anchorSelector(c) {
6633
+ var _a, _b;
6634
+ const sel = (_b = (_a = c.interactive_config) == null ? void 0 : _a.anchor) == null ? void 0 : _b.element_selector;
6635
+ return typeof sel === "string" && sel.trim() ? sel : null;
6636
+ }
6637
+ function declaredRotateMs(members) {
6638
+ return members.reduce((m2, c) => {
6639
+ var _a;
6640
+ const v = Number((_a = c.interactive_config) == null ? void 0 : _a.slot_rotate_ms);
6641
+ return Number.isFinite(v) && v > m2 ? v : m2;
6642
+ }, 0);
6643
+ }
6644
+ function pickSlotWinners(campaigns, opts = {}) {
6645
+ const groups = /* @__PURE__ */ new Map();
6646
+ const seen = /* @__PURE__ */ new Set();
6647
+ for (const c of campaigns) {
6648
+ if (opts.isPlaceable && !opts.isPlaceable(c)) continue;
6649
+ const modes = c.delivery_modes;
6650
+ if (!Array.isArray(modes) || !modes.includes("embedded_card")) continue;
6651
+ const slot = c.widget_category;
6652
+ if (!slot) continue;
6653
+ const sel = anchorSelector(c);
6654
+ if (sel !== null && opts.anchorResolves && opts.anchorResolves(sel)) continue;
6655
+ if (seen.has(c.id)) continue;
6656
+ seen.add(c.id);
6657
+ const arr2 = groups.get(slot);
6658
+ if (arr2) arr2.push(c);
6659
+ else groups.set(slot, [c]);
6660
+ }
6661
+ const out = [];
6662
+ groups.forEach((members, slot) => {
6663
+ out.push({ slot, members, declaredRotateMs: declaredRotateMs(members) });
6664
+ });
6665
+ return out;
6666
+ }
6667
+ const STORAGE_PREFIX = "aegis_slot_shapes:v2:";
6668
+ const SHAPE_CACHE_TTL_MS = 6 * 60 * 60 * 1e3;
6669
+ const PHONE_MAX_WIDTH_PX = 767;
6670
+ const STYLE_ID = "aegis-slot-shell-style";
6671
+ const SHELL_SELECTOR = ":scope > [data-aegis-slot-shell]";
6672
+ const LAYOUTS = /* @__PURE__ */ new Set(["hero", "rail", "grid", "bar", "card"]);
6673
+ function storageKey(ctx) {
6674
+ return `${STORAGE_PREFIX}${ctx.propertyId || "-"}:${ctx.surface || "-"}:${ctx.screen || "-"}:${ctx.locationId || "-"}`;
6675
+ }
6676
+ function cssAspect(v) {
6677
+ if (typeof v !== "string") return null;
6678
+ const m2 = v.trim().match(/^(\d+(?:\.\d+)?)\s*[/:]\s*(\d+(?:\.\d+)?)$/);
6679
+ if (!m2 || Number(m2[1]) <= 0 || Number(m2[2]) <= 0) return null;
6680
+ return `${m2[1]} / ${m2[2]}`;
6681
+ }
6682
+ function cssLength(v) {
6683
+ if (typeof v === "number" && Number.isFinite(v) && v > 0) return `${Math.round(v)}px`;
6684
+ if (typeof v !== "string") return null;
6685
+ const s = v.trim();
6686
+ if (/^\d+(\.\d+)?$/.test(s)) return `${s}px`;
6687
+ return /^\d+(\.\d+)?(px|rem|em|vh|svh|dvh|%)$/.test(s) ? s : null;
6688
+ }
6689
+ function isShape(v) {
6690
+ if (!v || typeof v !== "object") return false;
6691
+ const o = v;
6692
+ return typeof o.slot === "string" && !!o.slot && typeof o.layout === "string" && LAYOUTS.has(o.layout);
6693
+ }
6694
+ function toShapeMap(list) {
6695
+ const out = /* @__PURE__ */ new Map();
6696
+ const arr2 = Array.isArray(list) ? list : list && typeof list === "object" && Array.isArray(list.shapes) ? list.shapes : [];
6697
+ for (const s of arr2) if (isShape(s) && !out.has(s.slot)) out.set(s.slot, s);
6698
+ return out;
6699
+ }
6700
+ function readInlineShapes(doc = document) {
6701
+ const out = /* @__PURE__ */ new Map();
6702
+ doc.querySelectorAll("[data-aegis-slot-shapes]").forEach((el2) => {
6703
+ try {
6704
+ toShapeMap(JSON.parse(el2.textContent || "null")).forEach((s, k) => {
6705
+ if (!out.has(k)) out.set(k, s);
6706
+ });
6707
+ } catch {
6708
+ }
6709
+ });
6710
+ return out;
6711
+ }
6712
+ function readCachedShapes(ctx, now = Date.now()) {
6713
+ try {
6714
+ if (typeof localStorage === "undefined") return /* @__PURE__ */ new Map();
6715
+ const raw = localStorage.getItem(storageKey(ctx));
6716
+ if (!raw) return /* @__PURE__ */ new Map();
6717
+ const parsed = JSON.parse(raw);
6718
+ if (typeof (parsed == null ? void 0 : parsed.t) !== "number" || now - parsed.t > SHAPE_CACHE_TTL_MS || parsed.t > now + 6e4) {
6719
+ return /* @__PURE__ */ new Map();
6720
+ }
6721
+ return toShapeMap(parsed.shapes);
6722
+ } catch {
6723
+ return /* @__PURE__ */ new Map();
6724
+ }
6725
+ }
6726
+ function saveShapes(ctx, shapes, now = Date.now()) {
6727
+ try {
6728
+ if (typeof localStorage === "undefined") return;
6729
+ localStorage.setItem(storageKey(ctx), JSON.stringify({ t: now, shapes }));
6730
+ } catch {
6731
+ }
6732
+ }
6733
+ function attributeShape(slot) {
6734
+ const key = slot.getAttribute("data-aegis-slot");
6735
+ if (!key) return null;
6736
+ const aspect = cssAspect(slot.getAttribute("data-aegis-slot-aspect"));
6737
+ const minH = cssLength(slot.getAttribute("data-aegis-slot-min-height"));
6738
+ if (!aspect && !minH) return null;
6739
+ return { slot: key, layout: "card", aspect, min_height: minH };
6740
+ }
6741
+ function injectShellCss(doc) {
6742
+ if (doc.getElementById(STYLE_ID)) return;
6743
+ const style = doc.createElement("style");
6744
+ style.id = STYLE_ID;
6745
+ style.textContent = `[data-aegis-slot-shell]{position:relative;display:block;box-sizing:border-box;width:100%;overflow:hidden;border-radius:12px;background:#f1f5f9;aspect-ratio:var(--aegis-shell-ar,auto);min-height:var(--aegis-shell-min-h,0px);max-height:var(--aegis-shell-max-h,none);}@media (min-width:${PHONE_MAX_WIDTH_PX + 1}px){[data-aegis-slot-shell]{max-height:var(--aegis-shell-max-h-desktop,var(--aegis-shell-max-h,none));}}@media (max-width:${PHONE_MAX_WIDTH_PX}px){[data-aegis-slot-shell]{aspect-ratio:var(--aegis-shell-ar-phone,var(--aegis-shell-ar,auto));min-height:var(--aegis-shell-min-h-phone,var(--aegis-shell-min-h,0px));}}[data-aegis-slot-shell="hero"]{border-radius:16px;}@media (min-width:${PHONE_MAX_WIDTH_PX + 1}px){[data-aegis-slot-shell="hero"]{border-radius:0;}}[data-aegis-slot-shell] img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:center;display:block;}@keyframes aegis-shell-pulse{0%,100%{opacity:1}50%{opacity:.6}}@media (prefers-reduced-motion:no-preference){[data-aegis-slot-shell]:not([data-aegis-shell-has-image]){animation:aegis-shell-pulse 1.6s ease-in-out infinite;}}`;
6746
+ (doc.head || doc.documentElement).appendChild(style);
6747
+ }
6748
+ function srcsetUrl(url) {
6749
+ return url.replace(/\s/g, "%20").replace(/,/g, "%2C");
6750
+ }
6751
+ function safeHttpUrl(v) {
6752
+ var _a;
6753
+ if (typeof v !== "string" || !v) return null;
6754
+ try {
6755
+ const base = typeof window !== "undefined" && ((_a = window.location) == null ? void 0 : _a.origin) ? window.location.origin : "https://x.invalid";
6756
+ const u = new URL(v, `${base}/`);
6757
+ return u.protocol === "https:" || u.protocol === "http:" ? u.href : null;
6758
+ } catch {
6759
+ return null;
6760
+ }
6761
+ }
6762
+ function buildShell(doc, shape) {
6763
+ const el2 = doc.createElement("div");
6764
+ el2.setAttribute("data-aegis-slot-shell", shape.layout);
6765
+ el2.setAttribute("data-aegis-shell-owner", "sdk");
6766
+ el2.setAttribute("aria-hidden", "true");
6767
+ const ar = cssAspect(shape.aspect ?? null);
6768
+ if (ar) el2.style.setProperty("--aegis-shell-ar", ar);
6769
+ if (shape.layout === "hero") {
6770
+ const phone = cssAspect(shape.aspect_phone ?? null);
6771
+ el2.style.setProperty("--aegis-shell-ar-phone", phone ?? "auto");
6772
+ const phoneMin = phone ? null : cssLength(shape.min_height ?? null);
6773
+ if (phoneMin) el2.style.setProperty("--aegis-shell-min-h-phone", phoneMin);
6774
+ } else {
6775
+ const minH = cssLength(shape.min_height ?? null);
6776
+ if (minH) el2.style.setProperty("--aegis-shell-min-h", minH);
6777
+ }
6778
+ const maxH = cssLength(shape.max_height ?? null);
6779
+ if (maxH) {
6780
+ el2.style.setProperty(shape.layout === "hero" ? "--aegis-shell-max-h-desktop" : "--aegis-shell-max-h", maxH);
6781
+ }
6782
+ const img = shape.layout === "hero" ? shape.image : null;
6783
+ const src = img ? safeHttpUrl(img.src) : null;
6784
+ if (img && src) {
6785
+ const picture = doc.createElement("picture");
6786
+ const phoneSrc = safeHttpUrl(img.src_phone ?? null);
6787
+ if (phoneSrc) {
6788
+ const source = doc.createElement("source");
6789
+ source.setAttribute("media", `(max-width:${PHONE_MAX_WIDTH_PX}px)`);
6790
+ source.setAttribute("srcset", srcsetUrl(phoneSrc));
6791
+ picture.appendChild(source);
6792
+ }
6793
+ const im = doc.createElement("img");
6794
+ im.setAttribute("fetchpriority", "high");
6795
+ im.setAttribute("decoding", "async");
6796
+ im.alt = img.alt || "";
6797
+ if (img.width && img.height) {
6798
+ im.setAttribute("width", String(img.width));
6799
+ im.setAttribute("height", String(img.height));
6800
+ }
6801
+ im.src = src;
6802
+ picture.appendChild(im);
6803
+ el2.appendChild(picture);
6804
+ el2.setAttribute("data-aegis-shell-has-image", "");
6805
+ }
6806
+ return el2;
6807
+ }
6808
+ function removeSlotShell(slot) {
6809
+ slot.querySelectorAll(SHELL_SELECTOR).forEach((n) => n.remove());
6810
+ }
6811
+ function collapseUnfilledShells(slots, winners) {
6812
+ Array.prototype.forEach.call(slots, (slot) => {
6813
+ const key = slot.getAttribute("data-aegis-slot");
6814
+ const list = key ? winners.get(key) : void 0;
6815
+ if (!list || list.length === 0) removeSlotShell(slot);
6816
+ });
6817
+ }
6818
+ function removeAllShells(doc = document, opts = {}) {
6819
+ doc.querySelectorAll("[data-aegis-slot]").forEach((slot) => {
6820
+ slot.querySelectorAll(SHELL_SELECTOR).forEach((n) => {
6821
+ if (!opts.sdkOnly || n.getAttribute("data-aegis-shell-owner") === "sdk") n.remove();
6822
+ });
6823
+ });
6824
+ }
6825
+ function drawSlotShells(ctx, doc = document) {
6826
+ const slots = doc.querySelectorAll("[data-aegis-slot]");
6827
+ if (slots.length === 0) return 0;
6828
+ const inline = readInlineShapes(doc);
6829
+ const inlinePrinted = doc.querySelectorAll("[data-aegis-slot-shapes]").length > 0;
6830
+ let cached = null;
6831
+ let drawn = 0;
6832
+ slots.forEach((slot) => {
6833
+ if (slot.childElementCount > 0) return;
6834
+ const key = slot.getAttribute("data-aegis-slot");
6835
+ if (!key) return;
6836
+ let shape = inline.get(key) ?? null;
6837
+ if (shape && shape.may_be_empty) shape = null;
6838
+ if (!shape) shape = attributeShape(slot);
6839
+ if (!shape && !inlinePrinted) {
6840
+ if (cached === null) cached = readCachedShapes(ctx);
6841
+ const c = cached.get(key) ?? null;
6842
+ shape = c && !c.may_be_empty ? c : null;
6843
+ }
6844
+ if (!shape) return;
6845
+ injectShellCss(doc);
6846
+ slot.appendChild(buildShell(doc, shape));
6847
+ drawn += 1;
6848
+ });
6849
+ return drawn;
6850
+ }
6392
6851
  const RETURNING_MARKER_KEY = "aegis_returning_user";
6393
6852
  const SESSION_VERDICT_KEY = "aegis_new_visitor_session";
6394
6853
  let cachedVerdict = null;
@@ -6584,6 +7043,8 @@ const _AegisInAppManager = class _AegisInAppManager {
6584
7043
  this.slotObserver = null;
6585
7044
  this.slotRenderScheduled = false;
6586
7045
  this.slotsTornDown = false;
7046
+ this.campaignsLoaded = false;
7047
+ this.shellTimeout = null;
6587
7048
  this.lifecycleGen = 0;
6588
7049
  this.slotUnfilledBeaconed = /* @__PURE__ */ new Set();
6589
7050
  this.slotUnfilledSweepTimer = null;
@@ -6603,6 +7064,12 @@ const _AegisInAppManager = class _AegisInAppManager {
6603
7064
  if (config.productUrl) this.productUrl = config.productUrl;
6604
7065
  this.getWorkspaceId = config.getWorkspaceId;
6605
7066
  this.getCartState = config.getCartState;
7067
+ if (config.surface && _AegisInAppManager.KNOWN_SURFACES.has(config.surface)) {
7068
+ this.currentSurface = config.surface;
7069
+ }
7070
+ const screen = config.screen || config.surface;
7071
+ if (screen && screen !== "page_view") this.currentScreen = screen;
7072
+ if (config.locationId) this.currentLocationId = config.locationId;
6606
7073
  }
6607
7074
  emit(eventName, payload) {
6608
7075
  const handlers = this.hooks.get(eventName);
@@ -6704,7 +7171,8 @@ const _AegisInAppManager = class _AegisInAppManager {
6704
7171
  }
6705
7172
  } catch {
6706
7173
  }
6707
- ensureInAppFont();
7174
+ applyRootFonts(null);
7175
+ this.drawShells();
6708
7176
  await this.refreshCampaigns();
6709
7177
  if (this.enableSSE && this.organizationId) {
6710
7178
  this.connectSSE();
@@ -6712,8 +7180,10 @@ const _AegisInAppManager = class _AegisInAppManager {
6712
7180
  this.isInitialized = true;
6713
7181
  if (this.pendingPreInitRefresh) {
6714
7182
  this.pendingPreInitRefresh = false;
6715
- this.log("Re-fetching campaigns for surface/screen declared during init");
6716
- void this.refreshCampaigns();
7183
+ if (this.activeRequestKey() !== this.lastActiveRequestKey) {
7184
+ this.log("Re-fetching campaigns for surface/screen declared during init");
7185
+ void this.refreshCampaigns();
7186
+ }
6717
7187
  }
6718
7188
  if (typeof Notification !== "undefined" && Notification.permission === "granted" && this.propertyId) {
6719
7189
  let alreadyHealed = false;
@@ -6820,6 +7290,11 @@ const _AegisInAppManager = class _AegisInAppManager {
6820
7290
  }
6821
7291
  this.refreshCampaigns();
6822
7292
  }
7293
+ /** The page context a `/v1/in-app/active` request is built from now. */
7294
+ activeRequestKey() {
7295
+ const url = this.currentPageUrl() ?? "/";
7296
+ return [url, this.currentSurface ?? "", this.currentScreen ?? "", this.currentLocationId ?? ""].join("|");
7297
+ }
6823
7298
  /**
6824
7299
  * Qualifying-event refresh — schedule a debounced `refreshCampaigns()`
6825
7300
  * call in response to a host-app SDK event (`aegis.page()`,
@@ -6863,6 +7338,10 @@ const _AegisInAppManager = class _AegisInAppManager {
6863
7338
  this.log(`refreshOnEvent(${eventName}) before initialize — surface captured, refetch deferred to initialize()`);
6864
7339
  return;
6865
7340
  }
7341
+ if (isScreenDeclaration && this.lastActiveRequestKey !== void 0 && this.activeRequestKey() === this.lastActiveRequestKey) {
7342
+ this.log(`refreshOnEvent(${eventName}) — page context unchanged, no refetch`);
7343
+ return;
7344
+ }
6866
7345
  if (this.refreshDebounceTimer) {
6867
7346
  clearTimeout(this.refreshDebounceTimer);
6868
7347
  }
@@ -7109,6 +7588,7 @@ const _AegisInAppManager = class _AegisInAppManager {
7109
7588
  }
7110
7589
  async refreshCampaigns() {
7111
7590
  const gen = this.lifecycleGen;
7591
+ let requestKey;
7112
7592
  try {
7113
7593
  const context = new URLSearchParams({
7114
7594
  device_type: this.detectDeviceType(),
@@ -7127,6 +7607,9 @@ const _AegisInAppManager = class _AegisInAppManager {
7127
7607
  context.set("location_id", this.currentLocationId);
7128
7608
  }
7129
7609
  const url = `${this.apiHost}/v1/in-app/active?${context.toString()}`;
7610
+ requestKey = this.activeRequestKey();
7611
+ this.lastActiveRequestKey = requestKey;
7612
+ const shellCtx = this.shellContext();
7130
7613
  const headers = {
7131
7614
  "X-Aegis-Write-Key": this.writeKey,
7132
7615
  "Content-Type": "application/json"
@@ -7162,6 +7645,10 @@ const _AegisInAppManager = class _AegisInAppManager {
7162
7645
  const payload = await response.json();
7163
7646
  if (gen !== this.lifecycleGen) return;
7164
7647
  this.campaigns = Array.isArray(payload) ? payload : [];
7648
+ this.campaignsLoaded = true;
7649
+ this.campaignsRequestKey = requestKey;
7650
+ this.clearShellTimeout();
7651
+ applyCampaignFonts(this.campaigns);
7165
7652
  this.processABAssignments(this.campaigns);
7166
7653
  this.rehydrateSuppressionFromStorage();
7167
7654
  this.log(`Fetched ${this.campaigns.length} campaigns`);
@@ -7171,10 +7658,15 @@ const _AegisInAppManager = class _AegisInAppManager {
7171
7658
  this.mountPersistentLaunchers();
7172
7659
  this.tryDisplayNextCampaign();
7173
7660
  this.renderIntoSlots();
7661
+ this.saveSlotShapes(shellCtx);
7174
7662
  this.renderIntoAnchors();
7175
7663
  this.renderTokenAnchors();
7176
7664
  } catch (error) {
7665
+ if (requestKey !== void 0 && this.lastActiveRequestKey === requestKey) {
7666
+ this.lastActiveRequestKey = void 0;
7667
+ }
7177
7668
  if (gen !== this.lifecycleGen) return;
7669
+ if (!this.campaignsLoaded) this.removeShells();
7178
7670
  this.emitError(error, { stage: "refresh-campaigns" });
7179
7671
  this.log(`Error refreshing campaigns: ${error}`, "error");
7180
7672
  }
@@ -7325,6 +7817,70 @@ const _AegisInAppManager = class _AegisInAppManager {
7325
7817
  isPlaceableHere(c) {
7326
7818
  return this.matchesCurrentScreenOrSurface(c) && pageUrlRulesPass(c, this.currentPageUrl());
7327
7819
  }
7820
+ /** Does an operator element anchor resolve on this page? (An invalid
7821
+ * selector does not.) */
7822
+ anchorResolvesHere(sel) {
7823
+ if (typeof document === "undefined") return false;
7824
+ try {
7825
+ return !!document.querySelector(sel);
7826
+ } catch {
7827
+ return false;
7828
+ }
7829
+ }
7830
+ /** Shell storage key parts: this property + the declared surface/screen. */
7831
+ shellContext() {
7832
+ return {
7833
+ propertyId: this.propertyId ?? null,
7834
+ surface: this.currentSurface,
7835
+ screen: this.currentScreen,
7836
+ locationId: this.currentLocationId ?? null
7837
+ };
7838
+ }
7839
+ drawShells() {
7840
+ if (typeof document === "undefined" || this.slotsTornDown || this.campaignsLoaded) return;
7841
+ try {
7842
+ if (drawSlotShells(this.shellContext()) > 0 && !this.shellTimeout) {
7843
+ this.shellTimeout = setTimeout(() => {
7844
+ this.shellTimeout = null;
7845
+ if (!this.campaignsLoaded) this.removeShells();
7846
+ }, _AegisInAppManager.SHELL_TIMEOUT_MS);
7847
+ }
7848
+ } catch (err) {
7849
+ this.log(`slot shells skipped: ${err}`, "warn");
7850
+ }
7851
+ }
7852
+ clearShellTimeout() {
7853
+ if (this.shellTimeout) {
7854
+ clearTimeout(this.shellTimeout);
7855
+ this.shellTimeout = null;
7856
+ }
7857
+ }
7858
+ removeShells(opts = {}) {
7859
+ this.clearShellTimeout();
7860
+ if (typeof document === "undefined") return;
7861
+ try {
7862
+ removeAllShells(document, opts);
7863
+ } catch (err) {
7864
+ this.log(`slot shell cleanup skipped: ${err}`, "warn");
7865
+ }
7866
+ }
7867
+ /** Save the winners' shapes for the next visit to this page context. Every
7868
+ * winner of the response counts, on this page or not; a slot absent from
7869
+ * the save will not fill (no shell next time). */
7870
+ saveSlotShapes(ctx) {
7871
+ const shapes = [];
7872
+ const winners = pickSlotWinners(this.campaigns, {
7873
+ isPlaceable: (c) => this.isPlaceableHere(c),
7874
+ anchorResolves: (sel) => this.anchorResolvesHere(sel)
7875
+ });
7876
+ for (const g of winners) {
7877
+ const shape = g.members[0].slot_shape;
7878
+ if (!shape || typeof shape !== "object") continue;
7879
+ const rotating = g.declaredRotateMs > 0 && g.members.length > 1;
7880
+ shapes.push(rotating ? { ...shape, rotate_count: g.members.length } : shape);
7881
+ }
7882
+ saveShapes(ctx, shapes);
7883
+ }
7328
7884
  /** Remove everything this manager injected into `slot` and stop its rotation. */
7329
7885
  clearSlotContent(slot) {
7330
7886
  const timer = this.slotTimers.get(slot);
@@ -7371,7 +7927,6 @@ const _AegisInAppManager = class _AegisInAppManager {
7371
7927
  this.slotObserver.observe(document.body, { childList: true, subtree: true });
7372
7928
  }
7373
7929
  renderIntoSlots() {
7374
- var _a, _b;
7375
7930
  if (typeof document === "undefined" || this.slotsTornDown) return;
7376
7931
  this.ensureSlotObserver();
7377
7932
  this.scheduleSlotUnfilledSweep();
@@ -7386,28 +7941,16 @@ const _AegisInAppManager = class _AegisInAppManager {
7386
7941
  const slots = document.querySelectorAll("[data-aegis-slot]");
7387
7942
  if (slots.length === 0) return;
7388
7943
  const eligibleByCategory = /* @__PURE__ */ new Map();
7389
- const seenIds = /* @__PURE__ */ new Set();
7390
- for (const c of this.campaigns) {
7391
- if (!this.isPlaceableHere(c)) continue;
7392
- const modes = c.delivery_modes;
7393
- const category = c.widget_category;
7394
- if (!modes || !modes.includes("embedded_card")) continue;
7395
- if (!category) continue;
7396
- const anchorSel = (_b = (_a = c.interactive_config) == null ? void 0 : _a.anchor) == null ? void 0 : _b.element_selector;
7397
- if (typeof anchorSel === "string" && anchorSel.trim()) {
7398
- let anchorResolves = false;
7399
- try {
7400
- anchorResolves = !!document.querySelector(anchorSel);
7401
- } catch {
7402
- anchorResolves = false;
7403
- }
7404
- if (anchorResolves) continue;
7405
- }
7406
- if (seenIds.has(c.id)) continue;
7407
- seenIds.add(c.id);
7408
- const arr2 = eligibleByCategory.get(category);
7409
- if (arr2) arr2.push(c);
7410
- else eligibleByCategory.set(category, [c]);
7944
+ const declaredRotate = /* @__PURE__ */ new Map();
7945
+ for (const g of pickSlotWinners(this.campaigns, {
7946
+ isPlaceable: (c) => this.isPlaceableHere(c),
7947
+ anchorResolves: (sel) => this.anchorResolvesHere(sel)
7948
+ })) {
7949
+ eligibleByCategory.set(g.slot, g.members);
7950
+ declaredRotate.set(g.slot, g.declaredRotateMs);
7951
+ }
7952
+ if (this.campaignsLoaded && this.campaignsRequestKey === this.activeRequestKey()) {
7953
+ collapseUnfilledShells(slots, eligibleByCategory);
7411
7954
  }
7412
7955
  if (eligibleByCategory.size === 0) return;
7413
7956
  slots.forEach((slot) => {
@@ -7416,11 +7959,7 @@ const _AegisInAppManager = class _AegisInAppManager {
7416
7959
  const list = eligibleByCategory.get(key);
7417
7960
  if (!list || list.length === 0) return;
7418
7961
  const attrMs = parseInt(slot.getAttribute("data-aegis-slot-rotate") || "0", 10);
7419
- const declaredMs = list.reduce((m2, c) => {
7420
- var _a2;
7421
- const v = Number((_a2 = c.interactive_config) == null ? void 0 : _a2.slot_rotate_ms);
7422
- return Number.isFinite(v) && v > m2 ? v : m2;
7423
- }, 0);
7962
+ const declaredMs = declaredRotate.get(key) ?? 0;
7424
7963
  const rotateMs = attrMs > 0 ? attrMs : declaredMs;
7425
7964
  const rotating = rotateMs > 0 && list.length > 1;
7426
7965
  const shown = rotating ? list : list.slice(0, 1);
@@ -7430,6 +7969,7 @@ const _AegisInAppManager = class _AegisInAppManager {
7430
7969
  this.slotSignatures.set(slot, sig);
7431
7970
  this.renderedSlots.add(slot);
7432
7971
  slot.querySelectorAll(":scope > [data-aegis-slot-default]").forEach((d) => d.remove());
7972
+ removeSlotShell(slot);
7433
7973
  const flush = slot.hasAttribute("data-aegis-slot-flush");
7434
7974
  if (rotating) {
7435
7975
  this.renderRotatingSlot(slot, list, rotateMs, flush);
@@ -8422,7 +8962,7 @@ const _AegisInAppManager = class _AegisInAppManager {
8422
8962
  body.style.cssText = `padding: ${st.padY ?? 22}px ${st.padX ?? 20}px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px;`;
8423
8963
  if (campaign.title) {
8424
8964
  const t = document.createElement("div");
8425
- t.style.cssText = `font-size: 18px; font-weight: 800; letter-spacing: -0.01em; text-align: center; font-family: 'Urbanist', system-ui, -apple-system, sans-serif;`;
8965
+ t.style.cssText = `font-size: 18px; font-weight: 800; letter-spacing: -0.01em; text-align: center; ${fontFamilyCss("display")}`;
8426
8966
  t.textContent = campaign.title;
8427
8967
  body.appendChild(t);
8428
8968
  }
@@ -8522,7 +9062,7 @@ const _AegisInAppManager = class _AegisInAppManager {
8522
9062
  }
8523
9063
  const tx = document.createElement("span");
8524
9064
  tx.textContent = label;
8525
- tx.style.cssText = `white-space: nowrap; line-height: 1.05; font-size: ${fontPx}px; font-weight: 900; font-family: 'Urbanist', system-ui, -apple-system, sans-serif; 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;`;
9065
+ 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
9066
  lab.appendChild(tx);
8527
9067
  wheel.appendChild(lab);
8528
9068
  });
@@ -8575,7 +9115,7 @@ const _AegisInAppManager = class _AegisInAppManager {
8575
9115
  }
8576
9116
  const btn = document.createElement("button");
8577
9117
  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; font-family: 'Urbanist', system-ui, -apple-system, sans-serif;`;
9118
+ 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
9119
  btn.addEventListener("mouseenter", () => {
8580
9120
  if (btn.disabled) return;
8581
9121
  btn.style.transform = "translateY(-1px)";
@@ -8672,7 +9212,7 @@ const _AegisInAppManager = class _AegisInAppManager {
8672
9212
  eyebrow.style.cssText = "font-size: 13px; font-weight: 700; letter-spacing: 0.3px; opacity: 0.8;";
8673
9213
  const big = document.createElement("div");
8674
9214
  big.textContent = r.label;
8675
- big.style.cssText = `font-size: 24px; font-weight: 900; letter-spacing: -0.02em; font-family: 'Urbanist', system-ui, -apple-system, sans-serif;`;
9215
+ big.style.cssText = `font-size: 24px; font-weight: 900; letter-spacing: -0.02em; ${fontFamilyCss("display")}`;
8676
9216
  ov.appendChild(eyebrow);
8677
9217
  ov.appendChild(big);
8678
9218
  if (r.code) {
@@ -9245,7 +9785,7 @@ const _AegisInAppManager = class _AegisInAppManager {
9245
9785
  eb.style.cssText = "font-size: 12px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; opacity: 0.7;";
9246
9786
  const big = document.createElement("div");
9247
9787
  big.textContent = label;
9248
- big.style.cssText = `font-size: 22px; font-weight: 900; letter-spacing: -0.02em; font-family: 'Urbanist', system-ui, sans-serif;`;
9788
+ big.style.cssText = `font-size: 22px; font-weight: 900; letter-spacing: -0.02em; ${fontFamilyCss("display")}`;
9249
9789
  ov.appendChild(eb);
9250
9790
  ov.appendChild(big);
9251
9791
  if (code) {
@@ -9827,7 +10367,7 @@ const _AegisInAppManager = class _AegisInAppManager {
9827
10367
  iframe.style.cssText = `width: 100%; height: ${height}px; border: none; display: block; background: #fff; transform: translateZ(0); backface-visibility: hidden;`;
9828
10368
  iframe.title = campaign.title || "In-app content";
9829
10369
  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:system-ui,-apple-system,sans-serif;}</style>" + shim + "</head><body>" + html + "</body></html>";
10370
+ 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
10371
  const onMsg = (e) => {
9832
10372
  if (e.source !== iframe.contentWindow) return;
9833
10373
  const d = e.data;
@@ -10372,7 +10912,7 @@ const _AegisInAppManager = class _AegisInAppManager {
10372
10912
  };
10373
10913
  const heading = (txt, big = false) => {
10374
10914
  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; font-family: 'Urbanist', system-ui, -apple-system, sans-serif;`;
10915
+ 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
10916
  t.textContent = txt;
10377
10917
  return t;
10378
10918
  };
@@ -10787,7 +11327,7 @@ const _AegisInAppManager = class _AegisInAppManager {
10787
11327
  display: flex;
10788
11328
  align-items: center;
10789
11329
  justify-content: space-between;
10790
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
11330
+ ${fontFamilyCss("body")}
10791
11331
  animation: ${atBottom ? "aegisSlideInFromBottom" : "aegisSlideDown"} 0.3s ease-out;
10792
11332
  `;
10793
11333
  banner.setAttribute("data-banner-position", atBottom ? "bottom" : "top");
@@ -10907,7 +11447,7 @@ const _AegisInAppManager = class _AegisInAppManager {
10907
11447
  overflow: auto;
10908
11448
  box-shadow: 0 16px 48px rgba(0,0,0,0.22);
10909
11449
  animation: aegisScaleIn 0.3s ease-out;
10910
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
11450
+ ${fontFamilyCss("body")}
10911
11451
  `;
10912
11452
  if (videoUrl) {
10913
11453
  const mediaWrap = document.createElement("div");
@@ -11081,7 +11621,7 @@ const _AegisInAppManager = class _AegisInAppManager {
11081
11621
  z-index: 1000001; display: flex; flex-direction: column; align-items: center;
11082
11622
  justify-content: ${isBg ? "flex-end" : "center"}; padding: ${isBg ? "0" : "40px 20px"};
11083
11623
  animation: aegisFadeIn 0.3s ease-out; overflow: hidden;
11084
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
11624
+ ${fontFamilyCss("body")}
11085
11625
  `;
11086
11626
  if (isBg) {
11087
11627
  const media = document.createElement("div");
@@ -11219,7 +11759,7 @@ const _AegisInAppManager = class _AegisInAppManager {
11219
11759
  overflow: auto;
11220
11760
  box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
11221
11761
  animation: aegisSlideUp 0.3s ease-out;
11222
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
11762
+ ${fontFamilyCss("body")}
11223
11763
  `;
11224
11764
  const grabber = document.createElement("div");
11225
11765
  grabber.style.cssText = `width: 40px; height: 4px; border-radius: 2px; background: ${st.text}33; margin: 10px auto 0;`;
@@ -11364,7 +11904,7 @@ const _AegisInAppManager = class _AegisInAppManager {
11364
11904
  width: 85%;
11365
11905
  box-shadow: 0 16px 48px rgba(0,0,0,0.22);
11366
11906
  animation: aegisScaleIn 0.2s ease-out;
11367
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
11907
+ ${fontFamilyCss("body")}
11368
11908
  overflow: hidden;
11369
11909
  `;
11370
11910
  const content = document.createElement("div");
@@ -11482,7 +12022,7 @@ const _AegisInAppManager = class _AegisInAppManager {
11482
12022
  background: #000; border-radius: 14px; overflow: hidden;
11483
12023
  box-shadow: 0 10px 30px rgba(0,0,0,0.38); z-index: 999999;
11484
12024
  animation: ${slideAnim} 0.3s ease-out; transition: width 0.25s ease, border-radius 0.25s ease;
11485
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
12025
+ ${fontFamilyCss("body")}
11486
12026
  `;
11487
12027
  const mediaWrap = document.createElement("div");
11488
12028
  mediaWrap.style.cssText = "position: relative; width: 100%; background: #000; line-height: 0; aspect-ratio: 16 / 9;";
@@ -11633,7 +12173,7 @@ const _AegisInAppManager = class _AegisInAppManager {
11633
12173
  position: fixed; ${cornerCss} width: ${cornerW}px; max-width: calc(100vw - ${gap * 2}px);
11634
12174
  background: #000; border-radius: 14px; overflow: hidden;
11635
12175
  box-shadow: 0 10px 30px rgba(0,0,0,0.38); z-index: 999999; transition: none;
11636
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
12176
+ ${fontFamilyCss("body")}
11637
12177
  `;
11638
12178
  if (expandBtn) {
11639
12179
  expandBtn.textContent = "⤢";
@@ -11653,7 +12193,7 @@ const _AegisInAppManager = class _AegisInAppManager {
11653
12193
  width: ${theaterW}px; max-width: calc(100vw - ${gap * 2}px);
11654
12194
  background: #000; border-radius: 16px; overflow: hidden;
11655
12195
  box-shadow: 0 24px 60px rgba(0,0,0,0.55); z-index: 999999; transition: none;
11656
- font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
12196
+ ${fontFamilyCss("body")}
11657
12197
  `;
11658
12198
  if (expandBtn) {
11659
12199
  expandBtn.innerHTML = lucideSvg("x", { size: 16 });
@@ -11762,16 +12302,16 @@ const _AegisInAppManager = class _AegisInAppManager {
11762
12302
  }
11763
12303
  renderTooltip(campaign) {
11764
12304
  const ic = campaign.interactive_config || {};
11765
- const anchorSelector = ic.tooltip_anchor_selector || "[data-aegis-tooltip]";
12305
+ const anchorSelector2 = ic.tooltip_anchor_selector || "[data-aegis-tooltip]";
11766
12306
  const preferredPosition = ic.tooltip_position || "auto";
11767
12307
  const highlightOn = ic.tooltip_highlight !== false;
11768
- let anchor = document.querySelector(anchorSelector);
12308
+ let anchor = document.querySelector(anchorSelector2);
11769
12309
  if (!anchor) {
11770
12310
  console.warn(
11771
- `[AegisInApp] Tooltip anchor "${anchorSelector}" not found on this surface — tooltip not shown. On native apps this must be a key registered via registerInAppAnchor(); adding a new anchor needs an app release.`
12311
+ `[AegisInApp] Tooltip anchor "${anchorSelector2}" not found on this surface — tooltip not shown. On native apps this must be a key registered via registerInAppAnchor(); adding a new anchor needs an app release.`
11772
12312
  );
11773
12313
  void this.trackEvent(campaign.id, "anchor_unresolved", {
11774
- meta: { anchor_resolved: false, anchor_selector: anchorSelector, widget_type: "tooltip" }
12314
+ meta: { anchor_resolved: false, anchor_selector: anchorSelector2, widget_type: "tooltip" }
11775
12315
  });
11776
12316
  return;
11777
12317
  }
@@ -11783,7 +12323,7 @@ const _AegisInAppManager = class _AegisInAppManager {
11783
12323
  tooltip.style.cssText = `
11784
12324
  position: absolute; z-index: 1000001; max-width: 280px; width: max-content;
11785
12325
  background: ${bg}; color: ${textColor}; border-radius: 10px; padding: 14px 16px;
11786
- box-shadow: 0 8px 24px rgba(0,0,0,0.18); font-family: 'Urbanist', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
12326
+ box-shadow: 0 8px 24px rgba(0,0,0,0.18); ${fontFamilyCss("body")}
11787
12327
  animation: aegisScaleIn 0.2s ease-out; pointer-events: auto;
11788
12328
  `;
11789
12329
  const arrow = document.createElement("div");
@@ -11930,13 +12470,13 @@ const _AegisInAppManager = class _AegisInAppManager {
11930
12470
  };
11931
12471
  const ensureAnchor = () => {
11932
12472
  if (anchor && anchor.isConnected) return true;
11933
- const next = document.querySelector(anchorSelector);
12473
+ const next = document.querySelector(anchorSelector2);
11934
12474
  if (next) {
11935
12475
  anchor = next;
11936
12476
  return true;
11937
12477
  }
11938
12478
  void this.trackEvent(campaign.id, "anchor_unresolved", {
11939
- meta: { anchor_resolved: false, anchor_selector: anchorSelector, widget_type: "tooltip", phase: "runtime" }
12479
+ meta: { anchor_resolved: false, anchor_selector: anchorSelector2, widget_type: "tooltip", phase: "runtime" }
11940
12480
  });
11941
12481
  dismiss();
11942
12482
  return false;
@@ -12518,6 +13058,9 @@ const _AegisInAppManager = class _AegisInAppManager {
12518
13058
  this.slotSignatures = /* @__PURE__ */ new WeakMap();
12519
13059
  this.slotTimers = /* @__PURE__ */ new WeakMap();
12520
13060
  this.campaigns = [];
13061
+ this.removeShells({ sdkOnly: true });
13062
+ this.campaignsLoaded = false;
13063
+ this.campaignsRequestKey = void 0;
12521
13064
  if (typeof document !== "undefined") {
12522
13065
  document.querySelectorAll(
12523
13066
  ".aegis-in-app-banner, .aegis-in-app-modal-overlay, .aegis-in-app-fullscreen-overlay, .aegis-in-app-half-interstitial-overlay, .aegis-in-app-alert-overlay, .aegis-in-app-pip, .aegis-in-app-nps-overlay, .aegis-in-app-countdown-overlay, .aegis-in-app-rating-overlay, .aegis-in-app-poll-overlay, .aegis-in-app-quiz-overlay, .aegis-in-app-rating-card, .aegis-in-app-nps-card"
@@ -12554,9 +13097,11 @@ _AegisInAppManager.KNOWN_SURFACES = /* @__PURE__ */ new Set([
12554
13097
  "external_mobile_screen"
12555
13098
  ]);
12556
13099
  _AegisInAppManager.SERVED_DEDUP_PREFIX = "aegis_served_fired:";
13100
+ _AegisInAppManager.SHELL_TIMEOUT_MS = 1e4;
12557
13101
  _AegisInAppManager.JOURNEY_ACK_RETRY_MS = 2e3;
12558
13102
  let AegisInAppManager = _AegisInAppManager;
12559
13103
  function renderPreview(config, opts) {
13104
+ applyCampaignFonts([config, ...(opts == null ? void 0 : opts.coGroup) ?? []]);
12560
13105
  document.querySelectorAll(
12561
13106
  '[class^="aegis-in-app-"]'
12562
13107
  ).forEach((el2) => {
@@ -14149,7 +14694,7 @@ class AegisWidgetManager {
14149
14694
  display: flex;
14150
14695
  align-items: center;
14151
14696
  gap: 12px;
14152
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
14697
+ ${fontFamilyCss("body")}
14153
14698
  font-weight: 600;
14154
14699
  font-size: 14px;
14155
14700
  animation: aegisBubbleIn 0.3s ease-out;
@@ -14210,7 +14755,7 @@ class AegisWidgetManager {
14210
14755
  align-items: center;
14211
14756
  gap: 12px;
14212
14757
  max-width: 350px;
14213
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
14758
+ ${fontFamilyCss("body")}
14214
14759
  animation: aegisToastIn 0.3s ease-out;
14215
14760
  `;
14216
14761
  if (icon) {
@@ -14251,7 +14796,7 @@ class AegisWidgetManager {
14251
14796
  z-index: 1000000;
14252
14797
  padding: 32px;
14253
14798
  overflow-y: auto;
14254
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
14799
+ ${fontFamilyCss("body")}
14255
14800
  animation: aegisSlideInRight 0.3s ease-out;
14256
14801
  `;
14257
14802
  const title = document.createElement("h2");
@@ -14382,7 +14927,7 @@ class AegisWidgetManager {
14382
14927
  width: 90%;
14383
14928
  overflow: hidden;
14384
14929
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
14385
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
14930
+ ${fontFamilyCss("body")}
14386
14931
  animation: aegisScaleIn 0.3s ease-out;
14387
14932
  `;
14388
14933
  if (image_url) {
@@ -14626,7 +15171,7 @@ class AegisWidgetManager {
14626
15171
  width: 90%;
14627
15172
  padding: 40px;
14628
15173
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
14629
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
15174
+ ${fontFamilyCss("body")}
14630
15175
  animation: aegisScaleIn 0.3s ease-out;
14631
15176
  position: relative;
14632
15177
  `;
@@ -14752,7 +15297,7 @@ class AegisWidgetManager {
14752
15297
  padding: 40px;
14753
15298
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
14754
15299
  text-align: center;
14755
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
15300
+ ${fontFamilyCss("body")}
14756
15301
  animation: aegisScaleIn 0.3s ease-out;
14757
15302
  position: relative;
14758
15303
  `;
@@ -15161,7 +15706,7 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
15161
15706
  this.initialized = false;
15162
15707
  this.armedInAppTriggers = /* @__PURE__ */ new Set();
15163
15708
  {
15164
- const v = "1.43.6";
15709
+ const v = "1.45.0";
15165
15710
  try {
15166
15711
  globalThis.__AEGIS_SDK_VERSION__ = v;
15167
15712
  } catch {
@@ -15227,7 +15772,12 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
15227
15772
  // native) registers ONE `onAction` to handle add_to_cart/open_product/…;
15228
15773
  // legacy `aegis:*` DOM events still fire for back-compat.
15229
15774
  onAction: config.onAction,
15230
- productUrl: config.productUrl
15775
+ productUrl: config.productUrl,
15776
+ // Page context known at build time: the FIRST /v1/in-app/active is
15777
+ // already scoped, so no page(surface) refetch (slot plan Phase 1).
15778
+ surface: config.surface,
15779
+ screen: config.screen,
15780
+ locationId: config.locationId
15231
15781
  });
15232
15782
  this.intentRuleEvaluator = new IntentRuleEvaluator();
15233
15783
  if (config.governance) {
@@ -15299,6 +15849,12 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
15299
15849
  /**
15300
15850
  * Boots both managers in parallel. Safe to call multiple times — the
15301
15851
  * second + subsequent calls are no-ops.
15852
+ *
15853
+ * In-app paint never waits on the widget config: `inApp.initialize()` paints
15854
+ * the slots as soon as ITS `/v1/in-app/active` returns; the returned promise
15855
+ * only resolves after both. So a host must not hold page context back until
15856
+ * this resolves — pass `surface` / `screen` in the config (or call `page()`
15857
+ * before `initialize()`) and the first fetch is already scoped.
15302
15858
  */
15303
15859
  async initialize() {
15304
15860
  var _a;