@gengage/assistant-fe 0.1.6 → 0.1.7

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 (75) hide show
  1. package/README.md +100 -0
  2. package/dist/assistant-fe.css +1 -1
  3. package/dist/chat/components/ChatDrawer.d.ts +8 -4
  4. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  5. package/dist/chat/index.d.ts +5 -0
  6. package/dist/chat/index.d.ts.map +1 -1
  7. package/dist/chat/types.d.ts +1 -1
  8. package/dist/chat.cjs +1 -1
  9. package/dist/chat.iife.js +16 -16
  10. package/dist/chat.iife.js.map +1 -1
  11. package/dist/chat.js +2 -2
  12. package/dist/common/events.d.ts.map +1 -1
  13. package/dist/common/index.d.ts +2 -0
  14. package/dist/common/index.d.ts.map +1 -1
  15. package/dist/common/native-webview.d.ts +61 -0
  16. package/dist/common/native-webview.d.ts.map +1 -0
  17. package/dist/common/overlay.d.ts +5 -0
  18. package/dist/common/overlay.d.ts.map +1 -1
  19. package/dist/common.cjs +1 -1
  20. package/dist/common.cjs.map +1 -1
  21. package/dist/common.js +197 -426
  22. package/dist/common.js.map +1 -1
  23. package/dist/index-1yPxOqAw.cjs +13 -0
  24. package/dist/index-1yPxOqAw.cjs.map +1 -0
  25. package/dist/index-BH-V2lWn.js +510 -0
  26. package/dist/index-BH-V2lWn.js.map +1 -0
  27. package/dist/index-BelS6Vnv.cjs +2 -0
  28. package/dist/index-BelS6Vnv.cjs.map +1 -0
  29. package/dist/index-CERWfDdF.js +4571 -0
  30. package/dist/index-CERWfDdF.js.map +1 -0
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +55 -50
  35. package/dist/index.js.map +1 -1
  36. package/dist/native/index.d.ts +3 -0
  37. package/dist/native/index.d.ts.map +1 -0
  38. package/dist/native.cjs +2 -0
  39. package/dist/native.cjs.map +1 -0
  40. package/dist/native.iife.js +97 -0
  41. package/dist/native.iife.js.map +1 -0
  42. package/dist/native.js +9 -0
  43. package/dist/native.js.map +1 -0
  44. package/dist/qna/components/TextInput.d.ts.map +1 -1
  45. package/dist/qna/components/renderUISpec.d.ts.map +1 -1
  46. package/dist/qna/index.d.ts +1 -0
  47. package/dist/qna/index.d.ts.map +1 -1
  48. package/dist/qna/types.d.ts +1 -1
  49. package/dist/qna/types.d.ts.map +1 -1
  50. package/dist/qna.cjs +1 -1
  51. package/dist/qna.cjs.map +1 -1
  52. package/dist/qna.css +1 -1
  53. package/dist/qna.iife.js +14 -14
  54. package/dist/qna.iife.js.map +1 -1
  55. package/dist/qna.js +92 -80
  56. package/dist/qna.js.map +1 -1
  57. package/dist/{schemas-DhaO7I0-.cjs → schemas-DHzfUzwA.cjs} +22 -22
  58. package/dist/schemas-DHzfUzwA.cjs.map +1 -0
  59. package/dist/{schemas-BlkBmaA5.js → schemas-yF4IOEUi.js} +807 -755
  60. package/dist/schemas-yF4IOEUi.js.map +1 -0
  61. package/dist/simrel/components/ProductCard.d.ts.map +1 -1
  62. package/dist/simrel.cjs +1 -1
  63. package/dist/simrel.cjs.map +1 -1
  64. package/dist/simrel.css +1 -1
  65. package/dist/simrel.iife.js +8 -8
  66. package/dist/simrel.iife.js.map +1 -1
  67. package/dist/simrel.js +218 -214
  68. package/dist/simrel.js.map +1 -1
  69. package/package.json +9 -2
  70. package/dist/index-B8EeSm-F.cjs +0 -13
  71. package/dist/index-B8EeSm-F.cjs.map +0 -1
  72. package/dist/index-BSpLCzAK.js +0 -4523
  73. package/dist/index-BSpLCzAK.js.map +0 -1
  74. package/dist/schemas-BlkBmaA5.js.map +0 -1
  75. package/dist/schemas-DhaO7I0-.cjs.map +0 -1
package/dist/common.js CHANGED
@@ -1,245 +1,12 @@
1
- import { o as d, s as l, U as k, _ as w, d as u, v as m, V as S, W as x, A as E } from "./schemas-BlkBmaA5.js";
2
- import { B as xe, X as Ee, a as Ie, z as Ae, Y as qe, b as Pe, N as Ue, Z as Re, $ as Me, c as Le, a0 as Fe, a1 as De, j as Oe, k as Be, a2 as Ne, a3 as $e, P as We, m as He, M as ze, a4 as Ge, q as Ke, p as Qe, a5 as Ve, a6 as je, r as Ye, a7 as Xe, T as Ze, h as Je, l as et, a8 as tt, g as it, Q as nt, a9 as ot, w as st, aa as at, ab as rt, ac as lt } from "./schemas-BlkBmaA5.js";
3
- import { G as I } from "./index-BSpLCzAK.js";
4
- import { V as dt, i as ut, r as ht } from "./index-BSpLCzAK.js";
5
- import { s as ft } from "./quantity-stepper-B8kX8GbN.js";
6
- import { GengageQNA as A } from "./qna.js";
7
- import { GengageSimRel as q } from "./simrel.js";
8
- const f = d({
9
- enabled: u().default(!0)
10
- }), P = d({
11
- chat: l().optional(),
12
- qna: l().optional(),
13
- simrel: l().optional()
14
- }), U = d({}), R = w(["none", "x-api-key-header", "bearer-header", "body-api-key"]), M = d({
15
- mode: R.default("none"),
16
- key: l().optional(),
17
- headerName: l().optional(),
18
- bodyField: l().default("api_key")
19
- }), L = d({
20
- enabled: u().default(!0),
21
- endpoint: l().default("/analytics"),
22
- auth: M.default({ mode: "none", bodyField: "api_key" }),
23
- fireAndForget: u().default(!0),
24
- useBeacon: u().default(!0),
25
- keepaliveFetch: u().default(!0),
26
- timeoutMs: m().int().positive().default(4e3),
27
- maxRetries: m().int().min(0).max(5).default(1)
28
- }), v = "__gengageWidgetsInit", F = d({
29
- idempotencyKey: l().default(v),
30
- requireDomReady: u().default(!0)
31
- }), D = w(["log-and-ignore", "throw", "delegate"]), O = d({
32
- unknownActionPolicy: D.default("log-and-ignore"),
33
- allowScriptCall: u().default(!1)
34
- }), _ = d({
35
- version: k("1"),
36
- accountId: l().min(1),
37
- middlewareUrl: l().url(),
38
- locale: l().optional(),
39
- widgets: d({
40
- chat: f.default({ enabled: !0 }),
41
- qna: f.default({ enabled: !0 }),
42
- simrel: f.default({ enabled: !0 })
43
- }),
44
- mounts: P.default({}),
45
- transport: U.default({}),
46
- analytics: L.default({
47
- enabled: !0,
48
- endpoint: "/analytics",
49
- auth: { mode: "none", bodyField: "api_key" },
50
- fireAndForget: !0,
51
- useBeacon: !0,
52
- keepaliveFetch: !0,
53
- timeoutMs: 4e3,
54
- maxRetries: 1
55
- }),
56
- gtm: F.default({
57
- idempotencyKey: "__gengageWidgetsInit",
58
- requireDomReady: !0
59
- }),
60
- actionHandling: O.default({
61
- unknownActionPolicy: "log-and-ignore",
62
- allowScriptCall: !1
63
- })
64
- });
65
- function B(e) {
66
- return _.parse(e);
67
- }
68
- function N(e) {
69
- return _.safeParse(e);
70
- }
71
- function he(e) {
72
- return B({
73
- version: "1",
74
- accountId: e.accountId,
75
- middlewareUrl: e.middlewareUrl,
76
- locale: e.locale,
77
- widgets: {
78
- chat: { enabled: !0 },
79
- qna: { enabled: !0 },
80
- simrel: { enabled: !0 }
81
- }
82
- });
83
- }
84
- const T = `${v}_overlay_`, $ = "#gengage-qna", W = "#gengage-simrel";
85
- function p() {
86
- const e = window;
87
- return e.__gengageOverlayRegistry || (e.__gengageOverlayRegistry = {
88
- instances: {},
89
- pending: {}
90
- }), e.__gengageOverlayRegistry;
91
- }
92
- function H(e) {
93
- const t = {
94
- pageType: e.pageContext?.pageType ?? (e.sku !== void 0 ? "pdp" : "other")
95
- }, i = e.pageContext;
96
- 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;
97
- }
98
- function z(e, t) {
99
- const i = {
100
- ...e,
101
- ...t,
102
- pageType: t.pageType ?? e.pageType
103
- };
104
- return t.sku === void 0 && e.sku !== void 0 && (i.sku = e.sku), i;
105
- }
106
- function y(e) {
107
- return e instanceof HTMLElement || document.querySelector(e) ? e : null;
108
- }
109
- function C(e) {
110
- return e.idempotencyKey ?? `${T}${e.accountId}`;
111
- }
112
- class G {
113
- constructor(t, i) {
114
- this.options = t, this.onDestroy = i, this._chat = null, this._qna = null, this._simrel = null, this._analyticsClient = null, this._destroyed = !1, this._queue = Promise.resolve(), this._warnedQnaMountMissing = !1, this._warnedSimRelMountMissing = !1, this.idempotencyKey = C(t), this.session = S(t.session), this._pageContext = H(t);
115
- }
116
- get chat() {
117
- return this._chat;
118
- }
119
- get qna() {
120
- return this._qna;
121
- }
122
- get simrel() {
123
- return this._simrel;
124
- }
125
- get analyticsClient() {
126
- return this._analyticsClient;
127
- }
128
- async init() {
129
- window.gengage || (window.gengage = {}), window.gengage.sessionId = this.session.sessionId, window.gengage.pageContext = this._pageContext, await this._initChat(), await this._syncPdpWidgets(), this.options.wireQnaToChat !== !1 && x(), window.gengage.overlay = this;
130
- }
131
- openChat(t) {
132
- this._chat?.open(t);
133
- }
134
- closeChat() {
135
- this._chat?.close();
136
- }
137
- async updateContext(t) {
138
- this._destroyed || await this._enqueue(async () => {
139
- this._pageContext = z(this._pageContext, t), window.gengage || (window.gengage = {}), window.gengage.pageContext = this._pageContext, this._chat?.update(t), this._qna?.update(t), this._simrel?.update(t), await this._syncPdpWidgets();
140
- });
141
- }
142
- async updateSku(t, i = "pdp") {
143
- await this.updateContext({ sku: t, pageType: i });
144
- }
145
- destroy() {
146
- this._destroyed || (this._destroyed = !0, 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());
147
- }
148
- async _initChat() {
149
- if (this.options.chat?.enabled === !1) return;
150
- const t = this.options.middlewareUrl, i = {
151
- accountId: this.options.accountId,
152
- middlewareUrl: t,
153
- session: this.session,
154
- pageContext: this._pageContext,
155
- variant: this.options.chat?.variant ?? "floating"
156
- };
157
- this.options.theme !== void 0 && (i.theme = this.options.theme), this.options.locale !== void 0 && (i.locale = this.options.locale), this.options.pricing !== void 0 && (i.pricing = this.options.pricing), this.options.chat?.mountTarget !== void 0 && (i.mountTarget = this.options.chat.mountTarget), this.options.chat?.launcherSvg !== void 0 && (i.launcherSvg = this.options.chat.launcherSvg), this.options.chat?.hideMobileLauncher !== void 0 && (i.hideMobileLauncher = this.options.chat.hideMobileLauncher), this.options.chat?.mobileBreakpoint !== void 0 && (i.mobileBreakpoint = this.options.chat.mobileBreakpoint), this.options.chat?.mobileInitialState !== void 0 && (i.mobileInitialState = this.options.chat.mobileInitialState), this.options.chat?.i18n !== void 0 && (i.i18n = this.options.chat.i18n), this.options.chat?.actionHandling !== void 0 && (i.actionHandling = this.options.chat.actionHandling), this.options.onScriptCall !== void 0 && (i.onScriptCall = this.options.onScriptCall), this._chat = new I(), await this._chat.init(i);
158
- }
159
- async _syncPdpWidgets() {
160
- if (this._destroyed) return;
161
- const t = this._pageContext.sku;
162
- if (!(this._pageContext.pageType === "pdp" && t !== void 0 && t.length > 0)) {
163
- this._destroyPdpWidgets();
164
- return;
165
- }
166
- const n = this.options.middlewareUrl;
167
- if (this.options.qna?.enabled !== !1) {
168
- const s = this.options.qna?.mountTarget ?? $, a = y(s);
169
- if (a)
170
- if (this._warnedQnaMountMissing = !1, this._qna)
171
- this._qna.show(), this._qna.update({ pageType: "pdp", sku: t });
172
- else {
173
- const r = new A(), o = {
174
- accountId: this.options.accountId,
175
- middlewareUrl: n,
176
- session: this.session,
177
- pageContext: {
178
- pageType: "pdp",
179
- sku: t
180
- },
181
- mountTarget: a
182
- };
183
- this.options.theme !== void 0 && (o.theme = this.options.theme), this.options.qna?.ctaText !== void 0 && (o.ctaText = this.options.qna.ctaText), this.options.qna?.inputPlaceholder !== void 0 && (o.inputPlaceholder = this.options.qna.inputPlaceholder), await r.init(o), this._qna = r;
184
- }
185
- else
186
- this._qna?.destroy(), this._qna = null, this._warnedQnaMountMissing || (console.warn(`[gengage] QNA mount target not found: ${s}`), this._warnedQnaMountMissing = !0);
187
- } else
188
- this._qna?.destroy(), this._qna = null;
189
- if (this.options.simrel?.enabled !== !1) {
190
- const s = this.options.simrel?.mountTarget ?? W, a = y(s);
191
- if (a)
192
- if (this._warnedSimRelMountMissing = !1, this._simrel)
193
- this._simrel.show(), this._simrel.update({ pageType: "pdp", sku: t });
194
- else {
195
- const r = new q(), o = {
196
- accountId: this.options.accountId,
197
- middlewareUrl: n,
198
- session: this.session,
199
- sku: t,
200
- mountTarget: a
201
- };
202
- 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 = (c, h, g) => {
203
- this._chat?.saveSession(g ?? this.session.sessionId, h), window.location.href = c;
204
- }, await r.init(o), this._simrel = r;
205
- }
206
- else
207
- this._simrel?.destroy(), this._simrel = null, this._warnedSimRelMountMissing || (console.warn(`[gengage] SimRel mount target not found: ${s}`), this._warnedSimRelMountMissing = !0);
208
- } else
209
- this._simrel?.destroy(), this._simrel = null;
210
- }
211
- _destroyPdpWidgets() {
212
- this._qna?.destroy(), this._simrel?.destroy(), this._qna = null, this._simrel = null;
213
- }
214
- _enqueue(t) {
215
- const i = this._queue.then(t);
216
- return this._queue = i.catch((n) => {
217
- }), i;
218
- }
219
- }
220
- async function K(e) {
221
- const t = C(e), i = p(), n = i.instances[t];
222
- if (n) return n;
223
- const s = i.pending[t];
224
- if (s) return s;
225
- const a = new G(e, () => {
226
- const o = p();
227
- delete o.instances[t], delete o.pending[t];
228
- }), r = a.init().then(() => (i.instances[t] = a, delete i.pending[t], a)).catch((o) => {
229
- throw delete i.pending[t], o;
230
- });
231
- return i.pending[t] = r, r;
232
- }
233
- function Q(e) {
234
- return p().instances[e] ?? null;
235
- }
236
- function ge(e) {
237
- Q(e)?.destroy();
238
- }
239
- function fe(e) {
240
- return `${T}${e}`;
241
- }
242
- const V = {
1
+ import { A as h } from "./schemas-yF4IOEUi.js";
2
+ import { B as H, X as G, a as K, z as V, Y as j, b as Q, N as Y, Z as X, $ as Z, c as J, a0 as ee, a1 as te, j as ae, k as ne, a2 as oe, a3 as ie, P as re, m as se, M as ce, a4 as de, q as le, p as ue, a5 as he, a6 as fe, r as me, V as ge, a7 as pe, T as ye, h as ve, l as we, a8 as Te, g as Ee, Q as be, a9 as ke, w as Ce, aa as Se, W as Ae, ab as Ie, ac as Ue } from "./schemas-yF4IOEUi.js";
3
+ import { i as f, s as m } from "./index-BH-V2lWn.js";
4
+ import { A as _e, a as Pe, U as Re, b as Le, c as Be, d as qe, e as De, f as Fe, g as Ne, h as Oe, j as Me, p as $e } from "./index-BH-V2lWn.js";
5
+ import { V as ze, i as He, r as Ge } from "./index-CERWfDdF.js";
6
+ import { s as Ve } from "./quantity-stepper-B8kX8GbN.js";
7
+ import "./qna.js";
8
+ import "./simrel.js";
9
+ const g = {
243
10
  enabled: !0,
244
11
  endpoint: "/analytics",
245
12
  fireAndForget: !0,
@@ -249,19 +16,19 @@ const V = {
249
16
  maxRetries: 1,
250
17
  batchSize: 10,
251
18
  flushIntervalMs: 250
252
- }, j = {
19
+ }, p = {
253
20
  mode: "none",
254
21
  key: "",
255
22
  headerName: "X-API-Key",
256
23
  bodyField: "api_key"
257
24
  };
258
- class Y {
25
+ class y {
259
26
  constructor(t) {
260
27
  this.queue = [], this.flushTimer = null, this.config = {
261
- ...V,
28
+ ...g,
262
29
  ...t,
263
30
  auth: {
264
- ...j,
31
+ ...p,
265
32
  ...t.auth ?? {}
266
33
  }
267
34
  }, this.onPageHideBound = () => {
@@ -270,8 +37,8 @@ class Y {
270
37
  }
271
38
  track(t) {
272
39
  if (!this.config.enabled) return;
273
- const i = X(t);
274
- if (this.queue.push(i), this.queue.length >= this.config.batchSize) {
40
+ const a = v(t);
41
+ if (this.queue.push(a), this.queue.length >= this.config.batchSize) {
275
42
  this.scheduleImmediateFlush();
276
43
  return;
277
44
  }
@@ -279,8 +46,8 @@ class Y {
279
46
  }
280
47
  async flush(t = {}) {
281
48
  if (!this.config.enabled || this.queue.length === 0) return;
282
- const i = this.queue.splice(0, this.config.batchSize), n = this.buildTransportBody(i), s = Z(this.config.endpoint, this.config.middlewareUrl), a = t.preferBeacon ?? this.config.useBeacon;
283
- await this.sendWithRetry(s, n, a);
49
+ const a = this.queue.splice(0, this.config.batchSize), n = this.buildTransportBody(a), o = w(this.config.endpoint, this.config.middlewareUrl), r = t.preferBeacon ?? this.config.useBeacon;
50
+ await this.sendWithRetry(o, n, r);
284
51
  }
285
52
  /** Drain the entire queue, flushing in batch-sized chunks. */
286
53
  async flushAll(t = {}) {
@@ -299,49 +66,49 @@ class Y {
299
66
  this.flushTimer && (clearTimeout(this.flushTimer), this.flushTimer = null), this.flush();
300
67
  }
301
68
  buildTransportBody(t) {
302
- const i = { events: t };
303
- return this.config.auth.mode === "body-api-key" && this.config.auth.key && (i[this.config.auth.bodyField] = this.config.auth.key), i;
69
+ const a = { events: t };
70
+ return this.config.auth.mode === "body-api-key" && this.config.auth.key && (a[this.config.auth.bodyField] = this.config.auth.key), a;
304
71
  }
305
- async sendWithRetry(t, i, n) {
306
- let s = 0;
307
- for (; s <= this.config.maxRetries; ) {
308
- s += 1;
72
+ async sendWithRetry(t, a, n) {
73
+ let o = 0;
74
+ for (; o <= this.config.maxRetries; ) {
75
+ o += 1;
309
76
  try {
310
- if (await this.send(t, i, n)) return;
77
+ if (await this.send(t, a, n)) return;
311
78
  } catch {
312
79
  }
313
- s <= this.config.maxRetries && await new Promise((a) => setTimeout(a, Math.min(1e3, 100 * Math.pow(2, s - 1))));
80
+ o <= this.config.maxRetries && await new Promise((r) => setTimeout(r, Math.min(1e3, 100 * Math.pow(2, o - 1))));
314
81
  }
315
82
  }
316
- async send(t, i, n) {
317
- const s = JSON.stringify(i);
318
- if (n && this.config.useBeacon && this.config.auth.mode !== "x-api-key-header" && this.config.auth.mode !== "bearer-header" && J()) {
319
- const h = new Blob([s], { type: "application/json" });
320
- if (navigator.sendBeacon(t, h)) return !0;
83
+ async send(t, a, n) {
84
+ const o = JSON.stringify(a);
85
+ if (n && this.config.useBeacon && this.config.auth.mode !== "x-api-key-header" && this.config.auth.mode !== "bearer-header" && T()) {
86
+ const d = new Blob([o], { type: "application/json" });
87
+ if (navigator.sendBeacon(t, d)) return !0;
321
88
  }
322
89
  if (typeof fetch > "u") return !1;
323
- const r = {
90
+ const i = {
324
91
  "Content-Type": "application/json"
325
92
  };
326
- this.config.auth.mode === "x-api-key-header" && this.config.auth.key && (r[this.config.auth.headerName] = this.config.auth.key), this.config.auth.mode === "bearer-header" && this.config.auth.key && (r.Authorization = `Bearer ${this.config.auth.key}`);
327
- const o = typeof AbortController < "u" ? new AbortController() : null, c = o ? setTimeout(() => o.abort(), this.config.timeoutMs) : null;
93
+ this.config.auth.mode === "x-api-key-header" && this.config.auth.key && (i[this.config.auth.headerName] = this.config.auth.key), this.config.auth.mode === "bearer-header" && this.config.auth.key && (i.Authorization = `Bearer ${this.config.auth.key}`);
94
+ const s = typeof AbortController < "u" ? new AbortController() : null, c = s ? setTimeout(() => s.abort(), this.config.timeoutMs) : null;
328
95
  try {
329
- const h = {
96
+ const d = {
330
97
  method: "POST",
331
- headers: r,
332
- body: s,
98
+ headers: i,
99
+ body: o,
333
100
  keepalive: this.config.keepaliveFetch && this.config.fireAndForget
334
101
  };
335
- return o && (h.signal = o.signal), (await fetch(t, h)).ok;
102
+ return s && (d.signal = s.signal), (await fetch(t, d)).ok;
336
103
  } finally {
337
104
  c && clearTimeout(c);
338
105
  }
339
106
  }
340
107
  }
341
- function pe(e) {
342
- return new Y(e);
108
+ function L(e) {
109
+ return new y(e);
343
110
  }
344
- function X(e) {
111
+ function v(e) {
345
112
  const t = {
346
113
  event_name: e.event_name,
347
114
  event_version: e.event_version ?? "1",
@@ -353,15 +120,15 @@ function X(e) {
353
120
  };
354
121
  return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), e.widget !== void 0 && (t.widget = e.widget), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
355
122
  }
356
- function Z(e, t) {
123
+ function w(e, t) {
357
124
  if (/^https?:\/\//i.test(e)) return e;
358
- const i = E(t), n = e.startsWith("/") ? e : `/${e}`;
359
- return `${i}${n}`;
125
+ const a = h(t), n = e.startsWith("/") ? e : `/${e}`;
126
+ return `${a}${n}`;
360
127
  }
361
- function J() {
128
+ function T() {
362
129
  return typeof navigator < "u" && typeof navigator.sendBeacon == "function";
363
130
  }
364
- const ee = {
131
+ const E = {
365
132
  primaryColor: "#000000",
366
133
  primaryForeground: "#ffffff",
367
134
  backgroundColor: "#ffffff",
@@ -386,30 +153,30 @@ const ee = {
386
153
  "--gengage-qna-input-radius": "14px",
387
154
  "--gengage-simrel-card-radius": "14px"
388
155
  };
389
- function me(e) {
390
- return { ...ee, ...e };
156
+ function B(e) {
157
+ return { ...E, ...e };
391
158
  }
392
- const b = "tr";
393
- function ye(e) {
159
+ const l = "tr";
160
+ function q(e) {
394
161
  return {
395
162
  ACCOUNT_ID: e.accountId,
396
163
  MIDDLEWARE_URL: e.middlewareUrl,
397
- LOCALE: e.locale ?? b
164
+ LOCALE: e.locale ?? l
398
165
  };
399
166
  }
400
- function we(e, t = {}) {
401
- const i = {
167
+ function D(e, t = {}) {
168
+ const a = {
402
169
  accountId: e.accountId,
403
170
  middlewareUrl: e.middlewareUrl,
404
171
  session: { sessionId: e.sessionId },
405
172
  variant: "floating",
406
- locale: e.locale ?? b,
173
+ locale: e.locale ?? l,
407
174
  ...t
408
175
  };
409
- return e.theme !== void 0 && (i.theme = e.theme), i;
176
+ return e.theme !== void 0 && (a.theme = e.theme), a;
410
177
  }
411
- function ve(e, t = {}) {
412
- const i = {
178
+ function F(e, t = {}) {
179
+ const a = {
413
180
  accountId: e.accountId,
414
181
  middlewareUrl: e.middlewareUrl,
415
182
  session: { sessionId: e.sessionId },
@@ -417,10 +184,10 @@ function ve(e, t = {}) {
417
184
  mountTarget: e.mountTarget,
418
185
  ...t
419
186
  };
420
- return e.theme !== void 0 && (i.theme = e.theme), i;
187
+ return e.theme !== void 0 && (a.theme = e.theme), a;
421
188
  }
422
- function _e(e, t = {}) {
423
- const i = {
189
+ function N(e, t = {}) {
190
+ const a = {
424
191
  accountId: e.accountId,
425
192
  middlewareUrl: e.middlewareUrl,
426
193
  session: { sessionId: e.sessionId },
@@ -428,9 +195,9 @@ function _e(e, t = {}) {
428
195
  mountTarget: e.mountTarget,
429
196
  ...t
430
197
  };
431
- return e.theme !== void 0 && (i.theme = e.theme), i;
198
+ return e.theme !== void 0 && (a.theme = e.theme), a;
432
199
  }
433
- function Te(e, t = {}) {
200
+ function O(e, t = {}) {
434
201
  return {
435
202
  enabled: !0,
436
203
  middlewareUrl: e,
@@ -440,80 +207,80 @@ function Te(e, t = {}) {
440
207
  ...t
441
208
  };
442
209
  }
443
- function te(e) {
210
+ function b(e) {
444
211
  try {
445
212
  return document.querySelector(e), !0;
446
213
  } catch {
447
214
  return !1;
448
215
  }
449
216
  }
450
- function ie(e, t) {
451
- const i = [], n = e.mounts, s = [
217
+ function k(e, t) {
218
+ const a = [], n = e.mounts, o = [
452
219
  ["qna", n.qna],
453
220
  ["simrel", n.simrel],
454
221
  ["chat", n.chat]
455
222
  ];
456
- for (const [r, o] of s)
457
- if (o !== void 0) {
458
- if (!te(o)) {
459
- i.push({
223
+ for (const [i, s] of o)
224
+ if (s !== void 0) {
225
+ if (!b(s)) {
226
+ a.push({
460
227
  code: "INVALID_SELECTOR",
461
- message: `[gengage preflight] ${r} mount selector is invalid CSS: "${o}"`,
228
+ message: `[gengage preflight] ${i} mount selector is invalid CSS: "${s}"`,
462
229
  severity: "error"
463
230
  });
464
231
  continue;
465
232
  }
466
- document.querySelector(o) || i.push({
233
+ document.querySelector(s) || a.push({
467
234
  code: "MOUNT_NOT_FOUND",
468
- message: `[gengage preflight] ${r} mount target not found: "${o}" — widget will skip or wait for DOM`,
235
+ message: `[gengage preflight] ${i} mount target not found: "${s}" — widget will skip or wait for DOM`,
469
236
  severity: "warn"
470
237
  });
471
238
  }
472
- const a = e.gtm.idempotencyKey;
473
- if (window[a] !== void 0 && i.push({
239
+ const r = e.gtm.idempotencyKey;
240
+ if (window[r] !== void 0 && a.push({
474
241
  code: "DUPLICATE_IDEMPOTENCY",
475
- message: `[gengage preflight] window["${a}"] already exists — widgets may have already initialized`,
242
+ message: `[gengage preflight] window["${r}"] already exists — widgets may have already initialized`,
476
243
  severity: "warn"
477
244
  }), !t?.skipCspCheck) {
478
- let r = !1;
479
- const o = (c) => {
480
- c.blockedURI && e.middlewareUrl.startsWith(c.blockedURI) && (r = !0);
245
+ let i = !1;
246
+ const s = (c) => {
247
+ c.blockedURI && e.middlewareUrl.startsWith(c.blockedURI) && (i = !0);
481
248
  };
482
- document.addEventListener("securitypolicyviolation", o);
249
+ document.addEventListener("securitypolicyviolation", s);
483
250
  try {
484
251
  fetch(e.middlewareUrl, { method: "HEAD", mode: "no-cors" }).catch(() => {
485
252
  });
486
253
  } catch {
487
- r = !0;
254
+ i = !0;
488
255
  }
489
- document.removeEventListener("securitypolicyviolation", o), r && i.push({
256
+ document.removeEventListener("securitypolicyviolation", s), i && a.push({
490
257
  code: "CSP_BLOCKED",
491
258
  message: `[gengage preflight] middleware URL may be blocked by Content-Security-Policy: "${e.middlewareUrl}". Add it to connect-src.`,
492
259
  severity: "warn"
493
260
  });
494
261
  }
495
- for (const r of i)
496
- r.severity === "error" ? console.error(r.message) : console.warn(r.message);
262
+ for (const i of a)
263
+ i.severity === "error" ? console.error(i.message) : console.warn(i.message);
497
264
  return {
498
- ok: i.every((r) => r.severity !== "error"),
499
- warnings: i
265
+ ok: a.every((i) => i.severity !== "error"),
266
+ warnings: a
500
267
  };
501
268
  }
502
- function ne(e) {
503
- const t = N(e);
269
+ function C(e) {
270
+ const t = m(e);
504
271
  if (!t.success) {
505
- const i = t.error.issues.map((n) => `${n.path.join(".")}: ${n.message}`).join("; ");
506
- throw new Error(`[gengage] Invalid runtime config: ${i}`);
272
+ const a = t.error.issues.map((n) => `${n.path.join(".")}: ${n.message}`).join("; ");
273
+ throw new Error(`[gengage] Invalid runtime config: ${a}`);
507
274
  }
508
275
  return t.data;
509
276
  }
510
- function oe(e, t, i) {
277
+ function S(e, t, a) {
511
278
  const n = {
512
279
  accountId: e.accountId,
513
280
  middlewareUrl: e.middlewareUrl,
514
281
  idempotencyKey: e.gtm.idempotencyKey
515
282
  };
516
- return e.locale !== void 0 && (n.locale = e.locale), i !== void 0 && (n.pageContext = i, i.sku !== void 0 && (n.sku = i.sku)), n.chat = {
283
+ return e.locale !== void 0 && (n.locale = e.locale), a !== void 0 && (n.pageContext = a, a.sku !== void 0 && (n.sku = a.sku)), n.chat = {
517
284
  enabled: e.widgets.chat.enabled
518
285
  }, e.mounts.chat !== void 0 && (n.chat.mountTarget = e.mounts.chat), n.qna = {
519
286
  enabled: e.widgets.qna.enabled
@@ -521,30 +288,30 @@ function oe(e, t, i) {
521
288
  enabled: e.widgets.simrel.enabled
522
289
  }, e.mounts.simrel !== void 0 && (n.simrel.mountTarget = e.mounts.simrel), t?.onAddToCart !== void 0 && (n.onAddToCart = t.onAddToCart), t?.onProductNavigate !== void 0 && (n.onProductNavigate = t.onProductNavigate), t?.onScriptCall !== void 0 && (n.onScriptCall = t.onScriptCall), n;
523
290
  }
524
- async function Ce(e) {
525
- const t = ne(e.runtimeConfig);
291
+ async function M(e) {
292
+ const t = C(e.runtimeConfig);
526
293
  if (e.preflight !== !1) {
527
- const a = ie(t);
528
- if (!a.ok) {
529
- const r = a.warnings.filter((o) => o.severity === "error");
530
- throw new Error(`[gengage] Preflight failed: ${r.map((o) => o.message).join("; ")}`);
294
+ const r = k(t);
295
+ if (!r.ok) {
296
+ const i = r.warnings.filter((s) => s.severity === "error");
297
+ throw new Error(`[gengage] Preflight failed: ${i.map((s) => s.message).join("; ")}`);
531
298
  }
532
299
  }
533
- const i = e.contextResolver?.(), n = oe(t, e.hostActions, i), s = await K(n);
300
+ const a = e.contextResolver?.(), n = S(t, e.hostActions, a), o = await f(n);
534
301
  if (e.contextResolver !== void 0) {
535
- const a = e.contextResolver, r = () => {
536
- const c = a();
537
- s.updateContext(c);
302
+ const r = e.contextResolver, i = () => {
303
+ const c = r();
304
+ o.updateContext(c);
538
305
  };
539
- window.addEventListener("gengage:context:update", r);
540
- const o = s.destroy.bind(s);
541
- s.destroy = () => {
542
- window.removeEventListener("gengage:context:update", r), o();
306
+ window.addEventListener("gengage:context:update", i);
307
+ const s = o.destroy.bind(o);
308
+ o.destroy = () => {
309
+ window.removeEventListener("gengage:context:update", i), s();
543
310
  };
544
311
  }
545
- return s;
312
+ return o;
546
313
  }
547
- const se = [
314
+ const A = [
548
315
  {
549
316
  pageType: "home",
550
317
  urlPatterns: ["^/$", "^/index\\.html?$", "^/anasayfa$"]
@@ -567,106 +334,110 @@ const se = [
567
334
  urlPatterns: ["/urun/", "/product/", "/p/", "/-p-", "/-pm-"]
568
335
  }
569
336
  ];
570
- function ae(e, t) {
571
- const i = t ?? (typeof window < "u" ? new URL(window.location.href) : null);
572
- if (!i) return "other";
573
- const n = e ?? se, s = i.pathname;
574
- for (const a of n)
575
- if (!(a.urlPatterns && !a.urlPatterns.some((o) => {
337
+ function I(e, t) {
338
+ const a = t ?? (typeof window < "u" ? new URL(window.location.href) : null);
339
+ if (!a) return "other";
340
+ const n = e ?? A, o = a.pathname;
341
+ for (const r of n)
342
+ if (!(r.urlPatterns && !r.urlPatterns.some((s) => {
576
343
  try {
577
- return new RegExp(o, "i").test(s);
344
+ return new RegExp(s, "i").test(o);
578
345
  } catch {
579
346
  return !1;
580
347
  }
581
- })) && !(a.queryParam && !i.searchParams.has(a.queryParam)) && !(a.selector && typeof document < "u" && !document.querySelector(a.selector)))
582
- return a.pageType;
348
+ })) && !(r.queryParam && !a.searchParams.has(r.queryParam)) && !(r.selector && typeof document < "u" && !document.querySelector(r.selector)))
349
+ return r.pageType;
583
350
  return "other";
584
351
  }
585
- function re(e) {
352
+ function U(e) {
586
353
  const t = e ?? (typeof window < "u" ? new URL(window.location.href) : null);
587
354
  if (!t) return;
588
- const i = t.pathname, n = i.match(/\/(?:p|urun|product)\/([^/?#]+)/i);
355
+ const a = t.pathname, n = a.match(/\/(?:p|urun|product)\/([^/?#]+)/i);
589
356
  if (n?.[1]) return n[1];
590
- const s = i.match(/-p-(\d+)/i);
591
- if (s?.[1]) return s[1];
357
+ const o = a.match(/-p-(\d+)/i);
358
+ if (o?.[1]) return o[1];
592
359
  }
593
- function be(e) {
594
- const t = ae(e), i = { pageType: t };
360
+ function $(e) {
361
+ const t = I(e), a = { pageType: t };
595
362
  if (t === "pdp") {
596
- const n = re();
597
- n && (i.sku = n);
363
+ const n = U();
364
+ n && (a.sku = n);
598
365
  }
599
- return typeof window < "u" && (i.url = window.location.href), i;
366
+ return typeof window < "u" && (a.url = window.location.href), a;
600
367
  }
601
368
  export {
602
- _ as AccountRuntimeConfigSchema,
603
- R as AnalyticsAuthModeSchema,
604
- Y as AnalyticsClient,
605
- ee as BASE_WIDGET_THEME,
606
- xe as BaseWidget,
607
- b as DEFAULT_CUSTOMIZATION_LOCALE,
608
- Ee as DEFAULT_WIDGET_THEME_TOKENS,
609
- D as UnknownActionPolicySchema,
610
- dt as VoiceInput,
611
- Ie as adaptV1Event,
612
- be as autoDetectPageContext,
613
- Ae as basketAddEvent,
614
- qe as bootstrapSession,
615
- Pe as buildChatEndpointUrl,
616
- fe as buildOverlayIdempotencyKey,
617
- Ue as chatHistorySnapshotEvent,
618
- Re as checkoutCompleteEvent,
619
- Me as checkoutStartEvent,
620
- Le as consumeStream,
621
- ye as createAccountIdentity,
622
- pe as createAnalyticsClient,
623
- he as createDefaultAccountRuntimeConfig,
624
- Te as createDefaultAnalyticsConfig,
625
- we as createFloatingChatConfig,
626
- ve as createPdpQnaConfig,
627
- _e as createPdpSimRelConfig,
628
- Fe as defaultUnknownUISpecRenderer,
629
- ge as destroyOverlayWidgets,
630
- ae as detectPageType,
631
- De as dismissGlobalErrorToast,
632
- Oe as dispatch,
633
- re as extractSkuFromUrl,
634
- Be as getGlobalErrorMessage,
635
- Q as getOverlayWidgets,
636
- Ne as getWindowPageContext,
637
- Ce as initGengageClient,
638
- K as initOverlayWidgets,
639
- ut as isVoiceInputSupported,
640
- $e as listen,
641
- We as llmUsageEvent,
642
- He as mergeUISpecRegistry,
643
- ze as meteringIncrementEvent,
644
- Ge as meteringSummaryEvent,
645
- E as normalizeMiddlewareUrl,
646
- Ke as normalizeProductGroupingsResponse,
647
- Qe as normalizeSimilarProductsResponse,
648
- B as parseAccountRuntimeConfig,
649
- ie as preflightDiagnostics,
650
- Ve as productToNormalized,
651
- je as registerGlobalErrorToastListener,
652
- Ye as renderUISpecWithRegistry,
653
- S as resolveSession,
654
- ht as routeStreamAction,
655
- N as safeParseAccountRuntimeConfig,
656
- ft as sanitizeHtml,
657
- Xe as showGlobalErrorToast,
658
- Ze as streamChunkEvent,
659
- Je as streamDoneEvent,
660
- et as streamErrorEvent,
661
- tt as streamPost,
662
- it as streamStartEvent,
663
- nt as streamUiSpecEvent,
664
- ot as updatePageContext,
665
- st as widgetHistorySnapshotEvent,
666
- at as wireGADataLayer,
667
- x as wireQNAToChat,
668
- rt as wireSimilarToChat,
669
- me as withBaseTheme,
670
- lt as withDefaultWidgetTheme
369
+ _e as AccountRuntimeConfigSchema,
370
+ Pe as AnalyticsAuthModeSchema,
371
+ y as AnalyticsClient,
372
+ E as BASE_WIDGET_THEME,
373
+ H as BaseWidget,
374
+ l as DEFAULT_CUSTOMIZATION_LOCALE,
375
+ G as DEFAULT_WIDGET_THEME_TOKENS,
376
+ Re as UnknownActionPolicySchema,
377
+ ze as VoiceInput,
378
+ K as adaptV1Event,
379
+ Le as applyNativeSession,
380
+ $ as autoDetectPageContext,
381
+ V as basketAddEvent,
382
+ j as bootstrapSession,
383
+ Q as buildChatEndpointUrl,
384
+ Be as buildOverlayIdempotencyKey,
385
+ Y as chatHistorySnapshotEvent,
386
+ X as checkoutCompleteEvent,
387
+ Z as checkoutStartEvent,
388
+ J as consumeStream,
389
+ q as createAccountIdentity,
390
+ L as createAnalyticsClient,
391
+ qe as createDefaultAccountRuntimeConfig,
392
+ O as createDefaultAnalyticsConfig,
393
+ D as createFloatingChatConfig,
394
+ De as createNativeWebViewBridge,
395
+ F as createPdpQnaConfig,
396
+ N as createPdpSimRelConfig,
397
+ ee as defaultUnknownUISpecRenderer,
398
+ Fe as destroyOverlayWidgets,
399
+ Ne as detectNativeEnvironment,
400
+ I as detectPageType,
401
+ te as dismissGlobalErrorToast,
402
+ ae as dispatch,
403
+ U as extractSkuFromUrl,
404
+ ne as getGlobalErrorMessage,
405
+ Oe as getOverlayWidgets,
406
+ oe as getWindowPageContext,
407
+ M as initGengageClient,
408
+ Me as initNativeOverlayWidgets,
409
+ f as initOverlayWidgets,
410
+ He as isVoiceInputSupported,
411
+ ie as listen,
412
+ re as llmUsageEvent,
413
+ se as mergeUISpecRegistry,
414
+ ce as meteringIncrementEvent,
415
+ de as meteringSummaryEvent,
416
+ h as normalizeMiddlewareUrl,
417
+ le as normalizeProductGroupingsResponse,
418
+ ue as normalizeSimilarProductsResponse,
419
+ $e as parseAccountRuntimeConfig,
420
+ k as preflightDiagnostics,
421
+ he as productToNormalized,
422
+ fe as registerGlobalErrorToastListener,
423
+ me as renderUISpecWithRegistry,
424
+ ge as resolveSession,
425
+ Ge as routeStreamAction,
426
+ m as safeParseAccountRuntimeConfig,
427
+ Ve as sanitizeHtml,
428
+ pe as showGlobalErrorToast,
429
+ ye as streamChunkEvent,
430
+ ve as streamDoneEvent,
431
+ we as streamErrorEvent,
432
+ Te as streamPost,
433
+ Ee as streamStartEvent,
434
+ be as streamUiSpecEvent,
435
+ ke as updatePageContext,
436
+ Ce as widgetHistorySnapshotEvent,
437
+ Se as wireGADataLayer,
438
+ Ae as wireQNAToChat,
439
+ Ie as wireSimilarToChat,
440
+ B as withBaseTheme,
441
+ Ue as withDefaultWidgetTheme
671
442
  };
672
443
  //# sourceMappingURL=common.js.map