@xopcai/xopc 0.0.427 → 0.0.428
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-D_DXNHba.js → activity-store-WqnVruhY.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CjaQxFQt.js → agent-avatar-dicebear-CSiO9c2F.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-display-6Z4m31Fz.js → agent-avatar-display-D-yds6wG.js} +2 -2
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-D4ClP_DJ.js → agent-defaults-settings-panel-_UT9C7bg.js} +1 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-DVzYXsAy.js +1 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-u5c3GREg.js → agents-admin-api-Bgv4lJ9Y.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-B9slUA_1.js → agents-yTsbcxRi.js} +3 -3
- package/dist/gateway/static/root/assets/{api-C3Tp9MkF.js → api-C-9J9ghT.js} +1 -1
- package/dist/gateway/static/root/assets/{api-CRT9ZyH0.js → api-Dv6Cn-Rs.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-XqoIBF2H.js → app-management-settings-panel-BXJrrjH5.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-9ZtqCASo.js → appearance-settings-oYjAVulT.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DUeu_7iC.js → apps-page-D95yzj-f.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-BCQnOkV8.js → archive-plugin-DBPu3xCJ.js} +1 -1
- package/dist/gateway/static/root/assets/automation-api-DAou8Kji.js +1 -0
- package/dist/gateway/static/root/assets/{automation-result-state-CMfVTv_i.js → automation-result-state-CA7LV098.js} +1 -1
- package/dist/gateway/static/root/assets/automation-task-card-w6cKxfaP.js +3 -0
- package/dist/gateway/static/root/assets/{automations-page-DMIyWsP0.js → automations-page-D4LyOLzY.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-BGyvZZj5.js +9 -0
- package/dist/gateway/static/root/assets/{binary-plugins-CIB5cbvQ.js → binary-plugins-D25P9ZxQ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CXdlNAmZ.js → block-editor-BI105p1U.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-Fxo7HbK6.js → browser-automation-inputs-DhDRvWQE.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-Dn3LN5wo.js → browser-automations-page-CCPi1Bvy.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-control-api-CbbPvhHR.js → browser-control-api-BN4F-bM1.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-Cpm9fEPV.js → browser-settings-page-BZXUZpjp.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-BEvywfF9.js → capabilities-LC-yEQYo.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-BCzsIzvC.js → capabilities-page-DHJLl4RD.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-FJ3Vo7Wa.js +8 -0
- package/dist/gateway/static/root/assets/capabilities-u2z_KFRt.js +1 -0
- package/dist/gateway/static/root/assets/{channels-CA5z5dGY.js → channels-9Uaa-IN0.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-agents-api-D8YS5amE.js → chat-agents-api-Cffxfzi1.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-chart-block-B39npsXj.js → chat-chart-block-Bbk0b3TV.js} +1 -1
- package/dist/gateway/static/root/assets/chat-page--dKUIg5W.js +72 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DjFnElAM.js → chat-terminal-dock-CQMuG-Bz.js} +1 -1
- package/dist/gateway/static/root/assets/{command-palette-api-Dijix7V6.js → command-palette-api-BRxfFgGA.js} +1 -1
- package/dist/gateway/static/root/assets/composer-payload-handoff-_9L2A5AZ.js +1 -0
- package/dist/gateway/static/root/assets/{computer-settings-page-MkqyKyf3.js → computer-settings-page-Bm70SIjD.js} +1 -1
- package/dist/gateway/static/root/assets/{connected-providers-grid-BSvKP2u-.js → connected-providers-grid-B7ktDgqt.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-DlIl9bLx.js → connector-service-page-BVMEg8n-.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-DEJU8mgn.js → connectors-api-B07yoCzk.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-hPKaJUWY.js +1 -0
- package/dist/gateway/static/root/assets/{date-picker-BIfjfOTM.js → date-picker-BvEnSGZK.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DFNehTtd.js → desktop-pet-C1z9YDEg.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BDjsFown.js → desktop-pet-settings-CbbVb8GY.js} +1 -1
- package/dist/gateway/static/root/assets/{dev-view-store-CeZZLOc6.js → dev-view-store-38EmUIEC.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-DH_uJ698.js → device-pairing-wizard-Wb1EKiXA.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DiZXY7jF.js → directory-picker-path-field-BvKDrKc4.js} +1 -1
- package/dist/gateway/static/root/assets/{discussion-annotation-sync-BXqNuZnx.js → discussion-annotation-sync-BfVzIwe2.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-myQqsol2.js → extension-debug-page-CB9Lu3Sq.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-DaL-OcTw.js → extension-iframe-host-BzjrVAUR.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-marketplace-api-DRBszrCR.js → extension-marketplace-api-DigziAgd.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DvlGhZLa.js → extension-page-DUa9MeaZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-fOi6V6Cr.js → extension-provider-301x0rh-.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DOGlQpkx.js → extension-settings-page-CP9ciZUI.js} +1 -1
- package/dist/gateway/static/root/assets/{file-preview-surface-DfkXvFnc.js → file-preview-surface-BaMGmCbw.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BOCt_zOo.js → gateway-config-swr-BD4Bf8uu.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-BL_Cf0OQ.js → gateway-realtime-CSd9VB7Z.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-Bxkv62qs.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-restart-CHf8qY7H.js → gateway-restart-CIUCTKYR.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-Di41peSM.js → gateway-settings-CCqF1uZv.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CvkJYurV.js → gateway-startup-retry-BsU5k8oi.js} +1 -1
- package/dist/gateway/static/root/assets/{global-defaults-api-BWMbKu72.js → global-defaults-api-asOZQeM8.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-Bb_RC1O9.js +2 -0
- package/dist/gateway/static/root/assets/{image-generation-api-Ce-IY7Ug.js → image-generation-api-BbEnKsK1.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-W7_cDbxy.js → imports-page-CVnoGUyp.js} +1 -1
- package/dist/gateway/static/root/assets/index-ClPeYgQk.js +11 -0
- package/dist/gateway/static/root/assets/index-Cz-VjTNd.css +1 -0
- package/dist/gateway/static/root/assets/{install-connector-dialog-DWVl9ekV.js → install-connector-dialog-DXVOHMhS.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Doyu0Q9e.js → keyboard-shortcuts-settings-BCl90SrD.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-B3h3P6aI.js → local-app-workbench-page-CcJc9xLJ.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-D6D2bZGW.js → local-apps-page-CdAKoWfg.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-BJ1B1dQ7.js → local-session-drafts-nRGeybku.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Br7IfbXK.js → locale-store-B7y-RVe8.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-qiXos_12.js → logs-page-McbSQwJI.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-C0WcSdK7.js → management-settings-BIR0BwNV.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-Ck5s16p9.js → markdown-view-DFHa8rUg.js} +1 -1
- package/dist/gateway/static/root/assets/mcp-conversation-setup-page-Dwx4TuIr.js +1 -0
- package/dist/gateway/static/root/assets/{media-plugins-Ba6vUE4J.js → media-plugins-BzzLV7wW.js} +1 -1
- package/dist/gateway/static/root/assets/messages-DYDkJvXj.js +3 -0
- package/dist/gateway/static/root/assets/{model-selector-DCBmsHzj.js → model-selector-DJSVr3LM.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-cache-Bd-fYUrV.js → models-hub-cache-BUapaPTN.js} +1 -1
- package/dist/gateway/static/root/assets/new-chat-navigation-B6NPQ4h4.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-CnuxqWMd.js → note-detail-panel-CJ-dPovd.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-ClPkeHe5.js +1 -0
- package/dist/gateway/static/root/assets/{notes-api-8kp0X1x6.js → notes-api-ulup1oFS.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-XMdy-H3H.js → notes-page-BaFNplIr.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-api-DMMdeaNd.js → oauth-api-DINa08-z.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-provider-connect-CfOK8mPM.js → oauth-provider-connect-C0PVEHC2.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-CKlKWSJ7.js → page-context-capture-button-CGfR0dsc.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-draft-LF33STHC.js → page-context-draft-DhRNxc0v.js} +1 -1
- package/dist/gateway/static/root/assets/page-header-store-CoKMiYoi.js +1 -0
- package/dist/gateway/static/root/assets/{personal-avatar-D6CzIIfo.js → personal-avatar-DiVFO2Aw.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-CIMMSI25.js → personal-page-CiKdXLeR.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-wKdlrfPq.js → personal-settings-panel-Ds4ntiqu.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-dependencies-card-CDhk5277.js → phone-dependencies-card-B3R6L5Qu.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-connection-DZ-ZunPz.js → phone-model-connection-ucX3Tvl8.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-picker-DuZc5jYO.js → phone-model-picker-CU37sziM.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-settings-page-0u0GQl_R.js → phone-settings-page-BSdB2pnW.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-workspace-store-SN7hfddU.js → phone-workspace-store-Cmes9gQ4.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-Bfc-Wmrd.js → plugin-details-dialog-DblFhnuC.js} +1 -1
- package/dist/gateway/static/root/assets/{preference-select-fields-BKeHZLXZ.js → preference-select-fields-D2-QfMN5.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-BPur0vyo.js → product-automation-feedback-BzY3z8zu.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-Bfd7R483.js → product-open-page-BKw6H0Mn.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-Bnq68oVw.js → product-preview-content-CNaJb6Bj.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-modal-BPmTeweh.js → product-preview-modal-DgwrrpqJ.js} +2 -2
- package/dist/gateway/static/root/assets/project-detail-page-FReFYUv0.js +7 -0
- package/dist/gateway/static/root/assets/{project-understanding-DLvxAoTT.js → project-understanding-CrSkrJnM.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-BGy1pw9a.js → projects-page-Cp91_KzA.js} +1 -1
- package/dist/gateway/static/root/assets/{providers-api-DOnNfkwQ.js → providers-api-CBSC3jdu.js} +1 -1
- package/dist/gateway/static/root/assets/{recording-upload-CHFJbqW1.js → recording-upload-DBHAGKZj.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-DFDvOTg4.js → registry-api-QZEjziDq.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BVqwnOqO.js → remote-access-hub-BdXxFQfH.js} +1 -1
- package/dist/gateway/static/root/assets/{resource-unavailable-TQcRCpAg.js → resource-unavailable-BTNhcOHF.js} +1 -1
- package/dist/gateway/static/root/assets/route-preload-DS4fVFbc.js +2 -0
- package/dist/gateway/static/root/assets/{runtime-tools-api-9o3Wfji1.js → runtime-tools-api-BDTUD8Rj.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-ccVBG-bZ.js → runtime-tools-settings-panel-CYEzIrDf.js} +1 -1
- package/dist/gateway/static/root/assets/{service-recommendation-list-CNghOavt.js → service-recommendation-list-CfeYH6lK.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-Bs3r_d2_.js → session-api-DVXLCZX2.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-Bnq3qpqy.js → session-manager-DjRWxXJG.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-CyBj1Xw2.js → sessions-page-C8gwrFHR.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BMHe9uwy.js +1 -0
- package/dist/gateway/static/root/assets/{settings-advanced-section-DwpPPxT0.js → settings-advanced-section-BmrbHgQa.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-mode-store-CiRpsdTJ.js → settings-mode-store-Bk_hzwPK.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-Cd8Ermnn.js → settings-page-DCQnHCNN.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-header-BZl4AMiN.js → settings-page-header-BLKI3_9N.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-onhEgq-K.js → settings-page-layout-BqBVrkC9.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-interaction-page-Cvvj6JyV.js → setup-interaction-page-B9ACeAvO.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-D4qgE7QM.js → setup-status-panel-DEefuWo3.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-DA0QuFOD.js → share-link-dialog-C2LyeNzj.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-YDpIY4dC.js → share-preview-page-BFwEr7Ws.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-D8Q-m46d.js → shares-api-CTFkLQxq.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-DUvjOMmA.js → shares-settings-CpK3yhtc.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-uKU4sRiv.js → skill-api-DpicfA6o.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-list-api-BzKzG-xG.js → skill-list-api-B8fegRLZ.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-DkUXekcd.js → skill-reload-api-VmC8ySUy.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-ClyNSh-7.js → skills-page-BIWXS6Ki.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BN6sUX0H.js → system-settings-panel-BmoA92oX.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-L5RIelv0.js +3 -0
- package/dist/gateway/static/root/assets/{task-result-evidence-DKygspo2.js → task-result-evidence-BV-6hBVU.js} +1 -1
- package/dist/gateway/static/root/assets/{terminal-panel-store-DJVC7HqA.js → terminal-panel-store-BGdKE9hU.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-Dlnmgryi.js → theme-store-Dvv79Wb2.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-Bs76WeoF.js → tracing-settings-page-B4uA4Pnz.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-B7nx0NQJ.js → tunnel-api-BurZtvqx.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-activity-store-C4bblRnQ.js → understanding-activity-store-C1cLL8zq.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-refresh-store-BvCj9-Ue.js → understanding-refresh-store-C3Lr_pjY.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-anU5gslJ.js → usage-page-C91ZzLm9.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-YHxQ-UZg.js → use-autosave-zkzRuUtx.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-DYY3Yz4a.js → use-composer-attachments-CoiQAgjo.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-CYgWzDnv.js → use-file-preview-expanded-DFzy6iVy.js} +2 -2
- package/dist/gateway/static/root/assets/{use-personal-profile-D2Un8G1L.js → use-personal-profile-BB10h9ED.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-Dkg9tUr4.js → use-workspace-tree-sF5DcONt.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-WFnD5utO.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-BUes-Jlp.js → voice-api-key-field-Bqa4PeZx.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-CrULrSKC.js → voice-config-api-LNO2xXHk.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-input-shortcut-events-DFMNIyy4.js → voice-input-shortcut-events-AzfhxBX7.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-transcribe-api-Dy4hfftb.js → voice-transcribe-api-Cb8i6dLb.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CFF4cRFl.js → work-discovery-overlay-CdQUiV-a.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-BnYaVH3V.js → work-discovery-page-HcUloXxf.js} +1 -1
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-GFwVefVA.js → working-directory-picker-modal-Dv1HUipe.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-BdB4NEOh.js → workspace-api-Am2ee4R6.js} +2 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-CqHcVFhS.js +1 -0
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-NRL3YRjg.js → workspace-file-preview-dialog-z5Q00v92.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-open-location-menu-Dcij7wvJ.js → workspace-open-location-menu-4ONYaGy0.js} +1 -1
- package/dist/gateway/static/root/assets/xopc-cloud-account-card-DimGN59n.js +1 -0
- package/dist/gateway/static/root/index.html +80 -80
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/automations.js +1 -0
- package/dist/packages/gateway-contract/src/capabilities.js +6 -2
- package/dist/packages/gateway-contract/src/home.js +12 -2
- package/dist/src/agent/background-review/prompts.js +11 -6
- package/dist/src/agent/background-review/run-background-review.js +12 -3
- package/dist/src/agent/context/execution-context.js +3 -1
- package/dist/src/agent/embedded/configuration-capability-correction.js +1 -1
- package/dist/src/agent/embedded/run-turn.js +12 -1
- package/dist/src/agent/embedded/session-runner.js +4 -0
- package/dist/src/agent/mcp/connection-drafts.d.ts +2 -1
- package/dist/src/agent/mcp/connection-drafts.js +3 -2
- package/dist/src/agent/mcp/connection-setup.d.ts +15 -1
- package/dist/src/agent/mcp/connection-setup.js +219 -106
- package/dist/src/agent/mcp/continuation-guard.d.ts +3 -0
- package/dist/src/agent/mcp/continuation-guard.js +54 -0
- package/dist/src/agent/mcp/continuation-input.d.ts +4 -0
- package/dist/src/agent/mcp/continuation-input.js +13 -0
- package/dist/src/agent/mcp/conversation-setup.d.ts +121 -2
- package/dist/src/agent/mcp/conversation-setup.js +274 -39
- package/dist/src/agent/mcp/discovery.d.ts +102 -0
- package/dist/src/agent/mcp/discovery.js +219 -0
- package/dist/src/agent/mcp/native-mcp.js +8 -1
- package/dist/src/agent/mcp/setup-plan.d.ts +76 -0
- package/dist/src/agent/mcp/setup-plan.js +93 -0
- package/dist/src/agent/mcp/tool-catalog.d.ts +2 -0
- package/dist/src/agent/mcp/tool-catalog.js +7 -1
- package/dist/src/agent/mcp/transport.d.ts +20 -0
- package/dist/src/agent/mcp/transport.js +188 -0
- package/dist/src/agent/orchestration/delegation-scope.d.ts +2 -1
- package/dist/src/agent/prompt/conversational-configuration-guide.js +1 -1
- package/dist/src/agent/service/direct-turn-helpers.js +2 -1
- package/dist/src/agent/service/process-direct-streaming.js +2 -1
- package/dist/src/agent/service.js +5 -1
- package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +2 -2
- package/dist/src/agent/tool-manuals/xopc-configuration.js +37 -4
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/mcp-setup-tool.js +6 -2
- package/dist/src/agent/tools/xopc-use-tool.d.ts +1 -0
- package/dist/src/agent/tools/xopc-use-tool.js +21 -0
- package/dist/src/automations/api/routes.js +13 -5
- package/dist/src/automations/capabilities/read.js +31 -3
- package/dist/src/automations/domain/types.d.ts +2 -0
- package/dist/src/automations/service/automation-service.d.ts +7 -0
- package/dist/src/automations/service/automation-service.js +9 -2
- package/dist/src/automations/storage/automation-run-repository.d.ts +11 -2
- package/dist/src/automations/storage/automation-run-repository.js +28 -24
- package/dist/src/automations/storage/index.js +2 -2
- package/dist/src/config/schema.d.ts +3 -0
- package/dist/src/config/schema.js +3 -2
- package/dist/src/extensions/agent-plugins/setup.d.ts +1 -0
- package/dist/src/extensions/agent-plugins/setup.js +1 -0
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +0 -4
- package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
- package/dist/src/gateway/service.js +9 -8
- package/dist/src/home-intelligence/evidence-presentation.d.ts +3 -0
- package/dist/src/home-intelligence/evidence-presentation.js +30 -0
- package/dist/src/home-intelligence/generator.d.ts +8 -0
- package/dist/src/home-intelligence/generator.js +15 -4
- package/dist/src/home-intelligence/policy.js +3 -0
- package/dist/src/memory-learning/repository.d.ts +6 -1
- package/dist/src/memory-learning/repository.js +10 -5
- package/dist/src/memory-learning/service.js +23 -1
- package/dist/src/process/mcp-stdio-supervisor.d.ts +1 -0
- package/dist/src/process/mcp-stdio-supervisor.js +14 -0
- package/dist/src/tasks/task-criterion-review-repository.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/user-context/extraction/registry.js +2 -2
- package/dist/src/user-model/capture/executor.d.ts +1 -0
- package/dist/src/user-model/capture/executor.js +6 -6
- package/dist/src/user-model/capture/semantic.d.ts +3 -0
- package/dist/src/user-model/capture/semantic.js +14 -4
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-m1A8wF9p.js +0 -1
- package/dist/gateway/static/root/assets/automation-api-hRsGx-qe.js +0 -1
- package/dist/gateway/static/root/assets/automation-task-card-Bur78p68.js +0 -3
- package/dist/gateway/static/root/assets/automations-workspace-DEkDjxeU.js +0 -9
- package/dist/gateway/static/root/assets/capabilities-Bo2qEJhH.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-settings-panel-Cr67ziwX.js +0 -8
- package/dist/gateway/static/root/assets/chat-page-D92AWJbh.js +0 -72
- package/dist/gateway/static/root/assets/composer-payload-handoff-BQXlFKf4.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-Vx8-MY0Y.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BHBOPF_q.js +0 -1
- package/dist/gateway/static/root/assets/home-page-B3sgqrl3.js +0 -2
- package/dist/gateway/static/root/assets/index-D4B6O8B3.js +0 -11
- package/dist/gateway/static/root/assets/index-DGWBJDAM.css +0 -1
- package/dist/gateway/static/root/assets/mcp-conversation-setup-page-CENs3hGU.js +0 -1
- package/dist/gateway/static/root/assets/messages-ByFlEbsu.js +0 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-BFKZ7qJr.js +0 -1
- package/dist/gateway/static/root/assets/page-header-store-Du44NIEJ.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-D9nnyvrI.js +0 -7
- package/dist/gateway/static/root/assets/route-preload-DI43HQV_.js +0 -2
- package/dist/gateway/static/root/assets/send-1f1Ntw6E.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BI4DMz4_.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-CS9m7Ipo.js +0 -2
- package/dist/gateway/static/root/assets/user-model-page-DIgPL3tN.js +0 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-4cZ26iaD.js +0 -1
- package/dist/gateway/static/root/assets/xopc-cloud-account-card-DC9aG7Pl.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,p as o,r as s}from"./locale-store-Br7IfbXK.js";import{t as c}from"./check-DUBLcKHA.js";import{t as l}from"./circle-alert-BEjgurr2.js";import{x as u}from"./use-file-preview-expanded-CYgWzDnv.js";import{t as ee}from"./mic-CuUb7zc-.js";import{t as d}from"./rotate-ccw-JM1TBLpp.js";import{t as f}from"./settings-2-D-csvaET.js";import{t as te}from"./x-B_N4OPjy.js";import{t as p}from"./cn-0WouolD0.js";import{t as ne}from"./skeleton-BI5TyibZ.js";import{a as m,f as h,i as re,l as ie,n as g,r as ae,t as oe,u as se}from"./voice-transcribe-api-Dy4hfftb.js";import{d as _}from"./tasks-DRmd6sWt.js";import{s as v}from"./file-preview-surface-DfkXvFnc.js";import{t as y}from"./open-capability-settings-Cvb65hQB.js";import{n as b}from"./interaction-BdhHBbYa.js";import{t as x}from"./workspace-editor-agent-store-4cZ26iaD.js";import{l as S,p as C}from"./voice-input-shortcut-events-DFMNIyy4.js";function w(e){let t=e.task.contract?.acceptanceCriteria??[],n=new Map(e.runs.map(e=>[e.id,e])),r=e.receipts.filter(t=>n.get(t.runId)?.contractVersion===e.task.latestContractVersion).sort((e,t)=>t.finalizedAt-e.finalizedAt);return t.map((t,n)=>{let i=e.criterionReviews.find(r=>r.criterionIndex===n&&r.contractVersion===e.task.latestContractVersion&&r.criterionText===t),a={text:t,status:`unverified`,evidence:[]};for(let e of r){let n=e.verification.checks.find(e=>e.criterion===t);if(!n)continue;let r=e.evidence.filter(e=>n.evidenceTitles.includes(e.title)),i=n.status===`passed`&&_(e).has(t)?`passed`:n.status===`failed`?`failed`:`unverified`;a={text:t,status:i,evidence:r,runId:e.runId,verificationStatus:i,method:n.method,note:n.note};break}return i&&e.task.contract?.acceptancePolicy!==`verified_auto`?{...a,status:i.status,review:i}:e.task.contract?.acceptancePolicy===`manual`?{...a,status:`unverified`}:a})}function T(e){let t=new Set(e.runs.filter(t=>t.contractVersion===e.task.latestContractVersion).map(e=>e.id));return e.receipts.filter(e=>t.has(e.runId)).sort((e,t)=>t.finalizedAt-e.finalizedAt)[0]}function E(e){let t=T(e),n=w(e);return{receipt:t,verified:n.filter(e=>e.status===`passed`).length,criteria:n.length,deliverables:e.context.filter(e=>e.role===`deliverable`).length}}function D(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`:e.waits.some(e=>e.kind===`paused`)?`paused`:e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`)?`needsUser`:e.operationalState===`idle`?e.task.phase===`backlog`?`captured`:e.task.phase===`ready`?`ready`:e.task.phase===`review`?`review`:`ready`:e.operationalState}function O(e){return e===`failed`?`bg-danger/10 text-danger`:e===`needsUser`||e===`blocked`?`bg-warning/10 text-warning`:e===`completed`?`bg-success-soft text-success`:e===`running`||e===`verifying`||e===`review`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-muted`}function k(e){return e===`zh`?{newWork:`交给 xopc`,dialogTitle:`现在想完成什么?`,dialogDescription:`发送后会进入新对话。xopc 会直接回答或开始处理;需要持续推进时,再转为任务。`,intentLabel:`告诉 xopc 你要做什么`,intentPlaceholder:`例如:整理这周的会议记录,提炼待办并给出下周优先级`,intentSuggestion:`整理这周的会议记录,提炼待办并给出下周优先级`,submit:`进入对话并开始`,projectLabel:`归属项目`,monitoringLabel:`跟进策略`,monitoringModes:{observe:`仅观察`,ask_before_action:`行动前询问`,auto_low_risk:`自动执行低风险操作`},existingProject:`已有项目`,newProject:`新项目`,needsAttention:`需要你处理`,waitingStatus:`当前等待`,runAttention:`运行异常`,running:`xopc 正在处理`,continue:`继续推进`,recent:`最近对话`,evidenceCount:`项证据`,remainingCount:`项待继续`,projects:`长期项目`,emptyRunning:`当前没有正在处理的对话`,emptyContinue:`还没有需要继续推进的事项`,openChat:`打开对话`,whyNow:`为什么现在`,impact:`影响`,workDone:`AI 已完成`,recommendation:`建议`,policyReason:`处理依据`,proposedAction:`拟执行动作`,actionStates:{not_authorized:`仅建议,未获自动执行授权`,approval_required:`等待你批准`,pending:`等待执行`,executing:`正在执行`,completed:`已自动执行`,rejected:`已拒绝`,failed:`执行失败`},judgmentReasons:`判断依据`,rejectedAlternatives:`未选方案`,uncertainty:`不确定性`,snooze:`明天再看`,dismiss:`忽略`,feedbackPlaceholder:`告诉 AI:以后遇到这类情况应该怎样判断…`,applyFeedback:`调整后续判断`,evidence:`证据引用`,useful:`有帮助`,notUseful:`没帮助`,taskStatuses:{pending:`待推进`,planning:`正在明确完成标准`,waiting_dependency:`等待前置任务`,running:`正在推进`,verifying:`正在验证`,needs_user:`需要你`,blocked:`已阻塞`,paused:`已暂停`,completed:`已完成`,cancelled:`已结束`},taskProgress:{title:`xopc 已接手`,open:`查看结果`,decide:`查看并决定`,evidence:`项已验证依据`,statuses:{pending:`待推进`,planning:`正在明确完成标准`,waiting_dependency:`等待前置任务`,running:`正在推进`,verifying:`正在验证`,needs_user:`需要你`,blocked:`已阻塞`,paused:`已暂停`,completed:`已完成`,cancelled:`已结束`}},detailStatuses:{allocating:`正在分配执行者`,captured:`尚未安排`,ready:`等待开始`,queued:`已进入队列`,running:`正在执行`,verifying:`正在验证`,waiting:`等待条件`,blocked:`被阻塞`,failed:`执行失败`,cancelled:`执行已取消`,needsUser:`需要你处理`,review:`等待验收`,completed:`已完成`,ended:`已结束`,paused:`已暂停`},detailStatusDescriptions:{allocating:`任务已提交,正在后台选择合适的执行者。`,captured:`任务已记录,但尚未进入执行队列。安排后,xopc 会开始推进。`,ready:`任务已经准备好,可以交给 xopc 开始执行。`,queued:`任务已进入执行队列,xopc 将在资源可用时开始。`,running:`xopc 正在推进这个任务。`,verifying:`xopc 正在根据完成标准核验结果。`,waiting:`任务正在等待外部条件满足。`,blocked:`当前存在阻塞条件,解除后才能继续。`,failed:`最近一次执行失败;查看运行记录后可以重试。`,cancelled:`最近一次执行已取消;任务仍可重新开始。`,needsUser:`xopc 需要你的输入或批准后才能继续。`,review:`执行结果已经准备好,等待你验收。`,completed:`任务已经完成并关闭。`,ended:`任务已经结束,不会继续执行。`,paused:`已暂停自动推进和催办。恢复后仍需满足其他等待条件。`},statusSummary:`当前状态`,taskLabel:`任务`,taskDescription:`任务描述与目标`,editTaskField:`编辑`,saveTaskField:`保存`,cancelTaskField:`取消`,noTaskDescription:`添加任务背景、范围和交付要求。`,taskProperties:`任务属性`,taskPhase:`阶段`,priority:`优先级`,dueDate:`截止日期`,executorLabel:`执行 Agent`,priorityLabels:{low:`低优先级`,normal:`普通优先级`,high:`高优先级`,critical:`紧急`},unassigned:`未指定执行者`,noDueDate:`无截止时间`,updatedAt:`更新于 {{date}}`,successDefinition:`怎样才算完成`,taskDefinition:`任务定义`,criteriaProgress:`{{verified}}/{{total}} 已验证`,taskRelations:`任务关系`,dependencies:`前置任务`,dependents:`后续任务`,noDependencies:`没有前置任务`,noDependents:`没有后续任务`,editDependencies:`编辑前置任务`,saveDependencies:`保存关系`,cancelDependencyEdit:`取消`,dependenciesDescription:`所选任务全部完成后,xopc 才会开始推进当前任务。`,linkDependencies:`关联前置任务`,linkedDependencies:`已关联 {{count}} 个前置任务`,dependencySearchPlaceholder:`搜索任务名称`,noDependencyMatches:`没有匹配的任务`,noDependencyCandidates:`没有可选的其他任务`,removeDependency:`移除前置任务:{{task}}`,dependencyUpdateFailed:`前置任务更新失败,请刷新后重试。`,expectedOutputs:`预期输出`,constraints:`约束与边界`,approvalRequired:`需要你批准`,latestResult:`最新结果`,remainingWork:`还差什么`,nextAction:`下一步`,yourDecision:`只需你决定`,noRemainingWork:`已覆盖全部完成标准。`,noDecisionNeeded:`暂时不需要你做任何事,xopc 会继续推进。`,contextUsed:`本次使用的上下文`,contextSources:`信息来源`,contextAssumptions:`当前假设`,contextRisks:`风险`,contextRoleLabels:{input:`输入`,reference:`参考`,constraint:`约束`,deliverable:`交付物`,evidence:`证据`},contextKindLabels:{document:`文档`,file:`文件`,url:`链接`,session:`对话`,memory:`记忆`,task:`任务`,artifact:`产物`,source:`来源`},currentTask:`当前任务`,executionHistory:`历史执行记录({{count}})`,receiptStatuses:{succeeded:`执行成功`,failed:`执行失败`,cancelled:`已取消`},unresolvedCriteria:`待验证标准`,resultFeedback:`这件事做好了吗?`,doneWell:`结果有帮助`,needsFix:`结果没帮助`,correctionPlaceholder:`告诉 xopc 哪里不对、你真正想要的结果是什么`,submitCorrection:`修正并继续`,feedbackThanks:`收到,我会据此继续改进。`,correctionStarted:`收到,已重新打开并开始修正。`,noDefinition:`系统正在进一步明确完成标准。未明确前不会把事情误判为已完成。`,backToWork:`返回任务列表`,openTaskConversation:`进入对话`,taskNotFound:`没有找到这个任务`,runTask:`开始推进`,scheduleTask:`安排执行`,scheduleRecurringTask:`定时执行`,approveTask:`确认完成`,reopenTask:`重新打开`,moreActions:`更多操作`,pauseTask:`暂停推进`,resumeTask:`继续推进`,cancelTask:`结束事项`,cancelActiveRun:`取消当前执行`,deleteTask:`永久删除任务`,deleteTaskTitle:`永久删除这个任务?`,deleteTaskDescription:`将永久删除“{{title}}”及其执行记录、上下文和回执。关联对话、工作区文件和外部产物不会被删除。`,confirmDeleteTask:`永久删除`,keepTask:`保留任务`,deleteActiveTaskBlocked:`请先结束当前执行,再永久删除任务。`,actionFailed:`操作失败,请重试。`,verificationStatuses:{passed:`已验证`,failed:`验证未通过`,unverified:`待验证`}}:{newWork:`Ask xopc`,dialogTitle:`What do you want to get done?`,dialogDescription:`This opens a new conversation. xopc will answer or start working, and create a task only when the work needs ongoing progress.`,intentLabel:`Tell xopc what you need`,intentPlaceholder:`For example: summarize this week’s meeting notes and suggest next week’s priorities`,intentSuggestion:`Summarize this week’s meeting notes and suggest next week’s priorities`,submit:`Open conversation and start`,projectLabel:`Project`,monitoringLabel:`Follow-up policy`,monitoringModes:{observe:`Observe only`,ask_before_action:`Ask before acting`,auto_low_risk:`Auto-run low-risk actions`},existingProject:`Existing project`,newProject:`New project`,needsAttention:`Needs your attention`,waitingStatus:`Current status`,runAttention:`Run issues`,running:`xopc is working`,continue:`Continue`,recent:`Recent conversations`,evidenceCount:`evidence items`,remainingCount:`remaining`,projects:`Long-term projects`,emptyRunning:`No conversations are running`,emptyContinue:`No ongoing items yet`,openChat:`Open conversation`,whyNow:`Why now`,impact:`Impact`,workDone:`AI checked`,recommendation:`Recommendation`,policyReason:`Policy decision`,proposedAction:`Proposed action`,actionStates:{not_authorized:`Suggested only; not authorized for auto-run`,approval_required:`Waiting for your approval`,pending:`Queued to run`,executing:`Running`,completed:`Auto-run completed`,rejected:`Rejected`,failed:`Execution failed`},judgmentReasons:`Why this is recommended`,rejectedAlternatives:`Alternatives not chosen`,uncertainty:`Uncertainty`,snooze:`Tomorrow`,dismiss:`Dismiss`,feedbackPlaceholder:`Tell AI how to judge this kind of event next time…`,applyFeedback:`Update future judgments`,evidence:`Evidence references`,useful:`Useful`,notUseful:`Not useful`,taskStatuses:{pending:`Pending`,planning:`Defining done`,waiting_dependency:`Waiting on dependencies`,running:`In progress`,verifying:`Verifying`,needs_user:`Needs you`,blocked:`Blocked`,paused:`Paused`,completed:`Completed`,cancelled:`Ended`},taskProgress:{title:`xopc owns this task`,open:`View task`,decide:`Review and decide`,evidence:`verified evidence`,statuses:{pending:`Pending`,planning:`Defining done`,waiting_dependency:`Waiting on dependencies`,running:`In progress`,verifying:`Verifying`,needs_user:`Needs you`,blocked:`Needs you`,paused:`Paused`,completed:`Completed`,cancelled:`Ended`}},detailStatuses:{allocating:`Assigning an executor`,captured:`Not scheduled`,ready:`Ready to start`,queued:`Queued`,running:`In progress`,verifying:`Verifying`,waiting:`Waiting`,blocked:`Blocked`,failed:`Execution failed`,cancelled:`Execution cancelled`,needsUser:`Needs your attention`,review:`Ready for review`,completed:`Completed`,ended:`Ended`,paused:`Paused`},detailStatusDescriptions:{allocating:`The task is submitted and a suitable executor is being selected in the background.`,captured:`This task is captured but has not entered the work queue. Schedule it when you are ready.`,ready:`This task is ready for xopc to start.`,queued:`This task is queued and will start when resources are available.`,running:`xopc is currently working on this task.`,verifying:`xopc is checking the result against the completion criteria.`,waiting:`This task is waiting for an external condition.`,blocked:`A blocking condition must be resolved before work can continue.`,failed:`The latest run failed. Review its result before retrying.`,cancelled:`The latest run was cancelled. This task can be started again.`,needsUser:`xopc needs your input or approval before continuing.`,review:`The result is ready for your review.`,completed:`This task is complete and closed.`,ended:`This task has ended and will not continue.`,paused:`Automatic progress and reminders are paused. Other waiting conditions still apply after resuming.`},statusSummary:`Current status`,taskLabel:`Task`,taskDescription:`Description and objective`,editTaskField:`Edit`,saveTaskField:`Save`,cancelTaskField:`Cancel`,noTaskDescription:`Add background, scope, and delivery requirements.`,taskProperties:`Task properties`,taskPhase:`Phase`,priority:`Priority`,dueDate:`Due date`,executorLabel:`Agent`,priorityLabels:{low:`Low priority`,normal:`Normal priority`,high:`High priority`,critical:`Critical`},unassigned:`No assignee`,noDueDate:`No due date`,updatedAt:`Updated {{date}}`,successDefinition:`Definition of done`,taskDefinition:`Task definition`,criteriaProgress:`{{verified}}/{{total}} verified`,taskRelations:`Task relationships`,dependencies:`Dependencies`,dependents:`Dependent tasks`,noDependencies:`No dependencies`,noDependents:`No dependent tasks`,editDependencies:`Edit dependencies`,saveDependencies:`Save relationships`,cancelDependencyEdit:`Cancel`,dependenciesDescription:`xopc starts this task after every selected task is complete.`,linkDependencies:`Link dependencies`,linkedDependencies:`Linked dependencies: {{count}}`,dependencySearchPlaceholder:`Search tasks`,noDependencyMatches:`No matching tasks`,noDependencyCandidates:`There are no other tasks to select`,removeDependency:`Remove dependency: {{task}}`,dependencyUpdateFailed:`Dependencies could not be updated. Refresh and try again.`,expectedOutputs:`Expected outputs`,constraints:`Constraints and boundaries`,approvalRequired:`Your approval is required`,latestResult:`Latest result`,remainingWork:`What remains`,nextAction:`Next action`,yourDecision:`Your one decision`,noRemainingWork:`All completion criteria are covered.`,noDecisionNeeded:`Nothing is needed from you. xopc will keep moving this forward.`,contextUsed:`Context used for this task`,contextSources:`Sources`,contextAssumptions:`Current assumptions`,contextRisks:`Risks`,contextRoleLabels:{input:`Input`,reference:`Reference`,constraint:`Constraint`,deliverable:`Deliverable`,evidence:`Evidence`},contextKindLabels:{document:`Document`,file:`File`,url:`Link`,session:`Conversation`,memory:`Memory`,task:`Task`,artifact:`Artifact`,source:`Source`},currentTask:`Current task`,executionHistory:`Execution history ({{count}})`,receiptStatuses:{succeeded:`Succeeded`,failed:`Failed`,cancelled:`Cancelled`},unresolvedCriteria:`Criteria still to verify`,resultFeedback:`Was this done well?`,doneWell:`Helpful result`,needsFix:`Unhelpful result`,correctionPlaceholder:`Tell xopc what is wrong and what the right task should be`,submitCorrection:`Fix and continue`,feedbackThanks:`Got it. I will use this to improve future work.`,correctionStarted:`Got it. This was reopened and correction has started.`,noDefinition:`xopc is still clarifying the completion criteria. It will not mark this done before they are explicit.`,backToWork:`Back to tasks`,openTaskConversation:`Open conversation`,taskNotFound:`This task was not found`,runTask:`Start working`,scheduleTask:`Schedule work`,scheduleRecurringTask:`Schedule`,approveTask:`Mark complete`,reopenTask:`Reopen`,moreActions:`More actions`,pauseTask:`Pause`,resumeTask:`Continue`,cancelTask:`End task`,cancelActiveRun:`Cancel active run`,deleteTask:`Delete task permanently`,deleteTaskTitle:`Delete this task permanently?`,deleteTaskDescription:`This permanently deletes “{{title}}” and its execution records, context, and receipts. Linked conversations, workspace files, and external artifacts are kept.`,confirmDeleteTask:`Delete permanently`,keepTask:`Keep task`,deleteActiveTaskBlocked:`End the active run before deleting this task permanently.`,actionFailed:`The action failed. Please try again.`,verificationStatuses:{passed:`Verified`,failed:`Verification failed`,unverified:`Not verified`}}}function A(e,t,n,r){return new Promise((i,a)=>{let o=!1,s=(e,n)=>{o||(o=!0,clearTimeout(l),t.removeEventListener(`abort`,c),e===void 0?i(n):a(e))},c=()=>s(t.reason??new DOMException(`Cancelled`,`AbortError`)),l=setTimeout(()=>s(new DOMException(`Voice startup timed out`,`TimeoutError`)),n);e.then(e=>{o?r?.(e):s(void 0,e)},e=>s(e)),t.addEventListener(`abort`,c,{once:!0}),t.aborted&&c()})}function j(e,t,n,r){let i=e.get(t);if(i&&(n<i.revision||i.final&&!r||n===i.revision&&(i.final||!r)))return!1;if(!e.has(t)&&e.size>=256){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return e.set(t,{revision:n,final:r}),!0}var M=e(t(),1),N=null;function ce(e){return N&&N!==e?!1:(N=e,!0)}function le(e){N===e&&(N=null)}function ue(e){if(!(e instanceof Error))return!1;let t=e.body,n=typeof t?.error==`object`?t.error.code:void 0;return n===`VOICE_DISABLED`||n===`PROVIDER_UNAVAILABLE`}function de(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function fe(e){return e===`requesting`||e===`connecting`||e===`starting`}async function pe(){if(!navigator.permissions?.query)return null;try{return(await navigator.permissions.query({name:`microphone`})).state}catch{return null}}function me(e){return e instanceof DOMException||e instanceof Error?e.name:``}function he(e,t){if(e===`permission`)return`permission`;if(e===`recorder`)return`recorder`;if(e===`session`)return`session`;let n=me(t);return n===`NotAllowedError`||n===`SecurityError`?`permission`:`device`}function ge(e){let{disabled:t,chat:n,onTranscript:r}=e,[o,c]=(0,M.useState)(`idle`),[l,ee]=(0,M.useState)(!1),d=(0,M.useRef)(null),f=(0,M.useRef)(null),te=(0,M.useRef)(void 0),[p,ne]=(0,M.useState)(0),[_,v]=(0,M.useState)(0),[y,b]=(0,M.useState)(``),[x,S]=(0,M.useState)(``),[C,w]=(0,M.useState)(``),[T,E]=(0,M.useState)([]),[D,O]=(0,M.useState)(null),[k,N]=(0,M.useState)(`idle`),[ge,_e]=(0,M.useState)(null),[ve,ye]=(0,M.useState)(!1),P=(0,M.useRef)(!1),[F,I]=(0,M.useState)(null),[be,xe]=(0,M.useState)(null),[Se,Ce]=(0,M.useState)(!1),[we,Te]=(0,M.useState)(null),L=(0,M.useRef)(void 0),R=(0,M.useRef)(null),[Ee,De]=(0,M.useState)(`dictation`),Oe=(0,M.useRef)(Symbol(`voice-capture`)),z=(0,M.useRef)(`idle`),B=(0,M.useRef)(0),V=(0,M.useRef)(null),ke=(0,M.useRef)(null),H=(0,M.useRef)(null),Ae=(0,M.useRef)(void 0),je=(0,M.useRef)(void 0),U=(0,M.useRef)(null),Me=(0,M.useRef)(null),Ne=(0,M.useRef)(null),W=(0,M.useRef)(new Map),G=(0,M.useRef)(!1),Pe=(0,M.useRef)(()=>{}),Fe=(0,M.useRef)(new Map),K=(0,M.useRef)(null),Ie=(0,M.useRef)(null),Le=(0,M.useRef)(!1),Re=(0,M.useRef)(null),ze=(0,M.useRef)(!1),Be=(0,M.useRef)(0),Ve=(0,M.useRef)(6e5),He=(0,M.useRef)(null),q=(0,M.useRef)(null),Ue=(0,M.useRef)(r);Ue.current=r;let J=(0,M.useCallback)(e=>{z.current=e,c(e)},[]),Y=(0,M.useCallback)(()=>{He.current!=null&&(clearInterval(He.current),He.current=null)},[]),X=(0,M.useCallback)(()=>{Me.current?.getTracks().forEach(e=>e.stop()),Me.current=null},[]),Z=(0,M.useCallback)(()=>{le(Oe.current),B.current+=1,R.current?.abort(),R.current=null,Y(),q.current!==null&&clearTimeout(q.current),q.current=null,U.current?.stopRingback(),X(),d.current?.cancel(),d.current=null,f.current=null,te.current=void 0,ee(!1),V.current?.cancel(),V.current=null,ke.current=null,H.current=null;let e=U.current;U.current=null,e?.close(),Ne.current=null,ne(0),v(0),b(``),S(``),w(``),N(`idle`),_e(null),E([]),O(null),Re.current=null,P.current=!1,ye(!1),Ce(!1),Fe.current.clear(),W.current.clear(),G.current=!1,K.current=null,Ie.current=null},[X,Y]),Q=(0,M.useCallback)(()=>{Z(),J(`idle`)},[Z,J]),We=(0,M.useCallback)(()=>{H.current?.stop(`user_finished`),Q(),I(null),xe(null),Te(null)},[Q]),$=(0,M.useCallback)(async e=>{if(G.current)return;G.current=!0;let t=B.current,r=e??[...W.current.values()].join(` `).trim();if(X(),Y(),V.current?.cancel(),V.current=null,J(`transcribing`),!r){u(`warning`,n.voiceTranscribeEmpty),Q();return}let o=r;try{let e=await a(i(`/api/voice/transcriptions/refine`),{method:`POST`,body:JSON.stringify({text:r}),signal:AbortSignal.any([R.current.signal,AbortSignal.timeout(15e3)])});e.payload.text.trim()&&(o=e.payload.text)}catch{if(t!==B.current)return;u(`warning`,n.voiceRefinementFailed)}t===B.current&&(Ue.current(o),Q())},[Q,n.voiceRefinementFailed,n.voiceTranscribeEmpty,X,Y,J]),Ge=(0,M.useCallback)(async()=>{if(G.current)return;G.current=!0;let e=B.current;Y(),J(`transcribing`);try{let t=d.current;if(!f.current&&t){let n=await t.stop();if(e!==B.current)return;f.current=n}if(d.current=null,X(),e!==B.current)return;let r=f.current;if(!r)throw Error(n.voiceTranscribeEmpty);let i=await g(r,r.type,AbortSignal.any([R.current.signal,AbortSignal.timeout(9e4)]),te.current);if(e!==B.current)return;G.current=!1,await $(i.text.trim())}catch(t){if(e!==B.current)return;X(),G.current=!1,I(t instanceof Error?t.message:n.voiceTranscribeFailed),xe(`session`),J(`error`)}},[$,n.voiceTranscribeEmpty,n.voiceTranscribeFailed,X,Y,J]),Ke=(0,M.useCallback)(e=>{Te(e);let t=z.current;if(!(t===`idle`||t===`error`||G.current)){if(!L.current){if(t===`transcribing`&&e===`input_committed`){$();return}Y(),X(),V.current?.cancel(),V.current=null,H.current=null,I(n.voiceTranscribeFailed),J(`error`);return}Q()}},[$,Q,n.voiceTranscribeFailed,X,Y,J]),qe=(0,M.useCallback)(()=>{Y(),He.current=setInterval(()=>{let e=Ne.current;if(e===null)return;let t=performance.now()-e;if(ne(Math.max(0,t/1e3)),t>=Ve.current&&z.current===`recording`){if(!L.current){Pe.current();return}Te(`session_limit`),H.current?.stop(`user_finished`),Q()}},200)},[Q,Y]),Je=(0,M.useCallback)(async(e,r,i,a=!1)=>{if(t||z.current!==`idle`||e===`conversation`&&!i)return;if(!ce(Oe.current)){I(n.callCaptureBusy),e===`dictation`&&u(`error`,n.callCaptureBusy);return}L.current=i;let o=new AbortController;R.current=o,I(null),xe(null),Te(null);let c=++B.current,l=()=>c===B.current;De(e),_e(e===`conversation`?`preparing`:null),(!a||!Ae.current)&&(Ae.current=crypto.randomUUID()),je.current=r,w(``),J(`connecting`);let f=performance.now(),p=(e,t,n)=>A(e,o.signal,t,n),g=`permission`;try{if(e===`conversation`){g=`recorder`;let e=new ie;if(U.current=e,await p(e.start(),1e4),!l()){e.close();return}}g=`session`;let t=e===`dictation`?await p(oe(o.signal),2e4):null;if(!l())return;if(t?.mode===`unavailable`){let e=Error(n.voiceSttNotConfigured);throw Object.assign(e,{body:{error:{code:`PROVIDER_UNAVAILABLE`}}}),e}let c=t?.mode===`recorded`,f=c?[]:await p(se.preflight({purpose:e,...e===`conversation`?{mode:r,conversationId:i}:{},signal:o.signal}),2e4);if(!l())return;g=`permission`;let _=window.electronAPI?.system,y=await p(pe(),5e3);if(!l()||!fe(z.current))return;if(_&&y!==`granted`){J(`requesting`);let e=await p(_.requestMicrophone(),6e4);if(!l())return;let t=window.electronAPI?.platform===`darwin`&&e.status!==`granted`;if(e.status===`denied`||t)throw Error(`Microphone permission denied`)}else!_&&y!==`granted`&&J(`requesting`);if(!l()||!fe(z.current))return;J(`starting`),window.dispatchEvent(new Event(`xopc-voice-recording-start`)),g=`media`;let x=await p(navigator.mediaDevices.getUserMedia({audio:h()}),15e3,e=>e.getTracks().forEach(e=>e.stop()));if(!l()||!fe(z.current)){x.getTracks().forEach(e=>e.stop());return}if(Me.current=x,c){g=`recorder`;let e=await p(m.start(x,{onAudioLevel:({level:e})=>{l()&&v(Math.min(1,e*8))}}),15e3,e=>e.cancel());if(!l()){e.cancel();return}d.current=e,te.current=t.provider,ee(!0),Ve.current=6e5,Ne.current=performance.now(),ne(0),J(`recording`),qe();return}e===`conversation`&&(_e(`dialing`),U.current?.startRingback(),q.current=setTimeout(()=>{l()&&(U.current?.stopRingback(),_e(`slow`),q.current=null)},12e3)),g=`session`,J(`connecting`),W.current.clear();let C=await p(se.connect({timingMetrics:f,logicalCallId:Ae.current,recovery:a,language:s(),purpose:e,signal:o.signal,...e===`conversation`?{mode:r,conversationId:i}:{},onEvent:t=>{if(l()&&!((t.type===`input.transcript.delta`||t.type===`input.transcript.final`)&&!j(Fe.current,t.payload.utteranceId,t.payload.revision,t.type===`input.transcript.final`))){if(t.type===`input.transcript.delta`&&b(t.payload.text),t.type===`input.transcript.final`){let n=t.payload.text.trim();b(``),S(n),n&&e===`dictation`&&(W.current.set(t.payload.utteranceId,n),[...W.current.values()].join(` `).length>=2e4&&z.current===`recording`&&Pe.current(),S([...W.current.values()].join(` `)))}if(t.type===`input.speech_stopped`&&(Re.current=performance.now()),t.type===`response.created`){if(K.current){K.current!==t.payload.responseId&&H.current?.cancelResponse(t.payload.responseId);return}K.current=t.payload.responseId,Le.current=!1,ze.current=!1,Be.current=0,w(``),E([]),O(null),N(`thinking`)}if(t.type===`task.created`&&K.current===t.payload.responseId&&(Ie.current=t.payload.taskId),t.type===`task.activity`&&Ie.current===t.payload.taskId){let e={toolCallId:t.payload.toolCallId,toolName:t.payload.toolName,status:t.payload.status};E(t=>[...t.filter(t=>t.toolCallId!==e.toolCallId),e].slice(-8))}if(t.type===`task.done`&&Ie.current===t.payload.taskId&&(Ie.current=null,E([])),t.type===`response.clarification`&&K.current===t.payload.responseId&&O(t.payload),t.type===`response.text.delta`&&K.current===t.payload.responseId&&(N(`speaking`),w(e=>e+t.payload.delta)),t.type===`response.audio.started`&&K.current===t.payload.responseId&&N(`speaking`),t.type===`response.done`&&K.current===t.payload.responseId&&(Le.current=!0,U.current?.hasPendingAudio||(K.current=null,N(`idle`))),t.type===`response.cancelled`&&K.current===t.payload.responseId&&(K.current=null,N(`idle`),U.current?.clear()),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`RESPONSE_FAILED`&&u(`warning`,n.voiceResponseFailed),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`INPUT_DROPPED`&&u(`warning`,n.voiceInputDropped),t.type===`session.error`&&!t.payload.recoverable){let r=t.payload.code===`PROVIDER_UNAVAILABLE`,i=t.payload.code===`CONTEXT_CHANGED`?n.voiceContextChanged:r?n.voiceSttNotConfigured:t.payload.message;I(i),xe(`session`),Ce(r),e===`dictation`&&u(`error`,i,void 0,r?{href:`/settings/capabilities/models?configure=transcription`}:void 0),H.current?.stop(`surface_closed`),e===`conversation`?Z():(Y(),X(),V.current?.cancel(),V.current=null,H.current=null),J(`error`)}}},onAudio:(e,t)=>{if(!l())return;let n=K.current;if(!n||t!==n)return;let r=!ze.current,i=Re.current;r&&(ze.current=!0,Re.current!==null&&H.current?.reportMetric(n,`speech_end_to_audio_received`,performance.now()-Re.current),Re.current=null);let a=U.current?.enqueue(e,()=>{K.current===n&&(Be.current+=e.byteLength,H.current?.acknowledgeAudio(n,Be.current),Le.current&&!U.current?.hasPendingAudio&&(K.current=null,N(`idle`)))});r&&i!==null&&a!==void 0&&H.current?.reportMetric(n,`speech_end_to_audio_scheduled`,performance.now()-i+a)},onClose:e=>{l()&&Ke(e)}}),2e4,e=>e.stop(`surface_closed`));if(!l()){C.stop(`surface_closed`);return}U.current?.stopRingback(),q.current!==null&&clearTimeout(q.current),q.current=null,H.current=C,Ve.current=C.session.limits.maxSessionMs,g=`recorder`,J(`starting`);let T,D=[],k=await p(ae.start(x,{onSamples:e=>{if(!l()||P.current)return;if(!T){D.push(e);return}let t=(ke.current??T).push(e);t&&C.sendAudio(t)},onAudioLevel:({level:e})=>{l()&&(P.current||v(Math.min(1,e*8)))}}),15e3,e=>e.cancel());if(!l()||!fe(z.current)){k.cancel(),C.stop(`surface_closed`),x.getTracks().forEach(e=>e.stop());return}if(V.current=k,e===`conversation`&&(await p(U.current.start(),1e4),!l()))return;C.outputReady(),T=new re(k.sampleRate,C.session.inputFormat.sampleRate),ke.current=T;for(let e of D)C.sendAudio(T.push(e));Ne.current=performance.now(),ne(0),J(`recording`),_e(null),qe()}catch(t){if(!l())return;let r=he(g,t);console.error(`[chat:voice] realtime capture start failed`,{stage:g,durationMs:Math.round(performance.now()-f),kind:r,errorName:me(t),errorMessage:t instanceof Error?t.message:String(t)}),H.current?.stop(`surface_closed`),Z(),J(r===`session`?`error`:`idle`);let i=r===`session`&&ue(t),a=me(t)===`TimeoutError`?g===`session`?n.voiceConnectionTimeout:n.voiceMicrophoneTimeout:r===`permission`?n.voiceMicDenied:r===`device`?n.voiceMicUnavailable:r===`recorder`?n.voiceRecorderFailed:i?n.voiceSttNotConfigured:t instanceof Error?t.message:n.voiceSttNotConfigured;I(a),xe(r),Ce(i),e===`dictation`&&u(`error`,a,void 0,i?{href:`/settings/capabilities/models?configure=transcription`}:void 0)}},[t,Ke,n,Z,qe,X,Y,J]),Ye=(0,M.useCallback)(()=>{if(L.current)return;if(d.current||f.current){Ge();return}if(z.current===`error`&&W.current.size){$();return}if(z.current!==`recording`)return;J(`transcribing`),Y(),X();let e=V.current,t=B.current;V.current=null,e?.stop().then(()=>{if(t!==B.current)return;let e=ke.current?.flush();e&&H.current?.sendAudio(e),H.current?.commit()}).catch(()=>{t===B.current&&(u(`error`,n.voiceTranscribeFailed),H.current?.stop(`surface_closed`),Z(),J(`error`))})},[$,Ge,n.voiceTranscribeFailed,Z,X,Y,J]);Pe.current=Ye,(0,M.useEffect)(()=>()=>{le(Oe.current),B.current+=1,R.current?.abort(),d.current?.cancel(),f.current=null,V.current?.cancel(),H.current?.stop(`surface_closed`),U.current?.close(),q.current!==null&&clearTimeout(q.current),X(),Y()},[X,Y]);let Xe=(0,M.useCallback)(()=>{if(z.current===`error`){if(f.current){Ge();return}Z(),J(`idle`),Je(Ee,je.current,L.current,!0)}},[Je,Ge,Ee,Z,J]),Ze=(0,M.useCallback)(()=>Je(`dictation`),[Je]),Qe=(0,M.useCallback)((e,t)=>Je(`conversation`,t,e),[Je]),$e=(0,M.useCallback)(()=>{let e=performance.now(),t=K.current;U.current?.clear(),K.current=null,N(`idle`),t&&(H.current?.reportMetric(t,`local_stop`,performance.now()-e),H.current?.cancelResponse(t))},[]),et=(0,M.useCallback)(()=>{let e=!P.current;P.current=e,Me.current?.getAudioTracks().forEach(t=>{t.enabled=!e});let t=V.current,n=H.current;t&&n&&(ke.current=new re(t.sampleRate,n.session.inputFormat.sampleRate)),n?.setInputMuted(e),b(``),v(0),U.current?.duck(!1),ye(e)},[]);return{phase:o,voiceActive:o!==`idle`,recordedDictation:l,elapsedLabel:de(p),audioLevel:_,partialTranscript:y,finalTranscript:x,responseText:C,activities:T,clarification:D,dismissClarification:e=>O(t=>t?.requestId===e?null:t),responsePhase:k,callConnectionStage:ge,muted:ve,error:F,failureKind:be,settingsRequired:Se,endedReason:we,mode:Ee,startVoiceInput:Ze,startVoiceConversation:Qe,interruptResponse:$e,toggleMute:et,cancelVoiceInput:We,confirmVoiceInput:Ye,retryVoiceInput:Xe}}var _e=o(e=>({path:null,line:null,projectId:null,conversationId:null,setPath:(t,n,r,i,a)=>{if(t){let e=v.getState().scope;v.getState().openFile({path:t,line:n,projectId:r||void 0,conversationId:i||(e===`new`?void 0:e),agentId:x.getState().agentId||void 0,resultRevision:a})}e({path:t,resultRevision:t?a:void 0,line:t&&typeof n==`number`&&Number.isFinite(n)&&n>0?Math.floor(n):null,projectId:t&&r?.trim()||null,conversationId:t&&i?.trim()||null})}}));function ve(e){return`${e.name}\0${e.size}`}function ye(e){if(!e)return[];let t=new Set,n=[],r=e=>{if(!e||e.size===0)return;let r=ve(e);t.has(r)||(t.add(r),n.push(e))},{files:i}=e;if(i?.length)for(let e=0;e<i.length;e++)r(i.item(e));for(let t of Array.from(e.items??[]))t.kind===`file`&&r(t.getAsFile());return n}var P=n(),F=r();function I(e){let t=(0,P.c)(10),{disabled:n,chat:r,onStart:i}=e,a=S(be),o=r.voiceInput,s;t[0]===a?s=t[1]:(s=C(a).join(`+`),t[0]=a,t[1]=s);let c=`${o} (${s})`,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=p(`relative inline-flex size-11 sm:size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-fg-subtle hover:bg-surface-hover hover:text-fg`,b.transition,b.press,b.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),t[2]=l):l=t[2];let u;t[3]===i?u=t[4]:(u=()=>void i(),t[3]=i,t[4]=u);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,F.jsx)(ee,{className:`size-4 stroke-[1.75]`}),t[5]=d):d=t[5];let f;return t[6]!==n||t[7]!==u||t[8]!==c?(f=(0,F.jsx)(`button`,{type:`button`,className:l,disabled:n,title:c,"aria-label":c,onClick:u,children:d}),t[6]=n,t[7]=u,t[8]=c,t[9]=f):f=t[9],f}function be(e){return e.shortcut}function xe(e,t){let n=t.trim();if(!n)return e;let r=e.trim();return r?`${r} ${n}`:n}var Se=p(`inline-flex min-h-11 min-w-11 shrink-0 gap-2 px-3 items-center justify-center rounded-lg text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,b.transition,b.press,b.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),Ce=(0,M.memo)(function(e){let t=(0,P.c)(47),{phase:n,elapsedLabel:r,recordedDictation:i,audioLevel:a,partialTranscript:o,finalTranscript:s,error:u,settingsRequired:ee,disabled:m,chat:h,onCancel:re,onConfirm:ie,onRetry:g}=e,ae=n===`transcribing`,oe=n===`requesting`,se=n===`connecting`,_=n===`starting`,v=n===`error`,y=v?u||h.voiceTranscribeFailed:oe?h.voiceRequestingMicrophone:se?h.voiceConnectingService:_?h.voiceStartingMicrophone:ae?h.voiceTranscribing:i?h.voiceRecordedDictationStatus:h.voiceRecordingStatus,b;t[0]!==s||t[1]!==o?(b=[s,o].filter(Boolean),t[0]=s,t[1]=o,t[2]=b):b=t[2];let x=b.join(` `),S=oe||se||_||ae,C;t[3]!==a||t[4]!==v||t[5]!==n?(C=n===`recording`?(0,F.jsx)(`div`,{className:`flex h-5 shrink-0 items-center gap-0.5`,"aria-hidden":!0,children:Array.from({length:9},(e,t)=>{let n=.35+(t%4+1)*.16;return(0,F.jsx)(`span`,{className:`w-0.5 rounded-full bg-fg-muted motion-safe:transition-[height] motion-safe:duration-75`,style:{height:Math.max(3,Math.round(18*Math.min(1,a*n+.08)))}},t)})}):v?(0,F.jsx)(l,{className:`size-4 shrink-0 text-danger`,"aria-hidden":!0}):(0,F.jsx)(ne,{className:`h-4 w-8`}),t[3]=a,t[4]=v,t[5]=n,t[6]=C):C=t[6];let w=v?`alert`:`status`,T;t[7]!==y||t[8]!==w?(T=(0,F.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-sm text-fg-muted`,role:w,children:y}),t[7]=y,t[8]=w,t[9]=T):T=t[9];let E;t[10]!==r||t[11]!==n?(E=n===`recording`?(0,F.jsx)(`span`,{className:`shrink-0 text-sm tabular-nums text-fg-muted`,children:r}):null,t[10]=r,t[11]=n,t[12]=E):E=t[12];let D;t[13]!==C||t[14]!==T||t[15]!==E?(D=(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-1`,children:[C,T,E]}),t[13]=C,t[14]=T,t[15]=E,t[16]=D):D=t[16];let O;t[17]===x?O=t[18]:(O=x?(0,F.jsx)(`p`,{className:`max-h-28 overflow-y-auto overscroll-contain whitespace-pre-wrap break-words px-1 text-base text-fg`,children:x}):null,t[17]=x,t[18]=O);let k;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,F.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[19]=k):k=t[19];let A;t[20]!==h.voiceInputCancel||t[21]!==re?(A=(0,F.jsxs)(`button`,{type:`button`,className:Se,title:h.voiceInputCancel,"aria-label":h.voiceInputCancel,onClick:re,children:[k,h.voiceInputCancel]}),t[20]=h.voiceInputCancel,t[21]=re,t[22]=A):A=t[22];let j;t[23]!==m||t[24]!==v||t[25]!==h.voiceOpenSettings||t[26]!==h.voiceRetry||t[27]!==g||t[28]!==ee?(j=v&&ee?(0,F.jsxs)(`a`,{onClick:we,href:`#/settings/capabilities/models?configure=transcription`,className:p(Se,`text-accent-fg`),children:[(0,F.jsx)(f,{className:`size-4`,"aria-hidden":!0}),h.voiceOpenSettings]}):v?(0,F.jsxs)(`button`,{type:`button`,className:Se,disabled:m,"aria-label":h.voiceRetry,onClick:g,children:[(0,F.jsx)(d,{className:`size-4`,"aria-hidden":!0}),h.voiceRetry]}):null,t[23]=m,t[24]=v,t[25]=h.voiceOpenSettings,t[26]=h.voiceRetry,t[27]=g,t[28]=ee,t[29]=j):j=t[29];let M;t[30]!==m||t[31]!==v||t[32]!==s||t[33]!==h.voiceInputConfirm||t[34]!==ie||t[35]!==n?(M=n===`recording`||v&&s?(0,F.jsxs)(`button`,{type:`button`,className:p(Se,`rounded-full bg-accent text-on-accent hover:bg-accent-hover hover:text-on-accent`),disabled:m,"aria-label":h.voiceInputConfirm,onClick:ie,children:[(0,F.jsx)(c,{className:`size-4`,"aria-hidden":!0}),h.voiceInputConfirm]}):null,t[30]=m,t[31]=v,t[32]=s,t[33]=h.voiceInputConfirm,t[34]=ie,t[35]=n,t[36]=M):M=t[36];let N;t[37]!==A||t[38]!==j||t[39]!==M?(N=(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[A,j,M]}),t[37]=A,t[38]=j,t[39]=M,t[40]=N):N=t[40];let ce;return t[41]!==h.voiceInput||t[42]!==N||t[43]!==S||t[44]!==D||t[45]!==O?(ce=(0,F.jsxs)(`section`,{className:`w-full space-y-3 py-3`,"aria-label":h.voiceInput,"aria-busy":S,children:[D,O,N]}),t[41]=h.voiceInput,t[42]=N,t[43]=S,t[44]=D,t[45]=O,t[46]=ce):ce=t[46],ce});function we(e){!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&e.button===0&&(e.preventDefault(),y(`transcription`))}var Te=120*1e3,L=new Map;function R(){return typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Ee(e){for(let[t,n]of L)n.expiresAt<=e&&L.delete(t)}function De(e,t=Date.now()){Ee(t);let n=R();return L.set(n,{attachments:e.map(e=>({...e})),expiresAt:t+Te}),n}function Oe(e,t=Date.now()){let n=L.get(e);if(!n)return null;if(n.expiresAt<=t)return L.delete(e),null;if(!n.attachments)return null;let r=n.attachments;return n.attachments=null,r}export{I as a,ge as c,k as d,T as f,E as g,w as h,xe as i,ce as l,O as m,Oe as n,ye as o,D as p,Ce as r,_e as s,De as t,le as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as o,l as s,n as c,o as l}from"./locale-store-Br7IfbXK.js";import{t as u}from"./messages-ByFlEbsu.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-BGTk37IG.js";import{i as v,n as y,r as b,t as x}from"./service-recommendation-list-CNghOavt.js";import{t as S}from"./chevron-down-ccbiQQz_.js";import{t as C}from"./chevron-right-BweFrslA.js";import{n as w,r as T,t as E}from"./popover-select-CEMWIrtY.js";import{t as D}from"./circle-alert-BEjgurr2.js";import{t as O}from"./circle-check-C23XjkUj.js";import{t as k}from"./circle-pause-CN9jYH2s.js";import{a as A,i as j,n as M,r as N,t as P}from"./connector-filters-Cfcx9EA2.js";import{t as F}from"./clock-3-DnrAnuyZ.js";import{t as I}from"./database-CjjeZfRG.js";import{t as L}from"./ellipsis-0k4rZLoy.js";import{t as R}from"./external-link-DjqjBmc3.js";import{n as z}from"./secret-input-Dryrns2s.js";import{t as B}from"./eye-CABVeTq0.js";import{t as V}from"./key-round-DWbpyU2U.js";import{t as H}from"./loader-circle-CifKLtgG.js";import{a as U,c as ee,i as W,n as te,o as G,r as ne,s as re,t as ie}from"./install-connector-dialog-DWVl9ekV.js";import{t as K}from"./plug-DKYPEgkR.js";import{t as ae}from"./plus-Q2yW6OE7.js";import{t as oe}from"./refresh-cw-BRlGaq2w.js";import{t as q}from"./save-DRDABU--.js";import{t as J}from"./server-BlHCBjiE.js";import{t as se}from"./settings-uiTATseT.js";import{t as ce}from"./store-SzD1Jvgm.js";import{t as le}from"./terminal-oKqqZdiG.js";import{t as ue}from"./trash-2-DusmjVPV.js";import{t as Y}from"./wrench-DFb4r8bH.js";import{t as de}from"./x-B_N4OPjy.js";import{t as X}from"./cn-0WouolD0.js";import{t as fe}from"./skeleton-BI5TyibZ.js";import{r as pe}from"./extension-provider-fOi6V6Cr.js";import{i as me}from"./vendor-swr-CdRzEUwF.js";import{n as he,r as ge}from"./gateway-config-swr-BOCt_zOo.js";import{t as Z}from"./button-Cc4hUNTt.js";import{n as _e}from"./copy-to-clipboard-HOJ79TWv.js";import{n as ve}from"./interaction-BdhHBbYa.js";import{A as ye,E as be,F as xe,I as Se,L as Ce,M as we,N as Te,O as Ee,P as De,R as Oe,S as ke,_ as Ae,a as je,c as Me,d as Ne,i as Pe,j as Fe,l as Ie,m as Le,n as Re,o as ze,p as Be,r as Ve,s as He,u as Ue,v as We,w as Ge,x as Ke,y as qe,z as Je}from"./connectors-api-DEJU8mgn.js";import{s as Ye}from"./form-field-width-DJw_jULe.js";import{n as Xe}from"./electron-env-DHOGevH3.js";import{t as Ze}from"./page-tabs-oeTY7z3_.js";import{t as Qe}from"./page-header-store-Du44NIEJ.js";import{t as $e}from"./sliding-tab-list-DuQyViqe.js";import{t as et}from"./confirm-dialog-D7dQJytv.js";import{l as tt,m as nt,o as rt,r as it,t as at}from"./dist-ZrL34Ps4.js";import{t as ot}from"./capability-links-DzQWK1Fh.js";import{t as st}from"./capability-icon-DVoZxEgW.js";import{n as ct,t as lt}from"./capability-header-actions-BxMYfQ8y.js";import{t as ut}from"./connector-service-page-DlIl9bLx.js";import{t as dt}from"./number-input-El7Szeln.js";var Q=e(t(),1),ft=n(),$=r();function pt(e){let t=(0,ft.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,u,d,f;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(mt),p=e.slice(0,2),m=Math.max(0,e.length-p.length),h=o.connect,g;t[11]!==n||t[12]!==o?(g=W(n,o),t[11]=n,t[12]=o,t[13]=g):g=t[13];let _=g,v=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,y;t[14]!==h||t[15]!==n||t[16]!==i?(y=e=>(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,className:X(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(ee,{className:`size-4`}),h]}),t[14]=h,t[15]=n,t[16]=i,t[17]=y):y=t[17],s=y,f=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,c=`flex min-w-0 flex-1 flex-col`;let b;t[18]===n?b=t[19]:(b=(0,$.jsx)(te,{connector:n}),t[18]=n,t[19]=b);let x;t[20]!==n||t[21]!==a?(x=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=x):x=t[22];let S;t[23]===v?S=t[24]:(S=v?(0,$.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:v}):null,t[23]=v,t[24]=S);let C;t[25]!==S||t[26]!==x?(C=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),t[25]=S,t[26]=x,t[27]=C):C=t[27];let w;t[28]!==C||t[29]!==b?(w=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,C]}),t[28]=C,t[29]=b,t[30]=w):w=t[30];let T;t[31]!==r||t[32]!==s?(T=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=T):T=t[33];let E;t[34]!==r||t[35]!==o.connectedBadge?(E=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(O,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=E):E=t[36];let D;t[37]!==T||t[38]!==E?(D=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[T,E]}),t[37]=T,t[38]=E,t[39]=D):D=t[39],t[40]!==w||t[41]!==D?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[w,D]}),t[40]=w,t[41]=D,t[42]=l):l=t[42],t[43]===_?u=t[44]:(u=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:_,children:_}),t[43]=_,t[44]=u),d=p.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[p.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),m>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,m]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];let p;t[45]!==c||t[46]!==l||t[47]!==u||t[48]!==d?(p=(0,$.jsxs)(`div`,{className:c,children:[l,u,d]}),t[45]=c,t[46]=l,t[47]=u,t[48]=d,t[49]=p):p=t[49];let m;t[50]!==r||t[51]!==s?(m=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[50]=r,t[51]=s,t[52]=m):m=t[52];let h;return t[53]!==f||t[54]!==p||t[55]!==m?(h=(0,$.jsxs)(`div`,{className:f,children:[p,m]}),t[53]=f,t[54]=p,t[55]=m,t[56]=h):h=t[56],h}function mt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ht=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function gt(e,t){return t.some(t=>t.connectorId===e.id)}var _t=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function vt(){let e=(0,ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:X(`size-10 shrink-0 rounded-xl`,_t)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:X(`h-4 min-w-0 flex-1`,_t)}),(0,$.jsx)(`div`,{className:X(`h-8 w-[4.5rem] shrink-0 rounded-lg`,_t)})]}),(0,$.jsx)(`div`,{className:X(`h-3 w-full`,_t)}),(0,$.jsx)(`div`,{className:X(`h-3 w-[88%]`,_t)})]})]})}),e[1]=n):n=e[1],n}function yt(){let e=(0,ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(fe,{className:`size-9 shrink-0 rounded-lg`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4`,"aria-hidden":!0,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(fe,{className:`h-4 w-28 max-w-full`}),(0,$.jsx)(fe,{className:`h-3 w-20 max-w-full`})]})]}),(0,$.jsx)(fe,{className:`mt-2 h-3 w-48 max-w-full`}),(0,$.jsx)(fe,{className:`ml-auto mt-auto h-3 w-16`})]}),e[1]=n):n=e[1],n}var bt=[`understand`,`act`,`reach`];function xt(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function St(e){return xt(e)[0]??`act`}function Ct(e,t){let n=t?St(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function wt(e,t){return t.connectorCapabilityLabels[e]??e}function Tt(e,t){if(e.runtime.type===`mcp`)return U(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`cli`?e.runtime.adapterId:e.runtime.sourceKind;return U(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function Et(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Dt(e){let t=(0,ft.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:o}=e,s;t[0]!==n||t[1]!==o?(s=W(n,o),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c=s,l,u,v,y,b,x,S,C,w,T,E,D,k,A,j,M;if(t[3]!==n||t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==o){let e=xt(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(At),...(n.setup.config??[]).filter(kt)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let s=a,N=n.capabilities.filter(Ot);v=_,S=!0,t[27]===i?C=t[28]:(C=e=>{e||i()},t[27]=i,t[28]=C),u=m,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=x):x=t[29],l=h,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(y=X(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),t[30]=y):y=t[30];let P;t[31]===n?P=t[32]:(P=(0,$.jsx)(te,{connector:n,size:`lg`}),t[31]=n,t[32]=P);let F;t[33]===n.displayName?F=t[34]:(F=(0,$.jsx)(g,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=F);let I;t[35]!==r||t[36]!==o.connectedBadge?(I=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(O,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[35]=r,t[36]=o.connectedBadge,t[37]=I):I=t[37];let L;t[38]!==F||t[39]!==I?(L=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[F,I]}),t[38]=F,t[39]=I,t[40]=L):L=t[40];let R;t[41]===c?R=t[42]:(R=(0,$.jsx)(f,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:c}),t[41]=c,t[42]=R);let z;t[43]!==L||t[44]!==R?(z=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[L,R]}),t[43]=L,t[44]=R,t[45]=z):z=t[45];let B;t[46]!==P||t[47]!==z?(B=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[P,z]}),t[46]=P,t[47]=z,t[48]=B):B=t[48];let H;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(H=X(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ve.focusRingPanel),t[49]=H):H=t[49];let ee;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(de,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=ee):ee=t[50];let W;t[51]===o.modalClose?W=t[52]:(W=(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:H,"aria-label":o.modalClose,children:ee})}),t[51]=o.modalClose,t[52]=W),t[53]!==B||t[54]!==W?(b=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[B,W]}),t[53]=B,t[54]=W,t[55]=b):b=t[55],A=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,j=e.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.connectorBenefitHints[e]})]},e))})]}):null;let G;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=G):G=t[56];let ne;t[57]===o.detailPermissions?ne=t[58]:(ne=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.detailPermissions}),t[57]=o.detailPermissions,t[58]=ne);let re;t[59]!==n||t[60]!==o?(re=Et(n,o),t[59]=n,t[60]=o,t[61]=re):re=t[61];let ie;t[62]===re?ie=t[63]:(ie=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:re}),t[62]=re,t[63]=ie);let K;t[64]!==ne||t[65]!==ie?(K=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[G,(0,$.jsxs)(`div`,{children:[ne,ie]})]}),t[64]=ne,t[65]=ie,t[66]=K):K=t[66];let ae;t[67]===o.connectorSetupTitle?ae=t[68]:(ae=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorSetupTitle}),t[67]=o.connectorSetupTitle,t[68]=ae);let oe;t[69]!==s.length||t[70]!==o.connectorRequiredInputsCount||t[71]!==o.connectorSetupNone?(oe=s.length?U(o.connectorRequiredInputsCount,{count:String(s.length)}):o.connectorSetupNone,t[69]=s.length,t[70]=o.connectorRequiredInputsCount,t[71]=o.connectorSetupNone,t[72]=oe):oe=t[72];let q;t[73]===oe?q=t[74]:(q=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:oe}),t[73]=oe,t[74]=q);let se;t[75]!==ae||t[76]!==q?(se=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[ae,q]}),t[75]=ae,t[76]=q,t[77]=se):se=t[77],t[78]!==K||t[79]!==se?(M=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[K,se]}),t[78]=K,t[79]=se,t[80]=M):M=t[80],D=`rounded-xl border border-edge bg-surface-base`,t[81]===o.connectorTechnicalDetails?k=t[82]:(k=(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:o.connectorTechnicalDetails}),t[81]=o.connectorTechnicalDetails,t[82]=k),w=`space-y-5 border-t border-edge-subtle px-4 py-4`;let ce;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(J,{className:`size-3.5`,"aria-hidden":!0}),t[83]=ce):ce=t[83];let le;t[84]===o.connectorRuntimeTitle?le=t[85]:(le=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[ce,o.connectorRuntimeTitle]}),t[84]=o.connectorRuntimeTitle,t[85]=le);let ue;t[86]!==n||t[87]!==o?(ue=Tt(n,o),t[86]=n,t[87]=o,t[88]=ue):ue=t[88];let Y;t[89]===ue?Y=t[90]:(Y=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:ue}),t[89]=ue,t[90]=Y),t[91]!==le||t[92]!==Y?(T=(0,$.jsxs)(`div`,{children:[le,Y]}),t[91]=le,t[92]=Y,t[93]=T):T=t[93],E=N.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:N.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:wt(e,o)},e))}):null,t[3]=n,t[4]=c,t[5]=r,t[6]=i,t[7]=o,t[8]=l,t[9]=u,t[10]=v,t[11]=y,t[12]=b,t[13]=x,t[14]=S,t[15]=C,t[16]=w,t[17]=T,t[18]=E,t[19]=D,t[20]=k,t[21]=A,t[22]=j,t[23]=M}else l=t[8],u=t[9],v=t[10],y=t[11],b=t[12],x=t[13],S=t[14],C=t[15],w=t[16],T=t[17],E=t[18],D=t[19],k=t[20],A=t[21],j=t[22],M=t[23];let N;t[94]!==w||t[95]!==T||t[96]!==E?(N=(0,$.jsxs)(`div`,{className:w,children:[T,E]}),t[94]=w,t[95]=T,t[96]=E,t[97]=N):N=t[97];let P;t[98]!==N||t[99]!==D||t[100]!==k?(P=(0,$.jsxs)(`details`,{className:D,children:[k,N]}),t[98]=N,t[99]=D,t[100]=k,t[101]=P):P=t[101];let F;t[102]!==P||t[103]!==A||t[104]!==j||t[105]!==M?(F=(0,$.jsxs)(`div`,{className:A,children:[j,M,P]}),t[102]=P,t[103]=A,t[104]=j,t[105]=M,t[106]=F):F=t[106];let I;t[107]===o.modalClose?I=t[108]:(I=(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(Z,{variant:`secondary`,children:o.modalClose})}),t[107]=o.modalClose,t[108]=I);let L;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==o.connect?(L=r?null:(0,$.jsxs)(Z,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(ee,{className:`size-4`}),o.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=o.connect,t[114]=L):L=t[114];let R;t[115]!==I||t[116]!==L?(R=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[I,L]}),t[115]=I,t[116]=L,t[117]=R):R=t[117];let z;t[118]!==l||t[119]!==y||t[120]!==b||t[121]!==F||t[122]!==R?(z=(0,$.jsxs)(l,{className:y,children:[b,F,R]}),t[118]=l,t[119]=y,t[120]=b,t[121]=F,t[122]=R,t[123]=z):z=t[123];let B;t[124]!==u||t[125]!==x||t[126]!==z?(B=(0,$.jsxs)(u,{children:[x,z]}),t[124]=u,t[125]=x,t[126]=z,t[127]=B):B=t[127];let H;return t[128]!==v||t[129]!==S||t[130]!==C||t[131]!==B?(H=(0,$.jsx)(v,{open:S,onOpenChange:C,children:B}),t[128]=v,t[129]=S,t[130]=C,t[131]=B,t[132]=H):H=t[132],H}function Ot(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function kt(e){return e.required}function At(e){return e.required}var jt=(0,Q.memo)(function(e){let t=(0,ft.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:s,browseLabel:c,customLabel:l,serviceLabel:u,moreActionsLabel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=X(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,ve.transition),t[0]=m):m=t[0];let h=m,g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(ae,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=g):g=t[1];let _;t[2]===s?_=t[3]:(_=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s}),t[2]=s,t[3]=_);let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(S,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=v):v=t[4];let y;t[5]!==s||t[6]!==_?(y=(0,$.jsx)(nt,{asChild:!0,children:(0,$.jsxs)(Z,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":s,children:[g,_,v]})}),t[5]=s,t[6]=_,t[7]=y):y=t[7];let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(ce,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=b):b=t[8];let x;t[9]!==c||t[10]!==a?(x=(0,$.jsxs)(it,{className:h,onSelect:a,children:[b,c]}),t[9]=c,t[10]=a,t[11]=x):x=t[11];let C;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(Y,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=C):C=t[12];let w;t[13]!==l||t[14]!==o?(w=(0,$.jsxs)(it,{className:h,onSelect:o,children:[C,l]}),t[13]=l,t[14]=o,t[15]=w):w=t[15];let T;t[16]!==x||t[17]!==w?(T=(0,$.jsx)(rt,{children:(0,$.jsxs)(at,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[x,w]})}),t[16]=x,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==y?(E=(0,$.jsxs)(tt,{children:[y,T]}),t[19]=T,t[20]=y,t[21]=E):E=t[21];let D;t[22]===f?D=t[23]:(D=(0,$.jsx)(ut,{open:f,onOpenChange:p,hideTrigger:!0}),t[22]=f,t[23]=D);let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(L,{className:`size-4`,"aria-hidden":!0}),t[24]=O):O=t[24];let k;t[25]===d?k=t[26]:(k=(0,$.jsx)(nt,{asChild:!0,children:(0,$.jsx)(Z,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":d,title:d,children:O})}),t[25]=d,t[26]=k);let A;t[27]!==n||t[28]!==i||t[29]!==r?(A=n?(0,$.jsxs)(it,{className:h,disabled:r,onSelect:n,children:[r?(0,$.jsx)(H,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(oe,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=A):A=t[30];let j,M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>p(!0),M=(0,$.jsx)(se,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=j,t[32]=M):(j=t[31],M=t[32]);let N;t[33]===u?N=t[34]:(N=(0,$.jsxs)(it,{className:h,onSelect:j,children:[M,u]}),t[33]=u,t[34]=N);let P;t[35]!==A||t[36]!==N?(P=(0,$.jsx)(rt,{children:(0,$.jsxs)(at,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[A,N]})}),t[35]=A,t[36]=N,t[37]=P):P=t[37];let F;t[38]!==k||t[39]!==P?(F=(0,$.jsxs)(tt,{children:[k,P]}),t[38]=k,t[39]=P,t[40]=F):F=t[40];let I;return t[41]!==E||t[42]!==D||t[43]!==F?(I=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[E,D,F]}),t[41]=E,t[42]=D,t[43]=F,t[44]=I):I=t[44],I});function Mt(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var Nt=/^([^:=]+)[:=](.*)$/;function Pt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return It(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Nt.exec(t);r&&n.push(Mt(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function Ft(e){let t=Object.create(null);for(let n of e){let e=n.key.trim();e&&(t[e]=n.reference??n.value)}return Object.keys(t).length>0?t:void 0}function It(e){if(!e||typeof e!=`object`)return[Mt()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Mt(e),reference:t}:Mt(e,t==null?``:String(t)));return t.length>0?t:[Mt()]}function Lt(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function Rt(e){let t=e.trim();if(!t)return;if(t.startsWith(`[`)){let e=JSON.parse(t);if(!Array.isArray(e)||e.some(e=>typeof e!=`string`))throw Error(`Command arguments must be a JSON array of strings.`);return e}let n=[],r=``,i=``,a=!1;for(let e=0;e<t.length;e++){let o=t[e];o===`\\`&&t[e+1]&&i!==`'`&&/[\s"'\\]/.test(t[e+1])?(r+=t[++e],a=!0):i?o===i?i=``:r+=o:o===`"`||o===`'`?(i=o,a=!0):/\s/.test(o)?a&&=(n.push(r),r=``,!1):(r+=o,a=!0)}if(i)throw Error(`Command arguments contain an unclosed quote.`);return a&&n.push(r),n}function zt(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function Bt(e){let t={...e.extra,exposure:e.exposure};if(e.displayName?.trim()?t.displayName=e.displayName.trim():delete t.displayName,delete t.command,delete t.args,delete t.env,delete t.cwd,delete t.url,delete t.headers,delete t.type,e.transport===`stdio`){t.type=`stdio`,t.command=e.command.trim();let n=Rt(e.argsText);if(n&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envEntries){let n=new Set;for(let t of e.envEntries)if(!(!t.key.trim()&&!t.value&&!t.reference)){if(!t.key.trim()||n.has(t.key.trim()))throw Error(`Environment variable names must be non-empty and unique.`);n.add(t.key.trim())}let r=Ft(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=zt(e.envJson));delete t.oauth,delete t.auth}else{t.type=`http`,t.url=e.url.trim();let n=Ft(e.headers);n&&(t.headers=n);let r={...t.oauth??{}};e.oauthClientId.trim()?r.clientId=e.oauthClientId.trim():delete r.clientId,Object.keys(r).length?t.oauth=r:delete t.oauth}return e.timeout===void 0?delete t.timeout:t.timeout=e.timeout,t}function Vt(e,t){let n=t.oauth;return{clientKey:e,id:e,displayName:typeof t.displayName==`string`?t.displayName:``,transport:typeof t.url==`string`?`streamable-http`:`stdio`,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?JSON.stringify(t.args):``,envJson:t.env?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:``,url:typeof t.url==`string`?t.url:``,headers:It(t.headers),oauthClientId:typeof n?.clientId==`string`?n.clientId:``,timeout:typeof t.timeout==`number`?t.timeout:void 0,exposure:t.exposure??`codemode`,extra:t}}function Ht(e,t){let n=`mcp`;try{n=e.transport===`streamable-http`?new URL(e.url).hostname:e.command.split(/[\\/]/).pop()||n}catch{}let r=n.replace(/[^a-zA-Z0-9_-]+/g,`_`).replace(/^_+|_+$/g,``)||`mcp`,i=new Set([...t].map(e=>e.replace(/-/g,`_`))),a=r;for(let e=2;i.has(a.replace(/-/g,`_`));e++)a=`${r}_${e}`;return a}function Ut(e){let t=e.trim(),n=new URL(/^[a-z][a-z\d+.-]*:/i.test(t)&&!/^[^/]+:\d+(?:[/?#]|$)/.test(t)?t:`${/^(localhost|127\.0\.0\.1)(:|\/|$)/i.test(t)?`http`:`https`}://${t}`);if(![`http:`,`https:`].includes(n.protocol)||n.username||n.password)throw Error(`Use an HTTP or HTTPS MCP address without embedded credentials.`);return n.href}function Wt(e){let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Expected a JSON object.`);let n=t.mcpServers??t.mcp?.servers??t.servers;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Expected a server configuration object.`);let r=n?Object.entries(n):[[``,t]];if(!r.length)throw Error(`No MCP servers found.`);return r.map(([e,t])=>{if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid MCP server configuration.`);let n=t;if(typeof n.url!=`string`&&typeof n.command!=`string`)throw Error(`The configuration needs an MCP URL or command.`);if(n.args!==void 0&&(!Array.isArray(n.args)||n.args.some(e=>typeof e!=`string`)))throw Error(`Command arguments must be strings.`);let r=Vt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Ut(r.url),r})}function Gt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Kt(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Lt(e)).map(([e,t])=>Vt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function qt(e){return Bt(e)}async function Jt(e,t){return(await l(o(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function Yt(e,t,n,r){return(await l(o(`/api/mcp/drafts`),{method:`POST`,signal:r,body:JSON.stringify({serverId:e.id,sourceServerId:t,expectedServer:n,server:Bt(e)})})).payload}async function Xt(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Zt(e){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Qt(e,t=!1){let n=await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return he(),n.payload}async function $t(e){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function en(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function tn(e){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function nn(e,t){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function rn(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function an(e){let t=await l(o(`/api/mcp/servers`),{signal:e});return Object.fromEntries(t.payload.servers.filter(e=>e.lastCheck&&Number.isFinite(Date.parse(e.lastCheck.checkedAt))).map(e=>[e.id,e.lastCheck]))}async function on(e){let t=await l(o(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return he(),t.payload}function sn(e){let t=(0,ft.c)(111),{serverId:n,displayName:r,returnFocusTo:i,draftId:a,t:o,onClose:s,onConfigure:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[0]=l):l=t[0];let[u,v]=(0,Q.useState)(l),[y,b]=(0,Q.useState)(!0),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(0),D=(0,Q.useRef)(!1),O;t[1]!==a||t[2]!==n||t[3]!==o.setupAccessDenied||t[4]!==o.setupConflict||t[5]!==o.setupGatewayUnauthorized||t[6]!==o.setupRateLimited||t[7]!==o.toolsLoadFailed?(O=()=>{let e=new AbortController,t=!0;return b(!0),S(``),v([]),(a?rn(a,e.signal):Jt(n,e.signal)).then(e=>{t&&v(e)}).catch(e=>{let n=e?.status;t&&S(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&b(!1)}),()=>{t=!1,e.abort()}},t[1]=a,t[2]=n,t[3]=o.setupAccessDenied,t[4]=o.setupConflict,t[5]=o.setupGatewayUnauthorized,t[6]=o.setupRateLimited,t[7]=o.toolsLoadFailed,t[8]=O):O=t[8];let k;t[9]!==a||t[10]!==T||t[11]!==n||t[12]!==o?(k=[n,a,T,o],t[9]=a,t[10]=T,t[11]=n,t[12]=o,t[13]=k):k=t[13],(0,Q.useEffect)(O,k);let A,j,M,N,P,F,I,L,R,z,B,V,H;if(t[14]!==r||t[15]!==x||t[16]!==y||t[17]!==s||t[18]!==c||t[19]!==C||t[20]!==i||t[21]!==n||t[22]!==o.exposureLabels||t[23]!==o.setupConfigure||t[24]!==o.toolDetails||t[25]!==o.toolsClearSearch||t[26]!==o.toolsDialogSearchEmpty||t[27]!==o.toolsDialogSearchPlaceholder||t[28]!==o.toolsDialogSubtitle||t[29]!==o.toolsDialogTitle||t[30]!==o.toolsEmpty||t[31]!==o.toolsLoading||t[32]!==o.toolsRetryHint||t[33]!==o.toolsSearchSummary||t[34]!==o.toolsTitle||t[35]!==u){let e=C.trim().toLowerCase(),a;if(t[49]!==n){let e;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[51]=e):e=t[51],a=n.replace(e,`_`),t[49]=n,t[50]=a}else a=t[50];let l=`mcp__${a}__`,p=u.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));M=_,F=!0,t[52]===s?I=t[53]:(I=e=>{e||s()},t[52]=s,t[53]=I),j=m,t[54]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(d,{className:`fixed inset-0 z-[60] bg-scrim`}),t[54]=P):P=t[54],A=h,t[55]===i?V=t[56]:(V=e=>{(D.current||i)&&e.preventDefault(),!D.current&&i?.isConnected&&i.focus()},t[55]=i,t[56]=V),H=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`;let v;t[57]===o.toolsDialogTitle?v=t[58]:(v=(0,$.jsx)(g,{className:`font-semibold`,children:o.toolsDialogTitle}),t[57]=o.toolsDialogTitle,t[58]=v);let b;t[59]!==r||t[60]!==x||t[61]!==y||t[62]!==n||t[63]!==o.toolsDialogSubtitle||t[64]!==u.length?(b=y||x?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(u.length)),t[59]=r,t[60]=x,t[61]=y,t[62]=n,t[63]=o.toolsDialogSubtitle,t[64]=u.length,t[65]=b):b=t[65];let S;t[66]===b?S=t[67]:(S=(0,$.jsx)(f,{className:`mt-1 break-words text-sm text-fg-muted`,children:b}),t[66]=b,t[67]=S);let T;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>w(e.target.value),t[68]=T):T=t[68];let E;t[69]!==C||t[70]!==o.toolsDialogSearchPlaceholder?(E=(0,$.jsx)(`input`,{className:`mt-4 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:C,onChange:T,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[69]=C,t[70]=o.toolsDialogSearchPlaceholder,t[71]=E):E=t[71];let O=e&&!y&&!x?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(p.length)).replace(`{{count}}`,String(u.length))}):null;t[72]!==v||t[73]!==S||t[74]!==E||t[75]!==O?(N=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[v,S,E,O]}),t[72]=v,t[73]=S,t[74]=E,t[75]=O,t[76]=N):N=t[76],L=`min-h-0 flex-1 overflow-y-auto p-5`,R=y,t[77]!==o.toolsTitle||t[78]!==u.length?(z=o.toolsTitle.replace(`{{count}}`,String(u.length)),t[77]=o.toolsTitle,t[78]=u.length,t[79]=z):z=t[79],B=y?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map(ln)}):x?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:x}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(Z,{variant:`secondary`,onClick:()=>{D.current=!0,c()},children:o.setupConfigure}):null]}):p.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:p.map(e=>(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`h3`,{className:`break-all font-mono text-sm font-semibold text-fg`,children:e.name.startsWith(l)?e.name.slice(l.length):e.name}),e.exposure&&Object.hasOwn(o.exposureLabels,e.exposure)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.exposureLabels[e.exposure]}):null,e.description?(0,$.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:e.description}):null,(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:o.toolDetails}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:e.name}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel p-3 text-xs text-fg`,children:JSON.stringify(e.inputSchema,null,2)})]})]},e.name))}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.length?o.toolsDialogSearchEmpty:o.toolsEmpty}),e?(0,$.jsx)(Z,{variant:`secondary`,onClick:()=>w(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=x,t[16]=y,t[17]=s,t[18]=c,t[19]=C,t[20]=i,t[21]=n,t[22]=o.exposureLabels,t[23]=o.setupConfigure,t[24]=o.toolDetails,t[25]=o.toolsClearSearch,t[26]=o.toolsDialogSearchEmpty,t[27]=o.toolsDialogSearchPlaceholder,t[28]=o.toolsDialogSubtitle,t[29]=o.toolsDialogTitle,t[30]=o.toolsEmpty,t[31]=o.toolsLoading,t[32]=o.toolsRetryHint,t[33]=o.toolsSearchSummary,t[34]=o.toolsTitle,t[35]=u,t[36]=A,t[37]=j,t[38]=M,t[39]=N,t[40]=P,t[41]=F,t[42]=I,t[43]=L,t[44]=R,t[45]=z,t[46]=B,t[47]=V,t[48]=H}else A=t[36],j=t[37],M=t[38],N=t[39],P=t[40],F=t[41],I=t[42],L=t[43],R=t[44],z=t[45],B=t[46],V=t[47],H=t[48];let U;t[80]!==L||t[81]!==R||t[82]!==z||t[83]!==B?(U=(0,$.jsx)(`div`,{className:L,"aria-busy":R,"aria-label":z,children:B}),t[80]=L,t[81]=R,t[82]=z,t[83]=B,t[84]=U):U=t[84];let ee;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(ee=()=>E(cn),t[85]=ee):ee=t[85];let W;t[86]!==y||t[87]!==o.refreshTools?(W=(0,$.jsx)(Z,{variant:`secondary`,disabled:y,onClick:ee,children:o.refreshTools}),t[86]=y,t[87]=o.refreshTools,t[88]=W):W=t[88];let te;t[89]!==s||t[90]!==o.toolsDialogClose?(te=(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(Z,{onClick:s,children:o.toolsDialogClose})}),t[89]=s,t[90]=o.toolsDialogClose,t[91]=te):te=t[91];let G;t[92]!==W||t[93]!==te?(G=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[W,te]}),t[92]=W,t[93]=te,t[94]=G):G=t[94];let ne;t[95]!==A||t[96]!==N||t[97]!==U||t[98]!==G||t[99]!==V||t[100]!==H?(ne=(0,$.jsxs)(A,{onCloseAutoFocus:V,className:H,children:[N,U,G]}),t[95]=A,t[96]=N,t[97]=U,t[98]=G,t[99]=V,t[100]=H,t[101]=ne):ne=t[101];let re;t[102]!==j||t[103]!==P||t[104]!==ne?(re=(0,$.jsxs)(j,{children:[P,ne]}),t[102]=j,t[103]=P,t[104]=ne,t[105]=re):re=t[105];let ie;return t[106]!==M||t[107]!==F||t[108]!==I||t[109]!==re?(ie=(0,$.jsx)(M,{open:F,onOpenChange:I,children:re}),t[106]=M,t[107]=F,t[108]=I,t[109]=re,t[110]=ie):ie=t[110],ie}function cn(e){return e+1}function ln(e){return(0,$.jsx)(fe,{className:`h-24 w-full`},e)}function un(e){if(e.transport===`stdio`)return e.command.trim();try{let t=new URL(e.url);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.url.trim().split(/[?#]/,1)[0].replace(/\/\/[^/]*@/,`//`)}}function dn({row:e,lastCheck:t,t:n,cs:r,onEdit:i,onRemove:a}){let o=c(e=>e.language),[s,l]=(0,Q.useState)(!1),u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),h=e.displayName||e.id,g=un(e),_=e.extra.enabled===!1,v=_?k:t?O:F,y=e.transport===`stdio`?le:J,b=_?n.setupDisabled:t?r.customCheckSucceeded:r.customUnchecked,x=t?new Intl.DateTimeFormat(o,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.checkedAt)):null;return(0,$.jsxs)(`li`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`div`,{title:n.transportLabels[e.transport],className:`flex size-9 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-inset text-fg-muted`,children:(0,$.jsx)(y,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,$.jsx)(`h3`,{className:`min-w-0 max-w-full text-sm font-semibold text-fg`,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,title:h,className:`block max-w-full truncate rounded text-left hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:h})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:[(0,$.jsxs)(`span`,{title:x?r.customLastChecked.replace(`{{time}}`,x):void 0,"aria-label":x?`${b} · ${r.customLastChecked.replace(`{{time}}`,x)}`:b,className:X(`inline-flex shrink-0 items-center gap-1`,!_&&t?`text-emerald-700 dark:text-emerald-300`:`text-fg-muted`),children:[(0,$.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),b]}),t?(0,$.jsx)(`span`,{className:`text-fg-muted`,children:r.customToolCount.replace(`{{count}}`,String(t.toolCount))}):null]})]})})]}),(0,$.jsx)(`p`,{title:g,className:`mt-2 truncate font-mono text-xs leading-5 text-fg-muted`,children:g})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-auto text-[11px] text-fg-subtle`,children:n.transportLabels[e.transport]}),(0,$.jsx)(Z,{variant:`ghost`,className:`h-8 px-2 py-1 text-xs`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(Z,{ref:u,variant:`secondary`,className:`h-8 px-2 py-1 text-xs shadow-none sm:shadow-none`,disabled:_,onClick:()=>l(!0),children:n.viewTools}),(0,$.jsxs)(tt,{children:[(0,$.jsx)(nt,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,className:`size-8 p-0`,"aria-label":r.customManage.replace(`{{name}}`,h),title:r.customManage.replace(`{{name}}`,h),children:(0,$.jsx)(L,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(rt,{children:(0,$.jsx)(at,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:(0,$.jsxs)(it,{onSelect:()=>f(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none data-[highlighted]:bg-surface-hover`,children:[(0,$.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),n.removeServer]})})})]})]}),p?(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:p}):null,s?(0,$.jsx)(sn,{serverId:e.id,displayName:e.displayName,returnFocusTo:u.current,t:n,onClose:()=>l(!1),onConfigure:()=>{l(!1),i()}}):null,(0,$.jsx)(et,{open:d,title:r.removeConfirmTitle.replace(`{{name}}`,h),description:r.removeConfirmDescription,confirmLabel:n.removeServer,cancelLabel:r.modalCancel,destructive:!0,onCancel:()=>f(!1),onConfirm:()=>{f(!1),m(``),a().catch(()=>m(n.setupRemoveFailed))}})]})}function fn(e){let t=(0,ft.c)(30),{servers:n,lastChecks:r,t:i,cs:a,onAdd:o,onEdit:s,onRemove:c}=e,l;t[0]===a.customIntegrationsTitle?l=t[1]:(l=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.customIntegrationsTitle}),t[0]=a.customIntegrationsTitle,t[1]=l);let u;t[2]===n.length?u=t[3]:(u=(0,$.jsx)(`span`,{className:`rounded-md bg-surface-inset px-1.5 py-0.5 text-xs tabular-nums text-fg-muted`,children:n.length}),t[2]=n.length,t[3]=u);let d;t[4]!==l||t[5]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l,u]}),t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]===a.customIntegrationsHint?f=t[8]:(f=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.customIntegrationsHint}),t[7]=a.customIntegrationsHint,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}),t[12]=m):m=t[12];let h;t[13]!==a.customAdd||t[14]!==o?(h=(0,$.jsxs)(Z,{variant:`secondary`,className:`shrink-0 text-xs shadow-none sm:shadow-none`,onClick:o,children:[m,a.customAdd]}),t[13]=a.customAdd,t[14]=o,t[15]=h):h=t[15];let g;t[16]!==p||t[17]!==h?(g=(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[p,h]}),t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;t[19]!==a||t[20]!==r||t[21]!==s||t[22]!==c||t[23]!==n||t[24]!==i?(_=n.length?(0,$.jsx)(`ul`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:n.map(e=>(0,$.jsx)(dn,{row:e,lastCheck:r[e.id],t:i,cs:a,onEdit:()=>s(e),onRemove:()=>c(e)},e.clientKey))}):(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge px-5 py-8 text-center text-sm text-fg-muted`,children:a.customEmpty}),t[19]=a,t[20]=r,t[21]=s,t[22]=c,t[23]=n,t[24]=i,t[25]=_):_=t[25];let v;return t[26]!==a.customIntegrationsTitle||t[27]!==g||t[28]!==_?(v=(0,$.jsxs)(`section`,{"aria-label":a.customIntegrationsTitle,children:[g,_]}),t[26]=a.customIntegrationsTitle,t[27]=g,t[28]=_,t[29]=v):v=t[29],v}function pn(e){return e.format===`agent-plugin`&&!!e.pluginId&&(!!e.setup?.authorizations?.length||e.authorizationStatus===`required`||!!e.components?.mcp.some(e=>e.type!==`stdio`))}function mn(e){let t=(0,ft.c)(54),{extension:n,language:r,onOpen:i}=e,a;t[0]===r?a=t[1]:(a=r.startsWith(`zh`),t[0]=r,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(e,t)=>o?e:t,t[2]=o,t[3]=s);let c=s,l=n.installationState===`preparing`,u=n.activationEligible===!1,d=n.authorizationStatus===`required`,f;t[4]!==u||t[5]!==n.readiness||t[6]!==d||t[7]!==l||t[8]!==c?(f=l?c(`准备未完成`,`Setup incomplete`):u?c(`已停用`,`Disabled`):d?c(`需要授权`,`Authorization required`):n.readiness===`blocked`||n.readiness===`degraded`?c(`需要处理`,`Needs attention`):c(`已连接`,`Connected`),t[4]=u,t[5]=n.readiness,t[6]=d,t[7]=l,t[8]=c,t[9]=f):f=t[9];let p=f,m;t[10]!==u||t[11]!==d||t[12]!==l||t[13]!==c?(m=l?c(`继续安装`,`Continue setup`):!u&&d?c(`去授权`,`Connect account`):c(`查看详情`,`View details`),t[10]=u,t[11]=d,t[12]=l,t[13]=c,t[14]=m):m=t[14];let h=m,g;t[15]===n.setup?.authorizations?g=t[16]:(g=n.setup?.authorizations??[],t[15]=n.setup?.authorizations,t[16]=g);let _=g,v=_.length===1?_[0].title:n.name,y=l||!u&&(d||n.readiness===`blocked`||n.readiness===`degraded`),b=l?F:u?k:y?D:O,x=y&&`border-amber-500/25`,S;t[17]===x?S=t[18]:(S=X(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,x),t[17]=x,t[18]=S);let w=n.branding?.iconUrl,T;t[19]===w?T=t[20]:(T=(0,$.jsx)(st,{iconUrl:w,fallback:K,className:`size-9`}),t[19]=w,t[20]=T);let E;t[21]===v?E=t[22]:(E=(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-fg`,title:v,children:v}),t[21]=v,t[22]=E);let A=y?`text-amber-700 dark:text-amber-300`:u?`text-fg-muted`:`text-emerald-700 dark:text-emerald-300`,j;t[23]===A?j=t[24]:(j=X(`mt-1 inline-flex items-center gap-1 text-[11px]`,A),t[23]=A,t[24]=j);let M;t[25]===b?M=t[26]:(M=(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),t[25]=b,t[26]=M);let N;t[27]!==p||t[28]!==j||t[29]!==M?(N=(0,$.jsxs)(`span`,{className:j,children:[M,p]}),t[27]=p,t[28]=j,t[29]=M,t[30]=N):N=t[30];let P;t[31]!==E||t[32]!==N?(P=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[E,N]}),t[31]=E,t[32]=N,t[33]=P):P=t[33];let I;t[34]!==P||t[35]!==T?(I=(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-start gap-3`,children:[T,P]}),t[34]=P,t[35]=T,t[36]=I):I=t[36];let L=n.name,R;t[37]===c?R=t[38]:(R=c(`由插件提供`,`Provided by plugin`),t[37]=c,t[38]=R);let z;t[39]!==n.name||t[40]!==R?(z=(0,$.jsxs)(`span`,{className:`mt-2 block w-full truncate text-xs leading-5 text-fg-muted`,title:L,children:[R,` · `,n.name]}),t[39]=n.name,t[40]=R,t[41]=z):z=t[41];let B=y?`text-accent-fg`:`text-fg-muted`,V;t[42]===B?V=t[43]:(V=X(`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs`,B),t[42]=B,t[43]=V);let H;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(C,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[44]=H):H=t[44];let U;t[45]!==h||t[46]!==V?(U=(0,$.jsxs)(`span`,{className:V,children:[h,H]}),t[45]=h,t[46]=V,t[47]=U):U=t[47];let ee;return t[48]!==i||t[49]!==I||t[50]!==z||t[51]!==U||t[52]!==S?(ee=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:S,children:[I,z,U]}),t[48]=i,t[49]=I,t[50]=z,t[51]=U,t[52]=S,t[53]=ee):ee=t[53],ee}function hn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function gn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?hn(t)-hn(e):e.isCurrentAuthorization?-1:1}function _n(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(gn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>gn(e.primary,t.primary))}var vn=X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ye);function yn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function bn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function xn(e,t,n){return e.status===`connected`?U(n.composioHealthConnected,{count:String(t)}):e.status===`reauthorization_required`?n.composioHealthReconnect:e.status===`disconnected`?n.composioHealthDisconnected:e.errorCode===`missing_credential`?n.composioHealthMissingCredential:e.errorCode===`unauthorized`?n.composioHealthUnauthorized:e.errorCode===`forbidden`?n.composioHealthForbidden:e.errorCode===`network`?n.composioHealthNetwork:e.errorCode===`timeout`?n.composioHealthTimeout:n.composioHealthDegraded}function Sn(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function Cn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function wn({instance:e,t,onChanged:n}){let r=yn(e),i=c(e=>e.language)===`zh`,[a,o]=(0,Q.useState)([]),[s,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)([]),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)([]),[S,C]=(0,Q.useState)({}),[E,k]=(0,Q.useState)(`read`),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(null),[B,ee]=(0,Q.useState)(!1),[W,te]=(0,Q.useState)(!1),[G,re]=(0,Q.useState)(!1),ie=(0,Q.useRef)(0),K=(0,Q.useRef)(0),ae=(0,Q.useMemo)(()=>_n(a),[a]),q=(0,Q.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),J=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;j(!0),N(null);let t=++ie.current;try{let e=(await Promise.allSettled([q(Ae()).then(e=>{t===ie.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),ee(!0))}),q(Ne(r)).then(e=>{t===ie.current&&k(e)}),q(Ue(r)).then(e=>{t===ie.current&&(p(e.policy),h(e.agents))})])).find(e=>e.status===`rejected`);t===ie.current&&e?.status===`rejected`&&N(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===ie.current&&j(!1)}},[e.materialized,r,q]);(0,Q.useEffect)(()=>(J(),()=>{ie.current++}),[J]);let se=(0,Q.useCallback)(async()=>{if(!r)return;let e=++K.current;re(!0),F(!1);let t=t=>n=>{e===K.current&&t(n)},n=await Promise.allSettled([q(We(r)).then(t(l)),q(qe(20)).then(t(e=>d(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),q(Be(r)).then(t(y)),q(Ie(r)).then(t(_))]);e===K.current&&(F(n.some(e=>e.status===`rejected`)),re(!1))},[r,q]);(0,Q.useEffect)(()=>(W&&se(),()=>{K.current++}),[W,se]),(0,Q.useEffect)(()=>{let e=!1,t=_n(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return q(Ke()).then(t=>{e||x(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await q(Le(e.accountId))])).then(t=>{e||C(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,q]);let ce=(0,Q.useCallback)(async i=>{if(!r)return;let a=Xe()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),j(!0),N(null);try{if(!Xe()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await Fe(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(Xe()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else a.location.href=t.authorizationUrl;let o=await Je(r,t.connectionId,12e4,t.attemptId);if(i&&o.accountId!==i)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),J()])}catch(e){N(ne(e,t))}finally{a?.close(),j(!1)}},[e.connectorId,J,n,t,r]),le=(0,Q.useCallback)(async t=>{j(!0),N(null);try{await Ce(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),J()])}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[e.config,e.instanceId,J,n]),Y=async e=>{let t=Xe()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),N(null);try{let n=await Me(e.id);if(n.authorizationUrl)if(Xe())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await J()}catch(e){t?.close(),N(e instanceof Error?e.message:String(e))}},de=(0,Q.useCallback)(async e=>{if(r){k(e),N(null);try{await Ee(r,e)}catch(e){N(e instanceof Error?e.message:String(e)),await J()}}},[J,r]),pe=(0,Q.useCallback)(async e=>{if(r){N(null);try{p(await Se(r,e))}catch(e){N(e instanceof Error?e.message:String(e))}}},[r]),me=(0,Q.useCallback)(e=>{if(!f)return;let t=f.allowedAgentIds.includes(e);if(t&&f.allowedAgentIds.length===1)return;let n=t?f.allowedAgentIds.filter(t=>t!==e):[...f.allowedAgentIds,e];pe({allowedAgentIds:n})},[pe,f]),he=(0,Q.useCallback)(async e=>{j(!0),N(null);try{await e(),await J()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[J]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let ge=ae.filter(e=>e.primary.status===`active`).length,_e=ge>0?t.composioAddAccount:t.composioConnectAccount,ve=B&&ge>0,we=v?.requiresCustomAuthConfig===!0,Te=v?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,ve?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[ve?(0,$.jsx)(O,{className:`size-3.5`}):(0,$.jsx)(D,{className:`size-3.5`}),ve?t.connectionReady:B||M?t.connectionNeedsSetup:t.connectionChecking]}),B&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:U(t.composioAccountCount,{count:String(ae.length)})})]}),(0,$.jsxs)(Z,{variant:`primary`,className:`shrink-0`,disabled:A,onClick:()=>void ce(),children:[A?(0,$.jsx)(H,{className:`size-4 animate-spin`}):(0,$.jsx)(V,{className:`size-4`}),_e]})]}),M?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:M}),(0,$.jsx)(Z,{variant:`secondary`,disabled:A,onClick:()=>void J(),children:t.composioRetry})]}):null,g&&!ve?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:xn(g,ge,t)}),g.recovery===`none`?null:(0,$.jsx)(Z,{variant:`secondary`,disabled:A,onClick:()=>void(g.recovery===`retry`?J():ce()),children:g.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,we&&Te.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,f?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:E===`read`?t.composioAccessReadHint:E===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(w,{value:E,onChange:e=>void de(e.currentTarget.value),children:[(0,$.jsx)(T,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(T,{value:`write`,children:t.composioAccessReadWrite}),E===`admin`?(0,$.jsx)(T,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(w,{value:f.confirmationPolicy,onChange:e=>void pe({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(T,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(T,{value:`always`,children:t.composioConfirmAlways}),f.confirmationPolicy===`never`?(0,$.jsx)(T,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:f.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:X(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void pe({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),m.map(e=>(0,$.jsx)(`button`,{type:`button`,className:X(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>me(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:f.selectedAccountIds===null,disabled:A,onChange:e=>void pe({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),f.selectedAccountIds!==null&&ae.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:A,checked:f.selectedAccountIds.includes(e.accountId),onChange:t=>void pe({selectedAccountIds:t.currentTarget.checked?[...f.selectedAccountIds,e.accountId]:f.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),f.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),B&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:U(t.composioAccountCount,{count:String(ae.length)})})]}),(0,$.jsxs)(Z,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:A,onClick:()=>void J(),children:[(0,$.jsx)(oe,{className:X(`size-3.5`,A&&`animate-spin`)}),t.refresh]})]}),ae.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:ae.map(e=>{let r=e.primary,a=b.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?S[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:X(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:Sn(r.status,t)}),a?(0,$.jsx)(`p`,{className:X(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:U(t.connectorLearningStatus,{status:Cn(a,o,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(Z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void Y(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(Z,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:A,onClick:()=>z(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(Z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:A,onClick:()=>void ce(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(Z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:A,onClick:()=>void he(()=>De(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(Z,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:A,onClick:()=>void he(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await ye(r.accountId),await n?.()}),children:[(0,$.jsx)(oe,{className:`size-3.5`}),t.composioSyncNow]}):null]})]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[r.accountId&&(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 font-medium`,children:t.composioAllowedAgents}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:A,checked:r.allowedAgentIds==null,onChange:e=>void he(()=>De(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&m.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:A,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;he(()=>De(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&o?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:A,onChange:e=>void he(()=>Oe(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(w,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:A,onChange:e=>void he(()=>Oe(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(T,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(T,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(T,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(T,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:X(vn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&he(()=>xe(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(Z,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:A,onClick:()=>L(e.id),children:(0,$.jsx)(ue,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(Z,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:A,onClick:()=>void he(()=>ke(r.id)),children:(0,$.jsx)(oe,{className:`size-4`})})})]})]})]},e.key)})}):A&&!B?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(fe,{className:`h-16 w-full`}),(0,$.jsx)(fe,{className:`h-16 w-full`})]}):B?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>te(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[G?(0,$.jsx)(fe,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,P?(0,$.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[t.composioDiagnosticsUnavailable,(0,$.jsx)(Z,{variant:`ghost`,disabled:G,onClick:()=>void se(),children:t.composioRetry})]}):null,v?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:we?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(w,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:A,onChange:e=>void le(e.currentTarget.value),children:[we?null:(0,$.jsx)(T,{value:``,children:t.composioAuthConfigManaged}),we&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(T,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,Te.map(e=>(0,$.jsxs)(T,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children:s.length?s.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[bn(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:u.length?u.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})})]})]})]})]}),(0,$.jsx)(et,{open:R!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=R;z(null),e&&he(()=>Re(e))},onCancel:()=>z(null)}),(0,$.jsx)(et,{open:I!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=I;L(null),e&&he(()=>be(e))},onCancel:()=>L(null)})]})}var Tn=X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ye);function En(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function Dn(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function On({instance:e,definition:t,onClose:n,onChanged:r,t:i}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(()=>En(t,e)),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),A=t?.setup.config??[],j=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&A.length>0&&(t?.setup.secrets??[]).length===0,M=e.materialized.type===`mcp`,N=e.materialized.type===`composio`,P=e.materialized.type===`memorySource`,F=t?W(t,i):null,L=(0,Q.useCallback)(async()=>{D(!0),T(null);try{let t=await Te(e.instanceId);k(t),t.ok||T(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{D(!1)}},[e.instanceId,r,i.healthStatusLabels]),R=(0,Q.useCallback)(async()=>{o(!0),T(null);try{await Ge(e.instanceId),await r(),n()}catch(e){T(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),z=(0,Q.useCallback)(async()=>{if(!(!t||!j)){u(!0),T(null);try{let n={};for(let e of t.setup.config??[]){let t=Dn(e.type,S[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ce(e.instanceId,{config:n}),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[S,t,e.instanceId,r,j]),B=(0,Q.useCallback)(async()=>{y(!0),x(null),T(null);try{let t=await we(e.connectorId);x(t.recordIds.length),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.connectorId,r]);return(0,$.jsxs)(_,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(m,{children:[(0,$.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(h,{className:X(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,N?`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,40rem)]`:`h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(te,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(g,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:F??(e.materialized.type===`mcp`?U(i.mcpServerRuntime,{serverId:e.materialized.serverId}):U(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(p,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:X(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ve.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(de,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[w?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:w}):null,M?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,role:`status`,children:O?.ok?U(i.toolsAvailable,{count:String(O.toolCount)}):O?i.healthStatusLabels[O.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(Z,{variant:`secondary`,"aria-busy":E,disabled:E||!e.enabled,onClick:()=>void L(),children:[E?(0,$.jsx)(H,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),j?A.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:Tn,value:S[e.key]??``,placeholder:e.placeholder,onChange:t=>C(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,N?(0,$.jsx)(wn,{instance:e,t:i,onChanged:r}):null,P?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),F?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:F}):null,b===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:U(i.connectedSourceSynced,{count:String(b)})})]}),(0,$.jsxs)(Z,{disabled:v,onClick:()=>void B(),children:[v?(0,$.jsx)(H,{className:`size-4 animate-spin`}):(0,$.jsx)(I,{className:`size-4`}),i.composioSyncNow]})]}),j?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:A.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:Tn,value:S[e.key]??``,placeholder:e.placeholder,onChange:t=>C(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!M&&!N&&!P?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:(0,$.jsx)(`p`,{children:i.connectorPolicyHint})}):null,(0,$.jsxs)(`details`,{className:`mt-5 rounded-xl border border-edge`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-danger`,children:i.dangerZone}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-danger/15 px-4 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i.removeConnectorHint}),(0,$.jsxs)(Z,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(H,{className:`size-4 animate-spin`}):(0,$.jsx)(ue,{className:`size-4`}),i.remove]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(Z,{variant:`secondary`,onClick:n,children:i.modalClose}),(M||P)&&j?(0,$.jsxs)(Z,{variant:`primary`,disabled:l,onClick:()=>void z(),children:[l?(0,$.jsx)(H,{className:`size-4 animate-spin`}):(0,$.jsx)(q,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(et,{open:s,title:U(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),R()},onCancel:()=>{a||c(!1)}})]})}function kn(e){let t=(0,ft.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(G,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(On,{...e}),t[0]=e,t[1]=n),n}function An(e){let t=(0,ft.c)(59),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i!==void 0&&i,c;t[0]!==r||t[1]!==n?(c=Ct(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c.state,u;t[3]!==r||t[4]!==o?(u=r?W(r,o):null,t[3]=r,t[4]=o,t[5]=u):u=t[5];let d=u,f,p,m,h,g,_,v,y,b;if(t[6]!==l||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==a||t[11]!==o.connectionChecking||t[12]!==o.connectionNeedsSetup||t[13]!==o.connectionReady){f=l===`ready`?{label:o.connectionReady,Icon:O,className:`text-emerald-700 dark:text-emerald-300`}:l===`needs_setup`?{label:o.connectionNeedsSetup,Icon:D,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:F,className:`text-fg-muted`},b=`button`;let e=l===`needs_setup`&&`border-amber-500/25`,i=s&&`bg-accent-soft`;t[23]!==e||t[24]!==i?(p=X(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left hover:bg-surface-hover/45`,ve.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e,i),t[23]=e,t[24]=i,t[25]=p):p=t[25],t[26]!==n||t[27]!==a?(m=()=>a(n),t[26]=n,t[27]=a,t[28]=m):m=t[28],v=`flex w-full min-w-0 items-start gap-3`,t[29]===r?y=t[30]:(y=(0,$.jsx)(te,{connector:r,size:`sm`}),t[29]=r,t[30]=y),g=`min-w-0 flex-1`,t[31]===n.displayName?_=t[32]:(_=(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:n.displayName,children:n.displayName}),t[31]=n.displayName,t[32]=_),h=X(`mt-1 inline-flex items-center gap-1 text-[11px]`,f.className),t[6]=l,t[7]=r,t[8]=s,t[9]=n,t[10]=a,t[11]=o.connectionChecking,t[12]=o.connectionNeedsSetup,t[13]=o.connectionReady,t[14]=f,t[15]=p,t[16]=m,t[17]=h,t[18]=g,t[19]=_,t[20]=v,t[21]=y,t[22]=b}else f=t[14],p=t[15],m=t[16],h=t[17],g=t[18],_=t[19],v=t[20],y=t[21],b=t[22];let x;t[33]===f.Icon?x=t[34]:(x=(0,$.jsx)(f.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[33]=f.Icon,t[34]=x);let S;t[35]!==f.label||t[36]!==x||t[37]!==h?(S=(0,$.jsxs)(`span`,{className:h,children:[x,f.label]}),t[35]=f.label,t[36]=x,t[37]=h,t[38]=S):S=t[38];let w;t[39]!==S||t[40]!==g||t[41]!==_?(w=(0,$.jsxs)(`div`,{className:g,children:[_,S]}),t[39]=S,t[40]=g,t[41]=_,t[42]=w):w=t[42];let T;t[43]!==w||t[44]!==v||t[45]!==y?(T=(0,$.jsxs)(`div`,{className:v,children:[y,w]}),t[43]=w,t[44]=v,t[45]=y,t[46]=T):T=t[46];let E;t[47]===d?E=t[48]:(E=d?(0,$.jsx)(`p`,{className:`mt-2 w-full line-clamp-2 text-xs leading-5 text-fg-muted`,title:d,children:d}):null,t[47]=d,t[48]=E);let k;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(C,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[49]=k):k=t[49];let A;t[50]===o.installedDetails?A=t[51]:(A=(0,$.jsxs)(`span`,{className:`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs text-fg-muted`,children:[o.installedDetails,k]}),t[50]=o.installedDetails,t[51]=A);let j;return t[52]!==p||t[53]!==m||t[54]!==T||t[55]!==E||t[56]!==A||t[57]!==b?(j=(0,$.jsxs)(`button`,{type:b,className:p,onClick:m,children:[T,E,A]}),t[52]=p,t[53]=m,t[54]=T,t[55]=E,t[56]=A,t[57]=b,t[58]=j):j=t[58],j}function jn(e,t){return Gt()}function Mn(e){let t=e.headers.filter(e=>e.key.trim()),n=t.find(e=>e.key.toLowerCase()===`authorization`&&!e.reference&&/^Bearer\s/i.test(e.value)),r=e.extra.auth||t.some(e=>e.reference)||e.extra.oauth&&t.some(e=>e.key.toLowerCase()===`authorization`)?`existing`:e.extra.oauth?`oauth`:n?`bearer`:t.length?`headers`:`auto`;return{mode:r,token:n?.value.replace(/^Bearer\s+/i,``)??``,apiKey:``,headerName:``,customHeaders:t.length?t:[Mt()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function Nn(e,t){if(e.transport===`stdio`||t.mode===`existing`)return{...e,extra:{...e.extra}};let n={...e.extra};delete n.auth,t.mode!==`oauth`&&delete n.oauth;let r=t.mode===`headers`?t.customHeaders:t.additionalHeaders;if(t.mode===`bearer`){let e=t.token.trim().replace(/^Bearer\s+/i,``);r=[...r,Mt(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Mt(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Pn(e){let t=new Set;return e.findIndex(e=>{let n=e.key.trim();if(!n&&!e.value&&!e.reference)return!1;if(!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(n)||/[\r\n]/.test(e.value))return!0;let r=n.toLowerCase();return t.has(r)?!0:(t.add(r),!1)})}function Fn(){return X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ye)}function In({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,pasteFailedTitle:o,dismissLabel:s,keyPlaceholder:c,valuePlaceholder:l,headers:u,onChange:d,referenceLabel:f=`Existing credential reference`,showValueLabel:p=`Show value`,hideValueLabel:m=`Hide value`,allowPaste:h=!0}){let[g,_]=(0,Q.useState)(new Set),[v,y]=(0,Q.useState)(!1),b=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},x=()=>{d([...u,Mt()])},S=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[Mt()])},C=async()=>{try{let e=await _e();if(!e){y(!0);return}let t=Pt(e);if(!t?.length){y(!0);return}d(t)}catch{y(!0)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),h?(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void C(),children:[(0,$.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto_auto]`,children:[(0,$.jsx)(`input`,{className:X(Fn(),`col-span-3 min-w-0 font-mono text-xs sm:col-span-1`),"aria-label":`${c} ${t+1}`,value:e.key,placeholder:c,onChange:e=>b(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:X(Fn(),`min-w-0 font-mono text-xs`),type:g.has(e.clientKey)?`text`:`password`,autoComplete:`off`,"aria-label":`${l} ${t+1}`,readOnly:!!e.reference,value:e.reference?f:e.value,placeholder:e.reference?f:l,onChange:e=>b(t,{value:e.target.value})}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":g.has(e.clientKey)?m:p,onClick:()=>_(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:g.has(e.clientKey)?(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(B,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>S(t),"aria-label":r,children:(0,$.jsx)(ue,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})}),e.reference?(0,$.jsx)(`p`,{className:`col-span-3 break-words text-xs text-fg-muted sm:col-span-4`,children:f}):null]},e.clientKey))}),(0,$.jsx)(et,{open:v,title:o,description:a,confirmLabel:s,onConfirm:()=>y(!1),onCancel:()=>y(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:X(`self-start text-sm text-accent hover:underline`,ve.press),onClick:x,children:[`+ `,n]})]})}var Ln=X(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,Ye);function Rn(e){let t=(0,ft.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o!==void 0&&o,[c,l]=(0,Q.useState)(!1),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=X(Ln,`mt-1.5`),t[0]=u):u=t[0];let d=c?`text`:`password`,f;t[1]===r?f=t[2]:(f=e=>r(e.target.value),t[1]=r,t[2]=f);let p;t[3]!==s||t[4]!==d||t[5]!==f||t[6]!==n?(p=(0,$.jsx)(`input`,{className:u,type:d,value:n,required:s,autoComplete:`off`,onChange:f}),t[3]=s,t[4]=d,t[5]=f,t[6]=n,t[7]=p):p=t[7];let m;t[8]!==i||t[9]!==p?(m=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i,p]}),t[8]=i,t[9]=p,t[10]=m):m=t[10];let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>l(zn),t[11]=h):h=t[11];let g;t[12]===c?g=t[13]:(g=c?(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(B,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=g);let _=c?a.setupHideValue:a.setupShowValue,v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:h,children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==m?(y=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[m,v]}),t[17]=v,t[18]=m,t[19]=y):y=t[19],y}function zn(e){return!e}function Bn(e){let t=(0,ft.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a!==void 0&&a,c=o!==void 0&&o,l=c?i.envLabel:s?i.setupAdditionalHeaders:i.headersLabel,u=c?i.setupAddEnv:i.addHeader,d=c?i.setupRemoveEnv:i.removeHeader,f=c?i.setupEnvName:i.headerKeyPlaceholder,p=c?i.setupEnvValue:i.headerValuePlaceholder,m=!c,h;return t[0]!==n||t[1]!==r||t[2]!==i.optionalSuffix||t[3]!==i.pasteHeaders||t[4]!==i.pasteHeadersDismiss||t[5]!==i.pasteHeadersFailed||t[6]!==i.pasteHeadersFailedTitle||t[7]!==i.setupHideValue||t[8]!==i.setupReference||t[9]!==i.setupShowValue||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(h=(0,$.jsx)(In,{label:l,optionalLabel:i.optionalSuffix,addLabel:u,removeHeaderAria:d,pasteLabel:i.pasteHeaders,pasteFailed:i.pasteHeadersFailed,pasteFailedTitle:i.pasteHeadersFailedTitle,dismissLabel:i.pasteHeadersDismiss,keyPlaceholder:f,valuePlaceholder:p,headers:n,onChange:r,referenceLabel:i.setupReference,showValueLabel:i.setupShowValue,hideValueLabel:i.setupHideValue,allowPaste:m}),t[0]=n,t[1]=r,t[2]=i.optionalSuffix,t[3]=i.pasteHeaders,t[4]=i.pasteHeadersDismiss,t[5]=i.pasteHeadersFailed,t[6]=i.pasteHeadersFailedTitle,t[7]=i.setupHideValue,t[8]=i.setupReference,t[9]=i.setupShowValue,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function Vn(e){let t=(0,ft.c)(52),{draft:n,onChange:r,t:i,allowExisting:a}=e,o=i.setupAuthLabel,s=i.setupAuthLabel,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=X(Ln,`mt-1.5`),t[0]=c):c=t[0];let l=n.mode,u;t[1]===r?u=t[2]:(u=e=>r({mode:e.target.value}),t[1]=r,t[2]=u);let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=[`auto`,`oauth`,`bearer`,`apiKey`,`headers`,`none`],t[3]=d):d=t[3];let f;t[4]===i.setupAuthModes?f=t[5]:(f=d.map(e=>(0,$.jsx)(T,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=f);let p;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(p=a||n.mode===`existing`?(0,$.jsx)(T,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=p):p=t[9];let m;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==u||t[13]!==f||t[14]!==p?(m=(0,$.jsxs)(w,{"aria-label":s,className:c,value:l,onChange:u,children:[f,p]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=u,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]!==i.setupAuthLabel||t[17]!==m?(h=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[o,m]}),t[16]=i.setupAuthLabel,t[17]=m,t[18]=h):h=t[18];let g;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(g=n.mode===`auto`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthAutoHint}):null,t[19]=n.mode,t[20]=i.setupAuthAutoHint,t[21]=g):g=t[21];let _;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(_=n.mode===`oauth`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthOAuthHint}):null,t[22]=n.mode,t[23]=i.setupAuthOAuthHint,t[24]=_):_=t[24];let v;t[25]!==n.mode||t[26]!==i.setupExistingHint?(v=n.mode===`existing`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupExistingHint}):null,t[25]=n.mode,t[26]=i.setupExistingHint,t[27]=v):v=t[27];let y;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(y=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Rn,{value:n.token,onChange:e=>r({token:e}),label:i.setupTokenLabel,t:i,required:!0}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupTokenHint})]}):null,t[28]=n.mode,t[29]=n.token,t[30]=r,t[31]=i,t[32]=y):y=t[32];let b;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(b=n.mode===`apiKey`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.setupApiKeyHeader,(0,$.jsx)(`input`,{className:X(Ln,`mt-1.5`),placeholder:`x-api-key`,value:n.headerName,required:!0,onChange:e=>r({headerName:e.target.value})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupApiKeyHint}),(0,$.jsx)(Rn,{value:n.apiKey,onChange:e=>r({apiKey:e}),label:`API Key`,t:i,required:!0})]}):null,t[33]=n.apiKey,t[34]=n.headerName,t[35]=n.mode,t[36]=r,t[37]=i,t[38]=b):b=t[38];let x;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(x=n.mode===`headers`?(0,$.jsx)(Bn,{headers:n.customHeaders,onChange:e=>r({customHeaders:e}),t:i}):null,t[39]=n.customHeaders,t[40]=n.mode,t[41]=r,t[42]=i,t[43]=x):x=t[43];let S;return t[44]!==h||t[45]!==g||t[46]!==_||t[47]!==v||t[48]!==y||t[49]!==b||t[50]!==x?(S=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,g,_,v,y,b,x]}),t[44]=h,t[45]=g,t[46]=_,t[47]=v,t[48]=y,t[49]=b,t[50]=x,t[51]=S):S=t[51],S}function Hn(e){let t=(0,ft.c)(8),{label:n,children:r,hint:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{children:n}),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=i?(0,$.jsx)(`span`,{className:`block text-xs font-normal text-fg-muted`,children:i}):null,t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-sm font-medium text-fg`,children:[a,r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Un({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>It(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=Rt(e.argsText)??[]}catch{}let c=e=>n({argsText:JSON.stringify(e)});return(0,$.jsxs)(`div`,{"data-field":`commandOptions`,className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.argsLabel}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(Hn,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:Ln,value:e.argsText,onChange:e=>n({argsText:e.target.value})})}):s.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{className:Ln,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(ue,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(Bn,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(Ft(e)??{})})}})]})}function Wn(e){let t=(0,ft.c)(15),{row:n,t:r,onUpdate:i,variant:a,showOAuth:o,idReadOnly:s}=e,c=a===void 0?`all`:a,l=o!==void 0&&o,u=s!==void 0&&s,d=c!==`advanced`,f=c!==`basic`,p;t[0]!==d||t[1]!==i||t[2]!==n||t[3]!==r?(p=d?(0,$.jsxs)($.Fragment,{children:[n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:Ln,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(Un,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(Hn,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:Ln,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(Hn,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:Ln,value:n.displayName??``,placeholder:r.setupNamePlaceholder,onChange:e=>i({displayName:e.target.value})})})]}):null,t[0]=d,t[1]=i,t[2]=n,t[3]=r,t[4]=p):p=t[4];let m;t[5]!==f||t[6]!==u||t[7]!==i||t[8]!==n||t[9]!==l||t[10]!==r?(m=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:Ln,readOnly:u,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(Hn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Ln,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&l?(0,$.jsx)(Hn,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:Ln,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(Hn,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(w,{"aria-label":r.exposureLabel,className:Ln,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(T,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(Hn,{label:r.requestTimeoutLabel,children:(0,$.jsx)(dt,{allowEmpty:!0,type:`number`,min:1,className:Ln,value:n.timeout??``,placeholder:r.setupDefaultTimeout,onChange:e=>i({timeout:e.target.value?Number(e.target.value):void 0})})})]}):null,t[5]=f,t[6]=u,t[7]=i,t[8]=n,t[9]=l,t[10]=r,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==m?(h=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p,m]}),t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function Gn(e,t){let n=e;if(n?.status===429)return t.setupRateLimited;if(n?.status===401)return t.setupGatewayUnauthorized;if(n?.status===404||n?.status===409)return t.setupConflict;if(n?.status&&n.status>=500)return t.setupGatewayCheckFailed;let r={command_missing:t.setupCommandMissing,connection_refused:t.setupConnectionRefused,host_not_found:t.setupHostNotFound,timeout:t.setupTimedOut,access_denied:t.setupAccessDenied,network:t.setupServiceNetworkFailed,tls:t.setupTlsFailed,invalid_response:t.setupInvalidResponse,not_found:t.setupEndpointNotFound,rate_limited:t.setupServiceRateLimited,configuration:t.setupInvalidConfig};if(n?.errorCode&&Object.hasOwn(r,n.errorCode))return r[n.errorCode];let i=e instanceof Error?e.message:typeof e==`string`?e:n?.error??``;return/ENOENT|command not found|executable.{0,30}not found/i.test(i)?t.setupCommandMissing:/ECONNREFUSED|connection refused/i.test(i)?t.setupConnectionRefused:/ENOTFOUND|EAI_AGAIN|could not resolve/i.test(i)?t.setupHostNotFound:/timeout|timed out/i.test(i)?t.setupTimedOut:/fetch failed|failed to fetch|network error|NetworkError/i.test(i)?n?.error===void 0?t.setupGatewayNetworkFailed:t.setupServiceNetworkFailed:/\b(?:401|403)\b|unauthorized|forbidden|permission denied/i.test(i)?t.setupAccessDenied:t.setupCheckFailed}function Kn(e,t){return JSON.stringify({id:e.id,config:qt(Nn(e,t))})}function qn(e,t){try{return Kn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function Jn(e){let{t,cs:n}=e,r=(0,Q.useId)(),[i,a]=(0,Q.useState)(e.initialRow),[o,s]=(0,Q.useState)(()=>Mn(e.initialRow)),[c,l]=(0,Q.useState)(`idle`),[u,p]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(),[S,C]=(0,Q.useState)(),[E,D]=(0,Q.useState)(),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(``),[F,I]=(0,Q.useState)(``),[L,z]=(0,Q.useState)([]),[B,V]=(0,Q.useState)(`0`),[U,ee]=(0,Q.useState)(0),[W,te]=(0,Q.useState)(``),[G,ne]=(0,Q.useState)(!1),[re,ie]=(0,Q.useState)(!1),K=e.mode===`edit`,[ae,oe]=(0,Q.useState)(``),q=(0,Q.useRef)(void 0),[J]=(0,Q.useState)(()=>qn(e.initialRow,Mn(e.initialRow))),se=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),ce=(0,Q.useRef)(void 0),le=(0,Q.useRef)(void 0),ue=(0,Q.useRef)(void 0),Y=(0,Q.useRef)(null),fe=(0,Q.useRef)(``),pe=(0,Q.useRef)(!0),me=(0,Q.useRef)(null),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(null),ve=(0,Q.useRef)(e.onSaved);ve.current=e.onSaved;let ye=E?.state===`starting`||E?.state===`authorizing`,be=c!==`idle`||ye,xe=J!==qn(i,o),Se=i.extra.enabled===!1,Ce=!v&&(xe||!!N.trim());(0,Q.useEffect)(()=>(pe.current=!0,()=>{pe.current=!1,ce.current?.abort(),Y.current?.close(),q.current&&Zt(q.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!Ce)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[Ce]),(0,Q.useEffect)(()=>{if(!b)return;let e=ge.current?.querySelector(`[data-field="${b.field}"]`),t=e?.closest(`details`);t&&(t.open=!0);let n=e?.querySelector(`input,button,textarea`)??e;return n?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-describedby`,r),b.focus!==!1&&(n??_e.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[b,r]),(0,Q.useEffect)(()=>{if(!E||!ye)return;let e=new AbortController;le.current=e;let n;async function r(){try{let n=await en(q.current,e.signal);if(e.signal.aborted||(D(n),n.authorizationUrl&&fe.current!==n.authorizationUrl&&(fe.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&p(t.oauthOpenFailed):Y.current&&!Y.current.closed&&Y.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){ue.current=void 0,Y.current?.close(),C({state:`connected`,toolCount:n.toolCount}),p(``);return}if(n.state===`error`||n.state===`cancelled`){ue.current=void 0,Y.current?.close(),p(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&A(!0);return}}catch{if(e.signal.aborted)return;we(),Y.current?.close(),p(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[E?.id,ye,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function we(){ce.current?.abort(),le.current?.abort(),q.current&&Zt(q.current).catch(()=>{}),q.current=void 0,oe(``),ne(!1),C(void 0),D(void 0),p(``),x(void 0)}function Te(e){a(t=>({...t,...e})),we()}function Ee(e){s(t=>({...t,...e})),we()}function De(){c===`saving`||ye||(c===`checking`&&(we(),l(`idle`)),Ce?ie(!0):e.onClose())}function Oe(){try{z(Wt(N)),V(`0`),I(``)}catch{I(t.setupImportError),z([])}}function ke(){let t=L[Number(B)];if(!t)return;let n={...t,id:se.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...se.current?{enabled:i.extra.enabled}:{}}};a(n),s(Mn(n)),we(),ee(e=>e+1),M(!1),P(``),z([])}function Ae(e){function n(e,t){return x({field:e,message:t}),!1}if(e.transport===`streamable-http`){try{e.url=Ut(e.url)}catch{return n(`url`,t.setupAddressInvalid)}if(o.mode===`bearer`&&!o.token.trim().replace(/^Bearer\s*/i,``)||o.mode===`apiKey`&&(!o.apiKey.trim()||!o.headerName.trim()))return n(`auth`,t.setupCredentialRequired);if(Pn(e.headers)>=0)return n(`auth`,t.setupHeaderInvalid);if(o.mode===`oauth`&&e.headers.some(e=>e.key.trim().toLowerCase()===`authorization`))return n(`auth`,t.setupOAuthHeaderConflict);if(o.mode===`headers`&&!e.headers.some(e=>e.key.trim()&&(e.value.trim()||e.reference)))return n(`auth`,t.setupCredentialRequired)}else if(!e.command.trim())return n(`command`,t.setupCommandRequired);if(e.timeout!==void 0&&(!Number.isFinite(e.timeout)||e.timeout<=0))return n(`advanced`,t.setupInvalidConfig);try{qt(e)}catch(r){return n(e.transport===`stdio`?`commandOptions`:`advanced`,r instanceof Error&&r.message.startsWith(`Environment`)?t.setupEnvInvalid:t.setupInvalidConfig)}return!0}async function je(){p(``),l(`checking`),fe.current=``,window.electronAPI?.shell?.openExternalUrl||(Y.current=window.open(`about:blank`,`_blank`),Y.current&&(Y.current.opener=null));try{let e=await $t(q.current);if(!pe.current){Y.current?.close(),q.current&&Zt(q.current).catch(()=>{});return}ue.current=e.id,D(e)}catch{Y.current?.close(),pe.current&&p(t.setupAuthFailed)}finally{pe.current&&l(`idle`)}}async function Me(){let r=Nn(i,o);if(!Ae(r))return;let s=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==se.current),c=new Set([...e.managedServerIds,...s.map(e=>e.id)]);if(r.id=se.current||r.id.trim()||Ht(r,c),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...c].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){x({field:`advanced`,message:n.duplicateServerId});return}we(),l(`checking`);let u=new AbortController;ce.current=u;try{let n=await Yt(r,se.current||void 0,e.initialRow.extra,u.signal);if(!pe.current||u.signal.aborted){Zt(n.id).catch(()=>{});return}q.current=n.id,a(r),oe(qn(r,o));let i=await Xt(n.id,u.signal);if(!pe.current||u.signal.aborted)return;C(i),i.state===`error`&&p(Gn(i,t))}catch(e){pe.current&&!u.signal.aborted&&p(e.status===409?t.setupConflict:Gn(e,t))}finally{pe.current&&ce.current===u&&l(`idle`)}}async function Ne(n=!1){if(!(!q.current||S?.state!==`connected`||ae!==qn(i,o))){l(`saving`),p(``);try{let t=await Qt(q.current,n);q.current=void 0,await ve.current().catch(()=>{}),t?.reloadRequired?y(!0):e.onClose()}catch(e){let n=e.status;n===404||n===409?(we(),p(t.setupConflict)):p(t.setupSaveFailed)}finally{pe.current&&l(`idle`)}}}async function Pe(){le.current?.abort();let e=q.current;ue.current=void 0,D(void 0),Y.current?.close(),p(t.setupCancelled),l(`checking`);try{e&&await tn(e)}catch{pe.current&&(we(),p(t.setupCancelled))}finally{pe.current&&l(`idle`)}}async function Fe(){E?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(E.authorizationUrl)).ok||p(t.oauthOpenFailed):window.open(E.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Ie(){if(E)try{await nn(q.current,W),te(``),p(``)}catch{p(t.setupRedirectInvalid)}}let Le=!!q.current&&ae===qn(i,o)&&(o.mode===`oauth`||o.mode===`auto`&&S?.state===`oauth_required`)&&S?.state!==`connected`,Re=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(i.url.trim()),ze=L[Number(B)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_,{open:e.open,onOpenChange:e=>{e||De()},children:(0,$.jsxs)(m,{children:[(0,$.jsx)(d,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(h,{ref:me,tabIndex:-1,className:`fixed left-1/2 top-1/2 z-[60] flex h-[min(44rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,onOpenAutoFocus:e=>{e.preventDefault(),me.current?.focus()},children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge p-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(g,{className:`font-semibold`,children:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:c===`saving`||ye,onClick:De,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(de,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[j?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>M(!1),children:t.setupImportBack}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportEmpty}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[t.setupImport,(0,$.jsx)(`textarea`,{className:X(Ln,`mt-1.5 min-h-40 font-mono text-xs`),value:N,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{P(e.target.value),z([]),I(``)}})]}),(0,$.jsx)(Z,{variant:`secondary`,disabled:!N.trim(),onClick:Oe,children:t.setupImportPreview}),F?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:F}):null,ze?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportScope}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium`,children:[t.setupImportChoose,(0,$.jsx)(w,{"aria-label":t.setupImportChoose,className:X(Ln,`mt-1.5`),value:B,onChange:e=>V(e.target.value),children:L.map((e,t)=>(0,$.jsx)(T,{value:String(t),children:e.displayName||e.id||un(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[ze.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,un(ze)]})]}):null]}):(0,$.jsxs)(`form`,{ref:ge,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&i.url.trim())try{Ut(i.url)}catch{x({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),Me()},children:[(0,$.jsxs)(`fieldset`,{disabled:be||v,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)($e,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`stdio`].map(e=>(0,$.jsx)(Z,{type:`button`,variant:i.transport===e?`secondary`:`ghost`,"aria-pressed":i.transport===e,onClick:()=>Te({transport:e}),children:e===`stdio`?t.setupUseCommand:t.setupUseUrl},e))}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,onClick:()=>M(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Wn,{row:i,t,variant:`basic`,onUpdate:Te},`${i.transport}-${U}`)}),i.transport===`streamable-http`?(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(Vn,{allowExisting:!!i.extra.auth||i.headers.some(e=>!!e.reference),draft:o,onChange:Ee,t})}):null,b?(0,$.jsx)(`p`,{id:r,ref:_e,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:b.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:k,onToggle:e=>A(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupAdvanced}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Wn,{row:i,t,variant:`advanced`,idReadOnly:K,showOAuth:o.mode===`oauth`,onUpdate:Te}),i.transport===`streamable-http`&&o.mode!==`headers`&&o.mode!==`existing`?(0,$.jsx)(Bn,{additional:!0,headers:o.additionalHeaders,onChange:e=>Ee({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i.transport===`stdio`?t.setupCommandHostHint:Re?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),v?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!j&&!v?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[c===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(H,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),c===`saving`?t.setupSaving:t.setupChecking]}),c===`idle`&&K&&!xe&&!S&&!u&&!ye?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:Se?t.setupDisabled:e.lastCheck?t.setupLastCheck.replace(`{{count}}`,String(e.lastCheck.toolCount)):t.setupSavedUnchecked}):null,S?.state===`connected`?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(O,{className:`size-4 shrink-0`,"aria-hidden":!0}),S.toolCount?t.setupConnected.replace(`{{count}}`,String(S.toolCount)):t.setupZeroTools]}),(0,$.jsx)(Z,{ref:he,variant:`secondary`,onClick:()=>ne(!0),children:t.viewTools})]}):null,S?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,S?.state===`oauth_required`&&!ye?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,ye?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(H,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[E?.authorizationUrl?(0,$.jsxs)(Z,{variant:`secondary`,onClick:()=>void Fe(),children:[(0,$.jsx)(R,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void Pe(),children:t.setupCancelAuth})]}),E?.acceptsRedirect?(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:t.setupRemoteFallback}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.setupRedirectHint}),(0,$.jsxs)(`label`,{className:`mt-2 block text-sm`,children:[t.setupRedirectLabel,(0,$.jsx)(`input`,{className:Ln,value:W,onChange:e=>te(e.target.value)})]}),(0,$.jsx)(Z,{className:`mt-2`,disabled:!W.trim(),onClick:()=>void Ie(),children:t.setupContinue})]}):null]}):null,u?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:u}),u!==t.setupSaveFailed&&c!==`saving`?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:t.setupTestFailure}):null]}):null]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(Z,{variant:`secondary`,disabled:c===`saving`||ye,onClick:De,children:K||v?t.setupClose:n.modalCancel}),v?null:j?(0,$.jsx)(Z,{variant:`primary`,disabled:!ze,onClick:ke,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{variant:S?.state===`connected`?`secondary`:`primary`,disabled:be,onClick:()=>Le?void je():void Me(),children:Le?t.setupSignIn:t.setupTestConnection}),S?.state===`connected`&&ae===qn(i,o)?(0,$.jsxs)($.Fragment,{children:[Se?(0,$.jsx)(Z,{variant:`secondary`,disabled:be,onClick:()=>void Ne(!0),children:t.setupEnableSave}):null,(0,$.jsx)(Z,{variant:`primary`,disabled:be,"aria-busy":be,onClick:()=>void Ne(),children:K?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(et,{open:re,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>ie(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),G?(0,$.jsx)(sn,{draftId:q.current,serverId:i.id,displayName:i.displayName,returnFocusTo:he.current,t,onClose:()=>ne(!1)}):null]})}var Yn=`recommended`,Xn=`builtin`,Zn=`composio`,Qn=`xopc-store`;function $n(e,t=`en`){return e==="default"&&t.startsWith(`zh`)?Yn:Xn}function er(e,t){let n=e.connectorManifest;if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n;if(r.contractVersion!==1||r.id!==e.name)return null;let i=r.runtime,a=r.auth;if(!i||typeof i!=`object`||Array.isArray(i)||!a||typeof a!=`object`||Array.isArray(a))return null;let o=i,s=a;if(o.type!==`mcp`||typeof o.serverId!=`string`)return null;let c=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(r.category??``))?r.category:`custom`,l=s.mode===`oauth`?{mode:`oauth`,...typeof s.clientId==`string`?{clientId:s.clientId}:{}}:s.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`},u=e.localizations?.[t===`zh`?`zh-CN`:`en`];return{id:e.name,version:e.latestVersion??`store`,displayName:u?.displayName??(typeof r.displayName==`string`?r.displayName:e.name),description:u?.description??(typeof r.description==`string`?r.description:e.description),category:c,kind:`mcp`,source:`store`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},capabilities:Array.isArray(r.capabilities)?r.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(r.tags)?r.tags.filter(e=>typeof e==`string`):[`store`],auth:l,setup:r.setup&&typeof r.setup==`object`&&!Array.isArray(r.setup)?r.setup:{},runtime:{type:`mcp`,serverId:o.serverId}}}function tr(e){return v(e.map(e=>({connector:e,service:{id:e.id,source:e.source===`builtin`?`builtin-connector`:e.source===`store`?`store-connector`:`registry-connector`}})),`en`).map(e=>e.connector)}function nr(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function rr({embedded:e=!1,onHeaderActionChange:t}){let n=pe().filter(pn),r=c(e=>e.language),o=u(r),l=o.connectorsSettings,d=o.mcpSettings,f=s(e=>e.conversationId),p=!!f,m=a(),[h,g]=i(),_=h.get(`understanding`)===`1`,v=nr(h.get(`returnTo`)),S=!!h.get(`returnTo`)&&!_,C=h.get(`tab`),[w,T]=(0,Q.useState)(!_&&C===`connected`?`connected`:`discover`),{data:D}=me(p&&w===`discover`&&!_?[`service-recommendations`,r]:null,()=>y(r),{revalidateOnFocus:!1}),O=(0,Q.useMemo)(()=>new Set(D?.items.filter(e=>e.service?.source===`store-plugin`).map(e=>b(e.id))??[]),[D]),k=(0,Q.useRef)(!1),[A,F]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[I,L]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(!1),[B,V]=(0,Q.useState)(1),[U,ee]=(0,Q.useState)(void 0),[W,te]=(0,Q.useState)(``),[G,ne]=(0,Q.useState)(_||S?h.get(`connector`)??``:``),[K,ae]=(0,Q.useState)($n(_?`understanding`:`default`,r)),[oe,q]=(0,Q.useState)(`name`),[J,se]=(0,Q.useState)(_?`understand`:`all`),[ce,le]=(0,Q.useState)(null),[ue,Y]=(0,Q.useState)(null),[de,fe]=(0,Q.useState)(null),[he,_e]=(0,Q.useState)(null),[ve,ye]=(0,Q.useState)(null),[be,xe]=(0,Q.useState)(null),{data:Se,mutate:Ce}=ge(p),we=Se?.payload?.config,Te=(0,Q.useMemo)(()=>we===void 0?null:Kt(we),[we]),Ee=Te?.servers??[],De=A.instances.length+Ee.length+n.length,[Oe,ke]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(ke({}),!p||!we)return;let e=new AbortController;return an(e.signal).then(t=>{e.signal.aborted||ke(t)}).catch(()=>{}),()=>e.abort()},[p,we]);let Ae=(0,Q.useCallback)(async()=>{if(!f){F({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}F(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Pe(),je()]);F(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){F({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[f]);(0,Q.useEffect)(()=>{Ae()},[Ae]),(0,Q.useEffect)(()=>{k.current||A.loading||p&&!Te||(T(_?`discover`:De>0?`connected`:`discover`),k.current=!0)},[p,De,Te,_,A.loading]),(0,Q.useEffect)(()=>{ae(e=>e===`builtin`||e===`recommended`?$n(_?`understanding`:`default`,r):e)},[r,_]);let Me=(0,Q.useCallback)(e=>{k.current=!0,T(e)},[]),Ne=(0,Q.useMemo)(()=>[{id:Zn,displayName:l.composioSourceName},{id:Qn,displayName:l.storeSourceName}],[l.composioSourceName,l.storeSourceName]),Fe=(0,Q.useCallback)(async e=>{if(!p||K===`builtin`||K===`recommended`){F(e=>({...e,registryCatalog:[]})),V(1),ee(void 0);return}let t=G.trim(),n=Math.max(e?.page??1,1),i=e?.append??!1,a=K===`all`?Ne:Ne.filter(e=>e.id===K);if(a.length!==0){L(!0),i?F(e=>({...e,error:null})):(V(1),ee(void 0),F(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(a.map(async e=>{if(e.id===`composio`){let e=await Ve({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let i=await ze({q:t||void 0,page:n,pageSize:24,sort:oe===`source`?`newest`:`downloads`});return{connectors:i.items.flatMap(e=>{let t=er(e,r);return t?[t]:[]}),totalPages:i.meta.totalPages}})),o=tr(e.flatMap(e=>e.connectors)),s=Math.max(1,...e.map(e=>e.totalPages??1));V(n),ee(s),F(e=>({...e,registryCatalog:i?tr([...e.registryCatalog,...o]):o}))}catch(e){F(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{L(!1)}}},[oe,G,K,p,Ne,r]);(0,Q.useEffect)(()=>{if(w!==`discover`||A.loading)return;if(K===`builtin`||K===`recommended`){F(e=>({...e,registryCatalog:[]})),V(1),ee(void 0);return}let e=window.setTimeout(()=>{Fe()},G.trim()?350:0);return()=>window.clearTimeout(e)},[G,K,Fe,A.loading,w]);let Ie=(0,Q.useMemo)(()=>new Set(A.instances.map(e=>e.connectorId)),[A.instances]),Le=(0,Q.useMemo)(()=>new Map([...A.catalog,...A.registryCatalog].map(e=>[e.id,e])),[A.catalog,A.registryCatalog]);(0,Q.useEffect)(()=>{if(A.loading)return;let e=h.get(`connector`),t=h.get(`instance`);if(!e&&!t)return;let n=A.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)k.current=!0,te(``),fe(n.instanceId),_e(n),T(`connected`);else if(e){let t=Le.get(e);if(!t)return;k.current=!0,ae($n(_?`understanding`:`default`,r)),ne(``),Y(t),T(`discover`)}let i=new URLSearchParams(h);i.delete(`connector`),i.delete(`instance`),i.set(`tab`,n?`connected`:`discover`),g(i,{replace:!0})},[Le,_,r,h,g,A.instances,A.loading]);let Re=(0,Q.useCallback)(async e=>{z(!0),F(e=>({...e,error:null}));try{let t=await He(e);le(re(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){F(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{z(!1)}},[]);(0,Q.useEffect)(()=>{let e=h.get(`storeConnector`);if(!p||!e)return;let t=new URLSearchParams(h);t.delete(`storeConnector`),g(t,{replace:!0}),Re(e)},[p,h,g,Re]);let Be=(0,Q.useMemo)(()=>new Set(A.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[A.instances]),Ue=(0,Q.useCallback)(async e=>{let t=await on(e);await Ce(),await Ae(),t.reloadRequired&&F(e=>({...e,error:d.setupReloadRequired}))},[Ae,Ce,d.setupReloadRequired]),We=(0,Q.useCallback)(()=>{xe({mode:`add`,row:jn(Ee,Be)})},[Ee,Be]),Ge=Qe(e=>e.setPageHeader),Ke=Qe(e=>e.clearPageHeader),qe=(0,Q.useMemo)(()=>({searchLabel:w===`connected`?l.connectedSearchPlaceholder:l.discoverSearchPlaceholder,search:(0,$.jsx)(ct,{value:w===`connected`?W:G,onChange:w===`connected`?te:ne,placeholder:w===`connected`?l.connectedSearchPlaceholder:l.discoverSearchPlaceholder}),secondary:(0,$.jsx)(jt,{onRefresh:w===`connected`&&p?Ae:void 0,refreshing:A.loading,refreshLabel:l.refreshConnections,onBrowseCatalog:()=>Me(`discover`),onAddCustomServer:We,addLabel:l.addConnection,browseLabel:l.addFromCatalog,customLabel:l.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[W,l,G,p,r,Ae,o.capabilitiesHub.moreActions,We,Me,A.loading,w]);(0,Q.useLayoutEffect)(()=>e?(t?.(qe),()=>t?.(null)):(Ge({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:l.title})}),end:(0,$.jsx)(lt,{contribution:qe})}),()=>Ke()),[Ke,l.title,e,qe,t,Ge]);let Je=(0,Q.useMemo)(()=>A.instances.map(e=>({instance:e,value:Ct(e,Le.get(e.connectorId))})),[Le,A.instances]),Ye=(0,Q.useMemo)(()=>new Map(Je.map(({instance:e,value:t})=>[e.instanceId,t])),[Je]),Xe=(0,Q.useMemo)(()=>A.instances.filter(e=>N(e,W)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ye.get(e.instanceId)?.state??`checking`,i=Ye.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[W,Ye,A.instances]),et=(0,Q.useMemo)(()=>Xe.filter(e=>Ye.get(e.instanceId)?.state===`needs_setup`),[Ye,Xe]),tt=(0,Q.useMemo)(()=>Xe.filter(e=>Ye.get(e.instanceId)?.state!==`needs_setup`),[Ye,Xe]),nt=(0,Q.useMemo)(()=>Ee.filter(e=>P(e,W)),[W,Ee]),rt=(0,Q.useMemo)(()=>{let e=W.trim().toLowerCase();return n.filter(t=>[t.name,t.description,...(t.setup?.authorizations??[]).map(e=>e.title),...(t.components?.mcp??[]).map(e=>e.name)].filter(Boolean).join(` `).toLowerCase().includes(e))},[W,n]),it=Xe.length+nt.length+rt.length,at=(0,Q.useMemo)(()=>A.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&j(e)),[A.catalog]),st=(0,Q.useMemo)(()=>K===`recommended`?[]:K===`builtin`?at:K===`all`?tr([...at,...A.registryCatalog]):A.registryCatalog,[at,K,A.registryCatalog]),ut=(0,Q.useMemo)(()=>{let e=_?st.filter(e=>e.understanding?.mode===`activity`):tr(st).filter(e=>!O.has(b(e.id)));return M(J===`all`?e:e.filter(e=>xt(e).includes(J)),G,oe)},[oe,G,st,_,J,O]),dt=(0,Q.useMemo)(()=>bt.filter(e=>st.some(t=>xt(t).includes(e))),[st]);(0,Q.useEffect)(()=>{J!==`all`&&!dt.includes(J)&&se(`all`)},[dt,J]);let ft=w===`discover`&&K!==`builtin`&&!!(U&&B<U),mt=(0,Q.useMemo)(()=>A.instances.find(e=>e.instanceId===de)??he,[de,he,A.instances]),_t=(0,Q.useMemo)(()=>[{value:Yn,label:r===`zh`?`推荐服务`:`Recommended services`},{value:`all`,label:l.discoverSourceAll},{value:Xn,label:l.discoverSourceBuiltin},...Ne.map(e=>({value:e.id,label:e.displayName}))],[l.discoverSourceAll,l.discoverSourceBuiltin,Ne,r]),St=[{id:`connected`,label:l.tabConnected,count:De},{id:`discover`,label:l.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:X(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,e?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`),children:[p?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:l.tokenHint}),_?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:l.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:l.understandingSetupHint})]}),(0,$.jsx)(Z,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>m(v),children:l.understandingSetupDone})]}):null,S?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:l.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:l.recoverySetupHint})]}),(0,$.jsx)(Z,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>m(v),children:l.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(Ze,{items:St,activeTab:w,onChange:Me,ariaLabel:l.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),A.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:A.error}):null,w===`connected`&&p?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:A.loading?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":l.loading,children:ht.slice(0,3).map(e=>(0,$.jsx)(yt,{},e))}):De===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.connectionsEmpty}),(0,$.jsx)(Z,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Me(`discover`),children:l.addFromCatalog})]}):it===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:l.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[et.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:et.length})]}),(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:et.map(e=>(0,$.jsx)(An,{instance:e,definition:Le.get(e.connectorId),highlighted:e.instanceId===ve,onOpenDetails:e=>{ye(null),fe(e.instanceId),_e(e)},t:l},e.instanceId))})]}):null,tt.length||rt.length?(0,$.jsx)(`section`,{children:(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[tt.map(e=>(0,$.jsx)(An,{instance:e,definition:Le.get(e.connectorId),highlighted:e.instanceId===ve,onOpenDetails:e=>{ye(null),fe(e.instanceId),_e(e)},t:l},e.instanceId)),rt.map(e=>(0,$.jsx)(mn,{extension:e,language:r,onOpen:()=>m(ot(e.pluginId,`connections`,e.authorizationStatus===`required`))},e.id))]})}):null,nt.length||!W.trim()?(0,$.jsx)(fn,{servers:nt,lastChecks:Oe,t:d,cs:l,onAdd:We,onEdit:e=>xe({mode:`edit`,row:structuredClone(e)}),onRemove:Ue}):null]})}):null,w===`discover`&&p?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[_?null:(0,$.jsx)($e,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":l.taskFilterAria,indicatorClassName:`rounded-lg bg-surface-active`,children:[`all`,...dt].map(e=>(0,$.jsx)(`button`,{type:`button`,className:X(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,J===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":J===e,onClick:()=>se(e),children:e===`all`?l.taskAll:l.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:X(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,_?`grid-cols-1`:`grid-cols-2`),children:[_?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(E,{value:K,options:_t,placeholder:l.discoverSourceAll,allowEmpty:!1,ariaLabel:l.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ae})}),K===`recommended`?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(E,{value:oe,options:[{value:`name`,label:l.sortName},{value:`source`,label:l.sortSource}],placeholder:l.sortName,allowEmpty:!1,ariaLabel:l.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>q(e)})})]})]}),K===`recommended`?(0,$.jsx)(x,{layout:`cards`,initialCount:6,query:G,onChanged:async()=>{await Ae(),await Ce()}}):(A.loading||I)&&ut.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":l.loading,children:ht.map(e=>(0,$.jsx)(vt,{},e))}):ut.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:l.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[I?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":l.loading,children:(0,$.jsx)(H,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:ut.map(e=>(0,$.jsx)(pt,{connector:e,installed:Ie.has(e.id)||gt(e,A.instances),onInstall:e=>{if(e.source===`store`){Re(e.id);return}le(re(e))},onOpenDetails:e.source===`store`?void 0:Y,t:l},e.id))}),ft?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,disabled:I||R,onClick:()=>void Fe({page:B+1,append:!0}),children:[I?(0,$.jsx)(H,{className:`size-4 animate-spin`}):null,l.loadMore]})}):null]})]}):null]}),ce?(0,$.jsx)(ie,{draft:ce,onChange:le,onClose:()=>le(null),t:l,onInstalled:async e=>{await Ae(),await Ce(),ye(e.instanceId),Me(`connected`)}}):null,ue?(0,$.jsx)(Dt,{connector:ue,installed:Ie.has(ue.id)||gt(ue,A.instances),onClose:()=>Y(null),onInstall:e=>le(re(e)),t:l}):null,mt?(0,$.jsx)(kn,{instance:mt,definition:Le.get(mt.connectorId),onClose:()=>{fe(null),_e(null)},onChanged:Ae,t:l,mcp:d}):null,be?(0,$.jsx)(Jn,{open:!0,mode:be.mode,initialRow:be.row,lastCheck:be.mode===`edit`?Oe[be.row.id]:void 0,existingCustomServers:Ee,config:we,managedServerIds:Be,t:d,cs:l,onClose:()=>xe(null),onSaved:async()=>{await Ce(),await Ae(),Me(`connected`)}},`${be.mode}-${be.row.clientKey}`):null]})})}export{rr as ConnectorsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as e}from"./locale-store-Br7IfbXK.js";var t=e(()=>({connectionState:`idle`,error:null}));function n(e){t.setState(e)}export{t as n,n as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workspace-file-preview-dialog-NRL3YRjg.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/locale-store-Br7IfbXK.js","assets/messages-ByFlEbsu.js","assets/use-file-preview-expanded-CYgWzDnv.js","assets/preload-helper-Czpn1I53.js","assets/chunk-KS7C4IRE-CiwuuyV8.js","assets/createLucideIcon-DPHK1VkS.js","assets/app-window-DXFNqt_0.js","assets/check-DUBLcKHA.js","assets/chevron-down-ccbiQQz_.js","assets/copy-Dv6d4Dvw.js","assets/download-Dk-ZjtO6.js","assets/ellipsis-0k4rZLoy.js","assets/external-link-DjqjBmc3.js","assets/eye-CABVeTq0.js","assets/folder-open-CyzJ19I9.js","assets/link-2-D_ZKYUW7.js","assets/loader-circle-CifKLtgG.js","assets/markdown-view-Ck5s16p9.js","assets/dist-BGTk37IG.js","assets/es2015-DBLcMg5B.js","assets/dist-CxGUk8J-.js","assets/file-image-CDUPkZvG.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/app-link-DRy3-k7j.js","assets/product-delivery-DRyD9_Xq.js","assets/schemas-CCWMleym.js","assets/local-apps-Ck6kACsY.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/xml-_d7dTN2Q.js","assets/mermaid-render-oOellPHt.js","assets/markdown-view-C-DHb3Io.css","assets/message-square-plus-XP0tGdlV.js","assets/minimize-2-DtOGrlpo.js","assets/paperclip-f1HujQY1.js","assets/pencil-DmIY3Oa-.js","assets/refresh-cw-BRlGaq2w.js","assets/rotate-cw-LIg3Am9S.js","assets/save-DRDABU--.js","assets/search-DA7gz22f.js","assets/skeleton-BI5TyibZ.js","assets/constants-DBtMsXdW.js","assets/session-api-Bs3r_d2_.js","assets/gateway-startup-retry-CvkJYurV.js","assets/attachment-utils-core-BIOUBrpT.js","assets/interaction-BdhHBbYa.js","assets/activity-store-D_DXNHba.js","assets/app-chrome-BeB4KgOf.js","assets/electron-env-DHOGevH3.js","assets/use-async-resource-BHFGZCY2.js","assets/sliding-tab-list-DuQyViqe.js","assets/sliding-indicator-hwz0sx3h.js","assets/index.module-Cd9ENXfk.js","assets/workspace-api-BdB4NEOh.js","assets/files-BNL4kkSB.js","assets/dist-ZrL34Ps4.js","assets/dist-BuHnPloF.js","assets/floating-ui.dom-seOukHzT.js","assets/share-link-dialog-DA0QuFOD.js","assets/popover-select-CEMWIrtY.js","assets/dist-GJ8-1PAx.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/globe-DSSGFWFn.js","assets/button-Cc4hUNTt.js","assets/copy-text-row-CpiRzq4G.js","assets/file-preview-surface-DfkXvFnc.js","assets/phone-workspace-store-SN7hfddU.js","assets/shares-api-D8Q-m46d.js","assets/theme-store-Dlnmgryi.js","assets/middleware-Pd0e8Igk.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{l as a,m as o,t as s,u as c}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as l}from"./locale-store-Br7IfbXK.js";import{t as u}from"./messages-ByFlEbsu.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-BGTk37IG.js";import{t as v}from"./calendar-clock-D-quYVPe.js";import{t as y}from"./chevron-down-ccbiQQz_.js";import{t as b}from"./chevron-right-BweFrslA.js";import{t as x}from"./circle-alert-BEjgurr2.js";import{t as S}from"./circle-check-C23XjkUj.js";import{t as C}from"./clock-3-DnrAnuyZ.js";import{t as w}from"./external-link-DjqjBmc3.js";import{t as T}from"./history-DXH_9jsE.js";import{F as E,M as D}from"./markdown-view-Ck5s16p9.js";import{t as O}from"./message-circle-Badhj-4D.js";import{t as k}from"./paperclip-f1HujQY1.js";import{t as A}from"./plus-Q2yW6OE7.js";import{t as j}from"./refresh-cw-BRlGaq2w.js";import{t as M}from"./settings-2-D-csvaET.js";import{t as N}from"./sparkles-DHlfQFAF.js";import{t as P}from"./x-B_N4OPjy.js";import{t as F}from"./cn-0WouolD0.js";import{t as I}from"./skeleton-BI5TyibZ.js";import{s as L}from"./tasks-DRmd6sWt.js";import{C as R,E as z,S as B,_ as V,a as H,b as U,f as W,g as G,l as K,n as q,t as J,u as ee,v as te,w as ne,x as re}from"./use-composer-attachments-DYY3Yz4a.js";import{t as Y}from"./button-Cc4hUNTt.js";import{a as ie,i as ae,o as oe,s as se}from"./dist-GJ8-1PAx.js";import{a as ce,c as le,d as ue,h as de,i as fe,o as pe,r as me,t as he}from"./composer-payload-handoff-BQXlFKf4.js";import{t as ge}from"./page-header-store-Du44NIEJ.js";import{t as _e}from"./sliding-tab-list-DuQyViqe.js";import{n as ve,r as ye}from"./voice-input-shortcut-events-DFMNIyy4.js";import{n as be}from"./date-formatters-DukWSVwc.js";import{n as xe}from"./tab-completion-input-CxtEp0aP.js";import{n as Se,r as X,t as Ce}from"./task-result-evidence-DKygspo2.js";var Z=n(),Q=e(t(),1);function we(e,t,n=!1){let[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!0),[s,c]=(0,Q.useState)(null),l=(0,Q.useRef)(0),u=(0,Q.useCallback)(async()=>{let t=++l.current;c(null);try{let r=await(n?G(e,!0):G(e));t===l.current&&i(r)}catch(e){t===l.current&&c(e instanceof Error?e.message:String(e))}finally{t===l.current&&o(!1)}},[e,n]);return(0,Q.useEffect)(()=>(u(),()=>{l.current++}),[u,t]),(0,Q.useEffect)(()=>{let e,t=1/0,n=n=>{let r=Date.now()+n;r>=t||(window.clearTimeout(e),t=r,e=window.setTimeout(()=>{e=void 0,t=1/0,u()},n))},r=()=>n(100),i=()=>n(750),a=()=>{document.visibilityState===`visible`&&r()},o=[`task-changed-v2`,`task-updated`,`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`home-advisor-updated`,`gateway-realtime-connected`,`realtime-gap`,`focus`],s=[`session-updated`,`session-transcript-updated`];return o.forEach(e=>window.addEventListener(e,r)),s.forEach(e=>window.addEventListener(e,i)),document.addEventListener(`visibilitychange`,a),()=>{o.forEach(e=>window.removeEventListener(e,r)),s.forEach(e=>window.removeEventListener(e,i)),document.removeEventListener(`visibilitychange`,a),window.clearTimeout(e)}},[u]),{home:r,loading:a,loadError:s,setLoadError:c,load:u}}var $=r(),Te=12e3;function Ee(e){let t=(0,Z.c)(107),{variant:n,inputId:r,inputRef:i,intent:a,labels:o,attachments:s,isDragging:c,attachmentBusy:l,attachmentsFull:u,voice:d,chat:f,cancelAction:p,onIntentChange:m,onPickFiles:h,onRemoveAttachment:g,onPaste:_,onDragOver:v,onDragLeave:y,onDrop:b,onSubmit:x}=e,S=n===`inline`,C;t[0]!==s||t[1]!==a?(C=!!a.trim()||s.length>0,t[0]=s,t[1]=a,t[2]=C):C=t[2];let w=C,T=d.voiceActive&&d.phase!==`error`,E;t[3]!==x||t[4]!==d.voiceActive?(E=e=>{if(d.voiceActive){e.preventDefault();return}x(e)},t[3]=x,t[4]=d.voiceActive,t[5]=E):E=t[5];let D=S?`mx-auto mt-6 w-full overflow-hidden rounded-xl border border-edge bg-surface-base p-2 text-left shadow-surface transition-colors focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/15 sm:mt-8`:`flex min-h-0 flex-1 flex-col`,O;t[6]===D?O=t[7]:(O=F(`relative`,D),t[6]=D,t[7]=O);let A;t[8]!==S||t[9]!==c||t[10]!==o.dropFiles?(A=c?(0,$.jsx)(`div`,{className:F(`pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-accent-soft/90 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,S&&`rounded-2xl`),children:o.dropFiles}):null,t[8]=S,t[9]=c,t[10]=o.dropFiles,t[11]=A):A=t[11];let j=!S&&`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,M;t[12]===j?M=t[13]:(M=F(j),t[12]=j,t[13]=M);let P=S?`sr-only`:`mb-2 shrink-0 text-sm font-medium text-fg`,I;t[14]!==r||t[15]!==o.intentLabel||t[16]!==P?(I=(0,$.jsx)(`label`,{htmlFor:r,className:P,children:o.intentLabel}),t[14]=r,t[15]=o.intentLabel,t[16]=P,t[17]=I):I=t[17];let L;t[18]!==l||t[19]!==f||t[20]!==d.audioLevel||t[21]!==d.cancelVoiceInput||t[22]!==d.confirmVoiceInput||t[23]!==d.elapsedLabel||t[24]!==d.error||t[25]!==d.finalTranscript||t[26]!==d.partialTranscript||t[27]!==d.phase||t[28]!==d.recordedDictation||t[29]!==d.retryVoiceInput||t[30]!==d.settingsRequired||t[31]!==d.voiceActive?(L=d.voiceActive?(0,$.jsx)(me,{phase:d.phase,elapsedLabel:d.elapsedLabel,recordedDictation:d.recordedDictation,audioLevel:d.audioLevel,partialTranscript:d.partialTranscript,finalTranscript:d.finalTranscript,error:d.error,settingsRequired:d.settingsRequired,disabled:l,chat:f,onCancel:d.cancelVoiceInput,onConfirm:d.confirmVoiceInput,onRetry:d.retryVoiceInput}):null,t[18]=l,t[19]=f,t[20]=d.audioLevel,t[21]=d.cancelVoiceInput,t[22]=d.confirmVoiceInput,t[23]=d.elapsedLabel,t[24]=d.error,t[25]=d.finalTranscript,t[26]=d.partialTranscript,t[27]=d.phase,t[28]=d.recordedDictation,t[29]=d.retryVoiceInput,t[30]=d.settingsRequired,t[31]=d.voiceActive,t[32]=L):L=t[32];let R=T&&`hidden`,z=S?`min-h-24 bg-transparent px-3 py-2`:`min-h-32 flex-1 rounded-xl border border-edge bg-surface-base p-3 focus:border-accent focus:ring-2 focus:ring-accent/20`,B;t[33]!==R||t[34]!==z?(B=F(`w-full resize-none text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle`,R,z),t[33]=R,t[34]=z,t[35]=B):B=t[35];let V;t[36]===m?V=t[37]:(V=e=>m(e.target.value),t[36]=m,t[37]=V);let H=!S,U;t[38]!==r||t[39]!==i||t[40]!==a||t[41]!==o.intentPlaceholder||t[42]!==o.intentSuggestion||t[43]!==m||t[44]!==_||t[45]!==B||t[46]!==V||t[47]!==H?(U=(0,$.jsx)(xe,{ref:i,id:r,className:B,value:a,onChange:V,onPaste:_,suggestion:o.intentSuggestion,onAcceptSuggestion:m,onKeyDown:De,placeholder:o.intentPlaceholder,maxLength:Te,autoFocus:H}),t[38]=r,t[39]=i,t[40]=a,t[41]=o.intentPlaceholder,t[42]=o.intentSuggestion,t[43]=m,t[44]=_,t[45]=B,t[46]=V,t[47]=H,t[48]=U):U=t[48];let W=S?`border-b-0 bg-transparent px-3 pb-2 pt-0`:`mt-3 border-b-0 bg-transparent px-0 pb-0`,G;t[49]!==s||t[50]!==g||t[51]!==W?(G=(0,$.jsx)(q,{attachments:s,topPadded:!1,onRemove:g,className:W}),t[49]=s,t[50]=g,t[51]=W,t[52]=G):G=t[52];let K;t[53]!==S||t[54]!==a.length||t[55]!==o.shortcut?(K=S?null:(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,$.jsx)(`span`,{children:o.shortcut}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[a.length.toLocaleString(),` / `,Te.toLocaleString()]})]}),t[53]=S,t[54]=a.length,t[55]=o.shortcut,t[56]=K):K=t[56];let J;t[57]!==L||t[58]!==U||t[59]!==G||t[60]!==K||t[61]!==M||t[62]!==I?(J=(0,$.jsxs)(`div`,{className:M,children:[I,L,U,G,K]}),t[57]=L,t[58]=U,t[59]=G,t[60]=K,t[61]=M,t[62]=I,t[63]=J):J=t[63];let ee=S?`border-edge-subtle px-1 pt-2`:`border-edge px-5 py-4`,te;t[64]===ee?te=t[65]:(te=F(`flex shrink-0 items-center gap-2 border-t`,ee),t[64]=ee,t[65]=te);let ne=!S&&`mr-auto`,re;t[66]===ne?re=t[67]:(re=F(`flex items-center gap-1`,ne),t[66]=ne,t[67]=re);let ie=l||u,ae;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(k,{className:`size-4`,"aria-hidden":!0}),t[68]=ae):ae=t[68];let oe;t[69]!==o.attachTitle||t[70]!==h||t[71]!==ie?(oe=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-9 rounded-lg p-0`,disabled:ie,title:o.attachTitle,"aria-label":o.attachTitle,onClick:h,children:ae}),t[69]=o.attachTitle,t[70]=h,t[71]=ie,t[72]=oe):oe=t[72];let se;t[73]!==l||t[74]!==f||t[75]!==d.startVoiceInput||t[76]!==d.voiceActive?(se=d.voiceActive?null:(0,$.jsx)(ce,{disabled:l,chat:f,onStart:d.startVoiceInput}),t[73]=l,t[74]=f,t[75]=d.startVoiceInput,t[76]=d.voiceActive,t[77]=se):se=t[77];let le;t[78]!==re||t[79]!==oe||t[80]!==se?(le=(0,$.jsxs)(`div`,{className:re,children:[oe,se]}),t[78]=re,t[79]=oe,t[80]=se,t[81]=le):le=t[81];let ue;t[82]!==p||t[83]!==S||t[84]!==o.shortcut?(ue=S?(0,$.jsx)(`span`,{className:`hidden text-[11px] text-fg-subtle sm:inline`,children:o.shortcut}):p,t[82]=p,t[83]=S,t[84]=o.shortcut,t[85]=ue):ue=t[85];let de=S?`ml-auto h-9 rounded-lg px-3.5 text-xs`:`min-w-32`,fe=!w||l||d.voiceActive,pe=S?`size-3.5`:`size-4`,he;t[86]===pe?he=t[87]:(he=(0,$.jsx)(N,{className:pe,"aria-hidden":!0}),t[86]=pe,t[87]=he);let ge;t[88]!==o.submit||t[89]!==de||t[90]!==fe||t[91]!==he?(ge=(0,$.jsxs)(Y,{type:`submit`,variant:`primary`,className:de,disabled:fe,children:[he,o.submit]}),t[88]=o.submit,t[89]=de,t[90]=fe,t[91]=he,t[92]=ge):ge=t[92];let _e;t[93]!==te||t[94]!==le||t[95]!==ue||t[96]!==ge?(_e=(0,$.jsxs)(`div`,{className:te,children:[le,ue,ge]}),t[93]=te,t[94]=le,t[95]=ue,t[96]=ge,t[97]=_e):_e=t[97];let ve;return t[98]!==y||t[99]!==v||t[100]!==b||t[101]!==E||t[102]!==J||t[103]!==_e||t[104]!==O||t[105]!==A?(ve=(0,$.jsxs)(`form`,{onSubmit:E,onDragOver:v,onDragLeave:y,onDrop:b,className:O,children:[A,J,_e]}),t[98]=y,t[99]=v,t[100]=b,t[101]=E,t[102]=J,t[103]=_e,t[104]=O,t[105]=A,t[106]=ve):ve=t[106],ve}function De(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}function Oe(e){let t=(0,Z.c)(12),{href:n,children:r,onOpen:i}=e,o=a();if(n&&/^https?:\/\//i.test(n)){let e;return t[0]!==r||t[1]!==n?(e=(0,$.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`rounded-sm text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r}),t[0]=r,t[1]=n,t[2]=e):e=t[2],e}if(n?.startsWith(`/`)&&!n.startsWith(`//`)){let e=`${o.pathname}${o.search}`,a;t[3]!==n||t[4]!==e?(a=D(e,n),t[3]=n,t[4]=e,t[5]=a):a=t[5];let c;return t[6]!==r||t[7]!==i||t[8]!==a?(c=(0,$.jsx)(s,{to:a,className:`rounded-sm text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:i,children:r}),t[6]=r,t[7]=i,t[8]=a,t[9]=c):c=t[9],c}let c;return t[10]===r?c=t[11]:(c=(0,$.jsx)(`span`,{children:r}),t[10]=r,t[11]=c),c}function ke(e){let t=(0,Z.c)(4),{label:n,onClick:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),t[0]=i):i=t[0];let a;return t[1]!==n||t[2]!==r?(a=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-9 items-center gap-1.5 rounded-lg px-2 text-xs font-medium text-fg-muted transition-colors duration-150 hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:r,children:[i,n]}),t[1]=n,t[2]=r,t[3]=a):a=t[3],a}function Ae(e){let t=(0,Z.c)(65),{opportunity:n,copy:r,onOpenHistory:i}=e,a,o,s,c,l,u;if(t[0]!==r.aiLabel||t[1]!==r.automationAction||t[2]!==r.automationHint||t[3]!==r.history||t[4]!==r.minutes||t[5]!==r.needsSetup||t[6]!==r.why||t[7]!==i||t[8]!==n.capabilities||t[9]!==n.continuation||t[10]!==n.estimatedMinutes||t[11]!==n.outcome||t[12]!==n.rationale||t[13]!==n.title){let e=n.capabilities.filter(Me),d;t[20]===r.aiLabel?d=t[21]:(d=(0,$.jsx)(`span`,{children:r.aiLabel}),t[20]=r.aiLabel,t[21]=d);let f;t[22]!==r.minutes||t[23]!==n.estimatedMinutes?(f=n.estimatedMinutes?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),n.estimatedMinutes,` `,r.minutes]}):null,t[22]=r.minutes,t[23]=n.estimatedMinutes,t[24]=f):f=t[24];let p;t[25]!==d||t[26]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[d,f]}),t[25]=d,t[26]=f,t[27]=p):p=t[27];let m;t[28]!==r.history||t[29]!==i?(m=(0,$.jsx)(ke,{label:r.history,onClick:i}),t[28]=r.history,t[29]=i,t[30]=m):m=t[30],t[31]!==m||t[32]!==p?(a=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[p,m]}),t[31]=m,t[32]=p,t[33]=a):a=t[33],t[34]===n.title?o=t[35]:(o=(0,$.jsx)(`h3`,{className:`mt-3 text-xl font-semibold leading-7 tracking-tight text-fg`,children:n.title}),t[34]=n.title,t[35]=o),t[36]===n.outcome?s=t[37]:(s=(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n.outcome}),t[36]=n.outcome,t[37]=s);let h;t[38]===r.why?h=t[39]:(h=(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.why,`:`]}),t[38]=r.why,t[39]=h),t[40]!==n.rationale||t[41]!==h?(c=(0,$.jsxs)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:[h,n.rationale]}),t[40]=n.rationale,t[41]=h,t[42]=c):c=t[42],t[43]!==r.automationAction||t[44]!==r.automationHint||t[45]!==n.continuation?(l=n.continuation?.kind===`automation`?(0,$.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 rounded-xl border border-edge bg-surface-subtle p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:r.automationHint}),(0,$.jsx)(`a`,{href:`#${n.continuation.href}`,className:`inline-flex min-h-11 shrink-0 items-center rounded-lg px-3 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.automationAction})]}):null,t[43]=r.automationAction,t[44]=r.automationHint,t[45]=n.continuation,t[46]=l):l=t[46],u=e.length>0?(0,$.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,"aria-label":r.needsSetup,children:e.map(e=>(0,$.jsxs)(`a`,{href:`#${e.recoveryPath??`/settings`}`,className:`rounded-full border border-accent/25 bg-accent-soft px-2.5 py-1 text-xs text-accent hover:border-accent/50`,children:[r.needsSetup,` · `,e.capability]},`${e.kind}:${e.capability}`))}):null,t[0]=r.aiLabel,t[1]=r.automationAction,t[2]=r.automationHint,t[3]=r.history,t[4]=r.minutes,t[5]=r.needsSetup,t[6]=r.why,t[7]=i,t[8]=n.capabilities,t[9]=n.continuation,t[10]=n.estimatedMinutes,t[11]=n.outcome,t[12]=n.rationale,t[13]=n.title,t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l,t[19]=u}else a=t[14],o=t[15],s=t[16],c=t[17],l=t[18],u=t[19];let d;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(y,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[47]=d):d=t[47];let f;t[48]===r.evidence?f=t[49]:(f=(0,$.jsxs)(`summary`,{className:`flex min-h-9 cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[r.evidence,d]}),t[48]=r.evidence,t[49]=f);let p;t[50]===n.evidence?p=t[51]:(p=n.evidence.map(je),t[50]=n.evidence,t[51]=p);let m;t[52]===p?m=t[53]:(m=(0,$.jsx)(`ul`,{className:`mt-2 space-y-2 border-l border-edge pl-3 text-xs leading-5 text-fg-muted`,children:p}),t[52]=p,t[53]=m);let h;t[54]!==m||t[55]!==f?(h=(0,$.jsxs)(`details`,{open:!0,className:`mt-4 group`,children:[f,m]}),t[54]=m,t[55]=f,t[56]=h):h=t[56];let g;return t[57]!==a||t[58]!==h||t[59]!==o||t[60]!==s||t[61]!==c||t[62]!==l||t[63]!==u?(g=(0,$.jsxs)($.Fragment,{children:[a,o,s,c,l,u,h]}),t[57]=a,t[58]=h,t[59]=o,t[60]=s,t[61]=c,t[62]=l,t[63]=u,t[64]=g):g=t[64],g}function je(e){return(0,$.jsx)(`li`,{children:(0,$.jsx)(Oe,{href:e.href,children:e.observation})},e.id)}function Me(e){return e.readiness!==`ready`}function Ne(e){let t=(0,Z.c)(134),{advisor:n,copy:r,busy:i,onRefresh:a,onAction:o,onFeedback:s,onClarification:c,onOpenHistory:l,preflight:u,receipt:d}=e,[f,p]=(0,Q.useState)(),m;t[0]!==n.alternatives||t[1]!==n.primary||t[2]!==n.state?(m=n.state===`ready`?[n.primary,...n.alternatives]:[],t[0]=n.alternatives,t[1]=n.primary,t[2]=n.state,t[3]=m):m=t[3];let h=m,g;t[4]!==h||t[5]!==f?(g=h.find(e=>e.id===f)??h[0],t[4]=h,t[5]=f,t[6]=g):g=t[6];let _=g,v;t[7]===h[0]?.id?v=t[8]:(v=()=>p(h[0]?.id),t[7]=h[0]?.id,t[8]=v);let y=h[0]?.id,b;if(t[9]!==n.state||t[10]!==y?(b=[n.state,y],t[9]=n.state,t[10]=y,t[11]=b):b=t[11],(0,Q.useEffect)(v,b),n.state===`disabled`)return null;if(d){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(S,{className:`size-5 shrink-0 text-success`,"aria-hidden":!0}),t[12]=e):e=t[12];let n;t[13]===d.title?n=t[14]:(n=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:d.title}),t[13]=d.title,t[14]=n);let i;t[15]===d.detail?i=t[16]:(i=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:d.detail}),t[15]=d.detail,t[16]=i);let a;t[17]!==n||t[18]!==i?(a=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[n,i]}),t[17]=n,t[18]=i,t[19]=a):a=t[19];let o;t[20]!==r.history||t[21]!==l?(o=(0,$.jsx)(ke,{label:r.history,onClick:l}),t[20]=r.history,t[21]=l,t[22]=o):o=t[22];let s=`#${d.href}`,c;t[23]!==r.viewProgress||t[24]!==s?(c=(0,$.jsx)(Y,{asChild:!0,variant:`secondary`,className:`min-h-10 text-xs`,children:(0,$.jsx)(`a`,{href:s,children:r.viewProgress})}),t[23]=r.viewProgress,t[24]=s,t[25]=c):c=t[25];let u;t[26]!==o||t[27]!==c?(u=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[o,c]}),t[26]=o,t[27]=c,t[28]=u):u=t[28];let f;return t[29]!==u||t[30]!==a?(f=(0,$.jsx)(`section`,{className:`mt-7 rounded-2xl border border-success/25 bg-success-soft px-5 py-4`,role:`status`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[e,a,u]})}),t[29]=u,t[30]=a,t[31]=f):f=t[31],f}if(n.state===`quiet`||n.state===`refreshing`)return null;if(n.state===`clarification`){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[32]=e):e=t[32];let a;t[33]===r.aiLabel?a=t[34]:(a=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-accent`,children:[e,r.aiLabel]}),t[33]=r.aiLabel,t[34]=a);let o;t[35]!==r.history||t[36]!==l?(o=(0,$.jsx)(ke,{label:r.history,onClick:l}),t[35]=r.history,t[36]=l,t[37]=o):o=t[37];let s;t[38]!==a||t[39]!==o?(s=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[a,o]}),t[38]=a,t[39]=o,t[40]=s):s=t[40];let u;t[41]===n.question.question?u=t[42]:(u=(0,$.jsx)(`h3`,{id:`home-advisor-question`,className:`mt-3 text-lg font-semibold text-fg`,children:n.question.question}),t[41]=n.question.question,t[42]=u);let d;if(t[43]!==n.question.options||t[44]!==n.question.question||t[45]!==i||t[46]!==c){let e;t[48]!==n.question.question||t[49]!==i||t[50]!==c?(e=e=>(0,$.jsx)(Y,{type:`button`,variant:`secondary`,className:`min-h-11`,disabled:i,onClick:()=>c(n.question.question,e.label),children:e.label},e.id),t[48]=n.question.question,t[49]=i,t[50]=c,t[51]=e):e=t[51],d=n.question.options.map(e),t[43]=n.question.options,t[44]=n.question.question,t[45]=i,t[46]=c,t[47]=d}else d=t[47];let f;t[52]===d?f=t[53]:(f=(0,$.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:d}),t[52]=d,t[53]=f);let p;return t[54]!==u||t[55]!==f||t[56]!==s?(p=(0,$.jsxs)(`section`,{className:`mt-7 rounded-2xl border border-accent/25 bg-surface-base px-5 py-5`,"aria-labelledby":`home-advisor-question`,children:[s,u,f]}),t[54]=u,t[55]=f,t[56]=s,t[57]=p):p=t[57],p}if(!_)return null;let x=u?.opportunityId===_.id?u.value:void 0,C;t[58]!==n.stale||t[59]!==r.refreshing?(C=n.stale?(0,$.jsxs)(`p`,{className:`mb-3 inline-flex items-center gap-2 text-xs text-accent`,children:[(0,$.jsx)(j,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.refreshing]}):null,t[58]=n.stale,t[59]=r.refreshing,t[60]=C):C=t[60];let w;t[61]!==r||t[62]!==l||t[63]!==_?(w=(0,$.jsx)(Ae,{opportunity:_,copy:r,onOpenHistory:l}),t[61]=r,t[62]=l,t[63]=_,t[64]=w):w=t[64];let T;t[65]!==i||t[66]!==r.configure||t[67]!==r.degradedStart||t[68]!==r.setupHint||t[69]!==r.setupTitle||t[70]!==o||t[71]!==_||t[72]!==x?(T=x?.state===`needs_setup`?(0,$.jsx)(`div`,{className:`mt-5 rounded-xl border border-accent/25 bg-accent-soft/40 p-4`,role:`alert`,"aria-live":`polite`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(M,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:r.setupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r.setupHint}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:x.blockers.map(Pe)}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[x.recoveryActions.map(e=>(0,$.jsxs)(`a`,{href:`#${e.href}`,className:`inline-flex min-h-11 items-center rounded-lg border border-accent/30 px-3 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[r.configure,` · `,e.capability]},e.capability)),x.degradedAction?(0,$.jsx)(Y,{type:`button`,variant:`secondary`,className:`min-h-11`,disabled:i,onClick:()=>o(_,`degraded_start`),children:r.degradedStart}):null]})]})]})}):null,t[65]=i,t[66]=r.configure,t[67]=r.degradedStart,t[68]=r.setupHint,t[69]=r.setupTitle,t[70]=o,t[71]=_,t[72]=x,t[73]=T):T=t[73];let E;t[74]!==i||t[75]!==r.start||t[76]!==o||t[77]!==_?(E=_.actions.canStart?(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`min-h-11`,disabled:i,onClick:()=>o(_,`start`),children:[(0,$.jsx)(N,{className:`size-4`,"aria-hidden":!0}),r.start]}):null,t[74]=i,t[75]=r.start,t[76]=o,t[77]=_,t[78]=E):E=t[78];let D;t[79]!==i||t[80]!==r.discuss||t[81]!==o||t[82]!==_?(D=_.actions.canDiscuss?(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,className:`min-h-11`,disabled:i,onClick:()=>o(_,`discuss`),children:[(0,$.jsx)(O,{className:`size-4`,"aria-hidden":!0}),r.discuss]}):null,t[79]=i,t[80]=r.discuss,t[81]=o,t[82]=_,t[83]=D):D=t[83];let k;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(j,{className:`size-4`,"aria-hidden":!0}),t[84]=k):k=t[84];let A;t[85]!==i||t[86]!==r.refresh||t[87]!==a?(A=(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,className:`min-h-11`,disabled:i,onClick:a,title:r.refresh,children:[k,r.refresh]}),t[85]=i,t[86]=r.refresh,t[87]=a,t[88]=A):A=t[88];let P;t[89]===r.feedback?P=t[90]:(P=(0,$.jsx)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center rounded-lg px-3 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.feedback}),t[89]=r.feedback,t[90]=P);let F;t[91]===r.alreadyDone?F=t[92]:(F=[`already_done`,r.alreadyDone],t[91]=r.alreadyDone,t[92]=F);let I;t[93]===r.irrelevant?I=t[94]:(I=[`irrelevant`,r.irrelevant],t[93]=r.irrelevant,t[94]=I);let L;t[95]===r.later?L=t[96]:(L=[`too_early`,r.later],t[95]=r.later,t[96]=L);let R;t[97]===r.sourceIncorrect?R=t[98]:(R=[`source_incorrect`,r.sourceIncorrect],t[97]=r.sourceIncorrect,t[98]=R);let z;t[99]===r.lessLikeThis?z=t[100]:(z=[`less_like_this`,r.lessLikeThis],t[99]=r.lessLikeThis,t[100]=z);let B;t[101]!==F||t[102]!==I||t[103]!==L||t[104]!==R||t[105]!==z?(B=[F,I,L,R,z],t[101]=F,t[102]=I,t[103]=L,t[104]=R,t[105]=z,t[106]=B):B=t[106];let V=B,H;t[107]!==i||t[108]!==s||t[109]!==_||t[110]!==V?(H=(0,$.jsx)(`div`,{className:`absolute right-0 z-20 mt-1 w-44 rounded-xl border border-edge bg-surface-overlay p-1 shadow-float`,children:V.map(e=>{let[t,n]=e;return(0,$.jsx)(`button`,{type:`button`,disabled:i,className:`min-h-10 w-full rounded-lg px-3 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>s(_,t),children:n},t)})}),t[107]=i,t[108]=s,t[109]=_,t[110]=V,t[111]=H):H=t[111];let U;t[112]!==P||t[113]!==H?(U=(0,$.jsxs)(`details`,{className:`relative ml-auto`,children:[P,H]}),t[112]=P,t[113]=H,t[114]=U):U=t[114];let W;t[115]!==D||t[116]!==A||t[117]!==U||t[118]!==E?(W=(0,$.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[E,D,A,U]}),t[115]=D,t[116]=A,t[117]=U,t[118]=E,t[119]=W):W=t[119];let G;t[120]!==W||t[121]!==C||t[122]!==w||t[123]!==T?(G=(0,$.jsxs)(`div`,{className:`px-5 py-5 sm:px-6`,children:[C,w,T,W]}),t[120]=W,t[121]=C,t[122]=w,t[123]=T,t[124]=G):G=t[124];let K;t[125]!==i||t[126]!==r.alternatives||t[127]!==h||t[128]!==_.id?(K=h.length>1?(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:r.alternatives}),(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:h.filter(e=>e.id!==_.id).map(e=>(0,$.jsx)(`button`,{type:`button`,disabled:i,className:`min-h-10 rounded-lg border border-edge px-3 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>p(e.id),children:e.title},e.id))})]}):null,t[125]=i,t[126]=r.alternatives,t[127]=h,t[128]=_.id,t[129]=K):K=t[129];let q;return t[130]!==r.aiLabel||t[131]!==G||t[132]!==K?(q=(0,$.jsxs)(`section`,{className:`mt-7 rounded-2xl border border-accent/25 bg-surface-base`,"aria-label":r.aiLabel,children:[G,K]}),t[130]=r.aiLabel,t[131]=G,t[132]=K,t[133]=q):q=t[133],q}function Pe(e){return(0,$.jsx)(`li`,{children:e.message},`${e.kind}:${e.capability}`)}var Fe=new Set([`started`,`discussing`,`completed`]);function Ie(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[0,1,2].map(Le)}),e[0]=t):t=e[0],t}function Le(e){return(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-edge-subtle p-4`,children:[(0,$.jsx)(I,{className:`h-4 w-24 rounded`}),(0,$.jsx)(I,{className:`h-5 w-4/5 rounded`}),(0,$.jsx)(I,{className:`h-4 w-3/5 rounded`})]},e)}function Re(e){let t=(0,Z.c)(11),{open:n,refreshKey:r,onOpenChange:i,onReevaluate:a}=e,o=l(ze),s=u(o).projectsPage.home,v=c(),[b,x]=(0,Q.useState)(`all`),S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],t[0]=S):S=t[0];let[E,O]=(0,Q.useState)(S),[k,A]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(),F;t[1]===n?F=t[2]:(F=()=>{if(!n)return;let e=!0;return A(!0),N(void 0),V().then(t=>{e&&O(t.items)}).catch(t=>{e&&N(t instanceof Error?t.message:String(t))}).finally(()=>{e&&A(!1)}),()=>{e=!1}},t[1]=n,t[2]=F);let I;t[3]!==n||t[4]!==r?(I=[n,r],t[3]=n,t[4]=r,t[5]=I):I=t[5],(0,Q.useEffect)(F,I);let L=E.filter(e=>b===`all`||(b===`adopted`?Fe.has(e.status):!Fe.has(e.status))),R=new Intl.DateTimeFormat(o===`zh`?`zh-CN`:`en`,{dateStyle:`medium`}),z=new Intl.DateTimeFormat(o===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}),B=new Map;for(let e of L){let t=R.format(new Date(e.updatedAt));B.set(t,[...B.get(t)??[],e])}let H=[...B.entries()],U=e=>e.feedbackKind===`already_done`?s.advisorHistoryStatusCompleted:e.feedbackKind===`irrelevant`?s.advisorHistoryStatusIrrelevant:e.feedbackKind===`source_incorrect`?s.advisorHistoryStatusSourceIncorrect:e.feedbackKind===`less_like_this`?s.advisorHistoryStatusLessLikeThis:{available:s.advisorHistoryStatusAvailable,started:s.advisorHistoryStatusStarted,discussing:s.advisorHistoryStatusDiscussing,completed:s.advisorHistoryStatusCompleted,snoozed:s.advisorHistoryStatusSnoozed,dismissed:s.advisorHistoryStatusDismissed,expired:s.advisorHistoryStatusExpired,superseded:s.advisorHistoryStatusSuperseded}[e.status],W=e=>{if(e.href){i(!1),v(D(`/`,e.href));return}e.status===`discussing`&&(i(!1),v(`/chat/new?${new URLSearchParams({draft:e.opportunity.actionPrompt}).toString()}`))},G;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim`}),t[6]=G):G=t[6];let K;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(T,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),t[7]=K):K=t[7];let q;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(P,{className:`size-4`,"aria-hidden":!0}),t[8]=q):q=t[8];let J=k?(0,$.jsx)(Ie,{}):M?(0,$.jsxs)(`div`,{className:`rounded-xl border border-danger/25 bg-danger-soft p-4 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:s.advisorHistoryLoadFailed}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`mt-2`,onClick:()=>i(!1),children:s.advisorHistoryClose})]}):H.length===0?(0,$.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,$.jsx)(T,{className:`mx-auto size-6 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:s.advisorHistoryEmpty}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.advisorHistoryEmptyHint})]}):(0,$.jsx)(`div`,{className:`space-y-6`,children:H.map(e=>{let[t,n]=e;return(0,$.jsxs)(`section`,{"aria-label":t,children:[(0,$.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-subtle`,children:t}),(0,$.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>{let t=!!e.href||e.status===`discussing`,n=[`snoozed`,`dismissed`,`expired`,`superseded`].includes(e.status);return(0,$.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-accent`,children:U(e)}),(0,$.jsx)(`h4`,{className:`mt-1.5 text-sm font-semibold leading-5 text-fg`,children:e.opportunity.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.opportunity.outcome})]}),(0,$.jsx)(`time`,{className:`shrink-0 text-[11px] text-fg-subtle`,dateTime:new Date(e.updatedAt).toISOString(),children:z.format(new Date(e.updatedAt))})]}),e.snoozedUntil?(0,$.jsxs)(`p`,{className:`mt-2 inline-flex items-center gap-1 text-xs text-fg-muted`,children:[(0,$.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),s.advisorHistoryReturnsAt,` `,z.format(new Date(e.snoozedUntil))]}):null,(0,$.jsxs)(`details`,{className:`group mt-3`,children:[(0,$.jsxs)(`summary`,{className:`flex min-h-8 cursor-pointer list-none items-center gap-1 text-xs font-medium text-fg-muted hover:text-fg`,children:[s.advisorHistoryEvidence,(0,$.jsx)(y,{className:`size-3.5 transition-transform duration-200 group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1.5 border-l border-edge pl-3 text-xs leading-5 text-fg-muted`,children:e.opportunity.evidence.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(Oe,{href:e.href,onOpen:()=>i(!1),children:e.observation})},e.id))})]}),t||n?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[t?(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,className:`min-h-9 text-xs`,onClick:()=>W(e),children:[(0,$.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),e.status===`discussing`?s.advisorHistoryContinueDiscussion:s.advisorHistoryViewProgress]}):null,n?(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,className:`min-h-9 text-xs`,onClick:()=>{i(!1),a()},children:[(0,$.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),s.advisorHistoryReevaluate]}):null]}):null]},e.opportunity.id)})})]},t)})}),ee;return t[9]===J?ee=t[10]:(ee=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:J}),t[9]=J,t[10]=ee),(0,$.jsx)(_,{open:n,onOpenChange:i,children:(0,$.jsxs)(m,{children:[G,(0,$.jsxs)(h,{className:`xopc-drawer-right fixed right-0 top-0 z-[90] flex size-full max-w-lg flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none`,"aria-describedby":`home-advisor-history-description`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 border-b border-edge px-5 py-4`,children:[K,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(g,{className:`text-base font-semibold text-fg`,children:s.advisorHistoryTitle}),(0,$.jsx)(f,{id:`home-advisor-history-description`,className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.advisorHistoryDescription})]}),(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`-mr-2 size-9 shrink-0 p-0`,"aria-label":s.advisorHistoryClose,children:q})})]}),(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-3`,children:(0,$.jsx)(_e,{className:`inline-flex rounded-lg bg-surface-inset p-1`,role:`group`,"aria-label":s.advisorHistoryFilterLabel,indicatorClassName:`rounded-md bg-surface-panel shadow-surface`,children:[[`all`,s.advisorHistoryFilterAll],[`adopted`,s.advisorHistoryFilterAdopted],[`other`,s.advisorHistoryFilterOther]].map(e=>{let[t,n]=e;return(0,$.jsx)(`button`,{type:`button`,className:`min-h-9 rounded-md px-3 text-xs font-medium transition-colors duration-150 ${b===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`}`,"aria-pressed":b===t,onClick:()=>x(t),children:n},t)})})}),ee]})]})})}function ze(e){return e.language}function Be(e,t){return e.replace(`{{count}}`,String(t))}function Ve(e,t){if(e.state===`disabled`)return null;if(e.state===`ready`){let n=1+e.alternatives.length;return{label:Be(t.ready,n),detail:e.primary.title,tone:`accent`,refreshing:!!e.stale}}return e.state===`clarification`?{label:t.clarification,detail:e.question.question,tone:`accent`,refreshing:!1}:e.state===`refreshing`?{label:t.refreshing,detail:e.previous?.title??t.refreshingDetail,tone:`accent`,refreshing:!0}:e.reason===`generation_failed`?{label:t.generationFailed,detail:t.generationFailedDetail,tone:`danger`,refreshing:!1}:e.reason===`budget_exhausted`?{label:t.budgetExhausted,detail:t.budgetExhaustedDetail,tone:`warning`,refreshing:!1}:e.reason===`model_unavailable`?{label:t.modelUnavailable,detail:t.modelUnavailableDetail,tone:`warning`,refreshing:!1}:{label:t.idle,detail:t.idleDetail,tone:`neutral`,refreshing:!1}}var He={accent:`bg-accent`,danger:`bg-danger`,neutral:`bg-fg-subtle`,warning:`bg-warning`};function Ue(e){let t=(0,Z.c)(50),{advisor:n,busy:r,copy:i,onOpenHistory:a,onRefresh:o}=e,[s,c]=(0,Q.useState)(!1),l;t[0]!==n||t[1]!==i?(l=Ve(n,i),t[0]=n,t[1]=i,t[2]=l):l=t[2];let u=l;if(!u)return null;let d=n.state!==`refreshing`,f=n.state===`ready`?i.findAnother:i.retry,p=`${i.label}:${u.label}`,m;t[3]===u.refreshing?m=t[4]:(m=u.refreshing?(0,$.jsx)(j,{className:`size-3.5 shrink-0 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,$.jsx)(N,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[3]=u.refreshing,t[4]=m);let h=He[u.tone],g;t[5]===h?g=t[6]:(g=F(`size-1.5 shrink-0 rounded-full`,h),t[5]=h,t[6]=g);let _;t[7]===g?_=t[8]:(_=(0,$.jsx)(`span`,{className:g,"aria-hidden":!0}),t[7]=g,t[8]=_);let v;t[9]!==i.label||t[10]!==u.label?(v=(0,$.jsxs)(`span`,{className:`truncate`,children:[i.label,` · `,u.label]}),t[9]=i.label,t[10]=u.label,t[11]=v):v=t[11];let y;t[12]!==p||t[13]!==m||t[14]!==_||t[15]!==v?(y=(0,$.jsx)(se,{asChild:!0,children:(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-9 max-w-56 rounded-lg px-2.5`,"aria-label":p,children:[m,_,v]})}),t[12]=p,t[13]=m,t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===u.refreshing?b=t[18]:(b=(0,$.jsx)(`span`,{className:`mt-1 flex size-7 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent`,children:u.refreshing?(0,$.jsx)(j,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,$.jsx)(N,{className:`size-4`,"aria-hidden":!0})}),t[17]=u.refreshing,t[18]=b);let x;t[19]===u.label?x=t[20]:(x=(0,$.jsx)(`p`,{className:`font-semibold text-fg`,children:u.label}),t[19]=u.label,t[20]=x);let S;t[21]===u.detail?S=t[22]:(S=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.detail}),t[21]=u.detail,t[22]=S);let C;t[23]!==x||t[24]!==S?(C=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,S]}),t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]!==C||t[27]!==b?(w=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[b,C]}),t[26]=C,t[27]=b,t[28]=w):w=t[28];let E;t[29]===a?E=t[30]:(E=()=>{c(!1),a()},t[29]=a,t[30]=E);let D;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),t[31]=D):D=t[31];let O;t[32]!==i.history||t[33]!==E?(O=(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg text-xs`,onClick:E,children:[D,i.history]}),t[32]=i.history,t[33]=E,t[34]=O):O=t[34];let k;t[35]!==r||t[36]!==d||t[37]!==o||t[38]!==f?(k=d?(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg text-xs`,disabled:r,onClick:()=>{c(!1),o()},children:[(0,$.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),f]}):null,t[35]=r,t[36]=d,t[37]=o,t[38]=f,t[39]=k):k=t[39];let A;t[40]!==O||t[41]!==k?(A=(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-1 border-t border-edge-subtle pt-3`,children:[O,k]}),t[40]=O,t[41]=k,t[42]=A):A=t[42];let M;t[43]!==w||t[44]!==A?(M=(0,$.jsx)(ie,{children:(0,$.jsxs)(ae,{side:`bottom`,align:`end`,sideOffset:6,className:`z-[70] w-[min(21rem,calc(100vw-1.5rem))] rounded-xl border border-edge bg-surface-overlay p-4 text-sm text-fg shadow-popover outline-none`,onOpenAutoFocus:We,children:[w,A]})}),t[43]=w,t[44]=A,t[45]=M):M=t[45];let P;return t[46]!==s||t[47]!==M||t[48]!==y?(P=(0,$.jsxs)(oe,{open:s,onOpenChange:c,children:[y,M]}),t[46]=s,t[47]=M,t[48]=y,t[49]=P):P=t[49],P}function We(e){return e.preventDefault()}async function Ge(e,t=`en`){let n=await te(e),r=n.runs.filter(e=>!e.parentRunId).sort((e,t)=>t.queuedAt-e.queuedAt)[0];if(!n.allowedCommands.includes(`start`)||r?.status!==`failed`)throw Error(t===`zh`?`任务状态已变化,暂时无法重试。请刷新并查看当前状态。`:`Task is no longer available for retry. Refresh and review its current state.`);await W(e,{type:`start`,executor:L.parse({...r.executorRef,kind:r.executorKind})},n.task.version)}function Ke(e){let t=e.runs.filter(e=>!e.parentRunId).sort((e,t)=>t.queuedAt-e.queuedAt)[0],n=e.conversation?.currentExecutorAgentId??e.task.delegateAgentId,r=n?{kind:`agent`,agentId:n}:t?{...t.executorRef,kind:t.executorKind}:void 0,i=L.safeParse(r);return i.success?i.data:void 0}var qe=(0,Q.lazy)(()=>i(()=>import(`./workspace-file-preview-dialog-NRL3YRjg.js`).then(e=>e.n).then(e=>({default:e.WorkspaceFilePreviewPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74])));function Je({taskId:e,language:t,onComplete:n,onUpdated:r}){let i=t===`zh`,o=a(),c=`${o.pathname}${o.search}`,[l,u]=(0,Q.useState)(),[f,p]=(0,Q.useState)(),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(),[S,C]=(0,Q.useState)(!1),w=(0,Q.useRef)(!1),T=(0,Q.useRef)(0),[D,O]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{u(void 0),x(void 0)},[e]),(0,Q.useEffect)(()=>{let t=!0,n=++T.current;return p(void 0),te(e).then(e=>{t&&n===T.current&&!w.current&&u(e)}).catch(e=>{t&&n===T.current&&p(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[e,D]),(0,Q.useEffect)(()=>{let t=()=>{w.current||O(e=>e+1)},n=n=>{n.detail?.taskId===e&&t()};return window.addEventListener(`task-changed-v2`,n),window.addEventListener(`focus`,t),window.addEventListener(`realtime-gap`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.removeEventListener(`task-changed-v2`,n),window.removeEventListener(`focus`,t),window.removeEventListener(`realtime-gap`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[e]);let k=l?de(l):[],A=l?.task.phase===`review`&&l.allowedCommands.includes(`close`)&&l.waits.length===0&&k.length>0&&k.every(e=>e.status===`passed`),j=l?Ke(l):void 0,M=l?.allowedCommands.includes(`start`)&&l.waits.length===0&&j,N=e=>{T.current++,u(e),r?.(e)};async function P(e,t,r=!1){if(!w.current){w.current=!0,T.current++,C(!0),p(void 0);try{N(await e()),x(t),r&&n()}catch(e){p(e instanceof Error?e.message:String(e))}finally{w.current=!1,C(!1)}}}let F=l?.receipts.filter(e=>l.runs.some(t=>t.id===e.runId&&t.contractVersion===l.task.latestContractVersion)).sort((e,t)=>t.finalizedAt-e.finalizedAt)[0],L=k.filter(e=>e.status===`passed`).length,z=k.filter(e=>e.status===`failed`).length,B=k.length-L-z,V=l?.task.contract?.acceptancePolicy===`verified_auto`,H=E(c,e);return(0,$.jsxs)(`section`,{className:`mt-4 space-y-4 rounded-xl border border-edge bg-surface-panel p-4`,"aria-label":i?`任务结果与处理`:`Task result and actions`,"aria-busy":S,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i?`执行结果`:`Result`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`ghost`,disabled:S,onClick:()=>O(e=>e+1),children:i?`刷新状态`:`Refresh status`}),(0,$.jsx)(s,{to:H,className:`inline-flex min-h-9 items-center text-xs font-medium text-accent-fg hover:underline`,children:i?`查看任务详情`:`Task details`})]})]}),f?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f}):null,S?(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:i?`正在处理…`:`Processing…`}):null,b?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-success`,children:b}):null,!l&&!f?(0,$.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,$.jsx)(I,{className:`h-5 w-1/3`}),(0,$.jsx)(I,{className:`h-24 w-full`})]}):null,l?(0,$.jsxs)($.Fragment,{children:[F?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:F.completionVerdict===`achieved`?i?`执行报告已达成目标,请结合依据逐项验收。`:`The run reports the goal achieved. Review the evidence before accepting.`:i?`当前为阶段性结果,尚有工作需要推进。`:`This is a partial result. More work is needed.`}),(0,$.jsx)(X,{content:F.summary,contentKey:`home:${e}:result:${F.runId}`,language:t,previewHeight:180}),F.remainingWork.length>0?(0,$.jsxs)(`div`,{className:`text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i?`尚待完成`:`Remaining work`}),(0,$.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:F.remainingWork.map((e,t)=>(0,$.jsx)(`li`,{children:e},t))})]}):null,F.nextAction?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap text-sm text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:i?`下一步:`:`Next step: `}),F.nextAction]}):null,F.judgment?(0,$.jsxs)(`div`,{className:`space-y-1 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i?`判断依据`:`Assessment`}),(0,$.jsx)(`p`,{children:F.judgment.recommendation}),(0,$.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:F.judgment.reasons.map((e,t)=>(0,$.jsx)(`li`,{children:e},t))}),F.judgment.uncertainty?(0,$.jsxs)(`p`,{children:[i?`待确认:`:`Uncertainty: `,F.judgment.uncertainty]}):null]}):null,(0,$.jsx)(Ce,{evidence:F.evidence,projectId:l.task.projectId,conversationId:l.conversation?.activeConversationId,language:t,onOpenFile:y})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i?`当前任务版本暂无执行结果,可先处理等待事项或查看执行进度。`:`No result for the current task version. Resolve pending items or view progress.`}),k.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`h3`,{className:`text-sm font-semibold text-fg`,children:[i?`验收条件`:`Acceptance criteria`,` `,(0,$.jsxs)(`span`,{className:`font-normal text-fg-muted`,children:[L,`/`,k.length]})]}),k.map((n,r)=>(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 text-sm text-fg`,children:[(0,$.jsx)(`p`,{className:`break-words`,children:n.text}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i?{passed:`已通过`,failed:`未通过`,unverified:`待判定`}[n.status]:{passed:`Passed`,failed:`Failed`,unverified:`Not reviewed`}[n.status]})]}),l.task.phase===`review`&&!V?(0,$.jsx)(`div`,{className:`flex gap-2`,children:[`passed`,`failed`].map(t=>(0,$.jsx)(Y,{variant:`secondary`,disabled:S||n.status===t,onClick:()=>void P(()=>R(e,r,t,l.task.version,l.task.latestContractVersion),i?`判定已保存。`:`Review saved.`),children:i?t===`passed`?`确认通过`:`未通过`:t===`passed`?`Mark passed`:`Mark failed`},t))}):null]}),n.note?(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-xs leading-5 text-fg-muted`,children:n.note}):null,n.review?.note?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.review.note}):null,(0,$.jsx)(Ce,{evidence:n.evidence,projectId:l.task.projectId,conversationId:l.conversation?.activeConversationId,language:t,onOpenFile:y})]},r))]}):null,l.waits.length>0?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i?`等待处理`:`Pending items`}),l.waits.map(t=>(0,$.jsx)(`div`,{children:l.allowedCommands.includes(`resolve_wait`)&&(t.kind===`user_input`||t.kind===`approval`&&typeof t.condition.capability==`string`)&&t.condition.type!==`connection`?(0,$.jsx)(Se,{wait:t,detail:l,zh:i,onUpdated:N}):(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:t.reason}),t.kind===`paused`&&l.allowedCommands.includes(`resolve_wait`)?(0,$.jsx)(Y,{className:`mt-2`,disabled:S,onClick:()=>void P(()=>W(e,{type:`resolve_wait`,waitId:t.id},l.task.version),i?`已解除暂停,任务状态已更新。`:`Pause resolved. Task status updated.`),children:i?`恢复任务`:`Resume task`}):(0,$.jsx)(s,{to:typeof t.condition.dependsOnTaskId==`string`?E(c,t.condition.dependsOnTaskId):H,className:`mt-2 inline-flex min-h-9 items-center text-accent-fg hover:underline`,children:i?`查看并处理`:`View and resolve`})]})},t.id))]}):null,l.task.phase===`review`&&!A?(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i?`尚有 ${B} 项待判定、${z} 项未通过、${l.waits.length} 项等待处理。${V?`此任务需要执行验证;请继续执行以补齐依据和未完成项。`:`查看依据后逐项判定;未通过时可继续执行修正。`}`:`${B} unreviewed, ${z} failed, ${l.waits.length} pending items. ${V?`This task requires execution verification. Continue execution to supply missing evidence.`:`Review the evidence and mark each criterion; continue execution to fix failures.`}`}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[l.task.phase===`review`?(0,$.jsx)(Y,{variant:`primary`,disabled:S||!A,onClick:()=>void P(()=>W(e,{type:`close`,resolution:`done`},l.task.version),i?`任务已验收完成。`:`Task accepted.`,!0),children:i?`验收完成`:`Accept task`}):null,M?(0,$.jsx)(Y,{variant:A?`secondary`:`primary`,disabled:S,onClick:()=>void P(()=>W(e,{type:`start`,executor:j},l.task.version),i?`已开始执行,结果将自动更新。`:`Execution started. Results will update automatically.`),children:i?F?`继续执行并验证`:`开始执行`:F?`Continue and verify`:`Start execution`}):null]})]}):null,l&&v?(0,$.jsx)(_,{open:!0,onOpenChange:e=>{e||y(null)},children:(0,$.jsxs)(m,{children:[(0,$.jsx)(d,{className:`fixed inset-0 z-[80] bg-scrim`}),(0,$.jsxs)(h,{className:`app-main-surface fixed left-1/2 top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] w-[min(72rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel outline-none`,"aria-describedby":void 0,children:[(0,$.jsxs)(g,{className:`sr-only`,children:[i?`交付物预览`:`Artifact preview`,` · `,v]}),(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsxs)(`div`,{className:`flex-1 space-y-3 p-4`,"aria-busy":!0,children:[(0,$.jsx)(I,{className:`h-9 w-full`}),(0,$.jsx)(I,{className:`h-64 w-full`})]}),children:(0,$.jsx)(qe,{filePath:v,projectId:l.task.projectId,conversationId:l.conversation?.activeConversationId,onClose:()=>y(null)})})]})]})}):null]})}function Ye(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Xe(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`space-y-8`,"aria-busy":!0,children:[(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(I,{className:`h-10 w-3/5 rounded-xl`}),(0,$.jsx)(I,{className:`h-5 w-4/5 rounded-lg`})]}),(0,$.jsx)(I,{className:`h-64 rounded-2xl`}),(0,$.jsx)(I,{className:`h-32 rounded-xl`})]}),e[0]=t):t=e[0],t}function Ze(e){let t=(0,Z.c)(61),{item:n,busy:r,recommendationLabel:i,dueLabel:a,failureLabel:s,locale:c,onAction:l,onComplete:u,onUpdated:d}=e,[f,p]=o(),m;t[0]===n.openAction?m=t[1]:(m=n.openAction?.type===`open`?/^\/tasks\/([^/?#]+)/.exec(n.openAction.href):null,t[0]=n.openAction,t[1]=m);let h=m,g=n.primaryAction?.type===`task_review`?n.primaryAction.taskId:h?decodeURIComponent(h[1]):void 0,_;t[2]!==g||t[3]!==f?(_=g&&f.get(`reviewTask`)===g,t[2]=g,t[3]=f,t[4]=_):_=t[4];let v=!!_,y;t[5]!==g||t[6]!==f||t[7]!==p?(y=e=>{let t=new URLSearchParams(f);e&&g?t.set(`reviewTask`,g):t.delete(`reviewTask`),p(t)},t[5]=g,t[6]=f,t[7]=p,t[8]=y):y=t[8];let b=y,x;t[9]!==a||t[10]!==n.dueAt||t[11]!==c?(x=n.dueAt?`${a} ${be(new Date(n.dueAt),c)}`:null,t[9]=a,t[10]=n.dueAt,t[11]=c,t[12]=x):x=t[12];let S=x,C=n.kind===`failure`?s:S,w;t[13]===C?w=t[14]:(w=C?(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-warning`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-warning`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:C})]}):null,t[13]=C,t[14]=w);let T=!n.openAction,E;t[15]!==n.id||t[16]!==n.openAction||t[17]!==l?(E=()=>n.openAction&&l(n.openAction,n.id),t[15]=n.id,t[16]=n.openAction,t[17]=l,t[18]=E):E=t[18];let D;t[19]===n.title?D=t[20]:(D=(0,$.jsx)(`span`,{className:`block text-lg font-semibold leading-7 tracking-tight text-fg`,children:n.title}),t[19]=n.title,t[20]=D);let O;t[21]===n.summary?O=t[22]:(O=(0,$.jsx)(`span`,{className:`mt-1.5 block text-sm leading-6 text-fg-muted`,children:n.summary}),t[21]=n.summary,t[22]=O);let k;t[23]!==T||t[24]!==E||t[25]!==D||t[26]!==O?(k=(0,$.jsxs)(`button`,{type:`button`,className:`block w-full text-left outline-none focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-accent`,disabled:T,onClick:E,children:[D,O]}),t[23]=T,t[24]=E,t[25]=D,t[26]=O,t[27]=k):k=t[27];let A;t[28]!==n.recommendation||t[29]!==i?(A=n.recommendation?(0,$.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:[(0,$.jsxs)(`span`,{className:`font-semibold text-fg`,children:[i,`:`]}),n.recommendation]}):null,t[28]=n.recommendation,t[29]=i,t[30]=A):A=t[30];let j;t[31]!==r||t[32]!==n.id||t[33]!==n.primaryAction||t[34]!==n.secondaryActions||t[35]!==l||t[36]!==v||t[37]!==g||t[38]!==b?(j=n.primaryAction||n.secondaryActions.length>0?(0,$.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[n.primaryAction?(0,$.jsx)(Y,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3.5 text-xs`,disabled:r,"aria-expanded":g&&[`task_review`,`open`].includes(n.primaryAction.type)?v:void 0,onClick:()=>g&&[`task_review`,`open`].includes(n.primaryAction.type)?b(!v):l(n.primaryAction,n.id),children:n.primaryAction.label}):null,n.secondaryActions.map(e=>(0,$.jsx)(Y,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3.5 text-xs shadow-none`,disabled:r,onClick:()=>l(e,n.id),children:e.label},`${e.type}:${e.label}`))]}):null,t[31]=r,t[32]=n.id,t[33]=n.primaryAction,t[34]=n.secondaryActions,t[35]=l,t[36]=v,t[37]=g,t[38]=b,t[39]=j):j=t[39];let M;t[40]!==n.primaryAction?.type||t[41]!==c||t[42]!==v||t[43]!==g||t[44]!==b?(M=g&&n.primaryAction?.type===`retry_task`?(0,$.jsx)(Y,{variant:`ghost`,className:`mt-2`,"aria-expanded":v,onClick:()=>b(!v),children:c===`zh`?`查看结果与依据`:`View result and evidence`}):null,t[40]=n.primaryAction?.type,t[41]=c,t[42]=v,t[43]=g,t[44]=b,t[45]=M):M=t[45];let N;t[46]!==c||t[47]!==u||t[48]!==d||t[49]!==v||t[50]!==g||t[51]!==b?(N=v&&g?(0,$.jsx)(Je,{taskId:g,language:c,onUpdated:d,onComplete:()=>{b(!1),u()}},g):null,t[46]=c,t[47]=u,t[48]=d,t[49]=v,t[50]=g,t[51]=b,t[52]=N):N=t[52];let P;return t[53]!==r||t[54]!==k||t[55]!==A||t[56]!==j||t[57]!==M||t[58]!==N||t[59]!==w?(P=(0,$.jsxs)(`article`,{className:`px-5 py-5 sm:px-6 sm:py-6`,"aria-busy":r,children:[w,k,A,j,M,N]}),t[53]=r,t[54]=k,t[55]=A,t[56]=j,t[57]=M,t[58]=N,t[59]=w,t[60]=P):P=t[60],P}function Qe(e){let t=(0,Z.c)(38),{item:n,onAction:r,language:i,onUpdated:a}=e,[o,s]=(0,Q.useState)(!1),c;t[0]===n.openAction?c=t[1]:(c=n.openAction?.type===`open`?/^\/tasks\/([^/?#]+)/.exec(n.openAction.href):null,t[0]=n.openAction,t[1]=c);let l=c,u=l?decodeURIComponent(l[1]):void 0,d;t[2]===n.kind?d=t[3]:(d=n.kind===`scheduled`?(0,$.jsx)(v,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-fg-subtle`,"aria-hidden":!0}),t[2]=n.kind,t[3]=d);let f=d,p=!n.openAction,m=u?o:void 0,h;t[4]!==n.id||t[5]!==n.openAction||t[6]!==r||t[7]!==u?(h=()=>u?s($e):n.openAction&&r(n.openAction,n.id),t[4]=n.id,t[5]=n.openAction,t[6]=r,t[7]=u,t[8]=h):h=t[8];let g;t[9]===f?g=t[10]:(g=(0,$.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center text-fg-subtle`,children:f}),t[9]=f,t[10]=g);let _;t[11]===n.title?_=t[12]:(_=(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.title}),t[11]=n.title,t[12]=_);let y;t[13]===n.summary?y=t[14]:(y=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.summary}),t[13]=n.summary,t[14]=y);let x;t[15]!==_||t[16]!==y?(x=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[_,y]}),t[15]=_,t[16]=y,t[17]=x):x=t[17];let S;t[18]===n.statusLabel?S=t[19]:(S=n.statusLabel?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.statusLabel}):null,t[18]=n.statusLabel,t[19]=S);let C;t[20]===n.openAction?C=t[21]:(C=n.openAction?(0,$.jsx)(b,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[20]=n.openAction,t[21]=C);let w;t[22]!==S||t[23]!==C||t[24]!==p||t[25]!==m||t[26]!==h||t[27]!==g||t[28]!==x?(w=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-16 w-full items-center gap-3 py-3 text-left outline-none hover:text-fg focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-accent`,disabled:p,"aria-expanded":m,onClick:h,children:[g,x,S,C]}),t[22]=S,t[23]=C,t[24]=p,t[25]=m,t[26]=h,t[27]=g,t[28]=x,t[29]=w):w=t[29];let T;t[30]!==o||t[31]!==i||t[32]!==a||t[33]!==u?(T=u&&o?(0,$.jsx)(Je,{taskId:u,language:i,onUpdated:a,onComplete:()=>s(!1)}):null,t[30]=o,t[31]=i,t[32]=a,t[33]=u,t[34]=T):T=t[34];let E;return t[35]!==w||t[36]!==T?(E=(0,$.jsxs)(`div`,{children:[w,T]}),t[35]=w,t[36]=T,t[37]=E):E=t[37],E}function $e(e){return!e}function et(){let e=l(e=>e.language),t=u(e),n=t.projectsPage,r=ue(e),i=c(),o=a(),s=ge(e=>e.setPageHeader),v=ge(e=>e.clearPageHeader),[y,b]=(0,Q.useState)(!1),{home:S,loading:C,loadError:w,setLoadError:T,load:E}=we(e,o.key,y),[O,k]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(``),N=(0,Q.useRef)(!1),[F,I]=(0,Q.useState)(),[L,R]=(0,Q.useState)(!1),[V,W]=(0,Q.useState)(null),[G,q]=(0,Q.useState)(!1),[te,ie]=(0,Q.useState)(),[ae,oe]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(0),[de,me]=(0,Q.useState)(),[_e,be]=(0,Q.useState)(),[xe,Se]=(0,Q.useState)(!1),X=J({chat:t.chat}),Ce=(0,Q.useRef)(null),Z=le({disabled:xe,chat:t.chat,onTranscript:e=>{M(t=>fe(t,e)),window.setTimeout(()=>Ce.current?.focus(),0)}}),{phase:Te,voiceActive:De,startVoiceInput:Oe,cancelVoiceInput:ke,confirmVoiceInput:Ae,retryVoiceInput:je}=Z;(0,Q.useEffect)(()=>{if(!de)return;let e=window.setTimeout(()=>me(void 0),8e3);return()=>window.clearTimeout(e)},[de]);let Me=(0,Q.useCallback)(async e=>{if(!(e.length===0||xe)){Se(!0);try{await X.processFiles(e)}finally{Se(!1)}}},[xe,X.processFiles]),Pe=(0,Q.useCallback)(async e=>{let t=pe(e.clipboardData);t.length!==0&&(e.preventDefault(),await Me(t))},[Me]),Fe=(0,Q.useCallback)(e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,X.setIsDragging(!0))},[X.setIsDragging]),Ie=(0,Q.useCallback)(e=>{let t=e.relatedTarget;(!(t instanceof Node)||!e.currentTarget.contains(t))&&X.setIsDragging(!1)},[X.setIsDragging]),Le=(0,Q.useCallback)(async e=>{e.preventDefault(),X.setIsDragging(!1),await Me(Array.from(e.dataTransfer.files))},[X.setIsDragging,Me]),ze=(0,Q.useCallback)(e=>{e.preventDefault();let t=X.wireAttachmentsPayload(),n=t.length>0?he(t):void 0,r=H(j,n,{projectScope:`none`});r&&(k(!1),M(``),X.clearAttachments(),i(r))},[X.clearAttachments,X.wireAttachmentsPayload,j,i]),Be=X.attachments.length>=10,Ve={attachTitle:Be?Ye(t.chat.maxAttachmentsReached,{max:10}):`${t.chat.attachFile} (${X.attachments.length}/10)`,dropFiles:t.chat.dropFiles,intentLabel:r.intentLabel,intentPlaceholder:r.intentPlaceholder,intentSuggestion:r.intentSuggestion,shortcut:n.home.submitShortcut,submit:r.newWork},He=(0,Q.useMemo)(()=>({label:n.home.advisorStatusLabel,ready:n.home.advisorStatusReady,clarification:n.home.advisorStatusClarification,refreshing:n.home.advisorStatusRefreshing,refreshingDetail:n.home.advisorRefreshing,idle:n.home.advisorStatusIdle,idleDetail:n.home.advisorUnavailableTitle,generationFailed:n.home.advisorStatusGenerationFailed,budgetExhausted:n.home.advisorStatusBudgetExhausted,modelUnavailable:n.home.advisorStatusModelUnavailable,generationFailedDetail:n.home.advisorGenerationFailed,budgetExhaustedDetail:n.home.advisorBudgetExhausted,modelUnavailableDetail:n.home.advisorModelUnavailable,history:n.home.advisorHistory,retry:n.home.retry,findAnother:n.home.advisorRefresh}),[n.home]),We=!!(S&&S.needsUser.length===0&&S.backgroundCount===0),Ke=!!(S&&S.needsUser.length===0),qe=Ke||O;(0,Q.useEffect)(()=>{!qe&&De&&ke()},[ke,qe,De]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail?.target;t&&t!==`chat`||!qe||xe||(e.preventDefault(),Te===`recording`?Ae():Te===`idle`?(Ce.current?.focus(),Oe()):Te===`error`&&je())},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!qe||!De||(e.preventDefault(),ke(),Ce.current?.focus())};return window.addEventListener(ye,e),window.addEventListener(ve,t),()=>{window.removeEventListener(ye,e),window.removeEventListener(ve,t)}},[xe,ke,qe,Ae,je,Oe,De,Te]);let Je=(0,Q.useCallback)(e=>{e||ke(),k(e)},[ke]),$e=(0,Q.useCallback)((t,n)=>{if(t.type===`open`){i(D(`/`,t.href));return}t.type===`task_review`||N.current||(N.current=!0,W(n),I(void 0),T(null),(async()=>{try{if(t.type===`retry_task`)await Ge(t.taskId,e),I({message:e===`zh`?`任务已重新开始,可查看执行进度。`:`Task restarted. View progress.`,href:D(`/`,`/tasks/${encodeURIComponent(t.taskId)}`)});else if(t.type===`connector_decision`)await re({kind:`connector_approval`,approvalId:t.approvalId},t.decision),I({message:e===`zh`?t.decision===`approve`?`已批准授权,任务状态将自动更新。`:`已拒绝授权。`:t.decision===`approve`?`Permission approved. Task status will update.`:`Permission denied.`});else if(t.type===`retry_run`){let n=await B({kind:t.subjectKind,runId:t.runId});I({message:e===`zh`?`已发起重试,可查看新的执行结果。`:`Retry started. Follow the new execution.`,href:n.conversationId?`/chat/${encodeURIComponent(n.conversationId)}`:`/automations?run=${encodeURIComponent(n.runId)}`})}else t.type===`acknowledge_run`&&(await K({kind:t.subjectKind,runId:t.runId}),I({message:e===`zh`?`已确认此异常,已从待处理事项移除。`:`Issue acknowledged and removed from pending items.`}));await E()}catch(e){T(e instanceof Error?e.message:String(e))}finally{N.current=!1,W(null)}})())},[e,E,i]),et=(0,Q.useCallback)(t=>{I({message:e===`zh`?t.task.phase===`closed`?`任务已验收完成。`:`操作已保存,任务状态已更新。`:t.task.phase===`closed`?`Task accepted.`:`Action saved. Task status updated.`,href:D(`/`,`/tasks/${encodeURIComponent(t.task.id)}`)}),E()},[e,E]),tt=(0,Q.useCallback)(()=>{q(!0),ie(void 0),be(void 0),T(null),U(e).then(()=>E()).catch(e=>T(e instanceof Error?e.message:String(e))).finally(()=>q(!1))},[e,E]),nt=(0,Q.useCallback)((e,t)=>{q(!0),T(null),ee(e,t).then(async t=>{if(t.outcome===`needs_setup`){be({opportunityId:e.id,value:t.preflight});return}if(be(void 0),ce(e=>e+1),t.outcome===`task`){ie({title:n.home.advisorStartedTitle,detail:Ye(n.home.advisorStartedDetail,{title:e.title}),href:D(`/`,t.href)}),await E();return}i(t.href)}).catch(e=>T(e instanceof Error?e.message:String(e))).finally(()=>q(!1))},[E,i,n.home.advisorStartedDetail,n.home.advisorStartedTitle]),rt=(0,Q.useCallback)((e,t)=>{q(!0),ie(void 0),be(void 0),T(null),ne(e,{kind:t,snoozedUntil:t===`too_early`?Date.now()+4320*6e4:void 0}).then(({idempotencyKey:t})=>(me({opportunityId:e.id,idempotencyKey:t}),ce(e=>e+1),E())).catch(e=>T(e instanceof Error?e.message:String(e))).finally(()=>q(!1))},[E]),it=(0,Q.useCallback)(()=>{if(!de)return;let e=de;me(void 0),q(!0),T(null),z(e.opportunityId,e.idempotencyKey).then(()=>(ce(e=>e+1),E())).catch(t=>{me(e),T(t instanceof Error?t.message:String(t))}).finally(()=>q(!1))},[de,E]),at=(0,Q.useCallback)((e,t)=>{i(`/chat/new?${new URLSearchParams({draft:`${e}\n\n${t}`}).toString()}`)},[i]),ot=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[S?(0,$.jsx)(Ue,{advisor:S.advisor,busy:G,copy:He,onOpenHistory:()=>oe(!0),onRefresh:tt}):null,Ke?null:(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>k(!0),children:[(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0}),r.newWork]})]}),[G,He,r.newWork,S,tt,Ke]);(0,Q.useLayoutEffect)(()=>(s({startExtra:null,main:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),end:ot}),()=>v()),[v,ot,s,n.title]);let st=S?.needsUser.length??0,ct=S?.backgroundCount??0,lt=st>0?Ye(n.home.attentionTitle,{count:st}):ct>0?n.home.clearTitle:n.home.idleTitle,ut=st>0?ct>0?Ye(n.home.attentionIntroWithBackground,{count:ct}):n.home.attentionIntro:ct>0?Ye(n.home.clearIntro,{count:ct}):n.home.idleIntro;return(0,$.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[920px] flex-1 flex-col px-4 pb-8 pt-3 sm:px-6 lg:px-8 lg:pb-12 lg:pt-4`,children:[(0,$.jsx)(`input`,{ref:X.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files;t&&Me(Array.from(t)),e.target.value=``}}),(0,$.jsx)(_,{open:O,onOpenChange:Je,children:(0,$.jsxs)(m,{children:[(0,$.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(g,{className:`text-base font-semibold text-fg`,children:r.dialogTitle}),(0,$.jsx)(f,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:r.dialogDescription})]}),(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:n.cancel,"aria-label":n.cancel,children:(0,$.jsx)(P,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsx)(Ee,{variant:`dialog`,inputId:`new-conversation-intent`,inputRef:Ce,intent:j,labels:{...Ve,submit:r.submit},attachments:X.attachments,isDragging:X.isDragging,attachmentBusy:xe,attachmentsFull:Be,voice:Z,chat:t.chat,cancelAction:(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,children:n.cancel})}),onIntentChange:M,onPickFiles:()=>X.fileInputRef.current?.click(),onRemoveAttachment:X.removeAttachment,onPaste:e=>void Pe(e),onDragOver:Fe,onDragLeave:Ie,onDrop:e=>void Le(e),onSubmit:ze})]})]})}),(0,$.jsx)(Re,{open:ae,refreshKey:se,onOpenChange:oe,onReevaluate:tt}),w?(0,$.jsxs)(`div`,{role:`alert`,className:`mb-6 flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,$.jsx)(`span`,{children:w}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void E(),children:n.home.retry})]}):null,F?(0,$.jsxs)(`div`,{role:`status`,className:`mb-5 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-success/25 bg-success-soft px-4 py-3 text-sm text-fg`,children:[(0,$.jsx)(`span`,{children:F.message}),F.href?(0,$.jsx)(Y,{variant:`ghost`,onClick:()=>i(F.href),children:e===`zh`?`查看进展与结果`:`View progress and result`}):null]}):null,C?(0,$.jsx)(Xe,{}):S?(0,$.jsxs)(`div`,{className:We?`mx-auto my-auto w-full max-w-[640px]`:`w-full`,children:[(0,$.jsxs)(`section`,{className:We?`w-full text-center`:`max-w-3xl`,children:[(0,$.jsx)(`h2`,{className:`text-3xl font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:lt}),(0,$.jsx)(`p`,{className:We?`mx-auto mt-3 max-w-xl text-sm leading-6 text-fg-muted sm:text-base sm:leading-7`:`mt-3 max-w-2xl text-sm leading-6 text-fg-muted sm:text-base sm:leading-7`,children:ut})]}),Ke?(0,$.jsx)(Ee,{variant:`inline`,inputId:`home-conversation-intent`,inputRef:Ce,intent:j,labels:Ve,attachments:X.attachments,isDragging:X.isDragging,attachmentBusy:xe,attachmentsFull:Be,voice:Z,chat:t.chat,onIntentChange:M,onPickFiles:()=>X.fileInputRef.current?.click(),onRemoveAttachment:X.removeAttachment,onPaste:e=>void Pe(e),onDragOver:Fe,onDragLeave:Ie,onDrop:e=>void Le(e),onSubmit:ze}):null,(0,$.jsx)(Ne,{advisor:S.advisor,busy:G,copy:{aiLabel:n.home.advisorAiLabel,why:n.home.advisorWhy,evidence:n.home.advisorEvidence,needsSetup:n.home.advisorNeedsSetup,start:n.home.advisorStart,discuss:n.home.advisorDiscuss,refresh:n.home.advisorRefresh,refreshing:n.home.advisorRefreshing,history:n.home.advisorHistory,viewProgress:n.home.advisorViewProgress,alternatives:n.home.advisorAlternatives,feedback:n.home.advisorFeedback,alreadyDone:n.home.advisorAlreadyDone,irrelevant:n.home.advisorIrrelevant,later:n.home.advisorLater,lessLikeThis:n.home.advisorLessLikeThis,sourceIncorrect:n.home.advisorSourceIncorrect,minutes:n.home.advisorMinutes,setupTitle:n.home.advisorSetupTitle,setupHint:n.home.advisorSetupHint,configure:n.home.advisorConfigure,degradedStart:n.home.advisorDegradedStart,automationHint:n.home.advisorAutomationHint,automationAction:n.home.advisorAutomationAction},onRefresh:tt,onAction:nt,onFeedback:rt,onClarification:at,onOpenHistory:()=>oe(!0),preflight:_e,receipt:te}),S.needsUser.length>0?(0,$.jsxs)(`section`,{className:`mt-10`,"aria-labelledby":`home-needs-user-title`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,$.jsx)(x,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{id:`home-needs-user-title`,className:`text-sm font-semibold text-fg`,children:n.home.needsUserTitle})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base`,children:S.needsUser.map(t=>(0,$.jsx)(Ze,{item:t,busy:V!==null,recommendationLabel:n.home.recommendationLabel,dueLabel:n.home.dueLabel,failureLabel:r.runAttention,locale:e,onAction:$e,onComplete:()=>void E(),onUpdated:et},t.id))}),y||(S.attentionPolicy?.suppressedDecisionCount??0)+(S.attentionPolicy?.suppressedAttentionCount??0)>0?(0,$.jsx)(Y,{variant:`ghost`,className:`mt-2`,"aria-expanded":y,onClick:()=>b(e=>!e),children:e===`zh`?y?`收起待处理事项`:`查看其余 ${(S.attentionPolicy?.suppressedDecisionCount??0)+(S.attentionPolicy?.suppressedAttentionCount??0)} 项待处理事项`:y?`Show fewer pending items`:`View ${(S.attentionPolicy?.suppressedDecisionCount??0)+(S.attentionPolicy?.suppressedAttentionCount??0)} more pending items`}):null]}):null,S.background.length>0?(0,$.jsxs)(`section`,{className:`mt-10`,"aria-labelledby":`home-background-title`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1`,children:[(0,$.jsx)(`h2`,{id:`home-background-title`,className:`text-sm font-semibold text-fg`,children:n.home.backgroundTitle}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:Ye(n.home.backgroundCount,{count:S.backgroundCount})})]}),(0,$.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle border-y border-edge-subtle`,children:(L?S.background:S.background.slice(0,3)).map(t=>(0,$.jsx)(Qe,{item:t,language:e,onAction:$e,onUpdated:et},t.id))}),S.background.length>3?(0,$.jsx)(Y,{variant:`ghost`,className:`mt-2`,"aria-expanded":L,onClick:()=>R(e=>!e),children:e===`zh`?L?`收起`:`查看全部 ${S.backgroundCount} 项`:L?`Show less`:`View all ${S.backgroundCount} items`}):null]}):null]}):null,de?(0,$.jsxs)(`div`,{role:`status`,className:`fixed bottom-5 left-1/2 z-[100] flex -translate-x-1/2 items-center gap-4 rounded-lg border border-edge bg-surface-overlay px-4 py-3 text-sm text-fg shadow-float`,children:[(0,$.jsx)(`span`,{children:n.home.advisorFeedbackSaved}),(0,$.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:it,children:n.home.advisorUndo})]}):null]})}export{et as HomePage};
|