@xopcai/xopc 0.0.306 → 0.0.307
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-DLtim-_I.js → activity-store-wgSB2HYK.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-iQXtiilH.js → agent-avatar-dicebear-CZeQo09T.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BPsRb9Ck.js +1 -0
- package/dist/gateway/static/root/assets/agents-BlrHMbRx.js +1 -0
- package/dist/gateway/static/root/assets/{api-DfSU0-lD.js → api-BKHmTb0w.js} +1 -1
- package/dist/gateway/static/root/assets/api-DFOlahZv.js +1 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BpYFKz7B.js → app-management-settings-panel-Bzw4fQP8.js} +1 -1
- package/dist/gateway/static/root/assets/appearance-settings-8GZpUXva.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-BkQQtIxH.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BxOvZ-ZX.js → archive-plugin-CQ2NaoHb.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-B0FzTMAJ.js → attachment-load-BFi1H7yJ.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BpXuPaPg.js → automations-page-CDBXcii_.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-CUpiTTiY.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BP7wfpqy.js → binary-plugins-D07eWmOx.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-oMLvdnOQ.js → block-editor-CtVnjyYU.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automation-inputs-DTxSZ00u.js → browser-automation-inputs-BzkJog8e.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-IbJnwEY4.js → browser-automations-page-DyrSbDdG.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-CqTxLpil.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BZ_-pnS6.js +8 -0
- package/dist/gateway/static/root/assets/channels-settings-DAD9qE3J.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-D2AmAoty.js → channels-status-swr-B2JwuTjG.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-B-yI3Mi1.js → chat-terminal-dock-B62SZdAo.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-CWx_jnng.js → computer-settings-page-ClSresNq.js} +1 -1
- package/dist/gateway/static/root/assets/connector-service-page-CPqVmNvx.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-BUQyg3CW.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-DMRRL4Zg.js → cron-expression-CTMi_tql.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-BSwL0e6E.js → date-picker-B71AJK50.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-BQTspLzC.js → dependency-picker-DlyGK-kA.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-C3lFxDF6.js → desktop-pet-DGkbTE8_.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-Y8pjpXFE.js → desktop-pet-settings-BY8r9j66.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-DzRrgd59.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-CVGiGVcR.js → extension-debug-page-L8Mm1n3A.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-g3JtCP_y.js → extension-page-CFc4vSNU.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CjpoKV1f.js → extension-settings-page-B5zWyHr3.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BSvXXpKM.js → gateway-config-swr-B6wHa6ZI.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-BDCpS7U1.js → gateway-realtime-B53R0CA4.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BLDgrJ30.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-settings-CYG9WCZn.js → gateway-settings-D7qmTH4R.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-Caf8g3sC.js → gateway-startup-retry-DRzGnEV-.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-Cl834-SS.js → heartbeat-settings-Glsl3X5b.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-s9hDQ8Hc.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-BwEWBUVC.js → image-generation-api-Ck_pyDom.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-CoMlgSIA.js → imports-page-ByBX7ome.js} +1 -1
- package/dist/gateway/static/root/assets/{index-Do9MltC4.js → index-RBCkv8a_.js} +48 -48
- package/dist/gateway/static/root/assets/index-cFU4S35z.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CNq5D4pe.js → keyboard-shortcuts-settings-C45RlO8a.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-DP0x2jpR.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-DQnRA598.js → local-apps-page-C_AQc2bI.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-D16nmbaN.js → locale-store-msTfRK8P.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DvM8Pyok.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-DKcO5fQ-.js → management-settings-D1uwSutV.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-DCp4BlZP.js → markdown-view-BInabSKf.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Cy64sn_C.js → media-plugins-C4mhf13f.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-C-9oo69N.js → messages-F74LVAiU.js} +3 -3
- package/dist/gateway/static/root/assets/note-detail-panel-D35sErp2.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-8jCDklDn.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-CgEoHSVT.js → page-tabs-1go_BtX1.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-Ck2uKTbf.js → preview-open-alternatives-DmoSC0j1.js} +1 -1
- package/dist/gateway/static/root/assets/{proactive-page-Dr1mCJhZ.js → proactive-page-xAjKTIID.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DbZvJ5GE.js → product-open-page-gmi5LLwM.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BUMQHy_N.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DT-Mt7XR.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-DcQdwpPu.js → registry-api-BSWtko7U.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Clz3byir.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CPwdgWKo.js → runtime-tools-settings-panel-ClkOoxDl.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-8psK4cFO.js → schema-form-BuEmLiaU.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-tQRwktKm.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DqWg9XS5.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-D_Gsz5rl.js → settings-form-section-Dor39QON.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-C_Tj_mkZ.js → settings-page-Xj-yvIc8.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BB_sMB7P.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-B_M_oPsT.js → share-preview-page-BFWZoXdm.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-oDALm4b6.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DmwelnfK.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-DYgwzl5B.js → skills-page-BE9JXz4U.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-Cuh6s2HM.js → skills-page.utils-Ii8qeXhs.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-aassGyNb.js → system-settings-panel-Di6OSO-0.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-D1AWszc7.js +1 -0
- package/dist/gateway/static/root/assets/theme-store-1SZ-HFHX.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-DJYcPWIV.js → tunnel-api-DDOlOYlj.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-QGYG7oMZ.js → use-autosave-CQ8uWNnB.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-C00i4ea0.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-D1s0gIRW.js → voice-api-key-field-COTzshjL.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-D2goEn5e.js → voice-config-api-DgJML_uM.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DkFW9aJ6.js → work-discovery-overlay-_URrXbi4.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BYToUPUY.js → workflow-run-setup-panel-CALs-1nd.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-BUiBjz6m.js +6 -0
- package/dist/gateway/static/root/channel-icons/feishu.svg +6 -12
- package/dist/gateway/static/root/connector-icons/SOURCES.md +12 -0
- package/dist/gateway/static/root/connector-icons/dingtalk-mark.svg +1 -0
- package/dist/gateway/static/root/connector-icons/tencent-meeting-mark.svg +37 -0
- package/dist/gateway/static/root/connector-icons/wps-calendar.svg +14 -0
- package/dist/gateway/static/root/connector-icons/wps-docs.svg +14 -0
- package/dist/gateway/static/root/connector-icons/wps-mail.svg +7 -0
- package/dist/gateway/static/root/index.html +12 -12
- package/dist/package.js +1 -1
- package/dist/src/agent/external-tools/composio-provider.js +83 -20
- package/dist/src/agent/external-tools/gateway-tools.js +2 -1
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
- package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +2 -2
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/config/schema.d.ts +12 -0
- package/dist/src/config/schema.js +4 -2
- package/dist/src/connectors/account-access.d.ts +4 -0
- package/dist/src/connectors/account-access.js +23 -0
- package/dist/src/connectors/approval-resume.d.ts +4 -0
- package/dist/src/connectors/approval-resume.js +23 -0
- package/dist/src/connectors/auth-provider-registry.d.ts +1 -0
- package/dist/src/connectors/auth-provider-registry.js +2 -1
- package/dist/src/connectors/authorization-attempts.d.ts +21 -0
- package/dist/src/connectors/authorization-attempts.js +33 -0
- package/dist/src/connectors/builtin-catalog.js +1 -3
- package/dist/src/connectors/catalog.js +2 -1
- package/dist/src/connectors/china-catalog.d.ts +2 -0
- package/dist/src/connectors/china-catalog.js +430 -0
- package/dist/src/connectors/composio-backends.d.ts +26 -0
- package/dist/src/connectors/composio-backends.js +65 -0
- package/dist/src/connectors/composio-catalog.js +2 -1
- package/dist/src/connectors/composio-managed-client.js +3 -1
- package/dist/src/connectors/composio-managed-events.js +5 -2
- package/dist/src/connectors/composio-session-types.d.ts +2 -0
- package/dist/src/connectors/composio-sessions.d.ts +11 -2
- package/dist/src/connectors/composio-sessions.js +137 -35
- package/dist/src/connectors/composio-triggers.js +4 -2
- package/dist/src/connectors/composio.d.ts +11 -8
- package/dist/src/connectors/composio.js +68 -84
- package/dist/src/connectors/connected-source-ingestion.js +4 -3
- package/dist/src/connectors/connection-recovery-service.js +25 -13
- package/dist/src/connectors/connector-identity.d.ts +2 -0
- package/dist/src/connectors/connector-identity.js +18 -5
- package/dist/src/connectors/content-enrichment.js +1 -1
- package/dist/src/connectors/instances.js +1 -7
- package/dist/src/connectors/learning-coordinator.js +4 -3
- package/dist/src/connectors/materialize.js +14 -1
- package/dist/src/connectors/policy.d.ts +1 -1
- package/dist/src/connectors/policy.js +1 -1
- package/dist/src/connectors/principal.js +24 -3
- package/dist/src/connectors/providers.d.ts +1 -0
- package/dist/src/connectors/providers.js +14 -2
- package/dist/src/connectors/runtime-adapter-registry.js +4 -9
- package/dist/src/connectors/secret-store.d.ts +4 -1
- package/dist/src/connectors/secret-store.js +7 -3
- package/dist/src/connectors/source-change-publisher.js +4 -2
- package/dist/src/connectors/types.d.ts +16 -11
- package/dist/src/connectors/workflow-preflight.d.ts +2 -1
- package/dist/src/connectors/workflow-preflight.js +20 -3
- package/dist/src/gateway/hono/routes/connectors.js +208 -17
- package/dist/src/gateway/hono/routes/context-sources.js +1 -1
- package/dist/src/gateway/hono/routes/home.js +4 -1
- package/dist/src/gateway/hono/routes/imports.js +1 -1
- package/dist/src/gateway/hono/routes/local-apps.js +1 -1
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/hono/routes/update.js +2 -2
- package/dist/src/gateway/index.js +1 -1
- package/dist/src/gateway/run-loop.js +1 -1
- package/dist/src/gateway/service.js +10 -10
- package/dist/src/infra/gateway-processes.js +1 -1
- package/dist/src/infra/update-restart.js +2 -2
- package/dist/src/infra/update-runner.js +2 -2
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/proactive/follow-ups.js +2 -1
- package/dist/src/storage/sqlite/connection-wait-repository.d.ts +3 -0
- package/dist/src/storage/sqlite/connection-wait-repository.js +63 -2
- package/dist/src/storage/sqlite/connector-account-repository.d.ts +6 -0
- package/dist/src/storage/sqlite/connector-account-repository.js +35 -7
- package/dist/src/storage/sqlite/connector-repository.js +15 -10
- package/dist/src/storage/sqlite/connector-sync-policy-repository.js +1 -1
- package/dist/src/storage/sqlite/index.js +4 -2
- package/dist/src/storage/sqlite/migrations/182_connector_account_policies.sql +92 -0
- package/dist/src/storage/sqlite/migrations/183_connector_backend_consistency.sql +20 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +7 -7
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tasks/home-query-service.js +3 -3
- package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/workflows/domain/definition.d.ts +1 -0
- package/dist/src/workflows/domain/validation.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +14 -0
- package/dist/src/workflows/service/workflow-session-bridge.d.ts +1 -0
- package/dist/src/workflows/service/workflow-session-bridge.js +1 -0
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CxOv4ivK.js +0 -1
- package/dist/gateway/static/root/assets/agents-DzKx7z3k.js +0 -1
- package/dist/gateway/static/root/assets/api-gpHh07OL.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-BQfR5vrq.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-BceB7JHZ.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-Cn_p8zY_.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CCUO3G23.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BjMb5H2_.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-P22-_i13.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BLgPORmH.js +0 -2
- package/dist/gateway/static/root/assets/device-pairing-wizard-DM4_GMzo.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BGmP1obI.js +0 -1
- package/dist/gateway/static/root/assets/home-page-CB_XVtIM.js +0 -1
- package/dist/gateway/static/root/assets/index-CI37dTAn.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-BxQlEje6.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-CT5GrcMs.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-panel-5dc3LKTL.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-AbwxgXuG.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-DnE1zI1c.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BD0nLYxk.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-TYuE6A3S.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BcWDQQFX.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DzGQX6Hq.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CE2X89qN.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BL4H9Iym.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-WMKIgUOp.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-BjeRslap.js +0 -1
- package/dist/gateway/static/root/assets/theme-store-RUBQBsFP.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-PrRsd4go.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-Z8iZe9YP.js +0 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,p as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./popover-select-9i-ZtHXL.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./cn-JdwAhgNB.js";import{a as f,c as p,i as m,n as h,r as g}from"./locale-store-msTfRK8P.js";import{t as _}from"./messages-F74LVAiU.js";import{a as v,i as y,n as b,o as x,r as S,s as C,t as w}from"./dist-BGTk37IG.js";import{i as T}from"./vendor-swr-BIWyz7Rc.js";import{t as E}from"./button-CS04eWY9.js";import{t as D}from"./skeleton-BwbyijEw.js";import{i as O,o as k}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as A}from"./settings-shell-layer-context-DCp6ykjQ.js";import{Fc as j,Hr as M,Yi as N,_n as P,an as F,bs as I,ca as L,da as R,do as z,gn as B,hn as ee,jc as te,ku as ne,tc as re,uc as ie,wc as ae}from"./index-RBCkv8a_.js";import{n as oe,r as se}from"./settings-page-layout-X1x-2Cp9.js";import{t as ce}from"./browser-BLJWD7WI.js";import{n as le}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as ue}from"./schema-form-BuEmLiaU.js";import{n as de,t as fe}from"./channels-status-swr-B2JwuTjG.js";var V=e(t(),1),H=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ce(),1),U=r();async function he(e){let t=await m(g(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>pe(e),[e]),o=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[u,f]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{f({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let p=(0,V.useCallback)(async(n,i)=>{f(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});f(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){f(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(u.payload,e.id);if(!t){f(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return f(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||f(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,u.payload]),(0,V.useEffect)(()=>{let n=u.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(f(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||f(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,u.poll]);let m=a?.[1].label??(e.configured?n.reconnect:n.connect),h=e.actions?.[`doctor.run`]?.label??n.diagnose,g=G(u.payload),_=K(u.payload,e.id),v=_?u.generatedQr:q(u.payload),y=a?.[1].result===`qr`&&(u.busy||u.payload?.type===`qr`||u.payload?.type===`poll`),b=u.payload?.type===`form`?u.payload:null,x=u.payload?.type===`diagnostics`?u.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:d(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(E,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void p(a[0]),children:[u.busy?(0,U.jsx)(l,{className:`size-4 animate-spin`}):(0,U.jsx)(j,{className:`size-4`}),m]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(E,{type:`button`,variant:`secondary`,disabled:u.busy,onClick:()=>void p(`doctor.run`),children:[(0,U.jsx)(ie,{className:`size-4`}),h]}):null]})]}),g?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:g}):null,u.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:u.error}):null,y?(0,U.jsxs)(`div`,{className:d(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:v?(0,U.jsx)(`img`,{src:v,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(D,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:d(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[v?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(D,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(D,{className:`h-4 w-36 max-w-full`})]}),_?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:_,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(c,{className:`size-3.5`})]}):null]})]}):null,u.payload?.type===`poll`&&u.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(s,{className:u.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:u.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:u.payload.message??(u.payload.ok?n.complete:n.failed)})]}):null,b?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(ue,{schema:b.schema,values:u.formDraft,onChange:e=>f(t=>({...t,formDraft:e})),disabled:u.busy,labels:o}),(0,U.jsx)(E,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void p(b.submitAction,u.formDraft),children:n.saveSetup})]}):null,x?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?d(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,O):d(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,O,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:f,footer:p,wide:m,headerExtra:h}=e,g=m===void 0?!1:m,_=n===`drawer`,[T,D]=(0,V.useState)(null),O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,U.jsx)(v,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,k)}),t[0]=O):O=t[0];let j;t[1]!==n||t[2]!==g?(j=Se(n,g),t[1]=n,t[2]=g,t[3]=j):j=t[3];let M;t[4]===s?M=t[5]:(M=s?(0,U.jsx)(C,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=M);let N;t[6]===c?N=t[7]:(N=c?(0,U.jsx)(y,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=N);let P;t[8]!==l||t[9]!==o||t[10]!==h||t[11]!==_||t[12]!==a?(P=_?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,U.jsx)(b,{asChild:!0,children:(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,U.jsx)(u,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(b,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:d(I,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,U.jsx)(u,{className:`size-4`})})}),h]}),t[8]=l,t[9]=o,t[10]=h,t[11]=_,t[12]=a,t[13]=P):P=t[13];let F=_?`p-4`:`p-6`,L;t[14]===F?L=t[15]:(L=d(`min-h-0 flex-1 overflow-y-auto`,F),t[14]=F,t[15]=L);let R;t[16]!==f||t[17]!==L?(R=(0,U.jsx)(`div`,{className:L,children:f}),t[16]=f,t[17]=L,t[18]=R):R=t[18];let z;t[19]!==p||t[20]!==T||t[21]!==M||t[22]!==N||t[23]!==P||t[24]!==R?(z=(0,U.jsxs)(A,{layer:`modal`,portalContainer:T,children:[M,N,P,R,p]}),t[19]=p,t[20]=T,t[21]=M,t[22]=N,t[23]=P,t[24]=R,t[25]=z):z=t[25];let B;t[26]!==z||t[27]!==j?(B=(0,U.jsxs)(x,{children:[O,(0,U.jsx)(S,{ref:D,className:j,onOpenAutoFocus:we,children:z})]}),t[26]=z,t[27]=j,t[28]=B):B=t[28];let ee;return t[29]!==i||t[30]!==r||t[31]!==B?(ee=(0,U.jsx)(w,{open:r,onOpenChange:i,children:B}),t[29]=i,t[30]=r,t[31]=B,t[32]=ee):ee=t[32],ee}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(N,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(E,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(E,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(E,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function De(e){return g(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await f(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=T(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?g(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await f(g(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await f(g(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ue(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Q(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function et(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let[t,n]=(0,V.useState)(!1),r=(0,V.useMemo)(()=>!e.ui?.icon||t?null:new URL(g(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,U.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,U.jsx)(R,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=d(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===u?f=t[6]:(f=d(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:u,onRestart:f}=e,p;t[0]===n?p=t[1]:(p=Y(n),t[0]=n,t[1]=p);let m=p,h,g,_,v,y,b,x;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==f||t[8]!==u||t[9]!==i||t[10]!==m.enabled||t[11]!==m.ready){let e=Xe(n,r,s),o=$e(n,s);h=!m.enabled&&m.ready?u:i===`stopped`?f:c,b=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let l;t[19]===n?l=t[20]:(l=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=l);let p;t[21]===n.label?p=t[22]:(p=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=p);let S;t[23]===i?S=t[24]:(S=d(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=Be(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==p?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[p,w]}),t[31]=w,t[32]=p,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==l?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[l,T]}),t[34]=T,t[35]=l,t[36]=E):E=t[36];let D=m.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==m.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=m.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(x=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=x):x=t[47],g=`button`,_=c,v=`mt-5 min-h-[6.25rem] text-left`,y=m.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,s)}),o.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(it)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=f,t[8]=u,t[9]=i,t[10]=m.enabled,t[11]=m.ready,t[12]=h,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x}else h=t[12],g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18];let S;t[48]!==g||t[49]!==_||t[50]!==v||t[51]!==y?(S=(0,U.jsx)(`button`,{type:g,onClick:_,className:v,children:y}),t[48]=g,t[49]=_,t[50]=v,t[51]=y,t[52]=S):S=t[52];let C=a||o,w;t[53]!==a||t[54]!==o?(w=a||o?(0,U.jsx)(l,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=w):w=t[55];let T;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?s.restartingChannel:i===`stopped`?s.restartChannel:Ze(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let D;t[61]!==h||t[62]!==w||t[63]!==T||t[64]!==C?(D=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:h,disabled:C,children:[w,T]})}),t[61]=h,t[62]=w,t[63]=T,t[64]=C,t[65]=D):D=t[65];let O;return t[66]!==D||t[67]!==b||t[68]!==x||t[69]!==S?(O=(0,U.jsxs)(`article`,{className:b,children:[x,S,D]}),t[66]=D,t[67]=b,t[68]=x,t[69]=S,t[70]=O):O=t[70],O}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:c,onRestart:u,onCheck:f,onManageConnection:p}=e,m=n===`running`?s:n===`stopped`||n===`needs_setup`?ne:l,h=n===`running`&&`text-emerald-600 dark:text-emerald-400`,g=n===`stopped`&&`text-red-600 dark:text-red-400`,_=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,v=n===`disabled`&&`text-fg-muted`,y=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,b;t[0]!==h||t[1]!==g||t[2]!==_||t[3]!==v||t[4]!==y?(b=d(`mt-0.5 size-5 shrink-0`,h,g,_,v,y),t[0]=h,t[1]=g,t[2]=_,t[3]=v,t[4]=y,t[5]=b):b=t[5];let x;t[6]!==m||t[7]!==b?(x=(0,U.jsx)(m,{className:b}),t[6]=m,t[7]=b,t[8]=x):x=t[8];let S;t[9]===c.connectionStatus?S=t[10]:(S=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=S);let C;t[11]!==c||t[12]!==n?(C=Ve(n,c),t[11]=c,t[12]=n,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[14]=C,t[15]=w);let T;t[16]!==w||t[17]!==S?(T=(0,U.jsxs)(`div`,{children:[S,w]}),t[16]=w,t[17]=S,t[18]=T):T=t[18];let D;t[19]!==T||t[20]!==x?(D=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[x,T]}),t[19]=T,t[20]=x,t[21]=D):D=t[21];let O=i||r,k;t[22]===i?k=t[23]:(k=i?(0,U.jsx)(l,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=k);let A=i?c.checkingConnection:c.checkConnection,j;t[24]!==f||t[25]!==O||t[26]!==k||t[27]!==A?(j=(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:f,children:[k,A]}),t[24]=f,t[25]=O,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,U.jsxs)(E,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,U.jsx)(l,{className:`size-4 animate-spin`}):(0,U.jsx)(te,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=M):M=t[35];let N;t[36]!==o||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==p||t[41]!==r||t[42]!==a?(N=o?(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:p,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=o,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=p,t[41]=r,t[42]=a,t[43]=N):N=t[43];let P;t[44]!==j||t[45]!==M||t[46]!==N?(P=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=P):P=t[47];let F;return t[48]!==D||t[49]!==P?(F=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[D,P]})}),t[48]=D,t[49]=P,t[50]=F):F=t[50],F}function ot(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl bg-amber-50 px-4 py-3 text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(re,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:et(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,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 i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=h(e=>e.language),t=_(e),n=p(e=>!!e.conversationId),r=i(),{channelId:s}=a(),l=P(s),u=ke(n,e),f=u.entries,{data:v,mutate:y,isValidating:b}=T(n?fe():null,de,{revalidateOnFocus:!0}),{data:x,mutate:S}=T(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),C=x?.channels??{},w=x?.bindings??[],{data:E}=T(n?`channel-routing-agents`:null,L,{revalidateOnFocus:!1}),D=z(e=>e.setPageHeader),O=z(e=>e.clearPageHeader),k=(0,V.useMemo)(()=>f.find(e=>e.id===l),[l,f]),A=k?ze(k):null,{data:j,mutate:N}=T(n&&A?Pe(A):null,()=>Fe(A)),[I,R]=(0,V.useState)(null),[te,ne]=(0,V.useState)(!1),[re,ie]=(0,V.useState)(null),[ce,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=I??j??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>k?.configSchema??{type:`object`,properties:{}},[k?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(k),[k]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=k?K??ve(w,k.id):``,Re=(0,V.useMemo)(()=>(E?.items??[]).map(e=>{let n=F(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[E?.items,t.agentsSettings]),Ve=E?.items.find(e=>e.id===E.defaultId),X=Ve?F(Ve,t.agentsSettings):E?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((v??[]).map(e=>[e.name,e])),[v]),Je=v!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([u.mutate(),y()])},[u,y]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&y(t,!1)},[y]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:u.isValidating||b,saveOk:!1,onRefresh:()=>void Q()}):null,[u.isValidating,J,n,b,Q]);(0,V.useLayoutEffect)(()=>(D({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>O()),[O,Xe,t.settingsSections.channels,D]);let Ze=(0,V.useCallback)(e=>{r(B(e)),R(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(ee),R(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await m(g(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),he(!1)},[k?.id]);let et=(0,V.useCallback)(async()=>{if(!k||!I&&K===null)return!1;let e=ze(k);ne(!0),G(null);try{let t=await m(g(`/api/config`),{method:`PATCH`,body:JSON.stringify({...I?{channels:{[e]:I}}:{},...K===null?{}:{bindings:ye(w,k.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return I&&await N(I,!1),await S(),await u.mutate(),R(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[k,K,w,u,I,S,N]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=k?.id===e.id?I:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ie(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await m(g(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await u.mutate(),await S(),await y(),k?.id===e.id&&(await N(),R(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ie(null)}},[k?.id,u,I,S,N,y,Ze]),$=k?.ui?.modal,st=$?.placement!==`replace-config`,ct=k?Ye(k):`checking`,lt=k?!Y(k).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,className:`max-w-6xl`,padding:`px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[u.isLoading?(0,U.jsx)(le,{sections:2}):u.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(u.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:f.map(e=>(0,U.jsx)(rt,{entry:e,config:C[ze(e)]?.config,runtime:Ye(e),busy:re===e.id,restarting:ce===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!k,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:k?.label??J.selectChannel,srDescription:k?.description,wide:!0,footer:k?(0,U.jsx)(Ee,{ch:J,dirty:!!I||K!==null,saving:te,onCancel:Qe,onDiscard:()=>{R(null),q(null)},onSave:et}):null,children:k?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(tt,{entry:k}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:k.label}),(0,U.jsx)(`span`,{className:d(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(k).ready&&pe(k)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,k.label):k.description}),k.docsPath?(0,U.jsxs)(`a`,{href:k.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(c,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(k).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(nt,{checked:Y(k).enabled,disabled:re===k.id,label:J.toggleChannel.replace(`{{channel}}`,k.label),onToggle:()=>void it(k)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ce===k.id,checking:b,showConnectionOptions:me,canManageConnection:Y(k).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(k),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:k,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:k,locale:e,messages:J,compact:!0,onChanged:async()=>{await N(),await Q(),await S()}},k.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(M,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(M,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(ue,{schema:De,values:_e,onChange:e=>R(e),disabled:te,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(ae,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(o,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:te||!E,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(ae,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(ue,{schema:Oe,values:_e,onChange:e=>R(e),disabled:te,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t}from"./locale-store-
|
|
1
|
+
import{a as e,r as t}from"./locale-store-msTfRK8P.js";function n(e,t){let n=Date.now()-new Date(e).getTime();return n<6e4?t.justNow:n<36e5?t.minutesAgo.replace(`{{count}}`,String(Math.floor(n/6e4))):n<864e5?t.hoursAgo.replace(`{{count}}`,String(Math.floor(n/36e5))):n<6048e5?t.daysAgo.replace(`{{count}}`,String(Math.floor(n/864e5))):new Date(e).toLocaleDateString()}function r(e,t){let r=n(e.lastActive,t);return e.channel===`telegram`&&e.peerId?`${e.accountId??`default`} · ${e.peerKind??``} · ${e.peerId} · ${r}`:`${e.channel}: ${e.chatId} · ${r}`}async function i(){return(await e(t(`/api/channels/status`))).payload?.channels||[]}async function a(n){return(await e(t(`/api/sessions/chat-ids${n?`?channel=${encodeURIComponent(n)}`:``}`))).payload?.chatIds||[]}function o(){return t(`/api/channels/status`)}var s=i;export{a as i,s as n,r,o as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./plus-Q2yW6OE7.js";import{t as i}from"./x-B_N4OPjy.js";import{n as a}from"./locale-store-D16nmbaN.js";import{t as o}from"./messages-C-9oo69N.js";import{t as s}from"./button-CS04eWY9.js";import{t as c}from"./skeleton-BwbyijEw.js";import{M as l,N as u,ba as d,j as f,oc as p}from"./index-Do9MltC4.js";var m=2,h=1,ee=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(m,Math.floor(u/e.css.cell.width)),rows:Math.max(h,Math.floor(l/e.css.cell.height))}}},g=Object.defineProperty,_=Object.getOwnPropertyDescriptor,te=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?_(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&g(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ne=`Terminal input`,re={get:()=>ne,set:e=>ne=e},ie=`Too much output to announce, navigate to rows manually to read`,b={get:()=>ie,set:e=>ie=e};function ae(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function oe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function S(e,t,n,r){e.stopPropagation(),e.clipboardData&&se(e.clipboardData.getData(`text/plain`),t,n,r)}function se(e,t,n,r){e=ae(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ce(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function le(e,t,n,r,i){ce(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function C(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function w(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ue=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},de=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},fe=``,pe=` `,me=class e{constructor(){this.fg=0,this.bg=0,this.extended=new he}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},he=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},T=class e extends me{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new he,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?C(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ge=`di$target`,_e=`di$dependencies`,ve=new Map;function ye(e){return e[_e]||[]}function E(e){if(ve.has(e))return ve.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);be(t,e,r)};return t._id=e,ve.set(e,t),t}function be(e,t,n){t[ge]===t?t[_e].push({id:e,index:n}):(t[_e]=[{id:e,index:n}],t[ge]=t)}var D=E(`BufferService`),xe=E(`CoreMouseService`),Se=E(`CoreService`),Ce=E(`CharsetService`),we=E(`InstantiationService`),Te=E(`LogService`),O=E(`OptionsService`),Ee=E(`OscLinkService`),De=E(`UnicodeService`),Oe=E(`DecorationService`),ke=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new T,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Ae(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ke=v([y(0,D),y(1,O),y(2,Ee)],ke);function Ae(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./plus-Q2yW6OE7.js";import{t as i}from"./x-B_N4OPjy.js";import{n as a}from"./locale-store-msTfRK8P.js";import{t as o}from"./messages-F74LVAiU.js";import{t as s}from"./button-CS04eWY9.js";import{t as c}from"./skeleton-BwbyijEw.js";import{M as l,N as u,ba as d,j as f,pc as p}from"./index-RBCkv8a_.js";var m=2,h=1,ee=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(m,Math.floor(u/e.css.cell.width)),rows:Math.max(h,Math.floor(l/e.css.cell.height))}}},g=Object.defineProperty,_=Object.getOwnPropertyDescriptor,te=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?_(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&g(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ne=`Terminal input`,re={get:()=>ne,set:e=>ne=e},ie=`Too much output to announce, navigate to rows manually to read`,b={get:()=>ie,set:e=>ie=e};function ae(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function oe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function S(e,t,n,r){e.stopPropagation(),e.clipboardData&&se(e.clipboardData.getData(`text/plain`),t,n,r)}function se(e,t,n,r){e=ae(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ce(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function le(e,t,n,r,i){ce(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function C(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function w(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ue=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},de=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},fe=``,pe=` `,me=class e{constructor(){this.fg=0,this.bg=0,this.extended=new he}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},he=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},T=class e extends me{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new he,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?C(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ge=`di$target`,_e=`di$dependencies`,ve=new Map;function ye(e){return e[_e]||[]}function E(e){if(ve.has(e))return ve.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);be(t,e,r)};return t._id=e,ve.set(e,t),t}function be(e,t,n){t[ge]===t?t[_e].push({id:e,index:n}):(t[_e]=[{id:e,index:n}],t[ge]=t)}var D=E(`BufferService`),xe=E(`CoreMouseService`),Se=E(`CoreService`),Ce=E(`CharsetService`),we=E(`InstantiationService`),Te=E(`LogService`),O=E(`OptionsService`),Ee=E(`OscLinkService`),De=E(`UnicodeService`),Oe=E(`DecorationService`),ke=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new T,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Ae(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ke=v([y(0,D),y(1,O),y(2,Ee)],ke);function Ae(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
2
2
|
|
|
3
3
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var je=E(`CharSizeService`),Me=E(`CoreBrowserService`),Ne=E(`MouseService`),Pe=E(`RenderService`),Fe=E(`SelectionService`),Ie=E(`CharacterJoinerService`),Le=E(`ThemeService`),Re=E(`LinkProviderService`),ze=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Ge.isErrorNoTelemetry(e)?new Ge(e.message+`
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as a}from"./globe-DSSGFWFn.js";import{a as o,n as s,r as c}from"./locale-store-D16nmbaN.js";import{t as l}from"./messages-C-9oo69N.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{t as d}from"./button-CS04eWY9.js";import{r as f}from"./gateway-config-swr-BSvXXpKM.js";import{t as p}from"./skeleton-BwbyijEw.js";import{n as m,t as h}from"./registry-api-DcQdwpPu.js";import{Jc as g,Yc as _,ac as v,li as y,mc as b,nn as x,rn as S}from"./index-Do9MltC4.js";import{n as C,r as w}from"./settings-page-layout-X1x-2Cp9.js";var T=n(),E=e(t(),1),D=r();function O({zh:e}){let t=l(e?`zh`:`en`).computerSettings,n=u(`settings-agent-defaults`,x),r=u(h,m),a=n.data?.defaults.models.computerUse?.primary??``,[o,s]=(0,E.useState)(a),[c,f]=(0,E.useState)(!1),[g,_]=(0,E.useState)(``),[v,b]=(0,E.useState)(!1);(0,E.useEffect)(()=>{s(a)},[a]);let C=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{f(!0),_(``),b(!1);try{if(!C)throw Error(t.modelUnavailable);let e=await x(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await S({...e.defaults,models:r});await n.mutate(i,!1),b(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{f(!1)}};return(0,D.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,D.jsx)(p,{className:`h-52 w-full rounded-xl`}):n.error?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,D.jsx)(d,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.modelDescription}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelScope}),r.isLoading?(0,D.jsx)(p,{className:`h-10 w-full rounded-lg`}):(0,D.jsx)(y,{value:o,onChange:e=>{s(e),b(!1)},disabled:c,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`}),!C&&!r.isLoading&&!r.error&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,D.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[String(r.error),(0,D.jsx)(d,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(d,{variant:`primary`,disabled:c||o===a||!C||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel}),(0,D.jsx)(d,{asChild:!0,variant:`ghost`,children:(0,D.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),v&&(0,D.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:t.modelSaved})]}),g&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:g})]}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelPrivacy})]})}function k(e){let t=(0,T.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,D.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base/70 text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,D.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,D.jsx)(`div`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,D.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 p-4 sm:flex-nowrap sm:p-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function A(){let e=(0,T.c)(2),t=s(j)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,D.jsx)(M,{zh:t}),e[0]=t,e[1]=n),n}function j(e){return e.language}function M({zh:e}){let t=l(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:s}=f(!0),u=n?.payload?.config,[m,h]=(0,E.useState)(!1),[y,x]=(0,E.useState)(``),[S,T]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),[M,N]=(0,E.useState)(!1),P=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,F=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,E.useEffect)(()=>{if(!P)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await P.status();e||(j(t),N(!1))}catch{e||(j(null),N(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[P]);let I=async e=>{h(!0),x(``);try{await e()}catch(e){x(e instanceof Error?e.message:String(e))}finally{h(!1)}},L=e=>I(async()=>{await o(c(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r()}),R=async()=>{x(``),T(!1);try{await P?.stop(),T(!0),P&&j(await P.status())}catch(e){x(e instanceof Error?e.message:String(e))}},z=A?.session?.status??`idle`,B=t.states[z]??z;return(0,D.jsxs)(w,{gap:`gap-7`,children:[(0,D.jsx)(C,{title:t.title,subtitle:t.subtitle,meta:(0,D.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,D.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.experimental}),(0,D.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview})]}),(0,D.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:t.experimentalDescription})]}),actions:P&&(0,D.jsxs)(d,{onClick:()=>{R()},children:[(0,D.jsx)(v,{className:`size-3.5`}),t.stop]})}),y&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:y}),S&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),A?.controlPaused&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-warning-soft p-4`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.pausedNotice}),(0,D.jsx)(d,{disabled:m,onClick:()=>{I(async()=>{P&&j(await P.resume()),T(!1)})},children:t.resume})]}),(0,D.jsx)(O,{zh:e}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!u&&!s?(0,D.jsx)(p,{className:`h-40 w-full rounded-xl`}):s?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(s),` `,(0,D.jsx)(d,{onClick:()=>{I(()=>r())},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(g,{className:`size-5`}),title:t.desktop,description:t.desktopDescription,children:(0,D.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":u?.computer?.enabled===!0,disabled:m,onClick:()=>{L(u?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,D.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${u?.computer?.enabled?`bg-accent`:`bg-fg-muted/30`}`,children:(0,D.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${u?.computer?.enabled?`translate-x-5`:`translate-x-0`}`})})})}),(0,D.jsx)(k,{icon:(0,D.jsx)(b,{className:`size-5`}),title:t.fullControl,description:(0,D.jsxs)(D.Fragment,{children:[t.fullControlDescription,(0,D.jsx)(`span`,{className:`mt-1 block text-xs`,children:P?A?.fullControl?t.fullControlEnabled:t.fullControlDisabled:t.fullControlLocalOnly})]}),children:(0,D.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.fullControl,"aria-checked":A?.fullControl===!0,disabled:m||!P||!A||M,onClick:()=>{I(async()=>{P&&j(await P.setFullControl(A?.fullControl!==!0))})},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,D.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${A?.fullControl?`bg-accent`:`bg-fg-muted/30`}`,children:(0,D.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${A?.fullControl?`translate-x-5`:`translate-x-0`}`})})})}),(0,D.jsx)(k,{icon:(0,D.jsx)(a,{className:`size-5`}),title:t.browser,description:(0,D.jsxs)(D.Fragment,{children:[t.browserDescription,(0,D.jsx)(`span`,{className:`mt-1 block text-xs`,children:u?.browser?.enabled?t.browserEnabled:t.browserDisabled})]}),children:(0,D.jsx)(d,{asChild:!0,children:(0,D.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})]}),(0,D.jsxs)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:[t.safety,` `,t.lockedDescription]})]}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),P?M?(0,D.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):A?(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(_,{className:`size-5`}),title:t.device,description:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{"aria-live":`polite`,children:[A.connected?t.connected:t.disconnected,` · `,B]}),A.reenrollmentRequired&&(0,D.jsx)(`p`,{className:`mt-1`,children:t.revoked})]}),children:A.reenrollmentRequired&&(0,D.jsx)(d,{disabled:m,onClick:()=>{I(async()=>{j(await P.reenroll())})},children:t.reenroll})}),F&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(k,{icon:(0,D.jsx)(b,{className:`size-5`}),title:t.accessibility,description:t.accessibilityDescription,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.accessibility?t.granted:t.notGranted}),!A.permissions.accessibility&&(0,D.jsx)(d,{disabled:m,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{I(()=>F.requestAccessibility())},children:t.openSettings})]}),(0,D.jsxs)(k,{icon:(0,D.jsx)(_,{className:`size-5`}),title:t.screen,description:t.screenDescription,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.screenRecording===`granted`?t.granted:t.notGranted}),A.permissions.screenRecording!==`granted`&&(0,D.jsx)(d,{disabled:m,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{I(()=>F.requestScreen())},children:t.openSettings})]})]})]}):(0,D.jsx)(`div`,{"aria-label":t.checking,children:(0,D.jsx)(p,{className:`h-52 w-full rounded-xl`})}):(0,D.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(A?.error||A?.session?.errorCode)&&(0,D.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:A.error||A.session?.errorCode})]})]})}export{A as ComputerSettingsPage,M as ComputerSettingsPanel};
|
|
1
|
+
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"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as a}from"./globe-DSSGFWFn.js";import{a as o,n as s,r as c}from"./locale-store-msTfRK8P.js";import{t as l}from"./messages-F74LVAiU.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{t as d}from"./button-CS04eWY9.js";import{r as f}from"./gateway-config-swr-B6wHa6ZI.js";import{t as p}from"./skeleton-BwbyijEw.js";import{n as m,t as h}from"./registry-api-BSWtko7U.js";import{fc as g,li as _,nl as v,nn as y,rn as b,tl as x,xc as S}from"./index-RBCkv8a_.js";import{n as C,r as w}from"./settings-page-layout-X1x-2Cp9.js";var T=n(),E=e(t(),1),D=r();function O({zh:e}){let t=l(e?`zh`:`en`).computerSettings,n=u(`settings-agent-defaults`,y),r=u(h,m),a=n.data?.defaults.models.computerUse?.primary??``,[o,s]=(0,E.useState)(a),[c,f]=(0,E.useState)(!1),[g,v]=(0,E.useState)(``),[x,S]=(0,E.useState)(!1);(0,E.useEffect)(()=>{s(a)},[a]);let C=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{f(!0),v(``),S(!1);try{if(!C)throw Error(t.modelUnavailable);let e=await y(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await b({...e.defaults,models:r});await n.mutate(i,!1),S(!0)}catch(e){v(e instanceof Error?e.message:String(e))}finally{f(!1)}};return(0,D.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,D.jsx)(p,{className:`h-52 w-full rounded-xl`}):n.error?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,D.jsx)(d,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.modelDescription}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelScope}),r.isLoading?(0,D.jsx)(p,{className:`h-10 w-full rounded-lg`}):(0,D.jsx)(_,{value:o,onChange:e=>{s(e),S(!1)},disabled:c,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`}),!C&&!r.isLoading&&!r.error&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,D.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[String(r.error),(0,D.jsx)(d,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(d,{variant:`primary`,disabled:c||o===a||!C||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel}),(0,D.jsx)(d,{asChild:!0,variant:`ghost`,children:(0,D.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),x&&(0,D.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:t.modelSaved})]}),g&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:g})]}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelPrivacy})]})}function k(e){let t=(0,T.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,D.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base/70 text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,D.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,D.jsx)(`div`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,D.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 p-4 sm:flex-nowrap sm:p-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function A(){let e=(0,T.c)(2),t=s(j)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,D.jsx)(M,{zh:t}),e[0]=t,e[1]=n),n}function j(e){return e.language}function M({zh:e}){let t=l(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:s}=f(!0),u=n?.payload?.config,[m,h]=(0,E.useState)(!1),[_,y]=(0,E.useState)(``),[b,T]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),[M,N]=(0,E.useState)(!1),P=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,F=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,E.useEffect)(()=>{if(!P)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await P.status();e||(j(t),N(!1))}catch{e||(j(null),N(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[P]);let I=async e=>{h(!0),y(``);try{await e()}catch(e){y(e instanceof Error?e.message:String(e))}finally{h(!1)}},L=e=>I(async()=>{await o(c(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r()}),R=async()=>{y(``),T(!1);try{await P?.stop(),T(!0),P&&j(await P.status())}catch(e){y(e instanceof Error?e.message:String(e))}},z=A?.session?.status??`idle`,B=t.states[z]??z;return(0,D.jsxs)(w,{gap:`gap-7`,children:[(0,D.jsx)(C,{title:t.title,subtitle:t.subtitle,meta:(0,D.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,D.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.experimental}),(0,D.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview})]}),(0,D.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:t.experimentalDescription})]}),actions:P&&(0,D.jsxs)(d,{onClick:()=>{R()},children:[(0,D.jsx)(g,{className:`size-3.5`}),t.stop]})}),_&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:_}),b&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),A?.controlPaused&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-warning-soft p-4`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.pausedNotice}),(0,D.jsx)(d,{disabled:m,onClick:()=>{I(async()=>{P&&j(await P.resume()),T(!1)})},children:t.resume})]}),(0,D.jsx)(O,{zh:e}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!u&&!s?(0,D.jsx)(p,{className:`h-40 w-full rounded-xl`}):s?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(s),` `,(0,D.jsx)(d,{onClick:()=>{I(()=>r())},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(x,{className:`size-5`}),title:t.desktop,description:t.desktopDescription,children:(0,D.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":u?.computer?.enabled===!0,disabled:m,onClick:()=>{L(u?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,D.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${u?.computer?.enabled?`bg-accent`:`bg-fg-muted/30`}`,children:(0,D.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${u?.computer?.enabled?`translate-x-5`:`translate-x-0`}`})})})}),(0,D.jsx)(k,{icon:(0,D.jsx)(S,{className:`size-5`}),title:t.fullControl,description:(0,D.jsxs)(D.Fragment,{children:[t.fullControlDescription,(0,D.jsx)(`span`,{className:`mt-1 block text-xs`,children:P?A?.fullControl?t.fullControlEnabled:t.fullControlDisabled:t.fullControlLocalOnly})]}),children:(0,D.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.fullControl,"aria-checked":A?.fullControl===!0,disabled:m||!P||!A||M,onClick:()=>{I(async()=>{P&&j(await P.setFullControl(A?.fullControl!==!0))})},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,D.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${A?.fullControl?`bg-accent`:`bg-fg-muted/30`}`,children:(0,D.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${A?.fullControl?`translate-x-5`:`translate-x-0`}`})})})}),(0,D.jsx)(k,{icon:(0,D.jsx)(a,{className:`size-5`}),title:t.browser,description:(0,D.jsxs)(D.Fragment,{children:[t.browserDescription,(0,D.jsx)(`span`,{className:`mt-1 block text-xs`,children:u?.browser?.enabled?t.browserEnabled:t.browserDisabled})]}),children:(0,D.jsx)(d,{asChild:!0,children:(0,D.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})]}),(0,D.jsxs)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:[t.safety,` `,t.lockedDescription]})]}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),P?M?(0,D.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):A?(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(v,{className:`size-5`}),title:t.device,description:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{"aria-live":`polite`,children:[A.connected?t.connected:t.disconnected,` · `,B]}),A.reenrollmentRequired&&(0,D.jsx)(`p`,{className:`mt-1`,children:t.revoked})]}),children:A.reenrollmentRequired&&(0,D.jsx)(d,{disabled:m,onClick:()=>{I(async()=>{j(await P.reenroll())})},children:t.reenroll})}),F&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(k,{icon:(0,D.jsx)(S,{className:`size-5`}),title:t.accessibility,description:t.accessibilityDescription,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.accessibility?t.granted:t.notGranted}),!A.permissions.accessibility&&(0,D.jsx)(d,{disabled:m,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{I(()=>F.requestAccessibility())},children:t.openSettings})]}),(0,D.jsxs)(k,{icon:(0,D.jsx)(v,{className:`size-5`}),title:t.screen,description:t.screenDescription,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.screenRecording===`granted`?t.granted:t.notGranted}),A.permissions.screenRecording!==`granted`&&(0,D.jsx)(d,{disabled:m,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{I(()=>F.requestScreen())},children:t.openSettings})]})]})]}):(0,D.jsx)(`div`,{"aria-label":t.checking,children:(0,D.jsx)(p,{className:`h-52 w-full rounded-xl`})}):(0,D.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(A?.error||A?.session?.errorCode)&&(0,D.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:A.error||A.session?.errorCode})]})]})}export{A as ComputerSettingsPage,M as ComputerSettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as i}from"./locale-store-msTfRK8P.js";import{t as a}from"./messages-F74LVAiU.js";import{i as o}from"./vendor-swr-BIWyz7Rc.js";import{t as s}from"./button-CS04eWY9.js";import{t as c}from"./skeleton-BwbyijEw.js";import{Xi as l,Xo as u,as as d,bo as f,cs as p,gt as m,zo as h}from"./index-RBCkv8a_.js";var g=e(t(),1),_=n();function v(){let e=i(e=>e.language),t=a(e).connectorsSettings,n=e===`zh`,{data:v,error:y,mutate:b}=o(`connector-service`,u),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(),[D,O]=(0,g.useState)();async function k(e){w(!0),E(void 0);try{await e(),S(``),await b()}catch(e){E(e instanceof Error?e.message:String(e))}finally{w(!1)}}return(0,_.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[(0,_.jsx)(r,{to:`/connectors`,className:`text-sm text-accent-fg`,children:t.title}),(0,_.jsx)(`h1`,{className:`text-xl font-semibold`,children:n?`应用连接服务`:`App connection service`}),(0,_.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`此设置决定新账号通过哪个服务连接。已有账号继续使用其原来的连接服务。`:`Choose the service for new accounts. Existing accounts keep their original service.`}),!v&&!y?(0,_.jsx)(c,{className:`h-40 w-full`}):null,v?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[(0,_.jsx)(`h2`,{className:`font-medium`,children:`XOPC Cloud`}),(0,_.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioSetupHint}),(0,_.jsx)(m,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:v.mode===`managed`&&v.configured,onConnected:()=>{b()}}),(0,_.jsx)(s,{variant:`secondary`,disabled:C||v.mode===`managed`&&v.configured,onClick:()=>void k(()=>p({mode:`managed`})),children:v.mode===`managed`?n?`当前服务`:`Current service`:n?`使用 XOPC Cloud`:`Use XOPC Cloud`})]}),(0,_.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,_.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:t.composioSetupByok}),(0,_.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,_.jsxs)(`ol`,{className:`list-inside list-decimal text-sm text-fg-muted`,children:[(0,_.jsx)(`li`,{children:t.composioSetupStepProject}),(0,_.jsx)(`li`,{children:t.composioSetupStepKey}),(0,_.jsx)(`li`,{children:t.composioSetupStepPaste})]}),(0,_.jsx)(`a`,{href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,className:`text-sm text-accent-fg`,children:t.composioSetupOpenDashboard}),(0,_.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,_.jsx)(`span`,{children:`Composio API key`}),(0,_.jsx)(f,{value:x,onChange:S,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,_.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,_.jsx)(s,{disabled:C||!x.trim(),onClick:()=>void k(()=>h(x)),children:n?`验证并使用新项目`:`Verify and use new project`}),(0,_.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n?`验证只检查连接服务和现有账号访问,不执行写入。工具权限在实际使用时检查。环境变量密钥需在运行环境中修改。`:`Verification checks service and existing account access without writes. Tool permissions are checked on use. Environment keys must be updated in the gateway environment.`}),v.backends?.filter(e=>e.mode===`byok`).map(e=>(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-sm`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`p`,{children:e.label}),(0,_.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.credentialSource===`environment`?n?`环境变量`:`Environment`:n?`本地保存`:`Stored locally`,e.verifiedAt&&` · ${new Date(e.verifiedAt).toLocaleString()}`]})]}),(0,_.jsx)(s,{variant:`ghost`,disabled:C||!x.trim()||e.credentialSource===`environment`,onClick:()=>void k(()=>h(x,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,_.jsx)(s,{variant:`ghost`,disabled:C||e.id===v.backendId,onClick:()=>void k(()=>p({backendId:e.id})),children:e.id===v.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,_.jsx)(s,{variant:`ghost`,disabled:C||e.id===v.backendId,onClick:()=>O(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,T||y?(0,_.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:T??String(y)}):null,(0,_.jsx)(l,{open:!!D,title:n?`移除连接服务`:`Remove connection service`,description:n?`移除此服务及其本地保存的密钥,不修改环境变量。需要先切换服务并断开该项目的账号,已有数据不会删除。`:`Remove this service and its saved key, without changing environment variables. Switch services and disconnect this project’s accounts first. Existing data is retained.`,confirmLabel:n?`移除`:`Remove`,cancelLabel:t.modalCancel,destructive:!0,onCancel:()=>O(void 0),onConfirm:()=>{let e=D;O(void 0),e&&k(()=>d(e))}})]})}export{v as ConnectorServicePage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,h as a,t as o}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as s,r as c,t as l}from"./popover-select-9i-ZtHXL.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./loader-circle-CifKLtgG.js";import{t as f}from"./plus-Q2yW6OE7.js";import{t as p}from"./x-B_N4OPjy.js";import{t as m}from"./cn-JdwAhgNB.js";import{a as h,c as g,n as _,r as v}from"./locale-store-msTfRK8P.js";import{t as y}from"./messages-F74LVAiU.js";import{a as b,i as x,n as S,o as C,r as w,s as T,t as E}from"./dist-BGTk37IG.js";import{n as D}from"./copy-to-clipboard-HOJ79TWv.js";import{t as O}from"./button-CS04eWY9.js";import{n as k,r as A}from"./gateway-config-swr-B6wHa6ZI.js";import{t as j}from"./skeleton-BwbyijEw.js";import{i as M,o as N}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as P}from"./electron-env-Dit0bHgy.js";import{a as F,i as I,n as L,r as R,t as z}from"./dist-Che_jiQF.js";import{$l as B,$o as V,$s as H,Al as ee,Au as U,Bo as W,Dc as te,Eo as G,G as ne,Go as re,H as ie,Ho as ae,Jo as oe,Ko as se,Ks as ce,Mc as le,Mu as ue,Qo as de,Sn as fe,Tc as pe,U as K,Uo as q,V as me,Vc as he,Vo as ge,W as J,Wo as _e,Xi as ve,Yi as ye,Yo as be,Zc as xe,Zo as Se,_s as Ce,_u as Y,bn as X,cc as we,cu as Te,do as Ee,ds as De,es as Oe,fs as ke,gs as Ae,hs as je,ht as Me,is as Ne,kc as Pe,ku as Fe,ls as Ie,ms as Le,mt as Re,nc as ze,ns as Be,os as Ve,ps as He,pt as Ue,qo as We,rs as Ge,ss as Ke,ts as qe,us as Je,vc as Ye,vs as Xe,wc as Ze,wn as Qe,xc as $e,xl as et,xn as tt,xs as nt,yn as rt,ys as it,yu as at,zc as ot}from"./index-RBCkv8a_.js";import{t as st}from"./page-tabs-1go_BtX1.js";var Z=e(t(),1),Q=n(),$=r();function ct(e){let t=(0,Q.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,d,f,p;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(lt),h=e.slice(0,2),g=Math.max(0,e.length-h.length),_=o.connect,v;t[11]!==n||t[12]!==o?(v=K(n,o),t[11]=n,t[12]=o,t[13]=v):v=t[13];let y=v,b=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,x;t[14]!==_||t[15]!==n||t[16]!==i?(x=e=>(0,$.jsxs)(O,{type:`button`,variant:`primary`,className:m(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(xe,{className:`size-4`}),_]}),t[14]=_,t[15]=n,t[16]=i,t[17]=x):x=t[17],s=x,p=`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 S;t[18]===n?S=t[19]:(S=(0,$.jsx)(ne,{connector:n}),t[18]=n,t[19]=S);let C;t[20]!==n||t[21]!==a?(C=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]=C):C=t[22];let w;t[23]===b?w=t[24]:(w=b?(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:b}):null,t[23]=b,t[24]=w);let T;t[25]!==w||t[26]!==C?(T=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[25]=w,t[26]=C,t[27]=T):T=t[27];let E;t[28]!==T||t[29]!==S?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,T]}),t[28]=T,t[29]=S,t[30]=E):E=t[30];let D;t[31]!==r||t[32]!==s?(D=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]=D):D=t[33];let k;t[34]!==r||t[35]!==o.connectedBadge?(k=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)(u,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=k):k=t[36];let A;t[37]!==D||t[38]!==k?(A=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[D,k]}),t[37]=D,t[38]=k,t[39]=A):A=t[39],t[40]!==E||t[41]!==A?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[E,A]}),t[40]=E,t[41]=A,t[42]=l):l=t[42],t[43]===y?d=t[44]:(d=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:y,children:y}),t[43]=y,t[44]=d),f=h.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[h.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)),g>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,g]}):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]=d,t[9]=f,t[10]=p}else s=t[5],c=t[6],l=t[7],d=t[8],f=t[9],p=t[10];let h;t[45]!==c||t[46]!==l||t[47]!==d||t[48]!==f?(h=(0,$.jsxs)(`div`,{className:c,children:[l,d,f]}),t[45]=c,t[46]=l,t[47]=d,t[48]=f,t[49]=h):h=t[49];let g;t[50]!==r||t[51]!==s?(g=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]=g):g=t[52];let _;return t[53]!==p||t[54]!==h||t[55]!==g?(_=(0,$.jsxs)(`div`,{className:p,children:[h,g]}),t[53]=p,t[54]=h,t[55]=g,t[56]=_):_=t[56],_}function lt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ut=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function dt(e,t){return t.some(t=>t.connectorId===e.id)}var ft=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function pt(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:m(`size-10 shrink-0 rounded-xl`,ft)}),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:m(`h-4 min-w-0 flex-1`,ft)}),(0,$.jsx)(`div`,{className:m(`h-8 w-[4.5rem] shrink-0 rounded-lg`,ft)})]}),(0,$.jsx)(`div`,{className:m(`h-3 w-full`,ft)}),(0,$.jsx)(`div`,{className:m(`h-3 w-[88%]`,ft)})]})]})}),e[1]=n):n=e[1],n}var mt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ht(){let e=(0,Q.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:m(`size-10 shrink-0 rounded-xl`,mt)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:m(`h-4 w-48 max-w-full`,mt)}),(0,$.jsx)(`div`,{className:m(`h-3 w-72 max-w-full`,mt)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsx)(`div`,{className:m(`h-9 w-20 rounded-lg`,mt)}),(0,$.jsx)(`div`,{className:m(`h-9 w-20 rounded-lg`,mt)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,$.jsx)(`div`,{className:m(`h-8 w-20 rounded-md`,mt)}),(0,$.jsx)(`div`,{className:m(`h-8 w-24 rounded-md`,mt)}),(0,$.jsx)(`div`,{className:m(`h-8 w-28 rounded-md`,mt)})]}),(0,$.jsx)(`div`,{className:m(`mt-3 h-20 rounded-xl`,mt)})]}),e[3]=i):i=e[3],i}var gt=[`understand`,`act`,`reach`];function _t(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 vt(e){return _t(e)[0]??`act`}function yt(e,t){let n=t?vt(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 bt(e,t){return t.connectorCapabilityLabels[e]??e}function xt(e,t){if(e.runtime.type===`mcp`)return J(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.sourceKind;return J(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function St(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Ct(e){let t=(0,Q.c)(9),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`h4`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(wt),t[2]=r,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:a}),t[4]=a,t[5]=o);let s;return t[6]!==i||t[7]!==o?(s=(0,$.jsxs)(`section`,{children:[i,o]}),t[6]=i,t[7]=o,t[8]=s):s=t[8],s}function wt(e){return(0,$.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,$.jsx)(`p`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Tt({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,o]=(0,Z.useState)(!1),s=K(e,i),[c,l]=(0,Z.useState)(null),[f,h]=(0,Z.useState)(null),g=_t(e),_=[...(e.setup.secrets??[]).filter(e=>e.required),...(e.setup.config??[]).filter(e=>e.required)],v=e.capabilities.filter(e=>!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)),y=async()=>{o(!0),h(null);try{l(await Ge(e))}catch(e){l(null),h(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,$.jsx)(E,{open:!0,onOpenChange:e=>{e||n()},children:(0,$.jsxs)(C,{children:[(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(w,{className:m(`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`),children:[(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:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(ne,{connector:e,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(T,{className:`text-base font-semibold text-fg`,children:e.displayName}),t?(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)(u,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]}):null]}),(0,$.jsx)(x,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:s})]})]}),(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,nt.focusRingPanel),"aria-label":i.modalClose,children:(0,$.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,children:[g.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:g.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.connectorBenefitHints[e]})]},e))})]}):null,(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsx)(ee,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.detailPermissions}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:St(e,i)})]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.connectorSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:_.length?J(i.connectorRequiredInputsCount,{count:String(_.length)}):i.connectorSetupNone})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:i.connectorTechnicalDetails}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(pe,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:xt(e,i)})]}),v.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:v.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:bt(e,i)},e))}):null,(0,$.jsxs)(O,{variant:`secondary`,disabled:a,onClick:()=>void y(),children:[a?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(ce,{className:`size-4`}),i.connectorPreviewButton]}),f?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:f}):null,c?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Ct,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,$.jsx)(Ct,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description}))}),(0,$.jsx)(Ct,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description}))})]}):null]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(O,{variant:`secondary`,children:i.modalClose})}),t?null:(0,$.jsxs)(O,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,$.jsx)(xe,{className:`size-4`}),i.connect]})]})]})]})})}var Et=m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G);function Dt(e){let t=(0,Q.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:o,onClose:s,t:c,mcp:l}=e,u;t[0]===s?u=t[1]:(u=e=>{e||s()},t[0]=s,t[1]=u);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=f):f=t[2];let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=m(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(32rem,calc(100vh-2rem))] w-[min(100%-2rem,38rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float dark:border-edge`),t[3]=h):h=t[3];let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)(ot,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=g):g=t[4];let _;t[5]===c.runtimeSettingsTitle?_=t[6]:(_=(0,$.jsx)(T,{className:`text-base font-semibold text-fg`,children:c.runtimeSettingsTitle}),t[5]=c.runtimeSettingsTitle,t[6]=_);let v;t[7]===c.runtimeSettingsHint?v=t[8]:(v=(0,$.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:c.runtimeSettingsHint}),t[7]=c.runtimeSettingsHint,t[8]=v);let y;t[9]!==_||t[10]!==v?(y=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[g,(0,$.jsxs)(`div`,{className:`min-w-0`,children:[_,v]})]}),t[9]=_,t[10]=v,t[11]=y):y=t[11];let D;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(D=m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,nt.focusRingPanel),t[12]=D):D=t[12];let k;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=k):k=t[13];let A;t[14]===c.modalClose?A=t[15]:(A=(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:D,"aria-label":c.modalClose,children:k})}),t[14]=c.modalClose,t[15]=A);let j;t[16]!==A||t[17]!==y?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[y,A]}),t[16]=A,t[17]=y,t[18]=j):j=t[18];let M;t[19]===l.idleTtlLabel?M=t[20]:(M=(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:l.idleTtlLabel}),t[19]=l.idleTtlLabel,t[20]=M);let N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=m(Et,`w-40 flex-none`),t[21]=N):N=t[21];let P=r??``,F;t[22]===a?F=t[23]:(F=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=F);let I;t[24]!==l.idleTtlPlaceholder||t[25]!==P||t[26]!==F?(I=(0,$.jsx)(`input`,{type:`number`,min:0,className:N,value:P,placeholder:l.idleTtlPlaceholder,onChange:F}),t[24]=l.idleTtlPlaceholder,t[25]=P,t[26]=F,t[27]=I):I=t[27];let L;t[28]===l.idleTtlHint?L=t[29]:(L=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:l.idleTtlHint}),t[28]=l.idleTtlHint,t[29]=L);let R;t[30]!==M||t[31]!==I||t[32]!==L?(R=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[M,I,L]})}),t[30]=M,t[31]=I,t[32]=L,t[33]=R):R=t[33];let z;t[34]!==s||t[35]!==i||t[36]!==c.modalCancel?(z=(0,$.jsx)(O,{type:`button`,variant:`secondary`,disabled:i,onClick:s,children:c.modalCancel}),t[34]=s,t[35]=i,t[36]=c.modalCancel,t[37]=z):z=t[37];let B;t[38]===o?B=t[39]:(B=()=>void o(),t[38]=o,t[39]=B);let V;t[40]===i?V=t[41]:(V=i?(0,$.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=V);let H;t[42]!==l.save||t[43]!==i||t[44]!==B||t[45]!==V?(H=(0,$.jsxs)(O,{type:`button`,variant:`primary`,disabled:i,onClick:B,children:[V,l.save]}),t[42]=l.save,t[43]=i,t[44]=B,t[45]=V,t[46]=H):H=t[46];let ee;t[47]!==z||t[48]!==H?(ee=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[z,H]}),t[47]=z,t[48]=H,t[49]=ee):ee=t[49];let U;t[50]!==j||t[51]!==R||t[52]!==ee?(U=(0,$.jsxs)(C,{children:[f,(0,$.jsxs)(w,{className:h,children:[j,R,ee]})]}),t[50]=j,t[51]=R,t[52]=ee,t[53]=U):U=t[53];let W;return t[54]!==n||t[55]!==u||t[56]!==U?(W=(0,$.jsx)(E,{open:n,onOpenChange:u,children:U}),t[54]=n,t[55]=u,t[56]=U,t[57]=W):W=t[57],W}var Ot=(0,Z.memo)(function(e){let t=(0,Q.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,o;t[0]===a?o=t[1]:(o=m(`relative flex min-h-11 sm:min-h-9 min-w-0 flex-1 cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 focus-within:ring-2 focus-within:ring-accent`,a),t[0]=a,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(te,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=s):s=t[2];let c;t[3]===r?c=t[4]:(c=e=>r(e.currentTarget.value),t[3]=r,t[4]=c);let l;t[5]!==i||t[6]!==c||t[7]!==n?(l=(0,$.jsx)(`input`,{type:`search`,"aria-label":i,enterKeyHint:`search`,value:n,onChange:c,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-base sm:text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),t[5]=i,t[6]=c,t[7]=n,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,$.jsxs)(`label`,{className:o,children:[s,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}),kt=(0,Z.memo)(function(e){let t=(0,Q.c)(25),{onBrowseCatalog:n,onAddCustomServer:r,addLabel:i,browseLabel:a,customLabel:s}=e,c=_(At)===`zh`?`应用连接服务`:`Connection service`,l;t[0]===c?l=t[1]:(l=(0,$.jsx)(o,{to:`/settings/connector-service`,className:`text-xs text-fg-muted hover:text-fg`,children:c}),t[0]=c,t[1]=l);let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(f,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(ue,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[3]=d):d=t[3];let p;t[4]===i?p=t[5]:(p=(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsxs)(O,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[u,i,d]})}),t[4]=i,t[5]=p);let h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=m(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,nt.transition),t[6]=h):h=t[6];let g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(we,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=g):g=t[7];let v;t[8]!==a||t[9]!==n?(v=(0,$.jsxs)(X,{className:h,onSelect:n,children:[g,a]}),t[8]=a,t[9]=n,t[10]=v):v=t[10];let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=m(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,nt.transition),t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(ce,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=b):b=t[12];let x;t[13]!==s||t[14]!==r?(x=(0,$.jsxs)(X,{className:y,onSelect:r,children:[b,s]}),t[13]=s,t[14]=r,t[15]=x):x=t[15];let S;t[16]!==x||t[17]!==v?(S=(0,$.jsx)(tt,{children:(0,$.jsxs)(rt,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[v,x]})}),t[16]=x,t[17]=v,t[18]=S):S=t[18];let C;t[19]!==S||t[20]!==p?(C=(0,$.jsxs)(fe,{children:[p,S]}),t[19]=S,t[20]=p,t[21]=C):C=t[21];let w;return t[22]!==C||t[23]!==l?(w=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[l,C]}),t[22]=C,t[23]=l,t[24]=w):w=t[24],w});function At(e){return e.language}var jt=/^([^:=]+)[:=](.*)$/;function Mt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}))}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=jt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function Nt(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function Pt(e){if(!e||typeof e!=`object`)return[{key:``,value:``}];let t=Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}));return t.length>0?t:[{key:``,value:``}]}function Ft(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 It(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=(t&&typeof t==`object`?t:{}).servers,r={};if(!n||typeof n!=`object`||Array.isArray(n))return r;for(let[e,t]of Object.entries(n))!t||typeof t!=`object`||Array.isArray(t)||Ft(t)&&(r[e]=t);return r}function Lt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function Rt(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 zt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=Lt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=Rt(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=Nt(e.headers);return n&&(t.headers=n),e.transport===`streamable-http`&&e.auth===`oauth`&&(t.auth={type:`oauth`,...e.oauthClientId.trim()?{clientId:e.oauthClientId.trim()}:{}}),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}function Bt(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0,o=t.auth&&typeof t.auth==`object`&&!Array.isArray(t.auth)?t.auth:void 0,s=o?.type===`oauth`?`oauth`:`none`;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:Pt(a),auth:s,oauthClientId:typeof o?.clientId==`string`?o.clientId:``,connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0,requestTimeoutMs:typeof t.requestTimeoutMs==`number`&&Number.isFinite(t.requestTimeoutMs)?t.requestTimeoutMs:void 0}}function Vt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],auth:`none`,oauthClientId:``,connectionTimeoutMs:void 0,requestTimeoutMs:void 0}}function Ht(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=t&&typeof t==`object`?t:{},r=n.servers,i=r&&typeof r==`object`&&!Array.isArray(r)?Object.entries(r).flatMap(([e,t])=>!t||typeof t!=`object`||Array.isArray(t)||Ft(t)?[]:[Bt(e,t)]).sort((e,t)=>e.id.localeCompare(t.id)):[],a=typeof n.sessionIdleTtlMs==`number`?n.sessionIdleTtlMs:void 0;return{sessionIdleTtlMinutes:a==null?void 0:a===0?0:Math.round(a/6e4),servers:i}}function Ut(e){return zt(e)}async function Wt(e,t={}){let n={};for(let r of e.servers){let e=r.id.trim();if(e){if(t[e])throw Error(`Server id "${e}" is reserved by an installed connector.`);n[e]=zt(r)}}let r={servers:{...t,...n}};e.sessionIdleTtlMinutes!=null&&Number.isFinite(e.sessionIdleTtlMinutes)&&(r.sessionIdleTtlMs=e.sessionIdleTtlMinutes===0?0:Math.round(e.sessionIdleTtlMinutes*6e4)),await h(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),k()}async function Gt(e,t,n=``){let r=await h(v(`/api/mcp/servers/${encodeURIComponent(e)}/oauth${n}`),{method:t});if(!r.payload)throw Error(r.error??`MCP OAuth request failed`);return r.payload}function Kt(e){return Gt(e,`GET`)}function qt(e){return Gt(e,`POST`,`/start`)}function Jt(e){return Gt(e,`DELETE`)}function Yt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function Xt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.uri!=`string`||typeof e.name!=`string`)continue;let r=e.uri.trim(),i=e.name.trim();!r||!i||t.push({uri:r,name:i,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,mimeType:typeof e.mimeType==`string`&&e.mimeType.trim()?e.mimeType.trim():void 0})}return t}function Zt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();r&&t.push({name:r,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,argumentCount:typeof e.argumentCount==`number`?e.argumentCount:0})}return t}async function Qt(e,t){let n=await h(v(`/api/mcp/servers/${encodeURIComponent(e)}/test`),{method:`POST`,body:t?JSON.stringify({server:t}):void 0});if(!n.payload)throw Error(n.error??`MCP test failed`);let r=Yt(n.payload.tools),i=Xt(n.payload.resources),a=Zt(n.payload.prompts);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,resourceCount:typeof n.payload.resourceCount==`number`?n.payload.resourceCount:i.length,promptCount:typeof n.payload.promptCount==`number`?n.payload.promptCount:a.length,tools:r,resources:i,prompts:a}}function $t(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function en(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>600))return n*1e3}function tn(e){return e.requestTimeoutMs==null||!Number.isFinite(e.requestTimeoutMs)?``:String(Math.round(e.requestTimeoutMs/1e3))}function nn(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>14400))return n*1e3}function rn(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function an({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),b=rn(e),x=e.transport===`streamable-http`&&e.auth===`oauth`;(0,Z.useEffect)(()=>{if(!x){_(null);return}let t=!1,n=async()=>{try{let n=await Kt(e.id.trim());t||(_(n),n.status===`error`&&n.session?.error&&h(n.session.error),n.status===`connected`&&h(null))}catch(e){t||h(e instanceof Error?e.message:String(e))}};n();let r=window.setInterval(()=>{g?.status===`authorizing`&&n()},1e3);return()=>{t=!0,window.clearInterval(r)}},[g?.status,e.id,x]);let S=(0,Z.useCallback)(async()=>{y(!0),h(null);let n=Me();try{let r=await qt(e.id.trim());_(r),r.status===`error`&&r.session?.error&&h(r.session.error),r.status===`connected`&&h(null);let i=r.session?.authorizationUrl;i?await Re(i,n)||h(t.oauthOpenFailed):Ue(n)}catch(e){Ue(n),h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.id,t.oauthOpenFailed]),C=(0,Z.useCallback)(async()=>{y(!0),h(null);try{_(await Jt(e.id.trim()))}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.id]),w=(0,Z.useCallback)(async()=>{o(!0),h(null);try{let t=await Qt(e.id.trim());p({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){h(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),T=(0,Z.useCallback)(async()=>{c(!0),h(null);try{await i()}catch(e){h(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`px-4 py-3.5 hover:bg-surface-hover/50`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:r,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]}),x&&g?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.oauthStatus[g.status===`not_configured`?`disconnected`:g.status]}):null]}),b?(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:b,children:b}):null,m?(0,$.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:m}):null,f?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:J(n.customCapabilitySummary,{tools:String(f.toolCount),resources:String(f.resourceCount),prompts:String(f.promptCount)})}):null]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[x&&g?.status!==`connected`?(0,$.jsxs)(O,{variant:`secondary`,disabled:v,onClick:()=>void S(),children:[v?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(et,{className:`size-4`}),g?.status===`authorizing`?t.oauthOpenAuthorization:t.oauthConnect]}):(0,$.jsxs)(O,{variant:`secondary`,disabled:a,onClick:()=>void w(),children:[a?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(he,{className:`size-4`}),t.testConnection]}),x&&g?.status===`connected`?(0,$.jsxs)(O,{variant:`ghost`,disabled:v,onClick:()=>void C(),children:[v?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(H,{className:`size-4`}),t.oauthDisconnect]}):null,(0,$.jsxs)(O,{variant:`ghost`,disabled:s,onClick:()=>u(!0),children:[s?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(ze,{className:`size-4`}),t.removeServer]})]})]}),(0,$.jsx)(ve,{open:l,title:n.removeConfirmTitle.replace(`{{name}}`,e.id.trim()||t.cardUntitled),description:n.removeConfirmDescription,confirmLabel:t.removeServer,cancelLabel:n.modalCancel,destructive:!0,onConfirm:()=>{u(!1),T()},onCancel:()=>{s||u(!1)}})]})}function on(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function sn(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||on(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
|
|
2
|
+
`).toLowerCase().includes(r)}function cn(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function ln(e){let t=(0,Q.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,s]=(0,Z.useState)(``),c;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>sn(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],c=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=c}else c=t[3];let l=c,u;t[7]===o?u=t[8]:(u=o.trim(),t[7]=o,t[8]=u);let d=u.length>0,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(te,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=f):f=t[9];let p,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=m(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,G),h=e=>s(e.target.value),t[10]=p,t[11]=h):(p=t[10],h=t[11]);let g;t[12]!==o||t[13]!==i?(g=(0,$.jsxs)(`div`,{className:`relative`,children:[f,(0,$.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:p,onChange:h})]}),t[12]=o,t[13]=i,t[14]=g):g=t[14];let _;t[15]!==l.length||t[16]!==d||t[17]!==n.length?(_=d?(0,$.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[l.length,` / `,n.length]}):null,t[15]=l.length,t[16]=d,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,$.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[g,_]}),t[19]=g,t[20]=_,t[21]=v):v=t[21];let y;t[22]!==l||t[23]!==a||t[24]!==r?(y=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:l.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>{let n=e.shortName||cn(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,$.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=l,t[23]=a,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function un(e){let t=(0,Q.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:o,searchPlaceholder:s,searchEmptyLabel:c,emptyLabel:l,closeLabel:u,tools:d,stripPrefix:f}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(b,{className:m(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,N)}),t[0]=h):h=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=m(`xopc-dialog-content fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,M,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(ce,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=_):_=t[2];let v;t[3]===a?v=t[4]:(v=(0,$.jsxs)(T,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[_,a]}),t[3]=a,t[4]=v);let y;t[5]!==i||t[6]!==o||t[7]!==d.length?(y=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(d.length)),t[5]=i,t[6]=o,t[7]=d.length,t[8]=y):y=t[8];let D;t[9]===y?D=t[10]:(D=(0,$.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:y}),t[9]=y,t[10]=D);let k;t[11]!==v||t[12]!==D?(k=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[v,D]}),t[11]=v,t[12]=D,t[13]=k):k=t[13];let A;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[14]=A):A=t[14];let j;t[15]===u?j=t[16]:(j=(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":u,children:A})}),t[15]=u,t[16]=j);let P;t[17]!==k||t[18]!==j?(P=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[k,j]}),t[17]=k,t[18]=j,t[19]=P):P=t[19];let F;t[20]!==l||t[21]!==n||t[22]!==c||t[23]!==s||t[24]!==i||t[25]!==f||t[26]!==d?(F=d.length>0?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,$.jsx)(ln,{tools:d,stripPrefix:f,searchPlaceholder:s,searchEmptyLabel:c},`${i}-${n?`open`:`closed`}`)}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l})}),t[20]=l,t[21]=n,t[22]=c,t[23]=s,t[24]=i,t[25]=f,t[26]=d,t[27]=F):F=t[27];let I;t[28]===u?I=t[29]:(I=(0,$.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(O,{type:`button`,variant:`secondary`,children:u})})}),t[28]=u,t[29]=I);let L;t[30]!==P||t[31]!==F||t[32]!==I?(L=(0,$.jsxs)(C,{children:[h,(0,$.jsxs)(w,{className:g,children:[P,F,I]})]}),t[30]=P,t[31]=F,t[32]=I,t[33]=L):L=t[33];let R;return t[34]!==r||t[35]!==n||t[36]!==L?(R=(0,$.jsx)(E,{open:n,onOpenChange:r,children:L}),t[34]=r,t[35]=n,t[36]=L,t[37]=R):R=t[37],R}function dn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function fn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?dn(t)-dn(e):e.isCurrentAuthorization?-1:1}function pn(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(fn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>fn(e.primary,t.primary))}var mn=m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G);function hn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function gn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function _n(e,t,n){return e.status===`connected`?J(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 vn(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 yn(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 bn({instance:e,t,onChanged:n}){let r=hn(e),i=_(e=>e.language)===`zh`,[a,o]=(0,Z.useState)([]),[l,f]=(0,Z.useState)([]),[p,h]=(0,Z.useState)([]),[g,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)([]),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)([]),[D,k]=(0,Z.useState)({}),[A,M]=(0,Z.useState)(`read`),[N,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(!1),[B,H]=(0,Z.useState)(null),[U,te]=(0,Z.useState)(null),[G,ne]=(0,Z.useState)(!1),[re,ie]=(0,Z.useState)(!1),[ae,ce]=(0,Z.useState)(!1),ue=(0,Z.useRef)(0),fe=(0,Z.useRef)(0),pe=(0,Z.useMemo)(()=>pn(a),[a]),K=(0,Z.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]),q=(0,Z.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;F(!0),L(null);let t=++ue.current;try{let e=(await Promise.allSettled([K(V()).then(e=>{t===ue.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),ne(!0))}),K(be(r)).then(e=>{t===ue.current&&M(e)}),K(oe(r)).then(e=>{t===ue.current&&(v(e.policy),b(e.agents))})])).find(e=>e.status===`rejected`);t===ue.current&&e?.status===`rejected`&&L(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===ue.current&&F(!1)}},[e.materialized,r,K]);(0,Z.useEffect)(()=>(q(),()=>{ue.current++}),[q]);let me=(0,Z.useCallback)(async()=>{if(!r)return;let e=++fe.current;ce(!0),z(!1);let t=t=>n=>{e===fe.current&&t(n)},n=await Promise.allSettled([K(Oe(r)).then(t(f)),K(qe(20)).then(t(e=>h(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),K(Se(r)).then(t(w)),K(We(r)).then(t(S))]);e===fe.current&&(z(n.some(e=>e.status===`rejected`)),ce(!1))},[r,K]);(0,Z.useEffect)(()=>(re&&me(),()=>{fe.current++}),[re,me]),(0,Z.useEffect)(()=>{let e=!1,t=pn(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return K(Be()).then(t=>{e||E(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await K(de(e.accountId))])).then(t=>{e||k(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,K]);let he=(0,Z.useCallback)(async t=>{if(!r)return;let i=P()?null:window.open(`about:blank`,`_blank`);i&&(i.opener=null),F(!0),L(null);try{if(!P()&&!i)throw Error(`Allow popups to open the authorization page.`);let a=await De(e.connectorId,t);if(!a.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(P()){let e=await window.electronAPI?.shell?.openExternalUrl(a.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else i.location.href=a.authorizationUrl;let o=await it(r,a.connectionId,12e4,a.attemptId);if(t&&o.accountId!==t)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),q()])}catch(e){L(e instanceof Error?e.message:String(e))}finally{i?.close(),F(!1)}},[e.connectorId,q,n,r]),ge=(0,Z.useCallback)(async t=>{F(!0),L(null);try{await Ce(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),q()])}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}},[e.config,e.instanceId,q,n]),_e=async e=>{let t=P()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),L(null);try{let n=await se(e.id);if(n.authorizationUrl)if(P())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 q()}catch(e){t?.close(),L(e instanceof Error?e.message:String(e))}},ye=(0,Z.useCallback)(async e=>{if(r){M(e),L(null);try{await Ie(r,e)}catch(e){L(e instanceof Error?e.message:String(e)),await q()}}},[q,r]),xe=(0,Z.useCallback)(async e=>{if(r){L(null);try{v(await Ae(r,e))}catch(e){L(e instanceof Error?e.message:String(e))}}},[r]),Y=(0,Z.useCallback)(e=>{if(!g)return;let t=g.allowedAgentIds.includes(e);t&&g.allowedAgentIds.length===1||xe({allowedAgentIds:t?g.allowedAgentIds.filter(t=>t!==e):[...g.allowedAgentIds,e]})},[xe,g]),X=(0,Z.useCallback)(async e=>{F(!0),L(null);try{await e(),await q()}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}},[q]);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 we=pe.filter(e=>e.primary.status===`active`).length,Te=we>0?t.composioAddAccount:t.composioConnectAccount,Ee=G&&we>0,ke=C?.requiresCustomAuthConfig===!0,Me=C?.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:m(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Ee?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Ee?(0,$.jsx)(u,{className:`size-3.5`}):(0,$.jsx)(Fe,{className:`size-3.5`}),Ee?t.connectionReady:G||I?t.connectionNeedsSetup:t.connectionChecking]}),G&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:J(t.composioAccountCount,{count:String(pe.length)})})]}),(0,$.jsxs)(O,{variant:`primary`,className:`shrink-0`,disabled:N,onClick:()=>void he(),children:[N?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(ee,{className:`size-4`}),Te]})]}),I?(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:I}),(0,$.jsx)(O,{variant:`secondary`,disabled:N,onClick:()=>void q(),children:t.composioRetry})]}):null,x&&!Ee?(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:_n(x,we,t)}),x.recovery===`none`?null:(0,$.jsx)(O,{variant:`secondary`,disabled:N,onClick:()=>void(x.recovery===`retry`?q():he()),children:x.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,ke&&Me.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,g?(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:A===`read`?t.composioAccessReadHint:A===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(s,{value:A,onChange:e=>void ye(e.currentTarget.value),children:[(0,$.jsx)(c,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(c,{value:`write`,children:t.composioAccessReadWrite}),A===`admin`?(0,$.jsx)(c,{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)(s,{value:g.confirmationPolicy,onChange:e=>void xe({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(c,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(c,{value:`always`,children:t.composioConfirmAlways}),g.confirmationPolicy===`never`?(0,$.jsx)(c,{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:g.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:m(`rounded-full border px-2.5 py-1 text-xs transition-colors`,g.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void xe({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),y.map(e=>(0,$.jsx)(`button`,{type:`button`,className:m(`rounded-full border px-2.5 py-1 text-xs transition-colors`,g.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>Y(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:g.selectedAccountIds===null,disabled:N,onChange:e=>void xe({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),g.selectedAccountIds!==null&&pe.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:N,checked:g.selectedAccountIds.includes(e.accountId),onChange:t=>void xe({selectedAccountIds:t.currentTarget.checked?[...g.selectedAccountIds,e.accountId]:g.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),g.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}),G&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:J(t.composioAccountCount,{count:String(pe.length)})})]}),(0,$.jsxs)(O,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:N,onClick:()=>void q(),children:[(0,$.jsx)(le,{className:m(`size-3.5`,N&&`animate-spin`)}),t.refresh]})]}),pe.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:pe.map(e=>{let r=e.primary,a=T.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?D[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:m(`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`:vn(r.status,t)}),a?(0,$.jsx)(`p`,{className:m(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:J(t.connectorLearningStatus,{status:yn(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)(O,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void _e(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(O,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:N,onClick:()=>te(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(O,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:N,onClick:()=>void he(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(O,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:N,onClick:()=>void X(()=>Le(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(O,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:N,onClick:()=>void X(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await Je(r.accountId),await n?.()}),children:[(0,$.jsx)(le,{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:N,checked:r.allowedAgentIds==null,onChange:e=>void X(()=>Le(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&y.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:N,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;X(()=>Le(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:N,onChange:e=>void X(()=>Xe(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.proactiveEnabled,disabled:N||!o.scanEnabled,onChange:e=>void X(()=>Xe(r.accountId,{proactiveEnabled:e.currentTarget.checked}))}),t.connectorProactiveUse]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(s,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:N,onChange:e=>void X(()=>Xe(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(c,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:m(mn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&X(()=>je(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)(O,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:N,onClick:()=>H(e.id),children:(0,$.jsx)(ze,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(O,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:N,onClick:()=>void X(()=>Ne(r.id)),children:(0,$.jsx)(le,{className:`size-4`})})})]})]})]},e.key)})}):N&&!G?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(j,{className:`h-16 w-full`}),(0,$.jsx)(j,{className:`h-16 w-full`})]}):G?(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=>ie(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:[ae?(0,$.jsx)(j,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,R?(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)(O,{variant:`ghost`,disabled:ae,onClick:()=>void me(),children:t.composioRetry})]}):null,C?.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:ke?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)(s,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:N,onChange:e=>void ge(e.currentTarget.value),children:[ke?null:(0,$.jsx)(c,{value:``,children:t.composioAuthConfigManaged}),ke&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(c,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,Me.map(e=>(0,$.jsxs)(c,{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:l.length?l.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:[gn(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:p.length?p.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)(ve,{open:U!==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=U;te(null),e&&X(()=>W(e))},onCancel:()=>te(null)}),(0,$.jsx)(ve,{open:B!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=B;H(null),e&&X(()=>Ke(e))},onCancel:()=>H(null)})]})}var xn=m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G);function Sn(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function Cn(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 wn(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 Tn(e){let t=(0,Q.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,$.jsx)(R,{delayDuration:300,skipDelayDuration:100,children:(0,$.jsxs)(I,{children:[(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(`p`,{tabIndex:0,title:r,className:m(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:r})}),(0,$.jsx)(L,{children:(0,$.jsx)(z,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=(0,$.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=s);let c;t[4]===i?c=t[5]:(c=i?(0,$.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:i}):null,t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,o]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}function En({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,f]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,D]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(`health`),[N,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(()=>Cn(t,e)),[L,R]=(0,Z.useState)(null),z=t?.setup.config??[],V=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&z.length>0&&(t?.setup.secrets??[]).length===0,H=k?k.toolCount:e.usage.lastToolCount,U=e.materialized.type===`mcp`,W=e.materialized.type===`composio`,te=e.materialized.type===`memorySource`,G=t?K(t,i):null,re=(0,Z.useMemo)(()=>{let t=[[`health`,$e,i.detailHealth],[`tools`,ce,`${i.detailTools} ${k?k.toolCount:e.usage.lastToolCount??``}`],[`resources`,Te,`${i.detailResources} ${k?k.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,B,`${i.detailPrompts} ${k?k.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,ee,i.detailPermissions]];return V?[...t,[`config`,Te,i.connectorConfigLabel]]:t},[k,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,V,i]),ie=(0,Z.useCallback)(async()=>{s(!0),R(null);try{let t=await He(e.instanceId);A(t),t.toolCount>0&&M(`tools`),r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e.instanceId,r]),ae=(0,Z.useCallback)(async()=>{l(!0),R(null);try{await Ve(e.instanceId),await r(),n()}catch(e){R(e instanceof Error?e.message:String(e)),l(!1)}},[e.instanceId,r,n]),oe=(0,Z.useCallback)(async()=>{if(!(!t||!V)){g(!0),R(null);try{let n={};for(let e of t.setup.config??[]){let t=wn(e.type,F[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ce(e.instanceId,{config:n}),await r(),M(`health`)}catch(e){R(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[F,t,e.instanceId,r,V]),se=(0,Z.useCallback)(async()=>{v(!0),D(null),R(null);try{D((await ke(e.connectorId)).recordIds.length),await r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{v(!1)}},[e.connectorId,r]);return(0,$.jsxs)(E,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(C,{children:[(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(w,{className:m(`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`,W?`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)(ne,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(T,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:G??(e.materialized.type===`mcp`?J(i.mcpServerRuntime,{serverId:e.materialized.serverId}):J(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(S,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,nt.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(p,{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:[L?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:L}):null,U?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:re.map(([e,t,n])=>(0,$.jsxs)(`button`,{type:`button`,className:m(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,j===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>M(e),children:[(0,$.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,$.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[j===`health`?(0,$.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,$.jsxs)(`p`,{children:[i.statusLabel,` `,(0,$.jsx)(`span`,{className:k?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:Sn(k?.status??e.usage.lastHealthStatus,i)})]}),(0,$.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),k?.action?(0,$.jsx)(`p`,{children:k.action}):null]}):null,j===`tools`?k?.tools.length?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:J(i.toolsAvailable,{count:String(k.tools.length)})}),(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>P(!0),children:a.viewAllTools})]}),(0,$.jsx)(`div`,{className:`grid gap-2`,children:k.tools.slice(0,8).map(e=>(0,$.jsx)(Tn,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:H?J(i.toolsLastCheckSummary,{count:String(H)}):i.toolsRunTestHint}),(0,$.jsxs)(O,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void ie(),children:[o?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(he,{className:`size-4`}),i.test]})]}):null,j===`resources`?k?.resources.length?(0,$.jsx)(`div`,{className:`grid gap-2`,children:k.resources.slice(0,8).map(e=>(0,$.jsx)(Tn,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,j===`prompts`?k?.prompts.length?(0,$.jsx)(`div`,{className:`grid gap-2`,children:k.prompts.slice(0,8).map(e=>(0,$.jsx)(Tn,{title:e.title??e.name,description:e.description,meta:e.argumentCount?J(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,j===`permissions`?(0,$.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,$.jsx)(`p`,{children:J(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,$.jsx)(`p`,{children:e.materialized.type===`mcp`?J(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):J(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,$.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,j===`config`&&V?(0,$.jsx)(`div`,{className:`grid gap-3`,children:z.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:xn,value:F[e.key]??``,placeholder:e.placeholder,onChange:t=>I(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]})]}):null,W?(0,$.jsx)(bn,{instance:e,t:i,onChanged:r}):null,te?(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}),G?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:G}):null,y===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:J(i.connectedSourceSynced,{count:String(y)})})]}),(0,$.jsxs)(O,{disabled:_,onClick:()=>void se(),children:[_?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(Te,{className:`size-4`}),i.composioSyncNow]})]}),V?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:z.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:xn,value:F[e.key]??``,placeholder:e.placeholder,onChange:t=>I(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!U&&!W&&!te?(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)(O,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:c,onClick:()=>f(!0),children:[c?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(ze,{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)(O,{variant:`secondary`,onClick:n,children:i.modalClose}),(U&&j===`config`||te)&&V?(0,$.jsxs)(O,{variant:`primary`,disabled:h,onClick:()=>void oe(),children:[h?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(Pe,{className:`size-4`}),i.modalSave]}):null,U?(0,$.jsxs)(O,{variant:`secondary`,disabled:o,onClick:()=>void ie(),children:[o?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(he,{className:`size-4`}),i.test]}):null]})]})]}),e.materialized.type===`mcp`?(0,$.jsx)(un,{open:N,onOpenChange:P,serverId:e.materialized.serverId,title:J(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:k?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null,(0,$.jsx)(ve,{open:u,title:J(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{f(!1),ae()},onCancel:()=>{c||f(!1)}})]})}function Dn(e){let t=(0,Q.c)(55),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i===void 0?!1:i,c;t[0]!==r||t[1]!==n?(c=yt(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c.state,d;t[3]!==r||t[4]!==o?(d=r?K(r,o):null,t[3]=r,t[4]=o,t[5]=d):d=t[5];let f=d,p,h,g,_,v,y,b,x,S;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){p=l===`ready`?{label:o.connectionReady,Icon:u,className:`text-emerald-700 dark:text-emerald-300`}:l===`needs_setup`?{label:o.connectionNeedsSetup,Icon:Fe,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:Y,className:`text-fg-muted`},x=`button`;let e=s&&`bg-accent-soft`;t[23]===e?S=t[24]:(S=m(`flex w-full items-center gap-3 px-4 py-3.5 text-left hover:bg-surface-hover/60`,`rounded-none first:rounded-t-[calc(var(--radius-xl)-1px)] last:rounded-b-[calc(var(--radius-xl)-1px)]`,nt.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e),t[23]=e,t[24]=S),t[25]!==n||t[26]!==a?(h=()=>a(n),t[25]=n,t[26]=a,t[27]=h):h=t[27],t[28]===r?g=t[29]:(g=(0,$.jsx)(ne,{connector:r}),t[28]=r,t[29]=g),b=`min-w-0 flex-1`,v=`flex min-w-0 items-center gap-2`,t[30]===n.displayName?y=t[31]:(y=(0,$.jsx)(`h3`,{className:`truncate text-sm font-medium text-fg`,children:n.displayName}),t[30]=n.displayName,t[31]=y),_=m(`inline-flex shrink-0 items-center gap-1 text-xs font-medium`,p.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]=p,t[15]=h,t[16]=g,t[17]=_,t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S}else p=t[14],h=t[15],g=t[16],_=t[17],v=t[18],y=t[19],b=t[20],x=t[21],S=t[22];let C;t[32]===p.Icon?C=t[33]:(C=(0,$.jsx)(p.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[32]=p.Icon,t[33]=C);let w;t[34]!==p.label||t[35]!==C||t[36]!==_?(w=(0,$.jsxs)(`span`,{className:_,children:[C,p.label]}),t[34]=p.label,t[35]=C,t[36]=_,t[37]=w):w=t[37];let T;t[38]!==w||t[39]!==v||t[40]!==y?(T=(0,$.jsxs)(`div`,{className:v,children:[y,w]}),t[38]=w,t[39]=v,t[40]=y,t[41]=T):T=t[41];let E;t[42]===f?E=t[43]:(E=f?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:f}):null,t[42]=f,t[43]=E);let D;t[44]!==T||t[45]!==E||t[46]!==b?(D=(0,$.jsxs)(`div`,{className:b,children:[T,E]}),t[44]=T,t[45]=E,t[46]=b,t[47]=D):D=t[47];let O;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(U,{className:`size-4 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[48]=O):O=t[48];let k;return t[49]!==h||t[50]!==g||t[51]!==D||t[52]!==x||t[53]!==S?(k=(0,$.jsxs)(`button`,{type:x,className:S,onClick:h,children:[g,D,O]}),t[49]=h,t[50]=g,t[51]=D,t[52]=x,t[53]=S,t[54]=k):k=t[54],k}function On(e,t){let n=e.length+1,r=`server-${n}`,i=new Set([...e.map(e=>e.id.trim()),...t]);for(;i.has(r);)n+=1,r=`server-${n}`;return Vt(r)}function kn(e,t,n){let r=e.key.trim();if(r)return`key:${r}`;let i=e.value.trim();return i?`value:${i}`:`empty:${n.slice(0,t).filter(e=>!e.key.trim()&&!e.value.trim()).length}`}function An(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G)}function jn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:s,headers:c,onChange:l}){let u=(e,t)=>{l(c.map((n,r)=>r===e?{...n,...t}:n))},d=()=>{l([...c,{key:``,value:``}])},f=e=>{let t=c.filter((t,n)=>n!==e);l(t.length>0?t:[{key:``,value:``}])},p=async()=>{try{let e=await D();if(!e){window.alert(a);return}let t=Mt(e);if(!t?.length){window.alert(a);return}l(t)}catch{window.alert(a)}};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]}),(0,$.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void p(),children:[(0,$.jsx)(at,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{className:m(An(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>u(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:m(An(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:s,onChange:e=>u(t,{value:e.target.value})}),(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:c.length<=1&&!e.key&&!e.value,onClick:()=>f(t),"aria-label":r,children:(0,$.jsx)(ze,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},kn(e,t,c)))}),(0,$.jsxs)(`button`,{type:`button`,className:m(`self-start text-sm text-accent hover:underline`,nt.press),onClick:d,children:[`+ `,n]})]})}var Mn=[`stdio`,`sse`,`streamable-http`],Nn=[`none`,`oauth`];function Pn(e){let t=(0,Q.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,$.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,$.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function Fn(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G)}function In(e){let t=(0,Q.c)(37),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:o}=e,l=o===void 0?`all`:o,u=l===`all`||l===`basic`,d=l===`all`||l===`advanced`,f;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==u||t[5]!==r?(f=u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pn,{label:r.transportLabel,required:!0,children:(0,$.jsx)(s,{className:Fn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:Mn.map(e=>(0,$.jsx)(c,{value:e,children:r.transportLabels[e]},e))})}),(0,$.jsxs)(Pn,{label:r.serverIdLabel,required:!0,children:[(0,$.jsx)(`input`,{className:Fn(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:a}):null]})]}):null,t[0]=a,t[1]=i,t[2]=n.id,t[3]=n.transport,t[4]=u,t[5]=r,t[6]=f):f=t[6];let p;t[7]!==i||t[8]!==n.argsText||t[9]!==n.auth||t[10]!==n.command||t[11]!==n.cwd||t[12]!==n.envJson||t[13]!==n.headers||t[14]!==n.oauthClientId||t[15]!==n.transport||t[16]!==n.url||t[17]!==d||t[18]!==u||t[19]!==r||t[20]!==l?(p=n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(`div`,{className:l===`basic`?`md:col-span-2`:void 0,children:(0,$.jsx)(Pn,{label:r.commandLabel,required:!0,children:(0,$.jsx)(`input`,{className:Fn(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pn,{label:r.argsLabel,description:r.argsHint,children:(0,$.jsx)(`input`,{className:Fn(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,$.jsx)(Pn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Fn(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,$.jsx)(Pn,{label:r.envLabel,description:r.envHint,children:(0,$.jsx)(`textarea`,{className:m(Fn(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(`div`,{className:`md:col-span-2`,children:(0,$.jsx)(Pn,{label:r.urlLabel,required:!0,children:(0,$.jsx)(`input`,{className:m(Fn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u&&n.transport===`streamable-http`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pn,{label:r.authLabel,description:r.authHint,children:(0,$.jsx)(s,{className:Fn(),value:n.auth,onChange:e=>{let t=e.target.value;i({auth:t,headers:t===`oauth`?n.headers.filter(Rn):n.headers})},children:Nn.map(e=>(0,$.jsx)(c,{value:e,children:r.authLabels[e]},e))})}),n.auth===`oauth`?(0,$.jsx)(Pn,{label:r.oauthClientIdLabel,description:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:m(Fn(),`font-mono text-xs`),value:n.oauthClientId,placeholder:r.oauthClientIdPlaceholder,onChange:e=>i({oauthClientId:e.target.value})})}):null]}):null,d?(0,$.jsx)(jn,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>i({headers:n.auth===`oauth`?e.filter(Ln):e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.auth,t[10]=n.command,t[11]=n.cwd,t[12]=n.envJson,t[13]=n.headers,t[14]=n.oauthClientId,t[15]=n.transport,t[16]=n.url,t[17]=d,t[18]=u,t[19]=r,t[20]=l,t[21]=p):p=t[21];let h;t[22]!==i||t[23]!==n||t[24]!==d||t[25]!==r?(h=d?(0,$.jsx)(Pn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:600,className:Fn(),value:$t(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:en(e.target.value)})})}):null,t[22]=i,t[23]=n,t[24]=d,t[25]=r,t[26]=h):h=t[26];let g;t[27]!==i||t[28]!==n||t[29]!==d||t[30]!==r?(g=d?(0,$.jsx)(Pn,{label:r.requestTimeoutLabel,description:r.requestTimeoutHint,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:14400,className:Fn(),value:tn(n),placeholder:r.requestTimeoutPlaceholder,onChange:e=>i({requestTimeoutMs:nn(e.target.value)})})}):null,t[27]=i,t[28]=n,t[29]=d,t[30]=r,t[31]=g):g=t[31];let _;return t[32]!==f||t[33]!==p||t[34]!==h||t[35]!==g?(_=(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[f,p,h,g]}),t[32]=f,t[33]=p,t[34]=h,t[35]=g,t[36]=_):_=t[36],_}function Ln(e){return e.key.trim().toLowerCase()!==`authorization`}function Rn(e){return e.key.trim().toLowerCase()!==`authorization`}function zn(e,t){if(e.shortName)return e.shortName;let n=`${t.trim()}__`;return n&&e.name.startsWith(n)?e.name.slice(n.length):e.name}function Bn(e){let t=(0,Q.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=zn(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o=n.name===a?a:n.name,s;t[3]===n.description?s=t[4]:(s=n.description?.trim(),t[3]=n.description,t[4]=s);let c=s,l;t[5]!==a||t[6]!==o?(l=(0,$.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:o,children:a}),t[5]=a,t[6]=o,t[7]=l):l=t[7];let u;t[8]===c?u=t[9]:(u=c?(0,$.jsx)(R,{delayDuration:300,skipDelayDuration:100,children:(0,$.jsxs)(I,{children:[(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(`p`,{tabIndex:0,title:c,className:m(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:c})}),(0,$.jsx)(L,{children:(0,$.jsx)(z,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:c})})})]})}):null,t[8]=c,t[9]=u);let d;return t[10]!==l||t[11]!==u?(d=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Vn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:o,t:s,cs:c,onClose:l,onSaved:f}){let[h,g]=(0,Z.useState)(n),[_,v]=(0,Z.useState)(!1),[y,D]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)({status:`idle`}),[F,I]=(0,Z.useState)(null),L=n.id.trim(),R=h.id.trim()!==L&&o.has(h.id.trim())||o.has(h.id.trim())&&t===`add`?s.reservedServerId:void 0,z=h.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===h.id.trim())?c.duplicateServerId:void 0,B=h.id.trim().length>0&&!R&&!z&&(h.transport===`stdio`?h.command.trim().length>0:h.url.trim().length>0),V=!(h.transport===`streamable-http`&&h.auth===`oauth`),H=rn(h),ee=(0,Z.useCallback)(async()=>{if(h.id.trim()){D(!0),A(null),P({status:`loading`});try{P({status:`ok`,tools:(await Qt(h.id.trim(),Ut(h))).tools})}catch(e){P({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{D(!1)}}},[h]),U=(0,Z.useCallback)(async()=>{if(!(!B||_)){v(!0),A(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(h),await Wt({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},It(a)),await f(),l()}catch(e){A(e instanceof Error?e.message:String(e))}finally{v(!1)}}},[B,a,r,n.clientKey,t,l,f,L,h,_,i]);return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{open:e,onOpenChange:e=>{e||l()},children:(0,$.jsxs)(C,{children:[(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(w,{className:m(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float 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:`min-w-0`,children:[(0,$.jsx)(T,{className:`text-base font-semibold text-fg`,children:t===`add`?c.addCustomServerTitle:c.editCustomServerTitle}),(0,$.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?c.addCustomServerHint:c.editCustomServerHint})]}),(0,$.jsx)(S,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,nt.focusRingPanel),"aria-label":c.modalClose,children:[(0,$.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:c.modalClose})]})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(pe,{className:`size-4 text-accent`,"aria-hidden":!0}),h.id.trim()||s.cardUntitled]}),(0,$.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:H||(h.transport===`stdio`?s.commandLabel:s.urlLabel)})]}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:s.transportLabels[h.transport]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectorBasicConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.connectorBasicConfigHint})]}),(0,$.jsx)(In,{row:h,t:s,variant:`basic`,onUpdate:e=>{g(t=>({...t,...e})),A(null)},idConflictMessage:R??z})]}),N.status===`ok`?(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(ce,{className:`size-4 text-accent`,"aria-hidden":!0}),N.tools.length===0?s.toolsEmpty:s.toolsTitle.replace(`{{count}}`,String(N.tools.length))]}),N.tools.length>0?(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>I(N.tools),children:s.viewAllTools}):null]}),N.tools.length>0?(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:N.tools.slice(0,6).map((e,t)=>(0,$.jsx)(Bn,{tool:e,serverId:h.id},e.name||`tool-${t}`))}):null]}):null,N.status===`error`?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:N.message}):null,k?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:k}):null,(0,$.jsxs)(`details`,{open:j,onToggle:e=>M(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,$.jsx)(ue,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`group-open:hidden`,children:c.connectorShowAdvancedConfig}),(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:c.connectorHideAdvancedConfig})]}),(0,$.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,$.jsx)(In,{row:h,t:s,variant:`advanced`,onUpdate:e=>{g(t=>({...t,...e})),A(null)}})})]})]})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsxs)(O,{variant:`secondary`,disabled:!h.id.trim()||y||!V,title:V?void 0:s.oauthSaveBeforeTest,onClick:()=>void ee(),children:[y?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(he,{className:`size-4`}),s.testConnection]}),(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(O,{variant:`secondary`,children:c.modalCancel})}),(0,$.jsxs)(O,{variant:`primary`,disabled:!B||_,onClick:()=>void U(),children:[_?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(u,{className:`size-4`}),_?s.saving:c.modalSave]})]})]})]})}),F?(0,$.jsx)(un,{open:!0,onOpenChange:e=>{e||I(null)},serverId:h.id,title:s.toolsDialogTitle,subtitle:s.toolsDialogSubtitle,searchPlaceholder:s.toolsDialogSearchPlaceholder,searchEmptyLabel:s.toolsDialogSearchEmpty,emptyLabel:s.toolsEmpty,closeLabel:s.toolsDialogClose,tools:F,stripPrefix:`${h.id.trim()}__`}):null]}):null}var Hn=`builtin`,Un=`composio`,Wn=`xopc-store`;function Gn(e){return Hn}function Kn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function qn(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.description,e.category,e.kind,e.source,...e.tags??[]].some(e=>e.toLowerCase().includes(n)):!0}function Jn(e,t,n){return e.filter(e=>qn(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Yn(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.connectorId,e.instanceId,e.status,e.connectionStatus??``,e.materialized.type,e.materialized.type===`mcp`?e.materialized.serverId:e.materialized.id].some(e=>e.toLowerCase().includes(n)):!0}function Xn(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function Zn(e){let t=e.connectorManifest;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;if(n.contractVersion!==1||n.id!==e.name)return null;let r=n.runtime,i=n.auth;if(!r||typeof r!=`object`||Array.isArray(r)||!i||typeof i!=`object`||Array.isArray(i))return null;let a=r,o=i;if(a.type!==`mcp`||typeof a.serverId!=`string`)return null;let s=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(n.category??``))?n.category:`custom`,c=o.mode===`oauth`?{mode:`oauth`,...typeof o.clientId==`string`?{clientId:o.clientId}:{}}:o.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`};return{id:e.name,version:e.latestVersion??`store`,displayName:typeof n.displayName==`string`?n.displayName:e.name,description:typeof n.description==`string`?n.description:e.description,category:s,kind:`mcp`,source:`store`,capabilities:Array.isArray(n.capabilities)?n.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(n.tags)?n.tags.filter(e=>typeof e==`string`):[`store`],auth:c,setup:n.setup&&typeof n.setup==`object`&&!Array.isArray(n.setup)?n.setup:{},runtime:{type:`mcp`,serverId:a.serverId}}}function Qn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function $n(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function er(){let e=y(_(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=g(e=>e.conversationId),o=!!r,s=i(),[c,u]=a(),f=c.get(`understanding`)===`1`,p=$n(c.get(`returnTo`)),h=c.get(`tab`),[v,b]=(0,Z.useState)(!f&&h===`connected`?`connected`:`discover`),x=(0,Z.useRef)(!1),[S,C]=(0,Z.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[k,j]=(0,Z.useState)(1),[M,N]=(0,Z.useState)(void 0),[P,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)(f?c.get(`connector`)??``:``),[R,z]=(0,Z.useState)(Gn(f?`understanding`:`default`)),[B,V]=(0,Z.useState)(`name`),[H,ee]=(0,Z.useState)(f?`understand`:`all`),[U,W]=(0,Z.useState)(null),[te,G]=(0,Z.useState)(null),[ne,oe]=(0,Z.useState)(null),[se,ce]=(0,Z.useState)(null),[le,ue]=(0,Z.useState)(null),[de,fe]=(0,Z.useState)(null),[pe,K]=(0,Z.useState)(!1),[he,J]=(0,Z.useState)(void 0),[ve,be]=(0,Z.useState)(!1),{data:xe,mutate:Se}=A(o),Ce=xe?.payload?.config,Y=(0,Z.useMemo)(()=>Ce===void 0?null:Ht(Ce),[Ce]),X=Y?.servers??[],we=S.instances.length+X.length;(0,Z.useEffect)(()=>{Y&&J(Y.sessionIdleTtlMinutes)},[Y]);let Te=(0,Z.useCallback)(async()=>{if(!r){C({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}C(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([ae(),q()]);C(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){C({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,Z.useEffect)(()=>{Te()},[Te]),(0,Z.useEffect)(()=>{x.current||S.loading||o&&!Y||(b(f?`discover`:we>0?`connected`:`discover`),x.current=!0)},[o,we,Y,f,S.loading]);let De=(0,Z.useCallback)(e=>{x.current=!0,b(e)},[]),Oe=(0,Z.useMemo)(()=>[{id:Un,displayName:t.composioSourceName},{id:Wn,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),ke=(0,Z.useCallback)(async e=>{if(!o||R===`builtin`){C(e=>({...e,registryCatalog:[]})),j(1),N(void 0);return}let t=I.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=R===`all`?Oe:Oe.filter(e=>e.id===R);if(i.length!==0){T(!0),r?C(e=>({...e,error:null})):(j(1),N(void 0),C(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await ge({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await _e({q:t||void 0,page:n,pageSize:24,sort:B===`source`?`newest`:`downloads`});return{connectors:r.items.flatMap(e=>{let t=Zn(e);return t?[t]:[]}),totalPages:r.meta.totalPages}})),a=Qn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));j(n),N(o),C(e=>({...e,registryCatalog:r?Qn([...e.registryCatalog,...a]):a}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{T(!1)}}},[B,I,R,o,Oe]);(0,Z.useEffect)(()=>{if(v!==`discover`||S.loading)return;if(R===`builtin`){C(e=>({...e,registryCatalog:[]})),j(1),N(void 0);return}let e=window.setTimeout(()=>{ke()},I.trim()?350:0);return()=>window.clearTimeout(e)},[I,R,ke,S.loading,v]);let Ae=(0,Z.useMemo)(()=>new Set(S.instances.map(e=>e.connectorId)),[S.instances]),je=(0,Z.useMemo)(()=>new Map([...S.catalog,...S.registryCatalog].map(e=>[e.id,e])),[S.catalog,S.registryCatalog]);(0,Z.useEffect)(()=>{if(S.loading)return;let e=c.get(`connector`),t=c.get(`instance`);if(!e&&!t)return;let n=S.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)x.current=!0,F(``),oe(n.instanceId),ce(n),b(`connected`);else if(e){let t=je.get(e);if(!t)return;x.current=!0,z(Gn(f?`understanding`:`default`)),L(``),G(t),b(`discover`)}let r=new URLSearchParams(c);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),u(r,{replace:!0})},[je,f,c,u,S.instances,S.loading]);let Me=(0,Z.useCallback)(async e=>{D(!0),C(e=>({...e,error:null}));try{let t=await re(e);W(me(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{D(!1)}},[]),Ne=(0,Z.useMemo)(()=>new Set(S.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[S.instances]),Pe=(0,Z.useCallback)(async e=>{if(!Y||Ce===void 0)return;let t=X.filter(t=>t.clientKey!==e.clientKey);await Wt({sessionIdleTtlMinutes:Y.sessionIdleTtlMinutes,servers:t},It(Ce)),await Se(),await Te()},[Ce,X,Te,Y,Se]),Fe=(0,Z.useCallback)(()=>{fe({mode:`add`,row:On(X,Ne)})},[X,Ne]),Ie=(0,Z.useCallback)(async()=>{if(!(!Y||Ce===void 0||ve)){be(!0);try{await Wt({sessionIdleTtlMinutes:he,servers:X},It(Ce)),await Se(),K(!1)}finally{be(!1)}}},[Ce,X,n.saved,Y,Se,he,ve]),Le=Ee(e=>e.setPageHeader),Re=Ee(e=>e.clearPageHeader),ze=(0,Z.useMemo)(()=>(0,$.jsx)(kt,{onBrowseCatalog:()=>De(`discover`),onAddCustomServer:Fe,addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced}),[t,Fe,De]);(0,Z.useLayoutEffect)(()=>(Le({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:t.title})}),end:ze}),()=>Re()),[Re,t.title,ze,Le]);let Be=(0,Z.useMemo)(()=>S.instances.map(e=>({instance:e,value:yt(e,je.get(e.connectorId))})),[je,S.instances]),Ve=(0,Z.useMemo)(()=>new Map(Be.map(({instance:e,value:t})=>[e.instanceId,t])),[Be]),He=(0,Z.useMemo)(()=>S.instances.filter(e=>Yn(e,P)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ve.get(e.instanceId)?.state??`checking`,i=Ve.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[P,Ve,S.instances]),Ue=(0,Z.useMemo)(()=>He.filter(e=>Ve.get(e.instanceId)?.state===`needs_setup`),[Ve,He]),We=(0,Z.useMemo)(()=>He.filter(e=>Ve.get(e.instanceId)?.state!==`needs_setup`),[Ve,He]),Ge=(0,Z.useMemo)(()=>X.filter(e=>Xn(e,P)),[P,X]),Ke=He.length+Ge.length,qe=(0,Z.useMemo)(()=>S.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Kn(e)),[S.catalog]),Je=(0,Z.useMemo)(()=>R===`builtin`?qe:R===`all`?Qn([...qe,...S.registryCatalog]):S.registryCatalog,[qe,R,S.registryCatalog]),Xe=(0,Z.useMemo)(()=>{let e=f?Je.filter(e=>e.understanding?.mode===`activity`):Je;return Jn(H===`all`?e:e.filter(e=>_t(e).includes(H)),I,B)},[B,I,Je,f,H]),Qe=(0,Z.useMemo)(()=>gt.filter(e=>Je.some(t=>_t(t).includes(e))),[Je]);(0,Z.useEffect)(()=>{H!==`all`&&!Qe.includes(H)&&ee(`all`)},[Qe,H]);let $e=v===`discover`&&R!==`builtin`&&!!(M&&k<M),et=(0,Z.useMemo)(()=>S.instances.find(e=>e.instanceId===ne)??se,[ne,se,S.instances]),tt=(0,Z.useMemo)(()=>[{value:`all`,label:t.discoverSourceAll},{value:Hn,label:t.discoverSourceBuiltin},...Oe.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Oe]),nt=[{id:`connected`,label:t.tabConnected,count:we},{id:`discover`,label:t.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:`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[o?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),f?(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:t.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.understandingSetupHint})]}),(0,$.jsx)(O,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>s(p),children:t.understandingSetupDone})]}):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)(st,{items:nt,activeTab:v,onChange:De,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),S.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S.error}):null,v===`connected`&&o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[we>5||P?(0,$.jsx)(Ot,{value:P,onChange:F,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}):(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(ye,{className:`size-9 shrink-0 p-0`,loading:S.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:Te})]}),S.loading?(0,$.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:ut.slice(0,3).map(e=>(0,$.jsx)(ht,{},e))}):we===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,$.jsx)(O,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>De(`discover`),children:t.addFromCatalog})]}):Ke===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[Ue.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:t.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:Ue.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-amber-500/25 bg-amber-500/5`,children:Ue.map(e=>(0,$.jsx)(Dn,{instance:e,definition:je.get(e.connectorId),highlighted:e.instanceId===le,onOpenDetails:e=>{ue(null),oe(e.instanceId),ce(e)},t},e.instanceId))})]}):null,We.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:t.connectedServicesTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-fg-subtle`,children:We.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:We.map(e=>(0,$.jsx)(Dn,{instance:e,definition:je.get(e.connectorId),highlighted:e.instanceId===le,onOpenDetails:e=>{ue(null),oe(e.instanceId),ce(e)},t},e.instanceId))})]}):null,Ge.length||!P.trim()?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.customIntegrationsTitle}),(0,$.jsx)(`span`,{className:`ml-2 text-xs tabular-nums text-fg-subtle`,children:Ge.length}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.customIntegrationsHint})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-3`,children:[(0,$.jsx)(O,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:Fe,children:t.addCustomServerAdvanced}),(0,$.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>K(!0),children:[(0,$.jsx)(Ze,{className:`size-3.5`}),t.runtimeSettings]})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:Ge.map(e=>(0,$.jsx)(an,{row:e,t:n,cs:t,onEdit:()=>fe({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Pe(e)},e.clientKey))})]})]}):null]})]}):null,v===`discover`&&o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f?null:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.taskFilterAria,children:[`all`,...Qe].map(e=>(0,$.jsx)(`button`,{type:`button`,className:m(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,H===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":H===e,onClick:()=>ee(e),children:e===`all`?t.taskAll:t.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,$.jsx)(Ot,{value:I,onChange:L,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,$.jsxs)(`details`,{className:`relative shrink-0 lg:ml-auto`,children:[(0,$.jsxs)(`summary`,{className:`flex h-9 cursor-pointer list-none items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,$.jsx)(Ye,{className:`size-3.5`,"aria-hidden":!0}),t.filters]}),(0,$.jsxs)(`div`,{className:m(`mt-2 grid min-w-[15rem] grid-cols-1 gap-2 rounded-xl border border-edge bg-surface-panel p-3 shadow-popover sm:absolute sm:right-0 sm:z-10`,!f&&`sm:min-w-[24rem] sm:grid-cols-2`),children:[f?null:(0,$.jsx)(l,{value:R,options:tt,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:z}),(0,$.jsx)(l,{value:B,options:[{value:`name`,label:t.sortName},{value:`source`,label:t.sortSource}],placeholder:t.sortName,allowEmpty:!1,ariaLabel:t.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>V(e)})]})]})]}),(S.loading||w)&&Xe.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:ut.map(e=>(0,$.jsx)(pt,{},e))}):Xe.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[w?(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":t.loading,children:(0,$.jsx)(d,{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:Xe.map(e=>(0,$.jsx)(ct,{connector:e,installed:Ae.has(e.id)||dt(e,S.instances),onInstall:e=>{if(e.source===`store`){Me(e.id);return}W(me(e))},onOpenDetails:e.source===`store`?void 0:G,t},e.id))}),$e?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(O,{type:`button`,variant:`secondary`,disabled:w||E,onClick:()=>void ke({page:k+1,append:!0}),children:[w?(0,$.jsx)(d,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),U?(0,$.jsx)(ie,{draft:U,onChange:W,onClose:()=>W(null),t,onInstalled:async e=>{await Te(),await Se(),ue(e.instanceId),De(`connected`)}}):null,te?(0,$.jsx)(Tt,{connector:te,installed:Ae.has(te.id)||dt(te,S.instances),onClose:()=>G(null),onInstall:e=>W(me(e)),t}):null,et?(0,$.jsx)(En,{instance:et,definition:je.get(et.connectorId),onClose:()=>{oe(null),ce(null)},onChanged:Te,t,mcp:n}):null,de?(0,$.jsx)(Vn,{open:!0,mode:de.mode,initialRow:de.row,existingCustomServers:X,sessionIdleTtlMinutes:he,config:Ce,managedServerIds:Ne,t:n,cs:t,onClose:()=>fe(null),onSaved:async()=>{await Se(),await Te(),De(`connected`)}},`${de.mode}-${de.row.clientKey}`):null,(0,$.jsx)(Dt,{open:pe,sessionIdleTtlMinutes:he,saving:ve,onChange:J,onSave:Ie,onClose:()=>K(!1),t,mcp:n})]})})}export{er as ConnectorsPage};
|