@mcp-use/inspector 20.0.0-beta.5 → 20.0.0-beta.51
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/README.md +31 -78
- package/dist/app/inspector.css.gz +0 -0
- package/dist/app/inspector.js.gz +0 -0
- package/dist/app/providers/anthropic.png +0 -0
- package/dist/app/providers/google.png +0 -0
- package/dist/app/providers/openai.png +0 -0
- package/dist/cli.js +332 -1384
- package/dist/client/index.d.ts +1405 -50
- package/dist/client/index.js +165 -24019
- package/dist/server/index.d.ts +79 -7
- package/dist/server/index.js +370 -22
- package/package.json +77 -35
- package/dist/cdn/AnimatePresence-Dcw-FOy8.js +0 -393
- package/dist/cdn/ChatTab-B255lH5i.js +0 -6744
- package/dist/cdn/CheckboxIndicator-Bt4IICtv.js +0 -251
- package/dist/cdn/ConnectionSettingsForm-DF-NS58d.js +0 -929
- package/dist/cdn/ConnectionSettingsTab-dI-Cqe79.js +0 -150
- package/dist/cdn/ElicitationTab-CL1KJ0bz.js +0 -654
- package/dist/cdn/FormContext-tmgN_Vdr.js +0 -135
- package/dist/cdn/InspectorContext-UjtEbNod.js +0 -123
- package/dist/cdn/JSONDisplay-BFxf5oEu.js +0 -324
- package/dist/cdn/ListTabHeader-Cv-GmtGF.js +0 -88
- package/dist/cdn/ManufactOAuthCallback-B98kSYCj.js +0 -31
- package/dist/cdn/MarkdownRenderer-Ba7nA4Ie.js +0 -3610
- package/dist/cdn/NotificationsTab-CeImSrhx.js +0 -290
- package/dist/cdn/OAuthCallback-Blc2Asxc.js +0 -58
- package/dist/cdn/PromptsTab-BYKnY7Rp.js +0 -901
- package/dist/cdn/ResourcesTab-BGualKW-.js +0 -564
- package/dist/cdn/SamplingTab-BeZBUeni.js +0 -658
- package/dist/cdn/ServerMetadataTab-CvrKX8fz.js +0 -244
- package/dist/cdn/StatusIcon-D0-ARyOh.js +0 -66
- package/dist/cdn/ToolsTab-j6n4O_3s.js +0 -2033
- package/dist/cdn/ViewPreview-DihyG6Qd.js +0 -238
- package/dist/cdn/WidgetDebugContext-D4usL_MA.js +0 -324
- package/dist/cdn/WidgetWrapper-B4H3Fek7.js +0 -2210
- package/dist/cdn/basePath-B8HuhIMu.js +0 -25
- package/dist/cdn/bell-CGjAO_0s.js +0 -10
- package/dist/cdn/browser-CbQIH4w2.js +0 -42
- package/dist/cdn/brush-B_mKhyxG.js +0 -17
- package/dist/cdn/card-DgiYnSg-.js +0 -41
- package/dist/cdn/cfWorker-Bxcs9rNe.js +0 -10799
- package/dist/cdn/checkbox-By0FklhG.js +0 -20
- package/dist/cdn/chunk-QUQL4437-XnDcYQEx.js +0 -1508
- package/dist/cdn/clock-CmUbSx_B.js +0 -12
- package/dist/cdn/code-V_0nf5rg.js +0 -10
- package/dist/cdn/createLucideIcon-C5fZZ6oB.js +0 -38
- package/dist/cdn/dialog-BsDpuJd3.js +0 -1028
- package/dist/cdn/dist-DaMB0Su9.js +0 -616
- package/dist/cdn/dist-DbX5yidW.js +0 -2306
- package/dist/cdn/external-link-CjmfT6rW.js +0 -17
- package/dist/cdn/eye-B7H96av8.js +0 -29
- package/dist/cdn/folder-open-B3lu2rG_.js +0 -7
- package/dist/cdn/hash-BVQnWi7q.js +0 -33
- package/dist/cdn/history-Csw4rb44.js +0 -17
- package/dist/cdn/index-browser-DkQOzkvX.js +0 -1934
- package/dist/cdn/info-CNiOwqkf.js +0 -19
- package/dist/cdn/input-C2OBd4PJ.js +0 -12160
- package/dist/cdn/inspector-settings-layout-0VDsjeqb.js +0 -4
- package/dist/cdn/inspector.css +0 -2
- package/dist/cdn/inspector.js +0 -24523
- package/dist/cdn/jsx-runtime-CIxvMpEo.js +0 -180
- package/dist/cdn/label-B9Jmm9be.js +0 -60
- package/dist/cdn/loader-circle-BLy9A_pp.js +0 -7
- package/dist/cdn/manufact-auth-BQMHhbLV.js +0 -423
- package/dist/cdn/maximize-2-CH5Lq90B.js +0 -21
- package/dist/cdn/maximize-BALCV_ep.js +0 -21
- package/dist/cdn/message-square-BnxdpJxZ.js +0 -7
- package/dist/cdn/not-found-DEtSM_Wd.js +0 -34
- package/dist/cdn/play-vuZ5PLnI.js +0 -7
- package/dist/cdn/providerMeta-BQIfHuNL.js +0 -379
- package/dist/cdn/providers/anthropic.png +0 -0
- package/dist/cdn/providers/google.png +0 -0
- package/dist/cdn/providers/openai.png +0 -0
- package/dist/cdn/react-BIs9pQ3H.js +0 -926
- package/dist/cdn/react-BajV-X4P.js +0 -5425
- package/dist/cdn/refresh-cw-BXY-Pa0U.js +0 -21
- package/dist/cdn/save-Tgil_AJZ.js +0 -34
- package/dist/cdn/schemaHelpers-DTV38jGq.js +0 -16
- package/dist/cdn/select-DDdiIPR2.js +0 -2594
- package/dist/cdn/servers-Dm72iTpY.js +0 -26
- package/dist/cdn/shared-DaILIQPP.js +0 -1700
- package/dist/cdn/sheet-Br_l2kry.js +0 -2077
- package/dist/cdn/sparkles-BntO2rDR.js +0 -23
- package/dist/cdn/spinner-jQtC7EBj.js +0 -15
- package/dist/cdn/square-check-big-BvwQ17Bl.js +0 -10
- package/dist/cdn/switch-C3IyQuid.js +0 -664
- package/dist/cdn/tabs-subtle-CkdI6Mac.js +0 -787
- package/dist/cdn/telemetry-DabTAQ8x.js +0 -240
- package/dist/cdn/textarea-DSbwcFVt.js +0 -14
- package/dist/cdn/trash-2-RwpJY5SL.js +0 -25
- package/dist/cdn/useAriaLabelledBy-DqAdnppm.js +0 -29
- package/dist/cdn/useCompositeItem-BRqEzYh-.js +0 -26
- package/dist/cdn/useConfig-Btmh8wjJ.js +0 -235
- package/dist/cdn/useSavedRequests-Ci2I919u.js +0 -51
- package/dist/cdn/useViewHostProps-B6SKeeH9.js +0 -349
- package/dist/cdn/wrench-DzGmCfnb.js +0 -7
- package/dist/cdn/x-C3vRQIYu.js +0 -10
- package/dist/cdn/zap-Mb-pbw2X.js +0 -10
- package/dist/client/auth/manufact-auth.d.ts +0 -32
- package/dist/client/auth/manufact-auth.d.ts.map +0 -1
- package/dist/client/chat-history/ChatHistoryHeader.d.ts +0 -4
- package/dist/client/chat-history/ChatHistoryHeader.d.ts.map +0 -1
- package/dist/client/chat-history/ChatHistoryPanel.d.ts +0 -28
- package/dist/client/chat-history/ChatHistoryPanel.d.ts.map +0 -1
- package/dist/client/chat-history/ChatHistoryRail.d.ts +0 -5
- package/dist/client/chat-history/ChatHistoryRail.d.ts.map +0 -1
- package/dist/client/chat-history/ChatList.d.ts +0 -18
- package/dist/client/chat-history/ChatList.d.ts.map +0 -1
- package/dist/client/chat-history/ChatTitleReveal.d.ts +0 -10
- package/dist/client/chat-history/ChatTitleReveal.d.ts.map +0 -1
- package/dist/client/chat-history/chat-events-to-inspector-messages.d.ts +0 -13
- package/dist/client/chat-history/chat-events-to-inspector-messages.d.ts.map +0 -1
- package/dist/client/chat-history/chat-title.d.ts +0 -10
- package/dist/client/chat-history/chat-title.d.ts.map +0 -1
- package/dist/client/chat-history/providers/local-storage.d.ts +0 -21
- package/dist/client/chat-history/providers/local-storage.d.ts.map +0 -1
- package/dist/client/chat-history/types.d.ts +0 -39
- package/dist/client/chat-history/types.d.ts.map +0 -1
- package/dist/client/chat-history/useChatHistory.d.ts +0 -20
- package/dist/client/chat-history/useChatHistory.d.ts.map +0 -1
- package/dist/client/chat-history/useChatTitleGeneration.d.ts +0 -17
- package/dist/client/chat-history/useChatTitleGeneration.d.ts.map +0 -1
- package/dist/client/components/AddToClientDropdown.d.ts +0 -52
- package/dist/client/components/AddToClientDropdown.d.ts.map +0 -1
- package/dist/client/components/ChatTab.d.ts +0 -98
- package/dist/client/components/ChatTab.d.ts.map +0 -1
- package/dist/client/components/IframeConsole.d.ts +0 -7
- package/dist/client/components/IframeConsole.d.ts.map +0 -1
- package/dist/client/components/MCPAppsDebugControls.d.ts +0 -19
- package/dist/client/components/MCPAppsDebugControls.d.ts.map +0 -1
- package/dist/client/components/PromptsTab.d.ts +0 -34
- package/dist/client/components/PromptsTab.d.ts.map +0 -1
- package/dist/client/components/ResourcesTab.d.ts +0 -31
- package/dist/client/components/ResourcesTab.d.ts.map +0 -1
- package/dist/client/components/ToolsTab.d.ts +0 -39
- package/dist/client/components/ToolsTab.d.ts.map +0 -1
- package/dist/client/components/chat/AssistantMessage.d.ts +0 -10
- package/dist/client/components/chat/AssistantMessage.d.ts.map +0 -1
- package/dist/client/components/chat/ChatHeader.d.ts +0 -70
- package/dist/client/components/chat/ChatHeader.d.ts.map +0 -1
- package/dist/client/components/chat/ChatInput.d.ts +0 -29
- package/dist/client/components/chat/ChatInput.d.ts.map +0 -1
- package/dist/client/components/chat/ChatInputArea.d.ts +0 -65
- package/dist/client/components/chat/ChatInputArea.d.ts.map +0 -1
- package/dist/client/components/chat/ChatLandingForm.d.ts +0 -15
- package/dist/client/components/chat/ChatLandingForm.d.ts.map +0 -1
- package/dist/client/components/chat/ChatManagedNotice.d.ts +0 -10
- package/dist/client/components/chat/ChatManagedNotice.d.ts.map +0 -1
- package/dist/client/components/chat/ChatScrollToBottomButton.d.ts +0 -7
- package/dist/client/components/chat/ChatScrollToBottomButton.d.ts.map +0 -1
- package/dist/client/components/chat/ChatScrollTopFade.d.ts +0 -7
- package/dist/client/components/chat/ChatScrollTopFade.d.ts.map +0 -1
- package/dist/client/components/chat/ChatTraceView.d.ts +0 -7
- package/dist/client/components/chat/ChatTraceView.d.ts.map +0 -1
- package/dist/client/components/chat/ConfigurationDialog.d.ts +0 -42
- package/dist/client/components/chat/ConfigurationDialog.d.ts.map +0 -1
- package/dist/client/components/chat/ConfigureEmptyState.d.ts +0 -6
- package/dist/client/components/chat/ConfigureEmptyState.d.ts.map +0 -1
- package/dist/client/components/chat/CopyButton.d.ts +0 -10
- package/dist/client/components/chat/CopyButton.d.ts.map +0 -1
- package/dist/client/components/chat/FloatingChatElicitation.d.ts +0 -10
- package/dist/client/components/chat/FloatingChatElicitation.d.ts.map +0 -1
- package/dist/client/components/chat/McpReconnectBanner.d.ts +0 -10
- package/dist/client/components/chat/McpReconnectBanner.d.ts.map +0 -1
- package/dist/client/components/chat/MessageList.d.ts +0 -47
- package/dist/client/components/chat/MessageList.d.ts.map +0 -1
- package/dist/client/components/chat/MessageMetaActions.d.ts +0 -7
- package/dist/client/components/chat/MessageMetaActions.d.ts.map +0 -1
- package/dist/client/components/chat/PromptResultsList.d.ts +0 -8
- package/dist/client/components/chat/PromptResultsList.d.ts.map +0 -1
- package/dist/client/components/chat/PromptsDropdown.d.ts +0 -11
- package/dist/client/components/chat/PromptsDropdown.d.ts.map +0 -1
- package/dist/client/components/chat/StreamingAssistantContent.d.ts +0 -7
- package/dist/client/components/chat/StreamingAssistantContent.d.ts.map +0 -1
- package/dist/client/components/chat/SystemPromptButton.d.ts +0 -11
- package/dist/client/components/chat/SystemPromptButton.d.ts.map +0 -1
- package/dist/client/components/chat/ToolCallDisplay.d.ts +0 -10
- package/dist/client/components/chat/ToolCallDisplay.d.ts.map +0 -1
- package/dist/client/components/chat/ToolResultRenderer.d.ts +0 -15
- package/dist/client/components/chat/ToolResultRenderer.d.ts.map +0 -1
- package/dist/client/components/chat/ToolSelector.d.ts +0 -13
- package/dist/client/components/chat/ToolSelector.d.ts.map +0 -1
- package/dist/client/components/chat/UserMessage.d.ts +0 -10
- package/dist/client/components/chat/UserMessage.d.ts.map +0 -1
- package/dist/client/components/chat/chat-bar-styles.d.ts +0 -6
- package/dist/client/components/chat/chat-bar-styles.d.ts.map +0 -1
- package/dist/client/components/chat/chatModeStorage.d.ts +0 -11
- package/dist/client/components/chat/chatModeStorage.d.ts.map +0 -1
- package/dist/client/components/chat/conversion.d.ts +0 -19
- package/dist/client/components/chat/conversion.d.ts.map +0 -1
- package/dist/client/components/chat/freeTier.d.ts +0 -32
- package/dist/client/components/chat/freeTier.d.ts.map +0 -1
- package/dist/client/components/chat/managedChatNotice.d.ts +0 -16
- package/dist/client/components/chat/managedChatNotice.d.ts.map +0 -1
- package/dist/client/components/chat/providerMeta.d.ts +0 -27
- package/dist/client/components/chat/providerMeta.d.ts.map +0 -1
- package/dist/client/components/chat/system-prompt/local-storage.d.ts +0 -5
- package/dist/client/components/chat/system-prompt/local-storage.d.ts.map +0 -1
- package/dist/client/components/chat/system-prompt/types.d.ts +0 -8
- package/dist/client/components/chat/system-prompt/types.d.ts.map +0 -1
- package/dist/client/components/chat/system-prompt/useLocalSystemPrompt.d.ts +0 -3
- package/dist/client/components/chat/system-prompt/useLocalSystemPrompt.d.ts.map +0 -1
- package/dist/client/components/chat/system-prompt-default.d.ts +0 -2
- package/dist/client/components/chat/system-prompt-default.d.ts.map +0 -1
- package/dist/client/components/chat/trace.d.ts +0 -84
- package/dist/client/components/chat/trace.d.ts.map +0 -1
- package/dist/client/components/chat/types.d.ts +0 -75
- package/dist/client/components/chat/types.d.ts.map +0 -1
- package/dist/client/components/chat/useChatMessages.d.ts +0 -76
- package/dist/client/components/chat/useChatMessages.d.ts.map +0 -1
- package/dist/client/components/chat/useChatMessagesClientSide.d.ts +0 -43
- package/dist/client/components/chat/useChatMessagesClientSide.d.ts.map +0 -1
- package/dist/client/components/chat/useChatScrollToBottom.d.ts +0 -14
- package/dist/client/components/chat/useChatScrollToBottom.d.ts.map +0 -1
- package/dist/client/components/chat/useConfig.d.ts +0 -24
- package/dist/client/components/chat/useConfig.d.ts.map +0 -1
- package/dist/client/components/chat/useHostedChatMode.d.ts +0 -14
- package/dist/client/components/chat/useHostedChatMode.d.ts.map +0 -1
- package/dist/client/components/chat/useManagedCloudModel.d.ts +0 -14
- package/dist/client/components/chat/useManagedCloudModel.d.ts.map +0 -1
- package/dist/client/components/chat/utils.d.ts +0 -11
- package/dist/client/components/chat/utils.d.ts.map +0 -1
- package/dist/client/components/elicitation/shared/ElicitationAskUserPanel.d.ts +0 -12
- package/dist/client/components/elicitation/shared/ElicitationAskUserPanel.d.ts.map +0 -1
- package/dist/client/components/elicitation/shared/elicitationToAskUserQuestions.d.ts +0 -9
- package/dist/client/components/elicitation/shared/elicitationToAskUserQuestions.d.ts.map +0 -1
- package/dist/client/components/elicitation/shared/schemaHelpers.d.ts +0 -8
- package/dist/client/components/elicitation/shared/schemaHelpers.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptExecutionPanel.d.ts +0 -13
- package/dist/client/components/prompts/PromptExecutionPanel.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptInputForm.d.ts +0 -9
- package/dist/client/components/prompts/PromptInputForm.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptMessageCard.d.ts +0 -29
- package/dist/client/components/prompts/PromptMessageCard.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptResultDisplay.d.ts +0 -34
- package/dist/client/components/prompts/PromptResultDisplay.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptsList.d.ts +0 -10
- package/dist/client/components/prompts/PromptsList.d.ts.map +0 -1
- package/dist/client/components/prompts/SavedPromptsList.d.ts +0 -19
- package/dist/client/components/prompts/SavedPromptsList.d.ts.map +0 -1
- package/dist/client/components/resources/PropsConfigDialog.d.ts +0 -16
- package/dist/client/components/resources/PropsConfigDialog.d.ts.map +0 -1
- package/dist/client/components/resources/ResourceResultDisplay.d.ts +0 -30
- package/dist/client/components/resources/ResourceResultDisplay.d.ts.map +0 -1
- package/dist/client/components/resources/ResourcesList.d.ts +0 -10
- package/dist/client/components/resources/ResourcesList.d.ts.map +0 -1
- package/dist/client/components/shared/CollapsibleJSON.d.ts +0 -6
- package/dist/client/components/shared/CollapsibleJSON.d.ts.map +0 -1
- package/dist/client/components/shared/InspectorScrollArea.d.ts +0 -9
- package/dist/client/components/shared/InspectorScrollArea.d.ts.map +0 -1
- package/dist/client/components/shared/JSONDisplay.d.ts +0 -12
- package/dist/client/components/shared/JSONDisplay.d.ts.map +0 -1
- package/dist/client/components/shared/ListItem.d.ts +0 -24
- package/dist/client/components/shared/ListItem.d.ts.map +0 -1
- package/dist/client/components/shared/ListTabHeader.d.ts +0 -47
- package/dist/client/components/shared/ListTabHeader.d.ts.map +0 -1
- package/dist/client/components/shared/MarkdownRenderer.d.ts +0 -15
- package/dist/client/components/shared/MarkdownRenderer.d.ts.map +0 -1
- package/dist/client/components/shared/SchemaFormField.d.ts +0 -12
- package/dist/client/components/shared/SchemaFormField.d.ts.map +0 -1
- package/dist/client/components/shared/SearchTabHeader.d.ts +0 -28
- package/dist/client/components/shared/SearchTabHeader.d.ts.map +0 -1
- package/dist/client/components/shared/StatusIcon.d.ts +0 -12
- package/dist/client/components/shared/StatusIcon.d.ts.map +0 -1
- package/dist/client/components/shared/index.d.ts +0 -7
- package/dist/client/components/shared/index.d.ts.map +0 -1
- package/dist/client/components/tools/SaveRequestDialog.d.ts +0 -11
- package/dist/client/components/tools/SaveRequestDialog.d.ts.map +0 -1
- package/dist/client/components/tools/SavedRequestsList.d.ts +0 -19
- package/dist/client/components/tools/SavedRequestsList.d.ts.map +0 -1
- package/dist/client/components/tools/ToolExecutionPanel.d.ts +0 -20
- package/dist/client/components/tools/ToolExecutionPanel.d.ts.map +0 -1
- package/dist/client/components/tools/ToolInputForm.d.ts +0 -14
- package/dist/client/components/tools/ToolInputForm.d.ts.map +0 -1
- package/dist/client/components/tools/ToolResultDisplay.d.ts +0 -24
- package/dist/client/components/tools/ToolResultDisplay.d.ts.map +0 -1
- package/dist/client/components/tools/ToolsList.d.ts +0 -10
- package/dist/client/components/tools/ToolsList.d.ts.map +0 -1
- package/dist/client/components/tools/schema-utils.d.ts +0 -13
- package/dist/client/components/tools/schema-utils.d.ts.map +0 -1
- package/dist/client/components/tools/useToolExecution.d.ts +0 -26
- package/dist/client/components/tools/useToolExecution.d.ts.map +0 -1
- package/dist/client/components/tools/useToolsTabNavigation.d.ts +0 -35
- package/dist/client/components/tools/useToolsTabNavigation.d.ts.map +0 -1
- package/dist/client/components/ui/MeshGradientCanvas.d.ts +0 -13
- package/dist/client/components/ui/MeshGradientCanvas.d.ts.map +0 -1
- package/dist/client/components/ui/WidgetWrapper.d.ts +0 -12
- package/dist/client/components/ui/WidgetWrapper.d.ts.map +0 -1
- package/dist/client/components/ui/alert-dialog.d.ts +0 -15
- package/dist/client/components/ui/alert-dialog.d.ts.map +0 -1
- package/dist/client/components/ui/ask-user-questions.d.ts +0 -80
- package/dist/client/components/ui/ask-user-questions.d.ts.map +0 -1
- package/dist/client/components/ui/badge.d.ts +0 -34
- package/dist/client/components/ui/badge.d.ts.map +0 -1
- package/dist/client/components/ui/blur-fade.d.ts +0 -25
- package/dist/client/components/ui/blur-fade.d.ts.map +0 -1
- package/dist/client/components/ui/button.d.ts +0 -34
- package/dist/client/components/ui/button.d.ts.map +0 -1
- package/dist/client/components/ui/chat-message.d.ts +0 -23
- package/dist/client/components/ui/chat-message.d.ts.map +0 -1
- package/dist/client/components/ui/checkbox.d.ts +0 -4
- package/dist/client/components/ui/checkbox.d.ts.map +0 -1
- package/dist/client/components/ui/client-icons.d.ts +0 -20
- package/dist/client/components/ui/client-icons.d.ts.map +0 -1
- package/dist/client/components/ui/command.d.ts +0 -17
- package/dist/client/components/ui/command.d.ts.map +0 -1
- package/dist/client/components/ui/dialog.d.ts +0 -37
- package/dist/client/components/ui/dialog.d.ts.map +0 -1
- package/dist/client/components/ui/dropdown-menu.d.ts +0 -25
- package/dist/client/components/ui/dropdown-menu.d.ts.map +0 -1
- package/dist/client/components/ui/dropdown.d.ts +0 -30
- package/dist/client/components/ui/dropdown.d.ts.map +0 -1
- package/dist/client/components/ui/file-thumbnail.d.ts +0 -9
- package/dist/client/components/ui/file-thumbnail.d.ts.map +0 -1
- package/dist/client/components/ui/input.d.ts +0 -4
- package/dist/client/components/ui/input.d.ts.map +0 -1
- package/dist/client/components/ui/kbd.d.ts +0 -3
- package/dist/client/components/ui/kbd.d.ts.map +0 -1
- package/dist/client/components/ui/label.d.ts +0 -4
- package/dist/client/components/ui/label.d.ts.map +0 -1
- package/dist/client/components/ui/menu-item.d.ts +0 -52
- package/dist/client/components/ui/menu-item.d.ts.map +0 -1
- package/dist/client/components/ui/mesh-tab-background.d.ts +0 -12
- package/dist/client/components/ui/mesh-tab-background.d.ts.map +0 -1
- package/dist/client/components/ui/not-found.d.ts +0 -9
- package/dist/client/components/ui/not-found.d.ts.map +0 -1
- package/dist/client/components/ui/popover.d.ts +0 -6
- package/dist/client/components/ui/popover.d.ts.map +0 -1
- package/dist/client/components/ui/resizable.d.ts +0 -10
- package/dist/client/components/ui/resizable.d.ts.map +0 -1
- package/dist/client/components/ui/scroll-area.d.ts +0 -4
- package/dist/client/components/ui/scroll-area.d.ts.map +0 -1
- package/dist/client/components/ui/select.d.ts +0 -52
- package/dist/client/components/ui/select.d.ts.map +0 -1
- package/dist/client/components/ui/sheet.d.ts +0 -14
- package/dist/client/components/ui/sheet.d.ts.map +0 -1
- package/dist/client/components/ui/skeleton.d.ts +0 -4
- package/dist/client/components/ui/skeleton.d.ts.map +0 -1
- package/dist/client/components/ui/spinner.d.ts +0 -3
- package/dist/client/components/ui/spinner.d.ts.map +0 -1
- package/dist/client/components/ui/switch.d.ts +0 -22
- package/dist/client/components/ui/switch.d.ts.map +0 -1
- package/dist/client/components/ui/table.d.ts +0 -9
- package/dist/client/components/ui/table.d.ts.map +0 -1
- package/dist/client/components/ui/tabs-subtle.d.ts +0 -25
- package/dist/client/components/ui/tabs-subtle.d.ts.map +0 -1
- package/dist/client/components/ui/text-shimmer.d.ts +0 -11
- package/dist/client/components/ui/text-shimmer.d.ts.map +0 -1
- package/dist/client/components/ui/textarea.d.ts +0 -4
- package/dist/client/components/ui/textarea.d.ts.map +0 -1
- package/dist/client/components/ui/tooltip.d.ts +0 -43
- package/dist/client/components/ui/tooltip.d.ts.map +0 -1
- package/dist/client/components/ui-playground/shared/SafeAreaInsetsEditor.d.ts +0 -19
- package/dist/client/components/ui-playground/shared/SafeAreaInsetsEditor.d.ts.map +0 -1
- package/dist/client/console-log-bus.d.ts +0 -24
- package/dist/client/console-log-bus.d.ts.map +0 -1
- package/dist/client/constants/debug-options.d.ts +0 -16
- package/dist/client/constants/debug-options.d.ts.map +0 -1
- package/dist/client/context/InspectorContext.d.ts +0 -134
- package/dist/client/context/InspectorContext.d.ts.map +0 -1
- package/dist/client/context/ThemeContext.d.ts +0 -17
- package/dist/client/context/ThemeContext.d.ts.map +0 -1
- package/dist/client/context/WidgetDebugContext.d.ts +0 -121
- package/dist/client/context/WidgetDebugContext.d.ts.map +0 -1
- package/dist/client/hooks/use-merge-split.d.ts +0 -36
- package/dist/client/hooks/use-merge-split.d.ts.map +0 -1
- package/dist/client/hooks/use-proximity-hover-index.d.ts +0 -27
- package/dist/client/hooks/use-proximity-hover-index.d.ts.map +0 -1
- package/dist/client/hooks/use-proximity-hover.d.ts +0 -26
- package/dist/client/hooks/use-proximity-hover.d.ts.map +0 -1
- package/dist/client/hooks/use-touch-primary.d.ts +0 -2
- package/dist/client/hooks/use-touch-primary.d.ts.map +0 -1
- package/dist/client/hooks/useDeviceViewport.d.ts +0 -18
- package/dist/client/hooks/useDeviceViewport.d.ts.map +0 -1
- package/dist/client/hooks/useHostedSession.d.ts +0 -9
- package/dist/client/hooks/useHostedSession.d.ts.map +0 -1
- package/dist/client/hooks/useIframeConsole.d.ts +0 -24
- package/dist/client/hooks/useIframeConsole.d.ts.map +0 -1
- package/dist/client/hooks/useKeyboardShortcuts.d.ts +0 -28
- package/dist/client/hooks/useKeyboardShortcuts.d.ts.map +0 -1
- package/dist/client/hooks/useMCPPrompts.d.ts +0 -94
- package/dist/client/hooks/useMCPPrompts.d.ts.map +0 -1
- package/dist/client/hooks/useMcpAppsHostContext.d.ts +0 -27
- package/dist/client/hooks/useMcpAppsHostContext.d.ts.map +0 -1
- package/dist/client/hooks/usePropsLLM.d.ts +0 -20
- package/dist/client/hooks/usePropsLLM.d.ts.map +0 -1
- package/dist/client/hooks/useResourceProps.d.ts +0 -14
- package/dist/client/hooks/useResourceProps.d.ts.map +0 -1
- package/dist/client/hooks/useSavedRequests.d.ts +0 -6
- package/dist/client/hooks/useSavedRequests.d.ts.map +0 -1
- package/dist/client/hooks/useViewHostProps.d.ts +0 -19
- package/dist/client/hooks/useViewHostProps.d.ts.map +0 -1
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/lib/elevated.d.ts +0 -28
- package/dist/client/lib/elevated.d.ts.map +0 -1
- package/dist/client/lib/font-weight.d.ts +0 -10
- package/dist/client/lib/font-weight.d.ts.map +0 -1
- package/dist/client/lib/icon-context.d.ts +0 -15
- package/dist/client/lib/icon-context.d.ts.map +0 -1
- package/dist/client/lib/shape-context.d.ts +0 -21
- package/dist/client/lib/shape-context.d.ts.map +0 -1
- package/dist/client/lib/springs.d.ts +0 -32
- package/dist/client/lib/springs.d.ts.map +0 -1
- package/dist/client/lib/surface-classes.d.ts +0 -2
- package/dist/client/lib/surface-classes.d.ts.map +0 -1
- package/dist/client/lib/surface-context.d.ts +0 -7
- package/dist/client/lib/surface-context.d.ts.map +0 -1
- package/dist/client/lib/utils.d.ts +0 -3
- package/dist/client/lib/utils.d.ts.map +0 -1
- package/dist/client/mcp-apps/csp.d.ts +0 -26
- package/dist/client/mcp-apps/csp.d.ts.map +0 -1
- package/dist/client/mcp-apps/debug/csp-suggestions.d.ts +0 -17
- package/dist/client/mcp-apps/debug/csp-suggestions.d.ts.map +0 -1
- package/dist/client/mcp-apps/logging-transport.d.ts +0 -13
- package/dist/client/mcp-apps/logging-transport.d.ts.map +0 -1
- package/dist/client/rpc-traffic-coalesce.d.ts +0 -7
- package/dist/client/rpc-traffic-coalesce.d.ts.map +0 -1
- package/dist/client/rpc-traffic-store.d.ts +0 -37
- package/dist/client/rpc-traffic-store.d.ts.map +0 -1
- package/dist/client/telemetry/capture.d.ts +0 -7
- package/dist/client/telemetry/capture.d.ts.map +0 -1
- package/dist/client/telemetry/events.d.ts +0 -168
- package/dist/client/telemetry/events.d.ts.map +0 -1
- package/dist/client/telemetry/index.d.ts +0 -5
- package/dist/client/telemetry/index.d.ts.map +0 -1
- package/dist/client/telemetry/init.d.ts +0 -2
- package/dist/client/telemetry/init.d.ts.map +0 -1
- package/dist/client/telemetry/utils.d.ts +0 -7
- package/dist/client/telemetry/utils.d.ts.map +0 -1
- package/dist/client/types/message-content-block.d.ts +0 -19
- package/dist/client/types/message-content-block.d.ts.map +0 -1
- package/dist/client/types/pending-requests.d.ts +0 -17
- package/dist/client/types/pending-requests.d.ts.map +0 -1
- package/dist/client/utils/basePath.d.ts +0 -34
- package/dist/client/utils/basePath.d.ts.map +0 -1
- package/dist/client/utils/browser.d.ts +0 -5
- package/dist/client/utils/browser.d.ts.map +0 -1
- package/dist/client/utils/format.d.ts +0 -4
- package/dist/client/utils/format.d.ts.map +0 -1
- package/dist/client/utils/highlightJson.d.ts +0 -11
- package/dist/client/utils/highlightJson.d.ts.map +0 -1
- package/dist/client/utils/jsonUtils.d.ts +0 -24
- package/dist/client/utils/jsonUtils.d.ts.map +0 -1
- package/dist/client/utils/mcpClientUtils.d.ts +0 -131
- package/dist/client/utils/mcpClientUtils.d.ts.map +0 -1
- package/dist/client/utils/servers.d.ts +0 -14
- package/dist/client/utils/servers.d.ts.map +0 -1
- package/dist/server/asset-urls.d.ts +0 -18
- package/dist/server/asset-urls.d.ts.map +0 -1
- package/dist/server/asset-urls.js +0 -17
- package/dist/server/cdn-shell.d.ts +0 -18
- package/dist/server/cdn-shell.d.ts.map +0 -1
- package/dist/server/cdn-shell.js +0 -12
- package/dist/server/chunk-DSTNUYWX.js +0 -148
- package/dist/server/chunk-H6ZCIKBS.js +0 -63
- package/dist/server/chunk-IKTZUWSX.js +0 -0
- package/dist/server/chunk-J4FNYLBF.js +0 -54
- package/dist/server/chunk-K2F2AJOI.js +0 -619
- package/dist/server/chunk-KD7K27XK.js +0 -77
- package/dist/server/chunk-M5TZA42I.js +0 -54
- package/dist/server/chunk-OWR2BIBW.js +0 -40
- package/dist/server/chunk-PKBMQBKP.js +0 -7
- package/dist/server/chunk-SQ4XNMLT.js +0 -72
- package/dist/server/chunk-UJLXHNQP.js +0 -43
- package/dist/server/chunk-WFT4JHYI.js +0 -24
- package/dist/server/chunk-XCNS5CIW.js +0 -199
- package/dist/server/chunk-ZCGLU5T7.js +0 -156
- package/dist/server/cli.d.ts +0 -3
- package/dist/server/cli.d.ts.map +0 -1
- package/dist/server/cli.js +0 -141
- package/dist/server/create-dev-api-app.d.ts +0 -4
- package/dist/server/create-dev-api-app.d.ts.map +0 -1
- package/dist/server/create-dev-api-app.js +0 -11
- package/dist/server/dev-callback-redirect.d.ts +0 -3
- package/dist/server/dev-callback-redirect.d.ts.map +0 -1
- package/dist/server/dev-callback-redirect.js +0 -18
- package/dist/server/favicon-links.d.ts +0 -12
- package/dist/server/favicon-links.d.ts.map +0 -1
- package/dist/server/favicon-links.js +0 -11
- package/dist/server/favicon-static.d.ts +0 -4
- package/dist/server/favicon-static.d.ts.map +0 -1
- package/dist/server/favicon-static.js +0 -8
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/middleware.d.ts +0 -40
- package/dist/server/middleware.d.ts.map +0 -1
- package/dist/server/middleware.js +0 -17
- package/dist/server/proxy/index.d.ts +0 -3
- package/dist/server/proxy/index.d.ts.map +0 -1
- package/dist/server/proxy/index.js +0 -12
- package/dist/server/proxy/mcp-proxy.d.ts +0 -101
- package/dist/server/proxy/mcp-proxy.d.ts.map +0 -1
- package/dist/server/proxy/mcp-proxy.js +0 -10
- package/dist/server/proxy/oauth-proxy.d.ts +0 -26
- package/dist/server/proxy/oauth-proxy.d.ts.map +0 -1
- package/dist/server/proxy/oauth-proxy.js +0 -9
- package/dist/server/proxy-routes.d.ts +0 -16
- package/dist/server/proxy-routes.d.ts.map +0 -1
- package/dist/server/proxy-routes.js +0 -10
- package/dist/server/rpc-log-bus.d.ts +0 -17
- package/dist/server/rpc-log-bus.d.ts.map +0 -1
- package/dist/server/rpc-log-bus.js +0 -77
- package/dist/server/server.d.ts +0 -15
- package/dist/server/server.d.ts.map +0 -1
- package/dist/server/server.js +0 -66
- package/dist/server/static-assets.d.ts +0 -5
- package/dist/server/static-assets.d.ts.map +0 -1
- package/dist/server/static-assets.js +0 -9
- package/dist/server/utils.d.ts +0 -33
- package/dist/server/utils.d.ts.map +0 -1
- package/dist/server/utils.js +0 -17
- package/dist/server/version.d.ts +0 -7
- package/dist/server/version.d.ts.map +0 -1
- package/dist/server/version.js +0 -9
- package/dist/server/vite-dev-api-plugin.d.ts +0 -4
- package/dist/server/vite-dev-api-plugin.d.ts.map +0 -1
- package/dist/server/vite-dev-api-plugin.js +0 -30
- package/dist/web/apple-touch-icon.png +0 -0
- package/dist/web/assets/AnimatePresence-C5p0yiY1.js +0 -9
- package/dist/web/assets/ChatTab-BCobuZDc.js +0 -18
- package/dist/web/assets/ConnectionSettingsTab-BjGkLwVu.js +0 -1
- package/dist/web/assets/ElicitationTab-D3ZUKHND.js +0 -1
- package/dist/web/assets/FormContext-DH2caWKO.js +0 -1
- package/dist/web/assets/ListTabHeader-R17w_JsB.js +0 -1
- package/dist/web/assets/ManufactOAuthCallback-CS3ydSZg.js +0 -1
- package/dist/web/assets/MarkdownRenderer-BeeBfQhv.js +0 -47
- package/dist/web/assets/NotificationsTab-Uj0_DrmK.js +0 -1
- package/dist/web/assets/OAuthCallback-C0ljgCiw.js +0 -1
- package/dist/web/assets/PromptsTab-Bns2u0G-.js +0 -15
- package/dist/web/assets/ResourcesTab-CO24312V.js +0 -2
- package/dist/web/assets/SamplingTab-7gtN7FwU.js +0 -1
- package/dist/web/assets/ServerMetadataTab-CQwqYSjL.js +0 -1
- package/dist/web/assets/ToolsTab-bDdRxI1b.js +0 -8
- package/dist/web/assets/ViewPreview-Ba1Ec5uA.js +0 -1
- package/dist/web/assets/WidgetWrapper-CYHfzrtb.js +0 -34
- package/dist/web/assets/brush--0LobUi4.js +0 -1
- package/dist/web/assets/checkbox-CzBkaNKa.js +0 -1
- package/dist/web/assets/code-tME-5H6D.js +0 -1
- package/dist/web/assets/createLucideIcon-B3b8EU0b.js +0 -1
- package/dist/web/assets/dist-C5JjLJN9.js +0 -21
- package/dist/web/assets/index-TQ5V7cM9.js +0 -492
- package/dist/web/assets/index-fBX3akc8.css +0 -1
- package/dist/web/assets/input-CLYhA7PK.js +0 -1
- package/dist/web/assets/inspector-settings-layout-yjKRJDai.js +0 -1
- package/dist/web/assets/jsx-runtime-Cjj9sGSy.js +0 -1
- package/dist/web/assets/label-Cdim77Jw.js +0 -1
- package/dist/web/assets/maximize-2-BTT9QQU9.js +0 -1
- package/dist/web/assets/maximize-_O55kFcr.js +0 -1
- package/dist/web/assets/react-CU_d2d5K.js +0 -1
- package/dist/web/assets/refresh-cw-C9wQl8_d.js +0 -1
- package/dist/web/assets/save-B-MsgxX9.js +0 -1
- package/dist/web/assets/schemaHelpers-DLNTQr_6.js +0 -1
- package/dist/web/assets/select-CJ57-Bor.js +0 -1
- package/dist/web/assets/shared-BF0rJNdE.js +0 -1
- package/dist/web/assets/sparkles-2OAsc1aP.js +0 -1
- package/dist/web/assets/tabs-subtle-6D79T1xd.js +0 -1
- package/dist/web/assets/textarea-DLAmNVf_.js +0 -1
- package/dist/web/assets/useConfig-BAgALiZg.js +0 -1
- package/dist/web/assets/useViewHostProps-BYitt_6K.js +0 -1
- package/dist/web/assets/zap-Du2Uc5pa.js +0 -1
- package/dist/web/favicon-96x96.png +0 -0
- package/dist/web/favicon-black.svg +0 -5
- package/dist/web/favicon-white.svg +0 -5
- package/dist/web/favicon.ico +0 -0
- package/dist/web/favicon.svg +0 -5
- package/dist/web/index.html +0 -89
- package/dist/web/providers/anthropic.png +0 -0
- package/dist/web/providers/google.png +0 -0
- package/dist/web/providers/openai.png +0 -0
- package/dist/web/site.webmanifest +0 -21
- package/dist/web/web-app-manifest-192x192.png +0 -0
- package/dist/web/web-app-manifest-512x512.png +0 -0
- /package/dist/{cdn → app}/apple-touch-icon.png +0 -0
- /package/dist/{cdn → app}/favicon-96x96.png +0 -0
- /package/dist/{cdn → app}/favicon-black.svg +0 -0
- /package/dist/{cdn → app}/favicon-white.svg +0 -0
- /package/dist/{cdn → app}/favicon.ico +0 -0
- /package/dist/{cdn → app}/favicon.svg +0 -0
- /package/dist/{cdn → app}/site.webmanifest +0 -0
- /package/dist/{cdn → app}/web-app-manifest-192x192.png +0 -0
- /package/dist/{cdn → app}/web-app-manifest-512x512.png +0 -0
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react-CU_d2d5K.js";import{Cr as n,Dr as r,En as i,G as a,Ir as o,Lr as s,Mn as c,Nn as l,Nr as u,Sr as d,Tn as f,Yn as p,_r as m,a as h,an as g,br as _,c as v,d as y,dr as b,f as x,fr as S,gr as C,in as w,kn as T,mn as E,mr as D,n as O,on as k,or as A,pn as j,pr as M,r as N,s as P,sr as F,t as ee,u as te,wr as I,xr as L}from"./input-CLYhA7PK.js";import{t as R}from"./jsx-runtime-Cjj9sGSy.js";import{n as z,t as B}from"./label-Cdim77Jw.js";import{m as V,t as ne}from"./AnimatePresence-C5p0yiY1.js";import{a as H,c as re,i as U,n as ie,o as W,p as G,r as ae,s as oe,t as K}from"./select-CJ57-Bor.js";import{a as q,c as J,i as se,l as ce,n as le,o as ue,r as Y,s as de,t as fe}from"./FormContext-DH2caWKO.js";import{t as pe}from"./createLucideIcon-B3b8EU0b.js";import{t as me}from"./refresh-cw-C9wQl8_d.js";import{A as he,At as ge,B as _e,Bt as ve,C as ye,D as be,Dt as xe,E as Se,F as Ce,G as we,H as Te,Ht as Ee,I as De,Kt as Oe,N as ke,O as Ae,P as je,Pt as Me,R as Ne,S as Pe,T as Fe,U as Ie,Ut as Le,V as Re,Vt as ze,Wt as Be,Zt as Ve,a as He,an as Ue,b as We,bn as Ge,c as Ke,cn as qe,d as Je,dn as Ye,et as X,f as Xe,fn as Ze,g as Qe,gt as $e,hn as et,i as tt,in as nt,l as Z,mn as rt,n as it,o as at,ot,p as st,pn as ct,qt as lt,r as ut,rn as dt,s as ft,sn as pt,u as mt,v as ht,vn as gt,vt as _t,wt as vt,x as yt,xn as bt,xt,y as St,yt as Ct,zt as wt}from"./index-TQ5V7cM9.js";import{a as Tt,c as Et,i as Dt,n as Ot,o as kt,r as At,s as jt}from"./dist-C5JjLJN9.js";import{n as Mt,t as Nt}from"./MarkdownRenderer-BeeBfQhv.js";import{a as Pt,i as Ft,n as It,t as Lt}from"./tabs-subtle-6D79T1xd.js";import{a as Rt,c as zt,i as Bt,l as Vt,n as Ht,o as Ut,r as Wt,s as Gt,t as Kt}from"./useConfig-BAgALiZg.js";import{t as qt}from"./textarea-DLAmNVf_.js";import{t as Jt}from"./checkbox-CzBkaNKa.js";import{n as Yt,t as Xt}from"./schemaHelpers-DLNTQr_6.js";import{t as Zt}from"./useViewHostProps-BYitt_6K.js";var Qt=pe(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),$t=pe(`arrow-left-from-line`,[[`path`,{d:`m9 6-6 6 6 6`,key:`7v63n9`}],[`path`,{d:`M3 12h14`,key:`13k4hi`}],[`path`,{d:`M21 19V5`,key:`b4bplr`}]]),en=pe(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),tn=pe(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),nn=pe(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),rn=pe(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),an=pe(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Q=e(t(),1),$=R(),on=Q.forwardRef(({className:e,children:t,...n},r)=>(0,$.jsx)(`div`,{ref:r,"data-slot":`scroll-area`,className:s(`relative overflow-hidden`,e),...n,children:(0,$.jsx)(`div`,{"data-slot":`scroll-area-viewport`,className:`h-full w-full overflow-y-auto overflow-x-hidden`,children:t})}));on.displayName=`ScrollArea`;function sn({count:e}){return(0,$.jsx)(`div`,{className:`flex flex-row absolute top-0 right-0 z-10 w-full items-center justify-between gap-2 ${te}`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-full`,children:[(0,$.jsx)(`h2`,{className:y,children:`Chat History`}),(0,$.jsx)(u,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:e})]})})}function cn({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`skeleton`,className:s(`animate-pulse rounded-md bg-muted`,e),...t})}var ln=`New Chat`,un=`Chat`;function dn(e){return e===`New Chat`||e===`Chat`}var fn=`Generate a concise title (maximum 60 characters) for this chat based on the user's first message. Name the subject matter, task, or question — not the act of chatting. Never output meta phrases (e.g. do not use: greeting, introduction, initiation, conversation start, chat session). If there is no specific topic yet, reply with exactly: Chat. Return only the title, no quotes or extra text.`,pn=[`greeting`,`initiation`,`conversation start`,`introduction to`,`chat session`,`starting a chat`,`beginning of`];function mn(e){return typeof e.content==`string`?e.content.trim():String(e.content??``).trim()}function hn(e){for(let t of e){if(t.role!==`user`)continue;let e=mn(t);if(e)return e}return null}function gn(e){let t=e.toLowerCase();for(let e of pn)if(t.includes(e))return!0;return!1}function _n(e){let t=e.trim().split(/\r?\n/)[0].trim();if(!t)return!0;if(t.length>48)return!1;let n=t.replace(/\s+/g,` `).toLowerCase();return/^(hi|hello|hey|greetings?)[!.]?$/i.test(n)||/^(good morning|good afternoon|good evening)[!.]?$/i.test(n)||/^(hi|hello|hey)\s+(there|all|team|everyone)[!.]?$/i.test(n)}function vn(e){return e.length>60?`${e.substring(0,57)}...`:e}function yn(e){return e?.model?.trim()?e.provider===`ollama`?!0:!!e.apiKey?.trim():!1}async function bn(e,t,n){let r=t.trim();if(!r||!yn(e))return null;if(_n(r))return vn(r);try{let t=(await Tt({config:Et(e.provider,e.model,{apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl,maxTokens:128}),messages:[{role:`system`,content:fn},{role:`user`,content:r}],signal:n})).trim();if(!t)return null;let i=vn(t);return i===`Chat`||gn(i)?vn(r):i}catch{return null}}var xn=28,Sn=3,Cn=.72;function wn({chatId:e,title:t,className:n,onRevealComplete:r}){let[i,a]=(0,Q.useState)(t),[o,c]=(0,Q.useState)(0),[l,u]=(0,Q.useState)(1),d=(0,Q.useRef)(t),f=(0,Q.useRef)(null),p=(0,Q.useRef)(e);return(0,Q.useEffect)(()=>{if(p.current!==e){p.current=e,d.current=t,f.current=null,a(t),c(0),u(1);return}},[e,t]),(0,Q.useEffect)(()=>{let n=`${e}:${t}`;if(f.current===n){a(t),c(0),u(1);return}let i=d.current,o=dn(i)&&!dn(t)&&t!==i;if(d.current=t,!o){a(t),c(0),u(1);return}f.current=n;let s=0,l=t.length;a(``),c(Sn),u(Cn);let p,m=()=>{s+=1;let e=l>0?s/l:1;a(t.slice(0,s)),c(Sn*(1-e)),u(Cn+(1-Cn)*e),s<l?p=setTimeout(m,xn):r?.()};return p=setTimeout(m,xn),()=>{p&&clearTimeout(p)}},[e,t,r]),(0,$.jsx)(`span`,{className:s(`block truncate transition-[filter,opacity] duration-75`,n),style:{filter:o>0?`blur(${o}px)`:void 0,opacity:l},children:i})}function Tn({compact:e,hideAgentName:t}){return(0,$.jsxs)(`div`,{className:s(`flex items-center justify-between py-3 gap-2`,e?`px-4`:`px-3 rounded-lg`),children:[(0,$.jsxs)(`div`,{className:s(`flex-1 min-w-0 flex flex-col gap-1`,t?`gap-1.5`:`gap-1`),children:[(0,$.jsx)(cn,{className:`h-4 w-3/4`}),!t&&(0,$.jsx)(cn,{className:`h-3 w-1/2`})]}),(0,$.jsx)(cn,{className:`h-3 w-14 shrink-0`})]})}function En({chats:e,onDelete:t,onSelect:n,compact:r,hideAgentName:i,isLoading:o,currentChatId:c}){let[l,u]=Q.useState(``),d=e.filter(e=>e.type!==`agent_execution`),f=d.filter(e=>(e.title??``).toLowerCase().includes(l.toLowerCase())),p=e=>{let t=new Date(e),n=new Date;if(t.toDateString()===n.toDateString())return t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});let r=new Date(n);if(r.setDate(r.getDate()-1),t.toDateString()===r.toDateString())return`Yesterday`;let i=n.getTime()-t.getTime(),a=Math.floor(i/(1e3*60*60*24));return a<7?`${a} days ago`:t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})},m=e=>(0,$.jsxs)(`div`,{className:s(`flex items-center justify-between py-3 hover:bg-muted/50 transition-colors gap-2 cursor-pointer`,r?`px-4`:`px-3 rounded-lg`,c===e.id&&`bg-muted/50`),children:[(0,$.jsxs)(`div`,{className:s(`flex-1 min-w-0 flex overflow-hidden`,i?`flex-col`:`flex-col gap-1`),children:[(0,$.jsx)(`p`,{className:`text-sm font-medium truncate w-full`,children:(0,$.jsx)(wn,{chatId:e.id,title:e.title},`${e.id}:${e.title}`)}),!i&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground truncate w-full`,children:e.agent_name})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:p(e.updated_at)})})]});return(0,$.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[(0,$.jsx)(`div`,{className:`mb-4 px-3 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(a,{className:`absolute left-3 top-2.5 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(ee,{placeholder:`Search chats...`,value:l,onChange:e=>u(e.target.value),className:`pl-9 h-8 border-gray-300 dark:border-zinc-600`})]})}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:o&&d.length===0?(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(Tn,{compact:r,hideAgentName:i}),(0,$.jsx)(Tn,{compact:r,hideAgentName:i}),(0,$.jsx)(Tn,{compact:r,hideAgentName:i})]}):d.length===0?(0,$.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center min-h-[12rem]`,children:(0,$.jsx)(ve,{vertical:!0,noBorder:!0,message:`No chats`,className:`mt-0`})}):f.length===0?null:(0,$.jsx)(`div`,{className:`space-y-1`,children:f.map(e=>n?(0,$.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),className:`block w-full text-left group cursor-pointer`,children:m(e)},e.id):(0,$.jsx)(`div`,{className:`block group cursor-pointer`,children:m(e)},e.id))})})]})}var Dn=20;function On({provider:e,enabled:t=!0,agentId:n,refetchKey:r,refetchInterval:i=!1}){let[a,o]=(0,Q.useState)(1),[s,c]=(0,Q.useState)([]),[l,u]=(0,Q.useState)(0),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),h=(0,Q.useRef)(void 0),g=(0,Q.useCallback)(async()=>{if(t){f(!0),m(null);try{let t=await e.listChats({...n?{agentId:n}:{},take:Dn*a,skip:0});c(t.items),u(t.total)}catch(e){m(e instanceof Error?e:Error(String(e)))}finally{f(!1)}}},[e,t,n,a]);(0,Q.useEffect)(()=>{t&&o(1)},[t]),(0,Q.useEffect)(()=>{g()},[g]),(0,Q.useEffect)(()=>{r!==void 0&&r!==h.current&&(h.current=r,t&&g())},[r,t,g]),(0,Q.useEffect)(()=>{if(!t||!i)return;let e=setInterval(()=>void g(),i);return()=>clearInterval(e)},[t,i,g]);let _=l>s.length;return{chats:s,total:l,isLoading:d,error:p,hasNextPage:_,loadMore:(0,Q.useCallback)(()=>{_&&!d&&o(e=>e+1)},[_,d]),refetch:(0,Q.useCallback)(()=>{g()},[g]),deleteChat:(0,Q.useCallback)(async t=>{await e.deleteChat(t),await g()},[e,g])}}function kn({provider:e,open:t,onOpenChange:n,currentChatId:r,container:i,agentId:a,agentDisplayNameFallback:o,onSelectChat:c,variant:l=`drawer`,containerClassName:u,refetchKey:d,refetchInterval:f=!1,onCurrentChatDeleted:p,onDeleteSuccess:m,onDeleteError:h}){let g=(0,Q.useRef)(null),_=(0,Q.useRef)(null),{chats:v,isLoading:y,hasNextPage:b,loadMore:x,deleteChat:S}=On({provider:e,enabled:t,agentId:a,refetchKey:d,refetchInterval:o?f||3e3:f});(0,Q.useEffect)(()=>{if(!t||!_.current)return;let e=new IntersectionObserver(e=>{e[0]?.isIntersecting&&x()},{threshold:.5});return e.observe(_.current),()=>{e.disconnect()}},[t,b,y,x]);let C=async e=>{try{await S(e),m?.(),e===r&&p?.()}catch(e){console.error(`Failed to delete chat:`,e),h?.(e)}},w=v.map(e=>({...e,title:e.title||`New Chat`,agent_name:e.agent_name??o??`Unknown Agent`})),T=w.filter(e=>e.type!==`agent_execution`).length,E=(0,$.jsx)(En,{chats:w,onDelete:C,compact:l===`inline`,hideAgentName:!!o,isLoading:y&&v.length===0,currentChatId:r,onSelect:c?e=>{c(e),n(!1)}:void 0}),D=(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[(0,$.jsx)(sn,{count:T}),(0,$.jsxs)(on,{ref:g,className:s(`min-h-0 flex-1 w-full pt-14 sm:pt-16 [&_[data-slot=scroll-area-viewport]]:block!`,l===`inline`?`p-0`:`px-3 sm:px-5`),children:[E,b&&(0,$.jsx)(`div`,{ref:_,className:`py-4 flex items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(nt,{className:`h-4 w-4 animate-spin`}),`Loading more...`]})})]})]});return l===`inline`?(0,$.jsx)(`div`,{className:s(`flex h-full min-h-0 flex-col`,u),children:D}):(0,$.jsx)(Ke,{open:t,onOpenChange:n,children:(0,$.jsx)(Z,{side:`left`,className:`w-[400px] sm:w-[400px] border-zinc-200 p-0 dark:border-zinc-700`,container:i,children:D})})}function An({onCollapse:e}){return(0,$.jsxs)(O,{children:[(0,$.jsx)(h,{render:(0,$.jsxs)(F,{type:`button`,variant:`ghost`,size:`icon-sm`,tabIndex:-1,"aria-label":`Collapse`,onClick:e,className:`border-border absolute top-1/2 right-0 z-30 size-7 min-h-7 min-w-7 -translate-y-1/2 translate-x-1/2 rounded-full border bg-background`,children:[(0,$.jsx)($t,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Collapse`})]}),nativeButton:!0}),(0,$.jsx)(N,{side:`right`,children:`Collapse`})]})}var jn=`mcp-inspector-chats`,Mn=`New Chat`,Nn=40;function Pn(){try{let e=localStorage.getItem(jn);if(!e)return{sessions:[],messages:{}};let t=JSON.parse(e);return{sessions:Array.isArray(t.sessions)?t.sessions:[],messages:t.messages&&typeof t.messages==`object`?t.messages:{}}}catch{return{sessions:[],messages:{}}}}function Fn(e){localStorage.setItem(jn,JSON.stringify(e))}function In(){return new Date().toISOString()}function Ln(e){let t=e.find(e=>e.role===`user`);if(!t)return;let n=typeof t.content==`string`?t.content.trim():String(t.content??``).trim();if(n)return n.length>Nn?`${n.slice(0,Nn)}…`:n}var Rn=class{saveTimers=new Map;async listChats(e){let{sessions:t}=Pn(),n=t;e.agentId&&(n=t.filter(t=>t.agent_id===e.agentId)),n=[...n].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime());let r=n.length,i=e.skip??0,a=e.take??r;return{items:n.slice(i,i+a),total:r}}async getMessages(e){let{messages:t}=Pn();return t[e]??[]}async createChat(e){let t=Pn(),n=In(),r={id:crypto.randomUUID(),title:e.title??Mn,agent_id:e.agentId,agent_name:e.agentName??`MCP Server`,created_at:n,updated_at:n};return t.sessions.push(r),t.messages[r.id]=[],Fn(t),r}async updateChat(e,t){let n=Pn(),r=n.sessions.findIndex(t=>t.id===e);if(r===-1)throw Error(`Chat not found: ${e}`);let i=n.sessions[r];return t.title!==void 0&&(i.title=t.title),i.updated_at=In(),n.sessions[r]=i,Fn(n),i}async deleteChat(e){let t=Pn();t.sessions=t.sessions.filter(t=>t.id!==e),delete t.messages[e],Fn(t)}async saveMessages(e,t){let n=this.saveTimers.get(e);n&&clearTimeout(n),await new Promise(n=>{let r=setTimeout(()=>{this.saveTimers.delete(e);let r=Pn();r.messages[e]=t;let i=r.sessions.findIndex(t=>t.id===e);if(i!==-1){let e=r.sessions[i];if(e.updated_at=In(),e.title===Mn){let n=Ln(t);n&&(e.title=n)}r.sessions[i]=e}Fn(r),n()},500);this.saveTimers.set(e,r)})}};function zn({activeChatId:e,storage:t,messages:n,isLoading:r,effectiveClientSide:i,llmConfig:a,activeChatTitle:o,titleGenerationReady:s=!0,onTitleGenerated:c,onHistoryRefetch:l}){let u=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{u.current=null},[e]),(0,Q.useEffect)(()=>{if(!e||!t||r||!s||o&&!dn(o))return;let d=hn(n);if(!d)return;let f=`${e}:${d}`;if(u.current===f)return;u.current=f;let p=!1;return(async()=>{let n=null;if(t.generateTitle?n=await t.generateTitle(e):i&&a&&(n=await bn(a,d),n&&await t.updateChat(e,{title:n})),!p){if(!n||n===`New Chat`){u.current=null;return}l?.(),c?.(e,n)}})().catch(()=>{p||(u.current=null)}),()=>{p=!0}},[e,t,n,r,i,a,o,s,c,l])}var Bn=[`#e0eaff`,`#f9ffbd`,`#dedede`,`#ffffff`],Vn=.54;function Hn({className:e,children:t,shaderPhase:n=`hidden`,onShaderFadeComplete:r,meshAnimationPaused:i=!1,...a}){let o=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=window.requestAnimationFrame(()=>l(!0));return()=>window.cancelAnimationFrame(e)},[]),(0,Q.useEffect)(()=>{n===`fading`&&!c&&r?.()},[n,c,r]);let u=n!==`hidden`,d=n===`visible`&&c,f=e=>{e.propertyName===`opacity`&&n===`fading`&&r?.()};return(0,$.jsxs)(`div`,{ref:o,className:s(`relative flex min-h-0 flex-1 flex-col overflow-hidden bg-white dark:bg-black`,e),...a,children:[u&&(0,$.jsxs)(`div`,{className:s(`pointer-events-none absolute inset-x-0 bottom-0 z-0 transition-opacity duration-500`,d?`opacity-100`:`opacity-0`),style:{height:`${Vn*100}%`},"aria-hidden":!0,onTransitionEnd:f,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-[#edf2ff] dark:bg-[#1e293b]`}),(0,$.jsx)(`div`,{className:s(`absolute inset-0`,c?`opacity-75 dark:opacity-45`:`opacity-0`),children:(0,$.jsx)(wt,{className:`absolute inset-0 h-full w-full`,colors:[...Bn],distortion:.8,swirl:.1,grainMixer:0,grainOverlay:.3,speed:+!i})}),(0,$.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-white/0 from-[12%] via-white/60 via-[38%] to-white dark:from-black/0 dark:from-[12%] dark:via-black/60 dark:via-[38%] dark:to-black`})]}),(0,$.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col`,children:t})]})}function Un(e){return e?e.apiKey===`server-managed`||e.baseUrl?.includes(`/inspector/llm`)===!0:!1}function Wn(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes(`failed to fetch`)||t.includes(`networkerror`)||t.includes(`network request failed`)||t.includes(`load failed`)}function Gn(e,t){if(!t)return e>=502&&e<=504?{kind:`cloud_unavailable`}:null;if(e===402)return{kind:`credits_exhausted`,billingUrl:typeof t.upgradeUrl==`string`?t.upgradeUrl:typeof t.billingUrl==`string`?t.billingUrl:void 0,message:typeof t.message==`string`?t.message:`You've used your included free plan credits.`};if(e===429){if(t.loginRequired&&t.loginUrl)return{kind:`login_required`,loginUrl:String(t.loginUrl)};if(t.creditsExhausted)return{kind:`credits_exhausted`,billingUrl:typeof t.billingUrl==`string`?t.billingUrl:void 0,message:typeof t.message==`string`?t.message:`You've used your included free plan credits.`};if(t.error===`free_org_rate_limited`||typeof t.reason==`string`)return{kind:`credits_exhausted`,message:typeof t.message==`string`?t.message:`You've reached your included chat quota for this workspace.`}}return e>=502&&e<=504?{kind:`cloud_unavailable`}:null}function Kn(e){let t=e.match(/^OpenAI request failed \((\d+) /);if(!t)return null;let n=Number(t[1]),r=e.indexOf(`{`);if(r===-1)return null;try{let t=JSON.parse(e.slice(r));if(t&&typeof t==`object`&&!Array.isArray(t))return{status:n,body:t}}catch{}return null}function qn(e){if(e instanceof Error&&e.name===`LlmRequestError`){let t=e.status??0,n=e.body;return Gn(t,n&&typeof n==`object`&&!Array.isArray(n)?n:void 0)}if(e instanceof Error){let t=Kn(e.message);if(t)return Gn(t.status,t.body)}return Wn(e)?{kind:`cloud_unavailable`}:null}function Jn(e,t){return Gn(e,t)}var Yn=Q.createContext(null);function Xn(){let e=Q.useContext(Yn);if(!e)throw Error(`Command components must be used within <Command>`);return e}function Zn(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}var Qn=Q.forwardRef(({className:e,...t},n)=>{let[r,i]=Q.useState(``),[a,o]=Q.useState(null),[c,l]=Q.useState(0),u=Q.useCallback(()=>(l(e=>e+1),()=>l(e=>Math.max(0,e-1))),[]);return(0,$.jsx)(Yn.Provider,{value:{search:r,setSearch:i,activeValue:a,setActiveValue:o,visibleCount:c,registerVisible:u},children:(0,$.jsx)(`div`,{ref:n,className:s(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})})});Qn.displayName=`Command`;var $n=Q.forwardRef(({className:e,...t},n)=>{let{search:r,setSearch:i}=Xn();return(0,$.jsx)(`div`,{className:`flex items-center border-b px-3`,children:(0,$.jsx)(`input`,{ref:n,value:r,onChange:e=>i(e.target.value),className:s(`flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})})});$n.displayName=`CommandInput`;var er=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:s(`max-h-[300px] overflow-y-auto overflow-x-hidden`,e),...t}));er.displayName=`CommandList`;var tr=Q.forwardRef(({className:e,...t},n)=>{let{visibleCount:r}=Xn();return r>0?null:(0,$.jsx)(`div`,{ref:n,className:s(`py-6 text-center text-sm`,e),...t})});tr.displayName=`CommandEmpty`;var nr=Q.forwardRef(({className:e,heading:t,children:n,...r},i)=>(0,$.jsxs)(`div`,{ref:i,className:s(`overflow-hidden p-1 text-foreground [&_[data-command-group-heading]]:px-2 [&_[data-command-group-heading]]:py-1.5 [&_[data-command-group-heading]]:text-xs [&_[data-command-group-heading]]:font-medium [&_[data-command-group-heading]]:text-muted-foreground`,e),...r,children:[t?(0,$.jsx)(`div`,{"data-command-group-heading":``,children:t}):null,n]}));nr.displayName=`CommandGroup`;var rr=Q.forwardRef(({className:e,value:t,keywords:n,onSelect:r,disabled:i,onClick:a,...o},c)=>{let{search:l,activeValue:u,setActiveValue:d,registerVisible:f}=Xn(),p=Array.isArray(n)?n.join(` `):n,m=Zn(p?`${t} ${p}`:t,l),h=u===t;return Q.useLayoutEffect(()=>{if(m)return f()},[m,f]),Q.useEffect(()=>{m&&u===null&&!i&&d(t)},[m,u,i,d,t]),m?(0,$.jsx)(`div`,{ref:c,role:`option`,"aria-selected":h,"data-selected":h,"data-disabled":i,className:s(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50`,e),onMouseEnter:()=>!i&&d(t),onClick:e=>{a?.(e),i||r?.(t)},...o}):null});rr.displayName=`CommandItem`;var ir=`mcp-inspector-models-cache`,ar=1440*60*1e3;function or(){try{let e=localStorage.getItem(ir);if(e)return JSON.parse(e)}catch(e){console.error(`Failed to load models cache:`,e)}return{}}function sr(e,t){try{let n=or();n[e]={models:t,timestamp:Date.now()},localStorage.setItem(ir,JSON.stringify(n))}catch(e){console.error(`Failed to save models cache:`,e)}}function cr(e){try{let t=or(),n=t[e];if(n){if(Date.now()-n.timestamp<ar)return n.models;delete t[e],localStorage.setItem(ir,JSON.stringify(t))}}catch(e){console.error(`Failed to get cached models:`,e)}return null}function lr(e,t){return!Vt(e)||!t?.trim()?e:`${e}:${e===`ollama`?jt(t):t.trim().toLowerCase()}`}var ur=`chat-config-source`;function dr(e){return e===`openai`||e===`anthropic`||e===`google`?e:`openrouter`}async function fr(e,t){let n={};t&&(n.Authorization=`Bearer ${t}`);let r;try{r=await fetch(`${e}/models`,{headers:n})}catch{throw Error(`Failed to reach the server. Check the URL is correct and that CORS is enabled on the server.`)}if(!r.ok)throw Error(`Failed to fetch models: ${r.statusText}`);if(!(r.headers.get(`content-type`)??``).includes(`application/json`))throw Error(`Invalid URL — response was not JSON`);let i=await r.json();if(!Array.isArray(i?.data))throw Error(`Unexpected response format — expected { data: [...] } from the OpenAI-compatible endpoint`);return i.data.map(e=>({id:e.id}))}async function pr(e){let t=await fetch(`https://api.openai.com/v1/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`Failed to fetch OpenAI models: ${t.statusText}`);return(await t.json()).data.map(e=>({id:e.id}))}async function mr(e){let t=await fetch(`https://api.anthropic.com/v1/models`,{headers:{"x-api-key":e,"anthropic-version":`2023-06-01`,"anthropic-dangerous-direct-browser-access":`true`}});if(!t.ok)throw Error(`Failed to fetch Anthropic models: ${t.statusText}`);return(await t.json()).data.map(e=>({id:e.id,displayName:e.display_name}))}async function hr(e){let t=await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${e}`);if(!t.ok)throw Error(`Failed to fetch Google models: ${t.statusText}`);return((await t.json()).models||[]).map(e=>({id:e.name,displayName:e.displayName}))}async function gr(e){let t=await fetch(`https://openrouter.ai/api/v1/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`Failed to fetch OpenRouter models: ${t.statusText}`);return(await t.json()).data.map(e=>({id:e.id,displayName:e.name}))}async function _r(e,t){let n;try{n=await fetch(Dt(e,`/api/tags`),{headers:{...t.trim()?{Authorization:`Bearer ${t.trim()}`}:{}}})}catch(e){throw new At(e)}if(!n.ok)throw Error(`Failed to fetch Ollama models: ${n.statusText}`);return((await n.json()).models||[]).map(e=>({id:e.model||e.name||``}))}function vr({open:e,onOpenChange:t,tempProvider:n,tempModel:r,tempApiKey:i,tempBaseUrl:a,onProviderChange:o,onModelChange:c,onApiKeyChange:l,onBaseUrlChange:u,onSave:d,onClear:f,showClearButton:p=!1,buttonLabel:m=`Configure API Key`,hostedInspector:h=!1,freeTierInfo:g,managedCloudInfo:_,useManagedCloud:v=!1,onSaveManagedCloud:y}){let[b,x]=(0,Q.useState)([]),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(+!v),P=lr(n,a),te=!!(h||g||_),I=!!(_&&M===0);(0,Q.useEffect)(()=>{e&&N(+!v)},[e,v]),(0,Q.useEffect)(()=>{let t=zt(n),r=Vt(n);if(I||!e||!n||t&&!i.trim()||r&&!a.trim()){x([]),T(null);return}let o=setTimeout(async()=>{let e=cr(P);if(e){x(e),T(null);return}C(!0),T(null);try{let e=[];n===`openai-compatible`?e=await fr(a,i):n===`openai`?e=await pr(i):n===`anthropic`?e=await mr(i):n===`google`?e=await hr(i):n===`openrouter`?e=await gr(i):n===`ollama`&&(e=await _r(a,i)),sr(P,e),x(e)}catch(e){T(e instanceof Error?e.message:`Failed to fetch models. Please check your API key.`),x([])}finally{C(!1)}},500);return()=>clearTimeout(o)},[i,a,n,e,P,I]);let L=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!e||I){e||(L.current=null);return}let t=L.current;t!==null&&t!==n&&c(``),L.current=n},[n,e,c,I]);let R=Vt(n),z=!zt(n),V=e&&(!zt(n)||!!i.trim())&&(!R||!!a.trim()),ne=z?`API Key (optional)`:`API Key`,re=z?n===`ollama`?`Leave empty for local Ollama`:`Enter your API key (optional)`:`Enter your API key`,W=n===`openai-compatible`?`http://localhost:11434/v1`:Gt(n),G=n===`openai-compatible`?`Base URL of your OpenAI-compatible API. Local servers must have CORS enabled.`:null,oe=n===`ollama`?`Optional for local Ollama. Stored locally and never sent to our servers.`:`Your API key is stored locally and never sent to our servers.`,q=_?_.models.reduce((e,t)=>(e[t.provider]||(e[t.provider]=[]),e[t.provider].push(t),e),{}):{},J=_?.models.find(e=>e.id===_.selectedModelId),se=Object.keys(q),ce=J?.provider??se[0]??``,le=ce?q[ce]??[]:[],ue=!!f&&p&&(!_||M===1),Y=()=>{if(I&&y){y();return}d()},de=I?!!(_?.isLoading||!_?.selectedModelId||_?.models.length===0):zt(n)&&!i.trim()||R&&!a.trim()||!r.trim();return(0,$.jsx)(Ne,{open:e,onOpenChange:t,children:(0,$.jsxs)(_e,{className:`max-w-md`,"data-testid":`chat-config-dialog`,children:[(0,$.jsxs)(Ie,{children:[(0,$.jsx)(we,{children:te?`Configure Chat`:`LLM Provider Configuration`}),(0,$.jsx)(Re,{children:_?`Pick a Manufact cloud model or bring your own API key.`:g?`Chat requires an LLM. You can chat for free if you have a Manufact account, or you can use your own API key (not sent to Manufact).`:`Configure your LLM provider and API key to start chatting with the MCP server`})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[g&&(0,$.jsxs)(`button`,{type:`button`,onClick:g.onLoginClick,"data-testid":`chat-config-sign-in-card`,className:`relative w-full cursor-pointer overflow-hidden rounded-2xl text-left transition-opacity hover:opacity-95 active:opacity-90`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-[#edf2ff]`,"aria-hidden":!0}),(0,$.jsx)(wt,{className:`absolute inset-0 h-full w-full`,grainOverlay:.15}),(0,$.jsxs)(`div`,{className:`relative flex items-center justify-between gap-4 px-4 py-3.5`,children:[(0,$.jsxs)(`div`,{className:`text-sm font-medium text-black`,children:[(0,$.jsx)(`p`,{children:`Chat for free with a`}),(0,$.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5`,children:[(0,$.jsx)(ut,{symbolSize:14,textClassName:`text-sm`}),`account`]})]}),(0,$.jsx)(F,{size:`sm`,render:(0,$.jsx)(`span`,{"aria-hidden":`true`}),nativeButton:!1,tabIndex:-1,className:`pointer-events-none shrink-0`,children:`Sign in`})]})]}),_&&(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsxs)(Lt,{selectedIndex:M,onSelect:N,idPrefix:ur,className:`w-fit`,children:[(0,$.jsx)(It,{index:0,label:`Manufact cloud`}),(0,$.jsx)(It,{index:1,label:`API key`})]})}),(0,$.jsxs)(`div`,{className:s(`space-y-2`,_&&`!mt-2`),children:[(0,$.jsx)(B,{children:`Provider`}),I?(0,$.jsxs)(K,{value:ce,onValueChange:e=>{let t=_?.models.find(t=>t.provider===e);t&&_?.onModelChange(t.id)},children:[(0,$.jsx)(U,{className:`rounded-md`,leading:ce?(0,$.jsx)(He,{provider:dr(ce),className:`shrink-0`}):void 0,children:(0,$.jsx)(H,{})}),(0,$.jsx)(ie,{children:se.map(e=>(0,$.jsx)(ae,{value:e,label:ft(dr(e)),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(He,{provider:dr(e)}),(0,$.jsx)(`span`,{children:ft(dr(e))})]})},e))})]}):(0,$.jsxs)(K,{value:n,onValueChange:e=>o(e),children:[(0,$.jsx)(U,{className:`rounded-md`,leading:(0,$.jsx)(He,{provider:n,className:`shrink-0`}),children:(0,$.jsx)(H,{})}),(0,$.jsxs)(ie,{children:[(0,$.jsx)(ae,{value:`openai`,label:ft(`openai`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(He,{provider:`openai`}),(0,$.jsx)(`span`,{children:ft(`openai`)})]})}),(0,$.jsx)(ae,{value:`anthropic`,label:ft(`anthropic`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(He,{provider:`anthropic`}),(0,$.jsx)(`span`,{children:ft(`anthropic`)})]})}),(0,$.jsx)(ae,{value:`google`,label:ft(`google`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(He,{provider:`google`}),(0,$.jsx)(`span`,{children:ft(`google`)})]})}),(0,$.jsx)(ae,{value:`ollama`,label:ft(`ollama`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(He,{provider:`ollama`}),(0,$.jsx)(`span`,{children:ft(`ollama`)})]})}),(0,$.jsx)(ae,{value:`openrouter`,label:ft(`openrouter`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(He,{provider:`openrouter`}),(0,$.jsx)(`span`,{children:ft(`openrouter`)})]})}),(0,$.jsx)(ae,{value:`openai-compatible`,label:ft(`openai-compatible`),children:(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(`span`,{children:ft(`openai-compatible`)})})})]})]})]}),!I&&R&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(B,{children:`Base URL`}),(0,$.jsx)(ee,{value:a,onChange:e=>u(e.target.value),placeholder:W,"data-testid":`chat-config-base-url-input`}),G&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:G})]}),!I&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(B,{children:ne}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(ee,{type:A?`text`:`password`,value:i,onChange:e=>l(e.target.value),placeholder:re,className:`pr-10`,"data-testid":`chat-config-api-key-input`}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent`,onClick:()=>j(!A),children:A?(0,$.jsx)(Ze,{className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Ye,{className:`h-4 w-4 text-muted-foreground`})})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:oe})]}),I?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(B,{children:`Model`}),_?.isLoading?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(nt,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Loading models…`})]}):le.length>0?(0,$.jsxs)(Se,{open:O,modal:!0,onOpenChange:k,children:[(0,$.jsx)(Ae,{render:(0,$.jsxs)(F,{variant:`outline`,role:`combobox`,"aria-expanded":O,className:`w-full justify-between rounded-md`,"data-testid":`chat-config-cloud-model-select`,children:[(0,$.jsx)(`span`,{className:`inline-flex min-w-0 items-center gap-2 truncate`,children:J?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(He,{provider:dr(J.provider),className:`shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:at(J.name,J.provider)})]}):`Select a model…`}),(0,$.jsx)(en,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]}),nativeButton:!0}),(0,$.jsx)(be,{className:`w-full p-0`,align:`start`,children:(0,$.jsxs)(Qn,{children:[(0,$.jsx)($n,{placeholder:`Search models…`,className:`h-9`}),(0,$.jsxs)(er,{children:[(0,$.jsx)(tr,{children:`No model found.`}),(0,$.jsx)(nr,{children:le.map(e=>(0,$.jsxs)(rr,{value:e.id,keywords:[e.name,e.id,e.provider],onSelect:e=>{_?.onModelChange(e),k(!1)},children:[at(e.name,e.provider),(0,$.jsx)(gt,{className:s(`ml-auto h-4 w-4`,_?.selectedModelId===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})]})})]}):(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Cloud models unavailable — try again or use your own key.`})]}):V&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(B,{children:`Model`}),S?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(nt,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Loading models...`})]}):w?(0,$.jsx)(`div`,{className:`text-sm text-destructive`,children:w}):b.length>0?(0,$.jsxs)(Se,{open:E,modal:!0,onOpenChange:D,children:[(0,$.jsx)(Ae,{render:(0,$.jsxs)(F,{variant:`outline`,role:`combobox`,"aria-expanded":E,className:`w-full justify-between rounded-md`,"data-testid":`chat-config-model-select`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:r&&(b.find(e=>e.id===r)?.displayName||b.find(e=>e.id===r)?.id)||`Select a model...`}),(0,$.jsx)(en,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]}),nativeButton:!0}),(0,$.jsx)(be,{className:`w-full p-0`,align:`start`,children:(0,$.jsxs)(Qn,{children:[(0,$.jsx)($n,{placeholder:`Search models...`,className:`h-9`}),(0,$.jsxs)(er,{children:[(0,$.jsx)(tr,{children:`No model found.`}),(0,$.jsx)(nr,{children:b.map(e=>(0,$.jsxs)(rr,{value:e.id,keywords:e.displayName,onSelect:e=>{c(e===r?``:e),D(!1)},children:[e.displayName||e.id,(0,$.jsx)(gt,{className:s(`ml-auto h-4 w-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})]})})]}):(0,$.jsx)(ee,{value:r,onChange:e=>c(e.target.value),placeholder:`Enter model name manually`,"data-testid":`chat-config-model-input`})]}),(0,$.jsxs)(`div`,{className:`flex justify-between`,children:[ue&&(0,$.jsx)(F,{variant:`outline`,onClick:f,children:`Clear Config`}),(0,$.jsxs)(F,{onClick:Y,disabled:de,className:ue?`ml-auto`:``,"data-testid":`chat-config-save-button`,children:[(0,$.jsx)(Ue,{className:`h-4 w-4 mr-2`}),`Save Configuration`]})]})]})]})})}var yr=`rounded-full bg-background/80 backdrop-blur-md supports-[backdrop-filter]:bg-background/60 dark:bg-zinc-950/75 dark:supports-[backdrop-filter]:bg-zinc-950/55`,br=s(yr,`w-fit`),xr=s(yr,`h-9 gap-1.5 px-3`),Sr=`chat-view`;function Cr({llmConfig:e,hasMessages:t,configDialogOpen:n,onConfigDialogOpenChange:r,onClearChat:i,tempProvider:a,tempModel:o,tempApiKey:c,tempBaseUrl:l,onProviderChange:u,onModelChange:d,onApiKeyChange:f,onBaseUrlChange:p,onSaveConfig:m,onClearConfig:g,hideConfigButton:_,hostedInspector:v,freeTierInfo:y,managedCloudInfo:b,useManagedCloud:x,onSaveManagedCloud:S,showClearButton:C,clearButtonLabel:w,hideTitle:T,clearButtonHideIcon:E,clearButtonHideShortcut:D,clearButtonVariant:k,hideClearButton:A,onCopyChat:j,onExportChat:M,activeChatId:P,chatTitle:ee,showViewToggle:I,viewIndex:L=0,onViewIndexChange:R,elevatedHeader:z}){return(0,$.jsxs)(`div`,{className:s(`relative flex w-full items-center gap-2 overflow-visible`,te,z?`pointer-events-none absolute top-0 right-0 z-50`:`absolute top-0 right-0 z-10`),children:[(0,$.jsx)(`div`,{className:s(`flex min-w-0 flex-1 items-center`,z&&`pointer-events-auto`),children:!T&&(0,$.jsx)(`h2`,{className:s(`text-[15px] text-foreground [font-variation-settings:'wght'_550,'opsz'_20]`,br),children:P?(0,$.jsx)(wn,{chatId:P,title:ee??`Chat`},P):`Chat`})}),I&&R&&(0,$.jsx)(`div`,{className:s(`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 overflow-visible px-1`,z&&`pointer-events-auto`),children:(0,$.jsxs)(Lt,{selectedIndex:L,onSelect:R,idPrefix:Sr,className:`shrink-0 overflow-visible`,"data-testid":`chat-view-tabs`,children:[(0,$.jsx)(It,{label:`Conv`,index:0}),(0,$.jsx)(It,{label:`Raw`,index:1})]})}),(0,$.jsxs)(`div`,{className:s(`ml-auto flex shrink-0 items-center gap-2`,z&&`pointer-events-auto`),children:[!A&&t&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[j&&(0,$.jsxs)(F,{"data-testid":`chat-copy-button`,variant:`ghost`,size:`sm`,className:xr,onClick:j,children:[(0,$.jsx)(et,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Copy`})]}),M&&(0,$.jsxs)(ze,{children:[(0,$.jsx)(Be,{render:(0,$.jsxs)(F,{"data-testid":`chat-export-button`,variant:`ghost`,size:`sm`,className:xr,children:[(0,$.jsx)(rt,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Export`})]}),nativeButton:!0}),(0,$.jsxs)(Ee,{align:`end`,children:[(0,$.jsx)(Le,{"data-testid":`chat-export-json`,onClick:()=>M(`json`),children:`Export as JSON`}),(0,$.jsx)(Le,{"data-testid":`chat-export-markdown`,onClick:()=>M(`markdown`),children:`Export as Markdown`})]})]}),(0,$.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,$.jsxs)(O,{children:[(0,$.jsx)(h,{render:(0,$.jsxs)(F,{variant:k??`default`,size:`default`,className:`p-2 cursor-pointer ${D?`sm:px-3`:`sm:pr-1 sm:pl-3`}`,onClick:i,children:[!E&&(0,$.jsx)(an,{className:`h-4 w-4 sm:mr-2`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:w??`New Chat`}),!D&&(0,$.jsx)(`span`,{className:`hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2`,children:`⌘O`})]}),nativeButton:!0}),(0,$.jsx)(N,{children:(0,$.jsx)(`p`,{children:w??`New Chat`})})]})]}),(!_||v||y||b)&&(0,$.jsx)(vr,{open:n,onOpenChange:r,tempProvider:a,tempModel:o,tempApiKey:c,tempBaseUrl:l,onProviderChange:u,onModelChange:d,onApiKeyChange:f,onBaseUrlChange:p,onSave:m,onClear:g,showClearButton:C??(!!e&&!y&&!b),buttonLabel:e?`Change API Key`:`Configure API Key`,hostedInspector:v,freeTierInfo:y,managedCloudInfo:b,useManagedCloud:x,onSaveManagedCloud:S})]})]})}function wr({tools:e,disabledTools:t,onDisabledToolsChange:n,disabled:r}){let[i,a]=(0,Q.useState)(!1),o=e.length-t.size,c=t.size===0,l=t.size>0&&t.size<e.length,u=(0,Q.useCallback)(e=>{let r=new Set(t);r.has(e)?r.delete(e):r.add(e),n(r)},[t,n]),d=(0,Q.useCallback)(()=>{n(c?new Set(e.map(e=>e.name)):new Set)},[c,e,n]),f=(0,Q.useMemo)(()=>[...e].sort((e,t)=>e.name.localeCompare(t.name)),[e]);return e.length===0?null:(0,$.jsxs)(Se,{open:i,onOpenChange:a,children:[(0,$.jsxs)(O,{children:[(0,$.jsx)(h,{render:(0,$.jsx)(Ae,{render:(0,$.jsxs)(F,{variant:`ghost`,size:`sm`,disabled:r,className:s(`h-auto gap-1 rounded-full px-2 py-2`,l?`text-amber-500 dark:text-amber-400`:`text-muted-foreground hover:text-foreground`),type:`button`,"data-testid":`chat-tool-selector`,children:[(0,$.jsx)(lt,{className:`h-4 w-4 shrink-0`}),l&&(0,$.jsx)(`span`,{className:`flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-amber-500 px-1 text-[9px] font-bold leading-none text-white`,children:o})]}),nativeButton:!0}),nativeButton:!0}),(0,$.jsx)(N,{side:`top`,children:(0,$.jsxs)(`p`,{children:[`Tools (`,o,`/`,e.length,`)`]})})]}),(0,$.jsxs)(be,{className:`w-72 gap-0 p-0`,align:`start`,side:`top`,sideOffset:8,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b`,children:[(0,$.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:[`Allowed Tools (`,o,`/`,e.length,`)`]}),(0,$.jsx)(F,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:d,type:`button`,children:c?`Disable All`:`Enable All`})]}),(0,$.jsx)(`div`,{className:`max-h-64 overflow-y-auto`,children:f.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2.5 w-full px-3 py-1.5 text-left hover:bg-accent/50 transition-colors cursor-pointer`,onClick:()=>u(e.name),children:[(0,$.jsx)(Jt,{checked:!t.has(e.name),className:`pointer-events-none`,tabIndex:-1}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-mono`,children:e.name})]},e.name))})]})]})}function Tr({inputValue:e,isConnected:t,isLoading:n,textareaRef:r,attachments:i,placeholder:a=`Ask a question`,className:c,showAttachButton:l=!0,tools:u,disabledTools:d,onDisabledToolsChange:f,onInputChange:p,onKeyDown:m,onKeyUp:h,onClick:g,onAttachmentAdd:_,onAttachmentRemove:v,inlineControls:y,trailingControls:b}){let x=o(),S=(0,Q.useRef)(null),C=e=>{let t=e.target.files;if(t&&t.length>0)for(let e=0;e<t.length;e++)_(t[e]);S.current&&(S.current.value=``)},w=i.length>0;return(0,$.jsxs)(`div`,{className:`relative w-full`,children:[w&&(0,$.jsx)(`div`,{className:`absolute top-0 left-0 right-0 z-20 p-3 flex gap-2 flex-wrap`,children:i.map((e,t)=>(0,$.jsxs)(`div`,{className:`relative group bg-zinc-100/90 dark:bg-zinc-900/90 backdrop-blur-sm rounded-lg p-2 flex items-center gap-2 border border-zinc-200 dark:border-zinc-700`,"data-testid":`chat-attachment-${t}`,children:[(0,$.jsx)(pt,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium truncate max-w-[150px]`,children:e.name||`Image`}),e.size&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ye(e.size)})]}),(0,$.jsx)(`button`,{onClick:()=>v(t),className:`shrink-0 p-1 rounded-full hover:bg-zinc-200 dark:hover:bg-zinc-800 transition-colors`,title:`Remove attachment`,type:`button`,"data-testid":`chat-attachment-remove-${t}`,children:(0,$.jsx)(Oe,{className:`h-3 w-3`})})]},t))}),(0,$.jsx)(qt,{ref:r,value:e,onChange:e=>p(e.target.value),onKeyDown:m,onKeyUp:h,onClick:g,placeholder:t?a:`Server not connected`,className:s(`p-4 min-h-[150px] max-h-[300px]`,x.container,w&&`pt-20`,c),disabled:!t||n,"data-testid":`chat-input`}),(0,$.jsx)(`input`,{ref:S,type:`file`,accept:`image/*`,multiple:!0,onChange:C,className:`hidden`,"aria-label":`Upload images`}),(0,$.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 flex items-center justify-between gap-2 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[l&&(0,$.jsx)(F,{variant:`ghost`,size:`sm`,onClick:()=>S.current?.click(),disabled:!t||n,className:`h-auto w-auto aspect-square rounded-full p-2 text-muted-foreground hover:text-foreground`,title:`Attach images`,type:`button`,"data-testid":`chat-attach-button`,children:(0,$.jsx)(nn,{className:`h-4 w-4`})}),u&&u.length>0&&d&&f&&(0,$.jsx)(wr,{tools:u,disabledTools:d,onDisabledToolsChange:f,disabled:!t||n}),y]}),b?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:b}):null]})]})}function Er({promptResults:e,onDeletePromptResult:t}){return(0,$.jsx)(`div`,{className:`absolute top-4 left-4 right-4 flex gap-2 overflow-x-auto z-20 flex-nowrap`,style:{scrollbarWidth:`none`,msOverflowStyle:`none`},children:e.map(({promptName:e},n)=>(0,$.jsxs)(F,{type:`button`,className:`flex items-center gap-2 bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-[10px] px-1.5 py-0.5 dark:bg-zinc-700 rounded-lg border border-zinc-200 dark:border-zinc-300 font-medium hover:bg-zinc-300 dark:hover:bg-zinc-600`,children:[(0,$.jsx)(dt,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,$.jsx)(`span`,{className:`ml-1 h-4 w-4 rounded-full bg-zinc-400 dark:bg-zinc-600 hover:bg-zinc-500 dark:hover:bg-zinc-500 flex items-center justify-center cursor-pointer shrink-0 transition-colors`,onClick:e=>{e.stopPropagation(),t(n)},title:`Remove prompt`,role:`button`,tabIndex:0,children:(0,$.jsx)(Oe,{className:`h-2.5 w-2.5 text-white`})})]},n))})}function Dr({isOpen:e,focusedIndex:t,prompts:n,selectedPrompt:r,onPromptSelect:i}){return e?((0,Q.useEffect)(()=>{if(t>=0){let e=document.getElementById(`prompt-${t}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[t]),(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 right-0 max-w-3xl w-full max-h-[300px] overflow-y-auto rounded-lg border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 shadow-lg z-30 flex flex-col gap-2 mb-1`,"data-testid":`chat-prompts-dropdown`,children:(0,$.jsxs)(`div`,{className:`p-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-zinc-900 dark:text-zinc-100 mb-2`,children:`Prompts`}),n.map((e,n)=>(0,$.jsxs)(O,{children:[(0,$.jsx)(h,{render:(0,$.jsxs)(F,{id:`prompt-${n}`,type:`button`,variant:`ghost`,className:s(`w-full flex items-center px-3 py-2 rounded-md hover:bg-zinc-200 dark:hover:bg-zinc-700 transition-colors text-left justify-start`,t===n&&`bg-zinc-200 dark:bg-zinc-700`),onClick:()=>i(e),"data-testid":`chat-prompt-option-${n}`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-center shrink-0`,children:(0,$.jsx)(dt,{className:`h-4 w-4 text-zinc-600 dark:text-zinc-400`})}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsxs)(`div`,{className:`text-sm font-medium text-zinc-900 dark:text-zinc-100 flex items-center gap-2`,children:[e.name,r?.name===e.name&&(0,$.jsx)(Ce,{className:`size-3 text-zinc-600 dark:text-zinc-400`})]})})]}),nativeButton:!0}),(0,$.jsx)(N,{children:e.description})]},n))]})})):null}var Or=Q.createContext(void 0);function kr(e=!1){let t=Q.useContext(Or);if(!t&&!e)throw Error(_(86));return t}var Ar=Q.createContext(void 0);function jr(){return Q.useContext(Ar)}var Mr=[V],Nr=Q.forwardRef(function(e,t){let{render:r,className:i,disabled:a,readOnly:o,required:s,onValueChange:c,value:u,defaultValue:d,form:f,name:p,inputRef:m,id:h,style:g,..._}=e,{setTouched:v,setFocused:y,validationMode:b,name:x,disabled:S,state:C,validation:w,setDirty:T,setFilled:D,validityData:O}=ue(),{labelId:k}=Y(),{clearErrors:A}=fe(),j=kr(!0),M=S||a,N=x??p,P=l(h),[F,ee]=z({controlled:u,default:d,name:`RadioGroup`,state:`value`}),[te,I]=Q.useState(!1),L=n((e,t)=>{c?.(e,t),!t.isCanceled&&ee(e)}),R=Q.useRef(null),B=Q.useRef(null),V=Q.useRef(null);function ne(e){let t;return m&&(typeof m==`function`?t=m(e):m.current=e),B.current=e,w.inputRef.current=e,t}let H=n((e,t=!1)=>{if(e){if(t){R.current===e&&(R.current=null);return}R.current??=e}}),re=n(e=>{if(!e||e.disabled)return;V.current||=e;let t=B.current;if(e.checked||t==null||t.disabled)return ne(e)}),U=n(()=>{let e=B.current;return!e||e.disabled||!e.checked?null:F??null});se(R,P,F??null,U,!M,p),ce(F,()=>{A(N),T(F!==O.initialValue),D(F!=null),w.change(F);let e=V.current;F==null&&e&&!e.disabled&&ne(e)});let ie=_[`aria-labelledby`]??k??j?.legendId,W={...C,disabled:M??!1,required:s??!1,readOnly:o??!1},G=Q.useMemo(()=>({...C,checkedValue:F,disabled:M,form:f,validation:w,name:N,readOnly:o,registerControlRef:H,registerInputRef:re,required:s,setCheckedValue:L,setTouched:I,touched:te}),[F,M,f,w,C,N,o,H,re,s,L,I,te]),ae={id:h,role:`radiogroup`,"aria-required":s||void 0,"aria-disabled":M||void 0,"aria-readonly":o||void 0,"aria-labelledby":ie,onFocus(){y(!0)},onBlur(e){E(e.currentTarget,e.relatedTarget)||(v(!0),y(!1),b===`onBlur`&&w.commit(F))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&(I(!0),y(!0))}};return(0,$.jsx)(Ar.Provider,{value:G,children:(0,$.jsx)(Ft,{render:r,className:i,style:g,state:W,props:[ae,_,e=>w.getValidationProps(M??!1,e)],refs:[t],stateAttributesMapping:J,enableHomeAndEndKeys:!1,modifierKeys:Mr})})}),Pr=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Fr={checked(e){return e?{[Pr.checked]:``}:{[Pr.unchecked]:``}},...A,...J},Ir=Q.createContext(void 0),Lr=Q.forwardRef(function(e,t){let{render:i,className:a,disabled:o=!1,readOnly:s=!1,required:u=!1,"aria-labelledby":f,value:h,inputRef:_,nativeButton:v=!1,id:y,style:x,...S}=e,T=jr(),{disabled:E,readOnly:O,required:k,form:A,checkedValue:j,touched:N=!1,validation:P,name:F}=T??{},ee=T?.setCheckedValue??D,te=T?.setTouched??D,I=T?.registerControlRef??D,L=T?.registerInputRef??D,{setTouched:R,setFilled:z,state:B,disabled:V}=ue(),ne=St(),{labelId:H,getDescriptionProps:U}=Y(),ie=V||ne.disabled||E||o,W=O||s,G=k||u,ae=A,K=T?j===h:h===``,q=Q.useRef(null),J=Q.useRef(null),se=n(e=>{e&&I(e,ie)}),ce=C(_,J,L);d(()=>{J.current?.checked&&z(!0)},[z]),d(()=>{if(J.current){if(ie&&K){L(null);return}q.current&&I(q.current,ie),L(J.current)}},[K,ie,I,L]);let le=l(),de=re({id:y,implicit:!1,controlRef:q}),fe=v?void 0:de,pe=Fe(f,H,J,!v,fe),me={role:`radio`,"aria-checked":K,"aria-required":G||void 0,"aria-readonly":W||void 0,"aria-labelledby":pe,[Pt]:K?``:void 0,id:v?de:le,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||ie||W)return;e.preventDefault();let t=J.current;t&&t.dispatchEvent(new(r(t)).PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey}))},onFocus(e){e.defaultPrevented||ie||W||!N||(J.current?.click(),te(!1))}},{getButtonProps:he,buttonRef:ge}=m({disabled:ie,native:v,composite:!1}),_e={type:`radio`,ref:ce,form:ae,id:fe,name:F,tabIndex:-1,style:F?g:w,"aria-hidden":!0,...h===void 0?M:{value:oe(h)},disabled:ie,checked:K,required:G,readOnly:W,onChange(e){if(e.nativeEvent.defaultPrevented||ie||W||h===void 0)return;let t=c(p,e.nativeEvent);ee(h,t),!t.isCanceled&&R(!0)},onFocus(){q.current?.focus()}},ve=Q.useMemo(()=>({...B,required:G,disabled:ie,readOnly:W,checked:K}),[B,ie,W,K,G]),ye=ve,be=T!==void 0,xe=[t,q,ge,se],Se=[me,S,he,U,P?e=>P.getValidationProps(ie,e):M],Ce=b(`span`,e,{enabled:!be,state:ve,ref:xe,props:Se,stateAttributesMapping:Fr});return(0,$.jsxs)(Ir.Provider,{value:ye,children:[be?(0,$.jsx)(bt,{tag:`span`,render:i,className:a,style:x,state:ve,refs:xe,props:Se,stateAttributesMapping:Fr}):Ce,(0,$.jsx)(`input`,{..._e,suppressHydrationWarning:!0})]})}),Rr=[];function zr(e){let{allValues:t=Rr,value:r=Rr,onValueChange:i}=e,a=Q.useRef(r),o=Q.useRef(new Map),[s,c]=Q.useState(`mixed`),u=l(),d=r.length===t.length,f=r.length!==t.length&&r.length>0,p=n(i),m=Q.useCallback(()=>({id:u,indeterminate:f,checked:d,"aria-controls":t.map(e=>`${u}-${e}`).join(` `),onCheckedChange(e,n){let i=a.current,l=t.filter(e=>o.current.get(e)&&i.includes(e)),u=t.filter(e=>!o.current.get(e)||o.current.get(e)&&i.includes(e));if(i.length===u.length||i.length===0){r.length===u.length?p(l,n):p(u,n);return}let d=`mixed`,f=i;s===`mixed`?(d=`on`,f=u):s===`on`&&(d=`off`,f=l),p(f,n),n.isCanceled||c(d)}}),[t,d,u,f,p,s,r.length]),h=Q.useCallback(e=>({checked:r.includes(e),onCheckedChange(t,n){let i=r.slice();t?i.push(e):i.splice(i.indexOf(e),1),p(i,n),n.isCanceled||(a.current=i,c(`mixed`))}}),[p,r]);return Q.useMemo(()=>({id:u,indeterminate:f,getParentProps:m,getChildProps:h,disabledStatesRef:o}),[u,f,m,h])}var Br=Q.forwardRef(function(e,t){let{allValues:r,className:i,defaultValue:a,disabled:o=!1,id:s,onValueChange:c,render:u,value:d,style:f,...p}=e,{disabled:m,name:h,state:g,validation:_,setFilled:v,setDirty:y,validityData:x}=ue(),{labelId:C,getDescriptionProps:w}=Y(),{clearErrors:T}=fe(),E=m||o,D=Q.useMemo(()=>{if(d===void 0)return a??[]},[d,a]),[O,k]=z({controlled:d,default:D,name:`CheckboxGroup`,state:`value`}),A=n((e,t)=>{c?.(e,t),!t.isCanceled&&k(e)}),j=zr({allValues:r,value:O,onValueChange:A}),M=l(s),N=Q.useRef(null),P=Q.useCallback(e=>{N.current==null&&e!=null&&!e.hasAttribute(`data-parent`)&&(N.current=e)},[]);se(N,M,O,void 0,!!h&&!E,h);let F=O??S;ce(F,()=>{h&&T(h);let e=Array.isArray(x.initialValue)?x.initialValue:S;v(F.length>0),y(!W(F,e)),_.change(F)});let ee={...g,disabled:E},te=Q.useMemo(()=>({allValues:r,value:O,defaultValue:D,setValue:A,parent:j,disabled:E,validation:_,registerControlRef:P}),[r,O,D,A,j,E,_,P]),I=b(`div`,e,{state:ee,ref:t,props:[{id:s,role:`group`,"aria-labelledby":C},p,w],stateAttributesMapping:J});return(0,$.jsx)(ht.Provider,{value:te,children:I})}),Vr=function(e){let t=l(),r=e.controlId===void 0?t:e.controlId,[i,a]=Q.useState(r),[o,s]=Q.useState(e.labelId),[c,u]=Q.useState([]),d=I(()=>new Map),{messageIds:f}=Y(),p=n((e,t)=>{let n=d.current;if(t===void 0){n.delete(e);return}n.set(e,t),a(e=>{if(n.size===0)return;let t;for(let r of n.values()){if(e!==void 0&&r===e)return e;t===void 0&&(t=r)}return t})}),m=Q.useCallback(e=>{let t=e[`aria-describedby`]?e[`aria-describedby`].split(` `):[];return t.push(...f,...c),{...e,"aria-describedby":Array.from(new Set(t)).join(` `)||void 0}},[f,c]),h=Q.useMemo(()=>({controlId:i,registerControlId:p,labelId:o,setLabelId:s,messageIds:c,setMessageIds:u,getDescriptionProps:m}),[i,p,o,s,c,u,m]);return(0,$.jsx)(le.Provider,{value:h,children:e.children})};function Hr(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var Ur=Object.keys(de);function Wr(e){if(!e||e.valid||!e.valueMissing)return!1;let t=!1;for(let n of Ur)n!==`valid`&&(n===`valueMissing`?t=e[n]:e[n]&&(t=!1));return t}function Gr(e){let t=null;for(let n of e)if(!n.disabled){if(!n.validity.valid)return n;t??=n}return t}function Kr(e,t){let n=!1;for(let r of t)r.setCustomValidity(``),n||=r===e;n||e.setCustomValidity(``)}function qr(e){let{formRef:t}=fe(),{setValidityData:r,validate:i,validityData:a,validationDebounceTime:o,invalid:s,markedDirtyRef:c,state:l,shouldValidateOnChange:u,getRegisteredFieldId:d}=e,{controlId:p,getDescriptionProps:m}=Y(),h=f(),g=Q.useRef(null),_=I(()=>new Set).current,v=Q.useRef(0),y=Q.useCallback(e=>{if(e)return _.add(e),()=>{_.delete(e)}},[_]),b=n(async(e,n=!1)=>{let o=Gr(_)??g.current;if(!o)return;v.current+=1;let f=v.current;function m(e,n=s){let r=d()??p;if(r==null)return;let i=t.current.fields.get(r);if(!i)return;let a=Hr(e,n);t.current.fields.set(r,{...i,validityData:a})}if(n){if(l.valid!==!1)return;let t=o.validity;if(!t.valueMissing){let t={value:e,state:{...de,valid:!0},error:``,errors:[],initialValue:a.initialValue};Kr(o,_),m(t,!1),r(t);return}let n=Ur.reduce((e,n)=>(e[n]=t[n],e),{});if(!n.valid&&!Wr(n))return}function y(e){let t=Ur.reduce((t,n)=>(t[n]=e.validity[n],t),{}),n=!1;for(let e of Ur)if(e!==`valid`){if(e===`valueMissing`&&t[e])n=!0;else if(t[e])return t}return n&&!c.current&&(t.valid=!0,t.valueMissing=!1),t}h.clear();let b=null,x=[],S=y(o),C,w=u();if(o.validationMessage&&!w)C=o.validationMessage,x=[o.validationMessage];else{let n=i(e,Array.from(t.current.fields.values()).reduce((e,t)=>(t.name&&(e[t.name]=t.getValue()),e),{}));if(typeof n==`object`&&n&&`then`in n){if(b=await n,f!==v.current)return}else b=n;b===null?w&&(Kr(o,_),S.customError=!1,o.validationMessage?(C=o.validationMessage,x=[o.validationMessage]):o.validity.valid&&!S.valid&&(S.valid=!0)):(S.valid=!1,S.customError=!0,Array.isArray(b)?(x=b,o.setCustomValidity(b.join(`
|
|
2
|
-
`))):b&&(x=[b],o.setCustomValidity(b)))}let T={value:e,state:S,error:C??(Array.isArray(b)?b[0]:b??``),errors:x,initialValue:a.initialValue};m(T),r(T)}),x=n(e=>{h.clear();let t=u();t&&e!==``&&o?(v.current+=1,h.start(o,()=>{b(e)})):b(e,!t)}),S=Q.useCallback((e,t={})=>L(m(t),l.valid===!1&&!l.disabled&&!e?{"aria-invalid":!0}:M),[m,l.disabled,l.valid]);return Q.useMemo(()=>({getValidationProps:S,inputRef:g,registerInput:y,commit:b,change:x}),[S,y,b,x])}function Jr(e){let{commit:t,invalid:r,markedDirtyRef:i,name:a,setRegisteredFieldName:o,setRegisteredFieldId:s,setValidityData:c,validityData:l}=e,{formRef:u}=fe(),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(null),h=n(()=>{let e=p.current;if(e)return e.getValue?e.getValue():e.value});function g(e){return e.value===void 0?h():e.value}let _=n(()=>{let e=p.current;if(i.current=!0,!e){t(l.value);return}t(g(e))});function v(){let e=p.current;!e||!e.id||u.current.fields.set(e.id,{getValue:h,name:a??e.name,controlRef:e.controlRef??m,validityData:Hr(l,r),validate:_})}function y(e=p.current?.id){e&&u.current.fields.delete(e)}function b(){let e=p.current;if(!e)return;let t=g(e);l.initialValue===null&&t!==null&&c(e=>({...e,initialValue:t}))}return d(()=>{let e=p.current;!e||!e.id||(o(a?void 0:e.name),u.current.fields.set(e.id,{getValue:h,name:a??e.name,controlRef:e.controlRef??m,validityData:Hr(l,r),validate:_}))},[u,h,r,a,o,_,l]),d(()=>{let e=u.current.fields;return()=>{let t=p.current?.id;t&&e.delete(t)}},[u]),[_,n((e,t)=>{if(!t){f.current===e&&(f.current=null,y(),p.current=null,o(void 0),s(void 0));return}let n=p.current?.id;f.current=e,p.current=t,a||o(t.name),s(t.id),n&&n!==t.id&&y(n),b(),v()})]}var Yr=Q.forwardRef(function(e,t){let{errors:r,validationMode:i,submitAttemptedRef:a}=fe(),{render:o,className:s,validate:c,validationDebounceTime:l=0,validationMode:u=i,name:f,disabled:p=!1,invalid:m,dirty:h,touched:g,actionsRef:_,style:v,...y}=e,x=kr(!0)?.disabled,S=n(c||(()=>null)),C=x||p,[w,T]=Q.useState(!1),[E,D]=Q.useState(!1),[O,k]=Q.useState(!1),[A,j]=Q.useState(!1),M=h??E,N=g??w,P=Q.useRef(M),F=Q.useRef(void 0),[ee,te]=Q.useState(),I=f??ee;d(()=>{h!==void 0&&(P.current=h)},[h]);let L=Q.useCallback(()=>F.current,[]),R=Q.useCallback(e=>{F.current=e},[]),z=n(e=>{h===void 0&&(e&&(P.current=!0),D(e))}),B=n(e=>{g===void 0&&T(e)}),V=n(()=>u===`onChange`||u===`onSubmit`&&a.current),ne=I&&Object.hasOwn(r,I)?r[I]:null,H=!!(Array.isArray(ne)?ne.length:ne),re=m===!0||H,[U,ie]=Q.useState({state:de,error:``,errors:[],value:null,initialValue:null}),W=C?null:!re&&U.state.valid,G=Q.useMemo(()=>({disabled:C,touched:N,dirty:M,valid:W,filled:O,focused:A}),[C,N,M,W,O,A]),ae=qr({setValidityData:ie,validate:S,validityData:U,validationDebounceTime:l,invalid:re,markedDirtyRef:P,state:G,shouldValidateOnChange:V,getRegisteredFieldId:L}),[oe,K]=Jr({commit:ae.commit,invalid:re,markedDirtyRef:P,name:f,setRegisteredFieldName:te,setRegisteredFieldId:R,setValidityData:ie,validityData:U});Q.useImperativeHandle(_,()=>({validate:oe}),[oe]);let se=Q.useMemo(()=>({invalid:re,name:I,validityData:U,setValidityData:ie,disabled:C,touched:N,setTouched:B,dirty:M,setDirty:z,filled:O,setFilled:k,focused:A,setFocused:j,validate:S,validationMode:u,validationDebounceTime:l,shouldValidateOnChange:V,state:G,markedDirtyRef:P,registerFieldControl:K,validation:ae}),[re,I,U,C,N,B,M,z,O,k,A,j,S,u,l,V,G,K,ae]),ce=b(`div`,e,{ref:t,state:G,props:y,stateAttributesMapping:J});return(0,$.jsx)(q.Provider,{value:se,children:ce})}),Xr=Q.forwardRef(function(e,t){return(0,$.jsx)(Vr,{children:(0,$.jsx)(Yr,{...e,ref:t})})}),Zr={...J,...A},Qr=Q.forwardRef(function(e,t){let{render:n,id:r,className:a,match:o,style:s,...c}=e,u=l(r),{validityData:f,state:p,name:m}=ue(!1),{setMessageIds:h}=Y(),{errors:g}=fe(),_=m&&Object.hasOwn(g,m)?g[m]:null,v=!!(Array.isArray(_)?_.length:_),y=typeof o==`string`,x=!1;x=o===!0?!0:p.disabled?!1:y?!!f.state[o]:v||f.state.valid===!1;let{mounted:S,transitionStatus:C,setMounted:w}=T(x);d(()=>{if(!(!x||!u))return h(e=>e.concat(u)),()=>{h(e=>e.filter(e=>e!==u))}},[x,u,h]);let E=Q.useRef(null),[D,O]=Q.useState(null),[k,A]=Q.useState(null),j=f.error;!y&&v?j=_:f.errors.length>1&&(j=f.errors);let M=j??``;Array.isArray(j)&&(M=j.length>1?(0,$.jsx)(`ul`,{children:j.map(e=>(0,$.jsx)(`li`,{children:e},e))}):j[0]??``);let N=Array.isArray(j)?JSON.stringify(j):j;x&&N!==k&&(A(N),O(M)),i({open:x,ref:E,onComplete(){x||w(!1)}});let P={...p,transitionStatus:C},F=b(`div`,e,{ref:[t,E],state:P,props:[{id:u,children:x?M:D},c],stateAttributesMapping:Zr,enabled:S});return S?F:null}),$r=Q.forwardRef(function(e,t){let{render:r,className:i,id:a,name:o,value:s,disabled:l=!1,onValueChange:u,defaultValue:f,autoFocus:m=!1,style:h,...g}=e,{state:_,name:v,disabled:y,setTouched:x,setDirty:S,validityData:C,setFocused:w,setFilled:T,validationMode:E,validation:D}=ue(),{clearErrors:O}=fe(),A=y||l,M=v??o,N={..._,disabled:A},{labelId:P}=Y(),F=re({id:a});d(()=>{let e=s!=null;D.inputRef.current?.value||e&&s!==``?T(!0):e&&s===``&&T(!1)},[D.inputRef,T,s]);let ee=Q.useRef(null);d(()=>{m&&ee.current===j(k(ee.current))&&w(!0)},[m,w]);let[te]=z({controlled:s,default:f,name:`FieldControl`,state:`value`}),I=s!==void 0,L=I?te:void 0,R=n(()=>D.inputRef.current?.value);return se(D.inputRef,F,L,R,!A,o),b(`input`,e,{ref:[t,ee],state:N,props:[{id:F,disabled:A,name:M,ref:D.inputRef,"aria-labelledby":P,autoFocus:m,...I?{value:L}:{defaultValue:f},onChange(e){let t=e.currentTarget.value;u?.(t,c(p,e.nativeEvent)),S(t!==C.initialValue),T(t!==``),e.nativeEvent.defaultPrevented||(O(M),D.change(t))},onFocus(){w(!0)},onBlur(e){x(!0),w(!1),E===`onBlur`&&D.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(x(!0),D.commit(e.currentTarget.value))}},g,e=>D.getValidationProps(A,e)],stateAttributesMapping:J})}),ei=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,ti=P.moderate,ni=.07,ri=(ti.duration+ni)*1e3+80,ii=ti.duration*1e3+80;function ai(e,t){let n=t.filter(t=>t.start>=e.start&&t.end<=e.end).sort((e,t)=>e.start-t.start);if(n.length!==2)return null;let[r,i]=n;return i.start===r.end+2?{up:r,lo:i,gap:r.end+1}:null}function oi(e,t,n,r){let i=n[e],a=n[t];if(!i||!a)return null;if(r===`y`)return{top:i.top,left:Math.min(i.left,a.left),width:Math.max(i.width,a.width),height:a.top+a.height-i.top};let o=Math.min(i.left,a.left),s=Math.max(i.left+i.width,a.left+a.width);return{top:Math.min(i.top,a.top),left:o,width:s-o,height:Math.max(i.height,a.height)}}function si(e,t){return t===`y`?e.top+e.height/2:e.left+e.width/2}function ci(e,t){return t===`y`?[e,e,0,0]:[e,0,0,e]}function li(e,t){return t===`y`?[0,0,e,e]:[0,e,e,0]}function ui(e){return[e,e,e,e]}function di(e,t,n,r,i){let a=si(n,r);if(r===`y`){let n=t.top+t.height;e.height=a-e.top,e.radii=ci(i,r),e.instant=!0,t.top=a,t.height=n-a,t.radii=li(i,r),t.instant=!0,t.enterFrom={top:a,left:t.left,width:t.width,height:n-a,radii:li(i,r)};return}let o=t.left+t.width;e.width=a-e.left,e.radii=ci(i,r),e.instant=!0,t.left=a,t.width=o-a,t.radii=li(i,r),t.instant=!0,t.enterFrom={top:t.top,left:a,width:o-a,height:t.height,radii:li(i,r)}}function fi(e,t,n,r=`y`){let[i,a]=(0,Q.useState)([]),o=(0,Q.useRef)([]),s=(0,Q.useRef)(0),c=(0,Q.useRef)(new Map);ei(()=>{let t=o.current,n=e,r=[];for(let e of n){let n=ai(e,t);n&&(e.id===n.up.id||e.id===n.lo.id)&&r.push({tid:++s.current,kind:`merge`,survivorId:e.id,otherId:e.id===n.up.id?n.lo.id:n.up.id,gapIndex:n.gap,phase:`converge`})}for(let e of t){let t=ai(e,n);t&&r.push({tid:++s.current,kind:`split`,survivorId:t.up.id,otherId:t.lo.id,gapIndex:t.gap,phase:`splitIn`})}o.current=n.map(e=>({...e}));for(let e of r)c.current.set(e.tid,setTimeout(()=>{c.current.delete(e.tid),a(t=>t.some(t=>t.tid===e.tid)?t.flatMap(t=>t.tid===e.tid?t.kind===`merge`?[{...t,phase:`commit`}]:[]:[t]):t)},e.kind===`merge`?ri:ii));let i=e=>e.kind===`merge`?n.some(t=>t.id===e.survivorId&&e.gapIndex>t.start&&e.gapIndex<t.end):n.some(t=>t.id===e.survivorId&&t.end===e.gapIndex-1)&&n.some(t=>t.id===e.otherId&&t.start===e.gapIndex+1);a(e=>{for(let t of e){if(i(t))continue;let e=c.current.get(t.tid);e!==void 0&&(clearTimeout(e),c.current.delete(t.tid))}return[...e.filter(i),...r]})},[e.map(e=>`${e.id}:${e.start}-${e.end}`).join(`|`)]),(0,Q.useEffect)(()=>{let e=c.current;return()=>e.forEach(clearTimeout)},[]),(0,Q.useEffect)(()=>{i.some(e=>e.phase===`splitIn`||e.phase===`commit`)&&a(e=>e.flatMap(e=>e.phase===`commit`?[]:[{...e,phase:e.phase===`splitIn`?`diverge`:e.phase}]))},[i]);let l=[];for(let i of e){let e=oi(i.start,i.end,t,r);e&&l.push({key:`sel-${i.id}`,...e,radii:ui(n),instant:!1,exitInstant:!1,delayCorners:!1})}let u=new Map(l.map(e=>[e.key,e]));for(let e of i){let i=t[e.gapIndex],a=u.get(`sel-${e.survivorId}`);if(!i||!a)continue;let o=si(i,r);if(e.kind===`merge`){if(e.phase===`commit`){a.instant=!0,r===`y`?l.push({key:`sel-${e.otherId}`,top:o,left:a.left,width:a.width,height:a.top+a.height-o,radii:li(n,r),instant:!0,exitInstant:!0,delayCorners:!1,opacity:0}):l.push({key:`sel-${e.otherId}`,top:a.top,left:o,width:a.left+a.width-o,height:a.height,radii:li(n,r),instant:!0,exitInstant:!0,delayCorners:!1,opacity:0});continue}let t=Math.min(.1,Math.max(ni,ni+o/Math.max(r===`y`?i.height:i.width,1)*.002));if(r===`y`){let i=a.top+a.height;a.height=o-a.top,a.radii=ci(n,r),a.delayCorners=!0,a.cornerDelay=t,l.push({key:`sel-${e.otherId}`,top:o,left:a.left,width:a.width,height:i-o,radii:li(n,r),enterFrom:{top:o,left:a.left,width:a.width,height:i-o,radii:ui(n)},instant:!1,exitInstant:!0,delayCorners:!0,cornerDelay:t})}else{let i=a.left+a.width;a.width=o-a.left,a.radii=ci(n,r),a.delayCorners=!0,a.cornerDelay=t,l.push({key:`sel-${e.otherId}`,top:a.top,left:o,width:i-o,height:a.height,radii:li(n,r),enterFrom:{top:a.top,left:o,width:i-o,height:a.height,radii:ui(n)},instant:!1,exitInstant:!0,delayCorners:!0,cornerDelay:t})}}else if(e.phase===`splitIn`){let t=u.get(`sel-${e.otherId}`);if(!t)continue;di(a,t,i,r,n)}}for(let i of o.current){let a=ai(i,e),o=a&&t[a.gap];if(!a||!o)continue;let s=u.get(`sel-${a.up.id}`),c=u.get(`sel-${a.lo.id}`);!s||!c||di(s,c,o,r,n)}return l}function pi({blocks:e,dimmed:t}){return(0,$.jsx)(ne,{children:e.map(e=>{let n=e.delayCorners?{...ti,delay:e.cornerDelay??ni}:ti,r=e.opacity??(t?.8:1);return(0,$.jsx)(x.div,{"aria-hidden":!0,className:`absolute bg-active pointer-events-none`,initial:e.enterFrom?{opacity:r,top:e.enterFrom.top,left:e.enterFrom.left,width:e.enterFrom.width,height:e.enterFrom.height,borderTopLeftRadius:e.enterFrom.radii[0],borderTopRightRadius:e.enterFrom.radii[1],borderBottomRightRadius:e.enterFrom.radii[2],borderBottomLeftRadius:e.enterFrom.radii[3]}:!1,animate:{top:e.top,left:e.left,width:e.width,height:e.height,borderTopLeftRadius:e.radii[0],borderTopRightRadius:e.radii[1],borderBottomRightRadius:e.radii[2],borderBottomLeftRadius:e.radii[3],opacity:r},exit:{opacity:0,transition:e.exitInstant?{duration:0}:ti.exit},transition:e.instant?{duration:0}:{...ti,borderTopLeftRadius:n,borderTopRightRadius:n,borderBottomRightRadius:n,borderBottomLeftRadius:n,opacity:{duration:.08}}},e.key)})})}function mi(e,t){return e.id??`q-${t}`}function hi(e,t){return e.id??`o-${t}`}var gi=[],_i=(0,Q.forwardRef)(function({questions:e,currentIndex:t,defaultCurrentIndex:n=0,onCurrentIndexChange:r,answers:i,defaultAnswers:a,onAnswersChange:c,onComplete:l,onSkip:u,skipLabel:d=`Skip`,intro:f,onCancel:p,cancelLabel:m=`Cancel`,footerLeading:h,className:g,..._},y){let[b,S]=(0,Q.useState)(n),C=t!==void 0,w=C?t:b,T=(0,Q.useCallback)(e=>{C||S(e),r?.(e)},[C,r]),[E,D]=(0,Q.useState)(a??{}),O=i!==void 0,k=O?i:E,A=(0,Q.useRef)(k);(0,Q.useEffect)(()=>{A.current=k},[k]);let j=(0,Q.useCallback)(e=>{let t=e(A.current);return A.current=t,O||D(t),c?.(t),t},[O,c]),M=o(),N=X(`arrow-left`),ee=X(`arrow-right`),te=(0,Q.useMemo)(()=>function(e){return(0,$.jsx)(N,{...e,className:s(e.className,`hidden sm:block`)})},[N]),I=(0,Q.useMemo)(()=>function(e){return(0,$.jsx)(ee,{...e,className:s(e.className,`hidden sm:block`)})},[ee]),[L]=(0,Q.useState)(()=>{if(typeof navigator>`u`)return!1;let e=navigator,t=e.userAgentData?.platform||e.platform||``;return/mac/i.test(t)}),R=(0,Q.useId)(),z=e.length,B=Math.max(0,Math.min(w,Math.max(0,z-1))),V=e[B],H=V?mi(V,B):``,re=k[H],U=!!V?.multiSelect,ie=V?.skippable!==!1,W=!!V?.freeText,ae=V?.freeTextMultiline!==!1,oe=!W&&!!V?.allowOther,K=(0,Q.useMemo)(()=>re?.selectedIds??[],[re]),q=re?.otherText??``,J=V?.options??[],se=oe?J.length:-1,ce=J.length+ +!!oe,le=(0,Q.useRef)(null),ue=!!V;(0,Q.useEffect)(()=>{if(!ue)return;let e=le.current;if(e)return gi.push(e),()=>{let t=gi.indexOf(e);t!==-1&&gi.splice(t,1)}},[ue]);let Y=(0,Q.useRef)(null),de=(0,Q.useRef)(null),fe=(0,Q.useRef)(0),pe=(0,Q.useRef)(new Map),{activeIndex:me,setActiveIndex:he,itemRects:ge,sessionRef:_e,handlers:ve,registerItem:ye,measureItems:be}=G(Y);(0,Q.useEffect)(()=>{be()},[be,H,ce,M]);let[xe,Se]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{Se(!1)},[H]),(0,Q.useEffect)(()=>{let e=de.current;if(!e)return;e.style.height=`0px`,e.style.height=`${e.scrollHeight}px`;let t=parseFloat(window.getComputedStyle(e).lineHeight)||18;Se(e.scrollHeight>t*1.5),be()},[q,be,H]),(0,Q.useEffect)(()=>{W&&de.current?.focus({preventScroll:!0})},[W,H]);let Ce=(0,Q.useRef)(null),[we,Te]=(0,Q.useState)(`auto`);(0,Q.useEffect)(()=>{let e=Ce.current;if(!e)return;let t=()=>Te(e.offsetHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let[Ee,De]=(0,Q.useState)(null),[Oe,ke]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{he(null),De(null),ke(null)},[B,he]);let Ae=(0,Q.useRef)(!1),je=(0,Q.useCallback)(()=>{Y.current?.contains(document.activeElement)&&(Ae.current=!0)},[]);(0,Q.useEffect)(()=>{Ae.current&&(Ae.current=!1,(Y.current?.querySelector(`[data-proximity-index="0"]`))?.focus())},[B]);let Me=(0,Q.useCallback)(e=>{B>=z-1?l?.(e):(je(),T(B+1))},[B,z,l,T,je]),Ne=(0,Q.useCallback)(e=>{if(!V)return;let t=A.current[H]?.otherText;Me(j(n=>({...n,[H]:{questionId:H,selectedIds:[e],otherText:t||void 0,skipped:!1}})))},[V,H,j,Me]),Pe=(0,Q.useCallback)(e=>{V&&j(t=>{let n=t[H],r=new Set(n?.selectedIds??[]);return r.has(e)?r.delete(e):r.add(e),{...t,[H]:{questionId:H,selectedIds:Array.from(r),otherText:n?.otherText,skipped:!1}}})},[V,H,j]),Fe=(0,Q.useCallback)(e=>{V&&j(t=>({...t,[H]:{questionId:H,selectedIds:e,otherText:t[H]?.otherText,skipped:!1}}))},[V,H,j]),Ie=(0,Q.useCallback)(e=>{V&&(ke(null),j(t=>({...t,[H]:{questionId:H,selectedIds:t[H]?.selectedIds??[],otherText:e,skipped:!1}})))},[V,H,j]),Le=(0,Q.useCallback)(()=>{if(!V)return;let e=(A.current[H]?.otherText??``).trim();if(e){if(V.freeText&&V.freeTextValidate){let t=V.freeTextValidate(e);if(t){ke(t);return}}ke(null),Me(j(t=>({...t,[H]:{questionId:H,selectedIds:t[H]?.selectedIds??[],otherText:e,skipped:!1}})))}},[V,H,j,Me]),Re=(0,Q.useCallback)(()=>{if(!V)return;let e=j(e=>({...e,[H]:{questionId:H,selectedIds:e[H]?.selectedIds??[],otherText:e[H]?.otherText,skipped:!0}}));u?.(H,B),Me(e)},[V,H,j,u,B,Me]),ze=(0,Q.useCallback)(()=>{p?.()},[p]),Be=(0,Q.useCallback)(()=>{Me(k)},[Me,k]),Ve=(0,Q.useCallback)(()=>{B>0&&(je(),T(B-1))},[B,T,je]);(0,Q.useEffect)(()=>{if(!V)return;let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;if(!t)return;let n=t.tagName;if(n===`INPUT`||n===`TEXTAREA`||t.isContentEditable)return;let r=le.current;if(!r||!r.contains(t)&&(gi.some(e=>e!==r&&e.contains(t))||gi[gi.length-1]!==r))return;let i=e.key;if(i<`1`||i>`9`)return;let a=parseInt(i,10)-1;if(a>=0&&a<J.length){e.preventDefault();let t=hi(J[a],a);U?Pe(t):Ne(t)}else a===J.length&&oe&&(e.preventDefault(),de.current?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[V,J,U,oe,Ne,Pe]);let He=e=>{(Y.current?.querySelector(`[data-proximity-index="${e}"]`))?.focus()},Ue=(0,Q.useCallback)(e=>{he(e),oe&&e===se?de.current?.focus():He(e)},[oe,se,he]),We=e=>{let t=e.target,n=t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable;if(n&&e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;if(n&&(e.key===`ArrowUp`||e.key===`ArrowDown`)&&t.tagName===`TEXTAREA`){let n=t;if(e.key===`ArrowUp`&&n.selectionStart>0||e.key===`ArrowDown`&&n.selectionEnd<n.value.length)return}let r=e.preventBaseUIHandler;if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault(),e.stopPropagation(),r?.(),e.key===`ArrowLeft`?B>0&&Ve():ie&&z>1&&Re();return}if(ce!==0&&(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Home`||e.key===`End`)){e.preventDefault(),e.stopPropagation(),r?.();let t;if(e.key===`Home`)t=0;else if(e.key===`End`)t=ce-1;else{let r=n?se:me??-1;t=e.key===`ArrowDown`?r+1:r-1,t=(t+ce)%ce}Ue(t)}},Ge=e=>{if(e.key===`Enter`&&!(!(L?e.metaKey:e.ctrlKey)||!(U||W))){if(e.preventDefault(),W){q.trim().length>0&&Le();return}(K.length>0||q.trim().length>0)&&Be()}};if(!V)return(0,$.jsx)(`div`,{ref:y,className:s(`w-full max-w-[520px] p-5 bg-card border border-border`,M.container,g),..._,children:(0,$.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`No questions.`})});let Ke=me===null?null:ge[me],qe=Ee!==null&&!(oe&&Ee===se)?ge[Ee]:null,Je=(0,Q.useMemo)(()=>{let e=new Set;return J.forEach((t,n)=>{K.includes(hi(t,n))&&e.add(n)}),oe&&q.length>0&&e.add(se),e},[J,K,oe,q,se]),Ye=(0,Q.useMemo)(()=>{let e=[],t=[...Je].sort((e,t)=>e-t);for(let n of t){let t=e[e.length-1];t&&n===t.end+1?t.end=n:e.push({start:n,end:n})}let n=new Set,r=new Map,i=e.map(e=>{let t=null;for(let r=e.start;r<=e.end;r++){let e=pe.current.get(r);if(e!==void 0&&!n.has(e)){t=e;break}}let i=t??++fe.current;n.add(i);for(let t=e.start;t<=e.end;t++)r.set(t,i);return{...e,id:i}});return pe.current=r,i},[Je]),Xe=me!==null&&!Je.has(me),Ze=fi(Ye,ge,M.bgRadius),$e=z>1&&B>0,et=p!=null,tt=!et&&z>1&&ie,nt=U||W,Z=$e||tt||nt||et||h!=null,rt=J.findIndex((e,t)=>K.includes(hi(e,t))),it=(0,$.jsxs)(`div`,{ref:Y,role:U?`group`:`radiogroup`,"aria-labelledby":`${R}-${H}-title`,onMouseEnter:ve.onMouseEnter,onMouseMove:ve.onMouseMove,onMouseLeave:ve.onMouseLeave,onFocus:e=>{let t=e.target.closest(`[data-proximity-index]`)?.getAttribute(`data-proximity-index`);if(t!=null){let n=Number(t);he(n),De(e.target.matches(`:focus-visible`)?n:null)}},onBlur:e=>{Y.current?.contains(e.relatedTarget)||(De(null),he(null))},onKeyDown:We,className:`relative flex flex-col gap-0.5 -mx-3`,children:[(0,$.jsx)(ne,{children:(()=>{if(!oe)return null;let e=ge[se],t=Ee===se&&q.length===0;return!e||!t?null:(0,$.jsx)(x.div,{"aria-hidden":!0,className:s(`absolute pointer-events-none bg-card ring-1 ring-inset ring-border`,M.bg),initial:{opacity:0,top:e.top,left:e.left,width:e.width,height:e.height},animate:{opacity:1,top:e.top,left:e.left,width:e.width,height:e.height},exit:{opacity:0,transition:P.fast.exit},transition:{...P.fast,opacity:{duration:.08}}},`other-input`)})()}),(0,$.jsx)(ne,{children:Ke&&(0,$.jsx)(x.div,{"aria-hidden":!0,className:s(`absolute pointer-events-none bg-hover`,M.bg),initial:{opacity:0,top:Ke.top,left:Ke.left,width:Ke.width,height:Ke.height},animate:{opacity:1,top:Ke.top,left:Ke.left,width:Ke.width,height:Ke.height},exit:{opacity:0,transition:P.fast.exit},transition:{...P.fast,opacity:{duration:.08}}},`hover-${_e.current}`)}),(0,$.jsx)(pi,{blocks:Ze,dimmed:Xe}),(0,$.jsx)(ne,{children:qe&&(0,$.jsx)(x.div,{"aria-hidden":!0,className:s(`absolute pointer-events-none border border-[color:var(--focus-ring,#6B97FF)] z-20`,M.focusRing),initial:{opacity:0,top:qe.top-2,left:qe.left-2,width:qe.width+4,height:qe.height+4},animate:{opacity:1,top:qe.top-2,left:qe.left-2,width:qe.width+4,height:qe.height+4},exit:{opacity:0,transition:P.fast.exit},transition:{...P.fast,opacity:{duration:.08}}})}),J.map((e,t)=>{let n=hi(e,t),r=K.includes(n),i=!U&&me===t;return(0,$.jsx)(yi,{index:t,registerItem:ye,role:U?`checkbox`:`radio`,isSelected:r,tabIndex:t===rt||rt===-1&&t===0?0:-1,onClick:()=>U?Pe(n):Ne(n),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),U?Pe(n):Ne(n))},shape:M,"aria-checked":r,chipContent:t+1,chipFilled:r,isMulti:U,showArrow:i,bodyLayout:V.layout===`stacked`?`stacked`:`inline`,topAlign:V.layout===`stacked`,chipPosition:V.chipPosition??`right`,arrowIcon:(0,$.jsx)(ee,{size:14,strokeWidth:2,className:`h-3.5 w-3.5`}),hiddenControl:U?(0,$.jsx)(Qe,{name:n,className:`sr-only`,tabIndex:-1,"aria-hidden":!0}):(0,$.jsx)(Lr,{value:n,className:`sr-only`,tabIndex:-1,"aria-hidden":!0}),children:V.layout===`stacked`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`inline-grid`,children:[(0,$.jsx)(`span`,{className:`col-start-1 row-start-1 invisible`,style:{fontVariationSettings:v.semibold},"aria-hidden":`true`,children:e.title}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1 text-foreground transition-[color,font-variation-settings] duration-80`,style:{fontVariationSettings:r?v.semibold:v.medium},children:e.title})]}),e.description&&(0,$.jsx)(`span`,{className:`text-[12px] text-muted-foreground leading-snug`,children:e.description})]}):(0,$.jsxs)(`span`,{children:[(0,$.jsxs)(`span`,{className:`inline-grid`,children:[(0,$.jsx)(`span`,{className:`col-start-1 row-start-1 invisible`,style:{fontVariationSettings:v.semibold},"aria-hidden":`true`,children:e.title}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1 text-foreground transition-[color,font-variation-settings] duration-80`,style:{fontVariationSettings:r?v.semibold:v.medium},children:e.title})]}),e.description&&(0,$.jsxs)($.Fragment,{children:[` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.description})]})]})},n)}),oe&&(0,$.jsx)(yi,{index:se,registerItem:ye,role:null,isSelected:q.length>0,tabIndex:-1,onClick:()=>de.current?.focus(),shape:M,chipContent:se+1,chipFilled:q.length>0,isMulti:U,topAlign:xe,chipPosition:V.chipPosition??`right`,ariaLabel:V.otherPlaceholder??`Describe in your own words`,showArrow:!U&&(Ee===se||me===se)&&q.trim().length>0,arrowIcon:(0,$.jsx)(ee,{size:14,strokeWidth:2,className:`h-3.5 w-3.5`}),onArrowClick:!U&&q.trim().length>0?Le:void 0,children:(0,$.jsx)(`span`,{className:`inline-grid w-full`,children:(0,$.jsx)(`textarea`,{ref:de,rows:1,value:q,placeholder:V.otherPlaceholder??`Describe in your own words…`,"aria-label":V.otherPlaceholder??`Describe in your own words`,onChange:e=>Ie(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.shiftKey||U||(e.preventDefault(),Le()))},onClick:e=>e.stopPropagation(),className:s(`col-start-1 row-start-1 block w-full bg-transparent border-0 p-0 m-0 outline-none resize-none overflow-hidden text-[13px] leading-snug text-foreground placeholder:text-muted-foreground`),style:{fontVariationSettings:v.medium}})})})]});return(0,$.jsxs)(`div`,{ref:e=>{le.current=e,typeof y==`function`?y(e):y&&(y.current=e)},className:s(`relative w-full max-w-[520px] overflow-hidden bg-card border border-border`,M.container,g),..._,onKeyDown:e=>{_.onKeyDown?.(e),Ge(e)},children:[(0,$.jsx)(`div`,{className:`flex items-center px-4 sm:px-5 pt-4 sm:pt-5 pb-2 text-[12px] text-muted-foreground`,children:(0,$.jsxs)(`span`,{children:[`Question `,B+1,` of `,z]})}),f!=null&&(0,$.jsx)(`div`,{className:`px-4 sm:px-5 pb-3 text-[13px] leading-snug text-muted-foreground`,children:f}),(0,$.jsxs)(Xr,{invalid:Oe!==null,className:`contents`,children:[(0,$.jsx)(x.div,{animate:{height:we},initial:!1,transition:P.slow,className:`overflow-hidden`,children:(0,$.jsx)(`div`,{ref:Ce,className:s(`px-4 sm:px-5`,Z?`pb-1`:`pb-2.5 sm:pb-3`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h3`,{id:`${R}-${H}-title`,className:`text-[16px] text-foreground leading-snug`,style:{fontVariationSettings:v.semibold},children:V.title}),W?(0,$.jsx)(`div`,{onClick:()=>de.current?.focus(),className:s(`relative mt-1 -mx-3 px-3 py-2.5 cursor-text transition-colors`,ae?`min-h-[76px]`:`min-h-10`,M.bg,q.length>0?`bg-active`:`hover:bg-hover focus-within:bg-card focus-within:ring-1 focus-within:ring-inset focus-within:ring-border`),children:(0,$.jsx)($r,{value:q,onValueChange:Ie,render:(0,$.jsx)(`textarea`,{ref:de,rows:1,placeholder:V.freeTextPlaceholder??`Type your answer…`,"aria-labelledby":`${R}-${H}-title`,onKeyDown:e=>{e.key===`Enter`&&(e.shiftKey||e.metaKey||e.ctrlKey||ae||(e.preventDefault(),Le()))},className:`block w-full bg-transparent border-0 p-0 m-0 outline-none resize-none overflow-hidden text-[13px] leading-snug text-foreground placeholder:text-muted-foreground`,style:{fontVariationSettings:v.medium}})})}):U?(0,$.jsx)(Br,{value:K,onValueChange:Fe,render:it}):(0,$.jsx)(Nr,{value:K[0]??null,onValueChange:e=>{typeof e==`string`&&Ne(e)},render:it})]},H)})}),Z&&(0,$.jsx)(`div`,{className:`px-4 sm:px-5 pt-1 pb-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 -mx-2 sm:-mx-3`,children:[(0,$.jsxs)(`div`,{className:`relative flex flex-1 min-w-0 items-center gap-2`,children:[h!=null&&(0,$.jsx)(`div`,{className:`shrink-0 px-2 sm:px-3`,children:h}),(0,$.jsx)(ne,{mode:`popLayout`,initial:!1,children:$e&&(0,$.jsx)(x.div,{layout:`position`,initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...P.fast,opacity:{duration:.1}},children:(0,$.jsx)(F,{variant:`ghost`,size:`sm`,leadingIcon:te,onClick:Ve,className:`pl-3 sm:pl-[6px]`,children:`Back`})},`back`)}),Oe&&(0,$.jsx)(Qr,{match:!0,render:(0,$.jsx)(x.p,{role:`alert`,initial:{opacity:0,y:-2},animate:{opacity:1,y:0},transition:{...P.fast,opacity:{duration:.12}},className:`min-w-0 px-2 sm:px-3 text-left text-[12px] leading-snug text-destructive`}),children:Oe},`ft-error`)]}),(0,$.jsx)(`div`,{className:`relative flex items-center gap-2`,children:(0,$.jsxs)(ne,{mode:`popLayout`,initial:!1,children:[et&&(0,$.jsx)(x.div,{layout:`position`,initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...P.fast,opacity:{duration:.1}},children:(0,$.jsx)(F,{variant:`ghost`,size:`sm`,trailingIcon:I,onClick:ze,className:`pr-3 sm:pr-[6px]`,children:m})},`cancel`),tt&&(0,$.jsx)(x.div,{layout:`position`,initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...P.fast,opacity:{duration:.1}},children:(0,$.jsx)(F,{variant:`ghost`,size:`sm`,trailingIcon:I,onClick:Re,className:`pr-3 sm:pr-[6px]`,children:d})},`skip`),nt&&(0,$.jsx)(x.div,{layout:`position`,initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...P.fast,opacity:{duration:.1}},children:(0,$.jsx)(F,{variant:`primary`,size:`sm`,onClick:W?Le:Be,disabled:(W||K.length===0)&&q.trim().length===0,className:`pr-3 sm:pr-[6px]`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[V.nextLabel??(B>=z-1?`Finish`:`Continue`),(0,$.jsx)(`span`,{className:`hidden sm:contents`,children:(0,$.jsxs)(vi,{shape:M,tone:`inverted`,children:[L?`⌘`:`⌃`,`↵`]})})]})})},`continue`)]})})]})})]})]})});_i.displayName=`AskUserQuestions`;function vi({children:e,tone:t=`muted`,shape:n}){return(0,$.jsx)(`kbd`,{"aria-hidden":!0,suppressHydrationWarning:!0,className:s(`inline-flex items-center justify-center gap-0.5 px-1 min-w-[18px] h-[18px] text-[11px] leading-none font-sans tracking-wide`,t===`inverted`?`bg-background/15 text-background`:`bg-foreground/10 text-muted-foreground`,n.bg),children:e})}function yi({index:e,registerItem:t,role:n,isSelected:r,tabIndex:i,onClick:a,onKeyDown:o,shape:c,chipContent:l,chipFilled:u,isMulti:d,ariaLabel:f,showArrow:p,arrowIcon:m,onArrowClick:h,bodyLayout:g=`inline`,topAlign:_=!1,chipPosition:y=`right`,hiddenControl:b,children:S,...C}){let w=(0,Q.useRef)(null);(0,Q.useEffect)(()=>(t(e,w.current),()=>t(e,null)),[e,t]);let T=(0,$.jsx)(ne,{children:p&&(0,$.jsx)(x.span,{"aria-hidden":!h,role:h?`button`:void 0,onClick:h?e=>{e.stopPropagation(),h()}:void 0,className:s(`absolute inset-0 inline-flex items-center justify-center bg-foreground text-background`,c.bg,h&&`cursor-pointer`),initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:P.fast.exit},transition:{...P.fast,opacity:{duration:.08}},children:m})}),E=(0,$.jsxs)(`span`,{className:s(`shrink-0 w-7 h-7 relative inline-flex items-center justify-center`,_&&(g===`stacked`?`-mt-[1px]`:`-mt-[5px]`)),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:s(`absolute inline-flex items-center justify-center w-5 h-5 text-[11px] transition-[opacity,font-variation-settings] duration-80`,d&&c.bg,d?u?`bg-foreground text-background`:`border border-border text-muted-foreground`:u?`text-foreground`:`text-muted-foreground`,y===`right`&&p&&`opacity-0`),style:{fontVariationSettings:u?v.semibold:v.medium},children:l}),y===`right`&&T]}),D=y===`left`&&!d&&(0,$.jsx)(`span`,{className:s(`shrink-0 w-7 h-7 relative inline-flex items-center justify-center`,_&&(g===`stacked`?`-mt-[1px]`:`-mt-[5px]`)),children:T});return(0,$.jsxs)(`div`,{ref:w,"data-proximity-index":e,"data-state":r?`checked`:`unchecked`,role:n??void 0,"aria-checked":n===`radio`||n===`checkbox`?!!C[`aria-checked`]:void 0,"aria-label":f,tabIndex:i,onMouseDown:e=>{let t=e.target.closest(`button:not([tabindex="-1"]), a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);t&&t!==e.currentTarget||(e.preventDefault(),e.currentTarget.focus())},onClick:a,onKeyDown:o,className:s(`relative z-10 flex cursor-pointer select-none outline-none`,y===`left`?`gap-2`:`gap-3`,_?`items-start`:`items-center`,g===`stacked`?`min-h-14 py-2`:`min-h-10 py-1.5`,y===`left`?d?`pl-1.5 pr-3`:`pl-1.5 pr-1.5`:`pl-3 pr-1.5`,c.item),children:[y===`left`&&E,(0,$.jsx)(`span`,{className:s(`min-w-0 flex-1 text-[13px] leading-snug`,g===`stacked`?`flex flex-col gap-0.5`:`inline-flex items-center gap-0`),children:S}),y===`right`?E:D,b]})}function bi(e){if(e.mode===`url`&&`url`in e)return[{id:`__url_confirm__`,title:`Confirm completion`,layout:`stacked`,options:[{id:`confirmed`,title:`I've completed the required action`,description:e.url}],skippable:!1,nextLabel:`Confirm`}];let t=`requestedSchema`in e?e.requestedSchema:void 0;if(!t||t.type!==`object`||!t.properties)return[{id:`__freeform__`,title:`Your response`,freeText:!0,freeTextPlaceholder:`Type your response…`,skippable:!1}];let n=t.properties,r=t.required??[];return Object.entries(n).map(([e,t])=>{let n=t,i=r.includes(e),a=n.title||e,o=n.description,s=n.type||`string`,c=Yt(n),l=Xt(n),u=Array.isArray(n.enum),d=s===`array`&&Array.isArray(n.items?.enum),f=s===`array`&&l.length>0,p={id:e,title:a,skippable:!i,layout:o&&o.length>60?`stacked`:`inline`};if(s===`boolean`)return{...p,options:[{id:`true`,title:`Yes`},{id:`false`,title:`No`}]};if(f||d){let e=f?l:n.items.enum.map(e=>({const:e,title:e}))??[];return{...p,multiSelect:!0,options:e.map(e=>({id:e.const,title:e.title||e.const}))}}if(c.length>0)return{...p,layout:`stacked`,options:c.map(e=>({id:e.const,title:e.title||e.const}))};if(u){let e=n.enum,t=n.enumNames;return{...p,options:e.map((e,n)=>({id:e,title:t?.[n]||e}))}}return s===`number`||s===`integer`?{...p,freeText:!0,freeTextMultiline:!1,freeTextPlaceholder:n.default===void 0?`Enter a number…`:String(n.default),freeTextValidate:e=>{let t=e.trim();if(!t)return i?`Required`:null;let n=s===`integer`?parseInt(t,10):parseFloat(t);return Number.isNaN(n)?`Enter a valid number`:null}}:s===`string`&&(n.format===`textarea`||(n.maxLength??0)>100)?{...p,freeText:!0,freeTextPlaceholder:n.default||`Type your answer…`}:{...p,freeText:!0,freeTextMultiline:!1,freeTextPlaceholder:n.default===void 0?`Type your answer…`:String(n.default),freeTextValidate:e=>!e.trim()&&i?`Required`:null}})}function xi(e,t,n){if(n.mode===`url`)return{};let r=`requestedSchema`in n?n.requestedSchema:void 0,i=r?.type===`object`&&r.properties?r.properties:{},a={};for(let n of e){let e=n.id??``;if(e===`__freeform__`){let n=t[e]?.otherText?.trim();n&&(a.response=n);continue}let r=t[e];if(!r||r.skipped)continue;let o=i[e]?.type||`string`;if(n.freeText){let t=r.otherText?.trim()??``;if(!t)continue;a[e]=o===`number`||o===`integer`?o===`integer`?parseInt(t,10):parseFloat(t):t;continue}if(n.multiSelect){a[e]=r.selectedIds;continue}if(o===`boolean`){a[e]=r.selectedIds[0]===`true`;continue}r.selectedIds[0]!==void 0&&(a[e]=r.selectedIds[0])}return a}function Si(e,t,n){if(n.mode===`url`)return[];let r=`requestedSchema`in n?n.requestedSchema:void 0;return(r?.type===`object`?r.required??[]:[]).filter(n=>{let r=t[n];if(!r||r.skipped)return!0;let i=e.find(e=>e.id===n);return i?i.freeText?!r.otherText?.trim():(i.multiSelect,r.selectedIds.length===0):!0})}function Ci(e,t){if(t.mode===`url`)return{};let n=`requestedSchema`in t?t.requestedSchema:void 0,r=n?.type===`object`&&n.properties?n.properties:{},i={};for(let t of e){let e=t.id;if(!e||e.startsWith(`__`))continue;let n=r[e];if(!(!n||n.default===void 0)){if(t.freeText){i[e]={questionId:e,selectedIds:[],otherText:String(n.default),skipped:!1};continue}if(t.multiSelect&&Array.isArray(n.default)){i[e]={questionId:e,selectedIds:n.default.map(String),skipped:!1};continue}if(n.type===`boolean`){i[e]={questionId:e,selectedIds:[String(n.default)],skipped:!1};continue}i[e]={questionId:e,selectedIds:[String(n.default)],skipped:!1}}}return i}function wi({request:e,onApprove:t,onReject:n,testId:r=`inline-elicitation`,actionTestIdPrefix:i=`inline-elicitation`}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),l=(0,Q.useMemo)(()=>bi(e.request),[e.request]),u=(0,Q.useMemo)(()=>Ci(l,e.request),[l,e.request]),d=(e.request.mode||`form`)===`url`,f=d&&`url`in e.request?e.request.url:void 0,p=(n,r)=>{o(!0),c(n),t(e.id,r)};return a?(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,"data-testid":`${r}-responded`,children:[`Elicitation `,s,` — the tool will continue executing.`]}):(0,$.jsx)(_i,{questions:l,defaultAnswers:u,onComplete:t=>{if(a)return;if(d){if(!t.__url_confirm__?.selectedIds.includes(`confirmed`)){ot.error(`Confirm you've completed the external action`);return}p(`accepted`,{action:`accept`});return}let n=Si(l,t,e.request);if(n.length>0){ot.error(`Missing required fields`,{description:`Please fill in: ${n.join(`, `)}`});return}p(`accepted`,{action:`accept`,content:xi(l,t,e.request)})},intro:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-foreground/90`,children:e.request.message}),d&&f&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-muted/40 p-2`,children:[(0,$.jsx)(`code`,{className:`flex-1 text-xs font-mono break-all`,children:f}),(0,$.jsxs)(F,{size:`sm`,variant:`outline`,onClick:()=>window.open(f,`_blank`),"data-testid":`${i}-open-url`,children:[(0,$.jsx)(ct,{className:`h-3 w-3 mr-1`}),`Open`]})]})]}),onCancel:()=>n(e.id,`User cancelled elicitation request`),cancelLabel:`Cancel`,footerLeading:(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 cursor-pointer text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline`,onClick:()=>p(`declined`,{action:`decline`}),"data-testid":`${i}-decline-button`,children:`Decline`}),className:`w-full max-w-none shadow-lg`,"data-testid":r})}function Ti({requests:e,onApprove:t,onReject:n}){return e.length===0?null:(0,$.jsx)(`div`,{className:`mb-3 space-y-3 pointer-events-auto`,"data-testid":`floating-elicitation-stack`,children:e.map(e=>(0,$.jsx)(x.div,{initial:{opacity:0,y:12,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.98},transition:P.moderate,children:(0,$.jsx)(wi,{request:e,onApprove:t,onReject:n})},e.id))})}var Ei=`You are a helpful assistant with access to MCP tools. Help users interact with the MCP server.`;function Di(e){let t=e?.trim();return t?t!==Ei:!1}function Oi({value:e,onSave:t,disabled:n,isSaving:r=!1,compact:i=!1}){let[a,o]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(e??``),[u,d]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{l(e??``)},[e]);let f=(0,Q.useCallback)(async()=>{d(!0);try{await t(c),o(!1)}finally{d(!1)}},[c,t]),p=r||u,m=Di(e),g=(0,$.jsxs)(`button`,{type:`button`,"data-testid":`chat-system-prompt-button`,onClick:()=>o(!0),disabled:n,className:i?s(`inline-flex h-auto w-auto aspect-square items-center justify-center rounded-full p-2 transition-colors disabled:pointer-events-none disabled:opacity-50`,m?`text-amber-500 dark:text-amber-400`:`text-muted-foreground hover:text-foreground`):s(`inline-flex h-9 items-center justify-center gap-1.5 rounded-full border border-input bg-secondary px-3 text-sm font-medium shadow-xs transition-colors hover:bg-secondary/80 disabled:pointer-events-none disabled:opacity-50`,m?`text-amber-600 dark:text-amber-400`:`text-secondary-foreground`),children:[(0,$.jsx)(rn,{className:`h-4 w-4`}),!i&&(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`System Prompt`})]});return(0,$.jsxs)(Ne,{open:a,onOpenChange:o,children:[i?(0,$.jsxs)(O,{children:[(0,$.jsx)(h,{render:g,nativeButton:!0}),(0,$.jsx)(N,{side:`top`,children:(0,$.jsx)(`p`,{children:m?`Custom system prompt`:`System Prompt`})})]}):g,(0,$.jsxs)(_e,{className:`sm:max-w-xl`,children:[(0,$.jsx)(Ie,{children:(0,$.jsx)(we,{children:`System Prompt`})}),(0,$.jsx)(qt,{value:c,onChange:e=>l(e.target.value),placeholder:`Describe the assistant's behavior...`,className:`min-h-[160px] text-sm`}),(0,$.jsx)(Te,{children:(0,$.jsxs)(F,{size:`sm`,onClick:f,disabled:p||c===(e??``),className:`gap-1.5`,children:[p?(0,$.jsx)(nt,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(gt,{className:`h-3.5 w-3.5`}),`Save`]})})]})]})}function ki({inputValue:e,isConnected:t,isLoading:n,textareaRef:r,llmConfig:i,promptsDropdownOpen:a,promptFocusedIndex:o,prompts:c,selectedPrompt:l,promptResults:u,attachments:d,tools:f,disabledTools:p,onDisabledToolsChange:m,onInputChange:g,onKeyDown:_,onKeyUp:v,onClick:y,onSendMessage:b,onStopStreaming:x,onConfigDialogOpenChange:S,onPromptSelect:C,onDeletePromptResult:w,onAttachmentAdd:T,onAttachmentRemove:E,hideModelBadge:D,freeTierInfo:k,managedCloudInfo:A,modelBadgeMode:j=`byok`,modelDisplayName:M,followups:P=[],onFollowupSelect:ee,pendingElicitationRequests:te,onApproveElicitation:I,onRejectElicitation:L,systemPromptProvider:R}){let z=e.trim()||u.length>0||d.length>0,B=(te?.length??0)>0,V=i&&(!D||k||A)?(0,$.jsxs)(O,{children:[(0,$.jsx)(h,{render:(0,$.jsx)(tt,{provider:i.provider,model:i.model,displayName:M,mode:j,className:`shrink-0`,onClick:()=>S(!0)}),nativeButton:!0}),(0,$.jsx)(N,{children:(0,$.jsx)(`p`,{children:A||k?`Change model`:`Change API Key`})})]}):null;return(0,$.jsx)(`div`,{className:`w-full flex shrink-0 flex-col items-center px-2 pb-2 pt-0 sm:px-4 sm:pb-2 text-foreground`,children:(0,$.jsxs)(`div`,{className:`relative w-full max-w-3xl backdrop-blur-xl`,children:[B&&I&&L&&(0,$.jsx)(Ti,{requests:te,onApprove:I,onReject:L}),P.length>0&&(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:P.map(e=>(0,$.jsx)(F,{type:`button`,variant:`outline`,size:`sm`,className:`rounded-full`,onClick:()=>ee?.(e),disabled:n||!t,children:e},e))}),(0,$.jsx)(Dr,{isOpen:a,prompts:c,selectedPrompt:l,focusedIndex:o,onPromptSelect:C}),(0,$.jsx)(Er,{promptResults:u,onDeletePromptResult:w}),(0,$.jsx)(Tr,{inputValue:e,isConnected:t,isLoading:n,textareaRef:r,attachments:d,placeholder:`Ask a question or request an action...`,className:s(`bg-white/80 dark:text-white dark:bg-black backdrop-blur-sm border-gray-200 dark:border-zinc-800`,u.length>0&&`pt-16`),tools:f,disabledTools:p,onDisabledToolsChange:m,onInputChange:g,onKeyDown:_,onKeyUp:v,onClick:y,onAttachmentAdd:T,onAttachmentRemove:E,inlineControls:i&&R?(0,$.jsx)(Oi,{compact:!0,value:R.prompt,onSave:R.savePrompt,disabled:!t||n||R.disabled,isSaving:R.isSaving}):null,trailingControls:(0,$.jsxs)($.Fragment,{children:[V,(0,$.jsx)(F,{type:`button`,size:`sm`,className:s(`h-8 w-8 rounded-full p-0`,n&&`animate-spin`,!z&&!n&&`bg-zinc-400`),disabled:!n&&(!z||!t||B),title:n?`Stop streaming`:`Send`,onClick:n?x:b,"data-testid":`chat-send-button`,children:n?(0,$.jsx)(nt,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Ge,{className:`h-3.5 w-3.5`})})]})})]})})}function Ai({serverDisplayName:e,composerNotice:t,quickQuestions:n=[],onQuickQuestionSelect:r,...i}){return(0,$.jsx)(`div`,{className:`flex h-full flex-col items-center justify-center`,children:(0,$.jsxs)(De,{className:`w-full max-w-4xl mx-auto px-2 sm:px-4`,children:[(0,$.jsxs)(`div`,{className:`text-center mb-6 sm:mb-8`,children:[(0,$.jsxs)(`h1`,{className:`text-2xl sm:text-4xl font-light mb-2 dark:text-white`,"data-testid":`chat-landing-header`,children:[`Chat with `,e]}),(0,$.jsx)(`p`,{className:`mx-auto max-w-xl text-sm text-muted-foreground sm:text-base`,"data-testid":`chat-landing-description`,children:`Chat, inspect traces, preview widgets, and more.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[t,(0,$.jsx)(ki,{...i}),n.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-2 px-2`,children:n.map(e=>(0,$.jsx)(F,{type:`button`,variant:`outline`,size:`sm`,className:`rounded-full bg-white/70 dark:bg-black/50 text-gray-900 dark:text-white`,onClick:()=>r?.(e),disabled:i.isLoading||!i.isConnected,children:e},e))})]})]})})}function ji({onConfigureClick:e}){return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center`,children:[(0,$.jsx)(Ue,{className:`h-12 w-12 text-muted-foreground mb-4`}),(0,$.jsx)(`h3`,{className:`text-lg font-semibold mb-2`,children:`Configure Your LLM Provider`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4 max-w-md`,children:`To start chatting with the MCP server, you need to configure your LLM provider and API key. Your credentials are stored locally and used only for this chat.`}),(0,$.jsxs)(F,{onClick:e,"data-testid":`chat-configure-api-key-button`,children:[(0,$.jsx)(Ve,{className:`h-4 w-4 mr-2`}),`Configure API Key`]})]})}function Mi({children:e,as:t=`p`,className:n,duration:r=2,spread:i=2}){let a=x.create(t),o=(0,Q.useMemo)(()=>e.length*i,[e,i]);return(0,$.jsx)(a,{className:s(`relative inline-block bg-[length:250%_100%,auto] bg-clip-text`,`text-transparent [--base-color:#a1a1aa] [--base-gradient-color:#000]`,`[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]`,`dark:[--base-color:#71717a] dark:[--base-gradient-color:#ffffff] dark:[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))]`,n),initial:{backgroundPosition:`100% center`},animate:{backgroundPosition:`0% center`},transition:{repeat:1/0,duration:r,ease:`linear`},style:{"--spread":`${o}px`,backgroundImage:`var(--bg), linear-gradient(var(--base-color), var(--base-color))`},children:e})}function Ni(e){let t=e.match(/```/g);return t&&t.length%2==1?`${e}\n\`\`\``:e}var Pi=(0,Q.memo)(function({content:e,isStreaming:t=!1}){let n=(0,Q.useMemo)(()=>t?Ni(e):e,[e,t]);return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Nt,{className:s(`text-[14px] leading-relaxed text-foreground`,`[&_p]:mb-2 [&_p:last-child]:mb-0`,`[&_pre]:my-3 [&_ul]:mb-2 [&_ol]:mb-2`),content:n}),t?(0,$.jsx)(`span`,{className:`inline-block w-0.5 h-[1em] ml-0.5 -mt-1 align-middle bg-foreground/60 animate-pulse`,"aria-hidden":!0}):null]})});function Fi(){let[e,t]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(typeof window>`u`)return;let e=new AbortController,{signal:n}=e,r=()=>{let e=`ontouchstart`in window||navigator.maxTouchPoints>0,n=window.matchMedia(`(pointer: coarse)`).matches;t(e&&n)};return window.matchMedia(`(pointer: coarse)`).addEventListener(`change`,r,{signal:n}),window.addEventListener(`pointerdown`,r,{signal:n}),r(),()=>e.abort()},[]),e}function Ii({size:e}){return(0,$.jsxs)(`svg`,{width:Math.max(16,e*.35),height:Math.max(16,e*.35),viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,$.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,$.jsx)(`path`,{d:`M14 3v5h5`})]})}function Li({file:e,size:t,className:n}){let r=o(),i=e.type.startsWith(`image/`),[a,c]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!i){c(null);return}let t=URL.createObjectURL(e);return c(t),()=>URL.revokeObjectURL(t)},[i,e]);let l=i&&!a;return(0,$.jsx)(`div`,{className:s(`relative shrink-0 overflow-hidden bg-accent border border-border`,r.bg,n),style:{width:t,height:t},children:a?(0,$.jsx)(`img`,{src:a,alt:e.name,className:`absolute inset-0 w-full h-full object-cover`}):l?(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,$.jsx)(`div`,{className:`w-6 h-6 rounded-full border-2 border-border border-t-muted-foreground animate-spin`,"aria-label":`Loading preview`,role:`status`})}):(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-muted-foreground`,role:`img`,"aria-label":e.name,children:(0,$.jsx)(Ii,{size:t})})})}var Ri=(0,Q.forwardRef)(({from:e,files:t,thumbnailSize:n=64,time:r,actions:i,children:a,className:c,...l},u)=>{let d=o(),f=e===`user`,p=Fi(),m=f&&r!=null;return(0,$.jsxs)(x.div,{ref:u,layout:`position`,initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},transition:P.moderate,style:{transformOrigin:f?`bottom right`:`bottom left`},className:s(`group flex max-w-[80%] flex-col gap-1.5`,f?`items-end self-end`:`items-start self-start`,c),...l,children:[t&&t.length>0&&(0,$.jsx)(`div`,{className:s(`flex flex-wrap gap-1.5`,f?`justify-end`:`justify-start`),children:t.map((e,t)=>(0,$.jsx)(Li,{file:e,size:n},`${e.name}-${e.size}-${e.lastModified}-${t}`))}),a!=null&&a!==``&&(0,$.jsx)(`div`,{className:s(`py-2 text-[14px] whitespace-pre-wrap break-words`,f?s(d.bg,`px-3.5 text-pretty bg-[color-mix(in_oklab,var(--accent),var(--background)_45%)] text-accent-foreground`):`text-foreground`),children:a}),(m||i!=null)&&(0,$.jsxs)(`div`,{className:s(`flex items-center gap-2 px-1 text-[12px] leading-none text-muted-foreground select-none`,!p&&[`opacity-0 pointer-events-none transition-opacity duration-150`,`group-hover:opacity-100 group-hover:pointer-events-auto`,`group-focus-within:opacity-100 group-focus-within:pointer-events-auto`]),children:[m&&(0,$.jsx)(`span`,{className:`tabular-nums`,children:r}),i!=null&&(0,$.jsx)(`span`,{className:`flex items-center gap-0.5`,children:i})]})]})});Ri.displayName=`ChatMessage`;function zi({text:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground flex items-center rounded p-0.5`,onClick:async()=>{await Ct(e),n(!0),setTimeout(()=>n(!1),2e3)},title:`Copy message content`,"data-testid":`copy-button`,children:t?(0,$.jsx)(gt,{className:`h-3.5 w-3.5`}):(0,$.jsx)(et,{className:`h-3.5 w-3.5`})})}function Bi(e,t){let n=e===1?`token`:`tokens`;return`${e.toLocaleString()} ${n} ${t}`}function Vi({variant:e,copyText:t,inputTokens:n,outputTokens:r}){let i=!!t,a=e===`user`&&n!=null?Bi(n,`in`):e===`assistant`&&r!=null?Bi(r,`out`):null;if(!i&&!a)return null;let o=i?(0,$.jsx)(zi,{text:t}):null,s=a?(0,$.jsx)(`span`,{className:`tabular-nums`,title:e===`user`?`Input tokens`:`Output tokens`,"data-testid":e===`user`?`message-input-tokens`:`message-output-tokens`,children:a}):null;return e===`user`?(0,$.jsxs)($.Fragment,{children:[s,o]}):(0,$.jsxs)($.Fragment,{children:[o,s]})}function Hi({content:e,timestamp:t,_isStreaming:n,outputTokens:r}){return!e||e.length===0?null:(0,$.jsxs)(`div`,{"data-testid":`chat-message-assistant`,children:[(0,$.jsx)(Ri,{from:`assistant`,actions:(0,$.jsx)(Vi,{variant:`assistant`,copyText:e,outputTokens:r}),"data-testid":`chat-message-content`,children:(0,$.jsx)(Pi,{content:e,isStreaming:n})}),t!=null&&(0,$.jsx)(`span`,{className:`sr-only`,children:new Date(t).toLocaleTimeString()})]})}function Ui({toolName:e,args:t,result:n,state:r=`result`,partialArgs:i}){let a=r===`call`&&i?i:t,o=()=>{switch(r){case`call`:return(0,$.jsx)(nt,{className:`h-4 w-4 animate-spin text-blue-500 dark:text-blue-400`});case`result`:return(0,$.jsx)(gt,{className:`h-4 w-4 text-emerald-800 dark:text-emerald-400`});case`error`:return(0,$.jsx)(Oe,{className:`h-4 w-4 text-red-500 dark:text-red-400`});default:return(0,$.jsx)(gt,{className:`h-4 w-4 text-emerald-800 dark:text-emerald-400`})}},c=()=>{switch(r){case`call`:return` bg-blue-500/20 dark:bg-blue-500/20`;case`result`:return` bg-emerald-500/20 dark:bg-emerald-500/20`;case`error`:return` bg-red-500/20 dark:bg-red-500/20`;default:return` bg-emerald-500/20 dark:bg-emerald-500/20`}},l=e=>typeof e==`object`?yt(e).preview:String(e);return(0,$.jsxs)(Ke,{children:[(0,$.jsx)(st,{render:(0,$.jsxs)(`div`,{className:`flex max-w-min items-center gap-3 p-1 rounded-full border bg-card hover:bg-accent/50 transition-colors cursor-pointer my-4`,"data-testid":`chat-tool-call-${e}`,children:[(0,$.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 flex items-center justify-center shrink-0`,children:(0,$.jsx)(lt,{className:`size-4 text-muted-foreground`})}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`span`,{className:`text-sm font-medium truncate`,children:[e,`(`,Object.keys(a).length>0?(0,$.jsxs)(`span`,{className:`bg-muted-foreground/20 rounded-full px-1.5 mx-1 py-0.5 text-xs`,children:[Object.keys(a).length,` args`]}):``,`)`]})})}),(0,$.jsx)(`div`,{className:s(`w-8 h-8 rounded-full flex items-center justify-center`,c()),"data-testid":`chat-tool-call-status-${r}`,children:o()})]}),nativeButton:!1}),(0,$.jsxs)(Z,{side:`right`,className:`w-[400px] sm:w-[540px] p-4 overflow-y-auto`,"data-testid":`chat-tool-drawer`,children:[(0,$.jsxs)(Je,{children:[(0,$.jsxs)(Xe,{className:`flex items-center gap-2`,children:[(0,$.jsx)(lt,{className:`h-5 w-5`}),`Tool Call Details`]}),(0,$.jsxs)(mt,{className:`flex items-center gap-2`,children:[e,` — `,r,r===`call`&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-blue-500 dark:text-blue-400`,children:[(0,$.jsx)(nt,{className:`h-3 w-3 animate-spin`}),`streaming…`]})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Arguments`}),(0,$.jsxs)(`div`,{className:`relative`,"data-testid":`chat-tool-drawer-args`,children:[(0,$.jsx)(`pre`,{className:`text-xs bg-muted/50 rounded-lg p-3 overflow-x-auto border font-mono leading-relaxed max-h-48 whitespace-pre-wrap break-words`,children:l(a)}),(0,$.jsx)(F,{variant:`ghost`,size:`sm`,onClick:()=>Ct(l(a)),className:`absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100`,title:`Copy arguments`,children:(0,$.jsx)(et,{className:`h-3 w-3`})})]})]}),n&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Result`}),(0,$.jsx)(`div`,{className:`relative`,"data-testid":`chat-tool-drawer-result`,children:typeof n==`string`?(0,$.jsxs)(`div`,{className:s(`p-3 rounded-lg border text-sm leading-relaxed max-h-48 overflow-x-auto whitespace-pre-wrap break-words max-w-full`,r===`error`?`bg-destructive/10 border-destructive/20 text-destructive-foreground`:`bg-muted/30 border-border`),children:[n.startsWith(`Error`)?(0,$.jsxs)(`div`,{className:`font-mono`,children:[(0,$.jsx)(`div`,{className:`font-semibold text-destructive mb-1`,children:`Error:`}),(0,$.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:n.replace(/^Error:\s*/,``)})]}):(0,$.jsx)(`div`,{className:`whitespace-pre-wrap font-mono break-words`,children:n}),(0,$.jsx)(F,{variant:`ghost`,size:`sm`,onClick:()=>Ct(n),className:`absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100`,title:`Copy result`,children:(0,$.jsx)(et,{className:`h-3 w-3`})})]}):(0,$.jsxs)(`div`,{className:s(`p-3 rounded-lg border text-sm leading-relaxed max-h-96 overflow-y-auto max-w-full`,r===`error`?`bg-destructive/10 border-destructive/20 text-destructive-foreground`:`bg-muted/30 border-border`),children:[(0,$.jsx)(We,{data:n,filename:`tool-call-${e}-result-${Date.now()}.json`}),(0,$.jsx)(F,{variant:`ghost`,size:`sm`,onClick:()=>Ct(JSON.stringify(n,null,2)),className:`absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100`,title:`Copy result`,children:(0,$.jsx)(et,{className:`h-3 w-3`})})]})})]})]})]})]})}function Wi({widgetId:e}){let{getWidget:t}=it(),n=t(e)?.modelContext;if(!n?.content?.length&&!n?.structuredContent)return null;let r=n.content?.map(e=>e.text).join(` `)??JSON.stringify(n.structuredContent).slice(0,80);return(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] text-muted-foreground bg-muted/30 border border-border/40 rounded-md mt-1`,children:[(0,$.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-blue-400 shrink-0`}),(0,$.jsx)(`span`,{className:`font-medium`,children:`State synced to model`}),(0,$.jsx)(`span`,{className:`truncate opacity-60 max-w-[300px]`,children:r})]})}function Gi({toolName:e,toolArgs:t,result:n,serverId:r,readResource:i,toolMeta:a,onSendFollowUp:o,partialToolArgs:s,cancelled:c}){let l=(0,Q.useMemo)(()=>`chat-tool-${e}-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,[e]),u=(0,Q.useMemo)(()=>{if(!n)return null;if(typeof n==`string`)try{return JSON.parse(n)}catch{return n}return n},[n]),d=vt(a),f=d?a?.ui?.resourceUri??null:null,p=(0,Q.useMemo)(()=>t,[e,u]),m=(0,Q.useMemo)(()=>u,[e,u]),h=Zt({serverId:r??``,viewId:l,resourceUri:f??``,toolName:e,toolInput:p,toolOutput:m,toolMetadata:a,readResource:i??(async()=>({}))});return d&&f&&r&&i&&h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xt,{viewId:l,toolName:e,toolInput:p,toolOutput:m,partialToolInput:s,cancelled:c,className:`my-4`,onMessage:e=>{e.length>0&&o&&o(e)},...h}),(0,$.jsx)(Wi,{widgetId:l})]}):d&&!f?(0,$.jsx)(`div`,{className:`flex items-center justify-center w-full h-[200px] rounded border`,children:(0,$.jsx)(Ce,{className:`size-5`})}):d&&(!r||!i)?(0,$.jsx)(`div`,{className:`my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg`,children:(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`Cannot render widget: Missing required props (serverId or readResource)`})}):null}function Ki(e){let t=atob(e.data),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new File([n],e.name||`attachment`,{type:e.mimeType})}function qi({content:e,timestamp:t,attachments:n,inputTokens:r}){let i=(0,Q.useMemo)(()=>n?.map(Ki),[n]);return(!e||e.length===0)&&(!n||n.length===0)?null:(0,$.jsx)(`div`,{"data-testid":`chat-message-user`,className:`flex flex-col items-end`,children:(0,$.jsx)(Ri,{from:`user`,files:i,time:t?new Date(t).toLocaleTimeString():void 0,actions:e||r!=null?(0,$.jsx)(Vi,{variant:`user`,copyText:e||void 0,inputTokens:r}):void 0,"data-testid":`chat-message-content`,children:e&&e.length>0?e:void 0})})}var Ji={events:[],spans:[]};function Yi(e){if(!e||typeof e!=`object`)return;let t=e,n=(...e)=>{for(let n of e)if(typeof t[n]==`number`)return t[n]},r=n(`inputTokens`,`input_tokens`,`promptTokens`),i=n(`outputTokens`,`output_tokens`,`completionTokens`),a=n(`totalTokens`,`total_tokens`)??(r!==void 0&&i!==void 0?r+i:void 0);if(!(r===void 0&&i===void 0&&a===void 0))return{inputTokens:r,outputTokens:i,totalTokens:a}}var Xi=new Set([`apikey`,`authorization`,`accesstoken`,`refreshtoken`,`password`,`cookie`,`secret`]);function Zi(e){return Array.isArray(e)?e.map(Zi):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Xi.has(e.toLowerCase().replace(/[_-]/g,``))?`[REDACTED]`:Zi(t)]))}function Qi(e,t=120){let n;try{n=JSON.stringify(e)}catch{n=String(e)}return n.length>t?`${n.slice(0,t)}…`:n}function $i(e){switch(e.type){case`request`:return`LLM request`;case`text-delta`:return e.delta.trim()||`Text delta`;case`tool-call-start`:return e.toolName;case`tool-call-args`:return Qi(e.args);case`tool-result`:return Qi(e.result);case`usage`:return`${e.usage.totalTokens??`?`} tokens`;case`error`:return e.message;case`done`:return`Completed`;default:return e}}function ea(e,t){let n=(e,t)=>e===void 0&&t===void 0?void 0:(e??0)+(t??0);return{inputTokens:n(e?.inputTokens,t.inputTokens),outputTokens:n(e?.outputTokens,t.outputTokens),totalTokens:n(e?.totalTokens,t.totalTokens),cachedInputTokens:n(e?.cachedInputTokens,t.cachedInputTokens),reasoningTokens:n(e?.reasoningTokens,t.reasoningTokens)}}function ta(e,t){let n=e.spans.map(e=>({...e})),r=e.usage,i=[...n].reverse().find(e=>e.kind===`llm`&&e.status===`running`);if(t.type===`request`)n.push({id:`llm-${t.id}`,kind:`llm`,name:`LLM`,status:`running`,startedAt:t.timestamp,preview:$i(t)});else if((t.type===`text-delta`||t.type===`tool-call-start`)&&!i)i={id:`llm-${t.id}`,kind:`llm`,name:`LLM`,status:`running`,startedAt:t.timestamp,preview:t.type===`text-delta`?$i(t):`LLM response`},n.push(i),t.type===`tool-call-start`&&n.push({id:t.toolCallId,kind:`tool`,name:t.toolName,status:`running`,startedAt:t.timestamp,preview:$i(t)});else if(t.type===`tool-call-start`)n.push({id:t.toolCallId,kind:`tool`,name:t.toolName,status:`running`,startedAt:t.timestamp,preview:$i(t)});else if(t.type===`tool-call-args`){let e=n.find(e=>e.id===t.toolCallId);e&&(e.preview=$i(t))}else if(t.type===`tool-result`){let e=t.toolCallId?n.find(e=>e.id===t.toolCallId):[...n].reverse().find(e=>e.kind===`tool`&&e.name===t.toolName&&e.status===`running`);e&&(e.status=t.isError?`error`:`success`,e.endedAt=t.timestamp,e.preview=$i(t))}else t.type===`usage`?(r=ea(r,t.usage),i&&(i.usage=ea(i.usage,t.usage))):(t.type===`error`||t.type===`done`)&&i&&(i.status=t.type===`error`?`error`:`success`,i.endedAt=t.timestamp,i.preview=$i(t));return{events:[...e.events,t],spans:n,usage:r}}function na(e,t){let n=[],r=null;for(let t of e)t.type===`request`?(r&&n.push(r),r={request:t,response:[]}):r&&r.response.push(t);return r&&n.push(r),{turns:n,tokenUsage:t??null}}function ra(e){let t;for(let n of e)n.type===`usage`&&(t=ea(t,n.usage));return t}function ia(e){let t=[],n=0;for(;n<e.length;){if(e[n]?.role!==`user`){n++;continue}let r=e[n].id;n++;let i=null;for(;n<e.length&&e[n]?.role===`assistant`;)i=e[n].id,n++;t.push({userId:r,assistantId:i})}return t}function aa(e,t){let{turns:n}=na(t),r=ia(e),i=new Map,a=Math.min(n.length,r.length);for(let e=0;e<a;e++){let t=ra(n[e].response);if(!t)continue;let{userId:a,assistantId:o}=r[e];t.inputTokens!=null&&i.set(a,{...i.get(a),inputTokens:t.inputTokens}),o!=null&&t.outputTokens!=null&&i.set(o,{...i.get(o),outputTokens:t.outputTokens})}return i}var oa=(0,Q.memo)(({messages:e,isLoading:t,serverId:n,readResource:r,tools:i,sendMessage:a,messagesEndRef:o,traceEvents:s=[]})=>{let c=(0,Q.useMemo)(()=>aa(e,s),[e,s]),l=e=>{let t=e=>e.replace(/-/g,`_`),n=t(e);return i?.find(e=>t(e.name)===n)?._meta},u=e=>vt(l(e)),d=(0,Q.useCallback)(e=>{let t=e.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
|
|
3
|
-
`),n=e.filter(e=>e.type===`image`&&`data`in e&&`mimeType`in e).map(e=>({type:`image`,data:e.data,mimeType:e.mimeType}));a?.(t,n.length>0?n:void 0)},[a]),f=t&&(()=>{if(e.length===0)return!0;let t=e[e.length-1];if(t.role===`user`)return!0;if(t.role===`assistant`){if(t.parts&&t.parts.length>0)return!1;let e=typeof t.content==`string`?t.content:Array.isArray(t.content)?t.content.map(e=>typeof e==`string`?e:e.text||JSON.stringify(e)).join(``):JSON.stringify(t.content);return!(e&&e.trim().length>0)}return!1})(),p=e[e.length-1],m=t&&p?.role===`assistant`,h=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.type===`text`)return t;return-1},g=(e,t,n)=>m&&e.id===p?.id&&t===h(n),_=e=>m&&e.id===p?.id;return(0,$.jsxs)(`div`,{className:`space-y-6 max-w-3xl mx-auto px-2`,children:[e.map(e=>{let t=typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>typeof e==`string`?e:e.text||JSON.stringify(e)).join(``):JSON.stringify(e.content);if(e.role===`user`)return(0,$.jsx)(qi,{content:t,timestamp:e.timestamp,attachments:e.attachments,inputTokens:c.get(e.id)?.inputTokens},e.id);if(e.role===`assistant`){let i=c.get(e.id)?.outputTokens,a=e.parts&&e.parts.length>0?h(e.parts):-1;return(0,$.jsx)(`div`,{className:`space-y-4`,children:e.parts&&e.parts.length>0?e.parts.map((t,o)=>{let s=t.type===`text`?`${e.id}-text-${o}`:`${e.id}-tool-${t.toolInvocation?.toolName}-${o}`;return t.type===`text`?(0,$.jsx)(Hi,{content:t.text||``,timestamp:o===e.parts.length-1?e.timestamp:void 0,_isStreaming:g(e,o,e.parts),outputTokens:o===a?i:void 0},s):t.type===`tool-invocation`&&t.toolInvocation?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Ui,{toolName:t.toolInvocation.toolName,args:t.toolInvocation.args,result:t.toolInvocation.result,state:t.toolInvocation.state===`error`?`error`:t.toolInvocation.state===`streaming`||t.toolInvocation.state===`pending`?`call`:`result`,partialArgs:t.toolInvocation.partialArgs}),(t.toolInvocation.result||t.toolInvocation.state===`streaming`||u(t.toolInvocation.toolName))&&(0,$.jsx)(`div`,{"data-tool-call-id":`${e.id}-${t.toolInvocation.toolName}-${o}`,children:(0,$.jsx)(Gi,{toolName:t.toolInvocation.toolName,toolArgs:t.toolInvocation.args,result:t.toolInvocation.result||null,serverId:n,readResource:r,toolMeta:l(t.toolInvocation.toolName),onSendFollowUp:d,partialToolArgs:t.toolInvocation.partialArgs,cancelled:t.toolInvocation.state===`error`&&t.toolInvocation.result===`Cancelled by user`})})]},s):null}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hi,{content:t,timestamp:e.timestamp,_isStreaming:_(e),outputTokens:i}),e.toolCalls&&e.toolCalls.length>0&&(0,$.jsx)(`div`,{className:`space-y-2`,children:e.toolCalls.map(t=>{let i=`${e.id}-${t.toolName}-${JSON.stringify(t.args).slice(0,50)}`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Ui,{toolName:t.toolName,args:t.args,result:t.result,state:t.result?`result`:`call`}),(t.result||u(t.toolName))&&(0,$.jsx)(`div`,{"data-tool-call-id":i,children:(0,$.jsx)(Gi,{toolName:t.toolName,toolArgs:t.args,result:t.result||null,serverId:n,readResource:r,toolMeta:l(t.toolName),onSendFollowUp:d})})]},i)})})]})},e.id)}return null}),f&&(0,$.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,$.jsx)(`div`,{className:`flex-1`,children:(0,$.jsx)(`div`,{className:`rounded-lg p-4 max-w-fit`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`text-sm`,children:(0,$.jsx)(Mi,{duration:2,spread:1,children:`Thinking...`})})})})})}),(0,$.jsx)(`div`,{ref:o})]})});function sa({visible:e,onClick:t}){return(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 left-0 right-0 z-30 flex justify-center`,children:(0,$.jsx)(ne,{children:e&&(0,$.jsx)(x.div,{initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.96},transition:{duration:.18,ease:`easeOut`},children:(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`pointer-events-auto size-9 rounded-full border bg-background/95 p-0 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-background/80`,onClick:t,"aria-label":`Scroll to bottom`,title:`Scroll to bottom`,"data-testid":`chat-scroll-to-bottom`,children:(0,$.jsx)(Qt,{className:`size-4`})})})})})}function ca({visible:e}){return(0,$.jsx)(`div`,{"aria-hidden":!0,className:s(`pointer-events-none absolute inset-x-0 top-0 z-[5] h-32 bg-[linear-gradient(to_bottom,var(--background)_0%,var(--background)_24%,transparent_46%)] transition-opacity duration-200 sm:h-36`,e?`opacity-100`:`opacity-0`)})}function la(e,{messageCount:t,isLoading:n,enabled:r=!0}){let i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(!0),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(!0),u=(0,Q.useRef)({length:0,loading:!1}),d=t>0,f=r&&d&&!a,p=(0,Q.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.scrollHeight-(t.scrollTop+t.clientHeight)<=64;l.current=n,o(n),c(t.scrollTop>8)},[e]),m=(0,Q.useCallback)(t=>{let n=e.current;n&&(n.scrollTo({top:n.scrollHeight,behavior:t}),l.current=!0,o(!0))},[e]);return(0,Q.useEffect)(()=>{if(!r)return;let t=e.current;if(!t)return;p();let n=()=>p();t.addEventListener(`scroll`,n,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(()=>p()):null;return i?.observe(t),()=>{t.removeEventListener(`scroll`,n),i?.disconnect()}},[r,p,t,e]),(0,Q.useEffect)(()=>{if(!r||!d||!l.current)return;let e=u.current,i=t!==e.length,a=n!==e.loading;u.current={length:t,loading:n},!(!i&&!a)&&m(n?`auto`:`smooth`)},[r,d,n,t,m]),{messagesEndRef:i,showScrollToBottom:f,showTopFade:s,scrollToBottom:m}}function ua(e){return kt(e)}var da=e=>{let t=[];for(let n of e){if(n.error||n.result?.isError){let e={id:`prompt-error-${n.promptName}-${n.timestamp}`,role:`assistant`,content:n.error||`Prompt execution failed`,timestamp:n.timestamp};t.push(e);continue}let e=n.result;if(e&&`messages`in e&&Array.isArray(e.messages))for(let r of e.messages){let e=``,i=[];if(typeof r.content==`string`)e=r.content;else if(Array.isArray(r.content)){let t=[];for(let e of r.content)e.type===`text`&&e.text?t.push(e.text):e.type===`image`&&e.data?i.push({type:`image`,data:e.data,mimeType:e.mimeType||`image/png`}):e.type===`resource`&&t.push(`[Resource: ${e.resource?.uri||`embedded`}]`);e=t.join(`
|
|
4
|
-
`)}else r.content&&typeof r.content==`object`&&(r.content.type===`text`&&r.content.text?e=r.content.text:r.content.type===`image`&&r.content.data?i.push({type:`image`,data:r.content.data,mimeType:r.content.mimeType||`image/png`}):e=JSON.stringify(r.content));!e&&i.length===0&&(e=`[no content]`);let a={id:`prompt-${n.promptName}-${n.timestamp}-${t.length}`,role:r.role,content:e||``,timestamp:n.timestamp,attachments:i.length>0?i:void 0};t.push(a)}}return t};function fa({mcpServerUrl:e,llmConfig:t,authConfig:n,mcpAuthTokens:r,isConnected:i,chatApiUrl:a,waitForChatApiUrl:o,widgetModelContexts:s,initialMessages:c,disabledTools:l,streamProtocol:u=`sse`,credentials:d,extraHeaders:f,body:p}){let[m,h]=(0,Q.useState)(c??[]),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)([]),[b,x]=(0,Q.useState)(Ji),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),E=(0,Q.useRef)(null),D=(0,Q.useRef)(0),O=(0,Q.useCallback)(e=>{let t={...e,id:`trace-${++D.current}`,timestamp:Date.now()};x(e=>ta(e,t))},[]),k=(0,Q.useCallback)(async(c,g,b)=>{let x=[...v,...b??[]];if(!(c.trim()||g.length>0||x.length>0)||!t||!i)return;let S=[...da(g)];if(c.trim()||x.length>0){let e={id:`user-${Date.now()}`,role:`user`,content:c.trim(),timestamp:Date.now(),attachments:x.length>0?x:void 0};S.push(e)}h(e=>[...e,...S]),_(!0),y([]),E.current=new AbortController;try{let i=n,c=n?.type===`bearer`&&!!n.token,g=n?.type===`basic`&&!!(n.username||n.password);if(!c&&!g)if(r?.access_token)i={type:`oauth`,oauthTokens:r};else try{let t=`mcp:auth_${Rt(e)}_tokens`,n=localStorage.getItem(t);if(n){let e=JSON.parse(n);e?.access_token&&(i={type:`oauth`,oauthTokens:e})}}catch(e){console.warn(`Failed to retrieve OAuth tokens:`,e)}let _=[];if(s&&s.size>0){let e=[];for(let[,t]of s)t&&(t.content?.length?e.push(t.content.map(e=>e.text).join(`
|
|
5
|
-
`)):t.structuredContent&&e.push(JSON.stringify(t.structuredContent)));e.length>0&&_.push({id:`widget-context-${Date.now()}`,role:`user`,content:`[Current Widget State]\n${e.join(`
|
|
6
|
-
`)}`,timestamp:Date.now()})}let v=[...m,...S,..._],y=[...v.map(e=>({role:e.role,content:e.content||(e.parts?.filter(e=>e.type===`text`).map(e=>e.text).join(``)??``),attachments:e.attachments}))],b=a??(o?await o():void 0)??_t(`chat/stream`),x=p?p(y):{mcpServerUrl:e,llmConfig:t,authConfig:i,messages:y,...l&&l.size>0?{disabledTools:[...l]}:{}};O({type:`request`,request:{url:b,protocol:u,envelope:p?Zi(x):{mcpServerUrl:e,llmConfig:{provider:t.provider,model:t.model,temperature:t.temperature,baseUrl:t.baseUrl},messages:y,...l&&l.size>0?{disabledTools:[...l]}:{}},providerMessages:ua(v)}});let w=await fetch(b,{method:`POST`,headers:{"Content-Type":`application/json`,...f},signal:E.current.signal,...d?{credentials:d}:{},body:JSON.stringify(x)});if(!w.ok){let t=await w.json().catch(()=>null);if(a){let e=Jn(w.status,t);if(e){C(e);return}}if(w.status===401&&t?.error===`mcp_auth_required`){T({mcpServerUrl:t.mcpServerUrl??e,message:t.message});return}throw Error(`HTTP error! status: ${w.status}`)}let D=`assistant-${Date.now()}`,k=``,A=[];h(e=>[...e,{id:D,role:`assistant`,content:``,timestamp:Date.now(),parts:[]}]);let j=w.body?.getReader(),M=new TextDecoder;if(!j)throw Error(`No response body`);let N=()=>{h(e=>e.map(e=>e.id===D?{...e,parts:[...A]}:e))},P=()=>{h(e=>e.map(e=>e.id===D?{...e,parts:[...A],content:``}:e))},F=e=>{k+=e;let t=A[A.length-1];t&&t.type===`text`?t.text=k:A.push({type:`text`,text:k}),N()},ee=(e,t)=>{k&&=``,A.push({type:`tool-invocation`,toolInvocation:{toolName:e,args:t,state:`pending`}}),N()},te=(e,t)=>{let n;n=e.by===`toolName`?A.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.toolName===e.toolName&&!t.toolInvocation?.result):A[e.index],n?.toolInvocation&&(n.toolInvocation.result=t,n.toolInvocation.state=t?.isError?`error`:`result`,N())},I=new Map,L=``;for(;;){if(E.current?.signal.aborted){await j.cancel();break}let{done:e,value:t}=await j.read();if(e)break;L+=M.decode(t,{stream:!0});let n=L.split(`
|
|
7
|
-
`);L=n.pop()||``;for(let e of n)if(e.trim())try{if(u===`data-stream`){let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t),r=e.slice(t+1),i;try{i=JSON.parse(r)}catch{continue}switch(n){case`0`:{let e=typeof i==`string`?i:String(i);O({type:`text-delta`,delta:e,raw:i}),F(e);break}case`9`:{let e=i,t=e.args??{};if(typeof t.input==`string`&&Object.keys(t).length===1)try{let e=JSON.parse(t.input);typeof e==`object`&&e&&(t=e)}catch{}let n=String(e.toolCallId??`tool-${A.length}`),r=String(e.toolName??``);O({type:`tool-call-start`,toolCallId:n,toolName:r,raw:i}),O({type:`tool-call-args`,toolCallId:n,toolName:r,args:t,raw:i}),ee(r,t),e.toolCallId&&I.set(e.toolCallId,A.length-1);break}case`a`:{let e=i,t=I.get(e.toolCallId),n=e.result,r=n;if(r?.lc===1&&r?.type===`constructor`&&r?.kwargs?.content){let e=r.kwargs.content;if(typeof e==`string`)try{n=JSON.parse(e)}catch{n=e}}t!==void 0&&(O({type:`tool-result`,toolCallId:String(e.toolCallId??``),toolName:A[t]?.toolInvocation?.toolName??`Tool`,result:n,isError:!!(n&&typeof n==`object`&&n.isError),raw:i}),te({by:`index`,index:t},n));break}case`d`:{let e=Yi((i&&typeof i==`object`?i:void 0)?.usage);e&&O({type:`usage`,usage:e,raw:i}),O({type:`done`,raw:i}),P();break}case`3`:throw O({type:`error`,message:typeof i==`string`?i:JSON.stringify(i),raw:i}),Error(typeof i==`string`?i:JSON.stringify(i));default:break}}else{if(!e.startsWith(`data: `))continue;let t=JSON.parse(e.slice(6));if(t.type!==`message`){if(t.type===`text`)O({type:`text-delta`,delta:t.content,raw:t}),F(t.content);else if(t.type===`tool-call`){let e=t.toolCallId??`tool-${A.length}`;O({type:`tool-call-start`,toolCallId:e,toolName:t.toolName,raw:t}),O({type:`tool-call-args`,toolCallId:e,toolName:t.toolName,args:t.args,raw:t}),ee(t.toolName,t.args)}else if(t.type===`tool-result`)O({type:`tool-result`,toolCallId:t.toolCallId,toolName:t.toolName,result:t.result,isError:t.isError??t.result?.isError,raw:t}),te({by:`toolName`,toolName:t.toolName},t.result);else if(t.type===`done`){let e=Yi(t.usage);e&&O({type:`usage`,usage:e,raw:t}),O({type:`done`,raw:t}),P()}else if(t.type===`usage`){let e=Yi(t.usage??t);e&&O({type:`usage`,usage:e,raw:t})}else if(t.type===`error`)throw O({type:`error`,message:t.message||`Streaming error`,raw:t}),Error(t.message||`Streaming error`)}}}catch(t){if(t instanceof Error&&t.message!==`Streaming error`)console.error(`Failed to parse streaming event:`,t,e);else throw t}}if(E.current?.signal.aborted){for(let e of A)e.type===`tool-invocation`&&e.toolInvocation?.state===`pending`&&(e.toolInvocation.state=`error`,e.toolInvocation.result=`Cancelled by user`);h(e=>e.map(e=>e.id===D?{...e,parts:[...A],content:``}:e))}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;if(a&&Wn(e)){C({kind:`cloud_unavailable`});return}let t=`Unknown error occurred`;if(e instanceof Error){t=e.message;let n=e;n.status&&(t=`HTTP ${n.status}: ${t}`),(n.code===401||t.includes(`401`)||t.includes(`Unauthorized`))&&(t=`Authentication failed (401). Check your Authorization header in the connection settings.`)}let n={id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${t}`,timestamp:Date.now()};h(e=>[...e,n])}finally{_(!1),E.current=null}},[t,i,e,m,n,r,v,a,o,s,l,u,d,f,p,O]),A=(0,Q.useCallback)(()=>{h([]),C(null),T(null),x(Ji)},[]),j=(0,Q.useCallback)(()=>{C(null)},[]),M=(0,Q.useCallback)(e=>{C(e)},[]),N=(0,Q.useCallback)(()=>x(Ji),[]);return{messages:m,isLoading:g,attachments:v,managedChatNotice:S,mcpServerAuthRequired:w,sendMessage:k,clearMessages:A,clearManagedChatNotice:j,showManagedChatNotice:M,clearMcpServerAuthRequired:(0,Q.useCallback)(()=>{T(null)},[]),setMessages:h,stop:(0,Q.useCallback)(()=>{E.current&&E.current.abort()},[]),addAttachment:(0,Q.useCallback)(async e=>{try{let t=await Bt(e);y(e=>{let n=[...e,t];return Ut(n)?n:(alert(`Total attachment size exceeds 20MB limit`),e)})}catch(e){e instanceof Error?alert(e.message):alert(`Failed to add attachment`)}},[]),removeAttachment:(0,Q.useCallback)(e=>{y(t=>t.filter((t,n)=>n!==e))},[]),clearAttachments:(0,Q.useCallback)(()=>{y([])},[]),clearTrace:N,traceEvents:b.events,tokenUsage:b.usage}}function pa({connection:e,llmConfig:t,isConnected:n,readResource:r,widgetModelContexts:i,disabledTools:a,initialMessages:o,systemPrompt:s=Ei}){let[c,l]=(0,Q.useState)(o??[]),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)([]),[m,h]=(0,Q.useState)(Ji),[g,_]=(0,Q.useState)(null),v=(0,Q.useRef)(null),y=(0,Q.useRef)(0),b=(0,Q.useCallback)(e=>{let t={...e,id:`trace-${++y.current}`,timestamp:Date.now()};h(e=>ta(e,t))},[]);(0,Q.useEffect)(()=>{o!==void 0&&l(o)},[o]);let x=(0,Q.useCallback)(async(r,o,u)=>{let m=[...f,...u??[]];if(!(r.trim()||o.length>0||m.length>0)||!t||!n)return;let h=da(o),g={id:`user-${Date.now()}`,role:`user`,content:r.trim(),timestamp:Date.now(),attachments:m.length>0?m:void 0},y=[...h];(r.trim()||m.length>0)&&y.push(g),l(e=>[...e,...y]),d(!0),p([]),v.current=new AbortController;let x=Date.now(),S=0,C=`assistant-${Date.now()}`;try{let n=``,o=[],u=new Map,d=0,f=async()=>{let e=Date.now();e-d>=80&&(d=e,await new Promise(e=>setTimeout(e,0)))};l(e=>[...e,{id:C,role:`assistant`,content:``,timestamp:Date.now(),parts:[]}]);let p=[];if(i&&i.size>0){let e=[];for(let[,t]of i)t&&(t.content?.length?e.push(t.content.map(e=>e.text).join(`
|
|
8
|
-
`)):t.structuredContent&&e.push(JSON.stringify(t.structuredContent)));e.length>0&&p.push({id:`widget-context-${Date.now()}`,role:`user`,content:`[Current Widget State]\n${e.join(`
|
|
9
|
-
`)}`,timestamp:Date.now()})}let m=(g.attachments?.length??0)>0,_=ua([...c,...h,...p,...r.trim()||m?[g]:[]]);b({type:`request`,request:{provider:t.provider,model:t.model,messages:_}});let y=new Ot({llm:Et(t.provider,t.model,{apiKey:t.apiKey,temperature:t.temperature,baseUrl:t.baseUrl,credentials:t.credentials}),mcpServers:[e],systemPrompt:s,disallowedTools:a?[...a]:void 0,maxSteps:10,autoInitialize:!0}),w=e=>{try{return JSON.parse(e)}catch{let t=[()=>{let t=e;(t.match(/(?<!\\)"/g)||[]).length%2!=0&&(t+=`"`);let n=(t.match(/{/g)||[]).length-(t.match(/}/g)||[]).length,r=(t.match(/\[/g)||[]).length-(t.match(/]/g)||[]).length;for(let e=0;e<r;e++)t+=`]`;for(let e=0;e<n;e++)t+=`}`;return JSON.parse(t)},()=>{let t=e;t=t.replace(/,\s*"[^"]*"?\s*:\s*("([^"\\]|\\.)*)?$/,``),t=t.replace(/,\s*"[^"]*$/,``),(t.match(/(?<!\\)"/g)||[]).length%2!=0&&(t+=`"`);let n=(t.match(/{/g)||[]).length-(t.match(/}/g)||[]).length,r=(t.match(/\[/g)||[]).length-(t.match(/]/g)||[]).length;for(let e=0;e<r;e++)t+=`]`;for(let e=0;e<n;e++)t+=`}`;return JSON.parse(t)}];for(let e of t)try{return e()}catch{}return}},T=()=>{l(e=>e.map(e=>e.id===C?{...e,parts:[...o]}:e))};for await(let e of y.streamEvents({messages:_,signal:v.current?.signal})){if(v.current?.signal.aborted)break;if(e.type===`usage`){let t=e;b({type:`usage`,usage:t.usage,raw:t});continue}if(e.type===`text-delta`){b({type:`text-delta`,delta:e.delta,raw:e}),n+=e.delta;let t=o[o.length-1];t&&t.type===`text`?t.text=n:o.push({type:`text`,text:n}),T()}else if(e.type===`tool-call-start`)b({type:`tool-call-start`,toolCallId:e.toolCallId,toolName:e.toolName,raw:e}),n&&=``,u.set(e.toolCallId,{name:e.toolName,accumulatedJson:``}),o.push({type:`tool-invocation`,toolInvocation:{toolName:e.toolName,args:{},state:`streaming`,partialArgs:{}}}),T();else if(e.type===`tool-call-args-delta`){let t=u.get(e.toolCallId);if(t){t.accumulatedJson+=e.argsDelta;let n=w(t.accumulatedJson);if(n){let e=o.find(e=>e.type===`tool-invocation`&&e.toolInvocation?.state===`streaming`&&e.toolInvocation?.toolName===t.name);if(e&&e.toolInvocation){let t=e.toolInvocation.partialArgs,r=t?Object.keys(t):[],i=Object.keys(n),a=r.reduce((e,n)=>e+String(t[n]??``).length,0),o=i.reduce((e,t)=>e+String(n[t]??``).length,0);(i.length>r.length||o>=a)&&(e.toolInvocation.partialArgs=n),T(),await f()}}}}else if(e.type===`tool-call-ready`){b({type:`tool-call-args`,toolCallId:e.toolCallId,toolName:e.toolName,args:e.args,raw:e}),S++,n&&=``;let t=o.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.state===`streaming`&&t.toolInvocation?.toolName===e.toolName);t&&t.toolInvocation?(t.toolInvocation.args=e.args,t.toolInvocation.state=`pending`):o.push({type:`tool-invocation`,toolInvocation:{toolName:e.toolName,args:e.args,state:`pending`}}),T()}else if(e.type===`tool-result`){b({type:`tool-result`,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError,raw:e});let t=o.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.toolName===e.toolName&&!t.toolInvocation?.result);t&&t.toolInvocation&&(t.toolInvocation.result=e.result,t.toolInvocation.state=e.isError||e.result?.isError?`error`:`result`,T())}else if(e.type===`done`)b({type:`done`,raw:e});else if(e.type===`error`)throw b({type:`error`,message:e.message,raw:e}),Error(e.message)}if(v.current?.signal.aborted)for(let e of o)e.type===`tool-invocation`&&e.toolInvocation?.state===`pending`&&(e.toolInvocation.state=`error`,e.toolInvocation.result=`Cancelled by user`);l(e=>e.map(e=>e.id===C?{...e,parts:[...o],content:``}:e)),t&&xe(new Me({serverId:e.url,provider:t.provider,model:t.model,messageCount:c.length+1,toolCallsCount:S,success:!0,executionMode:`client-side`,duration:Date.now()-x})).catch(()=>{})}catch(n){if(n instanceof DOMException&&n.name===`AbortError`)return;let r=Un(t)?qn(n):null;if(r){_(r),l(e=>e.filter(e=>e.id!==C));return}console.error(`Client-side agent error:`,n);let i=`Unknown error occurred`;if(n instanceof Error){i=n.message;let e=n;e.status&&(i=`HTTP ${e.status}: ${i}`),(e.code===401||i.includes(`401`)||i.includes(`Unauthorized`))&&(i=`Authentication failed (401). Check your Authorization header in the connection settings.`)}t&&xe(new Me({serverId:e.url,provider:t.provider,model:t.model,messageCount:c.length+1,toolCallsCount:S,success:!1,executionMode:`client-side`,duration:Date.now()-x,error:i})).catch(()=>{});let a={id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${i}`,timestamp:Date.now()};l(e=>[...e,a])}finally{d(!1),v.current=null}},[e,t,n,c,r,f,a,i,b,s]),S=(0,Q.useCallback)(()=>{l([]),h(Ji),_(null)},[]),C=(0,Q.useCallback)(()=>h(Ji),[]),w=(0,Q.useCallback)(()=>{v.current&&v.current.abort()},[]),T=(0,Q.useCallback)(async e=>{try{let t=await Bt(e);p(e=>{let n=[...e,t];return Ut(n)?n:(alert(`Total attachment size exceeds 20MB limit`),e)})}catch(e){e instanceof Error?alert(e.message):alert(`Failed to add attachment`)}},[]),E=(0,Q.useCallback)(e=>{p(t=>t.filter((t,n)=>n!==e))},[]),D=(0,Q.useCallback)(()=>{p([])},[]);return{messages:c,isLoading:u,attachments:f,managedChatNotice:g,sendMessage:x,clearMessages:S,clearManagedChatNotice:(0,Q.useCallback)(()=>{_(null)},[]),showManagedChatNotice:(0,Q.useCallback)(e=>{_(e)},[]),setMessages:l,stop:w,addAttachment:T,removeAttachment:E,clearAttachments:D,clearTrace:C,traceEvents:m.events,tokenUsage:m.usage}}function ma({useClientSide:e,managedLlmConfig:t,localLlmConfig:n}){let r=!e&&t!=null,[i,a]=(0,Q.useState)(()=>Ht(r,n)),o=(0,Q.useCallback)(e=>{Wt(e?`byok`:`managed`),a(e)},[]),s=r?i:e||i||!!n,c=!!t&&!i;return{forceClientSide:i,setForceClientSide:o,effectiveClientSide:s,llmConfig:c?t??null:n??t??null,isManaged:c,hostUsesServerManagedStream:r}}function ha({serverName:e,serverUrl:t,message:n,onReconnect:r,onDismiss:i}){let[a,o]=(0,Q.useState)(!1),s=(0,Q.useCallback)(async()=>{o(!0);try{await r()}finally{o(!1)}},[r]),c=e;if(!c)try{c=new URL(t).host}catch{c=t}return(0,$.jsx)(`div`,{className:`w-full flex justify-center items-center px-2 sm:px-4 mb-2`,children:(0,$.jsxs)(`div`,{role:`alert`,className:`w-full max-w-3xl flex items-start gap-3 rounded-md border border-amber-300/60 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100`,children:[(0,$.jsx)(tn,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`font-medium`,children:[`Reconnect to `,(0,$.jsx)(`span`,{className:`font-semibold`,children:c})]}),(0,$.jsx)(`div`,{className:`text-xs opacity-90`,children:n??`The MCP server rejected your credentials. Reconnect to refresh them.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(F,{size:`sm`,variant:`default`,onClick:s,disabled:a,children:[(0,$.jsx)(me,{className:`size-3.5 ${a?`animate-spin`:``}`,"aria-hidden":!0}),a?`Reconnecting…`:`Reconnect`]}),i&&(0,$.jsx)(F,{size:`sm`,variant:`ghost`,onClick:i,"aria-label":`Dismiss`,children:`Dismiss`})]})]})})}function ga({notice:e,onConfigureApiKey:t,onSignIn:n,authorizing:r=!1}){return(0,$.jsx)(`div`,{className:`mb-2 flex w-full justify-center px-2 sm:px-4`,children:(0,$.jsxs)(`p`,{role:`status`,"data-testid":`chat-managed-notice`,className:`max-w-3xl rounded-md border border-amber-300/60 bg-amber-50 px-3 py-2 text-center text-sm text-amber-900 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100`,children:[e.kind===`cloud_unavailable`&&(0,$.jsxs)($.Fragment,{children:[`Cloud chat is currently not available.`,` `,(0,$.jsx)(_a,{onClick:t})]}),e.kind===`login_required`&&(0,$.jsxs)($.Fragment,{children:[`Sign in through Manufact Cloud to continue with managed chat.`,` `,n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{type:`button`,variant:`link`,size:`sm`,className:`h-auto px-0 align-baseline text-sm text-amber-900 hover:text-amber-700 dark:text-amber-100 dark:hover:text-amber-200`,disabled:r,onClick:n,children:r?`Authorizing…`:`Sign in`}),` · `]}),(0,$.jsx)(_a,{onClick:t})]}),e.kind===`credits_exhausted`&&(0,$.jsxs)($.Fragment,{children:[e.message??`You've used your included free plan credits for managed chat.`,` `,e.billingUrl&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`a`,{href:e.billingUrl,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2 hover:text-amber-700 dark:hover:text-amber-200`,children:`Upgrade your plan`}),` · `]}),(0,$.jsx)(_a,{onClick:t})]})]})})}function _a({onClick:e}){return(0,$.jsx)(`button`,{type:`button`,onClick:e,className:`underline underline-offset-2 hover:text-amber-700 dark:hover:text-amber-200`,"data-testid":`chat-managed-notice-configure-link`,children:`Configure your own API key`})}function va({events:e,usage:t}){return e.length===0?(0,$.jsx)(`p`,{className:`py-12 text-center text-sm text-muted-foreground`,children:`Raw request/response data will appear after the next message.`}):(0,$.jsx)(`div`,{className:`mx-auto max-w-4xl`,"data-testid":`chat-raw-view`,children:(0,$.jsx)(We,{data:na(e,t),filename:`chat-raw.json`,collapsible:!0,defaultExpanded:!1})})}function ya(e){return`mcp-inspector-system-prompt:${e}`}function ba(e){return typeof localStorage>`u`?null:localStorage.getItem(ya(e))}function xa(e,t){localStorage.setItem(ya(e),t)}function Sa(e){return e?.trim()||`You are a helpful assistant with access to MCP tools. Help users interact with the MCP server.`}function Ca(e){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),a=ya(e);return(0,Q.useEffect)(()=>{let t=()=>{n(ba(e))};t();let r=e=>{e.key===a&&t()};return window.addEventListener(`storage`,r),()=>window.removeEventListener(`storage`,r)},[e,a]),{prompt:t,savePrompt:(0,Q.useCallback)(async t=>{i(!0);try{xa(e,t),n(t)}finally{i(!1)}},[e]),isSaving:r}}var wa=/(?:^\/$|\s+\/$)/,Ta=[`ArrowDown`,`ArrowUp`,`Escape`,`Enter`];function Ea({connection:e,isConnected:t,useClientSide:n=!0,enableKeyboardShortcuts:r=!0,prompts:i,serverId:a,callPrompt:o,readResource:s,chatApiUrl:c,waitForChatApiUrl:l,initialMessages:u,managedLlmConfig:d,managedCloudModel:f,enableFreeTierUpgrade:p=!1,clearButtonLabel:m,hideTitle:g,hideModelBadge:_,clearButtonHideIcon:v,clearButtonHideShortcut:y,clearButtonVariant:b,hideClearButton:x,hideToolSelector:S,chatQuickQuestions:C=[],chatFollowups:w=[],streamProtocol:T,credentials:E,extraHeaders:D,body:k,chatStorageProvider:A,enableChatHistory:j,activeChatId:M,onActiveChatIdChange:P,titleGenerationReady:ee,activeChatTitle:te,onChatTitleGenerated:I,defaultView:L=`conv`,systemPromptProvider:R,elevatedHeader:z}){let{isEmbedded:B}=je(),V=Ca(a),ne=R??V,H=(0,Q.useMemo)(()=>Sa(ne.prompt),[ne.prompt]),re=(0,Q.useRef)(new Rn),U=A??(!B&&j!==!1?re.current:null),[ie,W]=(0,Q.useState)(null),G=M??ie,ae=(0,Q.useCallback)(e=>{P?P(e):W(e)},[P]),[oe,K]=(0,Q.useState)(!1),[q,J]=(0,Q.useState)(0),[se,ce]=(0,Q.useState)(),[le,ue]=(0,Q.useState)(void 0),[Y,de]=(0,Q.useState)(``),[fe,pe]=(0,Q.useState)(!1),[me,_e]=(0,Q.useState)(-1),[ve,ye]=(0,Q.useState)(C),[be,xe]=(0,Q.useState)(w),[Se,Ce]=(0,Q.useState)(L),[we,Te]=(0,Q.useState)(new Set),Ee=(0,Q.useRef)(null),De=(0,Q.useRef)(null),Oe=(0,Q.useRef)(null),Ae=(0,Q.useMemo)(()=>(e.tools??[]).map(e=>({name:e.name,description:e.description})),[e.tools]),{llmConfig:Me,authConfig:Ne,configDialogOpen:Fe,setConfigDialogOpen:Ie,tempProvider:Le,setTempProvider:Re,tempApiKey:ze,setTempApiKey:Be,tempModel:Ve,setTempModel:He,tempBaseUrl:Ue,setTempBaseUrl:We,saveLLMConfig:Ge,clearConfig:Ke}=Kt({mcpServerUrl:e.url??``}),{setForceClientSide:Je,effectiveClientSide:Ye,llmConfig:X,isManaged:Xe}=ma({useClientSide:n,managedLlmConfig:d,localLlmConfig:Me}),{getAllModelContexts:Ze}=it(),Qe=Ze(),et={connection:e,llmConfig:X,isConnected:t,readResource:s,widgetModelContexts:Qe,disabledTools:we},tt=fa({mcpServerUrl:e.url??``,llmConfig:X,authConfig:Ne,mcpAuthTokens:e.authTokens,isConnected:t,chatApiUrl:c,waitForChatApiUrl:l,widgetModelContexts:Qe,initialMessages:le??u,disabledTools:we,streamProtocol:T,credentials:E,extraHeaders:D,body:k}),nt=pa({...et,initialMessages:le??u,systemPrompt:H}),{messages:Z,isLoading:rt,attachments:st,sendMessage:ct,clearMessages:lt,setMessages:ut,stop:dt,addAttachment:ft,removeAttachment:pt,clearTrace:mt,traceEvents:ht,tokenUsage:gt}=Ye?nt:tt,[_t,vt]=(0,Q.useState)(()=>Z.length===0?`visible`:`hidden`),yt=(0,Q.useCallback)(()=>{vt(e=>e===`visible`?`fading`:e)},[]),bt=(0,Q.useCallback)(()=>{lt(),vt(`visible`)},[lt]),{messagesEndRef:xt,showScrollToBottom:St,showTopFade:wt,scrollToBottom:Tt}=la(De,{messageCount:Z.length,isLoading:rt,enabled:!!X}),Et=(0,Q.useCallback)(async e=>{if(!U)return;let[t,n]=await Promise.all([U.getMessages(e),U.listChats({agentId:a})]);ue(t),mt(),ut(t),vt(t.length===0?`visible`:`hidden`),ae(e),ce(n.items.find(t=>t.id===e)?.title)},[U,mt,ut,ae,a]),Dt=(0,Q.useCallback)(async()=>{lt(),ue([]),vt(`visible`),ce(ln),ae(null),U?(ae((await U.createChat({agentId:a,agentName:e.displayName||e.name||`MCP Server`})).id),J(e=>e+1)):ce(void 0)},[lt,U,a,e.displayName,e.name,ae]),Ot=(0,Q.useCallback)(async()=>{if(!U||G)return G;let t=await U.createChat({agentId:a,agentName:e.displayName||e.name||`MCP Server`});return ae(t.id),ce(ln),J(e=>e+1),t.id},[U,G,a,e.displayName,e.name,ae]);(0,Q.useEffect)(()=>{!U?.saveMessages||!G||U.saveMessages(G,Z)},[U,G,Z]);let kt=(0,Q.useCallback)(()=>{J(e=>e+1)},[]),At=(0,Q.useCallback)((e,t)=>{ce(t),I?.(e,t)},[I]),jt=te??se,Nt=jt&&!dn(jt)?jt:un;zn({activeChatId:G,storage:U,messages:Z,isLoading:rt,effectiveClientSide:Ye,llmConfig:X,activeChatTitle:jt,titleGenerationReady:ee,onTitleGenerated:At,onHistoryRefetch:kt});let Pt=nt.managedChatNotice??tt.managedChatNotice??null,Ft=(0,Q.useCallback)(()=>{nt.clearManagedChatNotice(),tt.clearManagedChatNotice()},[nt.clearManagedChatNotice,tt.clearManagedChatNotice]),It=(0,Q.useCallback)(e=>{nt.showManagedChatNotice(e),tt.showManagedChatNotice(e)},[nt.showManagedChatNotice,tt.showManagedChatNotice]),Lt=(0,Q.useCallback)(()=>{Ge()&&(Je(!0),Ft())},[Ge,Je,Ft]),Rt=Ye?null:tt.mcpServerAuthRequired??null,zt=Ye?void 0:tt.clearMcpServerAuthRequired,Bt=(0,Q.useCallback)(async()=>{try{await e.authenticate()}catch(e){console.error(`[ChatTab] MCP reconnect failed:`,e),ot.error(e instanceof Error?`Reconnect failed: ${e.message}`:`Reconnect failed`);return}zt?.()},[e,zt]),Vt=Rt?(0,$.jsx)(ha,{serverName:e.name,serverUrl:Rt.mcpServerUrl,message:Rt.message,onReconnect:Bt,onDismiss:zt}):null,Ht=(0,Q.useCallback)(()=>{Ie(!0)},[Ie]),{user:Ut,authorizing:Wt,authorize:Gt}=he(p?c:void 0),qt=(0,Q.useCallback)(()=>{Ie(!1),Gt().catch(e=>{if(c&&Wn(e)){It({kind:`cloud_unavailable`});return}ot.error(e instanceof Error?e.message:`Authorization failed`)})},[Gt,c,Ie,It]),Jt=Ut!=null;(0,Q.useEffect)(()=>{Jt&&Pt?.kind===`login_required`&&Ft()},[Ft,Jt,Pt?.kind]);let Yt=p&&!Jt?{onLoginClick:qt}:void 0,Xt=!!d&&!!_,Zt=Xt,Qt=p&&Jt&&f?{models:f.models,selectedModelId:f.selectedModelId,onModelChange:f.setSelectedModelId,isLoading:f.isLoading}:void 0,$t=Xe?`managed`:`byok`,en=Xe&&f?.selectedModel?at(f.selectedModel.name,f.selectedModel.provider):void 0,tn=(0,Q.useCallback)(()=>{Je(!1),Ft(),Ie(!1)},[Ft,Ie,Je]),{filteredPrompts:nn,setSelectedPrompt:rn,selectedPrompt:an,setPromptArgs:on,executePrompt:sn,results:cn,handleDeleteResult:fn,clearPromptResults:pn}=Mt({prompts:i,callPrompt:o,serverId:a}),mn=(0,Q.useCallback)(e=>Array.isArray(e)?e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean).slice(0,8):[],[]),hn=(0,Q.useCallback)(e=>{if(typeof e.content==`string`&&e.content.trim())return e.content;if(Array.isArray(e.content)&&e.content.length>0)return e.content.map(e=>typeof e==`string`?e:e.text??``).join(``);if(e.parts&&e.parts.length>0){let t=e.parts.filter(e=>e.type===`text`&&e.text).map(e=>e.text);if(t.length>0)return t.join(`
|
|
10
|
-
`)}return``},[]),gn=(0,Q.useCallback)(e=>{if(e==null)return`No result`;if(typeof e==`string`)try{let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}if(typeof e==`object`&&Array.isArray(e.content)){let t=e.content;return t.length===0?`Empty result`:t.map(e=>{if(e.type===`text`){let t=e.text||``;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}return e.type===`image`?`[Image: ${e.mimeType}]`:e.type===`resource`?`[Resource: ${e.resource?.uri||`unknown`}]`:JSON.stringify(e,null,2)}).join(`
|
|
11
|
-
|
|
12
|
-
`)}return JSON.stringify(e,null,2)},[]),_n=(0,Q.useCallback)(()=>Z.map(e=>{let t=hn(e),n=e.parts?.filter(e=>e.type===`tool-invocation`&&e.toolInvocation).map(e=>({toolName:e.toolInvocation.toolName,args:e.toolInvocation.args,state:e.toolInvocation.state,result:typeof e.toolInvocation.result==`string`?e.toolInvocation.result.slice(0,2e3):e.toolInvocation.result==null?void 0:JSON.stringify(e.toolInvocation.result).slice(0,2e3)})),r=t||(n?.length?`[Tool calls: ${n.map(e=>`${e.toolName}(${e.state})`).join(`, `)}]`:``);return{id:e.id,role:e.role,content:r,timestamp:e.timestamp,toolInvocations:n?.length?n:void 0}}),[Z,hn]),vn=(0,Q.useCallback)((e,t={})=>{typeof window>`u`||window.parent===window||window.parent.postMessage({type:e,serverId:a,...t},`*`)},[a]);(0,Q.useEffect)(()=>{vn(`mcp-inspector:chat:ready`,{capabilities:{send:!0,clear:!0,getState:!0,setQuickQuestions:!0,setFollowups:!0,loadMessages:!0}})},[vn]),(0,Q.useEffect)(()=>{vn(`mcp-inspector:chat:state_changed`,{isLoading:rt,messageCount:Z.length,messages:_n(),quickQuestions:ve,followups:be})},[be,_n,rt,Z.length,vn,ve]),(0,Q.useEffect)(()=>{let e=e=>{if(!e.data||typeof e.data!=`object`)return;let n=e.data;if(!n.type?.startsWith(`mcp-inspector:chat:`)||n.serverId&&n.serverId!==a)return;let r=n.requestId,i=(e,t={})=>{vn(`mcp-inspector:chat:command_result`,{requestId:r,ok:e,...t})};if(n.type===`mcp-inspector:chat:send`){let e=(n.message??n.prompt??``).trim();if(!e){i(!1,{error:`Missing message`});return}if(!X||!t){i(!1,{error:`Chat is not ready to send messages`});return}Z.length===0&&yt(),ct(e,[]).then(()=>{vn(`mcp-inspector:chat:message_sent`,{requestId:r,message:e,source:`bridge`}),i(!0)}).catch(e=>{i(!1,{error:e instanceof Error?e.message:String(e)})});return}if(n.type===`mcp-inspector:chat:clear`){bt(),vn(`mcp-inspector:chat:cleared`,{requestId:r}),i(!0);return}if(n.type===`mcp-inspector:chat:get_state`){vn(`mcp-inspector:chat:state`,{requestId:r,isLoading:rt,messageCount:Z.length,messages:_n(),quickQuestions:ve,followups:be}),i(!0);return}if(n.type===`mcp-inspector:chat:set_quick_questions`){let e=mn(n.questions);ye(e),i(!0,{quickQuestions:e});return}if(n.type===`mcp-inspector:chat:set_followups`){let e=mn(n.followups);xe(e),i(!0,{followups:e});return}if(n.type===`mcp-inspector:chat:load_messages`){let e=n.messages;if(!Array.isArray(e)){i(!1,{error:`messages must be an array`});return}ut(e),i(!0,{count:e.length});return}if(n.type===`mcp-inspector:chat:screenshot`){let e=n.toolCallId;(async()=>{try{let t=null;if(e&&(t=document.querySelector(`[data-tool-call-id="${e}"]`)),!t){let e=document.querySelectorAll(`[data-tool-call-id]`);e.length>0&&(t=e[e.length-1])}if(!t&&De.current&&(t=De.current),!t){i(!1,{error:`No screenshot target found`});return}let n=1e4,a=null,o=``,s=``;try{let e=await ge(()=>import(`https://esm.sh/html-to-image@1.11.13`),[]);e?.toPng?a=await Promise.race([e.toPng(t,{pixelRatio:1,backgroundColor:`#ffffff`,includeQueryParams:!0}),new Promise((e,t)=>setTimeout(()=>t(Error(`html-to-image timed out`)),n))]):o=`toPng not found on module`}catch(e){o=e instanceof Error?e.message:String(e)}if(!a)try{if(!window.html2canvas){let e=document.createElement(`script`);e.src=`https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js`,document.head.appendChild(e),await new Promise((t,n)=>{e.onload=()=>t(),e.onerror=()=>n(Error(`Failed to load html2canvas`))})}let e=window.html2canvas;a=(await Promise.race([e(t,{useCORS:!0,allowTaint:!0,backgroundColor:`#ffffff`,scale:1,logging:!1,foreignObjectRendering:!1}),new Promise((e,t)=>setTimeout(()=>t(Error(`html2canvas timed out`)),n))])).toDataURL(`image/png`)}catch(e){s=e instanceof Error?e.message:String(e)}if(a)vn(`mcp-inspector:chat:screenshot_result`,{requestId:r,toolCallId:e||null,image:a,timestamp:Date.now()}),i(!0);else{let t=De.current||document.body,n=t.innerText?.substring(0,5e3)||``,a=t.innerHTML?.substring(0,1e4)||``;vn(`mcp-inspector:chat:screenshot_result`,{requestId:r,toolCallId:e||null,image:``,domText:n,domHtml:a,error:`html-to-image: ${o||`ok`}; html2canvas: ${s||`ok`}`,timestamp:Date.now()}),i(!1,{error:`html-to-image: ${o}; html2canvas: ${s}`})}}catch(t){let n=(De.current||document.body).innerText?.substring(0,5e3)||``;vn(`mcp-inspector:chat:screenshot_result`,{requestId:r,toolCallId:e||null,image:``,domText:n,error:t instanceof Error?t.message:`Screenshot capture failed`,timestamp:Date.now()}),i(!1,{error:t instanceof Error?t.message:`Screenshot failed`})}})();return}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[bt,yt,ut,be,_n,rt,Z.length,vn,ve,mn,ct,a,X,t]),ke(r?{onNewChat:U?Dt:bt}:{});let yn=t=>{let n=(0,$.jsx)(Hn,{className:`h-full w-full`,shaderPhase:_t,meshAnimationPaused:Fe,onShaderFadeComplete:()=>vt(`hidden`),children:t});return U?(0,$.jsxs)(`div`,{className:`flex h-full flex-row overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`group/chat-history relative hidden shrink-0 flex-col overflow-visible transition-[width] duration-200 lg:flex`,style:{width:oe?320:0},children:[oe&&(0,$.jsx)(`div`,{className:`flex h-full w-full flex-col overflow-hidden border-r border-zinc-200 bg-background dark:border-zinc-700`,children:(0,$.jsx)(kn,{provider:U,open:!0,onOpenChange:K,currentChatId:G??void 0,agentId:a,agentDisplayNameFallback:e.displayName||e.name||`MCP Server`,onSelectChat:Et,variant:`inline`,containerClassName:`h-full border-0`,refetchKey:q,onCurrentChatDeleted:()=>void Dt()})}),oe&&(0,$.jsx)(An,{onCollapse:()=>K(!1)})]}),(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 overflow-hidden`,children:[!oe&&(0,$.jsx)(`div`,{className:`absolute top-1/2 left-4 z-50 hidden -translate-y-1/2 lg:block`,children:(0,$.jsxs)(O,{children:[(0,$.jsx)(h,{render:(0,$.jsx)(F,{size:`icon`,variant:`outline`,className:`size-10 aspect-square rounded-full`,onClick:()=>K(!0),children:(0,$.jsx)(qe,{size:16})}),nativeButton:!0}),(0,$.jsx)(N,{side:`right`,children:(0,$.jsx)(`p`,{children:`Chat History`})})]})}),n]})]}):n},bn=(0,Q.useCallback)(()=>{_e(-1),pe(!1),Oe.current=null},[]),xn=(0,Q.useCallback)(()=>{if(!Ee.current)return;let e=Ee.current.selectionStart,t=Y.slice(0,e),n=wa.test(t);pe(n),n?(Oe.current={start:e-1,end:e},_e(0)):bn()},[Y,bn]);(0,Q.useEffect)(()=>{X&&Z.length===0&&Ee.current&&Ee.current.focus()},[X,Z.length]),(0,Q.useEffect)(()=>{!rt&&Z.length>0&&Ee.current&&Ee.current.focus()},[rt,Z.length]),(0,Q.useEffect)(()=>{Ee.current&&xn()},[Y,xn]);let Sn=(0,Q.useCallback)(()=>{rn(null),on({}),bn()},[bn]),Cn=(0,Q.useCallback)(async e=>{if(rn(e),e.arguments&&e.arguments.length>0){rn(null),ot.error(`Prompts with arguments are not supported`,{description:`This prompt requires arguments which are not yet supported in chat mode.`});return}try{await sn(e,{})}catch(e){console.error(`Error executing prompt`,e)}finally{if(Ee.current&&Oe.current){let{start:e,end:t}=Oe.current;de(Y.slice(0,e)+Y.slice(t)),requestAnimationFrame(()=>{Ee.current?.focus(),Ee.current?.setSelectionRange(e,e)})}Sn()}},[sn,Sn,Y]),wn=(0,Q.useCallback)(()=>{(Y.trim()||cn.length>0||st.length>0)&&(Z.length===0&&yt(),Ot().then(()=>{ct(Y,cn),de(``),pn()}))},[Y,cn,ct,pn,st,Ot,Z.length,yt]),Tn=(0,Q.useCallback)(e=>{if(e.key===`ArrowDown`)_e(e=>nn.length===0?-1:(e+1)%nn.length);else if(e.key===`ArrowUp`)_e(e=>nn.length===0?-1:(e-1+nn.length)%nn.length);else if(e.key===`Escape`)e.stopPropagation(),bn();else if(e.key===`Enter`&&me>=0){let e=nn[me];e&&Cn(e)}},[nn,me,Cn,bn]),En=(0,Q.useCallback)(e=>{Ta.includes(e.key)&&fe?(e.preventDefault(),Tn(e)):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),wn())},[wn,Tn,fe]),Dn=(0,Q.useCallback)(e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&xn()},[xn]),On=(0,Q.useCallback)(e=>{let t=`# Chat Export - ${new Date().toLocaleString()}\n\n`;return t+=e.map(e=>{let t=e.role.charAt(0).toUpperCase()+e.role.slice(1);if(!e.parts||e.parts.length===0){let n=hn(e).trim();return n?`## ${t}\n${n}`:``}let n=[];for(let t of e.parts)if(t.type===`text`&&t.text?.trim())n.push(t.text.trim());else if(t.type===`tool-invocation`&&t.toolInvocation){let e=t.toolInvocation,r=gn(e.result);n.push(`#### ${e.toolName}\n**Arguments:**\n\`\`\`json\n${JSON.stringify(e.args,null,2)}\n\`\`\`\n**Result:**\n\n${r}`)}return n.length===0?``:`## ${t}\n\n${n.join(`
|
|
13
|
-
|
|
14
|
-
`)}`}).filter(e=>e!==``).join(`
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
`),t},[hn,gn]),jn=(0,Q.useCallback)(()=>{Ct(On(Z)).then(()=>ot.success(`Chat copied to clipboard`),()=>ot.error(`Failed to copy chat`))},[Z,On]),Mn=(0,Q.useCallback)(e=>{let t=`chat-export-${new Date().toISOString().split(`T`)[0]}`;if(e===`json`)Pe(Z.map(e=>({id:e.id,role:e.role,content:hn(e),timestamp:e.timestamp,toolInvocations:e.parts?.filter(e=>e.type===`tool-invocation`&&e.toolInvocation).map(e=>({toolName:e.toolInvocation.toolName,args:e.toolInvocation.args,result:e.toolInvocation.result}))})),t+`.json`);else{let e=On(Z),n=new Blob([e],{type:`text/markdown`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t+`.md`,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(r),100)}ot.success(`Chat exported as ${e.toUpperCase()}`)},[Z,On,hn]),Nn=(0,Q.useCallback)(()=>{Ke(),Dt()},[Ke,Dt]),Pn=(0,Q.useCallback)(e=>{e.trim()&&(!X||!t||(yt(),ct(e,[]).then(()=>{vn(`mcp-inspector:chat:message_sent`,{message:e,source:`quick_question`})})))},[vn,ct,X,t,yt]),Fn=(0,Q.useCallback)(e=>{e.trim()&&(!X||!t||ct(e,[]).then(()=>{vn(`mcp-inspector:chat:message_sent`,{message:e,source:`followup`})}))},[vn,ct,X,t]),In=Pt?(0,$.jsx)(ga,{notice:Pt,onConfigureApiKey:Ht,onSignIn:Pt.kind===`login_required`?c?qt:()=>{window.location.href=Pt.loginUrl}:void 0,authorizing:Wt}):null;return X&&Z.length===0?yn((0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute top-4 right-4 z-10`,children:(0,$.jsx)(vr,{open:Fe,onOpenChange:Ie,tempProvider:Le,tempModel:Ve,tempApiKey:ze,tempBaseUrl:Ue,onProviderChange:Re,onModelChange:He,onApiKeyChange:Be,onBaseUrlChange:We,onSave:Lt,onClear:Nn,showClearButton:!!Me,buttonLabel:`Change API Key`,hostedInspector:p,freeTierInfo:Yt,managedCloudInfo:Qt,useManagedCloud:Xe,onSaveManagedCloud:Qt?tn:void 0})}),(0,$.jsx)(Ai,{serverDisplayName:$e(e),composerNotice:In,inputValue:Y,isConnected:t&&!Pt&&!Rt,isLoading:rt,textareaRef:Ee,llmConfig:X,promptsDropdownOpen:fe,promptFocusedIndex:me,prompts:nn,selectedPrompt:an,promptResults:cn,attachments:st,tools:S?void 0:Ae,disabledTools:S?void 0:we,onDisabledToolsChange:S?void 0:Te,onDeletePromptResult:fn,onPromptSelect:Cn,onInputChange:de,onKeyDown:En,onKeyUp:Dn,onClick:xn,onSendMessage:wn,onStopStreaming:dt,onConfigDialogOpenChange:Ie,onAttachmentAdd:ft,onAttachmentRemove:pt,hideModelBadge:Zt,freeTierInfo:Yt,managedCloudInfo:Qt,modelBadgeMode:$t,modelDisplayName:en,quickQuestions:ve,onQuickQuestionSelect:Pn,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:ne}),Vt]})):yn((0,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(Cr,{llmConfig:X,hasMessages:Z.length>0,configDialogOpen:Fe,onConfigDialogOpenChange:Ie,onClearChat:U?Dt:bt,tempProvider:Le,tempModel:Ve,tempApiKey:ze,tempBaseUrl:Ue,onProviderChange:Re,onModelChange:He,onApiKeyChange:Be,onBaseUrlChange:We,onSaveConfig:Lt,onClearConfig:Nn,showClearButton:!!Me,hideConfigButton:Xt,hostedInspector:p,freeTierInfo:Yt,managedCloudInfo:Qt,useManagedCloud:Xe,onSaveManagedCloud:Qt?tn:void 0,onCopyChat:jn,onExportChat:Mn,clearButtonLabel:m,hideTitle:g,clearButtonHideIcon:v,clearButtonHideShortcut:y,clearButtonVariant:b,hideClearButton:x,activeChatId:G,chatTitle:Nt,showViewToggle:!!X,viewIndex:+(Se===`raw`),onViewIndexChange:e=>Ce(e===1?`raw`:`conv`),elevatedHeader:z}),(0,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(ca,{visible:wt&&!!X}),(0,$.jsx)(`div`,{ref:De,"data-testid":`chat-messages-scroll-container`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-2 sm:p-4 pt-[80px] sm:pt-[100px]`,children:X?Se===`conv`?(0,$.jsx)(oa,{messages:Z,isLoading:rt,serverId:e.url,readResource:s,tools:e.tools,sendMessage:(e,t)=>ct(e,[],t),serverBaseUrl:e.url,messagesEndRef:xt,traceEvents:ht}):(0,$.jsx)(va,{events:ht,usage:gt}):(0,$.jsx)(ji,{onConfigureClick:()=>Ie(!0)})}),X&&(0,$.jsx)(sa,{visible:St,onClick:()=>Tt(`smooth`)})]}),X&&(0,$.jsxs)(`div`,{className:`relative shrink-0`,children:[In,(0,$.jsx)(ki,{inputValue:Y,isConnected:t&&!Pt&&!Rt,isLoading:rt,textareaRef:Ee,llmConfig:X,promptsDropdownOpen:fe,promptFocusedIndex:me,prompts:nn,promptResults:cn,selectedPrompt:an,attachments:st,tools:S?void 0:Ae,disabledTools:S?void 0:we,onDisabledToolsChange:S?void 0:Te,onDeletePromptResult:fn,onPromptSelect:Cn,onInputChange:de,onKeyDown:En,onKeyUp:Dn,onClick:xn,onSendMessage:wn,onStopStreaming:dt,onConfigDialogOpenChange:Ie,onAttachmentAdd:ft,onAttachmentRemove:pt,hideModelBadge:Zt,freeTierInfo:Yt,managedCloudInfo:Qt,modelBadgeMode:$t,modelDisplayName:en,followups:be,onFollowupSelect:Fn,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:ne})]}),Vt]}))}export{Ea as ChatTab};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react-CU_d2d5K.js";import{d as n,l as r,sr as i,u as a}from"./input-CLYhA7PK.js";import{t as o}from"./jsx-runtime-Cjj9sGSy.js";import{L as s,Zt as c,dt as l,ft as u,lt as d,mt as f,ot as p,pt as m,ut as h}from"./index-TQ5V7cM9.js";import{t as g}from"./inspector-settings-layout-yjKRJDai.js";import{n as _}from"./ListTabHeader-R17w_JsB.js";var v=e(t(),1);function y(e,t){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(`auto`),[c,g]=(0,v.useState)(`auto`),[_,y]=(0,v.useState)([]),[b,x]=(0,v.useState)(`10000`),[S,C]=(0,v.useState)(`True`),[w,T]=(0,v.useState)(`60000`),[E,D]=(0,v.useState)(h()),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(``),[M,N]=(0,v.useState)(``);return(0,v.useEffect)(()=>{if(!e||!t)return;let n=f(e,l(e.id));a(n.url),r(n.name||n.url);let i=n.proxyConfig?.proxyAddress||(typeof n.autoProxyFallback==`object`?n.autoProxyFallback.proxyAddress:void 0);s(n.connectionMode||`auto`),g(u(n.protocolNegotiation)),D(i||h());let o=n.headers||{};y(Object.entries(o).map(([e,t],n)=>({id:`header-${n}`,name:e,value:String(t)}))),k(n.oauth?.clientId||``),j(n.oauth?.clientSecret||``),N(n.oauth?.scope||``),n.requestTimeout!==void 0&&x(String(n.requestTimeout)),n.resetTimeoutOnProgress!==void 0&&C(n.resetTimeoutOnProgress?`True`:`False`),n.maxTotalTimeout!==void 0&&T(String(n.maxTotalTimeout))},[e,t]),{alias:n,setAlias:r,url:i,setUrl:a,connectionMode:o,setConnectionMode:s,protocolMode:c,setProtocolMode:g,customHeaders:_,setCustomHeaders:y,requestTimeout:b,setRequestTimeout:x,resetTimeoutOnProgress:S,setResetTimeoutOnProgress:C,maxTotalTimeout:w,setMaxTotalTimeout:T,proxyAddress:E,setProxyAddress:D,clientId:O,setClientId:k,clientSecret:A,setClientSecret:j,scope:M,setScope:N,buildConfig:()=>{if(!i.trim())return null;let e=i.trim();try{let t=new URL(e);if(!(t.protocol===`http:`||t.protocol===`https:`))return p.error(`Invalid URL protocol. Please use http:// or https://`),null}catch{try{let t=`https://${e}`,n=new URL(t);if(!(n.protocol===`http:`||n.protocol===`https:`))return p.error(`Invalid URL protocol. Please use http:// or https://`),null;e=t}catch{return p.error(`Invalid URL format. Please enter a valid URL.`),null}}let t=_.reduce((e,t)=>(t.name&&t.value&&(e[t.name]=t.value),e),{}),r=o===`proxy`&&E.trim()?{proxyAddress:E.trim(),headers:t}:void 0,a=o===`auto`&&E.trim()?{enabled:!0,proxyAddress:E.trim()}:!1,s=d(O,A,M),l=Number.parseInt(b,10),u=Number.parseInt(w,10);return{url:e,name:n.trim()||e,transportType:`http`,connectionMode:o,protocolNegotiation:m(c),proxyConfig:r,headers:Object.keys(t).length>0?t:void 0,autoProxyFallback:a,...s?{oauth:s}:{},...Number.isFinite(l)?{requestTimeout:l}:{},resetTimeoutOnProgress:S===`True`,...Number.isFinite(u)?{maxTotalTimeout:u}:{}}}}}var b=o();function x({connection:e,onSave:t}){let o=y(e,!0),[l,u]=(0,v.useState)(!1);return(0,b.jsxs)(`div`,{className:`h-full overflow-y-auto overscroll-none`,onScroll:e=>u(e.currentTarget.scrollTop>0),children:[(0,b.jsxs)(`div`,{className:`${r(l)} flex flex-row items-center justify-between gap-2 ${a}`,children:[(0,b.jsxs)(`h2`,{className:`${n} flex items-center gap-1.5`,children:[(0,b.jsx)(c,{className:_,"aria-hidden":!0}),`Connection Settings`]}),(0,b.jsx)(i,{"data-testid":`connection-form-save-button`,size:`sm`,onClick:()=>{let e=o.buildConfig();e&&t(e)},children:`Save`})]}),(0,b.jsx)(`div`,{className:g,children:(0,b.jsx)(s,{alias:o.alias,setAlias:o.setAlias,url:o.url,setUrl:o.setUrl,connectionMode:o.connectionMode,setConnectionMode:o.setConnectionMode,protocolMode:o.protocolMode,setProtocolMode:o.setProtocolMode,customHeaders:o.customHeaders,setCustomHeaders:o.setCustomHeaders,requestTimeout:o.requestTimeout,setRequestTimeout:o.setRequestTimeout,resetTimeoutOnProgress:o.resetTimeoutOnProgress,setResetTimeoutOnProgress:o.setResetTimeoutOnProgress,maxTotalTimeout:o.maxTotalTimeout,setMaxTotalTimeout:o.setMaxTotalTimeout,proxyAddress:o.proxyAddress,setProxyAddress:o.setProxyAddress,clientId:o.clientId,setClientId:o.setClientId,clientSecret:o.clientSecret,setClientSecret:o.setClientSecret,scope:o.scope,setScope:o.setScope,showConnectButton:!1,showExportButton:!1,inlineSections:!0,cardSections:!0})})]})}export{x as ConnectionSettingsTab};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react-CU_d2d5K.js";import{Nr as n,a as r,n as i,r as a,sr as o,t as s}from"./input-CLYhA7PK.js";import{t as c}from"./jsx-runtime-Cjj9sGSy.js";import{t as l}from"./label-Cdim77Jw.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./shared-BF0rJNdE.js";import{t as g}from"./maximize-2-BTT9QQU9.js";import{At as _,Bt as v,Kt as y,P as b,Xt as x,b as S,bt as C,hn as w,mn as T,ot as E,pn as D,vn as O,yt as k}from"./index-TQ5V7cM9.js";import{t as A}from"./textarea-DLAmNVf_.js";import{t as j}from"./checkbox-CzBkaNKa.js";import{n as M,t as N}from"./schemaHelpers-DLNTQr_6.js";var P=e(t(),1),F=c();function I({requests:e,selectedRequest:t,onRequestSelect:r,focusedIndex:i,formatRelativeTime:a}){return e.length===0?(0,F.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center`,children:(0,F.jsx)(v,{vertical:!0,noBorder:!0,message:`No elicitation requests`})}):(0,F.jsx)(`div`,{children:e.map((e,o)=>{let s=e.request.mode||`form`,c=s===`form`&&`requestedSchema`in e.request&&e.request.requestedSchema;return(0,F.jsx)(m,{id:`elicitation-request-${e.id}`,"data-testid":`elicitation-request-item-${o}`,isSelected:t?.id===e.id,isFocused:i===o,title:(0,F.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.serverName,(0,F.jsx)(n,{variant:`outline`,className:s===`url`?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:s})]}),description:(()=>{let t=a(e.timestamp),n=[];return c&&n.push(`with schema`),s===`url`&&n.push(`external action`),t+(n.length>0?` | ${n.join(`, `)}`:``)})(),onClick:()=>r(e)},e.id)})})}function L({request:e,formData:t,onFieldChange:n,idPrefix:r,testIdPrefix:i,fieldContainerClassName:a=`space-y-2`,textareaRows:o=4,showOuterLabelForBoolean:c=!0,emptyFallback:u}){return(0,F.jsx)(F.Fragment,{children:(0,P.useMemo)(()=>{if(!(`requestedSchema`in e.request))return null;let d=e.request.requestedSchema;if(!d||d.type!==`object`||!d.properties)return u??(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No form schema available`});let f=d.properties,p=d.required||[];return(0,F.jsx)(`div`,{className:`space-y-4`,children:Object.entries(f).map(([e,u])=>{let d=u,f=p.includes(e),m=d.type||`string`,h=d.title||e,g=d.description,_=M(d),v=_.length>0,y=Array.isArray(d.enum),b=m===`array`&&Array.isArray(d.items?.enum),x=N(d),S=m===`array`&&x.length>0,C=Array.isArray(t[e])?t[e]:[],w=`${r}-${e}`,T=`${i}-${e}`;return(0,F.jsxs)(`div`,{className:a,children:[(m!==`boolean`||c)&&(0,F.jsxs)(l,{htmlFor:w,children:[h,f&&(0,F.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),g&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g}),m===`boolean`?(0,F.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,F.jsx)(j,{id:w,"data-testid":T,checked:t[e]||!1,onCheckedChange:t=>n(e,t)}),(0,F.jsxs)(l,{htmlFor:w,className:`text-sm font-normal cursor-pointer`,children:[h,!c&&f&&(0,F.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]})]}):m===`number`||m===`integer`?(0,F.jsx)(s,{id:w,"data-testid":T,type:`number`,value:t[e]??``,onChange:t=>{let r=m===`integer`?parseInt(t.target.value,10):parseFloat(t.target.value);n(e,isNaN(r)?``:r)},placeholder:d.default?.toString()||``}):v?(0,F.jsxs)(`select`,{id:w,"data-testid":T,value:t[e]||``,onChange:t=>n(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,F.jsx)(`option`,{value:``,children:`Select...`}),_.map(e=>(0,F.jsx)(`option`,{value:e.const,children:e.title||e.const},e.const))]}):y?(0,F.jsxs)(`select`,{id:w,"data-testid":T,value:t[e]||``,onChange:t=>n(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,F.jsx)(`option`,{value:``,children:`Select...`}),d.enum.map((e,t)=>(0,F.jsx)(`option`,{value:e,children:d.enumNames?.[t]||e},e))]}):b?(0,F.jsx)(`div`,{className:`space-y-2`,"data-testid":T,children:d.items.enum.map(t=>{let r=`${w}-${t}`;return(0,F.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,F.jsx)(j,{id:r,checked:C.includes(t),onCheckedChange:r=>{n(e,r?[...C,t]:C.filter(e=>e!==t))}}),(0,F.jsx)(l,{htmlFor:r,className:`text-sm font-normal cursor-pointer`,children:t})]},t)})}):S?(0,F.jsx)(`div`,{className:`space-y-2`,"data-testid":T,children:x.map(t=>{let r=`${w}-${t.const}`;return(0,F.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,F.jsx)(j,{id:r,checked:C.includes(t.const),onCheckedChange:r=>{n(e,r?[...C,t.const]:C.filter(e=>e!==t.const))}}),(0,F.jsx)(l,{htmlFor:r,className:`text-sm font-normal cursor-pointer`,children:t.title||t.const})]},t.const)})}):m===`string`&&(d.format===`textarea`||d.maxLength>100)?(0,F.jsx)(A,{id:w,"data-testid":T,value:t[e]||``,onChange:t=>n(e,t.target.value),placeholder:d.default||``,rows:o}):(0,F.jsx)(s,{id:w,"data-testid":T,type:`text`,value:t[e]||``,onChange:t=>n(e,t.target.value),placeholder:d.default||``})]},e)})})},[e,t,n,r,i,a,o,c,u])})}function R(e){let[t,n]=(0,P.useState)({}),[r,i]=(0,P.useState)(!1),a=e?.request.mode||`form`,o=a===`form`,s=a===`url`;return(0,P.useEffect)(()=>{if(e&&o&&`requestedSchema`in e.request){let t=e.request.requestedSchema,r={};if(t?.type===`object`&&t.properties)for(let[e,n]of Object.entries(t.properties)){let t=n;t.default===void 0?t.type===`array`?r[e]=[]:t.type===`boolean`?r[e]=!1:t.type===`number`||t.type===`integer`?r[e]=0:r[e]=``:r[e]=t.default}n(r)}i(!1)},[e?.id,o]),{formData:t,setFieldValue:(0,P.useCallback)((e,t)=>{n(n=>({...n,[e]:t}))},[]),getMissingRequiredFields:(0,P.useCallback)(()=>!e||!o||!(`requestedSchema`in e.request)?[]:(e.request.requestedSchema?.required??[]).filter(e=>t[e]===void 0||t[e]===``||t[e]===null),[e,t,o]),urlCompleted:r,setUrlCompleted:i,mode:a,isFormMode:o,isUrlMode:s}}function z({request:t,onApprove:s,onReject:c,onClose:u,previewMode:d,onTogglePreview:f,isCopied:p,onCopy:m,onDownload:h,onFullscreen:v}){let{formData:b,setFieldValue:x,getMissingRequiredFields:C,urlCompleted:k,setUrlCompleted:A,mode:M,isFormMode:N,isUrlMode:P}=R(t);return t?(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b dark:border-zinc-700`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:t.serverName}),(0,F.jsx)(n,{variant:`outline`,className:P?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:M}),(0,F.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:new Date(t.timestamp).toLocaleString()})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(i,{children:[(0,F.jsx)(r,{render:(0,F.jsx)(o,{variant:`ghost`,size:`sm`,onClick:m,className:`h-8 w-8 p-0`,children:p?(0,F.jsx)(O,{className:`h-4 w-4 text-green-600`}):(0,F.jsx)(w,{className:`h-4 w-4`})}),nativeButton:!0}),(0,F.jsx)(a,{children:`Copy request`})]}),(0,F.jsxs)(i,{children:[(0,F.jsx)(r,{render:(0,F.jsx)(o,{variant:`ghost`,size:`sm`,onClick:h,className:`h-8 w-8 p-0`,children:(0,F.jsx)(T,{className:`h-4 w-4`})}),nativeButton:!0}),(0,F.jsx)(a,{children:`Download request`})]}),(0,F.jsxs)(i,{children:[(0,F.jsx)(r,{render:(0,F.jsx)(o,{variant:`ghost`,size:`sm`,onClick:v,className:`h-8 w-8 p-0`,children:(0,F.jsx)(g,{className:`h-4 w-4`})}),nativeButton:!0}),(0,F.jsx)(a,{children:`Fullscreen`})]}),(0,F.jsx)(o,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,F.jsx)(y,{className:`h-4 w-4`})})]})]}),(0,F.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Message`}),(0,F.jsx)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:t.request.message})]}),P&&`url`in t.request&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`External Action Required`}),(0,F.jsxs)(`div`,{className:`bg-muted rounded-lg p-4 space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This request requires you to complete an action at an external URL:`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-background rounded border`,children:[(0,F.jsx)(`code`,{className:`flex-1 text-xs font-mono break-all`,children:t.request.url}),(0,F.jsxs)(o,{size:`sm`,variant:`outline`,onClick:()=>{t&&P&&`url`in t.request&&(window.open(t.request.url,`_blank`),A(!0))},className:`flex items-center gap-2`,children:[(0,F.jsx)(D,{className:`h-4 w-4`}),`Open URL`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center space-x-2 pt-2`,children:[(0,F.jsx)(j,{id:`url-completed`,checked:k,onCheckedChange:e=>A(!!e)}),(0,F.jsx)(l,{htmlFor:`url-completed`,className:`text-sm font-normal cursor-pointer`,children:`I have completed the required action`})]})]})]}),N&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Form Data`}),(0,F.jsx)(L,{request:t,formData:b,onFieldChange:x,idPrefix:`field`,testIdPrefix:`elicitation-field`,emptyFallback:(0,F.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:`No form schema available`})})]}),N&&`requestedSchema`in t.request&&t.request.requestedSchema&&(0,F.jsxs)(`details`,{className:`space-y-2`,children:[(0,F.jsx)(`summary`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer`,children:`Schema (for reference)`}),(0,F.jsx)(`div`,{className:`bg-muted rounded-lg p-3 max-h-64 overflow-auto`,children:(0,F.jsx)(S,{data:t.request.requestedSchema})})]})]}),(0,F.jsxs)(`div`,{className:`flex gap-2 p-4 border-t dark:border-zinc-700`,children:[(0,F.jsx)(o,{onClick:()=>{if(t){if(N){let e=C();if(e.length>0){E.error(`Missing required fields`,{description:`Please fill in: ${e.join(`, `)}`});return}s(t.id,{action:`accept`,content:b})}else P&&s(t.id,{action:`accept`});u(),_(()=>import(`./react-CU_d2d5K.js`).then(t=>e(t.t(),1)).then(e=>{let t=E(e.createElement(`div`,{className:`space-y-3`},e.createElement(`div`,null,e.createElement(`strong`,null,`Elicitation Response Sent`),e.createElement(`p`,{className:`text-sm text-muted-foreground mt-1`},`The tool will continue executing.`)),e.createElement(`div`,{className:`flex gap-2`},e.createElement(`button`,{"data-testid":`elicitation-view-tool-result`,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,onClick:()=>{let e=new globalThis.CustomEvent(`navigate-to-tool-result`,{detail:{toolName:null}});window.dispatchEvent(e),E.dismiss(t)}},`View Tool Result`))),{duration:5e3})}),[])}},className:`flex-1`,disabled:P&&!k,"data-testid":`elicitation-accept-button`,children:`Accept`}),(0,F.jsx)(o,{onClick:()=>{t&&(s(t.id,{action:`decline`}),u())},variant:`outline`,className:`flex-1`,"data-testid":`elicitation-decline-button`,children:`Decline`}),(0,F.jsx)(o,{onClick:()=>{t&&(c(t.id,`User cancelled elicitation request`),u())},variant:`outline`,className:`flex-1`,"data-testid":`elicitation-cancel-button`,children:`Cancel`})]})]}):(0,F.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,F.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select an elicitation request to view details`})})}function B({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:i}){let{selectedElicitationRequestId:a,setSelectedElicitationRequestId:o}=b(),[s,c]=(0,P.useState)(null),[l,m]=(0,P.useState)(``),[g,_]=(0,P.useState)(-1),[v,S]=(0,P.useState)(!0),[w,T]=(0,P.useState)(!1),[E,D]=(0,P.useState)(!0),[O,A]=(0,P.useState)(!1),j=(0,P.useRef)(null),M=(0,P.useRef)(null),N=(0,P.useRef)(null),L=(0,P.useRef)(!1);(0,P.useEffect)(()=>{if(console.log(`[ElicitationTab] Auto-selection check:`,{selectedElicitationRequestId:a,pendingRequestsCount:e.length,currentSelectedId:s?.id}),a&&e.length>0){let t=e.find(e=>e.id===a);console.log(`[ElicitationTab] Found request for auto-selection:`,!!t,t?.id),t&&(console.log(`[ElicitationTab] Auto-selecting request:`,t.id),o(null),c(t),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${t.id}`);console.log(`[ElicitationTab] Scrolling to element:`,!!e),e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[a,e,o]),(0,P.useEffect)(()=>{let t=t=>{let n=t.detail.requestId;console.log(`[ElicitationTab] Custom navigate event received:`,n);let r=e.find(e=>e.id===n);r&&(console.log(`[ElicitationTab] Selecting request from event:`,n),c(r),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${n}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},200))};return window.addEventListener(`navigate-to-elicitation`,t),()=>window.removeEventListener(`navigate-to-elicitation`,t)},[e]),(0,P.useEffect)(()=>{v&&e.length>0&&j.current&&!L.current&&(j.current.scrollTop=0)},[e.length,v]),(0,P.useEffect)(()=>{let e=j.current;if(!e)return;let t=()=>{e.scrollTop>0&&(L.current=!0,S(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,P.useEffect)(()=>{e.length===0&&(L.current=!1,S(!0))},[e.length]),(0,P.useEffect)(()=>{w&&N.current&&N.current.focus()},[w]);let R=(0,P.useCallback)(()=>{l.trim()||T(!1)},[l]),B=(0,P.useMemo)(()=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.serverName.toLowerCase().includes(t)||e.request.message.toLowerCase().includes(t)||JSON.stringify(e.request||{}).toLowerCase().includes(t))},[e,l]);(0,P.useEffect)(()=>{_(-1)},[l]),(0,P.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=B;if(e.key===`ArrowDown`)e.preventDefault(),_(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),_(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&g>=0){e.preventDefault();let t=B[g];t&&V(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[g,B]),(0,P.useEffect)(()=>{if(g>=0){let e=`elicitation-request-${B[g]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[g,B]);let V=(0,P.useCallback)(e=>{c(e)},[]),H=(0,P.useCallback)(()=>{window.confirm(`Are you sure you want to cancel all elicitation requests? This cannot be undone.`)&&(e.forEach(e=>{n(e.id,`User cancelled all requests`)}),c(null))},[e,n]),U=(0,P.useCallback)(async()=>{if(s)try{await k(JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(e){console.error(`[ElicitationTab] Failed to copy request:`,e)}},[s]),W=(0,P.useCallback)(()=>{if(s)try{let e=new globalThis.Blob([JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[ElicitationTab] Failed to download request:`,e)}},[s]),G=(0,P.useCallback)(async()=>{if(M.current)try{document.fullscreenElement?await document.exitFullscreen():await M.current.requestFullscreen()}catch(e){console.error(`[ElicitationTab] Failed to toggle fullscreen:`,e)}},[]);return i?(0,F.jsxs)(p,{orientation:`horizontal`,className:`h-full`,children:[(0,F.jsx)(u,{defaultSize:40,minSize:30,children:(0,F.jsx)(p,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,F.jsx)(u,{defaultSize:75,minSize:30,className:`h-full overflow-hidden`,children:(0,F.jsx)(f,{scrollRef:j,children:t=>(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(h,{isScrolled:t,title:`Elicitation`,icon:x,titleTestId:`elicitation-tab-header`,count:B.length,isSearchExpanded:w,searchQuery:l,searchPlaceholder:`Search requests...`,onSearchExpand:()=>T(!0),onSearchChange:m,onSearchBlur:R,bulkAction:{icon:y,label:`Cancel all`,onClick:H,disabled:e.length===0},searchInputRef:N}),(0,F.jsx)(I,{requests:B,selectedRequest:s,onRequestSelect:V,focusedIndex:g,formatRelativeTime:C})]})})})})}),(0,F.jsx)(d,{}),(0,F.jsx)(u,{defaultSize:60,minSize:40,children:(0,F.jsx)(`div`,{ref:M,className:`h-full bg-white dark:bg-zinc-900`,children:(0,F.jsx)(z,{request:s,onApprove:t,onReject:n,onClose:()=>c(null),previewMode:E,onTogglePreview:()=>D(!E),isCopied:O,onCopy:U,onDownload:W,onFullscreen:G})})})]}):(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,F.jsx)(x,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,F.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}export{B as ElicitationTab};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react-CU_d2d5K.js";import{Cr as n,Sr as r,br as i,mr as a,pr as o}from"./input-CLYhA7PK.js";var s=e(t(),1);function c(e,t){let i=s.useRef(e),a=n(t);r(()=>{i.current!==e&&a(i.current)},[e,a]),r(()=>{i.current=e},[e])}var l=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),u={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},d={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},f={disabled:!1,...d},p={valid(e){return e===null?null:e?{[l.valid]:``}:{[l.invalid]:``}}},m={invalid:void 0,name:void 0,validityData:{state:u,errors:[],error:``,value:``,initialValue:null},setValidityData:a,disabled:void 0,touched:d.touched,setTouched:a,dirty:d.dirty,setDirty:a,filled:d.filled,setFilled:a,focused:d.focused,setFocused:a,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:f,markedDirtyRef:{current:!1},registerFieldControl:a,validation:{getValidationProps:(e,t=o)=>t,inputRef:{current:null},registerInput:a,commit:async()=>{},change:a}},h=s.createContext(m);function g(e=!0){let t=s.useContext(h);if(t.setValidityData===a&&!e)throw Error(i(28));return t}function _(e,t,n,i,a=!0,o){let{registerFieldControl:c}=g(),l=s.useRef(null);l.current||=Symbol(),r(()=>{let r=l.current;if(!(!r||!a))return c(r,{controlRef:e,getValue:i,id:t,name:o,value:n}),()=>{c(r,void 0)}},[e,a,i,t,o,c,n])}var v=s.createContext({controlId:void 0,registerControlId:a,labelId:void 0,setLabelId:a,messageIds:[],setMessageIds:a,getDescriptionProps:e=>e});function y(){return s.useContext(v)}var b=s.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:a,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function x(){return s.useContext(b)}export{h as a,p as c,_ as i,c as l,v as n,g as o,y as r,u as s,x as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{G as e,Lr as t,Nr as n,a as r,d as i,l as a,n as o,r as s,sr as c,t as l,u}from"./input-CLYhA7PK.js";import{t as d}from"./jsx-runtime-Cjj9sGSy.js";import{t as f}from"./refresh-cw-C9wQl8_d.js";var p=d();function m({className:e,...n}){return(0,p.jsx)(`kbd`,{"data-slot":`kbd`,className:t(`bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none`,`[&_svg:not([class*='size-'])]:size-3`,`[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10`,e),...n})}var h=`h-3.5 w-3.5 shrink-0 text-muted-foreground`;function g({activeTab:t,isSearchExpanded:d,searchQuery:g,primaryTabTitle:_,secondaryTabTitle:v,primaryCount:y,secondaryCount:b,secondaryIcon:x,primaryIcon:S,searchPlaceholder:C=`Search...`,onSearchExpand:w,onSearchChange:T,onSearchBlur:E,onTabSwitch:D,searchInputRef:O,primaryTabName:k,onRefresh:A,isRefreshing:j=!1,isScrolled:M=!1}){let N=t===k,P=N?S:x,F=N?_:v;return(0,p.jsxs)(`div`,{className:`flex flex-row items-center justify-between gap-2 ${a(M)} ${u}`,children:[(0,p.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:d?(0,p.jsx)(l,{ref:O,placeholder:C,value:g,onChange:e=>T(e.target.value),onBlur:E,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`h2`,{className:`${i} flex items-center gap-1.5`,children:[(0,p.jsx)(P,{className:h,"aria-hidden":!0}),F]}),N&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:y}),(0,p.jsxs)(o,{children:[(0,p.jsx)(r,{render:(0,p.jsx)(c,{variant:`ghost`,size:`sm`,onClick:w,className:`h-8 w-8 p-0`,children:(0,p.jsx)(e,{className:`h-4 w-4`})}),nativeButton:!0}),(0,p.jsxs)(s,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,p.jsx)(m,{children:`F`})]})]}),A&&(0,p.jsxs)(o,{children:[(0,p.jsx)(r,{render:(0,p.jsx)(c,{variant:`ghost`,size:`sm`,onClick:A,disabled:j,className:`h-8 w-8 p-0`,children:(0,p.jsx)(f,{className:`h-4 w-4 ${j?`animate-spin`:``}`})}),nativeButton:!0}),(0,p.jsxs)(s,{side:`bottom`,className:`flex gap-2`,children:[`Refresh list`,(0,p.jsx)(m,{children:`R`})]})]})]})]})}),(0,p.jsxs)(c,{variant:`ghost`,size:`sm`,onClick:D,className:`gap-2 flex-shrink-0`,children:[(0,p.jsx)(`span`,{className:`hidden sm:inline`,children:N?v:_}),N&&b>0&&(0,p.jsx)(n,{className:`bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent`,variant:`outline`,children:b})]})]})}export{h as n,m as r,g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{in as r,j as i}from"./index-TQ5V7cM9.js";var a=e(t(),1),o=n();function s(){let[e,t]=(0,a.useState)(null);return(0,a.useEffect)(()=>{i().then(()=>window.close()).catch(e=>{t(e instanceof Error?e.message:String(e))})},[]),(0,o.jsx)(`div`,{className:`flex h-screen w-full items-center justify-center bg-background`,children:(0,o.jsx)(`div`,{className:`flex max-w-md flex-col items-center gap-4 p-6 text-center`,children:e?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`h1`,{className:`text-lg font-semibold text-destructive`,children:`Authorization failed`}),(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(r,{className:`size-8 animate-spin text-muted-foreground`}),(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Completing Manufact authorization…`})]})})})}export{s as ManufactOAuthCallback};
|