@gengage/assistant-fe 0.2.3 → 0.2.5

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 (98) hide show
  1. package/dist/assistant-fe.css +1 -1
  2. package/dist/chat/api.d.ts.map +1 -1
  3. package/dist/chat/catalog.d.ts +2 -0
  4. package/dist/chat/catalog.d.ts.map +1 -1
  5. package/dist/chat/components/ChatDrawer.d.ts +47 -2
  6. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  7. package/dist/chat/components/ChoicePrompter.d.ts +3 -1
  8. package/dist/chat/components/ChoicePrompter.d.ts.map +1 -1
  9. package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
  10. package/dist/chat/components/GroundingReviewCard.d.ts.map +1 -1
  11. package/dist/chat/components/PanelTopBar.d.ts +1 -0
  12. package/dist/chat/components/PanelTopBar.d.ts.map +1 -1
  13. package/dist/chat/components/ProductSummaryCard.d.ts.map +1 -1
  14. package/dist/chat/components/ReviewHighlights.d.ts.map +1 -1
  15. package/dist/chat/components/renderUISpec.d.ts.map +1 -1
  16. package/dist/chat/index.d.ts +22 -0
  17. package/dist/chat/index.d.ts.map +1 -1
  18. package/dist/chat/locales/en.d.ts.map +1 -1
  19. package/dist/chat/locales/tr.d.ts.map +1 -1
  20. package/dist/chat/panel-manager.d.ts +6 -4
  21. package/dist/chat/panel-manager.d.ts.map +1 -1
  22. package/dist/chat/session-persistence.d.ts +6 -1
  23. package/dist/chat/session-persistence.d.ts.map +1 -1
  24. package/dist/chat/types.d.ts +23 -1
  25. package/dist/chat/types.d.ts.map +1 -1
  26. package/dist/chat.cjs +1 -1
  27. package/dist/chat.iife.js +29 -29
  28. package/dist/chat.iife.js.map +1 -1
  29. package/dist/chat.js +2 -2
  30. package/dist/common/action-router.d.ts.map +1 -1
  31. package/dist/common/communication-bridge.d.ts.map +1 -1
  32. package/dist/common/ga-datalayer.d.ts.map +1 -1
  33. package/dist/common/price-formatter.d.ts +1 -1
  34. package/dist/common/price-formatter.d.ts.map +1 -1
  35. package/dist/common/product-utils.d.ts.map +1 -1
  36. package/dist/common/quantity-stepper.d.ts +1 -1
  37. package/dist/common/quantity-stepper.d.ts.map +1 -1
  38. package/dist/common/skeleton.d.ts +9 -0
  39. package/dist/common/skeleton.d.ts.map +1 -0
  40. package/dist/common/widget-base.d.ts.map +1 -1
  41. package/dist/common.cjs +1 -1
  42. package/dist/common.js +5 -5
  43. package/dist/{index-Bctbyou5.cjs → index-B6xRdkMq.cjs} +2 -2
  44. package/dist/{index-Bctbyou5.cjs.map → index-B6xRdkMq.cjs.map} +1 -1
  45. package/dist/{index-BaG-fiAK.js → index-BsvmfVa1.js} +3 -3
  46. package/dist/{index-BaG-fiAK.js.map → index-BsvmfVa1.js.map} +1 -1
  47. package/dist/index-BzCc2DCm.cjs +13 -0
  48. package/dist/index-BzCc2DCm.cjs.map +1 -0
  49. package/dist/index-D5UPIXIA.js +4831 -0
  50. package/dist/index-D5UPIXIA.js.map +1 -0
  51. package/dist/index.cjs +1 -1
  52. package/dist/index.js +3 -3
  53. package/dist/native.cjs +1 -1
  54. package/dist/native.iife.js +29 -29
  55. package/dist/native.iife.js.map +1 -1
  56. package/dist/native.js +1 -1
  57. package/dist/qna/index.d.ts.map +1 -1
  58. package/dist/qna.cjs +1 -1
  59. package/dist/qna.cjs.map +1 -1
  60. package/dist/qna.css +1 -1
  61. package/dist/qna.iife.js +14 -14
  62. package/dist/qna.iife.js.map +1 -1
  63. package/dist/qna.js +57 -48
  64. package/dist/qna.js.map +1 -1
  65. package/dist/quantity-stepper-CQWgexMO.cjs +2 -0
  66. package/dist/quantity-stepper-CQWgexMO.cjs.map +1 -0
  67. package/dist/quantity-stepper-CjY_cpgJ.js +80 -0
  68. package/dist/quantity-stepper-CjY_cpgJ.js.map +1 -0
  69. package/dist/{schemas-DOxyUYVA.cjs → schemas-CNzyBhf7.cjs} +8 -8
  70. package/dist/schemas-CNzyBhf7.cjs.map +1 -0
  71. package/dist/{schemas-D1Kd4wn8.js → schemas-Fiaobs4L.js} +306 -308
  72. package/dist/schemas-Fiaobs4L.js.map +1 -0
  73. package/dist/simrel/components/GroupTabs.d.ts.map +1 -1
  74. package/dist/simrel/components/ProductCard.d.ts.map +1 -1
  75. package/dist/simrel/components/ProductGrid.d.ts.map +1 -1
  76. package/dist/simrel/index.d.ts.map +1 -1
  77. package/dist/simrel/locales/en.d.ts.map +1 -1
  78. package/dist/simrel/locales/tr.d.ts.map +1 -1
  79. package/dist/simrel/types.d.ts +6 -0
  80. package/dist/simrel/types.d.ts.map +1 -1
  81. package/dist/simrel.cjs +1 -1
  82. package/dist/simrel.cjs.map +1 -1
  83. package/dist/simrel.css +1 -1
  84. package/dist/simrel.iife.js +11 -11
  85. package/dist/simrel.iife.js.map +1 -1
  86. package/dist/simrel.js +163 -158
  87. package/dist/simrel.js.map +1 -1
  88. package/package.json +1 -1
  89. package/dist/index-BHaQLt-o.js +0 -4468
  90. package/dist/index-BHaQLt-o.js.map +0 -1
  91. package/dist/index-CO5VnxEn.cjs +0 -13
  92. package/dist/index-CO5VnxEn.cjs.map +0 -1
  93. package/dist/quantity-stepper-BKtPQUR1.js +0 -78
  94. package/dist/quantity-stepper-BKtPQUR1.js.map +0 -1
  95. package/dist/quantity-stepper-DU6va4sS.cjs +0 -2
  96. package/dist/quantity-stepper-DU6va4sS.cjs.map +0 -1
  97. package/dist/schemas-D1Kd4wn8.js.map +0 -1
  98. package/dist/schemas-DOxyUYVA.cjs.map +0 -1
package/dist/simrel.js CHANGED
@@ -1,6 +1,6 @@
1
- import { b as P, p as j, q as M, c as N, a as I, v as B, x as q, r as z, o as b, s as h, f as H, e as $, _ as x, y as E, B as F, t as J, z as W, j as v, A as Q, C as V, g as Y, i as k, h as _, w as S, k as K, l as X, m as Z } from "./schemas-D1Kd4wn8.js";
2
- import { a as ee, c as te, b as ne, f as T, d as re } from "./quantity-stepper-BKtPQUR1.js";
3
- function R(n) {
1
+ import { b as P, p as B, q as j, c as I, a as R, v as M, x as q, r as H, o as b, s as h, f as z, e as $, _ as L, y as E, B as F, t as J, z as Q, j as v, A as W, C as Y, g as V, i as _, h as k, w as S, k as K, l as X, m as Z } from "./schemas-Fiaobs4L.js";
2
+ import { a as ee, c as te, b as ne, f as T, d as re } from "./quantity-stepper-CjY_cpgJ.js";
3
+ function N(n) {
4
4
  const e = [];
5
5
  for (const t of Object.values(n))
6
6
  if (t.type === "ProductCard" && t.props) {
@@ -9,18 +9,18 @@ function R(n) {
9
9
  }
10
10
  return e;
11
11
  }
12
- function L(n) {
12
+ function x(n) {
13
13
  const e = n.headers.get("Content-Type") ?? "";
14
14
  return e.includes("application/x-ndjson") || e.includes("text/event-stream");
15
15
  }
16
16
  async function ie(n, e) {
17
17
  const t = [], r = {
18
18
  onEvent: (i) => {
19
- const a = I(i);
20
- !a || a.type !== "ui_spec" || t.push(...R(a.spec.elements));
19
+ const a = R(i);
20
+ !a || a.type !== "ui_spec" || t.push(...N(a.spec.elements));
21
21
  }
22
22
  };
23
- return e !== void 0 && (r.signal = e), await N(n, r), t;
23
+ return e !== void 0 && (r.signal = e), await I(n, r), t;
24
24
  }
25
25
  async function oe(n, e, t) {
26
26
  const r = P("similar_products", e), i = {
@@ -32,12 +32,12 @@ async function oe(n, e, t) {
32
32
  const a = await fetch(r, i);
33
33
  if (!a.ok)
34
34
  throw new Error(`HTTP ${a.status}: ${a.statusText}`);
35
- if (L(a))
35
+ if (x(a))
36
36
  return ie(a, t);
37
37
  const s = await a.text();
38
38
  if (!s) return [];
39
39
  try {
40
- return j(JSON.parse(s));
40
+ return B(JSON.parse(s));
41
41
  } catch {
42
42
  throw new Error("Invalid JSON from similar_products endpoint");
43
43
  }
@@ -47,21 +47,21 @@ async function ae(n, e) {
47
47
  let r = null;
48
48
  const i = {
49
49
  onEvent: (a) => {
50
- const s = I(a);
50
+ const s = R(a);
51
51
  if (s) {
52
52
  if (s.type === "metadata" && s.meta) {
53
- const p = s.meta.group_name;
54
- if (typeof p == "string") {
55
- r = { name: p, products: [] };
56
- const d = s.meta.highlight;
57
- typeof d == "string" && (r.highlight = d), t.push(r);
53
+ const u = s.meta.group_name;
54
+ if (typeof u == "string") {
55
+ r = { name: u, products: [] };
56
+ const g = s.meta.highlight;
57
+ typeof g == "string" && (r.highlight = g), t.push(r);
58
58
  }
59
59
  }
60
- s.type === "ui_spec" && r && r.products.push(...R(s.spec.elements));
60
+ s.type === "ui_spec" && r && r.products.push(...N(s.spec.elements));
61
61
  }
62
62
  }
63
63
  };
64
- return e !== void 0 && (i.signal = e), await N(n, i), t;
64
+ return e !== void 0 && (i.signal = e), await I(n, i), t;
65
65
  }
66
66
  async function se(n, e, t) {
67
67
  const r = P("product_groupings", e), i = {
@@ -73,30 +73,30 @@ async function se(n, e, t) {
73
73
  const a = await fetch(r, i);
74
74
  if (!a.ok)
75
75
  throw new Error(`HTTP ${a.status}: ${a.statusText}`);
76
- if (L(a))
76
+ if (x(a))
77
77
  return ae(a, t);
78
78
  const s = await a.text();
79
79
  if (!s) return [];
80
80
  try {
81
- return M(JSON.parse(s));
81
+ return j(JSON.parse(s));
82
82
  } catch {
83
83
  throw new Error("Invalid JSON from product_groupings endpoint");
84
84
  }
85
85
  }
86
86
  function U(n) {
87
- const { product: e, index: t, discountType: r, onClick: i, onAddToCart: a, renderCard: s } = n, p = n.i18n, d = n.pricing;
87
+ const { product: e, index: t, discountType: r, onClick: i, onAddToCart: a, renderCard: s } = n, u = n.i18n, g = n.pricing;
88
88
  if (n.renderCardElement) {
89
89
  const o = n.renderCardElement(e, t);
90
90
  if (o) return o;
91
91
  }
92
92
  if (s) {
93
93
  const o = document.createElement("div");
94
- return o.className = "gengage-simrel-card gengage-simrel-card--custom", o.innerHTML = B(s(e, t)), o.addEventListener("click", (f) => {
94
+ return o.className = "gengage-simrel-card gengage-simrel-card--custom", o.innerHTML = M(s(e, t)), o.addEventListener("click", (f) => {
95
95
  f.target.closest(".gengage-simrel-atc") || f.target.closest(".gengage-chat-product-card-atc") || i(e);
96
96
  }), o;
97
97
  }
98
- const u = document.createElement("article");
99
- u.className = "gengage-simrel-card gengage-chat-product-card", u.setAttribute("role", "listitem"), u.dataset.sku = e.sku;
98
+ const l = document.createElement("article");
99
+ l.className = "gengage-simrel-card gengage-chat-product-card", e.inStock === !1 && l.classList.add("gengage-simrel-card--out-of-stock"), l.setAttribute("role", "listitem"), l.dataset.sku = e.sku;
100
100
  const c = document.createElement("div");
101
101
  if (c.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", e.imageUrl && q(e.imageUrl)) {
102
102
  const o = document.createElement("img");
@@ -106,50 +106,52 @@ function U(n) {
106
106
  const o = document.createElement("span");
107
107
  o.className = "gengage-simrel-badge gengage-chat-product-card-discount-badge", o.textContent = `%${te(e.discountPercent)}`, c.appendChild(o);
108
108
  }
109
- u.appendChild(c);
110
- const g = document.createElement("div");
111
- if (g.className = "gengage-simrel-card-info gengage-chat-product-card-body", e.brand) {
109
+ l.appendChild(c);
110
+ const p = document.createElement("div");
111
+ if (p.className = "gengage-simrel-card-info gengage-chat-product-card-body", e.brand) {
112
112
  const o = document.createElement("div");
113
- o.className = "gengage-simrel-card-brand gengage-chat-product-card-brand", o.textContent = e.brand, g.appendChild(o);
113
+ o.className = "gengage-simrel-card-brand gengage-chat-product-card-brand", o.textContent = e.brand, p.appendChild(o);
114
114
  }
115
115
  const m = document.createElement("div");
116
- if (m.className = "gengage-simrel-card-name gengage-chat-product-card-name", m.textContent = e.name, g.appendChild(m), e.rating != null && e.rating > 0) {
116
+ if (m.className = "gengage-simrel-card-name gengage-chat-product-card-name", m.textContent = e.name, m.title = e.name, p.appendChild(m), e.rating != null && e.rating > 0) {
117
117
  const o = document.createElement("div");
118
118
  if (o.className = "gengage-simrel-card-rating gengage-chat-product-card-rating", o.appendChild(ne(e.rating)), e.reviewCount != null) {
119
119
  const f = document.createElement("span");
120
120
  f.className = "gengage-simrel-card-review-count gengage-chat-product-card-review-count", f.textContent = ` (${e.reviewCount})`, o.appendChild(f);
121
121
  }
122
- g.appendChild(o);
122
+ p.appendChild(o);
123
123
  }
124
- const C = document.createElement("div");
125
- if (C.className = "gengage-simrel-card-price gengage-chat-product-card-price", e.originalPrice && e.originalPrice !== e.price && (r === "strike-through" || !r)) {
124
+ const y = document.createElement("div");
125
+ if (y.className = "gengage-simrel-card-price gengage-chat-product-card-price", e.originalPrice && e.originalPrice !== e.price && (r === "strike-through" || !r)) {
126
126
  const o = document.createElement("span");
127
- o.className = "gengage-simrel-card-price-original gengage-chat-product-card-original-price", o.textContent = T(e.originalPrice, d), C.appendChild(o);
127
+ o.className = "gengage-simrel-card-price-original gengage-chat-product-card-original-price", o.textContent = T(e.originalPrice, g), y.appendChild(o);
128
128
  }
129
- if (e.price) {
129
+ if (e.price && parseFloat(e.price) > 0) {
130
130
  const o = document.createElement("span");
131
- o.className = "gengage-simrel-card-price-current gengage-chat-product-card-price-current", o.textContent = T(e.price, d), C.appendChild(o);
131
+ o.className = "gengage-simrel-card-price-current gengage-chat-product-card-price-current", o.textContent = T(e.price, g), y.appendChild(o);
132
132
  }
133
- g.appendChild(C), u.appendChild(g);
134
- const l = document.createElement("button");
135
- if (l.className = "gengage-simrel-card-cta gengage-chat-product-card-cta", l.type = "button", l.textContent = p?.ctaLabel ?? "View", l.addEventListener("click", (o) => {
133
+ p.appendChild(y), l.appendChild(p);
134
+ const d = document.createElement("button");
135
+ if (d.className = "gengage-simrel-card-cta gengage-chat-product-card-cta", d.type = "button", d.textContent = u?.ctaLabel ?? "View", d.addEventListener("click", (o) => {
136
136
  o.preventDefault(), o.stopPropagation(), i(e);
137
- }), u.appendChild(l), e.inStock === !1) {
137
+ }), l.appendChild(d), e.inStock === !1) {
138
138
  const o = document.createElement("div");
139
- o.className = "gengage-simrel-card-oos", o.textContent = p?.outOfStockLabel ?? "Out of Stock", u.appendChild(o);
139
+ o.className = "gengage-simrel-card-oos", o.textContent = u?.outOfStockLabel ?? "Out of Stock", l.appendChild(o);
140
140
  } else if (e.cartCode) {
141
141
  const o = e.cartCode, f = re({
142
142
  compact: !0,
143
- label: p?.addToCartButton ?? "Add to Cart",
144
- onSubmit: (y) => {
145
- a({ sku: e.sku, quantity: y, cartCode: o });
143
+ label: u?.addToCartButton ?? "Add to Cart",
144
+ decreaseLabel: u?.decreaseLabel,
145
+ increaseLabel: u?.increaseLabel,
146
+ onSubmit: (C) => {
147
+ a({ sku: e.sku, quantity: C, cartCode: o });
146
148
  }
147
149
  });
148
- f.classList.add("gengage-simrel-atc"), u.appendChild(f);
150
+ f.classList.add("gengage-simrel-atc"), l.appendChild(f);
149
151
  }
150
- return u.addEventListener("click", (o) => {
152
+ return l.addEventListener("click", (o) => {
151
153
  o.target.closest(".gengage-simrel-atc") || o.target.closest(".gengage-chat-product-card-atc") || o.target.closest(".gengage-chat-product-card-cta") || i(e);
152
- }), u;
154
+ }), l;
153
155
  }
154
156
  function w(n) {
155
157
  const e = document.createElement("div");
@@ -165,54 +167,48 @@ function w(n) {
165
167
  const a = U(i);
166
168
  e.appendChild(a);
167
169
  }
168
- if (n.products.length === 0) {
169
- const t = document.createElement("div");
170
- t.className = "gengage-simrel-empty", t.textContent = n.i18n?.emptyStateMessage ?? "No similar products found.", e.appendChild(t);
171
- }
172
- return e;
170
+ return n.products.length === 0 && (e.style.display = "none", e.dataset.empty = "true"), e;
173
171
  }
174
172
  let ce = 0;
175
173
  function de(n) {
176
174
  const e = ce++, t = document.createElement("div");
177
- if (t.className = "gengage-simrel-groups", n.groups.length === 0) {
178
- const c = document.createElement("div");
179
- return c.className = "gengage-simrel-empty", c.textContent = n.i18n?.emptyStateMessage ?? "No similar products found.", t.appendChild(c), t;
180
- }
175
+ if (t.className = "gengage-simrel-groups", n.groups.length === 0)
176
+ return t.style.display = "none", t.dataset.empty = "true", t;
181
177
  const r = document.createElement("div");
182
178
  r.className = "gengage-simrel-tabs", r.setAttribute("role", "tablist");
183
179
  const i = [], a = [], s = (c) => {
184
- const g = {
180
+ const p = {
185
181
  products: c.products,
186
182
  onClick: n.onClick,
187
183
  onAddToCart: n.onAddToCart
188
184
  };
189
- 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), n.renderCardElement !== void 0 && (g.renderCardElement = n.renderCardElement), g;
190
- }, p = (c) => {
191
- for (let l = 0; l < i.length; l++) {
192
- const o = l === c;
193
- i[l].classList.toggle("gengage-simrel-tab--active", o), i[l].setAttribute("aria-selected", String(o)), i[l].tabIndex = o ? 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), n.renderCardElement !== void 0 && (p.renderCardElement = n.renderCardElement), p;
186
+ }, u = (c) => {
187
+ for (let d = 0; d < i.length; d++) {
188
+ const o = d === c;
189
+ i[d].classList.toggle("gengage-simrel-tab--active", o), i[d].setAttribute("aria-selected", String(o)), i[d].tabIndex = o ? 0 : -1;
194
190
  }
195
- const g = n.groups[c], m = a[c];
191
+ const p = n.groups[c], m = a[c];
196
192
  m.innerHTML = "";
197
- const C = w(s(g));
198
- m.appendChild(C);
199
- for (let l = 0; l < a.length; l++) {
200
- const o = l === c;
201
- a[l].style.display = o ? "" : "none", a[l].tabIndex = o ? 0 : -1;
193
+ const y = w(s(p));
194
+ m.appendChild(y);
195
+ for (let d = 0; d < a.length; d++) {
196
+ const o = d === c;
197
+ a[d].style.display = o ? "" : "none", a[d].tabIndex = o ? 0 : -1;
202
198
  }
203
199
  };
204
200
  for (let c = 0; c < n.groups.length; c++) {
205
- const g = n.groups[c], m = `gengage-simrel-tab-${e}-${c}`, C = `gengage-simrel-panel-${e}-${c}`, l = document.createElement("button");
206
- l.className = "gengage-simrel-tab", l.type = "button", l.id = m, l.textContent = g.name, l.setAttribute("role", "tab"), l.setAttribute("aria-controls", C), 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", () => p(c)), l.addEventListener("keydown", (f) => {
207
- let y = -1;
208
- f.key === "ArrowRight" || f.key === "ArrowDown" ? y = (c + 1) % n.groups.length : f.key === "ArrowLeft" || f.key === "ArrowUp" ? y = (c - 1 + n.groups.length) % n.groups.length : f.key === "Home" ? y = 0 : f.key === "End" && (y = n.groups.length - 1), y >= 0 && (f.preventDefault(), p(y), i[y].focus());
209
- }), i.push(l), r.appendChild(l);
201
+ const p = n.groups[c], m = `gengage-simrel-tab-${e}-${c}`, y = `gengage-simrel-panel-${e}-${c}`, d = document.createElement("button");
202
+ d.className = "gengage-simrel-tab", d.type = "button", d.id = m, d.textContent = p.name, d.setAttribute("role", "tab"), d.setAttribute("aria-controls", y), d.setAttribute("aria-selected", String(c === 0)), d.tabIndex = c === 0 ? 0 : -1, c === 0 && d.classList.add("gengage-simrel-tab--active"), d.addEventListener("click", () => u(c)), d.addEventListener("keydown", (f) => {
203
+ let C = -1;
204
+ f.key === "ArrowRight" || f.key === "ArrowDown" ? C = (c + 1) % n.groups.length : f.key === "ArrowLeft" || f.key === "ArrowUp" ? C = (c - 1 + n.groups.length) % n.groups.length : f.key === "Home" ? C = 0 : f.key === "End" && (C = n.groups.length - 1), C >= 0 && (f.preventDefault(), u(C), i[C].focus());
205
+ }), i.push(d), r.appendChild(d);
210
206
  const o = document.createElement("div");
211
- o.className = "gengage-simrel-tab-panel", o.id = C, o.setAttribute("role", "tabpanel"), o.setAttribute("aria-labelledby", m), o.tabIndex = c === 0 ? 0 : -1, c !== 0 && (o.style.display = "none"), a.push(o);
207
+ o.className = "gengage-simrel-tab-panel", o.id = y, o.setAttribute("role", "tabpanel"), o.setAttribute("aria-labelledby", m), o.tabIndex = c === 0 ? 0 : -1, c !== 0 && (o.style.display = "none"), a.push(o);
212
208
  }
213
209
  t.appendChild(r);
214
- const d = a[0], u = w(s(n.groups[0]));
215
- d.appendChild(u);
210
+ const g = a[0], l = w(s(n.groups[0]));
211
+ g.appendChild(l);
216
212
  for (const c of a) t.appendChild(c);
217
213
  return t;
218
214
  }
@@ -233,16 +229,16 @@ function A(n) {
233
229
  typeof a == "string" && (t.originalPrice = a);
234
230
  const s = e.discountPercent;
235
231
  typeof s == "number" && (t.discountPercent = s);
236
- const p = e.brand;
237
- typeof p == "string" && (t.brand = p);
238
- const d = e.rating;
239
- typeof d == "number" && (t.rating = d);
240
- const u = e.reviewCount;
241
- typeof u == "number" && (t.reviewCount = u);
232
+ const u = e.brand;
233
+ typeof u == "string" && (t.brand = u);
234
+ const g = e.rating;
235
+ typeof g == "number" && (t.rating = g);
236
+ const l = e.reviewCount;
237
+ typeof l == "number" && (t.reviewCount = l);
242
238
  const c = e.cartCode;
243
239
  typeof c == "string" && (t.cartCode = c);
244
- const g = e.inStock;
245
- typeof g == "boolean" && (t.inStock = g);
240
+ const p = e.inStock;
241
+ typeof p == "boolean" && (t.inStock = p);
246
242
  const m = e.extras;
247
243
  return m != null && typeof m == "object" && (t.extras = m), t;
248
244
  }
@@ -272,14 +268,14 @@ const O = {
272
268
  ProductCard: ({ element: n, context: e }) => {
273
269
  const t = n.props?.product ?? n.props, r = A(t);
274
270
  if (!r) return null;
275
- const i = n.props?.index, a = typeof i == "number" && Number.isFinite(i) ? i : 0, s = n.props?.discountType, p = s === "strike-through" || s === "badge" ? s : e.discountType, d = {
271
+ const i = n.props?.index, a = typeof i == "number" && Number.isFinite(i) ? i : 0, s = n.props?.discountType, u = s === "strike-through" || s === "badge" ? s : e.discountType, g = {
276
272
  product: r,
277
273
  index: a,
278
274
  onClick: e.onClick,
279
275
  onAddToCart: e.onAddToCart,
280
276
  i18n: e.i18n
281
277
  };
282
- return p !== void 0 && (d.discountType = p), e.renderCard !== void 0 && (d.renderCard = e.renderCard), e.renderCardElement !== void 0 && (d.renderCardElement = e.renderCardElement), e.pricing !== void 0 && (d.pricing = e.pricing), U(d);
278
+ return u !== void 0 && (g.discountType = u), e.renderCard !== void 0 && (g.renderCard = e.renderCard), e.renderCardElement !== void 0 && (g.renderCardElement = e.renderCardElement), e.pricing !== void 0 && (g.pricing = e.pricing), U(g);
283
279
  },
284
280
  GroupTabs: ({ element: n, context: e }) => {
285
281
  const t = n.props?.groups;
@@ -289,17 +285,17 @@ const O = {
289
285
  if (!a || typeof a != "object") continue;
290
286
  const s = a;
291
287
  if (typeof s.name != "string") continue;
292
- const p = [];
288
+ const u = [];
293
289
  if (Array.isArray(s.products))
294
- for (const u of s.products) {
295
- const c = A(u);
296
- c && p.push(c);
290
+ for (const l of s.products) {
291
+ const c = A(l);
292
+ c && u.push(c);
297
293
  }
298
- const d = {
294
+ const g = {
299
295
  name: s.name,
300
- products: p
296
+ products: u
301
297
  };
302
- typeof s.highlight == "string" && (d.highlight = s.highlight), r.push(d);
298
+ typeof s.highlight == "string" && (g.highlight = s.highlight), r.push(g);
303
299
  }
304
300
  const i = {
305
301
  groups: r,
@@ -332,12 +328,12 @@ const O = {
332
328
  if (!Array.isArray(r) || !e.onAction) return t;
333
329
  for (const i of r) {
334
330
  if (!i || typeof i != "object") continue;
335
- const a = i, s = a.label, p = le(a.action);
336
- if (typeof s != "string" || !p) continue;
337
- const d = document.createElement("button");
338
- d.className = "gengage-simrel-quick-action", d.type = "button", d.textContent = s, d.addEventListener("click", (u) => {
339
- u.preventDefault(), u.stopPropagation(), e.onAction?.(p);
340
- }), t.appendChild(d);
331
+ const a = i, s = a.label, u = le(a.action);
332
+ if (typeof s != "string" || !u) continue;
333
+ const g = document.createElement("button");
334
+ g.className = "gengage-simrel-quick-action", g.type = "button", g.textContent = s, g.addEventListener("click", (l) => {
335
+ l.preventDefault(), l.stopPropagation(), e.onAction?.(u);
336
+ }), t.appendChild(g);
341
337
  }
342
338
  return t;
343
339
  }
@@ -358,7 +354,7 @@ function ue() {
358
354
  return { ...O };
359
355
  }
360
356
  function ge(n, e, t = O, r = G) {
361
- return z({
357
+ return H({
362
358
  spec: n,
363
359
  context: e,
364
360
  registry: t,
@@ -372,6 +368,10 @@ const D = {
372
368
  addToCartButton: "Sepete Ekle",
373
369
  ctaLabel: "İncele",
374
370
  outOfStockLabel: "Stokta Yok",
371
+ decreaseLabel: "Azalt",
372
+ increaseLabel: "Artır",
373
+ errorLoadingMessage: "Benzer ürünler yüklenemedi.",
374
+ retryButtonText: "Tekrar dene",
375
375
  priceSuffix: " TL"
376
376
  }, pe = {
377
377
  similarProductsAriaLabel: "Similar products",
@@ -379,6 +379,10 @@ const D = {
379
379
  addToCartButton: "Add to cart",
380
380
  ctaLabel: "View",
381
381
  outOfStockLabel: "Out of Stock",
382
+ decreaseLabel: "Decrease",
383
+ increaseLabel: "Increase",
384
+ errorLoadingMessage: "Could not load similar products.",
385
+ retryButtonText: "Try again",
382
386
  priceSuffix: ""
383
387
  };
384
388
  function me(n) {
@@ -398,19 +402,19 @@ const he = b({
398
402
  brand: h().optional(),
399
403
  rating: E().min(0).max(5).optional(),
400
404
  reviewCount: E().int().nonnegative().optional()
401
- }), Ce = b({
402
- layout: x(["grid", "carousel"]).optional(),
403
- columns: E().int().positive().optional()
404
405
  }), ye = b({
406
+ layout: L(["grid", "carousel"]).optional(),
407
+ columns: E().int().positive().optional()
408
+ }), Ce = b({
405
409
  product: he,
406
410
  index: E().int().nonnegative(),
407
- discountType: x(["strike-through", "badge"]).optional()
411
+ discountType: L(["strike-through", "badge"]).optional()
408
412
  }), be = b({
409
413
  sku: h(),
410
414
  label: h().optional(),
411
415
  cartCode: h()
412
416
  }), Ee = b({
413
- actions: H(
417
+ actions: z(
414
418
  b({
415
419
  label: h(),
416
420
  action: b({
@@ -425,11 +429,11 @@ const he = b({
425
429
  }), Te = {
426
430
  components: {
427
431
  ProductGrid: {
428
- schema: Ce,
432
+ schema: ye,
429
433
  description: "Outer grid or carousel container for similar products."
430
434
  },
431
435
  ProductCard: {
432
- schema: ye,
436
+ schema: Ce,
433
437
  description: "A single product card with image, title, price, and actions."
434
438
  },
435
439
  AddToCartButton: {
@@ -446,12 +450,12 @@ const he = b({
446
450
  }
447
451
  }
448
452
  };
449
- class ke extends F {
453
+ class _e extends F {
450
454
  constructor() {
451
455
  super(...arguments), this._abortController = null, this._contentEl = null, this._i18n = D;
452
456
  }
453
457
  async onInit(e) {
454
- this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-simrel-container", this.root.appendChild(this._contentEl), this._lastSku = e.sku, await this._fetchAndRender(e.sku), this.isVisible = !0, J("simrel");
458
+ this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-simrel-container", this.root.appendChild(this._contentEl), this._lastSku = e.sku, await this._fetchAndRender(e.sku), J("simrel");
455
459
  }
456
460
  onUpdate(e) {
457
461
  const t = e.sku;
@@ -477,7 +481,7 @@ class ke extends F {
477
481
  url: e.url
478
482
  };
479
483
  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;
480
- W(e.sku, e.name);
484
+ Q(e.sku, e.name);
481
485
  const r = this.config.session?.sessionId ?? null;
482
486
  v("gengage:similar:product-click", {
483
487
  sku: e.sku,
@@ -486,8 +490,8 @@ class ke extends F {
486
490
  }), this.config.onProductNavigate?.(e.url, e.sku, r);
487
491
  }
488
492
  _handleAddToCart(e) {
489
- Q(e.sku, e.quantity), this.config.onAddToCart?.(e), v("gengage:similar:add-to-cart", e), this.track(
490
- V(this.analyticsContext(), {
493
+ W(e.sku, e.quantity), this.config.onAddToCart?.(e), v("gengage:similar:add-to-cart", e), this.track(
494
+ Y(this.analyticsContext(), {
491
495
  attribution_source: "simrel",
492
496
  attribution_action_id: crypto.randomUUID(),
493
497
  cart_value: 0,
@@ -506,58 +510,58 @@ class ke extends F {
506
510
  }
507
511
  async _fetchAndRender(e) {
508
512
  this._abort(), this._abortController = new AbortController();
509
- const t = this._abortController.signal;
510
- if (!this._contentEl) return;
513
+ const t = this._abortController.signal, r = setTimeout(() => this._abortController?.abort(), 1e4);
514
+ if (t.addEventListener("abort", () => clearTimeout(r)), !this._contentEl) return;
511
515
  this._contentEl.innerHTML = "", this._contentEl.style.display = "";
512
- const r = document.createElement("div");
513
- r.className = "gengage-simrel-loading";
514
516
  const i = document.createElement("div");
515
- i.className = "gengage-simrel-spinner", r.appendChild(i), this._contentEl.appendChild(r);
516
- const a = {
517
+ i.className = "gengage-simrel-loading";
518
+ const a = document.createElement("div");
519
+ a.className = "gengage-simrel-spinner", i.appendChild(a), this._contentEl.appendChild(i);
520
+ const s = {
517
521
  middlewareUrl: this.config.middlewareUrl
518
- }, s = crypto.randomUUID(), p = Date.now();
522
+ }, u = crypto.randomUUID(), g = Date.now();
519
523
  this.track(
520
- Y(this.analyticsContext(), {
524
+ V(this.analyticsContext(), {
521
525
  endpoint: "similar_products",
522
- request_id: s,
526
+ request_id: u,
523
527
  widget: "simrel"
524
528
  })
525
529
  );
526
530
  try {
527
- const d = {
531
+ const l = {
528
532
  account_id: this.config.accountId,
529
533
  session_id: this.config.session?.sessionId ?? "",
530
534
  correlation_id: this.config.session?.sessionId ?? "",
531
535
  sku: e
532
536
  };
533
- this.config.domain !== void 0 && (d.domain = this.config.domain);
534
- const u = await oe(d, a, t);
537
+ this.config.domain !== void 0 && (l.domain = this.config.domain);
538
+ const c = await oe(l, s, t);
535
539
  if (!this._contentEl) return;
536
- if (this._contentEl.innerHTML = "", u.length > 0)
540
+ if (this._contentEl.innerHTML = "", c.length > 0)
537
541
  try {
538
- const c = u.map((m) => m.sku), g = await se(
542
+ const p = c.map((y) => y.sku), m = await se(
539
543
  {
540
544
  account_id: this.config.accountId,
541
545
  session_id: this.config.session?.sessionId ?? "",
542
546
  correlation_id: this.config.session?.sessionId ?? "",
543
- skus: c
547
+ skus: p
544
548
  },
545
- a,
549
+ s,
546
550
  t
547
551
  );
548
- if (g.length > 0 && this._contentEl) {
549
- const m = this._buildGroupsSpec(g), C = this._renderUISpec(m);
550
- this._contentEl.appendChild(C), k("simrel"), this.track(
551
- _(this.analyticsContext(), {
552
- request_id: s,
553
- latency_ms: Date.now() - p,
554
- chunk_count: g.reduce((l, o) => l + o.products.length, 0),
552
+ if (m.length > 0 && this._contentEl) {
553
+ const y = this._buildGroupsSpec(m), d = this._renderUISpec(y);
554
+ this._contentEl.appendChild(d), _("simrel"), this.track(
555
+ k(this.analyticsContext(), {
556
+ request_id: u,
557
+ latency_ms: Date.now() - g,
558
+ chunk_count: m.reduce((o, f) => o + f.products.length, 0),
555
559
  widget: "simrel"
556
560
  })
557
561
  ), this.track(
558
562
  S(this.analyticsContext(), {
559
- message_count: g.reduce((l, o) => l + o.products.length, 0),
560
- history_ref: s,
563
+ message_count: m.reduce((o, f) => o + f.products.length, 0),
564
+ history_ref: u,
561
565
  redaction_level: "none",
562
566
  widget: "simrel"
563
567
  })
@@ -566,48 +570,49 @@ class ke extends F {
566
570
  }
567
571
  } catch {
568
572
  }
573
+ if (t.aborted) return;
569
574
  if (this._contentEl) {
570
- const c = this._buildProductsSpec(u), g = this._renderUISpec(c);
571
- this._contentEl.appendChild(g);
575
+ const p = this._buildProductsSpec(c), m = this._renderUISpec(p);
576
+ this._contentEl.appendChild(m);
572
577
  }
573
- u.length > 0 && k("simrel"), this.track(
574
- _(this.analyticsContext(), {
575
- request_id: s,
576
- latency_ms: Date.now() - p,
577
- chunk_count: u.length,
578
+ c.length > 0 && _("simrel"), this.track(
579
+ k(this.analyticsContext(), {
580
+ request_id: u,
581
+ latency_ms: Date.now() - g,
582
+ chunk_count: c.length,
578
583
  widget: "simrel"
579
584
  })
580
585
  ), this.track(
581
586
  S(this.analyticsContext(), {
582
- message_count: u.length,
583
- history_ref: s,
587
+ message_count: c.length,
588
+ history_ref: u,
584
589
  redaction_level: "none",
585
590
  widget: "simrel"
586
591
  })
587
592
  );
588
- } catch (d) {
589
- if (d instanceof DOMException && d.name === "AbortError") return;
593
+ } catch (l) {
594
+ if (l instanceof DOMException && l.name === "AbortError") return;
590
595
  if (v("gengage:global:error", {
591
596
  source: "simrel",
592
597
  code: "FETCH_ERROR",
593
598
  message: K(this.config.locale)
594
599
  }), this.track(
595
600
  X(this.analyticsContext(), {
596
- request_id: s,
601
+ request_id: u,
597
602
  error_code: "FETCH_ERROR",
598
- error_message: d instanceof Error ? d.message : String(d),
603
+ error_message: l instanceof Error ? l.message : String(l),
599
604
  widget: "simrel"
600
605
  })
601
606
  ), this._contentEl) {
602
607
  this._contentEl.innerHTML = "";
603
- const u = document.createElement("div");
604
- u.className = "gengage-simrel-error", u.style.cssText = "text-align:center;padding:16px;color:#6b7280;font-size:13px;";
605
- const c = document.createElement("span");
606
- c.textContent = this.config.locale?.startsWith("tr") ? "Benzer ürünler yüklenemedi." : "Could not load similar products.", u.appendChild(c);
607
- const g = document.createElement("button");
608
- g.textContent = this.config.locale?.startsWith("tr") ? "Tekrar dene" : "Try again", g.style.cssText = "margin-left:8px;border:1px solid #d1d5db;background:#fff;border-radius:6px;padding:4px 12px;cursor:pointer;font-size:13px;color:#374151;", g.addEventListener("click", () => {
608
+ const c = document.createElement("div");
609
+ c.className = "gengage-simrel-error";
610
+ const p = document.createElement("span");
611
+ p.textContent = this._i18n.errorLoadingMessage, c.appendChild(p);
612
+ const m = document.createElement("button");
613
+ m.className = "gengage-simrel-retry", m.textContent = this._i18n.retryButtonText, m.addEventListener("click", () => {
609
614
  this._fetchAndRender(this.config.sku);
610
- }), u.appendChild(g), this._contentEl.appendChild(u);
615
+ }), c.appendChild(m), this._contentEl.appendChild(c);
611
616
  }
612
617
  }
613
618
  }
@@ -627,7 +632,7 @@ class ke extends F {
627
632
  return 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), t;
628
633
  }
629
634
  _renderUISpec(e) {
630
- const t = this._resolveUISpecRegistry(), r = this._buildRenderContext(), i = this.config.renderer?.unknownRenderer ?? G, a = (d, u) => ge(d, u, t, i), s = this.config.renderer?.renderUISpec;
635
+ const t = this._resolveUISpecRegistry(), r = this._buildRenderContext(), i = this.config.renderer?.unknownRenderer ?? G, a = (g, l) => ge(g, l, t, i), s = this.config.renderer?.renderUISpec;
631
636
  return s ? s(e, r, {
632
637
  registry: t,
633
638
  unknownRenderer: i,
@@ -671,10 +676,10 @@ class ke extends F {
671
676
  }
672
677
  }
673
678
  function we() {
674
- return new ke();
679
+ return new _e();
675
680
  }
676
681
  export {
677
- ke as GengageSimRel,
682
+ _e as GengageSimRel,
678
683
  ue as createDefaultSimRelUISpecRegistry,
679
684
  we as createSimRelWidget,
680
685
  G as defaultSimRelUnknownUISpecRenderer,