@gengage/assistant-fe 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -286
- package/dist/assistant-fe.css +1 -1
- package/dist/chat/api.d.ts +1 -12
- package/dist/chat/api.d.ts.map +1 -1
- package/dist/chat/components/CategoriesContainer.d.ts.map +1 -1
- package/dist/chat/components/ChatDrawer.d.ts +15 -1
- package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
- package/dist/chat/components/ChoicePrompter.d.ts +1 -0
- package/dist/chat/components/ChoicePrompter.d.ts.map +1 -1
- package/dist/chat/components/ComparisonTable.d.ts +5 -3
- package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
- package/dist/chat/components/PanelTopBar.d.ts +2 -0
- package/dist/chat/components/PanelTopBar.d.ts.map +1 -1
- package/dist/chat/components/ProductSummaryCard.d.ts.map +1 -1
- package/dist/chat/components/ReviewHighlights.d.ts +3 -0
- package/dist/chat/components/ReviewHighlights.d.ts.map +1 -1
- package/dist/chat/components/renderUISpec.d.ts +0 -5
- package/dist/chat/components/renderUISpec.d.ts.map +1 -1
- package/dist/chat/index.d.ts +18 -9
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/chat/locales/en.d.ts.map +1 -1
- package/dist/chat/locales/tr.d.ts.map +1 -1
- package/dist/chat/session-persistence.d.ts +3 -0
- package/dist/chat/session-persistence.d.ts.map +1 -1
- package/dist/chat/types.d.ts +23 -25
- package/dist/chat/types.d.ts.map +1 -1
- package/dist/chat.cjs +1 -1
- package/dist/chat.iife.js +22 -22
- package/dist/chat.iife.js.map +1 -1
- package/dist/chat.js +8 -9
- package/dist/chat.js.map +1 -1
- package/dist/common/action-router.d.ts.map +1 -1
- package/dist/common/activity-tracker.d.ts +1 -1
- package/dist/common/analytics.d.ts +12 -8
- package/dist/common/analytics.d.ts.map +1 -1
- package/dist/common/api-paths.d.ts +2 -5
- package/dist/common/api-paths.d.ts.map +1 -1
- package/dist/common/config-schema.d.ts.map +1 -1
- package/dist/common/debug.d.ts +14 -0
- package/dist/common/debug.d.ts.map +1 -0
- package/dist/common/events.d.ts.map +1 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/native-webview.d.ts.map +1 -1
- package/dist/common/overlay.d.ts +19 -0
- package/dist/common/overlay.d.ts.map +1 -1
- package/dist/common/product-utils.d.ts +10 -0
- package/dist/common/product-utils.d.ts.map +1 -1
- package/dist/common/{v1-protocol-adapter.d.ts → protocol-adapter.d.ts} +2 -2
- package/dist/common/protocol-adapter.d.ts.map +1 -0
- package/dist/common/quantity-stepper.d.ts +10 -10
- package/dist/common/quantity-stepper.d.ts.map +1 -1
- package/dist/common/safe-html.d.ts.map +1 -1
- package/dist/common/streaming.d.ts.map +1 -1
- package/dist/common/tts-player.d.ts +2 -0
- package/dist/common/tts-player.d.ts.map +1 -1
- package/dist/common/types.d.ts +1 -1
- package/dist/common/voice-input.d.ts +1 -0
- package/dist/common/voice-input.d.ts.map +1 -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 +173 -172
- package/dist/common.js.map +1 -1
- package/dist/index-BA7N_XOO.cjs +2 -0
- package/dist/index-BA7N_XOO.cjs.map +1 -0
- package/dist/{index-CcOJTzYu.js → index-C6KDzSjm.js} +155 -159
- package/dist/index-C6KDzSjm.js.map +1 -0
- package/dist/index-RmQRBt6w.js +4449 -0
- package/dist/index-RmQRBt6w.js.map +1 -0
- package/dist/index-VgLdYuZV.cjs +13 -0
- package/dist/index-VgLdYuZV.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +16 -16
- package/dist/native.cjs +1 -1
- package/dist/native.iife.js +23 -23
- package/dist/native.iife.js.map +1 -1
- package/dist/native.js +1 -1
- package/dist/qna/index.d.ts +19 -0
- package/dist/qna/index.d.ts.map +1 -1
- package/dist/qna/types.d.ts +2 -2
- package/dist/qna/types.d.ts.map +1 -1
- package/dist/qna.cjs +1 -1
- package/dist/qna.cjs.map +1 -1
- package/dist/qna.css +1 -1
- package/dist/qna.iife.js +7 -7
- package/dist/qna.iife.js.map +1 -1
- package/dist/qna.js +14 -14
- package/dist/qna.js.map +1 -1
- package/dist/quantity-stepper-BKtPQUR1.js +78 -0
- package/dist/quantity-stepper-BKtPQUR1.js.map +1 -0
- package/dist/quantity-stepper-DU6va4sS.cjs +2 -0
- package/dist/quantity-stepper-DU6va4sS.cjs.map +1 -0
- package/dist/{schemas-yF4IOEUi.js → schemas-BAEbjFPE.js} +1181 -957
- package/dist/schemas-BAEbjFPE.js.map +1 -0
- package/dist/schemas-DIyHm5pa.cjs +86 -0
- package/dist/schemas-DIyHm5pa.cjs.map +1 -0
- package/dist/simrel/api.d.ts +1 -1
- package/dist/simrel/api.d.ts.map +1 -1
- package/dist/simrel/components/GroupTabs.d.ts +1 -1
- package/dist/simrel/components/GroupTabs.d.ts.map +1 -1
- package/dist/simrel/components/ProductCard.d.ts +1 -1
- package/dist/simrel/components/ProductCard.d.ts.map +1 -1
- package/dist/simrel/components/ProductGrid.d.ts +1 -1
- package/dist/simrel/components/ProductGrid.d.ts.map +1 -1
- package/dist/simrel/index.d.ts +20 -1
- package/dist/simrel/index.d.ts.map +1 -1
- package/dist/simrel/locales/en.d.ts.map +1 -1
- package/dist/simrel/locales/tr.d.ts.map +1 -1
- package/dist/simrel/types.d.ts +2 -0
- package/dist/simrel/types.d.ts.map +1 -1
- package/dist/simrel.cjs +1 -1
- package/dist/simrel.cjs.map +1 -1
- package/dist/simrel.css +1 -1
- package/dist/simrel.iife.js +11 -11
- package/dist/simrel.iife.js.map +1 -1
- package/dist/simrel.js +281 -267
- package/dist/simrel.js.map +1 -1
- package/package.json +1 -1
- package/dist/chat/components/ProactivePopup.d.ts +0 -20
- package/dist/chat/components/ProactivePopup.d.ts.map +0 -1
- package/dist/chat/heartbeat.d.ts +0 -71
- package/dist/chat/heartbeat.d.ts.map +0 -1
- package/dist/common/v1-protocol-adapter.d.ts.map +0 -1
- package/dist/index-BqIzV4ni.cjs +0 -2
- package/dist/index-BqIzV4ni.cjs.map +0 -1
- package/dist/index-CcOJTzYu.js.map +0 -1
- package/dist/index-DZ3Mi5xF.cjs +0 -13
- package/dist/index-DZ3Mi5xF.cjs.map +0 -1
- package/dist/index-FnP8WtfG.js +0 -4571
- package/dist/index-FnP8WtfG.js.map +0 -1
- package/dist/quantity-stepper-B8kX8GbN.js +0 -209
- package/dist/quantity-stepper-B8kX8GbN.js.map +0 -1
- package/dist/quantity-stepper-UbAp53Ow.cjs +0 -2
- package/dist/quantity-stepper-UbAp53Ow.cjs.map +0 -1
- package/dist/schemas-DHzfUzwA.cjs +0 -86
- package/dist/schemas-DHzfUzwA.cjs.map +0 -1
- package/dist/schemas-yF4IOEUi.js.map +0 -1
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { G as
|
|
2
|
-
import { GengageQNA as
|
|
3
|
-
import { GengageSimRel as
|
|
4
|
-
import { o as p, s as h,
|
|
5
|
-
const
|
|
1
|
+
import { G as F } from "./index-RmQRBt6w.js";
|
|
2
|
+
import { GengageQNA as Q } from "./qna.js";
|
|
3
|
+
import { GengageSimRel as H } from "./simrel.js";
|
|
4
|
+
import { o as p, s as h, Y as j, _ as U, D as M, d as y, y as S, Z as K, $ as V, E as $ } from "./schemas-BAEbjFPE.js";
|
|
5
|
+
const C = p({
|
|
6
6
|
enabled: y().default(!0)
|
|
7
|
-
}),
|
|
7
|
+
}), G = p({
|
|
8
8
|
chat: h().optional(),
|
|
9
9
|
qna: h().optional(),
|
|
10
10
|
simrel: h().optional()
|
|
11
|
-
}), Y = p({}), J =
|
|
11
|
+
}), Y = p({}), J = U(["none", "x-api-key-header", "bearer-header", "body-api-key"]), X = p({
|
|
12
12
|
mode: J.default("none"),
|
|
13
13
|
key: h().optional(),
|
|
14
14
|
headerName: h().optional(),
|
|
15
15
|
bodyField: h().default("api_key")
|
|
16
|
-
}),
|
|
16
|
+
}), Z = p({
|
|
17
17
|
enabled: y().default(!0),
|
|
18
18
|
endpoint: h().default("/analytics"),
|
|
19
19
|
auth: X.default({ mode: "none", bodyField: "api_key" }),
|
|
20
20
|
fireAndForget: y().default(!0),
|
|
21
21
|
useBeacon: y().default(!0),
|
|
22
22
|
keepaliveFetch: y().default(!0),
|
|
23
|
-
timeoutMs:
|
|
24
|
-
maxRetries:
|
|
25
|
-
}),
|
|
26
|
-
idempotencyKey: h().default(
|
|
23
|
+
timeoutMs: S().int().positive().default(4e3),
|
|
24
|
+
maxRetries: S().int().min(0).max(5).default(1)
|
|
25
|
+
}), R = "__gengageWidgetsInit", z = p({
|
|
26
|
+
idempotencyKey: h().default(R),
|
|
27
27
|
requireDomReady: y().default(!0)
|
|
28
|
-
}), ee =
|
|
28
|
+
}), ee = U(["log-and-ignore", "throw", "delegate"]), te = p({
|
|
29
29
|
unknownActionPolicy: ee.default("log-and-ignore"),
|
|
30
30
|
allowScriptCall: y().default(!1)
|
|
31
|
-
}),
|
|
32
|
-
version: j("1"),
|
|
33
|
-
accountId: h().min(1),
|
|
34
|
-
middlewareUrl: h().url(),
|
|
31
|
+
}), P = p({
|
|
32
|
+
version: j("1", { error: 'version must be "1"' }),
|
|
33
|
+
accountId: h({ error: "accountId must be a non-empty string" }).min(1, { error: "accountId must be a non-empty string" }),
|
|
34
|
+
middlewareUrl: h({ error: 'middlewareUrl must be a valid URL (e.g. "https://your-backend.example.com")' }).url({ error: 'middlewareUrl must be a valid URL (e.g. "https://your-backend.example.com")' }),
|
|
35
35
|
locale: h().optional(),
|
|
36
36
|
widgets: p({
|
|
37
|
-
chat:
|
|
38
|
-
qna:
|
|
39
|
-
simrel:
|
|
37
|
+
chat: C.default({ enabled: !0 }),
|
|
38
|
+
qna: C.default({ enabled: !0 }),
|
|
39
|
+
simrel: C.default({ enabled: !0 })
|
|
40
40
|
}),
|
|
41
|
-
mounts:
|
|
41
|
+
mounts: G.default({}),
|
|
42
42
|
transport: Y.default({}),
|
|
43
|
-
analytics:
|
|
43
|
+
analytics: Z.default({
|
|
44
44
|
enabled: !0,
|
|
45
45
|
endpoint: "/analytics",
|
|
46
46
|
auth: { mode: "none", bodyField: "api_key" },
|
|
@@ -50,7 +50,7 @@ const b = p({
|
|
|
50
50
|
timeoutMs: 4e3,
|
|
51
51
|
maxRetries: 1
|
|
52
52
|
}),
|
|
53
|
-
gtm:
|
|
53
|
+
gtm: z.default({
|
|
54
54
|
idempotencyKey: "__gengageWidgetsInit",
|
|
55
55
|
requireDomReady: !0
|
|
56
56
|
}),
|
|
@@ -59,18 +59,20 @@ const b = p({
|
|
|
59
59
|
allowScriptCall: !1
|
|
60
60
|
})
|
|
61
61
|
});
|
|
62
|
-
function ne(
|
|
63
|
-
|
|
62
|
+
function ne(n) {
|
|
63
|
+
M("config", "parsing account runtime config", n);
|
|
64
|
+
const e = P.parse(n);
|
|
65
|
+
return M("config", "config resolved", { accountId: e.accountId, middlewareUrl: e.middlewareUrl }), e;
|
|
64
66
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
67
|
+
function be(n) {
|
|
68
|
+
return P.safeParse(n);
|
|
67
69
|
}
|
|
68
|
-
function
|
|
70
|
+
function Te(n) {
|
|
69
71
|
return ne({
|
|
70
72
|
version: "1",
|
|
71
|
-
accountId:
|
|
72
|
-
middlewareUrl:
|
|
73
|
-
locale:
|
|
73
|
+
accountId: n.accountId,
|
|
74
|
+
middlewareUrl: n.middlewareUrl,
|
|
75
|
+
locale: n.locale,
|
|
74
76
|
widgets: {
|
|
75
77
|
chat: { enabled: !0 },
|
|
76
78
|
qna: { enabled: !0 },
|
|
@@ -78,37 +80,37 @@ function be(t) {
|
|
|
78
80
|
}
|
|
79
81
|
});
|
|
80
82
|
}
|
|
81
|
-
const
|
|
82
|
-
function
|
|
83
|
-
const
|
|
84
|
-
return
|
|
83
|
+
const W = `${R}_overlay_`, ie = "#gengage-qna", se = "#gengage-simrel";
|
|
84
|
+
function I() {
|
|
85
|
+
const n = window;
|
|
86
|
+
return n.__gengageOverlayRegistry || (n.__gengageOverlayRegistry = {
|
|
85
87
|
instances: {},
|
|
86
88
|
pending: {}
|
|
87
|
-
}),
|
|
89
|
+
}), n.__gengageOverlayRegistry;
|
|
88
90
|
}
|
|
89
|
-
function oe(
|
|
91
|
+
function oe(n) {
|
|
90
92
|
const e = {
|
|
91
|
-
pageType:
|
|
92
|
-
},
|
|
93
|
-
return
|
|
93
|
+
pageType: n.pageContext?.pageType ?? (n.sku !== void 0 ? "pdp" : "other")
|
|
94
|
+
}, t = n.pageContext;
|
|
95
|
+
return t?.sku !== void 0 && (e.sku = t.sku), t?.price !== void 0 && (e.price = t.price), t?.categoryTree !== void 0 && (e.categoryTree = t.categoryTree), t?.url !== void 0 && (e.url = t.url), t?.extra !== void 0 && (e.extra = t.extra), n.sku !== void 0 && (e.sku = n.sku), e;
|
|
94
96
|
}
|
|
95
|
-
function ae(
|
|
96
|
-
const
|
|
97
|
-
...
|
|
97
|
+
function ae(n, e) {
|
|
98
|
+
const t = {
|
|
99
|
+
...n,
|
|
98
100
|
...e,
|
|
99
|
-
pageType: e.pageType ??
|
|
101
|
+
pageType: e.pageType ?? n.pageType
|
|
100
102
|
};
|
|
101
|
-
return e.sku === void 0 &&
|
|
103
|
+
return e.sku === void 0 && n.sku !== void 0 && (t.sku = n.sku), t;
|
|
102
104
|
}
|
|
103
|
-
function
|
|
104
|
-
return
|
|
105
|
+
function k(n) {
|
|
106
|
+
return n instanceof HTMLElement || document.querySelector(n) ? n : null;
|
|
105
107
|
}
|
|
106
|
-
function
|
|
107
|
-
return
|
|
108
|
+
function L(n) {
|
|
109
|
+
return n.idempotencyKey ?? `${W}${n.accountId}`;
|
|
108
110
|
}
|
|
109
111
|
class re {
|
|
110
|
-
constructor(e,
|
|
111
|
-
this.options = e, this.onDestroy =
|
|
112
|
+
constructor(e, t) {
|
|
113
|
+
this.options = e, this.onDestroy = t, this._chat = null, this._qna = null, this._simrel = null, this._analyticsClient = null, this._offQnaWire = null, this._destroyed = !1, this._queue = Promise.resolve(), this._warnedQnaMountMissing = !1, this._warnedSimRelMountMissing = !1, this.idempotencyKey = L(e), this.session = K(e.session), this._pageContext = oe(e);
|
|
112
114
|
}
|
|
113
115
|
get chat() {
|
|
114
116
|
return this._chat;
|
|
@@ -123,7 +125,7 @@ class re {
|
|
|
123
125
|
return this._analyticsClient;
|
|
124
126
|
}
|
|
125
127
|
async init() {
|
|
126
|
-
window.gengage || (window.gengage = {}), window.gengage.sessionId = this.session.sessionId, window.gengage.pageContext = this._pageContext, await this._initChat(), this.options.wireQnaToChat !== !1 && (this._offQnaWire =
|
|
128
|
+
window.gengage || (window.gengage = {}), window.gengage.sessionId = this.session.sessionId, window.gengage.pageContext = this._pageContext, await this._initChat(), this.options.wireQnaToChat !== !1 && (this._offQnaWire = V()), await this._syncPdpWidgets(), window.gengage.overlay = this;
|
|
127
129
|
}
|
|
128
130
|
openChat(e) {
|
|
129
131
|
this._chat?.open(e);
|
|
@@ -136,22 +138,22 @@ class re {
|
|
|
136
138
|
this._pageContext = ae(this._pageContext, e), window.gengage || (window.gengage = {}), window.gengage.pageContext = this._pageContext, this._chat?.update(e), this._qna?.update(e), this._simrel?.update(e), await this._syncPdpWidgets();
|
|
137
139
|
});
|
|
138
140
|
}
|
|
139
|
-
async updateSku(e,
|
|
140
|
-
await this.updateContext({ sku: e, pageType:
|
|
141
|
+
async updateSku(e, t = "pdp") {
|
|
142
|
+
await this.updateContext({ sku: e, pageType: t });
|
|
141
143
|
}
|
|
142
144
|
destroy() {
|
|
143
145
|
this._destroyed || (this._destroyed = !0, this._offQnaWire?.(), this._offQnaWire = null, this._chat?.destroy(), this._qna?.destroy(), this._simrel?.destroy(), this._chat = null, this._qna = null, this._simrel = null, window.gengage?.overlay === this && delete window.gengage.overlay, this.onDestroy());
|
|
144
146
|
}
|
|
145
147
|
async _initChat() {
|
|
146
148
|
if (this.options.chat?.enabled === !1) return;
|
|
147
|
-
const e = this.options.middlewareUrl,
|
|
149
|
+
const e = this.options.middlewareUrl, t = {
|
|
148
150
|
accountId: this.options.accountId,
|
|
149
151
|
middlewareUrl: e,
|
|
150
152
|
session: this.session,
|
|
151
153
|
pageContext: this._pageContext,
|
|
152
154
|
variant: this.options.chat?.variant ?? "floating"
|
|
153
155
|
};
|
|
154
|
-
this.options.theme !== void 0 && (
|
|
156
|
+
this.options.theme !== void 0 && (t.theme = this.options.theme), this.options.locale !== void 0 && (t.locale = this.options.locale), this.options.pricing !== void 0 && (t.pricing = this.options.pricing), this.options.chat?.mountTarget !== void 0 && (t.mountTarget = this.options.chat.mountTarget), this.options.chat?.launcherSvg !== void 0 && (t.launcherSvg = this.options.chat.launcherSvg), this.options.chat?.headerTitle !== void 0 && (t.headerTitle = this.options.chat.headerTitle), this.options.chat?.headerAvatarUrl !== void 0 && (t.headerAvatarUrl = this.options.chat.headerAvatarUrl), this.options.chat?.headerBadge !== void 0 && (t.headerBadge = this.options.chat.headerBadge), this.options.chat?.headerCartUrl !== void 0 && (t.headerCartUrl = this.options.chat.headerCartUrl), this.options.chat?.headerFavoritesToggle !== void 0 && (t.headerFavoritesToggle = this.options.chat.headerFavoritesToggle), this.options.chat?.hideMobileLauncher !== void 0 && (t.hideMobileLauncher = this.options.chat.hideMobileLauncher), this.options.chat?.mobileBreakpoint !== void 0 && (t.mobileBreakpoint = this.options.chat.mobileBreakpoint), this.options.chat?.mobileInitialState !== void 0 && (t.mobileInitialState = this.options.chat.mobileInitialState), this.options.chat?.i18n !== void 0 && (t.i18n = this.options.chat.i18n), this.options.chat?.actionHandling !== void 0 && (t.actionHandling = this.options.chat.actionHandling), this.options.onScriptCall !== void 0 && (t.onScriptCall = this.options.onScriptCall), this._chat = new F(), await this._chat.init(t);
|
|
155
157
|
}
|
|
156
158
|
async _syncPdpWidgets() {
|
|
157
159
|
if (this._destroyed) return;
|
|
@@ -162,12 +164,12 @@ class re {
|
|
|
162
164
|
}
|
|
163
165
|
const a = this.options.middlewareUrl;
|
|
164
166
|
if (this.options.qna?.enabled !== !1) {
|
|
165
|
-
const s = this.options.qna?.mountTarget ?? ie, i =
|
|
167
|
+
const s = this.options.qna?.mountTarget ?? ie, i = k(s);
|
|
166
168
|
if (i)
|
|
167
169
|
if (this._warnedQnaMountMissing = !1, this._qna)
|
|
168
170
|
this._qna.show(), this._qna.update({ pageType: "pdp", sku: e });
|
|
169
171
|
else {
|
|
170
|
-
const u = new
|
|
172
|
+
const u = new Q(), o = {
|
|
171
173
|
accountId: this.options.accountId,
|
|
172
174
|
middlewareUrl: a,
|
|
173
175
|
session: this.session,
|
|
@@ -184,12 +186,12 @@ class re {
|
|
|
184
186
|
} else
|
|
185
187
|
this._qna?.destroy(), this._qna = null;
|
|
186
188
|
if (this.options.simrel?.enabled !== !1) {
|
|
187
|
-
const s = this.options.simrel?.mountTarget ?? se, i =
|
|
189
|
+
const s = this.options.simrel?.mountTarget ?? se, i = k(s);
|
|
188
190
|
if (i)
|
|
189
191
|
if (this._warnedSimRelMountMissing = !1, this._simrel)
|
|
190
192
|
this._simrel.show(), this._simrel.update({ pageType: "pdp", sku: e });
|
|
191
193
|
else {
|
|
192
|
-
const u = new
|
|
194
|
+
const u = new H(), o = {
|
|
193
195
|
accountId: this.options.accountId,
|
|
194
196
|
middlewareUrl: a,
|
|
195
197
|
session: this.session,
|
|
@@ -197,7 +199,7 @@ class re {
|
|
|
197
199
|
mountTarget: i
|
|
198
200
|
};
|
|
199
201
|
this.options.theme !== void 0 && (o.theme = this.options.theme), this.options.pricing !== void 0 && (o.pricing = this.options.pricing), this.options.simrel?.discountType !== void 0 && (o.discountType = this.options.simrel.discountType), this.options.onAddToCart !== void 0 && (o.onAddToCart = this.options.onAddToCart), this.options.onProductNavigate !== void 0 ? o.onProductNavigate = this.options.onProductNavigate : o.onProductNavigate = (r, c, m) => {
|
|
200
|
-
this._chat?.saveSession(m ?? this.session.sessionId, c), window.location.href = r;
|
|
202
|
+
$(r) && (this._chat?.saveSession(m ?? this.session.sessionId, c), window.location.href = r);
|
|
201
203
|
}, await u.init(o), this._simrel = u;
|
|
202
204
|
}
|
|
203
205
|
else
|
|
@@ -209,32 +211,32 @@ class re {
|
|
|
209
211
|
this._qna?.destroy(), this._simrel?.destroy(), this._qna = null, this._simrel = null;
|
|
210
212
|
}
|
|
211
213
|
_enqueue(e) {
|
|
212
|
-
const
|
|
213
|
-
return this._queue =
|
|
214
|
-
}),
|
|
214
|
+
const t = this._queue.then(e);
|
|
215
|
+
return this._queue = t.catch((a) => {
|
|
216
|
+
}), t;
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
|
-
async function de(
|
|
218
|
-
const e =
|
|
219
|
+
async function de(n) {
|
|
220
|
+
const e = L(n), t = I(), a = t.instances[e];
|
|
219
221
|
if (a) return a;
|
|
220
|
-
const s =
|
|
222
|
+
const s = t.pending[e];
|
|
221
223
|
if (s) return s;
|
|
222
|
-
const i = new re(
|
|
223
|
-
const o =
|
|
224
|
+
const i = new re(n, () => {
|
|
225
|
+
const o = I();
|
|
224
226
|
delete o.instances[e], delete o.pending[e];
|
|
225
|
-
}), u = i.init().then(() => (
|
|
226
|
-
throw delete
|
|
227
|
+
}), u = i.init().then(() => (t.instances[e] = i, delete t.pending[e], i)).catch((o) => {
|
|
228
|
+
throw delete t.pending[e], o;
|
|
227
229
|
});
|
|
228
|
-
return
|
|
230
|
+
return t.pending[e] = u, u;
|
|
229
231
|
}
|
|
230
|
-
function ce(
|
|
231
|
-
return
|
|
232
|
+
function ce(n) {
|
|
233
|
+
return I().instances[n] ?? null;
|
|
232
234
|
}
|
|
233
|
-
function Ce(
|
|
234
|
-
ce(
|
|
235
|
+
function Ce(n) {
|
|
236
|
+
ce(n)?.destroy();
|
|
235
237
|
}
|
|
236
|
-
function
|
|
237
|
-
return `${
|
|
238
|
+
function Ie(n) {
|
|
239
|
+
return `${W}${n}`;
|
|
238
240
|
}
|
|
239
241
|
const le = [
|
|
240
242
|
"gengage:chat:open",
|
|
@@ -247,11 +249,11 @@ const le = [
|
|
|
247
249
|
"gengage:similar:add-to-cart",
|
|
248
250
|
"gengage:global:error",
|
|
249
251
|
"gengage:context:update"
|
|
250
|
-
], ge = 32,
|
|
251
|
-
function ue(
|
|
252
|
-
let e =
|
|
253
|
-
if (typeof
|
|
254
|
-
const i =
|
|
252
|
+
], ge = 32, A = "#gengage-qna", E = "#gengage-simrel";
|
|
253
|
+
function ue(n) {
|
|
254
|
+
let e = n;
|
|
255
|
+
if (typeof n == "string") {
|
|
256
|
+
const i = n.trim();
|
|
255
257
|
if (i.length === 0) return null;
|
|
256
258
|
if (!i.startsWith("{") && !i.startsWith("["))
|
|
257
259
|
return { type: i };
|
|
@@ -262,98 +264,92 @@ function ue(t) {
|
|
|
262
264
|
}
|
|
263
265
|
}
|
|
264
266
|
if (!e || typeof e != "object") return null;
|
|
265
|
-
const
|
|
267
|
+
const t = e, a = [t.type, t.command, t.action, t.event].find(
|
|
266
268
|
(i) => typeof i == "string" && i.length > 0
|
|
267
269
|
);
|
|
268
270
|
if (!a) return null;
|
|
269
|
-
let s =
|
|
270
|
-
if (s === void 0 && "data" in
|
|
271
|
+
let s = t.payload;
|
|
272
|
+
if (s === void 0 && "data" in t && (s = t.data), a === "setSession" && s === void 0) {
|
|
271
273
|
const i = {};
|
|
272
|
-
typeof
|
|
274
|
+
typeof t.sessionId == "string" && (i.sessionId = t.sessionId), typeof t.userId == "string" && (i.userId = t.userId), (i.sessionId !== void 0 || i.userId !== void 0) && (s = i);
|
|
273
275
|
}
|
|
274
276
|
return s === void 0 ? { type: a } : { type: a, payload: s };
|
|
275
277
|
}
|
|
276
|
-
function he(
|
|
277
|
-
if (typeof
|
|
278
|
-
return { sku:
|
|
279
|
-
if (
|
|
280
|
-
const e =
|
|
278
|
+
function he(n) {
|
|
279
|
+
if (typeof n == "string" && n.length > 0)
|
|
280
|
+
return { sku: n };
|
|
281
|
+
if (n && typeof n == "object" && "sku" in n) {
|
|
282
|
+
const e = n.sku;
|
|
281
283
|
if (typeof e == "string" && e.length > 0) {
|
|
282
|
-
const
|
|
283
|
-
return
|
|
284
|
+
const t = n.pageType;
|
|
285
|
+
return t !== void 0 ? { sku: e, pageType: t } : { sku: e };
|
|
284
286
|
}
|
|
285
287
|
}
|
|
286
288
|
return null;
|
|
287
289
|
}
|
|
288
|
-
function N(
|
|
289
|
-
return e instanceof HTMLElement ? !0 : typeof e != "string" ? !1 :
|
|
290
|
+
function N(n, e) {
|
|
291
|
+
return e instanceof HTMLElement ? !0 : typeof e != "string" ? !1 : n.document.querySelector(e) !== null;
|
|
290
292
|
}
|
|
291
|
-
function
|
|
292
|
-
if (e instanceof HTMLElement || N(
|
|
293
|
+
function x(n, e, t) {
|
|
294
|
+
if (e instanceof HTMLElement || N(n, e) || typeof e != "string") return e;
|
|
293
295
|
if (e.startsWith("#")) {
|
|
294
296
|
const i = e.slice(1);
|
|
295
297
|
if (i.length > 0) {
|
|
296
|
-
const u =
|
|
298
|
+
const u = n.document.getElementById(i);
|
|
297
299
|
if (u) return u;
|
|
298
|
-
const o =
|
|
299
|
-
return o.id = i,
|
|
300
|
+
const o = n.document.createElement("div");
|
|
301
|
+
return o.id = i, n.document.body.appendChild(o), o;
|
|
300
302
|
}
|
|
301
303
|
}
|
|
302
|
-
const a =
|
|
304
|
+
const a = n.document.getElementById(t);
|
|
303
305
|
if (a) return a;
|
|
304
|
-
const s =
|
|
305
|
-
return s.id =
|
|
306
|
-
}
|
|
307
|
-
function W(t, e) {
|
|
308
|
-
const n = t.webkit?.messageHandlers?.[e];
|
|
309
|
-
return n && typeof n.postMessage == "function" ? n.postMessage.bind(n) : null;
|
|
310
|
-
}
|
|
311
|
-
function O(t, e) {
|
|
312
|
-
const n = t[e];
|
|
313
|
-
return n && typeof n == "object" && typeof n.postMessage == "function" ? n : null;
|
|
306
|
+
const s = n.document.createElement("div");
|
|
307
|
+
return s.id = t, n.document.body.appendChild(s), s;
|
|
314
308
|
}
|
|
315
|
-
function
|
|
316
|
-
|
|
309
|
+
function O(n, e) {
|
|
310
|
+
const t = n.webkit?.messageHandlers?.[e];
|
|
311
|
+
return t && typeof t.postMessage == "function" ? t.postMessage.bind(t) : null;
|
|
317
312
|
}
|
|
318
|
-
function
|
|
319
|
-
|
|
313
|
+
function w(n, e) {
|
|
314
|
+
const t = n[e];
|
|
315
|
+
return t && typeof t == "object" && typeof t.postMessage == "function" ? t : null;
|
|
320
316
|
}
|
|
321
|
-
function fe(
|
|
322
|
-
const e =
|
|
323
|
-
return
|
|
317
|
+
function fe(n = {}) {
|
|
318
|
+
const e = n.win ?? window, t = n.iosHandlerName ?? "gengage", a = n.androidInterfaceName ?? "GengageNative", s = n.reactNativeInterfaceName ?? "ReactNativeWebView";
|
|
319
|
+
return O(e, t) ? "ios" : w(e, a) ? "android" : w(e, s) ? "react-native" : "browser";
|
|
324
320
|
}
|
|
325
|
-
function pe(
|
|
326
|
-
const
|
|
327
|
-
if (
|
|
328
|
-
|
|
321
|
+
function pe(n, e = {}) {
|
|
322
|
+
const t = e.win ?? window;
|
|
323
|
+
if (n.sessionId !== void 0) {
|
|
324
|
+
t.__gengageSessionId = n.sessionId, t.gengage || (t.gengage = {}), t.gengage.sessionId = n.sessionId;
|
|
329
325
|
try {
|
|
330
|
-
|
|
326
|
+
t.sessionStorage.setItem("gengage_session_id", n.sessionId);
|
|
331
327
|
} catch {
|
|
332
328
|
}
|
|
333
329
|
}
|
|
334
|
-
if (
|
|
335
|
-
|
|
336
|
-
const a =
|
|
337
|
-
s.userId =
|
|
330
|
+
if (n.userId !== void 0) {
|
|
331
|
+
t.gengage || (t.gengage = {});
|
|
332
|
+
const a = t.gengage, s = a.session ?? {};
|
|
333
|
+
s.userId = n.userId, a.session = s;
|
|
338
334
|
}
|
|
339
335
|
}
|
|
340
|
-
function me(
|
|
341
|
-
const e =
|
|
342
|
-
if (
|
|
343
|
-
const a =
|
|
336
|
+
function me(n = {}) {
|
|
337
|
+
const e = n.win ?? window, t = e;
|
|
338
|
+
if (t.gengageNative) return t.gengageNative;
|
|
339
|
+
const a = n.iosHandlerName ?? "gengage", s = n.androidInterfaceName ?? "GengageNative", i = n.reactNativeInterfaceName ?? "ReactNativeWebView", u = n.trackedEvents ?? [...le], o = fe({ win: e, iosHandlerName: a, androidInterfaceName: s, reactNativeInterfaceName: i });
|
|
344
340
|
let r = e.gengage?.overlay ?? null;
|
|
345
341
|
const c = [], m = (l, d) => {
|
|
346
342
|
const f = d === void 0 ? { type: l } : { type: l, payload: d };
|
|
347
343
|
if (o === "ios") {
|
|
348
|
-
|
|
344
|
+
O(e, a)?.(f);
|
|
349
345
|
return;
|
|
350
346
|
}
|
|
351
347
|
if (o === "android") {
|
|
352
|
-
|
|
348
|
+
w(e, s)?.postMessage(JSON.stringify(f));
|
|
353
349
|
return;
|
|
354
350
|
}
|
|
355
351
|
if (o === "react-native") {
|
|
356
|
-
|
|
352
|
+
w(e, i)?.postMessage(JSON.stringify(f));
|
|
357
353
|
return;
|
|
358
354
|
}
|
|
359
355
|
}, v = (l) => {
|
|
@@ -365,7 +361,7 @@ function me(t = {}) {
|
|
|
365
361
|
});
|
|
366
362
|
};
|
|
367
363
|
e.addEventListener("gengage:bridge:message", v);
|
|
368
|
-
const
|
|
364
|
+
const B = u.map((l) => {
|
|
369
365
|
const d = (f) => {
|
|
370
366
|
const g = f.detail;
|
|
371
367
|
m("widget_event", {
|
|
@@ -380,8 +376,8 @@ function me(t = {}) {
|
|
|
380
376
|
if (!r || c.length === 0) return;
|
|
381
377
|
const l = c.splice(0, c.length);
|
|
382
378
|
for (const d of l)
|
|
383
|
-
|
|
384
|
-
},
|
|
379
|
+
q(d);
|
|
380
|
+
}, q = (l) => {
|
|
385
381
|
const d = ue(l);
|
|
386
382
|
if (!d || typeof d.type != "string") {
|
|
387
383
|
console.warn("[gengage:native-bridge] Invalid message:", l);
|
|
@@ -421,26 +417,26 @@ function me(t = {}) {
|
|
|
421
417
|
return;
|
|
422
418
|
}
|
|
423
419
|
default:
|
|
424
|
-
e.postMessage({ gengage: "native", type: f, payload: g }, e.location.origin),
|
|
420
|
+
e.postMessage({ gengage: "native", type: f, payload: g }, e.location.origin), n.logUnhandled && console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:", f);
|
|
425
421
|
}
|
|
426
|
-
},
|
|
422
|
+
}, b = {
|
|
427
423
|
env: o,
|
|
428
424
|
sendToNative: m,
|
|
429
|
-
receive:
|
|
425
|
+
receive: q,
|
|
430
426
|
setController(l) {
|
|
431
427
|
r = l, D();
|
|
432
428
|
},
|
|
433
429
|
destroy() {
|
|
434
430
|
e.removeEventListener("gengage:bridge:message", v);
|
|
435
|
-
for (const l of
|
|
431
|
+
for (const l of B)
|
|
436
432
|
e.removeEventListener(l.event, l.handler);
|
|
437
|
-
c.splice(0, c.length), e.gengageNative ===
|
|
433
|
+
c.splice(0, c.length), e.gengageNative === b && delete e.gengageNative;
|
|
438
434
|
}
|
|
439
435
|
};
|
|
440
|
-
return
|
|
436
|
+
return t.gengageNative = b, b;
|
|
441
437
|
}
|
|
442
|
-
async function
|
|
443
|
-
const { nativeBridge: e, emitReadyEvent:
|
|
438
|
+
async function Ne(n) {
|
|
439
|
+
const { nativeBridge: e, emitReadyEvent: t = !0, ...a } = n, s = me(e), i = { ...a };
|
|
444
440
|
i.onAddToCart || (i.onAddToCart = (c) => {
|
|
445
441
|
s.sendToNative("addToCart", {
|
|
446
442
|
sku: c.sku,
|
|
@@ -457,25 +453,25 @@ async function Ie(t) {
|
|
|
457
453
|
const u = i.qna?.enabled === !0 || i.qna?.mountTarget !== void 0;
|
|
458
454
|
if (i.qna?.enabled !== !1)
|
|
459
455
|
if (u) {
|
|
460
|
-
const c =
|
|
456
|
+
const c = x(
|
|
461
457
|
window,
|
|
462
|
-
i.qna?.mountTarget ??
|
|
458
|
+
i.qna?.mountTarget ?? A,
|
|
463
459
|
"gengage-qna"
|
|
464
460
|
);
|
|
465
461
|
i.qna = { ...i.qna, enabled: !0, mountTarget: c };
|
|
466
|
-
} else N(window,
|
|
462
|
+
} else N(window, A) || (i.qna = { enabled: !1 });
|
|
467
463
|
const o = i.simrel?.enabled === !0 || i.simrel?.mountTarget !== void 0;
|
|
468
464
|
if (i.simrel?.enabled !== !1)
|
|
469
465
|
if (o) {
|
|
470
|
-
const c =
|
|
466
|
+
const c = x(
|
|
471
467
|
window,
|
|
472
|
-
i.simrel?.mountTarget ??
|
|
468
|
+
i.simrel?.mountTarget ?? E,
|
|
473
469
|
"gengage-simrel"
|
|
474
470
|
);
|
|
475
471
|
i.simrel = { ...i.simrel, enabled: !0, mountTarget: c };
|
|
476
|
-
} else N(window,
|
|
472
|
+
} else N(window, E) || (i.simrel = { enabled: !1 });
|
|
477
473
|
const r = await de(i);
|
|
478
|
-
return s.setController(r),
|
|
474
|
+
return s.setController(r), t && s.sendToNative("ready", {
|
|
479
475
|
sessionId: r.session.sessionId,
|
|
480
476
|
widgets: {
|
|
481
477
|
chat: r.chat !== null,
|
|
@@ -491,20 +487,20 @@ async function Ie(t) {
|
|
|
491
487
|
};
|
|
492
488
|
}
|
|
493
489
|
export {
|
|
494
|
-
|
|
490
|
+
P as A,
|
|
495
491
|
le as D,
|
|
496
492
|
ee as U,
|
|
497
493
|
J as a,
|
|
498
494
|
pe as b,
|
|
499
|
-
|
|
500
|
-
|
|
495
|
+
Ie as c,
|
|
496
|
+
Te as d,
|
|
501
497
|
me as e,
|
|
502
498
|
Ce as f,
|
|
503
499
|
fe as g,
|
|
504
500
|
ce as h,
|
|
505
501
|
de as i,
|
|
506
|
-
|
|
502
|
+
Ne as j,
|
|
507
503
|
ne as p,
|
|
508
|
-
|
|
504
|
+
be as s
|
|
509
505
|
};
|
|
510
|
-
//# sourceMappingURL=index-
|
|
506
|
+
//# sourceMappingURL=index-C6KDzSjm.js.map
|