@xpert-ai/chatkit-ui5 0.18.0 → 0.18.2
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/chatkit.cjs +152 -48
- package/dist/chatkit.cjs.map +1 -1
- package/dist/chatkit.ui5.js +152 -48
- package/dist/chatkit.ui5.js.map +1 -1
- package/dist/index.js +152 -48
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/chatkit.cjs
CHANGED
|
@@ -48,7 +48,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
48
48
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
49
49
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
50
50
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
51
|
-
var _a, _b, _setTrainingOptOut_dec, _hideHistory_dec, _showHistory_dec, _sendCustomAction_dec, _shareThread_dec, _focusMessage_dec, _prepareLeave_dec, _setThreadId_dec, _setRuntimeCapabilities_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _c, _opts, _frameUrl, _frame, _wrapper, _windowDrag, _launcherCloseButton, _launcherOpen, _chatMinimizedToPet, _framePetOptionsOverride, _petClosedByContextMenu, _shadow, _petOverlay, _resolveLoaded, _loaded, _channelId, _messenger, _ChatKitElementBase_instances, emitAndThrow_fn, setOptionsDataAttributes_fn, getDisplayMode_fn, getConfiguredPetOptions_fn, mergeConfiguredPetPositionDefaults_fn, getOverlayPetOptions_fn, resolvePetAssetUrl_fn, resolveOverlayPetOptions_fn,
|
|
51
|
+
var _a, _b, _setTrainingOptOut_dec, _hideHistory_dec, _showHistory_dec, _sendCustomAction_dec, _shareThread_dec, _focusMessage_dec, _prepareLeave_dec, _setThreadId_dec, _setRuntimeCapabilities_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _c, _opts, _frameUrl, _frame, _wrapper, _windowDrag, _launcherCloseButton, _launcherOpen, _chatMinimizedToPet, _framePetOptionsOverride, _petClosedByContextMenu, _hostLauncherEnabled, _launcherVisible, _shadow, _petOverlay, _resolveLoaded, _loaded, _channelId, _messenger, _ChatKitElementBase_instances, emitAndThrow_fn, setOptionsDataAttributes_fn, getDisplayMode_fn, getConfiguredPetOptions_fn, mergeConfiguredPetPositionDefaults_fn, effectivePet_fn, innerOptions_fn, updateFrameOptions_fn, isLauncherHidden_fn, requestLauncherVisibility_fn, getOverlayPetOptions_fn, resolvePetAssetUrl_fn, resolveOverlayPetOptions_fn, setLauncherOpen_fn, setChatMinimizedToPet_fn, syncPetOverlayOptions_fn, handlePetActivate_fn, handlePetClose_fn, handlePetReply_fn, handlePetThreadSummaryActivate_fn, _handleLauncherClose, getFrameUrl_fn, setFrameUrl_fn, consumeFrameUrl_fn, _handleFrameLoad, _initialized, maybeInit_fn, _init;
|
|
52
52
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
53
53
|
const chatkitTypes = require("@xpert-ai/chatkit-types");
|
|
54
54
|
class EventEmitter {
|
|
@@ -272,10 +272,12 @@ class HttpError extends Error {
|
|
|
272
272
|
super(message);
|
|
273
273
|
__publicField(this, "status");
|
|
274
274
|
__publicField(this, "statusText");
|
|
275
|
+
__publicField(this, "retryAfterMs");
|
|
275
276
|
__publicField(this, "metadata");
|
|
276
277
|
this.name = "HttpError";
|
|
277
278
|
this.statusText = res.statusText;
|
|
278
279
|
this.status = res.status;
|
|
280
|
+
this.retryAfterMs = res.retryAfterMs;
|
|
279
281
|
this.metadata = metadata;
|
|
280
282
|
}
|
|
281
283
|
static fromPossibleFrameSafeError(error) {
|
|
@@ -288,7 +290,8 @@ class HttpError extends Error {
|
|
|
288
290
|
safeError.message,
|
|
289
291
|
{
|
|
290
292
|
status: safeError.status,
|
|
291
|
-
statusText: safeError.statusText
|
|
293
|
+
statusText: safeError.statusText,
|
|
294
|
+
retryAfterMs: safeError.retryAfterMs
|
|
292
295
|
},
|
|
293
296
|
safeError.metadata
|
|
294
297
|
);
|
|
@@ -306,11 +309,13 @@ const _FrameSafeHttpError = class _FrameSafeHttpError {
|
|
|
306
309
|
__publicField(this, "stack");
|
|
307
310
|
__publicField(this, "status");
|
|
308
311
|
__publicField(this, "statusText");
|
|
312
|
+
__publicField(this, "retryAfterMs");
|
|
309
313
|
__publicField(this, "metadata");
|
|
310
314
|
this.message = message;
|
|
311
315
|
this.stack = new Error(message).stack;
|
|
312
316
|
this.status = res.status;
|
|
313
317
|
this.statusText = res.statusText;
|
|
318
|
+
this.retryAfterMs = res.retryAfterMs;
|
|
314
319
|
this.metadata = metadata;
|
|
315
320
|
}
|
|
316
321
|
static fromHttpError(error) {
|
|
@@ -318,7 +323,8 @@ const _FrameSafeHttpError = class _FrameSafeHttpError {
|
|
|
318
323
|
error.message,
|
|
319
324
|
{
|
|
320
325
|
status: error.status,
|
|
321
|
-
statusText: error.statusText
|
|
326
|
+
statusText: error.statusText,
|
|
327
|
+
retryAfterMs: error.retryAfterMs
|
|
322
328
|
},
|
|
323
329
|
error.metadata
|
|
324
330
|
);
|
|
@@ -440,19 +446,42 @@ class FrameSafeIntegrationError {
|
|
|
440
446
|
}
|
|
441
447
|
}
|
|
442
448
|
function serializeFrameError(error) {
|
|
449
|
+
if (error instanceof HttpError || error instanceof FrameSafeHttpError) {
|
|
450
|
+
try {
|
|
451
|
+
return structuredClone(
|
|
452
|
+
error instanceof HttpError ? FrameSafeHttpError.fromHttpError(error) : error
|
|
453
|
+
);
|
|
454
|
+
} catch {
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
if (error && typeof error === "object" && "status" in error && typeof error.status === "number") {
|
|
458
|
+
const message = "message" in error && typeof error.message === "string" ? error.message : "ChatKit host request failed";
|
|
459
|
+
return new FrameSafeHttpError(message, {
|
|
460
|
+
status: error.status,
|
|
461
|
+
statusText: "statusText" in error && typeof error.statusText === "string" ? error.statusText : void 0,
|
|
462
|
+
retryAfterMs: readRetryAfterMs(error)
|
|
463
|
+
});
|
|
464
|
+
}
|
|
443
465
|
try {
|
|
444
466
|
return structuredClone(error);
|
|
445
467
|
} catch {
|
|
446
468
|
const message = error && typeof error === "object" && "message" in error && typeof error.message === "string" ? error.message : "ChatKit host request failed";
|
|
447
|
-
if (error && typeof error === "object" && "status" in error && typeof error.status === "number") {
|
|
448
|
-
return new FrameSafeHttpError(message, {
|
|
449
|
-
status: error.status,
|
|
450
|
-
statusText: "statusText" in error && typeof error.statusText === "string" ? error.statusText : void 0
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
469
|
return new Error(message);
|
|
454
470
|
}
|
|
455
471
|
}
|
|
472
|
+
function readRetryAfterMs(error) {
|
|
473
|
+
if ("retryAfterMs" in error && typeof error.retryAfterMs === "number" && Number.isFinite(error.retryAfterMs)) {
|
|
474
|
+
return Math.max(0, error.retryAfterMs);
|
|
475
|
+
}
|
|
476
|
+
if (!("headers" in error) || !error.headers || typeof error.headers !== "object")
|
|
477
|
+
return;
|
|
478
|
+
const headers = error.headers;
|
|
479
|
+
if (!("get" in headers) || typeof headers.get !== "function") return;
|
|
480
|
+
const value = headers.get("Retry-After");
|
|
481
|
+
if (typeof value !== "string" || !value.trim()) return;
|
|
482
|
+
const duration = /^\d+(\.\d+)?$/.test(value.trim()) ? Number(value) * 1e3 : Date.parse(value) - Date.now();
|
|
483
|
+
return Number.isFinite(duration) ? Math.max(0, duration) : void 0;
|
|
484
|
+
}
|
|
456
485
|
class BaseMessenger {
|
|
457
486
|
constructor({
|
|
458
487
|
handlers,
|
|
@@ -1009,6 +1038,7 @@ const PET_SUMMARY_FONT_FAMILY = 'system-ui, -apple-system, BlinkMacSystemFont, "
|
|
|
1009
1038
|
const PET_OVERLAY_COPY = {
|
|
1010
1039
|
"en-US": {
|
|
1011
1040
|
closePetMenuItem: "Close pet",
|
|
1041
|
+
reopenPet: "Show pet",
|
|
1012
1042
|
hideMessage: "Hide message",
|
|
1013
1043
|
expandMessage: "Expand message",
|
|
1014
1044
|
collapseMessage: "Collapse message",
|
|
@@ -1021,6 +1051,7 @@ const PET_OVERLAY_COPY = {
|
|
|
1021
1051
|
},
|
|
1022
1052
|
"zh-CN": {
|
|
1023
1053
|
closePetMenuItem: "关闭宠物",
|
|
1054
|
+
reopenPet: "显示宠物",
|
|
1024
1055
|
hideMessage: "隐藏消息",
|
|
1025
1056
|
expandMessage: "展开消息",
|
|
1026
1057
|
collapseMessage: "收起消息",
|
|
@@ -1231,6 +1262,7 @@ function parseThreadSummaryLogPayload(value) {
|
|
|
1231
1262
|
}
|
|
1232
1263
|
class PetOverlay {
|
|
1233
1264
|
constructor(root, options) {
|
|
1265
|
+
this.reopenButton = null;
|
|
1234
1266
|
this.overlayElement = null;
|
|
1235
1267
|
this.petElement = null;
|
|
1236
1268
|
this.contextMenuElement = null;
|
|
@@ -1478,6 +1510,7 @@ class PetOverlay {
|
|
|
1478
1510
|
this.root = root;
|
|
1479
1511
|
this.onActivate = options == null ? void 0 : options.onActivate;
|
|
1480
1512
|
this.onClose = options == null ? void 0 : options.onClose;
|
|
1513
|
+
this.onReopen = options == null ? void 0 : options.onReopen;
|
|
1481
1514
|
this.onReply = options == null ? void 0 : options.onReply;
|
|
1482
1515
|
this.onThreadSummaryActivate = options == null ? void 0 : options.onThreadSummaryActivate;
|
|
1483
1516
|
this.connect();
|
|
@@ -1521,6 +1554,44 @@ class PetOverlay {
|
|
|
1521
1554
|
this.resolveCharacter();
|
|
1522
1555
|
this.render();
|
|
1523
1556
|
}
|
|
1557
|
+
setReopenVisible(visible, zIndex) {
|
|
1558
|
+
var _a2, _b2, _c2, _d, _e, _f;
|
|
1559
|
+
if (!visible) {
|
|
1560
|
+
(_a2 = this.reopenButton) == null ? void 0 : _a2.remove();
|
|
1561
|
+
this.reopenButton = null;
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1564
|
+
if (!this.reopenButton) {
|
|
1565
|
+
const button2 = document.createElement("button");
|
|
1566
|
+
button2.type = "button";
|
|
1567
|
+
button2.addEventListener("click", () => {
|
|
1568
|
+
var _a3;
|
|
1569
|
+
return (_a3 = this.onReopen) == null ? void 0 : _a3.call(this);
|
|
1570
|
+
});
|
|
1571
|
+
this.root.append(button2);
|
|
1572
|
+
this.reopenButton = button2;
|
|
1573
|
+
}
|
|
1574
|
+
const button = this.reopenButton;
|
|
1575
|
+
const theme = typeof this.theme === "object" ? this.theme : null;
|
|
1576
|
+
const metrics = getSummaryThemeMetrics(this.theme);
|
|
1577
|
+
button.textContent = this.copy.reopenPet;
|
|
1578
|
+
Object.assign(button.style, {
|
|
1579
|
+
position: "fixed",
|
|
1580
|
+
insetInlineEnd: `${PET_SUMMARY_MARGIN}px`,
|
|
1581
|
+
bottom: `${PET_SUMMARY_MARGIN}px`,
|
|
1582
|
+
zIndex: String(zIndex ?? ((_b2 = chatkitTypes.normalizePetOptions(true)) == null ? void 0 : _b2.position.zIndex)),
|
|
1583
|
+
pointerEvents: "auto",
|
|
1584
|
+
cursor: "pointer",
|
|
1585
|
+
colorScheme: typeof this.theme === "string" ? this.theme : (theme == null ? void 0 : theme.colorScheme) ?? "light",
|
|
1586
|
+
color: ((_d = (_c2 = theme == null ? void 0 : theme.color) == null ? void 0 : _c2.surface) == null ? void 0 : _d.foreground) ?? "ButtonText",
|
|
1587
|
+
background: ((_f = (_e = theme == null ? void 0 : theme.color) == null ? void 0 : _e.surface) == null ? void 0 : _f.background) ?? "ButtonFace",
|
|
1588
|
+
border: "1px solid ButtonBorder",
|
|
1589
|
+
borderRadius: `${metrics.radius}px`,
|
|
1590
|
+
padding: metrics.padding,
|
|
1591
|
+
fontFamily: metrics.fontFamily,
|
|
1592
|
+
fontSize: `${metrics.bodySize}px`
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1524
1595
|
setState(state) {
|
|
1525
1596
|
var _a2;
|
|
1526
1597
|
const previous = this.lastAutoState;
|
|
@@ -1584,6 +1655,7 @@ class PetOverlay {
|
|
|
1584
1655
|
return;
|
|
1585
1656
|
}
|
|
1586
1657
|
this.connected = false;
|
|
1658
|
+
this.setReopenVisible(false);
|
|
1587
1659
|
this.clearRestingDelayTimer();
|
|
1588
1660
|
this.clearTimers();
|
|
1589
1661
|
this.removeDragListeners();
|
|
@@ -2491,9 +2563,6 @@ class PetOverlay {
|
|
|
2491
2563
|
window.removeEventListener("pointercancel", this.handlePointerUp);
|
|
2492
2564
|
}
|
|
2493
2565
|
}
|
|
2494
|
-
function getInnerOptions(options) {
|
|
2495
|
-
return removeMethods(options);
|
|
2496
|
-
}
|
|
2497
2566
|
function requireCommandCapability(value, context) {
|
|
2498
2567
|
const command = String(context.name);
|
|
2499
2568
|
return function(...args) {
|
|
@@ -2520,10 +2589,13 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
2520
2589
|
__privateAdd(this, _chatMinimizedToPet, false);
|
|
2521
2590
|
__privateAdd(this, _framePetOptionsOverride);
|
|
2522
2591
|
__privateAdd(this, _petClosedByContextMenu, false);
|
|
2592
|
+
__privateAdd(this, _hostLauncherEnabled, true);
|
|
2593
|
+
__privateAdd(this, _launcherVisible, true);
|
|
2523
2594
|
__privateAdd(this, _shadow, this.attachShadow({ mode: "open" }));
|
|
2524
2595
|
__privateAdd(this, _petOverlay, new PetOverlay(__privateGet(this, _shadow), {
|
|
2525
2596
|
onActivate: () => __privateMethod(this, _ChatKitElementBase_instances, handlePetActivate_fn).call(this),
|
|
2526
2597
|
onClose: () => __privateMethod(this, _ChatKitElementBase_instances, handlePetClose_fn).call(this),
|
|
2598
|
+
onReopen: () => __privateMethod(this, _ChatKitElementBase_instances, requestLauncherVisibility_fn).call(this, true),
|
|
2527
2599
|
onReply: (text) => __privateMethod(this, _ChatKitElementBase_instances, handlePetReply_fn).call(this, text),
|
|
2528
2600
|
onThreadSummaryActivate: (threadId) => void __privateMethod(this, _ChatKitElementBase_instances, handlePetThreadSummaryActivate_fn).call(this, threadId)
|
|
2529
2601
|
}));
|
|
@@ -2716,6 +2788,7 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
2716
2788
|
}
|
|
2717
2789
|
connectedCallback() {
|
|
2718
2790
|
__privateGet(this, _petOverlay).connect();
|
|
2791
|
+
if (__privateGet(this, _opts)) __privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
2719
2792
|
const style = document.createElement("style");
|
|
2720
2793
|
style.textContent = `
|
|
2721
2794
|
:host {
|
|
@@ -2994,19 +3067,26 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
2994
3067
|
__privateGet(this, _petOverlay).destroy();
|
|
2995
3068
|
}
|
|
2996
3069
|
applySanitizedOptions(newOptions) {
|
|
2997
|
-
var _a2, _b2;
|
|
3070
|
+
var _a2, _b2, _c2, _d;
|
|
3071
|
+
const sessionChanged = ((_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.sessionKey) !== newOptions.sessionKey || ((_b2 = __privateGet(this, _opts)) == null ? void 0 : _b2.api.xpertId) !== newOptions.api.xpertId || __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) !== __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this, newOptions);
|
|
3072
|
+
const pet = newOptions.pet;
|
|
3073
|
+
const enabled = typeof pet === "boolean" ? pet : (pet == null ? void 0 : pet.enabled) ?? true;
|
|
3074
|
+
if (sessionChanged || enabled !== __privateGet(this, _hostLauncherEnabled)) {
|
|
3075
|
+
__privateSet(this, _launcherVisible, enabled);
|
|
3076
|
+
}
|
|
3077
|
+
__privateSet(this, _hostLauncherEnabled, enabled);
|
|
3078
|
+
if (sessionChanged) {
|
|
3079
|
+
__privateSet(this, _framePetOptionsOverride, void 0);
|
|
3080
|
+
__privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
|
|
3081
|
+
}
|
|
2998
3082
|
__privateSet(this, _opts, newOptions);
|
|
2999
|
-
if (!((
|
|
3083
|
+
if (!((_c2 = newOptions.header) == null ? void 0 : _c2.windowDrag)) (_d = __privateGet(this, _windowDrag)) == null ? void 0 : _d.clear();
|
|
3000
3084
|
__privateSet(this, _petClosedByContextMenu, false);
|
|
3001
3085
|
__privateGet(this, _petOverlay).setLocale(newOptions.locale);
|
|
3002
3086
|
__privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
3003
3087
|
if (__privateGet(this, _initialized)) {
|
|
3004
3088
|
__privateMethod(this, _ChatKitElementBase_instances, setOptionsDataAttributes_fn).call(this, __privateGet(this, _opts));
|
|
3005
|
-
|
|
3006
|
-
__privateGet(this, _messenger).commands.setOptions(
|
|
3007
|
-
getInnerOptions(__privateMethod(this, _ChatKitElementBase_instances, getFrameOptions_fn).call(this, newOptions))
|
|
3008
|
-
);
|
|
3009
|
-
});
|
|
3089
|
+
__privateMethod(this, _ChatKitElementBase_instances, updateFrameOptions_fn).call(this);
|
|
3010
3090
|
} else {
|
|
3011
3091
|
__privateMethod(this, _ChatKitElementBase_instances, maybeInit_fn).call(this);
|
|
3012
3092
|
}
|
|
@@ -3098,6 +3178,8 @@ _launcherOpen = new WeakMap();
|
|
|
3098
3178
|
_chatMinimizedToPet = new WeakMap();
|
|
3099
3179
|
_framePetOptionsOverride = new WeakMap();
|
|
3100
3180
|
_petClosedByContextMenu = new WeakMap();
|
|
3181
|
+
_hostLauncherEnabled = new WeakMap();
|
|
3182
|
+
_launcherVisible = new WeakMap();
|
|
3101
3183
|
_shadow = new WeakMap();
|
|
3102
3184
|
_petOverlay = new WeakMap();
|
|
3103
3185
|
_resolveLoaded = new WeakMap();
|
|
@@ -3120,14 +3202,9 @@ setOptionsDataAttributes_fn = function(options) {
|
|
|
3120
3202
|
getDisplayMode_fn = function(options = __privateGet(this, _opts)) {
|
|
3121
3203
|
return (options == null ? void 0 : options.displayMode) === "pet" ? "pet" : "chat";
|
|
3122
3204
|
};
|
|
3123
|
-
getConfiguredPetOptions_fn = function(
|
|
3124
|
-
if (!
|
|
3125
|
-
|
|
3126
|
-
}
|
|
3127
|
-
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this, options) === "pet" && !chatkitTypes.normalizePetOptions(options.pet ?? null)) {
|
|
3128
|
-
return typeof options.pet === "object" ? { ...options.pet, enabled: true } : true;
|
|
3129
|
-
}
|
|
3130
|
-
return options.pet ?? null;
|
|
3205
|
+
getConfiguredPetOptions_fn = function() {
|
|
3206
|
+
if (!__privateGet(this, _opts)) return null;
|
|
3207
|
+
return __privateMethod(this, _ChatKitElementBase_instances, effectivePet_fn).call(this, __privateGet(this, _opts)) ?? (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet" ? true : null);
|
|
3131
3208
|
};
|
|
3132
3209
|
mergeConfiguredPetPositionDefaults_fn = function(pet) {
|
|
3133
3210
|
if (!pet) {
|
|
@@ -3155,9 +3232,41 @@ mergeConfiguredPetPositionDefaults_fn = function(pet) {
|
|
|
3155
3232
|
}
|
|
3156
3233
|
};
|
|
3157
3234
|
};
|
|
3235
|
+
effectivePet_fn = function(options) {
|
|
3236
|
+
const pet = options.pet;
|
|
3237
|
+
if (options.displayMode !== "pet" || __privateGet(this, _launcherVisible) === __privateGet(this, _hostLauncherEnabled)) {
|
|
3238
|
+
return pet;
|
|
3239
|
+
}
|
|
3240
|
+
return typeof pet === "object" ? { ...pet, enabled: __privateGet(this, _launcherVisible) } : __privateGet(this, _launcherVisible);
|
|
3241
|
+
};
|
|
3242
|
+
innerOptions_fn = function(options) {
|
|
3243
|
+
return removeMethods({
|
|
3244
|
+
...options,
|
|
3245
|
+
pet: __privateMethod(this, _ChatKitElementBase_instances, effectivePet_fn).call(this, options)
|
|
3246
|
+
});
|
|
3247
|
+
};
|
|
3248
|
+
updateFrameOptions_fn = function() {
|
|
3249
|
+
__privateGet(this, _loaded).then(() => {
|
|
3250
|
+
if (__privateGet(this, _opts))
|
|
3251
|
+
__privateGet(this, _messenger).commands.setOptions(__privateMethod(this, _ChatKitElementBase_instances, innerOptions_fn).call(this, __privateGet(this, _opts)));
|
|
3252
|
+
});
|
|
3253
|
+
};
|
|
3254
|
+
isLauncherHidden_fn = function() {
|
|
3255
|
+
return __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet" && !__privateGet(this, _launcherVisible);
|
|
3256
|
+
};
|
|
3257
|
+
requestLauncherVisibility_fn = function(visible) {
|
|
3258
|
+
__privateSet(this, _launcherVisible, visible);
|
|
3259
|
+
__privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
3260
|
+
__privateMethod(this, _ChatKitElementBase_instances, updateFrameOptions_fn).call(this);
|
|
3261
|
+
this.dispatchEvent(
|
|
3262
|
+
new CustomEvent("chatkit.pet.launcher.visibility.change", {
|
|
3263
|
+
detail: { visible }
|
|
3264
|
+
})
|
|
3265
|
+
);
|
|
3266
|
+
};
|
|
3158
3267
|
getOverlayPetOptions_fn = function() {
|
|
3159
3268
|
var _a2;
|
|
3160
|
-
if (__privateGet(this, _petClosedByContextMenu) || ((_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.pet) === false && __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) !== "pet") {
|
|
3269
|
+
if (__privateMethod(this, _ChatKitElementBase_instances, isLauncherHidden_fn).call(this) || __privateGet(this, _petClosedByContextMenu) || ((_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.pet) === false && __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) !== "pet") {
|
|
3161
3270
|
return null;
|
|
3162
3271
|
}
|
|
3163
3272
|
let pet;
|
|
@@ -3167,7 +3276,7 @@ getOverlayPetOptions_fn = function() {
|
|
|
3167
3276
|
pet = __privateMethod(this, _ChatKitElementBase_instances, getConfiguredPetOptions_fn).call(this);
|
|
3168
3277
|
}
|
|
3169
3278
|
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet" && !chatkitTypes.normalizePetOptions(pet ?? null)) {
|
|
3170
|
-
pet =
|
|
3279
|
+
pet = __privateMethod(this, _ChatKitElementBase_instances, getConfiguredPetOptions_fn).call(this);
|
|
3171
3280
|
}
|
|
3172
3281
|
return __privateMethod(this, _ChatKitElementBase_instances, resolveOverlayPetOptions_fn).call(this, pet);
|
|
3173
3282
|
};
|
|
@@ -3202,19 +3311,6 @@ resolveOverlayPetOptions_fn = function(pet) {
|
|
|
3202
3311
|
imageRendering: normalized.imageRendering
|
|
3203
3312
|
};
|
|
3204
3313
|
};
|
|
3205
|
-
getFrameOptions_fn = function(options) {
|
|
3206
|
-
const pet = __privateMethod(this, _ChatKitElementBase_instances, getConfiguredPetOptions_fn).call(this, options);
|
|
3207
|
-
if (pet === (options.pet ?? null)) {
|
|
3208
|
-
return options;
|
|
3209
|
-
}
|
|
3210
|
-
const nextOptions = { ...options };
|
|
3211
|
-
if (pet === null) {
|
|
3212
|
-
delete nextOptions.pet;
|
|
3213
|
-
} else {
|
|
3214
|
-
nextOptions.pet = pet;
|
|
3215
|
-
}
|
|
3216
|
-
return nextOptions;
|
|
3217
|
-
};
|
|
3218
3314
|
setLauncherOpen_fn = function(open) {
|
|
3219
3315
|
__privateSet(this, _launcherOpen, open);
|
|
3220
3316
|
if (open) {
|
|
@@ -3233,9 +3329,14 @@ setChatMinimizedToPet_fn = function(minimized) {
|
|
|
3233
3329
|
}
|
|
3234
3330
|
};
|
|
3235
3331
|
syncPetOverlayOptions_fn = function() {
|
|
3236
|
-
var _a2;
|
|
3332
|
+
var _a2, _b2, _c2;
|
|
3333
|
+
if (__privateMethod(this, _ChatKitElementBase_instances, isLauncherHidden_fn).call(this)) __privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
|
|
3237
3334
|
const overlayPetOptions = __privateMethod(this, _ChatKitElementBase_instances, getOverlayPetOptions_fn).call(this);
|
|
3238
3335
|
__privateGet(this, _petOverlay).setOptions(overlayPetOptions, (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.theme);
|
|
3336
|
+
__privateGet(this, _petOverlay).setReopenVisible(
|
|
3337
|
+
__privateMethod(this, _ChatKitElementBase_instances, isLauncherHidden_fn).call(this),
|
|
3338
|
+
typeof ((_b2 = __privateGet(this, _opts)) == null ? void 0 : _b2.pet) === "object" ? (_c2 = __privateGet(this, _opts).pet.position) == null ? void 0 : _c2.zIndex : void 0
|
|
3339
|
+
);
|
|
3239
3340
|
if (!overlayPetOptions) {
|
|
3240
3341
|
__privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
|
|
3241
3342
|
}
|
|
@@ -3256,14 +3357,14 @@ handlePetActivate_fn = function() {
|
|
|
3256
3357
|
__privateGet(this, _loaded).then(() => this.focusComposer()).catch(() => void 0);
|
|
3257
3358
|
};
|
|
3258
3359
|
handlePetClose_fn = function() {
|
|
3259
|
-
__privateSet(this, _petClosedByContextMenu, true);
|
|
3260
|
-
__privateSet(this, _framePetOptionsOverride, null);
|
|
3261
|
-
__privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
|
|
3262
3360
|
__privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
|
|
3263
|
-
__privateGet(this, _petOverlay).setOptions(null);
|
|
3264
3361
|
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet") {
|
|
3362
|
+
__privateMethod(this, _ChatKitElementBase_instances, requestLauncherVisibility_fn).call(this, false);
|
|
3265
3363
|
return;
|
|
3266
3364
|
}
|
|
3365
|
+
__privateSet(this, _petClosedByContextMenu, true);
|
|
3366
|
+
__privateSet(this, _framePetOptionsOverride, null);
|
|
3367
|
+
__privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
3267
3368
|
__privateGet(this, _loaded).then(() => __privateGet(this, _messenger).commands.setPetEnabled({ enabled: false })).catch(() => void 0);
|
|
3268
3369
|
};
|
|
3269
3370
|
handlePetReply_fn = async function(text) {
|
|
@@ -3316,7 +3417,7 @@ maybeInit_fn = function() {
|
|
|
3316
3417
|
const frameURL = new URL(__privateMethod(this, _ChatKitElementBase_instances, getFrameUrl_fn).call(this), window.location.origin);
|
|
3317
3418
|
__privateGet(this, _messenger).setTargetOrigin(frameURL.origin);
|
|
3318
3419
|
frameURL.hash = encodeBase64({
|
|
3319
|
-
options:
|
|
3420
|
+
options: __privateMethod(this, _ChatKitElementBase_instances, innerOptions_fn).call(this, __privateGet(this, _opts)),
|
|
3320
3421
|
referrer: window.location.origin,
|
|
3321
3422
|
profile: this.profile,
|
|
3322
3423
|
...__privateGet(this, _channelId) ? { channelId: __privateGet(this, _channelId) } : {}
|
|
@@ -3365,6 +3466,7 @@ const EVENT_HANDLER_MAP = {
|
|
|
3365
3466
|
"chatkit.response.start": "onResponseStart",
|
|
3366
3467
|
"chatkit.log": "onLog",
|
|
3367
3468
|
"chatkit.thread.change": "onThreadChange",
|
|
3469
|
+
"chatkit.pet.launcher.visibility.change": "onPetLauncherVisibilityChange",
|
|
3368
3470
|
"chatkit.project.change": "onProjectChange",
|
|
3369
3471
|
"chatkit.connectors.change": "onConnectorsChange",
|
|
3370
3472
|
"chatkit.thread.load.start": "onThreadLoadStart",
|
|
@@ -3378,6 +3480,7 @@ const UI5_EVENT_NAME_MAP = {
|
|
|
3378
3480
|
"chatkit.response.start": "responseStart",
|
|
3379
3481
|
"chatkit.log": "log",
|
|
3380
3482
|
"chatkit.thread.change": "threadChange",
|
|
3483
|
+
"chatkit.pet.launcher.visibility.change": "petLauncherVisibilityChange",
|
|
3381
3484
|
"chatkit.project.change": "projectChange",
|
|
3382
3485
|
"chatkit.connectors.change": "connectorsChange",
|
|
3383
3486
|
"chatkit.thread.load.start": "threadLoadStart",
|
|
@@ -3444,6 +3547,7 @@ const ChatKit = ControlBase.extend("xpertai.chatkit.ui5.ChatKit", {
|
|
|
3444
3547
|
responseStart: { parameters: { detail: { type: "object" } } },
|
|
3445
3548
|
log: { parameters: { detail: { type: "object" } } },
|
|
3446
3549
|
threadChange: { parameters: { detail: { type: "object" } } },
|
|
3550
|
+
petLauncherVisibilityChange: { parameters: { detail: { type: "object" } } },
|
|
3447
3551
|
threadLoadStart: { parameters: { detail: { type: "object" } } },
|
|
3448
3552
|
threadLoadEnd: { parameters: { detail: { type: "object" } } },
|
|
3449
3553
|
ready: { parameters: { detail: { type: "object" } } },
|