@gengage/assistant-fe 0.4.5 → 0.4.6

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 (49) hide show
  1. package/README.md +1 -1
  2. package/dist/api-paths-C4GDpeTf.js +1214 -0
  3. package/dist/chat/index.d.ts +1 -374
  4. package/dist/chat/runtime.d.ts +374 -0
  5. package/dist/chat-BRKK63lt.js +303 -0
  6. package/dist/chat-runtime.js +13 -0
  7. package/dist/chat.iife.js +6 -6
  8. package/dist/chat.js +11 -10
  9. package/dist/common/config-constants.d.ts +1 -0
  10. package/dist/common/config-schema.d.ts +0 -1
  11. package/dist/common/overlay.d.ts +4 -4
  12. package/dist/common-CEN5OW7E.js +491 -0
  13. package/dist/common.js +78 -76
  14. package/dist/{connection-warning-n88bjkqL.js → connection-warning-B6oIU-9s.js} +1 -1
  15. package/dist/context-VIG4SVcS.js +529 -0
  16. package/dist/index.js +70 -67
  17. package/dist/locale-CfqNifrU.js +7 -0
  18. package/dist/native-webview-DudQ7nHe.js +273 -0
  19. package/dist/native.iife.js +28 -91
  20. package/dist/native.js +1 -1
  21. package/dist/overlay-1EO41ZC7.js +212 -0
  22. package/dist/overlay.d.ts +4 -0
  23. package/dist/overlay.js +10 -0
  24. package/dist/pill-launcher-57nrdLRr.js +364 -0
  25. package/dist/qna/index.d.ts +1 -61
  26. package/dist/qna/runtime.d.ts +61 -0
  27. package/dist/qna-BNvttR6s.js +40 -0
  28. package/dist/qna-runtime.js +8 -0
  29. package/dist/qna.iife.js +4 -4
  30. package/dist/qna.js +6 -5
  31. package/dist/{simrel-K2TGFi1r.js → runtime-BdwZZIrO.js} +244 -293
  32. package/dist/{chat-B1lLKIxj.js → runtime-C0qZk0y7.js} +1643 -2297
  33. package/dist/{qna-C5Ok3wd0.js → runtime-DDu8Wk0z.js} +87 -121
  34. package/dist/schemas-CLo8wCjs.js +3207 -0
  35. package/dist/{simbut-Cb5RfaAp.js → simbut-BMWC6x_t.js} +24 -22
  36. package/dist/simbut.js +1 -1
  37. package/dist/simrel/index.d.ts +1 -59
  38. package/dist/simrel/runtime.d.ts +59 -0
  39. package/dist/simrel-ohfkluhp.js +55 -0
  40. package/dist/simrel-runtime.js +8 -0
  41. package/dist/simrel.iife.js +4 -4
  42. package/dist/simrel.js +7 -6
  43. package/dist/widget-base-TgwiA8cD.js +578 -0
  44. package/package.json +17 -1
  45. package/dist/common-C5e2gLuG.js +0 -387
  46. package/dist/locale-MM0U5eeR.js +0 -1109
  47. package/dist/native-webview-niMtkiHX.js +0 -586
  48. package/dist/schemas-JpRGzRQT.js +0 -4419
  49. /package/dist/{price-formatter-CR6VT5z4.js → price-formatter-xI3g9Cd4.js} +0 -0
@@ -1,106 +1,108 @@
1
- import { S as z, a as A, b as M, c as E, d as G, h as $, m as W, n as J, o as S, p as x, t as O, u as Q, w as Y } from "./schemas-JpRGzRQT.js";
2
- import { A as V, G as K, H as X, K as Z, R as P, _ as w, a as ee, et as I, it as L, n as te, nt as ne, t as re, tt as ie, x as se } from "./locale-MM0U5eeR.js";
3
- import { a as oe, n as ae, r as ce, t as R } from "./price-formatter-CR6VT5z4.js";
4
- import { n as de } from "./connection-warning-n88bjkqL.js";
5
- function B(e) {
1
+ import { a as D, f as j, i as F, m as H, r as N, t as R, u as U } from "./api-paths-C4GDpeTf.js";
2
+ import { S as z, b as T, f as $, i as W, t as J, w, x as Q } from "./widget-base-TgwiA8cD.js";
3
+ import { A as Y, E as A, N as V, a as S, l as K, v as X } from "./context-VIG4SVcS.js";
4
+ import { t as Z } from "./locale-CfqNifrU.js";
5
+ import { a as ee, n as te, r as re, t as P } from "./price-formatter-xI3g9Cd4.js";
6
+ import { n as ne } from "./connection-warning-B6oIU-9s.js";
7
+ function M(e) {
6
8
  const t = [];
7
- for (const n of Object.values(e)) if (n.type === "ProductCard" && n.props) {
8
- const r = n.props.product ?? n.props;
9
- typeof r.sku == "string" && typeof r.name == "string" && t.push(r);
9
+ for (const r of Object.values(e)) if (r.type === "ProductCard" && r.props) {
10
+ const n = r.props.product ?? r.props;
11
+ typeof n.sku == "string" && typeof n.name == "string" && t.push(n);
10
12
  }
11
13
  return t;
12
14
  }
13
- function q(e) {
15
+ function G(e) {
14
16
  const t = e.headers.get("Content-Type") ?? "";
15
17
  return t.includes("application/x-ndjson") || t.includes("text/event-stream");
16
18
  }
17
- async function le(e, t) {
18
- const n = [], r = { onEvent: (i) => {
19
- const s = x(i);
20
- !s || s.type !== "ui_spec" || n.push(...B(s.spec.elements));
19
+ async function ie(e, t) {
20
+ const r = [], n = { onEvent: (i) => {
21
+ const s = N(i);
22
+ !s || s.type !== "ui_spec" || r.push(...M(s.spec.elements));
21
23
  } };
22
- return t !== void 0 && (r.signal = t), await M(e, r), n;
24
+ return t !== void 0 && (n.signal = t), await U(e, n), r;
23
25
  }
24
- async function ue(e, t, n) {
25
- const r = G("similar_products", t), i = {
26
+ async function se(e, t, r) {
27
+ const n = R("similar_products", t), i = {
26
28
  method: "POST",
27
29
  headers: { "Content-Type": "application/json" },
28
30
  body: JSON.stringify(e)
29
31
  };
30
- n !== void 0 && (i.signal = n);
31
- const s = await fetch(r, i);
32
+ r !== void 0 && (i.signal = r);
33
+ const s = await fetch(n, i);
32
34
  if (!s.ok) throw new Error(`HTTP ${s.status}: ${s.statusText}`);
33
- if (q(s)) return le(s, n);
35
+ if (G(s)) return ie(s, r);
34
36
  const c = await s.text();
35
37
  if (!c) throw new Error("Empty response body from similar_products endpoint");
36
38
  try {
37
- return $(JSON.parse(c));
39
+ return D(JSON.parse(c));
38
40
  } catch {
39
41
  throw new Error("Invalid JSON from similar_products endpoint");
40
42
  }
41
43
  }
42
- async function ge(e, t) {
43
- const n = [];
44
- let r = null;
44
+ async function oe(e, t) {
45
+ const r = [];
46
+ let n = null;
45
47
  const i = { onEvent: (s) => {
46
- const c = x(s);
48
+ const c = N(s);
47
49
  if (c) {
48
50
  if (c.type === "metadata" && c.meta) {
49
51
  const d = c.meta.group_name;
50
52
  if (typeof d == "string") {
51
- r = {
53
+ n = {
52
54
  name: d,
53
55
  products: []
54
56
  };
55
- const u = c.meta.highlight;
56
- typeof u == "string" && (r.highlight = u), n.push(r);
57
+ const g = c.meta.highlight;
58
+ typeof g == "string" && (n.highlight = g), r.push(n);
57
59
  }
58
60
  }
59
- c.type === "ui_spec" && r && r.products.push(...B(c.spec.elements));
61
+ c.type === "ui_spec" && n && n.products.push(...M(c.spec.elements));
60
62
  }
61
63
  } };
62
- return t !== void 0 && (i.signal = t), await M(e, i), n;
64
+ return t !== void 0 && (i.signal = t), await U(e, i), r;
63
65
  }
64
- async function pe(e, t, n) {
65
- const r = G("product_groupings", t), i = {
66
+ async function ae(e, t, r) {
67
+ const n = R("product_groupings", t), i = {
66
68
  method: "POST",
67
69
  headers: { "Content-Type": "application/json" },
68
70
  body: JSON.stringify(e)
69
71
  };
70
- n !== void 0 && (i.signal = n);
71
- const s = await fetch(r, i);
72
+ r !== void 0 && (i.signal = r);
73
+ const s = await fetch(n, i);
72
74
  if (!s.ok) throw new Error(`HTTP ${s.status}: ${s.statusText}`);
73
- if (q(s)) return ge(s, n);
75
+ if (G(s)) return oe(s, r);
74
76
  const c = await s.text();
75
77
  if (!c) return [];
76
78
  try {
77
- return W(JSON.parse(c));
79
+ return F(JSON.parse(c));
78
80
  } catch {
79
81
  throw new Error("Invalid JSON from product_groupings endpoint");
80
82
  }
81
83
  }
82
- function D(e) {
83
- const { product: t, index: n, discountType: r, onClick: i, onAddToCart: s, renderCard: c } = e, d = e.i18n, u = e.pricing;
84
+ function x(e) {
85
+ const { product: t, index: r, discountType: n, onClick: i, onAddToCart: s, renderCard: c } = e, d = e.i18n, g = e.pricing;
84
86
  if (e.renderCardElement) {
85
- const o = e.renderCardElement(t, n);
87
+ const o = e.renderCardElement(t, r);
86
88
  if (o) return o;
87
89
  }
88
90
  if (c) {
89
91
  const o = document.createElement("div");
90
- return o.className = "gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive", o.dataset.gengagePart = "simrel-product-card", o.innerHTML = K(c(t, n)), o.addEventListener("click", (a) => {
92
+ return o.className = "gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive", o.dataset.gengagePart = "simrel-product-card", o.innerHTML = V(c(t, r)), o.addEventListener("click", (a) => {
91
93
  a.target.closest(".gengage-simrel-atc") || a.target.closest(".gengage-chat-product-card-atc") || i(t);
92
94
  }), o;
93
95
  }
94
96
  const l = document.createElement("article");
95
97
  l.className = "gengage-simrel-card gengage-chat-product-card gds-card gds-product-card gds-card-interactive", l.dataset.gengagePart = "simrel-product-card", t.inStock === !1 && l.classList.add("gengage-simrel-card--out-of-stock"), l.setAttribute("role", "listitem"), l.dataset.sku = t.sku;
96
98
  const h = document.createElement("div");
97
- if (h.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", h.dataset.gengagePart = "simrel-product-card-image", t.imageUrl && X(t.imageUrl)) {
99
+ if (h.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", h.dataset.gengagePart = "simrel-product-card-image", t.imageUrl && Y(t.imageUrl)) {
98
100
  const o = document.createElement("img");
99
- o.className = "gengage-chat-product-card-img", o.src = t.imageUrl, o.alt = t.name, o.loading = "lazy", ae(o), h.appendChild(o);
101
+ o.className = "gengage-chat-product-card-img", o.src = t.imageUrl, o.alt = t.name, o.loading = "lazy", te(o), h.appendChild(o);
100
102
  }
101
- if (r === "badge" && t.discountPercent && t.discountPercent > 0) {
103
+ if (n === "badge" && t.discountPercent && t.discountPercent > 0) {
102
104
  const o = document.createElement("span");
103
- o.className = "gengage-simrel-badge gengage-chat-product-card-discount-badge", o.textContent = `%${ce(t.discountPercent)}`, h.appendChild(o);
105
+ o.className = "gengage-simrel-badge gengage-chat-product-card-discount-badge", o.textContent = `%${re(t.discountPercent)}`, h.appendChild(o);
104
106
  }
105
107
  l.appendChild(h);
106
108
  const m = document.createElement("div");
@@ -111,20 +113,20 @@ function D(e) {
111
113
  const p = document.createElement("div");
112
114
  if (p.className = "gengage-simrel-card-name gengage-chat-product-card-name", p.textContent = t.name, p.title = t.name, m.appendChild(p), t.rating != null && t.rating > 0) {
113
115
  const o = document.createElement("div");
114
- if (o.className = "gengage-simrel-card-rating gengage-chat-product-card-rating", o.appendChild(oe(t.rating)), t.reviewCount != null) {
116
+ if (o.className = "gengage-simrel-card-rating gengage-chat-product-card-rating", o.appendChild(ee(t.rating)), t.reviewCount != null) {
115
117
  const a = document.createElement("span");
116
118
  a.className = "gengage-simrel-card-review-count gengage-chat-product-card-review-count", a.textContent = ` (${t.reviewCount})`, o.appendChild(a);
117
119
  }
118
120
  m.appendChild(o);
119
121
  }
120
122
  const y = document.createElement("div");
121
- if (y.className = "gengage-simrel-card-price gengage-chat-product-card-price", t.originalPrice && t.originalPrice !== t.price && (r === "strike-through" || !r)) {
123
+ if (y.className = "gengage-simrel-card-price gengage-chat-product-card-price", t.originalPrice && t.originalPrice !== t.price && (n === "strike-through" || !n)) {
122
124
  const o = document.createElement("span");
123
- o.className = "gengage-simrel-card-price-original gengage-chat-product-card-original-price", o.textContent = R(t.originalPrice, u), y.appendChild(o);
125
+ o.className = "gengage-simrel-card-price-original gengage-chat-product-card-original-price", o.textContent = P(t.originalPrice, g), y.appendChild(o);
124
126
  }
125
127
  if (t.price && parseFloat(t.price) > 0) {
126
128
  const o = document.createElement("span");
127
- o.className = "gengage-simrel-card-price-current gengage-chat-product-card-price-current", o.textContent = R(t.price, u), y.appendChild(o);
129
+ o.className = "gengage-simrel-card-price-current gengage-chat-product-card-price-current", o.textContent = P(t.price, g), y.appendChild(o);
128
130
  }
129
131
  m.appendChild(y), l.appendChild(m);
130
132
  const b = document.createElement("button");
@@ -147,40 +149,40 @@ function D(e) {
147
149
  o.target.closest(".gengage-simrel-atc") || o.target.closest(".gengage-chat-product-card-atc") || o.target.closest(".gengage-chat-product-card-cta") || i(t);
148
150
  }), l;
149
151
  }
150
- function N(e) {
152
+ function I(e) {
151
153
  const t = document.createElement("div");
152
154
  t.className = "gengage-simrel-grid", t.setAttribute("role", "list"), t.setAttribute("aria-label", e.i18n?.similarProductsAriaLabel ?? "Similar products"), e.columns && t.style.setProperty("--gengage-simrel-columns", String(e.columns));
153
- for (let n = 0; n < e.products.length; n++) {
154
- const r = {
155
- product: e.products[n],
156
- index: n,
155
+ for (let r = 0; r < e.products.length; r++) {
156
+ const n = {
157
+ product: e.products[r],
158
+ index: r,
157
159
  onClick: e.onClick,
158
160
  onAddToCart: e.onAddToCart
159
161
  };
160
- e.i18n !== void 0 && (r.i18n = e.i18n), e.discountType !== void 0 && (r.discountType = e.discountType), e.renderCard !== void 0 && (r.renderCard = e.renderCard), e.renderCardElement !== void 0 && (r.renderCardElement = e.renderCardElement);
161
- const i = D(r);
162
+ e.i18n !== void 0 && (n.i18n = e.i18n), e.discountType !== void 0 && (n.discountType = e.discountType), e.renderCard !== void 0 && (n.renderCard = e.renderCard), e.renderCardElement !== void 0 && (n.renderCardElement = e.renderCardElement);
163
+ const i = x(n);
162
164
  t.appendChild(i);
163
165
  }
164
166
  return e.products.length === 0 && (t.style.display = "none", t.dataset.empty = "true"), t;
165
167
  }
166
- var me = 0;
167
- function fe(e) {
168
- const t = me++, n = document.createElement("div");
169
- if (n.className = "gengage-simrel-groups", n.dataset.gengagePart = "simrel-groups", e.groups.length === 0)
170
- return n.style.display = "none", n.dataset.empty = "true", n;
171
- const r = document.createElement("div");
172
- r.className = "gengage-simrel-tabs gds-toolbar", r.dataset.gengagePart = "simrel-tab-bar", r.setAttribute("role", "tablist");
168
+ var ce = 0;
169
+ function de(e) {
170
+ const t = ce++, r = document.createElement("div");
171
+ if (r.className = "gengage-simrel-groups", r.dataset.gengagePart = "simrel-groups", e.groups.length === 0)
172
+ return r.style.display = "none", r.dataset.empty = "true", r;
173
+ const n = document.createElement("div");
174
+ n.className = "gengage-simrel-tabs gds-toolbar", n.dataset.gengagePart = "simrel-tab-bar", n.setAttribute("role", "tablist");
173
175
  const i = [], s = [];
174
176
  let c = 0;
175
177
  const d = (a) => {
176
- const g = {
178
+ const u = {
177
179
  products: a.products,
178
180
  onClick: e.onClick,
179
181
  onAddToCart: e.onAddToCart
180
182
  };
181
- return e.i18n !== void 0 && (g.i18n = e.i18n), e.discountType !== void 0 && (g.discountType = e.discountType), e.renderCard !== void 0 && (g.renderCard = e.renderCard), e.renderCardElement !== void 0 && (g.renderCardElement = e.renderCardElement), e.columns !== void 0 && (g.columns = e.columns), g;
182
- }, u = (a, g = !1) => {
183
- if (g && a !== c && e.onGroupingActivate) {
183
+ return e.i18n !== void 0 && (u.i18n = e.i18n), e.discountType !== void 0 && (u.discountType = e.discountType), e.renderCard !== void 0 && (u.renderCard = e.renderCard), e.renderCardElement !== void 0 && (u.renderCardElement = e.renderCardElement), e.columns !== void 0 && (u.columns = e.columns), u;
184
+ }, g = (a, u = !1) => {
185
+ if (u && a !== c && e.onGroupingActivate) {
184
186
  const f = e.groups[a];
185
187
  e.onGroupingActivate({
186
188
  grouping_label: f.name,
@@ -192,23 +194,23 @@ function fe(e) {
192
194
  const v = f === a;
193
195
  i[f].classList.toggle("gengage-simrel-tab--active", v), i[f].setAttribute("aria-selected", String(v)), i[f].tabIndex = v ? 0 : -1;
194
196
  }
195
- const k = e.groups[a], _ = s[a];
196
- _.innerHTML = "";
197
- const C = N(d(k));
198
- _.appendChild(C);
197
+ const _ = e.groups[a], E = s[a];
198
+ E.innerHTML = "";
199
+ const C = I(d(_));
200
+ E.appendChild(C);
199
201
  for (let f = 0; f < s.length; f++) {
200
202
  const v = f === a;
201
203
  s[f].style.display = v ? "" : "none", s[f].tabIndex = v ? 0 : -1;
202
204
  }
203
205
  };
204
206
  for (let a = 0; a < e.groups.length; a++) {
205
- const g = e.groups[a], k = `gengage-simrel-tab-${t}-${a}`, _ = `gengage-simrel-panel-${t}-${a}`, C = document.createElement("button");
206
- C.className = "gengage-simrel-tab gds-tab", C.type = "button", C.dataset.gengagePart = "simrel-tab", C.id = k, C.textContent = g.name, C.setAttribute("role", "tab"), C.setAttribute("aria-controls", _), C.setAttribute("aria-selected", String(a === 0)), C.tabIndex = a === 0 ? 0 : -1, a === 0 && C.classList.add("gengage-simrel-tab--active"), C.addEventListener("click", () => u(a, !0)), C.addEventListener("keydown", (v) => {
207
- let T = -1;
208
- v.key === "ArrowRight" || v.key === "ArrowDown" ? T = (a + 1) % e.groups.length : v.key === "ArrowLeft" || v.key === "ArrowUp" ? T = (a - 1 + e.groups.length) % e.groups.length : v.key === "Home" ? T = 0 : v.key === "End" && (T = e.groups.length - 1), T >= 0 && (v.preventDefault(), u(T, !0), i[T].focus());
209
- }), i.push(C), r.appendChild(C);
207
+ const u = e.groups[a], _ = `gengage-simrel-tab-${t}-${a}`, E = `gengage-simrel-panel-${t}-${a}`, C = document.createElement("button");
208
+ C.className = "gengage-simrel-tab gds-tab", C.type = "button", C.dataset.gengagePart = "simrel-tab", C.id = _, C.textContent = u.name, C.setAttribute("role", "tab"), C.setAttribute("aria-controls", E), C.setAttribute("aria-selected", String(a === 0)), C.tabIndex = a === 0 ? 0 : -1, a === 0 && C.classList.add("gengage-simrel-tab--active"), C.addEventListener("click", () => g(a, !0)), C.addEventListener("keydown", (v) => {
209
+ let k = -1;
210
+ v.key === "ArrowRight" || v.key === "ArrowDown" ? k = (a + 1) % e.groups.length : v.key === "ArrowLeft" || v.key === "ArrowUp" ? k = (a - 1 + e.groups.length) % e.groups.length : v.key === "Home" ? k = 0 : v.key === "End" && (k = e.groups.length - 1), k >= 0 && (v.preventDefault(), g(k, !0), i[k].focus());
211
+ }), i.push(C), n.appendChild(C);
210
212
  const f = document.createElement("div");
211
- f.className = "gengage-simrel-tab-panel", f.dataset.gengagePart = "simrel-tab-panel", f.id = _, f.setAttribute("role", "tabpanel"), f.setAttribute("aria-labelledby", k), f.tabIndex = a === 0 ? 0 : -1, a !== 0 && (f.style.display = "none"), s.push(f);
213
+ f.className = "gengage-simrel-tab-panel", f.dataset.gengagePart = "simrel-tab-panel", f.id = E, f.setAttribute("role", "tabpanel"), f.setAttribute("aria-labelledby", _), f.tabIndex = a === 0 ? 0 : -1, a !== 0 && (f.style.display = "none"), s.push(f);
212
214
  }
213
215
  const l = document.createElement("button");
214
216
  l.type = "button", l.className = "gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--left", l.setAttribute("aria-label", e.i18n?.scrollTabsLeft ?? "Scroll tabs left"), l.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>';
@@ -216,181 +218,181 @@ function fe(e) {
216
218
  h.type = "button", h.className = "gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--right", h.setAttribute("aria-label", e.i18n?.scrollTabsRight ?? "Scroll tabs right"), h.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>';
217
219
  const m = 200;
218
220
  l.addEventListener("click", () => {
219
- r.scrollBy({
221
+ n.scrollBy({
220
222
  left: -m,
221
223
  behavior: "smooth"
222
224
  });
223
225
  }), h.addEventListener("click", () => {
224
- r.scrollBy({
226
+ n.scrollBy({
225
227
  left: m,
226
228
  behavior: "smooth"
227
229
  });
228
230
  });
229
231
  const p = () => {
230
- const a = r.scrollLeft <= 4, g = r.scrollLeft + r.clientWidth >= r.scrollWidth - 4;
231
- l.style.display = a ? "none" : "", h.style.display = g ? "none" : "", r.classList.toggle("gengage-simrel-tabs--peek-right", !g), r.classList.toggle("gengage-simrel-tabs--peek-left", !a);
232
+ const a = n.scrollLeft <= 4, u = n.scrollLeft + n.clientWidth >= n.scrollWidth - 4;
233
+ l.style.display = a ? "none" : "", h.style.display = u ? "none" : "", n.classList.toggle("gengage-simrel-tabs--peek-right", !u), n.classList.toggle("gengage-simrel-tabs--peek-left", !a);
232
234
  };
233
- r.addEventListener("scroll", p, { passive: !0 }), typeof ResizeObserver < "u" && new ResizeObserver(p).observe(r), l.style.display = "none", h.style.display = "none", requestAnimationFrame(p);
235
+ n.addEventListener("scroll", p, { passive: !0 }), typeof ResizeObserver < "u" && new ResizeObserver(p).observe(n), l.style.display = "none", h.style.display = "none", requestAnimationFrame(p);
234
236
  const y = document.createElement("div");
235
- y.className = "gengage-simrel-tabs-wrapper", y.appendChild(l), y.appendChild(r), y.appendChild(h), n.appendChild(y);
236
- const b = s[0], o = N(d(e.groups[0]));
237
+ y.className = "gengage-simrel-tabs-wrapper", y.appendChild(l), y.appendChild(n), y.appendChild(h), r.appendChild(y);
238
+ const b = s[0], o = I(d(e.groups[0]));
237
239
  b.appendChild(o);
238
- for (const a of s) n.appendChild(a);
239
- return n;
240
+ for (const a of s) r.appendChild(a);
241
+ return r;
240
242
  }
241
- function U(e) {
243
+ function L(e) {
242
244
  if (!e || typeof e != "object") return null;
243
245
  const t = e;
244
246
  if (typeof t.sku != "string" || typeof t.name != "string" || typeof t.url != "string") return null;
245
- const n = {
247
+ const r = {
246
248
  sku: t.sku,
247
249
  name: t.name,
248
250
  url: t.url
249
- }, r = t.imageUrl;
250
- typeof r == "string" && (n.imageUrl = r);
251
+ }, n = t.imageUrl;
252
+ typeof n == "string" && (r.imageUrl = n);
251
253
  const i = t.price;
252
- typeof i == "string" && (n.price = i);
254
+ typeof i == "string" && (r.price = i);
253
255
  const s = t.originalPrice;
254
- typeof s == "string" && (n.originalPrice = s);
256
+ typeof s == "string" && (r.originalPrice = s);
255
257
  const c = t.discountPercent;
256
- typeof c == "number" && (n.discountPercent = c);
258
+ typeof c == "number" && (r.discountPercent = c);
257
259
  const d = t.brand;
258
- typeof d == "string" && (n.brand = d);
259
- const u = t.rating;
260
- typeof u == "number" && (n.rating = u);
260
+ typeof d == "string" && (r.brand = d);
261
+ const g = t.rating;
262
+ typeof g == "number" && (r.rating = g);
261
263
  const l = t.reviewCount;
262
- typeof l == "number" && (n.reviewCount = l);
264
+ typeof l == "number" && (r.reviewCount = l);
263
265
  const h = t.cartCode;
264
- typeof h == "string" && (n.cartCode = h);
266
+ typeof h == "string" && (r.cartCode = h);
265
267
  const m = t.inStock;
266
- typeof m == "boolean" && (n.inStock = m);
268
+ typeof m == "boolean" && (r.inStock = m);
267
269
  const p = t.extras;
268
- return p != null && typeof p == "object" && (n.extras = p), n;
270
+ return p != null && typeof p == "object" && (r.extras = p), r;
269
271
  }
270
- function he(e) {
272
+ function le(e) {
271
273
  if (!e || typeof e != "object") return null;
272
- const t = e, n = t.title, r = t.type;
273
- if (typeof n != "string" || typeof r != "string") return null;
274
+ const t = e, r = t.title, n = t.type;
275
+ if (typeof r != "string" || typeof n != "string") return null;
274
276
  const i = {
275
- title: n,
276
- type: r
277
+ title: r,
278
+ type: n
277
279
  };
278
280
  return t.payload !== void 0 && (i.payload = t.payload), i;
279
281
  }
280
- var j = {
281
- ProductGrid: ({ element: e, renderElement: t, context: n }) => {
282
- const r = document.createElement("div");
283
- r.className = "gengage-simrel-grid", r.setAttribute("role", "list");
282
+ var O = {
283
+ ProductGrid: ({ element: e, renderElement: t, context: r }) => {
284
+ const n = document.createElement("div");
285
+ n.className = "gengage-simrel-grid", n.setAttribute("role", "list");
284
286
  const i = e.props?.columns;
285
287
  let s;
286
- typeof i == "number" && Number.isFinite(i) && i > 0 ? s = Math.floor(i) : typeof n.gridColumns == "number" && Number.isFinite(n.gridColumns) && n.gridColumns > 0 && (s = Math.floor(n.gridColumns)), s !== void 0 && r.style.setProperty("--gengage-simrel-columns", String(s));
288
+ typeof i == "number" && Number.isFinite(i) && i > 0 ? s = Math.floor(i) : typeof r.gridColumns == "number" && Number.isFinite(r.gridColumns) && r.gridColumns > 0 && (s = Math.floor(r.gridColumns)), s !== void 0 && n.style.setProperty("--gengage-simrel-columns", String(s));
287
289
  for (const c of e.children ?? []) {
288
290
  const d = t(c);
289
- d && r.appendChild(d);
291
+ d && n.appendChild(d);
290
292
  }
291
- if (r.children.length === 0) {
293
+ if (n.children.length === 0) {
292
294
  const c = document.createElement("div");
293
- c.className = "gengage-simrel-empty", c.textContent = n.i18n.emptyStateMessage, r.appendChild(c);
295
+ c.className = "gengage-simrel-empty", c.textContent = r.i18n.emptyStateMessage, n.appendChild(c);
294
296
  }
295
- return r;
297
+ return n;
296
298
  },
297
299
  ProductCard: ({ element: e, context: t }) => {
298
- const n = U(e.props?.product ?? e.props);
299
- if (!n) return null;
300
- const r = e.props?.index, i = typeof r == "number" && Number.isFinite(r) ? r : 0, s = e.props?.discountType, c = s === "strike-through" || s === "badge" ? s : t.discountType, d = {
301
- product: n,
300
+ const r = L(e.props?.product ?? e.props);
301
+ if (!r) return null;
302
+ const n = e.props?.index, i = typeof n == "number" && Number.isFinite(n) ? n : 0, s = e.props?.discountType, c = s === "strike-through" || s === "badge" ? s : t.discountType, d = {
303
+ product: r,
302
304
  index: i,
303
305
  onClick: t.onClick,
304
306
  onAddToCart: t.onAddToCart,
305
307
  i18n: t.i18n
306
308
  };
307
- return c !== void 0 && (d.discountType = c), t.renderCard !== void 0 && (d.renderCard = t.renderCard), t.renderCardElement !== void 0 && (d.renderCardElement = t.renderCardElement), t.pricing !== void 0 && (d.pricing = t.pricing), D(d);
309
+ return c !== void 0 && (d.discountType = c), t.renderCard !== void 0 && (d.renderCard = t.renderCard), t.renderCardElement !== void 0 && (d.renderCardElement = t.renderCardElement), t.pricing !== void 0 && (d.pricing = t.pricing), x(d);
308
310
  },
309
311
  GroupTabs: ({ element: e, context: t }) => {
310
- const n = e.props?.groups;
311
- if (!Array.isArray(n)) return null;
312
- const r = [];
313
- for (const c of n) {
312
+ const r = e.props?.groups;
313
+ if (!Array.isArray(r)) return null;
314
+ const n = [];
315
+ for (const c of r) {
314
316
  if (!c || typeof c != "object") continue;
315
317
  const d = c;
316
318
  if (typeof d.name != "string") continue;
317
- const u = [];
319
+ const g = [];
318
320
  if (Array.isArray(d.products)) for (const h of d.products) {
319
- const m = U(h);
320
- m && u.push(m);
321
+ const m = L(h);
322
+ m && g.push(m);
321
323
  }
322
324
  const l = {
323
325
  name: d.name,
324
- products: u
326
+ products: g
325
327
  };
326
- typeof d.highlight == "string" && (l.highlight = d.highlight), r.push(l);
328
+ typeof d.highlight == "string" && (l.highlight = d.highlight), n.push(l);
327
329
  }
328
330
  const i = {
329
- groups: r,
331
+ groups: n,
330
332
  onClick: t.onClick,
331
333
  onAddToCart: t.onAddToCart,
332
334
  i18n: t.i18n
333
335
  }, s = e.props?.columns;
334
- return typeof s == "number" && Number.isFinite(s) && s > 0 ? i.columns = Math.floor(s) : typeof t.gridColumns == "number" && Number.isFinite(t.gridColumns) && t.gridColumns > 0 && (i.columns = Math.floor(t.gridColumns)), t.discountType !== void 0 && (i.discountType = t.discountType), t.renderCard !== void 0 && (i.renderCard = t.renderCard), t.renderCardElement !== void 0 && (i.renderCardElement = t.renderCardElement), t.onGroupingActivate !== void 0 && (i.onGroupingActivate = t.onGroupingActivate), fe(i);
336
+ return typeof s == "number" && Number.isFinite(s) && s > 0 ? i.columns = Math.floor(s) : typeof t.gridColumns == "number" && Number.isFinite(t.gridColumns) && t.gridColumns > 0 && (i.columns = Math.floor(t.gridColumns)), t.discountType !== void 0 && (i.discountType = t.discountType), t.renderCard !== void 0 && (i.renderCard = t.renderCard), t.renderCardElement !== void 0 && (i.renderCardElement = t.renderCardElement), t.onGroupingActivate !== void 0 && (i.onGroupingActivate = t.onGroupingActivate), de(i);
335
337
  },
336
338
  EmptyState: ({ element: e, context: t }) => {
337
- const n = document.createElement("div");
338
- n.className = "gengage-simrel-empty";
339
- const r = e.props?.message;
340
- return n.textContent = typeof r == "string" ? r : t.i18n.emptyStateMessage, n;
339
+ const r = document.createElement("div");
340
+ r.className = "gengage-simrel-empty";
341
+ const n = e.props?.message;
342
+ return r.textContent = typeof n == "string" ? n : t.i18n.emptyStateMessage, r;
341
343
  },
342
344
  AddToCartButton: ({ element: e, context: t }) => {
343
- const n = e.props?.sku, r = e.props?.cartCode;
344
- if (typeof n != "string" || typeof r != "string") return null;
345
+ const r = e.props?.sku, n = e.props?.cartCode;
346
+ if (typeof r != "string" || typeof n != "string") return null;
345
347
  const i = document.createElement("button");
346
348
  i.className = "gengage-simrel-atc gengage-chat-product-card-cta", i.type = "button";
347
349
  const s = e.props?.label;
348
350
  return i.textContent = typeof s == "string" ? s : t.i18n.addToCartButton, i.addEventListener("click", (c) => {
349
351
  c.preventDefault(), c.stopPropagation(), t.onAddToCart({
350
- sku: n,
352
+ sku: r,
351
353
  quantity: 1,
352
- cartCode: r
354
+ cartCode: n
353
355
  });
354
356
  }), i;
355
357
  },
356
358
  QuickActions: ({ element: e, context: t }) => {
357
- const n = document.createElement("div");
358
- n.className = "gengage-simrel-quick-actions";
359
- const r = e.props?.actions;
360
- if (!Array.isArray(r) || !t.onAction) return n;
361
- for (const i of r) {
359
+ const r = document.createElement("div");
360
+ r.className = "gengage-simrel-quick-actions";
361
+ const n = e.props?.actions;
362
+ if (!Array.isArray(n) || !t.onAction) return r;
363
+ for (const i of n) {
362
364
  if (!i || typeof i != "object") continue;
363
- const s = i, c = s.label, d = he(s.action);
365
+ const s = i, c = s.label, d = le(s.action);
364
366
  if (typeof c != "string" || !d) continue;
365
- const u = document.createElement("button");
366
- u.className = "gengage-simrel-quick-action", u.type = "button", u.textContent = c, u.addEventListener("click", (l) => {
367
+ const g = document.createElement("button");
368
+ g.className = "gengage-simrel-quick-action", g.type = "button", g.textContent = c, g.addEventListener("click", (l) => {
367
369
  l.preventDefault(), l.stopPropagation(), t.onAction?.(d);
368
- }), n.appendChild(u);
370
+ }), r.appendChild(g);
369
371
  }
370
- return n;
372
+ return r;
371
373
  }
372
- }, F = ({ element: e, renderElement: t }) => {
374
+ }, B = ({ element: e, renderElement: t }) => {
373
375
  if (!e.children || e.children.length === 0) return null;
374
- const n = document.createElement("div");
375
- for (const r of e.children) {
376
- const i = t(r);
377
- i && n.appendChild(i);
376
+ const r = document.createElement("div");
377
+ for (const n of e.children) {
378
+ const i = t(n);
379
+ i && r.appendChild(i);
378
380
  }
379
- return n;
381
+ return r;
380
382
  };
381
- function ye() {
382
- return { ...j };
383
+ function ge() {
384
+ return { ...O };
383
385
  }
384
- function Ce(e, t, n = j, r = F) {
385
- return Y({
386
+ function ue(e, t, r = O, n = B) {
387
+ return H({
386
388
  spec: e,
387
389
  context: t,
388
- registry: n,
390
+ registry: r,
389
391
  containerClassName: "gengage-simrel-uispec",
390
- unknownRenderer: r
392
+ unknownRenderer: n
391
393
  });
392
394
  }
393
- var H = {
395
+ var q = {
394
396
  similarProductsAriaLabel: "Benzer ürünler",
395
397
  emptyStateMessage: "Benzer ürün bulunamadı.",
396
398
  addToCartButton: "Sepete Ekle",
@@ -403,7 +405,7 @@ var H = {
403
405
  priceSuffix: " TL",
404
406
  scrollTabsLeft: "Sola kaydır",
405
407
  scrollTabsRight: "Sağa kaydır"
406
- }, be = {
408
+ }, pe = {
407
409
  similarProductsAriaLabel: "Similar products",
408
410
  emptyStateMessage: "No similar products found.",
409
411
  addToCartButton: "Add to cart",
@@ -417,74 +419,24 @@ var H = {
417
419
  scrollTabsLeft: "Scroll tabs left",
418
420
  scrollTabsRight: "Scroll tabs right"
419
421
  };
420
- function ve(e) {
422
+ function me(e) {
421
423
  return e ? e.toLowerCase().split("-")[0] ?? "tr" : "tr";
422
424
  }
423
- function Ee(e) {
424
- return ve(e) === "en" ? be : H;
425
+ function fe(e) {
426
+ return me(e) === "en" ? pe : q;
425
427
  }
426
- var _e = S({
427
- sku: E(),
428
- name: E(),
429
- imageUrl: E().url().optional(),
430
- price: E().optional(),
431
- originalPrice: E().optional(),
432
- discountPercent: A().optional(),
433
- url: E().url(),
434
- brand: E().optional(),
435
- rating: A().min(0).max(5).optional(),
436
- reviewCount: A().int().nonnegative().optional()
437
- }), ke = S({
438
- layout: O(["grid", "carousel"]).optional(),
439
- columns: A().int().positive().optional()
440
- }), Se = S({
441
- product: _e,
442
- index: A().int().nonnegative(),
443
- discountType: O(["strike-through", "badge"]).optional()
444
- }), Te = S({
445
- sku: E(),
446
- label: E().optional(),
447
- cartCode: E()
448
- }), we = S({ actions: J(S({
449
- label: E(),
450
- action: S({
451
- title: E(),
452
- type: E(),
453
- payload: Q().optional()
454
- })
455
- })) }), Ae = S({ message: E().optional() }), Ge = { components: {
456
- ProductGrid: {
457
- schema: ke,
458
- description: "Outer grid or carousel container for similar products."
459
- },
460
- ProductCard: {
461
- schema: Se,
462
- description: "A single product card with image, title, price, and actions."
463
- },
464
- AddToCartButton: {
465
- schema: Te,
466
- description: "Add-to-cart CTA rendered inside or below a product card."
467
- },
468
- QuickActions: {
469
- schema: we,
470
- description: "A row of quick-action buttons below product info."
471
- },
472
- EmptyState: {
473
- schema: Ae,
474
- description: "Empty state shown when no similar products are available."
475
- }
476
- } }, Pe = 12e4;
477
- function Ie(e) {
428
+ var he = 12e4;
429
+ function ye(e) {
478
430
  return e instanceof DOMException && e.name === "AbortError";
479
431
  }
480
- var Le = class extends te {
432
+ var Ce = class extends J {
481
433
  constructor(...e) {
482
- super(...e), this._abortController = null, this._contentEl = null, this._lastResultCount = -1, this._i18n = H;
434
+ super(...e), this._abortController = null, this._contentEl = null, this._lastResultCount = -1, this._i18n = q;
483
435
  }
484
436
  async onInit(e) {
485
- this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-simrel-container", this._contentEl.dataset.gengagePart = "simrel-container", this._contentEl.lang = re(e.locale);
437
+ this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-simrel-container", this._contentEl.dataset.gengagePart = "simrel-container", this._contentEl.lang = Z(e.locale);
486
438
  const t = this._clampGridColumns(e.gridColumns);
487
- t !== void 0 && this._contentEl.style.setProperty("--gengage-simrel-columns", String(t)), this.root.appendChild(this._contentEl), this._lastSku = e.sku, await this._fetchAndRender(e.sku), V("simrel");
439
+ t !== void 0 && this._contentEl.style.setProperty("--gengage-simrel-columns", String(t)), this.root.appendChild(this._contentEl), this._lastSku = e.sku, await this._fetchAndRender(e.sku), X("simrel");
488
440
  }
489
441
  onUpdate(e) {
490
442
  const t = e.sku;
@@ -507,16 +459,16 @@ var Le = class extends te {
507
459
  url: e.url
508
460
  };
509
461
  if (e.imageUrl !== void 0 && (t.imageUrl = e.imageUrl), e.price !== void 0 && (t.price = e.price), e.originalPrice !== void 0 && (t.originalPrice = e.originalPrice), e.discountPercent !== void 0 && (t.discountPercent = e.discountPercent), e.brand !== void 0 && (t.brand = e.brand), e.rating !== void 0 && (t.rating = e.rating), e.reviewCount !== void 0 && (t.reviewCount = e.reviewCount), e.cartCode !== void 0 && (t.cartCode = e.cartCode), e.inStock !== void 0 && (t.inStock = e.inStock), this.config.onProductClick?.(t) === !1) return;
510
- const n = this.config.session?.sessionId ?? null;
511
- w("gengage:similar:product-click", {
462
+ const r = this.config.session?.sessionId ?? null;
463
+ S("gengage:similar:product-click", {
512
464
  sku: e.sku,
513
465
  url: e.url,
514
- sessionId: n,
466
+ sessionId: r,
515
467
  productName: e.name
516
- }), this.config.onProductNavigate?.(e.url, e.sku, n);
468
+ }), this.config.onProductNavigate?.(e.url, e.sku, r);
517
469
  }
518
470
  _handleAddToCart(e) {
519
- se(e.sku, e.quantity), this.config.onAddToCart?.(e), w("gengage:similar:add-to-cart", e), this.track(Z(this.analyticsContext(), {
471
+ K(e.sku, e.quantity), this.config.onAddToCart?.(e), S("gengage:similar:add-to-cart", e), this.track($(this.analyticsContext(), {
520
472
  attribution_source: "simrel",
521
473
  attribution_action_id: crypto.randomUUID(),
522
474
  cart_value: 0,
@@ -532,40 +484,40 @@ var Le = class extends te {
532
484
  return this._abortController?.signal !== e;
533
485
  }
534
486
  _emitSimilarProductsImpression(e, t) {
535
- const n = this.config.session?.sessionId ?? null;
536
- w("gengage:similar:products-impression", {
487
+ const r = this.config.session?.sessionId ?? null;
488
+ S("gengage:similar:products-impression", {
537
489
  source_sku: this.config.sku,
538
490
  product_count: e,
539
491
  grouped: t,
540
- sessionId: n
492
+ sessionId: r
541
493
  });
542
494
  }
543
495
  _resolveRequestTimeoutMs() {
544
496
  const e = this.config.requestTimeoutMs;
545
- return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? Pe : Math.floor(e);
497
+ return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? he : Math.floor(e);
546
498
  }
547
499
  async _fetchAndRender(e) {
548
500
  this._abort();
549
501
  const t = new AbortController();
550
502
  this._abortController = t;
551
- const n = t.signal;
552
- let r = !1;
503
+ const r = t.signal;
504
+ let n = !1;
553
505
  const i = setTimeout(() => {
554
- r = !0, t.abort();
506
+ n = !0, t.abort();
555
507
  }, this._resolveRequestTimeoutMs());
556
- if (n.addEventListener("abort", () => clearTimeout(i), { once: !0 }), !this._contentEl) return;
508
+ if (r.addEventListener("abort", () => clearTimeout(i), { once: !0 }), !this._contentEl) return;
557
509
  this._contentEl.innerHTML = "", this._contentEl.style.display = "";
558
510
  const s = document.createElement("div");
559
511
  s.className = "gengage-simrel-loading", s.dataset.gengagePart = "simrel-loading";
560
512
  const c = document.createElement("div");
561
513
  c.className = "gengage-simrel-spinner", c.dataset.gengagePart = "simrel-loading-spinner", s.appendChild(c), this._contentEl.appendChild(s);
562
- const d = { middlewareUrl: this.config.middlewareUrl }, u = crypto.randomUUID(), l = Date.now(), h = de({
514
+ const d = { middlewareUrl: this.config.middlewareUrl }, g = crypto.randomUUID(), l = Date.now(), h = ne({
563
515
  source: "simrel",
564
516
  locale: this.config.locale
565
517
  });
566
- this.track(ne(this.analyticsContext(), {
518
+ this.track(z(this.analyticsContext(), {
567
519
  endpoint: "similar_products",
568
- request_id: u,
520
+ request_id: g,
569
521
  widget: "simrel"
570
522
  }));
571
523
  try {
@@ -576,64 +528,64 @@ var Le = class extends te {
576
528
  sku: e
577
529
  };
578
530
  this.config.domain !== void 0 && (m.domain = this.config.domain);
579
- const p = await ue(m, d, n);
531
+ const p = await se(m, d, r);
580
532
  if (this._lastResultCount = p.length, !this._contentEl) return;
581
533
  if (this._contentEl.innerHTML = "", p.length > 0) try {
582
- const y = p.map((a) => a.sku), b = new Map(p.map((a) => [a.sku, a])), o = (await pe({
534
+ const y = p.map((a) => a.sku), b = new Map(p.map((a) => [a.sku, a])), o = (await ae({
583
535
  account_id: this.config.accountId,
584
536
  session_id: this.config.session?.sessionId ?? "",
585
537
  correlation_id: this.config.session?.sessionId ?? "",
586
538
  skus: y
587
- }, d, n)).map((a) => ({
539
+ }, d, r)).map((a) => ({
588
540
  ...a,
589
- products: a.products.map((g) => ({
590
- ...b.get(g.sku),
591
- ...g
592
- })).filter((g) => typeof g.sku == "string" && typeof g.name == "string" && typeof g.url == "string")
541
+ products: a.products.map((u) => ({
542
+ ...b.get(u.sku),
543
+ ...u
544
+ })).filter((u) => typeof u.sku == "string" && typeof u.name == "string" && typeof u.url == "string")
593
545
  })).filter((a) => a.products.length > 0);
594
546
  if (o.length > 0 && this._contentEl) {
595
- const a = this._buildGroupsSpec(o), g = this._renderUISpec(a);
596
- this._contentEl.appendChild(g), P("simrel"), this.track(I(this.analyticsContext(), {
597
- request_id: u,
547
+ const a = this._buildGroupsSpec(o), u = this._renderUISpec(a);
548
+ this._contentEl.appendChild(u), A("simrel"), this.track(T(this.analyticsContext(), {
549
+ request_id: g,
598
550
  latency_ms: Date.now() - l,
599
- chunk_count: o.reduce((k, _) => k + _.products.length, 0),
551
+ chunk_count: o.reduce((_, E) => _ + E.products.length, 0),
600
552
  widget: "simrel"
601
- })), this.track(L(this.analyticsContext(), {
602
- message_count: o.reduce((k, _) => k + _.products.length, 0),
603
- history_ref: u,
553
+ })), this.track(w(this.analyticsContext(), {
554
+ message_count: o.reduce((_, E) => _ + E.products.length, 0),
555
+ history_ref: g,
604
556
  redaction_level: "none",
605
557
  widget: "simrel"
606
- })), this._emitSimilarProductsImpression(o.reduce((k, _) => k + _.products.length, 0), !0);
558
+ })), this._emitSimilarProductsImpression(o.reduce((_, E) => _ + E.products.length, 0), !0);
607
559
  return;
608
560
  }
609
561
  } catch {
610
562
  }
611
- if (this._isSuperseded(n)) return;
563
+ if (this._isSuperseded(r)) return;
612
564
  if (this._contentEl) {
613
565
  const y = this._buildProductsSpec(p), b = this._renderUISpec(y);
614
566
  this._contentEl.appendChild(b);
615
567
  }
616
- p.length > 0 && P("simrel"), this.track(I(this.analyticsContext(), {
617
- request_id: u,
568
+ p.length > 0 && A("simrel"), this.track(T(this.analyticsContext(), {
569
+ request_id: g,
618
570
  latency_ms: Date.now() - l,
619
571
  chunk_count: p.length,
620
572
  widget: "simrel"
621
- })), this.track(L(this.analyticsContext(), {
573
+ })), this.track(w(this.analyticsContext(), {
622
574
  message_count: p.length,
623
- history_ref: u,
575
+ history_ref: g,
624
576
  redaction_level: "none",
625
577
  widget: "simrel"
626
578
  })), this._emitSimilarProductsImpression(p.length, !1);
627
579
  } catch (m) {
628
- const p = Ie(m);
629
- if (p && this._isSuperseded(n)) return;
630
- const y = p && r ? "REQUEST_TIMEOUT" : "FETCH_ERROR", b = p && r ? "request_timeout" : m instanceof Error ? m.message : String(m);
631
- if (w("gengage:global:error", {
580
+ const p = ye(m);
581
+ if (p && this._isSuperseded(r)) return;
582
+ const y = p && n ? "REQUEST_TIMEOUT" : "FETCH_ERROR", b = p && n ? "request_timeout" : m instanceof Error ? m.message : String(m);
583
+ if (S("gengage:global:error", {
632
584
  source: "simrel",
633
585
  code: y,
634
- message: ee(this.config.locale, m)
635
- }), this.track(ie(this.analyticsContext(), {
636
- request_id: u,
586
+ message: W(this.config.locale, m)
587
+ }), this.track(Q(this.analyticsContext(), {
588
+ request_id: g,
637
589
  error_code: y,
638
590
  error_message: b,
639
591
  widget: "simrel"
@@ -643,10 +595,10 @@ var Le = class extends te {
643
595
  o.className = "gengage-simrel-error";
644
596
  const a = document.createElement("span");
645
597
  a.textContent = this._i18n.errorLoadingMessage, o.appendChild(a);
646
- const g = document.createElement("button");
647
- g.className = "gengage-simrel-retry", g.textContent = this._i18n.retryButtonText, g.addEventListener("click", () => {
598
+ const u = document.createElement("button");
599
+ u.className = "gengage-simrel-retry", u.textContent = this._i18n.retryButtonText, u.addEventListener("click", () => {
648
600
  this._fetchAndRender(this.config.sku);
649
- }), o.appendChild(g), this._contentEl.appendChild(o);
601
+ }), o.appendChild(u), this._contentEl.appendChild(o);
650
602
  }
651
603
  } finally {
652
604
  clearTimeout(i), h();
@@ -658,43 +610,43 @@ var Le = class extends te {
658
610
  }
659
611
  _resolveI18n(e) {
660
612
  return {
661
- ...Ee(e.locale),
613
+ ...fe(e.locale),
662
614
  ...e.i18n
663
615
  };
664
616
  }
665
617
  _resolveUISpecRegistry() {
666
- return z(ye(), this.config.renderer?.registry);
618
+ return j(ge(), this.config.renderer?.registry);
667
619
  }
668
620
  _buildRenderContext() {
669
621
  const e = this.config.renderCard, t = {
670
- onClick: (r) => this._handleProductClick(r),
671
- onAddToCart: (r) => this._handleAddToCart(r),
672
- onGroupingActivate: (r) => {
673
- w("gengage:similar:grouping-click", {
674
- grouping_label: r.grouping_label,
675
- grouping_index: r.grouping_index,
622
+ onClick: (n) => this._handleProductClick(n),
623
+ onAddToCart: (n) => this._handleAddToCart(n),
624
+ onGroupingActivate: (n) => {
625
+ S("gengage:similar:grouping-click", {
626
+ grouping_label: n.grouping_label,
627
+ grouping_index: n.grouping_index,
676
628
  sessionId: this.config.session?.sessionId ?? null
677
629
  });
678
630
  },
679
631
  i18n: this._i18n
680
632
  };
681
633
  this.config.discountType !== void 0 && (t.discountType = this.config.discountType), e !== void 0 && (t.renderCard = e), this.config.renderCardElement !== void 0 && (t.renderCardElement = this.config.renderCardElement), this.config.pricing !== void 0 && (t.pricing = this.config.pricing);
682
- const n = this._clampGridColumns(this.config.gridColumns);
683
- return n !== void 0 && (t.gridColumns = n), t;
634
+ const r = this._clampGridColumns(this.config.gridColumns);
635
+ return r !== void 0 && (t.gridColumns = r), t;
684
636
  }
685
637
  _renderUISpec(e) {
686
- const t = this._resolveUISpecRegistry(), n = this._buildRenderContext(), r = this.config.renderer?.unknownRenderer ?? F, i = (c, d) => Ce(c, d, t, r), s = this.config.renderer?.renderUISpec;
687
- return s ? s(e, n, {
638
+ const t = this._resolveUISpecRegistry(), r = this._buildRenderContext(), n = this.config.renderer?.unknownRenderer ?? B, i = (c, d) => ue(c, d, t, n), s = this.config.renderer?.renderUISpec;
639
+ return s ? s(e, r, {
688
640
  registry: t,
689
- unknownRenderer: r,
641
+ unknownRenderer: n,
690
642
  defaultRender: i
691
- }) : i(e, n);
643
+ }) : i(e, r);
692
644
  }
693
645
  _buildProductsSpec(e) {
694
- const t = {}, n = [];
646
+ const t = {}, r = [];
695
647
  for (let s = 0; s < e.length; s++) {
696
648
  const c = e[s], d = `product-${s}`;
697
- n.push(d), t[d] = {
649
+ r.push(d), t[d] = {
698
650
  type: "ProductCard",
699
651
  props: {
700
652
  product: c,
@@ -703,11 +655,11 @@ var Le = class extends te {
703
655
  }
704
656
  };
705
657
  }
706
- const r = { layout: "grid" }, i = this._clampGridColumns(this.config.gridColumns);
707
- return i !== void 0 && (r.columns = i), t.root = {
658
+ const n = { layout: "grid" }, i = this._clampGridColumns(this.config.gridColumns);
659
+ return i !== void 0 && (n.columns = i), t.root = {
708
660
  type: "ProductGrid",
709
- props: r,
710
- children: n
661
+ props: n,
662
+ children: r
711
663
  }, {
712
664
  root: "root",
713
665
  elements: t
@@ -723,14 +675,13 @@ var Le = class extends te {
723
675
  };
724
676
  }
725
677
  };
726
- function xe() {
727
- return new Le();
678
+ function Te() {
679
+ return new Ce();
728
680
  }
729
681
  export {
730
- F as a,
731
- ye as i,
732
- xe as n,
733
- Ce as o,
734
- Ge as r,
735
- Le as t
682
+ ue as a,
683
+ B as i,
684
+ Te as n,
685
+ ge as r,
686
+ Ce as t
736
687
  };