@alan-ai/alan-sdk-web 1.8.86 → 1.8.88
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/README.md +9 -28
- package/dist/alan_lib.js +826 -20
- package/dist/alan_lib.min.js +1 -1
- package/package.json +1 -1
package/dist/alan_lib.js
CHANGED
|
@@ -90463,7 +90463,10 @@
|
|
|
90463
90463
|
`,
|
|
90464
90464
|
minimize: `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
90465
90465
|
<path d="M3 17.25L18 17.25" stroke="none" stroke-width="1.5" stroke-linecap="round"/>
|
|
90466
|
-
</svg
|
|
90466
|
+
</svg>`,
|
|
90467
|
+
graph: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
90468
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.032 1H5.96802C5.52939 0.999989 5.15087 0.999979 4.83762 1.02135C4.50779 1.04386 4.17788 1.09336 3.85195 1.22836C3.11687 1.53285 2.53284 2.11687 2.22836 2.85195C2.09336 3.17788 2.04385 3.50779 2.02135 3.83762C1.99998 4.15087 1.99999 4.52936 2 4.968V5.03198C1.99999 5.47063 1.99998 5.84913 2.02135 6.16238C2.04385 6.49221 2.09336 6.82212 2.22836 7.14805C2.53284 7.88314 3.11687 8.46716 3.85195 8.77164C4.17788 8.90664 4.50779 8.95615 4.83762 8.97865C5.15088 9.00002 5.52936 9.00002 5.96801 9H11V12H8.7587C7.95376 12 7.28935 12 6.74817 12.0442C6.18608 12.0901 5.66937 12.1887 5.18404 12.436C4.43139 12.8195 3.81947 13.4314 3.43597 14.184C3.18868 14.6694 3.09012 15.1861 3.04419 15.7482C3.01124 16.1515 3.00285 16.6232 3.00072 17.1705C1.83515 17.5821 1 18.6935 1 20C1 21.6569 2.34315 23 4 23C5.65685 23 7 21.6569 7 20C7 18.6941 6.16559 17.5831 5.00083 17.171C5.00297 16.6425 5.01058 16.2412 5.03755 15.911C5.07337 15.4726 5.1383 15.2484 5.21799 15.092C5.40973 14.7157 5.7157 14.4097 6.09202 14.218C6.24842 14.1383 6.47262 14.0734 6.91104 14.0376C7.36113 14.0008 7.94342 14 8.8 14H11V17.1707C9.83481 17.5825 9 18.6938 9 20C9 21.6569 10.3431 23 12 23C13.6569 23 15 21.6569 15 20C15 18.6938 14.1652 17.5825 13 17.1707V14H15.2C16.0566 14 16.6389 14.0008 17.089 14.0376C17.5274 14.0734 17.7516 14.1383 17.908 14.218C18.2843 14.4097 18.5903 14.7157 18.782 15.092C18.8617 15.2484 18.9266 15.4726 18.9624 15.911C18.9894 16.2412 18.997 16.6425 18.9992 17.171C17.8344 17.5831 17 18.6941 17 20C17 21.6569 18.3431 23 20 23C21.6569 23 23 21.6569 23 20C23 18.6935 22.1648 17.5821 20.9993 17.1705C20.9971 16.6232 20.9888 16.1515 20.9558 15.7482C20.9099 15.1861 20.8113 14.6694 20.564 14.184C20.1805 13.4314 19.5686 12.8195 18.816 12.436C18.3306 12.1887 17.8139 12.0901 17.2518 12.0442C16.7106 12 16.0463 12 15.2414 12H13V9H18.032C18.4706 9.00002 18.8491 9.00002 19.1624 8.97865C19.4922 8.95615 19.8221 8.90664 20.1481 8.77164C20.8831 8.46716 21.4672 7.88314 21.7716 7.14805C21.9066 6.82212 21.9561 6.49221 21.9787 6.16238C22 5.84913 22 5.47064 22 5.03199V4.96801C22 4.52936 22 4.15088 21.9787 3.83762C21.9561 3.50779 21.9066 3.17788 21.7716 2.85195C21.4672 2.11687 20.8831 1.53285 20.1481 1.22836C19.8221 1.09336 19.4922 1.04386 19.1624 1.02135C18.8491 0.999979 18.4706 0.999989 18.032 1Z" fill="black" />
|
|
90469
|
+
</svg>`
|
|
90467
90470
|
};
|
|
90468
90471
|
function getCloseChatIcon(textChatOptions) {
|
|
90469
90472
|
return textChatOptions?.popup?.icons?.close?.svg || chatIcons.closeChat;
|
|
@@ -90546,10 +90549,12 @@
|
|
|
90546
90549
|
function mergeProgressiveMessages(messages, i, message) {
|
|
90547
90550
|
const maxLinksCount = 9;
|
|
90548
90551
|
const newImages = message.images || [];
|
|
90552
|
+
const newSuggestions = message.suggestions || [];
|
|
90549
90553
|
const oldText = messages[i].text || "";
|
|
90550
90554
|
const newText = message.text || "";
|
|
90551
90555
|
messages[i].text = oldText + newText;
|
|
90552
90556
|
messages[i].images = [...messages[i].images || [], ...newImages];
|
|
90557
|
+
messages[i].suggestions = [...messages[i].suggestions || [], ...newSuggestions];
|
|
90553
90558
|
messages[i].links = [...messages[i].links || [], ...message.links || []].splice(0, maxLinksCount);
|
|
90554
90559
|
if (!messages[i].parts) {
|
|
90555
90560
|
messages[i].parts = [];
|
|
@@ -90905,6 +90910,14 @@
|
|
|
90905
90910
|
}
|
|
90906
90911
|
return "none";
|
|
90907
90912
|
}
|
|
90913
|
+
function getEnvironment() {
|
|
90914
|
+
var key;
|
|
90915
|
+
if (uiState.project.id) {
|
|
90916
|
+
key = uiState.project.id;
|
|
90917
|
+
return key.substr(key.indexOf("/"));
|
|
90918
|
+
}
|
|
90919
|
+
return "none";
|
|
90920
|
+
}
|
|
90908
90921
|
function getDeviceId() {
|
|
90909
90922
|
if (!uiState.project.id)
|
|
90910
90923
|
return;
|
|
@@ -90970,14 +90983,17 @@
|
|
|
90970
90983
|
setTimeout(() => {
|
|
90971
90984
|
broadcastThemeToIframes();
|
|
90972
90985
|
iframeEl.classList.remove("alan-iframe-hidden");
|
|
90986
|
+
removeIframeLoader(iframeEl);
|
|
90973
90987
|
}, 200);
|
|
90974
90988
|
} else {
|
|
90975
90989
|
setTimeout(() => {
|
|
90976
90990
|
iframeEl.classList.remove("alan-iframe-hidden");
|
|
90991
|
+
removeIframeLoader(iframeEl);
|
|
90977
90992
|
}, 1200);
|
|
90978
90993
|
}
|
|
90979
90994
|
if (Math.abs(iframeEl.clientHeight - height) !== 20) {
|
|
90980
90995
|
iframeEl.style.height = (+height > maxIFrameHeight ? maxIFrameHeight : height) + "px";
|
|
90996
|
+
iframeEl.style.minHeight = "0px";
|
|
90981
90997
|
}
|
|
90982
90998
|
if ((!withSvg || !iframeEl.src) && !window.alanIframes[iframeId]?.initialized) {
|
|
90983
90999
|
broadcastReloadIframeToIframes(currentIframeId);
|
|
@@ -90987,7 +91003,8 @@
|
|
|
90987
91003
|
return;
|
|
90988
91004
|
}
|
|
90989
91005
|
if (withSvg) {
|
|
90990
|
-
if (!responseWrapper.classList.contains(
|
|
91006
|
+
if (!responseWrapper.classList.contains(`with-svg-for-${iframeId}`)) {
|
|
91007
|
+
responseWrapper.classList.add(`with-svg-for-${iframeId}`);
|
|
90991
91008
|
responseWrapper.classList.add("with-svg");
|
|
90992
91009
|
iframeEl.style.width = "100%";
|
|
90993
91010
|
setTimeout(() => {
|
|
@@ -91078,8 +91095,15 @@
|
|
|
91078
91095
|
broadcastReloadIframeToIframes,
|
|
91079
91096
|
adjustIFrameSize,
|
|
91080
91097
|
getThemeSrc,
|
|
91081
|
-
addImgToThePage
|
|
91098
|
+
addImgToThePage,
|
|
91099
|
+
removeIframeLoader
|
|
91082
91100
|
];
|
|
91101
|
+
function removeIframeLoader(iframe) {
|
|
91102
|
+
const iframeWrapper = iframe.closest(".act-embed-container");
|
|
91103
|
+
if (iframeWrapper) {
|
|
91104
|
+
iframeWrapper.classList.remove("loading");
|
|
91105
|
+
}
|
|
91106
|
+
}
|
|
91083
91107
|
function onIFrameSizeListener(event) {
|
|
91084
91108
|
if (event.data && event.data.source !== "alan-chat-iframe") {
|
|
91085
91109
|
return;
|
|
@@ -91616,8 +91640,8 @@
|
|
|
91616
91640
|
const responseBubbleLabelFontSize = getNumPropVal(textChatOptions?.bubbles?.response?.label?.fontSize, 15);
|
|
91617
91641
|
const responseBubbleLabelColor = textChatOptions?.bubbles?.response?.label?.color || `#171717`;
|
|
91618
91642
|
const responseBubbleLabelEnabled = uiState?.textChat?.options?.bubbles?.response?.label?.enabled === true;
|
|
91619
|
-
const btnAlignment = textChatOptions?.buttons?.alignment?.default || "
|
|
91620
|
-
const btnAlignmentFullscreen = textChatOptions?.buttons?.alignment?.fullScreen || "
|
|
91643
|
+
const btnAlignment = textChatOptions?.buttons?.alignment?.default || "right";
|
|
91644
|
+
const btnAlignmentFullscreen = textChatOptions?.buttons?.alignment?.fullScreen || "right";
|
|
91621
91645
|
const textChatAppearAnimationMs = uiState.textChat.defaults.appearAnimationMs;
|
|
91622
91646
|
const headerLayoutName = textChatOptions?.header?.layout?.name || "centered-title";
|
|
91623
91647
|
let cssChatHeight = getTextChatSizeAfterResize("height");
|
|
@@ -92713,7 +92737,7 @@
|
|
|
92713
92737
|
padding-left: ${avatarSize + avatarRightMargin}px;
|
|
92714
92738
|
}`;
|
|
92715
92739
|
keyFrames += getStyleSheetMarker() + `.alan-btn__chat-buttons .alan-chat__chat-btn {
|
|
92716
|
-
text-align: ${textChatOptions?.buttons?.textAlign?.default || "
|
|
92740
|
+
text-align: ${textChatOptions?.buttons?.textAlign?.default || "left"};
|
|
92717
92741
|
}`;
|
|
92718
92742
|
const defaultButtonBorderRadius = 20;
|
|
92719
92743
|
keyFrames += getStyleSheetMarker() + `.alan-chat__chat-btn {
|
|
@@ -92744,6 +92768,48 @@
|
|
|
92744
92768
|
box-shadow: ${textChatOptions?.buttons?.active?.hasShadow === false ? "none" : `0px 1px 3px rgba(16, 39, 126, 0.2)`};
|
|
92745
92769
|
color: ${textChatOptions?.buttons?.active?.color || `#0078ff`};
|
|
92746
92770
|
}`;
|
|
92771
|
+
keyFrames += getStyleSheetMarker() + `.alan-btn__chat-suggestions {
|
|
92772
|
+
margin-bottom: 16px;
|
|
92773
|
+
display:flex;
|
|
92774
|
+
flex-wrap: wrap;
|
|
92775
|
+
gap: ${btnsGap}px;
|
|
92776
|
+
clear: both;
|
|
92777
|
+
justify-content: ${flexMap[btnAlignment]};
|
|
92778
|
+
}`;
|
|
92779
|
+
keyFrames += getStyleSheetMarker() + `.alan-btn_text-chat-full-screen .alan-btn__chat-suggestions {
|
|
92780
|
+
justify-content: ${flexMap[btnAlignmentFullscreen]};
|
|
92781
|
+
}`;
|
|
92782
|
+
keyFrames += getStyleSheetMarker() + `.alan-btn__chat-suggestions .alan-chat__suggestion {
|
|
92783
|
+
text-align: ${textChatOptions?.buttons?.textAlign?.default || "left"};
|
|
92784
|
+
}`;
|
|
92785
|
+
keyFrames += getStyleSheetMarker() + `.alan-chat__suggestion {
|
|
92786
|
+
margin-bottom: 8px;
|
|
92787
|
+
padding: ${getPaddingProp(buttonsTopPadding, buttonsRightPadding, buttonsBottomPadding, buttonsLeftPadding)};
|
|
92788
|
+
line-height: 1.53;
|
|
92789
|
+
display: inline-block;
|
|
92790
|
+
border-radius: ${textChatOptions?.buttons?.borderRadius?.topLeft || defaultButtonBorderRadius}px ${textChatOptions?.buttons?.borderRadius?.topRight || defaultButtonBorderRadius}px ${textChatOptions?.buttons?.borderRadius?.bottomRight || defaultButtonBorderRadius}px ${textChatOptions?.buttons?.borderRadius?.bottomLeft || defaultButtonBorderRadius}px;
|
|
92791
|
+
position: relative;
|
|
92792
|
+
background-color: ${textChatOptions?.buttons?.default?.backgroundColor || `#ffffff`};
|
|
92793
|
+
border: 1px solid ${textChatOptions?.buttons?.default?.borderColor || `#ffffff`};
|
|
92794
|
+
box-shadow: ${textChatOptions?.buttons?.default?.hasShadow === false ? "none" : `0px 1px 3px rgba(16, 39, 126, 0.2)`};
|
|
92795
|
+
color: ${textChatOptions?.buttons?.default?.color || `#171717`};
|
|
92796
|
+
font-size: ${textChatOptions?.buttons?.fontSize || `15`}px;
|
|
92797
|
+
word-break: break-word;
|
|
92798
|
+
text-align: left;
|
|
92799
|
+
cursor: pointer;
|
|
92800
|
+
}`;
|
|
92801
|
+
keyFrames += getStyleSheetMarker() + `.alan-chat__suggestion:hover {
|
|
92802
|
+
background-color: ${textChatOptions?.buttons?.hover?.backgroundColor || `#ffffff`};
|
|
92803
|
+
border: 1px solid ${textChatOptions?.buttons?.hover?.borderColor || `#ffffff`};
|
|
92804
|
+
box-shadow: ${textChatOptions?.buttons?.hover?.hasShadow === false ? "none" : `0px 1px 3px rgba(16, 39, 126, 0.2)`};
|
|
92805
|
+
color: ${textChatOptions?.buttons?.hover?.color || `#0078ff`};
|
|
92806
|
+
}`;
|
|
92807
|
+
keyFrames += getStyleSheetMarker() + `.alan-chat__suggestion:active {
|
|
92808
|
+
background-color: ${textChatOptions?.buttons?.active?.backgroundColor || `#bcdafd`};
|
|
92809
|
+
border: 1px solid ${textChatOptions?.buttons?.active?.borderColor || `#bcdafd`};
|
|
92810
|
+
box-shadow: ${textChatOptions?.buttons?.active?.hasShadow === false ? "none" : `0px 1px 3px rgba(16, 39, 126, 0.2)`};
|
|
92811
|
+
color: ${textChatOptions?.buttons?.active?.color || `#0078ff`};
|
|
92812
|
+
}`;
|
|
92747
92813
|
var chatResponseCssDeltaWidth = 82;
|
|
92748
92814
|
keyFrames += getStyleSheetMarker() + `.alan-btn_text-chat-full-screen .alan-btn__chat-response {
|
|
92749
92815
|
margin-bottom: 16px;
|
|
@@ -93207,6 +93273,15 @@
|
|
|
93207
93273
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__dislike-btn svg path {
|
|
93208
93274
|
fill: ${bottomBtnsColor};
|
|
93209
93275
|
}`;
|
|
93276
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-graph {
|
|
93277
|
+
display: none;
|
|
93278
|
+
}`;
|
|
93279
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-graph svg path {
|
|
93280
|
+
fill: ${bottomBtnsColor};
|
|
93281
|
+
}`;
|
|
93282
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-graph:hover svg path {
|
|
93283
|
+
opacity: 0.8;
|
|
93284
|
+
}`;
|
|
93210
93285
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-btn alan-btn__copy-icon {
|
|
93211
93286
|
width: 22px;
|
|
93212
93287
|
}`;
|
|
@@ -94192,6 +94267,10 @@
|
|
|
94192
94267
|
style.textContent = highlightJsCss(theme);
|
|
94193
94268
|
style.id = hljsStylesId;
|
|
94194
94269
|
doc.getElementsByTagName("head")[0].appendChild(style);
|
|
94270
|
+
var lightHLJSOnlyStyle = doc.createElement("style");
|
|
94271
|
+
lightHLJSOnlyStyle.textContent = highlightJsCssForOnlyLightTheme();
|
|
94272
|
+
lightHLJSOnlyStyle.id = `alan-hljs-styles-light-only`;
|
|
94273
|
+
doc.getElementsByTagName("head")[0].appendChild(lightHLJSOnlyStyle);
|
|
94195
94274
|
}
|
|
94196
94275
|
function highlightCode(msgsHolder) {
|
|
94197
94276
|
if (window.hljs) {
|
|
@@ -94450,6 +94529,96 @@ code.hljs {
|
|
|
94450
94529
|
};
|
|
94451
94530
|
return themes[theme];
|
|
94452
94531
|
}
|
|
94532
|
+
function highlightJsCssForOnlyLightTheme() {
|
|
94533
|
+
const lightOnlyTheme = `
|
|
94534
|
+
.hljs-light-override pre code.hljs {
|
|
94535
|
+
display: block;
|
|
94536
|
+
overflow-x: auto;
|
|
94537
|
+
overflow-y: hidden;
|
|
94538
|
+
padding: 1em;
|
|
94539
|
+
}
|
|
94540
|
+
.hljs-light-override code.hljs {
|
|
94541
|
+
padding: 3px 5px;
|
|
94542
|
+
}
|
|
94543
|
+
.hljs-light-override .hljs {
|
|
94544
|
+
background-color: #f8f8f8 !important;
|
|
94545
|
+
}
|
|
94546
|
+
.hljs-light-override .hljs-doctag,
|
|
94547
|
+
.hljs-light-override .hljs-keyword,
|
|
94548
|
+
.hljs-light-override .hljs-meta .hljs-keyword,
|
|
94549
|
+
.hljs-light-override .hljs-template-tag,
|
|
94550
|
+
.hljs-light-override .hljs-template-variable,
|
|
94551
|
+
.hljs-light-override .hljs-type,
|
|
94552
|
+
.hljs-light-override .hljs-variable.language_ {
|
|
94553
|
+
color: #d73a49;
|
|
94554
|
+
}
|
|
94555
|
+
.hljs-light-override .hljs-title,
|
|
94556
|
+
.hljs-light-override .hljs-title.class_,
|
|
94557
|
+
.hljs-light-override .hljs-title.class_.inherited__,
|
|
94558
|
+
.hljs-light-override .hljs-title.function_ {
|
|
94559
|
+
color: #6f42c1;
|
|
94560
|
+
}
|
|
94561
|
+
.hljs-light-override .hljs-attr,
|
|
94562
|
+
.hljs-light-override .hljs-attribute,
|
|
94563
|
+
.hljs-light-override .hljs-literal,
|
|
94564
|
+
.hljs-light-override .hljs-meta,
|
|
94565
|
+
.hljs-light-override .hljs-number,
|
|
94566
|
+
.hljs-light-override .hljs-operator,
|
|
94567
|
+
.hljs-light-override .hljs-variable,
|
|
94568
|
+
.hljs-light-override .hljs-selector-attr,
|
|
94569
|
+
.hljs-light-override .hljs-selector-class,
|
|
94570
|
+
.hljs-light-override .hljs-selector-id {
|
|
94571
|
+
color: #005cc5;
|
|
94572
|
+
}
|
|
94573
|
+
.hljs-light-override .hljs-regexp,
|
|
94574
|
+
.hljs-light-override .hljs-string,
|
|
94575
|
+
.hljs-light-override .hljs-meta .hljs-string {
|
|
94576
|
+
color: #032f62;
|
|
94577
|
+
}
|
|
94578
|
+
.hljs-light-override .hljs-built_in,
|
|
94579
|
+
.hljs-light-override .hljs-symbol {
|
|
94580
|
+
color: #e36209;
|
|
94581
|
+
}
|
|
94582
|
+
.hljs-light-override .hljs-comment,
|
|
94583
|
+
.hljs-light-override .hljs-code,
|
|
94584
|
+
.hljs-light-override .hljs-formula {
|
|
94585
|
+
color: #6a737d;
|
|
94586
|
+
}
|
|
94587
|
+
.hljs-light-override .hljs-name,
|
|
94588
|
+
.hljs-light-override .hljs-quote,
|
|
94589
|
+
.hljs-light-override .hljs-selector-tag,
|
|
94590
|
+
.hljs-light-override .hljs-selector-pseudo {
|
|
94591
|
+
color: #22863a;
|
|
94592
|
+
}
|
|
94593
|
+
.hljs-light-override .hljs-subst {
|
|
94594
|
+
color: #24292e;
|
|
94595
|
+
}
|
|
94596
|
+
.hljs-light-override .hljs-section {
|
|
94597
|
+
color: #005cc5;
|
|
94598
|
+
font-weight: bold;
|
|
94599
|
+
}
|
|
94600
|
+
.hljs-light-override .hljs-bullet {
|
|
94601
|
+
color: #735c0f;
|
|
94602
|
+
}
|
|
94603
|
+
.hljs-light-override .hljs-emphasis {
|
|
94604
|
+
color: #24292e;
|
|
94605
|
+
font-style: italic;
|
|
94606
|
+
}
|
|
94607
|
+
.hljs-light-override .hljs-strong {
|
|
94608
|
+
color: #24292e;
|
|
94609
|
+
font-weight: bold;
|
|
94610
|
+
}
|
|
94611
|
+
.hljs-light-override .hljs-addition {
|
|
94612
|
+
color: #22863a;
|
|
94613
|
+
background-color: #f0fff4;
|
|
94614
|
+
}
|
|
94615
|
+
.hljs-light-override .hljs-deletion {
|
|
94616
|
+
color: #b31d28;
|
|
94617
|
+
background-color: #ffeef0;
|
|
94618
|
+
}
|
|
94619
|
+
`;
|
|
94620
|
+
return lightOnlyTheme;
|
|
94621
|
+
}
|
|
94453
94622
|
|
|
94454
94623
|
// alan_btn/src/helpers/mini/keepJSONInAttr.ts
|
|
94455
94624
|
function encodeValueForHtmlAttr(data) {
|
|
@@ -94484,7 +94653,8 @@ code.hljs {
|
|
|
94484
94653
|
|
|
94485
94654
|
// alan_btn/src/textChat/helpers/processClickByButtonInChat.ts
|
|
94486
94655
|
function processClickByButtonInChat(clickedEl, btnInstance, sendTextCall) {
|
|
94487
|
-
|
|
94656
|
+
clickedEl = clickedEl.classList.contains("alan-chat__chat-btn") || clickedEl.closest(".alan-chat__suggestion");
|
|
94657
|
+
if (clickedEl) {
|
|
94488
94658
|
const btnLabel = clickedEl.getAttribute("data-alan-button-label");
|
|
94489
94659
|
const btnText = clickedEl.getAttribute("data-alan-button-send-text");
|
|
94490
94660
|
const vsAttr = clickedEl.getAttribute("data-alan-button-set-visual-state");
|
|
@@ -94598,7 +94768,7 @@ code.hljs {
|
|
|
94598
94768
|
const reqId = msg.ctx?.reqId || msg.reqId;
|
|
94599
94769
|
if (reqId) {
|
|
94600
94770
|
window.tutorProject.call("sendFeedback", { reqId, status: msg.liked });
|
|
94601
|
-
if (options
|
|
94771
|
+
if (options?.onEvent) {
|
|
94602
94772
|
options.onEvent({ name: "feedbackSent", status: msg.liked, reqId });
|
|
94603
94773
|
}
|
|
94604
94774
|
}
|
|
@@ -94616,9 +94786,16 @@ code.hljs {
|
|
|
94616
94786
|
}
|
|
94617
94787
|
|
|
94618
94788
|
// alan_btn/src/textChat/saveChatStateToFile.ts
|
|
94619
|
-
var
|
|
94620
|
-
|
|
94621
|
-
|
|
94789
|
+
var LIBS_PREFIX = "https://storage.googleapis.com/alan-ai-public-resources/save-debug-chat-resources";
|
|
94790
|
+
async function saveChatState({
|
|
94791
|
+
chatName,
|
|
94792
|
+
chatEl,
|
|
94793
|
+
width,
|
|
94794
|
+
projectId,
|
|
94795
|
+
environment,
|
|
94796
|
+
requestIds,
|
|
94797
|
+
headContent
|
|
94798
|
+
}) {
|
|
94622
94799
|
const chatConteiner = chatEl.cloneNode(true);
|
|
94623
94800
|
const images = Array.from(chatConteiner.querySelectorAll("img"));
|
|
94624
94801
|
let imgData;
|
|
@@ -94665,13 +94842,410 @@ code.hljs {
|
|
|
94665
94842
|
console.error(`Failed to fetch or process iframe from ${srcUrl}:`, error);
|
|
94666
94843
|
}
|
|
94667
94844
|
}
|
|
94845
|
+
const functionsToInsert = iFrameSizeListenerFunctions.map((fn) => fn.toString()).join("\n\n");
|
|
94846
|
+
const onIFrameSizeListenerString = onIFrameSizeListener.toString();
|
|
94847
|
+
const copyTextToBufferString = copyTextToBuffer.toString();
|
|
94848
|
+
const outputPhrases = await getOutputLogs({
|
|
94849
|
+
projectId,
|
|
94850
|
+
environment,
|
|
94851
|
+
requestIds
|
|
94852
|
+
});
|
|
94668
94853
|
const alanMainClass = "alan-" + projectId;
|
|
94854
|
+
const code = `
|
|
94855
|
+
<script type="text/javascript">
|
|
94856
|
+
|
|
94857
|
+
${functionsToInsert}
|
|
94858
|
+
${copyTextToBufferString}
|
|
94859
|
+
|
|
94860
|
+
function copyCodeHandler(text){
|
|
94861
|
+
copyTextToBuffer(text);
|
|
94862
|
+
|
|
94863
|
+
copyButton.classList.add('alan-copy-btn-copied');
|
|
94864
|
+
setTimeout(() => {
|
|
94865
|
+
copyButton.classList.remove('alan-copy-btn-copied');
|
|
94866
|
+
}, 2000);
|
|
94867
|
+
}
|
|
94868
|
+
|
|
94869
|
+
|
|
94870
|
+
window.hljs.addPlugin({
|
|
94871
|
+
"after:highlightElement": ({ el, text }) => {
|
|
94872
|
+
const wrapper = el.parentElement;
|
|
94873
|
+
if (wrapper == null) {
|
|
94874
|
+
return;
|
|
94875
|
+
}
|
|
94876
|
+
|
|
94877
|
+
wrapper.classList.add("alan-btn__chat-response__code-wrapper");
|
|
94878
|
+
|
|
94879
|
+
const copyButton = document.createElement("span");
|
|
94880
|
+
copyButton.classList.add(
|
|
94881
|
+
"alan-btn__chat-response__copy-code-btn",
|
|
94882
|
+
);
|
|
94883
|
+
|
|
94884
|
+
const chatIcons = {
|
|
94885
|
+
copy: '<svg class="alan-btn__copy-icon" width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M19.5 16.5L19.5 4.5L18.75 3.75H9L8.25 4.5L8.25 7.5L5.25 7.5L4.5 8.25V20.25L5.25 21H15L15.75 20.25V17.25H18.75L19.5 16.5ZM15.75 15.75L15.75 8.25L15 7.5L9.75 7.5V5.25L18 5.25V15.75H15.75ZM6 9L14.25 9L14.25 19.5L6 19.5L6 9Z" fill="#080341"/></svg>',
|
|
94886
|
+
copied: '<svg class="alan-btn__copied-icon" width="24px" height="24px" viewBox="0 0 24 24" role="img" xmlns="http://www.w3.org/2000/svg" aria-labelledby="okIconTitle" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none" color="#000000"> <title id="okIconTitle">Copied!</title> <polyline points="4 13 9 18 20 7"/> </svg>'
|
|
94887
|
+
};
|
|
94888
|
+
|
|
94889
|
+
copyButton.innerHTML = chatIcons.copy + chatIcons.copied;
|
|
94890
|
+
|
|
94891
|
+
copyButton.onclick = () => {
|
|
94892
|
+
copyCodeHandler(text)
|
|
94893
|
+
};
|
|
94894
|
+
|
|
94895
|
+
wrapper.appendChild(copyButton);
|
|
94896
|
+
},
|
|
94897
|
+
});
|
|
94898
|
+
|
|
94899
|
+
window.addEventListener("message", ${onIFrameSizeListenerString});
|
|
94900
|
+
|
|
94901
|
+
function unescapeHtml(safe) {
|
|
94902
|
+
return safe
|
|
94903
|
+
.replace(/<(?!w)/g, "<")
|
|
94904
|
+
.replace(/(?<!w)>/g, ">")
|
|
94905
|
+
.replace(/&/g, "&")
|
|
94906
|
+
.replace(/"/g, '"')
|
|
94907
|
+
.replace(/'/g, "'");
|
|
94908
|
+
}
|
|
94909
|
+
|
|
94910
|
+
function escapeHtml(unsafe) {
|
|
94911
|
+
return unsafe
|
|
94912
|
+
.replace(/&/g, "&")
|
|
94913
|
+
.replace(/</g, "<")
|
|
94914
|
+
.replace(/>/g, ">")
|
|
94915
|
+
.replace(/"/g, """)
|
|
94916
|
+
.replace(/'/g, "'");
|
|
94917
|
+
}
|
|
94918
|
+
|
|
94919
|
+
var logs = ${JSON.stringify(outputPhrases)};
|
|
94920
|
+
|
|
94921
|
+
logs = logs.map(el => ({
|
|
94922
|
+
...el,
|
|
94923
|
+
context: unescapeHtml(el.context)
|
|
94924
|
+
}));
|
|
94925
|
+
|
|
94926
|
+
var zoomInstance;
|
|
94927
|
+
var xRef, yRef, isDraggingRef;
|
|
94928
|
+
var dragThreshold = 5;
|
|
94929
|
+
var detailsId = null;
|
|
94930
|
+
var detailsMap = {};
|
|
94931
|
+
|
|
94932
|
+
checkMsgLogs();
|
|
94933
|
+
|
|
94934
|
+
function checkMsgLogs() {
|
|
94935
|
+
|
|
94936
|
+
var graphIcons = document.querySelectorAll('.chat-bubble_graph, .alan-btn__chat-graph');
|
|
94937
|
+
|
|
94938
|
+
graphIcons.forEach((child) => {
|
|
94939
|
+
var msgReqId = child.getAttribute('data-request-id');
|
|
94940
|
+
const foundLog = logs.find(l => l.requestId === msgReqId);
|
|
94941
|
+
if (!foundLog || foundLog?.context === '') {
|
|
94942
|
+
child.parentElement.removeChild(child);
|
|
94943
|
+
}
|
|
94944
|
+
});
|
|
94945
|
+
}
|
|
94946
|
+
|
|
94947
|
+
document.addEventListener('mousedown', function onGraphClick(e) {
|
|
94948
|
+
var isOverlayEl = e.target.id === "overlay";
|
|
94949
|
+
|
|
94950
|
+
if (isOverlayEl) {
|
|
94951
|
+
closePopup(e.target.getAttribute('popup-id'));
|
|
94952
|
+
return;
|
|
94953
|
+
}
|
|
94954
|
+
})
|
|
94955
|
+
|
|
94956
|
+
document.addEventListener('click', function onCopyClick(e) {
|
|
94957
|
+
let clickedEl = e.target;
|
|
94958
|
+
clickedEl = clickedEl.closest('.alan-btn__chat-response__copy-code-btn');
|
|
94959
|
+
|
|
94960
|
+
if (clickedEl) {
|
|
94961
|
+
clickedEl.classList.add('alan-copy-btn-copied');
|
|
94962
|
+
setTimeout(() => {
|
|
94963
|
+
clickedEl.classList.remove('alan-copy-btn-copied');
|
|
94964
|
+
}, 2000);
|
|
94965
|
+
|
|
94966
|
+
const codeBlockEl = clickedEl.closest('.alan-btn__chat-response__code-wrapper');
|
|
94967
|
+
if (codeBlockEl) {
|
|
94968
|
+
copyTextToBuffer(codeBlockEl.innerText);
|
|
94969
|
+
}
|
|
94970
|
+
}
|
|
94971
|
+
});
|
|
94972
|
+
|
|
94973
|
+
document.addEventListener('click', function onGraphClick(e) {
|
|
94974
|
+
var graphEl = e.target.closest('.chat-bubble_graph, .alan-btn__chat-graph');
|
|
94975
|
+
if (graphEl) {
|
|
94976
|
+
var phrase = logs.filter(l => l.requestId === graphEl.getAttribute('data-request-id'))[0];
|
|
94977
|
+
|
|
94978
|
+
if (phrase) {
|
|
94979
|
+
var graphData, graph, graphTitle;
|
|
94980
|
+
|
|
94981
|
+
try {
|
|
94982
|
+
graphData = JSON.parse(phrase.context);
|
|
94983
|
+
if (graphData && graphData.opGraph) {
|
|
94984
|
+
graph = graphData.opGraph.dot;
|
|
94985
|
+
graphTitle = graphData.opGraph.title;
|
|
94986
|
+
detailsMap = graphData.opGraph.val;
|
|
94987
|
+
}
|
|
94988
|
+
|
|
94989
|
+
console.info('graphData', graphData)
|
|
94990
|
+
} catch (err) {
|
|
94991
|
+
console.log(err);
|
|
94992
|
+
}
|
|
94993
|
+
|
|
94994
|
+
createPopup('graph-popup','graph', graphTitle );
|
|
94995
|
+
|
|
94996
|
+
renderSvg(graph);
|
|
94997
|
+
}
|
|
94998
|
+
}
|
|
94999
|
+
})
|
|
95000
|
+
|
|
95001
|
+
function createPopup (id, bodyId, title) {
|
|
95002
|
+
var overlay = document.createElement('div');
|
|
95003
|
+
var popup = document.createElement('div');
|
|
95004
|
+
var popupBody = document.createElement('div');
|
|
95005
|
+
var popupTitle = document.createElement('div');
|
|
95006
|
+
var popupCloseBtn = document.createElement('div');
|
|
95007
|
+
popupCloseBtn.innerHTML = '<svg width="20px" height="20px" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="#000000" d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"/></svg>';
|
|
95008
|
+
overlay.id = 'overlay';
|
|
95009
|
+
overlay.setAttribute('popup-id', id)
|
|
95010
|
+
overlay.classList.add('${alanMainClass}');
|
|
95011
|
+
overlay.classList.add('hljs-light-override');
|
|
95012
|
+
popupBody.id = bodyId;
|
|
95013
|
+
if(bodyId === 'details'){
|
|
95014
|
+
popup.classList.add('alan-btn__chat-messages');
|
|
95015
|
+
}
|
|
95016
|
+
|
|
95017
|
+
popup.id = 'popup';
|
|
95018
|
+
popupTitle.id = 'popup-title';
|
|
95019
|
+
popupCloseBtn.id = 'popup-close-btn';
|
|
95020
|
+
|
|
95021
|
+
overlay.appendChild(popup);
|
|
95022
|
+
popup.appendChild(popupTitle);
|
|
95023
|
+
popup.appendChild(popupBody);
|
|
95024
|
+
|
|
95025
|
+
popupTitle.innerText = title;
|
|
95026
|
+
popupTitle.appendChild(popupCloseBtn);
|
|
95027
|
+
|
|
95028
|
+
popupCloseBtn.addEventListener('click', ()=>{closePopup(id)});
|
|
95029
|
+
|
|
95030
|
+
document.body.appendChild(overlay);
|
|
95031
|
+
}
|
|
95032
|
+
|
|
95033
|
+
function cancelEvent(e) {
|
|
95034
|
+
e.stopPropagation();
|
|
95035
|
+
e.preventDefault();
|
|
95036
|
+
}
|
|
95037
|
+
|
|
95038
|
+
const resetSelection = () => {
|
|
95039
|
+
d3.selectAll('#graph .selected').classed('selected', false);
|
|
95040
|
+
}
|
|
95041
|
+
|
|
95042
|
+
const addGraphEvents = () => {
|
|
95043
|
+
const nodes = d3.selectAll('.node,.edge,.w-clicked-elements text');
|
|
95044
|
+
nodes.on("click", function (e) {
|
|
95045
|
+
if (isDraggingRef) {
|
|
95046
|
+
cancelEvent(e);
|
|
95047
|
+
return;
|
|
95048
|
+
}
|
|
95049
|
+
|
|
95050
|
+
cancelEvent(e);
|
|
95051
|
+
resetSelection();
|
|
95052
|
+
const el = this.closest('[id]');
|
|
95053
|
+
|
|
95054
|
+
if (el?.classList?.contains('node')) {
|
|
95055
|
+
const id = el.getAttribute('id');
|
|
95056
|
+
console.info('Id:', id);
|
|
95057
|
+
if (detailsMap[id]) {
|
|
95058
|
+
openDetailsPopup(id);
|
|
95059
|
+
}
|
|
95060
|
+
el.classList.add("selected");
|
|
95061
|
+
} else if (el?.firstChild?.tagName?.toLowerCase() === 'a') {
|
|
95062
|
+
const id = el.getAttribute('id')?.replace('a_', '');
|
|
95063
|
+
console.info('Id:', id);
|
|
95064
|
+
if (detailsMap[id]) {
|
|
95065
|
+
openDetailsPopup(id);
|
|
95066
|
+
}
|
|
95067
|
+
el.classList.add("selected");
|
|
95068
|
+
} else {
|
|
95069
|
+
this.classList.add("selected");
|
|
95070
|
+
}
|
|
95071
|
+
});
|
|
95072
|
+
};
|
|
95073
|
+
|
|
95074
|
+
function closePopup(popupId){
|
|
95075
|
+
var overlayEl = document.querySelector('[popup-id="'+popupId+'"]');
|
|
95076
|
+
if (overlayEl) {
|
|
95077
|
+
overlayEl.remove();
|
|
95078
|
+
}
|
|
95079
|
+
}
|
|
95080
|
+
|
|
95081
|
+
function getSvg(graph, engine) {
|
|
95082
|
+
return new Promise((resolve, reject) => {
|
|
95083
|
+
try {
|
|
95084
|
+
Viz.instance().then(viz => {
|
|
95085
|
+
resolve(viz.renderSVGElement(graph, { engine }));
|
|
95086
|
+
});
|
|
95087
|
+
} catch (error) {
|
|
95088
|
+
console.info(error)
|
|
95089
|
+
reject(error);
|
|
95090
|
+
}
|
|
95091
|
+
});
|
|
95092
|
+
}
|
|
95093
|
+
|
|
95094
|
+
document.addEventListener('click', function (e){
|
|
95095
|
+
const clickedEl = e.target.closest('.mode-btn');
|
|
95096
|
+
if (!clickedEl) return;
|
|
95097
|
+
|
|
95098
|
+
const mode = clickedEl.getAttribute('mode');
|
|
95099
|
+
|
|
95100
|
+
if (!detailsId) return;
|
|
95101
|
+
|
|
95102
|
+
renderDetailsContent(detailsId, mode);
|
|
95103
|
+
});
|
|
95104
|
+
|
|
95105
|
+
function renderDetailsContent(id, mode){
|
|
95106
|
+
var detailsData = detailsMap[id];
|
|
95107
|
+
|
|
95108
|
+
if (!detailsData) return;
|
|
95109
|
+
const detailsEl = document.getElementById('details');
|
|
95110
|
+
|
|
95111
|
+
const elementsWithMode = document.querySelectorAll('[mode]');
|
|
95112
|
+
elementsWithMode.forEach(el => {
|
|
95113
|
+
el.classList.remove('active');
|
|
95114
|
+
});
|
|
95115
|
+
|
|
95116
|
+
const curMode = document.querySelector('[mode="'+mode+'"]');
|
|
95117
|
+
if (curMode) {
|
|
95118
|
+
curMode.classList.add('active');
|
|
95119
|
+
}
|
|
95120
|
+
|
|
95121
|
+
detailsEl.className = '';
|
|
95122
|
+
detailsEl.classList.add('mode-'+mode);
|
|
95123
|
+
|
|
95124
|
+
var codePart = typeof detailsData.value === 'object' && detailsData.value !== null ? JSON.stringify(detailsData.value,null,2): escapeHtml(detailsData.value);
|
|
95125
|
+
var markdownPart = '';
|
|
95126
|
+
|
|
95127
|
+
if (detailsData.type === 'markdown') {
|
|
95128
|
+
markdownPart = alanMarkdown(detailsData.value);
|
|
95129
|
+
}
|
|
95130
|
+
|
|
95131
|
+
if (mode === 'code') {
|
|
95132
|
+
detailsEl.innerHTML = '<div class="details-content">'+codePart+'</div>';
|
|
95133
|
+
}
|
|
95134
|
+
|
|
95135
|
+
if (mode === 'split') {
|
|
95136
|
+
detailsEl.innerHTML = '<div class="details-content">'+codePart+'</div><div class="details-content with-markdown">'+markdownPart+'</div>';
|
|
95137
|
+
}
|
|
95138
|
+
|
|
95139
|
+
if (mode === 'preview') {
|
|
95140
|
+
detailsEl.innerHTML = '<div class="details-content with-markdown">'+markdownPart+'</div>';
|
|
95141
|
+
}
|
|
95142
|
+
|
|
95143
|
+
detailsEl.querySelectorAll('pre code:not(.alan-btn__hljs-processed)').forEach((el) => {
|
|
95144
|
+
window.hljs.highlightElement(el);
|
|
95145
|
+
el.classList.add('alan-btn__hljs-processed');
|
|
95146
|
+
});
|
|
95147
|
+
}
|
|
95148
|
+
|
|
95149
|
+
function openDetailsPopup(id){
|
|
95150
|
+
detailsId = id;
|
|
95151
|
+
var detailsData = detailsMap[id];
|
|
95152
|
+
|
|
95153
|
+
if (!detailsData) return;
|
|
95154
|
+
|
|
95155
|
+
createPopup('details-popup', 'details', detailsData.name);
|
|
95156
|
+
|
|
95157
|
+
if (detailsData.type === 'markdown') {
|
|
95158
|
+
const detailsPopupEl = document.querySelector('[popup-id="details-popup"]');
|
|
95159
|
+
if (detailsPopupEl) {
|
|
95160
|
+
|
|
95161
|
+
const codeSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><g clipPath="url(#clip0_1_30)"><path d="M6.12023 14.2531L0 10.9153V9.06662L6.12023 5.74774V7.91913L1.85555 9.96778L6.12023 12.0937V14.2531Z" fill="#010002" /><path d="M7.16559 15.4212L11.2243 4.5788H12.5066L8.43841 15.4212H7.16559Z" fill="#010002" /><path d="M13.8798 14.2531V12.0937L18.1436 9.98499L13.8798 7.89254V5.74689L20 9.07006V10.9076L13.8798 14.2531Z" fill="#010002" /></g><defs><clipPath id="clip0_1_30"><rect width="20" height="20" fill="white" /></clipPath></defs></svg>';
|
|
95162
|
+
const splitSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.22222 17H4.55556C3.69689 17 3 16.3031 3 15.4444V4.55556C3 3.69611 3.69689 3 4.55556 3H15.4444C16.3039 3 17 3.69611 17 4.55556V15.4444C17 16.3031 16.3039 17 15.4444 17H10.7778V17.0179H9.22222V17ZM9.22222 15.4444V4.55556H4.55556V15.4444H9.22222ZM15.4444 4.55556H10.7778V15.4444H15.4444V4.55556Z" fill="black" /></svg>';
|
|
95163
|
+
const previewSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path fillRule="evenodd" clipRule="evenodd" d="M9.99535 12.9166C11.6062 12.9166 12.912 11.6108 12.912 9.99998C12.912 8.38915 11.6062 7.08331 9.99535 7.08331C8.38452 7.08331 7.07867 8.38915 7.07867 9.99998C7.07867 11.6108 8.38452 12.9166 9.99535 12.9166ZM9.99535 11.2453C9.3076 11.2453 8.75002 10.6877 8.75002 9.99998C8.75002 9.31223 9.3076 8.75465 9.99535 8.75465C10.6831 8.75465 11.2407 9.31223 11.2407 9.99998C11.2407 10.6877 10.6831 11.2453 9.99535 11.2453Z" fill="#0F0F0F" /><path fillRule="evenodd" clipRule="evenodd" d="M10 4.16669C5.99069 4.16669 3.26395 6.3409 1.82445 7.89984C0.714523 9.10185 0.714524 10.8982 1.82445 12.1002C3.26395 13.6592 5.99069 15.8334 10 15.8334C14.0094 15.8334 16.7361 13.6592 18.1756 12.1002C19.2855 10.8982 19.2855 9.10185 18.1756 7.89984C16.7361 6.3409 14.0094 4.16669 10 4.16669ZM3.04893 9.03052C4.32363 7.65004 6.63911 5.83335 10 5.83335C13.3609 5.83335 15.6764 7.65004 16.9511 9.03052C17.4714 9.59402 17.4714 10.406 16.9511 10.9695C15.6764 12.35 13.3609 14.1667 10 14.1667C6.63911 14.1667 4.32363 12.35 3.04893 10.9695C2.52858 10.406 2.52858 9.59402 3.04893 9.03052Z" fill="#0F0F0F" /></svg>';
|
|
95164
|
+
|
|
95165
|
+
const popupHeaderEl = detailsPopupEl.querySelector('#popup-title');
|
|
95166
|
+
const modeSwitcherElement = document.createElement('div');
|
|
95167
|
+
modeSwitcherElement.classList.add('switcher-modes');
|
|
95168
|
+
modeSwitcherElement.innerHTML = '<div class="mode-btn" mode="code">'+codeSvg+'</div><div class="mode-btn" mode="split">'+splitSvg+'</div><div class="mode-btn" mode="preview">'+previewSvg+'</div>';
|
|
95169
|
+
popupHeaderEl.appendChild(modeSwitcherElement);
|
|
95170
|
+
}
|
|
95171
|
+
}
|
|
95172
|
+
|
|
95173
|
+
renderDetailsContent(id, 'code');
|
|
95174
|
+
|
|
95175
|
+
}
|
|
95176
|
+
|
|
95177
|
+
const renderSvg = async (graph) => {
|
|
95178
|
+
|
|
95179
|
+
const graphEl = document.getElementById('graph');
|
|
95180
|
+
|
|
95181
|
+
const height = graphEl.clientHeight || 500;
|
|
95182
|
+
const width = graphEl.clientWidth || 900;
|
|
95183
|
+
|
|
95184
|
+
try {
|
|
95185
|
+
const svgEl = await getSvg(graph, 'dot');
|
|
95186
|
+
svgEl.setAttribute('width', width + 'px');
|
|
95187
|
+
svgEl.setAttribute('height', height + 'px');
|
|
95188
|
+
|
|
95189
|
+
document.getElementById("graph").innerHTML = '';
|
|
95190
|
+
document.getElementById("graph").appendChild(svgEl);
|
|
95191
|
+
|
|
95192
|
+
const svgD3 = d3.select('#graph svg');
|
|
95193
|
+
|
|
95194
|
+
svgD3.on("mousedown", function (event) {
|
|
95195
|
+
xRef = event.clientX;
|
|
95196
|
+
yRef = event.clientY;
|
|
95197
|
+
isDraggingRef = false;
|
|
95198
|
+
});
|
|
95199
|
+
|
|
95200
|
+
svgD3.on("mousemove", function (event) {
|
|
95201
|
+
if (event.buttons === 1) {
|
|
95202
|
+
const dx = event.clientX - xRef;
|
|
95203
|
+
const dy = event.clientY - yRef;
|
|
95204
|
+
if (Math.sqrt(dx * dx + dy * dy) > dragThreshold) {
|
|
95205
|
+
isDraggingRef = true;
|
|
95206
|
+
}
|
|
95207
|
+
}
|
|
95208
|
+
});
|
|
95209
|
+
|
|
95210
|
+
zoomInstance = svgPanZoom(svgEl, {
|
|
95211
|
+
zoomEnabled: true,
|
|
95212
|
+
controlIconsEnabled: true,
|
|
95213
|
+
fit: true,
|
|
95214
|
+
center: true,
|
|
95215
|
+
minZoom: 0.1,
|
|
95216
|
+
maxZoom: 400
|
|
95217
|
+
});
|
|
95218
|
+
|
|
95219
|
+
svgEl.addEventListener('paneresize', function (e) {
|
|
95220
|
+
zoomInstance.resize();
|
|
95221
|
+
}, false);
|
|
95222
|
+
window.addEventListener('resize', function (e) {
|
|
95223
|
+
zoomInstance.resize();
|
|
95224
|
+
});
|
|
95225
|
+
console.timeEnd('render graph');
|
|
95226
|
+
|
|
95227
|
+
addGraphEvents();
|
|
95228
|
+
|
|
95229
|
+
|
|
95230
|
+
} catch (error) {
|
|
95231
|
+
console.info(error)
|
|
95232
|
+
}
|
|
95233
|
+
};
|
|
95234
|
+
<\/script>
|
|
95235
|
+
`;
|
|
94669
95236
|
const newHtmlContent = `
|
|
94670
95237
|
<!DOCTYPE html>
|
|
94671
95238
|
<html lang="en">
|
|
94672
95239
|
<head>
|
|
94673
95240
|
<meta charset="UTF-8">
|
|
94674
95241
|
<title>Alan Text Chat History</title>
|
|
95242
|
+
<link href="${LIBS_PREFIX}/main.css?v=1" rel="stylesheet" />
|
|
95243
|
+
<link href="${LIBS_PREFIX}/highlight.light.css" rel="stylesheet" />
|
|
95244
|
+
<script src="${LIBS_PREFIX}/d3.v7.min.js" type="text/javascript"><\/script>
|
|
95245
|
+
<script src="${LIBS_PREFIX}/viz-standalone.js" type="text/javascript"><\/script>
|
|
95246
|
+
<script src="${LIBS_PREFIX}/svg-pan-zoom.min.js" type="text/javascript"><\/script>
|
|
95247
|
+
<script src="${LIBS_PREFIX}/alan_markdown.js" type="text/javascript"><\/script>
|
|
95248
|
+
<script src="${LIBS_PREFIX}/highlight.min.js?v=2" type="text/javascript"><\/script>
|
|
94675
95249
|
${headContent ? headContent : ""}
|
|
94676
95250
|
<style>
|
|
94677
95251
|
* {
|
|
@@ -94699,6 +95273,9 @@ code.hljs {
|
|
|
94699
95273
|
.alan-btn__history-chat-header > h1 {
|
|
94700
95274
|
padding-left: 10px !important;
|
|
94701
95275
|
color: #000;
|
|
95276
|
+
font-size: 2em;
|
|
95277
|
+
margin-block-start: 0.67em;
|
|
95278
|
+
margin-block-end: 0.67em;
|
|
94702
95279
|
}
|
|
94703
95280
|
.alan-btn__history-chat-header {
|
|
94704
95281
|
margin: 0px auto;
|
|
@@ -94729,6 +95306,143 @@ code.hljs {
|
|
|
94729
95306
|
gap: 20px;
|
|
94730
95307
|
justify-content: flex-end;
|
|
94731
95308
|
}
|
|
95309
|
+
|
|
95310
|
+
.alan-btn__chat-graph {
|
|
95311
|
+
display: flex!important;
|
|
95312
|
+
cursor:pointer;
|
|
95313
|
+
margin-top: 4px;
|
|
95314
|
+
align-items: flex-end;
|
|
95315
|
+
}
|
|
95316
|
+
|
|
95317
|
+
.alan-btn__chat-graph svg {
|
|
95318
|
+
max-width: 16px;
|
|
95319
|
+
}
|
|
95320
|
+
|
|
95321
|
+
#overlay {
|
|
95322
|
+
position: fixed;
|
|
95323
|
+
top: 0;
|
|
95324
|
+
left: 0;
|
|
95325
|
+
width: 100%;
|
|
95326
|
+
height: 100%;
|
|
95327
|
+
background: #0000004d;
|
|
95328
|
+
display: flex;
|
|
95329
|
+
align-items: center;
|
|
95330
|
+
justify-content: center;
|
|
95331
|
+
}
|
|
95332
|
+
|
|
95333
|
+
#popup {
|
|
95334
|
+
height: 90%;
|
|
95335
|
+
width: 90%;
|
|
95336
|
+
border-radius: 8px;
|
|
95337
|
+
background: #fff;
|
|
95338
|
+
color:#000;
|
|
95339
|
+
}
|
|
95340
|
+
|
|
95341
|
+
#popup-title {
|
|
95342
|
+
padding: 0 20px;
|
|
95343
|
+
height: 40px;
|
|
95344
|
+
position:relative;
|
|
95345
|
+
display:flex;
|
|
95346
|
+
align-items: center;
|
|
95347
|
+
justify-content: flex-start;
|
|
95348
|
+
font-weight: bold;
|
|
95349
|
+
font-size: 20px;
|
|
95350
|
+
border-bottom: 1px solid rgba(211, 211, 211, .5);
|
|
95351
|
+
}
|
|
95352
|
+
|
|
95353
|
+
#popup-close-btn {
|
|
95354
|
+
position: absolute;
|
|
95355
|
+
top:10px;
|
|
95356
|
+
right:10px;
|
|
95357
|
+
cursor: pointer;
|
|
95358
|
+
}
|
|
95359
|
+
|
|
95360
|
+
#graph {
|
|
95361
|
+
height:calc(100% - 40px);
|
|
95362
|
+
width: 100%;
|
|
95363
|
+
display: flex;
|
|
95364
|
+
align-items: center;
|
|
95365
|
+
justify-content: center;
|
|
95366
|
+
}
|
|
95367
|
+
|
|
95368
|
+
#graph svg {
|
|
95369
|
+
backface-visibility: hidden;
|
|
95370
|
+
will-change: transform;
|
|
95371
|
+
width: 100%;
|
|
95372
|
+
}
|
|
95373
|
+
|
|
95374
|
+
#graph svg text {
|
|
95375
|
+
font-size: 8.5px;
|
|
95376
|
+
font-family: monospace
|
|
95377
|
+
}
|
|
95378
|
+
|
|
95379
|
+
#details {
|
|
95380
|
+
overflow: auto;
|
|
95381
|
+
height: calc(100% - 40px);
|
|
95382
|
+
font-family: monospace;
|
|
95383
|
+
white-space: pre;
|
|
95384
|
+
}
|
|
95385
|
+
|
|
95386
|
+
.details-content {
|
|
95387
|
+
padding: 20px;
|
|
95388
|
+
overflow: auto;
|
|
95389
|
+
height: 100%;
|
|
95390
|
+
}
|
|
95391
|
+
|
|
95392
|
+
.switcher-modes {
|
|
95393
|
+
position: absolute;
|
|
95394
|
+
right: 40px;
|
|
95395
|
+
display: flex;
|
|
95396
|
+
top: 50%;
|
|
95397
|
+
transform: translateY(-50%);
|
|
95398
|
+
border: 1px solid rgba(0, 121, 232,.5);
|
|
95399
|
+
background-color: rgba(176, 217, 255, 0.15);
|
|
95400
|
+
border-radius: 8px;
|
|
95401
|
+
align-items: center;
|
|
95402
|
+
justify-content: center;
|
|
95403
|
+
}
|
|
95404
|
+
|
|
95405
|
+
.mode-btn {
|
|
95406
|
+
display: flex;
|
|
95407
|
+
align-items: center;
|
|
95408
|
+
justify-content: center;
|
|
95409
|
+
cursor: pointer;
|
|
95410
|
+
padding: 4px;
|
|
95411
|
+
}
|
|
95412
|
+
|
|
95413
|
+
.mode-btn.active {
|
|
95414
|
+
background-color: #b0d9ff73;
|
|
95415
|
+
}
|
|
95416
|
+
|
|
95417
|
+
.mode-btn:first-of-type {
|
|
95418
|
+
border-right: 1px solid rgba(0, 121, 232,.5);
|
|
95419
|
+
}
|
|
95420
|
+
|
|
95421
|
+
.mode-btn:last-of-type {
|
|
95422
|
+
border-left: 1px solid rgba(0, 121, 232,.5);
|
|
95423
|
+
}
|
|
95424
|
+
|
|
95425
|
+
.mode-btn svg path {
|
|
95426
|
+
fill: rgba(0, 121, 232, 1);
|
|
95427
|
+
}
|
|
95428
|
+
|
|
95429
|
+
.mode-btn:hover svg path {
|
|
95430
|
+
fill: #ff8800;
|
|
95431
|
+
}
|
|
95432
|
+
|
|
95433
|
+
.mode-split {
|
|
95434
|
+
display: flex;
|
|
95435
|
+
justify-content: center;
|
|
95436
|
+
}
|
|
95437
|
+
|
|
95438
|
+
.mode-split > div {
|
|
95439
|
+
width: 50%;
|
|
95440
|
+
min-width: 50%;
|
|
95441
|
+
max-width: 50%;
|
|
95442
|
+
}
|
|
95443
|
+
.mode-split > div:first-of-type {
|
|
95444
|
+
border-right: 1px solid rgba(211, 211, 211, .5);
|
|
95445
|
+
}
|
|
94732
95446
|
</style>
|
|
94733
95447
|
</head>
|
|
94734
95448
|
<body class="alan-btn__history-body">
|
|
@@ -94824,7 +95538,7 @@ code.hljs {
|
|
|
94824
95538
|
${chatConteiner.outerHTML}
|
|
94825
95539
|
</div>
|
|
94826
95540
|
</div>
|
|
94827
|
-
${
|
|
95541
|
+
${code}
|
|
94828
95542
|
</body>
|
|
94829
95543
|
</html>
|
|
94830
95544
|
`;
|
|
@@ -94877,6 +95591,33 @@ code.hljs {
|
|
|
94877
95591
|
reader.readAsDataURL(blob);
|
|
94878
95592
|
});
|
|
94879
95593
|
}
|
|
95594
|
+
async function getOutputLogs(param) {
|
|
95595
|
+
return new Promise((resolve, reject) => {
|
|
95596
|
+
if (!window.tutorProject)
|
|
95597
|
+
reject();
|
|
95598
|
+
window.tutorProject.call("getMessageGraphs", param, function(e, res) {
|
|
95599
|
+
if (e) {
|
|
95600
|
+
reject({ error: e });
|
|
95601
|
+
} else if (res && res.error) {
|
|
95602
|
+
reject({ ...res });
|
|
95603
|
+
} else {
|
|
95604
|
+
if (res.graphs) {
|
|
95605
|
+
resolve(
|
|
95606
|
+
res.graphs.map((el) => ({
|
|
95607
|
+
...el,
|
|
95608
|
+
context: escapeHtmlForGraph(el?.context || "")
|
|
95609
|
+
}))
|
|
95610
|
+
);
|
|
95611
|
+
} else {
|
|
95612
|
+
reject();
|
|
95613
|
+
}
|
|
95614
|
+
}
|
|
95615
|
+
});
|
|
95616
|
+
});
|
|
95617
|
+
}
|
|
95618
|
+
function escapeHtmlForGraph(unsafe) {
|
|
95619
|
+
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
95620
|
+
}
|
|
94880
95621
|
async function inlineExternalScripts(htmlContent) {
|
|
94881
95622
|
const parser = new DOMParser();
|
|
94882
95623
|
const doc = parser.parseFromString(htmlContent, "text/html");
|
|
@@ -95045,8 +95786,33 @@ code.hljs {
|
|
|
95045
95786
|
|
|
95046
95787
|
// alan_btn/alan_btn.ts
|
|
95047
95788
|
var import_sjcl = __toESM(require_sjcl());
|
|
95789
|
+
|
|
95790
|
+
// alan_btn/src/textChat/chatSuggestions.ts
|
|
95791
|
+
function renderSuggestions(suggestions) {
|
|
95792
|
+
return `<div class="alan-btn__chat-suggestions">
|
|
95793
|
+
${suggestions?.map((suggestion) => {
|
|
95794
|
+
const { textToAsk, label } = getSuggestionMetadata(suggestion);
|
|
95795
|
+
return `<div class="alan-chat__suggestion" data-alan-button-send-text="${textToAsk}">${label}</div>`;
|
|
95796
|
+
}).join("") || ""}</div>`;
|
|
95797
|
+
}
|
|
95798
|
+
function getSuggestionMetadata(suggestion) {
|
|
95799
|
+
const { text, markdown } = suggestion;
|
|
95800
|
+
let label = "";
|
|
95801
|
+
if (markdown) {
|
|
95802
|
+
label = alanMarkdown(markdown || "");
|
|
95803
|
+
} else {
|
|
95804
|
+
label = text || "";
|
|
95805
|
+
}
|
|
95806
|
+
const textToAsk = (text || label?.replace(/<\/?[^>]+(>|$)/g, "")).replace(/\n/g, " ").trim();
|
|
95807
|
+
return {
|
|
95808
|
+
textToAsk,
|
|
95809
|
+
label
|
|
95810
|
+
};
|
|
95811
|
+
}
|
|
95812
|
+
|
|
95813
|
+
// alan_btn/alan_btn.ts
|
|
95048
95814
|
(function(ns) {
|
|
95049
|
-
uiState.lib.version = "alan-version.1.8.
|
|
95815
|
+
uiState.lib.version = "alan-version.1.8.88".replace("alan-version.", "");
|
|
95050
95816
|
if (window.alanBtn) {
|
|
95051
95817
|
console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")");
|
|
95052
95818
|
}
|
|
@@ -97351,8 +98117,14 @@ ${curDialogId}`);
|
|
|
97351
98117
|
}
|
|
97352
98118
|
return result ? `<span class="alan-btn__chat-response-text-wrapper">${fixTargetForLinks(result)}</span>` : "";
|
|
97353
98119
|
}
|
|
98120
|
+
function addGraphIcon(msg) {
|
|
98121
|
+
if (msg.type === "response" /* Response */) {
|
|
98122
|
+
return `<span class='alan-btn__chat-graph' data-request-id="${getMsgReqId(msg)}">${chatIcons.graph}</span>`;
|
|
98123
|
+
}
|
|
98124
|
+
return "";
|
|
98125
|
+
}
|
|
97354
98126
|
function buildMsgContent(msg) {
|
|
97355
|
-
return `${buildImagesContent(msg)}${buildMsgTextContent(msg)}${buildLinksContent(msg)}${buildCommandsBlock(msg, uiState?.textChat?.options)}${buildMsgIncommingLoader(msg)}`;
|
|
98127
|
+
return `${buildImagesContent(msg)}${buildMsgTextContent(msg)}${buildLinksContent(msg)}${buildCommandsBlock(msg, uiState?.textChat?.options)}${buildMsgIncommingLoader(msg)}${addGraphIcon(msg)}`;
|
|
97356
98128
|
}
|
|
97357
98129
|
initMathJax(textChatMessages.length, (i2) => getMsgElForMathJax(i2));
|
|
97358
98130
|
document.addEventListener("click", (e) => {
|
|
@@ -97398,7 +98170,10 @@ ${LEARN_MORE_LABEL}
|
|
|
97398
98170
|
}, false);
|
|
97399
98171
|
window.addEventListener("click", (e) => {
|
|
97400
98172
|
var clickedEl = e.target;
|
|
97401
|
-
processClickByButtonInChat(clickedEl, btnInstance,
|
|
98173
|
+
processClickByButtonInChat(clickedEl, btnInstance, (text) => {
|
|
98174
|
+
textChatScrollPosition = null;
|
|
98175
|
+
_sendText(text);
|
|
98176
|
+
});
|
|
97402
98177
|
});
|
|
97403
98178
|
function getMsgBubbleLabel(msg) {
|
|
97404
98179
|
if (msg.type === "request" || msg.type === "response") {
|
|
@@ -97438,6 +98213,7 @@ ${LEARN_MORE_LABEL}
|
|
|
97438
98213
|
if (window.fakeMsg) {
|
|
97439
98214
|
msg.text = window.fakeMsg?.text || msg.text;
|
|
97440
98215
|
msg.images = window.fakeMsg?.images || msg.images;
|
|
98216
|
+
msg.suggestions = window.fakeMsg?.suggestions || msg.suggestions;
|
|
97441
98217
|
msg.links = window.fakeMsg?.links || msg.links;
|
|
97442
98218
|
if (window.fakeMsg?.text) {
|
|
97443
98219
|
if (msg.ctx) {
|
|
@@ -97471,7 +98247,11 @@ ${LEARN_MORE_LABEL}
|
|
|
97471
98247
|
} else {
|
|
97472
98248
|
innerMsgPart = buildMsgContent(msg);
|
|
97473
98249
|
}
|
|
97474
|
-
|
|
98250
|
+
let suggestionsHtml = "";
|
|
98251
|
+
if (msg?.suggestions?.length > 0) {
|
|
98252
|
+
suggestionsHtml += renderSuggestions(msg.suggestions);
|
|
98253
|
+
}
|
|
98254
|
+
msgHtml = `<div class="alan-btn__chat-inner-msg ${msg.type === "request" ? "alan-btn__chat-request" : "alan-btn__chat-response"} ${msg.images?.length > 0 ? "with-images" : ""} ${isMsgContainsTable(innerMsgPart) ? "with-table" : ""} ${isMsgContainsIFrame(innerMsgPart) ? "with-iframe" : ""}">${innerMsgPart}</div>${suggestionsHtml}`;
|
|
97475
98255
|
}
|
|
97476
98256
|
if (msg.name === "loading") {
|
|
97477
98257
|
const loaderId = `loading-msg-${guid()}`;
|
|
@@ -97489,6 +98269,7 @@ ${LEARN_MORE_LABEL}
|
|
|
97489
98269
|
if (isNew) {
|
|
97490
98270
|
var div = document.createElement("div");
|
|
97491
98271
|
div.id = "msg-" + msgInd;
|
|
98272
|
+
div.setAttribute("data-request-id", getMsgReqId(msg));
|
|
97492
98273
|
div.classList.add("alan-btn__chat-msg-holder");
|
|
97493
98274
|
div.setAttribute("data-msg-index", msgInd);
|
|
97494
98275
|
if (msg.type === "chat") {
|
|
@@ -97498,7 +98279,12 @@ ${LEARN_MORE_LABEL}
|
|
|
97498
98279
|
if (msg.type === "connection-separator") {
|
|
97499
98280
|
div.innerHTML = msgHtml;
|
|
97500
98281
|
} else {
|
|
97501
|
-
div.innerHTML =
|
|
98282
|
+
div.innerHTML = `
|
|
98283
|
+
${msg.name !== "loading" ? getMsgBubbleLabel(msg) : ""}
|
|
98284
|
+
<div class="alan-btn__chat-bubble-holder">
|
|
98285
|
+
${msg.type === "chat" || msg.type === "buttons" ? "" : avatarHtml}
|
|
98286
|
+
<div class="supper1">${msgHtml}</div>
|
|
98287
|
+
</div>`;
|
|
97502
98288
|
}
|
|
97503
98289
|
msgHolder.appendChild(div);
|
|
97504
98290
|
if (uiState.textChat.available && textChatIsHidden && msg.type === "response" && msg.read !== true) {
|
|
@@ -97525,7 +98311,10 @@ ${LEARN_MORE_LABEL}
|
|
|
97525
98311
|
innerEl.innerHTML = innerMsgPart;
|
|
97526
98312
|
innerEl.classList.remove("alan-incoming-msg");
|
|
97527
98313
|
innerEl.id = "";
|
|
97528
|
-
innerEl.
|
|
98314
|
+
const chatHolder = innerEl.closest(".alan-btn__chat-bubble-holder");
|
|
98315
|
+
if (chatHolder) {
|
|
98316
|
+
chatHolder.insertAdjacentHTML("beforebegin", getMsgBubbleLabel(msg));
|
|
98317
|
+
}
|
|
97529
98318
|
if (msg.type === "response" && msg.images?.length > 0) {
|
|
97530
98319
|
innerEl.classList.add("with-images");
|
|
97531
98320
|
}
|
|
@@ -97564,6 +98353,13 @@ ${LEARN_MORE_LABEL}
|
|
|
97564
98353
|
innerEl.insertAdjacentHTML("beforeend", buildLinksContent(updatedMsg));
|
|
97565
98354
|
innerEl.insertAdjacentHTML("beforeend", buildCommandsBlock(msg, uiState?.textChat?.options));
|
|
97566
98355
|
innerEl.insertAdjacentHTML("beforeend", buildMsgIncommingLoader(msg));
|
|
98356
|
+
const newSuggestions = msg?.suggestions;
|
|
98357
|
+
if (newSuggestions?.length > 0) {
|
|
98358
|
+
if (innerEl.nextElementSibling?.classList.contains("alan-btn__chat-suggestions")) {
|
|
98359
|
+
innerEl.nextElementSibling.remove();
|
|
98360
|
+
}
|
|
98361
|
+
innerEl.insertAdjacentHTML("afterend", renderSuggestions(updatedMsg.suggestions));
|
|
98362
|
+
}
|
|
97567
98363
|
if (isMsgContainsTable(innerEl?.innerHTML)) {
|
|
97568
98364
|
innerEl.classList.add("with-table");
|
|
97569
98365
|
}
|
|
@@ -98185,7 +98981,9 @@ ${LEARN_MORE_LABEL}
|
|
|
98185
98981
|
rightHeaderIconsHolder.appendChild(saveChatStateBtnImg);
|
|
98186
98982
|
rightHeaderIconsHolder.appendChild(expandCollapseChatBtnImg);
|
|
98187
98983
|
saveChatStateBtnImg.addEventListener("click", async () => {
|
|
98188
|
-
const
|
|
98984
|
+
const customHeadContent = `
|
|
98985
|
+
${document.head.innerHTML}
|
|
98986
|
+
`;
|
|
98189
98987
|
const initChat = document.querySelector("#chatMessagesWrapper");
|
|
98190
98988
|
if (!initChat)
|
|
98191
98989
|
return;
|
|
@@ -98197,7 +98995,15 @@ ${LEARN_MORE_LABEL}
|
|
|
98197
98995
|
saveChatStateBtnImg.classList.remove("saving");
|
|
98198
98996
|
}, 8e3);
|
|
98199
98997
|
try {
|
|
98200
|
-
await saveChatState(
|
|
98998
|
+
await saveChatState({
|
|
98999
|
+
chatName: title,
|
|
99000
|
+
chatEl: initChat,
|
|
99001
|
+
width: chatWidth2,
|
|
99002
|
+
projectId: getProjectId(),
|
|
99003
|
+
environment: getEnvironment(),
|
|
99004
|
+
requestIds: textChatMessages?.length > 0 ? textChatMessages.filter((m) => m.type === "response" /* Response */).map((m) => getMsgReqId(m)) : [],
|
|
99005
|
+
headContent: customHeadContent
|
|
99006
|
+
});
|
|
98201
99007
|
saveChatStateBtnImg.classList.remove("saving");
|
|
98202
99008
|
} catch (error) {
|
|
98203
99009
|
saveChatStateBtnImg.classList.remove("saving");
|