@gengage/assistant-fe 0.1.9 → 0.2.1
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/assistant-fe.css +1 -1
- package/dist/chat/components/CategoriesContainer.d.ts.map +1 -1
- package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
- package/dist/chat/components/renderUISpec.d.ts.map +1 -1
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/chat/panel-manager.d.ts +16 -0
- package/dist/chat/panel-manager.d.ts.map +1 -1
- package/dist/chat.cjs +1 -1
- package/dist/chat.iife.js +28 -28
- package/dist/chat.iife.js.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/common/action-router.d.ts.map +1 -1
- package/dist/common/debug.d.ts.map +1 -1
- package/dist/common/events.d.ts.map +1 -1
- package/dist/common/native-webview.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/protocol-adapter.d.ts.map +1 -1
- package/dist/common.cjs +1 -1
- package/dist/common.js +5 -5
- package/dist/index-BUtw0Jlm.cjs +2 -0
- package/dist/index-BUtw0Jlm.cjs.map +1 -0
- package/dist/index-D-tVifN8.cjs +13 -0
- package/dist/index-D-tVifN8.cjs.map +1 -0
- package/dist/{index-DR2uepzb.js → index-DjPldwe7.js} +181 -187
- package/dist/index-DjPldwe7.js.map +1 -0
- package/dist/{index-CEt87kCd.js → index-TY0qKDI-.js} +1291 -1292
- package/dist/index-TY0qKDI-.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/native.cjs +1 -1
- package/dist/native.iife.js +30 -30
- package/dist/native.iife.js.map +1 -1
- package/dist/native.js +1 -1
- package/dist/qna.cjs +1 -1
- package/dist/qna.iife.js +2 -2
- package/dist/qna.iife.js.map +1 -1
- package/dist/qna.js +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-DIhL3DkL.js → schemas-BAEbjFPE.js} +17 -12
- package/dist/schemas-BAEbjFPE.js.map +1 -0
- package/dist/{schemas-Dsr0bbO_.cjs → schemas-DIyHm5pa.cjs} +4 -4
- package/dist/{schemas-DIhL3DkL.js.map → schemas-DIyHm5pa.cjs.map} +1 -1
- package/dist/simrel/api.d.ts.map +1 -1
- package/dist/simrel/components/ProductCard.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 +1 -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 +6 -6
- package/dist/simrel.iife.js.map +1 -1
- package/dist/simrel.js +236 -234
- package/dist/simrel.js.map +1 -1
- package/package.json +1 -1
- package/dist/index-BWPx4pM7.cjs +0 -13
- package/dist/index-BWPx4pM7.cjs.map +0 -1
- package/dist/index-CEt87kCd.js.map +0 -1
- package/dist/index-DL4CAkyL.cjs +0 -2
- package/dist/index-DL4CAkyL.cjs.map +0 -1
- package/dist/index-DR2uepzb.js.map +0 -1
- package/dist/quantity-stepper-C-nV4lwi.js +0 -77
- package/dist/quantity-stepper-C-nV4lwi.js.map +0 -1
- package/dist/quantity-stepper-CURMkwRF.cjs +0 -2
- package/dist/quantity-stepper-CURMkwRF.cjs.map +0 -1
- package/dist/schemas-Dsr0bbO_.cjs.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, Y as
|
|
5
|
-
const
|
|
1
|
+
import { G as F } from "./index-TY0qKDI-.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
|
-
}),
|
|
12
|
-
mode:
|
|
11
|
+
}), Y = p({}), J = U(["none", "x-api-key-header", "bearer-header", "body-api-key"]), X = p({
|
|
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
|
-
auth:
|
|
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
|
-
}),
|
|
29
|
-
unknownActionPolicy:
|
|
28
|
+
}), ee = U(["log-and-ignore", "throw", "delegate"]), te = p({
|
|
29
|
+
unknownActionPolicy: ee.default("log-and-ignore"),
|
|
30
30
|
allowScriptCall: y().default(!1)
|
|
31
|
-
}),
|
|
32
|
-
version:
|
|
31
|
+
}), P = p({
|
|
32
|
+
version: j("1", { error: 'version must be "1"' }),
|
|
33
33
|
accountId: h({ error: "accountId must be a non-empty string" }).min(1, { error: "accountId must be a non-empty string" }),
|
|
34
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:
|
|
42
|
-
transport:
|
|
43
|
-
analytics:
|
|
41
|
+
mounts: G.default({}),
|
|
42
|
+
transport: Y.default({}),
|
|
43
|
+
analytics: Z.default({
|
|
44
44
|
enabled: !0,
|
|
45
45
|
endpoint: "/analytics",
|
|
46
46
|
auth: { mode: "none", bodyField: "api_key" },
|
|
@@ -50,29 +50,29 @@ const T = 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
|
}),
|
|
57
|
-
actionHandling:
|
|
57
|
+
actionHandling: te.default({
|
|
58
58
|
unknownActionPolicy: "log-and-ignore",
|
|
59
59
|
allowScriptCall: !1
|
|
60
60
|
})
|
|
61
61
|
});
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
const e =
|
|
65
|
-
return
|
|
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;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
return
|
|
67
|
+
function be(n) {
|
|
68
|
+
return P.safeParse(n);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
return
|
|
70
|
+
function Te(n) {
|
|
71
|
+
return ne({
|
|
72
72
|
version: "1",
|
|
73
|
-
accountId:
|
|
74
|
-
middlewareUrl:
|
|
75
|
-
locale:
|
|
73
|
+
accountId: n.accountId,
|
|
74
|
+
middlewareUrl: n.middlewareUrl,
|
|
75
|
+
locale: n.locale,
|
|
76
76
|
widgets: {
|
|
77
77
|
chat: { enabled: !0 },
|
|
78
78
|
qna: { enabled: !0 },
|
|
@@ -80,37 +80,37 @@ function Ie(t) {
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
85
|
-
const
|
|
86
|
-
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 = {
|
|
87
87
|
instances: {},
|
|
88
88
|
pending: {}
|
|
89
|
-
}),
|
|
89
|
+
}), n.__gengageOverlayRegistry;
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function oe(n) {
|
|
92
92
|
const e = {
|
|
93
|
-
pageType:
|
|
94
|
-
},
|
|
95
|
-
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;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
const
|
|
99
|
-
...
|
|
97
|
+
function ae(n, e) {
|
|
98
|
+
const t = {
|
|
99
|
+
...n,
|
|
100
100
|
...e,
|
|
101
|
-
pageType: e.pageType ??
|
|
101
|
+
pageType: e.pageType ?? n.pageType
|
|
102
102
|
};
|
|
103
|
-
return e.sku === void 0 &&
|
|
103
|
+
return e.sku === void 0 && n.sku !== void 0 && (t.sku = n.sku), t;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
106
|
-
return
|
|
105
|
+
function k(n) {
|
|
106
|
+
return n instanceof HTMLElement || document.querySelector(n) ? n : null;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
return
|
|
108
|
+
function L(n) {
|
|
109
|
+
return n.idempotencyKey ?? `${W}${n.accountId}`;
|
|
110
110
|
}
|
|
111
|
-
class
|
|
112
|
-
constructor(e,
|
|
113
|
-
this.options = e, this.onDestroy =
|
|
111
|
+
class re {
|
|
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);
|
|
114
114
|
}
|
|
115
115
|
get chat() {
|
|
116
116
|
return this._chat;
|
|
@@ -125,7 +125,7 @@ class ce {
|
|
|
125
125
|
return this._analyticsClient;
|
|
126
126
|
}
|
|
127
127
|
async init() {
|
|
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 =
|
|
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;
|
|
129
129
|
}
|
|
130
130
|
openChat(e) {
|
|
131
131
|
this._chat?.open(e);
|
|
@@ -135,25 +135,25 @@ class ce {
|
|
|
135
135
|
}
|
|
136
136
|
async updateContext(e) {
|
|
137
137
|
this._destroyed || await this._enqueue(async () => {
|
|
138
|
-
this._pageContext =
|
|
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();
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
-
async updateSku(e,
|
|
142
|
-
await this.updateContext({ sku: e, pageType:
|
|
141
|
+
async updateSku(e, t = "pdp") {
|
|
142
|
+
await this.updateContext({ sku: e, pageType: t });
|
|
143
143
|
}
|
|
144
144
|
destroy() {
|
|
145
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());
|
|
146
146
|
}
|
|
147
147
|
async _initChat() {
|
|
148
148
|
if (this.options.chat?.enabled === !1) return;
|
|
149
|
-
const e = this.options.middlewareUrl,
|
|
149
|
+
const e = this.options.middlewareUrl, t = {
|
|
150
150
|
accountId: this.options.accountId,
|
|
151
151
|
middlewareUrl: e,
|
|
152
152
|
session: this.session,
|
|
153
153
|
pageContext: this._pageContext,
|
|
154
154
|
variant: this.options.chat?.variant ?? "floating"
|
|
155
155
|
};
|
|
156
|
-
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);
|
|
157
157
|
}
|
|
158
158
|
async _syncPdpWidgets() {
|
|
159
159
|
if (this._destroyed) return;
|
|
@@ -164,12 +164,12 @@ class ce {
|
|
|
164
164
|
}
|
|
165
165
|
const a = this.options.middlewareUrl;
|
|
166
166
|
if (this.options.qna?.enabled !== !1) {
|
|
167
|
-
const s = this.options.qna?.mountTarget ??
|
|
167
|
+
const s = this.options.qna?.mountTarget ?? ie, i = k(s);
|
|
168
168
|
if (i)
|
|
169
169
|
if (this._warnedQnaMountMissing = !1, this._qna)
|
|
170
170
|
this._qna.show(), this._qna.update({ pageType: "pdp", sku: e });
|
|
171
171
|
else {
|
|
172
|
-
const u = new
|
|
172
|
+
const u = new Q(), o = {
|
|
173
173
|
accountId: this.options.accountId,
|
|
174
174
|
middlewareUrl: a,
|
|
175
175
|
session: this.session,
|
|
@@ -186,12 +186,12 @@ class ce {
|
|
|
186
186
|
} else
|
|
187
187
|
this._qna?.destroy(), this._qna = null;
|
|
188
188
|
if (this.options.simrel?.enabled !== !1) {
|
|
189
|
-
const s = this.options.simrel?.mountTarget ??
|
|
189
|
+
const s = this.options.simrel?.mountTarget ?? se, i = k(s);
|
|
190
190
|
if (i)
|
|
191
191
|
if (this._warnedSimRelMountMissing = !1, this._simrel)
|
|
192
192
|
this._simrel.show(), this._simrel.update({ pageType: "pdp", sku: e });
|
|
193
193
|
else {
|
|
194
|
-
const u = new
|
|
194
|
+
const u = new H(), o = {
|
|
195
195
|
accountId: this.options.accountId,
|
|
196
196
|
middlewareUrl: a,
|
|
197
197
|
session: this.session,
|
|
@@ -199,7 +199,7 @@ class ce {
|
|
|
199
199
|
mountTarget: i
|
|
200
200
|
};
|
|
201
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) => {
|
|
202
|
-
|
|
202
|
+
$(r) && (this._chat?.saveSession(m ?? this.session.sessionId, c), window.location.href = r);
|
|
203
203
|
}, await u.init(o), this._simrel = u;
|
|
204
204
|
}
|
|
205
205
|
else
|
|
@@ -211,34 +211,34 @@ class ce {
|
|
|
211
211
|
this._qna?.destroy(), this._simrel?.destroy(), this._qna = null, this._simrel = null;
|
|
212
212
|
}
|
|
213
213
|
_enqueue(e) {
|
|
214
|
-
const
|
|
215
|
-
return this._queue =
|
|
216
|
-
}),
|
|
214
|
+
const t = this._queue.then(e);
|
|
215
|
+
return this._queue = t.catch((a) => {
|
|
216
|
+
}), t;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
async function
|
|
220
|
-
const e =
|
|
219
|
+
async function de(n) {
|
|
220
|
+
const e = L(n), t = I(), a = t.instances[e];
|
|
221
221
|
if (a) return a;
|
|
222
|
-
const s =
|
|
222
|
+
const s = t.pending[e];
|
|
223
223
|
if (s) return s;
|
|
224
|
-
const i = new
|
|
225
|
-
const o =
|
|
224
|
+
const i = new re(n, () => {
|
|
225
|
+
const o = I();
|
|
226
226
|
delete o.instances[e], delete o.pending[e];
|
|
227
|
-
}), u = i.init().then(() => (
|
|
228
|
-
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;
|
|
229
229
|
});
|
|
230
|
-
return
|
|
230
|
+
return t.pending[e] = u, u;
|
|
231
231
|
}
|
|
232
|
-
function
|
|
233
|
-
return
|
|
232
|
+
function ce(n) {
|
|
233
|
+
return I().instances[n] ?? null;
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
|
|
235
|
+
function Ce(n) {
|
|
236
|
+
ce(n)?.destroy();
|
|
237
237
|
}
|
|
238
|
-
function
|
|
239
|
-
return `${
|
|
238
|
+
function Ie(n) {
|
|
239
|
+
return `${W}${n}`;
|
|
240
240
|
}
|
|
241
|
-
const
|
|
241
|
+
const le = [
|
|
242
242
|
"gengage:chat:open",
|
|
243
243
|
"gengage:chat:close",
|
|
244
244
|
"gengage:chat:ready",
|
|
@@ -249,11 +249,11 @@ const ue = [
|
|
|
249
249
|
"gengage:similar:add-to-cart",
|
|
250
250
|
"gengage:global:error",
|
|
251
251
|
"gengage:context:update"
|
|
252
|
-
],
|
|
253
|
-
function
|
|
254
|
-
let e =
|
|
255
|
-
if (typeof
|
|
256
|
-
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();
|
|
257
257
|
if (i.length === 0) return null;
|
|
258
258
|
if (!i.startsWith("{") && !i.startsWith("["))
|
|
259
259
|
return { type: i };
|
|
@@ -264,98 +264,92 @@ function fe(t) {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
if (!e || typeof e != "object") return null;
|
|
267
|
-
const
|
|
267
|
+
const t = e, a = [t.type, t.command, t.action, t.event].find(
|
|
268
268
|
(i) => typeof i == "string" && i.length > 0
|
|
269
269
|
);
|
|
270
270
|
if (!a) return null;
|
|
271
|
-
let s =
|
|
272
|
-
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) {
|
|
273
273
|
const i = {};
|
|
274
|
-
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);
|
|
275
275
|
}
|
|
276
276
|
return s === void 0 ? { type: a } : { type: a, payload: s };
|
|
277
277
|
}
|
|
278
|
-
function
|
|
279
|
-
if (typeof
|
|
280
|
-
return { sku:
|
|
281
|
-
if (
|
|
282
|
-
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;
|
|
283
283
|
if (typeof e == "string" && e.length > 0) {
|
|
284
|
-
const
|
|
285
|
-
return
|
|
284
|
+
const t = n.pageType;
|
|
285
|
+
return t !== void 0 ? { sku: e, pageType: t } : { sku: e };
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
return null;
|
|
289
289
|
}
|
|
290
|
-
function
|
|
291
|
-
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;
|
|
292
292
|
}
|
|
293
|
-
function
|
|
294
|
-
if (e instanceof HTMLElement ||
|
|
293
|
+
function x(n, e, t) {
|
|
294
|
+
if (e instanceof HTMLElement || N(n, e) || typeof e != "string") return e;
|
|
295
295
|
if (e.startsWith("#")) {
|
|
296
296
|
const i = e.slice(1);
|
|
297
297
|
if (i.length > 0) {
|
|
298
|
-
const u =
|
|
298
|
+
const u = n.document.getElementById(i);
|
|
299
299
|
if (u) return u;
|
|
300
|
-
const o =
|
|
301
|
-
return o.id = i,
|
|
300
|
+
const o = n.document.createElement("div");
|
|
301
|
+
return o.id = i, n.document.body.appendChild(o), o;
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
|
-
const a =
|
|
304
|
+
const a = n.document.getElementById(t);
|
|
305
305
|
if (a) return a;
|
|
306
|
-
const s =
|
|
307
|
-
return s.id =
|
|
306
|
+
const s = n.document.createElement("div");
|
|
307
|
+
return s.id = t, n.document.body.appendChild(s), s;
|
|
308
308
|
}
|
|
309
|
-
function
|
|
310
|
-
const
|
|
311
|
-
return
|
|
309
|
+
function O(n, e) {
|
|
310
|
+
const t = n.webkit?.messageHandlers?.[e];
|
|
311
|
+
return t && typeof t.postMessage == "function" ? t.postMessage.bind(t) : null;
|
|
312
312
|
}
|
|
313
|
-
function
|
|
314
|
-
const
|
|
315
|
-
return
|
|
313
|
+
function w(n, e) {
|
|
314
|
+
const t = n[e];
|
|
315
|
+
return t && typeof t == "object" && typeof t.postMessage == "function" ? t : null;
|
|
316
316
|
}
|
|
317
|
-
function
|
|
318
|
-
|
|
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";
|
|
319
320
|
}
|
|
320
|
-
function
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const e = t.win ?? window, n = t.iosHandlerName ?? "gengage", a = t.androidInterfaceName ?? "GengageNative", s = t.reactNativeInterfaceName ?? "ReactNativeWebView";
|
|
325
|
-
return L(e, n) ? "ios" : B(e, a) ? "android" : D(e, s) ? "react-native" : "browser";
|
|
326
|
-
}
|
|
327
|
-
function ye(t, e = {}) {
|
|
328
|
-
const n = e.win ?? window;
|
|
329
|
-
if (t.sessionId !== void 0) {
|
|
330
|
-
n.__gengageSessionId = t.sessionId, n.gengage || (n.gengage = {}), n.gengage.sessionId = t.sessionId;
|
|
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;
|
|
331
325
|
try {
|
|
332
|
-
|
|
326
|
+
t.sessionStorage.setItem("gengage_session_id", n.sessionId);
|
|
333
327
|
} catch {
|
|
334
328
|
}
|
|
335
329
|
}
|
|
336
|
-
if (
|
|
337
|
-
|
|
338
|
-
const a =
|
|
339
|
-
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;
|
|
340
334
|
}
|
|
341
335
|
}
|
|
342
|
-
function
|
|
343
|
-
const e =
|
|
344
|
-
if (
|
|
345
|
-
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 });
|
|
346
340
|
let r = e.gengage?.overlay ?? null;
|
|
347
341
|
const c = [], m = (l, d) => {
|
|
348
342
|
const f = d === void 0 ? { type: l } : { type: l, payload: d };
|
|
349
343
|
if (o === "ios") {
|
|
350
|
-
|
|
344
|
+
O(e, a)?.(f);
|
|
351
345
|
return;
|
|
352
346
|
}
|
|
353
347
|
if (o === "android") {
|
|
354
|
-
|
|
348
|
+
w(e, s)?.postMessage(JSON.stringify(f));
|
|
355
349
|
return;
|
|
356
350
|
}
|
|
357
351
|
if (o === "react-native") {
|
|
358
|
-
|
|
352
|
+
w(e, i)?.postMessage(JSON.stringify(f));
|
|
359
353
|
return;
|
|
360
354
|
}
|
|
361
355
|
}, v = (l) => {
|
|
@@ -367,7 +361,7 @@ function ve(t = {}) {
|
|
|
367
361
|
});
|
|
368
362
|
};
|
|
369
363
|
e.addEventListener("gengage:bridge:message", v);
|
|
370
|
-
const
|
|
364
|
+
const B = u.map((l) => {
|
|
371
365
|
const d = (f) => {
|
|
372
366
|
const g = f.detail;
|
|
373
367
|
m("widget_event", {
|
|
@@ -377,14 +371,14 @@ function ve(t = {}) {
|
|
|
377
371
|
};
|
|
378
372
|
return e.addEventListener(l, d), { event: l, handler: d };
|
|
379
373
|
}), _ = (l) => {
|
|
380
|
-
c.length >=
|
|
381
|
-
},
|
|
374
|
+
c.length >= ge && c.shift(), c.push(l);
|
|
375
|
+
}, D = () => {
|
|
382
376
|
if (!r || c.length === 0) return;
|
|
383
377
|
const l = c.splice(0, c.length);
|
|
384
378
|
for (const d of l)
|
|
385
|
-
|
|
386
|
-
},
|
|
387
|
-
const d =
|
|
379
|
+
q(d);
|
|
380
|
+
}, q = (l) => {
|
|
381
|
+
const d = ue(l);
|
|
388
382
|
if (!d || typeof d.type != "string") {
|
|
389
383
|
console.warn("[gengage:native-bridge] Invalid message:", l);
|
|
390
384
|
return;
|
|
@@ -406,16 +400,16 @@ function ve(t = {}) {
|
|
|
406
400
|
return;
|
|
407
401
|
}
|
|
408
402
|
case "updateSku": {
|
|
409
|
-
const
|
|
410
|
-
if (r &&
|
|
411
|
-
r.updateSku(
|
|
403
|
+
const T = he(g);
|
|
404
|
+
if (r && T) {
|
|
405
|
+
r.updateSku(T.sku, T.pageType);
|
|
412
406
|
return;
|
|
413
407
|
}
|
|
414
408
|
r ? console.warn("[gengage:native-bridge] updateSku: missing sku") : _(d);
|
|
415
409
|
return;
|
|
416
410
|
}
|
|
417
411
|
case "setSession": {
|
|
418
|
-
g && typeof g == "object" &&
|
|
412
|
+
g && typeof g == "object" && pe(g, { win: e });
|
|
419
413
|
return;
|
|
420
414
|
}
|
|
421
415
|
case "destroy": {
|
|
@@ -423,26 +417,26 @@ function ve(t = {}) {
|
|
|
423
417
|
return;
|
|
424
418
|
}
|
|
425
419
|
default:
|
|
426
|
-
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);
|
|
427
421
|
}
|
|
428
|
-
},
|
|
422
|
+
}, b = {
|
|
429
423
|
env: o,
|
|
430
424
|
sendToNative: m,
|
|
431
|
-
receive:
|
|
425
|
+
receive: q,
|
|
432
426
|
setController(l) {
|
|
433
|
-
r = l,
|
|
427
|
+
r = l, D();
|
|
434
428
|
},
|
|
435
429
|
destroy() {
|
|
436
430
|
e.removeEventListener("gengage:bridge:message", v);
|
|
437
|
-
for (const l of
|
|
431
|
+
for (const l of B)
|
|
438
432
|
e.removeEventListener(l.event, l.handler);
|
|
439
|
-
c.splice(0, c.length), e.gengageNative ===
|
|
433
|
+
c.splice(0, c.length), e.gengageNative === b && delete e.gengageNative;
|
|
440
434
|
}
|
|
441
435
|
};
|
|
442
|
-
return
|
|
436
|
+
return t.gengageNative = b, b;
|
|
443
437
|
}
|
|
444
|
-
async function
|
|
445
|
-
const { nativeBridge: e, emitReadyEvent:
|
|
438
|
+
async function Ne(n) {
|
|
439
|
+
const { nativeBridge: e, emitReadyEvent: t = !0, ...a } = n, s = me(e), i = { ...a };
|
|
446
440
|
i.onAddToCart || (i.onAddToCart = (c) => {
|
|
447
441
|
s.sendToNative("addToCart", {
|
|
448
442
|
sku: c.sku,
|
|
@@ -459,25 +453,25 @@ async function Me(t) {
|
|
|
459
453
|
const u = i.qna?.enabled === !0 || i.qna?.mountTarget !== void 0;
|
|
460
454
|
if (i.qna?.enabled !== !1)
|
|
461
455
|
if (u) {
|
|
462
|
-
const c =
|
|
456
|
+
const c = x(
|
|
463
457
|
window,
|
|
464
|
-
i.qna?.mountTarget ??
|
|
458
|
+
i.qna?.mountTarget ?? A,
|
|
465
459
|
"gengage-qna"
|
|
466
460
|
);
|
|
467
461
|
i.qna = { ...i.qna, enabled: !0, mountTarget: c };
|
|
468
|
-
} else
|
|
462
|
+
} else N(window, A) || (i.qna = { enabled: !1 });
|
|
469
463
|
const o = i.simrel?.enabled === !0 || i.simrel?.mountTarget !== void 0;
|
|
470
464
|
if (i.simrel?.enabled !== !1)
|
|
471
465
|
if (o) {
|
|
472
|
-
const c =
|
|
466
|
+
const c = x(
|
|
473
467
|
window,
|
|
474
|
-
i.simrel?.mountTarget ??
|
|
468
|
+
i.simrel?.mountTarget ?? E,
|
|
475
469
|
"gengage-simrel"
|
|
476
470
|
);
|
|
477
471
|
i.simrel = { ...i.simrel, enabled: !0, mountTarget: c };
|
|
478
|
-
} else
|
|
479
|
-
const r = await
|
|
480
|
-
return s.setController(r),
|
|
472
|
+
} else N(window, E) || (i.simrel = { enabled: !1 });
|
|
473
|
+
const r = await de(i);
|
|
474
|
+
return s.setController(r), t && s.sendToNative("ready", {
|
|
481
475
|
sessionId: r.session.sessionId,
|
|
482
476
|
widgets: {
|
|
483
477
|
chat: r.chat !== null,
|
|
@@ -493,20 +487,20 @@ async function Me(t) {
|
|
|
493
487
|
};
|
|
494
488
|
}
|
|
495
489
|
export {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
490
|
+
P as A,
|
|
491
|
+
le as D,
|
|
492
|
+
ee as U,
|
|
493
|
+
J as a,
|
|
494
|
+
pe as b,
|
|
495
|
+
Ie as c,
|
|
496
|
+
Te as d,
|
|
497
|
+
me as e,
|
|
498
|
+
Ce as f,
|
|
499
|
+
fe as g,
|
|
500
|
+
ce as h,
|
|
501
|
+
de as i,
|
|
502
|
+
Ne as j,
|
|
503
|
+
ne as p,
|
|
504
|
+
be as s
|
|
511
505
|
};
|
|
512
|
-
//# sourceMappingURL=index-
|
|
506
|
+
//# sourceMappingURL=index-DjPldwe7.js.map
|