@gengage/assistant-fe 0.5.2 → 0.5.3
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/{api-paths-HBfd3rta.js → api-paths-DMmq3LCM.js} +1 -1
- package/dist/assistant-fe.css +1 -1
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +1 -1
- package/dist/chat.js +1 -1
- package/dist/{common-C_qmksoI.js → common-B5CTtAV7.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-BvPwMY8A.js → connection-warning-CFgiLUDI.js} +1 -1
- package/dist/{fastIntent-nyosR4rE.js → fastIntent-Cwg4fzKy.js} +1 -1
- package/dist/index.js +10 -10
- package/dist/native.iife.js +2 -2
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +1 -1
- package/dist/qna.js +1 -1
- package/dist/{runtime-CYG0iBGe.js → runtime-B6gNwfPX.js} +80 -80
- package/dist/{runtime-Rp4C5hl9.js → runtime-C4ee5aef.js} +3 -3
- package/dist/{runtime-y339ccTq.js → runtime-ChBUw8vy.js} +3 -3
- package/dist/{simbut-COq7dQRk.js → simbut-DHPn6j5P.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/{simrel-FETpOe2f.js → simrel-BBSrAbwm.js} +112 -101
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.css +2 -2
- package/dist/simrel.iife.js +5 -5
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-BcrlFdYt.js → widget-base-CJIr0DLe.js} +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { d as x, h as Q, p as R, r as N, t as H } from "./api-paths-
|
|
1
|
+
import { d as x, h as Q, p as R, r as N, t as H } from "./api-paths-DMmq3LCM.js";
|
|
2
2
|
import { A as O, D as U, E as j, a as q, v as M } from "./context-BBuSsXZ9.js";
|
|
3
|
-
import { o as F, t as W } from "./widget-base-
|
|
3
|
+
import { o as F, t as W } from "./widget-base-CJIr0DLe.js";
|
|
4
4
|
import { t as A } from "./locale-CfqNifrU.js";
|
|
5
|
-
import { n as D } from "./connection-warning-
|
|
5
|
+
import { n as D } from "./connection-warning-CFgiLUDI.js";
|
|
6
6
|
async function z(e, t, n) {
|
|
7
7
|
const o = H("launcher_action", t), i = {
|
|
8
8
|
uiSpecs: [],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as ba, d as va, h as xa, p as ya, r as wa, s as Gt, t as _a } from "./api-paths-
|
|
1
|
+
import { c as ba, d as va, h as xa, p as ya, r as wa, s as Gt, t as _a } from "./api-paths-DMmq3LCM.js";
|
|
2
2
|
import { A as _e, C as ka, D as Ca, E as Sa, M as oe, N as pe, O as Ea, S as mt, T as Pa, _ as La, a as xe, b as Aa, d as Ta, f as Ia, g as Ma, h as Na, j as me, l as Ba, m as za, p as Ra, u as Ha, v as Fa, w as ft, x as Da } from "./context-BBuSsXZ9.js";
|
|
3
|
-
import { i as Ne, s as $t, t as Oa } from "./widget-base-
|
|
4
|
-
import { a as le, i as Ua, n as ja, o as qa, r as Va, s as Ga, t as bt } from "./fastIntent-
|
|
3
|
+
import { i as Ne, s as $t, t as Oa } from "./widget-base-CJIr0DLe.js";
|
|
4
|
+
import { a as le, i as Ua, n as ja, o as qa, r as Va, s as Ga, t as bt } from "./fastIntent-Cwg4fzKy.js";
|
|
5
5
|
import { t as De } from "./locale-CfqNifrU.js";
|
|
6
6
|
import { a as Wt, i as Kt, n as ue, r as Yt, t as J } from "./price-formatter-xI3g9Cd4.js";
|
|
7
7
|
function vt() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as m, D as h, _ as u, j as f, v as p } from "./context-BBuSsXZ9.js";
|
|
2
|
-
import { t as b } from "./widget-base-
|
|
2
|
+
import { t as b } from "./widget-base-CJIr0DLe.js";
|
|
3
3
|
import { t as y } from "./locale-CfqNifrU.js";
|
|
4
4
|
var g = { findSimilarLabel: "Benzerlerini Bul" }, _ = { findSimilarLabel: "Find Similar" };
|
|
5
5
|
function S(t, n) {
|
package/dist/simbut.iife.js
CHANGED
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
transform: translateY(0);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`,document.head.appendChild(e)}var f=null;function Y(){if(f!==null)return f;try{f=localStorage.getItem("gengage:debug")==="1"}catch{f=!1}return f}function S(e,t,i){if(!Y())return;const n=[`[gengage:${e}]`,t];i!==void 0&&n.push(i),console.debug(...n)}var j=("0.5.
|
|
47
|
+
`,document.head.appendChild(e)}var f=null;function Y(){if(f!==null)return f;try{f=localStorage.getItem("gengage:debug")==="1"}catch{f=!1}return f}function S(e,t,i){if(!Y())return;const n=[`[gengage:${e}]`,t];i!==void 0&&n.push(i),console.debug(...n)}var j=("0.5.3".trim(),"0.5.3".trim()),J=("iife-build".trim(),"iife-build".trim());function K(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${j} (${J})`))}var Q=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const t=U(e.theme);K(),this.config={...e,theme:t,session:N(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),O();const i=x("gengage:context:update",n=>this.update(n));this._cleanups.push(i),S("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(n){throw this.destroy(),n}this._destroying||(this.isInitialised=!0,S("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:e.pageType!==void 0&&(this.config={...this.config,pageContext:e}),this.onUpdate(e),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(e,t){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t),()=>this._handlers.get(e)?.delete(t)}emit(e,...t){this._handlers.get(e)?.forEach(i=>i(...t))}addCleanup(e){this._cleanups.push(e)}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const i=document.querySelector(e);if(!i)throw new Error(`[gengage] Mount target not found: "${e}"`);return i}const t=document.createElement("div");return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(t,document.body.firstChild),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(const[t,i]of Object.entries(e))if(i!==void 0){const n=t.startsWith("--")?t:`--gengage-${X(t)}`;this.root.style.setProperty(n,i)}}}};function X(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Z(e){const t=e?.trim();return t||"tr"}var C={findSimilarLabel:"Benzerlerini Bul"},ee={findSimilarLabel:"Find Similar"};function te(e,t){return t?.findSimilarLabel?t.findSimilarLabel:(e??"tr").toLowerCase().startsWith("en")?ee.findSimilarLabel:C.findSimilarLabel}function h(e){const t=typeof e.sku=="string"&&e.sku.length>0?e.sku:void 0,i=typeof e.pageContext?.sku=="string"&&e.pageContext.sku.length>0?e.pageContext.sku:void 0;return t??i}var E=class extends Q{constructor(...e){super(...e),this._button=null,this._inlineFrame=null,this._label=C.findSimilarLabel}async onInit(e){this._label=te(e.locale,e.i18n);const t=e.layout??"overlay";this.root.classList.add("gengage-simbut-root"),this.root.classList.toggle("gengage-simbut-root--overlay",t==="overlay"),this.root.classList.toggle("gengage-simbut-root--inline-card",t==="inline-card"),t==="overlay"&&window.getComputedStyle(this.root).position==="static"&&(this.root.style.position="relative");const i=document.createElement("button");i.type="button",i.className="gengage-chat-find-similar-pill",i.lang=Z(e.locale),i.textContent=this._label,this._button=i;const n=()=>{i.disabled=!(h(this.config)&&(this.config.onFindSimilar||this.config.chat))};if(i.addEventListener("click",r=>{r.stopPropagation();const s=h(this.config);if(!s)return;const o=this.config.imageUrl,g=typeof o=="string"&&L(o)?o:void 0;if(F(this._label,"findSimilar"),R(s),this.config.onFindSimilar){this.config.onFindSimilar(g?{sku:s,imageUrl:g}:{sku:s});return}const u=this.config.chat;if(!u)return;const a={title:this._label,type:"findSimilar",payload:{sku:s}};u.openWithAction(a,{sku:s})}),t==="inline-card"){const r=this._createInlineCard(e,i);this._inlineFrame=r,this.root.appendChild(r)}else this.root.appendChild(i);n(),k("simbut")}_createInlineCard(e,t){const i=e.inlineCard,n=typeof i?.title=="string"?i.title.trim():"",r=typeof i?.description=="string"?i.description.trim():"",s=typeof i?.imageUrl=="string"?i.imageUrl.trim():"",o=document.createElement("section");o.className="gengage-simbut-inline-card",o.dataset.gengagePart="simbut-inline-card";const g=document.createElement("div");if(g.className="gengage-simbut-inline-copy",g.dataset.gengagePart="simbut-inline-copy",n){const a=document.createElement("h4");a.className="gengage-simbut-inline-title",a.dataset.gengagePart="simbut-inline-title",a.textContent=n,g.appendChild(a)}if(r){const a=document.createElement("p");a.className="gengage-simbut-inline-description",a.dataset.gengagePart="simbut-inline-description",a.textContent=r,g.appendChild(a)}g.children.length>0&&o.appendChild(g);const u=document.createElement("div");if(u.className="gengage-simbut-inline-action",u.dataset.gengagePart="simbut-inline-action",u.appendChild(t),o.appendChild(u),s&&I(s)){const a=document.createElement("img");a.className="gengage-simbut-inline-image",a.dataset.gengagePart="simbut-inline-image",a.src=s,a.alt=typeof i?.imageAlt=="string"?i.imageAlt:"",a.loading="lazy",a.addEventListener("error",()=>{a.style.display="none"},{once:!0}),o.appendChild(a)}return o}onUpdate(e){if(!this._button)return;const t=!!h(this.config)&&(!!this.config.onFindSimilar||!!this.config.chat);this._button.disabled=!t}hide(){this.isVisible&&(this.isVisible=!1,this._inlineFrame&&(this._inlineFrame.style.display="none"),this._button&&(this._button.style.display="none"),this.onHide(),this.emit("hide"))}show(){this.isVisible||(this.isVisible=!0,this._inlineFrame&&(this._inlineFrame.style.display=""),this._button&&(this._button.style.display=""),this.onShow(),this.emit("show"))}_cleanupRoot(){}onShow(){}onHide(){}onDestroy(){this._inlineFrame?.remove(),this._inlineFrame=null,this._button?.remove(),this._button=null}setChat(e){if(this.config.chat=e,this._button){const t=!!h(this.config)&&(!!this.config.onFindSimilar||!!this.config.chat);this._button.disabled=!t}}};function ie(){return new E}m.GengageSimBut=E,m.createSimButWidget=ie})(this.Gengage=this.Gengage||{});
|
package/dist/simbut.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A, j as S } from "./context-BBuSsXZ9.js";
|
|
2
|
-
import { n as $, t as
|
|
2
|
+
import { n as $, t as L } from "./price-formatter-xI3g9Cd4.js";
|
|
3
3
|
import { a as C, c as f, n as q, o as h, t as k, u as H } from "./schemas-CLo8wCjs.js";
|
|
4
|
-
import { o as j } from "./runtime-
|
|
4
|
+
import { o as j } from "./runtime-B6gNwfPX.js";
|
|
5
5
|
var V = {
|
|
6
6
|
images: [
|
|
7
7
|
"images",
|
|
@@ -94,7 +94,7 @@ function F(e) {
|
|
|
94
94
|
const t = p(e);
|
|
95
95
|
return t ? [t] : [];
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function B(e) {
|
|
98
98
|
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
99
99
|
if (typeof e == "string") {
|
|
100
100
|
const t = Number.parseFloat(e);
|
|
@@ -131,7 +131,7 @@ function D(e) {
|
|
|
131
131
|
name: a,
|
|
132
132
|
url: n
|
|
133
133
|
};
|
|
134
|
-
for (const [i,
|
|
134
|
+
for (const [i, s] of Object.entries(t)) s !== void 0 && (o[i] = s);
|
|
135
135
|
return o;
|
|
136
136
|
}
|
|
137
137
|
function z(e) {
|
|
@@ -141,8 +141,8 @@ function z(e) {
|
|
|
141
141
|
if (!r) return null;
|
|
142
142
|
const a = [];
|
|
143
143
|
if (Array.isArray(t.products)) for (const i of t.products) {
|
|
144
|
-
const
|
|
145
|
-
|
|
144
|
+
const s = D(i);
|
|
145
|
+
s && a.push(s);
|
|
146
146
|
}
|
|
147
147
|
const n = {
|
|
148
148
|
name: r,
|
|
@@ -150,7 +150,7 @@ function z(e) {
|
|
|
150
150
|
}, o = p(t.highlight);
|
|
151
151
|
return o && (n.highlight = o), n;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function _(e, t) {
|
|
154
154
|
const r = typeof t == "string" ? t.split(".") : [...t];
|
|
155
155
|
let a = e;
|
|
156
156
|
for (const n of r) {
|
|
@@ -169,20 +169,20 @@ function w(e, t) {
|
|
|
169
169
|
}
|
|
170
170
|
function Q(e, t) {
|
|
171
171
|
for (const r of t) {
|
|
172
|
-
const a =
|
|
172
|
+
const a = _(e, r);
|
|
173
173
|
if (a != null) return a;
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function w(e, t) {
|
|
177
177
|
for (const r of t) {
|
|
178
|
-
const a = F(
|
|
178
|
+
const a = F(_(e, r));
|
|
179
179
|
if (a.length > 0) return a;
|
|
180
180
|
}
|
|
181
181
|
return [];
|
|
182
182
|
}
|
|
183
183
|
function y(e, t) {
|
|
184
184
|
for (const r of t) {
|
|
185
|
-
const a =
|
|
185
|
+
const a = _(e, r), n = p(a);
|
|
186
186
|
if (n) return n;
|
|
187
187
|
const o = F(a);
|
|
188
188
|
if (o.length > 0) return o[0];
|
|
@@ -190,7 +190,7 @@ function y(e, t) {
|
|
|
190
190
|
}
|
|
191
191
|
function W(e, t) {
|
|
192
192
|
for (const r of t) {
|
|
193
|
-
const a = E(
|
|
193
|
+
const a = E(_(e, r));
|
|
194
194
|
if (a) return a;
|
|
195
195
|
}
|
|
196
196
|
return null;
|
|
@@ -265,8 +265,8 @@ function Y(e, t, r) {
|
|
|
265
265
|
a.className = "gengage-simrel-default-card-image";
|
|
266
266
|
let n = null;
|
|
267
267
|
return r.length > 0 && (n = document.createElement("img"), n.src = r[0], n.alt = t, n.loading = "lazy", $(n), a.appendChild(n)), r.length > 1 && n && (a.addEventListener("mousemove", (o) => {
|
|
268
|
-
const i = a.getBoundingClientRect(),
|
|
269
|
-
n?.dataset.hoverIdx !== String(
|
|
268
|
+
const i = a.getBoundingClientRect(), s = Math.min(Math.floor((o.clientX - i.left) / i.width * r.length), r.length - 1);
|
|
269
|
+
n?.dataset.hoverIdx !== String(s) && (n.dataset.hoverIdx = String(s), n.src = r[s], e.querySelectorAll(".gengage-simrel-default-card-image-dot").forEach((u, m) => u.classList.toggle("is-active", m === s)));
|
|
270
270
|
}), a.addEventListener("mouseleave", () => {
|
|
271
271
|
n && (delete n.dataset.hoverIdx, n.src = r[0], e.querySelectorAll(".gengage-simrel-default-card-image-dot").forEach((o, i) => o.classList.toggle("is-active", i === 0)));
|
|
272
272
|
})), a;
|
|
@@ -287,32 +287,32 @@ function ee(e, t, r) {
|
|
|
287
287
|
const a = document.createElement("div");
|
|
288
288
|
return a.className = "gengage-simrel-default-card-image-dots", e.forEach((n, o) => {
|
|
289
289
|
const i = document.createElement("button");
|
|
290
|
-
i.className = `gengage-simrel-default-card-image-dot${o === 0 ? " is-active" : ""}`, i.type = "button", i.setAttribute("aria-label", r.labels.imageDot(o)), i.addEventListener("click", (
|
|
291
|
-
|
|
290
|
+
i.className = `gengage-simrel-default-card-image-dot${o === 0 ? " is-active" : ""}`, i.type = "button", i.setAttribute("aria-label", r.labels.imageDot(o)), i.addEventListener("click", (s) => {
|
|
291
|
+
s.preventDefault(), s.stopPropagation(), t.dataset.hoverIdx = String(o), t.style.opacity = "0", window.setTimeout(() => {
|
|
292
292
|
t.src = n, t.style.opacity = "1";
|
|
293
|
-
}, 50), a.querySelectorAll(".gengage-simrel-default-card-image-dot").forEach((
|
|
293
|
+
}, 50), a.querySelectorAll(".gengage-simrel-default-card-image-dot").forEach((u, m) => u.classList.toggle("is-active", m === o));
|
|
294
294
|
}), a.appendChild(i);
|
|
295
295
|
}), a;
|
|
296
296
|
}
|
|
297
297
|
function te(e, t, r, a) {
|
|
298
298
|
const n = e.reviewCount ?? 0, o = e.rating ?? 0, i = document.createElement("div");
|
|
299
299
|
i.className = "gengage-simrel-default-card-rating", n <= 0 && !r.productInfoLabel && i.classList.add("is-placeholder");
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
const
|
|
305
|
-
for (let
|
|
306
|
-
const
|
|
307
|
-
|
|
300
|
+
const s = document.createElement("div");
|
|
301
|
+
s.className = "gengage-simrel-default-card-rating-left";
|
|
302
|
+
const u = document.createElement("div");
|
|
303
|
+
u.className = "gengage-simrel-default-card-stars";
|
|
304
|
+
const m = Math.max(0, Math.min(5, Math.round(o)));
|
|
305
|
+
for (let c = 1; c <= 5; c += 1) {
|
|
306
|
+
const d = document.createElement("span");
|
|
307
|
+
d.className = `gengage-simrel-default-card-star${c <= m ? " is-filled" : ""}`, d.textContent = "★", u.appendChild(d);
|
|
308
308
|
}
|
|
309
|
-
|
|
310
|
-
const
|
|
311
|
-
if (
|
|
312
|
-
|
|
313
|
-
}),
|
|
314
|
-
const
|
|
315
|
-
|
|
309
|
+
s.appendChild(u);
|
|
310
|
+
const l = document.createElement("button");
|
|
311
|
+
if (l.className = "gengage-simrel-default-card-review-link", l.type = "button", l.textContent = r.reviewLabel(n), l.addEventListener("click", (c) => {
|
|
312
|
+
c.preventDefault(), c.stopPropagation(), a(e);
|
|
313
|
+
}), s.appendChild(l), i.appendChild(s), r.productInfoLabel) {
|
|
314
|
+
const c = document.createElement(t && S(t) ? "a" : "span");
|
|
315
|
+
c.className = "gengage-simrel-default-card-product-info-link", c.textContent = r.productInfoLabel, c instanceof HTMLAnchorElement && (c.href = t, c.target = "_blank", c.rel = "noopener noreferrer", c.addEventListener("click", (d) => d.stopPropagation())), i.appendChild(c);
|
|
316
316
|
}
|
|
317
317
|
return i;
|
|
318
318
|
}
|
|
@@ -341,79 +341,86 @@ function ae(e, t) {
|
|
|
341
341
|
if (n.appendChild(o), a.appendChild(n), e.length > 1) {
|
|
342
342
|
const i = document.createElement("div");
|
|
343
343
|
i.className = "gengage-simrel-default-card-feature-arrows";
|
|
344
|
-
const
|
|
345
|
-
const
|
|
346
|
-
o.classList.add(
|
|
347
|
-
o.classList.remove(
|
|
344
|
+
const s = (l, c) => {
|
|
345
|
+
const d = c === "next" ? "slide-out-left" : "slide-out-right", v = c === "next" ? "prepare-from-right" : "prepare-from-left";
|
|
346
|
+
o.classList.add(d), window.setTimeout(() => {
|
|
347
|
+
o.classList.remove(d), o.classList.add(v), o.textContent = e[l] ?? "", a.dataset.current = String(l), requestAnimationFrame(() => requestAnimationFrame(() => o.classList.remove(v)));
|
|
348
348
|
}, 250);
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
|
|
349
|
+
}, u = document.createElement("button");
|
|
350
|
+
u.className = "gengage-simrel-default-card-feature-prev", u.type = "button", u.textContent = "‹", u.setAttribute("aria-label", t.labels.previousPromotion), u.addEventListener("click", (l) => {
|
|
351
|
+
l.preventDefault(), l.stopPropagation(), s((Number.parseInt(a.dataset.current ?? "0", 10) - 1 + e.length) % e.length, "prev");
|
|
352
352
|
});
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}), i.appendChild(
|
|
353
|
+
const m = document.createElement("button");
|
|
354
|
+
m.className = "gengage-simrel-default-card-feature-next", m.type = "button", m.textContent = "›", m.setAttribute("aria-label", t.labels.nextPromotion), m.addEventListener("click", (l) => {
|
|
355
|
+
l.preventDefault(), l.stopPropagation(), s((Number.parseInt(a.dataset.current ?? "0", 10) + 1) % e.length, "next");
|
|
356
|
+
}), i.appendChild(u), i.appendChild(m), a.appendChild(i);
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
return r.appendChild(a), r;
|
|
360
360
|
}
|
|
361
|
-
function ne(e, t, r, a) {
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
if (
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
361
|
+
function ne(e, t, r, a, n) {
|
|
362
|
+
const o = B(e.originalPrice), i = B(e.price), s = i !== void 0 && o !== void 0 && i > 0 && o > 0 && i < o, u = document.createElement("div");
|
|
363
|
+
u.className = "gengage-simrel-default-card-price-action";
|
|
364
|
+
const m = document.createElement("div");
|
|
365
|
+
if (m.className = "gengage-simrel-default-card-price", s) {
|
|
366
|
+
const l = n === "inline" ? "gengage-simrel-default-card-price-old gengage-simrel-default-card-price-old--inline" : "gengage-simrel-default-card-price-old";
|
|
367
|
+
m.appendChild(x("span", l, L(String(o), r.pricing)));
|
|
368
|
+
const c = document.createElement("div");
|
|
369
|
+
if (c.className = "gengage-simrel-default-card-price-current-row", c.appendChild(x("span", "gengage-simrel-default-card-price-current", L(String(i), r.pricing))), t && r.media.specialPriceBadgeUrl && A(r.media.specialPriceBadgeUrl)) {
|
|
369
370
|
const d = document.createElement("img");
|
|
370
|
-
d.src = r.media.specialPriceBadgeUrl, d.className = "gengage-simrel-default-card-special-price-badge", d.alt = r.specialPriceBadgeAlt,
|
|
371
|
+
d.src = r.media.specialPriceBadgeUrl, d.className = "gengage-simrel-default-card-special-price-badge", d.alt = r.specialPriceBadgeAlt, c.appendChild(d);
|
|
371
372
|
}
|
|
372
|
-
|
|
373
|
+
m.appendChild(c);
|
|
373
374
|
} else {
|
|
374
|
-
const
|
|
375
|
-
|
|
375
|
+
const l = o ?? i;
|
|
376
|
+
m.appendChild(x("span", "gengage-simrel-default-card-price-current", l !== void 0 ? L(String(l), r.pricing) : ""));
|
|
376
377
|
}
|
|
377
|
-
if (
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}),
|
|
378
|
+
if (u.appendChild(m), r.ctaLabel) {
|
|
379
|
+
const l = document.createElement("button");
|
|
380
|
+
l.className = "gengage-simrel-default-card-cta", l.dataset.gengagePart = "simrel-product-card-cta", l.type = "button", l.dataset.sku = e.sku, l.textContent = r.ctaLabel, l.addEventListener("click", (c) => {
|
|
381
|
+
c.preventDefault(), c.stopPropagation(), a(e);
|
|
382
|
+
}), u.appendChild(l);
|
|
382
383
|
}
|
|
383
|
-
return
|
|
384
|
+
return u;
|
|
385
|
+
}
|
|
386
|
+
function oe(e, t) {
|
|
387
|
+
return e === "strike-through" || e === "badge" || e === "inline" ? e : t.discountType;
|
|
384
388
|
}
|
|
385
389
|
function M(e) {
|
|
386
|
-
const { product: t, config: r } = e, a =
|
|
387
|
-
|
|
388
|
-
const v = Y(
|
|
389
|
-
|
|
390
|
+
const { product: t, config: r } = e, a = w(t, r.fields.images).map((g) => X(g, t, r)).filter(A), n = w(t, r.fields.promotions), o = n.filter((g) => r.warrantyPromotionPattern.test(g)), i = n.filter((g) => !r.warrantyPromotionPattern.test(g)), s = y(t, r.fields.subtitle) ?? "", u = y(t, r.fields.discountReason) ?? "", m = O(Q(t, r.fields.specialPrice)) === !0 || r.specialPricePattern.test(u), l = t.brand ?? "", c = J(l && t.name.startsWith(`${l} `) ? t.name.slice(l.length + 1) : t.name, s), d = document.createElement("article");
|
|
391
|
+
d.className = "gengage-simrel-default-card gengage-simrel-default-scope gengage-simrel-card gds-card gds-product-card gds-card-interactive", d.dataset.gengagePart = "simrel-product-card", d.setAttribute("role", "listitem"), d.setAttribute("tabindex", "0"), d.setAttribute("aria-label", c), d.dataset.sku = t.sku, d.dataset.index = String(e.index);
|
|
392
|
+
const v = Y(d, c, a);
|
|
393
|
+
d.appendChild(v);
|
|
390
394
|
const G = v.querySelector("img"), P = document.createElement("div");
|
|
391
395
|
P.className = "gengage-simrel-default-card-meta-row";
|
|
392
396
|
const N = Z(K(t, r), r.labels.customBadgeAlt);
|
|
393
397
|
N && P.appendChild(N);
|
|
394
398
|
const I = ee(a, G, r);
|
|
395
|
-
I && P.appendChild(I),
|
|
399
|
+
I && P.appendChild(I), d.appendChild(P);
|
|
396
400
|
const b = document.createElement("div");
|
|
397
|
-
return b.className = "gengage-simrel-default-card-info", b.dataset.gengagePart = "simrel-product-card-body", b.appendChild(x("h3", "gengage-simrel-default-card-title",
|
|
401
|
+
return b.className = "gengage-simrel-default-card-info", b.dataset.gengagePart = "simrel-product-card-body", b.appendChild(x("h3", "gengage-simrel-default-card-title", c)), s && b.appendChild(x("p", "gengage-simrel-default-card-subtitle", s)), b.appendChild(te(t, y(t, r.fields.productInfoUrl), r, e.context.onClick)), b.appendChild(re([...w(t, r.fields.warranties), ...o])), b.appendChild(ae(i, r)), d.appendChild(b), d.appendChild(ne(t, m, r, e.context.onClick, e.context.discountType)), d.addEventListener("click", (g) => {
|
|
398
402
|
(g.target instanceof HTMLElement ? g.target : null)?.closest("button, a") || e.context.onClick(t);
|
|
399
|
-
}),
|
|
403
|
+
}), d.addEventListener("keydown", (g) => {
|
|
400
404
|
if (g.key !== "Enter" && g.key !== " ") return;
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
}),
|
|
405
|
+
const T = g.target instanceof HTMLElement ? g.target : null;
|
|
406
|
+
T && T !== d || (g.preventDefault(), e.context.onClick(t));
|
|
407
|
+
}), d;
|
|
404
408
|
}
|
|
405
|
-
function
|
|
409
|
+
function ie(e, t) {
|
|
406
410
|
const r = D(e.element.props?.product ?? e.element.props);
|
|
407
411
|
if (!r) return null;
|
|
408
|
-
const a = e.element.props?.index;
|
|
412
|
+
const a = e.element.props?.index, n = typeof a == "number" && Number.isFinite(a) ? a : 0, o = oe(e.element.props?.discountType, e.context);
|
|
409
413
|
return M({
|
|
410
414
|
product: r,
|
|
411
|
-
index:
|
|
412
|
-
context: e.context
|
|
415
|
+
index: n,
|
|
416
|
+
context: o === e.context.discountType ? e.context : {
|
|
417
|
+
...e.context,
|
|
418
|
+
...o !== void 0 ? { discountType: o } : {}
|
|
419
|
+
},
|
|
413
420
|
config: R(t, e.context)
|
|
414
421
|
});
|
|
415
422
|
}
|
|
416
|
-
function
|
|
423
|
+
function le(e) {
|
|
417
424
|
const t = document.createElement("div");
|
|
418
425
|
t.className = "gengage-simrel-grid gengage-simrel-default-grid gengage-simrel-default-scope", t.setAttribute("role", "list");
|
|
419
426
|
const r = e.element.props?.columns;
|
|
@@ -429,15 +436,15 @@ function ie(e) {
|
|
|
429
436
|
}
|
|
430
437
|
return t;
|
|
431
438
|
}
|
|
432
|
-
function
|
|
439
|
+
function se(e, t) {
|
|
433
440
|
const r = e.element.props?.groups;
|
|
434
441
|
if (!Array.isArray(r)) return null;
|
|
435
|
-
const a = r.map(z).filter((
|
|
436
|
-
product:
|
|
437
|
-
index:
|
|
442
|
+
const a = r.map(z).filter((u) => !!u), n = e.element.props?.columns, o = R(t, e.context), i = (u, m) => M({
|
|
443
|
+
product: u,
|
|
444
|
+
index: m,
|
|
438
445
|
context: e.context,
|
|
439
446
|
config: o
|
|
440
|
-
}),
|
|
447
|
+
}), s = j({
|
|
441
448
|
groups: a,
|
|
442
449
|
onClick: e.context.onClick,
|
|
443
450
|
onAddToCart: e.context.onAddToCart,
|
|
@@ -447,16 +454,16 @@ function le(e, t) {
|
|
|
447
454
|
...e.context.onGroupingActivate !== void 0 ? { onGroupingActivate: e.context.onGroupingActivate } : {},
|
|
448
455
|
...typeof n == "number" && Number.isFinite(n) && n > 0 ? { columns: Math.floor(n) } : e.context.gridColumns !== void 0 ? { columns: e.context.gridColumns } : {}
|
|
449
456
|
});
|
|
450
|
-
return
|
|
457
|
+
return s.classList.add("gengage-simrel-default-groups", "gengage-simrel-default-scope"), s;
|
|
451
458
|
}
|
|
452
|
-
function
|
|
459
|
+
function ve(e = {}) {
|
|
453
460
|
return { registry: {
|
|
454
|
-
ProductGrid: (t) =>
|
|
455
|
-
ProductCard: (t) =>
|
|
456
|
-
GroupTabs: (t) =>
|
|
461
|
+
ProductGrid: (t) => le(t),
|
|
462
|
+
ProductCard: (t) => ie(t, e),
|
|
463
|
+
GroupTabs: (t) => se(t, e)
|
|
457
464
|
} };
|
|
458
465
|
}
|
|
459
|
-
var
|
|
466
|
+
var ce = h({
|
|
460
467
|
sku: f(),
|
|
461
468
|
name: f(),
|
|
462
469
|
imageUrl: f().url().optional(),
|
|
@@ -467,47 +474,51 @@ var se = h({
|
|
|
467
474
|
brand: f().optional(),
|
|
468
475
|
rating: C().min(0).max(5).optional(),
|
|
469
476
|
reviewCount: C().int().nonnegative().optional()
|
|
470
|
-
}),
|
|
477
|
+
}), de = h({
|
|
471
478
|
layout: k(["grid", "carousel"]).optional(),
|
|
472
479
|
columns: C().int().positive().optional()
|
|
473
|
-
}), de = h({
|
|
474
|
-
product: se,
|
|
475
|
-
index: C().int().nonnegative(),
|
|
476
|
-
discountType: k(["strike-through", "badge"]).optional()
|
|
477
480
|
}), ue = h({
|
|
481
|
+
product: ce,
|
|
482
|
+
index: C().int().nonnegative(),
|
|
483
|
+
discountType: k([
|
|
484
|
+
"strike-through",
|
|
485
|
+
"badge",
|
|
486
|
+
"inline"
|
|
487
|
+
]).optional()
|
|
488
|
+
}), me = h({
|
|
478
489
|
sku: f(),
|
|
479
490
|
label: f().optional(),
|
|
480
491
|
cartCode: f()
|
|
481
|
-
}),
|
|
492
|
+
}), ge = h({ actions: q(h({
|
|
482
493
|
label: f(),
|
|
483
494
|
action: h({
|
|
484
495
|
title: f(),
|
|
485
496
|
type: f(),
|
|
486
497
|
payload: H().optional()
|
|
487
498
|
})
|
|
488
|
-
})) }),
|
|
499
|
+
})) }), fe = h({ message: f().optional() }), Ce = { components: {
|
|
489
500
|
ProductGrid: {
|
|
490
|
-
schema:
|
|
501
|
+
schema: de,
|
|
491
502
|
description: "Outer grid or carousel container for similar products."
|
|
492
503
|
},
|
|
493
504
|
ProductCard: {
|
|
494
|
-
schema:
|
|
505
|
+
schema: ue,
|
|
495
506
|
description: "A single product card with image, title, price, and actions."
|
|
496
507
|
},
|
|
497
508
|
AddToCartButton: {
|
|
498
|
-
schema:
|
|
509
|
+
schema: me,
|
|
499
510
|
description: "Add-to-cart CTA rendered inside or below a product card."
|
|
500
511
|
},
|
|
501
512
|
QuickActions: {
|
|
502
|
-
schema:
|
|
513
|
+
schema: ge,
|
|
503
514
|
description: "A row of quick-action buttons below product info."
|
|
504
515
|
},
|
|
505
516
|
EmptyState: {
|
|
506
|
-
schema:
|
|
517
|
+
schema: fe,
|
|
507
518
|
description: "Empty state shown when no similar products are available."
|
|
508
519
|
}
|
|
509
520
|
} };
|
|
510
521
|
export {
|
|
511
|
-
|
|
512
|
-
|
|
522
|
+
ve as n,
|
|
523
|
+
Ce as t
|
|
513
524
|
};
|
package/dist/simrel-runtime.js
CHANGED