ai12z 3.13.1-alpha.8 → 3.13.3

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 (179) hide show
  1. package/dist/cjs/ai12z-bot.cjs.entry.js +263 -54
  2. package/dist/cjs/ai12z-category_2.cjs.entry.js +13 -8
  3. package/dist/cjs/ai12z-chat-message.cjs.entry.js +22 -4
  4. package/dist/cjs/ai12z-chat_2.cjs.entry.js +11 -11
  5. package/dist/cjs/ai12z-container.cjs.entry.js +8 -6
  6. package/dist/cjs/ai12z-cta.cjs.entry.js +4 -4
  7. package/dist/cjs/ai12z-form.cjs.entry.js +3 -3
  8. package/dist/cjs/ai12z-inline-search.cjs.entry.js +2 -2
  9. package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +29 -19
  10. package/dist/cjs/ai12z-search-panel.cjs.entry.js +1 -1
  11. package/dist/cjs/{botHelpers-aCoootcN.js → botHelpers-D5Dj7TRA.js} +103 -0
  12. package/dist/cjs/chat-avatar_6.cjs.entry.js +2 -2
  13. package/dist/cjs/{ctaHelpers-CDVojcwO.js → ctaHelpers-_6HvZZie.js} +1 -1
  14. package/dist/cjs/dynamic-form.cjs.entry.js +1 -1
  15. package/dist/cjs/{index-BxQS1tNc.js → index-C-xyfB2W.js} +1 -1
  16. package/dist/cjs/index.cjs.js +12 -13
  17. package/dist/cjs/item-list.cjs.entry.js +2 -2
  18. package/dist/cjs/{keyboard-shortcuts-D9VJxzyq.js → keyboard-shortcuts-CwJb0TM7.js} +3 -3
  19. package/dist/cjs/library.cjs.js +1 -1
  20. package/dist/cjs/loader.cjs.js +1 -1
  21. package/dist/cjs/{logger-DX9yB2Q4.js → logger-B_JTV5L8.js} +18 -0
  22. package/dist/cjs/{parseHelper-BpdC7wTC.js → parseHelper-Cp45LpWl.js} +18 -16
  23. package/dist/cjs/{showdown-B5s2mBDO.js → processCarouselData-YEoGs649.js} +66 -0
  24. package/dist/cjs/{reCaptchaHelpers-BUylaRCH.js → reCaptchaHelpers-C5ato8kF.js} +1 -1
  25. package/dist/cjs/{scriptStyleLoader-Ge6Aq6DR.js → scriptStyleLoader-8VXGYoY8.js} +1 -1
  26. package/dist/cjs/search-results-page.cjs.entry.js +4 -4
  27. package/dist/cjs/{socket-service-C523Ww7_.js → socket-service-L0xv4YGT.js} +1 -1
  28. package/dist/cjs/{surveyHelpers-Bmju2R9I.js → surveyHelpers-D4qhA3pY.js} +1 -1
  29. package/dist/cjs/{utils-CVz8XUlb.js → utils-BAJarpnb.js} +21 -0
  30. package/dist/collection/components/ai12z-bot/ai12z-bot.js +179 -36
  31. package/dist/collection/components/ai12z-container/ai12z-container.js +5 -2
  32. package/dist/collection/components/ai12z-cta/components/audiorecorder/audio-recorder.js +9 -5
  33. package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js +23 -12
  34. package/dist/collection/components/ai12z-knowledge-box/components/ai12z-chat-message.css +31 -20
  35. package/dist/collection/components/ai12z-knowledge-box/components/ai12z-chat-message.js +20 -2
  36. package/dist/collection/utils/botHelpers/botHelpers.js +102 -0
  37. package/dist/collection/utils/cookieService.js +5 -5
  38. package/dist/collection/utils/liveagents/liveagent-event-handler.js +21 -0
  39. package/dist/collection/utils/liveagents/liveagent-types.js +10 -0
  40. package/dist/collection/utils/liveagents/providers/salesforce.js +42 -1
  41. package/dist/collection/utils/logger.js +18 -0
  42. package/dist/collection/utils/parseHelper/parseHelper.js +17 -15
  43. package/dist/collection/utils/scriptStyleLoader.js +1 -1
  44. package/dist/collection/utils/utils.js +20 -0
  45. package/dist/components/ai12z-bot.js +1 -1
  46. package/dist/components/ai12z-chat-message.js +1 -1
  47. package/dist/components/ai12z-chat.js +1 -1
  48. package/dist/components/ai12z-container.js +1 -1
  49. package/dist/components/ai12z-cta.js +1 -1
  50. package/dist/components/ai12z-form.js +1 -1
  51. package/dist/components/ai12z-inline-search.js +1 -1
  52. package/dist/components/ai12z-input-form.js +1 -1
  53. package/dist/components/ai12z-knowledge-box.js +1 -1
  54. package/dist/components/ai12z-search-panel.js +1 -1
  55. package/dist/components/audio-recorder.js +1 -1
  56. package/dist/components/dynamic-form.js +1 -1
  57. package/dist/components/index.js +1 -1
  58. package/dist/components/interaction-buttons.js +1 -1
  59. package/dist/components/item-list.js +1 -1
  60. package/dist/components/live-agent-chat.js +1 -1
  61. package/dist/components/{p-C1do_Dz1.js → p-5UYwpNzl.js} +1 -1
  62. package/dist/components/p-B3lv_O-6.js +1 -0
  63. package/dist/components/p-BCJzelr9.js +1 -0
  64. package/dist/components/{p-CwnTHnZf.js → p-BP8ig03d.js} +1 -1
  65. package/dist/components/p-B_OuPB-D.js +1 -0
  66. package/dist/components/{p-BP6Jn1lu.js → p-BhV62IFF.js} +1 -1
  67. package/dist/components/{p-Dpw9999O.js → p-Bo3Ig8oX.js} +1 -1
  68. package/dist/components/{p-Bpy-iS4w.js → p-C2wKkcYa.js} +1 -1
  69. package/dist/components/{p-CMNwhv4D.js → p-CKAp10SJ.js} +1 -1
  70. package/dist/components/{p-CzEX5569.js → p-CLdlCTTp.js} +1 -1
  71. package/dist/components/p-D2lp8C5d.js +1 -0
  72. package/dist/components/p-D2nUK4Pa.js +1 -0
  73. package/dist/components/{p-Db_CqV45.js → p-DA32xa7d.js} +1 -1
  74. package/dist/components/p-DJ68HDol.js +2 -0
  75. package/dist/components/{p-bubyF0x5.js → p-DKxaam7U.js} +1 -1
  76. package/dist/components/p-DPq7OOGr.js +1 -0
  77. package/dist/components/p-DT0Uarfg.js +1 -0
  78. package/dist/components/{p-DL3CHat9.js → p-DUaZgAhA.js} +6 -6
  79. package/dist/components/p-DXBxSLgN.js +1 -0
  80. package/dist/components/p-DmqUTHP1.js +1 -0
  81. package/dist/components/{p-jCB_VqUs.js → p-DsZWeAcM.js} +1 -1
  82. package/dist/components/{p-CL_K1Dih.js → p-Gr6Q2s96.js} +1 -1
  83. package/dist/components/{p-DByZf3r3.js → p-J--erGbY.js} +1 -1
  84. package/dist/components/{p-7x2_R-zS.js → p-ha1wIlZ-.js} +1 -1
  85. package/dist/components/{p-D5Holq94.js → p-q7YWDP9B.js} +1 -1
  86. package/dist/components/p-zVXADzTq.js +1 -0
  87. package/dist/components/privacy-modal.js +1 -1
  88. package/dist/components/search-results-page.js +1 -1
  89. package/dist/esm/ai12z-bot.entry.js +261 -52
  90. package/dist/esm/ai12z-category_2.entry.js +13 -8
  91. package/dist/esm/ai12z-chat-message.entry.js +22 -4
  92. package/dist/esm/ai12z-chat_2.entry.js +10 -10
  93. package/dist/esm/ai12z-container.entry.js +8 -6
  94. package/dist/esm/ai12z-cta.entry.js +4 -4
  95. package/dist/esm/ai12z-form.entry.js +3 -3
  96. package/dist/esm/ai12z-inline-search.entry.js +2 -2
  97. package/dist/esm/ai12z-knowledge-box.entry.js +27 -17
  98. package/dist/esm/ai12z-search-panel.entry.js +1 -1
  99. package/dist/esm/{botHelpers-BWLdDS2K.js → botHelpers-B_moTKAE.js} +103 -1
  100. package/dist/esm/chat-avatar_6.entry.js +2 -2
  101. package/dist/esm/{ctaHelpers-DU1CUJVk.js → ctaHelpers-BhM8KbEY.js} +1 -1
  102. package/dist/esm/dynamic-form.entry.js +1 -1
  103. package/dist/esm/{index-Bhw0hUAG.js → index-BQKLwW-C.js} +1 -1
  104. package/dist/esm/index.js +12 -13
  105. package/dist/esm/item-list.entry.js +2 -2
  106. package/dist/esm/{keyboard-shortcuts-DAR3wFMj.js → keyboard-shortcuts-Bd3LDe9j.js} +2 -2
  107. package/dist/esm/library.js +1 -1
  108. package/dist/esm/loader.js +1 -1
  109. package/dist/esm/{logger-ccneRP0V.js → logger-DUcx64Gz.js} +18 -0
  110. package/dist/esm/{parseHelper-Dlv8H_Go.js → parseHelper-9rP0JS7J.js} +18 -16
  111. package/dist/esm/{showdown-DNrUV4rI.js → processCarouselData-Bf2pDFsV.js} +66 -1
  112. package/dist/esm/{reCaptchaHelpers-cuRSIkQX.js → reCaptchaHelpers-CUcgfdqX.js} +1 -1
  113. package/dist/esm/{scriptStyleLoader-XPFRf8XJ.js → scriptStyleLoader-DXBxSLgN.js} +1 -1
  114. package/dist/esm/search-results-page.entry.js +4 -4
  115. package/dist/esm/{socket-service-Cm682xBc.js → socket-service-B1OMbkCM.js} +1 -1
  116. package/dist/esm/{surveyHelpers-BadJyyGS.js → surveyHelpers-CvrZlir1.js} +1 -1
  117. package/dist/esm/{utils-C7rQ7Hn6.js → utils-BTLjNTwP.js} +21 -1
  118. package/dist/library/index.esm.js +1 -1
  119. package/dist/library/library.esm.js +1 -1
  120. package/dist/library/{p-8019b3b3.entry.js → p-014d5664.entry.js} +1 -1
  121. package/dist/library/p-0641ba91.entry.js +2 -0
  122. package/dist/library/p-07f11cb8.entry.js +1 -0
  123. package/dist/library/p-29cd4edc.entry.js +1 -0
  124. package/dist/library/{p-09512d21.entry.js → p-2d262192.entry.js} +1 -1
  125. package/dist/library/{p-6a3ca44b.entry.js → p-60d5d99f.entry.js} +1 -1
  126. package/dist/library/{p-ca6d40c0.entry.js → p-6f3727d3.entry.js} +1 -1
  127. package/dist/library/{p-c27f05f2.entry.js → p-7f0e306c.entry.js} +1 -1
  128. package/dist/library/p-806bfb3d.entry.js +1 -0
  129. package/dist/library/p-83a71da9.entry.js +1 -0
  130. package/dist/library/{p-bc9e208a.entry.js → p-94bf0c7f.entry.js} +1 -1
  131. package/dist/library/{p-O1dyylW6.js → p-BZ_koFpE.js} +1 -1
  132. package/dist/library/p-B_moTKAE.js +1 -0
  133. package/dist/library/{p-Bv6YLRIH.js → p-Bbow4UZX.js} +1 -1
  134. package/dist/library/{p-D0d3rNXZ.js → p-C1eU4fpM.js} +1 -1
  135. package/dist/library/p-CnadO0kA.js +1 -0
  136. package/dist/library/{p-CzahZhNe.js → p-D5m1leH0.js} +3 -3
  137. package/dist/library/{p-D8lW3uyX.js → p-DAGa-uHD.js} +1 -1
  138. package/dist/library/p-DXBxSLgN.js +1 -0
  139. package/dist/library/p-DoBD_KPG.js +1 -0
  140. package/dist/library/{p-D1zUhFeh.js → p-NAKC5NP9.js} +1 -1
  141. package/dist/library/{p-6f39c96f.entry.js → p-cd764f70.entry.js} +1 -1
  142. package/dist/library/p-d3a2acee.entry.js +1 -0
  143. package/dist/library/p-dc131a5c.entry.js +1 -0
  144. package/dist/library/{p-C9vwNvHX.js → p-y3Go1NSi.js} +1 -1
  145. package/dist/types/components/ai12z-bot/ai12z-bot.d.ts +8 -0
  146. package/dist/types/components/ai12z-knowledge-box/components/ai12z-chat-message.d.ts +1 -0
  147. package/dist/types/utils/botHelpers/botHelpers.d.ts +8 -0
  148. package/dist/types/utils/cookieService.d.ts +3 -0
  149. package/dist/types/utils/liveagents/liveagent-event-handler.d.ts +6 -0
  150. package/dist/types/utils/liveagents/liveagent-types.d.ts +8 -0
  151. package/dist/types/utils/liveagents/providers/salesforce.d.ts +5 -0
  152. package/dist/types/utils/parseHelper/parseHelper.d.ts +2 -2
  153. package/dist/types/utils/utils.d.ts +6 -0
  154. package/package.json +2 -2
  155. package/dist/cjs/processCarouselData-706HSI5A.js +0 -69
  156. package/dist/components/p-19dJOtRv.js +0 -1
  157. package/dist/components/p-B2AnyKzN.js +0 -1
  158. package/dist/components/p-BfBy45fc.js +0 -1
  159. package/dist/components/p-Bh0xY9Up.js +0 -1
  160. package/dist/components/p-CFJOVfYo.js +0 -1
  161. package/dist/components/p-Ct0IdFwf.js +0 -2
  162. package/dist/components/p-DOfDD2pn.js +0 -1
  163. package/dist/components/p-Dd5OBDa4.js +0 -1
  164. package/dist/components/p-XPFRf8XJ.js +0 -1
  165. package/dist/components/p-i9uqNkVJ.js +0 -1
  166. package/dist/esm/processCarouselData-D0Zm1lKM.js +0 -67
  167. package/dist/library/p-4da1633e.entry.js +0 -1
  168. package/dist/library/p-5bf4d3ba.entry.js +0 -2
  169. package/dist/library/p-6c58b381.entry.js +0 -1
  170. package/dist/library/p-B9KPUh8s.js +0 -1
  171. package/dist/library/p-BIef3_l-.js +0 -1
  172. package/dist/library/p-BWLdDS2K.js +0 -1
  173. package/dist/library/p-DLWXFwkX.js +0 -1
  174. package/dist/library/p-XPFRf8XJ.js +0 -1
  175. package/dist/library/p-aa165aa7.entry.js +0 -1
  176. package/dist/library/p-cac072e9.entry.js +0 -1
  177. package/dist/library/p-f3ad0ce8.entry.js +0 -1
  178. package/dist/library/p-f94eed10.entry.js +0 -1
  179. /package/dist/library/{p-Dxm5eEMi.js → p-8-Jaom_c.js} +0 -0
@@ -2,20 +2,19 @@
2
2
 
3
3
  var index = require('./index-Ct2DwlDF.js');
4
4
  var responseAdapter = require('./response-adapter-CKKyyhMj.js');
5
- var showdown = require('./showdown-B5s2mBDO.js');
6
- var logger$1 = require('./logger-DX9yB2Q4.js');
7
- var utils = require('./utils-CVz8XUlb.js');
8
- var index$1 = require('./index-BxQS1tNc.js');
5
+ var processCarouselData = require('./processCarouselData-YEoGs649.js');
6
+ var logger$1 = require('./logger-B_JTV5L8.js');
7
+ var utils = require('./utils-BAJarpnb.js');
8
+ var index$1 = require('./index-C-xyfB2W.js');
9
9
  var globalStore = require('./global-store-R6x06KvJ.js');
10
- var reCaptchaHelpers = require('./reCaptchaHelpers-BUylaRCH.js');
11
- var botHelpers = require('./botHelpers-aCoootcN.js');
12
- var processCarouselData = require('./processCarouselData-706HSI5A.js');
13
- var surveyHelpers = require('./surveyHelpers-Bmju2R9I.js');
14
- var scriptStyleLoader = require('./scriptStyleLoader-Ge6Aq6DR.js');
15
- var keyboardShortcuts = require('./keyboard-shortcuts-D9VJxzyq.js');
16
- var ctaHelpers = require('./ctaHelpers-CDVojcwO.js');
10
+ var reCaptchaHelpers = require('./reCaptchaHelpers-C5ato8kF.js');
11
+ var botHelpers = require('./botHelpers-D5Dj7TRA.js');
12
+ var surveyHelpers = require('./surveyHelpers-D4qhA3pY.js');
13
+ var scriptStyleLoader = require('./scriptStyleLoader-8VXGYoY8.js');
14
+ var keyboardShortcuts = require('./keyboard-shortcuts-CwJb0TM7.js');
15
+ var ctaHelpers = require('./ctaHelpers-_6HvZZie.js');
17
16
  var appStore = require('./app-store-D249GRTi.js');
18
- var parseHelper = require('./parseHelper-BpdC7wTC.js');
17
+ var parseHelper = require('./parseHelper-Cp45LpWl.js');
19
18
  require('./_commonjsHelpers-MBWFX2dn.js');
20
19
 
21
20
  // ILiveAgentProvider.ts
@@ -23,6 +22,16 @@ const envMode = index.Env.DATA_MODE || "prod";
23
22
  // Additional methods can be added as needed for more functionality
24
23
  // This interface defines the contract for a Live Agent provider, allowing for chat management and message handling.
25
24
  // Implementations of this interface would handle the specifics of interacting with a live chat service.
25
+ /**
26
+ * Thrown when a resumed live-agent session is rejected with HTTP 401 or 403,
27
+ * indicating the stored access token has expired or been revoked.
28
+ */
29
+ class LiveAgentAuthExpiredError extends Error {
30
+ constructor(message = "Live agent session authentication has expired") {
31
+ super(message);
32
+ this.name = "LiveAgentAuthExpiredError";
33
+ }
34
+ }
26
35
 
27
36
  class EventBus {
28
37
  constructor() {
@@ -134,6 +143,10 @@ class SalesforceLiveAgentProvider {
134
143
  if (conversationResponse.ok) {
135
144
  this.sessionContext.conversationId = conversationId;
136
145
  ChatEventBus.emit("liveAgentReady", undefined);
146
+ ChatEventBus.emit("AGENT_SESSION_INFO", {
147
+ sessionId: this.sessionContext.accessToken,
148
+ conversationId: this.sessionContext.conversationId,
149
+ });
137
150
  // console.log(this.sessionContext?.initialMessages)
138
151
  // Send initial message to the agent here need to format the message properly
139
152
  // Iterate the initialmessages and create a user friendly display message with contact user: for user input and bot: as bot response
@@ -443,6 +456,43 @@ class SalesforceLiveAgentProvider {
443
456
  async startChat(startChatOptions) {
444
457
  await this.initialize(startChatOptions);
445
458
  }
459
+ /**
460
+ * Resumes an existing live agent session using a stored access token and conversation ID.
461
+ * Skips authentication and conversation creation — only reconnects the SSE listener.
462
+ */
463
+ async resumeChat(startChatOptions) {
464
+ var _a, _b, _c;
465
+ if (!(startChatOptions === null || startChatOptions === void 0 ? void 0 : startChatOptions.sessionId) || !(startChatOptions === null || startChatOptions === void 0 ? void 0 : startChatOptions.conversationId)) {
466
+ throw new Error("resumeChat requires sessionId (accessToken) and conversationId");
467
+ }
468
+ this.configSettings = (startChatOptions === null || startChatOptions === void 0 ? void 0 : startChatOptions.config) || this.configSettings;
469
+ if (!((_a = this.configSettings) === null || _a === void 0 ? void 0 : _a.instanceUrl) || !((_b = this.configSettings) === null || _b === void 0 ? void 0 : _b.orgId) || !((_c = this.configSettings) === null || _c === void 0 ? void 0 : _c.messagingChannelId)) {
470
+ throw new Error("Missing required configuration settings for resuming Salesforce Live Agent session");
471
+ }
472
+ this.sessionContext = {
473
+ accessToken: startChatOptions.sessionId,
474
+ conversationId: startChatOptions.conversationId,
475
+ userId: startChatOptions.userId || "",
476
+ isActive: true,
477
+ lastMessageReadTime: 0,
478
+ };
479
+ // Probe the session before declaring it ready
480
+ const probeUrl = new URL(`${this.configSettings.instanceUrl}/iamessage/api/v2/conversation/${this.sessionContext.conversationId}/entries`);
481
+ probeUrl.searchParams.set("limit", "1");
482
+ probeUrl.searchParams.set("direction", "FromEnd");
483
+ const probeRes = await fetch(probeUrl.toString(), {
484
+ method: "GET",
485
+ headers: { Authorization: `Bearer ${this.sessionContext.accessToken}` },
486
+ });
487
+ if (probeRes.status === 401 || probeRes.status === 403) {
488
+ throw new LiveAgentAuthExpiredError();
489
+ }
490
+ if (!probeRes.ok) {
491
+ throw new Error(`Session probe failed: ${probeRes.status} ${probeRes.statusText}`);
492
+ }
493
+ ChatEventBus.emit("liveAgentReady", undefined);
494
+ this.listenToMessages();
495
+ }
446
496
  /**
447
497
  *
448
498
  * @param sendMessageOptions
@@ -688,6 +738,27 @@ class LiveAgentEventHandler {
688
738
  throw error;
689
739
  }
690
740
  }
741
+ /**
742
+ * Resumes an existing live agent session (e.g. after a page reload) using stored
743
+ * session credentials. Authentication and conversation creation are skipped;
744
+ * only the SSE listener is reconnected.
745
+ */
746
+ async resumeLiveAgentSession(name = "salesforce", chatOptions) {
747
+ try {
748
+ this.logger.debug("Resuming Live Agent session", name, " --- ", chatOptions);
749
+ this.liveAgentProvider = LiveAgentProvider.getProvider(name);
750
+ if (this.liveAgentProvider.resumeChat) {
751
+ await this.liveAgentProvider.resumeChat(chatOptions);
752
+ }
753
+ else {
754
+ throw new Error(`Provider '${name}' does not support session resume`);
755
+ }
756
+ }
757
+ catch (error) {
758
+ this.logger.error("Error resuming Live Agent session:", error);
759
+ throw error;
760
+ }
761
+ }
691
762
  }
692
763
 
693
764
  function isRecord(value) {
@@ -733,7 +804,7 @@ function setCookie(name, value, options = {}) {
733
804
  let cookie = `${name}=${encodeURIComponent(value)}`;
734
805
  if (domain) {
735
806
  if (!/^[a-zA-Z0-9._-]+$/.test(domain)) {
736
- console.warn('AI12Z: Invalid cookie domain characters');
807
+ console.warn("AI12Z: Invalid cookie domain characters");
737
808
  return false;
738
809
  }
739
810
  cookie += `; Domain=${domain}`;
@@ -798,12 +869,12 @@ function getValidCookieDomain(subDomain) {
798
869
  if (typeof window === "undefined") {
799
870
  return undefined;
800
871
  }
801
- const bare = subDomain.replace(/^\./, '');
872
+ const bare = subDomain.replace(/^\./, "");
802
873
  const currentHost = window.location.hostname;
803
- if (currentHost === bare || currentHost.endsWith('.' + bare)) {
874
+ if (currentHost === bare || currentHost.endsWith("." + bare)) {
804
875
  return subDomain;
805
876
  }
806
- console.warn('AI12Z: subDomain does not match current host');
877
+ console.warn("AI12Z: subDomain does not match current host");
807
878
  return undefined;
808
879
  }
809
880
  /**
@@ -812,7 +883,7 @@ function getValidCookieDomain(subDomain) {
812
883
  * @param options - Optional path and domain (must match original cookie)
813
884
  */
814
885
  function deleteJsonCookie(name, options = {}) {
815
- const { path = '/', domain } = options;
886
+ const { path = "/", domain } = options;
816
887
  if (typeof document === "undefined") {
817
888
  return;
818
889
  }
@@ -823,6 +894,18 @@ const ai12zBotCss = () => `:host{font-family:var(--ai12zBot-v2-font-family) !imp
823
894
 
824
895
  const ai12zChatbotCss = () => `:host{--wes-c-icon-color:#fff;--fab-bottom:26px;--xsf-ai12z-zindex-isexpanded-10:20020;--ai-toolbar-icon-color:#2095ae;--xsf-ai12z-zindex-0:19979;--xsf-ai12z-zindex-10:19989;--xsf-ai12z-fab-bottom:26px}.modal-overlay{position:absolute;height:100%;width:100%;z-index:var(--xsf-ai12z-zindex-0);background-color:#2e2e2e99}.layout{pointer-events:none;position:fixed;inset:0;height:100dvh;width:99dvw;justify-content:flex-end;grid-template-rows:auto 1fr auto;grid-template-areas:"left toolbar right" "left main right" "left footer right";padding-top:96px;transition-property:grid-template-columns, padding-top;z-index:19979}.layout.is-open .modal{pointer-events:auto}.layout.is-expanded ai12z-bot{pointer-events:auto}.layout.is-open.is-expanded .modal{border-top-left-radius:0.75rem;border-top-right-radius:0.75rem;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);z-index:var(--xsf-ai12z-zindex-isexpanded-10)}.layout.is-open .user-input-fieldset{background-image:none;padding:0px;background:none}.layout.is-expanded .user-input-fieldset{border-top-left-radius:0.75rem;border-top-right-radius:0.75rem}.layout.is-open .grow-wrap>.textarea,.layout.is-open .grow-wrap>button,.layout.is-open .grow-wrap:after{border-color:var(--ai12zBot-v2-searchbar-open-border-color);}.layout.is-expanded .grow-wrap:after{display:none}.layout.is-open.is-expanded .user-input{z-index:var(--xsf-ai12z-zindex-isexpanded-10)}.layout.is-open .user-input{z-index:var(--xsf-ai12z-zindex-10)}.text-body2{font-size:16px;line-height:1.5;letter-spacing:-0.12px;font-weight:400}.modal-toolbar-icon{color:var(--ai12zBot-v2-toolbar-icon-color, inherit);width:1rem;height:1rem}.search-flex{flex:1 1 0%}.show-grid{display:grid}.hide-title{padding:0px;opacity:0;height:0px}.user-msg{background-color:var(--ai12zBot-v2-user-bubble-background);color:var(--ai12zBot-v2-user-bubble-font-color)}.text-body4{font-size:var(--ai12zBot-v2-timestamp-font-size);line-height:1.5;letter-spacing:0.03px;font-weight:400;color:var(--ai12zBot-v2-timestamp-font-color)}.isContent{background:var(--ai12zBot-v2-content-background);padding:10px}.default-botAvatar{color:var(--ai12zBot-v2-default-avatar-color)}.searchform{opacity:1;transform:none}.user-input{margin-left:auto;margin-right:auto;width:100%;max-width:840px;min-width:340px;grid-area:footer}.main{margin-left:auto;margin-right:auto;width:100%;max-width:840px;min-width:340px;margin-top:7px}.heading{color:var(--ai12zBot-v2-title-color)}.dropdown-item-button{display:flex;width:100%;cursor:pointer;align-items:center;-moz-column-gap:8px;column-gap:8px;border-radius:0.25rem;--tw-border-opacity:1;--tw-bg-opacity:1;background-color:var(--ai12zBot-v2-dropdown-bgcolor);padding:8px 24px;font-weight:500;--tw-text-opacity:1;color:var(--ai12zBot-v2-dropdown-font-color);transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:75ms}.helptext{padding:0px;opacity:0;height:0px}.minimize-input{transform:translateY(calc(-100% - 4px))}.ai-text-caption{font-size:12px;line-height:1.5;letter-spacing:0.2px;font-weight:400}.fab>button{background:var(--ai12zBot-v2-fab-button-background);}.user-input-fieldset{background:var(--ai12zBot-v2-searchbar-background)}.return-text-color{color:rgb(255, 255, 255)}.ai-minimize-icon svg{fill:currentColor;height:1em;width:1em}.hide-form{opacity:0;transform:none}.show-form{opacity:1;transform:none}.ai-minimize-icon{color:var(--wes-c-icon-color, inherit)}.fab{bottom:var(--fab-bottom, 30px)}.text-body1{font-size:var(--ai12zBot-v2-title-font-size);line-height:1.5;letter-spacing:-0.12px;font-weight:400}#message-submit{margin-right:6px;margin-bottom:7px;background-color:var(--ai12zBot-v2-searchbar-submit-bgcolor)}.ai-icon{color:var(--ai12zBot-v2-searchbar-submit-color);font-size:24px;width:1.5rem;height:1.5rem}.plus-icon{color:var(--ai12zBot-v2-searchbar-plus-icon-color);font-size:24px;width:1.5rem;height:1.5rem}.grow-wrap>.textarea,.grow-wrap:after{min-height:48px;align-content:center;border-radius:1.5rem;border-width:1px;border-style:solid;border:1px solid var(--ai12zBot-v2-searchbar-border-color);--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:8px 48px;text-indent:2px;font-size:16px;line-height:1.5;letter-spacing:-0.12px;font-weight:400;--tw-text-opacity:1;color:rgb(46 46 46 / var(--tw-text-opacity, 1));--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);--tw-ring-inset:inset;--tw-ring-offset-width:0px;transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:0.15s}.grow-wrap>.textarea,.grow-wrap:after{grid-area:1 / 1 / 2 / 2}.modal{position:relative;grid-column:span 1 / span 1;grid-column-start:2;grid-row:span 3 / span 3;grid-row-start:1;display:grid;border-top-left-radius:0;border-top-right-radius:0;background-position:center;box-shadow:0 16px 32px -4px #18181829, 0 12px 24px -4px #18181814;background-image:var(--ai12zBot-v2-modal-backgroundImage);background-repeat:no-repeat;background-size:100vw 100vh;grid-template-columns:subgrid;grid-template-rows:subgrid;z-index:var(--xsf-ai12z-zindex-10);transition:0.3sease-out;transition-property:grid-template-columns}.dropdown-menu{pointer-events:none;opacity:0;z-index:10;background-color:var(--ai12zBot-v2-dropdown-bgcolor);transform:translateY(-10px);transition:opacity 0.3s ease, transform 0.3s ease}.dropdown-menu.show{pointer-events:auto;opacity:1;pointer-events:auto;transform:translateY(0);background-color:var(--ai12zBot-v2-dropdown-bgcolor)}.copy-btn{color:var(--ai12zBot-v2-copy-btn-color)}.thumbs-up{fill:var(--ai12zBot-v2-feedback-selected);width:1.5rem}.thumbs-down{fill:var( --ai12zBot-v2-feedback-selected);width:1.5rem}.chat-thumbs-up{color:var(--ai12zBot-v2-feedback-color)}.thumbs-container{justify-content:flex-start;align-items:center}.back-btn svg{fill:var(--ai12zBot-v2-back-button-color)}.dropdown-item{background-color:var(--ai12zBot-v2-dropdown-bgcolor)}button:focus-visible{outline:2px solid var(--ai12zBot-v2-focus-visible-color, #0A2A43);outline-offset:2px}button.bot-btn-primary:focus-visible{outline:2px solid var(--ai12zBot-v2-focus-visible-color-primary, var(--ai12zBot-v2-focus-visible-color, #0A2A43));outline-offset:2px}button.bot-btn-secondary:focus-visible{outline:2px solid var(--ai12zBot-v2-focus-visible-color-secondary, var(--ai12zBot-v2-focus-visible-color, #0A2A43))}.bot-name{color:var(--ai12zBot-v2-fab-name-color, var(--ai12zBot-v2-bot-name-color));font-weight:var(--ai12zBot-v2-fab-font-weight, var(--ai12zBot-v2-bot-name-font-weight))}.ai12z-link{color:var(--ai12zBot-v2-link-color);text-decoration:underline}.ai12z-link:hover{color:var(--ai12zBot-v2-link-hover-color);text-decoration:underline}.toolbar{height:52px;border:#fff;grid-area:toolbar}.skip-link{position:absolute;left:-999px;top:auto;width:1px;height:1px;overflow:hidden}.skip-link:focus{left:10px;top:10px;width:auto;height:auto;z-index:1000}.enter-tip{font-size:12px;color:#666;margin-left:10px}.skip-links.hidden{position:absolute;left:-9999px;}.skip-links.visible{left:auto;position:static;}.error-message-container{margin-top:0.25rem}.error-msg{color:#dc2626;font-size:0.75rem;display:block;animation:slideIn 0.2s ease-out}.ai12z-form-honeypot{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}@keyframes slideIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@media (min-width: 1024px){.modal{background-size:80vw 100vh}}@media (min-width: 1024px){.layout.is-expanded{grid-template-columns:1fr minmax(340px, 80dvw) 1fr !important}}@media (min-width: 768px){.layout.is-expanded{-moz-column-gap:48px;column-gap:48px}}@media (max-width: 767px){.layout.is-open{padding-top:0px !important;grid-template-columns:0fr minmax(340px, 1fr) 0fr !important}}@media (max-width: 767px){.fab{right:30px;bottom:var(--xsf-ai12z-fab-bottom, 26px)}}`;
825
896
 
897
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
898
+ var t = {};
899
+ for (var p in s)
900
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
901
+ t[p] = s[p];
902
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
903
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
904
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
905
+ t[p[i]] = s[p[i]];
906
+ }
907
+ return t;
908
+ };
826
909
  const Ai12zBot = class {
827
910
  constructor(hostRef) {
828
911
  index.registerInstance(this, hostRef);
@@ -836,7 +919,7 @@ const Ai12zBot = class {
836
919
  this.isElementAvailable = index.createEvent(this, "isElementAvailable", 7);
837
920
  this.cdnPath = "https://cdn.ai12z.net/assets/bot";
838
921
  this.surveyCDNPath = "https://cdn.ai12z.net/pkg/surveyjs";
839
- this.styles = [`https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/default.min.css`, `https://cdn.ai12z.net/assets/bot/v2/tailwind.min.css`];
922
+ this.styles = [`https://cdn.jsdelivr.net/npm/@highlightjs/cdn-assets@11.11.1/styles/default.min.css`, `https://cdn.ai12z.net/assets/bot/v2/tailwind.min.css`];
840
923
  this.liveAgentEventHandler = new LiveAgentEventHandler();
841
924
  this.customStyle = "";
842
925
  this.customJS = "";
@@ -894,6 +977,10 @@ const Ai12zBot = class {
894
977
  this.isRendered = false; // Flag to track if the component has been rendered
895
978
  this.showShortcutsDialog = false; // Keyboard shortcuts help dialog
896
979
  this.showLiveAgentEndDialog = false;
980
+ this.liveAgentSessionId = "";
981
+ this.liveAgentConversationId = "";
982
+ this.liveAgentProviderName = "salesforce";
983
+ this.liveAgentListenersRegistered = false;
897
984
  this.shortcuts = keyboardShortcuts.DEFAULT_SHORTCUTS;
898
985
  this.announceMessage = ""; // For accessibility announcements
899
986
  this.messageRefs = [];
@@ -980,7 +1067,7 @@ const Ai12zBot = class {
980
1067
  }
981
1068
  };
982
1069
  this.handleMessage = (data, aiMessageId) => {
983
- const converter = new showdown.showdown.Converter();
1070
+ const converter = new processCarouselData.showdown.Converter();
984
1071
  // const aiMessageBubble = document.getElementById(aiMessageId);
985
1072
  // const aiMessageBubble = await waitForElement(`#${aiMessageId}`, this.el)
986
1073
  const aiMessageBubble = this.el.shadowRoot.querySelector(`#${aiMessageId}`);
@@ -1082,6 +1169,7 @@ const Ai12zBot = class {
1082
1169
  if (this.isLiveAgent) {
1083
1170
  this.messages = this.messages.slice(0, -1);
1084
1171
  this.liveAgentEventHandler.sendMessage({ sessionId: "", message: this.inputEl.value });
1172
+ this.updateBotState();
1085
1173
  if (this.inputEl.value) {
1086
1174
  this.inputEl.value = "";
1087
1175
  }
@@ -1109,7 +1197,7 @@ const Ai12zBot = class {
1109
1197
  // Get the last message in the messages array
1110
1198
  const lastMessage = this.messages[this.messages.length - 1];
1111
1199
  // check if last message is from user or agent
1112
- if (!lastMessage.sender || lastMessage.sender === null) {
1200
+ if (!lastMessage.sender || lastMessage.sender === null || lastMessage.type === "system") {
1113
1201
  // Generate a new temporary message object
1114
1202
  const tempMsg = utils.generateMessage(this.conversationId);
1115
1203
  // Generate a unique ID for the new message
@@ -1135,12 +1223,13 @@ const Ai12zBot = class {
1135
1223
  var _a;
1136
1224
  const aiMessageBubble = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#${this.currentDomId}`);
1137
1225
  if (aiMessageBubble) {
1138
- const converter = new showdown.showdown.Converter();
1226
+ const converter = new processCarouselData.showdown.Converter();
1139
1227
  let bubbleText = aiMessageBubble.getAttribute("data-bubbleText") || "";
1140
1228
  bubbleText = `${bubbleText} \n\n ${retMessage}`;
1141
1229
  aiMessageBubble.setAttribute("data-bubbleText", bubbleText);
1142
1230
  let html = converter.makeHtml(bubbleText);
1143
1231
  this.updateConversations(html, message[0]);
1232
+ this.updateBotState();
1144
1233
  }
1145
1234
  setTimeout(() => {
1146
1235
  this.scrollToBottom();
@@ -1188,6 +1277,8 @@ const Ai12zBot = class {
1188
1277
  this.handleAgentError = () => {
1189
1278
  this.addEventMessage("Something went wrong with Live Agent, please try again later");
1190
1279
  this.isLiveAgent = false;
1280
+ this.liveAgentSessionId = "";
1281
+ this.liveAgentConversationId = "";
1191
1282
  this.isTypingIndicatorVisible = false;
1192
1283
  this.liveAgentEventHandler.disconnectLiveAgent();
1193
1284
  this.clearEvents();
@@ -1202,6 +1293,8 @@ const Ai12zBot = class {
1202
1293
  this.announce("Live agent chat ended");
1203
1294
  }
1204
1295
  this.isLiveAgent = false;
1296
+ this.liveAgentSessionId = "";
1297
+ this.liveAgentConversationId = "";
1205
1298
  this.isTypingIndicatorVisible = false;
1206
1299
  this.liveAgentButtonText = "Talk to a Live Agent";
1207
1300
  this.clearEvents();
@@ -1212,19 +1305,28 @@ const Ai12zBot = class {
1212
1305
  if (this.isLiveAgentEnabled && this.currentDomId === "") {
1213
1306
  this.currentDomId = this.messages[this.messages.length - 1].id;
1214
1307
  }
1215
- const agentEventMessages = this.liveAgentEventHandler.addAgentEventMessage(event);
1216
- if (agentEventMessages) {
1217
- // If the "Finding a live agent..." placeholder is still in the DOM, remove it then append new message
1218
- this.removeFindingAgentPlaceholder();
1219
- const currentDomElement = this.el.shadowRoot.querySelector(`#${this.currentDomId}`);
1220
- if (currentDomElement) {
1221
- currentDomElement.parentNode.appendChild(agentEventMessages);
1222
- }
1223
- if (this.inputEl) {
1224
- this.inputEl.value = "";
1225
- }
1226
- this.currentDomId = "";
1308
+ // Persist each system event into this.messages so they survive page reload
1309
+ const systemMessages = event.map((evt) => ({
1310
+ id: evt.id || `system-${utils.generateUUID()}`,
1311
+ text: evt.text || "",
1312
+ type: "system",
1313
+ isUser: false,
1314
+ isLoading: false,
1315
+ timestamp: new Date(),
1316
+ images: [],
1317
+ conversationId: this.conversationId,
1318
+ formModel: {},
1319
+ surveyDomId: "",
1320
+ sender: evt.sender || null,
1321
+ }));
1322
+ this.messages = [...this.messages, ...systemMessages];
1323
+ this.updateBotState();
1324
+ // If the "Finding a live agent..." placeholder is still in the DOM, remove it then append new message
1325
+ this.removeFindingAgentPlaceholder();
1326
+ if (this.inputEl) {
1327
+ this.inputEl.value = "";
1227
1328
  }
1329
+ this.currentDomId = "";
1228
1330
  }
1229
1331
  };
1230
1332
  this.handleAgentSessionCreated = () => {
@@ -1238,6 +1340,12 @@ const Ai12zBot = class {
1238
1340
  this.inputEl = inputEl;
1239
1341
  });
1240
1342
  };
1343
+ this.handleAgentSessionInfo = (info) => {
1344
+ this.liveAgentSessionId = (info === null || info === void 0 ? void 0 : info.sessionId) || "";
1345
+ this.liveAgentConversationId = (info === null || info === void 0 ? void 0 : info.conversationId) || "";
1346
+ this.isLiveAgent = true;
1347
+ this.updateBotState();
1348
+ };
1241
1349
  this.toggleBot = _e => {
1242
1350
  // e.stopPropagation()
1243
1351
  this.isToggled = !this.isToggled;
@@ -1275,6 +1383,7 @@ const Ai12zBot = class {
1275
1383
  this.showWelcomeScreen = true;
1276
1384
  this.toggleBot(e);
1277
1385
  this.showHistory = false;
1386
+ this.updateBotState();
1278
1387
  break;
1279
1388
  }
1280
1389
  };
@@ -1508,11 +1617,56 @@ const Ai12zBot = class {
1508
1617
  if (!botState.newChat) {
1509
1618
  this.messages = [...(botState.messages || [])];
1510
1619
  }
1620
+ // Restore live agent session identifiers so they can be used for recovery
1621
+ if (botState.isLiveAgent && botState.liveAgentSessionId && botState.liveAgentConversationId) {
1622
+ this.isLiveAgent = botState.isLiveAgent || true;
1623
+ this.liveAgentSessionId = botState.liveAgentSessionId;
1624
+ this.liveAgentConversationId = botState.liveAgentConversationId;
1625
+ this.liveAgentProviderName = botState.liveAgentProviderName || "salesforce";
1626
+ this.liveAgentButtonText = "End Live Agent chat";
1627
+ // Schedule reconnection after the component has finished loading
1628
+ setTimeout(() => this.recoverLiveAgentSession(), 0);
1629
+ }
1511
1630
  setTimeout(() => {
1512
1631
  this.scrollToBottom();
1513
1632
  }, 100);
1514
1633
  }
1515
1634
  }
1635
+ async recoverLiveAgentSession() {
1636
+ var _a, _b, _c, _d, _f, _g;
1637
+ const liveAgentProviderNames = Object.keys((_c = (_b = (_a = this.botSettings) === null || _a === void 0 ? void 0 : _a.liveagent) === null || _b === void 0 ? void 0 : _b.providers) !== null && _c !== void 0 ? _c : {});
1638
+ if (liveAgentProviderNames.length === 0 || !this.liveAgentSessionId || !this.liveAgentConversationId) {
1639
+ return;
1640
+ }
1641
+ // const providerName = liveAgentProviderNames[0] as import("../../utils/liveagents/liveagent-factory-services").LiveAgentProviderType
1642
+ const liveAgentConfig = (_g = (_f = (_d = this.botSettings) === null || _d === void 0 ? void 0 : _d.liveagent) === null || _f === void 0 ? void 0 : _f.providers[this.liveAgentProviderName]) !== null && _g !== void 0 ? _g : null;
1643
+ if (!liveAgentConfig) {
1644
+ return;
1645
+ }
1646
+ try {
1647
+ this.registerLiveAgentListeners();
1648
+ await this.liveAgentEventHandler.resumeLiveAgentSession(this.liveAgentProviderName, {
1649
+ sessionId: this.liveAgentSessionId,
1650
+ conversationId: this.liveAgentConversationId,
1651
+ userId: this.visitorID,
1652
+ config: liveAgentConfig,
1653
+ });
1654
+ }
1655
+ catch (err) {
1656
+ if (err instanceof LiveAgentAuthExpiredError) {
1657
+ this.addEventMessage("Your live agent session has expired. Please reconnect.");
1658
+ this.announce("Live agent session expired");
1659
+ }
1660
+ else {
1661
+ console.warn("AI12Z: Failed to recover live agent session, ending gracefully:", err);
1662
+ }
1663
+ this.isLiveAgent = false;
1664
+ this.liveAgentSessionId = "";
1665
+ this.liveAgentConversationId = "";
1666
+ this.liveAgentButtonText = "Talk to a Live Agent";
1667
+ this.clearEvents();
1668
+ }
1669
+ }
1516
1670
  componentDidLoad() {
1517
1671
  globalStore.setBotElement(this.el); // register globally
1518
1672
  if (typeof window !== "undefined" && !window.Handlebars) {
@@ -1927,6 +2081,15 @@ const Ai12zBot = class {
1927
2081
  this.isConnectingLiveAgent = false;
1928
2082
  }
1929
2083
  }
2084
+ if (data.liveAgent && !this.isLiveAgent && !this.isConnectingLiveAgent) {
2085
+ this.isConnectingLiveAgent = true;
2086
+ try {
2087
+ await this.connectLiveChat();
2088
+ }
2089
+ finally {
2090
+ this.isConnectingLiveAgent = false;
2091
+ }
2092
+ }
1930
2093
  // ✅ Common cleanup
1931
2094
  this.conversationId = data.conversationId;
1932
2095
  // this.saveConversation()
@@ -2300,8 +2463,8 @@ const Ai12zBot = class {
2300
2463
  }
2301
2464
  }
2302
2465
  checkLiveAgentMode() {
2303
- var _a, _b;
2304
- const isLiveAgentConfigured = ((_a = this.botSettings) === null || _a === void 0 ? void 0 : _a.liveagent) && Object.keys((_b = this.botSettings) === null || _b === void 0 ? void 0 : _b.liveagent).length > 0;
2466
+ var _a, _b, _c, _d;
2467
+ const isLiveAgentConfigured = ((_b = (_a = this.botSettings) === null || _a === void 0 ? void 0 : _a.liveagent) === null || _b === void 0 ? void 0 : _b.providers) && Object.keys((_d = (_c = this.botSettings) === null || _c === void 0 ? void 0 : _c.liveagent) === null || _d === void 0 ? void 0 : _d.providers).length > 0;
2305
2468
  /**
2306
2469
  * Check if live agent is enabled
2307
2470
  * If live agent is configured and there are more than one messages in the chat,
@@ -2334,8 +2497,10 @@ const Ai12zBot = class {
2334
2497
  var _a, _b, _c, _d;
2335
2498
  this.liveAgentEventHandler.disconnectLiveAgent();
2336
2499
  this.isLiveAgent = false;
2500
+ this.liveAgentSessionId = "";
2501
+ this.liveAgentConversationId = "";
2337
2502
  this.liveAgentButtonText = "Talk to a Live Agent";
2338
- this.sendMessage((_b = (_a = this.botSettings) === null || _a === void 0 ? void 0 : _a.llmMessageOnDisconnect) !== null && _b !== void 0 ? _b : "The live agent has been disconnected. Please do not initiate the live agent directive again.", (_d = (_c = this.botSettings) === null || _c === void 0 ? void 0 : _c.userMessageOnDisconnect) !== null && _d !== void 0 ? _d : "The live agent has ended the conversation.", { isLiveChatEnded: true });
2503
+ this.sendMessage(((_a = this.botSettings) === null || _a === void 0 ? void 0 : _a.llmMessageOnDisconnect) !== "" ? (_b = this.botSettings) === null || _b === void 0 ? void 0 : _b.llmMessageOnDisconnect : "The live agent has been disconnected. Please do not initiate the live agent directive again.", ((_c = this.botSettings) === null || _c === void 0 ? void 0 : _c.userMessageOnDisconnect) !== "" ? (_d = this.botSettings) === null || _d === void 0 ? void 0 : _d.userMessageOnDisconnect : "The live agent has ended the conversation.", { isLiveChatEnded: true });
2339
2504
  this.announce("Live agent chat ended");
2340
2505
  this.clearEvents();
2341
2506
  }
@@ -2351,6 +2516,9 @@ const Ai12zBot = class {
2351
2516
  }
2352
2517
  }
2353
2518
  registerLiveAgentListeners() {
2519
+ if (this.liveAgentListenersRegistered)
2520
+ return;
2521
+ this.liveAgentListenersRegistered = true;
2354
2522
  ChatEventBus.on("FINDING_AGENT", this.findingAgent);
2355
2523
  ChatEventBus.on("AGENT_EVENT", this.agentEventHandler);
2356
2524
  ChatEventBus.on("TYPING_STARTED", this.handleTypingStarted);
@@ -2358,8 +2526,10 @@ const Ai12zBot = class {
2358
2526
  ChatEventBus.on("AGENT_MESSAGE", this.agentMessageCreated);
2359
2527
  ChatEventBus.on("AGENT_ERROR", this.handleAgentError);
2360
2528
  ChatEventBus.on("CONVERSATION_CLOSED", this.handleAgentConversationEnded);
2529
+ ChatEventBus.on("AGENT_SESSION_INFO", this.handleAgentSessionInfo);
2361
2530
  }
2362
2531
  clearEvents() {
2532
+ this.liveAgentListenersRegistered = false;
2363
2533
  ChatEventBus.off("FINDING_AGENT", this.findingAgent);
2364
2534
  ChatEventBus.off("AGENT_EVENT", this.agentEventHandler);
2365
2535
  ChatEventBus.off("AGENT_MESSAGE", this.agentMessageCreated);
@@ -2368,12 +2538,13 @@ const Ai12zBot = class {
2368
2538
  ChatEventBus.off("TYPING_STARTED", this.handleTypingStarted);
2369
2539
  ChatEventBus.off("TYPING_STOPPED", this.handleTypingStopped);
2370
2540
  ChatEventBus.off("AGENT_SESSION_CREATED", this.handleAgentSessionCreated);
2541
+ ChatEventBus.off("AGENT_SESSION_INFO", this.handleAgentSessionInfo);
2371
2542
  }
2372
2543
  async connectLiveChat() {
2373
- var _a, _b, _c, _d, _f, _g, _h;
2544
+ var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
2374
2545
  this.announce("Connecting to live agent");
2375
2546
  this.clearEvents();
2376
- const liveAgentProviderNames = Object.keys((_b = (_a = this.botSettings) === null || _a === void 0 ? void 0 : _a.liveagent) !== null && _b !== void 0 ? _b : {});
2547
+ const liveAgentProviderNames = Object.keys((_c = (_b = (_a = this.botSettings) === null || _a === void 0 ? void 0 : _a.liveagent) === null || _b === void 0 ? void 0 : _b.providers) !== null && _c !== void 0 ? _c : {});
2377
2548
  if (liveAgentProviderNames.length === 0) {
2378
2549
  console.error("No live agent provider found in bot settings");
2379
2550
  this.announce("Live agent is not configured");
@@ -2382,7 +2553,9 @@ const Ai12zBot = class {
2382
2553
  if (liveAgentProviderNames.length > 1) {
2383
2554
  console.warn("Multiple live agent providers found, using the first one");
2384
2555
  }
2385
- let liveAgentSettings = (_d = (_c = this.botSettings) === null || _c === void 0 ? void 0 : _c.liveagent[liveAgentProviderNames[0]]) !== null && _d !== void 0 ? _d : null;
2556
+ let liveAgentSettings = (_h = (_g = (_f = (_d = this.botSettings) === null || _d === void 0 ? void 0 : _d.liveagent) === null || _f === void 0 ? void 0 : _f.providers) === null || _g === void 0 ? void 0 : _g[liveAgentProviderNames[0]]) !== null && _h !== void 0 ? _h : null;
2557
+ let liveAgentBusinessHours = (_l = (_k = (_j = this.botSettings) === null || _j === void 0 ? void 0 : _j.liveagent) === null || _k === void 0 ? void 0 : _k.businessHours) !== null && _l !== void 0 ? _l : null;
2558
+ let liveAgentTimezone = (_p = (_o = (_m = this.botSettings) === null || _m === void 0 ? void 0 : _m.liveagent) === null || _o === void 0 ? void 0 : _o.timezone) !== null && _p !== void 0 ? _p : null;
2386
2559
  if (!liveAgentSettings) {
2387
2560
  console.error("No live agent settings found for the provider", liveAgentProviderNames[0]);
2388
2561
  this.announce("Live agent settings are unavailable");
@@ -2405,6 +2578,27 @@ const Ai12zBot = class {
2405
2578
  messageHistory: messageHistory,
2406
2579
  extraPrechatFormDetails,
2407
2580
  };
2581
+ this.liveAgentProviderName = liveAgentProviderNames[0];
2582
+ if (liveAgentBusinessHours && liveAgentTimezone) {
2583
+ let isWithinBusinessHours;
2584
+ try {
2585
+ isWithinBusinessHours = botHelpers.checkBusinessHours(liveAgentBusinessHours, liveAgentTimezone);
2586
+ }
2587
+ catch (e) {
2588
+ console.error("AI12Z: unexpected error evaluating business hours — blocking live agent connection", e);
2589
+ this.announce("Unexpected error evaluating business hours. Live agent connection blocked.");
2590
+ this.addEventMessage("Unexpected error evaluating business hours. Please try again later.");
2591
+ this.isTypingIndicatorVisible = false;
2592
+ return;
2593
+ }
2594
+ if (!isWithinBusinessHours) {
2595
+ const outsideHoursMsg = (_r = (_q = liveAgentSettings.config) === null || _q === void 0 ? void 0 : _q.outsideBusinessHoursMessage) !== null && _r !== void 0 ? _r : "Our live agents are currently offline. Please try again during our business hours.";
2596
+ this.addEventMessage(outsideHoursMsg);
2597
+ this.announce("Live agents are currently offline");
2598
+ this.isTypingIndicatorVisible = false;
2599
+ return;
2600
+ }
2601
+ }
2408
2602
  if (liveAgentProviderNames[0] === "liveagent") {
2409
2603
  if (!this.liveAgentRef) {
2410
2604
  this.isTypingIndicatorVisible = false;
@@ -2420,7 +2614,7 @@ const Ai12zBot = class {
2420
2614
  else {
2421
2615
  // Coerce to number; enforce minimum of 5 s to prevent misconfigured values;
2422
2616
  // fall back to 30 s when unset, non-numeric, or below the minimum.
2423
- const rawWait = Number((_f = liveAgentSettings === null || liveAgentSettings === void 0 ? void 0 : liveAgentSettings.config) === null || _f === void 0 ? void 0 : _f.maxWaitTime);
2617
+ const rawWait = Number((_s = liveAgentSettings === null || liveAgentSettings === void 0 ? void 0 : liveAgentSettings.config) === null || _s === void 0 ? void 0 : _s.maxWaitTime);
2424
2618
  const waitSeconds = Number.isFinite(rawWait) && rawWait >= 5 ? rawWait : 300;
2425
2619
  const timeoutMs = waitSeconds * 1000;
2426
2620
  // Step 1: register all listeners before connecting so no events are missed
@@ -2432,6 +2626,9 @@ const Ai12zBot = class {
2432
2626
  catch (err) {
2433
2627
  console.error("Live agent connection error:", err);
2434
2628
  this.isTypingIndicatorVisible = false;
2629
+ this.liveAgentSessionId = "";
2630
+ this.liveAgentConversationId = "";
2631
+ this.updateBotState();
2435
2632
  this.addEventMessage("Issue connecting to live agent. Please try again later.");
2436
2633
  this.announce("Issue connecting to live agent. Please try again later.");
2437
2634
  this.liveAgentEventHandler.disconnectLiveAgent();
@@ -2455,13 +2652,16 @@ const Ai12zBot = class {
2455
2652
  }
2456
2653
  catch (error) {
2457
2654
  // --- FAILURE LOGIC (TIMEOUT) ---
2655
+ this.liveAgentSessionId = "";
2656
+ this.liveAgentConversationId = "";
2458
2657
  this.isLiveAgent = false;
2459
2658
  this.isTypingIndicatorVisible = false;
2460
- const timeoutMsg = (_h = (_g = liveAgentSettings.config) === null || _g === void 0 ? void 0 : _g.maxWaitMessage) !== null && _h !== void 0 ? _h : "Sorry, no agents are available at the moment.";
2659
+ const timeoutMsg = (_u = (_t = liveAgentSettings.config) === null || _t === void 0 ? void 0 : _t.maxWaitMessage) !== null && _u !== void 0 ? _u : "Sorry, no agents are available at the moment.";
2461
2660
  this.removeFindingAgentPlaceholder();
2462
2661
  this.addEventMessage(timeoutMsg);
2463
2662
  this.liveAgentEventHandler.disconnectLiveAgent();
2464
2663
  this.clearEvents();
2664
+ this.updateBotState();
2465
2665
  this.announce("Agents are not available at this time.");
2466
2666
  // console.warn("Connection failed:", error.message)
2467
2667
  }
@@ -2515,6 +2715,10 @@ const Ai12zBot = class {
2515
2715
  projectId: (_c = this.botSettings) === null || _c === void 0 ? void 0 : _c.pId,
2516
2716
  configId: (_d = this.botSettings) === null || _d === void 0 ? void 0 : _d._id.$oid,
2517
2717
  newChat: this.messages.length === 0 ? true : false,
2718
+ isLiveAgent: this.isLiveAgent,
2719
+ liveAgentProviderName: this.liveAgentProviderName,
2720
+ liveAgentSessionId: this.liveAgentSessionId,
2721
+ liveAgentConversationId: this.liveAgentConversationId,
2518
2722
  };
2519
2723
  if (this.messages.length === 0) {
2520
2724
  this.conversationId = "";
@@ -2522,7 +2726,8 @@ const Ai12zBot = class {
2522
2726
  try {
2523
2727
  sessionStorage.setItem(sessionKey, JSON.stringify(newState));
2524
2728
  if (this.botSettings.cookies && getValidCookieDomain(this.botSettings.subDomain)) {
2525
- setJsonCookie(sessionKey, newState, { domain: this.botSettings.subDomain });
2729
+ const cookieState = __rest(newState, ["liveAgentSessionId", "liveAgentConversationId"]);
2730
+ setJsonCookie(sessionKey, cookieState, { domain: this.botSettings.subDomain });
2526
2731
  }
2527
2732
  }
2528
2733
  catch (error) {
@@ -2537,7 +2742,7 @@ const Ai12zBot = class {
2537
2742
  }
2538
2743
  }
2539
2744
  render() {
2540
- var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _w;
2745
+ var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _w, _x, _y;
2541
2746
  if (!this.canRender) {
2542
2747
  return (index.h(index.Host, null, index.h("span", { style: { display: "none" } }, "Failed to load ai12z bot control due to insufficient fund")));
2543
2748
  }
@@ -2551,7 +2756,7 @@ const Ai12zBot = class {
2551
2756
  display: this.isExpanded && this.isOpened ? "grid" : "none",
2552
2757
  opacity: this.isExpanded && this.isOpened ? "1" : "0",
2553
2758
  pointerEvents: this.isExpanded && this.isOpened ? "all" : "none",
2554
- } }), index.h("div", { class: "modal", "data-testid": "modal", "aria-hidden": "false", role: "dialog", "aria-modal": "true", tabindex: "-1", style: { display: this.isOpened ? "grid" : "none", opacity: this.isOpened ? "1" : "0", transform: this.isOpened ? "none" : "translateY(100%)" } }, index.h("header", { role: "banner" }, index.h("div", { class: "flex bg-white overflow-hidden border-b border-gray-90 border-solid md:pl-3 pl-4 justify-end md:rounded-t-xl items-center toolbar" }, index.h("div", { class: "flex gap-1 toolbar-overflow-actions" }, this.isLiveAgentEnabled && ((_g = (_f = this.botSettings) === null || _f === void 0 ? void 0 : _f.liveagent) === null || _g === void 0 ? void 0 : _g.liveagent) && (index.h("live-agent-chat", { config: (_j = (_h = this.botSettings) === null || _h === void 0 ? void 0 : _h.liveagent) === null || _j === void 0 ? void 0 : _j.liveagent, ref: el => (this.liveAgentRef = el) })), !this.showHistory && (index.h("button", { class: "rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 bot-btn-primary", tabindex: "0", "aria-label": "options menu", "aria-haspopup": "menu", "aria-expanded": this.isToggled ? "true" : "false", "aria-controls": "dropdown-menu", onClick: e => {
2759
+ } }), index.h("div", { class: "modal", "data-testid": "modal", "aria-hidden": "false", role: "dialog", "aria-modal": "true", tabindex: "-1", style: { display: this.isOpened ? "grid" : "none", opacity: this.isOpened ? "1" : "0", transform: this.isOpened ? "none" : "translateY(100%)" } }, index.h("header", { role: "banner" }, index.h("div", { class: "flex bg-white overflow-hidden border-b border-gray-90 border-solid md:pl-3 pl-4 justify-end md:rounded-t-xl items-center toolbar" }, index.h("div", { class: "flex gap-1 toolbar-overflow-actions" }, this.isLiveAgentEnabled && ((_h = (_g = (_f = this.botSettings) === null || _f === void 0 ? void 0 : _f.liveagent) === null || _g === void 0 ? void 0 : _g.providers) === null || _h === void 0 ? void 0 : _h.liveagent) && (index.h("live-agent-chat", { config: (_l = (_k = (_j = this.botSettings) === null || _j === void 0 ? void 0 : _j.liveagent) === null || _k === void 0 ? void 0 : _k.providers) === null || _l === void 0 ? void 0 : _l.liveagent, ref: el => (this.liveAgentRef = el) })), !this.showHistory && (index.h("button", { class: "rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 bot-btn-primary", tabindex: "0", "aria-label": "options menu", "aria-haspopup": "menu", "aria-expanded": this.isToggled ? "true" : "false", "aria-controls": "dropdown-menu", onClick: e => {
2555
2760
  e.preventDefault();
2556
2761
  e.stopPropagation();
2557
2762
  this.toggleBot(e);
@@ -2570,7 +2775,7 @@ const Ai12zBot = class {
2570
2775
  this.handleLiveAgentToolbarAction();
2571
2776
  }, onToggledChange: event => {
2572
2777
  this.isToggled = event.detail;
2573
- } })), ((_k = this.botSettings) === null || _k === void 0 ? void 0 : _k.botLogo) && index.h("img", { src: (_l = this.botSettings) === null || _l === void 0 ? void 0 : _l.botLogo, class: "w-8 h-8 rounded-lg", alt: "Bot Logo" }), index.h("h2", { class: "flex-1 pl-2 heading text-body1" }, (_m = this.botSettings) === null || _m === void 0 ? void 0 : _m.botName), index.h("div", { class: "buttons flex gap-2 p-[10px]" }, this.isLiveAgent && (index.h("button", { "aria-label": "End Live Agent", title: "End Live Agent", onClick: () => this.openEndLiveAgentDialog() }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 -960 960 960", width: "24px", fill: "#151313" }, index.h("path", { d: "m136-304-92-90q-12-12-12-28t12-28q88-95 203-142.5T480-640q118 0 232.5 47.5T916-450q12 12 12 28t-12 28l-92 90q-11 11-25.5 12t-26.5-8l-116-88q-8-6-12-14t-4-18v-114q-38-12-78-19t-82-7q-42 0-82 7t-78 19v114q0 10-4 18t-12 14l-116 88q-12 9-26.5 8T136-304Zm104-198q-29 15-56 34.5T128-424l40 40 72-56v-62Zm480 2v60l72 56 40-38q-29-26-56-45t-56-33Zm-480-2Zm480 2Z" })))), this.messages.length > 0 && (index.h("button", { class: "rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 bot-btn-primary", tabindex: "0", onClick: e => {
2778
+ } })), ((_m = this.botSettings) === null || _m === void 0 ? void 0 : _m.botLogo) && index.h("img", { src: (_o = this.botSettings) === null || _o === void 0 ? void 0 : _o.botLogo, class: "w-8 h-8 rounded-lg", alt: "Bot Logo" }), index.h("h2", { class: "flex-1 pl-2 heading text-body1" }, (_p = this.botSettings) === null || _p === void 0 ? void 0 : _p.botName), index.h("div", { class: "buttons flex gap-2 p-[10px]" }, this.isLiveAgent && (index.h("button", { "aria-label": "End Live Agent", title: "End Live Agent", onClick: () => this.openEndLiveAgentDialog() }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 -960 960 960", width: "24px", fill: "#151313" }, index.h("path", { d: "m136-304-92-90q-12-12-12-28t12-28q88-95 203-142.5T480-640q118 0 232.5 47.5T916-450q12 12 12 28t-12 28l-92 90q-11 11-25.5 12t-26.5-8l-116-88q-8-6-12-14t-4-18v-114q-38-12-78-19t-82-7q-42 0-82 7t-78 19v114q0 10-4 18t-12 14l-116 88q-12 9-26.5 8T136-304Zm104-198q-29 15-56 34.5T128-424l40 40 72-56v-62Zm480 2v60l72 56 40-38q-29-26-56-45t-56-33Zm-480-2Zm480 2Z" })))), this.messages.length > 0 && (index.h("button", { class: "rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 bot-btn-primary", tabindex: "0", onClick: e => {
2574
2779
  e.preventDefault();
2575
2780
  this.messages = [...[]];
2576
2781
  // this.conversationId = ""
@@ -2598,12 +2803,16 @@ const Ai12zBot = class {
2598
2803
  this.updateBotState();
2599
2804
  this.announce("Chat minimized");
2600
2805
  this.minimize.emit("minimize");
2601
- } }, index.h("i", { class: "block wes-icon--loading text-body2 modal-toolbar-icon", title: "Minimize Bot" }, index.h("svg", { viewBox: "0 0 26 26", xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", "aria-hidden": "true" }, index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M25 24.25C25 24.65 24.65 25 24.25 25H1.75C1.35 25 1 24.65 1 24.25V22.75C1 22.35 1.35 22 1.75 22H24.25C24.65 22 25 22.35 25 22.75V24.25Z" }))))))), index.h("div", { class: "flex-1 flex flex-col main", role: "main", "aria-labelledby": "chat-main-heading", id: "main-content", tabindex: "-1" }, index.h("h1", { id: "chat-main-heading", class: "sr-only" }, "Chat"), index.h("div", { class: "h-full flex flex-col chat-body" }, index.h("div", { class: "px-5 flex-[1_1_0] min-h-[calc(100%-1px)] flex flex-col gap-y-3 @md:px-3 messages-container", role: "region", "aria-labelledby": "messages-region-heading" }, index.h("h2", { id: "messages-region-heading", class: "sr-only" }, "Messages"), this.showWelcomeScreen && index.h("div", { class: "@md:px-6 pb-3 @md:pb-7 @md:pt-8 pt-5 text-display5", innerHTML: (_p = (_o = this.botSettings) === null || _o === void 0 ? void 0 : _o.welcome) === null || _p === void 0 ? void 0 : _p.message }), this.messages.length > 0 &&
2806
+ } }, index.h("i", { class: "block wes-icon--loading text-body2 modal-toolbar-icon", title: "Minimize Bot" }, index.h("svg", { viewBox: "0 0 26 26", xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", "aria-hidden": "true" }, index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M25 24.25C25 24.65 24.65 25 24.25 25H1.75C1.35 25 1 24.65 1 24.25V22.75C1 22.35 1.35 22 1.75 22H24.25C24.65 22 25 22.35 25 22.75V24.25Z" }))))))), index.h("div", { class: "flex-1 flex flex-col main", role: "main", "aria-labelledby": "chat-main-heading", id: "main-content", tabindex: "-1" }, index.h("h1", { id: "chat-main-heading", class: "sr-only" }, "Chat"), index.h("div", { class: "h-full flex flex-col chat-body" }, index.h("div", { class: "px-5 flex-[1_1_0] min-h-[calc(100%-1px)] flex flex-col gap-y-3 @md:px-3 messages-container", role: "region", "aria-labelledby": "messages-region-heading" }, index.h("h2", { id: "messages-region-heading", class: "sr-only" }, "Messages"), this.showWelcomeScreen && index.h("div", { class: "@md:px-6 pb-3 @md:pb-7 @md:pt-8 pt-5 text-display5", innerHTML: (_r = (_q = this.botSettings) === null || _q === void 0 ? void 0 : _q.welcome) === null || _r === void 0 ? void 0 : _r.message }), this.messages.length > 0 &&
2602
2807
  !this.showHistory &&
2603
2808
  this.messages.map((message, idx) => {
2604
- var _a, _b, _c, _d;
2605
2809
  // const showAvatar = !message.isUser && (idx === this.messages.length - 1 || this.messages[idx + 1]?.isUser === true)
2606
2810
  // const email = ""
2811
+ var _a, _b, _c, _d;
2812
+ // Render system event messages (e.g. "Agent has joined the chat") as a centered banner
2813
+ if (message.type === "system") {
2814
+ return (index.h("div", { class: "flex justify-center pb-3 message-item", role: "listitem", tabindex: -1, ref: el => (this.messageRefs[idx] = el), "aria-label": message.text }, index.h("span", { class: "text-[10px] font-medium text-gray-500 tracking-wide border-b border-gray-200 py-1 px-3 text-center" }, message.text)));
2815
+ }
2607
2816
  return (index.h("div", { class: `flex pb-3 gap-x-2 @md:gap-x-3
2608
2817
  ${message.isUser ? "self-end" : ""}
2609
2818
  ${message.isUser ? "justify-end" : ""} end-user-message message-item`, style: { opacity: "1", transform: "none" }, role: "listitem", tabindex: idx === this.focusedIndex ? 0 : -1, onKeyDown: e => this.handleMessageKeyNav(e, idx), ref: el => (this.messageRefs[idx] = el), "aria-label": `Message from ${message.isUser ? "User" : "Bot"}` }, message.isUser && !message.isHide && (index.h("div", { class: "flex flex-col items-end" }, index.h("div", { "data-testid": "message", class: "break-words @md:text-body2 box-border @md:pr-4 flex-1 rounded-lg py-2 px-4 user-msg text-body3", innerHTML: message.text, id: message.id, "aria-live": "polite", "aria-atomic": "false", "aria-label": message.text, role: "log" }, (_a = message === null || message === void 0 ? void 0 : message.images) === null || _a === void 0 ? void 0 : _a.map(img => {
@@ -2616,7 +2825,7 @@ const Ai12zBot = class {
2616
2825
  "opacity-90": !this.isProse,
2617
2826
  "max-w-full break-words @md:text-body2 box-border @md:pr-4 flex-1 rounded-lg text-gray-30 pr-2 text-body3": true,
2618
2827
  }, innerHTML: message.text, id: message.id }, message.isLoading && (index.h("div", { class: "w-full rounded-md", id: "spinner" }, index.h("div", { class: "flex animate-pulse space-x-4" }, index.h("div", { class: "flex-1 space-y-3 py-1" }, index.h("div", { class: "h-4 rounded bg-gray-200" }), index.h("div", { class: "space-y-3" }, index.h("div", { class: "grid grid-cols-3 gap-4" }, index.h("div", { class: "col-span-2 h-4 rounded bg-gray-200" }), index.h("div", { class: "col-span-1 h-4 rounded bg-gray-200" })), index.h("div", { class: "h-4 rounded bg-gray-200" }))))))), message.text !== "" && message.showIcon && ((_c = this.botSettings.showMessageIcons) !== null && _c !== void 0 ? _c : true) && (index.h("interaction-buttons", { message: message, chatArray: this.messages, currentIndex: idx, dataKey: this.dataKey, dataMode: this.dataMode, voice: this.voice, voiceType: this.voiceType, source: "bot", conversationId: this.conversationId, projectId: ((_d = this.botSettings) === null || _d === void 0 ? void 0 : _d.pId) || "" })), index.h("div", { class: "text-gray-30 pt-2 text-body4" }, this.botSettings.botName, " \u2022 ", message.timestamp)))));
2619
- }), this.showHistory && (index.h("chatbot-history", { chatList: this.conversationHistory, botName: (_q = this.botSettings) === null || _q === void 0 ? void 0 : _q.botName, styles: this.customStyle, scripts: this.customJS })), index.h("div", { class: "h-px pt-2px", style: { overflowAnchor: "auto" } })), index.h("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", class: "sr-only" }, this.announceMessage)))), index.h("form", { "data-testid": "user-input", class: `relative pointer-events-auto ${this.isOpened ? "p-2.5" : ""} searchform user-input`, "aria-label": "Message Area", "aria-hidden": "false", style: { opacity: !this.isMinimized ? "1" : "0", transform: "translateX(0)", pointerEvents: !this.isMinimized ? "auto" : "none" } }, !this.isOpened && (index.h("div", { class: `absolute right-4 md:right-0 border-2 border-white border-solid rounded-full ${this.isContent ? "" : "top-0"} minimize-input` }, index.h("button", { class: "rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-gray-500 bg-opacity-60 hover:bg-opacity-80 h-5 w-5 bot-btn-primary", "aria-label": "Minimize Bot", tabindex: "0", onClick: e => {
2828
+ }), this.showHistory && (index.h("chatbot-history", { chatList: this.conversationHistory, botName: (_s = this.botSettings) === null || _s === void 0 ? void 0 : _s.botName, styles: this.customStyle, scripts: this.customJS })), index.h("div", { class: "h-px pt-2px", style: { overflowAnchor: "auto" } })), index.h("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", class: "sr-only" }, this.announceMessage)))), index.h("form", { "data-testid": "user-input", class: `relative pointer-events-auto ${this.isOpened ? "p-2.5" : ""} searchform user-input`, "aria-label": "Message Area", "aria-hidden": "false", style: { opacity: !this.isMinimized ? "1" : "0", transform: "translateX(0)", pointerEvents: !this.isMinimized ? "auto" : "none" } }, !this.isOpened && (index.h("div", { class: `absolute right-4 md:right-0 border-2 border-white border-solid rounded-full ${this.isContent ? "" : "top-0"} minimize-input` }, index.h("button", { class: "rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-gray-500 bg-opacity-60 hover:bg-opacity-80 h-5 w-5 bot-btn-primary", "aria-label": "Minimize Bot", tabindex: "0", onClick: e => {
2620
2829
  e.preventDefault();
2621
2830
  this.isMinimized = !this.isMinimized;
2622
2831
  this.isOpened = !this.isMinimized;
@@ -2648,12 +2857,12 @@ const Ai12zBot = class {
2648
2857
  .filter(Boolean)
2649
2858
  .join(" "), "aria-placeholder": this.isLiveAgent
2650
2859
  ? "Type a message to the agent..."
2651
- : ((_r = this.botSettings) === null || _r === void 0 ? void 0 : _r.botPlaceholderText) !== ""
2652
- ? (_s = this.botSettings) === null || _s === void 0 ? void 0 : _s.botPlaceholderText
2653
- : "Ask me anything", "aria-label": "Type your message here", class: `resize-none overflow-hidden text-ellipsis focus:outline-none w-full custom-input ${this.hideAllButtons ? "hidden" : ""}`, "data-testid": "user-input-textarea", rows: this.rowCount, name: "userMessage", placeholder: this.isLiveAgent
2654
- ? "Type a message to the agent..."
2655
2860
  : ((_t = this.botSettings) === null || _t === void 0 ? void 0 : _t.botPlaceholderText) !== ""
2656
2861
  ? (_u = this.botSettings) === null || _u === void 0 ? void 0 : _u.botPlaceholderText
2862
+ : "Ask me anything", "aria-label": "Type your message here", class: `resize-none overflow-hidden text-ellipsis focus:outline-none w-full custom-input ${this.hideAllButtons ? "hidden" : ""}`, "data-testid": "user-input-textarea", rows: this.rowCount, name: "userMessage", placeholder: this.isLiveAgent
2863
+ ? "Type a message to the agent..."
2864
+ : ((_w = this.botSettings) === null || _w === void 0 ? void 0 : _w.botPlaceholderText) !== ""
2865
+ ? (_x = this.botSettings) === null || _x === void 0 ? void 0 : _x.botPlaceholderText
2657
2866
  : "Ask me anything", ref: el => (this.inputEl = el), onKeyUp: _e => {
2658
2867
  this.adjustHeight();
2659
2868
  }, onKeyDown: e => {
@@ -2715,8 +2924,8 @@ const Ai12zBot = class {
2715
2924
  }, onClick: () => {
2716
2925
  this.openChat();
2717
2926
  }
2718
- }, this.isBot && index.h("slot", { name: "bot" }), !this.isBot && (index.h("button", { class: "rounded-full flex cursor-pointer items-center pr-[14px] md:gap-x-3 focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-blue-focused bot-btn-primary", tabindex: "0", "aria-label": "open Bot" }, index.h("div", { class: "w-10 h-10 flex items-center justify-center bg-white rounded-full border relative" }, this.botSettings.botLaunchIcon && index.h("img", { src: this.botSettings.botLaunchIcon, alt: "bot icon", class: "w-8 h-8 rounded-lg" }), !this.botSettings.botLaunchIcon && (index.h("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", stroke: "#2095ae", "aria-hidden": "true" }, index.h("g", { "stroke-width": "0" }), index.h("g", { "stroke-linecap": "round", "stroke-linejoin": "round" }), index.h("g", null, " ", index.h("path", { d: "M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z", stroke: "#2095ae", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }), " ")))), index.h("span", { class: "bot-name" }, " ", (_w = this.botSettings) === null || _w === void 0 ? void 0 :
2719
- _w.botName, " ")))))), index.h("keyboard-shortcuts-dialog", { show: this.showShortcutsDialog, shortcuts: this.shortcuts, onCloseDialog: () => {
2927
+ }, this.isBot && index.h("slot", { name: "bot" }), !this.isBot && (index.h("button", { class: "rounded-full flex cursor-pointer items-center pr-[14px] md:gap-x-3 focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-blue-focused bot-btn-primary", tabindex: "0", "aria-label": "open Bot" }, index.h("div", { class: "w-10 h-10 flex items-center justify-center bg-white rounded-full border relative" }, this.botSettings.botLaunchIcon && index.h("img", { src: this.botSettings.botLaunchIcon, alt: "bot icon", class: "w-8 h-8 rounded-lg" }), !this.botSettings.botLaunchIcon && (index.h("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", stroke: "#2095ae", "aria-hidden": "true" }, index.h("g", { "stroke-width": "0" }), index.h("g", { "stroke-linecap": "round", "stroke-linejoin": "round" }), index.h("g", null, " ", index.h("path", { d: "M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z", stroke: "#2095ae", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }), " ")))), index.h("span", { class: "bot-name" }, " ", (_y = this.botSettings) === null || _y === void 0 ? void 0 :
2928
+ _y.botName, " ")))))), index.h("keyboard-shortcuts-dialog", { show: this.showShortcutsDialog, shortcuts: this.shortcuts, onCloseDialog: () => {
2720
2929
  this.showShortcutsDialog = false;
2721
2930
  } }), index.h("delete-confirmation-modal", { show: this.showLiveAgentEndDialog, dialogTitle: "End live agent chat?", message: "You are about to end the current live agent conversation. You can continue chatting with the bot after ending it.", confirmButtonText: "End", onConfirmDelete: () => {
2722
2931
  this.confirmEndLiveAgent();