@gengage/assistant-fe 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +100 -0
  2. package/dist/assistant-fe.css +1 -1
  3. package/dist/chat/components/AIGroupingCards.d.ts.map +1 -1
  4. package/dist/chat/components/AITopPicks.d.ts.map +1 -1
  5. package/dist/chat/components/ChatDrawer.d.ts +12 -4
  6. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  7. package/dist/chat/components/ComparisonTable.d.ts +2 -7
  8. package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
  9. package/dist/chat/components/productMentionLinker.d.ts.map +1 -1
  10. package/dist/chat/index.d.ts +14 -1
  11. package/dist/chat/index.d.ts.map +1 -1
  12. package/dist/chat/locales/en.d.ts.map +1 -1
  13. package/dist/chat/locales/tr.d.ts.map +1 -1
  14. package/dist/chat/panel-manager.d.ts +6 -2
  15. package/dist/chat/panel-manager.d.ts.map +1 -1
  16. package/dist/chat/session-persistence.d.ts +1 -0
  17. package/dist/chat/session-persistence.d.ts.map +1 -1
  18. package/dist/chat/types.d.ts +4 -2
  19. package/dist/chat/types.d.ts.map +1 -1
  20. package/dist/chat.cjs +1 -1
  21. package/dist/chat.iife.js +29 -29
  22. package/dist/chat.iife.js.map +1 -1
  23. package/dist/chat.js +2 -2
  24. package/dist/common/events.d.ts.map +1 -1
  25. package/dist/common/index.d.ts +2 -0
  26. package/dist/common/index.d.ts.map +1 -1
  27. package/dist/common/indexed-db.d.ts +2 -0
  28. package/dist/common/indexed-db.d.ts.map +1 -1
  29. package/dist/common/native-webview.d.ts +61 -0
  30. package/dist/common/native-webview.d.ts.map +1 -0
  31. package/dist/common/overlay.d.ts +5 -0
  32. package/dist/common/overlay.d.ts.map +1 -1
  33. package/dist/common/v1-protocol-adapter.d.ts.map +1 -1
  34. package/dist/common.cjs +1 -1
  35. package/dist/common.cjs.map +1 -1
  36. package/dist/common.js +197 -426
  37. package/dist/common.js.map +1 -1
  38. package/dist/index-1yPxOqAw.cjs +13 -0
  39. package/dist/index-1yPxOqAw.cjs.map +1 -0
  40. package/dist/index-BH-V2lWn.js +510 -0
  41. package/dist/index-BH-V2lWn.js.map +1 -0
  42. package/dist/index-BelS6Vnv.cjs +2 -0
  43. package/dist/index-BelS6Vnv.cjs.map +1 -0
  44. package/dist/index-CERWfDdF.js +4571 -0
  45. package/dist/index-CERWfDdF.js.map +1 -0
  46. package/dist/index.cjs +1 -1
  47. package/dist/index.d.ts +2 -2
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +55 -50
  50. package/dist/index.js.map +1 -1
  51. package/dist/native/index.d.ts +3 -0
  52. package/dist/native/index.d.ts.map +1 -0
  53. package/dist/native.cjs +2 -0
  54. package/dist/native.cjs.map +1 -0
  55. package/dist/native.iife.js +97 -0
  56. package/dist/native.iife.js.map +1 -0
  57. package/dist/native.js +9 -0
  58. package/dist/native.js.map +1 -0
  59. package/dist/qna/components/TextInput.d.ts.map +1 -1
  60. package/dist/qna/components/renderUISpec.d.ts.map +1 -1
  61. package/dist/qna/index.d.ts +1 -0
  62. package/dist/qna/index.d.ts.map +1 -1
  63. package/dist/qna/types.d.ts +1 -1
  64. package/dist/qna/types.d.ts.map +1 -1
  65. package/dist/qna.cjs +1 -1
  66. package/dist/qna.cjs.map +1 -1
  67. package/dist/qna.css +1 -1
  68. package/dist/qna.iife.js +20 -20
  69. package/dist/qna.iife.js.map +1 -1
  70. package/dist/qna.js +92 -80
  71. package/dist/qna.js.map +1 -1
  72. package/dist/schemas-DHzfUzwA.cjs +86 -0
  73. package/dist/schemas-DHzfUzwA.cjs.map +1 -0
  74. package/dist/{schemas-B9GN-J3e.js → schemas-yF4IOEUi.js} +1088 -987
  75. package/dist/schemas-yF4IOEUi.js.map +1 -0
  76. package/dist/simrel/components/ProductCard.d.ts.map +1 -1
  77. package/dist/simrel.cjs +1 -1
  78. package/dist/simrel.cjs.map +1 -1
  79. package/dist/simrel.css +1 -1
  80. package/dist/simrel.iife.js +20 -20
  81. package/dist/simrel.iife.js.map +1 -1
  82. package/dist/simrel.js +218 -214
  83. package/dist/simrel.js.map +1 -1
  84. package/package.json +9 -2
  85. package/dist/index-eefqsSOT.cjs +0 -13
  86. package/dist/index-eefqsSOT.cjs.map +0 -1
  87. package/dist/index-kp84NL1R.js +0 -4399
  88. package/dist/index-kp84NL1R.js.map +0 -1
  89. package/dist/schemas-B9GN-J3e.js.map +0 -1
  90. package/dist/schemas-tCxs1sED.cjs +0 -86
  91. package/dist/schemas-tCxs1sED.cjs.map +0 -1
package/dist/simrel.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b as P, p as j, q as D, c as I, a as R, r as M, o as C, s as m, f as q, e as B, _ as N, v as _, B as H, t as z, x as $, j as v, y as F, z as J, g as Q, i as E, h as k, w as S, k as W, l as V, m as Y } from "./schemas-B9GN-J3e.js";
1
+ import { b as A, p as D, q as j, c as I, a as R, r as M, o as b, s as h, f as q, e as B, _ as N, v, B as H, t as z, x as $, j as _, y as F, z as J, g as Q, i as E, h as k, w as S, k as W, l as V, m as Y } from "./schemas-yF4IOEUi.js";
2
2
  import { s as K, i as X, a as Z, c as ee, r as te, f as T, b as ne } from "./quantity-stepper-B8kX8GbN.js";
3
3
  function x(n) {
4
4
  const e = n.headers.get("Content-Type") ?? "";
@@ -7,12 +7,12 @@ function x(n) {
7
7
  async function re(n, e) {
8
8
  const t = [], r = {
9
9
  onEvent: (i) => {
10
- const s = R(i);
11
- if (!(!s || s.type !== "ui_spec")) {
12
- for (const a of Object.values(s.spec.elements))
13
- if (a.type === "ProductCard" && a.props) {
14
- const l = a.props.product ?? a.props;
15
- typeof l.sku == "string" && typeof l.name == "string" && t.push(l);
10
+ const o = R(i);
11
+ if (!(!o || o.type !== "ui_spec")) {
12
+ for (const s of Object.values(o.spec.elements))
13
+ if (s.type === "ProductCard" && s.props) {
14
+ const u = s.props.product ?? s.props;
15
+ typeof u.sku == "string" && typeof u.name == "string" && t.push(u);
16
16
  }
17
17
  }
18
18
  }
@@ -20,21 +20,21 @@ async function re(n, e) {
20
20
  return e !== void 0 && (r.signal = e), await I(n, r), t;
21
21
  }
22
22
  async function ie(n, e, t) {
23
- const r = P("similar_products", e), i = {
23
+ const r = A("similar_products", e), i = {
24
24
  method: "POST",
25
25
  headers: { "Content-Type": "application/json" },
26
26
  body: JSON.stringify(n)
27
27
  };
28
28
  t !== void 0 && (i.signal = t);
29
- const s = await fetch(r, i);
30
- if (!s.ok)
31
- throw new Error(`HTTP ${s.status}: ${s.statusText}`);
32
- if (x(s))
33
- return re(s, t);
34
- const a = await s.text();
35
- if (!a) return [];
29
+ const o = await fetch(r, i);
30
+ if (!o.ok)
31
+ throw new Error(`HTTP ${o.status}: ${o.statusText}`);
32
+ if (x(o))
33
+ return re(o, t);
34
+ const s = await o.text();
35
+ if (!s) return [];
36
36
  try {
37
- return j(JSON.parse(a));
37
+ return D(JSON.parse(s));
38
38
  } catch {
39
39
  throw new Error("Invalid JSON from similar_products endpoint");
40
40
  }
@@ -43,21 +43,21 @@ async function oe(n, e) {
43
43
  const t = [];
44
44
  let r = null;
45
45
  const i = {
46
- onEvent: (s) => {
47
- const a = R(s);
48
- if (a) {
49
- if (a.type === "metadata" && a.meta) {
50
- const l = a.meta.group_name;
51
- if (typeof l == "string") {
52
- r = { name: l, products: [] };
53
- const d = a.meta.highlight;
46
+ onEvent: (o) => {
47
+ const s = R(o);
48
+ if (s) {
49
+ if (s.type === "metadata" && s.meta) {
50
+ const u = s.meta.group_name;
51
+ if (typeof u == "string") {
52
+ r = { name: u, products: [] };
53
+ const d = s.meta.highlight;
54
54
  typeof d == "string" && (r.highlight = d), t.push(r);
55
55
  }
56
56
  }
57
- if (a.type === "ui_spec" && r) {
58
- for (const l of Object.values(a.spec.elements))
59
- if (l.type === "ProductCard" && l.props) {
60
- const d = l.props.product ?? l.props;
57
+ if (s.type === "ui_spec" && r) {
58
+ for (const u of Object.values(s.spec.elements))
59
+ if (u.type === "ProductCard" && u.props) {
60
+ const d = u.props.product ?? u.props;
61
61
  typeof d.sku == "string" && typeof d.name == "string" && r.products.push(d);
62
62
  }
63
63
  }
@@ -67,81 +67,85 @@ async function oe(n, e) {
67
67
  return e !== void 0 && (i.signal = e), await I(n, i), t;
68
68
  }
69
69
  async function se(n, e, t) {
70
- const r = P("product_groupings", e), i = {
70
+ const r = A("product_groupings", e), i = {
71
71
  method: "POST",
72
72
  headers: { "Content-Type": "application/json" },
73
73
  body: JSON.stringify(n)
74
74
  };
75
75
  t !== void 0 && (i.signal = t);
76
- const s = await fetch(r, i);
77
- if (!s.ok)
78
- throw new Error(`HTTP ${s.status}: ${s.statusText}`);
79
- if (x(s))
80
- return oe(s, t);
81
- const a = await s.text();
82
- if (!a) return [];
76
+ const o = await fetch(r, i);
77
+ if (!o.ok)
78
+ throw new Error(`HTTP ${o.status}: ${o.statusText}`);
79
+ if (x(o))
80
+ return oe(o, t);
81
+ const s = await o.text();
82
+ if (!s) return [];
83
83
  try {
84
- return D(JSON.parse(a));
84
+ return j(JSON.parse(s));
85
85
  } catch {
86
86
  throw new Error("Invalid JSON from product_groupings endpoint");
87
87
  }
88
88
  }
89
89
  function U(n) {
90
- const { product: e, index: t, discountType: r, onClick: i, onAddToCart: s, renderCard: a } = n, l = n.i18n, d = n.pricing;
91
- if (a) {
92
- const o = document.createElement("div");
93
- return o.className = "gengage-simrel-card gengage-simrel-card--custom", o.innerHTML = K(a(e, t)), o.addEventListener("click", (p) => {
94
- p.target.closest(".gengage-simrel-atc") || i(e);
95
- }), o;
96
- }
97
- const u = document.createElement("article");
98
- u.className = "gengage-simrel-card", u.setAttribute("role", "listitem"), u.dataset.sku = e.sku;
90
+ const { product: e, index: t, discountType: r, onClick: i, onAddToCart: o, renderCard: s } = n, u = n.i18n, d = n.pricing;
91
+ if (s) {
92
+ const a = document.createElement("div");
93
+ return a.className = "gengage-simrel-card gengage-simrel-card--custom", a.innerHTML = K(s(e, t)), a.addEventListener("click", (m) => {
94
+ m.target.closest(".gengage-simrel-atc") || m.target.closest(".gengage-chat-product-card-atc") || i(e);
95
+ }), a;
96
+ }
97
+ const g = document.createElement("article");
98
+ g.className = "gengage-simrel-card gengage-chat-product-card", g.setAttribute("role", "listitem"), g.dataset.sku = e.sku;
99
99
  const c = document.createElement("div");
100
- if (c.className = "gengage-simrel-card-image", e.imageUrl && X(e.imageUrl)) {
101
- const o = document.createElement("img");
102
- o.src = e.imageUrl, o.alt = e.name, o.loading = "lazy", Z(o), c.appendChild(o);
100
+ if (c.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", e.imageUrl && X(e.imageUrl)) {
101
+ const a = document.createElement("img");
102
+ a.className = "gengage-chat-product-card-img", a.src = e.imageUrl, a.alt = e.name, a.loading = "lazy", Z(a), c.appendChild(a);
103
103
  }
104
104
  if (r === "badge" && e.discountPercent && e.discountPercent > 0) {
105
- const o = document.createElement("span");
106
- o.className = "gengage-simrel-badge", o.textContent = `%${ee(e.discountPercent)}`, c.appendChild(o);
105
+ const a = document.createElement("span");
106
+ a.className = "gengage-simrel-badge gengage-chat-product-card-discount-badge", a.textContent = `%${ee(e.discountPercent)}`, c.appendChild(a);
107
107
  }
108
- u.appendChild(c);
109
- const g = document.createElement("div");
110
- if (g.className = "gengage-simrel-card-info", e.brand) {
111
- const o = document.createElement("div");
112
- o.className = "gengage-simrel-card-brand", o.textContent = e.brand, g.appendChild(o);
108
+ g.appendChild(c);
109
+ const p = document.createElement("div");
110
+ if (p.className = "gengage-simrel-card-info gengage-chat-product-card-body", e.brand) {
111
+ const a = document.createElement("div");
112
+ a.className = "gengage-simrel-card-brand gengage-chat-product-card-brand", a.textContent = e.brand, p.appendChild(a);
113
113
  }
114
114
  const f = document.createElement("div");
115
- if (f.className = "gengage-simrel-card-name", f.textContent = e.name, g.appendChild(f), e.rating != null && e.rating > 0) {
116
- const o = document.createElement("div");
117
- if (o.className = "gengage-simrel-card-rating", o.textContent = te(e.rating), e.reviewCount != null) {
118
- const p = document.createElement("span");
119
- p.className = "gengage-simrel-card-review-count", p.textContent = ` (${e.reviewCount})`, o.appendChild(p);
115
+ if (f.className = "gengage-simrel-card-name gengage-chat-product-card-name", f.textContent = e.name, p.appendChild(f), e.rating != null && e.rating > 0) {
116
+ const a = document.createElement("div");
117
+ if (a.className = "gengage-simrel-card-rating gengage-chat-product-card-rating", a.textContent = te(e.rating), e.reviewCount != null) {
118
+ const m = document.createElement("span");
119
+ m.className = "gengage-simrel-card-review-count gengage-chat-product-card-review-count", m.textContent = ` (${e.reviewCount})`, a.appendChild(m);
120
120
  }
121
- g.appendChild(o);
121
+ p.appendChild(a);
122
122
  }
123
- const h = document.createElement("div");
124
- if (h.className = "gengage-simrel-card-price", e.originalPrice && e.originalPrice !== e.price && (r === "strike-through" || !r)) {
125
- const o = document.createElement("span");
126
- o.className = "gengage-simrel-card-price-original", o.textContent = T(e.originalPrice, d), h.appendChild(o);
123
+ const y = document.createElement("div");
124
+ if (y.className = "gengage-simrel-card-price gengage-chat-product-card-price", e.originalPrice && e.originalPrice !== e.price && (r === "strike-through" || !r)) {
125
+ const a = document.createElement("span");
126
+ a.className = "gengage-simrel-card-price-original gengage-chat-product-card-original-price", a.textContent = T(e.originalPrice, d), y.appendChild(a);
127
127
  }
128
128
  if (e.price) {
129
- const o = document.createElement("span");
130
- o.className = "gengage-simrel-card-price-current", o.textContent = T(e.price, d), h.appendChild(o);
131
- }
132
- if (g.appendChild(h), u.appendChild(g), e.cartCode) {
133
- const o = e.cartCode, p = ne({
134
- compact: !1,
135
- label: l?.addToCartButton ?? "Sepete Ekle",
136
- onSubmit: (y) => {
137
- s({ sku: e.sku, quantity: y, cartCode: o });
129
+ const a = document.createElement("span");
130
+ a.className = "gengage-simrel-card-price-current gengage-chat-product-card-price-current", a.textContent = T(e.price, d), y.appendChild(a);
131
+ }
132
+ p.appendChild(y), g.appendChild(p);
133
+ const l = document.createElement("button");
134
+ if (l.className = "gengage-simrel-card-cta gengage-chat-product-card-cta", l.type = "button", l.textContent = "İncele", l.addEventListener("click", (a) => {
135
+ a.preventDefault(), a.stopPropagation(), i(e);
136
+ }), g.appendChild(l), e.cartCode && e.inStock !== !1) {
137
+ const a = e.cartCode, m = ne({
138
+ compact: !0,
139
+ label: u?.addToCartButton ?? "Sepete Ekle",
140
+ onSubmit: (C) => {
141
+ o({ sku: e.sku, quantity: C, cartCode: a });
138
142
  }
139
143
  });
140
- p.classList.add("gengage-simrel-atc"), u.appendChild(p);
144
+ m.classList.add("gengage-simrel-atc", "gengage-chat-product-card-atc"), g.appendChild(m);
141
145
  }
142
- return u.addEventListener("click", (o) => {
143
- o.target.closest(".gengage-simrel-atc") || i(e);
144
- }), u;
146
+ return g.addEventListener("click", (a) => {
147
+ a.target.closest(".gengage-simrel-atc") || a.target.closest(".gengage-chat-product-card-atc") || a.target.closest(".gengage-chat-product-card-cta") || i(e);
148
+ }), g;
145
149
  }
146
150
  function w(n) {
147
151
  const e = document.createElement("div");
@@ -154,8 +158,8 @@ function w(n) {
154
158
  onAddToCart: n.onAddToCart
155
159
  };
156
160
  n.i18n !== void 0 && (i.i18n = n.i18n), n.discountType !== void 0 && (i.discountType = n.discountType), n.renderCard !== void 0 && (i.renderCard = n.renderCard);
157
- const s = U(i);
158
- e.appendChild(s);
161
+ const o = U(i);
162
+ e.appendChild(o);
159
163
  }
160
164
  if (n.products.length === 0) {
161
165
  const t = document.createElement("div");
@@ -172,43 +176,43 @@ function ce(n) {
172
176
  }
173
177
  const r = document.createElement("div");
174
178
  r.className = "gengage-simrel-tabs", r.setAttribute("role", "tablist");
175
- const i = [], s = [], a = (c) => {
176
- const g = {
179
+ const i = [], o = [], s = (c) => {
180
+ const p = {
177
181
  products: c.products,
178
182
  onClick: n.onClick,
179
183
  onAddToCart: n.onAddToCart
180
184
  };
181
- return n.i18n !== void 0 && (g.i18n = n.i18n), n.discountType !== void 0 && (g.discountType = n.discountType), n.renderCard !== void 0 && (g.renderCard = n.renderCard), g;
182
- }, l = (c) => {
183
- for (let o = 0; o < i.length; o++) {
184
- const p = o === c;
185
- i[o].classList.toggle("gengage-simrel-tab--active", p), i[o].setAttribute("aria-selected", String(p)), i[o].tabIndex = p ? 0 : -1;
185
+ return n.i18n !== void 0 && (p.i18n = n.i18n), n.discountType !== void 0 && (p.discountType = n.discountType), n.renderCard !== void 0 && (p.renderCard = n.renderCard), p;
186
+ }, u = (c) => {
187
+ for (let l = 0; l < i.length; l++) {
188
+ const a = l === c;
189
+ i[l].classList.toggle("gengage-simrel-tab--active", a), i[l].setAttribute("aria-selected", String(a)), i[l].tabIndex = a ? 0 : -1;
186
190
  }
187
- const g = n.groups[c], f = s[c];
191
+ const p = n.groups[c], f = o[c];
188
192
  f.innerHTML = "";
189
- const h = w(a(g));
190
- f.appendChild(h);
191
- for (let o = 0; o < s.length; o++) {
192
- const p = o === c;
193
- s[o].style.display = p ? "" : "none", s[o].tabIndex = p ? 0 : -1;
193
+ const y = w(s(p));
194
+ f.appendChild(y);
195
+ for (let l = 0; l < o.length; l++) {
196
+ const a = l === c;
197
+ o[l].style.display = a ? "" : "none", o[l].tabIndex = a ? 0 : -1;
194
198
  }
195
199
  };
196
200
  for (let c = 0; c < n.groups.length; c++) {
197
- const g = n.groups[c], f = `gengage-simrel-tab-${e}-${c}`, h = `gengage-simrel-panel-${e}-${c}`, o = document.createElement("button");
198
- o.className = "gengage-simrel-tab", o.type = "button", o.id = f, o.textContent = g.name, o.setAttribute("role", "tab"), o.setAttribute("aria-controls", h), o.setAttribute("aria-selected", String(c === 0)), o.tabIndex = c === 0 ? 0 : -1, c === 0 && o.classList.add("gengage-simrel-tab--active"), o.addEventListener("click", () => l(c)), o.addEventListener("keydown", (y) => {
199
- let b = -1;
200
- y.key === "ArrowRight" || y.key === "ArrowDown" ? b = (c + 1) % n.groups.length : y.key === "ArrowLeft" || y.key === "ArrowUp" ? b = (c - 1 + n.groups.length) % n.groups.length : y.key === "Home" ? b = 0 : y.key === "End" && (b = n.groups.length - 1), b >= 0 && (y.preventDefault(), l(b), i[b].focus());
201
- }), i.push(o), r.appendChild(o);
202
- const p = document.createElement("div");
203
- p.className = "gengage-simrel-tab-panel", p.id = h, p.setAttribute("role", "tabpanel"), p.setAttribute("aria-labelledby", f), p.tabIndex = c === 0 ? 0 : -1, c !== 0 && (p.style.display = "none"), s.push(p);
201
+ const p = n.groups[c], f = `gengage-simrel-tab-${e}-${c}`, y = `gengage-simrel-panel-${e}-${c}`, l = document.createElement("button");
202
+ l.className = "gengage-simrel-tab", l.type = "button", l.id = f, l.textContent = p.name, l.setAttribute("role", "tab"), l.setAttribute("aria-controls", y), l.setAttribute("aria-selected", String(c === 0)), l.tabIndex = c === 0 ? 0 : -1, c === 0 && l.classList.add("gengage-simrel-tab--active"), l.addEventListener("click", () => u(c)), l.addEventListener("keydown", (m) => {
203
+ let C = -1;
204
+ m.key === "ArrowRight" || m.key === "ArrowDown" ? C = (c + 1) % n.groups.length : m.key === "ArrowLeft" || m.key === "ArrowUp" ? C = (c - 1 + n.groups.length) % n.groups.length : m.key === "Home" ? C = 0 : m.key === "End" && (C = n.groups.length - 1), C >= 0 && (m.preventDefault(), u(C), i[C].focus());
205
+ }), i.push(l), r.appendChild(l);
206
+ const a = document.createElement("div");
207
+ a.className = "gengage-simrel-tab-panel", a.id = y, a.setAttribute("role", "tabpanel"), a.setAttribute("aria-labelledby", f), a.tabIndex = c === 0 ? 0 : -1, c !== 0 && (a.style.display = "none"), o.push(a);
204
208
  }
205
209
  t.appendChild(r);
206
- const d = s[0], u = w(a(n.groups[0]));
207
- d.appendChild(u);
208
- for (const c of s) t.appendChild(c);
210
+ const d = o[0], g = w(s(n.groups[0]));
211
+ d.appendChild(g);
212
+ for (const c of o) t.appendChild(c);
209
213
  return t;
210
214
  }
211
- function A(n) {
215
+ function P(n) {
212
216
  if (!n || typeof n != "object") return null;
213
217
  const e = n;
214
218
  if (typeof e.sku != "string" || typeof e.name != "string" || typeof e.url != "string")
@@ -221,20 +225,20 @@ function A(n) {
221
225
  typeof r == "string" && (t.imageUrl = r);
222
226
  const i = e.price;
223
227
  typeof i == "string" && (t.price = i);
224
- const s = e.originalPrice;
225
- typeof s == "string" && (t.originalPrice = s);
226
- const a = e.discountPercent;
227
- typeof a == "number" && (t.discountPercent = a);
228
- const l = e.brand;
229
- typeof l == "string" && (t.brand = l);
228
+ const o = e.originalPrice;
229
+ typeof o == "string" && (t.originalPrice = o);
230
+ const s = e.discountPercent;
231
+ typeof s == "number" && (t.discountPercent = s);
232
+ const u = e.brand;
233
+ typeof u == "string" && (t.brand = u);
230
234
  const d = e.rating;
231
235
  typeof d == "number" && (t.rating = d);
232
- const u = e.reviewCount;
233
- typeof u == "number" && (t.reviewCount = u);
236
+ const g = e.reviewCount;
237
+ typeof g == "number" && (t.reviewCount = g);
234
238
  const c = e.cartCode;
235
239
  typeof c == "string" && (t.cartCode = c);
236
- const g = e.inStock;
237
- return typeof g == "boolean" && (t.inStock = g), t;
240
+ const p = e.inStock;
241
+ return typeof p == "boolean" && (t.inStock = p), t;
238
242
  }
239
243
  function de(n) {
240
244
  if (!n || typeof n != "object") return null;
@@ -249,47 +253,47 @@ const L = {
249
253
  r.className = "gengage-simrel-grid", r.setAttribute("role", "list");
250
254
  const i = n.props?.columns;
251
255
  typeof i == "number" && Number.isFinite(i) && i > 0 && r.style.setProperty("--gengage-simrel-columns", String(i));
252
- for (const s of n.children ?? []) {
253
- const a = e(s);
254
- a && r.appendChild(a);
256
+ for (const o of n.children ?? []) {
257
+ const s = e(o);
258
+ s && r.appendChild(s);
255
259
  }
256
260
  if (r.children.length === 0) {
257
- const s = document.createElement("div");
258
- s.className = "gengage-simrel-empty", s.textContent = t.i18n.emptyStateMessage, r.appendChild(s);
261
+ const o = document.createElement("div");
262
+ o.className = "gengage-simrel-empty", o.textContent = t.i18n.emptyStateMessage, r.appendChild(o);
259
263
  }
260
264
  return r;
261
265
  },
262
266
  ProductCard: ({ element: n, context: e }) => {
263
- const t = n.props?.product ?? n.props, r = A(t);
267
+ const t = n.props?.product ?? n.props, r = P(t);
264
268
  if (!r) return null;
265
- const i = n.props?.index, s = typeof i == "number" && Number.isFinite(i) ? i : 0, a = n.props?.discountType, l = a === "strike-through" || a === "badge" ? a : e.discountType, d = {
269
+ const i = n.props?.index, o = typeof i == "number" && Number.isFinite(i) ? i : 0, s = n.props?.discountType, u = s === "strike-through" || s === "badge" ? s : e.discountType, d = {
266
270
  product: r,
267
- index: s,
271
+ index: o,
268
272
  onClick: e.onClick,
269
273
  onAddToCart: e.onAddToCart,
270
274
  i18n: e.i18n
271
275
  };
272
- return l !== void 0 && (d.discountType = l), e.renderCard !== void 0 && (d.renderCard = e.renderCard), e.pricing !== void 0 && (d.pricing = e.pricing), U(d);
276
+ return u !== void 0 && (d.discountType = u), e.renderCard !== void 0 && (d.renderCard = e.renderCard), e.pricing !== void 0 && (d.pricing = e.pricing), U(d);
273
277
  },
274
278
  GroupTabs: ({ element: n, context: e }) => {
275
279
  const t = n.props?.groups;
276
280
  if (!Array.isArray(t)) return null;
277
281
  const r = [];
278
- for (const s of t) {
279
- if (!s || typeof s != "object") continue;
280
- const a = s;
281
- if (typeof a.name != "string") continue;
282
- const l = [];
283
- if (Array.isArray(a.products))
284
- for (const u of a.products) {
285
- const c = A(u);
286
- c && l.push(c);
282
+ for (const o of t) {
283
+ if (!o || typeof o != "object") continue;
284
+ const s = o;
285
+ if (typeof s.name != "string") continue;
286
+ const u = [];
287
+ if (Array.isArray(s.products))
288
+ for (const g of s.products) {
289
+ const c = P(g);
290
+ c && u.push(c);
287
291
  }
288
292
  const d = {
289
- name: a.name,
290
- products: l
293
+ name: s.name,
294
+ products: u
291
295
  };
292
- typeof a.highlight == "string" && (d.highlight = a.highlight), r.push(d);
296
+ typeof s.highlight == "string" && (d.highlight = s.highlight), r.push(d);
293
297
  }
294
298
  const i = {
295
299
  groups: r,
@@ -309,10 +313,10 @@ const L = {
309
313
  const t = n.props?.sku, r = n.props?.cartCode;
310
314
  if (typeof t != "string" || typeof r != "string") return null;
311
315
  const i = document.createElement("button");
312
- i.className = "gengage-simrel-atc", i.type = "button";
313
- const s = n.props?.label;
314
- return i.textContent = typeof s == "string" ? s : e.i18n.addToCartButton, i.addEventListener("click", (a) => {
315
- a.preventDefault(), a.stopPropagation(), e.onAddToCart({ sku: t, quantity: 1, cartCode: r });
316
+ i.className = "gengage-simrel-atc gengage-chat-product-card-cta", i.type = "button";
317
+ const o = n.props?.label;
318
+ return i.textContent = typeof o == "string" ? o : e.i18n.addToCartButton, i.addEventListener("click", (s) => {
319
+ s.preventDefault(), s.stopPropagation(), e.onAddToCart({ sku: t, quantity: 1, cartCode: r });
316
320
  }), i;
317
321
  },
318
322
  QuickActions: ({ element: n, context: e }) => {
@@ -322,11 +326,11 @@ const L = {
322
326
  if (!Array.isArray(r) || !e.onAction) return t;
323
327
  for (const i of r) {
324
328
  if (!i || typeof i != "object") continue;
325
- const s = i, a = s.label, l = de(s.action);
326
- if (typeof a != "string" || !l) continue;
329
+ const o = i, s = o.label, u = de(o.action);
330
+ if (typeof s != "string" || !u) continue;
327
331
  const d = document.createElement("button");
328
- d.className = "gengage-simrel-quick-action", d.type = "button", d.textContent = a, d.addEventListener("click", (u) => {
329
- u.preventDefault(), u.stopPropagation(), e.onAction?.(l);
332
+ d.className = "gengage-simrel-quick-action", d.type = "button", d.textContent = s, d.addEventListener("click", (g) => {
333
+ g.preventDefault(), g.stopPropagation(), e.onAction?.(u);
330
334
  }), t.appendChild(d);
331
335
  }
332
336
  return t;
@@ -361,57 +365,57 @@ const O = {
361
365
  emptyStateMessage: "Benzer ürün bulunamadı.",
362
366
  addToCartButton: "Sepete Ekle",
363
367
  priceSuffix: " TL"
364
- }, pe = {
368
+ }, ge = {
365
369
  similarProductsAriaLabel: "Similar products",
366
370
  emptyStateMessage: "No similar products found.",
367
371
  addToCartButton: "Add to cart",
368
372
  priceSuffix: ""
369
373
  };
370
- function ge(n) {
374
+ function pe(n) {
371
375
  return n ? n.toLowerCase().split("-")[0] ?? "tr" : "tr";
372
376
  }
373
377
  function me(n) {
374
- return ge(n) === "en" ? pe : O;
378
+ return pe(n) === "en" ? ge : O;
375
379
  }
376
- const fe = C({
377
- sku: m(),
378
- name: m(),
379
- imageUrl: m().url().optional(),
380
- price: m().optional(),
381
- originalPrice: m().optional(),
382
- discountPercent: _().optional(),
383
- url: m().url(),
384
- brand: m().optional(),
385
- rating: _().min(0).max(5).optional(),
386
- reviewCount: _().int().nonnegative().optional()
387
- }), he = C({
380
+ const he = b({
381
+ sku: h(),
382
+ name: h(),
383
+ imageUrl: h().url().optional(),
384
+ price: h().optional(),
385
+ originalPrice: h().optional(),
386
+ discountPercent: v().optional(),
387
+ url: h().url(),
388
+ brand: h().optional(),
389
+ rating: v().min(0).max(5).optional(),
390
+ reviewCount: v().int().nonnegative().optional()
391
+ }), fe = b({
388
392
  layout: N(["grid", "carousel"]).optional(),
389
- columns: _().int().positive().optional()
390
- }), ye = C({
391
- product: fe,
392
- index: _().int().nonnegative(),
393
+ columns: v().int().positive().optional()
394
+ }), ye = b({
395
+ product: he,
396
+ index: v().int().nonnegative(),
393
397
  discountType: N(["strike-through", "badge"]).optional()
394
- }), Ce = C({
395
- sku: m(),
396
- label: m().optional(),
397
- cartCode: m()
398
- }), be = C({
398
+ }), Ce = b({
399
+ sku: h(),
400
+ label: h().optional(),
401
+ cartCode: h()
402
+ }), be = b({
399
403
  actions: q(
400
- C({
401
- label: m(),
402
- action: C({
403
- title: m(),
404
- type: m(),
404
+ b({
405
+ label: h(),
406
+ action: b({
407
+ title: h(),
408
+ type: h(),
405
409
  payload: B().optional()
406
410
  })
407
411
  })
408
412
  )
409
- }), _e = C({
410
- message: m().optional()
413
+ }), ve = b({
414
+ message: h().optional()
411
415
  }), Se = {
412
416
  components: {
413
417
  ProductGrid: {
414
- schema: he,
418
+ schema: fe,
415
419
  description: "Outer grid or carousel container for similar products."
416
420
  },
417
421
  ProductCard: {
@@ -427,12 +431,12 @@ const fe = C({
427
431
  description: "A row of quick-action buttons below product info."
428
432
  },
429
433
  EmptyState: {
430
- schema: _e,
434
+ schema: ve,
431
435
  description: "Empty state shown when no similar products are available."
432
436
  }
433
437
  }
434
438
  };
435
- class ve extends H {
439
+ class _e extends H {
436
440
  constructor() {
437
441
  super(...arguments), this._abortController = null, this._contentEl = null, this._i18n = O;
438
442
  }
@@ -465,14 +469,14 @@ class ve extends H {
465
469
  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;
466
470
  $(e.sku, e.name);
467
471
  const r = this.config.session?.sessionId ?? null;
468
- v("gengage:similar:product-click", {
472
+ _("gengage:similar:product-click", {
469
473
  sku: e.sku,
470
474
  url: e.url,
471
475
  sessionId: r
472
476
  }), this.config.onProductNavigate?.(e.url, e.sku, r);
473
477
  }
474
478
  _handleAddToCart(e) {
475
- F(e.sku, e.quantity), this.config.onAddToCart?.(e), v("gengage:similar:add-to-cart", e), this.track(
479
+ F(e.sku, e.quantity), this.config.onAddToCart?.(e), _("gengage:similar:add-to-cart", e), this.track(
476
480
  J(this.analyticsContext(), {
477
481
  attribution_source: "simrel",
478
482
  attribution_action_id: crypto.randomUUID(),
@@ -499,13 +503,13 @@ class ve extends H {
499
503
  r.className = "gengage-simrel-loading";
500
504
  const i = document.createElement("div");
501
505
  i.className = "gengage-simrel-spinner", r.appendChild(i), this._contentEl.appendChild(r);
502
- const s = {
506
+ const o = {
503
507
  middlewareUrl: this.config.middlewareUrl
504
- }, a = crypto.randomUUID(), l = Date.now();
508
+ }, s = crypto.randomUUID(), u = Date.now();
505
509
  this.track(
506
510
  Q(this.analyticsContext(), {
507
511
  endpoint: "similar_products",
508
- request_id: a,
512
+ request_id: s,
509
513
  widget: "simrel"
510
514
  })
511
515
  );
@@ -517,33 +521,33 @@ class ve extends H {
517
521
  sku: e
518
522
  };
519
523
  this.config.domain !== void 0 && (d.domain = this.config.domain);
520
- const u = await ie(d, s, t);
524
+ const g = await ie(d, o, t);
521
525
  if (!this._contentEl) return;
522
- if (this._contentEl.innerHTML = "", u.length > 0)
526
+ if (this._contentEl.innerHTML = "", g.length > 0)
523
527
  try {
524
- const c = u.map((f) => f.sku), g = await se(
528
+ const c = g.map((f) => f.sku), p = await se(
525
529
  {
526
530
  account_id: this.config.accountId,
527
531
  session_id: this.config.session?.sessionId ?? "",
528
532
  correlation_id: this.config.session?.sessionId ?? "",
529
533
  skus: c
530
534
  },
531
- s,
535
+ o,
532
536
  t
533
537
  );
534
- if (g.length > 0 && this._contentEl) {
535
- const f = this._buildGroupsSpec(g), h = this._renderUISpec(f);
536
- this._contentEl.appendChild(h), E("simrel"), this.track(
538
+ if (p.length > 0 && this._contentEl) {
539
+ const f = this._buildGroupsSpec(p), y = this._renderUISpec(f);
540
+ this._contentEl.appendChild(y), E("simrel"), this.track(
537
541
  k(this.analyticsContext(), {
538
- request_id: a,
539
- latency_ms: Date.now() - l,
540
- chunk_count: g.reduce((o, p) => o + p.products.length, 0),
542
+ request_id: s,
543
+ latency_ms: Date.now() - u,
544
+ chunk_count: p.reduce((l, a) => l + a.products.length, 0),
541
545
  widget: "simrel"
542
546
  })
543
547
  ), this.track(
544
548
  S(this.analyticsContext(), {
545
- message_count: g.reduce((o, p) => o + p.products.length, 0),
546
- history_ref: a,
549
+ message_count: p.reduce((l, a) => l + a.products.length, 0),
550
+ history_ref: s,
547
551
  redaction_level: "none",
548
552
  widget: "simrel"
549
553
  })
@@ -553,33 +557,33 @@ class ve extends H {
553
557
  } catch {
554
558
  }
555
559
  if (this._contentEl) {
556
- const c = this._buildProductsSpec(u), g = this._renderUISpec(c);
557
- this._contentEl.appendChild(g);
560
+ const c = this._buildProductsSpec(g), p = this._renderUISpec(c);
561
+ this._contentEl.appendChild(p);
558
562
  }
559
- u.length > 0 && E("simrel"), this.track(
563
+ g.length > 0 && E("simrel"), this.track(
560
564
  k(this.analyticsContext(), {
561
- request_id: a,
562
- latency_ms: Date.now() - l,
563
- chunk_count: u.length,
565
+ request_id: s,
566
+ latency_ms: Date.now() - u,
567
+ chunk_count: g.length,
564
568
  widget: "simrel"
565
569
  })
566
570
  ), this.track(
567
571
  S(this.analyticsContext(), {
568
- message_count: u.length,
569
- history_ref: a,
572
+ message_count: g.length,
573
+ history_ref: s,
570
574
  redaction_level: "none",
571
575
  widget: "simrel"
572
576
  })
573
577
  );
574
578
  } catch (d) {
575
579
  if (d instanceof DOMException && d.name === "AbortError") return;
576
- v("gengage:global:error", {
580
+ _("gengage:global:error", {
577
581
  source: "simrel",
578
582
  code: "FETCH_ERROR",
579
583
  message: W(this.config.locale)
580
584
  }), this.track(
581
585
  V(this.analyticsContext(), {
582
- request_id: a,
586
+ request_id: s,
583
587
  error_code: "FETCH_ERROR",
584
588
  error_message: d instanceof Error ? d.message : String(d),
585
589
  widget: "simrel"
@@ -603,21 +607,21 @@ class ve extends H {
603
607
  return this.config.discountType !== void 0 && (t.discountType = this.config.discountType), e !== void 0 && (t.renderCard = e), this.config.pricing !== void 0 && (t.pricing = this.config.pricing), t;
604
608
  }
605
609
  _renderUISpec(e) {
606
- const t = this._resolveUISpecRegistry(), r = this._buildRenderContext(), i = this.config.renderer?.unknownRenderer ?? G, s = (d, u) => ue(d, u, t, i), a = this.config.renderer?.renderUISpec;
607
- return a ? a(e, r, {
610
+ const t = this._resolveUISpecRegistry(), r = this._buildRenderContext(), i = this.config.renderer?.unknownRenderer ?? G, o = (d, g) => ue(d, g, t, i), s = this.config.renderer?.renderUISpec;
611
+ return s ? s(e, r, {
608
612
  registry: t,
609
613
  unknownRenderer: i,
610
- defaultRender: s
611
- }) : s(e, r);
614
+ defaultRender: o
615
+ }) : o(e, r);
612
616
  }
613
617
  _buildProductsSpec(e) {
614
618
  const t = {}, r = [];
615
619
  for (let i = 0; i < e.length; i++) {
616
- const s = e[i], a = `product-${i}`;
617
- r.push(a), t[a] = {
620
+ const o = e[i], s = `product-${i}`;
621
+ r.push(s), t[s] = {
618
622
  type: "ProductCard",
619
623
  props: {
620
- product: s,
624
+ product: o,
621
625
  index: i,
622
626
  discountType: this.config.discountType
623
627
  }
@@ -647,10 +651,10 @@ class ve extends H {
647
651
  }
648
652
  }
649
653
  function Te() {
650
- return new ve();
654
+ return new _e();
651
655
  }
652
656
  export {
653
- ve as GengageSimRel,
657
+ _e as GengageSimRel,
654
658
  le as createDefaultSimRelUISpecRegistry,
655
659
  Te as createSimRelWidget,
656
660
  G as defaultSimRelUnknownUISpecRenderer,