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