@gengage/assistant-fe 0.1.0 → 0.1.2

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 (150) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +2 -2
  3. package/dist/assistant-fe.css +1 -1
  4. package/dist/chat/api.d.ts +12 -2
  5. package/dist/chat/api.d.ts.map +1 -1
  6. package/dist/chat/catalog.d.ts +246 -896
  7. package/dist/chat/catalog.d.ts.map +1 -1
  8. package/dist/chat/components/AIGroupingCards.d.ts.map +1 -1
  9. package/dist/chat/components/AISuggestedSearchCards.d.ts.map +1 -1
  10. package/dist/chat/components/AITopPicks.d.ts.map +1 -1
  11. package/dist/chat/components/CategoriesContainer.d.ts.map +1 -1
  12. package/dist/chat/components/ChatDrawer.d.ts +16 -3
  13. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  14. package/dist/chat/components/ComparisonTable.d.ts +9 -0
  15. package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
  16. package/dist/chat/components/GroundingReviewCard.d.ts.map +1 -1
  17. package/dist/chat/components/HandoffNotice.d.ts +5 -0
  18. package/dist/chat/components/HandoffNotice.d.ts.map +1 -0
  19. package/dist/chat/components/KvkkBanner.d.ts +1 -0
  20. package/dist/chat/components/KvkkBanner.d.ts.map +1 -1
  21. package/dist/chat/components/ProactivePopup.d.ts +9 -0
  22. package/dist/chat/components/ProactivePopup.d.ts.map +1 -1
  23. package/dist/chat/components/ProductSummaryCard.d.ts +4 -0
  24. package/dist/chat/components/ProductSummaryCard.d.ts.map +1 -0
  25. package/dist/chat/components/ReviewHighlights.d.ts +3 -1
  26. package/dist/chat/components/ReviewHighlights.d.ts.map +1 -1
  27. package/dist/chat/components/ThumbnailsColumn.d.ts.map +1 -1
  28. package/dist/chat/components/renderUISpec.d.ts +4 -3
  29. package/dist/chat/components/renderUISpec.d.ts.map +1 -1
  30. package/dist/chat/heartbeat.d.ts +71 -0
  31. package/dist/chat/heartbeat.d.ts.map +1 -0
  32. package/dist/chat/index.d.ts +39 -78
  33. package/dist/chat/index.d.ts.map +1 -1
  34. package/dist/chat/kvkk.d.ts +21 -0
  35. package/dist/chat/kvkk.d.ts.map +1 -0
  36. package/dist/chat/locales/en.d.ts.map +1 -1
  37. package/dist/chat/locales/tr.d.ts.map +1 -1
  38. package/dist/chat/panel-manager.d.ts +81 -0
  39. package/dist/chat/panel-manager.d.ts.map +1 -0
  40. package/dist/chat/session-persistence.d.ts +56 -0
  41. package/dist/chat/session-persistence.d.ts.map +1 -0
  42. package/dist/chat/types.d.ts +39 -1
  43. package/dist/chat/types.d.ts.map +1 -1
  44. package/dist/chat.cjs +1 -1
  45. package/dist/chat.iife.js +48 -10
  46. package/dist/chat.iife.js.map +1 -1
  47. package/dist/chat.js +9 -8
  48. package/dist/chat.js.map +1 -1
  49. package/dist/common/analytics-events.d.ts +2 -0
  50. package/dist/common/analytics-events.d.ts.map +1 -1
  51. package/dist/common/analytics.d.ts.map +1 -1
  52. package/dist/common/api-paths.d.ts +5 -0
  53. package/dist/common/api-paths.d.ts.map +1 -1
  54. package/dist/common/client.d.ts +4 -1
  55. package/dist/common/client.d.ts.map +1 -1
  56. package/dist/common/communication-bridge.d.ts.map +1 -1
  57. package/dist/common/config-schema.d.ts +33 -195
  58. package/dist/common/config-schema.d.ts.map +1 -1
  59. package/dist/common/ga-datalayer.d.ts +62 -0
  60. package/dist/common/ga-datalayer.d.ts.map +1 -0
  61. package/dist/common/index.d.ts +7 -0
  62. package/dist/common/index.d.ts.map +1 -1
  63. package/dist/common/indexed-db.d.ts +1 -1
  64. package/dist/common/indexed-db.d.ts.map +1 -1
  65. package/dist/common/merchant-configs.d.ts +22 -0
  66. package/dist/common/merchant-configs.d.ts.map +1 -0
  67. package/dist/common/overlay.d.ts +5 -0
  68. package/dist/common/overlay.d.ts.map +1 -1
  69. package/dist/common/page-detect.d.ts +31 -0
  70. package/dist/common/page-detect.d.ts.map +1 -0
  71. package/dist/common/preflight.d.ts +3 -1
  72. package/dist/common/preflight.d.ts.map +1 -1
  73. package/dist/common/price-formatter.d.ts +33 -0
  74. package/dist/common/price-formatter.d.ts.map +1 -0
  75. package/dist/common/product-utils.d.ts +26 -0
  76. package/dist/common/product-utils.d.ts.map +1 -0
  77. package/dist/common/quantity-stepper.d.ts +22 -0
  78. package/dist/common/quantity-stepper.d.ts.map +1 -0
  79. package/dist/common/safe-html.d.ts +10 -6
  80. package/dist/common/safe-html.d.ts.map +1 -1
  81. package/dist/common/streaming.d.ts +6 -0
  82. package/dist/common/streaming.d.ts.map +1 -1
  83. package/dist/common/tts-player.d.ts +12 -0
  84. package/dist/common/tts-player.d.ts.map +1 -0
  85. package/dist/common/types.d.ts +51 -0
  86. package/dist/common/types.d.ts.map +1 -1
  87. package/dist/common/v1-protocol-adapter.d.ts +9 -0
  88. package/dist/common/v1-protocol-adapter.d.ts.map +1 -1
  89. package/dist/common/voice-input.d.ts +74 -0
  90. package/dist/common/voice-input.d.ts.map +1 -0
  91. package/dist/common/widget-base.d.ts +18 -1
  92. package/dist/common/widget-base.d.ts.map +1 -1
  93. package/dist/common.cjs +1 -1
  94. package/dist/common.cjs.map +1 -1
  95. package/dist/common.js +564 -244
  96. package/dist/common.js.map +1 -1
  97. package/dist/index-CXbH-cw8.js +4337 -0
  98. package/dist/index-CXbH-cw8.js.map +1 -0
  99. package/dist/index-DHfTHscz.cjs +13 -0
  100. package/dist/index-DHfTHscz.cjs.map +1 -0
  101. package/dist/index.cjs +1 -1
  102. package/dist/index.d.ts +2 -2
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +61 -53
  105. package/dist/qna/catalog.d.ts +30 -96
  106. package/dist/qna/catalog.d.ts.map +1 -1
  107. package/dist/qna/components/TextInput.d.ts.map +1 -1
  108. package/dist/qna/components/renderUISpec.d.ts.map +1 -1
  109. package/dist/qna/index.d.ts +2 -0
  110. package/dist/qna/index.d.ts.map +1 -1
  111. package/dist/qna.cjs +1 -1
  112. package/dist/qna.cjs.map +1 -1
  113. package/dist/qna.iife.js +46 -8
  114. package/dist/qna.iife.js.map +1 -1
  115. package/dist/qna.js +94 -86
  116. package/dist/qna.js.map +1 -1
  117. package/dist/quantity-stepper-B8kX8GbN.js +209 -0
  118. package/dist/quantity-stepper-B8kX8GbN.js.map +1 -0
  119. package/dist/quantity-stepper-UbAp53Ow.cjs +2 -0
  120. package/dist/quantity-stepper-UbAp53Ow.cjs.map +1 -0
  121. package/dist/schemas-CPkzbgia.js +4572 -0
  122. package/dist/schemas-CPkzbgia.js.map +1 -0
  123. package/dist/schemas-tCxs1sED.cjs +86 -0
  124. package/dist/schemas-tCxs1sED.cjs.map +1 -0
  125. package/dist/simrel/api.d.ts.map +1 -1
  126. package/dist/simrel/catalog.d.ts +32 -240
  127. package/dist/simrel/catalog.d.ts.map +1 -1
  128. package/dist/simrel/components/GroupTabs.d.ts.map +1 -1
  129. package/dist/simrel/components/ProductCard.d.ts +2 -0
  130. package/dist/simrel/components/ProductCard.d.ts.map +1 -1
  131. package/dist/simrel/components/renderUISpec.d.ts.map +1 -1
  132. package/dist/simrel/index.d.ts.map +1 -1
  133. package/dist/simrel/types.d.ts +5 -0
  134. package/dist/simrel/types.d.ts.map +1 -1
  135. package/dist/simrel.cjs +1 -1
  136. package/dist/simrel.cjs.map +1 -1
  137. package/dist/simrel.css +1 -1
  138. package/dist/simrel.iife.js +46 -8
  139. package/dist/simrel.iife.js.map +1 -1
  140. package/dist/simrel.js +319 -279
  141. package/dist/simrel.js.map +1 -1
  142. package/package.json +28 -8
  143. package/dist/index-CFA70IGF.js +0 -3626
  144. package/dist/index-CFA70IGF.js.map +0 -1
  145. package/dist/index-Dfl89zpe.cjs +0 -13
  146. package/dist/index-Dfl89zpe.cjs.map +0 -1
  147. package/dist/types-CeON7iBO.cjs +0 -48
  148. package/dist/types-CeON7iBO.cjs.map +0 -1
  149. package/dist/types-yxW8WA7u.js +0 -4132
  150. package/dist/types-yxW8WA7u.js.map +0 -1
@@ -0,0 +1,4337 @@
1
+ import { b as fe, c as Ae, a as Pe, A as Be, r as Me, o as L, s as x, f as B, C as ae, d as oe, u as re, v as Y, e as $, _ as be, B as ze, D as De, j as O, t as Re, i as Ue, E as He, F as Fe, g as Oe, m as qe, G as je, H as Ve, I as Ge, y as $e, x as Ke, n as We, J as Ye, K as Qe, L as ge, h as Xe, M as Je, N as Ze, l as et, O as tt, P as at, Q as nt, R as it, S as ot, T as rt } from "./schemas-CPkzbgia.js";
2
+ import { s as Z, i as K, c as se, d as D, a as Q, f as F, e as G, r as xe, g as ve, b as we } from "./quantity-stepper-B8kX8GbN.js";
3
+ function st() {
4
+ const o = Date.now(), e = new Uint8Array(16);
5
+ crypto.getRandomValues(e), e[0] = o / 2 ** 40 & 255, e[1] = o / 2 ** 32 & 255, e[2] = o / 2 ** 24 & 255, e[3] = o / 2 ** 16 & 255, e[4] = o / 2 ** 8 & 255, e[5] = o & 255, e[6] = e[6] & 15 | 112, e[8] = e[8] & 63 | 128;
6
+ const t = Array.from(e, (a) => a.toString(16).padStart(2, "0")).join("");
7
+ return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
8
+ }
9
+ class ct {
10
+ constructor(e) {
11
+ this._handlers = /* @__PURE__ */ new Map(), this._destroyed = !1, this._namespace = e.namespace, this._allowedOrigins = e.allowedOrigins ?? ["*"], this._onMessage = e.onMessage, this._allowedOrigins.includes("*"), this._messageListener = (t) => this._handlePostMessage(t), window.addEventListener("message", this._messageListener);
12
+ }
13
+ /** Send a message to the host page via CustomEvent on window. */
14
+ send(e, t) {
15
+ if (this._destroyed) return;
16
+ const a = {
17
+ namespace: this._namespace,
18
+ type: e
19
+ };
20
+ t !== void 0 && (a.payload = t), window.dispatchEvent(
21
+ new CustomEvent("gengage:bridge:message", {
22
+ detail: a,
23
+ bubbles: !1
24
+ })
25
+ );
26
+ }
27
+ /**
28
+ * Register a handler for a specific message type.
29
+ * Returns an unsubscribe function.
30
+ */
31
+ on(e, t) {
32
+ this._handlers.has(e) || this._handlers.set(e, /* @__PURE__ */ new Set());
33
+ const a = this._handlers.get(e);
34
+ return a.add(t), () => {
35
+ a.delete(t), a.size === 0 && this._handlers.delete(e);
36
+ };
37
+ }
38
+ /** Clean up all event listeners and handlers. */
39
+ destroy() {
40
+ this._destroyed || (this._destroyed = !0, window.removeEventListener("message", this._messageListener), this._handlers.clear());
41
+ }
42
+ // ---------------------------------------------------------------------------
43
+ // Private
44
+ // ---------------------------------------------------------------------------
45
+ _handlePostMessage(e) {
46
+ if (this._destroyed || !this._isOriginAllowed(e.origin)) return;
47
+ const t = e.data;
48
+ if (!lt(t) || t.gengage !== this._namespace) return;
49
+ const a = { type: t.type };
50
+ t.payload !== void 0 && (a.payload = t.payload), this._onMessage?.(a);
51
+ const n = this._handlers.get(a.type);
52
+ if (n)
53
+ for (const i of n)
54
+ i(a.payload);
55
+ }
56
+ _isOriginAllowed(e) {
57
+ return this._allowedOrigins.includes("*") ? !0 : this._allowedOrigins.includes(e);
58
+ }
59
+ }
60
+ function lt(o) {
61
+ if (typeof o != "object" || o === null) return !1;
62
+ const e = o;
63
+ return typeof e.gengage == "string" && typeof e.type == "string";
64
+ }
65
+ const gt = console;
66
+ function dt(o, e, t = {}) {
67
+ const a = o.action, n = t.logger ?? gt;
68
+ switch (a.kind) {
69
+ case "open_chat": {
70
+ e.openChat?.(a.payload);
71
+ return;
72
+ }
73
+ case "navigate": {
74
+ if (typeof a.url != "string") {
75
+ X(a, e, t, n);
76
+ return;
77
+ }
78
+ const i = typeof a.newTab == "boolean" ? a.newTab : void 0;
79
+ if (e.navigate) {
80
+ i !== void 0 ? e.navigate({ url: a.url, newTab: i }) : e.navigate({ url: a.url });
81
+ return;
82
+ }
83
+ pt(a.url, i);
84
+ return;
85
+ }
86
+ case "save_session": {
87
+ if (typeof a.sessionId != "string" || typeof a.sku != "string") {
88
+ X(a, e, t, n);
89
+ return;
90
+ }
91
+ e.saveSession?.({ sessionId: a.sessionId, sku: a.sku });
92
+ return;
93
+ }
94
+ case "add_to_cart": {
95
+ if (typeof a.sku != "string" || typeof a.quantity != "number" || typeof a.cartCode != "string") {
96
+ X(a, e, t, n);
97
+ return;
98
+ }
99
+ e.addToCart?.({
100
+ sku: a.sku,
101
+ quantity: a.quantity,
102
+ cartCode: a.cartCode
103
+ });
104
+ return;
105
+ }
106
+ case "script_call": {
107
+ if (t.allowScriptCall === !1) {
108
+ X(a, e, t, n);
109
+ return;
110
+ }
111
+ if (typeof a.name != "string") {
112
+ X(a, e, t, n);
113
+ return;
114
+ }
115
+ const i = ht(a.payload) ? a.payload : void 0;
116
+ i !== void 0 ? e.scriptCall?.({ name: a.name, payload: i }) : e.scriptCall?.({ name: a.name });
117
+ return;
118
+ }
119
+ default:
120
+ X(a, e, t, n);
121
+ }
122
+ }
123
+ function X(o, e, t, a) {
124
+ const n = t.unknownActionPolicy ?? "log-and-ignore";
125
+ if (n === "delegate") {
126
+ e.unknown?.(o), e.unknown || a.warn("[gengage] Unknown action received without delegate handler", o);
127
+ return;
128
+ }
129
+ if (n === "throw")
130
+ throw new Error(`[gengage] Unknown action kind: ${o.kind}`);
131
+ a.warn("[gengage] Unknown action ignored", o);
132
+ }
133
+ function pt(o, e) {
134
+ if (!(typeof window > "u")) {
135
+ if (e) {
136
+ window.open(o, "_blank", "noopener,noreferrer");
137
+ return;
138
+ }
139
+ window.location.href = o;
140
+ }
141
+ }
142
+ function ht(o) {
143
+ return typeof o == "object" && o !== null && !Array.isArray(o);
144
+ }
145
+ const ut = ["image/jpeg", "image/png", "image/webp"], mt = 5 * 1024 * 1024;
146
+ function ft(o) {
147
+ return ut.includes(o.type) ? o.size > mt ? { ok: !1, reason: "too_large" } : { ok: !0 } : { ok: !1, reason: "invalid_type" };
148
+ }
149
+ function bt(o, e) {
150
+ const t = o.type, a = o.payload != null && typeof o.payload == "object" && !Array.isArray(o.payload) ? o.payload : {}, n = (i) => {
151
+ const r = { ...a };
152
+ for (const [s, l] of Object.entries(i))
153
+ s in r || (r[s] = l);
154
+ return r;
155
+ };
156
+ switch (t) {
157
+ case "inputText": {
158
+ const i = {
159
+ is_launcher: 0
160
+ };
161
+ return e.pageContext?.extra && (i.page_details = e.pageContext.extra), "is_suggested_text" in a || (i.is_suggested_text = 0), { ...o, payload: n(i) };
162
+ }
163
+ case "findSimilar": {
164
+ const i = {
165
+ is_launcher: 0
166
+ };
167
+ return o.title && (i.text = o.title), o.title && (i.input = o.title), { ...o, payload: n(i) };
168
+ }
169
+ case "getComparisonTable":
170
+ return o;
171
+ case "addToCart": {
172
+ const i = {};
173
+ return "error_message" in a || (i.error_message = ""), { ...o, payload: n(i) };
174
+ }
175
+ case "reviewSummary": {
176
+ const i = {};
177
+ return e.pageContext?.sku && !("sku" in a) && (i.sku = e.pageContext.sku), Object.keys(i).length === 0 ? o : { ...o, payload: n(i) };
178
+ }
179
+ default:
180
+ return o;
181
+ }
182
+ }
183
+ const xt = {
184
+ user_message: "inputText"
185
+ };
186
+ function vt(o) {
187
+ const { action: e, type: t, payload: a, ...n } = o, i = t ?? e?.type ?? "inputText", r = a ?? e?.payload, s = xt[i] ?? i, l = {
188
+ ...n,
189
+ type: s
190
+ };
191
+ return r !== void 0 && (l.payload = typeof r == "string" ? { text: r } : r), JSON.stringify(l);
192
+ }
193
+ function wt(o) {
194
+ const e = o.type ?? o.action?.type ?? "inputText", t = o.payload ?? o.action?.payload;
195
+ let a = o.action?.title ?? "";
196
+ (e === "inputText" || e === "user_message") && (typeof t == "string" ? a = t : t && typeof t == "object" && "text" in t && (a = String(t.text)));
197
+ const n = {
198
+ message: a,
199
+ session_id: o.session_id
200
+ };
201
+ if (o.user_id && (n.user_id = o.user_id), o.locale && (n.output_language = o.locale), o.meta?.outputLanguage && (n.output_language = o.meta.outputLanguage), o.sku || o.page_type) {
202
+ const i = {};
203
+ o.page_type && (i.screen_type = o.page_type), o.sku && (i.sku_list = [o.sku]), n.screen_context = i;
204
+ }
205
+ return e !== "inputText" && e !== "user_message" && (n.action_type = e, t !== void 0 && (n.action_payload = typeof t == "string" ? { text: t } : t)), JSON.stringify(n);
206
+ }
207
+ function yt(o, e, t) {
208
+ const a = fe("process_action", t), n = new AbortController();
209
+ return (async () => {
210
+ try {
211
+ const r = t.backendType === "acap" ? wt(o) : vt(o), s = t.attachment !== void 0;
212
+ let l;
213
+ if (s) {
214
+ const m = new FormData();
215
+ m.append("request", r), t.attachment !== void 0 && m.append("attachment", t.attachment), l = {
216
+ method: "POST",
217
+ body: m,
218
+ signal: n.signal
219
+ };
220
+ } else
221
+ l = {
222
+ method: "POST",
223
+ headers: { "Content-Type": "application/json" },
224
+ body: r,
225
+ signal: n.signal
226
+ };
227
+ const g = await fetch(a, l);
228
+ if (!g.ok) {
229
+ let m = g.statusText;
230
+ try {
231
+ const d = await g.json(), v = d.detail ?? d.message ?? d.error;
232
+ typeof v == "string" && (m = v);
233
+ } catch {
234
+ }
235
+ e.onError(new Error(`HTTP ${g.status}: ${m}`));
236
+ return;
237
+ }
238
+ let c = !1;
239
+ const h = () => {
240
+ c || (c = !0, e.onDone());
241
+ };
242
+ await Ae(g, {
243
+ onEvent: (m) => {
244
+ const d = Pe(m);
245
+ if (d)
246
+ switch (d.type) {
247
+ case "text_chunk":
248
+ e.onTextChunk(d.content, d.final === !0, {
249
+ productMentions: d.productMentions,
250
+ skuToProductItem: d.skuToProductItem,
251
+ conversationMode: d.conversationMode
252
+ });
253
+ break;
254
+ case "ui_spec":
255
+ e.onUISpec(d.spec, d.widget, d.panelHint);
256
+ break;
257
+ case "action":
258
+ e.onAction(d);
259
+ break;
260
+ case "metadata":
261
+ e.onMetadata(d);
262
+ break;
263
+ case "error":
264
+ e.onError(new Error(d.message));
265
+ break;
266
+ case "done":
267
+ h();
268
+ break;
269
+ }
270
+ },
271
+ onError: e.onError,
272
+ signal: n.signal
273
+ }), h();
274
+ } catch (r) {
275
+ if (r instanceof DOMException && r.name === "AbortError") return;
276
+ e.onError(r instanceof Error ? r : new Error(String(r)));
277
+ }
278
+ })(), n;
279
+ }
280
+ async function _t(o, e) {
281
+ const t = fe("proactive_action", e);
282
+ try {
283
+ const a = await fetch(t, {
284
+ method: "POST",
285
+ headers: { "Content-Type": "application/json" },
286
+ body: JSON.stringify(o)
287
+ });
288
+ return a.ok ? await a.json() : null;
289
+ } catch {
290
+ return null;
291
+ }
292
+ }
293
+ const ce = {
294
+ headerTitle: "Ürün Uzmanı",
295
+ inputPlaceholder: "Ürün ara, soru sor",
296
+ sendButton: "Gönder",
297
+ closeButton: "Kapat",
298
+ openButton: "Sohbeti aç",
299
+ newChatButton: "Yeni sohbet",
300
+ poweredBy: "Powered by Gengage",
301
+ errorMessage: "Bir hata oluştu. Lütfen tekrar deneyin.",
302
+ retryButton: "Tekrar Dene",
303
+ loadingMessage: "Düşünüyorum...",
304
+ productCtaLabel: "İncele",
305
+ attachImageButton: "Resim ekle",
306
+ removeAttachmentButton: "Resmi kaldır",
307
+ invalidFileType: "Sadece JPEG, PNG ve WebP dosyaları destekleniyor.",
308
+ fileTooLarge: "Dosya boyutu 5 MB'dan küçük olmalıdır.",
309
+ aiTopPicksTitle: "Sizin İçin En İyiler",
310
+ roleWinner: "En Beğendiğim",
311
+ roleBestValue: "En Uygun Fiyatlı",
312
+ roleBestAlternative: "En İyi Alternatif",
313
+ viewDetails: "Detayları Gör",
314
+ groundingReviewCta: "Yorumları Oku",
315
+ groundingReviewSubtitle: "{count} yorum mevcut",
316
+ variantsLabel: "Varyantlar",
317
+ sortRelated: "Önerilen",
318
+ sortPriceAsc: "Fiyat ↑",
319
+ sortPriceDesc: "Fiyat ↓",
320
+ compareSelected: "Karşılaştır",
321
+ panelTitleProductDetails: "Ürün Detayı",
322
+ panelTitleSimilarProducts: "Benzer Ürünler",
323
+ panelTitleComparisonResults: "Karşılaştırma Sonuçları",
324
+ panelTitleCategories: "Kategoriler",
325
+ inStockLabel: "Stokta",
326
+ outOfStockLabel: "Tükendi",
327
+ findSimilarLabel: "Benzerlerini Bul",
328
+ choicePrompterHeading: "Kararsız mı kaldın?",
329
+ choicePrompterSuggestion: "Ürünleri seçip karşılaştırabilirsin",
330
+ choicePrompterCta: "Seç ve Karşılaştır",
331
+ viewMoreLabel: "Daha Fazla Göster",
332
+ similarProductsLabel: "Benzer Ürünler",
333
+ addToCartButton: "Sepete Ekle",
334
+ shareButton: "Paylaş",
335
+ productInfoTab: "Ürün Bilgileri",
336
+ specificationsTab: "Teknik Özellikler",
337
+ recommendedChoiceLabel: "Önerilen Seçim",
338
+ highlightsLabel: "Öne Çıkan Özellikler",
339
+ keyDifferencesLabel: "Temel Farklar",
340
+ specialCasesLabel: "Özel Durumlar İçin",
341
+ emptyReviewsMessage: "Yorum özeti bulunamadı.",
342
+ closeAriaLabel: "Kapat",
343
+ startChatLabel: "Sohbete Başla",
344
+ voiceButton: "Sesli giriş",
345
+ voiceListening: "Dinleniyor...",
346
+ voiceNotSupported: "Sesli giriş bu tarayıcıda desteklenmiyor.",
347
+ voicePermissionDenied: "Mikrofon erişimi reddedildi.",
348
+ voiceError: "Sesli giriş hatası.",
349
+ handoffHeading: "Destek temsilcisine aktarılıyor"
350
+ }, kt = {
351
+ headerTitle: "Product Expert",
352
+ inputPlaceholder: "Search products, ask questions",
353
+ sendButton: "Send",
354
+ closeButton: "Close",
355
+ openButton: "Open chat",
356
+ newChatButton: "New chat",
357
+ poweredBy: "Powered by Gengage",
358
+ errorMessage: "Something went wrong. Please try again.",
359
+ retryButton: "Retry",
360
+ loadingMessage: "Thinking...",
361
+ productCtaLabel: "View",
362
+ attachImageButton: "Attach image",
363
+ removeAttachmentButton: "Remove image",
364
+ invalidFileType: "Only JPEG, PNG and WebP files are supported.",
365
+ fileTooLarge: "File must be smaller than 5 MB.",
366
+ aiTopPicksTitle: "Top Picks for You",
367
+ roleWinner: "Top Pick",
368
+ roleBestValue: "Best Value",
369
+ roleBestAlternative: "Best Alternative",
370
+ viewDetails: "View Details",
371
+ groundingReviewCta: "Read Reviews",
372
+ groundingReviewSubtitle: "{count} reviews available",
373
+ variantsLabel: "Variants",
374
+ sortRelated: "Related",
375
+ sortPriceAsc: "Price ↑",
376
+ sortPriceDesc: "Price ↓",
377
+ compareSelected: "Compare",
378
+ panelTitleProductDetails: "Product Details",
379
+ panelTitleSimilarProducts: "Similar Products",
380
+ panelTitleComparisonResults: "Comparison Results",
381
+ panelTitleCategories: "Categories",
382
+ inStockLabel: "In Stock",
383
+ outOfStockLabel: "Out of Stock",
384
+ findSimilarLabel: "Find Similar",
385
+ choicePrompterHeading: "Can't decide?",
386
+ choicePrompterSuggestion: "Select products to compare them",
387
+ choicePrompterCta: "Select & Compare",
388
+ viewMoreLabel: "Show More",
389
+ similarProductsLabel: "Similar Products",
390
+ addToCartButton: "Add to Cart",
391
+ shareButton: "Share",
392
+ productInfoTab: "Product Info",
393
+ specificationsTab: "Specifications",
394
+ recommendedChoiceLabel: "Recommended Choice",
395
+ highlightsLabel: "Key Highlights",
396
+ keyDifferencesLabel: "Key Differences",
397
+ specialCasesLabel: "For Special Cases",
398
+ emptyReviewsMessage: "No review summary found.",
399
+ closeAriaLabel: "Close",
400
+ startChatLabel: "Start Chat",
401
+ voiceButton: "Voice input",
402
+ voiceListening: "Listening...",
403
+ voiceNotSupported: "Voice input is not supported in this browser.",
404
+ voicePermissionDenied: "Microphone access denied.",
405
+ voiceError: "Voice input error.",
406
+ handoffHeading: "Transferring to a support agent"
407
+ };
408
+ function Ct(o) {
409
+ return o ? o.toLowerCase().split("-")[0] ?? "tr" : "tr";
410
+ }
411
+ function Et(o) {
412
+ return Ct(o) === "en" ? kt : ce;
413
+ }
414
+ function St() {
415
+ return ye() !== null;
416
+ }
417
+ function ye() {
418
+ const o = globalThis;
419
+ return o.SpeechRecognition ?? o.webkitSpeechRecognition ?? null;
420
+ }
421
+ class Tt {
422
+ constructor(e, t) {
423
+ this.recognition = null, this._state = "idle", this.silenceTimer = null, this.accumulatedTranscript = "", this.intentionalStop = !1, this.callbacks = e, this.lang = t?.lang ?? "tr-TR", this.silenceTimeoutMs = t?.silenceTimeoutMs ?? 1500, this.autoSubmit = t?.autoSubmit ?? !0;
424
+ }
425
+ get state() {
426
+ return this._state;
427
+ }
428
+ /**
429
+ * Start listening. Requests microphone permission on first call.
430
+ */
431
+ start() {
432
+ if (this._state === "listening") return;
433
+ const e = ye();
434
+ if (!e) {
435
+ this.setState("error"), this.callbacks.onError?.("not-supported", "Web Speech API is not supported in this browser.");
436
+ return;
437
+ }
438
+ if (typeof globalThis.isSecureContext < "u" && !globalThis.isSecureContext) {
439
+ this.setState("error"), this.callbacks.onError?.("not-allowed", "Voice input requires HTTPS.");
440
+ return;
441
+ }
442
+ this.accumulatedTranscript = "", this.intentionalStop = !1;
443
+ const t = new e();
444
+ t.continuous = !0, t.interimResults = !0, t.lang = this.lang, t.maxAlternatives = 1, t.onstart = () => {
445
+ this.setState("listening");
446
+ }, t.onresult = (a) => {
447
+ this.clearSilenceTimer();
448
+ let n = "", i = "";
449
+ for (let r = a.resultIndex; r < a.results.length; r++) {
450
+ const s = a.results[r];
451
+ if (!s) continue;
452
+ const l = s[0];
453
+ l && (s.isFinal ? i += l.transcript : n += l.transcript);
454
+ }
455
+ i && (this.accumulatedTranscript += i, this.callbacks.onFinal?.(this.accumulatedTranscript)), n && this.callbacks.onInterim?.(this.accumulatedTranscript + n), this.autoSubmit && this.accumulatedTranscript && this.startSilenceTimer();
456
+ }, t.onerror = (a) => {
457
+ const n = It(a.error);
458
+ this.intentionalStop && (a.error === "no-speech" || a.error === "aborted") || (this.setState("error"), this.callbacks.onError?.(n, a.message || a.error));
459
+ }, t.onend = () => {
460
+ if (this.clearSilenceTimer(), this._state === "listening" && !this.intentionalStop) {
461
+ try {
462
+ t.start();
463
+ } catch {
464
+ this.setState("idle");
465
+ }
466
+ return;
467
+ }
468
+ this.setState("idle");
469
+ }, this.recognition = t;
470
+ try {
471
+ t.start();
472
+ } catch {
473
+ this.setState("error"), this.callbacks.onError?.("unknown", "Failed to start speech recognition.");
474
+ }
475
+ }
476
+ /**
477
+ * Stop listening. Returns the accumulated transcript.
478
+ */
479
+ stop() {
480
+ if (this.intentionalStop = !0, this.clearSilenceTimer(), this.recognition) {
481
+ try {
482
+ this.recognition.stop();
483
+ } catch {
484
+ }
485
+ this.recognition = null;
486
+ }
487
+ return this.setState("idle"), this.accumulatedTranscript;
488
+ }
489
+ /**
490
+ * Abort listening. Discards any accumulated transcript.
491
+ */
492
+ abort() {
493
+ if (this.intentionalStop = !0, this.clearSilenceTimer(), this.accumulatedTranscript = "", this.recognition) {
494
+ try {
495
+ this.recognition.abort();
496
+ } catch {
497
+ }
498
+ this.recognition = null;
499
+ }
500
+ this.setState("idle");
501
+ }
502
+ /** Destroy the instance and release resources. */
503
+ destroy() {
504
+ this.abort();
505
+ }
506
+ setState(e) {
507
+ this._state !== e && (this._state = e, this.callbacks.onStateChange?.(e));
508
+ }
509
+ startSilenceTimer() {
510
+ this.clearSilenceTimer(), this.silenceTimer = setTimeout(() => {
511
+ const e = this.stop();
512
+ e.trim() && this.callbacks.onAutoSubmit?.(e.trim());
513
+ }, this.silenceTimeoutMs);
514
+ }
515
+ clearSilenceTimer() {
516
+ this.silenceTimer !== null && (clearTimeout(this.silenceTimer), this.silenceTimer = null);
517
+ }
518
+ }
519
+ function It(o) {
520
+ switch (o) {
521
+ case "not-allowed":
522
+ return "not-allowed";
523
+ case "no-speech":
524
+ return "no-speech";
525
+ case "audio-capture":
526
+ return "no-microphone";
527
+ case "network":
528
+ return "network";
529
+ case "aborted":
530
+ return "aborted";
531
+ default:
532
+ return "unknown";
533
+ }
534
+ }
535
+ function Lt(o) {
536
+ const e = document.createElement("div");
537
+ e.className = "gengage-chat-kvkk-banner", e.setAttribute("role", "alert");
538
+ const t = document.createElement("div");
539
+ t.className = "gengage-chat-kvkk-content", t.innerHTML = Z(o.htmlContent), e.appendChild(t);
540
+ const a = document.createElement("button");
541
+ return a.className = "gengage-chat-kvkk-dismiss", a.type = "button", a.setAttribute("aria-label", o.closeAriaLabel ?? "Kapat"), a.textContent = "×", a.addEventListener("click", o.onDismiss), e.appendChild(a), e;
542
+ }
543
+ class Nt {
544
+ constructor(e) {
545
+ this._el = document.createElement("div"), this._el.className = "gengage-chat-panel-topbar", this._backBtn = document.createElement("button"), this._backBtn.className = "gengage-chat-panel-topbar-back", this._backBtn.type = "button", this._backBtn.disabled = !0, this._backBtn.setAttribute("aria-label", "Back"), this._backBtn.textContent = "←", this._backBtn.addEventListener("click", () => e.onBack()), this._titleEl = document.createElement("span"), this._titleEl.className = "gengage-chat-panel-topbar-title", this._forwardBtn = document.createElement("button"), this._forwardBtn.className = "gengage-chat-panel-topbar-forward", this._forwardBtn.type = "button", this._forwardBtn.disabled = !0, this._forwardBtn.setAttribute("aria-label", "Forward"), this._forwardBtn.textContent = "→", this._forwardBtn.addEventListener("click", () => e.onForward()), this._el.appendChild(this._backBtn), this._el.appendChild(this._titleEl), this._el.appendChild(this._forwardBtn);
546
+ }
547
+ update(e, t, a) {
548
+ this._backBtn.disabled = !e, this._forwardBtn.disabled = !t, this._titleEl.textContent = a;
549
+ }
550
+ getElement() {
551
+ return this._el;
552
+ }
553
+ }
554
+ class At {
555
+ constructor(e) {
556
+ this._onThumbnailClick = e.onThumbnailClick, this._el = document.createElement("div"), this._el.className = "gengage-chat-thumbnails-column", this._el.style.display = "none";
557
+ }
558
+ getElement() {
559
+ return this._el;
560
+ }
561
+ setEntries(e) {
562
+ const t = /* @__PURE__ */ new Set(), a = [];
563
+ for (const n of e)
564
+ t.has(n.sku) || (t.add(n.sku), a.push(n));
565
+ this._el.innerHTML = "";
566
+ for (const n of a) {
567
+ const i = document.createElement("button");
568
+ if (i.type = "button", i.className = "gengage-chat-thumbnail-btn", i.title = n.sku, K(n.imageUrl)) {
569
+ const r = document.createElement("img");
570
+ r.className = "gengage-chat-thumbnail-img", r.src = n.imageUrl, r.alt = n.sku, r.width = 40, r.height = 40, i.appendChild(r);
571
+ }
572
+ i.addEventListener("click", () => {
573
+ this._onThumbnailClick(n.threadId);
574
+ }), this._el.appendChild(i);
575
+ }
576
+ }
577
+ show() {
578
+ this._el.style.display = "";
579
+ }
580
+ hide() {
581
+ this._el.style.display = "none";
582
+ }
583
+ }
584
+ const de = {
585
+ search: '<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="6.5" cy="6.5" r="5" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="10" y1="10" x2="15" y2="15" stroke="currentColor" stroke-width="1.5"/></svg>',
586
+ review: '<svg viewBox="0 0 16 16" class="gengage-chat-icon"><polygon points="8,1 10,6 15,6 11,9 12.5,14 8,11 3.5,14 5,9 1,6 6,6" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',
587
+ info: '<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="8" y1="7" x2="8" y2="12" stroke="currentColor" stroke-width="1.5"/><circle cx="8" cy="4.5" r="0.8" fill="currentColor"/></svg>',
588
+ similar: '<svg viewBox="0 0 16 16" class="gengage-chat-icon"><rect x="1" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/><rect x="9" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>'
589
+ }, Pt = ce;
590
+ class Bt {
591
+ constructor(e, t) {
592
+ this._panelVisible = !1, this._panelCollapsed = !1, this._panelForceExpanded = !1, this._onPanelToggle = void 0, this._pendingAttachment = null, this._onAttachment = void 0, this._onRollback = void 0, this._onLinkClick = void 0, this._userScrolledUp = !1, this._scrollLockedUntil = 0, this._thinkingSteps = [], this._firstBotMessageIds = /* @__PURE__ */ new Set(), this._voiceInput = null, this._micBtn = null, this._voiceEnabled = !1, this._voiceLang = "tr-TR", this.i18n = { ...Pt, ...t.i18n }, this.onSend = t.onSend, t.onPanelToggle !== void 0 && (this._onPanelToggle = t.onPanelToggle), t.onAttachment !== void 0 && (this._onAttachment = t.onAttachment), t.onRollback !== void 0 && (this._onRollback = t.onRollback), t.onLinkClick !== void 0 && (this._onLinkClick = t.onLinkClick), t.voiceEnabled && (this._voiceEnabled = !0), t.voiceLang !== void 0 && (this._voiceLang = t.voiceLang), this.root = document.createElement("div"), this.root.className = "gengage-chat-drawer", this.root.setAttribute("role", "dialog"), this.root.setAttribute("aria-label", this.i18n.headerTitle ?? "Chat"), this.root.setAttribute("aria-modal", "true");
593
+ const a = document.createElement("div");
594
+ a.className = "gengage-chat-header";
595
+ const n = document.createElement("div");
596
+ if (n.className = "gengage-chat-header-left", t.headerAvatarUrl) {
597
+ const u = document.createElement("img");
598
+ u.className = "gengage-chat-header-avatar", u.src = t.headerAvatarUrl, u.alt = t.headerTitle ?? "Assistant", n.appendChild(u);
599
+ }
600
+ const i = document.createElement("div");
601
+ i.className = "gengage-chat-header-info";
602
+ const r = document.createElement("div");
603
+ r.className = "gengage-chat-header-title-row";
604
+ const s = document.createElement("span");
605
+ if (s.className = "gengage-chat-header-title", s.textContent = t.headerTitle ?? this.i18n.headerTitle ?? "Gengage Asistanı", r.appendChild(s), t.headerBadge) {
606
+ const u = document.createElement("span");
607
+ u.className = "gengage-chat-header-badge", u.textContent = t.headerBadge, r.appendChild(u);
608
+ }
609
+ i.appendChild(r);
610
+ const l = document.createElement("a");
611
+ l.className = "gengage-chat-header-powered", l.href = "https://gengage.ai/", l.target = "_blank", l.rel = "noopener noreferrer", l.innerHTML = '<svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1a7 7 0 110 14A7 7 0 018 1zm0 1.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"/></svg>Powered by Gengage', i.appendChild(l), n.appendChild(i), a.appendChild(n);
612
+ const g = document.createElement("div");
613
+ if (g.className = "gengage-chat-header-right", t.headerCartUrl) {
614
+ const u = document.createElement("a");
615
+ u.className = "gengage-chat-header-btn", u.href = t.headerCartUrl, u.target = "_blank", u.rel = "noopener noreferrer", u.setAttribute("aria-label", "Sepetim"), u.innerHTML = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg>', g.appendChild(u);
616
+ }
617
+ if (t.headerFavoritesToggle) {
618
+ const u = document.createElement("button");
619
+ u.className = "gengage-chat-header-btn", u.type = "button", u.setAttribute("aria-label", "Favorilerim"), u.innerHTML = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>', u.addEventListener("click", () => t.onFavoritesClick?.()), g.appendChild(u);
620
+ }
621
+ const c = document.createElement("button");
622
+ c.className = "gengage-chat-close", c.type = "button", c.setAttribute("aria-label", this.i18n.closeButton), c.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>', c.addEventListener("click", t.onClose), g.appendChild(c), a.appendChild(g);
623
+ const h = document.createElement("div");
624
+ h.className = "gengage-chat-body", this._panelEl = document.createElement("div"), this._panelEl.className = "gengage-chat-panel", this._panelTopBar = new Nt({
625
+ onBack: () => t.onPanelBack?.(),
626
+ onForward: () => t.onPanelForward?.()
627
+ }), this._panelEl.appendChild(this._panelTopBar.getElement()), h.appendChild(this._panelEl), this._dividerEl = document.createElement("div"), this._dividerEl.className = "gengage-chat-panel-divider gengage-chat-panel-divider--hidden", this._dividerEl.setAttribute("role", "separator"), this._dividerEl.setAttribute("aria-label", "Toggle panel");
628
+ const m = document.createElement("button");
629
+ m.className = "gengage-chat-panel-divider-toggle", m.type = "button", m.setAttribute("aria-label", "Toggle panel"), m.textContent = "»", m.addEventListener("click", () => {
630
+ this.togglePanel(), this._onPanelToggle?.();
631
+ }), this._dividerEl.appendChild(m), h.appendChild(this._dividerEl);
632
+ const d = document.createElement("div");
633
+ d.className = "gengage-chat-conversation", d.appendChild(a), this._kvkkSlot = document.createElement("div"), this._kvkkSlot.className = "gengage-chat-kvkk-slot", d.appendChild(this._kvkkSlot), this.messagesEl = document.createElement("div"), this.messagesEl.className = "gengage-chat-messages", this.messagesEl.setAttribute("role", "log"), this.messagesEl.setAttribute("aria-live", "polite"), this.messagesEl.setAttribute("aria-label", "Chat messages");
634
+ let v = !1;
635
+ this.messagesEl.addEventListener(
636
+ "scroll",
637
+ () => {
638
+ v || (v = !0, requestAnimationFrame(() => {
639
+ v = !1;
640
+ const { scrollTop: u, scrollHeight: f, clientHeight: C } = this.messagesEl;
641
+ this._userScrolledUp = f - u - C > 10;
642
+ }));
643
+ },
644
+ { passive: !0 }
645
+ ), d.appendChild(this.messagesEl), this._thumbnailsColumn = new At({
646
+ onThumbnailClick: (u) => t.onThumbnailClick?.(u)
647
+ }), this._panelEl.appendChild(this._thumbnailsColumn.getElement()), this._pillsEl = document.createElement("div"), this._pillsEl.className = "gengage-chat-pills", this._pillsEl.setAttribute("role", "toolbar"), this._pillsEl.setAttribute("aria-label", "Suggestions"), this._pillsEl.style.display = "none";
648
+ const w = document.createElement("div");
649
+ w.className = "gengage-chat-pills-scroll", this._pillsEl.appendChild(w);
650
+ const b = document.createElement("button");
651
+ b.className = "gengage-chat-pills-arrow", b.type = "button", b.setAttribute("aria-label", "More suggestions"), b.textContent = "›", b.addEventListener("click", () => {
652
+ w.scrollBy({ left: 150, behavior: "smooth" });
653
+ }), this._pillsEl.appendChild(b);
654
+ let N = !1;
655
+ w.addEventListener(
656
+ "scroll",
657
+ () => {
658
+ N || (N = !0, requestAnimationFrame(() => {
659
+ N = !1;
660
+ const u = w.scrollLeft + w.clientWidth >= w.scrollWidth - 4;
661
+ b.style.display = u ? "none" : "";
662
+ }));
663
+ },
664
+ { passive: !0 }
665
+ ), d.appendChild(this._pillsEl), this._inputChipsEl = document.createElement("div"), this._inputChipsEl.className = "gengage-chat-input-chips", this._inputChipsEl.style.display = "none", d.appendChild(this._inputChipsEl);
666
+ const I = document.createElement("div");
667
+ I.className = "gengage-chat-input-area", this.inputEl = document.createElement("textarea"), this.inputEl.className = "gengage-chat-input", this.inputEl.rows = 1, this.inputEl.placeholder = this.i18n.inputPlaceholder, this.inputEl.addEventListener("input", () => {
668
+ requestAnimationFrame(() => {
669
+ this.inputEl.style.height = "auto", this.inputEl.style.height = `${Math.min(this.inputEl.scrollHeight, 120)}px`;
670
+ });
671
+ }), this.inputEl.addEventListener("keydown", (u) => {
672
+ u.key === "Enter" && (window.innerWidth < 768 || !u.shiftKey) && (u.preventDefault(), this._submit());
673
+ }), this.inputEl.addEventListener("paste", (u) => {
674
+ const f = u.clipboardData?.files[0];
675
+ f && f.type.startsWith("image/") && (u.preventDefault(), this._onAttachment ? this._onAttachment(f) : this.stageAttachment(f));
676
+ }), this._fileInput = document.createElement("input"), this._fileInput.type = "file", this._fileInput.accept = "image/jpeg,image/png,image/webp", this._fileInput.style.display = "none", this._fileInput.addEventListener("change", () => {
677
+ const u = this._fileInput.files?.[0];
678
+ u && (this._onAttachment ? this._onAttachment(u) : this.stageAttachment(u)), this._fileInput.value = "";
679
+ });
680
+ const p = document.createElement("button");
681
+ p.className = "gengage-chat-attach-btn", p.type = "button", p.setAttribute("aria-label", this.i18n.attachImageButton), p.innerHTML = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>', p.addEventListener("click", () => this._fileInput.click()), this._previewStrip = document.createElement("div"), this._previewStrip.className = "gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden";
682
+ const y = document.createElement("img");
683
+ y.className = "gengage-chat-attachment-preview-thumb", y.alt = "", this._previewName = document.createElement("span"), this._previewName.className = "gengage-chat-attachment-name";
684
+ const _ = document.createElement("button");
685
+ _.className = "gengage-chat-attachment-remove", _.type = "button", _.setAttribute("aria-label", this.i18n.removeAttachmentButton), _.textContent = "×", _.addEventListener("click", () => this.clearAttachment()), this._previewStrip.appendChild(y), this._previewStrip.appendChild(this._previewName), this._previewStrip.appendChild(_), this.sendBtn = document.createElement("button"), this.sendBtn.className = "gengage-chat-send", this.sendBtn.type = "button", this.sendBtn.setAttribute("aria-label", this.i18n.sendButton), this.sendBtn.innerHTML = '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>', this.sendBtn.addEventListener("click", () => this._submit()), I.addEventListener("dragover", (u) => {
686
+ u.preventDefault(), I.classList.add("gengage-chat-input-area--dragover");
687
+ }), I.addEventListener("dragleave", () => {
688
+ I.classList.remove("gengage-chat-input-area--dragover");
689
+ }), I.addEventListener("drop", (u) => {
690
+ u.preventDefault(), I.classList.remove("gengage-chat-input-area--dragover");
691
+ const f = u.dataTransfer?.files[0];
692
+ f && (this._onAttachment ? this._onAttachment(f) : this.stageAttachment(f));
693
+ });
694
+ const k = document.createElement("div");
695
+ k.className = "gengage-chat-input-pill", k.appendChild(p), k.appendChild(this.inputEl), this._voiceEnabled && St() && (this._micBtn = document.createElement("button"), this._micBtn.className = "gengage-chat-mic-btn", this._micBtn.type = "button", this._micBtn.setAttribute("aria-label", this.i18n.voiceButton), this._micBtn.innerHTML = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>', this._micBtn.addEventListener("click", () => this._toggleVoice()), k.appendChild(this._micBtn), this._voiceInput = new Tt(
696
+ {
697
+ onInterim: (u) => {
698
+ this.inputEl.value = u, this.inputEl.style.height = "auto", this.inputEl.style.height = `${Math.min(this.inputEl.scrollHeight, 120)}px`;
699
+ },
700
+ onFinal: (u) => {
701
+ this.inputEl.value = u;
702
+ },
703
+ onAutoSubmit: (u) => {
704
+ this.inputEl.value = u, this._micBtn?.classList.remove("gengage-chat-mic-btn--active"), this._submit();
705
+ },
706
+ onStateChange: (u) => {
707
+ u === "listening" ? this._micBtn?.classList.add("gengage-chat-mic-btn--active") : this._micBtn?.classList.remove("gengage-chat-mic-btn--active");
708
+ },
709
+ onError: (u, f) => {
710
+ this._micBtn?.classList.remove("gengage-chat-mic-btn--active");
711
+ }
712
+ },
713
+ { lang: this._voiceLang }
714
+ )), k.appendChild(this.sendBtn), I.appendChild(this._previewStrip), I.appendChild(this._fileInput), I.appendChild(k), d.appendChild(I), h.appendChild(d), this.root.appendChild(h);
715
+ const A = document.createElement("div");
716
+ A.className = "gengage-chat-footer", A.textContent = this.i18n.poweredBy, this.root.appendChild(A), this.root.addEventListener("keydown", (u) => {
717
+ u.key === "Escape" && t.onClose();
718
+ }), this._trapFocus(), e.appendChild(this.root);
719
+ }
720
+ addMessage(e) {
721
+ const t = document.createElement("div");
722
+ if (t.className = `gengage-chat-bubble gengage-chat-bubble--${e.role}`, t.dataset.messageId = e.id, e.threadId && (t.dataset.threadId = e.threadId), this._firstBotMessageIds.has(e.id) && t.classList.add("gengage-chat-bubble--first"), e.attachment) {
723
+ const a = document.createElement("img");
724
+ a.className = "gengage-chat-attachment-thumb";
725
+ const n = URL.createObjectURL(e.attachment);
726
+ a.src = n, a.alt = e.attachment.name, a.addEventListener("load", () => URL.revokeObjectURL(n), { once: !0 }), a.addEventListener("error", () => URL.revokeObjectURL(n), { once: !0 }), t.insertBefore(a, t.firstChild);
727
+ }
728
+ if (e.content) {
729
+ const a = document.createElement("div");
730
+ if (a.className = "gengage-chat-bubble-text", e.role === "assistant") {
731
+ if (a.innerHTML = Z(e.content), this._onLinkClick) {
732
+ const n = a.querySelectorAll("a[href]");
733
+ for (const i of n)
734
+ i.addEventListener("click", (r) => {
735
+ r.preventDefault();
736
+ const s = i.getAttribute("href");
737
+ s && this._onLinkClick?.(s);
738
+ });
739
+ }
740
+ } else
741
+ a.textContent = e.content;
742
+ t.appendChild(a);
743
+ }
744
+ if (e.role === "user" && this._onRollback) {
745
+ const a = document.createElement("button");
746
+ a.className = "gengage-chat-rollback-btn", a.type = "button", a.setAttribute("aria-label", "Rollback to this message"), a.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg>', a.addEventListener("click", (n) => {
747
+ n.stopPropagation(), this._onRollback?.(e.id);
748
+ }), t.appendChild(a);
749
+ }
750
+ this.messagesEl.appendChild(t), this._scrollToBottom(e.role === "user");
751
+ }
752
+ showTypingIndicator(e) {
753
+ this.removeTypingIndicator();
754
+ const t = document.createElement("div");
755
+ if (t.className = "gengage-chat-typing", t.dataset.typing = "true", this._thinkingSteps.length > 0)
756
+ this._renderThinkingStepsInto(t);
757
+ else {
758
+ const a = document.createElement("div");
759
+ a.className = "gengage-chat-typing-dots";
760
+ for (let n = 0; n < 3; n++) a.appendChild(document.createElement("span"));
761
+ if (t.appendChild(a), e) {
762
+ const n = document.createElement("span");
763
+ n.className = "gengage-chat-typing-sparkle", n.textContent = "✨", t.appendChild(n);
764
+ const i = document.createElement("span");
765
+ i.className = "gengage-chat-typing-text", i.textContent = e, t.appendChild(i);
766
+ }
767
+ }
768
+ this.messagesEl.appendChild(t), this._scrollToBottom(!0);
769
+ }
770
+ /** Accumulate a new thinking step (shown as a checklist in the typing indicator). */
771
+ addThinkingStep(e) {
772
+ this._thinkingSteps.push(e), this._renderThinkingSteps();
773
+ }
774
+ removeTypingIndicator() {
775
+ this.messagesEl.querySelector(".gengage-chat-typing")?.remove(), this._thinkingSteps = [];
776
+ }
777
+ showError(e, t) {
778
+ const a = document.createElement("div");
779
+ a.className = "gengage-chat-error";
780
+ const n = document.createElement("span");
781
+ if (n.textContent = e ?? this.i18n.errorMessage, a.appendChild(n), t) {
782
+ const i = document.createElement("button");
783
+ i.className = "gengage-chat-error-retry", i.textContent = this.i18n.retryButton ?? "Retry", i.addEventListener("click", () => {
784
+ a.remove(), t();
785
+ }), a.appendChild(i);
786
+ }
787
+ this.messagesEl.appendChild(a), this._scrollToBottom(!0);
788
+ }
789
+ clearMessages() {
790
+ this.messagesEl.innerHTML = "";
791
+ }
792
+ /** Replace suggestion pills. Pass empty array to hide. */
793
+ setPills(e) {
794
+ const t = this._pillsEl.querySelector(".gengage-chat-pills-scroll");
795
+ if (!t) return;
796
+ for (; t.firstChild; ) t.removeChild(t.firstChild);
797
+ if (e.length === 0) {
798
+ this._pillsEl.style.display = "none";
799
+ return;
800
+ }
801
+ this._pillsEl.style.display = "";
802
+ for (const n of e) {
803
+ const i = document.createElement("button");
804
+ if (i.className = n.image ? "gengage-chat-pill gengage-chat-pill--rich" : "gengage-chat-pill", i.type = "button", n.icon) {
805
+ const s = de[n.icon];
806
+ if (s) {
807
+ const l = document.createElement("span");
808
+ l.className = "gengage-chat-pill-icon", l.innerHTML = s, i.appendChild(l);
809
+ }
810
+ }
811
+ if (n.image && K(n.image)) {
812
+ const s = document.createElement("img");
813
+ s.className = "gengage-chat-pill-img", s.src = n.image, s.alt = "", i.appendChild(s);
814
+ }
815
+ const r = document.createElement("span");
816
+ if (r.className = "gengage-chat-pill-text", r.textContent = n.label, i.appendChild(r), n.description) {
817
+ const s = document.createElement("span");
818
+ s.className = "gengage-chat-pill-desc", s.textContent = n.description, i.appendChild(s);
819
+ }
820
+ i.addEventListener("click", () => n.onAction()), t.appendChild(i);
821
+ }
822
+ const a = this._pillsEl.querySelector(".gengage-chat-pills-arrow");
823
+ a && requestAnimationFrame(() => {
824
+ a.style.display = t.scrollWidth > t.clientWidth ? "" : "none";
825
+ });
826
+ }
827
+ focusInput() {
828
+ this.inputEl.focus();
829
+ }
830
+ showKvkkBanner(e, t) {
831
+ this._kvkkSlot.innerHTML = "";
832
+ const a = Lt({ htmlContent: e, onDismiss: t });
833
+ this._kvkkSlot.appendChild(a);
834
+ }
835
+ hideKvkkBanner() {
836
+ this._kvkkSlot.innerHTML = "";
837
+ }
838
+ getElement() {
839
+ return this.root;
840
+ }
841
+ /** Stage a file attachment for sending. Shows preview. */
842
+ stageAttachment(e) {
843
+ this._pendingAttachment = e, this._previewName.textContent = e.name;
844
+ const t = this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");
845
+ t && (t.src && t.src.startsWith("blob:") && URL.revokeObjectURL(t.src), t.src = URL.createObjectURL(e)), this._previewStrip.classList.remove("gengage-chat-attachment-preview--hidden");
846
+ }
847
+ /** Remove the staged attachment and hide preview. */
848
+ clearAttachment() {
849
+ const e = this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");
850
+ e?.src && (URL.revokeObjectURL(e.src), e.src = ""), this._pendingAttachment = null, this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden");
851
+ }
852
+ /** Get the currently staged attachment file, or null. */
853
+ getPendingAttachment() {
854
+ return this._pendingAttachment;
855
+ }
856
+ /** Replace panel content and show the panel. */
857
+ setPanelContent(e) {
858
+ this._panelEl.innerHTML = "", this._panelEl.appendChild(this._panelTopBar.getElement()), this._panelEl.appendChild(e), this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"), this._panelVisible || (this._panelVisible = !0, this._panelEl.classList.add("gengage-chat-panel--visible"), this.root.classList.add("gengage-chat-drawer--with-panel")), this._panelCollapsed && this._panelEl.classList.add("gengage-chat-panel--collapsed");
859
+ }
860
+ /** Append content to the panel without replacing existing content. */
861
+ appendPanelContent(e) {
862
+ this._panelEl.appendChild(e), this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"), this._panelVisible || (this._panelVisible = !0, this._panelEl.classList.add("gengage-chat-panel--visible"), this.root.classList.add("gengage-chat-drawer--with-panel"));
863
+ }
864
+ /** Return the panel element's content child (after topbar), or null. */
865
+ getPanelContentElement() {
866
+ const e = this._panelEl.children;
867
+ for (let t = 0; t < e.length; t++) {
868
+ const a = e[t];
869
+ if (!(a.classList.contains("gengage-chat-panel-topbar") || a.classList.contains("gengage-chat-thumbnails-column")))
870
+ return a;
871
+ }
872
+ return null;
873
+ }
874
+ /** Whether the panel is currently visible and has rendered content (beyond topbar + thumbnails column). */
875
+ hasPanelContent() {
876
+ return this._panelVisible && this._panelEl.childElementCount > 2;
877
+ }
878
+ /** Whether panel currently shows loading skeleton blocks. */
879
+ isPanelLoading() {
880
+ return this._panelEl.querySelector(".gengage-chat-panel-skeleton") !== null;
881
+ }
882
+ /** Show loading skeleton in the panel. Variant depends on contentType hint. */
883
+ showPanelLoading(e) {
884
+ this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"), this._panelEl.innerHTML = "", this._panelEl.appendChild(this._panelTopBar.getElement());
885
+ const t = document.createElement("div");
886
+ switch (t.className = "gengage-chat-panel-skeleton", e) {
887
+ case "productDetails": {
888
+ const a = document.createElement("div");
889
+ a.className = "gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image", t.appendChild(a);
890
+ for (let n = 0; n < 3; n++) {
891
+ const i = document.createElement("div");
892
+ i.className = "gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--text", t.appendChild(i);
893
+ }
894
+ break;
895
+ }
896
+ case "productList":
897
+ case "groupList": {
898
+ const a = document.createElement("div");
899
+ a.className = "gengage-chat-panel-skeleton-grid";
900
+ for (let n = 0; n < 6; n++) {
901
+ const i = document.createElement("div");
902
+ i.className = "gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--card", a.appendChild(i);
903
+ }
904
+ t.appendChild(a);
905
+ break;
906
+ }
907
+ case "comparisonTable": {
908
+ for (let a = 0; a < 4; a++) {
909
+ const n = document.createElement("div");
910
+ n.className = "gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--row", t.appendChild(n);
911
+ }
912
+ break;
913
+ }
914
+ default: {
915
+ for (let a = 0; a < 3; a++) {
916
+ const n = document.createElement("div");
917
+ n.className = "gengage-chat-panel-skeleton-block", t.appendChild(n);
918
+ }
919
+ break;
920
+ }
921
+ }
922
+ this._panelEl.appendChild(t), this._panelVisible || (this._panelVisible = !0, this._panelEl.classList.add("gengage-chat-panel--visible"), this.root.classList.add("gengage-chat-drawer--with-panel"));
923
+ }
924
+ /** Update the panel top bar navigation state. */
925
+ updatePanelTopBar(e, t, a) {
926
+ this._panelTopBar.update(e, t, a);
927
+ }
928
+ /**
929
+ * Hide the panel and clear its content. Always hides — even in force-expanded mode.
930
+ * Callers: _hideDrawer (stale panel cleanup), stream onDone (loading skeleton cleanup),
931
+ * thread navigation (no snapshot to restore). All require full hide.
932
+ */
933
+ clearPanel() {
934
+ this._panelEl.innerHTML = "", this._panelEl.appendChild(this._panelTopBar.getElement()), this._panelVisible = !1, this._panelCollapsed = !1, this._panelEl.classList.remove("gengage-chat-panel--visible", "gengage-chat-panel--collapsed"), this.root.classList.remove("gengage-chat-drawer--with-panel"), this._dividerEl.classList.add("gengage-chat-panel-divider--hidden");
935
+ }
936
+ /** Force the panel to stay expanded (panelMode: 'expanded'). Hides the divider toggle. */
937
+ setForceExpanded() {
938
+ this._panelForceExpanded = !0, this._panelCollapsed = !1, this._panelEl.classList.remove("gengage-chat-panel--collapsed"), this._panelVisible || (this._panelVisible = !0, this._panelEl.classList.add("gengage-chat-panel--visible"), this.root.classList.add("gengage-chat-drawer--with-panel")), this._dividerEl.classList.add("gengage-chat-panel-divider--hidden");
939
+ }
940
+ /** Toggle panel between collapsed and expanded. */
941
+ togglePanel() {
942
+ this._panelForceExpanded || this.setPanelCollapsed(!this._panelCollapsed);
943
+ }
944
+ /** Whether the panel is currently collapsed by the user. */
945
+ isPanelCollapsed() {
946
+ return this._panelCollapsed;
947
+ }
948
+ /** Programmatically set panel collapsed state. */
949
+ setPanelCollapsed(e) {
950
+ if (this._panelForceExpanded) return;
951
+ this._panelCollapsed = e, e ? this._panelEl.classList.add("gengage-chat-panel--collapsed") : this._panelEl.classList.remove("gengage-chat-panel--collapsed");
952
+ const t = this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");
953
+ t && (t.textContent = e ? "«" : "»");
954
+ }
955
+ /** Save panel collapsed state to sessionStorage. */
956
+ persistPanelState(e) {
957
+ try {
958
+ const t = `gengage:panel:${e}`;
959
+ this._panelCollapsed ? sessionStorage.setItem(t, "collapsed") : sessionStorage.removeItem(t);
960
+ } catch {
961
+ }
962
+ }
963
+ /** Restore panel collapsed state from sessionStorage. */
964
+ restorePanelState(e) {
965
+ try {
966
+ const t = `gengage:panel:${e}`;
967
+ sessionStorage.getItem(t) === "collapsed" && (this._panelCollapsed = !0);
968
+ } catch {
969
+ }
970
+ }
971
+ /** Re-render thinking steps inside the existing typing indicator container. */
972
+ _renderThinkingSteps() {
973
+ const e = this.messagesEl.querySelector('[data-typing="true"]');
974
+ if (!e) {
975
+ this.showTypingIndicator();
976
+ return;
977
+ }
978
+ e.innerHTML = "", this._renderThinkingStepsInto(e), this._scrollToBottom(!1);
979
+ }
980
+ /** Render the accumulated thinking-step checklist into a container element. */
981
+ _renderThinkingStepsInto(e) {
982
+ const t = document.createElement("div");
983
+ t.className = "gengage-chat-thinking-steps";
984
+ for (let a = 0; a < this._thinkingSteps.length; a++) {
985
+ const n = document.createElement("div");
986
+ n.className = "gengage-chat-thinking-step";
987
+ const i = document.createElement("span");
988
+ i.className = "gengage-chat-thinking-step-marker", a < this._thinkingSteps.length - 1 ? (i.textContent = "✓", i.classList.add("gengage-chat-thinking-step-marker--done")) : (i.textContent = "●", i.classList.add("gengage-chat-thinking-step-marker--active")), n.appendChild(i);
989
+ const r = document.createElement("span");
990
+ r.className = "gengage-chat-thinking-step-text", r.textContent = this._thinkingSteps[a], n.appendChild(r), t.appendChild(n);
991
+ }
992
+ e.appendChild(t);
993
+ }
994
+ _trapFocus() {
995
+ this.root.addEventListener("keydown", (e) => {
996
+ if (e.key !== "Tab") return;
997
+ const t = this.root.querySelectorAll(
998
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
999
+ );
1000
+ if (t.length === 0) return;
1001
+ const a = t[0], n = t[t.length - 1];
1002
+ if (!a || !n) return;
1003
+ const r = this.root.getRootNode().activeElement ?? document.activeElement;
1004
+ e.shiftKey ? r === a && (e.preventDefault(), n.focus()) : r === n && (e.preventDefault(), a.focus());
1005
+ });
1006
+ }
1007
+ _submit() {
1008
+ const e = this.inputEl.value.trim(), t = this._pendingAttachment;
1009
+ !e && !t || (this.onSend(e, t ?? void 0), this.inputEl.value = "", this.inputEl.style.height = "auto", this.clearAttachment());
1010
+ }
1011
+ _toggleVoice() {
1012
+ if (this._voiceInput)
1013
+ if (this._voiceInput.state === "listening") {
1014
+ const e = this._voiceInput.stop();
1015
+ e.trim() && (this.inputEl.value = e, this._submit());
1016
+ } else
1017
+ this.inputEl.value = "", this._voiceInput.start();
1018
+ }
1019
+ /** Lock auto-scroll for 500ms after session history restore to prevent visual jump. */
1020
+ lockScrollForRestore() {
1021
+ this._scrollLockedUntil = Date.now() + 500;
1022
+ }
1023
+ /** Scroll to bottom only if user hasn't scrolled up. Force=true always scrolls. */
1024
+ _scrollToBottom(e = !1) {
1025
+ !e && this._userScrolledUp || !e && Date.now() < this._scrollLockedUntil || requestAnimationFrame(() => {
1026
+ this.messagesEl.scrollTop = this.messagesEl.scrollHeight, this._userScrolledUp = !1;
1027
+ });
1028
+ }
1029
+ /** Public method for typewriter ticks — scrolls only if user is near bottom. */
1030
+ scrollToBottomIfNeeded() {
1031
+ this._scrollToBottom(!1);
1032
+ }
1033
+ /** Mark a message as the first bot message in its thread (for special styling). */
1034
+ markFirstBotMessage(e) {
1035
+ this._firstBotMessageIds.add(e);
1036
+ const t = this.messagesEl.querySelector(`[data-message-id="${CSS.escape(e)}"]`);
1037
+ t && t.classList.add("gengage-chat-bubble--first");
1038
+ }
1039
+ /** Scroll to the first message of the last thread (for restore targeting). */
1040
+ scrollToLastThread() {
1041
+ const e = this.messagesEl.querySelectorAll("[data-thread-id]");
1042
+ if (e.length === 0) {
1043
+ this._scrollToBottom(!0);
1044
+ return;
1045
+ }
1046
+ const t = e[e.length - 1].getAttribute("data-thread-id");
1047
+ if (!t) {
1048
+ this._scrollToBottom(!0);
1049
+ return;
1050
+ }
1051
+ const a = this.messagesEl.querySelector(`[data-thread-id="${CSS.escape(t)}"]`);
1052
+ a ? requestAnimationFrame(() => {
1053
+ a.scrollIntoView({ block: "start", behavior: "auto" }), this._userScrolledUp = !1;
1054
+ }) : this._scrollToBottom(!0);
1055
+ }
1056
+ /** Set compact input-area chips (search/info/review shortcuts above input). */
1057
+ setInputAreaChips(e) {
1058
+ if (this._inputChipsEl.innerHTML = "", e.length === 0) {
1059
+ this._inputChipsEl.style.display = "none";
1060
+ return;
1061
+ }
1062
+ this._inputChipsEl.style.display = "";
1063
+ for (const t of e) {
1064
+ const a = document.createElement("button");
1065
+ if (a.className = "gengage-chat-input-chip", a.type = "button", t.icon) {
1066
+ const i = de[t.icon];
1067
+ if (i) {
1068
+ const r = document.createElement("span");
1069
+ r.className = "gengage-chat-input-chip-icon", r.innerHTML = i, a.appendChild(r);
1070
+ }
1071
+ }
1072
+ const n = document.createElement("span");
1073
+ n.textContent = t.label, a.appendChild(n), a.addEventListener("click", () => t.onAction()), this._inputChipsEl.appendChild(a);
1074
+ }
1075
+ }
1076
+ /** Clear input-area chips. */
1077
+ clearInputAreaChips() {
1078
+ this._inputChipsEl.innerHTML = "", this._inputChipsEl.style.display = "none";
1079
+ }
1080
+ setThumbnails(e) {
1081
+ this._thumbnailsColumn.setEntries(e), e.length > 0 ? this._thumbnailsColumn.show() : this._thumbnailsColumn.hide();
1082
+ }
1083
+ hideThumbnails() {
1084
+ this._thumbnailsColumn.hide();
1085
+ }
1086
+ }
1087
+ const Mt = `<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1088
+ <rect x="3" y="7" width="18" height="13" rx="3" fill="currentColor" opacity="0.15"/>
1089
+ <rect x="3" y="7" width="18" height="13" rx="3" stroke="currentColor" stroke-width="1.5"/>
1090
+ <circle cx="9" cy="13" r="1.5" fill="currentColor"/>
1091
+ <circle cx="15" cy="13" r="1.5" fill="currentColor"/>
1092
+ <path d="M9.5 17C10.3 17.6 11.1 18 12 18C12.9 18 13.7 17.6 14.5 17" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
1093
+ <path d="M12 7V4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
1094
+ <circle cx="12" cy="3" r="1" fill="currentColor"/>
1095
+ <path d="M1 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
1096
+ <path d="M23 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
1097
+ </svg>`;
1098
+ function zt(o) {
1099
+ const e = document.createElement("div");
1100
+ e.className = "gengage-chat-launcher-container";
1101
+ const t = document.createElement("div");
1102
+ t.className = "gengage-chat-launcher-content-area", e.appendChild(t);
1103
+ const a = document.createElement("button");
1104
+ if (a.className = "gengage-chat-launcher", a.type = "button", a.setAttribute("aria-label", o.ariaLabel ?? "Open chat"), a.innerHTML = o.svgMarkup ?? Mt, o.tooltip !== void 0) {
1105
+ const i = document.createElement("span");
1106
+ i.className = "gengage-chat-launcher-tooltip", i.textContent = o.tooltip, a.appendChild(i);
1107
+ }
1108
+ o.hideMobile && (e.dataset.hideMobile = "1"), o.mobileBreakpoint !== void 0 && (e.dataset.mobileBreakpoint = String(o.mobileBreakpoint)), a.addEventListener("click", o.onClick), e.appendChild(a);
1109
+ const n = document.createElement("div");
1110
+ return n.className = "gengage-chat-launcher-content-area-bottom", e.appendChild(n), { container: e, button: a, contentArea: t, contentAreaBottom: n };
1111
+ }
1112
+ function Dt(o) {
1113
+ const e = document.createElement("div");
1114
+ e.className = "gengage-chat-proactive";
1115
+ const t = document.createElement("p");
1116
+ t.className = "gengage-chat-proactive-message", t.textContent = o.message, e.appendChild(t);
1117
+ const a = document.createElement("div");
1118
+ a.className = "gengage-chat-proactive-actions";
1119
+ let n = null;
1120
+ function i() {
1121
+ n !== null && clearTimeout(n), e.remove();
1122
+ }
1123
+ if (o.actionButtons && o.actionButtons.length > 0)
1124
+ for (const l of o.actionButtons) {
1125
+ const g = document.createElement("button");
1126
+ g.className = "gengage-chat-proactive-accept", g.type = "button", g.textContent = l.title, g.addEventListener("click", () => {
1127
+ i(), l.onSelect();
1128
+ }), a.appendChild(g);
1129
+ }
1130
+ else {
1131
+ const l = document.createElement("button");
1132
+ l.className = "gengage-chat-proactive-accept", l.type = "button", l.textContent = o.acceptLabel ?? "Sohbete Başla", l.addEventListener("click", () => {
1133
+ i(), o.onAccept();
1134
+ }), a.appendChild(l);
1135
+ }
1136
+ const r = document.createElement("button");
1137
+ r.className = "gengage-chat-proactive-dismiss", r.type = "button", r.textContent = "×", r.setAttribute("aria-label", o.closeAriaLabel ?? "Kapat"), r.addEventListener("click", () => {
1138
+ i(), o.onDismiss();
1139
+ }), e.appendChild(r), e.appendChild(a);
1140
+ const s = o.autoDismissMs ?? 15e3;
1141
+ return s > 0 && (n = setTimeout(() => {
1142
+ e.parentElement && (e.remove(), o.onDismiss());
1143
+ }, s)), requestAnimationFrame(() => e.classList.add("gengage-chat-proactive--visible")), e;
1144
+ }
1145
+ class Rt {
1146
+ constructor(e = {}) {
1147
+ this._idleTimer = null, this._maxScrollDepth = 0, this._lastReportedDepth = 0, this._listeners = [], this._destroyed = !1, this._idleThreshold = e.idleThresholdMs ?? 3e4, this._scrollGranularity = e.scrollGranularity ?? 25, this._onActivity = e.onActivity ?? null, this._setup();
1148
+ }
1149
+ _setup() {
1150
+ this._emit({ type: "pageview", timestamp: Date.now() }), this._resetIdleTimer(), this._listen(window, "scroll", () => this._onScroll(), { passive: !0 }), this._listen(window, "mousemove", () => this._resetIdleTimer(), { passive: !0 }), this._listen(window, "keydown", () => this._resetIdleTimer(), { passive: !0 }), this._listen(window, "touchstart", () => this._resetIdleTimer(), { passive: !0 }), this._listen(document, "visibilitychange", () => this._onVisibility());
1151
+ }
1152
+ _listen(e, t, a, n) {
1153
+ e.addEventListener(t, a, n), this._listeners.push([e, t, a]);
1154
+ }
1155
+ _resetIdleTimer() {
1156
+ this._idleTimer && clearTimeout(this._idleTimer), this._idleTimer = setTimeout(() => {
1157
+ this._emit({ type: "idle", timestamp: Date.now() });
1158
+ }, this._idleThreshold);
1159
+ }
1160
+ _onScroll() {
1161
+ const e = window.scrollY || document.documentElement.scrollTop, t = Math.max(document.documentElement.scrollHeight - window.innerHeight, 1), a = Math.min(100, Math.round(e / t * 100));
1162
+ a > this._maxScrollDepth && (this._maxScrollDepth = a);
1163
+ const n = Math.floor(a / this._scrollGranularity) * this._scrollGranularity;
1164
+ n > this._lastReportedDepth && (this._lastReportedDepth = n, this._emit({
1165
+ type: "scroll",
1166
+ timestamp: Date.now(),
1167
+ data: { depth: n }
1168
+ })), this._resetIdleTimer();
1169
+ }
1170
+ _onVisibility() {
1171
+ document.hidden ? (this._emit({ type: "blur", timestamp: Date.now() }), this._idleTimer && clearTimeout(this._idleTimer)) : (this._emit({ type: "focus", timestamp: Date.now() }), this._resetIdleTimer());
1172
+ }
1173
+ _emit(e) {
1174
+ this._destroyed || this._onActivity?.(e);
1175
+ }
1176
+ /** Current max scroll depth reached (0-100). */
1177
+ get maxScrollDepth() {
1178
+ return this._maxScrollDepth;
1179
+ }
1180
+ destroy() {
1181
+ this._destroyed = !0, this._idleTimer && clearTimeout(this._idleTimer);
1182
+ for (const [e, t, a] of this._listeners)
1183
+ e.removeEventListener(t, a);
1184
+ this._listeners = [];
1185
+ }
1186
+ }
1187
+ const Ut = /* @__PURE__ */ new Set([
1188
+ "audio/ogg",
1189
+ "audio/mpeg",
1190
+ "audio/mp3",
1191
+ "audio/wav",
1192
+ "audio/webm",
1193
+ "audio/aac",
1194
+ "audio/mp4"
1195
+ ]);
1196
+ function Ht(o, e = "audio/ogg") {
1197
+ const t = e.split(";")[0].trim();
1198
+ if (!Ut.has(t)) return null;
1199
+ try {
1200
+ const a = new Audio(`data:${e};base64,${o}`);
1201
+ return a.play().catch(() => {
1202
+ }), {
1203
+ stop: () => {
1204
+ a.pause(), a.currentTime = 0;
1205
+ }
1206
+ };
1207
+ } catch {
1208
+ return null;
1209
+ }
1210
+ }
1211
+ class Ft {
1212
+ constructor(e) {
1213
+ this._timer = null, this._destroyed = !1, this._abortController = null, this._sessionStart = Date.now(), this._lastActivity = Date.now(), this._searchesCount = 0, this._actionsCount = 0, this._triggerFireCounts = {}, this._options = e;
1214
+ const t = Be(e.middlewareUrl);
1215
+ this._endpoint = `${t}/v2/heartbeat`;
1216
+ }
1217
+ start() {
1218
+ this._timer || this._destroyed || this._scheduleNext();
1219
+ }
1220
+ /** Schedule the next poll after the current one finishes (prevents overlapping polls). */
1221
+ _scheduleNext() {
1222
+ this._destroyed || (this._timer = setTimeout(() => {
1223
+ this._poll().finally(() => this._scheduleNext());
1224
+ }, this._options.intervalMs));
1225
+ }
1226
+ stop() {
1227
+ this._timer && (clearTimeout(this._timer), this._timer = null);
1228
+ }
1229
+ /** Call when the user performs an action (search, click, etc.). */
1230
+ recordAction() {
1231
+ this._actionsCount++, this._lastActivity = Date.now();
1232
+ }
1233
+ /** Call when the user performs a search. */
1234
+ recordSearch() {
1235
+ this._searchesCount++, this._lastActivity = Date.now();
1236
+ }
1237
+ /** Call on any user interaction to reset idle timer. */
1238
+ recordActivity() {
1239
+ this._lastActivity = Date.now();
1240
+ }
1241
+ destroy() {
1242
+ this._destroyed = !0, this._abortController?.abort(), this._abortController = null, this.stop();
1243
+ }
1244
+ async _poll() {
1245
+ if (this._destroyed) return;
1246
+ const e = Date.now(), t = {
1247
+ account_id: this._options.accountId,
1248
+ thread_id: this._options.sessionId,
1249
+ output_language: this._options.locale.toUpperCase(),
1250
+ idle_seconds: (e - this._lastActivity) / 1e3,
1251
+ page_type: this._options.getPageType(),
1252
+ current_sku: this._options.getCurrentSku(),
1253
+ cart_item_count: 0,
1254
+ searches_count: this._searchesCount,
1255
+ actions_count: this._actionsCount,
1256
+ session_duration_seconds: (e - this._sessionStart) / 1e3,
1257
+ trigger_fire_counts: { ...this._triggerFireCounts }
1258
+ };
1259
+ this._abortController = new AbortController();
1260
+ try {
1261
+ const a = await fetch(this._endpoint, {
1262
+ method: "POST",
1263
+ headers: { "Content-Type": "application/json" },
1264
+ body: JSON.stringify(t),
1265
+ signal: this._abortController.signal
1266
+ });
1267
+ if (this._destroyed || !a.ok) return;
1268
+ const n = await a.json();
1269
+ if (this._destroyed) return;
1270
+ n.action === "message" && n.message && (n.trigger_type && (this._triggerFireCounts[n.trigger_type] = (this._triggerFireCounts[n.trigger_type] ?? 0) + 1), this._options.onMessage(n));
1271
+ } catch {
1272
+ }
1273
+ }
1274
+ }
1275
+ const Ot = {
1276
+ screen_size: "Ekran Boyutu",
1277
+ weight: "Ağırlık",
1278
+ battery_capacity: "Batarya Kapasitesi",
1279
+ battery_life: "Batarya Ömrü",
1280
+ storage: "Depolama",
1281
+ memory: "Bellek",
1282
+ ram: "RAM",
1283
+ processor: "İşlemci",
1284
+ camera: "Kamera",
1285
+ resolution: "Çözünürlük",
1286
+ display_type: "Ekran Tipi",
1287
+ refresh_rate: "Yenileme Hızı",
1288
+ color: "Renk",
1289
+ material: "Malzeme",
1290
+ dimensions: "Boyutlar",
1291
+ warranty: "Garanti",
1292
+ connectivity: "Bağlantı",
1293
+ water_resistance: "Su Dayanıklılığı",
1294
+ operating_system: "İşletim Sistemi",
1295
+ brand: "Marka",
1296
+ model: "Model",
1297
+ price: "Fiyat",
1298
+ energy_class: "Enerji Sınıfı",
1299
+ noise_level: "Gürültü Seviyesi",
1300
+ capacity: "Kapasite",
1301
+ power: "Güç",
1302
+ voltage: "Voltaj",
1303
+ width: "Genişlik",
1304
+ height: "Yükseklik",
1305
+ depth: "Derinlik"
1306
+ };
1307
+ function qt(o) {
1308
+ return Ot[o] ?? o.replace(/_/g, " ").replace(/^\w/, (e) => e.toUpperCase());
1309
+ }
1310
+ function jt(o) {
1311
+ const { recommended: e, products: t, attributes: a, highlights: n, specialCases: i, onProductClick: r, i18n: s } = o, l = document.createElement("div");
1312
+ l.className = "gengage-chat-comparison";
1313
+ const g = document.createElement("h3");
1314
+ if (g.className = "gengage-chat-comparison-heading", g.textContent = s?.comparisonHeading ?? "KARŞILAŞTIRMA SONUÇLARI", l.appendChild(g), e) {
1315
+ const c = document.createElement("div");
1316
+ c.className = "gengage-chat-comparison-recommended";
1317
+ const h = document.createElement("div");
1318
+ h.className = "gengage-chat-comparison-recommended-label", h.textContent = s?.recommendedChoiceLabel ?? "Önerilen Seçim", c.appendChild(h);
1319
+ const m = document.createElement("div");
1320
+ if (m.className = "gengage-chat-comparison-recommended-body", e.imageUrl && K(e.imageUrl)) {
1321
+ const b = document.createElement("img");
1322
+ b.src = e.imageUrl, b.alt = e.name, b.loading = "lazy", b.addEventListener(
1323
+ "error",
1324
+ () => {
1325
+ b.style.display = "none";
1326
+ },
1327
+ { once: !0 }
1328
+ ), m.appendChild(b);
1329
+ }
1330
+ const d = document.createElement("div");
1331
+ d.className = "gengage-chat-comparison-recommended-info";
1332
+ const v = document.createElement("div");
1333
+ v.className = "gengage-chat-comparison-recommended-title", v.textContent = e.name, d.appendChild(v);
1334
+ const w = document.createElement("div");
1335
+ if (w.className = "gengage-chat-comparison-recommended-price", w.textContent = e.price, d.appendChild(w), m.appendChild(d), m.addEventListener("click", () => {
1336
+ r(e.sku);
1337
+ }), m.style.cursor = "pointer", c.appendChild(m), n.length > 0) {
1338
+ const b = document.createElement("div");
1339
+ b.className = "gengage-chat-comparison-highlights";
1340
+ const N = document.createElement("div");
1341
+ N.className = "gengage-chat-comparison-highlights-label", N.textContent = s?.highlightsLabel ?? "Öne Çıkan Özellikler", b.appendChild(N);
1342
+ const I = document.createElement("ul");
1343
+ for (const p of n) {
1344
+ const y = document.createElement("li");
1345
+ y.textContent = p, I.appendChild(y);
1346
+ }
1347
+ b.appendChild(I), c.appendChild(b);
1348
+ }
1349
+ if (o.recommendedText) {
1350
+ const b = document.createElement("div");
1351
+ b.className = "gengage-chat-comparison-recommended-text", b.textContent = o.recommendedText, c.appendChild(b);
1352
+ }
1353
+ l.appendChild(c);
1354
+ }
1355
+ if (o.keyDifferencesHtml) {
1356
+ const c = document.createElement("div");
1357
+ c.className = "gengage-chat-comparison-key-differences";
1358
+ const h = document.createElement("h4");
1359
+ h.textContent = s?.keyDifferencesLabel ?? "Temel Farklar", c.appendChild(h);
1360
+ const m = document.createElement("div");
1361
+ m.className = "gengage-chat-comparison-key-differences-content", m.innerHTML = Z(Vt(o.keyDifferencesHtml)), c.appendChild(m), l.appendChild(c);
1362
+ }
1363
+ if (i && i.length > 0) {
1364
+ const c = document.createElement("details");
1365
+ c.className = "gengage-chat-comparison-special";
1366
+ const h = document.createElement("summary");
1367
+ h.textContent = s?.specialCasesLabel ?? "Özel Durumlar İçin", c.appendChild(h);
1368
+ const m = document.createElement("ul");
1369
+ for (const d of i) {
1370
+ const v = document.createElement("li");
1371
+ v.textContent = d, m.appendChild(v);
1372
+ }
1373
+ c.appendChild(m), l.appendChild(c);
1374
+ }
1375
+ if (t.length > 0 && a.length > 0) {
1376
+ const c = document.createElement("table");
1377
+ c.className = "gengage-chat-comparison-table";
1378
+ const h = document.createElement("thead"), m = document.createElement("tr"), d = document.createElement("th");
1379
+ m.appendChild(d);
1380
+ for (const w of t) {
1381
+ const b = document.createElement("th");
1382
+ if (w.sku === e?.sku && (b.className = "gengage-chat-comparison-selected"), w.imageUrl && K(w.imageUrl)) {
1383
+ const p = document.createElement("img");
1384
+ p.src = w.imageUrl, p.alt = w.name, p.loading = "lazy", p.addEventListener(
1385
+ "error",
1386
+ () => {
1387
+ p.style.display = "none";
1388
+ },
1389
+ { once: !0 }
1390
+ ), b.appendChild(p);
1391
+ }
1392
+ const N = document.createElement("div");
1393
+ N.textContent = w.name, b.appendChild(N);
1394
+ const I = document.createElement("div");
1395
+ I.className = "gengage-chat-comparison-table-price", I.textContent = w.price, b.appendChild(I), m.appendChild(b);
1396
+ }
1397
+ h.appendChild(m), c.appendChild(h);
1398
+ const v = document.createElement("tbody");
1399
+ for (const w of a) {
1400
+ const b = document.createElement("tr"), N = document.createElement("td");
1401
+ N.className = "gengage-chat-comparison-label", N.textContent = qt(w.label), b.appendChild(N);
1402
+ for (let I = 0; I < w.values.length; I++) {
1403
+ const p = document.createElement("td");
1404
+ t[I]?.sku === e?.sku && (p.className = "gengage-chat-comparison-selected"), p.textContent = w.values[I] ?? "", b.appendChild(p);
1405
+ }
1406
+ v.appendChild(b);
1407
+ }
1408
+ c.appendChild(v), l.appendChild(c);
1409
+ }
1410
+ if (o.productActions) {
1411
+ const c = document.createElement("div");
1412
+ c.className = "gengage-chat-comparison-product-actions";
1413
+ for (const h of t)
1414
+ if (o.productActions[h.sku]) {
1415
+ const d = document.createElement("button");
1416
+ d.className = "gengage-chat-comparison-view-btn", d.type = "button", d.textContent = h.name, d.addEventListener("click", () => r(h.sku)), c.appendChild(d);
1417
+ }
1418
+ c.childElementCount > 0 && l.appendChild(c);
1419
+ }
1420
+ return l;
1421
+ }
1422
+ function Vt(o) {
1423
+ const e = o.split(`
1424
+ `).filter((t) => t.trim());
1425
+ return e.length <= 1 ? o : "<ul>" + e.map((t) => `<li>${t.trim()}</li>`).join("") + "</ul>";
1426
+ }
1427
+ function Gt(o, e) {
1428
+ const t = document.createElement("div");
1429
+ t.className = "gengage-chat-review-highlights";
1430
+ const a = o.props?.reviews;
1431
+ if (!Array.isArray(a) || a.length === 0) {
1432
+ const m = document.createElement("div");
1433
+ return m.className = "gengage-chat-review-empty", m.textContent = e?.emptyReviewsMessage ?? "Yorum özeti bulunamadı.", t.appendChild(m), t;
1434
+ }
1435
+ const n = a.filter(
1436
+ (m) => m !== null && typeof m == "object"
1437
+ ), i = { all: n.length, positive: 0, negative: 0, neutral: 0 };
1438
+ for (const m of n)
1439
+ m.review_class === "positive" ? i.positive++ : m.review_class === "negative" ? i.negative++ : i.neutral++;
1440
+ const r = document.createElement("div");
1441
+ r.className = "gengage-chat-review-tabs";
1442
+ const s = [{ label: `Tümü (${i.all})`, filter: "all" }];
1443
+ i.positive > 0 && s.push({ label: `Olumlu (${i.positive})`, filter: "positive" }), i.negative > 0 && s.push({ label: `Olumsuz (${i.negative})`, filter: "negative" });
1444
+ let l = "all";
1445
+ const g = document.createElement("div");
1446
+ g.className = "gengage-chat-review-items";
1447
+ function c() {
1448
+ for (; g.firstChild; ) g.removeChild(g.firstChild);
1449
+ const m = l === "all" ? n : n.filter((d) => d.review_class === l);
1450
+ for (const d of m) {
1451
+ const v = document.createElement("article");
1452
+ v.className = "gengage-chat-review-item";
1453
+ const w = d.review_class;
1454
+ if ((w === "positive" || w === "negative" || w === "neutral") && (v.dataset.tone = w), typeof d.review_tag == "string" && d.review_tag.length > 0) {
1455
+ const b = document.createElement("div");
1456
+ b.className = "gengage-chat-review-tag", b.textContent = d.review_tag, v.appendChild(b);
1457
+ }
1458
+ if (typeof d.review_text == "string" && d.review_text.length > 0) {
1459
+ const b = document.createElement("div");
1460
+ b.className = "gengage-chat-review-text", b.textContent = d.review_text, v.appendChild(b);
1461
+ }
1462
+ if (d.review_rating !== void 0 && String(d.review_rating).length > 0) {
1463
+ const b = document.createElement("div");
1464
+ b.className = "gengage-chat-review-rating", b.textContent = String(d.review_rating), v.appendChild(b);
1465
+ }
1466
+ g.appendChild(v);
1467
+ }
1468
+ }
1469
+ for (const m of s) {
1470
+ const d = document.createElement("button");
1471
+ d.className = "gengage-chat-review-tab", d.type = "button", d.textContent = m.label, m.filter === l && d.classList.add("gengage-chat-review-tab--active"), d.addEventListener("click", () => {
1472
+ l = m.filter;
1473
+ for (const v of r.querySelectorAll(".gengage-chat-review-tab"))
1474
+ v.classList.toggle("gengage-chat-review-tab--active", v === d);
1475
+ c();
1476
+ }), r.appendChild(d);
1477
+ }
1478
+ t.appendChild(r);
1479
+ const h = /* @__PURE__ */ new Map();
1480
+ for (const m of n)
1481
+ if (typeof m.review_tag == "string" && m.review_tag.length > 0) {
1482
+ const d = h.get(m.review_tag);
1483
+ d ? d.count++ : h.set(m.review_tag, { count: 1, sentiment: m.review_class ?? "neutral" });
1484
+ }
1485
+ if (h.size > 0) {
1486
+ const m = document.createElement("div");
1487
+ m.className = "gengage-chat-review-pills";
1488
+ for (const [d, v] of h) {
1489
+ const w = document.createElement("span");
1490
+ w.className = "gengage-chat-review-pill", w.dataset.tone = v.sentiment;
1491
+ const b = document.createElement("span");
1492
+ b.className = "gengage-chat-review-pill-icon", b.textContent = v.sentiment === "positive" ? "✓" : v.sentiment === "negative" ? "✕" : "●", w.appendChild(b);
1493
+ const N = document.createElement("span");
1494
+ if (N.textContent = d, w.appendChild(N), v.count > 1) {
1495
+ const I = document.createElement("span");
1496
+ I.className = "gengage-chat-review-pill-count", I.textContent = String(v.count), w.appendChild(I);
1497
+ }
1498
+ m.appendChild(w);
1499
+ }
1500
+ t.appendChild(m);
1501
+ }
1502
+ return c(), t.appendChild(g), t;
1503
+ }
1504
+ const $t = {
1505
+ winner: "roleWinner",
1506
+ best_value: "roleBestValue",
1507
+ best_alternative: "roleBestAlternative"
1508
+ };
1509
+ function _e(o, e) {
1510
+ if (!o || !e) return null;
1511
+ const t = $t[o];
1512
+ return t ? e[t] ?? o : o;
1513
+ }
1514
+ function Kt(o, e) {
1515
+ const t = document.createElement("div");
1516
+ t.className = "gengage-chat-ai-top-picks";
1517
+ const a = o.props?.suggestions ?? [];
1518
+ if (a.length === 0) return t;
1519
+ const n = document.createElement("h3");
1520
+ n.className = "gengage-chat-ai-top-picks-title", n.textContent = e.i18n?.aiTopPicksTitle ?? "Top Picks", t.appendChild(n);
1521
+ const i = document.createElement("div");
1522
+ i.className = "gengage-chat-ai-top-picks-cards";
1523
+ for (let r = 0; r < a.length; r++) {
1524
+ const s = a[r], g = s.role === "winner" || r === 0 ? Wt(s, e) : Yt(s, e);
1525
+ i.appendChild(g);
1526
+ }
1527
+ return t.appendChild(i), t;
1528
+ }
1529
+ function Wt(o, e) {
1530
+ const t = document.createElement("div");
1531
+ t.className = "gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner";
1532
+ const a = document.createElement("span");
1533
+ a.className = "gengage-chat-ai-toppick-badge", a.textContent = _e(o.role, e.i18n) ?? e.i18n?.roleWinner ?? "TOP MATCH", t.appendChild(a);
1534
+ const n = o.product, i = n.discountPercent;
1535
+ if (typeof i == "number" && i > 0) {
1536
+ const h = document.createElement("span");
1537
+ h.className = "gengage-chat-ai-toppick-discount-badge", h.textContent = `%${se(i)}`, t.appendChild(h);
1538
+ }
1539
+ const r = n.imageUrl;
1540
+ if (r && K(r)) {
1541
+ const h = document.createElement("img");
1542
+ h.className = "gengage-chat-ai-toppick-img", D(h, "src", r), h.alt = n.name ?? "", Q(h), t.appendChild(h);
1543
+ }
1544
+ const s = document.createElement("div");
1545
+ s.className = "gengage-chat-ai-toppick-body";
1546
+ const l = n.name;
1547
+ if (l) {
1548
+ const h = document.createElement("div");
1549
+ h.className = "gengage-chat-ai-toppick-name", h.textContent = l, s.appendChild(h);
1550
+ }
1551
+ if (o.reason) {
1552
+ const h = document.createElement("div");
1553
+ h.className = "gengage-chat-ai-toppick-reason", h.textContent = o.reason, s.appendChild(h);
1554
+ }
1555
+ if (o.labels && o.labels.length > 0 && s.appendChild(ke(o.labels)), typeof o.expertQualityScore == "number") {
1556
+ const h = document.createElement("div");
1557
+ h.className = "gengage-chat-ai-toppick-score", h.textContent = `${o.expertQualityScore}/10`, s.appendChild(h);
1558
+ }
1559
+ if (o.reviewHighlight) {
1560
+ const h = document.createElement("blockquote");
1561
+ h.className = "gengage-chat-ai-toppick-review", h.textContent = o.reviewHighlight, s.appendChild(h);
1562
+ }
1563
+ const g = n.price, c = n.originalPrice;
1564
+ if (g) {
1565
+ const h = document.createElement("div");
1566
+ if (h.className = "gengage-chat-ai-toppick-price", c && c !== g) {
1567
+ const d = document.createElement("span");
1568
+ d.className = "gengage-chat-ai-toppick-original-price", d.textContent = F(c, e.pricing), h.appendChild(d), h.appendChild(document.createTextNode(" "));
1569
+ }
1570
+ const m = document.createElement("span");
1571
+ m.textContent = F(g, e.pricing), h.appendChild(m), s.appendChild(h);
1572
+ }
1573
+ if (t.appendChild(s), o.action) {
1574
+ const h = n.sku ?? null, m = document.createElement("div");
1575
+ m.className = "gengage-chat-ai-toppick-spinner", m.style.display = h && e.topPicksLoadingSku === h ? "" : "none", t.appendChild(m);
1576
+ const d = document.createElement("button");
1577
+ d.className = "gengage-chat-ai-toppick-cta", d.type = "button", d.textContent = e.i18n?.viewDetails ?? "View Details", d.addEventListener("click", () => {
1578
+ h && (m.style.display = ""), e.onAction(o.action);
1579
+ }), t.appendChild(d);
1580
+ }
1581
+ return t;
1582
+ }
1583
+ function Yt(o, e) {
1584
+ const t = document.createElement("div");
1585
+ t.className = "gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact";
1586
+ const a = o.product, n = a.discountPercent;
1587
+ if (typeof n == "number" && n > 0) {
1588
+ const c = document.createElement("span");
1589
+ c.className = "gengage-chat-ai-toppick-discount-badge", c.textContent = `%${se(n)}`, t.appendChild(c);
1590
+ }
1591
+ const i = a.imageUrl;
1592
+ if (i && K(i)) {
1593
+ const c = document.createElement("img");
1594
+ c.className = "gengage-chat-ai-toppick-img", D(c, "src", i), c.alt = a.name ?? "", Q(c), t.appendChild(c);
1595
+ }
1596
+ const r = document.createElement("div");
1597
+ r.className = "gengage-chat-ai-toppick-body";
1598
+ const s = _e(o.role, e.i18n);
1599
+ if (s) {
1600
+ const c = document.createElement("div");
1601
+ c.className = "gengage-chat-ai-toppick-role", c.textContent = s, r.appendChild(c);
1602
+ }
1603
+ const l = a.name;
1604
+ if (l) {
1605
+ const c = document.createElement("div");
1606
+ c.className = "gengage-chat-ai-toppick-name", c.textContent = l, r.appendChild(c);
1607
+ }
1608
+ if (o.reason) {
1609
+ const c = document.createElement("div");
1610
+ c.className = "gengage-chat-ai-toppick-reason", c.textContent = o.reason, r.appendChild(c);
1611
+ }
1612
+ o.labels && o.labels.length > 0 && r.appendChild(ke(o.labels));
1613
+ const g = a.price;
1614
+ if (g) {
1615
+ const c = document.createElement("div");
1616
+ c.className = "gengage-chat-ai-toppick-price", c.textContent = F(g, e.pricing), r.appendChild(c);
1617
+ }
1618
+ if (t.appendChild(r), o.action) {
1619
+ const c = a.sku ?? null, h = document.createElement("div");
1620
+ h.className = "gengage-chat-ai-toppick-spinner", h.style.display = c && e.topPicksLoadingSku === c ? "" : "none", t.appendChild(h);
1621
+ const m = document.createElement("button");
1622
+ m.className = "gengage-chat-ai-toppick-cta", m.type = "button", m.textContent = e.i18n?.viewDetails ?? "View Details", m.addEventListener("click", () => {
1623
+ c && (h.style.display = ""), e.onAction(o.action);
1624
+ }), t.appendChild(m);
1625
+ }
1626
+ return t;
1627
+ }
1628
+ function ke(o) {
1629
+ const e = document.createElement("div");
1630
+ e.className = "gengage-chat-ai-toppick-labels";
1631
+ for (const t of o) {
1632
+ const a = document.createElement("span");
1633
+ a.className = "gengage-chat-ai-toppick-label", a.dataset.sentiment = t.sentiment ?? "neutral", a.textContent = t.label, e.appendChild(a);
1634
+ }
1635
+ return e;
1636
+ }
1637
+ function Qt(o, e) {
1638
+ const t = document.createElement("div");
1639
+ t.className = "gengage-chat-grounding-review";
1640
+ const a = o.props ?? {}, n = a.title, i = a.reviewCount, r = a.action, s = e.i18n?.groundingReviewCta ?? "Yorumları Oku", l = document.createElement("span");
1641
+ l.className = "gengage-chat-grounding-review-icon", l.textContent = "📋", t.appendChild(l);
1642
+ const g = document.createElement("div");
1643
+ g.className = "gengage-chat-grounding-review-body";
1644
+ const c = document.createElement("div");
1645
+ if (c.className = "gengage-chat-grounding-review-title", c.textContent = n ?? "Müşteri Yorumları", g.appendChild(c), i) {
1646
+ const m = document.createElement("div");
1647
+ m.className = "gengage-chat-grounding-review-subtitle";
1648
+ const d = e.i18n?.groundingReviewSubtitle ?? "{count} yorum mevcut";
1649
+ m.textContent = d.replace("{count}", i), g.appendChild(m);
1650
+ }
1651
+ t.appendChild(g);
1652
+ const h = document.createElement("span");
1653
+ return h.className = "gengage-chat-grounding-review-cta", h.textContent = `${s} →`, t.appendChild(h), r && (t.style.cursor = "pointer", t.addEventListener("click", () => e.onAction(r))), t;
1654
+ }
1655
+ function Xt(o, e) {
1656
+ const t = document.createElement("div");
1657
+ t.className = "gengage-chat-grouping-cards";
1658
+ const a = o.props?.entries ?? [];
1659
+ if (a.length === 0) return t;
1660
+ for (const n of a) {
1661
+ const i = document.createElement("div");
1662
+ if (i.className = "gengage-chat-grouping-card", i.style.cursor = "pointer", i.addEventListener("click", () => e.onAction(n.action)), n.image && K(n.image)) {
1663
+ const g = document.createElement("img");
1664
+ g.className = "gengage-chat-grouping-card-img", g.src = n.image, g.alt = n.name, g.width = 20, g.height = 20, i.appendChild(g);
1665
+ }
1666
+ const r = document.createElement("div");
1667
+ r.className = "gengage-chat-grouping-card-body";
1668
+ const s = document.createElement("span");
1669
+ if (s.className = "gengage-chat-grouping-card-name", s.textContent = n.name, r.appendChild(s), n.description) {
1670
+ const g = document.createElement("span");
1671
+ g.className = "gengage-chat-grouping-card-desc", g.textContent = n.description, r.appendChild(g);
1672
+ }
1673
+ if (n.labels && n.labels.length > 0) {
1674
+ const g = document.createElement("span");
1675
+ g.className = "gengage-chat-grouping-card-labels", g.textContent = n.labels.slice(0, 3).join(" · "), r.appendChild(g);
1676
+ }
1677
+ i.appendChild(r);
1678
+ const l = document.createElement("span");
1679
+ l.className = "gengage-chat-grouping-card-arrow", l.textContent = "↳", i.insertBefore(l, i.firstChild), t.appendChild(i);
1680
+ }
1681
+ return t;
1682
+ }
1683
+ function Jt(o, e) {
1684
+ const t = document.createElement("div");
1685
+ t.className = "gengage-chat-suggested-search-cards";
1686
+ const a = o.props?.entries ?? [];
1687
+ if (a.length === 0) return t;
1688
+ for (const n of a) {
1689
+ const i = document.createElement("div");
1690
+ if (i.className = "gengage-chat-suggested-search-card", i.style.cursor = "pointer", i.addEventListener("click", () => e.onAction(n.action)), n.image && K(n.image)) {
1691
+ const l = document.createElement("img");
1692
+ l.className = "gengage-chat-suggested-search-card-img", l.src = n.image, l.alt = n.shortName, l.width = 40, l.height = 40, i.appendChild(l);
1693
+ }
1694
+ const r = document.createElement("div");
1695
+ r.className = "gengage-chat-suggested-search-card-body";
1696
+ const s = document.createElement("div");
1697
+ if (s.className = "gengage-chat-suggested-search-card-name", s.textContent = n.shortName, r.appendChild(s), n.detailedMessage) {
1698
+ const l = document.createElement("div");
1699
+ l.className = "gengage-chat-suggested-search-card-desc", l.textContent = n.detailedMessage, r.appendChild(l);
1700
+ }
1701
+ if (n.whyDifferent) {
1702
+ const l = document.createElement("div");
1703
+ l.className = "gengage-chat-suggested-search-card-diff", l.textContent = n.whyDifferent, r.appendChild(l);
1704
+ }
1705
+ i.appendChild(r), t.appendChild(i);
1706
+ }
1707
+ return t;
1708
+ }
1709
+ function Zt(o, e) {
1710
+ const t = document.createElement("button");
1711
+ t.className = "gengage-chat-comparison-floating-btn", t.type = "button";
1712
+ const a = e.i18n?.compareSelected ?? "Karşılaştır";
1713
+ return t.textContent = `${a} (${o.length})`, t.addEventListener("click", () => {
1714
+ e.onAction({
1715
+ title: a,
1716
+ type: "getComparisonTable",
1717
+ payload: { sku_list: [...o] }
1718
+ });
1719
+ }), t;
1720
+ }
1721
+ function ea(o) {
1722
+ const e = document.createElement("div");
1723
+ e.className = "gengage-chat-pros-cons";
1724
+ const t = o.props?.productName;
1725
+ if (t) {
1726
+ const i = document.createElement("h4");
1727
+ i.className = "gengage-chat-pros-cons-heading", i.textContent = t, e.appendChild(i);
1728
+ }
1729
+ const a = o.props?.pros, n = o.props?.cons;
1730
+ if (a && a.length > 0) {
1731
+ const i = document.createElement("ul");
1732
+ i.className = "gengage-chat-pros-cons-list";
1733
+ for (const r of a) {
1734
+ const s = document.createElement("li");
1735
+ s.className = "gengage-chat-pros-cons-item";
1736
+ const l = document.createElement("span");
1737
+ l.className = "gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--pro", l.textContent = "✓", s.appendChild(l);
1738
+ const g = document.createElement("span");
1739
+ g.textContent = r, s.appendChild(g), i.appendChild(s);
1740
+ }
1741
+ e.appendChild(i);
1742
+ }
1743
+ if (n && n.length > 0) {
1744
+ const i = document.createElement("ul");
1745
+ i.className = "gengage-chat-pros-cons-list";
1746
+ for (const r of n) {
1747
+ const s = document.createElement("li");
1748
+ s.className = "gengage-chat-pros-cons-item";
1749
+ const l = document.createElement("span");
1750
+ l.className = "gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--con", l.textContent = "✗", s.appendChild(l);
1751
+ const g = document.createElement("span");
1752
+ g.textContent = r, s.appendChild(g), i.appendChild(s);
1753
+ }
1754
+ e.appendChild(i);
1755
+ }
1756
+ return e;
1757
+ }
1758
+ function ta(o, e) {
1759
+ const t = o.props?.groups ?? [], a = o.props?.filterTags ?? [], n = document.createElement("div");
1760
+ if (n.className = "gengage-chat-categories", t.length === 0) return n;
1761
+ const i = document.createElement("div");
1762
+ i.className = "gengage-chat-categories-tabs", i.setAttribute("role", "tablist");
1763
+ const r = [], s = [], l = (g) => {
1764
+ for (let c = 0; c < r.length; c++) {
1765
+ const h = c === g;
1766
+ r[c].classList.toggle("gengage-chat-categories-tab--active", h), r[c].setAttribute("aria-selected", String(h)), r[c].tabIndex = h ? 0 : -1, s[c].style.display = h ? "" : "none";
1767
+ }
1768
+ };
1769
+ for (let g = 0; g < t.length; g++) {
1770
+ const c = t[g], h = `gengage-cat-tab-${g}`, m = `gengage-cat-panel-${g}`, d = document.createElement("button");
1771
+ d.className = "gengage-chat-categories-tab", d.type = "button", d.id = h, d.setAttribute("role", "tab"), d.setAttribute("aria-controls", m), d.setAttribute("aria-selected", String(g === 0)), d.tabIndex = g === 0 ? 0 : -1, g === 0 && d.classList.add("gengage-chat-categories-tab--active"), d.textContent = c.groupName, d.addEventListener("click", () => l(g)), d.addEventListener("keydown", (w) => {
1772
+ let b = -1;
1773
+ w.key === "ArrowRight" || w.key === "ArrowDown" ? b = (g + 1) % t.length : w.key === "ArrowLeft" || w.key === "ArrowUp" ? b = (g - 1 + t.length) % t.length : w.key === "Home" ? b = 0 : w.key === "End" && (b = t.length - 1), b >= 0 && (w.preventDefault(), l(b), r[b].focus());
1774
+ }), r.push(d), i.appendChild(d);
1775
+ const v = document.createElement("div");
1776
+ v.className = "gengage-chat-categories-grid", v.id = m, v.setAttribute("role", "tabpanel"), v.setAttribute("aria-labelledby", h), g !== 0 && (v.style.display = "none");
1777
+ for (const w of c.products) {
1778
+ const b = aa(w, e);
1779
+ v.appendChild(b);
1780
+ }
1781
+ s.push(v);
1782
+ }
1783
+ n.appendChild(i);
1784
+ for (const g of s) n.appendChild(g);
1785
+ if (a.length > 0) {
1786
+ const g = document.createElement("div");
1787
+ g.className = "gengage-chat-categories-filter-tags";
1788
+ for (const c of a) {
1789
+ const h = document.createElement("button");
1790
+ h.className = "gengage-chat-categories-filter-tag", h.type = "button", h.textContent = c.title, c.action && h.addEventListener("click", () => {
1791
+ e.onAction(c.action);
1792
+ }), g.appendChild(h);
1793
+ }
1794
+ n.appendChild(g);
1795
+ }
1796
+ return n;
1797
+ }
1798
+ function aa(o, e) {
1799
+ const t = document.createElement("div");
1800
+ if (t.className = "gengage-chat-product-card", o.imageUrl && K(o.imageUrl)) {
1801
+ const i = document.createElement("img");
1802
+ i.className = "gengage-chat-product-card-img", i.src = o.imageUrl, i.alt = o.name, t.appendChild(i);
1803
+ }
1804
+ const a = document.createElement("div");
1805
+ a.className = "gengage-chat-product-card-body";
1806
+ const n = document.createElement("div");
1807
+ if (n.className = "gengage-chat-product-card-name", n.textContent = o.name, a.appendChild(n), o.price) {
1808
+ const i = document.createElement("div");
1809
+ i.className = "gengage-chat-product-card-price", i.textContent = o.price, a.appendChild(i);
1810
+ }
1811
+ return t.appendChild(a), e.onProductSelect && (t.style.cursor = "pointer", t.addEventListener("click", () => {
1812
+ e.onProductSelect?.(o);
1813
+ })), t;
1814
+ }
1815
+ function na(o, e) {
1816
+ const t = document.createElement("div");
1817
+ t.className = "gengage-chat-handoff-notice", t.setAttribute("role", "alert");
1818
+ const a = document.createElement("span");
1819
+ a.className = "gengage-chat-handoff-notice-icon", a.textContent = "👤", a.setAttribute("aria-hidden", "true"), t.appendChild(a);
1820
+ const n = document.createElement("h4");
1821
+ n.className = "gengage-chat-handoff-notice-heading", n.textContent = e.i18n?.handoffHeading ?? "Transferring to a support agent", t.appendChild(n);
1822
+ const i = o.props?.summary;
1823
+ if (i) {
1824
+ const r = document.createElement("p");
1825
+ r.className = "gengage-chat-handoff-notice-summary", r.textContent = i, t.appendChild(r);
1826
+ }
1827
+ return t;
1828
+ }
1829
+ function ia(o, e) {
1830
+ const t = o.props?.product ?? o.props, a = document.createElement("div");
1831
+ if (a.className = "gengage-chat-product-summary", !t) return a;
1832
+ a.style.cursor = "pointer", a.addEventListener("click", (d) => {
1833
+ d.target.closest("a") || e.onProductSelect?.(t);
1834
+ });
1835
+ const n = t.imageUrl;
1836
+ if (n && G(n)) {
1837
+ const d = document.createElement("div");
1838
+ d.className = "gengage-chat-product-summary__image";
1839
+ const v = document.createElement("img");
1840
+ D(v, "src", n);
1841
+ const w = t.name;
1842
+ w && (v.alt = w), Q(v), d.appendChild(v), a.appendChild(d);
1843
+ }
1844
+ const i = document.createElement("div");
1845
+ i.className = "gengage-chat-product-summary__content";
1846
+ const r = t.brand, s = t.name;
1847
+ if (s) {
1848
+ const d = document.createElement("div");
1849
+ d.className = "gengage-chat-product-summary__name";
1850
+ const v = r && !s.toLowerCase().startsWith(r.toLowerCase());
1851
+ d.textContent = v ? `${r} ${s}` : s, i.appendChild(d);
1852
+ }
1853
+ const l = t.rating, g = t.reviewCount;
1854
+ if (typeof l == "number" && Number.isFinite(l) && l > 0) {
1855
+ const d = document.createElement("div");
1856
+ if (d.className = "gengage-chat-product-summary__rating", d.textContent = xe(ve(l)), typeof g == "number" && Number.isFinite(g)) {
1857
+ const v = document.createElement("span");
1858
+ v.className = "gengage-chat-product-summary__review-count", v.textContent = ` (${g})`, d.appendChild(v);
1859
+ }
1860
+ i.appendChild(d);
1861
+ }
1862
+ const c = t.price, h = t.originalPrice;
1863
+ if (c) {
1864
+ const d = document.createElement("div");
1865
+ if (d.className = "gengage-chat-product-summary__price", h && h !== c) {
1866
+ const w = document.createElement("span");
1867
+ w.className = "gengage-chat-product-summary__price-original", w.textContent = F(h, e.pricing), d.appendChild(w), d.appendChild(document.createTextNode(" "));
1868
+ }
1869
+ const v = document.createElement("span");
1870
+ v.className = "gengage-chat-product-summary__price-current", v.textContent = F(c, e.pricing), d.appendChild(v), i.appendChild(d);
1871
+ }
1872
+ a.appendChild(i);
1873
+ const m = t.url;
1874
+ if (m && G(m)) {
1875
+ const d = document.createElement("a");
1876
+ d.className = "gengage-chat-product-summary__cta", D(d, "href", m), D(d, "target", "_blank"), D(d, "rel", "noopener noreferrer"), d.textContent = e.i18n?.productCtaLabel ?? "İncele", a.appendChild(d);
1877
+ }
1878
+ return a;
1879
+ }
1880
+ function Ce() {
1881
+ return window.innerWidth < 768;
1882
+ }
1883
+ const Ee = {
1884
+ ActionButtons: ({ element: o, context: e }) => sa(o, e),
1885
+ ActionButton: ({ element: o, context: e }) => ca(o, e),
1886
+ ProductCard: ({ element: o, context: e }) => la(o, e),
1887
+ ProductDetailsPanel: ({ element: o, context: e }) => ga(o, e),
1888
+ ProductGrid: ({ element: o, spec: e, renderElement: t, context: a }) => ha(o, e, t, a),
1889
+ ReviewHighlights: ({ element: o, context: e }) => Gt(o, { emptyReviewsMessage: e.i18n?.emptyReviewsMessage }),
1890
+ ComparisonTable: ({ element: o, context: e }) => ua(o, e),
1891
+ AITopPicks: ({ element: o, context: e }) => Kt(o, e),
1892
+ GroundingReviewCard: ({ element: o, context: e }) => Qt(o, e),
1893
+ AIGroupingCards: ({ element: o, context: e }) => Xt(o, e),
1894
+ AISuggestedSearchCards: ({ element: o, context: e }) => Jt(o, e),
1895
+ ProsAndCons: ({ element: o }) => ea(o),
1896
+ CategoriesContainer: ({ element: o, context: e }) => ta(o, e),
1897
+ HandoffNotice: ({ element: o, context: e }) => na(o, e),
1898
+ ProductSummaryCard: ({ element: o, context: e }) => ia(o, e),
1899
+ Divider: ({ element: o }) => ma(o)
1900
+ }, Se = ({
1901
+ element: o,
1902
+ renderElement: e
1903
+ }) => {
1904
+ if (!o.children || o.children.length === 0)
1905
+ return null;
1906
+ const t = document.createElement("div");
1907
+ for (const a of o.children) {
1908
+ const n = e(a);
1909
+ n && t.appendChild(n);
1910
+ }
1911
+ return t;
1912
+ };
1913
+ function oa() {
1914
+ return { ...Ee };
1915
+ }
1916
+ function ra(o, e, t = Ee, a = Se) {
1917
+ return Me({
1918
+ spec: o,
1919
+ context: e,
1920
+ registry: t,
1921
+ containerClassName: "gengage-chat-uispec",
1922
+ unknownRenderer: a
1923
+ });
1924
+ }
1925
+ function sa(o, e) {
1926
+ const t = document.createElement("div");
1927
+ t.className = "gengage-chat-action-buttons";
1928
+ const a = o.props?.buttons;
1929
+ if (a)
1930
+ for (const n of a) {
1931
+ const i = document.createElement("button");
1932
+ i.className = "gengage-chat-action-btn", i.textContent = n.label, i.addEventListener("click", () => e.onAction(n.action)), t.appendChild(i);
1933
+ }
1934
+ return t;
1935
+ }
1936
+ function ca(o, e) {
1937
+ const t = document.createElement("button");
1938
+ t.className = "gengage-chat-action-btn";
1939
+ const a = o.props?.label;
1940
+ typeof a == "string" && (t.textContent = a);
1941
+ const n = o.props?.action;
1942
+ return n && t.addEventListener("click", () => e.onAction(n)), t;
1943
+ }
1944
+ function la(o, e) {
1945
+ const t = document.createElement("div");
1946
+ t.className = "gengage-chat-product-card";
1947
+ const a = o.props?.product ?? o.props;
1948
+ if (!a) return t;
1949
+ e.onProductSelect && (t.style.cursor = "pointer", t.addEventListener("click", (p) => {
1950
+ p.target.closest(".gengage-chat-product-card-atc") || p.target.closest(".gengage-chat-product-card-cta") || e.onProductSelect?.(a);
1951
+ }));
1952
+ const n = a.imageUrl;
1953
+ if (n && G(n)) {
1954
+ const p = document.createElement("div");
1955
+ p.className = "gengage-chat-product-card-img-wrapper";
1956
+ const y = document.createElement("img");
1957
+ y.className = "gengage-chat-product-card-img", y.loading = "lazy", D(y, "src", n);
1958
+ const _ = a.name;
1959
+ _ && (y.alt = _), Q(y), p.appendChild(y);
1960
+ const k = a.discountPercent;
1961
+ if (typeof k == "number" && k > 0) {
1962
+ const f = document.createElement("span");
1963
+ f.className = "gengage-chat-product-card-discount-badge", f.textContent = `%${se(k)}`, p.appendChild(f);
1964
+ }
1965
+ const A = a.sku;
1966
+ if (A) {
1967
+ const f = document.createElement("button");
1968
+ f.className = "gengage-chat-find-similar-pill", f.type = "button", f.textContent = e.i18n?.findSimilarLabel ?? "Benzerlerini Bul", f.addEventListener("click", (C) => {
1969
+ C.stopPropagation(), e.onAction({
1970
+ title: e.i18n?.findSimilarLabel ?? "Benzerlerini Bul",
1971
+ type: "findSimilar",
1972
+ payload: { sku: A, ...n ? { image_url: n } : {} }
1973
+ });
1974
+ }), p.appendChild(f);
1975
+ }
1976
+ const u = a.sku;
1977
+ if (u && e.onFavoriteToggle) {
1978
+ const f = document.createElement("button");
1979
+ f.className = "gengage-chat-favorite-btn", f.type = "button", f.setAttribute("aria-label", "Favorilere ekle");
1980
+ const C = e.favoritedSkus?.has(u) ?? !1;
1981
+ C && f.classList.add("gengage-chat-favorite-btn--active");
1982
+ const S = C ? "currentColor" : "none";
1983
+ f.innerHTML = `<svg width="16" height="16" viewBox="0 0 24 24" fill="${S}" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>`, f.addEventListener("click", (P) => {
1984
+ P.stopPropagation(), f.classList.toggle("gengage-chat-favorite-btn--active");
1985
+ const T = f.querySelector("svg");
1986
+ T && T.setAttribute(
1987
+ "fill",
1988
+ f.classList.contains("gengage-chat-favorite-btn--active") ? "currentColor" : "none"
1989
+ ), e.onFavoriteToggle(u, a);
1990
+ }), p.appendChild(f);
1991
+ }
1992
+ t.appendChild(p);
1993
+ }
1994
+ const i = document.createElement("div");
1995
+ i.className = "gengage-chat-product-card-body";
1996
+ const r = a.brand;
1997
+ if (r) {
1998
+ const p = document.createElement("div");
1999
+ p.className = "gengage-chat-product-card-brand", p.textContent = r, i.appendChild(p);
2000
+ }
2001
+ const s = a.name;
2002
+ if (s) {
2003
+ const p = document.createElement("div");
2004
+ p.className = "gengage-chat-product-card-name", p.textContent = s, i.appendChild(p);
2005
+ }
2006
+ const l = a.rating, g = a.reviewCount;
2007
+ if (typeof l == "number" && Number.isFinite(l)) {
2008
+ const p = document.createElement("div");
2009
+ if (p.className = "gengage-chat-product-card-rating", p.textContent = xe(l), typeof g == "number" && Number.isFinite(g)) {
2010
+ const y = document.createElement("span");
2011
+ y.className = "gengage-chat-product-card-review-count", y.textContent = ` (${g})`, p.appendChild(y);
2012
+ }
2013
+ i.appendChild(p);
2014
+ }
2015
+ const c = a.price, h = a.originalPrice;
2016
+ if (a.price_async === !0) {
2017
+ const p = document.createElement("div");
2018
+ p.className = "gengage-chat-product-card-price";
2019
+ const y = document.createElement("span");
2020
+ y.className = "gengage-chat-price-skeleton", p.appendChild(y), i.appendChild(p), setTimeout(() => {
2021
+ y.parentElement && (c ? y.replaceWith(document.createTextNode(F(c, e.pricing))) : y.remove());
2022
+ }, 300);
2023
+ } else if (c) {
2024
+ const p = document.createElement("div");
2025
+ if (p.className = "gengage-chat-product-card-price", h && h !== c) {
2026
+ const _ = document.createElement("span");
2027
+ _.className = "gengage-chat-product-card-original-price", _.textContent = F(h, e.pricing), p.appendChild(_), p.appendChild(document.createTextNode(" "));
2028
+ }
2029
+ const y = document.createElement("span");
2030
+ y.textContent = F(c, e.pricing), p.appendChild(y), i.appendChild(p);
2031
+ }
2032
+ const d = a.inStock;
2033
+ if (typeof d == "boolean") {
2034
+ const p = document.createElement("div");
2035
+ p.className = `gengage-chat-product-card-stock ${d ? "is-in-stock" : "is-out-of-stock"}`, p.textContent = d ? e.i18n?.inStockLabel ?? "Stokta" : e.i18n?.outOfStockLabel ?? "Tükendi", i.appendChild(p);
2036
+ }
2037
+ const v = a.promotions;
2038
+ if (v && v.length > 0) {
2039
+ const p = document.createElement("div");
2040
+ p.className = "gengage-chat-product-card-promos";
2041
+ for (const y of v) {
2042
+ const _ = document.createElement("span");
2043
+ _.className = "gengage-chat-product-card-promo-badge", _.textContent = y, p.appendChild(_);
2044
+ }
2045
+ i.appendChild(p);
2046
+ }
2047
+ t.appendChild(i);
2048
+ const w = a.url, b = a.sku, N = o.props?.action;
2049
+ if (N) {
2050
+ const p = document.createElement("button");
2051
+ p.className = "gengage-chat-product-card-cta", p.type = "button", p.textContent = N.title || e.i18n?.productCtaLabel || "Incele", p.addEventListener("click", () => e.onAction(N)), t.appendChild(p);
2052
+ } else if (w && G(w)) {
2053
+ const p = document.createElement("a");
2054
+ p.className = "gengage-chat-product-card-cta", D(p, "href", w), D(p, "target", "_blank"), D(p, "rel", "noopener noreferrer"), p.textContent = e.i18n?.productCtaLabel ?? "İncele", p.addEventListener("click", (y) => {
2055
+ e.onProductClick && b && (y.preventDefault(), e.onProductClick({ sku: b, url: w }));
2056
+ }), t.appendChild(p);
2057
+ }
2058
+ const I = a.cartCode;
2059
+ if (I && b) {
2060
+ const p = we({
2061
+ compact: !0,
2062
+ label: e.i18n?.addToCartButton ?? "Sepete Ekle",
2063
+ onSubmit: (y) => {
2064
+ e.onAction({
2065
+ title: e.i18n?.addToCartButton ?? "Sepete Ekle",
2066
+ type: "addToCart",
2067
+ payload: { sku: b, cartCode: I, quantity: y }
2068
+ });
2069
+ }
2070
+ });
2071
+ p.classList.add("gengage-chat-product-card-atc"), t.appendChild(p);
2072
+ }
2073
+ if (e.comparisonSelectMode && b && e.onToggleComparisonSku) {
2074
+ const p = document.createElement("div");
2075
+ p.className = "gengage-chat-comparison-select-wrapper";
2076
+ const y = document.createElement("input");
2077
+ return y.type = "checkbox", y.className = "gengage-chat-comparison-checkbox", y.checked = e.comparisonSelectedSkus?.includes(b) ?? !1, y.addEventListener("change", () => {
2078
+ e.onToggleComparisonSku?.(b);
2079
+ }), p.appendChild(y), p.appendChild(t), p;
2080
+ }
2081
+ return t;
2082
+ }
2083
+ function ga(o, e) {
2084
+ const t = document.createElement("article");
2085
+ t.className = "gengage-chat-product-details-panel";
2086
+ const a = o.props?.product ?? o.props;
2087
+ if (!a) return t;
2088
+ const n = a.images, i = a.imageUrl, r = a.sku;
2089
+ if (n && n.length > 1) {
2090
+ const u = document.createElement("div");
2091
+ u.className = "gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";
2092
+ const f = document.createElement("img");
2093
+ f.className = "gengage-chat-product-details-img";
2094
+ const C = n.find((z) => G(z));
2095
+ C && D(f, "src", C);
2096
+ const S = a.name;
2097
+ S && (f.alt = S), Q(f), u.appendChild(f);
2098
+ const P = document.createElement("div");
2099
+ P.className = "gengage-chat-product-gallery-thumbs";
2100
+ let T = null, E = 0;
2101
+ for (let z = 0; z < n.length; z++) {
2102
+ const H = n[z];
2103
+ if (!H || !G(H)) continue;
2104
+ const R = document.createElement("img");
2105
+ R.className = "gengage-chat-product-gallery-thumb", z === 0 && (R.classList.add("gengage-chat-product-gallery-thumb--active"), T = R), D(R, "src", H), R.alt = `${S ?? "Product"} ${z + 1}`, R.width = 48, R.height = 48, Q(R), R.addEventListener("click", () => {
2106
+ D(f, "src", H), T && T.classList.remove("gengage-chat-product-gallery-thumb--active"), R.classList.add("gengage-chat-product-gallery-thumb--active"), T = R, E = z;
2107
+ }), P.appendChild(R);
2108
+ }
2109
+ let M = 0;
2110
+ const U = 50;
2111
+ if (f.addEventListener(
2112
+ "touchstart",
2113
+ (z) => {
2114
+ M = z.changedTouches[0].clientX;
2115
+ },
2116
+ { passive: !0 }
2117
+ ), f.addEventListener("touchend", (z) => {
2118
+ const H = z.changedTouches[0].clientX, R = M - H;
2119
+ if (Math.abs(R) < U) return;
2120
+ const ne = P.querySelectorAll(".gengage-chat-product-gallery-thumb"), ie = R > 0 ? Math.min(E + 1, ne.length - 1) : Math.max(E - 1, 0);
2121
+ ie !== E && ne[ie] && ne[ie].click();
2122
+ }), u.appendChild(P), r) {
2123
+ const z = document.createElement("button");
2124
+ z.className = "gengage-chat-find-similar-pill", z.type = "button", z.textContent = e.i18n?.findSimilarLabel ?? "Benzerlerini Bul", z.addEventListener("click", () => {
2125
+ e.onAction({
2126
+ title: e.i18n?.findSimilarLabel ?? "Benzerlerini Bul",
2127
+ type: "findSimilar",
2128
+ payload: { sku: r, ...C ? { image_url: C } : {} }
2129
+ });
2130
+ }), u.appendChild(z);
2131
+ }
2132
+ t.appendChild(u);
2133
+ } else if (i && G(i)) {
2134
+ const u = document.createElement("div");
2135
+ u.className = "gengage-chat-product-details-media gengage-chat-product-details-img-wrap";
2136
+ const f = document.createElement("img");
2137
+ f.className = "gengage-chat-product-details-img", f.loading = "lazy", D(f, "src", i), Q(f);
2138
+ const C = a.name;
2139
+ if (C && (f.alt = C), u.appendChild(f), r) {
2140
+ const S = document.createElement("button");
2141
+ S.className = "gengage-chat-find-similar-pill", S.type = "button", S.textContent = e.i18n?.findSimilarLabel ?? "Benzerlerini Bul", S.addEventListener("click", () => {
2142
+ e.onAction({
2143
+ title: e.i18n?.findSimilarLabel ?? "Benzerlerini Bul",
2144
+ type: "findSimilar",
2145
+ payload: { sku: r, ...i ? { image_url: i } : {} }
2146
+ });
2147
+ }), u.appendChild(S);
2148
+ }
2149
+ t.appendChild(u);
2150
+ }
2151
+ const s = document.createElement("div");
2152
+ s.className = "gengage-chat-product-details-content";
2153
+ const l = a.name;
2154
+ if (l) {
2155
+ const u = document.createElement("h3");
2156
+ u.className = "gengage-chat-product-details-title", u.textContent = l, s.appendChild(u);
2157
+ }
2158
+ const g = a.rating, c = a.reviewCount;
2159
+ if (typeof g == "number" && Number.isFinite(g)) {
2160
+ const u = document.createElement("div");
2161
+ if (u.className = "gengage-chat-product-details-rating", u.textContent = `★ ${ve(g).toFixed(1)}`, typeof c == "number" && Number.isFinite(c)) {
2162
+ const f = document.createElement("span");
2163
+ f.className = "gengage-chat-product-details-review-count", f.textContent = ` (${c})`, u.appendChild(f);
2164
+ }
2165
+ s.appendChild(u);
2166
+ }
2167
+ const h = a.price, m = a.originalPrice;
2168
+ if (a.price_async === !0) {
2169
+ const u = document.createElement("div");
2170
+ u.className = "gengage-chat-product-details-price";
2171
+ const f = document.createElement("span");
2172
+ f.className = "gengage-chat-price-skeleton", u.appendChild(f), s.appendChild(u), setTimeout(() => {
2173
+ if (f.parentElement)
2174
+ if (h) {
2175
+ const C = document.createElement("span");
2176
+ C.className = "gengage-chat-product-details-current-price", C.textContent = F(h, e.pricing), f.replaceWith(C);
2177
+ } else
2178
+ f.remove();
2179
+ }, 300);
2180
+ } else if (h) {
2181
+ const u = document.createElement("div");
2182
+ if (u.className = "gengage-chat-product-details-price", m && m !== h) {
2183
+ const C = document.createElement("span");
2184
+ C.className = "gengage-chat-product-details-original-price", C.textContent = F(m, e.pricing), u.appendChild(C), u.appendChild(document.createTextNode(" "));
2185
+ }
2186
+ const f = document.createElement("span");
2187
+ f.className = "gengage-chat-product-details-current-price", f.textContent = F(h, e.pricing), u.appendChild(f), s.appendChild(u);
2188
+ }
2189
+ const v = a.inStock;
2190
+ if (typeof v == "boolean") {
2191
+ const u = document.createElement("div");
2192
+ u.className = `gengage-chat-product-details-stock ${v ? "is-in-stock" : "is-out-of-stock"}`, u.textContent = v ? "Stokta var" : "Stokta yok", s.appendChild(u);
2193
+ }
2194
+ const w = a.promotions;
2195
+ if (w && w.length > 0) {
2196
+ const u = document.createElement("div");
2197
+ u.className = "gengage-chat-product-details-promos";
2198
+ for (const f of w) {
2199
+ const C = document.createElement("span");
2200
+ C.className = "gengage-chat-product-details-promo-badge", C.textContent = f, u.appendChild(C);
2201
+ }
2202
+ s.appendChild(u);
2203
+ }
2204
+ const b = a.variants;
2205
+ if (b && b.length > 0) {
2206
+ const u = document.createElement("div");
2207
+ u.className = "gengage-chat-product-variants";
2208
+ const f = document.createElement("div");
2209
+ f.className = "gengage-chat-product-variants-label", f.textContent = e.i18n?.variantsLabel ?? "Varyantlar", u.appendChild(f);
2210
+ const C = document.createElement("div");
2211
+ C.className = "gengage-chat-product-variants-list";
2212
+ for (const S of b) {
2213
+ const P = S.name ?? S.variant_name, T = S.sku;
2214
+ if (!P && !T) continue;
2215
+ const E = document.createElement("button");
2216
+ E.className = "gengage-chat-product-variant-btn", E.type = "button";
2217
+ const M = P ?? T ?? "", U = S.price;
2218
+ U && String(U) !== String(h) ? E.textContent = `${M} - ${F(String(U), e.pricing)}` : E.textContent = M, T && E.addEventListener("click", () => {
2219
+ e.onAction({
2220
+ title: M,
2221
+ type: "launchVariant",
2222
+ payload: { sku: T }
2223
+ });
2224
+ }), C.appendChild(E);
2225
+ }
2226
+ u.appendChild(C), s.appendChild(u);
2227
+ }
2228
+ const N = a.sku, I = a.cartCode, p = document.createElement("div");
2229
+ p.className = "gengage-chat-product-details-actions";
2230
+ const y = o.props?.action;
2231
+ if (y) {
2232
+ const u = document.createElement("button");
2233
+ u.className = "gengage-chat-product-details-cta", u.type = "button", u.textContent = y.title || e.i18n?.productCtaLabel || "Incele", u.addEventListener("click", () => e.onAction(y)), p.appendChild(u);
2234
+ } else {
2235
+ const u = a.url;
2236
+ if (u && G(u)) {
2237
+ const f = document.createElement("a");
2238
+ f.className = "gengage-chat-product-details-cta", D(f, "href", u), D(f, "target", "_blank"), D(f, "rel", "noopener noreferrer"), f.textContent = e.i18n?.productCtaLabel ?? "Incele", f.addEventListener("click", (C) => {
2239
+ e.onProductClick && N && (C.preventDefault(), e.onProductClick({ sku: N, url: u }));
2240
+ }), p.appendChild(f);
2241
+ }
2242
+ }
2243
+ if (I && N) {
2244
+ const u = we({
2245
+ compact: !1,
2246
+ label: e.i18n?.addToCartButton ?? "Sepete Ekle",
2247
+ onSubmit: (f) => {
2248
+ e.onAction({
2249
+ title: e.i18n?.addToCartButton ?? "Sepete Ekle",
2250
+ type: "addToCart",
2251
+ payload: { sku: N, cartCode: I, quantity: f }
2252
+ });
2253
+ }
2254
+ });
2255
+ u.classList.add("gengage-chat-product-details-atc-stepper"), p.appendChild(u);
2256
+ }
2257
+ const _ = a.url;
2258
+ if (_ && G(_)) {
2259
+ let u = function(E, M) {
2260
+ const U = document.createElementNS(P, "circle");
2261
+ U.setAttribute("cx", E), U.setAttribute("cy", M), U.setAttribute("r", "3"), T.appendChild(U);
2262
+ }, f = function(E, M, U, z) {
2263
+ const H = document.createElementNS(P, "line");
2264
+ H.setAttribute("x1", E), H.setAttribute("y1", M), H.setAttribute("x2", U), H.setAttribute("y2", z), T.appendChild(H);
2265
+ };
2266
+ const C = document.createElement("button");
2267
+ C.className = "gengage-chat-product-details-share", C.type = "button";
2268
+ const S = e.i18n?.shareButton ?? "Paylaş";
2269
+ C.title = S, C.setAttribute("aria-label", S);
2270
+ const P = "http://www.w3.org/2000/svg", T = document.createElementNS(P, "svg");
2271
+ T.setAttribute("width", "18"), T.setAttribute("height", "18"), T.setAttribute("viewBox", "0 0 24 24"), T.setAttribute("fill", "none"), T.setAttribute("stroke", "currentColor"), T.setAttribute("stroke-width", "2"), T.setAttribute("stroke-linecap", "round"), T.setAttribute("stroke-linejoin", "round"), u("18", "5"), u("6", "12"), u("18", "19"), f("8.59", "13.51", "15.42", "17.49"), f("15.41", "6.51", "8.59", "10.49"), C.appendChild(T), C.addEventListener("click", async () => {
2272
+ const E = a.name;
2273
+ try {
2274
+ navigator.share ? await navigator.share({ title: E ?? "", url: _ }) : navigator.clipboard && (await navigator.clipboard.writeText(_), C.classList.add("gengage-chat-product-details-share--copied"), setTimeout(() => C.classList.remove("gengage-chat-product-details-share--copied"), 1500));
2275
+ } catch {
2276
+ }
2277
+ }), p.appendChild(C);
2278
+ }
2279
+ p.childElementCount > 0 && s.appendChild(p), t.appendChild(s);
2280
+ const k = a.description, A = a.specifications;
2281
+ return (k || A) && t.appendChild(da(k, A, e)), t;
2282
+ }
2283
+ function da(o, e, t) {
2284
+ const a = document.createElement("div");
2285
+ a.className = "gengage-chat-product-detail-tabs";
2286
+ const n = document.createElement("div");
2287
+ n.className = "gengage-chat-product-detail-tab-bar";
2288
+ const i = [];
2289
+ if (o) {
2290
+ const s = document.createElement("button");
2291
+ s.className = "gengage-chat-product-detail-tab gengage-chat-product-detail-tab--active", s.type = "button", s.textContent = t.i18n?.productInfoTab ?? "Ürün Bilgileri", n.appendChild(s);
2292
+ const l = document.createElement("div");
2293
+ l.className = "gengage-chat-product-detail-tab-panel", l.textContent = o, i.push(l);
2294
+ }
2295
+ if (e) {
2296
+ const s = document.createElement("button");
2297
+ s.className = `gengage-chat-product-detail-tab${o ? "" : " gengage-chat-product-detail-tab--active"}`, s.type = "button", s.textContent = t.i18n?.specificationsTab ?? "Teknik Özellikler", n.appendChild(s);
2298
+ const l = document.createElement("div");
2299
+ l.className = "gengage-chat-product-detail-tab-panel", o && (l.style.display = "none");
2300
+ const g = document.createElement("table");
2301
+ g.className = "gengage-chat-product-specs-table";
2302
+ const c = Array.isArray(e) ? e : Object.entries(e).map(([h, m]) => ({ key: h, value: m }));
2303
+ for (const h of c) {
2304
+ const m = document.createElement("tr"), d = document.createElement("td");
2305
+ d.className = "gengage-chat-product-specs-key", d.textContent = h.key;
2306
+ const v = document.createElement("td");
2307
+ v.className = "gengage-chat-product-specs-value", v.textContent = h.value, m.appendChild(d), m.appendChild(v), g.appendChild(m);
2308
+ }
2309
+ l.appendChild(g), i.push(l);
2310
+ }
2311
+ const r = n.querySelectorAll(".gengage-chat-product-detail-tab");
2312
+ r.forEach((s, l) => {
2313
+ s.addEventListener("click", () => {
2314
+ r.forEach((g) => g.classList.remove("gengage-chat-product-detail-tab--active")), s.classList.add("gengage-chat-product-detail-tab--active"), i.forEach((g, c) => {
2315
+ g.style.display = c === l ? "" : "none";
2316
+ });
2317
+ });
2318
+ }), a.appendChild(n);
2319
+ for (const s of i) a.appendChild(s);
2320
+ return a;
2321
+ }
2322
+ function Te(o, e, t) {
2323
+ if (!t || t.type === "related") return o;
2324
+ const a = o.map((n) => {
2325
+ const r = e.elements[n]?.props?.product, s = r ? Number(r.price) : NaN;
2326
+ return { id: n, price: Number.isFinite(s) ? s : 1 / 0 };
2327
+ });
2328
+ return a.sort((n, i) => n.price === 1 / 0 && i.price === 1 / 0 ? 0 : n.price === 1 / 0 ? 1 : i.price === 1 / 0 ? -1 : t.direction === "desc" ? i.price - n.price : n.price - i.price), a.map((n) => n.id);
2329
+ }
2330
+ function pa(o, e, t, a) {
2331
+ const n = Te(e, t, a), i = /* @__PURE__ */ new Map();
2332
+ for (const r of Array.from(o.children)) {
2333
+ const s = r.dataset.elementId;
2334
+ s && i.set(s, r);
2335
+ }
2336
+ for (const r of n) {
2337
+ const s = i.get(r);
2338
+ s && o.appendChild(s);
2339
+ }
2340
+ }
2341
+ function ha(o, e, t, a) {
2342
+ const n = document.createElement("div");
2343
+ n.className = "gengage-chat-product-grid-wrapper";
2344
+ const i = o.children ?? [];
2345
+ if (i.length > 1 && a?.onSortChange) {
2346
+ const g = document.createElement("div");
2347
+ g.className = "gengage-chat-product-sort-toolbar";
2348
+ const c = a.productSort ?? { type: "related" }, h = [
2349
+ { label: a.i18n?.sortRelated ?? "Önerilen", sortState: { type: "related" } },
2350
+ { label: a.i18n?.sortPriceAsc ?? "Fiyat ↑", sortState: { type: "price", direction: "asc" } },
2351
+ { label: a.i18n?.sortPriceDesc ?? "Fiyat ↓", sortState: { type: "price", direction: "desc" } }
2352
+ ];
2353
+ for (const m of h) {
2354
+ const d = document.createElement("button");
2355
+ d.className = "gengage-chat-product-sort-btn", d.type = "button", c.type === m.sortState.type && c.direction === m.sortState.direction && d.classList.add("gengage-chat-product-sort-btn--active"), d.textContent = m.label, d.addEventListener("click", () => {
2356
+ a.onSortChange?.(m.sortState), pa(r, i, e, m.sortState), g.querySelectorAll(".gengage-chat-product-sort-btn").forEach((w) => w.classList.remove("gengage-chat-product-sort-btn--active")), d.classList.add("gengage-chat-product-sort-btn--active");
2357
+ }), g.appendChild(d);
2358
+ }
2359
+ if (a.onToggleComparisonSku) {
2360
+ const m = document.createElement("div");
2361
+ m.className = "gengage-chat-product-sort-separator", g.appendChild(m);
2362
+ const d = document.createElement("button");
2363
+ d.className = "gengage-chat-comparison-toggle-btn", d.type = "button", a.comparisonSelectMode && d.classList.add("gengage-chat-comparison-toggle-btn--active"), d.textContent = a.i18n?.compareSelected ?? "Karşılaştır", d.addEventListener("click", () => {
2364
+ a.onToggleComparisonSku?.("");
2365
+ }), g.appendChild(d);
2366
+ }
2367
+ n.appendChild(g);
2368
+ }
2369
+ const r = document.createElement("div");
2370
+ r.className = "gengage-chat-product-grid";
2371
+ const s = Te(i, e, a?.productSort);
2372
+ for (const g of s) {
2373
+ if (!e.elements[g]) continue;
2374
+ const c = t(g);
2375
+ c && (c.dataset.elementId = g, r.appendChild(c));
2376
+ }
2377
+ if (Ce() && r.classList.add("gengage-chat-product-grid--mobile"), n.appendChild(r), o.props?.endOfList !== !0 && i.length > 0) {
2378
+ const g = document.createElement("button");
2379
+ g.className = "gengage-chat-product-grid-view-more", g.type = "button", g.textContent = a?.i18n?.viewMoreLabel ?? "Daha Fazla Göster", g.addEventListener("click", () => {
2380
+ a?.onAction({ title: "More", type: "moreProductList", payload: {} });
2381
+ }), n.appendChild(g);
2382
+ }
2383
+ if (a?.comparisonSelectMode && a.comparisonSelectedSkus && a.comparisonSelectedSkus.length >= 2) {
2384
+ const g = Zt(a.comparisonSelectedSkus, a);
2385
+ n.appendChild(g);
2386
+ }
2387
+ return n;
2388
+ }
2389
+ function ua(o, e) {
2390
+ const t = o.props ?? {}, a = t.keyDifferencesHtml, n = t.recommended, i = t.products ?? [], r = t.attributes ?? [], s = t.highlights ?? [], l = t.specialCases, g = t.recommendedText, c = t.winnerHits, h = t.productActions;
2391
+ if (!n)
2392
+ return document.createElement("div");
2393
+ const m = {
2394
+ recommended: n,
2395
+ products: i,
2396
+ attributes: r,
2397
+ highlights: s,
2398
+ specialCases: l,
2399
+ onProductClick: (v) => {
2400
+ e.onProductClick?.({ sku: v, url: "" });
2401
+ }
2402
+ };
2403
+ g !== void 0 && (m.recommendedText = g), c !== void 0 && (m.winnerHits = c), h !== void 0 && (m.productActions = h), a !== void 0 && (m.keyDifferencesHtml = a), e.i18n && (m.i18n = {
2404
+ comparisonHeading: e.i18n.panelTitleComparisonResults,
2405
+ recommendedChoiceLabel: e.i18n.recommendedChoiceLabel,
2406
+ highlightsLabel: e.i18n.highlightsLabel,
2407
+ keyDifferencesLabel: e.i18n.keyDifferencesLabel,
2408
+ specialCasesLabel: e.i18n.specialCasesLabel,
2409
+ addToCartButton: e.i18n.addToCartButton
2410
+ });
2411
+ const d = jt(m);
2412
+ return Ce() && d.classList.add("gengage-chat-comparison--mobile"), d;
2413
+ }
2414
+ function ma(o) {
2415
+ const e = document.createElement("hr");
2416
+ e.className = "gengage-chat-divider";
2417
+ const t = o.props?.label;
2418
+ if (t) {
2419
+ const a = document.createElement("div");
2420
+ a.className = "gengage-chat-divider-wrapper";
2421
+ const n = document.createElement("span");
2422
+ return n.className = "gengage-chat-divider-label", n.textContent = t, a.appendChild(e), a.appendChild(n), a;
2423
+ }
2424
+ return e;
2425
+ }
2426
+ const fa = /* @__PURE__ */ new Set([
2427
+ "P",
2428
+ "DIV",
2429
+ "H1",
2430
+ "H2",
2431
+ "H3",
2432
+ "H4",
2433
+ "H5",
2434
+ "H6",
2435
+ "LI",
2436
+ "UL",
2437
+ "OL",
2438
+ "BLOCKQUOTE",
2439
+ "PRE",
2440
+ "TABLE",
2441
+ "SECTION",
2442
+ "HR",
2443
+ "FIGURE",
2444
+ "FIGCAPTION",
2445
+ "DL",
2446
+ "DT",
2447
+ "DD"
2448
+ ]);
2449
+ function ba(o) {
2450
+ const e = [];
2451
+ let t = [];
2452
+ for (const a of o)
2453
+ a.nodeType === Node.ELEMENT_NODE && fa.has(a.tagName) ? (t.length > 0 && (e.push(t), t = []), e.push([a])) : t.push(a);
2454
+ return t.length > 0 && e.push(t), e;
2455
+ }
2456
+ function xa(o) {
2457
+ for (const e of o)
2458
+ for (const t of e)
2459
+ if (t.nodeType === Node.ELEMENT_NODE && (t.tagName === "TABLE" || t.querySelector?.("table")))
2460
+ return !0;
2461
+ return !1;
2462
+ }
2463
+ function va() {
2464
+ return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
2465
+ }
2466
+ function wa(o) {
2467
+ const { container: e, html: t, delayMs: a = 30, onTick: n, onComplete: i } = o, r = document.createElement("template");
2468
+ r.innerHTML = t;
2469
+ const s = ba(r.content.childNodes);
2470
+ if (va() || s.length <= 1 || xa(s))
2471
+ return e.innerHTML = t, i?.(), { complete() {
2472
+ }, cancel() {
2473
+ }, isRunning: !1 };
2474
+ e.innerHTML = "";
2475
+ let l = 0, g = null, c = !0;
2476
+ function h() {
2477
+ if (!c || l >= s.length) {
2478
+ c = !1, i?.();
2479
+ return;
2480
+ }
2481
+ const m = s[l], d = document.createElement("span");
2482
+ d.className = "gengage-chat-typewriter-block";
2483
+ for (const v of m)
2484
+ d.appendChild(v.cloneNode(!0));
2485
+ e.appendChild(d), l++, n?.(), l < s.length ? g = setTimeout(h, a) : (c = !1, i?.());
2486
+ }
2487
+ return h(), {
2488
+ complete() {
2489
+ c && (g !== null && clearTimeout(g), c = !1, e.innerHTML = t, i?.());
2490
+ },
2491
+ cancel() {
2492
+ g !== null && clearTimeout(g), c = !1;
2493
+ },
2494
+ get isRunning() {
2495
+ return c;
2496
+ }
2497
+ };
2498
+ }
2499
+ function ya(o) {
2500
+ const { container: e, mentions: t, onProductClick: a } = o;
2501
+ if (t.length === 0) return;
2502
+ const n = /* @__PURE__ */ new Map();
2503
+ for (const i of t)
2504
+ i.short_name.length !== 0 && n.set(i.short_name.toLowerCase(), i);
2505
+ if (n.size !== 0)
2506
+ for (const [i, r] of n) {
2507
+ const s = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
2508
+ let l = s.nextNode(), g = !1;
2509
+ for (; l && !g; ) {
2510
+ const c = l.textContent ?? "", h = c.toLowerCase().indexOf(i);
2511
+ if (h === -1) {
2512
+ l = s.nextNode();
2513
+ continue;
2514
+ }
2515
+ const m = c.slice(0, h), d = c.slice(h, h + r.short_name.length), v = c.slice(h + r.short_name.length), w = l.parentNode;
2516
+ if (!w) {
2517
+ l = s.nextNode();
2518
+ continue;
2519
+ }
2520
+ const b = document.createElement("a");
2521
+ b.className = "gengage-product-mention", b.textContent = d, b.href = "#", b.addEventListener("click", (N) => {
2522
+ N.preventDefault(), a(r.sku);
2523
+ }), m && w.insertBefore(document.createTextNode(m), l), w.insertBefore(b, l), v && w.insertBefore(document.createTextNode(v), l), w.removeChild(l), g = !0;
2524
+ }
2525
+ }
2526
+ }
2527
+ const _a = /* @__PURE__ */ new Set(["search", "info", "review", "similar"]), ka = /* @__PURE__ */ new Set([
2528
+ "quickAnswer",
2529
+ "reviewSummary",
2530
+ "searchDiscovery",
2531
+ "launchDiscovery",
2532
+ "exploreTogetherV2"
2533
+ ]);
2534
+ function Ca(o) {
2535
+ return !!(o.icon && _a.has(o.icon) || o.action?.type && ka.has(o.action.type));
2536
+ }
2537
+ const Ie = "gengage_choice_prompter_dismissed";
2538
+ function Ea(o) {
2539
+ const e = document.createElement("div");
2540
+ e.className = "gengage-chat-choice-prompter";
2541
+ const t = document.createElement("div");
2542
+ t.className = "gengage-chat-choice-prompter-heading", t.textContent = o.heading, e.appendChild(t);
2543
+ const a = document.createElement("div");
2544
+ a.className = "gengage-chat-choice-prompter-suggestion", a.textContent = o.suggestion, e.appendChild(a);
2545
+ const n = document.createElement("button");
2546
+ n.type = "button", n.className = "gengage-chat-choice-prompter-cta", n.textContent = o.ctaLabel, n.addEventListener("click", () => {
2547
+ pe(), e.remove(), o.onCtaClick();
2548
+ }), e.appendChild(n);
2549
+ const i = document.createElement("button");
2550
+ return i.type = "button", i.className = "gengage-chat-choice-prompter-dismiss", i.textContent = "×", i.setAttribute("aria-label", "Dismiss"), i.addEventListener("click", () => {
2551
+ pe(), e.remove(), o.onDismiss?.();
2552
+ }), e.appendChild(i), e;
2553
+ }
2554
+ function Sa() {
2555
+ try {
2556
+ return sessionStorage.getItem(Ie) === "1";
2557
+ } catch {
2558
+ return !1;
2559
+ }
2560
+ }
2561
+ function pe() {
2562
+ try {
2563
+ sessionStorage.setItem(Ie, "1");
2564
+ } catch {
2565
+ }
2566
+ }
2567
+ const Ta = "gengage_assistant", Ia = 3, W = "sessions", q = "context", V = "payload", j = "favorites";
2568
+ function ee(o) {
2569
+ return new Promise((e, t) => {
2570
+ o.onsuccess = () => e(o.result), o.onerror = () => t(o.error);
2571
+ });
2572
+ }
2573
+ function J(o) {
2574
+ return new Promise((e, t) => {
2575
+ o.oncomplete = () => e(), o.onerror = () => t(o.error), o.onabort = () => t(o.error ?? new DOMException("Transaction aborted"));
2576
+ });
2577
+ }
2578
+ class La {
2579
+ constructor(e = Ta, t = Ia) {
2580
+ this._db = null, this._dbName = e, this._version = t;
2581
+ }
2582
+ // -------------------------------------------------------------------------
2583
+ // Lifecycle
2584
+ // -------------------------------------------------------------------------
2585
+ async open() {
2586
+ return this._db ? this._db : new Promise((e, t) => {
2587
+ const a = indexedDB.open(this._dbName, this._version);
2588
+ a.onupgradeneeded = (n) => {
2589
+ const i = a.result, r = n.oldVersion;
2590
+ r < 1 && (i.createObjectStore(W, { keyPath: ["userId", "appId", "sessionId"] }), i.createObjectStore(q, { keyPath: ["sessionId", "threadId"] }), i.createObjectStore(V, {
2591
+ keyPath: ["threadId", "messageId"]
2592
+ }).createIndex("threadId", "threadId", { unique: !1 }), i.createObjectStore(j, { keyPath: ["userId", "appId", "sku"] })), r >= 1 && r < 2 && (i.objectStoreNames.contains(W) && i.deleteObjectStore(W), i.objectStoreNames.contains(V) && i.deleteObjectStore(V), i.createObjectStore(W, { keyPath: ["userId", "appId", "sessionId"] }), i.createObjectStore(V, {
2593
+ keyPath: ["threadId", "messageId"]
2594
+ }).createIndex("threadId", "threadId", { unique: !1 }), i.objectStoreNames.contains(q) || i.createObjectStore(q, { keyPath: ["sessionId", "threadId"] })), r < 3 && (i.objectStoreNames.contains(j) || i.createObjectStore(j, { keyPath: ["userId", "appId", "sku"] }));
2595
+ }, a.onsuccess = () => {
2596
+ this._db = a.result, e(this._db);
2597
+ }, a.onerror = () => t(a.error);
2598
+ });
2599
+ }
2600
+ close() {
2601
+ this._db?.close(), this._db = null;
2602
+ }
2603
+ // -------------------------------------------------------------------------
2604
+ // Sessions
2605
+ // -------------------------------------------------------------------------
2606
+ async saveSession(e) {
2607
+ const a = this._requireDb().transaction(W, "readwrite");
2608
+ a.objectStore(W).put(e), await J(a);
2609
+ }
2610
+ async loadSession(e, t, a) {
2611
+ const i = this._requireDb().transaction(W, "readonly");
2612
+ return await ee(i.objectStore(W).get([e, t, a])) ?? null;
2613
+ }
2614
+ // -------------------------------------------------------------------------
2615
+ // Context (compound key: [sessionId, threadId])
2616
+ // -------------------------------------------------------------------------
2617
+ async saveContext(e) {
2618
+ const a = this._requireDb().transaction(q, "readwrite");
2619
+ a.objectStore(q).put(e), await J(a);
2620
+ }
2621
+ async loadContext(e, t) {
2622
+ const n = this._requireDb().transaction(q, "readonly");
2623
+ return await ee(n.objectStore(q).get([e, t])) ?? null;
2624
+ }
2625
+ /**
2626
+ * Delete all context entries for a session whose threadId is lexicographically
2627
+ * greater than the given threadId. Used during rollback to prune future branches.
2628
+ *
2629
+ * Thread IDs are UUIDv7 (lexicographically sortable by time), so string
2630
+ * comparison is sufficient.
2631
+ */
2632
+ async deleteContextsAfterThread(e, t) {
2633
+ const n = this._requireDb().transaction(q, "readwrite"), r = n.objectStore(q).openCursor();
2634
+ await new Promise((s, l) => {
2635
+ r.onsuccess = () => {
2636
+ const g = r.result;
2637
+ if (!g) {
2638
+ s();
2639
+ return;
2640
+ }
2641
+ const c = g.value;
2642
+ if (c.sessionId === e && c.threadId > t)
2643
+ try {
2644
+ g.delete();
2645
+ } catch {
2646
+ }
2647
+ g.continue();
2648
+ }, r.onerror = () => l(r.error);
2649
+ }), await J(n);
2650
+ }
2651
+ /**
2652
+ * Load the most recent context for a session (latest threadId).
2653
+ * Uses lexicographic ordering of UUIDv7 threadIds for chronological sort.
2654
+ */
2655
+ async loadLatestContext(e) {
2656
+ const n = this._requireDb().transaction(q, "readonly").objectStore(q), i = IDBKeyRange.bound([e, ""], [e, "￿"]);
2657
+ return new Promise((r, s) => {
2658
+ const l = n.openCursor(i, "prev");
2659
+ l.onsuccess = () => {
2660
+ const g = l.result;
2661
+ r(g ? g.value : null);
2662
+ }, l.onerror = () => s(l.error);
2663
+ });
2664
+ }
2665
+ // -------------------------------------------------------------------------
2666
+ // Payload
2667
+ // -------------------------------------------------------------------------
2668
+ async savePayload(e) {
2669
+ const a = this._requireDb().transaction(V, "readwrite");
2670
+ a.objectStore(V).put(e), await J(a);
2671
+ }
2672
+ async loadPayload(e, t) {
2673
+ const n = this._requireDb().transaction(V, "readonly");
2674
+ return await ee(n.objectStore(V).get([e, t])) ?? null;
2675
+ }
2676
+ async loadPayloadsByThread(e) {
2677
+ const n = this._requireDb().transaction(V, "readonly").objectStore(V).index("threadId"), i = [];
2678
+ return new Promise((r, s) => {
2679
+ const l = n.openCursor(IDBKeyRange.only(e));
2680
+ l.onsuccess = () => {
2681
+ const g = l.result;
2682
+ if (!g) {
2683
+ r(i);
2684
+ return;
2685
+ }
2686
+ i.push(g.value), g.continue();
2687
+ }, l.onerror = () => s(l.error);
2688
+ });
2689
+ }
2690
+ // -------------------------------------------------------------------------
2691
+ // Favorites
2692
+ // -------------------------------------------------------------------------
2693
+ async saveFavorite(e) {
2694
+ const a = this._requireDb().transaction(j, "readwrite");
2695
+ a.objectStore(j).put(e), await J(a);
2696
+ }
2697
+ async removeFavorite(e, t, a) {
2698
+ const i = this._requireDb().transaction(j, "readwrite");
2699
+ i.objectStore(j).delete([e, t, a]), await J(i);
2700
+ }
2701
+ async loadFavorites(e, t) {
2702
+ const n = this._requireDb().transaction(j, "readonly");
2703
+ return (await ee(n.objectStore(j).getAll())).filter((r) => r.userId === e && r.appId === t);
2704
+ }
2705
+ async isFavorite(e, t, a) {
2706
+ const i = this._requireDb().transaction(j, "readonly");
2707
+ return await ee(i.objectStore(j).get([e, t, a])) !== void 0;
2708
+ }
2709
+ // -------------------------------------------------------------------------
2710
+ // Internal
2711
+ // -------------------------------------------------------------------------
2712
+ _requireDb() {
2713
+ if (!this._db)
2714
+ throw new Error("GengageIndexedDB: database not open. Call open() first.");
2715
+ return this._db;
2716
+ }
2717
+ }
2718
+ const Na = [
2719
+ "comparisonTable",
2720
+ "groupList",
2721
+ "productDetailsSimilars",
2722
+ "productList"
2723
+ ];
2724
+ class Aa {
2725
+ constructor(e) {
2726
+ this._lockCount = 1, this._hiddenByUser = !1, this._lastPanelContentType = null, this._chatShown = !1, this._isFavoritesMode = !1, this._lastExtended = !1, this._onChange = e.onChange;
2727
+ const t = new Set(Na);
2728
+ e.productDetailsInPanel && t.add("productDetails"), this._panelContentTypes = t;
2729
+ }
2730
+ get isExtended() {
2731
+ return this._lockCount === 0 && !this._hiddenByUser && !this._isFavoritesMode && this._lastPanelContentType !== null && this._panelContentTypes.has(this._lastPanelContentType) && this._chatShown;
2732
+ }
2733
+ unlock() {
2734
+ this._lockCount > 0 && this._lockCount--, this._checkStateChange();
2735
+ }
2736
+ lock() {
2737
+ this._lockCount++, this._checkStateChange();
2738
+ }
2739
+ setHiddenByUser(e) {
2740
+ this._hiddenByUser = e, this._checkStateChange();
2741
+ }
2742
+ setChatShown(e) {
2743
+ this._chatShown = e, this._checkStateChange();
2744
+ }
2745
+ setFavoritesMode(e) {
2746
+ this._isFavoritesMode = e, this._checkStateChange();
2747
+ }
2748
+ setPanelContentType(e) {
2749
+ this._lastPanelContentType = e, this._checkStateChange();
2750
+ }
2751
+ _checkStateChange() {
2752
+ const e = this.isExtended;
2753
+ e !== this._lastExtended && (this._lastExtended = e, this._onChange(e));
2754
+ }
2755
+ }
2756
+ class Pa {
2757
+ constructor(e) {
2758
+ this.deps = e, this.snapshots = /* @__PURE__ */ new Map(), this.snapshotTypes = /* @__PURE__ */ new Map(), this.activePanelMessageId = null, this.currentType = null, this.threads = [];
2759
+ }
2760
+ /**
2761
+ * Deep-clone the current panel content (excluding topbar/thumbnails) and store
2762
+ * it keyed by message ID. Called when a stream completes so panel content can
2763
+ * be restored later without duplicating the topbar.
2764
+ */
2765
+ snapshotForMessage(e) {
2766
+ const t = this.deps.drawer();
2767
+ if (!t?.hasPanelContent() || t.isPanelLoading()) return;
2768
+ const a = t.getPanelContentElement();
2769
+ if (!a) return;
2770
+ const n = a.cloneNode(!0);
2771
+ this.snapshots.set(e, n), this.currentType && this.snapshotTypes.set(e, this.currentType);
2772
+ }
2773
+ /**
2774
+ * Attach a click handler to a bot message bubble so clicking it restores
2775
+ * the panel content that was active when that message was received.
2776
+ */
2777
+ attachClickHandler(e) {
2778
+ const a = this.deps.shadow()?.querySelector(`[data-message-id="${CSS.escape(e)}"]`);
2779
+ a && (a.style.cursor = "pointer", a.addEventListener("click", () => this.restoreForMessage(e)));
2780
+ }
2781
+ /**
2782
+ * Restore the panel content snapshot associated with a given message ID.
2783
+ * Highlights the active message and de-highlights the previous one.
2784
+ * Also restores the panel topbar title for the snapshot's component type.
2785
+ * Returns true if the snapshot was found and restored.
2786
+ */
2787
+ restoreForMessage(e) {
2788
+ const t = this.snapshots.get(e);
2789
+ if (!t) return !1;
2790
+ const a = this.deps.shadow(), n = this.deps.drawer();
2791
+ this.activePanelMessageId && a?.querySelector(`[data-message-id="${CSS.escape(this.activePanelMessageId)}"]`)?.classList.remove("gengage-chat-bubble--active"), a?.querySelector(`[data-message-id="${CSS.escape(e)}"]`)?.classList.add("gengage-chat-bubble--active"), this.activePanelMessageId = e, n?.setPanelContent(t.cloneNode(!0));
2792
+ const r = this.snapshotTypes.get(e);
2793
+ return r && (this.currentType = r, this.updateTopBar(r)), !0;
2794
+ }
2795
+ /**
2796
+ * Send maximize-pdp / minify-pdp bridge messages with production-matching delays.
2797
+ * Called by the extended mode manager when panel extension state changes.
2798
+ */
2799
+ notifyExtension(e) {
2800
+ const t = this.deps.bridge();
2801
+ e ? setTimeout(() => t?.send("maximize-pdp", {}), 350) : setTimeout(() => t?.send("minify-pdp", {}), 200);
2802
+ }
2803
+ /**
2804
+ * Derive panel title from UISpec root element type using i18n strings.
2805
+ */
2806
+ titleForComponent(e) {
2807
+ const t = this.deps.i18n();
2808
+ switch (e) {
2809
+ case "ProductDetailsPanel":
2810
+ return t.panelTitleProductDetails;
2811
+ case "ProductGrid":
2812
+ return t.panelTitleSimilarProducts;
2813
+ case "ComparisonTable":
2814
+ return t.panelTitleComparisonResults;
2815
+ case "AIGroupingCards":
2816
+ return t.panelTitleCategories;
2817
+ default:
2818
+ return "";
2819
+ }
2820
+ }
2821
+ /**
2822
+ * Update the panel top bar navigation state and title.
2823
+ */
2824
+ updateTopBar(e) {
2825
+ const t = this.deps.currentThreadId();
2826
+ if (!t) return;
2827
+ const a = this.threads.indexOf(t), n = a > 0, i = a >= 0 && a < this.threads.length - 1, r = this.titleForComponent(e);
2828
+ this.deps.drawer()?.updatePanelTopBar(n, i, r);
2829
+ }
2830
+ /**
2831
+ * Set panel topbar title during loading (before actual panel content arrives).
2832
+ * Maps backend pending types to the same i18n titles used for final content.
2833
+ */
2834
+ updateTopBarForLoading(e) {
2835
+ const t = this.deps.i18n(), n = {
2836
+ productDetails: t.panelTitleProductDetails,
2837
+ productList: t.panelTitleSimilarProducts,
2838
+ comparisonTable: t.panelTitleComparisonResults,
2839
+ groupList: t.panelTitleCategories
2840
+ }[e] ?? "";
2841
+ if (n) {
2842
+ const i = this.deps.currentThreadId(), r = i ? this.threads.indexOf(i) : -1, s = r > 0, l = r >= 0 && r < this.threads.length - 1;
2843
+ this.deps.drawer()?.updatePanelTopBar(s, l, n);
2844
+ }
2845
+ }
2846
+ /**
2847
+ * Map UISpec component types to PanelContentType for the extended mode manager.
2848
+ */
2849
+ updateExtendedMode(e) {
2850
+ const a = {
2851
+ ComparisonTable: "comparisonTable",
2852
+ AIGroupingCards: "groupList",
2853
+ ProductDetailsPanel: "productDetails",
2854
+ ProductGrid: "productList"
2855
+ }[e] ?? null;
2856
+ this.deps.extendedModeManager()?.setPanelContentType(a);
2857
+ }
2858
+ /** Navigate to the previous panel thread. */
2859
+ navigateBack() {
2860
+ const e = this.deps.currentThreadId();
2861
+ if (!e) return;
2862
+ const t = this.threads.indexOf(e);
2863
+ if (t > 0) {
2864
+ const a = this.threads[t - 1];
2865
+ a && this.deps.rollbackToThread(a);
2866
+ }
2867
+ }
2868
+ /** Navigate to the next panel thread. */
2869
+ navigateForward() {
2870
+ const e = this.deps.currentThreadId();
2871
+ if (!e) return;
2872
+ const t = this.threads.indexOf(e);
2873
+ if (t >= 0 && t < this.threads.length - 1) {
2874
+ const a = this.threads[t + 1];
2875
+ a && this.deps.rollbackToThread(a);
2876
+ }
2877
+ }
2878
+ /**
2879
+ * Panel route shaping:
2880
+ * - product details => expanded LHS panel (`ProductDetailsPanel`)
2881
+ * - all other panel-routed specs keep their original component types
2882
+ */
2883
+ toPanelSpec(e) {
2884
+ const t = e.elements[e.root];
2885
+ if (!t || t.type !== "ProductCard") return e;
2886
+ const a = {
2887
+ ...t,
2888
+ type: "ProductDetailsPanel"
2889
+ };
2890
+ return {
2891
+ root: e.root,
2892
+ elements: {
2893
+ ...e.elements,
2894
+ [e.root]: a
2895
+ }
2896
+ };
2897
+ }
2898
+ destroy() {
2899
+ this.snapshots.clear(), this.snapshotTypes.clear(), this.activePanelMessageId = null, this.currentType = null, this.threads = [];
2900
+ }
2901
+ }
2902
+ class he {
2903
+ constructor(e) {
2904
+ this.favoritedSkus = /* @__PURE__ */ new Set(), this._db = e;
2905
+ }
2906
+ get db() {
2907
+ return this._db;
2908
+ }
2909
+ set db(e) {
2910
+ this._db = e;
2911
+ }
2912
+ /**
2913
+ * Persist current session state to IndexedDB.
2914
+ * Called after each stream completion (onDone). Non-fatal on failure.
2915
+ */
2916
+ async persist(e) {
2917
+ if (!this._db) return;
2918
+ const t = e.messages.map((n) => {
2919
+ const i = {
2920
+ id: n.id,
2921
+ role: n.role,
2922
+ timestamp: n.timestamp,
2923
+ status: n.status === "streaming" ? "done" : n.status
2924
+ };
2925
+ return n.threadId !== void 0 && (i.threadId = n.threadId), n.content !== void 0 && (i.content = n.content), n.silent && (i.silent = !0), i;
2926
+ }), a = {};
2927
+ for (const [n, i] of e.panelSnapshots)
2928
+ i.querySelector(".gengage-chat-panel-skeleton") || (a[n] = i.innerHTML);
2929
+ await this._db.saveSession({
2930
+ userId: e.userId,
2931
+ appId: e.appId,
2932
+ sessionId: e.sessionId,
2933
+ messages: t,
2934
+ currentThreadId: e.currentThreadId,
2935
+ lastThreadId: e.lastThreadId,
2936
+ createdAt: e.chatCreatedAt,
2937
+ panelThreads: e.panelThreads.length > 0 ? e.panelThreads : void 0,
2938
+ thumbnailEntries: e.thumbnailEntries.length > 0 ? e.thumbnailEntries : void 0,
2939
+ panelSnapshotHtml: Object.keys(a).length > 0 ? a : void 0
2940
+ }), e.lastBackendContext && e.currentThreadId && await this._db.saveContext({
2941
+ sessionId: e.sessionId,
2942
+ threadId: e.currentThreadId,
2943
+ context: e.lastBackendContext
2944
+ });
2945
+ for (const n of e.messages)
2946
+ n.uiSpec && n.threadId && await this._db.savePayload({
2947
+ threadId: n.threadId,
2948
+ messageId: n.id,
2949
+ uiSpec: n.uiSpec
2950
+ });
2951
+ try {
2952
+ sessionStorage.setItem("gengage_restore_session_id", e.sessionId);
2953
+ } catch {
2954
+ }
2955
+ }
2956
+ /**
2957
+ * Persist session to IndexedDB, then navigate to the URL.
2958
+ * Sends an 'openURLInNewTab' bridge message so the host page can intercept
2959
+ * (e.g. for SPA routing), then navigates directly as fallback.
2960
+ *
2961
+ * Legacy compatibility: robot-engine-lean navigated via window.location.href
2962
+ * after posting saveSessionAndOpenURL to the iframe. The clean-room runs in
2963
+ * the same window (Shadow DOM, not iframe), so it navigates directly.
2964
+ */
2965
+ async saveAndOpenURL(e, t, a) {
2966
+ try {
2967
+ await t();
2968
+ } catch {
2969
+ }
2970
+ a?.send("openURLInNewTab", { url: e }), window.location.href = e;
2971
+ }
2972
+ /**
2973
+ * Load a UISpec payload from IndexedDB with retry logic.
2974
+ * Returns null if not found or all retries fail.
2975
+ */
2976
+ async loadPayload(e, t) {
2977
+ if (!this._db) return null;
2978
+ for (let a = 0; a < 3; a++) {
2979
+ try {
2980
+ const n = await this._db.loadPayload(e, t);
2981
+ if (n) return n.uiSpec;
2982
+ } catch {
2983
+ }
2984
+ a < 2 && await new Promise((n) => setTimeout(n, 100));
2985
+ }
2986
+ return null;
2987
+ }
2988
+ /**
2989
+ * Load favorited SKUs from IDB into the in-memory set.
2990
+ */
2991
+ async loadFavorites(e, t) {
2992
+ if (this._db)
2993
+ try {
2994
+ const a = await this._db.loadFavorites(e, t);
2995
+ for (const n of a) this.favoritedSkus.add(n.sku);
2996
+ } catch {
2997
+ }
2998
+ }
2999
+ /**
3000
+ * Toggle a product's favorited state in IDB and in-memory set.
3001
+ */
3002
+ async toggleFavorite(e, t, a, n) {
3003
+ this._db && (this.favoritedSkus.has(a) ? (this.favoritedSkus.delete(a), await this._db.removeFavorite(e, t, a)) : (this.favoritedSkus.add(a), await this._db.saveFavorite({
3004
+ userId: e,
3005
+ appId: t,
3006
+ sku: a,
3007
+ name: n.name,
3008
+ imageUrl: n.imageUrl,
3009
+ price: n.price,
3010
+ savedAt: (/* @__PURE__ */ new Date()).toISOString()
3011
+ })));
3012
+ }
3013
+ close() {
3014
+ this._db?.close(), this._db = null;
3015
+ }
3016
+ }
3017
+ const Le = "gengage_kvkk_shown", Ba = ["kvkk", "kişisel veri", "kisisel veri"], Ma = /\b6698\b/;
3018
+ function le(o) {
3019
+ const e = o.toLowerCase();
3020
+ return Ba.some((t) => e.includes(t)) || Ma.test(e);
3021
+ }
3022
+ function ue(o) {
3023
+ try {
3024
+ return localStorage.getItem(`${Le}_${o}`) === "1";
3025
+ } catch {
3026
+ return !1;
3027
+ }
3028
+ }
3029
+ function za(o) {
3030
+ try {
3031
+ localStorage.setItem(`${Le}_${o}`, "1");
3032
+ } catch {
3033
+ }
3034
+ }
3035
+ function Da(o) {
3036
+ const t = new DOMParser().parseFromString(o, "text/html").body, a = Array.from(t.children);
3037
+ for (const n of a)
3038
+ if (le(n.textContent ?? "")) {
3039
+ n.remove();
3040
+ break;
3041
+ }
3042
+ return t.innerHTML.trim();
3043
+ }
3044
+ function Ra(o) {
3045
+ const e = new DOMParser().parseFromString(o, "text/html");
3046
+ for (const t of Array.from(e.body.children))
3047
+ if (le(t.textContent ?? ""))
3048
+ return t.outerHTML;
3049
+ return null;
3050
+ }
3051
+ const Ua = {
3052
+ tr: "TURKISH",
3053
+ en: "ENGLISH",
3054
+ de: "GERMAN",
3055
+ fr: "FRENCH"
3056
+ };
3057
+ function Ha(o) {
3058
+ return o ? Ua[o.toLowerCase().slice(0, 2)] ?? "TURKISH" : "TURKISH";
3059
+ }
3060
+ const Fa = ':host{all:initial;font-family:var(--gengage-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:var(--gengage-font-size, 14px)}.gengage-chat-root{position:fixed;z-index:var(--gengage-z-index, 2147483647);--_gengage-chat-offset: var(--gengage-chat-offset, 20px);--_gengage-chat-launcher-bottom: var(--gengage-chat-launcher-bottom, 20px);--_gengage-chat-launcher-right: var(--gengage-chat-launcher-right, 20px);--_gengage-chat-launcher-size: var(--gengage-chat-launcher-size, 56px);--_gengage-chat-drawer-width: var(--gengage-chat-width, 400px);--_gengage-chat-radius: var(--gengage-chat-shell-radius, 12px);--_gengage-chat-header-height: var(--gengage-chat-header-height, 60px);--_gengage-chat-conversation-width: var(--gengage-chat-conversation-width, 396px);--_gengage-chat-panel-min-width: var(--gengage-chat-panel-min-width, 320px);--_gengage-chat-panel-max-width: var(--gengage-chat-panel-max-width, 860px);--_gengage-chat-input-height: var(--gengage-chat-input-height, 48px);--_gengage-chat-shadow: var(--gengage-chat-shadow, 0 12px 40px rgba(15, 23, 42, .18));--_gengage-border-color: var(--gengage-border-color, #e5e7eb);--_gengage-discount-color: var(--gengage-discount-color, #ef4444);--_gengage-success-color: var(--gengage-success-color, #16a34a);--_gengage-text-secondary: var(--gengage-text-secondary, #64748b);--_gengage-qty-btn-size: var(--gengage-qty-btn-size, 28px);--_gengage-qty-btn-size-compact: var(--gengage-qty-btn-size-compact, 24px)}.gengage-chat-launcher-container{position:fixed;bottom:var(--_gengage-chat-launcher-bottom);right:var(--_gengage-chat-launcher-right);display:flex;flex-direction:column;align-items:flex-end;gap:10px;z-index:var(--gengage-z-index, 2147483647)}.gengage-chat-launcher-content-area,.gengage-chat-launcher-content-area-bottom{display:flex;flex-direction:column;align-items:flex-end;gap:8px}.gengage-chat-launcher-content-area:empty,.gengage-chat-launcher-content-area-bottom:empty{display:none}.gengage-chat-root--open .gengage-chat-launcher-content-area,.gengage-chat-root--open .gengage-chat-launcher-content-area-bottom{display:none}.gengage-chat-launcher{width:var(--_gengage-chat-launcher-size);height:var(--_gengage-chat-launcher-size);border-radius:50%;border:none;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 8px 22px #0f172a47;transition:transform .18s cubic-bezier(.2,.8,.2,1),box-shadow .18s ease;position:relative;flex-shrink:0}.gengage-chat-launcher:hover{transform:scale(1.05);box-shadow:0 14px 28px #0f172a47}.gengage-chat-launcher svg{width:24px;height:24px}.gengage-chat-launcher--hidden-mobile{display:none!important}.gengage-chat-launcher-tooltip{position:absolute;right:calc(100% + 12px);top:50%;transform:translateY(-50%);padding:6px 12px;border-radius:8px;background:#1e293b;color:#fff;font-size:13px;font-weight:500;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .2s ease;box-shadow:0 2px 8px #00000026}.gengage-chat-launcher-tooltip:after{content:"";position:absolute;left:100%;top:50%;transform:translateY(-50%);border:5px solid transparent;border-left-color:#1e293b}.gengage-chat-launcher:hover .gengage-chat-launcher-tooltip{opacity:1}.gengage-chat-root--open .gengage-chat-launcher-tooltip{display:none}.gengage-chat-proactive{position:fixed;bottom:calc(var(--_gengage-chat-launcher-bottom) + var(--_gengage-chat-launcher-size) + 14px);right:var(--_gengage-chat-launcher-right);width:280px;padding:16px 18px;border-radius:16px;background:#fff;box-shadow:0 8px 30px #0000001f,0 2px 8px #0000000f;opacity:0;transform:translateY(8px) scale(.96);transition:opacity .25s ease,transform .25s ease;z-index:2147483645}.gengage-chat-proactive--visible{opacity:1;transform:translateY(0) scale(1)}.gengage-chat-proactive-message{margin:0 0 12px;font-size:14px;line-height:1.5;color:#1f2937}.gengage-chat-proactive-actions{display:flex;gap:8px}.gengage-chat-proactive-accept{flex:1;padding:8px 16px;border:none;border-radius:10px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .15s ease}.gengage-chat-proactive-accept:hover{filter:brightness(1.08)}.gengage-chat-proactive-dismiss{position:absolute;top:8px;right:8px;width:24px;height:24px;border:none;border-radius:50%;background:transparent;color:#64748b;font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center}.gengage-chat-proactive-dismiss:hover{color:#475569;background:#f1f5f9}.gengage-chat-drawer{position:fixed;top:0;bottom:0;right:0;width:var(--_gengage-chat-drawer-width);max-height:-webkit-fill-available;max-height:100dvh;border-radius:0;background:var(--gengage-background-color, #fff);box-shadow:var(--_gengage-chat-shadow);display:flex;flex-direction:column;overflow:hidden;z-index:var(--gengage-z-index, 2147483647);transform-origin:right center;clip-path:inset(0);transition:clip-path .42s cubic-bezier(.25,.46,.45,.94),opacity .32s ease}.gengage-chat-root--mobile .gengage-chat-launcher-container{right:16px;bottom:calc(16px + env(safe-area-inset-bottom))}.gengage-chat-root--mobile .gengage-chat-drawer{left:0;right:0;bottom:0;width:100%;max-width:none;max-height:-webkit-fill-available;max-height:100dvh;border-radius:16px 16px 0 0;padding-bottom:env(safe-area-inset-bottom,0px);clip-path:inset(0);transition:clip-path .42s cubic-bezier(.25,.46,.45,.94),opacity .32s ease}.gengage-chat-root--mobile.gengage-chat-root--mobile-half .gengage-chat-drawer{top:auto;height:min(72dvh,620px);max-height:min(72dvh,620px)}.gengage-chat-root--mobile.gengage-chat-root--mobile-full .gengage-chat-drawer{top:0;height:100dvh;max-height:100dvh;border-radius:0}.gengage-chat-root--mobile .gengage-chat-input-area{padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));transform:translateY(calc(-1 * var(--gengage-keyboard-offset, 0px)))}.gengage-chat-header{display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;min-height:var(--_gengage-chat-header-height);padding:4px 12px;background:var(--gengage-chat-header-bg, #1d2939);color:var(--gengage-chat-header-foreground, #fff);box-shadow:0 4px 20px #00000014,0 0 2px #0000001f;border:none;position:relative;z-index:2}.gengage-chat-header-left{display:flex;align-items:center;gap:10px;min-width:0}.gengage-chat-header-avatar{width:40px;height:40px;border-radius:50%;object-fit:cover;flex-shrink:0;border:2px solid rgba(255,255,255,.15)}.gengage-chat-header-info{display:flex;flex-direction:column;gap:2px;min-width:0}.gengage-chat-header-title-row{display:flex;align-items:center;gap:6px}.gengage-chat-header-title{font-weight:700;font-size:15px;line-height:1.25;letter-spacing:.01em;color:inherit}.gengage-chat-header-badge{display:inline-flex;align-items:center;padding:1px 6px;border-radius:4px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;line-height:1.5}.gengage-chat-header-powered{display:flex;align-items:center;gap:4px;font-size:11px;color:#ffffffbf;text-decoration:none;transition:color .15s}.gengage-chat-header-powered:hover{color:#fffc}.gengage-chat-header-powered svg{width:12px;height:12px;opacity:.6}.gengage-chat-header-right{display:flex;align-items:center;gap:4px;flex-shrink:0}.gengage-chat-header-btn{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;text-decoration:none;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-header-btn:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-close{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;font-size:18px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-close:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-body{display:flex;flex:1;overflow:hidden;min-height:0}.gengage-chat-panel{display:none;width:0;overflow:hidden;transition:width .22s cubic-bezier(.2,.72,.2,1)}.gengage-chat-panel--visible{display:flex;flex-direction:column;position:relative;width:440px;min-width:440px;border-right:1px solid var(--_gengage-border-color);overflow-y:auto;padding:16px;background:#f8fafc}.gengage-chat-panel-divider{display:flex;align-items:center;width:4px;cursor:pointer;background:#e5e7eb;position:relative;flex-shrink:0;transition:background .15s;z-index:2}.gengage-chat-panel-divider:hover{background:#cbd5e1}.gengage-chat-panel-divider--hidden{display:none}.gengage-chat-panel-divider-toggle{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:24px;height:48px;border:1px solid var(--_gengage-border-color);border-radius:6px;background:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:14px;color:var(--_gengage-text-secondary);box-shadow:0 1px 3px #00000014;transition:background .15s,color .15s;padding:0;line-height:1}.gengage-chat-panel-divider-toggle:hover{background:#f1f5f9;color:#334155}.gengage-chat-panel--collapsed{flex:0 0 0px!important;width:0!important;min-width:0!important;max-width:0!important;padding:0!important;border-right:none!important;overflow:hidden}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider .gengage-chat-panel-divider-toggle{left:0;transform:translateY(-50%)}.gengage-chat-conversation{display:flex;flex-direction:column;flex:1;min-width:0;overflow:hidden;background:var(--gengage-background-color, #fff);position:relative;z-index:1}.gengage-chat-drawer--with-panel{width:auto;background:transparent;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-header{border-radius:0;flex-shrink:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex:1 1 0;min-height:0;gap:0;padding:0;align-items:stretch}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{flex:0 0 auto;width:clamp(var(--_gengage-chat-panel-min-width),50vw,var(--_gengage-chat-panel-max-width));min-width:var(--_gengage-chat-panel-min-width);max-width:var(--_gengage-chat-panel-max-width);border-right:none;background:#fff;padding:0 16px 16px;overflow-y:auto;margin:0;border-radius:0;box-shadow:0 8px 32px #0f172a1f,0 2px 8px #0f172a0f;max-height:100dvh}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle{width:20px;height:48px;border-radius:10px;background:var(--gengage-primary-color, #3b82f6);color:#fff;border:2px solid #fff;box-shadow:0 2px 8px #0f172a2e;font-size:12px;z-index:10}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:hover{background:var(--gengage-primary-hover, #2563eb);color:#fff}.gengage-chat-drawer--with-panel .gengage-chat-conversation{flex:0 0 var(--_gengage-chat-conversation-width);width:var(--_gengage-chat-conversation-width);border-left:none;background:var(--gengage-background-color, #fff);box-shadow:-4px 0 24px #0f172a1f,-1px 0 4px #0f172a0f}.gengage-chat-drawer--with-panel .gengage-chat-messages{padding-right:6px;scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.12) transparent}.gengage-chat-drawer--with-panel .gengage-chat-messages::-webkit-scrollbar{width:0}.gengage-chat-drawer--with-panel:has(.gengage-chat-panel--collapsed){width:var(--_gengage-chat-conversation-width);background:var(--gengage-background-color, #fff);box-shadow:var(--_gengage-chat-shadow)}.gengage-chat-drawer--with-panel .gengage-chat-footer{display:none}.gengage-chat-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:16px;min-height:0;scroll-behavior:smooth;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;touch-action:pan-y}.gengage-chat-messages::-webkit-scrollbar{width:6px}.gengage-chat-messages::-webkit-scrollbar-track{background:transparent}.gengage-chat-messages::-webkit-scrollbar-thumb{background:#0000001f;border-radius:3px}.gengage-chat-messages::-webkit-scrollbar-thumb:hover{background:#0003}.gengage-chat-bubble{max-width:85%;padding:12px 16px;border-radius:12px;line-height:1.5;font-size:14px;font-weight:500;word-wrap:break-word;overflow-wrap:break-word;animation:gengage-chat-msg-in .3s cubic-bezier(.2,.7,.2,1)}@keyframes gengage-chat-msg-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-bubble--user{align-self:flex-end;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);border-bottom-right-radius:4px}.gengage-chat-bubble--assistant{align-self:flex-start;background:#f3f4f6;color:#1f2937;border-bottom-left-radius:4px;min-width:120px}.gengage-chat-bubble--active{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:-2px}.gengage-chat-bubble--assistant:empty{display:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a{color:var(--gengage-primary-color, #2563eb);text-decoration:underline}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a:hover{text-decoration:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p{margin:0 0 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p:last-child{margin-bottom:0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text ul,.gengage-chat-bubble--assistant .gengage-chat-bubble-text ol{margin:6px 0;padding-left:20px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text li{margin-bottom:6px;line-height:1.5}.gengage-chat-bubble--assistant .gengage-chat-bubble-text code{background:#0000000f;padding:1px 4px;border-radius:3px;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text pre{background:#0000000a;padding:8px;border-radius:6px;overflow-x:auto;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text table{border-collapse:collapse;margin:4px 0;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text th,.gengage-chat-bubble--assistant .gengage-chat-bubble-text td{border:1px solid var(--_gengage-border-color);padding:4px 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text img{max-width:100%;height:auto;border-radius:4px;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text h1,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h2,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h3,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h4,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h5,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h6{margin:8px 0 4px;line-height:1.3;color:#0f172a}.gengage-chat-bubble--assistant .gengage-chat-bubble-text blockquote{border-left:3px solid var(--_gengage-border-color);padding-left:12px;margin:4px 0;color:var(--_gengage-text-secondary)}.gengage-chat-bubble--first{border-left:3px solid var(--gengage-accent-primary, #3b82f6);padding-left:12px}.gengage-chat-bubble--first .gengage-chat-bubble-text{font-size:15px}.gengage-chat-typing{display:flex;align-items:center;gap:5px;padding:8px 4px;align-self:flex-start;max-width:85%}.gengage-chat-typing:has(.gengage-chat-typing-text),.gengage-chat-typing:has(.gengage-chat-thinking-steps){background:#f3f4f6;padding:10px 14px;border-radius:12px 12px 12px 4px;gap:8px}.gengage-chat-typing-dots{display:flex;align-items:center;gap:5px}.gengage-chat-typing-dots span{width:6px;height:6px;border-radius:50%;background:#94a3b8;display:inline-block;animation:gengage-chat-typing-fade 1.4s ease-in-out infinite}.gengage-chat-typing-dots span:nth-child(2){animation-delay:.2s}.gengage-chat-typing-dots span:nth-child(3){animation-delay:.4s}@keyframes gengage-chat-typing-fade{0%,to{opacity:.25}50%{opacity:1}}.gengage-chat-typing-sparkle{animation:gengage-sparkle-pulse 1.2s infinite}@keyframes gengage-sparkle-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-typing-text{font-size:13px;color:var(--_gengage-text-secondary);font-style:italic;flex:1;min-width:0;word-wrap:break-word;overflow-wrap:break-word}.gengage-chat-thinking-steps{display:flex;flex-direction:column;gap:4px;padding:4px 0}.gengage-chat-thinking-step{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--gengage-chat-text-secondary, #666)}.gengage-chat-thinking-step-marker{font-size:12px;width:16px;text-align:center;flex-shrink:0}.gengage-chat-thinking-step-marker--done{color:var(--gengage-chat-success, #4caf50)}.gengage-chat-thinking-step-marker--active{color:var(--gengage-chat-primary, #1976d2);animation:gengage-thinking-pulse 1.5s ease-in-out infinite}@keyframes gengage-thinking-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-thinking-step-text{line-height:1.4}.gengage-chat-error{display:flex;align-items:center;justify-content:center;gap:10px;padding:10px 14px;border-radius:10px;background:#fef2f2;color:#991b1b;font-size:13px;text-align:center;border:1px solid #fecaca}.gengage-chat-error-retry{flex-shrink:0;padding:4px 12px;border:1px solid #fca5a5;border-radius:6px;background:#fff;color:#991b1b;font-size:12px;font-weight:500;cursor:pointer;transition:background .15s}.gengage-chat-error-retry:hover{background:#fee2e2}.gengage-chat-input-area{display:flex;flex-wrap:wrap;align-items:center;gap:0;padding:8px 12px;border-top:1px solid var(--_gengage-border-color);background:var(--gengage-background-color, #fff)}.gengage-chat-input-pill{display:flex;align-items:center;gap:4px;flex:1;min-width:0;height:44px;background:#f3f4f6;border:1px solid var(--_gengage-border-color);border-radius:30px;padding:2px 8px;overflow:hidden;transition:border-color .2s ease,box-shadow .2s ease}.gengage-chat-input-pill:focus-within{border-color:var(--gengage-primary-color, #3b82f6);box-shadow:0 0 0 2px #3b82f626}.gengage-chat-input{flex:1;min-width:0;min-height:40px;max-height:120px;padding:0 6px 0 14px;border:none;border-radius:0;font-size:14px;font-family:inherit;line-height:1.4;align-content:center;outline:none;background:transparent;color:#1f2937;resize:none;overflow-y:hidden}@media(max-width:767px){.gengage-chat-input{max-height:40px;white-space:nowrap;overflow:hidden}.gengage-chat-send{width:44px;height:44px;min-width:44px}}.gengage-chat-input::placeholder{font-size:14px;color:#6b7280}.gengage-chat-send{width:36px;height:36px;min-width:36px;padding:0;border:none;border-radius:50%;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-weight:700;font-size:0;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background-color .2s cubic-bezier(.4,0,.2,1),box-shadow .2s ease,transform .15s ease;box-shadow:0 2px 4px #0000001f}.gengage-chat-send:hover{filter:brightness(.92);transform:translateY(-1px);box-shadow:0 4px 8px #0000002e}.gengage-chat-send:active{transform:translateY(0);box-shadow:0 1px 2px #0000001f}.gengage-chat-send svg{width:18px;height:18px}.gengage-chat-send:disabled{background:#d1d5db;box-shadow:none;cursor:not-allowed}.gengage-chat-footer{padding:4px 10px;text-align:center;font-size:10px;color:#6b7280;border-top:1px solid #f1f5f9;background:var(--gengage-background-color, #fff)}.gengage-chat-uispec{width:100%}.gengage-chat-uispec:empty{display:none}.gengage-chat-uispec>*{animation:gengage-chat-widget-enter .16s cubic-bezier(.2,.7,.2,1) both}@keyframes gengage-chat-widget-enter{0%{opacity:0;transform:translateY(5px) scale(.99)}to{opacity:1;transform:translateY(0) scale(1)}}.gengage-chat-action-buttons{display:flex;gap:8px;padding:6px 0 4px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch}.gengage-chat-action-buttons::-webkit-scrollbar{display:none}.gengage-chat-action-btn{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;line-height:1.25;font-family:inherit;cursor:pointer;white-space:nowrap;transition:filter .15s ease,transform .1s ease}.gengage-chat-action-btn:hover{filter:brightness(.92)}.gengage-chat-action-btn:active{transform:scale(.97)}.gengage-chat-product-card{position:relative;border:1px solid #eee;border-radius:16px;overflow:hidden;background:#fff;width:160px;min-width:160px;max-width:160px;box-shadow:0 2px 8px #0000000f;transition:transform .1s ease,box-shadow .2s ease}.gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 16px #0000001f}.gengage-chat-product-card-img{width:100%;height:120px;object-fit:contain;display:block;background:#fff;padding:8px;box-sizing:border-box}.gengage-chat-product-card-body{display:flex;flex-direction:column;gap:4px;padding:8px 10px 10px;text-align:center}.gengage-chat-product-card-name{font-size:13px;font-weight:600;color:#1f2937;line-height:1.35;margin-bottom:0;min-height:0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}.gengage-chat-product-card-brand{font-size:10px;color:#666}.gengage-chat-product-card-rating{font-size:11px;color:#f59e0b;line-height:1}.gengage-chat-product-card-review-count{color:#64748b;font-size:10px}.gengage-chat-product-card-price{display:flex;align-items:baseline;justify-content:center;gap:4px;font-size:16px;font-weight:800;color:#0f172a}.gengage-chat-product-card-original-price{text-decoration:line-through;color:#64748b;font-weight:400;font-size:12px}.gengage-chat-price-skeleton{display:inline-block;width:80px;height:16px;background:linear-gradient(90deg,#e2e8f0 25%,#f1f5f9,#e2e8f0 75%);background-size:200% 100%;animation:gengage-skeleton-price-pulse 1.5s ease-in-out infinite;border-radius:4px;vertical-align:middle}@keyframes gengage-skeleton-price-pulse{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-product-card-cta{display:block;padding:8px 10px;text-align:center;background:transparent;color:var(--gengage-primary-color, #3b82f6);text-decoration:none;font-size:12px;font-weight:700;letter-spacing:.01em;border-top:1px solid #f1f5f9;transition:color .15s ease,background .15s ease}.gengage-chat-product-card-cta:hover{color:var(--gengage-primary-color, #0b24d6);background:#f8fafc}.gengage-chat-product-card-cta:active{background:#f1f5f9}.gengage-chat-product-summary{display:flex;align-items:center;gap:12px;padding:10px 12px;border:1px solid #e5e7eb;border-radius:12px;background:#fff;cursor:pointer;transition:background .15s,box-shadow .15s;margin:4px 0}.gengage-chat-product-summary:hover{background:#f9fafb;box-shadow:0 1px 4px #0000000f}.gengage-chat-product-summary__image{flex-shrink:0;width:64px;height:64px;border-radius:8px;overflow:hidden;border:1px solid #f3f4f6;background:#f9fafb}.gengage-chat-product-summary__image img{width:100%;height:100%;object-fit:cover;display:block}.gengage-chat-product-summary__content{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.gengage-chat-product-summary__name{font-size:13px;font-weight:500;line-height:1.3;color:#111827;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-product-summary__rating{font-size:11px;color:#f59e0b;line-height:1}.gengage-chat-product-summary__review-count{color:#6b7280;font-size:11px}.gengage-chat-product-summary__price{font-size:13px;font-weight:600;color:#111827;line-height:1;margin-top:2px}.gengage-chat-product-summary__price-original{text-decoration:line-through;color:#6b7280;font-weight:400;font-size:11px}.gengage-chat-product-summary__price-current{color:var(--gengage-primary-color, #111827)}.gengage-chat-product-summary__cta{flex-shrink:0;font-size:12px;font-weight:500;color:var(--gengage-primary-color, #2563eb);text-decoration:none;padding:4px 10px;border-radius:8px;transition:background .15s;white-space:nowrap}.gengage-chat-product-summary__cta:hover{background:#0000000a}.gengage-chat-product-summary__cta:focus-visible{outline:2px solid var(--gengage-primary-color, #2563eb);outline-offset:2px}.gengage-chat-product-grid{display:flex;gap:12px;overflow-x:auto;padding:8px 0;-webkit-overflow-scrolling:touch;scrollbar-width:none;scroll-snap-type:x proximity;min-height:180px}.gengage-chat-product-grid>*{scroll-snap-align:start;flex:0 0 auto}.gengage-chat-product-grid::-webkit-scrollbar{display:none}.gengage-chat-review-highlights{padding:2px 0 6px}.gengage-chat-review-item{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:10px 12px;background:#fff}.gengage-chat-review-item[data-tone=positive]{border-color:#bbf7d0;background:#f0fdf4}.gengage-chat-review-item[data-tone=negative]{border-color:#fecaca;background:#fef2f2}.gengage-chat-review-tag{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;color:var(--_gengage-text-secondary);margin-bottom:4px}.gengage-chat-review-text{font-size:13px;line-height:1.45;color:#1f2937}.gengage-chat-review-rating{margin-top:6px;font-size:12px;font-weight:700;color:#0f172a}.gengage-chat-review-empty{font-size:12px;color:var(--_gengage-text-secondary)}.gengage-chat-review-tabs{display:flex;gap:6px;margin-bottom:10px}.gengage-chat-review-tab{padding:6px 14px;border:1px solid var(--_gengage-border-color);border-radius:999px;background:#fff;color:var(--_gengage-text-secondary);font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;transition:background .15s,border-color .15s}.gengage-chat-review-tab:hover{background:#f8fafc}.gengage-chat-review-tab--active{background:#f1f5f9;border-color:#94a3b8;color:#0f172a}.gengage-chat-review-pills{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}.gengage-chat-review-pill{display:flex;align-items:center;gap:6px;padding:6px 10px;border:1px solid var(--_gengage-border-color);border-radius:8px;background:#fff;font-size:12px;color:#334155;box-shadow:0 1px 2px #0000000a}.gengage-chat-review-pill[data-tone=positive]{border-color:#bbf7d0}.gengage-chat-review-pill[data-tone=negative]{border-color:#fecaca}.gengage-chat-review-pill-icon{font-size:11px;font-weight:700}.gengage-chat-review-pill[data-tone=positive] .gengage-chat-review-pill-icon{color:#16a34a}.gengage-chat-review-pill[data-tone=negative] .gengage-chat-review-pill-icon{color:#dc2626}.gengage-chat-review-pill-count{font-size:10px;font-weight:700;background:#f1f5f9;color:var(--_gengage-text-secondary);border-radius:4px;padding:1px 5px}.gengage-chat-review-items{display:grid;gap:10px}.gengage-chat-divider{border:none;border-top:1px solid var(--_gengage-border-color);margin:8px 0}.gengage-chat-divider-wrapper{display:flex;align-items:center;gap:8px;margin:8px 0}.gengage-chat-divider-wrapper hr{flex:1;border:none;border-top:1px solid var(--_gengage-border-color);margin:0}.gengage-chat-divider-label{font-size:11px;color:#6b7280;white-space:nowrap}.gengage-chat--overlay .gengage-chat-drawer{position:fixed;inset:0;width:100%;max-width:480px;max-height:100%;margin:0 auto;border-radius:0;animation:gengage-chat-overlay-in .24s cubic-bezier(.2,.72,.2,1)}.gengage-chat--overlay:before{content:"";position:fixed;inset:0;background:#00000073;z-index:-1}@keyframes gengage-chat-overlay-in{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-panel-skeleton{display:flex;flex-direction:column;gap:14px;padding:6px 0}.gengage-chat-panel-skeleton-block{height:110px;border-radius:10px;background:linear-gradient(90deg,#e5e7eb 25%,#f3f4f6,#e5e7eb 75%);background-size:200% 100%;animation:gengage-panel-shimmer 1.4s infinite}@keyframes gengage-panel-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-panel-skeleton-block--image{height:200px;border-radius:8px;margin-bottom:12px}.gengage-chat-panel-skeleton-block--text{height:16px;border-radius:4px;margin-bottom:8px}.gengage-chat-panel-skeleton-block--text:nth-child(3){width:80%}.gengage-chat-panel-skeleton-block--text:nth-child(4){width:60%}.gengage-chat-panel-skeleton-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.gengage-chat-panel-skeleton-block--card{height:120px;border-radius:8px}.gengage-chat-panel-skeleton-block--row{height:32px;border-radius:4px;margin-bottom:4px}.gengage-chat-panel .gengage-chat-product-card{width:100%;max-width:100%;min-width:0;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--_gengage-border-color);box-shadow:0 1px 4px #0000000f;overflow:hidden;padding:0}.gengage-chat-panel .gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 12px #0000001a;border-color:#d1d5db}.gengage-chat-panel .gengage-chat-product-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));overflow-x:visible;gap:12px;min-height:auto;padding:4px 0}.gengage-chat-panel .gengage-chat-product-card-img{width:100%;height:160px;border-radius:0;object-fit:contain;background:#fafafa;padding:12px;box-sizing:border-box}.gengage-chat-panel .gengage-chat-product-card-body{padding:10px 12px 12px;text-align:left;gap:4px}.gengage-chat-panel .gengage-chat-product-card-name{min-height:0;margin-bottom:2px;font-size:13px;-webkit-line-clamp:2}.gengage-chat-panel .gengage-chat-product-card-price{justify-content:flex-start;font-size:15px}.gengage-chat-panel .gengage-chat-product-card-cta{display:block;padding:10px 12px;text-align:center;border-top:1px solid #f1f5f9;border-radius:0;background:transparent;color:var(--gengage-primary-color, #3b82f6);font-weight:700;font-size:13px}.gengage-chat-product-details-panel{display:flex;flex-direction:column;gap:12px;width:100%;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:16px;padding:14px;box-sizing:border-box}.gengage-chat-product-details-media{border:1px solid #f1f5f9;border-radius:12px;background:#fafafa;padding:12px;display:flex;flex-direction:column;align-items:center}.gengage-chat-product-details-img{width:100%;height:auto;max-height:300px;object-fit:contain;border-radius:8px}.gengage-chat-product-details-content{display:flex;flex-direction:column;gap:8px;min-width:0}.gengage-chat-product-details-title{margin:0;font-size:17px;font-weight:700;line-height:1.3;color:#0f172a}.gengage-chat-product-details-rating{display:inline-flex;align-items:center;gap:4px;width:fit-content;padding:3px 8px;border-radius:999px;background:#fff7ed;color:#9a3412;font-size:13px;font-weight:700}.gengage-chat-product-details-review-count{color:#7c2d12;font-weight:600}.gengage-chat-product-details-price{display:flex;align-items:baseline;gap:6px}.gengage-chat-product-details-original-price{font-size:14px;color:#64748b;text-decoration:line-through}.gengage-chat-product-details-current-price{font-size:22px;font-weight:800;line-height:1.1;color:#0f172a}.gengage-chat-product-details-stock{width:fit-content;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:700}.gengage-chat-product-details-stock.is-in-stock{background:#dcfce7;color:#166534}.gengage-chat-product-details-stock.is-out-of-stock{background:#fee2e2;color:#991b1b}.gengage-chat-product-details-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:4px}.gengage-chat-product-details-cta{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 20px;border-radius:999px;border:none;text-decoration:none;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:14px;font-weight:700;cursor:pointer;transition:filter .14s ease,transform .12s ease}.gengage-chat-product-details-cta:hover{filter:brightness(1.05);transform:translateY(-1px)}.gengage-chat-product-details-cta:active{transform:translateY(1px)}.gengage-chat-product-details-atc{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 20px;border:none;border-radius:10px;background:var(--_gengage-success-color);color:#fff;font-size:14px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .12s ease,transform .12s ease}.gengage-chat-product-details-atc:hover{filter:brightness(1.08);transform:translateY(-1px)}.gengage-chat-product-details-atc:active{transform:translateY(1px)}.gengage-chat-product-detail-tabs{margin-top:4px;border-top:1px solid var(--_gengage-border-color);padding-top:12px}.gengage-chat-product-detail-tab-bar{display:flex;gap:0;border-bottom:2px solid var(--_gengage-border-color);margin-bottom:12px}.gengage-chat-product-detail-tab{flex:1;padding:8px 12px;border:none;background:transparent;color:var(--_gengage-text-secondary);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-2px;transition:color .15s,border-color .15s}.gengage-chat-product-detail-tab:hover{color:#334155}.gengage-chat-product-detail-tab--active{color:var(--gengage-primary-color, #3b82f6);border-bottom-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-detail-tab-panel{font-size:13px;line-height:1.6;color:#374151}.gengage-chat-product-specs-table{width:100%;border-collapse:collapse;font-size:13px}.gengage-chat-product-specs-table tr:nth-child(2n){background:#f8fafc}.gengage-chat-product-specs-key{padding:6px 10px;font-weight:600;color:#475569;white-space:nowrap;border-bottom:1px solid #f1f5f9;width:40%}.gengage-chat-product-specs-value{padding:6px 10px;color:#1f2937;border-bottom:1px solid #f1f5f9}.gengage-chat-product-card-atc{position:absolute;bottom:42px;right:6px;opacity:0;transition:opacity .15s ease;z-index:1}.gengage-chat-product-card:hover .gengage-chat-product-card-atc{opacity:1}.gengage-chat-drawer.gengage-chat-drawer--hidden{clip-path:inset(0 0 0 100%);opacity:0;pointer-events:none;box-shadow:none}.gengage-chat-root--mobile .gengage-chat-drawer.gengage-chat-drawer--hidden{clip-path:inset(100% 0 0 0);opacity:0;pointer-events:none;box-shadow:none}@media(max-width:900px){.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:clamp(280px,calc(100vw - var(--_gengage-chat-conversation-width)),560px);max-width:560px}}.gengage-chat-attachment-preview{display:flex;align-items:center;gap:8px;padding:6px 10px;background:#f3f4f6;border:1px solid var(--_gengage-border-color);border-radius:8px;width:100%;box-sizing:border-box}.gengage-chat-attachment-preview--hidden{display:none}.gengage-chat-attachment-preview-thumb{width:40px;height:40px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-attachment-name{flex:1;font-size:12px;color:#4b5563;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.gengage-chat-attachment-remove{background:none;border:none;cursor:pointer;font-size:18px;color:#6b7280;padding:0 4px;line-height:1;flex-shrink:0}.gengage-chat-attachment-remove:hover{color:#ef4444}.gengage-chat-attach-btn{background:none;border:none;cursor:pointer;padding:6px;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-attach-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-attach-btn svg{width:20px;height:20px}.gengage-chat-mic-btn{background:none;border:none;cursor:pointer;padding:6px;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-mic-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-mic-btn svg{width:20px;height:20px}.gengage-chat-mic-btn--active{color:#ef4444;animation:gengage-mic-pulse 1.2s ease-in-out infinite}.gengage-chat-mic-btn--active:hover{color:#dc2626}@keyframes gengage-mic-pulse{0%,to{transform:scale(1);opacity:1}50%{transform:scale(1.15);opacity:.8}}.gengage-chat-input-area--dragover{outline:2px dashed var(--gengage-primary-color, #3b82f6);outline-offset:-2px;background:#eff6ff}.gengage-chat-attachment-thumb{width:120px;max-width:100%;height:auto;border-radius:8px;margin-bottom:6px;display:block}@media(max-width:768px){.gengage-chat-panel-divider{display:none}.gengage-chat-drawer--with-panel{left:0;right:0;width:100%;border-radius:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex-direction:column}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:100%;min-width:0;max-width:none;max-height:30dvh;border-right:none;border-bottom:1px solid var(--_gengage-border-color);padding:0 12px 12px;margin:0;border-radius:0;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-conversation{width:100%;flex:1;border-left:none}.gengage-chat-panel .gengage-chat-product-card{grid-template-columns:84px 1fr}.gengage-chat-panel .gengage-chat-product-card-cta{grid-column:1 / -1;width:100%}.gengage-chat-product-details-panel{padding:12px;gap:12px}.gengage-chat-product-details-media{min-height:140px}.gengage-chat-product-details-title{font-size:15px}.gengage-chat-product-details-current-price{font-size:20px}.gengage-chat-product-grid{scroll-snap-type:x mandatory}.gengage-chat-product-card{width:280px;min-width:280px;scroll-snap-align:center}.gengage-chat-product-card-img{height:180px}}@media(max-width:480px){.gengage-chat-drawer{position:fixed;inset:0;width:100%;max-height:100%;border-radius:0}.gengage-chat-bubble{max-width:100%}}.gengage-chat-kvkk-banner{display:flex;align-items:flex-start;gap:8px;padding:10px 14px;background:#fffbeb;border-bottom:1px solid #fde68a;font-size:12px;line-height:1.5;color:#92400e}.gengage-chat-kvkk-content{flex:1;min-width:0}.gengage-chat-kvkk-content a{color:#b45309;text-decoration:underline}.gengage-chat-kvkk-dismiss{flex-shrink:0;width:20px;height:20px;border:none;background:transparent;color:#92400e;font-size:16px;cursor:pointer;padding:0;line-height:1}.gengage-chat-comparison{padding:16px}.gengage-chat-comparison-heading{font-size:14px;font-weight:700;letter-spacing:.05em;color:#0f172a;margin:0 0 16px}.gengage-chat-comparison-recommended{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:16px;background:#fff;box-shadow:0 1px 3px #0000000f;margin-bottom:12px}.gengage-chat-comparison-recommended-label{font-size:12px;font-weight:700;color:#16a34a;text-transform:uppercase;letter-spacing:.04em;margin-bottom:12px}.gengage-chat-comparison-recommended-body{display:flex;gap:12px;align-items:flex-start}.gengage-chat-comparison-recommended-body img{width:80px;height:80px;object-fit:contain;border-radius:8px;background:#f8fafc}.gengage-chat-comparison-recommended-info{flex:1;min-width:0}.gengage-chat-comparison-recommended-title{font-size:14px;font-weight:600;color:#0f172a;margin-bottom:4px}.gengage-chat-comparison-recommended-price{font-size:16px;font-weight:700;color:#0f172a}.gengage-chat-comparison-highlights{margin-top:12px;padding-top:12px;border-top:1px solid #f1f5f9}.gengage-chat-comparison-highlights-label{font-size:12px;font-weight:600;color:var(--_gengage-text-secondary);margin-bottom:6px}.gengage-chat-comparison-highlights ul{margin:0;padding-left:18px;font-size:13px;color:#334155;line-height:1.6}.gengage-chat-comparison-special{background:#fffbeb;border:1px solid #fde68a;border-radius:12px;padding:12px 16px;margin-bottom:12px;font-size:13px;color:#92400e}.gengage-chat-comparison-special summary{cursor:pointer;font-weight:600}.gengage-chat-comparison-special ul{margin:8px 0 0;padding-left:18px;line-height:1.6}.gengage-chat-comparison-table{width:100%;border-collapse:collapse;font-size:13px;margin-top:12px}.gengage-chat-comparison-table th,.gengage-chat-comparison-table td{padding:10px 12px;text-align:center;border-bottom:1px solid #f1f5f9;vertical-align:top}.gengage-chat-comparison-table th{font-weight:600;font-size:12px;color:#334155}.gengage-chat-comparison-table th img{width:60px;height:60px;object-fit:contain;border-radius:6px;background:#f8fafc;margin-bottom:6px}.gengage-chat-comparison-table-price{font-weight:700;color:#0f172a}.gengage-chat-comparison-label{text-align:left;font-weight:600;color:var(--_gengage-text-secondary);white-space:nowrap}.gengage-chat-comparison-selected{background:#f0fdf4}.gengage-chat-comparison-recommended-text{padding:8px 12px;font-size:12px;color:var(--gengage-text-secondary, #475569);font-style:italic;border-top:1px solid var(--gengage-border-color, #e2e8f0);margin-top:8px}.gengage-chat-comparison-product-actions{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap}.gengage-chat-comparison-view-btn{flex:1;min-width:0;padding:8px 12px;border:1px solid var(--gengage-primary-color, #3b82f6);border-radius:6px;background:transparent;color:var(--gengage-primary-color, #3b82f6);font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .15s ease,color .15s ease;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.gengage-chat-comparison-view-btn:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-pills{position:relative;padding:8px 12px;border-top:1px solid #f1f5f9;background:var(--gengage-background-color, #fff)}.gengage-chat-pills-scroll{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;padding-right:28px}.gengage-chat-pills-scroll::-webkit-scrollbar{display:none}.gengage-chat-pill{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;font-family:inherit;white-space:nowrap;cursor:pointer;transition:filter .15s,transform .1s}.gengage-chat-pill:hover{filter:brightness(.92)}.gengage-chat-pill:active{transform:scale(.97)}.gengage-chat-pill--rich{display:flex;align-items:center;gap:8px;padding:6px 14px 6px 6px;border-radius:20px}.gengage-chat-pill-img{width:32px;height:32px;border-radius:50%;object-fit:cover;flex-shrink:0;background:#ffffff26}.gengage-chat-pill-text{font-size:13px;font-weight:600;line-height:1.2}.gengage-chat-pill-desc{display:none}.gengage-chat-pill--rich .gengage-chat-pill-desc{display:block;font-size:10px;font-weight:400;opacity:.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px}.gengage-chat-pills-arrow{position:absolute;right:8px;top:50%;transform:translateY(-50%);width:28px;height:28px;border-radius:50%;border:1px solid var(--_gengage-border-color);background:#fff;color:var(--_gengage-text-secondary);font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:-4px 0 8px #ffffffe6;z-index:1}.gengage-chat-pills-arrow:hover{background:#f8fafc;color:#334155}@media(prefers-reduced-motion:reduce){.gengage-chat-uispec>*,.gengage-chat-action-btn,.gengage-chat-product-card,.gengage-chat-product-card-cta,.gengage-chat-send,.gengage-chat-launcher,.gengage-chat-pill,.gengage-chat-drawer,.gengage-chat-proactive,.gengage-chat-typing-dots span,.gengage-chat-typing-sparkle,.gengage-chat-thinking-step-marker--active,.gengage-chat-bubble,.gengage-chat-panel-skeleton-block,.gengage-chat-ai-toppick-card,.gengage-chat-mic-btn--active,.gengage-chat-ai-toppick-spinner:after,.gengage-chat-panel-shimmer,.gengage-chat-overlay,.gengage-chat-product-details-skeleton-price{animation:none!important;transition:none!important;transform:none!important}}.gengage-chat-bubble--user{position:relative}.gengage-chat-rollback-btn{position:absolute;left:-28px;top:50%;transform:translateY(-50%);width:24px;height:24px;border:none;border-radius:50%;background:var(--gengage-surface-color, #f1f5f9);color:var(--gengage-text-secondary, #64748b);cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s ease;padding:0}.gengage-chat-bubble--user:hover .gengage-chat-rollback-btn{opacity:1}.gengage-chat-rollback-btn:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-bubble--hidden{display:none}.gengage-chat-ai-top-picks{display:flex;flex-direction:column;gap:12px;padding:8px 0}.gengage-chat-ai-top-picks-title{font-size:15px;font-weight:600;color:var(--gengage-text-primary, #1e293b);margin:0 0 4px}.gengage-chat-ai-top-picks-cards{display:flex;flex-direction:column;gap:10px}.gengage-chat-ai-toppick-discount-badge{position:absolute;top:8px;left:8px;background:var(--gengage-discount-bg, #ef4444);color:#fff;font-size:11px;font-weight:700;padding:2px 6px;border-radius:4px;z-index:1}.gengage-chat-ai-toppick-card--winner{position:relative;display:flex;flex-direction:column;border:2px solid var(--gengage-primary-color, #3b82f6);border-radius:12px;background:#fff;overflow:hidden;transition:box-shadow .2s ease}.gengage-chat-ai-toppick-card--winner:hover{box-shadow:0 4px 16px #3b82f626}.gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-img{width:100%;height:140px;object-fit:contain;background:#f8fafc}.gengage-chat-ai-toppick-card--compact{position:relative;display:flex;flex-direction:row;align-items:center;gap:12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;background:#fff;padding:10px;transition:box-shadow .2s ease,transform .15s ease}.gengage-chat-ai-toppick-card--compact:hover{box-shadow:0 2px 8px #00000014;transform:translateY(-1px)}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img{width:64px;height:64px;object-fit:contain;border-radius:8px;background:#f8fafc;flex-shrink:0}.gengage-chat-ai-toppick-badge{position:absolute;top:8px;left:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:10px;font-weight:700;text-transform:uppercase;padding:2px 8px;border-radius:4px;z-index:1;letter-spacing:.5px}.gengage-chat-ai-toppick-body{display:flex;flex-direction:column;gap:4px;padding:10px;flex:1;min-width:0}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-body{padding:0}.gengage-chat-ai-toppick-name{font-size:13px;font-weight:600;color:var(--gengage-text-primary, #1e293b);overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.gengage-chat-ai-toppick-role{font-size:11px;font-weight:600;color:var(--gengage-primary-color, #3b82f6);text-transform:uppercase;letter-spacing:.3px}.gengage-chat-ai-toppick-labels{display:flex;flex-wrap:wrap;gap:4px}.gengage-chat-ai-toppick-label{font-size:11px;padding:1px 6px;border-radius:4px;font-weight:500}.gengage-chat-ai-toppick-label[data-sentiment=positive]{background:#dcfce7;color:#166534}.gengage-chat-ai-toppick-label[data-sentiment=negative]{background:#fee2e2;color:#991b1b}.gengage-chat-ai-toppick-label[data-sentiment=neutral]{background:#f1f5f9;color:#475569}.gengage-chat-ai-toppick-score{font-size:12px;font-weight:700;color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-ai-toppick-reason{font-size:12px;color:var(--gengage-chat-text-secondary, #666);line-height:1.4;margin-top:4px}.gengage-chat-ai-toppick-review{font-size:12px;font-style:italic;color:var(--gengage-text-secondary, #64748b);margin:2px 0;padding-left:8px;border-left:2px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-ai-toppick-price{font-size:14px;font-weight:700;color:var(--gengage-text-primary, #1e293b)}.gengage-chat-ai-toppick-original-price{text-decoration:line-through;color:var(--gengage-text-secondary, #64748b);font-weight:400;font-size:12px}.gengage-chat-ai-toppick-cta{display:block;width:calc(100% - 20px);margin:6px 10px 10px;padding:8px 0;border:none;border-radius:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:13px;font-weight:600;cursor:pointer;text-align:center;transition:background .15s ease}.gengage-chat-ai-toppick-cta:hover{filter:brightness(.92)}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:auto;margin:0;padding:6px 14px;flex-shrink:0;align-self:center}.gengage-chat-ai-toppick-spinner{position:absolute;inset:0;background:#ffffffb3;display:flex;align-items:center;justify-content:center;border-radius:12px;z-index:3}.gengage-chat-ai-toppick-spinner:after{content:"";width:24px;height:24px;border:3px solid var(--gengage-border, #e2e8f0);border-top-color:var(--gengage-accent-primary, #3b82f6);border-radius:50%;animation:gengage-spin .7s linear infinite}@keyframes gengage-spin{to{transform:rotate(360deg)}}@media(max-width:768px){.gengage-chat-ai-top-picks-cards{flex-direction:row;overflow-x:auto;scroll-snap-type:x mandatory;-webkit-overflow-scrolling:touch;gap:10px;padding-bottom:4px}.gengage-chat-ai-toppick-card--winner,.gengage-chat-ai-toppick-card--compact{min-width:280px;max-width:280px;flex-shrink:0;scroll-snap-align:start}.gengage-chat-ai-toppick-card--compact{flex-direction:column;align-items:stretch}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img{width:100%;height:100px;border-radius:8px 8px 0 0}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:calc(100% - 20px);margin:6px 10px 10px;align-self:stretch}.gengage-chat-rollback-btn{left:-24px}}.gengage-chat-grounding-review{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grounding-review:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-grounding-review-icon{font-size:20px;flex-shrink:0}.gengage-chat-grounding-review-body{flex:1;min-width:0}.gengage-chat-grounding-review-title{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grounding-review-subtitle{font-size:12px;color:var(--gengage-text-muted, #64748b);margin-top:2px}.gengage-chat-grounding-review-cta{font-size:13px;font-weight:500;color:var(--gengage-primary-color, #3b82f6);white-space:nowrap;flex-shrink:0}.gengage-chat-grouping-cards{display:flex;flex-direction:column;gap:6px}.gengage-chat-grouping-card{display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:8px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grouping-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-grouping-card-arrow{display:none;font-size:14px;color:var(--gengage-primary-color, #3b82f6);flex-shrink:0}.gengage-chat-grouping-card-img{width:20px;height:20px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-grouping-card-body{flex:1;min-width:0;display:flex;align-items:baseline;gap:6px;flex-wrap:wrap}.gengage-chat-grouping-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grouping-card-desc{font-size:12px;color:var(--gengage-text-muted, #64748b)}.gengage-chat-grouping-card-labels{display:block;font-size:11px;color:var(--gengage-chat-text-secondary, #888);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gengage-chat-root--mobile .gengage-chat-grouping-card-img{display:none}.gengage-chat-root--mobile .gengage-chat-grouping-card-arrow{display:inline}.gengage-chat-suggested-search-cards{display:flex;flex-direction:column;gap:8px}.gengage-chat-suggested-search-card{display:flex;align-items:flex-start;gap:12px;padding:10px 14px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-suggested-search-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-suggested-search-card-img{width:40px;height:40px;border-radius:6px;object-fit:cover;flex-shrink:0}.gengage-chat-suggested-search-card-body{flex:1;min-width:0}.gengage-chat-suggested-search-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-suggested-search-card-desc{font-size:12px;color:var(--gengage-text-secondary, #475569);margin-top:2px}.gengage-chat-suggested-search-card-diff{font-size:11px;color:var(--gengage-text-muted, #64748b);margin-top:2px;font-style:italic}.gengage-chat-product-details-gallery{position:relative}.gengage-chat-product-details-gallery .gengage-chat-product-details-img{touch-action:pan-y}.gengage-chat-product-gallery-thumbs{display:flex;gap:8px;padding:10px 0 4px;overflow-x:auto;scrollbar-width:thin;justify-content:center;width:100%}.gengage-chat-product-gallery-thumb{width:56px;height:56px;object-fit:cover;border-radius:8px;border:2px solid transparent;cursor:pointer;flex-shrink:0;transition:border-color .15s ease;background:#fff}.gengage-chat-product-gallery-thumb:hover{border-color:var(--gengage-border-color, #cbd5e1)}.gengage-chat-product-gallery-thumb--active{border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-variants{margin-top:12px}.gengage-chat-product-variants-label{font-size:12px;font-weight:600;color:var(--gengage-text-muted, #64748b);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.gengage-chat-product-variants-list{display:flex;flex-wrap:wrap;gap:6px}.gengage-chat-product-variant-btn{padding:6px 12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:6px;background:var(--gengage-surface-color, #f8fafc);color:var(--gengage-text-color, #1e293b);font-size:12px;cursor:pointer;transition:background .15s ease,border-color .15s ease}.gengage-chat-product-variant-btn:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-grid-wrapper{display:flex;flex-direction:column;gap:8px}.gengage-chat-product-sort-toolbar{display:flex;gap:4px;padding:4px;background:var(--gengage-surface-color, #f8fafc);border-radius:8px;border:1px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-product-sort-btn{flex:1;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease}.gengage-chat-product-sort-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-product-sort-btn--active,.gengage-chat-product-sort-btn--active:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-product-sort-separator{width:1px;background:var(--gengage-border-color, #e2e8f0);margin:2px}.gengage-chat-comparison-toggle-btn{flex:none;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease;white-space:nowrap}.gengage-chat-comparison-toggle-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-comparison-toggle-btn--active,.gengage-chat-comparison-toggle-btn--active:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-comparison-select-wrapper{position:relative}.gengage-chat-comparison-checkbox{position:absolute;top:8px;left:8px;z-index:2;width:18px;height:18px;cursor:pointer;accent-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-comparison-floating-btn{display:block;width:100%;margin-top:8px;padding:10px 16px;border:none;border-radius:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:14px;font-weight:600;cursor:pointer;transition:background .15s ease;text-align:center}.gengage-chat-comparison-floating-btn:hover{background:var(--gengage-primary-hover, #2563eb)}.gengage-chat-panel-topbar{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--_gengage-border-color);background:#f8fafc;min-height:44px;flex-shrink:0;position:sticky;top:0;z-index:3}.gengage-chat-panel-topbar-back,.gengage-chat-panel-topbar-forward{width:28px;height:28px;min-width:28px;padding:0;border:1px solid #d1d5db;border-radius:6px;background:transparent;color:#374151;font-size:14px;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s ease,border-color .15s ease,opacity .15s ease}.gengage-chat-panel-topbar-back:hover:not(:disabled),.gengage-chat-panel-topbar-forward:hover:not(:disabled){background:#f3f4f6;border-color:#9ca3af}.gengage-chat-panel-topbar-back:disabled,.gengage-chat-panel-topbar-forward:disabled{opacity:.3;cursor:default}.gengage-chat-panel-topbar-title{flex:1;font-size:14px;font-weight:600;color:#1f2937;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}@keyframes gengage-typewriter-fade-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-typewriter-block{display:block;animation:gengage-typewriter-fade-in .15s ease both}@media(prefers-reduced-motion:reduce){.gengage-chat-typewriter-block{animation:none}}.gengage-product-mention{color:var(--gengage-primary-color, #3b82f6);text-decoration:none;cursor:pointer;font-weight:500;border-bottom:1px dashed var(--gengage-primary-color, #3b82f6);transition:border-color .15s}.gengage-product-mention:hover{border-bottom-style:solid}@keyframes gengage-skeleton-pulse{0%,to{opacity:.4}50%{opacity:.8}}.gengage-chat-panel-skeleton-block{animation:gengage-skeleton-pulse 1.5s ease-in-out infinite}@media(prefers-reduced-motion:reduce){.gengage-chat-panel-skeleton-block{animation:none}}.gengage-chat-input-chips{display:flex;gap:6px;padding:4px 12px 2px;flex-wrap:wrap}.gengage-chat-input-chip{display:inline-flex;align-items:center;padding:4px 10px;border-radius:12px;border:1px solid var(--_gengage-border-color);background:#f9fafb;color:#374151;font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .12s,border-color .12s;white-space:nowrap}.gengage-chat-input-chip:hover{background:#f3f4f6;border-color:#d1d5db}.gengage-chat-icon{width:14px;height:14px;flex-shrink:0}.gengage-chat-input-chip-icon,.gengage-chat-pill-icon{display:inline-flex;align-items:center;margin-right:4px}.gengage-chat-product-card-img-wrapper,.gengage-chat-product-details-img-wrap{position:relative;overflow:hidden}.gengage-chat-product-card-discount-badge{position:absolute;top:6px;left:6px;padding:2px 6px;border-radius:4px;background:var(--_gengage-discount-color);color:#fff;font-size:11px;font-weight:700;line-height:1.3;z-index:1}.gengage-chat-product-card-stock{font-size:11px;font-weight:600;margin-top:2px}.gengage-chat-product-card-stock.is-in-stock{color:var(--_gengage-success-color)}.gengage-chat-product-card-stock.is-out-of-stock{color:#dc2626}.gengage-chat-find-similar-pill{position:absolute;top:8px;right:8px;opacity:0;pointer-events:none;transition:opacity .2s ease;padding:4px 10px;font-size:11px;font-weight:500;font-family:inherit;border:none;border-radius:12px;background:var(--gengage-chat-pill-bg, rgba(0, 0, 0, .7));color:var(--gengage-chat-pill-text, #fff);cursor:pointer;white-space:nowrap;z-index:2}.gengage-chat-product-card-img-wrapper:hover .gengage-chat-find-similar-pill,.gengage-chat-product-details-img-wrap:hover .gengage-chat-find-similar-pill{opacity:1;pointer-events:auto}.gengage-chat-favorite-btn{position:absolute;top:8px;right:8px;background:#ffffffe6;border:none;border-radius:50%;width:28px;height:28px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--gengage-text-secondary, #64748b);z-index:3;transition:color .2s;padding:0}.gengage-chat-favorite-btn:hover,.gengage-chat-favorite-btn--active{color:var(--gengage-accent-primary, #ef4444)}.gengage-chat-product-card-promos,.gengage-chat-product-details-promos{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}.gengage-chat-product-card-promo-badge,.gengage-chat-product-details-promo-badge{display:inline-block;padding:2px 6px;font-size:10px;font-weight:500;border-radius:4px;background:var(--gengage-chat-promo-bg, #e8f5e9);color:var(--gengage-chat-promo-text, #2e7d32);white-space:nowrap}.gengage-chat-thumbnails-column{position:absolute;right:4px;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;gap:4px;z-index:2;pointer-events:auto}.gengage-chat-thumbnail-btn{display:flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border:2px solid #e5e7eb;border-radius:6px;background:#fff;cursor:pointer;overflow:hidden;transition:border-color .15s ease}.gengage-chat-thumbnail-btn:hover{border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-thumbnail-img{width:100%;height:100%;object-fit:cover}.gengage-chat-choice-prompter{position:absolute;bottom:12px;right:12px;width:200px;padding:12px 14px;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:10px;box-shadow:0 4px 12px #0000001a;z-index:10;animation:gengage-choice-prompter-in .2s ease}@keyframes gengage-choice-prompter-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-choice-prompter-heading{font-size:13px;font-weight:600;color:#1f2937;margin-bottom:4px}.gengage-chat-choice-prompter-suggestion{font-size:12px;color:#6b7280;margin-bottom:10px;line-height:1.4}.gengage-chat-choice-prompter-cta{display:block;width:100%;padding:6px 12px;border:none;border-radius:6px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;text-align:center;transition:opacity .15s ease}.gengage-chat-choice-prompter-cta:hover{opacity:.9}.gengage-chat-choice-prompter-dismiss{position:absolute;top:4px;right:6px;padding:2px 6px;border:none;background:none;color:#6b7280;font-size:16px;cursor:pointer;line-height:1}.gengage-chat-choice-prompter-dismiss:hover{color:#6b7280}@media(prefers-reduced-motion:reduce){.gengage-chat-choice-prompter{animation:none}}.gengage-chat-pros-cons{padding:12px 14px;background:#f8fafc;border-radius:8px;margin:8px 0}.gengage-chat-pros-cons-heading{margin:0 0 10px;font-size:14px;font-weight:600;color:#0f172a}.gengage-chat-pros-cons-list{list-style:none;margin:0 0 8px;padding:0}.gengage-chat-pros-cons-list:last-child{margin-bottom:0}.gengage-chat-pros-cons-item{display:flex;align-items:flex-start;gap:8px;padding:4px 0;font-size:13px;line-height:1.5;color:#334155}.gengage-chat-pros-cons-icon{flex-shrink:0;width:18px;height:18px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;border-radius:50%}.gengage-chat-pros-cons-icon--pro{color:#16a34a;background:#dcfce7}.gengage-chat-pros-cons-icon--con{color:#dc2626;background:#fee2e2}.gengage-chat-categories{display:flex;flex-direction:column;gap:8px}.gengage-chat-categories-tabs{display:flex;gap:4px;overflow-x:auto;padding:4px 0;-webkit-overflow-scrolling:touch}.gengage-chat-categories-tab{padding:6px 14px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:20px;background:var(--gengage-bg, #fff);color:var(--gengage-text, #374151);cursor:pointer;white-space:nowrap;font-size:13px;transition:background .15s,color .15s}.gengage-chat-categories-tab:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-categories-tab--active{background:var(--gengage-primary, #2563eb);color:#fff;border-color:var(--gengage-primary, #2563eb)}.gengage-chat-categories-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.gengage-chat-categories-filter-tags{display:flex;gap:6px;flex-wrap:wrap;margin-top:4px}.gengage-chat-categories-filter-tag{padding:4px 10px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:14px;background:var(--gengage-bg, #fff);color:var(--gengage-text-secondary, #6b7280);font-size:12px;cursor:pointer;transition:background .15s}.gengage-chat-categories-filter-tag:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid-view-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:8px;background:var(--gengage-bg, #fff);color:var(--gengage-primary, #2563eb);font-size:14px;font-weight:500;cursor:pointer;text-align:center;transition:background .15s;grid-column:1 / -1}.gengage-chat-product-grid-view-more:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid--mobile{display:flex;overflow-x:auto;gap:8px;padding:8px 0;-webkit-overflow-scrolling:touch}.gengage-chat-product-grid--mobile .gengage-chat-product-card{min-width:160px;max-width:180px;flex-shrink:0}.gengage-chat-comparison--mobile .gengage-chat-comparison-table,.gengage-chat-comparison--mobile .gengage-chat-comparison-table thead,.gengage-chat-comparison--mobile .gengage-chat-comparison-table tbody{display:block}.gengage-chat-comparison--mobile .gengage-chat-comparison-table tr{display:flex;flex-wrap:wrap}.gengage-chat-comparison-key-differences{margin-top:12px;padding:12px;background:var(--gengage-bg-secondary, #f9fafb);border-radius:8px}.gengage-chat-comparison-key-differences h4{margin:0 0 8px;font-size:14px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-comparison-key-differences-content{font-size:13px;color:var(--gengage-text-secondary, #6b7280);line-height:1.5}.gengage-chat-comparison-key-differences-content ul{margin:0;padding-left:18px}.gengage-chat-comparison-key-differences-content li{margin-bottom:4px}.gengage-chat-product-details-similars-heading{margin:16px 0 8px;font-size:15px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-product-details-similars{margin-top:8px}.gengage-chat-handoff-notice{display:flex;flex-direction:column;align-items:center;gap:6px;padding:16px;margin:8px 0;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;text-align:center}.gengage-chat-handoff-notice-icon{font-size:24px}.gengage-chat-handoff-notice-heading{margin:0;font-size:14px;font-weight:600;color:#92400e}.gengage-chat-handoff-notice-summary{margin:0;font-size:13px;line-height:1.5;color:#78350f}.gengage-qty-stepper{display:inline-flex;align-items:center;gap:0;border:1px solid #d1d5db;border-radius:8px;overflow:hidden;background:#fff}.gengage-qty-btn{width:var(--_gengage-qty-btn-size);height:var(--_gengage-qty-btn-size);border:none;background:transparent;color:#374151;font-size:14px;font-weight:600;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .12s}.gengage-qty-btn:hover:not(:disabled){background:#f3f4f6}.gengage-qty-btn:disabled{opacity:.35;cursor:default}.gengage-qty-value{min-width:24px;text-align:center;font-size:13px;font-weight:600;color:#1f2937;-webkit-user-select:none;user-select:none}.gengage-qty-submit{border:none;border-left:1px solid #d1d5db;background:var(--_gengage-success-color);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;padding:6px 12px;transition:filter .12s ease,transform .12s ease}.gengage-qty-submit:hover{filter:brightness(1.08)}.gengage-qty-submit:active{transform:translateY(1px)}.gengage-qty-stepper--compact{border-radius:14px;box-shadow:0 2px 6px #0000001f}.gengage-qty-stepper--compact .gengage-qty-btn{width:var(--_gengage-qty-btn-size-compact);height:var(--_gengage-qty-btn-size-compact);font-size:12px}.gengage-qty-stepper--compact .gengage-qty-value{min-width:18px;font-size:12px}.gengage-qty-stepper--compact .gengage-qty-submit{padding:4px 8px;font-size:13px;border-radius:0 14px 14px 0}.gengage-chat-product-details-atc-stepper{border-radius:10px}.gengage-chat-product-details-atc-stepper .gengage-qty-btn{width:32px;height:32px}.gengage-chat-product-details-atc-stepper .gengage-qty-value{min-width:28px;font-size:14px}.gengage-chat-product-details-atc-stepper .gengage-qty-submit{padding:8px 18px;font-size:14px;border-radius:0 10px 10px 0}.gengage-chat-product-details-share{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid #d1d5db;border-radius:10px;background:transparent;color:#6b7280;cursor:pointer;transition:color .12s,border-color .12s,background-color .12s;position:relative;flex-shrink:0}.gengage-chat-product-details-share:hover{color:var(--gengage-primary-color, #3b82f6);border-color:var(--gengage-primary-color, #3b82f6);background:#f0f7ff}.gengage-chat-product-details-share:before{content:attr(aria-label);position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#1e293b;color:#fff;font-size:11px;font-weight:500;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease;z-index:2}.gengage-chat-product-details-share:hover:before{opacity:1}.gengage-chat-product-details-share--copied:after{content:"✓";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:var(--_gengage-success-color);color:#fff;border-radius:10px;font-size:16px;font-weight:700}.gengage-chat-launcher:focus-visible,.gengage-chat-close:focus-visible,.gengage-chat-header-btn:focus-visible,.gengage-chat-header-powered:focus-visible,.gengage-chat-proactive-accept:focus-visible,.gengage-chat-proactive-dismiss:focus-visible,.gengage-chat-send:focus-visible,.gengage-chat-action-btn:focus-visible,.gengage-chat-pill:focus-visible,.gengage-chat-input-chip:focus-visible,.gengage-chat-pills-arrow:focus-visible,.gengage-chat-error-retry:focus-visible,.gengage-chat-product-card-cta:focus-visible,.gengage-chat-product-details-cta:focus-visible,.gengage-chat-product-details-atc:focus-visible,.gengage-chat-product-detail-tab:focus-visible,.gengage-chat-panel-divider-toggle:focus-visible,.gengage-chat-panel-topbar-back:focus-visible,.gengage-chat-panel-topbar-forward:focus-visible,.gengage-chat-rollback-btn:focus-visible,.gengage-chat-ai-toppick-cta:focus-visible,.gengage-chat-comparison-view-btn:focus-visible,.gengage-chat-comparison-toggle-btn:focus-visible,.gengage-chat-comparison-floating-btn:focus-visible,.gengage-chat-comparison-checkbox:focus-visible,.gengage-chat-product-sort-btn:focus-visible,.gengage-chat-product-variant-btn:focus-visible,.gengage-chat-product-gallery-thumb:focus-visible,.gengage-chat-thumbnail-btn:focus-visible,.gengage-chat-find-similar-pill:focus-visible,.gengage-chat-favorite-btn:focus-visible,.gengage-chat-attach-btn:focus-visible,.gengage-chat-mic-btn:focus-visible,.gengage-chat-attachment-remove:focus-visible,.gengage-chat-kvkk-dismiss:focus-visible,.gengage-chat-choice-prompter-cta:focus-visible,.gengage-chat-choice-prompter-dismiss:focus-visible,.gengage-chat-categories-tab:focus-visible,.gengage-chat-categories-filter-tag:focus-visible,.gengage-chat-product-grid-view-more:focus-visible,.gengage-chat-product-details-share:focus-visible,.gengage-qty-btn:focus-visible,.gengage-qty-submit:focus-visible{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:2px}', Oa = L({
3061
+ role: be(["user", "assistant"]),
3062
+ content: x(),
3063
+ timestamp: Y().optional()
3064
+ }), qa = L({
3065
+ sku: x(),
3066
+ name: x(),
3067
+ imageUrl: x().url().optional(),
3068
+ price: x().optional(),
3069
+ originalPrice: x().optional(),
3070
+ url: x().url(),
3071
+ /** Override CTA label (default: "View product") */
3072
+ ctaLabel: x().optional()
3073
+ }), ja = L({
3074
+ buttons: B(
3075
+ L({
3076
+ label: x(),
3077
+ /** Opaque action payload forwarded to the backend when clicked. */
3078
+ action: L({
3079
+ title: x(),
3080
+ type: x(),
3081
+ payload: $().optional()
3082
+ })
3083
+ })
3084
+ )
3085
+ }), Va = L({}), Ga = L({
3086
+ label: x().optional()
3087
+ }), me = L({
3088
+ sku: x(),
3089
+ name: x(),
3090
+ price: x(),
3091
+ imageUrl: x().optional(),
3092
+ rating: Y().optional(),
3093
+ reviewCount: Y().optional()
3094
+ }), $a = L({
3095
+ recommended: me,
3096
+ products: B(me),
3097
+ attributes: B(
3098
+ L({
3099
+ label: x(),
3100
+ values: B(x())
3101
+ })
3102
+ ),
3103
+ highlights: B(x()),
3104
+ specialCases: B(x()).optional(),
3105
+ recommendedText: x().optional(),
3106
+ winnerHits: ae(
3107
+ x(),
3108
+ L({
3109
+ positive: B(x()).optional(),
3110
+ negative: B(x()).optional()
3111
+ })
3112
+ ).optional(),
3113
+ productActions: ae(
3114
+ x(),
3115
+ L({
3116
+ title: x(),
3117
+ type: x(),
3118
+ payload: $().optional()
3119
+ })
3120
+ ).optional()
3121
+ }), Ka = L({
3122
+ label: x(),
3123
+ sentiment: be(["positive", "negative", "neutral"]).optional()
3124
+ }), Wa = L({
3125
+ product: ae(x(), $()),
3126
+ role: x().optional(),
3127
+ reason: x().optional(),
3128
+ labels: B(Ka).optional(),
3129
+ expertQualityScore: Y().optional(),
3130
+ reviewHighlight: x().optional(),
3131
+ action: L({
3132
+ title: x(),
3133
+ type: x(),
3134
+ payload: $().optional()
3135
+ }).optional()
3136
+ }), Ya = L({
3137
+ suggestions: B(Wa)
3138
+ }), Qa = L({
3139
+ title: x().optional(),
3140
+ text: x().optional(),
3141
+ reviewCount: x().optional(),
3142
+ action: L({ title: x(), type: x(), payload: $().optional() })
3143
+ }), Xa = L({
3144
+ entries: B(
3145
+ L({
3146
+ name: x(),
3147
+ image: x().optional(),
3148
+ description: x().optional(),
3149
+ action: L({ title: x(), type: x(), payload: $().optional() })
3150
+ })
3151
+ )
3152
+ }), Ja = L({
3153
+ entries: B(
3154
+ L({
3155
+ shortName: x(),
3156
+ detailedMessage: x().optional(),
3157
+ whyDifferent: x().optional(),
3158
+ image: x().optional(),
3159
+ action: L({ title: x(), type: x(), payload: $().optional() })
3160
+ })
3161
+ )
3162
+ }), Ne = L({
3163
+ title: x(),
3164
+ type: x(),
3165
+ payload: $().optional()
3166
+ }), Za = L({
3167
+ name: x().optional(),
3168
+ variant_name: x().optional(),
3169
+ sku: x().optional(),
3170
+ price: re([Y(), x()]).optional()
3171
+ }), en = L({
3172
+ product: L({
3173
+ sku: x().optional(),
3174
+ name: x().optional(),
3175
+ images: B(x()).optional(),
3176
+ imageUrl: x().optional(),
3177
+ rating: Y().optional(),
3178
+ reviewCount: Y().optional(),
3179
+ price: x().optional(),
3180
+ originalPrice: x().optional(),
3181
+ price_async: oe().optional(),
3182
+ inStock: oe().optional(),
3183
+ promotions: B(x()).optional(),
3184
+ variants: B(Za).optional(),
3185
+ url: x().optional(),
3186
+ cartCode: x().optional(),
3187
+ description: x().optional(),
3188
+ specifications: re([ae(x(), x()), B(L({ key: x(), value: x() }))]).optional()
3189
+ }).optional(),
3190
+ action: Ne.optional()
3191
+ }), tn = L({
3192
+ endOfList: oe().optional()
3193
+ }), an = L({
3194
+ review_class: x().optional(),
3195
+ review_text: x().optional(),
3196
+ review_rating: re([x(), Y()]).optional(),
3197
+ review_tag: x().optional()
3198
+ }), nn = L({
3199
+ reviews: B(an).optional()
3200
+ }), on = L({
3201
+ productName: x().optional(),
3202
+ pros: B(x()).optional(),
3203
+ cons: B(x()).optional()
3204
+ }), rn = L({
3205
+ groups: B(
3206
+ L({
3207
+ groupName: x(),
3208
+ products: B(ae(x(), $())).optional()
3209
+ })
3210
+ ).optional(),
3211
+ filterTags: B(
3212
+ L({
3213
+ title: x(),
3214
+ action: Ne.optional()
3215
+ })
3216
+ ).optional()
3217
+ }), sn = L({
3218
+ summary: x().optional(),
3219
+ products_discussed: B(x()).optional(),
3220
+ user_sentiment: x().optional()
3221
+ }), pn = {
3222
+ components: {
3223
+ MessageBubble: {
3224
+ schema: Oa,
3225
+ description: "A single chat message bubble for user or assistant turns."
3226
+ },
3227
+ ProductCard: {
3228
+ schema: qa,
3229
+ description: "A product card rendered inline in the chat stream."
3230
+ },
3231
+ ActionButtons: {
3232
+ schema: ja,
3233
+ description: "A horizontal row of quick-reply action buttons."
3234
+ },
3235
+ TypingIndicator: {
3236
+ schema: Va,
3237
+ description: "An animated indicator shown while the assistant is typing."
3238
+ },
3239
+ Divider: {
3240
+ schema: Ga,
3241
+ description: "A horizontal rule with an optional label."
3242
+ },
3243
+ ComparisonTable: {
3244
+ schema: $a,
3245
+ description: "A product comparison table with recommended pick, attribute rows, and highlights."
3246
+ },
3247
+ AITopPicks: {
3248
+ schema: Ya,
3249
+ description: "Rich AI-curated product suggestion cards with roles, sentiment labels, scores, and review quotes."
3250
+ },
3251
+ GroundingReviewCard: {
3252
+ schema: Qa,
3253
+ description: "A card showing review grounding data with review count and CTA."
3254
+ },
3255
+ AIGroupingCards: {
3256
+ schema: Xa,
3257
+ description: "Category grouping cards with images and labels for product discovery."
3258
+ },
3259
+ AISuggestedSearchCards: {
3260
+ schema: Ja,
3261
+ description: "Suggested search cards with images, descriptions, and differentiation."
3262
+ },
3263
+ ProductDetailsPanel: {
3264
+ schema: en,
3265
+ description: "Full product detail view with images, specs, variants, and purchase actions."
3266
+ },
3267
+ ProductGrid: {
3268
+ schema: tn,
3269
+ description: 'A scrollable grid of ProductCard children with optional "more" pagination.'
3270
+ },
3271
+ ReviewHighlights: {
3272
+ schema: nn,
3273
+ description: "A list of highlighted customer reviews with sentiment and ratings."
3274
+ },
3275
+ ProsAndCons: {
3276
+ schema: on,
3277
+ description: "A pros and cons list for a product."
3278
+ },
3279
+ CategoriesContainer: {
3280
+ schema: rn,
3281
+ description: "Tabbed product groups with optional filter tag buttons."
3282
+ },
3283
+ HandoffNotice: {
3284
+ schema: sn,
3285
+ description: "A notice shown when the conversation is escalated to a human agent."
3286
+ }
3287
+ }
3288
+ };
3289
+ function cn(o) {
3290
+ return o.length > 120 ? !1 : /^[a-zA-Z0-9#(),.\s%/\-]+$/.test(o);
3291
+ }
3292
+ function te(o) {
3293
+ return typeof o == "object" && o !== null && typeof o.type == "string";
3294
+ }
3295
+ class ln extends ze {
3296
+ constructor() {
3297
+ super(...arguments), this._shadow = null, this._rootEl = null, this._launcher = null, this._drawer = null, this._bridge = null, this._activityTracker = null, this._heartbeat = null, this._proactiveShown = !1, this._drawerVisible = !1, this._messages = [], this._currentMessageId = 0, this._abortControllers = /* @__PURE__ */ new Set(), this._currentThreadId = null, this._lastThreadId = null, this._chatCreatedAt = "", this._lastBackendContext = null, this._productSort = { type: "related" }, this._comparisonSelectMode = !1, this._comparisonSelectedSkus = [], this._thumbnailEntries = [], this._choicePrompterEl = null, this._openState = "full", this._mobileBreakpoint = 768, this._isMobileViewport = !1, this._pdpLaunched = !1, this._i18n = ce, this._extendedModeManager = null, this._activeTypewriter = null, this._activeTtsHandle = null, this._activeRequestThreadId = null, this._skuToProductItem = {}, this._conversationMode = null, this._initComplete = !1, this._pendingActions = [], this._bridgeContext = null, this._cartQuantity = null, this._threadsWithFirstBot = /* @__PURE__ */ new Set(), this._panel = null, this._session = null, this._eventCallbacks = /* @__PURE__ */ new Map();
3298
+ }
3299
+ async onInit(e) {
3300
+ this._i18n = this._resolveI18n(e), this._chatCreatedAt = (/* @__PURE__ */ new Date()).toISOString(), this._shadow = this.root.attachShadow({ mode: "open" });
3301
+ const t = document.createElement("style");
3302
+ t.textContent = Fa, this._shadow.appendChild(t);
3303
+ const a = document.createElement("div");
3304
+ a.className = "gengage-chat-root", this._rootEl = a, this._shadow.appendChild(a);
3305
+ const n = e.variant ?? "floating";
3306
+ if (n === "floating") {
3307
+ const c = {
3308
+ onClick: () => this.open(),
3309
+ ariaLabel: this._i18n.openButton
3310
+ };
3311
+ e.launcherSvg !== void 0 && (c.svgMarkup = e.launcherSvg), e.hideMobileLauncher !== void 0 && (c.hideMobile = e.hideMobileLauncher), e.mobileBreakpoint !== void 0 && (c.mobileBreakpoint = e.mobileBreakpoint), e.launcherTooltip !== void 0 && (c.tooltip = e.launcherTooltip), this._launcher = zt(c), a.appendChild(this._launcher.container);
3312
+ }
3313
+ n === "overlay" && a.classList.add("gengage-chat--overlay");
3314
+ const i = document.createElement("div");
3315
+ a.appendChild(i), this._drawer = new Bt(i, {
3316
+ i18n: this._i18n,
3317
+ onSend: (c, h) => this._sendMessage(c, h),
3318
+ onClose: () => this.close(),
3319
+ onAttachment: (c) => this._handleAttachment(c),
3320
+ onPanelToggle: () => {
3321
+ this._drawer?.persistPanelState(e.accountId);
3322
+ },
3323
+ onRollback: (c) => this._handleRollback(c),
3324
+ onPanelBack: () => this._panel?.navigateBack(),
3325
+ onPanelForward: () => this._panel?.navigateForward(),
3326
+ headerTitle: e.headerTitle,
3327
+ headerAvatarUrl: e.headerAvatarUrl,
3328
+ headerBadge: e.headerBadge,
3329
+ headerCartUrl: e.headerCartUrl,
3330
+ headerFavoritesToggle: e.headerFavoritesToggle,
3331
+ onFavoritesClick: () => {
3332
+ De(), e.onFavoritesClick?.();
3333
+ },
3334
+ onThumbnailClick: (c) => this._rollbackToThread(c),
3335
+ onLinkClick: (c) => {
3336
+ this._saveSessionAndOpenURL(c);
3337
+ },
3338
+ voiceEnabled: e.voiceEnabled,
3339
+ voiceLang: e.locale ? `${e.locale.split("-")[0] ?? "tr"}-${(e.locale.split("-")[1] ?? e.locale.split("-")[0] ?? "TR").toUpperCase()}` : void 0
3340
+ }), this._extendedModeManager = new Aa({
3341
+ onChange: (c) => this._panel?.notifyExtension(c),
3342
+ productDetailsInPanel: e.isDemoWebsite ?? !1
3343
+ }), this._panel = new Pa({
3344
+ drawer: () => this._drawer,
3345
+ shadow: () => this._shadow,
3346
+ currentThreadId: () => this._currentThreadId,
3347
+ bridge: () => this._bridge,
3348
+ extendedModeManager: () => this._extendedModeManager,
3349
+ i18n: () => this._i18n,
3350
+ rollbackToThread: (c) => this._rollbackToThread(c)
3351
+ }), n !== "inline" && this._drawer.getElement().classList.add("gengage-chat-drawer--hidden"), this._drawer.restorePanelState(e.accountId), (e.panelMode ?? "auto") === "collapsed" ? this._drawer.setPanelCollapsed(!0) : this._drawer.setForceExpanded();
3352
+ const s = sessionStorage.getItem("gengage_restore_session_id"), l = sessionStorage.getItem("gengage_restore_sku");
3353
+ s && l && (sessionStorage.removeItem("gengage_restore_session_id"), sessionStorage.removeItem("gengage_restore_sku"));
3354
+ try {
3355
+ const c = new La();
3356
+ await c.open(), this._session = new he(c), await this._restoreFromIndexedDB();
3357
+ } catch {
3358
+ this._session = new he(null);
3359
+ }
3360
+ this._registerPublicAPI(), e.mobileInitialState !== void 0 && (this._openState = e.mobileInitialState), this._mobileBreakpoint = e.mobileBreakpoint ?? 768, this._syncViewportState();
3361
+ const g = () => this._syncViewportState();
3362
+ if (window.addEventListener("resize", g, { passive: !0 }), this.addCleanup(() => window.removeEventListener("resize", g)), window.visualViewport) {
3363
+ const c = () => {
3364
+ if (!this._drawerVisible || !this._isMobileViewport) return;
3365
+ const h = this._drawer?.getElement();
3366
+ if (!h) return;
3367
+ const m = window.innerHeight - (window.visualViewport?.height ?? window.innerHeight);
3368
+ h.style.setProperty("--gengage-keyboard-offset", `${Math.max(0, m)}px`);
3369
+ };
3370
+ window.visualViewport.addEventListener("resize", c), this.addCleanup(() => window.visualViewport?.removeEventListener("resize", c));
3371
+ }
3372
+ n === "inline" && (this._drawerVisible = !0, this.isVisible = !0, this._applyOpenStateClasses()), this._bridge = new ct({
3373
+ namespace: "chat",
3374
+ onMessage: (c) => this._handleBridgeMessage(c)
3375
+ }), this._activityTracker = new Rt({
3376
+ idleThresholdMs: e.proactiveDelayMs ?? 3e4,
3377
+ onActivity: (c) => {
3378
+ if (c.type === "idle" && !this._proactiveShown && !this._drawerVisible) {
3379
+ const h = e.proactiveMinScrollDepth ?? 0;
3380
+ if (h > 0 && (this._activityTracker?.maxScrollDepth ?? 0) < h * 100)
3381
+ return;
3382
+ try {
3383
+ if (sessionStorage.getItem("gengage_proactive_shown")) return;
3384
+ } catch {
3385
+ }
3386
+ if (this._isProactiveCooldownActive()) return;
3387
+ e.proactiveFetchActions ? this._fetchAndShowProactive() : e.proactiveMessage && this._showProactivePopup(e.proactiveMessage);
3388
+ }
3389
+ }
3390
+ }), this.addCleanup(() => this._activityTracker?.destroy()), e.enableHeartbeat && (this._heartbeat = new Ft({
3391
+ middlewareUrl: e.middlewareUrl,
3392
+ accountId: e.accountId,
3393
+ sessionId: e.session?.sessionId ?? "",
3394
+ locale: e.locale ?? "tr",
3395
+ intervalMs: e.heartbeatIntervalMs ?? 3e4,
3396
+ getPageType: () => this.config.pageContext?.pageType ?? "other",
3397
+ getCurrentSku: () => this.config.pageContext?.sku ?? "",
3398
+ onMessage: (c) => {
3399
+ if (!this._proactiveShown && !this._drawerVisible && c.message) {
3400
+ const h = [];
3401
+ if (c.suggested_actions && Array.isArray(c.suggested_actions))
3402
+ for (const m of c.suggested_actions)
3403
+ m.title && te(m.requestDetails) && h.push({
3404
+ title: m.title,
3405
+ onSelect: () => {
3406
+ this.openWithAction(m.requestDetails);
3407
+ }
3408
+ });
3409
+ this._showProactivePopup(c.message, h.length > 0 ? h : void 0);
3410
+ }
3411
+ }
3412
+ }), this._heartbeat.start(), this.addCleanup(() => this._heartbeat?.destroy())), this._initComplete = !0;
3413
+ for (const c of this._pendingActions)
3414
+ this._sendAction(c.action, c.options);
3415
+ this._pendingActions = [], O("gengage:chat:ready", {}), Re("chat"), e.onReady?.();
3416
+ }
3417
+ onUpdate(e) {
3418
+ }
3419
+ onShow() {
3420
+ this._showDrawer(), this.emit("open"), O("gengage:chat:open", { state: this._openState }), Ue("chat"), this.config.onOpen?.(), !this._pdpLaunched && this.config.pageContext?.sku && (this._pdpLaunched = !0, this._sendAction(
3421
+ {
3422
+ title: "",
3423
+ type: "launchSingleProduct",
3424
+ payload: { sku: this.config.pageContext.sku }
3425
+ },
3426
+ { silent: !0 }
3427
+ ));
3428
+ }
3429
+ onHide() {
3430
+ (this.config.variant ?? "floating") === "floating" && (this.root.style.display = ""), this._hideDrawer(), this.emit("close"), O("gengage:chat:close", {}), this.config.onClose?.();
3431
+ }
3432
+ onDestroy() {
3433
+ this._abortControllers.forEach((e) => e.abort()), this._abortControllers.clear(), this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._activeTtsHandle?.stop(), this._activeTtsHandle = null, this._bridge?.destroy(), this._bridge = null, this._extendedModeManager = null, this._panel?.destroy(), this._panel = null, this._session?.close(), this._session = null, window.gengage && delete window.gengage.chat, this._shadow && (this._shadow.innerHTML = "", this._shadow = null), this._rootEl = null;
3434
+ }
3435
+ // ---------------------------------------------------------------------------
3436
+ // Public API
3437
+ // ---------------------------------------------------------------------------
3438
+ open(e) {
3439
+ e?.state !== void 0 && (this._openState = e.state, this._drawerVisible && this._applyOpenStateClasses()), this.show(), e?.initialMessage !== void 0 && this._sendMessage(e.initialMessage);
3440
+ }
3441
+ openWithAction(e, t) {
3442
+ t?.sku !== void 0 && this.update({ sku: t.sku }), this._pdpLaunched = !0, t?.state !== void 0 ? this._openState = t.state : this._isMobileViewport && (this._openState = "half"), this.show(), this._drawerVisible && this._applyOpenStateClasses(), this._sendAction(e);
3443
+ }
3444
+ /** Send a user message programmatically (same flow as typing + submit). */
3445
+ sendMessage(e) {
3446
+ this._sendMessage(e);
3447
+ }
3448
+ /** Send a backend action programmatically. */
3449
+ sendAction(e, t) {
3450
+ this._sendAction(e, t);
3451
+ }
3452
+ close() {
3453
+ this.hide();
3454
+ }
3455
+ saveSession(e, t) {
3456
+ sessionStorage.setItem("gengage_restore_session_id", e), sessionStorage.setItem("gengage_restore_sku", t);
3457
+ }
3458
+ get isOpen() {
3459
+ return this._drawerVisible;
3460
+ }
3461
+ /**
3462
+ * Register a callback for a GA4 event name (e.g. 'gengage-cart-add').
3463
+ * The callback receives the event detail and should return true (success) or false (failure).
3464
+ * For add-to-cart, failure triggers an error message in the chat.
3465
+ * @returns unsubscribe function
3466
+ */
3467
+ addCallback(e, t) {
3468
+ let a = this._eventCallbacks.get(e);
3469
+ return a || (a = /* @__PURE__ */ new Set(), this._eventCallbacks.set(e, a)), a.add(t), () => {
3470
+ a.delete(t), a.size === 0 && this._eventCallbacks.delete(e);
3471
+ };
3472
+ }
3473
+ // ---------------------------------------------------------------------------
3474
+ // Private
3475
+ // ---------------------------------------------------------------------------
3476
+ _handleBridgeMessage(e) {
3477
+ switch (e.type) {
3478
+ case "openChat":
3479
+ this.open();
3480
+ break;
3481
+ case "closeChat":
3482
+ this.close();
3483
+ break;
3484
+ case "startNewChatWithLauncherAction": {
3485
+ const t = e.payload, a = t?.action, n = te(a) ? a : te(t) ? t : null;
3486
+ n && this._sendAction(n, { silent: !0 }), this.open();
3487
+ break;
3488
+ }
3489
+ case "startNewChatWithDetailContext": {
3490
+ const t = e.payload;
3491
+ if (t && typeof t == "object") {
3492
+ this._bridgeContext = t;
3493
+ const a = t.sku;
3494
+ if (a && this.update({ sku: a }), te(t.action)) {
3495
+ this._pdpLaunched = !0, this.open(), this._sendAction(t.action);
3496
+ break;
3497
+ }
3498
+ }
3499
+ this.open();
3500
+ break;
3501
+ }
3502
+ case "launcherAction": {
3503
+ const a = e.payload?.action;
3504
+ a && typeof a == "object" && "type" in a && this._sendAction(a);
3505
+ break;
3506
+ }
3507
+ case "scrollToBottom":
3508
+ this._drawer?.scrollToBottomIfNeeded();
3509
+ break;
3510
+ case "addToCardHandler": {
3511
+ this._bridge?.send("addToCardResult", e.payload);
3512
+ break;
3513
+ }
3514
+ case "cartQuantityHandler": {
3515
+ const t = e.payload;
3516
+ t && "quantity" in t && typeof t.quantity == "number" && (this._cartQuantity = t.quantity);
3517
+ break;
3518
+ }
3519
+ case "minimizeRequestedByUser":
3520
+ this._extendedModeManager?.setHiddenByUser(!0);
3521
+ break;
3522
+ case "bgColorChange": {
3523
+ const a = e.payload?.color;
3524
+ typeof a == "string" && cn(a) && this._shadow && this._shadow.host.style.setProperty("--gengage-chat-bg", a);
3525
+ break;
3526
+ }
3527
+ }
3528
+ }
3529
+ _registerPublicAPI() {
3530
+ window.gengage || (window.gengage = {}), window.gengage.chat = {
3531
+ open: (e) => this.open(e),
3532
+ openWithAction: (e, t) => this.openWithAction(e, t),
3533
+ sendMessage: (e) => this.sendMessage(e),
3534
+ sendAction: (e, t) => this.sendAction(e, t),
3535
+ close: () => this.close(),
3536
+ saveSession: (e, t) => this.saveSession(e, t),
3537
+ get isOpen() {
3538
+ return !1;
3539
+ },
3540
+ // Placeholder, overridden below
3541
+ on: (e, t) => this.on(e, t),
3542
+ trackCheckout: (e, t) => this.trackCheckout(e, t),
3543
+ flushMeteringSummary: (e) => this.flushMeteringSummary(e),
3544
+ addCallback: (e, t) => this.addCallback(e, t)
3545
+ }, Object.defineProperty(window.gengage.chat, "isOpen", {
3546
+ get: () => this._drawerVisible
3547
+ });
3548
+ }
3549
+ _showDrawer() {
3550
+ if (this._drawerVisible) return;
3551
+ this._drawerVisible = !0;
3552
+ const e = this._drawer?.getElement();
3553
+ e && e.classList.remove("gengage-chat-drawer--hidden"), this._applyOpenStateClasses(), this._isMobileViewport && this._openState === "half" || this._drawer?.focusInput(), this._extendedModeManager?.setChatShown(!0);
3554
+ }
3555
+ _showProactivePopup(e, t) {
3556
+ if (this._proactiveShown || !this._rootEl) return;
3557
+ this._proactiveShown = !0;
3558
+ try {
3559
+ sessionStorage.setItem("gengage_proactive_shown", "1");
3560
+ } catch {
3561
+ }
3562
+ this._setProactiveCooldown();
3563
+ const a = {
3564
+ message: e,
3565
+ onAccept: () => this.open(),
3566
+ onDismiss: () => {
3567
+ },
3568
+ ...t && t.length > 0 && { actionButtons: t }
3569
+ };
3570
+ this.config.proactiveAcceptLabel !== void 0 && (a.acceptLabel = this.config.proactiveAcceptLabel);
3571
+ const n = Dt(a);
3572
+ this._rootEl.appendChild(n);
3573
+ }
3574
+ /** Fetch proactive actions from backend and show popup with per-action buttons. */
3575
+ async _fetchAndShowProactive() {
3576
+ if (!this._proactiveShown)
3577
+ try {
3578
+ const e = {
3579
+ middlewareUrl: this.config.middlewareUrl,
3580
+ accountId: this.config.accountId,
3581
+ backendType: this.config.backendType ?? "v1"
3582
+ }, t = this.config.pageContext?.sku, a = this.config.pageContext?.pageType, n = this.config.locale, i = await _t(
3583
+ {
3584
+ account_id: this.config.accountId,
3585
+ ...t && { sku: t },
3586
+ ...a && { page_type: a },
3587
+ ...n && { output_language: n }
3588
+ },
3589
+ e
3590
+ );
3591
+ if (!i) return;
3592
+ const r = i.question ?? i.title ?? "";
3593
+ if (!r) return;
3594
+ const s = [];
3595
+ if (i.actions && Array.isArray(i.actions))
3596
+ for (const l of i.actions) {
3597
+ const g = l, c = g.title;
3598
+ if (c && te(g.requestDetails)) {
3599
+ const h = g.requestDetails;
3600
+ s.push({
3601
+ title: c,
3602
+ onSelect: () => {
3603
+ this.openWithAction(h);
3604
+ }
3605
+ });
3606
+ }
3607
+ }
3608
+ this._showProactivePopup(r, s);
3609
+ } catch {
3610
+ }
3611
+ }
3612
+ _proactiveCooldownKey() {
3613
+ return `gengage_proactive_time_${this.config.accountId}`;
3614
+ }
3615
+ _isProactiveCooldownActive() {
3616
+ try {
3617
+ const e = localStorage.getItem(this._proactiveCooldownKey());
3618
+ if (e) {
3619
+ const t = Date.now() - parseInt(e, 10), a = this.config.proactiveCooldownMs ?? 36e5;
3620
+ return t < a;
3621
+ }
3622
+ } catch {
3623
+ }
3624
+ return !1;
3625
+ }
3626
+ _setProactiveCooldown() {
3627
+ try {
3628
+ localStorage.setItem(this._proactiveCooldownKey(), String(Date.now()));
3629
+ } catch {
3630
+ }
3631
+ }
3632
+ _hideDrawer() {
3633
+ if (!this._drawerVisible) return;
3634
+ this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._activeTtsHandle?.stop(), this._activeTtsHandle = null, this._drawerVisible = !1, this._openState = "full", this._drawer?.clearPanel();
3635
+ const e = this._drawer?.getElement();
3636
+ e && e.classList.add("gengage-chat-drawer--hidden"), this._applyOpenStateClasses(), this._extendedModeManager?.setChatShown(!1);
3637
+ }
3638
+ _syncViewportState() {
3639
+ if (this._rootEl) {
3640
+ if (this._isMobileViewport = window.innerWidth <= this._mobileBreakpoint, this._rootEl.classList.toggle("gengage-chat-root--mobile", this._isMobileViewport), this._launcher) {
3641
+ const e = this._isMobileViewport && this.config.hideMobileLauncher === !0;
3642
+ this._launcher.container.classList.toggle("gengage-chat-launcher--hidden-mobile", e);
3643
+ }
3644
+ this._applyOpenStateClasses();
3645
+ }
3646
+ }
3647
+ _applyOpenStateClasses() {
3648
+ if (!this._rootEl) return;
3649
+ const e = this._drawerVisible && this._isMobileViewport && this._openState === "half", t = this._drawerVisible && this._isMobileViewport && this._openState === "full";
3650
+ this._rootEl.classList.toggle("gengage-chat-root--open", this._drawerVisible), this._rootEl.classList.toggle("gengage-chat-root--mobile-half", e), this._rootEl.classList.toggle("gengage-chat-root--mobile-full", t);
3651
+ }
3652
+ _handleAttachment(e) {
3653
+ const t = ft(e);
3654
+ if (!t.ok) {
3655
+ const a = t.reason === "invalid_type" ? this._i18n.invalidFileType : this._i18n.fileTooLarge;
3656
+ O("gengage:global:error", {
3657
+ message: a,
3658
+ source: "chat"
3659
+ });
3660
+ return;
3661
+ }
3662
+ this._drawer?.stageAttachment(e);
3663
+ }
3664
+ _sendMessage(e, t) {
3665
+ He(), this._messages.some((i) => i.role === "user") || Fe();
3666
+ const n = {
3667
+ title: e,
3668
+ type: "user_message",
3669
+ payload: e
3670
+ };
3671
+ t !== void 0 ? this._sendAction(n, { attachment: t }) : this._sendAction(n);
3672
+ }
3673
+ _sendAction(e, t) {
3674
+ if (this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._activeTtsHandle?.stop(), this._activeTtsHandle = null, !this._initComplete) {
3675
+ this._pendingActions.length < 10 && this._pendingActions.push({ action: e, options: t });
3676
+ return;
3677
+ }
3678
+ if (this._choicePrompterEl?.remove(), this._choicePrompterEl = null, this._currentThreadId && this._lastThreadId && this._lastThreadId > this._currentThreadId) {
3679
+ const p = this._currentThreadId, y = this._messages.filter((k) => k.threadId !== void 0 && k.threadId > p);
3680
+ this._messages = this._messages.filter((k) => !k.threadId || k.threadId <= p);
3681
+ for (const k of y)
3682
+ this._shadow?.querySelector(`[data-message-id="${CSS.escape(k.id)}"]`)?.remove(), this._panel.snapshots.delete(k.id), this._panel.snapshotTypes.delete(k.id);
3683
+ this._shadow?.querySelectorAll("[data-thread-id]")?.forEach((k) => {
3684
+ k instanceof HTMLElement && k.dataset.threadId && k.dataset.threadId > p && k.remove();
3685
+ });
3686
+ }
3687
+ this._drawer?.setPills([]), this._drawer?.clearInputAreaChips(), this._bridge?.send("isResponding", !0);
3688
+ const a = st();
3689
+ this._currentThreadId = a, this._lastThreadId = a;
3690
+ const n = t?.preservePanel === !0;
3691
+ if (n || (this._activeRequestThreadId = a), !t?.silent) {
3692
+ const p = this._createMessage("user", typeof e.payload == "string" ? e.payload : e.title);
3693
+ p.threadId = a, t?.attachment !== void 0 && (p.attachment = t.attachment), this._drawer?.addMessage(p), this._messages.push(p);
3694
+ }
3695
+ t?.preservePanel || (this._drawer?.hasPanelContent() ? this._drawer.showPanelLoading() : this._drawer?.clearPanel()), this._drawer?.showTypingIndicator();
3696
+ let i = "";
3697
+ const r = this._createMessage("assistant", "");
3698
+ r.threadId = a, r.status = "streaming", this._messages.push(r), t?.preservePanel || (this._abortControllers.forEach((p) => p.abort()), this._abortControllers.clear());
3699
+ const s = {
3700
+ middlewareUrl: this.config.middlewareUrl,
3701
+ ...this.config.backendType ? { backendType: this.config.backendType } : {},
3702
+ ...this.config.accountId ? { accountId: this.config.accountId } : {}
3703
+ };
3704
+ t?.attachment !== void 0 && (s.attachment = t.attachment);
3705
+ const g = this._getVisibleMessages().filter((p) => p.content).slice(-50).map((p) => ({
3706
+ role: p.role === "user" ? "user" : "model",
3707
+ content: p.content ?? ""
3708
+ })), c = {
3709
+ outputLanguage: Ha(this.config.locale),
3710
+ parentUrl: window.location.href,
3711
+ windowWidth: String(window.innerWidth),
3712
+ windowHeight: String(window.innerHeight),
3713
+ selfUrl: "",
3714
+ id: this.config.session?.sessionId ?? "",
3715
+ userId: this.config.session?.userId ?? "",
3716
+ appId: this.config.accountId,
3717
+ threads: [],
3718
+ createdAt: this._chatCreatedAt,
3719
+ kvkkApproved: ue(this.config.accountId),
3720
+ voiceEnabled: this.config.voiceEnabled ?? !1,
3721
+ threadId: a,
3722
+ isControlGroup: this.config.session?.abTestVariant === "control",
3723
+ isMobile: this._isMobileViewport
3724
+ };
3725
+ this.config.session?.viewId !== void 0 && (c.viewId = this.config.session.viewId);
3726
+ const h = bt(e, {
3727
+ pageContext: this.config.pageContext,
3728
+ backendContext: this._lastBackendContext,
3729
+ isMobile: this._isMobileViewport
3730
+ }), m = {
3731
+ account_id: this.config.accountId,
3732
+ session_id: this.config.session?.sessionId ?? "",
3733
+ correlation_id: this.config.session?.sessionId ?? "",
3734
+ type: h.type,
3735
+ locale: this.config.locale ?? "tr",
3736
+ meta: c,
3737
+ context: {
3738
+ // Spread backend context (panel, message_id, etc.) but preserve FE's
3739
+ // authoritative chatHistory — the backend's stale `messages` must not
3740
+ // overwrite the up-to-date conversation history built by the widget.
3741
+ ...this._lastBackendContext ?? {},
3742
+ messages: g,
3743
+ // V1 backend reads session_id from context (not top-level).
3744
+ // Include here for V1 compatibility; V2 uses thread_id from meta.
3745
+ session_id: this.config.session?.sessionId ?? ""
3746
+ }
3747
+ };
3748
+ this.config.session?.userId !== void 0 && (m.user_id = this.config.session.userId), this.config.session?.viewId !== void 0 && (m.view_id = this.config.session.viewId), h.payload !== void 0 && (m.payload = h.payload), this.config.pageContext?.sku !== void 0 && (m.sku = this.config.pageContext.sku), this.config.pageContext?.pageType !== void 0 && (m.page_type = this.config.pageContext.pageType);
3749
+ const d = crypto.randomUUID(), v = Date.now();
3750
+ let w = 0, b = !1, N = !1;
3751
+ this.track(
3752
+ Oe(this.analyticsContext(), {
3753
+ endpoint: "process_action",
3754
+ request_id: d,
3755
+ widget: "chat"
3756
+ })
3757
+ );
3758
+ let I = null;
3759
+ I = yt(
3760
+ m,
3761
+ {
3762
+ onTextChunk: (p, y, _) => {
3763
+ if (!n && a !== this._activeRequestThreadId || (i += p, this._drawer?.removeTypingIndicator(), _?.skuToProductItem && (this._skuToProductItem = { ...this._skuToProductItem, ..._.skuToProductItem }), _?.conversationMode && (this._conversationMode = _.conversationMode), this.track(
3764
+ rt(this.analyticsContext(), {
3765
+ request_id: d,
3766
+ chunk_index: w++,
3767
+ widget: "chat"
3768
+ })
3769
+ ), !this._drawer)) return;
3770
+ let k = i;
3771
+ if (y && le(k)) {
3772
+ const u = this.config.accountId;
3773
+ if (!ue(u)) {
3774
+ const f = Ra(k);
3775
+ f && this._drawer?.showKvkkBanner(f, () => {
3776
+ this._drawer?.hideKvkkBanner();
3777
+ }), za(u);
3778
+ }
3779
+ k = Da(k);
3780
+ }
3781
+ const A = this._shadow?.querySelector(
3782
+ `[data-message-id="${r.id}"] .gengage-chat-bubble-text`
3783
+ );
3784
+ if (A ? A.innerHTML = Z(k) : (r.content = k, r.role === "assistant" && r.threadId && !this._threadsWithFirstBot.has(r.threadId) && (this._threadsWithFirstBot.add(r.threadId), this._drawer.markFirstBotMessage(r.id)), this._drawer.addMessage(r)), y) {
3785
+ r.content = k, r.status = "done", ge();
3786
+ const u = this._shadow?.querySelector(
3787
+ `[data-message-id="${r.id}"] .gengage-chat-bubble-text`
3788
+ );
3789
+ if (u) {
3790
+ this._activeTypewriter?.cancel();
3791
+ const f = _?.productMentions;
3792
+ this._activeTypewriter = wa({
3793
+ container: u,
3794
+ html: Z(k),
3795
+ onTick: () => this._drawer?.scrollToBottomIfNeeded(),
3796
+ onComplete: () => {
3797
+ this._activeTypewriter = null, f && f.length > 0 && u && ya({
3798
+ container: u,
3799
+ mentions: f,
3800
+ onProductClick: (C) => {
3801
+ this._sendAction({
3802
+ title: f.find((S) => S.sku === C)?.short_name ?? C,
3803
+ type: "launchSingleProduct",
3804
+ payload: { sku: C }
3805
+ });
3806
+ }
3807
+ });
3808
+ }
3809
+ });
3810
+ }
3811
+ }
3812
+ },
3813
+ onUISpec: (p, y, _) => {
3814
+ if (!n && a !== this._activeRequestThreadId || y !== "chat") return;
3815
+ const k = p.elements[p.root], A = k?.type ?? "unknown";
3816
+ this.track(
3817
+ nt(this.analyticsContext(), {
3818
+ request_id: d,
3819
+ chunk_index: w,
3820
+ component_type: A,
3821
+ widget: "chat"
3822
+ })
3823
+ );
3824
+ const u = this._buildRenderContext();
3825
+ if (A === "ComparisonTable") {
3826
+ const S = k?.props?.products;
3827
+ it(Array.isArray(S) ? S.length : 0);
3828
+ }
3829
+ if (A === "ProductGrid") {
3830
+ const S = k?.children?.length ?? 0;
3831
+ ot(void 0, S);
3832
+ }
3833
+ const f = _ === "panel" && this._panel ? this._panel.toPanelSpec(p) : p, C = !r.silent && (_ !== "panel" || A === "ProductCard") && A !== "ActionButtons";
3834
+ if (_ === "panel" && this._panel) {
3835
+ N = !0, k?.props?.similarsAppend === !0 && this._panel.currentType === "ProductDetailsPanel" && this._drawer?.hasPanelContent() && !this._drawer.isPanelLoading() ? this._appendSimilarsToPanel(f, u) : A === "ProductGrid" && this._drawer?.hasPanelContent() && !this._drawer.isPanelLoading() ? this._drawer.appendPanelContent(this._renderUISpec(f, u)) : (this._drawer?.setPanelContent(this._renderUISpec(f, u)), this._panel.currentType = A), r.threadId && !this._panel.threads.includes(r.threadId) && this._panel.threads.push(r.threadId);
3836
+ const S = this._panel.currentType ?? A;
3837
+ this._panel.updateTopBar(S), this._panel.updateExtendedMode(A);
3838
+ }
3839
+ if (A === "ProductDetailsPanel" && !r.silent && _ === "panel") {
3840
+ const S = k?.props?.product;
3841
+ if (S) {
3842
+ const P = {
3843
+ root: "root",
3844
+ elements: {
3845
+ root: {
3846
+ type: "ProductSummaryCard",
3847
+ props: { product: S }
3848
+ }
3849
+ }
3850
+ }, T = this._shadow?.querySelector(".gengage-chat-messages");
3851
+ if (T) {
3852
+ const E = this._renderUISpec(P, u);
3853
+ r.threadId && (E.dataset.threadId = r.threadId), T.appendChild(E), E.scrollIntoView({ behavior: "auto", block: "end" });
3854
+ }
3855
+ }
3856
+ }
3857
+ if (C) {
3858
+ const S = this._shadow?.querySelector(".gengage-chat-messages");
3859
+ if (S) {
3860
+ const P = this._renderUISpec(p, u);
3861
+ r.threadId && (P.dataset.threadId = r.threadId), S.appendChild(P), P.scrollIntoView({ behavior: "auto", block: "end" });
3862
+ }
3863
+ }
3864
+ if ((A === "ProductGrid" || A === "ProductCard") && r.threadId) {
3865
+ const S = k?.children ?? [], P = A === "ProductGrid" ? S.map((T) => p.elements[T]?.props?.product).filter(Boolean) : [k?.props?.product].filter(Boolean);
3866
+ for (const T of P) {
3867
+ const E = T.sku, M = T.imageUrl;
3868
+ E && M && this._thumbnailEntries.push({ sku: E, imageUrl: M, threadId: r.threadId });
3869
+ }
3870
+ this._drawer?.setThumbnails(this._thumbnailEntries);
3871
+ }
3872
+ if (A === "ProductGrid" || A === "ProductDetailsPanel") {
3873
+ const P = (A === "ProductGrid" ? (k?.children ?? []).map((T) => p.elements[T]?.props?.product).filter(Boolean) : [
3874
+ k?.props?.product ?? k?.props
3875
+ ].filter(Boolean)).map((T) => T.imageUrl).filter((T) => typeof T == "string").slice(0, 5);
3876
+ P.length > 0 && this._bridge?.send("previewImages", { images: P });
3877
+ }
3878
+ if (A === "ProductGrid" && _ === "panel" && !this._comparisonSelectMode && !Sa() && (this._choicePrompterEl?.remove(), this._choicePrompterEl = Ea({
3879
+ heading: this._i18n.choicePrompterHeading,
3880
+ suggestion: this._i18n.choicePrompterSuggestion,
3881
+ ctaLabel: this._i18n.choicePrompterCta,
3882
+ onCtaClick: () => {
3883
+ this._comparisonSelectMode = !0, this._choicePrompterEl = null;
3884
+ },
3885
+ onDismiss: () => {
3886
+ this._choicePrompterEl = null;
3887
+ }
3888
+ }), this._shadow?.querySelector(".gengage-chat-panel")?.appendChild(this._choicePrompterEl)), A === "ActionButtons") {
3889
+ const S = k?.props?.buttons;
3890
+ if (S && S.length > 0) {
3891
+ const P = [], T = [];
3892
+ for (const E of S)
3893
+ if (Ca(E)) {
3894
+ const M = {
3895
+ label: E.label,
3896
+ action: E.action
3897
+ };
3898
+ E.icon && (M.icon = E.icon), P.push(M);
3899
+ } else
3900
+ T.push(E);
3901
+ P.length > 0 && this._drawer?.setInputAreaChips(
3902
+ P.map((E) => ({
3903
+ label: E.label,
3904
+ onAction: () => this._sendAction(E.action),
3905
+ ...E.icon ? { icon: E.icon } : {}
3906
+ }))
3907
+ ), T.length > 0 && this._drawer?.setPills(
3908
+ T.map((E) => {
3909
+ const M = {
3910
+ label: E.label,
3911
+ onAction: () => this._sendAction(E.action)
3912
+ };
3913
+ return E.icon && (M.icon = E.icon), E.image && (M.image = E.image), E.description && (M.description = E.description), M;
3914
+ })
3915
+ );
3916
+ }
3917
+ }
3918
+ r.uiSpec = p;
3919
+ },
3920
+ onAction: (p) => {
3921
+ if (!(!n && a !== this._activeRequestThreadId) && p.type === "action") {
3922
+ const y = {};
3923
+ this.config.actionHandling?.unknownActionPolicy !== void 0 && (y.unknownActionPolicy = this.config.actionHandling.unknownActionPolicy), this.config.actionHandling?.allowScriptCall !== void 0 && (y.allowScriptCall = this.config.actionHandling.allowScriptCall), dt(
3924
+ p,
3925
+ {
3926
+ openChat: () => this.open(),
3927
+ navigate: (_) => {
3928
+ this._bridge?.send("navigate", _), _.newTab ? window.open(_.url, "_blank", "noopener,noreferrer") : window.location.href = _.url;
3929
+ },
3930
+ saveSession: (_) => this.saveSession(_.sessionId, _.sku),
3931
+ addToCart: (_) => {
3932
+ O("gengage:similar:add-to-cart", _);
3933
+ },
3934
+ scriptCall: (_) => {
3935
+ O("gengage:chat:script-call", _), this.config.onScriptCall?.(_);
3936
+ }
3937
+ },
3938
+ y
3939
+ );
3940
+ }
3941
+ },
3942
+ onMetadata: (p) => {
3943
+ if (!(!n && a !== this._activeRequestThreadId) && p.type === "metadata" && p.meta) {
3944
+ if ((p.meta.panel !== void 0 || p.meta.messages !== void 0 || p.meta.message_id !== void 0) && (this._lastBackendContext = p.meta), p.meta.panelLoading) {
3945
+ b = !0, N = !1;
3946
+ const _ = typeof p.meta.panelPendingType == "string" ? p.meta.panelPendingType : void 0;
3947
+ this._panel && (this._panel.currentType = null), this._drawer?.showPanelLoading(_), _ && this._panel?.updateTopBarForLoading(_);
3948
+ }
3949
+ if (p.meta.voice) {
3950
+ const _ = new CustomEvent("gengage:chat:voice", {
3951
+ detail: { payload: p.meta.voice },
3952
+ bubbles: !1,
3953
+ cancelable: !0
3954
+ }), k = window.dispatchEvent(_);
3955
+ if (tt(), k) {
3956
+ const A = p.meta.voice;
3957
+ A.audio_base64 && (this._activeTtsHandle?.stop(), this._activeTtsHandle = Ht(
3958
+ A.audio_base64,
3959
+ A.content_type ?? "audio/ogg"
3960
+ ));
3961
+ }
3962
+ }
3963
+ (p.meta.redirectTarget || p.meta.redirect) && O("gengage:chat:redirect", {
3964
+ target: p.meta.redirectTarget ?? null,
3965
+ payload: p.meta.redirect ?? null
3966
+ }), p.meta.analyzeAnimation && (b = !0, N = !1, this._panel && (this._panel.currentType = null), this._drawer?.showPanelLoading(), this._panel?.updateTopBarForLoading("productDetails")), p.meta.loading && typeof p.meta.loadingText == "string" && (this._drawer?.addThinkingStep(p.meta.loadingText), this._bridge?.send("loadingMessage", { text: p.meta.loadingText })), p.meta.visitorDataResponse && this._bridge?.send("engagingMessage", p.meta.visitorDataResponse), p.meta.formType && this._bridge?.send("glovOtokoc", {
3967
+ type: p.meta.formType,
3968
+ data: p.meta.formPayload
3969
+ }), p.meta.launcherContent && this._bridge?.send("launcherContent", p.meta.launcherContent), O("gengage:chat:metadata", { payload: p.meta });
3970
+ const y = p.meta;
3971
+ typeof y.prompt_tokens == "number" && typeof y.completion_tokens == "number" && this.track(
3972
+ at(this.analyticsContext(), {
3973
+ model: p.model ?? "unknown",
3974
+ prompt_tokens: y.prompt_tokens,
3975
+ completion_tokens: y.completion_tokens,
3976
+ total_tokens: y.total_tokens ?? y.prompt_tokens + y.completion_tokens
3977
+ })
3978
+ );
3979
+ }
3980
+ },
3981
+ onError: (p) => {
3982
+ I && this._abortControllers.delete(I), !(!n && a !== this._activeRequestThreadId) && (this._bridge?.send("isResponding", !1), this._bridge?.send("loadingMessage", { text: null }), this._drawer?.removeTypingIndicator(), b && !N && this._drawer?.isPanelLoading() && this._drawer.clearPanel(), b = !1, N = !1, O("gengage:global:error", {
3983
+ source: "chat",
3984
+ code: "STREAM_ERROR",
3985
+ message: this._i18n.errorMessage
3986
+ }), this.emit("error", p), this._drawer?.showError(p.message), r.status === "streaming" && (r.status = "error"), this.track(
3987
+ et(this.analyticsContext(), {
3988
+ request_id: d,
3989
+ error_code: "STREAM_ERROR",
3990
+ error_message: p.message,
3991
+ widget: "chat"
3992
+ })
3993
+ ));
3994
+ },
3995
+ onDone: () => {
3996
+ I && this._abortControllers.delete(I), !(!n && a !== this._activeRequestThreadId) && (this._activeRequestThreadId = null, this._bridge?.send("isResponding", !1), this._bridge?.send("loadingMessage", { text: null }), this._drawer?.removeTypingIndicator(), b && !N && this._drawer?.isPanelLoading() && this._drawer.clearPanel(), b = !1, N = !1, r.status === "streaming" && (r.status = "done", ge()), this.emit("message", r), this._panel?.snapshotForMessage(r.id), this._panel?.attachClickHandler(r.id), this.track(
3997
+ Xe(this.analyticsContext(), {
3998
+ request_id: d,
3999
+ latency_ms: Date.now() - v,
4000
+ chunk_count: w,
4001
+ widget: "chat"
4002
+ })
4003
+ ), this.track(
4004
+ Je(this.analyticsContext(), {
4005
+ meter_key: "chat_request",
4006
+ quantity: 1,
4007
+ unit: "request"
4008
+ })
4009
+ ), this.track(
4010
+ Ze(this.analyticsContext(), {
4011
+ message_count: this._messages.length,
4012
+ history_ref: this.config.session?.sessionId ?? "",
4013
+ redaction_level: "none"
4014
+ })
4015
+ ), this._persistToIndexedDB().catch(() => {
4016
+ }));
4017
+ }
4018
+ },
4019
+ s
4020
+ ), this._abortControllers.add(I);
4021
+ }
4022
+ /** Return messages visible at the current thread cursor. */
4023
+ _getVisibleMessages() {
4024
+ const e = this._messages.filter((a) => !a.silent);
4025
+ if (!this._currentThreadId) return e;
4026
+ const t = this._currentThreadId;
4027
+ return e.filter((a) => !a.threadId || a.threadId <= t);
4028
+ }
4029
+ /** Handle rollback-on-click from a user message bubble. */
4030
+ _appendSimilarsToPanel(e, t) {
4031
+ if (!this._drawer) return;
4032
+ const a = this._drawer.getPanelContentElement();
4033
+ if (!a) return;
4034
+ const n = document.createElement("h3");
4035
+ n.className = "gengage-chat-product-details-similars-heading", n.textContent = this._i18n.similarProductsLabel ?? "Benzer Ürünler", a.appendChild(n);
4036
+ const i = this._renderUISpec(e, t);
4037
+ i.classList.add("gengage-chat-product-details-similars"), a.appendChild(i);
4038
+ }
4039
+ _handleRollback(e) {
4040
+ const t = this._messages.find((a) => a.id === e);
4041
+ t?.threadId && this._rollbackToThread(t.threadId);
4042
+ }
4043
+ /** Rewind the conversation to the given thread. */
4044
+ _rollbackToThread(e) {
4045
+ this._currentThreadId = e, this._extendedModeManager?.setHiddenByUser(!1);
4046
+ for (const i of this._messages) {
4047
+ const r = this._shadow?.querySelector(`[data-message-id="${CSS.escape(i.id)}"]`);
4048
+ r && (i.threadId && i.threadId > e ? r.classList.add("gengage-chat-bubble--hidden") : r.classList.remove("gengage-chat-bubble--hidden"));
4049
+ }
4050
+ this._shadow?.querySelectorAll("[data-thread-id]").forEach((i) => {
4051
+ i instanceof HTMLElement && i.dataset.threadId && i.dataset.threadId > e ? i.classList.add("gengage-chat-bubble--hidden") : i instanceof HTMLElement && i.classList.remove("gengage-chat-bubble--hidden");
4052
+ });
4053
+ const t = this._messages.find((i) => i.role === "assistant" && i.threadId === e);
4054
+ t && this._panel?.restoreForMessage(t.id) || this._drawer?.clearPanel();
4055
+ const n = this._panel.currentType ?? "";
4056
+ this._panel?.updateTopBar(n), this._drawer?.setPills([]), this._session?.db && this.config.session?.sessionId && this._session?.db.loadContext(this.config.session.sessionId, e).then((i) => {
4057
+ i && (this._lastBackendContext = i.context);
4058
+ }).catch(() => {
4059
+ }), this._session?.db && this.config.session?.sessionId && this._session?.db.deleteContextsAfterThread(this.config.session.sessionId, e).catch(() => {
4060
+ });
4061
+ }
4062
+ // ---------------------------------------------------------------------------
4063
+ // IndexedDB persistence (delegates to SessionPersistence)
4064
+ // ---------------------------------------------------------------------------
4065
+ async _persistToIndexedDB() {
4066
+ !this._session || !this.config.session?.sessionId || await this._session.persist({
4067
+ userId: this.config.session.userId ?? "",
4068
+ appId: this.config.accountId,
4069
+ sessionId: this.config.session.sessionId,
4070
+ messages: this._messages,
4071
+ currentThreadId: this._currentThreadId,
4072
+ lastThreadId: this._lastThreadId,
4073
+ chatCreatedAt: this._chatCreatedAt,
4074
+ panelSnapshots: this._panel?.snapshots ?? /* @__PURE__ */ new Map(),
4075
+ panelThreads: this._panel?.threads ?? [],
4076
+ thumbnailEntries: this._thumbnailEntries,
4077
+ lastBackendContext: this._lastBackendContext
4078
+ });
4079
+ }
4080
+ _isSameOriginUrl(e) {
4081
+ try {
4082
+ return new URL(e, window.location.href).origin === window.location.origin;
4083
+ } catch {
4084
+ return !1;
4085
+ }
4086
+ }
4087
+ async _saveSessionAndOpenURL(e) {
4088
+ this._session && await this._session.saveAndOpenURL(e, () => this._persistToIndexedDB(), this._bridge);
4089
+ }
4090
+ async _loadPayload(e, t) {
4091
+ return this._session ? this._session.loadPayload(e, t) : null;
4092
+ }
4093
+ /**
4094
+ * Attempt to restore chat session from IndexedDB.
4095
+ * Always restores when IDB has session data for the current sessionId.
4096
+ * Best-effort — failures are silently ignored.
4097
+ */
4098
+ async _restoreFromIndexedDB() {
4099
+ if (!this._session?.db) return;
4100
+ const e = this.config.session?.sessionId;
4101
+ if (!e) return;
4102
+ const t = this.config.session?.userId ?? "", a = this.config.accountId;
4103
+ await this._session.loadFavorites(t, a);
4104
+ const n = await this._session.db?.loadSession(t, a, e);
4105
+ if (!n || n.messages.length === 0) return;
4106
+ if (this._pdpLaunched = !0, this._drawer?.lockScrollForRestore(), this._currentThreadId = n.currentThreadId, this._lastThreadId = n.lastThreadId, this._chatCreatedAt = n.createdAt, n.panelThreads && (this._panel.threads = n.panelThreads), n.thumbnailEntries && (this._thumbnailEntries = n.thumbnailEntries, this._drawer?.setThumbnails(this._thumbnailEntries)), n.panelSnapshotHtml)
4107
+ for (const [r, s] of Object.entries(n.panelSnapshotHtml)) {
4108
+ const l = document.createElement("div");
4109
+ l.innerHTML = Z(s), this._panel.snapshots.set(r, l);
4110
+ }
4111
+ let i = 0;
4112
+ for (const r of n.messages) {
4113
+ const s = {
4114
+ id: r.id,
4115
+ role: r.role,
4116
+ timestamp: r.timestamp,
4117
+ status: r.status
4118
+ };
4119
+ if (r.threadId !== void 0 && (s.threadId = r.threadId), r.content !== void 0 && (s.content = r.content), r.silent && (s.silent = !0), this._messages.push(s), s.silent) continue;
4120
+ s.role === "assistant" && s.threadId && !this._threadsWithFirstBot.has(s.threadId) && (this._threadsWithFirstBot.add(s.threadId), this._drawer?.markFirstBotMessage(s.id)), this._drawer?.addMessage(s);
4121
+ const l = parseInt(r.id.replace("msg-", ""), 10);
4122
+ if (!isNaN(l) && l > i && (i = l), s.role === "assistant" && s.threadId) {
4123
+ const g = await this._loadPayload(s.threadId, s.id);
4124
+ g && (s.uiSpec = g, this._restoreInlineUISpec(s), this._panel?.attachClickHandler(s.id), delete s.uiSpec);
4125
+ }
4126
+ }
4127
+ if (i > this._currentMessageId && (this._currentMessageId = i), this._currentThreadId) {
4128
+ let r = await this._session.db?.loadContext(e, this._currentThreadId);
4129
+ r || (r = await this._session.db?.loadLatestContext(e)), r && (this._lastBackendContext = r.context);
4130
+ }
4131
+ if (this._currentThreadId) {
4132
+ const r = [...this._messages].reverse().find((s) => s.role === "assistant" && s.threadId === this._currentThreadId && !s.silent);
4133
+ r && this._panel.snapshots.has(r.id) && this._panel?.restoreForMessage(r.id);
4134
+ }
4135
+ if (this._currentThreadId) {
4136
+ const r = this._currentThreadId;
4137
+ for (const s of this._messages)
4138
+ s.threadId && s.threadId > r && this._shadow?.querySelector(`[data-message-id="${CSS.escape(s.id)}"]`)?.classList.add("gengage-chat-bubble--hidden");
4139
+ this._shadow?.querySelectorAll("[data-thread-id]").forEach((s) => {
4140
+ s instanceof HTMLElement && s.dataset.threadId && s.dataset.threadId > r && s.classList.add("gengage-chat-bubble--hidden");
4141
+ });
4142
+ }
4143
+ if (this._panel.threads.length > 0 && this._currentThreadId) {
4144
+ const r = this._panel.threads[this._panel.threads.length - 1];
4145
+ if (r) {
4146
+ const s = [...this._messages].reverse().find((l) => l.role === "assistant" && l.threadId === r);
4147
+ if (s?.threadId) {
4148
+ const l = await this._loadPayload(s.threadId, s.id);
4149
+ if (l) {
4150
+ const g = l.elements[l.root];
4151
+ g && this._panel?.updateTopBar(g.type);
4152
+ }
4153
+ }
4154
+ }
4155
+ }
4156
+ setTimeout(() => {
4157
+ this._drawer?.scrollToLastThread();
4158
+ }, 550);
4159
+ }
4160
+ /**
4161
+ * Build a ChatUISpecRenderContext with all callbacks wired up.
4162
+ * Used both during streaming and during session restore.
4163
+ */
4164
+ _buildRenderContext() {
4165
+ const e = {
4166
+ onAction: (t) => {
4167
+ if (We(t.title, t.type), t.type === "findSimilar") {
4168
+ const n = typeof t.payload == "object" && t.payload !== null && "sku" in t.payload ? String(t.payload.sku) : "";
4169
+ Ye(n);
4170
+ }
4171
+ t.type === "getComparisonTable" && Qe(this._comparisonSelectedSkus);
4172
+ const a = t.type === "addToCart" || t.type === "like";
4173
+ this._sendAction(t, a ? { preservePanel: !0 } : void 0);
4174
+ },
4175
+ onProductClick: (t) => {
4176
+ Ke(t.sku), O("gengage:similar:product-click", {
4177
+ sku: t.sku,
4178
+ url: t.url,
4179
+ sessionId: this.config.session?.sessionId ?? null
4180
+ }), this.config.isDemoWebsite === !0 || !this._isSameOriginUrl(t.url) ? this._sendAction({
4181
+ title: t.sku,
4182
+ type: "launchSingleProduct",
4183
+ payload: { sku: t.sku }
4184
+ }) : this._saveSessionAndOpenURL(t.url);
4185
+ },
4186
+ onAddToCart: (t) => {
4187
+ $e(t.sku, t.quantity);
4188
+ const a = {
4189
+ ...t,
4190
+ sessionId: this.config.session?.sessionId ?? null
4191
+ };
4192
+ O("gengage:chat:add-to-cart", a), this._bridge?.send("addToCart", t), this._runEventCallbacks("gengage-cart-add", a), this._sendAction(
4193
+ {
4194
+ title: "Sepete Ekle",
4195
+ type: "addToCart",
4196
+ payload: { sku: t.sku, cart_code: t.cartCode, quantity: t.quantity }
4197
+ },
4198
+ { preservePanel: !0 }
4199
+ );
4200
+ },
4201
+ onProductSelect: (t) => {
4202
+ const a = {
4203
+ root: "root",
4204
+ elements: {
4205
+ root: {
4206
+ type: "ProductDetailsPanel",
4207
+ props: { product: t }
4208
+ }
4209
+ }
4210
+ };
4211
+ this._drawer?.setPanelContent(this._renderUISpec(a, e));
4212
+ },
4213
+ i18n: this._i18n,
4214
+ pricing: this.config.pricing,
4215
+ productSort: this._productSort,
4216
+ onSortChange: (t) => {
4217
+ this._productSort = t;
4218
+ },
4219
+ comparisonSelectMode: this._comparisonSelectMode,
4220
+ comparisonSelectedSkus: this._comparisonSelectedSkus,
4221
+ onToggleComparisonSku: (t) => {
4222
+ t === "" ? (this._comparisonSelectMode = !this._comparisonSelectMode, this._comparisonSelectMode || (this._comparisonSelectedSkus = [], Ve())) : this._comparisonSelectedSkus.indexOf(t) >= 0 ? this._comparisonSelectedSkus = this._comparisonSelectedSkus.filter((n) => n !== t) : (this._comparisonSelectedSkus = [...this._comparisonSelectedSkus, t], Ge(t));
4223
+ },
4224
+ favoritedSkus: this._session?.favoritedSkus ?? /* @__PURE__ */ new Set(),
4225
+ onFavoriteToggle: (t, a) => {
4226
+ je(t), this._toggleFavorite(t, a);
4227
+ const n = a.name ?? t;
4228
+ this._sendAction(
4229
+ {
4230
+ title: n,
4231
+ type: "like",
4232
+ payload: { sku: t }
4233
+ },
4234
+ { preservePanel: !0 }
4235
+ );
4236
+ }
4237
+ };
4238
+ return e;
4239
+ }
4240
+ async _toggleFavorite(e, t) {
4241
+ if (!this._session) return;
4242
+ const a = this.config.session?.userId ?? "", n = this.config.accountId;
4243
+ await this._session.toggleFavorite(a, n, e, t);
4244
+ }
4245
+ /**
4246
+ * Run registered callbacks for a GA4 event.
4247
+ * If any callback returns false or throws, handle the failure (e.g. show error for cart-add).
4248
+ */
4249
+ async _runEventCallbacks(e, t) {
4250
+ const a = this._eventCallbacks.get(e);
4251
+ if (!(!a || a.size === 0))
4252
+ for (const n of a)
4253
+ try {
4254
+ const i = n(t);
4255
+ if ((i instanceof Promise ? await i : i) === !1) {
4256
+ this._handleCallbackFailure(e, t);
4257
+ return;
4258
+ }
4259
+ } catch {
4260
+ this._handleCallbackFailure(e, t);
4261
+ return;
4262
+ }
4263
+ }
4264
+ /**
4265
+ * Handle a callback failure — for add-to-cart, show an error message in chat.
4266
+ */
4267
+ _handleCallbackFailure(e, t) {
4268
+ if (e === "gengage-cart-add") {
4269
+ const n = this._createMessage("assistant", "Üzgünüm sepete ekleyemedim, bir sorunla karşılaştım.");
4270
+ this._currentThreadId && (n.threadId = this._currentThreadId), this._messages.push(n), this._drawer?.addMessage(n);
4271
+ }
4272
+ }
4273
+ /**
4274
+ * Re-render inline UISpec elements for a restored bot message.
4275
+ * Inserts them into the messages container after the message bubble.
4276
+ */
4277
+ _restoreInlineUISpec(e) {
4278
+ if (!e.uiSpec || !this._drawer) return;
4279
+ const t = e.uiSpec, a = t.elements[t.root];
4280
+ if (!a) return;
4281
+ const n = a.type;
4282
+ if (n === "ActionButtons" || n === "ComparisonTable" || n === "ProductGrid" && a.props?.similarsAppend === !0) return;
4283
+ const i = this._buildRenderContext(), r = this._shadow?.querySelector(".gengage-chat-messages");
4284
+ if (!r) return;
4285
+ if (n === "ProductDetailsPanel") {
4286
+ const l = a.props?.product;
4287
+ if (!l) return;
4288
+ const g = {
4289
+ root: "root",
4290
+ elements: { root: { type: "ProductSummaryCard", props: { product: l } } }
4291
+ }, c = this._renderUISpec(g, i);
4292
+ e.threadId && (c.dataset.threadId = e.threadId), r.appendChild(c);
4293
+ return;
4294
+ }
4295
+ const s = this._renderUISpec(t, i);
4296
+ e.threadId && (s.dataset.threadId = e.threadId), r.appendChild(s);
4297
+ }
4298
+ _createMessage(e, t) {
4299
+ return this._currentMessageId++, {
4300
+ id: `msg-${this._currentMessageId}`,
4301
+ role: e,
4302
+ content: t,
4303
+ timestamp: Date.now(),
4304
+ status: "done"
4305
+ };
4306
+ }
4307
+ _resolveI18n(e) {
4308
+ return { ...Et(e.locale), ...e.i18n };
4309
+ }
4310
+ _resolveUISpecRegistry() {
4311
+ const e = oa();
4312
+ return qe(e, this.config.renderer?.registry);
4313
+ }
4314
+ _renderUISpec(e, t) {
4315
+ const a = this._resolveUISpecRegistry(), n = this.config.renderer?.unknownRenderer ?? Se, i = (l, g) => ra(l, g, a, n), r = this.config.renderer?.renderUISpec;
4316
+ return r ? r(e, t, {
4317
+ registry: a,
4318
+ unknownRenderer: n,
4319
+ defaultRender: i
4320
+ }) : i(e, t);
4321
+ }
4322
+ }
4323
+ function hn() {
4324
+ return new ln();
4325
+ }
4326
+ export {
4327
+ ln as G,
4328
+ Tt as V,
4329
+ oa as a,
4330
+ ra as b,
4331
+ hn as c,
4332
+ Se as d,
4333
+ pn as e,
4334
+ St as i,
4335
+ dt as r
4336
+ };
4337
+ //# sourceMappingURL=index-CXbH-cw8.js.map