@gengage/assistant-fe 0.6.50 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/api.d.ts +1 -1
- package/dist/chat/components/ChatDrawer.d.ts +3 -1
- package/dist/chat/features/beauty-consulting/mode-controller.d.ts +1 -1
- package/dist/chat/features/beauty-consulting/stream-handler.d.ts +7 -1
- package/dist/chat/history-storage.d.ts +36 -4
- package/dist/chat/runtime.d.ts +2 -2
- package/dist/chat/utils/chat-presentation-debug.d.ts +0 -14
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +56 -56
- package/dist/chat.js +1 -1
- package/dist/common/connection-warning.d.ts +10 -0
- package/dist/common/indexed-db.d.ts +35 -2
- package/dist/common/native-webview.d.ts +1 -1
- package/dist/common/streaming.d.ts +6 -1
- package/dist/common/transport.d.ts +2 -1
- package/dist/common/types.d.ts +16 -0
- package/dist/{common-DJFI5t11.js → common-CeuGSwJL.js} +61 -65
- package/dist/common.js +30 -30
- package/dist/{connection-warning-TXqyeFaf.js → connection-warning-C0e2byq5.js} +31 -25
- package/dist/{fastIntent-539wPavr.js → fastIntent-BI7l1oDv.js} +2 -2
- package/dist/global-error-toast-DvaKvPNA.js +798 -0
- package/dist/index.js +29 -29
- package/dist/native-webview-CHKpwixw.js +303 -0
- package/dist/native.iife.js +27 -27
- package/dist/native.js +1 -1
- package/dist/{overlay-BPZEIyo_.js → overlay-C3XzoSKd.js} +51 -32
- package/dist/overlay.js +6 -6
- package/dist/{price-formatter-CHUmYq8I.js → price-formatter-Q3wUKrl1.js} +2 -1
- package/dist/qna/runtime.d.ts +1 -0
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +32 -32
- package/dist/qna.js +1 -1
- package/dist/{request-response-cache-DwADBDeB.js → request-response-cache-BLQy7llq.js} +478 -454
- package/dist/{runtime-Do3qShrH.js → runtime-BC8-a6Ql.js} +231 -219
- package/dist/{runtime-9f9SB4WE.js → runtime-BSIrZhF2.js} +2783 -2692
- package/dist/{runtime-rTw1jMhB.js → runtime-DiONTdBz.js} +230 -212
- package/dist/{simbut-DlWvDoPI.js → simbut-BDbb3nMH.js} +5 -5
- package/dist/simbut.iife.js +2 -2
- package/dist/simbut.js +1 -1
- package/dist/simrel/components/GroupTabs.d.ts +6 -0
- package/dist/simrel/runtime.d.ts +8 -0
- package/dist/{simrel-BFPU2n5p.js → simrel-CdxDIKu3.js} +15 -15
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +22 -22
- package/dist/simrel.js +2 -2
- package/dist/widget-base-Cvxdrqqt.js +141 -0
- package/package.json +1 -1
- package/dist/context-UTzCGyR9.js +0 -543
- package/dist/native-webview-CYX30O3Q.js +0 -273
- package/dist/widget-base-BwU6SI2o.js +0 -365
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { a as
|
|
6
|
-
import {
|
|
1
|
+
import { a as q, f as R, g as F, i as I, m as z, n as N, o as D, t as G } from "./request-response-cache-BLQy7llq.js";
|
|
2
|
+
import { B as H, L as $, N as A, T as W, f as k, g as J, n as K } from "./global-error-toast-DvaKvPNA.js";
|
|
3
|
+
import { t as Q } from "./widget-base-Cvxdrqqt.js";
|
|
4
|
+
import { t as V } from "./locale-uQ5XZ2yS.js";
|
|
5
|
+
import { a as Y, n as X, r as Z, t as w } from "./price-formatter-Q3wUKrl1.js";
|
|
6
|
+
import { r as ee } from "./connection-warning-C0e2byq5.js";
|
|
7
7
|
function M(e) {
|
|
8
8
|
const t = [];
|
|
9
|
-
for (const
|
|
10
|
-
const
|
|
11
|
-
typeof
|
|
9
|
+
for (const r of Object.values(e)) if (r.type === "ProductCard" && r.props) {
|
|
10
|
+
const n = r.props.product ?? r.props;
|
|
11
|
+
typeof n.sku == "string" && typeof n.name == "string" && t.push(n);
|
|
12
12
|
}
|
|
13
13
|
return t;
|
|
14
14
|
}
|
|
@@ -16,93 +16,93 @@ function U(e) {
|
|
|
16
16
|
const t = e.headers.get("Content-Type") ?? "";
|
|
17
17
|
return t.includes("application/x-ndjson") || t.includes("text/event-stream");
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
const
|
|
19
|
+
async function te(e, t) {
|
|
20
|
+
const r = [], n = { onEvent: (s) => {
|
|
21
21
|
const i = I(s);
|
|
22
|
-
!i || i.type !== "ui_spec" ||
|
|
22
|
+
!i || i.type !== "ui_spec" || r.push(...M(i.spec.elements));
|
|
23
23
|
} };
|
|
24
|
-
return t !== void 0 && (
|
|
24
|
+
return t !== void 0 && (n.signal = t), await R(e, n), r;
|
|
25
25
|
}
|
|
26
|
-
async function
|
|
27
|
-
const
|
|
26
|
+
async function re(e, t, r) {
|
|
27
|
+
const n = N("similar_products", t), s = {
|
|
28
28
|
method: "POST",
|
|
29
29
|
headers: { "Content-Type": "application/json" },
|
|
30
30
|
body: JSON.stringify(e)
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
const i = await
|
|
32
|
+
r !== void 0 && (s.signal = r);
|
|
33
|
+
const i = await G(n, s);
|
|
34
34
|
if (!i.ok) throw new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
35
|
-
if (U(i)) return
|
|
35
|
+
if (U(i)) return te(i, r);
|
|
36
36
|
const a = await i.text();
|
|
37
37
|
if (!a) throw new Error("Empty response body from similar_products endpoint");
|
|
38
38
|
try {
|
|
39
|
-
return
|
|
39
|
+
return D(JSON.parse(a));
|
|
40
40
|
} catch {
|
|
41
41
|
throw new Error("Invalid JSON from similar_products endpoint");
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
async function ne(e, t) {
|
|
45
|
-
const
|
|
46
|
-
let
|
|
45
|
+
const r = [];
|
|
46
|
+
let n = null;
|
|
47
47
|
const s = { onEvent: (i) => {
|
|
48
48
|
const a = I(i);
|
|
49
49
|
if (a) {
|
|
50
50
|
if (a.type === "metadata" && a.meta) {
|
|
51
51
|
const d = a.meta.group_name;
|
|
52
52
|
if (typeof d == "string") {
|
|
53
|
-
|
|
53
|
+
n = {
|
|
54
54
|
name: d,
|
|
55
55
|
products: []
|
|
56
56
|
};
|
|
57
57
|
const m = a.meta.highlight;
|
|
58
|
-
typeof m == "string" && (
|
|
58
|
+
typeof m == "string" && (n.highlight = m), r.push(n);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
a.type === "ui_spec" &&
|
|
61
|
+
a.type === "ui_spec" && n && n.products.push(...M(a.spec.elements));
|
|
62
62
|
}
|
|
63
63
|
} };
|
|
64
|
-
return t !== void 0 && (s.signal = t), await
|
|
64
|
+
return t !== void 0 && (s.signal = t), await R(e, s), r;
|
|
65
65
|
}
|
|
66
|
-
async function
|
|
67
|
-
const
|
|
66
|
+
async function ie(e, t, r) {
|
|
67
|
+
const n = N("product_groupings", t), s = {
|
|
68
68
|
method: "POST",
|
|
69
69
|
headers: { "Content-Type": "application/json" },
|
|
70
70
|
body: JSON.stringify(e)
|
|
71
71
|
};
|
|
72
|
-
|
|
73
|
-
const i = await
|
|
72
|
+
r !== void 0 && (s.signal = r);
|
|
73
|
+
const i = await G(n, s);
|
|
74
74
|
if (!i.ok) throw new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
75
|
-
if (U(i)) return ne(i,
|
|
75
|
+
if (U(i)) return ne(i, r);
|
|
76
76
|
const a = await i.text();
|
|
77
77
|
if (!a) return [];
|
|
78
78
|
try {
|
|
79
|
-
return
|
|
79
|
+
return q(JSON.parse(a));
|
|
80
80
|
} catch {
|
|
81
81
|
throw new Error("Invalid JSON from product_groupings endpoint");
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
function
|
|
85
|
-
const { product: t, index:
|
|
84
|
+
function O(e) {
|
|
85
|
+
const { product: t, index: r, discountType: n, onClick: s, onAddToCart: i, renderCard: a } = e, d = e.i18n, m = e.pricing;
|
|
86
86
|
if (e.renderCardElement) {
|
|
87
|
-
const o = e.renderCardElement(t,
|
|
87
|
+
const o = e.renderCardElement(t, r);
|
|
88
88
|
if (o) return o;
|
|
89
89
|
}
|
|
90
90
|
if (a) {
|
|
91
91
|
const o = document.createElement("div");
|
|
92
|
-
return o.className = "gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive", o.dataset.gengagePart = "simrel-product-card", o.innerHTML = H(a(t,
|
|
92
|
+
return o.className = "gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive", o.dataset.gengagePart = "simrel-product-card", o.innerHTML = H(a(t, r)), o.addEventListener("click", (c) => {
|
|
93
93
|
c.target.closest(".gengage-simrel-atc") || c.target.closest(".gengage-chat-product-card-atc") || s(t);
|
|
94
94
|
}), o;
|
|
95
95
|
}
|
|
96
96
|
const l = document.createElement("article");
|
|
97
97
|
l.className = "gengage-simrel-card gengage-chat-product-card gds-card gds-product-card gds-card-interactive", l.dataset.gengagePart = "simrel-product-card", t.inStock === !1 && l.classList.add("gengage-simrel-card--out-of-stock"), l.setAttribute("role", "listitem"), l.dataset.sku = t.sku;
|
|
98
98
|
const g = document.createElement("div");
|
|
99
|
-
if (g.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", g.dataset.gengagePart = "simrel-product-card-image", t.imageUrl &&
|
|
99
|
+
if (g.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", g.dataset.gengagePart = "simrel-product-card-image", t.imageUrl && $(t.imageUrl)) {
|
|
100
100
|
const o = document.createElement("img");
|
|
101
|
-
o.className = "gengage-chat-product-card-img", o.src = t.imageUrl, o.alt = t.name, o.loading = "lazy",
|
|
101
|
+
o.className = "gengage-chat-product-card-img", o.src = t.imageUrl, o.alt = t.name, o.loading = "lazy", X(o), g.appendChild(o);
|
|
102
102
|
}
|
|
103
|
-
if (
|
|
103
|
+
if (n === "badge" && t.discountPercent && t.discountPercent > 0) {
|
|
104
104
|
const o = document.createElement("span");
|
|
105
|
-
o.className = "gengage-simrel-badge gengage-chat-product-card-discount-badge", o.textContent = `%${
|
|
105
|
+
o.className = "gengage-simrel-badge gengage-chat-product-card-discount-badge", o.textContent = `%${Z(t.discountPercent)}`, g.appendChild(o);
|
|
106
106
|
}
|
|
107
107
|
l.appendChild(g);
|
|
108
108
|
const u = document.createElement("div");
|
|
@@ -113,22 +113,22 @@ function G(e) {
|
|
|
113
113
|
const h = document.createElement("div");
|
|
114
114
|
if (h.className = "gengage-simrel-card-name gengage-chat-product-card-name", h.textContent = t.name, h.title = t.name, u.appendChild(h), t.rating != null && t.rating > 0) {
|
|
115
115
|
const o = document.createElement("div");
|
|
116
|
-
if (o.className = "gengage-simrel-card-rating gengage-chat-product-card-rating", o.appendChild(
|
|
116
|
+
if (o.className = "gengage-simrel-card-rating gengage-chat-product-card-rating", o.appendChild(Y(t.rating)), t.reviewCount != null) {
|
|
117
117
|
const c = document.createElement("span");
|
|
118
118
|
c.className = "gengage-simrel-card-review-count gengage-chat-product-card-review-count", c.textContent = ` (${t.reviewCount})`, o.appendChild(c);
|
|
119
119
|
}
|
|
120
120
|
u.appendChild(o);
|
|
121
121
|
}
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
122
|
+
const b = document.createElement("div");
|
|
123
|
+
if (b.className = "gengage-simrel-card-price gengage-chat-product-card-price", t.originalPrice && t.originalPrice !== t.price && (n === "strike-through" || n === "inline" || !n)) {
|
|
124
124
|
const o = document.createElement("span");
|
|
125
|
-
o.className = ["gengage-simrel-card-price-original", "gengage-chat-product-card-original-price"].join(" "),
|
|
125
|
+
o.className = ["gengage-simrel-card-price-original", "gengage-chat-product-card-original-price"].join(" "), n === "inline" && o.classList.add("gengage-simrel-card-price-original--inline"), o.textContent = w(t.originalPrice, m), b.appendChild(o);
|
|
126
126
|
}
|
|
127
127
|
if (t.price && parseFloat(t.price) > 0) {
|
|
128
128
|
const o = document.createElement("span");
|
|
129
|
-
o.className = "gengage-simrel-card-price-current gengage-chat-product-card-price-current", o.textContent =
|
|
129
|
+
o.className = "gengage-simrel-card-price-current gengage-chat-product-card-price-current", o.textContent = w(t.price, m), b.appendChild(o);
|
|
130
130
|
}
|
|
131
|
-
u.appendChild(
|
|
131
|
+
u.appendChild(b), l.appendChild(u);
|
|
132
132
|
const f = document.createElement("button");
|
|
133
133
|
if (f.className = "gengage-simrel-card-cta gengage-chat-product-card-cta gds-btn gds-btn-secondary", f.type = "button", f.dataset.gengagePart = "simrel-product-card-cta", f.textContent = d?.ctaLabel ?? "View", f.addEventListener("click", (o) => {
|
|
134
134
|
o.preventDefault(), o.stopPropagation(), s(t);
|
|
@@ -149,40 +149,44 @@ function G(e) {
|
|
|
149
149
|
o.target.closest(".gengage-simrel-atc") || o.target.closest(".gengage-chat-product-card-atc") || o.target.closest(".gengage-chat-product-card-cta") || s(t);
|
|
150
150
|
}), l;
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function P(e) {
|
|
153
153
|
const t = document.createElement("div");
|
|
154
154
|
t.className = "gengage-simrel-grid", t.setAttribute("role", "list"), t.setAttribute("aria-label", e.i18n?.similarProductsAriaLabel ?? "Similar products"), e.columns && t.style.setProperty("--gengage-simrel-columns", String(e.columns));
|
|
155
|
-
for (let
|
|
156
|
-
const
|
|
157
|
-
product: e.products[
|
|
158
|
-
index:
|
|
155
|
+
for (let r = 0; r < e.products.length; r++) {
|
|
156
|
+
const n = {
|
|
157
|
+
product: e.products[r],
|
|
158
|
+
index: r,
|
|
159
159
|
onClick: e.onClick,
|
|
160
160
|
onAddToCart: e.onAddToCart
|
|
161
161
|
};
|
|
162
|
-
e.i18n !== void 0 && (
|
|
163
|
-
const s =
|
|
162
|
+
e.i18n !== void 0 && (n.i18n = e.i18n), e.discountType !== void 0 && (n.discountType = e.discountType), e.renderCard !== void 0 && (n.renderCard = e.renderCard), e.renderCardElement !== void 0 && (n.renderCardElement = e.renderCardElement);
|
|
163
|
+
const s = O(n);
|
|
164
164
|
t.appendChild(s);
|
|
165
165
|
}
|
|
166
166
|
return e.products.length === 0 && (t.style.display = "none", t.dataset.empty = "true"), t;
|
|
167
167
|
}
|
|
168
|
-
var
|
|
169
|
-
function
|
|
170
|
-
const t =
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
168
|
+
var se = 0, S = /* @__PURE__ */ new WeakMap();
|
|
169
|
+
function oe(e) {
|
|
170
|
+
const t = S.get(e);
|
|
171
|
+
t && (t.disconnect(), S.delete(e));
|
|
172
|
+
}
|
|
173
|
+
function ae(e) {
|
|
174
|
+
const t = se++, r = document.createElement("div");
|
|
175
|
+
if (r.className = "gengage-simrel-groups", r.dataset.gengagePart = "simrel-groups", e.groups.length === 0)
|
|
176
|
+
return r.style.display = "none", r.dataset.empty = "true", r;
|
|
177
|
+
const n = document.createElement("div");
|
|
178
|
+
n.className = "gengage-simrel-tabs gds-toolbar", n.dataset.gengagePart = "simrel-tab-bar", n.setAttribute("role", "tablist");
|
|
175
179
|
const s = [], i = [];
|
|
176
180
|
let a = 0;
|
|
177
181
|
const d = (c) => {
|
|
178
|
-
const
|
|
182
|
+
const C = {
|
|
179
183
|
products: c.products,
|
|
180
184
|
onClick: e.onClick,
|
|
181
185
|
onAddToCart: e.onAddToCart
|
|
182
186
|
};
|
|
183
|
-
return e.i18n !== void 0 && (
|
|
184
|
-
}, m = (c,
|
|
185
|
-
if (
|
|
187
|
+
return e.i18n !== void 0 && (C.i18n = e.i18n), e.discountType !== void 0 && (C.discountType = e.discountType), e.renderCard !== void 0 && (C.renderCard = e.renderCard), e.renderCardElement !== void 0 && (C.renderCardElement = e.renderCardElement), e.columns !== void 0 && (C.columns = e.columns), C;
|
|
188
|
+
}, m = (c, C = !1) => {
|
|
189
|
+
if (C && c !== a && e.onGroupingActivate) {
|
|
186
190
|
const p = e.groups[c];
|
|
187
191
|
e.onGroupingActivate({
|
|
188
192
|
grouping_label: p.name,
|
|
@@ -196,19 +200,19 @@ function se(e) {
|
|
|
196
200
|
}
|
|
197
201
|
const T = e.groups[c], _ = i[c];
|
|
198
202
|
_.innerHTML = "";
|
|
199
|
-
const
|
|
200
|
-
_.appendChild(
|
|
203
|
+
const y = P(d(T));
|
|
204
|
+
_.appendChild(y);
|
|
201
205
|
for (let p = 0; p < i.length; p++) {
|
|
202
206
|
const v = p === c;
|
|
203
207
|
i[p].style.display = v ? "" : "none", i[p].tabIndex = v ? 0 : -1;
|
|
204
208
|
}
|
|
205
209
|
};
|
|
206
210
|
for (let c = 0; c < e.groups.length; c++) {
|
|
207
|
-
const
|
|
208
|
-
|
|
211
|
+
const C = e.groups[c], T = `gengage-simrel-tab-${t}-${c}`, _ = `gengage-simrel-panel-${t}-${c}`, y = document.createElement("button");
|
|
212
|
+
y.className = "gengage-simrel-tab gds-tab", y.type = "button", y.dataset.gengagePart = "simrel-tab", y.id = T, y.textContent = C.name, y.setAttribute("role", "tab"), y.setAttribute("aria-controls", _), y.setAttribute("aria-selected", String(c === 0)), y.tabIndex = c === 0 ? 0 : -1, c === 0 && y.classList.add("gengage-simrel-tab--active"), y.addEventListener("click", () => m(c, !0)), y.addEventListener("keydown", (v) => {
|
|
209
213
|
let E = -1;
|
|
210
214
|
v.key === "ArrowRight" || v.key === "ArrowDown" ? E = (c + 1) % e.groups.length : v.key === "ArrowLeft" || v.key === "ArrowUp" ? E = (c - 1 + e.groups.length) % e.groups.length : v.key === "Home" ? E = 0 : v.key === "End" && (E = e.groups.length - 1), E >= 0 && (v.preventDefault(), m(E, !0), s[E].focus());
|
|
211
|
-
}), s.push(
|
|
215
|
+
}), s.push(y), n.appendChild(y);
|
|
212
216
|
const p = document.createElement("div");
|
|
213
217
|
p.className = "gengage-simrel-tab-panel", p.dataset.gengagePart = "simrel-tab-panel", p.id = _, p.setAttribute("role", "tabpanel"), p.setAttribute("aria-labelledby", T), p.tabIndex = c === 0 ? 0 : -1, c !== 0 && (p.style.display = "none"), i.push(p);
|
|
214
218
|
}
|
|
@@ -218,181 +222,185 @@ function se(e) {
|
|
|
218
222
|
g.type = "button", g.className = "gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--right", g.setAttribute("aria-label", e.i18n?.scrollTabsRight ?? "Scroll tabs right"), g.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>';
|
|
219
223
|
const u = 200;
|
|
220
224
|
l.addEventListener("click", () => {
|
|
221
|
-
|
|
225
|
+
n.scrollBy({
|
|
222
226
|
left: -200,
|
|
223
227
|
behavior: "smooth"
|
|
224
228
|
});
|
|
225
229
|
}), g.addEventListener("click", () => {
|
|
226
|
-
|
|
230
|
+
n.scrollBy({
|
|
227
231
|
left: u,
|
|
228
232
|
behavior: "smooth"
|
|
229
233
|
});
|
|
230
234
|
});
|
|
231
235
|
const h = () => {
|
|
232
|
-
const c =
|
|
233
|
-
l.style.display = c ? "none" : "", g.style.display =
|
|
236
|
+
const c = n.scrollLeft <= 4, C = n.scrollLeft + n.clientWidth >= n.scrollWidth - 4;
|
|
237
|
+
l.style.display = c ? "none" : "", g.style.display = C ? "none" : "", n.classList.toggle("gengage-simrel-tabs--peek-right", !C), n.classList.toggle("gengage-simrel-tabs--peek-left", !c);
|
|
234
238
|
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
+
if (n.addEventListener("scroll", h, { passive: !0 }), typeof ResizeObserver < "u") {
|
|
240
|
+
const c = new ResizeObserver(h);
|
|
241
|
+
c.observe(n), S.set(r, c);
|
|
242
|
+
}
|
|
243
|
+
l.style.display = "none", g.style.display = "none", requestAnimationFrame(h);
|
|
244
|
+
const b = document.createElement("div");
|
|
245
|
+
b.className = "gengage-simrel-tabs-wrapper", b.appendChild(l), b.appendChild(n), b.appendChild(g), r.appendChild(b);
|
|
246
|
+
const f = i[0], o = P(d(e.groups[0]));
|
|
239
247
|
f.appendChild(o);
|
|
240
|
-
for (const c of i)
|
|
241
|
-
return
|
|
248
|
+
for (const c of i) r.appendChild(c);
|
|
249
|
+
return r;
|
|
242
250
|
}
|
|
243
|
-
function
|
|
251
|
+
function L(e) {
|
|
244
252
|
if (!e || typeof e != "object") return null;
|
|
245
253
|
const t = e;
|
|
246
254
|
if (typeof t.sku != "string" || typeof t.name != "string" || typeof t.url != "string") return null;
|
|
247
|
-
const
|
|
255
|
+
const r = {
|
|
248
256
|
sku: t.sku,
|
|
249
257
|
name: t.name,
|
|
250
258
|
url: t.url
|
|
251
|
-
},
|
|
252
|
-
typeof
|
|
259
|
+
}, n = t.imageUrl;
|
|
260
|
+
typeof n == "string" && (r.imageUrl = n);
|
|
253
261
|
const s = t.price;
|
|
254
|
-
typeof s == "string" && (
|
|
262
|
+
typeof s == "string" && (r.price = s);
|
|
255
263
|
const i = t.originalPrice;
|
|
256
|
-
typeof i == "string" && (
|
|
264
|
+
typeof i == "string" && (r.originalPrice = i);
|
|
257
265
|
const a = t.discountPercent;
|
|
258
|
-
typeof a == "number" && (
|
|
266
|
+
typeof a == "number" && (r.discountPercent = a);
|
|
259
267
|
const d = t.brand;
|
|
260
|
-
typeof d == "string" && (
|
|
268
|
+
typeof d == "string" && (r.brand = d);
|
|
261
269
|
const m = t.rating;
|
|
262
|
-
typeof m == "number" && (
|
|
270
|
+
typeof m == "number" && (r.rating = m);
|
|
263
271
|
const l = t.reviewCount;
|
|
264
|
-
typeof l == "number" && (
|
|
272
|
+
typeof l == "number" && (r.reviewCount = l);
|
|
265
273
|
const g = t.cartCode;
|
|
266
|
-
typeof g == "string" && (
|
|
274
|
+
typeof g == "string" && (r.cartCode = g);
|
|
267
275
|
const u = t.inStock;
|
|
268
|
-
typeof u == "boolean" && (
|
|
276
|
+
typeof u == "boolean" && (r.inStock = u);
|
|
269
277
|
const h = t.extras;
|
|
270
|
-
return h != null && typeof h == "object" && (
|
|
278
|
+
return h != null && typeof h == "object" && (r.extras = h), r;
|
|
271
279
|
}
|
|
272
|
-
function
|
|
280
|
+
function ce(e) {
|
|
273
281
|
if (!e || typeof e != "object") return null;
|
|
274
|
-
const t = e,
|
|
275
|
-
if (typeof
|
|
282
|
+
const t = e, r = t.title, n = t.type;
|
|
283
|
+
if (typeof r != "string" || typeof n != "string") return null;
|
|
276
284
|
const s = {
|
|
277
|
-
title:
|
|
278
|
-
type:
|
|
285
|
+
title: r,
|
|
286
|
+
type: n
|
|
279
287
|
};
|
|
280
288
|
return t.payload !== void 0 && (s.payload = t.payload), s;
|
|
281
289
|
}
|
|
282
|
-
var
|
|
283
|
-
ProductGrid: ({ element: e, renderElement: t, context:
|
|
284
|
-
const
|
|
285
|
-
|
|
290
|
+
var B = {
|
|
291
|
+
ProductGrid: ({ element: e, renderElement: t, context: r }) => {
|
|
292
|
+
const n = document.createElement("div");
|
|
293
|
+
n.className = "gengage-simrel-grid", n.setAttribute("role", "list");
|
|
286
294
|
const s = e.props?.columns;
|
|
287
295
|
let i;
|
|
288
|
-
typeof s == "number" && Number.isFinite(s) && s > 0 ? i = Math.floor(s) : typeof
|
|
296
|
+
typeof s == "number" && Number.isFinite(s) && s > 0 ? i = Math.floor(s) : typeof r.gridColumns == "number" && Number.isFinite(r.gridColumns) && r.gridColumns > 0 && (i = Math.floor(r.gridColumns)), i !== void 0 && n.style.setProperty("--gengage-simrel-columns", String(i));
|
|
289
297
|
for (const a of e.children ?? []) {
|
|
290
298
|
const d = t(a);
|
|
291
|
-
d &&
|
|
299
|
+
d && n.appendChild(d);
|
|
292
300
|
}
|
|
293
|
-
if (
|
|
301
|
+
if (n.children.length === 0) {
|
|
294
302
|
const a = document.createElement("div");
|
|
295
|
-
a.className = "gengage-simrel-empty", a.textContent =
|
|
303
|
+
a.className = "gengage-simrel-empty", a.textContent = r.i18n.emptyStateMessage, n.appendChild(a);
|
|
296
304
|
}
|
|
297
|
-
return
|
|
305
|
+
return n;
|
|
298
306
|
},
|
|
299
307
|
ProductCard: ({ element: e, context: t }) => {
|
|
300
|
-
const
|
|
301
|
-
if (!
|
|
302
|
-
const
|
|
303
|
-
product:
|
|
308
|
+
const r = L(e.props?.product ?? e.props);
|
|
309
|
+
if (!r) return null;
|
|
310
|
+
const n = e.props?.index, s = typeof n == "number" && Number.isFinite(n) ? n : 0, i = e.props?.discountType, a = i === "strike-through" || i === "badge" || i === "inline" ? i : t.discountType, d = {
|
|
311
|
+
product: r,
|
|
304
312
|
index: s,
|
|
305
313
|
onClick: t.onClick,
|
|
306
314
|
onAddToCart: t.onAddToCart,
|
|
307
315
|
i18n: t.i18n
|
|
308
316
|
};
|
|
309
|
-
return a !== void 0 && (d.discountType = a), t.renderCard !== void 0 && (d.renderCard = t.renderCard), t.renderCardElement !== void 0 && (d.renderCardElement = t.renderCardElement), t.pricing !== void 0 && (d.pricing = t.pricing),
|
|
317
|
+
return a !== void 0 && (d.discountType = a), t.renderCard !== void 0 && (d.renderCard = t.renderCard), t.renderCardElement !== void 0 && (d.renderCardElement = t.renderCardElement), t.pricing !== void 0 && (d.pricing = t.pricing), O(d);
|
|
310
318
|
},
|
|
311
319
|
GroupTabs: ({ element: e, context: t }) => {
|
|
312
|
-
const
|
|
313
|
-
if (!Array.isArray(
|
|
314
|
-
const
|
|
315
|
-
for (const a of
|
|
320
|
+
const r = e.props?.groups;
|
|
321
|
+
if (!Array.isArray(r)) return null;
|
|
322
|
+
const n = [];
|
|
323
|
+
for (const a of r) {
|
|
316
324
|
if (!a || typeof a != "object") continue;
|
|
317
325
|
const d = a;
|
|
318
326
|
if (typeof d.name != "string") continue;
|
|
319
327
|
const m = [];
|
|
320
328
|
if (Array.isArray(d.products)) for (const g of d.products) {
|
|
321
|
-
const u =
|
|
329
|
+
const u = L(g);
|
|
322
330
|
u && m.push(u);
|
|
323
331
|
}
|
|
324
332
|
const l = {
|
|
325
333
|
name: d.name,
|
|
326
334
|
products: m
|
|
327
335
|
};
|
|
328
|
-
typeof d.highlight == "string" && (l.highlight = d.highlight),
|
|
336
|
+
typeof d.highlight == "string" && (l.highlight = d.highlight), n.push(l);
|
|
329
337
|
}
|
|
330
338
|
const s = {
|
|
331
|
-
groups:
|
|
339
|
+
groups: n,
|
|
332
340
|
onClick: t.onClick,
|
|
333
341
|
onAddToCart: t.onAddToCart,
|
|
334
342
|
i18n: t.i18n
|
|
335
343
|
}, i = e.props?.columns;
|
|
336
|
-
return typeof i == "number" && Number.isFinite(i) && i > 0 ? s.columns = Math.floor(i) : typeof t.gridColumns == "number" && Number.isFinite(t.gridColumns) && t.gridColumns > 0 && (s.columns = Math.floor(t.gridColumns)), t.discountType !== void 0 && (s.discountType = t.discountType), t.renderCard !== void 0 && (s.renderCard = t.renderCard), t.renderCardElement !== void 0 && (s.renderCardElement = t.renderCardElement), t.onGroupingActivate !== void 0 && (s.onGroupingActivate = t.onGroupingActivate),
|
|
344
|
+
return typeof i == "number" && Number.isFinite(i) && i > 0 ? s.columns = Math.floor(i) : typeof t.gridColumns == "number" && Number.isFinite(t.gridColumns) && t.gridColumns > 0 && (s.columns = Math.floor(t.gridColumns)), t.discountType !== void 0 && (s.discountType = t.discountType), t.renderCard !== void 0 && (s.renderCard = t.renderCard), t.renderCardElement !== void 0 && (s.renderCardElement = t.renderCardElement), t.onGroupingActivate !== void 0 && (s.onGroupingActivate = t.onGroupingActivate), ae(s);
|
|
337
345
|
},
|
|
338
346
|
EmptyState: ({ element: e, context: t }) => {
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
const
|
|
342
|
-
return
|
|
347
|
+
const r = document.createElement("div");
|
|
348
|
+
r.className = "gengage-simrel-empty";
|
|
349
|
+
const n = e.props?.message;
|
|
350
|
+
return r.textContent = typeof n == "string" ? n : t.i18n.emptyStateMessage, r;
|
|
343
351
|
},
|
|
344
352
|
AddToCartButton: ({ element: e, context: t }) => {
|
|
345
|
-
const
|
|
346
|
-
if (typeof
|
|
353
|
+
const r = e.props?.sku, n = e.props?.cartCode;
|
|
354
|
+
if (typeof r != "string" || typeof n != "string") return null;
|
|
347
355
|
const s = document.createElement("button");
|
|
348
356
|
s.className = "gengage-simrel-atc gengage-chat-product-card-cta", s.type = "button";
|
|
349
357
|
const i = e.props?.label;
|
|
350
358
|
return s.textContent = typeof i == "string" ? i : t.i18n.addToCartButton, s.addEventListener("click", (a) => {
|
|
351
359
|
a.preventDefault(), a.stopPropagation(), t.onAddToCart({
|
|
352
|
-
sku:
|
|
360
|
+
sku: r,
|
|
353
361
|
quantity: 1,
|
|
354
|
-
cartCode:
|
|
362
|
+
cartCode: n
|
|
355
363
|
});
|
|
356
364
|
}), s;
|
|
357
365
|
},
|
|
358
366
|
QuickActions: ({ element: e, context: t }) => {
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
const
|
|
362
|
-
if (!Array.isArray(
|
|
363
|
-
for (const s of
|
|
367
|
+
const r = document.createElement("div");
|
|
368
|
+
r.className = "gengage-simrel-quick-actions";
|
|
369
|
+
const n = e.props?.actions;
|
|
370
|
+
if (!Array.isArray(n) || !t.onAction) return r;
|
|
371
|
+
for (const s of n) {
|
|
364
372
|
if (!s || typeof s != "object") continue;
|
|
365
|
-
const i = s, a = i.label, d =
|
|
373
|
+
const i = s, a = i.label, d = ce(i.action);
|
|
366
374
|
if (typeof a != "string" || !d) continue;
|
|
367
375
|
const m = document.createElement("button");
|
|
368
376
|
m.className = "gengage-simrel-quick-action", m.type = "button", m.textContent = a, m.addEventListener("click", (l) => {
|
|
369
377
|
l.preventDefault(), l.stopPropagation(), t.onAction?.(d);
|
|
370
|
-
}),
|
|
378
|
+
}), r.appendChild(m);
|
|
371
379
|
}
|
|
372
|
-
return
|
|
380
|
+
return r;
|
|
373
381
|
}
|
|
374
|
-
},
|
|
382
|
+
}, x = ({ element: e, renderElement: t }) => {
|
|
375
383
|
if (!e.children || e.children.length === 0) return null;
|
|
376
|
-
const
|
|
377
|
-
for (const
|
|
378
|
-
const s = t(
|
|
379
|
-
s &&
|
|
384
|
+
const r = document.createElement("div");
|
|
385
|
+
for (const n of e.children) {
|
|
386
|
+
const s = t(n);
|
|
387
|
+
s && r.appendChild(s);
|
|
380
388
|
}
|
|
381
|
-
return
|
|
389
|
+
return r;
|
|
382
390
|
};
|
|
383
|
-
function
|
|
384
|
-
return { ...
|
|
391
|
+
function de() {
|
|
392
|
+
return { ...B };
|
|
385
393
|
}
|
|
386
|
-
function
|
|
394
|
+
function le(e, t, r = B, n = x) {
|
|
387
395
|
return F({
|
|
388
396
|
spec: e,
|
|
389
397
|
context: t,
|
|
390
|
-
registry:
|
|
398
|
+
registry: r,
|
|
391
399
|
containerClassName: "gengage-simrel-uispec",
|
|
392
|
-
unknownRenderer:
|
|
400
|
+
unknownRenderer: n
|
|
393
401
|
});
|
|
394
402
|
}
|
|
395
|
-
var
|
|
403
|
+
var j = {
|
|
396
404
|
similarProductsAriaLabel: "Benzer ürünler",
|
|
397
405
|
emptyStateMessage: "Benzer ürün bulunamadı.",
|
|
398
406
|
addToCartButton: "Sepete Ekle",
|
|
@@ -405,7 +413,7 @@ var x = {
|
|
|
405
413
|
priceSuffix: " TL",
|
|
406
414
|
scrollTabsLeft: "Sola kaydır",
|
|
407
415
|
scrollTabsRight: "Sağa kaydır"
|
|
408
|
-
},
|
|
416
|
+
}, ge = {
|
|
409
417
|
similarProductsAriaLabel: "Similar products",
|
|
410
418
|
emptyStateMessage: "No similar products found.",
|
|
411
419
|
addToCartButton: "Add to cart",
|
|
@@ -419,26 +427,26 @@ var x = {
|
|
|
419
427
|
scrollTabsLeft: "Scroll tabs left",
|
|
420
428
|
scrollTabsRight: "Scroll tabs right"
|
|
421
429
|
};
|
|
422
|
-
function
|
|
430
|
+
function ue(e) {
|
|
423
431
|
return e ? e.toLowerCase().split("-")[0] ?? "tr" : "tr";
|
|
424
432
|
}
|
|
425
|
-
function ge(e) {
|
|
426
|
-
return le(e) === "en" ? de : x;
|
|
427
|
-
}
|
|
428
|
-
var ue = 12e4;
|
|
429
433
|
function pe(e) {
|
|
434
|
+
return ue(e) === "en" ? ge : j;
|
|
435
|
+
}
|
|
436
|
+
var me = 12e4;
|
|
437
|
+
function fe(e) {
|
|
430
438
|
return e instanceof DOMException && e.name === "AbortError";
|
|
431
439
|
}
|
|
432
|
-
var
|
|
440
|
+
var he = class extends Q {
|
|
433
441
|
constructor(...e) {
|
|
434
|
-
super(...e), this._abortController = null, this._contentEl = null, this._lastResultCount = -1, this._i18n =
|
|
442
|
+
super(...e), this._abortController = null, this._contentEl = null, this._lastResultCount = -1, this._i18n = j, this._pendingAddToCartKeys = /* @__PURE__ */ new Set();
|
|
435
443
|
}
|
|
436
444
|
async init(e) {
|
|
437
445
|
if (!this.isInitialised && (e.mountTarget === void 0 || e.mountTarget === null)) throw new Error("[gengage] SimRel mountTarget is required. Provide a merchant-owned mount before initializing.");
|
|
438
446
|
await super.init(e);
|
|
439
447
|
}
|
|
440
448
|
async onInit(e) {
|
|
441
|
-
this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-simrel-container", this._contentEl.dataset.gengagePart = "simrel-container", this._contentEl.lang =
|
|
449
|
+
this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-simrel-container", this._contentEl.dataset.gengagePart = "simrel-container", this._contentEl.lang = V(e.locale);
|
|
442
450
|
const t = this._clampGridColumns(e.gridColumns);
|
|
443
451
|
t !== void 0 && this._contentEl.style.setProperty("--gengage-simrel-columns", String(t)), this.root.appendChild(this._contentEl), this._lastSku = e.sku, await this._fetchAndRender(e.sku), W("simrel");
|
|
444
452
|
}
|
|
@@ -454,7 +462,7 @@ var me = class extends K {
|
|
|
454
462
|
onHide() {
|
|
455
463
|
}
|
|
456
464
|
onDestroy() {
|
|
457
|
-
this._abort(), this._contentEl && (this._contentEl.remove(), this._contentEl = null);
|
|
465
|
+
this._abort(), this._disposeRenderedGroupTabs(), this._contentEl && (this._contentEl.remove(), this._contentEl = null);
|
|
458
466
|
}
|
|
459
467
|
_handleProductClick(e) {
|
|
460
468
|
const t = {
|
|
@@ -463,13 +471,13 @@ var me = class extends K {
|
|
|
463
471
|
url: e.url
|
|
464
472
|
};
|
|
465
473
|
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
|
-
const
|
|
474
|
+
const r = this.config.session?.sessionId ?? null;
|
|
467
475
|
k("gengage:similar:product-click", {
|
|
468
476
|
sku: e.sku,
|
|
469
477
|
url: e.url,
|
|
470
|
-
sessionId:
|
|
478
|
+
sessionId: r,
|
|
471
479
|
productName: e.name
|
|
472
|
-
}), this.config.onProductNavigate?.(e.url, e.sku,
|
|
480
|
+
}), this.config.onProductNavigate?.(e.url, e.sku, r);
|
|
473
481
|
}
|
|
474
482
|
async _handleAddToCart(e) {
|
|
475
483
|
const t = `${e.sku}\0${e.cartCode}\0${e.quantity}`;
|
|
@@ -479,11 +487,11 @@ var me = class extends K {
|
|
|
479
487
|
if (this.config.onAddToCart === void 0) return;
|
|
480
488
|
try {
|
|
481
489
|
await Promise.resolve(this.config.onAddToCart(e));
|
|
482
|
-
} catch (
|
|
483
|
-
console.error("[gengage] simrel onAddToCart",
|
|
490
|
+
} catch (r) {
|
|
491
|
+
console.error("[gengage] simrel onAddToCart", r);
|
|
484
492
|
return;
|
|
485
493
|
}
|
|
486
|
-
|
|
494
|
+
J(e.sku, e.quantity), k("gengage:similar:add-to-cart", e);
|
|
487
495
|
} finally {
|
|
488
496
|
this._pendingAddToCartKeys.delete(t);
|
|
489
497
|
}
|
|
@@ -492,38 +500,41 @@ var me = class extends K {
|
|
|
492
500
|
_abort() {
|
|
493
501
|
this._abortController?.abort(), this._abortController = null;
|
|
494
502
|
}
|
|
503
|
+
_disposeRenderedGroupTabs() {
|
|
504
|
+
this._contentEl && this._contentEl.querySelectorAll('[data-gengage-part="simrel-groups"]').forEach((e) => oe(e));
|
|
505
|
+
}
|
|
495
506
|
_isSuperseded(e) {
|
|
496
507
|
return this._abortController?.signal !== e;
|
|
497
508
|
}
|
|
498
509
|
_emitSimilarProductsImpression(e, t) {
|
|
499
|
-
const
|
|
510
|
+
const r = this.config.session?.sessionId ?? null;
|
|
500
511
|
k("gengage:similar:products-impression", {
|
|
501
|
-
source_sku: this.config.sku,
|
|
512
|
+
source_sku: this._lastSku ?? this.config.sku,
|
|
502
513
|
product_count: e,
|
|
503
514
|
grouped: t,
|
|
504
|
-
sessionId:
|
|
515
|
+
sessionId: r
|
|
505
516
|
});
|
|
506
517
|
}
|
|
507
518
|
_resolveRequestTimeoutMs() {
|
|
508
519
|
const e = this.config.requestTimeoutMs;
|
|
509
|
-
return typeof e != "number" || !Number.isFinite(e) || e <= 0 ?
|
|
520
|
+
return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? me : Math.floor(e);
|
|
510
521
|
}
|
|
511
522
|
async _fetchAndRender(e) {
|
|
512
523
|
this._abort();
|
|
513
524
|
const t = new AbortController();
|
|
514
525
|
this._abortController = t;
|
|
515
|
-
const
|
|
516
|
-
let
|
|
526
|
+
const r = t.signal;
|
|
527
|
+
let n = !1;
|
|
517
528
|
const s = setTimeout(() => {
|
|
518
|
-
|
|
529
|
+
n = !0, t.abort();
|
|
519
530
|
}, this._resolveRequestTimeoutMs());
|
|
520
|
-
if (
|
|
521
|
-
this._contentEl.innerHTML = "", this._contentEl.style.display = "";
|
|
531
|
+
if (r.addEventListener("abort", () => clearTimeout(s), { once: !0 }), !this._contentEl) return;
|
|
532
|
+
this._disposeRenderedGroupTabs(), this._contentEl.innerHTML = "", this._contentEl.style.display = "";
|
|
522
533
|
const i = document.createElement("div");
|
|
523
534
|
i.className = "gengage-simrel-loading", i.dataset.gengagePart = "simrel-loading";
|
|
524
535
|
const a = document.createElement("div");
|
|
525
536
|
a.className = "gengage-simrel-spinner", a.dataset.gengagePart = "simrel-loading-spinner", i.appendChild(a), this._contentEl.appendChild(i);
|
|
526
|
-
const d = { middlewareUrl: this.config.middlewareUrl }, m =
|
|
537
|
+
const d = { middlewareUrl: this.config.middlewareUrl }, m = ee({
|
|
527
538
|
source: "simrel",
|
|
528
539
|
locale: this.config.locale
|
|
529
540
|
});
|
|
@@ -535,51 +546,52 @@ var me = class extends K {
|
|
|
535
546
|
sku: e
|
|
536
547
|
};
|
|
537
548
|
this.config.domain !== void 0 && (l.domain = this.config.domain);
|
|
538
|
-
const g = await
|
|
539
|
-
if (this._lastResultCount = g.length, !this._contentEl) return;
|
|
540
|
-
if (this._contentEl.innerHTML = "", g.length > 0 && this.config.enableProductGroupings !== !1) try {
|
|
541
|
-
const u = g.map((f) => f.sku), h = new Map(g.map((f) => [f.sku, f])),
|
|
549
|
+
const g = await re(l, d, r);
|
|
550
|
+
if (this._isSuperseded(r) || (this._lastResultCount = g.length, !this._contentEl)) return;
|
|
551
|
+
if (this._disposeRenderedGroupTabs(), this._contentEl.innerHTML = "", g.length > 0 && this.config.enableProductGroupings !== !1) try {
|
|
552
|
+
const u = g.map((f) => f.sku), h = new Map(g.map((f) => [f.sku, f])), b = (await ie({
|
|
542
553
|
account_id: this.config.accountId,
|
|
543
554
|
session_id: this.config.session?.sessionId ?? "",
|
|
544
555
|
correlation_id: this.config.session?.sessionId ?? "",
|
|
545
556
|
skus: u
|
|
546
|
-
}, d,
|
|
557
|
+
}, d, r)).map((f) => ({
|
|
547
558
|
...f,
|
|
548
559
|
products: f.products.map((o) => ({
|
|
549
560
|
...h.get(o.sku),
|
|
550
561
|
...o
|
|
551
562
|
})).filter((o) => typeof o.sku == "string" && typeof o.name == "string" && typeof o.url == "string")
|
|
552
563
|
})).filter((f) => f.products.length > 0);
|
|
553
|
-
if (
|
|
554
|
-
|
|
555
|
-
|
|
564
|
+
if (this._isSuperseded(r)) return;
|
|
565
|
+
if (b.length > 0 && this._contentEl) {
|
|
566
|
+
const f = this._buildGroupsSpec(b), o = this._renderUISpec(f);
|
|
567
|
+
this._contentEl.appendChild(o), A("simrel"), this._emitSimilarProductsImpression(b.reduce((c, C) => c + C.products.length, 0), !0);
|
|
556
568
|
return;
|
|
557
569
|
}
|
|
558
570
|
} catch {
|
|
559
571
|
}
|
|
560
|
-
if (this._isSuperseded(
|
|
572
|
+
if (this._isSuperseded(r)) return;
|
|
561
573
|
if (this._contentEl) {
|
|
562
574
|
const u = this._buildProductsSpec(g), h = this._renderUISpec(u);
|
|
563
575
|
this._contentEl.appendChild(h);
|
|
564
576
|
}
|
|
565
|
-
g.length > 0 &&
|
|
577
|
+
g.length > 0 && A("simrel"), this._emitSimilarProductsImpression(g.length, !1);
|
|
566
578
|
} catch (l) {
|
|
567
|
-
const g =
|
|
568
|
-
if (g && this._isSuperseded(
|
|
579
|
+
const g = fe(l);
|
|
580
|
+
if (g && this._isSuperseded(r)) return;
|
|
569
581
|
if (k("gengage:global:error", {
|
|
570
582
|
source: "simrel",
|
|
571
|
-
code: g &&
|
|
572
|
-
message:
|
|
583
|
+
code: g && n ? "REQUEST_TIMEOUT" : "FETCH_ERROR",
|
|
584
|
+
message: K(this.config.locale, l)
|
|
573
585
|
}), this._contentEl) {
|
|
574
|
-
this._contentEl.innerHTML = "";
|
|
586
|
+
this._disposeRenderedGroupTabs(), this._contentEl.innerHTML = "";
|
|
575
587
|
const u = document.createElement("div");
|
|
576
588
|
u.className = "gengage-simrel-error";
|
|
577
589
|
const h = document.createElement("span");
|
|
578
590
|
h.textContent = this._i18n.errorLoadingMessage, u.appendChild(h);
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
this._fetchAndRender(this.config.sku);
|
|
582
|
-
}), u.appendChild(
|
|
591
|
+
const b = document.createElement("button");
|
|
592
|
+
b.className = "gengage-simrel-retry", b.textContent = this._i18n.retryButtonText, b.addEventListener("click", () => {
|
|
593
|
+
this._fetchAndRender(this._lastSku ?? this.config.sku);
|
|
594
|
+
}), u.appendChild(b), this._contentEl.appendChild(u);
|
|
583
595
|
}
|
|
584
596
|
} finally {
|
|
585
597
|
clearTimeout(s), m();
|
|
@@ -591,45 +603,45 @@ var me = class extends K {
|
|
|
591
603
|
}
|
|
592
604
|
_resolveI18n(e) {
|
|
593
605
|
return {
|
|
594
|
-
...
|
|
606
|
+
...pe(e.locale),
|
|
595
607
|
...e.i18n
|
|
596
608
|
};
|
|
597
609
|
}
|
|
598
610
|
_resolveUISpecRegistry() {
|
|
599
|
-
return
|
|
611
|
+
return z(de(), this.config.renderer?.registry);
|
|
600
612
|
}
|
|
601
613
|
_buildRenderContext() {
|
|
602
614
|
const e = this.config.renderCard, t = {
|
|
603
|
-
onClick: (
|
|
604
|
-
onAddToCart: (
|
|
605
|
-
this._handleAddToCart(
|
|
615
|
+
onClick: (n) => this._handleProductClick(n),
|
|
616
|
+
onAddToCart: (n) => {
|
|
617
|
+
this._handleAddToCart(n);
|
|
606
618
|
},
|
|
607
|
-
onGroupingActivate: (
|
|
619
|
+
onGroupingActivate: (n) => {
|
|
608
620
|
k("gengage:similar:grouping-click", {
|
|
609
|
-
grouping_label:
|
|
610
|
-
grouping_index:
|
|
621
|
+
grouping_label: n.grouping_label,
|
|
622
|
+
grouping_index: n.grouping_index,
|
|
611
623
|
sessionId: this.config.session?.sessionId ?? null
|
|
612
624
|
});
|
|
613
625
|
},
|
|
614
626
|
i18n: this._i18n
|
|
615
627
|
};
|
|
616
628
|
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);
|
|
617
|
-
const
|
|
618
|
-
return
|
|
629
|
+
const r = this._clampGridColumns(this.config.gridColumns);
|
|
630
|
+
return r !== void 0 && (t.gridColumns = r), t;
|
|
619
631
|
}
|
|
620
632
|
_renderUISpec(e) {
|
|
621
|
-
const t = this._resolveUISpecRegistry(),
|
|
622
|
-
return i ? i(e,
|
|
633
|
+
const t = this._resolveUISpecRegistry(), r = this._buildRenderContext(), n = this.config.renderer?.unknownRenderer ?? x, s = (a, d) => le(a, d, t, n), i = this.config.renderer?.renderUISpec;
|
|
634
|
+
return i ? i(e, r, {
|
|
623
635
|
registry: t,
|
|
624
|
-
unknownRenderer:
|
|
636
|
+
unknownRenderer: n,
|
|
625
637
|
defaultRender: s
|
|
626
|
-
}) : s(e,
|
|
638
|
+
}) : s(e, r);
|
|
627
639
|
}
|
|
628
640
|
_buildProductsSpec(e) {
|
|
629
|
-
const t = {},
|
|
641
|
+
const t = {}, r = [];
|
|
630
642
|
for (let i = 0; i < e.length; i++) {
|
|
631
643
|
const a = e[i], d = `product-${i}`;
|
|
632
|
-
|
|
644
|
+
r.push(d), t[d] = {
|
|
633
645
|
type: "ProductCard",
|
|
634
646
|
props: {
|
|
635
647
|
product: a,
|
|
@@ -638,11 +650,11 @@ var me = class extends K {
|
|
|
638
650
|
}
|
|
639
651
|
};
|
|
640
652
|
}
|
|
641
|
-
const
|
|
642
|
-
return s !== void 0 && (
|
|
653
|
+
const n = { layout: "grid" }, s = this._clampGridColumns(this.config.gridColumns);
|
|
654
|
+
return s !== void 0 && (n.columns = s), t.root = {
|
|
643
655
|
type: "ProductGrid",
|
|
644
|
-
props:
|
|
645
|
-
children:
|
|
656
|
+
props: n,
|
|
657
|
+
children: r
|
|
646
658
|
}, {
|
|
647
659
|
root: "root",
|
|
648
660
|
elements: t
|
|
@@ -658,14 +670,14 @@ var me = class extends K {
|
|
|
658
670
|
};
|
|
659
671
|
}
|
|
660
672
|
};
|
|
661
|
-
function
|
|
662
|
-
return new
|
|
673
|
+
function ke() {
|
|
674
|
+
return new he();
|
|
663
675
|
}
|
|
664
676
|
export {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
677
|
+
le as a,
|
|
678
|
+
x as i,
|
|
679
|
+
ke as n,
|
|
680
|
+
ae as o,
|
|
681
|
+
de as r,
|
|
682
|
+
he as t
|
|
671
683
|
};
|