@active-reach/web-sdk 1.48.0 → 1.50.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 (55) hide show
  1. package/dist/aegis.min.js +1 -1
  2. package/dist/aegis.min.js.map +1 -1
  3. package/dist/{analytics-zA6ckfKP.mjs → analytics-DMY0Q0rI.mjs} +911 -312
  4. package/dist/analytics-DMY0Q0rI.mjs.map +1 -0
  5. package/dist/chat/AegisChat.d.ts +20 -0
  6. package/dist/chat/AegisChat.d.ts.map +1 -1
  7. package/dist/chat/index.d.ts +1 -1
  8. package/dist/chat/index.d.ts.map +1 -1
  9. package/dist/core/analytics.d.ts.map +1 -1
  10. package/dist/core/bootstrap.d.ts +2 -1
  11. package/dist/core/bootstrap.d.ts.map +1 -1
  12. package/dist/core/prefetch-bundle-client.d.ts.map +1 -1
  13. package/dist/core/purchase-backlog.d.ts +141 -0
  14. package/dist/core/purchase-backlog.d.ts.map +1 -0
  15. package/dist/core/purchase-events.d.ts +25 -0
  16. package/dist/core/purchase-events.d.ts.map +1 -0
  17. package/dist/core/queue.d.ts +39 -0
  18. package/dist/core/queue.d.ts.map +1 -1
  19. package/dist/core/sdk-config-poller.d.ts.map +1 -1
  20. package/dist/core/transport.d.ts +74 -1
  21. package/dist/core/transport.d.ts.map +1 -1
  22. package/dist/ecommerce/index.d.ts +1 -1
  23. package/dist/ecommerce/index.d.ts.map +1 -1
  24. package/dist/ecommerce/types.d.ts +10 -0
  25. package/dist/ecommerce/types.d.ts.map +1 -1
  26. package/dist/governance/trait-governor.d.ts +13 -6
  27. package/dist/governance/trait-governor.d.ts.map +1 -1
  28. package/dist/inapp/AegisInAppManager.d.ts +94 -6
  29. package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
  30. package/dist/inapp/anon-claim.d.ts +36 -0
  31. package/dist/inapp/anon-claim.d.ts.map +1 -0
  32. package/dist/inapp/index.d.ts +1 -1
  33. package/dist/inapp/index.d.ts.map +1 -1
  34. package/dist/inapp/prize-retry.d.ts +51 -0
  35. package/dist/inapp/prize-retry.d.ts.map +1 -0
  36. package/dist/inapp/rail-fallback.d.ts +83 -0
  37. package/dist/inapp/rail-fallback.d.ts.map +1 -0
  38. package/dist/inapp/renderers/games.d.ts.map +1 -1
  39. package/dist/inapp/renderers/types.d.ts +12 -0
  40. package/dist/inapp/renderers/types.d.ts.map +1 -1
  41. package/dist/inapp/section-spot-lineup.d.ts +43 -0
  42. package/dist/inapp/section-spot-lineup.d.ts.map +1 -0
  43. package/dist/index.d.ts +4 -3
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +986 -145
  46. package/dist/index.js.map +1 -1
  47. package/dist/react.js +1 -1
  48. package/dist/runtime/AegisMessageRuntime.d.ts +17 -0
  49. package/dist/runtime/AegisMessageRuntime.d.ts.map +1 -1
  50. package/dist/utils/fetch-abort.d.ts +23 -0
  51. package/dist/utils/fetch-abort.d.ts.map +1 -0
  52. package/dist/utils/preview-as-of.d.ts +21 -0
  53. package/dist/utils/preview-as-of.d.ts.map +1 -0
  54. package/package.json +2 -2
  55. package/dist/analytics-zA6ckfKP.mjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Storage, r as redactUrl, a as recordInAppItemTouch, e as ensureFbc, l as logger, A as Aegis } from "./analytics-zA6ckfKP.mjs";
2
- import { B, E, N, R, U, m } from "./analytics-zA6ckfKP.mjs";
1
+ import { g as generateUUID, S as Storage, r as redactUrl, i as isPreviewPage, p as previewAsOfToken, a as recordInAppItemTouch, e as ensureFbc, l as logger, A as Aegis } from "./analytics-DMY0Q0rI.mjs";
2
+ import { B, E, N, R, U, m } from "./analytics-DMY0Q0rI.mjs";
3
3
  import { a as assetIdOf } from "./AegisWebPush-BE9wJcx0.mjs";
4
4
  import { A } from "./AegisWebPush-BE9wJcx0.mjs";
5
5
  function debounce(func, wait) {
@@ -121,6 +121,130 @@ function fallbackUrlForAction(a, productUrl = productPath) {
121
121
  return void 0;
122
122
  }
123
123
  }
124
+ const PRIZE_GRANT_RETRY = "PRIZE_GRANT_RETRY";
125
+ const ANON_CLAIM_REASON = "verify_phone_to_claim";
126
+ const SIGN_IN_TO_PLAY_REASON = "sign_in_to_play";
127
+ const PRIZE_GRANT_RETRY_MESSAGE = "We couldn't hand over this prize right now. Please try again in a moment.";
128
+ const SPIN_AGAIN_MESSAGE = "We couldn't finish this play. Please try again.";
129
+ const NON_REDEEMABLE_MESSAGE = "This prize can't be redeemed.";
130
+ const DRAW_ANSWER_TIMEOUT_MS = 8e3;
131
+ function prizeStateOf(resp, retryMessage) {
132
+ if (!resp) return { state: "spin_again", message: retryMessage || SPIN_AGAIN_MESSAGE };
133
+ const prize = resp.prize;
134
+ if (!prize || typeof prize !== "object") return { state: "loss" };
135
+ const outcome = prize.outcome;
136
+ if (outcome === "non_redeemable") {
137
+ const msg = typeof prize.message === "string" && prize.message ? prize.message : NON_REDEEMABLE_MESSAGE;
138
+ if (prize.claimable === true && prize.non_redeemable_reason === ANON_CLAIM_REASON) {
139
+ return { state: "non_redeemable", message: msg, claimable: true };
140
+ }
141
+ if (prize.non_redeemable_reason === SIGN_IN_TO_PLAY_REASON) {
142
+ return { state: "non_redeemable", message: msg, signIn: true };
143
+ }
144
+ return { state: "non_redeemable", message: msg };
145
+ }
146
+ if (outcome === "loss") return { state: "loss" };
147
+ if (prize.win === false || String(prize.prize_type || "").toLowerCase() === "no_prize") return { state: "loss" };
148
+ if (outcome === "credited_win") return { state: "credited_win" };
149
+ return prize.win === false ? { state: "loss" } : { state: "credited_win" };
150
+ }
151
+ const CLAIM_BUTTON_LABEL = "Log in or sign up to claim";
152
+ const SIGN_IN_BUTTON_LABEL = "Sign in to play";
153
+ const ANON_CLAIMS_TTL_MS = 24 * 60 * 60 * 1e3;
154
+ const CLAIM_PATH = "/v1/in-app/responses/anon-claim";
155
+ const CLAIM_RETRY_MESSAGE = "We couldn't check this prize right now. Please try again.";
156
+ const CLAIM_EVENT = "aegis:anon-claim";
157
+ function claimAnswer(body) {
158
+ if (!body) return { claimed: false, text: CLAIM_RETRY_MESSAGE, code: "" };
159
+ const prize = body.prize && typeof body.prize === "object" ? body.prize : {};
160
+ const st = prizeStateOf(body);
161
+ const label = typeof prize.prize_label === "string" ? prize.prize_label : "";
162
+ if (body.status === "claimed" && st.state === "credited_win") {
163
+ const code = typeof prize.coupon_code === "string" ? prize.coupon_code : "";
164
+ return { claimed: true, text: label ? `You claimed: ${label}` : "Prize claimed", code };
165
+ }
166
+ if (st.state === "non_redeemable") return { claimed: false, text: st.message, code: "" };
167
+ const msg = typeof body.message === "string" && body.message ? body.message : CLAIM_RETRY_MESSAGE;
168
+ return { claimed: false, text: msg, code: "" };
169
+ }
170
+ const ANON_CLAIMS_STORAGE_KEY = "aegis_anon_claims";
171
+ function loadAnonClaims() {
172
+ try {
173
+ const raw = typeof localStorage !== "undefined" ? localStorage.getItem(ANON_CLAIMS_STORAGE_KEY) : null;
174
+ if (!raw) return { pending: [], tickets: {} };
175
+ const v = JSON.parse(raw);
176
+ if (typeof v.savedAt !== "number" || Date.now() - v.savedAt > ANON_CLAIMS_TTL_MS) {
177
+ return { pending: [], tickets: {} };
178
+ }
179
+ const pending = Array.isArray(v.pending) ? v.pending.filter((x) => typeof x === "string") : [];
180
+ const tickets = {};
181
+ if (v.tickets && typeof v.tickets === "object") {
182
+ for (const [k, t] of Object.entries(v.tickets)) if (typeof t === "string") tickets[k] = t;
183
+ }
184
+ return { pending, tickets };
185
+ } catch {
186
+ return { pending: [], tickets: {} };
187
+ }
188
+ }
189
+ function saveAnonClaims(state) {
190
+ try {
191
+ if (typeof localStorage !== "undefined") {
192
+ localStorage.setItem(ANON_CLAIMS_STORAGE_KEY, JSON.stringify({ ...state, savedAt: Date.now() }));
193
+ }
194
+ } catch {
195
+ }
196
+ }
197
+ function claimButton(onClick, label = CLAIM_BUTTON_LABEL) {
198
+ const btn = document.createElement("button");
199
+ btn.type = "button";
200
+ btn.setAttribute("data-aegis-anon-claim", "");
201
+ btn.textContent = label;
202
+ btn.style.cssText = "margin-top:8px;padding:8px 14px;border:0;border-radius:8px;font-weight:600;font-size:13px;cursor:pointer;background:#111827;color:#fff;";
203
+ btn.addEventListener("click", (e) => {
204
+ e.preventDefault();
205
+ btn.disabled = true;
206
+ onClick();
207
+ });
208
+ return btn;
209
+ }
210
+ function showClaimNotice(answer, onRetry) {
211
+ var _a;
212
+ if (typeof document === "undefined" || !document.body) return;
213
+ (_a = document.querySelector("[data-aegis-anon-claim-notice]")) == null ? void 0 : _a.remove();
214
+ const box = document.createElement("div");
215
+ box.setAttribute("data-aegis-anon-claim-notice", "");
216
+ box.setAttribute("role", "status");
217
+ box.style.cssText = "position:fixed;left:16px;right:16px;bottom:16px;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:14px/1.4 system-ui,sans-serif;";
218
+ const text = document.createElement("div");
219
+ text.style.cssText = "font-weight:600;";
220
+ text.textContent = answer.text;
221
+ box.appendChild(text);
222
+ if (answer.code) {
223
+ const code = document.createElement("div");
224
+ code.style.cssText = "margin-top:6px;font-family:monospace;font-size:15px;letter-spacing:0.5px;";
225
+ code.textContent = answer.code;
226
+ box.appendChild(code);
227
+ }
228
+ if (onRetry) {
229
+ const retry = document.createElement("button");
230
+ retry.type = "button";
231
+ retry.setAttribute("data-aegis-anon-claim-retry", "");
232
+ retry.textContent = "Try again";
233
+ retry.style.cssText = "margin-top:10px;margin-right:16px;border:0;background:none;color:#111827;font-weight:600;cursor:pointer;padding:0;";
234
+ retry.addEventListener("click", () => {
235
+ box.remove();
236
+ onRetry();
237
+ });
238
+ box.appendChild(retry);
239
+ }
240
+ const close = document.createElement("button");
241
+ close.type = "button";
242
+ close.textContent = "Close";
243
+ close.style.cssText = "margin-top:10px;border:0;background:none;color:#4b5563;cursor:pointer;padding:0;";
244
+ close.addEventListener("click", () => box.remove());
245
+ box.appendChild(close);
246
+ document.body.appendChild(box);
247
+ }
124
248
  const ICONS = {
125
249
  x: [
126
250
  ["path", { d: "M18 6 6 18" }],
@@ -426,16 +550,16 @@ function readRootVar(name) {
426
550
  return "";
427
551
  }
428
552
  }
429
- function detectFontHost(read = readRootVar) {
430
- return read(ACS_BODY_FONT_VAR) ? "acs" : "third_party";
553
+ function detectFontHost(read2 = readRootVar) {
554
+ return read2(ACS_BODY_FONT_VAR) ? "acs" : "third_party";
431
555
  }
432
- function resolveRootFonts(brand, read = readRootVar) {
433
- const host = detectFontHost(read);
556
+ function resolveRootFonts(brand, read2 = readRootVar) {
557
+ const host = detectFontHost(read2);
434
558
  if (host === "acs") {
435
559
  return {
436
560
  host,
437
561
  body: `var(${ACS_BODY_FONT_VAR})`,
438
- display: read(ACS_DISPLAY_FONT_VAR) ? `var(${ACS_DISPLAY_FONT_VAR})` : `var(${ACS_BODY_FONT_VAR})`,
562
+ display: read2(ACS_DISPLAY_FONT_VAR) ? `var(${ACS_DISPLAY_FONT_VAR})` : `var(${ACS_BODY_FONT_VAR})`,
439
563
  load: []
440
564
  };
441
565
  }
@@ -476,9 +600,9 @@ function ensurePreconnect() {
476
600
  document.head.appendChild(l);
477
601
  }
478
602
  }
479
- function loadFonts(loads, read = readRootVar) {
603
+ function loadFonts(loads, read2 = readRootVar) {
480
604
  if (typeof document === "undefined" || loads.length === 0) return;
481
- if (detectFontHost(read) === "acs") return;
605
+ if (detectFontHost(read2) === "acs") return;
482
606
  let grew = false;
483
607
  for (const { font, role } of loads) {
484
608
  const known = findGoogleFont(font.name);
@@ -512,15 +636,15 @@ function loadFonts(loads, read = readRootVar) {
512
636
  }
513
637
  link.href = googleFontsHref(requested);
514
638
  }
515
- function applyRootFonts(brand, read = readRootVar) {
516
- const r = resolveRootFonts(brand, read);
639
+ function applyRootFonts(brand, read2 = readRootVar) {
640
+ const r = resolveRootFonts(brand, read2);
517
641
  if (typeof document === "undefined") return r;
518
642
  const root = document.documentElement.style;
519
643
  if (r.body) root.setProperty(AEGIS_BODY_FONT_VAR, r.body);
520
644
  else root.removeProperty(AEGIS_BODY_FONT_VAR);
521
645
  if (r.display) root.setProperty(AEGIS_DISPLAY_FONT_VAR, r.display);
522
646
  else root.removeProperty(AEGIS_DISPLAY_FONT_VAR);
523
- loadFonts(r.load, read);
647
+ loadFonts(r.load, read2);
524
648
  return r;
525
649
  }
526
650
  function campaignFontFamily(campaign) {
@@ -532,8 +656,8 @@ function campaignFontFamily(campaign) {
532
656
  }
533
657
  return void 0;
534
658
  }
535
- function campaignFontVarsCss(value, read = readRootVar) {
536
- const served = fontValueToCss(value, detectFontHost(read));
659
+ function campaignFontVarsCss(value, read2 = readRootVar) {
660
+ const served = fontValueToCss(value, detectFontHost(read2));
537
661
  if (!served) return "";
538
662
  if (served.font) {
539
663
  loadFonts(
@@ -541,19 +665,19 @@ function campaignFontVarsCss(value, read = readRootVar) {
541
665
  { font: served.font, role: "body" },
542
666
  { font: served.font, role: "display" }
543
667
  ],
544
- read
668
+ read2
545
669
  );
546
670
  }
547
671
  return `${AEGIS_BODY_FONT_VAR}:${served.css};${AEGIS_DISPLAY_FONT_VAR}:${served.css};`;
548
672
  }
549
673
  const CAMPAIGN_SHEET_ID = "aegis-campaign-fonts";
550
674
  const SAFE_ID = /^[A-Za-z0-9_-]{1,128}$/;
551
- function registerCampaignFonts(campaigns, read = readRootVar) {
675
+ function registerCampaignFonts(campaigns, read2 = readRootVar) {
552
676
  const rules = [];
553
677
  for (const c of campaigns) {
554
678
  const id = typeof c.id === "string" ? c.id : "";
555
679
  if (!SAFE_ID.test(id)) continue;
556
- const decl = campaignFontVarsCss(campaignFontFamily(c), read);
680
+ const decl = campaignFontVarsCss(campaignFontFamily(c), read2);
557
681
  if (decl) rules.push(`[data-campaign-id="${id}"]{${decl}}`);
558
682
  }
559
683
  const css = rules.join("\n");
@@ -571,11 +695,11 @@ function registerCampaignFonts(campaigns, read = readRootVar) {
571
695
  sheet.textContent = css;
572
696
  return css;
573
697
  }
574
- function applyCampaignFonts(campaigns, read = readRootVar) {
698
+ function applyCampaignFonts(campaigns, read2 = readRootVar) {
575
699
  var _a;
576
700
  const brand = ((_a = campaigns.find((c) => c.brand_typography)) == null ? void 0 : _a.brand_typography) ?? null;
577
- applyRootFonts(brand, read);
578
- registerCampaignFonts(campaigns, read);
701
+ applyRootFonts(brand, read2);
702
+ registerCampaignFonts(campaigns, read2);
579
703
  }
580
704
  const HERO_IMAGE_SIZES = "100vw";
581
705
  function cardImageSizes(kind, widthPx) {
@@ -3602,6 +3726,21 @@ function injectStoryStyles() {
3602
3726
  `;
3603
3727
  document.head.appendChild(style);
3604
3728
  }
3729
+ async function drawAnswer(ctx, submitP) {
3730
+ var _a;
3731
+ let res = null;
3732
+ try {
3733
+ res = await Promise.race([
3734
+ submitP ?? Promise.resolve(null),
3735
+ new Promise((resolve) => window.setTimeout(() => resolve(null), DRAW_ANSWER_TIMEOUT_MS))
3736
+ ]);
3737
+ } catch {
3738
+ res = null;
3739
+ }
3740
+ const st = prizeStateOf(res, ((_a = ctx.takeRetryAnswer) == null ? void 0 : _a.call(ctx)) ?? null);
3741
+ const prize = res && res.prize && typeof res.prize === "object" ? res.prize : null;
3742
+ return { st, prize };
3743
+ }
3605
3744
  function earnPct(current, threshold) {
3606
3745
  return computeProgress({ threshold, current }).pct;
3607
3746
  }
@@ -4014,6 +4153,8 @@ function renderMysteryBox(ctx) {
4014
4153
  const row = document.createElement("div");
4015
4154
  row.style.cssText = "display:flex;gap:12px;justify-content:center;margin:8px 0 4px";
4016
4155
  let opened = false;
4156
+ const note = document.createElement("div");
4157
+ note.style.cssText = "font-size:12.5px;font-weight:600;min-height:16px;margin-top:6px;opacity:0.8";
4017
4158
  list.forEach((b, i) => {
4018
4159
  const box = document.createElement("button");
4019
4160
  box.type = "button";
@@ -4038,19 +4179,43 @@ function renderMysteryBox(ctx) {
4038
4179
  box.style.animation = "";
4039
4180
  let won = true;
4040
4181
  let prizeLabel = str$1(b.prize, "You won!");
4041
- try {
4042
- const res = await submitP;
4043
- const sp = res ? res.prize : null;
4044
- if (sp) {
4045
- won = sp.win !== false;
4046
- if (sp.prize_label) prizeLabel = String(sp.prize_label);
4182
+ let nonRedeemable = null;
4183
+ let claimable = false;
4184
+ let signIn = false;
4185
+ if (ctx.submitResponse) {
4186
+ const { st, prize } = await drawAnswer(ctx, submitP);
4187
+ if (st.state === "spin_again") {
4188
+ opened = false;
4189
+ Array.from(row.children).forEach((c) => {
4190
+ c.style.opacity = "";
4191
+ c.style.transform = "";
4192
+ });
4193
+ note.textContent = st.message;
4194
+ return;
4195
+ }
4196
+ note.textContent = "";
4197
+ if (prize && prize.prize_label) prizeLabel = String(prize.prize_label);
4198
+ won = st.state === "credited_win";
4199
+ if (st.state === "non_redeemable") {
4200
+ nonRedeemable = st.message;
4201
+ claimable = st.claimable === true;
4202
+ signIn = st.signIn === true;
4047
4203
  }
4048
- } catch {
4049
4204
  }
4050
4205
  box.style.background = won ? `${s.accent}` : "rgba(148,163,184,0.22)";
4051
4206
  box.style.color = won ? "#fff" : "#475569";
4052
4207
  box.style.transform = "scale(1.08)";
4053
4208
  box.replaceChildren();
4209
+ if (nonRedeemable !== null) {
4210
+ box.appendChild(gEl("span", "", prizeLabel));
4211
+ note.textContent = nonRedeemable;
4212
+ if (claimable && ctx.claimAnonWin) note.appendChild(claimButton(ctx.claimAnonWin));
4213
+ else if (signIn && ctx.dispatchAction) {
4214
+ const open = ctx.dispatchAction;
4215
+ note.appendChild(claimButton(() => open({ type: "open_login" }), SIGN_IN_BUTTON_LABEL));
4216
+ }
4217
+ return;
4218
+ }
4054
4219
  box.appendChild(gEl("span", "font-size:28px", won ? "🎉" : "🙈"));
4055
4220
  box.appendChild(gEl("span", "", won ? prizeLabel : "Not this time"));
4056
4221
  if (won) {
@@ -4068,6 +4233,7 @@ function renderMysteryBox(ctx) {
4068
4233
  row.appendChild(box);
4069
4234
  });
4070
4235
  s.content.appendChild(row);
4236
+ s.content.appendChild(note);
4071
4237
  s.ctaButton(str$1(ic.mystery_cta_text, ""));
4072
4238
  }
4073
4239
  function renderTierLadder(ctx) {
@@ -4258,19 +4424,27 @@ function renderSlotMachine(ctx) {
4258
4424
  const prov = [pool[rnd(pool.length)], pool[rnd(pool.length)], pool[rnd(pool.length)]];
4259
4425
  const provWin = prov[0] === prov[1] && prov[1] === prov[2];
4260
4426
  const submitP = (_b = ctx.submitResponse) == null ? void 0 : _b.call(ctx, "slot_machine", { win: provWin, symbols: prov });
4261
- let serverPrize = null;
4262
- try {
4263
- const res = await Promise.race([
4264
- submitP ?? Promise.resolve(null),
4265
- new Promise((resolve) => window.setTimeout(() => resolve(null), 1400))
4266
- ]);
4267
- serverPrize = res ? res.prize : null;
4268
- } catch {
4427
+ let win = provWin;
4428
+ let label = str$1(ic.slot_win_text, "You win!");
4429
+ let nonRedeemable = null;
4430
+ let claimable = false;
4431
+ let signIn = false;
4432
+ let spinAgain = null;
4433
+ let claimInStore = false;
4434
+ if (ctx.submitResponse) {
4435
+ const { st, prize } = await drawAnswer(ctx, submitP);
4436
+ if (prize && prize.prize_label) label = String(prize.prize_label);
4437
+ win = st.state === "credited_win";
4438
+ claimInStore = win && !!prize && String(prize.prize_type || "").toLowerCase() === "freebie" && !prize.coupon_code;
4439
+ if (st.state === "non_redeemable") {
4440
+ nonRedeemable = st.message;
4441
+ claimable = st.claimable === true;
4442
+ signIn = st.signIn === true;
4443
+ }
4444
+ if (st.state === "spin_again") spinAgain = st.message;
4269
4445
  }
4270
- const win = serverPrize ? serverPrize.win !== false : provWin;
4271
- const label = serverPrize && serverPrize.prize_label ? String(serverPrize.prize_label) : str$1(ic.slot_win_text, "You win!");
4272
4446
  let target;
4273
- if (serverPrize) {
4447
+ if (ctx.submitResponse) {
4274
4448
  if (win) {
4275
4449
  const sym = pool[rnd(pool.length)];
4276
4450
  target = [sym, sym, sym];
@@ -4283,8 +4457,29 @@ function renderSlotMachine(ctx) {
4283
4457
  }
4284
4458
  const finish = () => {
4285
4459
  var _a2, _b2, _c, _d;
4460
+ if (spinAgain !== null || nonRedeemable !== null) {
4461
+ result.textContent = spinAgain ?? `${label}: ${nonRedeemable}`;
4462
+ result.style.color = "#64748b";
4463
+ if (spinAgain === null && claimable && ctx.claimAnonWin) {
4464
+ const claimRow = document.createElement("div");
4465
+ claimRow.appendChild(claimButton(ctx.claimAnonWin));
4466
+ result.appendChild(claimRow);
4467
+ } else if (spinAgain === null && signIn && ctx.dispatchAction) {
4468
+ const open = ctx.dispatchAction;
4469
+ const signInRow = document.createElement("div");
4470
+ signInRow.appendChild(claimButton(() => open({ type: "open_login" }), SIGN_IN_BUTTON_LABEL));
4471
+ result.appendChild(signInRow);
4472
+ }
4473
+ if (spinAgain !== null && fresh) fresh.disabled = false;
4474
+ ctx.trackEvent(ctx.campaign.id, "clicked", { stepId: spinAgain !== null ? "retry" : "non_redeemable" });
4475
+ spinning = false;
4476
+ return;
4477
+ }
4286
4478
  result.textContent = win ? `🎉 ${label}` : "So close — try again next time!";
4287
4479
  result.style.color = win ? s.accent : "#94a3b8";
4480
+ if (win && claimInStore) {
4481
+ result.appendChild(gEl("div", "font-size:12px;font-weight:600;opacity:0.85;margin-top:2px", "🎟️ Show this screen to claim"));
4482
+ }
4288
4483
  if (win) {
4289
4484
  winLine.style.borderColor = s.accent;
4290
4485
  winLine.style.boxShadow = `0 0 14px ${s.accent}aa, inset 0 0 14px ${s.accent}55`;
@@ -5230,9 +5425,26 @@ function interactiveSig(msg) {
5230
5425
  }
5231
5426
  }
5232
5427
  let currentLauncher = null;
5428
+ const launcherListeners = /* @__PURE__ */ new Set();
5429
+ function setCurrentLauncher(next) {
5430
+ if (currentLauncher === next) return;
5431
+ currentLauncher = next;
5432
+ for (const listener of launcherListeners) {
5433
+ try {
5434
+ listener(next);
5435
+ } catch {
5436
+ }
5437
+ }
5438
+ }
5233
5439
  function getCurrentLauncher() {
5234
5440
  return currentLauncher;
5235
5441
  }
5442
+ function onLauncherChange(listener) {
5443
+ launcherListeners.add(listener);
5444
+ return () => {
5445
+ launcherListeners.delete(listener);
5446
+ };
5447
+ }
5236
5448
  function openChat(prefill) {
5237
5449
  currentLauncher == null ? void 0 : currentLauncher.openPanel(prefill);
5238
5450
  }
@@ -5240,7 +5452,7 @@ function closeChat() {
5240
5452
  currentLauncher == null ? void 0 : currentLauncher.closePanel();
5241
5453
  }
5242
5454
  const ATTENTION_DELAY_MS = 4500;
5243
- class AegisChat {
5455
+ const _AegisChat = class _AegisChat {
5244
5456
  constructor(config) {
5245
5457
  this.workspaceRejected = false;
5246
5458
  this.lastRemintAt = 0;
@@ -5249,6 +5461,8 @@ class AegisChat {
5249
5461
  this.renderedRows = /* @__PURE__ */ new Map();
5250
5462
  this.sessionResumed = false;
5251
5463
  this.open = false;
5464
+ this.destroyed = false;
5465
+ this.retryWaits = /* @__PURE__ */ new Set();
5252
5466
  this.initialized = false;
5253
5467
  this.unread = 0;
5254
5468
  this.renderedIds = /* @__PURE__ */ new Set();
@@ -5292,11 +5506,11 @@ class AegisChat {
5292
5506
  }
5293
5507
  if (this.whatsapp) {
5294
5508
  this.mountWhatsapp();
5295
- currentLauncher = this;
5509
+ setCurrentLauncher(this);
5296
5510
  return;
5297
5511
  }
5298
5512
  this.mount();
5299
- currentLauncher = this;
5513
+ setCurrentLauncher(this);
5300
5514
  if (this.displayMode !== "nav") this.scheduleAttention();
5301
5515
  }
5302
5516
  /** Called by the runtime when the visitor identifies. */
@@ -5358,6 +5572,13 @@ class AegisChat {
5358
5572
  }
5359
5573
  destroy() {
5360
5574
  var _a, _b;
5575
+ this.destroyed = true;
5576
+ this.open = false;
5577
+ for (const w of this.retryWaits) {
5578
+ clearTimeout(w.timer);
5579
+ w.wake();
5580
+ }
5581
+ this.retryWaits.clear();
5361
5582
  this.unbindViewport();
5362
5583
  this.disconnectSSE();
5363
5584
  this.stopPolling();
@@ -5365,11 +5586,10 @@ class AegisChat {
5365
5586
  this.waDismiss = void 0;
5366
5587
  (_b = this.root) == null ? void 0 : _b.remove();
5367
5588
  this.initialized = false;
5368
- if (currentLauncher === this) currentLauncher = null;
5589
+ if (currentLauncher === this) setCurrentLauncher(null);
5369
5590
  }
5370
5591
  // ── Send ─────────────────────────────────────────────────────────────────
5371
5592
  async send(text, media) {
5372
- var _a;
5373
5593
  const caption2 = text.trim();
5374
5594
  if (!caption2 && !media) return;
5375
5595
  const message = caption2 || (media ? media.type === "image" ? "Sent a photo 📷" : "Sent a file 📎" : "");
@@ -5387,33 +5607,72 @@ class AegisChat {
5387
5607
  this.input.style.height = "auto";
5388
5608
  }
5389
5609
  this.showTyping();
5390
- try {
5391
- const post = () => fetch(`${this.apiHost}/v1/chat/message`, {
5392
- method: "POST",
5393
- headers: { "Content-Type": "application/json", "X-Aegis-Write-Key": this.writeKey },
5394
- body: JSON.stringify({
5395
- workspace_id: this.sentWorkspaceId(),
5396
- message_text: message,
5397
- channel: this.channel,
5398
- anonymous_id: this.anonymousId,
5399
- contact_id: this.contactId,
5400
- media_url: media == null ? void 0 : media.url,
5401
- media_type: media == null ? void 0 : media.type,
5402
- // Active Web Chat — binds the campaign-configured persona. Optional;
5403
- // the backend falls back to the tenant default if unknown/absent
5404
- // (honored server-side in Phase E). JSON.stringify drops it if absent.
5405
- agent_persona: this.agentPersona
5406
- }),
5407
- keepalive: true
5610
+ await this.deliver({ message, media, clientMessageId: generateUUID() });
5611
+ }
5612
+ static retryAfterMs(res) {
5613
+ var _a, _b;
5614
+ const raw = (_b = (_a = res.headers) == null ? void 0 : _a.get) == null ? void 0 : _b.call(_a, "Retry-After");
5615
+ const secs = raw ? Number(raw) : NaN;
5616
+ return Number.isFinite(secs) && secs >= 0 ? Math.min(secs * 1e3, _AegisChat.RETRY_AFTER_CAP_MS) : null;
5617
+ }
5618
+ /** POST one message with bounded automatic retries on the SAME id. On a final
5619
+ * failure, leave a Retry action that re-sends the stored id and text. */
5620
+ async deliver(pending) {
5621
+ var _a;
5622
+ const { message, media, clientMessageId } = pending;
5623
+ const post = () => fetch(`${this.apiHost}/v1/chat/message`, {
5624
+ method: "POST",
5625
+ headers: { "Content-Type": "application/json", "X-Aegis-Write-Key": this.writeKey },
5626
+ body: JSON.stringify({
5627
+ workspace_id: this.sentWorkspaceId(),
5628
+ message_text: message,
5629
+ client_message_id: clientMessageId,
5630
+ channel: this.channel,
5631
+ anonymous_id: this.anonymousId,
5632
+ contact_id: this.contactId,
5633
+ media_url: media == null ? void 0 : media.url,
5634
+ media_type: media == null ? void 0 : media.type,
5635
+ // Active Web Chat — binds the campaign-configured persona. Optional;
5636
+ // the backend falls back to the tenant default if unknown/absent
5637
+ // (honored server-side in Phase E). JSON.stringify drops it if absent.
5638
+ agent_persona: this.agentPersona
5639
+ }),
5640
+ keepalive: true
5641
+ });
5642
+ const delays = _AegisChat.RETRY_DELAYS_MS;
5643
+ let res = null;
5644
+ for (let attempt = 0; attempt <= delays.length; attempt++) {
5645
+ if (this.destroyed) return;
5646
+ let waitMs = null;
5647
+ try {
5648
+ res = await post();
5649
+ if (await this.isWorkspaceMismatch(res)) res = await post();
5650
+ if (res.ok || !_AegisChat.RETRYABLE_STATUS.has(res.status)) break;
5651
+ this.log("send failed (retryable)", res.status);
5652
+ waitMs = _AegisChat.retryAfterMs(res);
5653
+ } catch (err) {
5654
+ this.log("send error", err);
5655
+ res = null;
5656
+ }
5657
+ if (attempt === delays.length) break;
5658
+ if (this.destroyed) return;
5659
+ await new Promise((resolve) => {
5660
+ const w = { timer: setTimeout(() => {
5661
+ this.retryWaits.delete(w);
5662
+ resolve();
5663
+ }, waitMs ?? delays[attempt]), wake: resolve };
5664
+ this.retryWaits.add(w);
5408
5665
  });
5409
- let res = await post();
5410
- if (await this.isWorkspaceMismatch(res)) res = await post();
5411
- if (!res.ok) {
5412
- this.log("send failed", res.status);
5413
- this.appendSystem("Sorry — your message could not be delivered. Please try again.");
5414
- return;
5415
- }
5666
+ }
5667
+ if (this.destroyed) return;
5668
+ if (!res || !res.ok) {
5669
+ if (res) this.log("send failed", res.status);
5670
+ this.appendDeliveryFailed(pending);
5671
+ return;
5672
+ }
5673
+ try {
5416
5674
  const data = await res.json();
5675
+ if (this.destroyed) return;
5417
5676
  try {
5418
5677
  (_a = this.onMessageSent) == null ? void 0 : _a.call(this);
5419
5678
  } catch {
@@ -5426,9 +5685,30 @@ class AegisChat {
5426
5685
  void this.refreshHistory();
5427
5686
  } catch (err) {
5428
5687
  this.log("send error", err);
5429
- this.appendSystem("Sorry — your message could not be delivered. Please try again.");
5688
+ this.appendDeliveryFailed(pending);
5430
5689
  }
5431
5690
  }
5691
+ /** The failed-message notice with a Retry button. Retry re-sends the stored
5692
+ * client id + text, so a message the server did accept is absorbed, not
5693
+ * answered twice, and the customer never has to retype. */
5694
+ appendDeliveryFailed(pending) {
5695
+ var _a;
5696
+ this.hideTyping();
5697
+ this.appendSystem("Sorry — your message could not be delivered.");
5698
+ const row = (_a = this.thread) == null ? void 0 : _a.lastElementChild;
5699
+ if (!row) return;
5700
+ const btn = document.createElement("button");
5701
+ btn.type = "button";
5702
+ btn.className = "aegis-chat-chip aegis-chat-retry";
5703
+ btn.textContent = "Retry";
5704
+ btn.addEventListener("click", () => {
5705
+ btn.disabled = true;
5706
+ row.remove();
5707
+ this.showTyping();
5708
+ void this.deliver(pending);
5709
+ });
5710
+ row.appendChild(btn);
5711
+ }
5432
5712
  // ── Media attachments ─────────────────────────────────────────────────────
5433
5713
  /** Validate + upload a picked file, then send it as a media message. */
5434
5714
  async handleFile(file) {
@@ -6309,7 +6589,11 @@ class AegisChat {
6309
6589
  style.textContent = CHAT_CSS;
6310
6590
  document.head.appendChild(style);
6311
6591
  }
6312
- }
6592
+ };
6593
+ _AegisChat.RETRYABLE_STATUS = /* @__PURE__ */ new Set([429, 502, 503, 504]);
6594
+ _AegisChat.RETRY_DELAYS_MS = [1e3, 3e3, 7e3];
6595
+ _AegisChat.RETRY_AFTER_CAP_MS = 3e4;
6596
+ let AegisChat = _AegisChat;
6313
6597
  const CHAT_CSS = `
6314
6598
  ${launcherRootCss("aegis-chat-root")}
6315
6599
  .aegis-chat-root{${fontFamilyCss("body")}}
@@ -7846,6 +8130,43 @@ function pickSlotWinners(campaigns, opts = {}) {
7846
8130
  });
7847
8131
  return out;
7848
8132
  }
8133
+ const SECTION_SPOT_SELECTOR_PREFIX = "[data-aegis-section-spot=";
8134
+ function isSectionSpotSelector(selector) {
8135
+ return typeof selector === "string" && selector.trim().startsWith(SECTION_SPOT_SELECTOR_PREFIX);
8136
+ }
8137
+ function sectionAnchor(c) {
8138
+ var _a;
8139
+ const anchor = (_a = c.interactive_config) == null ? void 0 : _a.anchor;
8140
+ const sel = anchor == null ? void 0 : anchor.element_selector;
8141
+ if (!isSectionSpotSelector(sel)) return null;
8142
+ const position = typeof (anchor == null ? void 0 : anchor.position) === "string" && anchor.position ? anchor.position : "inside";
8143
+ return position === "inside" ? sel.trim() : null;
8144
+ }
8145
+ function pickSectionSpotLineups(campaigns, opts = {}) {
8146
+ const groups = /* @__PURE__ */ new Map();
8147
+ const seen = /* @__PURE__ */ new Set();
8148
+ for (const c of campaigns) {
8149
+ const modes = c.delivery_modes;
8150
+ if (!Array.isArray(modes) || !modes.includes("embedded_card")) continue;
8151
+ const sel = sectionAnchor(c);
8152
+ if (sel === null) continue;
8153
+ if (opts.isPlaceable && !opts.isPlaceable(c)) continue;
8154
+ if (seen.has(c.id)) continue;
8155
+ seen.add(c.id);
8156
+ const list = groups.get(sel);
8157
+ if (list) list.push(c);
8158
+ else groups.set(sel, [c]);
8159
+ }
8160
+ const out = /* @__PURE__ */ new Map();
8161
+ groups.forEach((members, selector) => {
8162
+ out.set(selector, { selector, members, declaredRotateMs: declaredRotateMs(members) });
8163
+ });
8164
+ return out;
8165
+ }
8166
+ function sectionRotateMs(lineup) {
8167
+ if (!lineup || lineup.members.length < 2) return 0;
8168
+ return lineup.declaredRotateMs > 0 ? lineup.declaredRotateMs : 0;
8169
+ }
7849
8170
  const STORAGE_PREFIX = "aegis_slot_shapes:v2:";
7850
8171
  const SHAPE_CACHE_TTL_MS = 6 * 60 * 60 * 1e3;
7851
8172
  const PHONE_MAX_WIDTH_PX = 767;
@@ -8251,6 +8572,165 @@ function armBehaviouralTriggers(engine, triggers, armed, fire, isMobile) {
8251
8572
  }
8252
8573
  return newlyArmed;
8253
8574
  }
8575
+ const SDK_FETCH_ABORT_MS = 800;
8576
+ function fetchWithAbort(input, init = {}, timeoutMs = SDK_FETCH_ABORT_MS) {
8577
+ const budget = Math.min(timeoutMs, SDK_FETCH_ABORT_MS);
8578
+ if (typeof AbortController === "undefined") {
8579
+ return fetch(input, init);
8580
+ }
8581
+ const controller = new AbortController();
8582
+ const outer = init.signal;
8583
+ if (outer) {
8584
+ if (outer.aborted) controller.abort();
8585
+ else outer.addEventListener("abort", () => controller.abort(), { once: true });
8586
+ }
8587
+ const timer = setTimeout(() => controller.abort(), budget);
8588
+ return fetch(input, { ...init, signal: controller.signal }).catch((err) => {
8589
+ clearTimeout(timer);
8590
+ throw err;
8591
+ });
8592
+ }
8593
+ function isAbortError(err) {
8594
+ return !!err && typeof err === "object" && (err.name === "AbortError" || err.name === "TimeoutError");
8595
+ }
8596
+ const LAST_GOOD_PREFIX = "aegis_rail_lastgood:v1:";
8597
+ const LAST_GOOD_SPECIFIC_PREFIX = "aegis_rail_lastgood_specific:v1:";
8598
+ const POPULAR_PREFIX = "aegis_rail_popular:v1:";
8599
+ const RAIL_FALLBACK_TTL_MS = 24 * 60 * 60 * 1e3;
8600
+ const RAIL_FALLBACK_MAX_BYTES = 15e4;
8601
+ const RAIL_FALLBACK_MAX_RAILS = 8;
8602
+ function lastGoodKey(ctx) {
8603
+ return `${LAST_GOOD_PREFIX}${ctx.propertyId || "-"}:${ctx.surface || "-"}:${ctx.screen || "-"}:${ctx.locationId || "-"}`;
8604
+ }
8605
+ function specificKey(ctx) {
8606
+ return `${LAST_GOOD_SPECIFIC_PREFIX}${ctx.propertyId || "-"}:${ctx.surface || "-"}:${ctx.screen || "-"}:${ctx.locationId || "-"}`;
8607
+ }
8608
+ const GENERIC_REC_SOURCES = /* @__PURE__ */ new Set(["trending", "top_rated", "manual"]);
8609
+ const ANCHORED_REASONS = /* @__PURE__ */ new Set(["similar", "same_category"]);
8610
+ const LIVE_CARD_KEYS = [
8611
+ "price",
8612
+ "compare_at_price",
8613
+ "original_price",
8614
+ "sale_price",
8615
+ "discount_pct",
8616
+ "stock",
8617
+ "in_stock",
8618
+ "stock_status",
8619
+ "stock_qty",
8620
+ "available",
8621
+ "availability",
8622
+ "sold_out"
8623
+ ];
8624
+ function isAnchoredOrPersonal(c) {
8625
+ const ic = c.interactive_config || {};
8626
+ if (ic.rec_source !== void 0 && ic.rec_source !== null && ic.rec_source !== "") {
8627
+ if (typeof ic.rec_source !== "string" || !GENERIC_REC_SOURCES.has(ic.rec_source)) return true;
8628
+ } else if (c.type === "product_recommendation") {
8629
+ return true;
8630
+ }
8631
+ if (ic.already_won && typeof ic.already_won === "object") return true;
8632
+ const cards = Array.isArray(ic.cards) ? ic.cards : [];
8633
+ return cards.some((card) => {
8634
+ var _a;
8635
+ return typeof ((_a = card == null ? void 0 : card.metadata) == null ? void 0 : _a.reason) === "string" && ANCHORED_REASONS.has(card.metadata.reason);
8636
+ });
8637
+ }
8638
+ function stripLiveFacts(c) {
8639
+ const ic = c.interactive_config || {};
8640
+ if (!Array.isArray(ic.cards)) return c;
8641
+ const cards = ic.cards.map((card) => {
8642
+ const meta = { ...card.metadata || {} };
8643
+ for (const k of LIVE_CARD_KEYS) delete meta[k];
8644
+ const style = { ...card.style || {}, hide_price: true };
8645
+ delete style.badge;
8646
+ return { ...card, metadata: meta, style };
8647
+ });
8648
+ return { ...c, interactive_config: { ...ic, cards } };
8649
+ }
8650
+ function popularKey(ctx) {
8651
+ return `${POPULAR_PREFIX}${ctx.propertyId || "-"}:${ctx.locationId || "-"}`;
8652
+ }
8653
+ function isEmbeddedRail(c) {
8654
+ return Array.isArray(c.delivery_modes) && c.delivery_modes.includes("embedded_card");
8655
+ }
8656
+ function isPopularRail(c) {
8657
+ if (!isEmbeddedRail(c)) return false;
8658
+ const ic = c.interactive_config || {};
8659
+ if (ic.rec_source === "trending") return true;
8660
+ const cards = Array.isArray(ic.cards) ? ic.cards : [];
8661
+ return cards.length > 0 && cards.every((card) => {
8662
+ var _a;
8663
+ return ((_a = card == null ? void 0 : card.metadata) == null ? void 0 : _a.reason) === "popular_here";
8664
+ });
8665
+ }
8666
+ function embeddedOnly(c) {
8667
+ return { ...stripLiveFacts(c), delivery_modes: ["embedded_card"] };
8668
+ }
8669
+ function write(key, rails, now, audience) {
8670
+ try {
8671
+ if (typeof localStorage === "undefined") return;
8672
+ const raw = JSON.stringify({
8673
+ t: now,
8674
+ ...audience ? { path: audience.path || null, contact: audience.contactId || null } : {},
8675
+ rails: rails.slice(0, RAIL_FALLBACK_MAX_RAILS).map(embeddedOnly)
8676
+ });
8677
+ if (raw.length > RAIL_FALLBACK_MAX_BYTES) return;
8678
+ localStorage.setItem(key, raw);
8679
+ } catch {
8680
+ }
8681
+ }
8682
+ function read(key, now, audience) {
8683
+ try {
8684
+ if (typeof localStorage === "undefined") return [];
8685
+ const raw = localStorage.getItem(key);
8686
+ if (!raw) return [];
8687
+ const parsed = JSON.parse(raw);
8688
+ if (typeof (parsed == null ? void 0 : parsed.t) !== "number" || now - parsed.t > RAIL_FALLBACK_TTL_MS || parsed.t > now + 6e4) {
8689
+ return [];
8690
+ }
8691
+ if (audience) {
8692
+ if ((parsed.path ?? null) !== (audience.path || null)) return [];
8693
+ if ((parsed.contact ?? null) !== (audience.contactId || null)) return [];
8694
+ }
8695
+ if (!Array.isArray(parsed.rails)) return [];
8696
+ return parsed.rails.filter(
8697
+ (c) => !!c && typeof c === "object" && typeof c.id === "string" && isEmbeddedRail(c)
8698
+ );
8699
+ } catch {
8700
+ return [];
8701
+ }
8702
+ }
8703
+ function saveGoodRails(ctx, campaigns, now = Date.now(), audience = {}) {
8704
+ const rails = campaigns.filter(isEmbeddedRail);
8705
+ const generic = rails.filter((c) => !isAnchoredOrPersonal(c));
8706
+ const specific = rails.filter(isAnchoredOrPersonal);
8707
+ const save = (key, list, aud) => {
8708
+ if (list.length === 0) {
8709
+ try {
8710
+ if (typeof localStorage !== "undefined") localStorage.removeItem(key);
8711
+ } catch {
8712
+ }
8713
+ } else {
8714
+ write(key, list, now, aud);
8715
+ }
8716
+ };
8717
+ save(lastGoodKey(ctx), generic);
8718
+ save(specificKey(ctx), specific, audience);
8719
+ const popular = rails.filter((c) => isPopularRail(c) && !isAnchoredOrPersonal(c));
8720
+ if (popular.length > 0) write(popularKey(ctx), popular, now);
8721
+ }
8722
+ function readRailFallback(ctx, now = Date.now(), audience = {}) {
8723
+ const seen = /* @__PURE__ */ new Set();
8724
+ const lastGood = [...read(specificKey(ctx), now, audience), ...read(lastGoodKey(ctx), now)].filter((c) => {
8725
+ if (seen.has(c.id)) return false;
8726
+ seen.add(c.id);
8727
+ return true;
8728
+ });
8729
+ if (lastGood.length > 0) return { tier: "last_good", campaigns: lastGood };
8730
+ const popular = read(popularKey(ctx), now);
8731
+ if (popular.length > 0) return { tier: "popular", campaigns: popular };
8732
+ return { tier: "hidden", campaigns: [] };
8733
+ }
8254
8734
  function readAnonIdFromStorage$1() {
8255
8735
  if (typeof document === "undefined") return void 0;
8256
8736
  try {
@@ -8341,6 +8821,7 @@ const _AegisInAppManager = class _AegisInAppManager {
8341
8821
  this.displayedCampaigns = /* @__PURE__ */ new Set();
8342
8822
  this._displaySizeMul = 1;
8343
8823
  this.suppressedUntil = /* @__PURE__ */ new Map();
8824
+ this.overlaysHeld = false;
8344
8825
  this.isInitialized = false;
8345
8826
  this.reconnectAttempts = 0;
8346
8827
  this.maxReconnectAttempts = 5;
@@ -8361,18 +8842,25 @@ const _AegisInAppManager = class _AegisInAppManager {
8361
8842
  this.slotTimers = /* @__PURE__ */ new WeakMap();
8362
8843
  this.renderedSlots = /* @__PURE__ */ new Set();
8363
8844
  this.slotObserver = null;
8845
+ this.anchorWrappers = /* @__PURE__ */ new WeakMap();
8846
+ this.ownAnchorWrappers = /* @__PURE__ */ new Set();
8364
8847
  this.phoneVariantMedia = null;
8365
8848
  this.onPhoneVariantChange = () => {
8366
8849
  if (this.slotsTornDown || typeof document === "undefined") return;
8367
8850
  if (document.querySelector(`[data-aegis-slot][${SLOT_VARIANT_PHONE_ATTR}]`)) this.renderIntoSlots();
8368
8851
  };
8369
8852
  this.slotRenderScheduled = false;
8853
+ this.pendingSlotRender = false;
8854
+ this.pendingAnchorRender = false;
8370
8855
  this.slotsTornDown = false;
8371
8856
  this.campaignsLoaded = false;
8372
8857
  this.shellTimeout = null;
8373
8858
  this.lifecycleGen = 0;
8374
8859
  this.slotUnfilledBeaconed = /* @__PURE__ */ new Set();
8375
8860
  this.slotUnfilledSweepTimer = null;
8861
+ this.railFallbackTier = null;
8862
+ this.retryAnswers = /* @__PURE__ */ new Map();
8863
+ this.anonClaims = loadAnonClaims();
8376
8864
  this._pushOptInLoading = false;
8377
8865
  this.journeyStepByCampaign = /* @__PURE__ */ new Map();
8378
8866
  this.journeyAcks = /* @__PURE__ */ new Set();
@@ -8384,7 +8872,8 @@ const _AegisInAppManager = class _AegisInAppManager {
8384
8872
  this.organizationId = config.organizationId;
8385
8873
  this.propertyId = config.propertyId;
8386
8874
  this.debugMode = config.debugMode || false;
8387
- this.enableSSE = config.enableSSE === true;
8875
+ this.previewOnly = config.previewOnly === true || isPreviewPage();
8876
+ this.enableSSE = config.enableSSE === true && !this.previewOnly;
8388
8877
  this.onActionHandler = config.onAction;
8389
8878
  if (config.productUrl) this.productUrl = config.productUrl;
8390
8879
  this.getWorkspaceId = config.getWorkspaceId;
@@ -8396,13 +8885,13 @@ const _AegisInAppManager = class _AegisInAppManager {
8396
8885
  if (screen && screen !== "page_view") this.currentScreen = screen;
8397
8886
  if (config.locationId) this.currentLocationId = config.locationId;
8398
8887
  }
8399
- emit(eventName, payload) {
8888
+ emit(eventName, payload, info) {
8400
8889
  const handlers = this.hooks.get(eventName);
8401
8890
  if (!handlers || handlers.size === 0) return true;
8402
8891
  let proceed = true;
8403
8892
  for (const handler of handlers) {
8404
8893
  try {
8405
- const result = handler(payload);
8894
+ const result = handler(payload, info);
8406
8895
  if (result === false) proceed = false;
8407
8896
  } catch (err) {
8408
8897
  this.emitError(err, { event: eventName });
@@ -8427,6 +8916,9 @@ const _AegisInAppManager = class _AegisInAppManager {
8427
8916
  }
8428
8917
  }
8429
8918
  }
8919
+ // `info` is the optional second argument some events carry
8920
+ // (`campaign-will-show` -> CampaignWillShowInfo); `never` lets both one- and
8921
+ // two-argument handlers register.
8430
8922
  register(eventName, handler) {
8431
8923
  if (!this.hooks.has(eventName)) this.hooks.set(eventName, /* @__PURE__ */ new Set());
8432
8924
  this.hooks.get(eventName).add(handler);
@@ -8456,7 +8948,8 @@ const _AegisInAppManager = class _AegisInAppManager {
8456
8948
  }
8457
8949
  /** Sugar: subscribe to `campaign-will-show`. CANCELLABLE — return `false`
8458
8950
  * to suppress rendering this campaign (host-side suppression rules,
8459
- * route-aware blocking, etc.). */
8951
+ * route-aware blocking, etc.). The second argument says where it renders
8952
+ * (`{ target: 'slot' | 'overlay' }`). */
8460
8953
  onCampaignWillShow(handler) {
8461
8954
  return this.register("campaign-will-show", handler);
8462
8955
  }
@@ -8488,9 +8981,9 @@ const _AegisInAppManager = class _AegisInAppManager {
8488
8981
  this.log("AegisInApp already initialized");
8489
8982
  return;
8490
8983
  }
8491
- markReturningVisitor();
8984
+ if (!this.previewOnly) markReturningVisitor();
8492
8985
  try {
8493
- if (typeof localStorage !== "undefined") {
8986
+ if (!this.previewOnly && typeof localStorage !== "undefined") {
8494
8987
  const pv = parseInt(localStorage.getItem("aegis_pv_count") || "0", 10);
8495
8988
  localStorage.setItem("aegis_pv_count", String(pv + 1));
8496
8989
  }
@@ -8538,6 +9031,7 @@ const _AegisInAppManager = class _AegisInAppManager {
8538
9031
  this.log("AegisInApp initialized successfully");
8539
9032
  }
8540
9033
  async _sendPushBootBeacon() {
9034
+ if (this.previewOnly) return;
8541
9035
  try {
8542
9036
  if (sessionStorage.getItem("aegis_push_boot_beacon") === "1") return;
8543
9037
  } catch {
@@ -8608,6 +9102,9 @@ const _AegisInAppManager = class _AegisInAppManager {
8608
9102
  var _a;
8609
9103
  this.contactId = contactId;
8610
9104
  this.contactToken = contactToken;
9105
+ if (contactToken && (this.anonClaims.pending.length || loadAnonClaims().pending.length)) {
9106
+ void this.claimPendingAnonWins();
9107
+ }
8611
9108
  (_a = this.activeWebChat) == null ? void 0 : _a.updateContactId(contactId);
8612
9109
  this.disconnectSSE();
8613
9110
  if (this.enableSSE && this.organizationId) {
@@ -8987,10 +9484,18 @@ const _AegisInAppManager = class _AegisInAppManager {
8987
9484
  if (this.currentCartProductIds !== null) {
8988
9485
  context.set("cart_product_ids", this.currentCartProductIds.join(","));
8989
9486
  }
9487
+ const previewAsOf = previewAsOfToken();
9488
+ if (previewAsOf) {
9489
+ context.set("preview_as_of", previewAsOf);
9490
+ }
9491
+ if (this.previewOnly) {
9492
+ context.set("preview", "1");
9493
+ }
8990
9494
  const url = `${this.apiHost}/v1/in-app/active?${context.toString()}`;
8991
9495
  requestKey = this.activeRequestKey();
8992
9496
  this.lastActiveRequestKey = requestKey;
8993
9497
  const shellCtx = this.shellContext();
9498
+ const railAudience = this.railAudience();
8994
9499
  const headers = {
8995
9500
  "X-Aegis-Write-Key": this.writeKey,
8996
9501
  "Content-Type": "application/json"
@@ -9014,7 +9519,7 @@ const _AegisInAppManager = class _AegisInAppManager {
9014
9519
  if (Object.keys(abAssignments).length > 0) {
9015
9520
  headers["X-AB-Assignments"] = btoa(JSON.stringify(abAssignments));
9016
9521
  }
9017
- const response = await fetch(url, {
9522
+ const response = await fetchWithAbort(url, {
9018
9523
  method: "GET",
9019
9524
  headers,
9020
9525
  credentials: "include"
@@ -9027,6 +9532,7 @@ const _AegisInAppManager = class _AegisInAppManager {
9027
9532
  if (gen !== this.lifecycleGen) return;
9028
9533
  this.campaigns = Array.isArray(payload) ? payload : [];
9029
9534
  this.campaignsLoaded = true;
9535
+ this.railFallbackTier = null;
9030
9536
  this.campaignsRequestKey = requestKey;
9031
9537
  this.clearShellTimeout();
9032
9538
  applyCampaignFonts(this.campaigns);
@@ -9039,7 +9545,8 @@ const _AegisInAppManager = class _AegisInAppManager {
9039
9545
  this.mountPersistentLaunchers();
9040
9546
  this.tryDisplayNextCampaign();
9041
9547
  this.renderIntoSlots();
9042
- this.saveSlotShapes(shellCtx);
9548
+ if (!this.previewOnly) this.saveSlotShapes(shellCtx);
9549
+ if (!this.previewOnly) saveGoodRails(shellCtx, this.campaigns, Date.now(), railAudience);
9043
9550
  this.renderIntoAnchors();
9044
9551
  this.renderTokenAnchors();
9045
9552
  } catch (error) {
@@ -9047,12 +9554,16 @@ const _AegisInAppManager = class _AegisInAppManager {
9047
9554
  this.lastActiveRequestKey = void 0;
9048
9555
  }
9049
9556
  if (gen !== this.lifecycleGen) return;
9050
- if (!this.campaignsLoaded) this.removeShells();
9557
+ if (!this.campaignsLoaded) {
9558
+ this.applyRailFallback();
9559
+ this.removeShells();
9560
+ }
9051
9561
  this.emitError(error, { stage: "refresh-campaigns" });
9052
9562
  this.log(`Error refreshing campaigns: ${error}`, "error");
9053
9563
  }
9054
9564
  }
9055
9565
  emitServedEvents(campaigns) {
9566
+ if (this.previewOnly) return;
9056
9567
  if (typeof sessionStorage === "undefined") {
9057
9568
  for (const c of campaigns) {
9058
9569
  void this.trackEvent(c.id, "served");
@@ -9105,7 +9616,34 @@ const _AegisInAppManager = class _AegisInAppManager {
9105
9616
  const assignments = this.getABAssignments();
9106
9617
  return assignments[campaignId] ?? void 0;
9107
9618
  }
9619
+ /**
9620
+ * Hold every automatic overlay (pop-up, half sheet, full screen …) until
9621
+ * `releaseOverlays()`. A host whose page must not be interrupted yet (the bill
9622
+ * before it is paid, Active Bill Q15) calls this BEFORE `initialize()`; the
9623
+ * campaigns still load and fill their slots, only the overlay pick waits.
9624
+ */
9625
+ holdOverlays() {
9626
+ this.overlaysHeld = true;
9627
+ }
9628
+ /**
9629
+ * Lift `holdOverlays()` and run the overlay pick once, so the page gets at
9630
+ * most the one overlay the pick would have shown on load, with the same
9631
+ * pacing (`displayedCampaigns`, caps, suppression). No-op when not held.
9632
+ */
9633
+ releaseOverlays() {
9634
+ if (!this.overlaysHeld) return;
9635
+ this.overlaysHeld = false;
9636
+ if (this.campaigns.length > 0) this.tryDisplayNextCampaign();
9637
+ }
9638
+ /** True while `holdOverlays()` is in force. */
9639
+ overlaysAreHeld() {
9640
+ return this.overlaysHeld;
9641
+ }
9108
9642
  tryDisplayNextCampaign() {
9643
+ if (this.overlaysHeld) {
9644
+ this.log("overlay pick skipped: overlays held by the host");
9645
+ return;
9646
+ }
9109
9647
  const campaign = this.campaigns.find(
9110
9648
  (c) => !this.displayedCampaigns.has(c.id) && !c.client_trigger && !this.isSuppressed(c.id) && c.type !== "active_web_chat" && (c.sub_type !== "push_primer" || this._primerEligibleNow()) && !(Array.isArray(c.delivery_modes) && c.delivery_modes.length > 0 && !c.delivery_modes.includes("in_app_overlay"))
9111
9649
  );
@@ -9231,6 +9769,35 @@ const _AegisInAppManager = class _AegisInAppManager {
9231
9769
  this.log(`slot shells skipped: ${err}`, "warn");
9232
9770
  }
9233
9771
  }
9772
+ /**
9773
+ * WP17 rail fallback: last good rails for this page → the brand's popular
9774
+ * rails → hidden. Rails only (stored embedded-only), never an overlay, never
9775
+ * `served`/`campaigns-loaded`: a real /active answer replaces them. Fail-soft:
9776
+ * a fallback error just leaves the slots empty.
9777
+ */
9778
+ applyRailFallback() {
9779
+ if (typeof document === "undefined" || this.slotsTornDown) return;
9780
+ try {
9781
+ const fb = readRailFallback(this.shellContext(), Date.now(), this.railAudience());
9782
+ this.railFallbackTier = fb.tier;
9783
+ if (fb.tier === "hidden") return;
9784
+ const held = new Set(this.campaigns.map((c) => c.id));
9785
+ this.campaigns = [...this.campaigns, ...fb.campaigns.filter((c) => !held.has(c.id))];
9786
+ this.log(`/active did not answer: painting ${fb.campaigns.length} ${fb.tier} rail(s)`, "warn");
9787
+ this.renderIntoSlots();
9788
+ } catch (err) {
9789
+ this.log(`rail fallback skipped: ${err}`, "warn");
9790
+ }
9791
+ }
9792
+ /** Who / where anchored or personal rails answer (rail-fallback.ts). */
9793
+ railAudience() {
9794
+ const path = typeof window !== "undefined" && window.location ? window.location.pathname || "/" : null;
9795
+ return { path, contactId: this.contactId ?? null };
9796
+ }
9797
+ /** The fallback tier in use after a failed first /active (null when none). */
9798
+ getRailFallbackTier() {
9799
+ return this.railFallbackTier;
9800
+ }
9234
9801
  clearShellTimeout() {
9235
9802
  if (this.shellTimeout) {
9236
9803
  clearTimeout(this.shellTimeout);
@@ -9274,34 +9841,52 @@ const _AegisInAppManager = class _AegisInAppManager {
9274
9841
  ":scope > [data-aegis-rotate-stack], :scope > [data-aegis-rotate-pane], :scope > [data-aegis-slot-rendered], :scope > [data-aegis-rotate-dots]"
9275
9842
  ).forEach((n) => n.remove());
9276
9843
  }
9277
- // Re-fill slots that mount after a poll (SPA route changes). Observes the DOM
9278
- // once; when a new [data-aegis-slot] appears it re-runs renderIntoSlots from
9279
- // the cached campaigns (idempotent — already-filled slots are skipped). Does
9280
- // NOT loop on the SDK's own injections (those add content INTO a slot, not a
9281
- // new slot element).
9844
+ // Re-fill spots that mount after a poll (SPA route changes, a section drawn
9845
+ // after a client-side step). Observes the DOM once; when a new
9846
+ // [data-aegis-slot] appears it re-runs renderIntoSlots, and when an element
9847
+ // a cached campaign is anchored to appears (a Promo spot section's
9848
+ // [data-aegis-section-spot] box, or any operator element anchor) it re-runs
9849
+ // renderIntoAnchors, both from the cached campaigns (idempotent: filled
9850
+ // spots are skipped, a before/after wrapper is reused). Does NOT loop on
9851
+ // the SDK's own injections: a re-run adds nothing to a filled spot.
9282
9852
  ensureSlotObserver() {
9283
9853
  if (this.slotObserver || typeof MutationObserver === "undefined" || typeof document === "undefined") {
9284
9854
  return;
9285
9855
  }
9286
9856
  this.slotObserver = new MutationObserver((mutations) => {
9287
9857
  let sawSlot = false;
9858
+ let sawAnchor = false;
9859
+ const anchorSelectors = this.cachedAnchorSelectors();
9860
+ const hits = (el2, sel) => {
9861
+ var _a, _b;
9862
+ try {
9863
+ return !!(((_a = el2.matches) == null ? void 0 : _a.call(el2, sel)) || ((_b = el2.querySelector) == null ? void 0 : _b.call(el2, sel)));
9864
+ } catch {
9865
+ return false;
9866
+ }
9867
+ };
9288
9868
  for (const m2 of mutations) {
9289
9869
  m2.addedNodes.forEach((n) => {
9290
- var _a, _b;
9291
- if (sawSlot || n.nodeType !== 1) return;
9870
+ if (n.nodeType !== 1) return;
9292
9871
  const el2 = n;
9293
- if (((_a = el2.matches) == null ? void 0 : _a.call(el2, "[data-aegis-slot]")) || ((_b = el2.querySelector) == null ? void 0 : _b.call(el2, "[data-aegis-slot]"))) {
9294
- sawSlot = true;
9295
- }
9872
+ if (!sawSlot && hits(el2, "[data-aegis-slot]")) sawSlot = true;
9873
+ if (!sawAnchor && anchorSelectors.some((sel) => hits(el2, sel))) sawAnchor = true;
9296
9874
  });
9297
- if (sawSlot) break;
9875
+ if (sawSlot && sawAnchor) break;
9298
9876
  }
9299
- if (!sawSlot || this.slotRenderScheduled) return;
9877
+ if (sawSlot) this.pendingSlotRender = true;
9878
+ if (sawAnchor) this.pendingAnchorRender = true;
9879
+ if (!sawSlot && !sawAnchor || this.slotRenderScheduled) return;
9300
9880
  this.slotRenderScheduled = true;
9301
9881
  const run = () => {
9302
9882
  this.slotRenderScheduled = false;
9883
+ const slots = this.pendingSlotRender;
9884
+ const anchors = this.pendingAnchorRender;
9885
+ this.pendingSlotRender = false;
9886
+ this.pendingAnchorRender = false;
9303
9887
  if (this.slotsTornDown) return;
9304
- this.renderIntoSlots();
9888
+ if (slots) this.renderIntoSlots();
9889
+ if (anchors) this.renderIntoAnchors({ reportUnresolved: false });
9305
9890
  };
9306
9891
  if (typeof requestAnimationFrame === "function") requestAnimationFrame(run);
9307
9892
  else setTimeout(run, 0);
@@ -9559,6 +10144,20 @@ const _AegisInAppManager = class _AegisInAppManager {
9559
10144
  window.addEventListener("beforeunload", () => timer && clearInterval(timer), { once: true });
9560
10145
  }
9561
10146
  }
10147
+ /** Element-anchor selectors of the cached inline campaigns placeable here:
10148
+ * what the slot observer watches for (a Promo spot section mounted after
10149
+ * /active answered). */
10150
+ cachedAnchorSelectors() {
10151
+ var _a;
10152
+ const out = [];
10153
+ for (const c of this.campaigns) {
10154
+ if (!c.delivery_modes || !c.delivery_modes.includes("embedded_card")) continue;
10155
+ const ic = c.interactive_config;
10156
+ const sel = (_a = ic == null ? void 0 : ic.anchor) == null ? void 0 : _a.element_selector;
10157
+ if (typeof sel === "string" && sel && !out.includes(sel)) out.push(sel);
10158
+ }
10159
+ return out;
10160
+ }
9562
10161
  /**
9563
10162
  * Surface-Canvas inline element anchoring (Plotline / WebEngage model).
9564
10163
  *
@@ -9572,12 +10171,22 @@ const _AegisInAppManager = class _AegisInAppManager {
9572
10171
  * Reuses `renderCampaignIntoSlot` (same sub_type dispatch → `renderProgressBarInline`
9573
10172
  * etc.) so inline render code is single-sourced with the slot path. Embedded-card
9574
10173
  * gated (so an anchored campaign never ALSO renders as an overlay), surface-gated,
9575
- * and idempotent via `filledSlots` keyed on the resolved element. A selector that
9576
- * doesn't resolve emits `anchor_unresolved` (parity with tooltip anchoring).
10174
+ * and idempotent via `filledSlots` keyed on the resolved element.
10175
+ *
10176
+ * A selector that doesn't resolve emits `anchor_unresolved` (parity with tooltip
10177
+ * anchoring) only on the /active pass (`reportUnresolved` unset or true). The slot
10178
+ * observer's re-runs pass `reportUnresolved: false` and stay silent: an anchor
10179
+ * that mounts later (a Promo spot section) is not missing, and a DOM change must
10180
+ * never emit one event per campaign per mutation.
9577
10181
  */
9578
- renderIntoAnchors() {
9579
- var _a;
9580
- if (typeof document === "undefined") return;
10182
+ renderIntoAnchors(opts = {}) {
10183
+ var _a, _b;
10184
+ if (typeof document === "undefined" || this.slotsTornDown) return;
10185
+ this.ensureSlotObserver();
10186
+ const reportUnresolved = opts.reportUnresolved !== false;
10187
+ const sectionLineups = pickSectionSpotLineups(this.campaigns, {
10188
+ isPlaceable: (c) => this.isPlaceableHere(c)
10189
+ });
9581
10190
  for (const c of this.campaigns) {
9582
10191
  if (!this.isPlaceableHere(c)) continue;
9583
10192
  const modes = c.delivery_modes;
@@ -9593,17 +10202,31 @@ const _AegisInAppManager = class _AegisInAppManager {
9593
10202
  el2 = null;
9594
10203
  }
9595
10204
  if (!el2) {
9596
- void this.trackEvent(c.id, "anchor_unresolved", {
9597
- meta: { anchor_resolved: false, anchor_selector: selector, widget_type: c.sub_type }
9598
- });
10205
+ if (reportUnresolved) {
10206
+ void this.trackEvent(c.id, "anchor_unresolved", {
10207
+ meta: { anchor_resolved: false, anchor_selector: selector, widget_type: c.sub_type }
10208
+ });
10209
+ }
9599
10210
  continue;
9600
10211
  }
9601
10212
  const position = (anchor == null ? void 0 : anchor.position) || "inside";
9602
10213
  let target;
9603
10214
  if (position === "before" || position === "after") {
9604
- target = document.createElement("div");
9605
- target.setAttribute("data-aegis-anchor-wrapper", c.id);
9606
- (_a = el2.parentNode) == null ? void 0 : _a.insertBefore(target, position === "before" ? el2 : el2.nextSibling);
10215
+ let byCampaign = this.anchorWrappers.get(el2);
10216
+ if (!byCampaign) {
10217
+ byCampaign = /* @__PURE__ */ new Map();
10218
+ this.anchorWrappers.set(el2, byCampaign);
10219
+ }
10220
+ const kept = byCampaign.get(c.id);
10221
+ if (kept && kept.isConnected) {
10222
+ target = kept;
10223
+ } else {
10224
+ target = document.createElement("div");
10225
+ target.setAttribute("data-aegis-anchor-wrapper", c.id);
10226
+ (_a = el2.parentNode) == null ? void 0 : _a.insertBefore(target, position === "before" ? el2 : el2.nextSibling);
10227
+ byCampaign.set(c.id, target);
10228
+ this.ownAnchorWrappers.add(target);
10229
+ }
9607
10230
  } else {
9608
10231
  target = el2;
9609
10232
  if (position === "replace") {
@@ -9619,8 +10242,26 @@ const _AegisInAppManager = class _AegisInAppManager {
9619
10242
  }
9620
10243
  }
9621
10244
  if (this.filledSlots.has(target)) continue;
9622
- this.renderCampaignIntoSlot(c, target);
10245
+ const rotateMs = position === "inside" ? sectionRotateMs(sectionLineups.get(selector.trim())) : 0;
10246
+ if (rotateMs > 0) {
10247
+ this.clearSlotContent(target);
10248
+ this.renderRotatingSlot(target, ((_b = sectionLineups.get(selector.trim())) == null ? void 0 : _b.members) ?? [c], rotateMs);
10249
+ if (target.childElementCount === 0) continue;
10250
+ this.filledSlots.add(target);
10251
+ this.renderedSlots.add(target);
10252
+ continue;
10253
+ }
10254
+ this.clearSlotContent(target);
10255
+ const host = document.createElement("div");
10256
+ host.setAttribute("data-aegis-slot-rendered", c.id);
10257
+ target.appendChild(host);
10258
+ this.renderCampaignIntoSlot(c, host);
10259
+ if (host.childElementCount === 0) {
10260
+ host.remove();
10261
+ continue;
10262
+ }
9623
10263
  this.filledSlots.add(target);
10264
+ this.renderedSlots.add(target);
9624
10265
  }
9625
10266
  }
9626
10267
  /**
@@ -9690,7 +10331,8 @@ const _AegisInAppManager = class _AegisInAppManager {
9690
10331
  * skip — those types only make sense as fullscreen overlays.
9691
10332
  */
9692
10333
  renderCampaignIntoSlot(campaign, target, options) {
9693
- const proceed = this.emit("campaign-will-show", campaign);
10334
+ const willShow = { target: "slot" };
10335
+ const proceed = this.emit("campaign-will-show", campaign, willShow);
9694
10336
  if (!proceed) {
9695
10337
  this.log(
9696
10338
  `slot campaign ${campaign.id} suppressed by campaign-will-show handler`
@@ -10189,6 +10831,7 @@ const _AegisInAppManager = class _AegisInAppManager {
10189
10831
  /** POST a form response to /in-app/responses (gateway → cell-plane). The
10190
10832
  * cell-plane enriches the contact from the campaign's field-map. Best-effort. */
10191
10833
  async submitFormResponse(campaign, fields) {
10834
+ if (this.previewOnly) return;
10192
10835
  if (!this.organizationId) {
10193
10836
  this.log("submitFormResponse: no organizationId — cannot submit", "warn");
10194
10837
  return;
@@ -10225,14 +10868,88 @@ const _AegisInAppManager = class _AegisInAppManager {
10225
10868
  this.log(`submitFormResponse error: ${e}`, "warn");
10226
10869
  }
10227
10870
  }
10228
- /**
10229
- * Generic interactive response submit → POST /v1/in-app/responses. Returns the
10230
- * parsed server response (which for spin/scratch carries the server-picked
10231
- * `prize`) or null. Interactive Widgets Parity tracker — every embedded widget
10232
- * records a response so analytics + prize-from-segments work uniformly.
10233
- */
10871
+ /** The claim button's action: claim now when signed in, else ask the host to
10872
+ * open its sign-in (the existing OTP sign-in) and claim once it hands us a
10873
+ * contact token (`updateContactId`). */
10874
+ startAnonClaim(campaignId) {
10875
+ if (!this.anonClaims.pending.includes(campaignId)) this.anonClaims.pending.push(campaignId);
10876
+ saveAnonClaims(this.anonClaims);
10877
+ if (this.contactId && this.contactToken) {
10878
+ void this.claimPendingAnonWins();
10879
+ return;
10880
+ }
10881
+ this.dispatchAction({ type: "open_login" }, campaignId);
10882
+ }
10883
+ async claimPendingAnonWins() {
10884
+ const saved = loadAnonClaims();
10885
+ this.anonClaims = {
10886
+ pending: Array.from(/* @__PURE__ */ new Set([...saved.pending, ...this.anonClaims.pending])),
10887
+ tickets: { ...saved.tickets, ...this.anonClaims.tickets }
10888
+ };
10889
+ const ids = this.anonClaims.pending.slice();
10890
+ this.anonClaims.pending = [];
10891
+ saveAnonClaims(this.anonClaims);
10892
+ for (const id of ids) {
10893
+ const body = await this.claimAnonWin(id);
10894
+ const answer = claimAnswer(body);
10895
+ if (body) {
10896
+ delete this.anonClaims.tickets[id];
10897
+ saveAnonClaims(this.anonClaims);
10898
+ showClaimNotice(answer);
10899
+ } else {
10900
+ showClaimNotice(answer, () => this.startAnonClaim(id));
10901
+ }
10902
+ try {
10903
+ window.dispatchEvent(new CustomEvent(CLAIM_EVENT, { detail: { campaignId: id, ...answer, body } }));
10904
+ } catch {
10905
+ }
10906
+ void this.trackEvent(id, "clicked", { stepId: answer.claimed ? "anon_claim_claimed" : "anon_claim_not_eligible" });
10907
+ }
10908
+ }
10909
+ /** POST the claim. The cell decides from the device's stored play; this sends
10910
+ * only the campaign, the device id and the contact token. null = no answer. */
10911
+ async claimAnonWin(campaignId) {
10912
+ if (this.previewOnly) return null;
10913
+ if (!this.organizationId || !this.contactId || !this.contactToken) return null;
10914
+ try {
10915
+ const res = await fetch(`${this.apiHost}${CLAIM_PATH}`, {
10916
+ method: "POST",
10917
+ headers: {
10918
+ "Content-Type": "application/json",
10919
+ "X-Aegis-Write-Key": this.writeKey,
10920
+ "X-Organization-ID": this.organizationId,
10921
+ "X-Contact-ID": this.contactId,
10922
+ "X-Contact-Token": this.contactToken
10923
+ },
10924
+ body: JSON.stringify({
10925
+ campaign_id: campaignId,
10926
+ contact_id: this.contactId,
10927
+ anonymous_id: readAnonIdFromStorage$1(),
10928
+ claim_ticket: this.anonClaims.tickets[campaignId]
10929
+ })
10930
+ });
10931
+ if (!res.ok) {
10932
+ this.log(`anon win claim failed (${res.status})`, "warn");
10933
+ return null;
10934
+ }
10935
+ return await res.json().catch(() => null);
10936
+ } catch (e) {
10937
+ this.log(`anon win claim error: ${e}`, "warn");
10938
+ return null;
10939
+ }
10940
+ }
10941
+ /** The server's "try again" answer for this campaign's last submit, once. */
10942
+ takeRetryAnswer(campaignId) {
10943
+ const msg = this.retryAnswers.get(campaignId);
10944
+ if (msg === void 0) return null;
10945
+ this.retryAnswers.delete(campaignId);
10946
+ return msg;
10947
+ }
10234
10948
  async submitWidgetResponse(campaign, responseType, payload) {
10949
+ var _a, _b;
10950
+ if (this.previewOnly) return null;
10235
10951
  if (!this.organizationId) return null;
10952
+ this.retryAnswers.delete(campaign.id);
10236
10953
  try {
10237
10954
  const headers = {
10238
10955
  "Content-Type": "application/json",
@@ -10261,9 +10978,25 @@ const _AegisInAppManager = class _AegisInAppManager {
10261
10978
  });
10262
10979
  if (!res.ok) {
10263
10980
  this.log(`submitWidgetResponse ${responseType} failed (${res.status})`, "warn");
10981
+ if (res.status === 503) {
10982
+ const body = await res.json().catch(() => null);
10983
+ const code = (_a = body == null ? void 0 : body.detail) == null ? void 0 : _a.reason_code;
10984
+ if (code === PRIZE_GRANT_RETRY || code === "DIET_UNREAD") {
10985
+ const msg = (_b = body == null ? void 0 : body.detail) == null ? void 0 : _b.message;
10986
+ this.retryAnswers.set(
10987
+ campaign.id,
10988
+ typeof msg === "string" && msg ? msg : PRIZE_GRANT_RETRY_MESSAGE
10989
+ );
10990
+ }
10991
+ }
10264
10992
  return null;
10265
10993
  }
10266
- return await res.json().catch(() => null);
10994
+ const answer = await res.json().catch(() => null);
10995
+ if (answer && typeof answer.claim_ticket === "string" && answer.claim_ticket) {
10996
+ this.anonClaims.tickets[campaign.id] = answer.claim_ticket;
10997
+ saveAnonClaims(this.anonClaims);
10998
+ }
10999
+ return answer;
10267
11000
  } catch (e) {
10268
11001
  this.log(`submitWidgetResponse ${responseType} error: ${e}`, "warn");
10269
11002
  return null;
@@ -10682,7 +11415,13 @@ const _AegisInAppManager = class _AegisInAppManager {
10682
11415
  loseFx();
10683
11416
  this._playReaction(card, "empathize", void 0, ic);
10684
11417
  }
10685
- if (winReveal === "takeover" && r.won) renderTakeover(r);
11418
+ if (r.nonRedeemable !== void 0) {
11419
+ result.textContent = r.label ? `${r.label}: ${r.nonRedeemable}` : r.nonRedeemable;
11420
+ if (r.claimable) result.appendChild(claimButton(() => this.startAnonClaim(campaign.id)));
11421
+ else if (r.signIn) {
11422
+ result.appendChild(claimButton(() => this.dispatchAction({ type: "open_login" }, campaign.id), SIGN_IN_BUTTON_LABEL));
11423
+ }
11424
+ } else if (winReveal === "takeover" && r.won) renderTakeover(r);
10686
11425
  else if (r.label && r.code) {
10687
11426
  result.textContent = "";
10688
11427
  const tag = document.createElement("span");
@@ -10703,7 +11442,15 @@ const _AegisInAppManager = class _AegisInAppManager {
10703
11442
  result.appendChild(chip);
10704
11443
  const validTill = this._validTillLine(r.expiresAt, text);
10705
11444
  if (validTill) result.appendChild(validTill);
10706
- } else result.textContent = r.label || "Thanks for playing!";
11445
+ } else {
11446
+ result.textContent = r.label || "Thanks for playing!";
11447
+ if (r.won && !r.code && r.kind === "freebie") {
11448
+ const hint = document.createElement("div");
11449
+ hint.textContent = "🎟️ Show this screen to claim";
11450
+ hint.style.cssText = "margin-top: 4px; font-size: 12px; font-weight: 600; opacity: 0.85;";
11451
+ result.appendChild(hint);
11452
+ }
11453
+ }
10707
11454
  retireCta();
10708
11455
  };
10709
11456
  const beginSpin = (velocityDegPerMs) => {
@@ -10722,6 +11469,7 @@ const _AegisInAppManager = class _AegisInAppManager {
10722
11469
  const loopSpeed = 0.5 + v * 0.35;
10723
11470
  let looping = true;
10724
11471
  let done = false;
11472
+ let timedOut = false;
10725
11473
  let lastTs = now();
10726
11474
  const loopFrame = () => {
10727
11475
  if (!looping) return;
@@ -10741,6 +11489,16 @@ const _AegisInAppManager = class _AegisInAppManager {
10741
11489
  }
10742
11490
  return provisional;
10743
11491
  };
11492
+ const pauseForRetry = (message) => {
11493
+ if (done) return;
11494
+ done = true;
11495
+ looping = false;
11496
+ spinning = false;
11497
+ btn.disabled = false;
11498
+ btn.style.opacity = "";
11499
+ btn.style.transform = "";
11500
+ result.textContent = message;
11501
+ };
10744
11502
  const launch = (idx, r) => {
10745
11503
  if (done) return;
10746
11504
  done = true;
@@ -10758,27 +11516,48 @@ const _AegisInAppManager = class _AegisInAppManager {
10758
11516
  });
10759
11517
  };
10760
11518
  void this.submitWidgetResponse(campaign, "spin", { segment_index: provisional }).then((resp) => {
10761
- const prize = resp && resp.prize ? resp.prize : null;
11519
+ if (done) {
11520
+ if (!timedOut || spinning || resolved) return;
11521
+ done = false;
11522
+ spinning = true;
11523
+ btn.disabled = true;
11524
+ btn.style.opacity = "0.6";
11525
+ }
11526
+ const st2 = prizeStateOf(resp, this.takeRetryAnswer(campaign.id));
11527
+ if (st2.state === "spin_again") {
11528
+ pauseForRetry(st2.message);
11529
+ return;
11530
+ }
11531
+ const prize = resp.prize || null;
11532
+ if (!prize) {
11533
+ const li = lossIndex();
11534
+ launch(li, {
11535
+ label: labels[li] || "",
11536
+ code: "",
11537
+ won: false,
11538
+ kind: shown[li] && typeof shown[li].prize_type === "string" ? String(shown[li].prize_type).toLowerCase() : "no_prize"
11539
+ });
11540
+ return;
11541
+ }
10762
11542
  let idx = provisional;
10763
- if (prize && typeof prize.segment_index === "number") idx = prize.segment_index % n;
10764
- const label = prize && typeof prize.prize_label === "string" ? prize.prize_label : labels[idx] || "";
10765
- const code = prize && typeof prize.coupon_code === "string" ? prize.coupon_code : "";
10766
- const kind = prize && typeof prize.prize_type === "string" ? prize.prize_type.toLowerCase() : shown[idx] && typeof shown[idx].prize_type === "string" ? String(shown[idx].prize_type).toLowerCase() : "";
10767
- const lost = prize ? String(prize.prize_type || "").toLowerCase() === "no_prize" : isLossSeg(idx);
10768
- const expiresAt = prize && typeof prize.expires_at === "string" ? prize.expires_at : null;
10769
- launch(idx, { label, code, won: !!label && !lost, kind, expiresAt });
11543
+ if (typeof prize.segment_index === "number") idx = prize.segment_index % n;
11544
+ const label = typeof prize.prize_label === "string" ? prize.prize_label : labels[idx] || "";
11545
+ const kind = typeof prize.prize_type === "string" ? prize.prize_type.toLowerCase() : shown[idx] && typeof shown[idx].prize_type === "string" ? String(shown[idx].prize_type).toLowerCase() : "";
11546
+ if (st2.state === "non_redeemable") {
11547
+ launch(idx, { label, code: "", won: false, kind, nonRedeemable: st2.message, claimable: st2.claimable === true, signIn: st2.signIn === true });
11548
+ return;
11549
+ }
11550
+ const won = st2.state === "credited_win" && !!label;
11551
+ const code = won && typeof prize.coupon_code === "string" ? prize.coupon_code : "";
11552
+ const expiresAt = won && typeof prize.expires_at === "string" ? prize.expires_at : null;
11553
+ launch(idx, { label, code, won, kind, expiresAt });
10770
11554
  }).catch(() => {
10771
11555
  });
10772
11556
  window.setTimeout(() => {
10773
11557
  if (done) return;
10774
- const li = lossIndex();
10775
- launch(li, {
10776
- label: labels[li] || "",
10777
- code: "",
10778
- won: false,
10779
- kind: shown[li] && typeof shown[li].prize_type === "string" ? String(shown[li].prize_type).toLowerCase() : "no_prize"
10780
- });
10781
- }, 8e3);
11558
+ timedOut = true;
11559
+ pauseForRetry(SPIN_AGAIN_MESSAGE);
11560
+ }, DRAW_ANSWER_TIMEOUT_MS);
10782
11561
  };
10783
11562
  if (spinMode === "button" || spinMode === "both") {
10784
11563
  btn.addEventListener("click", () => beginSpin(0.7));
@@ -11261,12 +12040,38 @@ const _AegisInAppManager = class _AegisInAppManager {
11261
12040
  revealed = true;
11262
12041
  this.addAnimationStyles();
11263
12042
  void this.trackEvent(campaign.id, "clicked");
11264
- return Promise.resolve(dealOnce()).then(() => this.submitWidgetResponse(campaign, "scratch", { state: "revealed" })).then((resp) => {
12043
+ const answered = Promise.resolve(dealOnce()).then(() => this.submitWidgetResponse(campaign, "scratch", { state: "revealed" }));
12044
+ const bounded = Promise.race([
12045
+ answered,
12046
+ new Promise((resolve) => window.setTimeout(() => resolve(null), DRAW_ANSWER_TIMEOUT_MS))
12047
+ ]);
12048
+ return bounded.then((resp) => {
12049
+ var _a;
11265
12050
  if (!resp) {
11266
12051
  revealed = false;
12052
+ const again = prizeStateOf(null, this.takeRetryAnswer(campaign.id));
12053
+ let note = body.querySelector("[data-aegis-scratch-retry]");
12054
+ if (!note) {
12055
+ note = document.createElement("div");
12056
+ note.setAttribute("data-aegis-scratch-retry", "");
12057
+ note.style.cssText = "margin-top: 6px; font-size: 12px; font-weight: 600; opacity: 0.8;";
12058
+ body.appendChild(note);
12059
+ }
12060
+ note.textContent = again.state === "spin_again" ? again.message : "";
11267
12061
  return false;
11268
12062
  }
11269
- const won = scratchOutcome(resp) === true;
12063
+ (_a = body.querySelector("[data-aegis-scratch-retry]")) == null ? void 0 : _a.remove();
12064
+ const st2 = prizeStateOf(resp);
12065
+ if (st2.state === "non_redeemable") {
12066
+ const nrLabel = this._extractPrizeLabel(resp) || "";
12067
+ prizeText.textContent = nrLabel ? `${nrLabel}: ${st2.message}` : st2.message;
12068
+ if (st2.claimable) body.appendChild(claimButton(() => this.startAnonClaim(campaign.id)));
12069
+ else if (st2.signIn) {
12070
+ body.appendChild(claimButton(() => this.dispatchAction({ type: "open_login" }, campaign.id), SIGN_IN_BUTTON_LABEL));
12071
+ }
12072
+ return true;
12073
+ }
12074
+ const won = scratchOutcome(resp) === true && (st2.state === "credited_win" || !resp.prize);
11270
12075
  const sampleLabel = sampleWin && typeof sampleWin.label === "string" ? sampleWin.label : "";
11271
12076
  const label = this._extractPrizeLabel(resp) || sampleLabel || ic.scratch_prize_label || "You won!";
11272
12077
  const code = this._extractCouponCode(resp) || "";
@@ -11467,7 +12272,12 @@ const _AegisInAppManager = class _AegisInAppManager {
11467
12272
  if (Array.isArray(campaign.delivery_modes) && campaign.delivery_modes.length > 0 && !campaign.delivery_modes.includes("in_app_overlay")) {
11468
12273
  return;
11469
12274
  }
11470
- const proceed = this.emit("campaign-will-show", campaign);
12275
+ if (this.overlaysHeld && campaign.type !== "active_web_chat") {
12276
+ this.log(`campaign ${campaign.id} not drawn: overlays held by the host`);
12277
+ return;
12278
+ }
12279
+ const willShow = { target: "overlay" };
12280
+ const proceed = this.emit("campaign-will-show", campaign, willShow);
11471
12281
  if (!proceed) {
11472
12282
  this.log(`campaign ${campaign.id} suppressed by campaign-will-show handler`);
11473
12283
  return;
@@ -11644,7 +12454,9 @@ const _AegisInAppManager = class _AegisInAppManager {
11644
12454
  sanitizeUrl: (url) => this.sanitizeUrl(url),
11645
12455
  navigate: (url, buttonId) => this.navigateToCampaignAction(campaign, url, buttonId),
11646
12456
  dispatchAction: (action) => this.dispatchAction(action, campaign.id),
12457
+ claimAnonWin: () => this.startAnonClaim(campaign.id),
11647
12458
  submitResponse: (responseType, payload) => this.submitWidgetResponse(campaign, responseType, payload),
12459
+ takeRetryAnswer: () => this.takeRetryAnswer(campaign.id),
11648
12460
  playReaction: (el2, intent, lottieFile, scope) => this._playReaction(el2, intent, lottieFile, campaign.interactive_config, scope),
11649
12461
  haptic: (pattern) => {
11650
12462
  try {
@@ -12218,6 +13030,7 @@ const _AegisInAppManager = class _AegisInAppManager {
12218
13030
  */
12219
13031
  async _subscribeFromPushPrimer() {
12220
13032
  var _a, _b, _c, _d, _e;
13033
+ if (this.previewOnly) return "default";
12221
13034
  if (!this.propertyId) {
12222
13035
  return Notification.requestPermission();
12223
13036
  }
@@ -14331,6 +15144,7 @@ const _AegisInAppManager = class _AegisInAppManager {
14331
15144
  });
14332
15145
  }
14333
15146
  }
15147
+ if (this.previewOnly) return;
14334
15148
  try {
14335
15149
  const url = `${this.apiHost}/v1/in-app/events`;
14336
15150
  const externalEventId = `inapp_${campaignId}_${eventType}_${Date.now()}`;
@@ -14435,6 +15249,7 @@ const _AegisInAppManager = class _AegisInAppManager {
14435
15249
  * nothing — so a duplicate ack is harmless.
14436
15250
  */
14437
15251
  async ackJourneyQueueItem(step, action, attempt = 0) {
15252
+ if (this.previewOnly) return;
14438
15253
  const key = `${step}:${action}`;
14439
15254
  if (attempt === 0) {
14440
15255
  if (this.journeyAcks.has(key)) return;
@@ -14510,6 +15325,11 @@ const _AegisInAppManager = class _AegisInAppManager {
14510
15325
  }
14511
15326
  this.renderedSlots.forEach((slot) => this.clearSlotContent(slot));
14512
15327
  this.renderedSlots.clear();
15328
+ this.ownAnchorWrappers.forEach((w) => w.remove());
15329
+ this.ownAnchorWrappers.clear();
15330
+ this.anchorWrappers = /* @__PURE__ */ new WeakMap();
15331
+ this.pendingSlotRender = false;
15332
+ this.pendingAnchorRender = false;
14513
15333
  this.filledSlots = /* @__PURE__ */ new WeakSet();
14514
15334
  this.slotSignatures = /* @__PURE__ */ new WeakMap();
14515
15335
  this.slotTimers = /* @__PURE__ */ new WeakMap();
@@ -15105,7 +15925,7 @@ class SdkConfigPoller {
15105
15925
  if (this.currentETag) {
15106
15926
  headers["If-None-Match"] = this.currentETag;
15107
15927
  }
15108
- const response = await fetch(`${this.options.apiHost}/v1/sdk/config`, {
15928
+ const response = await fetchWithAbort(`${this.options.apiHost}/v1/sdk/config`, {
15109
15929
  method: "GET",
15110
15930
  headers
15111
15931
  });
@@ -15317,7 +16137,7 @@ class PrefetchBundleClient {
15317
16137
  }
15318
16138
  let response;
15319
16139
  try {
15320
- response = await fetch(url, { method: "GET", headers, cache: "no-cache" });
16140
+ response = await fetchWithAbort(url, { method: "GET", headers, cache: "no-cache" });
15321
16141
  } catch (err) {
15322
16142
  logger.warn("prefetch-bundle fetch network error:", err);
15323
16143
  return this.currentBundle;
@@ -17175,7 +17995,7 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
17175
17995
  this.initialized = false;
17176
17996
  this.armedInAppTriggers = /* @__PURE__ */ new Set();
17177
17997
  {
17178
- const v = "1.48.0";
17998
+ const v = "1.50.0";
17179
17999
  try {
17180
18000
  globalThis.__AEGIS_SDK_VERSION__ = v;
17181
18001
  } catch {
@@ -17196,6 +18016,8 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
17196
18016
  const ownsTriggerEngine = !config.triggerEngine;
17197
18017
  this.triggerEngine = triggerEngine;
17198
18018
  this.ownsTriggerEngine = ownsTriggerEngine;
18019
+ const previewOnly = config.previewOnly === true || isPreviewPage();
18020
+ this.spotsOnly = config.spotsOnly === true || previewOnly;
17199
18021
  this.contactId = config.contactId;
17200
18022
  this.contactToken = config.contactToken;
17201
18023
  this.pairingApiHost = config.apiHost ?? "";
@@ -17232,6 +18054,7 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
17232
18054
  propertyId: config.propertyId,
17233
18055
  debugMode: config.debugMode,
17234
18056
  enableSSE: config.enableSSE,
18057
+ previewOnly,
17235
18058
  getWorkspaceId: config.getWorkspaceId,
17236
18059
  // First-party cart reader — renderers (progress-bar) read live cart
17237
18060
  // state from here instead of `window.*` cart globals. See setCartState().
@@ -17266,7 +18089,7 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
17266
18089
  apiHost: config.apiHost,
17267
18090
  debugMode: config.debugMode
17268
18091
  });
17269
- if (config.enableChat) {
18092
+ if (config.enableChat && !previewOnly) {
17270
18093
  this.chat = new AegisChat({
17271
18094
  writeKey: config.writeKey,
17272
18095
  apiHost: config.apiHost,
@@ -17335,7 +18158,8 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
17335
18158
  maybeStartPairing(this.pairingApiHost);
17336
18159
  await Promise.all([
17337
18160
  this.inApp.initialize(),
17338
- this.widgets.initialize()
18161
+ // A spot-only page never starts the pop-up widget layer.
18162
+ this.spotsOnly ? Promise.resolve() : this.widgets.initialize()
17339
18163
  ]);
17340
18164
  (_a = this.chat) == null ? void 0 : _a.initialize();
17341
18165
  if (this.ownsTriggerEngine) {
@@ -17601,13 +18425,28 @@ async function bootstrap(apiHost, req) {
17601
18425
  if (req.attestationToken) body.attestationToken = req.attestationToken;
17602
18426
  if (req.userAgent) body.userAgent = req.userAgent;
17603
18427
  const url = `${apiHost.replace(/\/$/, "")}/v1/sdk/bootstrap`;
17604
- const doFetch = async () => fetch(url, {
17605
- method: "POST",
17606
- headers: { "Content-Type": "application/json" },
17607
- body: JSON.stringify(body),
17608
- credentials: "omit"
17609
- });
17610
- let resp = await doFetch();
18428
+ const doFetch = async () => {
18429
+ try {
18430
+ return await fetchWithAbort(url, {
18431
+ method: "POST",
18432
+ headers: { "Content-Type": "application/json" },
18433
+ body: JSON.stringify(body),
18434
+ credentials: "omit"
18435
+ });
18436
+ } catch (err) {
18437
+ if (isAbortError(err)) {
18438
+ throw new BootstrapError(0, `Bootstrap timed out after ${SDK_FETCH_ABORT_MS} ms`);
18439
+ }
18440
+ throw err;
18441
+ }
18442
+ };
18443
+ let resp;
18444
+ try {
18445
+ resp = await doFetch();
18446
+ } catch (err) {
18447
+ if (!(err instanceof BootstrapError) || err.status !== 0) throw err;
18448
+ resp = await doFetch();
18449
+ }
17611
18450
  if (resp.status >= 500) {
17612
18451
  await new Promise((r) => setTimeout(r, 750));
17613
18452
  resp = await doFetch();
@@ -17672,9 +18511,11 @@ export {
17672
18511
  fallbackUrlForAction,
17673
18512
  getChatContext,
17674
18513
  getCurrentLauncher,
18514
+ isPreviewPage,
17675
18515
  isReplaceableRailTitle,
17676
18516
  mountScratchSurface,
17677
18517
  m as murmurhash3_x86_32,
18518
+ onLauncherChange,
17678
18519
  openChat,
17679
18520
  parseAction,
17680
18521
  readFirstPartyCookie,