@vertesia/ui 1.0.0-dev.20260128.144200 → 1.0.0-dev.20260225.024852Z
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/esm/core/components/InputList.js +1 -1
- package/lib/esm/core/components/InputList.js.map +1 -1
- package/lib/esm/core/components/Overlay.js +1 -1
- package/lib/esm/core/components/Overlay.js.map +1 -1
- package/lib/esm/core/components/SidePanel.js +8 -2
- package/lib/esm/core/components/SidePanel.js.map +1 -1
- package/lib/esm/core/components/Switch.js +1 -1
- package/lib/esm/core/components/Switch.js.map +1 -1
- package/lib/esm/core/components/index.js +0 -8
- package/lib/esm/core/components/index.js.map +1 -1
- package/lib/esm/core/components/shadcn/MessageBox.js.map +1 -0
- package/lib/esm/core/components/shadcn/Panel.js +13 -0
- package/lib/esm/core/components/shadcn/Panel.js.map +1 -0
- package/lib/esm/core/components/{Badge.js → shadcn/badge.js} +2 -2
- package/lib/esm/core/components/shadcn/badge.js.map +1 -0
- package/lib/esm/core/components/shadcn/command.js +1 -1
- package/lib/esm/core/components/shadcn/command.js.map +1 -1
- package/lib/esm/core/components/shadcn/filters/filterBar.js +73 -83
- package/lib/esm/core/components/shadcn/filters/filterBar.js.map +1 -1
- package/lib/esm/core/components/shadcn/index.js +4 -2
- package/lib/esm/core/components/shadcn/index.js.map +1 -1
- package/lib/esm/core/components/shadcn/modal/ConfirmModal.js +10 -0
- package/lib/esm/core/components/shadcn/modal/ConfirmModal.js.map +1 -0
- package/lib/esm/core/components/{DeleteModal.js → shadcn/modal/DeleteModal.js} +1 -1
- package/lib/esm/core/components/shadcn/modal/DeleteModal.js.map +1 -0
- package/lib/esm/core/components/shadcn/{dialog.js → modal/dialog.js} +19 -15
- package/lib/esm/core/components/shadcn/modal/dialog.js.map +1 -0
- package/lib/esm/core/components/shadcn/modal/index.js +4 -0
- package/lib/esm/core/components/shadcn/modal/index.js.map +1 -0
- package/lib/esm/core/components/shadcn/popover.js +4 -2
- package/lib/esm/core/components/shadcn/popover.js.map +1 -1
- package/lib/esm/core/components/shadcn/selectBox.js +19 -15
- package/lib/esm/core/components/shadcn/selectBox.js.map +1 -1
- package/lib/esm/core/components/shadcn/tabs.js +16 -14
- package/lib/esm/core/components/shadcn/tabs.js.map +1 -1
- package/lib/esm/core/components/shadcn/textarea.js +30 -2
- package/lib/esm/core/components/shadcn/textarea.js.map +1 -1
- package/lib/esm/core/components/shadcn/tooltip.js +5 -1
- package/lib/esm/core/components/shadcn/tooltip.js.map +1 -1
- package/lib/esm/features/agent/PayloadBuilder.js +45 -0
- package/lib/esm/features/agent/PayloadBuilder.js.map +1 -1
- package/lib/esm/features/agent/chat/AgentChart.js +12 -232
- package/lib/esm/features/agent/chat/AgentChart.js.map +1 -1
- package/lib/esm/features/agent/chat/AskUserWidget.js +2 -1
- package/lib/esm/features/agent/chat/AskUserWidget.js.map +1 -1
- package/lib/esm/features/agent/chat/DocumentPanel.js +46 -0
- package/lib/esm/features/agent/chat/DocumentPanel.js.map +1 -0
- package/lib/esm/features/agent/chat/DocumentTabBar.js +17 -0
- package/lib/esm/features/agent/chat/DocumentTabBar.js.map +1 -0
- package/lib/esm/features/agent/chat/ModernAgentConversation.js +159 -402
- package/lib/esm/features/agent/chat/ModernAgentConversation.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js +99 -57
- package/lib/esm/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/BatchProgressPanel.js +4 -4
- package/lib/esm/features/agent/chat/ModernAgentOutput/BatchProgressPanel.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/Header.js +4 -4
- package/lib/esm/features/agent/chat/ModernAgentOutput/Header.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/InlineSlidingPlanPanel.js +3 -3
- package/lib/esm/features/agent/chat/ModernAgentOutput/InlineSlidingPlanPanel.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/MessageInput.js +25 -22
- package/lib/esm/features/agent/chat/ModernAgentOutput/MessageInput.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/MessageItem.js +110 -55
- package/lib/esm/features/agent/chat/ModernAgentOutput/MessageItem.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/StreamingMessage.js +2 -2
- package/lib/esm/features/agent/chat/ModernAgentOutput/StreamingMessage.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/ToolCallGroup.js +146 -55
- package/lib/esm/features/agent/chat/ModernAgentOutput/ToolCallGroup.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/WorkstreamTabs.js +5 -6
- package/lib/esm/features/agent/chat/ModernAgentOutput/WorkstreamTabs.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/utils.js +110 -2
- package/lib/esm/features/agent/chat/ModernAgentOutput/utils.js.map +1 -1
- package/lib/esm/features/agent/chat/SkillWidgetProvider.js +28 -15
- package/lib/esm/features/agent/chat/SkillWidgetProvider.js.map +1 -1
- package/lib/esm/features/agent/chat/hooks/useAgentPlans.js +146 -0
- package/lib/esm/features/agent/chat/hooks/useAgentPlans.js.map +1 -0
- package/lib/esm/features/agent/chat/hooks/useAgentStream.js +180 -0
- package/lib/esm/features/agent/chat/hooks/useAgentStream.js.map +1 -0
- package/lib/esm/features/agent/chat/hooks/useDocumentPanel.js +100 -0
- package/lib/esm/features/agent/chat/hooks/useDocumentPanel.js.map +1 -0
- package/lib/esm/features/agent/chat/hooks/useFileProcessing.js +90 -0
- package/lib/esm/features/agent/chat/hooks/useFileProcessing.js.map +1 -0
- package/lib/esm/features/agent/chat/index.js +6 -5
- package/lib/esm/features/agent/chat/index.js.map +1 -1
- package/lib/esm/features/agent/chat/types/document.js +2 -0
- package/lib/esm/features/agent/chat/types/document.js.map +1 -0
- package/lib/esm/features/agent/index.js +0 -2
- package/lib/esm/features/agent/index.js.map +1 -1
- package/lib/esm/features/store/collections/BrowseCollectionView.js +4 -6
- package/lib/esm/features/store/collections/BrowseCollectionView.js.map +1 -1
- package/lib/esm/features/store/collections/CreateCollection.js +4 -4
- package/lib/esm/features/store/collections/CreateCollection.js.map +1 -1
- package/lib/esm/features/store/collections/EditCollectionView.js +1 -1
- package/lib/esm/features/store/collections/EditCollectionView.js.map +1 -1
- package/lib/esm/features/store/objects/DocumentSearchResults.js +5 -5
- package/lib/esm/features/store/objects/DocumentSearchResults.js.map +1 -1
- package/lib/esm/features/store/objects/ExportPropertiesModal.js +3 -3
- package/lib/esm/features/store/objects/ExportPropertiesModal.js.map +1 -1
- package/lib/esm/features/store/objects/components/ContentOverview.js +19 -120
- package/lib/esm/features/store/objects/components/ContentOverview.js.map +1 -1
- package/lib/esm/features/store/objects/components/PropertiesEditorModal.js +1 -1
- package/lib/esm/features/store/objects/components/PropertiesEditorModal.js.map +1 -1
- package/lib/esm/features/store/objects/components/SelectDocumentModal.js +2 -2
- package/lib/esm/features/store/objects/components/SelectDocumentModal.js.map +1 -1
- package/lib/esm/features/store/objects/components/VectorSearchWidget.js +1 -1
- package/lib/esm/features/store/objects/components/VectorSearchWidget.js.map +1 -1
- package/lib/esm/features/store/objects/components/index.js +1 -1
- package/lib/esm/features/store/objects/components/index.js.map +1 -1
- package/lib/esm/features/store/objects/components/useDownloadFile.js +192 -0
- package/lib/esm/features/store/objects/components/useDownloadFile.js.map +1 -0
- package/lib/esm/features/store/objects/search/DocumentSearchContext.js +1 -2
- package/lib/esm/features/store/objects/search/DocumentSearchContext.js.map +1 -1
- package/lib/esm/features/store/objects/selection/SelectionActions.js +5 -8
- package/lib/esm/features/store/objects/selection/SelectionActions.js.map +1 -1
- package/lib/esm/features/store/objects/selection/actions/AddToCollectionAction.js +4 -4
- package/lib/esm/features/store/objects/selection/actions/AddToCollectionAction.js.map +1 -1
- package/lib/esm/features/store/objects/selection/actions/ChangeTypeAction.js +2 -2
- package/lib/esm/features/store/objects/selection/actions/ChangeTypeAction.js.map +1 -1
- package/lib/esm/features/store/objects/selection/actions/ExportPropertiesAction.js +1 -1
- package/lib/esm/features/store/objects/selection/actions/ExportPropertiesAction.js.map +1 -1
- package/lib/esm/features/store/objects/selection/actions/StartWorkflowComponent.js +3 -3
- package/lib/esm/features/store/objects/selection/actions/StartWorkflowComponent.js.map +1 -1
- package/lib/esm/features/store/objects/upload/DocumentUploadModal.js +13 -13
- package/lib/esm/features/store/objects/upload/DocumentUploadModal.js.map +1 -1
- package/lib/esm/features/store/objects/upload/useSmartFileUploadProcessing.js +15 -8
- package/lib/esm/features/store/objects/upload/useSmartFileUploadProcessing.js.map +1 -1
- package/lib/esm/features/store/types/ObjectSchemaEditor.js +6 -5
- package/lib/esm/features/store/types/ObjectSchemaEditor.js.map +1 -1
- package/lib/esm/features/store/types/SelectContentType.js +3 -3
- package/lib/esm/features/store/types/SelectContentType.js.map +1 -1
- package/lib/esm/features/store/types/SelectContentTypeModal.js +5 -4
- package/lib/esm/features/store/types/SelectContentTypeModal.js.map +1 -1
- package/lib/esm/features/store/types/TableLayoutEditor.js +4 -4
- package/lib/esm/features/store/types/TableLayoutEditor.js.map +1 -1
- package/lib/esm/features/user/UserInfo.js +73 -9
- package/lib/esm/features/user/UserInfo.js.map +1 -1
- package/lib/esm/features/utils/print.js +0 -1
- package/lib/esm/features/utils/print.js.map +1 -1
- package/lib/esm/layout/AppLayout.js +3 -4
- package/lib/esm/layout/AppLayout.js.map +1 -1
- package/lib/esm/layout/Sidebar.js +5 -5
- package/lib/esm/layout/Sidebar.js.map +1 -1
- package/lib/esm/router/HistoryNavigator.js +7 -1
- package/lib/esm/router/HistoryNavigator.js.map +1 -1
- package/lib/esm/router/Nav.js +2 -2
- package/lib/esm/router/Nav.js.map +1 -1
- package/lib/esm/session/UserSession.js +35 -9
- package/lib/esm/session/UserSession.js.map +1 -1
- package/lib/esm/session/UserSessionProvider.js +3 -2
- package/lib/esm/session/UserSessionProvider.js.map +1 -1
- package/lib/esm/shell/apps/AppProjectSelector.js +2 -2
- package/lib/esm/shell/apps/AppProjectSelector.js.map +1 -1
- package/lib/esm/shell/apps/StandaloneApp.js +2 -2
- package/lib/esm/shell/apps/StandaloneApp.js.map +1 -1
- package/lib/esm/shell/login/InviteAcceptModal.js +2 -2
- package/lib/esm/shell/login/InviteAcceptModal.js.map +1 -1
- package/lib/esm/shell/login/SignInModal.js +1 -1
- package/lib/esm/shell/login/SignInModal.js.map +1 -1
- package/lib/esm/shell/login/SignupForm.js +2 -2
- package/lib/esm/shell/login/SignupForm.js.map +1 -1
- package/lib/esm/shell/login/UserInfo.js +2 -2
- package/lib/esm/shell/login/UserInfo.js.map +1 -1
- package/lib/esm/widgets/json-view/JSONCode.js +1 -1
- package/lib/esm/widgets/json-view/JSONCode.js.map +1 -1
- package/lib/esm/widgets/json-view/JSONDisplay.js +1 -1
- package/lib/esm/widgets/json-view/JSONDisplay.js.map +1 -1
- package/lib/esm/widgets/markdown/ArtifactContentRenderer.js +84 -13
- package/lib/esm/widgets/markdown/ArtifactContentRenderer.js.map +1 -1
- package/lib/esm/widgets/markdown/MarkdownFigure.js +40 -0
- package/lib/esm/widgets/markdown/MarkdownFigure.js.map +1 -0
- package/lib/esm/widgets/markdown/MarkdownRenderer.js +42 -7
- package/lib/esm/widgets/markdown/MarkdownRenderer.js.map +1 -1
- package/lib/esm/widgets/markdown/MermaidDiagram.js +80 -5
- package/lib/esm/widgets/markdown/MermaidDiagram.js.map +1 -1
- package/lib/esm/widgets/markdown/codeBlockHandlers.js +33 -33
- package/lib/esm/widgets/markdown/codeBlockHandlers.js.map +1 -1
- package/lib/esm/widgets/markdown/codeBlockHandlers.test.js +2 -29
- package/lib/esm/widgets/markdown/codeBlockHandlers.test.js.map +1 -1
- package/lib/esm/widgets/markdown/index.js +1 -0
- package/lib/esm/widgets/markdown/index.js.map +1 -1
- package/lib/esm/widgets/markdown/normalizeCustomSchemeLinks.js +77 -0
- package/lib/esm/widgets/markdown/normalizeCustomSchemeLinks.js.map +1 -0
- package/lib/esm/widgets/markdown/normalizeDirectives.js +45 -0
- package/lib/esm/widgets/markdown/normalizeDirectives.js.map +1 -0
- package/lib/esm/widgets/markdown/remarkDirectiveHandler.js +96 -0
- package/lib/esm/widgets/markdown/remarkDirectiveHandler.js.map +1 -0
- package/lib/esm/widgets/monacoEditor/MonacoEditor.js +8 -14
- package/lib/esm/widgets/monacoEditor/MonacoEditor.js.map +1 -1
- package/lib/esm/widgets/schema-editor/ManagedSchema.js.map +1 -1
- package/lib/esm/widgets/schema-editor/editor/PropertyEditor.js +3 -3
- package/lib/esm/widgets/schema-editor/editor/PropertyEditor.js.map +1 -1
- package/lib/esm/widgets/schema-editor/json-schema4-utils.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/core/components/SidePanel.d.ts +4 -1
- package/lib/types/core/components/SidePanel.d.ts.map +1 -1
- package/lib/types/core/components/index.d.ts +0 -8
- package/lib/types/core/components/index.d.ts.map +1 -1
- package/lib/types/core/components/shadcn/MessageBox.d.ts.map +1 -0
- package/lib/types/core/components/{Panel.d.ts → shadcn/Panel.d.ts} +3 -1
- package/lib/types/core/components/shadcn/Panel.d.ts.map +1 -0
- package/lib/types/core/components/{Badge.d.ts → shadcn/badge.d.ts} +4 -4
- package/lib/types/core/components/shadcn/badge.d.ts.map +1 -0
- package/lib/types/core/components/shadcn/button.d.ts +1 -1
- package/lib/types/core/components/shadcn/filters/filterBar.d.ts.map +1 -1
- package/lib/types/core/components/shadcn/index.d.ts +4 -2
- package/lib/types/core/components/shadcn/index.d.ts.map +1 -1
- package/lib/types/core/components/shadcn/input.d.ts +1 -1
- package/lib/types/core/components/shadcn/modal/ConfirmModal.d.ts.map +1 -0
- package/lib/types/core/components/shadcn/modal/DeleteModal.d.ts.map +1 -0
- package/lib/types/core/components/shadcn/{dialog.d.ts → modal/dialog.d.ts} +7 -4
- package/lib/types/core/components/shadcn/modal/dialog.d.ts.map +1 -0
- package/lib/types/core/components/shadcn/modal/index.d.ts +4 -0
- package/lib/types/core/components/shadcn/modal/index.d.ts.map +1 -0
- package/lib/types/core/components/shadcn/popover.d.ts.map +1 -1
- package/lib/types/core/components/shadcn/selectBox.d.ts +9 -5
- package/lib/types/core/components/shadcn/selectBox.d.ts.map +1 -1
- package/lib/types/core/components/shadcn/tabs.d.ts +14 -5
- package/lib/types/core/components/shadcn/tabs.d.ts.map +1 -1
- package/lib/types/core/components/shadcn/textarea.d.ts +6 -2
- package/lib/types/core/components/shadcn/textarea.d.ts.map +1 -1
- package/lib/types/core/components/shadcn/tooltip.d.ts.map +1 -1
- package/lib/types/features/agent/PayloadBuilder.d.ts +22 -4
- package/lib/types/features/agent/PayloadBuilder.d.ts.map +1 -1
- package/lib/types/features/agent/chat/AgentChart.d.ts +3 -44
- package/lib/types/features/agent/chat/AgentChart.d.ts.map +1 -1
- package/lib/types/features/agent/chat/AskUserWidget.d.ts.map +1 -1
- package/lib/types/features/agent/chat/DocumentPanel.d.ts +16 -0
- package/lib/types/features/agent/chat/DocumentPanel.d.ts.map +1 -0
- package/lib/types/features/agent/chat/DocumentTabBar.d.ts +10 -0
- package/lib/types/features/agent/chat/DocumentTabBar.d.ts.map +1 -0
- package/lib/types/features/agent/chat/ModernAgentConversation.d.ts +69 -1
- package/lib/types/features/agent/chat/ModernAgentConversation.d.ts.map +1 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts +36 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts.map +1 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/BatchProgressPanel.d.ts +18 -2
- package/lib/types/features/agent/chat/ModernAgentOutput/BatchProgressPanel.d.ts.map +1 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/Header.d.ts +4 -7
- package/lib/types/features/agent/chat/ModernAgentOutput/Header.d.ts.map +1 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/MessageInput.d.ts +2 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/MessageInput.d.ts.map +1 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/MessageItem.d.ts +35 -7
- package/lib/types/features/agent/chat/ModernAgentOutput/MessageItem.d.ts.map +1 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/StreamingMessage.d.ts +11 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/StreamingMessage.d.ts.map +1 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/ToolCallGroup.d.ts +20 -2
- package/lib/types/features/agent/chat/ModernAgentOutput/ToolCallGroup.d.ts.map +1 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/WorkstreamTabs.d.ts.map +1 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/utils.d.ts +18 -1
- package/lib/types/features/agent/chat/ModernAgentOutput/utils.d.ts.map +1 -1
- package/lib/types/features/agent/chat/SkillWidgetProvider.d.ts.map +1 -1
- package/lib/types/features/agent/chat/hooks/useAgentPlans.d.ts +22 -0
- package/lib/types/features/agent/chat/hooks/useAgentPlans.d.ts.map +1 -0
- package/lib/types/features/agent/chat/hooks/useAgentStream.d.ts +42 -0
- package/lib/types/features/agent/chat/hooks/useAgentStream.d.ts.map +1 -0
- package/lib/types/features/agent/chat/hooks/useDocumentPanel.d.ts +22 -0
- package/lib/types/features/agent/chat/hooks/useDocumentPanel.d.ts.map +1 -0
- package/lib/types/features/agent/chat/hooks/useFileProcessing.d.ts +27 -0
- package/lib/types/features/agent/chat/hooks/useFileProcessing.d.ts.map +1 -0
- package/lib/types/features/agent/chat/index.d.ts +12 -8
- package/lib/types/features/agent/chat/index.d.ts.map +1 -1
- package/lib/types/features/agent/chat/types/document.d.ts +5 -0
- package/lib/types/features/agent/chat/types/document.d.ts.map +1 -0
- package/lib/types/features/agent/index.d.ts +0 -2
- package/lib/types/features/agent/index.d.ts.map +1 -1
- package/lib/types/features/store/collections/BrowseCollectionView.d.ts.map +1 -1
- package/lib/types/features/store/objects/ExportPropertiesModal.d.ts.map +1 -1
- package/lib/types/features/store/objects/components/ContentOverview.d.ts.map +1 -1
- package/lib/types/features/store/objects/components/PropertiesEditorModal.d.ts.map +1 -1
- package/lib/types/features/store/objects/components/index.d.ts +1 -1
- package/lib/types/features/store/objects/components/index.d.ts.map +1 -1
- package/lib/types/features/store/objects/components/useDownloadFile.d.ts +35 -0
- package/lib/types/features/store/objects/components/useDownloadFile.d.ts.map +1 -0
- package/lib/types/features/store/objects/search/DocumentSearchContext.d.ts.map +1 -1
- package/lib/types/features/store/objects/selection/SelectionActions.d.ts +1 -1
- package/lib/types/features/store/objects/selection/SelectionActions.d.ts.map +1 -1
- package/lib/types/features/store/objects/selection/actions/ChangeTypeAction.d.ts.map +1 -1
- package/lib/types/features/store/objects/selection/actions/ExportPropertiesAction.d.ts.map +1 -1
- package/lib/types/features/store/objects/upload/useSmartFileUploadProcessing.d.ts.map +1 -1
- package/lib/types/features/store/types/ObjectSchemaEditor.d.ts +2 -1
- package/lib/types/features/store/types/ObjectSchemaEditor.d.ts.map +1 -1
- package/lib/types/features/store/types/SelectContentTypeModal.d.ts +1 -1
- package/lib/types/features/store/types/SelectContentTypeModal.d.ts.map +1 -1
- package/lib/types/features/store/types/TableLayoutEditor.d.ts +2 -1
- package/lib/types/features/store/types/TableLayoutEditor.d.ts.map +1 -1
- package/lib/types/features/user/UserInfo.d.ts +12 -1
- package/lib/types/features/user/UserInfo.d.ts.map +1 -1
- package/lib/types/features/utils/print.d.ts.map +1 -1
- package/lib/types/layout/AppLayout.d.ts.map +1 -1
- package/lib/types/layout/Sidebar.d.ts +4 -2
- package/lib/types/layout/Sidebar.d.ts.map +1 -1
- package/lib/types/router/HistoryNavigator.d.ts.map +1 -1
- package/lib/types/router/Nav.d.ts +6 -1
- package/lib/types/router/Nav.d.ts.map +1 -1
- package/lib/types/session/UserSession.d.ts.map +1 -1
- package/lib/types/session/UserSessionProvider.d.ts +1 -0
- package/lib/types/session/UserSessionProvider.d.ts.map +1 -1
- package/lib/types/widgets/json-view/JSONCode.d.ts.map +1 -1
- package/lib/types/widgets/markdown/ArtifactContentRenderer.d.ts +10 -1
- package/lib/types/widgets/markdown/ArtifactContentRenderer.d.ts.map +1 -1
- package/lib/types/widgets/markdown/MarkdownFigure.d.ts +15 -0
- package/lib/types/widgets/markdown/MarkdownFigure.d.ts.map +1 -0
- package/lib/types/widgets/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/lib/types/widgets/markdown/MermaidDiagram.d.ts.map +1 -1
- package/lib/types/widgets/markdown/codeBlockHandlers.d.ts +5 -2
- package/lib/types/widgets/markdown/codeBlockHandlers.d.ts.map +1 -1
- package/lib/types/widgets/markdown/index.d.ts +1 -0
- package/lib/types/widgets/markdown/index.d.ts.map +1 -1
- package/lib/types/widgets/markdown/normalizeCustomSchemeLinks.d.ts +9 -0
- package/lib/types/widgets/markdown/normalizeCustomSchemeLinks.d.ts.map +1 -0
- package/lib/types/widgets/markdown/normalizeDirectives.d.ts +20 -0
- package/lib/types/widgets/markdown/normalizeDirectives.d.ts.map +1 -0
- package/lib/types/widgets/markdown/remarkDirectiveHandler.d.ts +2 -0
- package/lib/types/widgets/markdown/remarkDirectiveHandler.d.ts.map +1 -0
- package/lib/types/widgets/monacoEditor/MonacoEditor.d.ts +1 -3
- package/lib/types/widgets/monacoEditor/MonacoEditor.d.ts.map +1 -1
- package/lib/types/widgets/schema-editor/ManagedSchema.d.ts +1 -1
- package/lib/types/widgets/schema-editor/ManagedSchema.d.ts.map +1 -1
- package/lib/vertesia-ui-core.js +1 -1
- package/lib/vertesia-ui-core.js.map +1 -1
- package/lib/vertesia-ui-features.js +1 -1
- package/lib/vertesia-ui-features.js.map +1 -1
- package/lib/vertesia-ui-layout.js +1 -1
- package/lib/vertesia-ui-layout.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 +1 -1
- package/lib/vertesia-ui-widgets.js.map +1 -1
- package/package.json +14 -10
- package/src/core/components/InputList.tsx +1 -1
- package/src/core/components/Overlay.tsx +1 -1
- package/src/core/components/SidePanel.tsx +29 -15
- package/src/core/components/Switch.tsx +1 -1
- package/src/core/components/index.ts +0 -8
- package/src/core/components/shadcn/Panel.tsx +50 -0
- package/src/core/components/{Badge.tsx → shadcn/badge.tsx} +3 -3
- package/src/core/components/shadcn/command.tsx +1 -1
- package/src/core/components/shadcn/filters/filterBar.tsx +76 -87
- package/src/core/components/shadcn/index.ts +5 -3
- package/src/core/components/{ConfirmModal.tsx → shadcn/modal/ConfirmModal.tsx} +8 -8
- package/src/core/components/{DeleteModal.tsx → shadcn/modal/DeleteModal.tsx} +1 -1
- package/src/core/components/shadcn/{dialog.tsx → modal/dialog.tsx} +43 -32
- package/src/core/components/shadcn/modal/index.ts +3 -0
- package/src/core/components/shadcn/popover.tsx +4 -2
- package/src/core/components/shadcn/selectBox.tsx +71 -52
- package/src/core/components/shadcn/tabs.tsx +36 -19
- package/src/core/components/shadcn/textarea.tsx +43 -2
- package/src/core/components/shadcn/tooltip.tsx +23 -17
- package/src/features/agent/PayloadBuilder.tsx +70 -9
- package/src/features/agent/chat/AgentChart.tsx +46 -678
- package/src/features/agent/chat/AskUserWidget.tsx +4 -3
- package/src/features/agent/chat/DocumentPanel.tsx +120 -0
- package/src/features/agent/chat/DocumentTabBar.tsx +49 -0
- package/src/features/agent/chat/ModernAgentConversation.tsx +403 -549
- package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.tsx +162 -55
- package/src/features/agent/chat/ModernAgentOutput/BatchProgressPanel.tsx +40 -10
- package/src/features/agent/chat/ModernAgentOutput/Header.tsx +12 -16
- package/src/features/agent/chat/ModernAgentOutput/InlineSlidingPlanPanel.tsx +3 -3
- package/src/features/agent/chat/ModernAgentOutput/MessageInput.tsx +68 -75
- package/src/features/agent/chat/ModernAgentOutput/MessageItem.tsx +206 -94
- package/src/features/agent/chat/ModernAgentOutput/StreamingMessage.tsx +22 -5
- package/src/features/agent/chat/ModernAgentOutput/ToolCallGroup.tsx +295 -113
- package/src/features/agent/chat/ModernAgentOutput/WorkstreamTabs.tsx +11 -8
- package/src/features/agent/chat/ModernAgentOutput/utils.ts +133 -4
- package/src/features/agent/chat/SkillWidgetProvider.tsx +32 -15
- package/src/features/agent/chat/hooks/useAgentPlans.ts +190 -0
- package/src/features/agent/chat/hooks/useAgentStream.ts +239 -0
- package/src/features/agent/chat/hooks/useDocumentPanel.ts +118 -0
- package/src/features/agent/chat/hooks/useFileProcessing.ts +126 -0
- package/src/features/agent/chat/index.ts +18 -17
- package/src/features/agent/chat/types/document.ts +4 -0
- package/src/features/agent/index.ts +0 -2
- package/src/features/store/collections/BrowseCollectionView.tsx +5 -8
- package/src/features/store/collections/CreateCollection.tsx +8 -8
- package/src/features/store/collections/EditCollectionView.tsx +1 -1
- package/src/features/store/objects/DocumentSearchResults.tsx +9 -13
- package/src/features/store/objects/ExportPropertiesModal.tsx +9 -7
- package/src/features/store/objects/components/ContentOverview.tsx +29 -155
- package/src/features/store/objects/components/PropertiesEditorModal.tsx +0 -1
- package/src/features/store/objects/components/SelectDocumentModal.tsx +6 -6
- package/src/features/store/objects/components/VectorSearchWidget.tsx +2 -2
- package/src/features/store/objects/components/index.ts +1 -1
- package/src/features/store/objects/components/useDownloadFile.ts +237 -0
- package/src/features/store/objects/search/DocumentSearchContext.ts +1 -2
- package/src/features/store/objects/selection/SelectionActions.tsx +0 -4
- package/src/features/store/objects/selection/actions/AddToCollectionAction.tsx +13 -13
- package/src/features/store/objects/selection/actions/ChangeTypeAction.tsx +2 -6
- package/src/features/store/objects/selection/actions/ExportPropertiesAction.tsx +1 -3
- package/src/features/store/objects/selection/actions/StartWorkflowComponent.tsx +8 -8
- package/src/features/store/objects/upload/DocumentUploadModal.tsx +25 -25
- package/src/features/store/objects/upload/useSmartFileUploadProcessing.ts +16 -10
- package/src/features/store/types/ObjectSchemaEditor.tsx +32 -29
- package/src/features/store/types/SelectContentType.tsx +3 -3
- package/src/features/store/types/SelectContentTypeModal.tsx +17 -30
- package/src/features/store/types/TableLayoutEditor.tsx +14 -18
- package/src/features/user/UserInfo.tsx +176 -10
- package/src/features/utils/print.ts +0 -1
- package/src/layout/AppLayout.tsx +16 -44
- package/src/layout/Sidebar.tsx +7 -5
- package/src/router/HistoryNavigator.ts +9 -1
- package/src/router/Nav.tsx +7 -2
- package/src/session/UserSession.ts +38 -9
- package/src/session/UserSessionProvider.tsx +3 -2
- package/src/shell/apps/AppProjectSelector.tsx +2 -2
- package/src/shell/apps/StandaloneApp.tsx +3 -3
- package/src/shell/login/InviteAcceptModal.tsx +6 -6
- package/src/shell/login/SignInModal.tsx +1 -1
- package/src/shell/login/SignupForm.tsx +3 -3
- package/src/shell/login/UserInfo.tsx +5 -5
- package/src/widgets/json-view/JSONCode.tsx +1 -3
- package/src/widgets/json-view/JSONDisplay.tsx +1 -1
- package/src/widgets/markdown/ArtifactContentRenderer.tsx +115 -14
- package/src/widgets/markdown/MarkdownFigure.tsx +100 -0
- package/src/widgets/markdown/MarkdownRenderer.tsx +62 -9
- package/src/widgets/markdown/MermaidDiagram.tsx +97 -5
- package/src/widgets/markdown/codeBlockHandlers.test.tsx +3 -34
- package/src/widgets/markdown/codeBlockHandlers.tsx +47 -42
- package/src/widgets/markdown/index.ts +1 -0
- package/src/widgets/markdown/markdown.css +192 -0
- package/src/widgets/markdown/normalizeCustomSchemeLinks.test.ts +86 -0
- package/src/widgets/markdown/normalizeCustomSchemeLinks.ts +91 -0
- package/src/widgets/markdown/normalizeDirectives.ts +50 -0
- package/src/widgets/markdown/remarkDirectiveHandler.ts +119 -0
- package/src/widgets/monacoEditor/MonacoEditor.tsx +8 -22
- package/src/widgets/schema-editor/ManagedSchema.ts +1 -1
- package/src/widgets/schema-editor/editor/PropertyEditor.tsx +5 -5
- package/src/widgets/schema-editor/json-schema4-utils.ts +1 -1
- package/lib/esm/core/components/Badge.js.map +0 -1
- package/lib/esm/core/components/Button.js +0 -32
- package/lib/esm/core/components/Button.js.map +0 -1
- package/lib/esm/core/components/ConfirmModal.js +0 -10
- package/lib/esm/core/components/ConfirmModal.js.map +0 -1
- package/lib/esm/core/components/DeleteModal.js.map +0 -1
- package/lib/esm/core/components/MessageBox.js.map +0 -1
- package/lib/esm/core/components/Modal.js +0 -26
- package/lib/esm/core/components/Modal.js.map +0 -1
- package/lib/esm/core/components/Panel.js +0 -8
- package/lib/esm/core/components/Panel.js.map +0 -1
- package/lib/esm/core/components/SelectBox.js +0 -67
- package/lib/esm/core/components/SelectBox.js.map +0 -1
- package/lib/esm/core/components/shadcn/dialog.js.map +0 -1
- package/lib/esm/core/components/tabs/Tabs.js +0 -78
- package/lib/esm/core/components/tabs/Tabs.js.map +0 -1
- package/lib/esm/core/components/tabs/TabsContext.js +0 -7
- package/lib/esm/core/components/tabs/TabsContext.js.map +0 -1
- package/lib/esm/core/components/tabs/index.js +0 -3
- package/lib/esm/core/components/tabs/index.js.map +0 -1
- package/lib/esm/features/agent/createChartTool.js +0 -632
- package/lib/esm/features/agent/createChartTool.js.map +0 -1
- package/lib/esm/features/agent/examples.js +0 -295
- package/lib/esm/features/agent/examples.js.map +0 -1
- package/lib/esm/features/agent/visualization.js +0 -165
- package/lib/esm/features/agent/visualization.js.map +0 -1
- package/lib/esm/features/store/objects/components/useDownloadObject.js +0 -21
- package/lib/esm/features/store/objects/components/useDownloadObject.js.map +0 -1
- package/lib/types/core/components/Badge.d.ts.map +0 -1
- package/lib/types/core/components/Button.d.ts +0 -14
- package/lib/types/core/components/Button.d.ts.map +0 -1
- package/lib/types/core/components/ConfirmModal.d.ts.map +0 -1
- package/lib/types/core/components/DeleteModal.d.ts.map +0 -1
- package/lib/types/core/components/MessageBox.d.ts.map +0 -1
- package/lib/types/core/components/Modal.d.ts +0 -30
- package/lib/types/core/components/Modal.d.ts.map +0 -1
- package/lib/types/core/components/Panel.d.ts.map +0 -1
- package/lib/types/core/components/SelectBox.d.ts +0 -36
- package/lib/types/core/components/SelectBox.d.ts.map +0 -1
- package/lib/types/core/components/shadcn/dialog.d.ts.map +0 -1
- package/lib/types/core/components/tabs/Tabs.d.ts +0 -25
- package/lib/types/core/components/tabs/Tabs.d.ts.map +0 -1
- package/lib/types/core/components/tabs/TabsContext.d.ts +0 -17
- package/lib/types/core/components/tabs/TabsContext.d.ts.map +0 -1
- package/lib/types/core/components/tabs/index.d.ts +0 -3
- package/lib/types/core/components/tabs/index.d.ts.map +0 -1
- package/lib/types/features/agent/createChartTool.d.ts +0 -178
- package/lib/types/features/agent/createChartTool.d.ts.map +0 -1
- package/lib/types/features/agent/examples.d.ts +0 -59
- package/lib/types/features/agent/examples.d.ts.map +0 -1
- package/lib/types/features/agent/visualization.d.ts +0 -95
- package/lib/types/features/agent/visualization.d.ts.map +0 -1
- package/lib/types/features/store/objects/components/useDownloadObject.d.ts +0 -4
- package/lib/types/features/store/objects/components/useDownloadObject.d.ts.map +0 -1
- package/src/core/components/Button.tsx +0 -63
- package/src/core/components/Modal.tsx +0 -144
- package/src/core/components/Panel.tsx +0 -34
- package/src/core/components/SelectBox.tsx +0 -188
- package/src/core/components/tabs/Tabs.tsx +0 -132
- package/src/core/components/tabs/TabsContext.ts +0 -25
- package/src/core/components/tabs/index.ts +0 -2
- package/src/features/agent/CHART_INSTRUCTIONS.md +0 -228
- package/src/features/agent/createChartTool.ts +0 -643
- package/src/features/agent/examples.ts +0 -321
- package/src/features/agent/visualization.ts +0 -227
- package/src/features/store/objects/components/useDownloadObject.ts +0 -29
- /package/lib/esm/core/components/{MessageBox.js → shadcn/MessageBox.js} +0 -0
- /package/lib/types/core/components/{MessageBox.d.ts → shadcn/MessageBox.d.ts} +0 -0
- /package/lib/types/core/components/{ConfirmModal.d.ts → shadcn/modal/ConfirmModal.d.ts} +0 -0
- /package/lib/types/core/components/{DeleteModal.d.ts → shadcn/modal/DeleteModal.d.ts} +0 -0
- /package/src/core/components/{MessageBox.tsx → shadcn/MessageBox.tsx} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{Editor as a}from"@monaco-editor/react";import{useTheme as n,Styles as i,FormItem as s,Button as o,DotBadge as l,Table as c,VTooltip as d,VSelectBox as u,VModal as h,VModalTitle as m,ModalBody as p,ModalFooter as f,useFlag as g,useClickOutside as y,useToast as b}from"@vertesia/ui/core";import v from"debounce";import x,{clsx as w}from"clsx";import N,{useState as k,useRef as C,useEffect as S,useMemo as A,useCallback as j,createContext as O,useContext as I,memo as P,Component as L,useId as $,Children as E,isValidElement as R}from"react";import{Plus as F,Trash2 as T,Code as z,FileText as D,Table as V,Download as q,Link as K,Image as U,MessageSquare as M,GitBranch as _,BarChart3 as W,Loader2 as J,Check as B,Copy as H,Minimize2 as G,Maximize2 as Z,X,CheckCircle as Y,AlertCircle as Q,HelpCircle as ee,Send as te,Info as re,AlignLeft as ae,SquarePen as ne,ChevronDown as ie,ChevronRight as se,UploadIcon as oe,CheckCircleIcon as le,AlertCircleIcon as ce,XCircleIcon as de}from"lucide-react";import ue from"ajv";import he from"ajv-formats";import me,{defaultUrlTransform as pe}from"react-markdown";import fe from"remark-gfm";import{visit as ge,SKIP as ye}from"unist-util-visit";import{useUserSession as be}from"@vertesia/ui/session";import{toPng as ve}from"html-to-image";import*as xe from"@radix-ui/react-dialog";import we from"papaparse";import{VegaEmbed as Ne}from"react-vega";import{twMerge as ke}from"tailwind-merge";import{XAxis as Ce,YAxis as Se,CartesianGrid as Ae,Tooltip as je,Legend as Oe,ReferenceLine as Ie,ResponsiveContainer as Pe,ComposedChart as Le,AreaChart as $e,LineChart as Ee,BarChart as Re,Line as Fe,Area as Te,Bar as ze,PieChart as De,Pie as Ve,Cell as qe,ScatterChart as Ke,Scatter as Ue,RadarChart as Me,PolarGrid as _e,PolarAngleAxis as We,PolarRadiusAxis as Je,Radar as Be,RadialBarChart as He,RadialBar as Ge,FunnelChart as Ze,Funnel as Xe,LabelList as Ye,Treemap as Qe}from"recharts";import et from"mermaid";import{FusionFragmentProvider as tt,FusionFragmentHandler as rt}from"@vertesia/fusion-ux";import{offset as at,shift as nt,flip as it}from"@floating-ui/dom";import{useFloating as st,autoUpdate as ot,useDismiss as lt,useClick as ct,useHover as dt,useInteractions as ut,useTransitionStyles as ht,FloatingPortal as mt,FloatingFocusManager as pt,safePolygon as ft}from"@floating-ui/react";import{XMLParser as gt,XMLValidator as yt}from"fast-xml-parser";import{isNil as bt,omit as vt}from"lodash-es";class xt{VgetValue;VsetValue;constructor(e,t){this.VgetValue=e,this.VsetValue=t}getValue(){return this.VgetValue()}setValue(e){this.VsetValue(e||"")}}function wt({onChange:t,value:r="",className:i,editorRef:s,language:o="javascript",debounceTimeout:l=0,options:c={},beforeMount:d,onMount:u,defaultValue:h,minLines:m=10,maxLines:p}){const[f,g]=k(r),y=C(null),{theme:b}=n(),w=C(()=>f),N=C(e=>{g(e),y.current&&y.current.setValue(e)});S(()=>{w.current=()=>f},[f]),S(()=>(s&&(s.current=new xt(()=>w.current(),e=>N.current(e))),()=>{s&&(s.current=void 0)}),[s]);const O=A(()=>{if(t)return l>0?v(e=>t(e),l):t},[t,l]),I=j(e=>{const t=e||"";if(g(t),O){const e={docChanged:!0,state:{doc:{toString:()=>t,length:t.length}}};O(e)}},[O]),P=j((e,t)=>{y.current=e,N.current=t=>{g(t),e.setValue(t)},t.editor.defineTheme("errorLineTheme",{base:"dark"===b?"vs-dark":"vs",inherit:!0,rules:[],colors:{"editorError.background":"#ffebee","editorError.border":"#f44336"}}),t.editor.setTheme("errorLineTheme"),u?.(e,t)},[u,b]);S(()=>{r!==f&&(g(r),y.current&&y.current.setValue(r))},[r]);const L={fontSize:14,fontFamily:"monospace",minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",lineNumbers:"on",folding:!1,lineDecorationsWidth:0,lineNumbersMinChars:3,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2,insertSpaces:!0,glyphMargin:!0,renderValidationDecorations:"on",renderLineHighlight:"line",hover:{enabled:!0,delay:100},quickSuggestions:{other:!0,comments:!0,strings:!0},...c},$=19*(p||m)+20;return e("div",{className:x(i,"w-full"),style:{height:`${$}px`},children:e(a,{className:"h-full w-full",height:"100%",theme:"dark"===b?"vs-dark":"light",language:o,value:f,onChange:I,onMount:P,beforeMount:d,options:L,defaultValue:h||""})})}const Nt=O(void 0),kt=Nt.Provider;function Ct(){const e=I(Nt);if(!e)throw new Error("useFieldSet must be used within a Form or FieldSet element");return e}class St{object;components;disabled;constructor(e,t={},r=!1){this.object=e,this.components=t,this.disabled=r}}const At=O(void 0);function jt(){const e=I(At);if(!e)throw new Error("useForm must be used within a Form element");return e}const Ot=At.Provider,It=N.forwardRef(({object:t,type:r="text",onChange:a,...n},s)=>{const[o,l]=k(null!=t.value?String(t.value):""),[c,d]=k(t.schema.isBoolean&&!0===t.value);n.className?n.className=x(i.INPUT,n.className):n.className=i.INPUT;const u=e=>{n.disabled||(l(e.target.value),t.schema.isBoolean?(t.value=e.target.checked,d(t.value)):t.value=e.target.value,a&&a(e))};return"textarea"===r?e("textarea",{ref:s,...n,value:o,onChange:u}):e("input","checkbox"===r?{ref:s,...n,type:"checkbox",checked:c,onChange:u,className:"form-check-input"}:{ref:s,...n,type:r,value:o,onChange:u})});function Pt({object:t,components:r,onSubmit:a,children:n,onChange:i,disabled:s}){return t.observer=i,e(Ot,{value:new St(t,r||{},s??!1),children:e("form",{className:"w-full",onSubmit:e=>{e.stopPropagation(),e.preventDefault(),a&&a(t.value)},children:n})})}function Lt(){const t=jt();return e("div",{className:"flex flex-col gap-4 w-full",children:t.object.properties.map(Et)})}function $t({children:r,...a}){return t(Pt,{...a,children:[e(Lt,{}),r]})}function Et(t){return t.isList?e(Tt,{object:t},t.name):t.isObject?e(Ft,{object:t},t.name):e(Rt,{object:t},t.name)}function Rt({object:t,editor:r,inline:a=!1}){r||(r=t.schema.editor);const{components:n,disabled:i}=jt(),o=r&&n[r]||It,l=t.getInputType();"checkbox"===l&&(a=!0);const c=e=>{i||(t.schema.isBoolean?t.value=e.target.checked:t.schema.isNumber?t.value=parseFloat(e.target.value):t.value=e.target.value)};return t.isListItem?e(o,{object:t,type:l,onChange:c,disabled:i}):e(s,{label:t.title,required:t.schema.isRequired,description:t.schema.description,className:x("flex",a?"flex-row items-center":"flex-col"),children:e(o,{object:t,type:l,onChange:c,disabled:i})})}function Ft({object:r}){return t("div",{className:"flex flex-col gap-4 my-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 dark:border-l-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.properties.map(Et)]})}function Tt({object:r}){const[a,n]=k(r.value||[]),{disabled:i}=jt();return t("div",{className:"flex flex-col gap-4 my-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 darK:border-l-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.items.map((t,s)=>e(zt,{object:t,list:r,onDelete:()=>(e=>{i||(r.remove(e),n([...r.value]))})(s),disabled:i},`${s}-${a[s]??""}`)),e("div",{children:t(o,{variant:"secondary",onClick:()=>{i||(r.add(),n([...r.value]))},disabled:i,children:[e(F,{className:"size-6"})," Add"]})})]})}function zt({list:r,object:a,onDelete:n,disabled:i}){return t("div",{className:"flex gap-2 w-full",children:[e("div",{className:"flex-1",children:(s=a,l=r.schema.arraySchema.editor,s.isList?e(Tt,{object:s}):s.isObject?e(Ft,{object:s}):e(Rt,{object:s,editor:l}))}),e(o,{variant:"secondary",onClick:n,disabled:i,children:e(T,{className:"size-4"})})]});var s,l}class Dt{schema;properties={};_validator;constructor(e){this.schema=e||{type:"object",properties:{}},this.load()}get validator(){if(!this._validator){const e=new ue({allErrors:!0,strict:!1});he(e),this._validator=e.compile(this.schema)}return this._validator}load(){if(this.schema.properties){const e=this.schema.properties;Object.keys(e).forEach(t=>{this.loadProperty(t,e[t])})}}hasProperties(){return Object.keys(this.properties).length>0}get title(){return this.schema.title||this.schema.name}get description(){return this.schema.description}loadProperty(e,t){let r;return r="array"===t.type?new qt(this,e,t):new Vt(this,e,t),this.properties[e]=r,r}get type(){return this.schema.type}validate(e){return this.validator(e)?null:this.validator.errors||[]}addProperty(e,t,r=!1){"object"!==this.schema.type&&(this.schema.type="object"),this.schema.properties||(this.schema.properties={});const a="string"==typeof t?"object"===(n=t)?{type:"object",properties:{}}:"array"===n?{type:"array",items:{}}:{type:n}:t;var n;const i=this.loadProperty(e,a);return this.schema.properties[i.name]=i.schema,r&&(i.isRequired=!0),i}removeProperty(e){this.schema.properties&&(delete this.schema.properties[e],Array.isArray(this.schema.required)&&(this.schema.required=this.schema.required.filter(t=>t!==e))),delete this.properties[e]}getProperty(e){return this.properties[e]}get editor(){return this.schema.editor}}class Vt extends Dt{parent;name;constructor(e,t,r){if(super(r),this.parent=e,this.name=t,"array"===r.type)throw new Error("Array property must be instantiated using ArrayPropertySchema");"object"!==r.type||r.properties||(r.properties={})}get isMulti(){return!1}get isReadOnly(){return!!this.schema.readOnly}set isReadOnly(e){this.schema.readOnly=e}get defaultValue(){return this.schema.default}set defaultValue(e){this.schema.default=e}get enum(){return this.schema.enum}set enum(e){this.schema.enum=e}get isRequired(){const e=this.parent.schema.required;return!!e&&e.includes(this.name)}set isRequired(e){let t=Array.isArray(this.parent.schema.required)?this.parent.schema.required:[];t=e?t.concat(this.name):t.filter(e=>e!==this.name),this.parent.schema.required=t}get type(){return this.schema.type}set type(e){this.schema.type!==e&&(this.schema.type=e,"object"!==e&&(this.properties={},this.schema.properties=void 0))}remove(){this.parent.removeProperty(this.name)}get isBoolean(){return"boolean"===this.type}get isString(){return"string"===this.type}get isNumber(){return"number"===this.type||"integer"===this.type}get isObject(){return"object"===this.type}}class qt extends Vt{arraySchema;constructor(e,t,r){super(e,t,function(e){if("array"!==e.type)throw new Error("Expecting an array schema");if(e.items){if(Array.isArray(e.items))throw new Error("Tuple arrays are not supported")}else e.items={};return e.items}(r)),this.arraySchema=r}get isMulti(){return!0}}function Kt(e){return(e=e.replace(/_/g," ").replace(/([a-z0-9])&([A-Z])/g,"$1 $2"))[0].toUpperCase()+e.slice(1)}function Ut(e,t){if(t.editor)return t.editor;if(t.schema.format)return t.schema.format;switch(t.type){case"number":case"integer":return"number";case"boolean":return"checkbox";default:return"text"}}class Mt{parent;schema;name;observer;constructor(e,t,r){this.parent=e,this.schema=t,this.name=r}get isRoot(){return!this.parent}get root(){return this.parent?this.parent.root:this}get path(){return this.parent?this.parent.path.concat(this.name):[]}get isScalar(){return!1}get isListItem(){return!1}get isObject(){return!1}get isList(){return!1}get title(){return this.schema.title||Kt(this.name)}onChange(e){this.observer&&!1===this.observer(this)||this.parent&&this.parent.onChange(e)}}class _t extends Mt{constructor(e,t,r){super(e,t,r)}get isObject(){return!0}getProperty(e){const t=this.schema.properties[e];return t.isMulti?new Ht(this,t,this.getOrInitArrayProperty(e)):t.isObject?new Jt(this,t,t.name,this.getOrInitObjectProperty(e)):new Bt(this,t)}getOrInitObjectProperty(e){let t=this.value[e];return t||(this.value[e]=t={}),t}getOrInitArrayProperty(e){let t=this.value[e];return t||(this.value[e]=t=[]),t}setPropertyValue(e,t){return this.value[e]!==t&&(this.value[e]=t,!0)}getPropertyValue(e){return this.value[e]}get properties(){const e=[];for(const t of Object.values(this.schema.properties))t.isMulti?e.push(new Ht(this,t,this.getOrInitArrayProperty(t.name))):t.isObject?e.push(new Jt(this,t,t.name,this.getOrInitObjectProperty(t.name))):e.push(new Bt(this,t));return e}[Symbol.iterator](){return this.properties[Symbol.iterator]()}}class Wt extends _t{value;constructor(e,t={}){super(null,e instanceof Dt?e:new Dt(e),"#root"),this.value=t}}class Jt extends _t{value;constructor(e,t,r,a){super(e,t,r),this.value=a}}class Bt extends Mt{constructor(e,t){super(e,t,t.name),void 0===e.value[this.name]&&void 0!==t.defaultValue&&(e.value[this.name]=t.defaultValue)}get isScalar(){return!0}set value(e){this.parent.setPropertyValue(this.name,e)&&this.onChange(this)}get value(){return this.parent.getPropertyValue(this.name)}getInputType(){return Ut(this.name,this.schema)}}class Ht extends Mt{value;items=[];constructor(e,t,r){super(e,t,t.name),this.value=r;for(const e of this.value)this.add()}get isList(){return!0}newItem(e){return this.schema.isObject?new Gt(this,e):new Zt(this,e)}add(){const e=this.newItem(this.items.length);return this.items.push(e),e}remove(e){const t=this.value;if(e>=0&&e<this.items.length){this.items.splice(e,1);for(let e=0,t=this.items.length;e<t;e++){const t=this.items[e];t.index=e,t.name=String(e)}}Array.isArray(t)&&e>=0&&e<t.length&&(t.splice(e,1),this.onChange(this))}[Symbol.iterator](){return this.items[Symbol.iterator]()}item(e){if(e<0||e>=this.value.length)return;const t=this.value[e];return this.schema.isObject?new Jt(this,this.schema,String(e),t):new Zt(this,e)}trim(){for(;void 0===this.items[this.items.length-1];)this.items.pop()}}class Gt extends _t{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&(e.value[t]={}),this.key=this.name+"@"+Date.now()}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}}class Zt extends Mt{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&void 0!==e.schema.defaultValue&&(e.value[t]=e.schema.defaultValue),this.key=this.name+"@"+Date.now()}get isScalar(){return!0}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}getInputType(){return Ut(this.name,this.schema)}}function Xt({label:t,required:r,children:a}){return e(s,{label:t,required:r,children:a})}function Yt({children:t}){return e("p",{className:"mt-2 text-sm text-gray-500",children:t})}function Qt({children:t}){return e("p",{className:"mt-2 text-sm text-red-600",children:t})}function er({data:t,className:r}){const{theme:a}=n(),i=A(()=>{try{return JSON.stringify(t,null,2)}catch(e){return console.error("Failed to stringify JSON:",e),"{}"}},[t]);return e("div",{className:r,children:e(wt,{value:i,language:"json",theme:"dark"===a?"vs-dark":"vs",minLines:10,maxLines:50,options:{readOnly:!0,domReadOnly:!0}})})}function tr({value:t}){return e("div",{className:"flex flex-col gap-4",children:Object.entries(t).map(([t,r])=>e(nr,{name:t,value:r},t))})}function rr({name:t}){return e("div",{className:"text-md font-semibold",children:Kt(t)})}function ar({children:t,className:r}){return e("div",{className:x("flex flex-col gap-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 dark:border-l-slate-600",r),children:t})}function nr({name:r,value:a}){const n=lr(a);switch(n.type){case or.Inline:return t("div",{className:"w-full flex gap-2",children:[e(rr,{name:r+":"}),e("p",{children:n.value})]});case or.Paragraph:return t("div",{children:[e(rr,{name:r}),e("p",{children:n.value})]});case or.Prose:return t("div",{className:"prose dark:prose-invert",children:[e(rr,{name:r}),e("div",{className:"vprose dark:prose-invert",children:n.value})]});case or.Array:return e(ir,{name:r,value:a});case or.Object:return t("div",{children:[e(rr,{name:r}),e(ar,{className:"mt-2",children:Object.entries(a).map(([t,r])=>e(nr,{name:t,value:r},t))})]})}}function ir({name:r,value:a}){const n=a.join(" ").length,i=n/a.length,s="string"==typeof a[0]&&(n<80||n<400&&i<32),o=a.length>9;return t("div",s?{className:"flex gap-2 flex-wrap",children:[r&&e(rr,{name:r+":"}),a.map((t,r)=>e(l,{children:String(t)},r))]}:{children:[r&&e(rr,{name:r}),e("div",{className:"flex flex-col gap-2",children:a.map((t,r)=>e(sr,{index:r,value:t,useBullet:o},r))})]})}function sr({index:r,value:a,useBullet:n}){const i=n?e("span",{className:"text-xl",children:"•"}):t("span",{children:[r+1,"."]}),s=lr(a);let o;switch(s.type){case or.Object:o=e(ar,{children:Object.entries(a).map(([t,r])=>e(nr,{name:t,value:r},t))});break;case or.Array:o=e(ir,{value:a});break;case or.Prose:o=e("div",{className:"prose dark:prose-invert",children:s.value});break;default:o=e("div",{children:s.value})}return t("div",{className:"flex gap-4 hover:bg-slate-50 dark:hover:bg-slate-800 py-2 pr-2 pl-4",children:[e("div",{className:"font-semibold text-gray-600 dark:text-gray-400",children:i}),e("div",{children:o})]})}var or;function lr(e){if(null==e)return{value:"-",type:or.Inline};if(Array.isArray(e))return{value:e,type:or.Array};const t=typeof e;if("string"===t){const t=e.length;let r;return t<80?r=or.Inline:t>400?r=or.Prose:(r=or.Paragraph,e=e.replace(/(?:\n\n)+/g,"\n\n")),{type:r,value:e}}return"number"===t||"boolean"===t?{value:String(e),type:or.Inline}:{value:e,type:or.Object}}function cr({value:t,viewCode:r=!1}){return t?e("div",{className:"relative w-full",children:r?e(er,{data:t}):e(tr,{value:t})}):e("pre",{className:"whitespace-pre-wrap",children:"No Data to display"})}!function(e){e[e.Inline=0]="Inline",e[e.Paragraph=1]="Paragraph",e[e.Prose=2]="Prose",e[e.Array=3]="Array",e[e.Object=4]="Object"}(or||(or={}));class dr{components={};registerComponent(e,t){this.components[e]=t}getComponent(e){return this.components[e]}}const ur=O(null);function hr({components:t,children:a}){const n=A(()=>{const e=new dr;for(const[r,a]of Object.entries(t))e.registerComponent(r,a);return e},[t]);return e(r,{children:e(ur.Provider,{value:n,children:a})})}function mr(){return I(ur)}function pr(e){const t=I(ur);if(t)return t.getComponent(e)}const fr=O(null);function gr(){return I(fr)}function yr(e,t,r="inline"){return`artifact:${e}:${t}:${r}`}function br(e){return`file:${e}`}function vr(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:e.slice(6).trim()}:e.startsWith("document://")?{scheme:"document",path:e.slice(11).trim()}:e.startsWith("collection:")?{scheme:"collection",path:e.slice(11).trim()}:{scheme:"standard",path:e}}function xr(e,t){switch(e){case"store":case"document":return t?`/store/objects/${t}`:null;case"collection":return t?`/store/collections/${t}`:null;default:return null}}function wr({rawUrl:e,artifactRunId:t,disposition:r="inline"}){const{client:a}=be(),n=gr(),i=C(a);i.current=a;const s=C(n);s.current=n;const{scheme:o,path:l}=vr(e),c=xr(o,l),[d,u]=k(()=>{if(c)return{url:c,isLoading:!1,error:void 0};if("standard"===o)return{url:e,isLoading:!1,error:void 0};if(n&&("artifact"===o||"image"===o)){let e;e="artifact"===o&&t&&!l.startsWith("agents/")?yr(t,l,r):br(l);const a=n.getUrl(e);if(a)return{url:a,isLoading:!1,error:void 0}}return{url:void 0,isLoading:!0,error:void 0}}),[h,m]=k(0),p=j(async()=>{if(c||"standard"===o)return;if("artifact"!==o&&"image"!==o)return void u({url:void 0,isLoading:!1,error:`Unknown scheme: ${o}`});u(e=>({...e,isLoading:!0,error:void 0}));const e=i.current,a=s.current;try{let n;if("artifact"===o)if(t&&!l.startsWith("agents/")){const i=yr(t,l,r);if(a)n=await a.getOrFetch(i,async()=>(await e.files.getArtifactDownloadUrl(t,l,r)).url);else{n=(await e.files.getArtifactDownloadUrl(t,l,r)).url}}else{const t=br(l);if(a)n=await a.getOrFetch(t,async()=>(await e.files.getDownloadUrl(l)).url);else{n=(await e.files.getDownloadUrl(l)).url}}else{const t=br(l);if(a)n=await a.getOrFetch(t,async()=>(await e.files.getDownloadUrl(l)).url);else{n=(await e.files.getDownloadUrl(l)).url}}u({url:n,isLoading:!1,error:void 0})}catch(e){const t=e instanceof Error?e.message:"Failed to resolve URL";console.error("Failed to resolve URL:",l,e),u({url:void 0,isLoading:!1,error:t})}},[o,l,t,r,c]);S(()=>{if(d.url&&!d.error)return;let e=!1;return e||(async()=>{await p()})(),()=>{e=!0}},[p,h,d.url,d.error]);const f=j(()=>{u({url:void 0,isLoading:!0,error:void 0}),m(e=>e+1)},[]);return{url:d.url,isLoading:d.isLoading,error:d.error,scheme:o,retry:f}}const Nr={chart:{icon:W,label:"chart",defaultHeight:200},mermaid:{icon:_,label:"diagram",defaultHeight:150},proposal:{icon:M,label:"options",defaultHeight:100},code:{icon:z,label:"code",defaultHeight:80},image:{icon:U,label:"image",defaultHeight:150},link:{icon:K,label:"link",defaultHeight:24},expand:{icon:q,label:"content",defaultHeight:100},table:{icon:V,label:"table",defaultHeight:150},markdown:{icon:D,label:"content",defaultHeight:100},"fusion-fragment":{icon:z,label:"fragment",defaultHeight:150}};function kr({type:r,error:a,onRetry:n,message:i,height:s}){const o=Nr[r],l=s??o.defaultHeight,c="link"===r;if(a)return t("div",{className:"flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive "+(c?"inline-flex px-2 py-1 text-sm":"p-4"),style:c?void 0:{minHeight:l},children:[t("span",{className:"text-destructive",children:["Failed to load ",o.label]}),n&&e("button",{onClick:n,className:"ml-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors",children:"Retry"})]});const d=o.icon;return c?t("span",{className:"inline-flex items-center gap-1 text-muted animate-pulse",children:[e(d,{className:"h-3 w-3"}),e("span",{children:i||`Loading ${o.label}...`})]}):t("div",{className:"flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse",style:{minHeight:l},children:[e(d,{className:"h-8 w-8 text-muted"}),e("span",{className:"text-sm text-muted",children:i||`Loading ${o.label}...`}),e("div",{className:"flex gap-1",children:[...Array(3)].map((t,r)=>e("div",{className:"h-2 w-2 rounded-full bg-muted animate-bounce",style:{animationDelay:150*r+"ms"}},r))})]})}class Cr extends N.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){const{type:r,fallbackCode:a}=this.props;return t("div",{className:"space-y-2",children:[e(kr,{type:r,error:this.state.error?.message||"Rendering failed",onRetry:this.handleRetry}),a&&t("details",{className:"text-sm",children:[e("summary",{className:"cursor-pointer text-muted hover:text-foreground",children:"Show raw content"}),e("pre",{className:"mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs",children:e("code",{children:a})})]})]})}return this.props.children}}function Sr({node:t,href:r,children:a,className:n,artifactRunId:i,ExistingLink:s,...o}){const l=r||"",{scheme:c,path:d}=vr(l),u=xr(c,d);return u?"function"==typeof s?e(s,{node:t,href:u,...o,children:a}):e("a",{href:u,...o,className:n,target:"_blank",rel:"noopener noreferrer",children:a}):"standard"===c?"function"==typeof s?e(s,{node:t,href:r,...o,children:a}):e("a",{href:r,...o,className:n,target:"_blank",rel:"noopener noreferrer",children:a}):e(Ar,{rawHref:l,artifactRunId:i,className:n,rest:o,children:a})}function Ar({rawHref:t,artifactRunId:r,className:a,children:n,rest:i}){const{url:s,isLoading:o,error:l,retry:c}=wr({rawUrl:t,artifactRunId:r,disposition:"attachment"});return o?e("span",{className:"inline-flex items-center gap-1 text-muted",children:e(kr,{type:"link"})}):l?e("span",{className:"inline-flex items-center gap-1",children:e(kr,{type:"link",error:l,onRetry:c})}):e("a",{href:s||"#",...i,className:a,target:"_blank",rel:"noopener noreferrer",children:n})}function jr({node:t,src:r,alt:a,className:n,artifactRunId:i,ExistingImg:s,...o}){const l=r||"",{scheme:c}=vr(l);return"standard"===c?"function"==typeof s?e(s,{node:t,src:r,alt:a,...o}):e("img",{src:r,alt:a,className:n,...o}):e(Or,{rawSrc:l,alt:a,artifactRunId:i,className:n,rest:o})}function Or({rawSrc:t,alt:r,artifactRunId:a,className:n,rest:i}){const{url:s,isLoading:o,error:l,retry:c}=wr({rawUrl:t,artifactRunId:a,disposition:"inline"});return o?e(kr,{type:"image",message:r?`Loading ${r}...`:void 0}):l?e(kr,{type:"image",error:l,onRetry:c}):s?e("img",{src:s,alt:r,className:n,...i}):null}function Ir(...e){return ke(w(e))}function Pr({error:r,chartTitle:a}){return e("div",{className:"flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4",children:t("div",{className:"text-center",children:[t("p",{className:"text-sm font-medium text-red-600 dark:text-red-400",children:["Cannot render ",a||"Vega-Lite"," chart"]}),e("p",{className:"text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate",children:r})]})})}function Lr({isOpen:r,onClose:a,title:n,description:i,children:s}){return e(xe.Root,{open:r,onOpenChange:e=>!e&&a(),children:t(xe.Portal,{children:[e(xe.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"}),t(xe.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:a,children:[e(xe.Close,{asChild:!0,children:e("button",{onClick:a,className:"absolute top-3 right-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":"Close fullscreen",children:e(X,{className:"w-5 h-5 text-gray-600 dark:text-gray-300"})})}),e("div",{className:"flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150",children:s}),e("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:t("div",{className:"flex flex-col",children:[e(xe.Title,{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:n||"Dashboard"}),i&&e(xe.Description,{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5",children:i})]})})]})]})})}const $r={categorical:["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"],blues:["#dbeafe","#93c5fd","#3b82f6","#1d4ed8","#1e3a8a"],purples:["#f3e8ff","#c4b5fd","#8b5cf6","#6d28d9","#4c1d95"],diverging:["#ef4444","#fca5a5","#fef3c7","#86efac","#22c55e"]};function Er(e,t){if(!e||!e.encoding)return!1;for(const r of t)for(const t of Object.values(e.encoding))if(t&&"object"==typeof t&&t.field===r)return!0;if(Array.isArray(e.layer))for(const r of e.layer)if(Er(r,t))return!0;return!1}function Rr(e,t){if(!e)return!1;const r=e=>{if(!e)return!1;const r=e.color?.field;return r&&t.includes(r)};if(r(e.encoding))return!0;if(Array.isArray(e.layer))for(const t of e.layer)if(r(t.encoding))return!0;return!1}function Fr(e,t=[]){const r=[];if(!e||"object"!=typeof e)return r;if(e.data&&"object"==typeof e.data){const a=e.data.url;"string"==typeof a&&a.startsWith("artifact:")&&r.push({path:[...t,"data"],artifactPath:a.replace(/^artifact:/,"").trim()})}const a=["layer","vconcat","hconcat","concat","spec","repeat","facet"];for(const n of a)if(n in e){const a=e[n];Array.isArray(a)?a.forEach((e,a)=>{r.push(...Fr(e,[...t,n,String(a)]))}):"object"==typeof a&&null!==a&&r.push(...Fr(a,[...t,n]))}return r}const Tr=P(function({spec:a,artifactRunId:n}){const{title:i,description:s,spec:o,options:l}=a,[c,d]=k(!1),[u,h]=k(!1),[m,p]=k(null),[f,g]=k(!1),y=C(null),b=C(null),v=C(null),{client:x}=be(),w=gr(),N=C(x);N.current=x;const O=C(w);O.current=w;const[I,P]=k(null),[L,$]=k(!1),[E,R]=k(null),F=l?.mode||"chart",T="dashboard"===F,z=l?.enableFullscreen??T,D=l?.height||function(e,t){if("chart"===t)return 280;let r=1;if(e.vconcat)r=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){const t=e.columns||2,a=Array.isArray(e.concat)?e.concat.length:1;r=Math.ceil(a/t)}else e.facet&&(r=2);return Math.max(500,280*r+40)}(o,F);S(()=>{const e=Fr(o);if(0===e.length)return P(o),$(!1),void R(null);let t=!1;$(!0),R(null);return(async()=>{const r=new Map,a=N.current,i=O.current;for(const s of e)try{const e=s.path.join(".");let t;if(n&&!s.artifactPath.startsWith("agents/")){const e=yr(n,s.artifactPath,"inline");if(i)t=await i.getOrFetch(e,async()=>(await a.files.getArtifactDownloadUrl(n,s.artifactPath,"inline")).url);else{t=(await a.files.getArtifactDownloadUrl(n,s.artifactPath,"inline")).url}}else{const e=br(s.artifactPath);if(i)t=await i.getOrFetch(e,async()=>(await a.files.getDownloadUrl(s.artifactPath)).url);else{t=(await a.files.getDownloadUrl(s.artifactPath)).url}}const o=await fetch(t);if(!o.ok)throw new Error(`Failed to fetch artifact data: ${o.statusText}`);let l;if(s.artifactPath.toLowerCase().endsWith(".csv")){const e=await o.text();l=we.parse(e,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{const e=await o.json();l=Array.isArray(e)?e:[e]}r.set(e,l)}catch(e){return console.error(`Failed to resolve artifact: ${s.artifactPath}`,e),void(t||R(`Failed to load data from artifact: ${s.artifactPath}`))}if(!t){const e=function(e,t){const r=JSON.parse(JSON.stringify(e));for(const[e,a]of t){const t=e.split(".");let n=r;for(let e=0;e<t.length-1&&void 0!==n[t[e]];e++)n=n[t[e]];const i=t[t.length-1];n[i]&&"object"==typeof n[i]&&(delete n[i].url,n[i].values=a)}return r}(o,r);P(e),$(!1)}})(),()=>{t=!0}},[o,n]);const[V,K]=k(!1),U=C(!1);S(()=>{const e=()=>{const e=document.documentElement.classList.contains("dark");e!==U.current&&(U.current=e,K(e))};e();const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const[M,_]=k(0),W=C(0);S(()=>{if(!v.current)return;let e;const t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{const e=t[0]?.contentRect.width;e&&e!==W.current&&(W.current=e,_(e))},100)});t.observe(v.current);const r=v.current.clientWidth;return W.current=r,_(r),()=>{clearTimeout(e),t.disconnect()}},[]);const X=A(()=>Fr(o).length>0,[o]),Y=A(()=>{if(X&&!I)return null;let e=I||o;return e?(l?.parameterValues&&(e=function(e,t){if(!t||0===Object.keys(t).length)return e;const r=JSON.parse(JSON.stringify(e)),a=e=>{for(const r of e)r&&"object"==typeof r&&r.name&&r.name in t&&(r.value=t[r.name])};Array.isArray(r.params)&&a(r.params);const n=e=>{if(Array.isArray(e))for(const t of e)if(t&&Array.isArray(t.params)&&a(t.params),t.vconcat&&n(t.vconcat),t.hconcat&&n(t.hconcat),t.concat&&n(t.concat),Array.isArray(t.layer))for(const e of t.layer)e&&Array.isArray(e.params)&&a(e.params)};if(r.vconcat&&n(r.vconcat),r.hconcat&&n(r.hconcat),r.concat&&n(r.concat),Array.isArray(r.layer))for(const e of r.layer)e&&Array.isArray(e.params)&&a(e.params);return r}(e,l.parameterValues)),function(e){const t=JSON.parse(JSON.stringify(e)),r=["vconcat","hconcat","concat"];if(!r.some(e=>Array.isArray(t[e])))return t;const a=[];if(Array.isArray(t.params))for(const e of t.params)e&&"object"==typeof e&&e.name&&e.select&&a.push({name:e.name,param:e});if(0===a.length)return t;for(const{name:e,param:n}of a){const a=n.select?.fields||[],i="legend"===n.select?.bind;let s=null;for(const e of r)if(Array.isArray(t[e])){s=t[e];break}if(!s||0===s.length)continue;let o=0;for(let e=0;e<s.length;e++){const t=s[e];if(Er(t,a)||i&&Rr(t,a)){o=e;break}}const l=s[o];l.params||(l.params=[]),l.params.push(n),t.params=t.params.filter(t=>t.name!==e)}return Array.isArray(t.params)&&0===t.params.length&&delete t.params,t}(e)):null},[I,o,X,l?.parameterValues]),Q=j((e,t)=>{if(!e||"object"!=typeof e)return e;if(e.hconcat&&Array.isArray(e.hconcat)){const r=e.hconcat.length,a=(e.spacing??10)*(r-1),n=Math.floor((t-a)/r);return{...e,hconcat:e.hconcat.map(e=>Q(e,n))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>Q(e,t))};if(e.concat&&Array.isArray(e.concat)){const r=e.columns??e.concat.length,a=(e.spacing??10)*(r-1),n=Math.floor((t-a)/r);return{...e,concat:e.concat.map(e=>Q(e,n))}}const r=e.width;return"container"===r||"number"==typeof r&&r>t?{...e,width:t}:e},[]),ee=j((e,t=!1)=>{if(!Y)return null;const r=function(e){const t={background:"transparent",view:{stroke:"transparent"},range:{category:$r.categorical,diverging:$r.diverging,heatmap:$r.purples,ramp:$r.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}}}(V),a=t?"undefined"!=typeof window?Math.min(window.innerWidth-80,1400):1200:M>0?M-24:500,n="vconcat"in Y||"hconcat"in Y||"concat"in Y,s=n?{type:"pad",contains:"padding"}:{type:"fit",contains:"padding"};let o=Y;n&&a&&(o=Q(Y,a));const l=o.width,c=n?void 0:"container"===l?a:l??a,{width:d,...u}=o;return{$schema:"https://vega.github.io/schema/vega-lite/v6.json",...!n&&c?{width:c}:{},height:t?void 0:e,autosize:s,...n?o:u,...i&&!Y.title?{title:i}:{},config:{...r,...Y.config}}},[Y,i,V,M,Q]),te=j(async()=>{const e=f?b.current:y.current;if(e&&!u)try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),h(!0),setTimeout(()=>h(!1),2e3))},"image/png")}catch(e){console.error("Failed to copy chart:",e)}},[u,f]),re=j(async()=>{const e=f?b.current:y.current;if(e&&!c){d(!0);try{const t=await e.toImageURL("png",2),r=document.createElement("a");r.download=`${i||"chart"}.png`,r.href=t,r.click()}catch(e){console.error("Failed to export chart:",e)}finally{d(!1)}}},[i,c,f]),ae=j(e=>{y.current=e,p(null)},[]),ne=j(e=>{b.current=e},[]),ie=j(e=>{console.error("Vega-Lite rendering error:",e),p(e instanceof Error?e.message:"Unknown error")},[]),se=j(()=>{g(e=>!e)},[]);S(()=>{p(null)},[o]);const oe=({className:r})=>t("div",{className:Ir("flex items-center gap-2",r),children:[t("button",{onClick:te,disabled:u,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:"Copy to clipboard",children:[e(u?B:H,{className:"w-3 h-3"}),u?"Copied":"Copy"]}),t("button",{onClick:re,disabled:c,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:"Export as PNG",children:[e(q,{className:"w-3 h-3"}),c?"Exporting...":"Export"]}),z&&t("button",{onClick:se,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:f?"Exit fullscreen":"Fullscreen",children:[e(f?G:Z,{className:"w-3 h-3"}),f?"Exit":"Fullscreen"]})]});if(L||X&&!I)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:i||"Chart"})}),e("div",{className:"flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded",style:{width:"100%",height:D},children:t("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e(J,{className:"w-5 h-5 animate-spin"}),e("span",{className:"text-sm",children:"Loading data from artifacts..."})]})})]})});if(E)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:i||"Chart"})}),e("div",{style:{width:"100%",height:D},children:e(Pr,{error:E,chartTitle:i})})]})});if(m)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:i||"Chart"})}),e("div",{style:{width:"100%",height:D},children:e(Pr,{error:m,chartTitle:i})})]})});const le=ee(D),ce=ee(0,!0);return le?("undefined"!=typeof window&&localStorage.getItem("DEBUG_VEGA_RENDERS")&&console.log("VegaLite rendering with spec:",{title:i,hasData:!!le.data?.values,dataLength:le.data?.values?.length}),t(r,{children:[e("div",{className:Ir("bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",T&&"border-2"),children:t("div",{className:"flex flex-col gap-2 p-3",children:[t("div",{className:"flex items-center justify-between",children:[t("div",{className:"flex items-center gap-2",children:[e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:i||(T?"Dashboard":"Chart")}),T&&e("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"})]}),e(oe,{})]}),s&&e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:s}),e("div",{ref:v,className:"bg-white dark:bg-gray-900 rounded overflow-hidden",style:{width:"100%",height:D,minWidth:0},children:e(Ne,{spec:le,onEmbed:e=>ae(e.view),onError:ie,options:{renderer:l?.renderer||"canvas",actions:!1}})})]})}),t(Lr,{isOpen:f,onClose:()=>g(!1),title:i||(T?"Dashboard":"Chart"),description:s,children:[e("div",{className:"w-full h-full min-h-[calc(100vh-200px)]",children:ce&&e(Ne,{spec:ce,onEmbed:e=>ne(e.view),onError:ie,options:{renderer:l?.renderer||"canvas",actions:!1}})}),e("div",{className:"absolute bottom-6 right-6",children:e(oe,{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),zr=["#4f46e5","#06b6d4","#22c55e","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6"];class Dr extends L{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`Chart rendering error (${this.props.chartType}):`,e,t)}render(){return this.state.hasError?e("div",{className:"flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4",children:t("div",{className:"text-center",children:[t("p",{className:"text-sm font-medium text-red-600 dark:text-red-400",children:["Cannot render ",this.props.chartType," chart"]}),e("p",{className:"text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate",children:this.state.error?.message||"Unknown error"})]})}):this.props.children}}function Vr(e){if(!isFinite(e))return String(e);const t=Math.abs(e);return t>=1e9?(e/1e9).toFixed(1)+"B":t>=1e6?(e/1e6).toFixed(1)+"M":t>=1e3?(e/1e3).toFixed(1)+"K":e.toLocaleString()}const qr=P(function({spec:t,artifactRunId:r}){return function(e){return"vega-lite"===e.library}(t)?e(Tr,{spec:t,artifactRunId:r}):e(Ur,{spec:t})},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function Kr(e){if(e.chart)return e.chart;const t={BarChart:"bar",LineChart:"line",AreaChart:"area",PieChart:"pie",ScatterChart:"scatter",RadarChart:"radar",FunnelChart:"funnel",Treemap:"treemap",ComposedChart:"composed",RadialBarChart:"radialBar"};return e.type&&t[e.type]?t[e.type]:"bar"}const Ur=P(function({spec:a}){const n={...a,chart:Kr(a),xKey:a.xKey||a.x_axis?.data_key||"name",series:a.series||a.bars?.map(e=>({key:e.data_key||e.dataKey,color:e.fill||e.color,label:e.name}))||a.lines?.map(e=>({key:e.data_key||e.dataKey,color:e.stroke||e.color,label:e.name}))||[]},{chart:i,title:s,description:o,data:l,xKey:c,series:d,yAxis:u,options:h,nameKey:m,valueKey:p,yKey:f,axisKey:g,dataKey:y}=n,[b,v]=k(!1),[x,w]=k(!1),N=C(null),S=j(async()=>{if(N.current&&!x)try{const e=await ve(N.current,{backgroundColor:"#ffffff",pixelRatio:2}),t=await fetch(e),r=await t.blob();await navigator.clipboard.write([new ClipboardItem({"image/png":r})]),w(!0),setTimeout(()=>w(!1),2e3)}catch(e){console.error("Failed to copy chart:",e)}},[x]),A=j(async()=>{if(N.current&&!b){v(!0);try{const e=await ve(N.current,{backgroundColor:"#ffffff",pixelRatio:2}),t=document.createElement("a");t.download=`${s||"chart"}.png`,t.href=e,t.click()}catch(e){console.error("Failed to export chart:",e)}finally{v(!1)}}},[s,b]),O=d||[],I=l||[],P=t(r,{children:[e(Ce,{dataKey:c,tick:{fontSize:12}}),e(Se,{yAxisId:"left",tickFormatter:Vr,label:u?.left?.label?{value:u.left.label,angle:-90,position:"insideLeft"}:void 0}),O.some(e=>"right"===e.yAxisId)&&e(Se,{yAxisId:"right",orientation:"right",tickFormatter:Vr,label:u?.right?.label?{value:u.right.label,angle:-90,position:"insideRight"}:void 0})]}),L=t(r,{children:[e(Ae,{strokeDasharray:"3 3"}),e(je,{formatter:e=>"number"==typeof e?Vr(e):String(e)}),e(Oe,{}),h?.referenceZero&&e(Ie,{y:0,stroke:"#999",strokeDasharray:"3 3"})]}),$=()=>O.map((t,r)=>{const a=t.color||zr[r%zr.length],n=t.yAxisId||"left";return"line"===i?e(Fe,{type:"monotone",dataKey:t.key,name:t.label||t.key,stroke:a,dot:t.dot??!1,yAxisId:n},t.key):"area"===i?e(Te,{type:"monotone",dataKey:t.key,name:t.label||t.key,stroke:a,fill:a,fillOpacity:.3,stackId:h?.stacked?t.stackId||"stack":void 0,yAxisId:n},t.key):"bar"===i||"bar"===t.type?e(ze,{dataKey:t.key,name:t.label||t.key,fill:a,stackId:h?.stacked?t.stackId||"stack":void 0,yAxisId:n},t.key):"area"===t.type?e(Te,{type:"monotone",dataKey:t.key,name:t.label||t.key,stroke:a,fill:a,fillOpacity:.3,stackId:h?.stacked?t.stackId||"stack":void 0,yAxisId:n},t.key):e(Fe,{type:"monotone",dataKey:t.key,name:t.label||t.key,stroke:a,dot:t.dot??!1,yAxisId:n},t.key)});return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm my-5",children:t("div",{className:"flex flex-col gap-2 p-4",children:[t("div",{className:"flex items-center justify-between",children:[e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:s||"Chart"}),t("div",{className:"flex items-center gap-2 print:hidden chart-actions",children:[t("button",{onClick:S,disabled:x,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:"Copy to clipboard",children:[e(x?B:H,{className:"w-3 h-3"}),x?"Copied":"Copy"]}),t("button",{onClick:A,disabled:b,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:"Export as PNG",children:[e(q,{className:"w-3 h-3"}),b?"Exporting...":"Export"]})]})]}),o&&e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:o}),e("div",{ref:N,className:"bg-white dark:bg-gray-900 rounded",style:{width:"100%",height:280,minWidth:0},children:e(Dr,{chartType:i,children:e(Pe,{width:"100%",height:"100%",children:(()=>{switch(i){case"bar":return t(Re,{data:I,children:[P,L,$()]});case"line":return t(Ee,{data:I,children:[P,L,$()]});case"area":return t($e,{data:I,children:[P,L,$()]});case"composed":default:return t(Le,{data:I,children:[P,L,$()]});case"pie":return t(De,{children:[e(Ve,{data:I,dataKey:p||"value",nameKey:m||"name",cx:"50%",cy:"50%",innerRadius:h?.innerRadius||0,outerRadius:100,label:!1!==h?.showLabels,children:I.map((t,r)=>e(qe,{fill:zr[r%zr.length]},`cell-${r}`))}),e(je,{formatter:e=>"number"==typeof e?Vr(e):String(e)}),e(Oe,{})]});case"scatter":return(()=>{const r=c,a=f||"y";return t(Ke,{children:[e(Ae,{strokeDasharray:"3 3"}),e(Ce,{dataKey:r,name:r,tick:{fontSize:12}}),e(Se,{dataKey:a,name:a,tickFormatter:Vr}),e(je,{formatter:e=>"number"==typeof e?Vr(e):String(e)}),e(Oe,{}),O.length>0?O.map((t,r)=>e(Ue,{name:t.label||t.key,data:I,fill:t.color||zr[r%zr.length]},t.key)):e(Ue,{name:"Data",data:I,fill:zr[0]})]})})();case"radar":return(()=>{const r=g||c;return t(Me,{cx:"50%",cy:"50%",outerRadius:100,data:I,children:[e(_e,{}),e(We,{dataKey:r,tick:{fontSize:11}}),e(Je,{tickFormatter:Vr}),O.map((t,r)=>e(Be,{name:t.label||t.key,dataKey:t.key,stroke:t.color||zr[r%zr.length],fill:t.color||zr[r%zr.length],fillOpacity:.3},t.key)),e(je,{formatter:e=>"number"==typeof e?Vr(e):String(e)}),e(Oe,{})]})})();case"radialBar":return(()=>{const r=m||"name",a=p||"value",n=h?.startAngle??180,i=h?.endAngle??0;return t(He,{cx:"50%",cy:"50%",innerRadius:h?.innerRadius??30,outerRadius:100,barSize:15,data:I,startAngle:n,endAngle:i,children:[e(Ge,{label:{position:"insideStart",fill:"#fff",fontSize:11},background:!0,dataKey:a,children:I.map((t,r)=>e(qe,{fill:zr[r%zr.length]},`cell-${r}`))}),e(je,{formatter:e=>"number"==typeof e?Vr(e):String(e)}),e(Oe,{iconSize:10,layout:"vertical",verticalAlign:"middle",align:"right",formatter:(e,t)=>{const n=I.find(n=>n[r]===e||n[a]===t.payload?.value);return n?n[r]:e}})]})})();case"funnel":return(()=>{const r=m||"name",a=p||"value";return t(Ze,{children:[e(je,{formatter:e=>"number"==typeof e?Vr(e):String(e)}),t(Xe,{dataKey:a,data:I,isAnimationActive:!0,children:[I.map((t,r)=>e(qe,{fill:zr[r%zr.length]},`cell-${r}`)),!1!==h?.showLabels&&e(Ye,{position:"center",fill:"#fff",stroke:"none",dataKey:r})]})]})})();case"treemap":return e(Qe,{data:I,dataKey:y||p||"value",aspectRatio:4/3,stroke:"#fff",fill:"#4f46e5",content:({x:a,y:n,width:i,height:s,name:o,value:l,index:c})=>t("g",{children:[e("rect",{x:a,y:n,width:i,height:s,style:{fill:zr[c%zr.length],stroke:"#fff",strokeWidth:2}}),i>50&&s>30&&t(r,{children:[e("text",{x:a+i/2,y:n+s/2-7,textAnchor:"middle",fill:"#fff",fontSize:12,children:o}),e("text",{x:a+i/2,y:n+s/2+10,textAnchor:"middle",fill:"#fff",fontSize:11,children:Vr(l)})]})]})})}})()})})})]})})},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec));function Mr({code:t,className:r}){const a=C(null),[n,i]=k(null),[s,o]=k(null),l=$().replace(/:/g,"_");return S(()=>{let e=!1;return(async()=>{if(!t.trim())return i(null),void o(null);try{o(null);const r=`mermaid-${l}-${Date.now()}`,{svg:a}=await et.render(r,t.trim());e||i(a)}catch(t){if(!e){const e=t instanceof Error?t.message:"Failed to render mermaid diagram";o(e),i(null)}}})(),()=>{e=!0}},[t,l]),s?null:e("div",n?{ref:a,className:`my-4 overflow-x-auto ${r||""}`,dangerouslySetInnerHTML:{__html:n}}:{className:`my-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg animate-pulse ${r||""}`,children:e("div",{className:"h-32 bg-gray-200 dark:bg-gray-700 rounded"})})}et.initialize({startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:"inherit",suppressErrorRendering:!0});const _r={default:{border:"border-l-attention",bg:"bg-amber-50 dark:bg-amber-900/20",icon:"text-attention"},warning:{border:"border-l-destructive",bg:"bg-red-50 dark:bg-red-900/20",icon:"text-destructive"},info:{border:"border-l-info",bg:"bg-blue-50 dark:bg-blue-900/20",icon:"text-info"},success:{border:"border-l-success",bg:"bg-green-50 dark:bg-green-900/20",icon:"text-success"}},Wr={default:ee,warning:Q,info:M,success:Y};function Jr({question:r,description:a,options:n,onSelect:i,onMultiSelect:s,onSubmit:l,allowFreeResponse:c=!1,multiSelect:d=!1,placeholder:u="Type your response...",isLoading:h=!1,icon:m,variant:p="default",hideIcon:f=!1,hideBorder:g=!1,className:y,cardClassName:b,headerClassName:v,iconClassName:x,questionClassName:w,descriptionClassName:k,optionsClassName:C,buttonClassName:S,inputContainerClassName:A,inputClassName:j,submitButtonClassName:O}){const[I,P]=N.useState(""),[L,$]=N.useState(new Set),E=N.useRef(null),R=_r[p],F=Wr[p],T=()=>{I.trim()&&l&&(l(I.trim()),P(""))},z=g?"":`border-l-4 ${R.border}`;return e("div",{className:`my-4 font-sans ${y||""}`,children:t("div",{className:`${z} ${R.bg} rounded-r-lg shadow-sm ${b||""}`,children:[e("div",{className:`px-4 py-3 ${v||""}`,children:t("div",{className:"flex items-start gap-3",children:[!f&&e("div",{className:`flex-shrink-0 mt-0.5 ${R.icon} ${x||""}`,children:m||e(F,{className:"size-5"})}),t("div",{className:"flex-1 min-w-0",children:[e("h4",{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 ${w||""}`,children:r}),a&&e("p",{className:`mt-1 text-sm text-gray-600 dark:text-gray-400 ${k||""}`,children:a})]})]})}),n&&n.length>0&&e("div",{className:`px-4 pb-3 pt-1 ${C||""}`,children:d?t("div",{className:"space-y-2",children:[n.map(r=>t("label",{className:`flex items-start gap-3 px-4 py-3 rounded-lg cursor-pointer transition-colors\n ${L.has(r.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"}\n ${h?"opacity-50 cursor-not-allowed":""}`,children:[e("input",{type:"checkbox",checked:L.has(r.id),onChange:()=>{return e=r.id,void $(t=>{const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r});var e},disabled:h,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"}),t("div",{className:"flex-1 overflow-hidden",children:[t("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100 break-words",children:[r.icon,e("span",{className:"break-words",children:r.label})]}),r.description&&e("div",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400 break-words whitespace-pre-wrap",children:r.description})]})]},r.id)),e("div",{className:"pt-2",children:t(o,{size:"sm",onClick:()=>{L.size>0&&s&&(s(Array.from(L)),$(new Set))},disabled:h||0===L.size,className:"flex items-center gap-2",children:[e(te,{className:"size-4"}),"Submit Selection",L.size>0?` (${L.size})`:""]})})]}):e("div",{className:"flex flex-col gap-2 w-full",children:n.map(r=>e("button",{onClick:()=>i?.(r.id),disabled:h,className:`w-full text-left px-4 py-3 rounded-lg border border-gray-200 dark:border-gray-700\n bg-white dark:bg-gray-800\n hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-600\n focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1\n transition-colors\n ${h?"opacity-50 cursor-not-allowed":"cursor-pointer"}\n ${S||""}`,children:t("div",{className:"flex items-start gap-3",children:[r.icon&&e("span",{className:"flex-shrink-0 mt-0.5 text-gray-500 dark:text-gray-400",children:r.icon}),t("div",{className:"flex-1 overflow-hidden",children:[e("div",{className:"font-medium text-sm text-gray-900 dark:text-gray-100 break-words",children:r.label}),r.description&&e("div",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400 break-words whitespace-pre-wrap",children:r.description})]})]})},r.id))})}),c&&e("div",{className:`px-4 pb-3 pt-1 ${A||""}`,children:t("div",{className:"flex gap-2",children:[e("input",{ref:E,type:"text",value:I,onChange:e=>P(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),T())},placeholder:u,disabled:h,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 ${j||""}`}),e(o,{size:"sm",onClick:T,disabled:h||!I.trim(),className:O,children:h?"...":"Send"})]})})]})})}function Br({runId:e,path:t,parseJson:r=!0}){const{client:a}=be(),n=gr(),i=C(a);i.current=a;const s=C(n);s.current=n;const[o,l]=k({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),[c,d]=k(0),u=j(async()=>{if(!e)return void l({data:void 0,rawContent:void 0,isLoading:!1,error:"No run ID provided",contentType:void 0});if(!t)return void l({data:void 0,rawContent:void 0,isLoading:!1,error:"No artifact path provided",contentType:void 0});l(e=>({...e,isLoading:!0,error:void 0}));const a=i.current,n=s.current,o=function(e){const t=e.split(".").pop()?.toLowerCase();switch(t){case"json":return"json";case"md":case"txt":case"csv":case"yaml":case"yml":default:return"text";case"png":case"jpg":case"jpeg":case"gif":case"webp":case"pdf":return"binary"}}(t);try{const i=yr(e,t,"inline");let s;if(n)s=await n.getOrFetch(i,async()=>(await a.files.getArtifactDownloadUrl(e,t,"inline")).url);else{s=(await a.files.getArtifactDownloadUrl(e,t,"inline")).url}const c=await fetch(s);if(!c.ok)throw new Error(`Failed to fetch artifact: ${c.status} ${c.statusText}`);if("binary"===o)return void l({data:s,rawContent:void 0,isLoading:!1,error:void 0,contentType:o});const d=await c.text();let u;if(r&&"json"===o)try{u=JSON.parse(d)}catch{u=d}else u=d;l({data:u,rawContent:d,isLoading:!1,error:void 0,contentType:o})}catch(e){const r=e instanceof Error?e.message:"Failed to fetch artifact";console.error("Failed to fetch artifact content:",t,e),l({data:void 0,rawContent:void 0,isLoading:!1,error:r,contentType:o})}},[e,t,r]);S(()=>{u()},[u,c]);const h=j(()=>{l({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),d(e=>e+1)},[]);return{data:o.data,rawContent:o.rawContent,isLoading:o.isLoading,error:o.error,contentType:o.contentType,retry:h}}function Hr({content:r}){const{headers:a,rows:n}=A(()=>{if(!Array.isArray(r)||0===r.length)return{headers:[],rows:[]};const e=r[0];if("object"!=typeof e||null===e)return{headers:[],rows:[]};const t=Object.keys(e),a=r.map(e=>t.map(t=>{const r=e[t];return null==r?"":"object"==typeof r?JSON.stringify(r):String(r)}));return{headers:t,rows:a}},[r]);return 0===a.length?e(kr,{type:"table",error:"No table data found"}):t("div",{className:"overflow-x-auto",children:[t("table",{className:"min-w-full text-sm border-collapse",children:[e("thead",{children:e("tr",{className:"border-b",children:a.map((t,r)=>e("th",{className:"px-3 py-2 text-left font-medium text-muted",children:t},r))})}),e("tbody",{children:n.slice(0,100).map((t,r)=>e("tr",{className:"border-b border-muted/20",children:t.map((t,r)=>e("td",{className:"px-3 py-2",children:t},r))},r))})]}),n.length>100&&t("div",{className:"text-sm text-muted py-2",children:["Showing 100 of ",n.length," rows"]})]})}function Gr({content:t,path:r}){const a=r.split(".").pop()?.toLowerCase()||"",n="string"==typeof t?t:JSON.stringify(t,null,2);return e("pre",{className:"overflow-x-auto p-3 bg-muted/10 rounded text-sm",children:e("code",{className:`language-${a}`,children:n})})}function Zr({content:t,path:r}){const a="string"==typeof t?t:"",n=r.split("/").pop()||"Artifact image";return e("img",{src:a,alt:n,className:"max-w-full h-auto rounded",loading:"lazy"})}function Xr({content:t,renderType:r,path:a,runId:n,contentType:i}){const s=A(()=>"auto"!==r?r:function(e,t,r){const a=t.split(".").pop()?.toLowerCase();if(["png","jpg","jpeg","gif","webp","svg"].includes(a||""))return"image";if("md"===a)return"markdown";if("csv"===a)return"table";if("json"===r&&"object"==typeof e&&null!==e){const t=e;if("string"==typeof t.$schema&&t.$schema.includes("vega"))return"vega-lite";if("vega-lite"===t.library&&"spec"in t)return"vega-lite";if(("chart"in t||"type"in t)&&"data"in t&&Array.isArray(t.data))return"chart";if("template"in t&&"data"in t)return"fusion-fragment";if(Array.isArray(e)&&e.length>0&&"object"==typeof e[0])return"table"}return"code"}(t,a,i),[t,a,i,r]);switch(s){case"chart":return e(Cr,{type:"chart",fallbackCode:JSON.stringify(t,null,2),children:e(qr,{spec:t,artifactRunId:n})});case"vega-lite":{const r="object"==typeof t&&null!==t&&"library"in t?t:{library:"vega-lite",spec:t};return e(Cr,{type:"chart",fallbackCode:JSON.stringify(t,null,2),children:e(Tr,{spec:r,artifactRunId:n})})}case"fusion-fragment":{const r=t;return console.log("[ArtifactContentRenderer] fusion-fragment:",{hasTemplate:!!r.template,hasData:!!r.data,runId:n,hasVegaLiteChart:!!Tr}),r.template&&r.data?e(Cr,{type:"fusion-fragment",fallbackCode:JSON.stringify(t,null,2),children:e(tt,{data:r.data,ChartComponent:Tr,artifactRunId:n,children:e(rt,{code:JSON.stringify(r.template),data:r.data})})}):e(Cr,{type:"fusion-fragment",fallbackCode:JSON.stringify(t,null,2),children:e(rt,{code:JSON.stringify(t)})})}case"table":return e(Cr,{type:"table",fallbackCode:JSON.stringify(t,null,2),children:e(Hr,{content:t})});case"markdown":{const r="string"==typeof t?t:String(t);return e(Cr,{type:"markdown",fallbackCode:r,children:e(pa,{artifactRunId:n,children:r})})}case"image":return e(Cr,{type:"image",fallbackCode:a,children:e(Zr,{content:t,path:a})});default:return e(Gr,{content:t,path:a})}}const Yr=N.createContext({});function Qr({children:t,artifactRunId:r,onProposalSelect:a,onProposalSubmit:n}){const i=A(()=>({artifactRunId:r,onProposalSelect:a,onProposalSubmit:n}),[r,a,n]);return e(Yr.Provider,{value:i,children:t})}function ea(){return N.useContext(Yr)}function ta(e){const t=e.trim();if(t.length<2)return!0;if(!t.startsWith("{"))return!1;try{return JSON.parse(t),!1}catch(e){const r=["unexpected end","unterminated string","expected","unexpected token"],a=(e instanceof Error?e.message:"").toLowerCase();if(r.some(e=>a.includes(e))){let e=0,r=0,a=!1,n=!1;for(const i of t)n?n=!1:"\\"!==i?'"'!==i?a||("{"===i?e++:"}"===i?e--:"["===i?r++:"]"===i&&r--):a=!a:n=!0;return e>0||r>0||a}return!1}}function ra(e){try{let t=e.trim();const r=t.indexOf("{"),a=t.lastIndexOf("}");return-1!==r&&a>r&&(t=t.slice(r,a+1)),JSON.parse(t)}catch{return null}}function aa({code:t}){const{artifactRunId:r}=ea(),a=A(()=>ta(t),[t]),n=A(()=>{if(a)return null;const e=ra(t);return e?{library:"vega-lite",spec:e}:null},[t,a]);return a?e(kr,{type:"chart",message:"Loading chart..."}):n?e(Cr,{type:"chart",fallbackCode:t,children:e(Tr,{spec:n,artifactRunId:r})}):e(kr,{type:"chart",error:"Invalid Vega-Lite specification"})}function na({code:t}){const{artifactRunId:r}=ea(),a=A(()=>ta(t),[t]),{chartSpec:n,isVegaLite:i}=A(()=>{if(a)return{chartSpec:null,isVegaLite:!1};const e=ra(t);if(!e)return{chartSpec:null,isVegaLite:!1};const r=function(e){const t="string"==typeof e.$schema&&e.$schema.includes("vega"),r="vega-lite"===e.library&&"spec"in e;return t||r?"vega-lite":("chart"in e||"type"in e||"recharts"===e.library)&&"data"in e&&Array.isArray(e.data)?"recharts":null}(e);return r?"vega-lite"===r?"vega-lite"===e.library&&"spec"in e?{chartSpec:e,isVegaLite:!0}:{chartSpec:{library:"vega-lite",spec:e},isVegaLite:!0}:{chartSpec:e,isVegaLite:!1}:{chartSpec:null,isVegaLite:!1}},[t,a]);return a?e(kr,{type:"chart",message:"Loading chart..."}):n?e(Cr,i?{type:"chart",fallbackCode:t,children:e(Tr,{spec:n,artifactRunId:r})}:{type:"chart",fallbackCode:t,children:e(qr,{spec:n,artifactRunId:r})}):e(kr,{type:"chart",error:"Invalid chart specification"})}function ia({code:t}){const r=t.trim();return r?e(Cr,{type:"mermaid",fallbackCode:t,children:e(Mr,{code:r})}):e(kr,{type:"mermaid",error:"Empty diagram"})}function sa({code:t}){const{onProposalSelect:r,onProposalSubmit:a}=ea(),n=A(()=>ta(t),[t]),i=A(()=>{if(n)return null;try{const e=t.trim(),n=JSON.parse(e);if(!n.options||!n.question&&!n.title)return null;const i={question:n.question||n.title||"",description:n.description,options:Array.isArray(n.options)?n.options.map(e=>({id:e.id||e.value||"",label:e.label||"",description:e.description})):void 0,allowFreeResponse:n.allowFreeResponse??n.multiple,variant:n.variant,onSelect:r,onSubmit:a};return i.question&&i.options?.length?i:null}catch{return null}},[t,r,a,n]);return n?e(kr,{type:"proposal",message:"Loading options..."}):i?e(Cr,{type:"proposal",fallbackCode:t,children:e(Jr,{...i})}):e(kr,{type:"proposal",error:"Invalid proposal specification"})}function oa({code:t,language:r}){const{artifactRunId:a}=ea(),n=t.trim(),i=A(()=>{if(!r?.includes(":"))return"auto";const e=r.split(":")[1];return["chart","vega-lite","table","markdown","fusion-fragment","code","image","auto"].includes(e)?e:"auto"},[r]),{data:s,isLoading:o,error:l,contentType:c}=Br({runId:a,path:n});return a?o?e(kr,{type:"expand",message:`Loading ${n}...`}):l?e(kr,{type:"expand",error:`Failed to load artifact: ${l}`}):void 0===s?e(kr,{type:"expand",error:"No content found in artifact"}):e(Xr,{content:s,renderType:i,path:n,runId:a,contentType:c}):e(kr,{type:"expand",error:"No artifact run ID available"})}function la(e){return e?.startsWith("expand")??!1}function ca(){return{chart:na,"vega-lite":aa,vegalite:aa,mermaid:ia,proposal:sa,askuser:sa}}const da=["artifact:","image:","store:","document:","document://","collection:"];function ua(e){return da.some(t=>e.startsWith(t))?e:pe(e)}function ha(){return e=>{ge(e,"html",(e,t,r)=>{if(e.value&&/<!--[\s\S]*?-->/.test(e.value)&&r&&"number"==typeof t&&r.children)return r.children.splice(t,1),[ye,t]})}}const ma=ca();function pa({children:t,components:r,remarkPlugins:a=[],removeComments:n=!0,artifactRunId:i,className:s,codeClassName:o,inlineCodeClassName:l,linkClassName:c,imageClassName:d,onProposalSelect:u,onProposalSubmit:h}){const m=mr(),p=N.useMemo(()=>{const e=[fe,...a];return n&&e.push(ha),e},[a,n]),f=N.useMemo(()=>{const t=r||{},a=t.code,n=t.a,s=t.img;return{...t,code:({node:t,className:r,children:n,...i})=>{const s=/language-([\w-]+)/.exec(r||""),c=!s,d=s?s[1]:"";if(!c&&d){if(m){const t=m.getComponent(d);if(t){const r=String(n||"").trim();return e(t,{code:r,language:d})}}if(la(d)){const t=String(n||"").trim();return e(oa,{code:t,language:d})}const t=ma[d];if(t){const r=String(n||"").trim();return e(t,{code:r,language:d})}}if("function"==typeof a)return e(a,{node:t,className:r,...i,children:n});return e("code",{...i,className:c?`px-1.5 py-0.5 rounded ${l||""}`:`text-muted ${o||""}`,children:n})},a:t=>{const{node:r,href:a,children:s,...o}=t;return e(Sr,{node:r,href:a,className:c,artifactRunId:i,ExistingLink:n,...o,children:s})},img:t=>{const{node:r,src:a,alt:n,...o}=t;return e(jr,{node:r,src:a,alt:n,className:d,artifactRunId:i,ExistingImg:s,...o})}}},[r,i,m,o,l,c,d]),g=e(Qr,{artifactRunId:i,onProposalSelect:u,onProposalSubmit:h,children:e(me,{remarkPlugins:p,components:f,urlTransform:ua,children:t})});return s?e("div",{className:s,children:g}):g}const fa=O(void 0);function ga(){return I(fa)}const ya=Symbol("__SLOT_NAME");function ba(e,t){const r=[];return E.forEach(e,e=>{!function(e,t,r){let a;R(e)&&(a=e.type[ya])?r[a]=e:t.push(e)}(e,r,t)}),r.length>1?r:r[0]}function va(e,t){t[ya]=e}function xa(e){return e?"boolean"==typeof e?{enabled:e}:e:{enabled:!1}}function wa(t){const r={};if(ba(t.children,r),!r.content)throw new Error("Popover must provide a content slot");const a=r.trigger?.props,n=r.content.props;return e(Na,{...t,trigger:a,content:n})}function Na({middleware:r,offset:a,trigger:n,dismiss:i=!0,content:s,placement:o,strategy:l,zIndex:c=40}){const[d,u]=k(!1),h=st({open:d,placement:o,strategy:l,onOpenChange:u,middleware:r||[at(a||4),nt(),it()],whileElementsMounted:ot}),{floatingStyles:m,refs:{setReference:p,setFloating:f},context:g}=h,y=lt(g,xa(i)),b=ct(g,xa(!(v=n)||v.hover||v.click?v?.click:{enabled:!0}));var v;const w=dt(g,xa(function(e){return!0===e?.hover?{enabled:!0,handleClose:ft({blockPointerEvents:!0}),restMs:0}:e?.hover}(n))),{getReferenceProps:N,getFloatingProps:C}=ut([y,b,w]),{isMounted:S,styles:A}=ht(g,s.transition);return t(fa.Provider,{value:{...h,close:()=>u(!1)},children:[n&&e("div",{className:x(n.className,"inline-block"),ref:p,...N(),children:n.children}),e(mt,{children:S&&e("div",{ref:f,style:{...m,zIndex:c},...C(),children:e(pt,{context:g,children:e("div",{className:x(s.className,"bg-popover rounded-md text-popover-foreground max-w-md"),style:A,children:s.children})})})})]})}function ka(e){return null}function Ca(e){return null}function Sa({percent:t}){return e("div",{className:"w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700",children:e("div",{className:"bg-blue-600 h-2.5 rounded-full",style:{width:`${t}%`}})})}function Aa({className:r,properties:a}){return e(c,{className:r,children:e("tbody",{children:a.map(r=>t("tr",{children:[t("td",{className:"w-1/3 font-semibold gap-2",children:[e("span",{children:r.name}),r.description&&e(d,{description:r.description,placement:"top",children:e(re,{className:"size-3 ml-2 text-muted-foreground"})})]}),e("td",{className:"w-2/3",children:r.value??"undefined"})]},r.name))})})}var ja;function Oa(e,t){let r="any"===t.name?void 0:t.isNullable?[t.name,"null"]:t.name;if(t.isArray)if(e.type="array",e.properties=void 0,!e.items||Array.isArray(e.items))e.items={type:r,properties:t.isObject?{}:void 0};else{const a=e.items;a.type=r,t.isObject&&!a.properties&&(a.properties={})}else e.type=r,e.items=void 0,t.isObject?e.properties||(e.properties={}):e.properties=void 0}function Ia(e){let t,r=!1,a=!1;const n=e.type;if(Array.isArray(n))for(const e of n)"null"===e?r=!0:t||(t=e);else t=n;t||(t="any"),"array"===t&&(a=!0,t=function(e){if(!e)return"any";let t;t=Array.isArray(e)?Pa(e[0].type):Pa(e.type);"array"!==t&&"null"!==t||(t="any");return t}(e.items));let i=t;switch(e.editor){case"textarea":i="text";break;case"media":i="media";break;case"document":i="document"}return{isNullable:r,isArray:a,isObject:"object"===t,name:i}}function Pa(e){return e?Array.isArray(e)?e.find(e=>"null"!==e)||"any":e:"any"}va("trigger",ka),va("content",Ca),wa.Trigger=ka,wa.Content=Ca,function(e){e.string="string",e.number="number",e.integer="integer",e.boolean="boolean",e.object="object",e.any="any",e.text="text",e.media="media",e.document="document"}(ja||(ja={}));let La=0;class $a{source;onChange=()=>{};schema;root;constructor(e,t){this.schema=e?"string"==typeof e?JSON.parse(e):e:{title:t,type:"object",properties:{}},this.schema.properties||(this.schema.properties={}),this.root=new Ea("",this.schema,this),this.root.loadChildren()}get isEmpty(){return!this.root.children||0===this.root.children.length}get children(){return this.root.children}reload(){return this.root=new Ea("",this.schema,this),this.root.loadChildren(),this.onChange?.(this),this}withSource(e,t){return this.source={uri:t,name:e},this}withChangeListener(e){return this.onChange=e,this}replaceSchema(e){this.schema=e||{title:this.schema.title,type:"object",properties:{}},this.reload()}clone(){const e=new $a(this.schema);return e.source=this.source,this.onChange&&e.withChangeListener(this.onChange),e}}class Ea{schema;loader;parent;name;isRequired=!1;type;children;constructor(e,t,r,a){if(this.schema=t,this.loader=r,this.parent=a,this.name=e,this.type=Ia(t),this.parent){let t=this.parent._getPropertiesSchema().required;this.isRequired=!(!t||!Array.isArray(t))&&t.includes(e)}}get title(){return this.schema.title}set title(e){this.schema.title=e}get description(){return this.schema.description}set description(e){this.schema.description=e}get isParent(){return this.type.isObject}get isNew(){return!!this.schema.isNew}set isNew(e){e?this.schema.isNew=!0:delete this.schema.isNew}resetIsNew(){const e=this.isNew;return this.isNew=!1,e}getNameSignature(){return`${this.name}${this.isRequired?"":"?"}`}getTypeSignature(){return`${this.type.name}${this.type.isArray?"[]":""}${this.type.isNullable?"?":""}`}getSignature(){return`${this.getNameSignature()}: ${this.getTypeSignature()}`}reloadTree(){this.loader.reload()}loadChildren(){this.children=[],this.schema.items&&this.schema.items.properties?this._loadChildren(this.schema.items.properties):this.schema.properties&&this._loadChildren(this.schema.properties)}_loadChildren(e){for(const t of Object.keys(e)){const r=e[t],a=new Ea(t,r,this.loader,this);this.children.push(a),a.isParent&&a.loadChildren()}}_getPropertiesSchema(){return this.type.isArray&&this.type.isObject?this.schema.items:this.schema}findAvailableChildName(e){const t=this._getPropertiesSchema().properties||{};let r;do{r=e+ ++La}while(t[r]);return r}addChild(e,t,r=!1){if(!this.type.isObject)throw new Error("Cannot add child to a non object node");this.children||(this.children=[]);const a=function(e,t,r,a=!1){if("object"!==e.type)throw new Error("Cannot add property to a non-object schema");e.properties||(e.properties={});const n={};return Oa(n,r),e.properties[t]=n,a&&(Array.isArray(e.required)?function(e,t){e.includes(t)||e.push(t)}(e.required,t):e.required=[t]),n}(this._getPropertiesSchema(),e,t,r),n=new Ea(e,a,this.loader,this);return this.children.push(n),n}remove(){if(this.parent&&this.parent.type.isObject){return function(e,t){e.properties&&(delete e.properties[t],Array.isArray(e.required)&&(e.required=e.required.filter(e=>e!==t)))}(this.parent._getPropertiesSchema(),this.name),this.parent.children&&(this.parent.children=this.parent.children.filter(e=>e.name!==this.name)),!0}return!1}update(e){let t=!1;null!=e.name&&this.name!==e.name&&(this.parent&&function(e,t,r){if(e.properties){const a=e.properties,n={};for(const e of Object.keys(a)){const i=a[e];e===t?n[r]=i:n[e]=i}e.properties=n}e.required&&(e.required=e.required.map(e=>e===t?r:e))}(this.parent._getPropertiesSchema(),this.name,e.name),this.name=e.name,t=!0),null!=e.isRequired&&this.isRequired!==e.isRequired&&(this.parent&&function(e,t,r){if(Array.isArray(e.required)){const a=e.required.indexOf(t);r?a<0&&e.required.push(t):a>-1&&e.required.splice(a,1)}else r&&(e.required=[t])}(this.parent._getPropertiesSchema(),this.name,e.isRequired),this.isRequired=e.isRequired,t=!0);let r=e.type?.name;"any"===r&&(r=void 0);const a=r!==this.schema.type;return e.type&&(Oa(this.schema,e.type),this.type=e.type,this.type.isObject?this.children||(this.children=[]):this.children=void 0,t=!0),this.schema.editor&&null===e.editor?(this.schema.editor=void 0,t=!0):e.editor?(this.schema.editor=e.editor,t=!0):a&&(this.schema.editor=void 0,t=!0),e.description!==this.description&&(this.description=e.description,t=!0),t}getUpdateFromNameAndTypeSignature(e,t){let r=e.trim(),a=!0;r.endsWith("?")&&(r=r.substring(0,r.length-1).trim(),a=!1);const n=function(e){let t=!1,r=!1;(e=e.trim()).endsWith("?")&&(r=!0,e=e.substring(0,e.length-1).trim()),e.endsWith("[]")&&(t=!0,e=e.substring(0,e.length-2).trim());const a=ja[e];if(!a)throw new Error(`Unknown type "${e}"`);return{name:a,isArray:t,isNullable:r,isObject:a===ja.object}}(t);let i;return"text"===n.name?(n.name=ja.string,i="textarea"):"media"===n.name?(n.name=ja.any,i="media"):"document"===n.name?(n.name=ja.any,i="document"):i=null,{name:r,type:n,isRequired:a,editor:i}}updateFromNameAndTypeSignature(e,t){return this.update(this.getUpdateFromNameAndTypeSignature(e,t))}updateFromSignature(e){const t=(e=e.trim()).indexOf(":");if(t<0)throw new Error("Expecting a name and a type separated by a colon");const r=e.substring(0,t),a=e.substring(t+1);return this.updateFromNameAndTypeSignature(r,a)}}function Ra(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}const Fa=function(){const e=Object.values(ja),t=[...e];for(const r of e)t.push(r+"[]");return e.sort(),t}();function Ta({value:r,onChange:a,onCancel:n,onSave:i}){const[s,l]=k(!1);if(!r)return null;return t("div",{className:"flex items-center",children:[e("div",{className:"flex-1",children:e(za,{value:r.name,onChange:e=>{a({...r,name:e})},onCancel:n,onSave:i})}),e("div",{className:"px-1 font-semibold",children:":"}),e("div",{className:"flex-1",children:e(Da,{value:r.type,onChange:e=>{a({...r,type:e})},onCancel:n,onSave:i})}),t("div",{children:[e(o,{variant:"ghost",size:"xs",onClick:()=>l(!0),title:"Edit description",children:e(ae,{className:"size-4"})}),e(Va,{value:r.description,isOpen:s,onClose:e=>{void 0!==e&&"string"==typeof e&&a({...r,description:e},!0),l(!1)}})]})]})}function za({value:t,onChange:r,onCancel:a,onSave:n}){const s=C(null);S(()=>{s.current?.focus()},[]);return e("input",{onKeyUp:e=>{switch(e.key){case"Enter":n?.();break;case"Escape":a?.()}},ref:s,value:t,onChange:e=>{r(e.target.value)},className:i.INPUT_UNSTYLED,style:{fontSize:"inherit",width:"",display:"inline"}})}function Da({value:t,onChange:r,onCancel:a,onSave:n}){return e(u,{className:i.INPUT_UNSTYLED,options:Fa,value:t||"",onBlur:()=>{n?.()},onChange:r,onKeyDown:(e,t)=>{t||("Enter"===e.key?n?.():"Escape"===e.key&&a?.())},popupClass:"schema-type-suggest-popup z-90"})}function Va({value:r,isOpen:a,onClose:n}){return t(h,{isOpen:a,onClose:n,children:[e(m,{children:"Edit description"}),e(qa,{value:r,onSave:n})]})}function qa({value:a,onSave:n}){const i=C(null),[s,l]=k(a||"");return S(()=>{i.current&&i.current.focus()},[i.current]),t(r,{children:[e(p,{className:"h-max",children:e("textarea",{ref:i,className:"dark:bg-gray-800 w-full h-full dark:text-white",value:s,onChange:e=>l(e.target.value)})}),e(f,{children:e(o,{onClick:()=>n(s),children:"Save Changes"})})]})}function Ka({value:r}){return r?t("div",{className:"w-full flex items-baseline",children:[e("div",{children:r.name||""}),e("div",{className:"ml-2 text-sm text-muted",children:r.type||""})]}):null}function Ua(e){const[t,r]=k(new $a(e||{type:"object",properties:{}}).withChangeListener(e=>{r(e.clone())}));return t}const Ma="block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4",_a=`${Ma} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,Wa=`${Ma} shadow-xs ring-1 ring-inset ring-ring`;function Ja({value:r,onChange:a,onDelete:n,outlineOnHover:i=!1,editOnClick:s=!0,placeholder:o,viewer:l,editor:c,skipClickOutside:d,isEditing:u=!1,readonly:h=!1,onValidate:m}){const{on:p,off:f,isOn:y}=g(u),[b,v]=k();return t("div",{className:"",children:[y&&!h?e(Ha,{value:r,onSave:e=>{if(m){const t=m(e);if(t)return void v(t);v(void 0)}a(e)&&f()},onCancel:f,editor:c,skipClickOutside:e=>!!d&&d(e)}):e(Ba,{value:r,onEdit:p,viewer:l,placeholder:o,outlineOnHover:i,editOnClick:s,onDelete:n,readonly:h}),b&&e("div",{className:"text-red-500 text-sm",children:b})]})}function Ba({viewer:r,value:a,onEdit:n,editOnClick:i,outlineOnHover:s,placeholder:l,onDelete:c,readonly:d}){const u="invisible group-hover:visible";return t("div",{tabIndex:0,onKeyUp:e=>{"Enter"===e.key&&n()},onClick:()=>{i&&n()},className:x("flex justify-start items-center group",s?_a:Ma,{"cursor-pointer":i}),children:[e(r,{value:a,placeholder:l}),t("div",{className:"ml-auto flex space-x-2",children:[!d&&c&&e(o,{variant:"ghost",size:"sm",className:u,onClick:c,children:e(T,{className:"size-4"})}),d?null:e(o,{variant:"ghost",size:"sm",className:u,onClick:n,children:e(ne,{className:"size-4"})})]})]})}function Ha({editor:t,value:r,onSave:a,onCancel:n,skipClickOutside:i}){const[s,o]=k(r),l=C(r),[c,d]=k(null),u=()=>{a(l.current)},h=y(u,i);return e("div",{ref:h,children:e("div",{className:Wa,children:e("div",{className:"w-full",onClick:e=>e.stopPropagation(),children:e(t,{value:s,onChange:(e,t=!1)=>{o(e),l.current=e,t&&(c&&clearTimeout(c),d(setTimeout(()=>{a(e)},500)))},onSave:u,onCancel:n})})})})}function Ga(e){const t=e.target;return!(!t.closest||!t.closest(".schema-type-suggest-popup"))}function Za({schema:r,readonly:a=!1}){return t("ul",{className:"",children:[r.children.map(e=>Xa(e,a)),a?null:e(rn,{parent:r.root})]})}function Xa(t,r){return t.isParent?e(Qa,{property:t,readonly:r},t.name):e(Ya,{node:t,readonly:r},t.name)}function Ya({node:t,readonly:r}){return e("li",{children:e(tn,{property:t,readonly:r})})}function Qa({property:r,readonly:a}){const[n,i]=k(!0);return t("li",{children:[t("div",{className:"flex items-center w-full",children:[e("button",{onClick:()=>i(!n),children:e(n?ie:se,{className:"size-4"})}),e("div",{className:"flex-1",children:e(tn,{property:r,readonly:a})})]}),n&&t("ul",{className:"ml-4 border-l border-gray-400 border-dashed",children:[(r.children||[]).map(e=>Xa(e,a)),a?null:e(rn,{parent:r})]})]})}function en(e){return e?/^[a-zA-Z0-9_]+[?]?$/.test(e)?void 0:"Only letters, numbers, underscores or question mark are allowed (a-zA-Z0-9_?)":"Name is required"}function tn({property:t,readonly:r}){const a=b(),n=t.resetIsNew(),i=Ra(t);return e(Ja,{value:i,onChange:e=>{try{e.description&&"string"!=typeof e.description&&(e.description=void 0);const r=t.getUpdateFromNameAndTypeSignature(e.name,e.type);t.update({...r,description:e.description})&&t.reloadTree()}catch(e){return a({status:"error",title:"Invalid property declaration",description:e.message,duration:9e3}),!1}return!0},onDelete:()=>{t.remove(),t.reloadTree()},editor:Ta,viewer:Ka,outlineOnHover:!0,isEditing:n,skipClickOutside:Ga,readonly:r,onValidate:e=>en(e.name)})}function rn({parent:r}){return t(o,{variant:"ghost",onClick:()=>{const e=r.findAvailableChildName("new_property_");r.addChild(e,{isObject:!1,isArray:!1,isNullable:!1,name:ja.string},!0).isNew=!0,r.reloadTree()},children:[e(F,{className:"size-4"}),"Add property"]})}function an({content:t,...r}){const a=C(null);return S(()=>{if(!a.current)return;const e=(new DOMParser).parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)return console.warn("SvgIcon: No <svg> element found in provided string"),void(a.current.innerHTML="");r&&Object.entries(r).forEach(([t,r])=>{if(null==r)return;const a="className"===t?"class":t;e.setAttribute(a,String(r))}),a.current.innerHTML="",a.current.appendChild(e)},[t,r]),e("span",{ref:a})}function nn(t){return r=>e(an,{content:t,...r})}function sn({onDrop:r,message:a,buttonLabel:n="Upload Files",allowFolders:i=!0,className:s=""}){const[l,c]=k(!1),d=C(null),u=e=>{if(e.target.files&&e.target.files.length>0){const t=Array.from(e.target.files);if(t.some(e=>e.webkitRelativePath&&e.webkitRelativePath.includes("/"))){const e=new Set(t.map(e=>e.webkitRelativePath?.split("/")[0]).filter(Boolean)).size,a=t.length,n=1===e?`Preparing to upload 1 folder with ${a} files...`:`Preparing to upload ${e} folders with ${a} files...`,i={count:t.length,message:n};r(t,i)}else{const e={count:t.length,message:`Preparing to upload ${t.length} file${1===t.length?"":"s"}...`};r(t,e)}}};return t("div",{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${l?"border-color-primary bg-color-primary/10":"border-dashed border-color-border"} ${s}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.types.includes("Files")&&c(!0)},onDragLeave:e=>{e.preventDefault(),d.current&&!d.current.contains(e.relatedTarget)&&c(!1)},onDrop:async e=>{if(e.preventDefault(),c(!1),e.dataTransfer.items&&e.dataTransfer.items.length>0){const t=Array.from(e.dataTransfer.items),a=[],n=new Set,i=async e=>{if(e.isFile){const t=await new Promise(t=>{e.file(r=>{Object.defineProperty(r,"webkitRelativePath",{writable:!0,value:e.fullPath.substring(1)}),t(r)})});!t.name.startsWith(".")&&t.size>0&&a.push(t);const r=e.fullPath.substring(1).split("/").slice(0,-1).join("/");r&&n.add(r)}else if(e.isDirectory){const t=e.createReader(),r=await new Promise(e=>{t.readEntries(t=>{e(t)})});await Promise.all(r.map(i));const a=e.fullPath.substring(1);a&&n.add(a)}};try{if(await Promise.all(t.map(e=>{const t=e.webkitGetAsEntry?e.webkitGetAsEntry():e;return t?i(t):Promise.resolve()})),a.length>0){const e=new Set(Array.from(n).map(e=>e.split("/")[0]).filter(Boolean)).size,t=a.length;let i="";i=e>0?1===e?`Preparing to upload 1 folder with ${t} files...`:`Preparing to upload ${e} folders with ${t} files...`:`Preparing to upload ${t} file${1===t?"":"s"}...`,r(a,{count:a.length,message:i})}}catch(t){console.error("Error processing dropped files:",t);const a=Array.from(e.dataTransfer.files);a.length>0&&r(a)}}else if(e.dataTransfer.files&&e.dataTransfer.files.length>0){const t=Array.from(e.dataTransfer.files);r(t)}},children:[e(oe,{className:"h-12 w-12 mb-3 transition-colors "+(l?"text-primary":"text-muted/50")}),e("p",{className:"text-muted",children:a}),t("div",{className:"flex gap-2 justify-center mt-2",children:[e(o,{onClick:()=>{const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="*",e?.click(),e.onchange=e=>{u(e)}},children:n}),i&&e(o,{onClick:()=>{const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="*",e.webkitdirectory=!0,e?.click(),e.onchange=e=>{u(e)}},children:"Select Folder"})]})]})}function on({title:r,count:a,icon:n=e(le,{className:"h-4 w-4 text-green-500"}),items:i}){const[s,o]=k(!1);return t("div",{className:"border border-color-border rounded-md overflow-hidden",children:[t("div",{className:"flex items-center justify-between p-3 bg-color-muted/10 cursor-pointer",onClick:()=>o(!s),children:[t("div",{className:"flex items-center",children:[e("span",{className:"mr-2",children:n}),e("span",{className:"font-medium",children:r}),e("span",{className:"ml-2 px-2 py-0.5 bg-color-muted/20 rounded-full text-xs",children:a})]}),e("button",{className:"text-muted",children:e("svg",{className:"h-5 w-5 transition-transform "+(s?"transform rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),s&&e("div",{className:"p-3 border-t border-color-border max-h-48 overflow-y-auto",children:i.length>0?e("ul",{className:"space-y-1",children:i.map((t,r)=>e("li",{className:"text-sm py-1 px-2 rounded hover:bg-color-muted/10",children:t},r))}):e("div",{className:"text-sm text-muted py-2",children:"No items to display"})})]})}function ln({files:r,className:a="",location:n,collection:i}){const s=r.filter(e=>"success"===e.status),o=r.filter(e=>"updated"===e.status),l=r.filter(e=>"skipped"===e.status),c=r.filter(e=>"failed"===e.status),d=s.length,u=o.length,h=l.length,m=c.length,p=r.length;return t("div",{className:`flex flex-col py-2 ${a}`,children:[t("div",{className:"flex items-center mb-4",children:[e("div",{className:"size-8 mr-4 rounded-full bg-success/10 flex items-center justify-center",children:e(le,{className:"size-4 text-success"})}),e("div",{children:t("p",{className:"text-muted",children:[p," file",1!==p?"s":""," processed",i?` in collection '${i}'`:"",n?` in folder '${n}'`:""]})})]}),t("div",{className:"space-y-3 mt-2",children:[d>0&&e(on,{title:"Successfully Uploaded",count:d,icon:e(le,{className:"h-4 w-4 text-green-500"}),items:s.map(e=>e.name)}),u>0&&e(on,{title:"Successfully Updated",count:u,icon:e(le,{className:"h-4 w-4 text-blue-500"}),items:o.map(e=>e.name)}),h>0&&e(on,{title:"Skipped (Already Existed)",count:h,icon:e(ce,{className:"h-4 w-4 text-amber-500"}),items:l.map(e=>e.name)}),m>0&&e(on,{title:"Failed to Upload",count:m,icon:e(de,{className:"h-4 w-4 text-red-500"}),items:c.map(e=>e.name)})]})]})}const cn="#text",dn="#comment",un="#cdata",hn="DECLARATION_TAG",mn={tagColor:"#d43900",textColor:"#333",attributeKeyColor:"#2a7ab0",attributeValueColor:"#008000",separatorColor:"#333",commentColor:"#aaa",cdataColor:"#1d781d",fontFamily:"monospace"},pn={attributeKeyColor:"#FFD700",attributeValueColor:"#FF4500",tagColor:"#87CEFA",textColor:"#00FF00",separatorColor:"#FFD700",commentColor:"#BEBEBE",cdataColor:"#33CC66",fontFamily:"monospace"},fn=O({theme:mn,collapsible:!1,indentSize:2}),gn=()=>I(fn),yn=new gt({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:"",allowBooleanAttributes:!0,commentPropName:dn,cdataPropName:un,parseTagValue:!1});function bn(r){const{indentation:a,children:n,isInline:i}=r,{theme:s}=gn();return t("div",{style:{color:s.cdataColor},children:[e("span",{children:`${a}<![CDATA[`}),n,e("span",{children:`${i?"":a}]]>`})]})}function vn(t){const{collapsible:r,theme:a}=gn(),{collapsed:n}=t;return r?e("span",{style:{position:"relative"},children:e("span",{style:{position:"absolute",right:"0",border:0,padding:0,background:"none"},children:e(xn,{fill:a.separatorColor,style:{transform:`rotate(${n?0:90}deg)`,transition:"transform 0.2s"}})})}):null}function xn({...t}){return e("svg",{width:"16px",height:"16px",viewBox:"0 0 24 24",...t,children:e("path",{d:"M9 17.898C9 18.972 10.2649 19.546 11.0731 18.8388L17.3838 13.3169C18.1806 12.6197 18.1806 11.3801 17.3838 10.6829L11.0731 5.16108C10.2649 4.45388 9 5.02785 9 6.1018V17.898Z"})})}function wn(e){const{collapsible:t,initialCollapsedDepth:r}=gn(),[a,n]=k(()=>!(bt(r)||!t)&&e>=r);return S(()=>{n(!(bt(r)||!t)&&e>=r)},[r,e,t]),{collapsed:a,buttonProps:t?{onClick:()=>n(e=>!e),role:"button",style:{cursor:"pointer"}}:{}}}function Nn(r){const{indentation:a,children:n,isInline:i,level:s}=r,{theme:o}=gn(),{collapsed:l,buttonProps:c}=wn(s);return t("div",{style:{color:o.commentColor},children:[t("span",{...c,children:[e("span",{children:a}),e(vn,{collapsed:l}),e("span",{children:"\x3c!-- "})]}),!l&&n,l&&"...",e("span",{children:`${i||l?" ":a}--\x3e`})]})}function kn(r){const{attributes:a}=r,{theme:n}=gn();return a?e("span",{children:Object.entries(a).map(([r,a])=>t("span",{children:[e("span",{style:{color:n.attributeKeyColor},children:` ${r}`}),e("span",{style:{color:n.separatorColor},children:"="}),e("span",{style:{color:n.attributeValueColor},children:`"${a}"`})]},`attribute-${r}`))}):null}function Cn(r){const{indentation:a,tagKey:n,attributes:i}=r,{theme:s}=gn();return t("div",{children:[e("span",{style:{color:s.separatorColor},children:`${a}<?`}),e("span",{style:{color:s.tagColor},children:`${n.slice(1)}`}),e(kn,{attributes:i}),e("span",{style:{color:s.separatorColor},children:"?>"})]})}function Sn(e){return"string"==typeof e&&e.includes("\n")}function An(e){const t=e[":@"],r=vt(e,":@"),[[a,n]]=Object.entries(r),i=function(e){switch(e){case cn:case un:case dn:return e;default:return e.startsWith("?")?hn:"TAG"}}(a);return{attributes:t,tagKey:a,subElements:n,type:i}}function jn(e){return!!e&&Object.keys(e).length>0}function On(a){const{indentation:n,tagKey:i,attributes:s,children:o,isInline:l,hasChildren:c,level:d}=a,{collapsed:u,buttonProps:h}=wn(d),{theme:m}=gn();return t("div",{children:[t("span",{...h,children:[e("span",{children:n}),e(vn,{collapsed:u}),e("span",{style:{color:m.separatorColor},children:"<"}),e("span",{style:{color:m.tagColor},children:`${i}`}),!u&&e(kn,{attributes:s}),u&&jn(s)&&" ...",e("span",{style:{color:m.separatorColor},children:c?">":" />"})]}),c&&t(r,{children:[!u&&o,u&&"...",e("span",{style:{color:m.separatorColor},children:`${l||u?"":n}</`}),e("span",{style:{color:m.tagColor},children:`${i}`}),e("span",{style:{color:m.separatorColor},children:">"})]})]})}function In(t){const{hasSiblings:r,text:a,indentation:n,isText:i}=t,{theme:s}=gn(),o=i?{color:s.textColor}:void 0;return Sn(a)||r?e("div",{style:o,children:a.split("\n").filter(e=>!!e.trim()).map((t,r)=>e("div",{children:`${n}${t.trim()}`},`${r}`))}):e("span",{style:o,children:a})}function Pn(t){const{elements:a,level:n=0,isText:i=!0}=t,{indentSize:s}=gn();return Array.isArray(a)&&0!==a.length?e(r,{children:a.map((t,r)=>{const{tagKey:o,attributes:l,subElements:c,type:d}=An(t),u=a.length>1,h=function(e,t){return new Array(t*e+1).join(" ")}(s,n),m=`${n}-${r}`,p=function(e){return"string"!=typeof e&&1===e.length&&cn in e[0]&&!Sn(e[0][cn])}(c);switch(d){case cn:return e(In,{text:c,indentation:h,hasSiblings:u,isText:i},m);case dn:return e(Nn,{isInline:p,indentation:h,level:n,children:e(Pn,{elements:c,level:n+1,isText:!1})},m);case un:return e(bn,{indentation:h,isInline:p,children:e(Pn,{elements:c,level:n+1,isText:!1})},m);case hn:return e(Cn,{indentation:h,tagKey:o,attributes:l},m);default:return e(On,{indentation:h,tagKey:o,attributes:l,isInline:p,hasChildren:c.length>0,level:n,children:e(Pn,{elements:c,level:n+1})},m)}})}):null}function Ln(){return e("div",{children:"Invalid XML!"})}function $n(t){const{theme:r,xml:a,collapsible:n=!1,indentSize:i=2,invalidXml:s,initalCollapsedDepth:o,initialCollapsedDepth:l}=t,[c,d]=k(()=>document.documentElement.classList.contains("dark"));S(()=>{const e=document.documentElement,t=new MutationObserver(()=>{d(e.classList.contains("dark"))});return t.observe(e,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const u=A(()=>({...c?pn:mn,...r}),[c,r]),{json:h,valid:m}=function(e){return A(()=>{try{if(!yt.validate(e))throw new Error("Invalid XML!");const t=yn.parse(e);if("string"==typeof e&&e.trim().length>0&&0===t.length)throw new Error("Invalid XML!");return{json:t,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e.message}`}}},[e])}(a),p=A(()=>({theme:u,collapsible:n,indentSize:i,initialCollapsedDepth:l??o}),[u,n,i,o,l]);return m?e(fn.Provider,{value:p,children:e("div",{className:"rxv-container",style:{whiteSpace:"pre-wrap",fontFamily:u.fontFamily,overflowWrap:"break-word"},children:e(Pn,{elements:h})})}):s||e(Ln,{})}export{qt as ArrayPropertySchema,Xr as ArtifactContentRenderer,na as ChartCodeBlockHandler,Cr as CodeBlockErrorBoundary,Qr as CodeBlockHandlerProvider,kr as CodeBlockPlaceholder,hr as CodeBlockRendererProvider,sn as DropZone,oa as ExpandCodeBlockHandler,kt as FieldSetContextProvider,Pt as Form,St as FormContext,Ot as FormContextProvider,Qt as FormError,Yt as FormHelper,Xt as FormLabel,$t as GeneratedForm,It as Input,er as JSONCode,cr as JSONDisplay,tr as JSONView,Gt as ManageObjectEntry,Ht as ManagedListProperty,Wt as ManagedObject,_t as ManagedObjectBase,Jt as ManagedObjectProperty,Bt as ManagedProperty,Zt as ManagedScalarEntry,$a as ManagedSchema,jr as MarkdownImage,Sr as MarkdownLink,pa as MarkdownRenderer,ia as MermaidCodeBlockHandler,Mr as MermaidDiagram,wt as MonacoEditor,Mt as Node,wa as Popover,fa as PopoverContext,Sa as Progress,Aa as PropertiesView,Ta as PropertyEditor,za as PropertyNameEditor,Vt as PropertySchema,Ka as PropertyViewer,sa as ProposalCodeBlockHandler,Rt as ScalarField,Dt as Schema,Za as SchemaEditor,Ea as SchemaNode,an as SvgIcon,on as UploadResultCategory,ln as UploadSummary,xt as VEditorApi,$n as XMLViewer,Kt as computeTitleFromName,ca as createDefaultCodeBlockHandlers,nn as createSvgIcon,Ra as getEditableSchemaProperty,la as isExpandLanguage,xr as mapSchemeToRoute,vr as parseUrlScheme,Br as useArtifactContent,pr as useCodeBlockComponent,ea as useCodeBlockContext,mr as useCodeBlockRendererRegistry,Ct as useFieldSet,jt as useForm,ga as usePopoverContext,wr as useResolvedUrl,Ua as useSchema,en as validatePropertyName};
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{Editor as n}from"@monaco-editor/react";import{useTheme as a,Styles as i,FormItem as s,Button as o,DotBadge as l,Table as c,VTooltip as d,SelectBox as u,Modal as h,ModalTitle as m,ModalBody as p,ModalFooter as f,useFlag as g,useClickOutside as y,useToast as b}from"@vertesia/ui/core";import v from"debounce";import x,{clsx as w}from"clsx";import N,{useState as k,useRef as C,useEffect as S,useMemo as A,useCallback as j,createContext as O,useContext as $,memo as P,useId as I,Children as L,isValidElement as R}from"react";import{Plus as E,Trash2 as T,Code as F,FileText as D,Table as z,Download as q,Link as V,Image as M,MessageSquare as _,GitBranch as U,BarChart3 as W,Loader2 as H,Check as B,Copy as J,Minimize2 as K,Maximize2 as G,X,CheckCircle as Y,AlertCircle as Z,HelpCircle as Q,Send as ee,Info as te,AlignLeft as re,SquarePen as ne,ChevronDown as ae,ChevronRight as ie,UploadIcon as se,CheckCircleIcon as oe,AlertCircleIcon as le,XCircleIcon as ce}from"lucide-react";import de from"ajv";import ue from"ajv-formats";import he,{defaultUrlTransform as me}from"react-markdown";import pe from"remark-gfm";import fe from"remark-math";import ge from"remark-directive";import ye from"remark-github-blockquote-alert";import{remarkDefinitionList as be,defListHastHandlers as ve}from"remark-definition-list";import xe from"remark-supersub";import we from"rehype-katex";import{visit as Ne,SKIP as ke}from"unist-util-visit";import{useUserSession as Ce}from"@vertesia/ui/session";import*as Se from"@radix-ui/react-dialog";import Ae from"papaparse";import{VegaEmbed as je}from"react-vega";import{twMerge as Oe}from"tailwind-merge";import $e from"mermaid";import{MarkdownRenderer as Pe}from"@vertesia/ui/widgets";import Ie from"dompurify";import{FusionFragmentProvider as Le,FusionFragmentHandler as Re}from"@vertesia/fusion-ux";import{offset as Ee,shift as Te,flip as Fe}from"@floating-ui/dom";import{useFloating as De,autoUpdate as ze,useDismiss as qe,useClick as Ve,useHover as Me,useInteractions as _e,useTransitionStyles as Ue,FloatingPortal as We,FloatingFocusManager as He,safePolygon as Be}from"@floating-ui/react";import{XMLParser as Je,XMLValidator as Ke}from"fast-xml-parser";import{isNil as Ge,omit as Xe}from"lodash-es";class Ye{VgetValue;VsetValue;constructor(e,t){this.VgetValue=e,this.VsetValue=t}getValue(){return this.VgetValue()}setValue(e){this.VsetValue(e||"")}}function Ze({onChange:t,value:r,className:i,editorRef:s,language:o="javascript",debounceTimeout:l=0,options:c={},beforeMount:d,onMount:u,defaultValue:h}){const[m,p]=k(r||h||""),f=C(null),{theme:g}=a(),y=C(()=>m),b=C(e=>{p(e),f.current&&f.current.setValue(e)});S(()=>{y.current=()=>m},[m]),S(()=>(s&&(s.current=new Ye(()=>y.current(),e=>b.current(e))),()=>{s&&(s.current=void 0)}),[s]);const w=A(()=>{if(t)return l>0?v(e=>t(e),l):t},[t,l]),N=j(e=>{const t=e||"";if(p(t),w){const e={docChanged:!0,state:{doc:{toString:()=>t,length:t.length}}};w(e)}},[w]),O=j((e,t)=>{f.current=e,b.current=t=>{p(t),e.setValue(t)},t.editor.defineTheme("errorLineTheme",{base:"dark"===g?"vs-dark":"vs",inherit:!0,rules:[],colors:{"editorError.background":"#ffebee","editorError.border":"#f44336"}}),t.editor.setTheme("errorLineTheme"),u?.(e,t)},[u,g]);S(()=>{const e=r||h||"";e!==m&&(p(e),f.current&&f.current.setValue(e))},[r]);const $={fontSize:14,fontFamily:"monospace",minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",lineNumbers:"on",folding:!1,lineDecorationsWidth:10,lineNumbersMinChars:3,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2,insertSpaces:!0,glyphMargin:!0,renderValidationDecorations:"on",renderLineHighlight:"line",hover:{enabled:!0,delay:100},quickSuggestions:{other:!0,comments:!0,strings:!0},...c};return e("div",{className:x(i,"w-full h-full!"),children:e(n,{className:"h-full w-full",height:"100%",theme:"dark"===g?"vs-dark":"light",language:o,value:m,onChange:N,onMount:O,beforeMount:d,options:$,defaultValue:h||""})})}const Qe=O(void 0),et=Qe.Provider;function tt(){const e=$(Qe);if(!e)throw new Error("useFieldSet must be used within a Form or FieldSet element");return e}class rt{object;components;disabled;constructor(e,t={},r=!1){this.object=e,this.components=t,this.disabled=r}}const nt=O(void 0);function at(){const e=$(nt);if(!e)throw new Error("useForm must be used within a Form element");return e}const it=nt.Provider,st=N.forwardRef(({object:t,type:r="text",onChange:n,...a},s)=>{const[o,l]=k(null!=t.value?String(t.value):""),[c,d]=k(t.schema.isBoolean&&!0===t.value);a.className?a.className=x(i.INPUT,a.className):a.className=i.INPUT;const u=e=>{a.disabled||(l(e.target.value),t.schema.isBoolean?(t.value=e.target.checked,d(t.value)):t.value=e.target.value,n&&n(e))};return"textarea"===r?e("textarea",{ref:s,...a,value:o,onChange:u}):e("input","checkbox"===r?{ref:s,...a,type:"checkbox",checked:c,onChange:u,className:"form-check-input"}:{ref:s,...a,type:r,value:o,onChange:u})});function ot({object:t,components:r,onSubmit:n,children:a,onChange:i,disabled:s}){return t.observer=i,e(it,{value:new rt(t,r||{},s??!1),children:e("form",{className:"w-full",onSubmit:e=>{e.stopPropagation(),e.preventDefault(),n&&n(t.value)},children:a})})}function lt(){const t=at();return e("div",{className:"flex flex-col gap-4 w-full",children:t.object.properties.map(dt)})}function ct({children:r,...n}){return t(ot,{...n,children:[e(lt,{}),r]})}function dt(t){return t.isList?e(mt,{object:t},t.name):t.isObject?e(ht,{object:t},t.name):e(ut,{object:t},t.name)}function ut({object:t,editor:r,inline:n=!1}){r||(r=t.schema.editor);const{components:a,disabled:i}=at(),o=r&&a[r]||st,l=t.getInputType();"checkbox"===l&&(n=!0);const c=e=>{i||(t.schema.isBoolean?t.value=e.target.checked:t.schema.isNumber?t.value=parseFloat(e.target.value):t.value=e.target.value)};return t.isListItem?e(o,{object:t,type:l,onChange:c,disabled:i}):e(s,{label:t.title,required:t.schema.isRequired,description:t.schema.description,className:x("flex",n?"flex-row items-center":"flex-col"),children:e(o,{object:t,type:l,onChange:c,disabled:i})})}function ht({object:r}){return t("div",{className:"flex flex-col gap-4 my-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 dark:border-l-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.properties.map(dt)]})}function mt({object:r}){const[n,a]=k(r.value||[]),{disabled:i}=at();return t("div",{className:"flex flex-col gap-4 my-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 darK:border-l-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.items.map((t,s)=>e(pt,{object:t,list:r,onDelete:()=>(e=>{i||(r.remove(e),a([...r.value]))})(s),disabled:i},`${s}-${n[s]??""}`)),e("div",{children:t(o,{variant:"secondary",onClick:()=>{i||(r.add(),a([...r.value]))},disabled:i,children:[e(E,{className:"size-6"})," Add"]})})]})}function pt({list:r,object:n,onDelete:a,disabled:i}){return t("div",{className:"flex gap-2 w-full",children:[e("div",{className:"flex-1",children:(s=n,l=r.schema.arraySchema.editor,s.isList?e(mt,{object:s}):s.isObject?e(ht,{object:s}):e(ut,{object:s,editor:l}))}),e(o,{variant:"secondary",onClick:a,disabled:i,children:e(T,{className:"size-4"})})]});var s,l}class ft{schema;properties={};_validator;constructor(e){this.schema=e||{type:"object",properties:{}},this.load()}get validator(){if(!this._validator){const e=new de({allErrors:!0,strict:!1});ue(e),this._validator=e.compile(this.schema)}return this._validator}load(){if(this.schema.properties){const e=this.schema.properties;Object.keys(e).forEach(t=>{this.loadProperty(t,e[t])})}}hasProperties(){return Object.keys(this.properties).length>0}get title(){return this.schema.title||this.schema.name}get description(){return this.schema.description}loadProperty(e,t){let r;return r="array"===t.type?new yt(this,e,t):new gt(this,e,t),this.properties[e]=r,r}get type(){return this.schema.type}validate(e){return this.validator(e)?null:this.validator.errors||[]}addProperty(e,t,r=!1){"object"!==this.schema.type&&(this.schema.type="object"),this.schema.properties||(this.schema.properties={});const n="string"==typeof t?"object"===(a=t)?{type:"object",properties:{}}:"array"===a?{type:"array",items:{}}:{type:a}:t;var a;const i=this.loadProperty(e,n);return this.schema.properties[i.name]=i.schema,r&&(i.isRequired=!0),i}removeProperty(e){this.schema.properties&&(delete this.schema.properties[e],Array.isArray(this.schema.required)&&(this.schema.required=this.schema.required.filter(t=>t!==e))),delete this.properties[e]}getProperty(e){return this.properties[e]}get editor(){return this.schema.editor}}class gt extends ft{parent;name;constructor(e,t,r){if(super(r),this.parent=e,this.name=t,"array"===r.type)throw new Error("Array property must be instantiated using ArrayPropertySchema");"object"!==r.type||r.properties||(r.properties={})}get isMulti(){return!1}get isReadOnly(){return!!this.schema.readOnly}set isReadOnly(e){this.schema.readOnly=e}get defaultValue(){return this.schema.default}set defaultValue(e){this.schema.default=e}get enum(){return this.schema.enum}set enum(e){this.schema.enum=e}get isRequired(){const e=this.parent.schema.required;return!!e&&e.includes(this.name)}set isRequired(e){let t=Array.isArray(this.parent.schema.required)?this.parent.schema.required:[];t=e?t.concat(this.name):t.filter(e=>e!==this.name),this.parent.schema.required=t}get type(){return this.schema.type}set type(e){this.schema.type!==e&&(this.schema.type=e,"object"!==e&&(this.properties={},this.schema.properties=void 0))}remove(){this.parent.removeProperty(this.name)}get isBoolean(){return"boolean"===this.type}get isString(){return"string"===this.type}get isNumber(){return"number"===this.type||"integer"===this.type}get isObject(){return"object"===this.type}}class yt extends gt{arraySchema;constructor(e,t,r){super(e,t,function(e){if("array"!==e.type)throw new Error("Expecting an array schema");if(e.items){if(Array.isArray(e.items))throw new Error("Tuple arrays are not supported")}else e.items={};return e.items}(r)),this.arraySchema=r}get isMulti(){return!0}}function bt(e){return(e=e.replace(/_/g," ").replace(/([a-z0-9])&([A-Z])/g,"$1 $2"))[0].toUpperCase()+e.slice(1)}function vt(e,t){if(t.editor)return t.editor;if(t.schema.format)return t.schema.format;switch(t.type){case"number":case"integer":return"number";case"boolean":return"checkbox";default:return"text"}}class xt{parent;schema;name;observer;constructor(e,t,r){this.parent=e,this.schema=t,this.name=r}get isRoot(){return!this.parent}get root(){return this.parent?this.parent.root:this}get path(){return this.parent?this.parent.path.concat(this.name):[]}get isScalar(){return!1}get isListItem(){return!1}get isObject(){return!1}get isList(){return!1}get title(){return this.schema.title||bt(this.name)}onChange(e){this.observer&&!1===this.observer(this)||this.parent&&this.parent.onChange(e)}}class wt extends xt{constructor(e,t,r){super(e,t,r)}get isObject(){return!0}getProperty(e){const t=this.schema.properties[e];return t.isMulti?new St(this,t,this.getOrInitArrayProperty(e)):t.isObject?new kt(this,t,t.name,this.getOrInitObjectProperty(e)):new Ct(this,t)}getOrInitObjectProperty(e){let t=this.value[e];return t||(this.value[e]=t={}),t}getOrInitArrayProperty(e){let t=this.value[e];return t||(this.value[e]=t=[]),t}setPropertyValue(e,t){return this.value[e]!==t&&(this.value[e]=t,!0)}getPropertyValue(e){return this.value[e]}get properties(){const e=[];for(const t of Object.values(this.schema.properties))t.isMulti?e.push(new St(this,t,this.getOrInitArrayProperty(t.name))):t.isObject?e.push(new kt(this,t,t.name,this.getOrInitObjectProperty(t.name))):e.push(new Ct(this,t));return e}[Symbol.iterator](){return this.properties[Symbol.iterator]()}}class Nt extends wt{value;constructor(e,t={}){super(null,e instanceof ft?e:new ft(e),"#root"),this.value=t}}class kt extends wt{value;constructor(e,t,r,n){super(e,t,r),this.value=n}}class Ct extends xt{constructor(e,t){super(e,t,t.name),void 0===e.value[this.name]&&void 0!==t.defaultValue&&(e.value[this.name]=t.defaultValue)}get isScalar(){return!0}set value(e){this.parent.setPropertyValue(this.name,e)&&this.onChange(this)}get value(){return this.parent.getPropertyValue(this.name)}getInputType(){return vt(this.name,this.schema)}}class St extends xt{value;items=[];constructor(e,t,r){super(e,t,t.name),this.value=r;for(const e of this.value)this.add()}get isList(){return!0}newItem(e){return this.schema.isObject?new At(this,e):new jt(this,e)}add(){const e=this.newItem(this.items.length);return this.items.push(e),e}remove(e){const t=this.value;if(e>=0&&e<this.items.length){this.items.splice(e,1);for(let e=0,t=this.items.length;e<t;e++){const t=this.items[e];t.index=e,t.name=String(e)}}Array.isArray(t)&&e>=0&&e<t.length&&(t.splice(e,1),this.onChange(this))}[Symbol.iterator](){return this.items[Symbol.iterator]()}item(e){if(e<0||e>=this.value.length)return;const t=this.value[e];return this.schema.isObject?new kt(this,this.schema,String(e),t):new jt(this,e)}trim(){for(;void 0===this.items[this.items.length-1];)this.items.pop()}}class At extends wt{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&(e.value[t]={}),this.key=this.name+"@"+Date.now()}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}}class jt extends xt{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&void 0!==e.schema.defaultValue&&(e.value[t]=e.schema.defaultValue),this.key=this.name+"@"+Date.now()}get isScalar(){return!0}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}getInputType(){return vt(this.name,this.schema)}}function Ot({label:t,required:r,children:n}){return e(s,{label:t,required:r,children:n})}function $t({children:t}){return e("p",{className:"mt-2 text-sm text-gray-500",children:t})}function Pt({children:t}){return e("p",{className:"mt-2 text-sm text-red-600",children:t})}function It({data:t,className:r}){const{theme:n}=a(),i=A(()=>{try{return JSON.stringify(t,null,2)}catch(e){return console.error("Failed to stringify JSON:",e),"{}"}},[t]);return e("div",{className:`h-full ${r||""}`,children:e(Ze,{value:i,language:"json",theme:"dark"===n?"vs-dark":"vs",options:{readOnly:!0,domReadOnly:!0}})})}function Lt({value:t}){return e("div",{className:"flex flex-col gap-4",children:Object.entries(t).map(([t,r])=>e(Tt,{name:t,value:r},t))})}function Rt({name:t}){return e("div",{className:"text-md font-semibold",children:bt(t)})}function Et({children:t,className:r}){return e("div",{className:x("flex flex-col gap-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 dark:border-l-slate-600",r),children:t})}function Tt({name:r,value:n}){const a=qt(n);switch(a.type){case zt.Inline:return t("div",{className:"w-full flex gap-2",children:[e(Rt,{name:r+":"}),e("p",{children:a.value})]});case zt.Paragraph:return t("div",{children:[e(Rt,{name:r}),e("p",{children:a.value})]});case zt.Prose:return t("div",{className:"prose dark:prose-invert",children:[e(Rt,{name:r}),e("div",{className:"vprose dark:prose-invert",children:a.value})]});case zt.Array:return e(Ft,{name:r,value:n});case zt.Object:return t("div",{children:[e(Rt,{name:r}),e(Et,{className:"mt-2",children:Object.entries(n).map(([t,r])=>e(Tt,{name:t,value:r},t))})]})}}function Ft({name:r,value:n}){const a=n.join(" ").length,i=a/n.length,s="string"==typeof n[0]&&(a<80||a<400&&i<32),o=n.length>9;return t("div",s?{className:"flex gap-2 flex-wrap",children:[r&&e(Rt,{name:r+":"}),n.map((t,r)=>e(l,{children:String(t)},r))]}:{children:[r&&e(Rt,{name:r}),e("div",{className:"flex flex-col gap-2",children:n.map((t,r)=>e(Dt,{index:r,value:t,useBullet:o},r))})]})}function Dt({index:r,value:n,useBullet:a}){const i=a?e("span",{className:"text-xl",children:"•"}):t("span",{children:[r+1,"."]}),s=qt(n);let o;switch(s.type){case zt.Object:o=e(Et,{children:Object.entries(n).map(([t,r])=>e(Tt,{name:t,value:r},t))});break;case zt.Array:o=e(Ft,{value:n});break;case zt.Prose:o=e("div",{className:"prose dark:prose-invert",children:s.value});break;default:o=e("div",{children:s.value})}return t("div",{className:"flex gap-4 hover:bg-slate-50 dark:hover:bg-slate-800 py-2 pr-2 pl-4",children:[e("div",{className:"font-semibold text-gray-600 dark:text-gray-400",children:i}),e("div",{children:o})]})}var zt;function qt(e){if(null==e)return{value:"-",type:zt.Inline};if(Array.isArray(e))return{value:e,type:zt.Array};const t=typeof e;if("string"===t){const t=e.length;let r;return t<80?r=zt.Inline:t>400?r=zt.Prose:(r=zt.Paragraph,e=e.replace(/(?:\n\n)+/g,"\n\n")),{type:r,value:e}}return"number"===t||"boolean"===t?{value:String(e),type:zt.Inline}:{value:e,type:zt.Object}}function Vt({value:t,viewCode:r=!1}){return t?e("div",{className:"relative w-full h-full",children:r?e(It,{data:t}):e(Lt,{value:t})}):e("pre",{className:"whitespace-pre-wrap",children:"No Data to display"})}!function(e){e[e.Inline=0]="Inline",e[e.Paragraph=1]="Paragraph",e[e.Prose=2]="Prose",e[e.Array=3]="Array",e[e.Object=4]="Object"}(zt||(zt={}));class Mt{components={};registerComponent(e,t){this.components[e]=t}getComponent(e){return this.components[e]}}const _t=O(null);function Ut({components:t,children:n}){const a=A(()=>{const e=new Mt;for(const[r,n]of Object.entries(t))e.registerComponent(r,n);return e},[t]);return e(r,{children:e(_t.Provider,{value:a,children:n})})}function Wt(){return $(_t)}function Ht(e){const t=$(_t);if(t)return t.getComponent(e)}const Bt=O(null);function Jt(){return $(Bt)}function Kt(e,t,r="inline"){return`artifact:${e}:${t}:${r}`}function Gt(e){return`file:${e}`}function Xt(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:e.slice(6).trim()}:e.startsWith("document://")?{scheme:"document",path:e.slice(11).trim()}:e.startsWith("collection:")?{scheme:"collection",path:e.slice(11).trim()}:{scheme:"standard",path:e}}function Yt(e,t){switch(e){case"store":case"document":return t?`/store/objects/${t}`:null;case"collection":return t?`/store/collections/${t}`:null;default:return null}}function Zt({rawUrl:e,artifactRunId:t,disposition:r="inline"}){const{client:n}=Ce(),a=Jt(),i=C(n);i.current=n;const s=C(a);s.current=a;const{scheme:o,path:l}=Xt(e),c=Yt(o,l),[d,u]=k(()=>{if(c)return{url:c,isLoading:!1,error:void 0};if("standard"===o)return{url:e,isLoading:!1,error:void 0};if(a&&("artifact"===o||"image"===o)){let e;e="artifact"===o&&t&&!l.startsWith("agents/")?Kt(t,l,r):Gt(l);const n=a.getUrl(e);if(n)return{url:n,isLoading:!1,error:void 0}}return{url:void 0,isLoading:!0,error:void 0}}),[h,m]=k(0),p=j(async()=>{if(c||"standard"===o)return;if("artifact"!==o&&"image"!==o)return void u({url:void 0,isLoading:!1,error:`Unknown scheme: ${o}`});u(e=>({...e,isLoading:!0,error:void 0}));const e=i.current,n=s.current;try{let a;if("artifact"===o)if(t&&!l.startsWith("agents/")){const i=Kt(t,l,r);if(n)a=await n.getOrFetch(i,async()=>(await e.files.getArtifactDownloadUrl(t,l,r)).url);else{a=(await e.files.getArtifactDownloadUrl(t,l,r)).url}}else{const t=Gt(l);if(n)a=await n.getOrFetch(t,async()=>(await e.files.getDownloadUrl(l)).url);else{a=(await e.files.getDownloadUrl(l)).url}}else{const t=Gt(l);if(n)a=await n.getOrFetch(t,async()=>(await e.files.getDownloadUrl(l)).url);else{a=(await e.files.getDownloadUrl(l)).url}}u({url:a,isLoading:!1,error:void 0})}catch(e){const t=e instanceof Error?e.message:"Failed to resolve URL";console.error("Failed to resolve URL:",l,e),u({url:void 0,isLoading:!1,error:t})}},[o,l,t,r,c]);S(()=>{if(d.url&&!d.error)return;let e=!1;return e||(async()=>{await p()})(),()=>{e=!0}},[p,h,d.url,d.error]);const f=j(()=>{u({url:void 0,isLoading:!0,error:void 0}),m(e=>e+1)},[]);return{url:d.url,isLoading:d.isLoading,error:d.error,scheme:o,retry:f}}const Qt={chart:{icon:W,label:"chart",defaultHeight:200},mermaid:{icon:U,label:"diagram",defaultHeight:150},proposal:{icon:_,label:"options",defaultHeight:100},code:{icon:F,label:"code",defaultHeight:80},image:{icon:M,label:"image",defaultHeight:150},link:{icon:V,label:"link",defaultHeight:24},expand:{icon:q,label:"content",defaultHeight:100},table:{icon:z,label:"table",defaultHeight:150},markdown:{icon:D,label:"content",defaultHeight:100},"fusion-fragment":{icon:F,label:"fragment",defaultHeight:150}};function er({type:r,error:n,onRetry:a,message:i,height:s}){const o=Qt[r],l=s??o.defaultHeight,c="link"===r;if(n)return t("div",{className:"flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive "+(c?"inline-flex px-2 py-1 text-sm":"p-4"),style:c?void 0:{minHeight:l},children:[t("span",{className:"text-destructive",children:["Failed to load ",o.label]}),a&&e("button",{onClick:a,className:"ml-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors",children:"Retry"})]});const d=o.icon;return c?t("span",{className:"inline-flex items-center gap-1 text-muted animate-pulse",children:[e(d,{className:"h-3 w-3"}),e("span",{children:i||`Loading ${o.label}...`})]}):t("div",{className:"flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse",style:{minHeight:l},children:[e(d,{className:"h-8 w-8 text-muted"}),e("span",{className:"text-sm text-muted",children:i||`Loading ${o.label}...`}),e("div",{className:"flex gap-1",children:[...Array(3)].map((t,r)=>e("div",{className:"h-2 w-2 rounded-full bg-muted animate-bounce",style:{animationDelay:150*r+"ms"}},r))})]})}class tr extends N.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){const{type:r,fallbackCode:n}=this.props;return t("div",{className:"space-y-2",children:[e(er,{type:r,error:this.state.error?.message||"Rendering failed",onRetry:this.handleRetry}),n&&t("details",{className:"text-sm",children:[e("summary",{className:"cursor-pointer text-muted hover:text-foreground",children:"Show raw content"}),e("pre",{className:"mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs",children:e("code",{children:n})})]})]})}return this.props.children}}function rr({node:t,href:r,children:n,className:a,artifactRunId:i,ExistingLink:s,...o}){const l=r||"",{scheme:c,path:d}=Xt(l),u=Yt(c,d);return u?"function"==typeof s?e(s,{node:t,href:u,...o,children:n}):e("a",{href:u,...o,className:a,target:"_blank",rel:"noopener noreferrer",children:n}):"standard"===c?"function"==typeof s?e(s,{node:t,href:r,...o,children:n}):e("a",{href:r,...o,className:a,target:"_blank",rel:"noopener noreferrer",children:n}):e(nr,{rawHref:l,artifactRunId:i,className:a,rest:o,children:n})}function nr({rawHref:t,artifactRunId:r,className:n,children:a,rest:i}){const{url:s,isLoading:o,error:l,retry:c}=Zt({rawUrl:t,artifactRunId:r,disposition:"attachment"});return o?e("span",{className:"inline-flex items-center gap-1 text-muted",children:e(er,{type:"link"})}):l?e("span",{className:"inline-flex items-center gap-1",children:e(er,{type:"link",error:l,onRetry:c})}):e("a",{href:s||"#",...i,className:n,target:"_blank",rel:"noopener noreferrer",children:a})}function ar({node:t,src:r,alt:n,className:a,artifactRunId:i,ExistingImg:s,...o}){const l=r||"",{scheme:c}=Xt(l);return"standard"===c?"function"==typeof s?e(s,{node:t,src:r,alt:n,...o}):e("img",{src:r,alt:n,className:a,...o}):e(ir,{rawSrc:l,alt:n,artifactRunId:i,className:a,rest:o})}function ir({rawSrc:t,alt:r,artifactRunId:n,className:a,rest:i}){const{url:s,isLoading:o,error:l,retry:c}=Zt({rawUrl:t,artifactRunId:n,disposition:"inline"});return o?e(er,{type:"image",message:r?`Loading ${r}...`:void 0}):l?e(er,{type:"image",error:l,onRetry:c}):s?e("img",{src:s,alt:r,className:a,...i}):null}function sr({src:r,alt:n,caption:a,className:i,artifactRunId:s}){const o=r||"",{scheme:l}=Xt(o);return"standard"===l?t("figure",{className:"my-4",children:[e("img",{src:r,alt:n,className:i}),e("figcaption",{className:"mt-2 text-sm text-muted text-center italic",children:a})]}):e(or,{rawSrc:o,alt:n,caption:a,artifactRunId:s,className:i})}function or({rawSrc:r,alt:n,caption:a,artifactRunId:i,className:s}){const{url:o,isLoading:l,error:c,retry:d}=Zt({rawUrl:r,artifactRunId:i,disposition:"inline"});return l?e(er,{type:"image",message:n?`Loading ${n}...`:void 0}):c?e(er,{type:"image",error:c,onRetry:d}):o?t("figure",{className:"my-4",children:[e("img",{src:o,alt:n,className:s}),e("figcaption",{className:"mt-2 text-sm text-muted text-center italic",children:a})]}):null}const lr={note:"md-callout-info",tip:"md-callout-info",warning:"md-callout-attention",important:"md-callout-attention",caution:"md-callout-destructive"},cr={note:"Note",tip:"Tip",warning:"Warning",important:"Important",caution:"Caution"};function dr(){return e=>{Ne(e,e=>{if("containerDirective"!==e.type&&"leafDirective"!==e.type&&"textDirective"!==e.type)return;const t=e,r=t.data||(t.data={}),n=t.attributes||{},a=t.name;if("pagebreak"===a)return r.hName="hr",void(r.hProperties={className:"md-pagebreak"});if("columns"===a)return r.hName="div",void(r.hProperties={className:"md-columns"});if("column"===a){r.hName="div";const e={className:"md-column"};return n.width&&(e.style=`flex-basis:${n.width};flex-grow:0;flex-shrink:0`),void(r.hProperties=e)}if(a in lr){r.hName="div",r.hProperties={className:`md-callout ${lr[a]}`,"data-callout-type":a};const e=cr[a];if(e&&t.children){const r={type:"paragraph",data:{hName:"p",hProperties:{className:"md-callout-title"}},children:[{type:"text",value:e}]};t.children.unshift(r)}return}r.hName="div",r.hProperties={className:`md-${a}`,...Object.fromEntries(Object.entries(n).filter(([e])=>"class"!==e))},n.class&&(r.hProperties.className+=` ${n.class}`)})}}const ur=["artifact:","image:","store:","document://","collection:"],hr=/(!?\[[^\]\n]*\]\()((?:artifact:|image:|store:|document:\/\/|collection:)[^)]+)(\))/g,mr=/`[^`\n]*`/g,pr=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,fr=/\s+("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\([^)]*\))\s*$/;function gr(e){return ur.some(t=>e.startsWith(t))}function yr(e){return e.replace(hr,(e,t,r,n)=>`${t}${function(e){const t=e.trim();if(t.startsWith("<")){const r=t.indexOf(">");if(r>0&&gr(t.slice(1,r).trim()))return e}const r=t.match(fr),n=r?.index??-1,a=(n>=0?t.slice(0,n):t).trim(),i=n>=0?t.slice(n):"";return gr(a)?`<${a}>${i}`:e}(r)}${n}`)}function br(e){let t,r="",n=0;for(mr.lastIndex=0;null!==(t=mr.exec(e));)r+=yr(e.slice(n,t.index)),r+=t[0],n=t.index+t[0].length;return r+=yr(e.slice(n)),r}const vr=/^([ \t]*):::\s*(\w+)\s*(.*?)\s*:::[ \t]*$/gm;function xr(...e){return Oe(w(e))}function wr({error:r,chartTitle:n}){return e("div",{className:"flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4",children:t("div",{className:"text-center",children:[t("p",{className:"text-sm font-medium text-red-600 dark:text-red-400",children:["Cannot render ",n||"Vega-Lite"," chart"]}),e("p",{className:"text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate",children:r})]})})}function Nr({isOpen:r,onClose:n,title:a,description:i,children:s}){return e(Se.Root,{open:r,onOpenChange:e=>!e&&n(),children:t(Se.Portal,{children:[e(Se.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"}),t(Se.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:n,children:[e(Se.Close,{asChild:!0,children:e("button",{onClick:n,className:"absolute top-3 right-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":"Close fullscreen",children:e(X,{className:"w-5 h-5 text-gray-600 dark:text-gray-300"})})}),e("div",{className:"flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150",children:s}),e("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:t("div",{className:"flex flex-col",children:[e(Se.Title,{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:a||"Dashboard"}),i&&e(Se.Description,{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5",children:i})]})})]})]})})}const kr={categorical:["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"],blues:["#dbeafe","#93c5fd","#3b82f6","#1d4ed8","#1e3a8a"],purples:["#f3e8ff","#c4b5fd","#8b5cf6","#6d28d9","#4c1d95"],diverging:["#ef4444","#fca5a5","#fef3c7","#86efac","#22c55e"]};function Cr(e,t){if(!e||!e.encoding)return!1;for(const r of t)for(const t of Object.values(e.encoding))if(t&&"object"==typeof t&&t.field===r)return!0;if(Array.isArray(e.layer))for(const r of e.layer)if(Cr(r,t))return!0;return!1}function Sr(e,t){if(!e)return!1;const r=e=>{if(!e)return!1;const r=e.color?.field;return r&&t.includes(r)};if(r(e.encoding))return!0;if(Array.isArray(e.layer))for(const t of e.layer)if(r(t.encoding))return!0;return!1}function Ar(e,t=[]){const r=[];if(!e||"object"!=typeof e)return r;if(e.data&&"object"==typeof e.data){const n=e.data.url;"string"==typeof n&&n.startsWith("artifact:")&&r.push({path:[...t,"data"],artifactPath:n.replace(/^artifact:/,"").trim()})}const n=["layer","vconcat","hconcat","concat","spec","repeat","facet"];for(const a of n)if(a in e){const n=e[a];Array.isArray(n)?n.forEach((e,n)=>{r.push(...Ar(e,[...t,a,String(n)]))}):"object"==typeof n&&null!==n&&r.push(...Ar(n,[...t,a]))}return r}const jr=P(function({spec:n,artifactRunId:a}){const{title:i,description:s,spec:o,options:l}=n,[c,d]=k(!1),[u,h]=k(!1),[m,p]=k(null),[f,g]=k(!1),y=C(null),b=C(null),v=C(null),{client:x}=Ce(),w=Jt(),N=C(x);N.current=x;const O=C(w);O.current=w;const[$,P]=k(null),[I,L]=k(!1),[R,E]=k(null),T=l?.mode||"chart",F="dashboard"===T,D=l?.enableFullscreen??F,z=l?.height||function(e,t){if("chart"===t)return 280;let r=1;if(e.vconcat)r=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){const t=e.columns||2,n=Array.isArray(e.concat)?e.concat.length:1;r=Math.ceil(n/t)}else e.facet&&(r=2);return Math.max(500,280*r+40)}(o,T);S(()=>{const e=Ar(o);if(0===e.length)return P(o),L(!1),void E(null);let t=!1;L(!0),E(null);return(async()=>{const r=new Map,n=N.current,i=O.current;for(const s of e)try{const e=s.path.join(".");let t;if(a&&!s.artifactPath.startsWith("agents/")){const e=Kt(a,s.artifactPath,"inline");if(i)t=await i.getOrFetch(e,async()=>(await n.files.getArtifactDownloadUrl(a,s.artifactPath,"inline")).url);else{t=(await n.files.getArtifactDownloadUrl(a,s.artifactPath,"inline")).url}}else{const e=Gt(s.artifactPath);if(i)t=await i.getOrFetch(e,async()=>(await n.files.getDownloadUrl(s.artifactPath)).url);else{t=(await n.files.getDownloadUrl(s.artifactPath)).url}}const o=await fetch(t);if(!o.ok)throw new Error(`Failed to fetch artifact data: ${o.statusText}`);let l;if(s.artifactPath.toLowerCase().endsWith(".csv")){const e=await o.text();l=Ae.parse(e,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{const e=await o.json();l=Array.isArray(e)?e:[e]}r.set(e,l)}catch(e){return console.error(`Failed to resolve artifact: ${s.artifactPath}`,e),void(t||E(`Failed to load data from artifact: ${s.artifactPath}`))}if(!t){const e=function(e,t){const r=JSON.parse(JSON.stringify(e));for(const[e,n]of t){const t=e.split(".");let a=r;for(let e=0;e<t.length-1&&void 0!==a[t[e]];e++)a=a[t[e]];const i=t[t.length-1];a[i]&&"object"==typeof a[i]&&(delete a[i].url,a[i].values=n)}return r}(o,r);P(e),L(!1)}})(),()=>{t=!0}},[o,a]);const[V,M]=k(!1),_=C(!1);S(()=>{const e=()=>{const e=document.documentElement.classList.contains("dark");e!==_.current&&(_.current=e,M(e))};e();const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const[U,W]=k(0),X=C(0);S(()=>{if(!v.current)return;let e;const t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{const e=t[0]?.contentRect.width;e&&e!==X.current&&(X.current=e,W(e))},100)});t.observe(v.current);const r=v.current.clientWidth;return X.current=r,W(r),()=>{clearTimeout(e),t.disconnect()}},[]);const Y=A(()=>Ar(o).length>0,[o]),Z=A(()=>{if(Y&&!$)return null;let e=$||o;return e?(l?.parameterValues&&(e=function(e,t){if(!t||0===Object.keys(t).length)return e;const r=JSON.parse(JSON.stringify(e)),n=e=>{for(const r of e)r&&"object"==typeof r&&r.name&&r.name in t&&(r.value=t[r.name])};Array.isArray(r.params)&&n(r.params);const a=e=>{if(Array.isArray(e))for(const t of e)if(t&&Array.isArray(t.params)&&n(t.params),t.vconcat&&a(t.vconcat),t.hconcat&&a(t.hconcat),t.concat&&a(t.concat),Array.isArray(t.layer))for(const e of t.layer)e&&Array.isArray(e.params)&&n(e.params)};if(r.vconcat&&a(r.vconcat),r.hconcat&&a(r.hconcat),r.concat&&a(r.concat),Array.isArray(r.layer))for(const e of r.layer)e&&Array.isArray(e.params)&&n(e.params);return r}(e,l.parameterValues)),function(e){const t=JSON.parse(JSON.stringify(e)),r=["vconcat","hconcat","concat"];if(!r.some(e=>Array.isArray(t[e])))return t;const n=[];if(Array.isArray(t.params))for(const e of t.params)e&&"object"==typeof e&&e.name&&e.select&&n.push({name:e.name,param:e});if(0===n.length)return t;for(const{name:e,param:a}of n){const n=a.select?.fields||[],i="legend"===a.select?.bind;let s=null;for(const e of r)if(Array.isArray(t[e])){s=t[e];break}if(!s||0===s.length)continue;let o=0;for(let e=0;e<s.length;e++){const t=s[e];if(Cr(t,n)||i&&Sr(t,n)){o=e;break}}const l=s[o];l.params||(l.params=[]),l.params.push(a),t.params=t.params.filter(t=>t.name!==e)}return Array.isArray(t.params)&&0===t.params.length&&delete t.params,t}(e)):null},[$,o,Y,l?.parameterValues]),Q=j((e,t)=>{if(!e||"object"!=typeof e)return e;if(e.hconcat&&Array.isArray(e.hconcat)){const r=e.hconcat.length,n=(e.spacing??10)*(r-1),a=Math.floor((t-n)/r);return{...e,hconcat:e.hconcat.map(e=>Q(e,a))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>Q(e,t))};if(e.concat&&Array.isArray(e.concat)){const r=e.columns??e.concat.length,n=(e.spacing??10)*(r-1),a=Math.floor((t-n)/r);return{...e,concat:e.concat.map(e=>Q(e,a))}}const r=e.width;return"container"===r||"number"==typeof r&&r>t?{...e,width:t}:e},[]),ee=j((e,t=!1)=>{if(!Z)return null;const r=function(e){const t={background:"transparent",view:{stroke:"transparent"},range:{category:kr.categorical,diverging:kr.diverging,heatmap:kr.purples,ramp:kr.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}}}(V),n=t?"undefined"!=typeof window?Math.min(window.innerWidth-80,1400):1200:U>0?U-24:500,a="vconcat"in Z||"hconcat"in Z||"concat"in Z,s=a?{type:"pad",contains:"padding"}:{type:"fit",contains:"padding"};let o=Z;a&&n&&(o=Q(Z,n));const l=o.width,c=a?void 0:"container"===l?n:l??n,{width:d,...u}=o;return{$schema:"https://vega.github.io/schema/vega-lite/v6.json",...!a&&c?{width:c}:{},height:t?void 0:e,autosize:s,...a?o:u,...i&&!Z.title?{title:i}:{},config:{...r,...Z.config}}},[Z,i,V,U,Q]),te=j(async()=>{const e=f?b.current:y.current;if(e&&!u)try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),h(!0),setTimeout(()=>h(!1),2e3))},"image/png")}catch(e){console.error("Failed to copy chart:",e)}},[u,f]),re=j(async()=>{const e=f?b.current:y.current;if(e&&!c){d(!0);try{const t=await e.toImageURL("png",2),r=document.createElement("a");r.download=`${i||"chart"}.png`,r.href=t,r.click()}catch(e){console.error("Failed to export chart:",e)}finally{d(!1)}}},[i,c,f]),ne=j(e=>{y.current=e,p(null)},[]),ae=j(e=>{b.current=e},[]),ie=j(e=>{console.error("Vega-Lite rendering error:",e),p(e instanceof Error?e.message:"Unknown error")},[]),se=j(()=>{g(e=>!e)},[]);S(()=>{p(null)},[o]);const oe=({className:r})=>t("div",{className:xr("flex items-center gap-2",r),children:[t("button",{onClick:te,disabled:u,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:"Copy to clipboard",children:[e(u?B:J,{className:"w-3 h-3"}),u?"Copied":"Copy"]}),t("button",{onClick:re,disabled:c,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:"Export as PNG",children:[e(q,{className:"w-3 h-3"}),c?"Exporting...":"Export"]}),D&&t("button",{onClick:se,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:f?"Exit fullscreen":"Fullscreen",children:[e(f?K:G,{className:"w-3 h-3"}),f?"Exit":"Fullscreen"]})]});if(I||Y&&!$)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:i||"Chart"})}),e("div",{className:"flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded",style:{width:"100%",height:z},children:t("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e(H,{className:"w-5 h-5 animate-spin"}),e("span",{className:"text-sm",children:"Loading data from artifacts..."})]})})]})});if(R)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:i||"Chart"})}),e("div",{style:{width:"100%",height:z},children:e(wr,{error:R,chartTitle:i})})]})});if(m)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:i||"Chart"})}),e("div",{style:{width:"100%",height:z},children:e(wr,{error:m,chartTitle:i})})]})});const le=ee(z),ce=ee(0,!0);return le?("undefined"!=typeof window&&localStorage.getItem("DEBUG_VEGA_RENDERS")&&console.log("VegaLite rendering with spec:",{title:i,hasData:!!le.data?.values,dataLength:le.data?.values?.length}),t(r,{children:[e("div",{className:xr("bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",F&&"border-2"),children:t("div",{className:"flex flex-col gap-2 p-3",children:[t("div",{className:"flex items-center justify-between",children:[t("div",{className:"flex items-center gap-2",children:[e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:i||(F?"Dashboard":"Chart")}),F&&e("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"})]}),e(oe,{})]}),s&&e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:s}),e("div",{ref:v,className:"bg-white dark:bg-gray-900 rounded overflow-hidden",style:{width:"100%",height:z,minWidth:0},children:e(je,{spec:le,onEmbed:e=>ne(e.view),onError:ie,options:{renderer:l?.renderer||"canvas",actions:!1}})})]})}),t(Nr,{isOpen:f,onClose:()=>g(!1),title:i||(F?"Dashboard":"Chart"),description:s,children:[e("div",{className:"w-full h-full min-h-[calc(100vh-200px)]",children:ce&&e(je,{spec:ce,onEmbed:e=>ae(e.view),onError:ie,options:{renderer:l?.renderer||"canvas",actions:!1}})}),e("div",{className:"absolute bottom-6 right-6",children:e(oe,{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),Or='Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';function $r({code:t,className:r}){const n=C(null),[a,i]=k(null),[s,o]=k(null),l=I().replace(/:/g,"_");return S(()=>{let e=!1;return(async()=>{if(!t.trim())return i(null),void o(null);try{o(null);const r=`mermaid-${l}-${Date.now()}`,n=function(e){const t=e.trim();let r="",n=!1,a=!1;for(let e=0;e<t.length;e++){const i=t[e],s=e>0?t[e-1]:"";if('"'!==i||a||"\\"===s)if("'"!==i||n||"\\"===s){if((n||a)&&"\\"===i){let n=e;for(;"\\"===t[n];)n++;if("n"===t[n]){r+="<br/>",e=n;continue}}r+=i}else a=!a,r+=i;else n=!n,r+=i}return r}(t),{svg:a}=await $e.render(r,n),s=function(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let r=t.replace(/\swidth="[^"]*"/i,"").replace(/\sheight="[^"]*"/i,"");return/style="/i.test(r)?r=r.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):r+=' style="width:100%;height:auto;display:block;max-width:100%;"',/preserveAspectRatio=/i.test(r)||(r+=' preserveAspectRatio="xMidYMid meet"'),`<svg${r}>`})}(a);e||i(s)}catch(t){if(!e){const e=t instanceof Error?t.message:"Failed to render mermaid diagram";o(e),i(null)}}})(),()=>{e=!0}},[t,l]),s?null:e("div",a?{ref:n,className:`my-4 w-full overflow-x-auto [&_svg]:mx-auto [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-w-full ${r||""}`,dangerouslySetInnerHTML:{__html:a}}:{className:`my-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg animate-pulse ${r||""}`,children:e("div",{className:"h-32 bg-gray-200 dark:bg-gray-700 rounded"})})}$e.initialize({startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:Or,suppressErrorRendering:!0,flowchart:{htmlLabels:!0,useMaxWidth:!0,nodeSpacing:40,rankSpacing:50,padding:12},sequence:{useMaxWidth:!0},themeVariables:{fontFamily:Or}});const Pr={default:{border:"border-l-attention",bg:"bg-amber-50 dark:bg-amber-900/20",icon:"text-attention"},warning:{border:"border-l-destructive",bg:"bg-red-50 dark:bg-red-900/20",icon:"text-destructive"},info:{border:"border-l-info",bg:"bg-blue-50 dark:bg-blue-900/20",icon:"text-info"},success:{border:"border-l-success",bg:"bg-green-50 dark:bg-green-900/20",icon:"text-success"}},Ir={default:Q,warning:Z,info:_,success:Y};function Lr({question:r,description:n,options:a,onSelect:i,onMultiSelect:s,onSubmit:l,allowFreeResponse:c=!1,multiSelect:d=!1,placeholder:u="Type your response...",isLoading:h=!1,icon:m,variant:p="default",hideIcon:f=!1,hideBorder:g=!1,className:y,cardClassName:b,headerClassName:v,iconClassName:x,questionClassName:w,descriptionClassName:k,optionsClassName:C,buttonClassName:S,inputContainerClassName:A,inputClassName:j,submitButtonClassName:O}){const[$,P]=N.useState(""),[I,L]=N.useState(new Set),R=N.useRef(null),E=Pr[p],T=Ir[p],F=()=>{$.trim()&&l&&(l($.trim()),P(""))},D=g?"":`border-l-4 ${E.border}`;return e("div",{className:`my-4 font-sans ${y||""}`,children:t("div",{className:`${D} ${E.bg} rounded-r-lg shadow-sm ${b||""}`,children:[e("div",{className:`px-4 py-3 ${v||""}`,children:t("div",{className:"flex items-start gap-3",children:[!f&&e("div",{className:`flex-shrink-0 mt-0.5 ${E.icon} ${x||""}`,children:m||e(T,{className:"size-5"})}),t("div",{className:"flex-1 min-w-0",children:[e("div",{className:`prose prose-sm dark:prose-invert max-w-none text-gray-900 dark:text-gray-100 ${w||""}`,children:e(Pe,{children:r})}),n&&e("p",{className:`mt-1 text-sm text-gray-600 dark:text-gray-400 ${k||""}`,children:n})]})]})}),a&&a.length>0&&e("div",{className:`px-4 pb-3 pt-1 ${C||""}`,children:d?t("div",{className:"space-y-2",children:[a.map(r=>t("label",{className:`flex items-start gap-3 px-4 py-3 rounded-lg cursor-pointer transition-colors\n ${I.has(r.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"}\n ${h?"opacity-50 cursor-not-allowed":""}`,children:[e("input",{type:"checkbox",checked:I.has(r.id),onChange:()=>{return e=r.id,void L(t=>{const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r});var e},disabled:h,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"}),t("div",{className:"flex-1 overflow-hidden",children:[t("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100 break-words",children:[r.icon,e("span",{className:"break-words",children:r.label})]}),r.description&&e("div",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400 break-words whitespace-pre-wrap",children:r.description})]})]},r.id)),e("div",{className:"pt-2",children:t(o,{size:"sm",onClick:()=>{I.size>0&&s&&(s(Array.from(I)),L(new Set))},disabled:h||0===I.size,className:"flex items-center gap-2",children:[e(ee,{className:"size-4"}),"Submit Selection",I.size>0?` (${I.size})`:""]})})]}):e("div",{className:"flex flex-col gap-2 w-full",children:a.map(r=>e("button",{onClick:()=>i?.(r.id),disabled:h,className:`w-full text-left px-4 py-3 rounded-lg border border-gray-200 dark:border-gray-700\n bg-white dark:bg-gray-800\n hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-600\n focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1\n transition-colors\n ${h?"opacity-50 cursor-not-allowed":"cursor-pointer"}\n ${S||""}`,children:t("div",{className:"flex items-start gap-3",children:[r.icon&&e("span",{className:"flex-shrink-0 mt-0.5 text-gray-500 dark:text-gray-400",children:r.icon}),t("div",{className:"flex-1 overflow-hidden",children:[e("div",{className:"font-medium text-sm text-gray-900 dark:text-gray-100 break-words",children:r.label}),r.description&&e("div",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400 break-words whitespace-pre-wrap",children:r.description})]})]})},r.id))})}),c&&e("div",{className:`px-4 pb-3 pt-1 ${A||""}`,children:t("div",{className:"flex gap-2",children:[e("input",{ref:R,type:"text",value:$,onChange:e=>P(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),F())},placeholder:u,disabled:h,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 ${j||""}`}),e(o,{size:"sm",onClick:F,disabled:h||!$.trim(),className:O,children:h?"...":"Send"})]})})]})})}function Rr({runId:e,path:t,parseJson:r=!0}){const{client:n}=Ce(),a=Jt(),i=C(n);i.current=n;const s=C(a);s.current=a;const[o,l]=k({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),[c,d]=k(0),u=j(async()=>{if(!e)return void l({data:void 0,rawContent:void 0,isLoading:!1,error:"No run ID provided",contentType:void 0});if(!t)return void l({data:void 0,rawContent:void 0,isLoading:!1,error:"No artifact path provided",contentType:void 0});l(e=>({...e,isLoading:!0,error:void 0}));const n=i.current,a=s.current,o=function(e){const t=e.split(".").pop()?.toLowerCase();switch(t){case"json":return"json";case"md":case"txt":case"csv":case"yaml":case"yml":default:return"text";case"png":case"jpg":case"jpeg":case"gif":case"webp":case"pdf":return"binary"}}(t);try{const i=Kt(e,t,"inline");let s;if(a)s=await a.getOrFetch(i,async()=>(await n.files.getArtifactDownloadUrl(e,t,"inline")).url);else{s=(await n.files.getArtifactDownloadUrl(e,t,"inline")).url}const c=await fetch(s);if(!c.ok)throw new Error(`Failed to fetch artifact: ${c.status} ${c.statusText}`);if("binary"===o)return void l({data:s,rawContent:void 0,isLoading:!1,error:void 0,contentType:o});const d=await c.text();let u;if(r&&"json"===o)try{u=JSON.parse(d)}catch{u=d}else u=d;l({data:u,rawContent:d,isLoading:!1,error:void 0,contentType:o})}catch(e){const r=e instanceof Error?e.message:"Failed to fetch artifact";console.error("Failed to fetch artifact content:",t,e),l({data:void 0,rawContent:void 0,isLoading:!1,error:r,contentType:o})}},[e,t,r]);S(()=>{u()},[u,c]);const h=j(()=>{l({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),d(e=>e+1)},[]);return{data:o.data,rawContent:o.rawContent,isLoading:o.isLoading,error:o.error,contentType:o.contentType,retry:h}}function Er(e){if("object"!=typeof e||null===e)return null;const t=e;return"vega-lite"===t.library&&"spec"in t&&"object"==typeof t.spec&&null!==t.spec?t:"string"==typeof t.$schema&&t.$schema.includes("vega")?{library:"vega-lite",spec:t}:null}function Tr({content:r}){const{headers:n,rows:a}=A(()=>{if(!Array.isArray(r)||0===r.length)return{headers:[],rows:[]};const e=r[0];if("object"!=typeof e||null===e)return{headers:[],rows:[]};const t=Object.keys(e),n=r.map(e=>t.map(t=>{const r=e[t];return null==r?"":"object"==typeof r?JSON.stringify(r):String(r)}));return{headers:t,rows:n}},[r]);return 0===n.length?e(er,{type:"table",error:"No table data found"}):t("div",{className:"overflow-x-auto",children:[t("table",{className:"min-w-full text-sm border-collapse",children:[e("thead",{children:e("tr",{className:"border-b",children:n.map((t,r)=>e("th",{className:"px-3 py-2 text-left font-medium text-muted",children:t},r))})}),e("tbody",{children:a.slice(0,100).map((t,r)=>e("tr",{className:"border-b border-muted/20",children:t.map((t,r)=>e("td",{className:"px-3 py-2",children:t},r))},r))})]}),a.length>100&&t("div",{className:"text-sm text-muted py-2",children:["Showing 100 of ",a.length," rows"]})]})}function Fr({content:t,path:r}){const n=r.split(".").pop()?.toLowerCase()||"",a="string"==typeof t?t:JSON.stringify(t,null,2);return e("pre",{className:"overflow-x-auto p-3 bg-muted/10 rounded text-sm",children:e("code",{className:`language-${n}`,children:a})})}function Dr(e){return Ie.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:["use"],FORBID_TAGS:["foreignObject"]})}function zr(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let r=t;if(!/viewBox/i.test(r)){const e=/\swidth\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(r),t=/\sheight\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(r);e&&t&&(r+=` viewBox="0 0 ${e[1]} ${t[1]}"`)}return r=r.replace(/\swidth\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,"").replace(/\sheight\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,""),/style="/i.test(r)?r=r.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):r+=' style="width:100%;height:auto;display:block;max-width:100%;"',/preserveAspectRatio=/i.test(r)||(r+=' preserveAspectRatio="xMidYMid meet"'),`<svg${r}>`})}function qr({content:t}){const r=A(()=>{const e="string"==typeof t?t.trim():"";return e?zr(Dr(e)):null},[t]);return r?e("div",{style:{margin:"16px 0",width:"100%",overflowX:"auto"},dangerouslySetInnerHTML:{__html:r}}):e(er,{type:"expand",error:"Empty mockup"})}function Vr({content:t,path:r}){const n="string"==typeof t?t:"",a=r.split("/").pop()||"Artifact image";return e("img",{src:n,alt:a,className:"max-w-full h-auto rounded",loading:"lazy"})}function Mr({content:t,renderType:r,path:n,runId:a,contentType:i}){const s=A(()=>"auto"!==r?r:function(e,t,r){const n=t.split(".").pop()?.toLowerCase();if("svg"===n)return"mockup";if(["png","jpg","jpeg","gif","webp"].includes(n||""))return"image";if("md"===n)return"markdown";if("csv"===n)return"table";if("json"===r&&"object"==typeof e&&null!==e){const t=e;if("string"==typeof t.$schema&&t.$schema.includes("vega"))return"vega-lite";if("vega-lite"===t.library&&"spec"in t)return"vega-lite";if("template"in t&&"data"in t)return"fusion-fragment";if(Array.isArray(e)&&e.length>0&&"object"==typeof e[0])return"table"}return"code"}(t,n,i),[t,n,i,r]);switch(s){case"chart":{const r=Er(t);return r?e(tr,{type:"chart",fallbackCode:JSON.stringify(t,null,2),children:e(jr,{spec:r,artifactRunId:a})}):e(er,{type:"chart",error:"Only Vega-Lite charts are supported. Recharts rendering has been retired."})}case"vega-lite":{const r=Er(t);return r?e(tr,{type:"chart",fallbackCode:JSON.stringify(t,null,2),children:e(jr,{spec:r,artifactRunId:a})}):e(er,{type:"chart",error:"Invalid Vega-Lite specification"})}case"fusion-fragment":{const r=t;return console.log("[ArtifactContentRenderer] fusion-fragment:",{hasTemplate:!!r.template,hasData:!!r.data,runId:a,hasVegaLiteChart:!!jr}),r.template&&r.data?e(tr,{type:"fusion-fragment",fallbackCode:JSON.stringify(t,null,2),children:e(Le,{data:r.data,ChartComponent:jr,artifactRunId:a,children:e(Re,{code:JSON.stringify(r.template),data:r.data})})}):e(tr,{type:"fusion-fragment",fallbackCode:JSON.stringify(t,null,2),children:e(Re,{code:JSON.stringify(t)})})}case"table":return e(tr,{type:"table",fallbackCode:JSON.stringify(t,null,2),children:e(Tr,{content:t})});case"markdown":{const r="string"==typeof t?t:String(t);return e(tr,{type:"markdown",fallbackCode:r,children:e(sn,{artifactRunId:a,children:r})})}case"mockup":return e(tr,{type:"expand",fallbackCode:"string"==typeof t?t:n,children:e(qr,{content:t})});case"image":return e(tr,{type:"image",fallbackCode:n,children:e(Vr,{content:t,path:n})});default:return e(Fr,{content:t,path:n})}}const _r=N.createContext({});function Ur({children:t,artifactRunId:r,onProposalSelect:n,onProposalSubmit:a}){const i=A(()=>({artifactRunId:r,onProposalSelect:n,onProposalSubmit:a}),[r,n,a]);return e(_r.Provider,{value:i,children:t})}function Wr(){return N.useContext(_r)}function Hr(e){const t=e.trim();if(t.length<2)return!0;if(!t.startsWith("{"))return!1;try{return JSON.parse(t),!1}catch(e){const r=["unexpected end","unterminated string","expected","unexpected token"],n=(e instanceof Error?e.message:"").toLowerCase();if(r.some(e=>n.includes(e))){let e=0,r=0,n=!1,a=!1;for(const i of t)a?a=!1:"\\"!==i?'"'!==i?n||("{"===i?e++:"}"===i?e--:"["===i?r++:"]"===i&&r--):n=!n:a=!0;return e>0||r>0||n}return!1}}function Br(e){try{let t=e.trim();const r=t.indexOf("{"),n=t.lastIndexOf("}");return-1!==r&&n>r&&(t=t.slice(r,n+1)),JSON.parse(t)}catch{return null}}function Jr({code:t}){const{artifactRunId:r}=Wr(),n=A(()=>Hr(t),[t]),a=A(()=>{if(n)return null;const e=Br(t);return e?{library:"vega-lite",spec:e}:null},[t,n]);return n?e(er,{type:"chart",message:"Loading chart..."}):a?e(tr,{type:"chart",fallbackCode:t,children:e(jr,{spec:a,artifactRunId:r})}):e(er,{type:"chart",error:"Invalid Vega-Lite specification"})}function Kr({code:t}){const{artifactRunId:r}=Wr(),n=A(()=>Hr(t),[t]),a=A(()=>{if(n)return null;const e=Br(t);if(!e)return null;const r=function(e){const t="string"==typeof e.$schema&&e.$schema.includes("vega"),r="vega-lite"===e.library&&"spec"in e;return t||r?"vega-lite":null}(e);return r?"vega-lite"===e.library&&"spec"in e&&"object"==typeof e.spec?e:{library:"vega-lite",spec:e}:null},[t,n]);return n?e(er,{type:"chart",message:"Loading chart..."}):a?e(tr,{type:"chart",fallbackCode:t,children:e(jr,{spec:a,artifactRunId:r})}):e(er,{type:"chart",error:"Invalid Vega-Lite chart specification"})}function Gr({code:t}){const r=t.trim();return r?e(tr,{type:"mermaid",fallbackCode:t,children:e($r,{code:r})}):e(er,{type:"mermaid",error:"Empty diagram"})}function Xr({code:t}){const{onProposalSelect:r,onProposalSubmit:n}=Wr(),a=A(()=>Hr(t),[t]),i=A(()=>{if(a)return null;try{const e=t.trim(),a=JSON.parse(e);if(!a.options||!a.question&&!a.title)return null;const i={question:a.question||a.title||"",description:a.description,options:Array.isArray(a.options)?a.options.map(e=>({id:e.id||e.value||"",label:e.label||"",description:e.description})):void 0,allowFreeResponse:a.allowFreeResponse??a.multiple,variant:a.variant,onSelect:r,onSubmit:n};return i.question&&i.options?.length?i:null}catch{return null}},[t,r,n,a]);return a?e(er,{type:"proposal",message:"Loading options..."}):i?e(tr,{type:"proposal",fallbackCode:t,children:e(Lr,{...i})}):e(er,{type:"proposal",error:"Invalid proposal specification"})}function Yr({code:t}){const r=A(()=>{const e=t.trim();return e?zr(Dr(e)):null},[t]);return r?e(tr,{type:"code",fallbackCode:t,children:e("div",{style:{margin:"16px 0",width:"100%",overflowX:"auto"},dangerouslySetInnerHTML:{__html:r}})}):e(er,{type:"code",error:"Empty mockup"})}function Zr({code:t,language:r}){const{artifactRunId:n}=Wr(),a=t.trim(),i=A(()=>{if(!r?.includes(":"))return"auto";const e=r.split(":")[1];return["chart","vega-lite","table","markdown","fusion-fragment","mockup","code","image","auto"].includes(e)?e:"auto"},[r]),{data:s,isLoading:o,error:l,contentType:c}=Rr({runId:n,path:a});return n?o?e(er,{type:"expand",message:`Loading ${a}...`}):l?e(er,{type:"expand",error:`Failed to load artifact: ${l}`}):void 0===s?e(er,{type:"expand",error:"No content found in artifact"}):e(Mr,{content:s,renderType:i,path:a,runId:n,contentType:c}):e(er,{type:"expand",error:"No artifact run ID available"})}function Qr(e){return e?.startsWith("expand")??!1}function en(){return{chart:Kr,"vega-lite":Jr,vegalite:Jr,mermaid:Gr,mockup:Yr,svg:Yr,proposal:Xr,askuser:Xr}}const tn=["artifact:","image:","store:","document:","document://","collection:"];function rn(e){return tn.some(t=>e.startsWith(t))?e:me(e)}function nn(){return e=>{Ne(e,"html",(e,t,r)=>{if(e.value&&/<!--[\s\S]*?-->/.test(e.value)&&r&&"number"==typeof t&&r.children)return r.children.splice(t,1),[ke,t]})}}const an=en();function sn({children:t,components:r,remarkPlugins:n=[],removeComments:a=!0,artifactRunId:i,className:s,codeClassName:o,inlineCodeClassName:l,linkClassName:c,imageClassName:d,onProposalSelect:u,onProposalSubmit:h}){const m=Wt(),p=N.useMemo(()=>{return(e=function(e){if(!e||!ur.some(t=>e.includes(t)))return e;let t,r="",n=0;for(pr.lastIndex=0;null!==(t=pr.exec(e));)r+=br(e.slice(n,t.index)),r+=t[0],n=t.index+t[0].length;return r+=br(e.slice(n)),r}(t))&&e.includes(":::")?e.replace(vr,(e,t,r,n)=>n?`${t}:::${r}\n${t}${n}\n${t}:::`:`${t}::${r}`):e;var e},[t]),f=N.useMemo(()=>{const e=[pe,ge,dr,ye,be,xe,fe,...n];return a&&e.push(nn),e},[n,a]),g=N.useMemo(()=>[we],[]),y=N.useMemo(()=>({handlers:{...ve}}),[]),b=N.useMemo(()=>{const t=r||{},n=t.code,a=t.a,s=t.img;return{...t,code:({node:t,className:r,children:a,...i})=>{const s=/language-([\w-]+)/.exec(r||""),c=!s,d=s?s[1]:"";if(!c&&d){if(m){const t=m.getComponent(d);if(t){const r=String(a||"").trim();return e(t,{code:r,language:d})}}if(Qr(d)){const t=String(a||"").trim();return e(Zr,{code:t,language:d})}const t=an[d];if(t){const r=String(a||"").trim();return e(t,{code:r,language:d})}}if("function"==typeof n)return e(n,{node:t,className:r,...i,children:a});return e("code",{...i,className:c?`px-1.5 py-0.5 rounded ${l||""}`:` ${o||""}`,children:a})},a:t=>{const{node:r,href:n,children:s,...o}=t;return e(rr,{node:r,href:n,className:c,artifactRunId:i,ExistingLink:a,...o,children:s})},img:t=>{const{node:r,src:n,alt:a,title:o,...l}=t;return o?e(sr,{src:n,alt:a,caption:o,className:d,artifactRunId:i}):e(ar,{node:r,src:n,alt:a,className:d,artifactRunId:i,ExistingImg:s,...l})}}},[r,i,m,o,l,c,d]),v=e(Ur,{artifactRunId:i,onProposalSelect:u,onProposalSubmit:h,children:e(he,{remarkPlugins:f,rehypePlugins:g,remarkRehypeOptions:y,components:b,urlTransform:rn,children:p})});return e("div",s?{className:`md-content ${s}`,children:v}:{className:"md-content",children:v})}const on=O(void 0);function ln(){return $(on)}const cn=Symbol("__SLOT_NAME");function dn(e,t){const r=[];return L.forEach(e,e=>{!function(e,t,r){let n;R(e)&&(n=e.type[cn])?r[n]=e:t.push(e)}(e,r,t)}),r.length>1?r:r[0]}function un(e,t){t[cn]=e}function hn(e){return e?"boolean"==typeof e?{enabled:e}:e:{enabled:!1}}function mn(t){const r={};if(dn(t.children,r),!r.content)throw new Error("Popover must provide a content slot");const n=r.trigger?.props,a=r.content.props;return e(pn,{...t,trigger:n,content:a})}function pn({middleware:r,offset:n,trigger:a,dismiss:i=!0,content:s,placement:o,strategy:l,zIndex:c=40}){const[d,u]=k(!1),h=De({open:d,placement:o,strategy:l,onOpenChange:u,middleware:r||[Ee(n||4),Te(),Fe()],whileElementsMounted:ze}),{floatingStyles:m,refs:{setReference:p,setFloating:f},context:g}=h,y=qe(g,hn(i)),b=Ve(g,hn(!(v=a)||v.hover||v.click?v?.click:{enabled:!0}));var v;const w=Me(g,hn(function(e){return!0===e?.hover?{enabled:!0,handleClose:Be({blockPointerEvents:!0}),restMs:0}:e?.hover}(a))),{getReferenceProps:N,getFloatingProps:C}=_e([y,b,w]),{isMounted:S,styles:A}=Ue(g,s.transition);return t(on.Provider,{value:{...h,close:()=>u(!1)},children:[a&&e("div",{className:x(a.className,"inline-block"),ref:p,...N(),children:a.children}),e(We,{children:S&&e("div",{ref:f,style:{...m,zIndex:c},...C(),children:e(He,{context:g,children:e("div",{className:x(s.className,"bg-popover rounded-md text-popover-foreground max-w-md"),style:A,children:s.children})})})})]})}function fn(e){return null}function gn(e){return null}function yn({percent:t}){return e("div",{className:"w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700",children:e("div",{className:"bg-blue-600 h-2.5 rounded-full",style:{width:`${t}%`}})})}function bn({className:r,properties:n}){return e(c,{className:r,children:e("tbody",{children:n.map(r=>t("tr",{children:[t("td",{className:"w-1/3 font-semibold gap-2",children:[e("span",{children:r.name}),r.description&&e(d,{description:r.description,placement:"top",children:e(te,{className:"size-3 ml-2 text-muted-foreground"})})]}),e("td",{className:"w-2/3",children:r.value??"undefined"})]},r.name))})})}var vn;function xn(e,t){let r="any"===t.name?void 0:t.isNullable?[t.name,"null"]:t.name;if(t.isArray)if(e.type="array",e.properties=void 0,!e.items||Array.isArray(e.items))e.items={type:r,properties:t.isObject?{}:void 0};else{const n=e.items;n.type=r,t.isObject&&!n.properties&&(n.properties={})}else e.type=r,e.items=void 0,t.isObject?e.properties||(e.properties={}):e.properties=void 0}function wn(e){let t,r=!1,n=!1;const a=e.type;if(Array.isArray(a))for(const e of a)"null"===e?r=!0:t||(t=e);else t=a;t||(t="any"),"array"===t&&(n=!0,t=function(e){if(!e)return"any";let t;t=Array.isArray(e)?Nn(e[0].type):Nn(e.type);"array"!==t&&"null"!==t||(t="any");return t}(e.items));let i=t;switch(e.editor){case"textarea":i="text";break;case"media":i="media";break;case"document":i="document"}return{isNullable:r,isArray:n,isObject:"object"===t,name:i}}function Nn(e){return e?Array.isArray(e)?e.find(e=>"null"!==e)||"any":e:"any"}un("trigger",fn),un("content",gn),mn.Trigger=fn,mn.Content=gn,function(e){e.string="string",e.number="number",e.integer="integer",e.boolean="boolean",e.object="object",e.any="any",e.text="text",e.media="media",e.document="document"}(vn||(vn={}));let kn=0;class Cn{source;onChange=()=>{};schema;root;constructor(e,t){this.schema=e?"string"==typeof e?JSON.parse(e):e:{title:t,type:"object",properties:{}},this.schema.properties||(this.schema.properties={}),this.root=new Sn("",this.schema,this),this.root.loadChildren()}get isEmpty(){return!this.root.children||0===this.root.children.length}get children(){return this.root.children}reload(){return this.root=new Sn("",this.schema,this),this.root.loadChildren(),this.onChange?.(this),this}withSource(e,t){return this.source={uri:t,name:e},this}withChangeListener(e){return this.onChange=e,this}replaceSchema(e){this.schema=e||{title:this.schema.title,type:"object",properties:{}},this.reload()}clone(){const e=new Cn(this.schema);return e.source=this.source,this.onChange&&e.withChangeListener(this.onChange),e}}class Sn{schema;loader;parent;name;isRequired=!1;type;children;constructor(e,t,r,n){if(this.schema=t,this.loader=r,this.parent=n,this.name=e,this.type=wn(t),this.parent){let t=this.parent._getPropertiesSchema().required;this.isRequired=!(!t||!Array.isArray(t))&&t.includes(e)}}get title(){return this.schema.title}set title(e){this.schema.title=e}get description(){return this.schema.description}set description(e){this.schema.description=e}get isParent(){return this.type.isObject}get isNew(){return!!this.schema.isNew}set isNew(e){e?this.schema.isNew=!0:delete this.schema.isNew}resetIsNew(){const e=this.isNew;return this.isNew=!1,e}getNameSignature(){return`${this.name}${this.isRequired?"":"?"}`}getTypeSignature(){return`${this.type.name}${this.type.isArray?"[]":""}${this.type.isNullable?"?":""}`}getSignature(){return`${this.getNameSignature()}: ${this.getTypeSignature()}`}reloadTree(){this.loader.reload()}loadChildren(){this.children=[],this.schema.items&&this.schema.items.properties?this._loadChildren(this.schema.items.properties):this.schema.properties&&this._loadChildren(this.schema.properties)}_loadChildren(e){for(const t of Object.keys(e)){const r=e[t],n=new Sn(t,r,this.loader,this);this.children.push(n),n.isParent&&n.loadChildren()}}_getPropertiesSchema(){return this.type.isArray&&this.type.isObject?this.schema.items:this.schema}findAvailableChildName(e){const t=this._getPropertiesSchema().properties||{};let r;do{r=e+ ++kn}while(t[r]);return r}addChild(e,t,r=!1){if(!this.type.isObject)throw new Error("Cannot add child to a non object node");this.children||(this.children=[]);const n=function(e,t,r,n=!1){if("object"!==e.type)throw new Error("Cannot add property to a non-object schema");e.properties||(e.properties={});const a={};return xn(a,r),e.properties[t]=a,n&&(Array.isArray(e.required)?function(e,t){e.includes(t)||e.push(t)}(e.required,t):e.required=[t]),a}(this._getPropertiesSchema(),e,t,r),a=new Sn(e,n,this.loader,this);return this.children.push(a),a}remove(){if(this.parent&&this.parent.type.isObject){return function(e,t){e.properties&&(delete e.properties[t],Array.isArray(e.required)&&(e.required=e.required.filter(e=>e!==t)))}(this.parent._getPropertiesSchema(),this.name),this.parent.children&&(this.parent.children=this.parent.children.filter(e=>e.name!==this.name)),!0}return!1}update(e){let t=!1;null!=e.name&&this.name!==e.name&&(this.parent&&function(e,t,r){if(e.properties){const n=e.properties,a={};for(const e of Object.keys(n)){const i=n[e];e===t?a[r]=i:a[e]=i}e.properties=a}e.required&&(e.required=e.required.map(e=>e===t?r:e))}(this.parent._getPropertiesSchema(),this.name,e.name),this.name=e.name,t=!0),null!=e.isRequired&&this.isRequired!==e.isRequired&&(this.parent&&function(e,t,r){if(Array.isArray(e.required)){const n=e.required.indexOf(t);r?n<0&&e.required.push(t):n>-1&&e.required.splice(n,1)}else r&&(e.required=[t])}(this.parent._getPropertiesSchema(),this.name,e.isRequired),this.isRequired=e.isRequired,t=!0);let r=e.type?.name;"any"===r&&(r=void 0);const n=r!==this.schema.type;return e.type&&(xn(this.schema,e.type),this.type=e.type,this.type.isObject?this.children||(this.children=[]):this.children=void 0,t=!0),this.schema.editor&&null===e.editor?(this.schema.editor=void 0,t=!0):e.editor?(this.schema.editor=e.editor,t=!0):n&&(this.schema.editor=void 0,t=!0),e.description!==this.description&&(this.description=e.description,t=!0),t}getUpdateFromNameAndTypeSignature(e,t){let r=e.trim(),n=!0;r.endsWith("?")&&(r=r.substring(0,r.length-1).trim(),n=!1);const a=function(e){let t=!1,r=!1;(e=e.trim()).endsWith("?")&&(r=!0,e=e.substring(0,e.length-1).trim()),e.endsWith("[]")&&(t=!0,e=e.substring(0,e.length-2).trim());const n=vn[e];if(!n)throw new Error(`Unknown type "${e}"`);return{name:n,isArray:t,isNullable:r,isObject:n===vn.object}}(t);let i;return"text"===a.name?(a.name=vn.string,i="textarea"):"media"===a.name?(a.name=vn.any,i="media"):"document"===a.name?(a.name=vn.any,i="document"):i=null,{name:r,type:a,isRequired:n,editor:i}}updateFromNameAndTypeSignature(e,t){return this.update(this.getUpdateFromNameAndTypeSignature(e,t))}updateFromSignature(e){const t=(e=e.trim()).indexOf(":");if(t<0)throw new Error("Expecting a name and a type separated by a colon");const r=e.substring(0,t),n=e.substring(t+1);return this.updateFromNameAndTypeSignature(r,n)}}function An(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}const jn=function(){const e=Object.values(vn),t=[...e];for(const r of e)t.push(r+"[]");return e.sort(),t}();function On({value:r,onChange:n,onCancel:a,onSave:i}){const[s,l]=k(!1);if(!r)return null;return t("div",{className:"flex items-center",children:[e("div",{className:"flex-1",children:e($n,{value:r.name,onChange:e=>{n({...r,name:e})},onCancel:a,onSave:i})}),e("div",{className:"px-1 font-semibold",children:":"}),e("div",{className:"flex-1",children:e(Pn,{value:r.type,onChange:e=>{n({...r,type:e})},onCancel:a,onSave:i})}),t("div",{children:[e(o,{variant:"ghost",size:"xs",onClick:()=>l(!0),title:"Edit description",children:e(re,{className:"size-4"})}),e(In,{value:r.description,isOpen:s,onClose:e=>{void 0!==e&&"string"==typeof e&&n({...r,description:e},!0),l(!1)}})]})]})}function $n({value:t,onChange:r,onCancel:n,onSave:a}){const s=C(null);S(()=>{s.current?.focus()},[]);return e("input",{onKeyUp:e=>{switch(e.key){case"Enter":a?.();break;case"Escape":n?.()}},ref:s,value:t,onChange:e=>{r(e.target.value)},className:i.INPUT_UNSTYLED,style:{fontSize:"inherit",width:"",display:"inline"}})}function Pn({value:t,onChange:r,onCancel:n,onSave:a}){return e(u,{className:i.INPUT_UNSTYLED,options:jn,value:t||"",onBlur:()=>{a?.()},onChange:r,onKeyDown:(e,t)=>{t||("Enter"===e.key?a?.():"Escape"===e.key&&n?.())},popupClass:"schema-type-suggest-popup z-90"})}function In({value:r,isOpen:n,onClose:a}){return t(h,{isOpen:n,onClose:a,children:[e(m,{children:"Edit description"}),e(Ln,{value:r,onSave:a})]})}function Ln({value:n,onSave:a}){const i=C(null),[s,l]=k(n||"");return S(()=>{i.current&&i.current.focus()},[i.current]),t(r,{children:[e(p,{className:"h-max",children:e("textarea",{ref:i,className:"dark:bg-gray-800 w-full h-full dark:text-white",value:s,onChange:e=>l(e.target.value)})}),e(f,{children:e(o,{onClick:()=>a(s),children:"Save Changes"})})]})}function Rn({value:r}){return r?t("div",{className:"w-full flex items-baseline",children:[e("div",{children:r.name||""}),e("div",{className:"ml-2 text-sm text-muted",children:r.type||""})]}):null}function En(e){const[t,r]=k(new Cn(e||{type:"object",properties:{}}).withChangeListener(e=>{r(e.clone())}));return t}const Tn="block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4",Fn=`${Tn} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,Dn=`${Tn} shadow-xs ring-1 ring-inset ring-ring`;function zn({value:r,onChange:n,onDelete:a,outlineOnHover:i=!1,editOnClick:s=!0,placeholder:o,viewer:l,editor:c,skipClickOutside:d,isEditing:u=!1,readonly:h=!1,onValidate:m}){const{on:p,off:f,isOn:y}=g(u),[b,v]=k();return t("div",{className:"",children:[y&&!h?e(Vn,{value:r,onSave:e=>{if(m){const t=m(e);if(t)return void v(t);v(void 0)}n(e)&&f()},onCancel:f,editor:c,skipClickOutside:e=>!!d&&d(e)}):e(qn,{value:r,onEdit:p,viewer:l,placeholder:o,outlineOnHover:i,editOnClick:s,onDelete:a,readonly:h}),b&&e("div",{className:"text-red-500 text-sm",children:b})]})}function qn({viewer:r,value:n,onEdit:a,editOnClick:i,outlineOnHover:s,placeholder:l,onDelete:c,readonly:d}){const u="invisible group-hover:visible";return t("div",{tabIndex:0,onKeyUp:e=>{"Enter"===e.key&&a()},onClick:()=>{i&&a()},className:x("flex justify-start items-center group",s?Fn:Tn,{"cursor-pointer":i}),children:[e(r,{value:n,placeholder:l}),t("div",{className:"ml-auto flex space-x-2",children:[!d&&c&&e(o,{variant:"ghost",size:"sm",className:u,onClick:c,children:e(T,{className:"size-4"})}),d?null:e(o,{variant:"ghost",size:"sm",className:u,onClick:a,children:e(ne,{className:"size-4"})})]})]})}function Vn({editor:t,value:r,onSave:n,onCancel:a,skipClickOutside:i}){const[s,o]=k(r),l=C(r),[c,d]=k(null),u=()=>{n(l.current)},h=y(u,i);return e("div",{ref:h,children:e("div",{className:Dn,children:e("div",{className:"w-full",onClick:e=>e.stopPropagation(),children:e(t,{value:s,onChange:(e,t=!1)=>{o(e),l.current=e,t&&(c&&clearTimeout(c),d(setTimeout(()=>{n(e)},500)))},onSave:u,onCancel:a})})})})}function Mn(e){const t=e.target;return!(!t.closest||!t.closest(".schema-type-suggest-popup"))}function _n({schema:r,readonly:n=!1}){return t("ul",{className:"",children:[r.children.map(e=>Un(e,n)),n?null:e(Kn,{parent:r.root})]})}function Un(t,r){return t.isParent?e(Hn,{property:t,readonly:r},t.name):e(Wn,{node:t,readonly:r},t.name)}function Wn({node:t,readonly:r}){return e("li",{children:e(Jn,{property:t,readonly:r})})}function Hn({property:r,readonly:n}){const[a,i]=k(!0);return t("li",{children:[t("div",{className:"flex items-center w-full",children:[e("button",{onClick:()=>i(!a),children:e(a?ae:ie,{className:"size-4"})}),e("div",{className:"flex-1",children:e(Jn,{property:r,readonly:n})})]}),a&&t("ul",{className:"ml-4 border-l border-gray-400 border-dashed",children:[(r.children||[]).map(e=>Un(e,n)),n?null:e(Kn,{parent:r})]})]})}function Bn(e){return e?/^[a-zA-Z0-9_]+[?]?$/.test(e)?void 0:"Only letters, numbers, underscores or question mark are allowed (a-zA-Z0-9_?)":"Name is required"}function Jn({property:t,readonly:r}){const n=b(),a=t.resetIsNew(),i=An(t);return e(zn,{value:i,onChange:e=>{try{e.description&&"string"!=typeof e.description&&(e.description=void 0);const r=t.getUpdateFromNameAndTypeSignature(e.name,e.type);t.update({...r,description:e.description})&&t.reloadTree()}catch(e){return n({status:"error",title:"Invalid property declaration",description:e.message,duration:9e3}),!1}return!0},onDelete:()=>{t.remove(),t.reloadTree()},editor:On,viewer:Rn,outlineOnHover:!0,isEditing:a,skipClickOutside:Mn,readonly:r,onValidate:e=>Bn(e.name)})}function Kn({parent:r}){return t(o,{variant:"ghost",onClick:()=>{const e=r.findAvailableChildName("new_property_");r.addChild(e,{isObject:!1,isArray:!1,isNullable:!1,name:vn.string},!0).isNew=!0,r.reloadTree()},children:[e(E,{className:"size-4"}),"Add property"]})}function Gn({content:t,...r}){const n=C(null);return S(()=>{if(!n.current)return;const e=(new DOMParser).parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)return console.warn("SvgIcon: No <svg> element found in provided string"),void(n.current.innerHTML="");r&&Object.entries(r).forEach(([t,r])=>{if(null==r)return;const n="className"===t?"class":t;e.setAttribute(n,String(r))}),n.current.innerHTML="",n.current.appendChild(e)},[t,r]),e("span",{ref:n})}function Xn(t){return r=>e(Gn,{content:t,...r})}function Yn({onDrop:r,message:n,buttonLabel:a="Upload Files",allowFolders:i=!0,className:s=""}){const[l,c]=k(!1),d=C(null),u=e=>{if(e.target.files&&e.target.files.length>0){const t=Array.from(e.target.files);if(t.some(e=>e.webkitRelativePath&&e.webkitRelativePath.includes("/"))){const e=new Set(t.map(e=>e.webkitRelativePath?.split("/")[0]).filter(Boolean)).size,n=t.length,a=1===e?`Preparing to upload 1 folder with ${n} files...`:`Preparing to upload ${e} folders with ${n} files...`,i={count:t.length,message:a};r(t,i)}else{const e={count:t.length,message:`Preparing to upload ${t.length} file${1===t.length?"":"s"}...`};r(t,e)}}};return t("div",{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${l?"border-color-primary bg-color-primary/10":"border-dashed border-color-border"} ${s}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.types.includes("Files")&&c(!0)},onDragLeave:e=>{e.preventDefault(),d.current&&!d.current.contains(e.relatedTarget)&&c(!1)},onDrop:async e=>{if(e.preventDefault(),c(!1),e.dataTransfer.items&&e.dataTransfer.items.length>0){const t=Array.from(e.dataTransfer.items),n=[],a=new Set,i=async e=>{if(e.isFile){const t=await new Promise(t=>{e.file(r=>{Object.defineProperty(r,"webkitRelativePath",{writable:!0,value:e.fullPath.substring(1)}),t(r)})});!t.name.startsWith(".")&&t.size>0&&n.push(t);const r=e.fullPath.substring(1).split("/").slice(0,-1).join("/");r&&a.add(r)}else if(e.isDirectory){const t=e.createReader(),r=await new Promise(e=>{t.readEntries(t=>{e(t)})});await Promise.all(r.map(i));const n=e.fullPath.substring(1);n&&a.add(n)}};try{if(await Promise.all(t.map(e=>{const t=e.webkitGetAsEntry?e.webkitGetAsEntry():e;return t?i(t):Promise.resolve()})),n.length>0){const e=new Set(Array.from(a).map(e=>e.split("/")[0]).filter(Boolean)).size,t=n.length;let i="";i=e>0?1===e?`Preparing to upload 1 folder with ${t} files...`:`Preparing to upload ${e} folders with ${t} files...`:`Preparing to upload ${t} file${1===t?"":"s"}...`,r(n,{count:n.length,message:i})}}catch(t){console.error("Error processing dropped files:",t);const n=Array.from(e.dataTransfer.files);n.length>0&&r(n)}}else if(e.dataTransfer.files&&e.dataTransfer.files.length>0){const t=Array.from(e.dataTransfer.files);r(t)}},children:[e(se,{className:"h-12 w-12 mb-3 transition-colors "+(l?"text-primary":"text-muted/50")}),e("p",{className:"text-muted",children:n}),t("div",{className:"flex gap-2 justify-center mt-2",children:[e(o,{onClick:()=>{const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="*",e?.click(),e.onchange=e=>{u(e)}},children:a}),i&&e(o,{onClick:()=>{const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="*",e.webkitdirectory=!0,e?.click(),e.onchange=e=>{u(e)}},children:"Select Folder"})]})]})}function Zn({title:r,count:n,icon:a=e(oe,{className:"h-4 w-4 text-green-500"}),items:i}){const[s,o]=k(!1);return t("div",{className:"border border-color-border rounded-md overflow-hidden",children:[t("div",{className:"flex items-center justify-between p-3 bg-color-muted/10 cursor-pointer",onClick:()=>o(!s),children:[t("div",{className:"flex items-center",children:[e("span",{className:"mr-2",children:a}),e("span",{className:"font-medium",children:r}),e("span",{className:"ml-2 px-2 py-0.5 bg-color-muted/20 rounded-full text-xs",children:n})]}),e("button",{className:"text-muted",children:e("svg",{className:"h-5 w-5 transition-transform "+(s?"transform rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),s&&e("div",{className:"p-3 border-t border-color-border max-h-48 overflow-y-auto",children:i.length>0?e("ul",{className:"space-y-1",children:i.map((t,r)=>e("li",{className:"text-sm py-1 px-2 rounded hover:bg-color-muted/10",children:t},r))}):e("div",{className:"text-sm text-muted py-2",children:"No items to display"})})]})}function Qn({files:r,className:n="",location:a,collection:i}){const s=r.filter(e=>"success"===e.status),o=r.filter(e=>"updated"===e.status),l=r.filter(e=>"skipped"===e.status),c=r.filter(e=>"failed"===e.status),d=s.length,u=o.length,h=l.length,m=c.length,p=r.length;return t("div",{className:`flex flex-col py-2 ${n}`,children:[t("div",{className:"flex items-center mb-4",children:[e("div",{className:"size-8 mr-4 rounded-full bg-success/10 flex items-center justify-center",children:e(oe,{className:"size-4 text-success"})}),e("div",{children:t("p",{className:"text-muted",children:[p," file",1!==p?"s":""," processed",i?` in collection '${i}'`:"",a?` in folder '${a}'`:""]})})]}),t("div",{className:"space-y-3 mt-2",children:[d>0&&e(Zn,{title:"Successfully Uploaded",count:d,icon:e(oe,{className:"h-4 w-4 text-green-500"}),items:s.map(e=>e.name)}),u>0&&e(Zn,{title:"Successfully Updated",count:u,icon:e(oe,{className:"h-4 w-4 text-blue-500"}),items:o.map(e=>e.name)}),h>0&&e(Zn,{title:"Skipped (Already Existed)",count:h,icon:e(le,{className:"h-4 w-4 text-amber-500"}),items:l.map(e=>e.name)}),m>0&&e(Zn,{title:"Failed to Upload",count:m,icon:e(ce,{className:"h-4 w-4 text-red-500"}),items:c.map(e=>e.name)})]})]})}const ea="#text",ta="#comment",ra="#cdata",na="DECLARATION_TAG",aa={tagColor:"#d43900",textColor:"#333",attributeKeyColor:"#2a7ab0",attributeValueColor:"#008000",separatorColor:"#333",commentColor:"#aaa",cdataColor:"#1d781d",fontFamily:"monospace"},ia={attributeKeyColor:"#FFD700",attributeValueColor:"#FF4500",tagColor:"#87CEFA",textColor:"#00FF00",separatorColor:"#FFD700",commentColor:"#BEBEBE",cdataColor:"#33CC66",fontFamily:"monospace"},sa=O({theme:aa,collapsible:!1,indentSize:2}),oa=()=>$(sa),la=new Je({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:"",allowBooleanAttributes:!0,commentPropName:ta,cdataPropName:ra,parseTagValue:!1});function ca(r){const{indentation:n,children:a,isInline:i}=r,{theme:s}=oa();return t("div",{style:{color:s.cdataColor},children:[e("span",{children:`${n}<![CDATA[`}),a,e("span",{children:`${i?"":n}]]>`})]})}function da(t){const{collapsible:r,theme:n}=oa(),{collapsed:a}=t;return r?e("span",{style:{position:"relative"},children:e("span",{style:{position:"absolute",right:"0",border:0,padding:0,background:"none"},children:e(ua,{fill:n.separatorColor,style:{transform:`rotate(${a?0:90}deg)`,transition:"transform 0.2s"}})})}):null}function ua({...t}){return e("svg",{width:"16px",height:"16px",viewBox:"0 0 24 24",...t,children:e("path",{d:"M9 17.898C9 18.972 10.2649 19.546 11.0731 18.8388L17.3838 13.3169C18.1806 12.6197 18.1806 11.3801 17.3838 10.6829L11.0731 5.16108C10.2649 4.45388 9 5.02785 9 6.1018V17.898Z"})})}function ha(e){const{collapsible:t,initialCollapsedDepth:r}=oa(),[n,a]=k(()=>!(Ge(r)||!t)&&e>=r);return S(()=>{a(!(Ge(r)||!t)&&e>=r)},[r,e,t]),{collapsed:n,buttonProps:t?{onClick:()=>a(e=>!e),role:"button",style:{cursor:"pointer"}}:{}}}function ma(r){const{indentation:n,children:a,isInline:i,level:s}=r,{theme:o}=oa(),{collapsed:l,buttonProps:c}=ha(s);return t("div",{style:{color:o.commentColor},children:[t("span",{...c,children:[e("span",{children:n}),e(da,{collapsed:l}),e("span",{children:"\x3c!-- "})]}),!l&&a,l&&"...",e("span",{children:`${i||l?" ":n}--\x3e`})]})}function pa(r){const{attributes:n}=r,{theme:a}=oa();return n?e("span",{children:Object.entries(n).map(([r,n])=>t("span",{children:[e("span",{style:{color:a.attributeKeyColor},children:` ${r}`}),e("span",{style:{color:a.separatorColor},children:"="}),e("span",{style:{color:a.attributeValueColor},children:`"${n}"`})]},`attribute-${r}`))}):null}function fa(r){const{indentation:n,tagKey:a,attributes:i}=r,{theme:s}=oa();return t("div",{children:[e("span",{style:{color:s.separatorColor},children:`${n}<?`}),e("span",{style:{color:s.tagColor},children:`${a.slice(1)}`}),e(pa,{attributes:i}),e("span",{style:{color:s.separatorColor},children:"?>"})]})}function ga(e){return"string"==typeof e&&e.includes("\n")}function ya(e){const t=e[":@"],r=Xe(e,":@"),[[n,a]]=Object.entries(r),i=function(e){switch(e){case ea:case ra:case ta:return e;default:return e.startsWith("?")?na:"TAG"}}(n);return{attributes:t,tagKey:n,subElements:a,type:i}}function ba(e){return!!e&&Object.keys(e).length>0}function va(n){const{indentation:a,tagKey:i,attributes:s,children:o,isInline:l,hasChildren:c,level:d}=n,{collapsed:u,buttonProps:h}=ha(d),{theme:m}=oa();return t("div",{children:[t("span",{...h,children:[e("span",{children:a}),e(da,{collapsed:u}),e("span",{style:{color:m.separatorColor},children:"<"}),e("span",{style:{color:m.tagColor},children:`${i}`}),!u&&e(pa,{attributes:s}),u&&ba(s)&&" ...",e("span",{style:{color:m.separatorColor},children:c?">":" />"})]}),c&&t(r,{children:[!u&&o,u&&"...",e("span",{style:{color:m.separatorColor},children:`${l||u?"":a}</`}),e("span",{style:{color:m.tagColor},children:`${i}`}),e("span",{style:{color:m.separatorColor},children:">"})]})]})}function xa(t){const{hasSiblings:r,text:n,indentation:a,isText:i}=t,{theme:s}=oa(),o=i?{color:s.textColor}:void 0;return ga(n)||r?e("div",{style:o,children:n.split("\n").filter(e=>!!e.trim()).map((t,r)=>e("div",{children:`${a}${t.trim()}`},`${r}`))}):e("span",{style:o,children:n})}function wa(t){const{elements:n,level:a=0,isText:i=!0}=t,{indentSize:s}=oa();return Array.isArray(n)&&0!==n.length?e(r,{children:n.map((t,r)=>{const{tagKey:o,attributes:l,subElements:c,type:d}=ya(t),u=n.length>1,h=function(e,t){return new Array(t*e+1).join(" ")}(s,a),m=`${a}-${r}`,p=function(e){return"string"!=typeof e&&1===e.length&&ea in e[0]&&!ga(e[0][ea])}(c);switch(d){case ea:return e(xa,{text:c,indentation:h,hasSiblings:u,isText:i},m);case ta:return e(ma,{isInline:p,indentation:h,level:a,children:e(wa,{elements:c,level:a+1,isText:!1})},m);case ra:return e(ca,{indentation:h,isInline:p,children:e(wa,{elements:c,level:a+1,isText:!1})},m);case na:return e(fa,{indentation:h,tagKey:o,attributes:l},m);default:return e(va,{indentation:h,tagKey:o,attributes:l,isInline:p,hasChildren:c.length>0,level:a,children:e(wa,{elements:c,level:a+1})},m)}})}):null}function Na(){return e("div",{children:"Invalid XML!"})}function ka(t){const{theme:r,xml:n,collapsible:a=!1,indentSize:i=2,invalidXml:s,initalCollapsedDepth:o,initialCollapsedDepth:l}=t,[c,d]=k(()=>document.documentElement.classList.contains("dark"));S(()=>{const e=document.documentElement,t=new MutationObserver(()=>{d(e.classList.contains("dark"))});return t.observe(e,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const u=A(()=>({...c?ia:aa,...r}),[c,r]),{json:h,valid:m}=function(e){return A(()=>{try{if(!Ke.validate(e))throw new Error("Invalid XML!");const t=la.parse(e);if("string"==typeof e&&e.trim().length>0&&0===t.length)throw new Error("Invalid XML!");return{json:t,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e.message}`}}},[e])}(n),p=A(()=>({theme:u,collapsible:a,indentSize:i,initialCollapsedDepth:l??o}),[u,a,i,o,l]);return m?e(sa.Provider,{value:p,children:e("div",{className:"rxv-container",style:{whiteSpace:"pre-wrap",fontFamily:u.fontFamily,overflowWrap:"break-word"},children:e(wa,{elements:h})})}):s||e(Na,{})}export{yt as ArrayPropertySchema,Mr as ArtifactContentRenderer,Kr as ChartCodeBlockHandler,tr as CodeBlockErrorBoundary,Ur as CodeBlockHandlerProvider,er as CodeBlockPlaceholder,Ut as CodeBlockRendererProvider,Yn as DropZone,Zr as ExpandCodeBlockHandler,et as FieldSetContextProvider,ot as Form,rt as FormContext,it as FormContextProvider,Pt as FormError,$t as FormHelper,Ot as FormLabel,ct as GeneratedForm,st as Input,It as JSONCode,Vt as JSONDisplay,Lt as JSONView,At as ManageObjectEntry,St as ManagedListProperty,Nt as ManagedObject,wt as ManagedObjectBase,kt as ManagedObjectProperty,Ct as ManagedProperty,jt as ManagedScalarEntry,Cn as ManagedSchema,sr as MarkdownFigure,ar as MarkdownImage,rr as MarkdownLink,sn as MarkdownRenderer,Gr as MermaidCodeBlockHandler,$r as MermaidDiagram,Ze as MonacoEditor,xt as Node,mn as Popover,on as PopoverContext,yn as Progress,bn as PropertiesView,On as PropertyEditor,$n as PropertyNameEditor,gt as PropertySchema,Rn as PropertyViewer,Xr as ProposalCodeBlockHandler,ut as ScalarField,ft as Schema,_n as SchemaEditor,Sn as SchemaNode,Gn as SvgIcon,Zn as UploadResultCategory,Qn as UploadSummary,Ye as VEditorApi,ka as XMLViewer,bt as computeTitleFromName,en as createDefaultCodeBlockHandlers,Xn as createSvgIcon,An as getEditableSchemaProperty,Qr as isExpandLanguage,Yt as mapSchemeToRoute,Xt as parseUrlScheme,Rr as useArtifactContent,Ht as useCodeBlockComponent,Wr as useCodeBlockContext,Wt as useCodeBlockRendererRegistry,tt as useFieldSet,at as useForm,ln as usePopoverContext,Zt as useResolvedUrl,En as useSchema,Bn as validatePropertyName};
|
|
2
2
|
//# sourceMappingURL=vertesia-ui-widgets.js.map
|