@alan-ai/alan-sdk-web 1.8.61 → 1.8.63
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 +397 -153
- package/dist/alan_lib.min.js +1 -1
- package/package.json +1 -1
- package/dist/.DS_Store +0 -0
package/dist/alan_lib.js
CHANGED
|
@@ -83982,7 +83982,7 @@
|
|
|
83982
83982
|
expanded: false,
|
|
83983
83983
|
inlined: false,
|
|
83984
83984
|
options: null,
|
|
83985
|
-
loaderTimeoutMs:
|
|
83985
|
+
loaderTimeoutMs: 6e4,
|
|
83986
83986
|
defaults: {
|
|
83987
83987
|
minChatWidth: 250,
|
|
83988
83988
|
appearAnimationMs: 200,
|
|
@@ -84037,6 +84037,9 @@
|
|
|
84037
84037
|
messages[i].ctx = { format: "markdown" };
|
|
84038
84038
|
}
|
|
84039
84039
|
}
|
|
84040
|
+
if (message.ctx?.final === true) {
|
|
84041
|
+
messages[i].ctx.final = message.ctx?.final;
|
|
84042
|
+
}
|
|
84040
84043
|
}
|
|
84041
84044
|
|
|
84042
84045
|
// alan_btn/src/textChat/helpers/processMessageForChat.ts
|
|
@@ -84271,7 +84274,12 @@
|
|
|
84271
84274
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.29492 14.9898C6.88071 14.9898 6.54492 14.654 6.54492 14.2398V12.7003C6.54492 12.5898 6.45538 12.5003 6.34492 12.5003L4.77346 12.5003C4.35925 12.5003 4.02346 12.1645 4.02346 11.7503C4.02346 11.3361 4.35924 11.0003 4.77345 11.0003L6.79491 11.0003C7.48527 11.0003 8.04492 11.5599 8.04492 12.2503V14.2398C8.04492 14.654 7.70914 14.9898 7.29492 14.9898Z" fill="#969EB0"/>
|
|
84272
84275
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.7285 5.01044C13.1427 5.01044 13.4785 5.34622 13.4785 5.76044V7.29998C13.4785 7.41044 13.5681 7.49998 13.6785 7.49998L15.25 7.49997C15.6642 7.49997 16 7.83576 16 8.24997C16 8.66418 15.6642 8.99997 15.25 8.99997L13.2285 8.99999C12.5382 8.99999 11.9785 8.44035 11.9785 7.74999V5.76044C11.9785 5.34622 12.3143 5.01044 12.7285 5.01044Z" fill="#969EB0"/>
|
|
84273
84276
|
</svg>
|
|
84274
|
-
|
|
84277
|
+
`,
|
|
84278
|
+
saveChatState: `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
84279
|
+
<path d="M2.375 12.875C2.375 15.1141 2.375 16.2337 3.07062 16.9294C3.76624 17.625 4.88583 17.625 7.125 17.625H11.875C14.1142 17.625 15.2337 17.625 15.9294 16.9294C16.625 16.2337 16.625 15.1141 16.625 12.875" stroke="#1C274C" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
84280
|
+
<path d="M9.50001 3.375V13.6667M9.50001 13.6667L12.6667 10.2031M9.50001 13.6667L6.33334 10.2031" stroke="#1C274C" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
84281
|
+
</svg>
|
|
84282
|
+
`
|
|
84275
84283
|
};
|
|
84276
84284
|
function getCloseChatIcon(textChatOptions) {
|
|
84277
84285
|
return textChatOptions?.popup?.icons?.close?.svg || chatIcons.closeChat;
|
|
@@ -84282,6 +84290,9 @@
|
|
|
84282
84290
|
function getCollapseChatIcon(textChatOptions) {
|
|
84283
84291
|
return textChatOptions?.popup?.icons?.fullScreen?.svgCollapse || chatIcons.collapseChat;
|
|
84284
84292
|
}
|
|
84293
|
+
function getSaveChatStateIcon(textChatOptions) {
|
|
84294
|
+
return textChatOptions?.popup?.icons?.saveChatState?.svg || chatIcons.saveChatState;
|
|
84295
|
+
}
|
|
84285
84296
|
function getSendChatIcon(textChatOptions) {
|
|
84286
84297
|
return textChatOptions?.popup?.icons?.send?.svg || chatIcons.send;
|
|
84287
84298
|
}
|
|
@@ -85181,7 +85192,7 @@
|
|
|
85181
85192
|
if (chatGradientType === "custom" && chatCustomBg) {
|
|
85182
85193
|
chatBackgroud = chatCustomBg;
|
|
85183
85194
|
}
|
|
85184
|
-
keyFrames += getStyleSheetMarker() + `.alan-btn__popup-chat {
|
|
85195
|
+
keyFrames += getStyleSheetMarker() + `.alan-btn__popup-chat, ${getStyleSheetMarker() + `.alan-btn__history-chat`} {
|
|
85185
85196
|
height: 100%;
|
|
85186
85197
|
position: relative;
|
|
85187
85198
|
overflow: hidden;
|
|
@@ -85222,12 +85233,22 @@
|
|
|
85222
85233
|
gap: 8px;
|
|
85223
85234
|
position: relative;
|
|
85224
85235
|
}`;
|
|
85236
|
+
const defaultTextareaBorderRadius = 20;
|
|
85237
|
+
const topRightBorderRadius = textChatOptions?.textarea?.borderRadius?.topRight || defaultTextareaBorderRadius;
|
|
85238
|
+
const bottomRightBorderRadius = textChatOptions?.textarea?.borderRadius?.bottomRight || defaultTextareaBorderRadius;
|
|
85239
|
+
const calculatedTextareaRightPadding = Math.max(Math.max(topRightBorderRadius, bottomRightBorderRadius), textareaRightPadding);
|
|
85225
85240
|
keyFrames += getStyleSheetMarker() + `.alan-btn__chat-textarea-inner-holder {
|
|
85226
85241
|
width: 100%;
|
|
85227
85242
|
height: 100%;
|
|
85228
85243
|
position: relative;
|
|
85229
85244
|
display: flex;
|
|
85230
85245
|
align-items: center;
|
|
85246
|
+
overflow: hidden;
|
|
85247
|
+
border-radius: ${textChatOptions?.textarea?.borderRadius?.topLeft || defaultTextareaBorderRadius}px ${topRightBorderRadius}px ${bottomRightBorderRadius}px ${textChatOptions?.textarea?.borderRadius?.bottomLeft || defaultTextareaBorderRadius}px;
|
|
85248
|
+
border: 1px solid ${textChatOptions?.textarea?.borderColor || textChatOptions?.textarea?.backgroundColor || `transparent`};
|
|
85249
|
+
box-shadow: ${textChatOptions?.textarea?.hasShadow === false ? "none" : `0px 1px 3px rgba(16, 39, 126, 0.2)`};
|
|
85250
|
+
background-color: ${textChatOptions?.textarea?.backgroundColor || `#ffffff`} ;
|
|
85251
|
+
padding: ${getPaddingProp(0, calculatedTextareaRightPadding, 0, 0)};
|
|
85231
85252
|
}`;
|
|
85232
85253
|
keyFrames += getStyleSheetMarker() + `.alan-btn__chat-messages-empty-block {
|
|
85233
85254
|
flex: 1 1 auto;
|
|
@@ -85481,6 +85502,23 @@
|
|
|
85481
85502
|
fill: ${textChatOptions?.popup?.icons?.close?.hover?.fill || `#97989c`};
|
|
85482
85503
|
}`;
|
|
85483
85504
|
}
|
|
85505
|
+
keyFrames += getStyleSheetMarker() + `.alan-btn__save-chat-state-btn {
|
|
85506
|
+
height: 100%;
|
|
85507
|
+
display: ${textChatOptions?.popup?.saveChatState?.enabled ? "flex" : `none`};
|
|
85508
|
+
align-items: center;
|
|
85509
|
+
cursor: pointer;
|
|
85510
|
+
pointer-events: all;
|
|
85511
|
+
}`;
|
|
85512
|
+
keyFrames += getStyleSheetMarker() + `.alan-btn__save-chat-state-btn-disabled {
|
|
85513
|
+
opacity: 0.5;
|
|
85514
|
+
pointer-events: none;
|
|
85515
|
+
}`;
|
|
85516
|
+
keyFrames += getStyleSheetMarker() + `.alan-btn__save-chat-state-btn svg path {
|
|
85517
|
+
stroke: ${textChatOptions?.popup?.icons?.saveChatState?.default?.fill || `#969EB0`};
|
|
85518
|
+
}`;
|
|
85519
|
+
keyFrames += getStyleSheetMarker() + `.alan-btn__save-chat-state-btn:hover svg path {
|
|
85520
|
+
stroke: ${textChatOptions?.popup?.icons?.saveChatState?.hover?.fill || `#0046ff`};
|
|
85521
|
+
}`;
|
|
85484
85522
|
keyFrames += getStyleSheetMarker() + `.alan-btn__expand-collapse-chat-btn {
|
|
85485
85523
|
height: 100%;
|
|
85486
85524
|
display: ${textChatOptions?.popup?.fullScreenMode?.enabled ? "flex" : `none`};
|
|
@@ -85553,22 +85591,19 @@
|
|
|
85553
85591
|
display: ${withGradientForFooter ? "block" : "none"};
|
|
85554
85592
|
left:0;
|
|
85555
85593
|
}`;
|
|
85556
|
-
const defaultTextareaBorderRadius = 20;
|
|
85557
85594
|
keyFrames += getStyleSheetMarker() + `.alan-btn__chat-textarea {
|
|
85558
85595
|
width: 100%;
|
|
85559
|
-
border-radius: ${textChatOptions?.textarea?.borderRadius?.topLeft || defaultTextareaBorderRadius}px ${textChatOptions?.textarea?.borderRadius?.topRight || defaultTextareaBorderRadius}px ${textChatOptions?.textarea?.borderRadius?.bottomRight || defaultTextareaBorderRadius}px ${textChatOptions?.textarea?.borderRadius?.bottomLeft || defaultTextareaBorderRadius}px;
|
|
85560
|
-
border: 1px solid ${textChatOptions?.textarea?.borderColor || textChatOptions?.textarea?.backgroundColor || `transparent`};
|
|
85561
|
-
box-shadow: ${textChatOptions?.textarea?.hasShadow === false ? "none" : `0px 1px 3px rgba(16, 39, 126, 0.2)`};
|
|
85562
|
-
background-color: ${textChatOptions?.textarea?.backgroundColor || `#ffffff`} ;
|
|
85563
85596
|
color: ${textChatOptions?.textarea?.color || `#171717`} ;
|
|
85564
85597
|
overflow: hidden;
|
|
85565
85598
|
outline: none;
|
|
85566
85599
|
resize: none;
|
|
85600
|
+
background: transparent;
|
|
85601
|
+
border: none;
|
|
85567
85602
|
-webkit-appearance: none;
|
|
85568
85603
|
font-size: ${getTextAreaFontSize(isMobile(), textChatOptions?.textarea?.fontSize || defaultChatTextareaFontSize)}px;
|
|
85569
85604
|
line-height: ${chatTextareaLineHieght};
|
|
85570
85605
|
text-align: left;
|
|
85571
|
-
padding: ${getPaddingProp(textareaTopPadding,
|
|
85606
|
+
padding: ${getPaddingProp(textareaTopPadding, 0, textareaBottomPadding, textareaLeftPadding)};
|
|
85572
85607
|
margin: 0px!important;
|
|
85573
85608
|
-webkit-user-select: text;
|
|
85574
85609
|
-khtml-user-select: text;
|
|
@@ -85728,8 +85763,14 @@
|
|
|
85728
85763
|
}`;
|
|
85729
85764
|
keyFrames += getStyleSheetMarker() + `.multi-line .alan-btn__chat-mic-btn {
|
|
85730
85765
|
align-items: flex-end;
|
|
85766
|
+
transform-origin: bottom;
|
|
85731
85767
|
padding-bottom: ${textareaBottomPadding}px;
|
|
85732
85768
|
}`;
|
|
85769
|
+
const micActiveBottomPadding = +textareaBottomPadding - 2 >= 0 ? +textareaBottomPadding - 2 : 0;
|
|
85770
|
+
keyFrames += getStyleSheetMarker() + `.multi-line .alan-btn__chat-mic-btn.active {
|
|
85771
|
+
align-items: flex-end;
|
|
85772
|
+
padding-bottom: ${micActiveBottomPadding}px;
|
|
85773
|
+
}`;
|
|
85733
85774
|
keyFrames += getStyleSheetMarker() + `.alan-btn__chat-notifications-bubble {
|
|
85734
85775
|
position: absolute;
|
|
85735
85776
|
right: 4px;
|
|
@@ -86366,102 +86407,86 @@
|
|
|
86366
86407
|
const hasCopyBtn = textChatOptions?.bubbles?.response?.copyBtn;
|
|
86367
86408
|
const commandsBlockIsVisible = hasLikeBtn || hasCopyBtn;
|
|
86368
86409
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response-commands-wrapper {
|
|
86369
|
-
margin-top: 10px;
|
|
86370
86410
|
display: ${commandsBlockIsVisible ? "block" : "none"};
|
|
86371
|
-
|
|
86372
|
-
|
|
86373
|
-
|
|
86374
|
-
|
|
86411
|
+
line-height: 0;
|
|
86412
|
+
}`;
|
|
86413
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-response-commands-wrapper-hidden {
|
|
86414
|
+
display: none;
|
|
86375
86415
|
}`;
|
|
86376
86416
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response-commands-wrapper-content {
|
|
86377
86417
|
${commandsBlockIsVisible ? `
|
|
86378
86418
|
position:relative;
|
|
86379
|
-
margin-top:
|
|
86419
|
+
margin-top: 4px;
|
|
86380
86420
|
display: inline-flex;
|
|
86421
|
+
gap: 2px;
|
|
86381
86422
|
|
|
86382
86423
|
` : ""}
|
|
86383
86424
|
}`;
|
|
86384
|
-
|
|
86385
|
-
|
|
86386
|
-
|
|
86387
|
-
|
|
86388
|
-
position: absolute;
|
|
86389
|
-
border-radius: 6px;
|
|
86390
|
-
border: 1px solid #D2DAE5;
|
|
86391
|
-
display: block;
|
|
86392
|
-
width: 100%;
|
|
86393
|
-
height: 100%;
|
|
86394
|
-
top: -1px;
|
|
86395
|
-
left: -1px;
|
|
86396
|
-
pointer-events: none;
|
|
86397
|
-
|
|
86398
|
-
` : ""}
|
|
86399
|
-
}`;
|
|
86425
|
+
var copyBtnWidth = 20;
|
|
86426
|
+
var copyBtnHeight = 24;
|
|
86427
|
+
var likeDislikeBtnWidth = 18;
|
|
86428
|
+
var likeDislikeBtnHeight = 24;
|
|
86400
86429
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__like-btn {
|
|
86401
|
-
opacity: 0.5;
|
|
86402
86430
|
display: ${textChatOptions?.bubbles?.response?.likeBtn ? "flex" : `none`};
|
|
86403
86431
|
${textChatOptions?.bubbles?.response?.likeBtn ? `
|
|
86404
|
-
padding: 4px;
|
|
86405
86432
|
align-items: center;
|
|
86406
86433
|
border-radius: 5px;
|
|
86407
86434
|
cursor: pointer;
|
|
86408
|
-
width
|
|
86409
|
-
min-width
|
|
86410
|
-
height
|
|
86411
|
-
min-height
|
|
86435
|
+
width:${likeDislikeBtnWidth}px;
|
|
86436
|
+
min-width:${likeDislikeBtnWidth}px;
|
|
86437
|
+
height:${likeDislikeBtnHeight}px;
|
|
86438
|
+
min-height:${likeDislikeBtnHeight}px;
|
|
86412
86439
|
` : ``};
|
|
86413
86440
|
|
|
86414
86441
|
}`;
|
|
86415
86442
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__dislike-btn {
|
|
86416
|
-
opacity: 0.5;
|
|
86417
86443
|
display: ${textChatOptions?.bubbles?.response?.likeBtn ? "flex" : `none`};
|
|
86418
86444
|
${textChatOptions?.bubbles?.response?.likeBtn ? `
|
|
86419
|
-
padding: 4px;
|
|
86420
86445
|
align-items: center;
|
|
86421
86446
|
border-radius: 5px;
|
|
86422
86447
|
cursor: pointer;
|
|
86423
|
-
width
|
|
86424
|
-
min-width
|
|
86425
|
-
height
|
|
86426
|
-
min-height
|
|
86448
|
+
width:${likeDislikeBtnWidth}px;
|
|
86449
|
+
min-width:${likeDislikeBtnWidth}px;
|
|
86450
|
+
height:${likeDislikeBtnHeight}px;
|
|
86451
|
+
min-height:${likeDislikeBtnHeight}px;
|
|
86427
86452
|
` : ``};
|
|
86428
86453
|
}`;
|
|
86429
86454
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-btn {
|
|
86430
|
-
opacity: 0.5;
|
|
86431
86455
|
display: ${textChatOptions?.bubbles?.response?.copyBtn ? "inline-flex" : `none`};
|
|
86432
86456
|
${textChatOptions?.bubbles?.response?.copyBtn ? `
|
|
86433
|
-
padding: 4px;
|
|
86434
86457
|
align-items: center;
|
|
86435
86458
|
border-radius: 5px;
|
|
86436
86459
|
cursor: pointer;
|
|
86437
|
-
width
|
|
86438
|
-
min-width
|
|
86439
|
-
height
|
|
86440
|
-
min-height
|
|
86460
|
+
width:${copyBtnWidth}px;
|
|
86461
|
+
min-width:${copyBtnWidth}px;
|
|
86462
|
+
height:${copyBtnHeight}px;
|
|
86463
|
+
min-height:${copyBtnHeight}px;
|
|
86441
86464
|
` : ``};
|
|
86442
86465
|
}`;
|
|
86466
|
+
const bottomBtnsBgColor = textChatOptions?.bubbles?.response?.bottomBtns?.backgroundColor?.hover || `#dcddde`;
|
|
86467
|
+
const bottomBtnsColor = textChatOptions?.bubbles?.response?.bottomBtns?.color || "#17171780";
|
|
86443
86468
|
if (!isMobile()) {
|
|
86444
86469
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-btn:hover {
|
|
86445
|
-
background-color
|
|
86470
|
+
background-color:${bottomBtnsBgColor}!important;
|
|
86446
86471
|
}`;
|
|
86447
86472
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__like-btn:hover {
|
|
86448
|
-
background-color
|
|
86473
|
+
background-color:${bottomBtnsBgColor}!important;
|
|
86449
86474
|
}`;
|
|
86450
86475
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__dislike-btn:hover {
|
|
86451
|
-
background-color
|
|
86476
|
+
background-color:${bottomBtnsBgColor}!important;
|
|
86452
86477
|
}`;
|
|
86453
86478
|
}
|
|
86454
86479
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-btn svg {
|
|
86455
86480
|
width: 20px;
|
|
86456
86481
|
}`;
|
|
86457
86482
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-btn svg path {
|
|
86458
|
-
fill: ${
|
|
86483
|
+
fill: ${bottomBtnsColor};
|
|
86459
86484
|
}`;
|
|
86460
86485
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__like-btn svg path {
|
|
86461
|
-
fill: ${
|
|
86486
|
+
fill: ${bottomBtnsColor};
|
|
86462
86487
|
}`;
|
|
86463
86488
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__dislike-btn svg path {
|
|
86464
|
-
fill: ${
|
|
86489
|
+
fill: ${bottomBtnsColor};
|
|
86465
86490
|
}`;
|
|
86466
86491
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-btn alan-btn__copy-icon {
|
|
86467
86492
|
width: 22px;
|
|
@@ -86476,8 +86501,51 @@
|
|
|
86476
86501
|
display: inline-block;
|
|
86477
86502
|
}`;
|
|
86478
86503
|
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-btn.alan-copy-btn-copied .alan-btn__copied-icon {
|
|
86479
|
-
stroke: ${
|
|
86504
|
+
stroke: ${bottomBtnsColor};
|
|
86505
|
+
}`;
|
|
86506
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-response__code-wrapper {
|
|
86507
|
+
position: relative;
|
|
86508
|
+
}`;
|
|
86509
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-response__code-wrapper:hover .alan-btn__chat-response__copy-code-btn {
|
|
86510
|
+
display: flex;
|
|
86511
|
+
align-items: center;
|
|
86512
|
+
justify-content: center;
|
|
86513
|
+
}`;
|
|
86514
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-code-btn {
|
|
86515
|
+
position: absolute;
|
|
86516
|
+
top: 2px;
|
|
86517
|
+
right: 2px;
|
|
86518
|
+
width:${copyBtnWidth}px;
|
|
86519
|
+
min-width:${copyBtnWidth}px;
|
|
86520
|
+
height:${copyBtnHeight}px;
|
|
86521
|
+
min-height:${copyBtnHeight}px;
|
|
86522
|
+
border-radius: 2px;
|
|
86523
|
+
cursor: pointer;
|
|
86524
|
+
display: none;
|
|
86480
86525
|
}`;
|
|
86526
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-code-btn .alan-btn__copied-icon {
|
|
86527
|
+
display: none;
|
|
86528
|
+
}`;
|
|
86529
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-code-btn.alan-copy-btn-copied .alan-btn__copy-icon {
|
|
86530
|
+
display: none;
|
|
86531
|
+
}`;
|
|
86532
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-code-btn.alan-copy-btn-copied .alan-btn__copied-icon {
|
|
86533
|
+
display: inline-block;
|
|
86534
|
+
}`;
|
|
86535
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-code-btn svg path {
|
|
86536
|
+
fill: ${bottomBtnsColor};
|
|
86537
|
+
}`;
|
|
86538
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-code-btn.alan-copy-btn-copied .alan-btn__copied-icon {
|
|
86539
|
+
stroke: ${bottomBtnsColor};
|
|
86540
|
+
}`;
|
|
86541
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-code-btn svg {
|
|
86542
|
+
width:20px;
|
|
86543
|
+
}`;
|
|
86544
|
+
if (!isMobile()) {
|
|
86545
|
+
keyFrames += styleSheetMarker + `.alan-btn__chat-response__copy-code-btn:hover {
|
|
86546
|
+
background-color:${bottomBtnsBgColor}!important;
|
|
86547
|
+
}`;
|
|
86548
|
+
}
|
|
86481
86549
|
return keyFrames;
|
|
86482
86550
|
}
|
|
86483
86551
|
function getCssForResponseLoader(styleSheetMarker, textChatOptions) {
|
|
@@ -86705,17 +86773,18 @@
|
|
|
86705
86773
|
hasFooterLinks = !!tempNode.querySelector(".footnotes");
|
|
86706
86774
|
tempNode.remove();
|
|
86707
86775
|
}
|
|
86708
|
-
|
|
86709
|
-
|
|
86776
|
+
const links = msg.links?.filter((link) => isValidUrl(link?.href));
|
|
86777
|
+
for (let i = 0; i < links?.length; i++) {
|
|
86778
|
+
const curLink = links[i];
|
|
86710
86779
|
const target = getLinkTarget(curLink);
|
|
86711
86780
|
linksHtml += `<a class="alan-btn__chat-response-link" href="${curLink.href}" target="${target}">
|
|
86712
86781
|
<span class="alan-btn__chat-response-link-icon-wrapper">${getLinkIcon(curLink)}</span>
|
|
86713
86782
|
<span class="alan-btn__chat-response-link-title">${curLink.title || curLink.href}</span>
|
|
86714
86783
|
</a>`;
|
|
86715
86784
|
}
|
|
86716
|
-
if (
|
|
86785
|
+
if (links?.length) {
|
|
86717
86786
|
linksBlock = `<div class="alan-btn__chat-response-links-wrapper ${(msg.text || msg.images?.length > 0) && !hasFooterLinks ? "with-content-on-top" : ""}">
|
|
86718
|
-
${!hasFooterLinks ? `<span style="margin-right: 10px;display: inline-block;font-weight:
|
|
86787
|
+
${!hasFooterLinks ? `<span style="margin-right: 10px;display: inline-block;font-weight: 600;">${LEARN_MORE_LABEL} </span>` : ""}
|
|
86719
86788
|
${linksHtml}
|
|
86720
86789
|
</div>`;
|
|
86721
86790
|
}
|
|
@@ -86728,6 +86797,16 @@
|
|
|
86728
86797
|
return "_blank";
|
|
86729
86798
|
}
|
|
86730
86799
|
}
|
|
86800
|
+
function isValidUrl(url) {
|
|
86801
|
+
try {
|
|
86802
|
+
const parsedUrl = new URL(url);
|
|
86803
|
+
const hasValidProtocol = parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:";
|
|
86804
|
+
const hasValidHostname = parsedUrl.hostname.length > 0;
|
|
86805
|
+
return hasValidProtocol && hasValidHostname;
|
|
86806
|
+
} catch (e) {
|
|
86807
|
+
return false;
|
|
86808
|
+
}
|
|
86809
|
+
}
|
|
86731
86810
|
|
|
86732
86811
|
// alan_btn/src/styles/markdown.ts
|
|
86733
86812
|
function generateCssForMarkdown(stylesheetMarker, classPrefix) {
|
|
@@ -86989,16 +87068,21 @@
|
|
|
86989
87068
|
}`,
|
|
86990
87069
|
`.footnotes-list:before {
|
|
86991
87070
|
content: '${LEARN_MORE_LABEL}';
|
|
86992
|
-
font-weight:
|
|
87071
|
+
font-weight: 600;
|
|
86993
87072
|
}`,
|
|
86994
87073
|
`.footnote-item {
|
|
86995
87074
|
position: relative;
|
|
86996
|
-
display: inline-
|
|
87075
|
+
display: inline-flex;
|
|
87076
|
+
align-items: center;
|
|
87077
|
+
max-width: 100%;
|
|
86997
87078
|
border-radius: ${learnMoreTopLeftBorderRadius}px ${learnMoreTopRightBorderRadius}px ${learnMoreBottomRightBorderRadius}px ${learnMoreBottomLeftBorderRadius}px;
|
|
86998
87079
|
cursor: pointer;
|
|
86999
87080
|
border: 1px solid ${learnMoreLinkBorderColor};
|
|
87000
87081
|
margin-bottom:4px;
|
|
87001
87082
|
background-color: ${learnMoreLinkBackgroundColor};
|
|
87083
|
+
}`,
|
|
87084
|
+
`.footnote-item .footnote-backref {
|
|
87085
|
+
display: none;
|
|
87002
87086
|
}`,
|
|
87003
87087
|
`.footnote-item:hover {
|
|
87004
87088
|
border: 1px solid ${learnMoreLinkHoverBorderColor};
|
|
@@ -87014,6 +87098,10 @@
|
|
|
87014
87098
|
padding-right: 6px;
|
|
87015
87099
|
padding-left: 6px;
|
|
87016
87100
|
display: inline-block;
|
|
87101
|
+
overflow: hidden;
|
|
87102
|
+
text-overflow: ellipsis;
|
|
87103
|
+
white-space: nowrap;
|
|
87104
|
+
color: ${linkColor}!important;
|
|
87017
87105
|
}`,
|
|
87018
87106
|
`.footnote-item:hover p a {
|
|
87019
87107
|
text-decoration: none!important;
|
|
@@ -87280,14 +87368,41 @@
|
|
|
87280
87368
|
|
|
87281
87369
|
// alan_btn/src/textChat/highlightJs.ts
|
|
87282
87370
|
window.hljs = es_default;
|
|
87371
|
+
if (window.hljs) {
|
|
87372
|
+
window.hljs.addPlugin({
|
|
87373
|
+
"after:highlightElement": ({ el, text }) => {
|
|
87374
|
+
const wrapper = el.parentElement;
|
|
87375
|
+
if (wrapper == null) {
|
|
87376
|
+
return;
|
|
87377
|
+
}
|
|
87378
|
+
wrapper.classList.add("alan-btn__chat-response__code-wrapper");
|
|
87379
|
+
const copyButton = document.createElement("span");
|
|
87380
|
+
copyButton.classList.add(
|
|
87381
|
+
"alan-btn__chat-response__copy-code-btn"
|
|
87382
|
+
);
|
|
87383
|
+
copyButton.innerHTML = chatIcons.copy + chatIcons.copied;
|
|
87384
|
+
copyButton.onclick = () => {
|
|
87385
|
+
copyTextToBuffer(text);
|
|
87386
|
+
copyButton.classList.add("alan-copy-btn-copied");
|
|
87387
|
+
setTimeout(() => {
|
|
87388
|
+
copyButton.classList.remove("alan-copy-btn-copied");
|
|
87389
|
+
}, 2e3);
|
|
87390
|
+
};
|
|
87391
|
+
wrapper.appendChild(copyButton);
|
|
87392
|
+
}
|
|
87393
|
+
});
|
|
87394
|
+
}
|
|
87283
87395
|
var hljsTheme = false;
|
|
87284
|
-
function initHighlightJs(theme) {
|
|
87285
|
-
|
|
87396
|
+
function initHighlightJs(theme, customDocument) {
|
|
87397
|
+
const doc = customDocument || document;
|
|
87398
|
+
const hljsStylesId = `alan-hljs-styles-${theme}`;
|
|
87399
|
+
if (hljsTheme === theme && doc.getElementById(hljsStylesId))
|
|
87286
87400
|
return;
|
|
87287
87401
|
hljsTheme = theme;
|
|
87288
|
-
var style =
|
|
87402
|
+
var style = doc.createElement("style");
|
|
87289
87403
|
style.textContent = highlightJsCss(theme);
|
|
87290
|
-
|
|
87404
|
+
style.id = hljsStylesId;
|
|
87405
|
+
doc.getElementsByTagName("head")[0].appendChild(style);
|
|
87291
87406
|
}
|
|
87292
87407
|
function highlightCode(msgsHolder) {
|
|
87293
87408
|
if (window.hljs) {
|
|
@@ -87420,7 +87535,8 @@
|
|
|
87420
87535
|
.hljs-tag {
|
|
87421
87536
|
/* purposely ignored */
|
|
87422
87537
|
|
|
87423
|
-
}
|
|
87538
|
+
}
|
|
87539
|
+
`;
|
|
87424
87540
|
const darkTheme = `
|
|
87425
87541
|
pre code.hljs {
|
|
87426
87542
|
display: block;
|
|
@@ -87538,7 +87654,6 @@ code.hljs {
|
|
|
87538
87654
|
.hljs-punctuation,
|
|
87539
87655
|
.hljs-tag {
|
|
87540
87656
|
/* purposely ignored */
|
|
87541
|
-
|
|
87542
87657
|
}`;
|
|
87543
87658
|
const themes = {
|
|
87544
87659
|
light: lightTheme,
|
|
@@ -87729,55 +87844,65 @@ code.hljs {
|
|
|
87729
87844
|
|
|
87730
87845
|
// alan_btn/src/autosync.ts
|
|
87731
87846
|
var popstateListenerWasAdded = false;
|
|
87732
|
-
var
|
|
87733
|
-
|
|
87734
|
-
|
|
87847
|
+
var prevPageContent = "";
|
|
87848
|
+
var ALAN_BTN_PAGE_SYNC_EVENT = "alan-btn__page-sync";
|
|
87849
|
+
var syncPageStateDebounced = debounce(function() {
|
|
87850
|
+
window.dispatchEvent(new Event(ALAN_BTN_PAGE_SYNC_EVENT));
|
|
87851
|
+
}, 1e3);
|
|
87852
|
+
function autoSyncPageState(isEnabled) {
|
|
87853
|
+
if (isEnabled) {
|
|
87735
87854
|
sendPageState();
|
|
87736
87855
|
if (popstateListenerWasAdded !== true) {
|
|
87737
87856
|
popstateListenerWasAdded = true;
|
|
87738
|
-
window.addEventListener(
|
|
87857
|
+
window.addEventListener(ALAN_BTN_PAGE_SYNC_EVENT, listenForPageChanges);
|
|
87739
87858
|
}
|
|
87740
87859
|
} else {
|
|
87741
87860
|
popstateListenerWasAdded = false;
|
|
87742
|
-
window.removeEventListener(
|
|
87861
|
+
window.removeEventListener(ALAN_BTN_PAGE_SYNC_EVENT, listenForPageChanges);
|
|
87862
|
+
}
|
|
87863
|
+
}
|
|
87864
|
+
function logMutations(mutationsList, observer) {
|
|
87865
|
+
for (const mutation of mutationsList) {
|
|
87866
|
+
if (mutation?.target?.closest && mutation?.target?.closest(".alanBtn-root")) {
|
|
87867
|
+
continue;
|
|
87868
|
+
}
|
|
87869
|
+
syncPageStateDebounced([]);
|
|
87743
87870
|
}
|
|
87744
87871
|
}
|
|
87745
|
-
function
|
|
87872
|
+
function addSyncPageStateListener() {
|
|
87873
|
+
if (window.MutationObserver) {
|
|
87874
|
+
var observer = new MutationObserver(logMutations);
|
|
87875
|
+
observer.observe(document.body, {
|
|
87876
|
+
attributes: true,
|
|
87877
|
+
childList: true,
|
|
87878
|
+
subtree: true,
|
|
87879
|
+
characterData: true
|
|
87880
|
+
});
|
|
87881
|
+
}
|
|
87746
87882
|
if (window.navigation) {
|
|
87747
87883
|
window.navigation.addEventListener("navigate", (e) => {
|
|
87748
|
-
window.dispatchEvent(new Event(
|
|
87749
|
-
});
|
|
87750
|
-
} else if ("MutationObserver" in window) {
|
|
87751
|
-
var observer = new MutationObserver(function(mutations) {
|
|
87752
|
-
if (window.location.href !== previousUrl) {
|
|
87753
|
-
previousUrl = window.location.href;
|
|
87754
|
-
window.dispatchEvent(new Event("locationchange"));
|
|
87755
|
-
}
|
|
87884
|
+
window.dispatchEvent(new Event(ALAN_BTN_PAGE_SYNC_EVENT));
|
|
87756
87885
|
});
|
|
87757
|
-
var config = { subtree: true, childList: true };
|
|
87758
|
-
observer.observe(document, config);
|
|
87759
87886
|
} else {
|
|
87760
87887
|
const history = window.history;
|
|
87761
87888
|
const oldPushState = history.pushState;
|
|
87762
87889
|
history.pushState = function pushState(...args) {
|
|
87763
87890
|
const ret = oldPushState.apply(this, args);
|
|
87764
|
-
window.dispatchEvent(new Event(
|
|
87765
|
-
window.dispatchEvent(new Event("locationchange"));
|
|
87891
|
+
window.dispatchEvent(new Event(ALAN_BTN_PAGE_SYNC_EVENT));
|
|
87766
87892
|
return ret;
|
|
87767
87893
|
};
|
|
87768
87894
|
const oldReplaceState = history.replaceState;
|
|
87769
87895
|
history.replaceState = function replaceState(...args) {
|
|
87770
87896
|
const ret = oldReplaceState.apply(this, args);
|
|
87771
|
-
window.dispatchEvent(new Event(
|
|
87772
|
-
window.dispatchEvent(new Event("locationchange"));
|
|
87897
|
+
window.dispatchEvent(new Event(ALAN_BTN_PAGE_SYNC_EVENT));
|
|
87773
87898
|
return ret;
|
|
87774
87899
|
};
|
|
87775
87900
|
window.addEventListener("popstate", () => {
|
|
87776
|
-
window.dispatchEvent(new Event(
|
|
87901
|
+
window.dispatchEvent(new Event(ALAN_BTN_PAGE_SYNC_EVENT));
|
|
87777
87902
|
});
|
|
87778
87903
|
}
|
|
87779
87904
|
}
|
|
87780
|
-
function
|
|
87905
|
+
function listenForPageChanges() {
|
|
87781
87906
|
sendPageState();
|
|
87782
87907
|
}
|
|
87783
87908
|
function sendPageState() {
|
|
@@ -87785,26 +87910,35 @@ code.hljs {
|
|
|
87785
87910
|
page.innerHTML = document.getElementsByTagName("html")[0].innerHTML;
|
|
87786
87911
|
var scripts = page.getElementsByTagName("script");
|
|
87787
87912
|
var styles = page.getElementsByTagName("style");
|
|
87788
|
-
var
|
|
87913
|
+
var alanBtnEl = page.getElementsByClassName("alanBtn-root");
|
|
87914
|
+
var debugChatEl = page.getElementsByClassName("alanStudio-debug-chat");
|
|
87915
|
+
var elementsToRemove = [...scripts, ...styles, ...alanBtnEl, ...debugChatEl];
|
|
87789
87916
|
for (var i = 0; i < elementsToRemove.length; i++) {
|
|
87790
87917
|
elementsToRemove[i].remove();
|
|
87791
87918
|
}
|
|
87919
|
+
const pageContent = page.outerHTML;
|
|
87920
|
+
if (prevPageContent === pageContent) {
|
|
87921
|
+
return;
|
|
87922
|
+
}
|
|
87923
|
+
prevPageContent = pageContent;
|
|
87792
87924
|
if (window.tutorProject) {
|
|
87793
|
-
window.tutorProject.call("syncPageState", {
|
|
87925
|
+
window.tutorProject.call("syncPageState", {
|
|
87926
|
+
html: pageContent,
|
|
87927
|
+
url: window.location.href
|
|
87928
|
+
});
|
|
87794
87929
|
}
|
|
87795
87930
|
}
|
|
87796
87931
|
|
|
87797
87932
|
// alan_btn/src/textChat/buildCommandsBlock.ts
|
|
87798
|
-
function buildCommandsBlock(msg) {
|
|
87799
|
-
|
|
87800
|
-
|
|
87933
|
+
function buildCommandsBlock(msg, textChatOptions) {
|
|
87934
|
+
const isBlockVisible = msg.ctx?.enableFeedback || textChatOptions?.bubbles?.response?.copyBtn;
|
|
87935
|
+
return `<div class="alan-btn__chat-response-commands-wrapper ${isBlockVisible !== true ? "alan-btn__chat-response-commands-wrapper-hidden" : ""}">
|
|
87801
87936
|
<div class="alan-btn__chat-response-commands-wrapper-content">
|
|
87802
87937
|
${buildCopyBtnContent(msg)}
|
|
87803
|
-
|
|
87804
|
-
|
|
87938
|
+
${msg.ctx?.enableFeedback ? `
|
|
87939
|
+
<span class="alan-btn__chat-response__like-btn ${msg.liked >= 1 ? "selected" : ""}">${getLikeSvgIcon(msg)}</span>
|
|
87940
|
+
<span class="alan-btn__chat-response__dislike-btn ${msg.liked <= -1 ? "selected" : ""}">${getDislikeSvgIcon(msg)}</span>` : ""}
|
|
87805
87941
|
</div></div>`;
|
|
87806
|
-
}
|
|
87807
|
-
return "";
|
|
87808
87942
|
}
|
|
87809
87943
|
function getLikeSvgIcon(msg) {
|
|
87810
87944
|
return msg.liked === 1 ? chatIcons.likeSelected : chatIcons.like;
|
|
@@ -87818,10 +87952,91 @@ code.hljs {
|
|
|
87818
87952
|
return copyBtn;
|
|
87819
87953
|
return msg.type === "response" && isFinalMessage(msg) ? copyBtn : "";
|
|
87820
87954
|
}
|
|
87955
|
+
function changeMsgLikeStatus(msg) {
|
|
87956
|
+
const reqId = msg.ctx?.reqId || msg.reqId;
|
|
87957
|
+
if (reqId) {
|
|
87958
|
+
window.tutorProject.call("sendFeedback", { reqId, status: msg.liked });
|
|
87959
|
+
}
|
|
87960
|
+
}
|
|
87961
|
+
function resetStylesForLikeAndDislikeBtns(curMsgBubble, msg) {
|
|
87962
|
+
const likeBtnEl = curMsgBubble.querySelector(".alan-btn__chat-response__like-btn");
|
|
87963
|
+
const dislikeBtnEl = curMsgBubble.querySelector(".alan-btn__chat-response__dislike-btn");
|
|
87964
|
+
if (likeBtnEl && dislikeBtnEl) {
|
|
87965
|
+
likeBtnEl.innerHTML = getLikeSvgIcon(msg);
|
|
87966
|
+
dislikeBtnEl.innerHTML = getDislikeSvgIcon(msg);
|
|
87967
|
+
}
|
|
87968
|
+
}
|
|
87969
|
+
function deleteHiddenImagesWithCode(str) {
|
|
87970
|
+
return (str || "").replace(/<img\s+style="display:none;".*?\/>/gi, "").replace(/\s+$/g, "");
|
|
87971
|
+
}
|
|
87972
|
+
|
|
87973
|
+
// alan_btn/src/textChat/saveChatStateToFile.ts
|
|
87974
|
+
function saveChatState(chatEl, projectId, headContent, codeContent) {
|
|
87975
|
+
const alanBtnContent = chatEl.outerHTML;
|
|
87976
|
+
const alanMainClass = "alan-" + projectId;
|
|
87977
|
+
const newHtmlContent = `
|
|
87978
|
+
<!DOCTYPE html>
|
|
87979
|
+
<html lang="en">
|
|
87980
|
+
<head>
|
|
87981
|
+
<title>Alan Text Chat History</title>
|
|
87982
|
+
${headContent ? headContent : ""}
|
|
87983
|
+
<style>
|
|
87984
|
+
* {
|
|
87985
|
+
box-sizing: border-box;
|
|
87986
|
+
}
|
|
87987
|
+
body {
|
|
87988
|
+
padding:0 !important;
|
|
87989
|
+
margin: 0 !important;
|
|
87990
|
+
background: #c6cbce;
|
|
87991
|
+
}
|
|
87992
|
+
.alan-btn__history-chat-header > h1 {
|
|
87993
|
+
padding-left: 10px !important;
|
|
87994
|
+
color: #000;
|
|
87995
|
+
}
|
|
87996
|
+
.alan-btn__history-chat-header {
|
|
87997
|
+
margin: 0px auto;
|
|
87998
|
+
max-width: 500px;
|
|
87999
|
+
}
|
|
88000
|
+
.alan-history-inner-content {
|
|
88001
|
+
margin: 0px auto;
|
|
88002
|
+
max-width: 500px;
|
|
88003
|
+
height:100%;
|
|
88004
|
+
box-shadow: 0px 1px 3px rgba(16, 39, 126, 0.2);
|
|
88005
|
+
}
|
|
88006
|
+
</style>
|
|
88007
|
+
</head>
|
|
88008
|
+
<body class="alan-btn__history-body">
|
|
88009
|
+
<div class="alan-history-content ${alanMainClass}">
|
|
88010
|
+
<div class="alan-btn__history-chat-header">
|
|
88011
|
+
<h1>Alan Text Chat History</h1>
|
|
88012
|
+
</div>
|
|
88013
|
+
<div class="alan-btn__history-chat alan-history-inner-content">
|
|
88014
|
+
${alanBtnContent}
|
|
88015
|
+
</div>
|
|
88016
|
+
</div>
|
|
88017
|
+
${codeContent ? codeContent : ""}
|
|
88018
|
+
</body>
|
|
88019
|
+
</html>
|
|
88020
|
+
`;
|
|
88021
|
+
const now = /* @__PURE__ */ new Date();
|
|
88022
|
+
const year = now.getFullYear();
|
|
88023
|
+
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
88024
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
88025
|
+
const hours = String(now.getHours()).padStart(2, "0");
|
|
88026
|
+
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
88027
|
+
const seconds = String(now.getSeconds()).padStart(2, "0");
|
|
88028
|
+
const formattedDate = `__${year}-${month}-${day}_${hours}-${minutes}-${seconds}`;
|
|
88029
|
+
const blob = new Blob([newHtmlContent], { type: "text/html" });
|
|
88030
|
+
const link = document.createElement("a");
|
|
88031
|
+
link.href = URL.createObjectURL(blob);
|
|
88032
|
+
link.download = `alan_text_chat_history${formattedDate}.html`;
|
|
88033
|
+
link.click();
|
|
88034
|
+
URL.revokeObjectURL(link.href);
|
|
88035
|
+
}
|
|
87821
88036
|
|
|
87822
88037
|
// alan_btn/alan_btn.ts
|
|
87823
88038
|
(function(ns) {
|
|
87824
|
-
uiState.lib.version = "alan-version.1.8.
|
|
88039
|
+
uiState.lib.version = "alan-version.1.8.63".replace("alan-version.", "");
|
|
87825
88040
|
if (window.alanBtn) {
|
|
87826
88041
|
console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")");
|
|
87827
88042
|
}
|
|
@@ -88205,6 +88420,8 @@ code.hljs {
|
|
|
88205
88420
|
var btnBgLayerZIndex;
|
|
88206
88421
|
var popupIsVisible = false;
|
|
88207
88422
|
var tabActive = true;
|
|
88423
|
+
var tabId = guid();
|
|
88424
|
+
saveTabId();
|
|
88208
88425
|
window.addEventListener("online", updateOnlineStatus);
|
|
88209
88426
|
window.addEventListener("offline", updateOnlineStatus);
|
|
88210
88427
|
window.addEventListener("focus", syncChatHistoryBetweenTabs);
|
|
@@ -89305,12 +89522,15 @@ code.hljs {
|
|
|
89305
89522
|
}
|
|
89306
89523
|
}
|
|
89307
89524
|
if (options.key && !isTutorMode()) {
|
|
89308
|
-
|
|
89525
|
+
addSyncPageStateListener();
|
|
89526
|
+
}
|
|
89527
|
+
if (isTutorMode()) {
|
|
89528
|
+
autoSyncPageState(true);
|
|
89309
89529
|
}
|
|
89310
89530
|
function onOptionsReceived(data) {
|
|
89311
89531
|
console.log("Alan: options received");
|
|
89312
89532
|
console.timeEnd("Alan: receiving options time");
|
|
89313
|
-
autoSyncPageState(data);
|
|
89533
|
+
autoSyncPageState(data && data.web?.pageState?.autoSync !== false);
|
|
89314
89534
|
if (data && data.web) {
|
|
89315
89535
|
keepButtonPositionAfterDnD = data.web.alanButtonDragAndDrop?.keepButtonPositionAfterDnD || data.web.keepButtonPositionAfterDnD;
|
|
89316
89536
|
if (!keepButtonPositionAfterDnD) {
|
|
@@ -89923,12 +90143,6 @@ code.hljs {
|
|
|
89923
90143
|
}
|
|
89924
90144
|
return imgsBlock;
|
|
89925
90145
|
}
|
|
89926
|
-
function changeMsgLikeStatus(msg) {
|
|
89927
|
-
const reqId = msg.ctx?.reqId || msg.reqId;
|
|
89928
|
-
if (reqId) {
|
|
89929
|
-
window.tutorProject.call("sendFeedback", { reqId, status: msg.liked });
|
|
89930
|
-
}
|
|
89931
|
-
}
|
|
89932
90146
|
function performLikeOrDislike(e) {
|
|
89933
90147
|
const curMsgBubble = e.target.closest(".alan-btn__chat-msg-holder");
|
|
89934
90148
|
if (!curMsgBubble)
|
|
@@ -89949,14 +90163,6 @@ code.hljs {
|
|
|
89949
90163
|
resetStylesForLikeAndDislikeBtns(curMsgBubble, msg);
|
|
89950
90164
|
saveMessageHistory();
|
|
89951
90165
|
}
|
|
89952
|
-
function resetStylesForLikeAndDislikeBtns(curMsgBubble, msg) {
|
|
89953
|
-
const likeBtnEl = curMsgBubble.querySelector(".alan-btn__chat-response__like-btn");
|
|
89954
|
-
const dislikeBtnEl = curMsgBubble.querySelector(".alan-btn__chat-response__dislike-btn");
|
|
89955
|
-
if (likeBtnEl && dislikeBtnEl) {
|
|
89956
|
-
likeBtnEl.innerHTML = getLikeSvgIcon(msg);
|
|
89957
|
-
dislikeBtnEl.innerHTML = getDislikeSvgIcon(msg);
|
|
89958
|
-
}
|
|
89959
|
-
}
|
|
89960
90166
|
document.removeEventListener("click", performLikeOrDislike);
|
|
89961
90167
|
document.addEventListener("click", performLikeOrDislike);
|
|
89962
90168
|
function buildMsgTextContent(msg) {
|
|
@@ -89971,13 +90177,16 @@ code.hljs {
|
|
|
89971
90177
|
return result ? `<span class="alan-btn__chat-response-text-wrapper">${fixTargetForLinks(result)}</span>` : "";
|
|
89972
90178
|
}
|
|
89973
90179
|
function buildMsgContent(msg) {
|
|
89974
|
-
return `${buildImagesContent(msg)}${buildMsgTextContent(msg)}${buildLinksContent(msg)}${buildCommandsBlock(msg)}${buildMsgIncommingLoader(msg)}`;
|
|
90180
|
+
return `${buildImagesContent(msg)}${buildMsgTextContent(msg)}${buildLinksContent(msg)}${buildCommandsBlock(msg, uiState?.textChat?.options)}${buildMsgIncommingLoader(msg)}`;
|
|
89975
90181
|
}
|
|
89976
90182
|
initMathJax(textChatMessages.length, (i2) => getMsgElForMathJax(i2));
|
|
89977
90183
|
document.addEventListener("click", (e) => {
|
|
89978
90184
|
let clickedEl = e.target;
|
|
89979
90185
|
clickedEl = clickedEl.closest(".alan-btn__chat-response__copy-btn");
|
|
89980
90186
|
if (clickedEl) {
|
|
90187
|
+
let textChat = clickedEl.closest("#alan-text-chat");
|
|
90188
|
+
if (!textChat)
|
|
90189
|
+
return;
|
|
89981
90190
|
clickedEl.classList.add("alan-copy-btn-copied");
|
|
89982
90191
|
setTimeout(() => {
|
|
89983
90192
|
clickedEl.classList.remove("alan-copy-btn-copied");
|
|
@@ -89987,7 +90196,7 @@ code.hljs {
|
|
|
89987
90196
|
const msg = textChatMessages[msgInd];
|
|
89988
90197
|
let textToCopy = "";
|
|
89989
90198
|
if (msg) {
|
|
89990
|
-
textToCopy = msg.text || "";
|
|
90199
|
+
textToCopy = deleteHiddenImagesWithCode(msg.text || "");
|
|
89991
90200
|
copyTextToBuffer(
|
|
89992
90201
|
(msg.images?.length > 0 ? msg.images?.map((img) => img.src).join("\n") + "\n\n" : "") + textToCopy + (msg.links?.length > 0 ? `
|
|
89993
90202
|
|
|
@@ -90035,11 +90244,11 @@ ${LEARN_MORE_LABEL}
|
|
|
90035
90244
|
}
|
|
90036
90245
|
}
|
|
90037
90246
|
if (msg.ctx) {
|
|
90038
|
-
if (window.fakeMsg?.ctx?.
|
|
90039
|
-
msg.ctx.
|
|
90247
|
+
if (window.fakeMsg?.ctx?.enableFeedback) {
|
|
90248
|
+
msg.ctx.enableFeedback = window.fakeMsg?.ctx?.enableFeedback;
|
|
90040
90249
|
}
|
|
90041
90250
|
} else {
|
|
90042
|
-
msg.ctx = {
|
|
90251
|
+
msg.ctx = { enableFeedback: window.fakeMsg?.ctx?.enableFeedback };
|
|
90043
90252
|
}
|
|
90044
90253
|
window.fakeMsg = null;
|
|
90045
90254
|
}
|
|
@@ -90141,7 +90350,7 @@ ${LEARN_MORE_LABEL}
|
|
|
90141
90350
|
}
|
|
90142
90351
|
innerEl.insertAdjacentHTML("beforeend", buildMsgTextContent(updatedMsg));
|
|
90143
90352
|
innerEl.insertAdjacentHTML("beforeend", buildLinksContent(updatedMsg));
|
|
90144
|
-
innerEl.insertAdjacentHTML("beforeend", buildCommandsBlock(msg));
|
|
90353
|
+
innerEl.insertAdjacentHTML("beforeend", buildCommandsBlock(msg, uiState?.textChat?.options));
|
|
90145
90354
|
innerEl.insertAdjacentHTML("beforeend", buildMsgIncommingLoader(msg));
|
|
90146
90355
|
if (isMsgContainsTable(innerEl?.innerHTML)) {
|
|
90147
90356
|
innerEl.classList.add("with-table");
|
|
@@ -90168,6 +90377,7 @@ ${LEARN_MORE_LABEL}
|
|
|
90168
90377
|
enableTextareaInTheChat();
|
|
90169
90378
|
}
|
|
90170
90379
|
}
|
|
90380
|
+
manageSaveChatHistoryBtn();
|
|
90171
90381
|
}
|
|
90172
90382
|
function scrollTextChat(msgHolder, behavior) {
|
|
90173
90383
|
const scrollOptions = {
|
|
@@ -90193,7 +90403,10 @@ ${LEARN_MORE_LABEL}
|
|
|
90193
90403
|
}
|
|
90194
90404
|
function saveMessageHistory() {
|
|
90195
90405
|
if (isLocalStorageAvailable && curDialogId) {
|
|
90196
|
-
localStorage.
|
|
90406
|
+
const lastActiveTabId = localStorage.getItem("alan-btn-tab-id");
|
|
90407
|
+
if (lastActiveTabId === tabId) {
|
|
90408
|
+
localStorage.setItem(getKeyForSavingTextChatMessages(), JSON.stringify(textChatMessages));
|
|
90409
|
+
}
|
|
90197
90410
|
}
|
|
90198
90411
|
}
|
|
90199
90412
|
function getKeyForSavingTextChatMessages() {
|
|
@@ -90228,11 +90441,18 @@ ${LEARN_MORE_LABEL}
|
|
|
90228
90441
|
function clearChatAndChatHistory() {
|
|
90229
90442
|
clearChat();
|
|
90230
90443
|
clearChatHistoryStorage();
|
|
90444
|
+
manageSaveChatHistoryBtn();
|
|
90231
90445
|
}
|
|
90232
90446
|
function syncChatHistoryBetweenTabs() {
|
|
90233
90447
|
tabActive = true;
|
|
90448
|
+
saveTabId();
|
|
90234
90449
|
restoreMessageList(false);
|
|
90235
90450
|
}
|
|
90451
|
+
function saveTabId() {
|
|
90452
|
+
if (isLocalStorageAvailable) {
|
|
90453
|
+
localStorage.setItem("alan-btn-tab-id", tabId);
|
|
90454
|
+
}
|
|
90455
|
+
}
|
|
90236
90456
|
function restoreMessageList(initLoad) {
|
|
90237
90457
|
var savedMsgs;
|
|
90238
90458
|
if (isLocalStorageAvailable) {
|
|
@@ -90352,6 +90572,36 @@ ${LEARN_MORE_LABEL}
|
|
|
90352
90572
|
function onChatTextAreaChange(e) {
|
|
90353
90573
|
resizeTextArea();
|
|
90354
90574
|
}
|
|
90575
|
+
const resizeTextAreaDebounced = throttle(function() {
|
|
90576
|
+
resizeTextArea();
|
|
90577
|
+
}, 300);
|
|
90578
|
+
function resizeTextArea() {
|
|
90579
|
+
var el = getChatTextareaEl();
|
|
90580
|
+
if (!el)
|
|
90581
|
+
return;
|
|
90582
|
+
const isMultiline = uiState.textChat.options?.textarea?.fieldType === "multi-line";
|
|
90583
|
+
const defaultLineHeight = uiState.textChat.defaults.textareaLineHeight;
|
|
90584
|
+
if (isMultiline) {
|
|
90585
|
+
const defaultChatTextareaFontSize = uiState.textChat.defaults.textareaFontSize;
|
|
90586
|
+
const fontSize = +getTextAreaFontSize(isMobile(), uiState.textChat.options?.textarea?.fontSize || defaultChatTextareaFontSize);
|
|
90587
|
+
const textareaTopPadding = +getNumPropVal(uiState.textChat.options?.textarea?.padding?.top, 12);
|
|
90588
|
+
const textareaBottomPadding = +getNumPropVal(uiState.textChat.options?.textarea?.padding?.bottom, 12);
|
|
90589
|
+
const maxLinesCount = Math.max(+getNumPropVal(uiState.textChat.options?.textarea?.maxLinesCount, 7), 1);
|
|
90590
|
+
const paddingsAndBorder = textareaTopPadding + textareaBottomPadding;
|
|
90591
|
+
const lineHeight = fontSize * defaultLineHeight;
|
|
90592
|
+
const maxHeight = lineHeight * maxLinesCount + paddingsAndBorder;
|
|
90593
|
+
const defaultOneLineHeight = lineHeight + paddingsAndBorder;
|
|
90594
|
+
el.style.height = `${getDynamicInputHeight(el, maxHeight)}px`;
|
|
90595
|
+
if (el.offsetHeight > defaultOneLineHeight) {
|
|
90596
|
+
el.closest("#textarea-holder")?.classList?.add("multi-line");
|
|
90597
|
+
} else {
|
|
90598
|
+
el.closest("#textarea-holder")?.classList?.remove("multi-line");
|
|
90599
|
+
}
|
|
90600
|
+
} else {
|
|
90601
|
+
el.closest("#textarea-holder")?.classList?.remove("multi-line");
|
|
90602
|
+
el.style.height = `100%`;
|
|
90603
|
+
}
|
|
90604
|
+
}
|
|
90355
90605
|
function getDynamicInputHeight(el, maxHeight) {
|
|
90356
90606
|
const style = window.getComputedStyle(el);
|
|
90357
90607
|
const text = el.value;
|
|
@@ -90382,36 +90632,6 @@ ${LEARN_MORE_LABEL}
|
|
|
90382
90632
|
el.style.overflow = maxHeight - newHeight - 2 > 0 ? "hidden" : "auto";
|
|
90383
90633
|
return newHeight;
|
|
90384
90634
|
}
|
|
90385
|
-
const resizeTextAreaDebounced = throttle(function() {
|
|
90386
|
-
resizeTextArea();
|
|
90387
|
-
}, 300);
|
|
90388
|
-
function resizeTextArea() {
|
|
90389
|
-
var el = getChatTextareaEl();
|
|
90390
|
-
if (!el)
|
|
90391
|
-
return;
|
|
90392
|
-
const isMultiline = uiState.textChat.options?.textarea?.fieldType === "multi-line";
|
|
90393
|
-
const defaultLineHeight = uiState.textChat.defaults.textareaLineHeight;
|
|
90394
|
-
if (isMultiline) {
|
|
90395
|
-
const defaultChatTextareaFontSize = uiState.textChat.defaults.textareaFontSize;
|
|
90396
|
-
const fontSize = +getTextAreaFontSize(isMobile(), uiState.textChat.options?.textarea?.fontSize || defaultChatTextareaFontSize);
|
|
90397
|
-
const textareaTopPadding = +getNumPropVal(uiState.textChat.options?.textarea?.padding?.top, 12);
|
|
90398
|
-
const textareaBottomPadding = +getNumPropVal(uiState.textChat.options?.textarea?.padding?.bottom, 12);
|
|
90399
|
-
const maxLinesCount = +getNumPropVal(uiState.textChat.options?.textarea?.maxLinesCount, 7);
|
|
90400
|
-
const paddingsAndBorder = textareaTopPadding + textareaBottomPadding + 4;
|
|
90401
|
-
const lineHeight = fontSize * defaultLineHeight;
|
|
90402
|
-
const maxHeight = lineHeight * maxLinesCount + paddingsAndBorder;
|
|
90403
|
-
const defaultOneLineHeight = lineHeight + paddingsAndBorder;
|
|
90404
|
-
el.style.height = `${getDynamicInputHeight(el, maxHeight)}px`;
|
|
90405
|
-
if (el.offsetHeight > defaultOneLineHeight) {
|
|
90406
|
-
el.closest("#textarea-holder")?.classList?.add("multi-line");
|
|
90407
|
-
} else {
|
|
90408
|
-
el.closest("#textarea-holder")?.classList?.remove("multi-line");
|
|
90409
|
-
}
|
|
90410
|
-
} else {
|
|
90411
|
-
el.closest("#textarea-holder")?.classList?.remove("multi-line");
|
|
90412
|
-
el.style.height = `100%`;
|
|
90413
|
-
}
|
|
90414
|
-
}
|
|
90415
90635
|
function getRestoreMsgsLsKey() {
|
|
90416
90636
|
const projectId = getProjectId();
|
|
90417
90637
|
return `alan-btn-chat-sent-history-${projectId}`;
|
|
@@ -90576,6 +90796,16 @@ ${LEARN_MORE_LABEL}
|
|
|
90576
90796
|
el.addEventListener("input", onChatTextAreaChange);
|
|
90577
90797
|
return el;
|
|
90578
90798
|
}
|
|
90799
|
+
function manageSaveChatHistoryBtn() {
|
|
90800
|
+
var saveChatStateBtnImg = document.getElementById("alan-btn-save-chat-state-btn");
|
|
90801
|
+
if (saveChatStateBtnImg) {
|
|
90802
|
+
if (textChatMessages?.length > 0) {
|
|
90803
|
+
saveChatStateBtnImg.classList.remove("alan-btn__save-chat-state-btn-disabled");
|
|
90804
|
+
} else {
|
|
90805
|
+
saveChatStateBtnImg.classList.add("alan-btn__save-chat-state-btn-disabled");
|
|
90806
|
+
}
|
|
90807
|
+
}
|
|
90808
|
+
}
|
|
90579
90809
|
function initTextChat() {
|
|
90580
90810
|
var textareaDiv = document.getElementById("textarea-holder");
|
|
90581
90811
|
var textareaInnerDiv = document.getElementById("textarea-inner-holder");
|
|
@@ -90591,6 +90821,7 @@ ${LEARN_MORE_LABEL}
|
|
|
90591
90821
|
var leftHeaderIconsHolder = document.getElementById("chat-header-left-icons");
|
|
90592
90822
|
var closeChatBtnImg = document.getElementById("alan-btn-chat-close-btn");
|
|
90593
90823
|
var expandCollapseChatBtnImg = document.getElementById("alan-btn-expand-collapse-chat-btn");
|
|
90824
|
+
var saveChatStateBtnImg = document.getElementById("alan-btn-save-chat-state-btn");
|
|
90594
90825
|
const isMultiline = uiState.textChat.options?.textarea?.fieldType === "multi-line";
|
|
90595
90826
|
if (!chatDivWrapper.classList.contains("alan-btn__chat")) {
|
|
90596
90827
|
document.addEventListener("touchstart", keyboardScrollFixListenerForChat, { passive: false });
|
|
@@ -90626,11 +90857,20 @@ ${LEARN_MORE_LABEL}
|
|
|
90626
90857
|
leftHeaderIconsHolder = createDiv({ id: "chat-header-left-icons", class: "alan-btn__chat-header-left-icons" });
|
|
90627
90858
|
rightHeaderIconsHolder = createDiv({ id: "chat-header-right-icons", class: "alan-btn__chat-header-right-icons" });
|
|
90628
90859
|
if (!isMobile()) {
|
|
90860
|
+
saveChatStateBtnImg = createDivWithSvg(
|
|
90861
|
+
getSaveChatStateIcon(uiState?.textChat?.options),
|
|
90862
|
+
{ class: "alan-btn__save-chat-state-btn", id: "alan-btn-save-chat-state-btn" }
|
|
90863
|
+
);
|
|
90629
90864
|
expandCollapseChatBtnImg = createDivWithSvg(
|
|
90630
90865
|
`${getExpandChatIcon(uiState?.textChat?.options)}${getCollapseChatIcon(uiState?.textChat?.options)}`,
|
|
90631
90866
|
{ class: "alan-btn__expand-collapse-chat-btn", id: "alan-btn-expand-collapse-chat-btn" }
|
|
90632
90867
|
);
|
|
90868
|
+
rightHeaderIconsHolder.appendChild(saveChatStateBtnImg);
|
|
90633
90869
|
rightHeaderIconsHolder.appendChild(expandCollapseChatBtnImg);
|
|
90870
|
+
saveChatStateBtnImg.addEventListener("click", () => {
|
|
90871
|
+
const headContent = document.head.innerHTML;
|
|
90872
|
+
saveChatState(document.querySelector("#chatMessagesWrapper"), getProjectId(), headContent);
|
|
90873
|
+
});
|
|
90634
90874
|
expandCollapseChatBtnImg.addEventListener("click", expandCollapseTextChat);
|
|
90635
90875
|
addNeedClassesToExpandCollapseBtn(expandCollapseChatBtnImg);
|
|
90636
90876
|
}
|
|
@@ -90686,6 +90926,9 @@ ${LEARN_MORE_LABEL}
|
|
|
90686
90926
|
if (closeChatBtnImg) {
|
|
90687
90927
|
closeChatBtnImg.innerHTML = getCloseChatIcon(uiState.textChat.options);
|
|
90688
90928
|
}
|
|
90929
|
+
if (saveChatStateBtnImg) {
|
|
90930
|
+
saveChatStateBtnImg.innerHTML = getSaveChatStateIcon(uiState.textChat.options);
|
|
90931
|
+
}
|
|
90689
90932
|
if (expandCollapseChatBtnImg) {
|
|
90690
90933
|
expandCollapseChatBtnImg.innerHTML = `${getExpandChatIcon(uiState?.textChat?.options)}${getCollapseChatIcon(uiState?.textChat?.options)}`;
|
|
90691
90934
|
addNeedClassesToExpandCollapseBtn(expandCollapseChatBtnImg);
|
|
@@ -90744,6 +90987,7 @@ ${LEARN_MORE_LABEL}
|
|
|
90744
90987
|
chatTextarea.setAttribute("placeholder", uiState.textChat.options?.textarea?.placeholder);
|
|
90745
90988
|
}
|
|
90746
90989
|
}
|
|
90990
|
+
manageSaveChatHistoryBtn();
|
|
90747
90991
|
}
|
|
90748
90992
|
function getOpenCloseTextChatLocalStorageKey() {
|
|
90749
90993
|
return `alan-btn-text-chat-opened-for-projectId-${getProjectId()}`;
|