@iblai/web-containers 1.52.0 → 1.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/cjs/components/chat/loading-message.js +13 -0
  2. package/dist/cjs/components/chat/loading-message.js.map +1 -0
  3. package/dist/cjs/components/mentors/mentor-selection-grid.js +4 -2
  4. package/dist/cjs/components/mentors/mentor-selection-grid.js.map +1 -1
  5. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-management-content.js +9 -5
  6. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-management-content.js.map +1 -1
  7. package/dist/cjs/components/workflows/action-tooltip.js +11 -0
  8. package/dist/cjs/components/workflows/action-tooltip.js.map +1 -0
  9. package/dist/cjs/components/workflows/node-config-panel.js +576 -0
  10. package/dist/cjs/components/workflows/node-config-panel.js.map +1 -0
  11. package/dist/cjs/components/workflows/tool-dialogs.js +95 -60
  12. package/dist/cjs/components/workflows/tool-dialogs.js.map +1 -1
  13. package/dist/cjs/components/workflows/workflow-canvas.js +1028 -0
  14. package/dist/cjs/components/workflows/workflow-canvas.js.map +1 -0
  15. package/dist/cjs/components/workflows/workflow-definition.js +369 -0
  16. package/dist/cjs/components/workflows/workflow-definition.js.map +1 -0
  17. package/dist/cjs/components/workflows/workflow-editor.js +523 -0
  18. package/dist/cjs/components/workflows/workflow-editor.js.map +1 -0
  19. package/dist/cjs/components/workflows/workflow-preview-chat.js +57 -0
  20. package/dist/cjs/components/workflows/workflow-preview-chat.js.map +1 -0
  21. package/dist/cjs/components/workflows/workflow-sidebar.js +2 -2
  22. package/dist/cjs/components/workflows/workflow-sidebar.js.map +1 -1
  23. package/dist/cjs/components/workflows/workflows-list.js +115 -0
  24. package/dist/cjs/components/workflows/workflows-list.js.map +1 -0
  25. package/dist/cjs/i18n/messages/en.json.js +207 -18
  26. package/dist/cjs/i18n/messages/en.json.js.map +1 -1
  27. package/dist/cjs/i18n/messages/es.json.js +201 -12
  28. package/dist/cjs/i18n/messages/es.json.js.map +1 -1
  29. package/dist/cjs/i18n/messages/fr.json.js +201 -12
  30. package/dist/cjs/i18n/messages/fr.json.js.map +1 -1
  31. package/dist/cjs/i18n/messages/zh.json.js +201 -12
  32. package/dist/cjs/i18n/messages/zh.json.js.map +1 -1
  33. package/dist/cjs/index.js +17 -0
  34. package/dist/cjs/index.js.map +1 -1
  35. package/dist/cjs/next/index.js +10 -0
  36. package/dist/cjs/next/index.js.map +1 -1
  37. package/dist/cjs/web-containers/tsconfig.tsbuildinfo +1 -1
  38. package/dist/esm/components/chat/loading-message.js +11 -0
  39. package/dist/esm/components/chat/loading-message.js.map +1 -0
  40. package/dist/esm/components/mentors/mentor-selection-grid.js +4 -2
  41. package/dist/esm/components/mentors/mentor-selection-grid.js.map +1 -1
  42. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-management-content.js +9 -5
  43. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-management-content.js.map +1 -1
  44. package/dist/esm/components/workflows/action-tooltip.js +9 -0
  45. package/dist/esm/components/workflows/action-tooltip.js.map +1 -0
  46. package/dist/esm/components/workflows/node-config-panel.js +574 -0
  47. package/dist/esm/components/workflows/node-config-panel.js.map +1 -0
  48. package/dist/esm/components/workflows/tool-dialogs.js +96 -61
  49. package/dist/esm/components/workflows/tool-dialogs.js.map +1 -1
  50. package/dist/esm/components/workflows/workflow-canvas.js +1026 -0
  51. package/dist/esm/components/workflows/workflow-canvas.js.map +1 -0
  52. package/dist/esm/components/workflows/workflow-definition.js +352 -0
  53. package/dist/esm/components/workflows/workflow-definition.js.map +1 -0
  54. package/dist/esm/components/workflows/workflow-editor.js +521 -0
  55. package/dist/esm/components/workflows/workflow-editor.js.map +1 -0
  56. package/dist/esm/components/workflows/workflow-preview-chat.js +55 -0
  57. package/dist/esm/components/workflows/workflow-preview-chat.js.map +1 -0
  58. package/dist/esm/components/workflows/workflow-sidebar.js +2 -2
  59. package/dist/esm/components/workflows/workflow-sidebar.js.map +1 -1
  60. package/dist/esm/components/workflows/workflows-list.js +113 -0
  61. package/dist/esm/components/workflows/workflows-list.js.map +1 -0
  62. package/dist/esm/i18n/messages/en.json.js +203 -19
  63. package/dist/esm/i18n/messages/en.json.js.map +1 -1
  64. package/dist/esm/i18n/messages/es.json.js +197 -13
  65. package/dist/esm/i18n/messages/es.json.js.map +1 -1
  66. package/dist/esm/i18n/messages/fr.json.js +197 -13
  67. package/dist/esm/i18n/messages/fr.json.js.map +1 -1
  68. package/dist/esm/i18n/messages/zh.json.js +197 -13
  69. package/dist/esm/i18n/messages/zh.json.js.map +1 -1
  70. package/dist/esm/index.js +1 -0
  71. package/dist/esm/index.js.map +1 -1
  72. package/dist/esm/next/index.js +5 -0
  73. package/dist/esm/next/index.js.map +1 -1
  74. package/dist/esm/web-containers/tsconfig.tsbuildinfo +1 -1
  75. package/dist/index.d.ts +164 -19
  76. package/dist/next/index.d.ts +215 -3
  77. package/dist/package.json +1 -1
  78. package/package.json +1 -1
@@ -0,0 +1,521 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { useState, useMemo, useEffect, useRef, useCallback } from 'react';
3
+ import { useT } from '../../i18n/context.js';
4
+ import '../../packages/i18n/dist/index.esm.js';
5
+ import { Button } from '../ui/button.js';
6
+ import { Input } from '../ui/input.js';
7
+ import { WorkflowPreviewChat } from './workflow-preview-chat.js';
8
+ import { WorkflowCanvas } from './workflow-canvas.js';
9
+ import { migrateWorkflowDefinition, withoutNoteConnectivityWarnings } from './workflow-definition.js';
10
+ import { WorkflowSidebar } from './workflow-sidebar.js';
11
+ import { DeleteWorkflowModal } from './delete-workflow-modal.js';
12
+ import { useGetWorkflowQuery, useGetNodeTypesQuery, useLazyGetMentorSettingsQuery, usePatchWorkflowMutation, usePublishWorkflowMutation, useDeactivateWorkflowMutation, useValidateWorkflowMutation, useActivateWorkflowMutation, useDeleteWorkflowMutation } from '@iblai/data-layer';
13
+ import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '../ui/dropdown-menu.js';
14
+ import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '../ui/collapsible.js';
15
+ import { toast } from 'sonner';
16
+ import { useDebounce as a } from '../../node_modules/.pnpm/use-debounce@10.0.4_react@19.1.0/node_modules/use-debounce/dist/index.module.js';
17
+ import LoaderCircle from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/loader-circle.js';
18
+ import CircleAlert from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/circle-alert.js';
19
+ import ChevronLeft from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/chevron-left.js';
20
+ import Pencil from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/pencil.js';
21
+ import X from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/x.js';
22
+ import RotateCcw from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/rotate-ccw.js';
23
+ import Ellipsis from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/ellipsis.js';
24
+ import Power from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/power.js';
25
+ import Trash2 from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/trash-2.js';
26
+ import Eye from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/eye.js';
27
+ import TriangleAlert from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/triangle-alert.js';
28
+ import ChevronUp from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/chevron-up.js';
29
+ import ChevronDown from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
30
+
31
+ function getCategoryConfig(t) {
32
+ return {
33
+ core: { title: t('workflowsWorkflowEditor.categoryCore'), order: 1 },
34
+ tools: { title: t('workflowsWorkflowEditor.categoryTools'), order: 2 },
35
+ logic: { title: t('workflowsWorkflowEditor.categoryLogic'), order: 3 },
36
+ data: { title: t('workflowsWorkflowEditor.categoryData'), order: 4 },
37
+ };
38
+ }
39
+ const nodeCategoryOverride = {
40
+ note: 'core', // API has it in 'visual' but UI shows it in 'Core'
41
+ };
42
+ // The backend words these in terms of mentors, and repeats the runtime check
43
+ // once per Agent step.
44
+ const MENTOR_MESSAGES = [
45
+ [
46
+ /^Mentor existence will be validated at runtime/,
47
+ 'workflowsWorkflowEditor.agentCheckedAtRuntime',
48
+ ],
49
+ [
50
+ /^Node 'mentor' missing required field 'mentor_id'/,
51
+ 'workflowsWorkflowEditor.agentStepMissingAgent',
52
+ ],
53
+ ];
54
+ function inAgentWording(messages, t) {
55
+ const reworded = messages.map((message) => {
56
+ const match = MENTOR_MESSAGES.find(([pattern]) => pattern.test(message));
57
+ return match ? t(match[1]) : message;
58
+ });
59
+ return Array.from(new Set(reworded));
60
+ }
61
+ function transformNodeTypesToSections(nodeTypes, t) {
62
+ if (!(nodeTypes === null || nodeTypes === void 0 ? void 0 : nodeTypes.node_types))
63
+ return undefined;
64
+ const categoryConfig = getCategoryConfig(t);
65
+ const categoryMap = new Map();
66
+ Object.entries(categoryConfig).forEach(([catId, config]) => {
67
+ categoryMap.set(catId, { title: config.title, items: [] });
68
+ });
69
+ Object.entries(nodeTypes.node_types).forEach(([nodeId, nodeInfo]) => {
70
+ // The canvas adds the Start step to every workflow itself.
71
+ if (nodeId === 'start')
72
+ return;
73
+ const targetCategory = nodeCategoryOverride[nodeId] || nodeInfo.category;
74
+ const section = categoryMap.get(targetCategory);
75
+ if (section) {
76
+ section.items.push({
77
+ id: nodeId,
78
+ // The backend still labels the Agent step 'Mentor'.
79
+ label: nodeId === 'mentor' ? t('workflowsWorkflowEditor.agentNodeLabel') : nodeInfo.label,
80
+ category: targetCategory,
81
+ });
82
+ }
83
+ });
84
+ return Array.from(categoryMap.entries())
85
+ .sort(([a], [b]) => { var _a, _b, _c, _d; return ((_b = (_a = categoryConfig[a]) === null || _a === void 0 ? void 0 : _a.order) !== null && _b !== void 0 ? _b : 99) - ((_d = (_c = categoryConfig[b]) === null || _c === void 0 ? void 0 : _c.order) !== null && _d !== void 0 ? _d : 99); })
86
+ .map(([, section]) => section)
87
+ .filter((section) => section.items.length > 0);
88
+ }
89
+ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl, redirectToAuthSpa, onBack, onDeleted, onOpenAgentSettings, agentSettings, }) {
90
+ var _a, _b, _c, _d, _e, _f;
91
+ const t = useT();
92
+ const { data: workflow, isLoading, error, } = useGetWorkflowQuery({ org: tenantKey, uniqueId: workflowId }, { skip: !tenantKey || !workflowId });
93
+ const entryMentorId = (_a = workflow === null || workflow === void 0 ? void 0 : workflow.entrymentorid) !== null && _a !== void 0 ? _a : workflow === null || workflow === void 0 ? void 0 : workflow.entry_mentor_id;
94
+ const { data: nodeTypesData } = useGetNodeTypesQuery({ org: tenantKey }, { skip: !tenantKey });
95
+ const [mentorSettingsById, setMentorSettingsById] = useState({});
96
+ const [isMentorSettingsLoading, setIsMentorSettingsLoading] = useState(false);
97
+ const [fetchMentorSettings] = useLazyGetMentorSettingsQuery();
98
+ const mentorIdsFromDefinition = useMemo(() => {
99
+ var _a, _b;
100
+ const ids = new Set();
101
+ const nodes = ((_b = (_a = workflow === null || workflow === void 0 ? void 0 : workflow.definition) === null || _a === void 0 ? void 0 : _a.nodes) !== null && _b !== void 0 ? _b : []);
102
+ nodes.forEach((node) => {
103
+ if (node.type !== 'mentor')
104
+ return;
105
+ const nodeData = node.data;
106
+ const mentorId = (nodeData === null || nodeData === void 0 ? void 0 : nodeData.mentor_id) ||
107
+ (nodeData === null || nodeData === void 0 ? void 0 : nodeData.entry_mentor_id) ||
108
+ entryMentorId;
109
+ if (mentorId) {
110
+ ids.add(mentorId);
111
+ }
112
+ });
113
+ return Array.from(ids);
114
+ }, [(_b = workflow === null || workflow === void 0 ? void 0 : workflow.definition) === null || _b === void 0 ? void 0 : _b.nodes, entryMentorId]);
115
+ const missingMentorIds = useMemo(() => mentorIdsFromDefinition.filter((mentorId) => !Object.prototype.hasOwnProperty.call(mentorSettingsById, mentorId)), [mentorIdsFromDefinition, mentorSettingsById]);
116
+ useEffect(() => {
117
+ if (!tenantKey || !username || missingMentorIds.length === 0)
118
+ return;
119
+ let isActive = true;
120
+ setIsMentorSettingsLoading(true);
121
+ Promise.all(missingMentorIds.map(async (mentorId) => {
122
+ try {
123
+ const data = (await fetchMentorSettings({
124
+ mentor: mentorId,
125
+ org: tenantKey,
126
+ }).unwrap());
127
+ return { mentorId, data };
128
+ }
129
+ catch (_a) {
130
+ return { mentorId, data: null };
131
+ }
132
+ }))
133
+ .then((results) => {
134
+ if (!isActive)
135
+ return;
136
+ setMentorSettingsById((prev) => {
137
+ const next = { ...prev };
138
+ results.forEach(({ mentorId, data }) => {
139
+ next[mentorId] = data;
140
+ });
141
+ return next;
142
+ });
143
+ })
144
+ .finally(() => {
145
+ if (isActive) {
146
+ setIsMentorSettingsLoading(false);
147
+ }
148
+ });
149
+ return () => {
150
+ isActive = false;
151
+ };
152
+ }, [missingMentorIds, fetchMentorSettings, tenantKey, username]);
153
+ const isWaitingForMentorSettings = mentorIdsFromDefinition.length > 0 &&
154
+ (!username || missingMentorIds.length > 0 || isMentorSettingsLoading);
155
+ const [patchWorkflow, { isLoading: isSaving }] = usePatchWorkflowMutation();
156
+ const [publishWorkflow, { isLoading: isPublishing }] = usePublishWorkflowMutation();
157
+ const [deactivateWorkflow] = useDeactivateWorkflowMutation();
158
+ const [validateWorkflow] = useValidateWorkflowMutation();
159
+ const [activateWorkflow, { isLoading: isActivating }] = useActivateWorkflowMutation();
160
+ const [deleteWorkflow, { isLoading: isDeleting }] = useDeleteWorkflowMutation();
161
+ const [workflowName, setWorkflowName] = useState('');
162
+ const [isEditingName, setIsEditingName] = useState(false);
163
+ const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
164
+ const [draggedItem, setDraggedItem] = useState(null);
165
+ const [clickedItem, setClickedItem] = useState(null);
166
+ const [isPreviewMode, setIsPreviewMode] = useState(false);
167
+ const [previewKey, setPreviewKey] = useState(0);
168
+ const [newChatSignal, setNewChatSignal] = useState(0);
169
+ const [workflowData, setWorkflowData] = useState(null);
170
+ const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
171
+ const [validationResult, setValidationResult] = useState(null);
172
+ const [isValidationBannerOpen, setIsValidationBannerOpen] = useState(true);
173
+ const isInitialLoad = useRef(true);
174
+ const [debouncedWorkflowData] = a(workflowData, 1000);
175
+ const nodeTypeSections = useMemo(() => transformNodeTypesToSections(nodeTypesData, t), [nodeTypesData, t]);
176
+ // Never overwrite an in-progress rename with a cache refetch
177
+ const syncedNameRef = useRef(null);
178
+ useEffect(() => {
179
+ if (!workflow || isEditingName)
180
+ return;
181
+ if (syncedNameRef.current === workflow.name)
182
+ return;
183
+ syncedNameRef.current = workflow.name;
184
+ setWorkflowName(workflow.name);
185
+ }, [workflow, isEditingName]);
186
+ // Auto-save compares against the graph the canvas first reports, so merely
187
+ // opening a workflow never saves it - including one whose old field names
188
+ // were converted for display: a published workflow keeps running unchanged
189
+ // until someone edits it.
190
+ const initialWorkflowDataRef = useRef(null);
191
+ // True while the server still holds a definition the canvas converted.
192
+ const definitionNeedsSaveRef = useRef(false);
193
+ const savedDefinitionRef = useRef(workflow === null || workflow === void 0 ? void 0 : workflow.definition);
194
+ savedDefinitionRef.current = workflow === null || workflow === void 0 ? void 0 : workflow.definition;
195
+ const showValidation = (result, nodes) => {
196
+ const errors = inAgentWording(result.errors, t);
197
+ const warnings = inAgentWording(withoutNoteConnectivityWarnings(result.warnings, nodes), t);
198
+ if (errors.length === 0 && warnings.length === 0) {
199
+ setValidationResult(null);
200
+ return;
201
+ }
202
+ setValidationResult({ errors, warnings });
203
+ setIsValidationBannerOpen(true);
204
+ };
205
+ const showValidationRef = useRef(showValidation);
206
+ showValidationRef.current = showValidation;
207
+ useEffect(() => {
208
+ if (!debouncedWorkflowData || !workflow) {
209
+ return;
210
+ }
211
+ const currentDataStr = JSON.stringify({
212
+ nodes: debouncedWorkflowData.nodes,
213
+ edges: debouncedWorkflowData.edges,
214
+ });
215
+ if (isInitialLoad.current) {
216
+ if (currentDataStr === initialWorkflowDataRef.current) {
217
+ isInitialLoad.current = false;
218
+ return;
219
+ }
220
+ isInitialLoad.current = false;
221
+ }
222
+ if (currentDataStr === initialWorkflowDataRef.current) {
223
+ return;
224
+ }
225
+ const autoSave = async () => {
226
+ try {
227
+ const patchData = {
228
+ definition: {
229
+ nodes: debouncedWorkflowData.nodes,
230
+ edges: debouncedWorkflowData.edges,
231
+ },
232
+ };
233
+ await patchWorkflow({
234
+ org: tenantKey,
235
+ uniqueId: workflowId,
236
+ data: patchData,
237
+ }).unwrap();
238
+ setHasUnsavedChanges(false);
239
+ definitionNeedsSaveRef.current = false;
240
+ initialWorkflowDataRef.current = currentDataStr;
241
+ try {
242
+ const result = await validateWorkflow({
243
+ org: tenantKey,
244
+ uniqueId: workflowId,
245
+ }).unwrap();
246
+ showValidationRef.current(result, debouncedWorkflowData.nodes);
247
+ }
248
+ catch (_a) {
249
+ // Silent fail for validation
250
+ }
251
+ }
252
+ catch (_b) {
253
+ // Silent fail for auto-save, user can manually save
254
+ }
255
+ };
256
+ autoSave();
257
+ }, [debouncedWorkflowData, workflow, tenantKey, workflowId, patchWorkflow, validateWorkflow]);
258
+ const clickedItemTimerRef = useRef(null);
259
+ useEffect(() => () => {
260
+ if (clickedItemTimerRef.current)
261
+ clearTimeout(clickedItemTimerRef.current);
262
+ }, []);
263
+ const handleItemClick = (item) => {
264
+ setClickedItem(item);
265
+ if (clickedItemTimerRef.current)
266
+ clearTimeout(clickedItemTimerRef.current);
267
+ clickedItemTimerRef.current = setTimeout(() => setClickedItem(null), 100);
268
+ };
269
+ const currentNodes = () => {
270
+ var _a, _b, _c;
271
+ return (_a = workflowData === null || workflowData === void 0 ? void 0 : workflowData.nodes) !== null && _a !== void 0 ? _a : ((_c = (_b = workflow === null || workflow === void 0 ? void 0 : workflow.definition) === null || _b === void 0 ? void 0 : _b.nodes) !== null && _c !== void 0 ? _c : []);
272
+ };
273
+ const markDefinitionSaved = (data) => {
274
+ setHasUnsavedChanges(false);
275
+ definitionNeedsSaveRef.current = false;
276
+ initialWorkflowDataRef.current = JSON.stringify({
277
+ nodes: data.nodes,
278
+ edges: data.edges,
279
+ });
280
+ };
281
+ // Activate and Preview run what the server holds, which must match what
282
+ // the canvas shows (e.g. old field names converted on open).
283
+ const saveDefinitionIfNeeded = async () => {
284
+ if (!workflowData)
285
+ return;
286
+ if (!definitionNeedsSaveRef.current && !hasUnsavedChanges)
287
+ return;
288
+ await patchWorkflow({
289
+ org: tenantKey,
290
+ uniqueId: workflowId,
291
+ data: {
292
+ definition: { nodes: workflowData.nodes, edges: workflowData.edges },
293
+ },
294
+ }).unwrap();
295
+ markDefinitionSaved(workflowData);
296
+ };
297
+ const handlePreviewClick = async () => {
298
+ try {
299
+ await saveDefinitionIfNeeded();
300
+ }
301
+ catch (_a) {
302
+ toast.error(t('workflowsWorkflowEditor.failedToSaveWorkflow'));
303
+ }
304
+ setPreviewKey((k) => k + 1);
305
+ setIsPreviewMode(true);
306
+ };
307
+ const handleClosePreview = () => setIsPreviewMode(false);
308
+ const handleNewChat = () => setNewChatSignal((signal) => signal + 1);
309
+ const handleWorkflowStateChange = useCallback((state) => {
310
+ var _a, _b;
311
+ setWorkflowData(state);
312
+ if (initialWorkflowDataRef.current === null) {
313
+ initialWorkflowDataRef.current = JSON.stringify({
314
+ nodes: state.nodes,
315
+ edges: state.edges,
316
+ });
317
+ const saved = savedDefinitionRef.current;
318
+ const savedNodes = ((_a = saved === null || saved === void 0 ? void 0 : saved.nodes) !== null && _a !== void 0 ? _a : []);
319
+ const savedEdges = ((_b = saved === null || saved === void 0 ? void 0 : saved.edges) !== null && _b !== void 0 ? _b : []);
320
+ definitionNeedsSaveRef.current =
321
+ JSON.stringify(migrateWorkflowDefinition(savedNodes, savedEdges)) !==
322
+ JSON.stringify({ nodes: savedNodes, edges: savedEdges });
323
+ setHasUnsavedChanges(definitionNeedsSaveRef.current);
324
+ return;
325
+ }
326
+ setHasUnsavedChanges(true);
327
+ }, []);
328
+ const handleNameSave = async () => {
329
+ setIsEditingName(false);
330
+ if (workflow && workflowName !== workflow.name) {
331
+ try {
332
+ await patchWorkflow({
333
+ org: tenantKey,
334
+ uniqueId: workflowId,
335
+ data: { name: workflowName },
336
+ }).unwrap();
337
+ toast.success(t('workflowsWorkflowEditor.workflowNameUpdated'));
338
+ }
339
+ catch (_a) {
340
+ toast.error(t('workflowsWorkflowEditor.failedToUpdateName'));
341
+ setWorkflowName(workflow.name);
342
+ }
343
+ }
344
+ };
345
+ const handleSave = async () => {
346
+ if (!workflowData)
347
+ return;
348
+ try {
349
+ const patchData = {
350
+ definition: { nodes: workflowData.nodes, edges: workflowData.edges },
351
+ };
352
+ await patchWorkflow({
353
+ org: tenantKey,
354
+ uniqueId: workflowId,
355
+ data: patchData,
356
+ }).unwrap();
357
+ markDefinitionSaved(workflowData);
358
+ toast.success(t('workflowsWorkflowEditor.workflowSaved'));
359
+ }
360
+ catch (_a) {
361
+ toast.error(t('workflowsWorkflowEditor.failedToSaveWorkflow'));
362
+ }
363
+ };
364
+ const handlePublish = async () => {
365
+ const data = workflowData
366
+ ? { definition: { nodes: workflowData.nodes, edges: workflowData.edges } }
367
+ : undefined;
368
+ try {
369
+ await publishWorkflow({
370
+ org: tenantKey,
371
+ uniqueId: workflowId,
372
+ data,
373
+ }).unwrap();
374
+ if (workflowData)
375
+ markDefinitionSaved(workflowData);
376
+ setValidationResult(null);
377
+ toast.success(t('workflowsWorkflowEditor.workflowPublished'));
378
+ }
379
+ catch (err) {
380
+ const errorData = err === null || err === void 0 ? void 0 : err.data;
381
+ if (errorData && typeof errorData === 'object' && 'is_valid' in errorData) {
382
+ const validation = errorData;
383
+ showValidation(validation, currentNodes());
384
+ toast.error(t('workflowsWorkflowEditor.workflowHasValidationIssues'));
385
+ }
386
+ else {
387
+ toast.error(t('workflowsWorkflowEditor.failedToPublishWorkflow'));
388
+ }
389
+ }
390
+ };
391
+ const handleDeactivate = async () => {
392
+ try {
393
+ await deactivateWorkflow({
394
+ org: tenantKey,
395
+ uniqueId: workflowId,
396
+ }).unwrap();
397
+ toast.success(t('workflowsWorkflowEditor.workflowDeactivated'));
398
+ }
399
+ catch (_a) {
400
+ toast.error(t('workflowsWorkflowEditor.failedToDeactivateWorkflow'));
401
+ }
402
+ };
403
+ const handleActivate = async () => {
404
+ try {
405
+ await saveDefinitionIfNeeded();
406
+ }
407
+ catch (_a) {
408
+ toast.error(t('workflowsWorkflowEditor.failedToSaveWorkflow'));
409
+ return;
410
+ }
411
+ try {
412
+ const result = await activateWorkflow({
413
+ org: tenantKey,
414
+ uniqueId: workflowId,
415
+ }).unwrap();
416
+ if (result.is_valid) {
417
+ setValidationResult(null);
418
+ toast.success(t('workflowsWorkflowEditor.workflowActivated'));
419
+ }
420
+ else {
421
+ showValidation(result, currentNodes());
422
+ toast.error(t('workflowsWorkflowEditor.workflowHasValidationIssues'));
423
+ }
424
+ }
425
+ catch (err) {
426
+ const errorData = err === null || err === void 0 ? void 0 : err.data;
427
+ if (errorData && typeof errorData === 'object' && 'is_valid' in errorData) {
428
+ const validation = errorData;
429
+ showValidation(validation, currentNodes());
430
+ toast.error(t('workflowsWorkflowEditor.workflowHasValidationIssues'));
431
+ }
432
+ else {
433
+ toast.error(t('workflowsWorkflowEditor.failedToActivateWorkflow'));
434
+ }
435
+ }
436
+ };
437
+ const handleDeleteConfirm = async () => {
438
+ try {
439
+ await deleteWorkflow({
440
+ org: tenantKey,
441
+ uniqueId: workflowId,
442
+ }).unwrap();
443
+ toast.success(t('workflowsWorkflowEditor.workflowDeleted'));
444
+ setIsDeleteModalOpen(false);
445
+ onDeleted();
446
+ }
447
+ catch (_a) {
448
+ toast.error(t('workflowsWorkflowEditor.failedToDeleteWorkflow'));
449
+ }
450
+ };
451
+ if (isLoading || isWaitingForMentorSettings) {
452
+ return (jsx("div", { className: "flex h-screen items-center justify-center", children: jsx(LoaderCircle, { className: "h-8 w-8 animate-spin text-gray-400" }) }));
453
+ }
454
+ if (error || !workflow) {
455
+ return (jsx("div", { className: "flex h-screen items-center justify-center", children: jsxs("div", { className: "text-center", children: [jsx(CircleAlert, { className: "mx-auto mb-4 h-12 w-12 text-red-500" }), jsx("p", { className: "mb-4 text-gray-600", children: t('workflowsWorkflowEditor.failedToLoadWorkflow') }), jsxs(Button, { variant: "outline", className: "h-9 has-[>svg]:px-3", onClick: () => onBack(), children: [jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }), t('workflowsWorkflowEditor.goBack')] })] }) }));
456
+ }
457
+ // Workflows saved with the builder's old field names open with the names
458
+ // the backend reads; the next save stores them.
459
+ const definition = migrateWorkflowDefinition(((_d = (_c = workflow.definition) === null || _c === void 0 ? void 0 : _c.nodes) !== null && _d !== void 0 ? _d : []), ((_f = (_e = workflow.definition) === null || _e === void 0 ? void 0 : _e.edges) !== null && _f !== void 0 ? _f : []));
460
+ const initialNodes = definition.nodes.map((n) => {
461
+ const nodeData = n.data;
462
+ if (n.type === 'mentor') {
463
+ const mentorId = (nodeData === null || nodeData === void 0 ? void 0 : nodeData.mentor_id) ||
464
+ (nodeData === null || nodeData === void 0 ? void 0 : nodeData.entry_mentor_id) ||
465
+ entryMentorId;
466
+ const mentorData = mentorId ? mentorSettingsById[mentorId] : null;
467
+ return {
468
+ ...n,
469
+ draggable: true,
470
+ selectable: true,
471
+ connectable: true,
472
+ data: {
473
+ ...nodeData,
474
+ ...(mentorId ? { entry_mentor_id: mentorId } : {}),
475
+ // The agent's current settings win over what the step saved.
476
+ ...(mentorData && {
477
+ label: mentorData.display_name ||
478
+ mentorData.mentor_name ||
479
+ (nodeData === null || nodeData === void 0 ? void 0 : nodeData.label),
480
+ instructions: mentorData.system_prompt || (nodeData === null || nodeData === void 0 ? void 0 : nodeData.instructions),
481
+ model: mentorData.llm_name || (nodeData === null || nodeData === void 0 ? void 0 : nodeData.model),
482
+ }),
483
+ },
484
+ };
485
+ }
486
+ return {
487
+ ...n,
488
+ draggable: true,
489
+ selectable: true,
490
+ connectable: true,
491
+ };
492
+ });
493
+ const initialEdges = definition.edges;
494
+ return (jsxs("div", { className: "flex h-screen flex-col bg-white", children: [jsxs("div", { className: `flex items-center justify-between px-4 py-3 ${isPreviewMode ? 'border-b border-gray-200 bg-white' : 'bg-background border-border border-b'}`, children: [jsx("div", { className: "flex items-center gap-3", children: isPreviewMode ? (jsxs("div", { className: "flex items-center gap-2", children: [jsx("h1", { className: "text-foreground font-medium", children: workflowName }), jsx("span", { className: `rounded-md px-2 py-0.5 text-xs ${workflow.is_active ? 'bg-green-100 text-green-700' : 'bg-muted text-muted-foreground'}`, children: workflow.is_active
495
+ ? t('workflowsWorkflowEditor.statusActive')
496
+ : t('workflowsWorkflowEditor.statusDraft') })] })) : (jsxs(Fragment, { children: [jsx(Button, { variant: "ghost", size: "icon", className: "h-9 w-9 text-muted-foreground hover:text-foreground", onClick: () => onBack(), children: jsx(ChevronLeft, { className: "h-5 w-5" }) }), jsxs("div", { className: "flex items-center gap-2", children: [isEditingName ? (jsx(Input, { value: workflowName, onChange: (e) => setWorkflowName(e.target.value), onBlur: handleNameSave, onKeyDown: (e) => e.key === 'Enter' && handleNameSave(), className: "text-foreground h-8 w-[200px] font-medium", autoFocus: true, "aria-label": t('workflowsWorkflowEditor.enterWorkflowNameLabel') })) : (jsxs("button", { onClick: () => setIsEditingName(true), className: "text-foreground hover:text-foreground/80 flex items-center gap-1 font-medium", "aria-label": t('workflowsWorkflowEditor.editWorkflowNameLabel'), children: [workflowName, jsx(Pencil, { className: "h-3 w-3 opacity-50" })] })), jsx("span", { className: `rounded-md px-2 py-0.5 text-xs ${workflow.is_active ? 'bg-green-100 text-green-700' : 'bg-muted text-muted-foreground'}`, children: workflow.is_active
497
+ ? t('workflowsWorkflowEditor.statusActive')
498
+ : t('workflowsWorkflowEditor.statusDraft') }), hasUnsavedChanges && (jsx("span", { className: "text-muted-foreground text-xs", children: t('workflowsWorkflowEditor.unsaved') }))] })] })) }), jsx("div", { className: "flex items-center gap-2", children: isPreviewMode ? (jsxs(Fragment, { children: [jsxs(Button, { variant: "ghost", size: "sm", className: "h-8 gap-1.5 has-[>svg]:px-2.5 text-foreground hover:text-foreground hover:bg-gray-100", onClick: handleClosePreview, children: [jsx(X, { className: "mr-2 h-4 w-4" }), t('workflowsWorkflowEditor.closePreview')] }), jsxs(Button, { variant: "ghost", size: "sm", className: "h-8 gap-1.5 has-[>svg]:px-2.5 text-foreground hover:text-foreground hover:bg-gray-100", onClick: handleNewChat, "aria-label": t('workflowsWorkflowEditor.newChatLabel'), children: [jsx(RotateCcw, { className: "mr-2 h-4 w-4" }), t('workflowsWorkflowEditor.newChat')] }), jsx(Button, { size: "sm", className: "h-8 gap-1.5 has-[>svg]:px-2.5 bg-[#38A1E5] text-white hover:bg-[#38A1E5]/90", onClick: handlePublish, disabled: isPublishing, children: isPublishing ? (jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" })) : (t('workflowsWorkflowEditor.publish')) })] })) : (jsxs(Fragment, { children: [jsxs(DropdownMenu, { children: [jsx(DropdownMenuTrigger, { asChild: true, children: jsx(Button, { variant: "ghost", size: "icon", className: "h-9 w-9 text-muted-foreground hover:text-foreground", "aria-label": t('workflowsWorkflowEditor.moreOptionsLabel'), children: jsx(Ellipsis, { className: "h-5 w-5" }) }) }), jsxs(DropdownMenuContent, { align: "end", children: [workflow.is_active ? (jsxs(DropdownMenuItem, { onClick: handleDeactivate, children: [jsx(Power, { className: "mr-2 h-4 w-4" }), t('workflowsWorkflowEditor.deactivate')] })) : (jsxs(DropdownMenuItem, { onClick: handleActivate, disabled: isActivating, children: [jsx(Power, { className: "mr-2 h-4 w-4" }), isActivating
499
+ ? t('workflowsWorkflowEditor.activating')
500
+ : t('workflowsWorkflowEditor.activate')] })), jsxs(DropdownMenuItem, { onClick: () => setIsDeleteModalOpen(true), className: "text-red-600", children: [jsx(Trash2, { className: "mr-2 h-4 w-4" }), t('workflowsWorkflowEditor.delete')] })] })] }), jsxs(Button, { variant: "outline", size: "sm", className: "h-8 gap-1.5 has-[>svg]:px-2.5 text-foreground border-border hover:bg-accent bg-transparent", onClick: handlePreviewClick, children: [jsx(Eye, { className: "mr-2 h-4 w-4" }), t('workflowsWorkflowEditor.preview')] }), jsx(Button, { size: "sm", className: "h-8 gap-1.5 has-[>svg]:px-2.5 bg-[#38A1E5] text-white hover:bg-[#38A1E5]/90", onClick: handleSave, disabled: isSaving, children: isSaving ? (jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" })) : (t('workflowsWorkflowEditor.save')) }), jsx(Button, { size: "sm", className: "h-8 gap-1.5 has-[>svg]:px-2.5 bg-[#38A1E5] text-white hover:bg-[#38A1E5]/90", onClick: handlePublish, disabled: isPublishing, children: isPublishing ? (jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" })) : (t('workflowsWorkflowEditor.publish')) })] })) })] }), validationResult &&
501
+ (validationResult.errors.length > 0 || validationResult.warnings.length > 0) && (jsx(Collapsible, { open: isValidationBannerOpen, onOpenChange: setIsValidationBannerOpen, children: jsxs("div", { className: "border-border bg-background border-b px-4 py-2", children: [jsx(CollapsibleTrigger, { asChild: true, children: jsxs("button", { className: "flex w-full items-center justify-between text-sm", children: [jsxs("div", { className: "flex items-center gap-2", children: [validationResult.errors.length > 0 ? (jsx(CircleAlert, { className: "h-4 w-4 text-red-500" })) : (jsx(TriangleAlert, { className: "h-4 w-4 text-amber-500" })), jsxs("span", { className: validationResult.errors.length > 0 ? 'text-red-700' : 'text-amber-700', children: [validationResult.errors.length > 0 &&
502
+ t('workflowsWorkflowEditor.validationErrors', {
503
+ count: validationResult.errors.length,
504
+ }), validationResult.errors.length > 0 &&
505
+ validationResult.warnings.length > 0 &&
506
+ ', ', validationResult.warnings.length > 0 &&
507
+ t('workflowsWorkflowEditor.validationWarnings', {
508
+ count: validationResult.warnings.length,
509
+ })] })] }), jsxs("div", { className: "flex items-center gap-2", children: [isValidationBannerOpen ? (jsx(ChevronUp, { className: "text-muted-foreground h-4 w-4" })) : (jsx(ChevronDown, { className: "text-muted-foreground h-4 w-4" })), jsx("span", { role: "button", tabIndex: 0, className: "text-muted-foreground hover:text-foreground", onClick: (e) => {
510
+ e.stopPropagation();
511
+ setValidationResult(null);
512
+ }, onKeyDown: (e) => {
513
+ if (e.key === 'Enter' || e.key === ' ') {
514
+ e.stopPropagation();
515
+ setValidationResult(null);
516
+ }
517
+ }, children: jsx(X, { className: "h-4 w-4" }) })] })] }) }), jsx(CollapsibleContent, { children: jsxs("div", { className: "mt-2 space-y-1 pb-1", children: [validationResult.errors.map((error, i) => (jsxs("div", { className: "flex items-start gap-2 text-sm text-red-600", children: [jsx(CircleAlert, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }), jsx("span", { children: error })] }, `error-${i}`))), validationResult.warnings.map((warning, i) => (jsxs("div", { className: "flex items-start gap-2 text-sm text-amber-600", children: [jsx(TriangleAlert, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }), jsx("span", { children: warning })] }, `warning-${i}`)))] }) })] }) })), jsxs("div", { className: "flex flex-1 overflow-hidden", children: [!isPreviewMode && (jsx(WorkflowSidebar, { onDragStart: setDraggedItem, onItemClick: handleItemClick, nodeTypes: nodeTypeSections })), jsx("div", { className: isPreviewMode ? 'h-full w-[60%] border-r border-gray-200' : 'h-full flex-1', children: jsx(WorkflowCanvas, { onDraggedItem: isPreviewMode ? null : draggedItem, onClickedItem: isPreviewMode ? null : clickedItem, previewMode: isPreviewMode, initialNodes: initialNodes, initialEdges: initialEdges, onStateChange: handleWorkflowStateChange, org: tenantKey, defaultMentorId: entryMentorId, username: username, onOpenAgentSettings: onOpenAgentSettings, agentSettings: agentSettings }) }), isPreviewMode && (jsx("div", { className: "flex h-full w-[40%] flex-col bg-white", children: jsx(WorkflowPreviewChat, { tenantKey: tenantKey, mentorId: entryMentorId, username: username, axdToken: axdToken, baseWsUrl: baseWsUrl, redirectToAuthSpa: redirectToAuthSpa, newChatSignal: newChatSignal }, previewKey) }))] }), jsx(DeleteWorkflowModal, { isOpen: isDeleteModalOpen, onClose: () => setIsDeleteModalOpen(false), onConfirm: handleDeleteConfirm, isDeleting: isDeleting, workflowName: workflow.name })] }));
518
+ }
519
+
520
+ export { WorkflowEditor };
521
+ //# sourceMappingURL=workflow-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-editor.js","sources":["../../../../../../../src/components/workflows/workflow-editor.tsx"],"sourcesContent":[null],"names":["useDebounce","_jsx","Loader2","_jsxs","AlertCircle","_Fragment","MoreHorizontal","AlertTriangle"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,SAAS,iBAAiB,CAAC,CAAoB,EAAA;IAC7C,OAAO;AACL,QAAA,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,sCAAsC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;AACpE,QAAA,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,uCAAuC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;AACtE,QAAA,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,uCAAuC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;AACtE,QAAA,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,sCAAsC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;KACrE;AACH;AAEA,MAAM,oBAAo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iBAAiB,EACpC,aAAa,EAAE,aAAa,EAAA,EAPvB,UAAU,CAQf,GACE,CACP,CAAA,EAAA,CACG,EAENA,GAAA,CAAC,mBAAmB,EAAA,EAClB,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,MAAM,oBAAoB,CAAC,KAAK,CAAC,EAC1C,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAA,CAC3B,CAAA,EAAA,CACE;AAEV;;;;"}
@@ -0,0 +1,55 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { useState, useRef, useEffect, useCallback } from 'react';
3
+ import { useAdvancedChat, ANONYMOUS_USERNAME } from '@iblai/web-utils';
4
+ import { toast } from 'sonner';
5
+ import { useT } from '../../i18n/context.js';
6
+ import '../../packages/i18n/dist/index.esm.js';
7
+ import { ChatMessages } from '../chat/chat-messages/index.js';
8
+ import { ChatInputForm } from '../chat-input-form.js';
9
+ import { LoadingMessage } from '../chat/loading-message.js';
10
+ import Bot from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/bot.js';
11
+
12
+ const noopAsync = async () => { };
13
+ const noop = () => { };
14
+ function WorkflowPreviewChat({ tenantKey, mentorId, username, axdToken, baseWsUrl, redirectToAuthSpa, newChatSignal, }) {
15
+ const t = useT();
16
+ const [highlightedMessageId, setHighlightedMessageId] = useState(null);
17
+ const chatContainerRef = useRef(null);
18
+ const handledNewChatSignal = useRef(newChatSignal);
19
+ const { messages, sendMessage, stopGenerating, setMessage, activeTab, mentorName, profileImage, sessionId, enableSafetyDisclaimer, isPending, isStreaming, currentStreamingMessage, isConnected, startNewChat, } = useAdvancedChat({
20
+ mentorId: mentorId !== null && mentorId !== void 0 ? mentorId : '',
21
+ tenantKey,
22
+ // Hosts pass '' for a signed-out user, who chats as ANONYMOUS_USERNAME.
23
+ username: username || ANONYMOUS_USERNAME,
24
+ token: axdToken,
25
+ wsUrl: `${baseWsUrl}/ws/langflow/`,
26
+ stopGenerationWsUrl: `${baseWsUrl}/ws/langflow-stop-generation/`,
27
+ redirectToAuthSpa,
28
+ cachedSessionId: {},
29
+ errorHandler: (message) => {
30
+ toast.error(message);
31
+ },
32
+ });
33
+ const visibleMessages = messages.length > 0 && messages[0].role === 'assistant' ? messages.slice(1) : messages;
34
+ useEffect(() => {
35
+ if (handledNewChatSignal.current === newChatSignal)
36
+ return;
37
+ handledNewChatSignal.current = newChatSignal;
38
+ startNewChat();
39
+ }, [newChatSignal, startNewChat]);
40
+ useEffect(() => {
41
+ if (!chatContainerRef.current)
42
+ return;
43
+ chatContainerRef.current.scrollTo({
44
+ top: chatContainerRef.current.scrollHeight,
45
+ behavior: 'smooth',
46
+ });
47
+ }, [visibleMessages.length, isStreaming, isPending]);
48
+ const handleSubmit = useCallback((content) => {
49
+ sendMessage(activeTab, content, { visible: true });
50
+ }, [activeTab, sendMessage]);
51
+ return (jsxs("div", { className: "flex h-full flex-col", children: [jsx("div", { ref: chatContainerRef, className: "flex-1 overflow-y-auto p-6", children: visibleMessages.length === 0 && !isPending && !isStreaming ? (jsxs("div", { className: "flex h-full flex-col items-center justify-center text-center", children: [jsx(Bot, { className: "text-muted-foreground mb-3 h-10 w-10" }), jsx("h2", { className: "text-foreground text-xl font-semibold", children: t('workflowsWorkflowPreviewChat.emptyTitle') }), jsx("p", { className: "text-muted-foreground mt-2 text-sm", children: t('workflowsWorkflowPreviewChat.emptyDescription') })] })) : (jsxs(Fragment, { children: [jsx(ChatMessages, { messages: visibleMessages, highlightedMessageId: highlightedMessageId, profileImage: profileImage, mentorName: mentorName, sessionId: sessionId, mentorId: mentorId !== null && mentorId !== void 0 ? mentorId : '', tenantKey: tenantKey, handleHighlightMessage: setHighlightedMessageId, handleSubmit: handleSubmit }), (isPending || isStreaming) && !(currentStreamingMessage === null || currentStreamingMessage === void 0 ? void 0 : currentStreamingMessage.content) && (jsx(LoadingMessage, { mentorName: mentorName, profileImage: profileImage }))] })) }), jsx("div", { className: "border-t border-gray-200 p-4", children: jsx(ChatInputForm, { sessionId: sessionId, mentorId: mentorId, onSubmit: handleSubmit, stopGenerating: stopGenerating, onScreenSharingClick: noop, isScreenSharingModalOpen: false, onPhoneCallClick: noop, tenantKey: tenantKey, username: username, enableWebBrowsing: false, setMessage: setMessage, isStreaming: isStreaming, enableSafetyDisclaimer: enableSafetyDisclaimer, updateSessionTools: noopAsync, setSessionTools: noopAsync, activeTools: [], screenSharing: false, deepResearch: false, studyMode: false, imageGeneration: false, codeInterpreter: false, promptsIsEnabled: false, googleSlidesIsEnabled: false, googleDocumentIsEnabled: false, artifactsEnabled: false, compactMode: true, isConnecting: !isConnected }) })] }));
52
+ }
53
+
54
+ export { WorkflowPreviewChat };
55
+ //# sourceMappingURL=workflow-preview-chat.js.map