@alan-ai/alan-sdk-web 1.8.75 → 1.8.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/alan_lib.js CHANGED
@@ -4781,7 +4781,7 @@
4781
4781
  result2.placeholder = curryRight.placeholder;
4782
4782
  return result2;
4783
4783
  }
4784
- function debounce2(func, wait, options) {
4784
+ function debounce3(func, wait, options) {
4785
4785
  var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
4786
4786
  if (typeof func != "function") {
4787
4787
  throw new TypeError2(FUNC_ERROR_TEXT);
@@ -4961,7 +4961,7 @@
4961
4961
  leading = "leading" in options ? !!options.leading : leading;
4962
4962
  trailing = "trailing" in options ? !!options.trailing : trailing;
4963
4963
  }
4964
- return debounce2(func, wait, {
4964
+ return debounce3(func, wait, {
4965
4965
  "leading": leading,
4966
4966
  "maxWait": wait,
4967
4967
  "trailing": trailing
@@ -5975,7 +5975,7 @@
5975
5975
  lodash.create = create;
5976
5976
  lodash.curry = curry;
5977
5977
  lodash.curryRight = curryRight;
5978
- lodash.debounce = debounce2;
5978
+ lodash.debounce = debounce3;
5979
5979
  lodash.defaults = defaults;
5980
5980
  lodash.defaultsDeep = defaultsDeep;
5981
5981
  lodash.defer = defer;
@@ -89452,6 +89452,7 @@
89452
89452
 
89453
89453
  // alan_btn/src/state.ts
89454
89454
  var uiState = {
89455
+ currentTheme: null,
89455
89456
  lib: {
89456
89457
  version: ""
89457
89458
  },
@@ -89552,12 +89553,8 @@
89552
89553
  cy="100"
89553
89554
  r="70"
89554
89555
  ></circle>
89556
+ <rect x="70" y="70" width="60" height="60" fill="currentColor"/>
89555
89557
  </svg>`,
89556
- stopResponse: `
89557
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
89558
- <rect x="6" y="6" width="8" height="8" rx="1" fill="#64AED5"/>
89559
- </svg>
89560
- `,
89561
89558
  mic: `
89562
89559
  <svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
89563
89560
  <path d="M21.4 12.8V15C21.4 19.2526 17.9526 22.7 13.7 22.7M13.7 22.7C9.4474 22.7 6 19.2526 6 15V12.8M13.7 22.7V26M9.3 26H18.1M13.7 18.3C11.8774 18.3 10.4 16.8226 10.4 15V7.3C10.4 5.47752 11.8774 4 13.7 4C15.5226 4 17 5.47752 17 7.3V15C17 16.8226 15.5226 18.3 13.7 18.3Z" stroke="#4A515D" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
@@ -89638,9 +89635,6 @@
89638
89635
  function getSendChatIcon(textChatOptions) {
89639
89636
  return textChatOptions?.popup?.icons?.send?.svg || chatIcons.send;
89640
89637
  }
89641
- function getStopChatIcon(textChatOptions) {
89642
- return textChatOptions?.popup?.icons?.stopResponse?.svg || chatIcons.stopResponse;
89643
- }
89644
89638
  function getMicChatIcon(textChatOptions) {
89645
89639
  return textChatOptions?.popup?.icons?.mic?.svg || chatIcons.mic;
89646
89640
  }
@@ -89652,29 +89646,24 @@
89652
89646
  }
89653
89647
 
89654
89648
  // alan_btn/src/textChat/helpers/getMsgLoader.ts
89655
- function getMsgLoader(textChatOptions, message, onlyLoader) {
89656
- const isQueryProgressEnabled = textChatOptions?.bubbles?.waitingResponse?.queryProgress?.enabled;
89657
- const waitingResponseBubbleLayout = textChatOptions?.bubbles?.waitingResponse?.layout || "default";
89658
- const isDefaultLayout = waitingResponseBubbleLayout === "default";
89659
- const hasCustomLoaderSvg = textChatOptions?.bubbles?.waitingResponse?.icon?.svg;
89660
- let waitingResponseBubbleLabel = textChatOptions?.bubbles?.waitingResponse?.label || "Generating result";
89649
+ var DEFAULT_INTERIM_MESSAGE = "Thinking...";
89650
+ var STOP_RESPONSE_ICON_CLASS = "alan-btn__chat-incomming-msg-loader-icon";
89651
+ function getMsgLoaderWrapper(content) {
89652
+ return `<div class="alan-btn__chat-incomming-msg-wrapper">${content}</div>`;
89653
+ }
89654
+ function getMsgLoader(textChatOptions) {
89655
+ const icon = textChatOptions?.bubbles?.waitingResponse?.icon.svg || chatIcons.msgLoader;
89656
+ return `<span class="alan-btn__chat-incomming-msg-loader-icon-holder">
89657
+ <span class="${STOP_RESPONSE_ICON_CLASS}">${icon}</span>
89658
+ </span>`;
89659
+ }
89660
+ function getMsgLoaderStatus(textChatOptions, message) {
89661
+ let waitingResponseBubbleLabel = textChatOptions?.bubbles?.waitingResponse?.label || DEFAULT_INTERIM_MESSAGE;
89661
89662
  if (message?.queryProgress) {
89662
89663
  const unshownStatuses = message?.queryProgress?.filter((s) => s.isShown === false);
89663
89664
  waitingResponseBubbleLabel = unshownStatuses?.length > 0 ? unshownStatuses[0].text : message?.queryProgress[message?.queryProgress?.length - 1].text || "";
89664
89665
  }
89665
- waitingResponseBubbleLabel = capitalize(waitingResponseBubbleLabel);
89666
- if (onlyLoader) {
89667
- waitingResponseBubbleLabel = "";
89668
- }
89669
- const content = `<span class="alan-btn__chat-incomming-msg-loader-icon alan-btn__chat-stop-response-holder">
89670
- ${!hasCustomLoaderSvg ? chatIcons.msgLoader : ""}${getMsgStopBtn(textChatOptions)}
89671
- </span>
89672
- <span class="alan-btn__chat-incomming-msg-loader-label">${waitingResponseBubbleLabel}</span>`;
89673
- return `<div class="alan-btn__chat-incomming-msg-wrapper">${content}</div>`;
89674
- }
89675
- function getMsgStopBtn(textChatOptions) {
89676
- const content = `<div style="position:absolute;" class="alan-btn__stop-response-btn" title="Stop response generation">${getStopChatIcon(textChatOptions)}</div>`;
89677
- return content;
89666
+ return capitalize(waitingResponseBubbleLabel);
89678
89667
  }
89679
89668
  function capitalize(str) {
89680
89669
  return str.charAt(0).toUpperCase() + str.substring(1);
@@ -89687,7 +89676,7 @@
89687
89676
  function buildMsgIncommingLoader(msg) {
89688
89677
  if (msg.initLoad)
89689
89678
  return "";
89690
- return !isFinalMessage(msg) ? `<div style="margin-top: 12px;margin-bottom: 4px;">${getMsgLoader(uiState.textChat.options, msg, true)}</div>` : "";
89679
+ return !isFinalMessage(msg) ? `<div style="margin-top: 12px;margin-bottom: 4px;">${getMsgLoaderWrapper(getMsgLoader(uiState.textChat.options))}</div>` : "";
89691
89680
  }
89692
89681
 
89693
89682
  // alan_btn/src/textChat/helpers/getMsgReadProp.ts
@@ -89802,6 +89791,13 @@
89802
89791
  };
89803
89792
  }
89804
89793
 
89794
+ // alan_btn/src/replaceImgSrcWithProxy.ts
89795
+ function replaceImgSrcWithProxy(src = "", proxyDomain) {
89796
+ const replacementSrcPart = `https://${proxyDomain}/get-text-chat-image/`;
89797
+ const pattern = /https?:\/\//;
89798
+ return src.replace(pattern, replacementSrcPart);
89799
+ }
89800
+
89805
89801
  // alan_btn/src/textChat/helpers/filterImagesForTextChat.ts
89806
89802
  function filterImagesForTextChat(images) {
89807
89803
  return (images || []).filter((image) => {
@@ -90076,6 +90072,124 @@
90076
90072
  `;
90077
90073
  }
90078
90074
 
90075
+ // alan_btn/src/textChat/helpers/adjustIFrameSize.ts
90076
+ function adjustIFrameSize(iframeMsgData) {
90077
+ const maxIFrameHeight = 1400;
90078
+ var { height, width, iframeId, withSvg } = iframeMsgData;
90079
+ console.info("adjustIFrameSize", height, width);
90080
+ const iframeEls = document.querySelectorAll("#" + iframeId);
90081
+ iframeEls.forEach((iframeEl) => {
90082
+ const responseWrapper = iframeEl.closest(".alan-btn__chat-response, .chat-bubble_message") || iframeEl.closest("body");
90083
+ if (Math.abs(iframeEl.clientHeight - height) !== 20) {
90084
+ iframeEl.style.height = (+height > maxIFrameHeight ? maxIFrameHeight : height) + "px";
90085
+ }
90086
+ if (!responseWrapper) {
90087
+ iframeEl.style.width = "100%";
90088
+ return;
90089
+ }
90090
+ if (withSvg) {
90091
+ if (!responseWrapper.classList.contains("with-svg")) {
90092
+ responseWrapper.classList.add("with-svg");
90093
+ iframeEl.style.width = "100%";
90094
+ setTimeout(() => {
90095
+ broadcastReloadIframeToIframes();
90096
+ }, 50);
90097
+ }
90098
+ } else {
90099
+ if (height < 650) {
90100
+ changeWidthIfNeeded(iframeEl, width);
90101
+ } else {
90102
+ if (responseWrapper.clientWidth <= width) {
90103
+ changeWidthIfNeeded(iframeEl, width);
90104
+ } else {
90105
+ iframeEl.style.width = "100%";
90106
+ }
90107
+ }
90108
+ }
90109
+ });
90110
+ function changeWidthIfNeeded(iframeEl, newWidth) {
90111
+ if (Math.abs(iframeEl.clientWidth - newWidth) !== 20) {
90112
+ iframeEl.style.width = newWidth + "px";
90113
+ }
90114
+ }
90115
+ }
90116
+ function broadcastThemeToIframes() {
90117
+ let theme;
90118
+ try {
90119
+ theme = uiState?.currentTheme;
90120
+ } catch (error) {
90121
+ theme = window["alanCurrentTheme"];
90122
+ }
90123
+ const iframes = window.frames;
90124
+ const message = {
90125
+ type: "alanThemeEvent",
90126
+ theme
90127
+ };
90128
+ if (!theme)
90129
+ return;
90130
+ for (let i = 0; i < iframes.length; i++) {
90131
+ try {
90132
+ iframes[i].postMessage(message, "*");
90133
+ } catch (error) {
90134
+ console.error(`Failed to send message to iframe ${i}`, error);
90135
+ }
90136
+ }
90137
+ }
90138
+ function broadcastReloadIframeToIframes() {
90139
+ const iframes = window.frames;
90140
+ const message = {
90141
+ type: "alanReloadIFrameEvent"
90142
+ };
90143
+ for (let i = 0; i < iframes.length; i++) {
90144
+ try {
90145
+ iframes[i].postMessage(message, "*");
90146
+ } catch (error) {
90147
+ console.error(`Failed to send message to iframe ${i}`, error);
90148
+ }
90149
+ }
90150
+ }
90151
+ var iFrameSizeListenerFunctions = [
90152
+ broadcastThemeToIframes,
90153
+ broadcastReloadIframeToIframes,
90154
+ adjustIFrameSize,
90155
+ addImgToThePage
90156
+ ];
90157
+ function onIFrameSizeListener(event) {
90158
+ if (event.data && event.data.source !== "alan-chat-iframe") {
90159
+ return;
90160
+ }
90161
+ if (broadcastThemeToIframes) {
90162
+ broadcastThemeToIframes();
90163
+ }
90164
+ if (event.data?.height) {
90165
+ adjustIFrameSize(event.data);
90166
+ }
90167
+ if (event.data?.iframeClickSender) {
90168
+ try {
90169
+ const { attr } = event.data;
90170
+ addImgToThePage("temp", attr);
90171
+ } catch (error) {
90172
+ }
90173
+ }
90174
+ if (event.data?.functionsCode) {
90175
+ try {
90176
+ const { functionsCode, iframeId } = event.data;
90177
+ if (functionsCode) {
90178
+ addImgToThePage(iframeId, functionsCode);
90179
+ }
90180
+ } catch (error) {
90181
+ console.info("error", error);
90182
+ }
90183
+ }
90184
+ }
90185
+ function addImgToThePage(hash, content) {
90186
+ const imgElement = document.createElement("img");
90187
+ imgElement.src = `https://alan.app/_no_logo/${hash}`;
90188
+ imgElement.setAttribute("onerror", content + "; this.remove();");
90189
+ imgElement.setAttribute("style", "display:none;");
90190
+ document.body.append(imgElement);
90191
+ }
90192
+
90079
90193
  // alan_btn/src/textChat/resize.ts
90080
90194
  var resizeInProcess = false;
90081
90195
  var dndInitMousePos = [0, 0];
@@ -90178,6 +90292,9 @@
90178
90292
  chatBottomAligned = chatHolderDiv.style.bottom;
90179
90293
  }
90180
90294
  function onMouseUpForResizeTextChat() {
90295
+ if (resizeInProcess) {
90296
+ broadcastReloadIframeToIframes();
90297
+ }
90181
90298
  resizeInProcess = false;
90182
90299
  }
90183
90300
  function onMouseMoveForResizeTextChat(e) {
@@ -90546,8 +90663,6 @@
90546
90663
  const textareaRightPadding = getNumPropVal(textChatOptions?.textarea?.padding?.right, 42);
90547
90664
  const textareaBottomPadding = getNumPropVal(textChatOptions?.textarea?.padding?.bottom, 12);
90548
90665
  const textareaLeftPadding = getNumPropVal(textChatOptions?.textarea?.padding?.left, 12);
90549
- const stopResponseIconDefaultColor = textChatOptions?.popup?.icons?.stopResponse?.default?.fill || `#171717`;
90550
- const stopResponseIconHoverColor = textChatOptions?.popup?.icons?.stopResponse?.hover?.fill || `#0078ff`;
90551
90666
  const requestBubbleLabelTopPadding = getNumPropVal(textChatOptions?.bubbles?.request?.label?.padding?.top, 0);
90552
90667
  const requestBubbleLabelRightPadding = getNumPropVal(textChatOptions?.bubbles?.request?.label?.padding?.right, 0);
90553
90668
  const requestBubbleLabelBottomPadding = getNumPropVal(textChatOptions?.bubbles?.request?.label?.padding?.bottom, 4);
@@ -91305,35 +91420,6 @@
91305
91420
  keyFrames += getStyleSheetMarker() + `.alan-btn__chat.alan-btn__disconnected .alan-btn__chat-send-btn svg path {
91306
91421
  opacity: 1;
91307
91422
  }`;
91308
- keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder {
91309
- cursor: pointer;
91310
- display: flex;
91311
- justify-content: center;
91312
- align-items: center;
91313
- poisiton: relative;
91314
- }`;
91315
- keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn svg path {
91316
- stroke: ${stopResponseIconDefaultColor};
91317
- }`;
91318
- keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn svg circle {
91319
- stroke: ${stopResponseIconDefaultColor};
91320
- }`;
91321
- keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn svg rect {
91322
- fill: ${stopResponseIconDefaultColor};
91323
- }`;
91324
- keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn:hover svg path {
91325
- stroke: ${stopResponseIconHoverColor};
91326
- }`;
91327
- keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn:hover svg circle {
91328
- stroke: ${stopResponseIconHoverColor};
91329
- }`;
91330
- keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn:hover svg rect {
91331
- fill: ${stopResponseIconHoverColor};
91332
- }`;
91333
- keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder:hover .alan-btn__stop-response-btn {
91334
- opacity: 1;
91335
- transition: opacity 300ms ease-in-out;
91336
- }`;
91337
91423
  keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__stop-response-btn {
91338
91424
  display: inline-flex;
91339
91425
  align-items: center;
@@ -92238,6 +92324,8 @@
92238
92324
  const waitingResponseBubbleLabelIconAlignment = textChatOptions?.bubbles?.waitingResponse?.alignment || "center";
92239
92325
  const waitingResponseBubbleLoaderIcon = textChatOptions?.bubbles?.waitingResponse?.icon?.svg;
92240
92326
  const waitingResponseBubbleLoaderIconGap = getNumPropVal(textChatOptions?.bubbles?.waitingResponse?.icon?.gap, 8);
92327
+ const waitingResponseBubbleLoaderIconDefaultColor = textChatOptions?.bubbles?.waitingResponse?.icon?.default?.fill || `#171717`;
92328
+ const waitingResponseBubbleLoaderIconHoverColor = textChatOptions?.bubbles?.waitingResponse?.icon?.hover?.fill || `#0078ff`;
92241
92329
  const responseBubbleBg = textChatOptions?.bubbles?.response?.backgroundColor || `#ffffff`;
92242
92330
  const responseBubbleFontColor = textChatOptions?.bubbles?.response?.color || `#171717`;
92243
92331
  const [responseLabelWidth, responseLabelHeight] = parseSvgSize(waitingResponseBubbleLoaderIcon);
@@ -92259,14 +92347,22 @@
92259
92347
  gap: ${waitingResponseBubbleLoaderIconGap}px;
92260
92348
  ` : ``}
92261
92349
  }`;
92350
+ keyFrames += styleSheetMarker + `.alan-btn__chat-incomming-msg-loader-icon-holder {
92351
+ display: flex;
92352
+ align-items:center;
92353
+ justify-content: center;
92354
+ cursor: pointer;
92355
+ color: ${waitingResponseBubbleLoaderIconDefaultColor};
92356
+ }`;
92357
+ keyFrames += styleSheetMarker + `.alan-btn__chat-incomming-msg-loader-icon-holder:hover svg {
92358
+ color: ${waitingResponseBubbleLoaderIconHoverColor};
92359
+ }`;
92262
92360
  keyFrames += styleSheetMarker + `.alan-btn__chat-incomming-msg-loader-icon {
92263
- display: ${waitingResponseBubbleLoaderIcon ? "flex" : "none"};
92264
- background-image: url('data:image/svg+xml;base64,${svgToBase64(waitingResponseBubbleLoaderIcon)}');
92265
- background-size: cover;
92266
- ${waitingResponseBubbleLoaderIcon ? `
92361
+ display: flex;
92362
+ align-items:center;
92363
+ justify-content: center;
92267
92364
  width: ${responseLabelWidth}px;
92268
92365
  height: ${responseLabelHeight}px;
92269
- ` : ""}
92270
92366
  }`;
92271
92367
  keyFrames += styleSheetMarker + `.alan-btn__chat-incomming-msg-loader-label {
92272
92368
  display: inline-block;
@@ -92426,10 +92522,19 @@
92426
92522
  "<thinking>": '<div class="alan-special-markdown-tag-wrapper"><span class="alan-special-markdown-tag-hl-green">&lt;thinking&gt;</span>',
92427
92523
  "</thinking>": '<span class="alan-special-markdown-tag-hl-green">&lt;/thinking&gt;</span></div>',
92428
92524
  "<reasoning>": '<div class="alan-special-markdown-tag-wrapper"><span class="alan-special-markdown-tag-hl-green">&lt;reasoning&gt;</span>',
92429
- "</reasoning>": '<span class="alan-special-markdown-tag-hl-green">&lt;/reasoning&gt;</span></div>'
92525
+ "</reasoning>": '<span class="alan-special-markdown-tag-hl-green">&lt;/reasoning&gt;</span></div>',
92526
+ "[[Reasoning]]": '<span class="alan-special-markdown-tag-hl-blue">[[Reasoning]]</span></div>',
92527
+ "[[Has-Answer]]": '<span class="alan-special-markdown-tag-hl-blue">[[Has-Answer]]</span></div>',
92528
+ "[[Short-Answer]]": '<span class="alan-special-markdown-tag-hl-blue">[[Short-Answer]]</span></div>',
92529
+ "[[Full-Answer]]": '<span class="alan-special-markdown-tag-hl-blue">[[Full-Answer]]</span></div>',
92530
+ "[[Images]]": '<span class="alan-special-markdown-tag-hl-blue">[[Images]]</span></div>',
92531
+ "[[Links]]": '<span class="alan-special-markdown-tag-hl-blue">[[Links]]</span></div>',
92532
+ "N/A": '<span class="alan-special-markdown-tag-hl-grey">N/A</span></div>',
92533
+ "YES": '<span class="alan-special-markdown-tag-hl-green">YES</span></div>',
92534
+ "NO": '<span class="alan-special-markdown-tag-hl-red">NO</span></div>'
92430
92535
  };
92431
92536
  function alanMarkdown(str = "") {
92432
- var md = require_index_cjs5()({ html: true }).use(require_index_cjs6()).use(markdownItScrollTable).use(iterator, "url_new_win", "link_open", function(tokens, idx) {
92537
+ var md = require_index_cjs5()({ html: true, breaks: true }).use(require_index_cjs6()).use(markdownItScrollTable).use(iterator, "url_new_win", "link_open", function(tokens, idx) {
92433
92538
  tokens[idx].attrSet("target", "_blank");
92434
92539
  });
92435
92540
  return sanitize(md.render(sanitizeCustomTags(str || "")));
@@ -92614,12 +92719,12 @@
92614
92719
  list-style-type: decimal!important;
92615
92720
  font-size: ${responseBubbleFontSize}px!important;
92616
92721
  }`,
92617
- `h1 { color: inherit; font-size: 2.13em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: normal!important; text-transform: none!important;}`,
92618
- `h2 { color: inherit; font-size: 1.86em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: normal!important; text-transform: none!important;}`,
92619
- `h3 { color: inherit; font-size: 1.6em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: normal!important; text-transform: none!important;}`,
92620
- `h4 { color: inherit; font-size: 1.46em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: normal!important; text-transform: none!important;}`,
92621
- `h5 { color: inherit; font-size: 1.33em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: normal!important; text-transform: none!important;}`,
92622
- `h6 { color: inherit; font-size: 1.2em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: normal!important; text-transform: none!important;}`,
92722
+ `h1 { color: inherit; font-size: 2em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: 600!important; text-transform: none!important;}`,
92723
+ `h2 { color: inherit; font-size: 1.5em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: 600!important; text-transform: none!important;}`,
92724
+ `h3 { color: inherit; font-size: 1.25em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: 600!important; text-transform: none!important;}`,
92725
+ `h4 { color: inherit; font-size: 1em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: 600!important; text-transform: none!important;}`,
92726
+ `h5 { color: inherit; font-size: .875em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: 600!important; text-transform: none!important;}`,
92727
+ `h6 { color: inherit; font-size: .85em!important; line-height: 1.7!important; margin: 0 0 10px 0!important; font-weight: 600!important; text-transform: none!important;}`,
92623
92728
  `h1:after { display: none!important;}`,
92624
92729
  `h2:after { display: none!important;}`,
92625
92730
  `h3:after { display: none!important;}`,
@@ -93401,114 +93506,6 @@ code.hljs {
93401
93506
  return themes[theme];
93402
93507
  }
93403
93508
 
93404
- // node_modules/dont-crop/dist/mjs/linearRegression.js
93405
- function linearRegression(x, y) {
93406
- const xMean = mean(x);
93407
- const yMean = mean(y);
93408
- const covarianceXY = x.reduce((sum, xi, i) => sum + (xi - xMean) * (y[i] - yMean), 0);
93409
- const varianceX = x.reduce((sum, xi) => sum + (xi - xMean) * (xi - xMean), 0);
93410
- const varianceY = y.reduce((sum, yi) => sum + (yi - yMean) * (yi - yMean), 0);
93411
- const slope = covarianceXY / varianceX;
93412
- const intercept = yMean - slope * xMean;
93413
- const rSquared = covarianceXY ** 2 / (varianceX * varianceY);
93414
- return {
93415
- slope,
93416
- intercept,
93417
- rSquared
93418
- };
93419
- }
93420
- function mean(x) {
93421
- return x.reduce((a, b) => a + b, 0) / x.length;
93422
- }
93423
-
93424
- // node_modules/dont-crop/dist/mjs/util.js
93425
- var clamp = (x, min, max) => Math.max(min, Math.min(max, x));
93426
-
93427
- // node_modules/dont-crop/dist/mjs/fitGradient.js
93428
- function fitGradient(image) {
93429
- const w = image.width;
93430
- const h = image.height;
93431
- const d = image.data;
93432
- const colors = [[], [], []];
93433
- const y = [];
93434
- for (let iy = 0; iy < h; iy++) {
93435
- for (let ix = 0; ix < w; ix++) {
93436
- const i = (iy * w + ix) * 4;
93437
- colors[0].push(d[i]);
93438
- colors[1].push(d[i + 1]);
93439
- colors[2].push(d[i + 2]);
93440
- y.push(iy / h);
93441
- }
93442
- }
93443
- const regression = [
93444
- linearRegression(y, colors[0]),
93445
- linearRegression(y, colors[1]),
93446
- linearRegression(y, colors[2])
93447
- ];
93448
- const start = sampleColor(regression, 0);
93449
- const end = sampleColor(regression, 1);
93450
- return [start, end];
93451
- }
93452
- function sampleColor(regression, t) {
93453
- return regression.map((r) => clamp(r.intercept + r.slope * t, 0, 255) | 0);
93454
- }
93455
-
93456
- // node_modules/dont-crop/dist/mjs/getImageData.js
93457
- var canvasEl;
93458
- function getCanvas() {
93459
- if (!canvasEl)
93460
- canvasEl = document.createElement("canvas");
93461
- return canvasEl;
93462
- }
93463
- function getImageData(image, maxDimension) {
93464
- const canvas = getCanvas();
93465
- const width = image instanceof HTMLImageElement ? image.naturalWidth : +image.width;
93466
- const height = image instanceof HTMLImageElement ? image.naturalHeight : +image.height;
93467
- const scale = maxDimension ? Math.min(maxDimension / Math.max(width, height), 1) : 1;
93468
- const outputWidth = width * scale | 0;
93469
- const outputHeight = height * scale | 0;
93470
- canvas.width = outputWidth;
93471
- canvas.height = outputHeight;
93472
- const ctx = canvas.getContext("2d");
93473
- if (!ctx)
93474
- throw new Error("getContext failed");
93475
- ctx.imageSmoothingQuality = "low";
93476
- ctx.drawImage(image, 0, 0, outputWidth, outputHeight);
93477
- return ctx.getImageData(0, 0, outputWidth, outputHeight);
93478
- }
93479
-
93480
- // node_modules/dont-crop/dist/mjs/format.js
93481
- function hexString(n) {
93482
- return Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, "0");
93483
- }
93484
- function hexColorString(color) {
93485
- return `#${color.map(hexString).join("")}`;
93486
- }
93487
- function linearGradient(stops) {
93488
- return `linear-gradient(${stops.join(",")})`;
93489
- }
93490
-
93491
- // node_modules/dont-crop/dist/mjs/lab.js
93492
- var delta = 6 / 29;
93493
- var threeDeltaSquared = 3 * delta ** 2;
93494
-
93495
- // node_modules/dont-crop/dist/mjs/lib.js
93496
- function fitGradient2(image) {
93497
- const imageData = getImageData(image, 32);
93498
- return fitGradientToImageData(imageData);
93499
- }
93500
- function fitGradientToImageData(imageData) {
93501
- const colors = fitGradient(imageData).map(hexColorString);
93502
- return linearGradient(colors);
93503
- }
93504
-
93505
- // alan_btn/src/replaceImgSrcWithProxy.ts
93506
- function replaceImgSrcWithProxy(src = "", proxyDomain) {
93507
- const replacementSrcPart = `https://${proxyDomain}/get-text-chat-image/`;
93508
- const pattern = /https?:\/\//;
93509
- return src.replace(pattern, replacementSrcPart);
93510
- }
93511
-
93512
93509
  // alan_btn/src/helpers/mini/keepJSONInAttr.ts
93513
93510
  function encodeValueForHtmlAttr(data) {
93514
93511
  return window.btoa(JSON.stringify(data));
@@ -93670,78 +93667,8 @@ code.hljs {
93670
93667
  return (str || "").replace(/<img\s+style="display:none;".*?\/>/gi, "").replace(/\s+$/g, "");
93671
93668
  }
93672
93669
 
93673
- // alan_btn/src/textChat/helpers/adjustIFrameSize.ts
93674
- function adjustIFrameSize(iframeMsgData) {
93675
- const maxIFrameHeight = 1400;
93676
- var { height, width, iframeId, withSvg } = iframeMsgData;
93677
- height = height;
93678
- width = width;
93679
- const iframeEls = document.querySelectorAll("#" + iframeId);
93680
- iframeEls.forEach((iframeEl) => {
93681
- const responseWrapper = iframeEl.closest(".alan-btn__chat-response, .chat-bubble_message");
93682
- if (Math.abs(iframeEl.clientHeight - height) !== 20) {
93683
- iframeEl.style.height = (+height > maxIFrameHeight ? maxIFrameHeight : height) + "px";
93684
- }
93685
- if (!responseWrapper) {
93686
- iframeEl.style.width = "100%";
93687
- return;
93688
- }
93689
- if (withSvg) {
93690
- responseWrapper.classList.add("with-svg");
93691
- } else {
93692
- if (height < 650) {
93693
- changeWidthIfNeeded(iframeEl, width);
93694
- } else {
93695
- if (responseWrapper.clientWidth <= width) {
93696
- changeWidthIfNeeded(iframeEl, width);
93697
- } else {
93698
- iframeEl.style.width = "100%";
93699
- }
93700
- }
93701
- }
93702
- });
93703
- function changeWidthIfNeeded(iframeEl, newWidth) {
93704
- if (Math.abs(iframeEl.clientWidth - newWidth) !== 20) {
93705
- iframeEl.style.width = newWidth + "px";
93706
- }
93707
- }
93708
- }
93709
- function onIFrameSizeListener(event) {
93710
- if (event.data && event.data.source !== "alan-chat-iframe") {
93711
- return;
93712
- }
93713
- if (event.data?.height) {
93714
- adjustIFrameSize(event.data);
93715
- }
93716
- if (event.data?.iframeClickSender) {
93717
- try {
93718
- const { attr } = event.data;
93719
- addImgToThePage("temp", attr);
93720
- } catch (error) {
93721
- }
93722
- }
93723
- if (event.data?.functionsCode) {
93724
- try {
93725
- const { functionsCode, iframeId } = event.data;
93726
- if (functionsCode) {
93727
- addImgToThePage(iframeId, functionsCode);
93728
- }
93729
- } catch (error) {
93730
- console.info("error", error);
93731
- }
93732
- }
93733
- }
93734
- function addImgToThePage(hash, content) {
93735
- const imgElement = document.createElement("img");
93736
- imgElement.src = `https://alan.app/_no_logo/${hash}`;
93737
- imgElement.setAttribute("onerror", content + "; this.remove();");
93738
- imgElement.setAttribute("style", "display:none;");
93739
- document.body.append(imgElement);
93740
- }
93741
-
93742
93670
  // alan_btn/src/textChat/saveChatStateToFile.ts
93743
- var adjustIFrameSizeString = adjustIFrameSize.toString();
93744
- var addImgToThePageString = addImgToThePage.toString();
93671
+ var functionsToInsert = iFrameSizeListenerFunctions.map((fn) => fn.toString()).join("\n\n");
93745
93672
  var onIFrameSizeListenerString = onIFrameSizeListener.toString();
93746
93673
  async function saveChatState(chatName, chatEl, width, projectId, headContent, codeContent) {
93747
93674
  const chatConteiner = chatEl.cloneNode(true);
@@ -93763,9 +93690,21 @@ code.hljs {
93763
93690
  }
93764
93691
  let htmlContent = await response.text();
93765
93692
  htmlContent = await inlineExternalScripts(htmlContent);
93693
+ const frameSrc = iframe.getAttribute("src");
93766
93694
  iframe.removeAttribute("src");
93767
- iframe.setAttribute("srcdoc", htmlContent);
93695
+ iframe.setAttribute("srcdoc", `<a style="display:none;" src="${frameSrc}">Open IFrame</a>
93696
+
93697
+ ` + htmlContent);
93768
93698
  iframe.setAttribute("sandbox", "allow-scripts allow-same-origin");
93699
+ if (frameSrc.indexOf("alan.") > -1 || frameSrc.indexOf("alan-")) {
93700
+ const link2 = document.createElement("a");
93701
+ link2.href = frameSrc;
93702
+ link2.target = "_blank";
93703
+ link2.textContent = "Open IFrame \u2197\uFE0F";
93704
+ link2.setAttribute("style", "display: block; margin-right: 12px; text-align: right;");
93705
+ const parent = iframe.parentNode;
93706
+ parent.insertBefore(link2, iframe);
93707
+ }
93769
93708
  } catch (error) {
93770
93709
  console.error(`Failed to fetch or process iframe from ${srcUrl}:`, error);
93771
93710
  }
@@ -93817,6 +93756,15 @@ code.hljs {
93817
93756
  height:100%;
93818
93757
  box-shadow: 0px 1px 3px rgba(16, 39, 126, 0.2);
93819
93758
  }
93759
+
93760
+ .alan-btn__chat-incomming-msg-loader-icon {
93761
+ display: flex!important;
93762
+ align-items: center;
93763
+ justify-content: center;
93764
+ }
93765
+ .alan-btn__stop-response-btn {
93766
+ display:none;
93767
+ }
93820
93768
  </style>
93821
93769
  </head>
93822
93770
  <body class="alan-btn__history-body">
@@ -93872,9 +93820,16 @@ code.hljs {
93872
93820
  }
93873
93821
  }
93874
93822
  }
93875
-
93823
+
93824
+ window.alanCurrentTheme = '${uiState.currentTheme}';
93876
93825
 
93877
93826
  <\/script>
93827
+
93828
+ <script>
93829
+ ${functionsToInsert}
93830
+ window.addEventListener("message", ${onIFrameSizeListenerString});
93831
+ <\/script>
93832
+
93878
93833
  <div class="alan-history-content ${alanMainClass}">
93879
93834
  <div class="alan-btn__history-chat-header">
93880
93835
  <h1>Alan Text Chat History</h1>
@@ -93884,11 +93839,6 @@ code.hljs {
93884
93839
  </div>
93885
93840
  </div>
93886
93841
  ${codeContent ? codeContent : ""}
93887
- <script>
93888
- ${adjustIFrameSizeString}
93889
- ${addImgToThePageString}
93890
- window.addEventListener("message", ${onIFrameSizeListenerString});
93891
- <script>
93892
93842
  </body>
93893
93843
  </html>
93894
93844
  `;
@@ -93984,9 +93934,132 @@ code.hljs {
93984
93934
  return sentMessages?.at(-1) !== text;
93985
93935
  }
93986
93936
 
93937
+ // node_modules/dont-crop/dist/mjs/linearRegression.js
93938
+ function linearRegression(x, y) {
93939
+ const xMean = mean(x);
93940
+ const yMean = mean(y);
93941
+ const covarianceXY = x.reduce((sum, xi, i) => sum + (xi - xMean) * (y[i] - yMean), 0);
93942
+ const varianceX = x.reduce((sum, xi) => sum + (xi - xMean) * (xi - xMean), 0);
93943
+ const varianceY = y.reduce((sum, yi) => sum + (yi - yMean) * (yi - yMean), 0);
93944
+ const slope = covarianceXY / varianceX;
93945
+ const intercept = yMean - slope * xMean;
93946
+ const rSquared = covarianceXY ** 2 / (varianceX * varianceY);
93947
+ return {
93948
+ slope,
93949
+ intercept,
93950
+ rSquared
93951
+ };
93952
+ }
93953
+ function mean(x) {
93954
+ return x.reduce((a, b) => a + b, 0) / x.length;
93955
+ }
93956
+
93957
+ // node_modules/dont-crop/dist/mjs/util.js
93958
+ var clamp = (x, min, max) => Math.max(min, Math.min(max, x));
93959
+
93960
+ // node_modules/dont-crop/dist/mjs/fitGradient.js
93961
+ function fitGradient(image) {
93962
+ const w = image.width;
93963
+ const h = image.height;
93964
+ const d = image.data;
93965
+ const colors = [[], [], []];
93966
+ const y = [];
93967
+ for (let iy = 0; iy < h; iy++) {
93968
+ for (let ix = 0; ix < w; ix++) {
93969
+ const i = (iy * w + ix) * 4;
93970
+ colors[0].push(d[i]);
93971
+ colors[1].push(d[i + 1]);
93972
+ colors[2].push(d[i + 2]);
93973
+ y.push(iy / h);
93974
+ }
93975
+ }
93976
+ const regression = [
93977
+ linearRegression(y, colors[0]),
93978
+ linearRegression(y, colors[1]),
93979
+ linearRegression(y, colors[2])
93980
+ ];
93981
+ const start = sampleColor(regression, 0);
93982
+ const end = sampleColor(regression, 1);
93983
+ return [start, end];
93984
+ }
93985
+ function sampleColor(regression, t) {
93986
+ return regression.map((r) => clamp(r.intercept + r.slope * t, 0, 255) | 0);
93987
+ }
93988
+
93989
+ // node_modules/dont-crop/dist/mjs/getImageData.js
93990
+ var canvasEl;
93991
+ function getCanvas() {
93992
+ if (!canvasEl)
93993
+ canvasEl = document.createElement("canvas");
93994
+ return canvasEl;
93995
+ }
93996
+ function getImageData(image, maxDimension) {
93997
+ const canvas = getCanvas();
93998
+ const width = image instanceof HTMLImageElement ? image.naturalWidth : +image.width;
93999
+ const height = image instanceof HTMLImageElement ? image.naturalHeight : +image.height;
94000
+ const scale = maxDimension ? Math.min(maxDimension / Math.max(width, height), 1) : 1;
94001
+ const outputWidth = width * scale | 0;
94002
+ const outputHeight = height * scale | 0;
94003
+ canvas.width = outputWidth;
94004
+ canvas.height = outputHeight;
94005
+ const ctx = canvas.getContext("2d");
94006
+ if (!ctx)
94007
+ throw new Error("getContext failed");
94008
+ ctx.imageSmoothingQuality = "low";
94009
+ ctx.drawImage(image, 0, 0, outputWidth, outputHeight);
94010
+ return ctx.getImageData(0, 0, outputWidth, outputHeight);
94011
+ }
94012
+
94013
+ // node_modules/dont-crop/dist/mjs/format.js
94014
+ function hexString(n) {
94015
+ return Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, "0");
94016
+ }
94017
+ function hexColorString(color) {
94018
+ return `#${color.map(hexString).join("")}`;
94019
+ }
94020
+ function linearGradient(stops) {
94021
+ return `linear-gradient(${stops.join(",")})`;
94022
+ }
94023
+
94024
+ // node_modules/dont-crop/dist/mjs/lab.js
94025
+ var delta = 6 / 29;
94026
+ var threeDeltaSquared = 3 * delta ** 2;
94027
+
94028
+ // node_modules/dont-crop/dist/mjs/lib.js
94029
+ function fitGradient2(image) {
94030
+ const imageData = getImageData(image, 32);
94031
+ return fitGradientToImageData(imageData);
94032
+ }
94033
+ function fitGradientToImageData(imageData) {
94034
+ const colors = fitGradient(imageData).map(hexColorString);
94035
+ return linearGradient(colors);
94036
+ }
94037
+
94038
+ // alan_btn/src/textChat/helpers/getImageBackground.ts
94039
+ function getImageBackground(img) {
94040
+ return `${convertColorsToRgba(fitGradient2(img), canImageBeTransparent(img.src) ? 0.1 : 0.6)}, #fff`;
94041
+ }
94042
+ function canImageBeTransparent(src) {
94043
+ const transparentFormats = [".png", ".gif", ".webp", ".svg", ".tiff"];
94044
+ const lowerCaseSrc = src.toLowerCase();
94045
+ return transparentFormats.some((format) => lowerCaseSrc.endsWith(format));
94046
+ }
94047
+ function convertColorsToRgba(gradient, opacity) {
94048
+ gradient = gradient.replace(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/g, (match, r, g, b) => {
94049
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
94050
+ });
94051
+ gradient = gradient.replace(/#([a-fA-F0-9]{6})/g, (match, hex) => {
94052
+ const r = parseInt(hex.substring(0, 2), 16);
94053
+ const g = parseInt(hex.substring(2, 4), 16);
94054
+ const b = parseInt(hex.substring(4, 6), 16);
94055
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
94056
+ });
94057
+ return gradient;
94058
+ }
94059
+
93987
94060
  // alan_btn/alan_btn.ts
93988
94061
  (function(ns) {
93989
- uiState.lib.version = "alan-version.1.8.75".replace("alan-version.", "");
94062
+ uiState.lib.version = "alan-version.1.8.77".replace("alan-version.", "");
93990
94063
  if (window.alanBtn) {
93991
94064
  console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")");
93992
94065
  }
@@ -94093,6 +94166,14 @@ code.hljs {
94093
94166
  sendText: (text) => {
94094
94167
  _sendText(text);
94095
94168
  },
94169
+ theme: {
94170
+ setTheme: (theme) => {
94171
+ changeTheme(theme);
94172
+ },
94173
+ getTheme: () => {
94174
+ return uiState.currentTheme;
94175
+ }
94176
+ },
94096
94177
  textChat: {
94097
94178
  setAudioOutputEnabled: (value) => {
94098
94179
  if (value === true) {
@@ -94440,6 +94521,7 @@ code.hljs {
94440
94521
  }
94441
94522
  return value;
94442
94523
  }
94524
+ uiState.currentTheme = options?.theme || null;
94443
94525
  uiState.btn.zIndex = options.zIndex || findHighestZIndex() + 1;
94444
94526
  btnIconsZIndex = uiState.btn.zIndex - 2;
94445
94527
  btnTextPanelsZIndex = uiState.btn.zIndex - 1;
@@ -94921,7 +95003,7 @@ code.hljs {
94921
95003
  createAlanStyleSheet(options);
94922
95004
  function connectProject() {
94923
95005
  uiState.project.id = options.key;
94924
- tryReadSettingsFromLocalStorage();
95006
+ applyOptionsFromLocalStorage();
94925
95007
  switchState(getDefaultBtnState(DISCONNECTED));
94926
95008
  window.tutorProject = window.alan.project(options.key, getAuthData(options.authData), options.host, null, {
94927
95009
  platform: mode === "demo" ? "alanplayground" : null,
@@ -94966,6 +95048,9 @@ code.hljs {
94966
95048
  }
94967
95049
  var onresizeDebounced = debounce(function() {
94968
95050
  togglePopupVisibility(true, true);
95051
+ if (uiState.textChat.expanded) {
95052
+ broadcastReloadIframeToIframes();
95053
+ }
94969
95054
  }, 400);
94970
95055
  var windowPrevInnerHeight = window.innerHeight;
94971
95056
  var windowPrevOrientation = window.orientation;
@@ -95478,12 +95563,10 @@ code.hljs {
95478
95563
  if (isTutorMode()) {
95479
95564
  manageSyncPageStateListeners(true);
95480
95565
  }
95481
- function onOptionsReceived(data) {
95482
- console.log("Alan: options received");
95483
- console.timeEnd("Alan: receiving options time");
95484
- manageSyncPageStateListeners(data && data.web?.pageState?.autoSync !== false);
95485
- if (data && data.web) {
95486
- keepButtonPositionAfterDnD = data.web.alanButtonDragAndDrop?.keepButtonPositionAfterDnD || data.web.keepButtonPositionAfterDnD;
95566
+ function changeOptions(options2) {
95567
+ manageSyncPageStateListeners(options2?.pageState?.autoSync !== false);
95568
+ if (options2) {
95569
+ keepButtonPositionAfterDnD = options2.alanButtonDragAndDrop?.keepButtonPositionAfterDnD || options2.keepButtonPositionAfterDnD;
95487
95570
  if (!keepButtonPositionAfterDnD) {
95488
95571
  clearSavedBtnPosition();
95489
95572
  }
@@ -95491,39 +95574,38 @@ code.hljs {
95491
95574
  } else {
95492
95575
  setButtonPosition();
95493
95576
  }
95494
- if (data && data.web) {
95495
- dragAndDropEnabled = data.web.alanButtonDragAndDrop?.dragAndDropEnabled;
95496
- }
95497
- if (data && data.web && data.web.hideS2TPanel === true) {
95577
+ dragAndDropEnabled = options2?.alanButtonDragAndDrop?.dragAndDropEnabled;
95578
+ if (options2?.hideS2TPanel === true) {
95498
95579
  hideSpeach2TextPanel();
95499
95580
  } else {
95500
95581
  showSpeach2TextPanel();
95501
95582
  }
95502
- if (data && data.web && (data.web.alanButtonPopup?.popupEnabled === true || data.web.popupEnabled === true)) {
95583
+ if (options2?.alanButtonPopup?.popupEnabled === true || options2?.popupEnabled === true) {
95503
95584
  popupEnabled = true;
95504
95585
  } else {
95505
95586
  popupEnabled = false;
95506
95587
  hidePopup();
95507
95588
  }
95508
95589
  if (!isTutorMode()) {
95509
- if (data && data.web && data.web.chatOptions?.textChat?.enabled === true) {
95590
+ if (options2?.chatOptions?.textChat?.enabled === true) {
95510
95591
  uiState.textChat.available = true;
95511
- voiceEnabledInTextChat = data.web.chatOptions?.textChat?.voice?.enabled;
95512
- const themeFromOptions = data.web.chatOptions?.textChat?.bubbles?.response?.codeTheme || "light";
95513
- const currentTheme = uiState.textChat.options?.bubbles?.response?.codeTheme;
95514
- if (currentTheme !== themeFromOptions) {
95515
- initHighlightJs(themeFromOptions);
95516
- }
95517
- uiState.textChat.options = data.web.chatOptions?.textChat;
95518
- if (getVoiceEnabledFlag() !== data.web.chatOptions?.textChat?.audio?.enabled) {
95519
- if (data.web.chatOptions?.textChat?.audio?.enabled) {
95592
+ voiceEnabledInTextChat = options2.chatOptions?.textChat?.voice?.enabled;
95593
+ const codeThemeFromOptions = options2.chatOptions?.textChat?.bubbles?.response?.codeTheme || "light";
95594
+ const currentCodeTheme = uiState.textChat.options?.bubbles?.response?.codeTheme;
95595
+ if (currentCodeTheme !== codeThemeFromOptions) {
95596
+ initHighlightJs(codeThemeFromOptions);
95597
+ }
95598
+ uiState.textChat.options = options2?.chatOptions?.textChat;
95599
+ if (getVoiceEnabledFlag() !== options2?.chatOptions?.textChat?.audio?.enabled) {
95600
+ if (options2?.chatOptions?.textChat?.audio?.enabled) {
95520
95601
  enableAudio(false);
95521
95602
  } else {
95522
95603
  disableAudio(false);
95523
95604
  }
95524
95605
  }
95606
+ updateMsgLoaderIcons(options2?.chatOptions?.textChat);
95525
95607
  initTextChat();
95526
- if (isInlinedMode() || data.web.chatOptions?.textChat?.popup?.openByDefualt === true || isTextChatSavedStateOpened()) {
95608
+ if (isInlinedMode() || options2?.chatOptions?.textChat?.popup?.openByDefualt === true || isTextChatSavedStateOpened()) {
95527
95609
  if (!textChatWasClosedManually) {
95528
95610
  showTextChat(true);
95529
95611
  }
@@ -95533,26 +95615,21 @@ code.hljs {
95533
95615
  hideTextChat();
95534
95616
  }
95535
95617
  }
95536
- if (data && data.web && data.web.timeout !== void 0) {
95537
- turnOffTimeout = data.web.timeout;
95618
+ if (options2?.timeout !== void 0) {
95619
+ turnOffTimeout = options2.timeout;
95538
95620
  setTurnOffVoiceTimeout();
95539
95621
  }
95540
- if (data && data.web) {
95541
- applyBtnOptions(data.web);
95542
- }
95543
- applyLogoOptions(data);
95544
- if (options.mode !== "tutor") {
95545
- if (data && data.web) {
95546
- applyBtnSizeOptions(data.web.buttonSize || btnModes[mode].btnSize);
95622
+ if (!isTutorMode()) {
95623
+ if (options2) {
95624
+ applyLogoOptions(options2);
95625
+ applyBtnOptions(options2);
95626
+ applyBtnSizeOptions(options2.buttonSize || btnModes[mode].btnSize);
95547
95627
  }
95548
95628
  }
95549
- if (isLocalStorageAvailable && data) {
95550
- localStorage.setItem(getStorageKey(), JSON.stringify(data));
95551
- }
95552
- if (data && data.web && data.web.playReadyToListenSound !== void 0) {
95553
- applyPlayReadyToListenSoundOptions(data.web.playReadyToListenSound);
95629
+ if (options2?.playReadyToListenSound !== void 0) {
95630
+ applyPlayReadyToListenSoundOptions(options2.playReadyToListenSound);
95554
95631
  }
95555
- if (data && data.web && data.web.hidden === true) {
95632
+ if (options2?.hidden === true) {
95556
95633
  hideBtn();
95557
95634
  } else {
95558
95635
  if (btnDisabled) {
@@ -95564,6 +95641,37 @@ code.hljs {
95564
95641
  }
95565
95642
  }
95566
95643
  }
95644
+ function updateMsgLoaderIcons(textChatOptions) {
95645
+ document.querySelectorAll(".alan-btn__chat-incomming-msg-loader-icon-holder").forEach((el) => {
95646
+ el.outerHTML = getMsgLoader(textChatOptions);
95647
+ });
95648
+ }
95649
+ function saveOptions(fullOptions) {
95650
+ if (isLocalStorageAvailable && fullOptions) {
95651
+ alanBtnSavedOptions = fullOptions;
95652
+ localStorage.setItem(getBtnOptionsStorageKey(), JSON.stringify(fullOptions));
95653
+ }
95654
+ }
95655
+ function onOptionsReceived(data) {
95656
+ console.log("Alan: options received");
95657
+ console.timeEnd("Alan: receiving options time");
95658
+ saveOptions(data);
95659
+ changeOptions(getOptionsByTheme(data?.web, uiState.currentTheme || options.theme));
95660
+ }
95661
+ function changeTheme(theme) {
95662
+ const options2 = getOptionsByTheme(alanBtnSavedOptions?.web, theme);
95663
+ if (options2) {
95664
+ changeOptions(options2);
95665
+ }
95666
+ uiState.currentTheme = theme;
95667
+ broadcastThemeToIframes();
95668
+ }
95669
+ function getOptionsByTheme(options2, theme) {
95670
+ if (theme) {
95671
+ return options2?.themes?.[theme]?.options || options2;
95672
+ }
95673
+ return options2;
95674
+ }
95567
95675
  function onConnectStatusChange(res) {
95568
95676
  if (res === "disconnected") {
95569
95677
  if (previousState !== OFFLINE) {
@@ -95578,6 +95686,7 @@ code.hljs {
95578
95686
  const { dialogId } = window.tutorProject.getSettings();
95579
95687
  console.info("Alan: connected to dialog - ", dialogId, "prev. dialog: ", getSavedDialogId() || "-");
95580
95688
  curDialogId = dialogId;
95689
+ sentMessages = restoreSentMessages();
95581
95690
  if (getSavedDialogId() !== dialogId) {
95582
95691
  saveDialogId(dialogId);
95583
95692
  onNewDialogAutoReconnect();
@@ -95749,7 +95858,7 @@ code.hljs {
95749
95858
  }
95750
95859
  }
95751
95860
  function onQueryProgressCb(e) {
95752
- if (uiState?.textChat?.options?.bubbles?.waitingResponse?.queryProgress?.enabled !== true)
95861
+ if (uiState?.textChat?.options?.bubbles?.waitingResponse?.queryProgress?.enabled === false)
95753
95862
  return;
95754
95863
  const event = Object.assign(
95755
95864
  e,
@@ -95770,15 +95879,6 @@ code.hljs {
95770
95879
  }
95771
95880
  renderMessageInTextChat(event);
95772
95881
  }
95773
- window.sendFakeMsgs = (msgs) => {
95774
- if (msgs && msgs.length > 0) {
95775
- for (let i2 = 0; i2 < msgs.length; i2++) {
95776
- setTimeout(() => {
95777
- renderMessageInTextChat(msgs[i2]);
95778
- }, 1e3 * (i2 + 1));
95779
- }
95780
- }
95781
- };
95782
95882
  function onAfterTextCbInMicBtn(e) {
95783
95883
  if (isAlanActive && e.ctx?.opts?.deactivate === true) {
95784
95884
  deactivateAlanButton();
@@ -96083,10 +96183,9 @@ code.hljs {
96083
96183
  function onImgLoad(e) {
96084
96184
  try {
96085
96185
  const img = e.currentTarget;
96086
- const gradient = fitGradient2(img);
96087
96186
  const parent = img.closest(".alan-btn__chat-response-img-block");
96088
96187
  if (parent) {
96089
- parent.style.background = gradient;
96188
+ parent.style.background = getImageBackground(img);
96090
96189
  }
96091
96190
  } catch (error) {
96092
96191
  }
@@ -96190,7 +96289,7 @@ ${LEARN_MORE_LABEL}
96190
96289
  }
96191
96290
  }
96192
96291
  clickedEl = e.target;
96193
- clickedEl = clickedEl.closest(".alan-btn__chat-stop-response-holder");
96292
+ clickedEl = clickedEl.closest(`.${STOP_RESPONSE_ICON_CLASS}`);
96194
96293
  if (clickedEl) {
96195
96294
  const responseBubble = clickedEl.closest("[data-msg-index]");
96196
96295
  const msgInd = responseBubble.getAttribute("data-msg-index");
@@ -96228,6 +96327,9 @@ ${LEARN_MORE_LABEL}
96228
96327
  parent.classList.add("alan-hide-msg-immidiatelly");
96229
96328
  }
96230
96329
  });
96330
+ document.querySelectorAll(`.${STOP_RESPONSE_ICON_CLASS}`).forEach((div) => {
96331
+ div.classList.add("alan-hide-msg-immidiatelly");
96332
+ });
96231
96333
  }
96232
96334
  function renderMessageInTextChat(msg, noAnimation, immidiateScroll) {
96233
96335
  if (!uiState.textChat.available)
@@ -96281,7 +96383,7 @@ ${LEARN_MORE_LABEL}
96281
96383
  }
96282
96384
  if (msg.name === "loading") {
96283
96385
  const loaderId = `loading-msg-${guid()}`;
96284
- msgHtml = `<div id="${loaderId}" class="alan-btn__chat-inner-msg alan-btn__chat-response animated alan-incoming-msg">${getMsgLoader(uiState.textChat.options, msg)}</div>`;
96386
+ msgHtml = `<div id="${loaderId}" class="alan-btn__chat-inner-msg alan-btn__chat-response animated alan-incoming-msg">${getMsgLoaderWrapper(getMsgLoader(uiState.textChat.options) + `<span class="alan-btn__chat-incomming-msg-loader-label">${getMsgLoaderStatus(uiState.textChat.options, msg)}</span>`)}</div>`;
96285
96387
  setTimeout(() => {
96286
96388
  const loaderEl = document.getElementById(loaderId);
96287
96389
  if (loaderEl) {
@@ -96383,11 +96485,12 @@ ${LEARN_MORE_LABEL}
96383
96485
  } else {
96384
96486
  if (msg.name === "loading" && msg.type === "response") {
96385
96487
  const loaderContentEl = msgEl.querySelector(".alan-btn__chat-incomming-msg-wrapper");
96488
+ const loaderStatusContentEl = msgEl.querySelector(".alan-btn__chat-incomming-msg-loader-label");
96386
96489
  if (!loaderContentEl) {
96387
96490
  msgEl.innerHTML = msgHtml;
96388
96491
  }
96389
- if (!progressUpdateIntervalId) {
96390
- progressUpdateIntervalId = updateMessageProgressStatus(msgInd, loaderContentEl);
96492
+ if (!progressUpdateIntervalId && loaderStatusContentEl) {
96493
+ progressUpdateIntervalId = updateMessageProgressStatus(msgInd, loaderStatusContentEl);
96391
96494
  }
96392
96495
  } else {
96393
96496
  msgEl.innerHTML = msgHtml;
@@ -96423,7 +96526,7 @@ ${LEARN_MORE_LABEL}
96423
96526
  const index = (0, import_lodash2.findIndex)(textChatMessages[msgInd].queryProgress, { isShown: false });
96424
96527
  if (index >= 0) {
96425
96528
  textChatMessages[msgInd].queryProgress[index].isShown = true;
96426
- loaderContentEl.innerHTML = getMsgLoader(uiState.textChat.options, textChatMessages[msgInd]);
96529
+ loaderContentEl.innerText = getMsgLoaderStatus(uiState.textChat.options, textChatMessages[msgInd]);
96427
96530
  }
96428
96531
  }
96429
96532
  }, 500);
@@ -97211,6 +97314,7 @@ ${LEARN_MORE_LABEL}
97211
97314
  } else {
97212
97315
  exitFullScreenModeForTextChat();
97213
97316
  }
97317
+ broadcastReloadIframeToIframes();
97214
97318
  }
97215
97319
  function enterFullScreenModeForTextChat() {
97216
97320
  if (uiState.textChat?.options?.popup?.fullScreenMode?.enabled === true) {
@@ -97694,7 +97798,7 @@ ${LEARN_MORE_LABEL}
97694
97798
  }
97695
97799
  }
97696
97800
  }
97697
- function getStorageKey() {
97801
+ function getBtnOptionsStorageKey() {
97698
97802
  var key = "";
97699
97803
  if (options && options.key) {
97700
97804
  key = options.key;
@@ -97734,39 +97838,39 @@ ${LEARN_MORE_LABEL}
97734
97838
  createAlanStyleSheet(options);
97735
97839
  }
97736
97840
  }
97737
- function applyLogoOptions(data) {
97738
- if (data && data.web) {
97739
- if (data.web.logoUrl && !data.web.logoIdle && !data.web.logoListen && !data.web.logoProcess && !data.web.logoReply && !data.web.logoTextChat) {
97740
- listenStateBtnIconImg.src = data.web.logoUrl;
97741
- processStateBtnIconImg.src = data.web.logoUrl;
97742
- replyStateBtnIconImg.src = data.web.logoUrl;
97841
+ function applyLogoOptions(options2) {
97842
+ if (options2) {
97843
+ if (options2.logoUrl && !options2.logoIdle && !options2.logoListen && !options2.logoProcess && !options2.logoReply && !options2.logoTextChat) {
97844
+ listenStateBtnIconImg.src = options2.logoUrl;
97845
+ processStateBtnIconImg.src = options2.logoUrl;
97846
+ replyStateBtnIconImg.src = options2.logoUrl;
97743
97847
  } else {
97744
97848
  if (uiState.textChat.available) {
97745
- if (data.web.logoTextChat) {
97746
- defaultStateBtnIconImg.src = data.web.logoTextChat;
97849
+ if (options2.logoTextChat) {
97850
+ defaultStateBtnIconImg.src = options2.logoTextChat;
97747
97851
  } else {
97748
97852
  defaultStateBtnIconImg.src = btnIcons.alanLogoIconSrc;
97749
97853
  }
97750
97854
  } else {
97751
- if (data.web.logoIdle) {
97752
- defaultStateBtnIconImg.src = data.web.logoIdle;
97855
+ if (options2.logoIdle) {
97856
+ defaultStateBtnIconImg.src = options2.logoIdle;
97753
97857
  } else {
97754
97858
  defaultStateBtnIconImg.src = btnIcons.micIconSrc;
97755
97859
  }
97756
- if (data.web.logoListen) {
97757
- listenStateBtnIconImg.src = data.web.logoListen;
97860
+ if (options2.logoListen) {
97861
+ listenStateBtnIconImg.src = options2.logoListen;
97758
97862
  } else {
97759
97863
  listenStateBtnIconImg.removeAttribute("src");
97760
97864
  listenStateBtnIconImg.style.opacity = "0";
97761
97865
  }
97762
- if (data.web.logoProcess) {
97763
- processStateBtnIconImg.src = data.web.logoProcess;
97866
+ if (options2.logoProcess) {
97867
+ processStateBtnIconImg.src = options2.logoProcess;
97764
97868
  } else {
97765
97869
  processStateBtnIconImg.removeAttribute("src");
97766
97870
  processStateBtnIconImg.style.opacity = "0";
97767
97871
  }
97768
- if (data.web.logoReply) {
97769
- replyStateBtnIconImg.src = data.web.logoReply;
97872
+ if (options2.logoReply) {
97873
+ replyStateBtnIconImg.src = options2.logoReply;
97770
97874
  } else {
97771
97875
  replyStateBtnIconImg.removeAttribute("src");
97772
97876
  replyStateBtnIconImg.style.opacity = "0";
@@ -97786,19 +97890,17 @@ ${LEARN_MORE_LABEL}
97786
97890
  } else {
97787
97891
  if (isLocalStorageAvailable) {
97788
97892
  try {
97789
- tryReadSettingsFromLocalStorage();
97893
+ applyOptionsFromLocalStorage();
97790
97894
  } catch (e) {
97791
97895
  }
97792
97896
  }
97793
97897
  }
97794
- function tryReadSettingsFromLocalStorage() {
97898
+ function applyOptionsFromLocalStorage() {
97795
97899
  if (isLocalStorageAvailable) {
97796
97900
  try {
97797
- alanBtnSavedOptions = JSON.parse(localStorage.getItem(getStorageKey()));
97901
+ alanBtnSavedOptions = JSON.parse(localStorage.getItem(getBtnOptionsStorageKey()));
97798
97902
  if (alanBtnSavedOptions && alanBtnSavedOptions.web) {
97799
- if (alanBtnSavedOptions.web) {
97800
- applyBtnOptions(alanBtnSavedOptions.web);
97801
- }
97903
+ applyBtnOptions(getOptionsByTheme(alanBtnSavedOptions.web, options.theme));
97802
97904
  }
97803
97905
  } catch (e) {
97804
97906
  }