@gengage/assistant-fe 0.3.27 → 0.3.29

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/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, c as t, d as r, f as s, n, o as C, p as c, r as h, s as l, t as o } from "./chat-CWnNdto9.js";
1
+ import { a as e, c as t, d as r, f as s, n, o as C, p as c, r as h, s as l, t as o } from "./chat-3M_eI0kY.js";
2
2
  export {
3
3
  r as CHAT_SCROLL_ELEMENT_ID,
4
4
  e as ChatPresentationState,
@@ -0,0 +1 @@
1
+ export declare function escapeCssIdentifier(value: string): string;
@@ -1,7 +1,7 @@
1
1
  import { OverlayWidgetsController, OverlayWidgetsOptions } from './overlay.js';
2
2
  export declare const DEFAULT_NATIVE_TRACKED_EVENTS: readonly ["gengage:chat:open", "gengage:chat:close", "gengage:chat:ready", "gengage:chat:add-to-cart", "gengage:qna:action", "gengage:qna:open-chat", "gengage:similar:product-click", "gengage:similar:add-to-cart", "gengage:global:error", "gengage:context:update"];
3
3
  export type NativeTrackedEvent = (typeof DEFAULT_NATIVE_TRACKED_EVENTS)[number];
4
- export type NativeInboundMessage = 'openChat' | 'closeChat' | 'updateContext' | 'updateSku' | 'setSession' | 'destroy';
4
+ export type NativeInboundMessage = 'openChat' | 'closeChat' | 'updateContext' | 'updatePageContext' | 'setPageContext' | 'updateSku' | 'setSession' | 'destroy';
5
5
  export type NativeBridgeEnvironment = 'ios' | 'android' | 'react-native' | 'browser';
6
6
  export interface NativeSessionPayload {
7
7
  sessionId?: string;
@@ -111,7 +111,18 @@ export interface OverlayWidgetsController {
111
111
  state?: 'half' | 'full';
112
112
  }): void;
113
113
  closeChat(): void;
114
+ /**
115
+ * Merges partial page context (SKU, page type, category, …) into the active
116
+ * widgets. Use after SPA navigation so chat and PDP stay aligned.
117
+ */
114
118
  updateContext(patch: Partial<PageContext>): Promise<void>;
119
+ /** @see {@link updateContext} */
120
+ updatePageContext(patch: Partial<PageContext>): Promise<void>;
121
+ /**
122
+ * Merge-only page context update. This is an alias of {@link updateContext},
123
+ * not a full replacement of the existing PageContext.
124
+ */
125
+ setPageContext(patch: Partial<PageContext>): Promise<void>;
115
126
  updateSku(sku: string, pageType?: PageContext['pageType']): Promise<void>;
116
127
  destroy(): void;
117
128
  }
@@ -18,6 +18,8 @@ export interface PageContext {
18
18
  pageType: 'pdp' | 'plp' | 'home' | 'cart' | 'search' | 'other';
19
19
  /** Product SKU — required on PDP pages for QNA and Similar Products. */
20
20
  sku?: string;
21
+ /** Product SKU list — for PLP pages, used with the launchProductList init action. */
22
+ skuList?: string[];
21
23
  /** Product price, formatted as a string (e.g. "149.99"). */
22
24
  price?: string;
23
25
  /** Category path array, from broad to specific (e.g. ["Electronics", "TVs"]). */
@@ -1,5 +1,5 @@
1
- import { f as u } from "./schemas-DJ1qbfi8.js";
2
- import { h, l as f } from "./native-webview-CaasrbNn.js";
1
+ import { f as u } from "./schemas-BG_cvFvP.js";
2
+ import { h, l as f } from "./native-webview-3zNu74gQ.js";
3
3
  var m = {
4
4
  enabled: !0,
5
5
  endpoint: "/analytics",
package/dist/common.js CHANGED
@@ -1,9 +1,9 @@
1
- import { C as a, S as t, b as s, d as r, f as n, g as i, h as o, m as c, p as m, v as l, w as g, x as d, y as u } from "./schemas-DJ1qbfi8.js";
1
+ import { C as a, S as t, b as s, d as r, f as n, g as i, h as o, m as c, p as m, v as l, w as g, x as d, y as u } from "./schemas-BG_cvFvP.js";
2
2
  import { $ as E, A as S, D as h, E as v, F as y, G as C, H as f, I as A, J as T, K as w, L as U, M as W, N as I, O as P, P as D, Q as k, S as R, T as b, U as G, V as O, W as N, X as x, Y as L, Z as M, et as _, j as H, k as z, q as B, v as F, w as K, x as V, y as Q } from "./ga-datalayer-BwxWX-cr.js";
3
- import { i as Z, l as j, m as J, u as X } from "./chat-CWnNdto9.js";
3
+ import { i as Z, l as j, m as J, u as X } from "./chat-3M_eI0kY.js";
4
4
  import { n as $, t as ee } from "./connection-warning-CHHi3BAf.js";
5
- import { a as te, c as se, d as re, f as ne, h as ie, i as oe, l as ce, m as me, n as le, o as ge, p as de, r as ue, s as pe, u as Ee } from "./native-webview-CaasrbNn.js";
6
- import { a as he, c as ve, d as ye, f as Ce, i as fe, l as Ae, n as Te, o as we, p as Ue, r as We, s as Ie, t as Pe, u as De } from "./common-DKSCFuWo.js";
5
+ import { a as te, c as se, d as re, f as ne, h as ie, i as oe, l as ce, m as me, n as le, o as ge, p as de, r as ue, s as pe, u as Ee } from "./native-webview-3zNu74gQ.js";
6
+ import { a as he, c as ve, d as ye, f as Ce, i as fe, l as Ae, n as Te, o as we, p as Ue, r as We, s as Ie, t as Pe, u as De } from "./common-BYOYS_Ug.js";
7
7
  export {
8
8
  Ee as AccountRuntimeConfigSchema,
9
9
  re as AnalyticsAuthModeSchema,
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { C as a, b as t, d as s, f as i, w as n, x as r } from "./schemas-DJ1qbfi8.js";
1
+ import { C as a, b as t, d as s, f as i, w as n, x as r } from "./schemas-BG_cvFvP.js";
2
2
  import { A as c, D as m, E as l, F as d, I as g, L as p, N as u, O as S, P as f, k as C, v as U } from "./ga-datalayer-BwxWX-cr.js";
3
- import { c as A, i as I, l as y, m as R, n as D, o as E, s as T, t as W, u as w } from "./chat-CWnNdto9.js";
3
+ import { c as A, i as I, l as y, m as R, n as D, o as E, s as T, t as W, u as w } from "./chat-3M_eI0kY.js";
4
4
  import { t as N } from "./connection-warning-CHHi3BAf.js";
5
- import { a as P, i as k, n as G, o as L, t as Q } from "./qna-D33BNaWd.js";
6
- import { a as b, i as x, n as B, o as F, t as M } from "./simrel-DstZ5m2H.js";
5
+ import { a as P, i as k, n as G, o as L, t as Q } from "./qna-R1-EoKwH.js";
6
+ import { a as b, i as x, n as B, o as F, t as M } from "./simrel-BREHamN-.js";
7
7
  import { n as H, t as K } from "./simbut-BBXTlzOg.js";
8
- import { a as Z, c as j, d as q, f as J, h as X, i as Y, l as $, m as ee, n as ae, o as te, p as se, r as ie, s as ne, u as re } from "./native-webview-CaasrbNn.js";
9
- import { a as ce, c as me, d as le, i as de, l as ge, n as pe, o as ue, p as Se, r as fe, s as Ce, t as Ue, u as he } from "./common-DKSCFuWo.js";
8
+ import { a as Z, c as j, d as q, f as J, h as X, i as Y, l as $, m as ee, n as ae, o as te, p as se, r as ie, s as ne, u as re } from "./native-webview-3zNu74gQ.js";
9
+ import { a as ce, c as me, d as le, i as de, l as ge, n as pe, o as ue, p as Se, r as fe, s as Ce, t as Ue, u as he } from "./common-BYOYS_Ug.js";
10
10
  export {
11
11
  re as AccountRuntimeConfigSchema,
12
12
  q as AnalyticsAuthModeSchema,
@@ -1,15 +1,15 @@
1
- import { a as M, c as h, i as D, o as f, r as m, t as x } from "./schemas-DJ1qbfi8.js";
2
- import { I as H, M as Q, b as k, z as K } from "./ga-datalayer-BwxWX-cr.js";
3
- import { t as V } from "./chat-CWnNdto9.js";
4
- import { t as j } from "./qna-D33BNaWd.js";
5
- import { t as $ } from "./simrel-DstZ5m2H.js";
1
+ import { a as k, c as h, i as D, o as f, r as m, t as A } from "./schemas-BG_cvFvP.js";
2
+ import { I as H, M as Q, b as M, z as K } from "./ga-datalayer-BwxWX-cr.js";
3
+ import { t as V } from "./chat-3M_eI0kY.js";
4
+ import { t as $ } from "./qna-R1-EoKwH.js";
5
+ import { t as j } from "./simrel-BREHamN-.js";
6
6
  import { t as G } from "./simbut-BBXTlzOg.js";
7
7
  var b = f({ enabled: m().default(!0) }), Y = f({
8
8
  chat: h().optional(),
9
9
  qna: h().optional(),
10
10
  simrel: h().optional(),
11
11
  simbut: h().optional()
12
- }), J = f({}), X = x([
12
+ }), J = f({}), X = A([
13
13
  "none",
14
14
  "x-api-key-header",
15
15
  "bearer-header",
@@ -29,19 +29,19 @@ var b = f({ enabled: m().default(!0) }), Y = f({
29
29
  fireAndForget: m().default(!0),
30
30
  useBeacon: m().default(!0),
31
31
  keepaliveFetch: m().default(!0),
32
- timeoutMs: M().int().positive().default(4e3),
33
- maxRetries: M().int().min(0).max(5).default(1)
32
+ timeoutMs: k().int().positive().default(4e3),
33
+ maxRetries: k().int().min(0).max(5).default(1)
34
34
  }), R = "__gengageWidgetsInit", ee = f({
35
35
  idempotencyKey: h().default(R),
36
36
  requireDomReady: m().default(!0)
37
- }), te = x([
37
+ }), te = A([
38
38
  "log-and-ignore",
39
39
  "throw",
40
40
  "delegate"
41
41
  ]), ie = f({
42
42
  unknownActionPolicy: te.default("log-and-ignore"),
43
43
  allowScriptCall: m().default(!1)
44
- }), B = f({
44
+ }), L = f({
45
45
  version: D("1", { error: 'version must be "1"' }),
46
46
  accountId: h({ error: "accountId must be a non-empty string" }).min(1, { error: "accountId must be a non-empty string" }),
47
47
  middlewareUrl: h({ error: 'middlewareUrl must be a valid URL (e.g. "https://your-backend.example.com")' }).url({ error: 'middlewareUrl must be a valid URL (e.g. "https://your-backend.example.com")' }),
@@ -77,15 +77,15 @@ var b = f({ enabled: m().default(!0) }), Y = f({
77
77
  })
78
78
  });
79
79
  function ne(e) {
80
- k("config", "parsing account runtime config", e);
81
- const t = B.parse(e);
82
- return k("config", "config resolved", {
80
+ M("config", "parsing account runtime config", e);
81
+ const t = L.parse(e);
82
+ return M("config", "config resolved", {
83
83
  accountId: t.accountId,
84
84
  middlewareUrl: t.middlewareUrl
85
85
  }), t;
86
86
  }
87
87
  function qe(e) {
88
- return B.safeParse(e);
88
+ return L.safeParse(e);
89
89
  }
90
90
  function Se(e) {
91
91
  return ne({
@@ -101,7 +101,7 @@ function Se(e) {
101
101
  }
102
102
  });
103
103
  }
104
- var O = `${R}_overlay_`, se = "#gengage-qna", oe = "#gengage-simrel", ae = "#gengage-simbut";
104
+ var P = `${R}_overlay_`, se = "#gengage-qna", oe = "#gengage-simrel", ae = "#gengage-simbut";
105
105
  function q() {
106
106
  const e = window;
107
107
  return e.__gengageOverlayRegistry || (e.__gengageOverlayRegistry = {
@@ -111,7 +111,7 @@ function q() {
111
111
  }
112
112
  function re(e) {
113
113
  const t = { pageType: e.pageContext?.pageType ?? (e.sku !== void 0 ? "pdp" : "other") }, i = e.pageContext;
114
- return i?.sku !== void 0 && (t.sku = i.sku), i?.price !== void 0 && (t.price = i.price), i?.categoryTree !== void 0 && (t.categoryTree = i.categoryTree), i?.url !== void 0 && (t.url = i.url), i?.extra !== void 0 && (t.extra = i.extra), e.sku !== void 0 && (t.sku = e.sku), t;
114
+ return i?.sku !== void 0 && (t.sku = i.sku), i?.skuList !== void 0 && (t.skuList = i.skuList), i?.price !== void 0 && (t.price = i.price), i?.categoryTree !== void 0 && (t.categoryTree = i.categoryTree), i?.url !== void 0 && (t.url = i.url), i?.extra !== void 0 && (t.extra = i.extra), e.sku !== void 0 && (t.sku = e.sku), t;
115
115
  }
116
116
  function de(e, t) {
117
117
  const i = {
@@ -119,17 +119,17 @@ function de(e, t) {
119
119
  ...t,
120
120
  pageType: t.pageType ?? e.pageType
121
121
  };
122
- return t.sku === void 0 && e.sku !== void 0 && (i.sku = e.sku), i;
122
+ return t.pageType !== void 0 && t.pageType !== e.pageType ? (t.pageType !== "pdp" && t.sku === void 0 && delete i.sku, t.pageType !== "plp" && t.skuList === void 0 && delete i.skuList) : (t.sku === void 0 && e.sku !== void 0 && (i.sku = e.sku), t.skuList === void 0 && e.skuList !== void 0 && (i.skuList = e.skuList)), i;
123
123
  }
124
124
  function I(e) {
125
125
  return e instanceof HTMLElement || document.querySelector(e) ? e : null;
126
126
  }
127
- function P(e) {
128
- return e.idempotencyKey ?? `${O}${e.accountId}`;
127
+ function B(e) {
128
+ return e.idempotencyKey ?? `${P}${e.accountId}`;
129
129
  }
130
130
  var le = class {
131
131
  constructor(e, t) {
132
- this.options = e, this.onDestroy = t, this._chat = null, this._qna = null, this._simrel = null, this._simbut = null, this._analyticsClient = null, this._offQnaWire = null, this._destroyed = !1, this._queue = Promise.resolve(), this._warnedQnaMountMissing = !1, this._warnedSimRelMountMissing = !1, this._warnedSimButMountMissing = !1, this._warnedSimButNoChat = !1, this.idempotencyKey = P(e), this.session = Q(e.session), this._pageContext = re(e);
132
+ this.options = e, this.onDestroy = t, this._chat = null, this._qna = null, this._simrel = null, this._simbut = null, this._analyticsClient = null, this._offQnaWire = null, this._destroyed = !1, this._queue = Promise.resolve(), this._warnedQnaMountMissing = !1, this._warnedSimRelMountMissing = !1, this._warnedSimButMountMissing = !1, this._warnedSimButNoChat = !1, this.idempotencyKey = B(e), this.session = Q(e.session), this._pageContext = re(e);
133
133
  }
134
134
  get chat() {
135
135
  return this._chat;
@@ -157,7 +157,7 @@ var le = class {
157
157
  }
158
158
  async updateContext(e) {
159
159
  this._destroyed || await this._enqueue(async () => {
160
- this._pageContext = de(this._pageContext, e), window.gengage || (window.gengage = {}), window.gengage.pageContext = this._pageContext, this._chat?.update(e), this._qna?.update(e), this._simrel?.update(e), this._simbut?.update(e), await this._syncPdpWidgets();
160
+ this._pageContext = de(this._pageContext, e), window.gengage || (window.gengage = {}), window.gengage.pageContext = this._pageContext, this._chat?.update(this._pageContext), this._qna?.update(this._pageContext), this._simrel?.update(this._pageContext), this._simbut?.update(this._pageContext), await this._syncPdpWidgets();
161
161
  });
162
162
  }
163
163
  async updateSku(e, t = "pdp") {
@@ -166,6 +166,12 @@ var le = class {
166
166
  pageType: t
167
167
  });
168
168
  }
169
+ async updatePageContext(e) {
170
+ await this.updateContext(e);
171
+ }
172
+ async setPageContext(e) {
173
+ await this.updateContext(e);
174
+ }
169
175
  destroy() {
170
176
  this._destroyed || (this._destroyed = !0, this._offQnaWire?.(), this._offQnaWire = null, this._chat?.destroy(), this._qna?.destroy(), this._simrel?.destroy(), this._simbut?.destroy(), this._chat = null, this._qna = null, this._simrel = null, this._simbut = null, window.gengage?.overlay === this && delete window.gengage.overlay, this.onDestroy());
171
177
  }
@@ -197,7 +203,7 @@ var le = class {
197
203
  sku: e
198
204
  });
199
205
  else {
200
- const o = new j(), n = {
206
+ const o = new $(), n = {
201
207
  accountId: this.options.accountId,
202
208
  middlewareUrl: t,
203
209
  session: this.session,
@@ -224,15 +230,15 @@ var le = class {
224
230
  sku: e
225
231
  });
226
232
  else {
227
- const o = new $(), n = {
233
+ const o = new j(), n = {
228
234
  accountId: this.options.accountId,
229
235
  middlewareUrl: t,
230
236
  session: this.session,
231
237
  sku: e,
232
238
  mountTarget: s
233
239
  };
234
- this.options.theme !== void 0 && (n.theme = this.options.theme), this.options.pricing !== void 0 && (n.pricing = this.options.pricing), this.options.simrel?.discountType !== void 0 && (n.discountType = this.options.simrel.discountType), this.options.simrel?.renderCardElement !== void 0 && (n.renderCardElement = this.options.simrel.renderCardElement), this.options.simrel?.renderer !== void 0 && (n.renderer = this.options.simrel.renderer), this.options.onAddToCart !== void 0 && (n.onAddToCart = this.options.onAddToCart), this.options.onProductNavigate !== void 0 ? n.onProductNavigate = this.options.onProductNavigate : n.onProductNavigate = (d, u, a) => {
235
- K(d) && (this._chat?.saveSession(a ?? this.session.sessionId, u), window.location.href = d);
240
+ this.options.theme !== void 0 && (n.theme = this.options.theme), this.options.pricing !== void 0 && (n.pricing = this.options.pricing), this.options.simrel?.discountType !== void 0 && (n.discountType = this.options.simrel.discountType), this.options.simrel?.renderCardElement !== void 0 && (n.renderCardElement = this.options.simrel.renderCardElement), this.options.simrel?.renderer !== void 0 && (n.renderer = this.options.simrel.renderer), this.options.onAddToCart !== void 0 && (n.onAddToCart = this.options.onAddToCart), this.options.onProductNavigate !== void 0 ? n.onProductNavigate = this.options.onProductNavigate : n.onProductNavigate = (d, c, a) => {
241
+ K(d) && (this._chat?.saveSession(a ?? this.session.sessionId, c), window.location.href = d);
236
242
  }, await o.init(n), this._simrel = o;
237
243
  }
238
244
  else
@@ -272,27 +278,27 @@ var le = class {
272
278
  }), t;
273
279
  }
274
280
  };
275
- async function ce(e) {
276
- const t = P(e), i = q(), s = i.instances[t];
281
+ async function ue(e) {
282
+ const t = B(e), i = q(), s = i.instances[t];
277
283
  if (s) return s;
278
284
  const o = i.pending[t];
279
285
  if (o) return o;
280
286
  const n = new le(e, () => {
281
- const u = q();
282
- delete u.instances[t], delete u.pending[t];
283
- }), d = n.init().then(() => (i.instances[t] = n, delete i.pending[t], n)).catch((u) => {
284
- throw delete i.pending[t], u;
287
+ const c = q();
288
+ delete c.instances[t], delete c.pending[t];
289
+ }), d = n.init().then(() => (i.instances[t] = n, delete i.pending[t], n)).catch((c) => {
290
+ throw delete i.pending[t], c;
285
291
  });
286
292
  return i.pending[t] = d, d;
287
293
  }
288
- function ue(e) {
294
+ function ce(e) {
289
295
  return q().instances[e] ?? null;
290
296
  }
291
297
  function Ne(e) {
292
- ue(e)?.destroy();
298
+ ce(e)?.destroy();
293
299
  }
294
- function Me(e) {
295
- return `${O}${e}`;
300
+ function ke(e) {
301
+ return `${P}${e}`;
296
302
  }
297
303
  var ge = [
298
304
  "gengage:chat:open",
@@ -305,7 +311,7 @@ var ge = [
305
311
  "gengage:similar:add-to-cart",
306
312
  "gengage:global:error",
307
313
  "gengage:context:update"
308
- ], he = 32, U = "#gengage-qna", E = "#gengage-simrel";
314
+ ], he = 32, x = "#gengage-qna", U = "#gengage-simrel";
309
315
  function pe(e) {
310
316
  let t = e;
311
317
  if (typeof e == "string") {
@@ -353,15 +359,15 @@ function fe(e) {
353
359
  function S(e, t) {
354
360
  return t instanceof HTMLElement ? !0 : typeof t != "string" ? !1 : e.document.querySelector(t) !== null;
355
361
  }
356
- function A(e, t, i) {
362
+ function E(e, t, i) {
357
363
  if (t instanceof HTMLElement || S(e, t) || typeof t != "string") return t;
358
364
  if (t.startsWith("#")) {
359
365
  const n = t.slice(1);
360
366
  if (n.length > 0) {
361
367
  const d = e.document.getElementById(n);
362
368
  if (d) return d;
363
- const u = e.document.createElement("div");
364
- return u.id = n, e.document.body.appendChild(u), u;
369
+ const c = e.document.createElement("div");
370
+ return c.id = n, e.document.body.appendChild(c), c;
365
371
  }
366
372
  }
367
373
  const s = e.document.getElementById(i);
@@ -369,7 +375,7 @@ function A(e, t, i) {
369
375
  const o = e.document.createElement("div");
370
376
  return o.id = i, e.document.body.appendChild(o), o;
371
377
  }
372
- function F(e, t) {
378
+ function O(e, t) {
373
379
  const i = e.webkit?.messageHandlers?.[t];
374
380
  return i && typeof i.postMessage == "function" ? i.postMessage.bind(i) : null;
375
381
  }
@@ -379,7 +385,7 @@ function w(e, t) {
379
385
  }
380
386
  function me(e = {}) {
381
387
  const t = e.win ?? window, i = e.iosHandlerName ?? "gengage", s = e.androidInterfaceName ?? "GengageNative", o = e.reactNativeInterfaceName ?? "ReactNativeWebView";
382
- return F(t, i) ? "ios" : w(t, s) ? "android" : w(t, o) ? "react-native" : "browser";
388
+ return O(t, i) ? "ios" : w(t, s) ? "android" : w(t, o) ? "react-native" : "browser";
383
389
  }
384
390
  function ve(e, t = {}) {
385
391
  const i = t.win ?? window;
@@ -399,27 +405,27 @@ function ve(e, t = {}) {
399
405
  function ye(e = {}) {
400
406
  const t = e.win ?? window, i = t;
401
407
  if (i.gengageNative) return i.gengageNative;
402
- const s = e.iosHandlerName ?? "gengage", o = e.androidInterfaceName ?? "GengageNative", n = e.reactNativeInterfaceName ?? "ReactNativeWebView", d = e.trackedEvents ?? [...ge], u = me({
408
+ const s = e.iosHandlerName ?? "gengage", o = e.androidInterfaceName ?? "GengageNative", n = e.reactNativeInterfaceName ?? "ReactNativeWebView", d = e.trackedEvents ?? [...ge], c = me({
403
409
  win: t,
404
410
  iosHandlerName: s,
405
411
  androidInterfaceName: o,
406
412
  reactNativeInterfaceName: n
407
413
  });
408
414
  let a = t.gengage?.overlay ?? null;
409
- const c = [], v = (l, r) => {
415
+ const u = [], v = (l, r) => {
410
416
  const p = r === void 0 ? { type: l } : {
411
417
  type: l,
412
418
  payload: r
413
419
  };
414
- if (u === "ios") {
415
- F(t, s)?.(p);
420
+ if (c === "ios") {
421
+ O(t, s)?.(p);
416
422
  return;
417
423
  }
418
- if (u === "android") {
424
+ if (c === "android") {
419
425
  w(t, o)?.postMessage(JSON.stringify(p));
420
426
  return;
421
427
  }
422
- if (u === "react-native") {
428
+ if (c === "react-native") {
423
429
  w(t, n)?.postMessage(JSON.stringify(p));
424
430
  return;
425
431
  }
@@ -432,7 +438,7 @@ function ye(e = {}) {
432
438
  });
433
439
  };
434
440
  t.addEventListener("gengage:bridge:message", y);
435
- const L = d.map((l) => {
441
+ const F = d.map((l) => {
436
442
  const r = (p) => {
437
443
  const g = p.detail;
438
444
  v("widget_event", {
@@ -445,10 +451,10 @@ function ye(e = {}) {
445
451
  handler: r
446
452
  };
447
453
  }), _ = (l) => {
448
- c.length >= he && c.shift(), c.push(l);
454
+ u.length >= he && u.shift(), u.push(l);
449
455
  }, W = () => {
450
- if (!a || c.length === 0) return;
451
- const l = c.splice(0, c.length);
456
+ if (!a || u.length === 0) return;
457
+ const l = u.splice(0, u.length);
452
458
  for (const r of l) N(r);
453
459
  }, N = (l) => {
454
460
  const r = pe(l);
@@ -465,7 +471,9 @@ function ye(e = {}) {
465
471
  a ? a.closeChat() : _(r);
466
472
  return;
467
473
  case "updateContext":
468
- a && g && typeof g == "object" ? a.updateContext(g) : a ? console.warn("[gengage:native-bridge] updateContext: missing payload") : _(r);
474
+ case "updatePageContext":
475
+ case "setPageContext":
476
+ a && g && typeof g == "object" ? a.updateContext(g) : a ? console.warn(`[gengage:native-bridge] ${p}: missing payload`) : _(r);
469
477
  return;
470
478
  case "updateSku": {
471
479
  const T = fe(g);
@@ -490,7 +498,7 @@ function ye(e = {}) {
490
498
  }, t.location.origin), e.logUnhandled && console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:", p);
491
499
  }
492
500
  }, C = {
493
- env: u,
501
+ env: c,
494
502
  sendToNative: v,
495
503
  receive: N,
496
504
  setController(l) {
@@ -498,23 +506,23 @@ function ye(e = {}) {
498
506
  },
499
507
  destroy() {
500
508
  t.removeEventListener("gengage:bridge:message", y);
501
- for (const l of L) t.removeEventListener(l.event, l.handler);
502
- c.splice(0, c.length), t.gengageNative === C && delete t.gengageNative;
509
+ for (const l of F) t.removeEventListener(l.event, l.handler);
510
+ u.splice(0, u.length), t.gengageNative === C && delete t.gengageNative;
503
511
  }
504
512
  };
505
513
  return i.gengageNative = C, C;
506
514
  }
507
- async function ke(e) {
515
+ async function Me(e) {
508
516
  const { nativeBridge: t, emitReadyEvent: i = !0, ...s } = e, o = ye(t), n = { ...s };
509
- n.onAddToCart || (n.onAddToCart = (c) => {
517
+ n.onAddToCart || (n.onAddToCart = (u) => {
510
518
  o.sendToNative("addToCart", {
511
- sku: c.sku,
512
- quantity: c.quantity,
513
- cartCode: c.cartCode
519
+ sku: u.sku,
520
+ quantity: u.quantity,
521
+ cartCode: u.cartCode
514
522
  });
515
- }), n.onProductNavigate || (n.onProductNavigate = (c, v, y) => {
523
+ }), n.onProductNavigate || (n.onProductNavigate = (u, v, y) => {
516
524
  o.sendToNative("productNavigate", {
517
- url: c,
525
+ url: u,
518
526
  sku: v,
519
527
  sessionId: y
520
528
  });
@@ -522,24 +530,24 @@ async function ke(e) {
522
530
  const d = n.qna?.enabled === !0 || n.qna?.mountTarget !== void 0;
523
531
  if (n.qna?.enabled !== !1)
524
532
  if (d) {
525
- const c = A(window, n.qna?.mountTarget ?? U, "gengage-qna");
533
+ const u = E(window, n.qna?.mountTarget ?? x, "gengage-qna");
526
534
  n.qna = {
527
535
  ...n.qna,
528
536
  enabled: !0,
529
- mountTarget: c
537
+ mountTarget: u
530
538
  };
531
- } else S(window, U) || (n.qna = { enabled: !1 });
532
- const u = n.simrel?.enabled === !0 || n.simrel?.mountTarget !== void 0;
539
+ } else S(window, x) || (n.qna = { enabled: !1 });
540
+ const c = n.simrel?.enabled === !0 || n.simrel?.mountTarget !== void 0;
533
541
  if (n.simrel?.enabled !== !1)
534
- if (u) {
535
- const c = A(window, n.simrel?.mountTarget ?? E, "gengage-simrel");
542
+ if (c) {
543
+ const u = E(window, n.simrel?.mountTarget ?? U, "gengage-simrel");
536
544
  n.simrel = {
537
545
  ...n.simrel,
538
546
  enabled: !0,
539
- mountTarget: c
547
+ mountTarget: u
540
548
  };
541
- } else S(window, E) || (n.simrel = { enabled: !1 });
542
- const a = await ce(n);
549
+ } else S(window, U) || (n.simrel = { enabled: !1 });
550
+ const a = await ue(n);
543
551
  return o.setController(a), i && o.sendToNative("ready", {
544
552
  sessionId: a.session.sessionId,
545
553
  widgets: {
@@ -556,19 +564,19 @@ async function ke(e) {
556
564
  };
557
565
  }
558
566
  export {
559
- ke as a,
560
- ue as c,
567
+ Me as a,
568
+ ce as c,
561
569
  X as d,
562
570
  te as f,
563
571
  qe as h,
564
572
  me as i,
565
- ce as l,
573
+ ue as l,
566
574
  ne as m,
567
575
  ve as n,
568
- Me as o,
576
+ ke as o,
569
577
  Se as p,
570
578
  ye as r,
571
579
  Ne as s,
572
580
  ge as t,
573
- B as u
581
+ L as u
574
582
  };