@aslaluroba/help-center 3.0.14 → 4.0.0

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import * as i0 from '@angular/core';
2
- import { OnInit, OnDestroy, OnChanges, ElementRef, SimpleChanges, PipeTransform } from '@angular/core';
1
+ import * as _angular_core from '@angular/core';
2
+ import { OnInit, OnDestroy, ElementRef, PipeTransform } from '@angular/core';
3
3
  import { Observable } from 'rxjs';
4
4
 
5
5
  type Language = 'en' | 'ar';
@@ -7,11 +7,11 @@ interface TokenResponse {
7
7
  token: string;
8
8
  expiresIn: number;
9
9
  }
10
- interface Option$1 {
10
+ interface Option {
11
11
  id: string;
12
12
  helpScreenId: string;
13
13
  parentOptionId: string | null;
14
- nestedOptions: Option$1[];
14
+ nestedOptions: Option[];
15
15
  title: string;
16
16
  paragraphs: string[];
17
17
  chatWithUs: boolean;
@@ -31,6 +31,7 @@ interface Option$1 {
31
31
  };
32
32
  hasNestedOptions: boolean;
33
33
  order: number;
34
+ icon?: string;
34
35
  }
35
36
  interface Message$1 {
36
37
  id: string | number;
@@ -39,101 +40,88 @@ interface Message$1 {
39
40
  messageContent: string;
40
41
  sentAt: Date;
41
42
  isSeen: boolean;
43
+ attachmentIds?: string[];
42
44
  }
43
-
44
- declare class ApiService {
45
- private getTokenFunction;
46
- private baseUrl;
47
- /**
48
- * Initialize the API service with optional configuration
49
- * @param config Configuration object containing token function and optional base URL
50
- */
51
- initialize(config: ApiConfig): void;
52
- getValidToken(forceRefresh?: boolean): Promise<string>;
53
- private fetchWithAuth;
54
- apiRequest(endpoint: string, method?: string, body?: any, customHeaders?: Record<string, string>): Promise<Response>;
55
- static ɵfac: i0.ɵɵFactoryDeclaration<ApiService, never>;
56
- static ɵprov: i0.ɵɵInjectableDeclaration<ApiService>;
45
+ interface Tenant {
46
+ id: string;
47
+ name: string;
48
+ key: string;
57
49
  }
58
-
59
- type TranslationKey = 'ChatIntroMessage' | 'BabylaiTitle' | 'BabylaiDescription' | 'ChatNow' | 'TryBableAI' | 'ContactUs' | 'PickTopicTitle' | 'BabylAI' | 'ChatPlaceholder' | 'PoweredByBabylAI' | 'EndChat' | 'LeavingDialogTitle' | 'LeavingDialogBody' | 'StartNewChatDialogTitle' | 'StartNewChatDialogBody' | 'ReviewDialogTitle' | 'ReviewDialogDescription' | 'ReviewDialogRatingLabel' | 'ReviewDialogCommentLabel' | 'ReviewDialogCommentPlaceholder' | 'ReviewDialogSubmitButton' | 'ReviewDialogSkipButton' | 'Confirm' | 'Cancel' | 'title';
60
- declare class TranslationService {
61
- private translations;
62
- private _currentLang;
63
- readonly currentLang: Observable<Language>;
64
- constructor();
65
- translate(key: TranslationKey): string;
66
- setLanguage(lang: Language): void;
67
- getCurrentLang(): Language;
68
- static ɵfac: i0.ɵɵFactoryDeclaration<TranslationService, never>;
69
- static ɵprov: i0.ɵɵInjectableDeclaration<TranslationService>;
50
+ interface Assistant {
51
+ id: string;
52
+ tenantId: string;
53
+ tenant: Tenant;
54
+ name: string;
55
+ openAIAssistantId: string;
56
+ greeting: string;
57
+ closing: string;
70
58
  }
71
-
72
- declare class ThemeService {
73
- private primaryColor;
74
- private logoUrl;
75
- private isDarkMode;
76
- constructor();
77
- /**
78
- * Initialize dark mode detection based on browser preferences
79
- */
80
- private initializeDarkModeDetection;
81
- /**
82
- * Update dark mode state based on current browser preference
83
- */
84
- private updateDarkModeState;
85
- /**
86
- * Get current dark mode state
87
- */
88
- getDarkModeState(): i0.Signal<boolean>;
89
- /**
90
- * Check if dark mode is currently active
91
- */
92
- isDarkModeActive(): boolean;
93
- setPrimaryColor(color: string): void;
94
- setLogoUrl(url: string): void;
95
- getPrimaryColor(): string;
96
- getLogoUrl(): string;
97
- private updateCSSVariables;
98
- private generateColorVariations;
99
- /**
100
- * Lighten a color by a percentage
101
- */
102
- private lightenColor;
103
- /**
104
- * Darken a color by a percentage
105
- */
106
- private darkenColor;
107
- initializeTheme(primaryColor: string, logoUrl: string): void;
108
- static ɵfac: i0.ɵɵFactoryDeclaration<ThemeService, never>;
109
- static ɵprov: i0.ɵɵInjectableDeclaration<ThemeService>;
59
+ interface HelpScreenFile {
60
+ id: string;
61
+ name: string;
62
+ url: string;
63
+ type: string;
64
+ size?: number;
110
65
  }
111
-
112
- interface Option {
66
+ interface HelpScreenOption {
113
67
  id: string;
114
68
  helpScreenId: string;
115
69
  parentOptionId: string | null;
116
- nestedOptions: Option[];
70
+ nestedOptions: HelpScreenOption[];
117
71
  title: string;
118
72
  paragraphs: string[];
73
+ files: HelpScreenFile[];
119
74
  chatWithUs: boolean;
120
75
  assistantId?: string;
121
- assistant?: {
122
- id: string;
123
- tenantId: string;
124
- tenant: {
125
- id: string;
126
- name: string;
127
- key: string;
128
- };
129
- name: string;
130
- openAIAssistantId: string;
131
- greeting: string;
132
- closing: string;
133
- };
76
+ assistant?: Assistant;
134
77
  hasNestedOptions: boolean;
135
78
  order: number;
79
+ icon?: string;
136
80
  }
81
+ interface HelpScreenData {
82
+ id: string;
83
+ tenantId: string;
84
+ tenant: Tenant;
85
+ title: string;
86
+ description: string;
87
+ options: HelpScreenOption[];
88
+ chatWithUs: boolean;
89
+ }
90
+ interface PresignUploadRequestDto {
91
+ name: string;
92
+ contentType: string;
93
+ sizeBytes: number;
94
+ pathData: {
95
+ type: number;
96
+ chatSessionId: string;
97
+ };
98
+ }
99
+ interface PresignUploadResponse {
100
+ id: string;
101
+ uploadUrl: string;
102
+ path: string;
103
+ expiresAt: string;
104
+ }
105
+ interface PresignDownloadResponse {
106
+ id: string;
107
+ name: string;
108
+ downloadUrl: string;
109
+ contentType: string;
110
+ expiresAt: string;
111
+ }
112
+ interface SelectedFileDto {
113
+ file: File;
114
+ previewUrl: string;
115
+ uploading: boolean;
116
+ uploadedId: string | null;
117
+ error: string | null;
118
+ }
119
+ interface UploadResult {
120
+ fileId: string;
121
+ success: boolean;
122
+ error?: string;
123
+ }
124
+
137
125
  interface Message {
138
126
  id: string | number;
139
127
  sender: 'user' | 'assistant' | 'agent';
@@ -141,65 +129,79 @@ interface Message {
141
129
  messageContent: string;
142
130
  sentAt: Date;
143
131
  isSeen: boolean;
132
+ attachmentIds?: string[];
144
133
  }
145
- declare class HelpCenterWidgetComponent implements OnInit, OnDestroy, OnChanges {
134
+ declare class HelpCenterWidgetComponent implements OnInit, OnDestroy {
135
+ getToken: _angular_core.InputSignal<() => Promise<string>>;
136
+ helpScreenId: _angular_core.InputSignal<string>;
137
+ showArrow: _angular_core.InputSignal<boolean>;
138
+ messageLabel: _angular_core.InputSignal<string>;
139
+ currentLang: _angular_core.InputSignal<string>;
140
+ isIntroScreenEnabled: _angular_core.InputSignal<boolean>;
141
+ primaryColor: _angular_core.InputSignal<string>;
142
+ logoUrl: _angular_core.InputSignal<string>;
143
+ chatMessagesContainer: ElementRef;
144
+ isRTL: _angular_core.Signal<boolean>;
145
+ isPopupOpen: _angular_core.WritableSignal<boolean>;
146
+ helpScreenData: _angular_core.WritableSignal<HelpScreenData>;
147
+ status: _angular_core.WritableSignal<"idle" | "failed" | "loading" | "succeeded">;
148
+ error: _angular_core.WritableSignal<string>;
149
+ showArrowAnimation: _angular_core.WritableSignal<boolean>;
150
+ showTooltip: _angular_core.WritableSignal<boolean>;
151
+ sessionId: _angular_core.WritableSignal<string>;
152
+ isAblyConnected: _angular_core.WritableSignal<boolean>;
153
+ isChatClosed: _angular_core.WritableSignal<boolean>;
154
+ showChat: _angular_core.WritableSignal<boolean>;
155
+ messageText: _angular_core.WritableSignal<string>;
156
+ isTyping: _angular_core.WritableSignal<boolean>;
157
+ messages: _angular_core.WritableSignal<Message[]>;
158
+ showHelpScreenData: _angular_core.WritableSignal<boolean>;
159
+ chatIsLoading: _angular_core.WritableSignal<boolean>;
160
+ ablyToken: _angular_core.WritableSignal<string>;
161
+ needsAgent: _angular_core.WritableSignal<boolean>;
162
+ assistantStatus: _angular_core.WritableSignal<"typing" | "idle">;
163
+ selectedOption: _angular_core.WritableSignal<Option>;
164
+ selectedNestedOption: _angular_core.WritableSignal<Option>;
165
+ showEndChatConfirmation: _angular_core.WritableSignal<boolean>;
166
+ showStartNewChatConfirmation: _angular_core.WritableSignal<boolean>;
167
+ showReviewDialog: _angular_core.WritableSignal<boolean>;
168
+ isSubmittingReview: _angular_core.WritableSignal<boolean>;
169
+ isStartingNewChat: _angular_core.WritableSignal<boolean>;
170
+ pendingNewChatOption: _angular_core.WritableSignal<Option>;
146
171
  private apiService;
147
172
  private translationService;
148
173
  private themeService;
149
- getToken: () => Promise<string>;
150
- helpScreenId: string;
151
- showArrow: boolean;
152
- messageLabel: string | null;
153
- set currentLang(value: string);
154
- get currentLang(): string;
155
- isIntroScreenEnabled: boolean;
156
- primaryColor: string;
157
- logoUrl: string;
158
- chatMessagesContainer: ElementRef;
159
- private _currentLang;
160
- private langSubscription?;
161
- isRTL: boolean;
162
- isPopupOpen: boolean;
163
- helpScreenData: any;
164
- status: string;
165
- error: string | null;
166
- showArrowAnimation: boolean;
167
- showTooltip: boolean;
168
- sessionId: string | null;
169
- isAblyConnected: boolean;
170
- isChatClosed: boolean;
171
- showChat: boolean;
172
- messageText: string;
173
- isTyping: boolean;
174
- messages: Message[];
175
- showHelpScreenData: boolean;
176
- chatIsLoading: boolean;
177
- ablyToken: string | null;
178
- isOpen: boolean;
179
- needsAgent: boolean;
180
- assistantStatus: string;
181
- selectedOption: Option | null;
182
- selectedNestedOption: Option | null;
183
- showEndChatConfirmation: boolean;
184
- showStartNewChatConfirmation: boolean;
185
- showReviewDialog: boolean;
186
- isSubmittingReview: boolean;
187
- pendingNewChatOption: Option | null;
188
- constructor(apiService: ApiService, translationService: TranslationService, themeService: ThemeService);
174
+ private chatSessionService;
175
+ private fileUploadService;
176
+ private destroyRef;
177
+ private themeEffectRef?;
178
+ private languageEffectRef?;
179
+ constructor();
189
180
  ngOnInit(): void;
190
- ngOnChanges(changes: SimpleChanges): void;
191
181
  ngOnDestroy(): void;
192
182
  handleTogglePopup(): Promise<void>;
193
183
  private fetchHelpScreenData;
194
- createChatSession(option?: Option): Promise<any>;
195
- sendMessage(messageText?: string): Promise<void>;
196
- handleReceiveMessage(message: string, senderType: string, needsAgent: boolean): void;
184
+ createChatSession(option?: Option): Promise<{
185
+ chatSession: {
186
+ id: string;
187
+ };
188
+ ablyToken: string;
189
+ }>;
190
+ sendMessage(event?: {
191
+ text: string;
192
+ attachmentIds: string[];
193
+ pendingFiles?: File[];
194
+ } | string): Promise<void>;
195
+ handleReceiveMessage(message: string | {
196
+ content: string;
197
+ attachments?: string[];
198
+ }, senderType: number, needsAgent: boolean): void;
197
199
  private getSenderType;
198
200
  private hasActiveChatSession;
199
201
  private isWelcomeMessage;
200
202
  handleStartNewChat(option: Option): Promise<void>;
201
203
  private startNewChatSession;
202
- handleStartChat(option: any): Promise<void>;
204
+ handleStartChat(option: Option): Promise<void>;
203
205
  handleEndChat(): Promise<void>;
204
206
  confirmEndChat(): Promise<void>;
205
207
  handleReviewSubmit(reviewData: {
@@ -213,7 +215,12 @@ declare class HelpCenterWidgetComponent implements OnInit, OnDestroy, OnChanges
213
215
  cancelStartNewChat(): void;
214
216
  private clearCurrentChat;
215
217
  private startNewChatWithOption;
216
- closeChatSession(chatSessionId: string): Promise<any>;
218
+ /**
219
+ * Closes a chat session.
220
+ * @deprecated Use chatSessionService.closeSession() instead
221
+ * @private
222
+ */
223
+ private closeChatSession;
217
224
  handleClosePopup(): void;
218
225
  handleCloseArrowAnimation(): void;
219
226
  handleBack(): void;
@@ -222,15 +229,30 @@ declare class HelpCenterWidgetComponent implements OnInit, OnDestroy, OnChanges
222
229
  selectNestedOption(nestedOption: Option): void;
223
230
  handleShowHelpScreenData(): void;
224
231
  handleHideHelpScreenData(): void;
232
+ private scrollTimeout?;
225
233
  private scrollToBottom;
226
234
  getDirection(): "ltr" | "rtl";
227
- get helpScreenDataList(): any;
235
+ get helpScreenDataList(): {
236
+ icon: string;
237
+ title: string;
238
+ description: string;
239
+ actionLabel: string;
240
+ action: () => Promise<void>;
241
+ }[];
228
242
  navigateToUrl(url: string): void;
229
- static ɵfac: i0.ɵɵFactoryDeclaration<HelpCenterWidgetComponent, never>;
230
- static ɵcmp: i0.ɵɵComponentDeclaration<HelpCenterWidgetComponent, "app-help-center-widget", never, { "getToken": { "alias": "getToken"; "required": false; }; "helpScreenId": { "alias": "helpScreenId"; "required": false; }; "showArrow": { "alias": "showArrow"; "required": false; }; "messageLabel": { "alias": "messageLabel"; "required": false; }; "currentLang": { "alias": "currentLang"; "required": false; }; "isIntroScreenEnabled": { "alias": "isIntroScreenEnabled"; "required": false; }; "primaryColor": { "alias": "primaryColor"; "required": false; }; "logoUrl": { "alias": "logoUrl"; "required": false; }; }, {}, never, never, true, never>;
243
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<HelpCenterWidgetComponent, never>;
244
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<HelpCenterWidgetComponent, "app-help-center-widget", never, { "getToken": { "alias": "getToken"; "required": true; "isSignal": true; }; "helpScreenId": { "alias": "helpScreenId"; "required": true; "isSignal": true; }; "showArrow": { "alias": "showArrow"; "required": false; "isSignal": true; }; "messageLabel": { "alias": "messageLabel"; "required": false; "isSignal": true; }; "currentLang": { "alias": "currentLang"; "required": false; "isSignal": true; }; "isIntroScreenEnabled": { "alias": "isIntroScreenEnabled"; "required": false; "isSignal": true; }; "primaryColor": { "alias": "primaryColor"; "required": false; "isSignal": true; }; "logoUrl": { "alias": "logoUrl"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
231
245
  }
232
246
 
233
247
  type GetTokenFn = () => Promise<string>;
248
+ /**
249
+ * Service for managing help center configuration.
250
+ *
251
+ * Stores configuration such as API base URL and token retrieval function.
252
+ * This service is used internally by other services to access configuration.
253
+ *
254
+ * @publicApi
255
+ */
234
256
  declare class HelpCenterConfigService {
235
257
  private _apiBaseUrl;
236
258
  private _getTokenFn?;
@@ -238,38 +260,338 @@ declare class HelpCenterConfigService {
238
260
  getApiBaseUrl(): string;
239
261
  setGetTokenFn(fn: GetTokenFn): void;
240
262
  getTokenFn(): GetTokenFn | undefined;
241
- static ɵfac: i0.ɵɵFactoryDeclaration<HelpCenterConfigService, never>;
242
- static ɵprov: i0.ɵɵInjectableDeclaration<HelpCenterConfigService>;
263
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<HelpCenterConfigService, never>;
264
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<HelpCenterConfigService>;
265
+ }
266
+
267
+ /**
268
+ * Service for handling API requests with automatic authentication token management.
269
+ *
270
+ * Features:
271
+ * - Automatic token refresh on expiry
272
+ * - Token validation and format checking
273
+ * - Secure token storage using sessionStorage
274
+ * - Endpoint validation to prevent SSRF attacks
275
+ *
276
+ * @publicApi
277
+ */
278
+ declare class ApiService {
279
+ private getTokenFunction;
280
+ private baseUrl;
281
+ /**
282
+ * Initialize the API service with authentication configuration.
283
+ *
284
+ * This must be called before making any API requests. The service will use
285
+ * the provided token function to fetch and refresh tokens automatically.
286
+ *
287
+ * @param config Configuration object containing token function and optional base URL
288
+ * @throws Error if getToken function is not provided
289
+ *
290
+ * @example
291
+ * ```typescript
292
+ * apiService.initialize({
293
+ * getToken: async () => {
294
+ * const response = await fetch('/auth/token');
295
+ * const data = await response.json();
296
+ * return data.token;
297
+ * },
298
+ * baseUrl: 'https://api.example.com'
299
+ * });
300
+ * ```
301
+ */
302
+ initialize(config: ApiConfig): void;
303
+ /**
304
+ * Validate token format
305
+ * JWT tokens must have exactly 3 parts separated by dots (header.payload.signature)
306
+ */
307
+ private validateToken;
308
+ /**
309
+ * Retrieves a valid authentication token, fetching a new one if expired.
310
+ *
311
+ * Tokens are cached for 15 minutes. The service provides backward compatibility:
312
+ * - Checks localStorage first for existing tokens (backward compatibility)
313
+ * - Falls back to sessionStorage if no token found in localStorage
314
+ * - New tokens are stored in sessionStorage (preferred) or localStorage (fallback)
315
+ * - Automatically migrates tokens from localStorage to sessionStorage when found
316
+ *
317
+ * After expiry, a new token is automatically fetched using the configured getToken function.
318
+ *
319
+ * @param forceRefresh If true, forces a new token fetch even if current token is valid
320
+ * @returns Promise resolving to a valid authentication token
321
+ * @throws Error if API service is not initialized or token format is invalid
322
+ */
323
+ getValidToken(forceRefresh?: boolean): Promise<string>;
324
+ private fetchWithAuth;
325
+ /**
326
+ * Validate endpoint to prevent SSRF vulnerabilities
327
+ *
328
+ * Protects against:
329
+ * - Absolute URLs with any protocol (case-insensitive)
330
+ * - Protocol-relative URLs
331
+ * - Dangerous protocols (ftp, file, data, javascript, etc.)
332
+ * - URL-encoded path traversal
333
+ * - Double-encoded attacks
334
+ */
335
+ private validateEndpoint;
336
+ /**
337
+ * Makes an authenticated API request with automatic token management.
338
+ *
339
+ * This method automatically:
340
+ * - Validates the endpoint to prevent SSRF attacks
341
+ * - Adds authentication headers with a valid token
342
+ * - Retries with a fresh token if authentication fails
343
+ * - Handles errors and returns appropriate error messages
344
+ *
345
+ * @param endpoint API endpoint path (relative to baseUrl)
346
+ * @param method HTTP method (default: 'GET')
347
+ * @param body Request body object (will be JSON stringified)
348
+ * @param customHeaders Additional headers to include in the request
349
+ * @returns Promise resolving to the Response object
350
+ * @throws Error if endpoint validation fails, request fails, or authentication fails
351
+ *
352
+ * @example
353
+ * ```typescript
354
+ * // GET request
355
+ * const response = await apiService.apiRequest('client/help-screens/123');
356
+ * const data = await response.json();
357
+ *
358
+ * // POST request
359
+ * const response = await apiService.apiRequest(
360
+ * 'client/chat-sessions',
361
+ * 'POST',
362
+ * { helpScreenId: '123' }
363
+ * );
364
+ * ```
365
+ */
366
+ apiRequest<T = unknown>(endpoint: string, method?: string, body?: T | null, customHeaders?: Record<string, string>): Promise<Response>;
367
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ApiService, never>;
368
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<ApiService>;
243
369
  }
244
370
 
371
+ /**
372
+ * Service for retrieving authentication tokens from the configured token function.
373
+ *
374
+ * This service acts as a wrapper around the configured token retrieval function,
375
+ * providing a consistent interface for token management.
376
+ *
377
+ * @publicApi
378
+ */
245
379
  declare class TokenService {
246
380
  private config;
247
- constructor(config: HelpCenterConfigService);
381
+ /**
382
+ * Retrieves an authentication token using the configured token function.
383
+ *
384
+ * @returns Promise resolving to a TokenResponse containing the token and expiry time
385
+ * @throws Error if no token function is configured
386
+ */
248
387
  getToken(): Promise<TokenResponse>;
249
- static ɵfac: i0.ɵɵFactoryDeclaration<TokenService, never>;
250
- static ɵprov: i0.ɵɵInjectableDeclaration<TokenService>;
388
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TokenService, never>;
389
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<TokenService>;
390
+ }
391
+
392
+ type TranslationKey = 'ChatIntroMessage' | 'BabylaiTitle' | 'BabylaiDescription' | 'ChatNow' | 'TryBableAI' | 'ContactUs' | 'PickTopicTitle' | 'BabylAI' | 'ChatPlaceholder' | 'PoweredByBabylAI' | 'EndChat' | 'LeavingDialogTitle' | 'LeavingDialogBody' | 'StartNewChatDialogTitle' | 'StartNewChatDialogBody' | 'ReviewDialogTitle' | 'ReviewDialogDescription' | 'ReviewDialogRatingLabel' | 'ReviewDialogCommentLabel' | 'ReviewDialogCommentPlaceholder' | 'ReviewDialogSubmitButton' | 'ReviewDialogSkipButton' | 'Confirm' | 'Cancel' | 'Close' | 'Back' | 'title' | 'ErrorFetchingHelpScreen' | 'ErrorSendingMessage' | 'ErrorStartingChat' | 'ErrorEndingChat' | 'ErrorSubmittingReview' | 'ErrorClosingChat' | 'ErrorCreatingSession' | 'ErrorNetworkFailure' | 'ErrorUnknown' | 'ErrorMessageTooLong' | 'ErrorMessageEmpty';
393
+ /**
394
+ * Service for managing translations and language switching.
395
+ *
396
+ * Supports multiple languages (currently English and Arabic) with RTL support.
397
+ * Provides reactive language changes through Observable pattern.
398
+ *
399
+ * @publicApi
400
+ */
401
+ declare class TranslationService {
402
+ private translations;
403
+ private _currentLang;
404
+ readonly currentLang: Observable<Language>;
405
+ /**
406
+ * Translates a translation key to the current language.
407
+ *
408
+ * @param key Translation key to look up
409
+ * @returns Translated string in the current language, or the key itself if translation not found
410
+ *
411
+ * @example
412
+ * ```typescript
413
+ * const message = translationService.translate('ChatNow');
414
+ * // Returns 'Chat Now' in English or 'دردش الآن' in Arabic
415
+ * ```
416
+ */
417
+ translate(key: TranslationKey): string;
418
+ /**
419
+ * Sets the current language for translations.
420
+ *
421
+ * @param lang Language code ('en' or 'ar')
422
+ *
423
+ * @example
424
+ * ```typescript
425
+ * translationService.setLanguage('ar'); // Switch to Arabic
426
+ * ```
427
+ */
428
+ setLanguage(lang: Language): void;
429
+ /**
430
+ * Gets the current language code.
431
+ *
432
+ * @returns Current language code ('en' or 'ar')
433
+ */
434
+ getCurrentLang(): Language;
435
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TranslationService, never>;
436
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<TranslationService>;
437
+ }
438
+
439
+ /**
440
+ * Service for managing chat session lifecycle and operations.
441
+ *
442
+ * Handles:
443
+ * - Chat session creation and management
444
+ * - Ably connection management
445
+ * - Message sending operations
446
+ *
447
+ * @publicApi
448
+ */
449
+ declare class ChatSessionService {
450
+ private apiService;
451
+ /**
452
+ * Creates a new chat session with the specified option.
453
+ *
454
+ * @param option The help screen option to create a chat session for
455
+ * @param helpScreenId The help screen ID
456
+ * @param currentLang Current language code for API headers
457
+ * @returns Promise resolving to session data including sessionId and ablyToken
458
+ * @throws Error if session creation fails
459
+ */
460
+ createSession(option: Option, helpScreenId: string, currentLang: string): Promise<{
461
+ chatSession: {
462
+ id: string;
463
+ };
464
+ ablyToken: string;
465
+ }>;
466
+ /**
467
+ * Establishes Ably real-time connection for a chat session.
468
+ *
469
+ * @param sessionId The chat session ID
470
+ * @param ablyToken The Ably authentication token
471
+ * @param onMessageReceived Callback function for received messages
472
+ * @param tenantId The tenant ID for the connection
473
+ * @param option Optional option for token refresh (needed for token renewal)
474
+ * @param helpScreenId Optional help screen ID for token refresh
475
+ * @param currentLang Optional current language for token refresh
476
+ */
477
+ establishAblyConnection(sessionId: string, ablyToken: string, onMessageReceived: (message: string | {
478
+ content: string;
479
+ attachments?: string[];
480
+ }, senderType: number, needsAgent: boolean) => void, tenantId: string, option?: Option, helpScreenId?: string, currentLang?: string): Promise<void>;
481
+ /**
482
+ * Sends a message in an active chat session.
483
+ *
484
+ * @param sessionId The chat session ID
485
+ * @param messageContent The message content to send
486
+ * @param currentLang Current language code for API headers
487
+ * @throws Error if message sending fails
488
+ */
489
+ sendMessage(sessionId: string, messageContent: string, currentLang: string, attachmentIds?: string[]): Promise<void>;
490
+ /**
491
+ * Closes a chat session.
492
+ *
493
+ * @param sessionId The chat session ID to close
494
+ * @param currentLang Current language code for API headers
495
+ * @returns Promise resolving to the close response
496
+ * @throws Error if session closing fails
497
+ */
498
+ closeSession(sessionId: string, currentLang: string): Promise<unknown>;
499
+ /**
500
+ * Submits a review for a chat session.
501
+ *
502
+ * @param sessionId The chat session ID
503
+ * @param rating Rating value (1-5)
504
+ * @param comment Review comment (10-500 characters)
505
+ * @param currentLang Current language code for API headers
506
+ * @throws Error if review submission fails
507
+ */
508
+ submitReview(sessionId: string, rating: number, comment: string, currentLang: string): Promise<void>;
509
+ /**
510
+ * Stops the Ably connection.
511
+ */
512
+ stopConnection(): Promise<void>;
513
+ /**
514
+ * Checks if Ably connection is active.
515
+ *
516
+ * @returns True if connection is active, false otherwise
517
+ */
518
+ isConnectionActive(): boolean;
519
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ChatSessionService, never>;
520
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<ChatSessionService>;
251
521
  }
252
522
 
523
+ /**
524
+ * Service for managing language switching.
525
+ *
526
+ * Provides a simplified interface for switching between supported languages.
527
+ * This service wraps TranslationService for easier language management.
528
+ *
529
+ * @publicApi
530
+ */
253
531
  declare class LanguageService {
254
532
  private translationService;
255
- constructor(translationService: TranslationService);
533
+ /**
534
+ * Switches the application language.
535
+ *
536
+ * @param language Language code to switch to ('en' or 'ar')
537
+ *
538
+ * @example
539
+ * ```typescript
540
+ * languageService.switchLanguage('ar'); // Switch to Arabic
541
+ * ```
542
+ */
256
543
  switchLanguage(language: Language): void;
544
+ /**
545
+ * Gets the current application language.
546
+ *
547
+ * @returns Current language code ('en' or 'ar')
548
+ */
257
549
  getCurrentLang(): Language;
258
- static ɵfac: i0.ɵɵFactoryDeclaration<LanguageService, never>;
259
- static ɵprov: i0.ɵɵInjectableDeclaration<LanguageService>;
550
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<LanguageService, never>;
551
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<LanguageService>;
260
552
  }
261
553
 
554
+ /**
555
+ * Angular pipe for translating keys in templates.
556
+ *
557
+ * Usage in templates:
558
+ * ```html
559
+ * {{ 'ChatNow' | translate }}
560
+ * ```
561
+ *
562
+ * @publicApi
563
+ */
262
564
  declare class TranslatePipe implements PipeTransform {
263
565
  private translationService;
566
+ /**
567
+ * Transforms a translation key into the translated string for the current language.
568
+ *
569
+ * @param key Translation key to look up
570
+ * @returns Translated string in the current language
571
+ */
264
572
  transform(key: TranslationKey): string;
265
- static ɵfac: i0.ɵɵFactoryDeclaration<TranslatePipe, never>;
266
- static ɵpipe: i0.ɵɵPipeDeclaration<TranslatePipe, "translate", true>;
573
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TranslatePipe, never>;
574
+ static ɵpipe: _angular_core.ɵɵPipeDeclaration<TranslatePipe, "translate", true>;
267
575
  }
268
576
 
577
+ /**
578
+ * Configuration interface for API service initialization
579
+ *
580
+ * @publicApi
581
+ */
269
582
  interface ApiConfig {
583
+ /**
584
+ * Function that returns a promise resolving to an authentication token
585
+ * This function is called when tokens need to be refreshed
586
+ */
270
587
  getToken: () => Promise<string>;
588
+ /**
589
+ * Optional base URL for API requests
590
+ * Defaults to 'https://babylai.net/api' if not provided
591
+ * Should use HTTPS in production environments
592
+ */
271
593
  baseUrl?: string;
272
594
  }
273
595
 
274
- export { ApiService, HelpCenterConfigService, HelpCenterWidgetComponent, LanguageService, TokenService, TranslatePipe, TranslationService };
275
- export type { ApiConfig, GetTokenFn, Language, Message$1 as Message, Option$1 as Option, TokenResponse, TranslationKey };
596
+ export { ApiService, ChatSessionService, HelpCenterConfigService, HelpCenterWidgetComponent, LanguageService, TokenService, TranslatePipe, TranslationService };
597
+ export type { ApiConfig, Assistant, GetTokenFn, HelpScreenData, HelpScreenFile, HelpScreenOption, Language, Message$1 as Message, Option, PresignDownloadResponse, PresignUploadRequestDto, PresignUploadResponse, SelectedFileDto, Tenant, TokenResponse, TranslationKey, UploadResult };