@gengage/assistant-fe 0.6.19 → 0.6.22
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/README.md +4 -2
- package/dist/agentic/adaptor/create-adaptor.d.ts +6 -3
- package/dist/agentic/adaptor/mount.d.ts +8 -2
- package/dist/agentic/{similarity.d.ts → algos/similarity.d.ts} +11 -2
- package/dist/agentic/algos/similarity.js +261 -0
- package/dist/agentic/context/chat-context.d.ts +4 -2
- package/dist/agentic/context/context-store.d.ts +11 -1
- package/dist/agentic/context/persistence.d.ts +1 -0
- package/dist/agentic/contracts/agentic-contracts.d.ts +133 -0
- package/dist/agentic/debug/activity-collector.d.ts +14 -0
- package/dist/agentic/debug/activity-instrumentation.d.ts +22 -0
- package/dist/agentic/debug/activity-overlay.d.ts +3 -0
- package/dist/agentic/debug/activity-state.d.ts +37 -0
- package/dist/agentic/debug/local-dev.d.ts +18 -0
- package/dist/agentic/events/product-normalize.d.ts +4 -1
- package/dist/agentic/events/ui-specs.d.ts +8 -4
- package/dist/agentic/index.d.ts +25 -2
- package/dist/agentic/index.js +2792 -441
- package/dist/agentic/types.d.ts +77 -4
- package/dist/agentic/util/common/declarative-cache.d.ts +21 -0
- package/dist/agentic/util/common/fallback-status.d.ts +10 -0
- package/dist/agentic/util/common/flow-steps.d.ts +8 -0
- package/dist/agentic/util/common/gss-tool-aliases.d.ts +66 -0
- package/dist/agentic/util/common/iframe-scraper.d.ts +22 -0
- package/dist/agentic/util/common/llm-routing.d.ts +50 -0
- package/dist/agentic/util/common/object.d.ts +1 -0
- package/dist/agentic/util/common/open-product-page.d.ts +30 -0
- package/dist/agentic/util/common/panel-context.d.ts +3 -0
- package/dist/agentic/util/common/privacy.d.ts +14 -0
- package/dist/agentic/util/common/product-resolver.d.ts +20 -0
- package/dist/agentic/util/common/product-surface.d.ts +24 -0
- package/dist/agentic/util/common/ref-store.d.ts +15 -0
- package/dist/agentic/util/common/retail-privacy.d.ts +4 -0
- package/dist/agentic/util/common/route-params.d.ts +3 -0
- package/dist/agentic/util/common/similarity-ranking.d.ts +2 -0
- package/dist/agentic/util/common/site-awareness.d.ts +130 -0
- package/dist/agentic/util/lazy-runtime-loader.d.ts +2 -1
- package/dist/agentic/worker/rpc.d.ts +26 -6
- package/dist/agentic/worker.d.ts +15 -2
- package/dist/agentic/worker.js +316 -119
- package/dist/agentic.iife.js +352 -6
- package/dist/{api-paths-lIioK7-S.js → api-paths-DE3_TyTw.js} +1 -1
- package/dist/chat/history-storage.d.ts +1 -0
- package/dist/chat/runtime.d.ts +1 -1
- package/dist/chat/types.d.ts +1 -0
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +10 -10
- package/dist/chat.js +1 -1
- package/dist/{common-8WOyaL9-.js → common-BWnFHbvv.js} +2 -2
- package/dist/common.js +8 -8
- package/dist/{connection-warning-CBR0CWsY.js → connection-warning-Tk4ZjgMi.js} +1 -1
- package/dist/{context-heG8hv5l.js → context-UTzCGyR9.js} +19 -8
- package/dist/{fastIntent-Dw79pmRK.js → fastIntent-DIhMlxVd.js} +2 -2
- package/dist/index.js +13 -13
- package/dist/{native-webview-NWc9LrJh.js → native-webview-BcwGKkDe.js} +1 -1
- package/dist/native.iife.js +6 -6
- package/dist/native.js +1 -1
- package/dist/{overlay-COzFFq0-.js → overlay-cF2SjxYU.js} +1 -1
- package/dist/overlay.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/route-params-5KSvTyeb.js +2454 -0
- package/dist/{runtime-BsnZ6gt2.js → runtime-CjJy8KKu.js} +4 -4
- package/dist/{runtime-w0f2VkzL.js → runtime-H5hNQQKm.js} +51 -48
- package/dist/{runtime-D5Sj-_tA.js → runtime-wEP7N2Hr.js} +4 -4
- package/dist/{simbut-BvdJtzCu.js → simbut-BlBLtgVy.js} +2 -2
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/{simrel-DU6a27g9.js → simrel-S6-OsWJ9.js} +2 -2
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +2 -2
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-BeWuIxD6.js → widget-base-e4JwEf2I.js} +2 -2
- package/package.json +5 -1
- package/dist/account-config-D_EMuR0g.js +0 -1479
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a as j, d as L, h as F, i as q, p as z, r as I, t as N } from "./api-paths-
|
|
2
|
-
import { A as D, E as S, N as H, a as k, l as $, v as W } from "./context-
|
|
3
|
-
import { o as J, t as K } from "./widget-base-
|
|
1
|
+
import { a as j, d as L, h as F, i as q, p as z, r as I, t as N } from "./api-paths-DE3_TyTw.js";
|
|
2
|
+
import { A as D, E as S, N as H, a as k, l as $, v as W } from "./context-UTzCGyR9.js";
|
|
3
|
+
import { o as J, t as K } from "./widget-base-e4JwEf2I.js";
|
|
4
4
|
import { t as Q } from "./locale-uQ5XZ2yS.js";
|
|
5
5
|
import { t as R } from "./request-response-cache-BxRsKGJ0.js";
|
|
6
6
|
import { a as V, n as Y, r as X, t as A } from "./price-formatter-CHUmYq8I.js";
|
|
7
|
-
import { n as Z } from "./connection-warning-
|
|
7
|
+
import { n as Z } from "./connection-warning-Tk4ZjgMi.js";
|
|
8
8
|
function M(e) {
|
|
9
9
|
const t = [];
|
|
10
10
|
for (const n of Object.values(e)) if (n.type === "ProductCard" && n.props) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as Sa, d as Ea, h as Pa, p as La, r as Ta, s as Zt, t as Aa } from "./api-paths-
|
|
2
|
-
import { A as ke, C as Ia, D as Ma, E as Na, M as ge, N as fe, O as Ba, S as xt, T as za, _ as Ra, a as we, b as Ha, d as Fa, f as Da, g as Ua, h as Oa, j as ve, l as ja, m as $a, p as qa, u as Va, v as Ga, w as et, x as Wa } from "./context-
|
|
3
|
-
import { i as ze, s as Xt, t as Ka } from "./widget-base-
|
|
4
|
-
import { d as pe, f as Ya, i as Za, n as Xa, p as Qa, r as Ja, t as yt, u as en } from "./fastIntent-
|
|
1
|
+
import { c as Sa, d as Ea, h as Pa, p as La, r as Ta, s as Zt, t as Aa } from "./api-paths-DE3_TyTw.js";
|
|
2
|
+
import { A as ke, C as Ia, D as Ma, E as Na, M as ge, N as fe, O as Ba, S as xt, T as za, _ as Ra, a as we, b as Ha, d as Fa, f as Da, g as Ua, h as Oa, j as ve, l as ja, m as $a, p as qa, u as Va, v as Ga, w as et, x as Wa } from "./context-UTzCGyR9.js";
|
|
3
|
+
import { i as ze, s as Xt, t as Ka } from "./widget-base-e4JwEf2I.js";
|
|
4
|
+
import { d as pe, f as Ya, i as Za, n as Xa, p as Qa, r as Ja, t as yt, u as en } from "./fastIntent-DIhMlxVd.js";
|
|
5
5
|
import { t as Oe } from "./locale-uQ5XZ2yS.js";
|
|
6
6
|
import { t as tn } from "./request-response-cache-BxRsKGJ0.js";
|
|
7
7
|
import { a as Qt, i as Jt, n as be, r as ea, t as ae } from "./price-formatter-CHUmYq8I.js";
|
|
@@ -400,6 +400,7 @@ var Re = {
|
|
|
400
400
|
favoritesAriaLabel: "Favorilerim",
|
|
401
401
|
historyAriaLabel: "Sohbet geçmişi",
|
|
402
402
|
historyPageTitle: "Sohbet Geçmişi",
|
|
403
|
+
historyImageAttachmentLabel: "Görsel eklendi",
|
|
403
404
|
emptyHistoryMessage: "Henüz kaydedilmiş sohbet yok.",
|
|
404
405
|
historyDeleteLabel: "Sohbeti sil",
|
|
405
406
|
historyDeleteConfirmMessage: "Bu sohbet geçmişten silinsin mi? Bu işlem geri alınamaz.",
|
|
@@ -544,6 +545,7 @@ var Re = {
|
|
|
544
545
|
favoritesAriaLabel: "My favorites",
|
|
545
546
|
historyAriaLabel: "Chat history",
|
|
546
547
|
historyPageTitle: "Chat History",
|
|
548
|
+
historyImageAttachmentLabel: "Image attachment",
|
|
547
549
|
emptyHistoryMessage: "You don't have any saved chats yet.",
|
|
548
550
|
historyDeleteLabel: "Delete chat",
|
|
549
551
|
historyDeleteConfirmMessage: "Delete this chat from history? This cannot be undone.",
|
|
@@ -5708,15 +5710,15 @@ function wa(t) {
|
|
|
5708
5710
|
const e = typeof t.content == "string" ? _e(t.content) : "", a = "attachment" in t && t.attachment !== void 0;
|
|
5709
5711
|
return e.length > 0 || t.uiSpec !== void 0 || a;
|
|
5710
5712
|
}
|
|
5711
|
-
function go(t) {
|
|
5712
|
-
return t.filter((
|
|
5713
|
-
const
|
|
5714
|
-
id:
|
|
5715
|
-
role:
|
|
5716
|
-
timestamp:
|
|
5717
|
-
status:
|
|
5713
|
+
function go(t, e = co) {
|
|
5714
|
+
return t.filter((a) => !(a.status === "streaming" && !wa(a))).map((a) => {
|
|
5715
|
+
const n = {
|
|
5716
|
+
id: a.id,
|
|
5717
|
+
role: a.role,
|
|
5718
|
+
timestamp: a.timestamp,
|
|
5719
|
+
status: a.status === "error" ? "error" : "done"
|
|
5718
5720
|
};
|
|
5719
|
-
return
|
|
5721
|
+
return a.threadId !== void 0 && (n.threadId = a.threadId), a.content !== void 0 && (n.content = a.content), a.attachment !== void 0 && _e(n.content ?? "").length === 0 && (n.content = e), a.uiSpec !== void 0 && (n.uiSpec = a.uiSpec), a.frontendOnly && (n.frontendOnly = !0), a.silent && (n.silent = !0), a.renderHint !== void 0 && (n.renderHint = a.renderHint), a.photoAnalysis !== void 0 && (n.photoAnalysis = a.photoAnalysis), n;
|
|
5720
5722
|
});
|
|
5721
5723
|
}
|
|
5722
5724
|
function po(t) {
|
|
@@ -5782,7 +5784,7 @@ var bo = class {
|
|
|
5782
5784
|
}
|
|
5783
5785
|
saveSession(t) {
|
|
5784
5786
|
if (!this._storage) return null;
|
|
5785
|
-
const e = go(t.messages);
|
|
5787
|
+
const e = go(t.messages, t.attachmentPlaceholder);
|
|
5786
5788
|
if (!e.some((p) => p.role === "user" && !p.silent && typeof p.content == "string" && _e(p.content).length > 0)) return null;
|
|
5787
5789
|
const a = (/* @__PURE__ */ new Date()).toISOString(), n = po(e), r = ho(e), i = {};
|
|
5788
5790
|
for (const [p, g] of t.panelSnapshots)
|
|
@@ -6827,7 +6829,7 @@ var Ro = class Me extends Ka {
|
|
|
6827
6829
|
_shouldLockHostDocumentScroll() {
|
|
6828
6830
|
if (!this._drawerVisible) return !1;
|
|
6829
6831
|
const e = this.config.variant ?? "floating";
|
|
6830
|
-
return e === "inline" ? !1 : e === "overlay" || this._isMobileViewport ? !0 : this.
|
|
6832
|
+
return e === "inline" ? !1 : e === "overlay" || this._isMobileViewport ? !0 : this._isMaximizedForHostChrome();
|
|
6831
6833
|
}
|
|
6832
6834
|
_applyOpenStateClasses() {
|
|
6833
6835
|
if (!this._rootEl) return;
|
|
@@ -6873,42 +6875,42 @@ var Ro = class Me extends Ka {
|
|
|
6873
6875
|
}
|
|
6874
6876
|
}
|
|
6875
6877
|
_applyHostDocumentScrollLock() {
|
|
6876
|
-
if (
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
}
|
|
6889
|
-
this._hostScrollLockActive || (window.addEventListener("touchmove", this._preventHostDocumentTouchMove, {
|
|
6890
|
-
capture: !0,
|
|
6891
|
-
passive: !1
|
|
6892
|
-
}), window.addEventListener("wheel", this._preventHostDocumentWheel, {
|
|
6893
|
-
capture: !0,
|
|
6894
|
-
passive: !1
|
|
6895
|
-
}), document.addEventListener("touchmove", this._preventHostDocumentTouchMove, {
|
|
6896
|
-
capture: !0,
|
|
6897
|
-
passive: !1
|
|
6898
|
-
}), document.addEventListener("wheel", this._preventHostDocumentWheel, {
|
|
6899
|
-
capture: !0,
|
|
6900
|
-
passive: !1
|
|
6901
|
-
}), window.addEventListener("scroll", this._pinHostViewportScroll, {
|
|
6902
|
-
capture: !0,
|
|
6903
|
-
passive: !0
|
|
6904
|
-
}), this._hostScrollLockActive = !0);
|
|
6878
|
+
if (typeof document > "u" || typeof window > "u") return;
|
|
6879
|
+
const e = document.documentElement;
|
|
6880
|
+
if (!this._hostOverflowRestore) {
|
|
6881
|
+
const a = document.body;
|
|
6882
|
+
this._hostOverflowRestore = {
|
|
6883
|
+
htmlOverflow: e.style.overflow,
|
|
6884
|
+
bodyOverflow: a?.style.overflow ?? "",
|
|
6885
|
+
htmlOverscroll: e.style.overscrollBehavior,
|
|
6886
|
+
bodyOverscroll: a?.style.overscrollBehavior ?? ""
|
|
6887
|
+
}, e.dataset.gengageHostScrollLock = "1", e.style.overflow = "hidden", e.style.overscrollBehavior = "none", a && (a.style.overflow = "hidden", a.style.overscrollBehavior = "none"), this._hostScrollLockViewport = {
|
|
6888
|
+
x: window.scrollX,
|
|
6889
|
+
y: window.scrollY
|
|
6890
|
+
};
|
|
6905
6891
|
}
|
|
6892
|
+
this._hostScrollLockActive || (window.addEventListener("touchmove", this._preventHostDocumentTouchMove, {
|
|
6893
|
+
capture: !0,
|
|
6894
|
+
passive: !1
|
|
6895
|
+
}), window.addEventListener("wheel", this._preventHostDocumentWheel, {
|
|
6896
|
+
capture: !0,
|
|
6897
|
+
passive: !1
|
|
6898
|
+
}), document.addEventListener("touchmove", this._preventHostDocumentTouchMove, {
|
|
6899
|
+
capture: !0,
|
|
6900
|
+
passive: !1
|
|
6901
|
+
}), document.addEventListener("wheel", this._preventHostDocumentWheel, {
|
|
6902
|
+
capture: !0,
|
|
6903
|
+
passive: !1
|
|
6904
|
+
}), window.addEventListener("scroll", this._pinHostViewportScroll, {
|
|
6905
|
+
capture: !0,
|
|
6906
|
+
passive: !0
|
|
6907
|
+
}), this._hostScrollLockActive = !0);
|
|
6906
6908
|
}
|
|
6907
6909
|
_releaseHostDocumentScrollLock() {
|
|
6908
|
-
if (
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6910
|
+
if (typeof document > "u") return;
|
|
6911
|
+
typeof window < "u" && (window.removeEventListener("scroll", this._pinHostViewportScroll, { capture: !0 }), window.removeEventListener("touchmove", this._preventHostDocumentTouchMove, { capture: !0 }), window.removeEventListener("wheel", this._preventHostDocumentWheel, { capture: !0 })), document.removeEventListener("touchmove", this._preventHostDocumentTouchMove, { capture: !0 }), document.removeEventListener("wheel", this._preventHostDocumentWheel, { capture: !0 }), this._hostScrollLockActive = !1, this._hostScrollLockViewport = null, this._hostScrollPinning = !1;
|
|
6912
|
+
const e = document.documentElement, a = document.body;
|
|
6913
|
+
this._hostOverflowRestore ? (e.style.overflow = this._hostOverflowRestore.htmlOverflow, e.style.overscrollBehavior = this._hostOverflowRestore.htmlOverscroll, a && (a.style.overflow = this._hostOverflowRestore.bodyOverflow, a.style.overscrollBehavior = this._hostOverflowRestore.bodyOverscroll), this._hostOverflowRestore = null) : e.dataset.gengageHostScrollLock === "1" && (e.style.removeProperty("overflow"), e.style.removeProperty("overscroll-behavior"), a?.style.removeProperty("overflow"), a?.style.removeProperty("overscroll-behavior")), delete e.dataset.gengageHostScrollLock;
|
|
6912
6914
|
}
|
|
6913
6915
|
_handleAttachment(e) {
|
|
6914
6916
|
const a = sn(e);
|
|
@@ -7710,7 +7712,8 @@ var Ro = class Me extends Ka {
|
|
|
7710
7712
|
panelAiSpecByThread: this._panelAiSpecByThread,
|
|
7711
7713
|
lastBackendContext: this._lastBackendContext,
|
|
7712
7714
|
pageType: this.config.pageContext?.pageType,
|
|
7713
|
-
sku: this.config.pageContext?.sku
|
|
7715
|
+
sku: this.config.pageContext?.sku,
|
|
7716
|
+
attachmentPlaceholder: this._i18n.historyImageAttachmentLabel
|
|
7714
7717
|
});
|
|
7715
7718
|
a && (this._activeHistorySessionId = a.id);
|
|
7716
7719
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { d as x, h as Q, p as R, r as N, t as H } from "./api-paths-
|
|
2
|
-
import { A as O, D as U, E as j, a as q, v as M } from "./context-
|
|
3
|
-
import { o as F, t as W } from "./widget-base-
|
|
1
|
+
import { d as x, h as Q, p as R, r as N, t as H } from "./api-paths-DE3_TyTw.js";
|
|
2
|
+
import { A as O, D as U, E as j, a as q, v as M } from "./context-UTzCGyR9.js";
|
|
3
|
+
import { o as F, t as W } from "./widget-base-e4JwEf2I.js";
|
|
4
4
|
import { t as A } from "./locale-uQ5XZ2yS.js";
|
|
5
5
|
import { t as D } from "./request-response-cache-BxRsKGJ0.js";
|
|
6
|
-
import { n as z } from "./connection-warning-
|
|
6
|
+
import { n as z } from "./connection-warning-Tk4ZjgMi.js";
|
|
7
7
|
async function $(e, t, n) {
|
|
8
8
|
const o = H("launcher_action", t), i = {
|
|
9
9
|
uiSpecs: [],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as m, D as h, _ as u, j as f, v as p } from "./context-
|
|
2
|
-
import { t as b } from "./widget-base-
|
|
1
|
+
import { A as m, D as h, _ as u, j as f, v as p } from "./context-UTzCGyR9.js";
|
|
2
|
+
import { t as b } from "./widget-base-e4JwEf2I.js";
|
|
3
3
|
import { t as y } from "./locale-uQ5XZ2yS.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.6.
|
|
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.6.22".trim(),"0.6.22".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
|
-
import { A, j as S } from "./context-
|
|
1
|
+
import { A, j as S } from "./context-UTzCGyR9.js";
|
|
2
2
|
import { n as $, t as L } from "./price-formatter-CHUmYq8I.js";
|
|
3
3
|
import { a as C, c as f, n as q, o as h, t as k, u as H } from "./schemas-BnYUhYSy.js";
|
|
4
|
-
import { o as j } from "./runtime-
|
|
4
|
+
import { o as j } from "./runtime-CjJy8KKu.js";
|
|
5
5
|
var V = {
|
|
6
6
|
images: [
|
|
7
7
|
"images",
|
package/dist/simrel-runtime.js
CHANGED