@uipath/apollo-react 4.42.0 → 4.43.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.
Files changed (34) hide show
  1. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  2. package/dist/core/tokens/css/theme-variables.css +318 -4
  3. package/dist/core/tokens/css/variables.css +372 -0
  4. package/dist/core/tokens/jss/palette.cjs +1184 -0
  5. package/dist/core/tokens/jss/palette.d.ts +12 -1
  6. package/dist/core/tokens/jss/palette.js +1 -1
  7. package/dist/core/tokens/less/_variables.less +372 -0
  8. package/dist/core/tokens/scss/_variables.scss +895 -119
  9. package/dist/core/tokens/scss/base-host.scss +302 -0
  10. package/dist/core/tokens/scss/theme-variables.scss +310 -4
  11. package/dist/core/tokens/scss/theme.scss +307 -1
  12. package/dist/material/stories/chat-story-support.cjs +2437 -0
  13. package/dist/material/stories/chat-story-support.d.ts +11 -0
  14. package/dist/material/stories/chat-story-support.d.ts.map +1 -0
  15. package/dist/material/stories/chat-story-support.js +2381 -0
  16. package/dist/material/stories/storybook-helpers.cjs +166 -0
  17. package/dist/material/stories/storybook-helpers.d.ts +21 -0
  18. package/dist/material/stories/storybook-helpers.d.ts.map +1 -0
  19. package/dist/material/stories/storybook-helpers.js +109 -0
  20. package/dist/material/theme/index.cjs +27 -1
  21. package/dist/material/theme/index.d.ts +3 -1
  22. package/dist/material/theme/index.d.ts.map +1 -1
  23. package/dist/material/theme/index.js +23 -3
  24. package/dist/material/theme/overrides/MuiButton.cjs +4 -4
  25. package/dist/material/theme/overrides/MuiButton.js +4 -4
  26. package/dist/material/theme/overrides/MuiDatepicker.cjs +2 -2
  27. package/dist/material/theme/overrides/MuiDatepicker.js +2 -2
  28. package/dist/material/theme/overrides/MuiFab.cjs +3 -3
  29. package/dist/material/theme/overrides/MuiFab.js +3 -3
  30. package/dist/material/theme/overrides/index.cjs +8 -0
  31. package/dist/material/theme/overrides/index.d.ts +2 -0
  32. package/dist/material/theme/overrides/index.d.ts.map +1 -1
  33. package/dist/material/theme/overrides/index.js +4 -2
  34. package/package.json +5 -4
@@ -0,0 +1,2381 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import Box from "@mui/material/Box";
3
+ import Button from "@mui/material/Button";
4
+ import Checkbox from "@mui/material/Checkbox";
5
+ import Divider from "@mui/material/Divider";
6
+ import FormControlLabel from "@mui/material/FormControlLabel";
7
+ import TextField from "@mui/material/TextField";
8
+ import Typography from "@mui/material/Typography";
9
+ import { useCallback, useEffect, useRef, useState } from "react";
10
+ import { FontVariantToken } from "../../core/index.js";
11
+ import { ApChat, ApTypography, AutopilotChatEvent, AutopilotChatMode, AutopilotChatRole, AutopilotChatService } from "../components/index.js";
12
+ const CHAT_LOCALES = [
13
+ 'en',
14
+ 'de',
15
+ 'es',
16
+ 'es-MX',
17
+ 'fr',
18
+ 'ja',
19
+ 'ko',
20
+ 'pt',
21
+ 'pt-BR',
22
+ 'ru',
23
+ 'tr',
24
+ 'zh-CN',
25
+ 'zh-TW'
26
+ ];
27
+ function mapToChatLocale(globalLocale) {
28
+ return CHAT_LOCALES.includes(globalLocale) ? globalLocale : 'en';
29
+ }
30
+ function mapToChatTheme(globalTheme) {
31
+ switch(globalTheme){
32
+ case 'light':
33
+ return 'light';
34
+ case 'light-hc':
35
+ return 'light-hc';
36
+ case 'dark':
37
+ return 'dark';
38
+ case 'dark-hc':
39
+ return 'dark-hc';
40
+ case 'future-light':
41
+ return 'light';
42
+ case 'future-dark':
43
+ return 'dark';
44
+ default:
45
+ return 'dark';
46
+ }
47
+ }
48
+ function Section({ children }) {
49
+ return /*#__PURE__*/ jsxs(Box, {
50
+ sx: {
51
+ mb: 3,
52
+ '&:last-child': {
53
+ mb: 0,
54
+ '& > .MuiDivider-root': {
55
+ display: 'none'
56
+ }
57
+ }
58
+ },
59
+ children: [
60
+ children,
61
+ /*#__PURE__*/ jsx(Divider, {
62
+ sx: {
63
+ mt: 3
64
+ }
65
+ })
66
+ ]
67
+ });
68
+ }
69
+ function SectionTitle({ children }) {
70
+ return /*#__PURE__*/ jsx(ApTypography, {
71
+ variant: FontVariantToken.fontSizeMBold,
72
+ component: "h3",
73
+ sx: {
74
+ mb: 2
75
+ },
76
+ children: children
77
+ });
78
+ }
79
+ function ButtonGroup({ children }) {
80
+ return /*#__PURE__*/ jsx(Box, {
81
+ sx: {
82
+ display: 'flex',
83
+ flexWrap: 'wrap',
84
+ gap: 1,
85
+ mb: 1.5
86
+ },
87
+ children: children
88
+ });
89
+ }
90
+ function DemoButton({ primary = false, children, onClick, disabled, title }) {
91
+ return /*#__PURE__*/ jsx(Button, {
92
+ variant: primary ? 'contained' : 'outlined',
93
+ size: "small",
94
+ onClick: onClick,
95
+ disabled: disabled,
96
+ title: title,
97
+ sx: {
98
+ whiteSpace: 'nowrap'
99
+ },
100
+ children: children
101
+ });
102
+ }
103
+ function DemoInput({ style, type, min, max, value, onChange, placeholder, disabled }) {
104
+ return /*#__PURE__*/ jsx(TextField, {
105
+ size: "small",
106
+ fullWidth: true,
107
+ type: type,
108
+ value: value,
109
+ placeholder: placeholder,
110
+ disabled: disabled,
111
+ onChange: onChange,
112
+ inputProps: {
113
+ min,
114
+ max
115
+ },
116
+ sx: {
117
+ mb: 1.5
118
+ },
119
+ style: style
120
+ });
121
+ }
122
+ function DemoTextArea({ style, value, onChange, placeholder, disabled }) {
123
+ return /*#__PURE__*/ jsx(TextField, {
124
+ size: "small",
125
+ fullWidth: true,
126
+ multiline: true,
127
+ minRows: 3,
128
+ value: value,
129
+ placeholder: placeholder,
130
+ disabled: disabled,
131
+ onChange: onChange,
132
+ sx: {
133
+ mb: 1.5
134
+ },
135
+ style: style
136
+ });
137
+ }
138
+ function DemoSelect({ style, children, value, onChange, disabled }) {
139
+ return /*#__PURE__*/ jsx(TextField, {
140
+ select: true,
141
+ size: "small",
142
+ fullWidth: true,
143
+ value: value,
144
+ disabled: disabled,
145
+ onChange: onChange,
146
+ SelectProps: {
147
+ native: true
148
+ },
149
+ sx: {
150
+ mb: 1.5
151
+ },
152
+ style: style,
153
+ children: children
154
+ });
155
+ }
156
+ function InfoText({ children, style }) {
157
+ return /*#__PURE__*/ jsx(Typography, {
158
+ component: "p",
159
+ variant: "body2",
160
+ sx: {
161
+ color: 'text.secondary',
162
+ mt: 1
163
+ },
164
+ style: style,
165
+ children: children
166
+ });
167
+ }
168
+ function ChatShowcaseDemo({ theme, instanceName, initialMode = AutopilotChatMode.SideBySide, locale = 'en' }) {
169
+ const embeddedContainerRef = useRef(null);
170
+ const [chatService, setChatService] = useState(null);
171
+ const [chatMode, setChatMode] = useState(initialMode);
172
+ const [customMessage, setCustomMessage] = useState('Hello, how can I help you today?');
173
+ const [errorMessage, setErrorMessage] = useState('An error occurred. Please try again.');
174
+ const [streamingText, setStreamingText] = useState('This is a streaming response that will appear word by word...');
175
+ const [loadingMessage, setLoadingMessage] = useState('Thinking...');
176
+ const [waitForMore, setWaitForMore] = useState(false);
177
+ const [autoScroll, setAutoScroll] = useState(true);
178
+ const [isWaiting, setIsWaiting] = useState(false);
179
+ const [isShowLoading, setIsShowLoading] = useState(false);
180
+ const [features, setFeatures] = useState({
181
+ history: true,
182
+ settings: true,
183
+ attachments: true,
184
+ audio: false,
185
+ audioStreaming: false,
186
+ htmlPreview: true,
187
+ headerSeparator: false,
188
+ fullHeight: true,
189
+ resize: true,
190
+ close: true,
191
+ feedback: true,
192
+ model: true,
193
+ agentMode: true,
194
+ sendOnClick: false,
195
+ paginatedMessages: false,
196
+ compactMode: false,
197
+ customScrollTheme: false,
198
+ copy: true,
199
+ attachmentsAsync: false,
200
+ readOnly: false
201
+ });
202
+ const [selectedAgentMode, setSelectedAgentMode] = useState('agent');
203
+ const [selectedModel, setSelectedModel] = useState('gpt-4');
204
+ const [primaryFontToken, setPrimaryFontToken] = useState(FontVariantToken.fontSizeM);
205
+ const [promptBoxMinRows, setPromptBoxMinRows] = useState(2);
206
+ const [promptBoxMaxRows, setPromptBoxMaxRows] = useState(12);
207
+ const [resourcePaginationEnabled, setResourcePaginationEnabled] = useState(true);
208
+ const [resourcePageSize, setResourcePageSize] = useState(10);
209
+ const createResourceManager = useCallback(()=>{
210
+ const topLevelItems = [
211
+ {
212
+ id: 'variables',
213
+ type: 'category',
214
+ displayName: 'Variables',
215
+ icon: 'data_object',
216
+ hasNestedResources: true
217
+ },
218
+ {
219
+ id: 'files',
220
+ type: 'category',
221
+ displayName: 'This is an intentionally very very long category name',
222
+ icon: 'folder',
223
+ hasNestedResources: true
224
+ },
225
+ {
226
+ id: 'current-user',
227
+ type: 'context',
228
+ displayName: 'This is an intentionally very very long resource name',
229
+ icon: 'person',
230
+ tooltip: 'The currently logged in user context',
231
+ hasNestedResources: false
232
+ },
233
+ {
234
+ id: 'current-date',
235
+ type: 'context',
236
+ displayName: 'Current Date',
237
+ icon: 'calendar_today',
238
+ tooltip: "Today's date in ISO format",
239
+ hasNestedResources: false
240
+ }
241
+ ];
242
+ const variableIcons = [
243
+ 'text_fields',
244
+ 'mail',
245
+ 'numbers',
246
+ 'toggle_on',
247
+ 'settings',
248
+ 'person',
249
+ 'calendar_today',
250
+ 'list',
251
+ 'data_object',
252
+ 'code'
253
+ ];
254
+ const variableItems = Array.from({
255
+ length: 50
256
+ }, (_, i)=>({
257
+ id: `var-${i}`,
258
+ type: 'variable',
259
+ displayName: `variable_${i.toString().padStart(2, '0')}`,
260
+ icon: variableIcons[i % variableIcons.length],
261
+ tooltip: `Variable ${i} - This is a sample variable for testing pagination`
262
+ }));
263
+ const fileIcons = [
264
+ "description",
265
+ 'table_chart',
266
+ 'picture_as_pdf',
267
+ 'image',
268
+ 'code',
269
+ 'folder'
270
+ ];
271
+ const fileExtensions = [
272
+ '.json',
273
+ '.csv',
274
+ '.pdf',
275
+ '.png',
276
+ '.ts',
277
+ '.txt',
278
+ '.xml',
279
+ '.yaml'
280
+ ];
281
+ const fileItems = Array.from({
282
+ length: 30
283
+ }, (_, i)=>({
284
+ id: `file-${i}`,
285
+ type: 'file',
286
+ displayName: `document_${i.toString().padStart(2, '0')}${fileExtensions[i % fileExtensions.length]}`,
287
+ icon: fileIcons[i % fileIcons.length],
288
+ tooltip: `File ${i} - Sample file for testing pagination`
289
+ }));
290
+ const paginate = (items, skip, pageSize, paginationEnabled)=>{
291
+ if (!paginationEnabled) return {
292
+ paginatedItems: items,
293
+ done: true
294
+ };
295
+ const paginatedItems = items.slice(skip, skip + pageSize);
296
+ const done = skip + pageSize >= items.length;
297
+ return {
298
+ paginatedItems,
299
+ done
300
+ };
301
+ };
302
+ return {
303
+ getTopLevelResources: ()=>topLevelItems,
304
+ getNestedResources: async (resourceId, options)=>{
305
+ await new Promise((resolve)=>setTimeout(resolve, 300));
306
+ let items = [];
307
+ if ('variables' === resourceId) items = variableItems;
308
+ else if ('files' === resourceId) items = fileItems;
309
+ if (options?.searchText) {
310
+ const searchLower = options.searchText.toLowerCase();
311
+ items = items.filter((item)=>item.displayName.toLowerCase().includes(searchLower));
312
+ }
313
+ const skip = options?.skip ?? 0;
314
+ const { paginatedItems, done } = paginate(items, skip, resourcePageSize, resourcePaginationEnabled);
315
+ console.log(`[ResourceManager] getNestedResources: resourceId=${resourceId}, skip=${skip}, returned=${paginatedItems.length}, done=${done}`);
316
+ return {
317
+ items: paginatedItems,
318
+ done
319
+ };
320
+ },
321
+ globalSearch: async (options)=>{
322
+ await new Promise((resolve)=>setTimeout(resolve, 300));
323
+ let allItems = [
324
+ ...variableItems,
325
+ ...fileItems
326
+ ];
327
+ const skip = options.skip ?? 0;
328
+ if (options.searchText) {
329
+ const searchLower = options.searchText.toLowerCase();
330
+ if (0 === skip) {
331
+ const matchingTopLevel = topLevelItems.filter((item)=>item.displayName.toLowerCase().includes(searchLower));
332
+ allItems = [
333
+ ...matchingTopLevel,
334
+ ...allItems
335
+ ];
336
+ }
337
+ allItems = allItems.filter((item)=>item.displayName.toLowerCase().includes(searchLower));
338
+ }
339
+ const { paginatedItems, done } = paginate(allItems, skip, resourcePageSize, resourcePaginationEnabled);
340
+ console.log(`[ResourceManager] globalSearch: searchText="${options.searchText ?? ''}", skip=${skip}, returned=${paginatedItems.length}, done=${done}`);
341
+ return {
342
+ items: paginatedItems,
343
+ done
344
+ };
345
+ },
346
+ onResourceSelected: (item)=>{
347
+ console.log('Resource selected:', item.displayName);
348
+ }
349
+ };
350
+ }, [
351
+ resourcePaginationEnabled,
352
+ resourcePageSize
353
+ ]);
354
+ const createSettingsRenderer = useCallback(()=>(container)=>{
355
+ const settingsDiv = document.createElement('div');
356
+ settingsDiv.style.padding = '24px';
357
+ settingsDiv.style.color = 'var(--color-foreground)';
358
+ settingsDiv.innerHTML = `
359
+ <h2 style="margin: 0 0 16px 0; font-size: 20px; font-weight: 600;">Chat Settings</h2>
360
+
361
+ <div style="margin-bottom: 24px;">
362
+ <h3 style="margin: 0 0 12px 0; font-size: 16px; font-weight: 500;">Appearance</h3>
363
+ <label style="display: flex; align-items: center; gap: 8px; cursor: pointer; margin-bottom: 8px;">
364
+ <input type="checkbox" id="darkMode" style="cursor: pointer;" />
365
+ <span>Dark Mode</span>
366
+ </label>
367
+ <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
368
+ <input type="checkbox" id="compactMode" checked style="cursor: pointer;" />
369
+ <span>Compact Mode</span>
370
+ </label>
371
+ </div>
372
+
373
+ <div style="margin-bottom: 24px;">
374
+ <h3 style="margin: 0 0 12px 0; font-size: 16px; font-weight: 500;">Behavior</h3>
375
+ <label style="display: flex; align-items: center; gap: 8px; cursor: pointer; margin-bottom: 8px;">
376
+ <input type="checkbox" id="autoScroll" checked style="cursor: pointer;" />
377
+ <span>Auto-scroll to new messages</span>
378
+ </label>
379
+ <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
380
+ <input type="checkbox" id="soundEnabled" style="cursor: pointer;" />
381
+ <span>Enable sound notifications</span>
382
+ </label>
383
+ </div>
384
+
385
+ <div style="margin-bottom: 24px;">
386
+ <h3 style="margin: 0 0 12px 0; font-size: 16px; font-weight: 500;">Advanced</h3>
387
+ <label style="display: block; margin-bottom: 8px;">
388
+ <span style="display: block; margin-bottom: 4px;">Max Messages</span>
389
+ <input type="number" id="maxMessages" value="100" min="10" max="500"
390
+ style="padding: 8px; border: 1px solid var(--color-border); border-radius: 4px; background: var(--color-background); color: var(--color-foreground); width: 100px;" />
391
+ </label>
392
+ <label style="display: block;">
393
+ <span style="display: block; margin-bottom: 4px;">Response Delay (ms)</span>
394
+ <input type="number" id="responseDelay" value="0" min="0" max="5000" step="100"
395
+ style="padding: 8px; border: 1px solid var(--color-border); border-radius: 4px; background: var(--color-background); color: var(--color-foreground); width: 100px;" />
396
+ </label>
397
+ </div>
398
+
399
+ <div style="display: flex; gap: 12px;">
400
+ <button id="saveSettings" style="padding: 8px 16px; background: var(--color-primary); color: var(--color-foreground-on-accent); border: none; border-radius: 4px; cursor: pointer; font-weight: 500;">
401
+ Save Settings
402
+ </button>
403
+ <button id="resetSettings" style="padding: 8px 16px; background: transparent; color: var(--color-foreground); border: 1px solid var(--color-border); border-radius: 4px; cursor: pointer;">
404
+ Reset to Defaults
405
+ </button>
406
+ </div>
407
+ `;
408
+ const darkModeCheckbox = settingsDiv.querySelector('#darkMode');
409
+ darkModeCheckbox?.addEventListener('change', (e)=>{
410
+ console.log('Dark mode:', e.target.checked);
411
+ });
412
+ const saveButton = settingsDiv.querySelector('#saveSettings');
413
+ saveButton?.addEventListener('click', ()=>{
414
+ console.log('Settings saved:', {
415
+ darkMode: settingsDiv.querySelector('#darkMode').checked,
416
+ compactMode: settingsDiv.querySelector('#compactMode').checked,
417
+ autoScroll: settingsDiv.querySelector('#autoScroll').checked,
418
+ soundEnabled: settingsDiv.querySelector('#soundEnabled').checked,
419
+ maxMessages: settingsDiv.querySelector('#maxMessages').value,
420
+ responseDelay: settingsDiv.querySelector('#responseDelay').value
421
+ });
422
+ console.log('Settings saved successfully!');
423
+ });
424
+ const resetButton = settingsDiv.querySelector('#resetSettings');
425
+ resetButton?.addEventListener('click', ()=>{
426
+ settingsDiv.querySelector('#darkMode').checked = false;
427
+ settingsDiv.querySelector('#compactMode').checked = true;
428
+ settingsDiv.querySelector('#autoScroll').checked = true;
429
+ settingsDiv.querySelector('#soundEnabled').checked = false;
430
+ settingsDiv.querySelector('#maxMessages').value = '100';
431
+ settingsDiv.querySelector('#responseDelay').value = '0';
432
+ console.log('Settings reset to defaults');
433
+ });
434
+ container.appendChild(settingsDiv);
435
+ }, []);
436
+ useEffect(()=>{
437
+ const service = AutopilotChatService.Instantiate({
438
+ instanceName,
439
+ config: {
440
+ mode: initialMode,
441
+ readOnly: features.readOnly,
442
+ disabledFeatures: {
443
+ history: !features.history,
444
+ settings: !features.settings,
445
+ attachments: !features.attachments,
446
+ audio: !features.audio,
447
+ audioStreaming: !features.audioStreaming,
448
+ htmlPreview: !features.htmlPreview,
449
+ headerSeparator: !features.headerSeparator,
450
+ fullHeight: !features.fullHeight,
451
+ resize: !features.resize,
452
+ close: !features.close,
453
+ feedback: !features.feedback,
454
+ copy: !features.copy
455
+ },
456
+ settingsRenderer: createSettingsRenderer()
457
+ }
458
+ });
459
+ setChatService(service);
460
+ const unsubscribes = [];
461
+ service.setModels([
462
+ {
463
+ id: 'gpt-4',
464
+ name: 'GPT-4',
465
+ description: 'Most capable model'
466
+ },
467
+ {
468
+ id: 'gpt-3.5',
469
+ name: 'GPT-3.5 Turbo',
470
+ description: 'Fast and efficient'
471
+ },
472
+ {
473
+ id: 'claude-3',
474
+ name: 'Claude 3',
475
+ description: 'Anthropic model'
476
+ }
477
+ ]);
478
+ service.setSelectedModel('gpt-4');
479
+ service.setAgentModes([
480
+ {
481
+ id: 'agent',
482
+ name: 'Agent',
483
+ description: 'AI-powered autonomous agent mode',
484
+ icon: 'smart_toy'
485
+ },
486
+ {
487
+ id: 'plan',
488
+ name: 'Plan',
489
+ description: 'Create and review execution plans',
490
+ icon: 'edit_note'
491
+ },
492
+ {
493
+ id: 'attended',
494
+ name: 'Attended',
495
+ description: 'Human assisted execution',
496
+ icon: 'play_arrow'
497
+ }
498
+ ]);
499
+ service.setAgentMode('agent');
500
+ service.setCustomHeaderActions([
501
+ {
502
+ id: 'export',
503
+ name: 'Export Chat',
504
+ icon: 'download'
505
+ },
506
+ {
507
+ id: 'share',
508
+ name: 'Share',
509
+ icon: 'share'
510
+ }
511
+ ]);
512
+ service.setSuggestions([
513
+ {
514
+ label: 'What can you do?',
515
+ prompt: 'What can you do?'
516
+ },
517
+ {
518
+ label: 'Show me an example',
519
+ prompt: 'Show me an example'
520
+ },
521
+ {
522
+ label: 'Help me with code',
523
+ prompt: 'Help me with code'
524
+ }
525
+ ]);
526
+ service.setDefaultLoadingMessages([
527
+ 'Thinking...',
528
+ 'Processing your request...',
529
+ 'Analyzing...',
530
+ 'Working on it...'
531
+ ]);
532
+ service.setResourceManager(createResourceManager());
533
+ unsubscribes.push(service.on(AutopilotChatEvent.Request, (data)=>{
534
+ console.log('Request sent:', data);
535
+ }));
536
+ unsubscribes.push(service.on(AutopilotChatEvent.ModeChange, (mode)=>{
537
+ console.log('Mode changed:', mode);
538
+ }));
539
+ unsubscribes.push(service.on(AutopilotChatEvent.SetSelectedModel, (model)=>{
540
+ console.log('Model changed:', model);
541
+ setSelectedModel(model.id || model);
542
+ }));
543
+ unsubscribes.push(service.on(AutopilotChatEvent.SetSelectedAgentMode, (mode)=>{
544
+ console.log('Agent mode changed:', mode);
545
+ setSelectedAgentMode(mode.id);
546
+ }));
547
+ unsubscribes.push(service.on(AutopilotChatEvent.ModeChange, (mode)=>{
548
+ console.log('Chat mode changed:', mode);
549
+ setChatMode(mode);
550
+ }));
551
+ unsubscribes.push(service.on('feedback', (data)=>{
552
+ const { isPositive, message } = data;
553
+ console.log(`Feedback: ${isPositive ? 'Positive' : 'Negative'}`, message);
554
+ }));
555
+ unsubscribes.push(service.on('copy', (message)=>{
556
+ console.log('Copy event:', message);
557
+ }));
558
+ unsubscribes.push(service.on('attachments', (attachments)=>{
559
+ console.log('Attachments:', attachments);
560
+ }));
561
+ unsubscribes.push(service.on('stopResponse', ()=>{
562
+ console.log('Stop response event');
563
+ }));
564
+ const fakeSttPhrases = [
565
+ 'How do I schedule an unattended robot to run every weekday at 9 AM',
566
+ 'Show me the last ten failed jobs and group them by process name',
567
+ 'Can you walk me through setting up Document Understanding for invoices'
568
+ ];
569
+ let sttPhraseIndex = 0;
570
+ let sttDictationInterval = null;
571
+ unsubscribes.push(service.on(AutopilotChatEvent.SpeechToTextToggle, (isActive)=>{
572
+ console.log('[STT] toggle:', isActive);
573
+ if (isActive) {
574
+ const phrase = fakeSttPhrases[sttPhraseIndex % fakeSttPhrases.length] ?? '';
575
+ sttPhraseIndex++;
576
+ const words = phrase.split(' ');
577
+ let wordIndex = 0;
578
+ let transcript = '';
579
+ sttDictationInterval = setInterval(()=>{
580
+ if (wordIndex < words.length) {
581
+ transcript += (0 === wordIndex ? '' : ' ') + words[wordIndex];
582
+ service.setPrompt(transcript);
583
+ wordIndex++;
584
+ } else if (sttDictationInterval) {
585
+ clearInterval(sttDictationInterval);
586
+ sttDictationInterval = null;
587
+ }
588
+ }, 150);
589
+ } else if (sttDictationInterval) {
590
+ clearInterval(sttDictationInterval);
591
+ sttDictationInterval = null;
592
+ }
593
+ }));
594
+ unsubscribes.push(()=>{
595
+ if (sttDictationInterval) {
596
+ clearInterval(sttDictationInterval);
597
+ sttDictationInterval = null;
598
+ }
599
+ });
600
+ const fakeVoiceUserTurns = [
601
+ 'How do I debug a workflow in UiPath Studio?',
602
+ 'Can you suggest a retry strategy for flaky selectors?',
603
+ 'What is the difference between Attended and Unattended automations?'
604
+ ];
605
+ const fakeVoiceAssistantReplies = [
606
+ 'Start by enabling **Debug mode** in UiPath Studio and setting breakpoints on the activities you want to inspect. Use **Step Into** to walk through each action, and open the **Locals** panel to watch variables change.',
607
+ 'Wrap the click/type activity in a **Retry Scope** with 3-5 attempts and a short delay (500ms-2s). Pair it with a **Check App State** condition so the retry fires only when the expected element is missing.',
608
+ "**Attended** automations run on a user's machine alongside them. **Unattended** automations run on dedicated VMs without any user present; they're scheduled or queue-driven and scale across a robot fleet."
609
+ ];
610
+ let voiceTurnIndex = 0;
611
+ let voicePendingTimeouts = [];
612
+ let voicePendingInterval = null;
613
+ let voiceActiveStreamId = null;
614
+ const clearVoicePending = ()=>{
615
+ for (const id of voicePendingTimeouts)clearTimeout(id);
616
+ voicePendingTimeouts = [];
617
+ if (voicePendingInterval) {
618
+ clearInterval(voicePendingInterval);
619
+ voicePendingInterval = null;
620
+ }
621
+ };
622
+ unsubscribes.push(service.on(AutopilotChatEvent.InputStream, (event)=>{
623
+ const ev = event;
624
+ if (ev.activityStart) {
625
+ console.log('[voice] activityStart', ev.activityStart);
626
+ const userContent = fakeVoiceUserTurns[voiceTurnIndex % fakeVoiceUserTurns.length] ?? '';
627
+ const assistantContent = fakeVoiceAssistantReplies[voiceTurnIndex % fakeVoiceAssistantReplies.length] ?? '';
628
+ voiceTurnIndex++;
629
+ voiceActiveStreamId = `voice-stream-${voiceTurnIndex}`;
630
+ voicePendingTimeouts.push(setTimeout(()=>{
631
+ service.sendRequest({
632
+ content: userContent
633
+ });
634
+ voicePendingTimeouts.push(setTimeout(()=>{
635
+ const words = assistantContent.split(' ');
636
+ const streamId = voiceActiveStreamId ?? void 0;
637
+ let wordIndex = 0;
638
+ voicePendingInterval = setInterval(()=>{
639
+ if (wordIndex < words.length) {
640
+ service.sendResponse({
641
+ id: streamId,
642
+ content: (words[wordIndex] ?? '') + (wordIndex < words.length - 1 ? ' ' : ''),
643
+ stream: true,
644
+ created_at: new Date().toISOString(),
645
+ widget: 'apollo-markdown-renderer'
646
+ });
647
+ wordIndex++;
648
+ } else {
649
+ if (voicePendingInterval) {
650
+ clearInterval(voicePendingInterval);
651
+ voicePendingInterval = null;
652
+ }
653
+ service.sendResponse({
654
+ id: streamId,
655
+ content: '',
656
+ stream: true,
657
+ done: true,
658
+ created_at: new Date().toISOString(),
659
+ widget: 'apollo-markdown-renderer'
660
+ });
661
+ }
662
+ }, 80);
663
+ }, 400));
664
+ }, 600));
665
+ }
666
+ if (ev.mediaChunks) console.log('[voice] mediaChunks', ev.mediaChunks.length);
667
+ if (ev.activityEnd) {
668
+ console.log('[voice] activityEnd', ev.activityEnd);
669
+ const wasStreaming = null !== voicePendingInterval;
670
+ clearVoicePending();
671
+ if (wasStreaming && voiceActiveStreamId) service.sendResponse({
672
+ id: voiceActiveStreamId,
673
+ content: '',
674
+ stream: true,
675
+ done: true,
676
+ created_at: new Date().toISOString(),
677
+ widget: 'apollo-markdown-renderer'
678
+ });
679
+ voiceActiveStreamId = null;
680
+ }
681
+ }));
682
+ unsubscribes.push(()=>clearVoicePending());
683
+ unsubscribes.push(service.on('customHeaderActionClicked', (action)=>{
684
+ const actionData = action;
685
+ console.log('Custom header action clicked:', actionData);
686
+ let responseContent = '';
687
+ switch(actionData.id){
688
+ case 'export-pdf':
689
+ responseContent = '📄 **Exporting as PDF...**\n\nYour conversation has been exported to a PDF file.';
690
+ break;
691
+ case 'export-docx':
692
+ responseContent = '📝 **Exporting as DOCX...**\n\nYour conversation has been exported to a Word document.';
693
+ break;
694
+ case 'export-json':
695
+ responseContent = '💾 **Exporting as JSON...**\n\nYour conversation has been exported as JSON data.';
696
+ break;
697
+ case 'export-txt':
698
+ responseContent = '📋 **Exporting as Text...**\n\nYour conversation has been exported as plain text.';
699
+ break;
700
+ case 'share':
701
+ responseContent = '🔗 **Share Conversation**\n\nA shareable link has been generated:\n`https://example.com/chat/abc123`';
702
+ break;
703
+ case 'translate-es':
704
+ responseContent = '🇪🇸 **Traduciendo al español...**\n\nSu conversación ha sido traducida al español.';
705
+ break;
706
+ case 'translate-fr':
707
+ responseContent = '🇫🇷 **Traduction en français...**\n\nVotre conversation a été traduite en français.';
708
+ break;
709
+ case 'translate-de':
710
+ responseContent = '🇩🇪 **Übersetzung ins Deutsche...**\n\nIhre Unterhaltung wurde ins Deutsche übersetzt.';
711
+ break;
712
+ case 'translate-ja':
713
+ responseContent = '🇯🇵 **日本語に翻訳中...**\n\n会話が日本語に翻訳されました。';
714
+ break;
715
+ case 'translate-zh':
716
+ responseContent = '🇨🇳 **正在翻译成中文...**\n\n您的对话已翻译成中文。';
717
+ break;
718
+ case 'print':
719
+ responseContent = '🖨️ **Print Conversation**\n\nPreparing conversation for printing...';
720
+ break;
721
+ default:
722
+ responseContent = `✅ Action triggered: **${actionData.name}** (ID: ${actionData.id})`;
723
+ }
724
+ service.sendResponse({
725
+ content: responseContent,
726
+ groupId: `custom-action-${actionData.id}`,
727
+ created_at: '22-10-2025',
728
+ widget: 'apollo-markdown-renderer'
729
+ });
730
+ }));
731
+ return ()=>{
732
+ for (const unsubscribe of unsubscribes)unsubscribe();
733
+ service.close();
734
+ };
735
+ }, [
736
+ instanceName,
737
+ initialMode,
738
+ createResourceManager,
739
+ createSettingsRenderer,
740
+ features.attachments,
741
+ features.audio,
742
+ features.audioStreaming,
743
+ features.close,
744
+ features.copy,
745
+ features.feedback,
746
+ features.fullHeight,
747
+ features.headerSeparator,
748
+ features.history,
749
+ features.htmlPreview,
750
+ features.resize,
751
+ features.settings,
752
+ features.readOnly
753
+ ]);
754
+ useEffect(()=>{
755
+ if (chatService && chatMode === AutopilotChatMode.Embedded && embeddedContainerRef.current) chatService.patchConfig({
756
+ mode: AutopilotChatMode.Embedded,
757
+ embeddedContainer: embeddedContainerRef.current
758
+ });
759
+ }, [
760
+ chatService,
761
+ chatMode
762
+ ]);
763
+ useEffect(()=>{
764
+ if (chatService) {
765
+ chatService.initialize({
766
+ mode: chatMode,
767
+ readOnly: features.readOnly,
768
+ disabledFeatures: {
769
+ history: !features.history,
770
+ settings: !features.settings,
771
+ attachments: !features.attachments,
772
+ audio: !features.audio,
773
+ audioStreaming: !features.audioStreaming,
774
+ htmlPreview: !features.htmlPreview,
775
+ headerSeparator: !features.headerSeparator,
776
+ fullHeight: !features.fullHeight,
777
+ resize: !features.resize,
778
+ close: !features.close,
779
+ feedback: !features.feedback,
780
+ copy: !features.copy
781
+ },
782
+ settingsRenderer: createSettingsRenderer(),
783
+ ...chatMode === AutopilotChatMode.Embedded && embeddedContainerRef.current && {
784
+ embeddedContainer: embeddedContainerRef.current
785
+ }
786
+ });
787
+ if (features.model) {
788
+ chatService.setModels([
789
+ {
790
+ id: 'gpt-4',
791
+ name: 'GPT-4',
792
+ description: 'Most capable model'
793
+ },
794
+ {
795
+ id: 'gpt-3.5',
796
+ name: 'GPT-3.5 Turbo',
797
+ description: 'Fast and efficient'
798
+ },
799
+ {
800
+ id: 'claude-3',
801
+ name: 'Claude 3',
802
+ description: 'Anthropic model'
803
+ }
804
+ ]);
805
+ chatService.setSelectedModel(selectedModel);
806
+ } else chatService.setModels([]);
807
+ if (features.agentMode) {
808
+ chatService.setAgentModes([
809
+ {
810
+ id: 'agent',
811
+ name: 'Agent',
812
+ description: 'AI-powered autonomous agent mode',
813
+ icon: 'smart_toy'
814
+ },
815
+ {
816
+ id: 'plan',
817
+ name: 'Plan',
818
+ description: 'Create and review execution plans',
819
+ icon: 'edit_note'
820
+ },
821
+ {
822
+ id: 'attended',
823
+ name: 'Attended',
824
+ description: 'Human assisted execution',
825
+ icon: 'play_arrow'
826
+ }
827
+ ]);
828
+ chatService.setAgentMode(selectedAgentMode);
829
+ } else chatService.setAgentModes([]);
830
+ chatService.patchConfig({
831
+ paginatedMessages: features.paginatedMessages,
832
+ paginatedResources: resourcePaginationEnabled,
833
+ spacing: {
834
+ compactMode: features.compactMode,
835
+ ...features.compactMode ? {} : {
836
+ primaryFontToken,
837
+ promptBox: {
838
+ minRows: promptBoxMinRows,
839
+ maxRows: promptBoxMaxRows
840
+ }
841
+ }
842
+ },
843
+ theming: {
844
+ scrollBar: features.customScrollTheme ? {
845
+ scrollThumbColor: '#000000',
846
+ scrollSize: '16px',
847
+ scrollHoverColor: '#888888',
848
+ scrollBorderRadius: '8px'
849
+ } : void 0
850
+ }
851
+ });
852
+ if (features.attachmentsAsync) chatService.on('setAttachments', (attachments)=>{
853
+ const attachmentsData = attachments;
854
+ chatService.setAttachmentsLoading([
855
+ ...attachmentsData.added.map((attachment)=>({
856
+ ...attachment,
857
+ loading: true
858
+ }))
859
+ ]);
860
+ setTimeout(()=>{
861
+ chatService.setAttachmentsLoading([
862
+ ...attachmentsData.added.map((attachment)=>({
863
+ ...attachment,
864
+ loading: false
865
+ }))
866
+ ]);
867
+ }, 2000);
868
+ });
869
+ else chatService.setAttachmentsLoading([]);
870
+ }
871
+ }, [
872
+ features,
873
+ chatService,
874
+ selectedModel,
875
+ selectedAgentMode,
876
+ createSettingsRenderer,
877
+ chatMode,
878
+ primaryFontToken,
879
+ promptBoxMinRows,
880
+ promptBoxMaxRows,
881
+ resourcePaginationEnabled
882
+ ]);
883
+ const openChat = ()=>chatService?.open();
884
+ const closeChat = ()=>chatService?.close();
885
+ const setFullScreen = ()=>{
886
+ chatService?.setChatMode(AutopilotChatMode.FullScreen);
887
+ setChatMode(AutopilotChatMode.FullScreen);
888
+ };
889
+ const setSideBySide = ()=>{
890
+ chatService?.setChatMode(AutopilotChatMode.SideBySide);
891
+ setChatMode(AutopilotChatMode.SideBySide);
892
+ };
893
+ const setEmbedded = ()=>{
894
+ setChatMode(AutopilotChatMode.Embedded);
895
+ chatService?.setChatMode(AutopilotChatMode.Embedded);
896
+ };
897
+ const sendSimpleRequest = ()=>{
898
+ chatService?.sendRequest({
899
+ content: customMessage
900
+ });
901
+ };
902
+ const sendSimpleResponse = ()=>{
903
+ chatService?.sendResponse({
904
+ content: customMessage,
905
+ created_at: '22-10-2025',
906
+ widget: 'apollo-markdown-renderer',
907
+ shouldWaitForMoreMessages: waitForMore
908
+ });
909
+ };
910
+ const sendResponseWithActions = ()=>{
911
+ chatService?.sendResponse({
912
+ content: 'Here is a response with custom actions. Try the buttons below!',
913
+ created_at: '22-10-2025',
914
+ widget: 'apollo-markdown-renderer',
915
+ actions: [
916
+ {
917
+ name: 'copy-action',
918
+ label: 'Copy to Clipboard',
919
+ icon: 'content_copy',
920
+ eventName: 'copy-custom'
921
+ },
922
+ {
923
+ name: 'regenerate-action',
924
+ label: 'Regenerate',
925
+ icon: 'refresh',
926
+ eventName: 'regenerate-custom'
927
+ }
928
+ ]
929
+ });
930
+ chatService?.on('copy-custom', ()=>{
931
+ navigator.clipboard.writeText('Response copied!');
932
+ console.log('Copied to clipboard!');
933
+ });
934
+ chatService?.on('regenerate-custom', ()=>{
935
+ console.log('Regenerating response...');
936
+ });
937
+ };
938
+ const sendResponseWithCitations = ()=>{
939
+ chatService?.sendResponse({
940
+ content: 'According to research, the sky is blue due to Rayleigh scattering. See references below for more information.',
941
+ widget: 'default',
942
+ contentParts: [
943
+ {
944
+ text: 'According to research, the sky is blue due to Rayleigh scattering. ',
945
+ citations: [
946
+ {
947
+ id: 1,
948
+ title: 'Why is the Sky Blue?',
949
+ url: 'https://example.com/sky'
950
+ }
951
+ ]
952
+ },
953
+ {
954
+ text: 'See references below for more information.',
955
+ citations: [
956
+ {
957
+ id: 2,
958
+ title: 'Atmospheric Science',
959
+ url: 'https://example.com/atmosphere'
960
+ }
961
+ ]
962
+ }
963
+ ]
964
+ });
965
+ };
966
+ const sendStreamingResponse = ()=>{
967
+ chatService?.sendResponse({
968
+ content: streamingText,
969
+ fakeStream: true,
970
+ shouldWaitForMoreMessages: waitForMore
971
+ });
972
+ };
973
+ const sendCodeBlock = ()=>{
974
+ const codeContent = `\`\`\`typescript
975
+ // This is a long comment line that should wrap properly when displayed in the code block to test the wrapping functionality
976
+ interface UserProfile {
977
+ id: number;
978
+ username: string;
979
+ email: string;
980
+ firstName: string;
981
+ lastName: string;
982
+ createdAt: Date;
983
+ updatedAt: Date;
984
+ preferences: { theme: 'light' | 'dark'; language: string; notifications: boolean };
985
+ }
986
+
987
+ function processUserData(user: UserProfile, additionalMetadata: Record<string, unknown>): string {
988
+ const fullName = \`\${user.firstName} \${user.lastName}\`;
989
+ const metadataString = JSON.stringify(additionalMetadata, null, 2);
990
+
991
+ return \`User: \${fullName} (\${user.email}) - Created: \${user.createdAt.toISOString()} - Metadata: \${metadataString}\`;
992
+ }
993
+
994
+ const exampleUser: UserProfile = {
995
+ id: 12345,
996
+ username: 'john_doe_with_a_very_long_username_that_should_test_wrapping',
997
+ email: 'john.doe.with.a.very.long.email.address@example-domain-name.com',
998
+ firstName: 'John',
999
+ lastName: 'Doe',
1000
+ createdAt: new Date(),
1001
+ updatedAt: new Date(),
1002
+ preferences: { theme: 'dark', language: 'en-US', notifications: true }
1003
+ };
1004
+
1005
+ console.log(processUserData(exampleUser, { source: 'web', ipAddress: '192.168.1.1', userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' }));
1006
+ \`\`\``;
1007
+ chatService?.sendResponse({
1008
+ content: `Here's a TypeScript example with long lines to test wrapping:\n\n${codeContent}`,
1009
+ widget: 'default'
1010
+ });
1011
+ };
1012
+ const sendHTMLPreview = ()=>{
1013
+ const htmlContent = `\`\`\`html
1014
+ <!DOCTYPE html>
1015
+ <html>
1016
+ <head>
1017
+ <title>Hello World</title>
1018
+ <style>
1019
+ body { font-family: Arial; text-align: center; padding: 50px; }
1020
+ h1 { color: #fa4616; }
1021
+ </style>
1022
+ </head>
1023
+ <body>
1024
+ <h1>Hello, World!</h1>
1025
+ <p>This is an HTML preview example.</p>
1026
+ </body>
1027
+ </html>
1028
+ \`\`\``;
1029
+ chatService?.sendResponse({
1030
+ content: `Here's an HTML example with live preview:\n\n${htmlContent}`,
1031
+ widget: 'default'
1032
+ });
1033
+ };
1034
+ const showLoading = ()=>{
1035
+ chatService?.setLoadingMessage(loadingMessage);
1036
+ };
1037
+ const hideLoading = ()=>{
1038
+ chatService?.setLoadingMessage('');
1039
+ };
1040
+ const showError = ()=>{
1041
+ chatService?.setError(errorMessage);
1042
+ };
1043
+ const showWarning = ()=>{
1044
+ chatService?.setError('This is a warning message.');
1045
+ };
1046
+ const clearErrors = ()=>{
1047
+ chatService?.clearError();
1048
+ };
1049
+ const toggleHistory = ()=>{
1050
+ chatService?.toggleHistory();
1051
+ };
1052
+ const addHistoryItems = ()=>{
1053
+ chatService?.setHistory([
1054
+ {
1055
+ id: '1',
1056
+ name: 'Previous Conversation 1',
1057
+ timestamp: new Date(Date.now() - 86400000).toISOString()
1058
+ },
1059
+ {
1060
+ id: '2',
1061
+ name: 'Previous Conversation 2',
1062
+ timestamp: new Date(Date.now() - 172800000).toISOString()
1063
+ },
1064
+ {
1065
+ id: '3',
1066
+ name: 'Previous Conversation 3',
1067
+ timestamp: new Date(Date.now() - 259200000).toISOString()
1068
+ }
1069
+ ]);
1070
+ };
1071
+ const clearChat = ()=>{
1072
+ chatService?.newChat();
1073
+ };
1074
+ const toggleFeature = (feature)=>{
1075
+ setFeatures((prev)=>({
1076
+ ...prev,
1077
+ [feature]: !prev[feature]
1078
+ }));
1079
+ };
1080
+ const setPrompt = ()=>{
1081
+ chatService?.setPrompt('I need something to be done');
1082
+ };
1083
+ const resetPrompt = ()=>{
1084
+ chatService?.setPrompt('');
1085
+ };
1086
+ const stopResponse = ()=>{
1087
+ chatService?.stopResponse();
1088
+ };
1089
+ const toggleAutoScroll = ()=>{
1090
+ const newValue = !autoScroll;
1091
+ setAutoScroll(newValue);
1092
+ chatService?.toggleAutoScroll(newValue);
1093
+ };
1094
+ const setAllowedAttachments = ()=>{
1095
+ chatService?.setAllowedAttachments({
1096
+ types: {
1097
+ 'text/csv': [
1098
+ '.csv'
1099
+ ]
1100
+ },
1101
+ maxSize: 1048576,
1102
+ multiple: false
1103
+ });
1104
+ console.log('Allowed attachments set to: CSV files only, max 1MB');
1105
+ };
1106
+ const setFirstRunExperience = ()=>{
1107
+ chatService?.setFirstRunExperience({
1108
+ title: 'Welcome to UiPath Autopilot',
1109
+ description: "I'm here to help you build, understand, and troubleshoot your automation projects.",
1110
+ suggestions: [
1111
+ {
1112
+ label: 'New process',
1113
+ prompt: 'Can you provide a detailed step-by-step guide on how to create a new automation process?'
1114
+ },
1115
+ {
1116
+ label: 'Debug workflow',
1117
+ prompt: "I'm having trouble with my workflow execution. Can you explain debugging techniques?"
1118
+ },
1119
+ {
1120
+ label: 'Studio updates',
1121
+ prompt: 'What are the latest features in UiPath Studio?'
1122
+ }
1123
+ ]
1124
+ });
1125
+ };
1126
+ const setConversation = ()=>{
1127
+ chatService?.setConversation([
1128
+ {
1129
+ id: '1',
1130
+ role: AutopilotChatRole.User,
1131
+ content: 'How do I create a workflow that extracts data from invoices?',
1132
+ created_at: '22-10-2022',
1133
+ widget: ''
1134
+ },
1135
+ {
1136
+ id: '2',
1137
+ role: AutopilotChatRole.Assistant,
1138
+ content: 'To extract data from invoices, you can use UiPath Document Understanding. Here\'s a step-by-step approach:\n\n1. Install the Document Understanding package\n2. Create a new workflow and add the "Digitize Document" activity\n3. Configure it to use ML skills\n4. Use the "Data Extraction" activity\n5. Validate the extracted data',
1139
+ created_at: '23-10-2022',
1140
+ widget: ''
1141
+ }
1142
+ ]);
1143
+ };
1144
+ const setSuggestions = ()=>{
1145
+ chatService?.setSuggestions([
1146
+ {
1147
+ label: 'What can you do?',
1148
+ prompt: 'What can you do?'
1149
+ },
1150
+ {
1151
+ label: 'Show me an example',
1152
+ prompt: 'Show me an example'
1153
+ },
1154
+ {
1155
+ label: 'Help me with code',
1156
+ prompt: 'Help me with code'
1157
+ }
1158
+ ], true);
1159
+ };
1160
+ const sendToolCall = ()=>{
1161
+ chatService?.sendResponse({
1162
+ content: 'Tool call response',
1163
+ widget: 'apollo-agents-tool-call',
1164
+ meta: {
1165
+ input: {
1166
+ provider: 'GoogleCustomSearch',
1167
+ query: 'most interesting scientific fact discovered recently 2025',
1168
+ num: 5
1169
+ },
1170
+ output: {
1171
+ results: [
1172
+ {
1173
+ snippet: 'Breaking science news and articles...',
1174
+ title: 'ScienceDaily: Latest Research News',
1175
+ url: 'https://www.sciencedaily.com/'
1176
+ }
1177
+ ]
1178
+ },
1179
+ isError: false,
1180
+ startTime: new Date().toISOString(),
1181
+ endTime: new Date().toISOString(),
1182
+ toolName: 'Web_Search'
1183
+ }
1184
+ });
1185
+ };
1186
+ const sendResponseDisabledActions = ()=>{
1187
+ chatService?.sendResponse({
1188
+ content: 'Message with no actions',
1189
+ disableActions: true
1190
+ });
1191
+ };
1192
+ const setPreHook = ()=>{
1193
+ const actions = [
1194
+ 'new-chat',
1195
+ 'toggle-history',
1196
+ 'toggle-chat',
1197
+ 'close-chat',
1198
+ 'feedback'
1199
+ ];
1200
+ actions.forEach((action)=>{
1201
+ chatService?.setPreHook(action, async ()=>window.confirm(`${action} pre hook. Continue?`));
1202
+ });
1203
+ console.log('Pre-hooks set for all actions');
1204
+ };
1205
+ const setCustomHeaderActions = ()=>{
1206
+ chatService?.setCustomHeaderActions([
1207
+ {
1208
+ id: 'export',
1209
+ name: 'Export',
1210
+ icon: 'download',
1211
+ description: 'Export conversation in various formats',
1212
+ children: [
1213
+ {
1214
+ id: 'export-pdf',
1215
+ name: 'Export as PDF',
1216
+ icon: 'picture_as_pdf',
1217
+ description: 'Download conversation as PDF file'
1218
+ },
1219
+ {
1220
+ id: 'export-docx',
1221
+ name: 'Export as DOCX',
1222
+ icon: "description",
1223
+ description: 'Download conversation as Word document'
1224
+ },
1225
+ {
1226
+ id: 'export-json',
1227
+ name: 'Export as JSON',
1228
+ icon: 'data_object',
1229
+ description: 'Download conversation as JSON file'
1230
+ },
1231
+ {
1232
+ id: 'export-txt',
1233
+ name: 'Export as Text',
1234
+ icon: 'text_snippet',
1235
+ description: 'Download conversation as plain text'
1236
+ }
1237
+ ]
1238
+ },
1239
+ {
1240
+ id: 'share',
1241
+ name: 'Share Conversation',
1242
+ icon: 'share',
1243
+ description: 'Share this conversation with others'
1244
+ },
1245
+ {
1246
+ id: 'translate',
1247
+ name: 'Translate',
1248
+ icon: 'translate',
1249
+ description: 'Translate conversation to different languages',
1250
+ children: [
1251
+ {
1252
+ id: 'translate-es',
1253
+ name: 'Spanish',
1254
+ icon: 'language',
1255
+ description: 'Translate to Spanish'
1256
+ },
1257
+ {
1258
+ id: 'translate-fr',
1259
+ name: 'French',
1260
+ icon: 'language',
1261
+ description: 'Translate to French'
1262
+ },
1263
+ {
1264
+ id: 'translate-de',
1265
+ name: 'German',
1266
+ icon: 'language',
1267
+ description: 'Translate to German'
1268
+ },
1269
+ {
1270
+ id: 'translate-ja',
1271
+ name: 'Japanese',
1272
+ icon: 'language',
1273
+ description: 'Translate to Japanese'
1274
+ },
1275
+ {
1276
+ id: 'translate-zh',
1277
+ name: 'Chinese',
1278
+ icon: 'language',
1279
+ description: 'Translate to Chinese'
1280
+ }
1281
+ ]
1282
+ },
1283
+ {
1284
+ id: 'print',
1285
+ name: 'Print',
1286
+ icon: 'print',
1287
+ description: 'Print conversation'
1288
+ },
1289
+ {
1290
+ id: 'advanced',
1291
+ name: 'Advanced Settings',
1292
+ icon: 'tune',
1293
+ description: 'Advanced configuration options',
1294
+ disabled: true
1295
+ }
1296
+ ]);
1297
+ console.log('Custom header actions set');
1298
+ };
1299
+ const clearCustomHeaderActions = ()=>{
1300
+ chatService?.setCustomHeaderActions([]);
1301
+ console.log('Custom header actions cleared');
1302
+ };
1303
+ const setResourceManager = ()=>{
1304
+ chatService?.setResourceManager(createResourceManager());
1305
+ console.log('Resource manager set');
1306
+ };
1307
+ const clearResourceManager = ()=>{
1308
+ chatService?.setResourceManager(null);
1309
+ console.log('Resource manager cleared');
1310
+ };
1311
+ useEffect(()=>{
1312
+ if (chatService) {
1313
+ chatService.setResourceManager(createResourceManager());
1314
+ console.log(`Resource manager updated: pagination=${resourcePaginationEnabled}, pageSize=${resourcePageSize}`);
1315
+ }
1316
+ }, [
1317
+ chatService,
1318
+ createResourceManager,
1319
+ resourcePaginationEnabled,
1320
+ resourcePageSize
1321
+ ]);
1322
+ const sendResponseWithVariables = ()=>{
1323
+ chatService?.sendResponse({
1324
+ content: 'I will update [[resource-token:{"id":"var-email","type":"variable","icon":"mail","displayName":"email"}]] and [[resource-token:{"id":"var-long","type":"variable","icon":"data_object","displayName":"this_is_a_very_long_variable_name_that_should_test_truncation"}]] in the system, then notify [[resource-token:{"id":"var-username","type":"variable","icon":"person","displayName":"username"}]] when complete.',
1325
+ created_at: '02-02-2026',
1326
+ widget: 'default'
1327
+ });
1328
+ console.log('Sent response with resource tokens');
1329
+ };
1330
+ const streamWithResourceTokens = ()=>{
1331
+ const messageId = `streaming-resources-${Date.now()}`;
1332
+ let chunkIndex = 0;
1333
+ const chunks = [
1334
+ 'I will update the ',
1335
+ '[[resource-token:',
1336
+ '{"id":"var-',
1337
+ 'email","type":"variable",',
1338
+ '"icon":"mail","displayName":"email"}]]',
1339
+ ' variable in the system.\n\n',
1340
+ "Then I'll notify ",
1341
+ '[[resource-token:{',
1342
+ '"id":"var-username",',
1343
+ '"type":"variable","icon":"person",',
1344
+ '"displayName":"username"}]]',
1345
+ ' when the process is complete.\n\n',
1346
+ "I'll also update ",
1347
+ '[[resource-token:{',
1348
+ '"id":"var-long","type":"variable",',
1349
+ '"icon":"data_object","displayName":',
1350
+ '"this_is_a_very_long_variable_name_that_should_test_truncation"}]]',
1351
+ ' for testing.\n\n',
1352
+ "Finally, I'll log the result to ",
1353
+ '[[resource-token:{"id":"var-log","type":"variable","icon":"description","displayName":"activity_log"}]]',
1354
+ '.'
1355
+ ];
1356
+ const streamChunk = ()=>{
1357
+ if (chunkIndex >= chunks.length) return;
1358
+ const chunk = chunks[chunkIndex] ?? '';
1359
+ const isDone = chunkIndex === chunks.length - 1;
1360
+ chatService?.sendResponse({
1361
+ id: messageId,
1362
+ content: chunk,
1363
+ stream: true,
1364
+ done: isDone,
1365
+ created_at: '02-02-2026',
1366
+ widget: 'default'
1367
+ });
1368
+ const preview = chunk.slice(0, 30);
1369
+ const suffix = chunk.length > 30 ? '...' : '';
1370
+ console.log(`[StreamWithResourceTokens] Chunk ${chunkIndex + 1}/${chunks.length}: "${preview}${suffix}" (done: ${isDone})`);
1371
+ chunkIndex++;
1372
+ if (!isDone) setTimeout(streamChunk, 150);
1373
+ };
1374
+ streamChunk();
1375
+ };
1376
+ const streamWithCitations = ()=>{
1377
+ const messageId = `streaming-citations-${Date.now()}`;
1378
+ let streamIndex = 0;
1379
+ const streamingParts = [
1380
+ {
1381
+ index: 0,
1382
+ text: 'Based on the search results'
1383
+ },
1384
+ {
1385
+ index: 0,
1386
+ text: ", I'll"
1387
+ },
1388
+ {
1389
+ index: 0,
1390
+ text: ' create a comprehensive'
1391
+ },
1392
+ {
1393
+ index: 0,
1394
+ text: ' summary about UiPath with'
1395
+ },
1396
+ {
1397
+ index: 0,
1398
+ text: ' citations:\n\n##'
1399
+ },
1400
+ {
1401
+ index: 0,
1402
+ text: ' Company Background'
1403
+ },
1404
+ {
1405
+ index: 0,
1406
+ text: '\n- '
1407
+ },
1408
+ {
1409
+ index: 1,
1410
+ text: '**UiPath Inc**'
1411
+ },
1412
+ {
1413
+ index: 1,
1414
+ text: '. is a global'
1415
+ },
1416
+ {
1417
+ index: 1,
1418
+ text: ' software company that was'
1419
+ },
1420
+ {
1421
+ index: 1,
1422
+ text: ' founded in '
1423
+ },
1424
+ {
1425
+ index: 1,
1426
+ text: '_Bucharest, Romania_'
1427
+ },
1428
+ {
1429
+ index: 1,
1430
+ text: ', by'
1431
+ },
1432
+ {
1433
+ index: 1,
1434
+ text: ' **Daniel Dines**'
1435
+ },
1436
+ {
1437
+ index: 1,
1438
+ text: '',
1439
+ citation: {
1440
+ id: 1,
1441
+ title: 'UiPath - Wikipedia',
1442
+ url: 'https://en.wikipedia.org/wiki/UiPath'
1443
+ }
1444
+ },
1445
+ {
1446
+ index: 2,
1447
+ text: '. '
1448
+ },
1449
+ {
1450
+ index: 3,
1451
+ text: 'The'
1452
+ },
1453
+ {
1454
+ index: 3,
1455
+ text: ' company starte'
1456
+ },
1457
+ {
1458
+ index: 3,
1459
+ text: 'd its journey'
1460
+ },
1461
+ {
1462
+ index: 3,
1463
+ text: ' in 2005'
1464
+ },
1465
+ {
1466
+ index: 3,
1467
+ text: ' and has'
1468
+ },
1469
+ {
1470
+ index: 3,
1471
+ text: ' grown to become a leading'
1472
+ },
1473
+ {
1474
+ index: 3,
1475
+ text: ' enterprise automation software ven'
1476
+ },
1477
+ {
1478
+ index: 3,
1479
+ text: 'dor',
1480
+ citation: {
1481
+ id: 1,
1482
+ title: 'UiPath - Wikipedia',
1483
+ url: 'https://en.wikipedia.org/wiki/UiPath'
1484
+ }
1485
+ },
1486
+ {
1487
+ index: 3,
1488
+ text: '',
1489
+ citation: {
1490
+ id: 2,
1491
+ title: 'UiPath, Inc. (PATH)',
1492
+ url: 'https://ir.uipath.com/'
1493
+ }
1494
+ },
1495
+ {
1496
+ index: 4,
1497
+ text: '. \n\n## Core'
1498
+ },
1499
+ {
1500
+ index: 4,
1501
+ text: ' Business'
1502
+ },
1503
+ {
1504
+ index: 4,
1505
+ text: '\nU'
1506
+ },
1507
+ {
1508
+ index: 4,
1509
+ text: 'iPath special'
1510
+ },
1511
+ {
1512
+ index: 4,
1513
+ text: 'izes in several'
1514
+ },
1515
+ {
1516
+ index: 4,
1517
+ text: ' key areas:\n\n1'
1518
+ },
1519
+ {
1520
+ index: 4,
1521
+ text: '. **Rob'
1522
+ },
1523
+ {
1524
+ index: 4,
1525
+ text: 'otic Process Automation'
1526
+ },
1527
+ {
1528
+ index: 4,
1529
+ text: ':**'
1530
+ },
1531
+ {
1532
+ index: 4,
1533
+ text: '\n'
1534
+ },
1535
+ {
1536
+ index: 5,
1537
+ text: 'R'
1538
+ },
1539
+ {
1540
+ index: 5,
1541
+ text: 'PA has'
1542
+ },
1543
+ {
1544
+ index: 5,
1545
+ text: ' revolutionized how work'
1546
+ },
1547
+ {
1548
+ index: 5,
1549
+ text: ' gets done globally'
1550
+ },
1551
+ {
1552
+ index: 5,
1553
+ text: ' by eliminating time'
1554
+ },
1555
+ {
1556
+ index: 5,
1557
+ text: '-consuming, repet'
1558
+ },
1559
+ {
1560
+ index: 5,
1561
+ text: 'itive tasks from employees'
1562
+ },
1563
+ {
1564
+ index: 5,
1565
+ text: "' worklo"
1566
+ },
1567
+ {
1568
+ index: 5,
1569
+ text: 'ads',
1570
+ citation: {
1571
+ id: 3,
1572
+ title: 'Discovery Phase Guide',
1573
+ download_url: 'https://ontheline.trincoll.edu/images/bookdown/sample-local-pdf.pdf',
1574
+ page_number: 2
1575
+ }
1576
+ },
1577
+ {
1578
+ index: 6,
1579
+ text: '.'
1580
+ },
1581
+ {
1582
+ index: 6,
1583
+ text: '\n\n2. **'
1584
+ },
1585
+ {
1586
+ index: 6,
1587
+ text: 'Business Automation Platform**'
1588
+ },
1589
+ {
1590
+ index: 6,
1591
+ text: '\n'
1592
+ },
1593
+ {
1594
+ index: 7,
1595
+ text: 'The platform'
1596
+ },
1597
+ {
1598
+ index: 7,
1599
+ text: ' offers en'
1600
+ },
1601
+ {
1602
+ index: 7,
1603
+ text: 'd-to-en'
1604
+ },
1605
+ {
1606
+ index: 7,
1607
+ text: 'd process transformation'
1608
+ },
1609
+ {
1610
+ index: 7,
1611
+ text: ' capabilities on'
1612
+ },
1613
+ {
1614
+ index: 7,
1615
+ text: ' a single platform,'
1616
+ },
1617
+ {
1618
+ index: 7,
1619
+ text: ' featuring fully'
1620
+ },
1621
+ {
1622
+ index: 7,
1623
+ text: ' governed agentic'
1624
+ },
1625
+ {
1626
+ index: 7,
1627
+ text: ' automation that integ'
1628
+ },
1629
+ {
1630
+ index: 7,
1631
+ text: 'rates with existing systems'
1632
+ },
1633
+ {
1634
+ index: 7,
1635
+ text: '',
1636
+ citation: {
1637
+ id: 4,
1638
+ title: 'UiPath Business Automation Platform | UiPath',
1639
+ url: 'https://www.uipath.com/product'
1640
+ }
1641
+ }
1642
+ ];
1643
+ const streamChunk = ()=>{
1644
+ if (streamIndex >= streamingParts.length) return;
1645
+ const chunk = streamingParts[streamIndex];
1646
+ if (!chunk) return;
1647
+ chatService?.sendResponse({
1648
+ id: messageId,
1649
+ contentPartChunk: {
1650
+ index: chunk.index,
1651
+ text: chunk.text,
1652
+ ...chunk.citation && {
1653
+ citation: chunk.citation
1654
+ }
1655
+ },
1656
+ stream: true,
1657
+ done: streamIndex === streamingParts.length - 1
1658
+ });
1659
+ streamIndex++;
1660
+ if (streamIndex < streamingParts.length) setTimeout(streamChunk, 100);
1661
+ };
1662
+ streamChunk();
1663
+ };
1664
+ const handleAgentModeChange = (mode)=>{
1665
+ setSelectedAgentMode(mode);
1666
+ chatService?.setAgentMode(mode);
1667
+ };
1668
+ const handleModelChange = (modelId)=>{
1669
+ setSelectedModel(modelId);
1670
+ chatService?.setSelectedModel(modelId);
1671
+ };
1672
+ return /*#__PURE__*/ jsxs(Box, {
1673
+ sx: {
1674
+ display: 'flex',
1675
+ width: '100%'
1676
+ },
1677
+ children: [
1678
+ /*#__PURE__*/ jsxs(Box, {
1679
+ sx: {
1680
+ display: chatMode === AutopilotChatMode.FullScreen ? 'none' : 'flex',
1681
+ flexDirection: 'column',
1682
+ flexGrow: 1,
1683
+ gap: 1,
1684
+ maxHeight: '100vh',
1685
+ overflowY: 'auto',
1686
+ p: '16px 0 0 16px',
1687
+ boxSizing: 'border-box'
1688
+ },
1689
+ children: [
1690
+ /*#__PURE__*/ jsx(ApTypography, {
1691
+ variant: FontVariantToken.fontSizeH3Bold,
1692
+ component: "h2",
1693
+ sx: {
1694
+ mb: 3
1695
+ },
1696
+ children: "ApChat Showcase"
1697
+ }),
1698
+ /*#__PURE__*/ jsxs(Section, {
1699
+ children: [
1700
+ /*#__PURE__*/ jsx(SectionTitle, {
1701
+ children: "Chat Mode Controls"
1702
+ }),
1703
+ /*#__PURE__*/ jsxs(ButtonGroup, {
1704
+ children: [
1705
+ /*#__PURE__*/ jsx(DemoButton, {
1706
+ primary: true,
1707
+ onClick: openChat,
1708
+ children: "Open Chat"
1709
+ }),
1710
+ /*#__PURE__*/ jsx(DemoButton, {
1711
+ onClick: closeChat,
1712
+ children: "Close Chat"
1713
+ })
1714
+ ]
1715
+ }),
1716
+ /*#__PURE__*/ jsxs(ButtonGroup, {
1717
+ children: [
1718
+ /*#__PURE__*/ jsx(DemoButton, {
1719
+ onClick: setSideBySide,
1720
+ children: "Side by Side"
1721
+ }),
1722
+ /*#__PURE__*/ jsx(DemoButton, {
1723
+ onClick: setFullScreen,
1724
+ children: "Full Screen"
1725
+ }),
1726
+ /*#__PURE__*/ jsx(DemoButton, {
1727
+ onClick: setEmbedded,
1728
+ children: "Embedded"
1729
+ })
1730
+ ]
1731
+ }),
1732
+ /*#__PURE__*/ jsxs(ButtonGroup, {
1733
+ children: [
1734
+ /*#__PURE__*/ jsx(DemoButton, {
1735
+ onClick: toggleAutoScroll,
1736
+ children: "Toggle Auto Scroll"
1737
+ }),
1738
+ /*#__PURE__*/ jsx(DemoButton, {
1739
+ onClick: clearChat,
1740
+ children: "Clear Chat"
1741
+ })
1742
+ ]
1743
+ })
1744
+ ]
1745
+ }),
1746
+ /*#__PURE__*/ jsxs(Section, {
1747
+ children: [
1748
+ /*#__PURE__*/ jsx(SectionTitle, {
1749
+ children: "Chat Setup"
1750
+ }),
1751
+ /*#__PURE__*/ jsxs(ButtonGroup, {
1752
+ children: [
1753
+ /*#__PURE__*/ jsx(DemoButton, {
1754
+ onClick: setAllowedAttachments,
1755
+ children: "Set Allowed Attachments"
1756
+ }),
1757
+ /*#__PURE__*/ jsx(DemoButton, {
1758
+ onClick: setPreHook,
1759
+ children: "Set Pre Hook"
1760
+ })
1761
+ ]
1762
+ }),
1763
+ /*#__PURE__*/ jsx(ButtonGroup, {
1764
+ children: /*#__PURE__*/ jsx(DemoButton, {
1765
+ onClick: setFirstRunExperience,
1766
+ children: "Set First Run Experience"
1767
+ })
1768
+ })
1769
+ ]
1770
+ }),
1771
+ /*#__PURE__*/ jsxs(Section, {
1772
+ children: [
1773
+ /*#__PURE__*/ jsx(SectionTitle, {
1774
+ children: "Custom Header Actions"
1775
+ }),
1776
+ /*#__PURE__*/ jsxs(ButtonGroup, {
1777
+ children: [
1778
+ /*#__PURE__*/ jsx(DemoButton, {
1779
+ onClick: setCustomHeaderActions,
1780
+ children: "Set Custom Header Actions"
1781
+ }),
1782
+ /*#__PURE__*/ jsx(DemoButton, {
1783
+ onClick: clearCustomHeaderActions,
1784
+ children: "Clear Custom Header Actions"
1785
+ })
1786
+ ]
1787
+ })
1788
+ ]
1789
+ }),
1790
+ /*#__PURE__*/ jsxs(Section, {
1791
+ children: [
1792
+ /*#__PURE__*/ jsx(SectionTitle, {
1793
+ children: "Resource Manager"
1794
+ }),
1795
+ /*#__PURE__*/ jsxs(ButtonGroup, {
1796
+ children: [
1797
+ /*#__PURE__*/ jsx(DemoButton, {
1798
+ onClick: setResourceManager,
1799
+ children: "Set Resource Manager"
1800
+ }),
1801
+ /*#__PURE__*/ jsx(DemoButton, {
1802
+ onClick: clearResourceManager,
1803
+ children: "Clear Resource Manager"
1804
+ })
1805
+ ]
1806
+ }),
1807
+ /*#__PURE__*/ jsx(FormControlLabel, {
1808
+ control: /*#__PURE__*/ jsx(Checkbox, {
1809
+ size: "small",
1810
+ checked: resourcePaginationEnabled,
1811
+ onChange: ()=>setResourcePaginationEnabled(!resourcePaginationEnabled)
1812
+ }),
1813
+ label: "Enable Pagination (50 vars, 30 files)"
1814
+ }),
1815
+ /*#__PURE__*/ jsxs(InfoText, {
1816
+ style: {
1817
+ marginTop: 8
1818
+ },
1819
+ children: [
1820
+ "Page Size: ",
1821
+ resourcePageSize
1822
+ ]
1823
+ }),
1824
+ /*#__PURE__*/ jsx(DemoInput, {
1825
+ type: "number",
1826
+ min: 1,
1827
+ max: 20,
1828
+ value: resourcePageSize,
1829
+ onChange: (e)=>setResourcePageSize(Number(e.target.value)),
1830
+ style: {
1831
+ width: 80
1832
+ }
1833
+ }),
1834
+ /*#__PURE__*/ jsx(InfoText, {
1835
+ children: "Type @ in the chat input to trigger the picker. Test keyboard navigation (↑/↓), selection (Enter/Tab), and escape behavior."
1836
+ })
1837
+ ]
1838
+ }),
1839
+ /*#__PURE__*/ jsxs(Section, {
1840
+ children: [
1841
+ /*#__PURE__*/ jsx(SectionTitle, {
1842
+ children: "Model Selection"
1843
+ }),
1844
+ /*#__PURE__*/ jsxs(DemoSelect, {
1845
+ value: selectedModel,
1846
+ onChange: (e)=>handleModelChange(e.target.value),
1847
+ children: [
1848
+ /*#__PURE__*/ jsx("option", {
1849
+ value: "gpt-4",
1850
+ children: "GPT-4"
1851
+ }),
1852
+ /*#__PURE__*/ jsx("option", {
1853
+ value: "gpt-3.5",
1854
+ children: "GPT-3.5 Turbo"
1855
+ }),
1856
+ /*#__PURE__*/ jsx("option", {
1857
+ value: "claude-3",
1858
+ children: "Claude 3"
1859
+ })
1860
+ ]
1861
+ })
1862
+ ]
1863
+ }),
1864
+ /*#__PURE__*/ jsxs(Section, {
1865
+ children: [
1866
+ /*#__PURE__*/ jsx(SectionTitle, {
1867
+ children: "Agent Mode"
1868
+ }),
1869
+ /*#__PURE__*/ jsxs(DemoSelect, {
1870
+ value: selectedAgentMode,
1871
+ onChange: (e)=>handleAgentModeChange(e.target.value),
1872
+ children: [
1873
+ /*#__PURE__*/ jsx("option", {
1874
+ value: "agent",
1875
+ children: "Agent"
1876
+ }),
1877
+ /*#__PURE__*/ jsx("option", {
1878
+ value: "plan",
1879
+ children: "Plan"
1880
+ }),
1881
+ /*#__PURE__*/ jsx("option", {
1882
+ value: "attended",
1883
+ children: "Attended"
1884
+ })
1885
+ ]
1886
+ })
1887
+ ]
1888
+ }),
1889
+ /*#__PURE__*/ jsxs(Section, {
1890
+ children: [
1891
+ /*#__PURE__*/ jsx(SectionTitle, {
1892
+ children: "Input Styling"
1893
+ }),
1894
+ /*#__PURE__*/ jsx(InfoText, {
1895
+ children: "Primary Font Token"
1896
+ }),
1897
+ /*#__PURE__*/ jsxs(DemoSelect, {
1898
+ value: primaryFontToken,
1899
+ onChange: (e)=>setPrimaryFontToken(e.target.value),
1900
+ children: [
1901
+ /*#__PURE__*/ jsx("option", {
1902
+ value: FontVariantToken.fontSizeXs,
1903
+ children: "XS (fontSizeXs)"
1904
+ }),
1905
+ /*#__PURE__*/ jsx("option", {
1906
+ value: FontVariantToken.fontSizeS,
1907
+ children: "S (fontSizeS)"
1908
+ }),
1909
+ /*#__PURE__*/ jsx("option", {
1910
+ value: FontVariantToken.fontSizeM,
1911
+ children: "M (fontSizeM)"
1912
+ }),
1913
+ /*#__PURE__*/ jsx("option", {
1914
+ value: FontVariantToken.fontSizeL,
1915
+ children: "L (fontSizeL)"
1916
+ })
1917
+ ]
1918
+ }),
1919
+ /*#__PURE__*/ jsxs(InfoText, {
1920
+ style: {
1921
+ marginTop: 12
1922
+ },
1923
+ children: [
1924
+ "Prompt Box Min Rows: ",
1925
+ promptBoxMinRows
1926
+ ]
1927
+ }),
1928
+ /*#__PURE__*/ jsx(DemoInput, {
1929
+ type: "number",
1930
+ min: 1,
1931
+ max: 10,
1932
+ value: promptBoxMinRows,
1933
+ onChange: (e)=>setPromptBoxMinRows(Number(e.target.value))
1934
+ }),
1935
+ /*#__PURE__*/ jsxs(InfoText, {
1936
+ style: {
1937
+ marginTop: 12
1938
+ },
1939
+ children: [
1940
+ "Prompt Box Max Rows: ",
1941
+ promptBoxMaxRows
1942
+ ]
1943
+ }),
1944
+ /*#__PURE__*/ jsx(DemoInput, {
1945
+ type: "number",
1946
+ min: 1,
1947
+ max: 20,
1948
+ value: promptBoxMaxRows,
1949
+ onChange: (e)=>setPromptBoxMaxRows(Number(e.target.value))
1950
+ })
1951
+ ]
1952
+ }),
1953
+ /*#__PURE__*/ jsxs(Section, {
1954
+ children: [
1955
+ /*#__PURE__*/ jsx(SectionTitle, {
1956
+ children: "Message Controls"
1957
+ }),
1958
+ /*#__PURE__*/ jsxs(ButtonGroup, {
1959
+ children: [
1960
+ /*#__PURE__*/ jsx(DemoButton, {
1961
+ onClick: setPrompt,
1962
+ children: "Set Prompt"
1963
+ }),
1964
+ /*#__PURE__*/ jsx(DemoButton, {
1965
+ onClick: resetPrompt,
1966
+ children: "Reset Prompt"
1967
+ })
1968
+ ]
1969
+ }),
1970
+ /*#__PURE__*/ jsx(DemoInput, {
1971
+ placeholder: "Custom message",
1972
+ value: customMessage,
1973
+ onChange: (e)=>setCustomMessage(e.target.value)
1974
+ }),
1975
+ /*#__PURE__*/ jsxs(ButtonGroup, {
1976
+ children: [
1977
+ /*#__PURE__*/ jsx(DemoButton, {
1978
+ onClick: sendSimpleRequest,
1979
+ children: "Send Request"
1980
+ }),
1981
+ /*#__PURE__*/ jsx(DemoButton, {
1982
+ onClick: sendSimpleResponse,
1983
+ children: "Send Response"
1984
+ }),
1985
+ /*#__PURE__*/ jsx(DemoButton, {
1986
+ onClick: stopResponse,
1987
+ children: "Stop Response"
1988
+ })
1989
+ ]
1990
+ }),
1991
+ /*#__PURE__*/ jsxs(ButtonGroup, {
1992
+ children: [
1993
+ /*#__PURE__*/ jsx(DemoButton, {
1994
+ onClick: sendResponseWithActions,
1995
+ children: "With Actions"
1996
+ }),
1997
+ /*#__PURE__*/ jsx(DemoButton, {
1998
+ onClick: sendResponseWithCitations,
1999
+ children: "With Citations"
2000
+ }),
2001
+ /*#__PURE__*/ jsx(DemoButton, {
2002
+ onClick: sendResponseWithVariables,
2003
+ children: "With Resource Tokens"
2004
+ })
2005
+ ]
2006
+ }),
2007
+ /*#__PURE__*/ jsxs(ButtonGroup, {
2008
+ children: [
2009
+ /*#__PURE__*/ jsx(DemoButton, {
2010
+ onClick: sendCodeBlock,
2011
+ children: "Code Block"
2012
+ }),
2013
+ /*#__PURE__*/ jsx(DemoButton, {
2014
+ onClick: sendHTMLPreview,
2015
+ children: "HTML Preview"
2016
+ })
2017
+ ]
2018
+ }),
2019
+ /*#__PURE__*/ jsxs(ButtonGroup, {
2020
+ children: [
2021
+ /*#__PURE__*/ jsx(DemoButton, {
2022
+ onClick: sendToolCall,
2023
+ children: "Send Tool Call"
2024
+ }),
2025
+ /*#__PURE__*/ jsx(DemoButton, {
2026
+ onClick: sendResponseDisabledActions,
2027
+ children: "Disabled Actions"
2028
+ })
2029
+ ]
2030
+ }),
2031
+ /*#__PURE__*/ jsxs(ButtonGroup, {
2032
+ children: [
2033
+ /*#__PURE__*/ jsx(DemoButton, {
2034
+ onClick: setConversation,
2035
+ children: "Set Conversation"
2036
+ }),
2037
+ /*#__PURE__*/ jsx(DemoButton, {
2038
+ onClick: setSuggestions,
2039
+ children: "Set Suggestions"
2040
+ })
2041
+ ]
2042
+ }),
2043
+ /*#__PURE__*/ jsx(FormControlLabel, {
2044
+ control: /*#__PURE__*/ jsx(Checkbox, {
2045
+ size: "small",
2046
+ checked: waitForMore,
2047
+ onChange: ()=>setWaitForMore(!waitForMore)
2048
+ }),
2049
+ label: "Wait For More Messages"
2050
+ })
2051
+ ]
2052
+ }),
2053
+ /*#__PURE__*/ jsxs(Section, {
2054
+ children: [
2055
+ /*#__PURE__*/ jsx(SectionTitle, {
2056
+ children: "Streaming"
2057
+ }),
2058
+ /*#__PURE__*/ jsx(DemoTextArea, {
2059
+ placeholder: "Text to stream",
2060
+ value: streamingText,
2061
+ onChange: (e)=>setStreamingText(e.target.value)
2062
+ }),
2063
+ /*#__PURE__*/ jsxs(ButtonGroup, {
2064
+ children: [
2065
+ /*#__PURE__*/ jsx(DemoButton, {
2066
+ onClick: sendStreamingResponse,
2067
+ children: "Stream Response"
2068
+ }),
2069
+ /*#__PURE__*/ jsx(DemoButton, {
2070
+ onClick: streamWithCitations,
2071
+ children: "Stream With Citations"
2072
+ }),
2073
+ /*#__PURE__*/ jsx(DemoButton, {
2074
+ onClick: streamWithResourceTokens,
2075
+ children: "Stream Resource Tokens"
2076
+ })
2077
+ ]
2078
+ }),
2079
+ /*#__PURE__*/ jsx(InfoText, {
2080
+ children: 'Streams text progressively. "Stream Resource Tokens" demonstrates buffering of incomplete tokens to prevent flickering.'
2081
+ })
2082
+ ]
2083
+ }),
2084
+ /*#__PURE__*/ jsxs(Section, {
2085
+ children: [
2086
+ /*#__PURE__*/ jsx(SectionTitle, {
2087
+ children: "Loading & Error States"
2088
+ }),
2089
+ /*#__PURE__*/ jsx(DemoInput, {
2090
+ placeholder: "Loading message",
2091
+ value: loadingMessage,
2092
+ onChange: (e)=>setLoadingMessage(e.target.value)
2093
+ }),
2094
+ /*#__PURE__*/ jsxs(ButtonGroup, {
2095
+ children: [
2096
+ /*#__PURE__*/ jsx(DemoButton, {
2097
+ onClick: showLoading,
2098
+ children: "Show Loading"
2099
+ }),
2100
+ /*#__PURE__*/ jsx(DemoButton, {
2101
+ onClick: hideLoading,
2102
+ children: "Hide Loading"
2103
+ })
2104
+ ]
2105
+ }),
2106
+ /*#__PURE__*/ jsx(DemoInput, {
2107
+ placeholder: "Error message",
2108
+ value: errorMessage,
2109
+ onChange: (e)=>setErrorMessage(e.target.value)
2110
+ }),
2111
+ /*#__PURE__*/ jsxs(ButtonGroup, {
2112
+ children: [
2113
+ /*#__PURE__*/ jsx(DemoButton, {
2114
+ onClick: showError,
2115
+ children: "Show Error"
2116
+ }),
2117
+ /*#__PURE__*/ jsx(DemoButton, {
2118
+ onClick: showWarning,
2119
+ children: "Show Warning"
2120
+ }),
2121
+ /*#__PURE__*/ jsx(DemoButton, {
2122
+ onClick: clearErrors,
2123
+ children: "Clear Errors"
2124
+ })
2125
+ ]
2126
+ })
2127
+ ]
2128
+ }),
2129
+ /*#__PURE__*/ jsxs(Section, {
2130
+ children: [
2131
+ /*#__PURE__*/ jsx(SectionTitle, {
2132
+ children: "History"
2133
+ }),
2134
+ /*#__PURE__*/ jsxs(ButtonGroup, {
2135
+ children: [
2136
+ /*#__PURE__*/ jsx(DemoButton, {
2137
+ onClick: addHistoryItems,
2138
+ children: "Add History Items"
2139
+ }),
2140
+ /*#__PURE__*/ jsx(DemoButton, {
2141
+ onClick: toggleHistory,
2142
+ children: "Toggle History Panel"
2143
+ })
2144
+ ]
2145
+ })
2146
+ ]
2147
+ }),
2148
+ /*#__PURE__*/ jsxs(Section, {
2149
+ children: [
2150
+ /*#__PURE__*/ jsx(SectionTitle, {
2151
+ children: "Feature Toggles"
2152
+ }),
2153
+ /*#__PURE__*/ jsx(FormControlLabel, {
2154
+ control: /*#__PURE__*/ jsx(Checkbox, {
2155
+ size: "small",
2156
+ checked: features.history,
2157
+ onChange: ()=>toggleFeature('history')
2158
+ }),
2159
+ label: "History"
2160
+ }),
2161
+ /*#__PURE__*/ jsx(FormControlLabel, {
2162
+ control: /*#__PURE__*/ jsx(Checkbox, {
2163
+ size: "small",
2164
+ checked: features.settings,
2165
+ onChange: ()=>toggleFeature('settings')
2166
+ }),
2167
+ label: "Settings"
2168
+ }),
2169
+ /*#__PURE__*/ jsx(FormControlLabel, {
2170
+ control: /*#__PURE__*/ jsx(Checkbox, {
2171
+ size: "small",
2172
+ checked: features.attachments,
2173
+ onChange: ()=>toggleFeature('attachments')
2174
+ }),
2175
+ label: "Attachments"
2176
+ }),
2177
+ /*#__PURE__*/ jsx(FormControlLabel, {
2178
+ control: /*#__PURE__*/ jsx(Checkbox, {
2179
+ size: "small",
2180
+ checked: features.audio,
2181
+ onChange: ()=>toggleFeature('audio')
2182
+ }),
2183
+ label: "STT Dictate"
2184
+ }),
2185
+ /*#__PURE__*/ jsx(FormControlLabel, {
2186
+ control: /*#__PURE__*/ jsx(Checkbox, {
2187
+ size: "small",
2188
+ checked: features.audioStreaming,
2189
+ onChange: ()=>toggleFeature('audioStreaming')
2190
+ }),
2191
+ label: "Voice Interaction"
2192
+ }),
2193
+ /*#__PURE__*/ jsx(FormControlLabel, {
2194
+ control: /*#__PURE__*/ jsx(Checkbox, {
2195
+ size: "small",
2196
+ checked: features.htmlPreview,
2197
+ onChange: ()=>toggleFeature('htmlPreview')
2198
+ }),
2199
+ label: "HTML Preview"
2200
+ }),
2201
+ /*#__PURE__*/ jsx(FormControlLabel, {
2202
+ control: /*#__PURE__*/ jsx(Checkbox, {
2203
+ size: "small",
2204
+ checked: features.headerSeparator,
2205
+ onChange: ()=>toggleFeature('headerSeparator')
2206
+ }),
2207
+ label: "Header Separator"
2208
+ }),
2209
+ /*#__PURE__*/ jsx(FormControlLabel, {
2210
+ control: /*#__PURE__*/ jsx(Checkbox, {
2211
+ size: "small",
2212
+ checked: features.fullHeight,
2213
+ onChange: ()=>toggleFeature('fullHeight')
2214
+ }),
2215
+ label: "Full Height"
2216
+ }),
2217
+ /*#__PURE__*/ jsx(FormControlLabel, {
2218
+ control: /*#__PURE__*/ jsx(Checkbox, {
2219
+ size: "small",
2220
+ checked: features.resize,
2221
+ onChange: ()=>toggleFeature('resize')
2222
+ }),
2223
+ label: "Resize"
2224
+ }),
2225
+ /*#__PURE__*/ jsx(FormControlLabel, {
2226
+ control: /*#__PURE__*/ jsx(Checkbox, {
2227
+ size: "small",
2228
+ checked: features.close,
2229
+ onChange: ()=>toggleFeature('close')
2230
+ }),
2231
+ label: "Close"
2232
+ }),
2233
+ /*#__PURE__*/ jsx(FormControlLabel, {
2234
+ control: /*#__PURE__*/ jsx(Checkbox, {
2235
+ size: "small",
2236
+ checked: features.feedback,
2237
+ onChange: ()=>toggleFeature('feedback')
2238
+ }),
2239
+ label: "Feedback"
2240
+ }),
2241
+ /*#__PURE__*/ jsx(FormControlLabel, {
2242
+ control: /*#__PURE__*/ jsx(Checkbox, {
2243
+ size: "small",
2244
+ checked: features.model,
2245
+ onChange: ()=>toggleFeature('model')
2246
+ }),
2247
+ label: "Model"
2248
+ }),
2249
+ /*#__PURE__*/ jsx(FormControlLabel, {
2250
+ control: /*#__PURE__*/ jsx(Checkbox, {
2251
+ size: "small",
2252
+ checked: features.agentMode,
2253
+ onChange: ()=>toggleFeature('agentMode')
2254
+ }),
2255
+ label: "Agent Mode"
2256
+ }),
2257
+ /*#__PURE__*/ jsx(FormControlLabel, {
2258
+ control: /*#__PURE__*/ jsx(Checkbox, {
2259
+ size: "small",
2260
+ checked: features.sendOnClick,
2261
+ onChange: ()=>toggleFeature('sendOnClick')
2262
+ }),
2263
+ label: "Send On Click"
2264
+ }),
2265
+ /*#__PURE__*/ jsx(FormControlLabel, {
2266
+ control: /*#__PURE__*/ jsx(Checkbox, {
2267
+ size: "small",
2268
+ checked: features.paginatedMessages,
2269
+ onChange: ()=>toggleFeature('paginatedMessages')
2270
+ }),
2271
+ label: "Paginated Messages"
2272
+ }),
2273
+ /*#__PURE__*/ jsx(FormControlLabel, {
2274
+ control: /*#__PURE__*/ jsx(Checkbox, {
2275
+ size: "small",
2276
+ checked: features.compactMode,
2277
+ onChange: ()=>toggleFeature('compactMode')
2278
+ }),
2279
+ label: "Compact Mode"
2280
+ }),
2281
+ /*#__PURE__*/ jsx(FormControlLabel, {
2282
+ control: /*#__PURE__*/ jsx(Checkbox, {
2283
+ size: "small",
2284
+ checked: features.customScrollTheme,
2285
+ onChange: ()=>toggleFeature('customScrollTheme')
2286
+ }),
2287
+ label: "Custom Scroll Theme"
2288
+ }),
2289
+ /*#__PURE__*/ jsx(FormControlLabel, {
2290
+ control: /*#__PURE__*/ jsx(Checkbox, {
2291
+ size: "small",
2292
+ checked: features.copy,
2293
+ onChange: ()=>toggleFeature('copy')
2294
+ }),
2295
+ label: "Copy"
2296
+ }),
2297
+ /*#__PURE__*/ jsx(FormControlLabel, {
2298
+ control: /*#__PURE__*/ jsx(Checkbox, {
2299
+ size: "small",
2300
+ checked: features.attachmentsAsync,
2301
+ onChange: ()=>toggleFeature('attachmentsAsync')
2302
+ }),
2303
+ label: "Attachments Async"
2304
+ }),
2305
+ /*#__PURE__*/ jsx(FormControlLabel, {
2306
+ control: /*#__PURE__*/ jsx(Checkbox, {
2307
+ size: "small",
2308
+ checked: features.readOnly,
2309
+ onChange: ()=>toggleFeature('readOnly')
2310
+ }),
2311
+ label: "Read Only"
2312
+ })
2313
+ ]
2314
+ }),
2315
+ /*#__PURE__*/ jsxs(Section, {
2316
+ children: [
2317
+ /*#__PURE__*/ jsx(SectionTitle, {
2318
+ children: "State Controls"
2319
+ }),
2320
+ /*#__PURE__*/ jsx(FormControlLabel, {
2321
+ control: /*#__PURE__*/ jsx(Checkbox, {
2322
+ size: "small",
2323
+ checked: isWaiting,
2324
+ onChange: ()=>{
2325
+ setIsWaiting(!isWaiting);
2326
+ chatService?.setWaiting(!isWaiting);
2327
+ }
2328
+ }),
2329
+ label: "Set Waiting"
2330
+ }),
2331
+ /*#__PURE__*/ jsx(FormControlLabel, {
2332
+ control: /*#__PURE__*/ jsx(Checkbox, {
2333
+ size: "small",
2334
+ checked: isShowLoading,
2335
+ onChange: ()=>{
2336
+ setIsShowLoading(!isShowLoading);
2337
+ chatService?.setShowLoading(!isShowLoading);
2338
+ }
2339
+ }),
2340
+ label: "Set Show Loading"
2341
+ })
2342
+ ]
2343
+ })
2344
+ ]
2345
+ }),
2346
+ chatService && /*#__PURE__*/ jsx(Box, {
2347
+ sx: {
2348
+ justifySelf: 'flex-end',
2349
+ background: 'var(--color-background)'
2350
+ },
2351
+ children: /*#__PURE__*/ jsx(ApChat, {
2352
+ chatServiceInstance: chatService,
2353
+ locale: locale,
2354
+ theme: theme
2355
+ })
2356
+ }),
2357
+ /*#__PURE__*/ jsx(Box, {
2358
+ ref: embeddedContainerRef,
2359
+ sx: {
2360
+ position: 'fixed',
2361
+ bottom: 24,
2362
+ right: 24,
2363
+ width: 400,
2364
+ height: 600,
2365
+ boxShadow: 'var(--shadow-xl, 0 12px 32px rgba(0, 0, 0, 0.35))',
2366
+ borderRadius: '12px',
2367
+ overflow: 'hidden',
2368
+ zIndex: 1000,
2369
+ '& > *': {
2370
+ position: 'relative'
2371
+ }
2372
+ },
2373
+ style: {
2374
+ background: 'var(--color-background)',
2375
+ display: chatMode === AutopilotChatMode.Embedded ? 'block' : 'none'
2376
+ }
2377
+ })
2378
+ ]
2379
+ });
2380
+ }
2381
+ export { ChatShowcaseDemo, mapToChatLocale, mapToChatTheme };