@gengage/assistant-fe 0.1.8 → 0.2.0

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