@vertesia/ui 1.5.0-dev.20260717.131047Z → 1.5.0-dev.20260722.120446Z
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/components/SidePanel.js +1 -1
- package/lib/core/components/SidePanel.js.map +1 -1
- package/lib/core/components/shadcn/button.d.ts +10 -3
- package/lib/core/components/shadcn/button.d.ts.map +1 -1
- package/lib/core/components/shadcn/button.js +41 -9
- package/lib/core/components/shadcn/button.js.map +1 -1
- package/lib/core/components/shadcn/modal/dialog.js +1 -1
- package/lib/core/components/shadcn/modal/dialog.js.map +1 -1
- package/lib/core/components/shadcn/theme/ThemeSwitcher.js +1 -1
- package/lib/core/components/shadcn/theme/ThemeSwitcher.js.map +1 -1
- package/lib/features/agent/chat/AgentChatPlaybackControls.d.ts.map +1 -1
- package/lib/features/agent/chat/AgentChatPlaybackControls.js +2 -2
- package/lib/features/agent/chat/AgentChatPlaybackControls.js.map +1 -1
- package/lib/features/agent/chat/AgentRequestInputOverlay.d.ts.map +1 -1
- package/lib/features/agent/chat/AgentRequestInputOverlay.js +2 -2
- package/lib/features/agent/chat/AgentRequestInputOverlay.js.map +1 -1
- package/lib/features/agent/chat/ArtifactsTab.d.ts.map +1 -1
- package/lib/features/agent/chat/ArtifactsTab.js +5 -2
- package/lib/features/agent/chat/ArtifactsTab.js.map +1 -1
- package/lib/features/agent/chat/ImageLightbox.d.ts.map +1 -1
- package/lib/features/agent/chat/ImageLightbox.js +1 -1
- package/lib/features/agent/chat/ImageLightbox.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentConversation.js +1 -1
- package/lib/features/agent/chat/ModernAgentConversation.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js +5 -5
- package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/Header.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/Header.js +4 -2
- package/lib/features/agent/chat/ModernAgentOutput/Header.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageInput.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageInput.js +2 -2
- package/lib/features/agent/chat/ModernAgentOutput/MessageInput.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageItem.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageItem.js +2 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageItem.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/requestInputMessages.d.ts +6 -0
- package/lib/features/agent/chat/ModernAgentOutput/requestInputMessages.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/requestInputMessages.js +15 -1
- package/lib/features/agent/chat/ModernAgentOutput/requestInputMessages.js.map +1 -1
- package/lib/features/environment/SelectEnvironment.d.ts +28 -0
- package/lib/features/environment/SelectEnvironment.d.ts.map +1 -0
- package/lib/features/environment/SelectEnvironment.js +97 -0
- package/lib/features/environment/SelectEnvironment.js.map +1 -0
- package/lib/features/environment/index.d.ts +2 -0
- package/lib/features/environment/index.d.ts.map +1 -0
- package/lib/features/environment/index.js +2 -0
- package/lib/features/environment/index.js.map +1 -0
- package/lib/features/index.d.ts +2 -0
- package/lib/features/index.d.ts.map +1 -1
- package/lib/features/index.js +2 -0
- package/lib/features/index.js.map +1 -1
- package/lib/features/magic-pdf/AnnotatedImageSlider.js +12 -12
- package/lib/features/magic-pdf/AnnotatedImageSlider.js.map +1 -1
- package/lib/features/magic-pdf/DownloadPopover.d.ts.map +1 -1
- package/lib/features/magic-pdf/DownloadPopover.js +3 -17
- package/lib/features/magic-pdf/DownloadPopover.js.map +1 -1
- package/lib/features/magic-pdf/ExtractedContentView.js +2 -6
- package/lib/features/magic-pdf/ExtractedContentView.js.map +1 -1
- package/lib/features/magic-pdf/GroundedExtractionAssistantPanel.d.ts +25 -0
- package/lib/features/magic-pdf/GroundedExtractionAssistantPanel.d.ts.map +1 -0
- package/lib/features/magic-pdf/GroundedExtractionAssistantPanel.js +42 -0
- package/lib/features/magic-pdf/GroundedExtractionAssistantPanel.js.map +1 -0
- package/lib/features/magic-pdf/GroundedExtractionView.d.ts +27 -0
- package/lib/features/magic-pdf/GroundedExtractionView.d.ts.map +1 -0
- package/lib/features/magic-pdf/GroundedExtractionView.js +377 -0
- package/lib/features/magic-pdf/GroundedExtractionView.js.map +1 -0
- package/lib/features/magic-pdf/MagicPdfProvider.d.ts +0 -2
- package/lib/features/magic-pdf/MagicPdfProvider.d.ts.map +1 -1
- package/lib/features/magic-pdf/MagicPdfProvider.js +15 -42
- package/lib/features/magic-pdf/MagicPdfProvider.js.map +1 -1
- package/lib/features/magic-pdf/MagicPdfView.d.ts.map +1 -1
- package/lib/features/magic-pdf/MagicPdfView.js +2 -19
- package/lib/features/magic-pdf/MagicPdfView.js.map +1 -1
- package/lib/features/magic-pdf/index.d.ts +1 -0
- package/lib/features/magic-pdf/index.d.ts.map +1 -1
- package/lib/features/magic-pdf/index.js +1 -0
- package/lib/features/magic-pdf/index.js.map +1 -1
- package/lib/features/magic-pdf/types.d.ts +1 -1
- package/lib/features/magic-pdf/types.d.ts.map +1 -1
- package/lib/features/oauth/McpConnectionsButton.d.ts.map +1 -1
- package/lib/features/oauth/McpConnectionsButton.js +2 -2
- package/lib/features/oauth/McpConnectionsButton.js.map +1 -1
- package/lib/features/oauth/McpConnectionsDialog.d.ts.map +1 -1
- package/lib/features/oauth/McpConnectionsDialog.js +1 -1
- package/lib/features/oauth/McpConnectionsDialog.js.map +1 -1
- package/lib/features/oauth/RemoteMcpConnectionButton.d.ts.map +1 -1
- package/lib/features/oauth/RemoteMcpConnectionButton.js +1 -1
- package/lib/features/oauth/RemoteMcpConnectionButton.js.map +1 -1
- package/lib/features/pdf-viewer/PdfPageSlider.js +2 -2
- package/lib/features/pdf-viewer/PdfPageSlider.js.map +1 -1
- package/lib/features/pdf-viewer/SimplePdfViewer.d.ts.map +1 -1
- package/lib/features/pdf-viewer/SimplePdfViewer.js +3 -3
- package/lib/features/pdf-viewer/SimplePdfViewer.js.map +1 -1
- package/lib/features/permissions/UserPermissionsProvider.js +1 -1
- package/lib/features/permissions/UserPermissionsProvider.js.map +1 -1
- package/lib/features/store/objects/DocumentQuickFilter.d.ts.map +1 -1
- package/lib/features/store/objects/DocumentQuickFilter.js +5 -5
- package/lib/features/store/objects/DocumentQuickFilter.js.map +1 -1
- package/lib/features/store/objects/DocumentSearchResults.d.ts.map +1 -1
- package/lib/features/store/objects/DocumentSearchResults.js +2 -2
- package/lib/features/store/objects/DocumentSearchResults.js.map +1 -1
- package/lib/features/store/objects/components/ContentDispositionButton.d.ts.map +1 -1
- package/lib/features/store/objects/components/ContentDispositionButton.js +1 -1
- package/lib/features/store/objects/components/ContentDispositionButton.js.map +1 -1
- package/lib/features/store/objects/components/ContentOverview.d.ts.map +1 -1
- package/lib/features/store/objects/components/ContentOverview.js +78 -21
- package/lib/features/store/objects/components/ContentOverview.js.map +1 -1
- package/lib/features/store/objects/components/DocumentIcon.js +1 -1
- package/lib/features/store/objects/components/VectorSearchWidget.js +1 -1
- package/lib/features/store/objects/components/VectorSearchWidget.js.map +1 -1
- package/lib/features/store/objects/components/useContentPanelHooks.d.ts +1 -2
- package/lib/features/store/objects/components/useContentPanelHooks.d.ts.map +1 -1
- package/lib/features/store/objects/components/useContentPanelHooks.js +4 -8
- package/lib/features/store/objects/components/useContentPanelHooks.js.map +1 -1
- package/lib/features/store/objects/layout/renderers.d.ts.map +1 -1
- package/lib/features/store/objects/layout/renderers.js +2 -2
- package/lib/features/store/objects/layout/renderers.js.map +1 -1
- package/lib/features/store/objects/selection/SelectionActions.js +1 -1
- package/lib/features/store/objects/selection/SelectionActions.js.map +1 -1
- package/lib/features/store/types/ContentObjectTypesTable.d.ts.map +1 -1
- package/lib/features/store/types/ContentObjectTypesTable.js +4 -4
- package/lib/features/store/types/ContentObjectTypesTable.js.map +1 -1
- package/lib/features/store/types/IntakePolicyEditor.d.ts +15 -0
- package/lib/features/store/types/IntakePolicyEditor.d.ts.map +1 -0
- package/lib/features/store/types/IntakePolicyEditor.js +455 -0
- package/lib/features/store/types/IntakePolicyEditor.js.map +1 -0
- package/lib/features/store/types/IntakePolicyForm.d.ts +11 -0
- package/lib/features/store/types/IntakePolicyForm.d.ts.map +1 -0
- package/lib/features/store/types/IntakePolicyForm.js +91 -0
- package/lib/features/store/types/IntakePolicyForm.js.map +1 -0
- package/lib/features/store/types/SelectContentTypeModal.js +1 -1
- package/lib/features/store/types/SelectContentTypeModal.js.map +1 -1
- package/lib/features/store/types/index.d.ts +2 -0
- package/lib/features/store/types/index.d.ts.map +1 -1
- package/lib/features/store/types/index.js +2 -0
- package/lib/features/store/types/index.js.map +1 -1
- package/lib/features/store/types/intake-policy-editor.logic.d.ts +7 -0
- package/lib/features/store/types/intake-policy-editor.logic.d.ts.map +1 -0
- package/lib/features/store/types/intake-policy-editor.logic.js +60 -0
- package/lib/features/store/types/intake-policy-editor.logic.js.map +1 -0
- package/lib/features/store/types/typeCatalogCache.d.ts +5 -0
- package/lib/features/store/types/typeCatalogCache.d.ts.map +1 -0
- package/lib/features/store/types/typeCatalogCache.js +40 -0
- package/lib/features/store/types/typeCatalogCache.js.map +1 -0
- package/lib/features/user/UserInfo.js +7 -3
- package/lib/features/user/UserInfo.js.map +1 -1
- package/lib/features/views/ViewExperience.d.ts +20 -0
- package/lib/features/views/ViewExperience.d.ts.map +1 -0
- package/lib/features/views/ViewExperience.js +188 -0
- package/lib/features/views/ViewExperience.js.map +1 -0
- package/lib/features/views/ViewNavigation.d.ts +3 -0
- package/lib/features/views/ViewNavigation.d.ts.map +1 -0
- package/lib/features/views/ViewNavigation.js +36 -0
- package/lib/features/views/ViewNavigation.js.map +1 -0
- package/lib/features/views/ViewResults.d.ts +9 -0
- package/lib/features/views/ViewResults.d.ts.map +1 -0
- package/lib/features/views/ViewResults.js +229 -0
- package/lib/features/views/ViewResults.js.map +1 -0
- package/lib/features/views/ViewSearch.d.ts +3 -0
- package/lib/features/views/ViewSearch.d.ts.map +1 -0
- package/lib/features/views/ViewSearch.js +74 -0
- package/lib/features/views/ViewSearch.js.map +1 -0
- package/lib/features/views/index.d.ts +7 -0
- package/lib/features/views/index.d.ts.map +1 -0
- package/lib/features/views/index.js +7 -0
- package/lib/features/views/index.js.map +1 -0
- package/lib/features/views/types.d.ts +39 -0
- package/lib/features/views/types.d.ts.map +1 -0
- package/lib/features/views/types.js +2 -0
- package/lib/features/views/types.js.map +1 -0
- package/lib/features/views/viewState.d.ts +14 -0
- package/lib/features/views/viewState.d.ts.map +1 -0
- package/lib/features/views/viewState.js +117 -0
- package/lib/features/views/viewState.js.map +1 -0
- package/lib/i18n/locales/ar.json +16 -0
- package/lib/i18n/locales/de.json +12 -0
- package/lib/i18n/locales/en.json +245 -33
- package/lib/i18n/locales/es.json +13 -0
- package/lib/i18n/locales/fr.json +13 -0
- package/lib/i18n/locales/it.json +13 -0
- package/lib/i18n/locales/ja.json +11 -0
- package/lib/i18n/locales/ko.json +11 -0
- package/lib/i18n/locales/pt.json +13 -0
- package/lib/i18n/locales/ru.json +14 -0
- package/lib/i18n/locales/tr.json +12 -0
- package/lib/i18n/locales/zh-TW.json +11 -0
- package/lib/i18n/locales/zh.json +11 -0
- package/lib/router/HistoryNavigator.d.ts.map +1 -1
- package/lib/router/HistoryNavigator.js +23 -13
- package/lib/router/HistoryNavigator.js.map +1 -1
- package/lib/router/Nav.d.ts.map +1 -1
- package/lib/router/Nav.js +15 -6
- package/lib/router/Nav.js.map +1 -1
- package/lib/session/UserSession.d.ts.map +1 -1
- package/lib/session/UserSession.js +5 -3
- package/lib/session/UserSession.js.map +1 -1
- package/lib/vertesia-ui-core.js +4 -4
- package/lib/vertesia-ui-core.js.map +1 -1
- package/lib/vertesia-ui-features.js +34 -27
- package/lib/vertesia-ui-features.js.map +1 -1
- package/lib/vertesia-ui-i18n.js +15 -15
- package/lib/vertesia-ui-i18n.js.map +1 -1
- package/lib/vertesia-ui-router.js +1 -1
- package/lib/vertesia-ui-router.js.map +1 -1
- package/lib/vertesia-ui-session.js +1 -1
- package/lib/vertesia-ui-session.js.map +1 -1
- package/lib/vertesia-ui-shell.js +1 -1
- package/lib/vertesia-ui-shell.js.map +1 -1
- package/lib/vertesia-ui-widgets.js +7 -7
- package/lib/vertesia-ui-widgets.js.map +1 -1
- package/lib/widgets/form/Form.js +1 -1
- package/lib/widgets/form/Form.js.map +1 -1
- package/lib/widgets/json-view/JSONSwitcher.js +1 -1
- package/lib/widgets/json-view/JSONSwitcher.js.map +1 -1
- package/lib/widgets/json-view/JSONView.js +6 -6
- package/lib/widgets/json-view/JSONView.js.map +1 -1
- package/lib/widgets/monacoEditor/MonacoEditor.d.ts.map +1 -1
- package/lib/widgets/monacoEditor/MonacoEditor.js +29 -0
- package/lib/widgets/monacoEditor/MonacoEditor.js.map +1 -1
- package/lib/widgets/schema-editor/ManagedSchema.d.ts +8 -0
- package/lib/widgets/schema-editor/ManagedSchema.d.ts.map +1 -1
- package/lib/widgets/schema-editor/ManagedSchema.js +16 -0
- package/lib/widgets/schema-editor/ManagedSchema.js.map +1 -1
- package/lib/widgets/schema-editor/editor/EditableSchemaProperty.d.ts +2 -0
- package/lib/widgets/schema-editor/editor/EditableSchemaProperty.d.ts.map +1 -1
- package/lib/widgets/schema-editor/editor/EditableSchemaProperty.js +1 -0
- package/lib/widgets/schema-editor/editor/EditableSchemaProperty.js.map +1 -1
- package/lib/widgets/schema-editor/editor/PropertyViewer.d.ts.map +1 -1
- package/lib/widgets/schema-editor/editor/PropertyViewer.js +4 -1
- package/lib/widgets/schema-editor/editor/PropertyViewer.js.map +1 -1
- package/lib/widgets/schema-editor/editor/SchemaEditor.d.ts.map +1 -1
- package/lib/widgets/schema-editor/editor/SchemaEditor.js +22 -11
- package/lib/widgets/schema-editor/editor/SchemaEditor.js.map +1 -1
- package/package.json +32 -32
- package/src/__tests__/a11y.test.tsx +73 -0
- package/src/core/components/SidePanel.tsx +1 -1
- package/src/core/components/shadcn/button.tsx +67 -12
- package/src/core/components/shadcn/modal/dialog.tsx +1 -1
- package/src/core/components/shadcn/theme/ThemeSwitcher.tsx +1 -1
- package/src/features/agent/chat/AgentChatPlaybackControls.tsx +0 -5
- package/src/features/agent/chat/AgentRequestInputOverlay.test.tsx +31 -0
- package/src/features/agent/chat/AgentRequestInputOverlay.tsx +6 -2
- package/src/features/agent/chat/ArtifactsTab.tsx +19 -9
- package/src/features/agent/chat/ImageLightbox.tsx +0 -1
- package/src/features/agent/chat/ModernAgentConversation.test.tsx +48 -0
- package/src/features/agent/chat/ModernAgentConversation.tsx +0 -2
- package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.test.tsx +6 -1
- package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.tsx +21 -15
- package/src/features/agent/chat/ModernAgentOutput/Header.tsx +3 -3
- package/src/features/agent/chat/ModernAgentOutput/MessageInput.tsx +0 -2
- package/src/features/agent/chat/ModernAgentOutput/MessageItem.tsx +4 -1
- package/src/features/agent/chat/ModernAgentOutput/requestInputMessages.test.ts +80 -0
- package/src/features/agent/chat/ModernAgentOutput/requestInputMessages.ts +21 -1
- package/src/features/environment/SelectEnvironment.tsx +186 -0
- package/src/features/environment/index.ts +1 -0
- package/src/features/index.ts +2 -0
- package/src/features/magic-pdf/AnnotatedImageSlider.tsx +62 -66
- package/src/features/magic-pdf/DownloadPopover.tsx +5 -48
- package/src/features/magic-pdf/ExtractedContentView.tsx +2 -14
- package/src/features/magic-pdf/GroundedExtractionAssistantPanel.tsx +86 -0
- package/src/features/magic-pdf/GroundedExtractionView.test.tsx +65 -0
- package/src/features/magic-pdf/GroundedExtractionView.tsx +1055 -0
- package/src/features/magic-pdf/MagicPdfProvider.tsx +17 -47
- package/src/features/magic-pdf/MagicPdfView.tsx +3 -51
- package/src/features/magic-pdf/index.ts +1 -0
- package/src/features/magic-pdf/types.ts +1 -1
- package/src/features/oauth/McpConnectionsButton.tsx +0 -2
- package/src/features/oauth/McpConnectionsDialog.tsx +0 -1
- package/src/features/oauth/RemoteMcpConnectionButton.tsx +0 -1
- package/src/features/pdf-viewer/PdfPageSlider.tsx +5 -5
- package/src/features/pdf-viewer/SimplePdfViewer.tsx +11 -12
- package/src/features/permissions/UserPermissionsProvider.tsx +1 -1
- package/src/features/store/objects/DocumentQuickFilter.tsx +13 -15
- package/src/features/store/objects/DocumentSearchResults.tsx +3 -6
- package/src/features/store/objects/components/ContentDispositionButton.tsx +5 -1
- package/src/features/store/objects/components/ContentOverview.tsx +144 -44
- package/src/features/store/objects/components/DocumentIcon.tsx +1 -1
- package/src/features/store/objects/components/VectorSearchWidget.tsx +2 -2
- package/src/features/store/objects/components/useContentPanelHooks.ts +3 -15
- package/src/features/store/objects/layout/renderers.tsx +1 -2
- package/src/features/store/objects/selection/SelectionActions.tsx +1 -1
- package/src/features/store/types/ContentObjectTypesTable.tsx +12 -14
- package/src/features/store/types/IntakePolicyEditor.tsx +679 -0
- package/src/features/store/types/IntakePolicyForm.tsx +838 -0
- package/src/features/store/types/SelectContentTypeModal.tsx +2 -2
- package/src/features/store/types/index.ts +2 -0
- package/src/features/store/types/intake-policy-editor.logic.test.ts +109 -0
- package/src/features/store/types/intake-policy-editor.logic.ts +87 -0
- package/src/features/store/types/typeCatalogCache.ts +45 -0
- package/src/features/user/UserInfo.tsx +7 -7
- package/src/features/views/ViewExperience.test.tsx +273 -0
- package/src/features/views/ViewExperience.tsx +408 -0
- package/src/features/views/ViewNavigation.test.tsx +86 -0
- package/src/features/views/ViewNavigation.tsx +187 -0
- package/src/features/views/ViewResults.test.ts +82 -0
- package/src/features/views/ViewResults.tsx +609 -0
- package/src/features/views/ViewSearch.test.tsx +147 -0
- package/src/features/views/ViewSearch.tsx +205 -0
- package/src/features/views/index.ts +6 -0
- package/src/features/views/types.ts +57 -0
- package/src/features/views/viewState.test.ts +111 -0
- package/src/features/views/viewState.ts +132 -0
- package/src/i18n/locales/ar.json +16 -0
- package/src/i18n/locales/de.json +12 -0
- package/src/i18n/locales/en.json +965 -753
- package/src/i18n/locales/es.json +13 -0
- package/src/i18n/locales/fr.json +13 -0
- package/src/i18n/locales/it.json +13 -0
- package/src/i18n/locales/ja.json +11 -0
- package/src/i18n/locales/ko.json +11 -0
- package/src/i18n/locales/pt.json +13 -0
- package/src/i18n/locales/ru.json +14 -0
- package/src/i18n/locales/tr.json +12 -0
- package/src/i18n/locales/zh-TW.json +11 -0
- package/src/i18n/locales/zh.json +11 -0
- package/src/router/HistoryNavigator.test.ts +48 -0
- package/src/router/HistoryNavigator.ts +24 -13
- package/src/router/Nav.tsx +18 -8
- package/src/session/UserSession.test.ts +39 -0
- package/src/session/UserSession.ts +5 -3
- package/src/widgets/form/Form.tsx +1 -1
- package/src/widgets/json-view/JSONSwitcher.tsx +2 -2
- package/src/widgets/json-view/JSONView.tsx +7 -7
- package/src/widgets/monacoEditor/MonacoEditor.tsx +29 -0
- package/src/widgets/schema-editor/ManagedSchema.ts +22 -0
- package/src/widgets/schema-editor/editor/EditableSchemaProperty.tsx +3 -0
- package/src/widgets/schema-editor/editor/PropertyViewer.tsx +14 -3
- package/src/widgets/schema-editor/editor/SchemaEditor.tsx +80 -29
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import{Fragment as e,jsx as t,jsxs as n}from"react/jsx-runtime";import{Avatar as r,Badge as i,Breadcrumbs as a,Button as o,Card as s,CardContent as c,Center as l,Checkbox as u,Command as d,CommandEmpty as f,CommandGroup as p,CommandInput as m,CommandItem as h,ConfirmModal as g,CopyButton as _,DialogDescription as v,Divider as y,Dropdown as b,DropdownMenu as x,DropdownMenuContent as S,DropdownMenuItem as C,DropdownMenuRadioGroup as w,DropdownMenuRadioItem as T,DropdownMenuTrigger as E,EmptyCollection as D,ErrorBox as O,FilterBar as k,FilterBtn as A,FilterClear as j,FilterProvider as M,FormItem as N,Heading as P,Input as F,InputList as I,Label as L,MenuGroup as R,MenuItem as z,MessageBox as ee,Modal as B,ModalBody as te,ModalFooter as ne,ModalTitle as re,NumberInput as ie,Panel as ae,Popover as oe,PopoverContent as se,PopoverTrigger as ce,Portal as le,RadioGroup as ue,RadioGroupAdapter as de,ResizableHandle as fe,ResizablePanel as pe,ResizablePanelGroup as me,SelectBox as V,SelectList as he,Separator as ge,SharedState as _e,SidePanel as ve,Slider as ye,Spinner as be,Styles as xe,Switch as Se,TBody as Ce,THead as we,TR as Te,Table as Ee,Tabs as De,TabsBar as Oe,TabsPanel as ke,TagsInput as Ae,Textarea as je,VTooltip as Me,cn as H,errorMessage as Ne,insertNewlineAtCursor as Pe,onActivateKey as Fe,useDebounce as Ie,useFetch as Le,useFlag as Re,useIntersectionObserver as ze,useIsInModal as Be,useTheme as Ve,useToast as He,useWatchSharedState as Ue}from"@vertesia/ui/core";import We,{clsx as Ge}from"clsx";import{AnimatePresence as Ke,motion as qe}from"motion/react";import*as U from"react";import W,{Component as Je,createContext as Ye,forwardRef as Xe,memo as Ze,useCallback as G,useContext as Qe,useEffect as K,useId as $e,useLayoutEffect as et,useMemo as q,useRef as J,useState as Y,useSyncExternalStore as tt}from"react";import{NAMESPACE as nt,i18nInstance as rt,useUITranslation as X}from"@vertesia/ui/i18n";import{Activity as it,AlertCircle as at,AlertCircleIcon as ot,AlertTriangle as st,ArrowLeft as ct,ArrowUpIcon as lt,BarChart3 as ut,Bot as dt,Brain as ft,Check as pt,CheckCheck as mt,CheckCircle as ht,CheckCircle2 as gt,CheckCircleIcon as _t,CheckIcon as vt,ChevronDown as yt,ChevronDownIcon as bt,ChevronLeft as xt,ChevronRight as St,ChevronRightIcon as Ct,ChevronsDown as wt,ChevronsLeft as Tt,ChevronsRight as Et,ChevronsUp as Dt,ChevronsUpDown as Ot,Circle as kt,ClipboardCopyIcon as At,ClipboardList as jt,Clock as Mt,Code as Nt,Copy as Pt,CopyIcon as Ft,Cpu as It,Download as Lt,DownloadCloudIcon as Rt,DownloadIcon as zt,EllipsisVertical as Bt,ExternalLink as Vt,ExternalLinkIcon as Ht,Eye as Ut,EyeIcon as Wt,FileIcon as Gt,FileSearch as Kt,FileText as qt,FileTextIcon as Jt,Filter as Yt,FolderClosed as Xt,FolderIcon as Zt,FolderOpenIcon as Qt,GitBranch as $t,GitFork as en,HandIcon as tn,HelpCircle as nn,Image as rn,ImageIcon as an,Info as on,InfoIcon as sn,Layers as cn,LayoutGrid as ln,LayoutListIcon as un,Link as dn,Link2 as fn,Link2Off as pn,Loader2 as mn,Loader2Icon as hn,Maximize as gn,Maximize2 as _n,MessageSquare as vn,MessageSquareText as yn,Minimize2 as bn,Minus as xn,MonitorIcon as Sn,MoreHorizontal as Cn,MoreVertical as wn,PackageIcon as Tn,PaperclipIcon as En,Pause as Dn,Pencil as On,Play as kn,Plus as An,PlusIcon as jn,Radio as Mn,RefreshCcw as Nn,RefreshCw as Pn,RefreshCwIcon as Fn,Rewind as In,Rows3 as Ln,ScanSearch as Rn,Search as zn,Send as Bn,Settings as Vn,ShieldAlertIcon as Hn,ShieldCheckIcon as Un,SquareIcon as Wn,SquarePen as Gn,Table as Kn,TableProperties as qn,Terminal as Jn,Trash2 as Yn,Unlink2 as Xn,UploadIcon as Zn,User as Qn,Users as $n,Users2 as er,Wrench as tr,X as nr,XCircle as rr,XCircleIcon as ir,XIcon as ar}from"lucide-react";import*as or from"@radix-ui/react-dialog";import{UserSessionContext as sr,useUserSession as Z}from"@vertesia/ui/session";import cr from"papaparse";import{VegaEmbed as lr}from"react-vega";import{twMerge as ur}from"tailwind-merge";import{AUDIO_RENDITION_NAME as dr,AgentMessageType as Q,AgentSearchScope as fr,ContentNature as pr,ContentObjectStatus as mr,FileProcessingStatus as hr,ImageRenditionFormat as gr,InteractionStatus as _r,MarkdownRenditionFormat as vr,PDF_RENDITION_NAME as yr,POSTER_RENDITION_NAME as br,Permission as xr,PrincipalType as Sr,SearchTypes as Cr,SecurityLevelLabels as wr,SupportedEmbeddingTypes as Tr,WorkflowExecutionStatus as Er,getContentTypeRefId as Dr,mergeInCodePromptSchemas as Or,normalizeAgentToolApprovalMode as kr,normalizeToolCollection as Ar,supportsToolUse as jr}from"@vertesia/common";import"react-dom";import{Slot as Mr}from"@radix-ui/react-slot";import{cva as Nr}from"class-variance-authority";import*as Pr from"@radix-ui/react-tooltip";import"@vertesia/ui/env";import"framer-motion";import*as Fr from"@radix-ui/react-checkbox";import"@radix-ui/react-collapsible";import{Command as Ir}from"cmdk";import*as Lr from"@radix-ui/react-dropdown-menu";import Rr from"dayjs";import"react-calendar";import*as zr from"@radix-ui/react-popover";import{capitalize as Br}from"lodash-es";import*as Vr from"@radix-ui/react-label";import"@radix-ui/react-radio-group";import"react-resizable-panels";import*as Hr from"@radix-ui/react-separator";import*as Ur from"@radix-ui/react-slider";import*as Wr from"@radix-ui/react-switch";import*as Gr from"@radix-ui/react-tabs";import Kr,{defaultUrlTransform as qr}from"react-markdown";import Jr from"rehype-katex";import{defListHastHandlers as Yr,remarkDefinitionList as Xr}from"remark-definition-list";import Zr from"remark-directive";import Qr from"remark-gfm";import $r from"remark-github-blockquote-alert";import ei from"remark-math";import ti from"remark-supersub";import{SKIP as ni,visit as ri}from"unist-util-visit";import{FusionFragmentHandler as ii,FusionFragmentProvider as ai}from"@vertesia/fusion-ux";import oi from"dompurify";import si from"mermaid";import{NavLink as ci,useNavigate as li,useRouterContext as ui}from"@vertesia/ui/router";import{CodeBlockErrorBoundary as di,CodeBlockPlaceholder as fi,CodeBlockRendererProvider as pi,DropZone as mi,GeneratedForm as hi,JSONCode as gi,JSONDisplay as _i,ManagedObject as vi,MarkdownRenderer as yi,MonacoEditor as bi,Progress as xi,SchemaEditor as Si,UploadSummary as Ci,XMLViewer as wi,isIncompleteJson as Ti,useCodeBlockContext as Ei,useSchema as Di}from"@vertesia/ui/widgets";import{Document as Oi,Page as ki,pdfjs as Ai}from"react-pdf";import ji,{Ajv as Mi}from"ajv";import Ni from"dayjs/plugin/localizedFormat";import Pi from"dayjs/plugin/relativeTime";import{Md5 as Fi}from"ts-md5";import{ErrorBoundary as Ii}from"react-error-boundary";import{SidebarItem as Li}from"@vertesia/ui/layout";function Ri({children:e,secondary:n=!1}){return t(`span`,{className:n?`bg-secondary text-primary`:`text-foreground bg-muted`,children:e})}function zi(e){if(e)return e.name===`array`?zi(e.innerType):e}function Bi({property:e}){return n(`div`,{className:`flex items-center gap-x-2`,children:[t(`div`,{className:`font-semibold text-gray-600`,children:e.name}),e.optional&&t(Ri,{children:`optional`}),t(Ri,{children:e.type.value})]})}function Vi({activities:e}){return t(`div`,{className:`flex flex-col gap-y-4 divide-y divide-gray-200`,children:e.map(e=>t(Ui,{activity:e},e.name))})}function Hi({code:e,children:r}){return n(`div`,{className:`flex gap-2 items-center border-b border-b-gray-200 mb-2`,children:[t(`div`,{className:`text-lg font-medium text-gray-900 py-2 `,children:r}),e&&t(`div`,{children:t(Ri,{children:e})})]})}function Ui({activity:e,headingClass:r,headingRef:i}){return n(`div`,{className:r,id:e.name,ref:i,children:[t(`div`,{className:`text-xl font-semibold pt-8`,children:e.title}),t(`div`,{className:`pb-4`,children:t(Ri,{children:e.name})}),e.doc&&t(`div`,{className:`text-gray-700 pb-2`,children:e.doc}),n(`div`,{className:`pb-4`,children:[t(Hi,{code:e.paramsType,children:`Parameters`}),t(`div`,{className:`divide-y divide-gray-100`,children:e.params.map(e=>t(Wi,{property:e},e.name))})]}),n(`div`,{className:`pb-4`,children:[t(Hi,{children:`Returns`}),t(`div`,{children:e.returnType?e.returnType.value:`void`})]})]})}function Wi({property:e,className:r}){let i=q(()=>{let n=zi(e.type.innerType)??e.type;return n.name===`object`&&n.members?t(Ki,{members:n.members}):n.name===`enum`&&n.enum?t(Gi,{values:n.enum}):null},[e.type]);return n(`div`,{className:We(`py-2`,r),children:[t(Bi,{property:e}),e.doc&&t(`div`,{className:`text-gray-700 text-sm pt-2`,children:e.doc}),i&&t(`div`,{className:`my-2 overflow-hidden`,children:i})]})}function Gi({values:e}){return t(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.map(e=>t(Ri,{secondary:!0,children:e},e))})}function Ki({members:e}){return t(Ji,{className:`rounded-md border border-gray-200`,button:e=>n(`div`,{className:`px-4 py-2 flex items-center gap-x-2 text-sm font-medium hover:text-blue-600`,children:[t(Yi,{isOpen:e}),e?t(`div`,{children:`Hide child properties`}):t(`div`,{children:`Show child properties`})]}),body:t(qi,{properties:e})})}function qi({properties:e}){return t(`div`,{className:`border-s-2 border-s-blue-200 flex flex-col divide-y divide-gray-100 border-t border-t-gray-200`,children:e.map(e=>t(Wi,{property:e,className:`px-4 py-2`},e.name))})}function Ji({button:e,body:r,className:i,isInitiallyOpen:a}){let[s,c]=Y(a||!1);return n(`div`,{className:We(s?`block`:`inline-block`,i),children:[t(o,{variant:`unstyled`,className:`p-0 m-0 bg-transparent`,onClick:()=>c(!s),children:t(Ke,{children:e(s)})}),t(Ke,{children:s&&t(qe.div,{className:`overflow-hidden`,initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:`easeOut`},children:r})})]})}function Yi({isOpen:e}){return t(Ke,{propagate:!0,mode:`wait`,children:t(qe.div,{className:`font-mono font-semibold text-gray-400 text-lg`,initial:{rotate:0},animate:{rotate:e?45:0},transition:{duration:.2},children:`+`},`closeIcon`)})}function Xi(e){return e===`full_control`?`text-attention`:e===`auto_review`?`text-info`:`text-muted`}function Zi(e){return t(e===`full_control`?Hn:e===`ask`?tn:Un,{className:`size-4`})}function Qi({mode:e,onChange:r,disabled:i=!1,className:a}){let{t:s}=X(),c=q(()=>[{mode:`ask`,label:s(`agent.approvalMode.ask`),description:s(`agent.approvalMode.askDescription`),icon:t(tn,{className:`size-4`})},{mode:`auto_review`,label:s(`agent.approvalMode.autoReview`),description:s(`agent.approvalMode.autoReviewDescription`),icon:t(Un,{className:`size-4`})},{mode:`full_control`,label:s(`agent.approvalMode.fullControl`),description:s(`agent.approvalMode.fullControlDescription`),icon:t(Hn,{className:`size-4`})}],[s]),l=c.find(t=>t.mode===e)??c[2],u=t=>{t!==e&&r(t)};return n(x,{children:[t(E,{asChild:!0,children:n(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,className:H(`h-8 max-w-[13rem] rounded-full px-2.5 font-medium`,`bg-mixer-muted/15 text-muted hover:bg-muted hover:text-foreground disabled:opacity-60`,a),"aria-label":s(`agent.approvalMode.selectorLabel`),children:[t(`span`,{className:H(`shrink-0`,Xi(e)),children:Zi(e)}),t(`span`,{className:`min-w-0 truncate`,children:l.label}),t(bt,{className:`size-4 shrink-0 opacity-70`})]})}),n(S,{align:`start`,className:`z-[1000000] w-[min(28rem,calc(100vw-1rem))] p-2`,children:[t(`div`,{className:`px-2 pb-1.5 pt-1 text-sm font-medium text-foreground`,children:s(`agent.approvalMode.dropdownTitle`)}),t(w,{value:e,onValueChange:e=>u(e),children:c.map(e=>n(T,{value:e.mode,className:`min-h-14 items-start gap-3 rounded-md py-2 pe-8 ps-2 text-start`,children:[t(`span`,{className:H(`mt-0.5 shrink-0`,Xi(e.mode)),children:e.icon}),n(`span`,{className:`min-w-0 flex-1`,children:[t(`span`,{className:`block text-sm font-medium text-foreground`,children:e.label}),t(`span`,{className:`mt-0.5 block whitespace-normal text-sm leading-5 text-muted`,children:e.description})]})]},e.mode))})]})]})}function $(...e){return ur(Ge(e))}const $i=Ye(null);function ea({children:e}){let n=J(new Map),r=J(new Map),i=G(e=>n.current.get(e),[]),a=G((e,t)=>{n.current.set(e,t)},[]),o=G(async(e,t)=>{let i=n.current.get(e);if(i)return i;let a=r.current.get(e);if(a)return a;let o=t().then(t=>(n.current.set(e,t),r.current.delete(e),t)).catch(t=>{throw r.current.delete(e),t});return r.current.set(e,o),o},[]),s=W.useMemo(()=>({getUrl:i,setUrl:a,getOrFetch:o}),[i,a,o]);return t($i.Provider,{value:s,children:e})}function ta(){return Qe($i)}function na(e){return e.startsWith(`agents/`)||e.startsWith(`documents/`)}function ra(e,t,n=`inline`){return`artifact:${e}:${t}:${n}`}function ia(e){return`file:${e}`}function aa({error:e,chartTitle:r}){return t(`div`,{className:`flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4`,children:n(`div`,{className:`text-center`,children:[n(`p`,{className:`text-sm font-medium text-red-600 dark:text-red-400`,children:[`Cannot render `,r||`Vega-Lite`,` chart`]}),t(`p`,{className:`text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate`,children:e})]})})}function oa({isOpen:e,onClose:r,title:i,description:a,children:s}){let{t:c}=X();return t(or.Root,{open:e,onOpenChange:e=>!e&&r(),children:n(or.Portal,{children:[t(or.Overlay,{className:`fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),n(or.Content,{className:`fixed inset-2 sm:inset-4 z-50 flex flex-col bg-white dark:bg-gray-900 rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2`,onEscapeKeyDown:r,children:[t(or.Close,{asChild:!0,children:t(o,{variant:`unstyled`,onClick:r,className:`absolute top-3 end-3 z-10 p-2 rounded-lg bg-white/80 dark:bg-gray-800/80 backdrop-blur-sm hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150 shadow-sm`,"aria-label":c(`agent.closeFullscreen`),children:t(nr,{className:`w-5 h-5 text-gray-600 dark:text-gray-300`})})}),t(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150`,children:s}),t(`div`,{className:`flex items-center justify-between px-4 sm:px-6 py-3 border-t border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50 rounded-b-xl`,children:n(`div`,{className:`flex flex-col`,children:[t(or.Title,{className:`text-base font-semibold text-gray-900 dark:text-gray-100`,children:i||c(`agent.dashboard`)}),a&&t(or.Description,{className:`text-sm text-gray-500 dark:text-gray-400 mt-0.5`,children:a})]})})]})]})})}function sa(e,t){if(t===`chart`)return 280;let n=1;if(e.vconcat)n=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){let t=e.columns||2,r=Array.isArray(e.concat)?e.concat.length:1;n=Math.ceil(r/t)}else e.facet&&(n=2);return Math.max(500,n*280+40)}const ca={categorical:[`#6366f1`,`#8b5cf6`,`#ec4899`,`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#14b8a6`,`#06b6d4`,`#3b82f6`],blues:[`#dbeafe`,`#93c5fd`,`#3b82f6`,`#1d4ed8`,`#1e3a8a`],purples:[`#f3e8ff`,`#c4b5fd`,`#8b5cf6`,`#6d28d9`,`#4c1d95`],greens:[`#dcfce7`,`#86efac`,`#22c55e`,`#15803d`,`#14532d`],diverging:[`#ef4444`,`#fca5a5`,`#fef3c7`,`#86efac`,`#22c55e`]};function la(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ua(e){return la(e)}function da(e){let t=JSON.parse(JSON.stringify(e)),n=[`vconcat`,`hconcat`,`concat`];if(!n.some(e=>Array.isArray(t[e])))return t;let r=[];if(Array.isArray(t.params))for(let e of t.params)e&&typeof e==`object`&&e.name&&e.select&&r.push({name:e.name,param:e});if(r.length===0)return t;for(let{name:e,param:i}of r){let r=i.select?.fields||[],a=i.select?.bind===`legend`,o=null;for(let e of n)if(Array.isArray(t[e])){o=t[e];break}if(!o||o.length===0)continue;let s=0;for(let e=0;e<o.length;e++){let t=o[e];if(pa(t,r)||a&&ma(t,r)){s=e;break}}let c=o[s];c.params||=[],c.params.push(i),t.params=(t.params??[]).filter(t=>t.name!==e)}return Array.isArray(t.params)&&t.params.length===0&&delete t.params,t}function fa(e,t){if(!t||Object.keys(t).length===0)return e;let n=JSON.parse(JSON.stringify(e)),r=e=>{for(let n of e)n.name&&n.name in t&&(n.value=t[n.name])};Array.isArray(n.params)&&r(n.params);let i=e=>{if(Array.isArray(e)){for(let t of e)if(Array.isArray(t.params)&&r(t.params),t.vconcat&&i(t.vconcat),t.hconcat&&i(t.hconcat),t.concat&&i(t.concat),Array.isArray(t.layer))for(let e of t.layer)Array.isArray(e.params)&&r(e.params)}};if(n.vconcat&&i(n.vconcat),n.hconcat&&i(n.hconcat),n.concat&&i(n.concat),Array.isArray(n.layer))for(let e of n.layer)e&&Array.isArray(e.params)&&r(e.params);return n}function pa(e,t){if(!e?.encoding)return!1;for(let n of t)for(let t of Object.values(e.encoding))if(t.field===n)return!0;if(Array.isArray(e.layer)){for(let n of e.layer)if(pa(n,t))return!0}return!1}function ma(e,t){if(!e)return!1;let n=e=>{if(!e)return!1;let n=e.color?.field;return!!n&&t.includes(n)};if(n(e.encoding))return!0;if(Array.isArray(e.layer)){for(let t of e.layer)if(n(t.encoding))return!0}return!1}function ha(e,t=[]){let n=[];if(!e||typeof e!=`object`)return n;if(e.data&&typeof e.data==`object`){let r=e.data.url;typeof r==`string`&&r.startsWith(`artifact:`)&&n.push({path:[...t,`data`],artifactPath:r.replace(/^artifact:/,``).trim()})}for(let r of[`layer`,`vconcat`,`hconcat`,`concat`,`spec`,`repeat`,`facet`])if(r in e){let i=e[r];Array.isArray(i)?i.forEach((e,i)=>{ua(e)&&n.push(...ha(e,[...t,r,String(i)]))}):ua(i)&&n.push(...ha(i,[...t,r]))}return n}function ga(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of t){let t=e.split(`.`),i=n;for(let e=0;e<t.length-1;e++){let n=i[t[e]];if(!la(n))break;i=n}let a=t[t.length-1],o=i[a];la(o)&&(delete o.url,o.values=r)}return n}function _a(e){let t={background:`transparent`,view:{stroke:`transparent`},range:{category:ca.categorical,diverging:ca.diverging,heatmap:ca.purples,ramp:ca.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:`round`},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80}};return e?{...t,axis:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,gridColor:`#3f3f46`,domainColor:`#52525b`,tickColor:`#52525b`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#fafafa`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}:{...t,axis:{labelColor:`#71717a`,titleColor:`#3f3f46`,gridColor:`#e4e4e7`,domainColor:`#d4d4d8`,tickColor:`#d4d4d8`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#71717a`,titleColor:`#3f3f46`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#18181b`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}}const va=Ze(function({spec:r,artifactRunId:i}){let{t:a}=X(),{title:s,description:c,options:l}=r,u=r.spec,[d,f]=Y(!1),[p,m]=Y(!1),[h,g]=Y(null),[_,v]=Y(!1),y=J(null),b=J(null),x=J(null),{client:S}=Z(),C=ta(),w=J(S);w.current=S;let T=J(C);T.current=C;let[E,D]=Y(null),[O,k]=Y(!1),[A,j]=Y(null),M=l?.mode||`chart`,N=M===`dashboard`,P=l?.enableFullscreen??N,F=l?.height||sa(u,M);K(()=>{let e=ha(u);if(e.length===0){D(u),k(!1),j(null);return}i?console.info(`[VegaLiteChart] resolving artifacts with runId:`,i,e.map(e=>e.artifactPath)):console.warn(`[VegaLiteChart] artifact references found but artifactRunId is missing!`,{references:e.map(e=>e.artifactPath),artifactRunId:i});let t=!1;return k(!0),j(null),(async()=>{let n=new Map,r=w.current,a=T.current;for(let o of e)try{let e=o.path.join(`.`),t;if(i&&!na(o.artifactPath)){let e=ra(i,o.artifactPath,`inline`);t=a?await a.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(i,o.artifactPath,`inline`)).url):(await r.files.getArtifactDownloadUrl(i,o.artifactPath,`inline`)).url}else{let e=ia(o.artifactPath);t=a?await a.getOrFetch(e,async()=>(await r.files.getDownloadUrl(o.artifactPath)).url):(await r.files.getDownloadUrl(o.artifactPath)).url}let s=await fetch(t);if(!s.ok)throw Error(`Failed to fetch artifact data: ${s.statusText}`);let c=o.artifactPath.toLowerCase().endsWith(`.csv`),l;if(c){let e=await s.text();l=cr.parse(e,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{let e=await s.json();l=Array.isArray(e)?e:[e]}n.set(e,l)}catch(e){console.error(`Failed to resolve artifact: ${o.artifactPath}`,e),t||j(`Failed to load data from artifact: ${o.artifactPath}`);return}if(!t){let e=ga(u,n);D(e),k(!1)}})(),()=>{t=!0}},[u,i]);let[I,L]=Y(!1),R=J(!1);K(()=>{let e=()=>{let e=document.documentElement.classList.contains(`dark`);e!==R.current&&(R.current=e,L(e))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let[z,ee]=Y(0),B=J(0);K(()=>{if(!x.current)return;let e,t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{let e=t[0]?.contentRect.width;e&&e!==B.current&&(B.current=e,ee(e))},100)});t.observe(x.current);let n=x.current.clientWidth;return B.current=n,ee(n),()=>{clearTimeout(e),t.disconnect()}},[]);let te=q(()=>ha(u).length>0,[u]),ne=q(()=>{if(te&&!E)return null;let e=E||u;return e?(l?.parameterValues&&(e=fa(e,l.parameterValues)),da(e)):null},[E,u,te,l?.parameterValues]),re=G((e,t)=>{if(!e||typeof e!=`object`)return e;if(e.hconcat&&Array.isArray(e.hconcat)){let n=e.hconcat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,hconcat:e.hconcat.map(e=>re(e,i))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>re(e,t))};if(e.concat&&Array.isArray(e.concat)){let n=e.columns??e.concat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,concat:e.concat.map(e=>re(e,i))}}let n=e.width;return n===`container`||typeof n==`number`&&n>t?{...e,width:t}:e},[]),ie=G((e,t=!1)=>{if(!ne)return null;let n=_a(I),r=t?typeof window<`u`?Math.min(window.innerWidth-80,1400):1200:z>0?z-24:500,i=`vconcat`in ne||`hconcat`in ne||`concat`in ne,a=i?{type:`pad`,contains:`padding`}:{type:`fit`,contains:`padding`},o=ne;i&&r&&(o=re(ne,r));let c=o.width,l=i?void 0:c===`container`?r:c??r,{width:u,...d}=o;return{$schema:`https://vega.github.io/schema/vega-lite/v6.json`,...!i&&l?{width:l}:{},height:t?void 0:e,autosize:a,...i?o:d,...s&&!ne.title?{title:s}:{},config:{...n,...ne.config}}},[ne,s,I,z,re]),ae=G(async()=>{let e=_?b.current:y.current;if(!(!e||p))try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),m(!0),setTimeout(()=>m(!1),2e3))},`image/png`)}catch(e){console.error(`Failed to copy chart:`,e)}},[p,_]),oe=G(async()=>{let e=_?b.current:y.current;if(!(!e||d)){f(!0);try{let t=await e.toImageURL(`png`,2),n=document.createElement(`a`);n.download=`${s||`chart`}.png`,n.href=t,n.click()}catch(e){console.error(`Failed to export chart:`,e)}finally{f(!1)}}},[s,d,_]),se=G(e=>{y.current=e,g(null)},[]),ce=G(e=>{b.current=e},[]),le=G(e=>{console.error(`Vega-Lite rendering error:`,e),g(e instanceof Error?e.message:`Unknown error`)},[]),ue=G(()=>{v(e=>!e)},[]);K(()=>{g(null)},[u]);let de=({className:e})=>n(`div`,{className:$(`flex items-center gap-2`,e),children:[n(o,{variant:`unstyled`,onClick:ae,disabled:p,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1`,title:a(`agent.copyToClipboard`),children:[t(p?pt:Pt,{className:`w-3 h-3`}),a(p?`agent.copied`:`agent.copy`)]}),n(o,{variant:`unstyled`,onClick:oe,disabled:d,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1`,title:a(`agent.exportAsPng`),children:[t(Lt,{className:`w-3 h-3`}),a(d?`agent.exporting`:`agent.export`)]}),P&&n(o,{variant:`unstyled`,onClick:ue,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors flex items-center gap-1`,title:a(_?`agent.exitFullscreen`:`agent.fullscreen`),children:[t(_?bn:_n,{className:`w-3 h-3`}),a(_?`agent.exit`:`agent.fullscreen`)]})]});if(O||te&&!E)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{className:`flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded`,style:{width:`100%`,height:F},children:n(`div`,{className:`flex items-center gap-2 text-gray-500 dark:text-gray-400`,children:[t(mn,{className:`w-5 h-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading data from artifacts...`})]})})]})});if(A)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:F},children:t(aa,{error:A,chartTitle:s})})]})});if(h)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:F},children:t(aa,{error:h,chartTitle:s})})]})});let fe=ie(F),pe=ie(0,!0);return fe?(typeof window<`u`&&localStorage.getItem(`DEBUG_VEGA_RENDERS`)&&console.log(`VegaLite rendering with spec:`,{title:s,hasData:!!fe.data?.values,dataLength:fe.data?.values?.length}),n(e,{children:[t(`div`,{className:$(`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,N&&`border-2`),children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[n(`div`,{className:`flex items-center justify-between`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||(N?`Dashboard`:`Chart`)}),N&&t(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-indigo-100 dark:bg-indigo-900 text-indigo-700 dark:text-indigo-300`,children:`Interactive`})]}),t(de,{})]}),c&&t(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c}),t(`div`,{ref:x,className:`bg-white dark:bg-gray-900 rounded overflow-hidden`,style:{width:`100%`,height:F,minWidth:0},children:t(lr,{spec:fe,onEmbed:e=>se(e.view),onError:le,options:{renderer:l?.renderer||`canvas`,actions:!1}})})]})}),n(oa,{isOpen:_,onClose:()=>v(!1),title:s||(N?`Dashboard`:`Chart`),description:c,children:[t(`div`,{className:`w-full h-full min-h-[calc(100vh-200px)]`,children:pe&&t(lr,{spec:pe,onEmbed:e=>ce(e.view),onError:le,options:{renderer:l?.renderer||`canvas`,actions:!1}})}),t(`div`,{className:`absolute bottom-6 end-6`,children:t(de,{className:`bg-white dark:bg-gray-800 rounded-lg shadow-lg p-2 border border-gray-200 dark:border-gray-700`})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function ya(e){return e.library===`vega-lite`&&typeof e.spec==`object`}function ba(e){return e.library===`recharts`||e.library===void 0}function xa(e){return typeof e.$schema==`string`&&e.$schema.includes(`vega`)}const Sa=Ze(function({spec:e,artifactRunId:r}){return ya(e)?t(va,{spec:e,artifactRunId:r}):xa(e)?t(va,{spec:{library:`vega-lite`,spec:e},artifactRunId:r}):n(`div`,{className:`my-5 rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200`,children:[`Recharts chart rendering has been retired. Use a Vega-Lite chart spec (`,t(`code`,{children:`library: "vega-lite"`}),` with `,t(`code`,{children:`spec`}),`).`]})},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function Ca(e,t){return e===`live`?e:t===0?`live`:Math.min(Math.max(e,0),t-1)}function wa(e,t){return t===0?-1:e===`live`?t-1:Math.min(Math.max(e,0),t-1)}function Ta(e,t){if(e.length===0)return null;let n=t===`live`?e.length:wa(t,e.length);for(let t=Math.min(n-1,e.length-1);t>=0;t--)if(e[t].type===Q.QUESTION)return t;return null}function Ea(e,t){if(e.length===0||t===`live`)return null;let n=wa(t,e.length);for(let t=n+1;t<e.length;t++)if(e[t].type===Q.QUESTION)return t;return`live`}function Da(e,t,n){let r=n?Ca(t,e.length):`live`,i=wa(r,e.length),a=!n||r===`live`,o=a?e:e.slice(0,i+1);return{cursor:r,cursorIndex:i,isLive:a,renderedMessageCount:o.length,displayedMessages:o}}function Oa(e){let t=e.indexOf(`?`);return t===-1?new URLSearchParams:new URLSearchParams(e.slice(t+1))}function ka(){return!(typeof window>`u`)}function Aa(){if(!ka())return!1;let e=new URLSearchParams(window.location.search),t=Oa(window.location.hash),n=e.get(`agentChatPlayback`)??t.get(`agentChatPlayback`);return n===`1`||n===`true`}const ja=ka,Ma=Aa;function Na({cursor:e,messages:r,onChangeCursor:i,className:a}){let{t:s}=X(),c=r.length,l=e===`live`,u=wa(e,c),d=c>0&&(l||u>0),f=!l&&c>0,p=c>0&&(l||u>0),m=!l&&c>0&&u<c-1,h=c===0?0:u+1,[g,_]=Y(String(h));K(()=>{_(String(h))},[h]);let v=()=>{if(c!==0){if(e===`live`){i(c-1);return}i(Math.max(0,u-1))}},y=()=>{if(!(c===0||e===`live`)){if(u>=c-1){i(`live`);return}i(u+1)}},b=()=>{c!==0&&i(0)},x=()=>{c!==0&&i(c-1)},S=()=>{_(String(h))},C=(e,t=!1)=>{if(c===0){_(`0`);return}let n=Number.parseInt(e,10);if(!Number.isFinite(n)){t&&S();return}let r=Math.min(Math.max(n,1),c);_(String(r)),i(r-1)},w=e=>{c!==0&&C(e)},T=c>1,E=+!!T,D=Math.max(1,c),O=`size-7 rounded-lg text-muted hover:text-foreground disabled:opacity-35`,k=`${Math.max(3,String(c).length+1)}ch`;return n(`div`,{className:H(`inline-flex max-w-full flex-col gap-1 rounded-xl border border-border/70 bg-background/95 px-2 py-1 text-sm leading-none text-muted shadow-lg shadow-black/10 backdrop-blur`,a),"data-testid":`agent-test-playback-controls`,"data-playback-cursor":e,"data-live-message-count":c,"data-rendered-message-count":l?c:u+1,children:[n(`div`,{className:`flex max-w-full items-center gap-1`,children:[t(`span`,{className:`ms-2 me-1 font-medium leading-none text-foreground/80`,children:s(`agent.rewind.label`)}),t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`agent.rewind.jumpToStart`),title:s(`agent.rewind.jumpToStart`),disabled:!p,onClick:b,className:O,children:t(Tt,{className:`size-4`})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`agent.rewind.previousMessage`),title:s(`agent.rewind.previousMessage`),disabled:!d,onClick:v,className:O,children:t(xt,{className:`size-4`})}),n(`span`,{className:`inline-flex min-w-16 items-center justify-center gap-0.5 px-1 font-medium leading-none tabular-nums text-foreground/80`,"data-testid":`agent-test-playback-position`,children:[t(F,{type:`text`,variant:`unstyled`,size:`sm`,clearable:!1,inputMode:`numeric`,pattern:`[0-9]*`,value:g,"aria-label":s(`agent.rewind.positionInput`),disabled:c===0,onChange:e=>{let t=e.replace(/\D/g,``);_(t)},onBlur:e=>C(e.currentTarget.value,!0),onKeyDown:e=>{e.key===`Enter`&&(C(e.currentTarget.value,!0),e.currentTarget.blur())},style:{width:k},className:`h-7 w-auto rounded-md border border-transparent bg-transparent px-1 text-center text-sm font-medium leading-none tabular-nums text-foreground outline-none transition-colors hover:border-border focus:border-ring focus:bg-muted/30 disabled:opacity-50`}),t(`span`,{"aria-hidden":`true`,className:`text-muted`,children:`/`}),t(`span`,{className:`text-muted`,children:c})]}),t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`agent.rewind.nextMessage`),title:s(`agent.rewind.nextMessage`),disabled:!f,onClick:y,className:O,children:t(St,{className:`size-4`})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`agent.rewind.jumpToLatest`),title:s(`agent.rewind.jumpToLatest`),disabled:!m,onClick:x,className:O,children:t(Et,{className:`size-4`})}),t(o,{type:`button`,variant:l?`secondary`:`ghost`,size:`icon`,"aria-label":s(`agent.rewind.jumpToLive`),title:s(`agent.rewind.jumpToLive`),disabled:l,onClick:()=>i(`live`),className:H(O,l&&`bg-muted text-foreground`),children:t(Mn,{className:`size-4`})})]}),t(`div`,{className:`px-2 pb-1`,children:t(ye,{min:E,max:D,step:1,value:[h],"aria-label":s(`agent.rewind.positionInput`),disabled:!T,onValueChange:([e])=>w(String(e)),className:`h-2`})})]})}Ye(void 0);var Pa=class{filter(e,t){let n=t.toLowerCase();return e.filter(e=>this.valueOf(e).toLowerCase().includes(n))}renderOption(e){return this.valueOf(e)}findById(e,t){return e.find(e=>this.idOf(e)===t)}createItem(e){return null}},Fa=class e extends Pa{valueOf(e){return String(e)}idOf(e){return String(e)}static instance=new e};(class e extends Fa{createItem(e){return e}static instance=new e});const Ia=W.createContext(void 0);function La(){return W.useContext(Ia)}const Ra=Pr.Provider,za=Pr.Root,Ba=Pr.Trigger,Va=U.forwardRef(({className:e,sideOffset:n=4,side:r=`top`,...i},a)=>{let o=La();return t(Pr.Portal,{container:o,children:t(Pr.Content,{ref:a,sideOffset:n,side:r,style:{zIndex:100},className:$(`max-w-[90vw]`,`z-50 overflow-hidden rounded-md bg-tooltips border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...i})})});Va.displayName=Pr.Content.displayName;function Ha({description:e,children:r,size:i=`sm`,placement:a=`top`,className:o,asChild:s}){let[c,l]=U.useState(!1),u=U.useRef(!1);return U.useEffect(()=>{let e=()=>{l(!1),u.current=!0,requestAnimationFrame(()=>{u.current=!1})};return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e)}},[]),t(Ra,{delayDuration:0,children:n(za,{open:c,onOpenChange:e=>{u.current||l(e)},children:[t(Ba,{className:`cursor-pointer`,asChild:s,children:r}),t(Va,{side:a,className:`px-3 py-1.5 max-w-${i} text-${i} px-3 ${o}`,children:e})]})})}const Ua=new Set;function Wa(e,t,n){K(()=>{t&&!Ua.has(e)&&(Ua.add(e),console.warn(`[@vertesia/ui] ${e} is deprecated: ${n}`))},[t,n,e])}const Ga=Nr(`hover:cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{destructive:`bg-destructive dark:bg-destructive/10 text-destructive ring-1 ring-inset ring-destructive-muted/50 dark:ring-destructive-muted/50 shadow-xs hover:bg-destructive/50`,outline:`border border-input bg-background shadow-xs hover:bg-muted ring-inset`,secondary:`bg-primary/5 dark:bg-primary/10 text-primary shadow-xs hover:bg-primary/10 dark:hover:bg-primary/20 ring-inset`,ghost:`hover:bg-muted/50 dark:hover:bg-muted/20 ring-inset`,link:`text-foreground underline-offset-4 hover:underline ring-inset`,primary:`bg-primary text-white shadow-xs hover:bg-primary/90 ring-inset`,unstyled:``},size:{xs:`h-7 rounded px-2 py-1 text-xs gap-x-1`,sm:`h-8 rounded px-3 text-xs`,md:`h-9 rounded-md px-4 py-2`,lg:`h-10 rounded-md px-3`,xl:`rounded-md px-3.5 py-2.5 text-sm gap-x-2`,icon:`p-0 m-0 rounded-full`,none:``}},defaultVariants:{variant:`primary`,size:`md`}}),Ka=U.forwardRef(({className:r,variant:i,size:a,asChild:o=!1,alt:s,isDisabled:c,isLoading:l,title:u,onClick:d,type:f,...p},m)=>{Wa(`Button.alt`,s!==void 0,"use aria-label for the accessible name and wrap in <VTooltip> for a visual tooltip. `alt` is forwarded to both for one release.");let h=o?Mr:`button`,g=o?f:f??`button`,_=p[`aria-label`]??s,v=o?p.children:n(e,{children:[l&&t(mn,{className:`animate-spin`}),p.children]}),y=t(h,{className:We($(Ga({variant:i,size:a})),r),disabled:c||l||p.disabled,ref:m,onClick:d,type:g,autoFocus:!1,...p,"aria-label":_,children:v});return s||u?t(Ha,{description:s||u,asChild:!0,className:`cursor-pointer`,size:`xs`,placement:`top`,children:y}):y});Ka.displayName=`Button`;const qa=U.forwardRef(({size:e,content:n,toast:r,className:i,alt:a,"aria-label":o,...s},c)=>{let[l,u]=Y(!1),{t:d}=X();Wa(`CopyButton.alt`,a!==void 0,"use aria-label for the accessible name. `alt` is forwarded for one release.");let f=e=>{e.stopPropagation(),navigator.clipboard.writeText(n).then(()=>{u(!0),setTimeout(()=>u(!1),2e3),r?.toast&&r.toast({status:`success`,title:r.message||d(`misc.copiedToClipboard`),duration:2e3})}).catch(e=>{console.error(`Failed to copy text: `,e),r?.toast&&r.toast({status:`error`,title:d(`misc.failedToCopy`),duration:2e3})})},p=o??a??d(`misc.copy`);return t(Ka,{ref:c,className:$(i),variant:`unstyled`,size:e||`sm`,onClick:f,...s,"aria-label":p,title:p,children:l?t(pt,{className:`text-success`}):t(Ft,{className:`size-4`})})});qa.displayName=`CopyButton`;function Ja(e){return t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e(t))}}const Ya=Nr(`inline-flex items-center rounded-md px-2 py-1 text-xs font-medium`,{variants:{variant:{default:`text-foreground bg-muted`,secondary:`bg-secondary text-primary`,destructive:`bg-destructive text-destructive`,attention:`bg-attention text-attention`,success:`bg-success text-success`,info:`bg-info text-info`,done:`bg-done text-done`,outline:`bg-transparent border border-border text-foreground`}},defaultVariants:{variant:`default`}});function Xa({className:e,variant:n,children:r,onClick:i,...a}){let o=i?{role:`button`,tabIndex:0,onClick:i,onKeyDown:Ja(i)}:{};return t(`span`,{className:$(Ya({variant:n}),e),...o,...a,children:r})}Nr(`inline-flex items-center gap-x-1.5 rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ring-border`,{variants:{variant:{default:``,success:``,destructive:``,attention:``,done:``,info:``,outline:``}},defaultVariants:{variant:`default`}}),Nr(`h-1.5 w-1.5`,{variants:{variant:{default:`fill-foreground`,success:`fill-success`,destructive:`fill-destructive`,attention:`fill-attention`,done:`fill-done`,info:`fill-info`,outline:`fill-foreground`}},defaultVariants:{variant:`default`}});function Za({className:e,children:n}){return t(`ul`,{className:`${e} space-y-1 flex flex-col items-start`,children:n})}Za.Item=Xe(function(e,n){let{current:r,children:i,className:a,href:o=`#`,onClick:s,...c}=e;return t(`li`,{className:We(a,r?`bg-muted`:``,`w-full p-2 ps-3 text-sm leading-6 font-semibold hover:bg-muted`),children:t(`a`,{ref:n,href:o,onClick:e=>{s?(e.preventDefault(),s(e)):o===`#`&&e.preventDefault()},className:`w-full flex items-center gap-x-3`,...c,children:i})})});const Qa=`rounded-md text-sm flex w-full rounded-md border border-input bg-background ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 ring-inset focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,$a={INPUT_UNSTYLED:`block m-0 p-0 w-full border-0 focus:outline-hidden focus:ring-0 bg-transparent`,INPUT_NO_PADDING:Qa,INPUT:`${Qa} py-1.5`};function eo(e){return e==null||Number.isNaN(e)?``:e.toString()}W.forwardRef(({value:e,onChange:n,className:r,noScroll:i=!1,noSpinners:a=!1,...o},s)=>{let[c,l]=W.useState(eo(e));return K(()=>{if(e==null||!Number.isNaN(e)){let t=eo(e);l(t)}},[e]),t(`input`,{onWheel:i?e=>{e.currentTarget.blur()}:o.onWheel,type:`number`,value:c,onChange:e=>{let t=e.target.value;l(t),t===``?n?.(void 0,t):n?.(parseFloat(t),t)},className:We(r,$a.INPUT,{"no-spinners":a},a&&`[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`),ref:s,...o})});const to=U.forwardRef(({...e},n)=>t(`nav`,{ref:n,"aria-label":`breadcrumb`,...e}));to.displayName=`Breadcrumb`;const no=U.forwardRef(({className:e,...n},r)=>t(`ol`,{ref:r,className:$(`flex flex-wrap items-center gap-1.5 break-words text-sm text-muted sm:gap-2.5`,e),...n}));no.displayName=`BreadcrumbList`;const ro=U.forwardRef(({className:e,...n},r)=>t(`li`,{ref:r,className:$(`inline-flex items-center gap-1.5 text-muted`,e),...n}));ro.displayName=`BreadcrumbItem`;const io=U.forwardRef(({asChild:e,className:n,...r},i)=>t(`a`,{ref:i,className:$(`transition-colors hover:text-muted`,n),...r}));io.displayName=`BreadcrumbLink`;const ao=U.forwardRef(({className:e,href:n,onClick:r,...i},a)=>t(Ka,{variant:`ghost`,size:`md`,ref:a,className:$(`p-0! hover:underline! hover:bg-background!`,e),onClick:e=>{e.preventDefault(),r&&r(e)},...i}));ao.displayName=`BreadcrumbButton`;const oo=U.forwardRef(({className:e,...n},r)=>t(`span`,{ref:r,"aria-current":`page`,className:$(`font-normal text-foreground`,e),...n}));oo.displayName=`BreadcrumbPage`;const so=({children:e,className:n,...r})=>t(`li`,{role:`presentation`,"aria-hidden":`true`,className:$(`[&>svg]:w-3.5 [&>svg]:h-3.5`,n),...r,children:e??t(St,{className:`cn-rtl-flip`})});so.displayName=`BreadcrumbSeparator`;const co=({className:e,...r})=>n(`span`,{role:`presentation`,"aria-hidden":`true`,className:$(`flex h-9 w-9 items-center justify-center`,e),...r,children:[t(Cn,{className:`h-4 w-4`}),t(`span`,{className:`sr-only`,children:`More`})]});co.displayName=`BreadcrumbEllipsis`;const lo=U.forwardRef(({className:e,...n},r)=>t(`div`,{ref:r,className:$(`rounded-xl border bg-card text-card-foreground shadow`,e),...n}));lo.displayName=`Card`;const uo=U.forwardRef(({className:e,...n},r)=>t(`div`,{ref:r,className:$(`flex flex-col p-6`,e),...n}));uo.displayName=`CardHeader`;const fo=U.forwardRef(({className:e,...n},r)=>t(`div`,{ref:r,className:$(`font-semibold leading-none tracking-tight`,e),...n}));fo.displayName=`CardTitle`;const po=U.forwardRef(({className:e,...n},r)=>t(`div`,{ref:r,className:$(`text-sm text-muted-foreground`,e),...n}));po.displayName=`CardDescription`;const mo=U.forwardRef(({className:e,...n},r)=>t(`div`,{ref:r,className:$(`p-6 pt-0`,e),...n}));mo.displayName=`CardContent`;const ho=U.forwardRef(({className:e,...n},r)=>t(`div`,{ref:r,className:$(`flex items-center p-6 pt-0`,e),...n}));ho.displayName=`CardFooter`;const go=U.forwardRef(({className:e,...n},r)=>t(Fr.Root,{ref:r,className:$(`peer size-4 shrink-0 rounded-sm border border-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-white`,e),...n,children:t(Fr.Indicator,{className:$(`flex items-center justify-center text-current`),children:t(pt,{className:`size-4`})})}));go.displayName=Fr.Root.displayName;function _o({children:e}){return t(`span`,{style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`},children:e})}const vo=Ye(!1);function yo({children:e}){return t(vo.Provider,{value:!0,children:e})}function bo({className:e,children:r,isOpen:i,onClose:a,description:o=`Modal Description`,noCloseButton:s=!1,allowOverflow:c=!1,disableCloseOnClickOutside:l=!1,size:u=`md`,action:d}){let f=e=>{e||a()};function p(){switch(u){case`sm`:return`max-w-[20vw]`;case`md`:return`max-w-[60vw] lg:max-w-[40vw]`;case`lg`:return`max-w-[80vw] md:max-w-[60vw]`;case`xl`:return`max-w-[95vw] lg:max-w-[80vw]`;default:return`max-w-[60vw] lg:max-w-[40vw]`}}return n(Co,{open:i,onOpenChange:e=>{(!l||e)&&f(e)},children:[c&&t(Eo,{className:`z-50 fixed inset-0 bg-black/80`}),t(_o,{children:t(Oo,{children:o})}),n(Do,{className:$(`min-h-20 p-4`,`fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 sm:rounded-lg`,p(),e),children:[t(`div`,{className:`top-4 end-4 absolute`,children:n(`div`,{className:`flex gap-2`,children:[d&&d,!s&&t(To,{onClick:()=>f(!1),asChild:!0,autoFocus:!1,children:t(Ka,{variant:`outline`,alt:`Close`,className:`data-[state=open]:bg-accent opacity-70 hover:opacity-100 rounded-sm focus:outline-none focus:ring-2 focus:ring-ring ring-offset-background focus:ring-offset-2 data-[state=open]:text-muted-foreground transition-opacity disabled:pointer-events-none`,children:t(nr,{className:`size-4`})})})]})}),t(yo,{children:r})]})]})}const xo=({children:e,show:r=!0,className:i,description:a,showDivider:o=!1,...s})=>r?n(ko,{className:$(o?`border-b-solid border-b border-b-1 pb-2 mb-4`:``,`text-lg font-semibold leading-6 tracking-tight`,{"py-2":!a},i),...s,children:[e,a&&t(Oo,{className:`text-sm !font-normal text-muted-foreground pb-2`,children:a})]}):n(_o,{children:[t(ko,{children:e}),a&&t(Oo,{children:a})]}),So=({children:e,className:n,...r})=>t(`div`,{className:$(`text-sm max-h-[80vh] overflow-y-auto`,n),...r,children:e}),Co=or.Root,wo=or.Portal,To=or.Close,Eo=U.forwardRef(({className:e,...n},r)=>t(or.Overlay,{ref:r,className:$(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...n}));Eo.displayName=or.Overlay.displayName;const Do=U.forwardRef(({className:e,children:r,...i},a)=>{let o=La();return n(wo,{container:o,children:[t(Eo,{}),t(or.Content,{ref:a,autoFocus:!1,onOpenAutoFocus:e=>{e.preventDefault()},className:$(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...i,children:r})]})});Do.displayName=or.Content.displayName;const Oo=U.forwardRef(({className:e,...n},r)=>t(or.Description,{ref:r,className:$(`text-sm text-muted`,e),...n}));Oo.displayName=or.Description.displayName;const ko=U.forwardRef(({className:e,...n},r)=>t(or.Title,{ref:r,className:$(`text-lg font-semibold leading-none tracking-tight`,e),...n}));ko.displayName=or.Title.displayName;const Ao=U.forwardRef(({className:e,...n},r)=>t(Ir,{ref:r,className:$(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...n}));Ao.displayName=Ir.displayName;const jo=U.forwardRef(({className:e,...r},i)=>n(`div`,{className:`flex items-center px-3 border-b`,"cmdk-input-wrapper":``,children:[t(zn,{className:`opacity-50 size-4 shrink-0`}),t(Ir.Input,{ref:i,className:$(`focus:ring-0`,`border-0 flex h-8 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...r})]}));jo.displayName=Ir.Input.displayName;const Mo=U.forwardRef(({className:e,...n},r)=>t(Ir.List,{ref:r,className:$(`overflow-y-auto overflow-x-hidden`,e),...n}));Mo.displayName=Ir.List.displayName;const No=U.forwardRef((e,n)=>t(Ir.Empty,{ref:n,className:`py-2 text-sm text-center`,...e}));No.displayName=Ir.Empty.displayName;const Po=U.forwardRef(({className:e,...n},r)=>t(Ir.Group,{ref:r,className:$(`overflow-y-auto overflow-x-hidden p-1 text-foreground`,`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...n}));Po.displayName=Ir.Group.displayName;const Fo=U.forwardRef(({className:e,...n},r)=>t(Ir.Separator,{ref:r,className:$(`-mx-1 h-px bg-border`,e),...n}));Fo.displayName=Ir.Separator.displayName;const Io=U.forwardRef(({className:e,...n},r)=>t(Ir.Item,{ref:r,className:$(`hover:bg-muted cursor-pointer relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,e),...n}));Io.displayName=Ir.Item.displayName;const Lo=({className:e,...n})=>t(`span`,{className:$(`ms-auto text-xs tracking-widest text-muted-foreground`,e),...n});Lo.displayName=`CommandShortcut`;const Ro=U.createContext(!1);function zo({...e}){return t(Lr.Root,{"data-slot":`dropdown-menu`,...e})}function Bo({...e}){return t(Lr.Trigger,{"data-slot":`dropdown-menu-trigger`,...e})}function Vo({className:e,align:n=`start`,sideOffset:r=4,...i}){return t(Lr.Portal,{children:t(Lr.Content,{"data-slot":`dropdown-menu-content`,sideOffset:r,align:n,className:$(`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto data-[state=closed]:overflow-hidden`,e),...i})})}function Ho({className:e,inset:n,variant:r=`default`,...i}){return t(Lr.Item,{"data-slot":`dropdown-menu-item`,"data-inset":n,"data-variant":r,className:$(`hover:bg-muted focus:bg-muted data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive gap-2 rounded-md px-1.5 py-1 text-sm data-inset:ps-7 [&_svg:not([class*='size-'])]:size-4 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),...i})}const Uo={left:`start`,center:`center`,right:`end`};function Wo({trigger:e,children:r,align:i=`right`,hover:a}){let[o,s]=U.useState(!1),c=U.useRef(null);return a?n(`div`,{className:`relative inline-flex`,onMouseEnter:()=>{c.current&&clearTimeout(c.current),s(!0)},onMouseLeave:()=>{c.current=setTimeout(()=>s(!1),80)},children:[e,o&&t(`div`,{className:$(`absolute top-full pt-1 z-50`,i===`right`?`end-0`:i===`center`?`left-1/2 -translate-x-1/2`:`start-0`),children:t(`div`,{className:`min-w-32 rounded-lg p-1 shadow-md ring-1 ring-foreground/10 bg-popover text-popover-foreground`,children:t(Ro.Provider,{value:!0,children:r})})})]}):n(zo,{children:[t(Bo,{asChild:!0,children:t(`span`,{className:`-m-1.5 flex items-center p-1.5`,children:e})}),t(Vo,{align:Uo[i],className:`w-max`,children:r})]})}function Go({children:e,href:n,onClick:r,isDisabled:i=!1,variant:a=`default`,className:o}){let s=U.useContext(Ro),c=$(`w-full gap-2 rounded-md px-1.5 py-1 text-sm text-nowrap [&_svg:not([class*='size-'])]:size-4 flex cursor-default items-center select-none [&_svg]:pointer-events-none [&_svg]:shrink-0`,a===`destructive`?`text-destructive`:``,i?`pointer-events-none opacity-50`:`hover:bg-muted focus:bg-muted`,o);return s?n?t(`a`,{href:n,className:c,children:e}):t(`button`,{type:`button`,className:c,disabled:i,onClick:e=>{e.stopPropagation(),r?.(e)},children:e}):t(Ho,{className:$(`data-[disabled]:pointer-events-none data-[disabled]:opacity-50 text-nowrap`,o),disabled:i,variant:a,onClick:e=>{e.stopPropagation(),r?.(e)},asChild:!!n,children:n?t(`a`,{href:n,children:e}):e})}const Ko=U.createContext(null);function qo(e=!1,t=()=>{},n){e&&t(n===`enter`)}const Jo=U.forwardRef(({children:e,...n},r)=>{let i=U.useContext(Ko);if(!i)throw Error(`PopoverTrigger must be used within a Popover`);let{setOpen:a,hover:o,click:s}=i;return t(zr.Trigger,{ref:r,asChild:!0,onMouseEnter:()=>qo(o,a,`enter`),onMouseLeave:()=>qo(o,a,`leave`),onClick:()=>{s&&a(e=>!e)},...n,children:e})});Jo.displayName=zr.Trigger.displayName;const Yo=U.forwardRef(({className:e,align:n=`center`,side:r=`bottom`,...i},a)=>{let o=U.useContext(Ko);if(!o)throw Error(`PopoverContent must be used within a Popover`);let{setOpen:s,hover:c}=o,l=La();return t(zr.Portal,{container:l,children:t(zr.Content,{ref:a,align:n,side:r,onMouseEnter:()=>qo(c,s,`enter`),onMouseLeave:()=>qo(c,s,`leave`),className:$(`z-50 w-72 rounded-md border-popover bg-popover text-popover-foreground ring-1 ring-gray-200 dark:ring-slate-700 shadow-md focus:outline-none animate-in`,`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...i})})});Yo.displayName=zr.Content.displayName;const Xo=zr.Close;Xo.displayName=zr.Close.displayName;const Zo=Nr(``,{variants:{size:{xs:`rounded py-1 text-xs rounded-xs`,sm:`rounded text-xs rounded-sm`,md:`rounded-md py-2 text-sm`,lg:`rounded-md text-base`,xl:`rounded-md py-2.5 text-lg`},variant:{default:`flex w-full rounded-md border border-input bg-background ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 ring-inset focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,unstyled:`block m-0 p-0 w-full border-0 focus:outline-hidden focus:ring-0 bg-transparent`,noPadding:`block rounded-md border-0 bg-background shadow-2xs ring-1 ring-inset ring-ring placeholder:text-muted-foreground focus:ring-2 focus:ring-inset focus:ring-ring ring-offset-background`,legacy:`py-1.5 block rounded-md border-0 bg-background shadow-2xs ring-1 ring-inset ring-ring placeholder:text-muted-foreground focus:ring-2 focus:ring-inset focus:ring-ring ring-offset-background`}},defaultVariants:{size:`md`,variant:`default`}}),Qo=U.forwardRef(({className:e,type:r,size:i=`md`,variant:a=`default`,clearable:o=!0,onChange:s,value:c,invalid:l,...u},d)=>{let f=()=>{s?.(``)},p=e=>{s?.(e.target.value)},m=u[`aria-invalid`]??(l?!0:void 0);return n(`div`,{className:`w-full relative inline-block [&:hover_.clear-button]:opacity-100`,children:[t(`input`,{type:r,className:$(Zo({size:i,variant:a}),e,o&&c?`pe-8`:``),ref:d,value:c??``,onChange:p,...u,"aria-invalid":m}),o&&c&&!u.readOnly&&!u.disabled&&t(Ka,{variant:`link`,size:`icon`,type:`button`,onClick:f,className:`clear-button opacity-0 transition-opacity duration-200
|
|
1
|
+
import{Fragment as e,jsx as t,jsxs as n}from"react/jsx-runtime";import{Avatar as r,Badge as i,Breadcrumbs as a,Button as o,Card as s,CardContent as c,CardDescription as l,CardFooter as u,CardHeader as d,CardTitle as f,Center as p,Checkbox as m,Command as h,CommandEmpty as g,CommandGroup as _,CommandInput as v,CommandItem as y,ConfirmModal as b,CopyButton as x,DialogDescription as S,Divider as C,Dropdown as w,DropdownMenu as T,DropdownMenuContent as E,DropdownMenuItem as D,DropdownMenuRadioGroup as O,DropdownMenuRadioItem as k,DropdownMenuTrigger as A,EmptyCollection as j,ErrorBox as M,FilterBar as N,FilterBtn as P,FilterClear as F,FilterProvider as I,FormItem as L,Heading as R,Input as ee,InputList as te,Label as z,MenuGroup as ne,MenuItem as B,MessageBox as re,Modal as ie,ModalBody as ae,ModalFooter as oe,ModalTitle as se,NumberInput as ce,Panel as le,Popover as ue,PopoverContent as de,PopoverTrigger as fe,Portal as pe,RadioGroup as me,RadioGroupAdapter as he,ResizableHandle as ge,ResizablePanel as _e,ResizablePanelGroup as ve,SelectBox as ye,SelectList as be,Separator as xe,SharedState as Se,SidePanel as Ce,Slider as we,SortableTableHeaderCell as Te,Spinner as Ee,Styles as De,Switch as Oe,TBody as ke,THead as Ae,TR as je,Table as Me,TableHeaderCell as Ne,Tabs as Pe,TabsBar as Fe,TabsPanel as Ie,TagsInput as Le,Textarea as Re,VTooltip as ze,cn as V,errorMessage as H,insertNewlineAtCursor as Be,onActivateKey as Ve,useDebounce as He,useFetch as Ue,useFetchOnce as We,useFlag as Ge,useIntersectionObserver as Ke,useIsInModal as qe,useTheme as Je,useToast as Ye,useWatchSharedState as Xe}from"@vertesia/ui/core";import Ze,{clsx as Qe}from"clsx";import{AnimatePresence as $e,motion as et}from"motion/react";import*as U from"react";import W,{Component as tt,createContext as nt,forwardRef as rt,memo as it,useCallback as G,useContext as at,useEffect as K,useId as ot,useLayoutEffect as st,useMemo as q,useRef as J,useState as Y,useSyncExternalStore as ct}from"react";import{NAMESPACE as lt,i18nInstance as ut,useLocaleFormat as dt,useUITranslation as X}from"@vertesia/ui/i18n";import{Activity as ft,AlertCircle as pt,AlertCircleIcon as mt,AlertTriangle as ht,ArrowLeft as gt,ArrowUpIcon as _t,BarChart3 as vt,Bot as yt,Braces as bt,Brain as xt,Check as St,CheckCheck as Ct,CheckCircle as wt,CheckCircle2 as Tt,CheckCircleIcon as Et,CheckIcon as Dt,ChevronDown as Ot,ChevronDownIcon as kt,ChevronLeft as At,ChevronRight as jt,ChevronRightIcon as Mt,ChevronUp as Nt,ChevronsDown as Pt,ChevronsLeft as Ft,ChevronsRight as It,ChevronsUp as Lt,ChevronsUpDown as Rt,Circle as zt,ClipboardCopyIcon as Bt,ClipboardList as Vt,Clock as Ht,Code as Ut,Copy as Wt,CopyIcon as Gt,Cpu as Kt,Download as qt,DownloadCloudIcon as Jt,DownloadIcon as Yt,EllipsisVertical as Xt,ExternalLink as Zt,ExternalLinkIcon as Qt,Eye as $t,EyeIcon as en,FileDown as tn,FileIcon as nn,FileJson2 as rn,FileSearch as an,FileText as on,FileTextIcon as sn,Filter as cn,FolderClosed as ln,FolderIcon as un,FolderOpenIcon as dn,GitBranch as fn,GitFork as pn,Grid3X3 as mn,HandIcon as hn,HelpCircle as gn,Image as _n,ImageIcon as vn,Info as yn,InfoIcon as bn,Layers as xn,LayoutGrid as Sn,LayoutListIcon as Cn,Link as wn,Link2 as Tn,Link2Off as En,Loader2 as Dn,Loader2Icon as On,Maximize as kn,Maximize2 as An,MessageSquare as jn,MessageSquareText as Mn,Minimize2 as Nn,Minus as Pn,MonitorIcon as Fn,MoreHorizontal as In,MoreVertical as Ln,PackageIcon as Rn,PaperclipIcon as zn,Pause as Bn,Pencil as Vn,Play as Hn,Plus as Un,PlusIcon as Wn,Radio as Gn,RefreshCcw as Kn,RefreshCw as qn,RefreshCwIcon as Jn,Rewind as Yn,RotateCcw as Xn,Rows3 as Zn,Save as Qn,ScanSearch as $n,Search as er,Send as tr,Settings as nr,ShieldAlertIcon as rr,ShieldCheckIcon as ir,Sparkles as ar,SquareIcon as or,SquarePen as sr,Table as cr,TableProperties as lr,Terminal as ur,Trash2 as dr,Unlink2 as fr,UploadIcon as pr,User as mr,Users as hr,Users2 as gr,WandSparkles as _r,Wrench as vr,X as yr,XCircle as br,XCircleIcon as xr,XIcon as Sr}from"lucide-react";import*as Cr from"@radix-ui/react-dialog";import{UserSessionContext as wr,useUserSession as Z}from"@vertesia/ui/session";import Tr from"papaparse";import{VegaEmbed as Er}from"react-vega";import{twMerge as Dr}from"tailwind-merge";import{AUDIO_RENDITION_NAME as Or,AgentMessageType as Q,AgentSearchScope as kr,ContentNature as Ar,ContentObjectStatus as jr,ContentTypeIntakePolicySchema as Mr,FileProcessingStatus as Nr,ImageRenditionFormat as Pr,InteractionStatus as Fr,MarkdownRenditionFormat as Ir,PDF_RENDITION_NAME as Lr,POSTER_RENDITION_NAME as Rr,Permission as zr,PrincipalType as Br,SearchTypes as Vr,SecurityLevelLabels as Hr,SupportedEmbeddingTypes as Ur,WorkflowExecutionStatus as Wr,getContentTypeRefId as Gr,mergeInCodePromptSchemas as Kr,normalizeAgentToolApprovalMode as qr,normalizeToolCollection as Jr,supportsToolUse as Yr}from"@vertesia/common";import"react-dom";import{Slot as Xr}from"@radix-ui/react-slot";import{cva as Zr}from"class-variance-authority";import*as Qr from"@radix-ui/react-tooltip";import"@vertesia/ui/env";import"framer-motion";import*as $r from"@radix-ui/react-checkbox";import"@radix-ui/react-collapsible";import{Command as ei}from"cmdk";import*as ti from"@radix-ui/react-dropdown-menu";import ni from"dayjs";import"react-calendar";import*as ri from"@radix-ui/react-popover";import{capitalize as ii}from"lodash-es";import*as ai from"@radix-ui/react-label";import"@radix-ui/react-radio-group";import"react-resizable-panels";import*as oi from"@radix-ui/react-separator";import*as si from"@radix-ui/react-slider";import*as ci from"@radix-ui/react-switch";import*as li from"@radix-ui/react-tabs";import ui,{defaultUrlTransform as di}from"react-markdown";import fi from"rehype-katex";import{defListHastHandlers as pi,remarkDefinitionList as mi}from"remark-definition-list";import hi from"remark-directive";import gi from"remark-gfm";import _i from"remark-github-blockquote-alert";import vi from"remark-math";import yi from"remark-supersub";import{SKIP as bi,visit as xi}from"unist-util-visit";import{FusionFragmentHandler as Si,FusionFragmentProvider as Ci}from"@vertesia/fusion-ux";import wi from"dompurify";import Ti from"mermaid";import{NavLink as Ei,useNavigate as Di,useRouterContext as Oi}from"@vertesia/ui/router";import{CodeBlockErrorBoundary as ki,CodeBlockPlaceholder as Ai,CodeBlockRendererProvider as ji,DropZone as Mi,GeneratedForm as Ni,JSONCode as Pi,JSONDisplay as Fi,ManagedObject as Ii,MarkdownRenderer as Li,MonacoEditor as Ri,Progress as zi,SchemaEditor as Bi,UploadSummary as Vi,XMLViewer as Hi,isIncompleteJson as Ui,useCodeBlockContext as Wi,useSchema as Gi}from"@vertesia/ui/widgets";import Ki,{Ajv as qi}from"ajv";import Ji from"dayjs/plugin/localizedFormat";import Yi from"dayjs/plugin/relativeTime";import{Md5 as Xi}from"ts-md5";import{Document as Zi,Page as Qi,pdfjs as $i}from"react-pdf";import{ErrorBoundary as ea}from"react-error-boundary";import{FullHeightLayout as ta,SidebarItem as na}from"@vertesia/ui/layout";import ra from"ajv-formats";var ia=Object.defineProperty,aa=(e,t)=>{let n={};for(var r in e)ia(n,r,{get:e[r],enumerable:!0});return t||ia(n,Symbol.toStringTag,{value:`Module`}),n};function oa({children:e,secondary:n=!1}){return t(`span`,{className:n?`bg-secondary text-primary`:`text-foreground bg-muted`,children:e})}function sa(e){if(e)return e.name===`array`?sa(e.innerType):e}function ca({property:e}){return n(`div`,{className:`flex items-center gap-x-2`,children:[t(`div`,{className:`font-semibold text-gray-600`,children:e.name}),e.optional&&t(oa,{children:`optional`}),t(oa,{children:e.type.value})]})}function la({activities:e}){return t(`div`,{className:`flex flex-col gap-y-4 divide-y divide-gray-200`,children:e.map(e=>t(da,{activity:e},e.name))})}function ua({code:e,children:r}){return n(`div`,{className:`flex gap-2 items-center border-b border-b-gray-200 mb-2`,children:[t(`div`,{className:`text-lg font-medium text-gray-900 py-2 `,children:r}),e&&t(`div`,{children:t(oa,{children:e})})]})}function da({activity:e,headingClass:r,headingRef:i}){return n(`div`,{className:r,id:e.name,ref:i,children:[t(`div`,{className:`text-xl font-semibold pt-8`,children:e.title}),t(`div`,{className:`pb-4`,children:t(oa,{children:e.name})}),e.doc&&t(`div`,{className:`text-gray-700 pb-2`,children:e.doc}),n(`div`,{className:`pb-4`,children:[t(ua,{code:e.paramsType,children:`Parameters`}),t(`div`,{className:`divide-y divide-gray-100`,children:e.params.map(e=>t(fa,{property:e},e.name))})]}),n(`div`,{className:`pb-4`,children:[t(ua,{children:`Returns`}),t(`div`,{children:e.returnType?e.returnType.value:`void`})]})]})}function fa({property:e,className:r}){let i=q(()=>{let n=sa(e.type.innerType)??e.type;return n.name===`object`&&n.members?t(ma,{members:n.members}):n.name===`enum`&&n.enum?t(pa,{values:n.enum}):null},[e.type]);return n(`div`,{className:Ze(`py-2`,r),children:[t(ca,{property:e}),e.doc&&t(`div`,{className:`text-gray-700 text-sm pt-2`,children:e.doc}),i&&t(`div`,{className:`my-2 overflow-hidden`,children:i})]})}function pa({values:e}){return t(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.map(e=>t(oa,{secondary:!0,children:e},e))})}function ma({members:e}){return t(ga,{className:`rounded-md border border-gray-200`,button:e=>n(`div`,{className:`px-4 py-2 flex items-center gap-x-2 text-sm font-medium hover:text-blue-600`,children:[t(_a,{isOpen:e}),e?t(`div`,{children:`Hide child properties`}):t(`div`,{children:`Show child properties`})]}),body:t(ha,{properties:e})})}function ha({properties:e}){return t(`div`,{className:`border-s-2 border-s-blue-200 flex flex-col divide-y divide-gray-100 border-t border-t-gray-200`,children:e.map(e=>t(fa,{property:e,className:`px-4 py-2`},e.name))})}function ga({button:e,body:r,className:i,isInitiallyOpen:a}){let[s,c]=Y(a||!1);return n(`div`,{className:Ze(s?`block`:`inline-block`,i),children:[t(o,{variant:`unstyled`,className:`p-0 m-0 bg-transparent`,onClick:()=>c(!s),children:t($e,{children:e(s)})}),t($e,{children:s&&t(et.div,{className:`overflow-hidden`,initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:`easeOut`},children:r})})]})}function _a({isOpen:e}){return t($e,{propagate:!0,mode:`wait`,children:t(et.div,{className:`font-mono font-semibold text-gray-400 text-lg`,initial:{rotate:0},animate:{rotate:e?45:0},transition:{duration:.2},children:`+`},`closeIcon`)})}function va(e){return e===`full_control`?`text-attention`:e===`auto_review`?`text-info`:`text-muted`}function ya(e){return t(e===`full_control`?rr:e===`ask`?hn:ir,{className:`size-4`})}function ba({mode:e,onChange:r,disabled:i=!1,className:a}){let{t:s}=X(),c=q(()=>[{mode:`ask`,label:s(`agent.approvalMode.ask`),description:s(`agent.approvalMode.askDescription`),icon:t(hn,{className:`size-4`})},{mode:`auto_review`,label:s(`agent.approvalMode.autoReview`),description:s(`agent.approvalMode.autoReviewDescription`),icon:t(ir,{className:`size-4`})},{mode:`full_control`,label:s(`agent.approvalMode.fullControl`),description:s(`agent.approvalMode.fullControlDescription`),icon:t(rr,{className:`size-4`})}],[s]),l=c.find(t=>t.mode===e)??c[2],u=t=>{t!==e&&r(t)};return n(T,{children:[t(A,{asChild:!0,children:n(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,className:V(`h-8 max-w-[13rem] rounded-full px-2.5 font-medium`,`bg-mixer-muted/15 text-muted hover:bg-muted hover:text-foreground disabled:opacity-60`,a),"aria-label":s(`agent.approvalMode.selectorLabel`),children:[t(`span`,{className:V(`shrink-0`,va(e)),children:ya(e)}),t(`span`,{className:`min-w-0 truncate`,children:l.label}),t(kt,{className:`size-4 shrink-0 opacity-70`})]})}),n(E,{align:`start`,className:`z-[1000000] w-[min(28rem,calc(100vw-1rem))] p-2`,children:[t(`div`,{className:`px-2 pb-1.5 pt-1 text-sm font-medium text-foreground`,children:s(`agent.approvalMode.dropdownTitle`)}),t(O,{value:e,onValueChange:e=>u(e),children:c.map(e=>n(k,{value:e.mode,className:`min-h-14 items-start gap-3 rounded-md py-2 pe-8 ps-2 text-start`,children:[t(`span`,{className:V(`mt-0.5 shrink-0`,va(e.mode)),children:e.icon}),n(`span`,{className:`min-w-0 flex-1`,children:[t(`span`,{className:`block text-sm font-medium text-foreground`,children:e.label}),t(`span`,{className:`mt-0.5 block whitespace-normal text-sm leading-5 text-muted`,children:e.description})]})]},e.mode))})]})]})}function $(...e){return Dr(Qe(e))}const xa=nt(null);function Sa({children:e}){let n=J(new Map),r=J(new Map),i=G(e=>n.current.get(e),[]),a=G((e,t)=>{n.current.set(e,t)},[]),o=G(async(e,t)=>{let i=n.current.get(e);if(i)return i;let a=r.current.get(e);if(a)return a;let o=t().then(t=>(n.current.set(e,t),r.current.delete(e),t)).catch(t=>{throw r.current.delete(e),t});return r.current.set(e,o),o},[]),s=W.useMemo(()=>({getUrl:i,setUrl:a,getOrFetch:o}),[i,a,o]);return t(xa.Provider,{value:s,children:e})}function Ca(){return at(xa)}function wa(e){return e.startsWith(`agents/`)||e.startsWith(`documents/`)}function Ta(e,t,n=`inline`){return`artifact:${e}:${t}:${n}`}function Ea(e){return`file:${e}`}function Da({error:e,chartTitle:r}){return t(`div`,{className:`flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4`,children:n(`div`,{className:`text-center`,children:[n(`p`,{className:`text-sm font-medium text-red-600 dark:text-red-400`,children:[`Cannot render `,r||`Vega-Lite`,` chart`]}),t(`p`,{className:`text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate`,children:e})]})})}function Oa({isOpen:e,onClose:r,title:i,description:a,children:s}){let{t:c}=X();return t(Cr.Root,{open:e,onOpenChange:e=>!e&&r(),children:n(Cr.Portal,{children:[t(Cr.Overlay,{className:`fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),n(Cr.Content,{className:`fixed inset-2 sm:inset-4 z-50 flex flex-col bg-white dark:bg-gray-900 rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2`,onEscapeKeyDown:r,children:[t(Cr.Close,{asChild:!0,children:t(o,{variant:`unstyled`,onClick:r,className:`absolute top-3 end-3 z-10 p-2 rounded-lg bg-white/80 dark:bg-gray-800/80 backdrop-blur-sm hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150 shadow-sm`,"aria-label":c(`agent.closeFullscreen`),children:t(yr,{className:`w-5 h-5 text-gray-600 dark:text-gray-300`})})}),t(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150`,children:s}),t(`div`,{className:`flex items-center justify-between px-4 sm:px-6 py-3 border-t border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50 rounded-b-xl`,children:n(`div`,{className:`flex flex-col`,children:[t(Cr.Title,{className:`text-base font-semibold text-gray-900 dark:text-gray-100`,children:i||c(`agent.dashboard`)}),a&&t(Cr.Description,{className:`text-sm text-gray-500 dark:text-gray-400 mt-0.5`,children:a})]})})]})]})})}function ka(e,t){if(t===`chart`)return 280;let n=1;if(e.vconcat)n=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){let t=e.columns||2,r=Array.isArray(e.concat)?e.concat.length:1;n=Math.ceil(r/t)}else e.facet&&(n=2);return Math.max(500,n*280+40)}const Aa={categorical:[`#6366f1`,`#8b5cf6`,`#ec4899`,`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#14b8a6`,`#06b6d4`,`#3b82f6`],blues:[`#dbeafe`,`#93c5fd`,`#3b82f6`,`#1d4ed8`,`#1e3a8a`],purples:[`#f3e8ff`,`#c4b5fd`,`#8b5cf6`,`#6d28d9`,`#4c1d95`],greens:[`#dcfce7`,`#86efac`,`#22c55e`,`#15803d`,`#14532d`],diverging:[`#ef4444`,`#fca5a5`,`#fef3c7`,`#86efac`,`#22c55e`]};function ja(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ma(e){return ja(e)}function Na(e){let t=JSON.parse(JSON.stringify(e)),n=[`vconcat`,`hconcat`,`concat`];if(!n.some(e=>Array.isArray(t[e])))return t;let r=[];if(Array.isArray(t.params))for(let e of t.params)e&&typeof e==`object`&&e.name&&e.select&&r.push({name:e.name,param:e});if(r.length===0)return t;for(let{name:e,param:i}of r){let r=i.select?.fields||[],a=i.select?.bind===`legend`,o=null;for(let e of n)if(Array.isArray(t[e])){o=t[e];break}if(!o||o.length===0)continue;let s=0;for(let e=0;e<o.length;e++){let t=o[e];if(Fa(t,r)||a&&Ia(t,r)){s=e;break}}let c=o[s];c.params||=[],c.params.push(i),t.params=(t.params??[]).filter(t=>t.name!==e)}return Array.isArray(t.params)&&t.params.length===0&&delete t.params,t}function Pa(e,t){if(!t||Object.keys(t).length===0)return e;let n=JSON.parse(JSON.stringify(e)),r=e=>{for(let n of e)n.name&&n.name in t&&(n.value=t[n.name])};Array.isArray(n.params)&&r(n.params);let i=e=>{if(Array.isArray(e)){for(let t of e)if(Array.isArray(t.params)&&r(t.params),t.vconcat&&i(t.vconcat),t.hconcat&&i(t.hconcat),t.concat&&i(t.concat),Array.isArray(t.layer))for(let e of t.layer)Array.isArray(e.params)&&r(e.params)}};if(n.vconcat&&i(n.vconcat),n.hconcat&&i(n.hconcat),n.concat&&i(n.concat),Array.isArray(n.layer))for(let e of n.layer)e&&Array.isArray(e.params)&&r(e.params);return n}function Fa(e,t){if(!e?.encoding)return!1;for(let n of t)for(let t of Object.values(e.encoding))if(t.field===n)return!0;if(Array.isArray(e.layer)){for(let n of e.layer)if(Fa(n,t))return!0}return!1}function Ia(e,t){if(!e)return!1;let n=e=>{if(!e)return!1;let n=e.color?.field;return!!n&&t.includes(n)};if(n(e.encoding))return!0;if(Array.isArray(e.layer)){for(let t of e.layer)if(n(t.encoding))return!0}return!1}function La(e,t=[]){let n=[];if(!e||typeof e!=`object`)return n;if(e.data&&typeof e.data==`object`){let r=e.data.url;typeof r==`string`&&r.startsWith(`artifact:`)&&n.push({path:[...t,`data`],artifactPath:r.replace(/^artifact:/,``).trim()})}for(let r of[`layer`,`vconcat`,`hconcat`,`concat`,`spec`,`repeat`,`facet`])if(r in e){let i=e[r];Array.isArray(i)?i.forEach((e,i)=>{Ma(e)&&n.push(...La(e,[...t,r,String(i)]))}):Ma(i)&&n.push(...La(i,[...t,r]))}return n}function Ra(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of t){let t=e.split(`.`),i=n;for(let e=0;e<t.length-1;e++){let n=i[t[e]];if(!ja(n))break;i=n}let a=t[t.length-1],o=i[a];ja(o)&&(delete o.url,o.values=r)}return n}function za(e){let t={background:`transparent`,view:{stroke:`transparent`},range:{category:Aa.categorical,diverging:Aa.diverging,heatmap:Aa.purples,ramp:Aa.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:`round`},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80}};return e?{...t,axis:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,gridColor:`#3f3f46`,domainColor:`#52525b`,tickColor:`#52525b`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#fafafa`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}:{...t,axis:{labelColor:`#71717a`,titleColor:`#3f3f46`,gridColor:`#e4e4e7`,domainColor:`#d4d4d8`,tickColor:`#d4d4d8`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#71717a`,titleColor:`#3f3f46`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#18181b`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}}const Ba=it(function({spec:r,artifactRunId:i}){let{t:a}=X(),{title:s,description:c,options:l}=r,u=r.spec,[d,f]=Y(!1),[p,m]=Y(!1),[h,g]=Y(null),[_,v]=Y(!1),y=J(null),b=J(null),x=J(null),{client:S}=Z(),C=Ca(),w=J(S);w.current=S;let T=J(C);T.current=C;let[E,D]=Y(null),[O,k]=Y(!1),[A,j]=Y(null),M=l?.mode||`chart`,N=M===`dashboard`,P=l?.enableFullscreen??N,F=l?.height||ka(u,M);K(()=>{let e=La(u);if(e.length===0){D(u),k(!1),j(null);return}i?console.info(`[VegaLiteChart] resolving artifacts with runId:`,i,e.map(e=>e.artifactPath)):console.warn(`[VegaLiteChart] artifact references found but artifactRunId is missing!`,{references:e.map(e=>e.artifactPath),artifactRunId:i});let t=!1;return k(!0),j(null),(async()=>{let n=new Map,r=w.current,a=T.current;for(let o of e)try{let e=o.path.join(`.`),t;if(i&&!wa(o.artifactPath)){let e=Ta(i,o.artifactPath,`inline`);t=a?await a.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(i,o.artifactPath,`inline`)).url):(await r.files.getArtifactDownloadUrl(i,o.artifactPath,`inline`)).url}else{let e=Ea(o.artifactPath);t=a?await a.getOrFetch(e,async()=>(await r.files.getDownloadUrl(o.artifactPath)).url):(await r.files.getDownloadUrl(o.artifactPath)).url}let s=await fetch(t);if(!s.ok)throw Error(`Failed to fetch artifact data: ${s.statusText}`);let c=o.artifactPath.toLowerCase().endsWith(`.csv`),l;if(c){let e=await s.text();l=Tr.parse(e,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{let e=await s.json();l=Array.isArray(e)?e:[e]}n.set(e,l)}catch(e){console.error(`Failed to resolve artifact: ${o.artifactPath}`,e),t||j(`Failed to load data from artifact: ${o.artifactPath}`);return}if(!t){let e=Ra(u,n);D(e),k(!1)}})(),()=>{t=!0}},[u,i]);let[I,L]=Y(!1),R=J(!1);K(()=>{let e=()=>{let e=document.documentElement.classList.contains(`dark`);e!==R.current&&(R.current=e,L(e))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let[ee,te]=Y(0),z=J(0);K(()=>{if(!x.current)return;let e,t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{let e=t[0]?.contentRect.width;e&&e!==z.current&&(z.current=e,te(e))},100)});t.observe(x.current);let n=x.current.clientWidth;return z.current=n,te(n),()=>{clearTimeout(e),t.disconnect()}},[]);let ne=q(()=>La(u).length>0,[u]),B=q(()=>{if(ne&&!E)return null;let e=E||u;return e?(l?.parameterValues&&(e=Pa(e,l.parameterValues)),Na(e)):null},[E,u,ne,l?.parameterValues]),re=G((e,t)=>{if(!e||typeof e!=`object`)return e;if(e.hconcat&&Array.isArray(e.hconcat)){let n=e.hconcat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,hconcat:e.hconcat.map(e=>re(e,i))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>re(e,t))};if(e.concat&&Array.isArray(e.concat)){let n=e.columns??e.concat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,concat:e.concat.map(e=>re(e,i))}}let n=e.width;return n===`container`||typeof n==`number`&&n>t?{...e,width:t}:e},[]),ie=G((e,t=!1)=>{if(!B)return null;let n=za(I),r=t?typeof window<`u`?Math.min(window.innerWidth-80,1400):1200:ee>0?ee-24:500,i=`vconcat`in B||`hconcat`in B||`concat`in B,a=i?{type:`pad`,contains:`padding`}:{type:`fit`,contains:`padding`},o=B;i&&r&&(o=re(B,r));let c=o.width,l=i?void 0:c===`container`?r:c??r,{width:u,...d}=o;return{$schema:`https://vega.github.io/schema/vega-lite/v6.json`,...!i&&l?{width:l}:{},height:t?void 0:e,autosize:a,...i?o:d,...s&&!B.title?{title:s}:{},config:{...n,...B.config}}},[B,s,I,ee,re]),ae=G(async()=>{let e=_?b.current:y.current;if(!(!e||p))try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),m(!0),setTimeout(()=>m(!1),2e3))},`image/png`)}catch(e){console.error(`Failed to copy chart:`,e)}},[p,_]),oe=G(async()=>{let e=_?b.current:y.current;if(!(!e||d)){f(!0);try{let t=await e.toImageURL(`png`,2),n=document.createElement(`a`);n.download=`${s||`chart`}.png`,n.href=t,n.click()}catch(e){console.error(`Failed to export chart:`,e)}finally{f(!1)}}},[s,d,_]),se=G(e=>{y.current=e,g(null)},[]),ce=G(e=>{b.current=e},[]),le=G(e=>{console.error(`Vega-Lite rendering error:`,e),g(e instanceof Error?e.message:`Unknown error`)},[]),ue=G(()=>{v(e=>!e)},[]);K(()=>{g(null)},[u]);let de=({className:e})=>n(`div`,{className:$(`flex items-center gap-2`,e),children:[n(o,{variant:`unstyled`,onClick:ae,disabled:p,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1`,title:a(`agent.copyToClipboard`),children:[t(p?St:Wt,{className:`w-3 h-3`}),a(p?`agent.copied`:`agent.copy`)]}),n(o,{variant:`unstyled`,onClick:oe,disabled:d,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1`,title:a(`agent.exportAsPng`),children:[t(qt,{className:`w-3 h-3`}),a(d?`agent.exporting`:`agent.export`)]}),P&&n(o,{variant:`unstyled`,onClick:ue,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors flex items-center gap-1`,title:a(_?`agent.exitFullscreen`:`agent.fullscreen`),children:[t(_?Nn:An,{className:`w-3 h-3`}),a(_?`agent.exit`:`agent.fullscreen`)]})]});if(O||ne&&!E)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{className:`flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded`,style:{width:`100%`,height:F},children:n(`div`,{className:`flex items-center gap-2 text-gray-500 dark:text-gray-400`,children:[t(Dn,{className:`w-5 h-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading data from artifacts...`})]})})]})});if(A)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:F},children:t(Da,{error:A,chartTitle:s})})]})});if(h)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:F},children:t(Da,{error:h,chartTitle:s})})]})});let fe=ie(F),pe=ie(0,!0);return fe?(typeof window<`u`&&localStorage.getItem(`DEBUG_VEGA_RENDERS`)&&console.log(`VegaLite rendering with spec:`,{title:s,hasData:!!fe.data?.values,dataLength:fe.data?.values?.length}),n(e,{children:[t(`div`,{className:$(`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,N&&`border-2`),children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[n(`div`,{className:`flex items-center justify-between`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||(N?`Dashboard`:`Chart`)}),N&&t(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-indigo-100 dark:bg-indigo-900 text-indigo-700 dark:text-indigo-300`,children:`Interactive`})]}),t(de,{})]}),c&&t(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c}),t(`div`,{ref:x,className:`bg-white dark:bg-gray-900 rounded overflow-hidden`,style:{width:`100%`,height:F,minWidth:0},children:t(Er,{spec:fe,onEmbed:e=>se(e.view),onError:le,options:{renderer:l?.renderer||`canvas`,actions:!1}})})]})}),n(Oa,{isOpen:_,onClose:()=>v(!1),title:s||(N?`Dashboard`:`Chart`),description:c,children:[t(`div`,{className:`w-full h-full min-h-[calc(100vh-200px)]`,children:pe&&t(Er,{spec:pe,onEmbed:e=>ce(e.view),onError:le,options:{renderer:l?.renderer||`canvas`,actions:!1}})}),t(`div`,{className:`absolute bottom-6 end-6`,children:t(de,{className:`bg-white dark:bg-gray-800 rounded-lg shadow-lg p-2 border border-gray-200 dark:border-gray-700`})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function Va(e){return e.library===`vega-lite`&&typeof e.spec==`object`}function Ha(e){return e.library===`recharts`||e.library===void 0}function Ua(e){return typeof e.$schema==`string`&&e.$schema.includes(`vega`)}const Wa=it(function({spec:e,artifactRunId:r}){return Va(e)?t(Ba,{spec:e,artifactRunId:r}):Ua(e)?t(Ba,{spec:{library:`vega-lite`,spec:e},artifactRunId:r}):n(`div`,{className:`my-5 rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200`,children:[`Recharts chart rendering has been retired. Use a Vega-Lite chart spec (`,t(`code`,{children:`library: "vega-lite"`}),` with `,t(`code`,{children:`spec`}),`).`]})},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function Ga(e,t){return e===`live`?e:t===0?`live`:Math.min(Math.max(e,0),t-1)}function Ka(e,t){return t===0?-1:e===`live`?t-1:Math.min(Math.max(e,0),t-1)}function qa(e,t){if(e.length===0)return null;let n=t===`live`?e.length:Ka(t,e.length);for(let t=Math.min(n-1,e.length-1);t>=0;t--)if(e[t].type===Q.QUESTION)return t;return null}function Ja(e,t){if(e.length===0||t===`live`)return null;let n=Ka(t,e.length);for(let t=n+1;t<e.length;t++)if(e[t].type===Q.QUESTION)return t;return`live`}function Ya(e,t,n){let r=n?Ga(t,e.length):`live`,i=Ka(r,e.length),a=!n||r===`live`,o=a?e:e.slice(0,i+1);return{cursor:r,cursorIndex:i,isLive:a,renderedMessageCount:o.length,displayedMessages:o}}function Xa(e){let t=e.indexOf(`?`);return t===-1?new URLSearchParams:new URLSearchParams(e.slice(t+1))}function Za(){return!(typeof window>`u`)}function Qa(){if(!Za())return!1;let e=new URLSearchParams(window.location.search),t=Xa(window.location.hash),n=e.get(`agentChatPlayback`)??t.get(`agentChatPlayback`);return n===`1`||n===`true`}const $a=Za,eo=Qa;function to({cursor:e,messages:r,onChangeCursor:i,className:a}){let{t:s}=X(),c=r.length,l=e===`live`,u=Ka(e,c),d=c>0&&(l||u>0),f=!l&&c>0,p=c>0&&(l||u>0),m=!l&&c>0&&u<c-1,h=c===0?0:u+1,[g,_]=Y(String(h));K(()=>{_(String(h))},[h]);let v=()=>{if(c!==0){if(e===`live`){i(c-1);return}i(Math.max(0,u-1))}},y=()=>{if(!(c===0||e===`live`)){if(u>=c-1){i(`live`);return}i(u+1)}},b=()=>{c!==0&&i(0)},x=()=>{c!==0&&i(c-1)},S=()=>{_(String(h))},C=(e,t=!1)=>{if(c===0){_(`0`);return}let n=Number.parseInt(e,10);if(!Number.isFinite(n)){t&&S();return}let r=Math.min(Math.max(n,1),c);_(String(r)),i(r-1)},w=e=>{c!==0&&C(e)},T=c>1,E=+!!T,D=Math.max(1,c),O=`size-7 rounded-lg text-muted hover:text-foreground disabled:opacity-35`,k=`${Math.max(3,String(c).length+1)}ch`;return n(`div`,{className:V(`inline-flex max-w-full flex-col gap-1 rounded-xl border border-border/70 bg-background/95 px-2 py-1 text-sm leading-none text-muted shadow-lg shadow-black/10 backdrop-blur`,a),"data-testid":`agent-test-playback-controls`,"data-playback-cursor":e,"data-live-message-count":c,"data-rendered-message-count":l?c:u+1,children:[n(`div`,{className:`flex max-w-full items-center gap-1`,children:[t(`span`,{className:`ms-2 me-1 font-medium leading-none text-foreground/80`,children:s(`agent.rewind.label`)}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToStart`),disabled:!p,onClick:b,className:O,children:t(Ft,{className:`size-4`})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.previousMessage`),disabled:!d,onClick:v,className:O,children:t(At,{className:`size-4`})}),n(`span`,{className:`inline-flex min-w-16 items-center justify-center gap-0.5 px-1 font-medium leading-none tabular-nums text-foreground/80`,"data-testid":`agent-test-playback-position`,children:[t(ee,{type:`text`,variant:`unstyled`,size:`sm`,clearable:!1,inputMode:`numeric`,pattern:`[0-9]*`,value:g,"aria-label":s(`agent.rewind.positionInput`),disabled:c===0,onChange:e=>{let t=e.replace(/\D/g,``);_(t)},onBlur:e=>C(e.currentTarget.value,!0),onKeyDown:e=>{e.key===`Enter`&&(C(e.currentTarget.value,!0),e.currentTarget.blur())},style:{width:k},className:`h-7 w-auto rounded-md border border-transparent bg-transparent px-1 text-center text-sm font-medium leading-none tabular-nums text-foreground outline-none transition-colors hover:border-border focus:border-ring focus:bg-muted/30 disabled:opacity-50`}),t(`span`,{"aria-hidden":`true`,className:`text-muted`,children:`/`}),t(`span`,{className:`text-muted`,children:c})]}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.nextMessage`),disabled:!f,onClick:y,className:O,children:t(jt,{className:`size-4`})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToLatest`),disabled:!m,onClick:x,className:O,children:t(It,{className:`size-4`})}),t(o,{type:`button`,variant:l?`secondary`:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToLive`),disabled:l,onClick:()=>i(`live`),className:V(O,l&&`bg-muted text-foreground`),children:t(Gn,{className:`size-4`})})]}),t(`div`,{className:`px-2 pb-1`,children:t(we,{min:E,max:D,step:1,value:[h],"aria-label":s(`agent.rewind.positionInput`),disabled:!T,onValueChange:([e])=>w(String(e)),className:`h-2`})})]})}nt(void 0);var no=class{filter(e,t){let n=t.toLowerCase();return e.filter(e=>this.valueOf(e).toLowerCase().includes(n))}renderOption(e){return this.valueOf(e)}findById(e,t){return e.find(e=>this.idOf(e)===t)}createItem(e){return null}},ro=class e extends no{valueOf(e){return String(e)}idOf(e){return String(e)}static instance=new e};(class e extends ro{createItem(e){return e}static instance=new e});const io=W.createContext(void 0);function ao(){return W.useContext(io)}const oo=Qr.Provider,so=Qr.Root,co=Qr.Trigger,lo=U.forwardRef(({className:e,sideOffset:n=4,side:r=`top`,...i},a)=>{let o=ao();return t(Qr.Portal,{container:o,children:t(Qr.Content,{ref:a,sideOffset:n,side:r,style:{zIndex:100},className:$(`max-w-[90vw]`,`z-50 overflow-hidden rounded-md bg-tooltips border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...i})})});lo.displayName=Qr.Content.displayName;function uo({description:e,children:r,size:i=`sm`,placement:a=`top`,className:o,asChild:s}){let[c,l]=U.useState(!1),u=U.useRef(!1);return U.useEffect(()=>{let e=()=>{l(!1),u.current=!0,requestAnimationFrame(()=>{u.current=!1})};return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e)}},[]),t(oo,{delayDuration:0,children:n(so,{open:c,onOpenChange:e=>{u.current||l(e)},children:[t(co,{className:`cursor-pointer`,asChild:s,children:r}),t(lo,{side:a,className:`px-3 py-1.5 max-w-${i} text-${i} px-3 ${o}`,children:e})]})})}const fo=new Set;function po(e,t,n){K(()=>{t&&!fo.has(e)&&(fo.add(e),console.warn(`[@vertesia/ui] ${e} is deprecated: ${n}`))},[t,n,e])}function mo(e){return U.Children.toArray(e).some(e=>{if(typeof e==`string`)return e.trim().length>0;if(typeof e==`number`)return!0;if(U.isValidElement(e)){let t=e.props;return t[`aria-hidden`]===!0||t[`aria-hidden`]===`true`?!1:mo(t.children)}return!1})}const ho=Zr(`hover:cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{destructive:`bg-destructive dark:bg-destructive/10 text-destructive ring-1 ring-inset ring-destructive-muted/50 dark:ring-destructive-muted/50 shadow-xs hover:bg-destructive/50`,outline:`border border-input bg-background shadow-xs hover:bg-muted ring-inset`,secondary:`bg-primary/5 dark:bg-primary/10 text-primary shadow-xs hover:bg-primary/10 dark:hover:bg-primary/20 ring-inset`,ghost:`hover:bg-muted/50 dark:hover:bg-muted/20 ring-inset`,link:`text-foreground underline-offset-4 hover:underline ring-inset`,primary:`bg-primary text-white shadow-xs hover:bg-primary/90 ring-inset`,unstyled:``},size:{xs:`h-7 rounded px-2 py-1 text-xs gap-x-1`,sm:`h-8 rounded px-3 text-xs`,md:`h-9 rounded-md px-4 py-2`,lg:`h-10 rounded-md px-3`,xl:`rounded-md px-3.5 py-2.5 text-sm gap-x-2`,icon:`p-0 m-0 rounded-full`,none:``}},defaultVariants:{variant:`primary`,size:`md`}}),go=U.forwardRef(({className:r,variant:i,size:a,asChild:o=!1,alt:s,isDisabled:c,isLoading:l,title:u,tooltipPlacement:d=`top`,onClick:f,type:p,...m},h)=>{po(`Button.alt`,s!==void 0,"use `title` instead — it drives the same tooltip and the accessible name. `alt` remains an alias for one release.");let g=o?Xr:`button`,_=o?p:p??`button`,v=u??s,y=m[`aria-label`]??s??(mo(m.children)?void 0:u),b=o?m.children:n(e,{children:[l&&t(Dn,{className:`animate-spin`}),m.children]}),x=t(g,{className:Ze($(ho({variant:i,size:a})),r),disabled:c||l||m.disabled,ref:h,onClick:f,type:_,autoFocus:!1,...m,"aria-label":y,children:b});return v?t(uo,{description:v,asChild:!0,className:`cursor-pointer`,size:`xs`,placement:d,children:x}):x});go.displayName=`Button`;const _o=U.forwardRef(({size:e,content:n,toast:r,className:i,alt:a,"aria-label":o,...s},c)=>{let[l,u]=Y(!1),{t:d}=X();po(`CopyButton.alt`,a!==void 0,"use aria-label for the accessible name. `alt` is forwarded for one release.");let f=e=>{e.stopPropagation(),navigator.clipboard.writeText(n).then(()=>{u(!0),setTimeout(()=>u(!1),2e3),r?.toast&&r.toast({status:`success`,title:r.message||d(`misc.copiedToClipboard`),duration:2e3})}).catch(e=>{console.error(`Failed to copy text: `,e),r?.toast&&r.toast({status:`error`,title:d(`misc.failedToCopy`),duration:2e3})})},p=o??a??d(`misc.copy`);return t(go,{ref:c,className:$(i),variant:`unstyled`,size:e||`sm`,onClick:f,...s,title:p,children:l?t(St,{className:`text-success`}):t(Gt,{className:`size-4`})})});_o.displayName=`CopyButton`;function vo(e){return t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e(t))}}const yo=Zr(`inline-flex items-center rounded-md px-2 py-1 text-xs font-medium`,{variants:{variant:{default:`text-foreground bg-muted`,secondary:`bg-secondary text-primary`,destructive:`bg-destructive text-destructive`,attention:`bg-attention text-attention`,success:`bg-success text-success`,info:`bg-info text-info`,done:`bg-done text-done`,outline:`bg-transparent border border-border text-foreground`}},defaultVariants:{variant:`default`}});function bo({className:e,variant:n,children:r,onClick:i,...a}){let o=i?{role:`button`,tabIndex:0,onClick:i,onKeyDown:vo(i)}:{};return t(`span`,{className:$(yo({variant:n}),e),...o,...a,children:r})}Zr(`inline-flex items-center gap-x-1.5 rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ring-border`,{variants:{variant:{default:``,success:``,destructive:``,attention:``,done:``,info:``,outline:``}},defaultVariants:{variant:`default`}}),Zr(`h-1.5 w-1.5`,{variants:{variant:{default:`fill-foreground`,success:`fill-success`,destructive:`fill-destructive`,attention:`fill-attention`,done:`fill-done`,info:`fill-info`,outline:`fill-foreground`}},defaultVariants:{variant:`default`}});function xo({className:e,children:n}){return t(`ul`,{className:`${e} space-y-1 flex flex-col items-start`,children:n})}xo.Item=rt(function(e,n){let{current:r,children:i,className:a,href:o=`#`,onClick:s,...c}=e;return t(`li`,{className:Ze(a,r?`bg-muted`:``,`w-full p-2 ps-3 text-sm leading-6 font-semibold hover:bg-muted`),children:t(`a`,{ref:n,href:o,onClick:e=>{s?(e.preventDefault(),s(e)):o===`#`&&e.preventDefault()},className:`w-full flex items-center gap-x-3`,...c,children:i})})});const So=`rounded-md text-sm flex w-full rounded-md border border-input bg-background ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 ring-inset focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,Co={INPUT_UNSTYLED:`block m-0 p-0 w-full border-0 focus:outline-hidden focus:ring-0 bg-transparent`,INPUT_NO_PADDING:So,INPUT:`${So} py-1.5`};function wo(e){return e==null||Number.isNaN(e)?``:e.toString()}W.forwardRef(({value:e,onChange:n,className:r,noScroll:i=!1,noSpinners:a=!1,...o},s)=>{let[c,l]=W.useState(wo(e));return K(()=>{if(e==null||!Number.isNaN(e)){let t=wo(e);l(t)}},[e]),t(`input`,{onWheel:i?e=>{e.currentTarget.blur()}:o.onWheel,type:`number`,value:c,onChange:e=>{let t=e.target.value;l(t),t===``?n?.(void 0,t):n?.(parseFloat(t),t)},className:Ze(r,Co.INPUT,{"no-spinners":a},a&&`[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`),ref:s,...o})});const To=U.forwardRef(({...e},n)=>t(`nav`,{ref:n,"aria-label":`breadcrumb`,...e}));To.displayName=`Breadcrumb`;const Eo=U.forwardRef(({className:e,...n},r)=>t(`ol`,{ref:r,className:$(`flex flex-wrap items-center gap-1.5 break-words text-sm text-muted sm:gap-2.5`,e),...n}));Eo.displayName=`BreadcrumbList`;const Do=U.forwardRef(({className:e,...n},r)=>t(`li`,{ref:r,className:$(`inline-flex items-center gap-1.5 text-muted`,e),...n}));Do.displayName=`BreadcrumbItem`;const Oo=U.forwardRef(({asChild:e,className:n,...r},i)=>t(`a`,{ref:i,className:$(`transition-colors hover:text-muted`,n),...r}));Oo.displayName=`BreadcrumbLink`;const ko=U.forwardRef(({className:e,href:n,onClick:r,...i},a)=>t(go,{variant:`ghost`,size:`md`,ref:a,className:$(`p-0! hover:underline! hover:bg-background!`,e),onClick:e=>{e.preventDefault(),r&&r(e)},...i}));ko.displayName=`BreadcrumbButton`;const Ao=U.forwardRef(({className:e,...n},r)=>t(`span`,{ref:r,"aria-current":`page`,className:$(`font-normal text-foreground`,e),...n}));Ao.displayName=`BreadcrumbPage`;const jo=({children:e,className:n,...r})=>t(`li`,{role:`presentation`,"aria-hidden":`true`,className:$(`[&>svg]:w-3.5 [&>svg]:h-3.5`,n),...r,children:e??t(jt,{className:`cn-rtl-flip`})});jo.displayName=`BreadcrumbSeparator`;const Mo=({className:e,...r})=>n(`span`,{role:`presentation`,"aria-hidden":`true`,className:$(`flex h-9 w-9 items-center justify-center`,e),...r,children:[t(In,{className:`h-4 w-4`}),t(`span`,{className:`sr-only`,children:`More`})]});Mo.displayName=`BreadcrumbEllipsis`;const No=U.forwardRef(({className:e,...n},r)=>t(`div`,{ref:r,className:$(`rounded-xl border bg-card text-card-foreground shadow`,e),...n}));No.displayName=`Card`;const Po=U.forwardRef(({className:e,...n},r)=>t(`div`,{ref:r,className:$(`flex flex-col p-6`,e),...n}));Po.displayName=`CardHeader`;const Fo=U.forwardRef(({className:e,...n},r)=>t(`div`,{ref:r,className:$(`font-semibold leading-none tracking-tight`,e),...n}));Fo.displayName=`CardTitle`;const Io=U.forwardRef(({className:e,...n},r)=>t(`div`,{ref:r,className:$(`text-sm text-muted-foreground`,e),...n}));Io.displayName=`CardDescription`;const Lo=U.forwardRef(({className:e,...n},r)=>t(`div`,{ref:r,className:$(`p-6 pt-0`,e),...n}));Lo.displayName=`CardContent`;const Ro=U.forwardRef(({className:e,...n},r)=>t(`div`,{ref:r,className:$(`flex items-center p-6 pt-0`,e),...n}));Ro.displayName=`CardFooter`;const zo=U.forwardRef(({className:e,...n},r)=>t($r.Root,{ref:r,className:$(`peer size-4 shrink-0 rounded-sm border border-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-white`,e),...n,children:t($r.Indicator,{className:$(`flex items-center justify-center text-current`),children:t(St,{className:`size-4`})})}));zo.displayName=$r.Root.displayName;function Bo({children:e}){return t(`span`,{style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`},children:e})}const Vo=nt(!1);function Ho({children:e}){return t(Vo.Provider,{value:!0,children:e})}function Uo({className:e,children:r,isOpen:i,onClose:a,description:o=`Modal Description`,noCloseButton:s=!1,allowOverflow:c=!1,disableCloseOnClickOutside:l=!1,size:u=`md`,action:d}){let f=e=>{e||a()};function p(){switch(u){case`sm`:return`max-w-[20vw]`;case`md`:return`max-w-[60vw] lg:max-w-[40vw]`;case`lg`:return`max-w-[80vw] md:max-w-[60vw]`;case`xl`:return`max-w-[95vw] lg:max-w-[80vw]`;default:return`max-w-[60vw] lg:max-w-[40vw]`}}return n(Ko,{open:i,onOpenChange:e=>{(!l||e)&&f(e)},children:[c&&t(Yo,{className:`z-50 fixed inset-0 bg-black/80`}),t(Bo,{children:t(Zo,{children:o})}),n(Xo,{className:$(`min-h-20 p-4`,`fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 sm:rounded-lg`,p(),e),children:[t(`div`,{className:`top-4 end-4 absolute`,children:n(`div`,{className:`flex gap-2`,children:[d&&d,!s&&t(Jo,{onClick:()=>f(!1),asChild:!0,autoFocus:!1,children:t(go,{variant:`outline`,title:`Close`,className:`data-[state=open]:bg-accent opacity-70 hover:opacity-100 rounded-sm focus:outline-none focus:ring-2 focus:ring-ring ring-offset-background focus:ring-offset-2 data-[state=open]:text-muted-foreground transition-opacity disabled:pointer-events-none`,children:t(yr,{className:`size-4`})})})]})}),t(Ho,{children:r})]})]})}const Wo=({children:e,show:r=!0,className:i,description:a,showDivider:o=!1,...s})=>r?n(Qo,{className:$(o?`border-b-solid border-b border-b-1 pb-2 mb-4`:``,`text-lg font-semibold leading-6 tracking-tight`,{"py-2":!a},i),...s,children:[e,a&&t(Zo,{className:`text-sm !font-normal text-muted-foreground pb-2`,children:a})]}):n(Bo,{children:[t(Qo,{children:e}),a&&t(Zo,{children:a})]}),Go=({children:e,className:n,...r})=>t(`div`,{className:$(`text-sm max-h-[80vh] overflow-y-auto`,n),...r,children:e}),Ko=Cr.Root,qo=Cr.Portal,Jo=Cr.Close,Yo=U.forwardRef(({className:e,...n},r)=>t(Cr.Overlay,{ref:r,className:$(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...n}));Yo.displayName=Cr.Overlay.displayName;const Xo=U.forwardRef(({className:e,children:r,...i},a)=>{let o=ao();return n(qo,{container:o,children:[t(Yo,{}),t(Cr.Content,{ref:a,autoFocus:!1,onOpenAutoFocus:e=>{e.preventDefault()},className:$(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...i,children:r})]})});Xo.displayName=Cr.Content.displayName;const Zo=U.forwardRef(({className:e,...n},r)=>t(Cr.Description,{ref:r,className:$(`text-sm text-muted`,e),...n}));Zo.displayName=Cr.Description.displayName;const Qo=U.forwardRef(({className:e,...n},r)=>t(Cr.Title,{ref:r,className:$(`text-lg font-semibold leading-none tracking-tight`,e),...n}));Qo.displayName=Cr.Title.displayName;const $o=U.forwardRef(({className:e,...n},r)=>t(ei,{ref:r,className:$(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...n}));$o.displayName=ei.displayName;const es=U.forwardRef(({className:e,...r},i)=>n(`div`,{className:`flex items-center px-3 border-b`,"cmdk-input-wrapper":``,children:[t(er,{className:`opacity-50 size-4 shrink-0`}),t(ei.Input,{ref:i,className:$(`focus:ring-0`,`border-0 flex h-8 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...r})]}));es.displayName=ei.Input.displayName;const ts=U.forwardRef(({className:e,...n},r)=>t(ei.List,{ref:r,className:$(`overflow-y-auto overflow-x-hidden`,e),...n}));ts.displayName=ei.List.displayName;const ns=U.forwardRef((e,n)=>t(ei.Empty,{ref:n,className:`py-2 text-sm text-center`,...e}));ns.displayName=ei.Empty.displayName;const rs=U.forwardRef(({className:e,...n},r)=>t(ei.Group,{ref:r,className:$(`overflow-y-auto overflow-x-hidden p-1 text-foreground`,`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...n}));rs.displayName=ei.Group.displayName;const is=U.forwardRef(({className:e,...n},r)=>t(ei.Separator,{ref:r,className:$(`-mx-1 h-px bg-border`,e),...n}));is.displayName=ei.Separator.displayName;const as=U.forwardRef(({className:e,...n},r)=>t(ei.Item,{ref:r,className:$(`hover:bg-muted cursor-pointer relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,e),...n}));as.displayName=ei.Item.displayName;const os=({className:e,...n})=>t(`span`,{className:$(`ms-auto text-xs tracking-widest text-muted-foreground`,e),...n});os.displayName=`CommandShortcut`;const ss=U.createContext(!1);function cs({...e}){return t(ti.Root,{"data-slot":`dropdown-menu`,...e})}function ls({...e}){return t(ti.Trigger,{"data-slot":`dropdown-menu-trigger`,...e})}function us({className:e,align:n=`start`,sideOffset:r=4,...i}){return t(ti.Portal,{children:t(ti.Content,{"data-slot":`dropdown-menu-content`,sideOffset:r,align:n,className:$(`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto data-[state=closed]:overflow-hidden`,e),...i})})}function ds({className:e,inset:n,variant:r=`default`,...i}){return t(ti.Item,{"data-slot":`dropdown-menu-item`,"data-inset":n,"data-variant":r,className:$(`hover:bg-muted focus:bg-muted data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive gap-2 rounded-md px-1.5 py-1 text-sm data-inset:ps-7 [&_svg:not([class*='size-'])]:size-4 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),...i})}const fs={left:`start`,center:`center`,right:`end`};function ps({trigger:e,children:r,align:i=`right`,hover:a}){let[o,s]=U.useState(!1),c=U.useRef(null);return a?n(`div`,{className:`relative inline-flex`,onMouseEnter:()=>{c.current&&clearTimeout(c.current),s(!0)},onMouseLeave:()=>{c.current=setTimeout(()=>s(!1),80)},children:[e,o&&t(`div`,{className:$(`absolute top-full pt-1 z-50`,i===`right`?`end-0`:i===`center`?`left-1/2 -translate-x-1/2`:`start-0`),children:t(`div`,{className:`min-w-32 rounded-lg p-1 shadow-md ring-1 ring-foreground/10 bg-popover text-popover-foreground`,children:t(ss.Provider,{value:!0,children:r})})})]}):n(cs,{children:[t(ls,{asChild:!0,children:t(`span`,{className:`-m-1.5 flex items-center p-1.5`,children:e})}),t(us,{align:fs[i],className:`w-max`,children:r})]})}function ms({children:e,href:n,onClick:r,isDisabled:i=!1,variant:a=`default`,className:o}){let s=U.useContext(ss),c=$(`w-full gap-2 rounded-md px-1.5 py-1 text-sm text-nowrap [&_svg:not([class*='size-'])]:size-4 flex cursor-default items-center select-none [&_svg]:pointer-events-none [&_svg]:shrink-0`,a===`destructive`?`text-destructive`:``,i?`pointer-events-none opacity-50`:`hover:bg-muted focus:bg-muted`,o);return s?n?t(`a`,{href:n,className:c,children:e}):t(`button`,{type:`button`,className:c,disabled:i,onClick:e=>{e.stopPropagation(),r?.(e)},children:e}):t(ds,{className:$(`data-[disabled]:pointer-events-none data-[disabled]:opacity-50 text-nowrap`,o),disabled:i,variant:a,onClick:e=>{e.stopPropagation(),r?.(e)},asChild:!!n,children:n?t(`a`,{href:n,children:e}):e})}const hs=U.createContext(null);function gs(e=!1,t=()=>{},n){e&&t(n===`enter`)}const _s=U.forwardRef(({children:e,...n},r)=>{let i=U.useContext(hs);if(!i)throw Error(`PopoverTrigger must be used within a Popover`);let{setOpen:a,hover:o,click:s}=i;return t(ri.Trigger,{ref:r,asChild:!0,onMouseEnter:()=>gs(o,a,`enter`),onMouseLeave:()=>gs(o,a,`leave`),onClick:()=>{s&&a(e=>!e)},...n,children:e})});_s.displayName=ri.Trigger.displayName;const vs=U.forwardRef(({className:e,align:n=`center`,side:r=`bottom`,...i},a)=>{let o=U.useContext(hs);if(!o)throw Error(`PopoverContent must be used within a Popover`);let{setOpen:s,hover:c}=o,l=ao();return t(ri.Portal,{container:l,children:t(ri.Content,{ref:a,align:n,side:r,onMouseEnter:()=>gs(c,s,`enter`),onMouseLeave:()=>gs(c,s,`leave`),className:$(`z-50 w-72 rounded-md border-popover bg-popover text-popover-foreground ring-1 ring-gray-200 dark:ring-slate-700 shadow-md focus:outline-none animate-in`,`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...i})})});vs.displayName=ri.Content.displayName;const ys=ri.Close;ys.displayName=ri.Close.displayName;const bs=Zr(``,{variants:{size:{xs:`rounded py-1 text-xs rounded-xs`,sm:`rounded text-xs rounded-sm`,md:`rounded-md py-2 text-sm`,lg:`rounded-md text-base`,xl:`rounded-md py-2.5 text-lg`},variant:{default:`flex w-full rounded-md border border-input bg-background ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 ring-inset focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,unstyled:`block m-0 p-0 w-full border-0 focus:outline-hidden focus:ring-0 bg-transparent`,noPadding:`block rounded-md border-0 bg-background shadow-2xs ring-1 ring-inset ring-ring placeholder:text-muted-foreground focus:ring-2 focus:ring-inset focus:ring-ring ring-offset-background`,legacy:`py-1.5 block rounded-md border-0 bg-background shadow-2xs ring-1 ring-inset ring-ring placeholder:text-muted-foreground focus:ring-2 focus:ring-inset focus:ring-ring ring-offset-background`}},defaultVariants:{size:`md`,variant:`default`}}),xs=U.forwardRef(({className:e,type:r,size:i=`md`,variant:a=`default`,clearable:o=!0,onChange:s,value:c,invalid:l,...u},d)=>{let f=()=>{s?.(``)},p=e=>{s?.(e.target.value)},m=u[`aria-invalid`]??(l?!0:void 0);return n(`div`,{className:`w-full relative inline-block [&:hover_.clear-button]:opacity-100`,children:[t(`input`,{type:r,className:$(bs({size:i,variant:a}),e,o&&c?`pe-8`:``),ref:d,value:c??``,onChange:p,...u,"aria-invalid":m}),o&&c&&!u.readOnly&&!u.disabled&&t(go,{variant:`link`,size:`icon`,type:`button`,onClick:f,className:`clear-button opacity-0 transition-opacity duration-200
|
|
2
2
|
absolute top-1/2 -translate-y-1/2 text-muted !hover:text-destructive cursor-pointer
|
|
3
|
-
flex items-center justify-center size-6 rounded end-2`,"aria-label":`Clear input`,children:t(nr,{size:16})})]})});Qo.displayName=`Input`,W.createContext({filters:[],setFilters:()=>void 0,filterGroups:[]});var $o;(function(e){e.IS=`is`,e.IS_NOT=`is_not`,e.CONTAINS=`contains`,e.BEFORE=`before`,e.AFTER=`after`,e.IS_ANY_OF=`is_any_of`})($o||={});const es=Xe(({className:e,level:n=3,...r},i)=>t(`h${n}`,{ref:i,className:$({h1:`text-2xl font-medium tracking-tight`,h2:`text-xl font-medium tracking-tight`,h3:`text-lg font-medium`,h4:`text-base font-medium`,h5:`text-sm font-medium`,h6:`text-xs font-medium`}[`h${n}`],`mb-2`,e),...r}));es.displayName=`Heading`;const ts=Nr(`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`),ns=U.forwardRef(({className:e,required:r,...i},a)=>n(Vr.Root,{ref:a,className:$(ts(),e),...i,children:[i.children,r&&t(`span`,{className:`text-destructive-foreground ms-1`,children:`*`})]}));ns.displayName=Vr.Root.displayName,Ye(()=>{});const rs=U.forwardRef(({className:e,orientation:n=`horizontal`,decorative:r=!0,...i},a)=>t(Hr.Root,{ref:a,decorative:r,orientation:n,className:$(`shrink-0 bg-border`,n===`horizontal`?`h-[1px] w-full`:`h-full w-[1px]`,e),...i}));rs.displayName=Hr.Root.displayName;const is=U.forwardRef(({className:e,trackClassName:r,rangeClassName:i,thumbClassName:a,value:o,defaultValue:s,min:c=0,max:l=100,"aria-label":u,...d},f)=>{let p=U.useId(),m=Array.isArray(o)?o.length:Array.isArray(s)?s.length:1,h=U.useMemo(()=>Array.from({length:Math.max(1,m)},(e,t)=>`${p}-thumb-${t}`),[p,m]);return n(Ur.Root,{ref:f,"data-slot":`slider`,value:o,defaultValue:s,min:c,max:l,...d,className:$(`relative flex w-full touch-none select-none items-center data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col`,e),children:[t(Ur.Track,{"data-slot":`slider-track`,className:$(`relative h-1.5 w-full grow overflow-hidden rounded-full bg-muted data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5`,r),children:t(Ur.Range,{"data-slot":`slider-range`,className:$(`absolute h-full bg-primary data-[orientation=vertical]:w-full`,i)})}),h.map(e=>t(Ur.Thumb,{"data-slot":`slider-thumb`,"aria-label":u,className:$(`block size-3.5 rounded-full border border-primary bg-background shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,a)},e))]})});is.displayName=Ur.Root.displayName;const as={sm:[`h-5 w-8`,`size-3`,`translate-x-4 rtl:-translate-x-4`],md:[`h-6 w-11`,`size-4`,`translate-x-6 rtl:-translate-x-6`],lg:[`h-8 w-16`,`size-6`,`translate-x-9 rtl:-translate-x-9`]};function os({className:e,size:r=`md`,value:i,onChange:a,children:o,disabled:s,...c}){let[l,u,d]=as[r],f=t(Wr.Root,{"data-slot":`switch`,checked:i,onCheckedChange:a,disabled:s,...c,className:$(`data-[state=checked]:bg-primary data-[state=unchecked]:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 shrink-0 rounded-full border focus-visible:ring-3 aria-invalid:ring-3 peer group/switch relative inline-flex items-center transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,l,!o&&e),children:t(Wr.Thumb,{"data-slot":`switch-thumb`,className:$(`bg-white rounded-full pointer-events-none block ring-0 transition-transform`,u,i?d:`translate-x-1 rtl:-translate-x-1`)})});return o?n(`div`,{className:$(`flex items-center`,e),children:[f,t(`span`,{className:`px-2`,children:o})]}):f}const ss=U.createContext({size:void 0,tabs:void 0,current:void 0,setTab:void 0,responsive:!1,variant:`tabs`,updateHash:!0}),cs=U.forwardRef(({className:e,size:n,variant:r=`tabs`,...i},a)=>t(ss.Provider,{value:{size:n,variant:r},children:t(Gr.List,{ref:a,className:$(r===`tabs`?`border-b -mb-px flex gap-4`:`flex gap-2 p-1 rounded-md`,e),...i})}));cs.displayName=Gr.List.displayName;const ls=U.forwardRef(({className:e,href:n,variant:r=`tabs`,...i},a)=>{let{size:o}=U.useContext(ss),s=U.useCallback(e=>{if(n){e.preventDefault();let t=window.history.state;window.history.pushState(t,``,n)}i.onClick&&i.onClick(e)},[n,i.onClick]);return t(Gr.Trigger,{ref:a,className:$(r===`tabs`?$(`border-b-2 px-2 py-1.5 text-sm font-medium whitespace-nowrap cursor-pointer`,`border-transparent text-muted-foreground hover:border-border hover:text-foreground`,`data-[state=active]:border-primary data-[state=active]:text-primary`,`disabled:pointer-events-none disabled:opacity-50`):$(`px-3 py-1.5 text-sm font-medium whitespace-nowrap cursor-pointer rounded-sm transition-colors`,`tborder border-input bg-muted shadow-xs hover:bg-muted ring-inset`,`data-[state=active]:bg-primary data-[state=active]:text-white data-[state=active]:shadow-sm`,`disabled:pointer-events-none disabled:opacity-50`),e,o?`w-1/${o}`:``),onClick:s,...i})});ls.displayName=Gr.Trigger.displayName;const us=U.forwardRef(({className:e,...n},r)=>t(Gr.Content,{ref:r,className:$(`focus-visible:outline-none`,`flex-1 overflow-y-auto min-h-0 pt-2 pb-4`,e),...n}));us.displayName=Gr.Content.displayName;const ds=Nr(`text-foreground`,{variants:{size:{xl:`text-base md:text-lg leading-relaxed`,lg:`text-base leading-relaxed`,default:`text-sm leading-normal`,sm:`text-sm leading-normal`,xs:`text-xs leading-normal`},weight:{normal:`font-normal`,medium:`font-medium`,semibold:`font-semibold`}},defaultVariants:{size:`default`,weight:`normal`}}),fs=Xe(({className:e,size:n,weight:r,...i},a)=>t(`p`,{ref:a,className:$(ds({size:n,weight:r,className:e})),...i}));fs.displayName=`Text`,Ye({theme:`system`,setTheme:()=>null});function ps(e){switch(e){case`xs`:return`size-2`;case`sm`:return`size-3`;case`md`:return`size-4`;case`lg`:return`size-5`;case`xl`:return`size-7`;case`2xl`:return`size-10`;default:throw Error(`Unexpected size: ${e}`)}}function ms({size:e,className:r}){return n(`svg`,{className:We(`animate-[spin_0.8s_linear_infinite] text-indigo-500`,ps(e||`md`),r),xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,role:`img`,"aria-label":`Loading`,children:[t(`title`,{children:`Loading`}),t(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),t(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]})}function hs(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`oauth-complete`&&`success`in e&&typeof e.success==`boolean`}function gs({onComplete:e,onError:t}){let n=J(null),r=J(e),i=J(t);return K(()=>{r.current=e,i.current=t},[e,t]),K(()=>()=>{n.current&&=(n.current(),null)},[]),{openOAuthPopup:e=>{n.current&&=(n.current(),null);let t=window.screenX+(window.outerWidth-600)/2,a=window.screenY+(window.outerHeight-700)/2,o=window.open(e,`oauth_popup`,`width=600,height=700,left=${t},top=${a},popup=yes`),s=!1,c=null,l=new BroadcastChannel(`oauth-callback`);l.addEventListener(`message`,e=>{hs(e.data)&&(s=!0,l.close(),c&&clearInterval(c),r.current(),!e.data.success&&e.data.error&&i.current?.(e.data.error),n.current=null)}),o&&(c=setInterval(()=>{o.closed&&(c&&clearInterval(c),l.close(),s||r.current(),n.current=null)},1e3)),n.current=()=>{l.close(),c&&clearInterval(c)}}}}function _s({appId:r,collectionId:i,collectionName:a,authenticated:o,onAuthChange:s,onError:c,variant:l=`default`,showLabel:u=!1,showDisconnect:d=!1,readOnly:f=!1}){let{client:p}=Z(),{t:m}=X(),[h,g]=Y(null),[_,v]=Y(o===void 0&&!f),[y,b]=Y(!1),[x,S]=Y(!1),C=o??h?.authenticated??!1,w=a??i,T=`h-6 w-32 justify-center px-2 text-xs`,E=G(async()=>{if(o!==void 0){v(!1);return}if(f){v(!1);return}try{v(!0);let e=await p.remoteMcpConnections.getCollectionStatus(r,i);g(e)}catch(e){console.error(`[RemoteMcpConnectionButton] Failed to load OAuth status:`,e)}finally{v(!1)}},[p,r,i,o,f]);K(()=>{E()},[E]);let{openOAuthPopup:D}=gs({onComplete:()=>{b(!1),E(),s?.()},onError:e=>{console.error(`OAuth failed:`,e),b(!1)}}),O=async()=>{try{b(!0),c?.(null);let e=await p.remoteMcpConnections.authorize(r,i);e.connected?(b(!1),await E(),s?.()):e.authorization_url?D(e.authorization_url):(c?.(`${w}: Authorization URL not provided by server`),b(!1))}catch(e){console.error(`Failed to authorize:`,e);let t=(e instanceof Error?e.original_message??e.message:`Failed to connect`).replace(/^[A-Za-z\s]+:\s/,``);c?.(`${w}: ${t}`),b(!1)}},k=async()=>{try{S(!0),await p.remoteMcpConnections.disconnect(r,i),await E(),s?.()}catch(e){console.error(`Failed to disconnect:`,e)}finally{S(!1)}};return _?l===`compact`?t(Ka,{variant:`outline`,size:`sm`,disabled:!0,className:T,"aria-label":m(`mcpConnections.checkingStatus`),title:m(`mcpConnections.checkingStatus`),children:t(ms,{className:`size-3`})}):t(`div`,{className:`flex items-center gap-2 text-sm`,children:t(ms,{className:`size-4`})}):l===`full`?C?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-sm text-foreground`,children:[w,`:`]}),n(`div`,{className:`flex items-center gap-1 text-success text-sm`,children:[t(gt,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.connected`)})]}),d&&t(Ka,{variant:`ghost`,size:`sm`,onClick:k,disabled:x,children:x?t(ms,{className:`size-4`}):m(`mcpOAuth.disconnect`)})]}):n(`div`,{className:`flex items-center gap-2 text-sm`,children:[u&&n(`span`,{className:`font-medium text-foreground`,children:[w,`:`]}),t(Ka,{variant:`ghost`,size:`sm`,onClick:O,disabled:y,children:y?n(e,{children:[t(ms,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.authenticating`)})]}):n(e,{children:[t(Hn,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.authenticate`)})]})})]}):C?l===`compact`?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[w,`:`]}),!f&&d&&t(Ka,{variant:`outline`,size:`sm`,onClick:k,disabled:x,className:T,children:x?t(ms,{className:`size-3`}):n(e,{children:[t(Xn,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.disconnect`)})]})})]}):n(`div`,{className:`flex items-center gap-1 text-success`,children:[t(gt,{className:`size-4`}),t(`span`,{className:`text-sm`,children:m(`mcpOAuth.connected`)})]}):l===`compact`?f?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[a,`:`]}),t(`div`,{className:`flex items-center gap-1 text-muted`,children:t(`span`,{className:`text-xs`,children:m(`mcpOAuth.notConnected`)})})]}):n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[w,`:`]}),t(Ka,{variant:`outline`,size:`sm`,onClick:O,disabled:y,className:T,children:y?n(e,{children:[t(ms,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.connecting`)})]}):n(e,{children:[t(fn,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.connect`)})]})})]}):t(Ka,{variant:`outline`,size:`sm`,onClick:O,disabled:f||y,children:y?n(e,{children:[t(ms,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.connecting`)})]}):n(e,{children:[t(fn,{className:`size-4 me-1`}),t(`span`,{children:m(`mcpOAuth.connect`)})]})})}const vs=W.createContext({});function ys({children:e,artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}){let o=q(()=>({artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}),[n,r,i,a]);return t(vs.Provider,{value:o,children:e})}function bs(){return W.useContext(vs)}const xs=Ye(null);function Ss(){return Qe(xs)}const Cs={chart:{icon:ut,label:`chart`,defaultHeight:200},mermaid:{icon:$t,label:`diagram`,defaultHeight:150},proposal:{icon:vn,label:`options`,defaultHeight:100},code:{icon:Nt,label:`code`,defaultHeight:80},image:{icon:rn,label:`image`,defaultHeight:150},link:{icon:dn,label:`link`,defaultHeight:24},expand:{icon:Lt,label:`content`,defaultHeight:100},table:{icon:Kn,label:`table`,defaultHeight:150},markdown:{icon:qt,label:`content`,defaultHeight:100},"fusion-fragment":{icon:Nt,label:`fragment`,defaultHeight:150}};function ws({type:e,error:r,onRetry:i,message:a,height:s}){let c=Cs[e],l=s??c.defaultHeight,u=e===`link`;if(r)return n(`div`,{className:`flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive ${u?`inline-flex px-2 py-1 text-sm`:`p-4`}`,style:u?void 0:{minHeight:l},children:[n(`span`,{className:`text-destructive`,children:[`Failed to load `,c.label]}),i&&t(o,{variant:`unstyled`,onClick:i,className:`ms-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors text-destructive`,children:`Retry`})]});let d=c.icon;return u?n(`span`,{className:`inline-flex items-center gap-1 text-muted animate-pulse`,children:[t(d,{className:`h-3 w-3`}),t(`span`,{children:a||`Loading ${c.label}...`})]}):n(`div`,{className:`flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse`,style:{minHeight:l},children:[t(d,{className:`h-8 w-8 text-muted`}),t(`span`,{className:`text-sm text-muted`,children:a||`Loading ${c.label}...`}),t(`div`,{className:`flex gap-1`,children:[...[,,,]].map((e,n)=>t(`div`,{className:`h-2 w-2 rounded-full bg-muted animate-bounce`,style:{animationDelay:`${n*150}ms`}},`dot-${n}`))})]})}var Ts=class extends W.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`CodeBlock rendering error (${this.props.type}):`,e,t),this.props.onError?.(e)}handleRetry=()=>{this.setState({hasError:!1,error:void 0})};render(){if(this.state.hasError){let{type:e,fallbackCode:r}=this.props;return n(`div`,{className:`space-y-2`,children:[t(ws,{type:e,error:this.state.error?.message||`Rendering failed`,onRetry:this.handleRetry}),r&&n(`details`,{className:`text-sm`,children:[t(`summary`,{className:`cursor-pointer text-muted hover:text-foreground`,children:`Show raw content`}),t(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs`,children:t(`code`,{children:r})})]})]})}return this.props.children}};function Es(e,t,n){let r=t.split(`.`).pop()?.toLowerCase();if(r===`svg`)return`mockup`;if([`png`,`jpg`,`jpeg`,`gif`,`webp`].includes(r||``))return`image`;if(r===`md`)return`markdown`;if(r===`csv`)return`table`;if(n===`json`&&typeof e==`object`&&e){let t=e;if(typeof t.$schema==`string`&&t.$schema.includes(`vega`)||t.library===`vega-lite`&&`spec`in t)return`vega-lite`;if(`template`in t&&`data`in t)return`fusion-fragment`;if(Array.isArray(e)&&e.length>0&&typeof e[0]==`object`)return`table`}return`code`}function Ds(e){if(typeof e!=`object`||!e)return null;let t=e;return t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`&&t.spec!==null?t:typeof t.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}function Os({content:e}){let{headers:r,rows:i}=q(()=>{if(!Array.isArray(e)||e.length===0)return{headers:[],rows:[]};let t=e[0];if(typeof t!=`object`||!t)return{headers:[],rows:[]};let n=Object.keys(t);return{headers:n,rows:e.map(e=>n.map(t=>{let n=e[t];return n==null?``:typeof n==`object`?JSON.stringify(n):String(n)}))}},[e]);return r.length===0?t(ws,{type:`table`,error:`No table data found`}):n(`div`,{className:`overflow-x-auto`,children:[n(`table`,{className:`min-w-full text-sm border-collapse`,children:[t(`thead`,{children:t(`tr`,{className:`border-b`,children:r.map(e=>t(`th`,{className:`px-3 py-2 text-start font-medium text-muted`,children:e},e))})}),t(`tbody`,{children:i.slice(0,100).map((e,n)=>t(`tr`,{className:`border-b border-muted/20`,children:e.map((e,n)=>t(`td`,{className:`px-3 py-2`,children:e},`cell-${n}`))},`row-${n}`))})]}),i.length>100&&n(`div`,{className:`text-sm text-muted py-2`,children:[`Showing 100 of `,i.length,` rows`]})]})}function ks({content:e,path:n}){let r=n.split(`.`).pop()?.toLowerCase()||``,i=typeof e==`string`?e:JSON.stringify(e,null,2);return t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{className:`language-${r}`,children:i})})}function As(e){return oi.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:[`use`],FORBID_TAGS:[`foreignObject`]})}function js(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let n=t;if(!/viewBox/i.test(n)){let e=/\swidth\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n),t=/\sheight\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n);e&&t&&(n+=` viewBox="0 0 ${e[1]} ${t[1]}"`)}return n=n.replace(/\swidth\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``).replace(/\sheight\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``),/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}function Ms({content:e}){let n=q(()=>{let t=typeof e==`string`?e.trim():``;return t?js(As(t)):null},[e]);return n?t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}}):t(ws,{type:`expand`,error:`Empty mockup`})}function Ns({content:e,path:n}){return t(`img`,{src:typeof e==`string`?e:``,alt:n.split(`/`).pop()||`Artifact image`,className:`max-w-full h-auto rounded`,loading:`lazy`})}function Ps({content:e,renderType:n,path:r,runId:i,contentType:a}){let{MarkdownRenderer:o}=bs();switch(q(()=>n===`auto`?Es(e,r,a):n,[e,r,a,n])){case`chart`:{let n=Ds(e);return n?t(Ts,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(va,{spec:n,artifactRunId:i})}):t(ws,{type:`chart`,error:`Only Vega-Lite charts are supported. Recharts rendering has been retired.`})}case`vega-lite`:{let n=Ds(e);return n?t(Ts,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(va,{spec:n,artifactRunId:i})}):t(ws,{type:`chart`,error:`Invalid Vega-Lite specification`})}case`fusion-fragment`:{let n=e;return console.log(`[ArtifactContentRenderer] fusion-fragment:`,{hasTemplate:!!n.template,hasData:!!n.data,runId:i,hasVegaLiteChart:!!va}),n.template&&n.data?t(Ts,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(ai,{data:n.data,ChartComponent:va,artifactRunId:i,children:t(ii,{code:JSON.stringify(n.template),data:n.data})})}):t(Ts,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(ii,{code:JSON.stringify(e)})})}case`table`:return t(Ts,{type:`table`,fallbackCode:JSON.stringify(e,null,2),children:t(Os,{content:e})});case`markdown`:{let n=typeof e==`string`?e:String(e);return t(Ts,{type:`markdown`,fallbackCode:n,children:o?t(o,{artifactRunId:i,children:n}):t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{children:n})})})}case`mockup`:return t(Ts,{type:`expand`,fallbackCode:typeof e==`string`?e:r,children:t(Ms,{content:e})});case`image`:return t(Ts,{type:`image`,fallbackCode:r,children:t(Ns,{content:e,path:r})});default:return t(ks,{content:e,path:r})}}const Fs=`Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function Is(e){let t=e.trim(),n=``,r=!1,i=!1;for(let e=0;e<t.length;e++){let a=t[e],o=e>0?t[e-1]:``;if(a===`"`&&!i&&o!==`\\`){r=!r,n+=a;continue}if(a===`'`&&!r&&o!==`\\`){i=!i,n+=a;continue}if((r||i)&&a===`\\`){let r=e;for(;t[r]===`\\`;)r++;if(t[r]===`n`){n+=`<br/>`,e=r;continue}}n+=a}return n}function Ls(e){return e.replace(/<svg([^<>]*)>/i,(e,t)=>{let n=t.replace(/\swidth="[^"]*"/i,``).replace(/\sheight="[^"]*"/i,``);return/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}si.initialize({startOnLoad:!1,theme:`default`,securityLevel:`loose`,fontFamily:Fs,suppressErrorRendering:!0,flowchart:{htmlLabels:!0,useMaxWidth:!0,nodeSpacing:40,rankSpacing:50,padding:12},sequence:{useMaxWidth:!0},themeVariables:{fontFamily:Fs}});function Rs({code:e,className:n}){let r=J(null),[i,a]=Y(null),[o,s]=Y(null),c=$e().replace(/:/g,`_`);return K(()=>{let t=!1;return(async()=>{if(!e.trim()){a(null),s(null);return}try{s(null);let n=`mermaid-${c}-${Date.now()}`,r=Is(e),{svg:i}=await si.render(n,r),o=Ls(i);t||a(o)}catch(e){if(!t){let t=e instanceof Error?e.message:`Failed to render mermaid diagram`;s(t),a(null)}}})(),()=>{t=!0}},[e,c]),o?null:i?t(`div`,{ref:r,className:`my-4 w-full overflow-x-auto [&_svg]:mx-auto [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-w-full ${n||``}`,dangerouslySetInnerHTML:{__html:i}}):t(`div`,{className:`my-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg animate-pulse ${n||``}`,children:t(`div`,{className:`h-32 bg-gray-200 dark:bg-gray-700 rounded`})})}function zs(e){switch(e.split(`.`).pop()?.toLowerCase()){case`json`:return`json`;case`md`:case`txt`:case`csv`:case`yaml`:case`yml`:return`text`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`webp`:case`pdf`:return`binary`;default:return`text`}}function Bs({runId:e,path:t,parseJson:n=!0}){let{client:r}=Z(),i=ta(),a=J(r);a.current=r;let o=J(i);o.current=i;let[s,c]=Y({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l=G(async()=>{if(!e){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No run ID provided`,contentType:void 0});return}if(!t){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No artifact path provided`,contentType:void 0});return}c(e=>({...e,isLoading:!0,error:void 0}));let r=a.current,i=o.current,s=zs(t);try{let a=ra(e,t,`inline`),o;o=i?await i.getOrFetch(a,async()=>(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url):(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url;let l=await fetch(o);if(!l.ok)throw Error(`Failed to fetch artifact: ${l.status} ${l.statusText}`);if(s===`binary`){c({data:o,rawContent:void 0,isLoading:!1,error:void 0,contentType:s});return}let u=await l.text(),d;if(n&&s===`json`)try{d=JSON.parse(u)}catch{d=u}else d=u;c({data:d,rawContent:u,isLoading:!1,error:void 0,contentType:s})}catch(e){let n=e instanceof Error?e.message:`Failed to fetch artifact`;console.error(`Failed to fetch artifact content:`,t,e),c({data:void 0,rawContent:void 0,isLoading:!1,error:n,contentType:s})}},[e,t,n]);K(()=>{l()},[l]);let u=G(()=>{c({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l()},[l]);return{data:s.data,rawContent:s.rawContent,isLoading:s.isLoading,error:s.error,contentType:s.contentType,retry:u}}function Vs(e){let t=e.trim();if(t.length<2)return!0;if(!t.startsWith(`{`))return!1;try{return JSON.parse(t),!1}catch(e){let n=e instanceof Error?e.message:``,r=[`unexpected end`,`unterminated string`,`expected`,`unexpected token`],i=n.toLowerCase();if(r.some(e=>i.includes(e))){let e=0,n=0,r=!1,i=!1;for(let a of t){if(i){i=!1;continue}if(a===`\\`){i=!0;continue}if(a===`"`){r=!r;continue}r||(a===`{`?e++:a===`}`?e--:a===`[`?n++:a===`]`&&n--)}return e>0||n>0||r}return!1}}function Hs(e){try{let t=e.trim(),n=t.indexOf(`{`),r=t.lastIndexOf(`}`);return n!==-1&&r>n&&(t=t.slice(n,r+1)),JSON.parse(t)}catch{return null}}function Us(e){let t=typeof e.$schema==`string`&&e.$schema.includes(`vega`),n=e.library===`vega-lite`&&`spec`in e;return t||n?`vega-lite`:null}function Ws({code:e}){let{artifactRunId:n}=bs();n||console.warn(`[VegaLiteCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=q(()=>Vs(e),[e]),i=q(()=>{if(r)return null;let t=Hs(e);return t?{library:`vega-lite`,spec:t}:null},[e,r]);return r?t(ws,{type:`chart`,message:`Loading chart...`}):i?t(Ts,{type:`chart`,fallbackCode:e,children:t(va,{spec:i,artifactRunId:n})}):t(ws,{type:`chart`,error:`Invalid Vega-Lite specification`})}function Gs({code:e}){let{artifactRunId:n}=bs();n||console.warn(`[ChartCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=q(()=>Vs(e),[e]),i=q(()=>{if(r)return null;let t=Hs(e);return!t||!Us(t)?null:t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`?t:{library:`vega-lite`,spec:t}},[e,r]);return r?t(ws,{type:`chart`,message:`Loading chart...`}):i?t(Ts,{type:`chart`,fallbackCode:e,children:t(va,{spec:i,artifactRunId:n})}):t(ws,{type:`chart`,error:`Invalid Vega-Lite chart specification`})}function Ks({code:e}){let n=e.trim();return n?t(Ts,{type:`mermaid`,fallbackCode:e,children:t(Rs,{code:n})}):t(ws,{type:`mermaid`,error:`Empty diagram`})}function qs({code:e}){let n=q(()=>{let t=e.trim();return t?js(As(t)):null},[e]);return n?t(Ts,{type:`code`,fallbackCode:e,children:t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}})}):t(ws,{type:`code`,error:`Empty mockup`})}function Js({code:e,language:n}){let{artifactRunId:r}=bs(),i=e.trim(),a=q(()=>{if(!n?.includes(`:`))return`auto`;let e=n.split(`:`)[1];return[`chart`,`vega-lite`,`table`,`markdown`,`fusion-fragment`,`mockup`,`code`,`image`,`auto`].includes(e)?e:`auto`},[n]),{data:o,isLoading:s,error:c,contentType:l}=Bs({runId:r,path:i});return r?s?t(ws,{type:`expand`,message:`Loading ${i}...`}):c?t(ws,{type:`expand`,error:`Failed to load artifact: ${c}`}):o===void 0?t(ws,{type:`expand`,error:`No content found in artifact`}):t(Ps,{content:o,renderType:a,path:i,runId:r,contentType:l}):t(ws,{type:`expand`,error:`No artifact run ID available`})}function Ys(e){return e?.startsWith(`expand`)??!1}function Xs(){return{chart:Gs,"vega-lite":Ws,vegalite:Ws,mermaid:Ks,mockup:qs,svg:qs}}function Zs(e){return e.trim().replace(/^\/+/,``)}function Qs(e){return e.startsWith(`artifact:`)?{scheme:`artifact`,path:e.slice(9).trim()}:e.startsWith(`image:`)?{scheme:`image`,path:e.slice(6).trim()}:e.startsWith(`store:`)?{scheme:`store`,path:Zs(e.slice(6))}:e.startsWith(`document:`)?{scheme:`document`,path:Zs(e.slice(9))}:e.startsWith(`collection:`)?{scheme:`collection`,path:Zs(e.slice(11))}:{scheme:`standard`,path:e}}function $s(e,t){switch(e){case`store`:return t?`/store/objects/${t}`:null;case`document`:return t?`/store/objects/${t}`:null;case`collection`:return t?`/store/collections/${t}`:null;default:return null}}function ec({rawUrl:e,artifactRunId:t,disposition:n=`inline`}){let{client:r}=Z(),i=ta(),a=J(r);a.current=r;let o=J(i);o.current=i;let{scheme:s,path:c}=Qs(e),l=$s(s,c),[u,d]=Y(()=>{if(l)return{url:l,isLoading:!1,error:void 0};if(s===`standard`)return{url:e,isLoading:!1,error:void 0};if(i&&(s===`artifact`||s===`image`)){let e;e=s===`artifact`&&t&&!na(c)?ra(t,c,n):ia(c);let r=i.getUrl(e);if(r)return{url:r,isLoading:!1,error:void 0}}return{url:void 0,isLoading:!0,error:void 0}}),f=G(async()=>{if(l||s===`standard`)return;if(s!==`artifact`&&s!==`image`){d({url:void 0,isLoading:!1,error:`Unknown scheme: ${s}`});return}d(e=>({...e,isLoading:!0,error:void 0}));let e=a.current,r=o.current;try{let i;if(s===`artifact`)if(t&&!na(c)){let a=ra(t,c,n);i=r?await r.getOrFetch(a,async()=>(await e.files.getArtifactDownloadUrl(t,c,n)).url):(await e.files.getArtifactDownloadUrl(t,c,n)).url}else{let t=ia(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}else{let t=ia(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}d({url:i,isLoading:!1,error:void 0})}catch(e){let t=e instanceof Error?e.message:`Failed to resolve URL`;console.error(`Failed to resolve URL:`,c,e),d({url:void 0,isLoading:!1,error:t})}},[s,c,t,n,l]);K(()=>{if(u.url&&!u.error)return;let e=!1;return e||(async()=>{await f()})(),()=>{e=!0}},[f,u.url,u.error]);let p=G(()=>{d({url:void 0,isLoading:!0,error:void 0}),f()},[f]);return{url:u.url,isLoading:u.isLoading,error:u.error,scheme:s,retry:p}}function tc({src:e,alt:r,caption:i,className:a,artifactRunId:o}){let s=e||``,{scheme:c}=Qs(s);return c===`standard`?n(`figure`,{className:`my-4`,children:[t(`img`,{src:e,alt:r,className:a}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):t(nc,{rawSrc:s,alt:r,caption:i,artifactRunId:o,className:a})}function nc({rawSrc:e,alt:r,caption:i,artifactRunId:a,className:o}){let{url:s,isLoading:c,error:l,retry:u}=ec({rawUrl:e,artifactRunId:a,disposition:`inline`});return c?t(ws,{type:`image`,message:r?`Loading ${r}...`:void 0}):l?t(ws,{type:`image`,error:l,onRetry:u}):s?n(`figure`,{className:`my-4`,children:[t(`img`,{src:s,alt:r,className:o}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):null}function rc({node:e,src:n,alt:r,className:i,artifactRunId:a,ExistingImg:o,...s}){let c=n||``,{scheme:l}=Qs(c);return l===`standard`?typeof o==`function`?t(o,{node:e,src:n,alt:r,...s}):t(`img`,{src:n,alt:r,className:i,...s}):t(ic,{rawSrc:c,alt:r,artifactRunId:a,className:i,rest:s})}function ic({rawSrc:e,alt:n,artifactRunId:r,className:i,rest:a}){let{url:o,isLoading:s,error:c,retry:l}=ec({rawUrl:e,artifactRunId:r,disposition:`inline`});return s?t(ws,{type:`image`,message:n?`Loading ${n}...`:void 0}):c?t(ws,{type:`image`,error:c,onRetry:l}):o?t(`img`,{src:o,alt:n,className:i,...a}):null}function ac({node:e,href:n,children:r,className:i,artifactRunId:a,ExistingLink:o,...s}){let c=n||``,{scheme:l,path:u}=Qs(c),d=$s(l,u);return d?typeof o==`function`?t(o,{node:e,href:d,...s,children:r}):t(`a`,{href:d,...s,className:i,target:`_blank`,rel:`noopener noreferrer`,children:r}):l===`standard`?typeof o==`function`?t(o,{node:e,href:n,...s,children:r}):t(`a`,{href:n,...s,className:i,target:`_blank`,rel:`noopener noreferrer`,children:r}):t(oc,{rawHref:c,artifactRunId:a,className:i,rest:s,children:r})}function oc({rawHref:e,artifactRunId:n,className:r,children:i,rest:a}){let{url:o,isLoading:s,error:c,retry:l}=ec({rawUrl:e,artifactRunId:n,disposition:`attachment`});return s?t(`span`,{className:`inline-flex items-center gap-1 text-muted`,children:t(ws,{type:`link`})}):c?t(`span`,{className:`inline-flex items-center gap-1`,children:t(ws,{type:`link`,error:c,onRetry:l})}):t(`a`,{href:o||`#`,...a,className:r,target:`_blank`,rel:`noopener noreferrer`,children:i})}const sc=[`artifact:`,`image:`,`store:`,`document://`,`collection:`],cc=/(!?\[[^[\]\n]*\]\()((?:artifact:|image:|store:|document:\/\/|collection:)[^)[\n]+)(\))/g,lc=/`[^`\n]*`/g,uc=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,dc=/\s+("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\([^)]*\))\s*$/;function fc(e){return sc.some(t=>e.startsWith(t))}function pc(e){let t=e.trim();if(t.startsWith(`<`)){let n=t.indexOf(`>`);if(n>0&&fc(t.slice(1,n).trim()))return e}let n=t.match(dc)?.index??-1,r=(n>=0?t.slice(0,n):t).trim(),i=n>=0?t.slice(n):``;return fc(r)?`<${r}>${i}`:e}function mc(e){return e.replace(cc,(e,t,n,r)=>`${t}${pc(n)}${r}`)}function hc(e){let t=``,n=0;for(let r of e.matchAll(lc))t+=mc(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=mc(e.slice(n)),t}function gc(e){if(!e||!sc.some(t=>e.includes(t)))return e;let t=``,n=0;for(let r of e.matchAll(uc))t+=hc(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=hc(e.slice(n)),t}const _c=/^([ \t]*):::([^\n]*?):::[ \t]*$/gm,vc=/^\w+/;function yc(e){return e?.includes(`:::`)?e.replace(_c,(e,t,n)=>{let r=n.trim(),i=vc.exec(r);if(!i)return e;let a=i[0],o=r.slice(a.length).trim();return o?`${t}:::${a}\n${t}${o}\n${t}:::`:`${t}::${a}`}):e}const bc=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,xc=/`[^`\n]*`/g,Sc=/\\\$/g,Cc=/\\[^\s]/,wc=/[{}]/,Tc=/[_^][\w{]/,Ec=/^[a-zA-Z]$/,Dc=/^[a-zA-Z]\s*=/,Oc=/^\s/,kc=/\s$/,Ac=/[+*/-]$/,jc=/\^[+-]$/;function Mc(e){return Cc.test(e)||wc.test(e)||Tc.test(e)||Ec.test(e)||Dc.test(e)}function Nc(e){return!!(Oc.test(e)||kc.test(e)||Ac.test(e)&&!jc.test(e))}function Pc(e){let t=[];for(let n=0;n<e.length;n++)if(e[n]===`$`&&!(n>0&&e[n-1]===`\\`)){if(n+1<e.length&&e[n+1]===`$`){n++;continue}n>0&&e[n-1]===`$`&&(n<2||e[n-2]!==`\\`)||t.push(n)}return t}function Fc(e,t,n){let r=e.slice(t+1,n);return r.length===0||r.includes(`
|
|
4
|
-
`)?null:r}function Ic(e){let t=Pc(e);if(t.length<2)return e;let n=new Set,r=new Set,i=Array(t.length-1);for(let n=0;n<t.length-1;n++)i[n]=Fc(e,t[n],t[n+1]);let a=[];for(let e=0;e<t.length-1;e++){if(n.has(e))continue;let r=i[e];r!==null&&Mc(r)&&(n.add(e),n.add(e+1),a.push([t[e],t[e+1]]))}let o=0;for(;o<t.length;){if(n.has(o)){o++;continue}let e=o+1;for(;e<t.length&&n.has(e);)e++;if(e>=t.length)break;if(e>o+1){r.add(t[o]),o++;continue}let a=i[o];if(a===null){o++;continue}Nc(a)&&(r.add(t[o]),r.add(t[e])),n.add(o),n.add(e),o=e+1}for(let e=0;e<t.length;e++)n.has(e)||e+1<t.length&&n.has(e+1)&&r.add(t[e]);if(r.size===0&&a.length===0)return e;let s=[],c=0,l=Array.from(r).sort((e,t)=>e-t),u=0,d=0;for(;u<l.length||d<a.length;){let t=u<l.length?l[u]:1/0;if(t<(d<a.length?a[d][0]:1/0))t>c&&s.push(e.slice(c,t)),s.push(`\\$`),c=t+1,u++;else{let[t,n]=a[d];t>c&&s.push(e.slice(c,t));let r=e.slice(t,n+1);for(s.push(r.replace(Sc,`\\text{\\textdollar}`)),c=n+1;u<l.length&&l[u]<=n;)u++;d++}}return c<e.length&&s.push(e.slice(c)),s.join(``)}function Lc(e){let t=[],n=0;for(let r of e.matchAll(xc))t.push(Ic(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(Ic(e.slice(n))),t.join(``)}function Rc(e){if(!e?.includes(`$`))return e;let t=[],n=0;for(let r of e.matchAll(bc))t.push(Lc(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(Lc(e.slice(n))),t.join(``)}const zc={note:`md-callout-info`,tip:`md-callout-info`,warning:`md-callout-attention`,important:`md-callout-attention`,caution:`md-callout-destructive`},Bc={note:`Note`,tip:`Tip`,warning:`Warning`,important:`Important`,caution:`Caution`};function Vc(){return e=>{ri(e,e=>{if(e.type!==`containerDirective`&&e.type!==`leafDirective`&&e.type!==`textDirective`)return;let t=e;t.data||={};let n=t.data,r=t.attributes||{},i=t.name;if(i===`pagebreak`){n.hName=`hr`,n.hProperties={className:`md-pagebreak`};return}if(i===`columns`){n.hName=`div`,n.hProperties={className:`md-columns`};return}if(i===`column`){n.hName=`div`;let e={className:`md-column`};r.width&&(e.style=`flex-basis:${r.width};flex-grow:0;flex-shrink:0`),n.hProperties=e;return}if(i in zc){n.hName=`div`,n.hProperties={className:`md-callout ${zc[i]}`,"data-callout-type":i};let e=Bc[i];if(e&&t.children){let n={type:`paragraph`,data:{hName:`p`,hProperties:{className:`md-callout-title`}},children:[{type:`text`,value:e}]};t.children.unshift(n)}return}n.hName=`div`,n.hProperties={className:`md-${i}`,...Object.fromEntries(Object.entries(r).filter(([e])=>e!==`class`))},r.class&&(n.hProperties.className+=` ${r.class}`)})}}const Hc=[`artifact:`,`image:`,`store:`,`document:`,`document://`,`collection:`];function Uc(e){return Hc.some(t=>e.startsWith(t))?e:qr(e)}function Wc(){return e=>{ri(e,`html`,(e,t,n)=>{let r=e,i=n;if(typeof r.value==`string`&&/<!--[\s\S]*?-->/.test(r.value)&&i?.children&&typeof t==`number`)return i.children.splice(t,1),[ni,t]})}}const Gc=Xs();function Kc({children:e,components:n,remarkPlugins:r=[],removeComments:i=!0,artifactRunId:a,className:o,codeClassName:s,inlineCodeClassName:c,linkClassName:l,imageClassName:u,onProposalSelect:d,onProposalSubmit:f}){let p=Ss(),m=W.useMemo(()=>yc(gc(Rc(e))),[e]),h=t(ys,{artifactRunId:a,onProposalSelect:d,onProposalSubmit:f,MarkdownRenderer:Kc,children:t(Kr,{remarkPlugins:W.useMemo(()=>{let e=[Qr,Zr,Vc,$r,Xr,ti,ei,...r];return i&&e.push(Wc),e},[r,i]),rehypePlugins:W.useMemo(()=>[Jr],[]),remarkRehypeOptions:W.useMemo(()=>({handlers:{...Yr}}),[]),components:W.useMemo(()=>{let e=n||{},r=e.code,i=e.a,o=e.img,d=({node:e,className:n,children:i,...a})=>{let o=/language-([\w-]+)/.exec(n||``),l=!o,u=o?o[1]:``;if(!l&&u){if(p){let e=p.getComponent(u);if(e)return t(e,{code:String(i||``).trim(),language:u})}if(Ys(u))return t(Js,{code:String(i||``).trim(),language:u});let e=Gc[u];if(e)return t(e,{code:String(i||``).trim(),language:u})}return typeof r==`function`?t(r,{node:e,className:n,...a,children:i}):t(`code`,{...a,className:l?`px-1.5 py-0.5 rounded ${c||``}`:` ${s||``}`,children:i})},f=e=>{let{node:n,href:r,children:o,...s}=e;return t(ac,{node:n,href:r,className:l,artifactRunId:a,ExistingLink:typeof i==`function`?i:void 0,...s,children:o})},m=e=>{let{node:n,src:r,alt:i,title:s,...c}=e;return s?t(tc,{src:r,alt:i,caption:s,className:u,artifactRunId:a}):t(rc,{node:n,src:r,alt:i,className:u,artifactRunId:a,ExistingImg:typeof o==`function`?o:void 0,...c})};return{...e,code:d,a:f,img:m}},[n,a,p,s,c,l,u]),urlTransform:Uc,children:m})});return o?t(`div`,{className:`md-content ${o}`,children:h}):t(`div`,{className:`md-content`,children:h})}const qc={default:{border:`border-s-attention`,bg:`bg-amber-50 dark:bg-amber-900/20`,icon:`text-attention`},warning:{border:`border-s-destructive`,bg:`bg-red-50 dark:bg-red-900/20`,icon:`text-destructive`},info:{border:`border-s-info`,bg:`bg-blue-50 dark:bg-blue-900/20`,icon:`text-info`},success:{border:`border-s-success`,bg:`bg-green-50 dark:bg-green-900/20`,icon:`text-success`}},Jc={default:nn,warning:at,info:vn,success:ht},Yc=`max-h-80 overflow-y-auto overscroll-contain pe-2`;function Xc({question:r,description:i,options:a,onSelect:s,onMultiSelect:c,onSubmit:l,allowFreeResponse:u=!1,multiSelect:d=!1,placeholder:f,submitLabel:p,isLoading:m=!1,icon:h,variant:g=`default`,hideIcon:_=!1,hideBorder:v=!1,compact:y=!1,answered:b=!1,className:x,cardClassName:S,headerClassName:C,iconClassName:w,questionClassName:T,descriptionClassName:E,optionsClassName:D,buttonClassName:O,inputContainerClassName:k,inputClassName:A,submitButtonClassName:j}){let{t:M}=X(),N=f??M(`agent.typeYourResponse`),P=p??M(`agent.send`),[F,I]=W.useState(``),[L,R]=W.useState(new Set),z=W.useRef(null),ee=qc[g],B=Jc[g],te=e=>{R(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ne=()=>{L.size>0&&c&&(c(Array.from(L)),R(new Set))},re=()=>{F.trim()&&l&&(l(F.trim()),I(``))},ie=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),re())},ae=v?``:`border-s-4 ${ee.border}`;if(y){let c=h||t(B,{className:`size-4`}),l=t(`div`,{className:H(`agent-ask-question text-sm leading-6 text-foreground/85`,T),children:t(Kc,{children:r})});return b?t(`div`,{className:H(`my-1.5 font-sans`,x),children:n(`div`,{className:Yc,children:[l,i&&t(`p`,{className:H(`mt-1 text-xs leading-5 text-muted`,E),children:i})]})}):t(`div`,{className:H(`my-2 font-sans`,x),children:n(`div`,{className:H(`rounded-lg border border-border bg-background/60 shadow-none`,S),children:[t(`div`,{className:H(`px-3 py-2`,C),children:n(`div`,{className:`flex items-start gap-2.5`,children:[!_&&t(`div`,{className:H(`mt-1 flex-shrink-0 text-attention`,w),children:c}),t(`div`,{className:`min-w-0 flex-1`,children:n(`div`,{className:Yc,children:[l,i&&t(`p`,{className:H(`mt-1 text-xs leading-5 text-muted`,E),children:i})]})})]})}),a&&a.length>0&&t(`div`,{className:H(`flex flex-col gap-1.5 px-3 pb-3 pt-0`,D),children:d?n(e,{children:[a.map(e=>{let r=L.has(e.id);return n(`label`,{className:H(`flex cursor-pointer items-start gap-2.5 rounded-md border px-3 py-2 text-start transition-colors`,r?`border-info/60 bg-info/10`:`border-border bg-background/70 hover:bg-mixer-muted/15`,m&&`cursor-not-allowed opacity-50`,O),children:[t(`input`,{type:`checkbox`,checked:r,onChange:()=>te(e.id),disabled:m,className:`mt-1 size-4 rounded border-border bg-background text-info focus:ring-info`}),n(`span`,{className:`min-w-0 flex-1`,children:[n(`span`,{className:`flex items-center gap-2 text-sm font-medium leading-5 text-foreground`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`span`,{className:`mt-0.5 block break-words text-xs leading-5 text-muted`,children:e.description})]})]},e.id)}),t(`div`,{className:`pt-1`,children:n(o,{size:`sm`,onClick:ne,disabled:m||L.size===0,className:`inline-flex items-center gap-2`,children:[t(Bn,{className:`size-4`}),L.size>0?M(`agent.submitSelectionCount`,{count:L.size}):M(`agent.submitSelection`)]})})]}):a.map(e=>n(`button`,{type:`button`,onClick:()=>s?.(e.id),disabled:m,className:H(`flex w-full cursor-pointer items-start gap-2.5 rounded-md border border-border bg-background/70 px-3 py-2 text-start transition-colors`,`hover:bg-mixer-muted/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,m&&`cursor-not-allowed opacity-50`,O),children:[t(`span`,{className:`mt-1 size-4 flex-shrink-0 rounded-full border border-border`,"aria-hidden":`true`}),n(`span`,{className:`min-w-0 flex-1`,children:[n(`span`,{className:`flex items-center gap-2 text-sm font-medium leading-5 text-foreground`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`span`,{className:`mt-0.5 block break-words text-xs leading-5 text-muted`,children:e.description})]})]},e.id))}),u&&t(`div`,{className:H(`px-3 pb-3 pt-0`,k),children:n(`div`,{className:`flex gap-2`,children:[t(`input`,{ref:z,type:`text`,value:F,onChange:e=>I(e.target.value),onKeyDown:ie,placeholder:N,disabled:m,className:H(`min-w-0 flex-1 rounded-md border border-border bg-background/70 px-3 py-2 text-sm text-foreground focus:border-transparent focus:ring-2 focus:ring-ring`,A)}),t(o,{size:`sm`,onClick:re,disabled:m||!F.trim(),className:j,children:m?`...`:P})]})})]})})}return t(`div`,{className:`my-4 font-sans ${x||``}`,children:n(`div`,{className:`${ae} ${ee.bg} rounded-e-lg shadow-sm ${S||``}`,children:[t(`div`,{className:`px-4 py-3 ${C||``}`,children:n(`div`,{className:`flex items-start gap-3`,children:[!_&&t(`div`,{className:`flex-shrink-0 mt-0.5 ${ee.icon} ${w||``}`,children:h||t(B,{className:`size-5`})}),t(`div`,{className:`min-w-0 flex-1`,children:n(`div`,{className:Yc,children:[t(`div`,{className:`agent-ask-question prose prose-sm dark:prose-invert max-w-none text-gray-900 dark:text-gray-100 ${T||``}`,children:t(Kc,{children:r})}),i&&t(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400 ${E||``}`,children:i})]})})]})}),a&&a.length>0&&t(`div`,{className:`px-4 pb-3 pt-1 ${D||``}`,children:d?n(`div`,{className:`space-y-2`,children:[a.map(e=>n(`label`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg cursor-pointer transition-colors
|
|
3
|
+
flex items-center justify-center size-6 rounded end-2`,"aria-label":`Clear input`,children:t(yr,{size:16})})]})});xs.displayName=`Input`,W.createContext({filters:[],setFilters:()=>void 0,filterGroups:[]});var Ss;(function(e){e.IS=`is`,e.IS_NOT=`is_not`,e.CONTAINS=`contains`,e.BEFORE=`before`,e.AFTER=`after`,e.IS_ANY_OF=`is_any_of`})(Ss||={});const Cs=rt(({className:e,level:n=3,...r},i)=>t(`h${n}`,{ref:i,className:$({h1:`text-2xl font-medium tracking-tight`,h2:`text-xl font-medium tracking-tight`,h3:`text-lg font-medium`,h4:`text-base font-medium`,h5:`text-sm font-medium`,h6:`text-xs font-medium`}[`h${n}`],`mb-2`,e),...r}));Cs.displayName=`Heading`;const ws=Zr(`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`),Ts=U.forwardRef(({className:e,required:r,...i},a)=>n(ai.Root,{ref:a,className:$(ws(),e),...i,children:[i.children,r&&t(`span`,{className:`text-destructive-foreground ms-1`,children:`*`})]}));Ts.displayName=ai.Root.displayName,nt(()=>{});const Es=U.forwardRef(({className:e,orientation:n=`horizontal`,decorative:r=!0,...i},a)=>t(oi.Root,{ref:a,decorative:r,orientation:n,className:$(`shrink-0 bg-border`,n===`horizontal`?`h-[1px] w-full`:`h-full w-[1px]`,e),...i}));Es.displayName=oi.Root.displayName;const Ds=U.forwardRef(({className:e,trackClassName:r,rangeClassName:i,thumbClassName:a,value:o,defaultValue:s,min:c=0,max:l=100,"aria-label":u,...d},f)=>{let p=U.useId(),m=Array.isArray(o)?o.length:Array.isArray(s)?s.length:1,h=U.useMemo(()=>Array.from({length:Math.max(1,m)},(e,t)=>`${p}-thumb-${t}`),[p,m]);return n(si.Root,{ref:f,"data-slot":`slider`,value:o,defaultValue:s,min:c,max:l,...d,className:$(`relative flex w-full touch-none select-none items-center data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col`,e),children:[t(si.Track,{"data-slot":`slider-track`,className:$(`relative h-1.5 w-full grow overflow-hidden rounded-full bg-muted data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5`,r),children:t(si.Range,{"data-slot":`slider-range`,className:$(`absolute h-full bg-primary data-[orientation=vertical]:w-full`,i)})}),h.map(e=>t(si.Thumb,{"data-slot":`slider-thumb`,"aria-label":u,className:$(`block size-3.5 rounded-full border border-primary bg-background shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,a)},e))]})});Ds.displayName=si.Root.displayName;const Os={sm:[`h-5 w-8`,`size-3`,`translate-x-4 rtl:-translate-x-4`],md:[`h-6 w-11`,`size-4`,`translate-x-6 rtl:-translate-x-6`],lg:[`h-8 w-16`,`size-6`,`translate-x-9 rtl:-translate-x-9`]};function ks({className:e,size:r=`md`,value:i,onChange:a,children:o,disabled:s,...c}){let[l,u,d]=Os[r],f=t(ci.Root,{"data-slot":`switch`,checked:i,onCheckedChange:a,disabled:s,...c,className:$(`data-[state=checked]:bg-primary data-[state=unchecked]:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 shrink-0 rounded-full border focus-visible:ring-3 aria-invalid:ring-3 peer group/switch relative inline-flex items-center transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,l,!o&&e),children:t(ci.Thumb,{"data-slot":`switch-thumb`,className:$(`bg-white rounded-full pointer-events-none block ring-0 transition-transform`,u,i?d:`translate-x-1 rtl:-translate-x-1`)})});return o?n(`div`,{className:$(`flex items-center`,e),children:[f,t(`span`,{className:`px-2`,children:o})]}):f}const As=U.createContext({size:void 0,tabs:void 0,current:void 0,setTab:void 0,responsive:!1,variant:`tabs`,updateHash:!0}),js=U.forwardRef(({className:e,size:n,variant:r=`tabs`,...i},a)=>t(As.Provider,{value:{size:n,variant:r},children:t(li.List,{ref:a,className:$(r===`tabs`?`border-b -mb-px flex gap-4`:`flex gap-2 p-1 rounded-md`,e),...i})}));js.displayName=li.List.displayName;const Ms=U.forwardRef(({className:e,href:n,variant:r=`tabs`,...i},a)=>{let{size:o}=U.useContext(As),s=U.useCallback(e=>{if(n){e.preventDefault();let t=window.history.state;window.history.pushState(t,``,n)}i.onClick&&i.onClick(e)},[n,i.onClick]);return t(li.Trigger,{ref:a,className:$(r===`tabs`?$(`border-b-2 px-2 py-1.5 text-sm font-medium whitespace-nowrap cursor-pointer`,`border-transparent text-muted-foreground hover:border-border hover:text-foreground`,`data-[state=active]:border-primary data-[state=active]:text-primary`,`disabled:pointer-events-none disabled:opacity-50`):$(`px-3 py-1.5 text-sm font-medium whitespace-nowrap cursor-pointer rounded-sm transition-colors`,`tborder border-input bg-muted shadow-xs hover:bg-muted ring-inset`,`data-[state=active]:bg-primary data-[state=active]:text-white data-[state=active]:shadow-sm`,`disabled:pointer-events-none disabled:opacity-50`),e,o?`w-1/${o}`:``),onClick:s,...i})});Ms.displayName=li.Trigger.displayName;const Ns=U.forwardRef(({className:e,...n},r)=>t(li.Content,{ref:r,className:$(`focus-visible:outline-none`,`flex-1 overflow-y-auto min-h-0 pt-2 pb-4`,e),...n}));Ns.displayName=li.Content.displayName;const Ps=Zr(`text-foreground`,{variants:{size:{xl:`text-base md:text-lg leading-relaxed`,lg:`text-base leading-relaxed`,default:`text-sm leading-normal`,sm:`text-sm leading-normal`,xs:`text-xs leading-normal`},weight:{normal:`font-normal`,medium:`font-medium`,semibold:`font-semibold`}},defaultVariants:{size:`default`,weight:`normal`}}),Fs=rt(({className:e,size:n,weight:r,...i},a)=>t(`p`,{ref:a,className:$(Ps({size:n,weight:r,className:e})),...i}));Fs.displayName=`Text`,nt({theme:`system`,setTheme:()=>null});function Is(e){switch(e){case`xs`:return`size-2`;case`sm`:return`size-3`;case`md`:return`size-4`;case`lg`:return`size-5`;case`xl`:return`size-7`;case`2xl`:return`size-10`;default:throw Error(`Unexpected size: ${e}`)}}function Ls({size:e,className:r}){return n(`svg`,{className:Ze(`animate-[spin_0.8s_linear_infinite] text-indigo-500`,Is(e||`md`),r),xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,role:`img`,"aria-label":`Loading`,children:[t(`title`,{children:`Loading`}),t(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),t(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]})}function Rs(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`oauth-complete`&&`success`in e&&typeof e.success==`boolean`}function zs({onComplete:e,onError:t}){let n=J(null),r=J(e),i=J(t);return K(()=>{r.current=e,i.current=t},[e,t]),K(()=>()=>{n.current&&=(n.current(),null)},[]),{openOAuthPopup:e=>{n.current&&=(n.current(),null);let t=window.screenX+(window.outerWidth-600)/2,a=window.screenY+(window.outerHeight-700)/2,o=window.open(e,`oauth_popup`,`width=600,height=700,left=${t},top=${a},popup=yes`),s=!1,c=null,l=new BroadcastChannel(`oauth-callback`);l.addEventListener(`message`,e=>{Rs(e.data)&&(s=!0,l.close(),c&&clearInterval(c),r.current(),!e.data.success&&e.data.error&&i.current?.(e.data.error),n.current=null)}),o&&(c=setInterval(()=>{o.closed&&(c&&clearInterval(c),l.close(),s||r.current(),n.current=null)},1e3)),n.current=()=>{l.close(),c&&clearInterval(c)}}}}function Bs({appId:r,collectionId:i,collectionName:a,authenticated:o,onAuthChange:s,onError:c,variant:l=`default`,showLabel:u=!1,showDisconnect:d=!1,readOnly:f=!1}){let{client:p}=Z(),{t:m}=X(),[h,g]=Y(null),[_,v]=Y(o===void 0&&!f),[y,b]=Y(!1),[x,S]=Y(!1),C=o??h?.authenticated??!1,w=a??i,T=`h-6 w-32 justify-center px-2 text-xs`,E=G(async()=>{if(o!==void 0){v(!1);return}if(f){v(!1);return}try{v(!0);let e=await p.remoteMcpConnections.getCollectionStatus(r,i);g(e)}catch(e){console.error(`[RemoteMcpConnectionButton] Failed to load OAuth status:`,e)}finally{v(!1)}},[p,r,i,o,f]);K(()=>{E()},[E]);let{openOAuthPopup:D}=zs({onComplete:()=>{b(!1),E(),s?.()},onError:e=>{console.error(`OAuth failed:`,e),b(!1)}}),O=async()=>{try{b(!0),c?.(null);let e=await p.remoteMcpConnections.authorize(r,i);e.connected?(b(!1),await E(),s?.()):e.authorization_url?D(e.authorization_url):(c?.(`${w}: Authorization URL not provided by server`),b(!1))}catch(e){console.error(`Failed to authorize:`,e);let t=(e instanceof Error?e.original_message??e.message:`Failed to connect`).replace(/^[A-Za-z\s]+:\s/,``);c?.(`${w}: ${t}`),b(!1)}},k=async()=>{try{S(!0),await p.remoteMcpConnections.disconnect(r,i),await E(),s?.()}catch(e){console.error(`Failed to disconnect:`,e)}finally{S(!1)}};return _?l===`compact`?t(go,{variant:`outline`,size:`sm`,disabled:!0,className:T,title:m(`mcpConnections.checkingStatus`),children:t(Ls,{className:`size-3`})}):t(`div`,{className:`flex items-center gap-2 text-sm`,children:t(Ls,{className:`size-4`})}):l===`full`?C?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-sm text-foreground`,children:[w,`:`]}),n(`div`,{className:`flex items-center gap-1 text-success text-sm`,children:[t(Tt,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.connected`)})]}),d&&t(go,{variant:`ghost`,size:`sm`,onClick:k,disabled:x,children:x?t(Ls,{className:`size-4`}):m(`mcpOAuth.disconnect`)})]}):n(`div`,{className:`flex items-center gap-2 text-sm`,children:[u&&n(`span`,{className:`font-medium text-foreground`,children:[w,`:`]}),t(go,{variant:`ghost`,size:`sm`,onClick:O,disabled:y,children:y?n(e,{children:[t(Ls,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.authenticating`)})]}):n(e,{children:[t(rr,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.authenticate`)})]})})]}):C?l===`compact`?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[w,`:`]}),!f&&d&&t(go,{variant:`outline`,size:`sm`,onClick:k,disabled:x,className:T,children:x?t(Ls,{className:`size-3`}):n(e,{children:[t(fr,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.disconnect`)})]})})]}):n(`div`,{className:`flex items-center gap-1 text-success`,children:[t(Tt,{className:`size-4`}),t(`span`,{className:`text-sm`,children:m(`mcpOAuth.connected`)})]}):l===`compact`?f?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[a,`:`]}),t(`div`,{className:`flex items-center gap-1 text-muted`,children:t(`span`,{className:`text-xs`,children:m(`mcpOAuth.notConnected`)})})]}):n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[w,`:`]}),t(go,{variant:`outline`,size:`sm`,onClick:O,disabled:y,className:T,children:y?n(e,{children:[t(Ls,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.connecting`)})]}):n(e,{children:[t(Tn,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.connect`)})]})})]}):t(go,{variant:`outline`,size:`sm`,onClick:O,disabled:f||y,children:y?n(e,{children:[t(Ls,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.connecting`)})]}):n(e,{children:[t(Tn,{className:`size-4 me-1`}),t(`span`,{children:m(`mcpOAuth.connect`)})]})})}const Vs=W.createContext({});function Hs({children:e,artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}){let o=q(()=>({artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}),[n,r,i,a]);return t(Vs.Provider,{value:o,children:e})}function Us(){return W.useContext(Vs)}const Ws=nt(null);function Gs(){return at(Ws)}const Ks={chart:{icon:vt,label:`chart`,defaultHeight:200},mermaid:{icon:fn,label:`diagram`,defaultHeight:150},proposal:{icon:jn,label:`options`,defaultHeight:100},code:{icon:Ut,label:`code`,defaultHeight:80},image:{icon:_n,label:`image`,defaultHeight:150},link:{icon:wn,label:`link`,defaultHeight:24},expand:{icon:qt,label:`content`,defaultHeight:100},table:{icon:cr,label:`table`,defaultHeight:150},markdown:{icon:on,label:`content`,defaultHeight:100},"fusion-fragment":{icon:Ut,label:`fragment`,defaultHeight:150}};function qs({type:e,error:r,onRetry:i,message:a,height:s}){let c=Ks[e],l=s??c.defaultHeight,u=e===`link`;if(r)return n(`div`,{className:`flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive ${u?`inline-flex px-2 py-1 text-sm`:`p-4`}`,style:u?void 0:{minHeight:l},children:[n(`span`,{className:`text-destructive`,children:[`Failed to load `,c.label]}),i&&t(o,{variant:`unstyled`,onClick:i,className:`ms-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors text-destructive`,children:`Retry`})]});let d=c.icon;return u?n(`span`,{className:`inline-flex items-center gap-1 text-muted animate-pulse`,children:[t(d,{className:`h-3 w-3`}),t(`span`,{children:a||`Loading ${c.label}...`})]}):n(`div`,{className:`flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse`,style:{minHeight:l},children:[t(d,{className:`h-8 w-8 text-muted`}),t(`span`,{className:`text-sm text-muted`,children:a||`Loading ${c.label}...`}),t(`div`,{className:`flex gap-1`,children:[...[,,,]].map((e,n)=>t(`div`,{className:`h-2 w-2 rounded-full bg-muted animate-bounce`,style:{animationDelay:`${n*150}ms`}},`dot-${n}`))})]})}var Js=class extends W.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`CodeBlock rendering error (${this.props.type}):`,e,t),this.props.onError?.(e)}handleRetry=()=>{this.setState({hasError:!1,error:void 0})};render(){if(this.state.hasError){let{type:e,fallbackCode:r}=this.props;return n(`div`,{className:`space-y-2`,children:[t(qs,{type:e,error:this.state.error?.message||`Rendering failed`,onRetry:this.handleRetry}),r&&n(`details`,{className:`text-sm`,children:[t(`summary`,{className:`cursor-pointer text-muted hover:text-foreground`,children:`Show raw content`}),t(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs`,children:t(`code`,{children:r})})]})]})}return this.props.children}};function Ys(e,t,n){let r=t.split(`.`).pop()?.toLowerCase();if(r===`svg`)return`mockup`;if([`png`,`jpg`,`jpeg`,`gif`,`webp`].includes(r||``))return`image`;if(r===`md`)return`markdown`;if(r===`csv`)return`table`;if(n===`json`&&typeof e==`object`&&e){let t=e;if(typeof t.$schema==`string`&&t.$schema.includes(`vega`)||t.library===`vega-lite`&&`spec`in t)return`vega-lite`;if(`template`in t&&`data`in t)return`fusion-fragment`;if(Array.isArray(e)&&e.length>0&&typeof e[0]==`object`)return`table`}return`code`}function Xs(e){if(typeof e!=`object`||!e)return null;let t=e;return t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`&&t.spec!==null?t:typeof t.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}function Zs({content:e}){let{headers:r,rows:i}=q(()=>{if(!Array.isArray(e)||e.length===0)return{headers:[],rows:[]};let t=e[0];if(typeof t!=`object`||!t)return{headers:[],rows:[]};let n=Object.keys(t);return{headers:n,rows:e.map(e=>n.map(t=>{let n=e[t];return n==null?``:typeof n==`object`?JSON.stringify(n):String(n)}))}},[e]);return r.length===0?t(qs,{type:`table`,error:`No table data found`}):n(`div`,{className:`overflow-x-auto`,children:[n(`table`,{className:`min-w-full text-sm border-collapse`,children:[t(`thead`,{children:t(`tr`,{className:`border-b`,children:r.map(e=>t(`th`,{className:`px-3 py-2 text-start font-medium text-muted`,children:e},e))})}),t(`tbody`,{children:i.slice(0,100).map((e,n)=>t(`tr`,{className:`border-b border-muted/20`,children:e.map((e,n)=>t(`td`,{className:`px-3 py-2`,children:e},`cell-${n}`))},`row-${n}`))})]}),i.length>100&&n(`div`,{className:`text-sm text-muted py-2`,children:[`Showing 100 of `,i.length,` rows`]})]})}function Qs({content:e,path:n}){let r=n.split(`.`).pop()?.toLowerCase()||``,i=typeof e==`string`?e:JSON.stringify(e,null,2);return t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{className:`language-${r}`,children:i})})}function $s(e){return wi.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:[`use`],FORBID_TAGS:[`foreignObject`]})}function ec(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let n=t;if(!/viewBox/i.test(n)){let e=/\swidth\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n),t=/\sheight\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n);e&&t&&(n+=` viewBox="0 0 ${e[1]} ${t[1]}"`)}return n=n.replace(/\swidth\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``).replace(/\sheight\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``),/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}function tc({content:e}){let n=q(()=>{let t=typeof e==`string`?e.trim():``;return t?ec($s(t)):null},[e]);return n?t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}}):t(qs,{type:`expand`,error:`Empty mockup`})}function nc({content:e,path:n}){return t(`img`,{src:typeof e==`string`?e:``,alt:n.split(`/`).pop()||`Artifact image`,className:`max-w-full h-auto rounded`,loading:`lazy`})}function rc({content:e,renderType:n,path:r,runId:i,contentType:a}){let{MarkdownRenderer:o}=Us();switch(q(()=>n===`auto`?Ys(e,r,a):n,[e,r,a,n])){case`chart`:{let n=Xs(e);return n?t(Js,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(Ba,{spec:n,artifactRunId:i})}):t(qs,{type:`chart`,error:`Only Vega-Lite charts are supported. Recharts rendering has been retired.`})}case`vega-lite`:{let n=Xs(e);return n?t(Js,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(Ba,{spec:n,artifactRunId:i})}):t(qs,{type:`chart`,error:`Invalid Vega-Lite specification`})}case`fusion-fragment`:{let n=e;return console.log(`[ArtifactContentRenderer] fusion-fragment:`,{hasTemplate:!!n.template,hasData:!!n.data,runId:i,hasVegaLiteChart:!!Ba}),n.template&&n.data?t(Js,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(Ci,{data:n.data,ChartComponent:Ba,artifactRunId:i,children:t(Si,{code:JSON.stringify(n.template),data:n.data})})}):t(Js,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(Si,{code:JSON.stringify(e)})})}case`table`:return t(Js,{type:`table`,fallbackCode:JSON.stringify(e,null,2),children:t(Zs,{content:e})});case`markdown`:{let n=typeof e==`string`?e:String(e);return t(Js,{type:`markdown`,fallbackCode:n,children:o?t(o,{artifactRunId:i,children:n}):t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{children:n})})})}case`mockup`:return t(Js,{type:`expand`,fallbackCode:typeof e==`string`?e:r,children:t(tc,{content:e})});case`image`:return t(Js,{type:`image`,fallbackCode:r,children:t(nc,{content:e,path:r})});default:return t(Qs,{content:e,path:r})}}const ic=`Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function ac(e){let t=e.trim(),n=``,r=!1,i=!1;for(let e=0;e<t.length;e++){let a=t[e],o=e>0?t[e-1]:``;if(a===`"`&&!i&&o!==`\\`){r=!r,n+=a;continue}if(a===`'`&&!r&&o!==`\\`){i=!i,n+=a;continue}if((r||i)&&a===`\\`){let r=e;for(;t[r]===`\\`;)r++;if(t[r]===`n`){n+=`<br/>`,e=r;continue}}n+=a}return n}function oc(e){return e.replace(/<svg([^<>]*)>/i,(e,t)=>{let n=t.replace(/\swidth="[^"]*"/i,``).replace(/\sheight="[^"]*"/i,``);return/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}Ti.initialize({startOnLoad:!1,theme:`default`,securityLevel:`loose`,fontFamily:ic,suppressErrorRendering:!0,flowchart:{htmlLabels:!0,useMaxWidth:!0,nodeSpacing:40,rankSpacing:50,padding:12},sequence:{useMaxWidth:!0},themeVariables:{fontFamily:ic}});function sc({code:e,className:n}){let r=J(null),[i,a]=Y(null),[o,s]=Y(null),c=ot().replace(/:/g,`_`);return K(()=>{let t=!1;return(async()=>{if(!e.trim()){a(null),s(null);return}try{s(null);let n=`mermaid-${c}-${Date.now()}`,r=ac(e),{svg:i}=await Ti.render(n,r),o=oc(i);t||a(o)}catch(e){if(!t){let t=e instanceof Error?e.message:`Failed to render mermaid diagram`;s(t),a(null)}}})(),()=>{t=!0}},[e,c]),o?null:i?t(`div`,{ref:r,className:`my-4 w-full overflow-x-auto [&_svg]:mx-auto [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-w-full ${n||``}`,dangerouslySetInnerHTML:{__html:i}}):t(`div`,{className:`my-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg animate-pulse ${n||``}`,children:t(`div`,{className:`h-32 bg-gray-200 dark:bg-gray-700 rounded`})})}function cc(e){switch(e.split(`.`).pop()?.toLowerCase()){case`json`:return`json`;case`md`:case`txt`:case`csv`:case`yaml`:case`yml`:return`text`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`webp`:case`pdf`:return`binary`;default:return`text`}}function lc({runId:e,path:t,parseJson:n=!0}){let{client:r}=Z(),i=Ca(),a=J(r);a.current=r;let o=J(i);o.current=i;let[s,c]=Y({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l=G(async()=>{if(!e){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No run ID provided`,contentType:void 0});return}if(!t){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No artifact path provided`,contentType:void 0});return}c(e=>({...e,isLoading:!0,error:void 0}));let r=a.current,i=o.current,s=cc(t);try{let a=Ta(e,t,`inline`),o;o=i?await i.getOrFetch(a,async()=>(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url):(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url;let l=await fetch(o);if(!l.ok)throw Error(`Failed to fetch artifact: ${l.status} ${l.statusText}`);if(s===`binary`){c({data:o,rawContent:void 0,isLoading:!1,error:void 0,contentType:s});return}let u=await l.text(),d;if(n&&s===`json`)try{d=JSON.parse(u)}catch{d=u}else d=u;c({data:d,rawContent:u,isLoading:!1,error:void 0,contentType:s})}catch(e){let n=e instanceof Error?e.message:`Failed to fetch artifact`;console.error(`Failed to fetch artifact content:`,t,e),c({data:void 0,rawContent:void 0,isLoading:!1,error:n,contentType:s})}},[e,t,n]);K(()=>{l()},[l]);let u=G(()=>{c({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l()},[l]);return{data:s.data,rawContent:s.rawContent,isLoading:s.isLoading,error:s.error,contentType:s.contentType,retry:u}}function uc(e){let t=e.trim();if(t.length<2)return!0;if(!t.startsWith(`{`))return!1;try{return JSON.parse(t),!1}catch(e){let n=e instanceof Error?e.message:``,r=[`unexpected end`,`unterminated string`,`expected`,`unexpected token`],i=n.toLowerCase();if(r.some(e=>i.includes(e))){let e=0,n=0,r=!1,i=!1;for(let a of t){if(i){i=!1;continue}if(a===`\\`){i=!0;continue}if(a===`"`){r=!r;continue}r||(a===`{`?e++:a===`}`?e--:a===`[`?n++:a===`]`&&n--)}return e>0||n>0||r}return!1}}function dc(e){try{let t=e.trim(),n=t.indexOf(`{`),r=t.lastIndexOf(`}`);return n!==-1&&r>n&&(t=t.slice(n,r+1)),JSON.parse(t)}catch{return null}}function fc(e){let t=typeof e.$schema==`string`&&e.$schema.includes(`vega`),n=e.library===`vega-lite`&&`spec`in e;return t||n?`vega-lite`:null}function pc({code:e}){let{artifactRunId:n}=Us();n||console.warn(`[VegaLiteCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=q(()=>uc(e),[e]),i=q(()=>{if(r)return null;let t=dc(e);return t?{library:`vega-lite`,spec:t}:null},[e,r]);return r?t(qs,{type:`chart`,message:`Loading chart...`}):i?t(Js,{type:`chart`,fallbackCode:e,children:t(Ba,{spec:i,artifactRunId:n})}):t(qs,{type:`chart`,error:`Invalid Vega-Lite specification`})}function mc({code:e}){let{artifactRunId:n}=Us();n||console.warn(`[ChartCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=q(()=>uc(e),[e]),i=q(()=>{if(r)return null;let t=dc(e);return!t||!fc(t)?null:t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`?t:{library:`vega-lite`,spec:t}},[e,r]);return r?t(qs,{type:`chart`,message:`Loading chart...`}):i?t(Js,{type:`chart`,fallbackCode:e,children:t(Ba,{spec:i,artifactRunId:n})}):t(qs,{type:`chart`,error:`Invalid Vega-Lite chart specification`})}function hc({code:e}){let n=e.trim();return n?t(Js,{type:`mermaid`,fallbackCode:e,children:t(sc,{code:n})}):t(qs,{type:`mermaid`,error:`Empty diagram`})}function gc({code:e}){let n=q(()=>{let t=e.trim();return t?ec($s(t)):null},[e]);return n?t(Js,{type:`code`,fallbackCode:e,children:t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}})}):t(qs,{type:`code`,error:`Empty mockup`})}function _c({code:e,language:n}){let{artifactRunId:r}=Us(),i=e.trim(),a=q(()=>{if(!n?.includes(`:`))return`auto`;let e=n.split(`:`)[1];return[`chart`,`vega-lite`,`table`,`markdown`,`fusion-fragment`,`mockup`,`code`,`image`,`auto`].includes(e)?e:`auto`},[n]),{data:o,isLoading:s,error:c,contentType:l}=lc({runId:r,path:i});return r?s?t(qs,{type:`expand`,message:`Loading ${i}...`}):c?t(qs,{type:`expand`,error:`Failed to load artifact: ${c}`}):o===void 0?t(qs,{type:`expand`,error:`No content found in artifact`}):t(rc,{content:o,renderType:a,path:i,runId:r,contentType:l}):t(qs,{type:`expand`,error:`No artifact run ID available`})}function vc(e){return e?.startsWith(`expand`)??!1}function yc(){return{chart:mc,"vega-lite":pc,vegalite:pc,mermaid:hc,mockup:gc,svg:gc}}function bc(e){return e.trim().replace(/^\/+/,``)}function xc(e){return e.startsWith(`artifact:`)?{scheme:`artifact`,path:e.slice(9).trim()}:e.startsWith(`image:`)?{scheme:`image`,path:e.slice(6).trim()}:e.startsWith(`store:`)?{scheme:`store`,path:bc(e.slice(6))}:e.startsWith(`document:`)?{scheme:`document`,path:bc(e.slice(9))}:e.startsWith(`collection:`)?{scheme:`collection`,path:bc(e.slice(11))}:{scheme:`standard`,path:e}}function Sc(e,t){switch(e){case`store`:return t?`/store/objects/${t}`:null;case`document`:return t?`/store/objects/${t}`:null;case`collection`:return t?`/store/collections/${t}`:null;default:return null}}function Cc({rawUrl:e,artifactRunId:t,disposition:n=`inline`}){let{client:r}=Z(),i=Ca(),a=J(r);a.current=r;let o=J(i);o.current=i;let{scheme:s,path:c}=xc(e),l=Sc(s,c),[u,d]=Y(()=>{if(l)return{url:l,isLoading:!1,error:void 0};if(s===`standard`)return{url:e,isLoading:!1,error:void 0};if(i&&(s===`artifact`||s===`image`)){let e;e=s===`artifact`&&t&&!wa(c)?Ta(t,c,n):Ea(c);let r=i.getUrl(e);if(r)return{url:r,isLoading:!1,error:void 0}}return{url:void 0,isLoading:!0,error:void 0}}),f=G(async()=>{if(l||s===`standard`)return;if(s!==`artifact`&&s!==`image`){d({url:void 0,isLoading:!1,error:`Unknown scheme: ${s}`});return}d(e=>({...e,isLoading:!0,error:void 0}));let e=a.current,r=o.current;try{let i;if(s===`artifact`)if(t&&!wa(c)){let a=Ta(t,c,n);i=r?await r.getOrFetch(a,async()=>(await e.files.getArtifactDownloadUrl(t,c,n)).url):(await e.files.getArtifactDownloadUrl(t,c,n)).url}else{let t=Ea(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}else{let t=Ea(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}d({url:i,isLoading:!1,error:void 0})}catch(e){let t=e instanceof Error?e.message:`Failed to resolve URL`;console.error(`Failed to resolve URL:`,c,e),d({url:void 0,isLoading:!1,error:t})}},[s,c,t,n,l]);K(()=>{if(u.url&&!u.error)return;let e=!1;return e||(async()=>{await f()})(),()=>{e=!0}},[f,u.url,u.error]);let p=G(()=>{d({url:void 0,isLoading:!0,error:void 0}),f()},[f]);return{url:u.url,isLoading:u.isLoading,error:u.error,scheme:s,retry:p}}function wc({src:e,alt:r,caption:i,className:a,artifactRunId:o}){let s=e||``,{scheme:c}=xc(s);return c===`standard`?n(`figure`,{className:`my-4`,children:[t(`img`,{src:e,alt:r,className:a}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):t(Tc,{rawSrc:s,alt:r,caption:i,artifactRunId:o,className:a})}function Tc({rawSrc:e,alt:r,caption:i,artifactRunId:a,className:o}){let{url:s,isLoading:c,error:l,retry:u}=Cc({rawUrl:e,artifactRunId:a,disposition:`inline`});return c?t(qs,{type:`image`,message:r?`Loading ${r}...`:void 0}):l?t(qs,{type:`image`,error:l,onRetry:u}):s?n(`figure`,{className:`my-4`,children:[t(`img`,{src:s,alt:r,className:o}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):null}function Ec({node:e,src:n,alt:r,className:i,artifactRunId:a,ExistingImg:o,...s}){let c=n||``,{scheme:l}=xc(c);return l===`standard`?typeof o==`function`?t(o,{node:e,src:n,alt:r,...s}):t(`img`,{src:n,alt:r,className:i,...s}):t(Dc,{rawSrc:c,alt:r,artifactRunId:a,className:i,rest:s})}function Dc({rawSrc:e,alt:n,artifactRunId:r,className:i,rest:a}){let{url:o,isLoading:s,error:c,retry:l}=Cc({rawUrl:e,artifactRunId:r,disposition:`inline`});return s?t(qs,{type:`image`,message:n?`Loading ${n}...`:void 0}):c?t(qs,{type:`image`,error:c,onRetry:l}):o?t(`img`,{src:o,alt:n,className:i,...a}):null}function Oc({node:e,href:n,children:r,className:i,artifactRunId:a,ExistingLink:o,...s}){let c=n||``,{scheme:l,path:u}=xc(c),d=Sc(l,u);return d?typeof o==`function`?t(o,{node:e,href:d,...s,children:r}):t(`a`,{href:d,...s,className:i,target:`_blank`,rel:`noopener noreferrer`,children:r}):l===`standard`?typeof o==`function`?t(o,{node:e,href:n,...s,children:r}):t(`a`,{href:n,...s,className:i,target:`_blank`,rel:`noopener noreferrer`,children:r}):t(kc,{rawHref:c,artifactRunId:a,className:i,rest:s,children:r})}function kc({rawHref:e,artifactRunId:n,className:r,children:i,rest:a}){let{url:o,isLoading:s,error:c,retry:l}=Cc({rawUrl:e,artifactRunId:n,disposition:`attachment`});return s?t(`span`,{className:`inline-flex items-center gap-1 text-muted`,children:t(qs,{type:`link`})}):c?t(`span`,{className:`inline-flex items-center gap-1`,children:t(qs,{type:`link`,error:c,onRetry:l})}):t(`a`,{href:o||`#`,...a,className:r,target:`_blank`,rel:`noopener noreferrer`,children:i})}const Ac=[`artifact:`,`image:`,`store:`,`document://`,`collection:`],jc=/(!?\[[^[\]\n]*\]\()((?:artifact:|image:|store:|document:\/\/|collection:)[^)[\n]+)(\))/g,Mc=/`[^`\n]*`/g,Nc=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,Pc=/\s+("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\([^)]*\))\s*$/;function Fc(e){return Ac.some(t=>e.startsWith(t))}function Ic(e){let t=e.trim();if(t.startsWith(`<`)){let n=t.indexOf(`>`);if(n>0&&Fc(t.slice(1,n).trim()))return e}let n=t.match(Pc)?.index??-1,r=(n>=0?t.slice(0,n):t).trim(),i=n>=0?t.slice(n):``;return Fc(r)?`<${r}>${i}`:e}function Lc(e){return e.replace(jc,(e,t,n,r)=>`${t}${Ic(n)}${r}`)}function Rc(e){let t=``,n=0;for(let r of e.matchAll(Mc))t+=Lc(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=Lc(e.slice(n)),t}function zc(e){if(!e||!Ac.some(t=>e.includes(t)))return e;let t=``,n=0;for(let r of e.matchAll(Nc))t+=Rc(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=Rc(e.slice(n)),t}const Bc=/^([ \t]*):::([^\n]*?):::[ \t]*$/gm,Vc=/^\w+/;function Hc(e){return e?.includes(`:::`)?e.replace(Bc,(e,t,n)=>{let r=n.trim(),i=Vc.exec(r);if(!i)return e;let a=i[0],o=r.slice(a.length).trim();return o?`${t}:::${a}\n${t}${o}\n${t}:::`:`${t}::${a}`}):e}const Uc=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,Wc=/`[^`\n]*`/g,Gc=/\\\$/g,Kc=/\\[^\s]/,qc=/[{}]/,Jc=/[_^][\w{]/,Yc=/^[a-zA-Z]$/,Xc=/^[a-zA-Z]\s*=/,Zc=/^\s/,Qc=/\s$/,$c=/[+*/-]$/,el=/\^[+-]$/;function tl(e){return Kc.test(e)||qc.test(e)||Jc.test(e)||Yc.test(e)||Xc.test(e)}function nl(e){return!!(Zc.test(e)||Qc.test(e)||$c.test(e)&&!el.test(e))}function rl(e){let t=[];for(let n=0;n<e.length;n++)if(e[n]===`$`&&!(n>0&&e[n-1]===`\\`)){if(n+1<e.length&&e[n+1]===`$`){n++;continue}n>0&&e[n-1]===`$`&&(n<2||e[n-2]!==`\\`)||t.push(n)}return t}function il(e,t,n){let r=e.slice(t+1,n);return r.length===0||r.includes(`
|
|
4
|
+
`)?null:r}function al(e){let t=rl(e);if(t.length<2)return e;let n=new Set,r=new Set,i=Array(t.length-1);for(let n=0;n<t.length-1;n++)i[n]=il(e,t[n],t[n+1]);let a=[];for(let e=0;e<t.length-1;e++){if(n.has(e))continue;let r=i[e];r!==null&&tl(r)&&(n.add(e),n.add(e+1),a.push([t[e],t[e+1]]))}let o=0;for(;o<t.length;){if(n.has(o)){o++;continue}let e=o+1;for(;e<t.length&&n.has(e);)e++;if(e>=t.length)break;if(e>o+1){r.add(t[o]),o++;continue}let a=i[o];if(a===null){o++;continue}nl(a)&&(r.add(t[o]),r.add(t[e])),n.add(o),n.add(e),o=e+1}for(let e=0;e<t.length;e++)n.has(e)||e+1<t.length&&n.has(e+1)&&r.add(t[e]);if(r.size===0&&a.length===0)return e;let s=[],c=0,l=Array.from(r).sort((e,t)=>e-t),u=0,d=0;for(;u<l.length||d<a.length;){let t=u<l.length?l[u]:1/0;if(t<(d<a.length?a[d][0]:1/0))t>c&&s.push(e.slice(c,t)),s.push(`\\$`),c=t+1,u++;else{let[t,n]=a[d];t>c&&s.push(e.slice(c,t));let r=e.slice(t,n+1);for(s.push(r.replace(Gc,`\\text{\\textdollar}`)),c=n+1;u<l.length&&l[u]<=n;)u++;d++}}return c<e.length&&s.push(e.slice(c)),s.join(``)}function ol(e){let t=[],n=0;for(let r of e.matchAll(Wc))t.push(al(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(al(e.slice(n))),t.join(``)}function sl(e){if(!e?.includes(`$`))return e;let t=[],n=0;for(let r of e.matchAll(Uc))t.push(ol(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(ol(e.slice(n))),t.join(``)}const cl={note:`md-callout-info`,tip:`md-callout-info`,warning:`md-callout-attention`,important:`md-callout-attention`,caution:`md-callout-destructive`},ll={note:`Note`,tip:`Tip`,warning:`Warning`,important:`Important`,caution:`Caution`};function ul(){return e=>{xi(e,e=>{if(e.type!==`containerDirective`&&e.type!==`leafDirective`&&e.type!==`textDirective`)return;let t=e;t.data||={};let n=t.data,r=t.attributes||{},i=t.name;if(i===`pagebreak`){n.hName=`hr`,n.hProperties={className:`md-pagebreak`};return}if(i===`columns`){n.hName=`div`,n.hProperties={className:`md-columns`};return}if(i===`column`){n.hName=`div`;let e={className:`md-column`};r.width&&(e.style=`flex-basis:${r.width};flex-grow:0;flex-shrink:0`),n.hProperties=e;return}if(i in cl){n.hName=`div`,n.hProperties={className:`md-callout ${cl[i]}`,"data-callout-type":i};let e=ll[i];if(e&&t.children){let n={type:`paragraph`,data:{hName:`p`,hProperties:{className:`md-callout-title`}},children:[{type:`text`,value:e}]};t.children.unshift(n)}return}n.hName=`div`,n.hProperties={className:`md-${i}`,...Object.fromEntries(Object.entries(r).filter(([e])=>e!==`class`))},r.class&&(n.hProperties.className+=` ${r.class}`)})}}const dl=[`artifact:`,`image:`,`store:`,`document:`,`document://`,`collection:`];function fl(e){return dl.some(t=>e.startsWith(t))?e:di(e)}function pl(){return e=>{xi(e,`html`,(e,t,n)=>{let r=e,i=n;if(typeof r.value==`string`&&/<!--[\s\S]*?-->/.test(r.value)&&i?.children&&typeof t==`number`)return i.children.splice(t,1),[bi,t]})}}const ml=yc();function hl({children:e,components:n,remarkPlugins:r=[],removeComments:i=!0,artifactRunId:a,className:o,codeClassName:s,inlineCodeClassName:c,linkClassName:l,imageClassName:u,onProposalSelect:d,onProposalSubmit:f}){let p=Gs(),m=W.useMemo(()=>Hc(zc(sl(e))),[e]),h=t(Hs,{artifactRunId:a,onProposalSelect:d,onProposalSubmit:f,MarkdownRenderer:hl,children:t(ui,{remarkPlugins:W.useMemo(()=>{let e=[gi,hi,ul,_i,mi,yi,vi,...r];return i&&e.push(pl),e},[r,i]),rehypePlugins:W.useMemo(()=>[fi],[]),remarkRehypeOptions:W.useMemo(()=>({handlers:{...pi}}),[]),components:W.useMemo(()=>{let e=n||{},r=e.code,i=e.a,o=e.img,d=({node:e,className:n,children:i,...a})=>{let o=/language-([\w-]+)/.exec(n||``),l=!o,u=o?o[1]:``;if(!l&&u){if(p){let e=p.getComponent(u);if(e)return t(e,{code:String(i||``).trim(),language:u})}if(vc(u))return t(_c,{code:String(i||``).trim(),language:u});let e=ml[u];if(e)return t(e,{code:String(i||``).trim(),language:u})}return typeof r==`function`?t(r,{node:e,className:n,...a,children:i}):t(`code`,{...a,className:l?`px-1.5 py-0.5 rounded ${c||``}`:` ${s||``}`,children:i})},f=e=>{let{node:n,href:r,children:o,...s}=e;return t(Oc,{node:n,href:r,className:l,artifactRunId:a,ExistingLink:typeof i==`function`?i:void 0,...s,children:o})},m=e=>{let{node:n,src:r,alt:i,title:s,...c}=e;return s?t(wc,{src:r,alt:i,caption:s,className:u,artifactRunId:a}):t(Ec,{node:n,src:r,alt:i,className:u,artifactRunId:a,ExistingImg:typeof o==`function`?o:void 0,...c})};return{...e,code:d,a:f,img:m}},[n,a,p,s,c,l,u]),urlTransform:fl,children:m})});return o?t(`div`,{className:`md-content ${o}`,children:h}):t(`div`,{className:`md-content`,children:h})}const gl={default:{border:`border-s-attention`,bg:`bg-amber-50 dark:bg-amber-900/20`,icon:`text-attention`},warning:{border:`border-s-destructive`,bg:`bg-red-50 dark:bg-red-900/20`,icon:`text-destructive`},info:{border:`border-s-info`,bg:`bg-blue-50 dark:bg-blue-900/20`,icon:`text-info`},success:{border:`border-s-success`,bg:`bg-green-50 dark:bg-green-900/20`,icon:`text-success`}},_l={default:gn,warning:pt,info:jn,success:wt},vl=`max-h-80 overflow-y-auto overscroll-contain pe-2`;function yl({question:r,description:i,options:a,onSelect:s,onMultiSelect:c,onSubmit:l,allowFreeResponse:u=!1,multiSelect:d=!1,placeholder:f,submitLabel:p,isLoading:m=!1,icon:h,variant:g=`default`,hideIcon:_=!1,hideBorder:v=!1,compact:y=!1,answered:b=!1,className:x,cardClassName:S,headerClassName:C,iconClassName:w,questionClassName:T,descriptionClassName:E,optionsClassName:D,buttonClassName:O,inputContainerClassName:k,inputClassName:A,submitButtonClassName:j}){let{t:M}=X(),N=f??M(`agent.typeYourResponse`),P=p??M(`agent.send`),[F,I]=W.useState(``),[L,R]=W.useState(new Set),ee=W.useRef(null),te=gl[g],z=_l[g],ne=e=>{R(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},B=()=>{L.size>0&&c&&(c(Array.from(L)),R(new Set))},re=()=>{F.trim()&&l&&(l(F.trim()),I(``))},ie=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),re())},ae=v?``:`border-s-4 ${te.border}`;if(y){let c=h||t(z,{className:`size-4`}),l=t(`div`,{className:V(`agent-ask-question text-sm leading-6 text-foreground/85`,T),children:t(hl,{children:r})});return b?t(`div`,{className:V(`my-1.5 font-sans`,x),children:n(`div`,{className:vl,children:[l,i&&t(`p`,{className:V(`mt-1 text-xs leading-5 text-muted`,E),children:i})]})}):t(`div`,{className:V(`my-2 font-sans`,x),children:n(`div`,{className:V(`rounded-lg border border-border bg-background/60 shadow-none`,S),children:[t(`div`,{className:V(`px-3 py-2`,C),children:n(`div`,{className:`flex items-start gap-2.5`,children:[!_&&t(`div`,{className:V(`mt-1 flex-shrink-0 text-attention`,w),children:c}),t(`div`,{className:`min-w-0 flex-1`,children:n(`div`,{className:vl,children:[l,i&&t(`p`,{className:V(`mt-1 text-xs leading-5 text-muted`,E),children:i})]})})]})}),a&&a.length>0&&t(`div`,{className:V(`flex flex-col gap-1.5 px-3 pb-3 pt-0`,D),children:d?n(e,{children:[a.map(e=>{let r=L.has(e.id);return n(`label`,{className:V(`flex cursor-pointer items-start gap-2.5 rounded-md border px-3 py-2 text-start transition-colors`,r?`border-info/60 bg-info/10`:`border-border bg-background/70 hover:bg-mixer-muted/15`,m&&`cursor-not-allowed opacity-50`,O),children:[t(`input`,{type:`checkbox`,checked:r,onChange:()=>ne(e.id),disabled:m,className:`mt-1 size-4 rounded border-border bg-background text-info focus:ring-info`}),n(`span`,{className:`min-w-0 flex-1`,children:[n(`span`,{className:`flex items-center gap-2 text-sm font-medium leading-5 text-foreground`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`span`,{className:`mt-0.5 block break-words text-xs leading-5 text-muted`,children:e.description})]})]},e.id)}),t(`div`,{className:`pt-1`,children:n(o,{size:`sm`,onClick:B,disabled:m||L.size===0,className:`inline-flex items-center gap-2`,children:[t(tr,{className:`size-4`}),L.size>0?M(`agent.submitSelectionCount`,{count:L.size}):M(`agent.submitSelection`)]})})]}):a.map(e=>n(`button`,{type:`button`,onClick:()=>s?.(e.id),disabled:m,className:V(`flex w-full cursor-pointer items-start gap-2.5 rounded-md border border-border bg-background/70 px-3 py-2 text-start transition-colors`,`hover:bg-mixer-muted/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,m&&`cursor-not-allowed opacity-50`,O),children:[t(`span`,{className:`mt-1 size-4 flex-shrink-0 rounded-full border border-border`,"aria-hidden":`true`}),n(`span`,{className:`min-w-0 flex-1`,children:[n(`span`,{className:`flex items-center gap-2 text-sm font-medium leading-5 text-foreground`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`span`,{className:`mt-0.5 block break-words text-xs leading-5 text-muted`,children:e.description})]})]},e.id))}),u&&t(`div`,{className:V(`px-3 pb-3 pt-0`,k),children:n(`div`,{className:`flex gap-2`,children:[t(`input`,{ref:ee,type:`text`,value:F,onChange:e=>I(e.target.value),onKeyDown:ie,placeholder:N,disabled:m,className:V(`min-w-0 flex-1 rounded-md border border-border bg-background/70 px-3 py-2 text-sm text-foreground focus:border-transparent focus:ring-2 focus:ring-ring`,A)}),t(o,{size:`sm`,onClick:re,disabled:m||!F.trim(),className:j,children:m?`...`:P})]})})]})})}return t(`div`,{className:`my-4 font-sans ${x||``}`,children:n(`div`,{className:`${ae} ${te.bg} rounded-e-lg shadow-sm ${S||``}`,children:[t(`div`,{className:`px-4 py-3 ${C||``}`,children:n(`div`,{className:`flex items-start gap-3`,children:[!_&&t(`div`,{className:`flex-shrink-0 mt-0.5 ${te.icon} ${w||``}`,children:h||t(z,{className:`size-5`})}),t(`div`,{className:`min-w-0 flex-1`,children:n(`div`,{className:vl,children:[t(`div`,{className:`agent-ask-question prose prose-sm dark:prose-invert max-w-none text-gray-900 dark:text-gray-100 ${T||``}`,children:t(hl,{children:r})}),i&&t(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400 ${E||``}`,children:i})]})})]})}),a&&a.length>0&&t(`div`,{className:`px-4 pb-3 pt-1 ${D||``}`,children:d?n(`div`,{className:`space-y-2`,children:[a.map(e=>n(`label`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg cursor-pointer transition-colors
|
|
5
5
|
${L.has(e.id)?`bg-blue-50 dark:bg-blue-900/30 border border-blue-300 dark:border-blue-700`:`bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700`}
|
|
6
|
-
${m?`opacity-50 cursor-not-allowed`:``}`,children:[t(`input`,{type:`checkbox`,checked:L.has(e.id),onChange:()=>
|
|
6
|
+
${m?`opacity-50 cursor-not-allowed`:``}`,children:[t(`input`,{type:`checkbox`,checked:L.has(e.id),onChange:()=>ne(e.id),disabled:m,className:`mt-0.5 w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700`}),n(`div`,{className:`flex-1 overflow-hidden`,children:[n(`div`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100 break-words`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`div`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400 break-words whitespace-pre-wrap`,children:e.description})]})]},e.id)),t(`div`,{className:`pt-2`,children:n(o,{size:`sm`,onClick:B,disabled:m||L.size===0,className:`flex items-center gap-2`,children:[t(tr,{className:`size-4`}),L.size>0?M(`agent.submitSelectionCount`,{count:L.size}):M(`agent.submitSelection`)]})})]}):t(`div`,{className:`flex flex-col gap-2 w-full`,children:a.map(e=>t(o,{variant:`unstyled`,onClick:()=>s?.(e.id),disabled:m,className:`w-full h-auto whitespace-normal text-start px-4 py-3 rounded-lg border border-gray-200 dark:border-gray-700
|
|
7
7
|
bg-white dark:bg-gray-800
|
|
8
8
|
hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-600
|
|
9
9
|
focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1
|
|
10
10
|
transition-colors
|
|
11
11
|
${m?`opacity-50 cursor-not-allowed`:`cursor-pointer`}
|
|
12
|
-
${O||``}`,children:n(`div`,{className:`flex items-start gap-3`,children:[e.icon&&t(`span`,{className:`flex-shrink-0 mt-0.5 text-gray-500 dark:text-gray-400`,children:e.icon}),n(`div`,{className:`flex-1 overflow-hidden`,children:[t(`div`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100 break-words text-center`,children:e.label}),e.description&&t(`div`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400 break-words whitespace-pre-wrap`,children:e.description})]})]})},e.id))})}),u&&t(`div`,{className:`px-4 pb-3 pt-1 ${k||``}`,children:n(`div`,{className:`flex gap-2`,children:[t(`input`,{ref:
|
|
13
|
-
`).trim()||void 0}function wl(e){return Cl(e.message)}function Tl(e,t){let n=Cl(e.text);if(!n)return!1;let r=e.workstreamId||`main`;return t.some(t=>{if(_l(t.timestamp)<e.startTimestamp||vl(t)!==r)return!1;let i=typeof t.details?.streaming_id==`string`?t.details.streaming_id:void 0;return e.streamingId&&i?!(i!==e.streamingId||t.details?.display_role===`thinking`||Dl(t)||t.details?.tool_status):e.activityId&&t.details?.activity_id===e.activityId?!(t.details?.display_role===`thinking`||Dl(t)||t.details?.tool_status):t.type!==Q.THOUGHT&&t.type!==Q.ANSWER&&t.type!==Q.COMPLETE&&t.type!==Q.IDLE||!t.details?.streamed?!1:wl(t)===n})}function El(e,t){if(vl(e)!==vl(t))return!1;let n=wl(e),r=wl(t);if(!n||n!==r)return!1;let i=_l(e.timestamp);return _l(t.timestamp)-i>1e4?!1:!!(e.type===Q.ANSWER&&(t.type===Q.COMPLETE||t.type===Q.IDLE)||e.type===Q.THOUGHT&&(t.type===Q.ANSWER||t.type===Q.COMPLETE||t.type===Q.IDLE)&&(e.details?.streamed||t.details?.streamed)||e.type===t.type&&(e.details?.streamed||t.details?.streamed)&&(t.type===Q.THOUGHT||t.type===Q.ANSWER||t.type===Q.COMPLETE||t.type===Q.IDLE))}function Dl(e){return e.type===Q.THOUGHT&&!!e.details?.tool}function Ol(e){let t=e.details;return e.type===Q.THOUGHT&&(t?.display_role===`tool_preamble`||t?.tool===`think`)}function kl(e){if(Ol(e))return!1;if(Dl(e))return!0;if(e.type!==Q.THOUGHT)return!1;let t=e.details;return!!(Array.isArray(t?.tools)&&t.tools.length>0)}function Al(e){return e.details?.tool_run_id}function jl(e){return e.details?.tool_iteration}function Ml(e){return e.details?.tool_status}function Nl(e){let t=e.details?.activity_group_id;if(!(typeof t!=`string`||t.trim()===``))return t}function Pl(e,t,n){let r=new Map,i=new Map,a=new Map,o=[];for(let t of e){let e=Nl(t);if(t.type===Q.REQUEST_INPUT||t.type===Q.BATCH_PROGRESS)o.push(t);else if(Ol(t))o.push(t);else if(e)r.has(e)||r.set(e,{messages:[],firstTimestamp:_l(t.timestamp)}),r.get(e)?.messages.push(t);else if(kl(t)){let e=jl(t),n=Al(t);e===void 0?n?(a.has(n)||a.set(n,{messages:[],firstTimestamp:_l(t.timestamp)}),a.get(n)?.messages.push(t)):o.push(t):(i.has(e)||i.set(e,{messages:[],firstTimestamp:_l(t.timestamp)}),i.get(e)?.messages.push(t))}else o.push(t)}let s=[];r.forEach((e,t)=>{s.push({kind:`activity_group`,activityGroupId:t,messages:e.messages,timestamp:e.firstTimestamp})}),i.forEach((e,t)=>{s.push({kind:`iteration_group`,iteration:t,messages:e.messages,timestamp:e.firstTimestamp})}),a.forEach((e,t)=>{s.push({kind:`tool_run`,toolRunId:t,messages:e.messages,timestamp:e.firstTimestamp})});for(let e of o)s.push({kind:`message`,message:e,timestamp:_l(e.timestamp)});t.forEach((t,r)=>{t.text&&(Tl(t,e)||n&&n!==`all`&&n!==(t.workstreamId||`main`)||s.push({kind:`streaming`,streamingId:r,data:t,timestamp:t.startTimestamp}))}),s.sort((e,t)=>{let n=e.kind===`streaming`&&!e.data.isComplete,r=t.kind===`streaming`&&!t.data.isComplete;return n&&!r?1:r&&!n?-1:e.timestamp-t.timestamp});let c=[],l=[],u=()=>{l.length>0&&(l.length===1&&!Ol(l[0])?c.push({type:`single`,message:l[0]}):c.push({type:`tool_group`,messages:l,firstTimestamp:_l(l[0].timestamp)}),l=[])};for(let e of s)if(e.kind===`streaming`)u(),c.push({type:`streaming`,streamingId:e.streamingId,text:e.data.text,workstreamId:e.data.workstreamId,startTimestamp:e.data.startTimestamp,isComplete:e.data.isComplete});else if(e.kind===`activity_group`){u();let t=[...e.messages].sort((e,t)=>_l(e.timestamp)-_l(t.timestamp)),n=t.reduce((e,t)=>Ml(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolRunId:e.activityGroupId,toolStatus:n})}else if(e.kind===`iteration_group`){u();let t=[...e.messages].sort((e,t)=>_l(e.timestamp)-_l(t.timestamp)),n=t.reduce((e,t)=>Ml(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolStatus:n})}else if(e.kind===`tool_run`){u();let t=[...e.messages].sort((e,t)=>_l(e.timestamp)-_l(t.timestamp)),n=t.reduce((e,t)=>Ml(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolRunId:e.toolRunId,toolStatus:n})}else kl(e.message)?l.push(e.message):(u(),c.push({type:`single`,message:e.message}));return u(),c}function Fl(e,t){return t??e}function Il(e){let t=[],n=null,r=()=>{n&&=(t.push({type:`tool_group`,messages:n.messages,firstTimestamp:n.firstTimestamp,toolRunId:n.toolRunId,toolStatus:n.toolStatus,preambleText:n.preambleText,preambleMessage:n.preambleMessage}),null)};for(let i of e)i.type===`tool_group`?n?(n.messages=[...n.messages,...i.messages],n.toolStatus=Fl(n.toolStatus,i.toolStatus),!n.toolRunId&&i.toolRunId&&(n.toolRunId=i.toolRunId),!n.preambleMessage&&i.preambleMessage&&(n.preambleMessage=i.preambleMessage,n.preambleText=i.preambleText)):n={messages:[...i.messages],firstTimestamp:i.firstTimestamp,toolRunId:i.toolRunId,toolStatus:i.toolStatus,preambleText:i.preambleText,preambleMessage:i.preambleMessage}:(r(),t.push(i));return r(),t}function Ll(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function Rl(e){let t=zl(e.details?.tool_approval);if(!t)return Ll(e);let n=Bl(t.tool_title)??Bl(t.tool_name),r=Hl(Bl(t.target));if(n&&r)return`Approve ${n}: ${r}?`;let i=Bl(t.action_summary);return i?`Approve ${Vl(i)}?`:Ll(e)}function zl(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function Bl(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function Vl(e){return e.replace(/:\s*name(?::|\s+)/i,`: `)}function Hl(e){if(!e)return;let t=e.indexOf(`:`);if(t<0)return e;let n=e.slice(0,t),r=e.slice(t+1).trim();if(!r)return e;switch(n){case`document_id`:return`document ${r}`;case`object_id`:return`object ${r}`;case`collection_id`:return`collection ${r}`;case`process_id`:return`process ${r}`;case`process_definition_id`:return`process definition ${r}`;case`interaction_id`:return`interaction ${r}`;case`prompt_id`:return`prompt ${r}`;case`dashboard_id`:return`dashboard ${r}`;case`database_id`:return`database ${r}`;case`table_id`:return`table ${r}`;default:return r}}function Ul(e){let t=e.details;return e.type===Q.REQUEST_INPUT&&!!t?.ux}function Wl(e){let t=e.details;return[t?.request_id,t?.requestId,t?.activity_id,t?.activityId,t?.tool_run_id,t?.toolRunId,e.timestamp,Ll(e)].filter(e=>typeof e==`string`||typeof e==`number`).map(String).join(`|`)}function Gl(e){let t=e.details;return[t?.ack,t?._messageId,t?._deliveryStatus,e.timestamp,vl(e),Ll(e)].filter(e=>typeof e==`string`||typeof e==`number`).map(String).join(`|`)}function Kl(e){let t=new Set;return e.forEach((n,r)=>{if(n.type!==Q.REQUEST_INPUT)return;let i=vl(n);for(let a=r+1;a<e.length;a+=1){let r=e[a];if(vl(r)===i){if(r.type===Q.REQUEST_INPUT)break;if(r.type===Q.QUESTION){t.add(Wl(n));break}}}}),t}function ql(e){let t=new Set;for(let n of e){let e=zl(n.details),r=zl(e?.approval_request)?.approval_key,i=e?.approval_decision;typeof r==`string`&&(i===`denied`||i===`denied_with_feedback`||i===`timeout`||i===`reviewer_denied`||i===`cancelled_after_denial`)&&t.add(r)}return t}function Jl(e){let t=zl(zl(e.details)?.tool_approval)?.approval_key;return typeof t==`string`?t:void 0}function Yl(e){return e.type===Q.REQUEST_INPUT&&Jl(e)!==void 0}function Xl(e){if(e.type!==Q.QUESTION)return!1;let t=Ll(e).trim().toLowerCase();return t===`allow_once`||t===`allow_for_run`||t===`deny`}function Zl(e){if(e.type!==Q.QUESTION)return!1;let t=zl(e.details),n=zl(t?.metadata);return(zl(t?.tool_approval_response)??zl(n?.tool_approval_response))?.decision===`deny_with_feedback`}function Ql(e){return Xl(e)||Zl(e)}function $l(e,t){if(e.type!==Q.REQUEST_INPUT)return!1;let n=Jl(e);return n?t.has(n):!1}function eu(e){let t=new Set;return e.forEach((n,r)=>{if(!Yl(n))return;let i=vl(n);for(let a=r+1;a<e.length;a+=1){let r=e[a];if(vl(r)===i){if(r.type===Q.REQUEST_INPUT)break;if(r.type===Q.QUESTION){Ql(r)&&t.add(Wl(n));break}}}}),t}function tu(e,t,n){return Yl(e)&&(t.has(Wl(e))||$l(e,n))}function nu(e,t){let n=new Set;return e.forEach((r,i)=>{if(!Yl(r)||t&&!$l(r,t))return;let a=vl(r);for(let t=i+1;t<e.length;t+=1){let r=e[t];if(vl(r)===a){if(r.type===Q.REQUEST_INPUT)break;if(r.type===Q.QUESTION){Xl(r)&&n.add(Gl(r));break}}}}),n}function ru(e,t){return e.type===Q.QUESTION&&t.has(Gl(e))}function iu(e,t){return e.type===Q.REQUEST_INPUT&&t.has(Wl(e))}function au(e,t=`main`){let n=Kl(e),r=ql(e);for(let i=e.length-1;i>=0;--i){let a=e[i];if(Ul(a)&&vl(a)===t&&!iu(a,n)&&!$l(a,r))return a}}function ou({mcpConnect:e,onMcpConnected:r,onDecline:i,disabled:a}){let{client:s}=Z(),{t:c}=X();return n(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[t(_s,{appId:e.app_install_id,collectionId:e.collection_id,collectionName:e.name,variant:`default`,onAuthChange:()=>{s.remoteMcpConnections.getCollectionStatus(e.app_install_id,e.collection_id).then(t=>{t.authenticated&&r?.(e)}).catch(()=>{})},readOnly:a}),n(o,{variant:`ghost`,size:`sm`,onClick:i,disabled:a,children:[t(ar,{className:`size-4`}),t(`span`,{children:c(`mcpOAuth.decline`)})]})]})}function su({message:e,onSendMessage:r,onMcpConnected:i,isLoading:a=!1,disabled:o=!1,className:s}){let{t:c}=X();if(!e)return null;let l=e.details.ux,u=l.options??[],d=l.mcp_connect,f=l.free_response,p=o||a||!r,m=Rl(e),h=(e,t)=>{p||(t?r?.(e,t):r?.(e))},g=H(`flex-shrink-0 border-t border-border/70 bg-background/95 backdrop-blur`,`fixed bottom-0 end-0 start-0 z-20 lg:sticky lg:start-auto lg:end-auto`,`pb-safe-area`,s);return d?t(`div`,{className:g,"data-agent-request-input-overlay":!0,children:n(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-3 px-3 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[t(`div`,{className:`min-w-0 text-sm leading-6 text-foreground/85`,children:m}),t(ou,{mcpConnect:d,onMcpConnected:i,onDecline:()=>h(c(`agent.mcpDeclinedMessage`,{name:d.name})),disabled:p})]})}):t(`div`,{className:g,"data-agent-request-input-overlay":!0,children:t(`div`,{className:`mx-auto w-full max-w-3xl px-3 py-3`,children:t(Xc,{question:m,options:u,variant:l.variant,multiSelect:l.multiSelect,allowFreeResponse:u.length===0||!!f,placeholder:f?.placeholder,submitLabel:f?.submit_label,onSelect:h,onMultiSelect:e=>h(e.join(`, `)),onSubmit:e=>h(e,f?.metadata),hideBorder:!0,compact:!0,isLoading:p,className:`my-0`,cardClassName:`bg-background/80 shadow-lg shadow-black/5 dark:shadow-none`})})})}function cu({className:e,inline:r=!1,color:i=`blue`}){let a={blue:`from-blue-400 to-indigo-500 dark:from-blue-500 dark:to-indigo-400`,purple:`from-purple-400 to-violet-500 dark:from-purple-500 dark:to-violet-400`,teal:`from-teal-400 to-emerald-500 dark:from-teal-500 dark:to-emerald-400`,green:`from-green-400 to-emerald-500 dark:from-green-500 dark:to-emerald-400`,amber:`from-amber-400 to-orange-500 dark:from-amber-500 dark:to-orange-400`}[i];return n(`div`,{className:H(`flex items-center gap-1.5`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_infinite]`}),t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_0.2s_infinite]`}),t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_0.4s_infinite]`})]})}function lu({className:e,size:r=`md`,color:i=`blue`}){let a={sm:`w-3 h-3`,md:`w-5 h-5`,lg:`w-7 h-7`},o={blue:`bg-blue-500 dark:bg-blue-400`,purple:`bg-purple-500 dark:bg-purple-400`,teal:`bg-teal-500 dark:bg-teal-400`,green:`bg-green-500 dark:bg-green-400`,amber:`bg-amber-500 dark:bg-amber-400`};return n(`span`,{className:H(`relative flex`,e),children:[t(`span`,{className:H(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,o[i])}),t(`span`,{className:H(`animate-pulse absolute inline-flex h-[80%] w-[80%] rounded-full opacity-80`,o[i]),style:{left:`10%`,top:`10%`,animationDuration:`2s`}}),t(`span`,{className:H(`relative inline-flex rounded-full`,o[i],a[r])})]})}function uu({className:e,color:n=`blue`}){let[r,i]=Y(`.`);return K(()=>{let e=setInterval(()=>{i(e=>e===`.`?`..`:e===`..`?`...`:`.`)},500);return()=>clearInterval(e)},[]),t(`span`,{className:H({blue:`text-blue-600 dark:text-blue-400`,purple:`text-purple-600 dark:text-purple-400`,teal:`text-teal-600 dark:text-teal-400`,green:`text-green-600 dark:text-green-400`,amber:`text-amber-600 dark:text-amber-400`}[n],`font-bold`,e),children:r})}function du({message:e,className:r,color:i=`blue`}){let a={blue:{dot:`bg-blue-500 dark:bg-blue-400`,text:`text-blue-700 dark:text-blue-300`},purple:{dot:`bg-purple-500 dark:bg-purple-400`,text:`text-purple-700 dark:text-purple-300`},teal:{dot:`bg-teal-500 dark:bg-teal-400`,text:`text-teal-700 dark:text-teal-300`},green:{dot:`bg-green-500 dark:bg-green-400`,text:`text-green-700 dark:text-green-300`},amber:{dot:`bg-amber-500 dark:bg-amber-400`,text:`text-amber-700 dark:text-amber-300`}};return n(`div`,{className:H(`flex items-center gap-2 py-1`,r),children:[n(`div`,{className:`flex gap-1`,children:[t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`}),t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`,style:{animationDelay:`0.2s`}}),t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`,style:{animationDelay:`0.4s`}})]}),t(`div`,{className:`${a[i].text} font-medium text-xs`,children:e})]})}function fu({className:e,color:r=`blue`,width:i=`md`,message:a}){let[o,s]=Y(15),[c,l]=Y(`increasing`),[u,d]=Y(.4),f=J(null),p=J(!0);return K(()=>{let e=f.current;if(!e)return;let t=new IntersectionObserver(([e])=>{p.current=e.isIntersecting},{threshold:0});return t.observe(e),()=>t.disconnect()},[]),K(()=>{let e,t=Date.now(),n=()=>{if(!p.current){e=requestAnimationFrame(n);return}let r=Date.now(),i=r-t;t=r,s(e=>{let t=i/16*u,n=c===`increasing`?e+t:e-t;return n>=85?(l(`decreasing`),d(.3+Math.random()*.2),85):n<=15?(l(`increasing`),d(.3+Math.random()*.2),15):(Math.random()>.99&&d(e=>Math.max(.2,Math.min(.5,e+(Math.random()*.1-.05)))),n)}),e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>{cancelAnimationFrame(e)}},[c,u]),n(`div`,{ref:f,className:H(`flex flex-col gap-1`,e),children:[a&&t(`div`,{className:`text-xs font-medium ${{blue:`text-blue-700 dark:text-blue-300`,purple:`text-purple-700 dark:text-purple-300`,teal:`text-teal-700 dark:text-teal-300`,green:`text-green-700 dark:text-green-300`,amber:`text-amber-700 dark:text-amber-300`}[r]} mb-1`,children:a}),t(`div`,{className:H(`h-1.5 rounded-full overflow-hidden shadow-inner`,{blue:`bg-blue-200 dark:bg-blue-900/30`,purple:`bg-purple-200 dark:bg-purple-900/30`,teal:`bg-teal-200 dark:bg-teal-900/30`,green:`bg-green-200 dark:bg-green-900/30`,amber:`bg-amber-200 dark:bg-amber-900/30`}[r],{sm:`w-24`,md:`w-32`,lg:`w-48`,xl:`w-64`,full:`w-full`}[i]),children:t(`div`,{className:H(`h-full rounded-full`,{blue:`bg-gradient-to-r from-blue-400 to-blue-500 dark:from-blue-500 dark:to-blue-400`,purple:`bg-gradient-to-r from-purple-400 to-purple-500 dark:from-purple-500 dark:to-purple-400`,teal:`bg-gradient-to-r from-teal-400 to-teal-500 dark:from-teal-500 dark:to-teal-400`,green:`bg-gradient-to-r from-green-400 to-green-500 dark:from-green-500 dark:to-green-400`,amber:`bg-gradient-to-r from-amber-400 to-amber-500 dark:from-amber-500 dark:to-amber-400`}[r]),style:{width:`${o}%`,transition:`width 150ms cubic-bezier(0.4, 0.0, 0.2, 1)`}})})]})}function pu({className:e,color:n=`blue`,size:r=`md`}){let[i,a]=Y(Array(7).fill(50)),o=J(null),s=J(!0);K(()=>{let e=o.current;if(!e)return;let t=new IntersectionObserver(([e])=>{s.current=e.isIntersecting},{threshold:0});return t.observe(e),()=>t.disconnect()},[]);let c={sm:{width:`w-16`,height:`h-4`,barWidth:`w-0.5`,gap:`gap-[2px]`},md:{width:`w-20`,height:`h-5`,barWidth:`w-1`,gap:`gap-[3px]`},lg:{width:`w-24`,height:`h-6`,barWidth:`w-1.5`,gap:`gap-1`}},l={blue:`bg-gradient-to-b from-blue-400 to-blue-500 dark:from-blue-400 dark:to-blue-500`,purple:`bg-gradient-to-b from-purple-400 to-purple-500 dark:from-purple-400 dark:to-purple-500`,teal:`bg-gradient-to-b from-teal-400 to-teal-500 dark:from-teal-400 dark:to-teal-500`,green:`bg-gradient-to-b from-green-400 to-green-500 dark:from-green-400 dark:to-green-500`,amber:`bg-gradient-to-b from-amber-400 to-amber-500 dark:from-amber-400 dark:to-amber-500`};return K(()=>{let e,t=[1.2,1,1.5,.8,1.3,.9,1.1],n=[0,.5,1,1.5,2,2.5,3],r=0,i=()=>{if(!s.current){e=requestAnimationFrame(i);return}r+=.02;let o=Array(7).fill(0).map((e,i)=>10+(Math.sin(r*t[i]+n[i])+1)*40);a(o),e=requestAnimationFrame(i)};return e=requestAnimationFrame(i),()=>{cancelAnimationFrame(e)}},[]),t(`div`,{ref:o,className:H(`flex items-end justify-center`,c[r].width,c[r].height,c[r].gap,e),children:i.map((e,i)=>t(`div`,{className:H(c[r].barWidth,`rounded-full transform-gpu`,l[n]),style:{height:`${e}%`,transition:`height 100ms cubic-bezier(0.4, 0.0, 0.2, 1)`,opacity:.9}},`bar-${i}`))})}const mu=`Brewing some code magic...(Doing the robot dance...(Cooking up something good...(Working my gears...(Parsing the possibilities...(Crunching the numbers...(Connecting the digital dots...(Processing at maximum capacity...(Searching through my circuits...(Running advanced algorithms...(Computing optimal solutions...(Loading brilliance.exe...(Scanning the knowledge base...(Optimizing response protocols...(Having a quick brainstorm...(Thinking cap firmly on...(Pondering the digital universe...(Consulting my silicon wisdom...(Untangling the logic knots...(Assembling clever responses...(Mixing thoughtful ingredients...(Polishing the perfect answer...(Taking a momentary mind sprint...(Connecting virtual synapses...(Baking fresh ideas...(Stirring the thought pot...(Simmering solutions slowly...(Whipping up a smart response...(Adding a dash of intelligence...(Preparing a gourmet answer...(Growing brilliant ideas...(Cultivating the perfect response...(Gathering digital nectar...(Planting seeds of solutions...(Exploring the data landscape...(Mapping the solution path...(Navigating through possibilities...(Charting the course to answers...(Embarking on a thought expedition...(Sketching out concepts...(Painting with digital brushstrokes...(Composing my response symphony...(Crafting precision answers...(Weaving threads of information...(Just a moment of processing...(Taking a quick thinking break...(Almost there, final touches...(Putting the pieces together...(Making progress, hold tight...`.split(`(`),hu=Ye(null);function gu(){return Qe(hu)||{openImage:e=>window.open(e,`_blank`),closeImage:()=>{}}}function _u({children:e}){let[r,i]=Y(null),a=G((e,t)=>{i({src:e,alt:t})},[]),s=G(()=>{i(null)},[]),{t:c}=X();return n(hu.Provider,{value:{openImage:a,closeImage:s},children:[e,r&&t(`div`,{role:`button`,tabIndex:-1,"aria-label":c(`agent.close`),className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/80 backdrop-blur-sm`,onClick:s,onKeyDown:Fe(s),children:n(`div`,{className:`relative max-w-[90vw] max-h-[90vh]`,children:[t(`img`,{src:r.src,alt:r.alt||c(`agent.enlargedView`),className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-2xl`}),t(o,{variant:`unstyled`,className:`absolute top-2 end-2 text-white bg-black/50 rounded-full p-2 hover:bg-black/70 transition-colors`,onClick:s,title:c(`agent.close`),"aria-label":c(`agent.close`),children:t(nr,{className:`size-6`})}),t(`a`,{href:r.src,target:`_blank`,rel:`noopener noreferrer`,className:`absolute bottom-2 end-2 text-white bg-black/50 rounded-full p-2 hover:bg-black/70 transition-colors`,onClick:e=>e.stopPropagation(),title:c(`agent.openInNewTab`),children:t(Vt,{className:`size-5`})})]})})]})}const vu=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]),yu=new Set([`css`,`csv`,`html`,`js`,`json`,`jsx`,`log`,`md`,`mjs`,`sql`,`ts`,`tsx`,`txt`,`xml`,`yaml`,`yml`]);function bu(e){let t=e?.split(/[?#]/)[0]??``;return t.includes(`.`)?(t.split(`.`).pop()??``).toLowerCase():``}function xu(e){return e.contentType?.toLowerCase().startsWith(`image/`)?!0:vu.has(bu(e.artifactPath||e.href||e.name))}function Su(e){let t=e.contentType?.toLowerCase()??``;return t.startsWith(`text/`)||t===`application/json`||t.includes(`xml`)?!0:yu.has(bu(e.artifactPath||e.href||e.name))}function Cu(e){if(e.artifactPath)return e.artifactPath;if(e.href?.startsWith(`artifact:`))return e.href.slice(9)}function wu(e){let t=e.split(`/store/objects/`)[1];return t?t.split(/[?#]/)[0]:e.replace(/^store:/,``).replace(/^document:(?:\/\/)?/,``).split(/[?#]/)[0]}function Tu(e){return e.split(`/store/collections/`)[1]||e.replace(/^collection:/,``)}function Eu(e){return!!(e?.includes(`/store/objects/`)||e?.startsWith(`store:`)||e?.startsWith(`document:`))}function Du(e){return!!(e?.includes(`/store/collections/`)||e?.startsWith(`collection:`))}function Ou({item:n,children:r,StoreLinkComponent:i,CollectionLinkComponent:a}){let o=n.href;if(!o)return t(e,{children:r});if(Eu(o)){let e=wu(o);return i?t(i,{href:o,documentId:e,children:r}):t(`a`,{href:o.startsWith(`store:`)||o.startsWith(`document:`)?`/store/objects/${e}`:o,children:r})}if(Du(o)){let e=Tu(o);return a?t(a,{href:o,collectionId:e,children:r}):t(`a`,{href:o.startsWith(`collection:`)?`/store/collections/${e}`:o,children:r})}return/^https?:\/\//.test(o)||o.startsWith(`/`)?t(`a`,{href:o,target:o.startsWith(`/`)?void 0:`_blank`,rel:`noopener noreferrer`,children:r}):t(e,{children:r})}function ku({item:e,artifactRunId:r,variant:i,onRemove:a,StoreLinkComponent:s,CollectionLinkComponent:c}){let{t:l}=X(),u=Qe(sr),d=ta(),{openImage:f}=gu(),p=Cu(e),m=xu(e),h=m&&!Su(e),[g,_]=Y(e.previewUrl);K(()=>{_(e.previewUrl)},[e.previewUrl]),K(()=>{if(!h||e.previewUrl||!r||!p||!u?.client)return;let t=!1,n=ra(r,p,`inline`);return(async()=>{let e=d?await d.getOrFetch(n,async()=>(await u.client.files.getArtifactDownloadUrl(r,p,`inline`)).url):(await u.client.files.getArtifactDownloadUrl(r,p,`inline`)).url;t||_(e)})().catch(()=>{t||_(void 0)}),()=>{t=!0}},[p,r,e.previewUrl,u?.client,h,d]);let v={attention:`bg-attention/15 text-attention`,destructive:`bg-destructive/15 text-destructive`,info:`bg-info/15 text-info`,muted:`bg-muted text-muted`,success:`bg-success/15 text-success`}[e.statusTone??`muted`],y=!!(a&&e.removable!==!1),b=t=>{t.stopPropagation(),t.preventDefault(),a?.(e.id)},x=y?t(o,{variant:`unstyled`,size:`none`,"aria-label":l(`agent.removeFile`,{name:e.name}),onClick:b,className:H(`absolute -end-1.5 -top-1.5 inline-flex size-5 items-center justify-center rounded-full`,`border border-border bg-background text-muted shadow-sm transition-colors hover:text-foreground`),children:t(ar,{className:`size-3`,"aria-hidden":`true`})}):null,S=y?t(o,{variant:`unstyled`,size:`none`,"aria-label":l(`agent.removeFile`,{name:e.name}),onClick:b,className:H(`-me-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted`,`transition-colors hover:bg-mixer-muted/30 hover:text-foreground`),children:t(ar,{className:`size-3.5`,"aria-hidden":`true`})}):null,C=n(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5`,children:[h&&g?t(o,{type:`button`,variant:`unstyled`,size:`none`,onClick:t=>{t.stopPropagation(),t.preventDefault(),f(g,e.name)},"aria-label":e.name,title:l(`agent.enlargedView`),className:H(`group shrink-0 overflow-hidden rounded border border-border/60 p-0`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,i===`composer`?`size-6`:`size-24`),children:t(`img`,{src:g,alt:e.name,className:`h-full w-full object-cover transition-transform group-hover:scale-[1.05]`})}):t(m?an:Jt,{className:`size-3.5 shrink-0 text-muted`,"aria-hidden":`true`}),t(`span`,{className:H(`truncate`,i===`composer`?`max-w-[14rem]`:`max-w-[16rem]`),children:e.name}),e.statusLabel?t(`span`,{className:H(`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium`,v),children:e.statusLabel}):null]});return i===`composer`?n(`span`,{title:e.name,className:H(`inline-flex min-h-8 max-w-full items-center gap-1 rounded-xl border border-border/60`,`bg-mixer-muted/15 px-2.5 py-1 text-sm text-foreground/80 transition-colors`,e.href&&`hover:bg-mixer-muted/25`),children:[t(Ou,{item:e,StoreLinkComponent:s,CollectionLinkComponent:c,children:C}),S]}):n(`span`,{className:`relative inline-flex max-w-full`,children:[t(Ou,{item:e,StoreLinkComponent:s,CollectionLinkComponent:c,children:t(`span`,{title:e.name,className:H(`inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/60 bg-mixer-muted/15`,`px-2.5 py-1.5 text-xs text-foreground/80 transition-colors`,e.href&&`hover:bg-mixer-muted/25`),children:C})}),x]})}function Au({items:e,artifactRunId:n,className:r,align:i=`start`,variant:a=`message`,onRemove:o,StoreLinkComponent:s,CollectionLinkComponent:c}){return e.length===0?null:t(`div`,{className:H(`flex flex-wrap gap-2`,i===`end`&&`justify-end`,r),children:e.map(e=>t(ku,{item:e,artifactRunId:n,variant:a,onRemove:o,StoreLinkComponent:s,CollectionLinkComponent:c},e.id))})}const ju=/^\s*(?:\*\*)?(attachments|uploaded artifacts):(?:\*\*)?\s*$/i,Mu=/^\s*(?:[-*]\s*)?\[([^\]]+)]\(([^)]+)\)(?:\s+\((.*)\))?\s*$/;function Nu(e){let t=e.split(/\r?\n/),n=[],r=[],i=!1;for(let e of t){let t=e.trim();if(ju.test(t)){i=!0;continue}if(!i){n.push(e);continue}if(!t)continue;let a=Mu.exec(t);if(!a){i=!1,n.push(e);continue}let[,o,s,c]=a,l=s.startsWith(`artifact:`)?s.slice(9):void 0;r.push({id:`${s}-${r.length}`,name:o,href:s,artifactPath:l,contentType:c?.toLowerCase().includes(`image`)?`image/*`:void 0})}return{body:n.join(`
|
|
14
|
-
`).trim(),attachments:r}}function
|
|
15
|
-
`&&e!==`\r`}function
|
|
12
|
+
${O||``}`,children:n(`div`,{className:`flex items-start gap-3`,children:[e.icon&&t(`span`,{className:`flex-shrink-0 mt-0.5 text-gray-500 dark:text-gray-400`,children:e.icon}),n(`div`,{className:`flex-1 overflow-hidden`,children:[t(`div`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100 break-words text-center`,children:e.label}),e.description&&t(`div`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400 break-words whitespace-pre-wrap`,children:e.description})]})]})},e.id))})}),u&&t(`div`,{className:`px-4 pb-3 pt-1 ${k||``}`,children:n(`div`,{className:`flex gap-2`,children:[t(`input`,{ref:ee,type:`text`,value:F,onChange:e=>I(e.target.value),onKeyDown:ie,placeholder:N,disabled:m,className:`flex-1 px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 focus:border-transparent ${A||``}`}),t(o,{size:`sm`,onClick:re,disabled:m||!F.trim(),className:j,children:m?`...`:P})]})})]})})}function bl({question:e,description:n,onConfirm:r,onCancel:i,confirmLabel:a,cancelLabel:o,isLoading:s=!1,variant:c=`default`,className:l}){let{t:u}=X(),d=a??u(`agent.yes`),f=o??u(`agent.no`);return t(yl,{question:e,description:n,variant:c,isLoading:s,className:l,options:[{id:`confirm`,label:d,icon:t(wt,{className:`size-4`})},{id:`cancel`,label:f,icon:t(br,{className:`size-4`})}],onSelect:e=>{e===`confirm`?r():i()}})}function xl(e){let t=e.replace(/^workstream[:_-]?/i,``).replace(/^sys:/i,``).replace(/[-_:]?[0-9a-f]{8}-[0-9a-f-]{12,}$/i,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).replace(/[:_-]+/g,` `).trim();return t?t.split(/\s+/).map(e=>{let t=e.toLowerCase();return t===`qa`?`QA`:t===`ui`?`UI`:t===`api`?`API`:t===`url`?`URL`:t.charAt(0).toUpperCase()+t.slice(1)}).join(` `):e}function Sl(e){return/[0-9a-f]{8}-[0-9a-f-]{12,}/i.test(e)}function Cl(e,t){let n=t?xl(t):``,r=xl(e);if(!n)return r;if(Sl(e))return n;let i=n.toLowerCase().replace(/\s+/g,``);return r.toLowerCase().replace(/\s+/g,``).startsWith(i)?n:r}function wl(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function Tl(e){if(typeof e!=`string`)return!1;let t=e.trim().toLowerCase();return!!(t&&t!==`main`&&t!==`all`)}function El(e){let t=e.trim();if(!t||!/^[{[]/.test(t))return!1;try{return JSON.parse(t),!0}catch{return!1}}function Dl(e,t){return Tl(t)&&El(e)}function Ol(e){return!Dl(wl(e),e.workstream_id)||e.type!==Q.ANSWER&&e.type!==Q.COMPLETE?!1:e.details?.event_class===`user_content`||e.details?.streamed===!0}function kl(e){switch(e){case`running`:return`bg-info`;case`canceling`:return`bg-attention`;case`completed`:return`bg-success`;case`canceled`:case`failed`:case`timeout`:return`bg-destructive`}}function Al(e){let t=e.details,n=t?.status;if(n===`running`||n===`canceling`||n===`completed`||n===`canceled`||n===`failed`||n===`timeout`)return n;if(t?.workstream_event===`completed`)return`completed`}function jl(e){let t=e.details;if(t?.workstream_event!==`launched`)return null;let n=typeof t.workstream_id==`string`?t.workstream_id:typeof e.workstream_id==`string`?e.workstream_id:``;return!n||n===`main`||n===`all`?null:{workstreamId:n,launchId:typeof t.launch_id==`string`?t.launch_id:void 0,kind:typeof t.kind==`string`?t.kind:void 0,interaction:typeof t.interaction==`string`?t.interaction:void 0,childWorkflowId:typeof t.child_workflow_id==`string`?t.child_workflow_id:void 0,childWorkflowRunId:typeof t.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0}}function Ml(e){let t=e.details;if(t?.event_class!==`activity`||t.workstream_event!==void 0||e.type===Q.ERROR)return null;let n=typeof t.child_workflow_id==`string`?t.child_workflow_id:void 0,r=typeof t.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0;if(!n&&!r)return null;let i=typeof t.workstream_id==`string`&&t.workstream_id.trim()?t.workstream_id:typeof e.workstream_id==`string`?e.workstream_id:``;return Tl(i)?{workstreamId:i,launchId:typeof t.launch_id==`string`?t.launch_id:void 0,kind:typeof t.kind==`string`?t.kind:void 0,interaction:typeof t.interaction==`string`?t.interaction:void 0,childWorkflowId:n,childWorkflowRunId:r}:null}function Nl(e){let t=e.indexOf(`?`);return t===-1?null:new URLSearchParams(e.slice(t+1)).get(`agentChatDebug`)}function Pl(){if(typeof window>`u`)return!1;let e=new URLSearchParams(window.location.search).get(`agentChatDebug`),t=Nl(window.location.hash),n=e??t;if(n!==null)return n===`1`||n===`true`;try{let e=window.localStorage.getItem(`agentChatDebug`);return e===`1`||e===`true`}catch{return!1}}function Fl(e,t){Pl()&&console.debug(`[agent-chat] ${e}`,t??{})}function Il(e,t){let n=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime(),r=e.findIndex(e=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())>n);r===-1?e.push(t):e.splice(r,0,t)}const Ll=[Q.COMPLETE,Q.IDLE,Q.REQUEST_INPUT,Q.TERMINATED];function Rl(e){if(!e.length)return!0;let t=e=>e.details?._optimistic&&e.details?._deliveryStatus===`failed`&&Ll.includes(e.type),n=e.filter(e=>!t(e)),r=n.filter(e=>Vl(e)===`main`);if(r.length===0){let e=n[n.length-1];return!e||!Ll.includes(e.type)}let i=r[r.length-1];return!Ll.includes(i.type)}function zl(e){if(e.type!==Q.IDLE)return!1;let t=e.details?.status_reason,n=e.details?.display_role;return t===`user_stopped`||n===`user_stopped`||String(e.message??``).trim().toLowerCase().startsWith(`stopped.`)}function Bl(e){return typeof e==`number`?e:new Date(e).getTime()}function Vl(e){return e.workstream_id?e.workstream_id:`main`}function Hl(e){let t=e.details;return!t||typeof t!=`object`||Array.isArray(t)?{}:t}function Ul(e){if(Vl(e)===`main`||jl(e)||Ml(e))return!0;let t=Hl(e),n=typeof t.child_workflow_id==`string`||typeof t.child_workflow_run_id==`string`,r=typeof t.tool==`string`||typeof t.tool_run_id==`string`;return t.event_class===`activity`&&(e.type===Q.ERROR||e.type===Q.WARNING)&&!n&&!r}function Wl(e,t){return t===`all`?e.filter(Ul):e.filter(e=>(jl(e)??Ml(e))?.workstreamId!==t&&Vl(e)===t)}async function Gl(e,t){return e.agents.getArtifactUrl(t,`conversation.json`).then(e=>e.url)}function Kl(e){if(typeof e==`string`)return e.replace(/\r\n/g,`
|
|
13
|
+
`).trim()||void 0}function ql(e){return Kl(e.message)}function Jl(e,t){let n=Kl(e.text);if(!n)return!1;let r=e.workstreamId||`main`;return t.some(t=>{if(Bl(t.timestamp)<e.startTimestamp||Vl(t)!==r)return!1;let i=typeof t.details?.streaming_id==`string`?t.details.streaming_id:void 0;return e.streamingId&&i?!(i!==e.streamingId||t.details?.display_role===`thinking`||Xl(t)||t.details?.tool_status):e.activityId&&t.details?.activity_id===e.activityId?!(t.details?.display_role===`thinking`||Xl(t)||t.details?.tool_status):t.type!==Q.THOUGHT&&t.type!==Q.ANSWER&&t.type!==Q.COMPLETE&&t.type!==Q.IDLE||!t.details?.streamed?!1:ql(t)===n})}function Yl(e,t){if(Vl(e)!==Vl(t))return!1;let n=ql(e),r=ql(t);if(!n||n!==r)return!1;let i=Bl(e.timestamp);return Bl(t.timestamp)-i>1e4?!1:!!(e.type===Q.ANSWER&&(t.type===Q.COMPLETE||t.type===Q.IDLE)||e.type===Q.THOUGHT&&(t.type===Q.ANSWER||t.type===Q.COMPLETE||t.type===Q.IDLE)&&(e.details?.streamed||t.details?.streamed)||e.type===t.type&&(e.details?.streamed||t.details?.streamed)&&(t.type===Q.THOUGHT||t.type===Q.ANSWER||t.type===Q.COMPLETE||t.type===Q.IDLE))}function Xl(e){return e.type===Q.THOUGHT&&!!e.details?.tool}function Zl(e){let t=e.details;return e.type===Q.THOUGHT&&(t?.display_role===`tool_preamble`||t?.tool===`think`)}function Ql(e){if(Zl(e))return!1;if(Xl(e))return!0;if(e.type!==Q.THOUGHT)return!1;let t=e.details;return!!(Array.isArray(t?.tools)&&t.tools.length>0)}function $l(e){return e.details?.tool_run_id}function eu(e){return e.details?.tool_iteration}function tu(e){return e.details?.tool_status}function nu(e){let t=e.details?.activity_group_id;if(!(typeof t!=`string`||t.trim()===``))return t}function ru(e,t,n){let r=new Map,i=new Map,a=new Map,o=[];for(let t of e){let e=nu(t);if(t.type===Q.REQUEST_INPUT||t.type===Q.BATCH_PROGRESS)o.push(t);else if(Zl(t))o.push(t);else if(e)r.has(e)||r.set(e,{messages:[],firstTimestamp:Bl(t.timestamp)}),r.get(e)?.messages.push(t);else if(Ql(t)){let e=eu(t),n=$l(t);e===void 0?n?(a.has(n)||a.set(n,{messages:[],firstTimestamp:Bl(t.timestamp)}),a.get(n)?.messages.push(t)):o.push(t):(i.has(e)||i.set(e,{messages:[],firstTimestamp:Bl(t.timestamp)}),i.get(e)?.messages.push(t))}else o.push(t)}let s=[];r.forEach((e,t)=>{s.push({kind:`activity_group`,activityGroupId:t,messages:e.messages,timestamp:e.firstTimestamp})}),i.forEach((e,t)=>{s.push({kind:`iteration_group`,iteration:t,messages:e.messages,timestamp:e.firstTimestamp})}),a.forEach((e,t)=>{s.push({kind:`tool_run`,toolRunId:t,messages:e.messages,timestamp:e.firstTimestamp})});for(let e of o)s.push({kind:`message`,message:e,timestamp:Bl(e.timestamp)});t.forEach((t,r)=>{t.text&&(Jl(t,e)||n&&n!==`all`&&n!==(t.workstreamId||`main`)||s.push({kind:`streaming`,streamingId:r,data:t,timestamp:t.startTimestamp}))}),s.sort((e,t)=>{let n=e.kind===`streaming`&&!e.data.isComplete,r=t.kind===`streaming`&&!t.data.isComplete;return n&&!r?1:r&&!n?-1:e.timestamp-t.timestamp});let c=[],l=[],u=()=>{l.length>0&&(l.length===1&&!Zl(l[0])?c.push({type:`single`,message:l[0]}):c.push({type:`tool_group`,messages:l,firstTimestamp:Bl(l[0].timestamp)}),l=[])};for(let e of s)if(e.kind===`streaming`)u(),c.push({type:`streaming`,streamingId:e.streamingId,text:e.data.text,workstreamId:e.data.workstreamId,startTimestamp:e.data.startTimestamp,isComplete:e.data.isComplete});else if(e.kind===`activity_group`){u();let t=[...e.messages].sort((e,t)=>Bl(e.timestamp)-Bl(t.timestamp)),n=t.reduce((e,t)=>tu(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolRunId:e.activityGroupId,toolStatus:n})}else if(e.kind===`iteration_group`){u();let t=[...e.messages].sort((e,t)=>Bl(e.timestamp)-Bl(t.timestamp)),n=t.reduce((e,t)=>tu(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolStatus:n})}else if(e.kind===`tool_run`){u();let t=[...e.messages].sort((e,t)=>Bl(e.timestamp)-Bl(t.timestamp)),n=t.reduce((e,t)=>tu(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolRunId:e.toolRunId,toolStatus:n})}else Ql(e.message)?l.push(e.message):(u(),c.push({type:`single`,message:e.message}));return u(),c}function iu(e,t){return t??e}function au(e){let t=[],n=null,r=()=>{n&&=(t.push({type:`tool_group`,messages:n.messages,firstTimestamp:n.firstTimestamp,toolRunId:n.toolRunId,toolStatus:n.toolStatus,preambleText:n.preambleText,preambleMessage:n.preambleMessage}),null)};for(let i of e)i.type===`tool_group`?n?(n.messages=[...n.messages,...i.messages],n.toolStatus=iu(n.toolStatus,i.toolStatus),!n.toolRunId&&i.toolRunId&&(n.toolRunId=i.toolRunId),!n.preambleMessage&&i.preambleMessage&&(n.preambleMessage=i.preambleMessage,n.preambleText=i.preambleText)):n={messages:[...i.messages],firstTimestamp:i.firstTimestamp,toolRunId:i.toolRunId,toolStatus:i.toolStatus,preambleText:i.preambleText,preambleMessage:i.preambleMessage}:(r(),t.push(i));return r(),t}function ou(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function su(e){let t=cu(e.details?.tool_approval);if(!t)return ou(e);let n=lu(t.tool_title)??lu(t.tool_name),r=du(lu(t.target));if(n&&r)return`Approve ${n}: ${r}?`;let i=lu(t.action_summary);return i?`Approve ${uu(i)}?`:ou(e)}function cu(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function lu(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function uu(e){return e.replace(/:\s*name(?::|\s+)/i,`: `)}function du(e){if(!e)return;let t=e.indexOf(`:`);if(t<0)return e;let n=e.slice(0,t),r=e.slice(t+1).trim();if(!r)return e;switch(n){case`document_id`:return`document ${r}`;case`object_id`:return`object ${r}`;case`collection_id`:return`collection ${r}`;case`process_id`:return`process ${r}`;case`process_definition_id`:return`process definition ${r}`;case`interaction_id`:return`interaction ${r}`;case`prompt_id`:return`prompt ${r}`;case`dashboard_id`:return`dashboard ${r}`;case`database_id`:return`database ${r}`;case`table_id`:return`table ${r}`;default:return r}}function fu(e){let t=e.details;return e.type===Q.REQUEST_INPUT&&!!t?.ux}function pu(e){let t=e.details;return[t?.request_id,t?.requestId,t?.activity_id,t?.activityId,t?.tool_run_id,t?.toolRunId,e.timestamp,ou(e)].filter(e=>typeof e==`string`||typeof e==`number`).map(String).join(`|`)}function mu(e){let t=e.details;return[t?.ack,t?._messageId,t?._deliveryStatus,e.timestamp,Vl(e),ou(e)].filter(e=>typeof e==`string`||typeof e==`number`).map(String).join(`|`)}function hu(e){let t=new Set;return e.forEach((n,r)=>{if(n.type!==Q.REQUEST_INPUT)return;let i=Vl(n);for(let a=r+1;a<e.length;a+=1){let r=e[a];if(Vl(r)===i){if(r.type===Q.REQUEST_INPUT)break;if(r.type===Q.QUESTION){t.add(pu(n));break}}}}),t}function gu(e){let t=new Set;for(let n of e){let e=cu(n.details),r=cu(e?.approval_request)?.approval_key,i=e?.approval_decision;typeof r==`string`&&(i===`denied`||i===`denied_with_feedback`||i===`timeout`||i===`reviewer_denied`||i===`cancelled_after_denial`)&&t.add(r)}return t}function _u(e){let t=cu(cu(e.details)?.tool_approval)?.approval_key;return typeof t==`string`?t:void 0}function vu(e){return e.type===Q.REQUEST_INPUT&&_u(e)!==void 0}const yu=new Set([`allow_once`,`allow_for_run`,`deny`]);function bu(e,t){let n=_u(e);if(!(!n||!yu.has(t)))return{tool_approval_response:{decision:t,approval_key:n}}}function xu(e){if(e.type!==Q.QUESTION)return!1;let t=ou(e).trim().toLowerCase();return t===`allow_once`||t===`allow_for_run`||t===`deny`}function Su(e){if(e.type!==Q.QUESTION)return!1;let t=cu(e.details),n=cu(t?.metadata),r=(cu(t?.tool_approval_response)??cu(n?.tool_approval_response))?.decision;return r===`deny_with_feedback`||typeof r==`string`&&yu.has(r)}function Cu(e){return xu(e)||Su(e)}function wu(e,t){if(e.type!==Q.REQUEST_INPUT)return!1;let n=_u(e);return n?t.has(n):!1}function Tu(e){let t=new Set;return e.forEach((n,r)=>{if(!vu(n))return;let i=Vl(n);for(let a=r+1;a<e.length;a+=1){let r=e[a];if(Vl(r)===i){if(r.type===Q.REQUEST_INPUT)break;if(r.type===Q.QUESTION){Cu(r)&&t.add(pu(n));break}}}}),t}function Eu(e,t,n){return vu(e)&&(t.has(pu(e))||wu(e,n))}function Du(e,t){let n=new Set;return e.forEach((r,i)=>{if(!vu(r)||t&&!wu(r,t))return;let a=Vl(r);for(let t=i+1;t<e.length;t+=1){let r=e[t];if(Vl(r)===a){if(r.type===Q.REQUEST_INPUT)break;if(r.type===Q.QUESTION){xu(r)&&n.add(mu(r));break}}}}),n}function Ou(e,t){return e.type===Q.QUESTION&&t.has(mu(e))}function ku(e,t){return e.type===Q.REQUEST_INPUT&&t.has(pu(e))}function Au(e,t=`main`){let n=hu(e),r=gu(e);for(let i=e.length-1;i>=0;--i){let a=e[i];if(fu(a)&&Vl(a)===t&&!ku(a,n)&&!wu(a,r))return a}}function ju({mcpConnect:e,onMcpConnected:r,onDecline:i,disabled:a}){let{client:s}=Z(),{t:c}=X();return n(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[t(Bs,{appId:e.app_install_id,collectionId:e.collection_id,collectionName:e.name,variant:`default`,onAuthChange:()=>{s.remoteMcpConnections.getCollectionStatus(e.app_install_id,e.collection_id).then(t=>{t.authenticated&&r?.(e)}).catch(()=>{})},readOnly:a}),n(o,{variant:`ghost`,size:`sm`,onClick:i,disabled:a,children:[t(Sr,{className:`size-4`}),t(`span`,{children:c(`mcpOAuth.decline`)})]})]})}function Mu({message:e,onSendMessage:r,onMcpConnected:i,isLoading:a=!1,disabled:o=!1,className:s}){let{t:c}=X();if(!e)return null;let l=e.details.ux,u=l.options??[],d=l.mcp_connect,f=l.free_response,p=o||a||!r,m=su(e),h=(e,t)=>{p||(t?r?.(e,t):r?.(e))},g=V(`flex-shrink-0 border-t border-border/70 bg-background/95 backdrop-blur`,`fixed bottom-0 end-0 start-0 z-20 lg:sticky lg:start-auto lg:end-auto`,`pb-safe-area`,s);return d?t(`div`,{className:g,"data-agent-request-input-overlay":!0,children:n(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-3 px-3 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[t(`div`,{className:`min-w-0 text-sm leading-6 text-foreground/85`,children:m}),t(ju,{mcpConnect:d,onMcpConnected:i,onDecline:()=>h(c(`agent.mcpDeclinedMessage`,{name:d.name})),disabled:p})]})}):t(`div`,{className:g,"data-agent-request-input-overlay":!0,children:t(`div`,{className:`mx-auto w-full max-w-3xl px-3 py-3`,children:t(yl,{question:m,options:u,variant:l.variant,multiSelect:l.multiSelect,allowFreeResponse:u.length===0||!!f,placeholder:f?.placeholder,submitLabel:f?.submit_label,onSelect:t=>h(t,bu(e,t)),onMultiSelect:e=>h(e.join(`, `)),onSubmit:e=>h(e,f?.metadata),hideBorder:!0,compact:!0,isLoading:p,className:`my-0`,cardClassName:`bg-background/80 shadow-lg shadow-black/5 dark:shadow-none`})})})}function Nu({className:e,inline:r=!1,color:i=`blue`}){let a={blue:`from-blue-400 to-indigo-500 dark:from-blue-500 dark:to-indigo-400`,purple:`from-purple-400 to-violet-500 dark:from-purple-500 dark:to-violet-400`,teal:`from-teal-400 to-emerald-500 dark:from-teal-500 dark:to-emerald-400`,green:`from-green-400 to-emerald-500 dark:from-green-500 dark:to-emerald-400`,amber:`from-amber-400 to-orange-500 dark:from-amber-500 dark:to-orange-400`}[i];return n(`div`,{className:V(`flex items-center gap-1.5`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_infinite]`}),t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_0.2s_infinite]`}),t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_0.4s_infinite]`})]})}function Pu({className:e,size:r=`md`,color:i=`blue`}){let a={sm:`w-3 h-3`,md:`w-5 h-5`,lg:`w-7 h-7`},o={blue:`bg-blue-500 dark:bg-blue-400`,purple:`bg-purple-500 dark:bg-purple-400`,teal:`bg-teal-500 dark:bg-teal-400`,green:`bg-green-500 dark:bg-green-400`,amber:`bg-amber-500 dark:bg-amber-400`};return n(`span`,{className:V(`relative flex`,e),children:[t(`span`,{className:V(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,o[i])}),t(`span`,{className:V(`animate-pulse absolute inline-flex h-[80%] w-[80%] rounded-full opacity-80`,o[i]),style:{left:`10%`,top:`10%`,animationDuration:`2s`}}),t(`span`,{className:V(`relative inline-flex rounded-full`,o[i],a[r])})]})}function Fu({className:e,color:n=`blue`}){let[r,i]=Y(`.`);return K(()=>{let e=setInterval(()=>{i(e=>e===`.`?`..`:e===`..`?`...`:`.`)},500);return()=>clearInterval(e)},[]),t(`span`,{className:V({blue:`text-blue-600 dark:text-blue-400`,purple:`text-purple-600 dark:text-purple-400`,teal:`text-teal-600 dark:text-teal-400`,green:`text-green-600 dark:text-green-400`,amber:`text-amber-600 dark:text-amber-400`}[n],`font-bold`,e),children:r})}function Iu({message:e,className:r,color:i=`blue`}){let a={blue:{dot:`bg-blue-500 dark:bg-blue-400`,text:`text-blue-700 dark:text-blue-300`},purple:{dot:`bg-purple-500 dark:bg-purple-400`,text:`text-purple-700 dark:text-purple-300`},teal:{dot:`bg-teal-500 dark:bg-teal-400`,text:`text-teal-700 dark:text-teal-300`},green:{dot:`bg-green-500 dark:bg-green-400`,text:`text-green-700 dark:text-green-300`},amber:{dot:`bg-amber-500 dark:bg-amber-400`,text:`text-amber-700 dark:text-amber-300`}};return n(`div`,{className:V(`flex items-center gap-2 py-1`,r),children:[n(`div`,{className:`flex gap-1`,children:[t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`}),t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`,style:{animationDelay:`0.2s`}}),t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`,style:{animationDelay:`0.4s`}})]}),t(`div`,{className:`${a[i].text} font-medium text-xs`,children:e})]})}function Lu({className:e,color:r=`blue`,width:i=`md`,message:a}){let[o,s]=Y(15),[c,l]=Y(`increasing`),[u,d]=Y(.4),f=J(null),p=J(!0);return K(()=>{let e=f.current;if(!e)return;let t=new IntersectionObserver(([e])=>{p.current=e.isIntersecting},{threshold:0});return t.observe(e),()=>t.disconnect()},[]),K(()=>{let e,t=Date.now(),n=()=>{if(!p.current){e=requestAnimationFrame(n);return}let r=Date.now(),i=r-t;t=r,s(e=>{let t=i/16*u,n=c===`increasing`?e+t:e-t;return n>=85?(l(`decreasing`),d(.3+Math.random()*.2),85):n<=15?(l(`increasing`),d(.3+Math.random()*.2),15):(Math.random()>.99&&d(e=>Math.max(.2,Math.min(.5,e+(Math.random()*.1-.05)))),n)}),e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>{cancelAnimationFrame(e)}},[c,u]),n(`div`,{ref:f,className:V(`flex flex-col gap-1`,e),children:[a&&t(`div`,{className:`text-xs font-medium ${{blue:`text-blue-700 dark:text-blue-300`,purple:`text-purple-700 dark:text-purple-300`,teal:`text-teal-700 dark:text-teal-300`,green:`text-green-700 dark:text-green-300`,amber:`text-amber-700 dark:text-amber-300`}[r]} mb-1`,children:a}),t(`div`,{className:V(`h-1.5 rounded-full overflow-hidden shadow-inner`,{blue:`bg-blue-200 dark:bg-blue-900/30`,purple:`bg-purple-200 dark:bg-purple-900/30`,teal:`bg-teal-200 dark:bg-teal-900/30`,green:`bg-green-200 dark:bg-green-900/30`,amber:`bg-amber-200 dark:bg-amber-900/30`}[r],{sm:`w-24`,md:`w-32`,lg:`w-48`,xl:`w-64`,full:`w-full`}[i]),children:t(`div`,{className:V(`h-full rounded-full`,{blue:`bg-gradient-to-r from-blue-400 to-blue-500 dark:from-blue-500 dark:to-blue-400`,purple:`bg-gradient-to-r from-purple-400 to-purple-500 dark:from-purple-500 dark:to-purple-400`,teal:`bg-gradient-to-r from-teal-400 to-teal-500 dark:from-teal-500 dark:to-teal-400`,green:`bg-gradient-to-r from-green-400 to-green-500 dark:from-green-500 dark:to-green-400`,amber:`bg-gradient-to-r from-amber-400 to-amber-500 dark:from-amber-500 dark:to-amber-400`}[r]),style:{width:`${o}%`,transition:`width 150ms cubic-bezier(0.4, 0.0, 0.2, 1)`}})})]})}function Ru({className:e,color:n=`blue`,size:r=`md`}){let[i,a]=Y(Array(7).fill(50)),o=J(null),s=J(!0);K(()=>{let e=o.current;if(!e)return;let t=new IntersectionObserver(([e])=>{s.current=e.isIntersecting},{threshold:0});return t.observe(e),()=>t.disconnect()},[]);let c={sm:{width:`w-16`,height:`h-4`,barWidth:`w-0.5`,gap:`gap-[2px]`},md:{width:`w-20`,height:`h-5`,barWidth:`w-1`,gap:`gap-[3px]`},lg:{width:`w-24`,height:`h-6`,barWidth:`w-1.5`,gap:`gap-1`}},l={blue:`bg-gradient-to-b from-blue-400 to-blue-500 dark:from-blue-400 dark:to-blue-500`,purple:`bg-gradient-to-b from-purple-400 to-purple-500 dark:from-purple-400 dark:to-purple-500`,teal:`bg-gradient-to-b from-teal-400 to-teal-500 dark:from-teal-400 dark:to-teal-500`,green:`bg-gradient-to-b from-green-400 to-green-500 dark:from-green-400 dark:to-green-500`,amber:`bg-gradient-to-b from-amber-400 to-amber-500 dark:from-amber-400 dark:to-amber-500`};return K(()=>{let e,t=[1.2,1,1.5,.8,1.3,.9,1.1],n=[0,.5,1,1.5,2,2.5,3],r=0,i=()=>{if(!s.current){e=requestAnimationFrame(i);return}r+=.02;let o=Array(7).fill(0).map((e,i)=>10+(Math.sin(r*t[i]+n[i])+1)*40);a(o),e=requestAnimationFrame(i)};return e=requestAnimationFrame(i),()=>{cancelAnimationFrame(e)}},[]),t(`div`,{ref:o,className:V(`flex items-end justify-center`,c[r].width,c[r].height,c[r].gap,e),children:i.map((e,i)=>t(`div`,{className:V(c[r].barWidth,`rounded-full transform-gpu`,l[n]),style:{height:`${e}%`,transition:`height 100ms cubic-bezier(0.4, 0.0, 0.2, 1)`,opacity:.9}},`bar-${i}`))})}const zu=`Brewing some code magic...(Doing the robot dance...(Cooking up something good...(Working my gears...(Parsing the possibilities...(Crunching the numbers...(Connecting the digital dots...(Processing at maximum capacity...(Searching through my circuits...(Running advanced algorithms...(Computing optimal solutions...(Loading brilliance.exe...(Scanning the knowledge base...(Optimizing response protocols...(Having a quick brainstorm...(Thinking cap firmly on...(Pondering the digital universe...(Consulting my silicon wisdom...(Untangling the logic knots...(Assembling clever responses...(Mixing thoughtful ingredients...(Polishing the perfect answer...(Taking a momentary mind sprint...(Connecting virtual synapses...(Baking fresh ideas...(Stirring the thought pot...(Simmering solutions slowly...(Whipping up a smart response...(Adding a dash of intelligence...(Preparing a gourmet answer...(Growing brilliant ideas...(Cultivating the perfect response...(Gathering digital nectar...(Planting seeds of solutions...(Exploring the data landscape...(Mapping the solution path...(Navigating through possibilities...(Charting the course to answers...(Embarking on a thought expedition...(Sketching out concepts...(Painting with digital brushstrokes...(Composing my response symphony...(Crafting precision answers...(Weaving threads of information...(Just a moment of processing...(Taking a quick thinking break...(Almost there, final touches...(Putting the pieces together...(Making progress, hold tight...`.split(`(`),Bu=nt(null);function Vu(){return at(Bu)||{openImage:e=>window.open(e,`_blank`),closeImage:()=>{}}}function Hu({children:e}){let[r,i]=Y(null),a=G((e,t)=>{i({src:e,alt:t})},[]),s=G(()=>{i(null)},[]),{t:c}=X();return n(Bu.Provider,{value:{openImage:a,closeImage:s},children:[e,r&&t(`div`,{role:`button`,tabIndex:-1,"aria-label":c(`agent.close`),className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/80 backdrop-blur-sm`,onClick:s,onKeyDown:Ve(s),children:n(`div`,{className:`relative max-w-[90vw] max-h-[90vh]`,children:[t(`img`,{src:r.src,alt:r.alt||c(`agent.enlargedView`),className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-2xl`}),t(o,{variant:`unstyled`,className:`absolute top-2 end-2 text-white bg-black/50 rounded-full p-2 hover:bg-black/70 transition-colors`,onClick:s,title:c(`agent.close`),children:t(yr,{className:`size-6`})}),t(`a`,{href:r.src,target:`_blank`,rel:`noopener noreferrer`,className:`absolute bottom-2 end-2 text-white bg-black/50 rounded-full p-2 hover:bg-black/70 transition-colors`,onClick:e=>e.stopPropagation(),title:c(`agent.openInNewTab`),children:t(Zt,{className:`size-5`})})]})})]})}const Uu=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]),Wu=new Set([`css`,`csv`,`html`,`js`,`json`,`jsx`,`log`,`md`,`mjs`,`sql`,`ts`,`tsx`,`txt`,`xml`,`yaml`,`yml`]);function Gu(e){let t=e?.split(/[?#]/)[0]??``;return t.includes(`.`)?(t.split(`.`).pop()??``).toLowerCase():``}function Ku(e){return e.contentType?.toLowerCase().startsWith(`image/`)?!0:Uu.has(Gu(e.artifactPath||e.href||e.name))}function qu(e){let t=e.contentType?.toLowerCase()??``;return t.startsWith(`text/`)||t===`application/json`||t.includes(`xml`)?!0:Wu.has(Gu(e.artifactPath||e.href||e.name))}function Ju(e){if(e.artifactPath)return e.artifactPath;if(e.href?.startsWith(`artifact:`))return e.href.slice(9)}function Yu(e){let t=e.split(`/store/objects/`)[1];return t?t.split(/[?#]/)[0]:e.replace(/^store:/,``).replace(/^document:(?:\/\/)?/,``).split(/[?#]/)[0]}function Xu(e){return e.split(`/store/collections/`)[1]||e.replace(/^collection:/,``)}function Zu(e){return!!(e?.includes(`/store/objects/`)||e?.startsWith(`store:`)||e?.startsWith(`document:`))}function Qu(e){return!!(e?.includes(`/store/collections/`)||e?.startsWith(`collection:`))}function $u({item:n,children:r,StoreLinkComponent:i,CollectionLinkComponent:a}){let o=n.href;if(!o)return t(e,{children:r});if(Zu(o)){let e=Yu(o);return i?t(i,{href:o,documentId:e,children:r}):t(`a`,{href:o.startsWith(`store:`)||o.startsWith(`document:`)?`/store/objects/${e}`:o,children:r})}if(Qu(o)){let e=Xu(o);return a?t(a,{href:o,collectionId:e,children:r}):t(`a`,{href:o.startsWith(`collection:`)?`/store/collections/${e}`:o,children:r})}return/^https?:\/\//.test(o)||o.startsWith(`/`)?t(`a`,{href:o,target:o.startsWith(`/`)?void 0:`_blank`,rel:`noopener noreferrer`,children:r}):t(e,{children:r})}function ed({item:e,artifactRunId:r,variant:i,onRemove:a,StoreLinkComponent:s,CollectionLinkComponent:c}){let{t:l}=X(),u=at(wr),d=Ca(),{openImage:f}=Vu(),p=Ju(e),m=Ku(e),h=m&&!qu(e),[g,_]=Y(e.previewUrl);K(()=>{_(e.previewUrl)},[e.previewUrl]),K(()=>{if(!h||e.previewUrl||!r||!p||!u?.client)return;let t=!1,n=Ta(r,p,`inline`);return(async()=>{let e=d?await d.getOrFetch(n,async()=>(await u.client.files.getArtifactDownloadUrl(r,p,`inline`)).url):(await u.client.files.getArtifactDownloadUrl(r,p,`inline`)).url;t||_(e)})().catch(()=>{t||_(void 0)}),()=>{t=!0}},[p,r,e.previewUrl,u?.client,h,d]);let v={attention:`bg-attention/15 text-attention`,destructive:`bg-destructive/15 text-destructive`,info:`bg-info/15 text-info`,muted:`bg-muted text-muted`,success:`bg-success/15 text-success`}[e.statusTone??`muted`],y=!!(a&&e.removable!==!1),b=t=>{t.stopPropagation(),t.preventDefault(),a?.(e.id)},x=y?t(o,{variant:`unstyled`,size:`none`,"aria-label":l(`agent.removeFile`,{name:e.name}),onClick:b,className:V(`absolute -end-1.5 -top-1.5 inline-flex size-5 items-center justify-center rounded-full`,`border border-border bg-background text-muted shadow-sm transition-colors hover:text-foreground`),children:t(Sr,{className:`size-3`,"aria-hidden":`true`})}):null,S=y?t(o,{variant:`unstyled`,size:`none`,"aria-label":l(`agent.removeFile`,{name:e.name}),onClick:b,className:V(`-me-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted`,`transition-colors hover:bg-mixer-muted/30 hover:text-foreground`),children:t(Sr,{className:`size-3.5`,"aria-hidden":`true`})}):null,C=n(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5`,children:[h&&g?t(o,{type:`button`,variant:`unstyled`,size:`none`,onClick:t=>{t.stopPropagation(),t.preventDefault(),f(g,e.name)},"aria-label":e.name,title:l(`agent.enlargedView`),className:V(`group shrink-0 overflow-hidden rounded border border-border/60 p-0`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,i===`composer`?`size-6`:`size-24`),children:t(`img`,{src:g,alt:e.name,className:`h-full w-full object-cover transition-transform group-hover:scale-[1.05]`})}):t(m?vn:sn,{className:`size-3.5 shrink-0 text-muted`,"aria-hidden":`true`}),t(`span`,{className:V(`truncate`,i===`composer`?`max-w-[14rem]`:`max-w-[16rem]`),children:e.name}),e.statusLabel?t(`span`,{className:V(`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium`,v),children:e.statusLabel}):null]});return i===`composer`?n(`span`,{title:e.name,className:V(`inline-flex min-h-8 max-w-full items-center gap-1 rounded-xl border border-border/60`,`bg-mixer-muted/15 px-2.5 py-1 text-sm text-foreground/80 transition-colors`,e.href&&`hover:bg-mixer-muted/25`),children:[t($u,{item:e,StoreLinkComponent:s,CollectionLinkComponent:c,children:C}),S]}):n(`span`,{className:`relative inline-flex max-w-full`,children:[t($u,{item:e,StoreLinkComponent:s,CollectionLinkComponent:c,children:t(`span`,{title:e.name,className:V(`inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/60 bg-mixer-muted/15`,`px-2.5 py-1.5 text-xs text-foreground/80 transition-colors`,e.href&&`hover:bg-mixer-muted/25`),children:C})}),x]})}function td({items:e,artifactRunId:n,className:r,align:i=`start`,variant:a=`message`,onRemove:o,StoreLinkComponent:s,CollectionLinkComponent:c}){return e.length===0?null:t(`div`,{className:V(`flex flex-wrap gap-2`,i===`end`&&`justify-end`,r),children:e.map(e=>t(ed,{item:e,artifactRunId:n,variant:a,onRemove:o,StoreLinkComponent:s,CollectionLinkComponent:c},e.id))})}const nd=/^\s*(?:\*\*)?(attachments|uploaded artifacts):(?:\*\*)?\s*$/i,rd=/^\s*(?:[-*]\s*)?\[([^\]]+)]\(([^)]+)\)(?:\s+\((.*)\))?\s*$/;function id(e){let t=e.split(/\r?\n/),n=[],r=[],i=!1;for(let e of t){let t=e.trim();if(nd.test(t)){i=!0;continue}if(!i){n.push(e);continue}if(!t)continue;let a=rd.exec(t);if(!a){i=!1,n.push(e);continue}let[,o,s,c]=a,l=s.startsWith(`artifact:`)?s.slice(9):void 0;r.push({id:`${s}-${r.length}`,name:o,href:s,artifactPath:l,contentType:c?.toLowerCase().includes(`image`)?`image/*`:void 0})}return{body:n.join(`
|
|
14
|
+
`).trim(),attachments:r}}function ad({message:e,batchData:r,isRunning:i=!1,className:a,headerClassName:s,senderClassName:c,progressBarClassName:l,itemListClassName:u,itemClassName:d,summaryClassName:f}){let[p,m]=Y(!1),h=Ye(),{t:g}=X(),{tool_name:_,total:v,completed:y,succeeded:b,failed:x,items:S,started_at:C,completed_at:w}=r,T=v>0?y/v*100:0,E=x>0,D=y===v&&!i,O=i||!D?`running`:x===v?`error`:x>0?`warning`:`completed`,k=()=>i||!D?t(Pu,{size:`sm`,color:`blue`}):O===`completed`?t(wt,{className:`size-4 text-success`}):O===`error`||O===`warning`?t(pt,{className:`size-4 text-destructive`}):t(xn,{className:`size-4 text-purple-600`}),A=()=>O===`completed`?`border-s-success`:O===`error`?`border-s-destructive`:O===`warning`?`border-s-attention`:`border-s-blue-500`,j=()=>E?`bg-attention`:D?`bg-success`:`bg-blue-500`,M=()=>{let e=JSON.stringify(r,null,2);navigator.clipboard.writeText(e).then(()=>{h({status:`success`,title:g(`agent.copiedBatchDetails`),duration:2e3})})},N=((w?w-C:Date.now()-C)/1e3).toFixed(1);return n(`div`,{className:V(`border-s-4 shadow-md overflow-hidden bg-white dark:bg-gray-900 mb-5`,A(),a),children:[n(`div`,{role:`button`,tabIndex:0,"aria-expanded":p,className:V(`flex items-center justify-between px-4 py-2 border-b border-gray-100/80 dark:border-gray-800/80 bg-blue-50/50 dark:bg-blue-900/10 cursor-pointer`,s),onClick:()=>m(!p),onKeyDown:Ve(()=>m(!p)),children:[n(`div`,{className:`flex items-center gap-2`,children:[k(),t(`span`,{className:V(`text-xs font-medium text-muted`,c),children:g(`agent.batch`)}),t(`span`,{className:`text-xs text-blue-600 dark:text-blue-400 font-medium`,children:_}),n(`span`,{className:`text-xs text-muted`,children:[y,`/`,v]}),p?t(Ot,{className:`size-3 text-muted`}):t(jt,{className:`size-3 text-muted cn-rtl-flip`})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(`span`,{className:`text-xs text-muted`,children:[N,`s`]}),t(`span`,{className:`text-xs text-muted`,children:ni(C).format(`HH:mm:ss`)}),t(o,{variant:`ghost`,size:`xs`,onClick:e=>{e.stopPropagation(),M()},className:`text-muted`,title:g(`agent.copyBatchDetails`),children:t(Gt,{className:`size-3`})})]})]}),t(`div`,{className:V(`px-4 py-2 bg-gray-50/50 dark:bg-gray-800/30`,l),children:n(`div`,{className:`flex items-center gap-3`,children:[t(`div`,{className:`flex-1 h-2 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden`,children:t(`div`,{className:`h-full ${j()} transition-all duration-300 ease-out`,style:{width:`${T}%`}})}),n(`div`,{className:`flex items-center gap-2 text-xs`,children:[b>0&&n(`span`,{className:`text-success flex items-center gap-1`,children:[t(wt,{className:`size-3`}),b]}),x>0&&n(`span`,{className:`text-destructive flex items-center gap-1`,children:[t(pt,{className:`size-3`}),x]}),i&&y<v&&n(`span`,{className:`text-blue-500 flex items-center gap-1`,children:[t(Dn,{className:`size-3 animate-spin`}),v-y]})]})]})}),p&&S.length>0&&t(`div`,{className:V(`max-h-64 overflow-y-auto`,u),children:S.map(e=>n(`div`,{className:V(`flex items-center gap-2 px-4 py-1.5 text-xs border-b border-gray-100 dark:border-gray-800 last:border-b-0 hover:bg-gray-50 dark:hover:bg-gray-800/50`,d),children:[n(`div`,{className:`w-4 flex-shrink-0`,children:[e.status===`success`&&t(wt,{className:`size-3 text-success`}),e.status===`error`&&t(pt,{className:`size-3 text-destructive`}),e.status===`running`&&t(Dn,{className:`size-3 text-blue-500 animate-spin`}),e.status===`pending`&&t(`div`,{className:`size-3 rounded-full border border-gray-300 dark:border-gray-600`})]}),t(`span`,{className:`font-mono text-muted w-24 truncate flex-shrink-0`,title:e.id,children:e.id}),t(`span`,{className:`text-muted truncate flex-1`,title:e.message,children:e.message||(e.status===`pending`?g(`agent.waiting`):``)}),e.duration_ms!==void 0&&n(`span`,{className:`text-muted flex-shrink-0`,children:[(e.duration_ms/1e3).toFixed(1),`s`]})]},e.id))}),!p&&e.message&&t(`div`,{className:V(`px-4 py-2 text-xs text-muted`,f),children:e.message})]})}const od=it(ad,(e,t)=>!(e.isRunning!==t.isRunning||e.batchData.completed!==t.batchData.completed||e.batchData.succeeded!==t.batchData.succeeded||e.batchData.failed!==t.batchData.failed)),sd={sending:{icon:Ht,className:`text-muted/70`},received:{icon:St,className:`text-info`},consumed:{icon:Ct,className:`text-success`},failed:{icon:pt,className:`text-destructive`}};function cd(e){return e===`sending`||e===`received`||e===`consumed`||e===`failed`}function ld(e){if(e.type!==Q.QUESTION&&!zl(e))return;let t=e.details?._deliveryStatus;if(cd(t))return t;if(e.details?.ack)return`consumed`}function ud(e,t){switch(t){case`sending`:return e(`agent.messageSending`);case`received`:return e(`agent.messageReceived`);case`consumed`:return e(`agent.messageConsumed`);case`failed`:return e(`agent.messageFailed`)}return t}function dd({message:e,className:n}){let{t:r}=X(),i=ld(e);if(!i)return null;let a=sd[i],o=a.icon,s=ud(r,i);return t(ze,{description:s,asChild:!0,children:t(`span`,{"aria-label":s,className:V(`inline-flex h-5 w-5 items-center justify-center`,a.className,n),role:`img`,children:t(o,{className:`size-3.5`,"aria-hidden":`true`})})})}function fd({client:e,toast:t}){let n=ut.getFixedT(null,lt),[r,i]=Y(!1),a=G(async(r,a)=>{if(r){i(!0);try{pd((await e.files.getDownloadUrlWithOptions({file:r,name:a})).url,a)}catch(e){t({status:`error`,title:n(`store.downloadFailed`),description:e instanceof Error?e.message:n(`store.failedToGetDownloadUrl`),duration:5e3})}finally{i(!1)}}},[e,t,n]),o=G((e,t)=>{e&&pd(e,t)},[]),s=G(async(t,n)=>{let r=await(`store`in e?e.store:e).rendering.render(t);if(r.download_url)pd(r.download_url,n);else if(r.file_uri)pd((await e.files.getDownloadUrlWithOptions({file:r.file_uri,name:n})).url,n);else throw Error(`No download URL or file URI in response`)},[e]);return{downloadFromContentSource:a,downloadFromUrl:o,renderDocument:G(async(e,r)=>{i(!0);try{let i=`${r.title||`document`}.${r.format}`;await s({object_id:e,format:r.format,title:r.title,pandoc_options:r.pandocOptions,use_default_template:r.useDefaultTemplate,template_path:r.templateObjectId?`store:${r.templateObjectId}`:void 0},i),t({status:`success`,title:n(`store.documentExported`),description:n(`store.successfullyExportedTo`,{format:r.format.toUpperCase()}),duration:2e3})}catch(e){t({status:`error`,title:n(`store.exportFailed`),description:e instanceof Error?e.message:n(`store.failedToExportDocument`),duration:5e3})}finally{i(!1)}},[s,t,n]),renderContent:G(async(e,r)=>{i(!0);try{let i=`${r.title||`export`}.${r.format}`;await s({content:e,format:r.format,title:r.title,artifact_run_id:r.artifactRunId,pandoc_options:r.pandocOptions},i),t({status:`success`,title:n(`store.contentExported`),description:n(`store.successfullyExportedTo`,{format:r.format.toUpperCase()}),duration:2e3})}catch(e){t({status:`error`,title:n(`store.exportFailed`),description:e instanceof Error?e.message:n(`store.failedToExportContent`),duration:5e3})}finally{i(!1)}},[s,t,n]),isDownloading:r}}function pd(e,t){fetch(e).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.blob()}).then(n=>{let r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t||md(e),i.style.display=`none`,document.body.appendChild(i),i.click(),setTimeout(()=>{document.body.removeChild(i),URL.revokeObjectURL(r)},100)}).catch(()=>{let n=document.createElement(`a`);n.href=e,n.download=t||md(e),n.target=`_blank`,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),setTimeout(()=>{document.body.removeChild(n)},100)})}function md(e){try{let t=new URL(e).pathname.split(`/`);return t[t.length-1]||`download`}catch{return`download`}}function hd(e){return e!==void 0&&e>=`0`&&e<=`9`}function gd(e){return e===` `||e===` `}function _d(e){return e!==void 0&&e!==` `&&e!==` `&&e!==`
|
|
15
|
+
`&&e!==`\r`}function vd(e,t){if(t>0&&hd(e[t-1]))return;let n=t;for(;hd(e[n]);)n++;if(n===t||e[n]!==`.`)return;n++;let r=n;for(;gd(e[n]);)n++;return n>r&&_d(e[n])?n:void 0}function yd(e,t){for(let n=t;n<e.length;n++)if(vd(e,n)!==void 0)return n;return-1}function bd(e){let t=yd(e,0);if(t===-1)return e;let n=e.slice(0,t),r=t;for(;r!==-1;){let t=yd(e,vd(e,r)??r+1);if(t===-1){n+=e.slice(r),n+=`
|
|
16
16
|
|
|
17
|
-
`;break}let i=t;for(;i>r&&
|
|
17
|
+
`;break}let i=t;for(;i>r&&gd(e[i-1]);)i--;n+=e.slice(r,i),n+=`
|
|
18
18
|
|
|
19
|
-
`,r=t}return n}function
|
|
19
|
+
`,r=t}return n}function xd(e){let t=0;for(;gd(e[t]);)t++;return vd(e,t)!==void 0}function Sd(e){if(!e.includes(`
|
|
20
20
|
`))return e;let t=e.split(`
|
|
21
|
-
`),n=!1;return t.map(e=>{let t=n&&e.length>=2&&!
|
|
22
|
-
`)}function
|
|
21
|
+
`),n=!1;return t.map(e=>{let t=n&&e.length>=2&&!hd(e[0])&&e[1]!==`:`?` ${e}`:e;return n=xd(e),t}).join(`
|
|
22
|
+
`)}function Cd(e,t,n){if(typeof e!=`string`)return e;if(t===Q.THOUGHT||typeof n==`string`&&(n.toLowerCase().includes(`thinking about`)||n.toLowerCase().includes(`i'm thinking`)||n.toLowerCase().includes(`💭`))){let t=e;return t=Sd(bd(t)),t.includes(`:`)&&!t.includes(`
|
|
23
23
|
|
|
24
24
|
`)&&(t=t.replace(/\b(First|Next|Then|Finally|Lastly|Additionally|Step \d+):\s+/gi,`
|
|
25
25
|
|
|
26
26
|
$&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
|
|
27
27
|
- `)),t}return e.includes(`
|
|
28
28
|
|
|
29
|
-
`)?e:Yu(e)}const $u=[`className`,`cardClassName`,`headerClassName`,`contentClassName`,`timestampClassName`,`senderClassName`,`iconClassName`,`detailsClassName`,`artifactsClassName`,`proseClassName`];function ed(e,t,...n){let r={};for(let i of $u)r[i]=H(e[i],t[i],...n.map(e=>e?.[i]));return r}const td={Ready:`agent.ready`,Error:`agent.error`},nd={[Q.ANSWER]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Agent`,Icon:dt},[Q.COMPLETE]:{borderColor:`border-s-success`,iconColor:`text-success`,sender:`Completed`,Icon:ht},[Q.IDLE]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Ready`,Icon:Mt},[Q.REQUEST_INPUT]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Input`,Icon:Qn},[Q.QUESTION]:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`User`,Icon:Qn},[Q.THOUGHT]:{borderColor:`border-s-purple-500`,iconColor:`text-purple-600 dark:text-purple-400`,sender:`Agent`,Icon:dt},[Q.ERROR]:{borderColor:`border-s-destructive`,iconColor:`text-destructive`,sender:`Error`,Icon:at},[Q.UPDATE]:{borderColor:`border-s-success`,iconColor:`text-success`,sender:`Update`,Icon:on},[Q.PLAN]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Plan`,Icon:vn},[Q.TERMINATED]:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`Terminated`,Icon:ht},[Q.WARNING]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Warning`,Icon:at},[Q.SYSTEM]:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`System`,Icon:on},[Q.STREAMING_CHUNK]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Agent`,Icon:dt},[Q.BATCH_PROGRESS]:{borderColor:`border-s-blue-500`,iconColor:`text-blue-600 dark:text-blue-400`,sender:`Batch`,Icon:cn},[Q.RESTARTING]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Restarting`,Icon:Nn},default:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`Agent`,Icon:dt}};function rd({message:e,showPulsatingCircle:r=!1,onSendMessage:a,requestInputAnswered:s=!1,className:c,cardClassName:l,headerClassName:u,contentClassName:d,timestampClassName:f,senderClassName:p,iconClassName:m,detailsClassName:h,artifactsClassName:g,proseClassName:_,messageStyleOverrides:v,StoreLinkComponent:y,CollectionLinkComponent:x}){let[S,C]=Y(!1),{t:w}=X(),{client:T}=Z(),E=He(),D=ta(),{openImage:O}=gu(),{router:k}=ui(),A=J(T);A.current=T;let j=J(D);j.current=D;let{renderContent:M,isDownloading:N}=Vu({client:T,toast:E}),P=q(()=>{let t=nd[e.type]||nd.default,n=v?.default,r=v?.[e.type];return{...t,...n,...r,...ed(t,{className:c,cardClassName:l,headerClassName:u,contentClassName:d,timestampClassName:f,senderClassName:p,iconClassName:m,detailsClassName:h,artifactsClassName:g,proseClassName:_},n,r)}},[e.type,v,c,l,u,d,f,p,m,h,g,_]),F=q(()=>{let t=``;if(e.message&&(t=typeof e.message==`object`?JSON.stringify(e.message,null,2):e.message.trim?e.message.trim():String(e.message)),typeof t==`string`&&t.includes(`%thinking_message%`)){let e=Math.floor(Math.random()*mu.length);t=t.replace(/%thinking_message%/g,mu[e])}return t},[e.message]),I=q(()=>e.type===Q.QUESTION?Nu(F):null,[F,e.type]),L=I?.body??F,R=I?.attachments??[],ee=q(()=>L?Qu(L,e.type,typeof e.message==`string`?e.message:void 0):``,[L,e.type,e.message]),B=()=>{let t=F||``,n=typeof e.details==`string`?e.details:e.details?JSON.stringify(e.details,null,2):``,r=[t,n?`\n\nDetails:\n${n}`:``].join(``).trim();navigator.clipboard.writeText(r).then(()=>{E({status:`success`,title:w(`agent.copiedToClipboard`),duration:2e3})})},te=async t=>{let n=typeof F==`string`?F:``;if(!n.trim()){E({status:`error`,title:w(`agent.noContentToExport`),duration:2e3});return}let r=`Message ${Rr(e.timestamp).format(`YYYY-MM-DD HH-mm-ss`)}`;await M(n,{format:t,title:r,artifactRunId:ce})},ne=typeof F==`string`&&F.trim().length>0,re=e.type===Q.REQUEST_INPUT?e.details?.ux:void 0,ie=q(()=>({a:({node:e,ref:n,...r})=>{let i=r.href||``,a=i.startsWith(`/`)?k.getTopRouter().navigator.addStickyParams(i):i;return i.includes(`/store/objects`)?y?t(y,{href:a,documentId:i.split(`/store/objects/`)[1]||``,children:r.children}):t(ci,{href:a,topLevelNav:!0,children:r.children}):i.includes(`/store/collections`)?x?t(x,{href:a,collectionId:i.split(`/store/collections/`)[1]||``,children:r.children}):t(ci,{href:a,topLevelNav:!0,children:r.children}):t(`a`,{...r,target:`_blank`,rel:`noopener noreferrer`})},img:({node:e,ref:n,...r})=>t(o,{variant:`unstyled`,className:`block p-0`,onClick:()=>r.src&&O(r.src,r.alt),"aria-label":r.alt||r.src||`image`,children:t(`img`,{...r,alt:r.alt??``,className:`max-w-full h-auto rounded-lg shadow-md my-3 cursor-pointer hover:shadow-lg transition-shadow`,loading:`lazy`})})}),[O,y,x,k]),ae=n=>{if(typeof n==`object`)return t(`pre`,{className:`text-xs font-mono whitespace-pre-wrap overflow-x-auto bg-gray-100 dark:bg-gray-800 p-2 rounded text-gray-700`,children:JSON.stringify(n,null,2)});let r=e.workflow_run_id;return!r&&typeof n==`string`&&n.includes(`artifact:`)&&console.warn(`[MessageItem] message contains artifact references but workflow_run_id is missing!`,{type:e.type,workflow_run_id:e.workflow_run_id,hasArtifact:n.includes(`artifact:`)}),t(`div`,{className:H(`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-3 prose-headings:font-semibold prose-headings:tracking-normal prose-headings:mt-6 prose-headings:mb-3 prose-h1:text-xl prose-h2:text-lg prose-h3:text-base prose-li:my-1 prose-ul:my-3 prose-ol:my-3 prose-table:my-5 prose-pre:my-4 prose-hr:my-6 max-w-none text-[15px] break-words`,P.proseClassName),style:{overflowWrap:`anywhere`},children:t(yi,{artifactRunId:r,onProposalSelect:e=>a?.(e),onProposalSubmit:e=>a?.(e),components:ie,children:n})})},[oe,se]=Y([]),ce=e.workflow_run_id,le=e.details,ue=le?.outputFiles??le?.files;K(()=>{(async()=>{if(!ce||!Array.isArray(ue)||ue.length===0){se([]);return}let e=A.current,t=j.current;try{let n=await Promise.all(ue.map(async n=>{if(typeof n!=`string`||!n.trim())return null;let r=n.trim(),i=r.startsWith(`artifact:`)?r.slice(9):r,a=i.split(`.`).pop()?.toLowerCase()||``,o=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(a),s=o?`inline`:`attachment`;try{let n=ra(ce,i,s),a;return a=t?await t.getOrFetch(n,async()=>(await e.files.getArtifactDownloadUrl(ce,i,s)).url):(await e.files.getArtifactDownloadUrl(ce,i,s)).url,{displayName:r,artifactPath:i,url:a,isImage:o}}catch(e){return console.error(`Failed to resolve artifact URL for ${i}`,e),null}}));se(n.filter(e=>!!e))}catch(e){console.error(`Error loading artifact URLs from message details`,e),se([])}})()},[ce,ue]);let de=vl(e),{Icon:fe}=P;return t(`div`,{className:H(`w-full max-w-full`,P.className),children:n(`div`,{className:H(`border-s-4 bg-white dark:bg-gray-900 mb-4 w-full max-w-full overflow-hidden`,P.borderColor,P.cardClassName),"data-workstream-id":de,children:[n(`div`,{className:H(`flex items-center justify-between px-4 py-1.5`,P.headerClassName),children:[n(`div`,{className:`flex items-center gap-1.5`,children:[t(`div`,{className:H(r?`animate-fadeIn`:``,P.iconClassName),children:r?t(lu,{size:`sm`,color:`blue`}):t(fe,{className:`size-4 ${P.iconColor}`})}),t(`span`,{className:H(`text-xs font-medium text-muted`,P.senderClassName),children:td[P.sender]?w(td[P.sender]):P.sender}),de!==`main`&&de!==`all`&&t(i,{variant:`default`,className:`text-xs text-muted ms-1`,children:de})]}),n(`div`,{className:`flex items-center gap-1.5 print:hidden`,children:[t(Bu,{message:e}),t(`span`,{className:H(`text-[11px] text-muted/70`,P.timestampClassName),children:Rr(e.timestamp).format(`HH:mm:ss`)}),t(o,{variant:`ghost`,size:`xs`,onClick:B,className:`text-muted/50 hover:text-muted h-5 w-5 p-0`,title:w(`agent.copyMessage`),children:t(Ft,{className:`size-3`})}),ne&&n(b,{trigger:t(o,{variant:`ghost`,size:`xs`,className:`text-muted/50 hover:text-muted h-5 w-5 p-0`,title:w(`agent.exportMessage`),disabled:N,children:t(Lt,{className:`size-3 ${N?`animate-pulse`:``}`})}),children:[t(z,{onClick:()=>te(vr.pdf),children:w(`agent.exportAsPdf`)}),t(z,{onClick:()=>te(vr.docx),children:w(`agent.exportAsWord`)})]})]})]}),n(`div`,{className:H(`px-4 pb-3 bg-white dark:bg-gray-900 overflow-hidden`,P.contentClassName),children:[re?t(Xc,{question:typeof F==`string`?F:``,options:re.options,variant:re.variant,multiSelect:re.multiSelect,onSelect:e=>a?.(e),onMultiSelect:e=>a?.(e.join(`, `)),allowFreeResponse:!re.options?.length||!!re.free_response,placeholder:re.free_response?.placeholder,submitLabel:re.free_response?.submit_label,onSubmit:e=>a?.(e,re.free_response?.metadata),hideBorder:!0,compact:!0,answered:s}):L&&t(`div`,{className:`message-content break-words w-full`,style:{overflowWrap:`anywhere`,wordBreak:`break-word`},children:ae(ee||L)}),R.length>0&&t(Au,{items:R,artifactRunId:ce,variant:`message`,className:H(L&&`mt-3`),StoreLinkComponent:y,CollectionLinkComponent:x}),oe.length>0&&n(`div`,{className:H(`mt-3 text-xs`,P.artifactsClassName),children:[t(`div`,{className:`font-medium text-muted mb-1`,children:`Artifacts`}),oe.some(e=>e.isImage)&&t(`div`,{className:`mb-2 flex flex-wrap gap-3`,children:oe.filter(e=>e.isImage).map(({displayName:e,artifactPath:r,url:i})=>n(o,{variant:`unstyled`,className:`max-w-xs cursor-pointer text-start p-0`,onClick:()=>O(i,e),"aria-label":e,children:[t(`img`,{src:i,alt:e,className:`max-w-full h-auto rounded-lg shadow-sm hover:shadow-md transition-shadow`}),t(`div`,{className:`mt-1 text-[11px] text-muted truncate`,children:e})]},`${r}-preview`))}),t(`div`,{className:`flex flex-wrap gap-2 print:hidden`,children:oe.map(({displayName:e,artifactPath:n,url:r})=>t(o,{variant:`outline`,size:`xs`,className:`px-2 py-1 text-xs`,onClick:()=>window.open(r,`_blank`),title:n,children:e},n+r))})]}),e.details&&n(`div`,{className:H(`mt-2 print:hidden`,P.detailsClassName),children:[n(o,{variant:`unstyled`,onClick:()=>C(!S),className:`text-[11px] text-muted flex items-center`,children:[w(S?`agent.hideDetails`:`agent.showDetails`),t(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-3 w-3 ms-1 transition-transform ${S?`rotate-180`:``}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})]}),S&&t(`div`,{className:`mt-1 p-1.5 bg-muted border border-mixer-muted/40 rounded text-sm`,children:typeof e.details==`string`?ae(e.details):t(`pre`,{className:`text-xs font-mono whitespace-pre-wrap overflow-x-auto bg-muted p-2 rounded text-muted`,children:JSON.stringify(e.details,null,2)})})]})]})]})})}const id=Ze(rd,(e,t)=>e.message.timestamp===t.message.timestamp&&e.message.type===t.message.type&&e.message.message===t.message.message&&e.message.details===t.message.details&&e.message.workstream_id===t.message.workstream_id&&e.message.workflow_run_id===t.message.workflow_run_id&&e.showPulsatingCircle===t.showPulsatingCircle&&e.onSendMessage===t.onSendMessage&&e.requestInputAnswered===t.requestInputAnswered&&e.messageStyleOverrides===t.messageStyleOverrides&&$u.every(n=>e[n]===t[n]));function ad({text:e,workstreamId:r,artifactRunId:i,revealSpeed:a=300,isComplete:s=!1,timestamp:c,className:l,cardClassName:u,headerClassName:d,contentClassName:f,proseClassName:p,senderClassName:m,iconClassName:h}){let{t:g}=X(),[_,v]=Y(0),[y,b]=Y(``),x=J(null),S=J(e.length),C=J(0),w=J(c||Date.now()),T=J(e),E=J(0),D=J(performance.now()),O=J(a),k=J(0);K(()=>{let t=performance.now(),n=e.length-E.current,r=t-D.current;if(n>0&&r>30){let e=n/r*1e3,t=.2;O.current=O.current*(1-t)+e*t,O.current=Math.max(50,Math.min(2e3,O.current))}E.current=e.length,D.current=t},[e.length]),S.current=e.length,T.current=e;let A=G(()=>{let e=performance.now(),t=n=>{let r=n-e;e=n;let i=S.current-C.current;if(i<=0){k.current=0,x.current=null;return}let a;if(s)a=Math.max(500,O.current*2);else if(i<20)a=O.current*.85;else if(i<100)a=O.current;else if(i<500){let e=(i-100)/400;a=O.current*(1+e*.5)}else a=O.current*2;let o=a*r/1e3+k.current,c=Math.floor(o);k.current=o-c,c>0&&(C.current=Math.min(C.current+c,S.current),v(C.current)),x.current=requestAnimationFrame(t)};x.current=requestAnimationFrame(t)},[s]);K(()=>(e.length>C.current&&!x.current&&A(),()=>{x.current&&=(cancelAnimationFrame(x.current),null)}),[e.length,A]),K(()=>{s&&C.current<e.length&&(x.current&&=(cancelAnimationFrame(x.current),null),A())},[s,e.length,A]);let j=J(null),M=J(0);K(()=>{(_>=S.current||s)&&(b(T.current.slice(0,_)),M.current=_)},[_,s]);let N=_<e.length&&!s;K(()=>{if(!N){j.current&&=(clearInterval(j.current),null);return}return j.current||=window.setInterval(()=>{let e=C.current;e>M.current&&(b(T.current.slice(0,e)),M.current=e)},33),()=>{j.current&&=(clearInterval(j.current),null)}},[N]);let P=He(),F=q(()=>Rr(w.current).format(`HH:mm:ss`),[]),I=_<e.length,L=q(()=>{let t=y||e.slice(0,_);return I?t+`│`:t},[y,e,_,I]);return e?t(`div`,{className:H(`w-full max-w-full`,l),children:n(`div`,{className:H(`border-s-4 bg-white dark:bg-gray-900 mb-4 border-s-purple-500 w-full max-w-full overflow-hidden`,u),"data-workstream-id":r,children:[n(`div`,{className:H(`flex items-center justify-between px-4 py-1.5`,d),children:[n(`div`,{className:`flex items-center gap-1.5`,children:[t(`div`,{className:H(`animate-fadeIn`,h),children:I?t(`span`,{className:`size-2 rounded-full bg-blue-500 animate-pulse inline-block`}):t(dt,{className:`size-4 text-purple-600 dark:text-purple-400`})}),t(`span`,{className:H(`text-xs font-medium text-muted`,m),children:`Agent`}),r&&r!==`main`&&n(`span`,{className:`text-xs text-muted`,children:[`• Task `,r]})]}),n(`div`,{className:`flex items-center gap-2 text-muted`,children:[t(`span`,{className:`text-[11px]`,children:F}),t(o,{variant:`ghost`,size:`xs`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{P({status:`success`,title:g(`agent.copiedToClipboard`),duration:2e3})})},className:`size-6 p-0 hover:bg-gray-100 dark:hover:bg-gray-800`,title:g(`agent.copyMessage`),children:t(Ft,{className:`size-3`})})]})]}),n(`div`,{className:H(`px-3 pb-2 streaming-content`,I&&`streaming-active`,f),children:[t(`div`,{className:H(`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-3 prose-headings:font-semibold prose-headings:tracking-normal prose-headings:mt-6 prose-headings:mb-3 prose-h1:text-xl prose-h2:text-lg prose-h3:text-base prose-li:my-1 prose-ul:my-3 prose-ol:my-3 prose-table:my-5 prose-pre:my-4 prose-hr:my-6 max-w-none text-[15px] break-words`,p),style:{overflowWrap:`anywhere`},children:t(yi,{artifactRunId:i,children:L})}),t(`style`,{children:`
|
|
29
|
+
`)?e:bd(e)}const wd=[`className`,`cardClassName`,`headerClassName`,`contentClassName`,`timestampClassName`,`senderClassName`,`iconClassName`,`detailsClassName`,`artifactsClassName`,`proseClassName`];function Td(e,t,...n){let r={};for(let i of wd)r[i]=V(e[i],t[i],...n.map(e=>e?.[i]));return r}const Ed={Ready:`agent.ready`,Error:`agent.error`},Dd={[Q.ANSWER]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Agent`,Icon:yt},[Q.COMPLETE]:{borderColor:`border-s-success`,iconColor:`text-success`,sender:`Completed`,Icon:wt},[Q.IDLE]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Ready`,Icon:Ht},[Q.REQUEST_INPUT]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Input`,Icon:mr},[Q.QUESTION]:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`User`,Icon:mr},[Q.THOUGHT]:{borderColor:`border-s-purple-500`,iconColor:`text-purple-600 dark:text-purple-400`,sender:`Agent`,Icon:yt},[Q.ERROR]:{borderColor:`border-s-destructive`,iconColor:`text-destructive`,sender:`Error`,Icon:pt},[Q.UPDATE]:{borderColor:`border-s-success`,iconColor:`text-success`,sender:`Update`,Icon:yn},[Q.PLAN]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Plan`,Icon:jn},[Q.TERMINATED]:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`Terminated`,Icon:wt},[Q.WARNING]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Warning`,Icon:pt},[Q.SYSTEM]:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`System`,Icon:yn},[Q.STREAMING_CHUNK]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Agent`,Icon:yt},[Q.BATCH_PROGRESS]:{borderColor:`border-s-blue-500`,iconColor:`text-blue-600 dark:text-blue-400`,sender:`Batch`,Icon:xn},[Q.RESTARTING]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Restarting`,Icon:Kn},default:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`Agent`,Icon:yt}};function Od({message:e,showPulsatingCircle:r=!1,onSendMessage:a,requestInputAnswered:s=!1,className:c,cardClassName:l,headerClassName:u,contentClassName:d,timestampClassName:f,senderClassName:p,iconClassName:m,detailsClassName:h,artifactsClassName:g,proseClassName:_,messageStyleOverrides:v,StoreLinkComponent:y,CollectionLinkComponent:b}){let[x,S]=Y(!1),{t:C}=X(),{client:T}=Z(),E=Ye(),D=Ca(),{openImage:O}=Vu(),{router:k}=Oi(),A=J(T);A.current=T;let j=J(D);j.current=D;let{renderContent:M,isDownloading:N}=fd({client:T,toast:E}),P=q(()=>{let t=Dd[e.type]||Dd.default,n=v?.default,r=v?.[e.type];return{...t,...n,...r,...Td(t,{className:c,cardClassName:l,headerClassName:u,contentClassName:d,timestampClassName:f,senderClassName:p,iconClassName:m,detailsClassName:h,artifactsClassName:g,proseClassName:_},n,r)}},[e.type,v,c,l,u,d,f,p,m,h,g,_]),F=q(()=>{let t=``;if(e.message&&(t=typeof e.message==`object`?JSON.stringify(e.message,null,2):e.message.trim?e.message.trim():String(e.message)),typeof t==`string`&&t.includes(`%thinking_message%`)){let e=Math.floor(Math.random()*zu.length);t=t.replace(/%thinking_message%/g,zu[e])}return t},[e.message]),I=q(()=>e.type===Q.QUESTION?id(F):null,[F,e.type]),L=I?.body??F,R=I?.attachments??[],ee=q(()=>L?Cd(L,e.type,typeof e.message==`string`?e.message:void 0):``,[L,e.type,e.message]),te=()=>{let t=F||``,n=typeof e.details==`string`?e.details:e.details?JSON.stringify(e.details,null,2):``,r=[t,n?`\n\nDetails:\n${n}`:``].join(``).trim();navigator.clipboard.writeText(r).then(()=>{E({status:`success`,title:C(`agent.copiedToClipboard`),duration:2e3})})},z=async t=>{let n=typeof F==`string`?F:``;if(!n.trim()){E({status:`error`,title:C(`agent.noContentToExport`),duration:2e3});return}let r=`Message ${ni(e.timestamp).format(`YYYY-MM-DD HH-mm-ss`)}`;await M(n,{format:t,title:r,artifactRunId:ce})},ne=typeof F==`string`&&F.trim().length>0,re=e.type===Q.REQUEST_INPUT?e.details?.ux:void 0,ie=q(()=>({a:({node:e,ref:n,...r})=>{let i=r.href||``,a=i.startsWith(`/`)?k.getTopRouter().navigator.addStickyParams(i):i;return i.includes(`/store/objects`)?y?t(y,{href:a,documentId:i.split(`/store/objects/`)[1]||``,children:r.children}):t(Ei,{href:a,topLevelNav:!0,children:r.children}):i.includes(`/store/collections`)?b?t(b,{href:a,collectionId:i.split(`/store/collections/`)[1]||``,children:r.children}):t(Ei,{href:a,topLevelNav:!0,children:r.children}):t(`a`,{...r,target:`_blank`,rel:`noopener noreferrer`})},img:({node:e,ref:n,...r})=>t(o,{variant:`unstyled`,className:`block p-0`,onClick:()=>r.src&&O(r.src,r.alt),"aria-label":r.alt||r.src||`image`,children:t(`img`,{...r,alt:r.alt??``,className:`max-w-full h-auto rounded-lg shadow-md my-3 cursor-pointer hover:shadow-lg transition-shadow`,loading:`lazy`})})}),[O,y,b,k]),ae=n=>{if(typeof n==`object`)return t(`pre`,{className:`text-xs font-mono whitespace-pre-wrap overflow-x-auto bg-gray-100 dark:bg-gray-800 p-2 rounded text-gray-700`,children:JSON.stringify(n,null,2)});let r=e.workflow_run_id;return!r&&typeof n==`string`&&n.includes(`artifact:`)&&console.warn(`[MessageItem] message contains artifact references but workflow_run_id is missing!`,{type:e.type,workflow_run_id:e.workflow_run_id,hasArtifact:n.includes(`artifact:`)}),t(`div`,{className:V(`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-3 prose-headings:font-semibold prose-headings:tracking-normal prose-headings:mt-6 prose-headings:mb-3 prose-h1:text-xl prose-h2:text-lg prose-h3:text-base prose-li:my-1 prose-ul:my-3 prose-ol:my-3 prose-table:my-5 prose-pre:my-4 prose-hr:my-6 max-w-none text-[15px] break-words`,P.proseClassName),style:{overflowWrap:`anywhere`},children:t(Li,{artifactRunId:r,onProposalSelect:e=>a?.(e),onProposalSubmit:e=>a?.(e),components:ie,children:n})})},[oe,se]=Y([]),ce=e.workflow_run_id,le=e.details,ue=le?.outputFiles??le?.files;K(()=>{(async()=>{if(!ce||!Array.isArray(ue)||ue.length===0){se([]);return}let e=A.current,t=j.current;try{let n=await Promise.all(ue.map(async n=>{if(typeof n!=`string`||!n.trim())return null;let r=n.trim(),i=r.startsWith(`artifact:`)?r.slice(9):r,a=i.split(`.`).pop()?.toLowerCase()||``,o=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(a),s=o?`inline`:`attachment`;try{let n=Ta(ce,i,s),a;return a=t?await t.getOrFetch(n,async()=>(await e.files.getArtifactDownloadUrl(ce,i,s)).url):(await e.files.getArtifactDownloadUrl(ce,i,s)).url,{displayName:r,artifactPath:i,url:a,isImage:o}}catch(e){return console.error(`Failed to resolve artifact URL for ${i}`,e),null}}));se(n.filter(e=>!!e))}catch(e){console.error(`Error loading artifact URLs from message details`,e),se([])}})()},[ce,ue]);let de=Vl(e),{Icon:fe}=P;return t(`div`,{className:V(`w-full max-w-full`,P.className),children:n(`div`,{className:V(`border-s-4 bg-white dark:bg-gray-900 mb-4 w-full max-w-full overflow-hidden`,P.borderColor,P.cardClassName),"data-workstream-id":de,children:[n(`div`,{className:V(`flex items-center justify-between px-4 py-1.5`,P.headerClassName),children:[n(`div`,{className:`flex items-center gap-1.5`,children:[t(`div`,{className:V(r?`animate-fadeIn`:``,P.iconClassName),children:r?t(Pu,{size:`sm`,color:`blue`}):t(fe,{className:`size-4 ${P.iconColor}`})}),t(`span`,{className:V(`text-xs font-medium text-muted`,P.senderClassName),children:Ed[P.sender]?C(Ed[P.sender]):P.sender}),de!==`main`&&de!==`all`&&t(i,{variant:`default`,className:`text-xs text-muted ms-1`,children:de})]}),n(`div`,{className:`flex items-center gap-1.5 print:hidden`,children:[t(dd,{message:e}),t(`span`,{className:V(`text-[11px] text-muted/70`,P.timestampClassName),children:ni(e.timestamp).format(`HH:mm:ss`)}),t(o,{variant:`ghost`,size:`xs`,onClick:te,className:`text-muted/50 hover:text-muted h-5 w-5 p-0`,title:C(`agent.copyMessage`),children:t(Gt,{className:`size-3`})}),ne&&n(w,{trigger:t(o,{variant:`ghost`,size:`xs`,className:`text-muted/50 hover:text-muted h-5 w-5 p-0`,title:C(`agent.exportMessage`),disabled:N,children:t(qt,{className:`size-3 ${N?`animate-pulse`:``}`})}),children:[t(B,{onClick:()=>z(Ir.pdf),children:C(`agent.exportAsPdf`)}),t(B,{onClick:()=>z(Ir.docx),children:C(`agent.exportAsWord`)})]})]})]}),n(`div`,{className:V(`px-4 pb-3 bg-white dark:bg-gray-900 overflow-hidden`,P.contentClassName),children:[re?t(yl,{question:typeof F==`string`?F:``,options:re.options,variant:re.variant,multiSelect:re.multiSelect,onSelect:t=>a?.(t,bu(e,t)),onMultiSelect:e=>a?.(e.join(`, `)),allowFreeResponse:!re.options?.length||!!re.free_response,placeholder:re.free_response?.placeholder,submitLabel:re.free_response?.submit_label,onSubmit:e=>a?.(e,re.free_response?.metadata),hideBorder:!0,compact:!0,answered:s}):L&&t(`div`,{className:`message-content break-words w-full`,style:{overflowWrap:`anywhere`,wordBreak:`break-word`},children:ae(ee||L)}),R.length>0&&t(td,{items:R,artifactRunId:ce,variant:`message`,className:V(L&&`mt-3`),StoreLinkComponent:y,CollectionLinkComponent:b}),oe.length>0&&n(`div`,{className:V(`mt-3 text-xs`,P.artifactsClassName),children:[t(`div`,{className:`font-medium text-muted mb-1`,children:`Artifacts`}),oe.some(e=>e.isImage)&&t(`div`,{className:`mb-2 flex flex-wrap gap-3`,children:oe.filter(e=>e.isImage).map(({displayName:e,artifactPath:r,url:i})=>n(o,{variant:`unstyled`,className:`max-w-xs cursor-pointer text-start p-0`,onClick:()=>O(i,e),"aria-label":e,children:[t(`img`,{src:i,alt:e,className:`max-w-full h-auto rounded-lg shadow-sm hover:shadow-md transition-shadow`}),t(`div`,{className:`mt-1 text-[11px] text-muted truncate`,children:e})]},`${r}-preview`))}),t(`div`,{className:`flex flex-wrap gap-2 print:hidden`,children:oe.map(({displayName:e,artifactPath:n,url:r})=>t(o,{variant:`outline`,size:`xs`,className:`px-2 py-1 text-xs`,onClick:()=>window.open(r,`_blank`),title:n,children:e},n+r))})]}),e.details&&n(`div`,{className:V(`mt-2 print:hidden`,P.detailsClassName),children:[n(o,{variant:`unstyled`,onClick:()=>S(!x),className:`text-[11px] text-muted flex items-center`,children:[C(x?`agent.hideDetails`:`agent.showDetails`),t(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-3 w-3 ms-1 transition-transform ${x?`rotate-180`:``}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})]}),x&&t(`div`,{className:`mt-1 p-1.5 bg-muted border border-mixer-muted/40 rounded text-sm`,children:typeof e.details==`string`?ae(e.details):t(`pre`,{className:`text-xs font-mono whitespace-pre-wrap overflow-x-auto bg-muted p-2 rounded text-muted`,children:JSON.stringify(e.details,null,2)})})]})]})]})})}const kd=it(Od,(e,t)=>e.message.timestamp===t.message.timestamp&&e.message.type===t.message.type&&e.message.message===t.message.message&&e.message.details===t.message.details&&e.message.workstream_id===t.message.workstream_id&&e.message.workflow_run_id===t.message.workflow_run_id&&e.showPulsatingCircle===t.showPulsatingCircle&&e.onSendMessage===t.onSendMessage&&e.requestInputAnswered===t.requestInputAnswered&&e.messageStyleOverrides===t.messageStyleOverrides&&wd.every(n=>e[n]===t[n]));function Ad({text:e,workstreamId:r,artifactRunId:i,revealSpeed:a=300,isComplete:s=!1,timestamp:c,className:l,cardClassName:u,headerClassName:d,contentClassName:f,proseClassName:p,senderClassName:m,iconClassName:h}){let{t:g}=X(),[_,v]=Y(0),[y,b]=Y(``),x=J(null),S=J(e.length),C=J(0),w=J(c||Date.now()),T=J(e),E=J(0),D=J(performance.now()),O=J(a),k=J(0);K(()=>{let t=performance.now(),n=e.length-E.current,r=t-D.current;if(n>0&&r>30){let e=n/r*1e3,t=.2;O.current=O.current*(1-t)+e*t,O.current=Math.max(50,Math.min(2e3,O.current))}E.current=e.length,D.current=t},[e.length]),S.current=e.length,T.current=e;let A=G(()=>{let e=performance.now(),t=n=>{let r=n-e;e=n;let i=S.current-C.current;if(i<=0){k.current=0,x.current=null;return}let a;if(s)a=Math.max(500,O.current*2);else if(i<20)a=O.current*.85;else if(i<100)a=O.current;else if(i<500){let e=(i-100)/400;a=O.current*(1+e*.5)}else a=O.current*2;let o=a*r/1e3+k.current,c=Math.floor(o);k.current=o-c,c>0&&(C.current=Math.min(C.current+c,S.current),v(C.current)),x.current=requestAnimationFrame(t)};x.current=requestAnimationFrame(t)},[s]);K(()=>(e.length>C.current&&!x.current&&A(),()=>{x.current&&=(cancelAnimationFrame(x.current),null)}),[e.length,A]),K(()=>{s&&C.current<e.length&&(x.current&&=(cancelAnimationFrame(x.current),null),A())},[s,e.length,A]);let j=J(null),M=J(0);K(()=>{(_>=S.current||s)&&(b(T.current.slice(0,_)),M.current=_)},[_,s]);let N=_<e.length&&!s;K(()=>{if(!N){j.current&&=(clearInterval(j.current),null);return}return j.current||=window.setInterval(()=>{let e=C.current;e>M.current&&(b(T.current.slice(0,e)),M.current=e)},33),()=>{j.current&&=(clearInterval(j.current),null)}},[N]);let P=Ye(),F=q(()=>ni(w.current).format(`HH:mm:ss`),[]),I=_<e.length,L=q(()=>{let t=y||e.slice(0,_);return I?t+`│`:t},[y,e,_,I]);return e?t(`div`,{className:V(`w-full max-w-full`,l),children:n(`div`,{className:V(`border-s-4 bg-white dark:bg-gray-900 mb-4 border-s-purple-500 w-full max-w-full overflow-hidden`,u),"data-workstream-id":r,children:[n(`div`,{className:V(`flex items-center justify-between px-4 py-1.5`,d),children:[n(`div`,{className:`flex items-center gap-1.5`,children:[t(`div`,{className:V(`animate-fadeIn`,h),children:I?t(`span`,{className:`size-2 rounded-full bg-blue-500 animate-pulse inline-block`}):t(yt,{className:`size-4 text-purple-600 dark:text-purple-400`})}),t(`span`,{className:V(`text-xs font-medium text-muted`,m),children:`Agent`}),r&&r!==`main`&&n(`span`,{className:`text-xs text-muted`,children:[`• Task `,r]})]}),n(`div`,{className:`flex items-center gap-2 text-muted`,children:[t(`span`,{className:`text-[11px]`,children:F}),t(o,{variant:`ghost`,size:`xs`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{P({status:`success`,title:g(`agent.copiedToClipboard`),duration:2e3})})},className:`size-6 p-0 hover:bg-gray-100 dark:hover:bg-gray-800`,title:g(`agent.copyMessage`),children:t(Gt,{className:`size-3`})})]})]}),n(`div`,{className:V(`px-3 pb-2 streaming-content`,I&&`streaming-active`,f),children:[t(`div`,{className:V(`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-3 prose-headings:font-semibold prose-headings:tracking-normal prose-headings:mt-6 prose-headings:mb-3 prose-h1:text-xl prose-h2:text-lg prose-h3:text-base prose-li:my-1 prose-ul:my-3 prose-ol:my-3 prose-table:my-5 prose-pre:my-4 prose-hr:my-6 max-w-none text-[15px] break-words`,p),style:{overflowWrap:`anywhere`},children:t(Li,{artifactRunId:i,children:L})}),t(`style`,{children:`
|
|
30
30
|
/* Ensure inline elements flow properly */
|
|
31
31
|
.streaming-content p:last-child,
|
|
32
32
|
.streaming-content li:last-child {
|
|
@@ -37,11 +37,11 @@ $&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
|
|
|
37
37
|
mask-image: linear-gradient(to right, black 97%, transparent 100%);
|
|
38
38
|
-webkit-mask-image: linear-gradient(to right, black 97%, transparent 100%);
|
|
39
39
|
}
|
|
40
|
-
`})]})]})}):null}const od=W.memo(ad);function sd(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function cd(e){let t=e.replace(/\s+/g,` `).trim().toLowerCase();return t===`thinking`||t===`thinking...`||t===`working`||t===`working...`||t===`waiting`||t===`waiting...`}function ld(e){return e.type===Q.THOUGHT&&e.details?.display_role===`thinking`}function ud(e){if(ld(e))return!0;if(e.type!==Q.WARNING)return!1;let t=e.details,n=sd(e).replace(/^[^A-Za-z0-9]+/,``).toLowerCase();return typeof t?.attempt==`number`&&typeof t?.maxAttempts==`number`&&typeof t?.estimatedBackoffSeconds==`number`&&typeof t?.activityId==`string`&&(n.startsWith(`retrying operation`)||n.startsWith(`retrying checkpoint operation`))}function dd(e){if(typeof e==`number`)return e;if(!e)return-1/0;let t=new Date(e).getTime();return Number.isFinite(t)?t:-1/0}function fd(e){return e.reduce((e,t)=>Math.max(e,dd(t.timestamp)),-1/0)}function pd(e,t){let n=e.details?.[t];return typeof n==`string`&&n.trim()||void 0}function md(e,t,n){if(!e.some(ud))return e;if(!t)return e.filter(e=>!ud(e));let r=-1,i=-1;return e.forEach((e,t)=>{ud(e)?i=t:r=t}),e.filter((e,t)=>ud(e)?t===i&&t>r&&dd(e.timestamp)>=n:!0)}function hd(e){if(al(e))return!1;let t=sd(e);return!t||cd(t)?!1:e.type===Q.ANSWER?!0:Ol(e)?!1:e.type===Q.THOUGHT&&!!e.details?.streamed}function gd(e){if(e.type!==Q.ERROR&&e.type!==Q.WARNING)return!1;let t=e.details;return!!(t?.tool||t?.tool_status||t?.tool_run_id||t?.activity_group_id||t?.tool_event)}function _d(e){if(e.type!==Q.ERROR||gd(e))return!1;let t=e.details;return sd(e).startsWith(`Error analyzing conversation:`)&&typeof t?.error==`string`}function vd(e){if(e.type!==Q.ERROR)return!1;let t=e.details;return t?.event_class!==`activity`||t.workstream_event?!1:!(t.tool||t.tool_status||t.tool_run_id||t.activity_group_id||t.tool_event)}function yd(e){return al(e)||vd(e)?!1:e.type===Q.QUESTION||!!cl(e)||hd(e)||e.type===Q.REQUEST_INPUT&&!Yl(e)||e.type===Q.TERMINATED||(e.type===Q.ERROR||e.type===Q.WARNING)&&!gd(e)&&!ud(e)}function bd(e){let t=e.details?.tool_status;if(t===`running`||t===`completed`||t===`error`||t===`warning`)return t;if(e.type===Q.ERROR)return`error`;if(e.type===Q.WARNING)return`warning`}function xd(e,t){for(let n=e.length-1;n>=0;n--){let r=bd(e[n]);if(r===`error`||r===`warning`)return r;if(r)return t?`running`:`completed`}return t?`running`:`completed`}function Sd(e,t){return kl(e)&&!ld(e)&&t.length>0&&t.every(ld)}function Cd(e){return al(e)||hd(e)||cl(e)?!1:vd(e)||ud(e)||Yl(e)||gd(e)||Ol(e)||kl(e)||e.type===Q.UPDATE||e.type===Q.PLAN?!0:e.type===Q.THOUGHT&&!e.details?.streamed}function wd(e,t,n=fd(e)){let r=[],i=[],a=new Set,o=(e,t)=>{if(i.length===0)return;let a=md(i,e,n);if(a.length===0){i=[];return}let o=a[0],s=a[a.length-1],c=xd(a,e);r.push({type:`work`,id:e?`${o.timestamp}-active`:`${o.timestamp}-${s.timestamp}-${a.length}`,messages:a,isActive:e,status:c,startTimestamp:o.timestamp,endTimestamp:t?.timestamp??s.timestamp}),i=[]};for(let t of e){let e=cl(t),n=e?null:ll(t),s=e??n;if(s){let n=a.has(s.workstreamId);if(a.add(s.workstreamId),e||!n){o(!1,t),r.push({type:`message`,message:t});continue}}if(t.type===Q.COMPLETE||t.type===Q.IDLE){if(gl(t)){let e=i[0]?.timestamp;o(!1,t);let n=r[r.length-1];r.push({type:`stopped`,message:t,startTimestamp:e!==void 0&&n?.type===`work`?n.startTimestamp:e??t.timestamp,endTimestamp:t.timestamp});continue}o(!1,t);continue}if(Cd(t)||i.length>0&&_d(t)){if(Sd(t,i)){let e=r[r.length-1];if(e?.type===`work`&&!e.isActive){r.pop(),i=[...e.messages,t];continue}}i.push(t);continue}yd(t)&&(o(!1,t),r.push({type:`message`,message:t}))}return o(!t),r}function Td(e,t){if(e.activityId){let n=t.find(t=>kl(t)&&(pd(t,`activity_id`)===e.activityId||pd(t,`activity_group_id`)===e.activityId));if(n)return n;let r=t.find(t=>pd(t,`activity_id`)===e.activityId&&pd(t,`activity_group_id`))?.details?.activity_group_id;if(typeof r==`string`){let e=t.find(e=>kl(e)&&pd(e,`activity_group_id`)===r);if(e)return e}}if(e.isComplete)return;let n=dd(e.startTimestamp);if(!Number.isFinite(n))return;let r=[...t].filter(e=>dd(e.timestamp)>=n).sort((e,t)=>dd(e.timestamp)-dd(t.timestamp));for(let e of r){if(dd(e.timestamp)-n>6e4)return;if(kl(e))return e;if(yd(e))return}}function Ed(e,t){if(t.size===0)return e;let n=e.find(e=>e.workflow_run_id)?.workflow_run_id??``,r=[];return t.forEach((t,i)=>{let a=t.text.trim();if(!a||Tl(t,e)||il(a,t.workstreamId))return;let o=Td(t,e),s=o?pd(o,`activity_group_id`):void 0;r.push({timestamp:t.startTimestamp,workflow_run_id:n,type:o?Q.THOUGHT:Q.ANSWER,message:a,workstream_id:t.workstreamId,details:{activity_id:t.activityId,activity_group_id:s,display_role:o?`tool_preamble`:void 0,source:`streaming_summary`,streamed:!0,streaming_id:i,tools:o?.details?.tool?[o.details.tool]:void 0}})}),r.length===0?e:[...e,...r].sort((e,t)=>dd(e.timestamp)-dd(t.timestamp))}function Dd(e,t,n){let r=e[e.length-1];return r?r.type===`work`?r.endTimestamp??r.startTimestamp:r.message.timestamp??n:t.reduce((e,t)=>{let n=dd(t.timestamp);return!Number.isFinite(n)||n>=e.ms?e:{timestamp:t.timestamp,ms:n}},{ms:1/0}).timestamp??n}function Od(e,t,n){if(!t||n||e.some(e=>e.type===`work`&&e.isActive))return!1;let r=e[e.length-1];return r?r.type===`work`?!0:r.message.type===Q.QUESTION:!1}function kd(e){let t=e[e.length-1];return t?t.type===`message`&&t.message.type===Q.QUESTION&&e.length===1:!1}const Ad=new Set([`tool`,`tool_event`,`tool_run_id`,`tool_use_id`,`activity_group_id`,`event_class`,`tool_iteration`,`tool_status`,`message_to_human`,`tools`,`streamed`,`files`,`outputFiles`,`display_role`,`observation`,`progress_messages`,`browseruse`,`browser_use`]);function jd(e){return e?Object.entries(e).filter(([e,t])=>!Ad.has(e)&&t!=null&&t!==``):[]}function Md(e){return e.replace(/_/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function Nd(e){let t=e?.progress_messages;return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e,n=typeof t.message==`string`?t.message.trim():``;return n?[{message:n,status:typeof t.status==`string`?t.status:void 0,timestamp:typeof t.timestamp==`number`||typeof t.timestamp==`string`?t.timestamp:void 0}]:[]}):[]}function Pd(e){return[`progress`,e.timestamp??`no-time`,e.status??`status`,e.message].join(`:`)}function Fd(e){let t=e.details,n=typeof t?.tool_run_id==`string`?t.tool_run_id:void 0;if(n)return`tool-run:${n}`;let r=typeof t?.activity_group_id==`string`?t.activity_group_id:void 0,i=typeof t?.tool_use_id==`string`?t.tool_use_id:void 0;return r||i?`tool:${r??`no-activity`}:${i??`no-use`}`:[`message`,e.workstream_id??`main`,e.type,e.timestamp,Ud(e)].join(`:`)}function Id(e,t){return e.timestamp===t.timestamp&&e.type===t.type&&e.message===t.message&&e.details===t.details&&e.workstream_id===t.workstream_id&&e.workflow_run_id===t.workflow_run_id}function Ld(e){switch(e){case`completed`:return`bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-300 border-green-200 dark:border-green-800`;case`running`:return`bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-800`;case`error`:return`bg-red-50 dark:bg-red-900/30 text-red-700 dark:text-red-300 border-red-200 dark:border-red-800`;case`warning`:return`bg-yellow-50 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800`;default:return``}}function Rd(e){let t=new Map,n=[];for(let r of e){let e=r.details?.tool_run_id;e?(t.has(e)||t.set(e,[]),t.get(e)?.push(r)):n.push(r)}for(let[e,r]of t){if(r.length<=1){n.push(...r);continue}r.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime()));let e=r[r.length-1],t=r.find(e=>e.details?.tool_event===`started`),i=r.find(e=>e.details?.tool_status===`running`),a=t??i??r.find(e=>e.message?.trim()),o=(typeof a?.details?.message_to_human==`string`?a.details.message_to_human:void 0)||a?.message||e.message,s=r.filter(e=>e.details?.tool_event===`progress`&&e.message?.trim()).map(e=>({message:e.message.trim(),status:e.details?.tool_status,timestamp:e.timestamp})),c={};for(let e of r)Object.assign(c,e.details);s.length>0&&(c.progress_messages=s),n.push({...e,message:o,details:c})}return n.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),n}const zd=e=>/\.(png|jpg|jpeg|gif|webp|svg)(\?|$)/i.test(e);function Bd({files:e,className:r}){let{t:i}=X(),{openImage:a}=gu();return!e||e.length===0?null:t(`div`,{className:H(`mt-2 flex flex-wrap gap-2`,r),children:e.map(e=>{let r=e.split(`/`).pop()?.split(`?`)[0]||`file`;return zd(e)?t(o,{variant:`unstyled`,className:`cursor-pointer p-0`,onClick:()=>a(e,r),title:i(`agent.clickToEnlarge`),"aria-label":r,children:t(`img`,{src:e,alt:r,className:`max-w-[300px] max-h-[200px] rounded border hover:opacity-80 transition-opacity hover:shadow-lg`})},e):n(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 px-2 py-1 bg-muted rounded text-xs hover:bg-muted/80`,children:[`📎 `,r]},e)})})}const Vd=e=>{if(!e)return;let t=e.files??e.outputFiles;return Array.isArray(t)?t:void 0},Hd=e=>{let t=e.details;return e.type===Q.THOUGHT&&t?.display_role===`tool_preamble`},Ud=e=>{let t=e.details;if(Hd(e))return`assistant`;if(t?.tool)return t.tool;switch(e.type){case Q.UPDATE:return`update`;case Q.WARNING:return`warning`;case Q.ERROR:return`error`;case Q.SYSTEM:return`system`;default:return`activity`}},Wd=e=>Hd(e)?`text-[10px] px-1.5 py-0.5 rounded-md bg-gray-50 dark:bg-gray-800 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-gray-700 font-medium`:`text-[10px] px-1.5 py-0.5 rounded-md bg-purple-50 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 border border-purple-200 dark:border-purple-800 font-medium`;function Gd({message:e,isExpanded:r,onToggle:i,artifactRunId:a,classNames:s={}}){let{t:c}=X(),[l,u]=Y([]),d=He(),{client:f}=Z(),p=ta(),m=J(f);m.current=f;let h=J(p);h.current=p;let g=e.details,_=Ud(e),v=Wd(e),y=Vd(g),b=typeof e.message==`string`?e.message:``;K(()=>{if(!y||y.length===0||!a){u([]);return}let e=!1;return(async()=>{let t=m.current,n=h.current,r=await Promise.all(y.map(async e=>{if(!e||typeof e!=`string`)return null;if(e.startsWith(`http://`)||e.startsWith(`https://`))return e;let r=e.startsWith(`artifact:`)?e.slice(9):e,i=r.split(`.`).pop()?.toLowerCase()||``,o=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(i)?`inline`:`attachment`;try{let e=ra(a,r,o);return n?await n.getOrFetch(e,async()=>(await t.files.getArtifactDownloadUrl(a,r,o)).url):(await t.files.getArtifactDownloadUrl(a,r,o)).url}catch(e){return console.error(`Failed to resolve artifact URL for ${r}`,e),null}}));e||u(r.filter(e=>!!e))})(),()=>{e=!0}},[y,a]);let x=l.filter(e=>zd(e)),S=l.filter(e=>!zd(e)),C=()=>{let e=[b,g?`\n\nDetails:\n${JSON.stringify(g,null,2)}`:``].join(``).trim();navigator.clipboard.writeText(e).then(()=>{d({status:`success`,title:c(`agent.copiedToClipboard`),duration:2e3})})};return n(`div`,{className:H(`border-b border-gray-100 dark:border-gray-800 last:border-b-0`,s.itemClassName),children:[n(`div`,{role:`button`,tabIndex:0,className:H(`flex items-start justify-between px-3 py-2 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors`,s.itemHeaderClassName),onClick:i,onKeyDown:Fe(i),children:[n(`div`,{className:`flex items-start gap-2 flex-1 min-w-0`,children:[t(`div`,{className:`flex-shrink-0 pt-0.5`,children:r?t(yt,{className:`size-3 text-muted`}):t(St,{className:`size-3 text-muted cn-rtl-flip`})}),t(`div`,{className:`flex-1 min-w-0`,children:b?t(`span`,{className:`text-xs text-foreground line-clamp-2`,children:b}):n(`span`,{className:`text-xs text-muted italic`,children:[`Activity: `,_]})})]}),n(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[!r&&t(`span`,{className:H(v,s.toolBadgeClassName),children:_}),t(o,{variant:`ghost`,size:`xs`,onClick:e=>{e.stopPropagation(),C()},className:`text-muted opacity-0 group-hover:opacity-100 transition-opacity`,title:c(`agent.copyMessage`),children:t(Ft,{className:`size-3`})})]})]}),x.length>0&&t(`div`,{className:`px-3 pb-1.5`,children:t(Bd,{files:x})}),r&&(()=>{let r=g?.tool_status,i=jd(g),o=Nd(g);return n(`div`,{className:H(`px-4 py-2 bg-gray-50/50 dark:bg-gray-800/30`,s.itemContentClassName),children:[n(`div`,{className:`flex items-center gap-2 mb-2 flex-wrap`,children:[t(`span`,{className:H(v,s.toolBadgeClassName),children:_}),r&&t(`span`,{className:H(`text-[10px] px-1.5 py-0.5 rounded-md border font-medium`,Ld(r)),children:r}),t(`span`,{className:`text-[10px] text-muted/70`,children:Rr(e.timestamp).format(`HH:mm:ss`)})]}),i.length>0&&t(`div`,{className:`mb-2 space-y-0.5`,children:i.map(([e,r])=>n(`div`,{className:`flex gap-1.5 text-xs`,children:[n(`span`,{className:`text-muted font-medium flex-shrink-0`,children:[Md(e),`:`]}),t(`span`,{className:`text-foreground break-all`,children:typeof r==`object`?JSON.stringify(r):String(r)})]},e))}),o.length>0&&n(`div`,{className:`mb-2 space-y-1`,children:[t(`div`,{className:`text-[10px] uppercase tracking-wide text-muted/70 font-medium`,children:c(`agent.progress`)}),o.map(e=>n(`div`,{className:`text-xs text-muted`,children:[e.timestamp&&t(`span`,{className:`me-1 text-muted/60`,children:Rr(e.timestamp).format(`HH:mm:ss`)}),t(`span`,{children:e.message})]},Pd(e)))]}),(()=>{let e=typeof g?.observation==`string`?g.observation:void 0;return e&&e!==b?t(`div`,{className:`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-1.5 max-w-none text-sm`,children:t(yi,{artifactRunId:a,children:e})}):null})(),S.length>0&&t(Bd,{files:S})]})})()]})}function Kd({files:e,artifactRunId:n}){let[r,i]=Y([]),{client:a}=Z(),o=ta(),s=J(a);s.current=a;let c=J(o);return c.current=o,K(()=>{if(!e||e.length===0||!n){i([]);return}let t=!1;return(async()=>{let r=s.current,a=c.current,o=await Promise.all(e.map(async e=>{if(!e||typeof e!=`string`)return null;let t=e.startsWith(`artifact:`)?e.slice(9):e,i=t.split(`.`).pop()?.toLowerCase()||``;if(new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(i))return null;if(t.startsWith(`http://`)||t.startsWith(`https://`))return t;try{let e=ra(n,t,`attachment`);return a?await a.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(n,t,`attachment`)).url):(await r.files.getArtifactDownloadUrl(n,t,`attachment`)).url}catch(e){return console.error(`Failed to resolve artifact URL for ${t}`,e),null}}));t||i(o.filter(e=>!!e))})(),()=>{t=!0}},[e,n]),r.length===0?null:t(`div`,{className:`ps-4 pe-2 pb-1.5`,children:t(Bd,{files:r})})}function qd({messages:e,artifactRunId:n}){let[r,i]=Y([]),{client:a}=Z(),o=ta(),s=J(a);s.current=a;let c=J(o);return c.current=o,K(()=>{if(!n||e.length===0){i([]);return}let t=e[e.length-1].details,r=Vd(t);if(!r||r.length===0){i([]);return}let a=!1;return(async()=>{let e=s.current,t=c.current,o=await Promise.all(r.map(async r=>{if(!r||typeof r!=`string`)return null;let i=r.startsWith(`artifact:`)?r.slice(9):r,a=i.split(`.`).pop()?.toLowerCase()||``;if(!new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(a))return null;if(i.startsWith(`http://`)||i.startsWith(`https://`))return i;try{let r=ra(n,i,`inline`);return t?await t.getOrFetch(r,async()=>(await e.files.getArtifactDownloadUrl(n,i,`inline`)).url):(await e.files.getArtifactDownloadUrl(n,i,`inline`)).url}catch(e){return console.error(`Failed to resolve artifact URL for ${i}`,e),null}}));a||i(o.filter(e=>!!e))})(),()=>{a=!0}},[e,n]),r.length===0?null:t(`div`,{className:`px-3 py-1.5 border-b border-gray-100 dark:border-gray-800`,children:t(Bd,{files:r})})}function Jd({messages:r,showPulsatingCircle:i=!1,toolRunId:a,toolStatus:s,preambleText:c,preambleMessage:l,rootClassName:u,headerClassName:d,senderClassName:f,toolSummaryClassName:p,toolBadgeClassName:m,itemClassName:h,itemHeaderClassName:g,itemContentClassName:_}){let v=q(()=>Rd(r),[r]),y=q(()=>v.map(Fd),[v]),[b,x]=Y(!0),[S,C]=Y(new Set),[w,T]=Y(new Set),E=J(y),{t:D}=X(),O=He(),k=v.find(e=>e.workflow_run_id)?.workflow_run_id??v[0]?.workflow_run_id,A=()=>i?t(lu,{size:`sm`,color:`blue`}):s===`running`?t(`span`,{className:`size-2 rounded-full bg-blue-500 inline-block`}):s===`completed`?t(ht,{className:`size-4 text-success`}):s===`error`?t(at,{className:`size-4 text-destructive`}):s===`warning`?t(st,{className:`size-4 text-attention`}):t(dt,{className:`size-4 text-purple-600 dark:text-purple-400`}),j=()=>s===`completed`?`border-s-success`:s===`error`?`border-s-destructive`:s===`warning`?`border-s-attention`:`border-s-purple-500`;K(()=>{let e=E.current,t=new Set(e),n=y.filter(e=>!t.has(e));if(n.length>0){T(new Set(n));let e=setTimeout(()=>{T(new Set)},500);return E.current=y,()=>clearTimeout(e)}E.current=y},[y]);let M=v[0],N=v[v.length-1],P=M.timestamp,F=N.timestamp,I=v.map(e=>Ud(e)),L=new Set(I).size===1?`${v.length}× ${I[0]}`:`${v.length} activity updates`,R=e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},z=()=>{let e=v.map(e=>{let t=e.details;return`[${Ud(e)}] ${e.message||``}\n${t?JSON.stringify(t,null,2):``}`}).join(`
|
|
40
|
+
`})]})]})}):null}const jd=W.memo(Ad);function Md(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function Nd(e){let t=e.replace(/\s+/g,` `).trim().toLowerCase();return t===`thinking`||t===`thinking...`||t===`working`||t===`working...`||t===`waiting`||t===`waiting...`}function Pd(e){return e.type===Q.THOUGHT&&e.details?.display_role===`thinking`}function Fd(e){if(Pd(e))return!0;if(e.type!==Q.WARNING)return!1;let t=e.details,n=Md(e).replace(/^[^A-Za-z0-9]+/,``).toLowerCase();return typeof t?.attempt==`number`&&typeof t?.maxAttempts==`number`&&typeof t?.estimatedBackoffSeconds==`number`&&typeof t?.activityId==`string`&&(n.startsWith(`retrying operation`)||n.startsWith(`retrying checkpoint operation`))}function Id(e){if(typeof e==`number`)return e;if(!e)return-1/0;let t=new Date(e).getTime();return Number.isFinite(t)?t:-1/0}function Ld(e){return e.reduce((e,t)=>Math.max(e,Id(t.timestamp)),-1/0)}function Rd(e,t){let n=e.details?.[t];return typeof n==`string`&&n.trim()||void 0}function zd(e,t,n){if(!e.some(Fd))return e;if(!t)return e.filter(e=>!Fd(e));let r=-1,i=-1;return e.forEach((e,t)=>{Fd(e)?i=t:r=t}),e.filter((e,t)=>!Fd(e)||t===i&&t>r&&Id(e.timestamp)>=n)}function Bd(e){if(Ol(e))return!1;let t=Md(e);return!t||Nd(t)?!1:e.type===Q.ANSWER||!Zl(e)&&e.type===Q.THOUGHT&&!!e.details?.streamed}function Vd(e){if(e.type!==Q.ERROR&&e.type!==Q.WARNING)return!1;let t=e.details;return!!(t?.tool||t?.tool_status||t?.tool_run_id||t?.activity_group_id||t?.tool_event)}function Hd(e){if(e.type!==Q.ERROR||Vd(e))return!1;let t=e.details;return Md(e).startsWith(`Error analyzing conversation:`)&&typeof t?.error==`string`}function Ud(e){if(e.type!==Q.ERROR)return!1;let t=e.details;return t?.event_class!==`activity`||t.workstream_event?!1:!(t.tool||t.tool_status||t.tool_run_id||t.activity_group_id||t.tool_event)}function Wd(e){return Ol(e)||Ud(e)?!1:e.type===Q.QUESTION||!!jl(e)||Bd(e)||e.type===Q.REQUEST_INPUT&&!vu(e)||e.type===Q.TERMINATED||(e.type===Q.ERROR||e.type===Q.WARNING)&&!Vd(e)&&!Fd(e)}function Gd(e){let t=e.details?.tool_status;if(t===`running`||t===`completed`||t===`error`||t===`warning`)return t;if(e.type===Q.ERROR)return`error`;if(e.type===Q.WARNING)return`warning`}function Kd(e,t){for(let n=e.length-1;n>=0;n--){let r=Gd(e[n]);if(r===`error`||r===`warning`)return r;if(r)return t?`running`:`completed`}return t?`running`:`completed`}function qd(e,t){return Ql(e)&&!Pd(e)&&t.length>0&&t.every(Pd)}function Jd(e){return Ol(e)||Bd(e)||jl(e)?!1:Ud(e)||Fd(e)||vu(e)||Vd(e)||Zl(e)||Ql(e)||e.type===Q.UPDATE||e.type===Q.PLAN?!0:e.type===Q.THOUGHT&&!e.details?.streamed}function Yd(e,t,n=Ld(e)){let r=[],i=[],a=new Set,o=(e,t)=>{if(i.length===0)return;let a=zd(i,e,n);if(a.length===0){i=[];return}let o=a[0],s=a[a.length-1],c=Kd(a,e);r.push({type:`work`,id:e?`${o.timestamp}-active`:`${o.timestamp}-${s.timestamp}-${a.length}`,messages:a,isActive:e,status:c,startTimestamp:o.timestamp,endTimestamp:t?.timestamp??s.timestamp}),i=[]};for(let t of e){let e=jl(t),n=e?null:Ml(t),s=e??n;if(s){let n=a.has(s.workstreamId);if(a.add(s.workstreamId),e||!n){o(!1,t),r.push({type:`message`,message:t});continue}}if(t.type===Q.COMPLETE||t.type===Q.IDLE){if(zl(t)){let e=i[0]?.timestamp;o(!1,t);let n=r[r.length-1];r.push({type:`stopped`,message:t,startTimestamp:e!==void 0&&n?.type===`work`?n.startTimestamp:e??t.timestamp,endTimestamp:t.timestamp});continue}o(!1,t);continue}if(Jd(t)||i.length>0&&Hd(t)){if(qd(t,i)){let e=r[r.length-1];if(e?.type===`work`&&!e.isActive){r.pop(),i=[...e.messages,t];continue}}i.push(t);continue}Wd(t)&&(o(!1,t),r.push({type:`message`,message:t}))}return o(!t),r}function Xd(e,t){if(e.activityId){let n=t.find(t=>Ql(t)&&(Rd(t,`activity_id`)===e.activityId||Rd(t,`activity_group_id`)===e.activityId));if(n)return n;let r=t.find(t=>Rd(t,`activity_id`)===e.activityId&&Rd(t,`activity_group_id`))?.details?.activity_group_id;if(typeof r==`string`){let e=t.find(e=>Ql(e)&&Rd(e,`activity_group_id`)===r);if(e)return e}}if(e.isComplete)return;let n=Id(e.startTimestamp);if(!Number.isFinite(n))return;let r=[...t].filter(e=>Id(e.timestamp)>=n).sort((e,t)=>Id(e.timestamp)-Id(t.timestamp));for(let e of r){if(Id(e.timestamp)-n>6e4)return;if(Ql(e))return e;if(Wd(e))return}}function Zd(e,t){if(t.size===0)return e;let n=e.find(e=>e.workflow_run_id)?.workflow_run_id??``,r=[];return t.forEach((t,i)=>{let a=t.text.trim();if(!a||Jl(t,e)||Dl(a,t.workstreamId))return;let o=Xd(t,e),s=o?Rd(o,`activity_group_id`):void 0;r.push({timestamp:t.startTimestamp,workflow_run_id:n,type:o?Q.THOUGHT:Q.ANSWER,message:a,workstream_id:t.workstreamId,details:{activity_id:t.activityId,activity_group_id:s,display_role:o?`tool_preamble`:void 0,source:`streaming_summary`,streamed:!0,streaming_id:i,tools:o?.details?.tool?[o.details.tool]:void 0}})}),r.length===0?e:[...e,...r].sort((e,t)=>Id(e.timestamp)-Id(t.timestamp))}function Qd(e,t,n){let r=e[e.length-1];return r?r.type===`work`?r.endTimestamp??r.startTimestamp:r.message.timestamp??n:t.reduce((e,t)=>{let n=Id(t.timestamp);return!Number.isFinite(n)||n>=e.ms?e:{timestamp:t.timestamp,ms:n}},{ms:1/0}).timestamp??n}function $d(e,t,n){if(!t||n||e.some(e=>e.type===`work`&&e.isActive))return!1;let r=e[e.length-1];return r?r.type===`work`||r.message.type===Q.QUESTION:!1}function ef(e){let t=e[e.length-1];return t?t.type===`message`&&t.message.type===Q.QUESTION&&e.length===1:!1}const tf=new Set([`tool`,`tool_event`,`tool_run_id`,`tool_use_id`,`activity_group_id`,`event_class`,`tool_iteration`,`tool_status`,`message_to_human`,`tools`,`streamed`,`files`,`outputFiles`,`display_role`,`observation`,`progress_messages`,`browseruse`,`browser_use`]);function nf(e){return e?Object.entries(e).filter(([e,t])=>!tf.has(e)&&t!=null&&t!==``):[]}function rf(e){return e.replace(/_/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function af(e){let t=e?.progress_messages;return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e,n=typeof t.message==`string`?t.message.trim():``;return n?[{message:n,status:typeof t.status==`string`?t.status:void 0,timestamp:typeof t.timestamp==`number`||typeof t.timestamp==`string`?t.timestamp:void 0}]:[]}):[]}function of(e){return[`progress`,e.timestamp??`no-time`,e.status??`status`,e.message].join(`:`)}function sf(e){let t=e.details,n=typeof t?.tool_run_id==`string`?t.tool_run_id:void 0;if(n)return`tool-run:${n}`;let r=typeof t?.activity_group_id==`string`?t.activity_group_id:void 0,i=typeof t?.tool_use_id==`string`?t.tool_use_id:void 0;return r||i?`tool:${r??`no-activity`}:${i??`no-use`}`:[`message`,e.workstream_id??`main`,e.type,e.timestamp,hf(e)].join(`:`)}function cf(e,t){return e.timestamp===t.timestamp&&e.type===t.type&&e.message===t.message&&e.details===t.details&&e.workstream_id===t.workstream_id&&e.workflow_run_id===t.workflow_run_id}function lf(e){switch(e){case`completed`:return`bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-300 border-green-200 dark:border-green-800`;case`running`:return`bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-800`;case`error`:return`bg-red-50 dark:bg-red-900/30 text-red-700 dark:text-red-300 border-red-200 dark:border-red-800`;case`warning`:return`bg-yellow-50 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800`;default:return``}}function uf(e){let t=new Map,n=[];for(let r of e){let e=r.details?.tool_run_id;e?(t.has(e)||t.set(e,[]),t.get(e)?.push(r)):n.push(r)}for(let[e,r]of t){if(r.length<=1){n.push(...r);continue}r.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime()));let e=r[r.length-1],t=r.find(e=>e.details?.tool_event===`started`),i=r.find(e=>e.details?.tool_status===`running`),a=t??i??r.find(e=>e.message?.trim()),o=(typeof a?.details?.message_to_human==`string`?a.details.message_to_human:void 0)||a?.message||e.message,s=r.filter(e=>e.details?.tool_event===`progress`&&e.message?.trim()).map(e=>({message:e.message.trim(),status:e.details?.tool_status,timestamp:e.timestamp})),c={};for(let e of r)Object.assign(c,e.details);s.length>0&&(c.progress_messages=s),n.push({...e,message:o,details:c})}return n.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),n}const df=e=>/\.(png|jpg|jpeg|gif|webp|svg)(\?|$)/i.test(e);function ff({files:e,className:r}){let{t:i}=X(),{openImage:a}=Vu();return!e||e.length===0?null:t(`div`,{className:V(`mt-2 flex flex-wrap gap-2`,r),children:e.map(e=>{let r=e.split(`/`).pop()?.split(`?`)[0]||`file`;return df(e)?t(o,{variant:`unstyled`,className:`cursor-pointer p-0`,onClick:()=>a(e,r),title:i(`agent.clickToEnlarge`),"aria-label":r,children:t(`img`,{src:e,alt:r,className:`max-w-[300px] max-h-[200px] rounded border hover:opacity-80 transition-opacity hover:shadow-lg`})},e):n(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 px-2 py-1 bg-muted rounded text-xs hover:bg-muted/80`,children:[`📎 `,r]},e)})})}const pf=e=>{if(!e)return;let t=e.files??e.outputFiles;return Array.isArray(t)?t:void 0},mf=e=>{let t=e.details;return e.type===Q.THOUGHT&&t?.display_role===`tool_preamble`},hf=e=>{let t=e.details;if(mf(e))return`assistant`;if(t?.tool)return t.tool;switch(e.type){case Q.UPDATE:return`update`;case Q.WARNING:return`warning`;case Q.ERROR:return`error`;case Q.SYSTEM:return`system`;default:return`activity`}},gf=e=>mf(e)?`text-[10px] px-1.5 py-0.5 rounded-md bg-gray-50 dark:bg-gray-800 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-gray-700 font-medium`:`text-[10px] px-1.5 py-0.5 rounded-md bg-purple-50 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 border border-purple-200 dark:border-purple-800 font-medium`;function _f({message:e,isExpanded:r,onToggle:i,artifactRunId:a,classNames:s={}}){let{t:c}=X(),[l,u]=Y([]),d=Ye(),{client:f}=Z(),p=Ca(),m=J(f);m.current=f;let h=J(p);h.current=p;let g=e.details,_=hf(e),v=gf(e),y=pf(g),b=typeof e.message==`string`?e.message:``;K(()=>{if(!y||y.length===0||!a){u([]);return}let e=!1;return(async()=>{let t=m.current,n=h.current,r=await Promise.all(y.map(async e=>{if(!e||typeof e!=`string`)return null;if(e.startsWith(`http://`)||e.startsWith(`https://`))return e;let r=e.startsWith(`artifact:`)?e.slice(9):e,i=r.split(`.`).pop()?.toLowerCase()||``,o=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(i)?`inline`:`attachment`;try{let e=Ta(a,r,o);return n?await n.getOrFetch(e,async()=>(await t.files.getArtifactDownloadUrl(a,r,o)).url):(await t.files.getArtifactDownloadUrl(a,r,o)).url}catch(e){return console.error(`Failed to resolve artifact URL for ${r}`,e),null}}));e||u(r.filter(e=>!!e))})(),()=>{e=!0}},[y,a]);let x=l.filter(e=>df(e)),S=l.filter(e=>!df(e)),C=()=>{let e=[b,g?`\n\nDetails:\n${JSON.stringify(g,null,2)}`:``].join(``).trim();navigator.clipboard.writeText(e).then(()=>{d({status:`success`,title:c(`agent.copiedToClipboard`),duration:2e3})})};return n(`div`,{className:V(`border-b border-gray-100 dark:border-gray-800 last:border-b-0`,s.itemClassName),children:[n(`div`,{role:`button`,tabIndex:0,className:V(`flex items-start justify-between px-3 py-2 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors`,s.itemHeaderClassName),onClick:i,onKeyDown:Ve(i),children:[n(`div`,{className:`flex items-start gap-2 flex-1 min-w-0`,children:[t(`div`,{className:`flex-shrink-0 pt-0.5`,children:r?t(Ot,{className:`size-3 text-muted`}):t(jt,{className:`size-3 text-muted cn-rtl-flip`})}),t(`div`,{className:`flex-1 min-w-0`,children:b?t(`span`,{className:`text-xs text-foreground line-clamp-2`,children:b}):n(`span`,{className:`text-xs text-muted italic`,children:[`Activity: `,_]})})]}),n(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[!r&&t(`span`,{className:V(v,s.toolBadgeClassName),children:_}),t(o,{variant:`ghost`,size:`xs`,onClick:e=>{e.stopPropagation(),C()},className:`text-muted opacity-0 group-hover:opacity-100 transition-opacity`,title:c(`agent.copyMessage`),children:t(Gt,{className:`size-3`})})]})]}),x.length>0&&t(`div`,{className:`px-3 pb-1.5`,children:t(ff,{files:x})}),r&&(()=>{let r=g?.tool_status,i=nf(g),o=af(g);return n(`div`,{className:V(`px-4 py-2 bg-gray-50/50 dark:bg-gray-800/30`,s.itemContentClassName),children:[n(`div`,{className:`flex items-center gap-2 mb-2 flex-wrap`,children:[t(`span`,{className:V(v,s.toolBadgeClassName),children:_}),r&&t(`span`,{className:V(`text-[10px] px-1.5 py-0.5 rounded-md border font-medium`,lf(r)),children:r}),t(`span`,{className:`text-[10px] text-muted/70`,children:ni(e.timestamp).format(`HH:mm:ss`)})]}),i.length>0&&t(`div`,{className:`mb-2 space-y-0.5`,children:i.map(([e,r])=>n(`div`,{className:`flex gap-1.5 text-xs`,children:[n(`span`,{className:`text-muted font-medium flex-shrink-0`,children:[rf(e),`:`]}),t(`span`,{className:`text-foreground break-all`,children:typeof r==`object`?JSON.stringify(r):String(r)})]},e))}),o.length>0&&n(`div`,{className:`mb-2 space-y-1`,children:[t(`div`,{className:`text-[10px] uppercase tracking-wide text-muted/70 font-medium`,children:c(`agent.progress`)}),o.map(e=>n(`div`,{className:`text-xs text-muted`,children:[e.timestamp&&t(`span`,{className:`me-1 text-muted/60`,children:ni(e.timestamp).format(`HH:mm:ss`)}),t(`span`,{children:e.message})]},of(e)))]}),(()=>{let e=typeof g?.observation==`string`?g.observation:void 0;return e&&e!==b?t(`div`,{className:`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-1.5 max-w-none text-sm`,children:t(Li,{artifactRunId:a,children:e})}):null})(),S.length>0&&t(ff,{files:S})]})})()]})}function vf({files:e,artifactRunId:n}){let[r,i]=Y([]),{client:a}=Z(),o=Ca(),s=J(a);s.current=a;let c=J(o);return c.current=o,K(()=>{if(!e||e.length===0||!n){i([]);return}let t=!1;return(async()=>{let r=s.current,a=c.current,o=await Promise.all(e.map(async e=>{if(!e||typeof e!=`string`)return null;let t=e.startsWith(`artifact:`)?e.slice(9):e,i=t.split(`.`).pop()?.toLowerCase()||``;if(new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(i))return null;if(t.startsWith(`http://`)||t.startsWith(`https://`))return t;try{let e=Ta(n,t,`attachment`);return a?await a.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(n,t,`attachment`)).url):(await r.files.getArtifactDownloadUrl(n,t,`attachment`)).url}catch(e){return console.error(`Failed to resolve artifact URL for ${t}`,e),null}}));t||i(o.filter(e=>!!e))})(),()=>{t=!0}},[e,n]),r.length===0?null:t(`div`,{className:`ps-4 pe-2 pb-1.5`,children:t(ff,{files:r})})}function yf({messages:e,artifactRunId:n}){let[r,i]=Y([]),{client:a}=Z(),o=Ca(),s=J(a);s.current=a;let c=J(o);return c.current=o,K(()=>{if(!n||e.length===0){i([]);return}let t=e[e.length-1].details,r=pf(t);if(!r||r.length===0){i([]);return}let a=!1;return(async()=>{let e=s.current,t=c.current,o=await Promise.all(r.map(async r=>{if(!r||typeof r!=`string`)return null;let i=r.startsWith(`artifact:`)?r.slice(9):r,a=i.split(`.`).pop()?.toLowerCase()||``;if(!new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(a))return null;if(i.startsWith(`http://`)||i.startsWith(`https://`))return i;try{let r=Ta(n,i,`inline`);return t?await t.getOrFetch(r,async()=>(await e.files.getArtifactDownloadUrl(n,i,`inline`)).url):(await e.files.getArtifactDownloadUrl(n,i,`inline`)).url}catch(e){return console.error(`Failed to resolve artifact URL for ${i}`,e),null}}));a||i(o.filter(e=>!!e))})(),()=>{a=!0}},[e,n]),r.length===0?null:t(`div`,{className:`px-3 py-1.5 border-b border-gray-100 dark:border-gray-800`,children:t(ff,{files:r})})}function bf({messages:r,showPulsatingCircle:i=!1,toolRunId:a,toolStatus:s,preambleText:c,preambleMessage:l,rootClassName:u,headerClassName:d,senderClassName:f,toolSummaryClassName:p,toolBadgeClassName:m,itemClassName:h,itemHeaderClassName:g,itemContentClassName:_}){let v=q(()=>uf(r),[r]),y=q(()=>v.map(sf),[v]),[b,x]=Y(!0),[S,C]=Y(new Set),[w,T]=Y(new Set),E=J(y),{t:D}=X(),O=Ye(),k=v.find(e=>e.workflow_run_id)?.workflow_run_id??v[0]?.workflow_run_id,A=()=>i?t(Pu,{size:`sm`,color:`blue`}):s===`running`?t(`span`,{className:`size-2 rounded-full bg-blue-500 inline-block`}):s===`completed`?t(wt,{className:`size-4 text-success`}):s===`error`?t(pt,{className:`size-4 text-destructive`}):s===`warning`?t(ht,{className:`size-4 text-attention`}):t(yt,{className:`size-4 text-purple-600 dark:text-purple-400`}),j=()=>s===`completed`?`border-s-success`:s===`error`?`border-s-destructive`:s===`warning`?`border-s-attention`:`border-s-purple-500`;K(()=>{let e=E.current,t=new Set(e),n=y.filter(e=>!t.has(e));if(n.length>0){T(new Set(n));let e=setTimeout(()=>{T(new Set)},500);return E.current=y,()=>clearTimeout(e)}E.current=y},[y]);let M=v[0],N=v[v.length-1],P=M.timestamp,F=N.timestamp,I=v.map(e=>hf(e)),L=new Set(I).size===1?`${v.length}× ${I[0]}`:`${v.length} activity updates`,R=e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ee=()=>{let e=v.map(e=>{let t=e.details;return`[${hf(e)}] ${e.message||``}\n${t?JSON.stringify(t,null,2):``}`}).join(`
|
|
41
41
|
|
|
42
42
|
---
|
|
43
43
|
|
|
44
|
-
`);navigator.clipboard.writeText(e).then(()=>{O({status:`success`,title:D(`agent.copiedAllToolCalls`),duration:2e3})})};return n(`div`,{className:
|
|
44
|
+
`);navigator.clipboard.writeText(e).then(()=>{O({status:`success`,title:D(`agent.copiedAllToolCalls`),duration:2e3})})};return n(`div`,{className:V(`border-s-4 overflow-hidden bg-white dark:bg-gray-900 mb-4`,j(),u),children:[n(`div`,{role:`button`,tabIndex:0,"aria-expanded":!b,className:V(`flex items-center justify-between px-4 py-1.5 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors`,d),onClick:()=>x(!b),onKeyDown:Ve(()=>x(!b)),children:[n(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[A(),c?t(`span`,{className:V(`text-xs text-foreground line-clamp-2 flex-1 min-w-0`,p),children:c}):n(e,{children:[t(`span`,{className:V(`text-xs font-medium text-muted`,f),children:`Agent`}),t(`span`,{className:V(`text-xs text-purple-600 dark:text-purple-400 font-medium`,p),children:L})]}),b?t(jt,{className:`size-3 text-muted flex-shrink-0 cn-rtl-flip`}):t(Ot,{className:`size-3 text-muted flex-shrink-0`})]}),n(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[c&&t(`span`,{className:V(`text-[10px] text-purple-600 dark:text-purple-400 font-medium`,p),children:L}),n(`span`,{className:`text-[11px] text-muted/70`,children:[ni(P).format(`HH:mm:ss`),v.length>1&&` - ${ni(F).format(`HH:mm:ss`)}`]}),t(o,{variant:`ghost`,size:`xs`,onClick:e=>{e.stopPropagation(),ee()},className:`text-muted/50 hover:text-muted h-5 w-5 p-0`,title:D(`agent.copyAllToolCalls`),children:t(Gt,{className:`size-3`})})]})]}),t(yf,{messages:v,artifactRunId:k}),b&&t(`div`,{className:`px-3 py-0.5 space-y-0`,children:v.map((e,r)=>{let i=y[r]??sf(e),a=e.details,o=hf(e),s=gf(e),c=typeof e.message==`string`?e.message:``,l=w.has(i),u=S.has(i),d=pf(a);return n(`div`,{className:V(`border-b border-gray-100 dark:border-gray-800 last:border-b-0`,h),style:{opacity:+!l,transform:l?`translateX(-10px)`:`translateX(0)`,transition:`opacity 0.3s ease-out, transform 0.3s ease-out`,transitionDelay:`${(r-(v.length-w.size))*100}ms`,animation:l?`slideInFade 0.4s ease-out forwards`:`none`,animationDelay:`${(r-(v.length-w.size))*100}ms`},children:[n(`div`,{role:`button`,tabIndex:0,"aria-expanded":u,className:V(`flex items-start gap-2 py-1.5 text-xs cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50`,g),onClick:()=>R(i),onKeyDown:Ve(()=>R(i)),title:c,children:[t(`div`,{className:`flex-shrink-0 pt-0.5`,children:u?t(Ot,{className:`size-3 text-muted`}):t(jt,{className:`size-3 text-muted cn-rtl-flip`})}),t(`div`,{className:`flex-1 min-w-0`,children:c?t(`span`,{className:`text-foreground line-clamp-2`,children:c}):n(`span`,{className:`text-muted italic`,children:[`Activity: `,o]})}),!u&&t(`span`,{className:V(s,`flex-shrink-0`,m),children:o})]}),t(vf,{files:d,artifactRunId:k}),u&&(()=>{let r=a?.tool_status,i=nf(a),l=af(a);return n(`div`,{className:V(`ps-5 pe-3 pb-2 text-sm`,_),children:[n(`div`,{className:`flex items-center gap-2 mb-1.5 flex-wrap`,children:[t(`span`,{className:V(s,m),children:o}),r&&t(`span`,{className:V(`text-[10px] px-1.5 py-0.5 rounded-md border font-medium`,lf(r)),children:r}),t(`span`,{className:`text-[10px] text-muted/70`,children:ni(e.timestamp).format(`HH:mm:ss`)})]}),i.length>0&&t(`div`,{className:`mb-1.5 space-y-0.5`,children:i.map(([e,r])=>n(`div`,{className:`flex gap-1.5 text-xs`,children:[n(`span`,{className:`text-muted font-medium flex-shrink-0`,children:[rf(e),`:`]}),t(`span`,{className:`text-foreground break-all`,children:typeof r==`object`?JSON.stringify(r):String(r)})]},e))}),l.length>0&&n(`div`,{className:`mb-1.5 space-y-1`,children:[t(`div`,{className:`text-[10px] uppercase tracking-wide text-muted/70 font-medium`,children:D(`agent.progress`)}),l.map(e=>n(`div`,{className:`text-xs text-muted`,children:[e.timestamp&&t(`span`,{className:`me-1 text-muted/60`,children:ni(e.timestamp).format(`HH:mm:ss`)}),t(`span`,{children:e.message})]},of(e)))]}),(()=>{let e=typeof a?.observation==`string`?a.observation:void 0;return e&&e!==c?t(`div`,{className:`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-1.5 max-w-none text-sm`,children:t(Li,{artifactRunId:k,children:e})}):null})()]})})()]},i)})}),t(`style`,{children:`
|
|
45
45
|
@keyframes slideInFade {
|
|
46
46
|
from {
|
|
47
47
|
opacity: 0;
|
|
@@ -52,11 +52,11 @@ $&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
|
|
|
52
52
|
transform: translateX(0);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
`}),!b&&t(`div`,{className:`group`,children:v.map((e,n)=>{let r=y[n]??Fd(e);return t(Gd,{message:e,isExpanded:S.has(r),onToggle:()=>R(r),artifactRunId:k,classNames:{toolBadgeClassName:m,itemClassName:h,itemHeaderClassName:g,itemContentClassName:_}},r)})})]})}const Yd=Ze(Jd,(e,t)=>e.messages.length!==t.messages.length||e.showPulsatingCircle!==t.showPulsatingCircle||e.toolRunId!==t.toolRunId||e.toolStatus!==t.toolStatus||e.preambleText!==t.preambleText||e.rootClassName!==t.rootClassName||e.headerClassName!==t.headerClassName||e.senderClassName!==t.senderClassName||e.toolSummaryClassName!==t.toolSummaryClassName||e.toolBadgeClassName!==t.toolBadgeClassName||e.itemClassName!==t.itemClassName||e.itemHeaderClassName!==t.itemHeaderClassName||e.itemContentClassName!==t.itemContentClassName?!1:e.messages.every((e,n)=>Id(e,t.messages[n]))),Xd=`flex items-center gap-1.5 px-2 py-1 text-xs font-medium whitespace-nowrap transition-colors border-b-2 shrink-0 cursor-pointer`,Zd=`border-transparent text-muted hover:bg-muted`,Qd=`border-info bg-info text-info`;function $d(e){return e.length>20?`${e.substring(0,18)}...`:e}function ef({items:e,current:r,onSelect:i,label:a,active:o,count:s,completionStatus:c}){let[l,u]=Y(!1),d=J(null),f=J(!1),p=()=>{d.current&&=(clearTimeout(d.current),null)},m=()=>{p(),f.current=!0,u(!0)},h=()=>{p(),d.current=setTimeout(()=>u(!1),150)};return K(()=>()=>clearTimeout(d.current??void 0),[]),n(x,{modal:!1,open:l,onOpenChange:e=>{p(),e&&(f.current=!1),u(e)},children:[t(E,{asChild:!0,children:n(`button`,{type:`button`,onMouseEnter:m,onMouseLeave:h,className:H(Xd,o?Qd:Zd),children:[a,t(yt,{className:`ms-0.5 size-3.5`})]})}),t(S,{align:`end`,className:`w-max`,onMouseEnter:p,onMouseLeave:h,onCloseAutoFocus:e=>{f.current&&e.preventDefault()},children:e.map(([e,a])=>{let o=(s?.get(e)??0)>0;return n(C,{onClick:()=>i(e),className:H(`flex items-center gap-2`,e===r&&`text-info`),children:[t(`span`,{className:`truncate`,children:a}),o&&n(`span`,{className:`ms-auto inline-flex items-center gap-1`,children:[t(`span`,{className:`inline-flex items-center justify-center rounded-full bg-muted px-1.5 text-[10px] text-muted`,children:s?.get(e)}),c&&e!==`all`&&(c.get(e)?t(ht,{className:`size-3 text-success`}):t(Mt,{className:`size-3 text-attention`}))]})]},e)})})]})}function tf({entries:r,activeWorkstream:i,onSelectWorkstream:a,count:o,completionStatus:s}){let{t:c}=X(),l=J(null),u=J([]),d=J(null),[f,p]=Y({count:r.length,promote:!1}),m=()=>{let e=l.current;if(!e)return;let t=e.clientWidth,n=r.map((e,t)=>u.current[t]?.offsetWidth??0),a=n.reduce((e,t)=>e+t,0)+4*Math.max(0,r.length-1),o=(e,t)=>{let i=0,a=0;for(let o=0;o<r.length;o++){if(o===t)continue;let r=i+(a>0?4:0)+n[o];if(r>e)break;i=r,a+=1}return a},s;if(a<=t)s={count:r.length,promote:!1};else{let e=d.current?.offsetWidth??0,a=Math.max(1,o(t-e-4,-1)),c=r.findIndex(([e])=>e===i);s=c<0||c<a?{count:a,promote:!1}:{count:o(t-e-n[c]-8,c),promote:!0}}p(e=>e.count===s.count&&e.promote===s.promote?e:s)},h=J(m);h.current=m,et(()=>{h.current()}),K(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>h.current());return t.observe(e),()=>t.disconnect()},[]);let g=r.findIndex(([e])=>e===i),_,v;if(f.promote&&g>=0){let e=r.filter((e,t)=>t!==g);_=[...e.slice(0,f.count),r[g]],v=e.slice(f.count)}else _=r.slice(0,f.count),v=r.slice(f.count);let y=v.some(([e])=>e===i),b=c(`agent.moreTabs`),x=(r,i,a)=>{let c=(o?.get(r)??0)>0;return n(e,{children:[$d(i),c&&n(`span`,{className:`flex items-center gap-1`,children:[t(`span`,{className:H(`inline-flex items-center justify-center p-1 text-xs rounded-full`,a?`bg-info text-info`:`bg-muted text-muted`),children:o?.get(r)}),s&&r!==`all`&&(s.get(r)?t(ht,{className:`size-3 text-success`}):t(Mt,{className:`size-3 text-attention`}))]})]})};return n(`div`,{ref:l,className:`relative mb-1 bg-muted border-b border-muted/20`,children:[n(`div`,{"aria-hidden":!0,className:`pointer-events-none invisible absolute start-0 top-0 flex w-max gap-1`,children:[r.map(([e,n],r)=>t(`button`,{type:`button`,tabIndex:-1,ref:e=>{u.current[r]=e},className:H(Xd,Zd),children:x(e,n,!1)},e)),n(`button`,{type:`button`,tabIndex:-1,ref:d,className:H(Xd,Zd),children:[b,t(yt,{className:`ms-0.5 size-3.5`})]})]}),n(`div`,{className:`flex gap-1 overflow-hidden`,children:[_.map(([e,n])=>{let r=i===e;return t(`button`,{type:`button`,"aria-current":r?`page`:void 0,onClick:()=>a(e),title:n.length>20?n:void 0,className:H(Xd,r?Qd:Zd),children:x(e,n,r)},e)}),v.length>0&&t(ef,{items:v,current:i,onSelect:a,label:b,active:y,count:o,completionStatus:s})]})]})}function nf({workstreams:e,activeWorkstream:n,onSelectWorkstream:r,count:i,completionStatus:a}){let{t:o}=X(),s=new Map;s.set(`all`,o(`agent.allMessages`)),s.set(`main`,o(`agent.main`)),e.forEach((e,t)=>{t!==`all`&&t!==`main`&&t!==`research_france`&&t!==`statistics`&&s.set(t,e)}),e=s;let c=Array.from(e.entries()).sort(([e],[t])=>e===`all`?-1:t===`all`?1:e===`main`?-1:t===`main`?1:e.localeCompare(t));return c.length>2?t(tf,{entries:c,activeWorkstream:n,onSelectWorkstream:r,count:i,completionStatus:a}):t(`div`,{className:`py-0.5`})}function rf(e){let t=new Map,n=rt.getFixedT(null,nt);return t.set(`all`,n(`agent.allMessages`)),t.set(`main`,n(`agent.main`)),e.forEach(e=>{e.workstream_id&&e.workstream_id!==`main`&&e.workstream_id!==`all`&&!t.has(e.workstream_id)&&t.set(e.workstream_id,e.workstream_id)}),t}function af(e,t){return t===`all`?[...e]:t===`main`?e.filter(e=>vl(e)===`main`):e.filter(e=>vl(e)===t)}const of=e=>e.type===Q.BATCH_PROGRESS&&!!e.details?.batch_id;function sf(e){if(e==null||e===``)return Date.now();let t=typeof e==`number`?e:new Date(e).getTime();return Number.isFinite(t)?t:Date.now()}function cf(e){let t=Date.now()-sf(e);return Math.max(0,Math.round(t/1e3))}function lf(e,t){let n=sf(t)-sf(e);return Math.max(0,Math.round(n/1e3))}function uf(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function df(e){if(e==null||e===``)return;let t=typeof e==`number`?e:new Date(e).getTime();return Number.isFinite(t)?t:void 0}function ff(e){let t=df(e);if(t!==void 0)return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(new Date(t))}function pf(e){let t=e.details,n=t?.tool||``,r=Array.isArray(t?.tools)?t.tools.map(e=>typeof e==`string`?e:e.name||e.tool||``).filter(Boolean):[],i=[n,...r].join(` `).toLowerCase(),a=n.toLowerCase(),o=typeof e.message==`string`?e.message.trim():``;return t?.display_role===`tool_preamble`?i.includes(`search`)||i.includes(`web`)||i.includes(`fetch`)?`Preparing search`:r.length>0?`Preparing tools`:`Thinking`:a.includes(`search`)?`Searching`:a.includes(`fetch`)||a.includes(`web`)?`Searching the web`:a.includes(`read`)||a.includes(`document`)?`Reading`:a.includes(`edit`)||a.includes(`write`)||a.includes(`create`)?`Editing`:a.includes(`bash`)||a.includes(`shell`)||a.includes(`command`)?`Running command`:o||`Using tool`}function mf(e){return e?`Working`:`Worked`}function hf(e){return e.length>0&&e.every(ud)}function gf(e){return mf(e)}function _f(e){let t=e.filter(e=>vl(e)===`main`);return(t[t.length-1]??e[e.length-1])?.type===Q.QUESTION}function vf(e,t){let n=e.filter(e=>vl(e)===`main`),r=n[n.length-1]??e[e.length-1];if(!r||!ru(r,t))return!1;let i=hp(r);return i===`allow_once`||i===`allow_for_run`}function yf(e){if(e.type!==Q.UPDATE)return;let t=ep(e);if(t.tool!==void 0||t.activity_group_id!==void 0)return;let n=typeof t.path==`string`&&t.path.trim()?t.path.trim():void 0;if(n)return Sf(e)===`Prepared and saved artifact to ${n}`?n:void 0}function bf(e,t){let n=vl(e[t]);for(let r=t-1;r>=0;--r){let t=e[r];if(vl(t)!==n)continue;let i=ep(t);if(i.tool===`write_artifact`&&typeof i.activity_group_id==`string`)return t;if(t.type!==Q.REQUEST_INPUT&&!hp(t)&&i.display_role!==`thinking`&&(typeof i.tool==`string`&&i.tool!==`write_artifact`||t.type===Q.ANSWER||t.type===Q.COMPLETE||t.type===Q.IDLE||t.type===Q.TERMINATED))return}}function xf(e){return e.map((t,n)=>{let r=yf(t);if(!r)return t;let i=bf(e,n),a=i?ep(i):void 0;if(!a)return t;let o=typeof a.activity_group_id==`string`?a.activity_group_id:void 0,s=typeof a.tool_run_id==`string`?a.tool_run_id:void 0,c=typeof a.tool_use_id==`string`?a.tool_use_id:void 0,l=typeof a.tool_iteration==`number`?a.tool_iteration:void 0;return o?{...t,details:{...t.details,event_class:`activity`,tool:`write_artifact`,tool_run_id:s??`write_artifact`,tool_use_id:c??s??`write_artifact`,tool_iteration:l,tool_status:`completed`,tool_event:`progress`,activity_group_id:o,output:Sf(t),path:r}}:t})}function Sf(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function Cf({message:e,details:r,onSelectWorkstream:i}){let{t:a}=X(),o=el(r.workstreamId,r.interaction),s=r.interaction?Qc(r.interaction):``,c=s&&s!==o?s:void 0;return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":r.workstreamId,children:n(`button`,{type:`button`,className:H(`group flex w-full items-start gap-3 border-b border-border/70 py-2 text-start text-sm text-muted`,`transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2`,`focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-background`),onClick:()=>i?.(r.workstreamId),children:[t(dt,{className:`mt-0.5 size-4 shrink-0 text-muted`,"aria-hidden":`true`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[t(`span`,{className:`font-medium text-muted`,children:a(`agent.workstreams`)}),t(`span`,{className:`min-w-0 truncate text-foreground/85`,children:o})]}),c&&t(`div`,{className:`mt-0.5 truncate text-xs text-muted/75`,children:c}),t(`span`,{className:`sr-only`,children:Sf(e)})]}),t(St,{className:`mt-0.5 size-4 shrink-0 text-muted transition-transform group-hover:translate-x-0.5 rtl:rotate-180 rtl:group-hover:-translate-x-0.5`})]})})}const wf=[`agent-markdown vprose prose max-w-none break-words text-sm leading-6 text-foreground/80`,`prose-p:my-2 prose-p:leading-6 prose-li:my-0.5 prose-pre:my-3 prose-headings:tracking-normal`,`prose-headings:text-foreground prose-strong:text-foreground prose-code:text-foreground`,`prose-a:text-foreground prose-a:underline prose-a:decoration-muted prose-a:underline-offset-4`,`[&_p]:text-foreground/80 [&_li]:text-foreground/80 [&_li::marker]:text-muted`].join(` `),Tf=/\[[^\]]+\]\((?:\/store\/(?:objects|collections)\/|store:|document:|document:\/\/|collection:)[^)]+\)/,Ef={table:Ff};function Df(e){if(!e||typeof e!=`object`)return``;let t=e;return typeof t.value==`string`?t.value:Array.isArray(t.children)?t.children.map(Df).join(``):``}function Of(e,t){if(!e||typeof e!=`object`)return[];let n=e.children;return Array.isArray(n)?n.filter(e=>{if(!e||typeof e!=`object`)return!1;let n=e;return t?n.tagName===t:typeof n.tagName==`string`}):[]}function kf(e){return Of(e).filter(e=>e.tagName===`thead`||e.tagName===`tbody`).flatMap(e=>Of(e,`tr`).map(e=>Of(e).filter(e=>e.tagName===`th`||e.tagName===`td`).map(e=>Df(e).replace(/\s+/g,` `).trim())))}function Af(e){return Of(e,`tbody`).flatMap(e=>Of(e,`tr`).map(e=>Of(e,`td`).map(e=>Df(e).replace(/\s+/g,` `).trim())))}function jf(e){let t=kf(e),n=Af(e),r=Math.max(0,...t.map(e=>e.length));if(r<=1)return new Set;let i=new Set;for(let e=0;e<r;e+=1){let t=n.map(t=>t[e]||``).map(e=>e.trim()).filter(Boolean);if(t.length===0)continue;let r=t.map(e=>e.length),a=Math.max(...r),o=r.reduce((e,t)=>e+t,0)/r.length,s=t.some(e=>/\S{12,}/.test(e));a<=16&&o<=10&&!s&&i.add(e)}return i.size>=r?new Set:i}function Mf(e,t,n){return Math.min(n,Math.max(t,e))}function Nf(e){return e.reduce((e,t)=>{let n=t.match(/\S+/g)||[];return Math.max(e,...n.map(e=>e.length))},0)}function Pf(e){let t=kf(e),n=Math.max(0,...t.map(e=>e.length));if(n<=1)return[];let r=jf(e),i=Array.from({length:n},(e,n)=>{if(r.has(n))return 8;let i=t.map(e=>e[n]||``).map(e=>e.trim()).filter(Boolean);if(i.length===0)return 18;let a=i.map(e=>e.length),o=Math.max(...a),s=a.reduce((e,t)=>e+t,0)/a.length,c=Nf(i);return Mf(s*.7+o*.25+c*.45,18,90)}),a=i.reduce((e,t)=>e+t,0);return a<=0?[]:i.map((e,t)=>{let n=`${(e/a*100).toFixed(3)}%`;return{key:`agent-markdown-table-column-${t}`,compact:r.has(t),width:n}})}function Ff({node:e,className:r,children:i,...a}){let o=Pf(e);return n(`table`,{...a,className:r,children:[o.length>0?t(`colgroup`,{children:o.map(e=>t(`col`,{className:e.compact?`agent-markdown-table-compact-col`:void 0,style:{"--agent-markdown-table-column-width":e.width}},e.key))}):null,i]})}function If(e){if(e==null||typeof e==`boolean`)return 0;if(typeof e==`string`||typeof e==`number`)return String(e).length;if(Array.isArray(e))return e.reduce((e,t)=>e+If(t),0);if(W.isValidElement(e)){let t=e.props;return If(t.children)}return 0}function Lf(e,t){let[n,r]=Y(()=>cf(e));return K(()=>{if(!t){r(cf(e));return}let n=()=>r(cf(e));n();let i=window.setInterval(n,1e3);return()=>window.clearInterval(i)},[t,e]),n}function Rf(e=!0){let[t,n]=Y(0);return K(()=>{if(!e)return;let t=window.setInterval(()=>{n(()=>Math.floor(Math.random()*mu.length))},4e3);return()=>window.clearInterval(t)},[e]),t}function zf({children:e,message:r,workstreamId:i,className:a,artifactRunId:o,markdownComponents:s}){let{t:c}=X(),[l,u]=Y(!1),d=q(()=>If(e),[e])>520,f=typeof e==`string`||typeof e==`number`,p=f?String(e):``,m=typeof e==`string`&&Tf.test(e),h=r?Ru(r):void 0;return K(()=>{!d&&l&&u(!1)},[l,d]),t(`div`,{className:`mx-auto flex w-full max-w-3xl justify-end px-1`,children:n(`div`,{className:H(`max-w-[min(44rem,82%)] rounded-[1.35rem] bg-mixer-muted/35 px-4 py-2.5`,`text-sm font-normal leading-6 text-foreground/90 shadow-sm shadow-black/5 dark:bg-mixer-muted/15 dark:text-foreground/88 dark:shadow-none`,`break-words [overflow-wrap:anywhere]`,a),"data-workstream-id":i,children:[t(`div`,{className:H(f&&!m&&`whitespace-pre-wrap`,d&&!l&&`max-h-72 overflow-hidden [mask-image:linear-gradient(to_bottom,black_76%,transparent_100%)]`),children:m?t(yi,{artifactRunId:o,components:s,className:H(`agent-markdown vprose prose max-w-none break-words text-sm leading-6 text-foreground/90`,`prose-p:my-0 prose-p:leading-6 prose-a:text-foreground prose-a:underline prose-a:decoration-muted prose-a:underline-offset-4`,`[&_p+_p]:mt-2`),children:p}):e}),d&&n(`button`,{type:`button`,"aria-expanded":l,className:`mt-2 inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>u(e=>!e),children:[c(l?`agent.showLess`:`agent.showMore`),t(yt,{className:H(`size-4 transition-transform`,l&&`rotate-180`),"aria-hidden":`true`})]}),r&&h?t(`div`,{className:`mt-1.5 flex justify-end`,children:t(Bu,{message:r,className:`h-4 w-4`})}):null]})})}function Bf({message:r,onSendMessage:i,onSelectWorkstream:a,requestInputAnswered:o=!1,StoreLinkComponent:s,CollectionLinkComponent:c}){let l=r.type===Q.REQUEST_INPUT?Rl(r):Sf(r),u=cl(r)??ll(r),d=vl(r),f=r.workflow_run_id,p=q(()=>r.type===Q.QUESTION?Nu(l):null,[l,r.type]),m=q(()=>({...Ef,a:({node:e,ref:n,...r})=>{let i=r.href||``;if(i.includes(`/store/objects`)){let e=i.split(`/store/objects/`)[1]||``;return s?t(s,{href:i,documentId:e,children:r.children}):t(ci,{href:i,topLevelNav:!0,children:r.children})}if(i.includes(`/store/collections`)){let e=i.split(`/store/collections/`)[1]||``;return c?t(c,{href:i,collectionId:e,children:r.children}):t(ci,{href:i,topLevelNav:!0,children:r.children})}return t(`a`,{...r,target:`_blank`,rel:`noopener noreferrer`})}}),[s,c]);if(u)return t(Cf,{message:r,details:u,onSelectWorkstream:a});if(r.type===Q.QUESTION){let i=p?.body??l,a=p?.attachments??[];return n(e,{children:[a.length>0&&t(`div`,{className:`mx-auto flex w-full max-w-3xl justify-end px-1`,children:t(Au,{items:a,artifactRunId:f,align:`end`,variant:`message`,StoreLinkComponent:s,CollectionLinkComponent:c})}),i&&t(zf,{message:r,workstreamId:d,artifactRunId:f,markdownComponents:m,children:i})]})}let h=r.details;if(r.type===Q.REQUEST_INPUT&&h?.ux){let e=h.ux;return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,children:t(Xc,{question:l,options:e.options,variant:e.variant,multiSelect:e.multiSelect,onSelect:e=>i?.(e),onMultiSelect:e=>i?.(e.join(`, `)),allowFreeResponse:!e.options?.length||!!e.free_response,placeholder:e.free_response?.placeholder,submitLabel:e.free_response?.submit_label,onSubmit:t=>i?.(t,e.free_response?.metadata),hideBorder:!0,compact:!0,answered:o})})}let g=r.type===Q.ERROR||r.type===Q.WARNING;return n(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":d,children:[g&&t(`div`,{className:`mb-2 text-xs font-medium text-destructive`,children:r.type===Q.WARNING?`Warning`:`Error`}),l&&t(`div`,{className:H(wf,g&&`rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2`),style:{overflowWrap:`anywhere`},children:t(yi,{artifactRunId:f,onProposalSelect:e=>i?.(e),onProposalSubmit:e=>i?.(e),components:m,children:l})})]})}function Vf(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Hf(e){return e==null?!1:typeof e==`string`?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e==`object`?Object.keys(e).length>0:!0}function Uf(e){return e==null||e===!1?!1:typeof e==`string`?e.trim().length>0:!0}function Wf(e){if(!e||!Vf(e))return{};let t=e.properties;return Vf(t)?t:{}}function Gf(e,t){let n=e&&Vf(e)?e.title:void 0;return typeof n==`string`&&n.trim()?n:t.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}function Kf(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function qf(e){return e==null||e===``?t(`span`,{className:`text-muted`,children:`Not provided`}):typeof e==`boolean`?e?`Yes`:`No`:typeof e==`number`?String(e):typeof e==`string`?t(`span`,{className:`whitespace-pre-wrap`,children:e}):Array.isArray(e)&&e.every(e=>typeof e!=`object`||!e)?e.map(e=>Kf(e)).join(`, `):t(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-md bg-background/55 px-2 py-1.5 font-mono text-[12px] leading-relaxed text-foreground/80`,children:Kf(e)})}function Jf(e,r,i){if(!Hf(e))return null;if(!Vf(e))return qf(e);let a=Wf(r),o=[...Object.keys(a),...Object.keys(e).filter(e=>!(e in a))].map(t=>({key:t,label:Gf(a[t],t),value:e[t]})).filter(e=>Hf(e.value));return o.length===0?null:n(`div`,{className:`space-y-2 text-start`,children:[i?t(`div`,{className:`text-xs font-medium uppercase tracking-normal text-muted`,children:i}):null,t(`dl`,{className:`space-y-2`,children:o.map(e=>n(`div`,{className:`grid gap-1 sm:grid-cols-[minmax(7rem,32%)_1fr] sm:gap-3`,children:[t(`dt`,{className:`text-xs font-medium text-muted`,children:e.label}),t(`dd`,{className:`min-w-0 break-words text-sm text-foreground`,children:qf(e.value)})]},e.key))})]})}function Yf({data:e,schema:n,title:r,template:i,prependFriendlyMessage:a,timestamp:o,isSummaryView:s,messageItemClassNames:c,messageStyleOverrides:l,StoreLinkComponent:u,CollectionLinkComponent:d}){let f=a?.trim()||(typeof e==`string`?e.trim():``),p=i?.({data:e??a,schema:n,title:r});if(!Uf(p)&&f){let e={type:Q.QUESTION,message:f,timestamp:sf(o),workflow_run_id:``,workstream_id:`main`};return s?t(Bf,{message:e,StoreLinkComponent:u,CollectionLinkComponent:d}):t(id,{...c,messageStyleOverrides:l,message:e})}let m=Uf(p)?p:Jf(e,n,r);return Uf(m)?t(zf,{className:`py-3`,children:m}):null}function Xf({label:e,timestamp:r,className:i}){let a=Rf(),o=Lf(r,!0);return t(`div`,{className:H(`mx-auto w-full max-w-3xl px-1`,i),children:n(`div`,{className:`border-b border-border/70 pb-4 text-sm text-muted`,children:[n(`div`,{className:`flex items-center gap-3`,children:[t(lu,{size:`sm`,color:`blue`}),n(`div`,{className:`min-w-0`,children:[n(`div`,{children:[t(`span`,{className:`font-medium`,children:e}),n(`span`,{className:`ms-2 text-muted/75`,children:[`for `,uf(o)]})]}),t(`div`,{className:`mt-1 truncate text-muted/80`,children:mu[a]})]})]}),t(`div`,{className:`mt-3 ps-6`,children:t(cu,{color:`blue`})})]})})}const Zf=`_summary_started_at`,Qf=`_summary_finished_at`,$f=new Set([`account_id`,`activity_group_id`,`activity_id`,`channel_id`,`collection_id`,`document_id`,`display_role`,`event_class`,`id`,`object_id`,`project_id`,`run_id`,`streamed`,`tenant_id`,`thread_id`,`tool`,`tool_event`,`tool_iteration`,`tool_run_id`,`tool_use_id`,`tool_status`,`tools`,`message_to_human`,`progress_messages`,`source`,`token_usage`,`checkpoint_at`,`checkpoint_threshold`,`approval_decision`,`approval_request`,`cancellation_reason`,Zf,Qf,`workflow_run_id`]);function ep(e){return Vf(e.details)?e.details:{}}function tp(e){if(e.type!==Q.UPDATE)return!1;let t=ep(e).event_class;return t===`document_created`||t===`document_updated`}function np(e){return e.replace(/[_-]+/g,` `).replace(/\s+/g,` `).trim().replace(/\b\w/g,e=>e.toUpperCase())}function rp(e){let t=[];if(typeof e.tool==`string`&&e.tool.trim()&&t.push(e.tool.trim()),Array.isArray(e.tools)){for(let n of e.tools)if(typeof n==`string`&&n.trim())t.push(n.trim());else if(Vf(n)){let e=typeof n.name==`string`?n.name:n.tool;typeof e==`string`&&e.trim()&&t.push(e.trim())}}return t}function ip(e){let t=Array.from(new Set(rp(e)));return t.length>0?t.join(`, `):void 0}function ap(e){return typeof e==`number`||typeof e==`string`?e:void 0}const op=[`query`,`path`,`file`,`file_name`,`fileName`,`filename`,`name`,`title`,`artifact`,`artifact_path`,`url`,`command`];function sp(e){for(let t of op){let n=e[t];if(typeof n==`string`&&n.trim())return{key:t,value:n.trim()};if(typeof n==`number`||typeof n==`boolean`)return{key:t,value:String(n)}}}function cp(e){let t=ep(e),n=rp(t).join(` `).toLowerCase(),r=typeof t.tool==`string`?t.tool.toLowerCase():``,i=r||n;return Ol(e)?`think`:r.startsWith(`learn_`)||n.includes(`learn_`)?`skill`:r===`discover_tools`?`discover`:e.type===Q.THOUGHT&&!r?`think`:i.includes(`search`)||i.includes(`web`)||i.includes(`fetch`)?`search`:i.includes(`read`)||i.includes(`document`)||i.includes(`file`)?`read`:i.includes(`edit`)||i.includes(`write`)||i.includes(`patch`)||i.includes(`create`)?`edit`:i.includes(`bash`)||i.includes(`shell`)||i.includes(`command`)||i.includes(`terminal`)?`command`:e.type===Q.THOUGHT&&n.length===0?`think`:`tool`}function lp(e){switch(e){case`search`:return`Search`;case`read`:return`Read`;case`edit`:return`Edit`;case`command`:return`Bash`;case`skill`:return`Skill`;case`discover`:return`Tool`;case`think`:return`Thought`;default:return`Tool`}}function up(e){let t=sp(e);if(t)return t.value;let n=e.files??e.outputFiles;if(Array.isArray(n)&&n.length>0)return n.map(e=>Kf(e)).join(`, `)}function dp(e,t){switch(e){case`denied`:case`denied_with_feedback`:return`User declined to use ${t}.`;case`timeout`:return`Approval timed out for ${t}.`;case`reviewer_denied`:return`Approval reviewer denied ${t}.`;case`cancelled_after_denial`:return`Cancelled ${t} after another tool was denied.`;default:return}}function fp(e){switch(e){case`denied`:case`denied_with_feedback`:return`Declined by user`;case`timeout`:return`Approval timed out`;case`reviewer_denied`:return`Denied by reviewer`;case`cancelled_after_denial`:return`Cancelled after denial`;default:return}}function pp(e){let t=ep(e).tool_approval;return Vf(t)?t:void 0}function mp(e){let t=e?.approval_key;return typeof t==`string`&&t.trim()?t.trim():void 0}function hp(e){if(e.type!==Q.QUESTION)return;let t=Sf(e).trim().toLowerCase();if(t===`allow_once`||t===`allow_for_run`||t===`deny`)return t}function gp(e){let t=e.tool_title;if(typeof t==`string`&&t.trim())return t.trim();let n=e.tool_name;return typeof n==`string`&&n.trim()?np(n.trim()):`tool action`}function _p(e,t){let n=[];return e.forEach((r,i)=>{if(r.type!==Q.REQUEST_INPUT)return;let a=pp(r),o=mp(a);if(!a||!o||t.has(o))return;let s=vl(r),c;for(let t=i+1;t<e.length;t+=1){let n=e[t];if(vl(n)===s){if(n.type===Q.REQUEST_INPUT)break;if(n.type===Q.QUESTION){c=n;break}}}if(!c||hp(c)!==`deny`)return;let l=typeof a.tool_name==`string`&&a.tool_name.trim()?a.tool_name.trim():`tool_action`,u=gp(a),d=typeof a.target==`string`&&a.target.trim()?a.target:``,f={tool_name:l,tool_title:a.tool_title,action_summary:a.action_summary,target:a.target,approval_key:o};n.push({timestamp:c.timestamp??r.timestamp,workflow_run_id:c.workflow_run_id||r.workflow_run_id,type:Q.THOUGHT,message:dp(`denied`,u)??`User declined to use ${u}.`,workstream_id:s,details:{event_class:`activity`,tool:l,tool_run_id:`approval:${o}`,tool_use_id:`approval:${o}`,tool_status:`error`,tool_event:`failed`,activity_group_id:`approval:${o}`,approval_decision:`denied`,approval_request:f,input:a.input,target:d,observation:`The user declined this tool action.`,source:`synthetic_tool_approval_decision`}})}),n.length===0?e:[...e,...n].sort((e,t)=>sf(e.timestamp)-sf(t.timestamp))}function vp(e,t=160){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}...`:n}const yp=[`batch_id`,`activity_group_id`,`activity_id`,`tool_run_id`,`tool_use_id`,`streaming_id`,`chunk_index`,`tool_iteration`,`tool_event`];function bp(e){for(let t of yp){let n=e[t];if(typeof n==`string`&&n.trim())return`${t}:${n.trim()}`;if(typeof n==`number`||typeof n==`boolean`)return`${t}:${n}`}}function xp(e,t=`message`){let n=bp(ep(e)),r=vp(Sf(e),96);return[t,e.workstream_id||`main`,e.workflow_run_id,e.timestamp,e.type,n??r].filter(Boolean).join(`:`)}function Sp(e){if(e.type===`single`)return xp(e.message);if(e.type===`streaming`)return`streaming:${e.streamingId}:${e.startTimestamp}:${e.workstreamId||`main`}`;let t=e.messages[0],n=e.messages[e.messages.length-1],r=t?xp(t,`first`):e.firstTimestamp,i=n?xp(n,`last`):e.firstTimestamp;return[`group`,e.toolRunId,e.firstTimestamp,r,i].filter(Boolean).join(`:`)}function Cp(e,t){for(let n=t-1;n>=0;n--){let t=e[n];if(t.type===`single`)return t.message.timestamp;if(t.type===`tool_group`)return t.firstTimestamp;if(t.type===`streaming`)return t.startTimestamp}}function wp(e){let t=Kf(e).trim();return t.length>2400?`${t.slice(0,2400)}\n...`:t}function Tp(e,t,n,r){if(!(n==null||n===``)&&!(Array.isArray(n)&&n.length===0)&&!(Vf(n)&&Object.keys(n).length===0))return{key:e,label:t,value:n,tone:r}}function Ep(e,t){let n=Object.entries(e).reduce((e,[n,r])=>($f.has(n)||t.has(n)||r==null||r===``||(e[n]=r),e),{});return Object.keys(n).length>0?n:void 0}function Dp(e){let t=ep(e),n=new Set,r=[],i=sp(t),a=(e,i,a)=>{for(let o of i){let i=Tp(o,e,t[o],a);if(i){n.add(o),r.push(i);return}}};a(`Query`,[`query`]),a(`Input`,[`input`,`params`,`arguments`,`args`]),a(`Output`,[`output`,`stdout`,`result`,`results`,`content`,`result_summary`,`observation`,`display_message`],typeof t.approval_decision==`string`?`error`:void 0),a(`Files`,[`files`,`outputFiles`]),a(`Error`,[`error`,`stderr`],`error`),i&&n.add(i.key);let o=Ep(t,n);return r.length===0&&o&&r.push({key:`details`,label:`Details`,value:o}),r}function Op(e,t){if(e.type===Q.REQUEST_INPUT)return;let n=Sf(e),r=ep(e),i=Ol(e),a=cp(e),o=rp(r),s=up(r),c=typeof r.command==`string`&&r.command.trim()?r.command.trim():void 0,l=o[0]?np(o[0]):pf(e),u=dp(r.approval_decision,l),d=fp(r.approval_decision),f=typeof r.message_to_human==`string`&&r.message_to_human.trim()?r.message_to_human.trim():void 0,p=a===`think`?n||l:vp(a===`command`?f||(u?``:n)||c||l:f||s||(u?``:n)||l),m=n?a===`think`?n:vp(n,420):void 0,h=m&&m!==p&&!u;if(!(!p&&!h))return{key:`${e.timestamp}-${r.activity_id||r.tool_run_id||t}`,kind:a,label:lp(a),title:p,isPreamble:i,command:c,text:h?m:void 0,toolName:ip(r),startedAt:ap(r[Zf])??e.timestamp,finishedAt:ap(r[Qf])??e.timestamp,status:u?`error`:r.tool_status,decisionText:d,sections:Dp(e)}}function kp(e){let t=ep(e);return t.tool===`plan`||t.tool===`update_plan`}function Ap(e){let t=ep(e);return e.type===Q.UPDATE&&Array.isArray(t.updates)?!0:e.type===Q.PLAN&&Array.isArray(t.plan)}function jp(e){return typeof e.activity_group_id==`string`&&e.activity_group_id.trim()?e.activity_group_id.trim():void 0}function Mp(e){if(typeof e.tool_use_id==`string`&&e.tool_use_id.trim())return e.tool_use_id.trim();if(typeof e.tool_run_id==`string`&&e.tool_run_id.trim())return e.tool_run_id.trim();if(typeof e.tool==`string`&&e.tool.trim())return e.tool.trim()}function Np(e){let t=new Map,n=new Map,r=(e,t,n)=>{if(!t||!n)return;let r=e.get(t)??new Set;r.add(n),e.set(t,r)};for(let i of e){let e=ep(i),a=jp(e),o=Mp(e);e.tool_event===`started`&&r(t,a,o),typeof e.approval_decision==`string`&&r(n,a,o)}return new Set([...t.entries(),...n.entries()].filter(([,e])=>e.size>1).map(([e])=>e))}function Pp(e,t){let n=jp(e),r=Mp(e);if(n)return r&&t.has(n)?`activity:${n}:tool:${r}`:`activity:${n}`;if(typeof e.tool_use_id==`string`&&e.tool_use_id.trim())return`tool-use:${e.tool_use_id.trim()}`;if(typeof e.tool_run_id==`string`&&e.tool_run_id.trim())return`run:${e.tool_run_id.trim()}`}function Fp(e){let t=new Map,n=[],r,i=Np(e);e.forEach((e,a)=>{let o=ep(e);if(Ol(e)){n.push({index:a,message:e}),r=void 0;return}let s=Pp(o,i),c=!s&&Ap(e)?r:void 0,l=s??c;if(!l){n.push({index:a,message:e});return}let u=t.get(l);u?u.messages.push(e):t.set(l,{index:a,messages:[e]}),kp(e)?r=l:e.type===Q.PLAN&&(r=void 0)});let a=Array.from(t.values()).map(({index:e,messages:t})=>{let n=[...t].sort((e,t)=>sf(e.timestamp)-sf(t.timestamp)),r=n[n.length-1],i=n.find(e=>ep(e).tool_event===`started`),a=n.find(e=>Sf(e)),o=n.findLast(e=>typeof ep(e).approval_decision==`string`&&!!Sf(e)),s=n.findLast(e=>Sf(e).startsWith(`$ `)),c=n.findLast(e=>(e.type===Q.ERROR||e.type===Q.WARNING)&&Sf(e)),l={};for(let e of n)Object.assign(l,ep(e));c&&l.error===void 0&&l.stderr===void 0&&(l.error=Sf(c)),!c&&n.some(e=>e.type===Q.PLAN&&Array.isArray(e.details?.plan))&&(l.tool_status=`completed`),s&&l.command===void 0&&(l.command=Sf(s)),l[Zf]=n[0]?.timestamp,l[Qf]=n[n.length-1]?.timestamp;let u=typeof i?.details?.message_to_human==`string`?i.details.message_to_human:``;return{index:e,message:{...r,message:o?.message||u||(a?a.message:r.message),details:l}}});return[...n,...a].sort((e,t)=>e.index-t.index).map(({message:e})=>e)}function Ip(e){let t=new Set,n=[];return Fp(e).forEach((e,r)=>{let i=Op(e,r);if(!i)return;let a=`${i.kind}:${i.label}:${i.title}:${i.text??``}`;t.has(a)||(t.add(a),n.push(i))}),n}function Lp({kind:e,status:n}){if(n===`error`||n===`warning`)return t(st,{className:`size-3.5`});switch(e){case`search`:return t(zn,{className:`size-3.5`});case`read`:return t(qt,{className:`size-3.5`});case`edit`:return t(On,{className:`size-3.5`});case`command`:return t(Jn,{className:`size-3.5`});case`skill`:return t(ft,{className:`size-3.5`});case`discover`:return t(tr,{className:`size-3.5`});case`think`:return t(ft,{className:`size-3.5`});default:return t(tr,{className:`size-3.5`})}}function Rp(e){let t=[],n=df(e.startedAt),r=df(e.finishedAt),i=ff(e.startedAt),a=ff(e.finishedAt);return e.toolName&&t.push({label:`Tool`,value:e.toolName}),i&&a&&n!==void 0&&r!==void 0&&n!==r?(t.push({label:`Started`,value:i}),t.push({label:`Ended`,value:a}),t.push({label:`Duration`,value:uf(lf(e.startedAt,e.finishedAt))})):(i||a)&&t.push({label:`Time`,value:i??a??``}),t}function zp({hasDetailContent:e,item:r}){let i=Rp(r);return i.length===0?null:t(`dl`,{className:H(`flex flex-wrap gap-x-4 gap-y-1 text-xs`,e&&`mb-3 border-b border-border/60 pb-2`),children:i.map(e=>n(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[t(`dt`,{className:`shrink-0 text-muted`,children:e.label}),t(`dd`,{className:`min-w-0 wrap-break-word font-medium text-foreground/80`,children:e.value})]},e.label))})}function Bp({section:e}){let r=e.value,i=typeof r==`string`||typeof r==`number`||typeof r==`boolean`,a=e.label===`Files`&&Array.isArray(r),o=e.label===`Output`;if(a)return t(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:Array.from(new Set(r.map(e=>Kf(e)))).map(e=>t(`span`,{className:`rounded-md bg-mixer-muted/15 px-1.5 py-0.5 font-mono text-[11px] text-muted`,children:vp(e,64)},e))});let s=H(`text-xs font-medium`,e.tone===`error`?`text-destructive`:`text-muted`),c=i&&!String(r).includes(`
|
|
56
|
-
`)&&String(r).length<180?t(`div`,{className:
|
|
57
|
-
`)),e.text&&t.push(e.text);for(let n of e.sections)t.push(`${n.label}\n${
|
|
55
|
+
`}),!b&&t(`div`,{className:`group`,children:v.map((e,n)=>{let r=y[n]??sf(e);return t(_f,{message:e,isExpanded:S.has(r),onToggle:()=>R(r),artifactRunId:k,classNames:{toolBadgeClassName:m,itemClassName:h,itemHeaderClassName:g,itemContentClassName:_}},r)})})]})}const xf=it(bf,(e,t)=>e.messages.length!==t.messages.length||e.showPulsatingCircle!==t.showPulsatingCircle||e.toolRunId!==t.toolRunId||e.toolStatus!==t.toolStatus||e.preambleText!==t.preambleText||e.rootClassName!==t.rootClassName||e.headerClassName!==t.headerClassName||e.senderClassName!==t.senderClassName||e.toolSummaryClassName!==t.toolSummaryClassName||e.toolBadgeClassName!==t.toolBadgeClassName||e.itemClassName!==t.itemClassName||e.itemHeaderClassName!==t.itemHeaderClassName||e.itemContentClassName!==t.itemContentClassName?!1:e.messages.every((e,n)=>cf(e,t.messages[n]))),Sf=`flex items-center gap-1.5 px-2 py-1 text-xs font-medium whitespace-nowrap transition-colors border-b-2 shrink-0 cursor-pointer`,Cf=`border-transparent text-muted hover:bg-muted`,wf=`border-info bg-info text-info`;function Tf(e){return e.length>20?`${e.substring(0,18)}...`:e}function Ef({items:e,current:r,onSelect:i,label:a,active:o,count:s,completionStatus:c}){let[l,u]=Y(!1),d=J(null),f=J(!1),p=()=>{d.current&&=(clearTimeout(d.current),null)},m=()=>{p(),f.current=!0,u(!0)},h=()=>{p(),d.current=setTimeout(()=>u(!1),150)};return K(()=>()=>clearTimeout(d.current??void 0),[]),n(T,{modal:!1,open:l,onOpenChange:e=>{p(),e&&(f.current=!1),u(e)},children:[t(A,{asChild:!0,children:n(`button`,{type:`button`,onMouseEnter:m,onMouseLeave:h,className:V(Sf,o?wf:Cf),children:[a,t(Ot,{className:`ms-0.5 size-3.5`})]})}),t(E,{align:`end`,className:`w-max`,onMouseEnter:p,onMouseLeave:h,onCloseAutoFocus:e=>{f.current&&e.preventDefault()},children:e.map(([e,a])=>{let o=(s?.get(e)??0)>0;return n(D,{onClick:()=>i(e),className:V(`flex items-center gap-2`,e===r&&`text-info`),children:[t(`span`,{className:`truncate`,children:a}),o&&n(`span`,{className:`ms-auto inline-flex items-center gap-1`,children:[t(`span`,{className:`inline-flex items-center justify-center rounded-full bg-muted px-1.5 text-[10px] text-muted`,children:s?.get(e)}),c&&e!==`all`&&(c.get(e)?t(wt,{className:`size-3 text-success`}):t(Ht,{className:`size-3 text-attention`}))]})]},e)})})]})}function Df({entries:r,activeWorkstream:i,onSelectWorkstream:a,count:o,completionStatus:s}){let{t:c}=X(),l=J(null),u=J([]),d=J(null),[f,p]=Y({count:r.length,promote:!1}),m=()=>{let e=l.current;if(!e)return;let t=e.clientWidth,n=r.map((e,t)=>u.current[t]?.offsetWidth??0),a=n.reduce((e,t)=>e+t,0)+4*Math.max(0,r.length-1),o=(e,t)=>{let i=0,a=0;for(let o=0;o<r.length;o++){if(o===t)continue;let r=i+(a>0?4:0)+n[o];if(r>e)break;i=r,a+=1}return a},s;if(a<=t)s={count:r.length,promote:!1};else{let e=d.current?.offsetWidth??0,a=Math.max(1,o(t-e-4,-1)),c=r.findIndex(([e])=>e===i);s=c<0||c<a?{count:a,promote:!1}:{count:o(t-e-n[c]-8,c),promote:!0}}p(e=>e.count===s.count&&e.promote===s.promote?e:s)},h=J(m);h.current=m,st(()=>{h.current()}),K(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>h.current());return t.observe(e),()=>t.disconnect()},[]);let g=r.findIndex(([e])=>e===i),_,v;if(f.promote&&g>=0){let e=r.filter((e,t)=>t!==g);_=[...e.slice(0,f.count),r[g]],v=e.slice(f.count)}else _=r.slice(0,f.count),v=r.slice(f.count);let y=v.some(([e])=>e===i),b=c(`agent.moreTabs`),x=(r,i,a)=>{let c=(o?.get(r)??0)>0;return n(e,{children:[Tf(i),c&&n(`span`,{className:`flex items-center gap-1`,children:[t(`span`,{className:V(`inline-flex items-center justify-center p-1 text-xs rounded-full`,a?`bg-info text-info`:`bg-muted text-muted`),children:o?.get(r)}),s&&r!==`all`&&(s.get(r)?t(wt,{className:`size-3 text-success`}):t(Ht,{className:`size-3 text-attention`}))]})]})};return n(`div`,{ref:l,className:`relative mb-1 bg-muted border-b border-muted/20`,children:[n(`div`,{"aria-hidden":!0,className:`pointer-events-none invisible absolute start-0 top-0 flex w-max gap-1`,children:[r.map(([e,n],r)=>t(`button`,{type:`button`,tabIndex:-1,ref:e=>{u.current[r]=e},className:V(Sf,Cf),children:x(e,n,!1)},e)),n(`button`,{type:`button`,tabIndex:-1,ref:d,className:V(Sf,Cf),children:[b,t(Ot,{className:`ms-0.5 size-3.5`})]})]}),n(`div`,{className:`flex gap-1 overflow-hidden`,children:[_.map(([e,n])=>{let r=i===e;return t(`button`,{type:`button`,"aria-current":r?`page`:void 0,onClick:()=>a(e),title:n.length>20?n:void 0,className:V(Sf,r?wf:Cf),children:x(e,n,r)},e)}),v.length>0&&t(Ef,{items:v,current:i,onSelect:a,label:b,active:y,count:o,completionStatus:s})]})]})}function Of({workstreams:e,activeWorkstream:n,onSelectWorkstream:r,count:i,completionStatus:a}){let{t:o}=X(),s=new Map;s.set(`all`,o(`agent.allMessages`)),s.set(`main`,o(`agent.main`)),e.forEach((e,t)=>{t!==`all`&&t!==`main`&&t!==`research_france`&&t!==`statistics`&&s.set(t,e)}),e=s;let c=Array.from(e.entries()).sort(([e],[t])=>e===`all`?-1:t===`all`?1:e===`main`?-1:t===`main`?1:e.localeCompare(t));return c.length>2?t(Df,{entries:c,activeWorkstream:n,onSelectWorkstream:r,count:i,completionStatus:a}):t(`div`,{className:`py-0.5`})}function kf(e){let t=new Map,n=ut.getFixedT(null,lt);return t.set(`all`,n(`agent.allMessages`)),t.set(`main`,n(`agent.main`)),e.forEach(e=>{e.workstream_id&&e.workstream_id!==`main`&&e.workstream_id!==`all`&&!t.has(e.workstream_id)&&t.set(e.workstream_id,e.workstream_id)}),t}function Af(e,t){return t===`all`?[...e]:t===`main`?e.filter(e=>Vl(e)===`main`):e.filter(e=>Vl(e)===t)}const jf=e=>e.type===Q.BATCH_PROGRESS&&!!e.details?.batch_id;function Mf(e){if(e==null||e===``)return Date.now();let t=typeof e==`number`?e:new Date(e).getTime();return Number.isFinite(t)?t:Date.now()}function Nf(e){let t=Date.now()-Mf(e);return Math.max(0,Math.round(t/1e3))}function Pf(e,t){let n=Mf(t)-Mf(e);return Math.max(0,Math.round(n/1e3))}function Ff(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function If(e){if(e==null||e===``)return;let t=typeof e==`number`?e:new Date(e).getTime();return Number.isFinite(t)?t:void 0}function Lf(e){let t=If(e);if(t!==void 0)return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(new Date(t))}function Rf(e){let t=e.details,n=t?.tool||``,r=Array.isArray(t?.tools)?t.tools.map(e=>typeof e==`string`?e:e.name||e.tool||``).filter(Boolean):[],i=[n,...r].join(` `).toLowerCase(),a=n.toLowerCase(),o=typeof e.message==`string`?e.message.trim():``;return t?.display_role===`tool_preamble`?i.includes(`search`)||i.includes(`web`)||i.includes(`fetch`)?`Preparing search`:r.length>0?`Preparing tools`:`Thinking`:a.includes(`search`)?`Searching`:a.includes(`fetch`)||a.includes(`web`)?`Searching the web`:a.includes(`read`)||a.includes(`document`)?`Reading`:a.includes(`edit`)||a.includes(`write`)||a.includes(`create`)?`Editing`:a.includes(`bash`)||a.includes(`shell`)||a.includes(`command`)?`Running command`:o||`Using tool`}function zf(e){return e?`Working`:`Worked`}function Bf(e){return e.length>0&&e.every(Fd)}function Vf(e){return zf(e)}function Hf(e){let t=e.filter(e=>Vl(e)===`main`);return(t[t.length-1]??e[e.length-1])?.type===Q.QUESTION}function Uf(e,t){let n=e.filter(e=>Vl(e)===`main`),r=n[n.length-1]??e[e.length-1];if(!r||!Ou(r,t))return!1;let i=Bp(r);return i===`allow_once`||i===`allow_for_run`}function Wf(e){if(e.type!==Q.UPDATE)return;let t=Tp(e);if(t.tool!==void 0||t.activity_group_id!==void 0)return;let n=typeof t.path==`string`&&t.path.trim()?t.path.trim():void 0;if(n)return qf(e)===`Prepared and saved artifact to ${n}`?n:void 0}function Gf(e,t){let n=Vl(e[t]);for(let r=t-1;r>=0;--r){let t=e[r];if(Vl(t)!==n)continue;let i=Tp(t);if(i.tool===`write_artifact`&&typeof i.activity_group_id==`string`)return t;if(t.type!==Q.REQUEST_INPUT&&!Bp(t)&&i.display_role!==`thinking`&&(typeof i.tool==`string`&&i.tool!==`write_artifact`||t.type===Q.ANSWER||t.type===Q.COMPLETE||t.type===Q.IDLE||t.type===Q.TERMINATED))return}}function Kf(e){return e.map((t,n)=>{let r=Wf(t);if(!r)return t;let i=Gf(e,n),a=i?Tp(i):void 0;if(!a)return t;let o=typeof a.activity_group_id==`string`?a.activity_group_id:void 0,s=typeof a.tool_run_id==`string`?a.tool_run_id:void 0,c=typeof a.tool_use_id==`string`?a.tool_use_id:void 0,l=typeof a.tool_iteration==`number`?a.tool_iteration:void 0;return o?{...t,details:{...t.details,event_class:`activity`,tool:`write_artifact`,tool_run_id:s??`write_artifact`,tool_use_id:c??s??`write_artifact`,tool_iteration:l,tool_status:`completed`,tool_event:`progress`,activity_group_id:o,output:qf(t),path:r}}:t})}function qf(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function Jf({message:e,details:r,onSelectWorkstream:i}){let{t:a}=X(),o=Cl(r.workstreamId,r.interaction),s=r.interaction?xl(r.interaction):``,c=s&&s!==o?s:void 0;return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":r.workstreamId,children:n(`button`,{type:`button`,className:V(`group flex w-full items-start gap-3 border-b border-border/70 py-2 text-start text-sm text-muted`,`transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2`,`focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-background`),onClick:()=>i?.(r.workstreamId),children:[t(yt,{className:`mt-0.5 size-4 shrink-0 text-muted`,"aria-hidden":`true`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[t(`span`,{className:`font-medium text-muted`,children:a(`agent.workstreams`)}),t(`span`,{className:`min-w-0 truncate text-foreground/85`,children:o})]}),c&&t(`div`,{className:`mt-0.5 truncate text-xs text-muted/75`,children:c}),t(`span`,{className:`sr-only`,children:qf(e)})]}),t(jt,{className:`mt-0.5 size-4 shrink-0 text-muted transition-transform group-hover:translate-x-0.5 rtl:rotate-180 rtl:group-hover:-translate-x-0.5`})]})})}const Yf=[`agent-markdown vprose prose max-w-none break-words text-sm leading-6 text-foreground/80`,`prose-p:my-2 prose-p:leading-6 prose-li:my-0.5 prose-pre:my-3 prose-headings:tracking-normal`,`prose-headings:text-foreground prose-strong:text-foreground prose-code:text-foreground`,`prose-a:text-foreground prose-a:underline prose-a:decoration-muted prose-a:underline-offset-4`,`[&_p]:text-foreground/80 [&_li]:text-foreground/80 [&_li::marker]:text-muted`].join(` `),Xf=/\[[^\]]+\]\((?:\/store\/(?:objects|collections)\/|store:|document:|document:\/\/|collection:)[^)]+\)/,Zf={table:op};function Qf(e){if(!e||typeof e!=`object`)return``;let t=e;return typeof t.value==`string`?t.value:Array.isArray(t.children)?t.children.map(Qf).join(``):``}function $f(e,t){if(!e||typeof e!=`object`)return[];let n=e.children;return Array.isArray(n)?n.filter(e=>{if(!e||typeof e!=`object`)return!1;let n=e;return t?n.tagName===t:typeof n.tagName==`string`}):[]}function ep(e){return $f(e).filter(e=>e.tagName===`thead`||e.tagName===`tbody`).flatMap(e=>$f(e,`tr`).map(e=>$f(e).filter(e=>e.tagName===`th`||e.tagName===`td`).map(e=>Qf(e).replace(/\s+/g,` `).trim())))}function tp(e){return $f(e,`tbody`).flatMap(e=>$f(e,`tr`).map(e=>$f(e,`td`).map(e=>Qf(e).replace(/\s+/g,` `).trim())))}function np(e){let t=ep(e),n=tp(e),r=Math.max(0,...t.map(e=>e.length));if(r<=1)return new Set;let i=new Set;for(let e=0;e<r;e+=1){let t=n.map(t=>t[e]||``).map(e=>e.trim()).filter(Boolean);if(t.length===0)continue;let r=t.map(e=>e.length),a=Math.max(...r),o=r.reduce((e,t)=>e+t,0)/r.length,s=t.some(e=>/\S{12,}/.test(e));a<=16&&o<=10&&!s&&i.add(e)}return i.size>=r?new Set:i}function rp(e,t,n){return Math.min(n,Math.max(t,e))}function ip(e){return e.reduce((e,t)=>{let n=t.match(/\S+/g)||[];return Math.max(e,...n.map(e=>e.length))},0)}function ap(e){let t=ep(e),n=Math.max(0,...t.map(e=>e.length));if(n<=1)return[];let r=np(e),i=Array.from({length:n},(e,n)=>{if(r.has(n))return 8;let i=t.map(e=>e[n]||``).map(e=>e.trim()).filter(Boolean);if(i.length===0)return 18;let a=i.map(e=>e.length),o=Math.max(...a),s=a.reduce((e,t)=>e+t,0)/a.length,c=ip(i);return rp(s*.7+o*.25+c*.45,18,90)}),a=i.reduce((e,t)=>e+t,0);return a<=0?[]:i.map((e,t)=>{let n=`${(e/a*100).toFixed(3)}%`;return{key:`agent-markdown-table-column-${t}`,compact:r.has(t),width:n}})}function op({node:e,className:r,children:i,...a}){let o=ap(e);return n(`table`,{...a,className:r,children:[o.length>0?t(`colgroup`,{children:o.map(e=>t(`col`,{className:e.compact?`agent-markdown-table-compact-col`:void 0,style:{"--agent-markdown-table-column-width":e.width}},e.key))}):null,i]})}function sp(e){if(e==null||typeof e==`boolean`)return 0;if(typeof e==`string`||typeof e==`number`)return String(e).length;if(Array.isArray(e))return e.reduce((e,t)=>e+sp(t),0);if(W.isValidElement(e)){let t=e.props;return sp(t.children)}return 0}function cp(e,t){let[n,r]=Y(()=>Nf(e));return K(()=>{if(!t){r(Nf(e));return}let n=()=>r(Nf(e));n();let i=window.setInterval(n,1e3);return()=>window.clearInterval(i)},[t,e]),n}function lp(e=!0){let[t,n]=Y(0);return K(()=>{if(!e)return;let t=window.setInterval(()=>{n(()=>Math.floor(Math.random()*zu.length))},4e3);return()=>window.clearInterval(t)},[e]),t}function up({children:e,message:r,workstreamId:i,className:a,artifactRunId:o,markdownComponents:s}){let{t:c}=X(),[l,u]=Y(!1),d=q(()=>sp(e),[e])>520,f=typeof e==`string`||typeof e==`number`,p=f?String(e):``,m=typeof e==`string`&&Xf.test(e),h=r?ld(r):void 0;return K(()=>{!d&&l&&u(!1)},[l,d]),t(`div`,{className:`mx-auto flex w-full max-w-3xl justify-end px-1`,children:n(`div`,{className:V(`max-w-[min(44rem,82%)] rounded-[1.35rem] bg-mixer-muted/35 px-4 py-2.5`,`text-sm font-normal leading-6 text-foreground/90 shadow-sm shadow-black/5 dark:bg-mixer-muted/15 dark:text-foreground/88 dark:shadow-none`,`break-words [overflow-wrap:anywhere]`,a),"data-workstream-id":i,children:[t(`div`,{className:V(f&&!m&&`whitespace-pre-wrap`,d&&!l&&`max-h-72 overflow-hidden [mask-image:linear-gradient(to_bottom,black_76%,transparent_100%)]`),children:m?t(Li,{artifactRunId:o,components:s,className:V(`agent-markdown vprose prose max-w-none break-words text-sm leading-6 text-foreground/90`,`prose-p:my-0 prose-p:leading-6 prose-a:text-foreground prose-a:underline prose-a:decoration-muted prose-a:underline-offset-4`,`[&_p+_p]:mt-2`),children:p}):e}),d&&n(`button`,{type:`button`,"aria-expanded":l,className:`mt-2 inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>u(e=>!e),children:[c(l?`agent.showLess`:`agent.showMore`),t(Ot,{className:V(`size-4 transition-transform`,l&&`rotate-180`),"aria-hidden":`true`})]}),r&&h?t(`div`,{className:`mt-1.5 flex justify-end`,children:t(dd,{message:r,className:`h-4 w-4`})}):null]})})}function dp({message:r,onSendMessage:i,onSelectWorkstream:a,requestInputAnswered:o=!1,StoreLinkComponent:s,CollectionLinkComponent:c}){let l=r.type===Q.REQUEST_INPUT?su(r):qf(r),u=jl(r)??Ml(r),d=Vl(r),f=r.workflow_run_id,p=q(()=>r.type===Q.QUESTION?id(l):null,[l,r.type]),m=q(()=>({...Zf,a:({node:e,ref:n,...r})=>{let i=r.href||``;if(i.includes(`/store/objects`)){let e=i.split(`/store/objects/`)[1]||``;return s?t(s,{href:i,documentId:e,children:r.children}):t(Ei,{href:i,topLevelNav:!0,children:r.children})}if(i.includes(`/store/collections`)){let e=i.split(`/store/collections/`)[1]||``;return c?t(c,{href:i,collectionId:e,children:r.children}):t(Ei,{href:i,topLevelNav:!0,children:r.children})}return t(`a`,{...r,target:`_blank`,rel:`noopener noreferrer`})}}),[s,c]);if(u)return t(Jf,{message:r,details:u,onSelectWorkstream:a});if(r.type===Q.QUESTION){let i=p?.body??l,a=p?.attachments??[];return n(e,{children:[a.length>0&&t(`div`,{className:`mx-auto flex w-full max-w-3xl justify-end px-1`,children:t(td,{items:a,artifactRunId:f,align:`end`,variant:`message`,StoreLinkComponent:s,CollectionLinkComponent:c})}),i&&t(up,{message:r,workstreamId:d,artifactRunId:f,markdownComponents:m,children:i})]})}let h=r.details;if(r.type===Q.REQUEST_INPUT&&h?.ux){let e=h.ux;return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,children:t(yl,{question:l,options:e.options,variant:e.variant,multiSelect:e.multiSelect,onSelect:e=>i?.(e,bu(r,e)),onMultiSelect:e=>i?.(e.join(`, `)),allowFreeResponse:!e.options?.length||!!e.free_response,placeholder:e.free_response?.placeholder,submitLabel:e.free_response?.submit_label,onSubmit:t=>i?.(t,e.free_response?.metadata),hideBorder:!0,compact:!0,answered:o})})}let g=r.type===Q.ERROR||r.type===Q.WARNING;return n(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":d,children:[g&&t(`div`,{className:`mb-2 text-xs font-medium text-destructive`,children:r.type===Q.WARNING?`Warning`:`Error`}),l&&t(`div`,{className:V(Yf,g&&`rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2`),style:{overflowWrap:`anywhere`},children:t(Li,{artifactRunId:f,onProposalSelect:e=>i?.(e),onProposalSubmit:e=>i?.(e),components:m,children:l})})]})}function fp(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function pp(e){return e==null?!1:typeof e==`string`?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e!=`object`||Object.keys(e).length>0}function mp(e){return e==null||e===!1?!1:typeof e!=`string`||e.trim().length>0}function hp(e){if(!e||!fp(e))return{};let t=e.properties;return fp(t)?t:{}}function gp(e,t){let n=e&&fp(e)?e.title:void 0;return typeof n==`string`&&n.trim()?n:t.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}function _p(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function vp(e){return e==null||e===``?t(`span`,{className:`text-muted`,children:`Not provided`}):typeof e==`boolean`?e?`Yes`:`No`:typeof e==`number`?String(e):typeof e==`string`?t(`span`,{className:`whitespace-pre-wrap`,children:e}):Array.isArray(e)&&e.every(e=>typeof e!=`object`||!e)?e.map(e=>_p(e)).join(`, `):t(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-md bg-background/55 px-2 py-1.5 font-mono text-[12px] leading-relaxed text-foreground/80`,children:_p(e)})}function yp(e,r,i){if(!pp(e))return null;if(!fp(e))return vp(e);let a=hp(r),o=[...Object.keys(a),...Object.keys(e).filter(e=>!(e in a))].map(t=>({key:t,label:gp(a[t],t),value:e[t]})).filter(e=>pp(e.value));return o.length===0?null:n(`div`,{className:`space-y-2 text-start`,children:[i?t(`div`,{className:`text-xs font-medium uppercase tracking-normal text-muted`,children:i}):null,t(`dl`,{className:`space-y-2`,children:o.map(e=>n(`div`,{className:`grid gap-1 sm:grid-cols-[minmax(7rem,32%)_1fr] sm:gap-3`,children:[t(`dt`,{className:`text-xs font-medium text-muted`,children:e.label}),t(`dd`,{className:`min-w-0 break-words text-sm text-foreground`,children:vp(e.value)})]},e.key))})]})}function bp({data:e,schema:n,title:r,template:i,prependFriendlyMessage:a,timestamp:o,isSummaryView:s,messageItemClassNames:c,messageStyleOverrides:l,StoreLinkComponent:u,CollectionLinkComponent:d}){let f=a?.trim()||(typeof e==`string`?e.trim():``),p=i?.({data:e??a,schema:n,title:r});if(!mp(p)&&f){let e={type:Q.QUESTION,message:f,timestamp:Mf(o),workflow_run_id:``,workstream_id:`main`};return s?t(dp,{message:e,StoreLinkComponent:u,CollectionLinkComponent:d}):t(kd,{...c,messageStyleOverrides:l,message:e})}let m=mp(p)?p:yp(e,n,r);return mp(m)?t(up,{className:`py-3`,children:m}):null}function xp({label:e,timestamp:r,className:i}){let a=lp(),o=cp(r,!0);return t(`div`,{className:V(`mx-auto w-full max-w-3xl px-1`,i),children:n(`div`,{className:`border-b border-border/70 pb-4 text-sm text-muted`,children:[n(`div`,{className:`flex items-center gap-3`,children:[t(Pu,{size:`sm`,color:`blue`}),n(`div`,{className:`min-w-0`,children:[n(`div`,{children:[t(`span`,{className:`font-medium`,children:e}),n(`span`,{className:`ms-2 text-muted/75`,children:[`for `,Ff(o)]})]}),t(`div`,{className:`mt-1 truncate text-muted/80`,children:zu[a]})]})]}),t(`div`,{className:`mt-3 ps-6`,children:t(Nu,{color:`blue`})})]})})}const Sp=`_summary_started_at`,Cp=`_summary_finished_at`,wp=new Set([`account_id`,`activity_group_id`,`activity_id`,`channel_id`,`collection_id`,`document_id`,`display_role`,`event_class`,`id`,`object_id`,`project_id`,`run_id`,`streamed`,`tenant_id`,`thread_id`,`tool`,`tool_event`,`tool_iteration`,`tool_run_id`,`tool_use_id`,`tool_status`,`tools`,`message_to_human`,`progress_messages`,`source`,`token_usage`,`checkpoint_at`,`checkpoint_threshold`,`approval_decision`,`approval_request`,`cancellation_reason`,Sp,Cp,`workflow_run_id`]);function Tp(e){return fp(e.details)?e.details:{}}function Ep(e){if(e.type!==Q.UPDATE)return!1;let t=Tp(e).event_class;return t===`document_created`||t===`document_updated`}function Dp(e){return e.replace(/[_-]+/g,` `).replace(/\s+/g,` `).trim().replace(/\b\w/g,e=>e.toUpperCase())}function Op(e){let t=[];if(typeof e.tool==`string`&&e.tool.trim()&&t.push(e.tool.trim()),Array.isArray(e.tools)){for(let n of e.tools)if(typeof n==`string`&&n.trim())t.push(n.trim());else if(fp(n)){let e=typeof n.name==`string`?n.name:n.tool;typeof e==`string`&&e.trim()&&t.push(e.trim())}}return t}function kp(e){let t=Array.from(new Set(Op(e)));return t.length>0?t.join(`, `):void 0}function Ap(e){return typeof e==`number`||typeof e==`string`?e:void 0}const jp=[`query`,`path`,`file`,`file_name`,`fileName`,`filename`,`name`,`title`,`artifact`,`artifact_path`,`url`,`command`];function Mp(e){for(let t of jp){let n=e[t];if(typeof n==`string`&&n.trim())return{key:t,value:n.trim()};if(typeof n==`number`||typeof n==`boolean`)return{key:t,value:String(n)}}}function Np(e){let t=Tp(e),n=Op(t).join(` `).toLowerCase(),r=typeof t.tool==`string`?t.tool.toLowerCase():``,i=r||n;return Zl(e)?`think`:r.startsWith(`learn_`)||n.includes(`learn_`)?`skill`:r===`discover_tools`?`discover`:e.type===Q.THOUGHT&&!r?`think`:i.includes(`search`)||i.includes(`web`)||i.includes(`fetch`)?`search`:i.includes(`read`)||i.includes(`document`)||i.includes(`file`)?`read`:i.includes(`edit`)||i.includes(`write`)||i.includes(`patch`)||i.includes(`create`)?`edit`:i.includes(`bash`)||i.includes(`shell`)||i.includes(`command`)||i.includes(`terminal`)?`command`:e.type===Q.THOUGHT&&n.length===0?`think`:`tool`}function Pp(e){switch(e){case`search`:return`Search`;case`read`:return`Read`;case`edit`:return`Edit`;case`command`:return`Bash`;case`skill`:return`Skill`;case`discover`:return`Tool`;case`think`:return`Thought`;default:return`Tool`}}function Fp(e){let t=Mp(e);if(t)return t.value;let n=e.files??e.outputFiles;if(Array.isArray(n)&&n.length>0)return n.map(e=>_p(e)).join(`, `)}function Ip(e,t){switch(e){case`denied`:case`denied_with_feedback`:return`User declined to use ${t}.`;case`timeout`:return`Approval timed out for ${t}.`;case`reviewer_denied`:return`Approval reviewer denied ${t}.`;case`cancelled_after_denial`:return`Cancelled ${t} after another tool was denied.`;default:return}}function Lp(e){switch(e){case`denied`:case`denied_with_feedback`:return`Declined by user`;case`timeout`:return`Approval timed out`;case`reviewer_denied`:return`Denied by reviewer`;case`cancelled_after_denial`:return`Cancelled after denial`;default:return}}function Rp(e){let t=Tp(e).tool_approval;return fp(t)?t:void 0}function zp(e){let t=e?.approval_key;return typeof t==`string`&&t.trim()?t.trim():void 0}function Bp(e){if(e.type!==Q.QUESTION)return;let t=qf(e).trim().toLowerCase();if(t===`allow_once`||t===`allow_for_run`||t===`deny`)return t}function Vp(e){let t=e.tool_title;if(typeof t==`string`&&t.trim())return t.trim();let n=e.tool_name;return typeof n==`string`&&n.trim()?Dp(n.trim()):`tool action`}function Hp(e,t){let n=[];return e.forEach((r,i)=>{if(r.type!==Q.REQUEST_INPUT)return;let a=Rp(r),o=zp(a);if(!a||!o||t.has(o))return;let s=Vl(r),c;for(let t=i+1;t<e.length;t+=1){let n=e[t];if(Vl(n)===s){if(n.type===Q.REQUEST_INPUT)break;if(n.type===Q.QUESTION){c=n;break}}}if(!c||Bp(c)!==`deny`)return;let l=typeof a.tool_name==`string`&&a.tool_name.trim()?a.tool_name.trim():`tool_action`,u=Vp(a),d=typeof a.target==`string`&&a.target.trim()?a.target:``,f={tool_name:l,tool_title:a.tool_title,action_summary:a.action_summary,target:a.target,approval_key:o};n.push({timestamp:c.timestamp??r.timestamp,workflow_run_id:c.workflow_run_id||r.workflow_run_id,type:Q.THOUGHT,message:Ip(`denied`,u)??`User declined to use ${u}.`,workstream_id:s,details:{event_class:`activity`,tool:l,tool_run_id:`approval:${o}`,tool_use_id:`approval:${o}`,tool_status:`error`,tool_event:`failed`,activity_group_id:`approval:${o}`,approval_decision:`denied`,approval_request:f,input:a.input,target:d,observation:`The user declined this tool action.`,source:`synthetic_tool_approval_decision`}})}),n.length===0?e:[...e,...n].sort((e,t)=>Mf(e.timestamp)-Mf(t.timestamp))}function Up(e,t=160){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}...`:n}const Wp=[`batch_id`,`activity_group_id`,`activity_id`,`tool_run_id`,`tool_use_id`,`streaming_id`,`chunk_index`,`tool_iteration`,`tool_event`];function Gp(e){for(let t of Wp){let n=e[t];if(typeof n==`string`&&n.trim())return`${t}:${n.trim()}`;if(typeof n==`number`||typeof n==`boolean`)return`${t}:${n}`}}function Kp(e,t=`message`){let n=Gp(Tp(e)),r=Up(qf(e),96);return[t,e.workstream_id||`main`,e.workflow_run_id,e.timestamp,e.type,n??r].filter(Boolean).join(`:`)}function qp(e){if(e.type===`single`)return Kp(e.message);if(e.type===`streaming`)return`streaming:${e.streamingId}:${e.startTimestamp}:${e.workstreamId||`main`}`;let t=e.messages[0],n=e.messages[e.messages.length-1],r=t?Kp(t,`first`):e.firstTimestamp,i=n?Kp(n,`last`):e.firstTimestamp;return[`group`,e.toolRunId,e.firstTimestamp,r,i].filter(Boolean).join(`:`)}function Jp(e,t){for(let n=t-1;n>=0;n--){let t=e[n];if(t.type===`single`)return t.message.timestamp;if(t.type===`tool_group`)return t.firstTimestamp;if(t.type===`streaming`)return t.startTimestamp}}function Yp(e){let t=_p(e).trim();return t.length>2400?`${t.slice(0,2400)}\n...`:t}function Xp(e,t,n,r){if(!(n==null||n===``)&&!(Array.isArray(n)&&n.length===0)&&!(fp(n)&&Object.keys(n).length===0))return{key:e,label:t,value:n,tone:r}}function Zp(e,t){let n=Object.entries(e).reduce((e,[n,r])=>(wp.has(n)||t.has(n)||r==null||r===``||(e[n]=r),e),{});return Object.keys(n).length>0?n:void 0}function Qp(e){let t=Tp(e),n=new Set,r=[],i=Mp(t),a=(e,i,a)=>{for(let o of i){let i=Xp(o,e,t[o],a);if(i){n.add(o),r.push(i);return}}};a(`Query`,[`query`]),a(`Input`,[`input`,`params`,`arguments`,`args`]),a(`Output`,[`output`,`stdout`,`result`,`results`,`content`,`result_summary`,`observation`,`display_message`],typeof t.approval_decision==`string`?`error`:void 0),a(`Files`,[`files`,`outputFiles`]),a(`Error`,[`error`,`stderr`],`error`),i&&n.add(i.key);let o=Zp(t,n);return r.length===0&&o&&r.push({key:`details`,label:`Details`,value:o}),r}function $p(e,t){if(e.type===Q.REQUEST_INPUT)return;let n=qf(e),r=Tp(e),i=Zl(e),a=Np(e),o=Op(r),s=Fp(r),c=typeof r.command==`string`&&r.command.trim()?r.command.trim():void 0,l=o[0]?Dp(o[0]):Rf(e),u=Ip(r.approval_decision,l),d=Lp(r.approval_decision),f=typeof r.message_to_human==`string`&&r.message_to_human.trim()?r.message_to_human.trim():void 0,p=a===`think`?n||l:Up(a===`command`?f||(u?``:n)||c||l:f||s||(u?``:n)||l),m=n?a===`think`?n:Up(n,420):void 0,h=m&&m!==p&&!u;if(!(!p&&!h))return{key:`${e.timestamp}-${r.activity_id||r.tool_run_id||t}`,kind:a,label:Pp(a),title:p,isPreamble:i,command:c,text:h?m:void 0,toolName:kp(r),startedAt:Ap(r[Sp])??e.timestamp,finishedAt:Ap(r[Cp])??e.timestamp,status:u?`error`:r.tool_status,decisionText:d,sections:Qp(e)}}function em(e){let t=Tp(e);return t.tool===`plan`||t.tool===`update_plan`}function tm(e){let t=Tp(e);return e.type===Q.UPDATE&&Array.isArray(t.updates)?!0:e.type===Q.PLAN&&Array.isArray(t.plan)}function nm(e){return typeof e.activity_group_id==`string`&&e.activity_group_id.trim()?e.activity_group_id.trim():void 0}function rm(e){if(typeof e.tool_use_id==`string`&&e.tool_use_id.trim())return e.tool_use_id.trim();if(typeof e.tool_run_id==`string`&&e.tool_run_id.trim())return e.tool_run_id.trim();if(typeof e.tool==`string`&&e.tool.trim())return e.tool.trim()}function im(e){let t=new Map,n=new Map,r=(e,t,n)=>{if(!t||!n)return;let r=e.get(t)??new Set;r.add(n),e.set(t,r)};for(let i of e){let e=Tp(i),a=nm(e),o=rm(e);e.tool_event===`started`&&r(t,a,o),typeof e.approval_decision==`string`&&r(n,a,o)}return new Set([...t.entries(),...n.entries()].filter(([,e])=>e.size>1).map(([e])=>e))}function am(e,t){let n=nm(e),r=rm(e);if(n)return r&&t.has(n)?`activity:${n}:tool:${r}`:`activity:${n}`;if(typeof e.tool_use_id==`string`&&e.tool_use_id.trim())return`tool-use:${e.tool_use_id.trim()}`;if(typeof e.tool_run_id==`string`&&e.tool_run_id.trim())return`run:${e.tool_run_id.trim()}`}function om(e){let t=new Map,n=[],r,i=im(e);e.forEach((e,a)=>{let o=Tp(e);if(Zl(e)){n.push({index:a,message:e}),r=void 0;return}let s=am(o,i),c=!s&&tm(e)?r:void 0,l=s??c;if(!l){n.push({index:a,message:e});return}let u=t.get(l);u?u.messages.push(e):t.set(l,{index:a,messages:[e]}),em(e)?r=l:e.type===Q.PLAN&&(r=void 0)});let a=Array.from(t.values()).map(({index:e,messages:t})=>{let n=[...t].sort((e,t)=>Mf(e.timestamp)-Mf(t.timestamp)),r=n[n.length-1],i=n.find(e=>Tp(e).tool_event===`started`),a=n.find(e=>qf(e)),o=n.findLast(e=>typeof Tp(e).approval_decision==`string`&&!!qf(e)),s=n.findLast(e=>qf(e).startsWith(`$ `)),c=n.findLast(e=>(e.type===Q.ERROR||e.type===Q.WARNING)&&qf(e)),l={};for(let e of n)Object.assign(l,Tp(e));c&&l.error===void 0&&l.stderr===void 0&&(l.error=qf(c)),!c&&n.some(e=>e.type===Q.PLAN&&Array.isArray(e.details?.plan))&&(l.tool_status=`completed`),s&&l.command===void 0&&(l.command=qf(s)),l[Sp]=n[0]?.timestamp,l[Cp]=n[n.length-1]?.timestamp;let u=typeof i?.details?.message_to_human==`string`?i.details.message_to_human:``;return{index:e,message:{...r,message:o?.message||u||(a?a.message:r.message),details:l}}});return[...n,...a].sort((e,t)=>e.index-t.index).map(({message:e})=>e)}function sm(e){let t=new Set,n=[];return om(e).forEach((e,r)=>{let i=$p(e,r);if(!i)return;let a=`${i.kind}:${i.label}:${i.title}:${i.text??``}`;t.has(a)||(t.add(a),n.push(i))}),n}function cm({kind:e,status:n}){if(n===`error`||n===`warning`)return t(ht,{className:`size-3.5`});switch(e){case`search`:return t(er,{className:`size-3.5`});case`read`:return t(on,{className:`size-3.5`});case`edit`:return t(Vn,{className:`size-3.5`});case`command`:return t(ur,{className:`size-3.5`});case`skill`:return t(xt,{className:`size-3.5`});case`discover`:return t(vr,{className:`size-3.5`});case`think`:return t(xt,{className:`size-3.5`});default:return t(vr,{className:`size-3.5`})}}function lm(e){let t=[],n=If(e.startedAt),r=If(e.finishedAt),i=Lf(e.startedAt),a=Lf(e.finishedAt);return e.toolName&&t.push({label:`Tool`,value:e.toolName}),i&&a&&n!==void 0&&r!==void 0&&n!==r?(t.push({label:`Started`,value:i}),t.push({label:`Ended`,value:a}),t.push({label:`Duration`,value:Ff(Pf(e.startedAt,e.finishedAt))})):(i||a)&&t.push({label:`Time`,value:i??a??``}),t}function um({hasDetailContent:e,item:r}){let i=lm(r);return i.length===0?null:t(`dl`,{className:V(`flex flex-wrap gap-x-4 gap-y-1 text-xs`,e&&`mb-3 border-b border-border/60 pb-2`),children:i.map(e=>n(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[t(`dt`,{className:`shrink-0 text-muted`,children:e.label}),t(`dd`,{className:`min-w-0 wrap-break-word font-medium text-foreground/80`,children:e.value})]},e.label))})}function dm({section:e}){let r=e.value,i=typeof r==`string`||typeof r==`number`||typeof r==`boolean`,a=e.label===`Files`&&Array.isArray(r),o=e.label===`Output`;if(a)return t(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:Array.from(new Set(r.map(e=>_p(e)))).map(e=>t(`span`,{className:`rounded-md bg-mixer-muted/15 px-1.5 py-0.5 font-mono text-[11px] text-muted`,children:Up(e,64)},e))});let s=V(`text-xs font-medium`,e.tone===`error`?`text-destructive`:`text-muted`),c=i&&!String(r).includes(`
|
|
56
|
+
`)&&String(r).length<180?t(`div`,{className:V(`break-words text-xs`,e.tone===`error`?`text-destructive`:`text-foreground/75`),children:String(r)}):t(`pre`,{className:V(`max-h-52 overflow-auto whitespace-pre-wrap rounded-lg px-3 py-2 font-mono text-[11px] leading-relaxed`,e.tone===`error`?`bg-destructive/5 text-destructive`:`bg-mixer-muted/10 text-foreground/75`),children:Yp(r)});return n(`div`,{className:`mt-2`,children:[o?null:t(`div`,{className:V(`mb-1`,s),children:e.label}),c]})}function fm(e){return e.kind===`command`?`Shell`:e.label}function pm(e){if(e.kind!==`command`)return e.title;let t=e.command||e.title;return t.trim().startsWith(`$`)?t:`$ ${t}`}function mm(e){let t=[fm(e),pm(e)],n=lm(e).map(e=>`${e.label}: ${e.value}`);n.length>0&&t.push(n.join(`
|
|
57
|
+
`)),e.text&&t.push(e.text);for(let n of e.sections)t.push(`${n.label}\n${Yp(n.value)}`);return t.filter(Boolean).join(`
|
|
58
58
|
|
|
59
|
-
`)}async function Wp(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}if(typeof document>`u`)return!1;let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.insetInlineStart=`-9999px`,t.style.top=`0`,document.body.appendChild(t);try{return t.focus(),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}function Gp({item:e}){let r=e.kind===`command`&&e.command?Hp(e):void 0,i=!r&&e.sections.length===0?e.text:void 0,a=!!(r||i||e.sections.length),o=Up(e),[s,c]=Y(`idle`),l=J(void 0);return K(()=>()=>{l.current!==void 0&&window.clearTimeout(l.current)},[]),n(`div`,{className:`relative mt-2 rounded-lg border border-border/70 bg-mixer-muted/10 p-3 shadow-sm`,children:[a?t(`div`,{className:`absolute end-2 top-2`,children:t(`button`,{type:`button`,className:H(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted opacity-70 transition`,`hover:bg-mixer-muted/20 hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,s===`copied`&&`text-success opacity-100`,s===`failed`&&`text-destructive opacity-100`),onClick:()=>{Wp(o).then(e=>{c(e?`copied`:`failed`),l.current!==void 0&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>c(`idle`),2e3)})},"aria-label":`Copy tool details`,title:`Copy tool details`,children:t(s===`copied`?ht:Ft,{className:`size-4`})})}):null,n(`div`,{className:H(a&&`pe-7`),children:[t(zp,{item:e,hasDetailContent:a}),r?t(`pre`,{className:`mb-3 whitespace-pre-wrap break-words font-mono text-sm leading-6 text-foreground/85`,children:r}):null,i?t(`div`,{className:`mb-3 break-words text-sm leading-6 text-foreground/75`,children:i}):null,e.sections.length>0?t(`div`,{className:`space-y-3`,children:e.sections.map(e=>t(Bp,{section:e},e.key))}):null]}),s===`failed`&&a?t(`div`,{className:`mt-3 text-xs text-destructive`,children:`Copy failed`}):null]})}function Kp({item:e}){let r=!!e.decisionText,a=!r&&(e.status===`error`||e.status===`warning`),o=Rp(e).length>0,s=!!(e.command||e.text||e.sections.length||o),[c,l]=Y(!1),u=r?void 0:e.status;return n(`div`,{className:`min-w-0`,children:[n(`button`,{type:`button`,className:H(`grid w-full grid-cols-[1.5rem_1fr_auto] gap-2 text-start outline-none transition-colors`,`focus-visible:text-foreground focus-visible:underline focus-visible:underline-offset-4`,s?`cursor-pointer hover:text-foreground`:`cursor-default`),onClick:()=>s&&l(e=>!e),"aria-expanded":s?c:void 0,disabled:!s,children:[t(`span`,{className:H(`flex size-5 items-center justify-center pt-0.5`,a?`text-attention`:`text-muted`),children:t(Lp,{kind:e.kind,status:u})}),n(`span`,{className:`min-w-0 text-sm text-muted`,children:[t(`span`,{className:`break-words`,children:e.title}),e.decisionText?t(i,{variant:`destructive`,className:`ms-2 rounded-full shadow-sm shadow-destructive/10`,children:e.decisionText}):null]}),s?t(yt,{className:H(`mt-0.5 size-4 shrink-0 text-muted opacity-50 transition-transform`,!c&&`-rotate-90`),"aria-hidden":`true`}):null]}),s&&c?t(`div`,{className:`mt-1`,children:t(Gp,{item:e})}):null]})}function qp({item:e,artifactRunId:r,disableCollapse:i}){let{t:a}=X(),o=e.text??e.title,s=o.trim(),[c,l]=Y(!1),u=s?s.split(/\r?\n/).length:0,d=s.length>520||u>6,f=a(c?`agent.showLess`:`agent.showMore`);return n(`div`,{className:`min-w-0 py-1`,children:[t(`div`,{"data-testid":`summary-thought-prose`,className:H(wf,d&&!i&&!c&&`[display:-webkit-box] overflow-hidden [-webkit-box-orient:vertical] [-webkit-line-clamp:6]`),style:{overflowWrap:`anywhere`},children:t(yi,{artifactRunId:r,components:Ef,children:o})}),d&&!i?t(`div`,{className:`mt-1.5 flex justify-end`,children:n(`button`,{type:`button`,"aria-expanded":c,className:H(`inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors`,`[text-decoration:none] hover:text-foreground hover:[text-decoration:none]`,`focus-visible:text-foreground focus-visible:[text-decoration:none]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),onClick:()=>l(e=>!e),children:[f,t(yt,{className:H(`size-4 transition-transform`,c&&`rotate-180`),"aria-hidden":`true`})]})}):null]})}function Jp({items:e,artifactRunId:n,disablePreambleCollapse:r}){return t(`div`,{className:`mt-3`,children:t(`div`,{className:`space-y-3`,children:e.map(e=>e.isPreamble||e.kind===`think`?t(qp,{item:e,artifactRunId:n,disableCollapse:r},e.key):t(Kp,{item:e},e.key))})})}function Yp({text:e,artifactRunId:n,workstreamId:r}){return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":r,children:t(`div`,{className:wf,style:{overflowWrap:`anywhere`},children:t(yi,{artifactRunId:n,components:Ef,children:e})})})}function Xp({message:e,startTimestamp:r,endTimestamp:i,className:a}){let{t:o}=X(),s=uf(lf(r??e.timestamp,i??e.timestamp));return n(`div`,{className:H(`mx-auto w-full max-w-3xl px-1`,a),"data-testid":`summary-stopped-message`,children:[n(`div`,{className:`flex items-center justify-end gap-2 text-lg font-medium text-muted sm:text-xl`,children:[t(`span`,{children:o(`agent.youStoppedAfter`,{duration:s})}),t(Bu,{message:e,className:`h-5 w-5`})]}),t(`div`,{className:`mt-5 border-b border-border/70`})]})}function Zp({label:r,timestamp:i,durationSeconds:a,showElapsed:o,details:s,emptyDetailsLabel:c,defaultExpanded:l=!1,disablePreambleCollapse:u=!1,className:d,artifactRunId:f,onSendMessage:p,answeredToolApprovalRequestInputKeys:m,resolvedToolApprovalKeys:h}){let[g,_]=Y(l),v=Lf(i,o&&a===void 0),y=a??v,b=o&&i!==void 0,x=q(()=>Ip(s??[]),[s]),S=q(()=>(s??[]).filter(e=>Ul(e)&&!tu(e,m??new Set,h??new Set)),[m,s,h]),C=x.length>0||S.length>0||!!c;return t(`div`,{className:H(`mx-auto w-full max-w-3xl px-1`,d),children:n(`div`,{className:`border-b border-border/70 pb-3 text-sm text-muted`,children:[n(`button`,{type:`button`,className:H(`inline-flex max-w-full items-center gap-2 text-start outline-none`,`focus-visible:text-foreground focus-visible:underline focus-visible:underline-offset-4`,C?`cursor-pointer hover:text-foreground`:`cursor-default`),onClick:()=>C&&_(e=>!e),"aria-expanded":C?g:void 0,disabled:!C,children:[t(`span`,{className:`min-w-0 truncate font-medium`,children:r}),b?n(`span`,{className:`shrink-0 text-muted/75`,children:[`for `,uf(y)]}):null,C?t(g?yt:St,{className:`size-4 shrink-0 opacity-50`}):null]}),C&&g?x.length>0||S.length>0?n(e,{children:[x.length>0?t(Jp,{items:x,artifactRunId:f,disablePreambleCollapse:u}):null,S.length>0?t(`div`,{className:`mt-3 space-y-3`,children:S.map(e=>{let n=e.details.ux;return t(Xc,{question:Rl(e),options:n.options,variant:n.variant,multiSelect:n.multiSelect,onSelect:e=>p?.(e),onMultiSelect:e=>p?.(e.join(`, `)),allowFreeResponse:!n.options?.length||!!n.free_response,placeholder:n.free_response?.placeholder,submitLabel:n.free_response?.submit_label,onSubmit:e=>p?.(e,n.free_response?.metadata),hideBorder:!0,compact:!0,className:`my-0`,cardClassName:`bg-background/60 shadow-none`},xp(e,`work-request-input`))})}):null]}):n(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-muted`,children:[t(Jn,{className:`size-4 opacity-70`,"aria-hidden":`true`}),t(`span`,{children:c})]}):null]})})}function Qp({children:e,status:r}){let i=r===`error`?`bg-destructive`:r===`warning`?`bg-attention`:r===`completed`?`bg-success`:`bg-muted`;return n(`div`,{className:`relative ps-7`,children:[t(`div`,{className:`absolute start-2 top-0 bottom-0 w-px bg-border`}),t(`div`,{className:H(`absolute start-[5px] top-4 size-2.5 rounded-full ring-4 ring-background`,i)}),e]})}var $p=class extends Je{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return console.error(`Message render error:`,e),{hasError:!0,error:e}}componentDidUpdate(e){this.state.hasError&&e.children!==this.props.children&&this.setState({hasError:!1,error:void 0})}render(){return this.state.hasError?n(`div`,{className:`border-s-4 border-s-destructive bg-destructive/10 px-4 py-2 my-2 rounded-e`,children:[t(`p`,{className:`text-sm text-destructive font-medium`,children:rt.getFixedT(null,nt)(`agent.failedToRenderMessage`)}),t(`p`,{className:`text-xs text-muted mt-1 truncate`,children:this.state.error?.message||`Unknown error`})]}):this.props.children}};function em(e,t){let n=[...e.filter(e=>!tp(e)&&!t?.includes(e.type))].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),r=[];for(let e of n){let t=r[r.length-1];t&&El(t,e)||t&&nm(t,e)||r.push(e)}return r}function tm({messages:r,workstreamSourceMessages:i,bottomRef:a,viewMode:s=`stacked`,isCompleted:c=!1,streamingMessages:l=new Map,onSendMessage:u,messageItemClassNames:d,messageStyleOverrides:f,toolCallGroupClassNames:p,hideToolCallsInViewMode:m,streamingMessageClassNames:h,batchProgressPanelClassNames:g,artifactRunId:_,hideWorkstreamTabs:v,workingIndicatorClassName:y,messageListClassName:b,StoreLinkComponent:x,CollectionLinkComponent:S,prependFriendlyMessage:C,initialRequestData:w,initialRequestSchema:T,initialRequestTitle:E,initialRequestTemplate:D,showInitialRequest:O,hiddenMessageTypes:k,disableAutoScroll:A=!1,renderRequestInputControls:j=!0,activeWorkstream:M,onActiveWorkstreamChange:N}){_||console.warn(`[AllMessagesMixed] artifactRunId prop is missing!`);let{t:P}=X(),F=J(null),[I,L]=Y(`all`),R=M??I,z=G(e=>{M===void 0&&L(e),N?.(e)},[M,N]),ee=J(0),B=J(null),te=J(!1),ne=J(!1),re=l.size>0,ie=s===`sliding`;K(()=>{let e=F.current;if(!e)return;let t=()=>{if(ne.current)return;let{scrollTop:t,scrollHeight:n,clientHeight:r}=e,i=n-t-r;te.current=i>80};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]);let ae=q(()=>{let e=0;return l.forEach(t=>{e+=t.text?.length||0}),Math.floor(e/200)},[l]),oe=G(()=>{a.current&&(ne.current=!0,a.current.scrollIntoView({behavior:re?`instant`:`smooth`}),ee.current=Date.now(),requestAnimationFrame(()=>{ne.current=!1})),B.current=null},[a,re]);K(()=>{if(r.length,l.size,A||te.current)return;let e=Date.now()-ee.current;if(e>=100)oe();else if(B.current===null){let t=100-e;B.current=window.setTimeout(oe,t)}return()=>{B.current!==null&&(clearTimeout(B.current),B.current=null)}},[r.length,l.size,ae,oe,A]);let se=W.useMemo(()=>em(r,k),[r,k]),ce=W.useMemo(()=>i?em(i,k):se,[i,k,se]),le=W.useMemo(()=>{let e=rf(ce);return ce.forEach(t=>{let n=cl(t)??ll(t);n&&e.set(n.workstreamId,el(n.workstreamId,n.interaction))}),e},[ce]),ue=W.useMemo(()=>{if(R!==`all`)return le.get(R)??Qc(R)},[R,le]),de=G(()=>{let e=F.current;e&&(ne.current=!0,typeof e.scrollTo==`function`?e.scrollTo({top:0,behavior:`smooth`}):e.scrollTop=0,requestAnimationFrame(()=>{ne.current=!1}))},[]),fe=G(e=>{z(e),requestAnimationFrame(de)},[de,z]),pe=G(()=>{z(`all`),requestAnimationFrame(de)},[de,z]);K(()=>{R!==`all`&&!le.has(R)&&z(`all`)},[R,le,z]);let me=W.useMemo(()=>{let e=new Map;e.set(`all`,ce.length);let t=af(ce,`main`);return e.set(`main`,t.length),ce.forEach(t=>{let n=vl(t);n!==`main`&&e.set(n,(e.get(n)||0)+1)}),e},[ce]),V=W.useMemo(()=>xf(xl(se,R)),[se,R]),he=W.useMemo(()=>Kl(V),[V]),ge=W.useMemo(()=>ql(V),[V]),_e=W.useMemo(()=>eu(V),[V]),ve=W.useMemo(()=>nu(V),[V]),ye=W.useMemo(()=>{if(j)return;let e=au(V);return e?Wl(e):void 0},[V,j]),be=W.useCallback(e=>e.type===Q.REQUEST_INPUT&&(ye===Wl(e)||tu(e,_e,ge)),[_e,ye,ge]),xe=W.useCallback(e=>ru(e,ve),[ve]),Se=W.useMemo(()=>V.filter(e=>!xe(e)),[V,xe]),Ce=J(Date.now()),we=(!!C?.trim()||Hf(w)||D!==void 0)&&(O??!0),Te=q(()=>V.some(e=>e.type===Q.QUESTION),[V]),Ee=R===`all`&&we&&!Te,De=q(()=>V.reduce((e,t)=>Math.max(e,sf(t.timestamp)),-1/0),[V]),Oe=q(()=>V.reduce((e,t)=>ld(t)?e:Math.max(e,sf(t.timestamp)),-1/0),[V]),ke=q(()=>V.some(e=>Yl(e)&&!tu(e,_e,ge)),[_e,V,ge]),Ae=q(()=>vf(V,ve),[V,ve]),je=q(()=>ke||Ae||_f(Se)?!1:c||!hl(Se),[Se,Ae,ke,c]),{completeStreaming:Ne,incompleteStreaming:Pe}=W.useMemo(()=>{let e=new Map,t=[];return l.forEach((n,r)=>{if(R&&R!==`all`){let e=n.workstreamId||`main`;if(R!==e)return}n.startTimestamp<=Oe?e.set(r,n):n.text&&t.push({id:r,data:n})}),{completeStreaming:e,incompleteStreaming:t}},[l,R,Oe]),Fe=W.useMemo(()=>_p(Ed(V,Ne),ge),[V,Ne,ge]),Ie=W.useMemo(()=>Fe.filter(e=>!be(e)&&!xe(e)),[Fe,be,xe]),Le=q(()=>{if(Pe.some(({data:e})=>e.text.trim().length>0))return 1/0;let e=Pe.reduce((e,{data:t})=>Math.max(e,t.startTimestamp),-1/0);return Math.max(De,e)},[Pe,De]),Re=W.useMemo(()=>wd(Ie,je,Le),[Ie,je,Le]),ze=W.useMemo(()=>Il(Pl(V,Ne,R)),[V,Ne,R]),Be=q(()=>!je||_f(Se),[Se,je]),Ve=Od(Re,Be,Pe.length>0),He=kd(Re)?P(`agent.preparing`):P(`agent.working`),Ue=V.length===0&&we&&Be&&Pe.length===0,We=q(()=>Dd(Re,Ie,Ce.current),[Re,Ie]),Ge=J(We),Ke=J(!1),qe=q(()=>{if(!Ve)return We;let e=sf(We),t=sf(Ge.current);return!Ke.current||e<t?We:Ge.current},[We,Ve]);K(()=>{Ge.current=qe,Ke.current=Ve},[qe,Ve]);let U=q(()=>{let e=new Map,t=new Map;ce.forEach(e=>{let n=vl(e);t.has(n)||t.set(n,[]),t.get(n)?.push(e)});for(let[n,r]of t.entries())if(r.length>0){let t=r.some(e=>{if([Q.COMPLETE,Q.IDLE,Q.REQUEST_INPUT,Q.TERMINATED].includes(e.type))return!0;if(e.type===Q.UPDATE&&e.details){let t=e.details;return t.workstream_event===`completed`||t.status===`completed`||t.status===`canceled`}return!1});e.set(n,t)}return e},[ce]);return n(`div`,{ref:F,tabIndex:0,className:`flex-1 min-h-0 h-full w-full max-w-full overflow-y-auto overflow-x-hidden px-1.5 sm:px-2.5 lg:px-3 flex flex-col relative focus:outline-none`,"data-testid":`all-messages-mixed`,"data-message-count":r.length,"data-streaming-count":l.size,"data-view-mode":s,children:[t(`style`,{children:`
|
|
59
|
+
`)}async function hm(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}if(typeof document>`u`)return!1;let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.insetInlineStart=`-9999px`,t.style.top=`0`,document.body.appendChild(t);try{return t.focus(),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}function gm({item:e}){let r=e.kind===`command`&&e.command?pm(e):void 0,i=!r&&e.sections.length===0?e.text:void 0,a=!!(r||i||e.sections.length),o=mm(e),[s,c]=Y(`idle`),l=J(void 0);return K(()=>()=>{l.current!==void 0&&window.clearTimeout(l.current)},[]),n(`div`,{className:`relative mt-2 rounded-lg border border-border/70 bg-mixer-muted/10 p-3 shadow-sm`,children:[a?t(`div`,{className:`absolute end-2 top-2`,children:t(`button`,{type:`button`,className:V(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted opacity-70 transition`,`hover:bg-mixer-muted/20 hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,s===`copied`&&`text-success opacity-100`,s===`failed`&&`text-destructive opacity-100`),onClick:()=>{hm(o).then(e=>{c(e?`copied`:`failed`),l.current!==void 0&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>c(`idle`),2e3)})},"aria-label":`Copy tool details`,title:`Copy tool details`,children:t(s===`copied`?wt:Gt,{className:`size-4`})})}):null,n(`div`,{className:V(a&&`pe-7`),children:[t(um,{item:e,hasDetailContent:a}),r?t(`pre`,{className:`mb-3 whitespace-pre-wrap break-words font-mono text-sm leading-6 text-foreground/85`,children:r}):null,i?t(`div`,{className:`mb-3 break-words text-sm leading-6 text-foreground/75`,children:i}):null,e.sections.length>0?t(`div`,{className:`space-y-3`,children:e.sections.map(e=>t(dm,{section:e},e.key))}):null]}),s===`failed`&&a?t(`div`,{className:`mt-3 text-xs text-destructive`,children:`Copy failed`}):null]})}function _m({item:e}){let r=!!e.decisionText,a=!r&&(e.status===`error`||e.status===`warning`),o=lm(e).length>0,s=!!(e.command||e.text||e.sections.length||o),[c,l]=Y(!1),u=r?void 0:e.status;return n(`div`,{className:`min-w-0`,children:[n(`button`,{type:`button`,className:V(`grid w-full grid-cols-[1.5rem_1fr_auto] gap-2 text-start outline-none transition-colors`,`focus-visible:text-foreground focus-visible:underline focus-visible:underline-offset-4`,s?`cursor-pointer hover:text-foreground`:`cursor-default`),onClick:()=>s&&l(e=>!e),"aria-expanded":s?c:void 0,disabled:!s,children:[t(`span`,{className:V(`flex size-5 items-center justify-center pt-0.5`,a?`text-attention`:`text-muted`),children:t(cm,{kind:e.kind,status:u})}),n(`span`,{className:`min-w-0 text-sm text-muted`,children:[t(`span`,{className:`break-words`,children:e.title}),e.decisionText?t(i,{variant:`destructive`,className:`ms-2 rounded-full shadow-sm shadow-destructive/10`,children:e.decisionText}):null]}),s?t(Ot,{className:V(`mt-0.5 size-4 shrink-0 text-muted opacity-50 transition-transform`,!c&&`-rotate-90`),"aria-hidden":`true`}):null]}),s&&c?t(`div`,{className:`mt-1`,children:t(gm,{item:e})}):null]})}function vm({item:e,artifactRunId:r,disableCollapse:i}){let{t:a}=X(),o=e.text??e.title,s=o.trim(),[c,l]=Y(!1),u=s?s.split(/\r?\n/).length:0,d=s.length>520||u>6,f=a(c?`agent.showLess`:`agent.showMore`);return n(`div`,{className:`min-w-0 py-1`,children:[t(`div`,{"data-testid":`summary-thought-prose`,className:V(Yf,d&&!i&&!c&&`[display:-webkit-box] overflow-hidden [-webkit-box-orient:vertical] [-webkit-line-clamp:6]`),style:{overflowWrap:`anywhere`},children:t(Li,{artifactRunId:r,components:Zf,children:o})}),d&&!i?t(`div`,{className:`mt-1.5 flex justify-end`,children:n(`button`,{type:`button`,"aria-expanded":c,className:V(`inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors`,`[text-decoration:none] hover:text-foreground hover:[text-decoration:none]`,`focus-visible:text-foreground focus-visible:[text-decoration:none]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),onClick:()=>l(e=>!e),children:[f,t(Ot,{className:V(`size-4 transition-transform`,c&&`rotate-180`),"aria-hidden":`true`})]})}):null]})}function ym({items:e,artifactRunId:n,disablePreambleCollapse:r}){return t(`div`,{className:`mt-3`,children:t(`div`,{className:`space-y-3`,children:e.map(e=>e.isPreamble||e.kind===`think`?t(vm,{item:e,artifactRunId:n,disableCollapse:r},e.key):t(_m,{item:e},e.key))})})}function bm({text:e,artifactRunId:n,workstreamId:r}){return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":r,children:t(`div`,{className:Yf,style:{overflowWrap:`anywhere`},children:t(Li,{artifactRunId:n,components:Zf,children:e})})})}function xm({message:e,startTimestamp:r,endTimestamp:i,className:a}){let{t:o}=X(),s=Ff(Pf(r??e.timestamp,i??e.timestamp));return n(`div`,{className:V(`mx-auto w-full max-w-3xl px-1`,a),"data-testid":`summary-stopped-message`,children:[n(`div`,{className:`flex items-center justify-end gap-2 text-lg font-medium text-muted sm:text-xl`,children:[t(`span`,{children:o(`agent.youStoppedAfter`,{duration:s})}),t(dd,{message:e,className:`h-5 w-5`})]}),t(`div`,{className:`mt-5 border-b border-border/70`})]})}function Sm({label:r,timestamp:i,durationSeconds:a,showElapsed:o,details:s,emptyDetailsLabel:c,defaultExpanded:l=!1,disablePreambleCollapse:u=!1,className:d,artifactRunId:f,onSendMessage:p,answeredToolApprovalRequestInputKeys:m,resolvedToolApprovalKeys:h}){let[g,_]=Y(l),v=cp(i,o&&a===void 0),y=a??v,b=o&&i!==void 0,x=q(()=>sm(s??[]),[s]),S=q(()=>(s??[]).filter(e=>fu(e)&&!Eu(e,m??new Set,h??new Set)),[m,s,h]),C=x.length>0||S.length>0||!!c;return t(`div`,{className:V(`mx-auto w-full max-w-3xl px-1`,d),children:n(`div`,{className:`border-b border-border/70 pb-3 text-sm text-muted`,children:[n(`button`,{type:`button`,className:V(`inline-flex max-w-full items-center gap-2 text-start outline-none`,`focus-visible:text-foreground focus-visible:underline focus-visible:underline-offset-4`,C?`cursor-pointer hover:text-foreground`:`cursor-default`),onClick:()=>C&&_(e=>!e),"aria-expanded":C?g:void 0,disabled:!C,children:[t(`span`,{className:`min-w-0 truncate font-medium`,children:r}),b?n(`span`,{className:`shrink-0 text-muted/75`,children:[`for `,Ff(y)]}):null,C?t(g?Ot:jt,{className:`size-4 shrink-0 opacity-50`}):null]}),C&&g?x.length>0||S.length>0?n(e,{children:[x.length>0?t(ym,{items:x,artifactRunId:f,disablePreambleCollapse:u}):null,S.length>0?t(`div`,{className:`mt-3 space-y-3`,children:S.map(e=>{let n=e.details.ux;return t(yl,{question:su(e),options:n.options,variant:n.variant,multiSelect:n.multiSelect,onSelect:t=>p?.(t,bu(e,t)),onMultiSelect:e=>p?.(e.join(`, `)),allowFreeResponse:!n.options?.length||!!n.free_response,placeholder:n.free_response?.placeholder,submitLabel:n.free_response?.submit_label,onSubmit:e=>p?.(e,n.free_response?.metadata),hideBorder:!0,compact:!0,className:`my-0`,cardClassName:`bg-background/60 shadow-none`},Kp(e,`work-request-input`))})}):null]}):n(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-muted`,children:[t(ur,{className:`size-4 opacity-70`,"aria-hidden":`true`}),t(`span`,{children:c})]}):null]})})}function Cm({children:e,status:r}){let i=r===`error`?`bg-destructive`:r===`warning`?`bg-attention`:r===`completed`?`bg-success`:`bg-muted`;return n(`div`,{className:`relative ps-7`,children:[t(`div`,{className:`absolute start-2 top-0 bottom-0 w-px bg-border`}),t(`div`,{className:V(`absolute start-[5px] top-4 size-2.5 rounded-full ring-4 ring-background`,i)}),e]})}var wm=class extends tt{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return console.error(`Message render error:`,e),{hasError:!0,error:e}}componentDidUpdate(e){this.state.hasError&&e.children!==this.props.children&&this.setState({hasError:!1,error:void 0})}render(){return this.state.hasError?n(`div`,{className:`border-s-4 border-s-destructive bg-destructive/10 px-4 py-2 my-2 rounded-e`,children:[t(`p`,{className:`text-sm text-destructive font-medium`,children:ut.getFixedT(null,lt)(`agent.failedToRenderMessage`)}),t(`p`,{className:`text-xs text-muted mt-1 truncate`,children:this.state.error?.message||`Unknown error`})]}):this.props.children}};function Tm(e,t){let n=[...e.filter(e=>!Ep(e)&&!t?.includes(e.type))].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),r=[];for(let e of n){let t=r[r.length-1];t&&Yl(t,e)||t&&Dm(t,e)||r.push(e)}return r}function Em({messages:r,workstreamSourceMessages:i,bottomRef:a,viewMode:s=`stacked`,isCompleted:c=!1,streamingMessages:l=new Map,onSendMessage:u,messageItemClassNames:d,messageStyleOverrides:f,toolCallGroupClassNames:p,hideToolCallsInViewMode:m,streamingMessageClassNames:h,batchProgressPanelClassNames:g,artifactRunId:_,hideWorkstreamTabs:v,workingIndicatorClassName:y,messageListClassName:b,StoreLinkComponent:x,CollectionLinkComponent:S,prependFriendlyMessage:C,initialRequestData:w,initialRequestSchema:T,initialRequestTitle:E,initialRequestTemplate:D,showInitialRequest:O,hiddenMessageTypes:k,disableAutoScroll:A=!1,renderRequestInputControls:j=!0,activeWorkstream:M,onActiveWorkstreamChange:N}){_||console.warn(`[AllMessagesMixed] artifactRunId prop is missing!`);let{t:P}=X(),F=J(null),[I,L]=Y(`all`),R=M??I,ee=G(e=>{M===void 0&&L(e),N?.(e)},[M,N]),te=J(0),z=J(null),ne=J(!1),B=J(!1),re=l.size>0,ie=s===`sliding`;K(()=>{let e=F.current;if(!e)return;let t=()=>{if(B.current)return;let{scrollTop:t,scrollHeight:n,clientHeight:r}=e,i=n-t-r;ne.current=i>80};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]);let ae=q(()=>{let e=0;return l.forEach(t=>{e+=t.text?.length||0}),Math.floor(e/200)},[l]),oe=G(()=>{a.current&&(B.current=!0,a.current.scrollIntoView({behavior:re?`instant`:`smooth`}),te.current=Date.now(),requestAnimationFrame(()=>{B.current=!1})),z.current=null},[a,re]);K(()=>{if(r.length,l.size,A||ne.current)return;let e=Date.now()-te.current;if(e>=100)oe();else if(z.current===null){let t=100-e;z.current=window.setTimeout(oe,t)}return()=>{z.current!==null&&(clearTimeout(z.current),z.current=null)}},[r.length,l.size,ae,oe,A]);let se=W.useMemo(()=>Tm(r,k),[r,k]),ce=W.useMemo(()=>i?Tm(i,k):se,[i,k,se]),le=W.useMemo(()=>{let e=kf(ce);return ce.forEach(t=>{let n=jl(t)??Ml(t);n&&e.set(n.workstreamId,Cl(n.workstreamId,n.interaction))}),e},[ce]),ue=W.useMemo(()=>{if(R!==`all`)return le.get(R)??xl(R)},[R,le]),de=G(()=>{let e=F.current;e&&(B.current=!0,typeof e.scrollTo==`function`?e.scrollTo({top:0,behavior:`smooth`}):e.scrollTop=0,requestAnimationFrame(()=>{B.current=!1}))},[]),fe=G(e=>{ee(e),requestAnimationFrame(de)},[de,ee]),pe=G(()=>{ee(`all`),requestAnimationFrame(de)},[de,ee]);K(()=>{R!==`all`&&!le.has(R)&&ee(`all`)},[R,le,ee]);let me=W.useMemo(()=>{let e=new Map;e.set(`all`,ce.length);let t=Af(ce,`main`);return e.set(`main`,t.length),ce.forEach(t=>{let n=Vl(t);n!==`main`&&e.set(n,(e.get(n)||0)+1)}),e},[ce]),he=W.useMemo(()=>Kf(Wl(se,R)),[se,R]),ge=W.useMemo(()=>hu(he),[he]),_e=W.useMemo(()=>gu(he),[he]),ve=W.useMemo(()=>Tu(he),[he]),ye=W.useMemo(()=>Du(he),[he]),be=W.useMemo(()=>{if(j)return;let e=Au(he);return e?pu(e):void 0},[he,j]),xe=W.useCallback(e=>e.type===Q.REQUEST_INPUT&&(be===pu(e)||Eu(e,ve,_e)),[ve,be,_e]),Se=W.useCallback(e=>Ou(e,ye),[ye]),Ce=W.useMemo(()=>he.filter(e=>!Se(e)),[he,Se]),we=J(Date.now()),Te=(!!C?.trim()||pp(w)||D!==void 0)&&(O??!0),Ee=q(()=>he.some(e=>e.type===Q.QUESTION),[he]),De=R===`all`&&Te&&!Ee,Oe=q(()=>he.reduce((e,t)=>Math.max(e,Mf(t.timestamp)),-1/0),[he]),ke=q(()=>he.reduce((e,t)=>Pd(t)?e:Math.max(e,Mf(t.timestamp)),-1/0),[he]),Ae=q(()=>he.some(e=>vu(e)&&!Eu(e,ve,_e)),[ve,he,_e]),je=q(()=>Uf(he,ye),[he,ye]),Me=q(()=>Ae||je||Hf(Ce)?!1:c||!Rl(Ce),[Ce,je,Ae,c]),{completeStreaming:Ne,incompleteStreaming:Pe}=W.useMemo(()=>{let e=new Map,t=[];return l.forEach((n,r)=>{if(R&&R!==`all`){let e=n.workstreamId||`main`;if(R!==e)return}n.startTimestamp<=ke?e.set(r,n):n.text&&t.push({id:r,data:n})}),{completeStreaming:e,incompleteStreaming:t}},[l,R,ke]),Fe=W.useMemo(()=>Hp(Zd(he,Ne),_e),[he,Ne,_e]),Ie=W.useMemo(()=>Fe.filter(e=>!xe(e)&&!Se(e)),[Fe,xe,Se]),Le=q(()=>{if(Pe.some(({data:e})=>e.text.trim().length>0))return 1/0;let e=Pe.reduce((e,{data:t})=>Math.max(e,t.startTimestamp),-1/0);return Math.max(Oe,e)},[Pe,Oe]),Re=W.useMemo(()=>Yd(Ie,Me,Le),[Ie,Me,Le]),ze=W.useMemo(()=>au(ru(he,Ne,R)),[he,Ne,R]),H=q(()=>!Me||Hf(Ce),[Ce,Me]),Be=$d(Re,H,Pe.length>0),Ve=ef(Re)?P(`agent.preparing`):P(`agent.working`),He=he.length===0&&Te&&H&&Pe.length===0,Ue=q(()=>Qd(Re,Ie,we.current),[Re,Ie]),We=J(Ue),Ge=J(!1),Ke=q(()=>{if(!Be)return Ue;let e=Mf(Ue),t=Mf(We.current);return!Ge.current||e<t?Ue:We.current},[Ue,Be]);K(()=>{We.current=Ke,Ge.current=Be},[Ke,Be]);let qe=q(()=>{let e=new Map,t=new Map;ce.forEach(e=>{let n=Vl(e);t.has(n)||t.set(n,[]),t.get(n)?.push(e)});for(let[n,r]of t.entries())if(r.length>0){let t=r.some(e=>{if([Q.COMPLETE,Q.IDLE,Q.REQUEST_INPUT,Q.TERMINATED].includes(e.type))return!0;if(e.type===Q.UPDATE&&e.details){let t=e.details;return t.workstream_event===`completed`||t.status===`completed`||t.status===`canceled`}return!1});e.set(n,t)}return e},[ce]);return n(`div`,{ref:F,tabIndex:0,className:`flex-1 min-h-0 h-full w-full max-w-full overflow-y-auto overflow-x-hidden px-1.5 sm:px-2.5 lg:px-3 flex flex-col relative focus:outline-none`,"data-testid":`all-messages-mixed`,"data-message-count":r.length,"data-streaming-count":l.size,"data-view-mode":s,children:[t(`style`,{children:`
|
|
60
60
|
/* Better vertical rhythm for markdown */
|
|
61
61
|
.vprose > * + * {
|
|
62
62
|
margin-top: 0.625rem;
|
|
@@ -311,7 +311,7 @@ $&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
|
|
|
311
311
|
.agent-markdown tbody tr:hover {
|
|
312
312
|
background: transparent;
|
|
313
313
|
}
|
|
314
|
-
`}),s===`stacked`&&t(`div`,{className:H(`sticky top-0 z-10`,v&&`hidden`),children:t(nf,{workstreams:le,activeWorkstream:R,onSelectWorkstream:fe,count:me,completionStatus:U})}),V.length===0&&!we&&!(ie&&Ve)?R===`all`&&Be&&Pe.length===0?t(`div`,{className:`flex-1 px-2 py-6 sm:px-4`,children:t(Xf,{label:P(`agent.preparing`),timestamp:Ce.current,className:y})}):t(`div`,{className:`flex items-center justify-center h-full text-center py-8`,children:t(`div`,{className:`flex items-center px-3 py-2 text-sm text-muted`,children:P(R===`all`?`agent.waitingForAgentResponse`:`agent.noMessagesInWorkstream`)})}):n(`div`,{className:H(`flex-1 flex flex-col justify-start w-full max-w-full`,ie?`gap-6 px-2 py-6 sm:px-4`:`gap-3 pb-4`,b),children:[ie&&R!==`all`&&ue&&t(`div`,{className:`sticky top-0 z-20 -mx-2 bg-background/95 px-2 pb-2 pt-1 backdrop-blur sm:-mx-4 sm:px-4`,children:n(`div`,{className:`mx-auto flex w-full max-w-3xl items-center gap-2 border-b border-border/70 pb-3`,children:[t(Me,{description:P(`agent.backToMainAgent`),asChild:!0,children:t(o,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 text-muted hover:text-foreground`,"aria-label":P(`agent.backToMainAgent`),onClick:pe,children:t(ct,{className:`size-4`,"aria-hidden":`true`})})}),t(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:ue})]})}),Ee&&t(Yf,{data:w,schema:T,title:E,template:D,prependFriendlyMessage:C,timestamp:V[0]?.timestamp??Date.now(),isSummaryView:ie,messageItemClassNames:d,messageStyleOverrides:f,StoreLinkComponent:x,CollectionLinkComponent:S},`initial-request`),Ue&&t(Xf,{label:He,timestamp:qe,className:y}),s===`stacked`?n(e,{children:[ze.map((e,n)=>{let r=n===ze.length-1;if(e.type===`tool_group`){let n=e.messages[e.messages.length-1],i=e.toolStatus===`completed`||e.toolStatus===`error`||e.toolStatus===`warning`,a=!c&&r&&!ml.includes(n.type)&&!i;return m?.includes(s)?null:t(Qp,{status:e.toolStatus,children:t($p,{children:t(Yd,{...p,messages:e.messages,showPulsatingCircle:a,toolRunId:e.toolRunId,toolStatus:e.toolStatus,preambleText:e.preambleText,preambleMessage:e.preambleMessage,rootClassName:H(`rounded-lg border border-border bg-background/60 shadow-none`,p?.rootClassName),headerClassName:H(`px-3 py-2`,p?.headerClassName),itemHeaderClassName:H(`hover:bg-mixer-muted/20`,p?.itemHeaderClassName)})})},Sp(e))}else if(e.type===`streaming`)return t(Qp,{children:t(od,{...h,text:e.text,workstreamId:e.workstreamId,isComplete:e.isComplete,timestamp:e.startTimestamp,artifactRunId:_,cardClassName:H(`rounded-lg border border-border bg-background/60 shadow-none`,h?.cardClassName)})},Sp(e));else{let i=e.message;if(be(i)||xe(i))return null;if(gl(i))return t(Qp,{children:t(Xp,{message:i,startTimestamp:Cp(ze,n)??i.timestamp,endTimestamp:i.timestamp})},xp(i,`stopped`));let a=!c&&r&&!ml.includes(i.type);return of(i)?t($p,{children:t(Fu,{message:i,batchData:i.details,isRunning:!i.details.completed_at,...g})},`batch-${i.details.batch_id}-${i.timestamp}`):t(Qp,{status:`message`,children:t($p,{children:t(id,{...d,message:i,showPulsatingCircle:a,onSendMessage:u,requestInputAnswered:iu(i,he),cardClassName:H(`rounded-lg border border-border bg-background/60 shadow-none`,d?.cardClassName),headerClassName:H(`px-3 py-2`,d?.headerClassName),contentClassName:H(`bg-transparent`,d?.contentClassName),messageStyleOverrides:f,StoreLinkComponent:x,CollectionLinkComponent:S})})},xp(i))}}),Pe.map(({id:e,data:n})=>t(Qp,{children:t(od,{...h,text:n.text,workstreamId:n.workstreamId,isComplete:n.isComplete,timestamp:n.startTimestamp,artifactRunId:_,cardClassName:H(`rounded-lg border border-border bg-background/60 shadow-none`,h?.cardClassName)})},`streaming-incomplete-${e}`)),Be&&Pe.length===0&&!Ue&&t(Qp,{children:n(`div`,{className:H(`flex items-center gap-2 py-2 text-sm text-muted`,y),children:[t(lu,{size:`sm`,color:`blue`}),t(`span`,{children:P(`agent.working`)})]})})]}):n(e,{children:[Re.map(e=>{if(e.type===`work`){if(m?.includes(s))return null;let n=hf(e.messages);return t(Zp,{label:gf(e.isActive),status:e.status,timestamp:e.startTimestamp,durationSeconds:e.isActive?void 0:lf(e.startTimestamp,e.endTimestamp),showElapsed:!0,details:n?void 0:e.messages,defaultExpanded:e.isActive&&!n,disablePreambleCollapse:e.isActive,className:y,onSendMessage:u,answeredToolApprovalRequestInputKeys:_e,resolvedToolApprovalKeys:ge},`work-${e.id}-${e.isActive?`active`:`done`}-${e.status}`)}if(e.type===`stopped`)return t(Xp,{message:e.message,startTimestamp:e.startTimestamp,endTimestamp:e.endTimestamp},xp(e.message,`stopped-summary`));let n=e.message;return be(n)||xe(n)?null:of(n)?t($p,{children:t(Fu,{message:n,batchData:n.details,isRunning:!n.details.completed_at,...g})},xp(n,`batch`)):t($p,{children:t(Bf,{message:n,onSendMessage:u,onSelectWorkstream:fe,requestInputAnswered:iu(n,he),StoreLinkComponent:x,CollectionLinkComponent:S})},xp(n,`summary`))}),Pe.map(({id:e,data:n})=>t(Yp,{text:n.text,workstreamId:n.workstreamId,artifactRunId:_},`streaming-incomplete-${e}`)),Ve&&!Ue&&t(Zp,{label:He,status:`running`,timestamp:qe,showElapsed:!0,className:y})]}),t(`div`,{ref:a,className:`h-2`})]})]})}const nm=(e,t)=>{if(e.type!==t.type||e.message!==t.message)return!1;let n=e.details,r=t.details;if(n?.tool_status!==`completed`||r?.tool_status!==`completed`)return!1;let i=typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime();return(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())-i<2e3},rm=W.memo(tm);function im(e){return e?new Map(e.streamingMessages.map((e,t)=>[e.id??e.activityId??`stream-${t}`,e])):new Map}function am(e,t){return e?.find(e=>e.cursor===t)}function om(e,t){if(t===0||e===`live`)return`live`;let n=wa(e,t);return n>=t-1?`live`:n+1}function sm(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function cm(e){return sm(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function lm(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function um({fixture:e,cursor:r,initialCursor:i,onCursorChange:a,autoStepMs:s,repeat:c=1,viewMode:l,className:u,title:d,showHeader:f=!0}){let{t:p}=X(),m=e.messages,h=i??(m.length>0?0:`live`),[g,_]=Y(()=>Ca(h,m.length)),v=r??g,y=l??`sliding`,[b,x]=Y(!!s),[S,C]=Y(0),w=J(null),T=q(()=>Da(m,v,!0),[v,m]),E=T.displayedMessages,D=q(()=>im(am(e.streamingFrames,T.cursor)),[e.streamingFrames,T.cursor]),O=G(e=>{let t=Ca(e,m.length);r===void 0&&_(t),a?.(t)},[r,m.length,a]);K(()=>{let e=Ca(v,m.length);e!==v&&O(e)},[v,m.length,O]),K(()=>{if(!s||s<=0||!b)return;let e=window.setInterval(()=>{let e=om(v,m.length);if(e===`live`&&v===`live`){C(e=>{let t=e+1;return c>0&&t>=c?(x(!1),t):(O(m.length>0?0:`live`),t)});return}O(e)},s);return()=>window.clearInterval(e)},[s,v,b,m.length,c,O]);let k=E.length>0&&!hl(E),A=q(()=>au(E),[E]),j=d??e.metadata?.title??p(`agent.rewind.fixtureTitle`),M=G(()=>{let t={...e,metadata:{...e.metadata,title:j,exported_at:e.metadata?.exported_at??new Date().toISOString(),message_count:m.length}},n=e.metadata?.agent_run_id??`fixture`;lm(`${cm(j)||`agent-chat`}-${cm(n)}.json`,t)},[e,m.length,j]),N=G(()=>{O(om(T.cursor,m.length))},[m.length,T.cursor,O]);return n(`div`,{className:H(`flex h-full min-h-0 w-full flex-col bg-background text-foreground`,u),"data-agent-test-playback-enabled":!0,"data-agent-playback-cursor":T.cursor,"data-agent-live-message-count":m.length,"data-agent-rendered-message-count":T.renderedMessageCount,"data-agent-replay-playing":b||void 0,"data-agent-replay-loop":S,children:[f&&n(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,children:j}),t(`div`,{className:`text-xs text-muted`,children:p(`agent.rewind.fixtureMeta`,{messageCount:m.length,loops:S})})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:M,children:[t(Rt,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(`agent.rewind.exportFixture`)})]}),s&&s>0&&n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>x(e=>!e),children:[t(b?Dn:kn,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(b?`agent.rewind.pause`:`agent.rewind.resume`)})]})]})]}),t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(Na,{cursor:T.cursor,messages:m,onChangeCursor:O})}),t(rm,{messages:E,isCompleted:k,streamingMessages:D,bottomRef:w,artifactRunId:e.metadata?.agent_run_id??`agent-chat-fixture`,viewMode:y,renderRequestInputControls:!A}),A&&t(su,{message:A,onSendMessage:N,isLoading:!1})]})}function dm({className:e,inline:r=!1}){return n(`div`,{className:H(`flex items-center gap-1`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-blue-500 rounded-full animate-[jumping_1s_infinite_ease-in-out] hover:bg-blue-600`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-blue-500 rounded-full animate-[jumping_1s_0.3s_infinite_ease-in-out] hover:bg-blue-600`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-blue-500 rounded-full animate-[jumping_1s_0.6s_infinite_ease-in-out] hover:bg-blue-600`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}})]})}function fm(){let{client:e}=Z(),[t,n]=Y([]),[r,i]=Y(!0),[a,o]=Y(!1),s=J(0),c=G(async()=>{let t=s.current+1;s.current=t,i(!0),o(!1);try{let r=await e.apps.getInstalledApps(`tools`),a=[];for(let e of r){let t=e,n=t.oauth_collection_ids??[],r=t.manifest.oauth_providers??{};if(!t.manifest.tool_collections)continue;let i=t.manifest.tool_collections.map(e=>Ar(e)).filter(e=>e.type===`mcp`&&n.includes(e.id)),o=new Map,s=new Map,c=[];for(let e of i)if(e.oauth_provider){let t=o.get(e.oauth_provider)??[];t.push(e),o.set(e.oauth_provider,t)}else if(e.oauth_app){let t=s.get(e.oauth_app)??[];t.push(e),s.set(e.oauth_app,t)}else c.push(e);for(let[e,n]of o)a.push({key:`${t.id}:provider:${e}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:r[e]?.display_name||e,representativeId:n[0].id,memberIds:n.map(e=>e.id),memberNames:n.map(e=>e.name)});for(let[e,n]of s)a.push({key:`${t.id}:oauthapp:${e}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e,representativeId:n[0].id,memberIds:n.map(e=>e.id),memberNames:n.map(e=>e.name)});for(let e of c)a.push({key:`${t.id}:individual:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name]})}if(s.current!==t||(n(a),i(!1),a.length===0))return;o(!0);let c=new Map,l=await Promise.all(a.map(async t=>{try{let n=c.get(t.appId);n||(n=e.remoteMcpConnections.getStatus(t.appId),c.set(t.appId,n));let r=(await n).find(e=>e.collection_id===t.representativeId);return{...t,authStatus:r}}catch{return t}}));if(s.current!==t)return;n(l)}catch(e){s.current===t&&(console.error(`Failed to load MCP tool collections:`,e),n([]))}finally{s.current===t&&(i(!1),o(!1))}},[e]);return K(()=>{c()},[c]),{groups:t,loading:r,statusLoading:a,reload:c}}function pm(e,t){return t?.length?e.memberIds.every(e=>t.includes(e)):!1}function mm(e,t,n){let r=new Set(t??[]);if(n)for(let t of e.memberIds)r.delete(t);else for(let t of e.memberIds)r.add(t);return Array.from(r)}function hm(e,t){return e.filter(e=>e.authStatus?.authenticated===!0&&!pm(e,t)).length}function gm(e,t){return e.filter(e=>e.authStatus?.authenticated===!0&&!pm(e,t)).map(e=>e.label)}function _m({isOpen:e,onClose:r,groups:i,loading:a,statusLoading:o=!1,reload:s,disabledCollections:c,onChange:l,onConnectionChange:u,readOnly:d=!1}){let{t:f}=X(),p=()=>{s(),u?.()};return n(bo,{isOpen:e,onClose:r,size:`md`,className:`max-w-[92vw] sm:max-w-[620px] lg:max-w-[620px]`,children:[t(xo,{children:f(`mcpConnections.title`)}),n(So,{children:[t(`p`,{className:`mb-4 text-sm text-muted`,children:f(`mcpConnections.subtitle`)}),a?t(`div`,{className:`flex items-center justify-center py-8`,children:t(ms,{className:`size-5`})}):i.length===0?t(`div`,{className:`py-8 text-center text-sm text-muted`,children:f(`mcpConnections.empty`)}):t(`div`,{className:`space-y-1`,children:i.map(e=>{let r=!pm(e,c),i=e.authStatus?.authenticated===!0;return n(`div`,{className:`flex items-center justify-between gap-3 py-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[t(i?fn:pn,{className:`size-4 shrink-0 ${i?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(Ha,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:e.appName}),e.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:e.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`truncate ${r?`text-foreground`:`text-muted line-through`}`,children:e.label})})]}),n(`div`,{className:`flex shrink-0 items-center gap-3`,children:[o&&!e.authStatus?t(Ka,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,"aria-label":f(`mcpConnections.checkingStatus`),title:f(`mcpConnections.checkingStatus`),children:t(ms,{className:`size-3`})}):t(_s,{appId:e.appId,collectionId:e.representativeId,collectionName:e.label,authenticated:e.authStatus?.authenticated,onAuthChange:p,variant:`compact`,showDisconnect:!0,readOnly:d}),l&&t(os,{size:`sm`,value:r,onChange:t=>l(mm(e,c,t)),disabled:d,"aria-label":f(r?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:e.label})})]})]},e.key)})})]})]})}function vm({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1,variant:s=`outline`,size:c=`sm`}){let{t:l}=X(),{groups:u,loading:d,statusLoading:f,reload:p}=fm(),[m,h]=Y(!1);if(!d&&u.length===0)return null;let g=hm(u,r),_=gm(u,r),v=_.slice(0,2),y=_.length-v.length,b=v.length>0?`${v.join(`, `)}${y>0?` +${y}`:``}`:void 0;return n(e,{children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b&&t(`span`,{className:`max-w-48 truncate text-muted`,title:_.join(`, `),children:b}),n(Ka,{variant:s,size:c,className:`shrink-0`,onClick:()=>h(!0),disabled:d,"aria-label":l(`mcpConnections.manage`),children:[t(`span`,{children:l(`mcpConnections.label`)}),g>0&&t(Xa,{variant:`success`,children:g})]})]}),t(_m,{isOpen:m,onClose:()=>h(!1),groups:u,loading:d,reload:p,statusLoading:f,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}function ym({disabledCollections:e,onChange:r,onConnectionChange:i,readOnly:a=!1}){let{t:o}=X(),{groups:s,loading:c,statusLoading:l,reload:u}=fm();if(!c&&s.length===0)return null;let d=()=>{u(),i?.()};return c&&s.length===0?n(`div`,{className:`flex items-center gap-2 border-y border-border/70 py-2 text-sm text-muted`,children:[t(ms,{className:`size-4`}),t(`span`,{children:o(`mcpConnections.label`)})]}):t(`div`,{className:`space-y-1`,children:s.map(i=>{let s=!pm(i,e),c=i.authStatus?.authenticated===!0;return n(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 text-sm`,children:[n(`div`,{className:`flex min-w-36 flex-1 items-center gap-2`,children:[t(c?fn:pn,{className:`size-4 shrink-0 ${c?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(Ha,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:i.appName}),i.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:i.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`block truncate ${s?`text-foreground`:`text-muted line-through`}`,children:i.label})})]}),l&&!i.authStatus?t(Ka,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,"aria-label":o(`mcpConnections.checkingStatus`),title:o(`mcpConnections.checkingStatus`),children:t(ms,{className:`size-3`})}):t(_s,{appId:i.appId,collectionId:i.representativeId,collectionName:i.label,authenticated:i.authStatus?.authenticated,onAuthChange:d,variant:`compact`,showDisconnect:!0,readOnly:a}),r&&n(`div`,{className:`flex min-w-24 items-center justify-end gap-2 text-xs`,children:[t(`span`,{className:s?`text-muted`:`text-attention`,children:o(s?`mcpConnections.enabled`:`mcpConnections.disabled`)}),t(os,{size:`sm`,value:s,onChange:t=>r(mm(i,e,t)),disabled:a,"aria-label":o(s?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:i.label})})]})]},i.key)})})}function bm({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1}){let{t:s}=X(),{groups:c,loading:l,statusLoading:u,reload:d}=fm(),[f,p]=Y(!1);if(!l&&c.length===0)return null;let m=hm(c,r);return n(e,{children:[t(Wo,{align:`left`,trigger:t(Ka,{variant:`ghost`,size:`icon`,className:`size-8 rounded-md text-muted hover:bg-muted`,"aria-label":s(`mcpConnections.settings`),title:s(`mcpConnections.settings`),disabled:l,children:t(`span`,{className:`flex size-5 items-center justify-center rounded-[3px] border border-muted text-sm font-semibold leading-none`,"aria-hidden":`true`,children:`/`})}),children:n(Go,{onClick:()=>p(!0),isDisabled:l,children:[t(`span`,{children:s(`mcpConnections.title`)}),m>0&&t(Xa,{variant:`success`,children:m})]})}),t(_m,{isOpen:f,onClose:()=>p(!1),groups:c,loading:l,reload:d,statusLoading:u,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}Ai.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${Ai.version}/build/pdf.worker.min.mjs`;function xm({className:e,size:n=`md`}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(mn,{className:`${{sm:`w-4 h-4`,md:`w-6 h-6`,lg:`w-8 h-8`}[n]} animate-spin text-muted-foreground`})})}function Sm({pdfUrl:e,pageNumber:r,width:i,className:a,renderTextLayer:o=!1,renderAnnotationLayer:s=!1,onLoadSuccess:c,onError:l}){let[u,d]=Y(!0),[f,p]=Y(null);return f?t(`div`,{className:`flex items-center justify-center text-destructive text-sm ${a||``}`,children:`Failed to load PDF`}):n(`div`,{className:a,children:[u&&t(xm,{className:`py-4`,size:`md`}),t(Oi,{file:e,onLoadSuccess:({numPages:e})=>{d(!1),c?.(e)},onLoadError:e=>{d(!1),p(e),l?.(e)},loading:null,children:t(ki,{pageNumber:r,width:i,renderTextLayer:o,renderAnnotationLayer:s,loading:t(xm,{className:`py-4`,size:`sm`})})})]})}const Cm=Ye(null);function wm({pdfUrl:e,urlLoading:n=!1,children:r,onLoadSuccess:i}){let[a,o]=Y(0),[s,c]=Y(!0),[l,u]=Y(null),[d,f]=Y(null),p=async e=>{o(e.numPages),i?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1});f({width:t.width,height:t.height,aspectRatio:t.width/t.height})}catch(e){console.error(`Failed to get page dimensions:`,e)}c(!1)},m=e=>{c(!1),u(e)},h={pdfUrl:e,numPages:a,loading:n||(e?s:!0),error:l,pageDimensions:d};return l?t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`}):t(Cm.Provider,{value:h,children:e?t(Oi,{file:e,onLoadSuccess:p,onLoadError:m,loading:t(xm,{className:`py-4`,size:`md`}),children:r((e,n)=>t(ki,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(xm,{className:`py-4`,size:`sm`})},e))}):t(xm,{className:`py-4`,size:`md`})})}function Tm(){return Qe(Cm)}const Em=210/297;function Dm({pageNumber:e,width:n,className:r}){let i=Tm(),a=i?.pageDimensions?.aspectRatio??Em,o=n?Math.round(n/a):200;return i?.loading?t(`div`,{className:`flex items-center justify-center bg-muted ${r||``}`,style:{height:o,width:n||`100%`},children:t(xm,{size:`md`})}):t(`div`,{className:r,children:t(ki,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(xm,{className:`py-4`,size:`sm`})})})}function Om({pageNumber:e,width:n,isSelected:r,onSelect:i,renderThumbnail:a,aspectRatio:o=Em,rootMargin:s=`200px 0px`}){let c=J(null),[l,u]=Y(!1);K(()=>{let e=c.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0]?.isIntersecting&&u(!0)},{rootMargin:s,threshold:0});return t.observe(e),()=>t.disconnect()},[s]);let d=n?Math.round(n/o):200;return t(`div`,{ref:c,children:a({pageNumber:e,isSelected:r,pageElement:l?t(ki,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d},children:t(xm,{size:`sm`})})}):t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d,width:n||`100%`},children:t(`span`,{className:`text-muted-foreground text-xs`,children:e})}),onSelect:i})})}function km(e){if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return null}function Am({pdfUrl:r,urlLoading:i=!1,pageCount:a,currentPage:o,thumbnailWidth:s,onPageSelect:c,renderThumbnail:l,scrollContainerRef:u,onAspectRatioChange:d,onItemHeightChange:f,calculateItemHeight:p,onPageCountChange:m}){let[h,g]=Y(null),[_,v]=Y({start:0,end:Math.min(15,a)}),[y,b]=Y(null),x=J(null),S=G(e=>{g(e)},[]),C=G(async e=>{m?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1}),n=t.width/t.height;b(n),d?.(n)}catch(e){console.error(`Failed to get page dimensions:`,e),b(Em),d?.(Em)}},[d,m]),w=y??Em,T=s?Math.round(s/w):200,E=p?p(T):T+16+24+8;if(K(()=>{E>0&&y!==null&&f?.(E)},[E,y,f]),K(()=>{let e=u?.current||km(x.current);if(!e)return;let t=()=>{let t=e.scrollTop,n=e.clientHeight,r=Math.floor(t/E),i=Math.ceil((t+n)/E),o=Math.max(0,r-5),s=Math.min(a,i+5);v(e=>e.start!==o||e.end!==s?{start:o,end:s}:e)};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[E,a,u]),h)return t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`});if(i||!r)return t(xm,{className:`py-4`,size:`md`});let D=_.start*E,O=(a-_.end)*E,k=y!==null;return t(`div`,{ref:x,children:t(Oi,{file:r,onLoadSuccess:C,onLoadError:S,loading:t(xm,{className:`py-4`,size:`md`}),children:k?n(e,{children:[D>0&&t(`div`,{style:{height:D}}),Array.from({length:_.end-_.start},(e,n)=>{let r=_.start+n+1;return t(`div`,{"data-page-index":r-1,style:{height:E,overflow:`hidden`},children:t(Om,{pageNumber:r,width:s,isSelected:r===o,onSelect:()=>c(r),renderThumbnail:l,aspectRatio:w})},r)}),O>0&&t(`div`,{style:{height:O}})]}):t(xm,{className:`py-4`,size:`md`})})})}function jm({pdfUrl:e,pageNumber:r,width:i,height:a,className:o,renderTextLayer:s=!1,renderAnnotationLayer:c=!1,onPageChange:l}){let[u,d]=Y(0),[f,p]=Y(!0),[m,h]=Y(null);return K(()=>{u>0&&l?.(r,u)},[r,u,l]),m?t(`div`,{className:`flex items-center justify-center text-destructive ${o||``}`,children:n(`span`,{children:[`Failed to load PDF: `,m.message]})}):n(`div`,{className:o,children:[f&&t(xm,{className:`py-8`,size:`lg`}),t(Oi,{file:e,onLoadSuccess:({numPages:e})=>{d(e),p(!1)},onLoadError:e=>{p(!1),h(e)},loading:null,children:t(ki,{pageNumber:Math.min(r,u||1),width:i,height:a,renderTextLayer:s,renderAnnotationLayer:c,loading:t(xm,{className:`py-8`,size:`md`})})})]})}const Mm=[50,75,100,125,150,200,300];function Nm({pdfUrl:r,pdfUrlLoading:i=!1,pageCount:a,currentPage:s,onChange:c,onPageCountChange:u,className:d,compact:f=!1,headerExtra:p}){let{t:m}=X(),h=J(null),g=J(null),[_,v]=Y(void 0),[y,b]=Y(100),[x,S]=Y(.7070707070707071),[C,w]=Y(null),T=J(null),E=_?Math.round(_*y/100):void 0,D=G(()=>{let e=Mm.findIndex(e=>e>=y);e===-1&&(e=Mm.length-1);let t=Math.min(e+1,Mm.length-1);b(Mm[t])},[y]),O=G(()=>{let e=Mm.findIndex(e=>e>=y);e===-1&&(e=Mm.length-1);let t=Math.max(e-1,0);b(Mm[t])},[y]),k=G(()=>{b(100)},[]),A=G(e=>e+(f?28:48),[f]),j=G((e,t)=>{let n=e?Math.round(e/t):200;return A(n)},[A]);K(()=>{let e=g.current;if(!e)return;let t=null,n=()=>e.clientWidth-16-16-4,r=()=>{let t=n();if(t<=0)return;let r=T.current;if(r&&r>0){let n=e.scrollTop,i=Math.round(n/r),a=j(t,x),o=i*a;v(t),requestAnimationFrame(()=>{e.scrollTo({top:o,behavior:`instant`})}),T.current=a}else v(t),T.current=j(t,x)},i=n();i>0&&(v(i),T.current=j(i,x));let a=new ResizeObserver(()=>{t&&clearTimeout(t),t=setTimeout(r,150)});return a.observe(e),()=>{t&&clearTimeout(t),a.disconnect()}},[x,j]);let M=J(!1),N=J(null),P=J(y);K(()=>{P.current!==y&&(P.current=y,N.current={targetPage:s},M.current=!0)},[y,s]),K(()=>{let e=g.current,t=N.current;if(t&&e&&C){N.current=null;let n=(t.targetPage-1)*C;requestAnimationFrame(()=>{e.scrollTo({top:n,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})})}},[C]);let F=J(!1);K(()=>{let e=g.current;if(!(!e||!C||F.current))if(s>1){F.current=!0,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}else F.current=!0},[C,s]);let I=J(s);return K(()=>{let e=g.current;if(!(!e||!C)&&I.current!==s){I.current=s,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}},[s,C]),K(()=>{let e=g.current;if(!e||!C)return;let t=null,n=()=>{M.current||(t&&clearTimeout(t),t=setTimeout(()=>{let t=e.scrollTop,n=Math.round(t/C)+1,r=Math.max(1,Math.min(n,a));r!==s&&(I.current=r,c(r))},50))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{t&&clearTimeout(t),e.removeEventListener(`scroll`,n)}},[C,a,s,c]),n(`div`,{ref:h,className:We(`flex flex-col items-stretch`,f?`gap-y-1`:`gap-y-2`,d),children:[n(`div`,{className:We(`relative flex items-center justify-center px-2`,f?`h-6`:`h-9`),children:[t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s>1&&c(s-1)},alt:m(`pdf.previousPage`),children:t(Dt,{className:`size-4`})}),n(`div`,{className:`absolute start-2 flex items-center gap-x-1`,children:[t(Fm,{zoom:y,onZoomIn:D,onZoomOut:O,onFitToView:k,canZoomIn:y<Mm[Mm.length-1],canZoomOut:y>Mm[0]}),p&&n(e,{children:[t(`div`,{className:`w-px h-4 bg-border mx-1`}),p]})]}),t(`div`,{className:`absolute end-2`,children:t(Pm,{currentPage:s,totalPages:a,onChange:c})})]}),t(`div`,{ref:g,className:We(`flex flex-col items-center flex-1 overflow-y-auto px-2`,f?`gap-1`:`gap-2`),children:t(Am,{pdfUrl:r,urlLoading:i,pageCount:a,currentPage:s,thumbnailWidth:E,onPageSelect:c,onPageCountChange:u,scrollContainerRef:g,onAspectRatioChange:S,onItemHeightChange:w,calculateItemHeight:A,renderThumbnail:({pageNumber:e,isSelected:r,pageElement:i,onSelect:a})=>n(`div`,{className:We(`hover:bg-muted rounded-md w-full`,f?`p-1`:`p-2`),children:[t(o,{variant:`unstyled`,size:`none`,"aria-pressed":r,"aria-label":`Page ${e}`,className:We(`relative border-[2px] cursor-pointer overflow-hidden`,r?`border-primary`:`border-border`),onClick:a,children:i}),t(l,{className:We(`text-muted-foreground font-semibold`,f?`text-xs pt-0.5`:`text-sm pt-1`),children:e})]},e)})}),t(`div`,{className:We(`flex items-center justify-center`,f?`h-6`:`h-9`),children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s<a&&c(s+1)},alt:m(`pdf.nextPage`),children:t(wt,{className:`size-4`})})})]})}function Pm({currentPage:e,totalPages:r,onChange:i}){let{t:a}=X(),o=J(null),[s,c]=Y(String(e));K(()=>{c(String(e))},[e]);let l=()=>{let t=parseInt(s,10);!Number.isNaN(t)&&t>=1&&t<=r?i(t):c(String(e))};return n(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[t(`span`,{children:a(`pdf.page`)}),t(`input`,{ref:o,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:t=>{t.key===`Enter`?(l(),o.current?.blur()):t.key===`Escape`&&(c(String(e)),o.current?.blur())},onBlur:()=>{l()},className:`w-8 h-5 text-center text-xs px-1 py-0 bg-background border border-border rounded focus:outline-none focus:border-primary`}),n(`span`,{children:[`/ `,r]})]})}function Fm({zoom:e,onZoomIn:r,onZoomOut:i,onFitToView:a,canZoomIn:s,canZoomOut:c}){let{t:l}=X();return n(`div`,{className:`flex items-center gap-x-0.5`,children:[t(o,{variant:`ghost`,size:`xs`,onClick:i,isDisabled:!c,alt:l(`pdf.zoomOut`),children:t(xn,{})}),n(`span`,{className:`text-xs text-muted-foreground min-w-[32px] text-center`,children:[e,`%`]}),t(o,{variant:`ghost`,size:`xs`,onClick:r,isDisabled:!s,alt:l(`pdf.zoomIn`),children:t(An,{})}),t(o,{variant:`ghost`,size:`xs`,onClick:a,alt:l(`pdf.fitToWidth`),className:e===100?`text-muted-foreground/40`:void 0,children:t(gn,{})})]})}function Im({object:e,url:r,source:i,className:a}){let{t:s}=X(),{client:c}=Z(),[l,u]=Y(1),[d,f]=Y(r||``),[p,m]=Y(!r),[h,g]=Y(0),[_,v]=Y(!1);K(()=>{if(r){f(r),m(!1);return}let t=i||e?.content?.source;if(!t){m(!1);return}m(!0),c.files.getDownloadUrl(t).then(e=>{f(e.url)}).catch(e=>{console.error(`Failed to get PDF URL:`,e)}).finally(()=>{m(!1)})},[r,i,e?.content?.source,c]),K(()=>{let t=e?.metadata,n=t?.pages||t?.page_count||0;n>0&&g(n)},[e?.metadata]);let y=e=>{g(e)};return p?t(`div`,{className:`flex items-center justify-center h-full`,children:t(be,{size:`lg`})}):d?_?n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col overflow-hidden`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>v(!1),alt:s(`pdf.closeFullscreen`),children:t(nr,{className:`size-4`})})}),t(Nm,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:`flex-1 min-h-0`})]}):t(`div`,{className:`relative h-full flex flex-col`,children:t(Nm,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:a,compact:!0,headerExtra:t(Me,{description:s(`pdf.fullscreen`),placement:`bottom`,size:`xs`,children:t(o,{variant:`unstyled`,className:`p-1 rounded cursor-pointer transition-colors text-muted-foreground hover:text-foreground hover:bg-muted`,onClick:()=>v(!0),"aria-label":s(`pdf.fullscreen`),children:t(_n,{className:`size-4`})})})})}):t(`div`,{className:`flex items-center justify-center h-full text-muted`,children:s(`pdf.noPdfAvailable`)})}function Lm(e){return e.fileName||e.title||e.artifact?.path.split(`/`).pop()||e.sourcePath?.split(`/`).pop()||`Document`}function Rm(e){let t=e.split(`?`)[0]||e;return t.includes(`.`)&&t.split(`.`).pop()?.toLowerCase()||``}function zm(e){return e.contentType===`application/pdf`||e.extension===`pdf`}function Bm(e){return[`md`,`markdown`].includes(e.extension)||[`text/markdown`,`text/x-markdown`].includes(e.contentType||``)}function Vm(e){return e.contentType?.startsWith(`image/`)||[`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`].includes(e.extension)}function Hm(e){return e.contentType===`text/html`||[`html`,`htm`].includes(e.extension)}function Um(e){return[`application/xml`,`text/xml`].includes(e.contentType||``)||e.extension===`xml`}function Wm(e){return e.contentType?.startsWith(`text/`)||[`css`,`csv`,`json`,`txt`,`tsx`,`ts`,`jsx`,`js`,`xml`,`yaml`,`yml`].includes(e.extension)}function Gm(e){return[`tsx`,`jsx`].includes(e.extension)}function Km(e){return[`doc`,`docx`,`ppt`,`pptx`].includes(e.extension)||[`application/msword`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.ms-powerpoint`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`].includes(e.contentType||``)}function qm({content:e,extension:n}){return t(`pre`,{className:`h-full overflow-auto rounded-md bg-muted/10 p-3 text-xs leading-5`,children:t(`code`,{className:n?`language-${n}`:void 0,children:e||``})})}function Jm({message:e}){return n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-muted`,children:[t(Gt,{className:`size-8`}),t(`span`,{className:`text-sm`,children:e})]})}function Ym(e,n){if(e.Component){let r=e.Component;return t(r,{context:n})}return e.render?.(n)??null}function Xm(e,t){return e.includes(`.`)?e.replace(/\.[^/.]+$/,t):`${e}${t}`}function Zm(e){return e.split(`/`).pop()||e}function Qm(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function $m(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function eh(e){if(e!==void 0)return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function th(e){return Array.isArray(e)?e.length:0}function nh(e){try{let t=Qm(JSON.parse(e));if(!t)return;let n=Qm(t.viewport);return{ok:typeof t.ok==`boolean`?t.ok:void 0,source_artifact:typeof t.source_artifact==`string`?t.source_artifact:void 0,screenshot_artifact:typeof t.screenshot_artifact==`string`?t.screenshot_artifact:void 0,rendered_at:typeof t.rendered_at==`string`?t.rendered_at:void 0,viewport:n?{width:$m(n.width),height:$m(n.height)}:void 0,dependencies_reused:typeof t.dependencies_reused==`boolean`?t.dependencies_reused:void 0,status:$m(t.status),title:typeof t.title==`string`?t.title:void 0,console_errors:Array.isArray(t.console_errors)?t.console_errors:void 0,page_errors:Array.isArray(t.page_errors)?t.page_errors:void 0,failed_requests:Array.isArray(t.failed_requests)?t.failed_requests:void 0,bad_responses:Array.isArray(t.bad_responses)?t.bad_responses:void 0,timings_ms:Qm(t.timings_ms),error:t.error}}catch{return}}async function rh(e,t){let n=await fetch(e);if(!n.ok)throw Error(`Failed to load ${t}: ${n.statusText}`);return n.text()}function ih({metadata:e,sourcePath:t,fallbackPath:n,artifactMode:r}){let i=e?.screenshot_artifact?.replace(/^\/+/,``);if(!i)return n;if(r)return i;let a=e?.source_artifact?.replace(/^\/+/,``),o=t.replace(/^\/+/,``);if(a&&o.endsWith(a)){let e=o.slice(0,-a.length).replace(/\/+$/,``);return e?`${e}/${i}`:i}let s=o.includes(`/`)?o.slice(0,o.lastIndexOf(`/`)+1):``;return s?`${s}${Zm(i)}`:n}function ah({metadata:e}){if(!e)return null;let r=$m(e.timings_ms?.total_before_cleanup),a=th(e.console_errors)+th(e.page_errors)+th(e.failed_requests)+th(e.bad_responses);return n(`div`,{className:`grid gap-2 border-b p-3 text-xs`,children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.ok!==void 0&&t(i,{variant:e.ok?`success`:`destructive`,children:e.ok?`render ok`:`render failed`}),e.dependencies_reused!==void 0&&n(i,{variant:e.dependencies_reused?`info`:`secondary`,children:[`deps `,e.dependencies_reused?`reused`:`installed`]}),e.status&&n(i,{variant:`secondary`,children:[`HTTP `,e.status]}),a>0&&n(i,{variant:`attention`,children:[a,` browser issue(s)`]})]}),n(`div`,{className:`grid gap-1 text-muted sm:grid-cols-2`,children:[e.viewport?.width&&e.viewport.height&&n(`div`,{children:[`Viewport `,e.viewport.width,` x `,e.viewport.height]}),eh(r)&&n(`div`,{children:[`Total `,eh(r)]}),e.rendered_at&&n(`div`,{children:[`Rendered `,new Date(e.rendered_at).toLocaleString()]}),e.title&&n(`div`,{className:`truncate`,children:[`Title `,e.title]})]}),typeof e.error==`string`&&t(`div`,{className:`text-destructive`,children:e.error})]})}function oh({context:e}){let{client:r}=Z(),a=e.source.artifact,o=a?.path||e.source.sourcePath,s=!!a,c=e.content||``,[l,u]=Y({isLoading:!1}),d=G(async(e,t)=>a?(await r.files.getArtifactDownloadUrl(a.runId,e,t)).url:(await r.files.getDownloadUrl(e,Zm(e),t)).url,[a,r]);return K(()=>{if(!o){u({isLoading:!1,previewError:`No source path is available for this TSX artifact.`});return}let e=o,t=!1,n=Xm(e,`.png`),r=Xm(e,`.render.json`);async function i(){u({isLoading:!0});let i,a,o=n;try{i=nh(await rh(await d(r,`inline`),Zm(r))),o=ih({metadata:i,sourcePath:e,fallbackPath:n,artifactMode:s})}catch(e){a=e instanceof Error?e.message:`Render metadata is not available`}let c,l;try{c=await d(o,`inline`)}catch(e){l=e instanceof Error?e.message:`Sandbox render image is not available`}t||u({isLoading:!1,imageUrl:c,metadata:i,metadataError:a,previewError:l})}return i(),()=>{t=!0}},[s,d,o]),n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 border-b px-3 py-2 text-sm`,children:[t(an,{className:`size-4 text-info`}),t(`span`,{className:`font-medium`,children:`Sandbox render`}),l.isLoading?t(i,{variant:`secondary`,children:`loading`}):l.imageUrl?t(i,{variant:`success`,children:`PNG preview`}):t(i,{variant:`attention`,children:`source only`}),l.metadata?.rendered_at&&t(`span`,{className:`text-xs text-muted`,children:new Date(l.metadata.rendered_at).toLocaleString()})]}),l.isLoading?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(hn,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading sandbox render...`})]}):l.imageUrl?n(`div`,{className:`grid min-h-0 flex-1 xl:grid-cols-[minmax(0,1fr)_minmax(24rem,0.7fr)]`,children:[t(`div`,{className:`flex min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:l.imageUrl,alt:`${e.fileName} sandbox render`,className:`max-h-full max-w-full rounded-md object-contain`})}),n(`div`,{className:`min-h-0 overflow-auto border-t xl:border-s xl:border-t-0`,children:[t(ah,{metadata:l.metadata}),t(`div`,{className:`p-3`,children:t(qm,{content:c,extension:e.extension})})]})]}):n(`div`,{className:`grid min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]`,children:[n(`div`,{className:`border-b px-3 py-2 text-xs text-muted`,children:[`No sandbox-rendered PNG was found for this TSX artifact. Showing the source without executing it in Studio.`,l.previewError&&n(`span`,{className:`ms-1`,children:[`Preview lookup: `,l.previewError]}),!l.previewError&&l.metadataError&&n(`span`,{className:`ms-1`,children:[`Metadata lookup: `,l.metadataError]})]}),n(`div`,{className:`min-h-0 overflow-auto p-3`,children:[t(ah,{metadata:l.metadata}),t(qm,{content:c,extension:e.extension})]})]})]})}function sh({source:e,className:r,bodyClassName:i,renderers:a=[],converters:s=[],resolveUrl:c,loadText:l,createRendition:u,markdownComponents:d,showHeader:f=!0,onDownload:p}){let{client:m}=Z(),h=q(()=>Lm(e),[e]),g=q(()=>Rm(h),[h]),[_,v]=Y(e.url),[y,b]=Y(e.content),[x,S]=Y(null),[C,w]=Y(!1),[T,E]=Y(null),[D,O]=Y(0),k=[e.id,e.title,e.fileName,e.contentType,e.url,e.sourcePath,e.content,e.artifact?.runId,e.artifact?.path].join(`\0`),A=G(async(e,t)=>e.url?e.url:e.artifact?(await m.files.getArtifactDownloadUrl(e.artifact.runId,e.artifact.path,t)).url:e.sourcePath?(await m.files.getDownloadUrl(e.sourcePath,e.fileName,t)).url:``,[m]),j=c||A,M=G(async e=>{if(e.content!==void 0)return e.content;let t=await j(e,`inline`);if(!t)return``;let n=await fetch(t);if(!n.ok)throw Error(`Failed to load ${Lm(e)}: ${n.statusText}`);return n.text()},[j]),N=l||M,P={source:e,fileName:h,extension:g,contentType:e.contentType||x?.contentType,url:x?.url||_,content:x?.content||y,isLoading:C,error:T,reload:()=>O(e=>e+1)},F=a.find(e=>e.canRender(P)),I=!F&&(Bm(P)||Hm(P)||Um(P)||Wm(P)),L=!F&&(zm(P)||Vm(P)),R={source:e,fileName:h,extension:g,contentType:e.contentType,target:`pdf`},z=!F&&!P.url?s.find(e=>e.target===`pdf`&&e.canConvert(R)):void 0,ee=!F&&!P.url&&(Km(P)||!!z)&&(!!z||!!u);K(()=>{let t=!1,n=e;E(null),v(n.url),b(n.content),S(null);async function r(){if(!(!I&&!L&&!ee)){w(!0);try{if(ee){let e=z?await z.convert({source:n,fileName:h,extension:g,contentType:n.contentType,target:`pdf`}):await u?.(n,`pdf`);t||S(e??null);return}if(I){let e=await N(n);t||b(e);return}if(L){let e=await j(n,`inline`);t||v(e)}}catch(e){t||E(e instanceof Error?e.message:`Failed to load document`)}finally{t||w(!1)}}}return r(),()=>{t=!0}},[u,g,h,N,ee,I,L,D,j,z,e,k]);let B={...P,url:x?.url||_,content:x?.content||y,contentType:x?.contentType||e.contentType,isLoading:C,error:T},te;return te=C?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(hn,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading preview...`})]}):T?n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-destructive`,children:[t(ot,{className:`size-7`}),t(`span`,{className:`max-w-xl text-center text-sm`,children:T}),t(o,{variant:`outline`,size:`sm`,onClick:B.reload,children:`Retry`})]}):F?Ym(F,B):(zm(B)||x?.contentType===`application/pdf`)&&B.url?t(Im,{url:B.url,className:`h-full`}):Vm(B)&&B.url?t(`div`,{className:`flex h-full min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:B.url,alt:h,className:`max-h-full max-w-full rounded-md object-contain`})}):Bm(B)?t(`div`,{className:`prose prose-sm dark:prose-invert max-w-none px-5 py-4`,children:t(yi,{artifactRunId:e.artifact?.runId,components:d,children:B.content||``})}):Hm(B)?t(`iframe`,{title:h,className:`h-full min-h-96 w-full bg-white`,sandbox:``,srcDoc:B.content||``}):Um(B)?t(`div`,{className:`px-4 py-2`,children:t(wi,{xml:B.content||``,collapsible:!0})}):Gm(B)?t(oh,{context:B}):Wm(B)?t(qm,{content:B.content,extension:g}):Km(B)&&!z&&!u?t(Jm,{message:`This file needs a PDF rendition before it can be previewed.`}):t(Jm,{message:`Preview is not available for this file type.`}),n(`div`,{className:H(`flex h-full min-h-0 flex-col overflow-hidden`,r),children:[f&&n(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b py-2 ps-3 pe-16`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,title:h,children:h}),B.contentType&&t(`div`,{className:`truncate text-xs text-muted`,children:B.contentType})]}),p&&t(o,{variant:`outline`,size:`sm`,onClick:()=>p(e),children:`Download`})]}),t(`div`,{className:H(`min-h-0 flex-1 overflow-auto`,i),children:te})]})}const ch=/(^|\/)(tool-inputs|tool-results|archive)(\/|$)/,lh=/(^|\/)process\/(history|state)(\/|$)/,uh=[/conversation\.json$/,/^conversation-checkpoint-\d+\.json$/,/^tools\.json$/,/^tool-input-refs\.json$/,/^toolu[_-]/i];function dh(e){if(ch.test(e)||lh.test(e))return!0;let t=e.split(`/`).pop()??e;return uh.some(e=>e.test(t))}function fh(e){let t={name:``,path:``,isDirectory:!0,children:[]};for(let n of e){let e=n.split(`/`),r=t,i=``;for(let t=0;t<e.length;t++){let n=e[t];i=i?`${i}/${n}`:n;let a=t===e.length-1,o=r.children.find(e=>e.name===n);o||(o={name:n,path:i,isDirectory:!a,children:[]},r.children.push(o)),r=o}}let n=e=>{e.children.sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1),e.children.forEach(n)};return n(t),t.children}function ph(e,t){let n=`agents/${t}/`,r=e.indexOf(n);return r===-1?e.split(`/`).pop()??e:e.slice(r+n.length)}function mh(e,t,n=0,r=!1){let[i,a]=Y([]),[o,s]=Y(!1),[c,l]=Y(null),[u,d]=Y(0),f=J(0),p=G(async()=>{if(!t)return;let n=++f.current;s(!0),l(null);try{let r=await e.files.listArtifacts(t);if(n!==f.current)return;let i=r.map(e=>ph(e,t)).filter(e=>!!e);a(i)}catch(e){if(n!==f.current)return;l(e instanceof Error?e.message:`Failed to list artifacts`),a([])}finally{n===f.current&&s(!1)}},[e,t]);K(()=>{p()},[p,n,u]);let m=q(()=>r?i:i.filter(e=>!dh(e)),[i,r]),h=q(()=>fh(m),[m]),g=i.length-m.length,_=G(()=>{d(e=>e+1)},[]);return{tree:h,flatFiles:m,totalCount:i.length,systemHiddenCount:g,isLoading:o,error:c,refresh:_}}function hh(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function gh({node:e,depth:r,runId:i,onPreview:a,onDownload:s,downloadingPath:c,forceExpanded:l=!1}){let[u,d]=Y(!1),f=l||u;if(e.isDirectory)return n(`div`,{className:`min-w-0`,children:[n(o,{variant:`unstyled`,className:`flex w-full max-w-full items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>d(e=>!e),"aria-expanded":f,children:[f?t(bt,{className:`size-3.5 shrink-0 text-muted`}):t(Ct,{className:`size-3.5 shrink-0 text-muted cn-rtl-flip`}),t(f?Qt:Zt,{className:`size-4 shrink-0 text-info`}),t(`span`,{className:`min-w-0 truncate font-medium`,title:e.path,children:hh(e.name)})]}),f&&e.children.map(e=>t(gh,{node:e,depth:r+1,runId:i,onPreview:a,onDownload:s,downloadingPath:c,forceExpanded:l},`${i}:${e.path}`))]});let p=c===e.path;return n(`div`,{className:`group flex min-w-0 items-center gap-1.5 rounded text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 px-1 py-1 text-start`,onClick:()=>a(e.path),title:e.path,children:[t(`span`,{className:`size-3.5 shrink-0`}),t(Gt,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.name})]}),n(`div`,{className:`flex shrink-0 items-center pe-1 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[t(o,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,onClick:()=>a(e.path),"aria-label":`Preview artifact`,children:t(Wt,{className:`size-3.5`})}),t(o,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,onClick:()=>s(e.path),disabled:p,"aria-label":`Download artifact`,children:p?t(hn,{className:`size-3.5 animate-spin text-info`}):t(zt,{className:`size-3.5`})})]})]})}function _h(e){return e.reduce((e,t)=>t.isDirectory?e+_h(t.children):e+1,0)}function vh(e,t){let n=t.trim().toLocaleLowerCase();return n?e.flatMap(e=>{let t=`${e.name} ${e.path}`.toLocaleLowerCase().includes(n);if(!e.isDirectory)return t?[e]:[];let r=vh(e.children,n);return t?[{...e}]:r.length>0?[{...e,children:r}]:[]}):e}function yh(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function bh(e){switch(e.split(`.`).pop()?.toLowerCase()){case`css`:return`text/css`;case`gif`:return`image/gif`;case`htm`:case`html`:return`text/html`;case`jpeg`:case`jpg`:return`image/jpeg`;case`json`:return`application/json`;case`md`:case`markdown`:return`text/markdown`;case`pdf`:return`application/pdf`;case`png`:return`image/png`;case`svg`:return`image/svg+xml`;case`ts`:case`tsx`:return`text/typescript`;case`txt`:return`text/plain`;case`webp`:return`image/webp`;default:return}}function xh({icon:e,children:r,action:i}){return n(l,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r}),i]})}function Sh({runId:r,refreshKey:i=0}){let{t:a}=X(),{client:s}=Z(),[c,l]=Y(!1),{tree:u,flatFiles:d,totalCount:f,systemHiddenCount:p,isLoading:m,error:h,refresh:g}=mh(s,r,i,c),[_,v]=Y(null),[y,b]=Y(null),[x,S]=Y(``),C=x.trim(),w=q(()=>vh(u,C),[u,C]),T=q(()=>_h(w),[w]),E=$e(),D=G(async e=>{if(r){v(e);try{let{url:t}=await s.files.getArtifactDownloadUrl(r,e,`attachment`);yh(t,e.split(`/`).pop()||`artifact`)}catch(e){console.error(`Failed to get artifact download URL:`,e)}finally{v(null)}}},[s,r]),k=G(e=>{b(e)},[]),A=r&&y?{title:y.split(`/`).pop()||y,fileName:y.split(`/`).pop()||y,contentType:bh(y),artifact:{runId:r,path:y}}:null;return r?m&&f===0?t(xh,{icon:t(hn,{className:`mb-2 size-6 animate-spin`}),children:a(`agent.loadingArtifacts`)}):h?t(`div`,{className:`flex flex-col items-center justify-center p-4 text-muted w-full`,children:n(O,{title:`Fail to load Artifacts`,className:`w-full`,action:g,actionLabel:n(e,{children:[t(Fn,{className:`size-3.5 me-1.5`}),a(`agent.retry`)]}),children:[t(`span`,{className:`break-all text-muted`,children:h}),` `,t(`br`,{})]})}):f===0?t(xh,{icon:t(Tn,{className:`mb-2 size-8`}),action:n(o,{variant:`ghost`,size:`sm`,className:`mt-2`,onClick:g,children:[t(Fn,{className:`size-3.5 me-1.5`}),a(`agent.refresh`)]}),children:a(`agent.noArtifactsYet`)}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[n(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted`,children:[n(`span`,{children:[C?`${T} of ${d.length} file${d.length===1?``:`s`}`:`${d.length} file${d.length===1?``:`s`}`,!c&&p>0?` · ${p} hidden`:``]}),n(`div`,{className:`flex items-center gap-1`,children:[t(Se,{size:`sm`,value:c,onChange:l,children:t(`span`,{className:`text-xs text-muted`,children:a(`agent.showSystemArtifacts`)})}),t(o,{variant:`ghost`,size:`sm`,onClick:g,disabled:m,className:`h-6 w-6 p-0`,children:t(Fn,{className:`size-3.5 ${m?`animate-spin`:``}`})})]})]}),t(`label`,{htmlFor:E,className:`sr-only`,children:a(`form.filter`)}),t(F,{id:E,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:a(`store.searchPlaceholder`),value:x,onChange:S,clearable:!0})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:w.length>0?t(`div`,{className:`min-w-0`,children:w.map(e=>t(gh,{node:e,depth:0,runId:r,onPreview:k,onDownload:D,downloadingPath:_,forceExpanded:!!C},`${r}:${e.path}`))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:a(!c&&p>0?`agent.onlySystemArtifacts`:`agent.noContentAvailable`)})}),A&&n(B,{isOpen:!!y,onClose:()=>b(null),size:`xl`,className:`h-[90vh] p-0`,description:`Artifact preview`,children:[t(re,{show:!1,children:A.fileName}),t(te,{className:`h-full max-h-none p-0`,children:t(sh,{source:A,className:`h-full`,onDownload:()=>y&&void D(y)})})]})]}):t(xh,{icon:t(Tn,{className:`mb-2 size-8`}),children:`No run selected`})}const Ch=W.memo(Sh);function wh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Th(e){if(!wh(e))return;let t=e.browseruse??e.browser_use;if(!wh(t))return;let n={widget:typeof t.widget==`string`?t.widget:void 0,browser_workflow_id:typeof t.browser_workflow_id==`string`?t.browser_workflow_id:void 0,workstream_id:typeof t.workstream_id==`string`?t.workstream_id:void 0,phase:typeof t.phase==`string`?t.phase:void 0,url:typeof t.url==`string`?t.url:void 0,title:typeof t.title==`string`?t.title:void 0,screenshot:typeof t.screenshot==`string`?t.screenshot:void 0,raw_screenshot:typeof t.raw_screenshot==`string`?t.raw_screenshot:void 0,prefer_raw_screenshot:typeof t.prefer_raw_screenshot==`boolean`?t.prefer_raw_screenshot:void 0,updated_at:typeof t.updated_at==`number`?t.updated_at:void 0};if(!(n.widget&&n.widget!==`browseruse`)&&!(!n.url&&!n.title&&!n.screenshot&&!n.raw_screenshot))return n}function Eh(e){let t=new Map;for(let n of e){let e=Th(n.details);if(!e)continue;let r=e.workstream_id||n.workstream_id||`main`,i=e.updated_at??(typeof n.timestamp==`number`?n.timestamp:new Date(n.timestamp).getTime()),a=t.get(r);(!a||i>=a.timestamp)&&t.set(r,{state:{...e,workstream_id:r},timestamp:i})}return new Map(Array.from(t.entries()).map(([e,t])=>[e,t.state]))}function Dh(e){return e.replace(/^artifact:\/\//,``).replace(/^artifact:/,``).replace(/^\/+/,``)}function Oh(e){return e?e.replace(/_/g,` `):`browser`}function kh({state:e,runId:r,className:a,compact:o}){let{t:s}=X(),{client:c}=Z(),l=ta(),{openImage:u}=gu(),[d,f]=Y(),p=e.prefer_raw_screenshot===!1?e.screenshot||e.raw_screenshot:e.raw_screenshot||e.screenshot,m=e.title||e.url||s(`agent.browserUse`),h=q(()=>p&&Dh(p).split(`/`).pop()||s(`agent.browserScreenshot`),[p,s]);return K(()=>{if(!p){f(void 0);return}if(p.startsWith(`http://`)||p.startsWith(`https://`)){f(p);return}if(!r){f(void 0);return}let e=!1;return(async()=>{let t=Dh(p);try{let n=ra(r,t,`inline`),i=l?await l.getOrFetch(n,async()=>(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url):(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url;e||f(i)}catch(n){console.error(`Failed to resolve browser screenshot ${t}`,n),e||f(void 0)}})(),()=>{e=!0}},[c,r,p,l]),o?n(`div`,{className:H(`overflow-hidden rounded-md border border-border/70 bg-transparent`,a),children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[t(Sn,{className:`size-3.5 shrink-0 text-info`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserPreview`)}),e.phase&&n(`span`,{className:`truncate text-[11px] capitalize text-muted`,children:[`· `,Oh(e.phase)]})]}),t(`div`,{className:`truncate text-[11px] text-muted`,title:m,children:m})]}),e.url&&t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:H(`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Ht,{className:`size-3`})})]}),p&&(d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-32 w-full object-contain`})}):n(`div`,{className:`flex min-h-16 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-4 text-xs text-muted`,children:[t(an,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}))]}):n(`div`,{className:H(`overflow-hidden rounded-md border border-muted bg-mixer-muted/10`,a),children:[n(`div`,{className:`flex items-start justify-between gap-2 border-b border-muted px-2.5 py-2`,children:[n(`div`,{className:`flex min-w-0 items-start gap-2`,children:[t(Sn,{className:`mt-0.5 size-4 shrink-0 text-info`}),n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserUse`)}),t(`div`,{className:`truncate text-xs text-muted`,title:m,children:m})]})]}),t(i,{variant:`info`,className:`shrink-0 capitalize`,children:Oh(e.phase)})]}),d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-56 w-full object-contain`})}):n(`div`,{className:`flex min-h-28 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-6 text-xs text-muted`,children:[t(an,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}),e.url&&n(`div`,{className:`flex items-center gap-2 border-t border-muted px-2.5 py-1.5`,children:[t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 truncate text-xs text-info hover:underline`,title:e.url,children:e.url}),t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:H(`inline-flex h-6 shrink-0 items-center justify-center rounded-md px-1.5`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Ht,{className:`size-3`})})]})]})}function Ah({documents:e,activeId:n,onSelect:r}){return e.length===0?null:t(`div`,{className:`flex items-center gap-1 px-2 py-1.5`,children:t(b,{align:`right`,trigger:t(o,{variant:`ghost`,size:`xs`,title:`All opened documents`,className:`flex items-center gap-1.5 max-w-[220px] text-xs h-7 px-2`,children:t(bt,{className:`size-3 shrink-0`})}),children:e.map(e=>t(z,{onClick:()=>r(e.id),className:e.id===n?`font-medium`:``,children:t(`span`,{className:`truncate max-w-[200px]`,children:e.title})},e.id))})})}function jh({isOpen:e,documents:r,activeDocumentId:i,onSelectDocument:a,onCloseDocument:s,onUpdateDocumentTitle:c,refreshKey:l,runId:u}){let{client:d}=Z(),{t:f}=X(),[p,m]=Y(null),[h,g]=Y(!1),[_,v]=Y(null),[y,b]=Y(null),x=G(async e=>{g(!0),v(null);try{let[t,n]=await Promise.all([d.store.objects.getObjectText(e),d.store.objects.retrieve(e)]);m(t.text??null);let r=n.name;b(r),r&&c?.(e,r)}catch(e){let t=e instanceof Error?e.message:f(`agent.failedToLoadDocument`);v(t),m(null)}finally{g(!1)}},[d,c,f]);return K(()=>{i&&e&&x(i)},[i,l,e,x]),!e||r.length===0?null:n(`div`,{className:`h-full shadow-xl border border-muted/20 overflow-hidden flex flex-col`,children:[n(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-muted/20 shrink-0`,children:[n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(Jt,{className:`size-4 text-muted shrink-0`}),t(`h3`,{className:`font-bold text-sm truncate`,children:y||f(`agent.document`)})]}),n(`div`,{className:`flex items-center gap-1`,children:[t(Ah,{documents:r,activeId:i,onSelect:a}),i&&t(ci,{href:`/store/objects/${i}#overview`,topLevelNav:!0,className:`inline-flex items-center justify-center rounded-md text-sm font-medium h-8 w-8 hover:bg-muted/20 text-muted hover:text-foreground`,children:t(Me,{description:f(`agent.openDocument`),placement:`top`,size:`xs`,children:t(Ht,{className:`size-4`})})}),t(o,{variant:`ghost`,size:`sm`,onClick:()=>i&&s(i),title:f(`agent.close`),children:t(nr,{className:`size-4`})})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:h?n(`div`,{className:`flex items-center justify-center py-12`,children:[t(hn,{className:`size-5 animate-spin text-muted`}),t(`span`,{className:`ms-2 text-sm text-muted`,children:f(`agent.loadingDocument`)})]}):_?t(`div`,{className:`p-4 rounded-md bg-destructive/10 text-destructive text-sm`,children:_}):p?t(`div`,{className:`prose prose-sm dark:prose-invert max-w-none`,children:t(yi,{artifactRunId:u,children:p})}):n(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted`,children:[t(Jt,{className:`size-8 mb-2`}),t(`span`,{className:`text-sm`,children:f(`agent.noContentAvailable`)})]})})]})}const Mh=W.memo(jh);function Nh({plan:e,workstreamStatus:r,isOpen:i,onClose:a,plans:s=[],activePlanIndex:c=0,onChangePlan:u=()=>{}}){let{t:d}=X();if(!i)return null;let f=e.plan||[],p=f.length,m=f.reduce((e,t)=>t?.id&&(r.get(t.id.toString())===`completed`||t.status===`completed`)?e+1:e,0),h=p>0?Math.round(m/p*100):0,g=s.length>0?s.length-c:1,_=s[c]?.timestamp;return f.length===0?t(`div`,{className:`h-full overflow-hidden`,children:n(l,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[t(jt,{className:`mb-2 size-8`}),t(`span`,{className:`text-sm`,children:d(`agent.noPlanAvailable`)})]})}):t(`div`,{className:`h-full overflow-hidden`,children:n(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto px-2 py-3`,children:[n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex items-start justify-between gap-3`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-sm font-medium text-foreground`,children:d(`agent.taskProgress`)}),t(`div`,{className:`text-xs text-muted`,children:d(`agent.tasksCompleted`,{completed:m,total:p})})]}),s.length>1&&n(`div`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted`,children:[t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>u(Math.min(s.length-1,c+1)),disabled:c>=s.length-1,"aria-label":d(`agent.olderPlan`),title:d(`agent.olderPlan`),children:t(xt,{className:`size-4`,"aria-hidden":`true`})}),n(`div`,{className:`min-w-20 text-center`,children:[n(`div`,{className:`font-medium text-foreground`,children:[g,`/`,s.length]}),t(`div`,{className:`truncate`,children:_?new Date(_).toLocaleTimeString():d(`agent.unknownTime`)})]}),t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>u(Math.max(0,c-1)),disabled:c<=0,"aria-label":d(`agent.newerPlan`),title:d(`agent.newerPlan`),children:t(St,{className:`size-4`,"aria-hidden":`true`})})]})]}),t(`div`,{className:`h-2 overflow-hidden rounded-full bg-mixer-muted/20`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":p,"aria-valuenow":m,"aria-label":d(`agent.taskProgress`),children:t(`div`,{className:`h-full rounded-full bg-success transition-all duration-300`,style:{width:`${h}%`}})})]}),t(`ol`,{className:`divide-y divide-border/60`,children:f.map((e,i)=>{let a=e.id?e.id.toString():`task-${i}`,o=e.goal||`Task ${i+1}`,s=e.id?`task-${e.id.toString()}`:`task-${o}-${e.status||`pending`}`,c=e.status||`pending`,l=r.get(a);l!==void 0&&(c=l);let u=kt,f=`text-muted`;c===`in_progress`?(u=Mt,f=`text-info`):c===`completed`&&(u=ht,f=`text-success`);let p=d(c===`completed`?`agent.completed`:c===`in_progress`?`agent.inProgress`:`agent.pending`);return n(`li`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-3 px-1 py-3`,children:[t(`span`,{className:`mt-0.5 min-w-5 text-center text-xs font-medium tabular-nums text-muted/80`,children:a}),t(`span`,{className:`min-w-0 text-sm leading-5 text-foreground/85`,children:o}),n(`span`,{className:H(`flex items-center gap-1.5 text-xs font-medium`,f),children:[t(u,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t(`span`,{children:p})]})]},s)})}),(()=>{let e=new Set(f.filter(e=>e?.id).map(e=>e.id.toString())),i=Array.from(r.entries()).filter(([t])=>t!==`main`&&!e.has(t));return i.length>0?n(`div`,{className:`mt-1 px-1 py-2`,children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:d(`agent.workstreams`)}),t(`div`,{className:`divide-y divide-border/60`,children:i.map(([e,r])=>{let i=kt,a=`text-muted`,o=d(`agent.pending`);return r===`in_progress`?(i=Mt,a=`text-info`,o=d(`agent.inProgress`)):r===`completed`&&(i=ht,a=`text-success`,o=d(`agent.completed`)),n(`div`,{className:`flex items-center gap-2 py-2`,children:[t(i,{className:H(`size-3.5 shrink-0`,a)}),t(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground/80`,children:e}),t(`span`,{className:`text-xs font-medium text-muted`,children:o})]},e)})})]}):null})()]})})}const Ph=W.memo(Nh);function Fh({icon:e,children:r}){return n(l,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r})]})}function Ih({files:e}){let{t:r}=X(),a=q(()=>e?Array.from(e.values()):[],[e]),o=e=>{switch(e){case hr.UPLOADING:case hr.PROCESSING:return t(hn,{className:`size-4 animate-spin text-info`});case hr.READY:return t(_t,{className:`size-4 text-success`});case hr.ERROR:return t(ir,{className:`size-4 text-destructive`});default:return t(Jt,{className:`size-4 text-muted`})}},s=e=>{switch(e){case hr.UPLOADING:return t(i,{variant:`info`,children:r(`agent.uploading`)});case hr.PROCESSING:return t(i,{variant:`info`,children:r(`agent.processing`)});case hr.READY:return t(i,{variant:`success`,children:r(`agent.ready`)});case hr.ERROR:return t(i,{variant:`destructive`,children:r(`agent.error`)});default:return null}};return t(`div`,{className:`h-full min-h-0`,children:a.length===0?t(Fh,{icon:t(Jt,{className:`mb-2 size-8`}),children:r(`agent.noFilesUploadedYet`)}):t(`div`,{className:`space-y-2 p-2`,children:a.map(e=>n(`div`,{className:`flex items-start gap-2 p-2 border border-muted rounded-md`,children:[t(`div`,{className:`mt-0.5`,children:o(e.status)}),n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`span`,{className:`text-sm font-medium truncate`,children:e.name}),s(e.status)]}),e.error&&t(`div`,{className:`text-xs text-destructive mt-1`,children:e.error})]})]},e.id))})})}var Lh=class extends W.Component{state={hasError:!1};static getDerivedStateFromError(e){return{hasError:!0,message:e instanceof Error?e.message:String(e)}}componentDidCatch(e,t){console.error(`Agent right panel section failed to render`,{error:e,componentStack:t.componentStack})}render(){return this.state.hasError?n(`div`,{className:H(`rounded-md border border-destructive bg-mixer-destructive/10 text-destructive`,this.props.compact?`p-2 text-xs`:`m-3 p-3 text-sm`),children:[t(`div`,{className:`font-medium`,children:this.props.title}),t(`div`,{className:`mt-1 text-xs text-muted`,children:this.props.description}),this.state.message&&t(`div`,{className:`mt-1 break-all text-[11px] text-muted`,children:this.state.message})]}):this.props.children}};function Rh({workstreams:e,messages:r,runId:a}){let{t:s}=X(),{client:c}=Z(),l=He(),u=q(()=>Eh(r),[r]),d=s(`agent.panelRenderErrorDescription`),f=G(e=>{navigator.clipboard.writeText(e),l({status:`success`,title:s(`agent.runIdCopied`),duration:2e3})},[s,l]),p=G(async e=>{try{let t=await Sl(c,e);t&&window.open(t,`_blank`)}catch{l({status:`error`,title:s(`agent.failedToDownload`)})}},[c,s,l]);return e.length===0?t(Fh,{icon:t(un,{className:`mb-2 size-8`}),children:s(`agent.noActiveParallelTasks`)}):n(`div`,{className:`h-full min-h-0 overflow-y-auto px-2 py-2`,children:[t(`div`,{className:`px-1 pb-2 text-xs text-muted`,children:s(`agent.parallelWorkDescription`)}),t(`div`,{className:`divide-y divide-border/60`,children:e.map(e=>{let r=e.status===`running`||e.status===`canceling`,c=Math.round(e.elapsed_ms/1e3),l=Math.max(0,Math.round(e.remaining_ms/1e3)),m=e.deadline_ms>0?Math.min(100,Math.round(e.elapsed_ms/e.deadline_ms*100)):0,h=u.get(e.workstream_id),g=e.deadline_ms>0,_=e.child_workflow_run_id,v=[e.phase?Qc(e.phase):void 0,c>0?s(`agent.elapsed`,{seconds:c}):void 0,g&&l>0?s(`agent.remaining`,{seconds:l}):void 0].filter(Boolean),y=(()=>{switch(e.status){case`running`:return t(i,{variant:`info`,children:s(`agent.running`)});case`canceling`:return t(i,{variant:`attention`,children:s(`agent.canceling`)});case`completed`:return t(i,{variant:`done`,children:s(`agent.completed`)});case`failed`:return t(i,{variant:`destructive`,children:s(`agent.failed`)});case`timeout`:return t(i,{variant:`destructive`,children:s(`agent.timeout`)});case`canceled`:return t(i,{variant:`destructive`,children:s(`agent.canceled`)})}})();return t(Lh,{title:s(`agent.workstreamRenderError`),description:d,compact:!0,children:t(`div`,{className:`py-3`,children:n(`div`,{className:`flex items-start gap-2`,children:[t(`span`,{className:H(`mt-2 size-2 shrink-0 rounded-full`,ol(e.status)),"aria-hidden":`true`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[t(`span`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,title:e.workstream_id,children:Qc(e.workstream_id)}),y]}),v.length>0&&t(`div`,{className:`mt-0.5 truncate text-xs text-muted`,children:v.join(` · `)}),r&&g&&t(`div`,{className:`mt-2 h-1 rounded-full bg-muted`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m,"aria-valuetext":s(`agent.workstreamProgress`,{percent:m}),children:t(`div`,{className:`h-full rounded-full bg-info transition-all duration-500`,style:{width:`${m}%`}})}),h&&t(Lh,{title:s(`agent.browserWidgetRenderError`),description:d,compact:!0,children:t(kh,{state:h,runId:a,compact:!0,className:`mt-2`})}),_&&n(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>f(_),children:[t(At,{className:`size-3 me-1`}),s(`agent.copyRunId`)]}),n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>p(_),children:[t(Rt,{className:`size-3 me-1`}),s(`agent.download`)]})]})]})]})})},e.launch_id)})})]})}const zh=`flex items-center border-b-2 px-2 py-1.5 text-sm font-medium whitespace-nowrap cursor-pointer shrink-0`,Bh=`border-transparent text-muted-foreground hover:border-border hover:text-foreground`,Vh=`border-primary text-primary`;function Hh({tabs:e,current:r,onTabChange:i,label:a,active:o}){let[s,c]=Y(!1),l=J(null),u=J(!1),d=()=>{l.current&&=(clearTimeout(l.current),null)},f=()=>{d(),u.current=!0,c(!0)},p=()=>{d(),l.current=setTimeout(()=>c(!1),150)};return K(()=>()=>clearTimeout(l.current??void 0),[]),n(x,{modal:!1,open:s,onOpenChange:e=>{d(),e&&(u.current=!1),c(e)},children:[t(E,{asChild:!0,children:n(`button`,{type:`button`,onMouseEnter:f,onMouseLeave:p,className:H(zh,o?Vh:Bh),children:[a,t(bt,{className:`ms-1 size-4`})]})}),t(S,{align:`end`,className:`w-max`,onMouseEnter:d,onMouseLeave:p,onCloseAutoFocus:e=>{u.current&&e.preventDefault()},children:e.map(e=>t(C,{disabled:e.disabled,onClick:()=>i(e.name),className:H(e.name===r&&`text-primary`),children:e.label},e.name))})]})}function Uh({tabs:e,current:r,onTabChange:i,className:a}){let{t:o}=X(),s=J(null),c=J([]),l=J(null),[u,d]=Y({count:e.length,promote:!1}),f=()=>{let t=s.current;if(!t)return;let n=t.clientWidth,i=e.map((e,t)=>c.current[t]?.offsetWidth??0),a=i.reduce((e,t)=>e+t,0)+4*Math.max(0,e.length-1),o=(t,n)=>{let r=0,a=0;for(let o=0;o<e.length;o++){if(o===n)continue;let e=r+(a>0?4:0)+i[o];if(e>t)break;r=e,a+=1}return a},u;if(a<=n)u={count:e.length,promote:!1};else{let t=l.current?.offsetWidth??0,a=Math.max(1,o(n-t-4,-1)),s=e.findIndex(e=>e.name===r);u=s<0||s<a?{count:a,promote:!1}:{count:o(n-t-i[s]-8,s),promote:!0}}d(e=>e.count===u.count&&e.promote===u.promote?e:u)},p=J(f);p.current=f,et(()=>{p.current()}),K(()=>{let e=s.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>p.current());return t.observe(e),()=>t.disconnect()},[]);let m=e.findIndex(e=>e.name===r),h,g;if(u.promote&&m>=0){let t=e.filter((e,t)=>t!==m);h=[...t.slice(0,u.count),e[m]],g=t.slice(u.count)}else h=e.slice(0,u.count),g=e.slice(u.count);let _=g.some(e=>e.name===r),v=o(`agent.moreTabs`);return n(`div`,{ref:s,className:H(`relative`,a),children:[n(`div`,{"aria-hidden":!0,className:`pointer-events-none invisible absolute start-0 top-0 flex w-max gap-1`,children:[e.map((e,n)=>t(`button`,{type:`button`,tabIndex:-1,ref:e=>{c.current[n]=e},className:H(zh,Bh),children:e.label},e.name)),n(`button`,{type:`button`,tabIndex:-1,ref:l,className:H(zh,Bh),children:[v,t(bt,{className:`ms-1 size-4`})]})]}),n(`div`,{className:`-mb-px flex gap-1 overflow-hidden border-b`,children:[h.map(e=>{let n=e.name===r;return t(`button`,{type:`button`,"aria-current":n?`page`:void 0,disabled:e.disabled,onClick:()=>i(e.name),className:H(zh,n?Vh:Bh,`disabled:pointer-events-none disabled:opacity-50`),children:e.label},e.name)}),g.length>0&&t(Hh,{tabs:g,current:r,onTabChange:i,label:v,active:_})]})]})}function Wh({plan:e,workstreamStatus:r,plans:i=[],activePlanIndex:a=0,onChangePlan:s,activeWorkstreams:c=[],messages:l=[],hideWorkstreams:u=!1,openDocuments:d=[],activeDocumentId:f,onSelectDocument:p,onCloseDocument:m,onUpdateDocumentTitle:h,docRefreshKey:g=0,runId:_,processingFiles:v,showArtifacts:y=!1,artifactRefreshKey:b=0,payloadContent:x,conversationContent:S,onClose:C,defaultTab:w,activeTab:T,onTabChange:E}){let{t:D}=X(),[O,k]=Y(w||`plan`),A=T??O,j=e=>{k(e),E?.(e)},M=!u&&c.length>0,N=d.length>0,P=v?v.size>0:!1,F=G((e,n)=>t(Lh,{title:D(`agent.panelRenderError`,{name:e}),description:D(`agent.panelRenderErrorDescription`),children:n}),[D]),I={name:`conversation`,label:`Conversation`,content:S?F(`Conversation`,t(`div`,{className:`flex flex-col h-full min-h-0`,children:S})):null,is_allowed:!!S},L=[...S?[I]:[],{name:`plan`,label:D(`agent.plan`),content:F(D(`agent.plan`),e?t(Ph,{plan:e,workstreamStatus:r||new Map,isOpen:!0,onClose:C,plans:i,activePlanIndex:a,onChangePlan:s}):t(Fh,{icon:t(un,{className:`mb-2 size-8`}),children:D(`agent.noPlanAvailable`)})),is_allowed:!0},{name:`workstreams`,label:M?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[D(`agent.workstreams`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:c.length})]}):D(`agent.workstreams`),content:F(D(`agent.workstreams`),t(Rh,{workstreams:c,messages:l,runId:_})),is_allowed:!u},{name:`documents`,label:N?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[D(`agent.documents`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:d.length})]}):D(`agent.documents`),content:F(D(`agent.documents`),d.length>0&&p&&m?t(Mh,{isOpen:!0,documents:d,activeDocumentId:f??null,onSelectDocument:p,onCloseDocument:m,onUpdateDocumentTitle:h,refreshKey:g,runId:_}):t(Fh,{icon:t(Jt,{className:`mb-2 size-8`}),children:D(`agent.noDocumentsOpen`)})),is_allowed:!0},{name:`uploads`,label:P?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[D(`agent.uploads`),` `,t(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-info`})]}):D(`agent.uploads`),content:F(D(`agent.uploads`),t(Ih,{files:v})),is_allowed:!0},{name:`artifacts`,label:D(`agent.artifacts`),content:F(D(`agent.artifacts`),t(Ch,{runId:_,refreshKey:b})),is_allowed:y},{name:`payload`,label:D(`agent.payload`),content:x?F(D(`agent.payload`),t(`div`,{className:`overflow-y-auto`,children:x})):null,is_allowed:!!x}];return n(De,{tabs:L,current:A,onTabChange:j,fullHeight:!0,className:`px-0`,children:[n(`div`,{className:`flex items-end justify-between shrink-0 px-1 py-1 gap-1`,children:[t(Uh,{tabs:L.filter(e=>e.is_allowed===void 0||e.is_allowed===!0),current:A,onTabChange:j,className:`min-w-0 flex-1`}),!S&&t(o,{variant:`ghost`,size:`sm`,className:`shrink-0 ms-1`,onClick:C,title:`Close Right Panel`,children:t(ar,{className:`size-4`})})]}),t(ke,{className:`flex-1 min-h-0 pt-0 pb-0`})]})}const Gh=W.memo(Wh);function Kh(e){if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.kind!==`file`)continue;let i=r.getAsFile();if(i)if(r.type.startsWith(`image/`)&&(!i.name||i.name===`image.png`)){let e=r.type.split(`/`)[1]||`png`;t.push(new File([i],`pasted-image-${Date.now()}.${e}`,{type:i.type}))}else t.push(i)}return t}function qh(e,t,n=!1){let[r,i]=Y([]),[a,o]=Y(0),[s,c]=Y(new Map),[l,u]=Y(t),[d,f]=Y(!n),p=J(-1),m=J(new Set);K(()=>{e.length===0&&(i([]),o(0),c(new Map),f(!n),p.current=-1,m.current.clear())},[e.length,n]);let h=G(e=>{let n=e[e.length-1];n&&(n.type===Q.TERMINATED?u(!1):u(t?!0:n.type===Q.REQUEST_INPUT))},[t]);return K(()=>{if(e.length===0)return;let t=p.current+1;if(t>=e.length){h(e);return}let n=!1,r=[],a=[];for(let i=t;i<e.length;i++){let t=e[i];if(t.type===Q.PLAN)try{let e=null;if(t.details&&typeof t.details==`object`&&t.details.plan&&Array.isArray(t.details.plan)&&(e={plan:t.details.plan}),e){let i=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime();if(!m.current.has(i)){m.current.add(i),n=!0,r.push({plan:e,timestamp:i});let t=new Map;t.set(`main`,`in_progress`),Array.isArray(e.plan)&&e.plan.forEach(e=>{if(e&&typeof e==`object`&&e.id){let n=e.id.toString();t.set(n,e.status||`pending`)}}),a.push({timestamp:i,statusMap:t})}}}catch(e){console.error(`Failed to parse plan from message:`,e)}}p.current=e.length-1,n&&r.length>0&&(i(e=>[...[...r].reverse(),...e]),o(0),f(!0),a.length>0&&c(e=>{let t=new Map(e);for(let e of a)t.set(e.timestamp,e.statusMap);return t})),h(e)},[e,h]),K(()=>{if(r.length===1&&!d&&!sessionStorage.getItem(`plan-panel-shown`)){let e=setTimeout(()=>{f(!0),sessionStorage.setItem(`plan-panel-shown`,`true`)},500);return()=>clearTimeout(e)}},[r.length,d]),{plans:r,activePlanIndex:a,setActivePlanIndex:o,workstreamStatusMap:s,showInput:l,showSlidingPanel:d,setShowSlidingPanel:f}}function Jh(e,t){return{...e,details:{...e.details??{},_deliveryStatus:t}}}function Yh(e){let t=e.details,n=t?._messageId;if(typeof n==`string`&&n)return n;let r=t?.ack;return typeof r==`string`&&r?r:void 0}function Xh(e,t){let n=e?.[t];return typeof n==`string`&&n?n:void 0}function Zh(e){return e?.streaming_id_scope===`workflow_run`}function Qh(e){return[Q.COMPLETE,Q.IDLE,Q.TERMINATED,Q.REQUEST_INPUT].includes(e.type)}function $h(e){if(e.type===Q.STREAMING_CHUNK)return!1;if(e.type===Q.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files)return!1}return!!e.message||Qh(e)}function eg(e){if(e)return{type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,text:typeof e.message==`string`?e.message.slice(0,80):e.message?`[non-string]`:``,display_role:e.details?.display_role,source:e.details?.source}}function tg(e,t){if(e.find(e=>e.timestamp===t.timestamp))return e;if(!t.details?._optimistic&&(t.type===Q.QUESTION||gl(t))){let n=typeof t.details?.ack==`string`?t.details.ack:void 0,r=n?Jh(t,`consumed`):t;if(n){let i=e.filter(e=>!((e.type===t.type||gl(e))&&e.details?._optimistic&&Yh(e)===n));return pl(i,r),i}if(t.type===Q.QUESTION){let n=e.filter(e=>e.type===Q.QUESTION&&e.details?._optimistic&&e.message===t.message&&(e.workstream_id??`main`)===(t.workstream_id??`main`));if(n.length===1){let r=e.filter(e=>e!==n[0]);return pl(r,t),r}}}let n=[...e];return pl(n,t),n}function ng(e){let t=e.details,n=Xh(t,`streaming_id`),r=Xh(t,`activity_id`);return n&&Zh(t)?n:r??n}function rg(e){let t=e.details,n=Xh(t,`streaming_id`),r=Xh(t,`activity_id`),i=[];return n&&Zh(t)&&i.push(n),r&&i.push(r),[...new Set(i)]}function ig(e,t){let[n,r]=Y([]),[i,a]=Y(!1),[o,s]=Y(`loading`),[c,l]=Y(null),[u,d]=Y(null),[f,p]=Y(new Map),[m,h]=Y(0),g=G(()=>h(e=>e+1),[]),_=J(null),v=J(0),[y,b]=Y(new Map),x=J(new Map),S=J(null),[C,w]=Y(!1),T=J(null),E=G(()=>{let e=S.current;e&&(e.mode===`raf`?cancelAnimationFrame(e.id):clearTimeout(e.id),S.current=null)},[]),D=G(()=>{x.current.size>0&&(b(new Map(x.current)),w(!0),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>w(!1),50)),S.current=null},[]);return K(()=>{a(!hl(n))},[n]),K(()=>{fl(`stream state`,{agentRunId:t,messageCount:n.length,streamingCount:y.size,initialHistoryStatus:o,isCompleted:i,lastDeliveredTs:v.current,first:eg(n[0]),last:eg(n[n.length-1])})},[t,o,i,n,y.size]),K(()=>{let n=_.current!==t;_.current=t,n&&(r([]),s(`loading`),l(null),d(null),b(new Map),p(new Map),v.current=0);let i=new AbortController,a=n?void 0:v.current||void 0;return fl(`stream start`,{agentRunId:t,isNewConversation:n,since:a,streamNonce:m}),e.agents.getInternals(t).then(e=>{i.signal.aborted||(fl(`internals loaded`,{agentRunId:t,status:e.status,first_workflow_run_id:e.first_workflow_run_id}),l(e.status?.toUpperCase()??null),d(e.first_workflow_run_id??null))}).catch(e=>{i.signal.aborted||console.error(`Failed to check agent run status:`,e)}),e.agents.streamMessages(t,e=>{if(!i.signal.aborted){if(fl(`stream message`,{agentRunId:t,type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,hasMessage:!!e.message,display_role:e.details?.display_role,source:e.details?.source}),e.timestamp&&e.timestamp>v.current&&(v.current=e.timestamp),e.type===Q.STREAMING_CHUNK){let t=e.details,n=ng(e);if(!n)return;let r=x.current.get(n)||{text:``,workstreamId:e.workstream_id,startTimestamp:Date.now(),activityId:t?.activity_id,streamingId:t?.streaming_id},i=r.text+(e.message||``);x.current.set(n,{text:i,workstreamId:e.workstream_id,isComplete:t.is_final,startTimestamp:r.startTimestamp,activityId:t?.activity_id,streamingId:t?.streaming_id}),S.current===null&&(document.hidden?S.current={mode:`timeout`,id:window.setTimeout(D,16)}:S.current={mode:`raf`,id:requestAnimationFrame(D)});return}if(e.type===Q.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files){p(new Map(t.files.map(e=>[e.id,e])));return}}if(e.type===Q.THOUGHT||e.type===Q.ANSWER){let t=rg(e);if(t.length>0){for(let e of t)x.current.delete(e);b(e=>{let n=new Map(e),r=!1;for(let e of t)r=n.delete(e)||r;return r?n:e})}}(e.type===Q.COMPLETE||e.type===Q.IDLE)&&x.current.size>0&&D(),$h(e)&&r(t=>tg(t,e))}},a,i.signal,{onHistoryLoaded:e=>{if(i.signal.aborted)return;let n=e.filter($h);fl(`history loaded`,{agentRunId:t,count:e.length,timelineCount:n.length,since:a,first:eg(e[0]),last:eg(e[e.length-1])}),s(e.length>0?`has_messages`:`empty`),n.length>0&&r(e=>n.reduce((e,t)=>(t.timestamp&&t.timestamp>v.current&&(v.current=t.timestamp),tg(e,t)),e))},onHistoryError:e=>{i.signal.aborted||(fl(`history error`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),s(`error`))}}).then(()=>{if(!i.signal.aborted)return fl(`stream resolved`,{agentRunId:t}),e.agents.getInternals(t).then(e=>{i.signal.aborted||(fl(`internals refreshed after stream end`,{agentRunId:t,status:e.status}),l(e.status?.toUpperCase()??null))}).catch(e=>{i.signal.aborted||console.error(`Failed to refresh agent run status on stream end:`,e)})}).catch(e=>{i.signal.aborted||(fl(`stream failed`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),console.error(`Failed to stream agent messages:`,e))}),()=>{fl(`stream cleanup`,{agentRunId:t,streamNonce:m}),i.abort(),E(),x.current.clear(),T.current&&=(clearTimeout(T.current),null)}},[t,m,e.agents,D,E]),K(()=>{let e=()=>{!document.hidden&&x.current.size>0&&(E(),D())};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[D,E]),{messages:n,streamingMessages:y,isCompleted:i,initialHistoryStatus:o,debugChunkFlash:C,addOptimisticMessage:G(e=>{r(t=>{let n=[...t,e];return n.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),n})},[]),updateOptimisticMessageStatus:G((e,t)=>{r(n=>n.map(n=>n.details?._optimistic&&Yh(n)===e?Jh(n,t):n))},[]),removeOptimisticMessages:G(e=>{r(t=>t.filter(t=>!e(t)))},[]),reconnect:g,agentRunStatus:c,workflowRunId:u,serverFileUpdates:f}}function ag(e){if(typeof e==`string`&&e.trim().length>0)return e}function og(e,t){let n=ag(e.revision_root_id)||ag(e.revision_root)||ag(e.root_document_id)||ag(e.root_id);if(n)return n;let r=e.revision_info;if(r&&typeof r==`object`){let e=ag(r.root);if(e)return e}return t}function sg(e,t){return e.revisionRootId&&t.revisionRootId?e.revisionRootId===t.revisionRootId:t.revisionRootId?e.id===t.revisionRootId:e.revisionRootId?e.revisionRootId===t.id:e.id===t.id}function cg(e){let[t,n]=Y([]),[r,i]=Y(null),[a,o]=Y(!1),[s,c]=Y(0),l=J(-1);return K(()=>{e.length===0&&(n([]),i(null),o(!1),c(0),l.current=-1)},[e.length]),K(()=>{let t=l.current+1;if(!(t>=e.length)){for(let r=t;r<e.length;r++){let t=e[r];if(t.type===Q.UPDATE&&t.details){let e=t.details;if(e.event_class===`document_created`||e.event_class===`document_updated`){let t=ag(e.document_id),r=ag(e.updated_document_id)||t,a=e.title;if(r){let s=og(e,t||r),l={id:r,title:a||`Document`,revisionRootId:s};n(e=>{let t=e.findIndex(e=>sg(e,l));if(t<0)return[...e,l];let n=e[t];if(n.id===l.id&&n.title===l.title&&n.revisionRootId===l.revisionRootId)return e;let r=[...e];return r[t]=l,r}),i(l.id),o(!0),e.event_class===`document_updated`&&c(e=>e+1)}}}}l.current=e.length-1}},[e]),{openDocuments:t,activeDocumentId:r,isDocPanelOpen:a,docRefreshKey:s,closeDocPanel:G(()=>{o(!1)},[]),closeDocument:G(e=>{n(t=>{let n=t.filter(t=>t.id!==e);return n.length===0?(o(!1),i(null)):i(t=>t===e?n[0].id:t),n})},[]),selectDocument:G(e=>{i(e)},[]),openDocInPanel:G(e=>{n(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:`Document`,revisionRootId:e}]),i(e),o(!0)},[]),updateDocumentTitle:G((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,title:t}:n))},[])}}function lg(e){return e.type.startsWith(`image/`)}function ug(e){if(!(!lg(e)||typeof URL>`u`||!URL.createObjectURL))return URL.createObjectURL(e)}function dg(e){typeof URL<`u`&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function fg(e,t,n,r){let i=rt.getFixedT(null,nt),[a,o]=Y(new Map),[s,c]=Y(new Set),l=J(new Set),u=J(new Map),d=J(t),f=J(a);f.current=a;let p=J(n);p.current=n;let m=G(e=>{let t=u.current.get(e);t&&(dg(t),u.current.delete(e))},[]);K(()=>{if(d.current!==t){d.current=t,u.current.forEach(dg),u.current.clear(),o(new Map);let e=new Set;l.current=e,c(e)}},[t]),K(()=>()=>{u.current.forEach(dg),u.current.clear()},[]);let h=q(()=>{let e=new Map;return a.forEach((t,n)=>{s.has(n)||e.set(n,t)}),n.forEach((t,n)=>{if(!s.has(n)){let r=a.get(n);e.set(n,{...t,artifact_path:t.artifact_path??r?.artifact_path,reference:t.reference??r?.reference,...r?.preview_url?{preview_url:r.preview_url}:{}})}}),e},[a,s,n]);return{processingFiles:h,hasProcessingFiles:q(()=>Array.from(h.values()).some(e=>e.status===hr.UPLOADING||e.status===hr.PROCESSING),[h]),handleFileUpload:G(async n=>{for(let a of n){let n=`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,s=`files/${a.name}`,c=ug(a);c&&u.current.set(n,c);let d={id:n,name:a.name,content_type:a.type||`application/octet-stream`,size:a.size,status:hr.UPLOADING,started_at:Date.now(),preview_url:c};o(e=>new Map(e).set(n,d));try{if(await e.agents.uploadArtifact(t,s,a),o(e=>{let t=new Map(e),r=t.get(n);return r&&(r.status=hr.PROCESSING,r.artifact_path=s,r.reference=`artifact:${s}`),t}),l.current.has(n))continue;await e.agents.sendSignal(t,`FileUploaded`,{id:n,name:a.name,content_type:a.type||`application/octet-stream`,reference:`artifact:${s}`,artifact_path:s})}catch(e){if(l.current.has(n))continue;o(t=>{let r=new Map(t),i=r.get(n);return i&&(i.status=hr.ERROR,i.error=e instanceof Error?e.message:`Upload failed`,i.completed_at=Date.now()),r}),r({status:`error`,title:i(`agent.uploadFailed`),description:e instanceof Error?e.message:`Failed to upload file`,duration:3e3})}}},[e,t,r,i]),removeProcessingFile:G(async n=>{c(e=>{if(e.has(n))return e;let t=new Set(e);return t.add(n),l.current=t,t}),o(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t}),m(n);try{await e.agents.sendSignal(t,`FileRemoved`,{id:n})}catch(e){r({status:`error`,title:i(`agent.removeFileFailed`),description:e instanceof Error?e.message:`Failed to remove file`,duration:3e3})}},[t,e,m,i,r]),clearProcessingFiles:G(()=>{u.current.forEach(dg),u.current.clear(),c(e=>{let t=new Set(e);for(let e of p.current.keys())t.add(e);for(let e of f.current.keys())t.add(e);return l.current=t,t}),o(new Map)},[])}}function pg({activeWorkstreams:e,className:r}){let{t:i}=X(),a=q(()=>e.filter(e=>e.status===`running`||e.status===`canceling`),[e]),o=a.slice(0,3),s=Math.max(0,a.length-o.length);return a.length===0?null:t(`div`,{className:H(`mx-auto mb-2 w-full max-w-3xl px-1`,r),"data-agent-active-workstreams":!0,children:n(`output`,{className:`flex flex-col gap-1.5 rounded-2xl border border-border/70 bg-background/95 p-2 text-xs text-muted shadow-lg shadow-black/5`,"aria-live":`polite`,children:[n(`div`,{className:`flex items-center gap-2 px-1 font-medium`,children:[t(dt,{className:`size-3.5 text-muted`,"aria-hidden":`true`}),t(`span`,{children:i(`agent.activeWorkstreams`,{count:a.length})})]}),n(`div`,{className:`flex flex-col gap-0.5`,children:[o.map(e=>{let r=el(e.workstream_id,e.interaction);return n(`span`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:r,children:[t(`span`,{className:H(`size-1.5 shrink-0 rounded-full`,ol(e.status)),"aria-hidden":`true`}),t(`span`,{className:`truncate font-medium`,children:r}),e.phase&&t(`span`,{className:`truncate text-xs text-muted/75`,children:Qc(e.phase)})]},e.launch_id||e.workstream_id)}),s>0&&n(`span`,{className:`px-1 py-1 text-xs text-muted`,children:[`+`,s]})]})]})})}var mg=class{_listeners=new Set;snapshot;constructor(e){this.snapshot=new hg(e,this)}subscribe=e=>(this._listeners.add(e),()=>{this._listeners.delete(e)});getSnapshot=()=>this.snapshot;notify(){this._listeners.forEach(e=>{e()})}},hg=class e{vertesia;_interactive=!0;_debug_mode=!1;_non_blocking_subagents=!0;_checkpoint_tokens;_visibility;_user_channels;_collection;_disabled_mcp_collections;_start=!1;_preserveRunValues=!1;_interaction;_environment;_model=``;_model_options;_tool_names=[];_data;_mode=`start`;_scheduledWorkflowConfig;_interactionParamsSchema;_schemaVersion=0;_inputValidator;_store;constructor(e,t){this.vertesia=e,this._store=t}onStateChanged(){let e=this.clone();this._store.snapshot=e,this._store.notify()}clone(){let t=new e(this.vertesia,this._store);return t._interactionParamsSchema=this._interactionParamsSchema,t._schemaVersion=this._schemaVersion,t._interaction=this._interaction,t._data=this._data,t._environment=this._environment,t._model=this._model,t._model_options=this._model_options?{...this._model_options}:void 0,t._tool_names=[...this._tool_names],t._interactive=this._interactive,t._debug_mode=this._debug_mode,t._non_blocking_subagents=this._non_blocking_subagents,t._checkpoint_tokens=this._checkpoint_tokens,t._visibility=this._visibility,t._user_channels=this._user_channels?[...this._user_channels]:void 0,t._inputValidator=this._inputValidator,t._start=this._start,t._collection=this._collection,t._disabled_mcp_collections=this._disabled_mcp_collections?[...this._disabled_mcp_collections]:void 0,t._preserveRunValues=this._preserveRunValues,t._mode=this._mode,t._scheduledWorkflowConfig=this._scheduledWorkflowConfig,t}set mode(e){e!==this._mode&&(this._mode=e,e===`schedule`&&!this._scheduledWorkflowConfig&&(this._scheduledWorkflowConfig={name:``,description:``,cron_expression:`0 9 * * *`,timezone:`UTC`}),this.onStateChanged())}get mode(){return this._mode}set scheduledWorkflowConfig(e){this._scheduledWorkflowConfig=e,this.onStateChanged()}get scheduledWorkflowConfig(){return this._scheduledWorkflowConfig}updateScheduledWorkflowConfig(e){this._scheduledWorkflowConfig={...this._scheduledWorkflowConfig,...e},this.onStateChanged()}get interactive(){return this._interactive}set interactive(e){e!==this._interactive&&(this._interactive=e,this.onStateChanged())}get debug_mode(){return this._debug_mode}set debug_mode(e){e!==this._debug_mode&&(this._debug_mode=e,this.onStateChanged())}get non_blocking_subagents(){return this._non_blocking_subagents}set non_blocking_subagents(e){e!==this._non_blocking_subagents&&(this._non_blocking_subagents=e,this.onStateChanged())}get checkpoint_tokens(){return this._checkpoint_tokens}set checkpoint_tokens(e){e!==this._checkpoint_tokens&&(this._checkpoint_tokens=e,this.onStateChanged())}get visibility(){return this._visibility}set visibility(e){e!==this._visibility&&(this._visibility=e,this.onStateChanged())}get user_channels(){return this._user_channels}set user_channels(e){this._user_channels=e,this.onStateChanged()}get collection(){return this._collection}set collection(e){e!==this._collection&&(this._collection=e,this.onStateChanged())}get disabled_mcp_collections(){return this._disabled_mcp_collections}set disabled_mcp_collections(e){this._disabled_mcp_collections=e&&e.length>0?e:void 0,this.onStateChanged()}get search_scope(){return this._collection?fr.Collection:void 0}async restoreConversation(e){let t=e.interaction;e.version&&(/^[a-fA-F0-9]{24}$/.test(t)||(t=`${t}@${e.version}`));let n=await this.vertesia.interactions.catalog.resolve(t),r=n.runtime?.environment||e.config?.environment,i=e.config?.model,a=await(r?this.vertesia.environments.retrieve(r).catch(()=>void 0):Promise.resolve(void 0));this._data=e.data,this.interaction=n,e.interactionParamsSchema!=null&&(this.interactionParamsSchema=e.interactionParamsSchema),this._tool_names=e.tool_names||[],this._interactive=e.interactive,this._debug_mode=e.debug_mode??!1,this._non_blocking_subagents=e.non_blocking_subagents??!0,this._checkpoint_tokens=e.checkpoint_tokens,this._user_channels=e.user_channels,this._disabled_mcp_collections=e.disabled_mcp_collections,this._model_options=e.config?.model_options,this.collection=e.collection_id??void 0,this._model_options=e.config?.model_options,this.environment=a,i&&(this._model=i),this.onStateChanged()}get interaction(){return this._interaction}set interaction(e){if(e?.id!==this._interaction?.id){if(this._interaction=e,this.interactionParamsSchema=e?Or(e.prompts):void 0,this._inputValidator=void 0,e&&!this._preserveRunValues&&(this._model_options=e.model_options,e.runtime?.environment)){let t=e.runtime.environment;this.vertesia.environments.retrieve(t).then(e=>this.environment=e)}this.onStateChanged()}}get environment(){return this._environment}set environment(e){if(e?.id!==this._environment?.id){if(this._environment=e,!this._preserveRunValues){let t=this.interaction?.runtime?.model;t&&e&&jr(t,e.provider)?this._model=t:this._model=e?.default_model&&jr(e.default_model,e.provider)?e.default_model:``}this.onStateChanged()}}get model(){return this._model}set model(e){e!==this._model&&(this._model=e||``,this.onStateChanged())}get model_options(){return this._model_options}set model_options(e){JSON.stringify(e)!==JSON.stringify(this._model_options)&&(this._model_options=e,this.onStateChanged())}get tool_names(){return this._tool_names}set tool_names(e){this._tool_names=e,this.onStateChanged()}get data(){return this._data}set data(e){this._data=e,this.onStateChanged()}set run(e){console.log(`run`,e),this.onStateChanged()}set start(e){this._start!==e&&(this._start=e,this.onStateChanged())}markStarted(){this.start=!0}setMode(e){this.mode=e}setInteraction(e){this.interaction=e}setEnvironment(e){this.environment=e}setModel(e){this.model=e}setModelOptions(e){this.model_options=e}setToolNames(e){this.tool_names=e}setCollection(e){this.collection=e}setDisabledMcpCollections(e){this.disabled_mcp_collections=e}setInteractive(e){this.interactive=e}setDebugMode(e){this.debug_mode=e}setUserChannels(e){this.user_channels=e}setCheckpointTokens(e){this.checkpoint_tokens=e}setVisibility(e){this.visibility=e}setData(e){this.data=e}setPreserveRunValues(e){this.preserveRunValues=e}get start(){return this._start}get preserveRunValues(){return this._preserveRunValues}set preserveRunValues(e){this._preserveRunValues=e}get schemaVersion(){return this._schemaVersion}get interactionParamsSchema(){return this._interactionParamsSchema}set interactionParamsSchema(e){this._interactionParamsSchema!==e&&(this._interactionParamsSchema=e,this._schemaVersion+=1,e&&(this._data=this.initializeBooleanDefaults(this._data||{},e)),this.onStateChanged())}initializeBooleanDefaults(e,t){if(!t.properties)return e;let n={...e};for(let[e,r]of Object.entries(t.properties)){let t=r;t.type===`boolean`&&n[e]===void 0?n[e]=!1:t.type===`object`&&t.properties&&(n[e]=this.initializeBooleanDefaults(n[e]||{},t))}return n}reset(){if(this._start=!1,this._interactive=!0,this._debug_mode=!1,this._non_blocking_subagents=!0,this._checkpoint_tokens=void 0,this._visibility=void 0,this._user_channels=void 0,this._collection=void 0,this._disabled_mcp_collections=void 0,this._preserveRunValues=!1,this._model=``,this._model_options=void 0,this._environment=void 0,this._tool_names=[],this._interaction=void 0,this._data=void 0,this._interactionParamsSchema=null,this._inputValidator=void 0,this.model=void 0,this.environment=void 0,this.onStateChanged(),location.hash){let e=window.location.origin+window.location.pathname+window.location.search;history.replaceState(null,``,e),location.hash=``}}validateInput(){if(!this._interactionParamsSchema)return{isValid:!0};if(!this._inputValidator||this._inputValidator.schema!==this._interactionParamsSchema){let e=new ji({strict:!1});this._inputValidator={validate:e.compile(this._interactionParamsSchema),schema:this._interactionParamsSchema}}let e=this._data||{};return this._inputValidator.validate(e)?{isValid:!0}:{isValid:!1,errorMessage:this._inputValidator.validate.errors?this._inputValidator.validate.errors.map(e=>`${e.instancePath}: ${e.message}`).join(`, `):`Invalid payload data`}}};const gg=Ye(void 0);function _g({children:e}){let{client:n}=Z(),[r]=Y(()=>new mg(n)),i=tt(r.subscribe,r.getSnapshot);return t(gg.Provider,{value:i,children:e})}function vg(){let e=Qe(gg);if(!e)throw Error(`usePayloadBuilder must be used within a PayloadProvider`);return e}function yg({title:e,variant:r=`full`,isTerminal:i=!1,onClose:a,isModal:s,agentRunId:c,workflowRunId:l,viewMode:u,onViewModeChange:d,showPlanPanel:f,showPlanButton:p=!0,onTogglePlanPanel:m,showPlaybackButton:h=!1,isPlaybackEnabled:g=!1,onTogglePlayback:_,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C=!0,onClone:w,isReceivingChunks:T=!1,className:E}){let{t:D}=X(),O=r===`compact`,k=u===`sliding`?`stacked`:`sliding`,A=D(`agent.verbose`),j=D(`agent.summary`),M=k===`stacked`?A:j,N=n(`div`,{className:H(O?`flex flex-col items-center gap-1`:`flex justify-end items-center gap-2 ms-auto`),children:[p&&t(`div`,{className:`relative`,children:n(o,{size:r===`compact`?`icon`:`sm`,variant:f?`primary`:`ghost`,onClick:m,className:H(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),title:D(`agent.toggleRightSidebar`),children:[t(jt,{className:H(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)}):t(`span`,{className:`sr-only`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)})]})}),O?t(o,{variant:`ghost`,size:`icon`,onClick:()=>d(k),className:`size-8 rounded-lg`,title:M,"aria-label":M,children:t(k===`stacked`?Ln:yn,{className:`size-4`})}):n(`div`,{className:`flex items-center gap-1 bg-muted rounded p-0.5 mt-2 lg:mt-0`,children:[n(o,{variant:u===`stacked`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`stacked`),"aria-pressed":u===`stacked`,className:`gap-1.5`,children:[t(Ln,{className:`size-3.5`}),A]}),n(o,{variant:u===`sliding`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`sliding`),"aria-pressed":u===`sliding`,className:`gap-1.5`,children:[t(yn,{className:`size-3.5`}),j]})]}),h&&_&&n(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:g?`primary`:`ghost`,onClick:_,"aria-pressed":g,"aria-label":D(`agent.rewind.label`),title:D(`agent.rewind.label`),className:H(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:[t(In,{className:H(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(`agent.rewind.label`)}):t(`span`,{className:`sr-only`,children:D(`agent.rewind.label`)})]}),t(bg,{compact:O,agentRunId:c,workflowRunId:l,isModal:s,isTerminal:i,onClose:a,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C,onClone:w}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,"aria-label":D(`agent.close`),children:t(ar,{className:`size-4`})})]});return r===`compact`?t(_g,{children:t(`div`,{className:H(`inline-flex items-center rounded-xl border border-border/70 bg-background/90 p-1 shadow-lg shadow-black/10 backdrop-blur`,E),children:N})}):t(_g,{children:n(`div`,{className:H(`flex flex-wrap items-end justify-between py-1.5 px-2 border-b shadow-sm flex-shrink-0`,E),children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1`,children:[t(dt,{className:`size-5 text-muted`}),t(`span`,{className:`font-medium`,children:e})]}),n(`span`,{className:`text-xs text-muted ms-1 flex items-center gap-1.5`,children:[`(Agent Run ID: `,c,`)`,t(`span`,{className:H(`w-2 h-2 rounded-full transition-colors duration-200`,T?`bg-purple-500 shadow-[0_0_6px_2px_rgba(168,85,247,0.6)]`:`bg-gray-400`)})]})]}),N]})})}function bg({compact:e=!1,agentRunId:r,workflowRunId:i,isModal:a,isTerminal:s,onClose:c,onDownload:l,onExportFixture:u,resetWorkflow:d,onExportPdf:f,onShowDetails:p,allowWorkflowControl:m=!0,onClone:h}){let{t:g}=X(),_=He(),{client:v}=Z(),y=vg(),{router:x}=ui(),S=async()=>{try{return await v.agents.terminate(r,`cancel`),_({status:`success`,title:g(`agent.workflowCancelled`),duration:2e3}),y.reset(),d?.(),!0}catch{return _({status:`error`,title:g(`agent.failedToCancelWorkflow`),duration:2e3}),!1}},C=async()=>{try{let e=await v.agents.fork(r);_({status:`success`,title:g(`agent.conversationCloned`),duration:2e3}),h?.(e)}catch{_({status:`error`,title:g(`agent.failedToCloneConversation`),duration:2e3})}},w=e=>{let t=e.startsWith(`/`)?x.getTopRouter().navigator.addStickyParams(e):e;return window.open(t,`_blank`),t};return t(b,{align:`right`,trigger:t(o,{size:e?`icon`:`xs`,variant:`ghost`,title:g(`agent.moreActions`),"aria-label":g(`agent.moreActions`),className:e?`size-8 rounded-lg`:void 0,children:t(wn,{className:`size-4`})}),children:n(R,{label:`Actions`,children:[a&&n(z,{onClick:()=>w(`/store/agent-runner/${r}`),children:[t(Vt,{className:`size-3.5 text-muted`}),` `,g(`agent.openInNewTab`)]}),n(z,{onClick:()=>{navigator.clipboard.writeText(r),_({status:`success`,title:g(`agent.agentRunIdCopied`),duration:2e3})},children:[t(Ft,{className:`size-3.5 text-muted`}),` `,g(`agent.copyAgentRunId`)]}),n(z,{onClick:()=>{navigator.clipboard.writeText(i),_({status:`success`,title:g(`agent.workflowRunIdCopied`),duration:2e3})},children:[t(Ft,{className:`size-3.5 text-muted`}),` `,g(`agent.copyWorkflowRunId`)]}),p&&n(z,{onClick:p,children:[t(sn,{className:`size-3.5 text-muted`}),` `,g(`agent.details`)]}),n(z,{onClick:()=>{l?l():Sl(v,r).then(e=>window.open(e,`_blank`))},children:[t(Rt,{className:`size-3.5 text-muted`}),` `,g(`agent.downloadConversation`)]}),f&&n(z,{onClick:f,children:[t(Rt,{className:`size-3.5 text-muted`}),` `,g(`agent.exportAsPdf`)]}),u&&n(z,{onClick:u,children:[t(Rt,{className:`size-3.5 text-muted`}),` `,g(`agent.rewind.exportFixture`)]}),c&&a&&n(z,{onClick:c,children:[t(ar,{className:`size-3.5 text-muted`}),` `,g(`agent.close`)]}),h&&n(z,{onClick:C,children:[t(en,{className:`size-3.5 text-muted`}),` `,g(`agent.cloneConversation`)]}),m&&!s&&n(z,{onClick:S,variant:`destructive`,children:[t(ar,{className:`size-3.5`}),` `,g(`agent.cancelWorkflow`)]})]})})}function xg(e){return typeof e==`object`&&!!e&&`value`in e}function Sg(e){return xg(e)?e.value:e}function Cg(e){if(e.type===`stringList`)return e.value.map(e=>typeof e==`string`?e:Sg(e));if(e.multiple)return e.value.map(Sg);let t=e.value[0];return t===void 0?void 0:Sg(t)}function wg(e,t,n){e.query[t]=n}function Tg({buckets:e,name:r,placeholder:a}){let o=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:r,placeholder:a||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:o,type:`select`,labelRenderer:r=>{let a=e.find(e=>e._id===r),o=a?.name||r,s=`success`;if(a?.status)switch(a.status){case _r.published:s=`success`;break;case _r.archived:s=`destructive`;break;case _r.code:s=`info`;break}let c=a?.version&&a?.status?`v${a.version} ${a.status===_r.unknown?``:a.status}`:a?.status||(a?.version?`v${a.version}`:``);return n(`div`,{className:`w-full flex items-center justify-between`,children:[n(`div`,{className:`flex flex-row flex-wrap items-center gap-2 min-w-0 flex-1`,children:[t(`span`,{className:`text-sm truncate`,children:o}),c&&t(i,{variant:s,className:`text-xs w-fit`,children:c})]}),(a?.count??0)>0&&n(`span`,{className:`ms-2 text-xs shrink-0`,children:[`(`,a?.count,`)`]})]})},filterBy:(t,n)=>(e.find(e=>e._id===t)?.name||t).toLowerCase().includes(n.toLowerCase())}}function Eg(e){return`${e._id} (${e.count})`}function Dg(e){return`${e.name} (${e.count})`}function Og({buckets:e,name:t,placeholder:n,type:r=`select`,multiple:i=!1}){return{name:t,options:e.map(e=>({label:Eg(e),value:e._id})),type:r,multiple:i,placeholder:`${n??`${t.charAt(0).toUpperCase()+t.slice(1)}`}`,allowCreate:!1}}function kg({buckets:e,name:t,placeholder:n,type:r,multiple:i}){return Og({buckets:e,name:t,placeholder:n,type:r,multiple:i})}const Ag={},jg={},Mg={};function Ng(e){return typeof e==`object`&&!!e&&`status`in e&&e.status===404}function Pg(e,t,n){let r=e[t];return r||(r=n().catch(n=>{throw Ng(n)||delete e[t],n}),e[t]=r),r}function Fg(e){let{client:t}=Z();return Le(()=>Pg(Ag,e,()=>t.users.retrieve(e)),{deps:[e],condition:()=>!!e})}function Ig(e){let{client:t}=Z();return Le(()=>Pg(jg,e,()=>t.iam.groups.retrieve(e)),{deps:[e],condition:()=>!!e})}function Lg(e){let{client:t}=Z();return Le(()=>Pg(Mg,e,()=>t.apikeys.retrieve(e)),{deps:[e],condition:()=>!!e})}function Rg(){return t(`div`,{className:`size-8`})}function zg({showTitle:e=!1,size:i=`md`}){let{t:a}=X();return t(Zg,{title:a(`user.systemUser`),description:a(`user.systemUserDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(r,{src:`/icon.svg`,size:i}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:a(`user.systemUser`)})]})})}function Bg({showTitle:e=!1,size:r=`md`}){let{t:i}=X();return t(Zg,{title:i(`user.allProjectMembers`),description:i(`user.allProjectMembersDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(er,{className:`size-4`,size:r}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:i(`user.allProjectMembers`)})]})})}function Vg({accountId:i,showTitle:a=!1,size:o=`md`}){let{t:s}=X(),c=i.split(`:`)[0],l=i.split(`:`)[1],u=n(e,{children:[t(`div`,{children:s(`user.serviceAccountDescription`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`Type:`}),` `,c]}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,l]})]});return t(Zg,{title:s(`user.serviceAccount`),description:u,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:`/cloud.svg`,name:`SA`,color:`bg-amber-500`,className:`px-[5px] text-white`,size:o}),a&&n(`div`,{className:`text-sm font-semibold ps-2 truncate`,children:[s(`user.serviceAccount`),` : ~`,l.slice(-6)]})]})})}function Hg({email:i,showTitle:a=!1,size:o=`md`}){let{t:s}=X();return t(Zg,{title:`Email Agent`,description:n(e,{children:[t(`div`,{children:s(`user.serviceAccountDescription`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`Email:`}),` `,i]})]}),children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(r,{src:`/cloud.svg`,color:`bg-amber-500`,className:`px-[5px] text-white border-2 border-white dark:border-gray-800`,size:o}),t(r,{name:i,size:o,className:`border-2 border-white dark:border-gray-800`})]}),a&&n(`div`,{className:`text-sm font-semibold truncate`,children:[s(`user.agentOnBehalfOf`),` : `,i]})]})})}function Ug({agentId:i,onBehalfOfType:a,onBehalfOfId:o,showTitle:s=!1,size:c=`md`,isScheduleAgent:l=!1}){let{t:u}=X(),d=a===`user`&&o,f=a===`apikey`&&o,p=Fg(o||``),m=Lg(o||``),h=d?p.data:void 0,g=f?m.data:void 0,_=i.slice(-6),v=h?u(`user.agentOnBehalfOf`):g?u(`user.agentOnBehalfOfApiKey`):`${u(`user.serviceAccount`)}~${_}`;return t(Zg,{title:l?u(`user.schedule`,{title:v}):v,description:n(`div`,{className:`space-y-2`,children:[h&&n(`div`,{className:`flex items-center gap-2`,children:[t(r,{src:h.picture,name:h.name,size:`sm`}),n(`div`,{children:[t(`div`,{className:`font-medium`,children:h.name||h.email}),h.email&&h.name&&t(`div`,{className:`text-xs text-muted`,children:h.email})]})]}),g&&n(`div`,{children:[t(`div`,{className:`font-medium`,children:g.name}),n(`div`,{className:`text-xs text-muted-foreground`,children:[`Key ID: `,g.id]})]}),!h&&!g&&n(e,{children:[t(`div`,{children:u(`user.serviceAccountDescription`)}),n(`div`,{className:`text-gray-800 dark:text-gray-500 text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,i]})]})]}),children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(r,{src:`/cloud.svg`,color:`bg-amber-500`,className:`px-[5px] text-white border-2 border-white dark:border-gray-800`,size:c}),h&&t(r,{src:h.picture,name:h.name,size:c,className:`border-2 border-white dark:border-gray-800`}),g&&t(r,{name:`API`,color:`bg-gray-400`,size:c,className:`border-2 border-white dark:border-gray-800`})]}),s&&t(`div`,{className:`text-sm font-semibold truncate`,children:h?`Agent (${h.name||h.email})`:g?`Agent (${g.name})`:v})]})})}function Wg({title:e=`Error`,error:n,showTitle:r=!1,size:i=`md`}){return t(qg,{title:e,message:Ne(n),color:`bg-red-500`,showTitle:r,size:i})}function Gg({showTitle:e=!1,size:n=`md`,color:r}){let{t:i}=X();return t(qg,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),color:r,showTitle:e,size:n})}function Kg({userRef:e,showTitle:n=!1,size:r=`md`}){let{t:i}=X();if(!e)return t(qg,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),showTitle:n,size:r});let a=e.split(`:`),o=a[0];switch(o){case Sr.User:return t(Yg,{userId:a[1],showTitle:n,size:r});case Sr.Group:return t(Jg,{userId:a[1],showTitle:n,size:r});case`system`:return t(zg,{showTitle:n,size:r});case Sr.ServiceAccount:return t(Vg,{accountId:a.slice(1).join(`:`),showTitle:n,size:r});case Sr.Agent:{let e,i,o;return a[1]===`agent`?(e=a.slice(2,5).join(`:`),i=a[5],o=a[6]):(e=a.slice(1,4).join(`:`),i=a[4],o=a[5]),t(Ug,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r})}case Sr.Schedule:{let e=a[2]===`agent`?a.slice(3,6).join(`:`):`unknown-agent`,i=a[6],o=a[7];return t(Ug,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r,isScheduleAgent:!0})}case`email`:return t(Hg,{email:a[1],showTitle:n,size:r});case Sr.ApiKey:return t(Xg,{keyId:a[1],size:r,showTitle:n});case`project`:if(a[1]===`*`)return t(Bg,{showTitle:n,size:r});break;default:return t(Wg,{title:i(`user.unknownUser`),error:`Invalid user ref type: ${o}`,showTitle:n,size:r})}}function qg({title:e,message:i,color:a,size:o=`md`,showTitle:s=!1}){return t(Zg,{title:e,description:i,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{color:a,size:o}),s&&t(`div`,{className:`text-sm font-semibold ps-1`,children:e})]})})}function Jg({userId:e,showTitle:r=!1,size:i=`md`}){let{t:a}=X(),{data:o,error:s}=Ig(e);if(s)return Ng(s)?t(Gg,{showTitle:r,size:i,color:`bg-indigo-500`}):t(Wg,{title:a(`user.failedToFetchGroup`),error:s,showTitle:r,size:i});if(!o)return t(Rg,{});let c=n(`div`,{className:`space-y-1`,children:[o.description&&t(`div`,{className:`text-sm`,children:o.description}),t(`div`,{className:`text-xs text-muted-foreground`,children:a(`user.groupId`,{id:o.id})}),o.tags&&o.tags.length>0&&t(`div`,{className:`flex flex-wrap gap-1`,children:o.tags.map(e=>t(`span`,{className:`px-1.5 py-0.5 bg-muted rounded text-xs`,children:e},e))})]});return t(Zg,{title:o.name||a(`user.unnamedGroup`),description:c,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t($n,{className:`size-6 text-indigo-500`,size:i}),r&&t(`div`,{className:`text-sm font-semibold ps-2`,children:o.name||a(`user.unnamedGroup`)})]})})}function Yg({userId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=X(),{data:s,error:c}=Fg(e);if(c)return Ng(c)?t(Gg,{showTitle:i,size:a,color:`bg-indigo-500`}):t(Wg,{title:o(`user.failedToFetchUser`),error:c,showTitle:i,size:a});if(!s)return t(Rg,{});let l=t(`div`,{className:`truncate`,title:s.email,children:s.email});return t(Zg,{title:s.name||s.email||s.username||o(`user.unknown`),description:l,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:s.picture,name:s.name,color:`bg-indigo-500`,size:a}),i&&t(`div`,{className:`text-sm font-semibold ps-2`,children:s.name||s.email||s.username||o(`user.unknown`)})]})})}function Xg({keyId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=X(),{data:s,error:c}=Lg(e);if(c)return Ng(c)?t(Gg,{showTitle:i,size:a,color:`bg-pink-500`}):t(Wg,{title:o(`user.failedToFetchApiKey`),error:c,showTitle:i,size:a});if(!s)return t(Rg,{});let l=o(`user.privateKey`),u=t(r,{name:`PK`,color:`bg-pink-500`,size:a});return t(Zg,{title:l,description:n(Ee,{className:`dark:bg-gray-800 dark:text-gray-200 table-fixed w-full`,children:[n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.key`)}),t(`td`,{className:`truncate max-w-0`,children:s?.name})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.account`)}),t(`td`,{className:`truncate max-w-0`,children:s?.account})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.project`)}),t(`td`,{className:`truncate max-w-0`,children:s?.project.name})]})]}),children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[u,i&&t(`div`,{className:`text-sm font-semibold`,children:s?.name||s?.account||s?.project.name||o(`user.unknown`)})]})})}function Zg({title:e,description:r,children:i}){return n(oe,{hover:!0,children:[t(ce,{className:`cursor-pointer flex items-center inline-block`,children:t(`div`,{children:i})}),t(se,{align:`center`,sideOffset:8,side:`right`,children:n(`div`,{className:`flex flex-col gap-1 rounded-md shadow-md p-2`,children:[t(`div`,{className:`text-md font-semibold`,children:e}),r]})})]})}function Qg({buckets:e,name:r,placeholder:i}){let a=e.map(e=>({value:e._id,label:`(${e.count})`}));return{name:r,placeholder:i||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:a,labelRenderer:r=>{if(r===`Unknown User`||!r)return`Unknown User (${e.find(e=>e._id===r)?.count||0})`;let i=e.find(e=>e._id===r);return n(`div`,{className:`flex items-center w-full gap-2`,children:[t(`div`,{className:`flex-1 min-w-0 flex items-center truncate`,children:t(Kg,{userRef:r,showTitle:!0,size:`sm`})}),n(`span`,{className:`text-muted-foreground flex-shrink-0`,children:[`(`,i?.count||0,`)`]})]})}}}function $g({buckets:e,name:t,placeholder:n}){return Qg({buckets:e,name:t,placeholder:n})}function e_(e){let t=[];return t.push({name:`id`,placeholder:`Agent Run ID`,type:`text`,multiple:!1}),t.push(Tg({buckets:e.interactions||[],name:`interaction`,placeholder:`Interaction`})),t.push(kg({buckets:e.statuses||[],name:`status`,placeholder:`Status`})),t.push($g({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function t_(e){return t=>{e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name;wg(e,n,Cg(t))}}),e.search()}}function n_({facets:e,search:r,selectionCount:i,actions:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=Y([]),f=s??u,p=c??d,m=J(!1),h=J(typeof window<`u`&&!!new URLSearchParams(window.location.search).get(`filters`)),g=e_(e),_=l??g,v=q(()=>t_(r),[r]);return K(()=>{if(!m.current){m.current=!0;return}if(h.current){h.current=!1;return}v(f)},[f,v]),t(M,{filterGroups:_,filters:f,setFilters:p,children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(A,{}),n(`div`,{className:`flex justify-end`,children:[!i&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted-foreground`,children:r.initialized?`${r.totalCount} agent runs`:`Loading agent runs...`})}),a&&a.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:a.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(Pn,{className:`size-5`})})]})]}),f.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(k,{}),t(j,{})]})]})})}var r_=class{types;map={};constructor(e){this.types=e,e.sort((e,t)=>e.name.localeCompare(t.name));for(let t of e)this.map[t.id]=t}getType(e){return this.map[e]}getTypeLayout(e){let t=this.map[e];return t?t.table_layout:void 0}getTypeName(e){let t=this.map[e];return t?t.name:void 0}};const i_=Ye({registry:void 0,isLoading:!1,load:()=>Promise.resolve(),reload:()=>Promise.resolve()});function a_({children:e}){let{store:n,project:r}=Z(),[i,a]=Y(),[o,s]=Y(!1),c=J(!1),l=J(r?.id),u=G(async()=>{if(!(!r||c.current)){c.current=!0,s(!0);try{let e=await n.types.catalog.list({layout:!0});a(new r_(e))}catch(e){console.error(`Failed to fetch types`,e)}finally{s(!1),c.current=!1}}},[n,r]),d=G(async()=>(c.current=!1,u()),[u]);return K(()=>{l.current!==r?.id&&(l.current=r?.id,a(void 0),c.current=!1)}),t(i_.Provider,{value:{registry:i,isLoading:o,load:u,reload:d},children:e})}function o_(){let e=Qe(i_);return K(()=>{!e.registry&&!e.isLoading&&e.load()},[e.registry,e.isLoading,e.load]),e}function s_(e){let{registry:t}=o_(),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t){let e=t.types.map(e=>({label:e.name,value:e.id})),r={name:`types`,placeholder:`Type`,type:`select`,multiple:!0,options:e,filterBy:(t,n)=>e.find(e=>e.value===t)?.label?.toLowerCase().includes(n.toLowerCase())??!1};n.push(r)}return n}function c_(e){return t=>{if(t.length===0){e.clearFilters(!0);return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name;wg(e,n,Cg(t))}}),e.search()}}function l_({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=Y([]),l=s_(e),u=c_(r),d=i!==void 0&&a!==void 0;return t(M,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(A,{}),t(k,{}),t(j,{})]})})}function u_({buckets:e,typeRegistry:r,type:i=`select`,multiple:a=!1}){let o=new Map;return r||console.warn(`Type names cannot be resolved`),e.forEach(e=>{let t,n=e._id;e._id==null?(n=`Document`,t=`Document`):(t=r?.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),o.set(n,{name:t,count:e.count})}),{name:`types`,placeholder:`Types`,type:i,multiple:a,options:e.map(e=>{let t=e._id,n=t||`Document`,r=o.get(n);return{value:t,label:r?`${r.name} (${r.count})`:`Unknown (${e.count})`}}),labelRenderer:e=>{let r=o.get(e);return r?n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:r.name}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,r.count,`)`]})]}):(console.warn(`Type data not found for ${e}`),e)},filterBy:(e,t)=>{let n=o.get(e);return n?n.name.toLowerCase().includes(t.toLowerCase()):(console.warn(`Type name not found for ${e}`),!1)}}}function d_(e){return Array.isArray(e)?e:[]}function f_(e){let{registry:t}=o_(),n=[];if(n.push({placeholder:`ID`,name:`id`,type:`text`,options:[]}),n.push({placeholder:`Name`,name:`name`,type:`text`,options:[]}),e.type){let r=u_({buckets:d_(e.type),typeRegistry:t,type:`select`,multiple:!0});n.push(r)}if(e.status){let t=kg({buckets:d_(e.status),name:`status`,placeholder:`Status`,type:`select`,multiple:!0});n.push(t)}return e.tags&&n.push({name:`tags`,placeholder:`Tags`,type:`stringList`,options:d_(e.tags).map(e=>({label:e._id,value:e._id}))}),n.push({name:`created_at`,placeholder:`Created Date`,type:`date`,multiple:!0,options:[]}),n.push({name:`updated_at`,placeholder:`Updated Date`,type:`date`,multiple:!0,options:[]}),n}function p_(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name,r;if(t.type===`date`&&t.multiple){if(Array.isArray(t.value)&&t.value.length>0)if(t.value.length===1){let e=Sg(t.value[0]);r={gte:e,lte:e}}else t.value.length===2&&(r={gte:Sg(t.value[0]),lte:Sg(t.value[1])})}else r=Cg(t);n===`name`?wg(e,`name`,r):n===`id`?wg(e,`id`,r):wg(e,n,r)}}),e.search()}}function m_({facets:e,search:r}){let[i,a]=Y([]),o=f_(e),s=p_(r);return t(M,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},inModal:Be(),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(A,{}),t(k,{}),t(j,{})]})})}function h_({search:e,buckets:n,placeholder:r=`All Environments`,className:i}){let{client:a}=Z(),[o,s]=Y([]),c=e.getFilterValue(`environment`),l=t=>{e.setFilterValue(`environment`,t?._id)};K(()=>{if(a){let e=n.map(async e=>{let t;return await a.environments.retrieve(e._id).then(e=>{t=e.name}).catch(()=>{t=`${e._id} (deleted)`}),t||=e._id,{...e,name:t}});Promise.all(e).then(e=>{e.sort((e,t)=>e.name.localeCompare(t.name)),s(e)})}},[n,a]);let u=o?.find(e=>e._id===c);return t(V,{filterBy:`name`,className:i,isClearable:!0,optionLabel:Dg,options:o,value:u,onChange:l,by:`_id`,placeholder:r})}function g_(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.push({name:`prompt`,placeholder:`Prompt Name`,type:`text`,multiple:!1}),t.push({name:`model`,placeholder:`Model`,type:`text`,multiple:!1}),t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),t}function __(e){return t=>{if(t.length===0){e.clearFilters(!0,!0);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name;wg(e,n,Cg(t))}}),e.search(!0)}}function v_({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=Y([]),l=g_(e),u=__(r),d=i!==void 0&&a!==void 0;return t(M,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(A,{}),t(k,{}),t(j,{})]})})}function y_(e){let t=[];return t.push(kg({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!1})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function b_({facets:e,filters:r,setFilters:i}){return t(M,{filterGroups:y_(e),filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(A,{}),t(k,{}),t(j,{})]})})}function x_(e){let t=[];return t.push(kg({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!0})),t.push($g({buckets:e.started_by||[],name:`started_by`,placeholder:`Started By`})),t.push(kg({buckets:e.run_type||[],name:`run_type`,placeholder:`Mode`,multiple:!0})),t.push(kg({buckets:e.processes||[],name:`process`,placeholder:`Process`,multiple:!0})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function S_({facets:e,filters:r,setFilters:i}){return t(M,{filterGroups:x_(e),filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(A,{}),t(k,{}),t(j,{})]})})}function C_(e){let t=[];if(t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),e.role&&e.role.length>0){let n={name:`role`,placeholder:`Role`,type:`select`,options:e.role.map(e=>({label:e._id,value:e._id,count:e.count}))};t.push(n)}let n={name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0,options:(e.tags??[]).map(e=>({label:e._id,value:e._id}))};return t.push(n),t}function w_(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name;wg(e,n,Cg(t))}}),e.search()}}function T_({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=Y([]),l=C_(e),u=w_(r),d=i!==void 0&&a!==void 0;return t(M,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(A,{}),t(k,{}),t(j,{})]})})}function E_({buckets:e,name:r}){let i=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:`environment`,placeholder:r.charAt(0).toUpperCase()+r.slice(1),options:i,type:`select`,labelRenderer:r=>{let i=e.find(e=>e._id===r);return n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:i?.name||r}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,i?.count||0,`)`]})]})},filterBy:(t,n)=>(e.find(e=>e._id===t)?.name||t).toLowerCase().includes(n.toLowerCase())}}function D_(e){let t=[];if(t.push({name:`run_ids`,placeholder:`Run ID`,type:`text`,multiple:!1}),e.interactions){let n=Tg({buckets:e.interactions||[],name:`interaction`,placeholder:`Interactions`});t.push(n)}if(e.environments){let n=E_({buckets:e.environments||[],name:`environments`});t.push(n)}if(t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),e.models){let n=kg({buckets:e.models||[],name:`model`});t.push(n)}if(e.statuses){let n=kg({buckets:e.statuses||[],name:`status`});t.push(n)}if(e.finish_reason){let n=kg({buckets:e.finish_reason.map(e=>({...e,_id:e._id===null?`none`:e._id})),name:`finish_reason`,placeholder:`Finish Reason`});t.push(n)}if(e.created_by){let n=$g({buckets:e.created_by||[],name:`created_by`,placeholder:`Created By`});t.push(n)}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`workflow_run_ids`,placeholder:`Workflow Run ID`,type:`text`,multiple:!1}),t.push({name:`workflow_ids`,placeholder:`Workflow ID`,type:`text`,multiple:!1}),t}function O_(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name,r=Cg(t);(n===`run_ids`||n===`workflow_run_ids`||n===`workflow_ids`)&&!Array.isArray(r)&&(r=[r]),wg(e,n,r)}}),e.search()}}function k_({facets:e,search:r,actions:i,selectionCount:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=Y([]),f=D_(e),p=O_(r),m=s!==void 0&&c!==void 0,h=m?s:u;return t(M,{filterGroups:l??f,filters:h,setFilters:e=>{if(m){c(e);return}let t=typeof e==`function`?e(u):e;d(t),p(t)},children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(A,{}),n(`div`,{className:`flex justify-end`,children:[!a&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} calls`:`Loading calls...`})}),i&&i.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:i.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(Pn,{className:`size-5`})})]})]}),h.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(k,{}),t(j,{})]})]})})}function A_({search:e,buckets:n,name:r,placeholder:i,className:a}){let o=e.getFilterValue(r),s=t=>{e.setFilterValue(r,t?._id)},c=n?.find(e=>JSON.stringify(e._id)===JSON.stringify(o));return t(V,{filterBy:`_id`,className:a,isClearable:!0,optionLabel:Eg,options:n,value:c,onChange:s,by:`_id`,placeholder:i})}function j_({search:e,name:n,placeholder:r,className:i}){let[a,o]=Y([]);return K(()=>{e.setFilterValue(n,a)},[n,e,a]),t(I,{className:i,value:a,onChange:o,placeholder:r})}function M_(e){return`${e.name} (${e.count})`}function N_({search:e,buckets:n,placeholder:r=`Filter by Type`,className:i}){let[a,o]=Y([]),{registry:s}=o_(),c=e.getFilterValue(`type`),l=t=>{e.setFilterValue(`type`,t?._id)};K(()=>{if(s){let e=n.map(e=>{let t;return e._id==null?(e._id=`Document`,t=`Document`):(t=s.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),{...e,name:t}});e.sort((e,t)=>e.name.localeCompare(t.name)),o(e)}},[n,s]);let u=a?.find(e=>e._id===c);return t(V,{filterBy:`name`,className:i,isClearable:!0,optionLabel:M_,options:a,value:u,onChange:l,by:`_id`,placeholder:r})}function P_(e){let t=[];return t.push(kg({buckets:e.tags||[],name:`tags`,placeholder:`Tags`,multiple:!0})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function F_({facets:e,filters:r,setFilters:i}){return t(M,{filterGroups:P_(e),filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(A,{}),t(k,{}),t(j,{})]})})}function I_(e){let t=[];if(t.push({placeholder:`Workflow Name or Workflow Run ID`,name:`name`,type:`text`,options:[]}),e.status){let n=kg({buckets:e.status||[],name:`status`,placeholder:`Status`});t.push(n)}if(e.initiated_by){let n=$g({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`});t.push(n)}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`has_reported_errors`,placeholder:`Has Reported Errors`,type:`select`,multiple:!1,options:[{label:`Yes`,value:`true`},{label:`No`,value:`false`}]}),t}function L_(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name,r=Cg(t);if(n===`name`)wg(e,`search_term`,r),wg(e,`name`,r);else if(n===`has_reported_errors`){let t=Array.isArray(r)?r[0]:r;(t===`true`||t===`false`)&&wg(e,n,t===`true`)}else wg(e,n,r)}}),e.search()}}function R_({facets:e,search:r}){let[i,a]=Y([]),o=I_(e),s=L_(r);return t(M,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(A,{}),t(k,{}),t(j,{})]})})}function z_(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function B_({facets:e,filters:r,setFilters:i}){return t(M,{filterGroups:z_(e),filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(A,{}),t(k,{}),t(j,{})]})})}var V_=class e{object;objects;setState;collectionId;singleSelection=!1;constructor(e,t,n,r){this.object=e,this.objects=n,this.setState=r,this.singleSelection=Object.keys(this.objects).length===0,this.collectionId=t}isSingleSelection(){return this.singleSelection}hasSelection(){return this.object!==void 0||this.size()!==0}size(){return Object.keys(this.objects).length}getObjectIds(){return Object.keys(this.objects)}getObjectId(){return this.object?.id}clone(){return new e(this.object,this.collectionId,this.objects,this.setState)}add(e){this.objects[e.id]=e,this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}remove(e){delete this.objects[e],this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}addAll(e){for(let t of e)this.objects[t.id]=t;this.setState(this.clone())}isSelected(e){return this.objects[e]!==void 0}removeAll(){this.objects={},this.singleSelection=!0,this.setState(this.clone())}};const H_=Ye(void 0);function U_(){let e=Qe(H_);if(!e)throw Error(`useObjectSelection must be used within a ObjectSelectionProvider`);return e}function W_(){return Qe(H_)}function G_({value:e,collectionId:n,children:r}){let[i,a]=Y();return K(()=>{let t=new V_(e,n,{},a);a(t)},[n,e]),i&&t(H_.Provider,{value:i,children:r})}const K_=Ye(void 0);function q_({onFilter:e,children:n}){return t(K_.Provider,{value:e,children:n})}function J_(){return Qe(K_)}const Y_=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function X_({field:r,value:i,label:a,copyContent:s}){let c=J_(),l=Array.isArray(i)?i.length>0:i!==void 0&&i!==``;return n(e,{children:[s!==void 0&&s!==``&&t(_,{content:s,className:Y_}),l&&i!==void 0&&t(Me,{description:`Filter by ${a}`,asChild:!0,size:`xs`,children:t(o,{variant:`ghost`,size:`sm`,"aria-label":`Filter by ${a}`,className:Y_,onClick:e=>{e.stopPropagation(),c?.(r,i)},children:t(Yt,{className:`size-3`})})})]})}const Z_=`text/csv`,Q_=`image/`,$_=`application/pdf`,ev=`video/`,tv=[`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/msword`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`,`application/vnd.ms-powerpoint`],nv=e=>e===Z_||Z_.includes(e),rv=e=>e.startsWith(Q_)||Q_.includes(e),iv=e=>e===$_||$_.includes(e),av=e=>e.startsWith(ev)||ev.includes(e),ov=e=>tv.includes(e);function sv(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))});let a=i.createElement(`style`);return a.textContent=`
|
|
314
|
+
`}),s===`stacked`&&t(`div`,{className:V(`sticky top-0 z-10`,v&&`hidden`),children:t(Of,{workstreams:le,activeWorkstream:R,onSelectWorkstream:fe,count:me,completionStatus:qe})}),he.length===0&&!Te&&!(ie&&Be)?R===`all`&&H&&Pe.length===0?t(`div`,{className:`flex-1 px-2 py-6 sm:px-4`,children:t(xp,{label:P(`agent.preparing`),timestamp:we.current,className:y})}):t(`div`,{className:`flex items-center justify-center h-full text-center py-8`,children:t(`div`,{className:`flex items-center px-3 py-2 text-sm text-muted`,children:P(R===`all`?`agent.waitingForAgentResponse`:`agent.noMessagesInWorkstream`)})}):n(`div`,{className:V(`flex-1 flex flex-col justify-start w-full max-w-full`,ie?`gap-6 px-2 py-6 sm:px-4`:`gap-3 pb-4`,b),children:[ie&&R!==`all`&&ue&&t(`div`,{className:`sticky top-0 z-20 -mx-2 bg-background/95 px-2 pb-2 pt-1 backdrop-blur sm:-mx-4 sm:px-4`,children:n(`div`,{className:`mx-auto flex w-full max-w-3xl items-center gap-2 border-b border-border/70 pb-3`,children:[t(o,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 text-muted hover:text-foreground`,title:P(`agent.backToMainAgent`),onClick:pe,children:t(gt,{className:`size-4`,"aria-hidden":`true`})}),t(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:ue})]})}),De&&t(bp,{data:w,schema:T,title:E,template:D,prependFriendlyMessage:C,timestamp:he[0]?.timestamp??Date.now(),isSummaryView:ie,messageItemClassNames:d,messageStyleOverrides:f,StoreLinkComponent:x,CollectionLinkComponent:S},`initial-request`),He&&t(xp,{label:Ve,timestamp:Ke,className:y}),s===`stacked`?n(e,{children:[ze.map((e,n)=>{let r=n===ze.length-1;if(e.type===`tool_group`){let n=e.messages[e.messages.length-1],i=e.toolStatus===`completed`||e.toolStatus===`error`||e.toolStatus===`warning`,a=!c&&r&&!Ll.includes(n.type)&&!i;return m?.includes(s)?null:t(Cm,{status:e.toolStatus,children:t(wm,{children:t(xf,{...p,messages:e.messages,showPulsatingCircle:a,toolRunId:e.toolRunId,toolStatus:e.toolStatus,preambleText:e.preambleText,preambleMessage:e.preambleMessage,rootClassName:V(`rounded-lg border border-border bg-background/60 shadow-none`,p?.rootClassName),headerClassName:V(`px-3 py-2`,p?.headerClassName),itemHeaderClassName:V(`hover:bg-mixer-muted/20`,p?.itemHeaderClassName)})})},qp(e))}else if(e.type===`streaming`)return t(Cm,{children:t(jd,{...h,text:e.text,workstreamId:e.workstreamId,isComplete:e.isComplete,timestamp:e.startTimestamp,artifactRunId:_,cardClassName:V(`rounded-lg border border-border bg-background/60 shadow-none`,h?.cardClassName)})},qp(e));else{let i=e.message;if(xe(i)||Se(i))return null;if(zl(i))return t(Cm,{children:t(xm,{message:i,startTimestamp:Jp(ze,n)??i.timestamp,endTimestamp:i.timestamp})},Kp(i,`stopped`));let a=!c&&r&&!Ll.includes(i.type);return jf(i)?t(wm,{children:t(od,{message:i,batchData:i.details,isRunning:!i.details.completed_at,...g})},`batch-${i.details.batch_id}-${i.timestamp}`):t(Cm,{status:`message`,children:t(wm,{children:t(kd,{...d,message:i,showPulsatingCircle:a,onSendMessage:u,requestInputAnswered:ku(i,ge),cardClassName:V(`rounded-lg border border-border bg-background/60 shadow-none`,d?.cardClassName),headerClassName:V(`px-3 py-2`,d?.headerClassName),contentClassName:V(`bg-transparent`,d?.contentClassName),messageStyleOverrides:f,StoreLinkComponent:x,CollectionLinkComponent:S})})},Kp(i))}}),Pe.map(({id:e,data:n})=>t(Cm,{children:t(jd,{...h,text:n.text,workstreamId:n.workstreamId,isComplete:n.isComplete,timestamp:n.startTimestamp,artifactRunId:_,cardClassName:V(`rounded-lg border border-border bg-background/60 shadow-none`,h?.cardClassName)})},`streaming-incomplete-${e}`)),H&&Pe.length===0&&!He&&t(Cm,{children:n(`div`,{className:V(`flex items-center gap-2 py-2 text-sm text-muted`,y),children:[t(Pu,{size:`sm`,color:`blue`}),t(`span`,{children:P(`agent.working`)})]})})]}):n(e,{children:[Re.map(e=>{if(e.type===`work`){if(m?.includes(s))return null;let n=Bf(e.messages);return t(Sm,{label:Vf(e.isActive),status:e.status,timestamp:e.startTimestamp,durationSeconds:e.isActive?void 0:Pf(e.startTimestamp,e.endTimestamp),showElapsed:!0,details:n?void 0:e.messages,defaultExpanded:e.isActive&&!n,disablePreambleCollapse:e.isActive,className:y,onSendMessage:u,answeredToolApprovalRequestInputKeys:ve,resolvedToolApprovalKeys:_e},`work-${e.id}-${e.isActive?`active`:`done`}-${e.status}`)}if(e.type===`stopped`)return t(xm,{message:e.message,startTimestamp:e.startTimestamp,endTimestamp:e.endTimestamp},Kp(e.message,`stopped-summary`));let n=e.message;return xe(n)||Se(n)?null:jf(n)?t(wm,{children:t(od,{message:n,batchData:n.details,isRunning:!n.details.completed_at,...g})},Kp(n,`batch`)):t(wm,{children:t(dp,{message:n,onSendMessage:u,onSelectWorkstream:fe,requestInputAnswered:ku(n,ge),StoreLinkComponent:x,CollectionLinkComponent:S})},Kp(n,`summary`))}),Pe.map(({id:e,data:n})=>t(bm,{text:n.text,workstreamId:n.workstreamId,artifactRunId:_},`streaming-incomplete-${e}`)),Be&&!He&&t(Sm,{label:Ve,status:`running`,timestamp:Ke,showElapsed:!0,className:y})]}),t(`div`,{ref:a,className:`h-2`})]})]})}const Dm=(e,t)=>{if(e.type!==t.type||e.message!==t.message)return!1;let n=e.details,r=t.details;if(n?.tool_status!==`completed`||r?.tool_status!==`completed`)return!1;let i=typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime();return(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())-i<2e3},Om=W.memo(Em);function km(e){return e?new Map(e.streamingMessages.map((e,t)=>[e.id??e.activityId??`stream-${t}`,e])):new Map}function Am(e,t){return e?.find(e=>e.cursor===t)}function jm(e,t){if(t===0||e===`live`)return`live`;let n=Ka(e,t);return n>=t-1?`live`:n+1}function Mm(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function Nm(e){return Mm(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function Pm(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function Fm({fixture:e,cursor:r,initialCursor:i,onCursorChange:a,autoStepMs:s,repeat:c=1,viewMode:l,className:u,title:d,showHeader:f=!0}){let{t:p}=X(),m=e.messages,h=i??(m.length>0?0:`live`),[g,_]=Y(()=>Ga(h,m.length)),v=r??g,y=l??`sliding`,[b,x]=Y(!!s),[S,C]=Y(0),w=J(null),T=q(()=>Ya(m,v,!0),[v,m]),E=T.displayedMessages,D=q(()=>km(Am(e.streamingFrames,T.cursor)),[e.streamingFrames,T.cursor]),O=G(e=>{let t=Ga(e,m.length);r===void 0&&_(t),a?.(t)},[r,m.length,a]);K(()=>{let e=Ga(v,m.length);e!==v&&O(e)},[v,m.length,O]),K(()=>{if(!s||s<=0||!b)return;let e=window.setInterval(()=>{let e=jm(v,m.length);if(e===`live`&&v===`live`){C(e=>{let t=e+1;return c>0&&t>=c?(x(!1),t):(O(m.length>0?0:`live`),t)});return}O(e)},s);return()=>window.clearInterval(e)},[s,v,b,m.length,c,O]);let k=E.length>0&&!Rl(E),A=q(()=>Au(E),[E]),j=d??e.metadata?.title??p(`agent.rewind.fixtureTitle`),M=G(()=>{let t={...e,metadata:{...e.metadata,title:j,exported_at:e.metadata?.exported_at??new Date().toISOString(),message_count:m.length}},n=e.metadata?.agent_run_id??`fixture`;Pm(`${Nm(j)||`agent-chat`}-${Nm(n)}.json`,t)},[e,m.length,j]),N=G(()=>{O(jm(T.cursor,m.length))},[m.length,T.cursor,O]);return n(`div`,{className:V(`flex h-full min-h-0 w-full flex-col bg-background text-foreground`,u),"data-agent-test-playback-enabled":!0,"data-agent-playback-cursor":T.cursor,"data-agent-live-message-count":m.length,"data-agent-rendered-message-count":T.renderedMessageCount,"data-agent-replay-playing":b||void 0,"data-agent-replay-loop":S,children:[f&&n(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,children:j}),t(`div`,{className:`text-xs text-muted`,children:p(`agent.rewind.fixtureMeta`,{messageCount:m.length,loops:S})})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:M,children:[t(Jt,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(`agent.rewind.exportFixture`)})]}),s&&s>0&&n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>x(e=>!e),children:[t(b?Bn:Hn,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(b?`agent.rewind.pause`:`agent.rewind.resume`)})]})]})]}),t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(to,{cursor:T.cursor,messages:m,onChangeCursor:O})}),t(Om,{messages:E,isCompleted:k,streamingMessages:D,bottomRef:w,artifactRunId:e.metadata?.agent_run_id??`agent-chat-fixture`,viewMode:y,renderRequestInputControls:!A}),A&&t(Mu,{message:A,onSendMessage:N,isLoading:!1})]})}function Im({className:e,inline:r=!1}){return n(`div`,{className:V(`flex items-center gap-1`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-blue-500 rounded-full animate-[jumping_1s_infinite_ease-in-out] hover:bg-blue-600`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-blue-500 rounded-full animate-[jumping_1s_0.3s_infinite_ease-in-out] hover:bg-blue-600`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-blue-500 rounded-full animate-[jumping_1s_0.6s_infinite_ease-in-out] hover:bg-blue-600`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}})]})}function Lm(){let{client:e}=Z(),[t,n]=Y([]),[r,i]=Y(!0),[a,o]=Y(!1),s=J(0),c=G(async()=>{let t=s.current+1;s.current=t,i(!0),o(!1);try{let r=await e.apps.getInstalledApps(`tools`),a=[];for(let e of r){let t=e,n=t.oauth_collection_ids??[],r=t.manifest.oauth_providers??{};if(!t.manifest.tool_collections)continue;let i=t.manifest.tool_collections.map(e=>Jr(e)).filter(e=>e.type===`mcp`&&n.includes(e.id)),o=new Map,s=new Map,c=[];for(let e of i)if(e.oauth_provider){let t=o.get(e.oauth_provider)??[];t.push(e),o.set(e.oauth_provider,t)}else if(e.oauth_app){let t=s.get(e.oauth_app)??[];t.push(e),s.set(e.oauth_app,t)}else c.push(e);for(let[e,n]of o)a.push({key:`${t.id}:provider:${e}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:r[e]?.display_name||e,representativeId:n[0].id,memberIds:n.map(e=>e.id),memberNames:n.map(e=>e.name)});for(let[e,n]of s)a.push({key:`${t.id}:oauthapp:${e}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e,representativeId:n[0].id,memberIds:n.map(e=>e.id),memberNames:n.map(e=>e.name)});for(let e of c)a.push({key:`${t.id}:individual:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name]})}if(s.current!==t||(n(a),i(!1),a.length===0))return;o(!0);let c=new Map,l=await Promise.all(a.map(async t=>{try{let n=c.get(t.appId);n||(n=e.remoteMcpConnections.getStatus(t.appId),c.set(t.appId,n));let r=(await n).find(e=>e.collection_id===t.representativeId);return{...t,authStatus:r}}catch{return t}}));if(s.current!==t)return;n(l)}catch(e){s.current===t&&(console.error(`Failed to load MCP tool collections:`,e),n([]))}finally{s.current===t&&(i(!1),o(!1))}},[e]);return K(()=>{c()},[c]),{groups:t,loading:r,statusLoading:a,reload:c}}function Rm(e,t){return t?.length?e.memberIds.every(e=>t.includes(e)):!1}function zm(e,t,n){let r=new Set(t??[]);if(n)for(let t of e.memberIds)r.delete(t);else for(let t of e.memberIds)r.add(t);return Array.from(r)}function Bm(e,t){return e.filter(e=>e.authStatus?.authenticated===!0&&!Rm(e,t)).length}function Vm(e,t){return e.filter(e=>e.authStatus?.authenticated===!0&&!Rm(e,t)).map(e=>e.label)}function Hm({isOpen:e,onClose:r,groups:i,loading:a,statusLoading:o=!1,reload:s,disabledCollections:c,onChange:l,onConnectionChange:u,readOnly:d=!1}){let{t:f}=X(),p=()=>{s(),u?.()};return n(Uo,{isOpen:e,onClose:r,size:`md`,className:`max-w-[92vw] sm:max-w-[620px] lg:max-w-[620px]`,children:[t(Wo,{children:f(`mcpConnections.title`)}),n(Go,{children:[t(`p`,{className:`mb-4 text-sm text-muted`,children:f(`mcpConnections.subtitle`)}),a?t(`div`,{className:`flex items-center justify-center py-8`,children:t(Ls,{className:`size-5`})}):i.length===0?t(`div`,{className:`py-8 text-center text-sm text-muted`,children:f(`mcpConnections.empty`)}):t(`div`,{className:`space-y-1`,children:i.map(e=>{let r=!Rm(e,c),i=e.authStatus?.authenticated===!0;return n(`div`,{className:`flex items-center justify-between gap-3 py-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[t(i?Tn:En,{className:`size-4 shrink-0 ${i?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(uo,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:e.appName}),e.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:e.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`truncate ${r?`text-foreground`:`text-muted line-through`}`,children:e.label})})]}),n(`div`,{className:`flex shrink-0 items-center gap-3`,children:[o&&!e.authStatus?t(go,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:f(`mcpConnections.checkingStatus`),children:t(Ls,{className:`size-3`})}):t(Bs,{appId:e.appId,collectionId:e.representativeId,collectionName:e.label,authenticated:e.authStatus?.authenticated,onAuthChange:p,variant:`compact`,showDisconnect:!0,readOnly:d}),l&&t(ks,{size:`sm`,value:r,onChange:t=>l(zm(e,c,t)),disabled:d,"aria-label":f(r?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:e.label})})]})]},e.key)})})]})]})}function Um({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1,variant:s=`outline`,size:c=`sm`}){let{t:l}=X(),{groups:u,loading:d,statusLoading:f,reload:p}=Lm(),[m,h]=Y(!1);if(!d&&u.length===0)return null;let g=Bm(u,r),_=Vm(u,r),v=_.slice(0,2),y=_.length-v.length,b=v.length>0?`${v.join(`, `)}${y>0?` +${y}`:``}`:void 0;return n(e,{children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b&&t(`span`,{className:`max-w-48 truncate text-muted`,title:_.join(`, `),children:b}),n(go,{variant:s,size:c,className:`shrink-0`,onClick:()=>h(!0),disabled:d,"aria-label":l(`mcpConnections.manage`),children:[t(`span`,{children:l(`mcpConnections.label`)}),g>0&&t(bo,{variant:`success`,children:g})]})]}),t(Hm,{isOpen:m,onClose:()=>h(!1),groups:u,loading:d,reload:p,statusLoading:f,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}function Wm({disabledCollections:e,onChange:r,onConnectionChange:i,readOnly:a=!1}){let{t:o}=X(),{groups:s,loading:c,statusLoading:l,reload:u}=Lm();if(!c&&s.length===0)return null;let d=()=>{u(),i?.()};return c&&s.length===0?n(`div`,{className:`flex items-center gap-2 border-y border-border/70 py-2 text-sm text-muted`,children:[t(Ls,{className:`size-4`}),t(`span`,{children:o(`mcpConnections.label`)})]}):t(`div`,{className:`space-y-1`,children:s.map(i=>{let s=!Rm(i,e),c=i.authStatus?.authenticated===!0;return n(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 text-sm`,children:[n(`div`,{className:`flex min-w-36 flex-1 items-center gap-2`,children:[t(c?Tn:En,{className:`size-4 shrink-0 ${c?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(uo,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:i.appName}),i.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:i.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`block truncate ${s?`text-foreground`:`text-muted line-through`}`,children:i.label})})]}),l&&!i.authStatus?t(go,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:o(`mcpConnections.checkingStatus`),children:t(Ls,{className:`size-3`})}):t(Bs,{appId:i.appId,collectionId:i.representativeId,collectionName:i.label,authenticated:i.authStatus?.authenticated,onAuthChange:d,variant:`compact`,showDisconnect:!0,readOnly:a}),r&&n(`div`,{className:`flex min-w-24 items-center justify-end gap-2 text-xs`,children:[t(`span`,{className:s?`text-muted`:`text-attention`,children:o(s?`mcpConnections.enabled`:`mcpConnections.disabled`)}),t(ks,{size:`sm`,value:s,onChange:t=>r(zm(i,e,t)),disabled:a,"aria-label":o(s?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:i.label})})]})]},i.key)})})}function Gm({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1}){let{t:s}=X(),{groups:c,loading:l,statusLoading:u,reload:d}=Lm(),[f,p]=Y(!1);if(!l&&c.length===0)return null;let m=Bm(c,r);return n(e,{children:[t(ps,{align:`left`,trigger:t(go,{variant:`ghost`,size:`icon`,className:`size-8 rounded-md text-muted hover:bg-muted`,title:s(`mcpConnections.settings`),disabled:l,children:t(`span`,{className:`flex size-5 items-center justify-center rounded-[3px] border border-muted text-sm font-semibold leading-none`,"aria-hidden":`true`,children:`/`})}),children:n(ms,{onClick:()=>p(!0),isDisabled:l,children:[t(`span`,{children:s(`mcpConnections.title`)}),m>0&&t(bo,{variant:`success`,children:m})]})}),t(Hm,{isOpen:f,onClose:()=>p(!1),groups:c,loading:l,reload:d,statusLoading:u,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}const Km=/(^|\/)(tool-inputs|tool-results|archive)(\/|$)/,qm=/(^|\/)process\/(history|state)(\/|$)/,Jm=[/conversation\.json$/,/^conversation-checkpoint-\d+\.json$/,/^tools\.json$/,/^tool-input-refs\.json$/,/^toolu[_-]/i];function Ym(e){if(Km.test(e)||qm.test(e))return!0;let t=e.split(`/`).pop()??e;return Jm.some(e=>e.test(t))}function Xm(e){let t={name:``,path:``,isDirectory:!0,children:[]};for(let n of e){let e=n.split(`/`),r=t,i=``;for(let t=0;t<e.length;t++){let n=e[t];i=i?`${i}/${n}`:n;let a=t===e.length-1,o=r.children.find(e=>e.name===n);o||(o={name:n,path:i,isDirectory:!a,children:[]},r.children.push(o)),r=o}}let n=e=>{e.children.sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1),e.children.forEach(n)};return n(t),t.children}function Zm(e,t){let n=`agents/${t}/`,r=e.indexOf(n);return r===-1?e.split(`/`).pop()??e:e.slice(r+n.length)}function Qm(e,t,n=0,r=!1){let[i,a]=Y([]),[o,s]=Y(!1),[c,l]=Y(null),[u,d]=Y(0),f=J(0),p=G(async()=>{if(!t)return;let n=++f.current;s(!0),l(null);try{let r=await e.files.listArtifacts(t);if(n!==f.current)return;let i=r.map(e=>Zm(e,t)).filter(e=>!!e);a(i)}catch(e){if(n!==f.current)return;l(e instanceof Error?e.message:`Failed to list artifacts`),a([])}finally{n===f.current&&s(!1)}},[e,t]);K(()=>{p()},[p,n,u]);let m=q(()=>r?i:i.filter(e=>!Ym(e)),[i,r]),h=q(()=>Xm(m),[m]),g=i.length-m.length,_=G(()=>{d(e=>e+1)},[]);return{tree:h,flatFiles:m,totalCount:i.length,systemHiddenCount:g,isLoading:o,error:c,refresh:_}}const $m=W.lazy(async()=>({default:(await Promise.resolve().then(()=>Ry)).UniversalDocumentViewer}));function eh(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function th({node:e,depth:r,runId:i,onPreview:a,onDownload:s,downloadingPath:c,forceExpanded:l=!1}){let[u,d]=Y(!1),f=l||u;if(e.isDirectory)return n(`div`,{className:`min-w-0`,children:[n(o,{variant:`unstyled`,className:`flex w-full max-w-full items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>d(e=>!e),"aria-expanded":f,children:[f?t(kt,{className:`size-3.5 shrink-0 text-muted`}):t(Mt,{className:`size-3.5 shrink-0 text-muted cn-rtl-flip`}),t(f?dn:un,{className:`size-4 shrink-0 text-info`}),t(`span`,{className:`min-w-0 truncate font-medium`,title:e.path,children:eh(e.name)})]}),f&&e.children.map(e=>t(th,{node:e,depth:r+1,runId:i,onPreview:a,onDownload:s,downloadingPath:c,forceExpanded:l},`${i}:${e.path}`))]});let p=c===e.path;return n(`div`,{className:`group flex min-w-0 items-center gap-1.5 rounded text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 px-1 py-1 text-start`,onClick:()=>a(e.path),title:e.path,children:[t(`span`,{className:`size-3.5 shrink-0`}),t(nn,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.name})]}),n(`div`,{className:`flex shrink-0 items-center pe-1 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[t(o,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,onClick:()=>a(e.path),"aria-label":`Preview artifact`,children:t(en,{className:`size-3.5`})}),t(o,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,onClick:()=>s(e.path),disabled:p,"aria-label":`Download artifact`,children:p?t(On,{className:`size-3.5 animate-spin text-info`}):t(Yt,{className:`size-3.5`})})]})]})}function nh(e){return e.reduce((e,t)=>t.isDirectory?e+nh(t.children):e+1,0)}function rh(e,t){let n=t.trim().toLocaleLowerCase();return n?e.flatMap(e=>{let t=`${e.name} ${e.path}`.toLocaleLowerCase().includes(n);if(!e.isDirectory)return t?[e]:[];let r=rh(e.children,n);return t?[{...e}]:r.length>0?[{...e,children:r}]:[]}):e}function ih(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function ah(e){switch(e.split(`.`).pop()?.toLowerCase()){case`css`:return`text/css`;case`gif`:return`image/gif`;case`htm`:case`html`:return`text/html`;case`jpeg`:case`jpg`:return`image/jpeg`;case`json`:return`application/json`;case`md`:case`markdown`:return`text/markdown`;case`pdf`:return`application/pdf`;case`png`:return`image/png`;case`svg`:return`image/svg+xml`;case`ts`:case`tsx`:return`text/typescript`;case`txt`:return`text/plain`;case`webp`:return`image/webp`;default:return}}function oh({icon:e,children:r,action:i}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r}),i]})}function sh({runId:r,refreshKey:i=0}){let{t:a}=X(),{client:s}=Z(),[c,l]=Y(!1),{tree:u,flatFiles:d,totalCount:f,systemHiddenCount:m,isLoading:h,error:g,refresh:_}=Qm(s,r,i,c),[v,y]=Y(null),[b,x]=Y(null),[S,C]=Y(``),w=S.trim(),T=q(()=>rh(u,w),[u,w]),E=q(()=>nh(T),[T]),D=ot(),O=G(async e=>{if(r){y(e);try{let{url:t}=await s.files.getArtifactDownloadUrl(r,e,`attachment`);ih(t,e.split(`/`).pop()||`artifact`)}catch(e){console.error(`Failed to get artifact download URL:`,e)}finally{y(null)}}},[s,r]),k=G(e=>{x(e)},[]),A=r&&b?{title:b.split(`/`).pop()||b,fileName:b.split(`/`).pop()||b,contentType:ah(b),artifact:{runId:r,path:b}}:null;return r?h&&f===0?t(oh,{icon:t(On,{className:`mb-2 size-6 animate-spin`}),children:a(`agent.loadingArtifacts`)}):g?t(`div`,{className:`flex flex-col items-center justify-center p-4 text-muted w-full`,children:n(M,{title:`Fail to load Artifacts`,className:`w-full`,action:_,actionLabel:n(e,{children:[t(Jn,{className:`size-3.5 me-1.5`}),a(`agent.retry`)]}),children:[t(`span`,{className:`break-all text-muted`,children:g}),` `,t(`br`,{})]})}):f===0?t(oh,{icon:t(Rn,{className:`mb-2 size-8`}),action:n(o,{variant:`ghost`,size:`sm`,className:`mt-2`,onClick:_,children:[t(Jn,{className:`size-3.5 me-1.5`}),a(`agent.refresh`)]}),children:a(`agent.noArtifactsYet`)}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[n(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted`,children:[n(`span`,{children:[w?`${E} of ${d.length} file${d.length===1?``:`s`}`:`${d.length} file${d.length===1?``:`s`}`,!c&&m>0?` · ${m} hidden`:``]}),n(`div`,{className:`flex items-center gap-1`,children:[t(Oe,{size:`sm`,value:c,onChange:l,children:t(`span`,{className:`text-xs text-muted`,children:a(`agent.showSystemArtifacts`)})}),t(o,{variant:`ghost`,size:`sm`,onClick:_,disabled:h,className:`h-6 w-6 p-0`,children:t(Jn,{className:`size-3.5 ${h?`animate-spin`:``}`})})]})]}),t(`label`,{htmlFor:D,className:`sr-only`,children:a(`form.filter`)}),t(ee,{id:D,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:a(`store.searchPlaceholder`),value:S,onChange:C,clearable:!0})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:T.length>0?t(`div`,{className:`min-w-0`,children:T.map(e=>t(th,{node:e,depth:0,runId:r,onPreview:k,onDownload:O,downloadingPath:v,forceExpanded:!!w},`${r}:${e.path}`))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:a(!c&&m>0?`agent.onlySystemArtifacts`:`agent.noContentAvailable`)})}),A&&n(ie,{isOpen:!!b,onClose:()=>x(null),size:`xl`,className:`h-[90vh] p-0`,description:`Artifact preview`,children:[t(se,{show:!1,children:A.fileName}),t(ae,{className:`h-full max-h-none p-0`,children:t(W.Suspense,{fallback:t(p,{className:`h-full`,children:t(On,{className:`size-6 animate-spin text-muted`})}),children:t($m,{source:A,className:`h-full`,onDownload:()=>b&&void O(b)})})})]})]}):t(oh,{icon:t(Rn,{className:`mb-2 size-8`}),children:`No run selected`})}const ch=W.memo(sh);function lh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function uh(e){if(!lh(e))return;let t=e.browseruse??e.browser_use;if(!lh(t))return;let n={widget:typeof t.widget==`string`?t.widget:void 0,browser_workflow_id:typeof t.browser_workflow_id==`string`?t.browser_workflow_id:void 0,workstream_id:typeof t.workstream_id==`string`?t.workstream_id:void 0,phase:typeof t.phase==`string`?t.phase:void 0,url:typeof t.url==`string`?t.url:void 0,title:typeof t.title==`string`?t.title:void 0,screenshot:typeof t.screenshot==`string`?t.screenshot:void 0,raw_screenshot:typeof t.raw_screenshot==`string`?t.raw_screenshot:void 0,prefer_raw_screenshot:typeof t.prefer_raw_screenshot==`boolean`?t.prefer_raw_screenshot:void 0,updated_at:typeof t.updated_at==`number`?t.updated_at:void 0};if(!(n.widget&&n.widget!==`browseruse`)&&!(!n.url&&!n.title&&!n.screenshot&&!n.raw_screenshot))return n}function dh(e){let t=new Map;for(let n of e){let e=uh(n.details);if(!e)continue;let r=e.workstream_id||n.workstream_id||`main`,i=e.updated_at??(typeof n.timestamp==`number`?n.timestamp:new Date(n.timestamp).getTime()),a=t.get(r);(!a||i>=a.timestamp)&&t.set(r,{state:{...e,workstream_id:r},timestamp:i})}return new Map(Array.from(t.entries()).map(([e,t])=>[e,t.state]))}function fh(e){return e.replace(/^artifact:\/\//,``).replace(/^artifact:/,``).replace(/^\/+/,``)}function ph(e){return e?e.replace(/_/g,` `):`browser`}function mh({state:e,runId:r,className:a,compact:o}){let{t:s}=X(),{client:c}=Z(),l=Ca(),{openImage:u}=Vu(),[d,f]=Y(),p=e.prefer_raw_screenshot===!1?e.screenshot||e.raw_screenshot:e.raw_screenshot||e.screenshot,m=e.title||e.url||s(`agent.browserUse`),h=q(()=>p&&fh(p).split(`/`).pop()||s(`agent.browserScreenshot`),[p,s]);return K(()=>{if(!p){f(void 0);return}if(p.startsWith(`http://`)||p.startsWith(`https://`)){f(p);return}if(!r){f(void 0);return}let e=!1;return(async()=>{let t=fh(p);try{let n=Ta(r,t,`inline`),i=l?await l.getOrFetch(n,async()=>(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url):(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url;e||f(i)}catch(n){console.error(`Failed to resolve browser screenshot ${t}`,n),e||f(void 0)}})(),()=>{e=!0}},[c,r,p,l]),o?n(`div`,{className:V(`overflow-hidden rounded-md border border-border/70 bg-transparent`,a),children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[t(Fn,{className:`size-3.5 shrink-0 text-info`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserPreview`)}),e.phase&&n(`span`,{className:`truncate text-[11px] capitalize text-muted`,children:[`· `,ph(e.phase)]})]}),t(`div`,{className:`truncate text-[11px] text-muted`,title:m,children:m})]}),e.url&&t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:V(`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Qt,{className:`size-3`})})]}),p&&(d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-32 w-full object-contain`})}):n(`div`,{className:`flex min-h-16 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-4 text-xs text-muted`,children:[t(vn,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}))]}):n(`div`,{className:V(`overflow-hidden rounded-md border border-muted bg-mixer-muted/10`,a),children:[n(`div`,{className:`flex items-start justify-between gap-2 border-b border-muted px-2.5 py-2`,children:[n(`div`,{className:`flex min-w-0 items-start gap-2`,children:[t(Fn,{className:`mt-0.5 size-4 shrink-0 text-info`}),n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserUse`)}),t(`div`,{className:`truncate text-xs text-muted`,title:m,children:m})]})]}),t(i,{variant:`info`,className:`shrink-0 capitalize`,children:ph(e.phase)})]}),d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-56 w-full object-contain`})}):n(`div`,{className:`flex min-h-28 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-6 text-xs text-muted`,children:[t(vn,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}),e.url&&n(`div`,{className:`flex items-center gap-2 border-t border-muted px-2.5 py-1.5`,children:[t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 truncate text-xs text-info hover:underline`,title:e.url,children:e.url}),t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:V(`inline-flex h-6 shrink-0 items-center justify-center rounded-md px-1.5`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Qt,{className:`size-3`})})]})]})}function hh({documents:e,activeId:n,onSelect:r}){return e.length===0?null:t(`div`,{className:`flex items-center gap-1 px-2 py-1.5`,children:t(w,{align:`right`,trigger:t(o,{variant:`ghost`,size:`xs`,title:`All opened documents`,className:`flex items-center gap-1.5 max-w-[220px] text-xs h-7 px-2`,children:t(kt,{className:`size-3 shrink-0`})}),children:e.map(e=>t(B,{onClick:()=>r(e.id),className:e.id===n?`font-medium`:``,children:t(`span`,{className:`truncate max-w-[200px]`,children:e.title})},e.id))})})}function gh({isOpen:e,documents:r,activeDocumentId:i,onSelectDocument:a,onCloseDocument:s,onUpdateDocumentTitle:c,refreshKey:l,runId:u}){let{client:d}=Z(),{t:f}=X(),[p,m]=Y(null),[h,g]=Y(!1),[_,v]=Y(null),[y,b]=Y(null),x=G(async e=>{g(!0),v(null);try{let[t,n]=await Promise.all([d.store.objects.getObjectText(e),d.store.objects.retrieve(e)]);m(t.text??null);let r=n.name;b(r),r&&c?.(e,r)}catch(e){let t=e instanceof Error?e.message:f(`agent.failedToLoadDocument`);v(t),m(null)}finally{g(!1)}},[d,c,f]);return K(()=>{i&&e&&x(i)},[i,l,e,x]),!e||r.length===0?null:n(`div`,{className:`h-full shadow-xl border border-muted/20 overflow-hidden flex flex-col`,children:[n(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-muted/20 shrink-0`,children:[n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(sn,{className:`size-4 text-muted shrink-0`}),t(`h3`,{className:`font-bold text-sm truncate`,children:y||f(`agent.document`)})]}),n(`div`,{className:`flex items-center gap-1`,children:[t(hh,{documents:r,activeId:i,onSelect:a}),i&&t(Ei,{href:`/store/objects/${i}#overview`,topLevelNav:!0,className:`inline-flex items-center justify-center rounded-md text-sm font-medium h-8 w-8 hover:bg-muted/20 text-muted hover:text-foreground`,children:t(ze,{description:f(`agent.openDocument`),placement:`top`,size:`xs`,children:t(Qt,{className:`size-4`})})}),t(o,{variant:`ghost`,size:`sm`,onClick:()=>i&&s(i),title:f(`agent.close`),children:t(yr,{className:`size-4`})})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:h?n(`div`,{className:`flex items-center justify-center py-12`,children:[t(On,{className:`size-5 animate-spin text-muted`}),t(`span`,{className:`ms-2 text-sm text-muted`,children:f(`agent.loadingDocument`)})]}):_?t(`div`,{className:`p-4 rounded-md bg-destructive/10 text-destructive text-sm`,children:_}):p?t(`div`,{className:`prose prose-sm dark:prose-invert max-w-none`,children:t(Li,{artifactRunId:u,children:p})}):n(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted`,children:[t(sn,{className:`size-8 mb-2`}),t(`span`,{className:`text-sm`,children:f(`agent.noContentAvailable`)})]})})]})}const _h=W.memo(gh);function vh({plan:e,workstreamStatus:r,isOpen:i,onClose:a,plans:s=[],activePlanIndex:c=0,onChangePlan:l=()=>{}}){let{t:u}=X();if(!i)return null;let d=e.plan||[],f=d.length,m=d.reduce((e,t)=>t?.id&&(r.get(t.id.toString())===`completed`||t.status===`completed`)?e+1:e,0),h=f>0?Math.round(m/f*100):0,g=s.length>0?s.length-c:1,_=s[c]?.timestamp;return d.length===0?t(`div`,{className:`h-full overflow-hidden`,children:n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[t(Vt,{className:`mb-2 size-8`}),t(`span`,{className:`text-sm`,children:u(`agent.noPlanAvailable`)})]})}):t(`div`,{className:`h-full overflow-hidden`,children:n(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto px-2 py-3`,children:[n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex items-start justify-between gap-3`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-sm font-medium text-foreground`,children:u(`agent.taskProgress`)}),t(`div`,{className:`text-xs text-muted`,children:u(`agent.tasksCompleted`,{completed:m,total:f})})]}),s.length>1&&n(`div`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted`,children:[t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.min(s.length-1,c+1)),disabled:c>=s.length-1,"aria-label":u(`agent.olderPlan`),title:u(`agent.olderPlan`),children:t(At,{className:`size-4`,"aria-hidden":`true`})}),n(`div`,{className:`min-w-20 text-center`,children:[n(`div`,{className:`font-medium text-foreground`,children:[g,`/`,s.length]}),t(`div`,{className:`truncate`,children:_?new Date(_).toLocaleTimeString():u(`agent.unknownTime`)})]}),t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.max(0,c-1)),disabled:c<=0,"aria-label":u(`agent.newerPlan`),title:u(`agent.newerPlan`),children:t(jt,{className:`size-4`,"aria-hidden":`true`})})]})]}),t(`div`,{className:`h-2 overflow-hidden rounded-full bg-mixer-muted/20`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":f,"aria-valuenow":m,"aria-label":u(`agent.taskProgress`),children:t(`div`,{className:`h-full rounded-full bg-success transition-all duration-300`,style:{width:`${h}%`}})})]}),t(`ol`,{className:`divide-y divide-border/60`,children:d.map((e,i)=>{let a=e.id?e.id.toString():`task-${i}`,o=e.goal||`Task ${i+1}`,s=e.id?`task-${e.id.toString()}`:`task-${o}-${e.status||`pending`}`,c=e.status||`pending`,l=r.get(a);l!==void 0&&(c=l);let d=zt,f=`text-muted`;c===`in_progress`?(d=Ht,f=`text-info`):c===`completed`&&(d=wt,f=`text-success`);let p=u(c===`completed`?`agent.completed`:c===`in_progress`?`agent.inProgress`:`agent.pending`);return n(`li`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-3 px-1 py-3`,children:[t(`span`,{className:`mt-0.5 min-w-5 text-center text-xs font-medium tabular-nums text-muted/80`,children:a}),t(`span`,{className:`min-w-0 text-sm leading-5 text-foreground/85`,children:o}),n(`span`,{className:V(`flex items-center gap-1.5 text-xs font-medium`,f),children:[t(d,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t(`span`,{children:p})]})]},s)})}),(()=>{let e=new Set(d.filter(e=>e?.id).map(e=>e.id.toString())),i=Array.from(r.entries()).filter(([t])=>t!==`main`&&!e.has(t));return i.length>0?n(`div`,{className:`mt-1 px-1 py-2`,children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:u(`agent.workstreams`)}),t(`div`,{className:`divide-y divide-border/60`,children:i.map(([e,r])=>{let i=zt,a=`text-muted`,o=u(`agent.pending`);return r===`in_progress`?(i=Ht,a=`text-info`,o=u(`agent.inProgress`)):r===`completed`&&(i=wt,a=`text-success`,o=u(`agent.completed`)),n(`div`,{className:`flex items-center gap-2 py-2`,children:[t(i,{className:V(`size-3.5 shrink-0`,a)}),t(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground/80`,children:e}),t(`span`,{className:`text-xs font-medium text-muted`,children:o})]},e)})})]}):null})()]})})}const yh=W.memo(vh);function bh({icon:e,children:r}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r})]})}function xh({files:e}){let{t:r}=X(),a=q(()=>e?Array.from(e.values()):[],[e]),o=e=>{switch(e){case Nr.UPLOADING:case Nr.PROCESSING:return t(On,{className:`size-4 animate-spin text-info`});case Nr.READY:return t(Et,{className:`size-4 text-success`});case Nr.ERROR:return t(xr,{className:`size-4 text-destructive`});default:return t(sn,{className:`size-4 text-muted`})}},s=e=>{switch(e){case Nr.UPLOADING:return t(i,{variant:`info`,children:r(`agent.uploading`)});case Nr.PROCESSING:return t(i,{variant:`info`,children:r(`agent.processing`)});case Nr.READY:return t(i,{variant:`success`,children:r(`agent.ready`)});case Nr.ERROR:return t(i,{variant:`destructive`,children:r(`agent.error`)});default:return null}};return t(`div`,{className:`h-full min-h-0`,children:a.length===0?t(bh,{icon:t(sn,{className:`mb-2 size-8`}),children:r(`agent.noFilesUploadedYet`)}):t(`div`,{className:`space-y-2 p-2`,children:a.map(e=>n(`div`,{className:`flex items-start gap-2 p-2 border border-muted rounded-md`,children:[t(`div`,{className:`mt-0.5`,children:o(e.status)}),n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`span`,{className:`text-sm font-medium truncate`,children:e.name}),s(e.status)]}),e.error&&t(`div`,{className:`text-xs text-destructive mt-1`,children:e.error})]})]},e.id))})})}var Sh=class extends W.Component{state={hasError:!1};static getDerivedStateFromError(e){return{hasError:!0,message:e instanceof Error?e.message:String(e)}}componentDidCatch(e,t){console.error(`Agent right panel section failed to render`,{error:e,componentStack:t.componentStack})}render(){return this.state.hasError?n(`div`,{className:V(`rounded-md border border-destructive bg-mixer-destructive/10 text-destructive`,this.props.compact?`p-2 text-xs`:`m-3 p-3 text-sm`),children:[t(`div`,{className:`font-medium`,children:this.props.title}),t(`div`,{className:`mt-1 text-xs text-muted`,children:this.props.description}),this.state.message&&t(`div`,{className:`mt-1 break-all text-[11px] text-muted`,children:this.state.message})]}):this.props.children}};function Ch({workstreams:e,messages:r,runId:a}){let{t:s}=X(),{client:c}=Z(),l=Ye(),u=q(()=>dh(r),[r]),d=s(`agent.panelRenderErrorDescription`),f=G(e=>{navigator.clipboard.writeText(e),l({status:`success`,title:s(`agent.runIdCopied`),duration:2e3})},[s,l]),p=G(async e=>{try{let t=await Gl(c,e);t&&window.open(t,`_blank`)}catch{l({status:`error`,title:s(`agent.failedToDownload`)})}},[c,s,l]);return e.length===0?t(bh,{icon:t(Cn,{className:`mb-2 size-8`}),children:s(`agent.noActiveParallelTasks`)}):n(`div`,{className:`h-full min-h-0 overflow-y-auto px-2 py-2`,children:[t(`div`,{className:`px-1 pb-2 text-xs text-muted`,children:s(`agent.parallelWorkDescription`)}),t(`div`,{className:`divide-y divide-border/60`,children:e.map(e=>{let r=e.status===`running`||e.status===`canceling`,c=Math.round(e.elapsed_ms/1e3),l=Math.max(0,Math.round(e.remaining_ms/1e3)),m=e.deadline_ms>0?Math.min(100,Math.round(e.elapsed_ms/e.deadline_ms*100)):0,h=u.get(e.workstream_id),g=e.deadline_ms>0,_=e.child_workflow_run_id,v=[e.phase?xl(e.phase):void 0,c>0?s(`agent.elapsed`,{seconds:c}):void 0,g&&l>0?s(`agent.remaining`,{seconds:l}):void 0].filter(Boolean),y=(()=>{switch(e.status){case`running`:return t(i,{variant:`info`,children:s(`agent.running`)});case`canceling`:return t(i,{variant:`attention`,children:s(`agent.canceling`)});case`completed`:return t(i,{variant:`done`,children:s(`agent.completed`)});case`failed`:return t(i,{variant:`destructive`,children:s(`agent.failed`)});case`timeout`:return t(i,{variant:`destructive`,children:s(`agent.timeout`)});case`canceled`:return t(i,{variant:`destructive`,children:s(`agent.canceled`)})}})();return t(Sh,{title:s(`agent.workstreamRenderError`),description:d,compact:!0,children:t(`div`,{className:`py-3`,children:n(`div`,{className:`flex items-start gap-2`,children:[t(`span`,{className:V(`mt-2 size-2 shrink-0 rounded-full`,kl(e.status)),"aria-hidden":`true`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[t(`span`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,title:e.workstream_id,children:xl(e.workstream_id)}),y]}),v.length>0&&t(`div`,{className:`mt-0.5 truncate text-xs text-muted`,children:v.join(` · `)}),r&&g&&t(`div`,{className:`mt-2 h-1 rounded-full bg-muted`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m,"aria-valuetext":s(`agent.workstreamProgress`,{percent:m}),children:t(`div`,{className:`h-full rounded-full bg-info transition-all duration-500`,style:{width:`${m}%`}})}),h&&t(Sh,{title:s(`agent.browserWidgetRenderError`),description:d,compact:!0,children:t(mh,{state:h,runId:a,compact:!0,className:`mt-2`})}),_&&n(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>f(_),children:[t(Bt,{className:`size-3 me-1`}),s(`agent.copyRunId`)]}),n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>p(_),children:[t(Jt,{className:`size-3 me-1`}),s(`agent.download`)]})]})]})]})})},e.launch_id)})})]})}const wh=`flex items-center border-b-2 px-2 py-1.5 text-sm font-medium whitespace-nowrap cursor-pointer shrink-0`,Th=`border-transparent text-muted-foreground hover:border-border hover:text-foreground`,Eh=`border-primary text-primary`;function Dh({tabs:e,current:r,onTabChange:i,label:a,active:o}){let[s,c]=Y(!1),l=J(null),u=J(!1),d=()=>{l.current&&=(clearTimeout(l.current),null)},f=()=>{d(),u.current=!0,c(!0)},p=()=>{d(),l.current=setTimeout(()=>c(!1),150)};return K(()=>()=>clearTimeout(l.current??void 0),[]),n(T,{modal:!1,open:s,onOpenChange:e=>{d(),e&&(u.current=!1),c(e)},children:[t(A,{asChild:!0,children:n(`button`,{type:`button`,onMouseEnter:f,onMouseLeave:p,className:V(wh,o?Eh:Th),children:[a,t(kt,{className:`ms-1 size-4`})]})}),t(E,{align:`end`,className:`w-max`,onMouseEnter:d,onMouseLeave:p,onCloseAutoFocus:e=>{u.current&&e.preventDefault()},children:e.map(e=>t(D,{disabled:e.disabled,onClick:()=>i(e.name),className:V(e.name===r&&`text-primary`),children:e.label},e.name))})]})}function Oh({tabs:e,current:r,onTabChange:i,className:a}){let{t:o}=X(),s=J(null),c=J([]),l=J(null),[u,d]=Y({count:e.length,promote:!1}),f=()=>{let t=s.current;if(!t)return;let n=t.clientWidth,i=e.map((e,t)=>c.current[t]?.offsetWidth??0),a=i.reduce((e,t)=>e+t,0)+4*Math.max(0,e.length-1),o=(t,n)=>{let r=0,a=0;for(let o=0;o<e.length;o++){if(o===n)continue;let e=r+(a>0?4:0)+i[o];if(e>t)break;r=e,a+=1}return a},u;if(a<=n)u={count:e.length,promote:!1};else{let t=l.current?.offsetWidth??0,a=Math.max(1,o(n-t-4,-1)),s=e.findIndex(e=>e.name===r);u=s<0||s<a?{count:a,promote:!1}:{count:o(n-t-i[s]-8,s),promote:!0}}d(e=>e.count===u.count&&e.promote===u.promote?e:u)},p=J(f);p.current=f,st(()=>{p.current()}),K(()=>{let e=s.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>p.current());return t.observe(e),()=>t.disconnect()},[]);let m=e.findIndex(e=>e.name===r),h,g;if(u.promote&&m>=0){let t=e.filter((e,t)=>t!==m);h=[...t.slice(0,u.count),e[m]],g=t.slice(u.count)}else h=e.slice(0,u.count),g=e.slice(u.count);let _=g.some(e=>e.name===r),v=o(`agent.moreTabs`);return n(`div`,{ref:s,className:V(`relative`,a),children:[n(`div`,{"aria-hidden":!0,className:`pointer-events-none invisible absolute start-0 top-0 flex w-max gap-1`,children:[e.map((e,n)=>t(`button`,{type:`button`,tabIndex:-1,ref:e=>{c.current[n]=e},className:V(wh,Th),children:e.label},e.name)),n(`button`,{type:`button`,tabIndex:-1,ref:l,className:V(wh,Th),children:[v,t(kt,{className:`ms-1 size-4`})]})]}),n(`div`,{className:`-mb-px flex gap-1 overflow-hidden border-b`,children:[h.map(e=>{let n=e.name===r;return t(`button`,{type:`button`,"aria-current":n?`page`:void 0,disabled:e.disabled,onClick:()=>i(e.name),className:V(wh,n?Eh:Th,`disabled:pointer-events-none disabled:opacity-50`),children:e.label},e.name)}),g.length>0&&t(Dh,{tabs:g,current:r,onTabChange:i,label:v,active:_})]})]})}function kh({plan:e,workstreamStatus:r,plans:i=[],activePlanIndex:a=0,onChangePlan:s,activeWorkstreams:c=[],messages:l=[],hideWorkstreams:u=!1,openDocuments:d=[],activeDocumentId:f,onSelectDocument:p,onCloseDocument:m,onUpdateDocumentTitle:h,docRefreshKey:g=0,runId:_,processingFiles:v,showArtifacts:y=!1,artifactRefreshKey:b=0,payloadContent:x,conversationContent:S,onClose:C,defaultTab:w,activeTab:T,onTabChange:E}){let{t:D}=X(),[O,k]=Y(w||`plan`),A=T??O,j=e=>{k(e),E?.(e)},M=!u&&c.length>0,N=d.length>0,P=v?v.size>0:!1,F=G((e,n)=>t(Sh,{title:D(`agent.panelRenderError`,{name:e}),description:D(`agent.panelRenderErrorDescription`),children:n}),[D]),I={name:`conversation`,label:`Conversation`,content:S?F(`Conversation`,t(`div`,{className:`flex flex-col h-full min-h-0`,children:S})):null,is_allowed:!!S},L=[...S?[I]:[],{name:`plan`,label:D(`agent.plan`),content:F(D(`agent.plan`),e?t(yh,{plan:e,workstreamStatus:r||new Map,isOpen:!0,onClose:C,plans:i,activePlanIndex:a,onChangePlan:s}):t(bh,{icon:t(Cn,{className:`mb-2 size-8`}),children:D(`agent.noPlanAvailable`)})),is_allowed:!0},{name:`workstreams`,label:M?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[D(`agent.workstreams`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:c.length})]}):D(`agent.workstreams`),content:F(D(`agent.workstreams`),t(Ch,{workstreams:c,messages:l,runId:_})),is_allowed:!u},{name:`documents`,label:N?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[D(`agent.documents`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:d.length})]}):D(`agent.documents`),content:F(D(`agent.documents`),d.length>0&&p&&m?t(_h,{isOpen:!0,documents:d,activeDocumentId:f??null,onSelectDocument:p,onCloseDocument:m,onUpdateDocumentTitle:h,refreshKey:g,runId:_}):t(bh,{icon:t(sn,{className:`mb-2 size-8`}),children:D(`agent.noDocumentsOpen`)})),is_allowed:!0},{name:`uploads`,label:P?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[D(`agent.uploads`),` `,t(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-info`})]}):D(`agent.uploads`),content:F(D(`agent.uploads`),t(xh,{files:v})),is_allowed:!0},{name:`artifacts`,label:D(`agent.artifacts`),content:F(D(`agent.artifacts`),t(ch,{runId:_,refreshKey:b})),is_allowed:y},{name:`payload`,label:D(`agent.payload`),content:x?F(D(`agent.payload`),t(`div`,{className:`overflow-y-auto`,children:x})):null,is_allowed:!!x}];return n(Pe,{tabs:L,current:A,onTabChange:j,fullHeight:!0,className:`px-0`,children:[n(`div`,{className:`flex items-end justify-between shrink-0 px-1 py-1 gap-1`,children:[t(Oh,{tabs:L.filter(e=>e.is_allowed===void 0||e.is_allowed===!0),current:A,onTabChange:j,className:`min-w-0 flex-1`}),!S&&t(o,{variant:`ghost`,size:`sm`,className:`shrink-0 ms-1`,onClick:C,title:`Close Right Panel`,children:t(Sr,{className:`size-4`})})]}),t(Ie,{className:`flex-1 min-h-0 pt-0 pb-0`})]})}const Ah=W.memo(kh);function jh(e){if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.kind!==`file`)continue;let i=r.getAsFile();if(i)if(r.type.startsWith(`image/`)&&(!i.name||i.name===`image.png`)){let e=r.type.split(`/`)[1]||`png`;t.push(new File([i],`pasted-image-${Date.now()}.${e}`,{type:i.type}))}else t.push(i)}return t}function Mh(e,t,n=!1){let[r,i]=Y([]),[a,o]=Y(0),[s,c]=Y(new Map),[l,u]=Y(t),[d,f]=Y(!n),p=J(-1),m=J(new Set);K(()=>{e.length===0&&(i([]),o(0),c(new Map),f(!n),p.current=-1,m.current.clear())},[e.length,n]);let h=G(e=>{let n=e[e.length-1];n&&(n.type===Q.TERMINATED?u(!1):u(t?!0:n.type===Q.REQUEST_INPUT))},[t]);return K(()=>{if(e.length===0)return;let t=p.current+1;if(t>=e.length){h(e);return}let n=!1,r=[],a=[];for(let i=t;i<e.length;i++){let t=e[i];if(t.type===Q.PLAN)try{let e=null;if(t.details&&typeof t.details==`object`&&t.details.plan&&Array.isArray(t.details.plan)&&(e={plan:t.details.plan}),e){let i=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime();if(!m.current.has(i)){m.current.add(i),n=!0,r.push({plan:e,timestamp:i});let t=new Map;t.set(`main`,`in_progress`),Array.isArray(e.plan)&&e.plan.forEach(e=>{if(e&&typeof e==`object`&&e.id){let n=e.id.toString();t.set(n,e.status||`pending`)}}),a.push({timestamp:i,statusMap:t})}}}catch(e){console.error(`Failed to parse plan from message:`,e)}}p.current=e.length-1,n&&r.length>0&&(i(e=>[...[...r].reverse(),...e]),o(0),f(!0),a.length>0&&c(e=>{let t=new Map(e);for(let e of a)t.set(e.timestamp,e.statusMap);return t})),h(e)},[e,h]),K(()=>{if(r.length===1&&!d&&!sessionStorage.getItem(`plan-panel-shown`)){let e=setTimeout(()=>{f(!0),sessionStorage.setItem(`plan-panel-shown`,`true`)},500);return()=>clearTimeout(e)}},[r.length,d]),{plans:r,activePlanIndex:a,setActivePlanIndex:o,workstreamStatusMap:s,showInput:l,showSlidingPanel:d,setShowSlidingPanel:f}}function Nh(e,t){return{...e,details:{...e.details??{},_deliveryStatus:t}}}function Ph(e){let t=e.details,n=t?._messageId;if(typeof n==`string`&&n)return n;let r=t?.ack;return typeof r==`string`&&r?r:void 0}function Fh(e,t){let n=e?.[t];return typeof n==`string`&&n?n:void 0}function Ih(e){return e?.streaming_id_scope===`workflow_run`}function Lh(e){return[Q.COMPLETE,Q.IDLE,Q.TERMINATED,Q.REQUEST_INPUT].includes(e.type)}function Rh(e){if(e.type===Q.STREAMING_CHUNK)return!1;if(e.type===Q.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files)return!1}return!!e.message||Lh(e)}function zh(e){if(e)return{type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,text:typeof e.message==`string`?e.message.slice(0,80):e.message?`[non-string]`:``,display_role:e.details?.display_role,source:e.details?.source}}function Bh(e,t){if(e.find(e=>e.timestamp===t.timestamp))return e;if(!t.details?._optimistic&&(t.type===Q.QUESTION||zl(t))){let n=typeof t.details?.ack==`string`?t.details.ack:void 0,r=n?Nh(t,`consumed`):t;if(n){let i=e.filter(e=>!((e.type===t.type||zl(e))&&e.details?._optimistic&&Ph(e)===n));return Il(i,r),i}if(t.type===Q.QUESTION){let n=e.filter(e=>e.type===Q.QUESTION&&e.details?._optimistic&&e.message===t.message&&(e.workstream_id??`main`)===(t.workstream_id??`main`));if(n.length===1){let r=e.filter(e=>e!==n[0]);return Il(r,t),r}}}let n=[...e];return Il(n,t),n}function Vh(e){let t=e.details,n=Fh(t,`streaming_id`),r=Fh(t,`activity_id`);return n&&Ih(t)?n:r??n}function Hh(e){let t=e.details,n=Fh(t,`streaming_id`),r=Fh(t,`activity_id`),i=[];return n&&Ih(t)&&i.push(n),r&&i.push(r),[...new Set(i)]}function Uh(e,t){let[n,r]=Y([]),[i,a]=Y(!1),[o,s]=Y(`loading`),[c,l]=Y(null),[u,d]=Y(null),[f,p]=Y(new Map),[m,h]=Y(0),g=G(()=>h(e=>e+1),[]),_=J(null),v=J(0),[y,b]=Y(new Map),x=J(new Map),S=J(null),[C,w]=Y(!1),T=J(null),E=G(()=>{let e=S.current;e&&(e.mode===`raf`?cancelAnimationFrame(e.id):clearTimeout(e.id),S.current=null)},[]),D=G(()=>{x.current.size>0&&(b(new Map(x.current)),w(!0),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>w(!1),50)),S.current=null},[]);return K(()=>{a(!Rl(n))},[n]),K(()=>{Fl(`stream state`,{agentRunId:t,messageCount:n.length,streamingCount:y.size,initialHistoryStatus:o,isCompleted:i,lastDeliveredTs:v.current,first:zh(n[0]),last:zh(n[n.length-1])})},[t,o,i,n,y.size]),K(()=>{let n=_.current!==t;_.current=t,n&&(r([]),s(`loading`),l(null),d(null),b(new Map),p(new Map),v.current=0);let i=new AbortController,a=n?void 0:v.current||void 0;return Fl(`stream start`,{agentRunId:t,isNewConversation:n,since:a,streamNonce:m}),e.agents.getInternals(t).then(e=>{i.signal.aborted||(Fl(`internals loaded`,{agentRunId:t,status:e.status,first_workflow_run_id:e.first_workflow_run_id}),l(e.status?.toUpperCase()??null),d(e.first_workflow_run_id??null))}).catch(e=>{i.signal.aborted||console.error(`Failed to check agent run status:`,e)}),e.agents.streamMessages(t,e=>{if(!i.signal.aborted){if(Fl(`stream message`,{agentRunId:t,type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,hasMessage:!!e.message,display_role:e.details?.display_role,source:e.details?.source}),e.timestamp&&e.timestamp>v.current&&(v.current=e.timestamp),e.type===Q.STREAMING_CHUNK){let t=e.details,n=Vh(e);if(!n)return;let r=x.current.get(n)||{text:``,workstreamId:e.workstream_id,startTimestamp:Date.now(),activityId:t?.activity_id,streamingId:t?.streaming_id},i=r.text+(e.message||``);x.current.set(n,{text:i,workstreamId:e.workstream_id,isComplete:t.is_final,startTimestamp:r.startTimestamp,activityId:t?.activity_id,streamingId:t?.streaming_id}),S.current===null&&(document.hidden?S.current={mode:`timeout`,id:window.setTimeout(D,16)}:S.current={mode:`raf`,id:requestAnimationFrame(D)});return}if(e.type===Q.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files){p(new Map(t.files.map(e=>[e.id,e])));return}}if(e.type===Q.THOUGHT||e.type===Q.ANSWER){let t=Hh(e);if(t.length>0){for(let e of t)x.current.delete(e);b(e=>{let n=new Map(e),r=!1;for(let e of t)r=n.delete(e)||r;return r?n:e})}}(e.type===Q.COMPLETE||e.type===Q.IDLE)&&x.current.size>0&&D(),Rh(e)&&r(t=>Bh(t,e))}},a,i.signal,{onHistoryLoaded:e=>{if(i.signal.aborted)return;let n=e.filter(Rh);Fl(`history loaded`,{agentRunId:t,count:e.length,timelineCount:n.length,since:a,first:zh(e[0]),last:zh(e[e.length-1])}),s(e.length>0?`has_messages`:`empty`),n.length>0&&r(e=>n.reduce((e,t)=>(t.timestamp&&t.timestamp>v.current&&(v.current=t.timestamp),Bh(e,t)),e))},onHistoryError:e=>{i.signal.aborted||(Fl(`history error`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),s(`error`))}}).then(()=>{if(!i.signal.aborted)return Fl(`stream resolved`,{agentRunId:t}),e.agents.getInternals(t).then(e=>{i.signal.aborted||(Fl(`internals refreshed after stream end`,{agentRunId:t,status:e.status}),l(e.status?.toUpperCase()??null))}).catch(e=>{i.signal.aborted||console.error(`Failed to refresh agent run status on stream end:`,e)})}).catch(e=>{i.signal.aborted||(Fl(`stream failed`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),console.error(`Failed to stream agent messages:`,e))}),()=>{Fl(`stream cleanup`,{agentRunId:t,streamNonce:m}),i.abort(),E(),x.current.clear(),T.current&&=(clearTimeout(T.current),null)}},[t,m,e.agents,D,E]),K(()=>{let e=()=>{!document.hidden&&x.current.size>0&&(E(),D())};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[D,E]),{messages:n,streamingMessages:y,isCompleted:i,initialHistoryStatus:o,debugChunkFlash:C,addOptimisticMessage:G(e=>{r(t=>{let n=[...t,e];return n.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),n})},[]),updateOptimisticMessageStatus:G((e,t)=>{r(n=>n.map(n=>n.details?._optimistic&&Ph(n)===e?Nh(n,t):n))},[]),removeOptimisticMessages:G(e=>{r(t=>t.filter(t=>!e(t)))},[]),reconnect:g,agentRunStatus:c,workflowRunId:u,serverFileUpdates:f}}function Wh(e){if(typeof e==`string`&&e.trim().length>0)return e}function Gh(e,t){let n=Wh(e.revision_root_id)||Wh(e.revision_root)||Wh(e.root_document_id)||Wh(e.root_id);if(n)return n;let r=e.revision_info;if(r&&typeof r==`object`){let e=Wh(r.root);if(e)return e}return t}function Kh(e,t){return e.revisionRootId&&t.revisionRootId?e.revisionRootId===t.revisionRootId:t.revisionRootId?e.id===t.revisionRootId:e.revisionRootId?e.revisionRootId===t.id:e.id===t.id}function qh(e){let[t,n]=Y([]),[r,i]=Y(null),[a,o]=Y(!1),[s,c]=Y(0),l=J(-1);return K(()=>{e.length===0&&(n([]),i(null),o(!1),c(0),l.current=-1)},[e.length]),K(()=>{let t=l.current+1;if(!(t>=e.length)){for(let r=t;r<e.length;r++){let t=e[r];if(t.type===Q.UPDATE&&t.details){let e=t.details;if(e.event_class===`document_created`||e.event_class===`document_updated`){let t=Wh(e.document_id),r=Wh(e.updated_document_id)||t,a=e.title;if(r){let s=Gh(e,t||r),l={id:r,title:a||`Document`,revisionRootId:s};n(e=>{let t=e.findIndex(e=>Kh(e,l));if(t<0)return[...e,l];let n=e[t];if(n.id===l.id&&n.title===l.title&&n.revisionRootId===l.revisionRootId)return e;let r=[...e];return r[t]=l,r}),i(l.id),o(!0),e.event_class===`document_updated`&&c(e=>e+1)}}}}l.current=e.length-1}},[e]),{openDocuments:t,activeDocumentId:r,isDocPanelOpen:a,docRefreshKey:s,closeDocPanel:G(()=>{o(!1)},[]),closeDocument:G(e=>{n(t=>{let n=t.filter(t=>t.id!==e);return n.length===0?(o(!1),i(null)):i(t=>t===e?n[0].id:t),n})},[]),selectDocument:G(e=>{i(e)},[]),openDocInPanel:G(e=>{n(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:`Document`,revisionRootId:e}]),i(e),o(!0)},[]),updateDocumentTitle:G((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,title:t}:n))},[])}}function Jh(e){return e.type.startsWith(`image/`)}function Yh(e){if(!(!Jh(e)||typeof URL>`u`||!URL.createObjectURL))return URL.createObjectURL(e)}function Xh(e){typeof URL<`u`&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function Zh(e,t,n,r){let i=ut.getFixedT(null,lt),[a,o]=Y(new Map),[s,c]=Y(new Set),l=J(new Set),u=J(new Map),d=J(t),f=J(a);f.current=a;let p=J(n);p.current=n;let m=G(e=>{let t=u.current.get(e);t&&(Xh(t),u.current.delete(e))},[]);K(()=>{if(d.current!==t){d.current=t,u.current.forEach(Xh),u.current.clear(),o(new Map);let e=new Set;l.current=e,c(e)}},[t]),K(()=>()=>{u.current.forEach(Xh),u.current.clear()},[]);let h=q(()=>{let e=new Map;return a.forEach((t,n)=>{s.has(n)||e.set(n,t)}),n.forEach((t,n)=>{if(!s.has(n)){let r=a.get(n);e.set(n,{...t,artifact_path:t.artifact_path??r?.artifact_path,reference:t.reference??r?.reference,...r?.preview_url?{preview_url:r.preview_url}:{}})}}),e},[a,s,n]);return{processingFiles:h,hasProcessingFiles:q(()=>Array.from(h.values()).some(e=>e.status===Nr.UPLOADING||e.status===Nr.PROCESSING),[h]),handleFileUpload:G(async n=>{for(let a of n){let n=`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,s=`files/${a.name}`,c=Yh(a);c&&u.current.set(n,c);let d={id:n,name:a.name,content_type:a.type||`application/octet-stream`,size:a.size,status:Nr.UPLOADING,started_at:Date.now(),preview_url:c};o(e=>new Map(e).set(n,d));try{if(await e.agents.uploadArtifact(t,s,a),o(e=>{let t=new Map(e),r=t.get(n);return r&&(r.status=Nr.PROCESSING,r.artifact_path=s,r.reference=`artifact:${s}`),t}),l.current.has(n))continue;await e.agents.sendSignal(t,`FileUploaded`,{id:n,name:a.name,content_type:a.type||`application/octet-stream`,reference:`artifact:${s}`,artifact_path:s})}catch(e){if(l.current.has(n))continue;o(t=>{let r=new Map(t),i=r.get(n);return i&&(i.status=Nr.ERROR,i.error=e instanceof Error?e.message:`Upload failed`,i.completed_at=Date.now()),r}),r({status:`error`,title:i(`agent.uploadFailed`),description:e instanceof Error?e.message:`Failed to upload file`,duration:3e3})}}},[e,t,r,i]),removeProcessingFile:G(async n=>{c(e=>{if(e.has(n))return e;let t=new Set(e);return t.add(n),l.current=t,t}),o(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t}),m(n);try{await e.agents.sendSignal(t,`FileRemoved`,{id:n})}catch(e){r({status:`error`,title:i(`agent.removeFileFailed`),description:e instanceof Error?e.message:`Failed to remove file`,duration:3e3})}},[t,e,m,i,r]),clearProcessingFiles:G(()=>{u.current.forEach(Xh),u.current.clear(),c(e=>{let t=new Set(e);for(let e of p.current.keys())t.add(e);for(let e of f.current.keys())t.add(e);return l.current=t,t}),o(new Map)},[])}}function Qh({activeWorkstreams:e,className:r}){let{t:i}=X(),a=q(()=>e.filter(e=>e.status===`running`||e.status===`canceling`),[e]),o=a.slice(0,3),s=Math.max(0,a.length-o.length);return a.length===0?null:t(`div`,{className:V(`mx-auto mb-2 w-full max-w-3xl px-1`,r),"data-agent-active-workstreams":!0,children:n(`output`,{className:`flex flex-col gap-1.5 rounded-2xl border border-border/70 bg-background/95 p-2 text-xs text-muted shadow-lg shadow-black/5`,"aria-live":`polite`,children:[n(`div`,{className:`flex items-center gap-2 px-1 font-medium`,children:[t(yt,{className:`size-3.5 text-muted`,"aria-hidden":`true`}),t(`span`,{children:i(`agent.activeWorkstreams`,{count:a.length})})]}),n(`div`,{className:`flex flex-col gap-0.5`,children:[o.map(e=>{let r=Cl(e.workstream_id,e.interaction);return n(`span`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:r,children:[t(`span`,{className:V(`size-1.5 shrink-0 rounded-full`,kl(e.status)),"aria-hidden":`true`}),t(`span`,{className:`truncate font-medium`,children:r}),e.phase&&t(`span`,{className:`truncate text-xs text-muted/75`,children:xl(e.phase)})]},e.launch_id||e.workstream_id)}),s>0&&n(`span`,{className:`px-1 py-1 text-xs text-muted`,children:[`+`,s]})]})]})})}var $h=class{_listeners=new Set;snapshot;constructor(e){this.snapshot=new eg(e,this)}subscribe=e=>(this._listeners.add(e),()=>{this._listeners.delete(e)});getSnapshot=()=>this.snapshot;notify(){this._listeners.forEach(e=>{e()})}},eg=class e{vertesia;_interactive=!0;_debug_mode=!1;_non_blocking_subagents=!0;_checkpoint_tokens;_visibility;_user_channels;_collection;_disabled_mcp_collections;_start=!1;_preserveRunValues=!1;_interaction;_environment;_model=``;_model_options;_tool_names=[];_data;_mode=`start`;_scheduledWorkflowConfig;_interactionParamsSchema;_schemaVersion=0;_inputValidator;_store;constructor(e,t){this.vertesia=e,this._store=t}onStateChanged(){let e=this.clone();this._store.snapshot=e,this._store.notify()}clone(){let t=new e(this.vertesia,this._store);return t._interactionParamsSchema=this._interactionParamsSchema,t._schemaVersion=this._schemaVersion,t._interaction=this._interaction,t._data=this._data,t._environment=this._environment,t._model=this._model,t._model_options=this._model_options?{...this._model_options}:void 0,t._tool_names=[...this._tool_names],t._interactive=this._interactive,t._debug_mode=this._debug_mode,t._non_blocking_subagents=this._non_blocking_subagents,t._checkpoint_tokens=this._checkpoint_tokens,t._visibility=this._visibility,t._user_channels=this._user_channels?[...this._user_channels]:void 0,t._inputValidator=this._inputValidator,t._start=this._start,t._collection=this._collection,t._disabled_mcp_collections=this._disabled_mcp_collections?[...this._disabled_mcp_collections]:void 0,t._preserveRunValues=this._preserveRunValues,t._mode=this._mode,t._scheduledWorkflowConfig=this._scheduledWorkflowConfig,t}set mode(e){e!==this._mode&&(this._mode=e,e===`schedule`&&!this._scheduledWorkflowConfig&&(this._scheduledWorkflowConfig={name:``,description:``,cron_expression:`0 9 * * *`,timezone:`UTC`}),this.onStateChanged())}get mode(){return this._mode}set scheduledWorkflowConfig(e){this._scheduledWorkflowConfig=e,this.onStateChanged()}get scheduledWorkflowConfig(){return this._scheduledWorkflowConfig}updateScheduledWorkflowConfig(e){this._scheduledWorkflowConfig={...this._scheduledWorkflowConfig,...e},this.onStateChanged()}get interactive(){return this._interactive}set interactive(e){e!==this._interactive&&(this._interactive=e,this.onStateChanged())}get debug_mode(){return this._debug_mode}set debug_mode(e){e!==this._debug_mode&&(this._debug_mode=e,this.onStateChanged())}get non_blocking_subagents(){return this._non_blocking_subagents}set non_blocking_subagents(e){e!==this._non_blocking_subagents&&(this._non_blocking_subagents=e,this.onStateChanged())}get checkpoint_tokens(){return this._checkpoint_tokens}set checkpoint_tokens(e){e!==this._checkpoint_tokens&&(this._checkpoint_tokens=e,this.onStateChanged())}get visibility(){return this._visibility}set visibility(e){e!==this._visibility&&(this._visibility=e,this.onStateChanged())}get user_channels(){return this._user_channels}set user_channels(e){this._user_channels=e,this.onStateChanged()}get collection(){return this._collection}set collection(e){e!==this._collection&&(this._collection=e,this.onStateChanged())}get disabled_mcp_collections(){return this._disabled_mcp_collections}set disabled_mcp_collections(e){this._disabled_mcp_collections=e&&e.length>0?e:void 0,this.onStateChanged()}get search_scope(){return this._collection?kr.Collection:void 0}async restoreConversation(e){let t=e.interaction;e.version&&(/^[a-fA-F0-9]{24}$/.test(t)||(t=`${t}@${e.version}`));let n=await this.vertesia.interactions.catalog.resolve(t),r=n.runtime?.environment||e.config?.environment,i=e.config?.model,a=await(r?this.vertesia.environments.retrieve(r).catch(()=>void 0):Promise.resolve(void 0));this._data=e.data,this.interaction=n,e.interactionParamsSchema!=null&&(this.interactionParamsSchema=e.interactionParamsSchema),this._tool_names=e.tool_names||[],this._interactive=e.interactive,this._debug_mode=e.debug_mode??!1,this._non_blocking_subagents=e.non_blocking_subagents??!0,this._checkpoint_tokens=e.checkpoint_tokens,this._user_channels=e.user_channels,this._disabled_mcp_collections=e.disabled_mcp_collections,this._model_options=e.config?.model_options,this.collection=e.collection_id??void 0,this._model_options=e.config?.model_options,this.environment=a,i&&(this._model=i),this.onStateChanged()}get interaction(){return this._interaction}set interaction(e){if(e?.id!==this._interaction?.id){if(this._interaction=e,this.interactionParamsSchema=e?Kr(e.prompts):void 0,this._inputValidator=void 0,e&&!this._preserveRunValues&&(this._model_options=e.model_options,e.runtime?.environment)){let t=e.runtime.environment;this.vertesia.environments.retrieve(t).then(e=>this.environment=e)}this.onStateChanged()}}get environment(){return this._environment}set environment(e){if(e?.id!==this._environment?.id){if(this._environment=e,!this._preserveRunValues){let t=this.interaction?.runtime?.model;t&&e&&Yr(t,e.provider)?this._model=t:this._model=e?.default_model&&Yr(e.default_model,e.provider)?e.default_model:``}this.onStateChanged()}}get model(){return this._model}set model(e){e!==this._model&&(this._model=e||``,this.onStateChanged())}get model_options(){return this._model_options}set model_options(e){JSON.stringify(e)!==JSON.stringify(this._model_options)&&(this._model_options=e,this.onStateChanged())}get tool_names(){return this._tool_names}set tool_names(e){this._tool_names=e,this.onStateChanged()}get data(){return this._data}set data(e){this._data=e,this.onStateChanged()}set run(e){console.log(`run`,e),this.onStateChanged()}set start(e){this._start!==e&&(this._start=e,this.onStateChanged())}markStarted(){this.start=!0}setMode(e){this.mode=e}setInteraction(e){this.interaction=e}setEnvironment(e){this.environment=e}setModel(e){this.model=e}setModelOptions(e){this.model_options=e}setToolNames(e){this.tool_names=e}setCollection(e){this.collection=e}setDisabledMcpCollections(e){this.disabled_mcp_collections=e}setInteractive(e){this.interactive=e}setDebugMode(e){this.debug_mode=e}setUserChannels(e){this.user_channels=e}setCheckpointTokens(e){this.checkpoint_tokens=e}setVisibility(e){this.visibility=e}setData(e){this.data=e}setPreserveRunValues(e){this.preserveRunValues=e}get start(){return this._start}get preserveRunValues(){return this._preserveRunValues}set preserveRunValues(e){this._preserveRunValues=e}get schemaVersion(){return this._schemaVersion}get interactionParamsSchema(){return this._interactionParamsSchema}set interactionParamsSchema(e){this._interactionParamsSchema!==e&&(this._interactionParamsSchema=e,this._schemaVersion+=1,e&&(this._data=this.initializeBooleanDefaults(this._data||{},e)),this.onStateChanged())}initializeBooleanDefaults(e,t){if(!t.properties)return e;let n={...e};for(let[e,r]of Object.entries(t.properties)){let t=r;t.type===`boolean`&&n[e]===void 0?n[e]=!1:t.type===`object`&&t.properties&&(n[e]=this.initializeBooleanDefaults(n[e]||{},t))}return n}reset(){if(this._start=!1,this._interactive=!0,this._debug_mode=!1,this._non_blocking_subagents=!0,this._checkpoint_tokens=void 0,this._visibility=void 0,this._user_channels=void 0,this._collection=void 0,this._disabled_mcp_collections=void 0,this._preserveRunValues=!1,this._model=``,this._model_options=void 0,this._environment=void 0,this._tool_names=[],this._interaction=void 0,this._data=void 0,this._interactionParamsSchema=null,this._inputValidator=void 0,this.model=void 0,this.environment=void 0,this.onStateChanged(),location.hash){let e=window.location.origin+window.location.pathname+window.location.search;history.replaceState(null,``,e),location.hash=``}}validateInput(){if(!this._interactionParamsSchema)return{isValid:!0};if(!this._inputValidator||this._inputValidator.schema!==this._interactionParamsSchema){let e=new Ki({strict:!1});this._inputValidator={validate:e.compile(this._interactionParamsSchema),schema:this._interactionParamsSchema}}let e=this._data||{};return this._inputValidator.validate(e)?{isValid:!0}:{isValid:!1,errorMessage:this._inputValidator.validate.errors?this._inputValidator.validate.errors.map(e=>`${e.instancePath}: ${e.message}`).join(`, `):`Invalid payload data`}}};const tg=nt(void 0);function ng({children:e}){let{client:n}=Z(),[r]=Y(()=>new $h(n)),i=ct(r.subscribe,r.getSnapshot);return t(tg.Provider,{value:i,children:e})}function rg(){let e=at(tg);if(!e)throw Error(`usePayloadBuilder must be used within a PayloadProvider`);return e}function ig({title:e,variant:r=`full`,isTerminal:i=!1,onClose:a,isModal:s,agentRunId:c,workflowRunId:l,viewMode:u,onViewModeChange:d,showPlanPanel:f,showPlanButton:p=!0,onTogglePlanPanel:m,showPlaybackButton:h=!1,isPlaybackEnabled:g=!1,onTogglePlayback:_,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C=!0,onClone:w,isReceivingChunks:T=!1,className:E}){let{t:D}=X(),O=r===`compact`,k=u===`sliding`?`stacked`:`sliding`,A=D(`agent.verbose`),j=D(`agent.summary`),M=k===`stacked`?A:j,N=n(`div`,{className:V(O?`flex flex-row items-center gap-1 lg:flex-col`:`flex justify-end items-center gap-2 ms-auto`),children:[p&&t(`div`,{className:`relative`,children:n(o,{size:r===`compact`?`icon`:`sm`,variant:f?`primary`:`ghost`,onClick:m,className:V(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),title:D(`agent.toggleRightSidebar`),children:[t(Vt,{className:V(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)}):t(`span`,{className:`sr-only`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)})]})}),O?t(o,{variant:`ghost`,size:`icon`,onClick:()=>d(k),className:`size-8 rounded-lg`,title:M,"aria-label":M,children:t(k===`stacked`?Zn:Mn,{className:`size-4`})}):n(`div`,{className:`flex items-center gap-1 bg-muted rounded p-0.5 mt-2 lg:mt-0`,children:[n(o,{variant:u===`stacked`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`stacked`),"aria-pressed":u===`stacked`,className:`gap-1.5`,children:[t(Zn,{className:`size-3.5`}),A]}),n(o,{variant:u===`sliding`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`sliding`),"aria-pressed":u===`sliding`,className:`gap-1.5`,children:[t(Mn,{className:`size-3.5`}),j]})]}),h&&_&&n(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:g?`primary`:`ghost`,onClick:_,"aria-pressed":g,title:D(`agent.rewind.label`),className:V(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:[t(Yn,{className:V(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(`agent.rewind.label`)}):t(`span`,{className:`sr-only`,children:D(`agent.rewind.label`)})]}),t(ag,{compact:O,agentRunId:c,workflowRunId:l,isModal:s,isTerminal:i,onClose:a,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C,onClone:w}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,"aria-label":D(`agent.close`),children:t(Sr,{className:`size-4`})})]});return r===`compact`?t(ng,{children:t(`div`,{className:V(`inline-flex items-center rounded-xl border border-border/70 bg-background/90 p-1 shadow-lg shadow-black/10 backdrop-blur`,E),children:N})}):t(ng,{children:n(`div`,{className:V(`flex flex-wrap items-end justify-between py-1.5 px-2 border-b shadow-sm flex-shrink-0`,E),children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1`,children:[t(yt,{className:`size-5 text-muted`}),t(`span`,{className:`font-medium`,children:e})]}),n(`span`,{className:`text-xs text-muted ms-1 flex items-center gap-1.5`,children:[`(Agent Run ID: `,c,`)`,t(`span`,{className:V(`w-2 h-2 rounded-full transition-colors duration-200`,T?`bg-purple-500 shadow-[0_0_6px_2px_rgba(168,85,247,0.6)]`:`bg-gray-400`)})]})]}),N]})})}function ag({compact:e=!1,agentRunId:r,workflowRunId:i,isModal:a,isTerminal:s,onClose:c,onDownload:l,onExportFixture:u,resetWorkflow:d,onExportPdf:f,onShowDetails:p,allowWorkflowControl:m=!0,onClone:h}){let{t:g}=X(),_=Ye(),{client:v}=Z(),y=rg(),{router:b}=Oi(),x=async()=>{try{return await v.agents.terminate(r,`cancel`),_({status:`success`,title:g(`agent.workflowCancelled`),duration:2e3}),y.reset(),d?.(),!0}catch{return _({status:`error`,title:g(`agent.failedToCancelWorkflow`),duration:2e3}),!1}},S=async()=>{try{let e=await v.agents.fork(r);_({status:`success`,title:g(`agent.conversationCloned`),duration:2e3}),h?.(e)}catch{_({status:`error`,title:g(`agent.failedToCloneConversation`),duration:2e3})}},C=e=>{let t=e.startsWith(`/`)?b.getTopRouter().navigator.addStickyParams(e):e;return window.open(t,`_blank`),t};return t(w,{align:`right`,trigger:t(o,{size:e?`icon`:`xs`,variant:`ghost`,title:g(`agent.moreActions`),className:e?`size-8 rounded-lg`:void 0,children:t(Ln,{className:`size-4`})}),children:n(ne,{label:`Actions`,children:[a&&n(B,{onClick:()=>C(`/store/agent-runner/${r}`),children:[t(Zt,{className:`size-3.5 text-muted`}),` `,g(`agent.openInNewTab`)]}),n(B,{onClick:()=>{navigator.clipboard.writeText(r),_({status:`success`,title:g(`agent.agentRunIdCopied`),duration:2e3})},children:[t(Gt,{className:`size-3.5 text-muted`}),` `,g(`agent.copyAgentRunId`)]}),n(B,{onClick:()=>{navigator.clipboard.writeText(i),_({status:`success`,title:g(`agent.workflowRunIdCopied`),duration:2e3})},children:[t(Gt,{className:`size-3.5 text-muted`}),` `,g(`agent.copyWorkflowRunId`)]}),p&&n(B,{onClick:p,children:[t(bn,{className:`size-3.5 text-muted`}),` `,g(`agent.details`)]}),n(B,{onClick:()=>{l?l():Gl(v,r).then(e=>window.open(e,`_blank`))},children:[t(Jt,{className:`size-3.5 text-muted`}),` `,g(`agent.downloadConversation`)]}),f&&n(B,{onClick:f,children:[t(Jt,{className:`size-3.5 text-muted`}),` `,g(`agent.exportAsPdf`)]}),u&&n(B,{onClick:u,children:[t(Jt,{className:`size-3.5 text-muted`}),` `,g(`agent.rewind.exportFixture`)]}),c&&a&&n(B,{onClick:c,children:[t(Sr,{className:`size-3.5 text-muted`}),` `,g(`agent.close`)]}),h&&n(B,{onClick:S,children:[t(pn,{className:`size-3.5 text-muted`}),` `,g(`agent.cloneConversation`)]}),m&&!s&&n(B,{onClick:x,variant:`destructive`,children:[t(Sr,{className:`size-3.5`}),` `,g(`agent.cancelWorkflow`)]})]})})}function og(e){return typeof e==`object`&&!!e&&`value`in e}function sg(e){return og(e)?e.value:e}function cg(e){if(e.type===`stringList`)return e.value.map(e=>typeof e==`string`?e:sg(e));if(e.multiple)return e.value.map(sg);let t=e.value[0];return t===void 0?void 0:sg(t)}function lg(e,t,n){e.query[t]=n}function ug({buckets:e,name:r,placeholder:a}){let o=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:r,placeholder:a||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:o,type:`select`,labelRenderer:r=>{let a=e.find(e=>e._id===r),o=a?.name||r,s=`success`;if(a?.status)switch(a.status){case Fr.published:s=`success`;break;case Fr.archived:s=`destructive`;break;case Fr.code:s=`info`;break}let c=a?.version&&a?.status?`v${a.version} ${a.status===Fr.unknown?``:a.status}`:a?.status||(a?.version?`v${a.version}`:``);return n(`div`,{className:`w-full flex items-center justify-between`,children:[n(`div`,{className:`flex flex-row flex-wrap items-center gap-2 min-w-0 flex-1`,children:[t(`span`,{className:`text-sm truncate`,children:o}),c&&t(i,{variant:s,className:`text-xs w-fit`,children:c})]}),(a?.count??0)>0&&n(`span`,{className:`ms-2 text-xs shrink-0`,children:[`(`,a?.count,`)`]})]})},filterBy:(t,n)=>(e.find(e=>e._id===t)?.name||t).toLowerCase().includes(n.toLowerCase())}}function dg(e){return`${e._id} (${e.count})`}function fg(e){return`${e.name} (${e.count})`}function pg({buckets:e,name:t,placeholder:n,type:r=`select`,multiple:i=!1}){return{name:t,options:e.map(e=>({label:dg(e),value:e._id})),type:r,multiple:i,placeholder:`${n??`${t.charAt(0).toUpperCase()+t.slice(1)}`}`,allowCreate:!1}}function mg({buckets:e,name:t,placeholder:n,type:r,multiple:i}){return pg({buckets:e,name:t,placeholder:n,type:r,multiple:i})}const hg={},gg={},_g={};function vg(e){return typeof e==`object`&&!!e&&`status`in e&&e.status===404}function yg(e,t,n){let r=e[t];return r||(r=n().catch(n=>{throw vg(n)||delete e[t],n}),e[t]=r),r}function bg(e){let{client:t}=Z();return Ue(()=>yg(hg,e,()=>t.users.retrieve(e)),{deps:[e],condition:()=>!!e})}function xg(e){let{client:t}=Z();return Ue(()=>yg(gg,e,()=>t.iam.groups.retrieve(e)),{deps:[e],condition:()=>!!e})}function Sg(e){let{client:t}=Z();return Ue(()=>yg(_g,e,()=>t.apikeys.retrieve(e)),{deps:[e],condition:()=>!!e})}function Cg(){return t(`div`,{className:`size-8`})}function wg({showTitle:e=!1,size:i=`md`}){let{t:a}=X();return t(Ig,{title:a(`user.systemUser`),description:a(`user.systemUserDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(r,{src:`/icon.svg`,size:i}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:a(`user.systemUser`)})]})})}function Tg({showTitle:e=!1,size:r=`md`}){let{t:i}=X();return t(Ig,{title:i(`user.allProjectMembers`),description:i(`user.allProjectMembersDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(gr,{className:`size-4`,size:r}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:i(`user.allProjectMembers`)})]})})}function Eg({accountId:i,showTitle:a=!1,size:o=`md`}){let{t:s}=X(),c=i.split(`:`)[0],l=i.split(`:`)[1],u=n(e,{children:[t(`div`,{children:s(`user.serviceAccountDescription`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`Type:`}),` `,c]}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,l]})]});return t(Ig,{title:s(`user.serviceAccount`),description:u,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:`/cloud.svg`,name:`SA`,color:`bg-amber-500`,className:`px-[5px] text-white`,size:o}),a&&n(`div`,{className:`text-sm font-semibold ps-2 truncate`,children:[s(`user.serviceAccount`),` : ~`,l.slice(-6)]})]})})}function Dg({email:i,showTitle:a=!1,size:o=`md`}){let{t:s}=X();return t(Ig,{title:`Email Agent`,description:n(e,{children:[t(`div`,{children:s(`user.agentOnBehalfOf`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`Email:`}),` `,i]})]}),children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(r,{src:`/cloud.svg`,color:`bg-amber-500`,className:`px-[5px] text-white border-2 border-white dark:border-gray-800`,size:o}),t(r,{name:i,size:o,className:`border-2 border-white dark:border-gray-800`})]}),a&&n(`div`,{className:`text-sm font-semibold truncate`,children:[`Agent (`,i,`)`]})]})})}function Og({agentId:i,onBehalfOfType:a,onBehalfOfId:o,showTitle:s=!1,size:c=`md`,isScheduleAgent:l=!1}){let{t:u}=X(),d=a===`user`&&o,f=a===`apikey`&&o,p=bg(o||``),m=Sg(o||``),h=d?p.data:void 0,g=f?m.data:void 0,_=i.slice(-6),v=h?u(`user.agentOnBehalfOf`):g?u(`user.agentOnBehalfOfApiKey`):`${u(`user.serviceAccount`)}~${_}`;return t(Ig,{title:l?u(`user.schedule`,{title:v}):v,description:n(`div`,{className:`space-y-2`,children:[h&&n(`div`,{className:`flex items-center gap-2`,children:[t(r,{src:h.picture,name:h.name,size:`sm`}),n(`div`,{children:[t(`div`,{className:`font-medium`,children:h.name||h.email}),h.email&&h.name&&t(`div`,{className:`text-xs text-muted`,children:h.email})]})]}),g&&n(`div`,{children:[t(`div`,{className:`font-medium`,children:g.name}),n(`div`,{className:`text-xs text-muted-foreground`,children:[`Key ID: `,g.id]})]}),!h&&!g&&n(e,{children:[t(`div`,{children:u(`user.serviceAccountDescription`)}),n(`div`,{className:`text-gray-800 dark:text-gray-500 text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,i]})]})]}),children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(r,{src:`/cloud.svg`,color:`bg-amber-500`,className:`px-[5px] text-white border-2 border-white dark:border-gray-800`,size:c}),h&&t(r,{src:h.picture,name:h.name,size:c,className:`border-2 border-white dark:border-gray-800`}),g&&t(r,{name:`API`,color:`bg-gray-400`,size:c,className:`border-2 border-white dark:border-gray-800`})]}),s&&t(`div`,{className:`text-sm font-semibold truncate`,children:h?`Agent (${h.name||h.email})`:g?`Agent (${g.name})`:v})]})})}function kg({title:e=`Error`,error:n,showTitle:r=!1,size:i=`md`}){return t(Mg,{title:e,message:H(n),color:`bg-red-500`,showTitle:r,size:i})}function Ag({showTitle:e=!1,size:n=`md`,color:r}){let{t:i}=X();return t(Mg,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),color:r,showTitle:e,size:n})}function jg({userRef:e,showTitle:n=!1,size:r=`md`}){let{t:i}=X();if(!e)return t(Mg,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),showTitle:n,size:r});let a=e.split(`:`),o=a[0];switch(o){case Br.User:return t(Pg,{userId:a[1],showTitle:n,size:r});case Br.Group:return t(Ng,{userId:a[1],showTitle:n,size:r});case`system`:return t(wg,{showTitle:n,size:r});case Br.ServiceAccount:return t(Eg,{accountId:a.slice(1).join(`:`),showTitle:n,size:r});case Br.Agent:{let e,i,o;return a[1]===`agent`?(e=a.slice(2,5).join(`:`),i=a[5],o=a[6]):(e=a.slice(1,4).join(`:`),i=a[4],o=a[5]),t(Og,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r})}case Br.Schedule:{let e=a[2]===`agent`?a.slice(3,6).join(`:`):`unknown-agent`,i=a[6],o=a[7];return t(Og,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r,isScheduleAgent:!0})}case`email`:return t(Dg,{email:a[1],showTitle:n,size:r});case Br.ApiKey:return t(Fg,{keyId:a[1],size:r,showTitle:n});case`project`:if(a[1]===`*`)return t(Tg,{showTitle:n,size:r});break;default:return t(kg,{title:i(`user.unknownUser`),error:`Invalid user ref type: ${o}`,showTitle:n,size:r})}}function Mg({title:e,message:i,color:a,size:o=`md`,showTitle:s=!1}){return t(Ig,{title:e,description:i,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{color:a,size:o}),s&&t(`div`,{className:`text-sm font-semibold ps-1`,children:e})]})})}function Ng({userId:e,showTitle:r=!1,size:i=`md`}){let{t:a}=X(),{data:o,error:s}=xg(e);if(s)return vg(s)?t(Ag,{showTitle:r,size:i,color:`bg-indigo-500`}):t(kg,{title:a(`user.failedToFetchGroup`),error:s,showTitle:r,size:i});if(!o)return t(Cg,{});let c=n(`div`,{className:`space-y-1`,children:[o.description&&t(`div`,{className:`text-sm`,children:o.description}),t(`div`,{className:`text-xs text-muted-foreground`,children:a(`user.groupId`,{id:o.id})}),o.tags&&o.tags.length>0&&t(`div`,{className:`flex flex-wrap gap-1`,children:o.tags.map(e=>t(`span`,{className:`px-1.5 py-0.5 bg-muted rounded text-xs`,children:e},e))})]});return t(Ig,{title:o.name||a(`user.unnamedGroup`),description:c,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(hr,{className:`size-6 text-indigo-500`,size:i}),r&&t(`div`,{className:`text-sm font-semibold ps-2`,children:o.name||a(`user.unnamedGroup`)})]})})}function Pg({userId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=X(),{data:s,error:c}=bg(e);if(c)return vg(c)?t(Ag,{showTitle:i,size:a,color:`bg-indigo-500`}):t(kg,{title:o(`user.failedToFetchUser`),error:c,showTitle:i,size:a});if(!s)return t(Cg,{});let l=t(`div`,{className:`truncate`,title:s.email,children:s.email});return t(Ig,{title:s.name||s.email||s.username||o(`user.unknown`),description:l,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:s.picture,name:s.name,color:`bg-indigo-500`,size:a}),i&&t(`div`,{className:`text-sm font-semibold ps-2`,children:s.name||s.email||s.username||o(`user.unknown`)})]})})}function Fg({keyId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=X(),{data:s,error:c}=Sg(e);if(c)return vg(c)?t(Ag,{showTitle:i,size:a,color:`bg-pink-500`}):t(kg,{title:o(`user.failedToFetchApiKey`),error:c,showTitle:i,size:a});if(!s)return t(Cg,{});let l=o(`user.privateKey`),u=t(r,{name:`PK`,color:`bg-pink-500`,size:a});return t(Ig,{title:l,description:n(Me,{className:`dark:bg-gray-800 dark:text-gray-200 table-fixed w-full`,children:[n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.key`)}),t(`td`,{className:`truncate max-w-0`,children:s?.name})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.account`)}),t(`td`,{className:`truncate max-w-0`,children:s?.account})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.project`)}),t(`td`,{className:`truncate max-w-0`,children:s?.project.name})]})]}),children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[u,i&&t(`div`,{className:`text-sm font-semibold`,children:s?.name||s?.account||s?.project.name||o(`user.unknown`)})]})})}function Ig({title:e,description:r,children:i}){return n(ue,{hover:!0,children:[t(fe,{className:`cursor-pointer flex items-center inline-block`,children:t(`div`,{children:i})}),t(de,{align:`center`,sideOffset:8,side:`right`,children:n(`div`,{className:`flex flex-col gap-1 rounded-md shadow-md p-2`,children:[t(`div`,{className:`text-md font-semibold`,children:e}),r]})})]})}function Lg({buckets:e,name:r,placeholder:i}){let a=e.map(e=>({value:e._id,label:`(${e.count})`}));return{name:r,placeholder:i||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:a,labelRenderer:r=>{if(r===`Unknown User`||!r)return`Unknown User (${e.find(e=>e._id===r)?.count||0})`;let i=e.find(e=>e._id===r);return n(`div`,{className:`flex items-center w-full gap-2`,children:[t(`div`,{className:`flex-1 min-w-0 flex items-center truncate`,children:t(jg,{userRef:r,showTitle:!0,size:`sm`})}),n(`span`,{className:`text-muted-foreground flex-shrink-0`,children:[`(`,i?.count||0,`)`]})]})}}}function Rg({buckets:e,name:t,placeholder:n}){return Lg({buckets:e,name:t,placeholder:n})}function zg(e){let t=[];return t.push({name:`id`,placeholder:`Agent Run ID`,type:`text`,multiple:!1}),t.push(ug({buckets:e.interactions||[],name:`interaction`,placeholder:`Interaction`})),t.push(mg({buckets:e.statuses||[],name:`status`,placeholder:`Status`})),t.push(Rg({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function Bg(e){return t=>{e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name;lg(e,n,cg(t))}}),e.search()}}function Vg({facets:e,search:r,selectionCount:i,actions:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=Y([]),f=s??u,p=c??d,m=J(!1),h=J(typeof window<`u`&&!!new URLSearchParams(window.location.search).get(`filters`)),g=zg(e),_=l??g,v=q(()=>Bg(r),[r]);return K(()=>{if(!m.current){m.current=!0;return}if(h.current){h.current=!1;return}v(f)},[f,v]),t(I,{filterGroups:_,filters:f,setFilters:p,children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!i&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted-foreground`,children:r.initialized?`${r.totalCount} agent runs`:`Loading agent runs...`})}),a&&a.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:a.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(qn,{className:`size-5`})})]})]}),f.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}var Hg=class{types;map={};constructor(e){this.types=e,e.sort((e,t)=>e.name.localeCompare(t.name));for(let t of e)this.map[t.id]=t}getType(e){return this.map[e]}getTypeLayout(e){let t=this.map[e];return t?t.table_layout:void 0}getTypeName(e){let t=this.map[e];return t?t.name:void 0}};const Ug=nt({registry:void 0,isLoading:!1,load:()=>Promise.resolve(),reload:()=>Promise.resolve()});function Wg({children:e}){let{store:n,project:r}=Z(),[i,a]=Y(),[o,s]=Y(!1),c=J(!1),l=J(r?.id),u=G(async()=>{if(!(!r||c.current)){c.current=!0,s(!0);try{let e=await n.types.catalog.list({layout:!0});a(new Hg(e))}catch(e){console.error(`Failed to fetch types`,e)}finally{s(!1),c.current=!1}}},[n,r]),d=G(async()=>(c.current=!1,u()),[u]);return K(()=>{l.current!==r?.id&&(l.current=r?.id,a(void 0),c.current=!1)}),t(Ug.Provider,{value:{registry:i,isLoading:o,load:u,reload:d},children:e})}function Gg(){let e=at(Ug);return K(()=>{!e.registry&&!e.isLoading&&e.load()},[e.registry,e.isLoading,e.load]),e}function Kg(e){let{registry:t}=Gg(),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t){let e=t.types.map(e=>({label:e.name,value:e.id})),r={name:`types`,placeholder:`Type`,type:`select`,multiple:!0,options:e,filterBy:(t,n)=>e.find(e=>e.value===t)?.label?.toLowerCase().includes(n.toLowerCase())??!1};n.push(r)}return n}function qg(e){return t=>{if(t.length===0){e.clearFilters(!0);return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name;lg(e,n,cg(t))}}),e.search()}}function Jg({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=Y([]),l=Kg(e),u=qg(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function Yg({buckets:e,typeRegistry:r,type:i=`select`,multiple:a=!1}){let o=new Map;return r||console.warn(`Type names cannot be resolved`),e.forEach(e=>{let t,n=e._id;e._id==null?(n=`Document`,t=`Document`):(t=r?.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),o.set(n,{name:t,count:e.count})}),{name:`types`,placeholder:`Types`,type:i,multiple:a,options:e.map(e=>{let t=e._id,n=t||`Document`,r=o.get(n);return{value:t,label:r?`${r.name} (${r.count})`:`Unknown (${e.count})`}}),labelRenderer:e=>{let r=o.get(e);return r?n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:r.name}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,r.count,`)`]})]}):(console.warn(`Type data not found for ${e}`),e)},filterBy:(e,t)=>{let n=o.get(e);return n?n.name.toLowerCase().includes(t.toLowerCase()):(console.warn(`Type name not found for ${e}`),!1)}}}function Xg(e){return Array.isArray(e)?e:[]}function Zg(e){let{registry:t}=Gg(),n=[];if(n.push({placeholder:`ID`,name:`id`,type:`text`,options:[]}),n.push({placeholder:`Name`,name:`name`,type:`text`,options:[]}),e.type){let r=Yg({buckets:Xg(e.type),typeRegistry:t,type:`select`,multiple:!0});n.push(r)}if(e.status){let t=mg({buckets:Xg(e.status),name:`status`,placeholder:`Status`,type:`select`,multiple:!0});n.push(t)}return e.tags&&n.push({name:`tags`,placeholder:`Tags`,type:`stringList`,options:Xg(e.tags).map(e=>({label:e._id,value:e._id}))}),n.push({name:`created_at`,placeholder:`Created Date`,type:`date`,multiple:!0,options:[]}),n.push({name:`updated_at`,placeholder:`Updated Date`,type:`date`,multiple:!0,options:[]}),n}function Qg(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name,r;if(t.type===`date`&&t.multiple){if(Array.isArray(t.value)&&t.value.length>0)if(t.value.length===1){let e=sg(t.value[0]);r={gte:e,lte:e}}else t.value.length===2&&(r={gte:sg(t.value[0]),lte:sg(t.value[1])})}else r=cg(t);n===`name`?lg(e,`name`,r):n===`id`?lg(e,`id`,r):lg(e,n,r)}}),e.search()}}function $g({facets:e,search:r}){let[i,a]=Y([]),o=Zg(e),s=Qg(r);return t(I,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},inModal:qe(),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function e_({search:e,buckets:n,placeholder:r=`All Environments`,className:i}){let{client:a}=Z(),[o,s]=Y([]),c=e.getFilterValue(`environment`),l=t=>{e.setFilterValue(`environment`,t?._id)};K(()=>{if(a){let e=n.map(async e=>{let t;return await a.environments.retrieve(e._id).then(e=>{t=e.name}).catch(()=>{t=`${e._id} (deleted)`}),t||=e._id,{...e,name:t}});Promise.all(e).then(e=>{e.sort((e,t)=>e.name.localeCompare(t.name)),s(e)})}},[n,a]);let u=o?.find(e=>e._id===c);return t(ye,{filterBy:`name`,className:i,isClearable:!0,optionLabel:fg,options:o,value:u,onChange:l,by:`_id`,placeholder:r})}function t_(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.push({name:`prompt`,placeholder:`Prompt Name`,type:`text`,multiple:!1}),t.push({name:`model`,placeholder:`Model`,type:`text`,multiple:!1}),t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),t}function n_(e){return t=>{if(t.length===0){e.clearFilters(!0,!0);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name;lg(e,n,cg(t))}}),e.search(!0)}}function r_({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=Y([]),l=t_(e),u=n_(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function i_(e){let t=[];return t.push(mg({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!1})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function a_({facets:e,filters:r,setFilters:i}){return t(I,{filterGroups:i_(e),filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function o_(e){let t=[];return t.push(mg({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!0})),t.push(Rg({buckets:e.started_by||[],name:`started_by`,placeholder:`Started By`})),t.push(mg({buckets:e.run_type||[],name:`run_type`,placeholder:`Mode`,multiple:!0})),t.push(mg({buckets:e.processes||[],name:`process`,placeholder:`Process`,multiple:!0})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function s_({facets:e,filters:r,setFilters:i}){return t(I,{filterGroups:o_(e),filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function c_(e){let t=[];if(t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),e.role&&e.role.length>0){let n={name:`role`,placeholder:`Role`,type:`select`,options:e.role.map(e=>({label:e._id,value:e._id,count:e.count}))};t.push(n)}let n={name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0,options:(e.tags??[]).map(e=>({label:e._id,value:e._id}))};return t.push(n),t}function l_(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name;lg(e,n,cg(t))}}),e.search()}}function u_({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=Y([]),l=c_(e),u=l_(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function d_({buckets:e,name:r}){let i=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:`environment`,placeholder:r.charAt(0).toUpperCase()+r.slice(1),options:i,type:`select`,labelRenderer:r=>{let i=e.find(e=>e._id===r);return n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:i?.name||r}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,i?.count||0,`)`]})]})},filterBy:(t,n)=>(e.find(e=>e._id===t)?.name||t).toLowerCase().includes(n.toLowerCase())}}function f_(e){let t=[];if(t.push({name:`run_ids`,placeholder:`Run ID`,type:`text`,multiple:!1}),e.interactions){let n=ug({buckets:e.interactions||[],name:`interaction`,placeholder:`Interactions`});t.push(n)}if(e.environments){let n=d_({buckets:e.environments||[],name:`environments`});t.push(n)}if(t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),e.models){let n=mg({buckets:e.models||[],name:`model`});t.push(n)}if(e.statuses){let n=mg({buckets:e.statuses||[],name:`status`});t.push(n)}if(e.finish_reason){let n=mg({buckets:e.finish_reason.map(e=>({...e,_id:e._id===null?`none`:e._id})),name:`finish_reason`,placeholder:`Finish Reason`});t.push(n)}if(e.created_by){let n=Rg({buckets:e.created_by||[],name:`created_by`,placeholder:`Created By`});t.push(n)}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`workflow_run_ids`,placeholder:`Workflow Run ID`,type:`text`,multiple:!1}),t.push({name:`workflow_ids`,placeholder:`Workflow ID`,type:`text`,multiple:!1}),t}function p_(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name,r=cg(t);(n===`run_ids`||n===`workflow_run_ids`||n===`workflow_ids`)&&!Array.isArray(r)&&(r=[r]),lg(e,n,r)}}),e.search()}}function m_({facets:e,search:r,actions:i,selectionCount:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=Y([]),f=f_(e),p=p_(r),m=s!==void 0&&c!==void 0,h=m?s:u;return t(I,{filterGroups:l??f,filters:h,setFilters:e=>{if(m){c(e);return}let t=typeof e==`function`?e(u):e;d(t),p(t)},children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!a&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} calls`:`Loading calls...`})}),i&&i.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:i.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(qn,{className:`size-5`})})]})]}),h.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}function h_({search:e,buckets:n,name:r,placeholder:i,className:a}){let o=e.getFilterValue(r),s=t=>{e.setFilterValue(r,t?._id)},c=n?.find(e=>JSON.stringify(e._id)===JSON.stringify(o));return t(ye,{filterBy:`_id`,className:a,isClearable:!0,optionLabel:dg,options:n,value:c,onChange:s,by:`_id`,placeholder:i})}function g_({search:e,name:n,placeholder:r,className:i}){let[a,o]=Y([]);return K(()=>{e.setFilterValue(n,a)},[n,e,a]),t(te,{className:i,value:a,onChange:o,placeholder:r})}function __(e){return`${e.name} (${e.count})`}function v_({search:e,buckets:n,placeholder:r=`Filter by Type`,className:i}){let[a,o]=Y([]),{registry:s}=Gg(),c=e.getFilterValue(`type`),l=t=>{e.setFilterValue(`type`,t?._id)};K(()=>{if(s){let e=n.map(e=>{let t;return e._id==null?(e._id=`Document`,t=`Document`):(t=s.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),{...e,name:t}});e.sort((e,t)=>e.name.localeCompare(t.name)),o(e)}},[n,s]);let u=a?.find(e=>e._id===c);return t(ye,{filterBy:`name`,className:i,isClearable:!0,optionLabel:__,options:a,value:u,onChange:l,by:`_id`,placeholder:r})}function y_(e){let t=[];return t.push(mg({buckets:e.tags||[],name:`tags`,placeholder:`Tags`,multiple:!0})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function b_({facets:e,filters:r,setFilters:i}){return t(I,{filterGroups:y_(e),filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function x_(e){let t=[];if(t.push({placeholder:`Workflow Name or Workflow Run ID`,name:`name`,type:`text`,options:[]}),e.status){let n=mg({buckets:e.status||[],name:`status`,placeholder:`Status`});t.push(n)}if(e.initiated_by){let n=Rg({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`});t.push(n)}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`has_reported_errors`,placeholder:`Has Reported Errors`,type:`select`,multiple:!1,options:[{label:`Yes`,value:`true`},{label:`No`,value:`false`}]}),t}function S_(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name,r=cg(t);if(n===`name`)lg(e,`search_term`,r),lg(e,`name`,r);else if(n===`has_reported_errors`){let t=Array.isArray(r)?r[0]:r;(t===`true`||t===`false`)&&lg(e,n,t===`true`)}else lg(e,n,r)}}),e.search()}}function C_({facets:e,search:r}){let[i,a]=Y([]),o=x_(e),s=S_(r);return t(I,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function w_(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function T_({facets:e,filters:r,setFilters:i}){return t(I,{filterGroups:w_(e),filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}var E_=class e{object;objects;setState;collectionId;singleSelection=!1;constructor(e,t,n,r){this.object=e,this.objects=n,this.setState=r,this.singleSelection=Object.keys(this.objects).length===0,this.collectionId=t}isSingleSelection(){return this.singleSelection}hasSelection(){return this.object!==void 0||this.size()!==0}size(){return Object.keys(this.objects).length}getObjectIds(){return Object.keys(this.objects)}getObjectId(){return this.object?.id}clone(){return new e(this.object,this.collectionId,this.objects,this.setState)}add(e){this.objects[e.id]=e,this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}remove(e){delete this.objects[e],this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}addAll(e){for(let t of e)this.objects[t.id]=t;this.setState(this.clone())}isSelected(e){return this.objects[e]!==void 0}removeAll(){this.objects={},this.singleSelection=!0,this.setState(this.clone())}};const D_=nt(void 0);function O_(){let e=at(D_);if(!e)throw Error(`useObjectSelection must be used within a ObjectSelectionProvider`);return e}function k_(){return at(D_)}function A_({value:e,collectionId:n,children:r}){let[i,a]=Y();return K(()=>{let t=new E_(e,n,{},a);a(t)},[n,e]),i&&t(D_.Provider,{value:i,children:r})}const j_=nt(void 0);function M_({onFilter:e,children:n}){return t(j_.Provider,{value:e,children:n})}function N_(){return at(j_)}const P_=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function F_({field:r,value:i,label:a,copyContent:s}){let c=N_(),l=Array.isArray(i)?i.length>0:i!==void 0&&i!==``;return n(e,{children:[s!==void 0&&s!==``&&t(x,{content:s,className:P_}),l&&i!==void 0&&t(o,{variant:`ghost`,size:`sm`,title:`Filter by ${a}`,className:P_,onClick:e=>{e.stopPropagation(),c?.(r,i)},children:t(cn,{className:`size-3`})})]})}const I_=`text/csv`,L_=`image/`,R_=`application/pdf`,z_=`video/`,B_=[`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/msword`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`,`application/vnd.ms-powerpoint`],V_=e=>e===I_||I_.includes(e),H_=e=>e.startsWith(L_)||L_.includes(e),U_=e=>e===R_||R_.includes(e),W_=e=>e.startsWith(z_)||z_.includes(e),G_=e=>B_.includes(e);function K_(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))});let a=i.createElement(`style`);return a.textContent=`
|
|
315
315
|
@media print {
|
|
316
316
|
body {
|
|
317
317
|
margin: 24px;
|
|
@@ -436,19 +436,26 @@ $&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
|
|
|
436
436
|
page-break-inside: avoid;
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
|
-
`,i.head.appendChild(a),i.body.innerHTML=e.innerHTML,r.focus(),r.print(),setTimeout(()=>{n.parentNode?.removeChild(n)},1e3),!0}const cv={max_hw:import.meta.env?.VITE_RENDITION_HW||256,format:gr.jpeg,generate_if_missing:!0},lv=`vertesia.content_store.renditionId`;async function uv(e,t,n,r,i){if(!t?.content?.type||!(rv(t.content.type)||av(t.content.type)||iv(t.content.type))){i(`No preview available`);return}i(`Preparing preview...`);let a=Date.now()/1e3,o=localStorage.getItem(`${lv}_${t.id}_${cv.max_hw}`),s=localStorage.getItem(`${lv}_${t.id}_${cv.max_hw}_time`);if(o?.length&&s&&Math.abs(a-parseInt(s,10))<=900)return n(o),r(`${t.name} Rendition`),i(`ready`),o;i(`Preparing preview...`),e.objects.getRendition(t.id,cv).then(a=>{if(a.status===`generating`)i(`Preparing preview...`),n(``),r(``),setTimeout(()=>uv(e,t,n,r,i),6e4);else if(a.status===`failed`){i(`No preview available`),n(``),r(``);return}else{if(!a?.renditions?.length){i(`No preview available`),n(``),r(``);return}let e=a.renditions[0];localStorage.setItem(`${lv}_${t.id}_${cv.max_hw}`,e),localStorage.setItem(`${lv}_${t.id}_${cv.max_hw}_time`,(Date.now()/1e3).toString()),n(e),r(`${t.name} Rendition`),i(`ready`),console.log(`Rendition for document ${t.id} retrieved successfully: ${e}`)}}).catch(e=>{i(`No preview available`),console.warn(`Failed to retrieve rendition:`,e),n(``),r(``)})}function dv(e,t=7){return e?`~${e.slice(-t)}`:``}function fv(e,t){return e.length>t?`${e.substring(0,t)}...`:e}function pv(e){switch(e){case Er.RUNNING:return`text-info`;case Er.COMPLETED:return`text-success`;case Er.FAILED:return`text-destructive`;case Er.TERMINATED:case Er.CANCELED:return`text-attention`;default:return`text-muted`}}function mv(e){switch(e){case Er.RUNNING:return`Running`;case Er.COMPLETED:return`Completed`;case Er.FAILED:return`Failed`;case Er.CONTINUED_AS_NEW:return`Continued As New`;case Er.TERMINATED:return`Terminated`;case Er.TIMED_OUT:return`Timed Out`;case Er.CANCELED:return`Canceled`;default:return`Unknown`}}Rr.extend(Pi),Rr.extend(Ni);function hv(e){return typeof e==`object`&&!!e}function gv(e,t){if(!hv(e))return;let n=e[t];return typeof n==`string`?n:void 0}function _v(e){return typeof e==`string`?e:gv(e,`id`)||``}function vv(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:String(e)}const yv={string(e,r){let i=[];if(e){let t=e.get(`slice`);t&&i.push(e=>e.slice(parseInt(t,10)));let n=e.get(`max_length`);n&&i.push(e=>e.slice(0,parseInt(n,10))),e.has(`upper`)&&i.push(e=>e.toUpperCase()),e.has(`lower`)&&i.push(e=>e.toLowerCase()),e.has(`capitalize`)&&i.push(e=>e[0].toUpperCase()+e.substring(1)),e.has(`ellipsis`)&&i.push(e=>`${e}...`)}return(e,r,a)=>{let o;if(e){if(o=String(e),i.length>0)for(let e of i)o=e(o)}else o=``;return t(`td`,{className:`group/field`,children:a?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:o}),a]}):o},r)}},fileSize(e,n){return(e,n)=>{let r=``;if(e){let t=Number(e);if(Number.isNaN(t))r=String(e);else{let e=[`Bytes`,`KB`,`MB`,`GB`,`TB`];if(t===0)r=`0 Bytes`;else{let n=Math.floor(Math.log(t)/Math.log(1024));r=`${(t/1024**n).toFixed(2)} ${e[n]}`}}}return t(`td`,{className:`group/field`,children:r},n)}},number(e,n){let r,i;e&&(r=e.get(`currency`)||void 0,i=e.get(`decimals`)||void 0);let a=i?parseInt(i,10):2;return(e,n)=>{let i=Number(e);return t(`td`,{className:`group/field`,children:new Intl.NumberFormat(`en-US`,{style:r?`currency`:`decimal`,currency:r,maximumFractionDigits:a}).format(Number.isFinite(i)?i:0)},n)}},objectId(e,r){let i=[],a=!1;if(e){let t=e.get(`slice`);t&&(a=!0,i.push(e=>e.slice(parseInt(t,10))))}return(e,s,c)=>{let l=_v(e),u=i.reduce((e,t)=>t(e),l);return n(`td`,{className:`flex justify-start items-center gap-2 group/field`,children:[t(o,{variant:`ghost`,"aria-label":`Preview Object`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),r?.(l)},children:t(Ut,{className:`size-4`})}),a?`~`:``,u,c]},s)}},objectName(e,r){let i=`title`;return e&&(i=e.get(`title`)||`title`),(e,r,a)=>{let o=(hv(e)&&hv(e.properties)?e.properties:void 0)?.[i],s=vv(o),c=gv(e,`name`),l=gv(e,`id`),u=s||c||(l?dv(l):``);return t(`td`,{className:`group/field`,children:a?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:u}),a]}):u},r)}},objectLink(e,r){let i=[];return i.push(e=>e.slice(-7)),(e,a)=>{let s=_v(e);return n(`td`,{className:`flex justify-between items-center gap-2 max-w-48 group/field`,children:[`~`,i.reduce((e,t)=>t(e),s),t(o,{variant:`ghost`,alt:`Preview Object`,onClick:e=>{e.stopPropagation(),r?.(s)},children:t(Ut,{className:`size-4`})})]},a)}},typeLink(e,r){return(e,r,i)=>{let a=gv(e,`name`)||`n/a`;return t(`td`,{className:`group/field`,children:i?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:a}),i]}):a},r)}},revision(e,r){return(e,r)=>{let i=hv(e)&&hv(e.revision)?e.revision:void 0;if(!i)return t(`td`,{},r);let a=gv(i,`root`),o=gv(i,`label`);return t(`td`,{className:`group/field`,children:n(`div`,{className:`flex flex-col gap-0.5`,children:[a&&n(`div`,{className:`flex items-center gap-1`,children:[n(`span`,{className:`text-xs text-muted font-mono`,children:[`root: ~`,a.slice(-7)]}),t(`a`,{href:`/store/objects/${a}`,onClick:e=>e.stopPropagation(),children:t(Vt,{className:`size-3 text-muted`})})]}),o&&n(`span`,{className:`text-xs text-muted`,children:[`label: `,o]})]})},r)}},date(e,r){let i=`fromNow`,a;if(e){let t=e.get(`localized`);if(t)i=`format`,a=t;else{let t=e.get(`relative`);t&&(i=t)}}return(e,r,o)=>{let s=typeof e==`string`||typeof e==`number`||e instanceof Date?e:void 0;if(s===void 0)return t(`td`,{children:o},r);let c=Rr(s),l=i===`format`?c.format(a):i===`toNow`?c.toNow():c.fromNow();return t(`td`,{className:`group/field`,children:n(`div`,{className:`flex items-center gap-2`,children:[t(Me,{description:c.format(`LLL`),children:l}),o]})},r)}}},bv=yv.string();function xv(e){return typeof e==`object`&&!!e}function Sv(e,t){let n=e;if(!n)return;if(!t.length)return n;let r=t.length-1;for(let e=0;e<r;e++)if(!xv(n)||(n=n[t[e]],!n))return;if(xv(n))return n[t[r]]}function Cv(e){return!e||e===`.`?[]:e.split(`.`)}var wv=class{layout;renderer=bv;path;fallbackPath;previewObject;constructor(e,t){if(this.layout=e,this.path=Cv(e.field||``),this.fallbackPath=e.fallback?Cv(e.fallback):void 0,this.previewObject=t,e.render)this.renderer=(e,t)=>null;else{let t=e.type||`string`,n=t.indexOf(`?`);if(n>0){let e=t.substring(0,n),r=new URLSearchParams(t.substring(n+1));this.renderer=yv[e](r)}else this.renderer=yv[t]()}}get name(){return this.layout.name}resolveValue(e){let t=Sv(e,this.path);return t===void 0&&this.fallbackPath&&(t=Sv(e,this.fallbackPath)),t===void 0&&(t=this.layout.default),t}render(e,n){if(this.layout.render)return t(`td`,{className:`whitespace-nowrap px-3 py-4 text-sm group`,children:this.layout.render(e)},n);let r=this.layout.type||`string`,i=r.indexOf(`?`)>0?r.substring(0,r.indexOf(`?`)):r,a=this.buildActions(e,i);if((i===`objectId`||i===`objectLink`)&&this.previewObject){let t=r.indexOf(`?`),o=t>0?new URLSearchParams(r.substring(t+1)):void 0;return yv[i](o,t=>{this.previewObject?.(e.id)})(e,n,a)}return this.renderer(this.resolveValue(e),n,a)}buildActions(e,n){let r=this.layout.field;if(n===`objectId`||n===`objectLink`||r===`id`)return t(X_,{field:`id`,value:e.id,label:e.id,copyContent:e.id});if(n===`objectName`||r===`name`)return t(X_,{field:`name`,value:e.name,label:e.name??e.id});if(n===`typeLink`||r===`type.name`||r===`type`){let n=e.type?.id;return t(X_,{field:`type`,value:n,label:e.type?.name??n??`type`})}if(r===`status`)return t(X_,{field:`status`,value:e.status,label:e.status})}};function Tv({isLoading:e=!1,counts:r=6}){return e?t(`div`,{className:`flex flex-wrap gap-2 justify-between`,children:Array(r).fill(0).map((e,r)=>t(`div`,{className:`w-[15vw] animate-pulse`,children:n(s,{className:`relative flex flex-col border h-fit`,children:[t(`div`,{className:`h-48 bg-muted rounded-t-xl flex items-center justify-center text-muted`,children:`\xA0`}),t(ge,{className:`bg-muted h-[2px]`}),n(c,{className:`p-2 flex flex-col`,children:[n(`div`,{className:`flex flex-col overflow-hidden`,children:[t(`div`,{className:`h-5 bg-muted rounded w-3/4 mb-2`}),t(`div`,{className:`h-4 bg-muted rounded w-1/2`})]}),t(`div`,{className:`text-xs text-muted w-full flex justify-end mt-2`,children:t(`div`,{className:`h-3 bg-muted rounded w-1/4`})})]})]})},`skeleton-${r}`))}):null}function Ev({selection:e,document:r,onSelectionChange:i,onRowClick:a,highlightRow:l,previewObject:u,selectedObject:d}){let{client:f}=Z(),[p,m]=Y(void 0),[h,g]=Y(void 0),[_,v]=Y(void 0),y=typeof r.properties?.title==`string`?r.properties.title:r.name,b=e=>{e.stopPropagation(),i(r,e)};K(()=>{r?.content&&uv(f,r,m,g,v)},[f,r]);let x=l?.(r);return n(s,{className:`relative flex flex-col border h-fit w-full ${d?.id===r.id?`border-attention border-4`:``} ${x?`border-blue-400 dark:border-blue-500 bg-blue-50/50 dark:bg-blue-900/20`:``}`,onClick:()=>a?.(r),children:[x&&t(`div`,{className:`absolute top-2 end-8 z-10`,children:t(vt,{className:`size-4 text-blue-600 dark:text-blue-400`})}),e&&t(`div`,{className:`absolute top-2 start-2 z-10 flex flex-col items-center gap-1`,children:t(`input`,{checked:e.isSelected(r.id),type:`checkbox`,onChange:b,onClick:e=>e.stopPropagation()})}),t(`div`,{className:`absolute top-1 end-1 z-10 flex flex-col items-center`,children:t(o,{variant:`ghost`,size:`sm`,title:`Preivew Object`,onClick:e=>{e.stopPropagation(),u?.(r.id)},children:t(Ut,{className:`size-4 ${_===`ready`?`text-muted`:`text-white`}`})})}),p&&_===`ready`?t(`img`,{src:p,alt:h,className:`w-auto h-48 object-cover rounded-t-xl`}):t(`div`,{className:`h-48 bg-gray-700 rounded-t-xl flex items-center justify-center text-muted`,children:_}),t(ge,{className:`bg-gray-200 h-[2px]`}),n(c,{className:`p-2 flex flex-col`,children:[n(`div`,{className:`flex flex-col overflow-hidden`,children:[t(Me,{placement:`top`,description:y,children:t(`h3`,{className:`text-start font-medium leading-none truncate`,children:y})}),r?.type?.name?t(Me,{placement:`bottom`,size:`xs`,description:r?.type?.name,children:t(`p`,{className:`text-start text-xs text-muted truncate`,children:r?.type?.name})}):t(`p`,{className:`text-xs text-muted`,children:` `})]}),r.score&&n(`div`,{className:`text-xs text-muted w-full flex justify-end`,children:[`Score: `,r.score.toFixed(4)??`-`]})]})]})}function Dv({objects:e,selection:r,isLoading:i,columns:a,onRowClick:o,highlightRow:s,selectedObject:c,toggleAll:l,onSelectionChange:u}){let{t:d}=X();return n(Ee,{className:`w-full`,children:[t(we,{children:n(`tr`,{children:[r&&t(`th`,{children:t(`input`,{type:`checkbox`,onChange:l})}),a.map(e=>t(`th`,{children:e.name},e.name))]})}),n(Ce,{isLoading:i,columns:a.length+1,children:[e?.map(e=>{let i=s?.(e);return n(`tr`,{className:`group cursor-pointer hover:bg-muted ${c?.id===e.id?`bg-muted`:``} ${i?`bg-blue-50 dark:bg-blue-900/20`:``}`,onClick:()=>{o?.(e)},children:[r&&t(`td`,{onClick:e=>e.stopPropagation(),children:t(`input`,{checked:r.isSelected(e.id),type:`checkbox`,className:`${r.isSelected(e.id)?``:`hidden group-hover:block`}`,onChange:t=>u(e,t)})}),a.map((t,n)=>t.render(e,n)),t(`td`,{className:`w-8 text-center`,children:i&&t(vt,{className:`size-4 text-blue-600 dark:text-blue-400 inline-block`})})]},e.id)}),e.length===0&&t(`tr`,{children:t(`td`,{colSpan:a.length+ +!!r,className:`text-center`,children:d(`store.noObjectsDragAndDrop`)})})]})]})}function Ov({objects:r,selection:i,isLoading:a,onSelectionChange:o,onRowClick:s,highlightRow:c,previewObject:l,selectedObject:u}){return n(e,{children:[t(Tv,{isLoading:a}),t(`div`,{className:`w-full gap-2 grid xs:grid-cols-1 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-6 @xs:grid-cols-1 @sm:grid-cols-2 @md:grid-cols-3 @lg:grid-cols-4`,children:r.map(e=>t(Ev,{document:e,selection:i,onSelectionChange:o,onRowClick:s,highlightRow:c,previewObject:l,selectedObject:u},e.id))})]})}var kv=class{client;limit;collectionId;facets=new _e({});result=new _e({objects:[],isLoading:!1});initialized=!1;facetSpecs=[];query={};constructor(e,t=100){this.client=e,this.limit=t}withFacets(e){return this.facetSpecs=e,this}get objects(){return this.result.value.objects}get error(){return this.result.value.error}get isRunning(){return this.result.value.isLoading}get hasMore(){return this.result.value.hasMore||!1}getFilterValue(e){return this.query[e]}setFilterValue(e,t){this.query[e]=t,this.search()}setDefaultKeys(e){}clearFilters(e=!0){let{parent:t,full_text:n,vector:r,weights:i,score_aggregation:a,dynamic_scaling:o,limit:s,all_revisions:c}=this.query;this.query={parent:t,...n!==void 0&&{full_text:n},...r!==void 0&&{vector:r},...i!==void 0&&{weights:i},...a!==void 0&&{score_aggregation:a},...o!==void 0&&{dynamic_scaling:o},...s!==void 0&&{limit:s},...c!==void 0&&{all_revisions:c}},e&&this.search()}getFacetBuckets(e){let t=this.facets.value[e];return Array.isArray(t)?t:[]}resetFacets(){this.query={}}reset(e=!1){this.initialized=!1,this.result.value={objects:[],isLoading:e,hasMore:!0}}_updateRunningState(e){let t=this.result.value;this.result.value={objects:t.objects,isLoading:e,error:t.error,hasMore:t.hasMore}}_searchRequest(e,t,n,r=!0){let i={limit:t,offset:n,query:e,facets:r?this.facetSpecs:void 0};return this.collectionId?this.client.collections.searchMembers(this.collectionId,i):this.client.objects.search(i)}_facetsRequest(){let e={facets:this.facetSpecs,query:this.query};return this.collectionId?this.client.collections.computeFacets(this.collectionId,e):this.client.objects.computeFacets(e)}computeFacets(e){this._facetsRequest().then(e=>{this.facets.value=e})}async _search(e=!1,t=!1){if(this.isRunning&&e)return!1;let n=this.result.value;e||(this.initialized=!0),this.result.value={isLoading:!0,objects:e?this.objects:[],hasMore:e?this.result.value.hasMore:!0};let r=this.limit,i=e?this.objects.length:0;try{let n=await this._searchRequest(this.query,r,i,!t),a=n.results||[],o=n.facets||{};return this.result.value={isLoading:!1,objects:e?this.objects.concat(a):a,hasMore:a.length===r},!t&&o&&Object.keys(o).length>0&&(this.facets.value=o),!0}catch(e){if(typeof e==`object`&&e&&`status`in e&&e.status===404)return this.result.value={isLoading:!1,objects:[],hasMore:!1},!1;let t=e instanceof Error?e:Error(String(e));return this.result.value={error:t,isLoading:!1,objects:n.objects,hasMore:!1},!1}}search(e=!1){return this.isRunning?Promise.resolve(!1):this._search(!1,e)}loadMore(e=!1){return this.isRunning||!this.hasMore||this.query.vector?Promise.resolve(!1):(this.objects.length>0&&(e=!0),this._search(!0,e))}};const Av=Ye(void 0);function jv(){return Qe(Av)}function Mv(){return Ue(jv().facets)}function Nv(){let e=jv();return{...Ue(e.result),search:e}}function Pv(){return Ue(jv().facets).total}const Fv=rt.getFixedT(null,nt);var Iv;(function(e){e.CREATE=`create`,e.SKIP=`skip`,e.UPDATE=`update`})(Iv||={});async function Lv(e){try{let t=await e.arrayBuffer(),n=new Fi;return n.appendByteArray(new Uint8Array(t)),n.end()?.toString()}catch(e){console.error(`Error calculating file hash:`,e);return}}async function Rv(e,t){let n=[];for(let r=0;r<e.length;r+=5){let i=e.slice(r,r+5),a=await Promise.all(i.map(async e=>{let n=t||`/`;if(e.webkitRelativePath){let r=e.webkitRelativePath.split(`/`);if(r.length>1){let e=r.slice(0,-1).join(`/`);n=t?`${t}/${e}`:e}}return{file:e,hash:await Lv(e),name:e.name,size:e.size,location:n}}));n.push(...a)}return n}function zv(){let{client:e}=Z(),t=He();return{checkDocumentProcessing:G(async(n,r,i)=>{try{console.log(`Preparing metadata for ${n.length} files...`);let t=await Rv(n,r);return await(async()=>{let n=t.map(e=>e.hash).filter(Boolean);if(n.length===0)return;let r={"content.etag":{$in:n}},a;if(i){let t={query:{match:r},select:`id content.etag`};a=(await e.store.collections.searchMembers(i,t)).results}else{let t={query:r,select:`id content.etag`};a=await e.store.objects.find(t)}for(let e of a){let n=t.find(t=>t.hash===e.content?.etag);n&&(n.existingId=e.id,n.action=Iv.SKIP)}})(),await(async()=>{let n=t.filter(e=>e.action!==Iv.SKIP),r=n.map(e=>e.location),a=Array.from(new Set(r)),o=[];for(let t of a){let r={"content.name":{$in:n.filter(e=>e.location===t).map(e=>e.name)},location:t||`/`};if(i){let t=e.store.collections.searchMembers(i,{query:{match:r},select:`id content.name location`}).then(e=>e.results);o.push(t)}else{let t=e.store.objects.find({query:r,select:`id content.name location`});o.push(t)}}let s=(await Promise.all(o)).flat();console.log(`Found ${s.length} document to update`,s);for(let e of s){let n=t.find(t=>t.name===e.content?.name&&(t.location?t.location===e.location:e.location===`/`));n&&(n.existingId=e.id,n.action=Iv.UPDATE)}console.log(`Reconciled ${t.filter(e=>e.action===Iv.UPDATE).length}`)})(),t.forEach(e=>{e.action||=Iv.CREATE}),console.log(`Document processing check results:`,{totalFiles:n.length,toCreate:t.filter(e=>e.action===Iv.CREATE).length,toUpdate:t.filter(e=>e.action===Iv.UPDATE).length,toSkip:t.filter(e=>e.action===Iv.SKIP).length}),t}catch(e){throw t({title:Fv(`store.errorInUploadProcessingCheck`),status:`error`,description:Ne(e)}),console.log(`Error in file upload processing check`,e),Error(`Error in file upload processing check: ${Ne(e)}`,{cause:e})}},[e,t])}}function Bv({isOpen:r,onClose:i,files:a,collectionId:s,selectedFolder:c,title:l,children:u,onUploadComplete:d,hideFileSelection:f=!1,showTypeSelectionOnly:p=!1,allowFolders:m=!0}){let{client:h}=Z(),{registry:g}=o_(),_=He(),{t:v}=X(),y=l??v(`upload.uploadFiles`),[b,x]=Y([]),[S,C]=Y([]),[w,T]=Y(!1),[E,D]=Y(null),[O,k]=Y([]),[A,j]=Y(!1),[M,N]=Y(!1),[P,F]=Y(0),[I,L]=Y(Date.now()),[R,z]=Y(void 0),[ie,ae]=Y(null),[oe,se]=Y(y),[ce,le]=Y(``);K(()=>{s&&h.store.collections.retrieve(s).then(z)},[h.store.collections.retrieve,s]),K(()=>{A?(se(v(`upload.uploadingFiles`)),le(`${Math.round(P)}% complete`)):M?(se(v(`upload.uploadComplete`)),le(``)):w?(se(v(`upload.fileAnalysisResults`)),le(`${b.length} file${b.length===1?``:`s`}`)):b.length>0?(se(y),le(v(`upload.checkingForDuplicates`))):(se(y),le(``))},[A,M,w,y,P,b.length,v]);let ue=()=>!R&&!c?null:n(ee,{className:`mb-4`,status:`default`,icon:t(Zt,{className:`size-5`}),children:[t(`div`,{className:`flex items-center`,children:t(`span`,{className:`font-medium`,children:v(`upload.uploadLocation`)})}),n(`div`,{className:`text-sm mt-1`,children:[R&&n(`div`,{className:`flex items-center`,children:[t(`span`,{className:`me-1`,children:v(`upload.collectionLabel`)}),t(`span`,{className:`font-medium`,children:R.name})]}),c&&n(`div`,{className:`flex items-center mt-1`,children:[t(`span`,{className:`me-1`,children:v(`upload.folderLabel`)}),t(`span`,{className:`font-medium`,children:c})]})]})]}),[de,fe]=Y({toCreate:0,toUpdate:0,toSkip:0}),{checkDocumentProcessing:pe}=zv(),me=q(()=>g?.types||[],[g?.types]),he=G(async e=>{if(e.length)try{console.log(`Processing ${e.length} files to determine required actions...`);let t=await pe(e,c,s);C(t);let n=t.filter(e=>e.action===Iv.CREATE).length,r=t.filter(e=>e.action===Iv.UPDATE).length,i=t.filter(e=>e.action===Iv.SKIP).length;fe({toCreate:n,toUpdate:r,toSkip:i}),_({title:v(`upload.filesAnalyzed`),description:`${e.length} file(s): ${n} new, ${r} to update, ${i} to skip`,status:`info`,duration:4e3}),T(!0)}catch(e){console.error(`Error processing files:`,e),_({title:v(`agent.error`),description:v(`upload.errorAnalyzingFiles`),status:`error`,duration:5e3})}},[pe,s,c,v,_]);K(()=>{r&&(C([]),T(!1),D(null),k([]),j(!1),N(!1),F(0),fe({toCreate:0,toUpdate:0,toSkip:0}),ae(null),se(y),le(``),a&&a.length>0?(x(a),he(a)):x([]),L(Date.now()))},[r,a,he,y]);let ge=()=>{x([]),C([]),T(!1),D(null),k([]),j(!1),N(!1),F(0),fe({toCreate:0,toUpdate:0,toSkip:0}),ae(null),se(y),le(``),L(Date.now()),i()},_e=e=>{e&&e.length>0&&(x(e),he(e))},ve=async()=>{if(!S.length)return;let e=E?.id||null,t=S.map(e=>({file:e.file,status:`pending`,progress:0,action:e.action===Iv.CREATE?`create`:e.action===Iv.UPDATE?`update`:`skip`}));k(t),j(!0),N(!1);let n=S.filter(e=>e.action===Iv.SKIP),r=S.filter(e=>e.action===Iv.UPDATE),i=S.filter(e=>e.action===Iv.CREATE),a={success:!0,objectIds:[],uploadedFiles:[],skippedFiles:[],failedFiles:[]};for(let t of n)t.existingId&&(a.objectIds.push(t.existingId),a.skippedFiles.push({id:t.existingId,name:t.name,type:e,status:`skipped`,location:t.location}),k(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:t.existingId}:e)));let o=async(t,n)=>{let r=[];for(let e=0;e<t.length;e+=50)r.push(t.slice(e,e+50));for(let i=0;i<r.length;i++){let o=r[i];if(console.log(`Processing ${n} batch ${i+1}/${r.length} (${o.length} files)`),t.length>50){let e=i*50;_({title:v(`upload.processingFilesAction`,{action:n}),description:v(`upload.processedCount`,{processed:e,total:t.length}),status:`info`,duration:2e3})}let c=0;await Promise.all(o.map(async t=>{try{if(k(e=>e.map(e=>e.file===t.file?{...e,status:`uploading`,progress:20}:e)),n===`update`&&t.existingId)await h.store.objects.update(t.existingId,{type:e||void 0,content:t.file,location:t.location,name:t.name},{createRevision:!0,revisionLabel:`upload on ${new Date().toISOString()}`}),k(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:t.existingId}:e)),a.objectIds.push(t.existingId),a.uploadedFiles.push({id:t.existingId,name:t.name,type:e,status:`updated`,location:t.location});else{let n=await h.store.objects.create({type:e||void 0,content:t.file,location:t.location||t.file.webkitRelativePath||t.name},{collection_id:s});k(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:n.id}:e)),a.objectIds.push(n.id),a.uploadedFiles.push({id:n.id,name:t.name,type:e,status:`created`,location:t.location})}}catch(n){console.error(`Failed to process file ${t.name}:`,n),k(e=>e.map(e=>e.file===t.file?{...e,status:`error`,progress:100,message:Ne(n,`Unknown error`)}:e)),a.failedFiles.push({name:t.name,error:Ne(n,`Unknown error`),status:`failed`,location:t.location,type:e}),a.success=!1}c++,(c%5==0||c===o.length)&&k(e=>{let t=e.filter(e=>e.status===`success`||e.status===`error`).length,n=e.length,r=n>0?Math.round(t/n*100):0;return F(r),e})}))}};r.length>0&&await o(r,`update`),i.length>0&&await o(i,`create`),k(e=>{let t=e.filter(e=>e.status===`pending`).map(e=>({...e,status:`error`,progress:100,message:v(`upload.uploadProcessInterrupted`)}));return t.length>0?(t.forEach(e=>{a.failedFiles.push({name:e.file.name,error:v(`upload.uploadProcessInterrupted`),status:`failed`,type:E?.id||null})}),a.success=!1,e.map(e=>e.status===`pending`?{...e,status:`error`,progress:100,message:v(`upload.uploadProcessInterrupted`)}:e)):e}),j(!1),N(!0);let c=a.uploadedFiles.filter(e=>e.status===`created`).length,l=a.uploadedFiles.filter(e=>e.status===`updated`).length,u=a.skippedFiles.length,d=a.failedFiles.length,f=``;c>0&&(f+=`${c} file${c===1?``:`s`} uploaded`),l>0&&(f+=f?`, `:``,f+=`${l} file${l===1?``:`s`} updated`),u>0&&(f+=f?`, `:``,f+=`${u} file${u===1?``:`s`} skipped`),d>0&&(f+=f?`, `:``,f+=`${d} file${d===1?``:`s`} failed`),_({title:v(`upload.uploadComplete`),description:f,status:d>0?`warning`:`success`,duration:5e3}),ae(a)},ye=()=>n(`div`,{className:`mb-4`,children:[n(`div`,{className:`block text-sm font-medium mb-2`,children:[v(`store.contentType`),` `,t(`span`,{className:`text-muted font-normal`,children:v(`store.optional`)}),t(Me,{description:v(`upload.contentTypeTooltip`),placement:`top`,size:`xs`,children:t(on,{className:`size-3 ms-2`})})]}),t(V,{options:me,value:E,optionLabel:e=>e?e.name:v(`store.selectContentTypeLabel`),placeholder:v(`store.selectContentTypeAuto`),onChange:e=>D(e===void 0?null:e),filterBy:`name`,isClearable:!0}),!E&&t(`div`,{className:`p-2 rounded-md`,children:n(`div`,{className:`flex items-center text-attention`,children:[t(_t,{className:`size-4 me-1`}),v(`store.automaticTypeDetection`),t(Me,{description:v(`store.automaticTypeDetectionDescription`),placement:`top`,size:`xs`,children:t(on,{className:`size-3 ms-2`})})]})})]});return n(B,{isOpen:r,onClose:ge,className:`mx-auto`,disableCloseOnClickOutside:!0,children:[t(re,{description:ce,children:oe}),p?n(te,{children:[u,ue(),ye()]}):b.length===0&&!f?n(te,{className:`flex flex-col items-center justify-center p-8`,children:[ue(),t(mi,{onDrop:_e,message:v(`upload.dragAndDrop`),buttonLabel:v(`upload.selectFiles`),className:`w-full h-64`,allowFolders:m}),u]}):!A&&!M?t(te,{children:w?n(e,{children:[ue(),t(`div`,{className:`mb-4`,children:t(`div`,{className:`p-4 rounded-md mb-4`,children:n(`div`,{className:`grid grid-cols-3 gap-4`,children:[n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(Zn,{className:`size-5 text-primary`}),t(`span`,{className:`font-medium`,children:v(`upload.new`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:de.toCreate})]}),n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(_t,{className:`size-5 text-success`}),t(`span`,{className:`font-medium`,children:v(`upload.update`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:de.toUpdate})]}),n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(ot,{className:`size-5 text-mixer-attention/40`}),t(`span`,{className:`font-medium`,children:v(`upload.skip`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:de.toSkip})]})]})})}),ye(),t(ee,{className:`mb-4`,status:`info`,children:de.toCreate+de.toUpdate>0?n(`div`,{className:`space-y-1`,children:[t(`p`,{children:v(`upload.filesReadyToProcess`,{count:de.toCreate+de.toUpdate})}),t(`p`,{children:de.toSkip>0&&v(`upload.filesToSkip`,{count:de.toSkip})})]}):de.toSkip>0?t(`span`,{children:v(`upload.allFilesExist`,{count:de.toSkip})}):t(`span`,{children:v(`upload.noFilesToProcess`)})})]}):n(`div`,{className:`flex flex-col items-center justify-center py-4`,children:[t(be,{size:`lg`,className:`mb-4`}),t(`div`,{className:`text-lg font-medium`,children:v(`upload.analyzingFiles`)})]})}):A?n(te,{children:[ue(),t(`div`,{className:`mb-4`,children:t(`div`,{className:`h-2 bg-muted/20 rounded-full overflow-hidden`,children:t(`div`,{className:`h-full bg-primary rounded-full`,style:{width:`${P}%`}})})}),t(`div`,{className:`max-h-96 overflow-y-auto`,children:O.map((e,r)=>n(`div`,{className:`flex items-center py-2 border-b border-border last:border-b-0`,children:[n(`div`,{className:`me-3`,children:[e.status===`pending`&&t(Gt,{className:`size-5 text-muted`}),e.status===`uploading`&&t(be,{size:`sm`}),e.status===`success`&&t(_t,{className:`size-5 text-success`}),e.status===`error`&&t(ir,{className:`size-5 text-destructive`})]}),n(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`truncate font-medium`,children:e.file.name}),n(`div`,{className:`text-xs text-muted`,children:[e.status===`pending`&&v(`agent.waiting`),e.status===`uploading`&&v(`agent.uploading`),e.status===`success`&&(e.action===`create`?v(`store.created`):e.action===`update`?v(`store.updated`):v(`upload.skip`)),e.status===`error`&&e.message]})]})]},`${e.file.name}-${e.file.size}-${e.file.lastModified}`))})]}):t(te,{children:n(`div`,{className:`mb-4`,children:[ue(),t(Ci,{files:O.map(e=>{let t;return t=e.status===`success`?e.action===`create`?`success`:e.action===`update`?`updated`:`skipped`:`failed`,{name:e.file.name,status:t,error:e.status===`error`?e.message:void 0}}),location:c||void 0,collection:R?.name})]})}),(()=>{if(p)return n(ne,{children:[t(o,{variant:`ghost`,onClick:ge,children:v(`modal.cancel`)}),t(o,{onClick:()=>{let e={success:!0,objectIds:[],uploadedFiles:[{name:`type-selection`,type:E?.id||null,status:`created`}],skippedFiles:[],failedFiles:[]};d&&d(e),ge()},children:E?v(`upload.useTypeName`,{typeName:E.name}):v(`upload.useAutoDetection`)})]});if(b.length===0&&!f)return t(ne,{children:t(o,{variant:`ghost`,onClick:ge,children:v(`modal.cancel`)})});if(!A&&!M){let e=w;return n(ne,{children:[t(o,{variant:`ghost`,onClick:ge,children:v(`modal.cancel`)}),t(o,{disabled:!e,onClick:ve,children:de.toCreate+de.toUpdate>0?v(`agent.upload`):v(`upload.continue`)})]})}return A?t(ne,{children:t(o,{variant:`ghost`,disabled:!0,children:v(`agent.uploading`)})}):n(ne,{children:[t(o,{variant:`ghost`,onClick:()=>{x([]),C([]),T(!1),D(null),k([]),j(!1),N(!1),F(0),fe({toCreate:0,toUpdate:0,toSkip:0})},children:v(`upload.uploadMore`)}),t(o,{onClick:()=>{d&&ie&&d(ie),ge()},children:v(`agent.close`)})]})})()]},I)}function Vv(e){let t=typeof e==`function`?e:e.onUploadDone,{client:n,project:r,store:i}=Z(),a=jv(),o=He(),s=rt.getFixedT(null,nt),{checkDocumentProcessing:c}=zv();return async(e,l,u)=>{let d={success:!1,objectIds:[],uploadedFiles:[],skippedFiles:[],failedFiles:[]};if(!r)return o({status:`error`,title:s(`store.noProjectSelected`),duration:3e3}),d;if(!e||e.length===0)return o({status:`warning`,title:s(`store.noFilesSelected`),duration:3e3}),d;let f=Array.from(e).filter(e=>e.size>0);if(f.length===0)return o({status:`error`,title:s(`store.noValidFilesSelected`),description:s(`store.pleaseSelectValidFiles`),duration:5e3}),d;let p=[],m=[],h=[];console.log(`Processing ${f.length} files with smart file processing...`);let g=await c(f,null,u),_=g.filter(e=>e.action===Iv.CREATE).length,v=g.filter(e=>e.action===Iv.UPDATE).length,y=g.filter(e=>e.action===Iv.SKIP).length;o({title:s(`store.filesAnalyzedTitle`),description:`${f.length} file(s): ${_} new, ${v} to update, ${y} to skip`,status:`info`,duration:4e3});for(let e of g.filter(e=>e.action===Iv.SKIP&&e.existingId))p.push({id:e.existingId,name:e.name,type:l,status:`skipped`,location:e.location});let b=g.filter(e=>(e.action===Iv.CREATE||e.action===Iv.UPDATE)&&e.file);if(b.length>0){console.log(`Processing ${b.length} files (${b.filter(e=>e.action===Iv.CREATE).length} create, ${b.filter(e=>e.action===Iv.UPDATE).length} update)...`);let e=[];for(let t=0;t<b.length;t+=50)e.push(b.slice(t,t+50));for(let t=0;t<e.length;t++){let r=e[t],a=t*50;console.log(`Processing batch ${t+1}/${e.length} (${r.length} files)`),b.length>50&&o({title:s(`store.processingFiles`),description:`Processed ${a}/${b.length} files...`,status:`info`,duration:2e3});let c=await Promise.all(r.map(async e=>{try{if(e.action===Iv.UPDATE&&e.existingId){let t=await n.store.objects.update(e.existingId,{type:l||void 0,content:e.file,location:e.location,name:e.name},{createRevision:!0,revisionLabel:`upload on ${new Date().toISOString()}`});return m.push({id:e.existingId,name:e.name,type:l,status:`updated`,location:e.location}),d.objectIds.push(e.existingId),{success:!0,id:t.id,name:e.name,action:`update`}}else{let t=u?{collection_id:u}:void 0,n=await i.objects.create({type:l||void 0,content:e.file,location:e.location||e.file.webkitRelativePath||e.name},t);m.push({id:n.id,name:e.name,type:l,status:`created`,location:e.location})}}catch(t){console.error(`Failed to process file ${e.name}:`,t),h.push({name:e.name,error:Ne(t,`Unknown error`),status:`failed`,location:e.location,type:l}),o({status:`error`,title:s(`store.processingFailedFor`,{name:e.name}),description:Ne(t),duration:4e3})}})),f=m.filter(e=>e.status===`created`),p=m.filter(e=>e.status===`updated`),g=m.filter(e=>e.status===`failed`);console.log(`Batch ${t+1} results:`,{creates:f,updates:p,failures:g,total:c.length})}}let x=m.filter(e=>e.status===`created`).length,S=m.filter(e=>e.status===`updated`).length,C=m.filter(e=>e.status===`failed`).length,w=m.filter(e=>e.status===`skipped`).length;t&&(console.log(`Upload complete:`,{totalObjectIds:d.objectIds.length,uploadedFiles:x,updatedFiles:S,skippedFiles:w,failedFiles:C}),await t(d.objectIds));let T=``;return x>0&&(T+=`${x} file${x===1?``:`s`} uploaded`),S>0&&(T+=T?`, `:``,T+=`${S} file${S===1?``:`s`} updated`),w>0&&(T+=T?`, `:``,T+=`${w} file${w===1?``:`s`} skipped (already existed)`),C>0&&(T+=T?`, `:``,T+=`${C} file${C===1?``:`s`} failed`),T&&o({status:C>0?`warning`:`success`,title:T,duration:4e3}),a.search(),d}}const Hv=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function Uv({isGridView:e=!1,onUpload:n,collectionId:r,...i}){return n?t(Wv,{...i,onUpload:n,isGridView:e,collectionId:r}):t(Gv,{...i,isGridView:e})}function Wv({isGridView:e,onUpload:r,collectionId:i,skipTypeModal:a=!1,...o}){let[s,c]=Y(!1),[l,u]=Y([]),[d,f]=Y(!1),[p,m]=Y(null),[h,g]=Y(!1),_=jv(),v=He(),{t:y}=X(),{checkDocumentProcessing:b}=zv(),x=async(e,t)=>{console.log(`Files dropped on ObjectTable:`,e.length,t),c(!0);try{if(i){let t=await b(e,null,i);m(t);let n=t.filter(e=>e.action===`create`).length,r=t.filter(e=>e.action===`update`).length,a=t.filter(e=>e.action===`skip`).length;v({title:y(`store.filesReadyToProcess`),description:`${e.length} file(s): ${n} new, ${r} to update, ${a} to skip`,status:`info`,duration:4e3})}else m(null)}catch(e){console.error(`Error processing files:`,e),v({title:y(`store.errorProcessingFiles`),description:y(`store.errorCheckingDuplicates`),status:`error`,duration:4e3}),m(null)}finally{if(c(!1),u(e),f(!1),a){console.log(`Skipping type modal and calling onUpload directly`,{filesLength:e.length,processedFilesLength:p?.length});let t=r(e,null,i);t&&typeof t==`object`&&(t.processedFiles=p)}else console.log(`Setting typeSelectionOpen to true`,{filesLength:e.length}),g(!0)}},S=e=>{let t=[...l];u([]),m(null),g(!1),t.length>0&&e!==void 0&&(c(!0),console.log(`Starting upload with`,{typeId:e,filesCount:t.length,hasProcessingResults:!!p,collectionId:i}),r(t,e,i).finally(()=>{c(!1),_.search()}))},C=e=>{e.preventDefault(),e.stopPropagation(),f(!0)};return n(`div`,{className:`min-h-[400px] relative`,onDragOver:C,onDragEnter:C,onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),!e.currentTarget.contains(e.relatedTarget)&&f(!1)},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),f(!1),e.dataTransfer.items){let t=[];for(let n=0;n<e.dataTransfer.items.length;n++){let r=e.dataTransfer.items[n];if(r.kind===`file`){let e=r.getAsFile();e&&t.push(e)}}if(t.length>0){let e={count:t.length,message:`Preparing to upload ${t.length} file${t.length===1?``:`s`}...`};x(t,e)}}},children:[t(`div`,{className:We(`bg-white dark:bg-gray-800 opacity-40 absolute inset-0 z-50 flex justify-center items-center`,s?`block`:`hidden`),children:t(be,{size:`xl`})}),t(Gv,{...o,isGridView:e}),t(`div`,{className:We(`absolute inset-0 pointer-events-none`,d?`z-40`:`-z-10`),children:t(`div`,{className:`w-full h-full relative`,children:t(mi,{onDrop:x,message:`Drop files or folders here to upload`,className:We(`absolute inset-0 bg-white/90 dark:bg-gray-800/90 pointer-events-auto`,d?`flex`:`hidden`),buttonLabel:`Select Files or Folders`,allowFolders:!0})})}),t(Bv,{isOpen:h&&l.length>0,onClose:()=>{u([]),m(null),g(!1),S(void 0)},files:l,collectionId:i,selectedFolder:null,title:`Upload Files`,onUploadComplete:e=>{if(e){if(e.failedFiles&&e.failedFiles.length>0&&v({title:y(`store.uploadIssues`),description:`${e.failedFiles.length} file(s) failed to upload`,status:`warning`,duration:5e3}),e.success){let t=e.uploadedFiles.filter(e=>e.status===`created`).length,n=e.uploadedFiles.filter(e=>e.status===`updated`).length,r=e.skippedFiles.length;(t>0||n>0)&&v({title:y(`store.uploadComplete`),description:`${t>0?`${t} created`:``}${t>0&&n>0?`, `:``}${n>0?`${n} updated`:``}${r>0?`, ${r} skipped`:``}`,status:`success`,duration:5e3})}_.search()}u([]),m(null),g(!1),e?.success&&e.objectIds.length>0?S(null):S(void 0)}})]})}function Gv({objects:e,layout:n=Hv,isLoading:r,onRowClick:i,onSelectionChange:a,highlightRow:o,previewObject:s,selectedObject:c,isGridView:l}){let u=W_(),d=(t,n)=>{if(u){let r=n.nativeEvent instanceof MouseEvent&&n.nativeEvent.shiftKey;if(!n.target.checked)u.remove(t.id);else if(u.add(t),r){let n=e.findIndex(e=>e.id===t.id),r=Kv(e,n,u);if(r>-1&&r<n-1){let t=[];for(let i=r+1;i<n;i++)t.push(e[i]);u.addAll(t)}else{let t=qv(e,n,u);if(t>-1&&t>n+1){let r=[];for(let i=n+1;i<t;i++)r.push(e[i]);u.addAll(r)}}}a?.(u)}},f=t=>{u&&(t.target.checked?u.addAll(e):u.removeAll())},p=q(()=>{let e=n.length>0?n:Hv;return console.log(`Using layout with columns:`,e.map(e=>e.name).join(`, `)),e.map(e=>new wv(e,s))},[n,s]);return t(l?Ov:Dv,{objects:e,isLoading:r,columns:p,onRowClick:i,highlightRow:o,previewObject:s,selectedObject:c,selection:u,toggleAll:f,onSelectionChange:d})}function Kv(e,t,n){for(let r=t-1;r>=0;r--)if(n.isSelected(e[r].id))return r;return-1}function qv(e,t,n){let r=e.length;for(let i=t+1;i<r;i++)if(n.isSelected(e[i].id))return i;return-1}function Jv({children:e,limit:n,parent:r,typeId:i,facets:a,name:o,collectionId:s}){let{store:c}=Z(),l=q(()=>{let e;a?e=a:(e=[{name:`status`,field:`status`},{name:`location`,field:`location`}],i||e.unshift({name:`type`,field:`type`}));let t=new kv(c,n).withFacets(e);return t.collectionId=s,t.query.type=i,t.query.parent=r,t.query.name=o,s&&(t.query.all_revisions=!0),t},[s,a,n,o,r,c,i]);return t(Av.Provider,{value:l,children:e})}const Yv=`vertesia.content_store.lastDisplayedView`;function Xv({onUpdate:e}){let{t:n}=X(),[r,i]=Y(localStorage.getItem(Yv)===`grid`),a=()=>{r?c():s()},s=()=>{localStorage.setItem(Yv,`grid`),i(!0),e(!0)},c=()=>{localStorage.setItem(Yv,`table`),i(!1),e(!1)};return t(o,{variant:`outline`,onClick:a,alt:n(r?`misc.tableView`:`misc.thumbnailView`),children:t(r?qn:ln,{})})}Xv.LAST_DISPLAYED_VIEW=Yv;const Zv=[{name:`Name`,field:`properties.title`,type:`string`,fallback:`name`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Created At`,field:`created_at`,type:`date`}];function Qv({onChange:e,selectedIds:n}){return t(Jv,{children:t($v,{onRowClick:t=>{e(t||void 0)},selectedIds:n})})}function $v({onRowClick:e,selectedIds:r}){let{t:i}=X(),a=G(e=>!!r?.has(e.id),[r]),[s,c]=Y(!1),[l,u]=Y(localStorage.getItem(`vertesia.content_store.lastDisplayedView`)===`grid`),{search:d,isLoading:f,error:p,objects:m,hasMore:h}=Nv(),g=J(null);ze(g,()=>{s&&h&&!f&&(c(!1),d.loadMore(!0).finally(()=>{c(!0)}))},{threshold:.1,deps:[s,h,f]}),K(()=>{d.search().finally(()=>{c(!0)})},[d]);let _=Mv(),v=jv();return p?t(O,{title:i(`store.searchFailed`),children:p.message}):n(`div`,{className:`flex flex-col gap-2 h-full w-full`,children:[n(`div`,{className:`flex justify-between items-center flex-shrink-0`,children:[t(m_,{facets:_,search:v}),n(`div`,{className:`flex items-center gap-2`,children:[t(o,{variant:`outline`,onClick:()=>{c(!1),d.search().then(()=>c(!0))},"aria-label":`Refresh`,children:t(Pn,{size:16})}),t(Xv,{onUpdate:u})]})]}),n(`div`,{className:`@container relative flex-1 overflow-y-auto`,children:[t(Uv,{objects:m||[],isLoading:!m.length&&f,layout:Zv,onRowClick:e,highlightRow:r?.size?a:void 0,isGridView:l}),t(`div`,{ref:g,className:`h-4 w-full`})]})]})}function ey(e){let t=Math.max(0,e)/1e3,n=+(t>0&&t<10&&!Number.isInteger(t));return`${new Intl.NumberFormat(void 0,{maximumFractionDigits:n}).format(t)}K`}function ty({onSend:e,onStop:r,approvalModeSlot:i,mcpSlot:a,disabled:s=!1,isSending:c=!1,isStopping:l=!1,isStreaming:u=!1,isCompleted:d=!1,contextWindowUsage:f,onCompactContext:p,isCompactingContext:m=!1,activeTaskCount:h=0,activeWorkstreams:g=[],placeholder:_,onFilesSelected:v,uploadedFiles:y=[],onRemoveFile:x,onRemoveProcessingFile:S,acceptedFileTypes:C,maxFiles:w=5,processingFiles:T,artifactRunId:E,hasProcessingFiles:D=!1,renderDocumentSearch:O,selectedDocuments:k=[],onRemoveDocument:A,hideObjectLinking:j=!1,hideFileUpload:M=!1,disableDropZone:N=!1,className:P,inputClassName:F}){let{t:I}=X(),L=_??I(`agent.typeYourMessage`),R=J(null),ee=J(null),[ne,ie]=Y(``),[ae,oe]=Y(!1),[se,ce]=Y(!1),[le,ue]=Y(!1),de=!!(v&&!M),fe=de&&!N,pe=!j||de||!!O,me=y.length>=w,V=S??x,he=q(()=>g.filter(e=>e.status===`running`||e.status===`canceling`),[g]),ge=he.length||h,_e=f?I(`agent.contextUsageCompactLabel`,{percent:f.usedPercent}):void 0,ve=f?I(`agent.contextTokenUsage`,{used:ey(f.usedTokens),limit:ey(f.checkpointTokens)}):void 0,ye=q(()=>{let e=[];if(!M&&T)for(let t of T.values()){let n=t.preview_url,r=t.status===hr.UPLOADING?I(`agent.uploading`):t.status===hr.PROCESSING?I(`agent.processing`):t.status===hr.ERROR?I(`agent.error`):t.status===hr.READY?I(`agent.ready`):t.status;e.push({id:t.id,name:t.name,contentType:t.content_type,artifactPath:t.artifact_path,previewUrl:n,removable:!!V,statusLabel:r,statusTone:t.status===hr.ERROR?`destructive`:t.status===hr.READY?`success`:`attention`})}if(!M)for(let t of y)e.push({id:t.id,name:t.name,contentType:t.type,artifactPath:t.artifact_path,previewUrl:t.previewUrl,removable:!!x,statusLabel:I(`agent.ready`),statusTone:`success`});for(let t of k)e.push({id:t.id,name:t.name,href:`/store/objects/${t.id}`,removable:!!A,statusTone:`info`});return e},[V,M,A,x,T,k,I,y]);K(()=>{!s&&d&&R.current?.focus()},[s,d]);let xe=G(e=>{if(!de||!v)return;let t=Array.from(e),n=w-y.length,r=t.slice(0,n);r.length>0&&v(r)},[de,v,w,y.length]),Se=G(e=>{e.preventDefault(),e.stopPropagation(),fe&&ue(!0)},[fe]),Ce=G(e=>{e.preventDefault(),e.stopPropagation(),ue(!1)},[]),we=G(e=>{e.preventDefault(),e.stopPropagation(),ue(!1),fe&&e.dataTransfer?.files&&e.dataTransfer.files.length>0&&xe(e.dataTransfer.files)},[fe,xe]),Te=G(e=>{if(!de)return;let t=Kh(e.clipboardData?.items);t.length>0&&xe(t)},[de,xe]),Ee=G(e=>{de&&e.target.files&&e.target.files.length>0&&(xe(e.target.files),e.target.value=``)},[de,xe]),De=G(()=>{ee.current?.click()},[]),Oe=G(()=>ce(!1),[]),ke=G(e=>ce(!1),[]),Ae=()=>{let t=ne.trim();!t||s||c||D||(e(t),ie(``))},Ne=()=>{r&&!l&&r()},Fe=J(0),Ie=e=>{if(e.key===`Enter`){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)){e.preventDefault(),ne.trim().length>0&&Ae();return}e.shiftKey||(e.preventDefault(),Pe(e.currentTarget,ie));return}if(e.key===`Escape`&&u&&r){let e=Date.now();e-Fe.current<500?(Ne(),Fe.current=0):Fe.current=e}},Le=G(()=>{let e=R.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]);return K(()=>{Le()},[ne,Le]),n(`div`,{className:H(`px-3 py-3 flex-shrink-0 transition-all fixed lg:sticky bottom-0 start-0 end-0 lg:start-auto lg:end-auto w-full bg-background/95 backdrop-blur z-10`,le&&fe&&`bg-info/10 border-info`,P),onDragOver:fe?Se:void 0,onDragLeave:fe?Ce:void 0,onDrop:fe?we:void 0,children:[le&&fe&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-blue-100/80 dark:bg-blue-900/40 rounded-lg z-10 pointer-events-none`,children:n(`div`,{className:`text-blue-600 dark:text-blue-400 font-medium flex items-center gap-2`,children:[t(Zn,{className:`size-5`}),I(`agent.dropFilesToUpload`)]})}),de&&t(`input`,{ref:ee,type:`file`,multiple:!0,accept:C,onChange:Ee,className:`hidden`}),t(pg,{activeWorkstreams:g}),n(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-2 rounded-2xl border border-border/70 bg-mixer-muted/15 p-2.5 shadow-lg shadow-black/5`,children:[ye.length>0&&t(Au,{items:ye,artifactRunId:E,variant:`composer`,onRemove:e=>{T?.has(e)?V?.(e):y.some(t=>t.id===e)?x?.(e):A?.(e)},className:`gap-1.5`}),t(`div`,{className:`flex min-w-0 flex-1`,children:t(je,{ref:R,value:ne,onKeyDown:Ie,onChange:e=>ie(e.target.value),onPaste:Te,disabled:s,"aria-label":L,placeholder:L,rows:1,style:{maxHeight:`160px`},className:H(`min-h-[44px] resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 shadow-none focus-visible:ring-0`,F)})}),n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[pe&&n(b,{align:`left`,trigger:t(o,{variant:`ghost`,size:`icon`,className:`size-8 rounded-full text-muted hover:bg-muted`,"aria-label":I(`agent.addAttachment`),title:I(`agent.addAttachment`),children:t(jn,{className:`size-4`})}),children:[!j&&n(z,{onClick:()=>oe(!0),isDisabled:!d,children:[t(En,{className:`size-4`}),I(`agent.linkObject`)]}),de&&n(z,{onClick:De,isDisabled:me,children:[t(Zn,{className:`size-4`}),I(`agent.upload`)]}),O&&n(z,{onClick:()=>ce(!0),children:[t(Jt,{className:`size-4`}),t(`span`,{children:I(`agent.searchDocuments`)}),k.length>0&&t(`span`,{className:`ms-auto inline-flex items-center justify-center rounded-full bg-info/20 px-1.5 py-0.5 text-[10px] font-medium text-info`,children:k.length})]})]}),i,a,f&&t(Me,{asChild:!0,placement:`top`,size:`md`,className:`text-foreground shadow-lg`,description:n(`span`,{className:`block max-w-56 text-start text-sm leading-6`,children:[t(`span`,{className:`block`,children:I(`agent.contextRemainingUntilCompact`,{percent:f.remainingPercent})}),ve&&t(`span`,{className:`mt-1 block text-foreground/80`,children:ve})]}),children:t(o,{type:`button`,variant:`ghost`,size:`icon`,className:H(`size-8 rounded-lg text-info hover:bg-muted hover:text-info disabled:opacity-60`,`focus-visible:ring-2 focus-visible:ring-info/40`),"aria-label":_e,onClick:p,disabled:!p||m,children:m?t(be,{size:`sm`}):n(`svg`,{viewBox:`0 0 24 24`,className:H(`size-8 -rotate-90`,f.usedPercent>=90?`text-destructive`:f.usedPercent>=70?`text-attention`:`text-info`),"aria-hidden":`true`,children:[t(`circle`,{cx:`12`,cy:`12`,r:`9.75`,fill:`none`,strokeWidth:`4.5`,className:`stroke-current text-muted/50`}),t(`circle`,{cx:`12`,cy:`12`,r:`9.75`,fill:`none`,pathLength:100,strokeWidth:`4.5`,strokeLinecap:`round`,strokeDasharray:100,style:{strokeDashoffset:100-f.usedPercent},className:`stroke-current`})]})})}),he.length===0&&ge>0&&t(`output`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,"aria-live":`polite`,children:n(`span`,{className:`inline-flex h-8 items-center gap-1 rounded-full px-2 text-xs text-muted`,children:[t(it,{className:`size-3 text-attention`}),I(`agent.activeWorkstreams`,{count:ge})]})})]}),u&&r&&!ne.trim()?t(o,{onClick:Ne,disabled:l,variant:`ghost`,size:`icon`,className:H(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`,`[&_svg]:text-destructive disabled:[&_svg]:text-muted`),title:I(`agent.stopTooltip`),"aria-label":I(`agent.stopTooltip`),children:l?t(be,{size:`sm`}):t(Wn,{className:`size-3 fill-current stroke-current`})}):t(o,{onClick:Ae,disabled:s||c||!ne.trim()||D,variant:`ghost`,size:`icon`,className:H(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`),title:I(D?`agent.waitForFiles`:`agent.sendTooltip`),"aria-label":I(D?`agent.waitForFiles`:`agent.send`),children:c?t(be,{size:`sm`}):t(lt,{className:`size-4`})})]})]}),n(B,{isOpen:ae,onClose:()=>oe(!1),className:`min-w-[60vw]`,children:[t(re,{children:I(`agent.linkObject`)}),t(te,{className:`pb-6`,children:t(Qv,{onChange:e=>{let t=`[${e.properties?.title||e.name||`Object`}](store:${e.id})`,n=ne||``,r=R.current?.selectionStart||n.length,i=n.substring(0,r)+t+n.substring(r);ie(i),oe(!1),setTimeout(()=>{if(R.current){R.current.focus();let e=r+t.length;R.current.setSelectionRange(e,e)}},100)}})})]}),O?.({isOpen:se,onClose:Oe,onSelect:ke})]})}function ny({code:e}){let{onProposalSelect:n,onProposalSubmit:r}=Ei(),i=q(()=>Ti(e),[e]),a=q(()=>{if(i)return null;try{let t=e.trim(),i=JSON.parse(t);if(!i.options||!i.question&&!i.title)return null;let a={question:i.question||i.title||``,description:i.description,options:Array.isArray(i.options)?i.options.map(e=>({id:e.id||e.value||``,label:e.label||``,description:e.description})):void 0,allowFreeResponse:i.allowFreeResponse??i.multiple,variant:i.variant,onSelect:n,onSubmit:r};return!a.question||!a.options?.length?null:a}catch{return null}},[e,n,r,i]);return i?t(fi,{type:`proposal`,message:`Loading options...`}):a?t(di,{type:`proposal`,fallbackCode:e,children:t(Xc,{...a})}):t(fi,{type:`proposal`,error:`Invalid proposal specification`})}const ry=Ze(function({code:e}){let n=q(()=>{try{let t=JSON.parse(e);return t?.library===`vega-lite`&&t?.spec&&typeof t.spec==`object`?t:typeof t?.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}catch{return null}},[e]);return n?t(va,{spec:n}):null}),iy=Ze(function({code:e}){let n=q(()=>{try{return{library:`vega-lite`,spec:JSON.parse(e)}}catch{return null}},[e]);return n?t(va,{spec:n}):null}),ay={chart:ry,"vega-lite":iy,vegalite:iy,"fusion-fragment":ii,proposal:ny,askuser:ny};function oy({url:e,code:n}){let[r,i]=Y(null);return K(()=>{import(e).then(e=>{i(()=>e.default)}).catch(t=>{console.error(`Failed to load remote widget component from `,e,t)})},[e]),r?t(r,{code:n}):null}async function sy(e){let n=await e.apps.getInstalledApps(`tools`),r=new Set;for(let e of n){if(e.manifest.tool_collections&&e.manifest.tool_collections.length>0)for(let t of e.manifest.tool_collections||[]){let e=Ar(t).url;if(e.startsWith(`http://`)||e.startsWith(`https://`)){let t=e.indexOf(`/api/`);if(t>0){let n=e.substring(0,t);r.add(`${n}/api/widgets`)}}}e.manifest.endpoint&&e.manifest.capabilities?.includes(`tools`)&&r.add(new URL(`/api/widgets`,e.manifest.endpoint).toString())}let i=await Promise.all(Array.from(r).map(e=>fetch(e).then(e=>{if(!e.ok)throw Error(`Failed to fetch widgets: ${e.status} ${e.statusText}`);return e.json()}).then(e=>{let n=[],r=e.widgets;for(let[e,i]of Object.entries(r))n.push({name:e,component:e=>t(oy,{url:i.url,code:e.code})});return n}).catch(()=>(console.error(`Failed to fetch skill widgets from `,e),null)))),a={};for(let e of i.flat())e&&(a[e.name]=e.component);return a}function cy({children:e}){let{client:n}=Z(),[r,i]=Y(ay);return K(()=>{sy(n).then(e=>{i({...ay,...e})})},[n]),t(pi,{components:r,children:e})}const ly=new Map;function uy(e){if(typeof e==`number`)return e;if(!e)return Date.now();let t=new Date(e).getTime();return Number.isFinite(t)?t:Date.now()}function dy(e){return e===`running`||e===`canceling`}function fy(e){return!dy(e)}function py(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function my(e){for(let t=e.length-1;t>=0;t--){let n=e[t].details;if(!n)continue;let r=n.token_usage,i=py(r?.total),a=py(n.checkpoint_threshold)??py(n.checkpoint_at);if(typeof i!=`number`||typeof a!=`number`||a<=0)continue;let o=Math.max(0,Math.min(100,Math.round(i/a*100)));return{usedTokens:i,checkpointTokens:a,usedPercent:o,remainingPercent:Math.max(0,100-o)}}}function hy(e,t){return!fy(e.status)||!dy(t.status)?{...e,...t}:{...e,interaction:e.interaction??t.interaction,elapsed_ms:Math.max(e.elapsed_ms,t.elapsed_ms),deadline_ms:Math.max(e.deadline_ms,t.deadline_ms),remaining_ms:0,phase:e.phase??t.phase,child_workflow_id:e.child_workflow_id??t.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id??t.child_workflow_run_id}}function gy(e){let t=e.details,n=typeof t?.workstream_id==`string`&&t.workstream_id.trim()?t.workstream_id:vl(e);return n===`main`||n===`all`?null:{workstreamId:n,launchId:typeof t?.launch_id==`string`?t.launch_id:void 0,interaction:typeof t?.interaction==`string`?t.interaction:void 0,childWorkflowId:typeof t?.child_workflow_id==`string`?t.child_workflow_id:void 0,childWorkflowRunId:typeof t?.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0}}function _y(e){if(e.type!==Q.ERROR)return!1;let t=e.details;return t?.event_class!==`activity`||t.workstream_event?!1:!(t.tool||t.tool_status||t.tool_run_id||t.activity_group_id||t.tool_event)}function vy(e,t,n,r,i,a){if(r){let a=t.get(n);if(a?.startsWith(`message-derived:`)){let t=e.get(a);t&&(e.delete(a),e.set(r,{...t,launch_id:r,updated_at:Math.max(t.updated_at,i)}))}t.set(n,r)}let o=r??t.get(n)??`message-derived:${n}`,s=e.get(o);if(s)return s;let c={workstream_id:n,launch_id:o,elapsed_ms:0,deadline_ms:0,remaining_ms:0,status:`running`,started_at:i,updated_at:i,order:a};return e.set(o,c),t.has(n)||t.set(n,o),c}function yy(e){let t=new Map,n=new Map;return e.forEach((e,r)=>{let i=uy(e.timestamp),a=gy(e),o=cl(e),s=o?.workstreamId??a?.workstreamId;if(!s)return;let c=o?.launchId??a?.launchId,l=al(e);if(!o&&!c&&l&&!n.has(s))return;let u=vy(t,n,s,c,i,r);o?(u.interaction=o.interaction??u.interaction,u.child_workflow_id=o.childWorkflowId??u.child_workflow_id,u.child_workflow_run_id=o.childWorkflowRunId??u.child_workflow_run_id,u.status=`running`):(u.interaction=a?.interaction??u.interaction,u.child_workflow_id=a?.childWorkflowId??u.child_workflow_id,u.child_workflow_run_id=a?.childWorkflowRunId??u.child_workflow_run_id);let d=sl(e);d?u.status=d:l||(_y(e)?u.status=`failed`:(e.type===Q.COMPLETE||e.type===Q.IDLE)&&(u.status=`completed`)),!l&&(u.updated_at=Math.max(u.updated_at,i),dy(u.status)?u.elapsed_ms=Math.max(u.elapsed_ms,i-u.started_at):(u.elapsed_ms=Math.max(u.elapsed_ms,i-u.started_at),u.remaining_ms=0))}),Array.from(t.values()).sort((e,t)=>{let n=Number(!dy(e.status))-Number(!dy(t.status));return n===0?dy(e.status)?e.order-t.order:t.updated_at-e.updated_at||e.order-t.order:n}).map(({started_at:e,updated_at:t,order:n,...r})=>r)}function by(e){return{workstream_id:e.workstream_id,launch_id:e.launch_id,interaction:e.interaction,elapsed_ms:e.elapsed_ms,deadline_ms:e.deadline_ms,remaining_ms:Math.max(0,e.deadline_ms-e.elapsed_ms),status:e.status,phase:e.latest_progress?.phase,child_workflow_id:e.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id}}function xy(e){return{workstream_id:e.workstream_id,launch_id:e.launch_id,interaction:e.interaction,elapsed_ms:e.duration_ms??0,deadline_ms:0,remaining_ms:0,status:e.status,phase:e.last_progress?.phase,child_workflow_id:e.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id}}function Sy(e,t){let n=e.findIndex(e=>e.launch_id===t.launch_id);if(n>=0){e[n]=hy(e[n],t);return}let r=e.findIndex(e=>e.workstream_id===t.workstream_id&&e.launch_id.startsWith(`message-derived:`));if(r>=0&&!t.launch_id.startsWith(`message-derived:`)){e[r]=hy(e[r],t);return}e.push(t)}function Cy(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function wy(e,t=!0){let[n,r]=Y(()=>Math.max(0,Math.floor((Date.now()-uy(e))/1e3)));return K(()=>{if(!t)return;let n=()=>{r(Math.max(0,Math.floor((Date.now()-uy(e))/1e3)))};n();let i=window.setInterval(n,1e3);return()=>window.clearInterval(i)},[t,e]),n}function Ty(e=!0){let[t,n]=Y(0);return K(()=>{if(!e)return;let t=window.setInterval(()=>{n(()=>Math.floor(Math.random()*mu.length))},4e3);return()=>window.clearInterval(t)},[e]),t}function Ey({message:e,startedAt:r}){let{t:i}=X(),a=wy(r),o=Ty();return n(`div`,{className:`mx-auto flex min-h-full w-full max-w-3xl flex-col justify-end gap-6 px-1 py-8`,children:[t(`div`,{className:`flex w-full justify-end`,children:t(`div`,{className:H(`max-w-[min(44rem,82%)] rounded-[1.35rem] bg-mixer-muted/35 px-4 py-2.5`,`break-words text-sm font-normal leading-6 text-foreground/90 shadow-sm shadow-black/5`,`dark:bg-mixer-muted/15 dark:text-foreground/88 dark:shadow-none [overflow-wrap:anywhere]`),children:t(`div`,{className:`whitespace-pre-wrap`,children:e})})}),n(`div`,{className:`border-b border-border/70 pb-4 text-sm text-muted`,children:[n(`div`,{className:`flex items-center gap-3`,children:[t(lu,{size:`sm`,color:`blue`}),n(`div`,{className:`min-w-0`,children:[n(`div`,{children:[t(`span`,{className:`font-medium`,children:i(`agent.preparing`)}),n(`span`,{className:`ms-2 text-muted/75`,children:[`for `,Cy(a)]})]}),t(`div`,{className:`mt-1 truncate text-muted/80`,children:mu[o]})]})]}),t(`div`,{className:`mt-3 ps-6`,children:t(cu,{color:`blue`})})]})]})}function Dy(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;return i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))}),i.body.innerHTML=e.innerHTML,r.focus(),r.print(),setTimeout(()=>{n.parentNode?.removeChild(n)},1e3),!0}function Oy(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function ky(e){return Oy(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function Ay(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function jy(e){let{agentRunId:n,startWorkflow:r}=e;return n?t(cy,{children:t(Py,{...e,agentRunId:n})}):r?t(Ny,{...e}):t(My,{})}function My(){let{t:e}=X();return n(ee,{status:`info`,icon:t(dt,{className:`size-16 text-muted mb-4`}),children:[t(`div`,{className:`text-base font-medium text-muted`,children:e(`agent.noAgentRunning`)}),t(`div`,{className:`mt-3 text-sm text-muted`,children:e(`agent.selectInteraction`)})]})}function Ny({initialMessage:e,interactive:r=!0,startWorkflow:i,onClose:a,isModal:s=!1,fullWidth:c=!1,placeholder:l,startButtonText:u,title:d,getAttachedDocs:f,onAttachmentsSent:p,acceptedFileTypes:m,maxFiles:h=5,hideHeader:g=!1,hideFileUpload:_=!1,hideObjectLinking:v,headerVariant:y,inputContainerClassName:b,inputClassName:x,className:S,allowWorkflowControl:C,initialToolApprovalMode:w}){let{t:T}=X(),E=!_,D=l??T(`agent.typeYourMessage`),O=u??T(`agent.startAgent`),k=d??T(`agent.startNewConversation`),{client:A}=Z(),[j,M]=Y(``),[N,P]=Y(!1),[F,I]=Y(null),[L,R]=Y(null),[z,ee]=Y(null),[B,te]=Y(()=>kr(w,r)),ne=He(),re=J(null),ie=J(null),[ae,oe]=Y([]),[se,ce]=Y(!1),le=J(0),ue=G(e=>{E&&(e.preventDefault(),e.stopPropagation(),le.current++,e.dataTransfer?.types?.includes(`Files`)&&ce(!0))},[E]),de=G(e=>{E&&(e.preventDefault(),e.stopPropagation())},[E]),fe=G(e=>{E&&(e.preventDefault(),e.stopPropagation(),le.current--,le.current===0&&ce(!1))},[E]),pe=G(e=>{if(E&&(e.preventDefault(),e.stopPropagation(),le.current=0,ce(!1),e.dataTransfer?.files&&e.dataTransfer.files.length>0)){let t=Array.from(e.dataTransfer.files);oe(e=>[...e,...t].slice(0,h))}},[h,E]),me=G(e=>{if(!E)return;let t=Kh(e.clipboardData?.items);t.length>0&&oe(e=>[...e,...t].slice(0,h))},[E,h]),V=G(e=>{if(e.target.files&&e.target.files.length>0){let t=Array.from(e.target.files);oe(e=>[...e,...t].slice(0,h))}e.target.value=``},[h]),he=G(e=>{oe(t=>t.filter((t,n)=>n!==e))},[]);K(()=>{re.current&&re.current.focus()},[]);let ge=async()=>{if(!i)return;let e=j.trim();if(!(!e||N)){P(!0);try{sessionStorage.removeItem(`plan-panel-shown`),ne({title:E&&ae.length>0?T(`agent.startingAgentUploading`):T(`agent.startingAgent`),status:`info`,duration:3e3});let t=f?.()||[],n=e;if(t.length>0&&!/store:\S+/.test(e)&&(n=[e,``,`Attachments:`,...t.map(e=>`[${e.name}](/store/objects/${e.id})`)].join(`
|
|
439
|
+
`,i.head.appendChild(a),i.body.innerHTML=e.innerHTML,r.focus(),r.print(),setTimeout(()=>{n.parentNode?.removeChild(n)},1e3),!0}const q_={max_hw:import.meta.env?.VITE_RENDITION_HW||256,format:Pr.jpeg,generate_if_missing:!0},J_=`vertesia.content_store.renditionId`;async function Y_(e,t,n,r,i){if(!t?.content?.type||!(H_(t.content.type)||W_(t.content.type)||U_(t.content.type))){i(`No preview available`);return}i(`Preparing preview...`);let a=Date.now()/1e3,o=localStorage.getItem(`${J_}_${t.id}_${q_.max_hw}`),s=localStorage.getItem(`${J_}_${t.id}_${q_.max_hw}_time`);if(o?.length&&s&&Math.abs(a-parseInt(s,10))<=900)return n(o),r(`${t.name} Rendition`),i(`ready`),o;i(`Preparing preview...`),e.objects.getRendition(t.id,q_).then(a=>{if(a.status===`generating`)i(`Preparing preview...`),n(``),r(``),setTimeout(()=>Y_(e,t,n,r,i),6e4);else if(a.status===`failed`){i(`No preview available`),n(``),r(``);return}else{if(!a?.renditions?.length){i(`No preview available`),n(``),r(``);return}let e=a.renditions[0];localStorage.setItem(`${J_}_${t.id}_${q_.max_hw}`,e),localStorage.setItem(`${J_}_${t.id}_${q_.max_hw}_time`,(Date.now()/1e3).toString()),n(e),r(`${t.name} Rendition`),i(`ready`),console.log(`Rendition for document ${t.id} retrieved successfully: ${e}`)}}).catch(e=>{i(`No preview available`),console.warn(`Failed to retrieve rendition:`,e),n(``),r(``)})}function X_(e,t=7){return e?`~${e.slice(-t)}`:``}function Z_(e,t){return e.length>t?`${e.substring(0,t)}...`:e}function Q_(e){switch(e){case Wr.RUNNING:return`text-info`;case Wr.COMPLETED:return`text-success`;case Wr.FAILED:return`text-destructive`;case Wr.TERMINATED:case Wr.CANCELED:return`text-attention`;default:return`text-muted`}}function $_(e){switch(e){case Wr.RUNNING:return`Running`;case Wr.COMPLETED:return`Completed`;case Wr.FAILED:return`Failed`;case Wr.CONTINUED_AS_NEW:return`Continued As New`;case Wr.TERMINATED:return`Terminated`;case Wr.TIMED_OUT:return`Timed Out`;case Wr.CANCELED:return`Canceled`;default:return`Unknown`}}ni.extend(Yi),ni.extend(Ji);function ev(e){return typeof e==`object`&&!!e}function tv(e,t){if(!ev(e))return;let n=e[t];return typeof n==`string`?n:void 0}function nv(e){return typeof e==`string`?e:tv(e,`id`)||``}function rv(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:String(e)}const iv={string(e,r){let i=[];if(e){let t=e.get(`slice`);t&&i.push(e=>e.slice(parseInt(t,10)));let n=e.get(`max_length`);n&&i.push(e=>e.slice(0,parseInt(n,10))),e.has(`upper`)&&i.push(e=>e.toUpperCase()),e.has(`lower`)&&i.push(e=>e.toLowerCase()),e.has(`capitalize`)&&i.push(e=>e[0].toUpperCase()+e.substring(1)),e.has(`ellipsis`)&&i.push(e=>`${e}...`)}return(e,r,a)=>{let o;if(e){if(o=String(e),i.length>0)for(let e of i)o=e(o)}else o=``;return t(`td`,{className:`group/field`,children:a?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:o}),a]}):o},r)}},fileSize(e,n){return(e,n)=>{let r=``;if(e){let t=Number(e);if(Number.isNaN(t))r=String(e);else{let e=[`Bytes`,`KB`,`MB`,`GB`,`TB`];if(t===0)r=`0 Bytes`;else{let n=Math.floor(Math.log(t)/Math.log(1024));r=`${(t/1024**n).toFixed(2)} ${e[n]}`}}}return t(`td`,{className:`group/field`,children:r},n)}},number(e,n){let r,i;e&&(r=e.get(`currency`)||void 0,i=e.get(`decimals`)||void 0);let a=i?parseInt(i,10):2;return(e,n)=>{let i=Number(e);return t(`td`,{className:`group/field`,children:new Intl.NumberFormat(`en-US`,{style:r?`currency`:`decimal`,currency:r,maximumFractionDigits:a}).format(Number.isFinite(i)?i:0)},n)}},objectId(e,r){let i=[],a=!1;if(e){let t=e.get(`slice`);t&&(a=!0,i.push(e=>e.slice(parseInt(t,10))))}return(e,s,c)=>{let l=nv(e),u=i.reduce((e,t)=>t(e),l);return n(`td`,{className:`flex justify-start items-center gap-2 group/field`,children:[t(o,{variant:`ghost`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),r?.(l)},children:t($t,{className:`size-4`})}),a?`~`:``,u,c]},s)}},objectName(e,r){let i=`title`;return e&&(i=e.get(`title`)||`title`),(e,r,a)=>{let o=(ev(e)&&ev(e.properties)?e.properties:void 0)?.[i],s=rv(o),c=tv(e,`name`),l=tv(e,`id`),u=s||c||(l?X_(l):``);return t(`td`,{className:`group/field`,children:a?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:u}),a]}):u},r)}},objectLink(e,r){let i=[];return i.push(e=>e.slice(-7)),(e,a)=>{let s=nv(e);return n(`td`,{className:`flex justify-between items-center gap-2 max-w-48 group/field`,children:[`~`,i.reduce((e,t)=>t(e),s),t(o,{variant:`ghost`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),r?.(s)},children:t($t,{className:`size-4`})})]},a)}},typeLink(e,r){return(e,r,i)=>{let a=tv(e,`name`)||`n/a`;return t(`td`,{className:`group/field`,children:i?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:a}),i]}):a},r)}},revision(e,r){return(e,r)=>{let i=ev(e)&&ev(e.revision)?e.revision:void 0;if(!i)return t(`td`,{},r);let a=tv(i,`root`),o=tv(i,`label`);return t(`td`,{className:`group/field`,children:n(`div`,{className:`flex flex-col gap-0.5`,children:[a&&n(`div`,{className:`flex items-center gap-1`,children:[n(`span`,{className:`text-xs text-muted font-mono`,children:[`root: ~`,a.slice(-7)]}),t(`a`,{href:`/store/objects/${a}`,onClick:e=>e.stopPropagation(),children:t(Zt,{className:`size-3 text-muted`})})]}),o&&n(`span`,{className:`text-xs text-muted`,children:[`label: `,o]})]})},r)}},date(e,r){let i=`fromNow`,a;if(e){let t=e.get(`localized`);if(t)i=`format`,a=t;else{let t=e.get(`relative`);t&&(i=t)}}return(e,r,o)=>{let s=typeof e==`string`||typeof e==`number`||e instanceof Date?e:void 0;if(s===void 0)return t(`td`,{children:o},r);let c=ni(s),l=i===`format`?c.format(a):i===`toNow`?c.toNow():c.fromNow();return t(`td`,{className:`group/field`,children:n(`div`,{className:`flex items-center gap-2`,children:[t(ze,{description:c.format(`LLL`),children:l}),o]})},r)}}},av=iv.string();function ov(e){return typeof e==`object`&&!!e}function sv(e,t){let n=e;if(!n)return;if(!t.length)return n;let r=t.length-1;for(let e=0;e<r;e++)if(!ov(n)||(n=n[t[e]],!n))return;if(ov(n))return n[t[r]]}function cv(e){return!e||e===`.`?[]:e.split(`.`)}var lv=class{layout;renderer=av;path;fallbackPath;previewObject;constructor(e,t){if(this.layout=e,this.path=cv(e.field||``),this.fallbackPath=e.fallback?cv(e.fallback):void 0,this.previewObject=t,e.render)this.renderer=(e,t)=>null;else{let t=e.type||`string`,n=t.indexOf(`?`);if(n>0){let e=t.substring(0,n),r=new URLSearchParams(t.substring(n+1));this.renderer=iv[e](r)}else this.renderer=iv[t]()}}get name(){return this.layout.name}resolveValue(e){let t=sv(e,this.path);return t===void 0&&this.fallbackPath&&(t=sv(e,this.fallbackPath)),t===void 0&&(t=this.layout.default),t}render(e,n){if(this.layout.render)return t(`td`,{className:`whitespace-nowrap px-3 py-4 text-sm group`,children:this.layout.render(e)},n);let r=this.layout.type||`string`,i=r.indexOf(`?`)>0?r.substring(0,r.indexOf(`?`)):r,a=this.buildActions(e,i);if((i===`objectId`||i===`objectLink`)&&this.previewObject){let t=r.indexOf(`?`),o=t>0?new URLSearchParams(r.substring(t+1)):void 0;return iv[i](o,t=>{this.previewObject?.(e.id)})(e,n,a)}return this.renderer(this.resolveValue(e),n,a)}buildActions(e,n){let r=this.layout.field;if(n===`objectId`||n===`objectLink`||r===`id`)return t(F_,{field:`id`,value:e.id,label:e.id,copyContent:e.id});if(n===`objectName`||r===`name`)return t(F_,{field:`name`,value:e.name,label:e.name??e.id});if(n===`typeLink`||r===`type.name`||r===`type`){let n=e.type?.id;return t(F_,{field:`type`,value:n,label:e.type?.name??n??`type`})}if(r===`status`)return t(F_,{field:`status`,value:e.status,label:e.status})}};function uv({isLoading:e=!1,counts:r=6}){return e?t(`div`,{className:`flex flex-wrap gap-2 justify-between`,children:Array(r).fill(0).map((e,r)=>t(`div`,{className:`w-[15vw] animate-pulse`,children:n(s,{className:`relative flex flex-col border h-fit`,children:[t(`div`,{className:`h-48 bg-muted rounded-t-xl flex items-center justify-center text-muted`,children:`\xA0`}),t(xe,{className:`bg-muted h-[2px]`}),n(c,{className:`p-2 flex flex-col`,children:[n(`div`,{className:`flex flex-col overflow-hidden`,children:[t(`div`,{className:`h-5 bg-muted rounded w-3/4 mb-2`}),t(`div`,{className:`h-4 bg-muted rounded w-1/2`})]}),t(`div`,{className:`text-xs text-muted w-full flex justify-end mt-2`,children:t(`div`,{className:`h-3 bg-muted rounded w-1/4`})})]})]})},`skeleton-${r}`))}):null}function dv({selection:e,document:r,onSelectionChange:i,onRowClick:a,highlightRow:l,previewObject:u,selectedObject:d}){let{client:f}=Z(),[p,m]=Y(void 0),[h,g]=Y(void 0),[_,v]=Y(void 0),y=typeof r.properties?.title==`string`?r.properties.title:r.name,b=e=>{e.stopPropagation(),i(r,e)};K(()=>{r?.content&&Y_(f,r,m,g,v)},[f,r]);let x=l?.(r);return n(s,{className:`relative flex flex-col border h-fit w-full ${d?.id===r.id?`border-attention border-4`:``} ${x?`border-blue-400 dark:border-blue-500 bg-blue-50/50 dark:bg-blue-900/20`:``}`,onClick:()=>a?.(r),children:[x&&t(`div`,{className:`absolute top-2 end-8 z-10`,children:t(Dt,{className:`size-4 text-blue-600 dark:text-blue-400`})}),e&&t(`div`,{className:`absolute top-2 start-2 z-10 flex flex-col items-center gap-1`,children:t(`input`,{checked:e.isSelected(r.id),type:`checkbox`,onChange:b,onClick:e=>e.stopPropagation()})}),t(`div`,{className:`absolute top-1 end-1 z-10 flex flex-col items-center`,children:t(o,{variant:`ghost`,size:`sm`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),u?.(r.id)},children:t($t,{className:`size-4 ${_===`ready`?`text-muted`:`text-white`}`})})}),p&&_===`ready`?t(`img`,{src:p,alt:h,className:`w-auto h-48 object-cover rounded-t-xl`}):t(`div`,{className:`h-48 bg-gray-700 rounded-t-xl flex items-center justify-center text-muted`,children:_}),t(xe,{className:`bg-gray-200 h-[2px]`}),n(c,{className:`p-2 flex flex-col`,children:[n(`div`,{className:`flex flex-col overflow-hidden`,children:[t(ze,{placement:`top`,description:y,children:t(`h3`,{className:`text-start font-medium leading-none truncate`,children:y})}),r?.type?.name?t(ze,{placement:`bottom`,size:`xs`,description:r?.type?.name,children:t(`p`,{className:`text-start text-xs text-muted truncate`,children:r?.type?.name})}):t(`p`,{className:`text-xs text-muted`,children:` `})]}),r.score&&n(`div`,{className:`text-xs text-muted w-full flex justify-end`,children:[`Score: `,r.score.toFixed(4)??`-`]})]})]})}function fv({objects:e,selection:r,isLoading:i,columns:a,onRowClick:o,highlightRow:s,selectedObject:c,toggleAll:l,onSelectionChange:u}){let{t:d}=X();return n(Me,{className:`w-full`,children:[t(Ae,{children:n(`tr`,{children:[r&&t(`th`,{children:t(`input`,{type:`checkbox`,onChange:l})}),a.map(e=>t(`th`,{children:e.name},e.name))]})}),n(ke,{isLoading:i,columns:a.length+1,children:[e?.map(e=>{let i=s?.(e);return n(`tr`,{className:`group cursor-pointer hover:bg-muted ${c?.id===e.id?`bg-muted`:``} ${i?`bg-blue-50 dark:bg-blue-900/20`:``}`,onClick:()=>{o?.(e)},children:[r&&t(`td`,{onClick:e=>e.stopPropagation(),children:t(`input`,{checked:r.isSelected(e.id),type:`checkbox`,className:`${r.isSelected(e.id)?``:`hidden group-hover:block`}`,onChange:t=>u(e,t)})}),a.map((t,n)=>t.render(e,n)),t(`td`,{className:`w-8 text-center`,children:i&&t(Dt,{className:`size-4 text-blue-600 dark:text-blue-400 inline-block`})})]},e.id)}),e.length===0&&t(`tr`,{children:t(`td`,{colSpan:a.length+ +!!r,className:`text-center`,children:d(`store.noObjectsDragAndDrop`)})})]})]})}function pv({objects:r,selection:i,isLoading:a,onSelectionChange:o,onRowClick:s,highlightRow:c,previewObject:l,selectedObject:u}){return n(e,{children:[t(uv,{isLoading:a}),t(`div`,{className:`w-full gap-2 grid xs:grid-cols-1 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-6 @xs:grid-cols-1 @sm:grid-cols-2 @md:grid-cols-3 @lg:grid-cols-4`,children:r.map(e=>t(dv,{document:e,selection:i,onSelectionChange:o,onRowClick:s,highlightRow:c,previewObject:l,selectedObject:u},e.id))})]})}var mv=class{client;limit;collectionId;facets=new Se({});result=new Se({objects:[],isLoading:!1});initialized=!1;facetSpecs=[];query={};constructor(e,t=100){this.client=e,this.limit=t}withFacets(e){return this.facetSpecs=e,this}get objects(){return this.result.value.objects}get error(){return this.result.value.error}get isRunning(){return this.result.value.isLoading}get hasMore(){return this.result.value.hasMore||!1}getFilterValue(e){return this.query[e]}setFilterValue(e,t){this.query[e]=t,this.search()}setDefaultKeys(e){}clearFilters(e=!0){let{parent:t,full_text:n,vector:r,weights:i,score_aggregation:a,dynamic_scaling:o,limit:s,all_revisions:c}=this.query;this.query={parent:t,...n!==void 0&&{full_text:n},...r!==void 0&&{vector:r},...i!==void 0&&{weights:i},...a!==void 0&&{score_aggregation:a},...o!==void 0&&{dynamic_scaling:o},...s!==void 0&&{limit:s},...c!==void 0&&{all_revisions:c}},e&&this.search()}getFacetBuckets(e){let t=this.facets.value[e];return Array.isArray(t)?t:[]}resetFacets(){this.query={}}reset(e=!1){this.initialized=!1,this.result.value={objects:[],isLoading:e,hasMore:!0}}_updateRunningState(e){let t=this.result.value;this.result.value={objects:t.objects,isLoading:e,error:t.error,hasMore:t.hasMore}}_searchRequest(e,t,n,r=!0){let i={limit:t,offset:n,query:e,facets:r?this.facetSpecs:void 0};return this.collectionId?this.client.collections.searchMembers(this.collectionId,i):this.client.objects.search(i)}_facetsRequest(){let e={facets:this.facetSpecs,query:this.query};return this.collectionId?this.client.collections.computeFacets(this.collectionId,e):this.client.objects.computeFacets(e)}computeFacets(e){this._facetsRequest().then(e=>{this.facets.value=e})}async _search(e=!1,t=!1){if(this.isRunning&&e)return!1;let n=this.result.value;e||(this.initialized=!0),this.result.value={isLoading:!0,objects:e?this.objects:[],hasMore:!e||this.result.value.hasMore};let r=this.limit,i=e?this.objects.length:0;try{let n=await this._searchRequest(this.query,r,i,!t),a=n.results||[],o=n.facets||{};return this.result.value={isLoading:!1,objects:e?this.objects.concat(a):a,hasMore:a.length===r},!t&&o&&Object.keys(o).length>0&&(this.facets.value=o),!0}catch(e){if(typeof e==`object`&&e&&`status`in e&&e.status===404)return this.result.value={isLoading:!1,objects:[],hasMore:!1},!1;let t=e instanceof Error?e:Error(String(e));return this.result.value={error:t,isLoading:!1,objects:n.objects,hasMore:!1},!1}}search(e=!1){return this.isRunning?Promise.resolve(!1):this._search(!1,e)}loadMore(e=!1){return this.isRunning||!this.hasMore||this.query.vector?Promise.resolve(!1):(this.objects.length>0&&(e=!0),this._search(!0,e))}};const hv=nt(void 0);function gv(){return at(hv)}function _v(){return Xe(gv().facets)}function vv(){let e=gv();return{...Xe(e.result),search:e}}function yv(){return Xe(gv().facets).total}const bv=ut.getFixedT(null,lt);var xv;(function(e){e.CREATE=`create`,e.SKIP=`skip`,e.UPDATE=`update`})(xv||={});async function Sv(e){try{let t=await e.arrayBuffer(),n=new Xi;return n.appendByteArray(new Uint8Array(t)),n.end()?.toString()}catch(e){console.error(`Error calculating file hash:`,e);return}}async function Cv(e,t){let n=[];for(let r=0;r<e.length;r+=5){let i=e.slice(r,r+5),a=await Promise.all(i.map(async e=>{let n=t||`/`;if(e.webkitRelativePath){let r=e.webkitRelativePath.split(`/`);if(r.length>1){let e=r.slice(0,-1).join(`/`);n=t?`${t}/${e}`:e}}return{file:e,hash:await Sv(e),name:e.name,size:e.size,location:n}}));n.push(...a)}return n}function wv(){let{client:e}=Z(),t=Ye();return{checkDocumentProcessing:G(async(n,r,i)=>{try{console.log(`Preparing metadata for ${n.length} files...`);let t=await Cv(n,r);return await(async()=>{let n=t.map(e=>e.hash).filter(Boolean);if(n.length===0)return;let r={"content.etag":{$in:n}},a;if(i){let t={query:{match:r},select:`id content.etag`};a=(await e.store.collections.searchMembers(i,t)).results}else{let t={query:r,select:`id content.etag`};a=await e.store.objects.find(t)}for(let e of a){let n=t.find(t=>t.hash===e.content?.etag);n&&(n.existingId=e.id,n.action=xv.SKIP)}})(),await(async()=>{let n=t.filter(e=>e.action!==xv.SKIP),r=n.map(e=>e.location),a=Array.from(new Set(r)),o=[];for(let t of a){let r={"content.name":{$in:n.filter(e=>e.location===t).map(e=>e.name)},location:t||`/`};if(i){let t=e.store.collections.searchMembers(i,{query:{match:r},select:`id content.name location`}).then(e=>e.results);o.push(t)}else{let t=e.store.objects.find({query:r,select:`id content.name location`});o.push(t)}}let s=(await Promise.all(o)).flat();console.log(`Found ${s.length} document to update`,s);for(let e of s){let n=t.find(t=>t.name===e.content?.name&&(t.location?t.location===e.location:e.location===`/`));n&&(n.existingId=e.id,n.action=xv.UPDATE)}console.log(`Reconciled ${t.filter(e=>e.action===xv.UPDATE).length}`)})(),t.forEach(e=>{e.action||=xv.CREATE}),console.log(`Document processing check results:`,{totalFiles:n.length,toCreate:t.filter(e=>e.action===xv.CREATE).length,toUpdate:t.filter(e=>e.action===xv.UPDATE).length,toSkip:t.filter(e=>e.action===xv.SKIP).length}),t}catch(e){throw t({title:bv(`store.errorInUploadProcessingCheck`),status:`error`,description:H(e)}),console.log(`Error in file upload processing check`,e),Error(`Error in file upload processing check: ${H(e)}`,{cause:e})}},[e,t])}}function Tv({isOpen:r,onClose:i,files:a,collectionId:s,selectedFolder:c,title:l,children:u,onUploadComplete:d,hideFileSelection:f=!1,showTypeSelectionOnly:p=!1,allowFolders:m=!0}){let{client:h}=Z(),{registry:g}=Gg(),_=Ye(),{t:v}=X(),y=l??v(`upload.uploadFiles`),[b,x]=Y([]),[S,C]=Y([]),[w,T]=Y(!1),[E,D]=Y(null),[O,k]=Y([]),[A,j]=Y(!1),[M,N]=Y(!1),[P,F]=Y(0),[I,L]=Y(Date.now()),[R,ee]=Y(void 0),[te,z]=Y(null),[ne,B]=Y(y),[ce,le]=Y(``);K(()=>{s&&h.store.collections.retrieve(s).then(ee)},[h.store.collections.retrieve,s]),K(()=>{A?(B(v(`upload.uploadingFiles`)),le(`${Math.round(P)}% complete`)):M?(B(v(`upload.uploadComplete`)),le(``)):w?(B(v(`upload.fileAnalysisResults`)),le(`${b.length} file${b.length===1?``:`s`}`)):b.length>0?(B(y),le(v(`upload.checkingForDuplicates`))):(B(y),le(``))},[A,M,w,y,P,b.length,v]);let ue=()=>!R&&!c?null:n(re,{className:`mb-4`,status:`default`,icon:t(un,{className:`size-5`}),children:[t(`div`,{className:`flex items-center`,children:t(`span`,{className:`font-medium`,children:v(`upload.uploadLocation`)})}),n(`div`,{className:`text-sm mt-1`,children:[R&&n(`div`,{className:`flex items-center`,children:[t(`span`,{className:`me-1`,children:v(`upload.collectionLabel`)}),t(`span`,{className:`font-medium`,children:R.name})]}),c&&n(`div`,{className:`flex items-center mt-1`,children:[t(`span`,{className:`me-1`,children:v(`upload.folderLabel`)}),t(`span`,{className:`font-medium`,children:c})]})]})]}),[de,fe]=Y({toCreate:0,toUpdate:0,toSkip:0}),{checkDocumentProcessing:pe}=wv(),me=q(()=>g?.types||[],[g?.types]),he=G(async e=>{if(e.length)try{console.log(`Processing ${e.length} files to determine required actions...`);let t=await pe(e,c,s);C(t);let n=t.filter(e=>e.action===xv.CREATE).length,r=t.filter(e=>e.action===xv.UPDATE).length,i=t.filter(e=>e.action===xv.SKIP).length;fe({toCreate:n,toUpdate:r,toSkip:i}),_({title:v(`upload.filesAnalyzed`),description:`${e.length} file(s): ${n} new, ${r} to update, ${i} to skip`,status:`info`,duration:4e3}),T(!0)}catch(e){console.error(`Error processing files:`,e),_({title:v(`agent.error`),description:v(`upload.errorAnalyzingFiles`),status:`error`,duration:5e3})}},[pe,s,c,v,_]);K(()=>{r&&(C([]),T(!1),D(null),k([]),j(!1),N(!1),F(0),fe({toCreate:0,toUpdate:0,toSkip:0}),z(null),B(y),le(``),a&&a.length>0?(x(a),he(a)):x([]),L(Date.now()))},[r,a,he,y]);let ge=()=>{x([]),C([]),T(!1),D(null),k([]),j(!1),N(!1),F(0),fe({toCreate:0,toUpdate:0,toSkip:0}),z(null),B(y),le(``),L(Date.now()),i()},_e=e=>{e&&e.length>0&&(x(e),he(e))},ve=async()=>{if(!S.length)return;let e=E?.id||null,t=S.map(e=>({file:e.file,status:`pending`,progress:0,action:e.action===xv.CREATE?`create`:e.action===xv.UPDATE?`update`:`skip`}));k(t),j(!0),N(!1);let n=S.filter(e=>e.action===xv.SKIP),r=S.filter(e=>e.action===xv.UPDATE),i=S.filter(e=>e.action===xv.CREATE),a={success:!0,objectIds:[],uploadedFiles:[],skippedFiles:[],failedFiles:[]};for(let t of n)t.existingId&&(a.objectIds.push(t.existingId),a.skippedFiles.push({id:t.existingId,name:t.name,type:e,status:`skipped`,location:t.location}),k(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:t.existingId}:e)));let o=async(t,n)=>{let r=[];for(let e=0;e<t.length;e+=50)r.push(t.slice(e,e+50));for(let i=0;i<r.length;i++){let o=r[i];if(console.log(`Processing ${n} batch ${i+1}/${r.length} (${o.length} files)`),t.length>50){let e=i*50;_({title:v(`upload.processingFilesAction`,{action:n}),description:v(`upload.processedCount`,{processed:e,total:t.length}),status:`info`,duration:2e3})}let c=0;await Promise.all(o.map(async t=>{try{if(k(e=>e.map(e=>e.file===t.file?{...e,status:`uploading`,progress:20}:e)),n===`update`&&t.existingId)await h.store.objects.update(t.existingId,{type:e||void 0,content:t.file,location:t.location,name:t.name},{createRevision:!0,revisionLabel:`upload on ${new Date().toISOString()}`}),k(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:t.existingId}:e)),a.objectIds.push(t.existingId),a.uploadedFiles.push({id:t.existingId,name:t.name,type:e,status:`updated`,location:t.location});else{let n=await h.store.objects.create({type:e||void 0,content:t.file,location:t.location||t.file.webkitRelativePath||t.name},{collection_id:s});k(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:n.id}:e)),a.objectIds.push(n.id),a.uploadedFiles.push({id:n.id,name:t.name,type:e,status:`created`,location:t.location})}}catch(n){console.error(`Failed to process file ${t.name}:`,n),k(e=>e.map(e=>e.file===t.file?{...e,status:`error`,progress:100,message:H(n,`Unknown error`)}:e)),a.failedFiles.push({name:t.name,error:H(n,`Unknown error`),status:`failed`,location:t.location,type:e}),a.success=!1}c++,(c%5==0||c===o.length)&&k(e=>{let t=e.filter(e=>e.status===`success`||e.status===`error`).length,n=e.length,r=n>0?Math.round(t/n*100):0;return F(r),e})}))}};r.length>0&&await o(r,`update`),i.length>0&&await o(i,`create`),k(e=>{let t=e.filter(e=>e.status===`pending`).map(e=>({...e,status:`error`,progress:100,message:v(`upload.uploadProcessInterrupted`)}));return t.length>0?(t.forEach(e=>{a.failedFiles.push({name:e.file.name,error:v(`upload.uploadProcessInterrupted`),status:`failed`,type:E?.id||null})}),a.success=!1,e.map(e=>e.status===`pending`?{...e,status:`error`,progress:100,message:v(`upload.uploadProcessInterrupted`)}:e)):e}),j(!1),N(!0);let c=a.uploadedFiles.filter(e=>e.status===`created`).length,l=a.uploadedFiles.filter(e=>e.status===`updated`).length,u=a.skippedFiles.length,d=a.failedFiles.length,f=``;c>0&&(f+=`${c} file${c===1?``:`s`} uploaded`),l>0&&(f+=f?`, `:``,f+=`${l} file${l===1?``:`s`} updated`),u>0&&(f+=f?`, `:``,f+=`${u} file${u===1?``:`s`} skipped`),d>0&&(f+=f?`, `:``,f+=`${d} file${d===1?``:`s`} failed`),_({title:v(`upload.uploadComplete`),description:f,status:d>0?`warning`:`success`,duration:5e3}),z(a)},be=()=>n(`div`,{className:`mb-4`,children:[n(`div`,{className:`block text-sm font-medium mb-2`,children:[v(`store.contentType`),` `,t(`span`,{className:`text-muted font-normal`,children:v(`store.optional`)}),t(ze,{description:v(`upload.contentTypeTooltip`),placement:`top`,size:`xs`,children:t(yn,{className:`size-3 ms-2`})})]}),t(ye,{options:me,value:E,optionLabel:e=>e?e.name:v(`store.selectContentTypeLabel`),placeholder:v(`store.selectContentTypeAuto`),onChange:e=>D(e===void 0?null:e),filterBy:`name`,isClearable:!0}),!E&&t(`div`,{className:`p-2 rounded-md`,children:n(`div`,{className:`flex items-center text-attention`,children:[t(Et,{className:`size-4 me-1`}),v(`store.automaticTypeDetection`),t(ze,{description:v(`store.automaticTypeDetectionDescription`),placement:`top`,size:`xs`,children:t(yn,{className:`size-3 ms-2`})})]})})]});return n(ie,{isOpen:r,onClose:ge,className:`mx-auto`,disableCloseOnClickOutside:!0,children:[t(se,{description:ce,children:ne}),p?n(ae,{children:[u,ue(),be()]}):b.length===0&&!f?n(ae,{className:`flex flex-col items-center justify-center p-8`,children:[ue(),t(Mi,{onDrop:_e,message:v(`upload.dragAndDrop`),buttonLabel:v(`upload.selectFiles`),className:`w-full h-64`,allowFolders:m}),u]}):!A&&!M?t(ae,{children:w?n(e,{children:[ue(),t(`div`,{className:`mb-4`,children:t(`div`,{className:`p-4 rounded-md mb-4`,children:n(`div`,{className:`grid grid-cols-3 gap-4`,children:[n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(pr,{className:`size-5 text-primary`}),t(`span`,{className:`font-medium`,children:v(`upload.new`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:de.toCreate})]}),n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(Et,{className:`size-5 text-success`}),t(`span`,{className:`font-medium`,children:v(`upload.update`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:de.toUpdate})]}),n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(mt,{className:`size-5 text-mixer-attention/40`}),t(`span`,{className:`font-medium`,children:v(`upload.skip`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:de.toSkip})]})]})})}),be(),t(re,{className:`mb-4`,status:`info`,children:de.toCreate+de.toUpdate>0?n(`div`,{className:`space-y-1`,children:[t(`p`,{children:v(`upload.filesReadyToProcess`,{count:de.toCreate+de.toUpdate})}),t(`p`,{children:de.toSkip>0&&v(`upload.filesToSkip`,{count:de.toSkip})})]}):de.toSkip>0?t(`span`,{children:v(`upload.allFilesExist`,{count:de.toSkip})}):t(`span`,{children:v(`upload.noFilesToProcess`)})})]}):n(`div`,{className:`flex flex-col items-center justify-center py-4`,children:[t(Ee,{size:`lg`,className:`mb-4`}),t(`div`,{className:`text-lg font-medium`,children:v(`upload.analyzingFiles`)})]})}):A?n(ae,{children:[ue(),t(`div`,{className:`mb-4`,children:t(`div`,{className:`h-2 bg-muted/20 rounded-full overflow-hidden`,children:t(`div`,{className:`h-full bg-primary rounded-full`,style:{width:`${P}%`}})})}),t(`div`,{className:`max-h-96 overflow-y-auto`,children:O.map((e,r)=>n(`div`,{className:`flex items-center py-2 border-b border-border last:border-b-0`,children:[n(`div`,{className:`me-3`,children:[e.status===`pending`&&t(nn,{className:`size-5 text-muted`}),e.status===`uploading`&&t(Ee,{size:`sm`}),e.status===`success`&&t(Et,{className:`size-5 text-success`}),e.status===`error`&&t(xr,{className:`size-5 text-destructive`})]}),n(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`truncate font-medium`,children:e.file.name}),n(`div`,{className:`text-xs text-muted`,children:[e.status===`pending`&&v(`agent.waiting`),e.status===`uploading`&&v(`agent.uploading`),e.status===`success`&&(e.action===`create`?v(`store.created`):e.action===`update`?v(`store.updated`):v(`upload.skip`)),e.status===`error`&&e.message]})]})]},`${e.file.name}-${e.file.size}-${e.file.lastModified}`))})]}):t(ae,{children:n(`div`,{className:`mb-4`,children:[ue(),t(Vi,{files:O.map(e=>{let t;return t=e.status===`success`?e.action===`create`?`success`:e.action===`update`?`updated`:`skipped`:`failed`,{name:e.file.name,status:t,error:e.status===`error`?e.message:void 0}}),location:c||void 0,collection:R?.name})]})}),(()=>{if(p)return n(oe,{children:[t(o,{variant:`ghost`,onClick:ge,children:v(`modal.cancel`)}),t(o,{onClick:()=>{let e={success:!0,objectIds:[],uploadedFiles:[{name:`type-selection`,type:E?.id||null,status:`created`}],skippedFiles:[],failedFiles:[]};d&&d(e),ge()},children:E?v(`upload.useTypeName`,{typeName:E.name}):v(`upload.useAutoDetection`)})]});if(b.length===0&&!f)return t(oe,{children:t(o,{variant:`ghost`,onClick:ge,children:v(`modal.cancel`)})});if(!A&&!M){let e=w;return n(oe,{children:[t(o,{variant:`ghost`,onClick:ge,children:v(`modal.cancel`)}),t(o,{disabled:!e,onClick:ve,children:de.toCreate+de.toUpdate>0?v(`agent.upload`):v(`upload.continue`)})]})}return A?t(oe,{children:t(o,{variant:`ghost`,disabled:!0,children:v(`agent.uploading`)})}):n(oe,{children:[t(o,{variant:`ghost`,onClick:()=>{x([]),C([]),T(!1),D(null),k([]),j(!1),N(!1),F(0),fe({toCreate:0,toUpdate:0,toSkip:0})},children:v(`upload.uploadMore`)}),t(o,{onClick:()=>{d&&te&&d(te),ge()},children:v(`agent.close`)})]})})()]},I)}function Ev(e){let t=typeof e==`function`?e:e.onUploadDone,{client:n,project:r,store:i}=Z(),a=gv(),o=Ye(),s=ut.getFixedT(null,lt),{checkDocumentProcessing:c}=wv();return async(e,l,u)=>{let d={success:!1,objectIds:[],uploadedFiles:[],skippedFiles:[],failedFiles:[]};if(!r)return o({status:`error`,title:s(`store.noProjectSelected`),duration:3e3}),d;if(!e||e.length===0)return o({status:`warning`,title:s(`store.noFilesSelected`),duration:3e3}),d;let f=Array.from(e).filter(e=>e.size>0);if(f.length===0)return o({status:`error`,title:s(`store.noValidFilesSelected`),description:s(`store.pleaseSelectValidFiles`),duration:5e3}),d;let p=[],m=[],h=[];console.log(`Processing ${f.length} files with smart file processing...`);let g=await c(f,null,u),_=g.filter(e=>e.action===xv.CREATE).length,v=g.filter(e=>e.action===xv.UPDATE).length,y=g.filter(e=>e.action===xv.SKIP).length;o({title:s(`store.filesAnalyzedTitle`),description:`${f.length} file(s): ${_} new, ${v} to update, ${y} to skip`,status:`info`,duration:4e3});for(let e of g.filter(e=>e.action===xv.SKIP&&e.existingId))p.push({id:e.existingId,name:e.name,type:l,status:`skipped`,location:e.location});let b=g.filter(e=>(e.action===xv.CREATE||e.action===xv.UPDATE)&&e.file);if(b.length>0){console.log(`Processing ${b.length} files (${b.filter(e=>e.action===xv.CREATE).length} create, ${b.filter(e=>e.action===xv.UPDATE).length} update)...`);let e=[];for(let t=0;t<b.length;t+=50)e.push(b.slice(t,t+50));for(let t=0;t<e.length;t++){let r=e[t],a=t*50;console.log(`Processing batch ${t+1}/${e.length} (${r.length} files)`),b.length>50&&o({title:s(`store.processingFiles`),description:`Processed ${a}/${b.length} files...`,status:`info`,duration:2e3});let c=await Promise.all(r.map(async e=>{try{if(e.action===xv.UPDATE&&e.existingId){let t=await n.store.objects.update(e.existingId,{type:l||void 0,content:e.file,location:e.location,name:e.name},{createRevision:!0,revisionLabel:`upload on ${new Date().toISOString()}`});return m.push({id:e.existingId,name:e.name,type:l,status:`updated`,location:e.location}),d.objectIds.push(e.existingId),{success:!0,id:t.id,name:e.name,action:`update`}}else{let t=u?{collection_id:u}:void 0,n=await i.objects.create({type:l||void 0,content:e.file,location:e.location||e.file.webkitRelativePath||e.name},t);m.push({id:n.id,name:e.name,type:l,status:`created`,location:e.location})}}catch(t){console.error(`Failed to process file ${e.name}:`,t),h.push({name:e.name,error:H(t,`Unknown error`),status:`failed`,location:e.location,type:l}),o({status:`error`,title:s(`store.processingFailedFor`,{name:e.name}),description:H(t),duration:4e3})}})),f=m.filter(e=>e.status===`created`),p=m.filter(e=>e.status===`updated`),g=m.filter(e=>e.status===`failed`);console.log(`Batch ${t+1} results:`,{creates:f,updates:p,failures:g,total:c.length})}}let x=m.filter(e=>e.status===`created`).length,S=m.filter(e=>e.status===`updated`).length,C=m.filter(e=>e.status===`failed`).length,w=m.filter(e=>e.status===`skipped`).length;t&&(console.log(`Upload complete:`,{totalObjectIds:d.objectIds.length,uploadedFiles:x,updatedFiles:S,skippedFiles:w,failedFiles:C}),await t(d.objectIds));let T=``;return x>0&&(T+=`${x} file${x===1?``:`s`} uploaded`),S>0&&(T+=T?`, `:``,T+=`${S} file${S===1?``:`s`} updated`),w>0&&(T+=T?`, `:``,T+=`${w} file${w===1?``:`s`} skipped (already existed)`),C>0&&(T+=T?`, `:``,T+=`${C} file${C===1?``:`s`} failed`),T&&o({status:C>0?`warning`:`success`,title:T,duration:4e3}),a.search(),d}}const Dv=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function Ov({isGridView:e=!1,onUpload:n,collectionId:r,...i}){return n?t(kv,{...i,onUpload:n,isGridView:e,collectionId:r}):t(Av,{...i,isGridView:e})}function kv({isGridView:e,onUpload:r,collectionId:i,skipTypeModal:a=!1,...o}){let[s,c]=Y(!1),[l,u]=Y([]),[d,f]=Y(!1),[p,m]=Y(null),[h,g]=Y(!1),_=gv(),v=Ye(),{t:y}=X(),{checkDocumentProcessing:b}=wv(),x=async(e,t)=>{console.log(`Files dropped on ObjectTable:`,e.length,t),c(!0);try{if(i){let t=await b(e,null,i);m(t);let n=t.filter(e=>e.action===`create`).length,r=t.filter(e=>e.action===`update`).length,a=t.filter(e=>e.action===`skip`).length;v({title:y(`store.filesReadyToProcess`),description:`${e.length} file(s): ${n} new, ${r} to update, ${a} to skip`,status:`info`,duration:4e3})}else m(null)}catch(e){console.error(`Error processing files:`,e),v({title:y(`store.errorProcessingFiles`),description:y(`store.errorCheckingDuplicates`),status:`error`,duration:4e3}),m(null)}finally{if(c(!1),u(e),f(!1),a){console.log(`Skipping type modal and calling onUpload directly`,{filesLength:e.length,processedFilesLength:p?.length});let t=r(e,null,i);t&&typeof t==`object`&&(t.processedFiles=p)}else console.log(`Setting typeSelectionOpen to true`,{filesLength:e.length}),g(!0)}},S=e=>{let t=[...l];u([]),m(null),g(!1),t.length>0&&e!==void 0&&(c(!0),console.log(`Starting upload with`,{typeId:e,filesCount:t.length,hasProcessingResults:!!p,collectionId:i}),r(t,e,i).finally(()=>{c(!1),_.search()}))},C=e=>{e.preventDefault(),e.stopPropagation(),f(!0)};return n(`div`,{className:`min-h-[400px] relative`,onDragOver:C,onDragEnter:C,onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),!e.currentTarget.contains(e.relatedTarget)&&f(!1)},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),f(!1),e.dataTransfer.items){let t=[];for(let n=0;n<e.dataTransfer.items.length;n++){let r=e.dataTransfer.items[n];if(r.kind===`file`){let e=r.getAsFile();e&&t.push(e)}}if(t.length>0){let e={count:t.length,message:`Preparing to upload ${t.length} file${t.length===1?``:`s`}...`};x(t,e)}}},children:[t(`div`,{className:Ze(`bg-white dark:bg-gray-800 opacity-40 absolute inset-0 z-50 flex justify-center items-center`,s?`block`:`hidden`),children:t(Ee,{size:`xl`})}),t(Av,{...o,isGridView:e}),t(`div`,{className:Ze(`absolute inset-0 pointer-events-none`,d?`z-40`:`-z-10`),children:t(`div`,{className:`w-full h-full relative`,children:t(Mi,{onDrop:x,message:`Drop files or folders here to upload`,className:Ze(`absolute inset-0 bg-white/90 dark:bg-gray-800/90 pointer-events-auto`,d?`flex`:`hidden`),buttonLabel:`Select Files or Folders`,allowFolders:!0})})}),t(Tv,{isOpen:h&&l.length>0,onClose:()=>{u([]),m(null),g(!1),S(void 0)},files:l,collectionId:i,selectedFolder:null,title:`Upload Files`,onUploadComplete:e=>{if(e){if(e.failedFiles&&e.failedFiles.length>0&&v({title:y(`store.uploadIssues`),description:`${e.failedFiles.length} file(s) failed to upload`,status:`warning`,duration:5e3}),e.success){let t=e.uploadedFiles.filter(e=>e.status===`created`).length,n=e.uploadedFiles.filter(e=>e.status===`updated`).length,r=e.skippedFiles.length;(t>0||n>0)&&v({title:y(`store.uploadComplete`),description:`${t>0?`${t} created`:``}${t>0&&n>0?`, `:``}${n>0?`${n} updated`:``}${r>0?`, ${r} skipped`:``}`,status:`success`,duration:5e3})}_.search()}u([]),m(null),g(!1),e?.success&&e.objectIds.length>0?S(null):S(void 0)}})]})}function Av({objects:e,layout:n=Dv,isLoading:r,onRowClick:i,onSelectionChange:a,highlightRow:o,previewObject:s,selectedObject:c,isGridView:l}){let u=k_(),d=(t,n)=>{if(u){let r=n.nativeEvent instanceof MouseEvent&&n.nativeEvent.shiftKey;if(!n.target.checked)u.remove(t.id);else if(u.add(t),r){let n=e.findIndex(e=>e.id===t.id),r=jv(e,n,u);if(r>-1&&r<n-1){let t=[];for(let i=r+1;i<n;i++)t.push(e[i]);u.addAll(t)}else{let t=Mv(e,n,u);if(t>-1&&t>n+1){let r=[];for(let i=n+1;i<t;i++)r.push(e[i]);u.addAll(r)}}}a?.(u)}},f=t=>{u&&(t.target.checked?u.addAll(e):u.removeAll())},p=q(()=>{let e=n.length>0?n:Dv;return console.log(`Using layout with columns:`,e.map(e=>e.name).join(`, `)),e.map(e=>new lv(e,s))},[n,s]);return t(l?pv:fv,{objects:e,isLoading:r,columns:p,onRowClick:i,highlightRow:o,previewObject:s,selectedObject:c,selection:u,toggleAll:f,onSelectionChange:d})}function jv(e,t,n){for(let r=t-1;r>=0;r--)if(n.isSelected(e[r].id))return r;return-1}function Mv(e,t,n){let r=e.length;for(let i=t+1;i<r;i++)if(n.isSelected(e[i].id))return i;return-1}function Nv({children:e,limit:n,parent:r,typeId:i,facets:a,name:o,collectionId:s}){let{store:c}=Z(),l=q(()=>{let e;a?e=a:(e=[{name:`status`,field:`status`},{name:`location`,field:`location`}],i||e.unshift({name:`type`,field:`type`}));let t=new mv(c,n).withFacets(e);return t.collectionId=s,t.query.type=i,t.query.parent=r,t.query.name=o,s&&(t.query.all_revisions=!0),t},[s,a,n,o,r,c,i]);return t(hv.Provider,{value:l,children:e})}const Pv=`vertesia.content_store.lastDisplayedView`;function Fv({onUpdate:e}){let{t:n}=X(),[r,i]=Y(localStorage.getItem(Pv)===`grid`),a=()=>{r?c():s()},s=()=>{localStorage.setItem(Pv,`grid`),i(!0),e(!0)},c=()=>{localStorage.setItem(Pv,`table`),i(!1),e(!1)};return t(o,{variant:`outline`,onClick:a,title:n(r?`misc.tableView`:`misc.thumbnailView`),children:t(r?lr:Sn,{})})}Fv.LAST_DISPLAYED_VIEW=Pv;const Iv=[{name:`Name`,field:`properties.title`,type:`string`,fallback:`name`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Created At`,field:`created_at`,type:`date`}];function Lv({onChange:e,selectedIds:n}){return t(Nv,{children:t(Rv,{onRowClick:t=>{e(t||void 0)},selectedIds:n})})}function Rv({onRowClick:e,selectedIds:r}){let{t:i}=X(),a=G(e=>!!r?.has(e.id),[r]),[s,c]=Y(!1),[l,u]=Y(localStorage.getItem(`vertesia.content_store.lastDisplayedView`)===`grid`),{search:d,isLoading:f,error:p,objects:m,hasMore:h}=vv(),g=J(null);Ke(g,()=>{s&&h&&!f&&(c(!1),d.loadMore(!0).finally(()=>{c(!0)}))},{threshold:.1,deps:[s,h,f]}),K(()=>{d.search().finally(()=>{c(!0)})},[d]);let _=_v(),v=gv();return p?t(M,{title:i(`store.searchFailed`),children:p.message}):n(`div`,{className:`flex flex-col gap-2 h-full w-full`,children:[n(`div`,{className:`flex justify-between items-center flex-shrink-0`,children:[t($g,{facets:_,search:v}),n(`div`,{className:`flex items-center gap-2`,children:[t(o,{variant:`outline`,onClick:()=>{c(!1),d.search().then(()=>c(!0))},"aria-label":`Refresh`,children:t(qn,{size:16})}),t(Fv,{onUpdate:u})]})]}),n(`div`,{className:`@container relative flex-1 overflow-y-auto`,children:[t(Ov,{objects:m||[],isLoading:!m.length&&f,layout:Iv,onRowClick:e,highlightRow:r?.size?a:void 0,isGridView:l}),t(`div`,{ref:g,className:`h-4 w-full`})]})]})}function zv(e){let t=Math.max(0,e)/1e3,n=+(t>0&&t<10&&!Number.isInteger(t));return`${new Intl.NumberFormat(void 0,{maximumFractionDigits:n}).format(t)}K`}function Bv({onSend:e,onStop:r,approvalModeSlot:i,mcpSlot:a,disabled:s=!1,isSending:c=!1,isStopping:l=!1,isStreaming:u=!1,isCompleted:d=!1,contextWindowUsage:f,onCompactContext:p,isCompactingContext:m=!1,activeTaskCount:h=0,activeWorkstreams:g=[],placeholder:_,onFilesSelected:v,uploadedFiles:y=[],onRemoveFile:b,onRemoveProcessingFile:x,acceptedFileTypes:S,maxFiles:C=5,processingFiles:T,artifactRunId:E,hasProcessingFiles:D=!1,renderDocumentSearch:O,selectedDocuments:k=[],onRemoveDocument:A,hideObjectLinking:j=!1,hideFileUpload:M=!1,disableDropZone:N=!1,className:P,inputClassName:F}){let{t:I}=X(),L=_??I(`agent.typeYourMessage`),R=J(null),ee=J(null),[te,z]=Y(``),[ne,re]=Y(!1),[oe,ce]=Y(!1),[le,ue]=Y(!1),de=!!(v&&!M),fe=de&&!N,pe=!j||de||!!O,me=y.length>=C,he=x??b,ge=q(()=>g.filter(e=>e.status===`running`||e.status===`canceling`),[g]),_e=ge.length||h,ve=f?I(`agent.contextUsageCompactLabel`,{percent:f.usedPercent}):void 0,ye=f?I(`agent.contextTokenUsage`,{used:zv(f.usedTokens),limit:zv(f.checkpointTokens)}):void 0,be=q(()=>{let e=[];if(!M&&T)for(let t of T.values()){let n=t.preview_url,r=t.status===Nr.UPLOADING?I(`agent.uploading`):t.status===Nr.PROCESSING?I(`agent.processing`):t.status===Nr.ERROR?I(`agent.error`):t.status===Nr.READY?I(`agent.ready`):t.status;e.push({id:t.id,name:t.name,contentType:t.content_type,artifactPath:t.artifact_path,previewUrl:n,removable:!!he,statusLabel:r,statusTone:t.status===Nr.ERROR?`destructive`:t.status===Nr.READY?`success`:`attention`})}if(!M)for(let t of y)e.push({id:t.id,name:t.name,contentType:t.type,artifactPath:t.artifact_path,previewUrl:t.previewUrl,removable:!!b,statusLabel:I(`agent.ready`),statusTone:`success`});for(let t of k)e.push({id:t.id,name:t.name,href:`/store/objects/${t.id}`,removable:!!A,statusTone:`info`});return e},[he,M,A,b,T,k,I,y]);K(()=>{!s&&d&&R.current?.focus()},[s,d]);let xe=G(e=>{if(!de||!v)return;let t=Array.from(e),n=C-y.length,r=t.slice(0,n);r.length>0&&v(r)},[de,v,C,y.length]),Se=G(e=>{e.preventDefault(),e.stopPropagation(),fe&&ue(!0)},[fe]),Ce=G(e=>{e.preventDefault(),e.stopPropagation(),ue(!1)},[]),we=G(e=>{e.preventDefault(),e.stopPropagation(),ue(!1),fe&&e.dataTransfer?.files&&e.dataTransfer.files.length>0&&xe(e.dataTransfer.files)},[fe,xe]),Te=G(e=>{if(!de)return;let t=jh(e.clipboardData?.items);t.length>0&&xe(t)},[de,xe]),De=G(e=>{de&&e.target.files&&e.target.files.length>0&&(xe(e.target.files),e.target.value=``)},[de,xe]),Oe=G(()=>{ee.current?.click()},[]),ke=G(()=>ce(!1),[]),Ae=G(e=>ce(!1),[]),je=()=>{let t=te.trim();!t||s||c||D||(e(t),z(``))},Me=()=>{r&&!l&&r()},Ne=J(0),Pe=e=>{if(e.key===`Enter`){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)){e.preventDefault(),te.trim().length>0&&je();return}e.shiftKey||(e.preventDefault(),Be(e.currentTarget,z));return}if(e.key===`Escape`&&u&&r){let e=Date.now();e-Ne.current<500?(Me(),Ne.current=0):Ne.current=e}},Fe=G(()=>{let e=R.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]);return K(()=>{Fe()},[te,Fe]),n(`div`,{className:V(`px-3 py-3 flex-shrink-0 transition-all fixed lg:sticky bottom-0 start-0 end-0 lg:start-auto lg:end-auto w-full bg-background/95 backdrop-blur z-10`,le&&fe&&`bg-info/10 border-info`,P),onDragOver:fe?Se:void 0,onDragLeave:fe?Ce:void 0,onDrop:fe?we:void 0,children:[le&&fe&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-blue-100/80 dark:bg-blue-900/40 rounded-lg z-10 pointer-events-none`,children:n(`div`,{className:`text-blue-600 dark:text-blue-400 font-medium flex items-center gap-2`,children:[t(pr,{className:`size-5`}),I(`agent.dropFilesToUpload`)]})}),de&&t(`input`,{ref:ee,type:`file`,multiple:!0,accept:S,onChange:De,className:`hidden`}),t(Qh,{activeWorkstreams:g}),n(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-2 rounded-2xl border border-border/70 bg-mixer-muted/15 p-2.5 shadow-lg shadow-black/5`,children:[be.length>0&&t(td,{items:be,artifactRunId:E,variant:`composer`,onRemove:e=>{T?.has(e)?he?.(e):y.some(t=>t.id===e)?b?.(e):A?.(e)},className:`gap-1.5`}),t(`div`,{className:`flex min-w-0 flex-1`,children:t(Re,{ref:R,value:te,onKeyDown:Pe,onChange:e=>z(e.target.value),onPaste:Te,disabled:s,"aria-label":L,placeholder:L,rows:1,style:{maxHeight:`160px`},className:V(`min-h-[44px] resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 shadow-none focus-visible:ring-0`,F)})}),n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[pe&&n(w,{align:`left`,trigger:t(o,{variant:`ghost`,size:`icon`,className:`size-8 rounded-full text-muted hover:bg-muted`,title:I(`agent.addAttachment`),children:t(Wn,{className:`size-4`})}),children:[!j&&n(B,{onClick:()=>re(!0),isDisabled:!d,children:[t(zn,{className:`size-4`}),I(`agent.linkObject`)]}),de&&n(B,{onClick:Oe,isDisabled:me,children:[t(pr,{className:`size-4`}),I(`agent.upload`)]}),O&&n(B,{onClick:()=>ce(!0),children:[t(sn,{className:`size-4`}),t(`span`,{children:I(`agent.searchDocuments`)}),k.length>0&&t(`span`,{className:`ms-auto inline-flex items-center justify-center rounded-full bg-info/20 px-1.5 py-0.5 text-[10px] font-medium text-info`,children:k.length})]})]}),i,a,f&&t(ze,{asChild:!0,placement:`top`,size:`md`,className:`text-foreground shadow-lg`,description:n(`span`,{className:`block max-w-56 text-start text-sm leading-6`,children:[t(`span`,{className:`block`,children:I(`agent.contextRemainingUntilCompact`,{percent:f.remainingPercent})}),ye&&t(`span`,{className:`mt-1 block text-foreground/80`,children:ye})]}),children:t(o,{type:`button`,variant:`ghost`,size:`icon`,className:V(`size-8 rounded-lg text-info hover:bg-muted hover:text-info disabled:opacity-60`,`focus-visible:ring-2 focus-visible:ring-info/40`),"aria-label":ve,onClick:p,disabled:!p||m,children:m?t(Ee,{size:`sm`}):n(`svg`,{viewBox:`0 0 24 24`,className:V(`size-8 -rotate-90`,f.usedPercent>=90?`text-destructive`:f.usedPercent>=70?`text-attention`:`text-info`),"aria-hidden":`true`,children:[t(`circle`,{cx:`12`,cy:`12`,r:`9.75`,fill:`none`,strokeWidth:`4.5`,className:`stroke-current text-muted/50`}),t(`circle`,{cx:`12`,cy:`12`,r:`9.75`,fill:`none`,pathLength:100,strokeWidth:`4.5`,strokeLinecap:`round`,strokeDasharray:100,style:{strokeDashoffset:100-f.usedPercent},className:`stroke-current`})]})})}),ge.length===0&&_e>0&&t(`output`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,"aria-live":`polite`,children:n(`span`,{className:`inline-flex h-8 items-center gap-1 rounded-full px-2 text-xs text-muted`,children:[t(ft,{className:`size-3 text-attention`}),I(`agent.activeWorkstreams`,{count:_e})]})})]}),u&&r&&!te.trim()?t(o,{onClick:Me,disabled:l,variant:`ghost`,size:`icon`,className:V(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`,`[&_svg]:text-destructive disabled:[&_svg]:text-muted`),title:I(`agent.stopTooltip`),children:l?t(Ee,{size:`sm`}):t(or,{className:`size-3 fill-current stroke-current`})}):t(o,{onClick:je,disabled:s||c||!te.trim()||D,variant:`ghost`,size:`icon`,className:V(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`),title:I(D?`agent.waitForFiles`:`agent.sendTooltip`),"aria-label":I(D?`agent.waitForFiles`:`agent.send`),children:c?t(Ee,{size:`sm`}):t(_t,{className:`size-4`})})]})]}),n(ie,{isOpen:ne,onClose:()=>re(!1),className:`min-w-[60vw]`,children:[t(se,{children:I(`agent.linkObject`)}),t(ae,{className:`pb-6`,children:t(Lv,{onChange:e=>{let t=`[${e.properties?.title||e.name||`Object`}](store:${e.id})`,n=te||``,r=R.current?.selectionStart||n.length,i=n.substring(0,r)+t+n.substring(r);z(i),re(!1),setTimeout(()=>{if(R.current){R.current.focus();let e=r+t.length;R.current.setSelectionRange(e,e)}},100)}})})]}),O?.({isOpen:oe,onClose:ke,onSelect:Ae})]})}function Vv({code:e}){let{onProposalSelect:n,onProposalSubmit:r}=Wi(),i=q(()=>Ui(e),[e]),a=q(()=>{if(i)return null;try{let t=e.trim(),i=JSON.parse(t);if(!i.options||!i.question&&!i.title)return null;let a={question:i.question||i.title||``,description:i.description,options:Array.isArray(i.options)?i.options.map(e=>({id:e.id||e.value||``,label:e.label||``,description:e.description})):void 0,allowFreeResponse:i.allowFreeResponse??i.multiple,variant:i.variant,onSelect:n,onSubmit:r};return!a.question||!a.options?.length?null:a}catch{return null}},[e,n,r,i]);return i?t(Ai,{type:`proposal`,message:`Loading options...`}):a?t(ki,{type:`proposal`,fallbackCode:e,children:t(yl,{...a})}):t(Ai,{type:`proposal`,error:`Invalid proposal specification`})}const Hv=it(function({code:e}){let n=q(()=>{try{let t=JSON.parse(e);return t?.library===`vega-lite`&&t?.spec&&typeof t.spec==`object`?t:typeof t?.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}catch{return null}},[e]);return n?t(Ba,{spec:n}):null}),Uv=it(function({code:e}){let n=q(()=>{try{return{library:`vega-lite`,spec:JSON.parse(e)}}catch{return null}},[e]);return n?t(Ba,{spec:n}):null}),Wv={chart:Hv,"vega-lite":Uv,vegalite:Uv,"fusion-fragment":Si,proposal:Vv,askuser:Vv};function Gv({url:e,code:n}){let[r,i]=Y(null);return K(()=>{import(e).then(e=>{i(()=>e.default)}).catch(t=>{console.error(`Failed to load remote widget component from `,e,t)})},[e]),r?t(r,{code:n}):null}async function Kv(e){let n=await e.apps.getInstalledApps(`tools`),r=new Set;for(let e of n){if(e.manifest.tool_collections&&e.manifest.tool_collections.length>0)for(let t of e.manifest.tool_collections||[]){let e=Jr(t).url;if(e.startsWith(`http://`)||e.startsWith(`https://`)){let t=e.indexOf(`/api/`);if(t>0){let n=e.substring(0,t);r.add(`${n}/api/widgets`)}}}e.manifest.endpoint&&e.manifest.capabilities?.includes(`tools`)&&r.add(new URL(`/api/widgets`,e.manifest.endpoint).toString())}let i=await Promise.all(Array.from(r).map(e=>fetch(e).then(e=>{if(!e.ok)throw Error(`Failed to fetch widgets: ${e.status} ${e.statusText}`);return e.json()}).then(e=>{let n=[],r=e.widgets;for(let[e,i]of Object.entries(r))n.push({name:e,component:e=>t(Gv,{url:i.url,code:e.code})});return n}).catch(()=>(console.error(`Failed to fetch skill widgets from `,e),null)))),a={};for(let e of i.flat())e&&(a[e.name]=e.component);return a}function qv({children:e}){let{client:n}=Z(),[r,i]=Y(Wv);return K(()=>{Kv(n).then(e=>{i({...Wv,...e})})},[n]),t(ji,{components:r,children:e})}const Jv=new Map;function Yv(e){if(typeof e==`number`)return e;if(!e)return Date.now();let t=new Date(e).getTime();return Number.isFinite(t)?t:Date.now()}function Xv(e){return e===`running`||e===`canceling`}function Zv(e){return!Xv(e)}function Qv(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function $v(e){for(let t=e.length-1;t>=0;t--){let n=e[t].details;if(!n)continue;let r=n.token_usage,i=Qv(r?.total),a=Qv(n.checkpoint_threshold)??Qv(n.checkpoint_at);if(typeof i!=`number`||typeof a!=`number`||a<=0)continue;let o=Math.max(0,Math.min(100,Math.round(i/a*100)));return{usedTokens:i,checkpointTokens:a,usedPercent:o,remainingPercent:Math.max(0,100-o)}}}function ey(e,t){return!Zv(e.status)||!Xv(t.status)?{...e,...t}:{...e,interaction:e.interaction??t.interaction,elapsed_ms:Math.max(e.elapsed_ms,t.elapsed_ms),deadline_ms:Math.max(e.deadline_ms,t.deadline_ms),remaining_ms:0,phase:e.phase??t.phase,child_workflow_id:e.child_workflow_id??t.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id??t.child_workflow_run_id}}function ty(e){let t=e.details,n=typeof t?.workstream_id==`string`&&t.workstream_id.trim()?t.workstream_id:Vl(e);return n===`main`||n===`all`?null:{workstreamId:n,launchId:typeof t?.launch_id==`string`?t.launch_id:void 0,interaction:typeof t?.interaction==`string`?t.interaction:void 0,childWorkflowId:typeof t?.child_workflow_id==`string`?t.child_workflow_id:void 0,childWorkflowRunId:typeof t?.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0}}function ny(e){if(e.type!==Q.ERROR)return!1;let t=e.details;return t?.event_class!==`activity`||t.workstream_event?!1:!(t.tool||t.tool_status||t.tool_run_id||t.activity_group_id||t.tool_event)}function ry(e,t,n,r,i,a){if(r){let a=t.get(n);if(a?.startsWith(`message-derived:`)){let t=e.get(a);t&&(e.delete(a),e.set(r,{...t,launch_id:r,updated_at:Math.max(t.updated_at,i)}))}t.set(n,r)}let o=r??t.get(n)??`message-derived:${n}`,s=e.get(o);if(s)return s;let c={workstream_id:n,launch_id:o,elapsed_ms:0,deadline_ms:0,remaining_ms:0,status:`running`,started_at:i,updated_at:i,order:a};return e.set(o,c),t.has(n)||t.set(n,o),c}function iy(e){let t=new Map,n=new Map;return e.forEach((e,r)=>{let i=Yv(e.timestamp),a=ty(e),o=jl(e),s=o?.workstreamId??a?.workstreamId;if(!s)return;let c=o?.launchId??a?.launchId,l=Ol(e);if(!o&&!c&&l&&!n.has(s))return;let u=ry(t,n,s,c,i,r);o?(u.interaction=o.interaction??u.interaction,u.child_workflow_id=o.childWorkflowId??u.child_workflow_id,u.child_workflow_run_id=o.childWorkflowRunId??u.child_workflow_run_id,u.status=`running`):(u.interaction=a?.interaction??u.interaction,u.child_workflow_id=a?.childWorkflowId??u.child_workflow_id,u.child_workflow_run_id=a?.childWorkflowRunId??u.child_workflow_run_id);let d=Al(e);d?u.status=d:l||(ny(e)?u.status=`failed`:(e.type===Q.COMPLETE||e.type===Q.IDLE)&&(u.status=`completed`)),!l&&(u.updated_at=Math.max(u.updated_at,i),Xv(u.status)?u.elapsed_ms=Math.max(u.elapsed_ms,i-u.started_at):(u.elapsed_ms=Math.max(u.elapsed_ms,i-u.started_at),u.remaining_ms=0))}),Array.from(t.values()).sort((e,t)=>{let n=Number(!Xv(e.status))-Number(!Xv(t.status));return n===0?Xv(e.status)?e.order-t.order:t.updated_at-e.updated_at||e.order-t.order:n}).map(({started_at:e,updated_at:t,order:n,...r})=>r)}function ay(e){return{workstream_id:e.workstream_id,launch_id:e.launch_id,interaction:e.interaction,elapsed_ms:e.elapsed_ms,deadline_ms:e.deadline_ms,remaining_ms:Math.max(0,e.deadline_ms-e.elapsed_ms),status:e.status,phase:e.latest_progress?.phase,child_workflow_id:e.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id}}function oy(e){return{workstream_id:e.workstream_id,launch_id:e.launch_id,interaction:e.interaction,elapsed_ms:e.duration_ms??0,deadline_ms:0,remaining_ms:0,status:e.status,phase:e.last_progress?.phase,child_workflow_id:e.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id}}function sy(e,t){let n=e.findIndex(e=>e.launch_id===t.launch_id);if(n>=0){e[n]=ey(e[n],t);return}let r=e.findIndex(e=>e.workstream_id===t.workstream_id&&e.launch_id.startsWith(`message-derived:`));if(r>=0&&!t.launch_id.startsWith(`message-derived:`)){e[r]=ey(e[r],t);return}e.push(t)}function cy(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function ly(e,t=!0){let[n,r]=Y(()=>Math.max(0,Math.floor((Date.now()-Yv(e))/1e3)));return K(()=>{if(!t)return;let n=()=>{r(Math.max(0,Math.floor((Date.now()-Yv(e))/1e3)))};n();let i=window.setInterval(n,1e3);return()=>window.clearInterval(i)},[t,e]),n}function uy(e=!0){let[t,n]=Y(0);return K(()=>{if(!e)return;let t=window.setInterval(()=>{n(()=>Math.floor(Math.random()*zu.length))},4e3);return()=>window.clearInterval(t)},[e]),t}function dy({message:e,startedAt:r}){let{t:i}=X(),a=ly(r),o=uy();return n(`div`,{className:`mx-auto flex min-h-full w-full max-w-3xl flex-col justify-end gap-6 px-1 py-8`,children:[t(`div`,{className:`flex w-full justify-end`,children:t(`div`,{className:V(`max-w-[min(44rem,82%)] rounded-[1.35rem] bg-mixer-muted/35 px-4 py-2.5`,`break-words text-sm font-normal leading-6 text-foreground/90 shadow-sm shadow-black/5`,`dark:bg-mixer-muted/15 dark:text-foreground/88 dark:shadow-none [overflow-wrap:anywhere]`),children:t(`div`,{className:`whitespace-pre-wrap`,children:e})})}),n(`div`,{className:`border-b border-border/70 pb-4 text-sm text-muted`,children:[n(`div`,{className:`flex items-center gap-3`,children:[t(Pu,{size:`sm`,color:`blue`}),n(`div`,{className:`min-w-0`,children:[n(`div`,{children:[t(`span`,{className:`font-medium`,children:i(`agent.preparing`)}),n(`span`,{className:`ms-2 text-muted/75`,children:[`for `,cy(a)]})]}),t(`div`,{className:`mt-1 truncate text-muted/80`,children:zu[o]})]})]}),t(`div`,{className:`mt-3 ps-6`,children:t(Nu,{color:`blue`})})]})]})}function fy(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;return i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))}),i.body.innerHTML=e.innerHTML,r.focus(),r.print(),setTimeout(()=>{n.parentNode?.removeChild(n)},1e3),!0}function py(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function my(e){return py(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function hy(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function gy(e){let{agentRunId:n,startWorkflow:r}=e;return n?t(qv,{children:t(yy,{...e,agentRunId:n})}):r?t(vy,{...e}):t(_y,{})}function _y(){let{t:e}=X();return n(re,{status:`info`,icon:t(yt,{className:`size-16 text-muted mb-4`}),children:[t(`div`,{className:`text-base font-medium text-muted`,children:e(`agent.noAgentRunning`)}),t(`div`,{className:`mt-3 text-sm text-muted`,children:e(`agent.selectInteraction`)})]})}function vy({initialMessage:e,interactive:r=!0,startWorkflow:i,onClose:a,isModal:s=!1,fullWidth:c=!1,placeholder:l,startButtonText:u,title:d,getAttachedDocs:f,onAttachmentsSent:p,acceptedFileTypes:m,maxFiles:h=5,hideHeader:g=!1,hideFileUpload:_=!1,hideObjectLinking:v,headerVariant:y,inputContainerClassName:b,inputClassName:x,className:S,allowWorkflowControl:C,initialToolApprovalMode:w}){let{t:T}=X(),E=!_,D=l??T(`agent.typeYourMessage`),O=u??T(`agent.startAgent`),k=d??T(`agent.startNewConversation`),{client:A}=Z(),[j,M]=Y(``),[N,P]=Y(!1),[F,I]=Y(null),[L,R]=Y(null),[ee,te]=Y(null),[z,ne]=Y(()=>qr(w,r)),B=Ye(),re=J(null),ie=J(null),[ae,oe]=Y([]),[se,ce]=Y(!1),le=J(0),ue=G(e=>{E&&(e.preventDefault(),e.stopPropagation(),le.current++,e.dataTransfer?.types?.includes(`Files`)&&ce(!0))},[E]),de=G(e=>{E&&(e.preventDefault(),e.stopPropagation())},[E]),fe=G(e=>{E&&(e.preventDefault(),e.stopPropagation(),le.current--,le.current===0&&ce(!1))},[E]),pe=G(e=>{if(E&&(e.preventDefault(),e.stopPropagation(),le.current=0,ce(!1),e.dataTransfer?.files&&e.dataTransfer.files.length>0)){let t=Array.from(e.dataTransfer.files);oe(e=>[...e,...t].slice(0,h))}},[h,E]),me=G(e=>{if(!E)return;let t=jh(e.clipboardData?.items);t.length>0&&oe(e=>[...e,...t].slice(0,h))},[E,h]),he=G(e=>{if(e.target.files&&e.target.files.length>0){let t=Array.from(e.target.files);oe(e=>[...e,...t].slice(0,h))}e.target.value=``},[h]),ge=G(e=>{oe(t=>t.filter((t,n)=>n!==e))},[]);K(()=>{re.current&&re.current.focus()},[]);let _e=async()=>{if(!i)return;let e=j.trim();if(!(!e||N)){P(!0);try{sessionStorage.removeItem(`plan-panel-shown`),B({title:E&&ae.length>0?T(`agent.startingAgentUploading`):T(`agent.startingAgent`),status:`info`,duration:3e3});let t=f?.()||[],n=e;if(t.length>0&&!/store:\S+/.test(e)&&(n=[e,``,`Attachments:`,...t.map(e=>`[${e.name}](/store/objects/${e.id})`)].join(`
|
|
440
440
|
`)),E&&ae.length>0){let e=ae.map(e=>e.name).join(`, `);n=[n,``,`[System: ${ae.length} file(s) are being uploaded: ${e}. Please wait for the "Files Ready" notification before processing them.]`].join(`
|
|
441
|
-
`)}let r=await i(n,{tool_approval_mode:B});if(!r){R(null),ee(null);return}R(n),ee(Date.now());let a=r.agent_run_id,o=[];if(E&&ae.length>0){for(let e of ae)try{let t=`files/${e.name}`;await A.agents.uploadArtifact(a,t,e),await A.agents.sendSignal(a,`FileUploaded`,{id:`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:e.name,content_type:e.type||`application/octet-stream`,reference:`artifact:${t}`,artifact_path:t}),o.push(e.name)}catch(t){console.error(`Failed to upload staged file ${e.name}:`,t)}if(o.length>0)try{await A.agents.sendSignal(a,`UserInput`,{message:`[Files Ready] All ${o.length} file(s) have been uploaded and are now available: ${o.join(`, `)}. You can now process them.`,metadata:{type:`files_ready`,files:o}})}catch(e){console.error(`Failed to send files ready signal:`,e)}oe([])}p?.(),I(a),M(``),ne({title:T(`agent.agentStarted`),status:`success`,duration:3e3})}catch(e){R(null),ee(null),ne({title:T(`agent.errorStarting`),status:`error`,duration:3e3,description:e instanceof Error?e.message:T(`agent.unknownError`)})}finally{P(!1)}}},_e=e=>{if(e.key===`Enter`){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)){e.preventDefault(),ge();return}e.shiftKey||(e.preventDefault(),Pe(e.currentTarget,M))}},ve=G(()=>{let e=re.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]);return K(()=>{ve()},[j,ve]),F?t(Py,{onClose:a,isModal:s,initialMessage:e,placeholder:l,fullWidth:c,hideHeader:g,headerVariant:y,hideFileUpload:_,hideObjectLinking:v,inputContainerClassName:b,inputClassName:x,className:S,allowWorkflowControl:C,agentRunId:F,title:d,pendingStartMessage:L??void 0,pendingStartTimestamp:z??void 0,initialToolApprovalMode:B}):t(`div`,{className:H(`flex h-full flex-col items-center bg-background`,S),children:n(`div`,{className:H(`relative flex h-full w-full flex-col overflow-hidden border-0`,c?``:`max-w-4xl`),onDragEnter:E?ue:void 0,onDragOver:E?de:void 0,onDragLeave:E?fe:void 0,onDrop:E?pe:void 0,children:[E&&se&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info-background z-50 pointer-events-none rounded-lg`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2 text-lg`,children:[t(Zn,{className:`size-6`}),`Drop files to stage for upload`]})}),E&&t(`input`,{ref:ie,type:`file`,multiple:!0,accept:m,onChange:V,className:`hidden`}),!g&&n(`div`,{className:`flex items-center justify-between border-b border-border/60 bg-background px-3 py-2`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`div`,{className:`p-1`,children:t(It,{className:`size-3.5 text-muted`})}),t(`span`,{className:`text-sm font-medium text-foreground`,children:k})]}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,"aria-label":T(`agent.close`),title:T(`agent.close`),className:`text-muted hover:text-foreground`,children:t(ar,{className:`size-4`})})]}),t(`div`,{className:`flex flex-1 flex-col items-center justify-end overflow-y-auto bg-background px-4`,children:L&&z?t(Ey,{message:L,startedAt:z}):t(`div`,{className:`mx-auto flex min-h-full w-full max-w-3xl flex-col justify-end py-8`,children:e&&t(`div`,{className:`text-[15px] leading-relaxed text-foreground/80`,children:e})})}),t(`div`,{className:`shrink-0 bg-background px-4 pb-safe-area-4 pt-2`,children:n(`div`,{className:H(`mx-auto flex max-w-3xl flex-col gap-3 rounded-2xl border border-border/70 bg-mixer-muted/15 p-3 shadow-lg shadow-black/5`,b),children:[E&&ae.length>0&&t(`div`,{className:`flex flex-wrap gap-2`,children:ae.map((e,r)=>n(`div`,{className:`flex items-center gap-1.5 rounded-md bg-attention/10 px-2 py-1 text-sm text-attention`,title:T(`agent.fileStagedTooltip`),children:[t(Jt,{className:`size-3.5`}),t(`span`,{className:`max-w-[120px] truncate`,children:e.name}),t(`span`,{className:`text-xs opacity-70`,children:T(`agent.staged`)}),t(o,{variant:`unstyled`,"aria-label":`Remove staged file ${e.name}`,onClick:()=>he(r),className:`ms-1 rounded p-0.5 hover:bg-attention/20`,children:t(ar,{className:`size-3`})})]},`${e.name}-${e.size}-${e.lastModified}`))}),t(je,{ref:re,value:j,onChange:e=>M(e.target.value),onKeyDown:_e,onPaste:me,placeholder:D,disabled:N,rows:2,className:H(`min-h-[72px] resize-none overflow-hidden border-0 bg-transparent px-0 py-0 text-sm leading-6 shadow-none focus-visible:ring-0`,x),style:{minHeight:`72px`,maxHeight:`200px`}}),n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[E&&t(o,{variant:`ghost`,size:`icon`,onClick:()=>ie.current?.click(),disabled:N||ae.length>=h,"aria-label":T(`agent.upload`),className:`rounded-full text-muted`,title:T(`agent.upload`),children:t(Zn,{className:`size-4`})}),r&&t(Qi,{mode:B,onChange:te,disabled:N})]}),t(o,{onClick:ge,disabled:!j.trim()||N,variant:`ghost`,size:`icon`,className:H(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`),title:O,"aria-label":O,children:N?t(be,{size:`sm`}):t(lt,{className:`size-4`})})]})]})})]})})}function Py({agentRunId:r,title:i,interactive:a=!0,onClose:s,isModal:c=!1,fullWidth:l=!1,placeholder:u,resetWorkflow:d,onRestart:f,onClone:p,onShowDetails:m,allowWorkflowControl:h=!0,uploadedFiles:g,onRemoveFile:_,acceptedFileTypes:v,maxFiles:y,renderDocumentSearch:b,selectedDocuments:x,onRemoveDocument:S,hideObjectLinking:C,hideHeader:w,headerVariant:T=`full`,hideMessageInput:E,failedAction:D,hidePlanPanel:O,hideWorkstreamTabs:k,showRightPanel:A=!0,hideFileUpload:j,showArtifacts:M=!1,hideDocumentPanel:N,hiddenMessageTypes:P,getAttachedDocs:F,onAttachmentsSent:I,isUploading:L=!1,getMessageContext:R,className:z,inputContainerClassName:ie,inputClassName:ae,fusionData:oe,fileUploadRef:se,onProcessingFilesChange:ce,processingFiles:le,onPlansChange:ue,onWorkstreamStatusChange:de,viewMode:fe,onViewModeChange:pe,onShowInputChange:me,stopRef:V,onStoppingChange:he,messageItemClassNames:ge,messageStyleOverrides:_e,toolCallGroupClassNames:ve,hideToolCallsInViewMode:ye,streamingMessageClassNames:be,batchProgressPanelClassNames:xe,workingIndicatorClassName:Se,messageListClassName:Ce,StoreLinkComponent:we,CollectionLinkComponent:Te,prependFriendlyMessage:Ee,initialRequestData:De,initialRequestSchema:Oe,initialRequestTitle:ke,initialRequestTemplate:Ae,payloadContent:je,conversationContent:Me,conversationTab:Ne=!1,pendingStartMessage:Pe,pendingStartTimestamp:Fe,initialToolApprovalMode:Ie,enablePlayback:Le,showPlaybackToggle:Re=!0}){let{t:ze}=X(),{client:Be}=Z(),Ve=He(),{messages:Ue,streamingMessages:We,isCompleted:Ge,initialHistoryStatus:Ke,debugChunkFlash:qe,addOptimisticMessage:U,updateOptimisticMessageStatus:W,reconnect:Je,agentRunStatus:Ye,workflowRunId:Xe,serverFileUpdates:Ze}=ig(Be,r),{plans:Qe,activePlanIndex:$e,setActivePlanIndex:et,workstreamStatusMap:tt,showInput:nt,showSlidingPanel:rt,setShowSlidingPanel:it}=qh(Ue,a,c),{openDocuments:at,activeDocumentId:ot,isDocPanelOpen:st,docRefreshKey:ct,closeDocPanel:lt,closeDocument:ut,selectDocument:dt,openDocInPanel:ft,updateDocumentTitle:pt}=cg(Ue),{processingFiles:mt,hasProcessingFiles:gt,handleFileUpload:_t,removeProcessingFile:vt,clearProcessingFiles:yt}=fg(Be,r,Ze,Ve),bt=a&&!j,xt=G(e=>{vt(e)},[vt]),St=J(null),Ct=J(null),wt=J(null),[Tt,Et]=Y(!1),[Dt,Ot]=Y(!1),[kt,At]=Y(`sliding`),jt=fe??kt,Mt=G(e=>{pe?pe(e):At(e)},[pe]),[Nt,Pt]=Y(!1),[Ft,It]=Y(!1),[Lt,Rt]=Y(`all`),[zt,Bt]=Y(`live`),[Vt,Ht]=Y(!1),[Ut,Wt]=Y(0),[Gt,Kt]=Y([]),[qt,Jt]=Y([]),[Yt,Xt]=Y(!1),Zt=q(()=>Ie===void 0&&a?void 0:kr(Ie,a),[Ie,a]),[Qt,$t]=Y(Zt),en=J(!1),tn=J(0),nn=J(!1),rn=J(0),an=J(null);K(()=>{$t(Zt)},[Zt]);let on=J(Tt);on.current=Tt;let sn=J(gt);sn.current=gt;let cn=J(mt);cn.current=mt;let ln=q(()=>{let e=Ue.filter(e=>(e.workstream_id||`main`)===`main`);return e[e.length-1]},[Ue]),un=q(()=>ln?.type===Q.TERMINATED?`TERMINATED`:ln?.type===Q.COMPLETE&&(!Ye||Ye===`RUNNING`)?`COMPLETED`:Ye,[ln,Ye]),dn=q(()=>{let e=un?.toUpperCase();return e===`COMPLETED`||e===`FAILED`||e===`CANCELED`||e===`CANCELLED`||e===`TERMINATED`||e===`TIMED_OUT`},[un]),fn=q(()=>dn&&un?.toUpperCase()!==`FAILED`&&!!f,[dn,un,f]),pn=!E||fn,mn=q(()=>un?.toUpperCase()===`FAILED`||Ye?.toUpperCase()===`FAILED`,[un,Ye]),hn=J(dn);hn.current=dn;let gn=J(fn);gn.current=fn;let _n=q(()=>{let e=Qe[$e]||{plan:{plan:[]},timestamp:0},t=tt.get(e.timestamp)||new Map;return{plan:e.plan,workstreamStatus:t}},[Qe,$e,tt]),vn=q(()=>yy(Ue),[Ue]),yn=q(()=>{let e=[...vn];for(let t of qt)Sy(e,xy(t));for(let t of Gt)Sy(e,by(t));return e.map((e,t)=>({workstream:e,index:t})).sort((e,t)=>Number(!dy(e.workstream.status))-Number(!dy(t.workstream.status))||e.index-t.index).map(({workstream:e})=>e)},[vn,Gt,qt]),bn=q(()=>yn.filter(e=>dy(e.status)),[yn]),xn=q(()=>bn.filter(e=>e.status===`running`).length,[bn]),Sn=q(()=>{if(Lt===`all`)return;let e=yn.find(e=>e.workstream_id===Lt||e.launch_id===Lt);return e?el(e.workstream_id,e.interaction):el(Lt)},[Lt,yn]),Cn=q(()=>{if(u)return u;if(Sn)return ze(`agent.messageMainAgentWhileViewingWorkstream`,{workstream:Sn})},[Sn,u,ze]),wn=Re&&Le===void 0&&ka(),Tn=Le??(Aa()||Vt),En=q(()=>xl(P?.length?Ue.filter(e=>!P.includes(e.type)):Ue,Lt),[Lt,P,Ue]),Dn=q(()=>Da(En,zt,Tn),[Tn,zt,En]),On=Dn.cursor,kn=Dn.isLive,An=Tn&&!kn&&Dn.cursorIndex===En.length-1,jn=Dn.displayedMessages,Mn=kn?We:ly,Nn=q(()=>yy(jn),[jn]),Pn=q(()=>Nn.filter(e=>dy(e.status)),[Nn]),Fn=q(()=>Ge||!hl(Ue),[Ge,Ue]),In=kn||An?Fn:!1,Ln=q(()=>au(jn),[jn]),Rn=!!Ln&&!mn,zn=Tn&&!kn,Bn=pn&&!zn,Vn=q(()=>my(Ue),[Ue]),Hn=h&&!dn&&kn&&!!Vn;K(()=>{fl(`conversation render state`,{agentRunId:r,messageCount:Ue.length,playbackMessageCount:En.length,displayedMessageCount:jn.length,streamingCount:We.size,displayedStreamingCount:Mn.size,initialHistoryStatus:Ke,isCompleted:Ge,effectiveIsCompleted:Fn,displayedIsCompleted:In,agentRunStatus:Ye,effectiveWorkflowStatus:un,isWorkflowTerminal:dn,playbackCursor:On,isPlaybackEnabled:Tn,isPlaybackLive:kn,isPlaybackAtLatest:An,activeWorkstream:Lt,showInitialRequest:Ke===`empty`&&Ue.length===0,pendingStartVisible:Ue.length===0&&!Fn&&!!Pe})},[Lt,r,Ye,On,In,jn.length,Mn.size,Fn,un,Ke,Ge,An,Tn,kn,dn,Ue.length,Pe,En.length,We.size]);let Un=G(()=>{Ht(e=>!e)},[]),Wn=G(e=>{let t=wa(On,En.length),n=wa(e,En.length);Tn&&(n>t||e===`live`&&On!==`live`)&&(nn.current=!0,Wt(e=>e+1)),Bt(e)},[On,Tn,En.length]);K(()=>{if(!Tn){zt!==`live`&&Bt(`live`);return}On!==zt&&Bt(On)},[On,Tn,zt]),K(()=>{if(!Tn||!nn.current)return;nn.current=!1;let e=window.requestAnimationFrame(()=>{St.current?.scrollIntoView({behavior:`smooth`,block:`end`})});return()=>window.cancelAnimationFrame(e)},[Tn,Ut]);let Gn=G(()=>{it(e=>(e||sessionStorage.setItem(`plan-panel-shown`,`true`),!e))},[it]),Kn=G(e=>{et(e)},[et]),[qn,Jn]=Y(Me||Ne?`conversation`:`plan`),[Yn,Xn]=Y(400),[Qn,$n]=Y(!1),er=A&&(rt||st||!k&&yn.length>0||!!Me||Ne);K(()=>{!er&&Qn&&$n(!1)},[er,Qn]),K(()=>{if(!Qn)return;let e=e=>{let t=wt.current;if(!t)return;let n=t.getBoundingClientRect(),r=Math.max(300,n.width-420),i=n.right-e.clientX;Xn(Math.min(Math.max(i,300),r))},t=()=>{$n(!1)};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[Qn]);let tr=G(()=>{it(!1),lt()},[it,lt]),nr=G(({href:e,documentId:n,children:r})=>t(`a`,{href:e,className:`text-info underline cursor-pointer hover:text-info/80`,onClick:e=>{e.preventDefault(),e.stopPropagation(),ft(n),Jn(`documents`)},children:r}),[ft]),rr=we??nr;K(()=>(se&&(se.current=bt?_t:null),()=>{se&&(se.current=null)}),[se,_t,bt]),K(()=>{ce?.(mt)},[mt,ce]),K(()=>{ue?.(Qe,$e)},[Qe,$e,ue]),K(()=>{de?.(tt)},[tt,de]),K(()=>{en.current=!1,Xt(!1),Kt([]),Jt([])},[r]),K(()=>{let e=Ke!==`loading`&&!Fn&&!dn&&!Yt;if(fl(`active workstreams poll state`,{agentRunId:r,shouldPoll:e,initialHistoryStatus:Ke,effectiveIsCompleted:Fn,isWorkflowTerminal:dn,isWorkstreamQueryUnavailable:Yt}),!e){Kt(e=>e.length===0?e:[]);return}let t=!1,n=!1,i=async()=>{if(n){fl(`active workstreams fetch skipped while previous request is pending`,{agentRunId:r});return}n=!0;try{fl(`active workstreams fetch start`,{agentRunId:r});let e=await Be.agents.getActiveWorkstreams(r);if(t)return;if(fl(`active workstreams fetch success`,{agentRunId:r,runningCount:e.running?.length??0,completedCount:e.completed?.length??0,unavailable:e.unavailable===!0}),Kt(e.running??[]),Jt(e.completed??[]),e.unavailable){Xt(!0);return}en.current=!1}catch(e){if(t)return;Kt(e=>e.length===0?e:[]),Xt(!0),fl(`active workstreams fetch failed`,{agentRunId:r,error:e instanceof Error?e.message:String(e)}),en.current||=(console.warn(`Failed to fetch active workstreams:`,e),!0)}finally{n=!1}};i();let a=window.setInterval(i,1e4);return()=>{t=!0,window.clearInterval(a)}},[Be.agents,r,Fn,Ke,dn,Yt]),K(()=>{if(Ue.length!==0){if(fn){me?.(!0);return}if(!nt){me?.(!1);return}if(un&&un!==`RUNNING`){me?.(!1);return}un!==null&&me?.(!0)}},[nt,un,Ue.length,me,fn]);let ir=G(async()=>{let e=an.current;e&&await e},[]),ar=G((e,t)=>{let n=e.trim();if(!n||on.current||hn.current&&!gn.current)return;if(sn.current){Ve({status:`warning`,title:ze(`agent.filesProcessing`),description:ze(`agent.waitForFilesProcessing`),duration:3e3});return}Et(!0);let i=F?.()||[],a=R?.()||{},o=n;i.length>0&&!/store:\S+/.test(n)&&(o=[n,``,`Attachments:`,...i.map(e=>`[${e.name}](/store/objects/${e.id})`)].join(`
|
|
442
|
-
`));let s=Array.from(cn.current.values()).filter(e=>e.status===
|
|
443
|
-
`));let c=`msg-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,l={timestamp:Date.now(),workflow_run_id:r,type:Q.QUESTION,message:o,workstream_id:`main`,details:{_optimistic:!0,_messageId:c,_deliveryStatus:`sending`}};U(l);let u={...i.length>0?{attached_docs:i.map(e=>e.id)}:{},...a,...t,id:c,_messageId:c},d=()=>Be.agents.sendSignal(r,`UserInput`,{message:o,client_message_id:c,metadata:u}),f=()=>{W(c,`received`),I?.(),yt()};(async()=>{await ir(),hn.current&&(await Be.agents.restart(r),Je()),await d(),f()})().catch(e=>{W(c,`failed`),Ve({status:`error`,title:ze(`agent.failedToSend`),description:e instanceof Error?e.message:ze(`agent.unknownError`),duration:3e3})}).finally(()=>{Et(!1)})},[r,Be,Ve,F,R,I,yt,Je,U,W,ze,ir]),or=G(async e=>{try{await Be.agents.sendSignal(r,`McpConfigChanged`,{})}catch(e){console.error(`Failed to signal MCP config change`,e)}ar(ze(`agent.mcpConnectedMessage`,{name:e.name}))},[Be,r,ar,ze]),[sr,cr]=Y(void 0);K(()=>{let e=!1,t=rn.current;return Be.agents.retrieve(r).then(n=>{e||(cr(n.disabled_mcp_collections),rn.current===t&&(n.tool_approval_mode!==void 0||n.interactive!==void 0)&&$t(kr(n.tool_approval_mode,n.interactive)))}).catch(()=>{}),()=>{e=!0}},[Be,r]);let lr=G(e=>{let t=e.length>0?e:void 0;cr(t),Be.agents.sendSignal(r,`McpConfigChanged`,{disabled_mcp_collections:e}).catch(e=>console.error(`Failed to signal MCP config change`,e))},[Be,r]),ur=G(()=>{Be.agents.sendSignal(r,`McpConfigChanged`,{}).catch(e=>console.error(`Failed to signal MCP config change`,e))},[Be,r]),dr=G(e=>{let t=kr(e,a),n=Qt;rn.current+=1,$t(t);let i=Be.agents.sendSignal(r,`ToolApprovalModeChanged`,{mode:t}).then(()=>void 0).catch(e=>{$t(e=>e===t?n:e),Ve({status:`error`,title:ze(`agent.approvalMode.changeFailed`),description:e instanceof Error?e.message:ze(`agent.unknownError`),duration:3e3})});an.current=i,i.finally(()=>{an.current===i&&(an.current=null)})},[r,Be,a,ze,Ve,Qt]),fr=G(e=>{bt&&(e.preventDefault(),e.stopPropagation(),tn.current++,e.dataTransfer?.types?.includes(`Files`)&&It(!0))},[bt]),pr=G(e=>{bt&&(e.preventDefault(),e.stopPropagation())},[bt]),mr=G(e=>{bt&&(e.preventDefault(),e.stopPropagation(),tn.current--,tn.current===0&&It(!1))},[bt]),gr=G(e=>{if(bt&&(e.preventDefault(),e.stopPropagation(),tn.current=0,It(!1),e.dataTransfer?.files&&e.dataTransfer.files.length>0)){let t=Array.from(e.dataTransfer.files);_t(t)}},[_t,bt]),_r=G(async()=>{if(Nt)return;let e=`stop-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,t={timestamp:Date.now(),workflow_run_id:r,type:Q.IDLE,message:`Stopped. Waiting for your command...`,workstream_id:`main`,details:{_optimistic:!0,_messageId:e,_deliveryStatus:`sending`,display_role:`user_stopped`,status_reason:`user_stopped`}};U(t),Pt(!0);try{await Be.agents.sendSignal(r,`Stop`,{message:`User requested stop`,client_message_id:e,metadata:{id:e,_messageId:e}}),W(e,`received`)}catch(t){Ve({status:`error`,title:ze(`agent.failedToInterrupt`),description:t instanceof Error?t.message:ze(`agent.unknownError`),duration:3e3}),W(e,`failed`)}finally{Pt(!1)}},[Nt,r,U,Be.agents,Ve,ze,W]),vr=G(async()=>{if(!(Dt||Fn||!kn)){Ot(!0);try{await Be.agents.sendSignal(r,`TriggerCheckpoint`,{reason:`manual user request`})}catch(e){Ve({status:`error`,title:ze(`agent.failedToCompactContext`),description:e instanceof Error?e.message:ze(`agent.unknownError`),duration:3e3})}finally{Ot(!1)}}},[r,Be.agents,Fn,Dt,kn,ze,Ve]);K(()=>(V&&(V.current=h&&!Fn?_r:null),()=>{V&&(V.current=null)}),[V,Fn,_r,h]),K(()=>{he?.(Nt)},[Nt,he]);let yr=i||ze(`agent.agentConversation`),br=async()=>{try{let e=await Sl(Be,r);e&&window.open(e,`_blank`)}catch(e){console.error(`Failed to download conversation`,e),Ve({status:`error`,title:ze(`agent.failedToDownload`),duration:3e3})}},xr=G(()=>{let e=new Date().toISOString(),t=We.size>0?[{cursor:`live`,streamingMessages:Array.from(We,([e,t])=>({id:e,...t}))}]:void 0,n={metadata:{title:yr,agent_run_id:r,exported_at:e,message_count:Ue.length},messages:Ue,...t?{streamingFrames:t}:{}};Ay(`${ky(yr)||`agent-chat`}-${ky(r)}.json`,n),Ve({status:`success`,title:ze(`agent.rewind.fixtureExported`),duration:2e3})},[yr,r,Ue,We,ze,Ve]),[Sr,Cr]=Y(!1),wr=()=>{if(!Ct.current){Ve({status:`error`,title:ze(`agent.pdfExportFailed`),description:ze(`agent.noConversationContent`),duration:3e3});return}Cr(!0)},Tr=()=>{if(!Ct.current){Ve({status:`error`,title:ze(`agent.pdfExportFailed`),description:ze(`agent.noConversationContent`),duration:3e3});return}let e=`${yr} - ${r}`;if(!Dy(Ct.current,e)){Ve({status:`error`,title:ze(`agent.pdfExportFailed`),description:ze(`agent.unableToOpenPrint`),duration:4e3});return}Ve({status:`success`,title:ze(`agent.pdfExportReady`),description:ze(`agent.printDialogDescription`),duration:4e3}),Cr(!1)},Er=q(()=>Ue.filter(e=>e.type===Q.COMPLETE?!0:e.type===Q.THOUGHT?e.details?.tool_status===`completed`:!1).length,[Ue]),Dr=q(()=>_n.plan.plan?.reduce((e,t)=>(t.id&&t.goal&&e.set(t.id.toString(),t.goal),e),new Map),[_n.plan]),Or=e=>t(yg,{title:yr,variant:e,isCompleted:Fn,isTerminal:dn,onClose:s,isModal:c,agentRunId:r,workflowRunId:Xe||``,viewMode:jt,onViewModeChange:Mt,showPlanPanel:A&&rt,hasPlan:A&&Qe.length>0,showPlanButton:A&&!Ne,onTogglePlanPanel:Gn,showPlaybackButton:wn,isPlaybackEnabled:Tn,onTogglePlayback:Un,onDownload:br,onExportFixture:xr,resetWorkflow:d,onClone:p,onShowDetails:m,allowWorkflowControl:h,onExportPdf:wr,isReceivingChunks:qe}),Ar=n(`div`,{ref:Ct,"data-agent-playback-enabled":Tn||void 0,"data-agent-playback-cursor":Tn?On:void 0,"data-agent-live-message-count":Ue.length,"data-agent-rendered-message-count":jn.length,className:H(`flex flex-col min-h-0 min-w-0 border-0`,Ne?`flex-1 h-full`:er?`w-full flex-1 min-h-[50vh]`:l?`flex-1 w-full`:`flex-1 mx-auto ${c?``:`max-w-4xl`}`),children:[!w&&T===`compact`&&t(`div`,{className:`flex flex-shrink-0 justify-end border-b border-border/60 px-2 py-1 lg:hidden`,children:Or(`compact`)}),!w&&T!==`compact`&&t(`div`,{className:`flex-shrink-0`,children:Or(T)}),Tn&&t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(Na,{cursor:On,messages:En,onChangeCursor:Wn})}),Ue.length===0&&!Fn&&Pe&&Fe?t(Ey,{message:Pe,startedAt:Fe}):t(rm,{messages:jn,workstreamSourceMessages:Ue,bottomRef:St,isCompleted:In,plan:_n.plan,workstreamStatus:_n.workstreamStatus,showPlanPanel:A&&rt,onTogglePlanPanel:Gn,plans:Qe,activePlanIndex:$e,onChangePlan:Kn,taskLabels:Dr,streamingMessages:Mn,onSendMessage:kn?ar:void 0,messageItemClassNames:ge,messageStyleOverrides:_e,toolCallGroupClassNames:ve,hideToolCallsInViewMode:ye,streamingMessageClassNames:be,batchProgressPanelClassNames:xe,artifactRunId:r,viewMode:jt,hideWorkstreamTabs:k,workingIndicatorClassName:Se,messageListClassName:Ce,StoreLinkComponent:rr,CollectionLinkComponent:Te,prependFriendlyMessage:Ee,initialRequestData:De,initialRequestSchema:Oe,initialRequestTitle:ke,initialRequestTemplate:Ae,showInitialRequest:Ke===`empty`&&Ue.length===0,hiddenMessageTypes:P,disableAutoScroll:!kn,renderRequestInputControls:!Rn,activeWorkstream:Lt,onActiveWorkstreamChange:Rt}),Rn?t(su,{message:Ln,onSendMessage:kn?ar:void 0,onMcpConnected:kn?or:void 0,disabled:L||!kn,isLoading:Tt||L}):zn&&Pn.length>0?t(`div`,{className:`flex-shrink-0 pb-safe-area`,children:t(pg,{activeWorkstreams:Pn})}):Bn&&t(`div`,{className:`flex-shrink-0 pb-safe-area`,children:mn?D??t(ee,{status:`error`,icon:null,className:`m-2`,children:`This Workflow is FAILED`}):un&&un!==`RUNNING`&&!fn?jt===`sliding`&&un===`COMPLETED`?t(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-3 text-sm text-muted`,children:n(`div`,{className:`flex items-center gap-2 border-t border-success/25 pt-3 text-success`,children:[t(ht,{className:`size-4`}),t(`span`,{className:`font-medium`,children:`Workflow completed`})]})}):n(ee,{status:un===`COMPLETED`?`success`:`done`,icon:null,className:`m-2`,children:[`This Workflow is `,un]}):(nt||fn)&&t(ty,{onSend:ar,onStop:h?_r:void 0,approvalModeSlot:a&&Qt?t(Qi,{mode:Qt,onChange:dr,disabled:!kn||dn||!h}):void 0,mcpSlot:t(bm,{disabledCollections:sr,onChange:lr,onConnectionChange:ur}),disabled:L||!kn,isSending:Tt||L,isStopping:Nt,isStreaming:!Fn,isCompleted:Fn,contextWindowUsage:Hn?Vn:void 0,onCompactContext:Hn?vr:void 0,isCompactingContext:Dt,activeTaskCount:xn,activeWorkstreams:bn,placeholder:Cn,onFilesSelected:bt?_t:void 0,uploadedFiles:g,onRemoveFile:_,onRemoveProcessingFile:xt,acceptedFileTypes:v,maxFiles:y,processingFiles:mt,artifactRunId:r,hasProcessingFiles:gt,renderDocumentSearch:b,selectedDocuments:x,onRemoveDocument:S,hideObjectLinking:C,hideFileUpload:!bt,disableDropZone:bt,className:ie,inputClassName:ae})})]}),jr=t(ea,{children:t(_u,{children:n(`div`,{ref:wt,className:H(`flex flex-col lg:flex-row gap-2 w-full h-full relative overflow-hidden`,bt&&Ft&&`ring-2 ring-blue-400 ring-inset`,z),onDragEnter:bt?fr:void 0,onDragOver:bt?pr:void 0,onDragLeave:bt?mr:void 0,onDrop:bt?gr:void 0,children:[bt&&Ft&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-blue-100/80 dark:bg-blue-900/40 z-50 pointer-events-none rounded-lg`,children:n(`div`,{className:`text-blue-600 dark:text-blue-400 font-medium flex items-center gap-2 text-lg`,children:[t(Zn,{className:`size-6`}),`Drop files to upload`]})}),!Ne&&Ar,!Ne&&T===`compact`&&!w&&t(`div`,{className:`hidden h-full w-12 shrink-0 items-start justify-center px-1 pt-2 lg:flex`,children:Or(`compact`)}),er&&n(e,{children:[!Ne&&t(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize right panel`,"aria-valuenow":Math.round(Yn),"aria-valuemin":300,"aria-valuetext":`${Math.round(Yn)} pixels`,tabIndex:0,className:`hidden lg:block lg:w-1 lg:shrink-0 cursor-col-resize bg-border/70 hover:bg-border transition-colors`,onMouseDown:()=>$n(!0),onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.shiftKey?32:16,n=e.key===`ArrowLeft`?t:-t,r=wt.current,i=r?Math.max(300,r.getBoundingClientRect().width-420):900;Xn(e=>Math.min(Math.max(e+n,300),i))}}),t(`div`,{className:Ne?`w-full h-full overflow-auto`:`w-full lg:w-[var(--agent-right-panel-width)] lg:shrink-0 min-h-[50vh] lg:h-full border-t lg:border-t-0`,style:Ne?void 0:{"--agent-right-panel-width":`${Yn}px`},children:t(Gh,{plan:_n.plan,workstreamStatus:_n.workstreamStatus,plans:Qe,activePlanIndex:$e,onChangePlan:Kn,showPlan:!O&&rt,activeWorkstreams:yn,hideWorkstreams:k,openDocuments:at,activeDocumentId:ot,onSelectDocument:dt,onCloseDocument:ut,onUpdateDocumentTitle:pt,docRefreshKey:ct,runId:r,processingFiles:le??mt,showArtifacts:M,artifactRefreshKey:Er,messages:Ue,payloadContent:je,conversationContent:Ne?Ar:Me,onClose:tr,defaultTab:qn,activeTab:qn,onTabChange:Jn})})]}),n(B,{isOpen:Sr,onClose:()=>Cr(!1),children:[t(re,{children:`Export conversation as PDF`}),n(te,{children:[t(`p`,{className:`mb-2`,children:`This will open your browser's print dialog with the current conversation.`}),t(`p`,{className:`text-sm text-muted`,children:`To save a PDF, choose "Save as PDF" or a similar option in the print dialog.`})]}),n(ne,{align:`right`,children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>Cr(!1),children:`Cancel`}),t(o,{size:`sm`,onClick:Tr,children:`Open print dialog`})]})]})]})})});return oe?t(ai,{data:oe,sendMessage:ar,ChartComponent:va,artifactRunId:r,children:jr}):jr}function Fy({messages:e}){return t(`div`,{className:`flex flex-col overflow-y-auto space-y-6 py-4`,children:W.useMemo(()=>[...e].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),[e]).map(e=>t(id,{message:e,showPulsatingCircle:!1},`${e.workstream_id??`main`}-${e.timestamp}-${e.type}`))})}function Iy({messages:e,bottomRef:n,className:r,messagesClassName:i,emptyClassName:a}){let o=W.useRef(null);K(()=>{n.current&&n.current.scrollIntoView({behavior:`smooth`})},[e,n]);let s=W.useMemo(()=>[...e].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),[e]);return t(`div`,{ref:o,className:`flex-1 min-h-0 h-full overflow-y-auto py-4 px-4 sm:px-6 lg:px-8 bg-white flex flex-col ${r||``}`,"data-testid":`messages-container`,children:s.length===0?t(`div`,{className:`flex items-center justify-center h-full text-center py-8 ${a||``}`,children:t(`div`,{className:`flex items-center px-4 py-3 text-gray-500`,children:`Waiting for agent response...`})}):t(`div`,{className:`flex-1 flex flex-col justify-start h-full min-h-0 ${i||``}`,children:t(Fy,{messages:s,isCompleted:!1})})})}function Ly({children:e,fallback:n}){return Ry?t(Ry,{fallback:n,children:e}):t(Ii,{FallbackComponent:n,children:e})}let Ry=null;function zy(e){Ry=e}function By({children:e}){return t(Ly,{fallback:Vy,children:e})}function Vy({error:e}){let{t:r}=X(),i=e instanceof Error?e.message:void 0;return n(ee,{status:`error`,title:r(`errors.somethingWentWrong`),children:[n(`div`,{className:`mb-4`,children:[r(`errors.teamNotifiedLine1`),` `,r(`errors.teamNotifiedLine2`),`\xA0`,t(`a`,{className:`text-info`,href:`mailto:support@vertesiahq.com`,children:`support@vertesiahq.com`}),`.`]}),i&&t(`code`,{className:`w-full mt-4 text-sm text-muted break-words`,children:i})]})}function Hy({children:e}){return t(Ly,{fallback:Uy,children:e})}function Uy({error:e}){let r=e instanceof Error?e.message:void 0;return t(`tr`,{children:n(`td`,{colSpan:100,children:[t(`span`,{className:`text-xs`,children:` Cannot display row`}),t(`br`,{}),t(`span`,{className:`bg-gray-400`,children:r})]})})}function Wy({children:e}){return t(Ly,{fallback:Gy,children:e})}function Gy({error:e}){let r=e instanceof Error?e.message:void 0;return console.log(`WidgetError`,e),n(`div`,{className:`text-sm`,children:[`Sorry, this area cannot be loaded or rendered.`,r&&t(`pre`,{children:r})]})}const Ky=/^[a-f0-9]{24}$|^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$|^(?=.*\d)(?=.*[a-zA-Z])[a-zA-Z0-9_-]{8,}$/i;function qy(e){return Ky.test(e)}function Jy({className:e,children:r,title:i,description:o,actions:s,breadcrumbs:c,useDynamicBreadcrumbs:l=!0}){let u=li();function d(e){return e.replace(/[-_]/g,` `).split(` `).map(e=>Br(e)).join(` `)}let f=e=>{if(e?.title)return e.title;let t=e?.href||``;if(!t)return`Page`;let n=t.split(`#`)[0].split(`?`)[0].split(`/`).filter(e=>e.length>0);return n.length>=1?d(n[n.length-1]):`Page`},p=(()=>{let e=[];if(l&&typeof window<`u`){let t=window.history.state?.historyChain;if(Array.isArray(t))t.forEach((n,r)=>{let i=t.length-r;e.push({label:f(n),href:n.href,onClick:()=>u(n.href,{stepsBack:i})})});else{let t=window.location.pathname.split(`/`).filter(e=>e.length>0);for(let n=0;n<t.length;n++)if(qy(t[n])){let r=`/${t.slice(0,n).join(`/`)}`;e.push({label:d(t[n-1]||r),href:r,onClick:()=>u(r,{isBasePathNested:!1})})}}}return c&&c.length>0&&c.forEach(t=>{let n=t.props?.children||t,r=t.props?.href;e.push(r?{href:r,label:n,onClick:()=>u(r,{replace:t.props.clearBreadcrumbs})}:{label:n})}),e})();return n(`div`,{className:We(`pb-0 ps-4 pe-2 py-2 flex flex-col`,e),children:[n(`div`,{className:`flex items-start gap-4`,children:[n(`div`,{className:`w-full flex place-content-between h-auto min-h-8 flex-col items-start justify-center`,children:[n(`nav`,{className:`flex-1 flex justify-start text-sm`,children:[p.length>0&&t(a,{path:p,separator:t(St,{className:`size-3.5 cn-rtl-flip`}),maxItems:4}),o&&t(Me,{description:o,children:t(on,{className:`size-4 text-muted ms-4`})})]}),i&&t(`div`,{className:`flex gap-2 items-center`,children:t(`h1`,{className:`text-xl font-semibold break-all`,children:i})})]}),t(`div`,{className:`flex gap-x-2 shrink-0 items-center`,children:s})]}),r&&t(`div`,{className:`w-full flex items-center`,children:r})]})}function Yy(){let{t:e}=X();return n(`div`,{className:`text-center pt-32`,children:[t(`h1`,{className:`text-3xl font-bold text-red-500`,children:`404`}),t(`p`,{className:`text-2xl`,children:e(`layout.pageNotFound`)})]})}const Xy=`magic-pdf`;var Zy;(function(e){e.original=`original`,e.instrumented=`instrumented`})(Zy||={});var Qy=class{client;objectId;totalPages;cache=new Map;pending=new Map;constructor(e,t,n){this.client=e,this.objectId=t,this.totalPages=n}getCacheKey(e,t){return`${t}-${e}`}async getPageImageUrl(e,t){let n=this.getCacheKey(e,t),r=this.cache.get(n);if(r)return r;let i=this.pending.get(n);if(i)return i;let a=this.fetchImageUrl(e,t);this.pending.set(n,a);try{let e=await a;return this.cache.set(n,e),e}finally{this.pending.delete(n)}}async fetchImageUrl(e,t){let n=this.getImagePath(e,t);return(await this.client.files.getDownloadUrl(n)).url}getImagePath(e,t){let n=`${Xy}/${this.objectId}/pages`;switch(t){case Zy.original:return`${n}/page-${e}.original.jpg`;case Zy.instrumented:return`${n}/page-${e}.instrumented.jpg`}}},$y=class{client;objectId;totalPages;cache=new Map;pending=new Map;constructor(e,t,n){this.client=e,this.objectId=t,this.totalPages=n}async getPageLayout(e){let t=this.cache.get(e);if(t!==void 0)return t;let n=this.pending.get(e);if(n)return n;let r=this.fetchPageLayout(e);this.pending.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pending.delete(e)}}async fetchPageLayout(e){let t=`${Xy}/${this.objectId}/pages/page-${e}.layout.json`,n=await this.client.files.getDownloadUrl(t),r=await fetch(n.url,{method:`GET`});if(!r.ok)throw Error(`Failed to fetch json layout: ${r.statusText}`);return r.text()}},eb=class{totalPages;pages=[];constructor(e){this.totalPages=e}initFromContent(e){this.pages=tb(e,this.totalPages)}async loadUrls(e,t){}async getPageMarkdown(e){let t=e-1;return t<0||t>=this.pages.length?``:this.pages[t]}};function tb(e,t){let n=Array(t).fill(``),r=/<!--\s*\{\s*"page"\s*:\s*(\d+)\s*\}\s*-->/g,i=[];for(let t of e.matchAll(r))i.push({page:parseInt(t[1],10),index:t.index+t[0].length});for(let r=0;r<i.length;r++){let a=i[r],o=a.page-1;if(o<0||o>=t)continue;let s=a.index,c=e.slice(s).match(/<!--\s*\{\s*"page"\s*:\s*\d+\s*\}\s*-->/),l=c&&c.index!==void 0?s+c.index:e.length,u=e.slice(s,l).trim();u=u.replace(/\n---\s*$/,``).trim(),n[o]=u}return n}const nb=Ye(void 0);function rb({children:e,object:n}){let{client:r}=Z(),i=n.metadata.page_count||10,a=n.metadata?.content_processor?.type===`markdown`,[o,s]=Y(()=>{let e=new eb(i);a&&n.text&&e.initFromContent(n.text);let t=n.text?sb(n.text):``;return{count:i,layoutProvider:new $y(r,n.id,i),markdownProvider:e,imageProvider:new Qy(r,n.id,i),xml:t,xmlPages:n.text?ob(t):[],pdfUrl:``,pdfUrlLoading:!0}});return K(()=>{if(a){let e=n.metadata?.renditions?.find(e=>e.name===yr),t=n.content?.type===`application/pdf`,i=e?.content?.source||(t?n.content?.source:void 0);i?r.store.objects.getDownloadUrl(i,void 0,`inline`).then(e=>{s(t=>({...t,pdfUrl:e.url,pdfUrlLoading:!1}))}).catch(e=>{console.warn(`Failed to get PDF URL:`,e),s(e=>({...e,pdfUrlLoading:!1}))}):s(e=>({...e,pdfUrlLoading:!1}))}else s(e=>({...e,pdfUrlLoading:!1}))},[r,a,n.metadata,n.content?.type,n.content?.source]),t(nb.Provider,{value:o,children:e})}function ib(e,t,n){return e.files.getDownloadUrl(`${Xy}/${t}/${n}`).then(e=>e.url)}function ab(){let e=W.useContext(nb);if(!e)throw Error(`useMagicPdfContext must be used within a MagicPdfProvider`);return e}function ob(e){let t=new DOMParser().parseFromString(sb(e),`text/xml`).getElementsByTagName(`page`),n=new XMLSerializer;return Array.from(t).map(e=>n.serializeToString(e))}function sb(e){return e.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,``).replace(/<\?xml.*?\?>/g,``)}const cb=[50,75,100,125,150,200,300];function lb(e,t){let n=[e],r=1;for(;n.length<t;){let i=e+r,a=e-r;i<=t&&n.push(i),a>=1&&n.push(a),r++}return n}function ub({className:e,currentPage:r,onChange:i}){let{t:a}=X(),[s,c]=Y(Zy.instrumented),[l,u]=Y(1.2941176470588236),[d,f]=Y(new Map),[p,m]=Y(100),h=J(new Set),g=J(null),_=J(null),v=J(!1),{imageProvider:y,count:b}=ab(),x=G(()=>{let e=cb.findIndex(e=>e>=p);e===-1&&(e=cb.length-1);let t=Math.min(e+1,cb.length-1);m(cb[t])},[p]),S=G(()=>{let e=cb.findIndex(e=>e>=p);e===-1&&(e=cb.length-1);let t=Math.max(e-1,0);m(cb[t])},[p]),C=G(()=>{m(100)},[]);K(()=>{y.getPageImageUrl(1,s).then(e=>{let t=new window.Image;t.onload=()=>{t.width>0&&t.height>0&&u(t.height/t.width)},t.src=e}).catch(()=>{})},[y,s]);let w=J(s);K(()=>{let e=!1;w.current!==s&&(w.current=s,h.current=new Set,f(new Map));let t=lb(r,b),n=async t=>{if(!(e||h.current.has(t)))try{let n=await y.getPageImageUrl(t,s);e||(h.current.add(t),f(e=>new Map(e).set(t,n)))}catch{}};return t.forEach(e=>{n(e)}),()=>{e=!0}},[r,b,s,y]);let T=J(p);K(()=>{if(T.current!==p&&_.current){T.current=p,v.current=!0;let e=_.current.querySelector(`[data-page="${r}"]`);e?requestAnimationFrame(()=>{e.scrollIntoView({behavior:`instant`,block:`center`}),requestAnimationFrame(()=>{v.current=!1})}):v.current=!1}},[p,r]);let E=J(r);return K(()=>{if(E.current!==r&&_.current){E.current=r,v.current=!0;let e=_.current.querySelector(`[data-page="${r}"]`);e&&e.scrollIntoView({behavior:`instant`,block:`nearest`}),requestAnimationFrame(()=>{v.current=!1})}},[r]),K(()=>{let e=_.current;if(!e)return;let t=null,n=()=>{v.current||(t&&clearTimeout(t),t=setTimeout(()=>{let t=e.getBoundingClientRect(),n=t.top+t.height/2,a=r,o=1/0;for(let t=1;t<=b;t++){let r=e.querySelector(`[data-page="${t}"]`);if(r){let e=r.getBoundingClientRect(),i=e.top+e.height/2,s=Math.abs(i-n);s<o&&(o=s,a=t)}}a!==r&&(E.current=a,i(a))},50))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{t&&clearTimeout(t),e.removeEventListener(`scroll`,n)}},[b,r,i]),n(`div`,{ref:g,className:We(`flex flex-col items-stretch gap-y-2`,e),children:[n(`div`,{className:`relative flex items-center justify-center px-2 h-9`,children:[t(o,{variant:`ghost`,size:`xs`,onClick:()=>{r>1&&i(r-1)},alt:a(`pdf.previousPage`),children:t(Dt,{className:`size-4`})}),n(`div`,{className:`absolute start-2 flex items-center gap-x-1`,children:[t(db,{type:Zy.original,currentType:s,onClick:()=>c(Zy.original),icon:t(rn,{className:`size-4`}),tooltip:a(`pdf.originalImages`)}),t(db,{type:Zy.instrumented,currentType:s,onClick:()=>c(Zy.instrumented),icon:t(Rn,{className:`size-4`}),tooltip:a(`pdf.instrumentedImages`)}),t(`div`,{className:`w-px h-4 bg-border mx-1`}),t(fb,{zoom:p,onZoomIn:x,onZoomOut:S,onFitToView:C,canZoomIn:p<cb[cb.length-1],canZoomOut:p>cb[0]})]}),t(`div`,{className:`absolute end-2`,children:t(mb,{currentPage:r,totalPages:b,onChange:i})})]}),t(`div`,{ref:_,className:`flex flex-col items-center gap-2 flex-1 overflow-y-auto px-2`,children:Array.from({length:b},(e,n)=>t(pb,{currentPage:r,pageNumber:n+1,aspectRatio:l,zoom:p,url:d.get(n+1),onSelect:()=>i(n+1)},`page-thumb-${n}`))}),t(`div`,{className:`flex items-center justify-center h-9`,children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>{r<b&&i(r+1)},alt:a(`pdf.nextPage`),children:t(wt,{className:`size-4`})})})]})}function db({type:e,currentType:n,onClick:r,icon:i,tooltip:a}){let s=e===n;return t(Me,{description:a,placement:`bottom`,size:`xs`,children:t(o,{variant:`unstyled`,"aria-label":a,"aria-pressed":s,className:We(`p-1 rounded cursor-pointer transition-colors`,s?`text-primary bg-primary/10`:`text-muted-foreground hover:text-foreground hover:bg-muted`),onClick:r,children:i})})}function fb({zoom:e,onZoomIn:r,onZoomOut:i,onFitToView:a,canZoomIn:s,canZoomOut:c}){let{t:l}=X();return n(`div`,{className:`flex items-center gap-x-0.5`,children:[t(Me,{description:l(`pdf.zoomOut`),placement:`bottom`,size:`xs`,children:t(o,{variant:`unstyled`,"aria-label":l(`pdf.zoomOut`),className:We(`p-1 rounded cursor-pointer transition-colors`,c?`text-muted-foreground hover:text-foreground hover:bg-muted`:`text-muted-foreground/40 cursor-not-allowed`),onClick:i,disabled:!c,children:t(xn,{className:`size-4`})})}),n(`span`,{className:`text-xs text-muted-foreground min-w-[32px] text-center`,children:[e,`%`]}),t(Me,{description:l(`pdf.zoomIn`),placement:`bottom`,size:`xs`,children:t(o,{variant:`unstyled`,"aria-label":l(`pdf.zoomIn`),className:We(`p-1 rounded cursor-pointer transition-colors`,s?`text-muted-foreground hover:text-foreground hover:bg-muted`:`text-muted-foreground/40 cursor-not-allowed`),onClick:r,disabled:!s,children:t(An,{className:`size-4`})})}),t(Me,{description:l(`pdf.fitToWidth`),placement:`bottom`,size:`xs`,children:t(o,{variant:`unstyled`,"aria-label":l(`pdf.fitToWidth`),className:We(`p-1 rounded cursor-pointer transition-colors`,e===100?`text-muted-foreground/40`:`text-muted-foreground hover:text-foreground hover:bg-muted`),onClick:a,children:t(gn,{className:`size-4`})})})]})}function pb({pageNumber:e,currentPage:r,aspectRatio:i,zoom:a,url:s,onSelect:c}){let u=e===r;return n(`div`,{className:`p-2 hover:bg-muted rounded-md flex flex-col items-center`,"data-page":e,style:{width:`${a}%`},children:[t(o,{variant:`unstyled`,size:`none`,"aria-pressed":u,"aria-label":`Page ${e}`,className:We(`relative border-[2px] cursor-pointer overflow-hidden !flex items-center justify-center bg-muted/50 w-full`,u?`border-primary`:`border-border`),style:{aspectRatio:`1 / ${i}`},onClick:c,children:s?t(`img`,{src:s,alt:`Page ${e}`,className:`w-full`}):t(mn,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),t(l,{className:`text-sm text-muted-foreground pt-1 font-semibold`,children:e})]})}function mb({currentPage:e,totalPages:r,onChange:i}){let{t:a}=X(),o=J(null),[s,c]=Y(String(e));K(()=>{c(String(e))},[e]);let l=()=>{let t=parseInt(s,10);!Number.isNaN(t)&&t>=1&&t<=r?i(t):c(String(e))};return n(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[t(`span`,{children:a(`pdf.page`)}),t(`input`,{ref:o,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:t=>{t.key===`Enter`?(l(),o.current?.blur()):t.key===`Escape`&&(c(String(e)),o.current?.blur())},onBlur:()=>{l()},className:`w-8 h-5 text-center text-xs px-1 py-0 bg-background border border-border rounded focus:outline-none focus:border-primary`}),n(`span`,{children:[`/ `,r]})]})}function hb({object:e}){let{t:r}=X(),{client:i}=Z(),a=t=>{ib(i,e.id,t).then(e=>window.open(e,`_blank`))},s=e.metadata?.type===`document`&&e.metadata.content_processor?.type||`xml`,c=`p-2 cursor-pointer hover:bg-muted text-start text-sm`;return s===`markdown`?t(o,{variant:`ghost`,size:`xs`,onClick:()=>a(`document.md`),alt:r(`pdf.download`),children:t(Lt,{className:`size-4`})}):n(oe,{children:[t(ce,{children:t(o,{variant:`ghost`,size:`xs`,alt:r(`pdf.download`),children:t(Lt,{className:`size-4`})})}),t(se,{align:`start`,className:`p-0 w-auto`,children:n(`div`,{className:`min-w-[200px] flex flex-col divide-y divide-border`,children:[t(o,{variant:`unstyled`,className:c,onClick:()=>a(`annotated.pdf`),children:`annotated.pdf`}),t(o,{variant:`unstyled`,className:c,onClick:()=>a(`document.xml`),children:`document.xml`}),t(o,{variant:`unstyled`,className:c,onClick:()=>a(`analyzed-pages.json`),children:`analyzed-pages.json`})]})})]})}function gb({className:e}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(mn,{className:`w-6 h-6 animate-spin text-gray-400`})})}function _b({viewType:e,pageNumber:n}){switch(e){case`json`:return t(yb,{pageNumber:n});case`markdown`:return t(bb,{pageNumber:n});default:return t(vb,{pageNumber:n})}}function vb({pageNumber:e}){let{xmlPages:n}=ab();return t(`div`,{className:`px-4 py-2`,children:t(wi,{xml:n[e-1],collapsible:!0})})}function yb({pageNumber:e}){let[n,r]=Y(null),[i,a]=Y(!0),[o,s]=Y(null),{layoutProvider:c}=ab();return K(()=>{a(!0),s(null),c.getPageLayout(e).then(e=>{r(e?JSON.parse(e):null),a(!1)}).catch(e=>{console.error(e),s(e.message||`Failed to load layout`),a(!1)})},[e,c]),i?t(`div`,{className:`px-4 py-8`,children:t(gb,{})}):o?t(`div`,{className:`px-4 py-2 text-red-500 text-sm`,children:o}):n?t(gi,{className:`w-full`,data:n}):null}function bb({pageNumber:e}){let[r,i]=Y(null),[a,o]=Y(!0),[s,c]=Y(null),{markdownProvider:l}=ab();return K(()=>{o(!0),c(null),l.getPageMarkdown(e).then(e=>{i(e),o(!1)}).catch(e=>{console.error(e),c(e.message||`Failed to load markdown`),o(!1)})},[e,l]),a?n(`div`,{className:`h-full flex flex-col items-center justify-center gap-2`,children:[t(gb,{}),t(`span`,{className:`text-sm text-muted-foreground`,children:`Loading...`})]}):s?t(`div`,{className:`px-4 py-2 text-red-500 text-sm`,children:s}):t(`div`,{className:`px-4 py-2 prose prose-sm max-w-none dark:prose-invert`,children:r?t(yi,{children:r}):t(`div`,{children:`No markdown content available`})})}var xb=class extends Je{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`PDF View error:`,e,t)}render(){return this.state.hasError?t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(O,{title:rt.t(`pdf.failedToLoadViewer`,{ns:nt}),children:this.state.error?.message||`An unexpected error occurred`}),this.props.onClose&&t(o,{variant:`outline`,onClick:this.props.onClose,children:`Close`})]})}):this.props.children}};function Sb({objectId:e,onClose:r}){let{t:i}=X(),{client:a}=Z(),{data:s,error:c}=Le(()=>a.store.objects.retrieve(e,`+text`),[e]);return c?t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(O,{title:i(`pdf.fetchingDocumentFailed`),children:Ne(c)}),r&&t(o,{variant:`outline`,onClick:r,children:`Close`})]})}):s?t(xb,{onClose:r,children:t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:t(rb,{object:s,children:t(Cb,{object:s,onClose:r})})})}):n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,alt:i(`pdf.close`),children:t(nr,{className:`size-4`})})}),t(`div`,{className:`flex-1 flex items-center justify-center`,children:t(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary`})})]})}function Cb({object:e,onClose:r}){let{t:i}=X(),{count:a,pdfUrl:s,pdfUrlLoading:c}=ab(),l=()=>e.metadata?.type===`document`&&e.metadata.content_processor?.type===`markdown`?`markdown`:`xml`,[u,d]=Y(1);return l()===`xml`?n(me,{direction:`horizontal`,className:`absolute inset-0`,children:[t(pe,{defaultSize:50,minSize:20,maxSize:80,className:`bg-muted`,children:t(ub,{className:`h-full`,currentPage:u,onChange:d})}),t(fe,{className:`w-[4px] bg-border cursor-ew-resize`}),n(pe,{defaultSize:50,minSize:20,className:`flex flex-col`,children:[n(`div`,{className:`flex h-9 items-center justify-between shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:[t(`div`,{className:`flex items-center gap-x-2`,children:t(hb,{object:e})}),t(`span`,{className:`text-xs text-muted-foreground`,children:i(`pdf.pageOf`,{pageNumber:u,totalPages:a})}),t(`div`,{className:`flex items-center gap-x-2`,children:!!r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,alt:i(`pdf.close`),children:t(nr,{className:`size-4`})})})]}),t(`div`,{className:`flex-1 overflow-auto px-2`,children:t(_b,{pageNumber:u,viewType:`xml`})})]})]}):n(me,{direction:`horizontal`,className:`absolute inset-0`,children:[t(pe,{defaultSize:50,minSize:20,maxSize:80,className:`bg-muted`,children:t(Nm,{pdfUrl:s,pdfUrlLoading:c,pageCount:a,className:`h-full`,currentPage:u,onChange:d})}),t(fe,{className:`w-[4px] bg-border cursor-ew-resize`}),n(pe,{defaultSize:50,minSize:20,className:`flex flex-col`,children:[n(`div`,{className:`flex h-9 items-center justify-between shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:[t(`div`,{className:`flex items-center gap-x-2`,children:t(hb,{object:e})}),t(`span`,{className:`text-xs text-muted-foreground`,children:i(`pdf.pageOf`,{pageNumber:u,totalPages:a})}),t(`div`,{className:`flex items-center gap-x-2`,children:!!r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,alt:i(`pdf.close`),children:t(nr,{className:`size-4`})})})]}),t(`div`,{className:`flex-1 overflow-auto px-2`,children:t(_b,{pageNumber:u,viewType:`markdown`})})]})]})}const wb=[`image/jpeg`,`image/jpg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],Tb=[`video/mp4`,`video/webm`],Eb=[`audio/mp4`,`audio/m4a`,`audio/x-m4a`,`audio/mpeg`,`audio/ogg`,`audio/wav`,`audio/webm`];function Db(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`:`${n}:${r.toString().padStart(2,`0`)}`}function Ob({url:e,source:r,object:i,className:a}){let{t:o}=X(),{client:s}=Z(),[c,l]=Y(e),[u,d]=Y(!e&&(!!r||!!i)),f=i?.metadata,p=(f?.renditions||[]).find(e=>e.name===dr),m=i?.content?.type&&Eb.includes(i.content.type),h=!!i&&i.metadata?.type===pr.Audio&&!p&&!m;return K(()=>{if(e){l(e),d(!1);return}l(void 0),r||i?(d(!0),(async()=>{try{if(r){let e=await s.files.getDownloadUrl(r);l(e.url);return}if(!i||i.metadata?.type!==pr.Audio)return;let e;p?.content?.source?e=await s.files.getDownloadUrl(p.content.source):m&&i.content?.source&&(e=await s.files.getDownloadUrl(i.content.source)),e&&l(e.url)}catch(e){console.error(`Failed to get audio URL`,e)}finally{d(!1)}})()):d(!1)},[e,r,i,p,m,s]),h?t(`div`,{className:`flex justify-center items-center h-[200px] text-muted ${a??``}`.trim(),children:n(`div`,{className:`text-center`,children:[t(`p`,{children:o(`store.noAudioRendition`)}),t(`p`,{className:`text-sm mt-2`,children:o(`store.audioFormatRequired`)})]})}):u?t(`div`,{className:`flex justify-center items-center h-[200px] ${a??``}`.trim(),children:t(be,{size:`md`})}):c?n(`div`,{className:`flex flex-col items-center gap-4 ${a??``}`.trim(),children:[t(`audio`,{src:c,controls:!0,className:`w-full max-w-2xl`,children:`Your browser does not support the audio tag.`}),f?.duration&&n(`div`,{className:`text-sm text-muted`,children:[`Duration: `,Db(f.duration)]})]}):t(`div`,{className:`flex justify-center items-center h-[200px] text-muted ${a??``}`.trim(),children:`Failed to load audio`})}function kb({url:e,source:n,object:r,className:i}){let{client:a}=Z(),[o,s]=Y(e),[c,l]=Y(!e&&(!!n||!!r));return K(()=>{if(e){s(e),l(!1);return}s(void 0),n||r?(l(!0),(async()=>{try{if(n){let e=await a.files.getDownloadUrl(n);s(e.url);return}if(!r||r.metadata?.type!==pr.Image)return;let e=r.content?.type&&wb.includes(r.content.type);try{let e=await a.objects.getRendition(r.id,{format:gr.jpeg,generate_if_missing:!1,sign_url:!0});if(e.status===`found`&&e.renditions?.length){s(e.renditions[0]);return}}catch{}if(e&&r.content?.source){let e=await a.files.getDownloadUrl(r.content.source);s(e.url)}}finally{l(!1)}})()):l(!1)},[e,n,r,a]),c?t(`div`,{className:i,children:t(be,{size:`md`})}):o?t(`img`,{src:o,alt:r?.name,className:`w-full object-contain ${i??``}`.trim()}):null}function Ab({url:e,source:r,object:i,className:a}){let{t:o}=X(),{client:s}=Z(),[c,l]=Y(e),[u,d]=Y(),[f,p]=Y(!e&&(!!r||!!i)),m=i?.metadata?.renditions||[],h=m.find(e=>e.content.type===`video/mp4`)||m.find(e=>e.content.type===`video/webm`),g=i?.content?.type&&Tb.includes(i.content.type),_=m.find(e=>e.name===br),v=!!i&&i.metadata?.type===pr.Video&&!h&&!g;return K(()=>{if(e){l(e),p(!1);return}l(void 0),d(void 0),r||i?(p(!0),(async()=>{try{if(r){let e=await s.files.getDownloadUrl(r);l(e.url);return}if(!i||i.metadata?.type!==pr.Video)return;let e;h?.content?.source?e=await s.files.getDownloadUrl(h.content.source):g&&i.content?.source&&(e=await s.files.getDownloadUrl(i.content.source)),e&&l(e.url)}catch(e){console.error(`Failed to get video URL`,e)}finally{p(!1)}})()):p(!1)},[e,r,i,h,g,s]),K(()=>{_?.content?.source&&s.files.getDownloadUrl(_.content.source).then(e=>d(e.url)).catch(e=>console.error(`Failed to load poster image`,e))},[_,s]),v?t(`div`,{className:`flex justify-center items-center h-[400px] text-muted ${a??``}`.trim(),children:n(`div`,{className:`text-center`,children:[t(`p`,{children:o(`store.noVideoRendition`)}),t(`p`,{className:`text-sm mt-2`,children:o(`store.videoFormatRequired`)})]})}):f?t(`div`,{className:`flex justify-center items-center h-[400px] ${a??``}`.trim(),children:t(be,{size:`md`})}):c?t(`video`,{src:c,poster:u,controls:!0,className:`w-full h-full object-contain ${a??``}`.trim(),children:`Your browser does not support the video tag.`}):t(`div`,{className:`flex justify-center items-center h-[400px] text-muted ${a??``}`.trim(),children:`Failed to load video`})}function jb({oauthProviderId:r,onAuthChange:i}){let{client:a}=Z(),{t:o}=X(),[s,c]=Y(null),[l,u]=Y(!0),[d,f]=Y(!1),[p,m]=Y(!1),h=G(async()=>{try{u(!0);let e=await a.oauthProviders.getStatus(r);c(e)}catch(e){console.error(`Failed to load OAuth provider status:`,e)}finally{u(!1)}},[a,r]);K(()=>{h()},[h]);let{openOAuthPopup:g}=gs({onComplete:()=>{f(!1),h(),i?.()},onError:e=>{console.error(`OAuth provider auth failed:`,e),f(!1)}});return l?t(ms,{className:`size-4`}):s?.authenticated?n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1 text-success text-sm`,children:[t(gt,{className:`size-4`}),t(`span`,{children:o(`oauthProvider.connected`)})]}),t(Ka,{variant:`outline`,size:`sm`,onClick:async()=>{if(!p)try{m(!0),await a.oauthProviders.disconnect(r),await h(),i?.()}catch(e){console.error(`Failed to disconnect OAuth provider:`,e)}finally{m(!1)}},disabled:p,children:p?t(ms,{className:`size-3`}):o(`oauthProvider.disconnect`)})]}):t(Ka,{variant:`outline`,size:`sm`,onClick:async()=>{if(!d)try{f(!0);let e=await a.oauthProviders.authorize(r);e.authorization_url&&g(e.authorization_url)}catch(e){console.error(`Failed to authorize OAuth provider:`,e),f(!1)}},disabled:d,children:d?n(e,{children:[t(ms,{className:`size-4`}),t(`span`,{children:o(`oauthProvider.authenticating`)})]}):n(e,{children:[t(Vt,{className:`size-4 me-1`}),t(`span`,{children:o(`oauthProvider.authenticate`)})]})})}function Mb(...e){let t=Array.from(e);return t.__AnyOf__=!0,t}function Nb(...e){return Array.from(e)}function Pb(e){return e.__AnyOf__===!0}var Fb=class{system_roles;roles;permissions;constructor(e,t=[]){this.system_roles=t;let n=[...e.account_roles||[],...e.project_roles||[]],r=new Set(n);this.roles=r;let i=e.permissions??Ib(n,t),a=e.type===Sr.OAuthAccess?new Set(e.permissions??[]):void 0;this.permissions=new Set(a?i.filter(e=>a.has(e)):i)}hasPermission(e){if(typeof e==`string`)return this.permissions.has(e);if(Pb(e))return e.some(e=>this.permissions.has(e));for(let t of e)if(!this.permissions.has(t))return!1;return!0}};function Ib(e,t){let n=new Map(t.map(e=>[e.name,e.permissions])),r=new Set;for(let t of e)for(let e of n.get(t)??[])r.add(e);return Array.from(r)}const Lb=Ye(void 0);function Rb(){let e=Qe(Lb);if(!e)throw Error(`UserPermissionContext cannot be used outside UserPermissionProvider`);return e}function zb({children:e}){let{t:n}=X(),r=Z(),i=r.authToken,a=!!(i&&!i.permissions),{data:o,error:s,isLoading:c}=Le(()=>a?r.client.iam.roles.listSystem():Promise.resolve(void 0),[r,a]),l=q(()=>{if(i){if(i.permissions||!a)return new Fb(i);if(o&&!c)return new Fb(i,o)}else return},[i,o,c,a]);return s?t(O,{title:n(`store.failedToFetchRoleMappings`),children:Ne(s)}):l&&t(Lb.Provider,{value:l,children:e})}function Bb({permission:e,isDisabled:n,title:r,children:i,...a}){return Rb().hasPermission(e)?t(o,{isDisabled:n,title:r,...a,children:i}):null}function Vb({permission:e,...n}){return Rb().hasPermission(e)?t(Li,{...n}):null}var Hb=class extends de{idOf(e){return e.id}labelOf(e){return e.label}descriptionOf(e){return e.description}selectedClassName(e){return`border-3 border-primary`}};function Ub({isOpen:e,onClose:r,onConfirm:i,isLoading:a,uploadedFileName:s}){let{t:c}=X(),l=q(()=>[{id:`update`,label:c(`modal.saveVersion.updateCurrent`),description:c(s?`modal.saveVersion.updateWithFileDescription`:`modal.saveVersion.updateDescription`)},{id:`new-version`,label:c(`modal.saveVersion.createNew`),description:c(s?`modal.saveVersion.createWithFileDescription`:`modal.saveVersion.createDescription`)}],[c,s]),u=s?l[1]:l[0],[d,f]=Y(u),[p,m]=Y(``),h=new Hb;K(()=>{e&&(f(u),m(``))},[u,e]);let g=d?.id===`new-version`;return n(B,{isOpen:e,onClose:r,className:`sm:max-w-md`,children:[t(re,{children:c(`modal.saveChanges`)}),t(te,{children:n(`div`,{className:`space-y-4`,children:[s&&t(`div`,{className:`mb-4 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-md`,children:n(`p`,{className:`text-sm text-blue-700 dark:text-blue-300 font-medium`,children:[c(`modal.saveVersion.replaceFile`),` `,t(`span`,{className:`font-bold`,children:s})]})}),t(`p`,{className:`text-sm text-mixer-muted/5`,children:c(`modal.saveVersion.howToSave`)}),t(ue,{adapter:h,options:l,selected:d,onSelect:e=>{f(e)}}),g&&t(N,{label:c(`modal.saveVersion.versionLabel`),description:c(`modal.saveVersion.versionLabelDescription`),className:`mt-3 ps-8`,children:t(F,{value:p,onChange:m,placeholder:c(`modal.saveVersion.versionLabelPlaceholder`),className:`w-full`})})]})}),n(ne,{children:[t(o,{variant:`secondary`,onClick:r,disabled:a,children:c(`modal.cancel`)}),t(o,{variant:`primary`,onClick:async()=>{await i(g,g?p:void 0)},isLoading:a,children:c(`modal.save`)})]})]})}function Wb({isOpen:r,onClose:i,object:a,refetch:s}){let{client:c,store:l}=Z(),u=He(),{t:d}=X(),{theme:f}=Ve(),p=li(),[m,h]=Y(!1),[g,_]=Y(``),[v,y]=Y(!1),[b,x]=Y(null),S=J(void 0),[C,w]=Y(null),[T,E]=Y(null),D=G(async e=>{try{let t=await l.types.retrieve(e);t.object_schema&&w(t.object_schema)}catch(e){console.error(`Failed to fetch JSON schema:`,e)}},[l.types]);K(()=>{r&&(_(JSON.stringify(a.properties||{},null,2)),a.type?.id&&D(a.type.id))},[r,a,D]);let O=e=>{C&&e.json.jsonDefaults.setDiagnosticsOptions({validate:!0,schemas:[{uri:`http://myserver/object-schema.json`,fileMatch:[`*`],schema:C}]})};function k(){if(!S.current)return;let e=S.current.getValue();try{let t=JSON.parse(e);x(t),y(!0)}catch{u({status:`error`,title:d(`store.invalidJson`),description:d(`store.pleaseFixJsonSyntax`),duration:5e3})}}let A=e=>{_(e)};async function j(e,t){try{h(!0);let n=b||JSON.parse(g);if(e){let e=await c.objects.update(a.id,{properties:n},{createRevision:!0,revisionLabel:t});e.id!==a.id&&E(e.id),u({status:`success`,title:d(`store.newVersionCreated`),description:d(`store.newVersionCreatedDesc`),duration:2e3}),y(!1),i(),e.id!==a.id&&setTimeout(()=>{p(`/objects/${e.id}`),u({status:`info`,title:d(`store.viewingNewVersion`),description:t?d(`store.viewingVersionLabel`,{label:t}):d(`store.viewingNewVersionDefault`),duration:3e3})},100)}else await l.objects.update(a.id,{properties:n}),u({status:`success`,title:d(`store.propertiesUpdated`),description:d(`store.propertiesUpdatedDesc`),duration:2e3}),s&&await s(),y(!1),i()}catch(e){u({status:`error`,title:d(`store.errorUpdatingProperties`),description:Ne(e,d(`store.errorUpdatingPropertiesDefault`)),duration:5e3}),h(!1)}}function M(){y(!1)}return n(e,{children:[n(B,{isOpen:r,onClose:i,className:`sm:max-w-[90%] md:max-w-[80%] lg:max-w-[75%] xl:max-w-[70%]`,children:[t(re,{children:d(`store.editProperties`)}),n(te,{children:[n(`div`,{className:`mb-2 text-sm text-gray-500`,children:[a.type?.name?n(`span`,{children:[`Editing properties for object type: `,t(`strong`,{children:a.type.name})]}):t(`span`,{children:d(`store.editingGenericDocument`)}),C!==null&&t(`span`,{className:`ms-2 text-green-600`,children:`(JSON schema validation enabled)`})]}),t(`div`,{className:`h-[75vh] border rounded-md overflow-hidden`,children:t(bi,{value:g,language:`json`,editorRef:S,onChange:e=>A(e.state.doc.toString()),beforeMount:O,theme:f===`dark`?`vs-dark`:`vs`})})]}),n(ne,{children:[t(o,{variant:`secondary`,onClick:i,children:`Cancel`}),t(o,{variant:`primary`,onClick:k,children:`Save Changes`})]})]}),t(Ub,{isOpen:v,onClose:M,onConfirm:j,isLoading:m})]})}function Gb(e){switch(e){case`text/markdown`:return`markdown`;case`application/json`:return`json`;case`application/xml`:case`text/xml`:return`xml`;default:return`plaintext`}}function Kb({object:r,text:i,onClose:a,onSaved:s}){let{store:c}=Z(),l=He(),{t:u}=X(),{theme:d}=Ve(),f=li(),p=J(void 0),[m,h]=Y(!1),[g,_]=Y(!1),[v,y]=Y(!1),b=Gb(r.content?.type);console.log(`Determined language for Monaco Editor:`,b),console.log(`TextEditorPanel rendered with object:`,r,i);let x=G(()=>{m||h(!0)},[m]);function S(){p.current&&y(!0)}async function C(e,t){if(!p.current)return;let n=p.current.getValue(),i=r.content?.type||`text/plain`,o=r.content?.name||`content.txt`;try{_(!0);let d=new Blob([n],{type:i}),p=new File([d],o,{type:i}),m=await c.objects.update(r.id,{content:p},{createRevision:e,revisionLabel:t,ifMatch:r.content?.etag});l({status:`success`,title:u(`store.textSaved`),duration:2e3}),y(!1),e&&m.id!==r.id?(a(),setTimeout(()=>{f(`/objects/${m.id}`)},100)):s()}catch(e){let t=Ne(e,u(`store.errorSavingTextDefault`)),n=(typeof e==`object`&&e&&`status`in e?e.status:void 0)===412||t.includes(`412`);l({status:`error`,title:u(`store.errorSavingText`),description:n?u(`store.textConflict`):t,duration:5e3})}finally{_(!1)}}return n(e,{children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1 shrink-0`,children:[m&&t(`span`,{className:`text-xs text-attention`,children:u(`store.unsavedChanges`)}),t(`div`,{className:`flex-1`}),t(o,{variant:`ghost`,size:`sm`,onClick:a,disabled:g,children:u(`store.cancelEdit`)}),t(o,{variant:`secondary`,size:`sm`,onClick:S,disabled:!m,isLoading:g,children:u(`store.saveText`)})]}),t(`div`,{className:`flex-1 min-h-0 border rounded-md overflow-hidden mx-2 mb-2`,children:t(bi,{value:i,language:b,editorRef:p,onChange:x,theme:d===`dark`?`vs-dark`:`vs`,options:{wordWrap:`on`,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1}})}),t(Ub,{isOpen:v,onClose:()=>y(!1),onConfirm:C,isLoading:g})]})}const qb=128*1024;function Jb(e,t,n=!1){let{store:r}=Z(),[i,a]=Y(t),[o,s]=Y(()=>t&&t.length>qb?t.substring(0,qb):t),[c,l]=Y(!1),[u,d]=Y(()=>!!t&&t.length>qb),f=G(()=>{l(!0),r.objects.getObjectText(e).then(e=>{a(e.text),e.text&&e.text.length>qb?(s(e.text.substring(0,qb)),d(!0)):(s(e.text),d(!1))}).catch(e=>{console.error(`Failed to load text`,e),a(void 0),s(void 0),d(!1)}).finally(()=>{l(!1)})},[e,r]);return K(()=>{t&&t.length>qb?(a(t),s(t.substring(0,qb)),d(!0)):(a(t),s(t),d(!1)),n&&!t&&f()},[t,n,f]),{fullText:i,displayText:o,isLoading:c,isCropped:u,loadText:f}}function Yb(e,t){let{client:n}=Z(),[r,i]=Y({isComplete:!1});return K(()=>{if(!t)return;let r=!1,a,o=(e,t,n,r)=>{i(i=>{let a=JSON.stringify(i.progress??null),o=JSON.stringify(e??null);return i.status===t&&i.outputFormat===n&&i.isComplete===r&&a===o?i:{progress:e,status:t,outputFormat:n,isComplete:r}})};function s(){r||n.objects.analyze(e).getStatus().then(e=>{let t=e.output_format??e.progress?.output_format;e.status===Er.RUNNING?(o(e.progress,e.status,t,!1),r||(a=setTimeout(s,2e3))):o(e.progress,e.status,t,!0)}).catch(()=>{r||(a=setTimeout(s,1e4))})}return s(),()=>{r=!0,a&&clearTimeout(a)}},[t,e,n]),{progress:r.progress,status:r.status,outputFormat:r.outputFormat,isComplete:r.isComplete}}function Xb(e,t){let{client:n}=Z(),r=rt.getFixedT(null,nt),[i,a]=Y(),[o,s]=Y(!1),[c,l]=Y();return{pdfUrl:i,isConverting:o,error:c,triggerConversion:G(async()=>{if(!t||o)return;s(!0),l(void 0);let i=async t=>{try{let o=await n.objects.getRendition(e,{format:vr.pdf,generate_if_missing:t,sign_url:!0,block_on_generation:!1});o.status===`generating`?setTimeout(()=>i(!1),5e3):o.status===`found`&&o.renditions?.length?(a(o.renditions[0]),s(!1)):o.status===`failed`&&(l(r(`store.pdfConversionFailed`)),s(!1))}catch(e){console.error(`Failed to convert Office document to PDF:`,e),l(r(`store.failedToConvertToPdf`)),s(!1)}};await i(!0)},[e,t,o,n,r])}}const Zb=()=>({a:({node:e,...n})=>{let r=n.href||``;return r.includes(`/store/objects/`)?t(ci,{topLevelNav:!0,href:r,className:`text-info`,children:n.children}):t(`a`,{...n,target:`_blank`,rel:`noopener noreferrer`})},p:({node:e,...n})=>t(`p`,{...n,className:`my-0`}),pre:({node:e,...n})=>t(`pre`,{...n,className:`my-2 p-2 rounded`}),code:({node:e,className:n,children:r,...i})=>{let a=!/language-(\w+)/.exec(n||``);return t(`code`,{...i,className:a?`px-1.5 py-0.5 rounded`:`text-muted`,children:r})},h1:({node:e,...n})=>t(`h1`,{...n,className:`font-bold text-2xl my-2`}),h2:({node:e,...n})=>t(`h2`,{...n,className:`font-bold text-xl my-2`}),h3:({node:e,...n})=>t(`h3`,{...n,className:`font-bold text-lg my-2`}),li:({node:e,...n})=>t(`li`,{...n})});function Qb(e){return e===mr.created||e===mr.processing}function $b(e){return e.metadata?.content_processor?.type}function ex(e){return e?e.includes(`
|
|
441
|
+
`)}let r=await i(n,{tool_approval_mode:z});if(!r){R(null),te(null);return}R(n),te(Date.now());let a=r.agent_run_id,o=[];if(E&&ae.length>0){for(let e of ae)try{let t=`files/${e.name}`;await A.agents.uploadArtifact(a,t,e),await A.agents.sendSignal(a,`FileUploaded`,{id:`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:e.name,content_type:e.type||`application/octet-stream`,reference:`artifact:${t}`,artifact_path:t}),o.push(e.name)}catch(t){console.error(`Failed to upload staged file ${e.name}:`,t)}if(o.length>0)try{await A.agents.sendSignal(a,`UserInput`,{message:`[Files Ready] All ${o.length} file(s) have been uploaded and are now available: ${o.join(`, `)}. You can now process them.`,metadata:{type:`files_ready`,files:o}})}catch(e){console.error(`Failed to send files ready signal:`,e)}oe([])}p?.(),I(a),M(``),B({title:T(`agent.agentStarted`),status:`success`,duration:3e3})}catch(e){R(null),te(null),B({title:T(`agent.errorStarting`),status:`error`,duration:3e3,description:e instanceof Error?e.message:T(`agent.unknownError`)})}finally{P(!1)}}},ve=e=>{if(e.key===`Enter`){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)){e.preventDefault(),_e();return}e.shiftKey||(e.preventDefault(),Be(e.currentTarget,M))}},ye=G(()=>{let e=re.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]);return K(()=>{ye()},[j,ye]),F?t(yy,{onClose:a,isModal:s,initialMessage:e,placeholder:l,fullWidth:c,hideHeader:g,headerVariant:y,hideFileUpload:_,hideObjectLinking:v,inputContainerClassName:b,inputClassName:x,className:S,allowWorkflowControl:C,agentRunId:F,title:d,pendingStartMessage:L??void 0,pendingStartTimestamp:ee??void 0,initialToolApprovalMode:z}):t(`div`,{className:V(`flex h-full flex-col items-center bg-background`,S),children:n(`div`,{className:V(`relative flex h-full w-full flex-col overflow-hidden border-0`,c?``:`max-w-4xl`),onDragEnter:E?ue:void 0,onDragOver:E?de:void 0,onDragLeave:E?fe:void 0,onDrop:E?pe:void 0,children:[E&&se&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info-background z-50 pointer-events-none rounded-lg`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2 text-lg`,children:[t(pr,{className:`size-6`}),`Drop files to stage for upload`]})}),E&&t(`input`,{ref:ie,type:`file`,multiple:!0,accept:m,onChange:he,className:`hidden`}),!g&&n(`div`,{className:`flex items-center justify-between border-b border-border/60 bg-background px-3 py-2`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`div`,{className:`p-1`,children:t(Kt,{className:`size-3.5 text-muted`})}),t(`span`,{className:`text-sm font-medium text-foreground`,children:k})]}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,title:T(`agent.close`),className:`text-muted hover:text-foreground`,children:t(Sr,{className:`size-4`})})]}),t(`div`,{className:`flex flex-1 flex-col items-center justify-end overflow-y-auto bg-background px-4`,children:L&&ee?t(dy,{message:L,startedAt:ee}):t(`div`,{className:`mx-auto flex min-h-full w-full max-w-3xl flex-col justify-end py-8`,children:e&&t(`div`,{className:`text-[15px] leading-relaxed text-foreground/80`,children:e})})}),t(`div`,{className:`shrink-0 bg-background px-4 pb-safe-area-4 pt-2`,children:n(`div`,{className:V(`mx-auto flex max-w-3xl flex-col gap-3 rounded-2xl border border-border/70 bg-mixer-muted/15 p-3 shadow-lg shadow-black/5`,b),children:[E&&ae.length>0&&t(`div`,{className:`flex flex-wrap gap-2`,children:ae.map((e,r)=>n(`div`,{className:`flex items-center gap-1.5 rounded-md bg-attention/10 px-2 py-1 text-sm text-attention`,title:T(`agent.fileStagedTooltip`),children:[t(sn,{className:`size-3.5`}),t(`span`,{className:`max-w-[120px] truncate`,children:e.name}),t(`span`,{className:`text-xs opacity-70`,children:T(`agent.staged`)}),t(o,{variant:`unstyled`,"aria-label":`Remove staged file ${e.name}`,onClick:()=>ge(r),className:`ms-1 rounded p-0.5 hover:bg-attention/20`,children:t(Sr,{className:`size-3`})})]},`${e.name}-${e.size}-${e.lastModified}`))}),t(Re,{ref:re,value:j,onChange:e=>M(e.target.value),onKeyDown:ve,onPaste:me,placeholder:D,disabled:N,rows:2,className:V(`min-h-[72px] resize-none overflow-hidden border-0 bg-transparent px-0 py-0 text-sm leading-6 shadow-none focus-visible:ring-0`,x),style:{minHeight:`72px`,maxHeight:`200px`}}),n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[E&&t(o,{variant:`ghost`,size:`icon`,onClick:()=>ie.current?.click(),disabled:N||ae.length>=h,"aria-label":T(`agent.upload`),className:`rounded-full text-muted`,title:T(`agent.upload`),children:t(pr,{className:`size-4`})}),r&&t(ba,{mode:z,onChange:ne,disabled:N})]}),t(o,{onClick:_e,disabled:!j.trim()||N,variant:`ghost`,size:`icon`,className:V(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`),title:O,children:N?t(Ee,{size:`sm`}):t(_t,{className:`size-4`})})]})]})})]})})}function yy({agentRunId:r,title:i,interactive:a=!0,onClose:s,isModal:c=!1,fullWidth:l=!1,placeholder:u,resetWorkflow:d,onRestart:f,onClone:p,onShowDetails:m,allowWorkflowControl:h=!0,uploadedFiles:g,onRemoveFile:_,acceptedFileTypes:v,maxFiles:y,renderDocumentSearch:b,selectedDocuments:x,onRemoveDocument:S,hideObjectLinking:C,hideHeader:w,headerVariant:T=`full`,hideMessageInput:E,failedAction:D,hidePlanPanel:O,hideWorkstreamTabs:k,showRightPanel:A=!0,hideFileUpload:j,showArtifacts:M=!1,hideDocumentPanel:N,hiddenMessageTypes:P,getAttachedDocs:F,onAttachmentsSent:I,isUploading:L=!1,getMessageContext:R,className:ee,inputContainerClassName:te,inputClassName:z,fusionData:ne,fileUploadRef:B,onProcessingFilesChange:ce,processingFiles:le,onPlansChange:ue,onWorkstreamStatusChange:de,viewMode:fe,onViewModeChange:pe,onShowInputChange:me,stopRef:he,onStoppingChange:ge,messageItemClassNames:_e,messageStyleOverrides:ve,toolCallGroupClassNames:ye,hideToolCallsInViewMode:be,streamingMessageClassNames:xe,batchProgressPanelClassNames:Se,workingIndicatorClassName:Ce,messageListClassName:we,StoreLinkComponent:Te,CollectionLinkComponent:Ee,prependFriendlyMessage:De,initialRequestData:Oe,initialRequestSchema:ke,initialRequestTitle:Ae,initialRequestTemplate:je,payloadContent:Me,conversationContent:Ne,conversationTab:Pe=!1,pendingStartMessage:Fe,pendingStartTimestamp:Ie,initialToolApprovalMode:Le,enablePlayback:Re,showPlaybackToggle:ze=!0}){let{t:H}=X(),{client:Be}=Z(),Ve=Ye(),{messages:He,streamingMessages:Ue,isCompleted:We,initialHistoryStatus:Ge,debugChunkFlash:Ke,addOptimisticMessage:qe,updateOptimisticMessageStatus:Je,reconnect:Xe,agentRunStatus:Ze,workflowRunId:Qe,serverFileUpdates:$e}=Uh(Be,r),{plans:et,activePlanIndex:U,setActivePlanIndex:W,workstreamStatusMap:tt,showInput:nt,showSlidingPanel:rt,setShowSlidingPanel:it}=Mh(He,a,c),{openDocuments:at,activeDocumentId:ot,isDocPanelOpen:st,docRefreshKey:ct,closeDocPanel:lt,closeDocument:ut,selectDocument:dt,openDocInPanel:ft,updateDocumentTitle:pt}=qh(He),{processingFiles:mt,hasProcessingFiles:ht,handleFileUpload:gt,removeProcessingFile:_t,clearProcessingFiles:vt}=Zh(Be,r,$e,Ve),yt=a&&!j,bt=G(e=>{_t(e)},[_t]),xt=J(null),St=J(null),Ct=J(null),[Tt,Et]=Y(!1),[Dt,Ot]=Y(!1),[kt,At]=Y(`sliding`),jt=fe??kt,Mt=G(e=>{pe?pe(e):At(e)},[pe]),[Nt,Pt]=Y(!1),[Ft,It]=Y(!1),[Lt,Rt]=Y(`all`),[zt,Bt]=Y(`live`),[Vt,Ht]=Y(!1),[Ut,Wt]=Y(0),[Gt,Kt]=Y([]),[qt,Jt]=Y([]),[Yt,Xt]=Y(!1),Zt=q(()=>Le===void 0&&a?void 0:qr(Le,a),[Le,a]),[Qt,$t]=Y(Zt),en=J(!1),tn=J(0),nn=J(!1),rn=J(0),an=J(null);K(()=>{$t(Zt)},[Zt]);let on=J(Tt);on.current=Tt;let sn=J(ht);sn.current=ht;let cn=J(mt);cn.current=mt;let ln=q(()=>{let e=He.filter(e=>(e.workstream_id||`main`)===`main`);return e[e.length-1]},[He]),un=q(()=>ln?.type===Q.TERMINATED?`TERMINATED`:ln?.type===Q.COMPLETE&&(!Ze||Ze===`RUNNING`)?`COMPLETED`:Ze,[ln,Ze]),dn=q(()=>{let e=un?.toUpperCase();return e===`COMPLETED`||e===`FAILED`||e===`CANCELED`||e===`CANCELLED`||e===`TERMINATED`||e===`TIMED_OUT`},[un]),fn=q(()=>dn&&un?.toUpperCase()!==`FAILED`&&!!f,[dn,un,f]),pn=!E||fn,mn=q(()=>un?.toUpperCase()===`FAILED`||Ze?.toUpperCase()===`FAILED`,[un,Ze]),hn=J(dn);hn.current=dn;let gn=J(fn);gn.current=fn;let _n=q(()=>{let e=et[U]||{plan:{plan:[]},timestamp:0},t=tt.get(e.timestamp)||new Map;return{plan:e.plan,workstreamStatus:t}},[et,U,tt]),vn=q(()=>iy(He),[He]),yn=q(()=>{let e=[...vn];for(let t of qt)sy(e,oy(t));for(let t of Gt)sy(e,ay(t));return e.map((e,t)=>({workstream:e,index:t})).sort((e,t)=>Number(!Xv(e.workstream.status))-Number(!Xv(t.workstream.status))||e.index-t.index).map(({workstream:e})=>e)},[vn,Gt,qt]),bn=q(()=>yn.filter(e=>Xv(e.status)),[yn]),xn=q(()=>bn.filter(e=>e.status===`running`).length,[bn]),Sn=q(()=>{if(Lt===`all`)return;let e=yn.find(e=>e.workstream_id===Lt||e.launch_id===Lt);return e?Cl(e.workstream_id,e.interaction):Cl(Lt)},[Lt,yn]),Cn=q(()=>{if(u)return u;if(Sn)return H(`agent.messageMainAgentWhileViewingWorkstream`,{workstream:Sn})},[Sn,u,H]),wn=ze&&Re===void 0&&Za(),Tn=Re??(Qa()||Vt),En=q(()=>Wl(P?.length?He.filter(e=>!P.includes(e.type)):He,Lt),[Lt,P,He]),Dn=q(()=>Ya(En,zt,Tn),[Tn,zt,En]),On=Dn.cursor,kn=Dn.isLive,An=Tn&&!kn&&Dn.cursorIndex===En.length-1,jn=Dn.displayedMessages,Mn=kn?Ue:Jv,Nn=q(()=>iy(jn),[jn]),Pn=q(()=>Nn.filter(e=>Xv(e.status)),[Nn]),Fn=q(()=>We||!Rl(He),[We,He]),In=kn||An?Fn:!1,Ln=q(()=>Au(jn),[jn]),Rn=!!Ln&&!mn,zn=Tn&&!kn,Bn=pn&&!zn,Vn=q(()=>$v(He),[He]),Hn=h&&!dn&&kn&&!!Vn;K(()=>{Fl(`conversation render state`,{agentRunId:r,messageCount:He.length,playbackMessageCount:En.length,displayedMessageCount:jn.length,streamingCount:Ue.size,displayedStreamingCount:Mn.size,initialHistoryStatus:Ge,isCompleted:We,effectiveIsCompleted:Fn,displayedIsCompleted:In,agentRunStatus:Ze,effectiveWorkflowStatus:un,isWorkflowTerminal:dn,playbackCursor:On,isPlaybackEnabled:Tn,isPlaybackLive:kn,isPlaybackAtLatest:An,activeWorkstream:Lt,showInitialRequest:Ge===`empty`&&He.length===0,pendingStartVisible:He.length===0&&!Fn&&!!Fe})},[Lt,r,Ze,On,In,jn.length,Mn.size,Fn,un,Ge,We,An,Tn,kn,dn,He.length,Fe,En.length,Ue.size]);let Un=G(()=>{Ht(e=>!e)},[]),Wn=G(e=>{let t=Ka(On,En.length),n=Ka(e,En.length);Tn&&(n>t||e===`live`&&On!==`live`)&&(nn.current=!0,Wt(e=>e+1)),Bt(e)},[On,Tn,En.length]);K(()=>{if(!Tn){zt!==`live`&&Bt(`live`);return}On!==zt&&Bt(On)},[On,Tn,zt]),K(()=>{if(!Tn||!nn.current)return;nn.current=!1;let e=window.requestAnimationFrame(()=>{xt.current?.scrollIntoView({behavior:`smooth`,block:`end`})});return()=>window.cancelAnimationFrame(e)},[Tn,Ut]);let Gn=G(()=>{it(e=>(e||sessionStorage.setItem(`plan-panel-shown`,`true`),!e))},[it]),Kn=G(e=>{W(e)},[W]),[qn,Jn]=Y(Ne||Pe?`conversation`:`plan`),[Yn,Xn]=Y(400),[Zn,Qn]=Y(!1),$n=A&&(rt||st||!k&&yn.length>0||!!Ne||Pe);K(()=>{!$n&&Zn&&Qn(!1)},[$n,Zn]),K(()=>{if(!Zn)return;let e=e=>{let t=Ct.current;if(!t)return;let n=t.getBoundingClientRect(),r=Math.max(300,n.width-420),i=n.right-e.clientX;Xn(Math.min(Math.max(i,300),r))},t=()=>{Qn(!1)};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[Zn]);let er=G(()=>{it(!1),lt()},[it,lt]),tr=G(({href:e,documentId:n,children:r})=>t(`a`,{href:e,className:`text-info underline cursor-pointer hover:text-info/80`,onClick:e=>{e.preventDefault(),e.stopPropagation(),ft(n),Jn(`documents`)},children:r}),[ft]),nr=Te??tr;K(()=>(B&&(B.current=yt?gt:null),()=>{B&&(B.current=null)}),[B,gt,yt]),K(()=>{ce?.(mt)},[mt,ce]),K(()=>{ue?.(et,U)},[et,U,ue]),K(()=>{de?.(tt)},[tt,de]),K(()=>{en.current=!1,Xt(!1),Kt([]),Jt([])},[r]),K(()=>{let e=Ge!==`loading`&&!Fn&&!dn&&!Yt;if(Fl(`active workstreams poll state`,{agentRunId:r,shouldPoll:e,initialHistoryStatus:Ge,effectiveIsCompleted:Fn,isWorkflowTerminal:dn,isWorkstreamQueryUnavailable:Yt}),!e){Kt(e=>e.length===0?e:[]);return}let t=!1,n=!1,i=async()=>{if(n){Fl(`active workstreams fetch skipped while previous request is pending`,{agentRunId:r});return}n=!0;try{Fl(`active workstreams fetch start`,{agentRunId:r});let e=await Be.agents.getActiveWorkstreams(r);if(t)return;if(Fl(`active workstreams fetch success`,{agentRunId:r,runningCount:e.running?.length??0,completedCount:e.completed?.length??0,unavailable:e.unavailable===!0}),Kt(e.running??[]),Jt(e.completed??[]),e.unavailable){Xt(!0);return}en.current=!1}catch(e){if(t)return;Kt(e=>e.length===0?e:[]),Xt(!0),Fl(`active workstreams fetch failed`,{agentRunId:r,error:e instanceof Error?e.message:String(e)}),en.current||=(console.warn(`Failed to fetch active workstreams:`,e),!0)}finally{n=!1}};i();let a=window.setInterval(i,1e4);return()=>{t=!0,window.clearInterval(a)}},[Be.agents,r,Fn,Ge,dn,Yt]),K(()=>{if(He.length!==0){if(fn){me?.(!0);return}if(!nt){me?.(!1);return}if(un&&un!==`RUNNING`){me?.(!1);return}un!==null&&me?.(!0)}},[nt,un,He.length,me,fn]);let rr=G(async()=>{let e=an.current;e&&await e},[]),ir=G((e,t)=>{let n=e.trim();if(!n||on.current||hn.current&&!gn.current)return;if(sn.current){Ve({status:`warning`,title:H(`agent.filesProcessing`),description:H(`agent.waitForFilesProcessing`),duration:3e3});return}Et(!0);let i=F?.()||[],a=R?.()||{},o=n;i.length>0&&!/store:\S+/.test(n)&&(o=[n,``,`Attachments:`,...i.map(e=>`[${e.name}](/store/objects/${e.id})`)].join(`
|
|
442
|
+
`));let s=Array.from(cn.current.values()).filter(e=>e.status===Nr.READY).map(e=>{let t=e.reference?.startsWith(`artifact:`)?e.reference:e.artifact_path?`artifact:${e.artifact_path}`:void 0;return t?`[${e.name}](${t})`:void 0}).filter(e=>!!e);s.length>0&&(o=[o,``,`Uploaded artifacts:`,...s].join(`
|
|
443
|
+
`));let c=`msg-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,l={timestamp:Date.now(),workflow_run_id:r,type:Q.QUESTION,message:o,workstream_id:`main`,details:{_optimistic:!0,_messageId:c,_deliveryStatus:`sending`}};qe(l);let u={...i.length>0?{attached_docs:i.map(e=>e.id)}:{},...a,...t,id:c,_messageId:c},d=()=>Be.agents.sendSignal(r,`UserInput`,{message:o,client_message_id:c,metadata:u}),f=()=>{Je(c,`received`),I?.(),vt()};(async()=>{await rr(),hn.current&&(await Be.agents.restart(r),Xe()),await d(),f()})().catch(e=>{Je(c,`failed`),Ve({status:`error`,title:H(`agent.failedToSend`),description:e instanceof Error?e.message:H(`agent.unknownError`),duration:3e3})}).finally(()=>{Et(!1)})},[r,Be,Ve,F,R,I,vt,Xe,qe,Je,H,rr]),ar=G(async e=>{try{await Be.agents.sendSignal(r,`McpConfigChanged`,{})}catch(e){console.error(`Failed to signal MCP config change`,e)}ir(H(`agent.mcpConnectedMessage`,{name:e.name}))},[Be,r,ir,H]),[or,sr]=Y(void 0);K(()=>{let e=!1,t=rn.current;return Be.agents.retrieve(r).then(n=>{e||(sr(n.disabled_mcp_collections),rn.current===t&&(n.tool_approval_mode!==void 0||n.interactive!==void 0)&&$t(qr(n.tool_approval_mode,n.interactive)))}).catch(()=>{}),()=>{e=!0}},[Be,r]);let cr=G(e=>{let t=e.length>0?e:void 0;sr(t),Be.agents.sendSignal(r,`McpConfigChanged`,{disabled_mcp_collections:e}).catch(e=>console.error(`Failed to signal MCP config change`,e))},[Be,r]),lr=G(()=>{Be.agents.sendSignal(r,`McpConfigChanged`,{}).catch(e=>console.error(`Failed to signal MCP config change`,e))},[Be,r]),ur=G(e=>{let t=qr(e,a),n=Qt;rn.current+=1,$t(t);let i=Be.agents.sendSignal(r,`ToolApprovalModeChanged`,{mode:t}).then(()=>void 0).catch(e=>{$t(e=>e===t?n:e),Ve({status:`error`,title:H(`agent.approvalMode.changeFailed`),description:e instanceof Error?e.message:H(`agent.unknownError`),duration:3e3})});an.current=i,i.finally(()=>{an.current===i&&(an.current=null)})},[r,Be,a,H,Ve,Qt]),dr=G(e=>{yt&&(e.preventDefault(),e.stopPropagation(),tn.current++,e.dataTransfer?.types?.includes(`Files`)&&It(!0))},[yt]),fr=G(e=>{yt&&(e.preventDefault(),e.stopPropagation())},[yt]),mr=G(e=>{yt&&(e.preventDefault(),e.stopPropagation(),tn.current--,tn.current===0&&It(!1))},[yt]),hr=G(e=>{if(yt&&(e.preventDefault(),e.stopPropagation(),tn.current=0,It(!1),e.dataTransfer?.files&&e.dataTransfer.files.length>0)){let t=Array.from(e.dataTransfer.files);gt(t)}},[gt,yt]),gr=G(async()=>{if(Nt)return;let e=`stop-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,t={timestamp:Date.now(),workflow_run_id:r,type:Q.IDLE,message:`Stopped. Waiting for your command...`,workstream_id:`main`,details:{_optimistic:!0,_messageId:e,_deliveryStatus:`sending`,display_role:`user_stopped`,status_reason:`user_stopped`}};qe(t),Pt(!0);try{await Be.agents.sendSignal(r,`Stop`,{message:`User requested stop`,client_message_id:e,metadata:{id:e,_messageId:e}}),Je(e,`received`)}catch(t){Ve({status:`error`,title:H(`agent.failedToInterrupt`),description:t instanceof Error?t.message:H(`agent.unknownError`),duration:3e3}),Je(e,`failed`)}finally{Pt(!1)}},[Nt,r,qe,Be.agents,Ve,H,Je]),_r=G(async()=>{if(!(Dt||Fn||!kn)){Ot(!0);try{await Be.agents.sendSignal(r,`TriggerCheckpoint`,{reason:`manual user request`})}catch(e){Ve({status:`error`,title:H(`agent.failedToCompactContext`),description:e instanceof Error?e.message:H(`agent.unknownError`),duration:3e3})}finally{Ot(!1)}}},[r,Be.agents,Fn,Dt,kn,H,Ve]);K(()=>(he&&(he.current=h&&!Fn?gr:null),()=>{he&&(he.current=null)}),[he,Fn,gr,h]),K(()=>{ge?.(Nt)},[Nt,ge]);let vr=i||H(`agent.agentConversation`),yr=async()=>{try{let e=await Gl(Be,r);e&&window.open(e,`_blank`)}catch(e){console.error(`Failed to download conversation`,e),Ve({status:`error`,title:H(`agent.failedToDownload`),duration:3e3})}},br=G(()=>{let e=new Date().toISOString(),t=Ue.size>0?[{cursor:`live`,streamingMessages:Array.from(Ue,([e,t])=>({id:e,...t}))}]:void 0,n={metadata:{title:vr,agent_run_id:r,exported_at:e,message_count:He.length},messages:He,...t?{streamingFrames:t}:{}};hy(`${my(vr)||`agent-chat`}-${my(r)}.json`,n),Ve({status:`success`,title:H(`agent.rewind.fixtureExported`),duration:2e3})},[vr,r,He,Ue,H,Ve]),[xr,Sr]=Y(!1),Cr=()=>{if(!St.current){Ve({status:`error`,title:H(`agent.pdfExportFailed`),description:H(`agent.noConversationContent`),duration:3e3});return}Sr(!0)},wr=()=>{if(!St.current){Ve({status:`error`,title:H(`agent.pdfExportFailed`),description:H(`agent.noConversationContent`),duration:3e3});return}let e=`${vr} - ${r}`;if(!fy(St.current,e)){Ve({status:`error`,title:H(`agent.pdfExportFailed`),description:H(`agent.unableToOpenPrint`),duration:4e3});return}Ve({status:`success`,title:H(`agent.pdfExportReady`),description:H(`agent.printDialogDescription`),duration:4e3}),Sr(!1)},Tr=q(()=>He.filter(e=>e.type===Q.COMPLETE||e.type===Q.THOUGHT&&e.details?.tool_status===`completed`).length,[He]),Er=q(()=>_n.plan.plan?.reduce((e,t)=>(t.id&&t.goal&&e.set(t.id.toString(),t.goal),e),new Map),[_n.plan]),Dr=e=>t(ig,{title:vr,variant:e,isCompleted:Fn,isTerminal:dn,onClose:s,isModal:c,agentRunId:r,workflowRunId:Qe||``,viewMode:jt,onViewModeChange:Mt,showPlanPanel:A&&rt,hasPlan:A&&et.length>0,showPlanButton:A&&!Pe,onTogglePlanPanel:Gn,showPlaybackButton:wn,isPlaybackEnabled:Tn,onTogglePlayback:Un,onDownload:yr,onExportFixture:br,resetWorkflow:d,onClone:p,onShowDetails:m,allowWorkflowControl:h,onExportPdf:Cr,isReceivingChunks:Ke}),Or=n(`div`,{ref:St,"data-agent-playback-enabled":Tn||void 0,"data-agent-playback-cursor":Tn?On:void 0,"data-agent-live-message-count":He.length,"data-agent-rendered-message-count":jn.length,className:V(`flex flex-col min-h-0 min-w-0 border-0`,Pe?`flex-1 h-full`:$n?`w-full flex-1 min-h-[50vh]`:l?`flex-1 w-full`:`flex-1 mx-auto ${c?``:`max-w-4xl`}`),children:[!w&&T===`compact`&&t(`div`,{className:`flex flex-shrink-0 justify-end border-b border-border/60 px-2 py-1 lg:hidden`,children:Dr(`compact`)}),!w&&T!==`compact`&&t(`div`,{className:`flex-shrink-0`,children:Dr(T)}),Tn&&t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(to,{cursor:On,messages:En,onChangeCursor:Wn})}),He.length===0&&!Fn&&Fe&&Ie?t(dy,{message:Fe,startedAt:Ie}):t(Om,{messages:jn,workstreamSourceMessages:He,bottomRef:xt,isCompleted:In,plan:_n.plan,workstreamStatus:_n.workstreamStatus,showPlanPanel:A&&rt,onTogglePlanPanel:Gn,plans:et,activePlanIndex:U,onChangePlan:Kn,taskLabels:Er,streamingMessages:Mn,onSendMessage:kn?ir:void 0,messageItemClassNames:_e,messageStyleOverrides:ve,toolCallGroupClassNames:ye,hideToolCallsInViewMode:be,streamingMessageClassNames:xe,batchProgressPanelClassNames:Se,artifactRunId:r,viewMode:jt,hideWorkstreamTabs:k,workingIndicatorClassName:Ce,messageListClassName:we,StoreLinkComponent:nr,CollectionLinkComponent:Ee,prependFriendlyMessage:De,initialRequestData:Oe,initialRequestSchema:ke,initialRequestTitle:Ae,initialRequestTemplate:je,showInitialRequest:Ge===`empty`&&He.length===0,hiddenMessageTypes:P,disableAutoScroll:!kn,renderRequestInputControls:!Rn,activeWorkstream:Lt,onActiveWorkstreamChange:Rt}),Rn?t(Mu,{message:Ln,onSendMessage:kn?ir:void 0,onMcpConnected:kn?ar:void 0,disabled:L||!kn,isLoading:Tt||L}):zn&&Pn.length>0?t(`div`,{className:`flex-shrink-0 pb-safe-area`,children:t(Qh,{activeWorkstreams:Pn})}):Bn&&t(`div`,{className:`flex-shrink-0 pb-safe-area`,children:mn?D??t(re,{status:`error`,icon:null,className:`m-2`,children:`This Workflow is FAILED`}):un&&un!==`RUNNING`&&!fn?jt===`sliding`&&un===`COMPLETED`?t(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-3 text-sm text-muted`,children:n(`div`,{className:`flex items-center gap-2 border-t border-success/25 pt-3 text-success`,children:[t(wt,{className:`size-4`}),t(`span`,{className:`font-medium`,children:`Workflow completed`})]})}):n(re,{status:un===`COMPLETED`?`success`:`done`,icon:null,className:`m-2`,children:[`This Workflow is `,un]}):(nt||fn)&&t(Bv,{onSend:ir,onStop:h?gr:void 0,approvalModeSlot:a&&Qt?t(ba,{mode:Qt,onChange:ur,disabled:!kn||dn||!h}):void 0,mcpSlot:t(Gm,{disabledCollections:or,onChange:cr,onConnectionChange:lr}),disabled:L||!kn,isSending:Tt||L,isStopping:Nt,isStreaming:!Fn,isCompleted:Fn,contextWindowUsage:Hn?Vn:void 0,onCompactContext:Hn?_r:void 0,isCompactingContext:Dt,activeTaskCount:xn,activeWorkstreams:bn,placeholder:Cn,onFilesSelected:yt?gt:void 0,uploadedFiles:g,onRemoveFile:_,onRemoveProcessingFile:bt,acceptedFileTypes:v,maxFiles:y,processingFiles:mt,artifactRunId:r,hasProcessingFiles:ht,renderDocumentSearch:b,selectedDocuments:x,onRemoveDocument:S,hideObjectLinking:C,hideFileUpload:!yt,disableDropZone:yt,className:te,inputClassName:z})})]}),kr=t(Sa,{children:t(Hu,{children:n(`div`,{ref:Ct,className:V(`flex flex-col lg:flex-row gap-2 w-full h-full relative overflow-hidden`,yt&&Ft&&`ring-2 ring-blue-400 ring-inset`,ee),onDragEnter:yt?dr:void 0,onDragOver:yt?fr:void 0,onDragLeave:yt?mr:void 0,onDrop:yt?hr:void 0,children:[yt&&Ft&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-blue-100/80 dark:bg-blue-900/40 z-50 pointer-events-none rounded-lg`,children:n(`div`,{className:`text-blue-600 dark:text-blue-400 font-medium flex items-center gap-2 text-lg`,children:[t(pr,{className:`size-6`}),`Drop files to upload`]})}),!Pe&&Or,!Pe&&T===`compact`&&!w&&t(`div`,{className:`hidden h-full w-12 shrink-0 items-start justify-center px-1 pt-2 lg:flex`,children:Dr(`compact`)}),$n&&n(e,{children:[!Pe&&t(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize right panel`,"aria-valuenow":Math.round(Yn),"aria-valuemin":300,"aria-valuetext":`${Math.round(Yn)} pixels`,tabIndex:0,className:`hidden lg:block lg:w-1 lg:shrink-0 cursor-col-resize bg-border/70 hover:bg-border transition-colors`,onMouseDown:()=>Qn(!0),onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.shiftKey?32:16,n=e.key===`ArrowLeft`?t:-t,r=Ct.current,i=r?Math.max(300,r.getBoundingClientRect().width-420):900;Xn(e=>Math.min(Math.max(e+n,300),i))}}),t(`div`,{className:Pe?`w-full h-full overflow-auto`:`w-full lg:w-[var(--agent-right-panel-width)] lg:shrink-0 min-h-[50vh] lg:h-full border-t lg:border-t-0`,style:Pe?void 0:{"--agent-right-panel-width":`${Yn}px`},children:t(Ah,{plan:_n.plan,workstreamStatus:_n.workstreamStatus,plans:et,activePlanIndex:U,onChangePlan:Kn,showPlan:!O&&rt,activeWorkstreams:yn,hideWorkstreams:k,openDocuments:at,activeDocumentId:ot,onSelectDocument:dt,onCloseDocument:ut,onUpdateDocumentTitle:pt,docRefreshKey:ct,runId:r,processingFiles:le??mt,showArtifacts:M,artifactRefreshKey:Tr,messages:He,payloadContent:Me,conversationContent:Pe?Or:Ne,onClose:er,defaultTab:qn,activeTab:qn,onTabChange:Jn})})]}),n(ie,{isOpen:xr,onClose:()=>Sr(!1),children:[t(se,{children:`Export conversation as PDF`}),n(ae,{children:[t(`p`,{className:`mb-2`,children:`This will open your browser's print dialog with the current conversation.`}),t(`p`,{className:`text-sm text-muted`,children:`To save a PDF, choose "Save as PDF" or a similar option in the print dialog.`})]}),n(oe,{align:`right`,children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>Sr(!1),children:`Cancel`}),t(o,{size:`sm`,onClick:wr,children:`Open print dialog`})]})]})]})})});return ne?t(Ci,{data:ne,sendMessage:ir,ChartComponent:Ba,artifactRunId:r,children:kr}):kr}function by({messages:e}){return t(`div`,{className:`flex flex-col overflow-y-auto space-y-6 py-4`,children:W.useMemo(()=>[...e].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),[e]).map(e=>t(kd,{message:e,showPulsatingCircle:!1},`${e.workstream_id??`main`}-${e.timestamp}-${e.type}`))})}function xy({messages:e,bottomRef:n,className:r,messagesClassName:i,emptyClassName:a}){let o=W.useRef(null);K(()=>{n.current&&n.current.scrollIntoView({behavior:`smooth`})},[e,n]);let s=W.useMemo(()=>[...e].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),[e]);return t(`div`,{ref:o,className:`flex-1 min-h-0 h-full overflow-y-auto py-4 px-4 sm:px-6 lg:px-8 bg-white flex flex-col ${r||``}`,"data-testid":`messages-container`,children:s.length===0?t(`div`,{className:`flex items-center justify-center h-full text-center py-8 ${a||``}`,children:t(`div`,{className:`flex items-center px-4 py-3 text-gray-500`,children:`Waiting for agent response...`})}):t(`div`,{className:`flex-1 flex flex-col justify-start h-full min-h-0 ${i||``}`,children:t(by,{messages:s,isCompleted:!1})})})}$i.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${$i.version}/build/pdf.worker.min.mjs`;function Sy({className:e,size:n=`md`}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(Dn,{className:`${{sm:`w-4 h-4`,md:`w-6 h-6`,lg:`w-8 h-8`}[n]} animate-spin text-muted-foreground`})})}function Cy({pdfUrl:e,pageNumber:r,width:i,className:a,renderTextLayer:o=!1,renderAnnotationLayer:s=!1,onLoadSuccess:c,onError:l}){let[u,d]=Y(!0),[f,p]=Y(null);return f?t(`div`,{className:`flex items-center justify-center text-destructive text-sm ${a||``}`,children:`Failed to load PDF`}):n(`div`,{className:a,children:[u&&t(Sy,{className:`py-4`,size:`md`}),t(Zi,{file:e,onLoadSuccess:({numPages:e})=>{d(!1),c?.(e)},onLoadError:e=>{d(!1),p(e),l?.(e)},loading:null,children:t(Qi,{pageNumber:r,width:i,renderTextLayer:o,renderAnnotationLayer:s,loading:t(Sy,{className:`py-4`,size:`sm`})})})]})}const wy=nt(null);function Ty({pdfUrl:e,urlLoading:n=!1,children:r,onLoadSuccess:i}){let[a,o]=Y(0),[s,c]=Y(!0),[l,u]=Y(null),[d,f]=Y(null),p=async e=>{o(e.numPages),i?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1});f({width:t.width,height:t.height,aspectRatio:t.width/t.height})}catch(e){console.error(`Failed to get page dimensions:`,e)}c(!1)},m=e=>{c(!1),u(e)},h={pdfUrl:e,numPages:a,loading:n||!e||s,error:l,pageDimensions:d};return l?t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`}):t(wy.Provider,{value:h,children:e?t(Zi,{file:e,onLoadSuccess:p,onLoadError:m,loading:t(Sy,{className:`py-4`,size:`md`}),children:r((e,n)=>t(Qi,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(Sy,{className:`py-4`,size:`sm`})},e))}):t(Sy,{className:`py-4`,size:`md`})})}function Ey(){return at(wy)}const Dy=210/297;function Oy({pageNumber:e,width:n,className:r}){let i=Ey(),a=i?.pageDimensions?.aspectRatio??Dy,o=n?Math.round(n/a):200;return i?.loading?t(`div`,{className:`flex items-center justify-center bg-muted ${r||``}`,style:{height:o,width:n||`100%`},children:t(Sy,{size:`md`})}):t(`div`,{className:r,children:t(Qi,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(Sy,{className:`py-4`,size:`sm`})})})}function ky({pageNumber:e,width:n,isSelected:r,onSelect:i,renderThumbnail:a,aspectRatio:o=Dy,rootMargin:s=`200px 0px`}){let c=J(null),[l,u]=Y(!1);K(()=>{let e=c.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0]?.isIntersecting&&u(!0)},{rootMargin:s,threshold:0});return t.observe(e),()=>t.disconnect()},[s]);let d=n?Math.round(n/o):200;return t(`div`,{ref:c,children:a({pageNumber:e,isSelected:r,pageElement:l?t(Qi,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d},children:t(Sy,{size:`sm`})})}):t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d,width:n||`100%`},children:t(`span`,{className:`text-muted-foreground text-xs`,children:e})}),onSelect:i})})}function Ay(e){if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return null}function jy({pdfUrl:r,urlLoading:i=!1,pageCount:a,currentPage:o,thumbnailWidth:s,onPageSelect:c,renderThumbnail:l,scrollContainerRef:u,onAspectRatioChange:d,onItemHeightChange:f,calculateItemHeight:p,onPageCountChange:m}){let[h,g]=Y(null),[_,v]=Y({start:0,end:Math.min(15,a)}),[y,b]=Y(null),x=J(null),S=G(e=>{g(e)},[]),C=G(async e=>{m?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1}),n=t.width/t.height;b(n),d?.(n)}catch(e){console.error(`Failed to get page dimensions:`,e),b(Dy),d?.(Dy)}},[d,m]),w=y??Dy,T=s?Math.round(s/w):200,E=p?p(T):T+16+24+8;if(K(()=>{E>0&&y!==null&&f?.(E)},[E,y,f]),K(()=>{let e=u?.current||Ay(x.current);if(!e)return;let t=()=>{let t=e.scrollTop,n=e.clientHeight,r=Math.floor(t/E),i=Math.ceil((t+n)/E),o=Math.max(0,r-5),s=Math.min(a,i+5);v(e=>e.start!==o||e.end!==s?{start:o,end:s}:e)};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[E,a,u]),h)return t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`});if(i||!r)return t(Sy,{className:`py-4`,size:`md`});let D=_.start*E,O=(a-_.end)*E,k=y!==null;return t(`div`,{ref:x,children:t(Zi,{file:r,onLoadSuccess:C,onLoadError:S,loading:t(Sy,{className:`py-4`,size:`md`}),children:k?n(e,{children:[D>0&&t(`div`,{style:{height:D}}),Array.from({length:_.end-_.start},(e,n)=>{let r=_.start+n+1;return t(`div`,{"data-page-index":r-1,style:{height:E,overflow:`hidden`},children:t(ky,{pageNumber:r,width:s,isSelected:r===o,onSelect:()=>c(r),renderThumbnail:l,aspectRatio:w})},r)}),O>0&&t(`div`,{style:{height:O}})]}):t(Sy,{className:`py-4`,size:`md`})})})}function My({pdfUrl:e,pageNumber:r,width:i,height:a,className:o,renderTextLayer:s=!1,renderAnnotationLayer:c=!1,onPageChange:l}){let[u,d]=Y(0),[f,p]=Y(!0),[m,h]=Y(null);return K(()=>{u>0&&l?.(r,u)},[r,u,l]),m?t(`div`,{className:`flex items-center justify-center text-destructive ${o||``}`,children:n(`span`,{children:[`Failed to load PDF: `,m.message]})}):n(`div`,{className:o,children:[f&&t(Sy,{className:`py-8`,size:`lg`}),t(Zi,{file:e,onLoadSuccess:({numPages:e})=>{d(e),p(!1)},onLoadError:e=>{p(!1),h(e)},loading:null,children:t(Qi,{pageNumber:Math.min(r,u||1),width:i,height:a,renderTextLayer:s,renderAnnotationLayer:c,loading:t(Sy,{className:`py-8`,size:`md`})})})]})}const Ny=[50,75,100,125,150,200,300];function Py({pdfUrl:r,pdfUrlLoading:i=!1,pageCount:a,currentPage:s,onChange:c,onPageCountChange:l,className:u,compact:d=!1,headerExtra:f}){let{t:m}=X(),h=J(null),g=J(null),[_,v]=Y(void 0),[y,b]=Y(100),[x,S]=Y(.7070707070707071),[C,w]=Y(null),T=J(null),E=_?Math.round(_*y/100):void 0,D=G(()=>{let e=Ny.findIndex(e=>e>=y);e===-1&&(e=Ny.length-1);let t=Math.min(e+1,Ny.length-1);b(Ny[t])},[y]),O=G(()=>{let e=Ny.findIndex(e=>e>=y);e===-1&&(e=Ny.length-1);let t=Math.max(e-1,0);b(Ny[t])},[y]),k=G(()=>{b(100)},[]),A=G(e=>e+(d?28:48),[d]),j=G((e,t)=>{let n=e?Math.round(e/t):200;return A(n)},[A]);K(()=>{let e=g.current;if(!e)return;let t=null,n=()=>e.clientWidth-16-16-4,r=()=>{let t=n();if(t<=0)return;let r=T.current;if(r&&r>0){let n=e.scrollTop,i=Math.round(n/r),a=j(t,x),o=i*a;v(t),requestAnimationFrame(()=>{e.scrollTo({top:o,behavior:`instant`})}),T.current=a}else v(t),T.current=j(t,x)},i=n();i>0&&(v(i),T.current=j(i,x));let a=new ResizeObserver(()=>{t&&clearTimeout(t),t=setTimeout(r,150)});return a.observe(e),()=>{t&&clearTimeout(t),a.disconnect()}},[x,j]);let M=J(!1),N=J(null),P=J(y);K(()=>{P.current!==y&&(P.current=y,N.current={targetPage:s},M.current=!0)},[y,s]),K(()=>{let e=g.current,t=N.current;if(t&&e&&C){N.current=null;let n=(t.targetPage-1)*C;requestAnimationFrame(()=>{e.scrollTo({top:n,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})})}},[C]);let F=J(!1);K(()=>{let e=g.current;if(!(!e||!C||F.current))if(s>1){F.current=!0,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}else F.current=!0},[C,s]);let I=J(s);return K(()=>{let e=g.current;if(!(!e||!C)&&I.current!==s){I.current=s,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}},[s,C]),K(()=>{let e=g.current;if(!e||!C)return;let t=null,n=()=>{M.current||(t&&clearTimeout(t),t=setTimeout(()=>{let t=e.scrollTop,n=Math.round(t/C)+1,r=Math.max(1,Math.min(n,a));r!==s&&(I.current=r,c(r))},50))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{t&&clearTimeout(t),e.removeEventListener(`scroll`,n)}},[C,a,s,c]),n(`div`,{ref:h,className:Ze(`flex flex-col items-stretch`,d?`gap-y-1`:`gap-y-2`,u),children:[n(`div`,{className:Ze(`relative flex items-center justify-center px-2`,d?`h-6`:`h-9`),children:[t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s>1&&c(s-1)},title:m(`pdf.previousPage`),children:t(Lt,{className:`size-4`})}),n(`div`,{className:`absolute start-2 flex items-center gap-x-1`,children:[t(Iy,{zoom:y,onZoomIn:D,onZoomOut:O,onFitToView:k,canZoomIn:y<Ny[Ny.length-1],canZoomOut:y>Ny[0]}),f&&n(e,{children:[t(`div`,{className:`w-px h-4 bg-border mx-1`}),f]})]}),t(`div`,{className:`absolute end-2`,children:t(Fy,{currentPage:s,totalPages:a,onChange:c})})]}),t(`div`,{ref:g,className:Ze(`flex flex-col items-center flex-1 overflow-y-auto px-2`,d?`gap-1`:`gap-2`),children:t(jy,{pdfUrl:r,urlLoading:i,pageCount:a,currentPage:s,thumbnailWidth:E,onPageSelect:c,onPageCountChange:l,scrollContainerRef:g,onAspectRatioChange:S,onItemHeightChange:w,calculateItemHeight:A,renderThumbnail:({pageNumber:e,isSelected:r,pageElement:i,onSelect:a})=>n(`div`,{className:Ze(`hover:bg-muted rounded-md w-full`,d?`p-1`:`p-2`),children:[t(o,{variant:`unstyled`,size:`none`,"aria-pressed":r,"aria-label":`Page ${e}`,className:Ze(`relative border-[2px] cursor-pointer overflow-hidden`,r?`border-primary`:`border-border`),onClick:a,children:i}),t(p,{className:Ze(`text-muted-foreground font-semibold`,d?`text-xs pt-0.5`:`text-sm pt-1`),children:e})]},e)})}),t(`div`,{className:Ze(`flex items-center justify-center`,d?`h-6`:`h-9`),children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s<a&&c(s+1)},title:m(`pdf.nextPage`),children:t(Pt,{className:`size-4`})})})]})}function Fy({currentPage:e,totalPages:r,onChange:i}){let{t:a}=X(),o=J(null),[s,c]=Y(String(e));K(()=>{c(String(e))},[e]);let l=()=>{let t=parseInt(s,10);!Number.isNaN(t)&&t>=1&&t<=r?i(t):c(String(e))};return n(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[t(`span`,{children:a(`pdf.page`)}),t(`input`,{ref:o,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:t=>{t.key===`Enter`?(l(),o.current?.blur()):t.key===`Escape`&&(c(String(e)),o.current?.blur())},onBlur:()=>{l()},className:`w-8 h-5 text-center text-xs px-1 py-0 bg-background border border-border rounded focus:outline-none focus:border-primary`}),n(`span`,{children:[`/ `,r]})]})}function Iy({zoom:e,onZoomIn:r,onZoomOut:i,onFitToView:a,canZoomIn:s,canZoomOut:c}){let{t:l}=X();return n(`div`,{className:`flex items-center gap-x-0.5`,children:[t(o,{variant:`ghost`,size:`xs`,onClick:i,isDisabled:!c,title:l(`pdf.zoomOut`),children:t(Pn,{})}),n(`span`,{className:`text-xs text-muted-foreground min-w-[32px] text-center`,children:[e,`%`]}),t(o,{variant:`ghost`,size:`xs`,onClick:r,isDisabled:!s,title:l(`pdf.zoomIn`),children:t(Un,{})}),t(o,{variant:`ghost`,size:`xs`,onClick:a,title:l(`pdf.fitToWidth`),className:e===100?`text-muted-foreground/40`:void 0,children:t(kn,{})})]})}function Ly({object:e,url:r,source:i,className:a}){let{t:s}=X(),{client:c}=Z(),[l,u]=Y(1),[d,f]=Y(r||``),[p,m]=Y(!r),[h,g]=Y(0),[_,v]=Y(!1);K(()=>{if(r){f(r),m(!1);return}let t=i||e?.content?.source;if(!t){m(!1);return}m(!0),c.files.getDownloadUrl(t).then(e=>{f(e.url)}).catch(e=>{console.error(`Failed to get PDF URL:`,e)}).finally(()=>{m(!1)})},[r,i,e?.content?.source,c]),K(()=>{let t=e?.metadata,n=t?.pages||t?.page_count||0;n>0&&g(n)},[e?.metadata]);let y=e=>{g(e)};return p?t(`div`,{className:`flex items-center justify-center h-full`,children:t(Ee,{size:`lg`})}):d?_?n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col overflow-hidden`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>v(!1),title:s(`pdf.closeFullscreen`),children:t(yr,{className:`size-4`})})}),t(Py,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:`flex-1 min-h-0`})]}):t(`div`,{className:`relative h-full flex flex-col`,children:t(Py,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:a,compact:!0,headerExtra:t(o,{title:s(`pdf.fullscreen`),tooltipPlacement:`bottom`,variant:`unstyled`,className:`p-1 rounded cursor-pointer transition-colors text-muted-foreground hover:text-foreground hover:bg-muted`,onClick:()=>v(!0),children:t(An,{className:`size-4`})})})}):t(`div`,{className:`flex items-center justify-center h-full text-muted`,children:s(`pdf.noPdfAvailable`)})}var Ry=aa({UniversalDocumentViewer:()=>lb});function zy(e){return e.fileName||e.title||e.artifact?.path.split(`/`).pop()||e.sourcePath?.split(`/`).pop()||`Document`}function By(e){let t=e.split(`?`)[0]||e;return t.includes(`.`)&&t.split(`.`).pop()?.toLowerCase()||``}function Vy(e){return e.contentType===`application/pdf`||e.extension===`pdf`}function Hy(e){return[`md`,`markdown`].includes(e.extension)||[`text/markdown`,`text/x-markdown`].includes(e.contentType||``)}function Uy(e){return e.contentType?.startsWith(`image/`)||[`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`].includes(e.extension)}function Wy(e){return e.contentType===`text/html`||[`html`,`htm`].includes(e.extension)}function Gy(e){return[`application/xml`,`text/xml`].includes(e.contentType||``)||e.extension===`xml`}function Ky(e){return e.contentType?.startsWith(`text/`)||[`css`,`csv`,`json`,`txt`,`tsx`,`ts`,`jsx`,`js`,`xml`,`yaml`,`yml`].includes(e.extension)}function qy(e){return[`tsx`,`jsx`].includes(e.extension)}function Jy(e){return[`doc`,`docx`,`ppt`,`pptx`].includes(e.extension)||[`application/msword`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.ms-powerpoint`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`].includes(e.contentType||``)}function Yy({content:e,extension:n}){return t(`pre`,{className:`h-full overflow-auto rounded-md bg-muted/10 p-3 text-xs leading-5`,children:t(`code`,{className:n?`language-${n}`:void 0,children:e||``})})}function Xy({message:e}){return n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-muted`,children:[t(nn,{className:`size-8`}),t(`span`,{className:`text-sm`,children:e})]})}function Zy(e,n){if(e.Component){let r=e.Component;return t(r,{context:n})}return e.render?.(n)??null}function Qy(e,t){return e.includes(`.`)?e.replace(/\.[^/.]+$/,t):`${e}${t}`}function $y(e){return e.split(`/`).pop()||e}function eb(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function tb(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function nb(e){if(e!==void 0)return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function rb(e){return Array.isArray(e)?e.length:0}function ib(e){try{let t=eb(JSON.parse(e));if(!t)return;let n=eb(t.viewport);return{ok:typeof t.ok==`boolean`?t.ok:void 0,source_artifact:typeof t.source_artifact==`string`?t.source_artifact:void 0,screenshot_artifact:typeof t.screenshot_artifact==`string`?t.screenshot_artifact:void 0,rendered_at:typeof t.rendered_at==`string`?t.rendered_at:void 0,viewport:n?{width:tb(n.width),height:tb(n.height)}:void 0,dependencies_reused:typeof t.dependencies_reused==`boolean`?t.dependencies_reused:void 0,status:tb(t.status),title:typeof t.title==`string`?t.title:void 0,console_errors:Array.isArray(t.console_errors)?t.console_errors:void 0,page_errors:Array.isArray(t.page_errors)?t.page_errors:void 0,failed_requests:Array.isArray(t.failed_requests)?t.failed_requests:void 0,bad_responses:Array.isArray(t.bad_responses)?t.bad_responses:void 0,timings_ms:eb(t.timings_ms),error:t.error}}catch{return}}async function ab(e,t){let n=await fetch(e);if(!n.ok)throw Error(`Failed to load ${t}: ${n.statusText}`);return n.text()}function ob({metadata:e,sourcePath:t,fallbackPath:n,artifactMode:r}){let i=e?.screenshot_artifact?.replace(/^\/+/,``);if(!i)return n;if(r)return i;let a=e?.source_artifact?.replace(/^\/+/,``),o=t.replace(/^\/+/,``);if(a&&o.endsWith(a)){let e=o.slice(0,-a.length).replace(/\/+$/,``);return e?`${e}/${i}`:i}let s=o.includes(`/`)?o.slice(0,o.lastIndexOf(`/`)+1):``;return s?`${s}${$y(i)}`:n}function sb({metadata:e}){if(!e)return null;let r=tb(e.timings_ms?.total_before_cleanup),a=rb(e.console_errors)+rb(e.page_errors)+rb(e.failed_requests)+rb(e.bad_responses);return n(`div`,{className:`grid gap-2 border-b p-3 text-xs`,children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.ok!==void 0&&t(i,{variant:e.ok?`success`:`destructive`,children:e.ok?`render ok`:`render failed`}),e.dependencies_reused!==void 0&&n(i,{variant:e.dependencies_reused?`info`:`secondary`,children:[`deps `,e.dependencies_reused?`reused`:`installed`]}),e.status&&n(i,{variant:`secondary`,children:[`HTTP `,e.status]}),a>0&&n(i,{variant:`attention`,children:[a,` browser issue(s)`]})]}),n(`div`,{className:`grid gap-1 text-muted sm:grid-cols-2`,children:[e.viewport?.width&&e.viewport.height&&n(`div`,{children:[`Viewport `,e.viewport.width,` x `,e.viewport.height]}),nb(r)&&n(`div`,{children:[`Total `,nb(r)]}),e.rendered_at&&n(`div`,{children:[`Rendered `,new Date(e.rendered_at).toLocaleString()]}),e.title&&n(`div`,{className:`truncate`,children:[`Title `,e.title]})]}),typeof e.error==`string`&&t(`div`,{className:`text-destructive`,children:e.error})]})}function cb({context:e}){let{client:r}=Z(),a=e.source.artifact,o=a?.path||e.source.sourcePath,s=!!a,c=e.content||``,[l,u]=Y({isLoading:!1}),d=G(async(e,t)=>a?(await r.files.getArtifactDownloadUrl(a.runId,e,t)).url:(await r.files.getDownloadUrl(e,$y(e),t)).url,[a,r]);return K(()=>{if(!o){u({isLoading:!1,previewError:`No source path is available for this TSX artifact.`});return}let e=o,t=!1,n=Qy(e,`.png`),r=Qy(e,`.render.json`);async function i(){u({isLoading:!0});let i,a,o=n;try{i=ib(await ab(await d(r,`inline`),$y(r))),o=ob({metadata:i,sourcePath:e,fallbackPath:n,artifactMode:s})}catch(e){a=e instanceof Error?e.message:`Render metadata is not available`}let c,l;try{c=await d(o,`inline`)}catch(e){l=e instanceof Error?e.message:`Sandbox render image is not available`}t||u({isLoading:!1,imageUrl:c,metadata:i,metadataError:a,previewError:l})}return i(),()=>{t=!0}},[s,d,o]),n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 border-b px-3 py-2 text-sm`,children:[t(vn,{className:`size-4 text-info`}),t(`span`,{className:`font-medium`,children:`Sandbox render`}),l.isLoading?t(i,{variant:`secondary`,children:`loading`}):l.imageUrl?t(i,{variant:`success`,children:`PNG preview`}):t(i,{variant:`attention`,children:`source only`}),l.metadata?.rendered_at&&t(`span`,{className:`text-xs text-muted`,children:new Date(l.metadata.rendered_at).toLocaleString()})]}),l.isLoading?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(On,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading sandbox render...`})]}):l.imageUrl?n(`div`,{className:`grid min-h-0 flex-1 xl:grid-cols-[minmax(0,1fr)_minmax(24rem,0.7fr)]`,children:[t(`div`,{className:`flex min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:l.imageUrl,alt:`${e.fileName} sandbox render`,className:`max-h-full max-w-full rounded-md object-contain`})}),n(`div`,{className:`min-h-0 overflow-auto border-t xl:border-s xl:border-t-0`,children:[t(sb,{metadata:l.metadata}),t(`div`,{className:`p-3`,children:t(Yy,{content:c,extension:e.extension})})]})]}):n(`div`,{className:`grid min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]`,children:[n(`div`,{className:`border-b px-3 py-2 text-xs text-muted`,children:[`No sandbox-rendered PNG was found for this TSX artifact. Showing the source without executing it in Studio.`,l.previewError&&n(`span`,{className:`ms-1`,children:[`Preview lookup: `,l.previewError]}),!l.previewError&&l.metadataError&&n(`span`,{className:`ms-1`,children:[`Metadata lookup: `,l.metadataError]})]}),n(`div`,{className:`min-h-0 overflow-auto p-3`,children:[t(sb,{metadata:l.metadata}),t(Yy,{content:c,extension:e.extension})]})]})]})}function lb({source:e,className:r,bodyClassName:i,renderers:a=[],converters:s=[],resolveUrl:c,loadText:l,createRendition:u,markdownComponents:d,showHeader:f=!0,onDownload:p}){let{client:m}=Z(),h=q(()=>zy(e),[e]),g=q(()=>By(h),[h]),[_,v]=Y(e.url),[y,b]=Y(e.content),[x,S]=Y(null),[C,w]=Y(!1),[T,E]=Y(null),[D,O]=Y(0),k=[e.id,e.title,e.fileName,e.contentType,e.url,e.sourcePath,e.content,e.artifact?.runId,e.artifact?.path].join(`\0`),A=G(async(e,t)=>e.url?e.url:e.artifact?(await m.files.getArtifactDownloadUrl(e.artifact.runId,e.artifact.path,t)).url:e.sourcePath?(await m.files.getDownloadUrl(e.sourcePath,e.fileName,t)).url:``,[m]),j=c||A,M=G(async e=>{if(e.content!==void 0)return e.content;let t=await j(e,`inline`);if(!t)return``;let n=await fetch(t);if(!n.ok)throw Error(`Failed to load ${zy(e)}: ${n.statusText}`);return n.text()},[j]),N=l||M,P={source:e,fileName:h,extension:g,contentType:e.contentType||x?.contentType,url:x?.url||_,content:x?.content||y,isLoading:C,error:T,reload:()=>O(e=>e+1)},F=a.find(e=>e.canRender(P)),I=!F&&(Hy(P)||Wy(P)||Gy(P)||Ky(P)),L=!F&&(Vy(P)||Uy(P)),R={source:e,fileName:h,extension:g,contentType:e.contentType,target:`pdf`},ee=!F&&!P.url?s.find(e=>e.target===`pdf`&&e.canConvert(R)):void 0,te=!F&&!P.url&&(Jy(P)||!!ee)&&(!!ee||!!u);K(()=>{let t=!1,n=e;E(null),v(n.url),b(n.content),S(null);async function r(){if(!(!I&&!L&&!te)){w(!0);try{if(te){let e=ee?await ee.convert({source:n,fileName:h,extension:g,contentType:n.contentType,target:`pdf`}):await u?.(n,`pdf`);t||S(e??null);return}if(I){let e=await N(n);t||b(e);return}if(L){let e=await j(n,`inline`);t||v(e)}}catch(e){t||E(e instanceof Error?e.message:`Failed to load document`)}finally{t||w(!1)}}}return r(),()=>{t=!0}},[u,g,h,N,te,I,L,D,j,ee,e,k]);let z={...P,url:x?.url||_,content:x?.content||y,contentType:x?.contentType||e.contentType,isLoading:C,error:T},ne;return ne=C?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(On,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading preview...`})]}):T?n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-destructive`,children:[t(mt,{className:`size-7`}),t(`span`,{className:`max-w-xl text-center text-sm`,children:T}),t(o,{variant:`outline`,size:`sm`,onClick:z.reload,children:`Retry`})]}):F?Zy(F,z):(Vy(z)||x?.contentType===`application/pdf`)&&z.url?t(Ly,{url:z.url,className:`h-full`}):Uy(z)&&z.url?t(`div`,{className:`flex h-full min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:z.url,alt:h,className:`max-h-full max-w-full rounded-md object-contain`})}):Hy(z)?t(`div`,{className:`prose prose-sm dark:prose-invert max-w-none px-5 py-4`,children:t(Li,{artifactRunId:e.artifact?.runId,components:d,children:z.content||``})}):Wy(z)?t(`iframe`,{title:h,className:`h-full min-h-96 w-full bg-white`,sandbox:``,srcDoc:z.content||``}):Gy(z)?t(`div`,{className:`px-4 py-2`,children:t(Hi,{xml:z.content||``,collapsible:!0})}):qy(z)?t(cb,{context:z}):Ky(z)?t(Yy,{content:z.content,extension:g}):Jy(z)&&!ee&&!u?t(Xy,{message:`This file needs a PDF rendition before it can be previewed.`}):t(Xy,{message:`Preview is not available for this file type.`}),n(`div`,{className:V(`flex h-full min-h-0 flex-col overflow-hidden`,r),children:[f&&n(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b py-2 ps-3 pe-16`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,title:h,children:h}),z.contentType&&t(`div`,{className:`truncate text-xs text-muted`,children:z.contentType})]}),p&&t(o,{variant:`outline`,size:`sm`,onClick:()=>p(e),children:`Download`})]}),t(`div`,{className:V(`min-h-0 flex-1 overflow-auto`,i),children:ne})]})}function ub(e){return e.name}function db({isClearable:e=!1,onChange:n,ignoreVirtuals:r=!1,selectedEnvId:i,disabled:a=!1}){let{t:o}=X(),{client:s}=Z(),[c,l]=Y(),{data:u,isLoading:d}=We(()=>s.environments.list().then(e=>(r?e.filter(e=>!e.provider.startsWith(`virtual_`)):e).slice().sort((e,t)=>e.name.localeCompare(t.name))));return K(()=>{l(u?.find(e=>e.id===i))},[u,i]),t(ye,{isClearable:e,optionLabel:ub,options:u??[],value:c,onChange:e=>{l(e),n(e)},placeholder:o(`intakePolicy.placeholder.environment`),filterBy:`name`,disabled:a,isLoading:d})}function fb(e){return e.name}function pb(e){return e?.length?n=>t(`span`,{className:e.some(e=>e.id===n.id)?`opacity-50`:``,children:n.name}):fb}function mb({envId:e,isClearable:n,onChange:r,selectedModelId:i,disabled:a=!1,greyedModels:o,onModelsLoaded:s}){let{t:c}=X(),{client:l}=Z(),[u,d]=Y(),{data:f,isLoading:p}=Ue(async()=>{if(!e)return[];try{return[...(await l.environments.retrieve(e)).enabled_models??[]].sort((e,t)=>e.name.localeCompare(t.name))}catch{return[]}},[e]);return K(()=>{if(!i){d(void 0);return}let e=f?.find(e=>e.id===i);d(e??{id:i,name:i,provider:`unknown`})},[f,i]),K(()=>{f&&s?.(f)},[f,s]),t(ye,{isClearable:n,by:`id`,optionLabel:pb(o),options:f??[],value:u,onChange:e=>{d(e),r(e)},placeholder:c(`intakePolicy.placeholder.model`),disabled:a,isLoading:p})}function hb({env:e,isClearable:n,onChange:r}){let{t:i}=X(),{client:a}=Z(),[o,s]=Y(),{data:c,isLoading:l}=Ue(async()=>{if(!e)return[];try{return a.environments.listTrainableModels(e.id)}catch{return[]}},[e?.id]);return t(ye,{isClearable:n,by:`id`,optionLabel:fb,options:c??[],value:o,onChange:e=>{s(e),r(e)},placeholder:i(`intakePolicy.placeholder.model`),disabled:!e,isLoading:l})}function gb({children:e,fallback:n}){return _b?t(_b,{fallback:n,children:e}):t(ea,{FallbackComponent:n,children:e})}let _b=null;function vb(e){_b=e}function yb({children:e}){return t(gb,{fallback:bb,children:e})}function bb({error:e}){let{t:r}=X(),i=e instanceof Error?e.message:void 0;return n(re,{status:`error`,title:r(`errors.somethingWentWrong`),children:[n(`div`,{className:`mb-4`,children:[r(`errors.teamNotifiedLine1`),` `,r(`errors.teamNotifiedLine2`),`\xA0`,t(`a`,{className:`text-info`,href:`mailto:support@vertesiahq.com`,children:`support@vertesiahq.com`}),`.`]}),i&&t(`code`,{className:`w-full mt-4 text-sm text-muted break-words`,children:i})]})}function xb({children:e}){return t(gb,{fallback:Sb,children:e})}function Sb({error:e}){let r=e instanceof Error?e.message:void 0;return t(`tr`,{children:n(`td`,{colSpan:100,children:[t(`span`,{className:`text-xs`,children:` Cannot display row`}),t(`br`,{}),t(`span`,{className:`bg-gray-400`,children:r})]})})}function Cb({children:e}){return t(gb,{fallback:wb,children:e})}function wb({error:e}){let r=e instanceof Error?e.message:void 0;return console.log(`WidgetError`,e),n(`div`,{className:`text-sm`,children:[`Sorry, this area cannot be loaded or rendered.`,r&&t(`pre`,{children:r})]})}const Tb=/^[a-f0-9]{24}$|^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$|^(?=.*\d)(?=.*[a-zA-Z])[a-zA-Z0-9_-]{8,}$/i;function Eb(e){return Tb.test(e)}function Db({className:e,children:r,title:i,description:o,actions:s,breadcrumbs:c,useDynamicBreadcrumbs:l=!0}){let u=Di();function d(e){return e.replace(/[-_]/g,` `).split(` `).map(e=>ii(e)).join(` `)}let f=e=>{if(e?.title)return e.title;let t=e?.href||``;if(!t)return`Page`;let n=t.split(`#`)[0].split(`?`)[0].split(`/`).filter(e=>e.length>0);return n.length>=1?d(n[n.length-1]):`Page`},p=(()=>{let e=[];if(l&&typeof window<`u`){let t=window.history.state?.historyChain;if(Array.isArray(t))t.forEach((n,r)=>{let i=t.length-r;e.push({label:f(n),href:n.href,onClick:()=>u(n.href,{stepsBack:i})})});else{let t=window.location.pathname.split(`/`).filter(e=>e.length>0);for(let n=0;n<t.length;n++)if(Eb(t[n])){let r=`/${t.slice(0,n).join(`/`)}`;e.push({label:d(t[n-1]||r),href:r,onClick:()=>u(r,{isBasePathNested:!1})})}}}return c&&c.length>0&&c.forEach(t=>{let n=t.props?.children||t,r=t.props?.href;e.push(r?{href:r,label:n,onClick:()=>u(r,{replace:t.props.clearBreadcrumbs})}:{label:n})}),e})();return n(`div`,{className:Ze(`pb-0 ps-4 pe-2 py-2 flex flex-col`,e),children:[n(`div`,{className:`flex items-start gap-4`,children:[n(`div`,{className:`w-full flex place-content-between h-auto min-h-8 flex-col items-start justify-center`,children:[n(`nav`,{className:`flex-1 flex justify-start text-sm`,children:[p.length>0&&t(a,{path:p,separator:t(jt,{className:`size-3.5 cn-rtl-flip`}),maxItems:4}),o&&t(ze,{description:o,children:t(yn,{className:`size-4 text-muted ms-4`})})]}),i&&t(`div`,{className:`flex gap-2 items-center`,children:t(`h1`,{className:`text-xl font-semibold break-all`,children:i})})]}),t(`div`,{className:`flex gap-x-2 shrink-0 items-center`,children:s})]}),r&&t(`div`,{className:`w-full flex items-center`,children:r})]})}function Ob(){let{t:e}=X();return n(`div`,{className:`text-center pt-32`,children:[t(`h1`,{className:`text-3xl font-bold text-red-500`,children:`404`}),t(`p`,{className:`text-2xl`,children:e(`layout.pageNotFound`)})]})}function kb({objectId:e,onExtractionChanged:r,selectedField:i,onClose:a}){let{t:o}=X(),{client:s}=Z(),[c,l]=Y(void 0),u=J(r);u.current=r;let d=J(i);d.current=i;let f=G(async t=>{let n=d.current,r=n&&t?`Regarding the field "${n}": ${t}`:t,i=await s.store.objects.analyze(e).startGroundedAssistant(r?{user_prompt:r}:{});return l(i.agent_run_id),{agent_run_id:i.agent_run_id}},[s,e]),p=G(e=>{e&&u.current?.()},[]);return n(`div`,{className:`flex h-full flex-col`,children:[i&&!c&&n(`div`,{className:`shrink-0 border-b border-border bg-muted/40 px-3 py-1.5 text-xs text-muted-foreground`,children:[o(`grounded.assistantField`),` `,t(`span`,{className:`font-mono text-foreground`,children:i})]}),t(gy,{agentRunId:c,startWorkflow:f,interactive:!0,fullWidth:!0,hideObjectLinking:!0,onShowInputChange:p,onClose:a})]})}const Ab=`magic-pdf`;function jb(e){return e.replace(/^\$\.?/,``).replace(/^data\./,``)}function Mb(e){let{client:t}=Z(),[n,r]=Y(!1);return K(()=>{let n=!1;return r(!1),t.files.getDownloadUrl(`${Ab}/${e}/grounded-extraction.json`).then(e=>fetch(e.url,{method:`HEAD`})).then(e=>{n||r(e.ok)}).catch(()=>{}),()=>{n=!0}},[t,e]),n}function Nb(e){let{client:t}=Z(),[n,r]=Y(null);return K(()=>{let n=!1;return r(null),t.files.getDownloadUrl(`${Ab}/${e}/grounded-extraction.json`).then(e=>fetch(e.url)).then(e=>e.ok?e.json():null).then(e=>{n||!e?.citations||r({confidence:e.confidence,verified:e.citations.filter(e=>e.verified).length,total:e.citations.length,verdict:e.verdict,verdict_reason:e.verdict_reason})}).catch(()=>{}),()=>{n=!0}},[t,e]),n}function Pb({objectId:e,onClose:r}){let{t:i}=X(),{client:a}=Z(),{data:s,error:c,isLoading:l,refetch:u}=Ue(async()=>{let t=await a.files.getDownloadUrl(`${Ab}/${e}/grounded-extraction.json`),n=await fetch(t.url);if(!n.ok)throw Error(i(`grounded.notFound`));return n.json()},[e]);return c?t(`div`,{className:`flex h-full items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:i(`grounded.failedToLoad`),children:H(c)}),r&&t(o,{variant:`outline`,onClick:r,children:i(`pdf.close`)})]})}):l||!s?t(`div`,{className:`flex h-full items-center justify-center`,children:t(Ee,{size:`lg`})}):t(`div`,{className:`relative h-full`,children:t(Ib,{extraction:s,objectId:e,onClose:r,onExtractionChanged:u})})}function Fb({objectId:e,onClose:n}){return t(`div`,{className:`fixed inset-0 bg-background z-50`,children:t(Pb,{objectId:e,onClose:n})})}function Ib({extraction:r,objectId:a,onClose:s,onExtractionChanged:c}){let{t:l}=X(),{client:u}=Z(),d=q(()=>Object.keys(r.pages).map(e=>parseInt(e,10)).sort((e,t)=>e-t),[r.pages]),f=e=>{u.files.getDownloadUrl(`${Ab}/${a}/${e}`).then(e=>window.open(e.url,`_blank`)).catch(()=>{})},[p,m]=Y(d[0]??1),[h,g]=Y(void 0),[_,v]=Y(!1),[y,b]=Y(!1),[x,S]=Y(`original`),[C,w]=Y(!1),T=q(()=>{let e={digital:0,ocr:0,reviewerConfirmed:0,snapped:0,imageRead:0},t=[];for(let n of r.citations)n.verified?n.snapped?e.snapped++:(n.confidence??0)>=1?e.digital++:e.ocr++:n.reviewed?e.reviewerConfirmed++:(e.imageRead++,t.push(n));let n=e.digital+e.ocr+e.snapped,i=e.reviewerConfirmed;return{groups:e,unverified:t,digitallyVerified:n,modelVerified:i,totalVerified:n+i}},[r.citations]),E=q(()=>{let e=new Map;for(let t of r.citations){let n=jb(t.path),r=e.get(n)??[];r.push(t),e.set(n,r)}return e},[r.citations]),D=r.citations.length,O=e=>{g(e);let t=E.get(jb(e))?.[0];t&&m(t.page)},k=d.indexOf(p),A=h?E.get(jb(h))?.find(e=>e.page===p):void 0,j=A?.cells?A.cells.start===A.cells.end?A.cells.start:`${A.cells.start}:${A.cells.end}`:void 0;return n(ve,{direction:`horizontal`,className:`absolute inset-0`,children:[n(_e,{defaultSize:55,minSize:25,className:`flex flex-col bg-muted`,children:[n(`div`,{className:`relative flex h-9 shrink-0 items-center justify-center bg-sidebar px-2 border-b border-sidebar-border`,children:[j&&t(i,{variant:`secondary`,className:`absolute start-2 max-w-32 truncate font-mono text-[11px]`,title:j,children:j}),n(`div`,{className:`flex items-center gap-2`,children:[t(o,{variant:`ghost`,size:`xs`,"aria-label":l(`grounded.previousPage`),disabled:k<=0,onClick:()=>m(d[k-1]),children:t(At,{className:`size-4`})}),t(`span`,{className:`text-xs text-muted-foreground`,children:l(`pdf.pageOf`,{pageNumber:p,totalPages:d.length})}),t(o,{variant:`ghost`,size:`xs`,"aria-label":l(`grounded.nextPage`),disabled:k>=d.length-1,onClick:()=>m(d[k+1]),children:t(jt,{className:`size-4`})})]}),n(`fieldset`,{className:`absolute end-2 flex items-center gap-0.5 rounded border-0 bg-muted p-0.5`,children:[t(`legend`,{className:`sr-only`,children:l(`grounded.checkerboard`)}),t(ze,{description:l(`pdf.originalImages`),placement:`bottom`,size:`xs`,asChild:!0,children:n(o,{variant:x===`original`?`outline`:`ghost`,size:`xs`,"aria-label":l(`pdf.originalImages`),"aria-pressed":x===`original`,className:`h-6 gap-1 px-1.5`,onClick:()=>S(`original`),children:[t(_n,{className:`size-3.5`}),t(`span`,{className:`hidden sm:inline`,children:l(`pdf.page`)})]})}),t(ze,{description:l(`grounded.checkerboard`),placement:`bottom`,size:`xs`,asChild:!0,children:n(o,{variant:x===`grid`?`outline`:`ghost`,size:`xs`,"aria-label":l(`grounded.checkerboard`),"aria-pressed":x===`grid`,className:`h-6 gap-1 px-1.5`,onClick:()=>S(`grid`),children:[t(mn,{className:`size-3.5`}),t(`span`,{className:`hidden sm:inline`,children:l(`grounded.checkerboard`)})]})})]})]}),t(`div`,{className:`flex-1 overflow-auto p-2`,children:t(Lb,{objectId:a,page:p,dims:r.pages[String(p)],citations:r.citations.filter(e=>e.page===p),selectedPath:h,onSelectPath:g,imageMode:x})})]}),t(ge,{className:`w-[4px] bg-border cursor-ew-resize`}),n(_e,{defaultSize:45,minSize:20,className:`flex flex-col`,children:[n(`div`,{className:`flex h-9 items-center justify-between shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:[t(`span`,{className:`text-sm font-medium`,children:l(`grounded.title`)}),n(`div`,{className:`flex items-center gap-2`,children:[t(ze,{description:l(`grounded.assistantTooltip`),placement:`bottom`,size:`xs`,asChild:!0,children:t(o,{variant:C?`primary`:`ghost`,size:`xs`,"aria-label":l(`grounded.assistant`),onClick:()=>w(e=>!e),children:t(ar,{className:`size-4`})})}),r.verdict&&t(`button`,{type:`button`,className:`cursor-pointer`,onClick:()=>b(e=>!e),"aria-expanded":y,"aria-label":l(`grounded.verdictDetails`),children:t(i,{variant:r.verdict===`good_to_go`?`success`:`attention`,children:r.verdict===`good_to_go`?l(`grounded.verdictGoodToGo`):l(`grounded.verdictNeedsReview`)})}),typeof r.hardness?.score==`number`&&n(i,{variant:r.hardness.score>=.5?`attention`:r.hardness.score>=.2?`info`:`secondary`,title:l(`grounded.hardnessHint`),children:[l(`grounded.hardness`,{percent:Math.round(r.hardness.score*100)}),r.hardness.escalated?` ↑`:``]}),r.citations.length>0&&(()=>{let e=Math.round(100*T.totalVerified/r.citations.length);return t(i,{variant:e>=95?`success`:e>=50?`attention`:`destructive`,title:l(`grounded.confidenceHint`),children:l(`grounded.confidence`,{percent:e})})})(),n(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-1`,onClick:()=>v(e=>!e),"aria-expanded":_,"aria-label":l(`grounded.breakdownTitle`),children:[T.digitallyVerified>0&&t(i,{variant:`success`,title:l(`grounded.digitalVerifiedHint`),children:l(`grounded.digitalVerifiedOf`,{count:T.digitallyVerified,total:D})}),T.modelVerified>0&&t(i,{variant:`success`,title:l(`grounded.modelVerifiedHint`),children:l(`grounded.modelVerifiedOf`,{count:T.modelVerified,total:D})}),T.groups.imageRead>0&&t(i,{variant:`attention`,title:l(`grounded.unverifiedHint`),children:l(`grounded.unverifiedCount`,{count:T.groups.imageRead})})]}),t(o,{variant:`ghost`,size:`xs`,"aria-label":l(`grounded.downloadCitations`),title:l(`grounded.downloadCitations`),onClick:()=>f(`grounded-extraction.json`),children:t(rn,{className:`size-4`})}),t(o,{variant:`ghost`,size:`xs`,"aria-label":l(`grounded.downloadBlocks`),title:l(`grounded.downloadBlocks`),onClick:()=>f(`pages/page-${p}.json`),children:t(on,{className:`size-4`})}),t(o,{variant:`ghost`,size:`xs`,"aria-label":l(`grounded.downloadAnnotated`),title:l(`grounded.downloadAnnotated`),onClick:()=>f(`grounded-annotated.pdf`),children:t(tn,{className:`size-4`})}),!!s&&t(o,{variant:`ghost`,size:`xs`,onClick:s,"aria-label":l(`pdf.close`),children:t(yr,{className:`size-4`})})]})]}),y&&r.verdict&&n(`div`,{className:`shrink-0 border-b border-border bg-background px-3 py-2 text-sm`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:V(`font-medium`,r.verdict===`good_to_go`?`text-success`:`text-attention`),children:r.verdict===`good_to_go`?l(`grounded.verdictGoodToGo`):l(`grounded.verdictNeedsReview`)}),t(`span`,{className:`text-xs text-muted-foreground`,children:r.review?l(`grounded.verdictByReviewer`):l(`grounded.verdictByConfidence`)})]}),(r.verdict_reason??r.review?.verdict_reason)&&t(`p`,{className:`mt-1 text-xs`,children:r.verdict_reason??r.review?.verdict_reason}),r.review?.summary&&n(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[n(`span`,{className:`font-medium text-foreground`,children:[l(`grounded.reviewSummary`),`: `]}),r.review.summary]}),typeof r.review?.corrections_applied==`number`&&r.review.corrections_applied>0&&t(`p`,{className:`mt-1 text-xs text-info`,children:l(`grounded.reviewCorrections`,{count:r.review.corrections_applied})})]}),_&&n(`div`,{className:`shrink-0 border-b border-border bg-background px-3 py-2 text-sm max-h-72 overflow-auto`,children:[t(`div`,{className:`font-medium mb-1`,children:l(`grounded.breakdownTitle`)}),n(`div`,{className:`grid grid-cols-2 gap-x-4 text-xs`,children:[t(`span`,{className:`col-span-2 mt-1 font-medium text-success`,children:l(`grounded.digitalVerifiedOf`,{count:T.digitallyVerified,total:D})}),t(`span`,{className:`ps-2 text-muted-foreground`,children:l(`grounded.breakdownDigital`)}),t(`span`,{className:`text-end text-success`,children:T.groups.digital}),t(`span`,{className:`ps-2 text-muted-foreground`,children:l(`grounded.breakdownOcr`)}),t(`span`,{className:`text-end text-success`,children:T.groups.ocr}),t(`span`,{className:`ps-2 text-muted-foreground`,children:l(`grounded.breakdownSnapped`)}),t(`span`,{className:`text-end text-success`,children:T.groups.snapped}),t(`span`,{className:`col-span-2 mt-2 font-medium text-success`,children:l(`grounded.modelVerifiedOf`,{count:T.modelVerified,total:D})}),t(`span`,{className:`ps-2 text-muted-foreground`,children:l(`grounded.breakdownReviewer`)}),t(`span`,{className:`text-end text-success`,children:T.groups.reviewerConfirmed}),T.groups.imageRead>0&&n(e,{children:[t(`span`,{className:`col-span-2 mt-2 font-medium text-attention`,children:l(`grounded.unverifiedCount`,{count:T.groups.imageRead})}),t(`span`,{className:`ps-2 text-muted-foreground`,children:l(`grounded.breakdownImageRead`)}),t(`span`,{className:`text-end text-attention`,children:T.groups.imageRead})]})]}),t(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:l(`grounded.breakdownVerificationHelp`)}),T.unverified.length>0&&n(`div`,{className:`mt-2`,children:[t(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:l(`grounded.breakdownUnverifiedList`)}),t(`ul`,{className:`space-y-0.5`,children:T.unverified.map(e=>t(`li`,{children:n(`button`,{type:`button`,className:`w-full text-start text-xs rounded px-1 py-0.5 hover:bg-muted cursor-pointer`,onClick:()=>{O(e.path),v(!1)},children:[t(`span`,{className:`text-muted-foreground`,children:e.path}),` `,t(`span`,{children:String(e.value??``)})]})},e.path))})]})]}),n(`div`,{className:`flex-1 overflow-auto p-3`,children:[t(Rb,{value:r.data,path:``,citationsByPath:E,selectedPath:h,onSelect:O}),r.conflicts&&r.conflicts.length>0&&t(`div`,{className:`mt-4 text-xs text-attention`,children:l(`grounded.conflicts`,{count:r.conflicts.length})})]})]}),C&&n(e,{children:[t(ge,{className:`w-[4px] bg-border cursor-ew-resize`}),t(_e,{defaultSize:30,minSize:20,className:`flex flex-col border-s border-border`,children:t(kb,{objectId:a,onExtractionChanged:c,selectedField:h,onClose:()=>w(!1)})})]})]})}function Lb({objectId:e,page:r,dims:i,citations:a,selectedPath:o,onSelectPath:s,imageMode:c}){let{t:l}=X(),{client:u}=Z(),[d,f]=Y(void 0);if(K(()=>{let t=!1;return f(void 0),u.files.getDownloadUrl(`${Ab}/${e}/pages/page-${r}.${c}.jpg`).then(e=>{t||f(e.url)}).catch(e=>console.warn(`Failed to load page image`,e)),()=>{t=!0}},[u,c,e,r]),!d||!i)return t(`div`,{className:`flex items-center justify-center h-64`,children:t(Ee,{})});let p=a.flatMap(e=>e.boxes.map((n,r)=>{let a=o!==void 0&&jb(o)===jb(e.path),c=e.cells?e.cells.start===e.cells.end?e.cells.start:`${e.cells.start}:${e.cells.end}`:void 0;return t(`button`,{type:`button`,"aria-label":e.path,title:`${e.path}${c?`\n${c}`:``}${e.source_text?`\n${e.source_text}`:``}`,onClick:()=>s(jb(e.path)),className:V(`absolute cursor-pointer border rounded-[1px] transition-colors`,e.misaligned&&`border-dashed`,a?`border-2 border-destructive bg-destructive/20 z-10`:o?`border-info/30 hover:border-info`:e.verified?`border-success/70 hover:bg-success/20`:e.reviewed?`border-info/70 hover:bg-info/20`:`border-attention/80 hover:bg-attention/20`),style:{position:`absolute`,left:`${n.x/i.width*100}%`,top:`${n.y/i.height*100}%`,width:`${n.w/i.width*100}%`,height:`${n.h/i.height*100}%`}},`${e.path}-${r}`)})),m=((i.rotation??0)%360+360)%360;if(m!==0){let e=m===90||m===270;return n(`div`,{className:`relative w-full`,style:{aspectRatio:`${i.width} / ${i.height}`},children:[t(`img`,{src:d,alt:l(`grounded.pageAlt`,{page:r}),className:`absolute select-none`,style:{left:`50%`,top:`50%`,width:`${(e?i.height/i.width:1)*100}%`,height:`${(e?i.width/i.height:1)*100}%`,maxWidth:`none`,transform:`translate(-50%, -50%) rotate(${m}deg)`,transformOrigin:`center center`}}),p]})}return n(`div`,{className:`relative w-full`,children:[t(`img`,{src:d,alt:l(`grounded.pageAlt`,{page:r}),className:`w-full select-none`}),p]})}function Rb({value:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}){return Array.isArray(e)?e.length>0&&e.every(e=>typeof e==`object`&&!!e)?t(zb,{items:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}):t(`div`,{className:`space-y-1`,children:e.map((e,n)=>t(Rb,{value:e,path:`${r}[${n}]`,citationsByPath:i,selectedPath:a,onSelect:o},`${r}[${n}]`))}):typeof e==`object`&&e?t(`div`,{className:r?`ps-3 border-s border-border space-y-0.5`:`space-y-0.5`,children:Object.entries(e).map(([e,s])=>{let c=r?`${r}.${e}`:e;return typeof s!=`object`||!s?t(Bb,{label:e,value:s,path:c,citationsByPath:i,selectedPath:a,onSelect:o},c):n(`div`,{className:`pt-1`,children:[!(Array.isArray(s)&&s.length>0&&s.every(e=>typeof e==`object`&&!!e))&&t(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:e}),t(Rb,{value:s,path:c,citationsByPath:i,selectedPath:a,onSelect:o})]},c)})}):null}function zb({items:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}){let{t:s}=X(),c=q(()=>{let t=new Set;for(let n of e)for(let e of Object.keys(n))t.add(e);return Array.from(t)},[e]);return n(`div`,{className:`pt-1`,children:[n(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:[r.split(`.`).pop(),` (`,e.length,`)`]}),t(`div`,{className:`overflow-x-auto`,children:n(`table`,{className:`w-full text-xs`,children:[t(`thead`,{children:t(`tr`,{className:`text-start text-muted-foreground`,children:c.map(e=>t(`th`,{scope:`col`,className:`py-1 pe-2 font-medium`,children:e},e))})}),t(`tbody`,{children:e.map((e,l)=>t(`tr`,{className:`border-t border-border/50`,children:c.map(c=>{let u=`${r}[${l}].${c}`,d=i.get(u)?.[0];return t(`td`,{className:`py-0.5 pe-2`,children:n(`button`,{type:`button`,onClick:()=>o(u),className:V(`text-start rounded px-1 w-full`,a===u?`bg-destructive/15 ring-1 ring-destructive`:d?`hover:bg-muted cursor-pointer`:`text-muted-foreground cursor-default`),children:[Ub(e[c]),d&&typeof d.confidence==`number`&&t(`span`,{className:V(`ms-1 text-[10px]`,Hb(d.confidence)),title:s(`grounded.confidenceHint`),children:Vb(d.confidence)})]})},c)})},`${r}[${l}]`))})]})})]})}function Bb({label:e,value:r,path:i,citationsByPath:a,selectedPath:o,onSelect:s}){let{t:c}=X(),l=a.get(i)?.[0];return n(`button`,{type:`button`,onClick:()=>l&&s(i),className:V(`flex items-center gap-2 w-full text-start text-sm rounded px-1.5 py-0.5`,o===i?`bg-destructive/15 ring-1 ring-destructive`:l?`hover:bg-muted`:``,!l&&`cursor-default`),children:[t(`span`,{className:`text-muted-foreground min-w-28 shrink-0`,children:e}),t(`span`,{className:`flex-1 wrap-break-word`,children:Ub(r)}),l&&typeof l.confidence==`number`&&t(`span`,{className:V(`text-xs shrink-0`,Hb(l.confidence)),title:c(`grounded.confidenceHint`),children:Vb(l.confidence)}),l&&(l.verified?t(Tt,{"aria-label":c(`grounded.verified`),className:`size-3.5 shrink-0 text-success`}):l.reviewed?t(ar,{"aria-label":c(`grounded.aiVerified`),className:`size-3.5 shrink-0 text-info`}):t($t,{"aria-label":c(`grounded.readFromImage`),className:`size-3.5 shrink-0 text-attention`}))]})}function Vb(e){let t=e*100;return Number.isInteger(t)?`${t}%`:`${(Math.floor(t*100)/100).toFixed(2)}%`}function Hb(e){return e>=.95?`text-success`:e>=.7?`text-attention`:`text-destructive`}function Ub(e){return e==null||e===``?`—`:typeof e==`boolean`?e?`true`:`false`:typeof e==`object`?JSON.stringify(e):String(e)}const Wb=`magic-pdf`;var Gb;(function(e){e.original=`original`,e.instrumented=`instrumented`})(Gb||={});var Kb=class{client;objectId;totalPages;cache=new Map;pending=new Map;constructor(e,t,n){this.client=e,this.objectId=t,this.totalPages=n}getCacheKey(e,t){return`${t}-${e}`}async getPageImageUrl(e,t){let n=this.getCacheKey(e,t),r=this.cache.get(n);if(r)return r;let i=this.pending.get(n);if(i)return i;let a=this.fetchImageUrl(e,t);this.pending.set(n,a);try{let e=await a;return this.cache.set(n,e),e}finally{this.pending.delete(n)}}async fetchImageUrl(e,t){let n=this.getImagePath(e,t);return(await this.client.files.getDownloadUrl(n)).url}getImagePath(e,t){let n=`${Wb}/${this.objectId}/pages`;switch(t){case Gb.original:return`${n}/page-${e}.original.jpg`;case Gb.instrumented:return`${n}/page-${e}.instrumented.jpg`}}},qb=class{client;objectId;totalPages;cache=new Map;pending=new Map;constructor(e,t,n){this.client=e,this.objectId=t,this.totalPages=n}async getPageLayout(e){let t=this.cache.get(e);if(t!==void 0)return t;let n=this.pending.get(e);if(n)return n;let r=this.fetchPageLayout(e);this.pending.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pending.delete(e)}}async fetchPageLayout(e){let t=`${Wb}/${this.objectId}/pages/page-${e}.layout.json`,n=await this.client.files.getDownloadUrl(t),r=await fetch(n.url,{method:`GET`});if(!r.ok)throw Error(`Failed to fetch json layout: ${r.statusText}`);return r.text()}},Jb=class{totalPages;pages=[];constructor(e){this.totalPages=e}initFromContent(e){this.pages=Yb(e,this.totalPages)}async loadUrls(e,t){}async getPageMarkdown(e){let t=e-1;return t<0||t>=this.pages.length?``:this.pages[t]}};function Yb(e,t){let n=Array(t).fill(``),r=/<!--\s*\{\s*"page"\s*:\s*(\d+)\s*\}\s*-->/g,i=[];for(let t of e.matchAll(r))i.push({page:parseInt(t[1],10),index:t.index+t[0].length});for(let r=0;r<i.length;r++){let a=i[r],o=a.page-1;if(o<0||o>=t)continue;let s=a.index,c=e.slice(s).match(/<!--\s*\{\s*"page"\s*:\s*\d+\s*\}\s*-->/),l=c&&c.index!==void 0?s+c.index:e.length,u=e.slice(s,l).trim();u=u.replace(/\n---\s*$/,``).trim(),n[o]=u}return n}const Xb=nt(void 0);function Zb({children:e,object:n}){let{client:r}=Z(),i=n.metadata.page_count||10,[a,o]=Y(()=>{let e=new Jb(i);return n.text&&e.initFromContent(n.text),{count:i,layoutProvider:new qb(r,n.id,i),markdownProvider:e,imageProvider:new Kb(r,n.id,i),pdfUrl:``,pdfUrlLoading:!0}});return K(()=>{let e=n.metadata?.renditions?.find(e=>e.name===Lr),t=n.content?.type===`application/pdf`,i=e?.content?.source||(t?n.content?.source:void 0);i?r.store.objects.getDownloadUrl(i,void 0,`inline`).then(e=>{o(t=>({...t,pdfUrl:e.url,pdfUrlLoading:!1}))}).catch(e=>{console.warn(`Failed to get PDF URL:`,e),o(e=>({...e,pdfUrlLoading:!1}))}):o(e=>({...e,pdfUrlLoading:!1}))},[r,n.metadata,n.content?.type,n.content?.source]),t(Xb.Provider,{value:a,children:e})}function Qb(e,t,n){return e.files.getDownloadUrl(`${Wb}/${t}/${n}`).then(e=>e.url)}function $b(){let e=W.useContext(Xb);if(!e)throw Error(`useMagicPdfContext must be used within a MagicPdfProvider`);return e}function ex({object:e}){let{t:n}=X(),{client:r}=Z(),i=t=>{Qb(r,e.id,t).then(e=>window.open(e,`_blank`))};return t(o,{variant:`ghost`,size:`xs`,onClick:()=>i(`document.md`),title:n(`pdf.download`),children:t(qt,{className:`size-4`})})}function tx({className:e}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(Dn,{className:`w-6 h-6 animate-spin text-gray-400`})})}function nx({viewType:e,pageNumber:n}){switch(e){case`json`:return t(rx,{pageNumber:n});case`markdown`:return t(ix,{pageNumber:n});default:return t(ix,{pageNumber:n})}}function rx({pageNumber:e}){let[n,r]=Y(null),[i,a]=Y(!0),[o,s]=Y(null),{layoutProvider:c}=$b();return K(()=>{a(!0),s(null),c.getPageLayout(e).then(e=>{r(e?JSON.parse(e):null),a(!1)}).catch(e=>{console.error(e),s(e.message||`Failed to load layout`),a(!1)})},[e,c]),i?t(`div`,{className:`px-4 py-8`,children:t(tx,{})}):o?t(`div`,{className:`px-4 py-2 text-red-500 text-sm`,children:o}):n?t(Pi,{className:`w-full`,data:n}):null}function ix({pageNumber:e}){let[r,i]=Y(null),[a,o]=Y(!0),[s,c]=Y(null),{markdownProvider:l}=$b();return K(()=>{o(!0),c(null),l.getPageMarkdown(e).then(e=>{i(e),o(!1)}).catch(e=>{console.error(e),c(e.message||`Failed to load markdown`),o(!1)})},[e,l]),a?n(`div`,{className:`h-full flex flex-col items-center justify-center gap-2`,children:[t(tx,{}),t(`span`,{className:`text-sm text-muted-foreground`,children:`Loading...`})]}):s?t(`div`,{className:`px-4 py-2 text-red-500 text-sm`,children:s}):t(`div`,{className:`px-4 py-2 prose prose-sm max-w-none dark:prose-invert`,children:r?t(Li,{children:r}):t(`div`,{children:`No markdown content available`})})}var ax=class extends tt{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`PDF View error:`,e,t)}render(){return this.state.hasError?t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:ut.t(`pdf.failedToLoadViewer`,{ns:lt}),children:this.state.error?.message||`An unexpected error occurred`}),this.props.onClose&&t(o,{variant:`outline`,onClick:this.props.onClose,children:`Close`})]})}):this.props.children}};function ox({objectId:e,onClose:r}){let{t:i}=X(),{client:a}=Z(),{data:s,error:c}=Ue(()=>a.store.objects.retrieve(e,`+text`),[e]);return c?t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:i(`pdf.fetchingDocumentFailed`),children:H(c)}),r&&t(o,{variant:`outline`,onClick:r,children:`Close`})]})}):s?t(ax,{onClose:r,children:t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:t(Zb,{object:s,children:t(sx,{object:s,onClose:r})})})}):n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,title:i(`pdf.close`),children:t(yr,{className:`size-4`})})}),t(`div`,{className:`flex-1 flex items-center justify-center`,children:t(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary`})})]})}function sx({object:e,onClose:r}){let{t:i}=X(),{count:a,pdfUrl:s,pdfUrlLoading:c}=$b(),[l,u]=Y(1);return n(ve,{direction:`horizontal`,className:`absolute inset-0`,children:[t(_e,{defaultSize:50,minSize:20,maxSize:80,className:`bg-muted`,children:t(Py,{pdfUrl:s,pdfUrlLoading:c,pageCount:a,className:`h-full`,currentPage:l,onChange:u})}),t(ge,{className:`w-[4px] bg-border cursor-ew-resize`}),n(_e,{defaultSize:50,minSize:20,className:`flex flex-col`,children:[n(`div`,{className:`flex h-9 items-center justify-between shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:[t(`div`,{className:`flex items-center gap-x-2`,children:t(ex,{object:e})}),t(`span`,{className:`text-xs text-muted-foreground`,children:i(`pdf.pageOf`,{pageNumber:l,totalPages:a})}),t(`div`,{className:`flex items-center gap-x-2`,children:!!r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,title:i(`pdf.close`),children:t(yr,{className:`size-4`})})})]}),t(`div`,{className:`flex-1 overflow-auto px-2`,children:t(nx,{pageNumber:l,viewType:`markdown`})})]})]})}const cx=[`image/jpeg`,`image/jpg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],lx=[`video/mp4`,`video/webm`],ux=[`audio/mp4`,`audio/m4a`,`audio/x-m4a`,`audio/mpeg`,`audio/ogg`,`audio/wav`,`audio/webm`];function dx(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`:`${n}:${r.toString().padStart(2,`0`)}`}function fx({url:e,source:r,object:i,className:a}){let{t:o}=X(),{client:s}=Z(),[c,l]=Y(e),[u,d]=Y(!e&&(!!r||!!i)),f=i?.metadata,p=(f?.renditions||[]).find(e=>e.name===Or),m=i?.content?.type&&ux.includes(i.content.type),h=!!i&&i.metadata?.type===Ar.Audio&&!p&&!m;return K(()=>{if(e){l(e),d(!1);return}l(void 0),r||i?(d(!0),(async()=>{try{if(r){let e=await s.files.getDownloadUrl(r);l(e.url);return}if(!i||i.metadata?.type!==Ar.Audio)return;let e;p?.content?.source?e=await s.files.getDownloadUrl(p.content.source):m&&i.content?.source&&(e=await s.files.getDownloadUrl(i.content.source)),e&&l(e.url)}catch(e){console.error(`Failed to get audio URL`,e)}finally{d(!1)}})()):d(!1)},[e,r,i,p,m,s]),h?t(`div`,{className:`flex justify-center items-center h-[200px] text-muted ${a??``}`.trim(),children:n(`div`,{className:`text-center`,children:[t(`p`,{children:o(`store.noAudioRendition`)}),t(`p`,{className:`text-sm mt-2`,children:o(`store.audioFormatRequired`)})]})}):u?t(`div`,{className:`flex justify-center items-center h-[200px] ${a??``}`.trim(),children:t(Ee,{size:`md`})}):c?n(`div`,{className:`flex flex-col items-center gap-4 ${a??``}`.trim(),children:[t(`audio`,{src:c,controls:!0,className:`w-full max-w-2xl`,children:`Your browser does not support the audio tag.`}),f?.duration&&n(`div`,{className:`text-sm text-muted`,children:[`Duration: `,dx(f.duration)]})]}):t(`div`,{className:`flex justify-center items-center h-[200px] text-muted ${a??``}`.trim(),children:`Failed to load audio`})}function px({url:e,source:n,object:r,className:i}){let{client:a}=Z(),[o,s]=Y(e),[c,l]=Y(!e&&(!!n||!!r));return K(()=>{if(e){s(e),l(!1);return}s(void 0),n||r?(l(!0),(async()=>{try{if(n){let e=await a.files.getDownloadUrl(n);s(e.url);return}if(!r||r.metadata?.type!==Ar.Image)return;let e=r.content?.type&&cx.includes(r.content.type);try{let e=await a.objects.getRendition(r.id,{format:Pr.jpeg,generate_if_missing:!1,sign_url:!0});if(e.status===`found`&&e.renditions?.length){s(e.renditions[0]);return}}catch{}if(e&&r.content?.source){let e=await a.files.getDownloadUrl(r.content.source);s(e.url)}}finally{l(!1)}})()):l(!1)},[e,n,r,a]),c?t(`div`,{className:i,children:t(Ee,{size:`md`})}):o?t(`img`,{src:o,alt:r?.name,className:`w-full object-contain ${i??``}`.trim()}):null}function mx({url:e,source:r,object:i,className:a}){let{t:o}=X(),{client:s}=Z(),[c,l]=Y(e),[u,d]=Y(),[f,p]=Y(!e&&(!!r||!!i)),m=i?.metadata?.renditions||[],h=m.find(e=>e.content.type===`video/mp4`)||m.find(e=>e.content.type===`video/webm`),g=i?.content?.type&&lx.includes(i.content.type),_=m.find(e=>e.name===Rr),v=!!i&&i.metadata?.type===Ar.Video&&!h&&!g;return K(()=>{if(e){l(e),p(!1);return}l(void 0),d(void 0),r||i?(p(!0),(async()=>{try{if(r){let e=await s.files.getDownloadUrl(r);l(e.url);return}if(!i||i.metadata?.type!==Ar.Video)return;let e;h?.content?.source?e=await s.files.getDownloadUrl(h.content.source):g&&i.content?.source&&(e=await s.files.getDownloadUrl(i.content.source)),e&&l(e.url)}catch(e){console.error(`Failed to get video URL`,e)}finally{p(!1)}})()):p(!1)},[e,r,i,h,g,s]),K(()=>{_?.content?.source&&s.files.getDownloadUrl(_.content.source).then(e=>d(e.url)).catch(e=>console.error(`Failed to load poster image`,e))},[_,s]),v?t(`div`,{className:`flex justify-center items-center h-[400px] text-muted ${a??``}`.trim(),children:n(`div`,{className:`text-center`,children:[t(`p`,{children:o(`store.noVideoRendition`)}),t(`p`,{className:`text-sm mt-2`,children:o(`store.videoFormatRequired`)})]})}):f?t(`div`,{className:`flex justify-center items-center h-[400px] ${a??``}`.trim(),children:t(Ee,{size:`md`})}):c?t(`video`,{src:c,poster:u,controls:!0,className:`w-full h-full object-contain ${a??``}`.trim(),children:`Your browser does not support the video tag.`}):t(`div`,{className:`flex justify-center items-center h-[400px] text-muted ${a??``}`.trim(),children:`Failed to load video`})}function hx({oauthProviderId:r,onAuthChange:i}){let{client:a}=Z(),{t:o}=X(),[s,c]=Y(null),[l,u]=Y(!0),[d,f]=Y(!1),[p,m]=Y(!1),h=G(async()=>{try{u(!0);let e=await a.oauthProviders.getStatus(r);c(e)}catch(e){console.error(`Failed to load OAuth provider status:`,e)}finally{u(!1)}},[a,r]);K(()=>{h()},[h]);let{openOAuthPopup:g}=zs({onComplete:()=>{f(!1),h(),i?.()},onError:e=>{console.error(`OAuth provider auth failed:`,e),f(!1)}});return l?t(Ls,{className:`size-4`}):s?.authenticated?n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1 text-success text-sm`,children:[t(Tt,{className:`size-4`}),t(`span`,{children:o(`oauthProvider.connected`)})]}),t(go,{variant:`outline`,size:`sm`,onClick:async()=>{if(!p)try{m(!0),await a.oauthProviders.disconnect(r),await h(),i?.()}catch(e){console.error(`Failed to disconnect OAuth provider:`,e)}finally{m(!1)}},disabled:p,children:p?t(Ls,{className:`size-3`}):o(`oauthProvider.disconnect`)})]}):t(go,{variant:`outline`,size:`sm`,onClick:async()=>{if(!d)try{f(!0);let e=await a.oauthProviders.authorize(r);e.authorization_url&&g(e.authorization_url)}catch(e){console.error(`Failed to authorize OAuth provider:`,e),f(!1)}},disabled:d,children:d?n(e,{children:[t(Ls,{className:`size-4`}),t(`span`,{children:o(`oauthProvider.authenticating`)})]}):n(e,{children:[t(Zt,{className:`size-4 me-1`}),t(`span`,{children:o(`oauthProvider.authenticate`)})]})})}function gx(...e){let t=Array.from(e);return t.__AnyOf__=!0,t}function _x(...e){return Array.from(e)}function vx(e){return e.__AnyOf__===!0}var yx=class{system_roles;roles;permissions;constructor(e,t=[]){this.system_roles=t;let n=[...e.account_roles||[],...e.project_roles||[]],r=new Set(n);this.roles=r;let i=e.permissions??bx(n,t),a=e.type===Br.OAuthAccess?new Set(e.permissions??[]):void 0;this.permissions=new Set(a?i.filter(e=>a.has(e)):i)}hasPermission(e){if(typeof e==`string`)return this.permissions.has(e);if(vx(e))return e.some(e=>this.permissions.has(e));for(let t of e)if(!this.permissions.has(t))return!1;return!0}};function bx(e,t){let n=new Map(t.map(e=>[e.name,e.permissions])),r=new Set;for(let t of e)for(let e of n.get(t)??[])r.add(e);return Array.from(r)}const xx=nt(void 0);function Sx(){let e=at(xx);if(!e)throw Error(`UserPermissionContext cannot be used outside UserPermissionProvider`);return e}function Cx({children:e}){let{t:n}=X(),r=Z(),i=r.authToken,a=!!(i&&!i.permissions),{data:o,error:s,isLoading:c}=Ue(()=>a?r.client.iam.roles.listSystem():Promise.resolve(void 0),[r.client,i,a]),l=q(()=>{if(i){if(i.permissions||!a)return new yx(i);if(o&&!c)return new yx(i,o)}else return},[i,o,c,a]);return s?t(M,{title:n(`store.failedToFetchRoleMappings`),children:H(s)}):l&&t(xx.Provider,{value:l,children:e})}function wx({permission:e,isDisabled:n,title:r,children:i,...a}){return Sx().hasPermission(e)?t(o,{isDisabled:n,title:r,...a,children:i}):null}function Tx({permission:e,...n}){return Sx().hasPermission(e)?t(na,{...n}):null}const Ex=new WeakMap;function Dx(e,t){let n=Ex.get(e);n||(n=new Map,Ex.set(e,n));let r=n.get(t);return r||(r=e.types.catalog.resolve(t).then(e=>e??void 0,()=>{Ex.get(e)?.delete(t)}),n.set(t,r)),r}function Ox(e,t){let n=Ex.get(e);n&&(t?n.delete(t):n.clear())}var kx=class extends he{idOf(e){return e.id}labelOf(e){return e.label}descriptionOf(e){return e.description}selectedClassName(e){return`border-3 border-primary`}};function Ax({isOpen:e,onClose:r,onConfirm:i,isLoading:a,uploadedFileName:s}){let{t:c}=X(),l=q(()=>[{id:`update`,label:c(`modal.saveVersion.updateCurrent`),description:c(s?`modal.saveVersion.updateWithFileDescription`:`modal.saveVersion.updateDescription`)},{id:`new-version`,label:c(`modal.saveVersion.createNew`),description:c(s?`modal.saveVersion.createWithFileDescription`:`modal.saveVersion.createDescription`)}],[c,s]),u=s?l[1]:l[0],[d,f]=Y(u),[p,m]=Y(``),h=new kx;K(()=>{e&&(f(u),m(``))},[u,e]);let g=d?.id===`new-version`;return n(ie,{isOpen:e,onClose:r,className:`sm:max-w-md`,children:[t(se,{children:c(`modal.saveChanges`)}),t(ae,{children:n(`div`,{className:`space-y-4`,children:[s&&t(`div`,{className:`mb-4 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-md`,children:n(`p`,{className:`text-sm text-blue-700 dark:text-blue-300 font-medium`,children:[c(`modal.saveVersion.replaceFile`),` `,t(`span`,{className:`font-bold`,children:s})]})}),t(`p`,{className:`text-sm text-mixer-muted/5`,children:c(`modal.saveVersion.howToSave`)}),t(me,{adapter:h,options:l,selected:d,onSelect:e=>{f(e)}}),g&&t(L,{label:c(`modal.saveVersion.versionLabel`),description:c(`modal.saveVersion.versionLabelDescription`),className:`mt-3 ps-8`,children:t(ee,{value:p,onChange:m,placeholder:c(`modal.saveVersion.versionLabelPlaceholder`),className:`w-full`})})]})}),n(oe,{children:[t(o,{variant:`secondary`,onClick:r,disabled:a,children:c(`modal.cancel`)}),t(o,{variant:`primary`,onClick:async()=>{await i(g,g?p:void 0)},isLoading:a,children:c(`modal.save`)})]})]})}function jx({isOpen:r,onClose:i,object:a,refetch:s}){let{client:c,store:l}=Z(),u=Ye(),{t:d}=X(),{theme:f}=Je(),p=Di(),[m,h]=Y(!1),[g,_]=Y(``),[v,y]=Y(!1),[b,x]=Y(null),S=J(void 0),[C,w]=Y(null),[T,E]=Y(null),D=G(async e=>{try{let t=await l.types.retrieve(e);t.object_schema&&w(t.object_schema)}catch(e){console.error(`Failed to fetch JSON schema:`,e)}},[l.types]);K(()=>{r&&(_(JSON.stringify(a.properties||{},null,2)),a.type?.id&&D(a.type.id))},[r,a,D]);let O=e=>{C&&e.json.jsonDefaults.setDiagnosticsOptions({validate:!0,schemas:[{uri:`http://myserver/object-schema.json`,fileMatch:[`*`],schema:C}]})};function k(){if(!S.current)return;let e=S.current.getValue();try{let t=JSON.parse(e);x(t),y(!0)}catch{u({status:`error`,title:d(`store.invalidJson`),description:d(`store.pleaseFixJsonSyntax`),duration:5e3})}}let A=e=>{_(e)};async function j(e,t){try{h(!0);let n=b||JSON.parse(g);if(e){let e=await c.objects.update(a.id,{properties:n},{createRevision:!0,revisionLabel:t});e.id!==a.id&&E(e.id),u({status:`success`,title:d(`store.newVersionCreated`),description:d(`store.newVersionCreatedDesc`),duration:2e3}),y(!1),i(),e.id!==a.id&&setTimeout(()=>{p(`/objects/${e.id}`),u({status:`info`,title:d(`store.viewingNewVersion`),description:t?d(`store.viewingVersionLabel`,{label:t}):d(`store.viewingNewVersionDefault`),duration:3e3})},100)}else await l.objects.update(a.id,{properties:n}),u({status:`success`,title:d(`store.propertiesUpdated`),description:d(`store.propertiesUpdatedDesc`),duration:2e3}),s&&await s(),y(!1),i()}catch(e){u({status:`error`,title:d(`store.errorUpdatingProperties`),description:H(e,d(`store.errorUpdatingPropertiesDefault`)),duration:5e3}),h(!1)}}function M(){y(!1)}return n(e,{children:[n(ie,{isOpen:r,onClose:i,className:`sm:max-w-[90%] md:max-w-[80%] lg:max-w-[75%] xl:max-w-[70%]`,children:[t(se,{children:d(`store.editProperties`)}),n(ae,{children:[n(`div`,{className:`mb-2 text-sm text-gray-500`,children:[a.type?.name?n(`span`,{children:[`Editing properties for object type: `,t(`strong`,{children:a.type.name})]}):t(`span`,{children:d(`store.editingGenericDocument`)}),C!==null&&t(`span`,{className:`ms-2 text-green-600`,children:`(JSON schema validation enabled)`})]}),t(`div`,{className:`h-[75vh] border rounded-md overflow-hidden`,children:t(Ri,{value:g,language:`json`,editorRef:S,onChange:e=>A(e.state.doc.toString()),beforeMount:O,theme:f===`dark`?`vs-dark`:`vs`})})]}),n(oe,{children:[t(o,{variant:`secondary`,onClick:i,children:`Cancel`}),t(o,{variant:`primary`,onClick:k,children:`Save Changes`})]})]}),t(Ax,{isOpen:v,onClose:M,onConfirm:j,isLoading:m})]})}function Mx(e){switch(e){case`text/markdown`:return`markdown`;case`application/json`:return`json`;case`application/xml`:case`text/xml`:return`xml`;default:return`plaintext`}}function Nx({object:r,text:i,onClose:a,onSaved:s}){let{store:c}=Z(),l=Ye(),{t:u}=X(),{theme:d}=Je(),f=Di(),p=J(void 0),[m,h]=Y(!1),[g,_]=Y(!1),[v,y]=Y(!1),b=Mx(r.content?.type);console.log(`Determined language for Monaco Editor:`,b),console.log(`TextEditorPanel rendered with object:`,r,i);let x=G(()=>{m||h(!0)},[m]);function S(){p.current&&y(!0)}async function C(e,t){if(!p.current)return;let n=p.current.getValue(),i=r.content?.type||`text/plain`,o=r.content?.name||`content.txt`;try{_(!0);let d=new Blob([n],{type:i}),p=new File([d],o,{type:i}),m=await c.objects.update(r.id,{content:p},{createRevision:e,revisionLabel:t,ifMatch:r.content?.etag});l({status:`success`,title:u(`store.textSaved`),duration:2e3}),y(!1),e&&m.id!==r.id?(a(),setTimeout(()=>{f(`/objects/${m.id}`)},100)):s()}catch(e){let t=H(e,u(`store.errorSavingTextDefault`)),n=(typeof e==`object`&&e&&`status`in e?e.status:void 0)===412||t.includes(`412`);l({status:`error`,title:u(`store.errorSavingText`),description:n?u(`store.textConflict`):t,duration:5e3})}finally{_(!1)}}return n(e,{children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1 shrink-0`,children:[m&&t(`span`,{className:`text-xs text-attention`,children:u(`store.unsavedChanges`)}),t(`div`,{className:`flex-1`}),t(o,{variant:`ghost`,size:`sm`,onClick:a,disabled:g,children:u(`store.cancelEdit`)}),t(o,{variant:`secondary`,size:`sm`,onClick:S,disabled:!m,isLoading:g,children:u(`store.saveText`)})]}),t(`div`,{className:`flex-1 min-h-0 border rounded-md overflow-hidden mx-2 mb-2`,children:t(Ri,{value:i,language:b,editorRef:p,onChange:x,theme:d===`dark`?`vs-dark`:`vs`,options:{wordWrap:`on`,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1}})}),t(Ax,{isOpen:v,onClose:()=>y(!1),onConfirm:C,isLoading:g})]})}const Px=128*1024;function Fx(e,t,n=!1){let{store:r}=Z(),[i,a]=Y(t),[o,s]=Y(()=>t&&t.length>Px?t.substring(0,Px):t),[c,l]=Y(!1),[u,d]=Y(()=>!!t&&t.length>Px),f=G(()=>{l(!0),r.objects.getObjectText(e).then(e=>{a(e.text),e.text&&e.text.length>Px?(s(e.text.substring(0,Px)),d(!0)):(s(e.text),d(!1))}).catch(e=>{console.error(`Failed to load text`,e),a(void 0),s(void 0),d(!1)}).finally(()=>{l(!1)})},[e,r]);return K(()=>{t&&t.length>Px?(a(t),s(t.substring(0,Px)),d(!0)):(a(t),s(t),d(!1)),n&&!t&&f()},[t,n,f]),{fullText:i,displayText:o,isLoading:c,isCropped:u,loadText:f}}function Ix(e,t){let{client:n}=Z(),[r,i]=Y({isComplete:!1});return K(()=>{if(!t)return;let r=!1,a,o=(e,t,n)=>{i(r=>{let i=JSON.stringify(r.progress??null),a=JSON.stringify(e??null);return r.status===t&&r.isComplete===n&&i===a?r:{progress:e,status:t,isComplete:n}})};function s(){r||n.objects.analyze(e).getStatus().then(e=>{e.status===Wr.RUNNING?(o(e.progress,e.status,!1),r||(a=setTimeout(s,2e3))):o(e.progress,e.status,!0)}).catch(()=>{r||(a=setTimeout(s,1e4))})}return s(),()=>{r=!0,a&&clearTimeout(a)}},[t,e,n]),{progress:r.progress,status:r.status,isComplete:r.isComplete}}function Lx(e,t){let{client:n}=Z(),r=ut.getFixedT(null,lt),[i,a]=Y(),[o,s]=Y(!1),[c,l]=Y();return{pdfUrl:i,isConverting:o,error:c,triggerConversion:G(async()=>{if(!t||o)return;s(!0),l(void 0);let i=async t=>{try{let o=await n.objects.getRendition(e,{format:Ir.pdf,generate_if_missing:t,sign_url:!0,block_on_generation:!1});o.status===`generating`?setTimeout(()=>i(!1),5e3):o.status===`found`&&o.renditions?.length?(a(o.renditions[0]),s(!1)):o.status===`failed`&&(l(r(`store.pdfConversionFailed`)),s(!1))}catch(e){console.error(`Failed to convert Office document to PDF:`,e),l(r(`store.failedToConvertToPdf`)),s(!1)}};await i(!0)},[e,t,o,n,r])}}const Rx=()=>({a:({node:e,...n})=>{let r=n.href||``;return r.includes(`/store/objects/`)?t(Ei,{topLevelNav:!0,href:r,className:`text-info`,children:n.children}):t(`a`,{...n,target:`_blank`,rel:`noopener noreferrer`})},p:({node:e,...n})=>t(`p`,{...n,className:`my-0`}),pre:({node:e,...n})=>t(`pre`,{...n,className:`my-2 p-2 rounded`}),code:({node:e,className:n,children:r,...i})=>{let a=!/language-(\w+)/.exec(n||``);return t(`code`,{...i,className:a?`px-1.5 py-0.5 rounded`:`text-muted`,children:r})},h1:({node:e,...n})=>t(`h1`,{...n,className:`font-bold text-2xl my-2`}),h2:({node:e,...n})=>t(`h2`,{...n,className:`font-bold text-xl my-2`}),h3:({node:e,...n})=>t(`h3`,{...n,className:`font-bold text-lg my-2`}),li:({node:e,...n})=>t(`li`,{...n})});function zx(e){return e===jr.created||e===jr.processing}function Bx(e){return e.metadata?.content_processor?.type}function Vx(e){return e?e.includes(`
|
|
444
444
|
# `)||e.includes(`
|
|
445
445
|
## `)||e.includes(`
|
|
446
446
|
### `)||e.includes(`
|
|
447
447
|
* `)||e.includes(`
|
|
448
448
|
- `)||e.includes(`
|
|
449
|
-
+ `)||e.includes(`:!1}function tx(e){return e?`h-full overflow-auto`:`hidden`}var nx;(function(e){e.Text=`text`,e.Image=`image`,e.Video=`video`,e.Audio=`audio`,e.Pdf=`pdf`,e.Transcript=`transcript`})(nx||={});function rx({object:e,loadText:r,refetch:i,canEditProperties:a=!0}){let o=He(),{t:s}=X(),c=async(e,t)=>{try{await navigator.clipboard.writeText(e),o({status:`success`,title:s(`store.contentCopied`,{type:s(t===`text`?`store.contentType`:`store.properties`)}),description:s(`store.successfullyCopied`,{type:t}),duration:2e3})}catch(e){console.error(`Failed to copy ${t}:`,e),o({status:`error`,title:s(`store.copyFailed`),description:s(`store.failedToCopy`,{type:t}),duration:5e3})}};return n(me,{direction:`horizontal`,className:`h-full`,children:[t(pe,{defaultSize:67,className:`min-w-[100px]`,children:t(ax,{object:e,loadText:r??!1,handleCopyContent:c,refetch:i})}),t(fe,{withHandle:!0}),t(pe,{defaultSize:33,className:`min-w-[100px]`,children:t(ix,{object:e,refetch:i??(()=>Promise.resolve()),handleCopyContent:c,canEditProperties:a})})]})}function ix({object:r,refetch:i,handleCopyContent:a,canEditProperties:s}){let{t:c}=X(),[l,u]=Y(!1),[d,f]=Y(!1);return n(e,{children:[n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex justify-between items-center px-2`,children:[n(`div`,{className:`flex items-center gap-1 bg-muted mb-2 p-1 rounded`,children:[t(o,{variant:`${l?`ghost`:`primary`}`,size:`sm`,alt:c(`store.previewProperties`),onClick:()=>u(!l),children:`Properties`}),t(o,{variant:`${l?`primary`:`ghost`}`,size:`sm`,alt:c(`store.viewInJsonFormat`),onClick:()=>u(!l),children:`JSON`})]}),n(`div`,{className:`flex items-center gap-2`,children:[r.properties&&t(o,{variant:`ghost`,size:`sm`,title:`Copy properties`,onClick:()=>a(JSON.stringify(r.properties,null,2),`properties`),children:t(Pt,{className:`size-4`})}),s&&t(Bb,{permission:xr.content_write,variant:`ghost`,size:`sm`,onClick:()=>{f(!0)},title:`Edit properties`,className:`flex items-center gap-2`,children:t(Gn,{className:`size-4`})})]})]}),r.properties?t(`div`,{className:`flex-1 min-h-0 px-2`,children:t(_i,{value:r.properties,viewCode:l})}):t(`div`,{className:`flex-1 min-h-0 px-2`,children:t(`div`,{children:c(`store.noPropertiesDefined`)})})]}),t(Wb,{isOpen:d,onClose:()=>{f(!1)},object:r,refetch:i})]})}function ax({object:e,loadText:r,handleCopyContent:i,refetch:a}){let{client:s}=Z(),{t:c}=X(),l=e?.metadata?.type===pr.Image,u=e?.metadata?.type===pr.Video,d=e?.metadata?.type===pr.Audio,f=e?.content?.type===`application/pdf`,p=e?.content?.type?ov(e.content.type):!1,m=Qb(e?.status),h=!!(e.transcript&&(u||d)),g=e.metadata?.renditions?.find(e=>e.name===yr),[_,v]=Y(u?nx.Video:d?nx.Audio:l?nx.Image:nx.Text),[y,b]=Y(_===nx.Pdf);K(()=>{_===nx.Pdf&&b(!0)},[_]);let[x,S]=Y(!1),C=!!(e.content?.source&&e.content?.type&&!m&&!e.is_locked&&e.user_permissions?.can_write!==!1&&(e.content.type.startsWith(`text/`)||e.content.type===`application/json`||e.content.type===`application/xml`)),{fullText:w,displayText:T,isLoading:E,isCropped:D,loadText:O}=Jb(e.id,e.text,r),k=(f||p)&&m&&(_===nx.Text||_===nx.Pdf),{progress:A,status:j,outputFormat:M,isComplete:N}=Yb(e.id,k),{pdfUrl:P,isConverting:F,error:I,triggerConversion:L}=Xb(e.id,p),R=q(()=>[{id:`office-pdf-rendition`,target:`pdf`,canConvert:({contentType:e,extension:t})=>p||(e?ov(e):!1)||[`doc`,`docx`,`ppt`,`pptx`].includes(t),convert:async()=>{let t=await s.objects.getRendition(e.id,{format:vr.pdf,generate_if_missing:!0,sign_url:!0,block_on_generation:!0});return t.status===`found`&&t.renditions?.length?{url:t.renditions[0],contentType:`application/pdf`,fileName:`${e.name||`document`}.pdf`}:null}}],[s,p,e.id,e.name]);K(()=>{N&&j===Er.COMPLETED&&O()},[N,j,O]);let z=(f||p)&&m&&!N&&j===Er.RUNNING,ee=_===nx.Pdf&&!z,B=z&&(_===nx.Text||_===nx.Pdf),te=y&&!z,ne=J(null);return n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex justify-between items-center px-2 shrink-0`,children:[n(`div`,{className:`flex items-center gap-2 mb-2`,children:[n(`div`,{className:`flex items-center gap-1 bg-muted p-1 rounded`,children:[l&&t(o,{variant:_===nx.Image?`primary`:`ghost`,size:`sm`,alt:c(`store.viewImage`),onClick:()=>v(nx.Image),children:`Image`}),u&&t(o,{variant:_===nx.Video?`primary`:`ghost`,size:`sm`,alt:c(`store.viewVideo`),onClick:()=>v(nx.Video),children:`Video`}),d&&t(o,{variant:_===nx.Audio?`primary`:`ghost`,size:`sm`,alt:c(`store.viewAudio`),onClick:()=>v(nx.Audio),children:`Audio`}),h&&t(o,{variant:_===nx.Transcript?`primary`:`ghost`,size:`sm`,alt:c(`store.viewTranscript`),onClick:()=>v(nx.Transcript),children:`Transcript`}),t(o,{variant:_===nx.Text?`primary`:`ghost`,size:`sm`,alt:c(`store.viewText`),onClick:()=>v(nx.Text),children:`Text`}),f&&t(o,{variant:_===nx.Pdf?`primary`:`ghost`,size:`sm`,alt:c(`store.viewPdf`),onClick:()=>v(nx.Pdf),children:`PDF`}),p&&t(o,{variant:_===nx.Pdf?`primary`:`ghost`,size:`sm`,alt:c(`store.viewAsPdf`),onClick:()=>{v(nx.Pdf),!g&&!P&&!F&&L()},disabled:F,children:F?t(be,{size:`sm`}):`PDF`})]}),t(lx,{object:e})]}),_===nx.Text&&!z&&!x&&t(ox,{object:e,text:T,fullText:w,handleCopyContent:i,textContainerRef:ne,isEditing:x,onToggleEdit:()=>S(!0),canEdit:C}),_===nx.Pdf&&p&&(g||P)&&t(ux,{object:e,pdfRendition:g,officePdfUrl:P})]}),_===nx.Image&&t(`div`,{className:tx(!0),children:t(kb,{object:e})}),_===nx.Video&&t(`div`,{className:tx(!0),children:t(Ab,{object:e})}),_===nx.Audio&&t(`div`,{className:tx(!0),children:t(Ob,{object:e})}),h&&_===nx.Transcript&&t(`div`,{className:tx(!0),children:t(cx,{object:e,handleCopyContent:i})}),f&&te&&t(`div`,{className:tx(ee),children:t(dx,{object:e})}),p&&te&&t(`div`,{className:tx(ee),children:t(fx,{object:e,pdfRendition:g,officePdfUrl:P,converters:R,officePdfConverting:F,officePdfError:I})}),B&&t(`div`,{className:tx(!0),children:t(px,{progress:A,status:j,outputFormat:M})}),_===nx.Text&&!z&&!x&&E&&t(`div`,{className:tx(!0),children:t(`div`,{className:`flex justify-center items-center flex-1`,children:t(be,{size:`lg`})})}),_===nx.Text&&!z&&!x&&!E&&t(`div`,{className:tx(!0),children:t(sx,{object:e,text:T,isTextCropped:D,textContainerRef:ne})}),x&&_===nx.Text&&w!=null&&t(Kb,{object:e,text:w,onClose:()=>S(!1),onSaved:()=>{S(!1),O(),a?.()}})]})}function ox({object:r,text:i,fullText:a,handleCopyContent:s,onToggleEdit:c,canEdit:l}){let{client:u,project:d}=Z(),f=He(),{t:p}=X(),m=r.content,{renderDocument:h,isDownloading:g}=Vu({client:u,toast:f}),{data:_}=Le(()=>d?u.projects.retrieve(d.id):Promise.resolve(void 0),[d?.id]),v=_?.configuration?.pdf_template_object_id,y=m?.type&&m.type===`text/markdown`,x=$b(r),S=async(e,t)=>{if(g)return;f({status:`info`,title:`Preparing ${e.toUpperCase()}`,description:p(`store.renderingDocument`),duration:2e3});let n=t===!1?void 0:v;await h(r.id,{format:e,title:r.name||`document`,useDefaultTemplate:t,templateObjectId:n})};return t(`div`,{className:`h-[41px] text-lg font-semibold flex justify-between items-center px-2`,children:n(`div`,{className:`flex items-center gap-2`,children:[a&&n(e,{children:[t(o,{variant:`ghost`,size:`sm`,title:`Copy text`,onClick:()=>s(a,`text`),children:t(Pt,{className:`size-4`})}),l&&c&&t(Bb,{permission:xr.content_write,variant:`ghost`,size:`sm`,onClick:c,title:p(`store.editText`),className:`flex items-center gap-2`,children:t(Gn,{className:`size-4`})})]}),g?t(o,{variant:`ghost`,size:`sm`,disabled:!0,className:`flex items-center gap-2`,alt:`download`,children:t(be,{size:`sm`})}):n(b,{trigger:t(o,{variant:`ghost`,size:`sm`,disabled:!i,className:`flex items-center gap-2`,alt:`download`,children:t(Lt,{className:`size-4`})}),children:[a&&t(z,{onClick:e=>{if(e.preventDefault(),e.stopPropagation(),!a)return;let t=`txt`,n=`text/plain`;x===`xml`?(t=`xml`,n=`text/xml`):(x===`markdown`||y)&&(t=`md`,n=`text/markdown`);let i=new Blob([a],{type:n}),o=URL.createObjectURL(i),s=`${r.name||`document`}.${t}`,c=document.createElement(`a`);c.href=o,c.download=s,c.style.display=`none`,setTimeout(()=>{c.click(),URL.revokeObjectURL(o)},0)},children:n(`div`,{className:`flex items-center gap-2`,children:[t(Lt,{className:`size-4`}),`Download Text`]})}),y&&i&&n(e,{children:[t(z,{onClick:()=>S(vr.docx),children:n(`div`,{className:`flex items-center gap-2`,children:[t(Lt,{className:`size-4`}),`Export as DOCX`]})}),t(z,{onClick:()=>S(vr.pdf,!1),children:n(`div`,{className:`flex items-center gap-2`,children:[t(Lt,{className:`size-4`}),`Export as PDF`]})}),t(z,{onClick:()=>S(vr.pdf),children:n(`div`,{className:`flex items-center gap-2`,children:[t(Lt,{className:`size-4`}),`Export as Branded PDF`]})})]})]})]})})}const sx=Ze(({object:r,text:i,isTextCropped:a,textContainerRef:o})=>{let{t:s}=X(),c=Qb(r?.status),l=$b(r)===`xml`,u=r.content?.type&&(r.content.type===`text/markdown`||r.content.type===`text/plain`),d=!l&&(u||ex(i)),f={id:r.id,title:r.name,fileName:r.content?.name||r.name,contentType:l?`text/xml`:d?`text/markdown`:r.content?.type,content:i,sourcePath:r.content?.source};return i?n(e,{children:[a&&t(`div`,{className:`px-2 py-2 bg-attention/10 border-s-4 border-attention mx-2 mb-2 rounded`,children:n(`div`,{className:`flex items-center gap-2 text-attention`,children:[t(st,{className:`size-4`}),t(`span`,{className:`text-sm font-semibold`,children:s(`store.showingFirst128K`)})]})}),t(`div`,{className:`max-w-7xl px-2 h-full overflow-auto`,ref:o,children:t(sh,{source:f,className:`h-full`,bodyClassName:`overflow-auto`,markdownComponents:Zb()})})]}):t(`div`,{className:`px-2`,children:t(`div`,{children:c?`Extracting content...`:`No content`})})});function cx({object:e,handleCopyContent:r}){let{t:i}=X(),a=e.transcript,s=a?.text,c=a?.segments,l=s||(c?c.map(e=>e.text).join(` `):``),u=e=>{let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`:`${n}:${r.toString().padStart(2,`0`)}`};return n(`div`,{className:`flex flex-col h-full`,children:[t(`div`,{className:`flex justify-end items-center px-2 mb-2`,children:l&&t(o,{variant:`ghost`,size:`sm`,title:`Copy transcript`,onClick:()=>r(l,`text`),children:t(Pt,{className:`size-4`})})}),t(`div`,{className:`h-full} overflow-auto px-2`,children:c&&c.length>0?t(`div`,{className:`space-y-2`,children:c.map((e,r)=>n(`div`,{className:`flex gap-3 text-sm`,children:[n(`span`,{className:`text-muted font-mono text-xs shrink-0 pt-0.5`,children:[u(e.start),e.end&&` - ${u(e.end)}`]}),t(`span`,{className:`flex-1`,children:e.text})]},`segment-${r}`))}):s?t(`pre`,{className:`text-wrap bg-muted text-muted p-2 whitespace-pre-wrap`,children:s}):t(`div`,{className:`text-muted`,children:i(`store.noTranscriptAvailable`)})})]})}function lx({object:r}){let[i,a]=Y(!1),s=$b(r);return s===`xml`||s===`markdown`?n(e,{children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>a(!0),title:`Side by side view`,children:t(Kt,{className:`size-4`})}),i&&t(le,{children:t(Sb,{objectId:r.id,onClose:()=>a(!1)})})]}):null}function ux({object:e,pdfRendition:n,officePdfUrl:r}){let{client:i}=Z(),a=He(),{t:s}=X(),[c,l]=Y(!1);return t(`div`,{className:`flex items-center gap-2`,children:t(o,{variant:`ghost`,size:`sm`,onClick:async()=>{l(!0);try{let t=r;!t&&n?.content?.source&&(t=(await i.files.getDownloadUrl(n.content.source,`${e.name||`document`}.pdf`,`attachment`)).url),t&&window.open(t,`_blank`)}catch(e){console.error(`Failed to download PDF:`,e),a({status:`error`,title:s(`store.downloadFailed`),description:s(`store.failedToDownloadPdf`),duration:5e3})}finally{l(!1)}},disabled:c,title:`Download PDF`,children:c?t(be,{size:`sm`}):t(Lt,{className:`size-4`})})})}function dx({object:e}){return t(`div`,{className:`h-full`,children:t(sh,{source:{id:e.id,title:e.name,fileName:e.content?.name||e.name,contentType:e.content?.type,sourcePath:e.content?.source},className:`h-full`})})}function fx({object:e,pdfRendition:r,officePdfUrl:i,converters:a,officePdfConverting:o,officePdfError:s}){let{t:c}=X();return o?n(`div`,{className:`flex flex-col justify-center items-center flex-1 gap-2`,children:[t(be,{size:`lg`}),t(`span`,{className:`text-muted`,children:c(`store.convertingToPdf`)})]}):s?n(`div`,{className:`flex flex-col justify-center items-center flex-1 gap-2 text-destructive`,children:[t(st,{className:`size-8`}),t(`span`,{children:s})]}):r?.content?.source?t(`div`,{className:`h-full`,children:t(sh,{source:{id:e.id,title:e.name,fileName:`${e.name||`document`}.pdf`,contentType:`application/pdf`,sourcePath:r.content.source},className:`h-full`})}):i?t(`div`,{className:`h-full`,children:t(sh,{source:{id:e.id,title:e.name,fileName:`${e.name||`document`}.pdf`,contentType:`application/pdf`,url:i},className:`h-full`})}):t(`div`,{className:`h-full`,children:t(sh,{source:{id:e.id,title:e.name,fileName:e.content?.name||e.name,contentType:e.content?.type,sourcePath:e.content?.source},converters:a,className:`h-full`})})}function px({progress:r,status:i,outputFormat:a}){let{t:o}=X(),s=pv(i),c=mv(i),l=a===`xml`,u=r?.percent!=null&&!Number.isNaN(r.percent)?r.percent:0;return n(`div`,{className:`px-4 py-4`,children:[r&&n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex flex-col gap-1`,children:[t(mx,{name:l?`Analyze Layouts`:`Analyze Page`,progress:r.pages}),l&&n(e,{children:[t(mx,{name:`Extract Tables`,progress:r.tables}),t(mx,{name:`Describe Images`,progress:r.images}),t(mx,{name:`Process Visually`,progress:r.visuals})]})]}),n(`div`,{className:`pt-2 text-sm text-muted`,children:[`Progress: `,u,`%`,t(`span`,{className:`px-2`,children:`•`}),t(`span`,{className:s,children:c}),r.started_at&&n(e,{children:[t(`span`,{className:`px-2`,children:`•`}),n(`span`,{children:[((Date.now()-r.started_at)/1e3).toFixed(0),` sec. elapsed`]})]})]}),t(xi,{percent:u})]}),!r&&n(`div`,{className:`flex items-center gap-2 text-muted`,children:[t(be,{size:`sm`}),t(`span`,{children:o(`store.loadingProcessingStatus`)})]})]})}function mx({name:e,progress:t}){return n(`div`,{className:`flex gap-2 text-sm`,children:[n(`span`,{className:`text-muted min-w-36`,children:[e,`:`]}),n(`span`,{children:[t.processed,` of `,t.total]})]})}const hx=Object.values(Cr),gx=Object.values(Tr);function _x({onChange:e,isLoading:r,refresh:i,searchTypes:a}){let{client:s,project:c}=Z(),{t:l}=X(),d=He(),[f,p]=Y(void 0),[m,h]=Y(void 0),g=!!c&&(!!m?.embeddings.text||!!m?.embeddings.image),[_,v]=Y(void 0),y=J(i),b=J(void 0),[x,S]=Y(!1),[C,w]=Y(a||hx),[T,E]=Y(100);K(()=>{a&&w(a)},[a]);let D={},O=!1,k=!1;C.forEach(e=>{e===Cr.full_text?O=!0:k=!0,gx.includes(e)&&(D[e]=!0)}),K(()=>{y.current!==i&&(y.current=i,p(void 0),v(void 0))}),K(()=>{c&&s.projects.retrieve(c.id).then(e=>{h(e.configuration)})},[s.projects.retrieve,c]),K(()=>{_&&d({title:_,status:`success`,duration:2e3})},[_,d]),K(()=>{let t=b.current;b.current=f,t&&(!f||f.length===0)&&e(void 0)},[e,f]);let A=()=>{!g||!f||(e({vector:k?{text:f,config:D}:void 0,full_text:O?f:void 0,limit:T}),v(`Searching...`))},j=e=>{e.key===`Enter`&&A()},M=e=>t=>{w(t?t=>Array.from(new Set([...t,e])):t=>t.filter(t=>t!==e))};return n(`div`,{className:`flex gap-1 items-center`,children:[t(F,{placeholder:l(`store.searchPlaceholder`),value:f,onChange:p,onKeyDown:j,className:`min-w-[200px]`}),t(o,{variant:`ghost`,onClick:()=>S(!0),alt:l(`store.semanticSearchSettings`),className:`ms-1`,children:t(Vn,{size:18})}),n(B,{isOpen:x,onClose:()=>S(!1),children:[t(re,{children:l(`store.searchTypes`)}),t(te,{children:n(`div`,{className:`flex flex-col gap-2`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(u,{id:`search-type-full_text`,checked:C.includes(Cr.full_text),onCheckedChange:M(Cr.full_text)}),t(L,{htmlFor:`search-type-full_text`,children:l(`store.fullText`)})]}),t(`div`,{className:`font-semibold mt-2 mb-1`,children:l(`store.embeddings`)}),gx.map(e=>n(`div`,{className:`flex items-center gap-2`,children:[t(u,{id:`search-type-${e}`,checked:C.includes(e),onCheckedChange:M(e)}),t(L,{htmlFor:`search-type-${e}`,children:e.charAt(0).toUpperCase()+e.slice(1)})]},e)),n(`div`,{className:`mt-3`,children:[t(`span`,{className:`me-2`,children:l(`store.limit`)}),t(ie,{type:`number`,min:1,value:T,onChange:e=>E(Number(e??100)),style:{width:80}})]})]})}),t(ne,{children:t(o,{variant:`outline`,onClick:()=>S(!1),children:l(`store.close`)})})]}),t(o,{variant:`secondary`,isLoading:r,onClick:A,isDisabled:!g,alt:l(`store.semanticSearch`),children:l(`store.search`)})]})}const vx=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function yx(e,t){return(t?e.getTypeLayout(t):vx)??vx}function bx({onUploadDone:e=async()=>{},layout:n,toolbarActions:r}){let i=jv(),a=He(),{t:o}=X(),s=Vv(G(async t=>{await e(t),setTimeout(()=>{console.log(`Delayed refresh after upload to ensure backend consistency`),i.search().then(e=>{e&&a({title:o(`store.documentListRefreshed`),description:o(`store.documentListRefreshedDesc`),status:`info`,duration:3e3})}).catch(e=>{console.error(`Failed to refresh search results:`,e)})},1e3)},[e,i,o,a]));return t(xx,{layout:n,onUpload:G((e,t)=>{let n=i.collectionId;return s(e,t,n)},[i,s]),toolbarActions:r})}function xx({layout:e,onUpload:r,allowFilter:i=!0,allowSearch:a=!0,toolbarActions:o}){let{t:s}=X(),c=jv(),[l,u]=Y(!1),[d,f]=Y(null),{registry:p}=o_(),{search:m,isLoading:h,error:g,objects:_,hasMore:v}=Nv(),[y,b]=Y(p?e||yx(p,m.query.type):vx);K(()=>{e&&b(e)},[e]);let[x,S]=Y(0),[C,w]=Y(0),[T,E]=Y(localStorage.getItem(Xv.LAST_DISPLAYED_VIEW)===`grid`),[D,k]=Y([]),A=J(null),j=J(null),M=G((e,t)=>{u(!1),e.catch(e=>{console.error(t,e)}).finally(()=>{u(!0)})},[]);K(()=>{let e=!1;return m.initialized?(u(!0),()=>{e=!0}):(u(!1),w(0),m.search().catch(t=>{e||console.error(`Initial search failed:`,t)}).finally(()=>{e||u(!0)}),()=>{e=!0})},[m]),K(()=>{_.length<C&&w(_.length)},[_.length,C]),ze(A,()=>{l&&_.length>0&&_.length!==C&&(u(!1),m.loadMore().catch(e=>{console.error(`Failed to load more search results:`,e)}).finally(()=>{w(_.length),u(!0)}))},{deps:[l,_.length]});let N=e=>{if(e?.vector){if(m.query.vector=e.vector,m.query.full_text=e.full_text,m.query.weights=e.weights,m.query.score_aggregation=e.score_aggregation,m.query.dynamic_scaling=e.dynamic_scaling,e.limit!==void 0&&(m.limit=e.limit,m.query.limit=e.limit),!y.find(e=>e.name===`Search Score`)){let e=[...y,{name:`Search Score`,field:`score`,render:e=>typeof e.score==`number`?e.score.toFixed(4):`0.0000`}];b(e)}M(m.search(),`Vector search failed:`)}else e?.full_text?(m.query.full_text=e.full_text,e.limit!==void 0&&(m.limit=e.limit,m.query.limit=e.limit),M(m.search(),`Text search failed:`)):e===void 0&&l&&(delete m.query.vector,delete m.query.full_text,M(m.search(),`Search reset failed:`))},P=Mv(),F=jv(),I=()=>{M(m.search(),`Search refresh failed:`)},L=f_(P),R=p_(F),z=e=>{let t=typeof e==`function`?e(D):e;k(t),R(t)},ee=(e,t)=>{let n=L.find(t=>t.name===e),r={name:e,type:n?.type,placeholder:n?.placeholder,multiple:n?.multiple};z(i=>{let a=i.filter(t=>t.name!==e);if(n?.type===`stringList`||Array.isArray(t)){let n=Array.isArray(t)?t:[t],o=i.find(t=>t.name===e)?.value??[];return[...a,{...r,value:Array.from(new Set([...o,...n]))}]}return[...a,{...r,value:[{value:t,label:t}]}]})},B=new URL(window.location.href),te=B.searchParams.get(`filters`);if(te)try{let e=te.split(`;`),t=e.filter(e=>{let[t]=e.split(`:`),n=decodeURIComponent(t);return n!==`start`&&n!==`end`});if(t.length!==e.length){let e=t.length>0?t.join(`;`):``;e?B.searchParams.set(`filters`,e):B.searchParams.delete(`filters`),window.history.replaceState(window.history.state||{},``,B.toString())}}catch(e){console.error(`Failed to clean start/end filters from URL:`,e)}let ne=li();return n(`div`,{className:`flex flex-col gap-y-2 flex-1 min-h-0 `,children:[t(Cx,{object:d,onClose:()=>f(null)}),g&&t(O,{title:s(`store.error`),children:g.message}),t(Sx,{isLoading:h,refreshTrigger:x,allowFilter:i,allowSearch:a,filterGroups:L,filters:D,handleFilterChange:z,handleVectorSearch:N,handleRefetch:I,setIsGridView:E,toolbarActions:o}),t(`div`,{className:`flex flex-col w-full flex-1 min-h-0 border rounded-md mb-2`,children:n(`div`,{ref:j,className:`flex-1 min-h-0 overflow-y-auto`,children:[t(q_,{onFilter:ee,children:t(Uv,{objects:_,isLoading:!_.length&&h,layout:y,onRowClick:e=>{ne(`/objects/${e.id}`)},previewObject:e=>{let t=_.find(t=>t.id===e)||null;f(t)},selectedObject:d,onUpload:r,isGridView:T,collectionId:c.collectionId})}),v?t(`div`,{ref:A,className:`w-full flex justify-center`,children:t(be,{size:`xl`})}):t(`div`,{className:`text-muted text-center text-sm py-1`,children:`All ${_.length} objects loaded.`})]})})]})}function Sx(e){let{t:r}=X(),{isLoading:i,refreshTrigger:a,allowFilter:s,allowSearch:c,filterGroups:l,filters:u,handleFilterChange:d,handleVectorSearch:f,handleRefetch:p,setIsGridView:m,toolbarActions:h}=e;return n(`div`,{className:`sticky top-0 z-10 bg-background py-2 flex justify-between items-center`,children:[s?t(M,{filterGroups:l,filters:u,setFilters:d,children:n(`div`,{children:[t(`div`,{className:`flex flex-row gap-4 items-center justify-between w-full`,children:n(`div`,{className:`flex gap-2 items-center w-2/3`,children:[c&&t(_x,{onChange:f,isLoading:i,refresh:a,className:`w-full`}),t(A,{})]})}),n(`div`,{className:`flex gap-2 items-center pt-2`,children:[t(k,{}),t(j,{})]})]})}):t(`div`,{className:`flex flex-row gap-4 items-center justify-between w-full`,children:t(`div`,{className:`flex gap-2 items-center w-2/3`,children:c&&t(_x,{onChange:f,isLoading:i,refresh:a})})}),n(`div`,{className:`flex gap-1 items-center`,children:[h,t(Me,{description:r(`store.refresh`),asChild:!0,size:`xs`,placement:`top`,children:t(o,{variant:`outline`,onClick:p,"aria-label":r(`store.refresh`),children:t(Pn,{size:16})})}),t(Xv,{onUpdate:m})]})]})}function Cx({object:e,onClose:r}){let{store:i}=Z(),a=He(),s=li(),{downloadFromContentSource:c}=Vu({client:i,toast:a}),l=e?.content?.source,u=typeof e?.properties?.title==`string`?e.properties.title:e?.name;return e?n(ve,{title:u,isOpen:!0,onClose:r,children:[n(`div`,{className:`flex items-center gap-x-2`,children:[t(o,{variant:`ghost`,size:`sm`,title:`Open Object`,onClick:()=>s(`/objects/${e.id}`),children:t(Vt,{className:`size-4`})}),l&&t(o,{variant:`ghost`,size:`sm`,title:`Download`,onClick:()=>c(l,e.name||e.content?.name),children:t(Lt,{className:`size-4`})})]}),t(y,{className:`my-2`}),t(`div`,{className:`pt-2`,children:t(rx,{object:e,loadText:!0},e.id)})]}):null}const wx=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Revision`,field:`.`,type:`revision`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function Tx({collection:e}){let n=He(),{client:r}=Z(),{registry:i}=o_(),a=async t=>{t.length>0&&await r.store.collections.addMembers(e.id,t).catch(e=>{n({title:`Failed to add objects to collection`,description:e.message,status:`error`})})},o=Ex(e,i);return t(`div`,{className:`flex flex-col h-full`,children:e.dynamic?t(xx,{layout:o}):t(bx,{onUploadDone:a,layout:o})})}function Ex(e,t){let n=e.table_layout;return n&&n.length>0||(e.type&&t&&(n=t?.getTypeLayout(Dr(e.type))),n&&n.length>0)?n:wx}function Dx({className:e,defaultValue:r,onChange:i,isClearable:a,multiple:o}){let{t:s}=X(),{registry:c}=o_(),[l,u]=Y(!1),d=e=>e===null?s(`store.none`):n(`div`,{children:[t(`div`,{className:`text-sm`,children:e.name}),t(`div`,{className:`text-xs text-muted truncate`,children:e.description})]}),[f,p]=Y(),[m,h]=Y([]);return K(()=>{if(!l&&(u(!0),c&&r)){if(o&&Array.isArray(r)){let e=c.types.filter(e=>r.includes(e.id));h(e)}let e=c.types.find(e=>e.id===r);e&&p(e)}},[l,c,r,o]),o?t(`div`,{className:`flex flex-col gap-4 content-between`,children:t(V,{options:c?.types||[],value:m,onChange:e=>{h(e),i(e)},placeholder:s(`store.chooseContentTypes`),optionLabel:d,className:e||`text-sm bg-background`,filterBy:`name`,isClearable:a||!1,multiple:!0})}):t(`div`,{className:`flex flex-col gap-4 content-between`,children:t(V,{options:c?.types||[],value:f,onChange:e=>{p(e||void 0),i(e)},placeholder:s(`store.chooseContentType`),optionLabel:d,className:e||`text-sm bg-background`,filterBy:`name`,isClearable:a||!1})})}function Ox({onClose:r,redirect:i=!0,onAddToCollection:a}){let s=li(),c=He(),{t:l}=X(),[u,d]=Y(!1),{client:f}=Z(),[p,m]=Y({dynamic:!1,name:``,description:``});function h(e,t){m({...p,[e]:t})}return n(e,{children:[t(te,{children:n(`form`,{onSubmit:e=>e.preventDefault(),children:[t(N,{label:l(`type.name`),required:!0,children:t(F,{type:`text`,value:p.name||``,onChange:e=>h(`name`,e)})}),t(N,{label:l(`type.description`),className:`mt-2`,children:t(je,{value:p.description||``,onChange:e=>h(`description`,e.target.value)})}),t(N,{label:l(`store.dynamicCollection`),className:`mt-2`,direction:`row`,description:l(`store.dynamicCollectionDescription`),children:t(Se,{value:p.dynamic||!1,onChange:e=>h(`dynamic`,e)})}),!p.dynamic&&t(N,{label:l(`store.allowedContentTypes`),className:`mt-4`,description:l(`store.allowedContentTypesOptionalDescription`),children:t(Dx,{defaultValue:p.allowed_types||null,onChange:e=>{Array.isArray(e)?h(`allowed_types`,e.map(e=>e.id)):h(`allowed_types`,e?[e.id]:[])},isClearable:!0,multiple:!0})}),t(N,{label:l(`store.contentType`),className:`mt-2`,description:l(`store.typeDescription`),children:t(Dx,{defaultValue:p.type||null,onChange:e=>{Array.isArray(e)?h(`type`,e.length>0?e[0].id:null):h(`type`,e?.id||null)},isClearable:!0})})]})}),t(ne,{children:t(o,{isDisabled:u,onClick:()=>{if(!p?.name?.trim()){c({title:l(`type.nameRequired`),description:l(`store.pleaseProvideName`),status:`error`,duration:5e3});return}p.name=p.name.trim(),p.description&&=p.description.trim(),p.dynamic??=!1,d(!0),f.store.collections.create(p).then(e=>{r(),c({title:l(`store.collectionCreated`),description:`Collection "${e.name}" created successfully`,status:`success`,duration:3e3}),i&&s(`/collections/${e.id}`),a&&a(e.id)}).catch(e=>{c({title:l(`store.failedToCreateCollection`),description:e.message,status:`error`,duration:5e3})}).finally(()=>d(!1))},children:l(`store.createCollection`)})})]})}function kx({isOpen:e,onClose:r}){let{t:i}=X();return n(B,{onClose:r,isOpen:e,children:[t(re,{children:i(`store.createACollection`)}),t(Ox,{onClose:r})]})}Rr.extend(Pi);function Ax(){let{client:r}=Z(),i=He(),{t:a}=X(),[s,c]=Y(),[l,u]=Y(!0),[d,f]=Y(!1),{data:p,error:m,refetch:h}=Le(()=>r.store.collections.search({}),[]);return K(()=>{(p||m)&&u(!1)},[p,m]),m?t(O,{title:a(`store.collectionFetchFailed`),children:Ne(m)}):n(e,{children:[p&&(p.length>0?n(Ee,{className:`w-full`,children:[t(`thead`,{children:n(`tr`,{children:[t(`th`,{children:a(`type.name`)}),t(`th`,{children:a(`type.type`)}),t(`th`,{children:a(`store.created`)}),t(`th`,{})]})}),t(Ce,{columns:4,isLoading:l,children:p.map(e=>n(Te,{children:[t(`td`,{children:n(`div`,{className:`flex items-center gap-2`,children:[t(jx,{isDynamic:e.dynamic}),t(ci,{href:`/collections/${e.id}`,children:e.name})]})}),t(`td`,{children:e.type?.name||`-`}),t(`td`,{children:Rr(e.created_at).fromNow()}),t(`td`,{className:`text-end`,children:t(o,{variant:`destructive`,size:`sm`,onClick:()=>c(e.id),children:t(Yn,{className:`size-4`})})})]},e.id))})]}):t(D,{title:a(`store.noCollections`),buttonLabel:a(`store.newCollections`),onClick:()=>f(!0),children:a(`store.getStartedCollections`)})),t(kx,{isOpen:d,onClose:()=>f(!1)}),t(g,{isOpen:!!s,title:a(`store.deleteCollection`),content:a(`store.areYouSureDeleteCollection`),onConfirm:async()=>{if(s)try{await r.store.collections.delete(s),i({title:a(`store.collectionDeleted`),status:`success`,duration:3e3}),h()}catch(e){console.error(`Failed to delete collection:`,e),i({title:a(`store.failedToDeleteCollection`),description:Ne(e),status:`error`,duration:5e3})}finally{c(void 0)}},onCancel:()=>c(void 0)})]})}function jx({isDynamic:e}){let{t:n}=X();return t(Me,{description:n(e?`store.dynamicCollection`:`store.staticCollection`),className:`me-2`,children:t(e?zn:Xt,{className:`size-5`})})}Rr.extend(Pi);const Mx=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function Nx({objects:e,isLoading:r,onFilter:i,selectedIds:a,onToggleOne:s,allSelected:c,onToggleAll:l}){let{t:u}=X(),d=li(),f=!!s;return n(Ee,{className:`w-full`,children:[t(we,{children:n(`tr`,{children:[f&&t(`th`,{className:`w-[5%]`,children:t(`input`,{type:`checkbox`,checked:!!c,"aria-label":u(`store.actions.selectAllTypes`),onChange:e=>l?.(e.target.checked)})}),t(`th`,{children:u(`store.name`)}),t(`th`,{children:u(`store.strictMode`)}),t(`th`,{children:u(`store.semanticChunking`)}),t(`th`,{children:u(`store.updatedAt`)})]})}),t(Ce,{isLoading:r&&(!e||e.length===0),columns:f?5:4,children:e?.map(e=>n(`tr`,{onClick:()=>d(`/types/${e.id}`),className:`group cursor-pointer hover:bg-muted`,children:[f&&t(`td`,{className:`w-[5%]`,children:t(`input`,{type:`checkbox`,className:We(`checkbox group-hover:inline-block`,a?.includes(e.id)?`inline-block`:`hidden`),checked:a?.includes(e.id)??!1,"aria-label":u(`store.actions.selectType`,{name:e.name}),onClick:e=>e.stopPropagation(),onChange:t=>s?.(e.id,t.target.checked)})}),t(`td`,{className:`group/field`,children:n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:e.name}),t(_,{content:e.id,className:Mx}),i&&t(Me,{description:`Filter by ${e.name}`,asChild:!0,size:`xs`,children:t(o,{variant:`ghost`,size:`sm`,"aria-label":`Filter by ${e.name}`,className:Mx,onClick:t=>{t.stopPropagation(),i(`name`,e.name)},children:t(Yt,{className:`size-3`})})})]})}),t(`td`,{children:e.strict_mode?`Yes`:`No`}),t(`td`,{children:e.is_chunkable?`Yes`:`No`}),t(`td`,{children:t(Me,{description:Rr(e.updated_at).format(`YYYY-MM-DD HH:mm:ss`),children:Rr(e.updated_at).fromNow()})})]},e.id))})]})}function Px({title:e,isOpen:r,onClose:i,okLabel:a,initialPayload:s,isLoading:c}){let{t:l}=X(),u=He(),[d,f]=Y(s?.name),[p,m]=Y(s?.description),h=s?.strict_mode??!1,g=()=>{if(!d){u({status:`error`,title:l(`type.nameRequired`),duration:5e3});return}i({name:d,description:p,strict_mode:h}).then(()=>i())};return n(B,{isOpen:r,onClose:()=>i(),children:[t(re,{children:e}),t(te,{className:`pt-0`,children:n(`div`,{className:`h-full flex flex-col gap-4 content-between`,children:[n(`div`,{children:[t(`div`,{className:`block text-sm font-medium text-muted`,children:l(`type.name`)}),t(F,{value:d,onChange:f})]}),n(`div`,{children:[t(`div`,{className:`block text-sm font-medium text-muted`,children:l(`type.description`)}),t(je,{value:p,onChange:e=>m(e.target.value),minLines:5})]})]})}),t(ne,{children:n(`div`,{className:`flex justify-end gap-4`,children:[t(o,{variant:`secondary`,onClick:()=>i(),children:l(`modal.cancel`)}),t(o,{variant:`primary`,onClick:()=>g(),isLoading:c,children:a})]})})]})}var Fx=class{client;limit;result=new _e({objects:[],isLoading:!1});query={};constructor(e,t=100){this.client=e,this.limit=t}get objects(){return this.result.value.objects}get error(){return this.result.value.error}get isRunning(){return this.result.value.isLoading}getFilterValue(e){return this.query[e]}setFilterValue(e,t){this.query[e]=t,this.search()}reset(e=!1){this.result.value={objects:[],isLoading:e}}_updateRunningState(e){let t=this.result.value;this.result.value={objects:t.objects,isLoading:e,error:t.error}}async _search(e=!1){if(this.isRunning)return Promise.resolve(!1);this.result.value={isLoading:!0,objects:e?this.objects:[]};let t=this.limit,n=this.objects.length;return this.client.types.list({limit:t,offset:n,query:this.query}).then(async e=>(this.result.value={isLoading:!1,objects:this.objects.concat(e)},!0)).catch(e=>{throw this.result.value={error:e,isLoading:!1,objects:this.objects},e})}search(){return this.isRunning?Promise.resolve(!1):this._search(!1)}loadMore(){return this.isRunning?Promise.resolve(!1):this._search(!0)}};const Ix=Ye(void 0);function Lx(){return Qe(Ix)}function Rx(){let e=Lx();return{...Ue(e.result),search:e}}function zx(){return Lx().objects.length}var Bx;(function(e){e.true=`Yes`,e.false=`No`})(Bx||={});function Vx({isDirty:r=!1}){let{store:i}=Z(),{reload:a}=o_(),{t:s}=X(),c=He(),[l,u]=Y(!1),{search:d,isLoading:f,error:p,objects:m}=Rx(),[h,_]=Y([]),[v,y]=Y(!1),[b,x]=Y(!1),S=h.length,C=!!m&&m.length>0&&m.every(e=>h.includes(e.id)),w=m?.filter(e=>h.includes(e.id))??[],T=(e,t)=>{_(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))},E=e=>{_(e&&m?m.map(e=>e.id):[])},k=async()=>{if(!b){x(!0);try{let e=await Promise.allSettled(h.map(e=>i.types.delete(e))),t=e.filter(e=>e.status===`rejected`).length,n=e.length-t;y(!1),_([]),a(),await d.search(),c(t===0?{status:`success`,title:s(`store.actions.typeDeleted`,{count:n}),duration:3e3}:{status:`error`,title:s(`store.actions.typeDeletePartial`,{succeeded:n,failed:t}),duration:5e3})}catch(e){c({status:`error`,title:s(`store.actions.failedToDeleteTypes`),description:e instanceof Error?e.message:void 0,duration:5e3})}finally{x(!1)}}},[A,j]=Y(``),M=Ie(A,500),N=J(null);ze(N,()=>{l&&d.loadMore()},{deps:[l,d]}),K(()=>{d.search().then(()=>u(!0))},[d]),K(()=>{d.query.name=M,d.search().then(()=>u(!0))},[M,d]);let[P,I]=Y(void 0),L=e=>{I(e)};K(()=>{d.query.chunkable=P?P===`Yes`:void 0,d.search().then(()=>u(!0))},[P,d]),K(()=>{r&&l&&d.search().then(()=>u(!0))},[r,l,d]);let[R,z]=Y(!1);return p?t(O,{title:s(`store.failedToFetchTypes`),children:p.message}):n(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[n(`div`,{className:`flex flex-shrink-0 gap-4 items-center`,children:[t(F,{placeholder:s(`store.filterByName`),value:A,onChange:j}),t(V,{className:`w-60`,isClearable:!0,options:Object.values(Bx),value:P,onChange:L,placeholder:s(`store.isChunkable`)}),S>0&&n(`div`,{className:`flex items-center gap-2 ms-auto`,children:[t(`span`,{className:`text-sm font-medium whitespace-nowrap`,children:s(`store.actions.selectedCount`,{n:S})}),t(Me,{description:s(`store.actions.clearSelection`),asChild:!0,children:t(o,{variant:`ghost`,"aria-label":s(`store.actions.clearSelection`),onClick:()=>_([]),children:t(nr,{className:`size-4`})})}),t(o,{variant:`destructive`,isDisabled:b,onClick:()=>y(!0),children:s(b?`store.actions.deleting`:`store.actions.deleteSelected`)})]})]}),t(`div`,{className:`flex flex-col w-full flex-1 min-h-0 border rounded-md my-2`,children:n(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[!f&&m?.length===0?t(D,{title:s(`store.noType`),buttonLabel:s(`store.createType`),onClick:()=>{z(!0)},children:s(`store.getStartedTypes`)}):n(e,{children:[t(Nx,{objects:m,isLoading:f,onFilter:(e,t)=>{e===`name`&&j(t)},selectedIds:h,onToggleOne:T,allSelected:C,onToggleAll:E}),t(`div`,{ref:N,className:`h-4 w-full`})]}),t(Px,{okLabel:`Create`,title:s(`store.createType`),isOpen:R,onClose:async e=>e?i.types.create(e).then(async()=>{c({status:`success`,title:s(`store.typeCreated`),duration:2e3}),a(),d.search().then(()=>u(!0))}).catch(e=>{c({status:`error`,title:s(`store.errorCreatingType`),description:e.message,duration:5e3})}):(z(!1),Promise.resolve())}),t(g,{isOpen:v,title:s(`store.actions.deleteType`,{count:S}),content:n(`div`,{children:[t(`p`,{children:s(`store.actions.deleteTypeConfirm`,{count:S})}),w.length>0&&n(e,{children:[t(`div`,{className:`mt-2`,children:s(`store.actions.affectedItems`)}),t(`ul`,{className:`mt-1 max-h-40 overflow-y-auto rounded-md border p-2 text-sm`,children:w.map(e=>t(`li`,{className:`truncate py-0.5`,children:e.name||e.id},e.id))})]})]}),onConfirm:k,onCancel:()=>y(!1),confirmationValue:`delete`,confirmationLabel:s(`store.actions.typeToConfirmDelete`),confirmationPlaceholder:`delete`})]})})]})}function Hx({objectType:e,onSchemaUpdate:r,readonly:i=!1}){let{store:a}=Z(),{t:s}=X(),c=He(),{theme:l}=Ve(),[u,d]=Y(!1),f=Di(e.object_schema),p=J(void 0),[m,h]=Y(!1),g=q(()=>Ux(f.schema),[f]),_=()=>{m&&!y()||(d(!0),a.types.update(e.id,{object_schema:f.schema}).then(()=>{r(f),c({status:`success`,title:s(`store.schemaUpdated`),description:s(`store.schemaUpdatedSuccess`),duration:2e3})}).catch(e=>{c({status:`error`,title:s(`store.failedToUpdateSchema`),description:e.message,duration:5e3})}).finally(()=>{d(!1)}))},v=()=>{m&&!y()||h(e=>!e)},y=()=>{if(p.current){let e=p.current.getValue();try{let t=Wx(e);Gx(t),f.replaceSchema(t)}catch(e){return c({status:`error`,title:s(`store.invalidJsonSchema`),description:Ne(e),duration:5e3}),!1}}return!0};return t(ae,{title:n(`div`,{className:`flex gap-2 items-center`,children:[t(`div`,{className:`text-base font-semibold`,children:s(`store.schemaEditor`)}),!i&&t(`div`,{children:t(o,{variant:`outline`,size:`sm`,onClick:v,children:s(m?`store.editSchema`:`store.editJson`)})})]}),className:`bg-background! h-full`,action:i?void 0:t(o,{isLoading:u,variant:`outline`,size:`sm`,onClick:_,children:s(`modal.saveChanges`)}),children:m?t(bi,{value:g,language:`json`,editorRef:p,theme:l===`dark`?`vs-dark`:`vs`,options:{readOnly:i}}):t(Si,{schema:f,readonly:i})})}function Ux(e){return e?JSON.stringify(e,null,2):``}function Wx(e){if(e?.trim())return JSON.parse(e.trim())}const Gx=e=>{try{new Mi({strict:!1}).compile(e)}catch(e){throw Error(`Invalid JSON Schema definition: ${Ne(e)}`,{cause:e})}};function Kx({isOpen:e,onClose:r,title:i,children:a,initialSelectedType:s=null,allowNone:c=!0}){let{t:l}=X(),u=i??l(`store.selectContentType`),{registry:d}=o_(),[f,p]=Y(s),m=d?.types||[],h=()=>{r(void 0)};return n(B,{isOpen:e,onClose:h,className:`w-full max-w-xl mx-auto`,children:[t(re,{children:u}),n(te,{children:[a,n(`div`,{className:`mb-4 mt-4`,children:[n(`div`,{className:`block text-sm font-medium mb-2`,children:[l(`store.contentType`),` `,c&&t(`span`,{className:`text-gray-500 font-normal`,children:l(`store.optional`)})]}),c?t(V,{options:m,value:f,optionLabel:e=>e?e.name:l(`store.selectContentTypeLabel`),placeholder:l(`store.selectContentTypeAuto`),onChange:e=>p(e||null),filterBy:`name`,isClearable:!0}):t(V,{options:m,value:f,optionLabel:e=>e?e.name:l(`store.selectContentTypeLabel`),placeholder:l(`store.selectContentTypeLabel`),onChange:e=>p(e||null),filterBy:`name`})]}),!f&&n(`div`,{className:`flex items-center text-attention`,children:[t(_t,{className:`size-4 me-1`}),l(`store.automaticTypeDetection`),t(Me,{description:l(`store.automaticTypeDetectionDescription`),placement:`top`,size:`xs`,children:t(on,{className:`size-3 ms-2`})})]})]}),n(ne,{children:[t(o,{variant:`ghost`,onClick:h,alt:l(`modal.cancel`),children:l(`modal.cancel`)}),t(o,{onClick:()=>{r(f?.id??null),p(null)},alt:l(`store.confirmSelection`),children:l(`modal.confirm`)})]})]})}function qx({children:e,limit:n,name:r,chunkable:i}){let{store:a}=Z(),o=q(()=>{let e=new Fx(a,n);return e.query.name=r,e.query.chunkable=i,e},[i,n,r,a]);return t(Ix.Provider,{value:o,children:e})}function Jx({objectType:e,onLayoutUpdate:n,readonly:r=!1}){let i=He(),{theme:a}=Ve(),{t:s}=X(),[c,l]=Y(!1),{store:u}=Z(),d=J(void 0),f=q(()=>Yx(e.table_layout),[e.table_layout]),p=(e,t)=>{i({status:`error`,title:e,description:t,duration:5e3})};return t(ae,{title:`Table Layout Editor`,className:`bg-background! h-full`,action:r?void 0:t(o,{isLoading:c,variant:`outline`,size:`sm`,onClick:()=>{if(!d.current)return;let t=d.current.getValue(),r;if(!t)r=null;else try{r=JSON.parse(t)}catch(e){return p(`Invalid JSON`,Ne(e))}if(!Array.isArray(r))return p(`Invalid JSON`,`The table layout must be an array`);if(r.some(e=>!e?.name||!e.field))return p(`Invalid JSON`,`A table layout entry must contain the following properties:] {field, name, converter?}`);l(!0),u.types.update(e.id,{table_layout:r}).then(e=>{i({status:`success`,title:s(`store.tableLayoutUpdated`),description:s(`store.tableLayoutUpdatedDesc`),duration:2e3}),n(e.table_layout)}).catch(e=>{i({status:`error`,title:s(`store.failedToUpdateTableLayout`),description:e.message,duration:5e3})}).finally(()=>{l(!1)})},children:s(`store.saveChanges`)}),children:t(`div`,{className:`h-full`,children:t(bi,{value:f,language:`json`,editorRef:d,theme:a===`dark`?`vs-dark`:`vs`,options:{readOnly:r}})})})}function Yx(e){return e?JSON.stringify(e,null,2):`[
|
|
449
|
+
+ `)||e.includes(`:!1}function Hx(e){return e?`h-full overflow-auto`:`hidden`}var Ux;(function(e){e.Text=`text`,e.Image=`image`,e.Video=`video`,e.Audio=`audio`,e.Pdf=`pdf`,e.Transcript=`transcript`})(Ux||={});function Wx({object:e,loadText:r,refetch:i,canEditProperties:a=!0}){let o=Ye(),{t:s}=X(),c=async(e,t)=>{try{await navigator.clipboard.writeText(e),o({status:`success`,title:s(`store.contentCopied`,{type:s(t===`text`?`store.contentType`:`store.properties`)}),description:s(`store.successfullyCopied`,{type:t}),duration:2e3})}catch(e){console.error(`Failed to copy ${t}:`,e),o({status:`error`,title:s(`store.copyFailed`),description:s(`store.failedToCopy`,{type:t}),duration:5e3})}};return n(ve,{direction:`horizontal`,className:`h-full`,children:[t(_e,{defaultSize:67,className:`min-w-[100px]`,children:t(Kx,{object:e,loadText:r??!1,handleCopyContent:c,refetch:i})}),t(ge,{withHandle:!0}),t(_e,{defaultSize:33,className:`min-w-[100px]`,children:t(Gx,{object:e,refetch:i??(()=>Promise.resolve()),handleCopyContent:c,canEditProperties:a})})]})}function Gx({object:r,refetch:a,handleCopyContent:s,canEditProperties:c}){let{t:l}=X(),[u,d]=Y(!1),[f,p]=Y(!1),m=Nb(r.id);return n(e,{children:[n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex justify-between items-center px-2`,children:[n(`div`,{className:`flex items-center gap-1 bg-muted mb-2 p-1 rounded`,children:[t(o,{variant:`${u?`ghost`:`primary`}`,size:`sm`,title:l(`store.previewProperties`),onClick:()=>d(!u),children:`Properties`}),t(o,{variant:`${u?`primary`:`ghost`}`,size:`sm`,title:l(`store.viewInJsonFormat`),onClick:()=>d(!u),children:`JSON`})]}),n(`div`,{className:`flex items-center gap-2`,children:[r.properties&&t(o,{variant:`ghost`,size:`sm`,title:`Copy properties`,onClick:()=>s(JSON.stringify(r.properties,null,2),`properties`),children:t(Wt,{className:`size-4`})}),c&&t(wx,{permission:zr.content_write,variant:`ghost`,size:`sm`,onClick:()=>{p(!0)},title:`Edit properties`,className:`flex items-center gap-2`,children:t(sr,{className:`size-4`})})]})]}),m&&r.properties&&n(`div`,{className:`flex items-center gap-2 px-2 pb-2`,children:[typeof m.confidence==`number`&&t(i,{variant:m.confidence>=.95?`success`:`attention`,title:l(`grounded.confidenceHint`),children:l(`grounded.confidence`,{percent:Math.floor(m.confidence*100)})}),t(i,{variant:m.verified===m.total?`success`:`attention`,children:l(`grounded.verifiedOf`,{verified:m.verified,total:m.total})})]}),r.properties?t(`div`,{className:`flex-1 min-h-0 px-2`,children:t(Fi,{value:r.properties,viewCode:u})}):t(`div`,{className:`flex-1 min-h-0 px-2`,children:t(`div`,{children:l(`store.noPropertiesDefined`)})})]}),t(jx,{isOpen:f,onClose:()=>{p(!1)},object:r,refetch:a})]})}function Kx(e){let{client:n}=Z(),r=e.object.type,i=r?.id,a=r?.default_view,{data:o}=Ue(async()=>!i||a?null:(await Dx(n,i))?.intake?.default_view??null,[i,a]),s=a??o;return i&&!a&&o===void 0?t(`div`,{className:`flex h-full items-center justify-center`,children:t(Ee,{size:`lg`})}):t(qx,{...e,defaultView:s??void 0})}function qx({object:e,loadText:r,handleCopyContent:i,refetch:a,defaultView:s}){let{client:c}=Z(),{t:l}=X(),u=e?.metadata?.type===Ar.Image,d=e?.metadata?.type===Ar.Video,f=e?.metadata?.type===Ar.Audio,p=e?.content?.type===`application/pdf`,m=e?.content?.type?G_(e.content.type):!1,h=zx(e?.status),g=!!(e.transcript&&(d||f)),_=e.metadata?.renditions?.find(e=>e.name===Lr),v=()=>{switch(s){case`text`:return Ux.Text;case`pdf`:if(p||m||_)return Ux.Pdf;break;case`image`:if(u)return Ux.Image;break;case`properties`:return Ux.Text;default:break}return d?Ux.Video:f?Ux.Audio:u?Ux.Image:Ux.Text},y=Mb(e.id),[b,x]=Y(v()),[S,C]=Y(b===Ux.Pdf);K(()=>{b===Ux.Pdf&&C(!0)},[b]);let[w,T]=Y(!1),E=!!(e.content?.source&&e.content?.type&&!h&&!e.is_locked&&e.user_permissions?.can_write!==!1&&(e.content.type.startsWith(`text/`)||e.content.type===`application/json`||e.content.type===`application/xml`)),{fullText:D,displayText:O,isLoading:k,isCropped:A,loadText:j}=Fx(e.id,e.text,r),M=(p||m)&&h&&(b===Ux.Text||b===Ux.Pdf),{progress:N,status:P,isComplete:F}=Ix(e.id,M),{pdfUrl:I,isConverting:L,error:R,triggerConversion:ee}=Lx(e.id,m),te=q(()=>[{id:`office-pdf-rendition`,target:`pdf`,canConvert:({contentType:e,extension:t})=>m||(e?G_(e):!1)||[`doc`,`docx`,`ppt`,`pptx`].includes(t),convert:async()=>{let t=await c.objects.getRendition(e.id,{format:Ir.pdf,generate_if_missing:!0,sign_url:!0,block_on_generation:!0});return t.status===`found`&&t.renditions?.length?{url:t.renditions[0],contentType:`application/pdf`,fileName:`${e.name||`document`}.pdf`}:null}}],[c,m,e.id,e.name]);K(()=>{F&&P===Wr.COMPLETED&&j()},[F,P,j]);let z=(p||m)&&h&&!F&&P===Wr.RUNNING,ne=b===Ux.Pdf&&!z,B=z&&(b===Ux.Text||b===Ux.Pdf),re=S&&!z,ie=J(null);return n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex justify-between items-center px-2 shrink-0`,children:[n(`div`,{className:`flex items-center gap-2 mb-2`,children:[n(`div`,{className:`flex items-center gap-1 bg-muted p-1 rounded`,children:[u&&t(o,{variant:b===Ux.Image?`primary`:`ghost`,size:`sm`,title:l(`store.viewImage`),onClick:()=>x(Ux.Image),children:`Image`}),d&&t(o,{variant:b===Ux.Video?`primary`:`ghost`,size:`sm`,title:l(`store.viewVideo`),onClick:()=>x(Ux.Video),children:`Video`}),f&&t(o,{variant:b===Ux.Audio?`primary`:`ghost`,size:`sm`,title:l(`store.viewAudio`),onClick:()=>x(Ux.Audio),children:`Audio`}),g&&t(o,{variant:b===Ux.Transcript?`primary`:`ghost`,size:`sm`,title:l(`store.viewTranscript`),onClick:()=>x(Ux.Transcript),children:`Transcript`}),t(o,{variant:b===Ux.Text?`primary`:`ghost`,size:`sm`,title:l(`store.viewText`),onClick:()=>x(Ux.Text),children:`Text`}),p&&t(o,{variant:b===Ux.Pdf?`primary`:`ghost`,size:`sm`,title:l(`store.viewPdf`),onClick:()=>x(Ux.Pdf),children:`PDF`}),m&&t(o,{variant:b===Ux.Pdf?`primary`:`ghost`,size:`sm`,title:l(`store.viewAsPdf`),onClick:()=>{x(Ux.Pdf),!_&&!I&&!L&&ee()},disabled:L,children:L?t(Ee,{size:`sm`}):`PDF`})]}),n(`div`,{className:`flex items-center gap-1`,children:[t(Zx,{object:e}),t(Qx,{objectId:e.id,available:y})]})]}),b===Ux.Text&&!z&&!w&&t(Jx,{object:e,text:O,fullText:D,handleCopyContent:i,textContainerRef:ie,isEditing:w,onToggleEdit:()=>T(!0),canEdit:E}),b===Ux.Pdf&&m&&(_||I)&&t($x,{object:e,pdfRendition:_,officePdfUrl:I})]}),b===Ux.Image&&t(`div`,{className:Hx(!0),children:t(px,{object:e})}),b===Ux.Video&&t(`div`,{className:Hx(!0),children:t(mx,{object:e})}),b===Ux.Audio&&t(`div`,{className:Hx(!0),children:t(fx,{object:e})}),g&&b===Ux.Transcript&&t(`div`,{className:Hx(!0),children:t(Xx,{object:e,handleCopyContent:i})}),p&&re&&t(`div`,{className:Hx(ne),children:t(eS,{object:e})}),m&&re&&t(`div`,{className:Hx(ne),children:t(tS,{object:e,pdfRendition:_,officePdfUrl:I,converters:te,officePdfConverting:L,officePdfError:R})}),B&&t(`div`,{className:Hx(!0),children:t(nS,{progress:N,status:P})}),b===Ux.Text&&!z&&!w&&k&&t(`div`,{className:Hx(!0),children:t(`div`,{className:`flex justify-center items-center flex-1`,children:t(Ee,{size:`lg`})})}),b===Ux.Text&&!z&&!w&&!k&&t(`div`,{className:Hx(!0),children:t(Yx,{object:e,text:O,isTextCropped:A,textContainerRef:ie})}),w&&b===Ux.Text&&D!=null&&t(Nx,{object:e,text:D,onClose:()=>T(!1),onSaved:()=>{T(!1),j(),a?.()}})]})}function Jx({object:r,text:i,fullText:a,handleCopyContent:s,onToggleEdit:c,canEdit:l}){let{client:u,project:d}=Z(),f=Ye(),{t:p}=X(),m=r.content,{renderDocument:h,isDownloading:g}=fd({client:u,toast:f}),{data:_}=Ue(()=>d?u.projects.retrieve(d.id):Promise.resolve(void 0),[d?.id]),v=_?.configuration?.pdf_template_object_id,y=m?.type&&m.type===`text/markdown`,b=async(e,t)=>{if(g)return;f({status:`info`,title:`Preparing ${e.toUpperCase()}`,description:p(`store.renderingDocument`),duration:2e3});let n=t===!1?void 0:v;await h(r.id,{format:e,title:r.name||`document`,useDefaultTemplate:t,templateObjectId:n})};return t(`div`,{className:`h-[41px] text-lg font-semibold flex justify-between items-center px-2`,children:n(`div`,{className:`flex items-center gap-2`,children:[a&&n(e,{children:[t(o,{variant:`ghost`,size:`sm`,title:`Copy text`,onClick:()=>s(a,`text`),children:t(Wt,{className:`size-4`})}),l&&c&&t(wx,{permission:zr.content_write,variant:`ghost`,size:`sm`,onClick:c,title:p(`store.editText`),className:`flex items-center gap-2`,children:t(sr,{className:`size-4`})})]}),g?t(o,{variant:`ghost`,size:`sm`,disabled:!0,className:`flex items-center gap-2`,title:`download`,children:t(Ee,{size:`sm`})}):n(w,{trigger:t(o,{variant:`ghost`,size:`sm`,disabled:!i,className:`flex items-center gap-2`,title:`download`,children:t(qt,{className:`size-4`})}),children:[a&&t(B,{onClick:e=>{if(e.preventDefault(),e.stopPropagation(),!a)return;let t=`txt`,n=`text/plain`;m?.type===`application/xml`||m?.type===`text/xml`?(t=`xml`,n=`text/xml`):y&&(t=`md`,n=`text/markdown`);let i=new Blob([a],{type:n}),o=URL.createObjectURL(i),s=`${r.name||`document`}.${t}`,c=document.createElement(`a`);c.href=o,c.download=s,c.style.display=`none`,setTimeout(()=>{c.click(),URL.revokeObjectURL(o)},0)},children:n(`div`,{className:`flex items-center gap-2`,children:[t(qt,{className:`size-4`}),`Download Text`]})}),y&&i&&n(e,{children:[t(B,{onClick:()=>b(Ir.docx),children:n(`div`,{className:`flex items-center gap-2`,children:[t(qt,{className:`size-4`}),`Export as DOCX`]})}),t(B,{onClick:()=>b(Ir.pdf,!1),children:n(`div`,{className:`flex items-center gap-2`,children:[t(qt,{className:`size-4`}),`Export as PDF`]})}),t(B,{onClick:()=>b(Ir.pdf),children:n(`div`,{className:`flex items-center gap-2`,children:[t(qt,{className:`size-4`}),`Export as Branded PDF`]})})]})]})]})})}const Yx=it(({object:r,text:i,isTextCropped:a,textContainerRef:o})=>{let{t:s}=X(),c=zx(r?.status),l=r.content,u=Bx(r)===`xml`||l?.type===`application/xml`||l?.type===`text/xml`,d=l?.type&&(l.type===`text/markdown`||l.type===`text/plain`),f=!u&&(d||Vx(i)),p={id:r.id,title:r.name,fileName:r.content?.name||r.name,contentType:u?`text/xml`:f?`text/markdown`:r.content?.type,content:i,sourcePath:r.content?.source};return i?n(e,{children:[a&&t(`div`,{className:`px-2 py-2 bg-attention/10 border-s-4 border-attention mx-2 mb-2 rounded`,children:n(`div`,{className:`flex items-center gap-2 text-attention`,children:[t(ht,{className:`size-4`}),t(`span`,{className:`text-sm font-semibold`,children:s(`store.showingFirst128K`)})]})}),t(`div`,{className:`max-w-7xl px-2 h-full overflow-auto`,ref:o,children:t(lb,{source:p,className:`h-full`,bodyClassName:`overflow-auto`,markdownComponents:Rx()})})]}):t(`div`,{className:`px-2`,children:t(`div`,{children:c?`Extracting content...`:`No content`})})});function Xx({object:e,handleCopyContent:r}){let{t:i}=X(),a=e.transcript,s=a?.text,c=a?.segments,l=s||(c?c.map(e=>e.text).join(` `):``),u=e=>{let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`:`${n}:${r.toString().padStart(2,`0`)}`};return n(`div`,{className:`flex flex-col h-full`,children:[t(`div`,{className:`flex justify-end items-center px-2 mb-2`,children:l&&t(o,{variant:`ghost`,size:`sm`,title:`Copy transcript`,onClick:()=>r(l,`text`),children:t(Wt,{className:`size-4`})})}),t(`div`,{className:`h-full} overflow-auto px-2`,children:c&&c.length>0?t(`div`,{className:`space-y-2`,children:c.map((e,r)=>n(`div`,{className:`flex gap-3 text-sm`,children:[n(`span`,{className:`text-muted font-mono text-xs shrink-0 pt-0.5`,children:[u(e.start),e.end&&` - ${u(e.end)}`]}),t(`span`,{className:`flex-1`,children:e.text})]},`segment-${r}`))}):s?t(`pre`,{className:`text-wrap bg-muted text-muted p-2 whitespace-pre-wrap`,children:s}):t(`div`,{className:`text-muted`,children:i(`store.noTranscriptAvailable`)})})]})}function Zx({object:r}){let[i,a]=Y(!1);return Bx(r)===`markdown`?n(e,{children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>a(!0),title:`Side by side view`,children:t(an,{className:`size-4`})}),i&&t(pe,{children:t(ox,{objectId:r.id,onClose:()=>a(!1)})})]}):null}function Qx({objectId:r,available:i}){let{t:a}=X(),[s,c]=Y(!1);return i?n(e,{children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>c(!0),title:a(`grounded.title`),"aria-label":a(`grounded.title`),children:t($n,{className:`size-4`})}),s&&t(pe,{children:t(Fb,{objectId:r,onClose:()=>c(!1)})})]}):null}function $x({object:e,pdfRendition:n,officePdfUrl:r}){let{client:i}=Z(),a=Ye(),{t:s}=X(),[c,l]=Y(!1);return t(`div`,{className:`flex items-center gap-2`,children:t(o,{variant:`ghost`,size:`sm`,onClick:async()=>{l(!0);try{let t=r;!t&&n?.content?.source&&(t=(await i.files.getDownloadUrl(n.content.source,`${e.name||`document`}.pdf`,`attachment`)).url),t&&window.open(t,`_blank`)}catch(e){console.error(`Failed to download PDF:`,e),a({status:`error`,title:s(`store.downloadFailed`),description:s(`store.failedToDownloadPdf`),duration:5e3})}finally{l(!1)}},disabled:c,title:`Download PDF`,children:c?t(Ee,{size:`sm`}):t(qt,{className:`size-4`})})})}function eS({object:e}){return t(`div`,{className:`h-full`,children:t(lb,{source:{id:e.id,title:e.name,fileName:e.content?.name||e.name,contentType:e.content?.type,sourcePath:e.content?.source},className:`h-full`})})}function tS({object:e,pdfRendition:r,officePdfUrl:i,converters:a,officePdfConverting:o,officePdfError:s}){let{t:c}=X();return o?n(`div`,{className:`flex flex-col justify-center items-center flex-1 gap-2`,children:[t(Ee,{size:`lg`}),t(`span`,{className:`text-muted`,children:c(`store.convertingToPdf`)})]}):s?n(`div`,{className:`flex flex-col justify-center items-center flex-1 gap-2 text-destructive`,children:[t(ht,{className:`size-8`}),t(`span`,{children:s})]}):r?.content?.source?t(`div`,{className:`h-full`,children:t(lb,{source:{id:e.id,title:e.name,fileName:`${e.name||`document`}.pdf`,contentType:`application/pdf`,sourcePath:r.content.source},className:`h-full`})}):i?t(`div`,{className:`h-full`,children:t(lb,{source:{id:e.id,title:e.name,fileName:`${e.name||`document`}.pdf`,contentType:`application/pdf`,url:i},className:`h-full`})}):t(`div`,{className:`h-full`,children:t(lb,{source:{id:e.id,title:e.name,fileName:e.content?.name||e.name,contentType:e.content?.type,sourcePath:e.content?.source},converters:a,className:`h-full`})})}function nS({progress:r,status:i}){let{t:a}=X(),o=Q_(i),s=$_(i),c=r?.phase===`grounded_extraction`,l=r?.percent!=null&&!Number.isNaN(r.percent)?r.percent:0;return n(`div`,{className:`px-4 py-4`,children:[r&&n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex flex-col gap-1`,children:[t(rS,{name:c?`Prepare Evidence`:`Analyze Page`,progress:r.pages}),c&&n(e,{children:[t(rS,{name:`Run OCR`,progress:r.images}),t(rS,{name:`Extract Grounded Data`,progress:r.tables}),t(rS,{name:`Review and Annotate`,progress:r.visuals})]})]}),n(`div`,{className:`pt-2 text-sm text-muted`,children:[`Progress: `,l,`%`,t(`span`,{className:`px-2`,children:`•`}),t(`span`,{className:o,children:s}),r.started_at&&n(e,{children:[t(`span`,{className:`px-2`,children:`•`}),n(`span`,{children:[((Date.now()-r.started_at)/1e3).toFixed(0),` sec. elapsed`]})]})]}),t(zi,{percent:l})]}),!r&&n(`div`,{className:`flex items-center gap-2 text-muted`,children:[t(Ee,{size:`sm`}),t(`span`,{children:a(`store.loadingProcessingStatus`)})]})]})}function rS({name:e,progress:t}){return n(`div`,{className:`flex gap-2 text-sm`,children:[n(`span`,{className:`text-muted min-w-36`,children:[e,`:`]}),n(`span`,{children:[t.processed,` of `,t.total]})]})}const iS=Object.values(Vr),aS=Object.values(Ur);function oS({onChange:e,isLoading:r,refresh:i,searchTypes:a}){let{client:s,project:c}=Z(),{t:l}=X(),u=Ye(),[d,f]=Y(void 0),[p,h]=Y(void 0),g=!!c&&(!!p?.embeddings.text||!!p?.embeddings.image),[_,v]=Y(void 0),y=J(i),b=J(void 0),[x,S]=Y(!1),[C,w]=Y(a||iS),[T,E]=Y(100);K(()=>{a&&w(a)},[a]);let D={},O=!1,k=!1;C.forEach(e=>{e===Vr.full_text?O=!0:k=!0,aS.includes(e)&&(D[e]=!0)}),K(()=>{y.current!==i&&(y.current=i,f(void 0),v(void 0))}),K(()=>{c&&s.projects.retrieve(c.id).then(e=>{h(e.configuration)})},[s.projects.retrieve,c]),K(()=>{_&&u({title:_,status:`success`,duration:2e3})},[_,u]),K(()=>{let t=b.current;b.current=d,t&&(!d||d.length===0)&&e(void 0)},[e,d]);let A=()=>{!g||!d||(e({vector:k?{text:d,config:D}:void 0,full_text:O?d:void 0,limit:T}),v(`Searching...`))},j=e=>{e.key===`Enter`&&A()},M=e=>t=>{w(t?t=>Array.from(new Set([...t,e])):t=>t.filter(t=>t!==e))};return n(`div`,{className:`flex gap-1 items-center`,children:[t(ee,{placeholder:l(`store.searchPlaceholder`),value:d,onChange:f,onKeyDown:j,className:`min-w-[200px]`}),t(o,{variant:`ghost`,onClick:()=>S(!0),title:l(`store.semanticSearchSettings`),className:`ms-1`,children:t(nr,{size:18})}),n(ie,{isOpen:x,onClose:()=>S(!1),children:[t(se,{children:l(`store.searchTypes`)}),t(ae,{children:n(`div`,{className:`flex flex-col gap-2`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:`search-type-full_text`,checked:C.includes(Vr.full_text),onCheckedChange:M(Vr.full_text)}),t(z,{htmlFor:`search-type-full_text`,children:l(`store.fullText`)})]}),t(`div`,{className:`font-semibold mt-2 mb-1`,children:l(`store.embeddings`)}),aS.map(e=>n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:`search-type-${e}`,checked:C.includes(e),onCheckedChange:M(e)}),t(z,{htmlFor:`search-type-${e}`,children:e.charAt(0).toUpperCase()+e.slice(1)})]},e)),n(`div`,{className:`mt-3`,children:[t(`span`,{className:`me-2`,children:l(`store.limit`)}),t(ce,{type:`number`,min:1,value:T,onChange:e=>E(Number(e??100)),style:{width:80}})]})]})}),t(oe,{children:t(o,{variant:`outline`,onClick:()=>S(!1),children:l(`store.close`)})})]}),t(o,{variant:`secondary`,isLoading:r,onClick:A,isDisabled:!g,title:l(`store.semanticSearch`),children:l(`store.search`)})]})}const sS=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function cS(e,t){return(t?e.getTypeLayout(t):sS)??sS}function lS({onUploadDone:e=async()=>{},layout:n,toolbarActions:r}){let i=gv(),a=Ye(),{t:o}=X(),s=Ev(G(async t=>{await e(t),setTimeout(()=>{console.log(`Delayed refresh after upload to ensure backend consistency`),i.search().then(e=>{e&&a({title:o(`store.documentListRefreshed`),description:o(`store.documentListRefreshedDesc`),status:`info`,duration:3e3})}).catch(e=>{console.error(`Failed to refresh search results:`,e)})},1e3)},[e,i,o,a]));return t(uS,{layout:n,onUpload:G((e,t)=>{let n=i.collectionId;return s(e,t,n)},[i,s]),toolbarActions:r})}function uS({layout:e,onUpload:r,allowFilter:i=!0,allowSearch:a=!0,toolbarActions:o}){let{t:s}=X(),c=gv(),[l,u]=Y(!1),[d,f]=Y(null),{registry:p}=Gg(),{search:m,isLoading:h,error:g,objects:_,hasMore:v}=vv(),[y,b]=Y(p?e||cS(p,m.query.type):sS);K(()=>{e&&b(e)},[e]);let[x,S]=Y(0),[C,w]=Y(0),[T,E]=Y(localStorage.getItem(Fv.LAST_DISPLAYED_VIEW)===`grid`),[D,O]=Y([]),k=J(null),A=J(null),j=G((e,t)=>{u(!1),e.catch(e=>{console.error(t,e)}).finally(()=>{u(!0)})},[]);K(()=>{let e=!1;return m.initialized?(u(!0),()=>{e=!0}):(u(!1),w(0),m.search().catch(t=>{e||console.error(`Initial search failed:`,t)}).finally(()=>{e||u(!0)}),()=>{e=!0})},[m]),K(()=>{_.length<C&&w(_.length)},[_.length,C]),Ke(k,()=>{l&&_.length>0&&_.length!==C&&(u(!1),m.loadMore().catch(e=>{console.error(`Failed to load more search results:`,e)}).finally(()=>{w(_.length),u(!0)}))},{deps:[l,_.length]});let N=e=>{if(e?.vector){if(m.query.vector=e.vector,m.query.full_text=e.full_text,m.query.weights=e.weights,m.query.score_aggregation=e.score_aggregation,m.query.dynamic_scaling=e.dynamic_scaling,e.limit!==void 0&&(m.limit=e.limit,m.query.limit=e.limit),!y.find(e=>e.name===`Search Score`)){let e=[...y,{name:`Search Score`,field:`score`,render:e=>typeof e.score==`number`?e.score.toFixed(4):`0.0000`}];b(e)}j(m.search(),`Vector search failed:`)}else e?.full_text?(m.query.full_text=e.full_text,e.limit!==void 0&&(m.limit=e.limit,m.query.limit=e.limit),j(m.search(),`Text search failed:`)):e===void 0&&l&&(delete m.query.vector,delete m.query.full_text,j(m.search(),`Search reset failed:`))},P=_v(),F=gv(),I=()=>{j(m.search(),`Search refresh failed:`)},L=Zg(P),R=Qg(F),ee=e=>{let t=typeof e==`function`?e(D):e;O(t),R(t)},te=(e,t)=>{let n=L.find(t=>t.name===e),r={name:e,type:n?.type,placeholder:n?.placeholder,multiple:n?.multiple};ee(i=>{let a=i.filter(t=>t.name!==e);if(n?.type===`stringList`||Array.isArray(t)){let n=Array.isArray(t)?t:[t],o=i.find(t=>t.name===e)?.value??[];return[...a,{...r,value:Array.from(new Set([...o,...n]))}]}return[...a,{...r,value:[{value:t,label:t}]}]})},z=new URL(window.location.href),ne=z.searchParams.get(`filters`);if(ne)try{let e=ne.split(`;`),t=e.filter(e=>{let[t]=e.split(`:`),n=decodeURIComponent(t);return n!==`start`&&n!==`end`});if(t.length!==e.length){let e=t.length>0?t.join(`;`):``;e?z.searchParams.set(`filters`,e):z.searchParams.delete(`filters`),window.history.replaceState(window.history.state||{},``,z.toString())}}catch(e){console.error(`Failed to clean start/end filters from URL:`,e)}let B=Di();return n(`div`,{className:`flex flex-col gap-y-2 flex-1 min-h-0 `,children:[t(fS,{object:d,onClose:()=>f(null)}),g&&t(M,{title:s(`store.error`),children:g.message}),t(dS,{isLoading:h,refreshTrigger:x,allowFilter:i,allowSearch:a,filterGroups:L,filters:D,handleFilterChange:ee,handleVectorSearch:N,handleRefetch:I,setIsGridView:E,toolbarActions:o}),t(`div`,{className:`flex flex-col w-full flex-1 min-h-0 border rounded-md mb-2`,children:n(`div`,{ref:A,className:`flex-1 min-h-0 overflow-y-auto`,children:[t(M_,{onFilter:te,children:t(Ov,{objects:_,isLoading:!_.length&&h,layout:y,onRowClick:e=>{B(`/objects/${e.id}`)},previewObject:e=>{let t=_.find(t=>t.id===e)||null;f(t)},selectedObject:d,onUpload:r,isGridView:T,collectionId:c.collectionId})}),v?t(`div`,{ref:k,className:`w-full flex justify-center`,children:t(Ee,{size:`xl`})}):t(`div`,{className:`text-muted text-center text-sm py-1`,children:`All ${_.length} objects loaded.`})]})})]})}function dS(e){let{t:r}=X(),{isLoading:i,refreshTrigger:a,allowFilter:s,allowSearch:c,filterGroups:l,filters:u,handleFilterChange:d,handleVectorSearch:f,handleRefetch:p,setIsGridView:m,toolbarActions:h}=e;return n(`div`,{className:`sticky top-0 z-10 bg-background py-2 flex justify-between items-center`,children:[s?t(I,{filterGroups:l,filters:u,setFilters:d,children:n(`div`,{children:[t(`div`,{className:`flex flex-row gap-4 items-center justify-between w-full`,children:n(`div`,{className:`flex gap-2 items-center w-2/3`,children:[c&&t(oS,{onChange:f,isLoading:i,refresh:a,className:`w-full`}),t(P,{})]})}),n(`div`,{className:`flex gap-2 items-center pt-2`,children:[t(N,{}),t(F,{})]})]})}):t(`div`,{className:`flex flex-row gap-4 items-center justify-between w-full`,children:t(`div`,{className:`flex gap-2 items-center w-2/3`,children:c&&t(oS,{onChange:f,isLoading:i,refresh:a})})}),n(`div`,{className:`flex gap-1 items-center`,children:[h,t(o,{variant:`outline`,onClick:p,title:r(`store.refresh`),children:t(qn,{size:16})}),t(Fv,{onUpdate:m})]})]})}function fS({object:e,onClose:r}){let{store:i}=Z(),a=Ye(),s=Di(),{downloadFromContentSource:c}=fd({client:i,toast:a}),l=e?.content?.source,u=typeof e?.properties?.title==`string`?e.properties.title:e?.name;return e?n(Ce,{title:u,isOpen:!0,onClose:r,children:[n(`div`,{className:`flex items-center gap-x-2`,children:[t(o,{variant:`ghost`,size:`sm`,title:`Open Object`,onClick:()=>s(`/objects/${e.id}`),children:t(Zt,{className:`size-4`})}),l&&t(o,{variant:`ghost`,size:`sm`,title:`Download`,onClick:()=>c(l,e.name||e.content?.name),children:t(qt,{className:`size-4`})})]}),t(C,{className:`my-2`}),t(`div`,{className:`pt-2`,children:t(Wx,{object:e,loadText:!0},e.id)})]}):null}const pS=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Revision`,field:`.`,type:`revision`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function mS({collection:e}){let n=Ye(),{client:r}=Z(),{registry:i}=Gg(),a=async t=>{t.length>0&&await r.store.collections.addMembers(e.id,t).catch(e=>{n({title:`Failed to add objects to collection`,description:e.message,status:`error`})})},o=hS(e,i);return t(`div`,{className:`flex flex-col h-full`,children:e.dynamic?t(uS,{layout:o}):t(lS,{onUploadDone:a,layout:o})})}function hS(e,t){let n=e.table_layout;return n&&n.length>0||(e.type&&t&&(n=t?.getTypeLayout(Gr(e.type))),n&&n.length>0)?n:pS}function gS({className:e,defaultValue:r,onChange:i,isClearable:a,multiple:o}){let{t:s}=X(),{registry:c}=Gg(),[l,u]=Y(!1),d=e=>e===null?s(`store.none`):n(`div`,{children:[t(`div`,{className:`text-sm`,children:e.name}),t(`div`,{className:`text-xs text-muted truncate`,children:e.description})]}),[f,p]=Y(),[m,h]=Y([]);return K(()=>{if(!l&&(u(!0),c&&r)){if(o&&Array.isArray(r)){let e=c.types.filter(e=>r.includes(e.id));h(e)}let e=c.types.find(e=>e.id===r);e&&p(e)}},[l,c,r,o]),o?t(`div`,{className:`flex flex-col gap-4 content-between`,children:t(ye,{options:c?.types||[],value:m,onChange:e=>{h(e),i(e)},placeholder:s(`store.chooseContentTypes`),optionLabel:d,className:e||`text-sm bg-background`,filterBy:`name`,isClearable:a||!1,multiple:!0})}):t(`div`,{className:`flex flex-col gap-4 content-between`,children:t(ye,{options:c?.types||[],value:f,onChange:e=>{p(e||void 0),i(e)},placeholder:s(`store.chooseContentType`),optionLabel:d,className:e||`text-sm bg-background`,filterBy:`name`,isClearable:a||!1})})}function _S({onClose:r,redirect:i=!0,onAddToCollection:a}){let s=Di(),c=Ye(),{t:l}=X(),[u,d]=Y(!1),{client:f}=Z(),[p,m]=Y({dynamic:!1,name:``,description:``});function h(e,t){m({...p,[e]:t})}return n(e,{children:[t(ae,{children:n(`form`,{onSubmit:e=>e.preventDefault(),children:[t(L,{label:l(`type.name`),required:!0,children:t(ee,{type:`text`,value:p.name||``,onChange:e=>h(`name`,e)})}),t(L,{label:l(`type.description`),className:`mt-2`,children:t(Re,{value:p.description||``,onChange:e=>h(`description`,e.target.value)})}),t(L,{label:l(`store.dynamicCollection`),className:`mt-2`,direction:`row`,description:l(`store.dynamicCollectionDescription`),children:t(Oe,{value:p.dynamic||!1,onChange:e=>h(`dynamic`,e)})}),!p.dynamic&&t(L,{label:l(`store.allowedContentTypes`),className:`mt-4`,description:l(`store.allowedContentTypesOptionalDescription`),children:t(gS,{defaultValue:p.allowed_types||null,onChange:e=>{Array.isArray(e)?h(`allowed_types`,e.map(e=>e.id)):h(`allowed_types`,e?[e.id]:[])},isClearable:!0,multiple:!0})}),t(L,{label:l(`store.contentType`),className:`mt-2`,description:l(`store.typeDescription`),children:t(gS,{defaultValue:p.type||null,onChange:e=>{Array.isArray(e)?h(`type`,e.length>0?e[0].id:null):h(`type`,e?.id||null)},isClearable:!0})})]})}),t(oe,{children:t(o,{isDisabled:u,onClick:()=>{if(!p?.name?.trim()){c({title:l(`type.nameRequired`),description:l(`store.pleaseProvideName`),status:`error`,duration:5e3});return}p.name=p.name.trim(),p.description&&=p.description.trim(),p.dynamic??=!1,d(!0),f.store.collections.create(p).then(e=>{r(),c({title:l(`store.collectionCreated`),description:`Collection "${e.name}" created successfully`,status:`success`,duration:3e3}),i&&s(`/collections/${e.id}`),a&&a(e.id)}).catch(e=>{c({title:l(`store.failedToCreateCollection`),description:e.message,status:`error`,duration:5e3})}).finally(()=>d(!1))},children:l(`store.createCollection`)})})]})}function vS({isOpen:e,onClose:r}){let{t:i}=X();return n(ie,{onClose:r,isOpen:e,children:[t(se,{children:i(`store.createACollection`)}),t(_S,{onClose:r})]})}ni.extend(Yi);function yS(){let{client:r}=Z(),i=Ye(),{t:a}=X(),[s,c]=Y(),[l,u]=Y(!0),[d,f]=Y(!1),{data:p,error:m,refetch:h}=Ue(()=>r.store.collections.search({}),[]);return K(()=>{(p||m)&&u(!1)},[p,m]),m?t(M,{title:a(`store.collectionFetchFailed`),children:H(m)}):n(e,{children:[p&&(p.length>0?n(Me,{className:`w-full`,children:[t(`thead`,{children:n(`tr`,{children:[t(`th`,{children:a(`type.name`)}),t(`th`,{children:a(`type.type`)}),t(`th`,{children:a(`store.created`)}),t(`th`,{})]})}),t(ke,{columns:4,isLoading:l,children:p.map(e=>n(je,{children:[t(`td`,{children:n(`div`,{className:`flex items-center gap-2`,children:[t(bS,{isDynamic:e.dynamic}),t(Ei,{href:`/collections/${e.id}`,children:e.name})]})}),t(`td`,{children:e.type?.name||`-`}),t(`td`,{children:ni(e.created_at).fromNow()}),t(`td`,{className:`text-end`,children:t(o,{variant:`destructive`,size:`sm`,onClick:()=>c(e.id),children:t(dr,{className:`size-4`})})})]},e.id))})]}):t(j,{title:a(`store.noCollections`),buttonLabel:a(`store.newCollections`),onClick:()=>f(!0),children:a(`store.getStartedCollections`)})),t(vS,{isOpen:d,onClose:()=>f(!1)}),t(b,{isOpen:!!s,title:a(`store.deleteCollection`),content:a(`store.areYouSureDeleteCollection`),onConfirm:async()=>{if(s)try{await r.store.collections.delete(s),i({title:a(`store.collectionDeleted`),status:`success`,duration:3e3}),h()}catch(e){console.error(`Failed to delete collection:`,e),i({title:a(`store.failedToDeleteCollection`),description:H(e),status:`error`,duration:5e3})}finally{c(void 0)}},onCancel:()=>c(void 0)})]})}function bS({isDynamic:e}){let{t:n}=X();return t(ze,{description:n(e?`store.dynamicCollection`:`store.staticCollection`),className:`me-2`,children:t(e?er:ln,{className:`size-5`})})}ni.extend(Yi);const xS=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function SS({objects:e,isLoading:r,onFilter:i,selectedIds:a,onToggleOne:s,allSelected:c,onToggleAll:l}){let{t:u}=X(),d=Di(),f=!!s;return n(Me,{className:`w-full`,children:[t(Ae,{children:n(`tr`,{children:[f&&t(`th`,{className:`w-[5%]`,children:t(`input`,{type:`checkbox`,checked:!!c,"aria-label":u(`store.actions.selectAllTypes`),onChange:e=>l?.(e.target.checked)})}),t(`th`,{children:u(`store.name`)}),t(`th`,{children:u(`store.strictMode`)}),t(`th`,{children:u(`store.semanticChunking`)}),t(`th`,{children:u(`store.updatedAt`)})]})}),t(ke,{isLoading:r&&(!e||e.length===0),columns:f?5:4,children:e?.map(e=>n(`tr`,{onClick:()=>d(`/types/${e.id}`),className:`group cursor-pointer hover:bg-muted`,children:[f&&t(`td`,{className:`w-[5%]`,children:t(`input`,{type:`checkbox`,className:Ze(`checkbox group-hover:inline-block`,a?.includes(e.id)?`inline-block`:`hidden`),checked:a?.includes(e.id)??!1,"aria-label":u(`store.actions.selectType`,{name:e.name}),onClick:e=>e.stopPropagation(),onChange:t=>s?.(e.id,t.target.checked)})}),t(`td`,{className:`group/field`,children:n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:e.name}),t(x,{content:e.id,className:xS}),i&&t(o,{variant:`ghost`,size:`sm`,title:`Filter by ${e.name}`,className:xS,onClick:t=>{t.stopPropagation(),i(`name`,e.name)},children:t(cn,{className:`size-3`})})]})}),t(`td`,{children:e.strict_mode?`Yes`:`No`}),t(`td`,{children:e.is_chunkable?`Yes`:`No`}),t(`td`,{children:t(ze,{description:ni(e.updated_at).format(`YYYY-MM-DD HH:mm:ss`),children:ni(e.updated_at).fromNow()})})]},e.id))})]})}function CS({title:e,isOpen:r,onClose:i,okLabel:a,initialPayload:s,isLoading:c}){let{t:l}=X(),u=Ye(),[d,f]=Y(s?.name),[p,m]=Y(s?.description),h=s?.strict_mode??!1,g=()=>{if(!d){u({status:`error`,title:l(`type.nameRequired`),duration:5e3});return}i({name:d,description:p,strict_mode:h}).then(()=>i())};return n(ie,{isOpen:r,onClose:()=>i(),children:[t(se,{children:e}),t(ae,{className:`pt-0`,children:n(`div`,{className:`h-full flex flex-col gap-4 content-between`,children:[n(`div`,{children:[t(`div`,{className:`block text-sm font-medium text-muted`,children:l(`type.name`)}),t(ee,{value:d,onChange:f})]}),n(`div`,{children:[t(`div`,{className:`block text-sm font-medium text-muted`,children:l(`type.description`)}),t(Re,{value:p,onChange:e=>m(e.target.value),minLines:5})]})]})}),t(oe,{children:n(`div`,{className:`flex justify-end gap-4`,children:[t(o,{variant:`secondary`,onClick:()=>i(),children:l(`modal.cancel`)}),t(o,{variant:`primary`,onClick:()=>g(),isLoading:c,children:a})]})})]})}var wS=class{client;limit;result=new Se({objects:[],isLoading:!1});query={};constructor(e,t=100){this.client=e,this.limit=t}get objects(){return this.result.value.objects}get error(){return this.result.value.error}get isRunning(){return this.result.value.isLoading}getFilterValue(e){return this.query[e]}setFilterValue(e,t){this.query[e]=t,this.search()}reset(e=!1){this.result.value={objects:[],isLoading:e}}_updateRunningState(e){let t=this.result.value;this.result.value={objects:t.objects,isLoading:e,error:t.error}}async _search(e=!1){if(this.isRunning)return Promise.resolve(!1);this.result.value={isLoading:!0,objects:e?this.objects:[]};let t=this.limit,n=this.objects.length;return this.client.types.list({limit:t,offset:n,query:this.query}).then(async e=>(this.result.value={isLoading:!1,objects:this.objects.concat(e)},!0)).catch(e=>{throw this.result.value={error:e,isLoading:!1,objects:this.objects},e})}search(){return this.isRunning?Promise.resolve(!1):this._search(!1)}loadMore(){return this.isRunning?Promise.resolve(!1):this._search(!0)}};const TS=nt(void 0);function ES(){return at(TS)}function DS(){let e=ES();return{...Xe(e.result),search:e}}function OS(){return ES().objects.length}var kS;(function(e){e.true=`Yes`,e.false=`No`})(kS||={});function AS({isDirty:r=!1}){let{store:i}=Z(),{reload:a}=Gg(),{t:s}=X(),c=Ye(),[l,u]=Y(!1),{search:d,isLoading:f,error:p,objects:m}=DS(),[h,g]=Y([]),[_,v]=Y(!1),[y,x]=Y(!1),S=h.length,C=!!m&&m.length>0&&m.every(e=>h.includes(e.id)),w=m?.filter(e=>h.includes(e.id))??[],T=(e,t)=>{g(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))},E=e=>{g(e&&m?m.map(e=>e.id):[])},D=async()=>{if(!y){x(!0);try{let e=await Promise.allSettled(h.map(e=>i.types.delete(e))),t=e.filter(e=>e.status===`rejected`).length,n=e.length-t;v(!1),g([]),a(),await d.search(),c(t===0?{status:`success`,title:s(`store.actions.typeDeleted`,{count:n}),duration:3e3}:{status:`error`,title:s(`store.actions.typeDeletePartial`,{succeeded:n,failed:t}),duration:5e3})}catch(e){c({status:`error`,title:s(`store.actions.failedToDeleteTypes`),description:e instanceof Error?e.message:void 0,duration:5e3})}finally{x(!1)}}},[O,k]=Y(``),A=He(O,500),N=J(null);Ke(N,()=>{l&&d.loadMore()},{deps:[l,d]}),K(()=>{d.search().then(()=>u(!0))},[d]),K(()=>{d.query.name=A,d.search().then(()=>u(!0))},[A,d]);let[P,F]=Y(void 0),I=e=>{F(e)};K(()=>{d.query.chunkable=P?P===`Yes`:void 0,d.search().then(()=>u(!0))},[P,d]),K(()=>{r&&l&&d.search().then(()=>u(!0))},[r,l,d]);let[L,R]=Y(!1);return p?t(M,{title:s(`store.failedToFetchTypes`),children:p.message}):n(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[n(`div`,{className:`flex flex-shrink-0 gap-4 items-center`,children:[t(ee,{placeholder:s(`store.filterByName`),value:O,onChange:k}),t(ye,{className:`w-60`,isClearable:!0,options:Object.values(kS),value:P,onChange:I,placeholder:s(`store.isChunkable`)}),S>0&&n(`div`,{className:`flex items-center gap-2 ms-auto`,children:[t(`span`,{className:`text-sm font-medium whitespace-nowrap`,children:s(`store.actions.selectedCount`,{n:S})}),t(ze,{description:s(`store.actions.clearSelection`),asChild:!0,children:t(o,{variant:`ghost`,"aria-label":s(`store.actions.clearSelection`),onClick:()=>g([]),children:t(yr,{className:`size-4`})})}),t(o,{variant:`destructive`,isDisabled:y,onClick:()=>v(!0),children:s(y?`store.actions.deleting`:`store.actions.deleteSelected`)})]})]}),t(`div`,{className:`flex flex-col w-full flex-1 min-h-0 border rounded-md my-2`,children:n(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[!f&&m?.length===0?t(j,{title:s(`store.noType`),buttonLabel:s(`store.createType`),onClick:()=>{R(!0)},children:s(`store.getStartedTypes`)}):n(e,{children:[t(SS,{objects:m,isLoading:f,onFilter:(e,t)=>{e===`name`&&k(t)},selectedIds:h,onToggleOne:T,allSelected:C,onToggleAll:E}),t(`div`,{ref:N,className:`h-4 w-full`})]}),t(CS,{okLabel:`Create`,title:s(`store.createType`),isOpen:L,onClose:async e=>e?i.types.create(e).then(async()=>{c({status:`success`,title:s(`store.typeCreated`),duration:2e3}),a(),d.search().then(()=>u(!0))}).catch(e=>{c({status:`error`,title:s(`store.errorCreatingType`),description:e.message,duration:5e3})}):(R(!1),Promise.resolve())}),t(b,{isOpen:_,title:s(`store.actions.deleteType`,{count:S}),content:n(`div`,{children:[t(`p`,{children:s(`store.actions.deleteTypeConfirm`,{count:S})}),w.length>0&&n(e,{children:[t(`div`,{className:`mt-2`,children:s(`store.actions.affectedItems`)}),t(`ul`,{className:`mt-1 max-h-40 overflow-y-auto rounded-md border p-2 text-sm`,children:w.map(e=>t(`li`,{className:`truncate py-0.5`,children:e.name||e.id},e.id))})]})]}),onConfirm:D,onCancel:()=>v(!1),confirmationValue:`delete`,confirmationLabel:s(`store.actions.typeToConfirmDelete`),confirmationPlaceholder:`delete`})]})})]})}function jS(e,t,n){if(t.length===0)return e;let r=structuredClone(e),i=[r],a=r;for(let e of t.slice(0,-1)){let t=a[e],n=IS(t)?t:{};a[e]=n,a=n,i.push(a)}let o=t[t.length-1];return n===void 0||n===``?(delete a[o],FS(i,t)):a[o]=n,r}function MS(e,t,n,r){let i=e?.map(e=>[...e])??[],a=i[t]??[1,1];return a[n]=r,i[t]=a,i}function NS(e,t){let n={...e,environment:t};return delete n.model,delete n.model_options,LS(n)?n:void 0}function PS(e,t){let n={...e,model:t};return t!==e?.model&&delete n.model_options,LS(n)?n:void 0}function FS(e,t){for(let n=e.length-1;n>0;--n){let r=e[n];if(Object.keys(r).length>0)break;delete e[n-1][t[n-1]]}}function IS(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function LS(e){return Object.values(e).some(e=>e!==void 0)}function RS({policy:e,section:r,onChange:i,readonly:a=!1}){let{t:o}=X(),s=(t,n)=>i(jS(e,t,n));if(r===`overview`)return n(zS,{children:[n(BS,{title:o(`intakePolicy.section.classification`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(WS,{label:o(`intakePolicy.field.mode`),description:o(`intakePolicy.help.mode`),value:e.mode,options:YS(o,[`programmatic`,`agentic`]),onChange:e=>s([`mode`],e),readonly:a}),t(WS,{label:o(`intakePolicy.field.defaultView`),value:e.default_view,options:YS(o,[`auto`,`text`,`pdf`,`image`,`properties`]),onChange:e=>s([`default_view`],e),readonly:a})]}),t(HS,{label:o(`intakePolicy.field.identificationGuidance`),description:o(`intakePolicy.help.identificationGuidance`),value:e.identification?.guidance,onChange:e=>s([`identification`,`guidance`],e),readonly:a}),t(HS,{label:o(`intakePolicy.field.distinguishFrom`),value:e.identification?.distinguish_from,onChange:e=>s([`identification`,`distinguish_from`],e),readonly:a}),t(L,{label:o(`intakePolicy.field.examples`),description:o(`intakePolicy.help.examples`),children:t(Le,{options:e.identification?.examples??[],value:e.identification?.examples??[],onChange:e=>s([`identification`,`examples`],e.length?e:void 0),onOptionsChange:e=>s([`identification`,`examples`],e.length?e:void 0),creatable:!0,disabled:a,placeholder:o(`intakePolicy.placeholder.objectId`)})})]}),n(BS,{title:o(`intakePolicy.section.locate`),last:!0,children:[t(HS,{label:o(`intakePolicy.field.locateInstructions`),description:o(`intakePolicy.help.locateInstructions`),value:e.locate?.instructions,onChange:t=>s([`locate`],t?{...e.locate,instructions:t}:void 0),readonly:a}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(WS,{label:o(`intakePolicy.field.contactSheetDetail`),value:e.locate?.detail,options:[{value:8,label:o(`intakePolicy.option.pagesPerSheet`,{count:8})},{value:16,label:o(`intakePolicy.option.pagesPerSheet`,{count:16})}],onChange:e=>s([`locate`,`detail`],e),readonly:a||!e.locate}),t(US,{label:o(`intakePolicy.field.locateMinPages`),value:e.locate?.min_pages,min:0,onChange:e=>s([`locate`,`min_pages`],e),readonly:a||!e.locate})]})]})]});if(r===`conversion`)return n(zS,{children:[n(BS,{title:o(`intakePolicy.section.conversion`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(GS,{label:o(`intakePolicy.field.enabled`),value:e.text_conversion?.enabled,onChange:e=>s([`text_conversion`,`enabled`],e),readonly:a}),t(WS,{label:o(`intakePolicy.field.method`),value:e.text_conversion?.method,options:YS(o,[`auto`,`basic`,`llm`,`custom`]),onChange:e=>s([`text_conversion`,`method`],e),readonly:a}),t(WS,{label:o(`intakePolicy.field.outputFormat`),value:e.text_conversion?.output_format,options:YS(o,[`markdown`,`text`]),onChange:e=>s([`text_conversion`,`output_format`],e),readonly:a}),t(WS,{label:o(`intakePolicy.field.pageScope`),value:e.text_conversion?.scope,options:YS(o,[`all`,`located`]),onChange:e=>s([`text_conversion`,`scope`],e),readonly:a})]}),t(HS,{label:o(`intakePolicy.field.instructions`),value:e.text_conversion?.instructions,onChange:e=>s([`text_conversion`,`instructions`],e),readonly:a})]}),e.text_conversion?.method===`custom`&&t(BS,{title:o(`intakePolicy.section.customConversion`),children:n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(VS,{label:o(`intakePolicy.field.interaction`),value:e.text_conversion.custom?.interaction,onChange:e=>s([`text_conversion`,`custom`,`interaction`],e),readonly:a}),t(VS,{label:o(`intakePolicy.field.agent`),value:e.text_conversion.custom?.agent,onChange:e=>s([`text_conversion`,`custom`,`agent`],e),readonly:a})]})}),t(BS,{title:o(`intakePolicy.section.pageRanges`),last:!0,children:t(qS,{value:e.text_conversion?.page_ranges,onChange:e=>s([`text_conversion`,`page_ranges`],e),readonly:a})})]});if(r===`extraction`)return n(zS,{children:[n(BS,{title:o(`intakePolicy.section.extraction`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(GS,{label:o(`intakePolicy.field.enabled`),value:e.extraction?.enabled,onChange:e=>s([`extraction`,`enabled`],e),readonly:a}),t(WS,{label:o(`intakePolicy.field.source`),value:e.extraction?.source,options:YS(o,[`auto`,`text`,`vision`,`mixed`]),onChange:e=>s([`extraction`,`source`],e),readonly:a}),t(WS,{label:o(`intakePolicy.field.pageScope`),value:e.extraction?.scope,options:YS(o,[`all`,`located`]),onChange:e=>s([`extraction`,`scope`],e),readonly:a}),t(US,{label:o(`intakePolicy.field.maxPages`),value:e.extraction?.max_pages,min:1,onChange:e=>s([`extraction`,`max_pages`],e),readonly:a})]}),t(VS,{label:o(`intakePolicy.field.interaction`),value:e.extraction?.interaction,onChange:e=>s([`extraction`,`interaction`],e),readonly:a}),t(HS,{label:o(`intakePolicy.field.instructions`),value:e.extraction?.instructions,onChange:e=>s([`extraction`,`instructions`],e),readonly:a}),t(qS,{value:e.extraction?.page_ranges,onChange:e=>s([`extraction`,`page_ranges`],e),readonly:a})]}),t(BS,{title:o(`intakePolicy.section.visionBudget`),children:n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[t(WS,{label:o(`intakePolicy.field.defaultDetail`),value:e.extraction?.vision?.default_detail,options:YS(o,[`low`,`standard`,`high`]),onChange:e=>s([`extraction`,`vision`,`default_detail`],e),readonly:a}),t(KS,{value:e.extraction?.vision?.allowed_details,onChange:e=>s([`extraction`,`vision`,`allowed_details`],e),readonly:a}),t(US,{label:o(`intakePolicy.field.maxImageTokens`),value:e.extraction?.vision?.max_image_tokens,min:1,onChange:e=>s([`extraction`,`vision`,`max_image_tokens`],e),readonly:a}),t(US,{label:o(`intakePolicy.field.maxPayloadMb`),value:e.extraction?.vision?.max_payload_mb,min:1,onChange:e=>s([`extraction`,`vision`,`max_payload_mb`],e),readonly:a}),t(US,{label:o(`intakePolicy.field.maxPagesPerCall`),value:e.extraction?.vision?.max_pages_per_call,min:1,onChange:e=>s([`extraction`,`vision`,`max_pages_per_call`],e),readonly:a})]})}),n(BS,{title:o(`intakePolicy.section.verification`),last:!0,children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[t(GS,{label:o(`intakePolicy.field.enabled`),value:e.extraction?.verification?.enabled,onChange:e=>s([`extraction`,`verification`,`enabled`],e),readonly:a}),t(VS,{label:o(`intakePolicy.field.model`),value:e.extraction?.verification?.model,onChange:e=>s([`extraction`,`verification`,`model`],e),readonly:a}),t(VS,{label:o(`intakePolicy.field.environment`),value:e.extraction?.verification?.environment,onChange:e=>s([`extraction`,`verification`,`environment`],e),readonly:a}),t(US,{label:o(`intakePolicy.field.threshold`),value:e.extraction?.verification?.threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`verification`,`threshold`],e),readonly:a}),t(US,{label:o(`intakePolicy.field.maxRetries`),value:e.extraction?.verification?.max_retries,min:0,onChange:e=>s([`extraction`,`verification`,`max_retries`],e),readonly:a}),t(WS,{label:o(`intakePolicy.field.onFailure`),value:e.extraction?.verification?.on_fail,options:YS(o,[`flag`,`block`]),onChange:e=>s([`extraction`,`verification`,`on_fail`],e),readonly:a})]}),t(HS,{label:o(`intakePolicy.field.materiality`),value:e.extraction?.verification?.materiality,onChange:e=>s([`extraction`,`verification`,`materiality`],e),readonly:a})]})]});if(r===`grounding`){let r=e.extraction?.grounding,i=r?.review;return n(zS,{children:[n(BS,{title:o(`intakePolicy.section.grounding`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(GS,{label:o(`intakePolicy.field.enabled`),value:r?.enabled,onChange:e=>s([`extraction`,`grounding`,`enabled`],e),readonly:a}),t(US,{label:o(`intakePolicy.field.maxPages`),value:r?.max_pages,min:1,onChange:e=>s([`extraction`,`grounding`,`max_pages`],e),readonly:a}),t(US,{label:o(`intakePolicy.field.windowPages`),value:r?.window_pages,min:1,onChange:e=>s([`extraction`,`grounding`,`window_pages`],e),readonly:a}),t(VS,{label:o(`intakePolicy.field.interaction`),value:r?.interaction,onChange:e=>s([`extraction`,`grounding`,`interaction`],e),readonly:a})]}),n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[t(GS,{label:o(`intakePolicy.field.useVision`),value:r?.use_vision,onChange:e=>s([`extraction`,`grounding`,`use_vision`],e),readonly:a}),t(GS,{label:o(`intakePolicy.field.forceOcr`),value:r?.force_ocr,onChange:e=>s([`extraction`,`grounding`,`force_ocr`],e),readonly:a}),t(GS,{label:o(`intakePolicy.field.refreshOcr`),value:r?.refresh_ocr,onChange:e=>s([`extraction`,`grounding`,`refresh_ocr`],e),readonly:a}),t(GS,{label:o(`intakePolicy.field.omitBlockBoxes`),value:r?.omit_block_boxes,onChange:e=>s([`extraction`,`grounding`,`omit_block_boxes`],e),readonly:a}),t(GS,{label:o(`intakePolicy.field.updateProperties`),value:r?.update_properties,onChange:e=>s([`extraction`,`grounding`,`update_properties`],e),readonly:a})]})]}),n(BS,{title:o(`intakePolicy.section.models`),children:[t(JS,{title:o(`intakePolicy.field.primaryModel`),config:r?.config,onChange:e=>s([`extraction`,`grounding`,`config`],e),readonly:a}),t(JS,{title:o(`intakePolicy.field.hardModel`),config:r?.hard_config,onChange:e=>s([`extraction`,`grounding`,`hard_config`],e),readonly:a}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(US,{label:o(`intakePolicy.field.hardnessThreshold`),value:r?.hardness_threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`hardness_threshold`],e),readonly:a}),t(US,{label:o(`intakePolicy.field.minCitationDensity`),value:r?.min_citation_density,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`min_citation_density`],e),readonly:a})]})]}),n(BS,{title:o(`intakePolicy.section.review`),last:!0,children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(GS,{label:o(`intakePolicy.field.enabled`),value:i?.enabled,onChange:e=>s([`extraction`,`grounding`,`review`,`enabled`],e),readonly:a}),t(GS,{label:o(`intakePolicy.field.forceReview`),value:i?.force,onChange:e=>s([`extraction`,`grounding`,`review`,`force`],e),readonly:a}),t(US,{label:o(`intakePolicy.field.reviewThreshold`),value:i?.threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`review`,`threshold`],e),readonly:a}),t(US,{label:o(`intakePolicy.field.coverageThreshold`),value:i?.coverage_threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`review`,`coverage_threshold`],e),readonly:a})]}),t(JS,{title:o(`intakePolicy.field.reviewModel`),config:i?.config,onChange:e=>s([`extraction`,`grounding`,`review`,`config`],e),readonly:a})]})]})}return n(zS,{children:[t(BS,{title:o(`intakePolicy.section.rendering`),children:t(HS,{label:o(`intakePolicy.field.renderingTemplate`),description:o(`intakePolicy.help.renderingTemplate`),value:e.rendering_template,onChange:e=>s([`rendering_template`],e),readonly:a,monospace:!0,minLines:8})}),t(BS,{title:o(`intakePolicy.section.embeddings`),last:!0,children:n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(GS,{label:o(`intakePolicy.field.textEmbedding`),value:e.embeddings?.text,onChange:e=>s([`embeddings`,`text`],e),readonly:a}),t(GS,{label:o(`intakePolicy.field.imageEmbedding`),value:e.embeddings?.image,onChange:e=>s([`embeddings`,`image`],e),readonly:a}),t(GS,{label:o(`intakePolicy.field.propertiesEmbedding`),value:e.embeddings?.properties,onChange:e=>s([`embeddings`,`properties`],e),readonly:a}),t(GS,{label:o(`intakePolicy.field.generateToc`),value:e.generate_toc,onChange:e=>s([`generate_toc`],e),readonly:a})]})})]})}function zS({children:e}){return t(`div`,{className:`mx-auto w-full max-w-6xl px-1 py-4`,children:e})}function BS({title:e,children:r,last:i=!1}){return n(`section`,{className:i?`pb-3`:`mb-6 border-b pb-6`,children:[t(`h3`,{className:`mb-4 text-sm font-semibold`,children:e}),t(`div`,{className:`space-y-4`,children:r})]})}function VS({label:e,value:n,onChange:r,readonly:i,description:a}){return t(L,{label:e,description:a,children:t(ee,{value:n??``,onChange:e=>r(e||void 0),disabled:i})})}function HS({label:e,value:n,onChange:r,readonly:i,description:a,minLines:o=3,monospace:s=!1}){return t(L,{label:e,description:a,children:t(Re,{value:n??``,onChange:e=>r(e.target.value||void 0),disabled:i,minLines:o,maxLines:14,className:s?`font-mono`:void 0})})}function US({label:e,value:n,onChange:r,readonly:i,min:a,max:o,step:s}){return t(L,{label:e,children:t(ce,{value:n,onChange:e=>r(e===void 0||Number.isFinite(e)?e:void 0),disabled:i,min:a,max:o,step:s??1,noScroll:!0})})}function WS({label:e,description:n,value:r,options:i,onChange:a,readonly:o}){let{t:s}=X(),c=[{value:`__inherit__`,label:s(`intakePolicy.option.inherit`)},...i];return t(L,{label:e,description:n,children:t(ye,{options:c,value:c.find(e=>e.value===r)??c[0],by:`value`,optionLabel:e=>e.label,onChange:e=>a(e.value===`__inherit__`?void 0:e.value),disabled:o})})}function GS({label:e,value:n,onChange:r,readonly:i}){let{t:a}=X(),o=[{value:`inherit`,label:a(`intakePolicy.option.inherit`)},{value:`enabled`,label:a(`intakePolicy.option.enabled`)},{value:`disabled`,label:a(`intakePolicy.option.disabled`)}],s=n===void 0?`inherit`:n?`enabled`:`disabled`;return t(L,{label:e,children:t(ye,{options:[...o],value:o.find(e=>e.value===s),by:`value`,optionLabel:e=>e.label,onChange:e=>r(e.value===`inherit`?void 0:e.value===`enabled`),disabled:i})})}function KS({value:e,onChange:n,readonly:r}){let{t:i}=X(),a=YS(i,[`low`,`standard`,`high`]);return t(L,{label:i(`intakePolicy.field.allowedDetails`),children:t(ye,{multiple:!0,options:a,value:a.filter(t=>e?.includes(t.value)),by:`value`,optionLabel:e=>e.label,onChange:e=>n(e.length?e.map(e=>e.value):void 0),disabled:r})})}function qS({value:e,onChange:r,readonly:i}){let{t:a}=X(),s=t=>{let n=e?.filter((e,n)=>n!==t);r(n?.length?n:void 0)};return t(L,{label:a(`intakePolicy.field.pageRanges`),description:a(`intakePolicy.help.pageRanges`),children:n(`div`,{className:`space-y-2`,children:[e?.map((c,l)=>n(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.25rem] gap-2`,children:[t(ce,{"aria-label":a(`intakePolicy.field.rangeStart`),value:c[0],onChange:t=>{t!==void 0&&Number.isFinite(t)&&r(MS(e,l,0,t))},disabled:i,step:1,noScroll:!0}),t(ce,{"aria-label":a(`intakePolicy.field.rangeEnd`),value:c[1],onChange:t=>{t!==void 0&&Number.isFinite(t)&&r(MS(e,l,1,t))},disabled:i,step:1,noScroll:!0}),t(ze,{description:a(`intakePolicy.action.removeRange`),children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`intakePolicy.action.removeRange`),onClick:()=>s(l),disabled:i,children:t(dr,{className:`size-4`})})})]},`${l}`)),n(o,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r([...e??[],[1,1]]),disabled:i,children:[t(Un,{className:`size-4`}),a(`intakePolicy.action.addRange`)]})]})})}function JS({title:e,config:r,onChange:i,readonly:a}){let{t:o}=X();return n(`div`,{children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:e}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(L,{label:o(`intakePolicy.field.environment`),children:t(db,{selectedEnvId:r?.environment,onChange:e=>i(NS(r,e?.id)),isClearable:!0,disabled:a})}),t(L,{label:o(`intakePolicy.field.model`),children:t(mb,{envId:r?.environment,selectedModelId:r?.model,onChange:e=>i(PS(r,e?.id)),isClearable:!0,disabled:a||!r?.environment})})]})]})}function YS(e,t){return t.map(t=>({value:t,label:e(`intakePolicy.option.${t}`)}))}const XS=[{key:`minimal`,value:{identification:{guidance:`Documents that match this content type.`,distinguish_from:`Do not select this type for unrelated documents.`}}},{key:`extraction_only`,value:{text_conversion:{enabled:!1},extraction:{enabled:!0,source:`vision`,instructions:`Extract required fields only. Ignore cover pages, appendices, legal boilerplate, and marketing content.`},rendering_template:`# {{properties.title}}
|
|
450
450
|
|
|
451
|
-
]`}function Xx({collection:e}){let{client:n}=Z(),{t:r}=X(),[i,a]=Y(void 0),[s,c]=Y(e.shared_properties||[]),l=He();K(()=>{e.type?.id&&n.store.types.retrieve(e.type.id).then(a)},[n.store.types.retrieve,e.type?.id]);let u=i?Object.keys(i.object_schema?.properties||{}):[];return t(ae,{title:r(`store.sharedProperties`),description:r(`store.sharedPropertiesDescription`),action:t(o,{size:`lg`,isLoading:!1,onClick:()=>{n.store.collections.update(e.id,{shared_properties:s}).then(()=>{l({title:r(`store.updatedSharedProperties`),status:`success`})}).catch(e=>{l({title:r(`store.failedToUpdateSharedProperties`),description:e.message,status:`error`})})},children:r(`modal.save`)}),children:t(`div`,{className:``,children:t(Ae,{value:s,onChange:e=>{c(e)},options:u,placeholder:r(`store.selectPropertiesToShare`)})})})}function Zx({collection:e}){let{client:n}=Z(),{t:r}=X(),[i,a]=Y(e.skip_head_sync??!1),[o,s]=Y(!1),c=He();return t(ae,{title:r(`store.syncMemberHeads`),description:r(`store.syncMemberHeadsDescription`),children:t(Se,{disabled:o,value:!i,onChange:t=>{let i=!t;s(!0),n.store.collections.update(e.id,{skip_head_sync:i}).then(()=>{c({title:r(`store.updatedSkipHeadSync`),status:`success`}),a(i)}).catch(e=>{c({title:r(`store.failedToUpdateSkipHeadSync`),description:e.message,status:`error`})}).finally(()=>{s(!1)})},children:r(`store.enableSyncMemberHeads`)})})}function Qx(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $x({refetch:r,collection:a}){let{t:s}=X(),c=a.type?Dr(a.type):void 0,l=J(void 0),u=He(),{theme:d}=Ve(),{client:f}=Z(),p=Qe(Av),[m,h]=Y(!1),[g,_]=Y({name:a.name,description:a.description||``,query:a.query?JSON.stringify(a.query,null,2):``,tags:a.tags||[],type:a.type?Dr(a.type):``,allowed_types:a.allowed_types||[],sensitivity:a.sensitivity,compartments:a.compartments||[]}),[v,y]=Y(``),b=q(()=>Yx(a.table_layout),[a.table_layout]),x=()=>{let e;try{let t=g.query?JSON.parse(g.query):void 0;if(t!==void 0&&!Qx(t))throw Error(s(`store.invalidQueryJson`));e=t}catch(e){u({title:s(`store.invalidQueryJson`),description:Ne(e),status:`error`,duration:5e3});return}let t={name:g.name,description:g.description,query:e,tags:g.tags,type:g.type,allowed_types:g.allowed_types,sensitivity:g.sensitivity,compartments:g.compartments},n;if(t.name||(n=s(`type.nameRequired`)),t.type||=null,n){u({title:s(`store.validationFailed`),description:n,status:`error`,duration:5e3});return}if(l.current){let e=l.current.getValue();if(e)try{t.table_layout=JSON.parse(e)}catch(e){u({title:s(`store.invalidTableLayout`),description:Ne(e),status:`error`,duration:5e3});return}else t.table_layout=null}h(!0),f.store.collections.update(a.id,t).then(()=>{r(),a.dynamic&&p&&(p.reset(),p.search()),u({title:s(`store.collectionUpdated`),description:s(`store.collectionUpdatedSuccess`),status:`success`,duration:3e3})}).catch(e=>{u({title:s(`store.failedToUpdateCollection`),description:Ne(e),status:`error`,duration:5e3})}).finally(()=>{h(!1)})},S=(e,t)=>{_({...g,[e]:t})};return n(`div`,{className:`flex flex-col gap-4 py-2`,children:[n(ae,{title:s(`store.configuration`),action:t(o,{size:`lg`,isDisabled:m,onClick:x,children:s(`modal.save`)}),children:[n(`div`,{className:`flex justify-between mb-2`,children:[n(`div`,{className:`w-1/2 gap-2 flex flex-col`,children:[t(`div`,{className:`text-sm font-medium mb-1`,children:s(`store.createdBy`)}),n(`div`,{className:`gap-2 flex items-center`,children:[t(Kg,{userRef:a.created_by,showTitle:!0}),n(`span`,{children:[`at `,Rr(a.created_at).format(`YYYY-MM-DD HH:mm:ss`)]})]})]}),n(`div`,{className:`w-1/2 gap-2 flex flex-col`,children:[t(`div`,{className:`text-sm font-medium mb-1`,children:s(`store.updatedBy`)}),n(`div`,{className:`gap-2 flex items-center`,children:[t(Kg,{userRef:a.updated_by,showTitle:!0}),n(`span`,{children:[`at `,Rr(a.updated_at).format(`YYYY-MM-DD HH:mm:ss`)]})]})]})]}),t(N,{label:s(`type.name`),required:!0,children:t(F,{value:g.name,onChange:e=>S(`name`,e)})}),t(N,{label:s(`type.description`),children:t(je,{value:g.description,onChange:e=>S(`description`,e.target.value)})}),!a.dynamic&&t(N,{label:s(`store.allowedContentTypes`),description:s(`store.allowedContentTypesSelectDescription`),children:t(Dx,{defaultValue:g.allowed_types||null,onChange:e=>{Array.isArray(e)?S(`allowed_types`,e.map(e=>e.id)):S(`allowed_types`,e?[e.id]:[])},isClearable:!0,multiple:!0})}),a.dynamic&&t(N,{label:s(`store.query`),description:s(`store.queryDescription`),children:t(je,{className:xe.INPUT,minLines:1,maxLines:12,value:g.query,onChange:e=>S(`query`,e.target.value)})}),t(N,{label:s(`store.tableLayout`),description:s(`store.tableLayoutDescription`),className:`h-[200px]`,children:t(bi,{className:`border-1 rounded-md border-border`,value:b,language:`json`,editorRef:l,theme:d===`dark`?`vs-dark`:`vs`})}),t(N,{label:s(`store.contentType`),description:s(`store.typeSelectDescription`),children:t(Dx,{defaultValue:g.type||null,onChange:e=>{Array.isArray(e)?S(`type`,e.length>0?e[0].id:null):S(`type`,e?.id||null)},isClearable:!0})}),t(N,{label:`Sensitivity`,description:`BLP sensitivity level — propagated to member documents (max across collections)`,children:t(V,{options:wr.map((e,t)=>({label:`${t} — ${e}`,value:t})),value:g.sensitivity===void 0?void 0:{label:`${g.sensitivity} — ${wr[g.sensitivity]??`Unknown`}`,value:g.sensitivity},onChange:e=>S(`sensitivity`,e.value),optionLabel:e=>e.label,by:`value`,placeholder:`Not set`})}),n(N,{label:`Compartments`,description:`Security compartments — propagated to member documents (union across collections)`,children:[n(`div`,{className:`flex gap-2`,children:[t(F,{value:v,onChange:y,placeholder:`Add a compartment`,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=v.trim();t&&!g.compartments.includes(t)&&(S(`compartments`,[...g.compartments,t]),y(``))}}}),t(o,{type:`button`,variant:`outline`,onClick:()=>{let e=v.trim();e&&!g.compartments.includes(e)&&(S(`compartments`,[...g.compartments,e]),y(``))},children:`Add`})]}),t(`div`,{className:`flex gap-1 flex-wrap mt-2`,children:g.compartments.map(e=>n(i,{variant:`secondary`,className:`cursor-pointer`,onClick:()=>S(`compartments`,g.compartments.filter(t=>t!==e)),children:[e,` ×`]},e))})]})]}),c&&t(eS,{typeId:c,collection:a}),!a.dynamic&&n(e,{children:[t(Zx,{collection:a}),t(Xx,{collection:a})]})]})}function eS({typeId:e,collection:n}){let{t:r}=X(),[i,a]=Y({}),s=He(),{client:c}=Z(),[l,u]=Y(!1),{data:d,error:f}=Le(()=>c.store.types.catalog.resolve(e),[e]),p=d?.object_schema||{},m=q(()=>new vi(p,n.properties||{}),[p,n.properties]);if(f)return t(O,{title:r(`store.failedToLoadType`),children:Ne(f)});if(!d)return null;let h=e=>{if(!e||!Object.keys(e).length)return;let t={properties:e||{}};u(!0),c.store.collections.update(n.id,t).then(()=>{s({title:r(`store.collectionPropertiesUpdated`),description:r(`store.collectionUpdatedSuccess`),status:`success`,duration:3e3})}).catch(e=>{s({title:r(`store.failedToUpdateCollectionProperties`),description:Ne(e),status:`error`,duration:5e3})}).finally(()=>{u(!1)})};return t(ae,{title:r(`store.properties`),action:t(o,{size:`lg`,isLoading:l,type:`submit`,onClick:()=>h(i),children:r(`modal.save`)}),children:t(hi,{object:m,onChange:e=>{e instanceof vi&&a(e.value)}})})}function tS({onChange:e,value:r,disabled:i=!1,placeholder:a,searchPlaceholder:s,filterOut:c,allowDynamic:l=!0,multiple:u=!1}){let{client:g}=Z(),{t:_}=X(),v=a??_(`store.selectACollection`),y=s??_(`store.searchCollections`),[b,x]=Y(``),[S,C]=Y(!1),[w,T]=Y(!1),E=Ie(b,300),D=G(async e=>{C(!0);let t=e.trim(),n=await g.store.collections.search({dynamic:l?void 0:!1,name:w&&t||void 0});return C(!1),!w&&n.length>=1e3&&T(!0),c&&c.length>0?n.filter(e=>!c.includes(e.id)):n},[g,l,c,w]),{data:k,error:A}=Le(()=>D(w?E:``),[w?E:``,D]),j=q(()=>k?u&&Array.isArray(r)?k.filter(e=>r.includes(e.id)):!u&&typeof r==`string`?k.find(e=>e.id===r):u?[]:void 0:u?[]:void 0,[k,r,u]),M=G(t=>{if(u){let n=Array.isArray(r)?r:[];if(n.includes(t.id)){let r=n.filter(e=>e!==t.id);e(r,k?.filter(e=>r.includes(e.id))||[])}else{let r=[...n,t.id];e(r,k?.filter(e=>r.includes(e.id))||[])}}else e(t.id,t)},[e,r,k,u]),N=G(()=>{e(void 0,void 0)},[e]),P=G(e=>{x(e)},[]),F=b.trim().length>0,I=q(()=>{if(!k)return[];if(w||!F)return k;let e=b.toLowerCase();return k.filter(t=>t.name.toLowerCase().includes(e))},[k,w,F,b]),L=u?Array.isArray(j)&&j.length>0:!!j;return A?t(O,{title:_(`store.collectionFetchFailed`),children:Ne(A)}):n(oe,{children:[t(ce,{asChild:!0,children:n(o,{variant:`outline`,role:`combobox`,"aria-haspopup":`listbox`,className:H(`w-full justify-between min-w-0`),disabled:i,children:[t(`span`,{className:`truncate flex-1 text-start min-w-0`,children:u&&Array.isArray(j)&&j.length>0?j.length===1?j[0].name:_(`store.collectionsSelected`,{count:j.length}):!u&&j&&!Array.isArray(j)?j.name:v}),L&&!i?t(o,{variant:`unstyled`,"aria-label":`Clear selection`,className:`ms-2 shrink-0 opacity-50 hover:opacity-100 hover:text-destructive cursor-pointer`,onClick:e=>{e.stopPropagation(),N()},children:t(nr,{className:`h-4 w-4`})}):t(Ot,{className:`ms-2 h-4 w-4 shrink-0 opacity-50`})]})}),t(se,{className:`mt-2 mb-2 w-[var(--radix-popover-trigger-width)] p-0`,align:`start`,children:n(d,{shouldFilter:!1,children:[n(`div`,{className:`flex justify-between items-center border-b px-3`,"cmdk-input-wrapper":``,children:[t(m,{placeholder:y,value:b,onValueChange:P,className:`flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`}),S&&t(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`})]}),t(f,{children:_(S?`store.searching`:F?`store.noCollectionsFound`:`store.noCollectionsAvailable`)}),n(p,{className:`max-h-[300px] overflow-auto`,children:[L&&!F&&t(h,{value:`__clear__`,onSelect:N,className:`text-destructive`,children:`Remove collection selection(s)`}),F&&t(h,{value:`__clear_search__`,onSelect:()=>x(``),className:`text-muted`,children:_(`store.clearSelection`)}),I.map(e=>{let i=u&&Array.isArray(r)?r.includes(e.id):r===e.id;return n(h,{value:e.id,onSelect:()=>M(e),className:`flex items-center justify-between`,children:[t(`span`,{className:`truncate`,children:e.name}),i&&t(pt,{className:`ms-2 h-4 w-4 shrink-0`})]},e.id)})]})]})})]})}function nS({isOpen:e,onClose:r}){return n(B,{onClose:()=>r(),isOpen:!!e,className:`min-w-[60vw]`,children:[t(re,{children:`Select Content`}),t(te,{className:`pt-0 overflow-y-auto max-h-[80vh] min-h-[80vh]`,children:e&&t(Qv,{onChange:r})})]})}const rS=/store:([a-f0-9]+)/;function iS({object:e}){let{client:r}=Z(),{off:i,on:a,isOn:s}=Re(),[c,l]=Y(e.value==null?``:String(e.value)),[u,d]=Y(void 0),f=t=>{let n=t.target.value;l(n),e.value=n},p=G(()=>{l(``),e.value=``,d(void 0)},[e]);return K(()=>{if(!c||u)return;let e=c.match(rS);e&&r.objects.retrieve(e[1]).then(e=>{d(e)}).catch(()=>{p()})},[c,r.objects.retrieve,p,u]),n(`div`,{children:[n(`div`,{className:`relative`,children:[t(`input`,{value:c,onChange:f,className:We(xe.INPUT,`pe-10 w-full`)}),u&&t(`div`,{className:`absolute inset-y-0 end-10 flex items-center justify-center `,children:t(o,{onClick:p,variant:`unstyled`,className:`hover:text-red-500 hover:bg-gray-100 dark:hover:bg-gray-600`,children:t(nr,{className:`size-5`})})}),t(`div`,{className:`absolute inset-y-0 end-0 flex items-center justify-center`,children:t(o,{onClick:a,variant:`unstyled`,className:`hover:bg-gray-100 dark:hover:bg-gray-600`,children:t(Ot,{className:`size-5`})})}),t(nS,{value:c,isOpen:s,onClose:t=>{if(t){let n=`store:${t.id}`;l(n),d(t||void 0),e.value=n}i()}})]}),u&&t(`div`,{className:`p-1 semibold text-sm text-gray-600 dark:text-slate-300`,children:typeof u.properties?.title==`string`?u.properties.title:u.name})]})}function aS({objectId:e,isOpen:r,onClose:i}){let a=li(),{client:s,store:c}=Z(),[l,u]=Y(null),[d,f]=Y(!1),[p,m]=Y(!1),[h,g]=Y(),[_,v]=Y(),[y,b]=Y(`preview`),{t:x}=X(),S=He(),C=G(async e=>{m(!0);try{let t=await c.objects.getObjectText(e);g(t.text)}catch(e){console.error(`Error loading text:`,e)}finally{m(!1)}},[c.objects]),w=G(async e=>{if(e.content?.source)try{(await s.objects.getRendition(e.id,{format:gr.jpeg,generate_if_missing:!1})).status===`found`&&console.log(`Found rendition`);let t=await s.files.getDownloadUrl(e.content.source);v(t.url)}catch(e){console.error(`Error loading image:`,e)}},[s.files,s.objects]);K(()=>{e&&r?(f(!0),c.objects.retrieve(e,`+embeddings`).then(e=>{u(e),e.text?g(e.text):C(e.id);let t=e.content;t?.source&&t.type?.startsWith(`image/`)&&w(e)}).catch(e=>{console.error(`Error loading object:`,e),S({title:x(`agent.error`),description:x(`store.failedToLoadDocument`),status:`error`,duration:3e3})}).finally(()=>{f(!1)})):(u(null),g(void 0),v(void 0))},[e,r,c.objects,C,w,x,S]);let T=()=>{l&&(a(`/legal/objects/${l.id}`),i())},E=h&&(h.startsWith(`#`)||h.includes(`
|
|
451
|
+
{{properties.summary}}`,embeddings:{text:!0,properties:!0},default_view:`pdf`}},{key:`grounded`,value:{extraction:{enabled:!0,grounding:{enabled:!0,use_vision:!0,config:{model:`publishers/google/models/gemini-3.5-flash`,model_options:{_option_id:`vertexai-gemini`,max_tokens:32e3,thinking_level:`LOW`,temperature:0}},hard_config:{model:`publishers/google/models/gemini-3.1-pro-preview`,model_options:{_option_id:`vertexai-gemini`,max_tokens:32e3,thinking_level:`LOW`,temperature:0}},hardness_threshold:.5,min_citation_density:.3,window_pages:3,review:{enabled:!0,config:{model:`publishers/google/models/gemini-3.5-flash`,model_options:{_option_id:`vertexai-gemini`,thinking_level:`MEDIUM`,max_tokens:32e3,temperature:0}},coverage_threshold:.2}}},default_view:`pdf`}},{key:`visual_first`,value:{identification:{guidance:`Presentation decks or visual reports with slides, charts, diagrams, tables, or callouts.`},text_conversion:{enabled:!0,method:`auto`},extraction:{enabled:!0,source:`auto`,instructions:`Use visual evidence when layout, charts, diagrams, or slide structure contain material information.`},default_view:`pdf`}},{key:`structured_spreadsheet`,value:{text_conversion:{enabled:!0,method:`auto`,instructions:`Preserve sheet names, headers, row labels, totals, and period columns.`},extraction:{enabled:!0,source:`text`,instructions:`Extract values from worksheet text. Do not infer values from charts.`},default_view:`properties`}},{key:`media_no_transcript`,value:{text_conversion:{enabled:!1},extraction:{enabled:!0,source:`auto`,instructions:`Analyze available metadata and source evidence without creating a transcript.`},default_view:`properties`}},{key:`full_reference`,value:{mode:`programmatic`,identification:{guidance:`Supplier invoices: billing documents with an invoice number, line items, amounts due, tax breakdown, and payment terms.`,distinguish_from:`Quotes and estimates are offers, not payment requests. Credit notes carry negative amounts. Receipts confirm a payment already made.`,examples:[]},text_conversion:{enabled:!0,method:`auto`,instructions:`Keep the commercial terms and totals. Drop boilerplate and legal footers.`,output_format:`markdown`,custom:{interaction:`my-project:ConvertSpecialDocument`,agent:`my-project:DocumentConversionAgent`}},extraction:{enabled:!0,source:`auto`,instructions:`Extract totals from the summary block, not from line items. Amounts include currency. Dates use ISO 8601.`,interaction:`sys:ExtractInformation`,verification:{enabled:!1,model:`publishers/anthropic/models/claude-sonnet`,environment:`default`,materiality:`Amounts, dates, identifiers, and party names are material. Typos in free text are not.`,threshold:.85,max_retries:1,on_fail:`flag`},grounding:{enabled:!0,interaction:`sys:ExtractInformationGrounded`,max_pages:20,force_ocr:!1,use_vision:!0,omit_block_boxes:!1,config:{model:`publishers/google/models/gemini-3.5-flash`},hard_config:{model:`publishers/google/models/gemini-3.1-pro-preview`},hardness_threshold:.5,window_pages:3,update_properties:!0,min_citation_density:.3,refresh_ocr:!1,review:{enabled:!0,config:{model:`publishers/google/models/gemini-3.5-flash`},coverage_threshold:.2}}},rendering_template:`# Invoice {{properties.invoice_number}}
|
|
452
|
+
|
|
453
|
+
- Vendor: {{properties.vendor_name}}
|
|
454
|
+
- Total: {{properties.currency}} {{properties.total_amount}}
|
|
455
|
+
- Due: {{properties.due_date}}`,embeddings:{text:!0,image:!1,properties:!0},generate_toc:!1,default_view:`auto`}}],ZS={};function QS({objectType:r,value:a,onSave:s,onIntakeUpdate:c,readonly:l=!1}){let{store:u}=Z(),{t:d}=X(),f=Ye(),{theme:p}=Je(),m=J(void 0),h=q(()=>oC(),[]),[g,_]=Y(!1),v=r?.intake??a,[y,b]=Y(()=>aC(v)),[x,S]=Y(()=>aC(v)),[C,T]=Y(void 0),[E,D]=Y(`overview`),O=y!==x,k=q(()=>{let e=sC(y,h);return e.ok?e.policy:void 0},[y,h]),A=k??v??ZS,j=e=>{let t=e,n=t.languages?.json?.jsonDefaults??t.json?.jsonDefaults,r=structuredClone(Mr);n?.setDiagnosticsOptions({validate:!0,allowComments:!1,schemas:[{uri:`vertesia://schemas/content-type-intake-policy.json`,fileMatch:[`*`],schema:r}]})},M=()=>{let e=sC(E===`json`?m.current?.getValue()??y:y,h);if(!e.ok){T(e.message);return}return T(void 0),e.policy},N=()=>{let e=M();if(!e)return;let t=s??(r?e=>u.types.update(r.id,{intake:e}).then(e=>e.intake):void 0);t&&(_(!0),t(e).then(t=>{let n=aC(t??e);b(n),S(n),c?.(t??e),f({status:`success`,title:d(`intakePolicy.toast.updated`),description:d(`intakePolicy.toast.saved`),duration:2e3})}).catch(e=>{f({status:`error`,title:d(`intakePolicy.toast.updateFailed`),description:H(e),duration:5e3})}).finally(()=>{_(!1)}))},P=()=>{let e=sC(E===`json`?m.current?.getValue()??y:y,h);T(e.ok?void 0:e.message),f({status:e.ok?`success`:`error`,title:e.ok?d(`intakePolicy.toast.valid`):d(`intakePolicy.toast.invalid`),description:e.ok?d(`intakePolicy.toast.schemaValid`):e.message,duration:3e3})},F=()=>{b(x),m.current?.setValue(x),T(void 0)},I=()=>{let e=M();if(!e)return;let t=aC(e);b(t),m.current?.setValue(t)},L=e=>{let t=aC(e.value);b(t),m.current?.setValue(t),T(void 0),D(`overview`)};return t(le,{title:n(`div`,{className:`flex items-center gap-2`,children:[t(`div`,{className:`text-base font-semibold`,children:d(`intakePolicy.title`)}),O&&t(i,{variant:`attention`,children:d(`intakePolicy.status.unsaved`)})]}),className:`bg-background! h-full`,action:l?void 0:n(e,{children:[t(w,{align:`right`,trigger:n(o,{variant:`outline`,size:`sm`,children:[t(_r,{className:`size-4`}),d(`intakePolicy.action.examples`)]}),children:t(ne,{label:d(`intakePolicy.action.insertExample`),children:XS.map(e=>n(B,{onClick:()=>L(e),children:[t(on,{className:`size-4`}),n(`div`,{className:`flex flex-col`,children:[t(`span`,{children:d(`intakePolicy.example.${e.key}.label`)}),t(`span`,{className:`text-xs text-muted`,children:d(`intakePolicy.example.${e.key}.description`)})]})]},e.key))})}),E===`json`&&n(e,{children:[n(o,{variant:`outline`,size:`sm`,onClick:I,children:[t(bt,{className:`size-4`}),d(`intakePolicy.action.format`)]}),n(o,{variant:`outline`,size:`sm`,onClick:P,children:[t(Tt,{className:`size-4`}),d(`intakePolicy.action.validate`)]})]}),n(o,{variant:`outline`,size:`sm`,onClick:F,disabled:!O,children:[t(Xn,{className:`size-4`}),d(`intakePolicy.action.revert`)]}),n(o,{isLoading:g,size:`sm`,onClick:N,disabled:!O,children:[t(Qn,{className:`size-4`}),d(`intakePolicy.action.save`)]})]}),children:n(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[t(eC,{policy:A}),C&&t(`div`,{className:`rounded-sm border border-destructive bg-mixer-destructive/10 px-3 py-2 text-sm whitespace-pre-line text-destructive`,children:C}),n(Pe,{tabs:$S(d,k??ZS,l,e=>{b(aC(e)),T(void 0)},y,{editorRef:m,beforeMount:j,onChange:e=>{b(e),T(void 0)},theme:p}),current:E,onTabChange:e=>{let t=e;if(t!==`json`&&!k){T(d(`intakePolicy.error.fixJsonBeforeForm`)),D(`json`);return}D(t)},updateHash:!1,responsive:!0,fullHeight:!0,className:`px-0`,children:[t(Fe,{sticky:!0}),t(Ie,{className:`min-h-0 flex-1 overflow-auto pt-1`})]})]})})}function $S(e,r,i,a,o,s){let c=(e,n)=>({name:e,label:n,content:t(RS,{policy:r,section:e,onChange:a,readonly:i})});return[c(`overview`,e(`intakePolicy.tab.overview`)),c(`conversion`,e(`intakePolicy.tab.conversion`)),c(`extraction`,e(`intakePolicy.tab.extraction`)),c(`grounding`,e(`intakePolicy.tab.grounding`)),c(`output`,e(`intakePolicy.tab.output`)),{name:`json`,label:e(`intakePolicy.tab.json`),content:n(`div`,{className:`flex h-full min-h-[36rem] gap-4 py-3`,children:[t(`div`,{className:`min-w-0 flex-1 overflow-hidden rounded-sm border`,children:t(Ri,{value:o,language:`json`,editorRef:s.editorRef,beforeMount:s.beforeMount,onChange:e=>s.onChange(e.state.doc.toString()),theme:s.theme===`dark`?`vs-dark`:`vs`,options:{readOnly:i,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:`on`,lineNumbers:`on`,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2}})}),t(tC,{})]})}]}function eC({policy:e}){let{t:r}=X(),a=e.extraction?.grounding;return t(`div`,{className:`flex flex-wrap gap-2`,children:[[r(`intakePolicy.summary.mode`),iC(r,e.mode)],[r(`intakePolicy.summary.conversion`),rC(r,e.text_conversion?.enabled)],[r(`intakePolicy.summary.method`),iC(r,e.text_conversion?.method)],[r(`intakePolicy.summary.source`),iC(r,e.extraction?.source)],[r(`intakePolicy.summary.extraction`),rC(r,e.extraction?.enabled)],[r(`intakePolicy.summary.grounding`),rC(r,a?.enabled)],[r(`intakePolicy.summary.defaultView`),iC(r,e.default_view)],[r(`intakePolicy.summary.toc`),rC(r,e.generate_toc)],[r(`intakePolicy.summary.template`),e.rendering_template?r(`intakePolicy.option.set`):r(`intakePolicy.option.inherit`)]].map(([e,r])=>n(i,{variant:`outline`,className:`gap-1`,children:[n(`span`,{className:`text-muted`,children:[e,`:`]}),t(`span`,{children:r})]},e))})}function tC(){let{t:e}=X();return n(`aside`,{className:`hidden w-80 shrink-0 overflow-y-auto rounded-sm border bg-mixer-muted/20 p-3 text-sm lg:block`,children:[t(`div`,{className:`mb-3 font-semibold`,children:e(`intakePolicy.help.title`)}),n(`div`,{className:`space-y-3 text-muted`,children:[t(nC,{label:`identification`,text:e(`intakePolicy.help.identification`)}),t(nC,{label:`text_conversion`,text:e(`intakePolicy.help.textConversion`)}),t(nC,{label:`extraction.source`,text:e(`intakePolicy.help.extractionSource`)}),t(nC,{label:`extraction.grounding`,text:e(`intakePolicy.help.grounding`)}),t(nC,{label:`extraction.grounding.review`,text:e(`intakePolicy.help.review`)}),t(nC,{label:`rendering_template`,text:e(`intakePolicy.help.renderingTemplate`)}),t(nC,{label:`embeddings`,text:e(`intakePolicy.help.embeddings`)}),t(nC,{label:`default_view`,text:e(`intakePolicy.help.defaultView`)})]})]})}function nC({label:e,text:r}){return n(`div`,{children:[t(`div`,{className:`font-medium text-foreground`,children:e}),t(`div`,{children:r})]})}function rC(e,t){return e(t===!0?`intakePolicy.option.enabled`:t===!1?`intakePolicy.option.disabled`:`intakePolicy.option.inherit`)}function iC(e,t){return e(t?`intakePolicy.option.${t}`:`intakePolicy.option.inherit`)}function aC(e){return JSON.stringify(e??ZS,null,2)}function oC(){let e=new Ki({strict:!1,allErrors:!0});return ra(e),e.compile(Mr)}function sC(e,t){let n;try{n=e.trim()?JSON.parse(e):{}}catch(e){return{ok:!1,message:`Invalid JSON: ${H(e)}`}}return t(n)?{ok:!0,policy:n}:{ok:!1,message:cC(t.errors)}}function cC(e){return e?.length?e.map(e=>`${e.instancePath||`/`} ${e.message??`is invalid`}`).join(`
|
|
456
|
+
`):`The intake policy does not match the schema.`}function lC({objectType:e,onSchemaUpdate:r,readonly:i=!1}){let{store:a}=Z(),{t:s}=X(),c=Ye(),{theme:l}=Je(),[u,d]=Y(!1),f=Gi(e.object_schema),p=J(void 0),[m,h]=Y(!1),g=q(()=>uC(f.schema),[f]),_=()=>{m&&!y()||(d(!0),a.types.update(e.id,{object_schema:f.schema}).then(()=>{r(f),c({status:`success`,title:s(`store.schemaUpdated`),description:s(`store.schemaUpdatedSuccess`),duration:2e3})}).catch(e=>{c({status:`error`,title:s(`store.failedToUpdateSchema`),description:e.message,duration:5e3})}).finally(()=>{d(!1)}))},v=()=>{m&&!y()||h(e=>!e)},y=()=>{if(p.current){let e=p.current.getValue();try{let t=dC(e);fC(t),f.replaceSchema(t)}catch(e){return c({status:`error`,title:s(`store.invalidJsonSchema`),description:H(e),duration:5e3}),!1}}return!0};return t(le,{title:n(`div`,{className:`flex gap-2 items-center`,children:[t(`div`,{className:`text-base font-semibold`,children:s(`store.schemaEditor`)}),!i&&t(`div`,{children:t(o,{variant:`outline`,size:`sm`,onClick:v,children:s(m?`store.editSchema`:`store.editJson`)})})]}),className:`bg-background! h-full`,action:i?void 0:t(o,{isLoading:u,variant:`outline`,size:`sm`,onClick:_,children:s(`modal.saveChanges`)}),children:m?t(Ri,{value:g,language:`json`,editorRef:p,theme:l===`dark`?`vs-dark`:`vs`,options:{readOnly:i}}):t(Bi,{schema:f,readonly:i})})}function uC(e){return e?JSON.stringify(e,null,2):``}function dC(e){if(e?.trim())return JSON.parse(e.trim())}const fC=e=>{try{new qi({strict:!1}).compile(e)}catch(e){throw Error(`Invalid JSON Schema definition: ${H(e)}`,{cause:e})}};function pC({isOpen:e,onClose:r,title:i,children:a,initialSelectedType:s=null,allowNone:c=!0}){let{t:l}=X(),u=i??l(`store.selectContentType`),{registry:d}=Gg(),[f,p]=Y(s),m=d?.types||[],h=()=>{r(void 0)};return n(ie,{isOpen:e,onClose:h,className:`w-full max-w-xl mx-auto`,children:[t(se,{children:u}),n(ae,{children:[a,n(`div`,{className:`mb-4 mt-4`,children:[n(`div`,{className:`block text-sm font-medium mb-2`,children:[l(`store.contentType`),` `,c&&t(`span`,{className:`text-gray-500 font-normal`,children:l(`store.optional`)})]}),c?t(ye,{options:m,value:f,optionLabel:e=>e?e.name:l(`store.selectContentTypeLabel`),placeholder:l(`store.selectContentTypeAuto`),onChange:e=>p(e||null),filterBy:`name`,isClearable:!0}):t(ye,{options:m,value:f,optionLabel:e=>e?e.name:l(`store.selectContentTypeLabel`),placeholder:l(`store.selectContentTypeLabel`),onChange:e=>p(e||null),filterBy:`name`})]}),!f&&n(`div`,{className:`flex items-center text-attention`,children:[t(Et,{className:`size-4 me-1`}),l(`store.automaticTypeDetection`),t(ze,{description:l(`store.automaticTypeDetectionDescription`),placement:`top`,size:`xs`,children:t(yn,{className:`size-3 ms-2`})})]})]}),n(oe,{children:[t(o,{variant:`ghost`,onClick:h,title:l(`modal.cancel`),children:l(`modal.cancel`)}),t(o,{onClick:()=>{r(f?.id??null),p(null)},title:l(`store.confirmSelection`),children:l(`modal.confirm`)})]})]})}function mC({children:e,limit:n,name:r,chunkable:i}){let{store:a}=Z(),o=q(()=>{let e=new wS(a,n);return e.query.name=r,e.query.chunkable=i,e},[i,n,r,a]);return t(TS.Provider,{value:o,children:e})}function hC({objectType:e,onLayoutUpdate:n,readonly:r=!1}){let i=Ye(),{theme:a}=Je(),{t:s}=X(),[c,l]=Y(!1),{store:u}=Z(),d=J(void 0),f=q(()=>gC(e.table_layout),[e.table_layout]),p=(e,t)=>{i({status:`error`,title:e,description:t,duration:5e3})};return t(le,{title:`Table Layout Editor`,className:`bg-background! h-full`,action:r?void 0:t(o,{isLoading:c,variant:`outline`,size:`sm`,onClick:()=>{if(!d.current)return;let t=d.current.getValue(),r;if(!t)r=null;else try{r=JSON.parse(t)}catch(e){return p(`Invalid JSON`,H(e))}if(!Array.isArray(r))return p(`Invalid JSON`,`The table layout must be an array`);if(r.some(e=>!e?.name||!e.field))return p(`Invalid JSON`,`A table layout entry must contain the following properties:] {field, name, converter?}`);l(!0),u.types.update(e.id,{table_layout:r}).then(e=>{i({status:`success`,title:s(`store.tableLayoutUpdated`),description:s(`store.tableLayoutUpdatedDesc`),duration:2e3}),n(e.table_layout)}).catch(e=>{i({status:`error`,title:s(`store.failedToUpdateTableLayout`),description:e.message,duration:5e3})}).finally(()=>{l(!1)})},children:s(`store.saveChanges`)}),children:t(`div`,{className:`h-full`,children:t(Ri,{value:f,language:`json`,editorRef:d,theme:a===`dark`?`vs-dark`:`vs`,options:{readOnly:r}})})})}function gC(e){return e?JSON.stringify(e,null,2):`[
|
|
457
|
+
|
|
458
|
+
]`}function _C({collection:e}){let{client:n}=Z(),{t:r}=X(),[i,a]=Y(void 0),[s,c]=Y(e.shared_properties||[]),l=Ye();K(()=>{e.type?.id&&n.store.types.retrieve(e.type.id).then(a)},[n.store.types.retrieve,e.type?.id]);let u=i?Object.keys(i.object_schema?.properties||{}):[];return t(le,{title:r(`store.sharedProperties`),description:r(`store.sharedPropertiesDescription`),action:t(o,{size:`lg`,isLoading:!1,onClick:()=>{n.store.collections.update(e.id,{shared_properties:s}).then(()=>{l({title:r(`store.updatedSharedProperties`),status:`success`})}).catch(e=>{l({title:r(`store.failedToUpdateSharedProperties`),description:e.message,status:`error`})})},children:r(`modal.save`)}),children:t(`div`,{className:``,children:t(Le,{value:s,onChange:e=>{c(e)},options:u,placeholder:r(`store.selectPropertiesToShare`)})})})}function vC({collection:e}){let{client:n}=Z(),{t:r}=X(),[i,a]=Y(e.skip_head_sync??!1),[o,s]=Y(!1),c=Ye();return t(le,{title:r(`store.syncMemberHeads`),description:r(`store.syncMemberHeadsDescription`),children:t(Oe,{disabled:o,value:!i,onChange:t=>{let i=!t;s(!0),n.store.collections.update(e.id,{skip_head_sync:i}).then(()=>{c({title:r(`store.updatedSkipHeadSync`),status:`success`}),a(i)}).catch(e=>{c({title:r(`store.failedToUpdateSkipHeadSync`),description:e.message,status:`error`})}).finally(()=>{s(!1)})},children:r(`store.enableSyncMemberHeads`)})})}function yC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function bC({refetch:r,collection:a}){let{t:s}=X(),c=a.type?Gr(a.type):void 0,l=J(void 0),u=Ye(),{theme:d}=Je(),{client:f}=Z(),p=at(hv),[m,h]=Y(!1),[g,_]=Y({name:a.name,description:a.description||``,query:a.query?JSON.stringify(a.query,null,2):``,tags:a.tags||[],type:a.type?Gr(a.type):``,allowed_types:a.allowed_types||[],sensitivity:a.sensitivity,compartments:a.compartments||[]}),[v,y]=Y(``),b=q(()=>gC(a.table_layout),[a.table_layout]),x=()=>{let e;try{let t=g.query?JSON.parse(g.query):void 0;if(t!==void 0&&!yC(t))throw Error(s(`store.invalidQueryJson`));e=t}catch(e){u({title:s(`store.invalidQueryJson`),description:H(e),status:`error`,duration:5e3});return}let t={name:g.name,description:g.description,query:e,tags:g.tags,type:g.type,allowed_types:g.allowed_types,sensitivity:g.sensitivity,compartments:g.compartments},n;if(t.name||(n=s(`type.nameRequired`)),t.type||=null,n){u({title:s(`store.validationFailed`),description:n,status:`error`,duration:5e3});return}if(l.current){let e=l.current.getValue();if(e)try{t.table_layout=JSON.parse(e)}catch(e){u({title:s(`store.invalidTableLayout`),description:H(e),status:`error`,duration:5e3});return}else t.table_layout=null}h(!0),f.store.collections.update(a.id,t).then(()=>{r(),a.dynamic&&p&&(p.reset(),p.search()),u({title:s(`store.collectionUpdated`),description:s(`store.collectionUpdatedSuccess`),status:`success`,duration:3e3})}).catch(e=>{u({title:s(`store.failedToUpdateCollection`),description:H(e),status:`error`,duration:5e3})}).finally(()=>{h(!1)})},S=(e,t)=>{_({...g,[e]:t})};return n(`div`,{className:`flex flex-col gap-4 py-2`,children:[n(le,{title:s(`store.configuration`),action:t(o,{size:`lg`,isDisabled:m,onClick:x,children:s(`modal.save`)}),children:[n(`div`,{className:`flex justify-between mb-2`,children:[n(`div`,{className:`w-1/2 gap-2 flex flex-col`,children:[t(`div`,{className:`text-sm font-medium mb-1`,children:s(`store.createdBy`)}),n(`div`,{className:`gap-2 flex items-center`,children:[t(jg,{userRef:a.created_by,showTitle:!0}),n(`span`,{children:[`at `,ni(a.created_at).format(`YYYY-MM-DD HH:mm:ss`)]})]})]}),n(`div`,{className:`w-1/2 gap-2 flex flex-col`,children:[t(`div`,{className:`text-sm font-medium mb-1`,children:s(`store.updatedBy`)}),n(`div`,{className:`gap-2 flex items-center`,children:[t(jg,{userRef:a.updated_by,showTitle:!0}),n(`span`,{children:[`at `,ni(a.updated_at).format(`YYYY-MM-DD HH:mm:ss`)]})]})]})]}),t(L,{label:s(`type.name`),required:!0,children:t(ee,{value:g.name,onChange:e=>S(`name`,e)})}),t(L,{label:s(`type.description`),children:t(Re,{value:g.description,onChange:e=>S(`description`,e.target.value)})}),!a.dynamic&&t(L,{label:s(`store.allowedContentTypes`),description:s(`store.allowedContentTypesSelectDescription`),children:t(gS,{defaultValue:g.allowed_types||null,onChange:e=>{Array.isArray(e)?S(`allowed_types`,e.map(e=>e.id)):S(`allowed_types`,e?[e.id]:[])},isClearable:!0,multiple:!0})}),a.dynamic&&t(L,{label:s(`store.query`),description:s(`store.queryDescription`),children:t(Re,{className:De.INPUT,minLines:1,maxLines:12,value:g.query,onChange:e=>S(`query`,e.target.value)})}),t(L,{label:s(`store.tableLayout`),description:s(`store.tableLayoutDescription`),className:`h-[200px]`,children:t(Ri,{className:`border-1 rounded-md border-border`,value:b,language:`json`,editorRef:l,theme:d===`dark`?`vs-dark`:`vs`})}),t(L,{label:s(`store.contentType`),description:s(`store.typeSelectDescription`),children:t(gS,{defaultValue:g.type||null,onChange:e=>{Array.isArray(e)?S(`type`,e.length>0?e[0].id:null):S(`type`,e?.id||null)},isClearable:!0})}),t(L,{label:`Sensitivity`,description:`BLP sensitivity level — propagated to member documents (max across collections)`,children:t(ye,{options:Hr.map((e,t)=>({label:`${t} — ${e}`,value:t})),value:g.sensitivity===void 0?void 0:{label:`${g.sensitivity} — ${Hr[g.sensitivity]??`Unknown`}`,value:g.sensitivity},onChange:e=>S(`sensitivity`,e.value),optionLabel:e=>e.label,by:`value`,placeholder:`Not set`})}),n(L,{label:`Compartments`,description:`Security compartments — propagated to member documents (union across collections)`,children:[n(`div`,{className:`flex gap-2`,children:[t(ee,{value:v,onChange:y,placeholder:`Add a compartment`,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=v.trim();t&&!g.compartments.includes(t)&&(S(`compartments`,[...g.compartments,t]),y(``))}}}),t(o,{type:`button`,variant:`outline`,onClick:()=>{let e=v.trim();e&&!g.compartments.includes(e)&&(S(`compartments`,[...g.compartments,e]),y(``))},children:`Add`})]}),t(`div`,{className:`flex gap-1 flex-wrap mt-2`,children:g.compartments.map(e=>n(i,{variant:`secondary`,className:`cursor-pointer`,onClick:()=>S(`compartments`,g.compartments.filter(t=>t!==e)),children:[e,` ×`]},e))})]})]}),c&&t(xC,{typeId:c,collection:a}),!a.dynamic&&n(e,{children:[t(vC,{collection:a}),t(_C,{collection:a})]})]})}function xC({typeId:e,collection:n}){let{t:r}=X(),[i,a]=Y({}),s=Ye(),{client:c}=Z(),[l,u]=Y(!1),{data:d,error:f}=Ue(()=>c.store.types.catalog.resolve(e),[e]),p=d?.object_schema||{},m=q(()=>new Ii(p,n.properties||{}),[p,n.properties]);if(f)return t(M,{title:r(`store.failedToLoadType`),children:H(f)});if(!d)return null;let h=e=>{if(!e||!Object.keys(e).length)return;let t={properties:e||{}};u(!0),c.store.collections.update(n.id,t).then(()=>{s({title:r(`store.collectionPropertiesUpdated`),description:r(`store.collectionUpdatedSuccess`),status:`success`,duration:3e3})}).catch(e=>{s({title:r(`store.failedToUpdateCollectionProperties`),description:H(e),status:`error`,duration:5e3})}).finally(()=>{u(!1)})};return t(le,{title:r(`store.properties`),action:t(o,{size:`lg`,isLoading:l,type:`submit`,onClick:()=>h(i),children:r(`modal.save`)}),children:t(Ni,{object:m,onChange:e=>{e instanceof Ii&&a(e.value)}})})}function SC({onChange:e,value:r,disabled:i=!1,placeholder:a,searchPlaceholder:s,filterOut:c,allowDynamic:l=!0,multiple:u=!1}){let{client:d}=Z(),{t:f}=X(),p=a??f(`store.selectACollection`),m=s??f(`store.searchCollections`),[b,x]=Y(``),[S,C]=Y(!1),[w,T]=Y(!1),E=He(b,300),D=G(async e=>{C(!0);let t=e.trim(),n=await d.store.collections.search({dynamic:l?void 0:!1,name:w&&t||void 0});return C(!1),!w&&n.length>=1e3&&T(!0),c&&c.length>0?n.filter(e=>!c.includes(e.id)):n},[d,l,c,w]),{data:O,error:k}=Ue(()=>D(w?E:``),[w?E:``,D]),A=q(()=>O?u&&Array.isArray(r)?O.filter(e=>r.includes(e.id)):!u&&typeof r==`string`?O.find(e=>e.id===r):u?[]:void 0:u?[]:void 0,[O,r,u]),j=G(t=>{if(u){let n=Array.isArray(r)?r:[];if(n.includes(t.id)){let r=n.filter(e=>e!==t.id);e(r,O?.filter(e=>r.includes(e.id))||[])}else{let r=[...n,t.id];e(r,O?.filter(e=>r.includes(e.id))||[])}}else e(t.id,t)},[e,r,O,u]),N=G(()=>{e(void 0,void 0)},[e]),P=G(e=>{x(e)},[]),F=b.trim().length>0,I=q(()=>{if(!O)return[];if(w||!F)return O;let e=b.toLowerCase();return O.filter(t=>t.name.toLowerCase().includes(e))},[O,w,F,b]),L=u?Array.isArray(A)&&A.length>0:!!A;return k?t(M,{title:f(`store.collectionFetchFailed`),children:H(k)}):n(ue,{children:[t(fe,{asChild:!0,children:n(o,{variant:`outline`,role:`combobox`,"aria-haspopup":`listbox`,className:V(`w-full justify-between min-w-0`),disabled:i,children:[t(`span`,{className:`truncate flex-1 text-start min-w-0`,children:u&&Array.isArray(A)&&A.length>0?A.length===1?A[0].name:f(`store.collectionsSelected`,{count:A.length}):!u&&A&&!Array.isArray(A)?A.name:p}),L&&!i?t(o,{variant:`unstyled`,"aria-label":`Clear selection`,className:`ms-2 shrink-0 opacity-50 hover:opacity-100 hover:text-destructive cursor-pointer`,onClick:e=>{e.stopPropagation(),N()},children:t(yr,{className:`h-4 w-4`})}):t(Rt,{className:`ms-2 h-4 w-4 shrink-0 opacity-50`})]})}),t(de,{className:`mt-2 mb-2 w-[var(--radix-popover-trigger-width)] p-0`,align:`start`,children:n(h,{shouldFilter:!1,children:[n(`div`,{className:`flex justify-between items-center border-b px-3`,"cmdk-input-wrapper":``,children:[t(v,{placeholder:m,value:b,onValueChange:P,className:`flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`}),S&&t(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`})]}),t(g,{children:f(S?`store.searching`:F?`store.noCollectionsFound`:`store.noCollectionsAvailable`)}),n(_,{className:`max-h-[300px] overflow-auto`,children:[L&&!F&&t(y,{value:`__clear__`,onSelect:N,className:`text-destructive`,children:`Remove collection selection(s)`}),F&&t(y,{value:`__clear_search__`,onSelect:()=>x(``),className:`text-muted`,children:f(`store.clearSelection`)}),I.map(e=>{let i=u&&Array.isArray(r)?r.includes(e.id):r===e.id;return n(y,{value:e.id,onSelect:()=>j(e),className:`flex items-center justify-between`,children:[t(`span`,{className:`truncate`,children:e.name}),i&&t(St,{className:`ms-2 h-4 w-4 shrink-0`})]},e.id)})]})]})})]})}function CC({isOpen:e,onClose:r}){return n(ie,{onClose:()=>r(),isOpen:!!e,className:`min-w-[60vw]`,children:[t(se,{children:`Select Content`}),t(ae,{className:`pt-0 overflow-y-auto max-h-[80vh] min-h-[80vh]`,children:e&&t(Lv,{onChange:r})})]})}const wC=/store:([a-f0-9]+)/;function TC({object:e}){let{client:r}=Z(),{off:i,on:a,isOn:s}=Ge(),[c,l]=Y(e.value==null?``:String(e.value)),[u,d]=Y(void 0),f=t=>{let n=t.target.value;l(n),e.value=n},p=G(()=>{l(``),e.value=``,d(void 0)},[e]);return K(()=>{if(!c||u)return;let e=c.match(wC);e&&r.objects.retrieve(e[1]).then(e=>{d(e)}).catch(()=>{p()})},[c,r.objects.retrieve,p,u]),n(`div`,{children:[n(`div`,{className:`relative`,children:[t(`input`,{value:c,onChange:f,className:Ze(De.INPUT,`pe-10 w-full`)}),u&&t(`div`,{className:`absolute inset-y-0 end-10 flex items-center justify-center `,children:t(o,{onClick:p,variant:`unstyled`,className:`hover:text-red-500 hover:bg-gray-100 dark:hover:bg-gray-600`,children:t(yr,{className:`size-5`})})}),t(`div`,{className:`absolute inset-y-0 end-0 flex items-center justify-center`,children:t(o,{onClick:a,variant:`unstyled`,className:`hover:bg-gray-100 dark:hover:bg-gray-600`,children:t(Rt,{className:`size-5`})})}),t(CC,{value:c,isOpen:s,onClose:t=>{if(t){let n=`store:${t.id}`;l(n),d(t||void 0),e.value=n}i()}})]}),u&&t(`div`,{className:`p-1 semibold text-sm text-gray-600 dark:text-slate-300`,children:typeof u.properties?.title==`string`?u.properties.title:u.name})]})}function EC({objectId:e,isOpen:r,onClose:i}){let a=Di(),{client:s,store:c}=Z(),[l,u]=Y(null),[d,f]=Y(!1),[p,m]=Y(!1),[h,g]=Y(),[_,v]=Y(),[y,b]=Y(`preview`),{t:x}=X(),S=Ye(),C=G(async e=>{m(!0);try{let t=await c.objects.getObjectText(e);g(t.text)}catch(e){console.error(`Error loading text:`,e)}finally{m(!1)}},[c.objects]),w=G(async e=>{if(e.content?.source)try{(await s.objects.getRendition(e.id,{format:Pr.jpeg,generate_if_missing:!1})).status===`found`&&console.log(`Found rendition`);let t=await s.files.getDownloadUrl(e.content.source);v(t.url)}catch(e){console.error(`Error loading image:`,e)}},[s.files,s.objects]);K(()=>{e&&r?(f(!0),c.objects.retrieve(e,`+embeddings`).then(e=>{u(e),e.text?g(e.text):C(e.id);let t=e.content;t?.source&&t.type?.startsWith(`image/`)&&w(e)}).catch(e=>{console.error(`Error loading object:`,e),S({title:x(`agent.error`),description:x(`store.failedToLoadDocument`),status:`error`,duration:3e3})}).finally(()=>{f(!1)})):(u(null),g(void 0),v(void 0))},[e,r,c.objects,C,w,x,S]);let T=()=>{l&&(a(`/legal/objects/${l.id}`),i())},E=h&&(h.startsWith(`#`)||h.includes(`
|
|
452
459
|
#`)||h.includes(`
|
|
453
|
-
*`)),D=l?.content?.type?.startsWith(`image/`),O=l?.content?.type===`application/pdf`;return r?n(`div`,{className:`fixed inset-y-0 end-0 w-2/5 dark:bg-slate-900 shadow-xl z-50 flex flex-col transition-transform duration-300 transform ${r?`translate-x-0`:`translate-x-full rtl:-translate-x-full`}`,children:[n(`div`,{className:`flex items-center justify-between px-4 py-3 border-b dark:border-gray-700 bg-gradient-to-r from-indigo-50 to-gray-50 dark:from-gray-800 dark:to-gray-900`,children:[n(`div`,{className:`flex items-center`,children:[t(qt,{className:`h-5 w-5 text-indigo-600 me-2`}),t(`h2`,{className:`text-lg font-semibold text-gray-800 dark:text-gray-200 truncate`,children:d?x(`store.loadingDocument`):l?.name||x(`store.documentPreview`)})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{variant:`ghost`,size:`sm`,onClick:T,className:`flex items-center gap-1 text-indigo-600 hover:text-indigo-800`,children:[t(_n,{className:`h-4 w-4`}),t(`span`,{children:x(`store.fullView`)})]}),t(o,{variant:`ghost`,size:`sm`,onClick:i,className:`flex items-center text-gray-600 hover:text-gray-800 dark:text-gray-300 dark:hover:text-gray-100`,children:t(nr,{className:`h-5 w-5`})})]})]}),d?t(`div`,{className:`flex-1 flex items-center justify-center`,children:n(`div`,{className:`text-center`,children:[t(be,{size:`lg`,className:`text-indigo-600 dark:text-indigo-400 mb-2`}),t(`p`,{className:`text-gray-600 dark:text-gray-400`,children:x(`store.loadingDocument`)})]})}):n(`div`,{className:`flex-1 flex flex-col h-full`,children:[t(`div`,{className:`border-b`,children:n(`div`,{className:`flex px-4`,children:[t(o,{variant:`unstyled`,className:`py-2 px-4 font-medium border-b-2 ${y===`preview`?`border-indigo-600 text-indigo-700 dark:text-indigo-300`:`border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`}`,onClick:()=>b(`preview`),children:n(`div`,{className:`flex items-center gap-1`,children:[t(ln,{className:`h-4 w-4`}),t(`span`,{children:x(`store.preview`)})]})}),t(o,{variant:`unstyled`,className:`py-2 px-4 font-medium border-b-2 ${y===`properties`?`border-indigo-600 text-indigo-700 dark:text-indigo-300`:`border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`}`,onClick:()=>b(`properties`),children:n(`div`,{className:`flex items-center gap-1`,children:[t(on,{className:`h-4 w-4`}),t(`span`,{children:x(`store.properties`)})]})})]})}),n(`div`,{className:`flex-1 overflow-auto p-4`,children:[y===`preview`&&n(`div`,{className:`h-full`,children:[p?t(`div`,{className:`flex items-center justify-center h-40`,children:t(be,{size:`md`,className:`text-indigo-600 dark:text-indigo-400`})}):h?t(`div`,{className:`shadow rounded-md p-4 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800`,children:E?t(`div`,{className:`prose prose-sm max-w-none prose-p:my-2 prose-pre:bg-gray-800 prose-pre:my-2 prose-headings:text-indigo-700 dark:prose-invert dark:prose-headings:text-indigo-300`,children:t(yi,{children:h})}):t(`pre`,{className:`text-wrap whitespace-pre-wrap dark:text-gray-200`,children:h})}):null,D&&t(`div`,{className:`mt-4`,children:_?t(`div`,{className:`border border-gray-200 dark:border-gray-700 rounded-md p-2 bg-white dark:bg-gray-800`,children:t(`img`,{src:_,alt:l?.name,className:`mx-auto max-h-[70vh] object-contain`})}):t(`div`,{className:`flex items-center justify-center h-40`,children:t(be,{size:`md`,className:`text-indigo-600 dark:text-indigo-400`})})}),O&&n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-gray-200 dark:border-gray-700 rounded-md p-4 bg-gray-50 dark:bg-gray-800`,children:[t(qt,{className:`h-16 w-16 text-indigo-300 dark:text-indigo-400 mb-4`}),t(`p`,{className:`text-gray-600 dark:text-gray-400 text-center mb-4`,children:x(`store.pdfPreviewFullView`)}),t(o,{onClick:T,className:`bg-indigo-600 hover:bg-indigo-700 text-white`,children:x(`store.openFullDocumentView`)})]}),!D&&!h&&!O&&!p&&n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-gray-200 dark:border-gray-700 rounded-md p-4 bg-gray-50 dark:bg-gray-800`,children:[t(qt,{className:`h-16 w-16 text-gray-300 dark:text-gray-600 mb-4`}),t(`p`,{className:`text-gray-600 dark:text-gray-400 text-center`,children:x(`store.noPreviewAvailable`)})]})]}),y===`properties`&&l&&n(`div`,{className:`h-full`,children:[l.properties?t(`div`,{className:`shadow rounded-md p-4 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800`,children:t(_i,{value:l.properties})}):n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-gray-200 dark:border-gray-700 rounded-md p-4 bg-gray-50 dark:bg-gray-800`,children:[t(on,{className:`h-16 w-16 text-gray-300 dark:text-gray-600 mb-4`}),t(`p`,{className:`text-gray-600 dark:text-gray-400 text-center`,children:x(`store.noPropertiesAvailable`)})]}),n(`div`,{className:`mt-4`,children:[t(`h3`,{className:`text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2`,children:x(`store.documentInformation`)}),t(`div`,{className:`shadow rounded-md p-4 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800`,children:n(`div`,{className:`grid grid-cols-2 gap-y-2 gap-x-4 text-sm`,children:[t(`div`,{className:`text-gray-500 dark:text-gray-400`,children:x(`store.id`)}),t(`div`,{className:`font-medium dark:text-gray-200`,children:l.id}),t(`div`,{className:`text-gray-500 dark:text-gray-400`,children:x(`store.contentType`)}),t(`div`,{className:`font-medium dark:text-gray-200`,children:l.type?.name||x(`store.unknown`)}),t(`div`,{className:`text-gray-500 dark:text-gray-400`,children:x(`store.contentType`)}),t(`div`,{className:`font-medium dark:text-gray-200`,children:l.content?.type||x(`store.na`)}),t(`div`,{className:`text-gray-500`,children:x(`store.size`)}),t(`div`,{className:`font-medium`,children:l.content&&`size`in l.content?oS(l.content.size):x(`store.unknown`)}),t(`div`,{className:`text-gray-500`,children:x(`store.created`)}),t(`div`,{className:`font-medium`,children:l.created_at?new Date(l.created_at).toLocaleString():x(`store.na`)}),t(`div`,{className:`text-gray-500`,children:x(`store.updated`)}),t(`div`,{className:`font-medium`,children:l.updated_at?new Date(l.updated_at).toLocaleString():x(`store.na`)})]})})]})]})]})]}),n(`div`,{className:`flex items-center justify-between p-4 border-t bg-gray-50 dark:bg-gray-800 dark:border-gray-700`,children:[t(`div`,{children:l?.content?.source&&n(o,{onClick:()=>{l?.content?.source&&s.files.getDownloadUrl(l.content.source).then(e=>{window.open(e.url,`_blank`)}).catch(e=>{console.error(`Error getting download URL:`,e),S({title:x(`agent.error`),description:x(`store.failedToDownloadFile`),status:`error`,duration:3e3})})},variant:`outline`,className:`text-indigo-600 border-indigo-300 hover:bg-indigo-50`,children:[t(Lt,{className:`h-4 w-4 me-2`}),x(`pdf.download`)]})}),n(o,{onClick:T,className:`bg-indigo-600 hover:bg-indigo-700 text-white`,children:[x(`store.openFullDocument`),t(St,{className:`h-4 w-4 ms-2 cn-rtl-flip`})]})]})]}):null}function oS(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`}var sS;(function(e){e.CSV=`CSV`,e.JSON=`JSON`})(sS||={});function cS({isExporting:e,isOpen:r,onClose:i}){return n(B,{onClose:()=>i(void 0),isOpen:r,children:[t(re,{children:`Export Object Properties`}),n(te,{children:[!e&&t(lS,{onClose:i}),e&&t(uS,{})]})]})}function lS({onClose:e}){let{t:r}=X(),[i,a]=Y(void 0),[s,c]=Y(void 0),l=[`Export selected objects`,`Export all objects`],u=e=>e===l[1];return n(te,{className:`min-h-[104px] pt-0 flex flex-col gap-y-4`,children:[t(`div`,{className:`h-1/3`,children:t(V,{options:l,value:s,onChange:c,placeholder:r(`store.chooseWhatToExport`),className:`h-full w-full text-sm`,filterBy:`name`,isClearable:!0})}),n(`div`,{className:`h-1/2 flex flex-col gap-y-8 content-between`,children:[t(V,{options:Object.values(sS),value:i,onChange:a,placeholder:r(`store.chooseAFormat`),className:`h-full w-full text-sm`,filterBy:`name`,isClearable:!0}),t(o,{className:`w-full`,isDisabled:!i||!s,onClick:()=>{e(i,u(s))},children:r(`store.actions.exportProperties`)})]})]})}function uS(){let{t:e}=X();return t(te,{className:`min-h-[84px] pt-0`,children:n(`div`,{className:`h-full grid flex-col gap-y-2 content-between justify-items-center`,children:[n(`div`,{className:`text-sm flex flex-col gap-x-2`,children:[t(`p`,{children:e(`store.exportInProgress`)}),t(`p`,{className:`pt-2 grid justify-items-center`,children:e(`store.pleaseWait`)})]}),t(be,{size:`lg`})]})})}const dS=Ye(void 0);function fS(){let e=Qe(dS);if(!e)throw Error(`You cannot use useActionContext outside an ActionProvider`);return e}function pS(e,t){let n=fS();return K(()=>n.registerCallback(e,t),[n,e,t]),n}function mS({action:e,objectIds:n}){let[r,i]=Y(!1),a=G(()=>(n.length>0&&i(!0),Promise.resolve(!0)),[n]);return pS(e.id,a),r&&t(le,{children:t(_S,{objectIds:n,isOpen:r,onClose:()=>{i(!1)}})})}const hS=rt.getFixedT(null,nt),gS={id:`addToCollection`,name:hS(`store.actions.addToCollection`),description:hS(`store.actions.addToCollectionDesc`),confirm:!1,component:mS};function _S({isOpen:e,onClose:r,objectIds:i}){let{t:a}=X();return n(B,{isOpen:e,onClose:r,className:`max-w-lg w-full min-w-0 overflow-hidden`,children:[t(re,{className:`flex flex-col min-w-0 overflow-hidden`,children:a(`store.actions.addToCollectionTitle`)}),t(v,{className:`min-w-0 overflow-hidden`,children:a(`store.actions.addToCollectionBody`)}),t(`div`,{className:`min-w-0 max-w-full overflow-hidden`,children:t(vS,{onClose:r,objectIds:i})})]})}function vS({onClose:e,objectIds:r}){let{t:i}=X(),a=He(),{client:s}=Z(),[c,l]=Y(),u=({collectionId:t})=>{!t||!r?.length||s.store.collections.addMembers(t,r).then(()=>{a({title:i(`store.actions.addToCollectionSuccess`),status:`success`,description:i(`store.actions.addToCollectionSuccessDesc`,{count:r.length}),duration:3e3}),e()}).catch(()=>{a({title:i(`store.actions.addToCollectionFailure`),status:`error`,description:i(`store.actions.addToCollectionFailureDesc`),duration:5e3})})};return n(De,{defaultValue:`select`,tabs:[{name:`select`,label:i(`store.actions.selectCollection`),content:n(`div`,{className:`p-4 min-w-0 max-w-full overflow-hidden`,children:[t(P,{level:5,children:i(`store.actions.chooseExistingCollections`)}),t(te,{className:`min-w-0 max-w-full overflow-hidden`,children:t(`div`,{className:`mb-4 min-w-0 max-w-full overflow-hidden`,children:t(tS,{onChange:(e,t)=>{typeof e==`string`||e===void 0?l(e):Array.isArray(e)&&e.length>0?l(e[0]):l(void 0)},value:c})})}),t(ne,{children:t(o,{isDisabled:!c,onClick:()=>c&&u({collectionId:c}),children:i(`store.actions.addToCollectionButton`)})})]})},{name:`create`,label:i(`store.actions.createNew`),content:t(`div`,{className:`p-4`,children:t(Ox,{onClose:e,onAddToCollection:e=>u({collectionId:e}),redirect:!1})})}],fullWidth:!0,children:[t(Oe,{}),t(ke,{})]})}function yS({action:e,objectIds:r,children:i}){let{t:a}=X(),{store:o}=Z(),s=He(),[c,l]=Y(!1),u=G(()=>(l(!0),Promise.resolve(!0)),[]);return pS(e.id,u),n(`div`,{children:[i,t(Kx,{isOpen:c,onClose:e=>{l(!1),e!==void 0&&o.runOperation({name:`change_type`,ids:r,params:{typeId:e}}).then(e=>{s({status:`success`,title:a(`store.actions.changeType`),description:`Change the type of ${r.length} objects is ${e.status===`in_progress`?`in progress`:`completed`}`,duration:2e3})}).catch(e=>{s({status:`error`,title:a(`store.actions.errorChangingType`),description:e.message,duration:5e3})})},title:`Change Content Type`,confirmLabel:`Change Type`,children:n(`p`,{className:`pt-2 text-xs`,children:[`Note: This action will raise the `,t(`code`,{children:`change_type`}),` event and will trigger the standard intake workflows which may reset the object properties.`]})})]})}const bS=rt.getFixedT(null,nt),xS={id:`changeType`,name:bS(`store.actions.changeContentType`),description:bS(`store.actions.changeContentTypeDesc`),confirm:!1,component:yS};function SS({action:r,callback:i,children:a}){let{t:o}=X(),[s,c]=Y(!1),l=r.confirmationText||`Are you sure you want to ${r.name}?`,u=G(e=>r.confirm?(c(!0),Promise.resolve(!0)):i(e),[r.confirm,i]),d=pS(r.id,u);return n(e,{children:[a,t(g,{onConfirm:()=>{c(!1),i({...d.params,action:r})},onCancel:()=>c(!1),title:o(`store.actions.areYouSure`),content:l,isOpen:s})]})}function CS({action:r,objectIds:i,children:a}){let{t:o}=X(),s=fS(),c=He(),{client:l}=Z(),u=jv(),d=li(),[f,p]=Y(!1),m=i?.length??0,h=s.params?.type?.name??`object`,_=G(()=>(p(!0),Promise.resolve(!0)),[]);pS(r.id,_);let v=G(()=>(p(!1),i?.length?l.store.objects.delete(i).then(e=>{let t=e.deleted>1?`s`:``;if(c({status:`success`,title:`${e.deleted} object${t} deleted`,duration:2e3}),e.failed.length>0&&c({status:`warning`,title:`${e.failed.length} object(s) could not be deleted`,duration:3e3}),u){s.params?.selection?.removeAll();let e=JSON.parse(JSON.stringify(u.facets));i.length===e._value.total&&u.resetFacets(),u.search()}else d(`/objects`)}).catch(e=>{c({status:`error`,title:o(`store.actions.errorDeletingObjects`),description:e.message,duration:5e3})}):(c({status:`error`,title:o(`store.actions.noObjectsSelected`),description:o(`store.actions.pleaseSelectObjectsToDelete`),duration:3e3}),Promise.resolve(!1))),[l.store.objects.delete,s.params?.selection?.removeAll,d,i,u,u?.facets,u?.resetFacets,u?.search,o,c]);return n(e,{children:[a,t(g,{isOpen:f,title:m===1?`Delete ${h}`:`Delete ${h}s`,content:n(`div`,{children:[n(`p`,{children:[`Delete `,m,` selected `,h,m===1?``:`s`,`? `,m===1?`This ${h}`:`These ${h}s`,` will be permanently removed.`]}),t(`p`,{children:t(`span`,{className:`text-destructive`,children:`This action cannot be undone.`})})]}),onConfirm:v,onCancel:()=>p(!1),confirmationValue:`delete`,confirmationLabel:`Type "delete" to confirm`,confirmationPlaceholder:`delete`})]})}const wS=rt.getFixedT(null,nt),TS={id:`delete`,name:wS(`store.actions.delete`),description:wS(`store.actions.deleteTheSelectedObjects`),confirm:!0,confirmationText:wS(`store.actions.confirmDeleteAll`),component:CS,destructive:!0},ES={id:`deleteFromCollections`,name:wS(`store.actions.deleteObjects`),description:wS(`store.actions.deleteTheSelectedObjects`),confirm:!0,confirmationText:wS(`store.actions.confirmDeleteSelected`),component:CS,destructive:!0};function DS({action:e,objectIds:n}){let{t:r}=X(),{store:i}=Z(),a=He(),[o,s]=Y(!1),[c,l]=Y(!1),u=G(()=>(s(!0),Promise.resolve(!0)),[]),d=pS(e.id,u);return t(cS,{isExporting:c,isOpen:o,onClose:(e,t)=>{if(e&&(t||n.length>0)){l(!0);let o=d.params?.search?.query||{},c=d.params?.search?.result?.value?.objects?.map(e=>e.id)||void 0,u=async e=>i.objects.list({query:{parent:e}}).then(e=>e.map(e=>e.id)),f=async()=>t?c?o.vector?c:[]:n.length===0?[]:(await u(n[0])).concat(n):n,p=d.params?.type?.id??o.type,m=d.params?.type?.table_layout??void 0;f().then(c=>{i.objects.exportProperties({objectIds:c,type:e,query:t&&!o.vector?{...o,type:p}:{type:p},table_layout:m}).then(e=>{let i=new Blob([e.data],{type:e.type}),o=window.URL.createObjectURL(i),s=document.createElement(`a`);s.download=e.name,s.href=o,s.click(),a({status:`success`,title:r(`store.actions.exportProperties`),description:t?`Export the properties of all objects completed`:`Export the properties of ${n.length} object${n.length>1?`s`:``} is completed`,duration:2e3})}).catch(e=>{a({status:`error`,title:r(`store.actions.errorExportProperties`),description:e.message,duration:5e3})}).finally(()=>{l(!1),s(!1)})})}else s(!1),a({status:`error`,title:r(`store.actions.errorExportProperties`),description:`No objects selected for export`,duration:5e3})}})}const OS=rt.getFixedT(null,nt),kS={id:`exportProperties`,name:OS(`store.actions.exportProperties`),description:OS(`store.actions.exportAllObjectProperties`),confirm:!1,component:DS};function AS({action:e,objectIds:n,collectionId:r}){let{t:i}=X(),a=fS(),o=He(),{client:s}=Z(),c=jv();return t(SS,{action:e,callback:G(()=>n?.length?r?s.store.collections.deleteMembers(r,n).then(()=>{let e=n.length>1?`s`:``;o({status:`success`,title:`${n.length} object${e} removed from collection`,description:`Objects have been removed from the collection`,duration:2e3}),c&&(a.params?.selection?.removeAll(),c.search())}).catch(e=>{o({status:`error`,title:i(`store.actions.errorRemovingObjects`),description:Ne(e),duration:5e3})}):(o({status:`error`,title:i(`store.actions.noCollectionContext`),description:i(`store.actions.cannotRemoveNoCollection`),duration:3e3}),Promise.resolve(!1)):(o({status:`error`,title:i(`store.actions.noObjectsSelected`),description:i(`store.actions.pleaseSelectObjectsToRemove`),duration:3e3}),Promise.resolve(!1)),[s.store.collections.deleteMembers,r,a.params?.selection?.removeAll,n,c,c?.search,i,o])})}const jS=rt.getFixedT(null,nt),MS={id:`removeFromCollection`,name:jS(`store.actions.removeFromCollection`),description:jS(`store.actions.removeFromCollectionDesc`),confirm:!0,confirmationText:jS(`store.actions.confirmRemoveFromCollection`),component:AS,destructive:!0};var NS=class{params;allActions=[];callbacks={};constructor(e){this.params=e}get actions(){return this.params.selection?.collectionId?this.allActions.filter(e=>e.id!==`addToCollection`&&e.id!==`delete`):this.allActions.filter(e=>e.id!==`removeFromCollection`&&e.id!==`deleteFromCollections`)}registerCallback(e,t){return this.callbacks[e]=t,()=>{delete this.callbacks[e]}}unregisterCallback(e){delete this.callbacks[e]}findAction(e){return this.allActions.find(t=>t.id===e)}async run(e){let t=this.findAction(e);if(!t)throw Error(`Action ${e} not found`);let n={...this.params,action:t},r=this.callbacks[e];if(r)return r(n);throw Error(`No action callback set`)}};const PS=[kS,xS,gS,TS,MS,ES];function FS({children:e,type:r}){let i=U_(),a=He(),{client:o}=Z(),s=jv(),c=q(()=>{let e=new NS({selection:i,toast:a,client:o,search:s,type:r});return e.allActions=PS,e},[o,s,i,a,r]);return c&&n(dS.Provider,{value:c,children:[t(IS,{}),e]})}function IS(){let e=fS(),n=e.params.selection,r=n.getObjectId(),i=n.isSingleSelection()&&r?[r]:n.getObjectIds();return t(`div`,{style:{display:`none`},children:e.allActions.map(e=>t(e.component,{action:e,objectIds:i,collectionId:n.collectionId},e.id))})}function LS(){let{t:r}=X(),i=U_(),[a,s]=Y(!1);return i?.hasSelection()?n(e,{children:[t(o,{onClick:()=>s(!0),children:r(`store.actions.startWorkflow`)}),a&&t(RS,{objectIds:i.getObjectIds(),onClose:()=>s(!1)})]}):null}function RS({objectIds:e,onClose:r}){let{t:i}=X(),{client:a}=Z(),s=He(),[c,l]=Y(void 0),[u,d]=Y(!1),{data:f,isLoading:p}=Le(()=>a.store.workflows.rules.list(),[]);return n(B,{isOpen:!0,onClose:r,children:[t(re,{children:i(`store.actions.startWorkflowByRule`)}),n(te,{children:[t(`div`,{className:`pb-2`,children:i(`store.actions.chooseWorkflowRule`)}),p?t(`div`,{className:`flex justify-center py-4`,children:t(be,{})}):t(`div`,{className:`max-h-[420px] overflow-y-auto border-border border rounded-md`,children:t(he,{className:`text-start`,options:f??[],value:c,onChange:l,optionLayout:e=>({label:e.name})})})]}),n(ne,{align:`right`,children:[t(o,{variant:`outline`,onClick:r,disabled:u,children:`Cancel`}),t(o,{onClick:async()=>{if(!(!c||u)){d(!0);try{await a.store.workflows.rules.execute(c.id,e),s({title:i(`store.actions.workflowStarted`),status:`success`,duration:3e3}),r()}catch(e){s({title:i(`store.actions.errorStartingWorkflow`),description:e instanceof Error?e.message:void 0,status:`error`,duration:9e3})}finally{d(!1)}}},isDisabled:!c||u,isLoading:u,children:`Start`})]})]})}function zS({type:e,allowMutations:r=!0,allowDelete:i=!0,allowWorkflowRun:a=!1}){let s=U_(),c=s.size(),l=c>1?`s`:``,u=s?.hasSelection(),d=s?.isSingleSelection();return t(FS,{type:e,children:n(`div`,{className:`flex items-center gap-x-2`,children:[u&&!d&&n(`div`,{className:`flex items-center gap-x-1 shrink-0`,children:[n(`div`,{className:`text-sm nowrap`,children:[c,` document`,l,` selected`]}),t(o,{title:`Clear selection`,variant:`ghost`,onClick:()=>{s?.removeAll()},children:t(nr,{className:`size-4`})})]}),a&&t(LS,{}),t(HS,{selection:s,allowMutations:r,allowDelete:i,children:e=>e.length>0?t(o,{variant:`ghost`,alt:`More action`,size:`sm`,children:t(Bt,{size:16})}):null})]})})}function BS({collectionId:r,allowFolders:i=!0}){let{t:a}=X(),[s,c]=Y([]),[l,u]=Y(!1);return n(e,{children:[t(o,{onClick:()=>u(!0),children:a(`store.upload`)}),t(Bv,{collectionId:r??``,isOpen:l,onClose:()=>{u(!1),c([])},files:s,title:`Upload Files`,onUploadComplete:e=>{e?.success&&c([])},allowFolders:i})]})}function VS(e){return{label:e.name,className:We(`flex-1 px-2 py-2 hover:bg-accent nowrap`,e.destructive?`text-destructive`:``)}}function HS({selection:e,children:r,allowMutations:i=!0,allowDelete:a=!0}){let o=fS(),s=e=>{o.run(e.id)},c=WS(o.actions,e,{allowMutations:i,allowDelete:a}),l=r(c);return l?n(oe,{hover:!0,children:[t(ce,{children:l}),t(se,{className:`p-0 w-50`,align:`end`,sideOffset:6,children:t(US,{executeAction:s,actions:c})})]}):null}function US({executeAction:e,actions:n}){return t(`div`,{className:`rounded-md shadow-md py-2`,children:t(`div`,{className:`px-1 text-sm`,children:t(he,{options:n,optionLayout:VS,onChange:t=>{e(t)},noCheck:!0})})})}function WS(e,t,n){return t?.hasSelection()?e.filter(e=>e.hideInList?!1:e.id===`delete`||e.id===`deleteFromCollections`?n.allowDelete:e.id===`changeType`||e.id===`addToCollection`||e.id===`removeFromCollection`?n.allowMutations:!0):[kS]}function GS({user:e}){return n(`div`,{className:`flex items-center`,children:[t(`div`,{className:`w-9 h-9`,children:e.picture?t(`img`,{className:`inline-block h-9 w-9 rounded-full`,src:e.picture,alt:e.name}):t(`span`,{className:`inline-flex h-8 w-8 items-center justify-center rounded-full bg-indigo-600`,children:t(`span`,{className:`text-sm font-medium leading-none text-white`,children:e.name.split(` `).map(e=>e[0]).join(``)})})}),n(`div`,{className:`ms-3`,children:[t(`p`,{className:`text-sm font-medium text-gray-700 dark:text-slate-50 group-hover:text-gray-900`,children:e.name??`Deleted User`}),t(`p`,{className:`text-xs font-medium text-gray-500 dark:text-slate-300 group-hover:text-gray-700`,children:e.email??`Deleted User`})]})]})}export{Vi as ActivitiesDoc,Ui as ActivityDoc,gS as AddToCollectionAction,mS as AddToCollectionActionComponent,Qi as AgentApprovalModeSelector,Sa as AgentChart,um as AgentChatFixtureReplay,Na as AgentChatPlaybackControls,n_ as AgentRunnerFacetsNav,Nb as AllOf,cu as AnimatedThinkingDots,Mb as AnyOf,Xg as ApiKeyAvatar,Xc as AskUserWidget,Ob as AudioPanel,Tx as BrowseCollectionView,xS as ChangeTypeAction,yS as ChangeTypeActionComponent,jx as CollectionIcon,l_ as CollectionsFacetsNav,Ax as CollectionsTable,Zc as ConfirmationWidget,Xv as ContentDispositionButton,Vx as ContentObjectTypesSearch,Nx as ContentObjectTypesTable,rx as ContentOverview,Ox as CreateCollectionForm,kx as CreateCollectionModal,Px as CreateOrUpdateTypeModal,TS as DeleteObjectsAction,CS as DeleteObjectsActionComponent,ES as DeleteObjectsFromCollectionsAction,Ov as DocumentGridView,Ev as DocumentIcon,Tv as DocumentIconSkeleton,iS as DocumentInput,aS as DocumentPreviewPanel,kv as DocumentSearch,Jv as DocumentSearchProvider,xx as DocumentSearchResults,bx as DocumentSearchResultsWithDropZone,V_ as DocumentSelection,G_ as DocumentSelectionProvider,Uv as DocumentTable,wv as DocumentTableColumn,Dv as DocumentTableView,Bv as DocumentUploadModal,m_ as DocumentsFacetsNav,$x as EditCollectionView,h_ as EnvironmentFacet,kS as ExportPropertiesAction,DS as ExportPropertiesComponent,cS as ExportPropertiesModal,sS as ExportTypes,Iv as FileUploadAction,Jy as GenericPageNavHeader,yg as Header,kb as ImagePanel,v_ as InteractionsFacetsNav,dm as JumpingDots,nd as MESSAGE_STYLES,Sb as MagicPdfView,bm as McpConnectionsActionMenu,vm as McpConnectionsButton,_m as McpConnectionsDialog,ym as McpConnectionsInlineList,id as MessageItem,Iy as MessagesContainer,jy as ModernAgentConversation,Yy as NotFoundView,jb as OAuthProviderConnectButton,Hx as ObjectSchemaEditor,Fx as ObjectTypeSearch,Ix as ObjectTypeSearchContext,qx as ObjectTypeSearchProvider,FS as ObjectsActionContextProvider,By as PanelErrorBoundary,hg as PayloadBuilder,_g as PayloadBuilderProvider,mg as PayloadBuilderStore,gg as PayloadContext,jm as PdfDocumentRenderer,Sm as PdfPageRenderer,Nm as PdfPageSlider,Am as PdfThumbnailList,b_ as ProcessDefinitionsFacetsNav,S_ as ProcessRunsFacetsNav,T_ as PromptsFacetsNav,Wb as PropertiesEditorModal,lu as PulsatingCircle,du as PulsingMessageLoader,_s as RemoteMcpConnectionButton,MS as RemoveFromCollectionAction,AS as RemoveFromCollectionActionComponent,Hy as RowErrorBoundary,k_ as RunsFacetsNav,Ub as SaveVersionConfirmModal,Av as SearchContext,Bb as SecureButton,Vb as SecureSidebarItem,tS as SelectCollection,Dx as SelectContentType,Kx as SelectContentTypeModal,Qv as SelectDocument,nS as SelectDocumentModal,zS as SelectionActions,wm as SharedPdfProvider,Xx as SharedPropsEditor,Dm as SimplePdfPage,Im as SimplePdfViewer,cy as SkillWidgetProvider,od as StreamingMessage,A_ as StringFacet,j_ as StringListFacet,Zx as SyncMemberHeadsToggle,Jx as TableLayoutEditor,fu as ThinkingBar,mu as ThinkingMessages,N_ as TypeFacet,r_ as TypeRegistry,a_ as TypeRegistryProvider,uu as TypedDots,sh as UniversalDocumentViewer,BS as UploadObjectsButton,GS as UserAvatar,Kg as UserInfo,zb as UserPermissionProvider,Fb as UserPermissions,Lb as UserPermissionsContext,Tg as VInteractionFacet,kg as VStringFacet,u_ as VTypeFacet,$g as VUserFacet,va as VegaLiteChart,Ly as VertesiaErrorBoundary,Ab as VideoPanel,Eb as WEB_SUPPORTED_AUDIO_FORMATS,wb as WEB_SUPPORTED_IMAGE_FORMATS,Tb as WEB_SUPPORTED_VIDEO_FORMATS,pu as WavyThinking,Wy as WidgetErrorBoundary,F_ as WorkflowDefinitionsFacetsNav,R_ as WorkflowExecutionsFacetsNav,B_ as WorkflowRulesFacetsNav,Ca as clampPlaybackCursor,hm as countConnectedActiveGroups,t_ as createAgentRunnerFilterHandler,Da as createPlaybackState,Cg as filterValueToQueryValue,Db as formatDuration,gm as getConnectedActiveGroupLabels,Ea as getNextUserTurnIndex,wa as getPlaybackCursorIndex,Ta as getPreviousUserTurnIndex,pv as getWorkflowStatusColor,mv as getWorkflowStatusName,ka as isAgentChatPlaybackAvailable,Aa as isAgentChatPlaybackEnabled,Pb as isAnyOf,nv as isCsv,pm as isGroupDisabled,rv as isImage,ja as isLocalhostAgentChatPlaybackAvailable,Ma as isLocalhostAgentChatPlaybackEnabled,iv as isPdf,ov as isPreviewableAsPdf,ba as isRechartsSpec,ya as isVegaLiteSpec,av as isVideo,sv as printElementToPdf,uv as retrieveRendition,zy as setErrorBoundaryComponent,wg as setSearchQueryValue,dv as shortId,fv as shortenString,Yx as stringifyTableLayout,mm as toggleGroupDisabled,Sg as unwrapFilterOptionValue,e_ as useAgentRunnerFilterGroups,s_ as useCollectionsFilterGroups,c_ as useCollectionsFilterHandler,f_ as useDocumentFilterGroups,p_ as useDocumentFilterHandler,jv as useDocumentSearch,Pv as useDocumentSearchCount,U_ as useDocumentSelection,Vv as useDocumentUploadHandler,Vu as useDownloadFile,Lg as useFetchApiKeyInfo,Ig as useFetchGroupInfo,Fg as useFetchUserInfo,g_ as useInteractionsFilterGroups,__ as useInteractionsFilterHandler,fm as useMcpConnections,gs as useOAuthPopup,W_ as useOptionalDocumentSelection,vg as usePayloadBuilder,y_ as useProcessDefinitionsFilterGroups,x_ as useProcessRunsFilterGroups,C_ as usePromptsFilterGroups,w_ as usePromptsFilterHandler,D_ as useRunsFilterGroups,O_ as useRunsFilterHandler,Lx as useSearch,zx as useSearchCount,Tm as useSharedPdf,zv as useSmartFileUploadProcessing,o_ as useTypeRegistry,Rb as useUserPermissions,Mv as useWatchDocumentSearchFacets,Nv as useWatchDocumentSearchResult,Rx as useWatchSearchResult,P_ as useWorkflowDefinitionsFilterGroups,I_ as useWorkflowExecutionsFilterGroups,L_ as useWorkflowExecutionsFilterHandler,z_ as useWorkflowRulesFilterGroups};
|
|
460
|
+
*`)),D=l?.content?.type?.startsWith(`image/`),O=l?.content?.type===`application/pdf`;return r?n(`div`,{className:`fixed inset-y-0 end-0 w-2/5 dark:bg-slate-900 shadow-xl z-50 flex flex-col transition-transform duration-300 transform ${r?`translate-x-0`:`translate-x-full rtl:-translate-x-full`}`,children:[n(`div`,{className:`flex items-center justify-between px-4 py-3 border-b dark:border-gray-700 bg-gradient-to-r from-indigo-50 to-gray-50 dark:from-gray-800 dark:to-gray-900`,children:[n(`div`,{className:`flex items-center`,children:[t(on,{className:`h-5 w-5 text-indigo-600 me-2`}),t(`h2`,{className:`text-lg font-semibold text-gray-800 dark:text-gray-200 truncate`,children:d?x(`store.loadingDocument`):l?.name||x(`store.documentPreview`)})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{variant:`ghost`,size:`sm`,onClick:T,className:`flex items-center gap-1 text-indigo-600 hover:text-indigo-800`,children:[t(An,{className:`h-4 w-4`}),t(`span`,{children:x(`store.fullView`)})]}),t(o,{variant:`ghost`,size:`sm`,onClick:i,className:`flex items-center text-gray-600 hover:text-gray-800 dark:text-gray-300 dark:hover:text-gray-100`,children:t(yr,{className:`h-5 w-5`})})]})]}),d?t(`div`,{className:`flex-1 flex items-center justify-center`,children:n(`div`,{className:`text-center`,children:[t(Ee,{size:`lg`,className:`text-indigo-600 dark:text-indigo-400 mb-2`}),t(`p`,{className:`text-gray-600 dark:text-gray-400`,children:x(`store.loadingDocument`)})]})}):n(`div`,{className:`flex-1 flex flex-col h-full`,children:[t(`div`,{className:`border-b`,children:n(`div`,{className:`flex px-4`,children:[t(o,{variant:`unstyled`,className:`py-2 px-4 font-medium border-b-2 ${y===`preview`?`border-indigo-600 text-indigo-700 dark:text-indigo-300`:`border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`}`,onClick:()=>b(`preview`),children:n(`div`,{className:`flex items-center gap-1`,children:[t(Sn,{className:`h-4 w-4`}),t(`span`,{children:x(`store.preview`)})]})}),t(o,{variant:`unstyled`,className:`py-2 px-4 font-medium border-b-2 ${y===`properties`?`border-indigo-600 text-indigo-700 dark:text-indigo-300`:`border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`}`,onClick:()=>b(`properties`),children:n(`div`,{className:`flex items-center gap-1`,children:[t(yn,{className:`h-4 w-4`}),t(`span`,{children:x(`store.properties`)})]})})]})}),n(`div`,{className:`flex-1 overflow-auto p-4`,children:[y===`preview`&&n(`div`,{className:`h-full`,children:[p?t(`div`,{className:`flex items-center justify-center h-40`,children:t(Ee,{size:`md`,className:`text-indigo-600 dark:text-indigo-400`})}):h?t(`div`,{className:`shadow rounded-md p-4 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800`,children:E?t(`div`,{className:`prose prose-sm max-w-none prose-p:my-2 prose-pre:bg-gray-800 prose-pre:my-2 prose-headings:text-indigo-700 dark:prose-invert dark:prose-headings:text-indigo-300`,children:t(Li,{children:h})}):t(`pre`,{className:`text-wrap whitespace-pre-wrap dark:text-gray-200`,children:h})}):null,D&&t(`div`,{className:`mt-4`,children:_?t(`div`,{className:`border border-gray-200 dark:border-gray-700 rounded-md p-2 bg-white dark:bg-gray-800`,children:t(`img`,{src:_,alt:l?.name,className:`mx-auto max-h-[70vh] object-contain`})}):t(`div`,{className:`flex items-center justify-center h-40`,children:t(Ee,{size:`md`,className:`text-indigo-600 dark:text-indigo-400`})})}),O&&n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-gray-200 dark:border-gray-700 rounded-md p-4 bg-gray-50 dark:bg-gray-800`,children:[t(on,{className:`h-16 w-16 text-indigo-300 dark:text-indigo-400 mb-4`}),t(`p`,{className:`text-gray-600 dark:text-gray-400 text-center mb-4`,children:x(`store.pdfPreviewFullView`)}),t(o,{onClick:T,className:`bg-indigo-600 hover:bg-indigo-700 text-white`,children:x(`store.openFullDocumentView`)})]}),!D&&!h&&!O&&!p&&n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-gray-200 dark:border-gray-700 rounded-md p-4 bg-gray-50 dark:bg-gray-800`,children:[t(on,{className:`h-16 w-16 text-gray-300 dark:text-gray-600 mb-4`}),t(`p`,{className:`text-gray-600 dark:text-gray-400 text-center`,children:x(`store.noPreviewAvailable`)})]})]}),y===`properties`&&l&&n(`div`,{className:`h-full`,children:[l.properties?t(`div`,{className:`shadow rounded-md p-4 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800`,children:t(Fi,{value:l.properties})}):n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-gray-200 dark:border-gray-700 rounded-md p-4 bg-gray-50 dark:bg-gray-800`,children:[t(yn,{className:`h-16 w-16 text-gray-300 dark:text-gray-600 mb-4`}),t(`p`,{className:`text-gray-600 dark:text-gray-400 text-center`,children:x(`store.noPropertiesAvailable`)})]}),n(`div`,{className:`mt-4`,children:[t(`h3`,{className:`text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2`,children:x(`store.documentInformation`)}),t(`div`,{className:`shadow rounded-md p-4 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800`,children:n(`div`,{className:`grid grid-cols-2 gap-y-2 gap-x-4 text-sm`,children:[t(`div`,{className:`text-gray-500 dark:text-gray-400`,children:x(`store.id`)}),t(`div`,{className:`font-medium dark:text-gray-200`,children:l.id}),t(`div`,{className:`text-gray-500 dark:text-gray-400`,children:x(`store.contentType`)}),t(`div`,{className:`font-medium dark:text-gray-200`,children:l.type?.name||x(`store.unknown`)}),t(`div`,{className:`text-gray-500 dark:text-gray-400`,children:x(`store.contentType`)}),t(`div`,{className:`font-medium dark:text-gray-200`,children:l.content?.type||x(`store.na`)}),t(`div`,{className:`text-gray-500`,children:x(`store.size`)}),t(`div`,{className:`font-medium`,children:l.content&&`size`in l.content?DC(l.content.size):x(`store.unknown`)}),t(`div`,{className:`text-gray-500`,children:x(`store.created`)}),t(`div`,{className:`font-medium`,children:l.created_at?new Date(l.created_at).toLocaleString():x(`store.na`)}),t(`div`,{className:`text-gray-500`,children:x(`store.updated`)}),t(`div`,{className:`font-medium`,children:l.updated_at?new Date(l.updated_at).toLocaleString():x(`store.na`)})]})})]})]})]})]}),n(`div`,{className:`flex items-center justify-between p-4 border-t bg-gray-50 dark:bg-gray-800 dark:border-gray-700`,children:[t(`div`,{children:l?.content?.source&&n(o,{onClick:()=>{l?.content?.source&&s.files.getDownloadUrl(l.content.source).then(e=>{window.open(e.url,`_blank`)}).catch(e=>{console.error(`Error getting download URL:`,e),S({title:x(`agent.error`),description:x(`store.failedToDownloadFile`),status:`error`,duration:3e3})})},variant:`outline`,className:`text-indigo-600 border-indigo-300 hover:bg-indigo-50`,children:[t(qt,{className:`h-4 w-4 me-2`}),x(`pdf.download`)]})}),n(o,{onClick:T,className:`bg-indigo-600 hover:bg-indigo-700 text-white`,children:[x(`store.openFullDocument`),t(jt,{className:`h-4 w-4 ms-2 cn-rtl-flip`})]})]})]}):null}function DC(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`}var OC;(function(e){e.CSV=`CSV`,e.JSON=`JSON`})(OC||={});function kC({isExporting:e,isOpen:r,onClose:i}){return n(ie,{onClose:()=>i(void 0),isOpen:r,children:[t(se,{children:`Export Object Properties`}),n(ae,{children:[!e&&t(AC,{onClose:i}),e&&t(jC,{})]})]})}function AC({onClose:e}){let{t:r}=X(),[i,a]=Y(void 0),[s,c]=Y(void 0),l=[`Export selected objects`,`Export all objects`],u=e=>e===l[1];return n(ae,{className:`min-h-[104px] pt-0 flex flex-col gap-y-4`,children:[t(`div`,{className:`h-1/3`,children:t(ye,{options:l,value:s,onChange:c,placeholder:r(`store.chooseWhatToExport`),className:`h-full w-full text-sm`,filterBy:`name`,isClearable:!0})}),n(`div`,{className:`h-1/2 flex flex-col gap-y-8 content-between`,children:[t(ye,{options:Object.values(OC),value:i,onChange:a,placeholder:r(`store.chooseAFormat`),className:`h-full w-full text-sm`,filterBy:`name`,isClearable:!0}),t(o,{className:`w-full`,isDisabled:!i||!s,onClick:()=>{e(i,u(s))},children:r(`store.actions.exportProperties`)})]})]})}function jC(){let{t:e}=X();return t(ae,{className:`min-h-[84px] pt-0`,children:n(`div`,{className:`h-full grid flex-col gap-y-2 content-between justify-items-center`,children:[n(`div`,{className:`text-sm flex flex-col gap-x-2`,children:[t(`p`,{children:e(`store.exportInProgress`)}),t(`p`,{className:`pt-2 grid justify-items-center`,children:e(`store.pleaseWait`)})]}),t(Ee,{size:`lg`})]})})}const MC=nt(void 0);function NC(){let e=at(MC);if(!e)throw Error(`You cannot use useActionContext outside an ActionProvider`);return e}function PC(e,t){let n=NC();return K(()=>n.registerCallback(e,t),[n,e,t]),n}function FC({action:e,objectIds:n}){let[r,i]=Y(!1),a=G(()=>(n.length>0&&i(!0),Promise.resolve(!0)),[n]);return PC(e.id,a),r&&t(pe,{children:t(RC,{objectIds:n,isOpen:r,onClose:()=>{i(!1)}})})}const IC=ut.getFixedT(null,lt),LC={id:`addToCollection`,name:IC(`store.actions.addToCollection`),description:IC(`store.actions.addToCollectionDesc`),confirm:!1,component:FC};function RC({isOpen:e,onClose:r,objectIds:i}){let{t:a}=X();return n(ie,{isOpen:e,onClose:r,className:`max-w-lg w-full min-w-0 overflow-hidden`,children:[t(se,{className:`flex flex-col min-w-0 overflow-hidden`,children:a(`store.actions.addToCollectionTitle`)}),t(S,{className:`min-w-0 overflow-hidden`,children:a(`store.actions.addToCollectionBody`)}),t(`div`,{className:`min-w-0 max-w-full overflow-hidden`,children:t(zC,{onClose:r,objectIds:i})})]})}function zC({onClose:e,objectIds:r}){let{t:i}=X(),a=Ye(),{client:s}=Z(),[c,l]=Y(),u=({collectionId:t})=>{!t||!r?.length||s.store.collections.addMembers(t,r).then(()=>{a({title:i(`store.actions.addToCollectionSuccess`),status:`success`,description:i(`store.actions.addToCollectionSuccessDesc`,{count:r.length}),duration:3e3}),e()}).catch(()=>{a({title:i(`store.actions.addToCollectionFailure`),status:`error`,description:i(`store.actions.addToCollectionFailureDesc`),duration:5e3})})};return n(Pe,{defaultValue:`select`,tabs:[{name:`select`,label:i(`store.actions.selectCollection`),content:n(`div`,{className:`p-4 min-w-0 max-w-full overflow-hidden`,children:[t(R,{level:5,children:i(`store.actions.chooseExistingCollections`)}),t(ae,{className:`min-w-0 max-w-full overflow-hidden`,children:t(`div`,{className:`mb-4 min-w-0 max-w-full overflow-hidden`,children:t(SC,{onChange:(e,t)=>{typeof e==`string`||e===void 0?l(e):Array.isArray(e)&&e.length>0?l(e[0]):l(void 0)},value:c})})}),t(oe,{children:t(o,{isDisabled:!c,onClick:()=>c&&u({collectionId:c}),children:i(`store.actions.addToCollectionButton`)})})]})},{name:`create`,label:i(`store.actions.createNew`),content:t(`div`,{className:`p-4`,children:t(_S,{onClose:e,onAddToCollection:e=>u({collectionId:e}),redirect:!1})})}],fullWidth:!0,children:[t(Fe,{}),t(Ie,{})]})}function BC({action:e,objectIds:r,children:i}){let{t:a}=X(),{store:o}=Z(),s=Ye(),[c,l]=Y(!1),u=G(()=>(l(!0),Promise.resolve(!0)),[]);return PC(e.id,u),n(`div`,{children:[i,t(pC,{isOpen:c,onClose:e=>{l(!1),e!==void 0&&o.runOperation({name:`change_type`,ids:r,params:{typeId:e}}).then(e=>{s({status:`success`,title:a(`store.actions.changeType`),description:`Change the type of ${r.length} objects is ${e.status===`in_progress`?`in progress`:`completed`}`,duration:2e3})}).catch(e=>{s({status:`error`,title:a(`store.actions.errorChangingType`),description:e.message,duration:5e3})})},title:`Change Content Type`,confirmLabel:`Change Type`,children:n(`p`,{className:`pt-2 text-xs`,children:[`Note: This action will raise the `,t(`code`,{children:`change_type`}),` event and will trigger the standard intake workflows which may reset the object properties.`]})})]})}const VC=ut.getFixedT(null,lt),HC={id:`changeType`,name:VC(`store.actions.changeContentType`),description:VC(`store.actions.changeContentTypeDesc`),confirm:!1,component:BC};function UC({action:r,callback:i,children:a}){let{t:o}=X(),[s,c]=Y(!1),l=r.confirmationText||`Are you sure you want to ${r.name}?`,u=G(e=>r.confirm?(c(!0),Promise.resolve(!0)):i(e),[r.confirm,i]),d=PC(r.id,u);return n(e,{children:[a,t(b,{onConfirm:()=>{c(!1),i({...d.params,action:r})},onCancel:()=>c(!1),title:o(`store.actions.areYouSure`),content:l,isOpen:s})]})}function WC({action:r,objectIds:i,children:a}){let{t:o}=X(),s=NC(),c=Ye(),{client:l}=Z(),u=gv(),d=Di(),[f,p]=Y(!1),m=i?.length??0,h=s.params?.type?.name??`object`,g=G(()=>(p(!0),Promise.resolve(!0)),[]);PC(r.id,g);let _=G(()=>(p(!1),i?.length?l.store.objects.delete(i).then(e=>{let t=e.deleted>1?`s`:``;if(c({status:`success`,title:`${e.deleted} object${t} deleted`,duration:2e3}),e.failed.length>0&&c({status:`warning`,title:`${e.failed.length} object(s) could not be deleted`,duration:3e3}),u){s.params?.selection?.removeAll();let e=JSON.parse(JSON.stringify(u.facets));i.length===e._value.total&&u.resetFacets(),u.search()}else d(`/objects`)}).catch(e=>{c({status:`error`,title:o(`store.actions.errorDeletingObjects`),description:e.message,duration:5e3})}):(c({status:`error`,title:o(`store.actions.noObjectsSelected`),description:o(`store.actions.pleaseSelectObjectsToDelete`),duration:3e3}),Promise.resolve(!1))),[l.store.objects.delete,s.params?.selection?.removeAll,d,i,u,u?.facets,u?.resetFacets,u?.search,o,c]);return n(e,{children:[a,t(b,{isOpen:f,title:m===1?`Delete ${h}`:`Delete ${h}s`,content:n(`div`,{children:[n(`p`,{children:[`Delete `,m,` selected `,h,m===1?``:`s`,`? `,m===1?`This ${h}`:`These ${h}s`,` will be permanently removed.`]}),t(`p`,{children:t(`span`,{className:`text-destructive`,children:`This action cannot be undone.`})})]}),onConfirm:_,onCancel:()=>p(!1),confirmationValue:`delete`,confirmationLabel:`Type "delete" to confirm`,confirmationPlaceholder:`delete`})]})}const GC=ut.getFixedT(null,lt),KC={id:`delete`,name:GC(`store.actions.delete`),description:GC(`store.actions.deleteTheSelectedObjects`),confirm:!0,confirmationText:GC(`store.actions.confirmDeleteAll`),component:WC,destructive:!0},qC={id:`deleteFromCollections`,name:GC(`store.actions.deleteObjects`),description:GC(`store.actions.deleteTheSelectedObjects`),confirm:!0,confirmationText:GC(`store.actions.confirmDeleteSelected`),component:WC,destructive:!0};function JC({action:e,objectIds:n}){let{t:r}=X(),{store:i}=Z(),a=Ye(),[o,s]=Y(!1),[c,l]=Y(!1),u=G(()=>(s(!0),Promise.resolve(!0)),[]),d=PC(e.id,u);return t(kC,{isExporting:c,isOpen:o,onClose:(e,t)=>{if(e&&(t||n.length>0)){l(!0);let o=d.params?.search?.query||{},c=d.params?.search?.result?.value?.objects?.map(e=>e.id)||void 0,u=async e=>i.objects.list({query:{parent:e}}).then(e=>e.map(e=>e.id)),f=async()=>t?c?o.vector?c:[]:n.length===0?[]:(await u(n[0])).concat(n):n,p=d.params?.type?.id??o.type,m=d.params?.type?.table_layout??void 0;f().then(c=>{i.objects.exportProperties({objectIds:c,type:e,query:t&&!o.vector?{...o,type:p}:{type:p},table_layout:m}).then(e=>{let i=new Blob([e.data],{type:e.type}),o=window.URL.createObjectURL(i),s=document.createElement(`a`);s.download=e.name,s.href=o,s.click(),a({status:`success`,title:r(`store.actions.exportProperties`),description:t?`Export the properties of all objects completed`:`Export the properties of ${n.length} object${n.length>1?`s`:``} is completed`,duration:2e3})}).catch(e=>{a({status:`error`,title:r(`store.actions.errorExportProperties`),description:e.message,duration:5e3})}).finally(()=>{l(!1),s(!1)})})}else s(!1),a({status:`error`,title:r(`store.actions.errorExportProperties`),description:`No objects selected for export`,duration:5e3})}})}const YC=ut.getFixedT(null,lt),XC={id:`exportProperties`,name:YC(`store.actions.exportProperties`),description:YC(`store.actions.exportAllObjectProperties`),confirm:!1,component:JC};function ZC({action:e,objectIds:n,collectionId:r}){let{t:i}=X(),a=NC(),o=Ye(),{client:s}=Z(),c=gv();return t(UC,{action:e,callback:G(()=>n?.length?r?s.store.collections.deleteMembers(r,n).then(()=>{let e=n.length>1?`s`:``;o({status:`success`,title:`${n.length} object${e} removed from collection`,description:`Objects have been removed from the collection`,duration:2e3}),c&&(a.params?.selection?.removeAll(),c.search())}).catch(e=>{o({status:`error`,title:i(`store.actions.errorRemovingObjects`),description:H(e),duration:5e3})}):(o({status:`error`,title:i(`store.actions.noCollectionContext`),description:i(`store.actions.cannotRemoveNoCollection`),duration:3e3}),Promise.resolve(!1)):(o({status:`error`,title:i(`store.actions.noObjectsSelected`),description:i(`store.actions.pleaseSelectObjectsToRemove`),duration:3e3}),Promise.resolve(!1)),[s.store.collections.deleteMembers,r,a.params?.selection?.removeAll,n,c,c?.search,i,o])})}const QC=ut.getFixedT(null,lt),$C={id:`removeFromCollection`,name:QC(`store.actions.removeFromCollection`),description:QC(`store.actions.removeFromCollectionDesc`),confirm:!0,confirmationText:QC(`store.actions.confirmRemoveFromCollection`),component:ZC,destructive:!0};var ew=class{params;allActions=[];callbacks={};constructor(e){this.params=e}get actions(){return this.params.selection?.collectionId?this.allActions.filter(e=>e.id!==`addToCollection`&&e.id!==`delete`):this.allActions.filter(e=>e.id!==`removeFromCollection`&&e.id!==`deleteFromCollections`)}registerCallback(e,t){return this.callbacks[e]=t,()=>{delete this.callbacks[e]}}unregisterCallback(e){delete this.callbacks[e]}findAction(e){return this.allActions.find(t=>t.id===e)}async run(e){let t=this.findAction(e);if(!t)throw Error(`Action ${e} not found`);let n={...this.params,action:t},r=this.callbacks[e];if(r)return r(n);throw Error(`No action callback set`)}};const tw=[XC,HC,LC,KC,$C,qC];function nw({children:e,type:r}){let i=O_(),a=Ye(),{client:o}=Z(),s=gv(),c=q(()=>{let e=new ew({selection:i,toast:a,client:o,search:s,type:r});return e.allActions=tw,e},[o,s,i,a,r]);return c&&n(MC.Provider,{value:c,children:[t(rw,{}),e]})}function rw(){let e=NC(),n=e.params.selection,r=n.getObjectId(),i=n.isSingleSelection()&&r?[r]:n.getObjectIds();return t(`div`,{style:{display:`none`},children:e.allActions.map(e=>t(e.component,{action:e,objectIds:i,collectionId:n.collectionId},e.id))})}function iw(){let{t:r}=X(),i=O_(),[a,s]=Y(!1);return i?.hasSelection()?n(e,{children:[t(o,{onClick:()=>s(!0),children:r(`store.actions.startWorkflow`)}),a&&t(aw,{objectIds:i.getObjectIds(),onClose:()=>s(!1)})]}):null}function aw({objectIds:e,onClose:r}){let{t:i}=X(),{client:a}=Z(),s=Ye(),[c,l]=Y(void 0),[u,d]=Y(!1),{data:f,isLoading:p}=Ue(()=>a.store.workflows.rules.list(),[]);return n(ie,{isOpen:!0,onClose:r,children:[t(se,{children:i(`store.actions.startWorkflowByRule`)}),n(ae,{children:[t(`div`,{className:`pb-2`,children:i(`store.actions.chooseWorkflowRule`)}),p?t(`div`,{className:`flex justify-center py-4`,children:t(Ee,{})}):t(`div`,{className:`max-h-[420px] overflow-y-auto border-border border rounded-md`,children:t(be,{className:`text-start`,options:f??[],value:c,onChange:l,optionLayout:e=>({label:e.name})})})]}),n(oe,{align:`right`,children:[t(o,{variant:`outline`,onClick:r,disabled:u,children:`Cancel`}),t(o,{onClick:async()=>{if(!(!c||u)){d(!0);try{await a.store.workflows.rules.execute(c.id,e),s({title:i(`store.actions.workflowStarted`),status:`success`,duration:3e3}),r()}catch(e){s({title:i(`store.actions.errorStartingWorkflow`),description:e instanceof Error?e.message:void 0,status:`error`,duration:9e3})}finally{d(!1)}}},isDisabled:!c||u,isLoading:u,children:`Start`})]})]})}function ow({type:e,allowMutations:r=!0,allowDelete:i=!0,allowWorkflowRun:a=!1}){let s=O_(),c=s.size(),l=c>1?`s`:``,u=s?.hasSelection(),d=s?.isSingleSelection();return t(nw,{type:e,children:n(`div`,{className:`flex items-center gap-x-2`,children:[u&&!d&&n(`div`,{className:`flex items-center gap-x-1 shrink-0`,children:[n(`div`,{className:`text-sm nowrap`,children:[c,` document`,l,` selected`]}),t(o,{title:`Clear selection`,variant:`ghost`,onClick:()=>{s?.removeAll()},children:t(yr,{className:`size-4`})})]}),a&&t(iw,{}),t(lw,{selection:s,allowMutations:r,allowDelete:i,children:e=>e.length>0?t(o,{variant:`ghost`,title:`More action`,size:`sm`,children:t(Xt,{size:16})}):null})]})})}function sw({collectionId:r,allowFolders:i=!0}){let{t:a}=X(),[s,c]=Y([]),[l,u]=Y(!1);return n(e,{children:[t(o,{onClick:()=>u(!0),children:a(`store.upload`)}),t(Tv,{collectionId:r??``,isOpen:l,onClose:()=>{u(!1),c([])},files:s,title:`Upload Files`,onUploadComplete:e=>{e?.success&&c([])},allowFolders:i})]})}function cw(e){return{label:e.name,className:Ze(`flex-1 px-2 py-2 hover:bg-accent nowrap`,e.destructive?`text-destructive`:``)}}function lw({selection:e,children:r,allowMutations:i=!0,allowDelete:a=!0}){let o=NC(),s=e=>{o.run(e.id)},c=dw(o.actions,e,{allowMutations:i,allowDelete:a}),l=r(c);return l?n(ue,{hover:!0,children:[t(fe,{children:l}),t(de,{className:`p-0 w-50`,align:`end`,sideOffset:6,children:t(uw,{executeAction:s,actions:c})})]}):null}function uw({executeAction:e,actions:n}){return t(`div`,{className:`rounded-md shadow-md py-2`,children:t(`div`,{className:`px-1 text-sm`,children:t(be,{options:n,optionLayout:cw,onChange:t=>{e(t)},noCheck:!0})})})}function dw(e,t,n){return t?.hasSelection()?e.filter(e=>e.hideInList?!1:e.id===`delete`||e.id===`deleteFromCollections`?n.allowDelete:e.id===`changeType`||e.id===`addToCollection`||e.id===`removeFromCollection`?n.allowMutations:!0):[XC]}function fw({user:e}){return n(`div`,{className:`flex items-center`,children:[t(`div`,{className:`w-9 h-9`,children:e.picture?t(`img`,{className:`inline-block h-9 w-9 rounded-full`,src:e.picture,alt:e.name}):t(`span`,{className:`inline-flex h-8 w-8 items-center justify-center rounded-full bg-indigo-600`,children:t(`span`,{className:`text-sm font-medium leading-none text-white`,children:e.name.split(` `).map(e=>e[0]).join(``)})})}),n(`div`,{className:`ms-3`,children:[t(`p`,{className:`text-sm font-medium text-gray-700 dark:text-slate-50 group-hover:text-gray-900`,children:e.name??`Deleted User`}),t(`p`,{className:`text-xs font-medium text-gray-500 dark:text-slate-300 group-hover:text-gray-700`,children:e.email??`Deleted User`})]})]})}function pw(e,t,n,r){return n?r===!1?[t]:e.includes(t)?e:[...e,t]:e.filter(e=>e!==t)}function mw({node:e}){return n(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-2`,children:[t(`span`,{className:`truncate`,children:e.label}),t(`span`,{className:`text-xs tabular-nums text-muted`,children:e.count})]})}function hw({configuration:e,result:r,isLoading:i,onChange:a}){let{t:s}=X(),c=ot(),l=e.presentation??(e.source===`location`||e.source===`hierarchy`?`tree`:`list`),u=e.source!==`hierarchy`&&e.multi_select,d=r.breadcrumbs??[],f=(e,t)=>{a(pw(r.selected,e,t,u))};return n(`section`,{className:`space-y-2`,"aria-labelledby":`${c}-label`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`h2`,{id:`${c}-label`,className:`text-sm font-semibold`,children:e.label}),r.selected.length>0&&n(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a([]),"aria-label":`${s(`filter.clearAll`)}: ${e.label}`,children:[t(yr,{className:`size-3.5`}),s(`filter.clearAll`)]})]}),e.source===`hierarchy`&&d.length>0&&t(`nav`,{"aria-label":`${e.label} path`,children:t(`ol`,{className:`flex flex-wrap items-center gap-1 text-sm`,children:d.map((e,r)=>n(`li`,{className:`flex items-center gap-1`,children:[r>0&&t(jt,{"aria-hidden":`true`,className:`size-3.5 text-muted`}),t(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a([e.id]),"aria-current":r===d.length-1?`page`:void 0,children:e.label})]},e.id))})}),r.selected.length>0&&(e.source===`location`||e.source===`collection`)&&t(`div`,{className:`flex flex-wrap gap-1`,children:r.selected.map(e=>{let a=r.nodes.find(t=>t.id===e)?.label??e;return n(o,{type:`button`,variant:`secondary`,size:`sm`,disabled:i,onClick:()=>f(e,!1),"aria-label":s(`view.removeSelection`,{value:a}),children:[a,t(yr,{"aria-hidden":`true`,className:`size-3.5`})]},e)})}),l===`select`&&u===!1?t(ye,{options:r.nodes,value:r.nodes.find(e=>r.selected.includes(e.id)),onChange:e=>a([e.id]),optionLabel:e=>`${e.label} (${e.count})`,by:`id`,disabled:i,placeholder:e.label,"aria-label":e.label}):l===`select`?t(ye,{multiple:!0,options:r.nodes,value:r.nodes.filter(e=>r.selected.includes(e.id)),onChange:e=>a(e.map(e=>e.id)),optionLabel:e=>`${e.label} (${e.count})`,by:`id`,disabled:i,placeholder:e.label,"aria-label":e.label}):l===`chips`?t(`div`,{className:`flex flex-wrap gap-2`,children:r.nodes.map(e=>n(o,{type:`button`,variant:r.selected.includes(e.id)?`secondary`:`outline`,size:`sm`,disabled:i,onClick:()=>f(e.id,!r.selected.includes(e.id)),children:[e.label,t(`span`,{className:`text-xs tabular-nums text-muted`,children:e.count})]},e.id))}):e.source===`hierarchy`?t(`div`,{className:`space-y-1`,children:r.nodes.map(e=>n(o,{type:`button`,variant:r.selected.includes(e.id)?`secondary`:`ghost`,className:`w-full justify-start`,disabled:i,onClick:()=>a([e.id]),children:[t(mw,{node:e}),e.expandable&&t(jt,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted`})]},e.id))}):t(`div`,{className:`space-y-1`,children:r.nodes.map((e,a)=>{let o=`${c}-${a}`;return n(`div`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-muted`,children:[t(m,{id:o,checked:r.selected.includes(e.id),disabled:i,onCheckedChange:t=>f(e.id,t===!0)}),t(`label`,{htmlFor:o,className:`flex min-w-0 flex-1 cursor-pointer text-sm`,children:t(mw,{node:e})})]},e.id)})}),r.nodes.length===0&&t(`p`,{className:`text-sm text-muted`,children:s(`filter.noAvailableFilters`)})]})}const gw=`display`,_w=`sort`,vw=`offset`;function yw(e){if(e===null||e.trim()===``)return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:void 0}function bw(e,t){let n={};for(let r of new Set(e.keys())){if(!r.startsWith(t)||r.length===t.length)continue;let i=e.getAll(r).filter(e=>e!==``);i.length>0&&(n[r.slice(t.length)]=i)}return Object.keys(n).length>0?n:void 0}function xw(e){let t=new URLSearchParams(e.startsWith(`?`)?e.slice(1):e),n=t.get(`q`)?.trim(),r=t.get(gw)?.trim(),i=t.get(_w)?.trim(),a=yw(t.get(vw)),o=bw(t,`t.`),s=bw(t,`n.`);return{...n?{query:n}:{},...o?{key_terms:o}:{},...s?{navigation:s}:{},...r?{display:r}:{},...i?{sort:i}:{},...a?{offset:a}:{}}}function Sw(e){for(let t of[...e.keys()])(t===`q`||t===gw||t===_w||t===vw||t.startsWith(`t.`)||t.startsWith(`n.`))&&e.delete(t)}function Cw(e,t,n){if(n)for(let[r,i]of Object.entries(n).sort(([e],[t])=>e.localeCompare(t)))for(let n of i)n!==``&&e.append(`${t}${r}`,n)}function ww(e,t=``){let n=new URLSearchParams(t.startsWith(`?`)?t.slice(1):t);Sw(n),e.query?.trim()&&n.set(`q`,e.query.trim()),e.display&&n.set(gw,e.display),e.sort&&n.set(_w,e.sort),e.offset&&e.offset>0&&n.set(vw,String(e.offset)),Cw(n,`t.`,e.key_terms),Cw(n,`n.`,e.navigation);let r=n.toString();return r?`?${r}`:``}function Tw(e){let t=Object.fromEntries(Object.entries(e.navigation).filter(([,e])=>e.selected.length>0).map(([e,t])=>[e,t.selected]));return Object.keys(t).length>0?t:void 0}function Ew(e,t){let n=new Set(t.definition.search?.key_terms?.map(e=>e.id)??[]),r=e.key_terms?Object.fromEntries(Object.entries(e.key_terms).filter(([e,t])=>n.has(e)&&t.length)):void 0,i=Tw(t);return{...e.query?.trim()?{query:e.query.trim()}:{},...r&&Object.keys(r).length>0?{key_terms:r}:{},...i?{navigation:i}:{},...t.display?{display:t.display}:{},...t.sort?{sort:t.sort}:{},...e.offset&&e.offset>0?{offset:e.offset}:{},...e.limit?{limit:e.limit}:{}}}function Dw(e,t,n){return t.sort??e.sort??(e.query?.trim()?void 0:n)}function Ow(e){if(typeof window>`u`)return;let t=ww(e,window.location.search);window.history.replaceState(window.history.state||{},``,`${window.location.pathname}${t}`)}function kw(e,t){return!t||t===`.`?e:t.split(`.`).reduce((e,t)=>{if(!(!e||typeof e!=`object`||Array.isArray(e)))return e[t]},e)}function Aw(e,t){return t===`score`?e.score:t.startsWith(`annotation.`)?kw(e.annotation,t.slice(11)):t.startsWith(`document.`)?kw(e.document,t.slice(9)):kw(e.document,t)}const jw=nt(void 0);function Mw(e){if(!(e==null||e===``))return Array.isArray(e)?e.map(Mw).filter(Boolean).join(`, `):typeof e==`object`?JSON.stringify(e):String(e)}function Nw(e,t,n){let r=Aw(e,t.field),i=t.fallback??``;if(r==null||r===``)return i;if(t.format===`date`){let e=String(r),t=/^\d{4}-\d{2}-\d{2}$/.test(e),a=new Date(e);if(Number.isNaN(a.getTime()))return Mw(r)??i;let o={year:`numeric`,month:`numeric`,day:`numeric`,...t?{timeZone:`UTC`}:{}};return n?.formatDate(a,o)??new Intl.DateTimeFormat(void 0,o).format(a)}if(t.format===`number`){let e=typeof r==`number`?r:Number(r);return Number.isFinite(e)?n?.formatNumber(e)??new Intl.NumberFormat().format(e):Mw(r)??i}return Mw(r)??i}function Pw({hit:e,field:n,className:r}){let a=Nw(e,n,at(jw));return a?n.format===`badge`||n.format===`content_type`?t(i,{className:r,children:a}):t(`span`,{className:r,children:a}):null}function Fw({hit:e,onOpenHit:r,compact:i=!1}){let{t:a}=X();return r?i?t(ze,{description:a(`agent.openDocument`),asChild:!0,children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`agent.openDocument`),onClick:()=>r(e),children:t(Zt,{className:`size-4`})})}):n(o,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(e),children:[t(Zt,{className:`size-4`}),a(`agent.openDocument`)]}):null}function Iw(e,t){if(t.source!==`property`||!t.field)return;let n=Mw(Aw(e,t.field));if(n)try{let e=new URL(n,typeof window>`u`?`https://localhost`:window.location.origin);return e.protocol===`http:`||e.protocol===`https:`?e.toString():void 0}catch{return}}function Lw({hit:e,media:n,resolveMedia:r,className:i}){let a=n?Iw(e,n):void 0,[o,s]=Y(),[c,l]=Y(!1);K(()=>{if(s(void 0),l(!1),a||!n||!r)return;let t=!0;return Promise.resolve(r(e,n)).then(e=>{t&&s(e)}).catch(()=>{t&&l(!0)}),()=>{t=!1}},[a,e,n,r]);let u=c?void 0:a??o,d=n?.fit===`contain`?`object-contain`:`object-cover`;if(u)return t(`img`,{src:u,alt:``,className:`${d} ${i??``}`,onError:()=>l(!0)});let f=n?.source===`type_icon`?`type_icon`:n?.fallback??`type_icon`;return f===`none`?null:t(`div`,{className:`flex items-center justify-center bg-muted ${i??``}`,"aria-hidden":`true`,children:t(f===`placeholder`?vn:on,{className:`size-10 text-muted-foreground`})})}function Rw({hit:e}){let n=e.annotation?.why_match??e.annotation?.answer??e.annotation?.excerpt;return n?t(`p`,{className:`text-sm text-info`,children:n}):null}function zw({hit:e,fields:n}){return n?.length?t(`div`,{className:`flex flex-wrap gap-1`,children:n.map(n=>t(Pw,{hit:e,field:n},`${n.field}-${n.label??``}`))}):null}function Bw({hit:e,fields:r}){let i=at(jw);return r?.length?t(`dl`,{className:`space-y-1 text-sm`,children:r.map(r=>{let a=Nw(e,r,i);return a?n(`div`,{className:`flex gap-2`,children:[r.label&&t(`dt`,{className:`shrink-0 text-muted`,children:r.label}),t(`dd`,{className:`min-w-0 truncate`,children:a})]},`${r.field}-${r.label??``}`):null})}):null}function Vw({display:e,hits:r,onOpenHit:i,resolveMedia:a}){return t(`div`,{className:`divide-y divide-border rounded-md border`,children:r.map(r=>n(`article`,{className:`flex gap-4 p-4`,children:[e.media&&t(Lw,{hit:r,media:e.media,resolveMedia:a,className:`size-20 shrink-0 rounded-md`}),n(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[n(`div`,{children:[t(`h3`,{className:`font-semibold`,children:t(Pw,{hit:r,field:e.title})}),e.subtitle&&t(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm text-muted`,children:e.subtitle.map(e=>t(Pw,{hit:r,field:e},e.field))})]}),e.description&&t(`p`,{className:`line-clamp-3 text-sm text-muted-foreground`,children:t(Pw,{hit:r,field:e.description})}),t(zw,{hit:r,fields:e.badges}),t(Rw,{hit:r})]}),t(`div`,{className:`shrink-0 self-center`,children:t(Fw,{hit:r,onOpenHit:i,compact:!0})})]},r.id))})}function Hw({display:e,hits:r,isLoading:i,onOpenHit:a,sortOptions:o,currentSort:s,onSortChange:c}){let{t:l}=X();return t(`div`,{className:`overflow-x-auto rounded-md border`,children:n(Me,{className:`w-full`,children:[t(Ae,{children:n(`tr`,{children:[e.columns.map(e=>{let n=e.sort_option?o?.find(t=>t.id===e.sort_option):void 0;return!e.sortable||!n?t(Ne,{children:e.label??e.field},`${e.field}-${e.label??``}`):t(Te,{sortDirection:s===n.id?n.sort[0]?.order===`desc`?`descending`:`ascending`:`none`,onSort:()=>c?.(n.id),disabled:i||!c,sortIndicator:e=>e===`ascending`?t(Nt,{className:`size-3`,"aria-hidden":`true`}):e===`descending`?t(Ot,{className:`size-3`,"aria-hidden":`true`}):t(Rt,{className:`size-3 text-muted`,"aria-hidden":`true`}),children:e.label??e.field},`${e.field}-${e.label??``}`)}),a&&t(Ne,{className:`w-0`,children:t(`span`,{className:`sr-only`,children:l(`agent.openDocument`)})})]})}),t(ke,{isLoading:i&&r.length===0,columns:e.columns.length+ +!!a,children:r.map(r=>n(`tr`,{children:[e.columns.map(e=>t(`td`,{style:e.width?{width:e.width}:void 0,children:t(Pw,{hit:r,field:e})},`${r.id}-${e.field}`)),a&&t(`td`,{className:`w-0 whitespace-nowrap text-end`,children:t(Fw,{hit:r,onOpenHit:a,compact:!0})})]},r.id))})]})})}const Uw={2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`md:grid-cols-2 xl:grid-cols-4`,5:`md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-5`,6:`md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-6`};function Ww({hit:e,configuration:r,onOpenHit:i,resolveMedia:a}){return n(s,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[r.media&&t(Lw,{hit:e,media:r.media,resolveMedia:a,className:`h-40 w-full border-b`}),n(d,{className:`gap-2 p-4`,children:[t(zw,{hit:e,fields:r.badges}),t(f,{className:`truncate text-base`,children:t(Pw,{hit:e,field:r.title})}),r.description&&t(l,{className:`line-clamp-3`,children:t(Pw,{hit:e,field:r.description})})]}),n(c,{className:`flex-1 p-4 pt-0`,children:[t(Bw,{hit:e,fields:r.fields}),t(Rw,{hit:e})]}),i&&t(u,{className:`justify-end p-4 pt-0`,children:t(Fw,{hit:e,onOpenHit:i})})]})}function Gw({display:e,hits:n,onOpenHit:r,resolveMedia:i}){return t(`div`,{className:`grid grid-cols-1 gap-4 ${Uw[e.columns??3]}`,children:n.map(n=>t(Ww,{hit:n,configuration:e,onOpenHit:r,resolveMedia:i},n.id))})}function Kw({display:e,hits:r,onOpenHit:i,resolveMedia:a}){return t(`div`,{className:`grid grid-cols-1 gap-4 ${Uw[e.columns??4]}`,children:r.map(r=>n(s,{className:`overflow-hidden`,children:[t(Lw,{hit:r,media:e.media,resolveMedia:a,className:`aspect-square w-full border-b`}),n(c,{className:`space-y-2 p-3`,children:[t(`h3`,{className:`truncate font-semibold`,children:t(Pw,{hit:r,field:e.title})}),e.caption&&t(`div`,{className:`space-y-1 text-sm text-muted`,children:e.caption.map(e=>t(`div`,{className:`truncate`,children:t(Pw,{hit:r,field:e})},e.field))}),t(Fw,{hit:r,onOpenHit:i})]})]},r.id))})}function qw({display:e,hits:r,onOpenHit:a,resolveMedia:o}){let s=new Map;for(let t of r){let n=Mw(Aw(t,e.group_by))??``;s.set(n,[...s.get(n)??[],t])}return t(`div`,{className:`flex min-w-max gap-4 overflow-x-auto pb-2`,children:(e.columns?.length?[...e.columns].sort((e,t)=>(e.order??0)-(t.order??0)):[...s.keys()].sort().map(e=>({value:e,label:e||`—`}))).map(r=>{let c=s.get(r.value)??[];return n(`section`,{className:`w-80 shrink-0 space-y-3 rounded-lg bg-muted/40 p-3`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`h3`,{className:`font-semibold`,children:r.label}),t(i,{children:c.length})]}),t(`div`,{className:`space-y-3`,children:c.map(n=>t(Ww,{hit:n,configuration:e.card,onOpenHit:a,resolveMedia:o},n.id))})]},r.value)})})}function Jw(e,n,r,i,a,o,s,c){return e.type===`table`?t(Hw,{display:e,hits:n,isLoading:r,onOpenHit:i,sortOptions:o,currentSort:s,onSortChange:c}):e.type===`cards`?t(Gw,{display:e,hits:n,onOpenHit:i,resolveMedia:a}):e.type===`gallery`?t(Kw,{display:e,hits:n,onOpenHit:i,resolveMedia:a}):e.type===`board`?t(qw,{display:e,hits:n,onOpenHit:i,resolveMedia:a}):t(Vw,{display:e,hits:n,onOpenHit:i,resolveMedia:a})}function Yw({configuration:e,definition:n,request:r,result:i,isLoading:a,onSortChange:o,onOpenHit:s,resolveMedia:c}){let{t:l}=X(),u=dt();return!a&&i.hits.length===0?t(`p`,{className:`py-12 text-center text-sm text-muted`,children:l(`filter.noResultsFound`)}):t(jw.Provider,{value:u,children:Jw(e,i.hits,a,s,c,n.results?.sort_options,Dw(r,i,n.results?.default_sort),o)})}function Xw(e,t){return t?`text`:e===`number`?`number`:e===`date`?`date`:`text`}function Zw(e){let[t=``,n=``]=(e[0]??``).split(`..`,2);return[t,n]}function Qw(e,t){return e||t?[`${e}..${t}`]:[]}function $w(e,t){return t?e.join(`, `):e[0]??``}function eT(e,t){return t?e.split(`,`).map(e=>e.trim()).filter(Boolean):e.trim()?[e.trim()]:[]}function tT({term:e,values:n,isLoading:r,onChange:i}){let a=J(!1),o=J(void 0),[s,c]=Y(()=>$w(n,e.multiple)),l=$w(n,e.multiple);return K(()=>{a.current&&o.current===l||c(l),o.current=void 0},[l]),t(L,{label:e.label,children:t(ee,{type:Xw(e.type,e.multiple),name:`view-key-term-${e.id}`,autoComplete:`off`,value:s,onFocus:()=>{a.current=!0},onBlur:()=>{a.current=!1;let t=eT(s,e.multiple);c($w(t,e.multiple))},onChange:t=>{c(t);let n=eT(t,e.multiple);o.current=$w(n,e.multiple),i(n)},placeholder:e.label,disabled:r})})}function nT({configuration:e,query:r,keyTerms:i,isLoading:a,onQueryChange:s,onKeyTermsChange:c,onSubmit:l}){let{t:u}=X(),d=ot(),f=e.key_terms?.filter(e=>e.operator!==`range`)??[],p=e.key_terms?.filter(e=>e.operator===`range`)??[];return n(`form`,{className:`flex flex-col gap-3`,"aria-label":u(`layout.search`),autoComplete:`off`,onSubmit:e=>{e.preventDefault(),l()},children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`label`,{htmlFor:d,className:`sr-only`,children:u(`layout.search`)}),t(ee,{id:d,name:`view-query`,autoComplete:`off`,value:r,onChange:s,placeholder:e.placeholder??u(`store.searchPlaceholder`),disabled:a}),n(o,{type:`submit`,disabled:a,className:`shrink-0`,children:[t(er,{className:`size-4`}),u(a?`store.searching`:`store.search`)]})]}),e.key_terms&&e.key_terms.length>0&&n(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[f.length>0&&n(`fieldset`,{className:`rounded-md border border-mixer-muted/30 bg-mixer-muted/5 p-3 ${p.length===0?`lg:col-span-2`:``}`,children:[t(`legend`,{className:`px-1 text-xs font-medium text-muted`,children:u(`view.searchFields`)}),t(`div`,{className:`grid gap-3 sm:grid-cols-2 ${p.length===0?`lg:grid-cols-4`:``}`,children:f.map(e=>t(tT,{term:e,values:i[e.id]??[],isLoading:a,onChange:t=>c(e.id,t)},e.id))})]}),p.length>0&&n(`fieldset`,{className:`rounded-md border border-mixer-muted/30 bg-mixer-muted/5 p-3 ${f.length===0?`lg:col-span-2`:``}`,children:[t(`legend`,{className:`px-1 text-xs font-medium text-muted`,children:u(`view.ranges`)}),t(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:p.map(e=>{let[r,o]=Zw(i[e.id]??[]),s=e.type===`number`?`number`:e.type===`date`?`date`:`text`;return n(`fieldset`,{className:`min-w-0`,children:[t(`legend`,{className:`mb-1 text-sm font-medium`,children:e.label}),n(`div`,{className:`grid grid-cols-2 gap-2`,children:[t(ee,{type:s,name:`view-key-term-${e.id}-from`,autoComplete:`off`,"aria-label":`${e.label}: ${u(`view.from`)}`,value:r,onChange:t=>c(e.id,Qw(t.trim(),o)),placeholder:u(`view.from`),disabled:a}),t(ee,{type:s,name:`view-key-term-${e.id}-to`,autoComplete:`off`,"aria-label":`${e.label}: ${u(`view.to`)}`,value:o,onChange:t=>c(e.id,Qw(r,t.trim())),placeholder:u(`view.to`),disabled:a})]})]},e.id)})})]})]})]})}const rT={id:`default`,label:`Results`,type:`list`,title:{field:`name`},subtitle:[{field:`type.name`,format:`content_type`},{field:`location`,format:`location`}],description:{field:`description`}};function iT(e){return!e||typeof window>`u`?{}:xw(window.location.search)}function aT(e){let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e.length>0));return Object.keys(t).length>0?t:void 0}function oT(e){let{client:n}=Z(),r=G(t=>n.views.execute(e.viewId,t),[n,e.viewId]),i=G(async(e,t)=>{if(t.source!==`content_thumbnail`)return;let r=e.document.content;try{let t=await n.objects.getRenditionSafe(e.id,r?.type,{format:Pr.jpeg,max_hw:512,generate_if_missing:!1,sign_url:!0});if(t?.status===`found`&&t.renditions?.length)return t.renditions[0]}catch{}if(r?.source&&r.type?.startsWith(`image/`))return(await n.files.getDownloadUrl(r.source)).url},[n]);return t(cT,{...e,execute:r,resolveMedia:e.resolveMedia??i})}function sT({execute:e,...n}){return e?t(cT,{...n,execute:e},n.viewId):t(oT,{...n},n.viewId)}function cT({execute:e,renderers:r,onOpenHit:i,resolveMedia:a,syncUrl:s=!0,showHeader:c=!0,className:l}){let{t:u}=X(),d=J(e);d.current=e;let f=J(0),[p,m]=Y(()=>iT(s)),[h,g]=Y(p.query??``),[_,v]=Y(p.key_terms??{}),[y,b]=Y(),[x,S]=Y(!0),[C,w]=Y(),T=G((e,t)=>{let n=++f.current;return m(e),t&&s&&Ow(e),S(!0),w(void 0),d.current(e).then(t=>{if(n===f.current){let n=Ew(e,t);m(n),s&&Ow(n),b(t)}}).catch(e=>{n===f.current&&w(e instanceof Error?e:Error(String(e)))}).finally(()=>{n===f.current&&S(!1)})},[s]),E=G(()=>{let e=iT(s);return g(e.query??``),v(e.key_terms??{}),T(e,!1)},[T,s]);K(()=>(E(),()=>{f.current+=1}),[E]),K(()=>{if(!s||typeof window>`u`)return;let e=()=>void E();return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[E,s]);let D=y?.definition,O=q(()=>[...D?.navigation??[]].sort((e,t)=>(e.order??0)-(t.order??0)),[D?.navigation]),k=D?.results,A=y?.display??p.display??k?.default_display,j=k?.displays.find(e=>e.id===A)??rT,N=y?Dw(p,y,k?.default_sort):p.sort,P=e=>{T(e,!0)},F=(e,t)=>{let n=aT({...p.navigation??{},[e.id]:t});P({...p,navigation:n,offset:void 0})},I=()=>{P({...p,query:h.trim()||void 0,key_terms:aT(_),offset:void 0})};if(!y&&x)return t(`div`,{className:`flex h-full min-h-48 items-center justify-center`,children:t(Ee,{size:`xl`})});if(!y||!D)return t(`div`,{className:`flex h-full min-h-48 items-center justify-center p-4`,children:t(M,{title:u(`store.searchFailed`),action:()=>void E(),actionLabel:u(`agent.retry`),children:u(`store.searchFailed`)})});let L=D.search?.renderer?r?.search?.[D.search.renderer]??nT:nT,R=j.renderer?r?.results?.[j.renderer]??Yw:Yw,ee=O.length>0&&D.layout?.navigation_position!==`top`,te=D.layout?.mode===`worklist`,z=p.offset??0,ne=p.limit??j.page_size??20,B=z>0,ie=z+y.hits.length<y.total,ae=O.map(e=>{let n=y.navigation[e.id]??{id:e.id,selected:[],nodes:[]};return t(e.renderer?r?.navigation?.[e.renderer]??hw:hw,{configuration:e,result:n,isLoading:x,onChange:t=>F(e,t)},e.id)});return n(ta,{className:l,children:[c&&t(Db,{title:D.name,description:D.description}),n(ta.Fixed,{heightClass:`h-auto`,className:`space-y-3 border-b p-3`,children:[D.search&&t(L,{configuration:D.search,query:h,keyTerms:_,isLoading:x,onQueryChange:g,onKeyTermsChange:(e,t)=>v(n=>({...n,[e]:t})),onSubmit:I}),O.length>0&&D.layout?.navigation_position===`top`&&t(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:ae})]}),t(ta.Body,{className:`p-0`,children:n(`div`,{className:ee?te?`grid min-h-full lg:grid-cols-[minmax(0,1fr)_18rem]`:`grid min-h-full lg:grid-cols-[18rem_minmax(0,1fr)]`:`min-h-full`,children:[ee&&t(`aside`,{className:te?`space-y-5 border-b p-4 lg:order-2 lg:border-s lg:border-b-0`:`space-y-5 border-b p-4 lg:border-e lg:border-b-0`,children:ae}),n(`main`,{className:`min-w-0 space-y-4 p-4 ${te?`lg:order-1`:``}`,children:[C&&t(M,{title:u(`store.searchFailed`),action:()=>void T(p,!1),actionLabel:u(`agent.retry`),children:u(`store.searchFailed`)}),y.search.warnings.length>0&&t(re,{status:`warning`,title:u(`view.warning`),children:t(`ul`,{className:`list-disc space-y-1 ps-4`,children:y.search.warnings.map(e=>t(`li`,{children:e.message},`${e.code}-${e.path??``}`))})}),n(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[n(`div`,{className:`flex items-center gap-2 text-sm text-muted`,children:[t(`span`,{children:u(`view.resultsCount`,{count:y.total})}),x&&t(Ee,{size:`sm`})]}),n(`div`,{className:`flex flex-wrap items-center gap-3`,children:[k?.allow_display_switch&&k.displays.length>1&&n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`text-sm text-muted`,children:u(`view.display`)}),t(ye,{options:k.displays,value:j,onChange:e=>P({...p,display:e.id,offset:void 0}),optionLabel:e=>e.label,by:`id`,disabled:x,"aria-label":u(`view.display`),className:`min-w-36`})]}),k?.sort_options&&k.sort_options.length>0&&n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`text-sm text-muted`,children:u(`view.sort`)}),t(ye,{options:k.sort_options,value:k.sort_options.find(e=>e.id===N),onChange:e=>P({...p,sort:e.id,offset:void 0}),optionLabel:e=>e.label,by:`id`,disabled:x,"aria-label":u(`view.sort`),className:`min-w-44`})]})]})]}),t(R,{configuration:j,definition:D,request:p,result:y,isLoading:x,onSortChange:e=>P({...p,sort:e,offset:void 0}),onOpenHit:i,resolveMedia:a}),(B||ie)&&n(`nav`,{className:`flex items-center justify-center gap-2`,"aria-label":u(`view.pagination`),children:[n(o,{type:`button`,variant:`outline`,disabled:!B||x,onClick:()=>P({...p,offset:Math.max(0,z-ne)||void 0}),children:[t(At,{className:`size-4 cn-rtl-flip`}),u(`grounded.previousPage`)]}),n(o,{type:`button`,variant:`outline`,disabled:!ie||x,onClick:()=>P({...p,offset:z+ne}),children:[u(`grounded.nextPage`),t(jt,{className:`size-4 cn-rtl-flip`})]})]})]})]})})]})}export{la as ActivitiesDoc,da as ActivityDoc,LC as AddToCollectionAction,FC as AddToCollectionActionComponent,ba as AgentApprovalModeSelector,Wa as AgentChart,Fm as AgentChatFixtureReplay,to as AgentChatPlaybackControls,Vg as AgentRunnerFacetsNav,_x as AllOf,Nu as AnimatedThinkingDots,gx as AnyOf,Fg as ApiKeyAvatar,yl as AskUserWidget,fx as AudioPanel,mS as BrowseCollectionView,HC as ChangeTypeAction,BC as ChangeTypeActionComponent,bS as CollectionIcon,Jg as CollectionsFacetsNav,yS as CollectionsTable,bl as ConfirmationWidget,Fv as ContentDispositionButton,AS as ContentObjectTypesSearch,SS as ContentObjectTypesTable,Wx as ContentOverview,_S as CreateCollectionForm,vS as CreateCollectionModal,CS as CreateOrUpdateTypeModal,hw as DefaultViewNavigation,Yw as DefaultViewResults,nT as DefaultViewSearch,KC as DeleteObjectsAction,WC as DeleteObjectsActionComponent,qC as DeleteObjectsFromCollectionsAction,pv as DocumentGridView,dv as DocumentIcon,uv as DocumentIconSkeleton,TC as DocumentInput,EC as DocumentPreviewPanel,mv as DocumentSearch,Nv as DocumentSearchProvider,uS as DocumentSearchResults,lS as DocumentSearchResultsWithDropZone,E_ as DocumentSelection,A_ as DocumentSelectionProvider,Ov as DocumentTable,lv as DocumentTableColumn,fv as DocumentTableView,Tv as DocumentUploadModal,$g as DocumentsFacetsNav,bC as EditCollectionView,e_ as EnvironmentFacet,XC as ExportPropertiesAction,JC as ExportPropertiesComponent,kC as ExportPropertiesModal,OC as ExportTypes,xv as FileUploadAction,Db as GenericPageNavHeader,Pb as GroundedExtractionPanel,Fb as GroundedExtractionView,ig as Header,px as ImagePanel,QS as IntakePolicyEditor,r_ as InteractionsFacetsNav,Im as JumpingDots,Dd as MESSAGE_STYLES,ox as MagicPdfView,Gm as McpConnectionsActionMenu,Um as McpConnectionsButton,Hm as McpConnectionsDialog,Wm as McpConnectionsInlineList,kd as MessageItem,xy as MessagesContainer,gy as ModernAgentConversation,Ob as NotFoundView,hx as OAuthProviderConnectButton,lC as ObjectSchemaEditor,wS as ObjectTypeSearch,TS as ObjectTypeSearchContext,mC as ObjectTypeSearchProvider,nw as ObjectsActionContextProvider,yb as PanelErrorBoundary,eg as PayloadBuilder,ng as PayloadBuilderProvider,$h as PayloadBuilderStore,tg as PayloadContext,My as PdfDocumentRenderer,Cy as PdfPageRenderer,Py as PdfPageSlider,jy as PdfThumbnailList,a_ as ProcessDefinitionsFacetsNav,s_ as ProcessRunsFacetsNav,u_ as PromptsFacetsNav,jx as PropertiesEditorModal,Pu as PulsatingCircle,Iu as PulsingMessageLoader,Bs as RemoteMcpConnectionButton,$C as RemoveFromCollectionAction,ZC as RemoveFromCollectionActionComponent,xb as RowErrorBoundary,m_ as RunsFacetsNav,Ax as SaveVersionConfirmModal,hv as SearchContext,wx as SecureButton,Tx as SecureSidebarItem,SC as SelectCollection,gS as SelectContentType,pC as SelectContentTypeModal,Lv as SelectDocument,CC as SelectDocumentModal,db as SelectEnvironment,mb as SelectModel,hb as SelectTrainingModel,ow as SelectionActions,Ty as SharedPdfProvider,_C as SharedPropsEditor,Oy as SimplePdfPage,Ly as SimplePdfViewer,qv as SkillWidgetProvider,jd as StreamingMessage,h_ as StringFacet,g_ as StringListFacet,vC as SyncMemberHeadsToggle,hC as TableLayoutEditor,Lu as ThinkingBar,zu as ThinkingMessages,v_ as TypeFacet,Hg as TypeRegistry,Wg as TypeRegistryProvider,Fu as TypedDots,lb as UniversalDocumentViewer,sw as UploadObjectsButton,fw as UserAvatar,jg as UserInfo,Cx as UserPermissionProvider,yx as UserPermissions,xx as UserPermissionsContext,ug as VInteractionFacet,mg as VStringFacet,Yg as VTypeFacet,Rg as VUserFacet,Ba as VegaLiteChart,gb as VertesiaErrorBoundary,mx as VideoPanel,sT as ViewExperience,ux as WEB_SUPPORTED_AUDIO_FORMATS,cx as WEB_SUPPORTED_IMAGE_FORMATS,lx as WEB_SUPPORTED_VIDEO_FORMATS,Ru as WavyThinking,Cb as WidgetErrorBoundary,b_ as WorkflowDefinitionsFacetsNav,C_ as WorkflowExecutionsFacetsNav,T_ as WorkflowRulesFacetsNav,Ew as canonicalizeViewState,Ga as clampPlaybackCursor,Bm as countConnectedActiveGroups,Bg as createAgentRunnerFilterHandler,Ya as createPlaybackState,cg as filterValueToQueryValue,dx as formatDuration,Nw as formatViewFieldValue,Vm as getConnectedActiveGroupLabels,Ja as getNextUserTurnIndex,Ka as getPlaybackCursorIndex,qa as getPreviousUserTurnIndex,Aw as getViewFieldValue,Q_ as getWorkflowStatusColor,$_ as getWorkflowStatusName,Ox as invalidateTypeCache,Za as isAgentChatPlaybackAvailable,Qa as isAgentChatPlaybackEnabled,vx as isAnyOf,V_ as isCsv,Rm as isGroupDisabled,H_ as isImage,$a as isLocalhostAgentChatPlaybackAvailable,eo as isLocalhostAgentChatPlaybackEnabled,U_ as isPdf,G_ as isPreviewableAsPdf,Ha as isRechartsSpec,Va as isVegaLiteSpec,W_ as isVideo,xw as parseViewState,K_ as printElementToPdf,Ow as replaceViewStateInUrl,Dx as resolveTypeCached,Dw as resolveViewSort,Y_ as retrieveRendition,ww as serializeViewState,vb as setErrorBoundaryComponent,lg as setSearchQueryValue,X_ as shortId,Z_ as shortenString,gC as stringifyTableLayout,zm as toggleGroupDisabled,sg as unwrapFilterOptionValue,zg as useAgentRunnerFilterGroups,Kg as useCollectionsFilterGroups,qg as useCollectionsFilterHandler,Zg as useDocumentFilterGroups,Qg as useDocumentFilterHandler,gv as useDocumentSearch,yv as useDocumentSearchCount,O_ as useDocumentSelection,Ev as useDocumentUploadHandler,fd as useDownloadFile,Sg as useFetchApiKeyInfo,xg as useFetchGroupInfo,bg as useFetchUserInfo,Mb as useGroundedExtractionAvailable,Nb as useGroundedSummary,t_ as useInteractionsFilterGroups,n_ as useInteractionsFilterHandler,Lm as useMcpConnections,zs as useOAuthPopup,k_ as useOptionalDocumentSelection,rg as usePayloadBuilder,i_ as useProcessDefinitionsFilterGroups,o_ as useProcessRunsFilterGroups,c_ as usePromptsFilterGroups,l_ as usePromptsFilterHandler,f_ as useRunsFilterGroups,p_ as useRunsFilterHandler,ES as useSearch,OS as useSearchCount,Ey as useSharedPdf,wv as useSmartFileUploadProcessing,Gg as useTypeRegistry,Sx as useUserPermissions,_v as useWatchDocumentSearchFacets,vv as useWatchDocumentSearchResult,DS as useWatchSearchResult,y_ as useWorkflowDefinitionsFilterGroups,x_ as useWorkflowExecutionsFilterGroups,S_ as useWorkflowExecutionsFilterHandler,w_ as useWorkflowRulesFilterGroups};
|
|
454
461
|
//# sourceMappingURL=vertesia-ui-features.js.map
|