biel-search 0.1.3 → 0.1.5
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/biel-search/_commonjsHelpers-37e0f1f2.js +36 -0
- package/dist/biel-search/_commonjsHelpers-37e0f1f2.js.map +1 -0
- package/dist/biel-search/biel-bot.entry.js +211 -0
- package/dist/biel-search/biel-bot.entry.js.map +1 -0
- package/dist/biel-search/biel-button.entry.js +85 -0
- package/dist/biel-search/biel-button.entry.js.map +1 -0
- package/dist/biel-search/biel-chat.entry.js +63 -0
- package/dist/biel-search/biel-chat.entry.js.map +1 -0
- package/dist/biel-search/biel-feedback.entry.js +32 -0
- package/dist/biel-search/biel-feedback.entry.js.map +1 -0
- package/dist/{components/p-850f691d.js → biel-search/biel-header.entry.js} +9 -33
- package/dist/biel-search/biel-header.entry.js.map +1 -0
- package/dist/{components/p-ff7ee845.js → biel-search/biel-input.entry.js} +17 -33
- package/dist/biel-search/biel-input.entry.js.map +1 -0
- package/dist/{components/p-67420809.js → biel-search/biel-message.entry.js} +30 -60
- package/dist/biel-search/biel-message.entry.js.map +1 -0
- package/dist/biel-search/biel-search.css +151 -1
- package/dist/biel-search/biel-search.esm.js +48 -1
- package/dist/biel-search/biel-search.esm.js.map +1 -1
- package/dist/{components/p-e976f525.js → biel-search/biel-sources.entry.js} +11 -31
- package/dist/biel-search/biel-sources.entry.js.map +1 -0
- package/dist/biel-search/biel-suggested-questions.entry.js +23 -0
- package/dist/biel-search/biel-suggested-questions.entry.js.map +1 -0
- package/dist/biel-search/biel-table.entry.js +18 -0
- package/dist/biel-search/biel-table.entry.js.map +1 -0
- package/dist/{components/p-7f60983b.js → biel-search/code-snippet.entry.js} +13 -35
- package/dist/biel-search/code-snippet.entry.js.map +1 -0
- package/dist/biel-search/index-0e558c11.js +2995 -0
- package/dist/biel-search/index-0e558c11.js.map +1 -0
- package/dist/biel-search/index.esm.js +16 -1
- package/dist/biel-search/index.esm.js.map +1 -1
- package/dist/biel-search/shadow-css-964ae2c5.js +358 -0
- package/dist/biel-search/shadow-css-964ae2c5.js.map +1 -0
- package/dist/components/biel-feedback.d.ts +11 -0
- package/dist/types/components/biel-bot/biel-bot.d.ts +15 -0
- package/dist/types/components/biel-button/biel-button.d.ts +6 -0
- package/dist/types/components/biel-chat/biel-chat.d.ts +6 -0
- package/dist/types/components/biel-feedback/biel-feedback.d.ts +13 -0
- package/dist/types/components/biel-input/biel-input.d.ts +1 -0
- package/dist/types/components/biel-message/biel-message.d.ts +3 -0
- package/dist/types/components.d.ts +59 -2
- package/dist/types/services/biel-service.d.ts +3 -0
- package/package.json +1 -1
- package/dist/biel-search/p-1b3c90ca.js +0 -3
- package/dist/biel-search/p-1b3c90ca.js.map +0 -1
- package/dist/biel-search/p-90c1832c.entry.js +0 -3
- package/dist/biel-search/p-90c1832c.entry.js.map +0 -1
- package/dist/biel-search/p-e1255160.js +0 -2
- package/dist/biel-search/p-e1255160.js.map +0 -1
- package/dist/cjs/app-globals-3a1e7e63.js +0 -7
- package/dist/cjs/app-globals-3a1e7e63.js.map +0 -1
- package/dist/cjs/biel-bot_10.cjs.entry.js +0 -64002
- package/dist/cjs/biel-bot_10.cjs.entry.js.map +0 -1
- package/dist/cjs/biel-search.cjs.js +0 -27
- package/dist/cjs/biel-search.cjs.js.map +0 -1
- package/dist/cjs/index-05fc01fd.js +0 -1281
- package/dist/cjs/index-05fc01fd.js.map +0 -1
- package/dist/cjs/index.cjs.js +0 -11
- package/dist/cjs/index.cjs.js.map +0 -1
- package/dist/cjs/loader.cjs.js +0 -17
- package/dist/cjs/loader.cjs.js.map +0 -1
- package/dist/collection/collection-manifest.json +0 -21
- package/dist/collection/components/biel-bot/biel-bot.css +0 -189
- package/dist/collection/components/biel-bot/biel-bot.js +0 -366
- package/dist/collection/components/biel-bot/biel-bot.js.map +0 -1
- package/dist/collection/components/biel-button/biel-button.css +0 -63
- package/dist/collection/components/biel-button/biel-button.js +0 -321
- package/dist/collection/components/biel-button/biel-button.js.map +0 -1
- package/dist/collection/components/biel-chat/biel-chat.css +0 -75
- package/dist/collection/components/biel-chat/biel-chat.js +0 -171
- package/dist/collection/components/biel-chat/biel-chat.js.map +0 -1
- package/dist/collection/components/biel-header/biel-header.css +0 -43
- package/dist/collection/components/biel-header/biel-header.js +0 -165
- package/dist/collection/components/biel-header/biel-header.js.map +0 -1
- package/dist/collection/components/biel-input/biel-input.css +0 -55
- package/dist/collection/components/biel-input/biel-input.js +0 -164
- package/dist/collection/components/biel-input/biel-input.js.map +0 -1
- package/dist/collection/components/biel-message/biel-message.css +0 -67
- package/dist/collection/components/biel-message/biel-message.js +0 -113
- package/dist/collection/components/biel-message/biel-message.js.map +0 -1
- package/dist/collection/components/biel-sources/biel-sources.css +0 -42
- package/dist/collection/components/biel-sources/biel-sources.js +0 -52
- package/dist/collection/components/biel-sources/biel-sources.js.map +0 -1
- package/dist/collection/components/biel-suggested-questions/biel-suggested-questions.css +0 -39
- package/dist/collection/components/biel-suggested-questions/biel-suggested-questions.js +0 -82
- package/dist/collection/components/biel-suggested-questions/biel-suggested-questions.js.map +0 -1
- package/dist/collection/components/biel-table/biel-table.css +0 -37
- package/dist/collection/components/biel-table/biel-table.js +0 -43
- package/dist/collection/components/biel-table/biel-table.js.map +0 -1
- package/dist/collection/components/code-snippet/code-snippet.css +0 -162
- package/dist/collection/components/code-snippet/code-snippet.js +0 -101
- package/dist/collection/components/code-snippet/code-snippet.js.map +0 -1
- package/dist/collection/index.js +0 -11
- package/dist/collection/index.js.map +0 -1
- package/dist/collection/services/biel-service.js +0 -34
- package/dist/collection/services/biel-service.js.map +0 -1
- package/dist/collection/services/biel-websocket-service.js +0 -64
- package/dist/collection/services/biel-websocket-service.js.map +0 -1
- package/dist/collection/utils/utils.js +0 -4
- package/dist/collection/utils/utils.js.map +0 -1
- package/dist/components/biel-bot.js +0 -8
- package/dist/components/biel-bot.js.map +0 -1
- package/dist/components/biel-button.js +0 -167
- package/dist/components/biel-button.js.map +0 -1
- package/dist/components/biel-chat.js +0 -8
- package/dist/components/biel-chat.js.map +0 -1
- package/dist/components/biel-header.js +0 -8
- package/dist/components/biel-header.js.map +0 -1
- package/dist/components/biel-input.js +0 -8
- package/dist/components/biel-input.js.map +0 -1
- package/dist/components/biel-message.js +0 -8
- package/dist/components/biel-message.js.map +0 -1
- package/dist/components/biel-sources.js +0 -8
- package/dist/components/biel-sources.js.map +0 -1
- package/dist/components/biel-suggested-questions.js +0 -8
- package/dist/components/biel-suggested-questions.js.map +0 -1
- package/dist/components/biel-table.js +0 -8
- package/dist/components/biel-table.js.map +0 -1
- package/dist/components/code-snippet.js +0 -8
- package/dist/components/code-snippet.js.map +0 -1
- package/dist/components/index.js +0 -9
- package/dist/components/index.js.map +0 -1
- package/dist/components/p-67420809.js.map +0 -1
- package/dist/components/p-7b8b1ac3.js +0 -1098
- package/dist/components/p-7b8b1ac3.js.map +0 -1
- package/dist/components/p-7f60983b.js.map +0 -1
- package/dist/components/p-850f691d.js.map +0 -1
- package/dist/components/p-c2df1f51.js +0 -104
- package/dist/components/p-c2df1f51.js.map +0 -1
- package/dist/components/p-cb355eb1.js +0 -37
- package/dist/components/p-cb355eb1.js.map +0 -1
- package/dist/components/p-e6f985f6.js +0 -43
- package/dist/components/p-e6f985f6.js.map +0 -1
- package/dist/components/p-e976f525.js.map +0 -1
- package/dist/components/p-f601cd15.js +0 -257
- package/dist/components/p-f601cd15.js.map +0 -1
- package/dist/components/p-ff7ee845.js.map +0 -1
- package/dist/esm/biel-bot_10.entry.js +0 -63989
- package/dist/esm/biel-bot_10.entry.js.map +0 -1
- package/dist/esm/biel-search.js +0 -22
- package/dist/esm/biel-search.js.map +0 -1
- package/dist/esm/index-6ad604ca.js +0 -1252
- package/dist/esm/index-6ad604ca.js.map +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/loader.js +0 -13
- package/dist/esm/loader.js.map +0 -1
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- /package/dist/{esm → biel-search}/app-globals-0f993ce5.js +0 -0
- /package/dist/{esm → biel-search}/app-globals-0f993ce5.js.map +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2
|
+
|
|
3
|
+
function getDefaultExportFromCjs (x) {
|
|
4
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function getDefaultExportFromNamespaceIfPresent (n) {
|
|
8
|
+
return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getDefaultExportFromNamespaceIfNotNamed (n) {
|
|
12
|
+
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getAugmentedNamespace(n) {
|
|
16
|
+
if (n.__esModule) return n;
|
|
17
|
+
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
18
|
+
Object.keys(n).forEach(function (k) {
|
|
19
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
20
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return n[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return a;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function commonjsRequire (path) {
|
|
31
|
+
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { commonjsGlobal as c };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=_commonjsHelpers-37e0f1f2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"_commonjsHelpers-37e0f1f2.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":[],"sourcesContent":[],"version":3}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { r as registerInstance, h, g as getElement } from './index-0e558c11.js';
|
|
2
|
+
|
|
3
|
+
const WS_URL = 'wss://app.biel.ai/ws/messages';
|
|
4
|
+
class BielWebSocketService {
|
|
5
|
+
constructor(projectId, errorMessage) {
|
|
6
|
+
this.messageHandlers = [];
|
|
7
|
+
this.isConnected = false;
|
|
8
|
+
this.chatId = '';
|
|
9
|
+
this.projectId = projectId;
|
|
10
|
+
this.errorMessage = errorMessage;
|
|
11
|
+
this.connect();
|
|
12
|
+
}
|
|
13
|
+
connect() {
|
|
14
|
+
this.ws = new WebSocket(`${WS_URL}/${this.projectId}/`);
|
|
15
|
+
this.ws.onopen = () => {
|
|
16
|
+
this.isConnected = true;
|
|
17
|
+
};
|
|
18
|
+
this.ws.onmessage = (event) => {
|
|
19
|
+
const message = JSON.parse(event.data);
|
|
20
|
+
if (!this.chatId && message.chatId) {
|
|
21
|
+
this.chatId = message.chatId;
|
|
22
|
+
}
|
|
23
|
+
if (message.from) {
|
|
24
|
+
this.loadingEndHandler();
|
|
25
|
+
this.messageHandlers.forEach(handler => handler(message));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
this.ws.onclose = () => {
|
|
29
|
+
this.isConnected = false;
|
|
30
|
+
};
|
|
31
|
+
this.ws.onerror = (error) => {
|
|
32
|
+
console.error('WebSocket error:', error);
|
|
33
|
+
this.isConnected = false;
|
|
34
|
+
this.loadingEndHandler();
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
sendMessage(message) {
|
|
38
|
+
const payload = {
|
|
39
|
+
projectId: this.projectId,
|
|
40
|
+
chatId: this.chatId,
|
|
41
|
+
url: window.location.href,
|
|
42
|
+
from: 'user',
|
|
43
|
+
message: message,
|
|
44
|
+
};
|
|
45
|
+
if (this.isConnected) {
|
|
46
|
+
this.ws.send(JSON.stringify(payload));
|
|
47
|
+
this.loadingStartHandler();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.messageHandlers.forEach(handler => handler({ message: this.errorMessage, from: 'ai' }));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
closeSocket() {
|
|
54
|
+
this.ws.close();
|
|
55
|
+
}
|
|
56
|
+
onMessage(handler) {
|
|
57
|
+
this.messageHandlers.push(handler);
|
|
58
|
+
}
|
|
59
|
+
onLoadingStart(handler) {
|
|
60
|
+
this.loadingStartHandler = handler;
|
|
61
|
+
}
|
|
62
|
+
onLoadingEnd(handler) {
|
|
63
|
+
this.loadingEndHandler = handler;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const BASE_URL = "https://app.biel.ai/api/v1";
|
|
68
|
+
class BielService {
|
|
69
|
+
constructor(project, errorMessage404, errorMessage403, errorMessageDefault) {
|
|
70
|
+
this.project = project;
|
|
71
|
+
this.errorMessage404 = errorMessage404;
|
|
72
|
+
this.errorMessage403 = errorMessage403;
|
|
73
|
+
this.errorMessageDefault = errorMessageDefault;
|
|
74
|
+
}
|
|
75
|
+
async getProjectDetails() {
|
|
76
|
+
try {
|
|
77
|
+
const response = await fetch(`${BASE_URL}/projects/${this.project}/`);
|
|
78
|
+
if (response.status === 404) {
|
|
79
|
+
return this.errorMessage404;
|
|
80
|
+
}
|
|
81
|
+
if (response.status === 403) {
|
|
82
|
+
return this.errorMessage403;
|
|
83
|
+
}
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
return this.errorMessageDefault;
|
|
86
|
+
}
|
|
87
|
+
const data = await response.json();
|
|
88
|
+
return {
|
|
89
|
+
whitelabel: data.whitelabel,
|
|
90
|
+
suggestedQuestions: data.suggested_questions,
|
|
91
|
+
initialMessage: data.initial_message
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.error('Error fetching project details:', error);
|
|
96
|
+
return this.errorMessageDefault;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async sendFeedback(messageId, feedback) {
|
|
100
|
+
try {
|
|
101
|
+
const response = await fetch(`${BASE_URL}/messages/${messageId}/feedback/`, {
|
|
102
|
+
method: 'POST',
|
|
103
|
+
headers: { 'Content-Type': 'application/json; charset=UTF-8' },
|
|
104
|
+
body: JSON.stringify(feedback),
|
|
105
|
+
});
|
|
106
|
+
if (!response.ok) {
|
|
107
|
+
console.error('Error:', response.status);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
console.error('Error sending feedback:', error);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const bielBotCss = ".text-center{flex-grow:1;text-align:center}.biel-bot-wrapper{position:absolute;z-index:var(--biel-bot-wrapper-z-index)}.biel-overlay{background-color:var(--biel-bot-screenshot-bg-color);height:100%;left:0;position:fixed;top:0;width:100%;z-index:var(--biel-bot-screnshot-z-index)}.biel-bot{display:inline-block;position:relative}.biel-bot-content{background-color:var(--biel-bot-content-bg-color);border:1px solid var(--biel-bot-header-text-color);border-radius:var(--biel-bot-content-border-radius);box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .30), 0px 2px 6px 2px rgba(60, 64, 67, .15);box-sizing:border-box;color:var(--biel-bot-content-text-color);display:flex;flex-direction:column;font-family:var(--biel-bot-content-font-family);left:50%;max-width:90%;max-height:80vh;overflow:hidden;padding:20px;position:fixed;top:50%;transform:translate(-50%, -50%);width:100%;z-index:var(--biel-bot-content-z-index);transition:all 0.3s ease-in-out;animation:fadeIn 0.3s}.biel-bot-header{margin-bottom:20px}.biel-bot-footer{font-size:var(--biel-footer-font-size);text-align:center}.biel-bot-footer a{color:var(--biel-bot-footer-link);font-weight:500;text-decoration:none}.biel-logo{align-items:center;display:flex;justify-content:center;margin-top:5px}.biel-logo a{margin-left:3px}.biel-bot-close{background-color:var(--biel-bot-close-bg-color);border:0;border-radius:50%;cursor:pointer;height:22px;margin-left:auto;padding:0;width:22px}.biel-bot-close svg{stroke:var(--biel-bot-close-color)}.biel-bot-content.fullscreen{width:100vw;max-width:100vw;height:100vh;max-height:100vh;border-radius:0;padding:20px 5vw;left:50%;top:50%;transform:translate(-50%, -50%);transition:all 0.3s ease-in-out;animation:fadeIn 0.3s}@media screen and (min-width: 768px){.biel-bot-content{max-width:600px;max-height:82vh}.biel-bot-content.biel-bot-content--bottom-right{bottom:var(--biel-bot-content-position-bottom);left:initial;right:var(--biel-bot-content-position-right);top:initial;transform:initial}.biel-bot-content.biel-bot-content--bottom-left{bottom:var(--biel-bot-content-position-bottom);left:var(--biel-bot-content-position-left);top:initial;transform:initial}.biel-bot-content.biel-bot-content--top-right{right:var(--biel-bot-content-position-right);left:initial;top:var(--biel-bot-content-position-top);transform:initial}.biel-bot-content.biel-bot-content--top-left{left:var(--biel-bot-content-position-left);top:var(--biel-bot-content-position-top);transform:initial}.biel-bot-content.biel-bot-content--center-left{left:5px;right:auto;top:50%;transform:translateY(-50%)}.biel-bot-content.biel-bot-content--center-right{left:auto;right:5px;top:50%;transform:translateY(-50%)}.biel-bot-content.biel-bot-content--sidebar-left.biel-bot-content--open,.biel-bot-content.biel-bot-content--sidebar-right.biel-bot-content--open{transform:translateX(0);max-height:100vh}.biel-bot-content.biel-bot-content--sidebar-left{max-width:300px;left:0;right:auto;height:100vh;top:0;transform:translateX(-100%);border-radius:0}.biel-bot-content.biel-bot-content--sidebar-right{max-width:300px;left:auto;right:0;height:100vh;top:0;transform:translateX(100%);border-radius:0}.biel-bot-content.fullscreen{width:100vw;max-width:100vw;height:100vh;max-height:100vh;border-radius:0;padding:20px 25vw;left:50%;top:50%;transform:translate(-50%, -50%);transition:all 0.3s ease-in-out;animation:fadeIn 0.3s}.biel-bot-content.fullscreen.biel-bot-content--bottom-right{left:initial;top:initial;bottom:0;right:0;transform:initial}.biel-bot-content.fullscreen.biel-bot-content--bottom-left{left:0;top:initial;bottom:0;transform:initial}.biel-bot-content.fullscreen.biel-bot-content--center-right,.biel-bot-content.fullscreen.biel-bot-content--top-right{left:initial;top:0;bottom:0;right:0;transform:initial}.biel-bot-content.fullscreen.biel-bot-content--sidebar-right{left:initial;top:0;bottom:0;right:0;transform:initial}.biel-bot-content.fullscreen.biel-bot-content--sidebar-left{left:0;top:0;bottom:0;transform:initial}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{from{opacity:1}to{opacity:0}}";
|
|
117
|
+
|
|
118
|
+
const BielBot = class {
|
|
119
|
+
handleClose() {
|
|
120
|
+
const modal = this.el.shadowRoot.querySelector('.biel-bot-content');
|
|
121
|
+
modal.style.animation = 'fadeOut 0.3s';
|
|
122
|
+
setTimeout(() => {
|
|
123
|
+
this.showModal = false;
|
|
124
|
+
document.body.style.overflow = '';
|
|
125
|
+
}, 299);
|
|
126
|
+
}
|
|
127
|
+
handleFullscreenClicked() {
|
|
128
|
+
this.isFullscreen = !this.isFullscreen;
|
|
129
|
+
setTimeout(() => {
|
|
130
|
+
document.body.style.overflow = this.isFullscreen ? 'hidden' : '';
|
|
131
|
+
}, 300);
|
|
132
|
+
}
|
|
133
|
+
handleQuestionSelected(event) {
|
|
134
|
+
this.handleMessageSent(event);
|
|
135
|
+
}
|
|
136
|
+
handleFeedback(event) {
|
|
137
|
+
if (!this.hideFeedback) {
|
|
138
|
+
const { messageId, reaction } = event.detail;
|
|
139
|
+
this.bielService.sendFeedback(messageId, { reaction });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
constructor(hostRef) {
|
|
143
|
+
registerInstance(this, hostRef);
|
|
144
|
+
this.modalPosition = 'center';
|
|
145
|
+
this.project = '';
|
|
146
|
+
this.showModal = false;
|
|
147
|
+
this.fetchData = true;
|
|
148
|
+
this.headerTitle = 'Company Name AI';
|
|
149
|
+
this.inputPlaceholderText = 'Type your message';
|
|
150
|
+
this.sendButtonText = 'Send';
|
|
151
|
+
this.hideExpandButton = false;
|
|
152
|
+
this.expandModal = false;
|
|
153
|
+
this.errorMessage404 = "Oops! We could not find the provided project ID.";
|
|
154
|
+
this.errorMessage403 = "Oops! The request URL does not match the one defined for this project.";
|
|
155
|
+
this.errorMessageDefault = "Oops! Please try again later.";
|
|
156
|
+
this.footerText = "AI generated answers. Always verify the sources before using them.";
|
|
157
|
+
this.suggestedQuestionsTitle = 'Suggested questions';
|
|
158
|
+
this.initialMessages = [];
|
|
159
|
+
this.disableInput = false;
|
|
160
|
+
this.hideFeedback = false;
|
|
161
|
+
this.isFullscreen = this.expandModal;
|
|
162
|
+
this.isLoading = false;
|
|
163
|
+
this.showPoweredBy = true;
|
|
164
|
+
this.suggestedQuestions = undefined;
|
|
165
|
+
this.welcomeMessage = undefined;
|
|
166
|
+
this.messages = [];
|
|
167
|
+
this.loadedChat = false;
|
|
168
|
+
if (!this.disableInput) {
|
|
169
|
+
this.webSocketService = new BielWebSocketService(this.project, this.errorMessageDefault);
|
|
170
|
+
this.webSocketService.onMessage(this.handleIncomingMessage.bind(this));
|
|
171
|
+
this.webSocketService.onLoadingStart(() => this.isLoading = true);
|
|
172
|
+
this.webSocketService.onLoadingEnd(() => this.isLoading = false);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
handleIncomingMessage(message) {
|
|
176
|
+
this.messages = [...this.messages, { sender: message.from, text: message.message, messageId: message.messageId, sources: message.sources }];
|
|
177
|
+
}
|
|
178
|
+
async componentWillLoad() {
|
|
179
|
+
if (this.initialMessages.length > 0) {
|
|
180
|
+
this.messages = [...this.initialMessages];
|
|
181
|
+
this.loadedChat = true;
|
|
182
|
+
}
|
|
183
|
+
if (this.fetchData && !this.disableInput) {
|
|
184
|
+
this.bielService = new BielService(this.project, this.errorMessage404, this.errorMessage403, this.errorMessageDefault);
|
|
185
|
+
const result = await this.bielService.getProjectDetails();
|
|
186
|
+
if (typeof result === 'string') {
|
|
187
|
+
this.welcomeMessage = result;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
this.showPoweredBy = result.whitelabel;
|
|
191
|
+
this.suggestedQuestions = result.suggestedQuestions;
|
|
192
|
+
this.welcomeMessage = result.initialMessage;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
handleMessageSent(event) {
|
|
197
|
+
this.messages = [...this.messages, { text: event.detail, sender: 'user' }];
|
|
198
|
+
if (!this.disableInput) {
|
|
199
|
+
this.webSocketService.sendMessage(event.detail);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
render() {
|
|
203
|
+
return (h("div", { key: '3859ef3aaac75a1c77c852afda76239eb21e5891', class: 'biel-bot-wrapper' }, this.showModal && (h("div", { key: '3d872afafc528bb031370ac0b70f2e52744c2ae3', class: "feedback-overlay" })), this.showModal && (h("div", { key: '38dd9be033f5675180692cdd8893ee024777423d', class: `biel-bot-content biel-bot-content--${this.modalPosition} ${this.showModal ? 'biel-bot-content--open' : ''} ${this.isFullscreen ? 'fullscreen' : ''}`, ref: el => (this.modalContent = el) }, h("div", { key: '9beba7847f68dcf6ae80d6aa6a0c21ff09f86a38', class: "biel-bot-header" }, h("biel-header", { key: '5c37420640d0f798105581b0647ba4fabd666137', headerTitle: this.headerTitle, project: this.project, showPoweredBy: this.showPoweredBy, hideExpandButton: this.hideExpandButton, fullscreen: this.isFullscreen })), h("div", { key: '3e9420299a18d67d14e9d5c2bc2b7dcbffdf8e6d', class: "biel-bot-body" }, h("biel-chat", { key: 'ab6ddc35fc61dda5a538b7ee5f430be229aff18b', messages: this.messages, welcomeMessage: this.welcomeMessage, hideFeedback: this.hideFeedback, loadedChat: this.loadedChat, suggestedQuestions: this.suggestedQuestions, suggestedQuestionsTitle: this.suggestedQuestionsTitle, isFullscreen: this.isFullscreen, isLoading: this.isLoading, modalPosition: this.modalPosition }), h("biel-input", { key: '77256321397b784ac81be231d4515051e6c04668', placeholderText: this.inputPlaceholderText, sendButtonText: this.sendButtonText, onMessageSent: (event) => this.handleMessageSent(event), isDisabled: this.isLoading || this.disableInput })), h("div", { key: '57fce332b7c983521a756ad6c6eca74f5beb4849', class: "biel-bot-footer" }, this.footerText)))));
|
|
204
|
+
}
|
|
205
|
+
get el() { return getElement(this); }
|
|
206
|
+
};
|
|
207
|
+
BielBot.style = bielBotCss;
|
|
208
|
+
|
|
209
|
+
export { BielBot as biel_bot };
|
|
210
|
+
|
|
211
|
+
//# sourceMappingURL=biel-bot.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"biel-bot.entry.esm.js","mappings":";;AAAA,MAAM,MAAM,GAAG,+BAA+B,CAAC;MAElC,oBAAoB;IAU/B,YAAY,SAAiB,EAAE,YAAoB;QAR3C,oBAAe,GAA+B,EAAE,CAAC;QACjD,gBAAW,GAAY,KAAK,CAAC;QAE7B,WAAM,GAAW,EAAE,CAAC;QAM1B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,OAAO,EAAE,CAAC;KAChB;IAEO,OAAO;QACb,IAAI,CAAC,EAAE,GAAG,IAAI,SAAS,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QAExD,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG;YACf,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;SACzB,CAAC;QAEF,IAAI,CAAC,EAAE,CAAC,SAAS,GAAG,CAAC,KAAK;YACxB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE;gBAClC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;aAC9B;YACD,IAAI,OAAO,CAAC,IAAI,EAAE;gB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IAAI,CAAC,SAAS,GAAG,wBAAwB,GAAG,EAAE,IAAI,IAAI,CAAC,YAAY,GAAG,YAAY,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC,IACpM,4DAAK,KAAK,EAAC,iBAAiB,IAC1B,oEAAa,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,EAAE,IAAI,CAAC,YAAY,GAAgB,CACxL,EACN,4DAAK,KAAK,EAAC,eAAe,IACxB,kEACE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,cAAc,EAAE,IAAI,CAAC,cAAc,EACnC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,EAC3C,uBAAuB,EAAE,IAAI,CAAC,uBAAuB,EACrD,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,aAAa,EAAE,IAAI,CAAC,aAAa,GACvB,EACZ,mEACE,eAAe,EAAE,IAAI,CAAC,oBAAoB,EAC1C,cAAc,EAAE,IAAI,CAAC,cAAc,EACnC,aAAa,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EACvD,UAAU,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,YAAY,GACpC,CACT,EACN,4DAAK,KAAK,EAAC,iBAAiB,IACzB,IAAI,CAAC,UAAU,CACZ,CACF,CACP,CACG,EACN;KACH;;;;;;;","names":[],"sources":["src/services/biel-websocket-service.ts","src/services/biel-service.ts","src/components/biel-bot/biel-bot.css?tag=biel-bot&encapsulation=shadow","src/components/biel-bot/biel-bot.tsx"],"sourcesContent":["const WS_URL = 'wss://app.biel.ai/ws/messages';\n\nexport class BielWebSocketService {\n private ws: WebSocket;\n private messageHandlers: ((message: any) => void)[] = [];\n private isConnected: boolean = false;\n private projectId: string;\n private chatId: string = '';\n private errorMessage: string;\n private loadingStartHandler: () => void;\n private loadingEndHandler: () => void;\n\n constructor(projectId: string, errorMessage: string) {\n this.projectId = projectId;\n this.errorMessage = errorMessage;\n this.connect();\n }\n\n private connect(): void {\n this.ws = new WebSocket(`${WS_URL}/${this.projectId}/`);\n\n this.ws.onopen = () => {\n this.isConnected = true;\n };\n\n this.ws.onmessage = (event) => {\n const message = JSON.parse(event.data);\n if (!this.chatId && message.chatId) {\n this.chatId = message.chatId;\n }\n if (message.from) {\n this.loadingEndHandler();\n this.messageHandlers.forEach(handler => handler(message));\n }\n };\n\n this.ws.onclose = () => {\n this.isConnected = false;\n };\n\n this.ws.onerror = (error) => {\n console.error('WebSocket error:', error);\n this.isConnected = false;\n this.loadingEndHandler();\n };\n }\n\n public sendMessage(message: string): void {\n const payload = {\n projectId: this.projectId,\n chatId: this.chatId,\n url: window.location.href,\n from: 'user',\n message: message,\n };\n if (this.isConnected) {\n this.ws.send(JSON.stringify(payload));\n this.loadingStartHandler();\n } else {\n this.messageHandlers.forEach(handler => handler({ message: this.errorMessage, from: 'ai' }));\n }\n }\n\n public closeSocket(): void {\n this.ws.close();\n }\n\n public onMessage(handler: (message: any) => void): void {\n this.messageHandlers.push(handler);\n }\n\n public onLoadingStart(handler: () => void): void {\n this.loadingStartHandler = handler;\n }\n\n public onLoadingEnd(handler: () => void): void {\n this.loadingEndHandler = handler;\n }\n}\n","const BASE_URL = \"https://app.biel.ai/api/v1\";\n\nexport class BielService {\n private project: string;\n private errorMessage404: string;\n private errorMessage403: string;\n private errorMessageDefault: string;\n\n constructor(project: string, errorMessage404: string, errorMessage403: string, errorMessageDefault: string) {\n this.project = project;\n this.errorMessage404 = errorMessage404;\n this.errorMessage403 = errorMessage403;\n this.errorMessageDefault = errorMessageDefault;\n }\n\n async getProjectDetails(): Promise<{ whitelabel: boolean, suggestedQuestions: string[], initialMessage: string } | string> {\n try {\n const response = await fetch(`${BASE_URL}/projects/${this.project}/`);\n\n if (response.status === 404) {\n return this.errorMessage404;\n }\n\n if (response.status === 403) {\n return this.errorMessage403;\n }\n\n if (!response.ok) {\n return this.errorMessageDefault;\n }\n\n const data = await response.json();\n return {\n whitelabel: data.whitelabel,\n suggestedQuestions: data.suggested_questions,\n initialMessage: data.initial_message\n };\n } catch (error) {\n console.error('Error fetching project details:', error);\n return this.errorMessageDefault;\n }\n }\n\n async sendFeedback(messageId: string, feedback: { reaction: 0 | 1 }) {\n try {\n const response = await fetch(`${BASE_URL}/messages/${messageId}/feedback/`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json; charset=UTF-8' },\n body: JSON.stringify(feedback),\n });\n\n if (!response.ok) {\n console.error('Error:', response.status);\n }\n } catch (error) {\n console.error('Error sending feedback:', error);\n }\n }\n}\n",".text-center {\n flex-grow: 1;\n text-align: center;\n}\n\n.biel-bot-wrapper {\n position: absolute;\n z-index: var(--biel-bot-wrapper-z-index);\n}\n\n.biel-overlay {\n background-color: var(--biel-bot-screenshot-bg-color);\n height: 100%;\n left: 0;\n position: fixed;\n top: 0;\n width: 100%;\n z-index: var(--biel-bot-screnshot-z-index);\n}\n\n.biel-bot {\n display: inline-block;\n position: relative;\n}\n\n.biel-bot-content {\n background-color: var(--biel-bot-content-bg-color);\n border: 1px solid var(--biel-bot-header-text-color);\n border-radius: var(--biel-bot-content-border-radius);\n box-shadow: 0px 1px 2px 0px rgba(60, 64, 67, .30), 0px 2px 6px 2px rgba(60, 64, 67, .15);\n box-sizing: border-box;\n color: var(--biel-bot-content-text-color);\n display: flex;\n flex-direction: column;\n font-family: var(--biel-bot-content-font-family);\n left: 50%;\n max-width: 90%;\n max-height: 80vh;\n overflow: hidden;\n padding: 20px;\n position: fixed;\n top: 50%;\n transform: translate(-50%, -50%);\n width: 100%;\n z-index: var(--biel-bot-content-z-index);\n transition: all 0.3s ease-in-out;\n animation: fadeIn 0.3s;\n}\n\n.biel-bot-header {\n margin-bottom: 20px;\n}\n\n.biel-bot-footer {\n font-size: var(--biel-footer-font-size);\n text-align: center;\n}\n\n.biel-bot-footer a {\n color: var(--biel-bot-footer-link);\n font-weight: 500;\n text-decoration: none;\n}\n\n.biel-logo {\n align-items: center;\n display: flex;\n justify-content: center;\n margin-top: 5px;\n}\n\n.biel-logo a {\n margin-left: 3px;\n}\n\n.biel-bot-close {\n background-color: var(--biel-bot-close-bg-color);\n border: 0;\n border-radius: 50%;\n cursor: pointer;\n height: 22px;\n margin-left: auto;\n padding: 0;\n width: 22px;\n}\n\n.biel-bot-close svg {\n stroke: var(--biel-bot-close-color);\n}\n\n.biel-bot-content.fullscreen {\n width: 100vw;\n max-width: 100vw;\n height: 100vh;\n max-height: 100vh;\n border-radius: 0;\n padding: 20px 5vw;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n transition: all 0.3s ease-in-out;\n animation: fadeIn 0.3s;\n}\n\n@media screen and (min-width: 768px) {\n\n .biel-bot-content {\n max-width: 600px;\n max-height: 82vh;\n }\n\n .biel-bot-content.biel-bot-content--bottom-right {\n bottom: var(--biel-bot-content-position-bottom);\n left: initial;\n right: var(--biel-bot-content-position-right);\n top: initial;\n transform: initial;\n }\n\n .biel-bot-content.biel-bot-content--bottom-left {\n bottom: var(--biel-bot-content-position-bottom);\n left: var(--biel-bot-content-position-left);\n top: initial;\n transform: initial;\n }\n\n .biel-bot-content.biel-bot-content--top-right {\n right: var(--biel-bot-content-position-right);\n left: initial;\n top: var(--biel-bot-content-position-top);\n transform: initial;\n }\n\n .biel-bot-content.biel-bot-content--top-left {\n left: var(--biel-bot-content-position-left);\n top: var(--biel-bot-content-position-top);\n transform: initial;\n }\n\n .biel-bot-content.biel-bot-content--center-left {\n left: 5px;\n right: auto;\n top: 50%;\n transform: translateY(-50%);\n }\n\n .biel-bot-content.biel-bot-content--center-right {\n left: auto;\n right: 5px;\n top: 50%;\n transform: translateY(-50%);\n }\n\n .biel-bot-content.biel-bot-content--sidebar-left.biel-bot-content--open,\n .biel-bot-content.biel-bot-content--sidebar-right.biel-bot-content--open {\n transform: translateX(0);\n max-height: 100vh;\n }\n\n .biel-bot-content.biel-bot-content--sidebar-left {\n max-width: 300px;\n left: 0;\n right: auto;\n height: 100vh;\n top: 0;\n transform: translateX(-100%);\n border-radius: 0;\n }\n\n .biel-bot-content.biel-bot-content--sidebar-right {\n max-width: 300px;\n left: auto;\n right: 0;\n height: 100vh;\n top: 0;\n transform: translateX(100%);\n border-radius: 0;\n }\n\n .biel-bot-content.fullscreen {\n width: 100vw;\n max-width: 100vw;\n height: 100vh;\n max-height: 100vh;\n border-radius: 0;\n padding: 20px 25vw;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n transition: all 0.3s ease-in-out;\n animation: fadeIn 0.3s;\n }\n\n .biel-bot-content.fullscreen.biel-bot-content--bottom-right {\n left: initial;\n top: initial;\n bottom: 0;\n right: 0;\n transform: initial;\n }\n\n .biel-bot-content.fullscreen.biel-bot-content--bottom-left {\n left: 0;\n top: initial;\n bottom: 0;\n transform: initial;\n }\n\n .biel-bot-content.fullscreen.biel-bot-content--center-right,\n .biel-bot-content.fullscreen.biel-bot-content--top-right {\n left: initial;\n top: 0;\n bottom: 0;\n right: 0;\n transform: initial;\n }\n\n .biel-bot-content.fullscreen.biel-bot-content--sidebar-right {\n left: initial;\n top: 0;\n bottom: 0;\n right: 0;\n transform: initial;\n }\n\n .biel-bot-content.fullscreen.biel-bot-content--sidebar-left {\n left: 0;\n top: 0;\n bottom: 0;\n transform: initial;\n }\n}\n\n@keyframes fadeIn {\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n}\n\n@keyframes fadeOut {\n from {\n opacity: 1;\n }\n\n to {\n opacity: 0;\n }\n}","import { Component, Element, h, Listen, Prop, State } from '@stencil/core';\nimport { BielWebSocketService } from '../../services/biel-websocket-service';\nimport { BielService } from '../../services/biel-service';\n\n@Component({\n tag: 'biel-bot',\n styleUrl: 'biel-bot.css',\n shadow: true\n})\nexport class BielBot {\n\n // Define the component properties\n @Prop() modalPosition: string = 'center';\n @Prop() project: string = '';\n @Prop({ mutable: true, reflect: true }) showModal: boolean = false;\n @Prop() fetchData: boolean = true;\n @Prop() headerTitle: string = 'Company Name AI';\n @Prop() inputPlaceholderText: string = 'Type your message';\n @Prop() sendButtonText: string = 'Send';\n @Prop() hideExpandButton: boolean = false;\n @Prop() expandModal: boolean = false;\n @Prop() errorMessage404: string = \"Oops! We could not find the provided project ID.\";\n @Prop() errorMessage403: string = \"Oops! The request URL does not match the one defined for this project.\";\n @Prop() errorMessageDefault: string = \"Oops! Please try again later.\";\n @Prop() footerText: string = \"AI generated answers. Always verify the sources before using them.\";\n @Prop() suggestedQuestionsTitle: string = 'Suggested questions';\n @Prop() initialMessages: { text: string, sender: 'user' | 'ai', feedback?: 0 | 1 }[] = [];\n @Prop() disableInput: boolean = false;\n @Prop() hideFeedback: boolean = false;\n\n @State() isFullscreen: boolean = this.expandModal;\n @State() isLoading: boolean = false;\n @State() showPoweredBy: boolean = true;\n @State() suggestedQuestions: string[];\n @State() welcomeMessage: string;\n @State() messages: { text: string, sender: 'user' | 'ai', messageId?: string, feedback?: 0 | 1 , sources?: { title: string, url: string }[] }[] = [];\n @State() loadedChat: boolean = false;\n\n @Element() el: HTMLElement;\n\n @Listen('closeClicked', { target: 'body' })\n handleClose() {\n const modal = this.el.shadowRoot.querySelector('.biel-bot-content') as HTMLElement;\n modal.style.animation = 'fadeOut 0.3s';\n setTimeout(() => {\n this.showModal = false;\n document.body.style.overflow = '';\n }, 299);\n }\n @Listen('fullscreenClicked', { target: 'body' })\n handleFullscreenClicked() {\n this.isFullscreen = !this.isFullscreen;\n setTimeout(() => {\n document.body.style.overflow = this.isFullscreen ? 'hidden' : '';\n }, 300);\n }\n @Listen('suggestedQuestionClick', { target: 'body' })\n handleQuestionSelected(event: CustomEvent<string>) {\n this.handleMessageSent(event);\n }\n @Listen('feedbackSent', { target: 'body' })\n handleFeedback(event: CustomEvent<{ messageId: string, reaction: 0 | 1 }>) {\n if (!this.hideFeedback) {\n const { messageId, reaction } = event.detail;\n this.bielService.sendFeedback(messageId, { reaction });\n }\n }\n\n // Define the accesible and modificable divs in the screenshot\n modalContent: HTMLElement;\n webSocketService: BielWebSocketService;\n bielService: BielService;\n\n constructor() {\n if (!this.disableInput) {\n this.webSocketService = new BielWebSocketService(this.project, this.errorMessageDefault);\n this.webSocketService.onMessage(this.handleIncomingMessage.bind(this));\n this.webSocketService.onLoadingStart(() => this.isLoading = true);\n this.webSocketService.onLoadingEnd(() => this.isLoading = false);\n }\n }\n\n handleIncomingMessage(message: any) {\n this.messages = [...this.messages, { sender: message.from, text: message.message, messageId: message.messageId, sources: message.sources }];\n }\n\n async componentWillLoad() {\n if (this.initialMessages.length > 0) {\n this.messages = [...this.initialMessages];\n this.loadedChat = true;\n }\n if (this.fetchData && !this.disableInput) {\n this.bielService = new BielService(\n this.project,\n this.errorMessage404,\n this.errorMessage403,\n this.errorMessageDefault\n );\n const result = await this.bielService.getProjectDetails();\n\n if (typeof result === 'string') {\n this.welcomeMessage = result;\n } else {\n this.showPoweredBy = result.whitelabel;\n this.suggestedQuestions = result.suggestedQuestions;\n this.welcomeMessage = result.initialMessage;\n }\n }\n }\n\n handleMessageSent(event: CustomEvent<string>) {\n this.messages = [...this.messages, { text: event.detail, sender: 'user' }];\n if (!this.disableInput) {\n this.webSocketService.sendMessage(event.detail);\n }\n }\n\n render() {\n return (\n <div class='biel-bot-wrapper'>\n {this.showModal && (<div class=\"feedback-overlay\"></div>)}\n {this.showModal && (\n <div class={`biel-bot-content biel-bot-content--${this.modalPosition} ${this.showModal ? 'biel-bot-content--open' : ''} ${this.isFullscreen ? 'fullscreen' : ''}`} ref={el => (this.modalContent = el)}>\n <div class=\"biel-bot-header\">\n <biel-header headerTitle={this.headerTitle} project={this.project} showPoweredBy={this.showPoweredBy} hideExpandButton={this.hideExpandButton} fullscreen={this.isFullscreen}></biel-header>\n </div>\n <div class=\"biel-bot-body\">\n <biel-chat \n messages={this.messages} \n welcomeMessage={this.welcomeMessage}\n hideFeedback={this.hideFeedback} \n loadedChat={this.loadedChat} \n suggestedQuestions={this.suggestedQuestions} \n suggestedQuestionsTitle={this.suggestedQuestionsTitle} \n isFullscreen={this.isFullscreen} \n isLoading={this.isLoading}\n modalPosition={this.modalPosition}>\n </biel-chat>\n <biel-input\n placeholderText={this.inputPlaceholderText}\n sendButtonText={this.sendButtonText}\n onMessageSent={(event) => this.handleMessageSent(event)}\n isDisabled={this.isLoading || this.disableInput}>\n </biel-input>\n </div>\n <div class=\"biel-bot-footer\">\n {this.footerText}\n </div>\n </div>\n )}\n </div>\n );\n }\n}"],"version":3}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { r as registerInstance, h, a as Host, g as getElement } from './index-0e558c11.js';
|
|
2
|
+
|
|
3
|
+
const bielButtonCss = ".biel-button-content{cursor:pointer;max-width:fit-content;z-index:var(-biel-button-z-index)}.biel-button-content--light{align-items:center;background-color:var(--biel-button-light-bg-color);border-radius:var(--biel-button-border-radius);box-shadow:rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;box-sizing:border-box;color:var(--biel-button-light-text-color);display:flex;font-family:var(--feedback-font-family);font-size:var(--biel-button-text-font-size);font-weight:var(--biel-button-text-font-weight);padding:8px 15px}.biel-button-content--dark{align-items:center;background-color:var(--biel-button-dark-bg-color);border-radius:var(--biel-button-border-radius);box-shadow:rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;box-sizing:border-box;color:var(--biel-button-dark-text-color);display:flex;font-family:var(--feedback-font-family);font-weight:var(--biel-button-text-font-weight);font-size:var(--biel-button-text-font-size);padding:8px 15px}.biel-button-content--bottom-right{bottom:15px;position:fixed;right:15px}.biel-button-content--center-right{position:fixed;transform:rotate(-90deg) translateY(-50%);top:50%}.biel-button-content--center-right.biel-button-content--dark,.biel-button-content--center-right.biel-button-content--light{border-radius:4px;border-bottom-left-radius:0px;border-bottom-right-radius:0px}.biel-button-content-icon{height:var(--biel-button-icon-size);margin-right:5px;width:var(--biel-button-icon-size)}.biel-button-content--center-right .biel-button-content-icon{rotate:90deg}";
|
|
4
|
+
|
|
5
|
+
const BielButton = class {
|
|
6
|
+
constructor(hostRef) {
|
|
7
|
+
registerInstance(this, hostRef);
|
|
8
|
+
this.customFont = false;
|
|
9
|
+
this.project = '';
|
|
10
|
+
this.buttonStyle = 'default';
|
|
11
|
+
this.buttonPosition = 'default';
|
|
12
|
+
this.modalPosition = 'center';
|
|
13
|
+
this.headerTitle = 'Company Name AI';
|
|
14
|
+
this.hideIcon = false;
|
|
15
|
+
this.hideExpandButton = false;
|
|
16
|
+
this.expandModal = false;
|
|
17
|
+
this.errorMessage404 = "Oops! We could not find the provided project ID.";
|
|
18
|
+
this.errorMessage403 = "Oops! The request URL does not match the one defined for this project.";
|
|
19
|
+
this.errorMessageDefault = "Oops! Please try again later.";
|
|
20
|
+
this.footerText = "AI generated answers. Always verify the sources before using them.";
|
|
21
|
+
this.initialMessages = [];
|
|
22
|
+
this.disableInput = false;
|
|
23
|
+
this.hideFeedback = false;
|
|
24
|
+
}
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
this.bielBot = document.createElement('biel-bot');
|
|
27
|
+
const props = [
|
|
28
|
+
'customFont',
|
|
29
|
+
'project',
|
|
30
|
+
'modalPosition',
|
|
31
|
+
'headerTitle',
|
|
32
|
+
'hideExpandButton',
|
|
33
|
+
'expandModal',
|
|
34
|
+
'errorMessage404',
|
|
35
|
+
'errorMessage403',
|
|
36
|
+
'errorMessageDefault',
|
|
37
|
+
'footerText',
|
|
38
|
+
'initialMessages',
|
|
39
|
+
'disableInput',
|
|
40
|
+
'hideFeedback',
|
|
41
|
+
];
|
|
42
|
+
props.forEach(prop => {
|
|
43
|
+
this.bielBot[prop] = this[prop];
|
|
44
|
+
});
|
|
45
|
+
document.body.appendChild(this.bielBot);
|
|
46
|
+
}
|
|
47
|
+
disconnectedCallback() {
|
|
48
|
+
document.body.removeChild(this.bielBot);
|
|
49
|
+
}
|
|
50
|
+
isSafariBrowser() {
|
|
51
|
+
const isSafari = /safari/i.test(navigator.userAgent) && !/chrome/i.test(navigator.userAgent);
|
|
52
|
+
return isSafari;
|
|
53
|
+
}
|
|
54
|
+
componentDidLoad() {
|
|
55
|
+
if (this.buttonPosition === 'center-right') {
|
|
56
|
+
const buttonContent = this.el.shadowRoot.querySelector('.biel-button-content');
|
|
57
|
+
let adjustment = 0;
|
|
58
|
+
if (this.isSafariBrowser()) {
|
|
59
|
+
adjustment = 10;
|
|
60
|
+
}
|
|
61
|
+
buttonContent.style.right = `${(buttonContent.offsetWidth + adjustment) / 2 * -1}px`;
|
|
62
|
+
}
|
|
63
|
+
if (!this.customFont) {
|
|
64
|
+
this.loadInterFont();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
loadInterFont() {
|
|
68
|
+
const link = document.createElement('link');
|
|
69
|
+
link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';
|
|
70
|
+
link.rel = 'stylesheet';
|
|
71
|
+
document.head.appendChild(link);
|
|
72
|
+
}
|
|
73
|
+
showModal() {
|
|
74
|
+
this.bielBot.showModal = true;
|
|
75
|
+
}
|
|
76
|
+
render() {
|
|
77
|
+
return (h(Host, { key: '84e8befdfbaee903ddee90ece093b0e7d4906328' }, h("a", { key: '8643e23e4eff9265c5b62241144f2a9c03193685', class: `biel-button-content biel-button-content--${this.buttonStyle} biel-button-content--${this.buttonPosition}`, onClick: () => this.showModal() }, !this.hideIcon && (h("span", { key: '33488e042b97f5794d99d7346967bf9baf419af9', class: "biel-button-content-icon" }, h("svg", { key: 'd830564e13b2902b5d15807bb79b857211abd3cc', xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "lucide lucide-bot" }, h("path", { key: '81c2ab79323d3223688138c8ef5a237f16a56c48', d: "M12 8V4H8" }), h("rect", { key: '361b2d41795fbb759343c9c0da7c0c056ca8ee09', width: "16", height: "12", x: "4", y: "8", rx: "2" }), h("path", { key: '725dc9c901a96cde0dde2e3418639e09684f837d', d: "M2 14h2" }), h("path", { key: 'b0bcb73986433d0bfa9a48af638cf47824d7c32e', d: "M20 14h2" }), h("path", { key: 'b0d051bc5fbb0309aa13c4eb71b665124a553105', d: "M15 13v2" }), h("path", { key: '3ac5061089cb3eaaa4f583a59f6846f324ac8e6d', d: "M9 13v2" })))), h("slot", { key: '83eb310c40d4ab0575d1c0170e086b58a9bb31e3' }))));
|
|
78
|
+
}
|
|
79
|
+
get el() { return getElement(this); }
|
|
80
|
+
};
|
|
81
|
+
BielButton.style = bielButtonCss;
|
|
82
|
+
|
|
83
|
+
export { BielButton as biel_button };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=biel-button.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"biel-button.entry.esm.js","mappings":";;AAAA,MAAM,aAAa,GAAG,siDAAsiD;;MCO/iD,UAAU;;;0BAIS,KAAK;uBACT,EAAE;2BACE,SAAS;8BACN,SAAS;6BACV,QAAQ;2BACV,iBAAiB;wBACnB,KAAK;gCACG,KAAK;2BACV,KAAK;+BACF,kDAAkD;+BAClD,wEAAwE;mCACpE,+BAA+B;0BACxC,oEAAoE;+BAC5B,EAAE;4BACvC,KAAK;4BACL,KAAK;;IAErC,iBAAiB;QACf,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAClD,MAAM,KAAK,GAAG;YACZ,YAAY;YACZ,SAAS;YACT,eAAe;YACf,aAAa;YACb,kBAAkB;YAClB,aAAa;YACb,iBAAiB;YACjB,i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AAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;KACjC;IAED,SAAS;QACP,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;KAC/B;IAED,MAAM;QACJ,QACE,EAAC,IAAI,uDACH,0DAAG,KAAK,EAAE,4CAA4C,IAAI,CAAC,WAAW,yBAAyB,IAAI,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE,IAClJ,CAAC,IAAI,CAAC,QAAQ,KACb,6DAAM,KAAK,EAAC,0BAA0B,IACpC,4DAAK,KAAK,EAAC,4BAA4B,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,kBAAc,GAAG,oBAAgB,OAAO,qBAAiB,OAAO,EAAC,KAAK,EAAC,mBAAmB,IAAC,6DAAM,CAAC,EAAC,WAAW,GAAE,EAAA,6DAAM,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,CAAC,EAAC,GAAG,EAAC,CAAC,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,GAAE,EAAA,6DAAM,CAAC,EAAC,SAAS,GAAE,EAAA,6DAAM,CAAC,EAAC,UAAU,GAAE,EAAA,6DAAM,CAAC,EAAC,UAAU,GAAE,EAAA,6DAAM,CAAC,EAAC,SAAS,GAAE,CAAM,CACpW,CACR,EACD,8DAAQ,CACN,CACC,EACP;KACH;;;;;;;","names":[],"sources":["src/components/biel-button/biel-button.css?tag=biel-button&encapsulation=shadow","src/components/biel-button/biel-button.tsx"],"sourcesContent":[".biel-button-content {\n cursor: pointer;\n max-width: fit-content;\n z-index: var(-biel-button-z-index);\n}\n\n.biel-button-content--light{\n align-items: center;\n background-color: var(--biel-button-light-bg-color);\n border-radius: var(--biel-button-border-radius);\n box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;\n box-sizing: border-box;\n color: var(--biel-button-light-text-color);\n display: flex;\n font-family: var(--feedback-font-family);\n font-size: var(--biel-button-text-font-size);\n font-weight: var(--biel-button-text-font-weight);\n padding: 8px 15px;\n}\n\n.biel-button-content--dark{\n align-items: center;\n background-color: var(--biel-button-dark-bg-color);\n border-radius: var(--biel-button-border-radius);\n box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;\n box-sizing: border-box;\n color: var(--biel-button-dark-text-color);\n display: flex;\n font-family: var(--feedback-font-family);\n font-weight: var(--biel-button-text-font-weight);\n font-size: var(--biel-button-text-font-size);\n padding: 8px 15px;\n}\n\n.biel-button-content--bottom-right{\n bottom: 15px;\n position: fixed;\n right: 15px;\n}\n\n.biel-button-content--center-right{\n position: fixed;\n transform: rotate(-90deg) translateY(-50%);\n top: 50%;\n}\n\n.biel-button-content--center-right.biel-button-content--dark,\n.biel-button-content--center-right.biel-button-content--light {\n border-radius: 4px;\n border-bottom-left-radius: 0px;\n border-bottom-right-radius: 0px;\n}\n\n\n.biel-button-content-icon {\n height: var(--biel-button-icon-size);\n margin-right: 5px;\n width: var(--biel-button-icon-size);\n}\n\n.biel-button-content--center-right .biel-button-content-icon {\n rotate: 90deg;\n}","import { Component, Element, Host, Prop, h } from '@stencil/core';\n\n@Component({\n tag: 'biel-button',\n styleUrl: 'biel-button.css',\n shadow: true,\n})\nexport class BielButton {\n\n bielBot: any;\n @Element() el: HTMLElement;\n @Prop() customFont: boolean = false;\n @Prop() project: string = '';\n @Prop() buttonStyle: string = 'default';\n @Prop() buttonPosition: string = 'default';\n @Prop() modalPosition: string = 'center';\n @Prop() headerTitle: string = 'Company Name AI';\n @Prop() hideIcon: boolean = false;\n @Prop() hideExpandButton: boolean = false;\n @Prop() expandModal: boolean = false;\n @Prop() errorMessage404: string = \"Oops! We could not find the provided project ID.\";\n @Prop() errorMessage403: string = \"Oops! The request URL does not match the one defined for this project.\";\n @Prop() errorMessageDefault: string = \"Oops! Please try again later.\";\n @Prop() footerText: string = \"AI generated answers. Always verify the sources before using them.\";\n @Prop() initialMessages: { text: string, sender: 'user' | 'ai' }[] = [];\n @Prop() disableInput: boolean = false;\n @Prop() hideFeedback: boolean = false;\n\n connectedCallback() {\n this.bielBot = document.createElement('biel-bot');\n const props = [\n 'customFont',\n 'project',\n 'modalPosition',\n 'headerTitle',\n 'hideExpandButton',\n 'expandModal',\n 'errorMessage404',\n 'errorMessage403',\n 'errorMessageDefault',\n 'footerText',\n 'initialMessages',\n 'disableInput',\n 'hideFeedback',\n ];\n\n props.forEach(prop => {\n this.bielBot[prop] = this[prop];\n });\n\n document.body.appendChild(this.bielBot);\n }\n\n disconnectedCallback() {\n document.body.removeChild(this.bielBot);\n }\n\n isSafariBrowser() {\n const isSafari = /safari/i.test(navigator.userAgent) && !/chrome/i.test(navigator.userAgent);\n return isSafari;\n }\n\n componentDidLoad() {\n if (this.buttonPosition === 'center-right') {\n const buttonContent = this.el.shadowRoot.querySelector('.biel-button-content') as HTMLElement;\n let adjustment = 0;\n if (this.isSafariBrowser()) {\n adjustment = 10;\n }\n buttonContent.style.right = `${(buttonContent.offsetWidth + adjustment) / 2 * -1}px`;\n }\n if (!this.customFont) {\n this.loadInterFont();\n }\n }\n\n loadInterFont() {\n const link = document.createElement('link');\n link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';\n link.rel = 'stylesheet';\n document.head.appendChild(link);\n }\n\n showModal() {\n this.bielBot.showModal = true;\n }\n\n render() {\n return (\n <Host>\n <a class={`biel-button-content biel-button-content--${this.buttonStyle} biel-button-content--${this.buttonPosition}`} onClick={() => this.showModal()}>\n {!this.hideIcon && (\n <span class=\"biel-button-content-icon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-bot\"><path d=\"M12 8V4H8\"/><rect width=\"16\" height=\"12\" x=\"4\" y=\"8\" rx=\"2\"/><path d=\"M2 14h2\"/><path d=\"M20 14h2\"/><path d=\"M15 13v2\"/><path d=\"M9 13v2\"/></svg>\n </span>\n )}\n <slot />\n </a>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { r as registerInstance, h, g as getElement } from './index-0e558c11.js';
|
|
2
|
+
|
|
3
|
+
const bielChatCss = ".biel-chat-container{display:flex;flex-direction:column;height:var(--biel-chat-height);overflow-y:auto;padding:10px;transition:all 0.3s ease-in-out}.biel-chat-container.sidebar-right,.biel-chat-container.sidebar-left{height:calc(100vh - 200px)}.biel-chat-container.fullscreen{height:calc(100vh - (200px + var(--biel-footer-font-size) + 12px));max-height:calc(100vh - (200px + var(--biel-footer-font-size) + 12px))}.biel-chat-container::-webkit-scrollbar{width:6px}.biel-chat-container::-webkit-scrollbar-thumb{background-color:var(--biel-chat-scrollbar-color);border-radius:10px;border:3px solid transparent}.biel-chat-container::-webkit-scrollbar-thumb:hover{background-color:var(--biel-chat-scrollbar-hover-color)}.loading-animation{display:flex;align-items:center;justify-content:center;height:40px;margin-top:10px}.loading-animation .dot{width:8px;height:8px;margin:0 5px;background-color:var(--biel-text-color);border-radius:50%;animation:bounce 1.2s infinite ease-in-out}.loading-animation .dot:nth-child(1){animation-delay:-0.32s}.loading-animation .dot:nth-child(2){animation-delay:-0.16s}.loading-animation .dot:nth-child(3){animation-delay:0s}@keyframes bounce{0%,80%,100%{transform:scale(0)}40%{transform:scale(1)}}@media screen and (min-width: 768px){.biel-chat-container.fullscreen{height:calc(100vh - 180px);max-height:calc(100vh - 180px)}}";
|
|
4
|
+
|
|
5
|
+
const BielChat = class {
|
|
6
|
+
constructor(hostRef) {
|
|
7
|
+
registerInstance(this, hostRef);
|
|
8
|
+
this.offset = 0;
|
|
9
|
+
this.chatHeight = undefined;
|
|
10
|
+
this.messages = [];
|
|
11
|
+
this.isFullscreen = undefined;
|
|
12
|
+
this.isLoading = false;
|
|
13
|
+
this.suggestedQuestions = undefined;
|
|
14
|
+
this.welcomeMessage = undefined;
|
|
15
|
+
this.suggestedQuestionsTitle = undefined;
|
|
16
|
+
this.loadedChat = undefined;
|
|
17
|
+
this.hideFeedback = undefined;
|
|
18
|
+
this.modalPosition = undefined;
|
|
19
|
+
}
|
|
20
|
+
handleTextareaHeightChanged(event) {
|
|
21
|
+
this.offset += event.detail;
|
|
22
|
+
if (this.isFullscreen) {
|
|
23
|
+
this.adjustChatHeight();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
adjustChatHeight() {
|
|
27
|
+
const chatContainer = this.el.shadowRoot.querySelector('.biel-chat-container');
|
|
28
|
+
if (chatContainer) {
|
|
29
|
+
const varHeight = getComputedStyle(document.body).getPropertyValue('--biel-chat-height');
|
|
30
|
+
if (this.modalPosition !== 'sidebar-right' && this.modalPosition !== 'sidebar-left') {
|
|
31
|
+
const baseHeight = this.isFullscreen ? 'calc(100vh - 180px)' : varHeight;
|
|
32
|
+
this.chatHeight = `calc(${baseHeight} - ${this.offset}px)`;
|
|
33
|
+
chatContainer.style.height = this.chatHeight;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.chatHeight = `calc(100vh - 200px - ${this.offset}px)`;
|
|
37
|
+
chatContainer.style.height = this.chatHeight;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
componentDidUpdate() {
|
|
42
|
+
this.scrollToBottom();
|
|
43
|
+
this.adjustChatHeight();
|
|
44
|
+
}
|
|
45
|
+
scrollToBottom() {
|
|
46
|
+
const container = this.el.shadowRoot.querySelector('.biel-chat-container');
|
|
47
|
+
if (container) {
|
|
48
|
+
container.scrollTo({
|
|
49
|
+
top: container.scrollHeight,
|
|
50
|
+
behavior: 'smooth'
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
render() {
|
|
55
|
+
return (h("div", { key: '33975fb495da9e40f540593d55d141732fc492a2', class: `biel-chat-container ${this.isFullscreen ? 'fullscreen' : ''} ${this.modalPosition}` }, this.welcomeMessage && !this.loadedChat && (h("biel-message", { key: 'dac9218dec8ad9d6d31a808a6c5660cd816ae415', text: this.welcomeMessage, sender: "ai" })), this.suggestedQuestions && this.suggestedQuestions.length > 0 && !this.loadedChat && (h("biel-suggested-questions", { key: '720d61e3593a653dfe3eeb624761e58fb25b81dd', heading: this.suggestedQuestionsTitle, questions: this.suggestedQuestions })), this.messages.map((message) => (h("biel-message", { messageId: message.messageId, text: message.text, sender: message.sender, sources: message.sources, feedback: message.feedback, hideFeedback: this.hideFeedback }))), this.isLoading && (h("div", { key: 'e31d14374ba692107eabfd8c31443d7e026f8b33', class: "loading-animation" }, h("div", { key: '6453aa79e3d84aadd6f85b66777028274a78513a', class: "dot" }), h("div", { key: '1d426132f4d08592c6cfea3aaa54d2c1bb60bb0a', class: "dot" }), h("div", { key: '0051ff6777d8433b6cafa1e6f0986acff9fda87f', class: "dot" })))));
|
|
56
|
+
}
|
|
57
|
+
get el() { return getElement(this); }
|
|
58
|
+
};
|
|
59
|
+
BielChat.style = bielChatCss;
|
|
60
|
+
|
|
61
|
+
export { BielChat as biel_chat };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=biel-chat.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"biel-chat.entry.esm.js","mappings":";;AAAA,MAAM,WAAW,GAAG,40CAA40C;;MCOn1C,QAAQ;;;sBAEO,CAAC;;wBAGqH,EAAE;;yBAErH,KAAK;;;;;;;;IAUlC,2BAA2B,CAAC,KAA0B;QACpD,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;QAC5B,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,IAAI,CAAC,gBAAgB,EAAE,CAAC;SACzB;KACF;IAED,gBAAgB;QACd,MAA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I,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,EAAC,IAAI,GAAgB,CACrE,EACA,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,KAChF,iFAA0B,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,SAAS,EAAE,IAAI,CAAC,kBAAkB,GAA6B,CACjI,EACA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,MACzB,oBACE,SAAS,EAAE,OAAO,CAAC,SAAS,EAC5B,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,OAAO,EAAE,OAAO,CAAC,OAAO,EACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,YAAY,EAAE,IAAI,CAAC,YAAY,GAClB,CAChB,CAAC,EACD,IAAI,CAAC,SAAS,KACb,4DAAK,KAAK,EAAC,mBAAmB,IAC5B,4DAAK,KAAK,EAAC,KAAK,GAAO,EACvB,4DAAK,KAAK,EAAC,KAAK,GAAO,EACvB,4DAAK,KAAK,EAAC,KAAK,GAAO,CACnB,CACP,CACG,EACN;KACH;;;;;;;","names":[],"sources":["src/components/biel-chat/biel-chat.css?tag=biel-chat&encapsulation=shadow","src/components/biel-chat/biel-chat.tsx"],"sourcesContent":[".biel-chat-container {\n display: flex;\n flex-direction: column;\n height: var(--biel-chat-height);\n overflow-y: auto;\n padding: 10px;\n transition: all 0.3s ease-in-out;\n}\n\n.biel-chat-container.sidebar-right,\n.biel-chat-container.sidebar-left {\n height: calc(100vh - 200px);\n}\n\n.biel-chat-container.fullscreen {\n height: calc(100vh - (200px + var(--biel-footer-font-size) + 12px));\n max-height: calc(100vh - (200px + var(--biel-footer-font-size) + 12px));\n}\n\n.biel-chat-container::-webkit-scrollbar {\n width: 6px;\n}\n\n.biel-chat-container::-webkit-scrollbar-thumb {\n background-color: var(--biel-chat-scrollbar-color);\n border-radius: 10px;\n border: 3px solid transparent;\n}\n\n.biel-chat-container::-webkit-scrollbar-thumb:hover {\n background-color: var(--biel-chat-scrollbar-hover-color);\n}\n\n.loading-animation {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 40px;\n margin-top: 10px;\n}\n\n.loading-animation .dot {\n width: 8px;\n height: 8px;\n margin: 0 5px;\n background-color: var(--biel-text-color);\n border-radius: 50%;\n animation: bounce 1.2s infinite ease-in-out;\n}\n\n.loading-animation .dot:nth-child(1) {\n animation-delay: -0.32s;\n}\n\n.loading-animation .dot:nth-child(2) {\n animation-delay: -0.16s;\n}\n\n.loading-animation .dot:nth-child(3) {\n animation-delay: 0s;\n}\n\n@keyframes bounce {\n\n 0%,\n 80%,\n 100% {\n transform: scale(0);\n }\n\n 40% {\n transform: scale(1);\n }\n}\n\n@media screen and (min-width: 768px) {\n .biel-chat-container.fullscreen {\n height: calc(100vh - 180px);\n max-height: calc(100vh - 180px);\n }\n}","import { Component, Element, Prop, h, Listen, State } from '@stencil/core';\n\n@Component({\n tag: 'biel-chat',\n styleUrl: 'biel-chat.css',\n shadow: true,\n})\nexport class BielChat {\n\n @State() offset: number = 0;\n @State() chatHeight: string;\n\n @Prop() messages: { text: string, sender: 'user' | 'ai', messageId?: string, feedback?: 0 | 1, sources?: { title: string, url: string }[] }[] = [];\n @Prop() isFullscreen: boolean;\n @Prop() isLoading: boolean = false;\n @Prop() suggestedQuestions: string[];\n @Prop() welcomeMessage: string;\n @Prop() suggestedQuestionsTitle: string;\n @Prop() loadedChat: boolean;\n @Prop() hideFeedback: boolean;\n @Prop() modalPosition: string;\n @Element() el: HTMLElement;\n\n @Listen('textareaHeightChanged', { target: 'body' })\n handleTextareaHeightChanged(event: CustomEvent<number>) {\n this.offset += event.detail;\n if (this.isFullscreen) {\n this.adjustChatHeight();\n }\n }\n\n adjustChatHeight() {\n const chatContainer = this.el.shadowRoot.querySelector<HTMLElement>('.biel-chat-container');\n if (chatContainer) {\n const varHeight = getComputedStyle(document.body).getPropertyValue('--biel-chat-height');\n if (this.modalPosition !== 'sidebar-right' && this.modalPosition !== 'sidebar-left') {\n const baseHeight = this.isFullscreen ? 'calc(100vh - 180px)' : varHeight;\n this.chatHeight = `calc(${baseHeight} - ${this.offset}px)`;\n chatContainer.style.height = this.chatHeight;\n } else {\n this.chatHeight = `calc(100vh - 200px - ${this.offset}px)`;\n chatContainer.style.height = this.chatHeight;\n }\n }\n }\n\n componentDidUpdate() {\n this.scrollToBottom();\n this.adjustChatHeight();\n }\n\n scrollToBottom() {\n const container = this.el.shadowRoot.querySelector('.biel-chat-container');\n if (container) {\n container.scrollTo({\n top: container.scrollHeight,\n behavior: 'smooth'\n });\n }\n }\n\n render() {\n return (\n <div class={`biel-chat-container ${this.isFullscreen ? 'fullscreen' : ''} ${this.modalPosition}`}>\n {this.welcomeMessage && !this.loadedChat && (\n <biel-message text={this.welcomeMessage} sender=\"ai\"></biel-message>\n )}\n {this.suggestedQuestions && this.suggestedQuestions.length > 0 && !this.loadedChat && (\n <biel-suggested-questions heading={this.suggestedQuestionsTitle} questions={this.suggestedQuestions}></biel-suggested-questions>\n )}\n {this.messages.map((message) => (\n <biel-message\n messageId={message.messageId}\n text={message.text}\n sender={message.sender}\n sources={message.sources}\n feedback={message.feedback}\n hideFeedback={this.hideFeedback}>\n </biel-message>\n ))}\n {this.isLoading && (\n <div class=\"loading-animation\">\n <div class=\"dot\"></div>\n <div class=\"dot\"></div>\n <div class=\"dot\"></div>\n </div>\n )}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { r as registerInstance, e as createEvent, h } from './index-0e558c11.js';
|
|
2
|
+
|
|
3
|
+
const bielFeedbackCss = ".biel-feedback-container{display:flex;align-items:center;padding:5px;padding-left:0;padding-bottom:0}.biel-feedback-reaction{display:flex;gap:5px}.biel-feedback-btn{background:var(--biel-feedback-background-color);color:var(--biel-feedback-text-color);border:none;cursor:pointer;padding:4px 10px;border-radius:6px;transition:all 0.2s ease}.biel-feedback-btn:hover{background:var(--biel-feedback-background-hover-color)}.active,.active:hover{background:var(--biel-feedback-background-selected-color);color:var(--biel-feedback-text-selected-color)}";
|
|
4
|
+
|
|
5
|
+
const BielFeedback = class {
|
|
6
|
+
constructor(hostRef) {
|
|
7
|
+
registerInstance(this, hostRef);
|
|
8
|
+
this.feedbackSent = createEvent(this, "feedbackSent", 7);
|
|
9
|
+
this.messageId = undefined;
|
|
10
|
+
this.initialReaction = undefined;
|
|
11
|
+
this.reaction = undefined;
|
|
12
|
+
}
|
|
13
|
+
componentWillLoad() {
|
|
14
|
+
if (this.initialReaction !== undefined) {
|
|
15
|
+
this.reaction = this.initialReaction;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
handleReaction(reaction) {
|
|
19
|
+
if (this.messageId && this.reaction !== reaction) {
|
|
20
|
+
this.reaction = reaction;
|
|
21
|
+
this.feedbackSent.emit({ messageId: this.messageId, reaction: this.reaction });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
return (h("div", { key: 'd56ec391a875137535a10287a8d3d4dbcebeb5e1', class: "biel-feedback-container" }, h("div", { key: '08b54ce6cda89a286993650532481707786e3de2', class: "biel-feedback-reaction" }, h("button", { key: 'd834d0ab422460a1067624233feb01343dc6cced', class: `biel-feedback-btn like-btn ${this.reaction === 1 ? 'active' : ''}`, onClick: () => this.handleReaction(1) }, h("svg", { key: '1520bbc7f231a4f173711d67d10669171b746dab', xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "lucide lucide-thumbs-up" }, h("path", { key: '20fbfac154b8c911fbeefafcb003436a729fd549', d: "M7 10v12" }), h("path", { key: '2db1e65fa377ef4f92225f619614e4c69003d239', d: "M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z" }))), h("button", { key: '03bac9e257e23d11133a23ace7937ad19340d5ed', class: `biel-feedback-btn dislike-btn ${this.reaction === 0 ? 'active' : ''}`, onClick: () => this.handleReaction(0) }, h("svg", { key: '53eafd58d1914d1e17f3b03b3880dc58d9d6a5f3', xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "lucide lucide-thumbs-down" }, h("path", { key: '1a6598fb9cf83fbfb2b81f7b8d95fbcbc138b14c', d: "M17 14V2" }), h("path", { key: '2db89950d5a4b27a1741a38489f48206c8ddb7ba', d: "M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z" }))))));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
BielFeedback.style = bielFeedbackCss;
|
|
29
|
+
|
|
30
|
+
export { BielFeedback as biel_feedback };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=biel-feedback.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"biel-feedback.entry.esm.js","mappings":";;AAAA,MAAM,eAAe,GAAG,oiBAAoiB;;MCM/iB,YAAY;;;;;;;;IASvB,iBAAiB;QACf,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE;YACtC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC;SACtC;KACF;IAED,cAAc,CAAC,QAAe;QAC5B,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE;YAChD,IAAI,CAAC,QAAQ,GA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biel-feedback/biel-feedback.css?tag=biel-feedback&encapsulation=shadow","src/components/biel-feedback/biel-feedback.tsx"],"sourcesContent":[".biel-feedback-container {\n display: flex;\n align-items: center;\n padding: 5px;\n padding-left: 0;\n padding-bottom: 0;\n}\n\n.biel-feedback-reaction {\n display: flex;\n gap: 5px;\n}\n\n.biel-feedback-btn {\n background: var(--biel-feedback-background-color);\n color: var(--biel-feedback-text-color);\n border: none;\n cursor: pointer;\n padding: 4px 10px; \n border-radius: 6px;\n transition: all 0.2s ease;\n}\n\n.biel-feedback-btn:hover {\n background: var(--biel-feedback-background-hover-color);\n}\n\n.active, .active:hover {\n background: var(--biel-feedback-background-selected-color);\n color: var(--biel-feedback-text-selected-color);\n}","import { Component, Event, EventEmitter, h, Prop, State } from '@stencil/core';\n@Component({\n tag: 'biel-feedback',\n styleUrl: 'biel-feedback.css',\n shadow: true,\n})\nexport class BielFeedback {\n\n @Prop() messageId: string;\n @Prop() initialReaction?: 0 | 1;\n\n @State() reaction: 0 | 1; // 0 = Dislike, 1 = Like\n\n @Event() feedbackSent: EventEmitter<{ messageId: string, reaction: 0 | 1 }>;\n\n componentWillLoad() {\n if (this.initialReaction !== undefined) {\n this.reaction = this.initialReaction;\n }\n }\n\n handleReaction(reaction: 0 | 1) {\n if (this.messageId && this.reaction !== reaction) {\n this.reaction = reaction;\n this.feedbackSent.emit({ messageId: this.messageId, reaction: this.reaction });\n }\n }\n\n render() {\n return (\n <div class=\"biel-feedback-container\">\n <div class=\"biel-feedback-reaction\">\n <button class={`biel-feedback-btn like-btn ${this.reaction === 1 ? 'active' : ''}`} onClick={() => this.handleReaction(1)}>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-thumbs-up\"><path d=\"M7 10v12\" /><path d=\"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z\" /></svg>\n </button>\n <button class={`biel-feedback-btn dislike-btn ${this.reaction === 0 ? 'active' : ''}`} onClick={() => this.handleReaction(0)}>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-thumbs-down\"><path d=\"M17 14V2\" /><path d=\"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z\" /></svg>\n </button>\n </div>\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as registerInstance, e as createEvent, h } from './index-0e558c11.js';
|
|
2
2
|
|
|
3
3
|
const bielHeaderCss = ".biel-header{align-items:top;display:flex;padding-bottom:10px;color:var(--biel-header-text-color);border-bottom:1px solid var(--biel-header-border-color);justify-content:space-between}.biel-header__title{font-size:var(--biel-header-font-size);font-weight:var(--biel-header-font-weight)}.biel-header__powered-by:not(:empty){color:var(--biel-header-powered-by-text-color);padding-top:5px;font-size:14px;height:12px}.biel-header__powered-by a{color:var(--biel-header-powered-by-link-color);font-weight:500;text-decoration:none}.biel-header__icons{display:flex;justify-content:flex-end}.biel-header__icon{color:var(--biel-header-text-color);background:none;border:none;cursor:pointer;display:flex;padding:3px;padding-top:0;margin-left:5px}";
|
|
4
|
-
const BielHeaderStyle0 = bielHeaderCss;
|
|
5
4
|
|
|
6
|
-
const BielHeader =
|
|
7
|
-
constructor() {
|
|
8
|
-
|
|
9
|
-
this.__registerHost();
|
|
10
|
-
this.__attachShadow();
|
|
5
|
+
const BielHeader = class {
|
|
6
|
+
constructor(hostRef) {
|
|
7
|
+
registerInstance(this, hostRef);
|
|
11
8
|
this.closeClicked = createEvent(this, "closeClicked", 7);
|
|
12
9
|
this.fullscreenClicked = createEvent(this, "fullscreenClicked", 7);
|
|
13
10
|
this.headerTitle = undefined;
|
|
@@ -28,32 +25,11 @@ const BielHeader = /*@__PURE__*/ proxyCustomElement(class BielHeader extends H {
|
|
|
28
25
|
this.fullscreenClicked.emit();
|
|
29
26
|
}
|
|
30
27
|
render() {
|
|
31
|
-
return (h("header", { key: '
|
|
28
|
+
return (h("header", { key: '7d08c8f1a3e30a2a4ccb3793609fb7871ec78c1d', class: "biel-header" }, h("div", { key: '12b78778af97d18a5f21296593edd6a2f2cebda2', class: "biel-header__title-container" }, h("div", { key: 'f31d4313863b166af252fd011f965eb81ed091d8', class: "biel-header__title" }, this.headerTitle), h("div", { key: '494790f0ca4acdd5a99fa9fe0bc20a17de59b3df', class: "biel-header__powered-by" }, this.showPoweredBy && (h("span", { key: '969aa7de2c85b2a9d2208019b9c3e69db0162f7d' }, "Powered by ", h("a", { key: '3284183f9e362476c5c57898c33f235661ed440d', target: "_blank", href: "https://biel.ai" }, "biel.ai"))))), h("div", { key: '58184f21aa31d6b40ba7912d8ff7c21272c0c208', class: "biel-header__icons" }, !this.hideExpandButton && (h("button", { key: 'd558d51c22f5b97213c388a399f9c01eb221d0ab', class: "biel-header__icon", onClick: () => this.handleFullscreenClick() }, this.isFullscreen ? (h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "lucide lucide-minimize-2" }, h("polyline", { points: "4 14 10 14 10 20" }), h("polyline", { points: "20 10 14 10 14 4" }), h("line", { x1: "14", x2: "21", y1: "10", y2: "3" }), h("line", { x1: "3", x2: "10", y1: "21", y2: "14" }))) : (h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "lucide lucide-maximize-2" }, h("polyline", { points: "15 3 21 3 21 9" }), h("polyline", { points: "9 21 3 21 3 15" }), h("line", { x1: "21", x2: "14", y1: "3", y2: "10" }), h("line", { x1: "3", x2: "10", y1: "21", y2: "14" }))))), h("button", { key: 'a87adae083905bec2393deae62b9c1894569ba4e', class: "biel-header__icon", onClick: () => this.handleCloseClick() }, h("svg", { key: '0ea2cec29cb0dfc2f46d4e48af6db5d6f5e2ee16', xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "lucide lucide-x" }, h("path", { key: '71a85b7436d3fb748be3834b2e8020e52ddc41aa', d: "M18 6 6 18" }), h("path", { key: '24f0bf0230162dabc784c3f591345f4a20351dfb', d: "m6 6 12 12" }))))));
|
|
32
29
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"headerTitle": [1, "header-title"],
|
|
36
|
-
"project": [1],
|
|
37
|
-
"hideExpandButton": [4, "hide-expand-button"],
|
|
38
|
-
"showPoweredBy": [4, "show-powered-by"],
|
|
39
|
-
"fullscreen": [4],
|
|
40
|
-
"isFullscreen": [32]
|
|
41
|
-
}]);
|
|
42
|
-
function defineCustomElement() {
|
|
43
|
-
if (typeof customElements === "undefined") {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const components = ["biel-header"];
|
|
47
|
-
components.forEach(tagName => { switch (tagName) {
|
|
48
|
-
case "biel-header":
|
|
49
|
-
if (!customElements.get(tagName)) {
|
|
50
|
-
customElements.define(tagName, BielHeader);
|
|
51
|
-
}
|
|
52
|
-
break;
|
|
53
|
-
} });
|
|
54
|
-
}
|
|
55
|
-
defineCustomElement();
|
|
30
|
+
};
|
|
31
|
+
BielHeader.style = bielHeaderCss;
|
|
56
32
|
|
|
57
|
-
export { BielHeader as
|
|
33
|
+
export { BielHeader as biel_header };
|
|
58
34
|
|
|
59
|
-
//# sourceMappingURL=
|
|
35
|
+
//# sourceMappingURL=biel-header.entry.js.map
|