@masterteam/faris 0.0.1
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/assets/faris.css +2 -0
- package/assets/i18n/ar.json +21 -0
- package/assets/i18n/en.json +21 -0
- package/fesm2022/masterteam-faris.mjs +1932 -0
- package/fesm2022/masterteam-faris.mjs.map +1 -0
- package/package.json +48 -0
- package/types/masterteam-faris.d.ts +115 -0
|
@@ -0,0 +1,1932 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Pipe, Injectable, EventEmitter, Output, Input, Component, ViewContainerRef, forwardRef, ViewChild } from '@angular/core';
|
|
3
|
+
import { Button } from '@masterteam/components/button';
|
|
4
|
+
import { ConfirmationService } from '@masterteam/components/confirmation';
|
|
5
|
+
import { BehaviorSubject, of, EMPTY, Subject, Subscription } from 'rxjs';
|
|
6
|
+
import { DomSanitizer } from '@angular/platform-browser';
|
|
7
|
+
import { TranslocoService } from '@jsverse/transloco';
|
|
8
|
+
import { HttpContext, HttpClient } from '@angular/common/http';
|
|
9
|
+
import { Router, NavigationEnd } from '@angular/router';
|
|
10
|
+
import { REQUEST_CONTEXT } from '@masterteam/components';
|
|
11
|
+
import { ToastService } from '@masterteam/components/toast';
|
|
12
|
+
import { filter, map, tap, finalize, debounceTime, switchMap, catchError, takeUntil } from 'rxjs/operators';
|
|
13
|
+
import * as i1 from '@angular/forms';
|
|
14
|
+
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
|
|
15
|
+
import { Overlay } from '@angular/cdk/overlay';
|
|
16
|
+
import { ComponentPortal } from '@angular/cdk/portal';
|
|
17
|
+
import { Icon } from '@masterteam/icons';
|
|
18
|
+
import { DOCUMENT } from '@angular/common';
|
|
19
|
+
import { trigger, transition, style, animate } from '@angular/animations';
|
|
20
|
+
|
|
21
|
+
class FarisTranslatePipe {
|
|
22
|
+
transloco = inject(TranslocoService);
|
|
23
|
+
transform(key, params) {
|
|
24
|
+
if (!key) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
return this.transloco.translate(key, params);
|
|
28
|
+
}
|
|
29
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisTranslatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
30
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.0.3", ngImport: i0, type: FarisTranslatePipe, isStandalone: true, name: "translate", pure: false });
|
|
31
|
+
}
|
|
32
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisTranslatePipe, decorators: [{
|
|
33
|
+
type: Pipe,
|
|
34
|
+
args: [{
|
|
35
|
+
name: 'translate',
|
|
36
|
+
standalone: true,
|
|
37
|
+
pure: false,
|
|
38
|
+
}]
|
|
39
|
+
}] });
|
|
40
|
+
|
|
41
|
+
function normalizeAuthUser(rawUser) {
|
|
42
|
+
if (!rawUser || typeof rawUser !== 'object') {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const details = rawUser?.user ?? rawUser?.data?.user ?? rawUser;
|
|
46
|
+
const resolvedId = details?.id ??
|
|
47
|
+
details?.userId ??
|
|
48
|
+
details?.user_id ??
|
|
49
|
+
rawUser?.id ??
|
|
50
|
+
rawUser?.userId ??
|
|
51
|
+
rawUser?.user_id ??
|
|
52
|
+
'';
|
|
53
|
+
const resolvedDisplayName = details?.displayName ??
|
|
54
|
+
details?.name ??
|
|
55
|
+
details?.userName ??
|
|
56
|
+
details?.username ??
|
|
57
|
+
'';
|
|
58
|
+
const resolvedPhoto = details?.photo ?? details?.image ?? null;
|
|
59
|
+
return {
|
|
60
|
+
...rawUser,
|
|
61
|
+
user: {
|
|
62
|
+
...details,
|
|
63
|
+
id: resolvedId ? String(resolvedId) : '',
|
|
64
|
+
displayName: resolvedDisplayName,
|
|
65
|
+
photo: resolvedPhoto,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function resolveFarisAuthFromLocalStorage() {
|
|
70
|
+
try {
|
|
71
|
+
const raw = localStorage.getItem('auth');
|
|
72
|
+
if (!raw) {
|
|
73
|
+
return { user: null, token: '' };
|
|
74
|
+
}
|
|
75
|
+
const parsed = JSON.parse(raw);
|
|
76
|
+
const user = normalizeAuthUser(parsed?.user ?? parsed ?? null);
|
|
77
|
+
const token = (typeof parsed?.token === 'string' && parsed.token) ||
|
|
78
|
+
(typeof parsed?.accessToken === 'string' && parsed.accessToken) ||
|
|
79
|
+
(typeof user?.token === 'string' && user.token) ||
|
|
80
|
+
(typeof user?.accessToken === 'string' && user.accessToken) ||
|
|
81
|
+
(typeof user?.data?.token === 'string' && user.data.token) ||
|
|
82
|
+
'';
|
|
83
|
+
return { user, token };
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return { user: null, token: '' };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const DEFAULT_FARIS_URL = 'http://34.166.126.184:8004/';
|
|
91
|
+
function resolveFarisUrlFromLocalStorage(fallbackUrl = DEFAULT_FARIS_URL) {
|
|
92
|
+
const directValue = localStorage.getItem('farisUrl');
|
|
93
|
+
if (directValue?.trim()) {
|
|
94
|
+
return directValue;
|
|
95
|
+
}
|
|
96
|
+
const configValue = localStorage.getItem('config');
|
|
97
|
+
if (!configValue) {
|
|
98
|
+
return fallbackUrl;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
const parsed = JSON.parse(configValue);
|
|
102
|
+
const farisApiUrl = parsed?.config?.farisApiUrl ||
|
|
103
|
+
parsed?.config?.basicConfig?.farisApiUrl ||
|
|
104
|
+
parsed?.farisApiUrl ||
|
|
105
|
+
parsed?.basicConfig?.farisApiUrl;
|
|
106
|
+
if (typeof farisApiUrl === 'string' && farisApiUrl.trim()) {
|
|
107
|
+
return farisApiUrl;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// ignore parse errors and use fallback
|
|
112
|
+
}
|
|
113
|
+
return fallbackUrl;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
class FarisService {
|
|
117
|
+
sessionId = null;
|
|
118
|
+
baseUrl = '';
|
|
119
|
+
requestContext = new HttpContext().set(REQUEST_CONTEXT, {
|
|
120
|
+
useBaseUrl: false,
|
|
121
|
+
});
|
|
122
|
+
activeLevelMenuItem = '';
|
|
123
|
+
activeModuleId = null;
|
|
124
|
+
mySpaceActiveTab = '';
|
|
125
|
+
kpiTemplateId = '';
|
|
126
|
+
kpiSchemaId = '';
|
|
127
|
+
initiativesTemplateId = '';
|
|
128
|
+
initiativesSchemaId = '';
|
|
129
|
+
strategyTemplateId = '';
|
|
130
|
+
conversations = new BehaviorSubject([]);
|
|
131
|
+
http = inject(HttpClient);
|
|
132
|
+
toast = inject(ToastService);
|
|
133
|
+
router = inject(Router, { optional: true });
|
|
134
|
+
constructor() {
|
|
135
|
+
const farisUrl = resolveFarisUrlFromLocalStorage();
|
|
136
|
+
this.baseUrl = this.normalizeBaseUrl(farisUrl);
|
|
137
|
+
if (this.router) {
|
|
138
|
+
this.subscribeToRouterChanges();
|
|
139
|
+
this.fillValuesFromRoute(this.router.routerState.snapshot.url);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
get currentUser() {
|
|
143
|
+
return resolveFarisAuthFromLocalStorage().user;
|
|
144
|
+
}
|
|
145
|
+
get currentToken() {
|
|
146
|
+
const localStorageToken = resolveFarisAuthFromLocalStorage().token;
|
|
147
|
+
if (localStorageToken) {
|
|
148
|
+
return localStorageToken;
|
|
149
|
+
}
|
|
150
|
+
return this.currentUser?.token ?? '';
|
|
151
|
+
}
|
|
152
|
+
get currentUserId() {
|
|
153
|
+
const details = this.resolveCurrentUserDetails();
|
|
154
|
+
const resolvedId = details?.id ??
|
|
155
|
+
details?.userId ??
|
|
156
|
+
details?.user_id ??
|
|
157
|
+
this.currentUser?.id ??
|
|
158
|
+
this.currentUser?.userId ??
|
|
159
|
+
this.currentUser?.user_id;
|
|
160
|
+
return resolvedId == null ? '' : String(resolvedId);
|
|
161
|
+
}
|
|
162
|
+
get currentUserName() {
|
|
163
|
+
const details = this.resolveCurrentUserDetails();
|
|
164
|
+
return (details?.displayName ??
|
|
165
|
+
details?.name ??
|
|
166
|
+
details?.userName ??
|
|
167
|
+
details?.username ??
|
|
168
|
+
'');
|
|
169
|
+
}
|
|
170
|
+
normalizeBaseUrl(url) {
|
|
171
|
+
return url.endsWith('/') ? url.slice(0, -1) : url;
|
|
172
|
+
}
|
|
173
|
+
subscribeToRouterChanges() {
|
|
174
|
+
if (!this.router) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
this.router.events
|
|
178
|
+
.pipe(filter((event) => event instanceof NavigationEnd))
|
|
179
|
+
.subscribe((event) => {
|
|
180
|
+
this.fillValuesFromRoute(event.urlAfterRedirects);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
fillValuesFromRoute(currentUrl) {
|
|
184
|
+
this.mySpaceActiveTab = '';
|
|
185
|
+
this.kpiTemplateId = '';
|
|
186
|
+
this.kpiSchemaId = '';
|
|
187
|
+
this.initiativesTemplateId = '';
|
|
188
|
+
this.initiativesSchemaId = '';
|
|
189
|
+
this.strategyTemplateId = '';
|
|
190
|
+
if (currentUrl.includes('/tasks-center')) {
|
|
191
|
+
this.getMySpaceValuesFromUrl(currentUrl);
|
|
192
|
+
}
|
|
193
|
+
if (currentUrl.includes('/kpis')) {
|
|
194
|
+
this.getKpisValuesFromUrl(currentUrl);
|
|
195
|
+
}
|
|
196
|
+
if (currentUrl.includes('/initiatives')) {
|
|
197
|
+
this.getInitiativesValuesFromUrl(currentUrl);
|
|
198
|
+
}
|
|
199
|
+
if (currentUrl.includes('/strategy')) {
|
|
200
|
+
this.getStrategyValuesFromUrl(currentUrl);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
getLevelValuesFromUrl(currentUrl) {
|
|
204
|
+
const splitUrl = currentUrl.split('/');
|
|
205
|
+
const thirdSegment = splitUrl[3];
|
|
206
|
+
const fourthSegment = splitUrl[4];
|
|
207
|
+
this.activeLevelMenuItem = thirdSegment?.includes('?')
|
|
208
|
+
? thirdSegment.split('?')[0]
|
|
209
|
+
: thirdSegment;
|
|
210
|
+
this.activeModuleId = Number.isNaN(Number(fourthSegment))
|
|
211
|
+
? null
|
|
212
|
+
: fourthSegment;
|
|
213
|
+
if (splitUrl.includes('log')) {
|
|
214
|
+
const index = splitUrl.findIndex((item) => item === 'log');
|
|
215
|
+
this.activeLevelMenuItem = '';
|
|
216
|
+
for (let i = index; i < splitUrl.length; i += 1) {
|
|
217
|
+
this.activeLevelMenuItem += `${splitUrl[i]}${i === splitUrl.length - 1 ? '' : '/'}`;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
getMySpaceValuesFromUrl(currentUrl) {
|
|
222
|
+
const splitUrl = currentUrl.split('/');
|
|
223
|
+
if (splitUrl[2]) {
|
|
224
|
+
this.mySpaceActiveTab = splitUrl[2].includes('?')
|
|
225
|
+
? splitUrl[2].split('?')[0]
|
|
226
|
+
: splitUrl[2];
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
getKpisValuesFromUrl(currentUrl) {
|
|
230
|
+
const splitUrl = currentUrl.split('/');
|
|
231
|
+
if (splitUrl[3]) {
|
|
232
|
+
this.kpiTemplateId = splitUrl[2].includes('?')
|
|
233
|
+
? splitUrl[2].split('?')[0]
|
|
234
|
+
: splitUrl[2];
|
|
235
|
+
this.kpiSchemaId = splitUrl[3].includes('?')
|
|
236
|
+
? splitUrl[3].split('?')[0]
|
|
237
|
+
: splitUrl[3];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
getInitiativesValuesFromUrl(currentUrl) {
|
|
241
|
+
const splitUrl = currentUrl.split('/');
|
|
242
|
+
if (splitUrl[3]) {
|
|
243
|
+
this.initiativesTemplateId = splitUrl[2].includes('?')
|
|
244
|
+
? splitUrl[2].split('?')[0]
|
|
245
|
+
: splitUrl[2];
|
|
246
|
+
this.initiativesSchemaId = splitUrl[3].includes('?')
|
|
247
|
+
? splitUrl[3].split('?')[0]
|
|
248
|
+
: splitUrl[3];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
getStrategyValuesFromUrl(currentUrl) {
|
|
252
|
+
const splitUrl = currentUrl.split('/');
|
|
253
|
+
if (splitUrl[3]) {
|
|
254
|
+
this.strategyTemplateId = splitUrl[2].includes('?')
|
|
255
|
+
? splitUrl[2].split('?')[0]
|
|
256
|
+
: splitUrl[2];
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
extractCanvasJson(markdown) {
|
|
260
|
+
if (!markdown) {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
const regex = /```canvas\s*([\s\S]*?)\s*```/;
|
|
264
|
+
const match = markdown.match(regex);
|
|
265
|
+
if (!match?.[1]) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
return JSON.parse(match[1].trim());
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
generateIframUrl(message, conversationId) {
|
|
276
|
+
const canvasJson = this.extractCanvasJson(message?.content);
|
|
277
|
+
if (!canvasJson) {
|
|
278
|
+
return '';
|
|
279
|
+
}
|
|
280
|
+
switch (canvasJson.agent) {
|
|
281
|
+
case 'kpi-data-agent':
|
|
282
|
+
return `${this.baseUrl}/agents/quality-guard?id=${canvasJson?.payload?.id}&name=${canvasJson?.payload?.name}&description=${canvasJson?.payload?.description}&session_id=${conversationId}&auth_token=${this.currentToken}&router_message_id=${message?.message_id}`;
|
|
283
|
+
case 'kpi-benchmark-agent':
|
|
284
|
+
return `${this.baseUrl}/agents/benchmarking-agent?id=${canvasJson?.payload?.id}&name=${canvasJson?.payload?.name}&session_id=${conversationId}&auth_token=${this.currentToken}&router_message_id=${message?.message_id}`;
|
|
285
|
+
case 'kpi-summary-agent':
|
|
286
|
+
return `${this.baseUrl}/agents/executive-summary?id=${canvasJson?.payload?.id}&name=${canvasJson?.payload?.name}&session_id=${conversationId}&auth_token=${this.currentToken}&router_message_id=${message?.message_id}`;
|
|
287
|
+
default:
|
|
288
|
+
return '';
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
sendMessage(message) {
|
|
292
|
+
const url = `${this.baseUrl}/chat`;
|
|
293
|
+
const body = {
|
|
294
|
+
user_message: message,
|
|
295
|
+
session_id: this.sessionId,
|
|
296
|
+
user_name: this.currentUserName,
|
|
297
|
+
user_id: this.currentUserId,
|
|
298
|
+
current_view: this.buildCurrentView(),
|
|
299
|
+
};
|
|
300
|
+
return this.http.post(url, body, { context: this.requestContext }).pipe(map((res) => {
|
|
301
|
+
if (res?.data && typeof res.data === 'object') {
|
|
302
|
+
return {
|
|
303
|
+
...res,
|
|
304
|
+
...res.data,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return res;
|
|
308
|
+
}), tap((res) => {
|
|
309
|
+
if (res?.session_id) {
|
|
310
|
+
this.sessionId = res.session_id;
|
|
311
|
+
setTimeout(() => {
|
|
312
|
+
this.getUserDetails().subscribe();
|
|
313
|
+
}, 150);
|
|
314
|
+
}
|
|
315
|
+
}));
|
|
316
|
+
}
|
|
317
|
+
clearSession() {
|
|
318
|
+
this.sessionId = null;
|
|
319
|
+
}
|
|
320
|
+
getUserDetails() {
|
|
321
|
+
if (!this.currentUserId) {
|
|
322
|
+
this.conversations.next([]);
|
|
323
|
+
return of({ conversations: [] });
|
|
324
|
+
}
|
|
325
|
+
const url = `${this.baseUrl}/users/${this.currentUserId}`;
|
|
326
|
+
return this.http.get(url, { context: this.requestContext }).pipe(map((res) => {
|
|
327
|
+
const conversations = this.resolveConversationsPayload(res).map((conversation) => this.normalizeConversation(conversation));
|
|
328
|
+
return { conversations };
|
|
329
|
+
}), tap((res) => {
|
|
330
|
+
this.conversations.next(res.conversations);
|
|
331
|
+
}));
|
|
332
|
+
}
|
|
333
|
+
getConversationDetails(sessionId) {
|
|
334
|
+
this.sessionId = sessionId;
|
|
335
|
+
const url = `${this.baseUrl}/conversations/${sessionId}`;
|
|
336
|
+
return this.http
|
|
337
|
+
.get(url, { context: this.requestContext })
|
|
338
|
+
.pipe(map((res) => this.resolveConversationMessagesPayload(res).map((item) => this.normalizeConversationMessage(item))));
|
|
339
|
+
}
|
|
340
|
+
deleteConversation(sessionId) {
|
|
341
|
+
const url = `${this.baseUrl}/conversations/${sessionId}`;
|
|
342
|
+
return this.http.delete(url, { context: this.requestContext });
|
|
343
|
+
}
|
|
344
|
+
copyToClipboard(content) {
|
|
345
|
+
if (!content || typeof content !== 'string') {
|
|
346
|
+
this.toast.error('Failed to copy content');
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
navigator.clipboard
|
|
350
|
+
.writeText(content)
|
|
351
|
+
.then(() => {
|
|
352
|
+
this.toast.success('Content copied to clipboard');
|
|
353
|
+
})
|
|
354
|
+
.catch(() => {
|
|
355
|
+
this.toast.error('Failed to copy content');
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
downloadDocument(item) {
|
|
359
|
+
const url = `${this.baseUrl}/download-docx/${item.message_id}`;
|
|
360
|
+
return this.http
|
|
361
|
+
.get(url, { responseType: 'blob', context: this.requestContext })
|
|
362
|
+
.pipe(tap((res) => {
|
|
363
|
+
const blobUrl = window.URL.createObjectURL(res);
|
|
364
|
+
const link = document.createElement('a');
|
|
365
|
+
link.href = blobUrl;
|
|
366
|
+
link.download = `faris-response-${item.message_id}.docx`;
|
|
367
|
+
document.body.appendChild(link);
|
|
368
|
+
link.click();
|
|
369
|
+
document.body.removeChild(link);
|
|
370
|
+
window.URL.revokeObjectURL(blobUrl);
|
|
371
|
+
}));
|
|
372
|
+
}
|
|
373
|
+
sendFeedback(messageId, score, traceId, feedback) {
|
|
374
|
+
if (!this.sessionId) {
|
|
375
|
+
return EMPTY;
|
|
376
|
+
}
|
|
377
|
+
const url = `${this.baseUrl}/feedback`;
|
|
378
|
+
const body = {
|
|
379
|
+
session_id: this.sessionId,
|
|
380
|
+
message_id: messageId,
|
|
381
|
+
score,
|
|
382
|
+
trace_id: traceId,
|
|
383
|
+
feedback,
|
|
384
|
+
};
|
|
385
|
+
return this.http.post(url, body, { context: this.requestContext }).pipe(tap(() => {
|
|
386
|
+
this.getUserDetails().subscribe();
|
|
387
|
+
}));
|
|
388
|
+
}
|
|
389
|
+
generate() {
|
|
390
|
+
return this.generator();
|
|
391
|
+
}
|
|
392
|
+
buildCurrentView() {
|
|
393
|
+
let currentView = { page: 'Home' };
|
|
394
|
+
if (this.mySpaceActiveTab) {
|
|
395
|
+
currentView = {
|
|
396
|
+
page: 'tasks-center',
|
|
397
|
+
Module: this.mySpaceActiveTab === 'Support'
|
|
398
|
+
? 'escalation'
|
|
399
|
+
: this.mySpaceActiveTab.toLowerCase(),
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
if (this.kpiSchemaId && this.kpiTemplateId) {
|
|
403
|
+
currentView = {
|
|
404
|
+
page: 'kpis',
|
|
405
|
+
schemaId: this.kpiSchemaId,
|
|
406
|
+
templateId: this.kpiTemplateId,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
if (this.initiativesTemplateId && this.initiativesSchemaId) {
|
|
410
|
+
currentView = {
|
|
411
|
+
page: 'initiatives',
|
|
412
|
+
schemaId: this.initiativesSchemaId,
|
|
413
|
+
templateId: this.initiativesTemplateId,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
if (this.strategyTemplateId) {
|
|
417
|
+
currentView = {
|
|
418
|
+
page: 'strategy',
|
|
419
|
+
templateId: this.strategyTemplateId,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
if (this.activeModuleId) {
|
|
423
|
+
currentView['ModuleId'] = this.activeModuleId;
|
|
424
|
+
}
|
|
425
|
+
return currentView;
|
|
426
|
+
}
|
|
427
|
+
resolveCurrentUserDetails() {
|
|
428
|
+
const user = this.currentUser;
|
|
429
|
+
return user?.user ?? user?.data?.user ?? user ?? null;
|
|
430
|
+
}
|
|
431
|
+
resolveConversationsPayload(res) {
|
|
432
|
+
const candidates = [
|
|
433
|
+
res,
|
|
434
|
+
res?.conversations,
|
|
435
|
+
res?.data?.conversations,
|
|
436
|
+
res?.data?.items,
|
|
437
|
+
res?.data,
|
|
438
|
+
res?.result?.conversations,
|
|
439
|
+
res?.result,
|
|
440
|
+
res?.payload?.conversations,
|
|
441
|
+
res?.payload,
|
|
442
|
+
];
|
|
443
|
+
for (const candidate of candidates) {
|
|
444
|
+
if (Array.isArray(candidate)) {
|
|
445
|
+
return candidate;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return [];
|
|
449
|
+
}
|
|
450
|
+
normalizeConversation(conversation) {
|
|
451
|
+
const resolvedId = conversation?.id ??
|
|
452
|
+
conversation?.session_id ??
|
|
453
|
+
conversation?.sessionId ??
|
|
454
|
+
conversation?.conversation_id ??
|
|
455
|
+
conversation?.conversationId;
|
|
456
|
+
const resolvedUpdatedAt = conversation?.updated_at ??
|
|
457
|
+
conversation?.updatedAt ??
|
|
458
|
+
conversation?.last_updated_at ??
|
|
459
|
+
conversation?.lastUpdatedAt ??
|
|
460
|
+
conversation?.created_at ??
|
|
461
|
+
conversation?.createdAt ??
|
|
462
|
+
conversation?.timestamp ??
|
|
463
|
+
conversation?.date ??
|
|
464
|
+
null;
|
|
465
|
+
const resolvedTitle = conversation?.title ??
|
|
466
|
+
conversation?.conversation_title ??
|
|
467
|
+
conversation?.conversationTitle ??
|
|
468
|
+
conversation?.name ??
|
|
469
|
+
conversation?.subject ??
|
|
470
|
+
'';
|
|
471
|
+
return {
|
|
472
|
+
...conversation,
|
|
473
|
+
id: resolvedId == null ? '' : String(resolvedId),
|
|
474
|
+
updated_at: resolvedUpdatedAt,
|
|
475
|
+
title: resolvedTitle,
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
resolveConversationMessagesPayload(res) {
|
|
479
|
+
const candidates = [
|
|
480
|
+
res,
|
|
481
|
+
res?.messages,
|
|
482
|
+
res?.conversation,
|
|
483
|
+
res?.data?.messages,
|
|
484
|
+
res?.data?.conversation,
|
|
485
|
+
res?.data,
|
|
486
|
+
res?.result?.messages,
|
|
487
|
+
res?.result,
|
|
488
|
+
res?.payload?.messages,
|
|
489
|
+
res?.payload,
|
|
490
|
+
];
|
|
491
|
+
for (const candidate of candidates) {
|
|
492
|
+
if (Array.isArray(candidate)) {
|
|
493
|
+
return candidate;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return [];
|
|
497
|
+
}
|
|
498
|
+
normalizeConversationMessage(item) {
|
|
499
|
+
const normalizedRole = this.resolveMessageRole(item);
|
|
500
|
+
return {
|
|
501
|
+
...item,
|
|
502
|
+
role: normalizedRole,
|
|
503
|
+
content: item?.content ?? item?.message ?? item?.text ?? '',
|
|
504
|
+
message_id: item?.message_id ??
|
|
505
|
+
item?.messageId ??
|
|
506
|
+
item?.id ??
|
|
507
|
+
item?.router_message_id,
|
|
508
|
+
trace_id: item?.trace_id ?? item?.traceId,
|
|
509
|
+
score: item?.score ?? null,
|
|
510
|
+
feedback: item?.feedback ?? null,
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
resolveMessageRole(item) {
|
|
514
|
+
const role = item?.role ?? item?.sender ?? item?.messageRole ?? item?.message_role;
|
|
515
|
+
if (role === 'user' || role === 'assistant') {
|
|
516
|
+
return role;
|
|
517
|
+
}
|
|
518
|
+
if (typeof role === 'string') {
|
|
519
|
+
const normalized = role.toLowerCase();
|
|
520
|
+
if (normalized.includes('assistant') ||
|
|
521
|
+
normalized.includes('bot') ||
|
|
522
|
+
normalized.includes('ai') ||
|
|
523
|
+
normalized.includes('system')) {
|
|
524
|
+
return 'assistant';
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (item?.is_user === true || item?.fromUser === true) {
|
|
528
|
+
return 'user';
|
|
529
|
+
}
|
|
530
|
+
return 'assistant';
|
|
531
|
+
}
|
|
532
|
+
generator() {
|
|
533
|
+
return `${this.s4()}${this.s4()}-${this.s4()}-${this.s4()}-${this.s4()}-${this.s4()}${this.s4()}${this.s4()}`;
|
|
534
|
+
}
|
|
535
|
+
s4() {
|
|
536
|
+
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
|
537
|
+
}
|
|
538
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
539
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisService, providedIn: 'root' });
|
|
540
|
+
}
|
|
541
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisService, decorators: [{
|
|
542
|
+
type: Injectable,
|
|
543
|
+
args: [{
|
|
544
|
+
providedIn: 'root',
|
|
545
|
+
}]
|
|
546
|
+
}], ctorParameters: () => [] });
|
|
547
|
+
|
|
548
|
+
class FarisCanvasComponent {
|
|
549
|
+
message = null;
|
|
550
|
+
conversationId = null;
|
|
551
|
+
closed = new EventEmitter();
|
|
552
|
+
loading = true;
|
|
553
|
+
iframeUrl = null;
|
|
554
|
+
farisService = inject(FarisService);
|
|
555
|
+
sanitizer = inject(DomSanitizer);
|
|
556
|
+
ngOnInit() {
|
|
557
|
+
this.setIframeUrl();
|
|
558
|
+
this.loading = true;
|
|
559
|
+
}
|
|
560
|
+
ngOnChanges() {
|
|
561
|
+
this.setIframeUrl();
|
|
562
|
+
this.loading = true;
|
|
563
|
+
}
|
|
564
|
+
onIframeLoad() {
|
|
565
|
+
this.loading = false;
|
|
566
|
+
}
|
|
567
|
+
closeCanvas() {
|
|
568
|
+
this.closed.emit();
|
|
569
|
+
}
|
|
570
|
+
setIframeUrl() {
|
|
571
|
+
const url = this.farisService.generateIframUrl(this.message, this.conversationId);
|
|
572
|
+
this.iframeUrl = url
|
|
573
|
+
? this.sanitizer.bypassSecurityTrustResourceUrl(url)
|
|
574
|
+
: null;
|
|
575
|
+
}
|
|
576
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisCanvasComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
577
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: FarisCanvasComponent, isStandalone: true, selector: "mt-faris-canvas", inputs: { message: "message", conversationId: "conversationId" }, outputs: { closed: "closed" }, usesOnChanges: true, ngImport: i0, template: "@if (iframeUrl) {\r\n <div class=\"faris-canvas-frame\">\r\n <div class=\"faris-canvas-frame-header\">\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.x-close\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn\"\r\n aria-label=\"Close Canvas\"\r\n (click)=\"closeCanvas()\"\r\n ></mt-button>\r\n </div>\r\n\r\n <div class=\"faris-canvas-iframe-container\">\r\n @if (loading) {\r\n <div class=\"iframe-loading\">\r\n <div\r\n class=\"h-6 w-6 animate-spin rounded-full border-2 border-slate-300 border-t-[var(--primary-color)]\"\r\n ></div>\r\n </div>\r\n }\r\n\r\n <iframe\r\n [src]=\"iframeUrl\"\r\n width=\"100%\"\r\n height=\"100vh\"\r\n frameborder=\"0\"\r\n allowfullscreen\r\n (load)=\"onIframeLoad()\"\r\n ></iframe>\r\n </div>\r\n </div>\r\n} @else {\r\n <div class=\"faris-canvas-empty p-4 text-sm text-slate-600\">\r\n {{ \"faris.unable-to-load-content\" | translate }}\r\n </div>\r\n}\r\n", styles: [":host{background-color:#fff;padding:.25em}.faris-canvas-frame{border:2px solid lightgray;border-radius:var(--faris-border-radius);background:#fff;overflow:hidden;position:relative;height:calc(100vh - 1em);display:flex;flex-direction:column}.faris-canvas-frame-header{display:flex;justify-content:flex-end;align-items:center;background:#f7f9fa;border-bottom:1px solid #e0e0e0;padding:.5em 1em;min-height:48px;z-index:10}.faris-canvas-iframe-container{height:100%;width:100%;position:relative;flex:1 1 auto}.faris-canvas-iframe-container .iframe-loading{position:absolute;inset:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;z-index:2;background:#ffffffb3}.faris-canvas-iframe-container iframe{border:none;min-height:400px;height:100%;width:100%;display:block}.faris-canvas-iframe-container .spinner-border{width:1.25em;height:1.25em}\n"], dependencies: [{ kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "pipe", type: FarisTranslatePipe, name: "translate" }] });
|
|
578
|
+
}
|
|
579
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisCanvasComponent, decorators: [{
|
|
580
|
+
type: Component,
|
|
581
|
+
args: [{ selector: 'mt-faris-canvas', standalone: true, imports: [FarisTranslatePipe, Button], template: "@if (iframeUrl) {\r\n <div class=\"faris-canvas-frame\">\r\n <div class=\"faris-canvas-frame-header\">\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.x-close\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn\"\r\n aria-label=\"Close Canvas\"\r\n (click)=\"closeCanvas()\"\r\n ></mt-button>\r\n </div>\r\n\r\n <div class=\"faris-canvas-iframe-container\">\r\n @if (loading) {\r\n <div class=\"iframe-loading\">\r\n <div\r\n class=\"h-6 w-6 animate-spin rounded-full border-2 border-slate-300 border-t-[var(--primary-color)]\"\r\n ></div>\r\n </div>\r\n }\r\n\r\n <iframe\r\n [src]=\"iframeUrl\"\r\n width=\"100%\"\r\n height=\"100vh\"\r\n frameborder=\"0\"\r\n allowfullscreen\r\n (load)=\"onIframeLoad()\"\r\n ></iframe>\r\n </div>\r\n </div>\r\n} @else {\r\n <div class=\"faris-canvas-empty p-4 text-sm text-slate-600\">\r\n {{ \"faris.unable-to-load-content\" | translate }}\r\n </div>\r\n}\r\n", styles: [":host{background-color:#fff;padding:.25em}.faris-canvas-frame{border:2px solid lightgray;border-radius:var(--faris-border-radius);background:#fff;overflow:hidden;position:relative;height:calc(100vh - 1em);display:flex;flex-direction:column}.faris-canvas-frame-header{display:flex;justify-content:flex-end;align-items:center;background:#f7f9fa;border-bottom:1px solid #e0e0e0;padding:.5em 1em;min-height:48px;z-index:10}.faris-canvas-iframe-container{height:100%;width:100%;position:relative;flex:1 1 auto}.faris-canvas-iframe-container .iframe-loading{position:absolute;inset:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;z-index:2;background:#ffffffb3}.faris-canvas-iframe-container iframe{border:none;min-height:400px;height:100%;width:100%;display:block}.faris-canvas-iframe-container .spinner-border{width:1.25em;height:1.25em}\n"] }]
|
|
582
|
+
}], propDecorators: { message: [{
|
|
583
|
+
type: Input
|
|
584
|
+
}], conversationId: [{
|
|
585
|
+
type: Input
|
|
586
|
+
}], closed: [{
|
|
587
|
+
type: Output
|
|
588
|
+
}] } });
|
|
589
|
+
|
|
590
|
+
class AgentCardComponent {
|
|
591
|
+
agent;
|
|
592
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AgentCardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
593
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.3", type: AgentCardComponent, isStandalone: true, selector: "mt-faris-agent-card", inputs: { agent: "agent" }, ngImport: i0, template: "<div\r\n class=\"flex cursor-pointer items-center gap-3 rounded-md border border-slate-200 bg-slate-50 px-2 py-2 transition hover:bg-slate-100\"\r\n [style.border-color]=\"agent?.color || null\"\r\n>\r\n <img\r\n class=\"h-10 w-10 rounded object-contain p-1\"\r\n [src]=\"agent?.icon\"\r\n alt=\"\"\r\n />\r\n <div class=\"text-sm leading-5\">\r\n <strong class=\"block text-slate-900\">{{ agent?.title }}</strong>\r\n <p class=\"m-0 text-slate-600\">{{ agent?.desc }}</p>\r\n </div>\r\n</div>\r\n", styles: [""] });
|
|
594
|
+
}
|
|
595
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AgentCardComponent, decorators: [{
|
|
596
|
+
type: Component,
|
|
597
|
+
args: [{ selector: 'mt-faris-agent-card', standalone: true, template: "<div\r\n class=\"flex cursor-pointer items-center gap-3 rounded-md border border-slate-200 bg-slate-50 px-2 py-2 transition hover:bg-slate-100\"\r\n [style.border-color]=\"agent?.color || null\"\r\n>\r\n <img\r\n class=\"h-10 w-10 rounded object-contain p-1\"\r\n [src]=\"agent?.icon\"\r\n alt=\"\"\r\n />\r\n <div class=\"text-sm leading-5\">\r\n <strong class=\"block text-slate-900\">{{ agent?.title }}</strong>\r\n <p class=\"m-0 text-slate-600\">{{ agent?.desc }}</p>\r\n </div>\r\n</div>\r\n" }]
|
|
598
|
+
}], propDecorators: { agent: [{
|
|
599
|
+
type: Input
|
|
600
|
+
}] } });
|
|
601
|
+
|
|
602
|
+
class FarisMarkdownPipe {
|
|
603
|
+
sanitizer = inject(DomSanitizer);
|
|
604
|
+
transform(value) {
|
|
605
|
+
const source = this.toStringValue(value);
|
|
606
|
+
if (!source) {
|
|
607
|
+
return '';
|
|
608
|
+
}
|
|
609
|
+
const escaped = this.escapeHtml(source).replace(/\r\n/g, '\n');
|
|
610
|
+
const html = this.toHtml(escaped);
|
|
611
|
+
return this.sanitizer.bypassSecurityTrustHtml(html);
|
|
612
|
+
}
|
|
613
|
+
toHtml(content) {
|
|
614
|
+
let html = content;
|
|
615
|
+
html = html.replace(/```canvas\s*[\s\S]*?```/gi, '');
|
|
616
|
+
html = html.replace(/```chart\s*([\s\S]*?)```/gi, (_match, code) => {
|
|
617
|
+
const payload = encodeURIComponent(code.trim());
|
|
618
|
+
return `<div class="chart-placeholder" data-options="${payload}"></div>`;
|
|
619
|
+
});
|
|
620
|
+
html = html.replace(/```([a-zA-Z0-9_-]+)?\s*([\s\S]*?)```/g, (_match, lang, code) => `<pre class="faris-code"><code class="language-${lang ?? 'plain'}">${code.trim()}</code></pre>`);
|
|
621
|
+
html = html.replace(/^###\s+(.+)$/gm, '<h3>$1</h3>');
|
|
622
|
+
html = html.replace(/^##\s+(.+)$/gm, '<h2>$1</h2>');
|
|
623
|
+
html = html.replace(/^#\s+(.+)$/gm, '<h1>$1</h1>');
|
|
624
|
+
html = html.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>');
|
|
625
|
+
html = html.replace(/`([^`]+)`/g, '<code>$1</code>');
|
|
626
|
+
html = html.replace(/\[(.+?)\]\((https?:\/\/[^\s)]+)\)/g, '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>');
|
|
627
|
+
return html.replace(/\n/g, '<br>');
|
|
628
|
+
}
|
|
629
|
+
toStringValue(value) {
|
|
630
|
+
if (typeof value === 'string') {
|
|
631
|
+
return value;
|
|
632
|
+
}
|
|
633
|
+
if (value == null) {
|
|
634
|
+
return '';
|
|
635
|
+
}
|
|
636
|
+
try {
|
|
637
|
+
return JSON.stringify(value, null, 2);
|
|
638
|
+
}
|
|
639
|
+
catch {
|
|
640
|
+
return String(value);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
escapeHtml(content) {
|
|
644
|
+
return content
|
|
645
|
+
.replace(/&/g, '&')
|
|
646
|
+
.replace(/</g, '<')
|
|
647
|
+
.replace(/>/g, '>')
|
|
648
|
+
.replace(/"/g, '"')
|
|
649
|
+
.replace(/'/g, ''');
|
|
650
|
+
}
|
|
651
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisMarkdownPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
652
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.0.3", ngImport: i0, type: FarisMarkdownPipe, isStandalone: true, name: "farisMarkdown" });
|
|
653
|
+
}
|
|
654
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisMarkdownPipe, decorators: [{
|
|
655
|
+
type: Pipe,
|
|
656
|
+
args: [{
|
|
657
|
+
name: 'farisMarkdown',
|
|
658
|
+
standalone: true,
|
|
659
|
+
}]
|
|
660
|
+
}] });
|
|
661
|
+
|
|
662
|
+
class FarisMessageActionsComponent {
|
|
663
|
+
currentVote = null;
|
|
664
|
+
canvasMessage = false;
|
|
665
|
+
downloading = false;
|
|
666
|
+
action = new EventEmitter();
|
|
667
|
+
emitAction(action) {
|
|
668
|
+
this.action.emit(action);
|
|
669
|
+
}
|
|
670
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisMessageActionsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
671
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: FarisMessageActionsComponent, isStandalone: true, selector: "mt-faris-message-actions", inputs: { currentVote: "currentVote", canvasMessage: "canvasMessage", downloading: "downloading" }, outputs: { action: "action" }, ngImport: i0, template: "<div class=\"feedback-controls mt-3 flex items-center gap-1\">\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.copy-01\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn faris-btn-muted\"\r\n [tooltip]=\"'faris.copy-response' | translate\"\r\n (click)=\"emitAction('copy')\"\r\n ></mt-button>\r\n\r\n @if (!canvasMessage) {\r\n <mt-button\r\n type=\"button\"\r\n icon=\"file.file-plus-01\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn faris-btn-muted\"\r\n [loading]=\"downloading\"\r\n [tooltip]=\"'faris.create-document' | translate\"\r\n (click)=\"emitAction('download')\"\r\n ></mt-button>\r\n }\r\n\r\n <mt-button\r\n type=\"button\"\r\n icon=\"arrow.refresh-cw-01\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn faris-btn-muted\"\r\n [tooltip]=\"'faris.retry-response' | translate\"\r\n (click)=\"emitAction('retry')\"\r\n ></mt-button>\r\n\r\n <div class=\"feedback-separator mx-1 h-6 w-px bg-black/10\"></div>\r\n\r\n <mt-button\r\n type=\"button\"\r\n icon=\"alert.thumbs-up\"\r\n variant=\"text\"\r\n [styleClass]=\"\r\n 'faris-btn faris-btn-muted like' +\r\n (currentVote === 'like' ? ' text-green-600' : '')\r\n \"\r\n [tooltip]=\"'faris.helpful' | translate\"\r\n (click)=\"emitAction('like')\"\r\n ></mt-button>\r\n\r\n <mt-button\r\n type=\"button\"\r\n icon=\"alert.thumbs-down\"\r\n variant=\"text\"\r\n [styleClass]=\"\r\n 'faris-btn faris-btn-muted dislike' +\r\n (currentVote === 'dislike' ? ' text-red-600' : '')\r\n \"\r\n [tooltip]=\"'faris.not-helpful' | translate\"\r\n (click)=\"emitAction('dislike')\"\r\n ></mt-button>\r\n</div>\r\n", styles: [".feedback-controls{display:flex;align-items:center;margin-top:.75em;gap:.25em}.faris-btn.like:hover{background-color:rgb(from var(--success) r g b / 10%)}.faris-btn.dislike:hover{background-color:rgb(from var(--danger) r g b / 10%)}.feedback-separator{width:1px;height:1.5em;background-color:#0000001a;margin:0 .25em}\n"], dependencies: [{ kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "pipe", type: FarisTranslatePipe, name: "translate" }] });
|
|
672
|
+
}
|
|
673
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisMessageActionsComponent, decorators: [{
|
|
674
|
+
type: Component,
|
|
675
|
+
args: [{ selector: 'mt-faris-message-actions', standalone: true, imports: [FarisTranslatePipe, Button], template: "<div class=\"feedback-controls mt-3 flex items-center gap-1\">\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.copy-01\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn faris-btn-muted\"\r\n [tooltip]=\"'faris.copy-response' | translate\"\r\n (click)=\"emitAction('copy')\"\r\n ></mt-button>\r\n\r\n @if (!canvasMessage) {\r\n <mt-button\r\n type=\"button\"\r\n icon=\"file.file-plus-01\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn faris-btn-muted\"\r\n [loading]=\"downloading\"\r\n [tooltip]=\"'faris.create-document' | translate\"\r\n (click)=\"emitAction('download')\"\r\n ></mt-button>\r\n }\r\n\r\n <mt-button\r\n type=\"button\"\r\n icon=\"arrow.refresh-cw-01\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn faris-btn-muted\"\r\n [tooltip]=\"'faris.retry-response' | translate\"\r\n (click)=\"emitAction('retry')\"\r\n ></mt-button>\r\n\r\n <div class=\"feedback-separator mx-1 h-6 w-px bg-black/10\"></div>\r\n\r\n <mt-button\r\n type=\"button\"\r\n icon=\"alert.thumbs-up\"\r\n variant=\"text\"\r\n [styleClass]=\"\r\n 'faris-btn faris-btn-muted like' +\r\n (currentVote === 'like' ? ' text-green-600' : '')\r\n \"\r\n [tooltip]=\"'faris.helpful' | translate\"\r\n (click)=\"emitAction('like')\"\r\n ></mt-button>\r\n\r\n <mt-button\r\n type=\"button\"\r\n icon=\"alert.thumbs-down\"\r\n variant=\"text\"\r\n [styleClass]=\"\r\n 'faris-btn faris-btn-muted dislike' +\r\n (currentVote === 'dislike' ? ' text-red-600' : '')\r\n \"\r\n [tooltip]=\"'faris.not-helpful' | translate\"\r\n (click)=\"emitAction('dislike')\"\r\n ></mt-button>\r\n</div>\r\n", styles: [".feedback-controls{display:flex;align-items:center;margin-top:.75em;gap:.25em}.faris-btn.like:hover{background-color:rgb(from var(--success) r g b / 10%)}.faris-btn.dislike:hover{background-color:rgb(from var(--danger) r g b / 10%)}.feedback-separator{width:1px;height:1.5em;background-color:#0000001a;margin:0 .25em}\n"] }]
|
|
676
|
+
}], propDecorators: { currentVote: [{
|
|
677
|
+
type: Input
|
|
678
|
+
}], canvasMessage: [{
|
|
679
|
+
type: Input
|
|
680
|
+
}], downloading: [{
|
|
681
|
+
type: Input
|
|
682
|
+
}], action: [{
|
|
683
|
+
type: Output
|
|
684
|
+
}] } });
|
|
685
|
+
|
|
686
|
+
class ParseMentionPipe {
|
|
687
|
+
transform(value) {
|
|
688
|
+
if (!value) {
|
|
689
|
+
return '';
|
|
690
|
+
}
|
|
691
|
+
const regex = /@{{({.*?})}}/g;
|
|
692
|
+
return value.replace(regex, (match, jsonString) => {
|
|
693
|
+
try {
|
|
694
|
+
const jsonObject = JSON.parse(jsonString);
|
|
695
|
+
return `@${jsonObject.title}`;
|
|
696
|
+
}
|
|
697
|
+
catch {
|
|
698
|
+
return match;
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: ParseMentionPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
703
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.0.3", ngImport: i0, type: ParseMentionPipe, isStandalone: true, name: "parseMention" });
|
|
704
|
+
}
|
|
705
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: ParseMentionPipe, decorators: [{
|
|
706
|
+
type: Pipe,
|
|
707
|
+
args: [{
|
|
708
|
+
name: 'parseMention',
|
|
709
|
+
standalone: true,
|
|
710
|
+
}]
|
|
711
|
+
}] });
|
|
712
|
+
|
|
713
|
+
class FarisMessageComponent {
|
|
714
|
+
item;
|
|
715
|
+
currentUserPhoto = '';
|
|
716
|
+
loading = false;
|
|
717
|
+
thinkingText = '';
|
|
718
|
+
fallbackUserPhoto = 'data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"40\" height=\"40\" viewBox=\"0 0 40 40\"><circle cx=\"20\" cy=\"20\" r=\"20\" fill=\"%23e2e8f0\"/><circle cx=\"20\" cy=\"15\" r=\"7\" fill=\"%2394a3b8\"/><path d=\"M8 34c2.5-6 7.5-9 12-9s9.5 3 12 9\" fill=\"%2394a3b8\"/></svg>';
|
|
719
|
+
action = new EventEmitter();
|
|
720
|
+
canvas = new EventEmitter();
|
|
721
|
+
canvasMessage = false;
|
|
722
|
+
downloading = false;
|
|
723
|
+
farisService = inject(FarisService);
|
|
724
|
+
ngOnInit() {
|
|
725
|
+
this.canvasMessage = this.resolveContent(this.item?.content).includes('```canvas');
|
|
726
|
+
}
|
|
727
|
+
takeAction(action, item) {
|
|
728
|
+
if (action === 'download') {
|
|
729
|
+
this.downloadDocument(item);
|
|
730
|
+
}
|
|
731
|
+
this.action.emit({ action, item });
|
|
732
|
+
}
|
|
733
|
+
launchCanvas() {
|
|
734
|
+
this.canvas.emit(this.item);
|
|
735
|
+
}
|
|
736
|
+
setFallbackUserPhoto() {
|
|
737
|
+
this.currentUserPhoto = this.fallbackUserPhoto;
|
|
738
|
+
}
|
|
739
|
+
downloadDocument(item) {
|
|
740
|
+
this.downloading = true;
|
|
741
|
+
this.farisService
|
|
742
|
+
.downloadDocument(item)
|
|
743
|
+
.pipe(finalize(() => (this.downloading = false)))
|
|
744
|
+
.subscribe();
|
|
745
|
+
}
|
|
746
|
+
resolveContent(content) {
|
|
747
|
+
if (typeof content === 'string') {
|
|
748
|
+
return content;
|
|
749
|
+
}
|
|
750
|
+
if (content == null) {
|
|
751
|
+
return '';
|
|
752
|
+
}
|
|
753
|
+
try {
|
|
754
|
+
return JSON.stringify(content);
|
|
755
|
+
}
|
|
756
|
+
catch {
|
|
757
|
+
return String(content);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisMessageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
761
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: FarisMessageComponent, isStandalone: true, selector: "mt-faris-message", inputs: { item: "item", currentUserPhoto: "currentUserPhoto", loading: "loading", thinkingText: "thinkingText" }, outputs: { action: "action", canvas: "canvas" }, ngImport: i0, template: "@if (item.role === \"user\") {\r\n <div class=\"faris-message\">\r\n <img\r\n [src]=\"currentUserPhoto || fallbackUserPhoto\"\r\n (error)=\"setFallbackUserPhoto()\"\r\n class=\"rounded-full user-img-md\"\r\n alt=\"\"\r\n />\r\n <div\r\n class=\"result-markdown result-width user\"\r\n [innerHTML]=\"item.content | parseMention | farisMarkdown\"\r\n ></div>\r\n </div>\r\n}\r\n\r\n@if (item.role === \"assistant\") {\r\n <div class=\"faris-message\">\r\n <div class=\"gemini-ic\" [class.thinking]=\"loading && !item.loaded\">\r\n <svg\r\n focusable=\"false\"\r\n viewBox=\"0 -960 960 960\"\r\n height=\"28\"\r\n width=\"28\"\r\n class=\"EiVpKc aoH\"\r\n >\r\n <path\r\n d=\"M480-80q2,0 2-2q0-82 31-154t85-126t126-85t154-31q2,0 2-2t-2-2q-82,0-154-31T598-598T513-724T482-878q0-2-2-2t-2,2q0,82-31,154T362-598T236-513T82-482q-2,0-2,2t2,2q82,0 154,31t126,85t85,126T478-82q0,2 2,2Z\"\r\n ></path>\r\n </svg>\r\n </div>\r\n\r\n <div class=\"flex w-[85%] max-w-[98%] flex-col\">\r\n @if (!loading || item.loaded) {\r\n <div class=\"w-full\">\r\n <div\r\n class=\"result-markdown faris\"\r\n [innerHTML]=\"item.content | farisMarkdown\"\r\n ></div>\r\n\r\n @if (canvasMessage) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"'faris.launch-canvas' | translate\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n styleClass=\"mt-2\"\r\n (click)=\"launchCanvas()\"\r\n ></mt-button>\r\n }\r\n\r\n <mt-faris-message-actions\r\n [downloading]=\"downloading\"\r\n [canvasMessage]=\"canvasMessage\"\r\n [currentVote]=\"\r\n item.feedback === '1'\r\n ? 'like'\r\n : item.feedback === '-1'\r\n ? 'dislike'\r\n : null\r\n \"\r\n (action)=\"takeAction($event, item)\"\r\n >\r\n </mt-faris-message-actions>\r\n </div>\r\n }\r\n\r\n @if (loading && !item.loaded) {\r\n <div class=\"thinking-text\">{{ thinkingText }}</div>\r\n }\r\n </div>\r\n </div>\r\n}\r\n", styles: ["@charset \"UTF-8\";@keyframes thinking-animation{0%{filter:drop-shadow(0 0 2px rgba(74,144,226,.5))}50%{filter:drop-shadow(0 0 8px rgb(123,207,255))}to{filter:drop-shadow(0 0 2px rgba(74,144,226,.5))}}@keyframes thinking-text-animation{0%{background-position:0% 50%}to{background-position:100% 50%}}.faris-message{display:flex;gap:1em}.user-img-md{height:24px;width:24px;object-fit:cover}.result-width{width:85%;max-width:98%}.result-markdown{padding:10px;border-radius:var(--faris-lg-border-radius);overflow-wrap:anywhere}.result-markdown pre.faris-code{margin:8px 0;overflow-x:auto;border-radius:var(--faris-sm-border-radius);background:#f6f8fa;padding:8px}.result-markdown code{border-radius:var(--faris-sm-border-radius);background:#f6f8fa;padding:2px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.85em}.result-markdown h1,.result-markdown h2,.result-markdown h3{margin:10px 0 6px;font-weight:600;line-height:1.3}.result-markdown h1{font-size:1.1em}.result-markdown h2{font-size:1em}.result-markdown h3{font-size:.95em}.result-markdown a{color:var(--primary-color);text-decoration:underline}.result-markdown.user{background-color:var(--primary-color, #e9eef6);color:#fff}.result-markdown.faris{border:1px solid #dfe2e5}::ng-deep .md-table-wrapper{width:100%;overflow-y:auto}::ng-deep .gemini-ic.thinking{animation:thinking-animation 2s infinite}.thinking-text{background:linear-gradient(to right,#a3a3a3 20%,#c3c3c3 30%,#f0f0f0 50%,#f8f8f8,#f0f0f0,#c3c3c3 80%,#a3a3a3);animation:thinking-text-animation 1.5s infinite linear;-webkit-background-clip:text;background-clip:text;background-size:500% auto;color:transparent;font-size:1em}.thinking-text:after{overflow:hidden;display:inline-block;vertical-align:bottom;content:\"\\2026\";color:#f8f8f8;width:0;animation:ellipsis .9s infinite steps(4,end)}@keyframes ellipsis{to{width:1.25em}}\n"], dependencies: [{ kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: FarisMessageActionsComponent, selector: "mt-faris-message-actions", inputs: ["currentVote", "canvasMessage", "downloading"], outputs: ["action"] }, { kind: "pipe", type: ParseMentionPipe, name: "parseMention" }, { kind: "pipe", type: FarisTranslatePipe, name: "translate" }, { kind: "pipe", type: FarisMarkdownPipe, name: "farisMarkdown" }] });
|
|
762
|
+
}
|
|
763
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisMessageComponent, decorators: [{
|
|
764
|
+
type: Component,
|
|
765
|
+
args: [{ selector: 'mt-faris-message', standalone: true, imports: [
|
|
766
|
+
Button,
|
|
767
|
+
ParseMentionPipe,
|
|
768
|
+
FarisTranslatePipe,
|
|
769
|
+
FarisMarkdownPipe,
|
|
770
|
+
FarisMessageActionsComponent,
|
|
771
|
+
], template: "@if (item.role === \"user\") {\r\n <div class=\"faris-message\">\r\n <img\r\n [src]=\"currentUserPhoto || fallbackUserPhoto\"\r\n (error)=\"setFallbackUserPhoto()\"\r\n class=\"rounded-full user-img-md\"\r\n alt=\"\"\r\n />\r\n <div\r\n class=\"result-markdown result-width user\"\r\n [innerHTML]=\"item.content | parseMention | farisMarkdown\"\r\n ></div>\r\n </div>\r\n}\r\n\r\n@if (item.role === \"assistant\") {\r\n <div class=\"faris-message\">\r\n <div class=\"gemini-ic\" [class.thinking]=\"loading && !item.loaded\">\r\n <svg\r\n focusable=\"false\"\r\n viewBox=\"0 -960 960 960\"\r\n height=\"28\"\r\n width=\"28\"\r\n class=\"EiVpKc aoH\"\r\n >\r\n <path\r\n d=\"M480-80q2,0 2-2q0-82 31-154t85-126t126-85t154-31q2,0 2-2t-2-2q-82,0-154-31T598-598T513-724T482-878q0-2-2-2t-2,2q0,82-31,154T362-598T236-513T82-482q-2,0-2,2t2,2q82,0 154,31t126,85t85,126T478-82q0,2 2,2Z\"\r\n ></path>\r\n </svg>\r\n </div>\r\n\r\n <div class=\"flex w-[85%] max-w-[98%] flex-col\">\r\n @if (!loading || item.loaded) {\r\n <div class=\"w-full\">\r\n <div\r\n class=\"result-markdown faris\"\r\n [innerHTML]=\"item.content | farisMarkdown\"\r\n ></div>\r\n\r\n @if (canvasMessage) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"'faris.launch-canvas' | translate\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n styleClass=\"mt-2\"\r\n (click)=\"launchCanvas()\"\r\n ></mt-button>\r\n }\r\n\r\n <mt-faris-message-actions\r\n [downloading]=\"downloading\"\r\n [canvasMessage]=\"canvasMessage\"\r\n [currentVote]=\"\r\n item.feedback === '1'\r\n ? 'like'\r\n : item.feedback === '-1'\r\n ? 'dislike'\r\n : null\r\n \"\r\n (action)=\"takeAction($event, item)\"\r\n >\r\n </mt-faris-message-actions>\r\n </div>\r\n }\r\n\r\n @if (loading && !item.loaded) {\r\n <div class=\"thinking-text\">{{ thinkingText }}</div>\r\n }\r\n </div>\r\n </div>\r\n}\r\n", styles: ["@charset \"UTF-8\";@keyframes thinking-animation{0%{filter:drop-shadow(0 0 2px rgba(74,144,226,.5))}50%{filter:drop-shadow(0 0 8px rgb(123,207,255))}to{filter:drop-shadow(0 0 2px rgba(74,144,226,.5))}}@keyframes thinking-text-animation{0%{background-position:0% 50%}to{background-position:100% 50%}}.faris-message{display:flex;gap:1em}.user-img-md{height:24px;width:24px;object-fit:cover}.result-width{width:85%;max-width:98%}.result-markdown{padding:10px;border-radius:var(--faris-lg-border-radius);overflow-wrap:anywhere}.result-markdown pre.faris-code{margin:8px 0;overflow-x:auto;border-radius:var(--faris-sm-border-radius);background:#f6f8fa;padding:8px}.result-markdown code{border-radius:var(--faris-sm-border-radius);background:#f6f8fa;padding:2px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.85em}.result-markdown h1,.result-markdown h2,.result-markdown h3{margin:10px 0 6px;font-weight:600;line-height:1.3}.result-markdown h1{font-size:1.1em}.result-markdown h2{font-size:1em}.result-markdown h3{font-size:.95em}.result-markdown a{color:var(--primary-color);text-decoration:underline}.result-markdown.user{background-color:var(--primary-color, #e9eef6);color:#fff}.result-markdown.faris{border:1px solid #dfe2e5}::ng-deep .md-table-wrapper{width:100%;overflow-y:auto}::ng-deep .gemini-ic.thinking{animation:thinking-animation 2s infinite}.thinking-text{background:linear-gradient(to right,#a3a3a3 20%,#c3c3c3 30%,#f0f0f0 50%,#f8f8f8,#f0f0f0,#c3c3c3 80%,#a3a3a3);animation:thinking-text-animation 1.5s infinite linear;-webkit-background-clip:text;background-clip:text;background-size:500% auto;color:transparent;font-size:1em}.thinking-text:after{overflow:hidden;display:inline-block;vertical-align:bottom;content:\"\\2026\";color:#f8f8f8;width:0;animation:ellipsis .9s infinite steps(4,end)}@keyframes ellipsis{to{width:1.25em}}\n"] }]
|
|
772
|
+
}], propDecorators: { item: [{
|
|
773
|
+
type: Input
|
|
774
|
+
}], currentUserPhoto: [{
|
|
775
|
+
type: Input
|
|
776
|
+
}], loading: [{
|
|
777
|
+
type: Input
|
|
778
|
+
}], thinkingText: [{
|
|
779
|
+
type: Input
|
|
780
|
+
}], action: [{
|
|
781
|
+
type: Output
|
|
782
|
+
}], canvas: [{
|
|
783
|
+
type: Output
|
|
784
|
+
}] } });
|
|
785
|
+
|
|
786
|
+
class MentionApiService {
|
|
787
|
+
baseUrl = '';
|
|
788
|
+
http = inject(HttpClient);
|
|
789
|
+
constructor() {
|
|
790
|
+
let url = resolveFarisUrlFromLocalStorage();
|
|
791
|
+
if (url.endsWith('/')) {
|
|
792
|
+
url = url.slice(0, -1);
|
|
793
|
+
}
|
|
794
|
+
this.baseUrl = url;
|
|
795
|
+
}
|
|
796
|
+
search(term) {
|
|
797
|
+
return this.http.get(`${this.baseUrl}/search`, {
|
|
798
|
+
params: { query: term },
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MentionApiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
802
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MentionApiService, providedIn: 'root' });
|
|
803
|
+
}
|
|
804
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MentionApiService, decorators: [{
|
|
805
|
+
type: Injectable,
|
|
806
|
+
args: [{ providedIn: 'root' }]
|
|
807
|
+
}], ctorParameters: () => [] });
|
|
808
|
+
|
|
809
|
+
class MentionListComponent {
|
|
810
|
+
items = [];
|
|
811
|
+
loading = false;
|
|
812
|
+
itemSelected = new EventEmitter();
|
|
813
|
+
activeIndex = 0;
|
|
814
|
+
ngOnChanges() {
|
|
815
|
+
this.activeIndex = 0;
|
|
816
|
+
setTimeout(() => this.scrollActiveItemIntoView(), 0);
|
|
817
|
+
}
|
|
818
|
+
onItemClick(event, item) {
|
|
819
|
+
event.preventDefault();
|
|
820
|
+
this.itemSelected.emit(item);
|
|
821
|
+
}
|
|
822
|
+
moveActiveUp() {
|
|
823
|
+
if (!this.items.length) {
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
this.activeIndex =
|
|
827
|
+
(this.activeIndex - 1 + this.items.length) % this.items.length;
|
|
828
|
+
this.scrollActiveItemIntoView();
|
|
829
|
+
}
|
|
830
|
+
moveActiveDown() {
|
|
831
|
+
if (!this.items.length) {
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
this.activeIndex = (this.activeIndex + 1) % this.items.length;
|
|
835
|
+
this.scrollActiveItemIntoView();
|
|
836
|
+
}
|
|
837
|
+
selectActiveItem() {
|
|
838
|
+
if (!this.items.length) {
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
this.itemSelected.emit(this.items[this.activeIndex]);
|
|
842
|
+
}
|
|
843
|
+
scrollActiveItemIntoView() {
|
|
844
|
+
const list = document.querySelector('.mention-list');
|
|
845
|
+
if (!list) {
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
const items = list.querySelectorAll('.mention-item');
|
|
849
|
+
if (!items.length) {
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
const activeItem = items[this.activeIndex];
|
|
853
|
+
activeItem?.scrollIntoView({ block: 'nearest' });
|
|
854
|
+
}
|
|
855
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MentionListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
856
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: MentionListComponent, isStandalone: true, selector: "mt-faris-mention-list", inputs: { items: "items", loading: "loading" }, outputs: { itemSelected: "itemSelected" }, usesOnChanges: true, ngImport: i0, template: "<ul class=\"mention-list\">\r\n @if (loading) {\r\n <li title=\"loading...\">\r\n <div class=\"mention-item skeleton\"> </div>\r\n <div class=\"mention-item skeleton\"> </div>\r\n <div class=\"mention-item skeleton\"> </div>\r\n </li>\r\n }\r\n\r\n @if (!loading && items.length === 0) {\r\n <li class=\"mention-item-empty\">\r\n {{ \"faris.no-results-found\" | translate }}\r\n </li>\r\n }\r\n\r\n @for (item of items; track item.id; let i = $index) {\r\n <li\r\n (mousedown)=\"onItemClick($event, item)\"\r\n class=\"mention-item\"\r\n [class.active]=\"i === activeIndex\"\r\n [hidden]=\"loading\"\r\n >\r\n {{ item.title }}\r\n @if (item.levelType) {\r\n <span class=\"mention-item-type\">({{ item.levelType }})</span>\r\n }\r\n </li>\r\n }\r\n</ul>\r\n", styles: [".mention-list{list-style:none;margin:0;padding:5px;background:#fff;border-radius:var(--faris-border-radius);box-shadow:0 5px 10px #0000001a;max-height:200px;overflow-y:auto;z-index:1503;background-color:#ffffffbf;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}.mention-item{padding:8px 12px;cursor:pointer;border-radius:var(--faris-sm-border-radius)}.mention-item:not(:last-child){margin-bottom:4px}.mention-item:hover{background-color:#f2f2f2}.mention-item-empty{padding:8px 12px;color:#888;font-style:italic}.mention-item.active{background-color:#e5e5e5;font-weight:700}.mention-item-type{opacity:.75;font-size:.9em}.skeleton{background-color:#e0e0e0;animation:pulse 1.5s infinite ease-in-out}@keyframes pulse{0%{background-color:#e0e0e0}50%{background-color:#f0f0f0}to{background-color:#e0e0e0}}\n"], dependencies: [{ kind: "pipe", type: FarisTranslatePipe, name: "translate" }] });
|
|
857
|
+
}
|
|
858
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MentionListComponent, decorators: [{
|
|
859
|
+
type: Component,
|
|
860
|
+
args: [{ selector: 'mt-faris-mention-list', standalone: true, imports: [FarisTranslatePipe], template: "<ul class=\"mention-list\">\r\n @if (loading) {\r\n <li title=\"loading...\">\r\n <div class=\"mention-item skeleton\"> </div>\r\n <div class=\"mention-item skeleton\"> </div>\r\n <div class=\"mention-item skeleton\"> </div>\r\n </li>\r\n }\r\n\r\n @if (!loading && items.length === 0) {\r\n <li class=\"mention-item-empty\">\r\n {{ \"faris.no-results-found\" | translate }}\r\n </li>\r\n }\r\n\r\n @for (item of items; track item.id; let i = $index) {\r\n <li\r\n (mousedown)=\"onItemClick($event, item)\"\r\n class=\"mention-item\"\r\n [class.active]=\"i === activeIndex\"\r\n [hidden]=\"loading\"\r\n >\r\n {{ item.title }}\r\n @if (item.levelType) {\r\n <span class=\"mention-item-type\">({{ item.levelType }})</span>\r\n }\r\n </li>\r\n }\r\n</ul>\r\n", styles: [".mention-list{list-style:none;margin:0;padding:5px;background:#fff;border-radius:var(--faris-border-radius);box-shadow:0 5px 10px #0000001a;max-height:200px;overflow-y:auto;z-index:1503;background-color:#ffffffbf;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}.mention-item{padding:8px 12px;cursor:pointer;border-radius:var(--faris-sm-border-radius)}.mention-item:not(:last-child){margin-bottom:4px}.mention-item:hover{background-color:#f2f2f2}.mention-item-empty{padding:8px 12px;color:#888;font-style:italic}.mention-item.active{background-color:#e5e5e5;font-weight:700}.mention-item-type{opacity:.75;font-size:.9em}.skeleton{background-color:#e0e0e0;animation:pulse 1.5s infinite ease-in-out}@keyframes pulse{0%{background-color:#e0e0e0}50%{background-color:#f0f0f0}to{background-color:#e0e0e0}}\n"] }]
|
|
861
|
+
}], propDecorators: { items: [{
|
|
862
|
+
type: Input
|
|
863
|
+
}], loading: [{
|
|
864
|
+
type: Input
|
|
865
|
+
}], itemSelected: [{
|
|
866
|
+
type: Output
|
|
867
|
+
}] } });
|
|
868
|
+
|
|
869
|
+
class MentionInputComponent {
|
|
870
|
+
inputRef;
|
|
871
|
+
loading = false;
|
|
872
|
+
resizeObserver;
|
|
873
|
+
overlayRef = null;
|
|
874
|
+
destroy$ = new Subject();
|
|
875
|
+
search$ = new Subject();
|
|
876
|
+
onChange = () => { };
|
|
877
|
+
onTouched = () => { };
|
|
878
|
+
mentionListInstance = null;
|
|
879
|
+
overlay = inject(Overlay);
|
|
880
|
+
viewContainerRef = inject(ViewContainerRef);
|
|
881
|
+
mentionApiService = inject(MentionApiService);
|
|
882
|
+
ngOnInit() {
|
|
883
|
+
this.search$
|
|
884
|
+
.pipe(debounceTime(300), switchMap((searchTerm) => {
|
|
885
|
+
this.loading = true;
|
|
886
|
+
if (this.overlayRef) {
|
|
887
|
+
this.showSuggestions([]);
|
|
888
|
+
}
|
|
889
|
+
return this.mentionApiService.search(searchTerm).pipe(catchError((_err) => {
|
|
890
|
+
this.loading = false;
|
|
891
|
+
return of([]);
|
|
892
|
+
}));
|
|
893
|
+
}), takeUntil(this.destroy$))
|
|
894
|
+
.subscribe((items) => {
|
|
895
|
+
this.loading = false;
|
|
896
|
+
if (this.overlayRef) {
|
|
897
|
+
this.showSuggestions(items);
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
ngAfterViewInit() {
|
|
902
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
903
|
+
for (const entry of entries) {
|
|
904
|
+
const { offsetWidth } = entry.target;
|
|
905
|
+
if (this.overlayRef) {
|
|
906
|
+
this.overlayRef.updatePosition();
|
|
907
|
+
this.overlayRef.updateSize({
|
|
908
|
+
width: 'fit-content',
|
|
909
|
+
minWidth: '250px',
|
|
910
|
+
maxWidth: `${offsetWidth}px`,
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
this.resizeObserver.observe(this.inputRef.nativeElement);
|
|
916
|
+
}
|
|
917
|
+
onInput() {
|
|
918
|
+
const { word, trigger } = this.getCurrentWord();
|
|
919
|
+
if (trigger === '@' && word.length) {
|
|
920
|
+
this.openOverlay();
|
|
921
|
+
this.search$.next(word);
|
|
922
|
+
}
|
|
923
|
+
else {
|
|
924
|
+
this.closeOverlay();
|
|
925
|
+
}
|
|
926
|
+
this.emitValueChange();
|
|
927
|
+
}
|
|
928
|
+
onBlur() {
|
|
929
|
+
this.onTouched();
|
|
930
|
+
}
|
|
931
|
+
onArrowUpDown(event) {
|
|
932
|
+
const keyboardEvent = event;
|
|
933
|
+
if (!this.overlayRef || !this.mentionListInstance) {
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
event.preventDefault();
|
|
937
|
+
if (keyboardEvent.key === 'ArrowUp') {
|
|
938
|
+
this.mentionListInstance.moveActiveUp();
|
|
939
|
+
}
|
|
940
|
+
else if (keyboardEvent.key === 'ArrowDown') {
|
|
941
|
+
this.mentionListInstance.moveActiveDown();
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
onEnter(event) {
|
|
945
|
+
const keyboardEvent = event;
|
|
946
|
+
if (this.overlayRef && this.mentionListInstance) {
|
|
947
|
+
event.preventDefault();
|
|
948
|
+
event.stopPropagation();
|
|
949
|
+
this.mentionListInstance.selectActiveItem();
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
this.insertParagraphAtCaret(keyboardEvent);
|
|
953
|
+
}
|
|
954
|
+
onTab(event) {
|
|
955
|
+
if (!this.overlayRef || !this.mentionListInstance) {
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
event.preventDefault();
|
|
959
|
+
event.stopPropagation();
|
|
960
|
+
this.mentionListInstance.selectActiveItem();
|
|
961
|
+
}
|
|
962
|
+
writeValue(value) {
|
|
963
|
+
if (!this.inputRef?.nativeElement) {
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
this.inputRef.nativeElement.innerHTML = value || '<p><br></p>';
|
|
967
|
+
if (!value && this.overlayRef) {
|
|
968
|
+
this.closeOverlay();
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
registerOnChange(fn) {
|
|
972
|
+
this.onChange = fn;
|
|
973
|
+
}
|
|
974
|
+
registerOnTouched(fn) {
|
|
975
|
+
this.onTouched = fn;
|
|
976
|
+
}
|
|
977
|
+
setDisabledState(isDisabled) {
|
|
978
|
+
if (!this.inputRef?.nativeElement) {
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
this.inputRef.nativeElement.contentEditable = isDisabled ? 'false' : 'true';
|
|
982
|
+
}
|
|
983
|
+
ngOnDestroy() {
|
|
984
|
+
this.destroy$.next();
|
|
985
|
+
this.destroy$.complete();
|
|
986
|
+
this.resizeObserver?.disconnect();
|
|
987
|
+
this.closeOverlay();
|
|
988
|
+
}
|
|
989
|
+
insertParagraphAtCaret(event) {
|
|
990
|
+
if (event.key !== 'Enter') {
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
event.preventDefault();
|
|
994
|
+
const selection = window.getSelection();
|
|
995
|
+
if (!selection || selection.rangeCount === 0) {
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
const range = selection.getRangeAt(0);
|
|
999
|
+
let currentParagraph = range.startContainer;
|
|
1000
|
+
while (currentParagraph &&
|
|
1001
|
+
currentParagraph.nodeType === Node.ELEMENT_NODE &&
|
|
1002
|
+
currentParagraph.tagName !== 'P') {
|
|
1003
|
+
currentParagraph = currentParagraph.parentElement;
|
|
1004
|
+
}
|
|
1005
|
+
if (!currentParagraph || currentParagraph.tagName !== 'P') {
|
|
1006
|
+
const paragraph = document.createElement('p');
|
|
1007
|
+
paragraph.innerHTML = '<br>';
|
|
1008
|
+
this.inputRef.nativeElement.appendChild(paragraph);
|
|
1009
|
+
this.moveCaretToEndOf(paragraph);
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
const afterRange = range.cloneRange();
|
|
1013
|
+
afterRange.setEndAfter(currentParagraph);
|
|
1014
|
+
const fragment = afterRange.extractContents();
|
|
1015
|
+
const newParagraph = document.createElement('p');
|
|
1016
|
+
if (fragment.textContent?.trim().length) {
|
|
1017
|
+
newParagraph.appendChild(fragment);
|
|
1018
|
+
}
|
|
1019
|
+
else {
|
|
1020
|
+
newParagraph.innerHTML = '<br>';
|
|
1021
|
+
}
|
|
1022
|
+
if (currentParagraph.nextSibling) {
|
|
1023
|
+
currentParagraph.parentNode?.insertBefore(newParagraph, currentParagraph.nextSibling);
|
|
1024
|
+
}
|
|
1025
|
+
else {
|
|
1026
|
+
currentParagraph.parentNode?.appendChild(newParagraph);
|
|
1027
|
+
}
|
|
1028
|
+
this.moveCaretToEndOf(newParagraph);
|
|
1029
|
+
}
|
|
1030
|
+
getCurrentWord() {
|
|
1031
|
+
const selection = window.getSelection();
|
|
1032
|
+
if (!selection || selection.rangeCount === 0) {
|
|
1033
|
+
return { word: '', trigger: null };
|
|
1034
|
+
}
|
|
1035
|
+
const blockNode = this.getCaretBlockNode(this.inputRef.nativeElement);
|
|
1036
|
+
if (!blockNode) {
|
|
1037
|
+
return { word: '', trigger: null };
|
|
1038
|
+
}
|
|
1039
|
+
const range = selection.getRangeAt(0).cloneRange();
|
|
1040
|
+
range.selectNodeContents(blockNode);
|
|
1041
|
+
range.setEnd(selection.anchorNode, selection.anchorOffset);
|
|
1042
|
+
const textBeforeCaret = range.toString();
|
|
1043
|
+
const match = textBeforeCaret.match(/@(\w*)$/);
|
|
1044
|
+
if (match) {
|
|
1045
|
+
return { word: match[1], trigger: '@' };
|
|
1046
|
+
}
|
|
1047
|
+
return { word: '', trigger: null };
|
|
1048
|
+
}
|
|
1049
|
+
openOverlay() {
|
|
1050
|
+
if (this.overlayRef) {
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
const positionStrategy = this.overlay
|
|
1054
|
+
.position()
|
|
1055
|
+
.flexibleConnectedTo(this.inputRef)
|
|
1056
|
+
.withPush(true)
|
|
1057
|
+
.withPositions([
|
|
1058
|
+
{
|
|
1059
|
+
originX: 'start',
|
|
1060
|
+
originY: 'top',
|
|
1061
|
+
overlayX: 'start',
|
|
1062
|
+
overlayY: 'bottom',
|
|
1063
|
+
offsetY: -8,
|
|
1064
|
+
},
|
|
1065
|
+
{
|
|
1066
|
+
originX: 'start',
|
|
1067
|
+
originY: 'bottom',
|
|
1068
|
+
overlayX: 'start',
|
|
1069
|
+
overlayY: 'top',
|
|
1070
|
+
offsetY: 8,
|
|
1071
|
+
},
|
|
1072
|
+
]);
|
|
1073
|
+
this.overlayRef = this.overlay.create({
|
|
1074
|
+
positionStrategy,
|
|
1075
|
+
scrollStrategy: this.overlay.scrollStrategies.reposition(),
|
|
1076
|
+
panelClass: 'mention-overlay-panel',
|
|
1077
|
+
width: 'fit-content',
|
|
1078
|
+
minWidth: '250px',
|
|
1079
|
+
maxWidth: `${this.inputRef.nativeElement.offsetWidth}px`,
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
showSuggestions(items = []) {
|
|
1083
|
+
if (!this.overlayRef) {
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
if (this.overlayRef.hasAttached()) {
|
|
1087
|
+
this.overlayRef.detach();
|
|
1088
|
+
}
|
|
1089
|
+
const strippedItems = items.map((item) => ({
|
|
1090
|
+
...item,
|
|
1091
|
+
rank: undefined,
|
|
1092
|
+
}));
|
|
1093
|
+
const portal = new ComponentPortal(MentionListComponent, this.viewContainerRef);
|
|
1094
|
+
const componentRef = this.overlayRef.attach(portal);
|
|
1095
|
+
componentRef.instance.items = strippedItems;
|
|
1096
|
+
componentRef.instance.loading = this.loading;
|
|
1097
|
+
this.mentionListInstance = componentRef.instance;
|
|
1098
|
+
if (items.length > 0) {
|
|
1099
|
+
this.mentionListInstance.activeIndex = 0;
|
|
1100
|
+
}
|
|
1101
|
+
componentRef.instance.itemSelected
|
|
1102
|
+
.pipe(takeUntil(this.destroy$))
|
|
1103
|
+
.subscribe((item) => {
|
|
1104
|
+
this.insertMention(item);
|
|
1105
|
+
this.closeOverlay();
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
insertMention(item) {
|
|
1109
|
+
const selection = window.getSelection();
|
|
1110
|
+
if (!selection || selection.rangeCount === 0) {
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
const blockNode = this.getCaretBlockNode(this.inputRef.nativeElement);
|
|
1114
|
+
if (!blockNode) {
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
const range = selection.getRangeAt(0);
|
|
1118
|
+
const preCaretRange = range.cloneRange();
|
|
1119
|
+
preCaretRange.selectNodeContents(blockNode);
|
|
1120
|
+
preCaretRange.setEnd(selection.anchorNode, selection.anchorOffset);
|
|
1121
|
+
const textBeforeCaret = preCaretRange.toString();
|
|
1122
|
+
const lastAt = textBeforeCaret.lastIndexOf('@');
|
|
1123
|
+
if (lastAt === -1) {
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
let charCount = textBeforeCaret.length - lastAt;
|
|
1127
|
+
const treeWalker = document.createTreeWalker(blockNode, NodeFilter.SHOW_TEXT, null);
|
|
1128
|
+
let currentNode = treeWalker.lastChild();
|
|
1129
|
+
let offset = 0;
|
|
1130
|
+
while (currentNode && charCount > 0) {
|
|
1131
|
+
if (currentNode.textContent) {
|
|
1132
|
+
if (charCount <= currentNode.textContent.length) {
|
|
1133
|
+
offset = currentNode.textContent.length - charCount;
|
|
1134
|
+
break;
|
|
1135
|
+
}
|
|
1136
|
+
charCount -= currentNode.textContent.length;
|
|
1137
|
+
}
|
|
1138
|
+
currentNode = treeWalker.previousNode();
|
|
1139
|
+
}
|
|
1140
|
+
if (!currentNode) {
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
const newRange = document.createRange();
|
|
1144
|
+
newRange.setStart(currentNode, offset);
|
|
1145
|
+
newRange.setEnd(range.endContainer, range.endOffset);
|
|
1146
|
+
newRange.deleteContents();
|
|
1147
|
+
const mentionNode = document.createElement('span');
|
|
1148
|
+
mentionNode.className = 'mention-highlight';
|
|
1149
|
+
mentionNode.contentEditable = 'false';
|
|
1150
|
+
mentionNode.textContent = `@${item.title}`;
|
|
1151
|
+
mentionNode.setAttribute('data-mention', JSON.stringify(item));
|
|
1152
|
+
newRange.insertNode(mentionNode);
|
|
1153
|
+
const space = document.createTextNode('\u00A0');
|
|
1154
|
+
mentionNode.after(space);
|
|
1155
|
+
const afterRange = document.createRange();
|
|
1156
|
+
afterRange.setStartAfter(space);
|
|
1157
|
+
afterRange.collapse(true);
|
|
1158
|
+
selection.removeAllRanges();
|
|
1159
|
+
selection.addRange(afterRange);
|
|
1160
|
+
this.inputRef.nativeElement.focus();
|
|
1161
|
+
this.emitValueChange();
|
|
1162
|
+
}
|
|
1163
|
+
emitValueChange() {
|
|
1164
|
+
if (!this.inputRef?.nativeElement) {
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
this.onChange(this.getEncodedValue());
|
|
1168
|
+
}
|
|
1169
|
+
closeOverlay() {
|
|
1170
|
+
if (!this.overlayRef) {
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
this.overlayRef.dispose();
|
|
1174
|
+
this.overlayRef = null;
|
|
1175
|
+
this.mentionListInstance = null;
|
|
1176
|
+
}
|
|
1177
|
+
getEncodedValue() {
|
|
1178
|
+
const traverse = (node) => {
|
|
1179
|
+
let result = '';
|
|
1180
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1181
|
+
const element = node;
|
|
1182
|
+
if (element.classList.contains('mention-highlight') &&
|
|
1183
|
+
element.hasAttribute('data-mention')) {
|
|
1184
|
+
result += `@{{${element.getAttribute('data-mention')}}}`;
|
|
1185
|
+
}
|
|
1186
|
+
else {
|
|
1187
|
+
node.childNodes.forEach((child) => {
|
|
1188
|
+
result += traverse(child);
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
else if (node.nodeType === Node.TEXT_NODE) {
|
|
1193
|
+
result += node.textContent ?? '';
|
|
1194
|
+
}
|
|
1195
|
+
return result;
|
|
1196
|
+
};
|
|
1197
|
+
return traverse(this.inputRef.nativeElement);
|
|
1198
|
+
}
|
|
1199
|
+
getCaretBlockNode(container) {
|
|
1200
|
+
const selection = window.getSelection();
|
|
1201
|
+
if (!selection || selection.rangeCount === 0) {
|
|
1202
|
+
return null;
|
|
1203
|
+
}
|
|
1204
|
+
let node = selection.anchorNode;
|
|
1205
|
+
while (node && node !== container) {
|
|
1206
|
+
if (node.nodeType === Node.ELEMENT_NODE &&
|
|
1207
|
+
node.tagName.match(/^(DIV|P|LI)$/)) {
|
|
1208
|
+
return node;
|
|
1209
|
+
}
|
|
1210
|
+
node = node.parentNode;
|
|
1211
|
+
}
|
|
1212
|
+
return container;
|
|
1213
|
+
}
|
|
1214
|
+
moveCaretToEndOf(element) {
|
|
1215
|
+
const range = document.createRange();
|
|
1216
|
+
const selection = window.getSelection();
|
|
1217
|
+
range.selectNodeContents(element);
|
|
1218
|
+
range.collapse(false);
|
|
1219
|
+
selection?.removeAllRanges();
|
|
1220
|
+
selection?.addRange(range);
|
|
1221
|
+
element.focus();
|
|
1222
|
+
}
|
|
1223
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MentionInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1224
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.3", type: MentionInputComponent, isStandalone: true, selector: "mt-faris-mention-input", providers: [
|
|
1225
|
+
{
|
|
1226
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1227
|
+
useExisting: forwardRef(() => MentionInputComponent),
|
|
1228
|
+
multi: true,
|
|
1229
|
+
},
|
|
1230
|
+
], viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["mentionInput"], descendants: true, static: true }], ngImport: i0, template: "<div\r\n #mentionInput\r\n class=\"mention-input\"\r\n contenteditable=\"true\"\r\n (input)=\"onInput()\"\r\n (blur)=\"onBlur()\"\r\n (keydown.arrowUp)=\"onArrowUpDown($event)\"\r\n (keydown.arrowDown)=\"onArrowUpDown($event)\"\r\n (keydown.enter)=\"onEnter($event)\"\r\n (keydown.tab)=\"onTab($event)\"\r\n></div>\r\n", styles: [":host{width:100%;display:block}::ng-deep .cdk-overlay-connected-position-bounding-box:has(.mention-overlay-panel){display:flex;flex-direction:column;position:absolute}::ng-deep .mention-overlay-panel{z-index:1501}::ng-deep .mention-input .mention-highlight{font-weight:700;border-radius:var(--faris-sm-border-radius)}.mention-input{min-height:40px;min-height:3em;height:3em;max-height:3em;cursor:text;line-height:1.5;outline:none;overflow-y:auto;border:1px solid #dee2e6;padding:.5em;border-radius:var(--faris-border-radius);resize:none;font-size:1em;background-color:#fff}.mention-input p{margin:0}.mention-input:focus{box-shadow:0 5px 10px #00000014}\n"] });
|
|
1231
|
+
}
|
|
1232
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MentionInputComponent, decorators: [{
|
|
1233
|
+
type: Component,
|
|
1234
|
+
args: [{ selector: 'mt-faris-mention-input', standalone: true, providers: [
|
|
1235
|
+
{
|
|
1236
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1237
|
+
useExisting: forwardRef(() => MentionInputComponent),
|
|
1238
|
+
multi: true,
|
|
1239
|
+
},
|
|
1240
|
+
], template: "<div\r\n #mentionInput\r\n class=\"mention-input\"\r\n contenteditable=\"true\"\r\n (input)=\"onInput()\"\r\n (blur)=\"onBlur()\"\r\n (keydown.arrowUp)=\"onArrowUpDown($event)\"\r\n (keydown.arrowDown)=\"onArrowUpDown($event)\"\r\n (keydown.enter)=\"onEnter($event)\"\r\n (keydown.tab)=\"onTab($event)\"\r\n></div>\r\n", styles: [":host{width:100%;display:block}::ng-deep .cdk-overlay-connected-position-bounding-box:has(.mention-overlay-panel){display:flex;flex-direction:column;position:absolute}::ng-deep .mention-overlay-panel{z-index:1501}::ng-deep .mention-input .mention-highlight{font-weight:700;border-radius:var(--faris-sm-border-radius)}.mention-input{min-height:40px;min-height:3em;height:3em;max-height:3em;cursor:text;line-height:1.5;outline:none;overflow-y:auto;border:1px solid #dee2e6;padding:.5em;border-radius:var(--faris-border-radius);resize:none;font-size:1em;background-color:#fff}.mention-input p{margin:0}.mention-input:focus{box-shadow:0 5px 10px #00000014}\n"] }]
|
|
1241
|
+
}], propDecorators: { inputRef: [{
|
|
1242
|
+
type: ViewChild,
|
|
1243
|
+
args: ['mentionInput', { static: true }]
|
|
1244
|
+
}] } });
|
|
1245
|
+
|
|
1246
|
+
class FarisChatComponent {
|
|
1247
|
+
_selectedConversation = null;
|
|
1248
|
+
_selectedConversationId = null;
|
|
1249
|
+
set selectedConversation(conversation) {
|
|
1250
|
+
const nextConversationId = this.resolveConversationId(conversation);
|
|
1251
|
+
if (nextConversationId &&
|
|
1252
|
+
nextConversationId === this._selectedConversationId) {
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
1255
|
+
this._selectedConversation = conversation;
|
|
1256
|
+
this._selectedConversationId = nextConversationId;
|
|
1257
|
+
if (!nextConversationId) {
|
|
1258
|
+
this._selectedConversation = null;
|
|
1259
|
+
this._selectedConversationId = null;
|
|
1260
|
+
this.chatHistory = [];
|
|
1261
|
+
this.showResult = false;
|
|
1262
|
+
this.farisService.clearSession();
|
|
1263
|
+
}
|
|
1264
|
+
else {
|
|
1265
|
+
this.getConversationDetails(nextConversationId);
|
|
1266
|
+
}
|
|
1267
|
+
this.userInput = '';
|
|
1268
|
+
}
|
|
1269
|
+
launchCanvas = new EventEmitter();
|
|
1270
|
+
selectConversation = new EventEmitter();
|
|
1271
|
+
userInput = '';
|
|
1272
|
+
showResult = false;
|
|
1273
|
+
loading = false;
|
|
1274
|
+
markdownContent = '';
|
|
1275
|
+
currentUserPhoto = '';
|
|
1276
|
+
chatHistory = [];
|
|
1277
|
+
dots = '';
|
|
1278
|
+
intervalId = null;
|
|
1279
|
+
thinkingText = '';
|
|
1280
|
+
deepThinkingTimeoutId = null;
|
|
1281
|
+
deepThinkingDelay = 10000;
|
|
1282
|
+
deepThinkingText = 'Deep thinking is needed and the response might take more than usual...';
|
|
1283
|
+
thinkingTexts = [
|
|
1284
|
+
'Thinking',
|
|
1285
|
+
'Hmm, analyzing the data',
|
|
1286
|
+
'Let me think for a moment',
|
|
1287
|
+
'Just a second, processing your request',
|
|
1288
|
+
'Considering all possibilities',
|
|
1289
|
+
"Let's see what I can come up with",
|
|
1290
|
+
'Running some calculations',
|
|
1291
|
+
'Thinking hard about this one',
|
|
1292
|
+
'Let me get back to you',
|
|
1293
|
+
];
|
|
1294
|
+
agents = [];
|
|
1295
|
+
subscriptions = new Subscription();
|
|
1296
|
+
farisService = inject(FarisService);
|
|
1297
|
+
get selectedChatId() {
|
|
1298
|
+
return this._selectedConversationId ?? '';
|
|
1299
|
+
}
|
|
1300
|
+
get currentUserDisplayName() {
|
|
1301
|
+
const currentUser = this.farisService.currentUser;
|
|
1302
|
+
return (currentUser?.user?.displayName ??
|
|
1303
|
+
currentUser?.displayName ??
|
|
1304
|
+
currentUser?.user?.name ??
|
|
1305
|
+
currentUser?.name ??
|
|
1306
|
+
'');
|
|
1307
|
+
}
|
|
1308
|
+
ngOnInit() {
|
|
1309
|
+
this.loading = true;
|
|
1310
|
+
this.currentUserPhoto = this.resolveUserPhoto();
|
|
1311
|
+
this.startThinking(false);
|
|
1312
|
+
setTimeout(() => {
|
|
1313
|
+
this.loading = false;
|
|
1314
|
+
}, 600);
|
|
1315
|
+
}
|
|
1316
|
+
sendQuery(query) {
|
|
1317
|
+
const value = (query || this.userInput || '').trim();
|
|
1318
|
+
if (!value || this.loading) {
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
this.userInput = value;
|
|
1322
|
+
this.showResult = true;
|
|
1323
|
+
this.loading = true;
|
|
1324
|
+
this.startThinking();
|
|
1325
|
+
this.chatHistory = [
|
|
1326
|
+
...this.chatHistory,
|
|
1327
|
+
{ role: 'user', content: value, loaded: true },
|
|
1328
|
+
{ role: 'assistant', content: this.markdownContent, loaded: false },
|
|
1329
|
+
];
|
|
1330
|
+
this.subscriptions.add(this.farisService
|
|
1331
|
+
.sendMessage(value)
|
|
1332
|
+
.pipe(finalize(() => {
|
|
1333
|
+
this.loading = false;
|
|
1334
|
+
this.stopThinking();
|
|
1335
|
+
}))
|
|
1336
|
+
.subscribe((res) => {
|
|
1337
|
+
const index = this.chatHistory.length - 1;
|
|
1338
|
+
this.chatHistory[index].content = res?.content;
|
|
1339
|
+
this.chatHistory[index].loaded = true;
|
|
1340
|
+
this.chatHistory[index].message_id = res?.message_id;
|
|
1341
|
+
this.chatHistory[index].trace_id = res?.trace_id;
|
|
1342
|
+
this.chatHistory[index].feedback = res?.feedback;
|
|
1343
|
+
this.chatHistory[index].score = res?.score;
|
|
1344
|
+
this.scrollToBottom();
|
|
1345
|
+
const canvas = this.resolveContent(res?.content).includes('\n```canvas');
|
|
1346
|
+
if (!this.selectedChatId) {
|
|
1347
|
+
const sessionId = res?.session_id ?? res?.sessionId ?? res?.id ?? undefined;
|
|
1348
|
+
this.selectConversation.emit({
|
|
1349
|
+
id: sessionId,
|
|
1350
|
+
title: res?.conversation_title ?? res?.conversationTitle ?? value,
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
if (canvas) {
|
|
1354
|
+
this.launchCanvas.emit(this.chatHistory[index]);
|
|
1355
|
+
}
|
|
1356
|
+
}));
|
|
1357
|
+
setTimeout(() => {
|
|
1358
|
+
this.userInput = '';
|
|
1359
|
+
}, 10);
|
|
1360
|
+
}
|
|
1361
|
+
takeAction(action, item) {
|
|
1362
|
+
if (!this.selectedChatId || !item?.message_id) {
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
switch (action) {
|
|
1366
|
+
case 'like':
|
|
1367
|
+
case 'dislike':
|
|
1368
|
+
this.likeDislikeFeedback(action, item);
|
|
1369
|
+
break;
|
|
1370
|
+
case 'copy':
|
|
1371
|
+
this.farisService.copyToClipboard(this.resolveContent(item.content));
|
|
1372
|
+
break;
|
|
1373
|
+
default:
|
|
1374
|
+
break;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
ngOnDestroy() {
|
|
1378
|
+
this.chatHistory = [];
|
|
1379
|
+
this.showResult = false;
|
|
1380
|
+
this.farisService.clearSession();
|
|
1381
|
+
if (this.intervalId) {
|
|
1382
|
+
clearInterval(this.intervalId);
|
|
1383
|
+
this.intervalId = null;
|
|
1384
|
+
}
|
|
1385
|
+
if (this.deepThinkingTimeoutId) {
|
|
1386
|
+
clearTimeout(this.deepThinkingTimeoutId);
|
|
1387
|
+
this.deepThinkingTimeoutId = null;
|
|
1388
|
+
}
|
|
1389
|
+
if (!this.subscriptions.closed) {
|
|
1390
|
+
this.subscriptions.unsubscribe();
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
resolveUserPhoto() {
|
|
1394
|
+
const currentUser = this.farisService.currentUser;
|
|
1395
|
+
const photo = currentUser?.user?.photo ??
|
|
1396
|
+
currentUser?.photo ??
|
|
1397
|
+
currentUser?.user?.image ??
|
|
1398
|
+
currentUser?.image;
|
|
1399
|
+
if (typeof photo === 'string') {
|
|
1400
|
+
return photo;
|
|
1401
|
+
}
|
|
1402
|
+
return photo?.fileName ?? '';
|
|
1403
|
+
}
|
|
1404
|
+
startThinking(shouldGenerateNew = true) {
|
|
1405
|
+
this.thinkingText = this.getRandomThinkingText(shouldGenerateNew);
|
|
1406
|
+
this.scrollToBottom();
|
|
1407
|
+
if (this.intervalId) {
|
|
1408
|
+
clearInterval(this.intervalId);
|
|
1409
|
+
}
|
|
1410
|
+
let count = 0;
|
|
1411
|
+
this.intervalId = setInterval(() => {
|
|
1412
|
+
count = (count + 1) % 4;
|
|
1413
|
+
this.dots = '.'.repeat(count);
|
|
1414
|
+
}, 500);
|
|
1415
|
+
if (this.deepThinkingTimeoutId) {
|
|
1416
|
+
clearTimeout(this.deepThinkingTimeoutId);
|
|
1417
|
+
}
|
|
1418
|
+
this.deepThinkingTimeoutId = setTimeout(() => {
|
|
1419
|
+
if (this.loading) {
|
|
1420
|
+
this.thinkingText = this.deepThinkingText;
|
|
1421
|
+
}
|
|
1422
|
+
}, this.deepThinkingDelay);
|
|
1423
|
+
}
|
|
1424
|
+
stopThinking() {
|
|
1425
|
+
if (this.intervalId) {
|
|
1426
|
+
clearInterval(this.intervalId);
|
|
1427
|
+
this.intervalId = null;
|
|
1428
|
+
}
|
|
1429
|
+
this.dots = '';
|
|
1430
|
+
if (this.deepThinkingTimeoutId) {
|
|
1431
|
+
clearTimeout(this.deepThinkingTimeoutId);
|
|
1432
|
+
this.deepThinkingTimeoutId = null;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
scrollToBottom() {
|
|
1436
|
+
const container = document.getElementById('results-container');
|
|
1437
|
+
if (!container) {
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
setTimeout(() => {
|
|
1441
|
+
container.scrollTo({
|
|
1442
|
+
top: container.scrollHeight + 100,
|
|
1443
|
+
behavior: 'smooth',
|
|
1444
|
+
});
|
|
1445
|
+
}, 150);
|
|
1446
|
+
}
|
|
1447
|
+
getRandomThinkingText(generateNew = true) {
|
|
1448
|
+
if (!generateNew) {
|
|
1449
|
+
return this.thinkingTexts[0];
|
|
1450
|
+
}
|
|
1451
|
+
const randomIndex = Math.floor(Math.random() * this.thinkingTexts.length);
|
|
1452
|
+
return this.thinkingTexts[randomIndex];
|
|
1453
|
+
}
|
|
1454
|
+
getConversationDetails(id) {
|
|
1455
|
+
this.subscriptions.add(this.farisService.getConversationDetails(id).subscribe((res) => {
|
|
1456
|
+
this.showResult = true;
|
|
1457
|
+
this.chatHistory = (res || []).map((item) => ({
|
|
1458
|
+
role: item.role,
|
|
1459
|
+
content: item.content,
|
|
1460
|
+
loaded: true,
|
|
1461
|
+
message_id: item.message_id,
|
|
1462
|
+
trace_id: item.trace_id,
|
|
1463
|
+
score: item.score,
|
|
1464
|
+
feedback: item.feedback,
|
|
1465
|
+
}));
|
|
1466
|
+
this.scrollToBottom();
|
|
1467
|
+
}));
|
|
1468
|
+
}
|
|
1469
|
+
resolveConversationId(conversation) {
|
|
1470
|
+
const id = conversation?.id ??
|
|
1471
|
+
conversation?.session_id ??
|
|
1472
|
+
conversation?.sessionId ??
|
|
1473
|
+
conversation?.conversation_id ??
|
|
1474
|
+
conversation?.conversationId;
|
|
1475
|
+
return id == null ? null : String(id);
|
|
1476
|
+
}
|
|
1477
|
+
likeDislikeFeedback(vote, item) {
|
|
1478
|
+
if (!this.selectedChatId || !item?.message_id) {
|
|
1479
|
+
return;
|
|
1480
|
+
}
|
|
1481
|
+
let score = vote === 'like' ? 1 : -1;
|
|
1482
|
+
if ((item.feedback === 1 && score === 1) ||
|
|
1483
|
+
(item.feedback === -1 && score === -1)) {
|
|
1484
|
+
score = 0;
|
|
1485
|
+
}
|
|
1486
|
+
this.subscriptions.add(this.farisService
|
|
1487
|
+
.sendFeedback(item.message_id, score, item.trace_id)
|
|
1488
|
+
.subscribe());
|
|
1489
|
+
}
|
|
1490
|
+
resolveContent(content) {
|
|
1491
|
+
if (typeof content === 'string') {
|
|
1492
|
+
return content;
|
|
1493
|
+
}
|
|
1494
|
+
if (content == null) {
|
|
1495
|
+
return '';
|
|
1496
|
+
}
|
|
1497
|
+
try {
|
|
1498
|
+
return JSON.stringify(content);
|
|
1499
|
+
}
|
|
1500
|
+
catch {
|
|
1501
|
+
return String(content);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisChatComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1505
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: FarisChatComponent, isStandalone: true, selector: "mt-faris-chat", inputs: { selectedConversation: "selectedConversation" }, outputs: { launchCanvas: "launchCanvas", selectConversation: "selectConversation" }, ngImport: i0, template: "<div class=\"relative flex h-full w-full flex-col justify-between\" #container>\r\n @if (!showResult) {\r\n <div class=\"welcome-user\">\r\n <span class=\"hello-gradient\"\r\n >{{ \"faris.hello\" | translate }}, {{ currentUserDisplayName }}</span\r\n >\r\n <span class=\"welcome-text\">{{\r\n \"faris.welcome-message\" | translate\r\n }}</span>\r\n </div>\r\n }\r\n\r\n <div class=\"results-container\" id=\"results-container\">\r\n <div class=\"pre-defined-questions flex w-full flex-col\">\r\n @if (!showResult) {\r\n @for (agent of agents; track agent?.title) {\r\n <mt-faris-agent-card\r\n class=\"real-content\"\r\n [agent]=\"agent\"\r\n (click)=\"sendQuery(agent.title)\"\r\n ></mt-faris-agent-card>\r\n }\r\n }\r\n\r\n @if (showResult) {\r\n @for (\r\n item of chatHistory;\r\n track item.trace_id || item.message_id || $index\r\n ) {\r\n <mt-faris-message\r\n [item]=\"item\"\r\n [currentUserPhoto]=\"currentUserPhoto\"\r\n [loading]=\"loading\"\r\n [thinkingText]=\"thinkingText\"\r\n (action)=\"takeAction($event.action, $event.item)\"\r\n (canvas)=\"launchCanvas.emit($event)\"\r\n >\r\n </mt-faris-message>\r\n }\r\n }\r\n </div>\r\n </div>\r\n\r\n <div class=\"search-box\">\r\n <form class=\"w-full\" #chatForm=\"ngForm\" (ngSubmit)=\"sendQuery(userInput)\">\r\n <div class=\"input-box\">\r\n <mt-faris-mention-input\r\n [(ngModel)]=\"userInput\"\r\n [ngModelOptions]=\"{ standalone: true }\"\r\n (keydown.enter)=\"sendQuery(userInput)\"\r\n ></mt-faris-mention-input>\r\n\r\n <mt-button\r\n type=\"submit\"\r\n icon=\"communication.send-01\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn faris-btn-lg\"\r\n [disabled]=\"!userInput || !userInput.trim() || loading\"\r\n ></mt-button>\r\n </div>\r\n </form>\r\n\r\n <small>{{ \"faris.input-message\" | translate }}</small>\r\n </div>\r\n</div>\r\n", styles: [".results-container{height:90%;overflow-y:auto;margin:0 1em 100px}.conversations-container{height:85%;overflow-y:auto;margin:0 1em 140px}.search-box{position:absolute;display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:90px;border-top:1px solid #dee2e6;gap:.5em;padding:.5em 1em;bottom:0;left:0}.search-box small{font-size:.65em;opacity:.8}.search-box .input-box{display:flex;align-items:center;gap:.5em}.search-box .input-box textarea{border:1px solid #dee2e6;padding:.5em;border-radius:var(--faris-border-radius);box-shadow:0 5px 10px #00000014;resize:none;height:unset!important;width:100%!important;outline:none;font-size:1em}.search-box .input-box textarea::-webkit-input-placeholder{font-size:1em}.pre-defined-questions{gap:1em;width:100%}.welcome-user{display:flex;flex-direction:column;gap:.5em;font-size:1.1em;font-weight:500;padding:0 1em 1.2em;line-height:22px}.welcome-user .hello-gradient{font-size:1.5em;font-weight:700;background:-webkit-linear-gradient(315deg,#217bfe 0,#078efb 33%,#ac87eb 100%);background:linear-gradient(135deg,#217bfe 0,#078efb 33%,#ac87eb);background-size:200% 100%;display:-webkit-inline-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;word-break:break-word;-webkit-background-clip:text;background-clip:text;color:transparent;-webkit-text-fill-color:transparent;inline-size:-webkit-fit-content;inline-size:fit-content;display:block;animation:gradient-shine 1.5s ease-in}@keyframes gradient-shine{0%{background-position:200% center;opacity:0}60%{opacity:1}to{background-position:0% center;opacity:1}}.welcome-user .welcome-text{display:inline-block;background:linear-gradient(90deg,#888 100%,transparent 0%);background-size:0% 100%;background-repeat:no-repeat;color:transparent;background-clip:text;-webkit-background-clip:text;animation:fill-gray 1.5s forwards;animation-delay:.5s}@keyframes fill-text{0%{background-size:0% 100%;opacity:0}30%{opacity:1}to{background-size:200% 100%;opacity:1}}@keyframes fill-gray{0%{background-size:0% 100%;opacity:0}30%{opacity:1}to{background-size:100% 100%;opacity:1}}:dir(rtl) .welcome-user .hello-gradient{background:linear-gradient(-135deg,#217bfe 0,#078efb 33%,#ac87eb);background-size:200% 100%;background-position:0% center;-webkit-background-clip:text;background-clip:text;color:transparent;-webkit-text-fill-color:transparent;animation:gradient-shine-rtl 1.5s ease-in}@keyframes gradient-shine-rtl{0%{background-position:-200% center;opacity:0}60%{opacity:1}to{background-position:0% center;opacity:1}}:dir(rtl) .welcome-user .welcome-text{background:linear-gradient(270deg,#888 100%,transparent 0%);background-size:0% 100%;background-repeat:no-repeat;background-position:right center;background-clip:text;-webkit-background-clip:text;color:transparent;animation:fill-gray-rtl 1.5s forwards;animation-delay:.5s}@keyframes fill-gray-rtl{0%{background-size:0% 100%;opacity:0}30%{opacity:1}to{background-size:100% 100%;opacity:1}}::ng-deep markdown{width:calc(100% - 28px)}::ng-deep markdown h1{font-size:1em}::ng-deep markdown h2{font-size:.9em}::ng-deep markdown h3{font-size:.8em}::ng-deep markdown h4{font-size:.7em}::ng-deep markdown h5{font-size:.6em}::ng-deep markdown h6{font-size:.5em}::ng-deep markdown p{font-size:.9em;line-height:1.5;margin:8px 0}::ng-deep markdown ul,::ng-deep markdown ol{font-size:.9em;line-height:1.5;margin-inline-start:1.5em;padding:0;list-style-type:disclosure-closed}::ng-deep markdown li{margin-bottom:.5em}::ng-deep markdown blockquote{border-inline-start:4px solid #dfe2e5;padding:.5em 1em;margin:1em 0;background-color:#f6f8fa}::ng-deep markdown code{background-color:#f6f8fa;padding:.2em .4em;border-radius:var(--faris-sm-border-radius);font-family:Courier New,Courier,monospace}::ng-deep markdown table{width:100%;border-collapse:collapse;margin:1em 0}::ng-deep markdown th,::ng-deep markdown td{border:1px solid #dfe2e5;padding:.5em;text-align:start}::ng-deep markdown th{background-color:#f6f8fa;font-weight:700}::ng-deep markdown img{max-width:100%;height:auto;display:block;margin:1em 0}::ng-deep markdown .chart-placeholder{width:100%!important}.thinking{position:absolute;inset-inline-start:0;bottom:110px}#thinkingText{font-size:12px;font-weight:700}@keyframes dots{0%{content:\".\"}33%{content:\"..\"}66%{content:\"...\"}}#dots:after{content:\".\";animation:dots 1s infinite steps(3,end)}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i1.NgForm, selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: AgentCardComponent, selector: "mt-faris-agent-card", inputs: ["agent"] }, { kind: "component", type: FarisMessageComponent, selector: "mt-faris-message", inputs: ["item", "currentUserPhoto", "loading", "thinkingText"], outputs: ["action", "canvas"] }, { kind: "component", type: MentionInputComponent, selector: "mt-faris-mention-input" }, { kind: "pipe", type: FarisTranslatePipe, name: "translate" }] });
|
|
1506
|
+
}
|
|
1507
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisChatComponent, decorators: [{
|
|
1508
|
+
type: Component,
|
|
1509
|
+
args: [{ selector: 'mt-faris-chat', standalone: true, imports: [
|
|
1510
|
+
FormsModule,
|
|
1511
|
+
Button,
|
|
1512
|
+
AgentCardComponent,
|
|
1513
|
+
FarisTranslatePipe,
|
|
1514
|
+
FarisMessageComponent,
|
|
1515
|
+
MentionInputComponent,
|
|
1516
|
+
], template: "<div class=\"relative flex h-full w-full flex-col justify-between\" #container>\r\n @if (!showResult) {\r\n <div class=\"welcome-user\">\r\n <span class=\"hello-gradient\"\r\n >{{ \"faris.hello\" | translate }}, {{ currentUserDisplayName }}</span\r\n >\r\n <span class=\"welcome-text\">{{\r\n \"faris.welcome-message\" | translate\r\n }}</span>\r\n </div>\r\n }\r\n\r\n <div class=\"results-container\" id=\"results-container\">\r\n <div class=\"pre-defined-questions flex w-full flex-col\">\r\n @if (!showResult) {\r\n @for (agent of agents; track agent?.title) {\r\n <mt-faris-agent-card\r\n class=\"real-content\"\r\n [agent]=\"agent\"\r\n (click)=\"sendQuery(agent.title)\"\r\n ></mt-faris-agent-card>\r\n }\r\n }\r\n\r\n @if (showResult) {\r\n @for (\r\n item of chatHistory;\r\n track item.trace_id || item.message_id || $index\r\n ) {\r\n <mt-faris-message\r\n [item]=\"item\"\r\n [currentUserPhoto]=\"currentUserPhoto\"\r\n [loading]=\"loading\"\r\n [thinkingText]=\"thinkingText\"\r\n (action)=\"takeAction($event.action, $event.item)\"\r\n (canvas)=\"launchCanvas.emit($event)\"\r\n >\r\n </mt-faris-message>\r\n }\r\n }\r\n </div>\r\n </div>\r\n\r\n <div class=\"search-box\">\r\n <form class=\"w-full\" #chatForm=\"ngForm\" (ngSubmit)=\"sendQuery(userInput)\">\r\n <div class=\"input-box\">\r\n <mt-faris-mention-input\r\n [(ngModel)]=\"userInput\"\r\n [ngModelOptions]=\"{ standalone: true }\"\r\n (keydown.enter)=\"sendQuery(userInput)\"\r\n ></mt-faris-mention-input>\r\n\r\n <mt-button\r\n type=\"submit\"\r\n icon=\"communication.send-01\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn faris-btn-lg\"\r\n [disabled]=\"!userInput || !userInput.trim() || loading\"\r\n ></mt-button>\r\n </div>\r\n </form>\r\n\r\n <small>{{ \"faris.input-message\" | translate }}</small>\r\n </div>\r\n</div>\r\n", styles: [".results-container{height:90%;overflow-y:auto;margin:0 1em 100px}.conversations-container{height:85%;overflow-y:auto;margin:0 1em 140px}.search-box{position:absolute;display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:90px;border-top:1px solid #dee2e6;gap:.5em;padding:.5em 1em;bottom:0;left:0}.search-box small{font-size:.65em;opacity:.8}.search-box .input-box{display:flex;align-items:center;gap:.5em}.search-box .input-box textarea{border:1px solid #dee2e6;padding:.5em;border-radius:var(--faris-border-radius);box-shadow:0 5px 10px #00000014;resize:none;height:unset!important;width:100%!important;outline:none;font-size:1em}.search-box .input-box textarea::-webkit-input-placeholder{font-size:1em}.pre-defined-questions{gap:1em;width:100%}.welcome-user{display:flex;flex-direction:column;gap:.5em;font-size:1.1em;font-weight:500;padding:0 1em 1.2em;line-height:22px}.welcome-user .hello-gradient{font-size:1.5em;font-weight:700;background:-webkit-linear-gradient(315deg,#217bfe 0,#078efb 33%,#ac87eb 100%);background:linear-gradient(135deg,#217bfe 0,#078efb 33%,#ac87eb);background-size:200% 100%;display:-webkit-inline-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;word-break:break-word;-webkit-background-clip:text;background-clip:text;color:transparent;-webkit-text-fill-color:transparent;inline-size:-webkit-fit-content;inline-size:fit-content;display:block;animation:gradient-shine 1.5s ease-in}@keyframes gradient-shine{0%{background-position:200% center;opacity:0}60%{opacity:1}to{background-position:0% center;opacity:1}}.welcome-user .welcome-text{display:inline-block;background:linear-gradient(90deg,#888 100%,transparent 0%);background-size:0% 100%;background-repeat:no-repeat;color:transparent;background-clip:text;-webkit-background-clip:text;animation:fill-gray 1.5s forwards;animation-delay:.5s}@keyframes fill-text{0%{background-size:0% 100%;opacity:0}30%{opacity:1}to{background-size:200% 100%;opacity:1}}@keyframes fill-gray{0%{background-size:0% 100%;opacity:0}30%{opacity:1}to{background-size:100% 100%;opacity:1}}:dir(rtl) .welcome-user .hello-gradient{background:linear-gradient(-135deg,#217bfe 0,#078efb 33%,#ac87eb);background-size:200% 100%;background-position:0% center;-webkit-background-clip:text;background-clip:text;color:transparent;-webkit-text-fill-color:transparent;animation:gradient-shine-rtl 1.5s ease-in}@keyframes gradient-shine-rtl{0%{background-position:-200% center;opacity:0}60%{opacity:1}to{background-position:0% center;opacity:1}}:dir(rtl) .welcome-user .welcome-text{background:linear-gradient(270deg,#888 100%,transparent 0%);background-size:0% 100%;background-repeat:no-repeat;background-position:right center;background-clip:text;-webkit-background-clip:text;color:transparent;animation:fill-gray-rtl 1.5s forwards;animation-delay:.5s}@keyframes fill-gray-rtl{0%{background-size:0% 100%;opacity:0}30%{opacity:1}to{background-size:100% 100%;opacity:1}}::ng-deep markdown{width:calc(100% - 28px)}::ng-deep markdown h1{font-size:1em}::ng-deep markdown h2{font-size:.9em}::ng-deep markdown h3{font-size:.8em}::ng-deep markdown h4{font-size:.7em}::ng-deep markdown h5{font-size:.6em}::ng-deep markdown h6{font-size:.5em}::ng-deep markdown p{font-size:.9em;line-height:1.5;margin:8px 0}::ng-deep markdown ul,::ng-deep markdown ol{font-size:.9em;line-height:1.5;margin-inline-start:1.5em;padding:0;list-style-type:disclosure-closed}::ng-deep markdown li{margin-bottom:.5em}::ng-deep markdown blockquote{border-inline-start:4px solid #dfe2e5;padding:.5em 1em;margin:1em 0;background-color:#f6f8fa}::ng-deep markdown code{background-color:#f6f8fa;padding:.2em .4em;border-radius:var(--faris-sm-border-radius);font-family:Courier New,Courier,monospace}::ng-deep markdown table{width:100%;border-collapse:collapse;margin:1em 0}::ng-deep markdown th,::ng-deep markdown td{border:1px solid #dfe2e5;padding:.5em;text-align:start}::ng-deep markdown th{background-color:#f6f8fa;font-weight:700}::ng-deep markdown img{max-width:100%;height:auto;display:block;margin:1em 0}::ng-deep markdown .chart-placeholder{width:100%!important}.thinking{position:absolute;inset-inline-start:0;bottom:110px}#thinkingText{font-size:12px;font-weight:700}@keyframes dots{0%{content:\".\"}33%{content:\"..\"}66%{content:\"...\"}}#dots:after{content:\".\";animation:dots 1s infinite steps(3,end)}\n"] }]
|
|
1517
|
+
}], propDecorators: { selectedConversation: [{
|
|
1518
|
+
type: Input
|
|
1519
|
+
}], launchCanvas: [{
|
|
1520
|
+
type: Output
|
|
1521
|
+
}], selectConversation: [{
|
|
1522
|
+
type: Output
|
|
1523
|
+
}] } });
|
|
1524
|
+
|
|
1525
|
+
class FarisChatHistoryComponent {
|
|
1526
|
+
userConversations = [];
|
|
1527
|
+
showChatHistory = false;
|
|
1528
|
+
selectedConversation = null;
|
|
1529
|
+
selectConversation = new EventEmitter();
|
|
1530
|
+
deleteConversationHandler = new EventEmitter();
|
|
1531
|
+
closeHistory = new EventEmitter();
|
|
1532
|
+
groupedConversations = [];
|
|
1533
|
+
ngOnChanges(changes) {
|
|
1534
|
+
if (changes['userConversations']) {
|
|
1535
|
+
this.groupedConversations = this.groupConversations(this.userConversations || []);
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
onCloseHistory() {
|
|
1539
|
+
this.closeHistory.emit(true);
|
|
1540
|
+
}
|
|
1541
|
+
onSelectConversation(conversation) {
|
|
1542
|
+
this.selectConversation.emit(conversation);
|
|
1543
|
+
}
|
|
1544
|
+
onDeleteConversation(event, id) {
|
|
1545
|
+
event.stopPropagation();
|
|
1546
|
+
this.deleteConversationHandler.emit({ event, id });
|
|
1547
|
+
}
|
|
1548
|
+
groupConversations(conversations) {
|
|
1549
|
+
const normalized = (conversations || []).map((conversation, index) => this.normalizeConversation(conversation, index));
|
|
1550
|
+
const sorted = [...normalized].sort((a, b) => this.resolveConversationTimestamp(b) -
|
|
1551
|
+
this.resolveConversationTimestamp(a));
|
|
1552
|
+
const todayGroup = { label: 'Today', conversations: [] };
|
|
1553
|
+
const yesterdayGroup = {
|
|
1554
|
+
label: 'Yesterday',
|
|
1555
|
+
conversations: [],
|
|
1556
|
+
};
|
|
1557
|
+
const thisWeekGroup = {
|
|
1558
|
+
label: 'This Week',
|
|
1559
|
+
conversations: [],
|
|
1560
|
+
};
|
|
1561
|
+
const lastWeekGroup = {
|
|
1562
|
+
label: 'Last Week',
|
|
1563
|
+
conversations: [],
|
|
1564
|
+
};
|
|
1565
|
+
const monthGroups = new Map();
|
|
1566
|
+
const now = new Date();
|
|
1567
|
+
const todayStart = this.startOfDay(now).getTime();
|
|
1568
|
+
const yesterdayStart = this.startOfDay(this.addDays(now, -1)).getTime();
|
|
1569
|
+
const thisWeekStart = this.startOfWeek(now).getTime();
|
|
1570
|
+
const lastWeekStart = this.startOfWeek(this.addDays(now, -7)).getTime();
|
|
1571
|
+
for (const conversation of sorted) {
|
|
1572
|
+
const updatedDate = this.resolveConversationDate(conversation) ?? now;
|
|
1573
|
+
const updatedStart = this.startOfDay(updatedDate).getTime();
|
|
1574
|
+
if (updatedStart === todayStart) {
|
|
1575
|
+
conversation.displayDate = 'Today';
|
|
1576
|
+
todayGroup.conversations.push(conversation);
|
|
1577
|
+
continue;
|
|
1578
|
+
}
|
|
1579
|
+
if (updatedStart === yesterdayStart) {
|
|
1580
|
+
conversation.displayDate = 'Yesterday';
|
|
1581
|
+
yesterdayGroup.conversations.push(conversation);
|
|
1582
|
+
continue;
|
|
1583
|
+
}
|
|
1584
|
+
if (updatedStart >= thisWeekStart) {
|
|
1585
|
+
conversation.displayDate = this.formatDayMonth(updatedDate);
|
|
1586
|
+
thisWeekGroup.conversations.push(conversation);
|
|
1587
|
+
continue;
|
|
1588
|
+
}
|
|
1589
|
+
if (updatedStart >= lastWeekStart) {
|
|
1590
|
+
conversation.displayDate = this.formatDayMonth(updatedDate);
|
|
1591
|
+
lastWeekGroup.conversations.push(conversation);
|
|
1592
|
+
continue;
|
|
1593
|
+
}
|
|
1594
|
+
const monthLabel = this.formatMonthYear(updatedDate);
|
|
1595
|
+
conversation.displayDate = this.formatDayMonth(updatedDate);
|
|
1596
|
+
if (!monthGroups.has(monthLabel)) {
|
|
1597
|
+
monthGroups.set(monthLabel, {
|
|
1598
|
+
label: monthLabel,
|
|
1599
|
+
conversations: [],
|
|
1600
|
+
sortValue: this.startOfMonth(updatedDate).getTime(),
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
monthGroups.get(monthLabel)?.conversations.push(conversation);
|
|
1604
|
+
}
|
|
1605
|
+
const fixedOrder = [
|
|
1606
|
+
todayGroup,
|
|
1607
|
+
yesterdayGroup,
|
|
1608
|
+
thisWeekGroup,
|
|
1609
|
+
lastWeekGroup,
|
|
1610
|
+
].filter((group) => group.conversations.length > 0);
|
|
1611
|
+
const orderedMonthGroups = Array.from(monthGroups.values()).sort((a, b) => (b.sortValue ?? 0) - (a.sortValue ?? 0));
|
|
1612
|
+
return [...fixedOrder, ...orderedMonthGroups];
|
|
1613
|
+
}
|
|
1614
|
+
formatDayMonth(date) {
|
|
1615
|
+
return new Intl.DateTimeFormat('en', {
|
|
1616
|
+
day: 'numeric',
|
|
1617
|
+
month: 'short',
|
|
1618
|
+
}).format(date);
|
|
1619
|
+
}
|
|
1620
|
+
formatMonthYear(date) {
|
|
1621
|
+
return new Intl.DateTimeFormat('en', {
|
|
1622
|
+
month: 'long',
|
|
1623
|
+
year: 'numeric',
|
|
1624
|
+
}).format(date);
|
|
1625
|
+
}
|
|
1626
|
+
startOfDay(date) {
|
|
1627
|
+
const result = new Date(date);
|
|
1628
|
+
result.setHours(0, 0, 0, 0);
|
|
1629
|
+
return result;
|
|
1630
|
+
}
|
|
1631
|
+
startOfWeek(date) {
|
|
1632
|
+
const result = this.startOfDay(date);
|
|
1633
|
+
const day = result.getDay();
|
|
1634
|
+
result.setDate(result.getDate() - day);
|
|
1635
|
+
return result;
|
|
1636
|
+
}
|
|
1637
|
+
startOfMonth(date) {
|
|
1638
|
+
const result = this.startOfDay(date);
|
|
1639
|
+
result.setDate(1);
|
|
1640
|
+
return result;
|
|
1641
|
+
}
|
|
1642
|
+
addDays(date, days) {
|
|
1643
|
+
const result = new Date(date);
|
|
1644
|
+
result.setDate(result.getDate() + days);
|
|
1645
|
+
return result;
|
|
1646
|
+
}
|
|
1647
|
+
normalizeConversation(conversation, index) {
|
|
1648
|
+
const id = conversation?.id ??
|
|
1649
|
+
conversation?.session_id ??
|
|
1650
|
+
conversation?.sessionId ??
|
|
1651
|
+
conversation?.conversation_id ??
|
|
1652
|
+
conversation?.conversationId ??
|
|
1653
|
+
`conversation-${index}`;
|
|
1654
|
+
const updatedAt = conversation?.updated_at ??
|
|
1655
|
+
conversation?.updatedAt ??
|
|
1656
|
+
conversation?.last_updated_at ??
|
|
1657
|
+
conversation?.lastUpdatedAt ??
|
|
1658
|
+
conversation?.created_at ??
|
|
1659
|
+
conversation?.createdAt ??
|
|
1660
|
+
conversation?.timestamp ??
|
|
1661
|
+
conversation?.date ??
|
|
1662
|
+
null;
|
|
1663
|
+
const title = conversation?.title ??
|
|
1664
|
+
conversation?.conversation_title ??
|
|
1665
|
+
conversation?.conversationTitle ??
|
|
1666
|
+
conversation?.name ??
|
|
1667
|
+
conversation?.subject ??
|
|
1668
|
+
'';
|
|
1669
|
+
return {
|
|
1670
|
+
...conversation,
|
|
1671
|
+
id: String(id),
|
|
1672
|
+
updated_at: updatedAt,
|
|
1673
|
+
title,
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
resolveConversationDate(conversation) {
|
|
1677
|
+
const candidate = conversation?.updated_at;
|
|
1678
|
+
if (!candidate) {
|
|
1679
|
+
return null;
|
|
1680
|
+
}
|
|
1681
|
+
const date = new Date(candidate);
|
|
1682
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
1683
|
+
}
|
|
1684
|
+
resolveConversationTimestamp(conversation) {
|
|
1685
|
+
return this.resolveConversationDate(conversation)?.getTime() ?? 0;
|
|
1686
|
+
}
|
|
1687
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisChatHistoryComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1688
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: FarisChatHistoryComponent, isStandalone: true, selector: "mt-faris-chat-history", inputs: { userConversations: "userConversations", showChatHistory: "showChatHistory", selectedConversation: "selectedConversation" }, outputs: { selectConversation: "selectConversation", deleteConversationHandler: "deleteConversationHandler", closeHistory: "closeHistory" }, usesOnChanges: true, ngImport: i0, template: "<div\r\n class=\"conversations-history\"\r\n [class.closed-chat-history-side]=\"!showChatHistory\"\r\n>\r\n <div class=\"conversations-header\">\r\n <span class=\"conversations-title\">{{\r\n \"faris.chat-history\" | translate\r\n }}</span>\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.x-close\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn\"\r\n (click)=\"onCloseHistory()\"\r\n ></mt-button>\r\n </div>\r\n\r\n <div class=\"conversations-list\">\r\n @for (group of groupedConversations; track group.label) {\r\n <div class=\"conversation-group-header\">{{ group.label }}</div>\r\n\r\n @for (conversation of group.conversations; track conversation.id) {\r\n <div\r\n class=\"conversation-item flex w-full cursor-pointer items-center justify-between gap-2 rounded-md p-2\"\r\n (click)=\"onSelectConversation(conversation)\"\r\n [class.active-conversation]=\"\r\n selectedConversation?.id === conversation.id\r\n \"\r\n >\r\n <mt-icon icon=\"communication.message-chat-circle\"></mt-icon>\r\n\r\n <div class=\"conversation-title-group\">\r\n <div class=\"conversation-title\">\r\n {{ (conversation?.title | parseMention) || \" \" }}\r\n </div>\r\n <div class=\"conversation-subtitle\">\r\n {{ conversation.displayDate }}\r\n </div>\r\n </div>\r\n\r\n <div class=\"conversation-actions\">\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.trash-01\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn faris-btn-muted text-red-600\"\r\n [tooltip]=\"'faris.delete' | translate\"\r\n (click)=\"onDeleteConversation($event, conversation?.id)\"\r\n ></mt-button>\r\n </div>\r\n </div>\r\n }\r\n }\r\n </div>\r\n</div>\r\n", styles: [".conversations-history{display:flex;flex-direction:column;height:100%;background:#f8f9fa;border-inline-end:1px solid #e0e0e0;overflow-y:auto;width:20vw;min-width:220px;max-width:320px;transition:width .2s;overflow-x:hidden}.conversations-history .conversations-header{display:flex;align-items:center;justify-content:space-between;padding:.5em .75em;font-size:1.1em;font-weight:500;color:#333;border-bottom:1px solid #e0e0e0}.conversations-history .conversations-header .history-close-button{display:flex;align-items:center;justify-content:center;border:1px solid transparent;background-color:transparent;border-radius:var(--faris-sm-border-radius);width:2em;height:2em;cursor:pointer;font-size:1.1em;padding:0;transition:all .2s ease}.conversations-history .conversations-header .history-close-button:hover{background-color:#0000000d}.conversations-history .conversations-list{display:flex;flex-direction:column;padding:.5em;gap:.5em;overflow-y:auto;height:calc(100vh - 50px)}.conversations-history .conversation-title-group{flex:1;overflow:hidden}.conversations-history .conversation-title-group .conversation-title{font-size:.98em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:inherit}.conversations-history .conversation-title-group .conversation-subtitle{font-size:.9em;opacity:.8}.conversations-history .conversation-group-header{margin-top:1em;margin-bottom:.5em;font-size:1.1em}.conversations-history .conversation-item{cursor:pointer;color:#333;border-radius:var(--faris-border-radius);transition:background .15s;-webkit-user-select:none;user-select:none}.conversations-history .conversation-item .conversation-actions{display:flex;align-items:center;gap:.5em;opacity:0;transition:all .2s ease}.conversations-history .conversation-item:hover .conversation-actions{opacity:1}.conversations-history mt-icon{font-size:1.2em}.conversations-history .conversation-item{gap:.5em}.conversations-history .conversation-item.active,.conversations-history .conversation-item.active-conversation{background:#e3f2fd;color:var(--primary-color);font-weight:600}.conversations-history .conversation-item:hover:not(.active-conversation){background:#f1f1f1}.closed-chat-history-side{width:0px!important;min-width:0px!important;border-inline-end:none!important}\n"], dependencies: [{ kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "pipe", type: FarisTranslatePipe, name: "translate" }, { kind: "pipe", type: ParseMentionPipe, name: "parseMention" }] });
|
|
1689
|
+
}
|
|
1690
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisChatHistoryComponent, decorators: [{
|
|
1691
|
+
type: Component,
|
|
1692
|
+
args: [{ selector: 'mt-faris-chat-history', standalone: true, imports: [FarisTranslatePipe, ParseMentionPipe, Button, Icon], template: "<div\r\n class=\"conversations-history\"\r\n [class.closed-chat-history-side]=\"!showChatHistory\"\r\n>\r\n <div class=\"conversations-header\">\r\n <span class=\"conversations-title\">{{\r\n \"faris.chat-history\" | translate\r\n }}</span>\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.x-close\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn\"\r\n (click)=\"onCloseHistory()\"\r\n ></mt-button>\r\n </div>\r\n\r\n <div class=\"conversations-list\">\r\n @for (group of groupedConversations; track group.label) {\r\n <div class=\"conversation-group-header\">{{ group.label }}</div>\r\n\r\n @for (conversation of group.conversations; track conversation.id) {\r\n <div\r\n class=\"conversation-item flex w-full cursor-pointer items-center justify-between gap-2 rounded-md p-2\"\r\n (click)=\"onSelectConversation(conversation)\"\r\n [class.active-conversation]=\"\r\n selectedConversation?.id === conversation.id\r\n \"\r\n >\r\n <mt-icon icon=\"communication.message-chat-circle\"></mt-icon>\r\n\r\n <div class=\"conversation-title-group\">\r\n <div class=\"conversation-title\">\r\n {{ (conversation?.title | parseMention) || \" \" }}\r\n </div>\r\n <div class=\"conversation-subtitle\">\r\n {{ conversation.displayDate }}\r\n </div>\r\n </div>\r\n\r\n <div class=\"conversation-actions\">\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.trash-01\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn faris-btn-muted text-red-600\"\r\n [tooltip]=\"'faris.delete' | translate\"\r\n (click)=\"onDeleteConversation($event, conversation?.id)\"\r\n ></mt-button>\r\n </div>\r\n </div>\r\n }\r\n }\r\n </div>\r\n</div>\r\n", styles: [".conversations-history{display:flex;flex-direction:column;height:100%;background:#f8f9fa;border-inline-end:1px solid #e0e0e0;overflow-y:auto;width:20vw;min-width:220px;max-width:320px;transition:width .2s;overflow-x:hidden}.conversations-history .conversations-header{display:flex;align-items:center;justify-content:space-between;padding:.5em .75em;font-size:1.1em;font-weight:500;color:#333;border-bottom:1px solid #e0e0e0}.conversations-history .conversations-header .history-close-button{display:flex;align-items:center;justify-content:center;border:1px solid transparent;background-color:transparent;border-radius:var(--faris-sm-border-radius);width:2em;height:2em;cursor:pointer;font-size:1.1em;padding:0;transition:all .2s ease}.conversations-history .conversations-header .history-close-button:hover{background-color:#0000000d}.conversations-history .conversations-list{display:flex;flex-direction:column;padding:.5em;gap:.5em;overflow-y:auto;height:calc(100vh - 50px)}.conversations-history .conversation-title-group{flex:1;overflow:hidden}.conversations-history .conversation-title-group .conversation-title{font-size:.98em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:inherit}.conversations-history .conversation-title-group .conversation-subtitle{font-size:.9em;opacity:.8}.conversations-history .conversation-group-header{margin-top:1em;margin-bottom:.5em;font-size:1.1em}.conversations-history .conversation-item{cursor:pointer;color:#333;border-radius:var(--faris-border-radius);transition:background .15s;-webkit-user-select:none;user-select:none}.conversations-history .conversation-item .conversation-actions{display:flex;align-items:center;gap:.5em;opacity:0;transition:all .2s ease}.conversations-history .conversation-item:hover .conversation-actions{opacity:1}.conversations-history mt-icon{font-size:1.2em}.conversations-history .conversation-item{gap:.5em}.conversations-history .conversation-item.active,.conversations-history .conversation-item.active-conversation{background:#e3f2fd;color:var(--primary-color);font-weight:600}.conversations-history .conversation-item:hover:not(.active-conversation){background:#f1f1f1}.closed-chat-history-side{width:0px!important;min-width:0px!important;border-inline-end:none!important}\n"] }]
|
|
1693
|
+
}], propDecorators: { userConversations: [{
|
|
1694
|
+
type: Input
|
|
1695
|
+
}], showChatHistory: [{
|
|
1696
|
+
type: Input
|
|
1697
|
+
}], selectedConversation: [{
|
|
1698
|
+
type: Input
|
|
1699
|
+
}], selectConversation: [{
|
|
1700
|
+
type: Output
|
|
1701
|
+
}], deleteConversationHandler: [{
|
|
1702
|
+
type: Output
|
|
1703
|
+
}], closeHistory: [{
|
|
1704
|
+
type: Output
|
|
1705
|
+
}] } });
|
|
1706
|
+
|
|
1707
|
+
class MinimizablePopupComponent {
|
|
1708
|
+
title = '';
|
|
1709
|
+
maximized = false;
|
|
1710
|
+
closed = new EventEmitter();
|
|
1711
|
+
direction = 'ltr';
|
|
1712
|
+
isClosing = false;
|
|
1713
|
+
document = inject(DOCUMENT);
|
|
1714
|
+
ngOnInit() {
|
|
1715
|
+
this.document.body.style.overflow = 'hidden';
|
|
1716
|
+
this.direction =
|
|
1717
|
+
this.document.documentElement.dir === 'rtl' ? 'rtl' : 'ltr';
|
|
1718
|
+
}
|
|
1719
|
+
ngOnDestroy() {
|
|
1720
|
+
this.document.body.style.overflow = 'auto';
|
|
1721
|
+
}
|
|
1722
|
+
get enterTransform() {
|
|
1723
|
+
return this.direction === 'rtl' ? 'translateX(-100%)' : 'translateX(100%)';
|
|
1724
|
+
}
|
|
1725
|
+
get leaveTransform() {
|
|
1726
|
+
return this.direction === 'rtl' ? 'translateX(-100%)' : 'translateX(100%)';
|
|
1727
|
+
}
|
|
1728
|
+
close() {
|
|
1729
|
+
this.isClosing = true;
|
|
1730
|
+
}
|
|
1731
|
+
onAnimationDone(event) {
|
|
1732
|
+
if (event.toState === 'void' && this.isClosing) {
|
|
1733
|
+
this.closed.emit(true);
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MinimizablePopupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1737
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: MinimizablePopupComponent, isStandalone: true, selector: "mt-faris-popup", inputs: { title: "title", maximized: "maximized" }, outputs: { closed: "closed" }, ngImport: i0, template: "<div class=\"custom-window-backdrop\"></div>\r\n@if (!isClosing) {\r\n <div\r\n class=\"custom-window-modal\"\r\n [@slideInOut]=\"{\r\n value: '',\r\n params: {\r\n enterTransform: enterTransform,\r\n leaveTransform: leaveTransform,\r\n },\r\n }\"\r\n (@slideInOut.done)=\"onAnimationDone($event)\"\r\n >\r\n <ng-content select=\"[panelCanvas]\"></ng-content>\r\n <div class=\"custom-window-container\" [class.maximized]=\"maximized\">\r\n <ng-content select=\"[panelSidebar]\"></ng-content>\r\n <div class=\"resizable-panel\">\r\n <div class=\"panel-content\">\r\n <div\r\n class=\"modal-header flex items-center justify-between p-4 border-bottom-1 border-b border-surface-300\"\r\n >\r\n <h5 class=\"modal-title custom-window-title\">\r\n <ng-content select=\"[panelTitle]\"></ng-content>\r\n </h5>\r\n <div class=\"modal-controls flex items-center\">\r\n <ng-content select=\"[panelActions]\"></ng-content>\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.x-close\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn\"\r\n (click)=\"close()\"\r\n ></mt-button>\r\n </div>\r\n </div>\r\n <div class=\"modal-body w-full\">\r\n <ng-content select=\"[panelChat]\"></ng-content>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n}\r\n", styles: ["@keyframes smooth-appear{0%{opacity:0}to{opacity:1}}:host{display:block;position:fixed;inset:0;z-index:1501!important}.custom-window-backdrop{position:fixed;inset:0;background-color:#0003;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);z-index:1500!important}.custom-window-modal{position:relative;display:flex;justify-content:flex-end;z-index:1501!important}.custom-window-modal .modal-header{background:#fff;border-radius:0!important}.custom-window-modal .modal-controls{display:flex;align-items:center;justify-content:flex-end;gap:.5em}.custom-window-modal .modal-controls button{margin-left:.25em}.custom-window-modal .modal-body{height:calc(100% - 79px)!important;max-height:100%!important;padding:1em 0!important}.custom-window-modal .custom-window-container{display:flex;justify-content:flex-end;transition:all .4s ease}.custom-window-modal .custom-window-container.maximized,.custom-window-modal .custom-window-container.maximized .resizable-panel{flex:1}.custom-window-title{flex:1;overflow:hidden}.minimized-tab{position:fixed;bottom:10px;left:0;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.resizable-container{position:fixed;inset:0;display:flex;justify-content:flex-end;pointer-events:none;transition:all .4s ease;transform:translate(0);align-items:end}.resizable-container.resizing{background-color:#0000001a;pointer-events:auto}.resizable-panel{position:relative;flex:1;width:35vw;min-width:600px;height:100vh;background:#fff;pointer-events:auto;display:flex;flex-direction:column;align-items:end}.resize-handle{height:6px;cursor:ns-resize;background:#ccc;position:absolute;top:0;left:0;right:0}.resize-handle.horizontal{width:3px;height:100%;cursor:ew-resize;z-index:1500}.panel-content{flex:1;overflow:auto;width:100%}.custom-close-badge{top:-30%;right:-10%}.minimized-tab-1{left:115px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-2{left:230px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-3{left:345px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-4{left:460px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-5{left:575px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-6{left:690px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-7{left:805px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-8{left:920px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-9{left:1035px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-10{left:1150px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-11{left:1265px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-12{left:1380px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-13{left:1495px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-14{left:1610px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-15{left:1725px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-16{left:1840px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-17{left:1955px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-18{left:2070px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-19{left:2185px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-20{left:2300px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-1{right:115px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-2{right:230px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-3{right:345px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-4{right:460px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-5{right:575px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-6{right:690px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-7{right:805px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-8{right:920px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-9{right:1035px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-10{right:1150px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-11{right:1265px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-12{right:1380px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-13{right:1495px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-14{right:1610px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-15{right:1725px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-16{right:1840px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-17{right:1955px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-18{right:2070px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-19{right:2185px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-20{right:2300px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .custom-close-badge{left:-10%;right:auto}\n"], dependencies: [{ kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }], animations: [
|
|
1738
|
+
trigger('slideInOut', [
|
|
1739
|
+
transition(':enter', [
|
|
1740
|
+
style({ transform: '{{enterTransform}}' }),
|
|
1741
|
+
animate('300ms cubic-bezier(0.4,0,0.2,1)', style({ transform: 'translateX(0)' })),
|
|
1742
|
+
], { params: { enterTransform: 'translateX(100%)' } }),
|
|
1743
|
+
transition(':leave', [
|
|
1744
|
+
animate('300ms cubic-bezier(0.4,0,0.2,1)', style({ transform: '{{leaveTransform}}' })),
|
|
1745
|
+
], { params: { leaveTransform: 'translateX(100%)' } }),
|
|
1746
|
+
]),
|
|
1747
|
+
] });
|
|
1748
|
+
}
|
|
1749
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MinimizablePopupComponent, decorators: [{
|
|
1750
|
+
type: Component,
|
|
1751
|
+
args: [{ selector: 'mt-faris-popup', standalone: true, imports: [Button], animations: [
|
|
1752
|
+
trigger('slideInOut', [
|
|
1753
|
+
transition(':enter', [
|
|
1754
|
+
style({ transform: '{{enterTransform}}' }),
|
|
1755
|
+
animate('300ms cubic-bezier(0.4,0,0.2,1)', style({ transform: 'translateX(0)' })),
|
|
1756
|
+
], { params: { enterTransform: 'translateX(100%)' } }),
|
|
1757
|
+
transition(':leave', [
|
|
1758
|
+
animate('300ms cubic-bezier(0.4,0,0.2,1)', style({ transform: '{{leaveTransform}}' })),
|
|
1759
|
+
], { params: { leaveTransform: 'translateX(100%)' } }),
|
|
1760
|
+
]),
|
|
1761
|
+
], template: "<div class=\"custom-window-backdrop\"></div>\r\n@if (!isClosing) {\r\n <div\r\n class=\"custom-window-modal\"\r\n [@slideInOut]=\"{\r\n value: '',\r\n params: {\r\n enterTransform: enterTransform,\r\n leaveTransform: leaveTransform,\r\n },\r\n }\"\r\n (@slideInOut.done)=\"onAnimationDone($event)\"\r\n >\r\n <ng-content select=\"[panelCanvas]\"></ng-content>\r\n <div class=\"custom-window-container\" [class.maximized]=\"maximized\">\r\n <ng-content select=\"[panelSidebar]\"></ng-content>\r\n <div class=\"resizable-panel\">\r\n <div class=\"panel-content\">\r\n <div\r\n class=\"modal-header flex items-center justify-between p-4 border-bottom-1 border-b border-surface-300\"\r\n >\r\n <h5 class=\"modal-title custom-window-title\">\r\n <ng-content select=\"[panelTitle]\"></ng-content>\r\n </h5>\r\n <div class=\"modal-controls flex items-center\">\r\n <ng-content select=\"[panelActions]\"></ng-content>\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.x-close\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn\"\r\n (click)=\"close()\"\r\n ></mt-button>\r\n </div>\r\n </div>\r\n <div class=\"modal-body w-full\">\r\n <ng-content select=\"[panelChat]\"></ng-content>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n}\r\n", styles: ["@keyframes smooth-appear{0%{opacity:0}to{opacity:1}}:host{display:block;position:fixed;inset:0;z-index:1501!important}.custom-window-backdrop{position:fixed;inset:0;background-color:#0003;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);z-index:1500!important}.custom-window-modal{position:relative;display:flex;justify-content:flex-end;z-index:1501!important}.custom-window-modal .modal-header{background:#fff;border-radius:0!important}.custom-window-modal .modal-controls{display:flex;align-items:center;justify-content:flex-end;gap:.5em}.custom-window-modal .modal-controls button{margin-left:.25em}.custom-window-modal .modal-body{height:calc(100% - 79px)!important;max-height:100%!important;padding:1em 0!important}.custom-window-modal .custom-window-container{display:flex;justify-content:flex-end;transition:all .4s ease}.custom-window-modal .custom-window-container.maximized,.custom-window-modal .custom-window-container.maximized .resizable-panel{flex:1}.custom-window-title{flex:1;overflow:hidden}.minimized-tab{position:fixed;bottom:10px;left:0;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.resizable-container{position:fixed;inset:0;display:flex;justify-content:flex-end;pointer-events:none;transition:all .4s ease;transform:translate(0);align-items:end}.resizable-container.resizing{background-color:#0000001a;pointer-events:auto}.resizable-panel{position:relative;flex:1;width:35vw;min-width:600px;height:100vh;background:#fff;pointer-events:auto;display:flex;flex-direction:column;align-items:end}.resize-handle{height:6px;cursor:ns-resize;background:#ccc;position:absolute;top:0;left:0;right:0}.resize-handle.horizontal{width:3px;height:100%;cursor:ew-resize;z-index:1500}.panel-content{flex:1;overflow:auto;width:100%}.custom-close-badge{top:-30%;right:-10%}.minimized-tab-1{left:115px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-2{left:230px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-3{left:345px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-4{left:460px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-5{left:575px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-6{left:690px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-7{left:805px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-8{left:920px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-9{left:1035px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-10{left:1150px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-11{left:1265px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-12{left:1380px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-13{left:1495px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-14{left:1610px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-15{left:1725px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-16{left:1840px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-17{left:1955px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-18{left:2070px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-19{left:2185px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}.minimized-tab-20{left:2300px;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-1{right:115px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-2{right:230px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-3{right:345px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-4{right:460px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-5{right:575px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-6{right:690px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-7{right:805px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-8{right:920px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-9{right:1035px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-10{right:1150px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-11{right:1265px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-12{right:1380px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-13{right:1495px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-14{right:1610px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-15{right:1725px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-16{right:1840px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-17{right:1955px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-18{right:2070px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-19{right:2185px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .minimized-tab-20{right:2300px;left:auto;position:fixed;bottom:10px;z-index:1501;background-color:var(--primary-color, #2a2e34);color:#fff;border:none;padding:.5em 1em;border-radius:.25em;cursor:pointer}::ng-deep [lang=ar] .custom-close-badge{left:-10%;right:auto}\n"] }]
|
|
1762
|
+
}], propDecorators: { title: [{
|
|
1763
|
+
type: Input
|
|
1764
|
+
}], maximized: [{
|
|
1765
|
+
type: Input
|
|
1766
|
+
}], closed: [{
|
|
1767
|
+
type: Output
|
|
1768
|
+
}] } });
|
|
1769
|
+
|
|
1770
|
+
const initialCanvasData = {
|
|
1771
|
+
visible: false,
|
|
1772
|
+
message: null,
|
|
1773
|
+
conversationId: null,
|
|
1774
|
+
};
|
|
1775
|
+
class FarisComponent {
|
|
1776
|
+
showChatBot = false;
|
|
1777
|
+
showChatBotChange = new EventEmitter();
|
|
1778
|
+
showChatHistory = false;
|
|
1779
|
+
userConversations = [];
|
|
1780
|
+
selectedConversation = null;
|
|
1781
|
+
canvasData = initialCanvasData;
|
|
1782
|
+
maximized = false;
|
|
1783
|
+
subscription;
|
|
1784
|
+
subscriptions = new Subscription();
|
|
1785
|
+
farisService = inject(FarisService);
|
|
1786
|
+
confirmationService = inject(ConfirmationService);
|
|
1787
|
+
getUserDetails() {
|
|
1788
|
+
this.subscriptions.add(this.farisService.getUserDetails().subscribe());
|
|
1789
|
+
}
|
|
1790
|
+
ngOnChanges(changes) {
|
|
1791
|
+
if (!changes['showChatBot']) {
|
|
1792
|
+
return;
|
|
1793
|
+
}
|
|
1794
|
+
if (changes['showChatBot'].currentValue) {
|
|
1795
|
+
this.onChatOpened();
|
|
1796
|
+
return;
|
|
1797
|
+
}
|
|
1798
|
+
this.onChatClosed();
|
|
1799
|
+
}
|
|
1800
|
+
launchCanvas(item) {
|
|
1801
|
+
this.canvasData = {
|
|
1802
|
+
visible: true,
|
|
1803
|
+
message: item,
|
|
1804
|
+
conversationId: this.selectedConversation?.id ?? null,
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
onDeleteConversationHandler({ event, id, }) {
|
|
1808
|
+
this.confirmationService.confirmDelete({
|
|
1809
|
+
event,
|
|
1810
|
+
type: 'popup',
|
|
1811
|
+
accept: () => {
|
|
1812
|
+
this.deleteConversation(id);
|
|
1813
|
+
},
|
|
1814
|
+
reject: () => { },
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
deleteConversation(id) {
|
|
1818
|
+
this.subscriptions.add(this.farisService.deleteConversation(String(id)).subscribe(() => {
|
|
1819
|
+
if (id === this.selectedConversation?.id) {
|
|
1820
|
+
this.openNewChat();
|
|
1821
|
+
}
|
|
1822
|
+
setTimeout(() => {
|
|
1823
|
+
this.getUserDetails();
|
|
1824
|
+
}, 250);
|
|
1825
|
+
}));
|
|
1826
|
+
}
|
|
1827
|
+
selectConversation(conversation) {
|
|
1828
|
+
if (this.selectedConversation !== conversation) {
|
|
1829
|
+
this.selectedConversation = conversation;
|
|
1830
|
+
this.canvasData = initialCanvasData;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
onSelectConversation(conversation) {
|
|
1834
|
+
this.selectConversation(conversation);
|
|
1835
|
+
}
|
|
1836
|
+
onCloseHistory() {
|
|
1837
|
+
this.showChatHistory = false;
|
|
1838
|
+
}
|
|
1839
|
+
toggleChatHistory() {
|
|
1840
|
+
this.showChatHistory = !this.showChatHistory;
|
|
1841
|
+
if (this.showChatHistory) {
|
|
1842
|
+
this.getUserDetails();
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
openFarisChat() {
|
|
1846
|
+
this.showChatBot = !this.showChatBot;
|
|
1847
|
+
this.showChatBotChange.emit(this.showChatBot);
|
|
1848
|
+
if (this.showChatBot) {
|
|
1849
|
+
this.onChatOpened();
|
|
1850
|
+
return;
|
|
1851
|
+
}
|
|
1852
|
+
this.onChatClosed();
|
|
1853
|
+
}
|
|
1854
|
+
getUniqueArrayByProperty(array) {
|
|
1855
|
+
const uniqueMap = new Map();
|
|
1856
|
+
array.forEach((item, index) => {
|
|
1857
|
+
const key = item?.id ??
|
|
1858
|
+
item?.session_id ??
|
|
1859
|
+
item?.sessionId ??
|
|
1860
|
+
item?.conversation_id ??
|
|
1861
|
+
item?.conversationId ??
|
|
1862
|
+
`conversation-${index}`;
|
|
1863
|
+
uniqueMap.set(String(key), item);
|
|
1864
|
+
});
|
|
1865
|
+
return Array.from(uniqueMap.values());
|
|
1866
|
+
}
|
|
1867
|
+
closeChatBot() {
|
|
1868
|
+
this.showChatBot = false;
|
|
1869
|
+
this.showChatBotChange.emit(false);
|
|
1870
|
+
this.onChatClosed();
|
|
1871
|
+
this.selectedConversation = null;
|
|
1872
|
+
this.maximized = false;
|
|
1873
|
+
this.canvasData = initialCanvasData;
|
|
1874
|
+
}
|
|
1875
|
+
openNewChat() {
|
|
1876
|
+
this.selectConversation(null);
|
|
1877
|
+
}
|
|
1878
|
+
ngOnDestroy() {
|
|
1879
|
+
if (this.subscription && !this.subscription.closed) {
|
|
1880
|
+
this.subscription.unsubscribe();
|
|
1881
|
+
}
|
|
1882
|
+
if (!this.subscriptions.closed) {
|
|
1883
|
+
this.subscriptions.unsubscribe();
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
onChatOpened() {
|
|
1887
|
+
this.getUserDetails();
|
|
1888
|
+
if (this.subscription && !this.subscription.closed) {
|
|
1889
|
+
return;
|
|
1890
|
+
}
|
|
1891
|
+
this.subscriptions.add((this.subscription = this.farisService.conversations.subscribe((value) => {
|
|
1892
|
+
if (!value.length) {
|
|
1893
|
+
this.selectConversation(null);
|
|
1894
|
+
}
|
|
1895
|
+
this.userConversations = this.getUniqueArrayByProperty(value);
|
|
1896
|
+
})));
|
|
1897
|
+
}
|
|
1898
|
+
onChatClosed() {
|
|
1899
|
+
this.farisService.conversations.next([]);
|
|
1900
|
+
this.showChatHistory = false;
|
|
1901
|
+
this.userConversations = [];
|
|
1902
|
+
this.farisService.clearSession();
|
|
1903
|
+
if (this.subscription && !this.subscription.closed) {
|
|
1904
|
+
this.subscription.unsubscribe();
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1908
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: FarisComponent, isStandalone: true, selector: "mt-faris", inputs: { showChatBot: "showChatBot" }, outputs: { showChatBotChange: "showChatBotChange" }, usesOnChanges: true, ngImport: i0, template: "@if (showChatBot) {\r\n <mt-faris-popup\r\n class=\"chat-bot-popup\"\r\n [maximized]=\"maximized && !canvasData.visible\"\r\n (closed)=\"closeChatBot()\"\r\n >\r\n <div panelTitle class=\"faris-title-container\">\r\n <div class=\"gemini-ic has-hover\">\r\n <svg\r\n focusable=\"false\"\r\n viewBox=\"0 -960 960 960\"\r\n height=\"28\"\r\n width=\"28\"\r\n class=\"EiVpKc aoH\"\r\n >\r\n <path\r\n d=\"M480-80q2,0 2-2q0-82 31-154t85-126t126-85t154-31q2,0 2-2t-2-2q-82,0-154-31T598-598T513-724T482-878q0-2-2-2t-2,2q0,82-31,154T362-598T236-513T82-482q-2,0-2,2t2,2q82,0 154,31t126,85t85,126T478-82q0,2 2,2Z\"\r\n ></path>\r\n </svg>\r\n </div>\r\n <div class=\"faris-title-group\">\r\n <div class=\"faris-title\">Ask Faris</div>\r\n <div\r\n class=\"faris-subtitle\"\r\n [title]=\"(selectedConversation?.title | parseMention) ?? ''\"\r\n >\r\n {{\r\n (selectedConversation?.title | parseMention) ||\r\n (\"faris.new-conversation\" | translate)\r\n }}\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <ng-container panelActions>\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.plus\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn\"\r\n (click)=\"openNewChat()\"\r\n ></mt-button>\r\n <mt-button\r\n type=\"button\"\r\n [icon]=\"maximized ? 'layout.minimize-02' : 'layout.maximize-02'\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn\"\r\n (click)=\"maximized = !maximized\"\r\n ></mt-button>\r\n <mt-button\r\n type=\"button\"\r\n icon=\"custom.history-sp\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn\"\r\n (click)=\"toggleChatHistory()\"\r\n ></mt-button>\r\n </ng-container>\r\n\r\n @if (canvasData.visible) {\r\n <mt-faris-canvas\r\n [message]=\"canvasData.message\"\r\n [conversationId]=\"canvasData.conversationId\"\r\n class=\"flex-1\"\r\n panelCanvas\r\n (closed)=\"canvasData.visible = false\"\r\n ></mt-faris-canvas>\r\n }\r\n\r\n <mt-faris-chat-history\r\n panelSidebar\r\n [userConversations]=\"userConversations\"\r\n [showChatHistory]=\"showChatHistory\"\r\n [selectedConversation]=\"selectedConversation\"\r\n (selectConversation)=\"onSelectConversation($event)\"\r\n (deleteConversationHandler)=\"onDeleteConversationHandler($event)\"\r\n (closeHistory)=\"onCloseHistory()\"\r\n >\r\n </mt-faris-chat-history>\r\n\r\n <div panelChat class=\"flex h-full w-full\">\r\n <mt-faris-chat\r\n class=\"w-full\"\r\n (launchCanvas)=\"launchCanvas($event)\"\r\n (selectConversation)=\"onSelectConversation($event)\"\r\n [selectedConversation]=\"selectedConversation\"\r\n >\r\n </mt-faris-chat>\r\n </div>\r\n </mt-faris-popup>\r\n}\r\n", styles: [":host{font-size:15.4545px}::ng-deep :root{--faris-border-radius: 8px;--faris-sm-border-radius: 5px;--faris-lg-border-radius: 10px}::ng-deep .faris-btn{display:flex;align-items:center;justify-content:center;border:1px solid transparent;background-color:transparent;border-radius:var(--faris-sm-border-radius);width:2em;height:2em;cursor:pointer;font-size:1.1em;padding:0;transition:all .2s ease}::ng-deep .faris-btn-muted{color:#99a1af}::ng-deep .faris-btn:hover{background-color:#0000000d}::ng-deep .faris-btn-lg{width:2.5em;height:2.5em;font-size:1.4em}::ng-deep .faris-btn:disabled{cursor:not-allowed;opacity:.7}::ng-deep .gemini-ic{display:inline-block;cursor:pointer;transition:transform .3s ease;transform-origin:center center;position:relative}::ng-deep .gemini-ic svg{fill:#4a90e2;transition:fill .3s ease;filter:drop-shadow(0 0 2px rgba(74,144,226,.5))}::ng-deep .gemini-ic.has-hover:hover{animation:gemini-hover-animation 1.5s infinite alternate ease-in-out;transform-origin:center center}::ng-deep .gemini-ic:hover svg{fill:#4a90e2;filter:drop-shadow(0 0 8px rgba(123,207,255,.9))}::ng-deep .gemini-ic.rotating{display:flex;width:22px;height:22px;animation:rotate 2s linear infinite;transform-origin:center center}@keyframes gemini-hover-animation{0%{transform:scale(1) rotate(0);filter:drop-shadow(0 0 2px rgba(74,144,226,.5))}50%{transform:scale(1.15) rotate(10deg);filter:drop-shadow(0 0 12px rgb(123,207,255))}to{transform:scale(1) rotate(-10deg);filter:drop-shadow(0 0 2px rgba(74,144,226,.5))}}@keyframes rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.faris-title-container{display:flex;align-items:center;font-weight:500;gap:.5em;overflow:hidden}.faris-title-container .faris-title-group{flex:1;overflow:hidden}.faris-title-container .faris-title-group .faris-title{font-size:1em}.faris-title-container .faris-title-group .faris-subtitle{font-size:.9em;opacity:.8;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.closed-chat-history-side{min-width:60px!important}.hide-shadow-btn:focus{box-shadow:none!important}.conversation-item{height:40px}.conversation-item.active-conversation{background-color:var(--primary-color);color:var(--white)}.conversation-item.active-conversation mt-icon{color:var(--white)}.conversation-item label{font-size:15px;font-weight:600;line-height:20px}\n"], dependencies: [{ kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: MinimizablePopupComponent, selector: "mt-faris-popup", inputs: ["title", "maximized"], outputs: ["closed"] }, { kind: "component", type: FarisCanvasComponent, selector: "mt-faris-canvas", inputs: ["message", "conversationId"], outputs: ["closed"] }, { kind: "component", type: FarisChatHistoryComponent, selector: "mt-faris-chat-history", inputs: ["userConversations", "showChatHistory", "selectedConversation"], outputs: ["selectConversation", "deleteConversationHandler", "closeHistory"] }, { kind: "component", type: FarisChatComponent, selector: "mt-faris-chat", inputs: ["selectedConversation"], outputs: ["launchCanvas", "selectConversation"] }, { kind: "pipe", type: ParseMentionPipe, name: "parseMention" }, { kind: "pipe", type: FarisTranslatePipe, name: "translate" }] });
|
|
1909
|
+
}
|
|
1910
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FarisComponent, decorators: [{
|
|
1911
|
+
type: Component,
|
|
1912
|
+
args: [{ selector: 'mt-faris', standalone: true, imports: [
|
|
1913
|
+
Button,
|
|
1914
|
+
MinimizablePopupComponent,
|
|
1915
|
+
ParseMentionPipe,
|
|
1916
|
+
FarisTranslatePipe,
|
|
1917
|
+
FarisCanvasComponent,
|
|
1918
|
+
FarisChatHistoryComponent,
|
|
1919
|
+
FarisChatComponent,
|
|
1920
|
+
], template: "@if (showChatBot) {\r\n <mt-faris-popup\r\n class=\"chat-bot-popup\"\r\n [maximized]=\"maximized && !canvasData.visible\"\r\n (closed)=\"closeChatBot()\"\r\n >\r\n <div panelTitle class=\"faris-title-container\">\r\n <div class=\"gemini-ic has-hover\">\r\n <svg\r\n focusable=\"false\"\r\n viewBox=\"0 -960 960 960\"\r\n height=\"28\"\r\n width=\"28\"\r\n class=\"EiVpKc aoH\"\r\n >\r\n <path\r\n d=\"M480-80q2,0 2-2q0-82 31-154t85-126t126-85t154-31q2,0 2-2t-2-2q-82,0-154-31T598-598T513-724T482-878q0-2-2-2t-2,2q0,82-31,154T362-598T236-513T82-482q-2,0-2,2t2,2q82,0 154,31t126,85t85,126T478-82q0,2 2,2Z\"\r\n ></path>\r\n </svg>\r\n </div>\r\n <div class=\"faris-title-group\">\r\n <div class=\"faris-title\">Ask Faris</div>\r\n <div\r\n class=\"faris-subtitle\"\r\n [title]=\"(selectedConversation?.title | parseMention) ?? ''\"\r\n >\r\n {{\r\n (selectedConversation?.title | parseMention) ||\r\n (\"faris.new-conversation\" | translate)\r\n }}\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <ng-container panelActions>\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.plus\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn\"\r\n (click)=\"openNewChat()\"\r\n ></mt-button>\r\n <mt-button\r\n type=\"button\"\r\n [icon]=\"maximized ? 'layout.minimize-02' : 'layout.maximize-02'\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn\"\r\n (click)=\"maximized = !maximized\"\r\n ></mt-button>\r\n <mt-button\r\n type=\"button\"\r\n icon=\"custom.history-sp\"\r\n variant=\"text\"\r\n styleClass=\"faris-btn\"\r\n (click)=\"toggleChatHistory()\"\r\n ></mt-button>\r\n </ng-container>\r\n\r\n @if (canvasData.visible) {\r\n <mt-faris-canvas\r\n [message]=\"canvasData.message\"\r\n [conversationId]=\"canvasData.conversationId\"\r\n class=\"flex-1\"\r\n panelCanvas\r\n (closed)=\"canvasData.visible = false\"\r\n ></mt-faris-canvas>\r\n }\r\n\r\n <mt-faris-chat-history\r\n panelSidebar\r\n [userConversations]=\"userConversations\"\r\n [showChatHistory]=\"showChatHistory\"\r\n [selectedConversation]=\"selectedConversation\"\r\n (selectConversation)=\"onSelectConversation($event)\"\r\n (deleteConversationHandler)=\"onDeleteConversationHandler($event)\"\r\n (closeHistory)=\"onCloseHistory()\"\r\n >\r\n </mt-faris-chat-history>\r\n\r\n <div panelChat class=\"flex h-full w-full\">\r\n <mt-faris-chat\r\n class=\"w-full\"\r\n (launchCanvas)=\"launchCanvas($event)\"\r\n (selectConversation)=\"onSelectConversation($event)\"\r\n [selectedConversation]=\"selectedConversation\"\r\n >\r\n </mt-faris-chat>\r\n </div>\r\n </mt-faris-popup>\r\n}\r\n", styles: [":host{font-size:15.4545px}::ng-deep :root{--faris-border-radius: 8px;--faris-sm-border-radius: 5px;--faris-lg-border-radius: 10px}::ng-deep .faris-btn{display:flex;align-items:center;justify-content:center;border:1px solid transparent;background-color:transparent;border-radius:var(--faris-sm-border-radius);width:2em;height:2em;cursor:pointer;font-size:1.1em;padding:0;transition:all .2s ease}::ng-deep .faris-btn-muted{color:#99a1af}::ng-deep .faris-btn:hover{background-color:#0000000d}::ng-deep .faris-btn-lg{width:2.5em;height:2.5em;font-size:1.4em}::ng-deep .faris-btn:disabled{cursor:not-allowed;opacity:.7}::ng-deep .gemini-ic{display:inline-block;cursor:pointer;transition:transform .3s ease;transform-origin:center center;position:relative}::ng-deep .gemini-ic svg{fill:#4a90e2;transition:fill .3s ease;filter:drop-shadow(0 0 2px rgba(74,144,226,.5))}::ng-deep .gemini-ic.has-hover:hover{animation:gemini-hover-animation 1.5s infinite alternate ease-in-out;transform-origin:center center}::ng-deep .gemini-ic:hover svg{fill:#4a90e2;filter:drop-shadow(0 0 8px rgba(123,207,255,.9))}::ng-deep .gemini-ic.rotating{display:flex;width:22px;height:22px;animation:rotate 2s linear infinite;transform-origin:center center}@keyframes gemini-hover-animation{0%{transform:scale(1) rotate(0);filter:drop-shadow(0 0 2px rgba(74,144,226,.5))}50%{transform:scale(1.15) rotate(10deg);filter:drop-shadow(0 0 12px rgb(123,207,255))}to{transform:scale(1) rotate(-10deg);filter:drop-shadow(0 0 2px rgba(74,144,226,.5))}}@keyframes rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.faris-title-container{display:flex;align-items:center;font-weight:500;gap:.5em;overflow:hidden}.faris-title-container .faris-title-group{flex:1;overflow:hidden}.faris-title-container .faris-title-group .faris-title{font-size:1em}.faris-title-container .faris-title-group .faris-subtitle{font-size:.9em;opacity:.8;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.closed-chat-history-side{min-width:60px!important}.hide-shadow-btn:focus{box-shadow:none!important}.conversation-item{height:40px}.conversation-item.active-conversation{background-color:var(--primary-color);color:var(--white)}.conversation-item.active-conversation mt-icon{color:var(--white)}.conversation-item label{font-size:15px;font-weight:600;line-height:20px}\n"] }]
|
|
1921
|
+
}], propDecorators: { showChatBot: [{
|
|
1922
|
+
type: Input
|
|
1923
|
+
}], showChatBotChange: [{
|
|
1924
|
+
type: Output
|
|
1925
|
+
}] } });
|
|
1926
|
+
|
|
1927
|
+
/**
|
|
1928
|
+
* Generated bundle index. Do not edit.
|
|
1929
|
+
*/
|
|
1930
|
+
|
|
1931
|
+
export { FarisComponent, FarisService, resolveFarisAuthFromLocalStorage };
|
|
1932
|
+
//# sourceMappingURL=masterteam-faris.mjs.map
|