ai12z 3.15.1 → 3.16.1-alpha.2
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/cjs/{SearchResult-DirxAsMi.js → SearchResult-CvTJr55G.js} +1 -1
- package/dist/cjs/ai12z-bot.cjs.entry.js +205 -70
- package/dist/cjs/ai12z-category_2.cjs.entry.js +7 -7
- package/dist/cjs/ai12z-chat-message.cjs.entry.js +14 -14
- package/dist/cjs/ai12z-chat_2.cjs.entry.js +163 -46
- package/dist/cjs/ai12z-container.cjs.entry.js +4 -4
- package/dist/cjs/ai12z-cta.cjs.entry.js +15 -13
- package/dist/cjs/ai12z-form.cjs.entry.js +9 -6
- package/dist/cjs/ai12z-inline-search.cjs.entry.js +8 -8
- package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +11 -11
- package/dist/cjs/ai12z-search-panel.cjs.entry.js +8 -8
- package/dist/cjs/ai12z-spinner.cjs.entry.js +2 -2
- package/dist/cjs/{app-store-D249GRTi.js → app-store-BtkiHvcw.js} +1 -1
- package/dist/cjs/chat-avatar_6.cjs.entry.js +16 -15
- package/dist/cjs/chatbot-history_2.cjs.entry.js +1 -1
- package/dist/cjs/{ctaHelpers-C155mCQE.js → ctaHelpers-DUPj5SnE.js} +1 -1
- package/dist/cjs/dynamic-form.cjs.entry.js +4 -4
- package/dist/cjs/image-uploader_2.cjs.entry.js +2 -2
- package/dist/cjs/{index-7yvwbcAl.js → index-CKLC7f4y.js} +1 -1
- package/dist/cjs/{index-Ct2DwlDF.js → index-v8T1EJAJ.js} +1 -1
- package/dist/cjs/index.cjs.js +15 -15
- package/dist/cjs/item-list.cjs.entry.js +7 -4
- package/dist/cjs/{keyboard-shortcuts-WOyQOe62.js → keyboard-shortcuts-BWprLtLj.js} +2 -2
- package/dist/cjs/library.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{logger-B_JTV5L8.js → logger-2ZBZCKdM.js} +1 -1
- package/dist/cjs/{parseHelper-DjDPCQ3f.js → parseHelper-5fRVefLm.js} +2 -2
- package/dist/cjs/{processCarouselData-6FLCPOVT.js → processCarouselData-kCVPE4mw.js} +1 -1
- package/dist/cjs/{reCaptchaHelpers-BIbBtULr.js → reCaptchaHelpers-sfktrnTF.js} +1 -1
- package/dist/cjs/{scriptStyleLoader-8VXGYoY8.js → scriptStyleLoader-D-bqKqSb.js} +4 -2
- package/dist/cjs/search-results-page.cjs.entry.js +20 -20
- package/dist/cjs/{socket-service-CUHVVM8r.js → socket-service-5mM7NSYN.js} +2 -2
- package/dist/cjs/{styleSheetRegistry-Cf6kOnS3.js → styleSheetRegistry-CaWjqgX7.js} +1 -1
- package/dist/cjs/{surveyHelpers-CnSWyzvp.js → surveyHelpers-DohugkWP.js} +1 -1
- package/dist/cjs/{utils-BkemWeq3.js → utils-7C5_GnyF.js} +1 -1
- package/dist/collection/components/ai12z-bot/ai12z-bot.js +116 -48
- package/dist/collection/components/ai12z-bot/ai12z-chatbot.css +17 -17
- package/dist/collection/components/ai12z-bot/components/interaction-buttons/interaction-buttons.js +12 -11
- package/dist/collection/components/ai12z-bot/privacy-modal.js +2 -2
- package/dist/collection/components/ai12z-cta/ai12z-cta.css +34 -38
- package/dist/collection/components/ai12z-cta/ai12z-cta.js +6 -6
- package/dist/collection/components/ai12z-cta/components/Chat.js +3 -6
- package/dist/collection/components/ai12z-cta/components/DynamicForm.js +3 -3
- package/dist/collection/components/ai12z-cta/components/ai12z-chat.css +17 -17
- package/dist/collection/components/ai12z-cta/components/itemlist/item-list.js +5 -2
- package/dist/collection/components/ai12z-form/ai12z-form.js +5 -2
- package/dist/collection/components/ai12z-inline-search/ai12z-inline-search.js +4 -4
- package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.css +3 -3
- package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js +4 -4
- package/dist/collection/components/ai12z-knowledge-box/components/ai12z-chat-message.js +11 -11
- package/dist/collection/components/ai12z-search-panel/ai12z-search-panel.css +17 -17
- package/dist/collection/components/ai12z-search-panel/ai12z-search-panel.js +4 -4
- package/dist/collection/components/ai12z-search-panel/search-results-view.css +31 -31
- package/dist/collection/components/ai12z-search-panel/search-results-view.js +14 -14
- package/dist/collection/components/input/Input.js +148 -28
- package/dist/collection/components/input/input.css +151 -15
- package/dist/collection/components/spinner/Spinner.js +1 -1
- package/dist/collection/global/tailwind.css +1 -0
- package/dist/collection/utils/liveagents/providers/salesforce.js +77 -10
- package/dist/collection/utils/scriptStyleLoader.js +3 -2
- package/dist/components/ai12z-bot.js +1 -1
- package/dist/components/ai12z-category.js +1 -1
- package/dist/components/ai12z-chat-message.js +1 -1
- package/dist/components/ai12z-chat.js +1 -1
- package/dist/components/ai12z-container.js +1 -1
- package/dist/components/ai12z-cta.js +1 -1
- package/dist/components/ai12z-form.js +1 -1
- package/dist/components/ai12z-inline-search.js +1 -1
- package/dist/components/ai12z-input-form.js +1 -1
- package/dist/components/ai12z-knowledge-box.js +1 -1
- package/dist/components/ai12z-search-panel.js +1 -1
- package/dist/components/ai12z-spinner.js +1 -1
- package/dist/components/audio-recorder.js +1 -1
- package/dist/components/chat-avatar.js +1 -1
- package/dist/components/chatbot-history.js +1 -1
- package/dist/components/delete-confirmation-modal.js +1 -1
- package/dist/components/dynamic-form.js +1 -1
- package/dist/components/hamburger-menu.js +1 -1
- package/dist/components/image-uploader.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/interaction-buttons.js +1 -1
- package/dist/components/item-list.js +1 -1
- package/dist/components/keyboard-shortcuts-dialog.js +1 -1
- package/dist/components/live-agent-chat.js +1 -1
- package/dist/components/p-9ZSKFUQq.js +1 -0
- package/dist/components/p-B8jSr9lW.js +1 -0
- package/dist/components/{p-nIR_us0u.js → p-BBkc2Zz3.js} +1 -1
- package/dist/components/{p-BczaHEQv.js → p-BGqU6S_C.js} +1 -1
- package/dist/components/p-BHZ4-nkE.js +1 -0
- package/dist/components/{p-BkJ2N8cm.js → p-BOiNZwPJ.js} +1 -1
- package/dist/components/{p-Cul4gRY4.js → p-BugQD-4q.js} +1 -1
- package/dist/components/p-C0caR14R.js +1 -0
- package/dist/components/{p-Crr5-qOu.js → p-C2pbHN4a.js} +1 -1
- package/dist/components/{p-BSva-YCE.js → p-C3JmvA9z.js} +1 -1
- package/dist/components/{p-DPq7OOGr.js → p-C3hnDJ1x.js} +1 -1
- package/dist/components/{p-BvLFdH7U.js → p-C5rVF0zE.js} +2 -2
- package/dist/components/{p-DBIwC6w6.js → p-CGQBDC3e.js} +2 -2
- package/dist/components/{p-DpEYThNR.js → p-COOdy5C-.js} +1 -1
- package/dist/components/p-CcfettiK.js +1 -0
- package/dist/components/p-CfmVopBG.js +1 -0
- package/dist/components/{p-DtdLjSwM.js → p-Cv-HbFj1.js} +1 -1
- package/dist/components/p-D-mcIUO8.js +1 -0
- package/dist/components/{p-U4xTjAZs.js → p-DEkZRvM1.js} +1 -1
- package/dist/components/p-DQKllbP7.js +1 -0
- package/dist/components/{p-ZGVz1_9H.js → p-De--d4FT.js} +2 -2
- package/dist/components/{p-QO3g1E0T.js → p-DiUq1_cL.js} +1 -1
- package/dist/components/{p-BwTPnzKJ.js → p-DlmdK220.js} +1 -1
- package/dist/components/p-DndtP5Bd.js +1 -0
- package/dist/components/{p-CLtV90Um.js → p-DvJUX5RM.js} +1 -1
- package/dist/components/p-GhhnA1Fw.js +1 -0
- package/dist/components/{p-3BAAsU08.js → p-NQcpUWMC.js} +1 -1
- package/dist/components/{p-D2lp8C5d.js → p-Q3uBgncp.js} +1 -1
- package/dist/components/p-ZQeNPv0R.js +1 -0
- package/dist/components/p-hbJqzZAj.js +1 -0
- package/dist/components/p-jD70af30.js +1 -0
- package/dist/components/{p-DV6vheeJ.js → p-k5IjpIIA.js} +1 -1
- package/dist/components/p-tEjcbjhZ.js +1 -0
- package/dist/components/privacy-modal.js +1 -1
- package/dist/components/search-results-page.js +1 -1
- package/dist/components/typing-indicator.js +1 -1
- package/dist/esm/{SearchResult-zLaEhc3L.js → SearchResult-C3g6BSvv.js} +1 -1
- package/dist/esm/ai12z-bot.entry.js +205 -70
- package/dist/esm/ai12z-category_2.entry.js +7 -7
- package/dist/esm/ai12z-chat-message.entry.js +14 -14
- package/dist/esm/ai12z-chat_2.entry.js +163 -46
- package/dist/esm/ai12z-container.entry.js +4 -4
- package/dist/esm/ai12z-cta.entry.js +15 -13
- package/dist/esm/ai12z-form.entry.js +9 -6
- package/dist/esm/ai12z-inline-search.entry.js +8 -8
- package/dist/esm/ai12z-knowledge-box.entry.js +11 -11
- package/dist/esm/ai12z-search-panel.entry.js +8 -8
- package/dist/esm/ai12z-spinner.entry.js +2 -2
- package/dist/esm/{app-store-DYN4CiXV.js → app-store-BSQPOUME.js} +1 -1
- package/dist/esm/chat-avatar_6.entry.js +16 -15
- package/dist/esm/chatbot-history_2.entry.js +1 -1
- package/dist/esm/{ctaHelpers-C4e51qnO.js → ctaHelpers-BOdS23pG.js} +1 -1
- package/dist/esm/dynamic-form.entry.js +4 -4
- package/dist/esm/image-uploader_2.entry.js +2 -2
- package/dist/esm/{index-BNpVu1WU.js → index-B9OPtxv2.js} +1 -1
- package/dist/esm/{index-B1TMiWhO.js → index-CZVgVfgd.js} +1 -1
- package/dist/esm/index.js +15 -15
- package/dist/esm/item-list.entry.js +7 -4
- package/dist/esm/{keyboard-shortcuts-Bk21yvRt.js → keyboard-shortcuts-9ySnK42C.js} +2 -2
- package/dist/esm/library.js +2 -2
- package/dist/esm/loader.js +2 -2
- package/dist/esm/{logger-DUcx64Gz.js → logger-C0PEnW3T.js} +1 -1
- package/dist/esm/{parseHelper-gVIHT7hQ.js → parseHelper-TNZZ7pZJ.js} +2 -2
- package/dist/esm/{processCarouselData-DVQDRd62.js → processCarouselData-BbqNSwni.js} +1 -1
- package/dist/esm/{reCaptchaHelpers-OYM0kzvt.js → reCaptchaHelpers-BRdKn-CM.js} +1 -1
- package/dist/esm/{scriptStyleLoader-DXBxSLgN.js → scriptStyleLoader-_-YNtQPs.js} +4 -2
- package/dist/esm/search-results-page.entry.js +20 -20
- package/dist/esm/{socket-service-Cg81jrif.js → socket-service-BaSfS-C4.js} +2 -2
- package/dist/esm/{styleSheetRegistry-CE8gVmmQ.js → styleSheetRegistry-BccKic5X.js} +1 -1
- package/dist/esm/{surveyHelpers-AQCMAhqW.js → surveyHelpers-BeCs_jb6.js} +1 -1
- package/dist/esm/{utils-CULbS8sV.js → utils-C75qrx0v.js} +1 -1
- package/dist/library/index.esm.js +1 -1
- package/dist/library/library.esm.js +1 -1
- package/dist/library/p-03e6c526.entry.js +1 -0
- package/dist/library/p-09ccce13.entry.js +1 -0
- package/dist/library/{p-8bfd66d2.entry.js → p-0a6d1461.entry.js} +1 -1
- package/dist/library/p-1174b3f9.entry.js +1 -0
- package/dist/library/{p-834a8cbd.entry.js → p-21e30d74.entry.js} +1 -1
- package/dist/library/p-48be863a.entry.js +1 -0
- package/dist/library/p-4b1b23ad.entry.js +1 -0
- package/dist/library/p-4f5c680e.entry.js +1 -0
- package/dist/library/{p-0f3e9ab9.entry.js → p-6c81c334.entry.js} +2 -2
- package/dist/library/p-74379d4c.entry.js +1 -0
- package/dist/library/p-8f41d206.entry.js +1 -0
- package/dist/library/p-97c4b33d.entry.js +1 -0
- package/dist/library/{p-CV0mPAnV.js → p-B18nLcR3.js} +1 -1
- package/dist/library/{p-BNpVu1WU.js → p-B9OPtxv2.js} +2 -2
- package/dist/library/{p-Ct8sQ1U7.js → p-BdtAdObU.js} +1 -1
- package/dist/library/{p-BQ6J3hmg.js → p-C33Bq1u3.js} +1 -1
- package/dist/library/{p-eEaKza-p.js → p-C7dGy5Bg.js} +1 -1
- package/dist/library/{p-C-TEC3kM.js → p-C7riVXol.js} +1 -1
- package/dist/library/{p-CkF7XHob.js → p-CVoJ6Qcc.js} +1 -1
- package/dist/library/{p-uxR195i6.js → p-CZ_3jJSY.js} +1 -1
- package/dist/library/{p-t-IIK8Lf.js → p-CfHNdl7N.js} +1 -1
- package/dist/library/{p-CCX5tDch.js → p-CqE4eXes.js} +1 -1
- package/dist/library/{p-C0mTjqwo.js → p-CsG0EN7R.js} +1 -1
- package/dist/library/{p-K29FTcpc.js → p-D5B5YlEl.js} +1 -1
- package/dist/library/{p-9vi1mn3E.js → p-DginFHFR.js} +1 -1
- package/dist/library/{p-8-Jaom_c.js → p-SsXpfHmP.js} +1 -1
- package/dist/library/p-_4Q98Hn5.js +1 -0
- package/dist/library/p-ac9bbba9.entry.js +1 -0
- package/dist/library/p-b744339c.entry.js +1 -0
- package/dist/library/p-cd6d00c7.entry.js +1 -0
- package/dist/library/p-d20ffcd1.entry.js +1 -0
- package/dist/library/{p-45a98c22.entry.js → p-d39e26f2.entry.js} +1 -1
- package/dist/types/components/ai12z-bot/ai12z-bot.d.ts +13 -0
- package/dist/types/components/input/Input.d.ts +17 -1
- package/dist/types/utils/liveagents/providers/salesforce.d.ts +1 -0
- package/package.json +3 -2
- package/dist/components/p-B6Z8iUC6.js +0 -1
- package/dist/components/p-BNi-pmSE.js +0 -1
- package/dist/components/p-BmUFHK-0.js +0 -1
- package/dist/components/p-C81g_cTG.js +0 -1
- package/dist/components/p-C9rXDQ8C.js +0 -1
- package/dist/components/p-DU8l3fUF.js +0 -1
- package/dist/components/p-DXBxSLgN.js +0 -1
- package/dist/components/p-DXCT5yQi.js +0 -1
- package/dist/components/p-Df9qc2ID.js +0 -1
- package/dist/components/p-H_Oufd6v.js +0 -1
- package/dist/components/p-T7hfVn0q.js +0 -1
- package/dist/components/p-VgIOw1rD.js +0 -1
- package/dist/components/p-bq6ZwcFk.js +0 -1
- package/dist/components/p-c9R9wdZM.js +0 -1
- package/dist/library/p-0064ee30.entry.js +0 -1
- package/dist/library/p-0e878a47.entry.js +0 -1
- package/dist/library/p-1b526a0b.entry.js +0 -1
- package/dist/library/p-31191f51.entry.js +0 -1
- package/dist/library/p-352117bd.entry.js +0 -1
- package/dist/library/p-35d4d829.entry.js +0 -1
- package/dist/library/p-3ec86817.entry.js +0 -1
- package/dist/library/p-4db922ec.entry.js +0 -1
- package/dist/library/p-84168066.entry.js +0 -1
- package/dist/library/p-8c5400c6.entry.js +0 -1
- package/dist/library/p-DXBxSLgN.js +0 -1
- package/dist/library/p-cfc2295e.entry.js +0 -1
- package/dist/library/p-d0e0337d.entry.js +0 -1
- package/dist/library/p-ffd7e67a.entry.js +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-v8T1EJAJ.js');
|
|
4
4
|
var responseAdapter = require('./response-adapter-CKKyyhMj.js');
|
|
5
|
-
var processCarouselData = require('./processCarouselData-
|
|
6
|
-
var logger$1 = require('./logger-
|
|
7
|
-
var utils = require('./utils-
|
|
8
|
-
var index$1 = require('./index-
|
|
5
|
+
var processCarouselData = require('./processCarouselData-kCVPE4mw.js');
|
|
6
|
+
var logger$1 = require('./logger-2ZBZCKdM.js');
|
|
7
|
+
var utils = require('./utils-7C5_GnyF.js');
|
|
8
|
+
var index$1 = require('./index-CKLC7f4y.js');
|
|
9
9
|
var globalStore = require('./global-store-R6x06KvJ.js');
|
|
10
|
-
var reCaptchaHelpers = require('./reCaptchaHelpers-
|
|
10
|
+
var reCaptchaHelpers = require('./reCaptchaHelpers-sfktrnTF.js');
|
|
11
11
|
var botHelpers = require('./botHelpers-D5Dj7TRA.js');
|
|
12
|
-
var surveyHelpers = require('./surveyHelpers-
|
|
13
|
-
var scriptStyleLoader = require('./scriptStyleLoader-
|
|
14
|
-
var keyboardShortcuts = require('./keyboard-shortcuts-
|
|
15
|
-
var ctaHelpers = require('./ctaHelpers-
|
|
16
|
-
var appStore = require('./app-store-
|
|
17
|
-
var parseHelper = require('./parseHelper-
|
|
12
|
+
var surveyHelpers = require('./surveyHelpers-DohugkWP.js');
|
|
13
|
+
var scriptStyleLoader = require('./scriptStyleLoader-D-bqKqSb.js');
|
|
14
|
+
var keyboardShortcuts = require('./keyboard-shortcuts-BWprLtLj.js');
|
|
15
|
+
var ctaHelpers = require('./ctaHelpers-DUPj5SnE.js');
|
|
16
|
+
var appStore = require('./app-store-BtkiHvcw.js');
|
|
17
|
+
var parseHelper = require('./parseHelper-5fRVefLm.js');
|
|
18
18
|
require('./_commonjsHelpers-MBWFX2dn.js');
|
|
19
19
|
|
|
20
20
|
// ILiveAgentProvider.ts
|
|
@@ -406,6 +406,7 @@ class SalesforceLiveAgentProvider {
|
|
|
406
406
|
return "unknown";
|
|
407
407
|
}
|
|
408
408
|
handleSessionStatusChange(event) {
|
|
409
|
+
var _a;
|
|
409
410
|
try {
|
|
410
411
|
if (!event.data)
|
|
411
412
|
return;
|
|
@@ -416,6 +417,18 @@ class SalesforceLiveAgentProvider {
|
|
|
416
417
|
if ((entryPayload === null || entryPayload === void 0 ? void 0 : entryPayload.sessionStatus) === "Active") {
|
|
417
418
|
ChatEventBus.emit("AGENT_SESSION_CREATED", true);
|
|
418
419
|
}
|
|
420
|
+
else if ((entryPayload === null || entryPayload === void 0 ? void 0 : entryPayload.sessionStatus) === "Ended") {
|
|
421
|
+
// The agent (or system) ended the session. Salesforce's authoritative
|
|
422
|
+
// CloseConversation event can lag by minutes, so end the live-agent
|
|
423
|
+
// session now — otherwise the user is stuck in "Type a message to the
|
|
424
|
+
// agent" mode with no indication the agent left. This is transfer-safe:
|
|
425
|
+
// a transfer keeps the session "Active", only a real end reports "Ended".
|
|
426
|
+
ChatEventBus.emit("CONVERSATION_CLOSED", true);
|
|
427
|
+
// Mirror the CloseConversation case: tear down the SSE connection too.
|
|
428
|
+
// Closing halts delivery of the registered named listeners, so the now-
|
|
429
|
+
// redundant (and delayed) CloseConversation event won't reopen this path.
|
|
430
|
+
(_a = this.eventSource) === null || _a === void 0 ? void 0 : _a.close();
|
|
431
|
+
}
|
|
419
432
|
}
|
|
420
433
|
catch (error) {
|
|
421
434
|
logger.error("Error handling session status change event:", error);
|
|
@@ -423,19 +436,31 @@ class SalesforceLiveAgentProvider {
|
|
|
423
436
|
}
|
|
424
437
|
}
|
|
425
438
|
listenToMessages() {
|
|
426
|
-
var _a, _b, _c;
|
|
439
|
+
var _a, _b, _c, _d;
|
|
427
440
|
logger.debug("Listening to messages from Salesforce Live Agent");
|
|
428
441
|
// this.endpointSSE = "http://localhost:5050"
|
|
429
|
-
|
|
442
|
+
// Close any existing connection before opening a new one (e.g. on resume)
|
|
443
|
+
// so we don't leak a dangling SSE stream.
|
|
444
|
+
(_a = this.eventSource) === null || _a === void 0 ? void 0 : _a.close();
|
|
445
|
+
const eventSource = new EventSource(`${this.endpointSSE}/bot/liveagent/sse?token=${(_b = this.sessionContext) === null || _b === void 0 ? void 0 : _b.accessToken}&org_id=${(_c = this.configSettings) === null || _c === void 0 ? void 0 : _c.orgId}&sse_url=${(_d = this.configSettings) === null || _d === void 0 ? void 0 : _d.instanceUrl}`, {
|
|
430
446
|
withCredentials: true,
|
|
431
447
|
});
|
|
432
448
|
if (!eventSource) {
|
|
433
449
|
logger.error("Failed to create EventSource");
|
|
434
450
|
throw new Error("Failed to create EventSource");
|
|
435
451
|
}
|
|
436
|
-
eventSource
|
|
437
|
-
|
|
438
|
-
//
|
|
452
|
+
this.eventSource = eventSource;
|
|
453
|
+
eventSource.onerror = (event) => {
|
|
454
|
+
// Native EventSource routes BOTH transport failures and any server-sent
|
|
455
|
+
// `event: error` frame to this same "error" channel (WHATWG spec: a frame
|
|
456
|
+
// with `event: error` dispatches a MessageEvent of type "error"). A server
|
|
457
|
+
// frame carries `.data`; a transport failure is a bare Event. Read the data
|
|
458
|
+
// when present so an upstream rejection is logged with its status rather
|
|
459
|
+
// than as a generic "connection lost". (The proxy also sends a dedicated
|
|
460
|
+
// `upstream_error` event — see below — which is the preferred, unambiguous
|
|
461
|
+
// channel; this stays as a defensive fallback.)
|
|
462
|
+
const data = event === null || event === void 0 ? void 0 : event.data;
|
|
463
|
+
logger.error(typeof data === "string" && data ? `❌ SSE server error frame: ${data}` : "❌ SSE Error: Connection lost or error occurred");
|
|
439
464
|
ChatEventBus.emit("AGENT_ERROR", true);
|
|
440
465
|
// Optionally, you can close the EventSource if needed
|
|
441
466
|
eventSource.close();
|
|
@@ -444,7 +469,7 @@ class SalesforceLiveAgentProvider {
|
|
|
444
469
|
logger.debug("✅ SSE Connection Established");
|
|
445
470
|
// ChatEventBus.emit("liveAgentReady", undefined)
|
|
446
471
|
};
|
|
447
|
-
|
|
472
|
+
const handleSSEMessage = (event) => {
|
|
448
473
|
var _a, _b;
|
|
449
474
|
try {
|
|
450
475
|
const parsedEventData = JSON.parse(event.data);
|
|
@@ -508,6 +533,45 @@ class SalesforceLiveAgentProvider {
|
|
|
508
533
|
return;
|
|
509
534
|
}
|
|
510
535
|
};
|
|
536
|
+
// Salesforce MIAW delivers NAMED SSE events (event:CONVERSATION_*), which do
|
|
537
|
+
// NOT trigger EventSource.onmessage — that only fires for unnamed "message"
|
|
538
|
+
// events. Register the handler for each named conversation event (and keep
|
|
539
|
+
// onmessage as a fallback) so the lifecycle events are actually processed.
|
|
540
|
+
// Without this the widget never sees SessionStatusChanged/ParticipantChanged,
|
|
541
|
+
// never emits AGENT_SESSION_CREATED, times out, and tears down the session.
|
|
542
|
+
//
|
|
543
|
+
// Single source of truth: every conversationEntry.entryType the handleSSEMessage
|
|
544
|
+
// switch above handles maps 1:1 to its named CONVERSATION_* event here. Keep
|
|
545
|
+
// this map in sync with the switch — a missing entry means that event is
|
|
546
|
+
// silently never delivered (that is exactly what happened to StreamingToken /
|
|
547
|
+
// ProgressIndicator before this map existed).
|
|
548
|
+
const SF_ENTRY_EVENT_MAP = {
|
|
549
|
+
Message: "CONVERSATION_MESSAGE",
|
|
550
|
+
RoutingResult: "CONVERSATION_ROUTING_RESULT",
|
|
551
|
+
RoutingWorkResult: "CONVERSATION_ROUTING_WORK_RESULT",
|
|
552
|
+
ParticipantChanged: "CONVERSATION_PARTICIPANT_CHANGED",
|
|
553
|
+
TypingStartedIndicator: "CONVERSATION_TYPING_STARTED_INDICATOR",
|
|
554
|
+
TypingStoppedIndicator: "CONVERSATION_TYPING_STOPPED_INDICATOR",
|
|
555
|
+
DeliveryAcknowledgement: "CONVERSATION_DELIVERY_ACKNOWLEDGEMENT",
|
|
556
|
+
ReadAcknowledgement: "CONVERSATION_READ_ACKNOWLEDGEMENT",
|
|
557
|
+
CloseConversation: "CONVERSATION_CLOSE_CONVERSATION",
|
|
558
|
+
StreamingToken: "CONVERSATION_STREAMING_TOKEN",
|
|
559
|
+
ProgressIndicator: "CONVERSATION_PROGRESS_INDICATOR",
|
|
560
|
+
SessionStatusChanged: "CONVERSATION_SESSION_STATUS_CHANGED",
|
|
561
|
+
};
|
|
562
|
+
Object.values(SF_ENTRY_EVENT_MAP).forEach(type => eventSource.addEventListener(type, handleSSEMessage));
|
|
563
|
+
eventSource.onmessage = handleSSEMessage;
|
|
564
|
+
// The SSE proxy signals a Salesforce upstream rejection (non-200) with a
|
|
565
|
+
// dedicated named event carrying a plain-text reason. It is deliberately NOT
|
|
566
|
+
// named `error`, which would collide with EventSource's native error channel
|
|
567
|
+
// (onerror) and be indistinguishable from a transport failure. Handle it here
|
|
568
|
+
// so the specific status is logged and the user is notified. NOTE: the data is
|
|
569
|
+
// plain text ("upstream returned 503"), so do NOT JSON.parse it.
|
|
570
|
+
eventSource.addEventListener("upstream_error", (event) => {
|
|
571
|
+
logger.error("❌ Live agent SSE upstream error:", event.data);
|
|
572
|
+
ChatEventBus.emit("AGENT_ERROR", true);
|
|
573
|
+
eventSource.close();
|
|
574
|
+
});
|
|
511
575
|
}
|
|
512
576
|
/** Interface Implementation */
|
|
513
577
|
/**
|
|
@@ -679,14 +743,17 @@ class SalesforceLiveAgentProvider {
|
|
|
679
743
|
* It sends a POST request to the Salesforce MIAW API to close the conversation.
|
|
680
744
|
*/
|
|
681
745
|
async endChat(_sessionId) {
|
|
682
|
-
var _a, _b, _c, _d, _e, _f;
|
|
746
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
683
747
|
(_a = this.availabilityAbort) === null || _a === void 0 ? void 0 : _a.abort();
|
|
748
|
+
// Tear down the SSE stream on an explicit end so the connection and its
|
|
749
|
+
// registered named listeners don't leak past the session.
|
|
750
|
+
(_b = this.eventSource) === null || _b === void 0 ? void 0 : _b.close();
|
|
684
751
|
// console.log("this.sessionContext?.conversationId", this.sessionContext?.conversationId)
|
|
685
|
-
if ((
|
|
686
|
-
const res = await fetch(`${(
|
|
752
|
+
if ((_c = this.sessionContext) === null || _c === void 0 ? void 0 : _c.conversationId) {
|
|
753
|
+
const res = await fetch(`${(_d = this.configSettings) === null || _d === void 0 ? void 0 : _d.instanceUrl}/iamessage/api/v2/conversation/${(_e = this.sessionContext) === null || _e === void 0 ? void 0 : _e.conversationId}?esDeveloperName=${(_f = this.configSettings) === null || _f === void 0 ? void 0 : _f.messagingChannelId}`, {
|
|
687
754
|
method: "DELETE",
|
|
688
755
|
headers: {
|
|
689
|
-
"Authorization": `Bearer ${(
|
|
756
|
+
"Authorization": `Bearer ${(_g = this.sessionContext) === null || _g === void 0 ? void 0 : _g.accessToken}`,
|
|
690
757
|
"Content-Type": "application/json",
|
|
691
758
|
},
|
|
692
759
|
});
|
|
@@ -961,7 +1028,7 @@ function deleteJsonCookie(name, options = {}) {
|
|
|
961
1028
|
|
|
962
1029
|
const ai12zBotCss = () => `:host{font-family:var(--ai12zBot-v2-font-family) !important;font-size:var(--ai12zBot-v2-font-size) !important;color:var(--ai12zBot-v2-font-color, black);text-align:var(--ai12zBot-v2-text-align, left)}.chat-body{height:100%;overflow-y:auto;display:flex;flex-direction:column;gap:10px;overflow-x:hidden}.chat-body::-webkit-scrollbar{width:5px;height:5px;}.chat-body::-webkit-scrollbar-thumb{background-color:#888;border-radius:10px;}.message{padding:10px;border-radius:15px;font-size:14px;line-height:1.4;word-wrap:break-word}span.prose{font-size:14px;}.image-Container{position:relative;display:inline-block;margin-right:10px}.delete-image{opacity:3;position:absolute;right:3px;top:0;cursor:pointer;line-height:10px}.ai12zBtn{background-color:var(--ai12zBot-v2-button-background) !important;color:var(--ai12zBot-v2-button-font-color);padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none;margin:5px}.ai12z-btn{background-color:var(--ai12zBot-v2-button-background) !important;color:var(--ai12zBot-v2-button-font-color);padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none;margin:5px}.custom-privacy{color:var(--ai12z-bot-privacy-color);padding-bottom:10px;padding-left:5px;margin-top:auto;}@media (max-width: 768px){.hide-chatbot{display:none !important}}`;
|
|
963
1030
|
|
|
964
|
-
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:
|
|
1031
|
+
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:12px;border-top-right-radius:12px;--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:12px;border-top-right-radius:12px}.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:16px;height:16px}.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:4px;--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:24px;height:24px}.plus-icon{color:var(--ai12zBot-v2-searchbar-plus-icon-color);font-size:24px;width:24px;height:24px}.grow-wrap>.textarea,.grow-wrap:after{min-height:48px;align-content:center;border-radius:24px;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:24px}.thumbs-down{fill:var( --ai12zBot-v2-feedback-selected);width:24px}.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:4px}.error-msg{color:#dc2626;font-size:12px;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)}}`;
|
|
965
1032
|
|
|
966
1033
|
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
967
1034
|
var t = {};
|
|
@@ -988,7 +1055,10 @@ const Ai12zBot = class {
|
|
|
988
1055
|
this.isElementAvailable = index.createEvent(this, "isElementAvailable", 7);
|
|
989
1056
|
this.cdnPath = "https://cdn.ai12z.net/assets/bot";
|
|
990
1057
|
this.surveyCDNPath = "https://cdn.ai12z.net/pkg/surveyjs";
|
|
991
|
-
this.styles = [
|
|
1058
|
+
this.styles = [
|
|
1059
|
+
`https://cdn.jsdelivr.net/npm/@highlightjs/cdn-assets@11.11.1/styles/default.min.css`,
|
|
1060
|
+
`https://cdn.ai12z.net/assets/bot/${index.Env.CDN_PATH}/tailwind.min.css`
|
|
1061
|
+
];
|
|
992
1062
|
this.liveAgentEventHandler = new LiveAgentEventHandler();
|
|
993
1063
|
this.customStyle = "";
|
|
994
1064
|
this.customJS = "";
|
|
@@ -1262,49 +1332,51 @@ const Ai12zBot = class {
|
|
|
1262
1332
|
// }
|
|
1263
1333
|
};
|
|
1264
1334
|
this.agentMessageCreated = (message) => {
|
|
1265
|
-
|
|
1266
|
-
// Get the last message in the messages array
|
|
1267
|
-
const lastMessage = this.messages[this.messages.length - 1];
|
|
1268
|
-
// check if last message is from user or agent
|
|
1269
|
-
if (!lastMessage.sender || lastMessage.sender === null || lastMessage.type === "system") {
|
|
1270
|
-
// Generate a new temporary message object
|
|
1271
|
-
const tempMsg = utils.generateMessage(this.conversationId);
|
|
1272
|
-
// Generate a unique ID for the new message
|
|
1273
|
-
this.currentDomId = `chatbot-${utils.generateUUID()}`;
|
|
1274
|
-
tempMsg.id = this.currentDomId;
|
|
1275
|
-
tempMsg.isLoading = false;
|
|
1276
|
-
// Set sender to 'agent' for live agent messages
|
|
1277
|
-
this.messages = [...this.messages, tempMsg];
|
|
1278
|
-
}
|
|
1279
|
-
else {
|
|
1280
|
-
// If the last message is from the user or already has a sender, update its ID
|
|
1281
|
-
const { id, idChanged } = parseHelper.ensureMessageId(this.currentDomId, this.messages, "chatbot");
|
|
1282
|
-
this.currentDomId = id;
|
|
1283
|
-
if (idChanged)
|
|
1284
|
-
this.messages = [...this.messages];
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1335
|
+
var _a;
|
|
1287
1336
|
const retMessage = this.liveAgentEventHandler.handleAgentMessage(message);
|
|
1288
|
-
if (retMessage)
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1337
|
+
if (!retMessage)
|
|
1338
|
+
return;
|
|
1339
|
+
this.announce("New message received from live agent");
|
|
1340
|
+
// Render agent messages declaratively through component state (the same way
|
|
1341
|
+
// agentEventHandler renders the "agent joined" banner) instead of writing
|
|
1342
|
+
// into a DOM bubble that Stencil may not have rendered yet. The old code
|
|
1343
|
+
// added an empty bubble to state then, one requestAnimationFrame later,
|
|
1344
|
+
// queried `#currentDomId` in the shadow DOM to write the text — but Stencil's
|
|
1345
|
+
// re-render is async, so for the first agent message(s) the element didn't
|
|
1346
|
+
// exist yet, the querySelector returned null, and the text was dropped
|
|
1347
|
+
// entirely (never stored in state). It only "worked after" a user reply
|
|
1348
|
+
// forced a re-render. Building the message in state removes that race.
|
|
1349
|
+
const converter = new processCarouselData.showdown.Converter();
|
|
1350
|
+
const finalHtml = converter.makeHtml(retMessage);
|
|
1351
|
+
const entry = Array.isArray(message) ? message[0] : message;
|
|
1352
|
+
// Behavior change vs. pre-#2493: each agent message now renders as its own
|
|
1353
|
+
// bubble. The previous code concatenated consecutive agent messages that
|
|
1354
|
+
// arrived before a user reply into one growing bubble (via a persistent
|
|
1355
|
+
// currentDomId + string concat). One-bubble-per-message is intentional here —
|
|
1356
|
+
// it matches how bot/user messages already render and avoids the DOM-append
|
|
1357
|
+
// race this PR fixes. To restore merged bubbles, append to the last agent
|
|
1358
|
+
// message's `text` in state (when the last message is the same sender and no
|
|
1359
|
+
// user message interrupted) instead of always pushing a new entry.
|
|
1360
|
+
const agentMsg = {
|
|
1361
|
+
id: `chatbot-${utils.generateUUID()}`,
|
|
1362
|
+
text: finalHtml,
|
|
1363
|
+
isUser: false,
|
|
1364
|
+
isLoading: false,
|
|
1365
|
+
timestamp: new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }),
|
|
1366
|
+
images: [],
|
|
1367
|
+
conversationId: this.conversationId,
|
|
1368
|
+
formModel: {},
|
|
1369
|
+
surveyDomId: "",
|
|
1370
|
+
thumbsId: `${utils.generateUUID()}`,
|
|
1371
|
+
showIcon: true,
|
|
1372
|
+
hideThumbsUpandDown: true,
|
|
1373
|
+
insightId: null,
|
|
1374
|
+
sender: (_a = entry === null || entry === void 0 ? void 0 : entry.sender) !== null && _a !== void 0 ? _a : { role: "agent", displayName: "Agent" },
|
|
1375
|
+
};
|
|
1376
|
+
this.messages = [...this.messages, agentMsg];
|
|
1377
|
+
this.currentDomId = "";
|
|
1378
|
+
this.updateBotState();
|
|
1379
|
+
this.scheduleAutoScroll();
|
|
1308
1380
|
};
|
|
1309
1381
|
this.addEventMessage = (_message) => {
|
|
1310
1382
|
const agentEventMessages = this.liveAgentEventHandler.addAgentEventMessage([
|
|
@@ -1356,10 +1428,42 @@ const Ai12zBot = class {
|
|
|
1356
1428
|
this.announce("Live agent connection failed");
|
|
1357
1429
|
};
|
|
1358
1430
|
this.handleAgentConversationEnded = () => {
|
|
1359
|
-
// Only
|
|
1360
|
-
//
|
|
1431
|
+
// Only notify if an agent was actually connected; suppress when the session
|
|
1432
|
+
// timed out with no agent available.
|
|
1433
|
+
//
|
|
1434
|
+
// This can be invoked more than once — the sessionStatus="Ended" path and the
|
|
1435
|
+
// delayed CloseConversation both emit CONVERSATION_CLOSED. That double-fire is
|
|
1436
|
+
// handled by the isLiveAgent gate below, NOT by alreadyNotified: isLiveAgent is
|
|
1437
|
+
// set false synchronously in this same call, so any later invocation skips the
|
|
1438
|
+
// whole block (JS is single-threaded; no await runs in between).
|
|
1439
|
+
//
|
|
1440
|
+
// alreadyNotified guards a different case: when the agent leaving already
|
|
1441
|
+
// produced a "<name> has left the chat" participant banner, don't stack a
|
|
1442
|
+
// near-duplicate "The live agent has left the conversation." notice on top.
|
|
1361
1443
|
if (this.isLiveAgent) {
|
|
1362
|
-
this.
|
|
1444
|
+
const last = this.messages[this.messages.length - 1];
|
|
1445
|
+
const alreadyNotified = (last === null || last === void 0 ? void 0 : last.type) === "system" && typeof (last === null || last === void 0 ? void 0 : last.text) === "string" && last.text.toLowerCase().includes("left");
|
|
1446
|
+
if (!alreadyNotified) {
|
|
1447
|
+
// Render the banner through state (like agentEventHandler) rather than
|
|
1448
|
+
// the DOM-query addEventMessage, which silently no-ops when the target
|
|
1449
|
+
// bubble isn't rendered — that's why the "ended" notice never showed.
|
|
1450
|
+
this.messages = [
|
|
1451
|
+
...this.messages,
|
|
1452
|
+
{
|
|
1453
|
+
id: `system-${utils.generateUUID()}`,
|
|
1454
|
+
text: "The live agent has left the conversation.",
|
|
1455
|
+
type: "system",
|
|
1456
|
+
isUser: false,
|
|
1457
|
+
isLoading: false,
|
|
1458
|
+
timestamp: new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }),
|
|
1459
|
+
images: [],
|
|
1460
|
+
conversationId: this.conversationId,
|
|
1461
|
+
formModel: {},
|
|
1462
|
+
surveyDomId: "",
|
|
1463
|
+
sender: null,
|
|
1464
|
+
},
|
|
1465
|
+
];
|
|
1466
|
+
}
|
|
1363
1467
|
this.announce("Live agent chat ended");
|
|
1364
1468
|
}
|
|
1365
1469
|
this.isLiveAgent = false;
|
|
@@ -1367,7 +1471,10 @@ const Ai12zBot = class {
|
|
|
1367
1471
|
this.liveAgentConversationId = "";
|
|
1368
1472
|
this.isTypingIndicatorVisible = false;
|
|
1369
1473
|
this.liveAgentButtonText = "Talk to a Live Agent";
|
|
1474
|
+
this.currentDomId = "";
|
|
1370
1475
|
this.clearEvents();
|
|
1476
|
+
this.updateBotState();
|
|
1477
|
+
this.scheduleAutoScroll();
|
|
1371
1478
|
};
|
|
1372
1479
|
this.agentEventHandler = event => {
|
|
1373
1480
|
this.isTypingIndicatorVisible = false;
|
|
@@ -1394,6 +1501,10 @@ const Ai12zBot = class {
|
|
|
1394
1501
|
this.inputEl.value = "";
|
|
1395
1502
|
}
|
|
1396
1503
|
this.currentDomId = "";
|
|
1504
|
+
// Scroll the new banner (e.g. "… has joined the chat") into view — but only
|
|
1505
|
+
// when the user is already near the bottom (see scheduleAutoScroll), so we
|
|
1506
|
+
// don't yank them down mid-scroll during a join/leave burst.
|
|
1507
|
+
this.scheduleAutoScroll();
|
|
1397
1508
|
}
|
|
1398
1509
|
};
|
|
1399
1510
|
this.handleAgentSessionCreated = () => {
|
|
@@ -2212,6 +2323,7 @@ const Ai12zBot = class {
|
|
|
2212
2323
|
controlType: data.controlType,
|
|
2213
2324
|
thumbsId: `${utils.generateUUID()}`,
|
|
2214
2325
|
showIcon: !data.controlType && !this.surveyDomId,
|
|
2326
|
+
hideThumbsUpandDown: this.isLiveAgent ? true : false,
|
|
2215
2327
|
insightId: (_f = data === null || data === void 0 ? void 0 : data.insightId) !== null && _f !== void 0 ? _f : null,
|
|
2216
2328
|
sender: (_g = data === null || data === void 0 ? void 0 : data.sender) !== null && _g !== void 0 ? _g : null,
|
|
2217
2329
|
itemComponent: data,
|
|
@@ -2533,6 +2645,29 @@ const Ai12zBot = class {
|
|
|
2533
2645
|
this.unreadCount = 0;
|
|
2534
2646
|
}
|
|
2535
2647
|
}
|
|
2648
|
+
/** True when the chat is scrolled to (or within `threshold`px of) the bottom. */
|
|
2649
|
+
isNearBottom(threshold = 150) {
|
|
2650
|
+
var _a;
|
|
2651
|
+
const container = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(".chat-body");
|
|
2652
|
+
if (!container)
|
|
2653
|
+
return true;
|
|
2654
|
+
return container.scrollHeight - container.scrollTop - container.clientHeight <= threshold;
|
|
2655
|
+
}
|
|
2656
|
+
/**
|
|
2657
|
+
* Auto-scroll for the live-agent path (agent messages + join/leave banners).
|
|
2658
|
+
* Unlike scrollToBottom(), this (1) only scrolls when the user is already near
|
|
2659
|
+
* the bottom, so a burst never yanks the view down while they read history, and
|
|
2660
|
+
* (2) coalesces rapid messages into a single scroll via a short debounce.
|
|
2661
|
+
* The near-bottom check is captured now, before Stencil re-renders and grows the
|
|
2662
|
+
* container — if they weren't near the bottom, their position is left alone.
|
|
2663
|
+
*/
|
|
2664
|
+
scheduleAutoScroll() {
|
|
2665
|
+
if (!this.isNearBottom())
|
|
2666
|
+
return;
|
|
2667
|
+
if (this.autoScrollTimer)
|
|
2668
|
+
clearTimeout(this.autoScrollTimer);
|
|
2669
|
+
this.autoScrollTimer = setTimeout(() => this.scrollToBottom(), 60);
|
|
2670
|
+
}
|
|
2536
2671
|
checkLiveAgentMode() {
|
|
2537
2672
|
var _a, _b, _c, _d;
|
|
2538
2673
|
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;
|
|
@@ -2924,7 +3059,7 @@ const Ai12zBot = class {
|
|
|
2924
3059
|
this.errorMessage = errorMsg.detail;
|
|
2925
3060
|
this.showErrorMessage = true;
|
|
2926
3061
|
this.announce(errorMsg.detail || "Image upload failed");
|
|
2927
|
-
}, ref: el => (this.imageUploaderRef = el) })))))), index.h("div", { class: `textarea` }, this.imagesBase64List.length > 0 && (index.h("div", { class: "flex flex-wrap gap-2 mx-1 mt-2.5 mb-1" }, this.imagesBase64List.map((img, idx) => (index.h("div", { class: "image-Container sc-ai12z-input-form", key: idx }, index.h("img", { src: img, style: { width: "70px", height: "50px", borderRadius: "
|
|
3062
|
+
}, ref: el => (this.imageUploaderRef = el) })))))), index.h("div", { class: `textarea` }, this.imagesBase64List.length > 0 && (index.h("div", { class: "flex flex-wrap gap-2 mx-1 mt-2.5 mb-1" }, this.imagesBase64List.map((img, idx) => (index.h("div", { class: "image-Container sc-ai12z-input-form", key: idx }, index.h("img", { src: img, style: { width: "70px", height: "50px", borderRadius: "12px" }, alt: "uploaded image" }), index.h("span", { class: "delete-image sc-ai12z-input-form cursor-pointer ml-1", onClick: () => {
|
|
2928
3063
|
this.imagesBase64List = this.imagesBase64List.filter((_, i) => i !== idx);
|
|
2929
3064
|
// console.log("upload imageuloaderred", this.imageUploaderRef)
|
|
2930
3065
|
if (this.imageUploaderRef && typeof this.imageUploaderRef.removeImageAtIndex === "function") {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var SearchResult = require('./SearchResult-
|
|
5
|
-
var utils = require('./utils-
|
|
3
|
+
var index = require('./index-v8T1EJAJ.js');
|
|
4
|
+
var SearchResult = require('./SearchResult-CvTJr55G.js');
|
|
5
|
+
var utils = require('./utils-7C5_GnyF.js');
|
|
6
6
|
var _commonjsHelpers = require('./_commonjsHelpers-MBWFX2dn.js');
|
|
7
|
-
var appStore = require('./app-store-
|
|
8
|
-
var parseHelper = require('./parseHelper-
|
|
9
|
-
require('./ctaHelpers-
|
|
10
|
-
require('./logger-
|
|
7
|
+
var appStore = require('./app-store-BtkiHvcw.js');
|
|
8
|
+
var parseHelper = require('./parseHelper-5fRVefLm.js');
|
|
9
|
+
require('./ctaHelpers-DUPj5SnE.js');
|
|
10
|
+
require('./logger-2ZBZCKdM.js');
|
|
11
11
|
|
|
12
12
|
const categoryCss = () => `ai12z-category{font-family:var(--ai12z-font-family) !important;font-size:var(--ai12z-search-font-size, var(--ai12z-font-size)) !important}.custom-title{font-size:var(--ai12z-category-font-size);color:var(--ai12z-category-font-color)}`;
|
|
13
13
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-v8T1EJAJ.js');
|
|
4
4
|
var botHelpers = require('./botHelpers-D5Dj7TRA.js');
|
|
5
|
-
var styleSheetRegistry = require('./styleSheetRegistry-
|
|
6
|
-
require('./utils-
|
|
5
|
+
var styleSheetRegistry = require('./styleSheetRegistry-CaWjqgX7.js');
|
|
6
|
+
require('./utils-7C5_GnyF.js');
|
|
7
7
|
|
|
8
8
|
const ai12zChatMessageCss = () => `.show-more-btn{background:none;color:var(--ai12z-knowledge-box-show-more-color, #4a8aff);font-size:16px;cursor:pointer;font-weight:500;border-radius:6px;transition:color 0.2s ease, background 0.2s ease;border:1px solid var(--ai12z-knowledge-box-show-more-border, blue);padding:10px;border-radius:20px;align-items:center;justify-content:center;margin:auto;display:block;z-index:20;position:relative;width:30%}.show-more-btn:hover{color:var(--ai12z-knowledge-box-show-more-hover-color, #1a73e8);background:rgba(74, 138, 255, 0.08)}.show-more-btn:active{background:rgba(74, 138, 255, 0.15)}.show-more-btn svg{vertical-align:middle;gap:5px;transition:transform 0.3s ease-in-out;display:inline-block;margin-left:10px;font-size:20}.message-text{line-height:1.55;font-size:15px;color:var(--ai12z-knowledge-box-text-color, #1e1e1e);transition:max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);overflow:hidden}.fade-overlay{position:absolute;bottom:0;left:0;right:0;height:100px;z-index:10;pointer-events:none;opacity:1;transition:opacity 0.3s ease-in-out;background:linear-gradient( to bottom, rgba(255, 255, 255, 0) 0%, var(--ai12z-knowledge-box-bg-color, #ffffff) 85% )}.chat-message{position:relative;}.custom-line-clamp{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:var(--line-clamp);line-clamp:var(--line-clamp)}.ai12z-form-honeypot{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}.ai12zBtn{background-color:var(--ai12z-knowledge-box-primary-color);color:white;padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none;margin:5px}`;
|
|
9
9
|
|
|
@@ -55,18 +55,10 @@ const Ai12zChatMessage = class {
|
|
|
55
55
|
botHelpers.initializeScript(event.detail.id, this.mainObject);
|
|
56
56
|
}
|
|
57
57
|
componentWillLoad() {
|
|
58
|
-
var _a, _b;
|
|
59
58
|
this.loadScriptsSequentially();
|
|
60
|
-
// Adopt customCSS in this shadow root using the shared CSSStyleSheet
|
|
61
|
-
// already constructed by the parent knowledge-box (zero extra fetches).
|
|
62
|
-
if ((_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.customCSS) {
|
|
63
|
-
styleSheetRegistry.adoptStyleSheet(this.kbSettings.customCSS, this.el.shadowRoot);
|
|
64
|
-
}
|
|
65
|
-
if ((_b = this.kbSettings) === null || _b === void 0 ? void 0 : _b.customJS) {
|
|
66
|
-
styleSheetRegistry.loadScriptOnce(this.kbSettings.customJS, this.el.shadowRoot);
|
|
67
|
-
}
|
|
68
59
|
}
|
|
69
60
|
componentDidLoad() {
|
|
61
|
+
var _a, _b;
|
|
70
62
|
// Initialise the ai12z global exactly once; never overwrite an existing value.
|
|
71
63
|
if (!window["ai12z"]) {
|
|
72
64
|
window["ai12z"] = {};
|
|
@@ -75,6 +67,14 @@ const Ai12zChatMessage = class {
|
|
|
75
67
|
ai12zHeading.text = `var ai12zChat = window["ai12z"] = {}`;
|
|
76
68
|
this.el.shadowRoot.appendChild(ai12zHeading);
|
|
77
69
|
this.checkOverflow();
|
|
70
|
+
// Adopt customCSS in this shadow root using the shared CSSStyleSheet
|
|
71
|
+
// already constructed by the parent knowledge-box (zero extra fetches).
|
|
72
|
+
if ((_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.customCSS) {
|
|
73
|
+
styleSheetRegistry.adoptStyleSheet(this.kbSettings.customCSS, this.el.shadowRoot);
|
|
74
|
+
}
|
|
75
|
+
if ((_b = this.kbSettings) === null || _b === void 0 ? void 0 : _b.customJS) {
|
|
76
|
+
styleSheetRegistry.loadScriptOnce(this.kbSettings.customJS, this.el.shadowRoot);
|
|
77
|
+
}
|
|
78
78
|
}
|
|
79
79
|
async loadScriptsSequentially() {
|
|
80
80
|
try {
|
|
@@ -156,9 +156,9 @@ const Ai12zChatMessage = class {
|
|
|
156
156
|
render() {
|
|
157
157
|
var _a, _b, _c, _d;
|
|
158
158
|
const lineClamp = (_b = (_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.numberOfLines) !== null && _b !== void 0 ? _b : 10;
|
|
159
|
-
return (index.h("div", { key: '
|
|
159
|
+
return (index.h("div", { key: '2d24739583f2f73daa28590c6c121531cf6ab4ce', class: "chat-message" }, index.h("div", { key: '9e8ca0a62a0de746f367164ff51ea9b9a22e93a0', ref: (el) => this.messageRef = el, class: { 'message-text': true, "custom-line-clamp": !this.isExpanded && !this.isCollapsing && this.showButton }, style: {
|
|
160
160
|
"--line-clamp": `${lineClamp}`,
|
|
161
|
-
}, innerHTML: this.text, onClick: this.showButton ? this.toggleExpand : undefined }), !this.isExpanded && this.showButton && this.canExpand && index.h("div", { key: '
|
|
161
|
+
}, innerHTML: this.text, onClick: this.showButton ? this.toggleExpand : undefined }), !this.isExpanded && this.showButton && this.canExpand && index.h("div", { key: '12f386a03fc84f97d2e585ea21cf4f8d31964c34', class: "fade-overlay" }), this.showButton && this.canExpand && index.h("button", { key: '1633be8cd35334eae64f75d7ce5fd87b30054849', class: "show-more-btn", onClick: this.toggleExpand }, this.isExpanded ? (((_c = this.kbSettings) === null || _c === void 0 ? void 0 : _c.showLessButtonLabel) || "Show less") : (((_d = this.kbSettings) === null || _d === void 0 ? void 0 : _d.showMoreButtonLabel) || "Show more"), this.isExpanded ? index.h("svg", { width: "1em", height: "1em", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, index.h("polyline", { points: "6 9 12 15 18 9" })) : index.h("svg", { width: "1em", height: "1em", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, index.h("polyline", { points: "18 15 12 9 6 15" })))));
|
|
162
162
|
}
|
|
163
163
|
get el() { return index.getElement(this); }
|
|
164
164
|
static get watchers() { return {
|