@xpert-ai/chatkit-web-component 0.3.3 → 0.3.5
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/xpert-chatkit.js +167 -27
- package/dist/xpert-chatkit.js.map +1 -1
- package/dist/xpert-chatkit.umd.cjs +167 -27
- package/dist/xpert-chatkit.umd.cjs.map +1 -1
- package/package.json +3 -3
|
@@ -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, _setThreadId_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _c, _opts, _frameUrl, _frame, _wrapper, _launcherCloseButton, _launcherOpen, _framePetOptionsOverride, _petClosedByContextMenu, _shadow, _petOverlay, _resolveLoaded, _loaded, _messenger, _ChatKitElementBase_instances, emitAndThrow_fn, setOptionsDataAttributes_fn, getDisplayMode_fn, getConfiguredPetOptions_fn, mergeConfiguredPetPositionDefaults_fn, getOverlayPetOptions_fn, resolvePetAssetUrl_fn, resolveOverlayPetOptions_fn, getFrameOptions_fn, setLauncherOpen_fn, handlePetActivate_fn, handlePetClose_fn, handlePetReply_fn, handlePetThreadSummaryActivate_fn, _handleLauncherClose, getFrameUrl_fn, setFrameUrl_fn, consumeFrameUrl_fn, _handleFrameLoad, _initialized, maybeInit_fn, _init;
|
|
54
|
+
var _a, _b, _setTrainingOptOut_dec, _hideHistory_dec, _showHistory_dec, _sendCustomAction_dec, _shareThread_dec, _setThreadId_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _c, _opts, _frameUrl, _frame, _wrapper, _launcherCloseButton, _launcherOpen, _chatMinimizedToPet, _framePetOptionsOverride, _petClosedByContextMenu, _shadow, _petOverlay, _resolveLoaded, _loaded, _messenger, _ChatKitElementBase_instances, emitAndThrow_fn, setOptionsDataAttributes_fn, getDisplayMode_fn, getConfiguredPetOptions_fn, mergeConfiguredPetPositionDefaults_fn, getOverlayPetOptions_fn, resolvePetAssetUrl_fn, resolveOverlayPetOptions_fn, getFrameOptions_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());
|
|
@@ -1142,6 +1142,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1142
1142
|
const PET_SUMMARY_WIDTH = 320;
|
|
1143
1143
|
const PET_SUMMARY_MARGIN = 12;
|
|
1144
1144
|
const PET_CONTEXT_MENU_MARGIN = 8;
|
|
1145
|
+
const PET_SUMMARY_FONT_FAMILY = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif';
|
|
1145
1146
|
const PET_OVERLAY_COPY = {
|
|
1146
1147
|
"en-US": {
|
|
1147
1148
|
closePetMenuItem: "Close pet",
|
|
@@ -1233,6 +1234,65 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1233
1234
|
}
|
|
1234
1235
|
return "en-US";
|
|
1235
1236
|
}
|
|
1237
|
+
function getSummaryDensityMetrics(density) {
|
|
1238
|
+
switch (density) {
|
|
1239
|
+
case "compact":
|
|
1240
|
+
return {
|
|
1241
|
+
padding: "8px 10px",
|
|
1242
|
+
gap: 6,
|
|
1243
|
+
marginTop: 3,
|
|
1244
|
+
toggleSize: 30,
|
|
1245
|
+
actionSize: 22
|
|
1246
|
+
};
|
|
1247
|
+
case "spacious":
|
|
1248
|
+
return {
|
|
1249
|
+
padding: "14px 16px",
|
|
1250
|
+
gap: 10,
|
|
1251
|
+
marginTop: 6,
|
|
1252
|
+
toggleSize: 38,
|
|
1253
|
+
actionSize: 28
|
|
1254
|
+
};
|
|
1255
|
+
case "normal":
|
|
1256
|
+
default:
|
|
1257
|
+
return {
|
|
1258
|
+
padding: "12px 14px",
|
|
1259
|
+
gap: 8,
|
|
1260
|
+
marginTop: 4,
|
|
1261
|
+
toggleSize: 34,
|
|
1262
|
+
actionSize: 26
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
function getSummaryRadius(radius) {
|
|
1267
|
+
switch (radius) {
|
|
1268
|
+
case "pill":
|
|
1269
|
+
return 24;
|
|
1270
|
+
case "round":
|
|
1271
|
+
return 16;
|
|
1272
|
+
case "sharp":
|
|
1273
|
+
return 0;
|
|
1274
|
+
case "soft":
|
|
1275
|
+
default:
|
|
1276
|
+
return 12;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
function getSummaryThemeMetrics(theme) {
|
|
1280
|
+
var _a2, _b2;
|
|
1281
|
+
const themeObject = typeof theme === "string" ? null : theme;
|
|
1282
|
+
const baseSize = ((_a2 = themeObject == null ? void 0 : themeObject.typography) == null ? void 0 : _a2.baseSize) ?? 16;
|
|
1283
|
+
const density = (themeObject == null ? void 0 : themeObject.density) ?? "normal";
|
|
1284
|
+
const densityOffset = density === "compact" ? -1 : density === "spacious" ? 1 : 0;
|
|
1285
|
+
const bodySize = clampNumber(baseSize - 2 + densityOffset, 11, 17);
|
|
1286
|
+
const densityMetrics = getSummaryDensityMetrics(density);
|
|
1287
|
+
return {
|
|
1288
|
+
...densityMetrics,
|
|
1289
|
+
bodySize,
|
|
1290
|
+
titleSize: bodySize + 1,
|
|
1291
|
+
iconSize: clampNumber(bodySize + 2, 13, 19),
|
|
1292
|
+
radius: getSummaryRadius(themeObject == null ? void 0 : themeObject.radius),
|
|
1293
|
+
fontFamily: ((_b2 = themeObject == null ? void 0 : themeObject.typography) == null ? void 0 : _b2.fontFamily) ?? PET_SUMMARY_FONT_FAMILY
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1236
1296
|
function isPetState(value) {
|
|
1237
1297
|
return value === "idle" || value === "running-right" || value === "running-left" || value === "waving" || value === "jumping" || value === "failed" || value === "waiting" || value === "running" || value === "review";
|
|
1238
1298
|
}
|
|
@@ -1268,6 +1328,12 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1268
1328
|
summary.messageId || summary.updatedAt || summary.message
|
|
1269
1329
|
].join(":");
|
|
1270
1330
|
}
|
|
1331
|
+
function getThreadSummaryInteractionKey(summary) {
|
|
1332
|
+
if (!summary) {
|
|
1333
|
+
return null;
|
|
1334
|
+
}
|
|
1335
|
+
return [summary.threadId, summary.messageId ?? ""].join(":");
|
|
1336
|
+
}
|
|
1271
1337
|
function parseThreadSummaryPayload(value) {
|
|
1272
1338
|
if (value === null) {
|
|
1273
1339
|
return { summary: null };
|
|
@@ -1309,6 +1375,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1309
1375
|
this.summaryToggleElement = null;
|
|
1310
1376
|
this.mediaElement = null;
|
|
1311
1377
|
this.options = null;
|
|
1378
|
+
this.theme = null;
|
|
1312
1379
|
this.resolved = null;
|
|
1313
1380
|
this.summary = null;
|
|
1314
1381
|
this.summaryRenderKey = null;
|
|
@@ -1557,10 +1624,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1557
1624
|
this.installReducedMotionListener();
|
|
1558
1625
|
this.render();
|
|
1559
1626
|
}
|
|
1560
|
-
setOptions(pet) {
|
|
1627
|
+
setOptions(pet, theme) {
|
|
1561
1628
|
this.closeContextMenu();
|
|
1562
1629
|
const nextOptions = normalizePetOptions(pet);
|
|
1563
1630
|
this.options = nextOptions;
|
|
1631
|
+
this.theme = theme ?? null;
|
|
1564
1632
|
if (!nextOptions) {
|
|
1565
1633
|
this.isDragging = false;
|
|
1566
1634
|
this.isHovering = false;
|
|
@@ -1610,8 +1678,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1610
1678
|
this.render();
|
|
1611
1679
|
}
|
|
1612
1680
|
setThreadSummary(summary) {
|
|
1613
|
-
const previousKey =
|
|
1614
|
-
const nextKey =
|
|
1681
|
+
const previousKey = getThreadSummaryInteractionKey(this.summary);
|
|
1682
|
+
const nextKey = getThreadSummaryInteractionKey(summary);
|
|
1615
1683
|
this.summary = summary;
|
|
1616
1684
|
if (!summary) {
|
|
1617
1685
|
this.isSummaryCollapsed = false;
|
|
@@ -1906,10 +1974,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1906
1974
|
return;
|
|
1907
1975
|
}
|
|
1908
1976
|
const nextRenderKey = [
|
|
1909
|
-
summaryKey,
|
|
1910
|
-
summary.title,
|
|
1911
|
-
summary.message,
|
|
1912
|
-
summary.status,
|
|
1913
1977
|
this.copyLocale,
|
|
1914
1978
|
this.isSummaryExpanded ? "expanded" : "compact",
|
|
1915
1979
|
this.isSummaryHovering ? "hover" : "rest",
|
|
@@ -1934,6 +1998,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1934
1998
|
}, 0);
|
|
1935
1999
|
}
|
|
1936
2000
|
}
|
|
2001
|
+
this.updateSummaryBubbleContent(summary);
|
|
1937
2002
|
this.positionSummaryBubble(position, size);
|
|
1938
2003
|
}
|
|
1939
2004
|
renderCollapsedSummary(position, size) {
|
|
@@ -1954,7 +2019,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1954
2019
|
return;
|
|
1955
2020
|
}
|
|
1956
2021
|
const viewport = getViewportSize();
|
|
1957
|
-
const badgeSize =
|
|
2022
|
+
const badgeSize = getSummaryThemeMetrics(this.theme).toggleSize;
|
|
1958
2023
|
const x = clampNumber(
|
|
1959
2024
|
position.x + size.width - badgeSize * 0.35,
|
|
1960
2025
|
PET_SUMMARY_MARGIN,
|
|
@@ -2000,6 +2065,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2000
2065
|
}
|
|
2001
2066
|
createSummaryBubble(summary) {
|
|
2002
2067
|
const shouldShowReplyButton = this.isSummaryHovering && !this.isReplyOpen;
|
|
2068
|
+
const metrics = getSummaryThemeMetrics(this.theme);
|
|
2003
2069
|
const bubble = document.createElement("div");
|
|
2004
2070
|
bubble.setAttribute("data-chatkit-pet-summary", "");
|
|
2005
2071
|
bubble.addEventListener("pointerenter", this.handleSummaryPointerEnter);
|
|
@@ -2010,19 +2076,18 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2010
2076
|
bubble.style.left = "0";
|
|
2011
2077
|
bubble.style.boxSizing = "border-box";
|
|
2012
2078
|
bubble.style.pointerEvents = "auto";
|
|
2013
|
-
bubble.style.padding =
|
|
2014
|
-
bubble.style.paddingBottom = "12px";
|
|
2079
|
+
bubble.style.padding = metrics.padding;
|
|
2015
2080
|
bubble.style.border = "1px solid rgba(148, 163, 184, 0.22)";
|
|
2016
|
-
bubble.style.borderRadius =
|
|
2081
|
+
bubble.style.borderRadius = `${metrics.radius}px`;
|
|
2017
2082
|
bubble.style.background = "rgba(255, 255, 255, 0.94)";
|
|
2018
2083
|
bubble.style.color = "#1f2937";
|
|
2019
2084
|
bubble.style.boxShadow = "0 8px 24px rgba(15, 23, 42, 0.1)";
|
|
2020
|
-
bubble.style.font =
|
|
2085
|
+
bubble.style.font = `500 ${metrics.bodySize}px/1.35 ${metrics.fontFamily}`;
|
|
2021
2086
|
bubble.style.backdropFilter = "blur(10px)";
|
|
2022
2087
|
const header = document.createElement("div");
|
|
2023
2088
|
header.style.display = "flex";
|
|
2024
2089
|
header.style.alignItems = "center";
|
|
2025
|
-
header.style.gap =
|
|
2090
|
+
header.style.gap = `${metrics.gap}px`;
|
|
2026
2091
|
if (this.isSummaryHovering || this.isReplyOpen) {
|
|
2027
2092
|
header.append(
|
|
2028
2093
|
this.createSummaryActionButton(
|
|
@@ -2040,7 +2105,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2040
2105
|
title.style.textOverflow = "ellipsis";
|
|
2041
2106
|
title.style.whiteSpace = "nowrap";
|
|
2042
2107
|
title.style.fontWeight = "700";
|
|
2043
|
-
title.style.fontSize =
|
|
2108
|
+
title.style.fontSize = `${metrics.titleSize}px`;
|
|
2109
|
+
title.dataset.chatkitPetSummaryTitle = "";
|
|
2044
2110
|
header.append(title);
|
|
2045
2111
|
if (this.isSummaryHovering || this.isReplyOpen) {
|
|
2046
2112
|
header.append(
|
|
@@ -2055,7 +2121,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2055
2121
|
}
|
|
2056
2122
|
const message = document.createElement("div");
|
|
2057
2123
|
message.textContent = summary.message;
|
|
2058
|
-
message.style.marginTop =
|
|
2124
|
+
message.style.marginTop = `${metrics.marginTop}px`;
|
|
2059
2125
|
message.style.fontWeight = "400";
|
|
2060
2126
|
message.style.color = "#374151";
|
|
2061
2127
|
message.style.overflow = "hidden";
|
|
@@ -2067,6 +2133,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2067
2133
|
message.style.setProperty("-webkit-line-clamp", "2");
|
|
2068
2134
|
message.style.setProperty("-webkit-box-orient", "vertical");
|
|
2069
2135
|
}
|
|
2136
|
+
message.dataset.chatkitPetSummaryMessage = "";
|
|
2070
2137
|
bubble.append(header, message);
|
|
2071
2138
|
if (shouldShowReplyButton) {
|
|
2072
2139
|
const reply = this.createTextButton(
|
|
@@ -2083,7 +2150,30 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2083
2150
|
}
|
|
2084
2151
|
return bubble;
|
|
2085
2152
|
}
|
|
2153
|
+
updateSummaryBubbleContent(summary) {
|
|
2154
|
+
var _a2, _b2, _c2;
|
|
2155
|
+
const title = (_a2 = this.summaryElement) == null ? void 0 : _a2.querySelector(
|
|
2156
|
+
"[data-chatkit-pet-summary-title]"
|
|
2157
|
+
);
|
|
2158
|
+
if (title && title.textContent !== summary.title) {
|
|
2159
|
+
title.textContent = summary.title;
|
|
2160
|
+
}
|
|
2161
|
+
const message = (_b2 = this.summaryElement) == null ? void 0 : _b2.querySelector(
|
|
2162
|
+
"[data-chatkit-pet-summary-message]"
|
|
2163
|
+
);
|
|
2164
|
+
if (message && message.textContent !== summary.message) {
|
|
2165
|
+
message.textContent = summary.message;
|
|
2166
|
+
}
|
|
2167
|
+
const statusIcon = (_c2 = this.summaryElement) == null ? void 0 : _c2.querySelector(
|
|
2168
|
+
"[data-chatkit-pet-summary-status]"
|
|
2169
|
+
);
|
|
2170
|
+
if (statusIcon && statusIcon.dataset.chatkitPetSummaryStatus !== summary.status) {
|
|
2171
|
+
const nextIcon = this.createStatusIcon(summary.status);
|
|
2172
|
+
statusIcon.replaceWith(nextIcon);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2086
2175
|
createSummaryToggleButton(label) {
|
|
2176
|
+
const metrics = getSummaryThemeMetrics(this.theme);
|
|
2087
2177
|
const button = document.createElement("button");
|
|
2088
2178
|
button.type = "button";
|
|
2089
2179
|
button.textContent = label;
|
|
@@ -2099,18 +2189,21 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2099
2189
|
button.style.color = "#475569";
|
|
2100
2190
|
button.style.boxShadow = "0 6px 18px rgba(15, 23, 42, 0.1)";
|
|
2101
2191
|
button.style.cursor = "pointer";
|
|
2102
|
-
button.style.font =
|
|
2192
|
+
button.style.font = `600 ${metrics.titleSize}px/1 ${metrics.fontFamily}`;
|
|
2103
2193
|
button.style.display = "flex";
|
|
2104
2194
|
button.style.alignItems = "center";
|
|
2105
2195
|
button.style.justifyContent = "center";
|
|
2106
2196
|
return button;
|
|
2107
2197
|
}
|
|
2108
2198
|
createStatusIcon(status) {
|
|
2199
|
+
const metrics = getSummaryThemeMetrics(this.theme);
|
|
2200
|
+
const iconSize = metrics.iconSize;
|
|
2109
2201
|
const icon = document.createElement("span");
|
|
2110
2202
|
icon.setAttribute("aria-hidden", "true");
|
|
2203
|
+
icon.dataset.chatkitPetSummaryStatus = status;
|
|
2111
2204
|
icon.style.display = "inline-flex";
|
|
2112
|
-
icon.style.width =
|
|
2113
|
-
icon.style.height =
|
|
2205
|
+
icon.style.width = `${iconSize}px`;
|
|
2206
|
+
icon.style.height = `${iconSize}px`;
|
|
2114
2207
|
icon.style.alignItems = "center";
|
|
2115
2208
|
icon.style.justifyContent = "center";
|
|
2116
2209
|
icon.style.flex = "0 0 auto";
|
|
@@ -2122,7 +2215,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2122
2215
|
return icon;
|
|
2123
2216
|
}
|
|
2124
2217
|
icon.style.borderRadius = "999px";
|
|
2125
|
-
icon.style.fontSize =
|
|
2218
|
+
icon.style.fontSize = `${Math.max(10, iconSize - 4)}px`;
|
|
2126
2219
|
icon.style.fontWeight = "700";
|
|
2127
2220
|
if (status === "failed") {
|
|
2128
2221
|
icon.textContent = "!";
|
|
@@ -2134,8 +2227,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2134
2227
|
icon.style.border = "2px solid #22c55e";
|
|
2135
2228
|
icon.style.position = "relative";
|
|
2136
2229
|
const check = document.createElement("span");
|
|
2137
|
-
check.style.width =
|
|
2138
|
-
check.style.height =
|
|
2230
|
+
check.style.width = `${Math.round(iconSize * 0.44)}px`;
|
|
2231
|
+
check.style.height = `${Math.round(iconSize * 0.25)}px`;
|
|
2139
2232
|
check.style.borderLeft = "2px solid #22c55e";
|
|
2140
2233
|
check.style.borderBottom = "2px solid #22c55e";
|
|
2141
2234
|
check.style.transform = "rotate(-45deg) translate(1px, -1px)";
|
|
@@ -2143,6 +2236,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2143
2236
|
return icon;
|
|
2144
2237
|
}
|
|
2145
2238
|
createSummaryActionButton(label, title, onClick) {
|
|
2239
|
+
const metrics = getSummaryThemeMetrics(this.theme);
|
|
2146
2240
|
const button = document.createElement("button");
|
|
2147
2241
|
button.type = "button";
|
|
2148
2242
|
button.textContent = label;
|
|
@@ -2152,14 +2246,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2152
2246
|
event.stopPropagation();
|
|
2153
2247
|
onClick();
|
|
2154
2248
|
});
|
|
2155
|
-
button.style.width =
|
|
2156
|
-
button.style.height =
|
|
2249
|
+
button.style.width = `${metrics.actionSize}px`;
|
|
2250
|
+
button.style.height = `${metrics.actionSize}px`;
|
|
2157
2251
|
button.style.border = "0";
|
|
2158
2252
|
button.style.borderRadius = "999px";
|
|
2159
2253
|
button.style.background = "rgba(241, 245, 249, 0.96)";
|
|
2160
2254
|
button.style.color = "#475569";
|
|
2161
2255
|
button.style.cursor = "pointer";
|
|
2162
|
-
button.style.font =
|
|
2256
|
+
button.style.font = `600 ${metrics.titleSize}px/1 ${metrics.fontFamily}`;
|
|
2163
2257
|
return button;
|
|
2164
2258
|
}
|
|
2165
2259
|
createTextButton(label, onClick) {
|
|
@@ -2498,6 +2592,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2498
2592
|
__privateAdd(this, _wrapper);
|
|
2499
2593
|
__privateAdd(this, _launcherCloseButton);
|
|
2500
2594
|
__privateAdd(this, _launcherOpen, false);
|
|
2595
|
+
__privateAdd(this, _chatMinimizedToPet, false);
|
|
2501
2596
|
__privateAdd(this, _framePetOptionsOverride);
|
|
2502
2597
|
__privateAdd(this, _petClosedByContextMenu, false);
|
|
2503
2598
|
__privateAdd(this, _shadow, this.attachShadow({ mode: "open" }));
|
|
@@ -2634,6 +2729,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2634
2729
|
:host([data-display-mode="pet"]) {
|
|
2635
2730
|
display: contents;
|
|
2636
2731
|
}
|
|
2732
|
+
:host([data-chat-minimized-to-pet="true"]) {
|
|
2733
|
+
display: contents;
|
|
2734
|
+
}
|
|
2637
2735
|
.ck-iframe {
|
|
2638
2736
|
border: none;
|
|
2639
2737
|
position: absolute;
|
|
@@ -2744,6 +2842,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2744
2842
|
:host([data-loaded="true"]) .ck-wrapper {
|
|
2745
2843
|
opacity: 1;
|
|
2746
2844
|
}
|
|
2845
|
+
:host([data-chat-minimized-to-pet="true"]) .ck-wrapper {
|
|
2846
|
+
opacity: 0;
|
|
2847
|
+
pointer-events: none;
|
|
2848
|
+
visibility: hidden;
|
|
2849
|
+
}
|
|
2747
2850
|
:host([data-display-mode="pet"]:not([data-chat-open="true"])) .ck-wrapper {
|
|
2748
2851
|
opacity: 0;
|
|
2749
2852
|
}
|
|
@@ -2830,7 +2933,17 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2830
2933
|
__privateSet(this, _petClosedByContextMenu, false);
|
|
2831
2934
|
}
|
|
2832
2935
|
__privateSet(this, _framePetOptionsOverride, payload.pet);
|
|
2833
|
-
|
|
2936
|
+
__privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
2937
|
+
}
|
|
2938
|
+
});
|
|
2939
|
+
__privateGet(this, _messenger).on("chat_minimize_change", (data) => {
|
|
2940
|
+
const minimized = typeof data === "object" && data !== null && "minimized" in data && data.minimized === true;
|
|
2941
|
+
if (minimized && !__privateMethod(this, _ChatKitElementBase_instances, getOverlayPetOptions_fn).call(this)) {
|
|
2942
|
+
return;
|
|
2943
|
+
}
|
|
2944
|
+
__privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, minimized);
|
|
2945
|
+
if (minimized) {
|
|
2946
|
+
__privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
|
|
2834
2947
|
}
|
|
2835
2948
|
});
|
|
2836
2949
|
__privateGet(this, _messenger).on("unmount", () => {
|
|
@@ -2868,7 +2981,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2868
2981
|
__privateSet(this, _opts, newOptions);
|
|
2869
2982
|
__privateSet(this, _petClosedByContextMenu, false);
|
|
2870
2983
|
__privateGet(this, _petOverlay).setLocale(newOptions.locale);
|
|
2871
|
-
|
|
2984
|
+
__privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
2872
2985
|
if (__privateGet(this, _initialized)) {
|
|
2873
2986
|
__privateMethod(this, _ChatKitElementBase_instances, setOptionsDataAttributes_fn).call(this, __privateGet(this, _opts));
|
|
2874
2987
|
__privateGet(this, _loaded).then(() => {
|
|
@@ -2948,6 +3061,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2948
3061
|
_wrapper = new WeakMap();
|
|
2949
3062
|
_launcherCloseButton = new WeakMap();
|
|
2950
3063
|
_launcherOpen = new WeakMap();
|
|
3064
|
+
_chatMinimizedToPet = new WeakMap();
|
|
2951
3065
|
_framePetOptionsOverride = new WeakMap();
|
|
2952
3066
|
_petClosedByContextMenu = new WeakMap();
|
|
2953
3067
|
_shadow = new WeakMap();
|
|
@@ -3069,7 +3183,32 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3069
3183
|
delete this.dataset.chatOpen;
|
|
3070
3184
|
}
|
|
3071
3185
|
};
|
|
3186
|
+
setChatMinimizedToPet_fn = function(minimized) {
|
|
3187
|
+
const next = minimized && Boolean(__privateMethod(this, _ChatKitElementBase_instances, getOverlayPetOptions_fn).call(this));
|
|
3188
|
+
__privateSet(this, _chatMinimizedToPet, next);
|
|
3189
|
+
if (next) {
|
|
3190
|
+
this.dataset.chatMinimizedToPet = "true";
|
|
3191
|
+
} else {
|
|
3192
|
+
delete this.dataset.chatMinimizedToPet;
|
|
3193
|
+
}
|
|
3194
|
+
};
|
|
3195
|
+
syncPetOverlayOptions_fn = function() {
|
|
3196
|
+
var _a2;
|
|
3197
|
+
const overlayPetOptions = __privateMethod(this, _ChatKitElementBase_instances, getOverlayPetOptions_fn).call(this);
|
|
3198
|
+
__privateGet(this, _petOverlay).setOptions(overlayPetOptions, (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.theme);
|
|
3199
|
+
if (!overlayPetOptions) {
|
|
3200
|
+
__privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
|
|
3201
|
+
}
|
|
3202
|
+
};
|
|
3072
3203
|
handlePetActivate_fn = function() {
|
|
3204
|
+
if (__privateGet(this, _chatMinimizedToPet)) {
|
|
3205
|
+
__privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
|
|
3206
|
+
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet") {
|
|
3207
|
+
__privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, true);
|
|
3208
|
+
}
|
|
3209
|
+
__privateGet(this, _loaded).then(() => this.focusComposer()).catch(() => void 0);
|
|
3210
|
+
return;
|
|
3211
|
+
}
|
|
3073
3212
|
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) !== "pet") {
|
|
3074
3213
|
return;
|
|
3075
3214
|
}
|
|
@@ -3079,6 +3218,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3079
3218
|
handlePetClose_fn = function() {
|
|
3080
3219
|
__privateSet(this, _petClosedByContextMenu, true);
|
|
3081
3220
|
__privateSet(this, _framePetOptionsOverride, null);
|
|
3221
|
+
__privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
|
|
3082
3222
|
__privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
|
|
3083
3223
|
__privateGet(this, _petOverlay).setOptions(null);
|
|
3084
3224
|
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet") {
|