ai12z 3.7.1-alpha.16 → 3.7.1-alpha.17

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.
Files changed (36) hide show
  1. package/dist/cjs/ai12z-chat_2.cjs.entry.js +66 -29
  2. package/dist/cjs/ai12z-chat_2.cjs.entry.js.map +1 -1
  3. package/dist/cjs/index.cjs.js +1 -1
  4. package/dist/cjs/library.cjs.js +1 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/search-results-page.cjs.entry.js +1 -1
  7. package/dist/cjs/{search-results-view-f69cf014.js → search-results-view-edf85106.js} +15 -31
  8. package/dist/cjs/search-results-view-edf85106.js.map +1 -0
  9. package/dist/collection/components/ai12z-cta/components/Chat.js +66 -29
  10. package/dist/collection/components/ai12z-cta/components/Chat.js.map +1 -1
  11. package/dist/collection/components/ai12z-search-panel/search-results-view.js +15 -32
  12. package/dist/collection/components/ai12z-search-panel/search-results-view.js.map +1 -1
  13. package/dist/esm/ai12z-chat_2.entry.js +66 -29
  14. package/dist/esm/ai12z-chat_2.entry.js.map +1 -1
  15. package/dist/esm/index.js +1 -1
  16. package/dist/esm/library.js +1 -1
  17. package/dist/esm/loader.js +1 -1
  18. package/dist/esm/search-results-page.entry.js +1 -1
  19. package/dist/esm/{search-results-view-fd8a7c61.js → search-results-view-992c0f8c.js} +15 -31
  20. package/dist/esm/search-results-view-992c0f8c.js.map +1 -0
  21. package/dist/library/index.esm.js +1 -1
  22. package/dist/library/library.esm.js +1 -1
  23. package/dist/library/library.esm.js.map +1 -1
  24. package/dist/library/{p-cf4ba2ef.js → p-0248dcd3.js} +2 -2
  25. package/dist/library/p-0248dcd3.js.map +1 -0
  26. package/dist/library/{p-74227470.entry.js → p-552527f3.entry.js} +2 -2
  27. package/dist/library/{p-3e440e44.entry.js → p-7a61c16c.entry.js} +2 -2
  28. package/dist/library/p-7a61c16c.entry.js.map +1 -0
  29. package/dist/types/components/ai12z-cta/components/Chat.d.ts +1 -1
  30. package/dist/types/components/ai12z-search-panel/search-results-view.d.ts +0 -5
  31. package/package.json +2 -2
  32. package/dist/cjs/search-results-view-f69cf014.js.map +0 -1
  33. package/dist/esm/search-results-view-fd8a7c61.js.map +0 -1
  34. package/dist/library/p-3e440e44.entry.js.map +0 -1
  35. package/dist/library/p-cf4ba2ef.js.map +0 -1
  36. /package/dist/library/{p-74227470.entry.js.map → p-552527f3.entry.js.map} +0 -0
@@ -919,36 +919,73 @@ const MyChat = class {
919
919
  observer.observe(element, { childList: true, subtree: true });
920
920
  });
921
921
  }
922
- invokeSocket() {
923
- var _a, _b, _c;
924
- const socketId = this.socketIn.getSocketId();
925
- if (socketId) {
926
- const retrievedService = socketService.SocketService.getInstanceById(socketId);
927
- const socket = retrievedService.getSocket();
928
- const data = {
929
- apiKey: (_a = this.apiKey) !== null && _a !== void 0 ? _a : index.Env.DATA_KEY,
930
- query: this.query,
931
- conversationId: (_b = this.conversationId) !== null && _b !== void 0 ? _b : "",
932
- base64Images: ((_c = this.imgFiles) === null || _c === void 0 ? void 0 : _c.length) > 0 ? this.imgFiles : [],
933
- event: "evaluate_query",
934
- attributes: this.dataAttributes,
935
- excludeTags: this.chatExcludeTags,
936
- includeTags: this.chatIncludeTags,
937
- meta: utils.getMetaInfo(),
938
- };
939
- socket.emit("evaluate_query", data, (error, _response) => {
940
- if (error) {
941
- console.error("Error occurred while evaluating query:", error);
942
- this.aiMessageId = `chatbot-${utils.generateUUID()}`;
943
- this.chats[this.chats.length - 1].id = this.aiMessageId;
944
- this.chats[this.chats.length - 1].text = "Error connecting to server. Please try again later.";
922
+ async invokeSocket() {
923
+ var _a, _b, _c, _d;
924
+ let socketId = (_a = this.socketIn) === null || _a === void 0 ? void 0 : _a.getSocketId();
925
+ if (!socketId) {
926
+ console.error("Socket ID not available");
927
+ return;
928
+ }
929
+ let retrievedService = socketService.SocketService.getInstanceById(socketId);
930
+ // If no service found, try waiting for connection
931
+ if (!retrievedService) {
932
+ console.warn(`No socket service found for socket ID: ${socketId}, attempting to wait for connection...`);
933
+ try {
934
+ // Wait for the connection to complete
935
+ await this.socketIn.waitForConnection();
936
+ // Get the socketId again after connection
937
+ socketId = this.socketIn.getSocketId();
938
+ retrievedService = socketService.SocketService.getInstanceById(socketId);
939
+ }
940
+ catch (error) {
941
+ console.error("Failed to wait for connection:", error);
942
+ }
943
+ }
944
+ // If still no service, create a new one
945
+ if (!retrievedService) {
946
+ console.warn("Creating new socket service...");
947
+ try {
948
+ const newSocketService = socketService.SocketService.createInstance(this.env);
949
+ await newSocketService.waitForConnection();
950
+ // Update the socketIn reference
951
+ this.socketIn = newSocketService;
952
+ socketId = newSocketService.getSocketId();
953
+ retrievedService = socketService.SocketService.getInstanceById(socketId);
954
+ if (!retrievedService) {
955
+ console.error("Failed to create and retrieve new socket service");
956
+ return;
945
957
  }
946
- });
947
- // this.scrollToLatestBubble()
958
+ }
959
+ catch (error) {
960
+ console.error("Failed to create new socket service:", error);
961
+ return;
962
+ }
948
963
  }
949
- else {
950
- console.error("Socket ID not available after waiting for connection");
964
+ const socket = retrievedService.getSocket();
965
+ if (!socket) {
966
+ console.error("Socket not available from service");
967
+ return;
951
968
  }
969
+ const data = {
970
+ apiKey: (_b = this.apiKey) !== null && _b !== void 0 ? _b : index.Env.DATA_KEY,
971
+ query: this.query,
972
+ conversationId: (_c = this.conversationId) !== null && _c !== void 0 ? _c : "",
973
+ base64Images: ((_d = this.imgFiles) === null || _d === void 0 ? void 0 : _d.length) > 0 ? this.imgFiles : [],
974
+ event: "evaluate_query",
975
+ attributes: this.dataAttributes,
976
+ excludeTags: this.chatExcludeTags,
977
+ includeTags: this.chatIncludeTags,
978
+ meta: utils.getMetaInfo(),
979
+ };
980
+ socket.emit("evaluate_query", data, (error, _response) => {
981
+ if (error) {
982
+ console.error("Error occurred while evaluating query:", error);
983
+ this.aiMessageId = `chatbot-${utils.generateUUID()}`;
984
+ this.chats[this.chats.length - 1].id = this.aiMessageId;
985
+ this.chats[this.chats.length - 1].text = "Error connecting to server. Please try again later.";
986
+ }
987
+ });
988
+ // this.scrollToLatestBubble()
952
989
  }
953
990
  updateAnchorTags(htmlContent) {
954
991
  const parser = new DOMParser();
@@ -1167,7 +1204,7 @@ const MyChat = class {
1167
1204
  render() {
1168
1205
  var _a;
1169
1206
  const email = "";
1170
- return (index.h("div", { key: '1a5d6821a17399af923785d4a2de5a9fb8143feb' }, index.h("ul", { key: '633a7e548b5d6109dd236c6115728e1b9d3dc3df', id: "main-content", tabindex: "-1", class: {
1207
+ return (index.h("div", { key: 'c8697e96ee680146bd5b5fb4d5f4ceadb163a005' }, index.h("ul", { key: 'ca1ce7de27b1e095f9113c3f9330586d1bda4558', id: "main-content", tabindex: "-1", class: {
1171
1208
  "chat-list": true,
1172
1209
  "custom-list": this.componentType === "search",
1173
1210
  // "custom-chat-top-height": this.componentType === "search",
@@ -1236,7 +1273,7 @@ const MyChat = class {
1236
1273
  }
1237
1274
  // this.isPlayed = false
1238
1275
  } }, index.h("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", class: "icon-md-heavy" }, index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12ZM9.5 8.5C8.94772 8.5 8.5 8.94772 8.5 9.5V14.5C8.5 15.0523 8.94772 15.5 9.5 15.5H14.5C15.0523 15.5 15.5 15.0523 15.5 14.5V9.5C15.5 8.94772 15.0523 8.5 14.5 8.5H9.5Z", fill: "currentColor" })))), !this.isPlayed && (index.h("button", { class: "copy-btn", onClick: () => this.speakText(this.removeHtmlTags(chat.clipboard)), "aria-label": "Play", tabindex: "0" }, index.h("svg", { class: "w-6 h-6", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M11 4.9099C11 4.47485 10.4828 4.24734 10.1621 4.54132L6.67572 7.7372C6.49129 7.90626 6.25019 8.00005 6 8.00005H4C3.44772 8.00005 3 8.44776 3 9.00005V15C3 15.5523 3.44772 16 4 16H6C6.25019 16 6.49129 16.0938 6.67572 16.2629L10.1621 19.4588C10.4828 19.7527 11 19.5252 11 19.0902V4.9099ZM8.81069 3.06701C10.4142 1.59714 13 2.73463 13 4.9099V19.0902C13 21.2655 10.4142 22.403 8.81069 20.9331L5.61102 18H4C2.34315 18 1 16.6569 1 15V9.00005C1 7.34319 2.34315 6.00005 4 6.00005H5.61102L8.81069 3.06701ZM20.3166 6.35665C20.8019 6.09313 21.409 6.27296 21.6725 6.75833C22.5191 8.3176 22.9996 10.1042 22.9996 12.0001C22.9996 13.8507 22.5418 15.5974 21.7323 17.1302C21.4744 17.6185 20.8695 17.8054 20.3811 17.5475C19.8927 17.2896 19.7059 16.6846 19.9638 16.1962C20.6249 14.9444 20.9996 13.5175 20.9996 12.0001C20.9996 10.4458 20.6064 8.98627 19.9149 7.71262C19.6514 7.22726 19.8312 6.62017 20.3166 6.35665ZM15.7994 7.90049C16.241 7.5688 16.8679 7.65789 17.1995 8.09947C18.0156 9.18593 18.4996 10.5379 18.4996 12.0001C18.4996 13.3127 18.1094 14.5372 17.4385 15.5604C17.1357 16.0222 16.5158 16.1511 16.0539 15.8483C15.5921 15.5455 15.4632 14.9255 15.766 14.4637C16.2298 13.7564 16.4996 12.9113 16.4996 12.0001C16.4996 10.9859 16.1653 10.0526 15.6004 9.30063C15.2687 8.85905 15.3578 8.23218 15.7994 7.90049Z", fill: "currentColor" })))), index.h("button", { class: "copy-btn", onClick: () => this.copyToClipboard(chat.clipboard), "aria-label": "Copy to Clipboard", tabindex: "0" }, !this.copied && (index.h("svg", { class: "w-6 h-6", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M7 5C7 3.34315 8.34315 2 10 2H19C20.6569 2 22 3.34315 22 5V14C22 15.6569 20.6569 17 19 17H17V19C17 20.6569 15.6569 22 14 22H5C3.34315 22 2 20.6569 2 19V10C2 8.34315 3.34315 7 5 7H7V5ZM9 7H14C15.6569 7 17 8.34315 17 10V15H19C19.5523 15 20 14.5523 20 14V5C20 4.44772 19.5523 4 19 4H10C9.44772 4 9 4.44772 9 5V7ZM5 9C4.44772 9 4 9.44772 4 10V19C4 19.5523 4.44772 20 5 20H14C14.5523 20 15 19.5523 15 19V10C15 9.44772 14.5523 9 14 9H5Z", fill: "currentColor" }))), this.copied && (index.h("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", class: "w-6 h-6" }, index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M19.8198 6.19526C20.0601 6.45561 20.0601 6.87772 19.8198 7.13807L9.9736 17.8047C9.73328 18.0651 9.34364 18.0651 9.10332 17.8047L4.18024 12.4714C3.93992 12.2111 3.93992 11.7889 4.18024 11.5286C4.42056 11.2682 4.8102 11.2682 5.05053 11.5286L9.53846 16.3905L18.9495 6.19526C19.1898 5.93491 19.5794 5.93491 19.8198 6.19526Z", fill: "currentColor" })))), index.h("button", { id: `thumbsUp_${chat.thumbsId}`, onClick: () => this.thumbsUp(chat.thumbsId, chat.insightId), class: "chat-thumbs-up", "aria-label": "Thumbs Up", tabindex: "0" }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", class: "w-6 h-6" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6.633 10.25c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 0 1 2.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 0 0 .322-1.672V2.75a.75.75 0 0 1 .75-.75 2.25 2.25 0 0 1 2.25 2.25c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282m0 0h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 0 1-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 0 0-1.423-.23H5.904m10.598-9.75H14.25M5.904 18.5c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 0 1-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 9.953 4.167 9.5 5 9.5h1.053c.472 0 .745.556.5.96a8.958 8.958 0 0 0-1.302 4.665c0 1.194.232 2.333.654 3.375Z" }))), index.h("button", { id: `thumbsDown_${chat.thumbsId}`, onClick: () => this.thumbsDown(chat.thumbsId, chat.insightId), class: "chat-thumbs-up", "aria-label": "Thumbs Down", tabindex: "0" }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", class: "w-6 h-6" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M7.498 15.25H4.372c-1.026 0-1.945-.694-2.054-1.715a12.137 12.137 0 0 1-.068-1.285c0-2.848.992-5.464 2.649-7.521C5.287 4.247 5.886 4 6.504 4h4.016a4.5 4.5 0 0 1 1.423.23l3.114 1.04a4.5 4.5 0 0 0 1.423.23h1.294M7.498 15.25c.618 0 .991.724.725 1.282A7.471 7.471 0 0 0 7.5 19.75 2.25 2.25 0 0 0 9.75 22a.75.75 0 0 0 .75-.75v-.633c0-.573.11-1.14.322-1.672.304-.76.93-1.33 1.653-1.715a9.04 9.04 0 0 0 2.86-2.4c.498-.634 1.226-1.08 2.032-1.08h.384m-10.253 1.5H9.7m8.075-9.75c.01.05.027.1.05.148.593 1.2.925 2.55.925 3.977 0 1.487-.36 2.89-.999 4.125m.023-8.25c-.076-.365.183-.75.575-.75h.908c.889 0 1.713.518 1.972 1.368.339 1.11.521 2.287.521 3.507 0 1.553-.295 3.036-.831 4.398-.306.774-1.086 1.227-1.918 1.227h-1.053c-.472 0-.745-.556-.5-.96a8.95 8.95 0 0 0 .303-.54" }))), index.h("button", { class: "copy-btn", tabindex: "0", "aria-label": "Send Email" }, index.h("a", { href: `mailto:${email}?subject=${encodeURIComponent((_e = this.chats[idx - 1]) === null || _e === void 0 ? void 0 : _e.message)}&body=${encodeURIComponent(this.removeHtmlTags(chat.clipboard))}`, target: "_blank", "aria-label": "Send Email" }, index.h("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", stroke: "currentColor", "stroke-width": "0.3", class: "w-6 h-6" }, index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M3.75 5.25L3 6V18L3.75 18.75H20.25L21 18V6L20.25 5.25H3.75ZM4.5 7.6955V17.25H19.5V7.69525L11.9999 14.5136L4.5 7.6955ZM18.3099 6.75H5.68986L11.9999 12.4864L18.3099 6.75Z", fill: "currentColor" }), " "))))))));
1239
- }), index.h("div", { key: 'b0188af49a4dd6aa845cb96a12b631cbbb9699b9', class: "scroll-bottom" }))));
1276
+ }), index.h("div", { key: 'a54a2040ade11dcfce29194ff6ba262077c9ab46', class: "scroll-bottom" }))));
1240
1277
  }
1241
1278
  get element() { return index.getElement(this); }
1242
1279
  static get watchers() { return {