@gengage/assistant-fe 0.2.2 → 0.2.4
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.
- package/dist/assistant-fe.css +1 -1
- package/dist/chat/catalog.d.ts +2 -0
- package/dist/chat/catalog.d.ts.map +1 -1
- package/dist/chat/components/ChatDrawer.d.ts +47 -2
- package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
- package/dist/chat/components/ChoicePrompter.d.ts +3 -1
- package/dist/chat/components/ChoicePrompter.d.ts.map +1 -1
- package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
- package/dist/chat/components/PanelTopBar.d.ts +1 -0
- package/dist/chat/components/PanelTopBar.d.ts.map +1 -1
- package/dist/chat/components/ProductSummaryCard.d.ts.map +1 -1
- package/dist/chat/components/ReviewHighlights.d.ts.map +1 -1
- package/dist/chat/components/renderUISpec.d.ts.map +1 -1
- package/dist/chat/index.d.ts +22 -0
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/chat/locales/en.d.ts.map +1 -1
- package/dist/chat/locales/tr.d.ts.map +1 -1
- package/dist/chat/panel-manager.d.ts +6 -4
- package/dist/chat/panel-manager.d.ts.map +1 -1
- package/dist/chat/session-persistence.d.ts +6 -1
- package/dist/chat/session-persistence.d.ts.map +1 -1
- package/dist/chat/types.d.ts +23 -1
- package/dist/chat/types.d.ts.map +1 -1
- package/dist/chat.cjs +1 -1
- package/dist/chat.iife.js +29 -29
- package/dist/chat.iife.js.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/common/communication-bridge.d.ts.map +1 -1
- package/dist/common/price-formatter.d.ts +1 -1
- package/dist/common/price-formatter.d.ts.map +1 -1
- package/dist/common/product-utils.d.ts.map +1 -1
- package/dist/common/quantity-stepper.d.ts +1 -1
- package/dist/common/quantity-stepper.d.ts.map +1 -1
- package/dist/common/skeleton.d.ts +9 -0
- package/dist/common/skeleton.d.ts.map +1 -0
- package/dist/common/widget-base.d.ts.map +1 -1
- package/dist/common.cjs +1 -1
- package/dist/common.js +5 -5
- package/dist/index-BQVIyEOM.cjs +13 -0
- package/dist/index-BQVIyEOM.cjs.map +1 -0
- package/dist/index-Cdmhc_35.js +4783 -0
- package/dist/index-Cdmhc_35.js.map +1 -0
- package/dist/{index-CUukV8wH.cjs → index-DjdiNtXX.cjs} +2 -2
- package/dist/{index-CUukV8wH.cjs.map → index-DjdiNtXX.cjs.map} +1 -1
- package/dist/{index-CpLM7vPC.js → index-hUs4nTXp.js} +3 -3
- package/dist/{index-CpLM7vPC.js.map → index-hUs4nTXp.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/native.cjs +1 -1
- package/dist/native.iife.js +29 -29
- package/dist/native.iife.js.map +1 -1
- package/dist/native.js +1 -1
- package/dist/qna/index.d.ts.map +1 -1
- package/dist/qna.cjs +1 -1
- package/dist/qna.cjs.map +1 -1
- package/dist/qna.css +1 -1
- package/dist/qna.iife.js +13 -13
- package/dist/qna.iife.js.map +1 -1
- package/dist/qna.js +53 -44
- package/dist/qna.js.map +1 -1
- package/dist/quantity-stepper-CQWgexMO.cjs +2 -0
- package/dist/quantity-stepper-CQWgexMO.cjs.map +1 -0
- package/dist/quantity-stepper-CjY_cpgJ.js +80 -0
- package/dist/quantity-stepper-CjY_cpgJ.js.map +1 -0
- package/dist/{schemas-D1Kd4wn8.js → schemas-C7h8aelU.js} +2 -2
- package/dist/schemas-C7h8aelU.js.map +1 -0
- package/dist/{schemas-DOxyUYVA.cjs → schemas-DXvpS-Yg.cjs} +2 -2
- package/dist/schemas-DXvpS-Yg.cjs.map +1 -0
- package/dist/simrel/components/GroupTabs.d.ts.map +1 -1
- package/dist/simrel/components/ProductCard.d.ts.map +1 -1
- package/dist/simrel/components/ProductGrid.d.ts.map +1 -1
- package/dist/simrel/index.d.ts.map +1 -1
- package/dist/simrel/locales/en.d.ts.map +1 -1
- package/dist/simrel/locales/tr.d.ts.map +1 -1
- package/dist/simrel/types.d.ts +2 -0
- package/dist/simrel/types.d.ts.map +1 -1
- package/dist/simrel.cjs +1 -1
- package/dist/simrel.cjs.map +1 -1
- package/dist/simrel.css +1 -1
- package/dist/simrel.iife.js +11 -11
- package/dist/simrel.iife.js.map +1 -1
- package/dist/simrel.js +149 -148
- package/dist/simrel.js.map +1 -1
- package/package.json +2 -1
- package/dist/index-CB8DgwIv.cjs +0 -13
- package/dist/index-CB8DgwIv.cjs.map +0 -1
- package/dist/index-EEUjXgSt.js +0 -4468
- package/dist/index-EEUjXgSt.js.map +0 -1
- package/dist/quantity-stepper-BKtPQUR1.js +0 -78
- package/dist/quantity-stepper-BKtPQUR1.js.map +0 -1
- package/dist/quantity-stepper-DU6va4sS.cjs +0 -2
- package/dist/quantity-stepper-DU6va4sS.cjs.map +0 -1
- package/dist/schemas-D1Kd4wn8.js.map +0 -1
- 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
|
|
2
|
-
import { a as ee, c as te, b as ne, f as T, d as re } from "./quantity-stepper-
|
|
3
|
-
function
|
|
1
|
+
import { b as P, p as j, q as B, c as I, a as R, v as q, x as H, r as M, o as b, s as h, f as z, e as $, _ as N, 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-C7h8aelU.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 L(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
|
|
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 =
|
|
20
|
-
!a || a.type !== "ui_spec" || t.push(...
|
|
19
|
+
const a = R(i);
|
|
20
|
+
!a || a.type !== "ui_spec" || t.push(...L(a.spec.elements));
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
return e !== void 0 && (r.signal = e), await
|
|
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,7 +32,7 @@ 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 (
|
|
35
|
+
if (x(a))
|
|
36
36
|
return ie(a, t);
|
|
37
37
|
const s = await a.text();
|
|
38
38
|
if (!s) return [];
|
|
@@ -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 =
|
|
50
|
+
const s = R(a);
|
|
51
51
|
if (s) {
|
|
52
52
|
if (s.type === "metadata" && s.meta) {
|
|
53
|
-
const
|
|
54
|
-
if (typeof
|
|
55
|
-
r = { name:
|
|
56
|
-
const
|
|
57
|
-
typeof
|
|
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(...
|
|
60
|
+
s.type === "ui_spec" && r && r.products.push(...L(s.spec.elements));
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
return e !== void 0 && (i.signal = e), await
|
|
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,32 +73,32 @@ 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 (
|
|
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
|
|
81
|
+
return B(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,
|
|
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 =
|
|
94
|
+
return o.className = "gengage-simrel-card gengage-simrel-card--custom", o.innerHTML = q(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
|
|
99
|
-
|
|
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
|
-
if (c.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", e.imageUrl &&
|
|
101
|
+
if (c.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", e.imageUrl && H(e.imageUrl)) {
|
|
102
102
|
const o = document.createElement("img");
|
|
103
103
|
o.className = "gengage-chat-product-card-img", o.src = e.imageUrl, o.alt = e.name, o.loading = "lazy", ee(o), c.appendChild(o);
|
|
104
104
|
}
|
|
@@ -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
|
-
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
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,
|
|
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,
|
|
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
|
-
|
|
122
|
+
p.appendChild(o);
|
|
123
123
|
}
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
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,
|
|
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,
|
|
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
|
-
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
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
|
-
}),
|
|
137
|
+
}), l.appendChild(d), e.inStock === !1) {
|
|
138
138
|
const o = document.createElement("div");
|
|
139
|
-
o.className = "gengage-simrel-card-oos", o.textContent =
|
|
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:
|
|
144
|
-
|
|
145
|
-
|
|
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"),
|
|
150
|
+
f.classList.add("gengage-simrel-atc"), l.appendChild(f);
|
|
149
151
|
}
|
|
150
|
-
return
|
|
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
|
-
}),
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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 && (
|
|
190
|
-
},
|
|
191
|
-
for (let
|
|
192
|
-
const o =
|
|
193
|
-
i[
|
|
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
|
|
191
|
+
const p = n.groups[c], m = a[c];
|
|
196
192
|
m.innerHTML = "";
|
|
197
|
-
const
|
|
198
|
-
m.appendChild(
|
|
199
|
-
for (let
|
|
200
|
-
const o =
|
|
201
|
-
a[
|
|
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
|
|
206
|
-
|
|
207
|
-
let
|
|
208
|
-
f.key === "ArrowRight" || f.key === "ArrowDown" ?
|
|
209
|
-
}), i.push(
|
|
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 =
|
|
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
|
|
215
|
-
|
|
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
|
|
237
|
-
typeof
|
|
238
|
-
const
|
|
239
|
-
typeof
|
|
240
|
-
const
|
|
241
|
-
typeof
|
|
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
|
|
245
|
-
typeof
|
|
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,
|
|
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
|
|
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
|
|
288
|
+
const u = [];
|
|
293
289
|
if (Array.isArray(s.products))
|
|
294
|
-
for (const
|
|
295
|
-
const c = A(
|
|
296
|
-
c &&
|
|
290
|
+
for (const l of s.products) {
|
|
291
|
+
const c = A(l);
|
|
292
|
+
c && u.push(c);
|
|
297
293
|
}
|
|
298
|
-
const
|
|
294
|
+
const g = {
|
|
299
295
|
name: s.name,
|
|
300
|
-
products:
|
|
296
|
+
products: u
|
|
301
297
|
};
|
|
302
|
-
typeof s.highlight == "string" && (
|
|
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,
|
|
336
|
-
if (typeof s != "string" || !
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}), t.appendChild(
|
|
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
|
|
357
|
+
return M({
|
|
362
358
|
spec: n,
|
|
363
359
|
context: e,
|
|
364
360
|
registry: t,
|
|
@@ -372,6 +368,8 @@ const D = {
|
|
|
372
368
|
addToCartButton: "Sepete Ekle",
|
|
373
369
|
ctaLabel: "İncele",
|
|
374
370
|
outOfStockLabel: "Stokta Yok",
|
|
371
|
+
decreaseLabel: "Azalt",
|
|
372
|
+
increaseLabel: "Artır",
|
|
375
373
|
priceSuffix: " TL"
|
|
376
374
|
}, pe = {
|
|
377
375
|
similarProductsAriaLabel: "Similar products",
|
|
@@ -379,6 +377,8 @@ const D = {
|
|
|
379
377
|
addToCartButton: "Add to cart",
|
|
380
378
|
ctaLabel: "View",
|
|
381
379
|
outOfStockLabel: "Out of Stock",
|
|
380
|
+
decreaseLabel: "Decrease",
|
|
381
|
+
increaseLabel: "Increase",
|
|
382
382
|
priceSuffix: ""
|
|
383
383
|
};
|
|
384
384
|
function me(n) {
|
|
@@ -398,19 +398,19 @@ const he = b({
|
|
|
398
398
|
brand: h().optional(),
|
|
399
399
|
rating: E().min(0).max(5).optional(),
|
|
400
400
|
reviewCount: E().int().nonnegative().optional()
|
|
401
|
-
}), Ce = b({
|
|
402
|
-
layout: x(["grid", "carousel"]).optional(),
|
|
403
|
-
columns: E().int().positive().optional()
|
|
404
401
|
}), ye = b({
|
|
402
|
+
layout: N(["grid", "carousel"]).optional(),
|
|
403
|
+
columns: E().int().positive().optional()
|
|
404
|
+
}), Ce = b({
|
|
405
405
|
product: he,
|
|
406
406
|
index: E().int().nonnegative(),
|
|
407
|
-
discountType:
|
|
407
|
+
discountType: N(["strike-through", "badge"]).optional()
|
|
408
408
|
}), be = b({
|
|
409
409
|
sku: h(),
|
|
410
410
|
label: h().optional(),
|
|
411
411
|
cartCode: h()
|
|
412
412
|
}), Ee = b({
|
|
413
|
-
actions:
|
|
413
|
+
actions: z(
|
|
414
414
|
b({
|
|
415
415
|
label: h(),
|
|
416
416
|
action: b({
|
|
@@ -425,11 +425,11 @@ const he = b({
|
|
|
425
425
|
}), Te = {
|
|
426
426
|
components: {
|
|
427
427
|
ProductGrid: {
|
|
428
|
-
schema:
|
|
428
|
+
schema: ye,
|
|
429
429
|
description: "Outer grid or carousel container for similar products."
|
|
430
430
|
},
|
|
431
431
|
ProductCard: {
|
|
432
|
-
schema:
|
|
432
|
+
schema: Ce,
|
|
433
433
|
description: "A single product card with image, title, price, and actions."
|
|
434
434
|
},
|
|
435
435
|
AddToCartButton: {
|
|
@@ -506,58 +506,58 @@ class ke extends F {
|
|
|
506
506
|
}
|
|
507
507
|
async _fetchAndRender(e) {
|
|
508
508
|
this._abort(), this._abortController = new AbortController();
|
|
509
|
-
const t = this._abortController.signal;
|
|
510
|
-
if (!this._contentEl) return;
|
|
509
|
+
const t = this._abortController.signal, r = setTimeout(() => this._abortController?.abort(), 1e4);
|
|
510
|
+
if (t.addEventListener("abort", () => clearTimeout(r)), !this._contentEl) return;
|
|
511
511
|
this._contentEl.innerHTML = "", this._contentEl.style.display = "";
|
|
512
|
-
const r = document.createElement("div");
|
|
513
|
-
r.className = "gengage-simrel-loading";
|
|
514
512
|
const i = document.createElement("div");
|
|
515
|
-
i.className = "gengage-simrel-
|
|
516
|
-
const a =
|
|
513
|
+
i.className = "gengage-simrel-loading";
|
|
514
|
+
const a = document.createElement("div");
|
|
515
|
+
a.className = "gengage-simrel-spinner", i.appendChild(a), this._contentEl.appendChild(i);
|
|
516
|
+
const s = {
|
|
517
517
|
middlewareUrl: this.config.middlewareUrl
|
|
518
|
-
},
|
|
518
|
+
}, u = crypto.randomUUID(), g = Date.now();
|
|
519
519
|
this.track(
|
|
520
520
|
Y(this.analyticsContext(), {
|
|
521
521
|
endpoint: "similar_products",
|
|
522
|
-
request_id:
|
|
522
|
+
request_id: u,
|
|
523
523
|
widget: "simrel"
|
|
524
524
|
})
|
|
525
525
|
);
|
|
526
526
|
try {
|
|
527
|
-
const
|
|
527
|
+
const l = {
|
|
528
528
|
account_id: this.config.accountId,
|
|
529
529
|
session_id: this.config.session?.sessionId ?? "",
|
|
530
530
|
correlation_id: this.config.session?.sessionId ?? "",
|
|
531
531
|
sku: e
|
|
532
532
|
};
|
|
533
|
-
this.config.domain !== void 0 && (
|
|
534
|
-
const
|
|
533
|
+
this.config.domain !== void 0 && (l.domain = this.config.domain);
|
|
534
|
+
const c = await oe(l, s, t);
|
|
535
535
|
if (!this._contentEl) return;
|
|
536
|
-
if (this._contentEl.innerHTML = "",
|
|
536
|
+
if (this._contentEl.innerHTML = "", c.length > 0)
|
|
537
537
|
try {
|
|
538
|
-
const
|
|
538
|
+
const p = c.map((y) => y.sku), m = await se(
|
|
539
539
|
{
|
|
540
540
|
account_id: this.config.accountId,
|
|
541
541
|
session_id: this.config.session?.sessionId ?? "",
|
|
542
542
|
correlation_id: this.config.session?.sessionId ?? "",
|
|
543
|
-
skus:
|
|
543
|
+
skus: p
|
|
544
544
|
},
|
|
545
|
-
|
|
545
|
+
s,
|
|
546
546
|
t
|
|
547
547
|
);
|
|
548
|
-
if (
|
|
549
|
-
const
|
|
550
|
-
this._contentEl.appendChild(
|
|
548
|
+
if (m.length > 0 && this._contentEl) {
|
|
549
|
+
const y = this._buildGroupsSpec(m), d = this._renderUISpec(y);
|
|
550
|
+
this._contentEl.appendChild(d), k("simrel"), this.track(
|
|
551
551
|
_(this.analyticsContext(), {
|
|
552
|
-
request_id:
|
|
553
|
-
latency_ms: Date.now() -
|
|
554
|
-
chunk_count:
|
|
552
|
+
request_id: u,
|
|
553
|
+
latency_ms: Date.now() - g,
|
|
554
|
+
chunk_count: m.reduce((o, f) => o + f.products.length, 0),
|
|
555
555
|
widget: "simrel"
|
|
556
556
|
})
|
|
557
557
|
), this.track(
|
|
558
558
|
S(this.analyticsContext(), {
|
|
559
|
-
message_count:
|
|
560
|
-
history_ref:
|
|
559
|
+
message_count: m.reduce((o, f) => o + f.products.length, 0),
|
|
560
|
+
history_ref: u,
|
|
561
561
|
redaction_level: "none",
|
|
562
562
|
widget: "simrel"
|
|
563
563
|
})
|
|
@@ -566,48 +566,49 @@ class ke extends F {
|
|
|
566
566
|
}
|
|
567
567
|
} catch {
|
|
568
568
|
}
|
|
569
|
+
if (t.aborted) return;
|
|
569
570
|
if (this._contentEl) {
|
|
570
|
-
const
|
|
571
|
-
this._contentEl.appendChild(
|
|
571
|
+
const p = this._buildProductsSpec(c), m = this._renderUISpec(p);
|
|
572
|
+
this._contentEl.appendChild(m);
|
|
572
573
|
}
|
|
573
|
-
|
|
574
|
+
c.length > 0 && k("simrel"), this.track(
|
|
574
575
|
_(this.analyticsContext(), {
|
|
575
|
-
request_id:
|
|
576
|
-
latency_ms: Date.now() -
|
|
577
|
-
chunk_count:
|
|
576
|
+
request_id: u,
|
|
577
|
+
latency_ms: Date.now() - g,
|
|
578
|
+
chunk_count: c.length,
|
|
578
579
|
widget: "simrel"
|
|
579
580
|
})
|
|
580
581
|
), this.track(
|
|
581
582
|
S(this.analyticsContext(), {
|
|
582
|
-
message_count:
|
|
583
|
-
history_ref:
|
|
583
|
+
message_count: c.length,
|
|
584
|
+
history_ref: u,
|
|
584
585
|
redaction_level: "none",
|
|
585
586
|
widget: "simrel"
|
|
586
587
|
})
|
|
587
588
|
);
|
|
588
|
-
} catch (
|
|
589
|
-
if (
|
|
589
|
+
} catch (l) {
|
|
590
|
+
if (l instanceof DOMException && l.name === "AbortError") return;
|
|
590
591
|
if (v("gengage:global:error", {
|
|
591
592
|
source: "simrel",
|
|
592
593
|
code: "FETCH_ERROR",
|
|
593
594
|
message: K(this.config.locale)
|
|
594
595
|
}), this.track(
|
|
595
596
|
X(this.analyticsContext(), {
|
|
596
|
-
request_id:
|
|
597
|
+
request_id: u,
|
|
597
598
|
error_code: "FETCH_ERROR",
|
|
598
|
-
error_message:
|
|
599
|
+
error_message: l instanceof Error ? l.message : String(l),
|
|
599
600
|
widget: "simrel"
|
|
600
601
|
})
|
|
601
602
|
), this._contentEl) {
|
|
602
603
|
this._contentEl.innerHTML = "";
|
|
603
|
-
const
|
|
604
|
-
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
const
|
|
608
|
-
|
|
604
|
+
const c = document.createElement("div");
|
|
605
|
+
c.className = "gengage-simrel-error";
|
|
606
|
+
const p = document.createElement("span");
|
|
607
|
+
p.textContent = this.config.locale?.startsWith("tr") ? "Benzer ürünler yüklenemedi." : "Could not load similar products.", c.appendChild(p);
|
|
608
|
+
const m = document.createElement("button");
|
|
609
|
+
m.className = "gengage-simrel-retry", m.textContent = this.config.locale?.startsWith("tr") ? "Tekrar dene" : "Try again", m.addEventListener("click", () => {
|
|
609
610
|
this._fetchAndRender(this.config.sku);
|
|
610
|
-
}),
|
|
611
|
+
}), c.appendChild(m), this._contentEl.appendChild(c);
|
|
611
612
|
}
|
|
612
613
|
}
|
|
613
614
|
}
|
|
@@ -627,7 +628,7 @@ class ke extends F {
|
|
|
627
628
|
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
629
|
}
|
|
629
630
|
_renderUISpec(e) {
|
|
630
|
-
const t = this._resolveUISpecRegistry(), r = this._buildRenderContext(), i = this.config.renderer?.unknownRenderer ?? G, a = (
|
|
631
|
+
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
632
|
return s ? s(e, r, {
|
|
632
633
|
registry: t,
|
|
633
634
|
unknownRenderer: i,
|