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