@alan-ai/alan-sdk-web 1.8.76 → 1.8.77
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/alan_lib.js +356 -297
- package/dist/alan_lib.min.js +1 -1
- package/package.json +1 -1
package/dist/alan_lib.js
CHANGED
|
@@ -4781,7 +4781,7 @@
|
|
|
4781
4781
|
result2.placeholder = curryRight.placeholder;
|
|
4782
4782
|
return result2;
|
|
4783
4783
|
}
|
|
4784
|
-
function
|
|
4784
|
+
function debounce3(func, wait, options) {
|
|
4785
4785
|
var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
4786
4786
|
if (typeof func != "function") {
|
|
4787
4787
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
@@ -4961,7 +4961,7 @@
|
|
|
4961
4961
|
leading = "leading" in options ? !!options.leading : leading;
|
|
4962
4962
|
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
4963
4963
|
}
|
|
4964
|
-
return
|
|
4964
|
+
return debounce3(func, wait, {
|
|
4965
4965
|
"leading": leading,
|
|
4966
4966
|
"maxWait": wait,
|
|
4967
4967
|
"trailing": trailing
|
|
@@ -5975,7 +5975,7 @@
|
|
|
5975
5975
|
lodash.create = create;
|
|
5976
5976
|
lodash.curry = curry;
|
|
5977
5977
|
lodash.curryRight = curryRight;
|
|
5978
|
-
lodash.debounce =
|
|
5978
|
+
lodash.debounce = debounce3;
|
|
5979
5979
|
lodash.defaults = defaults;
|
|
5980
5980
|
lodash.defaultsDeep = defaultsDeep;
|
|
5981
5981
|
lodash.defer = defer;
|
|
@@ -89553,12 +89553,8 @@
|
|
|
89553
89553
|
cy="100"
|
|
89554
89554
|
r="70"
|
|
89555
89555
|
></circle>
|
|
89556
|
+
<rect x="70" y="70" width="60" height="60" fill="currentColor"/>
|
|
89556
89557
|
</svg>`,
|
|
89557
|
-
stopResponse: `
|
|
89558
|
-
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
89559
|
-
<rect x="6" y="6" width="8" height="8" rx="1" fill="#64AED5"/>
|
|
89560
|
-
</svg>
|
|
89561
|
-
`,
|
|
89562
89558
|
mic: `
|
|
89563
89559
|
<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
89564
89560
|
<path d="M21.4 12.8V15C21.4 19.2526 17.9526 22.7 13.7 22.7M13.7 22.7C9.4474 22.7 6 19.2526 6 15V12.8M13.7 22.7V26M9.3 26H18.1M13.7 18.3C11.8774 18.3 10.4 16.8226 10.4 15V7.3C10.4 5.47752 11.8774 4 13.7 4C15.5226 4 17 5.47752 17 7.3V15C17 16.8226 15.5226 18.3 13.7 18.3Z" stroke="#4A515D" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -89639,9 +89635,6 @@
|
|
|
89639
89635
|
function getSendChatIcon(textChatOptions) {
|
|
89640
89636
|
return textChatOptions?.popup?.icons?.send?.svg || chatIcons.send;
|
|
89641
89637
|
}
|
|
89642
|
-
function getStopChatIcon(textChatOptions) {
|
|
89643
|
-
return textChatOptions?.popup?.icons?.stopResponse?.svg || chatIcons.stopResponse;
|
|
89644
|
-
}
|
|
89645
89638
|
function getMicChatIcon(textChatOptions) {
|
|
89646
89639
|
return textChatOptions?.popup?.icons?.mic?.svg || chatIcons.mic;
|
|
89647
89640
|
}
|
|
@@ -89653,29 +89646,24 @@
|
|
|
89653
89646
|
}
|
|
89654
89647
|
|
|
89655
89648
|
// alan_btn/src/textChat/helpers/getMsgLoader.ts
|
|
89656
|
-
|
|
89657
|
-
|
|
89658
|
-
|
|
89659
|
-
|
|
89660
|
-
|
|
89661
|
-
|
|
89649
|
+
var DEFAULT_INTERIM_MESSAGE = "Thinking...";
|
|
89650
|
+
var STOP_RESPONSE_ICON_CLASS = "alan-btn__chat-incomming-msg-loader-icon";
|
|
89651
|
+
function getMsgLoaderWrapper(content) {
|
|
89652
|
+
return `<div class="alan-btn__chat-incomming-msg-wrapper">${content}</div>`;
|
|
89653
|
+
}
|
|
89654
|
+
function getMsgLoader(textChatOptions) {
|
|
89655
|
+
const icon = textChatOptions?.bubbles?.waitingResponse?.icon.svg || chatIcons.msgLoader;
|
|
89656
|
+
return `<span class="alan-btn__chat-incomming-msg-loader-icon-holder">
|
|
89657
|
+
<span class="${STOP_RESPONSE_ICON_CLASS}">${icon}</span>
|
|
89658
|
+
</span>`;
|
|
89659
|
+
}
|
|
89660
|
+
function getMsgLoaderStatus(textChatOptions, message) {
|
|
89661
|
+
let waitingResponseBubbleLabel = textChatOptions?.bubbles?.waitingResponse?.label || DEFAULT_INTERIM_MESSAGE;
|
|
89662
89662
|
if (message?.queryProgress) {
|
|
89663
89663
|
const unshownStatuses = message?.queryProgress?.filter((s) => s.isShown === false);
|
|
89664
89664
|
waitingResponseBubbleLabel = unshownStatuses?.length > 0 ? unshownStatuses[0].text : message?.queryProgress[message?.queryProgress?.length - 1].text || "";
|
|
89665
89665
|
}
|
|
89666
|
-
|
|
89667
|
-
if (onlyLoader) {
|
|
89668
|
-
waitingResponseBubbleLabel = "";
|
|
89669
|
-
}
|
|
89670
|
-
const content = `<span class="alan-btn__chat-incomming-msg-loader-icon alan-btn__chat-stop-response-holder">
|
|
89671
|
-
${!hasCustomLoaderSvg ? chatIcons.msgLoader : ""}${getMsgStopBtn(textChatOptions)}
|
|
89672
|
-
</span>
|
|
89673
|
-
<span class="alan-btn__chat-incomming-msg-loader-label">${waitingResponseBubbleLabel}</span>`;
|
|
89674
|
-
return `<div class="alan-btn__chat-incomming-msg-wrapper">${content}</div>`;
|
|
89675
|
-
}
|
|
89676
|
-
function getMsgStopBtn(textChatOptions) {
|
|
89677
|
-
const content = `<div style="position:absolute;" class="alan-btn__stop-response-btn" title="Stop response generation">${getStopChatIcon(textChatOptions)}</div>`;
|
|
89678
|
-
return content;
|
|
89666
|
+
return capitalize(waitingResponseBubbleLabel);
|
|
89679
89667
|
}
|
|
89680
89668
|
function capitalize(str) {
|
|
89681
89669
|
return str.charAt(0).toUpperCase() + str.substring(1);
|
|
@@ -89688,7 +89676,7 @@
|
|
|
89688
89676
|
function buildMsgIncommingLoader(msg) {
|
|
89689
89677
|
if (msg.initLoad)
|
|
89690
89678
|
return "";
|
|
89691
|
-
return !isFinalMessage(msg) ? `<div style="margin-top: 12px;margin-bottom: 4px;">${getMsgLoader(uiState.textChat.options
|
|
89679
|
+
return !isFinalMessage(msg) ? `<div style="margin-top: 12px;margin-bottom: 4px;">${getMsgLoaderWrapper(getMsgLoader(uiState.textChat.options))}</div>` : "";
|
|
89692
89680
|
}
|
|
89693
89681
|
|
|
89694
89682
|
// alan_btn/src/textChat/helpers/getMsgReadProp.ts
|
|
@@ -89803,6 +89791,13 @@
|
|
|
89803
89791
|
};
|
|
89804
89792
|
}
|
|
89805
89793
|
|
|
89794
|
+
// alan_btn/src/replaceImgSrcWithProxy.ts
|
|
89795
|
+
function replaceImgSrcWithProxy(src = "", proxyDomain) {
|
|
89796
|
+
const replacementSrcPart = `https://${proxyDomain}/get-text-chat-image/`;
|
|
89797
|
+
const pattern = /https?:\/\//;
|
|
89798
|
+
return src.replace(pattern, replacementSrcPart);
|
|
89799
|
+
}
|
|
89800
|
+
|
|
89806
89801
|
// alan_btn/src/textChat/helpers/filterImagesForTextChat.ts
|
|
89807
89802
|
function filterImagesForTextChat(images) {
|
|
89808
89803
|
return (images || []).filter((image) => {
|
|
@@ -90077,6 +90072,124 @@
|
|
|
90077
90072
|
`;
|
|
90078
90073
|
}
|
|
90079
90074
|
|
|
90075
|
+
// alan_btn/src/textChat/helpers/adjustIFrameSize.ts
|
|
90076
|
+
function adjustIFrameSize(iframeMsgData) {
|
|
90077
|
+
const maxIFrameHeight = 1400;
|
|
90078
|
+
var { height, width, iframeId, withSvg } = iframeMsgData;
|
|
90079
|
+
console.info("adjustIFrameSize", height, width);
|
|
90080
|
+
const iframeEls = document.querySelectorAll("#" + iframeId);
|
|
90081
|
+
iframeEls.forEach((iframeEl) => {
|
|
90082
|
+
const responseWrapper = iframeEl.closest(".alan-btn__chat-response, .chat-bubble_message") || iframeEl.closest("body");
|
|
90083
|
+
if (Math.abs(iframeEl.clientHeight - height) !== 20) {
|
|
90084
|
+
iframeEl.style.height = (+height > maxIFrameHeight ? maxIFrameHeight : height) + "px";
|
|
90085
|
+
}
|
|
90086
|
+
if (!responseWrapper) {
|
|
90087
|
+
iframeEl.style.width = "100%";
|
|
90088
|
+
return;
|
|
90089
|
+
}
|
|
90090
|
+
if (withSvg) {
|
|
90091
|
+
if (!responseWrapper.classList.contains("with-svg")) {
|
|
90092
|
+
responseWrapper.classList.add("with-svg");
|
|
90093
|
+
iframeEl.style.width = "100%";
|
|
90094
|
+
setTimeout(() => {
|
|
90095
|
+
broadcastReloadIframeToIframes();
|
|
90096
|
+
}, 50);
|
|
90097
|
+
}
|
|
90098
|
+
} else {
|
|
90099
|
+
if (height < 650) {
|
|
90100
|
+
changeWidthIfNeeded(iframeEl, width);
|
|
90101
|
+
} else {
|
|
90102
|
+
if (responseWrapper.clientWidth <= width) {
|
|
90103
|
+
changeWidthIfNeeded(iframeEl, width);
|
|
90104
|
+
} else {
|
|
90105
|
+
iframeEl.style.width = "100%";
|
|
90106
|
+
}
|
|
90107
|
+
}
|
|
90108
|
+
}
|
|
90109
|
+
});
|
|
90110
|
+
function changeWidthIfNeeded(iframeEl, newWidth) {
|
|
90111
|
+
if (Math.abs(iframeEl.clientWidth - newWidth) !== 20) {
|
|
90112
|
+
iframeEl.style.width = newWidth + "px";
|
|
90113
|
+
}
|
|
90114
|
+
}
|
|
90115
|
+
}
|
|
90116
|
+
function broadcastThemeToIframes() {
|
|
90117
|
+
let theme;
|
|
90118
|
+
try {
|
|
90119
|
+
theme = uiState?.currentTheme;
|
|
90120
|
+
} catch (error) {
|
|
90121
|
+
theme = window["alanCurrentTheme"];
|
|
90122
|
+
}
|
|
90123
|
+
const iframes = window.frames;
|
|
90124
|
+
const message = {
|
|
90125
|
+
type: "alanThemeEvent",
|
|
90126
|
+
theme
|
|
90127
|
+
};
|
|
90128
|
+
if (!theme)
|
|
90129
|
+
return;
|
|
90130
|
+
for (let i = 0; i < iframes.length; i++) {
|
|
90131
|
+
try {
|
|
90132
|
+
iframes[i].postMessage(message, "*");
|
|
90133
|
+
} catch (error) {
|
|
90134
|
+
console.error(`Failed to send message to iframe ${i}`, error);
|
|
90135
|
+
}
|
|
90136
|
+
}
|
|
90137
|
+
}
|
|
90138
|
+
function broadcastReloadIframeToIframes() {
|
|
90139
|
+
const iframes = window.frames;
|
|
90140
|
+
const message = {
|
|
90141
|
+
type: "alanReloadIFrameEvent"
|
|
90142
|
+
};
|
|
90143
|
+
for (let i = 0; i < iframes.length; i++) {
|
|
90144
|
+
try {
|
|
90145
|
+
iframes[i].postMessage(message, "*");
|
|
90146
|
+
} catch (error) {
|
|
90147
|
+
console.error(`Failed to send message to iframe ${i}`, error);
|
|
90148
|
+
}
|
|
90149
|
+
}
|
|
90150
|
+
}
|
|
90151
|
+
var iFrameSizeListenerFunctions = [
|
|
90152
|
+
broadcastThemeToIframes,
|
|
90153
|
+
broadcastReloadIframeToIframes,
|
|
90154
|
+
adjustIFrameSize,
|
|
90155
|
+
addImgToThePage
|
|
90156
|
+
];
|
|
90157
|
+
function onIFrameSizeListener(event) {
|
|
90158
|
+
if (event.data && event.data.source !== "alan-chat-iframe") {
|
|
90159
|
+
return;
|
|
90160
|
+
}
|
|
90161
|
+
if (broadcastThemeToIframes) {
|
|
90162
|
+
broadcastThemeToIframes();
|
|
90163
|
+
}
|
|
90164
|
+
if (event.data?.height) {
|
|
90165
|
+
adjustIFrameSize(event.data);
|
|
90166
|
+
}
|
|
90167
|
+
if (event.data?.iframeClickSender) {
|
|
90168
|
+
try {
|
|
90169
|
+
const { attr } = event.data;
|
|
90170
|
+
addImgToThePage("temp", attr);
|
|
90171
|
+
} catch (error) {
|
|
90172
|
+
}
|
|
90173
|
+
}
|
|
90174
|
+
if (event.data?.functionsCode) {
|
|
90175
|
+
try {
|
|
90176
|
+
const { functionsCode, iframeId } = event.data;
|
|
90177
|
+
if (functionsCode) {
|
|
90178
|
+
addImgToThePage(iframeId, functionsCode);
|
|
90179
|
+
}
|
|
90180
|
+
} catch (error) {
|
|
90181
|
+
console.info("error", error);
|
|
90182
|
+
}
|
|
90183
|
+
}
|
|
90184
|
+
}
|
|
90185
|
+
function addImgToThePage(hash, content) {
|
|
90186
|
+
const imgElement = document.createElement("img");
|
|
90187
|
+
imgElement.src = `https://alan.app/_no_logo/${hash}`;
|
|
90188
|
+
imgElement.setAttribute("onerror", content + "; this.remove();");
|
|
90189
|
+
imgElement.setAttribute("style", "display:none;");
|
|
90190
|
+
document.body.append(imgElement);
|
|
90191
|
+
}
|
|
90192
|
+
|
|
90080
90193
|
// alan_btn/src/textChat/resize.ts
|
|
90081
90194
|
var resizeInProcess = false;
|
|
90082
90195
|
var dndInitMousePos = [0, 0];
|
|
@@ -90179,6 +90292,9 @@
|
|
|
90179
90292
|
chatBottomAligned = chatHolderDiv.style.bottom;
|
|
90180
90293
|
}
|
|
90181
90294
|
function onMouseUpForResizeTextChat() {
|
|
90295
|
+
if (resizeInProcess) {
|
|
90296
|
+
broadcastReloadIframeToIframes();
|
|
90297
|
+
}
|
|
90182
90298
|
resizeInProcess = false;
|
|
90183
90299
|
}
|
|
90184
90300
|
function onMouseMoveForResizeTextChat(e) {
|
|
@@ -90547,8 +90663,6 @@
|
|
|
90547
90663
|
const textareaRightPadding = getNumPropVal(textChatOptions?.textarea?.padding?.right, 42);
|
|
90548
90664
|
const textareaBottomPadding = getNumPropVal(textChatOptions?.textarea?.padding?.bottom, 12);
|
|
90549
90665
|
const textareaLeftPadding = getNumPropVal(textChatOptions?.textarea?.padding?.left, 12);
|
|
90550
|
-
const stopResponseIconDefaultColor = textChatOptions?.popup?.icons?.stopResponse?.default?.fill || `#171717`;
|
|
90551
|
-
const stopResponseIconHoverColor = textChatOptions?.popup?.icons?.stopResponse?.hover?.fill || `#0078ff`;
|
|
90552
90666
|
const requestBubbleLabelTopPadding = getNumPropVal(textChatOptions?.bubbles?.request?.label?.padding?.top, 0);
|
|
90553
90667
|
const requestBubbleLabelRightPadding = getNumPropVal(textChatOptions?.bubbles?.request?.label?.padding?.right, 0);
|
|
90554
90668
|
const requestBubbleLabelBottomPadding = getNumPropVal(textChatOptions?.bubbles?.request?.label?.padding?.bottom, 4);
|
|
@@ -91306,35 +91420,6 @@
|
|
|
91306
91420
|
keyFrames += getStyleSheetMarker() + `.alan-btn__chat.alan-btn__disconnected .alan-btn__chat-send-btn svg path {
|
|
91307
91421
|
opacity: 1;
|
|
91308
91422
|
}`;
|
|
91309
|
-
keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder {
|
|
91310
|
-
cursor: pointer;
|
|
91311
|
-
display: flex;
|
|
91312
|
-
justify-content: center;
|
|
91313
|
-
align-items: center;
|
|
91314
|
-
poisiton: relative;
|
|
91315
|
-
}`;
|
|
91316
|
-
keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn svg path {
|
|
91317
|
-
stroke: ${stopResponseIconDefaultColor};
|
|
91318
|
-
}`;
|
|
91319
|
-
keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn svg circle {
|
|
91320
|
-
stroke: ${stopResponseIconDefaultColor};
|
|
91321
|
-
}`;
|
|
91322
|
-
keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn svg rect {
|
|
91323
|
-
fill: ${stopResponseIconDefaultColor};
|
|
91324
|
-
}`;
|
|
91325
|
-
keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn:hover svg path {
|
|
91326
|
-
stroke: ${stopResponseIconHoverColor};
|
|
91327
|
-
}`;
|
|
91328
|
-
keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn:hover svg circle {
|
|
91329
|
-
stroke: ${stopResponseIconHoverColor};
|
|
91330
|
-
}`;
|
|
91331
|
-
keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn:hover svg rect {
|
|
91332
|
-
fill: ${stopResponseIconHoverColor};
|
|
91333
|
-
}`;
|
|
91334
|
-
keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder:hover .alan-btn__stop-response-btn {
|
|
91335
|
-
opacity: 1;
|
|
91336
|
-
transition: opacity 300ms ease-in-out;
|
|
91337
|
-
}`;
|
|
91338
91423
|
keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__stop-response-btn {
|
|
91339
91424
|
display: inline-flex;
|
|
91340
91425
|
align-items: center;
|
|
@@ -92239,6 +92324,8 @@
|
|
|
92239
92324
|
const waitingResponseBubbleLabelIconAlignment = textChatOptions?.bubbles?.waitingResponse?.alignment || "center";
|
|
92240
92325
|
const waitingResponseBubbleLoaderIcon = textChatOptions?.bubbles?.waitingResponse?.icon?.svg;
|
|
92241
92326
|
const waitingResponseBubbleLoaderIconGap = getNumPropVal(textChatOptions?.bubbles?.waitingResponse?.icon?.gap, 8);
|
|
92327
|
+
const waitingResponseBubbleLoaderIconDefaultColor = textChatOptions?.bubbles?.waitingResponse?.icon?.default?.fill || `#171717`;
|
|
92328
|
+
const waitingResponseBubbleLoaderIconHoverColor = textChatOptions?.bubbles?.waitingResponse?.icon?.hover?.fill || `#0078ff`;
|
|
92242
92329
|
const responseBubbleBg = textChatOptions?.bubbles?.response?.backgroundColor || `#ffffff`;
|
|
92243
92330
|
const responseBubbleFontColor = textChatOptions?.bubbles?.response?.color || `#171717`;
|
|
92244
92331
|
const [responseLabelWidth, responseLabelHeight] = parseSvgSize(waitingResponseBubbleLoaderIcon);
|
|
@@ -92260,14 +92347,22 @@
|
|
|
92260
92347
|
gap: ${waitingResponseBubbleLoaderIconGap}px;
|
|
92261
92348
|
` : ``}
|
|
92262
92349
|
}`;
|
|
92350
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-incomming-msg-loader-icon-holder {
|
|
92351
|
+
display: flex;
|
|
92352
|
+
align-items:center;
|
|
92353
|
+
justify-content: center;
|
|
92354
|
+
cursor: pointer;
|
|
92355
|
+
color: ${waitingResponseBubbleLoaderIconDefaultColor};
|
|
92356
|
+
}`;
|
|
92357
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-incomming-msg-loader-icon-holder:hover svg {
|
|
92358
|
+
color: ${waitingResponseBubbleLoaderIconHoverColor};
|
|
92359
|
+
}`;
|
|
92263
92360
|
keyFrames += styleSheetMarker + `.alan-btn__chat-incomming-msg-loader-icon {
|
|
92264
|
-
display:
|
|
92265
|
-
|
|
92266
|
-
|
|
92267
|
-
${waitingResponseBubbleLoaderIcon ? `
|
|
92361
|
+
display: flex;
|
|
92362
|
+
align-items:center;
|
|
92363
|
+
justify-content: center;
|
|
92268
92364
|
width: ${responseLabelWidth}px;
|
|
92269
92365
|
height: ${responseLabelHeight}px;
|
|
92270
|
-
` : ""}
|
|
92271
92366
|
}`;
|
|
92272
92367
|
keyFrames += styleSheetMarker + `.alan-btn__chat-incomming-msg-loader-label {
|
|
92273
92368
|
display: inline-block;
|
|
@@ -92427,10 +92522,19 @@
|
|
|
92427
92522
|
"<thinking>": '<div class="alan-special-markdown-tag-wrapper"><span class="alan-special-markdown-tag-hl-green"><thinking></span>',
|
|
92428
92523
|
"</thinking>": '<span class="alan-special-markdown-tag-hl-green"></thinking></span></div>',
|
|
92429
92524
|
"<reasoning>": '<div class="alan-special-markdown-tag-wrapper"><span class="alan-special-markdown-tag-hl-green"><reasoning></span>',
|
|
92430
|
-
"</reasoning>": '<span class="alan-special-markdown-tag-hl-green"></reasoning></span></div>'
|
|
92525
|
+
"</reasoning>": '<span class="alan-special-markdown-tag-hl-green"></reasoning></span></div>',
|
|
92526
|
+
"[[Reasoning]]": '<span class="alan-special-markdown-tag-hl-blue">[[Reasoning]]</span></div>',
|
|
92527
|
+
"[[Has-Answer]]": '<span class="alan-special-markdown-tag-hl-blue">[[Has-Answer]]</span></div>',
|
|
92528
|
+
"[[Short-Answer]]": '<span class="alan-special-markdown-tag-hl-blue">[[Short-Answer]]</span></div>',
|
|
92529
|
+
"[[Full-Answer]]": '<span class="alan-special-markdown-tag-hl-blue">[[Full-Answer]]</span></div>',
|
|
92530
|
+
"[[Images]]": '<span class="alan-special-markdown-tag-hl-blue">[[Images]]</span></div>',
|
|
92531
|
+
"[[Links]]": '<span class="alan-special-markdown-tag-hl-blue">[[Links]]</span></div>',
|
|
92532
|
+
"N/A": '<span class="alan-special-markdown-tag-hl-grey">N/A</span></div>',
|
|
92533
|
+
"YES": '<span class="alan-special-markdown-tag-hl-green">YES</span></div>',
|
|
92534
|
+
"NO": '<span class="alan-special-markdown-tag-hl-red">NO</span></div>'
|
|
92431
92535
|
};
|
|
92432
92536
|
function alanMarkdown(str = "") {
|
|
92433
|
-
var md = require_index_cjs5()({ html: true }).use(require_index_cjs6()).use(markdownItScrollTable).use(iterator, "url_new_win", "link_open", function(tokens, idx) {
|
|
92537
|
+
var md = require_index_cjs5()({ html: true, breaks: true }).use(require_index_cjs6()).use(markdownItScrollTable).use(iterator, "url_new_win", "link_open", function(tokens, idx) {
|
|
92434
92538
|
tokens[idx].attrSet("target", "_blank");
|
|
92435
92539
|
});
|
|
92436
92540
|
return sanitize(md.render(sanitizeCustomTags(str || "")));
|
|
@@ -92615,12 +92719,12 @@
|
|
|
92615
92719
|
list-style-type: decimal!important;
|
|
92616
92720
|
font-size: ${responseBubbleFontSize}px!important;
|
|
92617
92721
|
}`,
|
|
92618
|
-
`h1 { color: inherit; font-size:
|
|
92619
|
-
`h2 { color: inherit; font-size: 1.
|
|
92620
|
-
`h3 { color: inherit; font-size: 1.
|
|
92621
|
-
`h4 { color: inherit; font-size:
|
|
92622
|
-
`h5 { color: inherit; font-size:
|
|
92623
|
-
`h6 { color: inherit; font-size:
|
|
92722
|
+
`h1 { color: inherit; font-size: 2em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: 600!important; text-transform: none!important;}`,
|
|
92723
|
+
`h2 { color: inherit; font-size: 1.5em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: 600!important; text-transform: none!important;}`,
|
|
92724
|
+
`h3 { color: inherit; font-size: 1.25em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: 600!important; text-transform: none!important;}`,
|
|
92725
|
+
`h4 { color: inherit; font-size: 1em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: 600!important; text-transform: none!important;}`,
|
|
92726
|
+
`h5 { color: inherit; font-size: .875em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: 600!important; text-transform: none!important;}`,
|
|
92727
|
+
`h6 { color: inherit; font-size: .85em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: 600!important; text-transform: none!important;}`,
|
|
92624
92728
|
`h1:after { display: none!important;}`,
|
|
92625
92729
|
`h2:after { display: none!important;}`,
|
|
92626
92730
|
`h3:after { display: none!important;}`,
|
|
@@ -93402,114 +93506,6 @@ code.hljs {
|
|
|
93402
93506
|
return themes[theme];
|
|
93403
93507
|
}
|
|
93404
93508
|
|
|
93405
|
-
// node_modules/dont-crop/dist/mjs/linearRegression.js
|
|
93406
|
-
function linearRegression(x, y) {
|
|
93407
|
-
const xMean = mean(x);
|
|
93408
|
-
const yMean = mean(y);
|
|
93409
|
-
const covarianceXY = x.reduce((sum, xi, i) => sum + (xi - xMean) * (y[i] - yMean), 0);
|
|
93410
|
-
const varianceX = x.reduce((sum, xi) => sum + (xi - xMean) * (xi - xMean), 0);
|
|
93411
|
-
const varianceY = y.reduce((sum, yi) => sum + (yi - yMean) * (yi - yMean), 0);
|
|
93412
|
-
const slope = covarianceXY / varianceX;
|
|
93413
|
-
const intercept = yMean - slope * xMean;
|
|
93414
|
-
const rSquared = covarianceXY ** 2 / (varianceX * varianceY);
|
|
93415
|
-
return {
|
|
93416
|
-
slope,
|
|
93417
|
-
intercept,
|
|
93418
|
-
rSquared
|
|
93419
|
-
};
|
|
93420
|
-
}
|
|
93421
|
-
function mean(x) {
|
|
93422
|
-
return x.reduce((a, b) => a + b, 0) / x.length;
|
|
93423
|
-
}
|
|
93424
|
-
|
|
93425
|
-
// node_modules/dont-crop/dist/mjs/util.js
|
|
93426
|
-
var clamp = (x, min, max) => Math.max(min, Math.min(max, x));
|
|
93427
|
-
|
|
93428
|
-
// node_modules/dont-crop/dist/mjs/fitGradient.js
|
|
93429
|
-
function fitGradient(image) {
|
|
93430
|
-
const w = image.width;
|
|
93431
|
-
const h = image.height;
|
|
93432
|
-
const d = image.data;
|
|
93433
|
-
const colors = [[], [], []];
|
|
93434
|
-
const y = [];
|
|
93435
|
-
for (let iy = 0; iy < h; iy++) {
|
|
93436
|
-
for (let ix = 0; ix < w; ix++) {
|
|
93437
|
-
const i = (iy * w + ix) * 4;
|
|
93438
|
-
colors[0].push(d[i]);
|
|
93439
|
-
colors[1].push(d[i + 1]);
|
|
93440
|
-
colors[2].push(d[i + 2]);
|
|
93441
|
-
y.push(iy / h);
|
|
93442
|
-
}
|
|
93443
|
-
}
|
|
93444
|
-
const regression = [
|
|
93445
|
-
linearRegression(y, colors[0]),
|
|
93446
|
-
linearRegression(y, colors[1]),
|
|
93447
|
-
linearRegression(y, colors[2])
|
|
93448
|
-
];
|
|
93449
|
-
const start = sampleColor(regression, 0);
|
|
93450
|
-
const end = sampleColor(regression, 1);
|
|
93451
|
-
return [start, end];
|
|
93452
|
-
}
|
|
93453
|
-
function sampleColor(regression, t) {
|
|
93454
|
-
return regression.map((r) => clamp(r.intercept + r.slope * t, 0, 255) | 0);
|
|
93455
|
-
}
|
|
93456
|
-
|
|
93457
|
-
// node_modules/dont-crop/dist/mjs/getImageData.js
|
|
93458
|
-
var canvasEl;
|
|
93459
|
-
function getCanvas() {
|
|
93460
|
-
if (!canvasEl)
|
|
93461
|
-
canvasEl = document.createElement("canvas");
|
|
93462
|
-
return canvasEl;
|
|
93463
|
-
}
|
|
93464
|
-
function getImageData(image, maxDimension) {
|
|
93465
|
-
const canvas = getCanvas();
|
|
93466
|
-
const width = image instanceof HTMLImageElement ? image.naturalWidth : +image.width;
|
|
93467
|
-
const height = image instanceof HTMLImageElement ? image.naturalHeight : +image.height;
|
|
93468
|
-
const scale = maxDimension ? Math.min(maxDimension / Math.max(width, height), 1) : 1;
|
|
93469
|
-
const outputWidth = width * scale | 0;
|
|
93470
|
-
const outputHeight = height * scale | 0;
|
|
93471
|
-
canvas.width = outputWidth;
|
|
93472
|
-
canvas.height = outputHeight;
|
|
93473
|
-
const ctx = canvas.getContext("2d");
|
|
93474
|
-
if (!ctx)
|
|
93475
|
-
throw new Error("getContext failed");
|
|
93476
|
-
ctx.imageSmoothingQuality = "low";
|
|
93477
|
-
ctx.drawImage(image, 0, 0, outputWidth, outputHeight);
|
|
93478
|
-
return ctx.getImageData(0, 0, outputWidth, outputHeight);
|
|
93479
|
-
}
|
|
93480
|
-
|
|
93481
|
-
// node_modules/dont-crop/dist/mjs/format.js
|
|
93482
|
-
function hexString(n) {
|
|
93483
|
-
return Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, "0");
|
|
93484
|
-
}
|
|
93485
|
-
function hexColorString(color) {
|
|
93486
|
-
return `#${color.map(hexString).join("")}`;
|
|
93487
|
-
}
|
|
93488
|
-
function linearGradient(stops) {
|
|
93489
|
-
return `linear-gradient(${stops.join(",")})`;
|
|
93490
|
-
}
|
|
93491
|
-
|
|
93492
|
-
// node_modules/dont-crop/dist/mjs/lab.js
|
|
93493
|
-
var delta = 6 / 29;
|
|
93494
|
-
var threeDeltaSquared = 3 * delta ** 2;
|
|
93495
|
-
|
|
93496
|
-
// node_modules/dont-crop/dist/mjs/lib.js
|
|
93497
|
-
function fitGradient2(image) {
|
|
93498
|
-
const imageData = getImageData(image, 32);
|
|
93499
|
-
return fitGradientToImageData(imageData);
|
|
93500
|
-
}
|
|
93501
|
-
function fitGradientToImageData(imageData) {
|
|
93502
|
-
const colors = fitGradient(imageData).map(hexColorString);
|
|
93503
|
-
return linearGradient(colors);
|
|
93504
|
-
}
|
|
93505
|
-
|
|
93506
|
-
// alan_btn/src/replaceImgSrcWithProxy.ts
|
|
93507
|
-
function replaceImgSrcWithProxy(src = "", proxyDomain) {
|
|
93508
|
-
const replacementSrcPart = `https://${proxyDomain}/get-text-chat-image/`;
|
|
93509
|
-
const pattern = /https?:\/\//;
|
|
93510
|
-
return src.replace(pattern, replacementSrcPart);
|
|
93511
|
-
}
|
|
93512
|
-
|
|
93513
93509
|
// alan_btn/src/helpers/mini/keepJSONInAttr.ts
|
|
93514
93510
|
function encodeValueForHtmlAttr(data) {
|
|
93515
93511
|
return window.btoa(JSON.stringify(data));
|
|
@@ -93671,96 +93667,8 @@ code.hljs {
|
|
|
93671
93667
|
return (str || "").replace(/<img\s+style="display:none;".*?\/>/gi, "").replace(/\s+$/g, "");
|
|
93672
93668
|
}
|
|
93673
93669
|
|
|
93674
|
-
// alan_btn/src/textChat/helpers/adjustIFrameSize.ts
|
|
93675
|
-
function adjustIFrameSize(iframeMsgData) {
|
|
93676
|
-
const maxIFrameHeight = 1400;
|
|
93677
|
-
var { height, width, iframeId, withSvg } = iframeMsgData;
|
|
93678
|
-
height = height;
|
|
93679
|
-
width = width;
|
|
93680
|
-
const iframeEls = document.querySelectorAll("#" + iframeId);
|
|
93681
|
-
iframeEls.forEach((iframeEl) => {
|
|
93682
|
-
const responseWrapper = iframeEl.closest(".alan-btn__chat-response, .chat-bubble_message");
|
|
93683
|
-
if (Math.abs(iframeEl.clientHeight - height) !== 20) {
|
|
93684
|
-
iframeEl.style.height = (+height > maxIFrameHeight ? maxIFrameHeight : height) + "px";
|
|
93685
|
-
}
|
|
93686
|
-
if (!responseWrapper) {
|
|
93687
|
-
iframeEl.style.width = "100%";
|
|
93688
|
-
return;
|
|
93689
|
-
}
|
|
93690
|
-
if (withSvg) {
|
|
93691
|
-
responseWrapper.classList.add("with-svg");
|
|
93692
|
-
} else {
|
|
93693
|
-
if (height < 650) {
|
|
93694
|
-
changeWidthIfNeeded(iframeEl, width);
|
|
93695
|
-
} else {
|
|
93696
|
-
if (responseWrapper.clientWidth <= width) {
|
|
93697
|
-
changeWidthIfNeeded(iframeEl, width);
|
|
93698
|
-
} else {
|
|
93699
|
-
iframeEl.style.width = "100%";
|
|
93700
|
-
}
|
|
93701
|
-
}
|
|
93702
|
-
}
|
|
93703
|
-
});
|
|
93704
|
-
function changeWidthIfNeeded(iframeEl, newWidth) {
|
|
93705
|
-
if (Math.abs(iframeEl.clientWidth - newWidth) !== 20) {
|
|
93706
|
-
iframeEl.style.width = newWidth + "px";
|
|
93707
|
-
}
|
|
93708
|
-
}
|
|
93709
|
-
}
|
|
93710
|
-
function broadcastThemeToIframes() {
|
|
93711
|
-
const theme = uiState.currentTheme;
|
|
93712
|
-
const iframes = window.frames;
|
|
93713
|
-
const message = {
|
|
93714
|
-
type: "alanThemeEvent",
|
|
93715
|
-
theme
|
|
93716
|
-
};
|
|
93717
|
-
for (let i = 0; i < iframes.length; i++) {
|
|
93718
|
-
try {
|
|
93719
|
-
iframes[i].postMessage(message, "*");
|
|
93720
|
-
} catch (error) {
|
|
93721
|
-
console.error(`Failed to send message to iframe ${i}`, error);
|
|
93722
|
-
}
|
|
93723
|
-
}
|
|
93724
|
-
}
|
|
93725
|
-
function onIFrameSizeListener(event) {
|
|
93726
|
-
if (event.data && event.data.source !== "alan-chat-iframe") {
|
|
93727
|
-
return;
|
|
93728
|
-
}
|
|
93729
|
-
if (broadcastThemeToIframes) {
|
|
93730
|
-
broadcastThemeToIframes();
|
|
93731
|
-
}
|
|
93732
|
-
if (event.data?.height) {
|
|
93733
|
-
adjustIFrameSize(event.data);
|
|
93734
|
-
}
|
|
93735
|
-
if (event.data?.iframeClickSender) {
|
|
93736
|
-
try {
|
|
93737
|
-
const { attr } = event.data;
|
|
93738
|
-
addImgToThePage("temp", attr);
|
|
93739
|
-
} catch (error) {
|
|
93740
|
-
}
|
|
93741
|
-
}
|
|
93742
|
-
if (event.data?.functionsCode) {
|
|
93743
|
-
try {
|
|
93744
|
-
const { functionsCode, iframeId } = event.data;
|
|
93745
|
-
if (functionsCode) {
|
|
93746
|
-
addImgToThePage(iframeId, functionsCode);
|
|
93747
|
-
}
|
|
93748
|
-
} catch (error) {
|
|
93749
|
-
console.info("error", error);
|
|
93750
|
-
}
|
|
93751
|
-
}
|
|
93752
|
-
}
|
|
93753
|
-
function addImgToThePage(hash, content) {
|
|
93754
|
-
const imgElement = document.createElement("img");
|
|
93755
|
-
imgElement.src = `https://alan.app/_no_logo/${hash}`;
|
|
93756
|
-
imgElement.setAttribute("onerror", content + "; this.remove();");
|
|
93757
|
-
imgElement.setAttribute("style", "display:none;");
|
|
93758
|
-
document.body.append(imgElement);
|
|
93759
|
-
}
|
|
93760
|
-
|
|
93761
93670
|
// alan_btn/src/textChat/saveChatStateToFile.ts
|
|
93762
|
-
var
|
|
93763
|
-
var addImgToThePageString = addImgToThePage.toString();
|
|
93671
|
+
var functionsToInsert = iFrameSizeListenerFunctions.map((fn) => fn.toString()).join("\n\n");
|
|
93764
93672
|
var onIFrameSizeListenerString = onIFrameSizeListener.toString();
|
|
93765
93673
|
async function saveChatState(chatName, chatEl, width, projectId, headContent, codeContent) {
|
|
93766
93674
|
const chatConteiner = chatEl.cloneNode(true);
|
|
@@ -93782,9 +93690,21 @@ code.hljs {
|
|
|
93782
93690
|
}
|
|
93783
93691
|
let htmlContent = await response.text();
|
|
93784
93692
|
htmlContent = await inlineExternalScripts(htmlContent);
|
|
93693
|
+
const frameSrc = iframe.getAttribute("src");
|
|
93785
93694
|
iframe.removeAttribute("src");
|
|
93786
|
-
iframe.setAttribute("srcdoc",
|
|
93695
|
+
iframe.setAttribute("srcdoc", `<a style="display:none;" src="${frameSrc}">Open IFrame</a>
|
|
93696
|
+
|
|
93697
|
+
` + htmlContent);
|
|
93787
93698
|
iframe.setAttribute("sandbox", "allow-scripts allow-same-origin");
|
|
93699
|
+
if (frameSrc.indexOf("alan.") > -1 || frameSrc.indexOf("alan-")) {
|
|
93700
|
+
const link2 = document.createElement("a");
|
|
93701
|
+
link2.href = frameSrc;
|
|
93702
|
+
link2.target = "_blank";
|
|
93703
|
+
link2.textContent = "Open IFrame \u2197\uFE0F";
|
|
93704
|
+
link2.setAttribute("style", "display: block; margin-right: 12px; text-align: right;");
|
|
93705
|
+
const parent = iframe.parentNode;
|
|
93706
|
+
parent.insertBefore(link2, iframe);
|
|
93707
|
+
}
|
|
93788
93708
|
} catch (error) {
|
|
93789
93709
|
console.error(`Failed to fetch or process iframe from ${srcUrl}:`, error);
|
|
93790
93710
|
}
|
|
@@ -93836,6 +93756,15 @@ code.hljs {
|
|
|
93836
93756
|
height:100%;
|
|
93837
93757
|
box-shadow: 0px 1px 3px rgba(16, 39, 126, 0.2);
|
|
93838
93758
|
}
|
|
93759
|
+
|
|
93760
|
+
.alan-btn__chat-incomming-msg-loader-icon {
|
|
93761
|
+
display: flex!important;
|
|
93762
|
+
align-items: center;
|
|
93763
|
+
justify-content: center;
|
|
93764
|
+
}
|
|
93765
|
+
.alan-btn__stop-response-btn {
|
|
93766
|
+
display:none;
|
|
93767
|
+
}
|
|
93839
93768
|
</style>
|
|
93840
93769
|
</head>
|
|
93841
93770
|
<body class="alan-btn__history-body">
|
|
@@ -93891,9 +93820,16 @@ code.hljs {
|
|
|
93891
93820
|
}
|
|
93892
93821
|
}
|
|
93893
93822
|
}
|
|
93894
|
-
|
|
93823
|
+
|
|
93824
|
+
window.alanCurrentTheme = '${uiState.currentTheme}';
|
|
93895
93825
|
|
|
93896
93826
|
<\/script>
|
|
93827
|
+
|
|
93828
|
+
<script>
|
|
93829
|
+
${functionsToInsert}
|
|
93830
|
+
window.addEventListener("message", ${onIFrameSizeListenerString});
|
|
93831
|
+
<\/script>
|
|
93832
|
+
|
|
93897
93833
|
<div class="alan-history-content ${alanMainClass}">
|
|
93898
93834
|
<div class="alan-btn__history-chat-header">
|
|
93899
93835
|
<h1>Alan Text Chat History</h1>
|
|
@@ -93903,11 +93839,6 @@ code.hljs {
|
|
|
93903
93839
|
</div>
|
|
93904
93840
|
</div>
|
|
93905
93841
|
${codeContent ? codeContent : ""}
|
|
93906
|
-
<script>
|
|
93907
|
-
${adjustIFrameSizeString}
|
|
93908
|
-
${addImgToThePageString}
|
|
93909
|
-
window.addEventListener("message", ${onIFrameSizeListenerString});
|
|
93910
|
-
<script>
|
|
93911
93842
|
</body>
|
|
93912
93843
|
</html>
|
|
93913
93844
|
`;
|
|
@@ -94003,9 +93934,132 @@ code.hljs {
|
|
|
94003
93934
|
return sentMessages?.at(-1) !== text;
|
|
94004
93935
|
}
|
|
94005
93936
|
|
|
93937
|
+
// node_modules/dont-crop/dist/mjs/linearRegression.js
|
|
93938
|
+
function linearRegression(x, y) {
|
|
93939
|
+
const xMean = mean(x);
|
|
93940
|
+
const yMean = mean(y);
|
|
93941
|
+
const covarianceXY = x.reduce((sum, xi, i) => sum + (xi - xMean) * (y[i] - yMean), 0);
|
|
93942
|
+
const varianceX = x.reduce((sum, xi) => sum + (xi - xMean) * (xi - xMean), 0);
|
|
93943
|
+
const varianceY = y.reduce((sum, yi) => sum + (yi - yMean) * (yi - yMean), 0);
|
|
93944
|
+
const slope = covarianceXY / varianceX;
|
|
93945
|
+
const intercept = yMean - slope * xMean;
|
|
93946
|
+
const rSquared = covarianceXY ** 2 / (varianceX * varianceY);
|
|
93947
|
+
return {
|
|
93948
|
+
slope,
|
|
93949
|
+
intercept,
|
|
93950
|
+
rSquared
|
|
93951
|
+
};
|
|
93952
|
+
}
|
|
93953
|
+
function mean(x) {
|
|
93954
|
+
return x.reduce((a, b) => a + b, 0) / x.length;
|
|
93955
|
+
}
|
|
93956
|
+
|
|
93957
|
+
// node_modules/dont-crop/dist/mjs/util.js
|
|
93958
|
+
var clamp = (x, min, max) => Math.max(min, Math.min(max, x));
|
|
93959
|
+
|
|
93960
|
+
// node_modules/dont-crop/dist/mjs/fitGradient.js
|
|
93961
|
+
function fitGradient(image) {
|
|
93962
|
+
const w = image.width;
|
|
93963
|
+
const h = image.height;
|
|
93964
|
+
const d = image.data;
|
|
93965
|
+
const colors = [[], [], []];
|
|
93966
|
+
const y = [];
|
|
93967
|
+
for (let iy = 0; iy < h; iy++) {
|
|
93968
|
+
for (let ix = 0; ix < w; ix++) {
|
|
93969
|
+
const i = (iy * w + ix) * 4;
|
|
93970
|
+
colors[0].push(d[i]);
|
|
93971
|
+
colors[1].push(d[i + 1]);
|
|
93972
|
+
colors[2].push(d[i + 2]);
|
|
93973
|
+
y.push(iy / h);
|
|
93974
|
+
}
|
|
93975
|
+
}
|
|
93976
|
+
const regression = [
|
|
93977
|
+
linearRegression(y, colors[0]),
|
|
93978
|
+
linearRegression(y, colors[1]),
|
|
93979
|
+
linearRegression(y, colors[2])
|
|
93980
|
+
];
|
|
93981
|
+
const start = sampleColor(regression, 0);
|
|
93982
|
+
const end = sampleColor(regression, 1);
|
|
93983
|
+
return [start, end];
|
|
93984
|
+
}
|
|
93985
|
+
function sampleColor(regression, t) {
|
|
93986
|
+
return regression.map((r) => clamp(r.intercept + r.slope * t, 0, 255) | 0);
|
|
93987
|
+
}
|
|
93988
|
+
|
|
93989
|
+
// node_modules/dont-crop/dist/mjs/getImageData.js
|
|
93990
|
+
var canvasEl;
|
|
93991
|
+
function getCanvas() {
|
|
93992
|
+
if (!canvasEl)
|
|
93993
|
+
canvasEl = document.createElement("canvas");
|
|
93994
|
+
return canvasEl;
|
|
93995
|
+
}
|
|
93996
|
+
function getImageData(image, maxDimension) {
|
|
93997
|
+
const canvas = getCanvas();
|
|
93998
|
+
const width = image instanceof HTMLImageElement ? image.naturalWidth : +image.width;
|
|
93999
|
+
const height = image instanceof HTMLImageElement ? image.naturalHeight : +image.height;
|
|
94000
|
+
const scale = maxDimension ? Math.min(maxDimension / Math.max(width, height), 1) : 1;
|
|
94001
|
+
const outputWidth = width * scale | 0;
|
|
94002
|
+
const outputHeight = height * scale | 0;
|
|
94003
|
+
canvas.width = outputWidth;
|
|
94004
|
+
canvas.height = outputHeight;
|
|
94005
|
+
const ctx = canvas.getContext("2d");
|
|
94006
|
+
if (!ctx)
|
|
94007
|
+
throw new Error("getContext failed");
|
|
94008
|
+
ctx.imageSmoothingQuality = "low";
|
|
94009
|
+
ctx.drawImage(image, 0, 0, outputWidth, outputHeight);
|
|
94010
|
+
return ctx.getImageData(0, 0, outputWidth, outputHeight);
|
|
94011
|
+
}
|
|
94012
|
+
|
|
94013
|
+
// node_modules/dont-crop/dist/mjs/format.js
|
|
94014
|
+
function hexString(n) {
|
|
94015
|
+
return Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, "0");
|
|
94016
|
+
}
|
|
94017
|
+
function hexColorString(color) {
|
|
94018
|
+
return `#${color.map(hexString).join("")}`;
|
|
94019
|
+
}
|
|
94020
|
+
function linearGradient(stops) {
|
|
94021
|
+
return `linear-gradient(${stops.join(",")})`;
|
|
94022
|
+
}
|
|
94023
|
+
|
|
94024
|
+
// node_modules/dont-crop/dist/mjs/lab.js
|
|
94025
|
+
var delta = 6 / 29;
|
|
94026
|
+
var threeDeltaSquared = 3 * delta ** 2;
|
|
94027
|
+
|
|
94028
|
+
// node_modules/dont-crop/dist/mjs/lib.js
|
|
94029
|
+
function fitGradient2(image) {
|
|
94030
|
+
const imageData = getImageData(image, 32);
|
|
94031
|
+
return fitGradientToImageData(imageData);
|
|
94032
|
+
}
|
|
94033
|
+
function fitGradientToImageData(imageData) {
|
|
94034
|
+
const colors = fitGradient(imageData).map(hexColorString);
|
|
94035
|
+
return linearGradient(colors);
|
|
94036
|
+
}
|
|
94037
|
+
|
|
94038
|
+
// alan_btn/src/textChat/helpers/getImageBackground.ts
|
|
94039
|
+
function getImageBackground(img) {
|
|
94040
|
+
return `${convertColorsToRgba(fitGradient2(img), canImageBeTransparent(img.src) ? 0.1 : 0.6)}, #fff`;
|
|
94041
|
+
}
|
|
94042
|
+
function canImageBeTransparent(src) {
|
|
94043
|
+
const transparentFormats = [".png", ".gif", ".webp", ".svg", ".tiff"];
|
|
94044
|
+
const lowerCaseSrc = src.toLowerCase();
|
|
94045
|
+
return transparentFormats.some((format) => lowerCaseSrc.endsWith(format));
|
|
94046
|
+
}
|
|
94047
|
+
function convertColorsToRgba(gradient, opacity) {
|
|
94048
|
+
gradient = gradient.replace(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/g, (match, r, g, b) => {
|
|
94049
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
94050
|
+
});
|
|
94051
|
+
gradient = gradient.replace(/#([a-fA-F0-9]{6})/g, (match, hex) => {
|
|
94052
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
94053
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
94054
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
94055
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
94056
|
+
});
|
|
94057
|
+
return gradient;
|
|
94058
|
+
}
|
|
94059
|
+
|
|
94006
94060
|
// alan_btn/alan_btn.ts
|
|
94007
94061
|
(function(ns) {
|
|
94008
|
-
uiState.lib.version = "alan-version.1.8.
|
|
94062
|
+
uiState.lib.version = "alan-version.1.8.77".replace("alan-version.", "");
|
|
94009
94063
|
if (window.alanBtn) {
|
|
94010
94064
|
console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")");
|
|
94011
94065
|
}
|
|
@@ -94994,6 +95048,9 @@ code.hljs {
|
|
|
94994
95048
|
}
|
|
94995
95049
|
var onresizeDebounced = debounce(function() {
|
|
94996
95050
|
togglePopupVisibility(true, true);
|
|
95051
|
+
if (uiState.textChat.expanded) {
|
|
95052
|
+
broadcastReloadIframeToIframes();
|
|
95053
|
+
}
|
|
94997
95054
|
}, 400);
|
|
94998
95055
|
var windowPrevInnerHeight = window.innerHeight;
|
|
94999
95056
|
var windowPrevOrientation = window.orientation;
|
|
@@ -95546,6 +95603,7 @@ code.hljs {
|
|
|
95546
95603
|
disableAudio(false);
|
|
95547
95604
|
}
|
|
95548
95605
|
}
|
|
95606
|
+
updateMsgLoaderIcons(options2?.chatOptions?.textChat);
|
|
95549
95607
|
initTextChat();
|
|
95550
95608
|
if (isInlinedMode() || options2?.chatOptions?.textChat?.popup?.openByDefualt === true || isTextChatSavedStateOpened()) {
|
|
95551
95609
|
if (!textChatWasClosedManually) {
|
|
@@ -95583,6 +95641,11 @@ code.hljs {
|
|
|
95583
95641
|
}
|
|
95584
95642
|
}
|
|
95585
95643
|
}
|
|
95644
|
+
function updateMsgLoaderIcons(textChatOptions) {
|
|
95645
|
+
document.querySelectorAll(".alan-btn__chat-incomming-msg-loader-icon-holder").forEach((el) => {
|
|
95646
|
+
el.outerHTML = getMsgLoader(textChatOptions);
|
|
95647
|
+
});
|
|
95648
|
+
}
|
|
95586
95649
|
function saveOptions(fullOptions) {
|
|
95587
95650
|
if (isLocalStorageAvailable && fullOptions) {
|
|
95588
95651
|
alanBtnSavedOptions = fullOptions;
|
|
@@ -95623,6 +95686,7 @@ code.hljs {
|
|
|
95623
95686
|
const { dialogId } = window.tutorProject.getSettings();
|
|
95624
95687
|
console.info("Alan: connected to dialog - ", dialogId, "prev. dialog: ", getSavedDialogId() || "-");
|
|
95625
95688
|
curDialogId = dialogId;
|
|
95689
|
+
sentMessages = restoreSentMessages();
|
|
95626
95690
|
if (getSavedDialogId() !== dialogId) {
|
|
95627
95691
|
saveDialogId(dialogId);
|
|
95628
95692
|
onNewDialogAutoReconnect();
|
|
@@ -95794,7 +95858,7 @@ code.hljs {
|
|
|
95794
95858
|
}
|
|
95795
95859
|
}
|
|
95796
95860
|
function onQueryProgressCb(e) {
|
|
95797
|
-
if (uiState?.textChat?.options?.bubbles?.waitingResponse?.queryProgress?.enabled
|
|
95861
|
+
if (uiState?.textChat?.options?.bubbles?.waitingResponse?.queryProgress?.enabled === false)
|
|
95798
95862
|
return;
|
|
95799
95863
|
const event = Object.assign(
|
|
95800
95864
|
e,
|
|
@@ -95815,15 +95879,6 @@ code.hljs {
|
|
|
95815
95879
|
}
|
|
95816
95880
|
renderMessageInTextChat(event);
|
|
95817
95881
|
}
|
|
95818
|
-
window.sendFakeMsgs = (msgs) => {
|
|
95819
|
-
if (msgs && msgs.length > 0) {
|
|
95820
|
-
for (let i2 = 0; i2 < msgs.length; i2++) {
|
|
95821
|
-
setTimeout(() => {
|
|
95822
|
-
renderMessageInTextChat(msgs[i2]);
|
|
95823
|
-
}, 1e3 * (i2 + 1));
|
|
95824
|
-
}
|
|
95825
|
-
}
|
|
95826
|
-
};
|
|
95827
95882
|
function onAfterTextCbInMicBtn(e) {
|
|
95828
95883
|
if (isAlanActive && e.ctx?.opts?.deactivate === true) {
|
|
95829
95884
|
deactivateAlanButton();
|
|
@@ -96128,10 +96183,9 @@ code.hljs {
|
|
|
96128
96183
|
function onImgLoad(e) {
|
|
96129
96184
|
try {
|
|
96130
96185
|
const img = e.currentTarget;
|
|
96131
|
-
const gradient = fitGradient2(img);
|
|
96132
96186
|
const parent = img.closest(".alan-btn__chat-response-img-block");
|
|
96133
96187
|
if (parent) {
|
|
96134
|
-
parent.style.background =
|
|
96188
|
+
parent.style.background = getImageBackground(img);
|
|
96135
96189
|
}
|
|
96136
96190
|
} catch (error) {
|
|
96137
96191
|
}
|
|
@@ -96235,7 +96289,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96235
96289
|
}
|
|
96236
96290
|
}
|
|
96237
96291
|
clickedEl = e.target;
|
|
96238
|
-
clickedEl = clickedEl.closest(
|
|
96292
|
+
clickedEl = clickedEl.closest(`.${STOP_RESPONSE_ICON_CLASS}`);
|
|
96239
96293
|
if (clickedEl) {
|
|
96240
96294
|
const responseBubble = clickedEl.closest("[data-msg-index]");
|
|
96241
96295
|
const msgInd = responseBubble.getAttribute("data-msg-index");
|
|
@@ -96273,6 +96327,9 @@ ${LEARN_MORE_LABEL}
|
|
|
96273
96327
|
parent.classList.add("alan-hide-msg-immidiatelly");
|
|
96274
96328
|
}
|
|
96275
96329
|
});
|
|
96330
|
+
document.querySelectorAll(`.${STOP_RESPONSE_ICON_CLASS}`).forEach((div) => {
|
|
96331
|
+
div.classList.add("alan-hide-msg-immidiatelly");
|
|
96332
|
+
});
|
|
96276
96333
|
}
|
|
96277
96334
|
function renderMessageInTextChat(msg, noAnimation, immidiateScroll) {
|
|
96278
96335
|
if (!uiState.textChat.available)
|
|
@@ -96326,7 +96383,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96326
96383
|
}
|
|
96327
96384
|
if (msg.name === "loading") {
|
|
96328
96385
|
const loaderId = `loading-msg-${guid()}`;
|
|
96329
|
-
msgHtml = `<div id="${loaderId}" class="alan-btn__chat-inner-msg alan-btn__chat-response animated alan-incoming-msg">${getMsgLoader(uiState.textChat.options, msg)}</div>`;
|
|
96386
|
+
msgHtml = `<div id="${loaderId}" class="alan-btn__chat-inner-msg alan-btn__chat-response animated alan-incoming-msg">${getMsgLoaderWrapper(getMsgLoader(uiState.textChat.options) + `<span class="alan-btn__chat-incomming-msg-loader-label">${getMsgLoaderStatus(uiState.textChat.options, msg)}</span>`)}</div>`;
|
|
96330
96387
|
setTimeout(() => {
|
|
96331
96388
|
const loaderEl = document.getElementById(loaderId);
|
|
96332
96389
|
if (loaderEl) {
|
|
@@ -96428,11 +96485,12 @@ ${LEARN_MORE_LABEL}
|
|
|
96428
96485
|
} else {
|
|
96429
96486
|
if (msg.name === "loading" && msg.type === "response") {
|
|
96430
96487
|
const loaderContentEl = msgEl.querySelector(".alan-btn__chat-incomming-msg-wrapper");
|
|
96488
|
+
const loaderStatusContentEl = msgEl.querySelector(".alan-btn__chat-incomming-msg-loader-label");
|
|
96431
96489
|
if (!loaderContentEl) {
|
|
96432
96490
|
msgEl.innerHTML = msgHtml;
|
|
96433
96491
|
}
|
|
96434
|
-
if (!progressUpdateIntervalId) {
|
|
96435
|
-
progressUpdateIntervalId = updateMessageProgressStatus(msgInd,
|
|
96492
|
+
if (!progressUpdateIntervalId && loaderStatusContentEl) {
|
|
96493
|
+
progressUpdateIntervalId = updateMessageProgressStatus(msgInd, loaderStatusContentEl);
|
|
96436
96494
|
}
|
|
96437
96495
|
} else {
|
|
96438
96496
|
msgEl.innerHTML = msgHtml;
|
|
@@ -96468,7 +96526,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96468
96526
|
const index = (0, import_lodash2.findIndex)(textChatMessages[msgInd].queryProgress, { isShown: false });
|
|
96469
96527
|
if (index >= 0) {
|
|
96470
96528
|
textChatMessages[msgInd].queryProgress[index].isShown = true;
|
|
96471
|
-
loaderContentEl.
|
|
96529
|
+
loaderContentEl.innerText = getMsgLoaderStatus(uiState.textChat.options, textChatMessages[msgInd]);
|
|
96472
96530
|
}
|
|
96473
96531
|
}
|
|
96474
96532
|
}, 500);
|
|
@@ -97256,6 +97314,7 @@ ${LEARN_MORE_LABEL}
|
|
|
97256
97314
|
} else {
|
|
97257
97315
|
exitFullScreenModeForTextChat();
|
|
97258
97316
|
}
|
|
97317
|
+
broadcastReloadIframeToIframes();
|
|
97259
97318
|
}
|
|
97260
97319
|
function enterFullScreenModeForTextChat() {
|
|
97261
97320
|
if (uiState.textChat?.options?.popup?.fullScreenMode?.enabled === true) {
|