@gengage/assistant-fe 0.1.9 → 0.2.1

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 (71) hide show
  1. package/dist/assistant-fe.css +1 -1
  2. package/dist/chat/components/CategoriesContainer.d.ts.map +1 -1
  3. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  4. package/dist/chat/components/renderUISpec.d.ts.map +1 -1
  5. package/dist/chat/index.d.ts.map +1 -1
  6. package/dist/chat/panel-manager.d.ts +16 -0
  7. package/dist/chat/panel-manager.d.ts.map +1 -1
  8. package/dist/chat.cjs +1 -1
  9. package/dist/chat.iife.js +28 -28
  10. package/dist/chat.iife.js.map +1 -1
  11. package/dist/chat.js +2 -2
  12. package/dist/common/action-router.d.ts.map +1 -1
  13. package/dist/common/debug.d.ts.map +1 -1
  14. package/dist/common/events.d.ts.map +1 -1
  15. package/dist/common/native-webview.d.ts.map +1 -1
  16. package/dist/common/product-utils.d.ts +10 -0
  17. package/dist/common/product-utils.d.ts.map +1 -1
  18. package/dist/common/protocol-adapter.d.ts.map +1 -1
  19. package/dist/common.cjs +1 -1
  20. package/dist/common.js +5 -5
  21. package/dist/index-BUtw0Jlm.cjs +2 -0
  22. package/dist/index-BUtw0Jlm.cjs.map +1 -0
  23. package/dist/index-D-tVifN8.cjs +13 -0
  24. package/dist/index-D-tVifN8.cjs.map +1 -0
  25. package/dist/{index-DR2uepzb.js → index-DjPldwe7.js} +181 -187
  26. package/dist/index-DjPldwe7.js.map +1 -0
  27. package/dist/{index-CEt87kCd.js → index-TY0qKDI-.js} +1291 -1292
  28. package/dist/index-TY0qKDI-.js.map +1 -0
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +3 -3
  31. package/dist/native.cjs +1 -1
  32. package/dist/native.iife.js +30 -30
  33. package/dist/native.iife.js.map +1 -1
  34. package/dist/native.js +1 -1
  35. package/dist/qna.cjs +1 -1
  36. package/dist/qna.iife.js +2 -2
  37. package/dist/qna.iife.js.map +1 -1
  38. package/dist/qna.js +1 -1
  39. package/dist/quantity-stepper-BKtPQUR1.js +78 -0
  40. package/dist/quantity-stepper-BKtPQUR1.js.map +1 -0
  41. package/dist/quantity-stepper-DU6va4sS.cjs +2 -0
  42. package/dist/quantity-stepper-DU6va4sS.cjs.map +1 -0
  43. package/dist/{schemas-DIhL3DkL.js → schemas-BAEbjFPE.js} +17 -12
  44. package/dist/schemas-BAEbjFPE.js.map +1 -0
  45. package/dist/{schemas-Dsr0bbO_.cjs → schemas-DIyHm5pa.cjs} +4 -4
  46. package/dist/{schemas-DIhL3DkL.js.map → schemas-DIyHm5pa.cjs.map} +1 -1
  47. package/dist/simrel/api.d.ts.map +1 -1
  48. package/dist/simrel/components/ProductCard.d.ts.map +1 -1
  49. package/dist/simrel/locales/en.d.ts.map +1 -1
  50. package/dist/simrel/locales/tr.d.ts.map +1 -1
  51. package/dist/simrel/types.d.ts +1 -0
  52. package/dist/simrel/types.d.ts.map +1 -1
  53. package/dist/simrel.cjs +1 -1
  54. package/dist/simrel.cjs.map +1 -1
  55. package/dist/simrel.css +1 -1
  56. package/dist/simrel.iife.js +6 -6
  57. package/dist/simrel.iife.js.map +1 -1
  58. package/dist/simrel.js +236 -234
  59. package/dist/simrel.js.map +1 -1
  60. package/package.json +1 -1
  61. package/dist/index-BWPx4pM7.cjs +0 -13
  62. package/dist/index-BWPx4pM7.cjs.map +0 -1
  63. package/dist/index-CEt87kCd.js.map +0 -1
  64. package/dist/index-DL4CAkyL.cjs +0 -2
  65. package/dist/index-DL4CAkyL.cjs.map +0 -1
  66. package/dist/index-DR2uepzb.js.map +0 -1
  67. package/dist/quantity-stepper-C-nV4lwi.js +0 -77
  68. package/dist/quantity-stepper-C-nV4lwi.js.map +0 -1
  69. package/dist/quantity-stepper-CURMkwRF.cjs +0 -2
  70. package/dist/quantity-stepper-CURMkwRF.cjs.map +0 -1
  71. package/dist/schemas-Dsr0bbO_.cjs.map +0 -1
@@ -1,46 +1,46 @@
1
- import { G as H } from "./index-CEt87kCd.js";
2
- import { GengageQNA as j } from "./qna.js";
3
- import { GengageSimRel as K } from "./simrel.js";
4
- import { o as p, s as h, Y as V, _ as x, D as q, d as y, y as M, Z as $, $ as G, E as Y } from "./schemas-DIhL3DkL.js";
5
- const T = p({
1
+ import { G as F } from "./index-TY0qKDI-.js";
2
+ import { GengageQNA as Q } from "./qna.js";
3
+ import { GengageSimRel as H } from "./simrel.js";
4
+ import { o as p, s as h, Y as j, _ as U, D as M, d as y, y as S, Z as K, $ as V, E as $ } from "./schemas-BAEbjFPE.js";
5
+ const C = p({
6
6
  enabled: y().default(!0)
7
- }), J = p({
7
+ }), G = p({
8
8
  chat: h().optional(),
9
9
  qna: h().optional(),
10
10
  simrel: h().optional()
11
- }), X = p({}), Z = x(["none", "x-api-key-header", "bearer-header", "body-api-key"]), z = p({
12
- mode: Z.default("none"),
11
+ }), Y = p({}), J = U(["none", "x-api-key-header", "bearer-header", "body-api-key"]), X = p({
12
+ mode: J.default("none"),
13
13
  key: h().optional(),
14
14
  headerName: h().optional(),
15
15
  bodyField: h().default("api_key")
16
- }), ee = p({
16
+ }), Z = p({
17
17
  enabled: y().default(!0),
18
18
  endpoint: h().default("/analytics"),
19
- auth: z.default({ mode: "none", bodyField: "api_key" }),
19
+ auth: X.default({ mode: "none", bodyField: "api_key" }),
20
20
  fireAndForget: y().default(!0),
21
21
  useBeacon: y().default(!0),
22
22
  keepaliveFetch: y().default(!0),
23
- timeoutMs: M().int().positive().default(4e3),
24
- maxRetries: M().int().min(0).max(5).default(1)
25
- }), U = "__gengageWidgetsInit", te = p({
26
- idempotencyKey: h().default(U),
23
+ timeoutMs: S().int().positive().default(4e3),
24
+ maxRetries: S().int().min(0).max(5).default(1)
25
+ }), R = "__gengageWidgetsInit", z = p({
26
+ idempotencyKey: h().default(R),
27
27
  requireDomReady: y().default(!0)
28
- }), ne = x(["log-and-ignore", "throw", "delegate"]), ie = p({
29
- unknownActionPolicy: ne.default("log-and-ignore"),
28
+ }), ee = U(["log-and-ignore", "throw", "delegate"]), te = p({
29
+ unknownActionPolicy: ee.default("log-and-ignore"),
30
30
  allowScriptCall: y().default(!1)
31
- }), R = p({
32
- version: V("1", { error: 'version must be "1"' }),
31
+ }), P = p({
32
+ version: j("1", { error: 'version must be "1"' }),
33
33
  accountId: h({ error: "accountId must be a non-empty string" }).min(1, { error: "accountId must be a non-empty string" }),
34
34
  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")' }),
35
35
  locale: h().optional(),
36
36
  widgets: p({
37
- chat: T.default({ enabled: !0 }),
38
- qna: T.default({ enabled: !0 }),
39
- simrel: T.default({ enabled: !0 })
37
+ chat: C.default({ enabled: !0 }),
38
+ qna: C.default({ enabled: !0 }),
39
+ simrel: C.default({ enabled: !0 })
40
40
  }),
41
- mounts: J.default({}),
42
- transport: X.default({}),
43
- analytics: ee.default({
41
+ mounts: G.default({}),
42
+ transport: Y.default({}),
43
+ analytics: Z.default({
44
44
  enabled: !0,
45
45
  endpoint: "/analytics",
46
46
  auth: { mode: "none", bodyField: "api_key" },
@@ -50,29 +50,29 @@ const T = p({
50
50
  timeoutMs: 4e3,
51
51
  maxRetries: 1
52
52
  }),
53
- gtm: te.default({
53
+ gtm: z.default({
54
54
  idempotencyKey: "__gengageWidgetsInit",
55
55
  requireDomReady: !0
56
56
  }),
57
- actionHandling: ie.default({
57
+ actionHandling: te.default({
58
58
  unknownActionPolicy: "log-and-ignore",
59
59
  allowScriptCall: !1
60
60
  })
61
61
  });
62
- function se(t) {
63
- q("config", "parsing account runtime config", t);
64
- const e = R.parse(t);
65
- return q("config", "config resolved", { accountId: e.accountId, middlewareUrl: e.middlewareUrl }), e;
62
+ function ne(n) {
63
+ M("config", "parsing account runtime config", n);
64
+ const e = P.parse(n);
65
+ return M("config", "config resolved", { accountId: e.accountId, middlewareUrl: e.middlewareUrl }), e;
66
66
  }
67
- function Ce(t) {
68
- return R.safeParse(t);
67
+ function be(n) {
68
+ return P.safeParse(n);
69
69
  }
70
- function Ie(t) {
71
- return se({
70
+ function Te(n) {
71
+ return ne({
72
72
  version: "1",
73
- accountId: t.accountId,
74
- middlewareUrl: t.middlewareUrl,
75
- locale: t.locale,
73
+ accountId: n.accountId,
74
+ middlewareUrl: n.middlewareUrl,
75
+ locale: n.locale,
76
76
  widgets: {
77
77
  chat: { enabled: !0 },
78
78
  qna: { enabled: !0 },
@@ -80,37 +80,37 @@ function Ie(t) {
80
80
  }
81
81
  });
82
82
  }
83
- const P = `${U}_overlay_`, oe = "#gengage-qna", ae = "#gengage-simrel";
84
- function C() {
85
- const t = window;
86
- return t.__gengageOverlayRegistry || (t.__gengageOverlayRegistry = {
83
+ const W = `${R}_overlay_`, ie = "#gengage-qna", se = "#gengage-simrel";
84
+ function I() {
85
+ const n = window;
86
+ return n.__gengageOverlayRegistry || (n.__gengageOverlayRegistry = {
87
87
  instances: {},
88
88
  pending: {}
89
- }), t.__gengageOverlayRegistry;
89
+ }), n.__gengageOverlayRegistry;
90
90
  }
91
- function re(t) {
91
+ function oe(n) {
92
92
  const e = {
93
- pageType: t.pageContext?.pageType ?? (t.sku !== void 0 ? "pdp" : "other")
94
- }, n = t.pageContext;
95
- return n?.sku !== void 0 && (e.sku = n.sku), n?.price !== void 0 && (e.price = n.price), n?.categoryTree !== void 0 && (e.categoryTree = n.categoryTree), n?.url !== void 0 && (e.url = n.url), n?.extra !== void 0 && (e.extra = n.extra), t.sku !== void 0 && (e.sku = t.sku), e;
93
+ pageType: n.pageContext?.pageType ?? (n.sku !== void 0 ? "pdp" : "other")
94
+ }, t = n.pageContext;
95
+ return t?.sku !== void 0 && (e.sku = t.sku), t?.price !== void 0 && (e.price = t.price), t?.categoryTree !== void 0 && (e.categoryTree = t.categoryTree), t?.url !== void 0 && (e.url = t.url), t?.extra !== void 0 && (e.extra = t.extra), n.sku !== void 0 && (e.sku = n.sku), e;
96
96
  }
97
- function de(t, e) {
98
- const n = {
99
- ...t,
97
+ function ae(n, e) {
98
+ const t = {
99
+ ...n,
100
100
  ...e,
101
- pageType: e.pageType ?? t.pageType
101
+ pageType: e.pageType ?? n.pageType
102
102
  };
103
- return e.sku === void 0 && t.sku !== void 0 && (n.sku = t.sku), n;
103
+ return e.sku === void 0 && n.sku !== void 0 && (t.sku = n.sku), t;
104
104
  }
105
- function S(t) {
106
- return t instanceof HTMLElement || document.querySelector(t) ? t : null;
105
+ function k(n) {
106
+ return n instanceof HTMLElement || document.querySelector(n) ? n : null;
107
107
  }
108
- function W(t) {
109
- return t.idempotencyKey ?? `${P}${t.accountId}`;
108
+ function L(n) {
109
+ return n.idempotencyKey ?? `${W}${n.accountId}`;
110
110
  }
111
- class ce {
112
- constructor(e, n) {
113
- this.options = e, this.onDestroy = n, this._chat = null, this._qna = null, this._simrel = null, this._analyticsClient = null, this._offQnaWire = null, this._destroyed = !1, this._queue = Promise.resolve(), this._warnedQnaMountMissing = !1, this._warnedSimRelMountMissing = !1, this.idempotencyKey = W(e), this.session = $(e.session), this._pageContext = re(e);
111
+ class re {
112
+ constructor(e, t) {
113
+ this.options = e, this.onDestroy = t, this._chat = null, this._qna = null, this._simrel = null, this._analyticsClient = null, this._offQnaWire = null, this._destroyed = !1, this._queue = Promise.resolve(), this._warnedQnaMountMissing = !1, this._warnedSimRelMountMissing = !1, this.idempotencyKey = L(e), this.session = K(e.session), this._pageContext = oe(e);
114
114
  }
115
115
  get chat() {
116
116
  return this._chat;
@@ -125,7 +125,7 @@ class ce {
125
125
  return this._analyticsClient;
126
126
  }
127
127
  async init() {
128
- window.gengage || (window.gengage = {}), window.gengage.sessionId = this.session.sessionId, window.gengage.pageContext = this._pageContext, await this._initChat(), this.options.wireQnaToChat !== !1 && (this._offQnaWire = G()), await this._syncPdpWidgets(), window.gengage.overlay = this;
128
+ window.gengage || (window.gengage = {}), window.gengage.sessionId = this.session.sessionId, window.gengage.pageContext = this._pageContext, await this._initChat(), this.options.wireQnaToChat !== !1 && (this._offQnaWire = V()), await this._syncPdpWidgets(), window.gengage.overlay = this;
129
129
  }
130
130
  openChat(e) {
131
131
  this._chat?.open(e);
@@ -135,25 +135,25 @@ class ce {
135
135
  }
136
136
  async updateContext(e) {
137
137
  this._destroyed || await this._enqueue(async () => {
138
- 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), await this._syncPdpWidgets();
138
+ this._pageContext = ae(this._pageContext, e), window.gengage || (window.gengage = {}), window.gengage.pageContext = this._pageContext, this._chat?.update(e), this._qna?.update(e), this._simrel?.update(e), await this._syncPdpWidgets();
139
139
  });
140
140
  }
141
- async updateSku(e, n = "pdp") {
142
- await this.updateContext({ sku: e, pageType: n });
141
+ async updateSku(e, t = "pdp") {
142
+ await this.updateContext({ sku: e, pageType: t });
143
143
  }
144
144
  destroy() {
145
145
  this._destroyed || (this._destroyed = !0, this._offQnaWire?.(), this._offQnaWire = null, this._chat?.destroy(), this._qna?.destroy(), this._simrel?.destroy(), this._chat = null, this._qna = null, this._simrel = null, window.gengage?.overlay === this && delete window.gengage.overlay, this.onDestroy());
146
146
  }
147
147
  async _initChat() {
148
148
  if (this.options.chat?.enabled === !1) return;
149
- const e = this.options.middlewareUrl, n = {
149
+ const e = this.options.middlewareUrl, t = {
150
150
  accountId: this.options.accountId,
151
151
  middlewareUrl: e,
152
152
  session: this.session,
153
153
  pageContext: this._pageContext,
154
154
  variant: this.options.chat?.variant ?? "floating"
155
155
  };
156
- this.options.theme !== void 0 && (n.theme = this.options.theme), this.options.locale !== void 0 && (n.locale = this.options.locale), this.options.pricing !== void 0 && (n.pricing = this.options.pricing), this.options.chat?.mountTarget !== void 0 && (n.mountTarget = this.options.chat.mountTarget), this.options.chat?.launcherSvg !== void 0 && (n.launcherSvg = this.options.chat.launcherSvg), this.options.chat?.headerTitle !== void 0 && (n.headerTitle = this.options.chat.headerTitle), this.options.chat?.headerAvatarUrl !== void 0 && (n.headerAvatarUrl = this.options.chat.headerAvatarUrl), this.options.chat?.headerBadge !== void 0 && (n.headerBadge = this.options.chat.headerBadge), this.options.chat?.headerCartUrl !== void 0 && (n.headerCartUrl = this.options.chat.headerCartUrl), this.options.chat?.headerFavoritesToggle !== void 0 && (n.headerFavoritesToggle = this.options.chat.headerFavoritesToggle), this.options.chat?.hideMobileLauncher !== void 0 && (n.hideMobileLauncher = this.options.chat.hideMobileLauncher), this.options.chat?.mobileBreakpoint !== void 0 && (n.mobileBreakpoint = this.options.chat.mobileBreakpoint), this.options.chat?.mobileInitialState !== void 0 && (n.mobileInitialState = this.options.chat.mobileInitialState), this.options.chat?.i18n !== void 0 && (n.i18n = this.options.chat.i18n), this.options.chat?.actionHandling !== void 0 && (n.actionHandling = this.options.chat.actionHandling), this.options.onScriptCall !== void 0 && (n.onScriptCall = this.options.onScriptCall), this._chat = new H(), await this._chat.init(n);
156
+ this.options.theme !== void 0 && (t.theme = this.options.theme), this.options.locale !== void 0 && (t.locale = this.options.locale), this.options.pricing !== void 0 && (t.pricing = this.options.pricing), this.options.chat?.mountTarget !== void 0 && (t.mountTarget = this.options.chat.mountTarget), this.options.chat?.launcherSvg !== void 0 && (t.launcherSvg = this.options.chat.launcherSvg), this.options.chat?.headerTitle !== void 0 && (t.headerTitle = this.options.chat.headerTitle), this.options.chat?.headerAvatarUrl !== void 0 && (t.headerAvatarUrl = this.options.chat.headerAvatarUrl), this.options.chat?.headerBadge !== void 0 && (t.headerBadge = this.options.chat.headerBadge), this.options.chat?.headerCartUrl !== void 0 && (t.headerCartUrl = this.options.chat.headerCartUrl), this.options.chat?.headerFavoritesToggle !== void 0 && (t.headerFavoritesToggle = this.options.chat.headerFavoritesToggle), this.options.chat?.hideMobileLauncher !== void 0 && (t.hideMobileLauncher = this.options.chat.hideMobileLauncher), this.options.chat?.mobileBreakpoint !== void 0 && (t.mobileBreakpoint = this.options.chat.mobileBreakpoint), this.options.chat?.mobileInitialState !== void 0 && (t.mobileInitialState = this.options.chat.mobileInitialState), this.options.chat?.i18n !== void 0 && (t.i18n = this.options.chat.i18n), this.options.chat?.actionHandling !== void 0 && (t.actionHandling = this.options.chat.actionHandling), this.options.onScriptCall !== void 0 && (t.onScriptCall = this.options.onScriptCall), this._chat = new F(), await this._chat.init(t);
157
157
  }
158
158
  async _syncPdpWidgets() {
159
159
  if (this._destroyed) return;
@@ -164,12 +164,12 @@ class ce {
164
164
  }
165
165
  const a = this.options.middlewareUrl;
166
166
  if (this.options.qna?.enabled !== !1) {
167
- const s = this.options.qna?.mountTarget ?? oe, i = S(s);
167
+ const s = this.options.qna?.mountTarget ?? ie, i = k(s);
168
168
  if (i)
169
169
  if (this._warnedQnaMountMissing = !1, this._qna)
170
170
  this._qna.show(), this._qna.update({ pageType: "pdp", sku: e });
171
171
  else {
172
- const u = new j(), o = {
172
+ const u = new Q(), o = {
173
173
  accountId: this.options.accountId,
174
174
  middlewareUrl: a,
175
175
  session: this.session,
@@ -186,12 +186,12 @@ class ce {
186
186
  } else
187
187
  this._qna?.destroy(), this._qna = null;
188
188
  if (this.options.simrel?.enabled !== !1) {
189
- const s = this.options.simrel?.mountTarget ?? ae, i = S(s);
189
+ const s = this.options.simrel?.mountTarget ?? se, i = k(s);
190
190
  if (i)
191
191
  if (this._warnedSimRelMountMissing = !1, this._simrel)
192
192
  this._simrel.show(), this._simrel.update({ pageType: "pdp", sku: e });
193
193
  else {
194
- const u = new K(), o = {
194
+ const u = new H(), o = {
195
195
  accountId: this.options.accountId,
196
196
  middlewareUrl: a,
197
197
  session: this.session,
@@ -199,7 +199,7 @@ class ce {
199
199
  mountTarget: i
200
200
  };
201
201
  this.options.theme !== void 0 && (o.theme = this.options.theme), this.options.pricing !== void 0 && (o.pricing = this.options.pricing), this.options.simrel?.discountType !== void 0 && (o.discountType = this.options.simrel.discountType), this.options.onAddToCart !== void 0 && (o.onAddToCart = this.options.onAddToCart), this.options.onProductNavigate !== void 0 ? o.onProductNavigate = this.options.onProductNavigate : o.onProductNavigate = (r, c, m) => {
202
- Y(r) && (this._chat?.saveSession(m ?? this.session.sessionId, c), window.location.href = r);
202
+ $(r) && (this._chat?.saveSession(m ?? this.session.sessionId, c), window.location.href = r);
203
203
  }, await u.init(o), this._simrel = u;
204
204
  }
205
205
  else
@@ -211,34 +211,34 @@ class ce {
211
211
  this._qna?.destroy(), this._simrel?.destroy(), this._qna = null, this._simrel = null;
212
212
  }
213
213
  _enqueue(e) {
214
- const n = this._queue.then(e);
215
- return this._queue = n.catch((a) => {
216
- }), n;
214
+ const t = this._queue.then(e);
215
+ return this._queue = t.catch((a) => {
216
+ }), t;
217
217
  }
218
218
  }
219
- async function le(t) {
220
- const e = W(t), n = C(), a = n.instances[e];
219
+ async function de(n) {
220
+ const e = L(n), t = I(), a = t.instances[e];
221
221
  if (a) return a;
222
- const s = n.pending[e];
222
+ const s = t.pending[e];
223
223
  if (s) return s;
224
- const i = new ce(t, () => {
225
- const o = C();
224
+ const i = new re(n, () => {
225
+ const o = I();
226
226
  delete o.instances[e], delete o.pending[e];
227
- }), u = i.init().then(() => (n.instances[e] = i, delete n.pending[e], i)).catch((o) => {
228
- throw delete n.pending[e], o;
227
+ }), u = i.init().then(() => (t.instances[e] = i, delete t.pending[e], i)).catch((o) => {
228
+ throw delete t.pending[e], o;
229
229
  });
230
- return n.pending[e] = u, u;
230
+ return t.pending[e] = u, u;
231
231
  }
232
- function ge(t) {
233
- return C().instances[t] ?? null;
232
+ function ce(n) {
233
+ return I().instances[n] ?? null;
234
234
  }
235
- function Ne(t) {
236
- ge(t)?.destroy();
235
+ function Ce(n) {
236
+ ce(n)?.destroy();
237
237
  }
238
- function qe(t) {
239
- return `${P}${t}`;
238
+ function Ie(n) {
239
+ return `${W}${n}`;
240
240
  }
241
- const ue = [
241
+ const le = [
242
242
  "gengage:chat:open",
243
243
  "gengage:chat:close",
244
244
  "gengage:chat:ready",
@@ -249,11 +249,11 @@ const ue = [
249
249
  "gengage:similar:add-to-cart",
250
250
  "gengage:global:error",
251
251
  "gengage:context:update"
252
- ], he = 32, k = "#gengage-qna", A = "#gengage-simrel";
253
- function fe(t) {
254
- let e = t;
255
- if (typeof t == "string") {
256
- const i = t.trim();
252
+ ], ge = 32, A = "#gengage-qna", E = "#gengage-simrel";
253
+ function ue(n) {
254
+ let e = n;
255
+ if (typeof n == "string") {
256
+ const i = n.trim();
257
257
  if (i.length === 0) return null;
258
258
  if (!i.startsWith("{") && !i.startsWith("["))
259
259
  return { type: i };
@@ -264,98 +264,92 @@ function fe(t) {
264
264
  }
265
265
  }
266
266
  if (!e || typeof e != "object") return null;
267
- const n = e, a = [n.type, n.command, n.action, n.event].find(
267
+ const t = e, a = [t.type, t.command, t.action, t.event].find(
268
268
  (i) => typeof i == "string" && i.length > 0
269
269
  );
270
270
  if (!a) return null;
271
- let s = n.payload;
272
- if (s === void 0 && "data" in n && (s = n.data), a === "setSession" && s === void 0) {
271
+ let s = t.payload;
272
+ if (s === void 0 && "data" in t && (s = t.data), a === "setSession" && s === void 0) {
273
273
  const i = {};
274
- typeof n.sessionId == "string" && (i.sessionId = n.sessionId), typeof n.userId == "string" && (i.userId = n.userId), (i.sessionId !== void 0 || i.userId !== void 0) && (s = i);
274
+ typeof t.sessionId == "string" && (i.sessionId = t.sessionId), typeof t.userId == "string" && (i.userId = t.userId), (i.sessionId !== void 0 || i.userId !== void 0) && (s = i);
275
275
  }
276
276
  return s === void 0 ? { type: a } : { type: a, payload: s };
277
277
  }
278
- function pe(t) {
279
- if (typeof t == "string" && t.length > 0)
280
- return { sku: t };
281
- if (t && typeof t == "object" && "sku" in t) {
282
- const e = t.sku;
278
+ function he(n) {
279
+ if (typeof n == "string" && n.length > 0)
280
+ return { sku: n };
281
+ if (n && typeof n == "object" && "sku" in n) {
282
+ const e = n.sku;
283
283
  if (typeof e == "string" && e.length > 0) {
284
- const n = t.pageType;
285
- return n !== void 0 ? { sku: e, pageType: n } : { sku: e };
284
+ const t = n.pageType;
285
+ return t !== void 0 ? { sku: e, pageType: t } : { sku: e };
286
286
  }
287
287
  }
288
288
  return null;
289
289
  }
290
- function I(t, e) {
291
- return e instanceof HTMLElement ? !0 : typeof e != "string" ? !1 : t.document.querySelector(e) !== null;
290
+ function N(n, e) {
291
+ return e instanceof HTMLElement ? !0 : typeof e != "string" ? !1 : n.document.querySelector(e) !== null;
292
292
  }
293
- function E(t, e, n) {
294
- if (e instanceof HTMLElement || I(t, e) || typeof e != "string") return e;
293
+ function x(n, e, t) {
294
+ if (e instanceof HTMLElement || N(n, e) || typeof e != "string") return e;
295
295
  if (e.startsWith("#")) {
296
296
  const i = e.slice(1);
297
297
  if (i.length > 0) {
298
- const u = t.document.getElementById(i);
298
+ const u = n.document.getElementById(i);
299
299
  if (u) return u;
300
- const o = t.document.createElement("div");
301
- return o.id = i, t.document.body.appendChild(o), o;
300
+ const o = n.document.createElement("div");
301
+ return o.id = i, n.document.body.appendChild(o), o;
302
302
  }
303
303
  }
304
- const a = t.document.getElementById(n);
304
+ const a = n.document.getElementById(t);
305
305
  if (a) return a;
306
- const s = t.document.createElement("div");
307
- return s.id = n, t.document.body.appendChild(s), s;
306
+ const s = n.document.createElement("div");
307
+ return s.id = t, n.document.body.appendChild(s), s;
308
308
  }
309
- function L(t, e) {
310
- const n = t.webkit?.messageHandlers?.[e];
311
- return n && typeof n.postMessage == "function" ? n.postMessage.bind(n) : null;
309
+ function O(n, e) {
310
+ const t = n.webkit?.messageHandlers?.[e];
311
+ return t && typeof t.postMessage == "function" ? t.postMessage.bind(t) : null;
312
312
  }
313
- function O(t, e) {
314
- const n = t[e];
315
- return n && typeof n == "object" && typeof n.postMessage == "function" ? n : null;
313
+ function w(n, e) {
314
+ const t = n[e];
315
+ return t && typeof t == "object" && typeof t.postMessage == "function" ? t : null;
316
316
  }
317
- function B(t, e) {
318
- return O(t, e);
317
+ function fe(n = {}) {
318
+ const e = n.win ?? window, t = n.iosHandlerName ?? "gengage", a = n.androidInterfaceName ?? "GengageNative", s = n.reactNativeInterfaceName ?? "ReactNativeWebView";
319
+ return O(e, t) ? "ios" : w(e, a) ? "android" : w(e, s) ? "react-native" : "browser";
319
320
  }
320
- function D(t, e) {
321
- return O(t, e);
322
- }
323
- function me(t = {}) {
324
- const e = t.win ?? window, n = t.iosHandlerName ?? "gengage", a = t.androidInterfaceName ?? "GengageNative", s = t.reactNativeInterfaceName ?? "ReactNativeWebView";
325
- return L(e, n) ? "ios" : B(e, a) ? "android" : D(e, s) ? "react-native" : "browser";
326
- }
327
- function ye(t, e = {}) {
328
- const n = e.win ?? window;
329
- if (t.sessionId !== void 0) {
330
- n.__gengageSessionId = t.sessionId, n.gengage || (n.gengage = {}), n.gengage.sessionId = t.sessionId;
321
+ function pe(n, e = {}) {
322
+ const t = e.win ?? window;
323
+ if (n.sessionId !== void 0) {
324
+ t.__gengageSessionId = n.sessionId, t.gengage || (t.gengage = {}), t.gengage.sessionId = n.sessionId;
331
325
  try {
332
- n.sessionStorage.setItem("gengage_session_id", t.sessionId);
326
+ t.sessionStorage.setItem("gengage_session_id", n.sessionId);
333
327
  } catch {
334
328
  }
335
329
  }
336
- if (t.userId !== void 0) {
337
- n.gengage || (n.gengage = {});
338
- const a = n.gengage, s = a.session ?? {};
339
- s.userId = t.userId, a.session = s;
330
+ if (n.userId !== void 0) {
331
+ t.gengage || (t.gengage = {});
332
+ const a = t.gengage, s = a.session ?? {};
333
+ s.userId = n.userId, a.session = s;
340
334
  }
341
335
  }
342
- function ve(t = {}) {
343
- const e = t.win ?? window, n = e;
344
- if (n.gengageNative) return n.gengageNative;
345
- const a = t.iosHandlerName ?? "gengage", s = t.androidInterfaceName ?? "GengageNative", i = t.reactNativeInterfaceName ?? "ReactNativeWebView", u = t.trackedEvents ?? [...ue], o = me({ win: e, iosHandlerName: a, androidInterfaceName: s, reactNativeInterfaceName: i });
336
+ function me(n = {}) {
337
+ const e = n.win ?? window, t = e;
338
+ if (t.gengageNative) return t.gengageNative;
339
+ const a = n.iosHandlerName ?? "gengage", s = n.androidInterfaceName ?? "GengageNative", i = n.reactNativeInterfaceName ?? "ReactNativeWebView", u = n.trackedEvents ?? [...le], o = fe({ win: e, iosHandlerName: a, androidInterfaceName: s, reactNativeInterfaceName: i });
346
340
  let r = e.gengage?.overlay ?? null;
347
341
  const c = [], m = (l, d) => {
348
342
  const f = d === void 0 ? { type: l } : { type: l, payload: d };
349
343
  if (o === "ios") {
350
- L(e, a)?.(f);
344
+ O(e, a)?.(f);
351
345
  return;
352
346
  }
353
347
  if (o === "android") {
354
- B(e, s)?.postMessage(JSON.stringify(f));
348
+ w(e, s)?.postMessage(JSON.stringify(f));
355
349
  return;
356
350
  }
357
351
  if (o === "react-native") {
358
- D(e, i)?.postMessage(JSON.stringify(f));
352
+ w(e, i)?.postMessage(JSON.stringify(f));
359
353
  return;
360
354
  }
361
355
  }, v = (l) => {
@@ -367,7 +361,7 @@ function ve(t = {}) {
367
361
  });
368
362
  };
369
363
  e.addEventListener("gengage:bridge:message", v);
370
- const F = u.map((l) => {
364
+ const B = u.map((l) => {
371
365
  const d = (f) => {
372
366
  const g = f.detail;
373
367
  m("widget_event", {
@@ -377,14 +371,14 @@ function ve(t = {}) {
377
371
  };
378
372
  return e.addEventListener(l, d), { event: l, handler: d };
379
373
  }), _ = (l) => {
380
- c.length >= he && c.shift(), c.push(l);
381
- }, Q = () => {
374
+ c.length >= ge && c.shift(), c.push(l);
375
+ }, D = () => {
382
376
  if (!r || c.length === 0) return;
383
377
  const l = c.splice(0, c.length);
384
378
  for (const d of l)
385
- N(d);
386
- }, N = (l) => {
387
- const d = fe(l);
379
+ q(d);
380
+ }, q = (l) => {
381
+ const d = ue(l);
388
382
  if (!d || typeof d.type != "string") {
389
383
  console.warn("[gengage:native-bridge] Invalid message:", l);
390
384
  return;
@@ -406,16 +400,16 @@ function ve(t = {}) {
406
400
  return;
407
401
  }
408
402
  case "updateSku": {
409
- const b = pe(g);
410
- if (r && b) {
411
- r.updateSku(b.sku, b.pageType);
403
+ const T = he(g);
404
+ if (r && T) {
405
+ r.updateSku(T.sku, T.pageType);
412
406
  return;
413
407
  }
414
408
  r ? console.warn("[gengage:native-bridge] updateSku: missing sku") : _(d);
415
409
  return;
416
410
  }
417
411
  case "setSession": {
418
- g && typeof g == "object" && ye(g, { win: e });
412
+ g && typeof g == "object" && pe(g, { win: e });
419
413
  return;
420
414
  }
421
415
  case "destroy": {
@@ -423,26 +417,26 @@ function ve(t = {}) {
423
417
  return;
424
418
  }
425
419
  default:
426
- e.postMessage({ gengage: "native", type: f, payload: g }, e.location.origin), t.logUnhandled && console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:", f);
420
+ e.postMessage({ gengage: "native", type: f, payload: g }, e.location.origin), n.logUnhandled && console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:", f);
427
421
  }
428
- }, w = {
422
+ }, b = {
429
423
  env: o,
430
424
  sendToNative: m,
431
- receive: N,
425
+ receive: q,
432
426
  setController(l) {
433
- r = l, Q();
427
+ r = l, D();
434
428
  },
435
429
  destroy() {
436
430
  e.removeEventListener("gengage:bridge:message", v);
437
- for (const l of F)
431
+ for (const l of B)
438
432
  e.removeEventListener(l.event, l.handler);
439
- c.splice(0, c.length), e.gengageNative === w && delete e.gengageNative;
433
+ c.splice(0, c.length), e.gengageNative === b && delete e.gengageNative;
440
434
  }
441
435
  };
442
- return n.gengageNative = w, w;
436
+ return t.gengageNative = b, b;
443
437
  }
444
- async function Me(t) {
445
- const { nativeBridge: e, emitReadyEvent: n = !0, ...a } = t, s = ve(e), i = { ...a };
438
+ async function Ne(n) {
439
+ const { nativeBridge: e, emitReadyEvent: t = !0, ...a } = n, s = me(e), i = { ...a };
446
440
  i.onAddToCart || (i.onAddToCart = (c) => {
447
441
  s.sendToNative("addToCart", {
448
442
  sku: c.sku,
@@ -459,25 +453,25 @@ async function Me(t) {
459
453
  const u = i.qna?.enabled === !0 || i.qna?.mountTarget !== void 0;
460
454
  if (i.qna?.enabled !== !1)
461
455
  if (u) {
462
- const c = E(
456
+ const c = x(
463
457
  window,
464
- i.qna?.mountTarget ?? k,
458
+ i.qna?.mountTarget ?? A,
465
459
  "gengage-qna"
466
460
  );
467
461
  i.qna = { ...i.qna, enabled: !0, mountTarget: c };
468
- } else I(window, k) || (i.qna = { enabled: !1 });
462
+ } else N(window, A) || (i.qna = { enabled: !1 });
469
463
  const o = i.simrel?.enabled === !0 || i.simrel?.mountTarget !== void 0;
470
464
  if (i.simrel?.enabled !== !1)
471
465
  if (o) {
472
- const c = E(
466
+ const c = x(
473
467
  window,
474
- i.simrel?.mountTarget ?? A,
468
+ i.simrel?.mountTarget ?? E,
475
469
  "gengage-simrel"
476
470
  );
477
471
  i.simrel = { ...i.simrel, enabled: !0, mountTarget: c };
478
- } else I(window, A) || (i.simrel = { enabled: !1 });
479
- const r = await le(i);
480
- return s.setController(r), n && s.sendToNative("ready", {
472
+ } else N(window, E) || (i.simrel = { enabled: !1 });
473
+ const r = await de(i);
474
+ return s.setController(r), t && s.sendToNative("ready", {
481
475
  sessionId: r.session.sessionId,
482
476
  widgets: {
483
477
  chat: r.chat !== null,
@@ -493,20 +487,20 @@ async function Me(t) {
493
487
  };
494
488
  }
495
489
  export {
496
- R as A,
497
- ue as D,
498
- ne as U,
499
- Z as a,
500
- ye as b,
501
- qe as c,
502
- Ie as d,
503
- ve as e,
504
- Ne as f,
505
- me as g,
506
- ge as h,
507
- le as i,
508
- Me as j,
509
- se as p,
510
- Ce as s
490
+ P as A,
491
+ le as D,
492
+ ee as U,
493
+ J as a,
494
+ pe as b,
495
+ Ie as c,
496
+ Te as d,
497
+ me as e,
498
+ Ce as f,
499
+ fe as g,
500
+ ce as h,
501
+ de as i,
502
+ Ne as j,
503
+ ne as p,
504
+ be as s
511
505
  };
512
- //# sourceMappingURL=index-DR2uepzb.js.map
506
+ //# sourceMappingURL=index-DjPldwe7.js.map