@gengage/assistant-fe 0.4.5 → 0.4.6

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.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/dist/api-paths-C4GDpeTf.js +1214 -0
  3. package/dist/chat/index.d.ts +1 -374
  4. package/dist/chat/runtime.d.ts +374 -0
  5. package/dist/chat-BRKK63lt.js +303 -0
  6. package/dist/chat-runtime.js +13 -0
  7. package/dist/chat.iife.js +6 -6
  8. package/dist/chat.js +11 -10
  9. package/dist/common/config-constants.d.ts +1 -0
  10. package/dist/common/config-schema.d.ts +0 -1
  11. package/dist/common/overlay.d.ts +4 -4
  12. package/dist/common-CEN5OW7E.js +491 -0
  13. package/dist/common.js +78 -76
  14. package/dist/{connection-warning-n88bjkqL.js → connection-warning-B6oIU-9s.js} +1 -1
  15. package/dist/context-VIG4SVcS.js +529 -0
  16. package/dist/index.js +70 -67
  17. package/dist/locale-CfqNifrU.js +7 -0
  18. package/dist/native-webview-DudQ7nHe.js +273 -0
  19. package/dist/native.iife.js +28 -91
  20. package/dist/native.js +1 -1
  21. package/dist/overlay-1EO41ZC7.js +212 -0
  22. package/dist/overlay.d.ts +4 -0
  23. package/dist/overlay.js +10 -0
  24. package/dist/pill-launcher-57nrdLRr.js +364 -0
  25. package/dist/qna/index.d.ts +1 -61
  26. package/dist/qna/runtime.d.ts +61 -0
  27. package/dist/qna-BNvttR6s.js +40 -0
  28. package/dist/qna-runtime.js +8 -0
  29. package/dist/qna.iife.js +4 -4
  30. package/dist/qna.js +6 -5
  31. package/dist/{simrel-K2TGFi1r.js → runtime-BdwZZIrO.js} +244 -293
  32. package/dist/{chat-B1lLKIxj.js → runtime-C0qZk0y7.js} +1643 -2297
  33. package/dist/{qna-C5Ok3wd0.js → runtime-DDu8Wk0z.js} +87 -121
  34. package/dist/schemas-CLo8wCjs.js +3207 -0
  35. package/dist/{simbut-Cb5RfaAp.js → simbut-BMWC6x_t.js} +24 -22
  36. package/dist/simbut.js +1 -1
  37. package/dist/simrel/index.d.ts +1 -59
  38. package/dist/simrel/runtime.d.ts +59 -0
  39. package/dist/simrel-ohfkluhp.js +55 -0
  40. package/dist/simrel-runtime.js +8 -0
  41. package/dist/simrel.iife.js +4 -4
  42. package/dist/simrel.js +7 -6
  43. package/dist/widget-base-TgwiA8cD.js +578 -0
  44. package/package.json +17 -1
  45. package/dist/common-C5e2gLuG.js +0 -387
  46. package/dist/locale-MM0U5eeR.js +0 -1109
  47. package/dist/native-webview-niMtkiHX.js +0 -586
  48. package/dist/schemas-JpRGzRQT.js +0 -4419
  49. /package/dist/{price-formatter-CR6VT5z4.js → price-formatter-xI3g9Cd4.js} +0 -0
package/dist/simrel.js CHANGED
@@ -1,9 +1,10 @@
1
- import { a, i as r, n as i, o as t, r as l, t as m } from "./simrel-K2TGFi1r.js";
1
+ import { a, i as r, n as t, r as i, t as m } from "./runtime-BdwZZIrO.js";
2
+ import { t as s } from "./simrel-ohfkluhp.js";
2
3
  export {
3
4
  m as GengageSimRel,
4
- r as createDefaultSimRelUISpecRegistry,
5
- i as createSimRelWidget,
6
- a as defaultSimRelUnknownUISpecRenderer,
7
- t as renderSimRelUISpec,
8
- l as simRelCatalog
5
+ i as createDefaultSimRelUISpecRegistry,
6
+ t as createSimRelWidget,
7
+ r as defaultSimRelUnknownUISpecRenderer,
8
+ a as renderSimRelUISpec,
9
+ s as simRelCatalog
9
10
  };
@@ -0,0 +1,578 @@
1
+ import { o as h, r as y } from "./context-VIG4SVcS.js";
2
+ function U(e, i) {
3
+ const t = {
4
+ event_name: "stream.start",
5
+ account_id: e.account_id,
6
+ session_id: e.session_id,
7
+ correlation_id: e.correlation_id,
8
+ payload: {
9
+ endpoint: i.endpoint,
10
+ request_id: i.request_id
11
+ }
12
+ };
13
+ return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), i.widget !== void 0 && (t.widget = i.widget), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
14
+ }
15
+ function W(e, i) {
16
+ const t = {
17
+ request_id: i.request_id,
18
+ chunk_index: i.chunk_index
19
+ };
20
+ i.latency_ms !== void 0 && (t.latency_ms = i.latency_ms);
21
+ const r = {
22
+ event_name: "stream.chunk",
23
+ account_id: e.account_id,
24
+ session_id: e.session_id,
25
+ correlation_id: e.correlation_id,
26
+ payload: t
27
+ };
28
+ return e.view_id !== void 0 && (r.view_id = e.view_id), e.user_id !== void 0 && (r.user_id = e.user_id), i.widget !== void 0 && (r.widget = i.widget), e.page_type !== void 0 && (r.page_type = e.page_type), e.sku !== void 0 && (r.sku = e.sku), r;
29
+ }
30
+ function F(e, i) {
31
+ const t = {
32
+ event_name: "stream.ui_spec",
33
+ account_id: e.account_id,
34
+ session_id: e.session_id,
35
+ correlation_id: e.correlation_id,
36
+ payload: {
37
+ request_id: i.request_id,
38
+ chunk_index: i.chunk_index,
39
+ component_type: i.component_type
40
+ }
41
+ };
42
+ return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), i.widget !== void 0 && (t.widget = i.widget), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
43
+ }
44
+ function z(e, i) {
45
+ const t = {
46
+ event_name: "stream.done",
47
+ account_id: e.account_id,
48
+ session_id: e.session_id,
49
+ correlation_id: e.correlation_id,
50
+ payload: {
51
+ request_id: i.request_id,
52
+ latency_ms: i.latency_ms,
53
+ chunk_count: i.chunk_count
54
+ }
55
+ };
56
+ return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), i.widget !== void 0 && (t.widget = i.widget), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
57
+ }
58
+ function G(e, i) {
59
+ const t = {
60
+ event_name: "stream.error",
61
+ account_id: e.account_id,
62
+ session_id: e.session_id,
63
+ correlation_id: e.correlation_id,
64
+ payload: {
65
+ request_id: i.request_id,
66
+ error_code: i.error_code,
67
+ error_message: i.error_message
68
+ }
69
+ };
70
+ return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), i.widget !== void 0 && (t.widget = i.widget), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
71
+ }
72
+ function Y(e, i) {
73
+ const t = {
74
+ model: i.model,
75
+ prompt_tokens: i.prompt_tokens,
76
+ completion_tokens: i.completion_tokens,
77
+ total_tokens: i.total_tokens
78
+ };
79
+ i.provider !== void 0 && (t.provider = i.provider);
80
+ const r = {
81
+ event_name: "llm.usage",
82
+ account_id: e.account_id,
83
+ session_id: e.session_id,
84
+ correlation_id: e.correlation_id,
85
+ payload: t
86
+ };
87
+ return e.view_id !== void 0 && (r.view_id = e.view_id), e.user_id !== void 0 && (r.user_id = e.user_id), e.page_type !== void 0 && (r.page_type = e.page_type), e.sku !== void 0 && (r.sku = e.sku), r;
88
+ }
89
+ function J(e, i) {
90
+ const t = {
91
+ event_name: "metering.increment",
92
+ account_id: e.account_id,
93
+ session_id: e.session_id,
94
+ correlation_id: e.correlation_id,
95
+ payload: {
96
+ meter_key: i.meter_key,
97
+ quantity: i.quantity,
98
+ unit: i.unit
99
+ }
100
+ };
101
+ return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
102
+ }
103
+ function b(e, i) {
104
+ const t = {
105
+ event_name: "metering.summary",
106
+ account_id: e.account_id,
107
+ session_id: e.session_id,
108
+ correlation_id: e.correlation_id,
109
+ payload: {
110
+ meter_key: i.meter_key,
111
+ quantity: i.quantity,
112
+ unit: i.unit
113
+ }
114
+ };
115
+ return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
116
+ }
117
+ function K(e, i) {
118
+ const t = {
119
+ event_name: "chat.history.snapshot",
120
+ account_id: e.account_id,
121
+ session_id: e.session_id,
122
+ correlation_id: e.correlation_id,
123
+ payload: {
124
+ message_count: i.message_count,
125
+ history_ref: i.history_ref,
126
+ redaction_level: i.redaction_level
127
+ }
128
+ };
129
+ return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
130
+ }
131
+ function j(e, i) {
132
+ const t = {
133
+ event_name: "widget.history.snapshot",
134
+ account_id: e.account_id,
135
+ session_id: e.session_id,
136
+ correlation_id: e.correlation_id,
137
+ widget: i.widget,
138
+ payload: {
139
+ message_count: i.message_count,
140
+ history_ref: i.history_ref,
141
+ redaction_level: i.redaction_level
142
+ }
143
+ };
144
+ return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
145
+ }
146
+ function Q(e, i) {
147
+ const t = {
148
+ event_name: "basket.add",
149
+ account_id: e.account_id,
150
+ session_id: e.session_id,
151
+ correlation_id: e.correlation_id,
152
+ widget: i.attribution_source,
153
+ payload: {
154
+ attribution_source: i.attribution_source,
155
+ attribution_action_id: i.attribution_action_id,
156
+ cart_value: i.cart_value,
157
+ currency: i.currency,
158
+ line_items: i.line_items,
159
+ sku: i.sku
160
+ }
161
+ };
162
+ return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
163
+ }
164
+ function w(e, i) {
165
+ const t = {
166
+ event_name: "checkout.start",
167
+ account_id: e.account_id,
168
+ session_id: e.session_id,
169
+ correlation_id: e.correlation_id,
170
+ widget: i.attribution_source,
171
+ payload: {
172
+ attribution_source: i.attribution_source,
173
+ attribution_action_id: i.attribution_action_id,
174
+ cart_value: i.cart_value,
175
+ currency: i.currency,
176
+ line_items: i.line_items
177
+ }
178
+ };
179
+ return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
180
+ }
181
+ function k(e, i) {
182
+ const t = {
183
+ event_name: "checkout.complete",
184
+ account_id: e.account_id,
185
+ session_id: e.session_id,
186
+ correlation_id: e.correlation_id,
187
+ widget: i.attribution_source,
188
+ payload: {
189
+ attribution_source: i.attribution_source,
190
+ attribution_action_id: i.attribution_action_id,
191
+ cart_value: i.cart_value,
192
+ currency: i.currency,
193
+ line_items: i.line_items
194
+ }
195
+ };
196
+ return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
197
+ }
198
+ var _ = {
199
+ "--gengage-chat-offset": "20px",
200
+ "--gengage-chat-launcher-size": "56px",
201
+ "--gengage-chat-width": "400px",
202
+ "--gengage-chat-shell-radius": "1rem",
203
+ "--gengage-chat-header-height": "72px",
204
+ "--gengage-chat-conversation-width": "396px",
205
+ "--gengage-chat-panel-min-width": "320px",
206
+ "--gengage-chat-panel-max-width": "1200px",
207
+ "--gengage-chat-input-height": "48px",
208
+ "--gengage-qna-pill-radius": "999px",
209
+ "--gengage-qna-input-radius": "12px",
210
+ "--gengage-simrel-card-radius": "0.75rem",
211
+ "--radius-control": "12px",
212
+ "--radius-card": "16px",
213
+ "--radius-panel": "24px",
214
+ "--radius-pill": "999px",
215
+ "--surface-card-muted": "#f8fafc",
216
+ "--text-secondary": "#4b5563",
217
+ "--text-muted": "#6b7280",
218
+ "--border-default": "rgba(17, 24, 39, 0.10)"
219
+ };
220
+ function E(e) {
221
+ return e ? {
222
+ ..._,
223
+ ...e
224
+ } : { ..._ };
225
+ }
226
+ var s = {
227
+ primaryColor: "#b7102a",
228
+ primaryForeground: "#ffffff",
229
+ backgroundColor: "#ffffff",
230
+ foregroundColor: "#111827",
231
+ borderRadius: "0.75rem",
232
+ fontFamily: '"Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
233
+ fontSize: "14px",
234
+ zIndex: "1000",
235
+ "--glov-chatbot-width": "420px",
236
+ "--glov-left-spacing": "260px",
237
+ "--chatbot-padding": "16px",
238
+ "--root-wrapper-background-color": "#f8f9fa",
239
+ "--root-wrapper-border-color": "#edeeef",
240
+ "--gengage-chat-width": "400px",
241
+ "--gengage-chat-shell-radius": "1rem",
242
+ "--gengage-chat-header-height": "72px",
243
+ "--gengage-chat-conversation-width": "396px",
244
+ "--gengage-chat-panel-min-width": "320px",
245
+ "--gengage-chat-panel-max-width": "1200px",
246
+ "--gengage-chat-input-height": "48px",
247
+ "--gengage-qna-pill-radius": "999px",
248
+ "--gengage-qna-input-radius": "0.75rem",
249
+ "--gengage-simrel-card-radius": "0.75rem",
250
+ "--client-primary": "#b7102a",
251
+ "--client-primary-hover": "color-mix(in srgb, #b7102a 88%, black 12%)",
252
+ "--client-primary-active": "color-mix(in srgb, #b7102a 78%, black 22%)",
253
+ "--client-primary-subtle": "color-mix(in srgb, #b7102a 12%, white)",
254
+ "--client-primary-soft": "color-mix(in srgb, #b7102a 20%, white)",
255
+ "--client-on-primary": "#ffffff",
256
+ "--client-focus-ring": "color-mix(in srgb, #b7102a 32%, transparent)",
257
+ "--surface-page": "#f6f7fb",
258
+ "--surface-shell": "#10131a",
259
+ "--surface-card": "#ffffff",
260
+ "--surface-card-muted": "#f8fafc",
261
+ "--surface-card-soft": "#f8fafc",
262
+ "--surface-elevated": "#ffffff",
263
+ "--surface-input": "#ffffff",
264
+ "--surface-overlay": "rgba(16, 19, 26, 0.52)",
265
+ "--text-primary": "#111827",
266
+ "--text-secondary": "#4b5563",
267
+ "--text-muted": "#6b7280",
268
+ "--text-inverse": "#f9fafb",
269
+ "--border-subtle": "rgba(17, 24, 39, 0.06)",
270
+ "--border-default": "rgba(17, 24, 39, 0.10)",
271
+ "--border-strong": "rgba(17, 24, 39, 0.18)",
272
+ "--shadow-1": "0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06)",
273
+ "--shadow-2": "0 4px 12px rgba(16, 24, 40, 0.08)",
274
+ "--shadow-3": "0 10px 24px rgba(16, 24, 40, 0.12)",
275
+ "--radius-control": "12px",
276
+ "--radius-card": "16px",
277
+ "--radius-panel": "24px",
278
+ "--radius-pill": "999px",
279
+ "--success": "#16a34a",
280
+ "--warning": "#d97706",
281
+ "--error": "#dc2626",
282
+ "--info": "#2563eb",
283
+ "--rating": "#f5b301",
284
+ "--ai-accent-start": "#0b24d6",
285
+ "--ai-accent-end": "#f768f2",
286
+ "--ai-accent-soft": "linear-gradient(135deg, rgba(11, 36, 214, 0.08), rgba(247, 104, 242, 0.08))"
287
+ };
288
+ function X(e) {
289
+ return {
290
+ ...s,
291
+ ...e
292
+ };
293
+ }
294
+ var o = "gengage-global-toast-root", c = "gengage-global-toast-style", g = "gengage-global-toast-root--visible", C = 4200, T = 1500, I = 15e3, S = [
295
+ "--gengage-font-family",
296
+ "--surface-card",
297
+ "--text-primary",
298
+ "--text-muted",
299
+ "--border-default",
300
+ "--radius-card",
301
+ "--shadow-3",
302
+ "--error",
303
+ "--ds-toast-error-bg",
304
+ "--ds-toast-error-border",
305
+ "--ds-toast-error-accent",
306
+ "--ds-toast-error-fg",
307
+ "--ds-toast-error-shadow"
308
+ ], f = !1, a = null, M = [
309
+ /failed to fetch/i,
310
+ /networkerror/i,
311
+ /network request failed/i,
312
+ /load failed/i,
313
+ /err_network/i,
314
+ /fetch failed/i,
315
+ /network error/i
316
+ ];
317
+ function l(e) {
318
+ return typeof e == "string" && e.toLowerCase().startsWith("tr");
319
+ }
320
+ function q(e) {
321
+ if (typeof navigator < "u" && navigator.onLine === !1) return !0;
322
+ const i = e instanceof Error ? e.message.trim() : "";
323
+ return i ? M.some((t) => t.test(i)) : !1;
324
+ }
325
+ function Z(e, i) {
326
+ return q(i) ? l(e) ? "Bağlantı sorunu oluştu. Lütfen tekrar deneyin." : "Connection issue. Please try again." : l(e) ? "Bir hata oluştu. Lütfen tekrar deneyin." : "Something went wrong. Please try again.";
327
+ }
328
+ function $() {
329
+ f || typeof window > "u" || typeof document > "u" || (f = !0, h("gengage:global:error", (e) => {
330
+ L(e);
331
+ }));
332
+ }
333
+ function L(e) {
334
+ if (typeof document > "u") return;
335
+ const i = e.message.trim();
336
+ if (!i) return;
337
+ O();
338
+ const t = N();
339
+ D(t), t.innerHTML = "";
340
+ const r = document.createElement("section");
341
+ r.className = "gengage-global-toast gengage-global-toast--error", r.setAttribute("role", "status"), r.setAttribute("aria-live", "polite");
342
+ const n = document.createElement("div");
343
+ n.className = "gengage-global-toast-title", n.textContent = A(e.source);
344
+ const d = document.createElement("div");
345
+ d.className = "gengage-global-toast-message", d.textContent = i, r.appendChild(n), r.appendChild(d), t.appendChild(r), t.classList.add(g), a && (clearTimeout(a), a = null), e.sticky !== !0 && (a = setTimeout(() => {
346
+ R();
347
+ }, B(e.durationMs)));
348
+ }
349
+ function R() {
350
+ if (typeof document > "u") return;
351
+ const e = document.getElementById(o);
352
+ e && (e.classList.remove(g), e.innerHTML = "", a && (clearTimeout(a), a = null));
353
+ }
354
+ function A(e) {
355
+ switch (e) {
356
+ case "chat":
357
+ return "Chat warning";
358
+ case "qna":
359
+ return "QnA warning";
360
+ case "simrel":
361
+ return "Widget warning";
362
+ default:
363
+ return "Connection warning";
364
+ }
365
+ }
366
+ function N() {
367
+ const e = document.getElementById(o);
368
+ if (e instanceof HTMLElement) return e;
369
+ const i = document.createElement("div");
370
+ return i.id = o, i.className = "gengage-global-toast-root", document.body.appendChild(i), i;
371
+ }
372
+ function D(e) {
373
+ if (typeof document > "u" || typeof window > "u") return;
374
+ const i = document.querySelector(".gengage-chat-root, .gengage-qna-container, .gengage-simrel-container, .gengage-simbut-root");
375
+ if (!i) return;
376
+ const t = window.getComputedStyle(i);
377
+ for (const r of S) {
378
+ const n = t.getPropertyValue(r).trim();
379
+ n ? e.style.setProperty(r, n) : e.style.removeProperty(r);
380
+ }
381
+ }
382
+ function B(e) {
383
+ return typeof e != "number" || !Number.isFinite(e) ? C : Math.min(I, Math.max(T, Math.round(e)));
384
+ }
385
+ function O() {
386
+ if (document.getElementById(c)) return;
387
+ const e = document.createElement("style");
388
+ e.id = c;
389
+ const i = s["--surface-card"] ?? s.backgroundColor ?? "#ffffff", t = s["--text-primary"] ?? s.foregroundColor ?? "#111827", r = s["--border-default"] ?? "rgba(17, 24, 39, 0.10)", n = s["--error"] ?? "#dc2626", d = s["--shadow-3"] ?? "0 10px 24px rgba(16, 24, 40, 0.12)", v = s["--radius-card"] ?? "16px", m = s["--text-muted"] ?? "#6b7280";
390
+ e.textContent = `
391
+ #${o} {
392
+ position: fixed;
393
+ top: 16px;
394
+ right: 16px;
395
+ z-index: 2147483646;
396
+ pointer-events: none;
397
+ }
398
+ #${o}.${g} {
399
+ pointer-events: auto;
400
+ }
401
+ #${o} .gengage-global-toast {
402
+ min-width: 260px;
403
+ max-width: min(92vw, 420px);
404
+ border-radius: var(--radius-card, ${v});
405
+ border: 1px solid var(--ds-toast-error-border, color-mix(in srgb, var(--error, ${n}) 18%, var(--border-default, ${r})));
406
+ border-left: 4px solid var(--ds-toast-error-accent, var(--error, ${n}));
407
+ background: var(--ds-toast-error-bg, color-mix(in srgb, var(--error, ${n}) 5%, var(--surface-card, ${i})));
408
+ color: var(--ds-toast-error-fg, color-mix(in srgb, var(--error, ${n}) 22%, var(--text-primary, ${t})));
409
+ box-shadow: var(--ds-toast-error-shadow, var(--shadow-3, ${d}));
410
+ padding: 10px 12px;
411
+ font-family: var(--gengage-font-family, ${JSON.stringify(s.fontFamily ?? '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif')});
412
+ font-size: 13px;
413
+ line-height: 1.4;
414
+ animation: gengage-global-toast-in 180ms ease-out forwards;
415
+ }
416
+ #${o} .gengage-global-toast-title {
417
+ margin: 0 0 4px;
418
+ font-size: 12px;
419
+ font-weight: 700;
420
+ color: var(--text-muted, ${m});
421
+ }
422
+ #${o} .gengage-global-toast-message {
423
+ margin: 0;
424
+ font-weight: 500;
425
+ }
426
+ @keyframes gengage-global-toast-in {
427
+ from {
428
+ opacity: 0;
429
+ transform: translateY(-8px);
430
+ }
431
+ to {
432
+ opacity: 1;
433
+ transform: translateY(0);
434
+ }
435
+ }
436
+ `, document.head.appendChild(e);
437
+ }
438
+ var u = null;
439
+ function V() {
440
+ if (u !== null) return u;
441
+ try {
442
+ u = localStorage.getItem("gengage:debug") === "1";
443
+ } catch {
444
+ u = !1;
445
+ }
446
+ return u;
447
+ }
448
+ function p(e, i, t) {
449
+ if (!V()) return;
450
+ const r = [`[gengage:${e}]`, i];
451
+ t !== void 0 && r.push(t), console.debug(...r);
452
+ }
453
+ var x = class {
454
+ constructor() {
455
+ this.isVisible = !1, this.isInitialised = !1, this._handlers = /* @__PURE__ */ new Map(), this._cleanups = [], this._ownsRoot = !1, this._destroying = !1;
456
+ }
457
+ async init(e) {
458
+ if (this.isInitialised) {
459
+ console.warn("[gengage] Widget already initialised. Call update() instead.");
460
+ return;
461
+ }
462
+ const i = E(e.theme);
463
+ this.config = {
464
+ ...e,
465
+ theme: i,
466
+ session: y(e.session)
467
+ }, this.root = this._resolveMount(e.mountTarget), this._applyTheme(i), $();
468
+ const t = h("gengage:context:update", (r) => this.update(r));
469
+ this._cleanups.push(t), p("lifecycle", `${this.constructor.name}.init`, {
470
+ accountId: e.accountId,
471
+ sku: e.pageContext?.sku
472
+ });
473
+ try {
474
+ await this.onInit(this.config);
475
+ } catch (r) {
476
+ throw this.destroy(), r;
477
+ }
478
+ this._destroying || (this.isInitialised = !0, p("lifecycle", `${this.constructor.name} ready`), this.emit("ready"));
479
+ }
480
+ update(e) {
481
+ this.isInitialised && (this.config.pageContext ? this.config = {
482
+ ...this.config,
483
+ pageContext: {
484
+ ...this.config.pageContext,
485
+ ...e
486
+ }
487
+ } : e.pageType !== void 0 && (this.config = {
488
+ ...this.config,
489
+ pageContext: e
490
+ }), this.onUpdate(e), this.emit("context-update", this.config.pageContext));
491
+ }
492
+ show() {
493
+ this.isVisible || (this.isVisible = !0, this.root.style.display = "", this.onShow(), this.emit("show"));
494
+ }
495
+ hide() {
496
+ this.isVisible && (this.isVisible = !1, this.root.style.display = "none", this.onHide(), this.emit("hide"));
497
+ }
498
+ destroy() {
499
+ this._destroying || (this._destroying = !0, this.emit("destroy"), this._cleanups.forEach((e) => e()), this._cleanups.length = 0, this._handlers.clear(), this.onDestroy(), this.config.analyticsClient?.destroy(), this._cleanupRoot(), this.isInitialised = !1);
500
+ }
501
+ _cleanupRoot() {
502
+ this._ownsRoot ? this.root.remove() : this.root.innerHTML = "";
503
+ }
504
+ on(e, i) {
505
+ return this._handlers.has(e) || this._handlers.set(e, /* @__PURE__ */ new Set()), this._handlers.get(e).add(i), () => this._handlers.get(e)?.delete(i);
506
+ }
507
+ trackCheckout(e, i) {
508
+ const t = e === "start" ? w : k;
509
+ this.track(t(this.analyticsContext(), i));
510
+ }
511
+ flushMeteringSummary(e) {
512
+ this.track(b(this.analyticsContext(), e));
513
+ }
514
+ emit(e, ...i) {
515
+ this._handlers.get(e)?.forEach((t) => t(...i));
516
+ }
517
+ addCleanup(e) {
518
+ this._cleanups.push(e);
519
+ }
520
+ track(e) {
521
+ this.config.analyticsClient?.track(e);
522
+ }
523
+ analyticsContext() {
524
+ const e = {
525
+ account_id: this.config.accountId,
526
+ session_id: this.config.session?.sessionId ?? "",
527
+ correlation_id: this.config.session?.sessionId ?? ""
528
+ };
529
+ return this.config.session?.viewId !== void 0 && (e.view_id = this.config.session.viewId), this.config.session?.userId !== void 0 && (e.user_id = this.config.session.userId), this.config.pageContext?.pageType !== void 0 && (e.page_type = this.config.pageContext.pageType), this.config.pageContext?.sku !== void 0 && (e.sku = this.config.pageContext.sku), this.config.session?.abTestVariant !== void 0 && (e.ab_test_variant = this.config.session.abTestVariant), this.config.session?.abTestExperimentId !== void 0 && (e.ab_test_experiment_id = this.config.session.abTestExperimentId), e;
530
+ }
531
+ _resolveMount(e) {
532
+ if (e instanceof HTMLElement) return e;
533
+ if (typeof e == "string") {
534
+ const t = document.querySelector(e);
535
+ if (!t) throw new Error(`[gengage] Mount target not found: "${e}"`);
536
+ return t;
537
+ }
538
+ const i = document.createElement("div");
539
+ return i.dataset.gengageWidget = this.constructor.name.toLowerCase(), document.body.insertBefore(i, document.body.firstChild), this._ownsRoot = !0, i;
540
+ }
541
+ _applyTheme(e) {
542
+ if (e) {
543
+ for (const [i, t] of Object.entries(e)) if (t !== void 0) {
544
+ const r = i.startsWith("--") ? i : `--gengage-${H(i)}`;
545
+ this.root.style.setProperty(r, t);
546
+ }
547
+ }
548
+ }
549
+ };
550
+ function H(e) {
551
+ return e.replace(/([A-Z])/g, "-$1").toLowerCase();
552
+ }
553
+ export {
554
+ F as C,
555
+ U as S,
556
+ J as _,
557
+ q as a,
558
+ z as b,
559
+ s as c,
560
+ E as d,
561
+ Q as f,
562
+ Y as g,
563
+ w as h,
564
+ Z as i,
565
+ X as l,
566
+ k as m,
567
+ p as n,
568
+ $ as o,
569
+ K as p,
570
+ R as r,
571
+ L as s,
572
+ x as t,
573
+ _ as u,
574
+ b as v,
575
+ j as w,
576
+ G as x,
577
+ W as y
578
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gengage/assistant-fe",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Source-available frontend widgets for Gengage AI Assistant — chat, Q&A, and similar-products. Backend is SaaS (gengage.ai).",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -43,14 +43,26 @@
43
43
  "types": "./dist/chat/index.d.ts",
44
44
  "import": "./dist/chat.js"
45
45
  },
46
+ "./chat/runtime": {
47
+ "types": "./dist/chat/runtime.d.ts",
48
+ "import": "./dist/chat-runtime.js"
49
+ },
46
50
  "./qna": {
47
51
  "types": "./dist/qna/index.d.ts",
48
52
  "import": "./dist/qna.js"
49
53
  },
54
+ "./qna/runtime": {
55
+ "types": "./dist/qna/runtime.d.ts",
56
+ "import": "./dist/qna-runtime.js"
57
+ },
50
58
  "./simrel": {
51
59
  "types": "./dist/simrel/index.d.ts",
52
60
  "import": "./dist/simrel.js"
53
61
  },
62
+ "./simrel/runtime": {
63
+ "types": "./dist/simrel/runtime.d.ts",
64
+ "import": "./dist/simrel-runtime.js"
65
+ },
54
66
  "./simbut": {
55
67
  "types": "./dist/simbut/index.d.ts",
56
68
  "import": "./dist/simbut.js"
@@ -63,6 +75,10 @@
63
75
  "types": "./dist/native/index.d.ts",
64
76
  "import": "./dist/native.js"
65
77
  },
78
+ "./overlay": {
79
+ "types": "./dist/overlay.d.ts",
80
+ "import": "./dist/overlay.js"
81
+ },
66
82
  "./chat.iife": "./dist/chat.iife.js",
67
83
  "./qna.iife": "./dist/qna.iife.js",
68
84
  "./simrel.iife": "./dist/simrel.iife.js",