@active-reach/web-sdk 1.51.0 → 1.52.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/inapp/AegisInAppManager.d.ts +8 -0
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
- package/dist/inapp/anon-claim.d.ts.map +1 -1
- package/dist/inapp/brand-accent.d.ts +34 -0
- package/dist/inapp/brand-accent.d.ts.map +1 -0
- package/dist/inapp/index.d.ts +3 -0
- package/dist/inapp/index.d.ts.map +1 -1
- 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/hero.d.ts +48 -0
- package/dist/inapp/renderers/hero.d.ts.map +1 -1
- package/dist/inapp/renderers/overlay-layout.d.ts +41 -0
- package/dist/inapp/renderers/overlay-layout.d.ts.map +1 -0
- package/dist/inapp/renderers/product-rail-section.d.ts +37 -7
- package/dist/inapp/renderers/product-rail-section.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.map +1 -1
- package/dist/inapp/renderers/sticky-bar.d.ts.map +1 -1
- package/dist/inapp/slot-kind.d.ts +28 -0
- package/dist/inapp/slot-kind.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +482 -291
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -148,6 +148,254 @@ function prizeStateOf(resp, retryMessage) {
|
|
|
148
148
|
if (outcome === "credited_win") return { state: "credited_win" };
|
|
149
149
|
return prize.win === false ? { state: "loss" } : { state: "credited_win" };
|
|
150
150
|
}
|
|
151
|
+
const BOTTOM_RESERVE_VAR = "--aegis-bottom-reserve";
|
|
152
|
+
const DESKTOP_MIN_WIDTH_PX = 768;
|
|
153
|
+
function bottomOffset(px) {
|
|
154
|
+
return `calc(var(${BOTTOM_RESERVE_VAR}, 0px) + ${px}px)`;
|
|
155
|
+
}
|
|
156
|
+
const SHEET_STYLE_ID = "aegis-overlay-layout-style";
|
|
157
|
+
function injectOverlayLayoutCss() {
|
|
158
|
+
if (typeof document === "undefined" || !document.head) return;
|
|
159
|
+
if (document.getElementById(SHEET_STYLE_ID)) return;
|
|
160
|
+
const style = document.createElement("style");
|
|
161
|
+
style.id = SHEET_STYLE_ID;
|
|
162
|
+
style.textContent = `@media (min-width:${DESKTOP_MIN_WIDTH_PX}px){.aegis-sheet-overlay{align-items:center !important;padding:24px !important;}.aegis-sheet{border-radius:20px !important;max-height:80vh !important;}.aegis-sheet-grabber{display:none !important;}.aegis-bottom-panel{top:0 !important;bottom:0 !important;display:flex !important;align-items:center !important;justify-content:center !important;padding:24px !important;background:rgba(17,24,39,0.45) !important;}.aegis-bottom-panel > *{width:100%;}}`;
|
|
163
|
+
document.head.appendChild(style);
|
|
164
|
+
}
|
|
165
|
+
function overlayAnchor(c) {
|
|
166
|
+
const ic = c.interactive_config || {};
|
|
167
|
+
switch (c.type) {
|
|
168
|
+
case "sticky_bar":
|
|
169
|
+
return ic.sticky_position === "top" ? "top" : "bottom";
|
|
170
|
+
case "progress_bar":
|
|
171
|
+
case "carousel_cards":
|
|
172
|
+
return "bottom";
|
|
173
|
+
case "banner":
|
|
174
|
+
return ic.banner_position === "bottom" ? "bottom" : "top";
|
|
175
|
+
case "pip": {
|
|
176
|
+
const pos = typeof ic.pip_position === "string" ? ic.pip_position : "bottom-right";
|
|
177
|
+
return pos.startsWith("top") ? "top" : "bottom";
|
|
178
|
+
}
|
|
179
|
+
default:
|
|
180
|
+
return "center";
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const keywords = ["inherit", "system", "serif", "mono"];
|
|
184
|
+
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" };
|
|
185
|
+
const aliases = { "system-ui": "system", "-apple-system": "system", "georgia": "serif", "times new roman": "serif", "sf mono": "mono", "ui-monospace": "mono", "menlo": "mono", "monospace": "mono" };
|
|
186
|
+
const role_weights = { "body": [400, 500], "display": [600, 700] };
|
|
187
|
+
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%" } }];
|
|
188
|
+
const FONT_ALLOWLIST = {
|
|
189
|
+
keywords,
|
|
190
|
+
system_stacks,
|
|
191
|
+
aliases,
|
|
192
|
+
role_weights,
|
|
193
|
+
google
|
|
194
|
+
};
|
|
195
|
+
const BODY_FONT_STACK = "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif";
|
|
196
|
+
const SERIF_STACK = "Georgia, 'Times New Roman', serif";
|
|
197
|
+
const AEGIS_BODY_FONT_VAR = "--aegis-font-body";
|
|
198
|
+
const AEGIS_DISPLAY_FONT_VAR = "--aegis-font-display";
|
|
199
|
+
const ACS_DISPLAY_FONT_VAR = "--acs-font-display";
|
|
200
|
+
const ACS_BODY_FONT_VAR = "--acs-font-body";
|
|
201
|
+
const GOOGLE_FONTS = FONT_ALLOWLIST.google;
|
|
202
|
+
const KEYWORDS = FONT_ALLOWLIST.keywords;
|
|
203
|
+
const SYSTEM_STACKS = FONT_ALLOWLIST.system_stacks;
|
|
204
|
+
const ALIASES = FONT_ALLOWLIST.aliases;
|
|
205
|
+
const ROLE_WEIGHTS = FONT_ALLOWLIST.role_weights;
|
|
206
|
+
function fontFamilyCss(role) {
|
|
207
|
+
return `font-family:var(${role === "display" ? AEGIS_DISPLAY_FONT_VAR : AEGIS_BODY_FONT_VAR});`;
|
|
208
|
+
}
|
|
209
|
+
function findGoogleFont(value) {
|
|
210
|
+
const v = value.trim().toLowerCase();
|
|
211
|
+
return GOOGLE_FONTS.find((f) => f.name.toLowerCase() === v);
|
|
212
|
+
}
|
|
213
|
+
function normalizeFontValue(value) {
|
|
214
|
+
var _a;
|
|
215
|
+
if (typeof value !== "string") return null;
|
|
216
|
+
const first = value.split(",")[0].trim().replace(/^['"]|['"]$/g, "").trim();
|
|
217
|
+
if (!first) return null;
|
|
218
|
+
const v = first.toLowerCase();
|
|
219
|
+
if (KEYWORDS.includes(v)) return v;
|
|
220
|
+
if (ALIASES[v]) return ALIASES[v];
|
|
221
|
+
return ((_a = findGoogleFont(first)) == null ? void 0 : _a.name) ?? null;
|
|
222
|
+
}
|
|
223
|
+
function fallbackFamily(f) {
|
|
224
|
+
return `${f.name} Aegis Fallback`;
|
|
225
|
+
}
|
|
226
|
+
function fontValueToCss(value, host = "third_party") {
|
|
227
|
+
const canonical = normalizeFontValue(value);
|
|
228
|
+
if (!canonical) return null;
|
|
229
|
+
if (canonical === "inherit") return { css: "initial" };
|
|
230
|
+
if (SYSTEM_STACKS[canonical]) return { css: SYSTEM_STACKS[canonical] };
|
|
231
|
+
const f = findGoogleFont(canonical);
|
|
232
|
+
if (!f) return null;
|
|
233
|
+
const stack = f.category === "serif" ? SERIF_STACK : BODY_FONT_STACK;
|
|
234
|
+
if (host === "acs") return { css: `var(${acsFaceVar(f)}), ${stack}` };
|
|
235
|
+
return { css: `'${f.name}', '${fallbackFamily(f)}', ${stack}`, font: f };
|
|
236
|
+
}
|
|
237
|
+
function acsFaceVar(f) {
|
|
238
|
+
return `--acs-face-${f.name.toLowerCase().replace(/ /g, "-")}`;
|
|
239
|
+
}
|
|
240
|
+
function readRootVar(name) {
|
|
241
|
+
if (typeof document === "undefined" || typeof getComputedStyle !== "function") return "";
|
|
242
|
+
try {
|
|
243
|
+
return getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
|
244
|
+
} catch {
|
|
245
|
+
return "";
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function detectFontHost(read2 = readRootVar) {
|
|
249
|
+
return read2(ACS_BODY_FONT_VAR) ? "acs" : "third_party";
|
|
250
|
+
}
|
|
251
|
+
function resolveRootFonts(brand, read2 = readRootVar) {
|
|
252
|
+
const host = detectFontHost(read2);
|
|
253
|
+
if (host === "acs") {
|
|
254
|
+
return {
|
|
255
|
+
host,
|
|
256
|
+
body: `var(${ACS_BODY_FONT_VAR})`,
|
|
257
|
+
display: read2(ACS_DISPLAY_FONT_VAR) ? `var(${ACS_DISPLAY_FONT_VAR})` : `var(${ACS_BODY_FONT_VAR})`,
|
|
258
|
+
load: []
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
const load = [];
|
|
262
|
+
const pick = (role) => {
|
|
263
|
+
const served = fontValueToCss(role === "display" ? brand == null ? void 0 : brand.display : brand == null ? void 0 : brand.body);
|
|
264
|
+
if (!served) return null;
|
|
265
|
+
if (served.font) load.push({ font: served.font, role });
|
|
266
|
+
return served.css;
|
|
267
|
+
};
|
|
268
|
+
const body = pick("body");
|
|
269
|
+
const display = pick("display");
|
|
270
|
+
return { host, body, display, load };
|
|
271
|
+
}
|
|
272
|
+
const LINK_ID = "aegis-inapp-fonts";
|
|
273
|
+
const FALLBACK_STYLE_ID = "aegis-inapp-font-fallbacks";
|
|
274
|
+
const PRECONNECT_ORIGINS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
|
|
275
|
+
const requested = /* @__PURE__ */ new Map();
|
|
276
|
+
function googleFontsHref(families) {
|
|
277
|
+
const parts = [...families.keys()].sort((a, b) => a.localeCompare(b)).map((name) => {
|
|
278
|
+
const weights = [...families.get(name) ?? []].sort((a, b) => a - b);
|
|
279
|
+
return `family=${name.replace(/ /g, "+")}:wght@${weights.join(";")}`;
|
|
280
|
+
});
|
|
281
|
+
return `https://fonts.googleapis.com/css2?${parts.join("&")}&display=swap`;
|
|
282
|
+
}
|
|
283
|
+
function fallbackFaceCss(fonts) {
|
|
284
|
+
return fonts.map(
|
|
285
|
+
(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};}`
|
|
286
|
+
).join("\n");
|
|
287
|
+
}
|
|
288
|
+
function ensurePreconnect() {
|
|
289
|
+
for (const origin of PRECONNECT_ORIGINS) {
|
|
290
|
+
if (document.head.querySelector(`link[rel="preconnect"][href="${origin}"]`)) continue;
|
|
291
|
+
const l = document.createElement("link");
|
|
292
|
+
l.rel = "preconnect";
|
|
293
|
+
l.href = origin;
|
|
294
|
+
if (origin.includes("gstatic")) l.crossOrigin = "anonymous";
|
|
295
|
+
document.head.appendChild(l);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function loadFonts(loads, read2 = readRootVar) {
|
|
299
|
+
if (typeof document === "undefined" || loads.length === 0) return;
|
|
300
|
+
if (detectFontHost(read2) === "acs") return;
|
|
301
|
+
let grew = false;
|
|
302
|
+
for (const { font, role } of loads) {
|
|
303
|
+
const known = findGoogleFont(font.name);
|
|
304
|
+
if (!known) continue;
|
|
305
|
+
const set = requested.get(known.name) ?? /* @__PURE__ */ new Set();
|
|
306
|
+
for (const w of ROLE_WEIGHTS[role]) {
|
|
307
|
+
if (!set.has(w)) {
|
|
308
|
+
set.add(w);
|
|
309
|
+
grew = true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
requested.set(known.name, set);
|
|
313
|
+
}
|
|
314
|
+
if (!grew) return;
|
|
315
|
+
ensurePreconnect();
|
|
316
|
+
let style = document.getElementById(FALLBACK_STYLE_ID);
|
|
317
|
+
if (!style) {
|
|
318
|
+
style = document.createElement("style");
|
|
319
|
+
style.id = FALLBACK_STYLE_ID;
|
|
320
|
+
document.head.appendChild(style);
|
|
321
|
+
}
|
|
322
|
+
style.textContent = fallbackFaceCss(
|
|
323
|
+
[...requested.keys()].map((n) => findGoogleFont(n)).filter((f) => !!f)
|
|
324
|
+
);
|
|
325
|
+
let link = document.getElementById(LINK_ID);
|
|
326
|
+
if (!link) {
|
|
327
|
+
link = document.createElement("link");
|
|
328
|
+
link.id = LINK_ID;
|
|
329
|
+
link.rel = "stylesheet";
|
|
330
|
+
document.head.appendChild(link);
|
|
331
|
+
}
|
|
332
|
+
link.href = googleFontsHref(requested);
|
|
333
|
+
}
|
|
334
|
+
function applyRootFonts(brand, read2 = readRootVar) {
|
|
335
|
+
const r = resolveRootFonts(brand, read2);
|
|
336
|
+
if (typeof document === "undefined") return r;
|
|
337
|
+
const root = document.documentElement.style;
|
|
338
|
+
if (r.body) root.setProperty(AEGIS_BODY_FONT_VAR, r.body);
|
|
339
|
+
else root.removeProperty(AEGIS_BODY_FONT_VAR);
|
|
340
|
+
if (r.display) root.setProperty(AEGIS_DISPLAY_FONT_VAR, r.display);
|
|
341
|
+
else root.removeProperty(AEGIS_DISPLAY_FONT_VAR);
|
|
342
|
+
loadFonts(r.load, read2);
|
|
343
|
+
return r;
|
|
344
|
+
}
|
|
345
|
+
function campaignFontFamily(campaign) {
|
|
346
|
+
var _a;
|
|
347
|
+
const style = (_a = campaign == null ? void 0 : campaign.interactive_config) == null ? void 0 : _a.style;
|
|
348
|
+
if (style && typeof style === "object") {
|
|
349
|
+
const ff = style.fontFamily;
|
|
350
|
+
if (typeof ff === "string" && ff.trim()) return ff;
|
|
351
|
+
}
|
|
352
|
+
return void 0;
|
|
353
|
+
}
|
|
354
|
+
function campaignFontVarsCss(value, read2 = readRootVar) {
|
|
355
|
+
const served = fontValueToCss(value, detectFontHost(read2));
|
|
356
|
+
if (!served) return "";
|
|
357
|
+
if (served.font) {
|
|
358
|
+
loadFonts(
|
|
359
|
+
[
|
|
360
|
+
{ font: served.font, role: "body" },
|
|
361
|
+
{ font: served.font, role: "display" }
|
|
362
|
+
],
|
|
363
|
+
read2
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
return `${AEGIS_BODY_FONT_VAR}:${served.css};${AEGIS_DISPLAY_FONT_VAR}:${served.css};`;
|
|
367
|
+
}
|
|
368
|
+
const CAMPAIGN_SHEET_ID = "aegis-campaign-fonts";
|
|
369
|
+
const SAFE_ID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
370
|
+
function registerCampaignFonts(campaigns, read2 = readRootVar) {
|
|
371
|
+
const rules = [];
|
|
372
|
+
for (const c of campaigns) {
|
|
373
|
+
const id = typeof c.id === "string" ? c.id : "";
|
|
374
|
+
if (!SAFE_ID.test(id)) continue;
|
|
375
|
+
const decl = campaignFontVarsCss(campaignFontFamily(c), read2);
|
|
376
|
+
if (decl) rules.push(`[data-campaign-id="${id}"]{${decl}}`);
|
|
377
|
+
}
|
|
378
|
+
const css = rules.join("\n");
|
|
379
|
+
if (typeof document === "undefined") return css;
|
|
380
|
+
let sheet = document.getElementById(CAMPAIGN_SHEET_ID);
|
|
381
|
+
if (!css) {
|
|
382
|
+
sheet == null ? void 0 : sheet.remove();
|
|
383
|
+
return css;
|
|
384
|
+
}
|
|
385
|
+
if (!sheet) {
|
|
386
|
+
sheet = document.createElement("style");
|
|
387
|
+
sheet.id = CAMPAIGN_SHEET_ID;
|
|
388
|
+
document.head.appendChild(sheet);
|
|
389
|
+
}
|
|
390
|
+
sheet.textContent = css;
|
|
391
|
+
return css;
|
|
392
|
+
}
|
|
393
|
+
function applyCampaignFonts(campaigns, read2 = readRootVar) {
|
|
394
|
+
var _a;
|
|
395
|
+
const brand = ((_a = campaigns.find((c) => c.brand_typography)) == null ? void 0 : _a.brand_typography) ?? null;
|
|
396
|
+
applyRootFonts(brand, read2);
|
|
397
|
+
registerCampaignFonts(campaigns, read2);
|
|
398
|
+
}
|
|
151
399
|
const CLAIM_BUTTON_LABEL = "Log in or sign up to claim";
|
|
152
400
|
const SIGN_IN_BUTTON_LABEL = "Sign in to play";
|
|
153
401
|
const ANON_CLAIMS_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -214,7 +462,7 @@ function showClaimNotice(answer, onRetry) {
|
|
|
214
462
|
const box = document.createElement("div");
|
|
215
463
|
box.setAttribute("data-aegis-anon-claim-notice", "");
|
|
216
464
|
box.setAttribute("role", "status");
|
|
217
|
-
box.style.cssText =
|
|
465
|
+
box.style.cssText = `position:fixed;left:16px;right:16px;bottom:${bottomOffset(16)};max-width:420px;margin:0 auto;z-index:2147483646;background:#fff;color:#111827;border-radius:12px;padding:14px 16px;box-shadow:0 8px 30px rgba(0,0,0,0.18);font-size:14px;line-height:1.4;${fontFamilyCss("body")}`;
|
|
218
466
|
const text = document.createElement("div");
|
|
219
467
|
text.style.cssText = "font-weight:600;";
|
|
220
468
|
text.textContent = answer.text;
|
|
@@ -485,222 +733,6 @@ function lucideSvg(name, opts = {}) {
|
|
|
485
733
|
}).join("");
|
|
486
734
|
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>`;
|
|
487
735
|
}
|
|
488
|
-
const keywords = ["inherit", "system", "serif", "mono"];
|
|
489
|
-
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" };
|
|
490
|
-
const aliases = { "system-ui": "system", "-apple-system": "system", "georgia": "serif", "times new roman": "serif", "sf mono": "mono", "ui-monospace": "mono", "menlo": "mono", "monospace": "mono" };
|
|
491
|
-
const role_weights = { "body": [400, 500], "display": [600, 700] };
|
|
492
|
-
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%" } }];
|
|
493
|
-
const FONT_ALLOWLIST = {
|
|
494
|
-
keywords,
|
|
495
|
-
system_stacks,
|
|
496
|
-
aliases,
|
|
497
|
-
role_weights,
|
|
498
|
-
google
|
|
499
|
-
};
|
|
500
|
-
const BODY_FONT_STACK = "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif";
|
|
501
|
-
const SERIF_STACK = "Georgia, 'Times New Roman', serif";
|
|
502
|
-
const AEGIS_BODY_FONT_VAR = "--aegis-font-body";
|
|
503
|
-
const AEGIS_DISPLAY_FONT_VAR = "--aegis-font-display";
|
|
504
|
-
const ACS_DISPLAY_FONT_VAR = "--acs-font-display";
|
|
505
|
-
const ACS_BODY_FONT_VAR = "--acs-font-body";
|
|
506
|
-
const GOOGLE_FONTS = FONT_ALLOWLIST.google;
|
|
507
|
-
const KEYWORDS = FONT_ALLOWLIST.keywords;
|
|
508
|
-
const SYSTEM_STACKS = FONT_ALLOWLIST.system_stacks;
|
|
509
|
-
const ALIASES = FONT_ALLOWLIST.aliases;
|
|
510
|
-
const ROLE_WEIGHTS = FONT_ALLOWLIST.role_weights;
|
|
511
|
-
function fontFamilyCss(role) {
|
|
512
|
-
return `font-family:var(${role === "display" ? AEGIS_DISPLAY_FONT_VAR : AEGIS_BODY_FONT_VAR});`;
|
|
513
|
-
}
|
|
514
|
-
function findGoogleFont(value) {
|
|
515
|
-
const v = value.trim().toLowerCase();
|
|
516
|
-
return GOOGLE_FONTS.find((f) => f.name.toLowerCase() === v);
|
|
517
|
-
}
|
|
518
|
-
function normalizeFontValue(value) {
|
|
519
|
-
var _a;
|
|
520
|
-
if (typeof value !== "string") return null;
|
|
521
|
-
const first = value.split(",")[0].trim().replace(/^['"]|['"]$/g, "").trim();
|
|
522
|
-
if (!first) return null;
|
|
523
|
-
const v = first.toLowerCase();
|
|
524
|
-
if (KEYWORDS.includes(v)) return v;
|
|
525
|
-
if (ALIASES[v]) return ALIASES[v];
|
|
526
|
-
return ((_a = findGoogleFont(first)) == null ? void 0 : _a.name) ?? null;
|
|
527
|
-
}
|
|
528
|
-
function fallbackFamily(f) {
|
|
529
|
-
return `${f.name} Aegis Fallback`;
|
|
530
|
-
}
|
|
531
|
-
function fontValueToCss(value, host = "third_party") {
|
|
532
|
-
const canonical = normalizeFontValue(value);
|
|
533
|
-
if (!canonical) return null;
|
|
534
|
-
if (canonical === "inherit") return { css: "initial" };
|
|
535
|
-
if (SYSTEM_STACKS[canonical]) return { css: SYSTEM_STACKS[canonical] };
|
|
536
|
-
const f = findGoogleFont(canonical);
|
|
537
|
-
if (!f) return null;
|
|
538
|
-
const stack = f.category === "serif" ? SERIF_STACK : BODY_FONT_STACK;
|
|
539
|
-
if (host === "acs") return { css: `var(${acsFaceVar(f)}), ${stack}` };
|
|
540
|
-
return { css: `'${f.name}', '${fallbackFamily(f)}', ${stack}`, font: f };
|
|
541
|
-
}
|
|
542
|
-
function acsFaceVar(f) {
|
|
543
|
-
return `--acs-face-${f.name.toLowerCase().replace(/ /g, "-")}`;
|
|
544
|
-
}
|
|
545
|
-
function readRootVar(name) {
|
|
546
|
-
if (typeof document === "undefined" || typeof getComputedStyle !== "function") return "";
|
|
547
|
-
try {
|
|
548
|
-
return getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
|
549
|
-
} catch {
|
|
550
|
-
return "";
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
function detectFontHost(read2 = readRootVar) {
|
|
554
|
-
return read2(ACS_BODY_FONT_VAR) ? "acs" : "third_party";
|
|
555
|
-
}
|
|
556
|
-
function resolveRootFonts(brand, read2 = readRootVar) {
|
|
557
|
-
const host = detectFontHost(read2);
|
|
558
|
-
if (host === "acs") {
|
|
559
|
-
return {
|
|
560
|
-
host,
|
|
561
|
-
body: `var(${ACS_BODY_FONT_VAR})`,
|
|
562
|
-
display: read2(ACS_DISPLAY_FONT_VAR) ? `var(${ACS_DISPLAY_FONT_VAR})` : `var(${ACS_BODY_FONT_VAR})`,
|
|
563
|
-
load: []
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
const load = [];
|
|
567
|
-
const pick = (role) => {
|
|
568
|
-
const served = fontValueToCss(role === "display" ? brand == null ? void 0 : brand.display : brand == null ? void 0 : brand.body);
|
|
569
|
-
if (!served) return null;
|
|
570
|
-
if (served.font) load.push({ font: served.font, role });
|
|
571
|
-
return served.css;
|
|
572
|
-
};
|
|
573
|
-
const body = pick("body");
|
|
574
|
-
const display = pick("display");
|
|
575
|
-
return { host, body, display, load };
|
|
576
|
-
}
|
|
577
|
-
const LINK_ID = "aegis-inapp-fonts";
|
|
578
|
-
const FALLBACK_STYLE_ID = "aegis-inapp-font-fallbacks";
|
|
579
|
-
const PRECONNECT_ORIGINS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
|
|
580
|
-
const requested = /* @__PURE__ */ new Map();
|
|
581
|
-
function googleFontsHref(families) {
|
|
582
|
-
const parts = [...families.keys()].sort((a, b) => a.localeCompare(b)).map((name) => {
|
|
583
|
-
const weights = [...families.get(name) ?? []].sort((a, b) => a - b);
|
|
584
|
-
return `family=${name.replace(/ /g, "+")}:wght@${weights.join(";")}`;
|
|
585
|
-
});
|
|
586
|
-
return `https://fonts.googleapis.com/css2?${parts.join("&")}&display=swap`;
|
|
587
|
-
}
|
|
588
|
-
function fallbackFaceCss(fonts) {
|
|
589
|
-
return fonts.map(
|
|
590
|
-
(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};}`
|
|
591
|
-
).join("\n");
|
|
592
|
-
}
|
|
593
|
-
function ensurePreconnect() {
|
|
594
|
-
for (const origin of PRECONNECT_ORIGINS) {
|
|
595
|
-
if (document.head.querySelector(`link[rel="preconnect"][href="${origin}"]`)) continue;
|
|
596
|
-
const l = document.createElement("link");
|
|
597
|
-
l.rel = "preconnect";
|
|
598
|
-
l.href = origin;
|
|
599
|
-
if (origin.includes("gstatic")) l.crossOrigin = "anonymous";
|
|
600
|
-
document.head.appendChild(l);
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
function loadFonts(loads, read2 = readRootVar) {
|
|
604
|
-
if (typeof document === "undefined" || loads.length === 0) return;
|
|
605
|
-
if (detectFontHost(read2) === "acs") return;
|
|
606
|
-
let grew = false;
|
|
607
|
-
for (const { font, role } of loads) {
|
|
608
|
-
const known = findGoogleFont(font.name);
|
|
609
|
-
if (!known) continue;
|
|
610
|
-
const set = requested.get(known.name) ?? /* @__PURE__ */ new Set();
|
|
611
|
-
for (const w of ROLE_WEIGHTS[role]) {
|
|
612
|
-
if (!set.has(w)) {
|
|
613
|
-
set.add(w);
|
|
614
|
-
grew = true;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
requested.set(known.name, set);
|
|
618
|
-
}
|
|
619
|
-
if (!grew) return;
|
|
620
|
-
ensurePreconnect();
|
|
621
|
-
let style = document.getElementById(FALLBACK_STYLE_ID);
|
|
622
|
-
if (!style) {
|
|
623
|
-
style = document.createElement("style");
|
|
624
|
-
style.id = FALLBACK_STYLE_ID;
|
|
625
|
-
document.head.appendChild(style);
|
|
626
|
-
}
|
|
627
|
-
style.textContent = fallbackFaceCss(
|
|
628
|
-
[...requested.keys()].map((n) => findGoogleFont(n)).filter((f) => !!f)
|
|
629
|
-
);
|
|
630
|
-
let link = document.getElementById(LINK_ID);
|
|
631
|
-
if (!link) {
|
|
632
|
-
link = document.createElement("link");
|
|
633
|
-
link.id = LINK_ID;
|
|
634
|
-
link.rel = "stylesheet";
|
|
635
|
-
document.head.appendChild(link);
|
|
636
|
-
}
|
|
637
|
-
link.href = googleFontsHref(requested);
|
|
638
|
-
}
|
|
639
|
-
function applyRootFonts(brand, read2 = readRootVar) {
|
|
640
|
-
const r = resolveRootFonts(brand, read2);
|
|
641
|
-
if (typeof document === "undefined") return r;
|
|
642
|
-
const root = document.documentElement.style;
|
|
643
|
-
if (r.body) root.setProperty(AEGIS_BODY_FONT_VAR, r.body);
|
|
644
|
-
else root.removeProperty(AEGIS_BODY_FONT_VAR);
|
|
645
|
-
if (r.display) root.setProperty(AEGIS_DISPLAY_FONT_VAR, r.display);
|
|
646
|
-
else root.removeProperty(AEGIS_DISPLAY_FONT_VAR);
|
|
647
|
-
loadFonts(r.load, read2);
|
|
648
|
-
return r;
|
|
649
|
-
}
|
|
650
|
-
function campaignFontFamily(campaign) {
|
|
651
|
-
var _a;
|
|
652
|
-
const style = (_a = campaign == null ? void 0 : campaign.interactive_config) == null ? void 0 : _a.style;
|
|
653
|
-
if (style && typeof style === "object") {
|
|
654
|
-
const ff = style.fontFamily;
|
|
655
|
-
if (typeof ff === "string" && ff.trim()) return ff;
|
|
656
|
-
}
|
|
657
|
-
return void 0;
|
|
658
|
-
}
|
|
659
|
-
function campaignFontVarsCss(value, read2 = readRootVar) {
|
|
660
|
-
const served = fontValueToCss(value, detectFontHost(read2));
|
|
661
|
-
if (!served) return "";
|
|
662
|
-
if (served.font) {
|
|
663
|
-
loadFonts(
|
|
664
|
-
[
|
|
665
|
-
{ font: served.font, role: "body" },
|
|
666
|
-
{ font: served.font, role: "display" }
|
|
667
|
-
],
|
|
668
|
-
read2
|
|
669
|
-
);
|
|
670
|
-
}
|
|
671
|
-
return `${AEGIS_BODY_FONT_VAR}:${served.css};${AEGIS_DISPLAY_FONT_VAR}:${served.css};`;
|
|
672
|
-
}
|
|
673
|
-
const CAMPAIGN_SHEET_ID = "aegis-campaign-fonts";
|
|
674
|
-
const SAFE_ID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
675
|
-
function registerCampaignFonts(campaigns, read2 = readRootVar) {
|
|
676
|
-
const rules = [];
|
|
677
|
-
for (const c of campaigns) {
|
|
678
|
-
const id = typeof c.id === "string" ? c.id : "";
|
|
679
|
-
if (!SAFE_ID.test(id)) continue;
|
|
680
|
-
const decl = campaignFontVarsCss(campaignFontFamily(c), read2);
|
|
681
|
-
if (decl) rules.push(`[data-campaign-id="${id}"]{${decl}}`);
|
|
682
|
-
}
|
|
683
|
-
const css = rules.join("\n");
|
|
684
|
-
if (typeof document === "undefined") return css;
|
|
685
|
-
let sheet = document.getElementById(CAMPAIGN_SHEET_ID);
|
|
686
|
-
if (!css) {
|
|
687
|
-
sheet == null ? void 0 : sheet.remove();
|
|
688
|
-
return css;
|
|
689
|
-
}
|
|
690
|
-
if (!sheet) {
|
|
691
|
-
sheet = document.createElement("style");
|
|
692
|
-
sheet.id = CAMPAIGN_SHEET_ID;
|
|
693
|
-
document.head.appendChild(sheet);
|
|
694
|
-
}
|
|
695
|
-
sheet.textContent = css;
|
|
696
|
-
return css;
|
|
697
|
-
}
|
|
698
|
-
function applyCampaignFonts(campaigns, read2 = readRootVar) {
|
|
699
|
-
var _a;
|
|
700
|
-
const brand = ((_a = campaigns.find((c) => c.brand_typography)) == null ? void 0 : _a.brand_typography) ?? null;
|
|
701
|
-
applyRootFonts(brand, read2);
|
|
702
|
-
registerCampaignFonts(campaigns, read2);
|
|
703
|
-
}
|
|
704
736
|
const HERO_IMAGE_SIZES = "100vw";
|
|
705
737
|
function cardImageSizes(kind, widthPx) {
|
|
706
738
|
if (typeof widthPx === "number" && widthPx > 0 && Number.isFinite(widthPx)) return `${Math.round(widthPx)}px`;
|
|
@@ -1805,8 +1837,9 @@ function buildNpsElement(el2, ctx, fg, accent, muted) {
|
|
|
1805
1837
|
wrap.appendChild(scale);
|
|
1806
1838
|
return wrap;
|
|
1807
1839
|
}
|
|
1808
|
-
function buildProgressElement(el2, ctx, accent, muted, compact) {
|
|
1840
|
+
function buildProgressElement(el2, ctx, accent, muted, compact, onMeasuredDefault) {
|
|
1809
1841
|
const { trackEvent, campaign, sanitizeColor } = ctx;
|
|
1842
|
+
const reportMeasured = compact ? compact.onMeasured : onMeasuredDefault;
|
|
1810
1843
|
const goal = el2.goal_type || "cart_total";
|
|
1811
1844
|
const moneyGoal = goal === "cart_total";
|
|
1812
1845
|
const fill = el2.fill ? sanitizeColor(el2.fill) : accent;
|
|
@@ -1878,17 +1911,17 @@ function buildProgressElement(el2, ctx, accent, muted, compact) {
|
|
|
1878
1911
|
let firedUnlock = false;
|
|
1879
1912
|
let seenIncomplete = false;
|
|
1880
1913
|
const update = () => {
|
|
1881
|
-
var _a
|
|
1914
|
+
var _a;
|
|
1882
1915
|
const th = threshold();
|
|
1883
1916
|
const cur = readCur();
|
|
1884
1917
|
if (th <= 0 && el2.threshold_source === "free_delivery_setting") {
|
|
1885
1918
|
wrap.style.display = "none";
|
|
1886
1919
|
markProgress(shell, null, false);
|
|
1887
|
-
|
|
1920
|
+
reportMeasured == null ? void 0 : reportMeasured(false);
|
|
1888
1921
|
return;
|
|
1889
1922
|
}
|
|
1890
1923
|
wrap.style.display = "flex";
|
|
1891
|
-
|
|
1924
|
+
reportMeasured == null ? void 0 : reportMeasured(true);
|
|
1892
1925
|
const { pct, complete } = computeProgress({ threshold: th, current: cur });
|
|
1893
1926
|
bar.style.width = `${pct}%`;
|
|
1894
1927
|
markProgress(shell, pct, complete);
|
|
@@ -1910,7 +1943,7 @@ function buildProgressElement(el2, ctx, accent, muted, compact) {
|
|
|
1910
1943
|
firedUnlock = true;
|
|
1911
1944
|
if (seenIncomplete) {
|
|
1912
1945
|
trackEvent(campaign.id, "clicked", { stepId: el2.id || "unlocked" });
|
|
1913
|
-
if (el2.celebrate_on_complete !== false) (
|
|
1946
|
+
if (el2.celebrate_on_complete !== false) (_a = ctx.playReaction) == null ? void 0 : _a.call(ctx, wrap, "celebrate");
|
|
1914
1947
|
}
|
|
1915
1948
|
}
|
|
1916
1949
|
} else {
|
|
@@ -2176,7 +2209,12 @@ function renderCardFromTemplate(card, opts) {
|
|
|
2176
2209
|
break;
|
|
2177
2210
|
}
|
|
2178
2211
|
case "progress": {
|
|
2179
|
-
|
|
2212
|
+
const tileDisplay = tile.style.display;
|
|
2213
|
+
const onMeasured = (measured) => {
|
|
2214
|
+
tile.hidden = !measured;
|
|
2215
|
+
tile.style.display = measured ? tileDisplay : "none";
|
|
2216
|
+
};
|
|
2217
|
+
container.appendChild(buildProgressElement(el2, ctx, brand, muted, void 0, onMeasured));
|
|
2180
2218
|
break;
|
|
2181
2219
|
}
|
|
2182
2220
|
case "countdown": {
|
|
@@ -2286,6 +2324,28 @@ function renderCardFromTemplate(card, opts) {
|
|
|
2286
2324
|
}
|
|
2287
2325
|
return tile;
|
|
2288
2326
|
}
|
|
2327
|
+
const BRAND_ACCENT_VAR = "--aegis-brand-accent";
|
|
2328
|
+
const DEFAULT_BRAND_ACCENT = "#4169e1";
|
|
2329
|
+
const CONCRETE = /^(#[0-9a-fA-F]{3,6}|rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)|rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*[\d.]+\s*\))$/;
|
|
2330
|
+
function brandAccentCss(fallback = DEFAULT_BRAND_ACCENT) {
|
|
2331
|
+
return `var(${BRAND_ACCENT_VAR}, ${fallback})`;
|
|
2332
|
+
}
|
|
2333
|
+
function readBrandAccent() {
|
|
2334
|
+
if (typeof document === "undefined" || typeof getComputedStyle !== "function") return null;
|
|
2335
|
+
const els = [document.documentElement, document.body].filter(Boolean);
|
|
2336
|
+
for (const el2 of els) {
|
|
2337
|
+
try {
|
|
2338
|
+
const v = getComputedStyle(el2).getPropertyValue(BRAND_ACCENT_VAR).trim();
|
|
2339
|
+
if (v && CONCRETE.test(v)) return v;
|
|
2340
|
+
} catch {
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
return null;
|
|
2344
|
+
}
|
|
2345
|
+
function resolveAccent(explicit, sanitizeColor, fallback = DEFAULT_BRAND_ACCENT) {
|
|
2346
|
+
if (typeof explicit === "string" && explicit.trim()) return sanitizeColor(explicit.trim());
|
|
2347
|
+
return brandAccentCss(fallback);
|
|
2348
|
+
}
|
|
2289
2349
|
const MAX_CARDS_RENDERED = 10;
|
|
2290
2350
|
function renderCarouselCards(ctx) {
|
|
2291
2351
|
const { campaign, trackEvent, sanitizeColor, log, addAnimationStyles } = ctx;
|
|
@@ -2302,12 +2362,13 @@ function renderCarouselCards(ctx) {
|
|
|
2302
2362
|
addAnimationStyles();
|
|
2303
2363
|
const bg = "#ffffff";
|
|
2304
2364
|
const fg = "#0f172a";
|
|
2305
|
-
const accent =
|
|
2365
|
+
const accent = resolveAccent(campaign.background_color, sanitizeColor);
|
|
2306
2366
|
const overlay = document.createElement("div");
|
|
2307
|
-
|
|
2367
|
+
injectOverlayLayoutCss();
|
|
2368
|
+
overlay.className = "aegis-in-app-carousel-overlay aegis-bottom-panel";
|
|
2308
2369
|
overlay.setAttribute("data-campaign-id", campaign.id);
|
|
2309
2370
|
overlay.style.cssText = `
|
|
2310
|
-
position: fixed; left: 0; right: 0; bottom: 0;
|
|
2371
|
+
position: fixed; left: 0; right: 0; bottom: ${bottomOffset(0)};
|
|
2311
2372
|
z-index: 99999; padding: 12px 12px 20px;
|
|
2312
2373
|
background: rgba(0,0,0,0.12); backdrop-filter: blur(8px);
|
|
2313
2374
|
${fontFamilyCss("body")}
|
|
@@ -2482,14 +2543,12 @@ function renderStickyBar(ctx) {
|
|
|
2482
2543
|
} catch {
|
|
2483
2544
|
}
|
|
2484
2545
|
addAnimationStyles();
|
|
2485
|
-
const bg = sanitizeColor
|
|
2486
|
-
ic.sticky_bg_color || campaign.background_color || "#4169e1"
|
|
2487
|
-
);
|
|
2546
|
+
const bg = resolveAccent(ic.sticky_bg_color || campaign.background_color, sanitizeColor);
|
|
2488
2547
|
const fg = sanitizeColor(campaign.text_color || "#ffffff");
|
|
2489
2548
|
const bar = document.createElement("div");
|
|
2490
2549
|
bar.className = "aegis-in-app-sticky-bar";
|
|
2491
2550
|
bar.setAttribute("data-campaign-id", campaign.id);
|
|
2492
|
-
const positionCss = position === "top" ? "top: 0; left: 0; right: 0; animation: aegisSlideDown 0.3s ease-out;" :
|
|
2551
|
+
const positionCss = position === "top" ? "top: 0; left: 0; right: 0; animation: aegisSlideDown 0.3s ease-out;" : `bottom: ${bottomOffset(0)}; left: 0; right: 0; animation: aegisSlideInFromBottom 0.3s ease-out;`;
|
|
2493
2552
|
bar.style.cssText = `
|
|
2494
2553
|
position: fixed; ${positionCss}
|
|
2495
2554
|
background: ${bg}; color: ${fg};
|
|
@@ -2586,7 +2645,7 @@ function buildProgressBar(ctx, inline, compact = false) {
|
|
|
2586
2645
|
padding: 10px 14px;
|
|
2587
2646
|
${fontFamilyCss("body")}
|
|
2588
2647
|
` : `
|
|
2589
|
-
position: fixed; left: 12px; right: 12px; bottom:
|
|
2648
|
+
position: fixed; left: 12px; right: 12px; bottom: ${bottomOffset(12)};
|
|
2590
2649
|
max-width: 540px; margin: 0 auto;
|
|
2591
2650
|
background: ${bg}; color: ${fg}; border-radius: 12px;
|
|
2592
2651
|
padding: 10px 14px; z-index: 999997;
|
|
@@ -3069,14 +3128,37 @@ function isProductCard(card) {
|
|
|
3069
3128
|
return Boolean(m2.product_id || m2.sku);
|
|
3070
3129
|
}
|
|
3071
3130
|
function isProductRailCards(cards) {
|
|
3072
|
-
return cards.
|
|
3131
|
+
return cards.some(isProductCard);
|
|
3132
|
+
}
|
|
3133
|
+
function productRailOrder(cards) {
|
|
3134
|
+
const all = cards.map((card, index) => ({ card, index }));
|
|
3135
|
+
return [...all.filter((e) => isProductCard(e.card)), ...all.filter((e) => !isProductCard(e.card))];
|
|
3073
3136
|
}
|
|
3074
3137
|
function productRailAccent(ctx) {
|
|
3075
|
-
return
|
|
3138
|
+
return resolveAccent(ctx.campaign.background_color, ctx.sanitizeColor);
|
|
3139
|
+
}
|
|
3140
|
+
function clampOpt(v, lo, hi) {
|
|
3141
|
+
if (v === void 0 || v === null || v === "") return void 0;
|
|
3142
|
+
const n = Number(v);
|
|
3143
|
+
if (!Number.isFinite(n)) return void 0;
|
|
3144
|
+
return Math.max(lo, Math.min(hi, n));
|
|
3145
|
+
}
|
|
3146
|
+
function productRailStyle(ctx) {
|
|
3147
|
+
const ic = ctx.campaign.interactive_config || {};
|
|
3148
|
+
const tc = ctx.campaign.text_color;
|
|
3149
|
+
const wRaw = ic.heading_font_weight != null ? String(ic.heading_font_weight) : "";
|
|
3150
|
+
return {
|
|
3151
|
+
fg: typeof tc === "string" && tc.trim() ? ctx.sanitizeColor(tc.trim()) : "#0f172a",
|
|
3152
|
+
weight: ["400", "500", "600", "700", "800"].includes(wRaw) ? wRaw : "700",
|
|
3153
|
+
padX: clampOpt(ic.padding_x, 0, 32) ?? 0,
|
|
3154
|
+
padY: clampOpt(ic.padding_y, 0, 24) ?? 0,
|
|
3155
|
+
radius: clampOpt(ic.border_radius, 0, 24) ?? 0
|
|
3156
|
+
};
|
|
3076
3157
|
}
|
|
3077
3158
|
function renderProductRailSection(ctx, target, opts) {
|
|
3078
3159
|
const { campaign } = ctx;
|
|
3079
|
-
const
|
|
3160
|
+
const style = productRailStyle(ctx);
|
|
3161
|
+
const fg = style.fg;
|
|
3080
3162
|
const accent = productRailAccent(ctx);
|
|
3081
3163
|
const layout = opts.layout || "row";
|
|
3082
3164
|
const section = document.createElement("section");
|
|
@@ -3086,12 +3168,14 @@ function renderProductRailSection(ctx, target, opts) {
|
|
|
3086
3168
|
section.style.cssText = `
|
|
3087
3169
|
${fontFamilyCss("body")}
|
|
3088
3170
|
color: ${fg};
|
|
3171
|
+
${style.padX || style.padY ? `padding: ${style.padY}px ${style.padX}px;` : ""}
|
|
3172
|
+
${style.radius ? `border-radius: ${style.radius}px;` : ""}
|
|
3089
3173
|
`;
|
|
3090
3174
|
if (opts.heading) {
|
|
3091
3175
|
const title = document.createElement("h2");
|
|
3092
3176
|
title.textContent = opts.heading;
|
|
3093
3177
|
title.setAttribute("data-aegis-rail-heading", "");
|
|
3094
|
-
title.style.cssText =
|
|
3178
|
+
title.style.cssText = `font-weight: ${style.weight}; font-size: 16px; margin: 0 0 2px; color: ${fg};`;
|
|
3095
3179
|
section.appendChild(title);
|
|
3096
3180
|
}
|
|
3097
3181
|
if (opts.subtitle) {
|
|
@@ -3110,12 +3194,13 @@ function renderProductRailSection(ctx, target, opts) {
|
|
|
3110
3194
|
} else {
|
|
3111
3195
|
strip.style.cssText = `
|
|
3112
3196
|
display: flex; gap: 10px; overflow-x: auto;
|
|
3113
|
-
scroll-snap-type: x proximity; padding:
|
|
3197
|
+
scroll-snap-type: x proximity; padding: 2px 2px 12px; scroll-padding: 0 2px;
|
|
3114
3198
|
-webkit-overflow-scrolling: touch; scrollbar-width: none;
|
|
3115
3199
|
`;
|
|
3116
3200
|
strip.style.msOverflowStyle = "none";
|
|
3117
3201
|
}
|
|
3118
|
-
opts.cards.
|
|
3202
|
+
const order = opts.productsFirst ? productRailOrder(opts.cards) : opts.cards.map((card, index) => ({ card, index }));
|
|
3203
|
+
order.forEach(({ card: c, index: i }) => {
|
|
3119
3204
|
const tile = renderCardFromTemplate(c, {
|
|
3120
3205
|
template: opts.template,
|
|
3121
3206
|
ctx,
|
|
@@ -3136,7 +3221,7 @@ function renderProductRailSection(ctx, target, opts) {
|
|
|
3136
3221
|
arrow.innerHTML = "›";
|
|
3137
3222
|
arrow.style.cssText = `
|
|
3138
3223
|
position: absolute; top: 50%; right: 0; transform: translateY(-50%);
|
|
3139
|
-
width: 30px; height: 30px; border-radius: 999px; border: 1px solid ${fg}
|
|
3224
|
+
width: 30px; height: 30px; border-radius: 999px; border: 1px solid color-mix(in srgb, ${fg} 10%, transparent);
|
|
3140
3225
|
background: #fff; color: ${fg}; font-size: 18px; line-height: 1; cursor: pointer;
|
|
3141
3226
|
box-shadow: 0 2px 8px rgba(0,0,0,0.12); display: flex; align-items: center;
|
|
3142
3227
|
justify-content: center; z-index: 2;
|
|
@@ -3175,7 +3260,7 @@ function renderProductRecommendation(ctx) {
|
|
|
3175
3260
|
addAnimationStyles();
|
|
3176
3261
|
const bg = "#ffffff";
|
|
3177
3262
|
const fg = "#0f172a";
|
|
3178
|
-
const accent =
|
|
3263
|
+
const accent = resolveAccent(campaign.background_color, sanitizeColor);
|
|
3179
3264
|
const overlay = document.createElement("div");
|
|
3180
3265
|
overlay.className = "aegis-in-app-product-rec";
|
|
3181
3266
|
overlay.setAttribute("data-campaign-id", campaign.id);
|
|
@@ -4737,8 +4822,9 @@ function renderVideoInline(ctx, target) {
|
|
|
4737
4822
|
return true;
|
|
4738
4823
|
}
|
|
4739
4824
|
const HEX = /^#[0-9a-fA-F]{3,8}$/;
|
|
4740
|
-
|
|
4741
|
-
|
|
4825
|
+
const RADIUS_PX = { none: 0, lg: 8, xl: 12, "2xl": 16 };
|
|
4826
|
+
function heroRadiusPx(radius) {
|
|
4827
|
+
return radius !== void 0 && Object.prototype.hasOwnProperty.call(RADIUS_PX, radius) ? RADIUS_PX[radius] : void 0;
|
|
4742
4828
|
}
|
|
4743
4829
|
const ASPECT = { "16:9": "16 / 9", "4:3": "4 / 3", "21:9": "21 / 9" };
|
|
4744
4830
|
const HERO_DESKTOP_RATIO = "8 / 3";
|
|
@@ -4756,7 +4842,7 @@ function _injectHeroResponsiveCss() {
|
|
|
4756
4842
|
if (document.getElementById("aegis-hero-style")) return;
|
|
4757
4843
|
const style = document.createElement("style");
|
|
4758
4844
|
style.id = "aegis-hero-style";
|
|
4759
|
-
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;}}`;
|
|
4845
|
+
style.textContent = `.aegis-hero-root{border-radius:var(--aegis-hero-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;}}`;
|
|
4760
4846
|
document.head.appendChild(style);
|
|
4761
4847
|
}
|
|
4762
4848
|
function srcsetUrl$1(url) {
|
|
@@ -4787,38 +4873,103 @@ function cardUrl(c) {
|
|
|
4787
4873
|
if (t && t.value) return t.type === "category" ? `?category=${encodeURIComponent(t.value)}` : t.value;
|
|
4788
4874
|
return "";
|
|
4789
4875
|
}
|
|
4876
|
+
function announcementContent(campaign, card) {
|
|
4877
|
+
const ic = campaign.interactive_config || {};
|
|
4878
|
+
const head = card ? cardHeadline(card) : campaign.title || "";
|
|
4879
|
+
const sub = card ? cardSub(card) : campaign.body || "";
|
|
4880
|
+
const text = [head, sub].filter(Boolean).join(" · ");
|
|
4881
|
+
const coupon = typeof ic.coupon_code === "string" ? ic.coupon_code.trim() : "";
|
|
4882
|
+
const ctaUrl = (card ? cardUrl(card) : "") || campaign.action_url || "";
|
|
4883
|
+
const ctaText = (card ? cardCta(card) : "") || campaign.button_text || (ctaUrl ? "Order now" : "");
|
|
4884
|
+
if (!text && !coupon && !ctaText) return null;
|
|
4885
|
+
return { text, coupon, ctaText, ctaUrl };
|
|
4886
|
+
}
|
|
4887
|
+
function _injectAnnouncementCss() {
|
|
4888
|
+
if (typeof document === "undefined" || !document.head) return;
|
|
4889
|
+
if (document.getElementById("aegis-announcement-style")) return;
|
|
4890
|
+
const style = document.createElement("style");
|
|
4891
|
+
style.id = "aegis-announcement-style";
|
|
4892
|
+
style.textContent = `@media (min-width:${HERO_PHONE_MAX_WIDTH_PX + 1}px){.aegis-announcement-bar{flex-wrap:nowrap !important;}.aegis-announcement-text{flex:1 1 auto;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.aegis-announcement-coupon,.aegis-announcement-cta{flex:none;}}`;
|
|
4893
|
+
document.head.appendChild(style);
|
|
4894
|
+
}
|
|
4895
|
+
function renderAnnouncementBar(ctx, card, accent) {
|
|
4896
|
+
const { campaign, sanitizeUrl: sanitizeUrl2, trackEvent } = ctx;
|
|
4897
|
+
const content = announcementContent(campaign, card);
|
|
4898
|
+
if (!content) return null;
|
|
4899
|
+
_injectAnnouncementCss();
|
|
4900
|
+
const bar = document.createElement("div");
|
|
4901
|
+
bar.className = "aegis-announcement-bar";
|
|
4902
|
+
bar.setAttribute("data-campaign-id", campaign.id);
|
|
4903
|
+
bar.style.cssText = `display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;column-gap:10px;row-gap:4px;min-height:34px;box-sizing:border-box;background:${accent};color:#fff;padding:7px 16px;font-weight:600;font-size:13px;line-height:1.35;${fontFamilyCss("body")}text-align:left;`;
|
|
4904
|
+
if (content.text) {
|
|
4905
|
+
const t = document.createElement("span");
|
|
4906
|
+
t.className = "aegis-announcement-text";
|
|
4907
|
+
t.setAttribute("data-aegis-announcement-text", "");
|
|
4908
|
+
t.style.cssText = "min-width:0;overflow-wrap:anywhere;";
|
|
4909
|
+
t.textContent = content.text;
|
|
4910
|
+
bar.appendChild(t);
|
|
4911
|
+
}
|
|
4912
|
+
if (content.coupon) {
|
|
4913
|
+
const chip = document.createElement("button");
|
|
4914
|
+
chip.type = "button";
|
|
4915
|
+
chip.className = "aegis-announcement-coupon";
|
|
4916
|
+
chip.setAttribute("data-aegis-announcement-coupon", "");
|
|
4917
|
+
chip.setAttribute("aria-label", `Copy code ${content.coupon}`);
|
|
4918
|
+
chip.style.cssText = "border:1px dashed rgba(255,255,255,0.75);background:rgba(255,255,255,0.14);color:inherit;border-radius:6px;padding:1px 8px;font:inherit;font-family:ui-monospace,monospace;font-size:12px;letter-spacing:0.04em;cursor:pointer;white-space:nowrap;";
|
|
4919
|
+
chip.textContent = content.coupon;
|
|
4920
|
+
chip.addEventListener("click", (e) => {
|
|
4921
|
+
var _a;
|
|
4922
|
+
e.stopPropagation();
|
|
4923
|
+
try {
|
|
4924
|
+
void ((_a = navigator.clipboard) == null ? void 0 : _a.writeText(content.coupon));
|
|
4925
|
+
chip.textContent = "Copied";
|
|
4926
|
+
} catch {
|
|
4927
|
+
}
|
|
4928
|
+
setTimeout(() => {
|
|
4929
|
+
chip.textContent = content.coupon;
|
|
4930
|
+
}, 1500);
|
|
4931
|
+
});
|
|
4932
|
+
bar.appendChild(chip);
|
|
4933
|
+
}
|
|
4934
|
+
const url = content.ctaUrl ? sanitizeUrl2(content.ctaUrl) : "";
|
|
4935
|
+
if (url && content.ctaText) {
|
|
4936
|
+
const a = document.createElement("a");
|
|
4937
|
+
a.className = "aegis-announcement-cta";
|
|
4938
|
+
a.setAttribute("data-aegis-announcement-cta", "");
|
|
4939
|
+
a.href = url;
|
|
4940
|
+
a.style.cssText = "color:inherit;text-decoration:underline;text-underline-offset:2px;cursor:pointer;white-space:nowrap;font-weight:700;";
|
|
4941
|
+
a.textContent = `${content.ctaText} ›`;
|
|
4942
|
+
a.addEventListener("click", (e) => {
|
|
4943
|
+
e.preventDefault();
|
|
4944
|
+
trackEvent(campaign.id, "clicked");
|
|
4945
|
+
if (ctx.navigate) ctx.navigate(url);
|
|
4946
|
+
else if (typeof window !== "undefined") window.location.assign(url);
|
|
4947
|
+
});
|
|
4948
|
+
bar.appendChild(a);
|
|
4949
|
+
}
|
|
4950
|
+
return bar;
|
|
4951
|
+
}
|
|
4952
|
+
function heroAccent(chrome, backgroundColor) {
|
|
4953
|
+
if (chrome.accent && chrome.accent !== "brand" && HEX.test(chrome.accent)) return chrome.accent;
|
|
4954
|
+
if (backgroundColor && HEX.test(backgroundColor)) return backgroundColor;
|
|
4955
|
+
return brandAccentCss();
|
|
4956
|
+
}
|
|
4790
4957
|
function renderHeroInline(ctx, target) {
|
|
4791
4958
|
const { campaign, sanitizeUrl: sanitizeUrl2, trackEvent } = ctx;
|
|
4792
4959
|
const ic = campaign.interactive_config || {};
|
|
4793
4960
|
const cards = Array.isArray(ic.cards) ? ic.cards : [];
|
|
4794
|
-
if (cards.length === 0) return false;
|
|
4795
4961
|
const chrome = ic.chrome || {};
|
|
4796
|
-
const accent =
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
);
|
|
4800
|
-
const variant = chrome.variant ?? "hero_fullbleed";
|
|
4962
|
+
const accent = heroAccent(chrome, campaign.background_color);
|
|
4963
|
+
const isAnnouncement = campaign.widget_category === "announcement";
|
|
4964
|
+
const variant = chrome.variant ?? (isAnnouncement ? "announcement_bar" : "hero_fullbleed");
|
|
4801
4965
|
if (variant === "announcement_bar") {
|
|
4802
|
-
const
|
|
4803
|
-
|
|
4804
|
-
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;`;
|
|
4805
|
-
bar.textContent = [cardHeadline(c), cardSub(c)].filter(Boolean).join(" · ");
|
|
4806
|
-
const url = sanitizeUrl2(cardUrl(c));
|
|
4807
|
-
if (url && cardCta(c)) {
|
|
4808
|
-
const a = document.createElement("span");
|
|
4809
|
-
a.style.cssText = "text-decoration:underline;cursor:pointer;white-space:nowrap;";
|
|
4810
|
-
a.textContent = cardCta(c);
|
|
4811
|
-
a.addEventListener("click", () => {
|
|
4812
|
-
var _a;
|
|
4813
|
-
trackEvent(campaign.id, "clicked");
|
|
4814
|
-
(_a = ctx.navigate) == null ? void 0 : _a.call(ctx, url);
|
|
4815
|
-
});
|
|
4816
|
-
bar.appendChild(a);
|
|
4817
|
-
}
|
|
4966
|
+
const bar = renderAnnouncementBar(ctx, cards[0] ?? null, accent);
|
|
4967
|
+
if (!bar) return false;
|
|
4818
4968
|
target.appendChild(bar);
|
|
4819
4969
|
trackEvent(campaign.id, "impression");
|
|
4820
4970
|
return true;
|
|
4821
4971
|
}
|
|
4972
|
+
if (cards.length === 0) return false;
|
|
4822
4973
|
_injectHeroResponsiveCss();
|
|
4823
4974
|
const explicitRatio = chrome.aspect_ratio ? ASPECT[chrome.aspect_ratio] : void 0;
|
|
4824
4975
|
const hasPhoneImage = cards.some(
|
|
@@ -4826,7 +4977,8 @@ function renderHeroInline(ctx, target) {
|
|
|
4826
4977
|
);
|
|
4827
4978
|
const root = document.createElement("div");
|
|
4828
4979
|
root.className = explicitRatio ? "aegis-hero-root" : `aegis-hero-root aegis-hero-auto${hasPhoneImage ? " aegis-hero-phone-square" : ""}`;
|
|
4829
|
-
|
|
4980
|
+
const radiusPx = heroRadiusPx(chrome.radius);
|
|
4981
|
+
root.style.cssText = `position:relative;width:100%;overflow:hidden;box-shadow:0 1px 2px rgba(16,24,40,0.06);${explicitRatio ? `aspect-ratio:${explicitRatio};` : ""}${radiusPx !== void 0 ? `--aegis-hero-radius:${radiusPx}px;` : ""}`;
|
|
4830
4982
|
root.setAttribute("data-campaign-id", campaign.id);
|
|
4831
4983
|
const track = document.createElement("div");
|
|
4832
4984
|
track.style.cssText = "display:flex;height:100%;width:100%;transition:transform 0.5s ease;";
|
|
@@ -7772,12 +7924,17 @@ function renderReviewsInline(ctx, target, creds) {
|
|
|
7772
7924
|
}
|
|
7773
7925
|
function renderReviewsOverlay(ctx, creds) {
|
|
7774
7926
|
if (typeof document === "undefined" || !(creds == null ? void 0 : creds.apiHost) || !(creds == null ? void 0 : creds.writeKey)) return;
|
|
7927
|
+
injectOverlayLayoutCss();
|
|
7775
7928
|
const overlay = document.createElement("div");
|
|
7929
|
+
overlay.className = "aegis-sheet-overlay";
|
|
7776
7930
|
overlay.setAttribute("data-campaign-id", ctx.campaign.id);
|
|
7777
7931
|
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;";
|
|
7778
7932
|
const sheet = document.createElement("div");
|
|
7933
|
+
sheet.className = "aegis-sheet";
|
|
7779
7934
|
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);`;
|
|
7780
|
-
|
|
7935
|
+
const grabber = el("div", "width:38px;height:4px;border-radius:999px;background:#e5e7eb;margin:0 auto 14px;");
|
|
7936
|
+
grabber.className = "aegis-sheet-grabber";
|
|
7937
|
+
sheet.appendChild(grabber);
|
|
7781
7938
|
const bar = el("div", "display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;");
|
|
7782
7939
|
bar.appendChild(el("div", "font-weight:800;font-size:17px;", ctx.campaign.title || "Customer reviews"));
|
|
7783
7940
|
const close = el("button", "background:none;border:none;cursor:pointer;padding:4px 8px;color:#6b7280;");
|
|
@@ -8165,6 +8322,21 @@ function pickSlotWinners(campaigns, opts = {}) {
|
|
|
8165
8322
|
});
|
|
8166
8323
|
return out;
|
|
8167
8324
|
}
|
|
8325
|
+
function slotKind(c) {
|
|
8326
|
+
const sub = typeof c.sub_type === "string" ? c.sub_type.trim() : "";
|
|
8327
|
+
if (sub && sub !== "standard") return sub;
|
|
8328
|
+
return typeof c.type === "string" ? c.type : "";
|
|
8329
|
+
}
|
|
8330
|
+
function stepsAsFormFields(ic, title) {
|
|
8331
|
+
const raw = Array.isArray(ic.steps) ? ic.steps : [];
|
|
8332
|
+
const steps = raw.length > 0 ? raw : [{ question: title || "Tell us more", options: [] }];
|
|
8333
|
+
return steps.map((step, i) => {
|
|
8334
|
+
const key = typeof step.key === "string" && step.key ? step.key : `step_${i + 1}`;
|
|
8335
|
+
const label = typeof step.question === "string" && step.question || typeof step.label === "string" && step.label || `Step ${i + 1}`;
|
|
8336
|
+
const options = Array.isArray(step.options) ? step.options.filter((o) => typeof o === "string" && o !== "") : [];
|
|
8337
|
+
return options.length > 0 ? { key, label, type: "select", options, required: step.required === true } : { key, label, type: "text", required: step.required === true };
|
|
8338
|
+
});
|
|
8339
|
+
}
|
|
8168
8340
|
const SECTION_SPOT_SELECTOR_PREFIX = "[data-aegis-section-spot=";
|
|
8169
8341
|
function isSectionSpotSelector(selector) {
|
|
8170
8342
|
return typeof selector === "string" && selector.trim().startsWith(SECTION_SPOT_SELECTOR_PREFIX);
|
|
@@ -10400,16 +10572,17 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
10400
10572
|
return;
|
|
10401
10573
|
}
|
|
10402
10574
|
this._ensureSurveyTemplate(campaign);
|
|
10403
|
-
const
|
|
10404
|
-
|
|
10405
|
-
|
|
10406
|
-
} else if (campaign.widget_category === "hero") {
|
|
10575
|
+
const kind = slotKind(campaign);
|
|
10576
|
+
const _isMultiCard = kind === "product_recommendation" || kind === "carousel_cards";
|
|
10577
|
+
if (campaign.widget_category === "hero" || campaign.widget_category === "announcement") {
|
|
10407
10578
|
const heroCtx = this.buildRenderContext(campaign);
|
|
10408
10579
|
const heroSlot = target.closest("[data-aegis-slot]");
|
|
10409
10580
|
heroCtx.shellImage = heroSlot ? this.shellHeroImages.get(heroSlot) ?? null : null;
|
|
10410
10581
|
rendered = renderHeroInline(heroCtx, target);
|
|
10582
|
+
} else if (this._hasComposedTemplate(ic) && !_isMultiCard) {
|
|
10583
|
+
rendered = this.renderComposedCardSlot(campaign, ic, target);
|
|
10411
10584
|
} else
|
|
10412
|
-
switch (
|
|
10585
|
+
switch (kind) {
|
|
10413
10586
|
// P6.full — star_rating / nps_survey / quick_poll slots route through the
|
|
10414
10587
|
// unified composed-card slot engine via `_ensureSurveyTemplate` (the gate
|
|
10415
10588
|
// above), so the bespoke *Slot survey renderers are RETIRED.
|
|
@@ -10448,16 +10621,20 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
10448
10621
|
writeKey: this.writeKey
|
|
10449
10622
|
});
|
|
10450
10623
|
break;
|
|
10624
|
+
case "multi_step_form": {
|
|
10625
|
+
const stepFields = stepsAsFormFields(ic, campaign.title);
|
|
10626
|
+
rendered = this.renderFormSlot(campaign, stepFields, bg, text, target);
|
|
10627
|
+
break;
|
|
10628
|
+
}
|
|
10451
10629
|
case "quiz":
|
|
10452
10630
|
rendered = this.renderQuizSlot(campaign, ic, bg, text, target);
|
|
10453
10631
|
if (!rendered) {
|
|
10454
10632
|
rendered = this.renderGenericCardSlot(campaign, ic, bg, text, target);
|
|
10455
10633
|
}
|
|
10456
10634
|
break;
|
|
10457
|
-
// Remaining
|
|
10458
|
-
//
|
|
10459
|
-
//
|
|
10460
|
-
// here as merchants need them.
|
|
10635
|
+
// Remaining kinds (sticky_bar, pip, banner, modal, ...) render as a
|
|
10636
|
+
// generic card in a slot (the overlay path handles their full UX);
|
|
10637
|
+
// dedicated slot variants get added here as merchants need them.
|
|
10461
10638
|
default:
|
|
10462
10639
|
rendered = this.renderGenericCardSlot(campaign, ic, bg, text, target);
|
|
10463
10640
|
break;
|
|
@@ -10576,7 +10753,9 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
10576
10753
|
template,
|
|
10577
10754
|
ctx,
|
|
10578
10755
|
action: "navigate",
|
|
10579
|
-
|
|
10756
|
+
// The palette accent may be the brand var expression: never pass it
|
|
10757
|
+
// through sanitizeColor (which turns var() into #000000).
|
|
10758
|
+
layoutAccent: campaign.background_color ? this.sanitizeColor(campaign.background_color) : accent
|
|
10580
10759
|
});
|
|
10581
10760
|
target.appendChild(tile);
|
|
10582
10761
|
return true;
|
|
@@ -10616,7 +10795,9 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
10616
10795
|
template,
|
|
10617
10796
|
ctx: this.buildRenderContext(campaign),
|
|
10618
10797
|
action: "navigate",
|
|
10619
|
-
|
|
10798
|
+
// The palette accent may be the brand var expression: never pass it
|
|
10799
|
+
// through sanitizeColor (which turns var() into #000000).
|
|
10800
|
+
layoutAccent: campaign.background_color ? this.sanitizeColor(campaign.background_color) : accent
|
|
10620
10801
|
});
|
|
10621
10802
|
modal.appendChild(tile);
|
|
10622
10803
|
this._addCornerClose(modal, overlay, campaign.id, text);
|
|
@@ -10709,7 +10890,8 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
10709
10890
|
if (buttonText) {
|
|
10710
10891
|
const btn = document.createElement("button");
|
|
10711
10892
|
btn.textContent = buttonText;
|
|
10712
|
-
|
|
10893
|
+
const pal = this._surfacePalette(campaign);
|
|
10894
|
+
btn.style.cssText = `margin-top: 2px; align-self: flex-start; padding: 8px 14px; border-radius: ${st.btnRadius ?? 9}px; border: none; background: ${pal.btnBg}; color: ${pal.btnText}; font-size: 13px; font-weight: 600; cursor: pointer;`;
|
|
10713
10895
|
btn.addEventListener("click", () => {
|
|
10714
10896
|
void this.trackEvent(campaign.id, "clicked");
|
|
10715
10897
|
if (actionUrl) window.open(actionUrl, "_blank", "noopener");
|
|
@@ -11694,7 +11876,8 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
11694
11876
|
layout,
|
|
11695
11877
|
template: resolveGlobalTemplate(ic),
|
|
11696
11878
|
className: "aegis-in-app-carousel-rail",
|
|
11697
|
-
actionFor: () => "cart"
|
|
11879
|
+
actionFor: (c) => isProductCard(c) ? "cart" : "navigate",
|
|
11880
|
+
productsFirst: true
|
|
11698
11881
|
});
|
|
11699
11882
|
this._carouselAutoplay(ic, layout, cards.length, strip2);
|
|
11700
11883
|
return true;
|
|
@@ -12232,7 +12415,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
12232
12415
|
*/
|
|
12233
12416
|
_slotStyle(campaign) {
|
|
12234
12417
|
const ic = campaign.interactive_config || {};
|
|
12235
|
-
const
|
|
12418
|
+
const clampOpt2 = (v, lo, hi) => {
|
|
12236
12419
|
if (v === void 0 || v === null || v === "") return void 0;
|
|
12237
12420
|
const n = Number(v);
|
|
12238
12421
|
if (!Number.isFinite(n)) return void 0;
|
|
@@ -12243,10 +12426,10 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
12243
12426
|
return {
|
|
12244
12427
|
bg: pal.bg,
|
|
12245
12428
|
text: pal.text,
|
|
12246
|
-
radius:
|
|
12247
|
-
padX:
|
|
12248
|
-
padY:
|
|
12249
|
-
btnRadius:
|
|
12429
|
+
radius: clampOpt2(ic.border_radius, 0, 24) ?? 12,
|
|
12430
|
+
padX: clampOpt2(ic.padding_x, 0, 32),
|
|
12431
|
+
padY: clampOpt2(ic.padding_y, 0, 24),
|
|
12432
|
+
btnRadius: clampOpt2(ic.button_radius, 0, 999),
|
|
12250
12433
|
weight: ["400", "500", "600", "700"].includes(wRaw) ? wRaw : void 0
|
|
12251
12434
|
};
|
|
12252
12435
|
}
|
|
@@ -12335,7 +12518,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
12335
12518
|
this.log(`campaign ${campaign.id} not drawn: overlays held by the host`);
|
|
12336
12519
|
return;
|
|
12337
12520
|
}
|
|
12338
|
-
const willShow = { target: "overlay" };
|
|
12521
|
+
const willShow = { target: "overlay", anchor: overlayAnchor(campaign) };
|
|
12339
12522
|
const proceed = this.emit("campaign-will-show", campaign, willShow);
|
|
12340
12523
|
if (!proceed) {
|
|
12341
12524
|
this.log(`campaign ${campaign.id} suppressed by campaign-will-show handler`);
|
|
@@ -13594,7 +13777,10 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
13594
13777
|
* fill when branded, CTA accent when clean. */
|
|
13595
13778
|
_surfacePalette(campaign) {
|
|
13596
13779
|
const ic = campaign.interactive_config || {};
|
|
13597
|
-
const
|
|
13780
|
+
const explicit = campaign.background_color ? this.sanitizeColor(campaign.background_color) : "";
|
|
13781
|
+
const hostBrand = explicit ? "" : readBrandAccent() || "";
|
|
13782
|
+
const brand = explicit || hostBrand || brandAccentCss();
|
|
13783
|
+
const brandInk = explicit || hostBrand ? this._contrastText(explicit || hostBrand) : "#ffffff";
|
|
13598
13784
|
const surface = ic.surface_style;
|
|
13599
13785
|
if (surface === "branded") {
|
|
13600
13786
|
const bg = brand;
|
|
@@ -13606,7 +13792,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
13606
13792
|
const text = campaign.text_color ? this.sanitizeColor(campaign.text_color) : "#ffffff";
|
|
13607
13793
|
return { bg, text, btnBg: "#ffffff", btnText: bg, accent: text, branded: false };
|
|
13608
13794
|
}
|
|
13609
|
-
return { bg: "#ffffff", text: "#0f172a", btnBg: brand, btnText:
|
|
13795
|
+
return { bg: "#ffffff", text: "#0f172a", btnBg: brand, btnText: brandInk, accent: brand, branded: false };
|
|
13610
13796
|
}
|
|
13611
13797
|
inAppStyle(campaign) {
|
|
13612
13798
|
const ic = campaign.interactive_config || {};
|
|
@@ -13642,7 +13828,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
13642
13828
|
const atBottom = ic.banner_position === "bottom";
|
|
13643
13829
|
banner.style.cssText = `
|
|
13644
13830
|
position: fixed;
|
|
13645
|
-
${atBottom ?
|
|
13831
|
+
${atBottom ? `bottom: ${bottomOffset(0)};` : "top: 0;"}
|
|
13646
13832
|
left: 0;
|
|
13647
13833
|
right: 0;
|
|
13648
13834
|
background: ${st.bg};
|
|
@@ -14314,15 +14500,17 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
14314
14500
|
// Corner → fixed-position CSS for the floating PiP card.
|
|
14315
14501
|
_pipCornerCss(position, gap) {
|
|
14316
14502
|
switch (position) {
|
|
14503
|
+
// Bottom corners sit above the host's dock / launcher / cart pill
|
|
14504
|
+
// (`--aegis-bottom-reserve`, overlay-layout.ts, 1.52.0).
|
|
14317
14505
|
case "bottom-left":
|
|
14318
|
-
return `bottom: ${gap}
|
|
14506
|
+
return `bottom: ${bottomOffset(gap)}; left: ${gap}px;`;
|
|
14319
14507
|
case "top-right":
|
|
14320
14508
|
return `top: ${gap}px; right: ${gap}px;`;
|
|
14321
14509
|
case "top-left":
|
|
14322
14510
|
return `top: ${gap}px; left: ${gap}px;`;
|
|
14323
14511
|
case "bottom-right":
|
|
14324
14512
|
default:
|
|
14325
|
-
return `bottom: ${gap}
|
|
14513
|
+
return `bottom: ${bottomOffset(gap)}; right: ${gap}px;`;
|
|
14326
14514
|
}
|
|
14327
14515
|
}
|
|
14328
14516
|
renderPIP(campaign) {
|
|
@@ -18054,7 +18242,7 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
|
|
|
18054
18242
|
this.initialized = false;
|
|
18055
18243
|
this.armedInAppTriggers = /* @__PURE__ */ new Set();
|
|
18056
18244
|
{
|
|
18057
|
-
const v = "1.
|
|
18245
|
+
const v = "1.52.0";
|
|
18058
18246
|
try {
|
|
18059
18247
|
globalThis.__AEGIS_SDK_VERSION__ = v;
|
|
18060
18248
|
} catch {
|
|
@@ -18549,6 +18737,8 @@ export {
|
|
|
18549
18737
|
AegisLoyaltyManager,
|
|
18550
18738
|
AegisMessageRuntime,
|
|
18551
18739
|
A as AegisWebPush,
|
|
18740
|
+
BOTTOM_RESERVE_VAR,
|
|
18741
|
+
BRAND_ACCENT_VAR,
|
|
18552
18742
|
B as BloomFilter,
|
|
18553
18743
|
BootstrapError,
|
|
18554
18744
|
DEFAULT_RAIL_TITLES,
|
|
@@ -18576,6 +18766,7 @@ export {
|
|
|
18576
18766
|
m as murmurhash3_x86_32,
|
|
18577
18767
|
onLauncherChange,
|
|
18578
18768
|
openChat,
|
|
18769
|
+
overlayAnchor,
|
|
18579
18770
|
parseAction,
|
|
18580
18771
|
readFirstPartyCookie,
|
|
18581
18772
|
renderPreview,
|