@xopcai/xopc 0.0.161 → 0.0.162
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-o7GRljfD.js → activity-store-hpcNv9MZ.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-9R3szLMc.js → agent-avatar-dicebear-Zf9UQEmQ.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DfVkZlHc.js +2 -0
- package/dist/gateway/static/root/assets/{api-jSTqFMq9.js → api-Dnatri09.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-D81cyE76.js → app-management-settings-panel-BBTR9wJP.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Ct6bZQCV.js → appearance-settings-C2zpLCHD.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BMtAa4Ra.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CfD7AZKn.js → archive-plugin-9eR_ODY1.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CP_Gaxt3.js → attachment-load-DPuWYUeX.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-BGKM_NDZ.js → automation-suggestion-card-Dw49OJRl.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-BiSAMYTr.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-IPr2EVnS.js → binary-plugins-BdkJpDFm.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-B6aHEGA6.js → block-editor-CAi7SXYU.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-DHmaEJS2.js +8 -0
- package/dist/gateway/static/root/assets/browser-workflow-inputs-Dx6wkGz1.js +1 -0
- package/dist/gateway/static/root/assets/browser-workflows-page-Skertc-A.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-B5wSgf4f.js +2 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-CCX9-LjU.js → capability-presets-api-CNFl7dM3.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DyvFZwBj.js +2 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-MmLMLDWf.js → channel-recipient-api-DYQyGDw4.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-BBKEqDZn.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-Drk110ve.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-BbjzIs87.js → connector-logo-Bng6kxYF.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-HpgaUDQ1.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-Bpf6oegd.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DQLqGLc0.js → desktop-pet-settings-BVUyefSd.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-ClsiXhmz.js → directory-picker-path-field-DjSZAPz_.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CjMPPdzg.js → dreaming-settings-CAZk2AM4.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-57eizjhB.js → extension-debug-page-C2F6vTTd.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CsbSb3u1.js → extension-page-AnIt4bn4.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DKA9-lyP.js → extension-settings-page-CLSc6682.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-DIPJuzBZ.js → gateway-config-api-DLFyZv33.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CDLqAQY7.js → gateway-settings-DnQAA-qq.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DrfSJtvT.js → gateway-startup-retry-DbzLyJ3R.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-DrnKFC6M.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-Cw1hpJkZ.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-lGC10UkU.js → goals-config-api-REmr3QCr.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BDGkTVma.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-BWq0pdrA.js → goals-settings-Dz0F3uRO.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-D4o8BJVv.js → heartbeat-settings-CQFY5gYs.js} +1 -1
- package/dist/gateway/static/root/assets/index-C8JkTS6d.js +199 -0
- package/dist/gateway/static/root/assets/index-hmrG55qg.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-6T2QYehS.js → keyboard-shortcuts-settings-BnOQXU5k.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Bdef1b7F.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-DCjg2K9f.js → local-apps-page-KsOtWOyM.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Dar-xqQr.js → locale-store-0lpYdNDr.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CyYCBqym.js → logs-page-CwLPgrWh.js} +3 -3
- package/dist/gateway/static/root/assets/{markdown-split-rt1XO43g.js → markdown-split-D5GRg10r.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Bwo8CJuh.js → media-plugins-C1ryULGs.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BwQ3WssU.js +5 -0
- package/dist/gateway/static/root/assets/{notes-page-Dp-pkX7d.js → notes-page-CIeZ1_DT.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-Cf06q19x.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-CzZ4iKOb.js → page-tabs-Caj1-E_X.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-3E_Qa-58.js → preview-open-alternatives-DKwEce-9.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-B2T48Sbt.js → product-open-page-B90ZskkN.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-SHTurM4t.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BcC2qUAw.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-6vGefBHv.js +1 -0
- package/dist/gateway/static/root/assets/save-bar-controls-BDYt53uQ.js +1 -0
- package/dist/gateway/static/root/assets/{schedule-field-TkqUL3wm.js → schedule-field-Bcdni4Pj.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DC-iU5IG.js → schema-form-D7oCARF7.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-C5014a53.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CDY3ZI1K.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-Dpqth3oA.js → settings-collapsible-section-6eNF8Jey.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-CNqF6IwY.js → settings-form-section-CARTHCxH.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DkvwitK_.js → settings-loading-skeleton-DEwYqESe.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-B6vVdHeQ.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-DWvNgISx.js → settings-page-layout-D3srt5Bi.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-z-rF0Hdg.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DGpSPW-n.js → share-preview-page-Ck9SxiXw.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CHZFXE_d.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-B7p2QNXt.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-ncw3tX9P.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-8TxxSbUw.js → system-settings-panel-DLBUQSk2.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-B5FzMWOx.js → theme-store-C1oaqeD2.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-DEGtSA5h.js → typed-models-lib-Divbg_C4.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-BDU6FneG.js → use-channel-catalog-CP9a_rAf.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-iYfeSLKI.js +1 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-CrwkicvT.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-BQWxyPg8.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-50ZzGay5.js +1 -0
- package/dist/gateway/static/root/assets/work-page-DPqEahx7.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Cwi8Pz7n.js → workflow-run-setup-panel-DbDPYQwB.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-C3eIC5HZ.js +11 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +1 -0
- package/dist/src/agent/client-error-format.js +3 -3
- package/dist/src/agent/outcomes/task-evaluation.d.ts +20 -0
- package/dist/src/agent/outcomes/task-evaluation.js +48 -0
- package/dist/src/agent/outcomes/task-verifier.d.ts +29 -0
- package/dist/src/agent/outcomes/task-verifier.js +71 -0
- package/dist/src/agent/prompt/memory/index.js +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +32 -1
- package/dist/src/agent/service.js +1 -0
- package/dist/src/agent/service.types.d.ts +1 -0
- package/dist/src/agent/tools/browser/tool/browser-use-tool.d.ts +1 -7
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js +2 -73
- package/dist/src/agent/tools/browser/tool/schemas.d.ts +1 -13
- package/dist/src/agent/tools/browser/tool/schemas.js +1 -9
- package/dist/src/agent/tools/browser-recipe-tool.d.ts +12 -0
- package/dist/src/agent/tools/browser-recipe-tool.js +113 -0
- package/dist/src/agent/tools/factory.d.ts +2 -0
- package/dist/src/agent/tools/factory.js +2 -0
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/automations/domain/types.d.ts +13 -0
- package/dist/src/automations/domain/validation.d.ts +44 -24
- package/dist/src/automations/domain/validation.js +27 -18
- package/dist/src/automations/draft/automation-draft-validator.d.ts +6 -1
- package/dist/src/automations/draft/automation-draft-validator.js +1 -0
- package/dist/src/automations/service/action-executor.d.ts +1 -0
- package/dist/src/automations/service/action-executor.js +22 -0
- package/dist/src/browser/index.d.ts +0 -1
- package/dist/src/browser/index.js +1 -2
- package/dist/src/browser/pipeline/runner.d.ts +9 -2
- package/dist/src/browser/pipeline/runner.js +151 -105
- package/dist/src/browser/pipeline/schema.d.ts +21 -15
- package/dist/src/browser/pipeline/schema.js +93 -99
- package/dist/src/browser/recipes/index.d.ts +3 -0
- package/dist/src/browser/recipes/index.js +3 -0
- package/dist/src/browser/recipes/repository.d.ts +13 -0
- package/dist/src/browser/recipes/repository.js +81 -0
- package/dist/src/browser/recipes/runtime-service.d.ts +6 -0
- package/dist/src/browser/recipes/runtime-service.js +30 -0
- package/dist/src/browser/recipes/service.d.ts +36 -0
- package/dist/src/browser/recipes/service.js +186 -0
- package/dist/src/browser/recipes/types.d.ts +36 -0
- package/dist/src/browser/recipes/types.js +1 -0
- package/dist/src/cli/commands/browser-cli-helpers.js +6 -12
- package/dist/src/cli/commands/browser.js +4 -3
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/schema.d.ts +3 -3
- package/dist/src/config/schema.js +21 -21
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -1
- package/dist/src/gateway/hono/routes/browser-workflows.d.ts +3 -0
- package/dist/src/gateway/hono/routes/browser-workflows.js +78 -0
- package/dist/src/gateway/hono/routes/home.js +1 -0
- package/dist/src/gateway/hono/routes/index.js +4 -0
- package/dist/src/gateway/hono/routes/interaction-state.d.ts +3 -0
- package/dist/src/gateway/hono/routes/interaction-state.js +45 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/memory.js +33 -4
- package/dist/src/gateway/hono/routes/task-outcomes.d.ts +3 -0
- package/dist/src/gateway/hono/routes/task-outcomes.js +109 -0
- package/dist/src/gateway/hono/routes/you.d.ts +10 -2
- package/dist/src/gateway/hono/routes/you.js +184 -28
- package/dist/src/gateway/service/run-gateway-agent.js +84 -0
- package/dist/src/gateway/service.d.ts +3 -0
- package/dist/src/gateway/service.js +14 -0
- package/dist/src/proactive/insight-repository.d.ts +2 -0
- package/dist/src/proactive/insight-repository.js +5 -2
- package/dist/src/proactive/run-processor.js +22 -1
- package/dist/src/proactive/types.d.ts +2 -0
- package/dist/src/proactive/value-score.d.ts +13 -0
- package/dist/src/proactive/value-score.js +30 -0
- package/dist/src/share/share-types.js +5 -5
- package/dist/src/share/site-share-types.d.ts +1 -1
- package/dist/src/share/site-share-types.js +5 -5
- package/dist/src/storage/sqlite/index.d.ts +3 -0
- package/dist/src/storage/sqlite/index.js +4 -1
- package/dist/src/storage/sqlite/interaction-state-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/interaction-state-repository.js +60 -0
- package/dist/src/storage/sqlite/memory-records-repository.js +1 -1
- package/dist/src/storage/sqlite/migrations/053_browser_recipes.sql +45 -0
- package/dist/src/storage/sqlite/migrations/054_task_outcomes.sql +24 -0
- package/dist/src/storage/sqlite/migrations/055_relationship_settings.sql +14 -0
- package/dist/src/storage/sqlite/migrations/056_task_verification.sql +6 -0
- package/dist/src/storage/sqlite/migrations/057_interaction_states.sql +11 -0
- package/dist/src/storage/sqlite/migrations/058_proactive_value.sql +3 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/relationship-settings-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/relationship-settings-repository.js +64 -0
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +46 -0
- package/dist/src/storage/sqlite/task-outcome-repository.d.ts +90 -0
- package/dist/src/storage/sqlite/task-outcome-repository.js +138 -0
- package/dist/src/user-context/interaction-state.d.ts +13 -0
- package/dist/src/user-context/interaction-state.js +69 -0
- package/dist/src/user-context/memory-use-audit.d.ts +10 -0
- package/dist/src/user-context/memory-use-audit.js +25 -0
- package/dist/src/user-context/personal-playbook.d.ts +11 -0
- package/dist/src/user-context/personal-playbook.js +41 -0
- package/dist/src/user-context/projection.d.ts +4 -0
- package/dist/src/user-context/projection.js +5 -1
- package/dist/src/user-context/relationship-continuity.d.ts +14 -0
- package/dist/src/user-context/relationship-continuity.js +51 -0
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/action-boundary-settings-panel-BIVBUiNT.js +0 -1
- package/dist/gateway/static/root/assets/agents-_qbUaYbs.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-0sPqD0FK.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-BxWBuBsE.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-C499b9AH.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dva9SiPK.js +0 -2
- package/dist/gateway/static/root/assets/channels-settings-DNAU7u9o.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-CIOH7tgn.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-TwiBp8vY.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-CYH5ZSXy.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-Q3B0E-0s.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-C5VAK04G.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-BJb-5IYw.js +0 -2
- package/dist/gateway/static/root/assets/index-CkUHH170.css +0 -1
- package/dist/gateway/static/root/assets/index-vq_cJZJC.js +0 -199
- package/dist/gateway/static/root/assets/local-app-workbench-page-euH17Kvb.js +0 -2
- package/dist/gateway/static/root/assets/messages-CxySDn9d.js +0 -5
- package/dist/gateway/static/root/assets/models-hub-panel-DObxxjc9.js +0 -2
- package/dist/gateway/static/root/assets/notes-workbench-CCb4RXcZ.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-BvEcriRC.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-B_e79MRJ.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DGcqnYfR.js +0 -1
- package/dist/gateway/static/root/assets/save-bar-controls-CkeKasGm.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DQZhrDJ8.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BkdeN99Y.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-qPG7I2zd.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-lwRAh9aw.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BGj9IVUr.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-B2UBAs5U.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-DdjzFZ8I.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-BTTZpAGV.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-DuDQd-WU.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BUVkVCsW.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-DeEPPu4n.js +0 -1
- package/dist/gateway/static/root/assets/work-page-DQNUyTUq.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-BIy4wrzO.js +0 -11
- package/dist/src/browser/pipeline/source.d.ts +0 -9
- package/dist/src/browser/pipeline/source.js +0 -77
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{r,s as i}from"./locale-store-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{r,s as i}from"./locale-store-0lpYdNDr.js";import{i as a}from"./vendor-swr-BIWyz7Rc.js";import{Bs as o,Gn as s,It as c,Kn as l,wc as u,ws as d}from"./index-C8JkTS6d.js";import{s as f}from"./typed-models-lib-Divbg_C4.js";var p=[{key:`code-intelligence`,toolIds:[`code_search`,`code_read_symbol`,`code_trace`,`code_impact`,`code_architecture`]},{key:`workspace`,toolIds:[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`]},{key:`execution`,toolIds:[`exec_command`,`execute_code`]},{key:`messaging`,toolIds:[`send_message`,`send_media`,`text_to_speech`]},{key:`memory`,toolIds:[`memory_search`,`memory_get`,`curated_memory`,`session_search`]},{key:`media`,toolIds:[`image`,`image_generate`,`read_media`,`create_share`]},{key:`web`,toolIds:[`web_search`,`web_fetch`,`web_extract`,`browser_use`]},{key:`misc`,toolIds:[`session_status`,`dreaming`,`tool_manual`,`clarify`,`todo`,`update_plan`,`automation`,`workflow`,`delegate_task`]},{key:`unknown`,toolIds:[`skills_list`,`skill_view`,`skill_manage`]},{key:`extensions`,toolIds:[`extensions`]},{key:`mcp`,toolIds:[`bundle-mcp`]}],m=new Set(p.flatMap(e=>[...e.toolIds].map(e=>String(e))));function h(e){return e.filter(e=>e&&!m.has(e)).sort((e,t)=>e.localeCompare(t))}var g=e(t(),1),_=n(),v=[`deep`,`fast`,`cheap`,`code`,`review`];function y(e){return v.includes(e)}function b(e){let{rows:t,onChange:n,disabled:r,defaultRole:i,chat:p,labels:m}=e,{data:h=[]}=a(s,l,{revalidateOnFocus:!1}),b=(0,g.useMemo)(()=>new Set(h.filter(e=>e.vision===!0).map(e=>e.id)),[h]),x=(0,g.useRef)([]),S=(0,g.useRef)(0);for(;x.current.length<t.length;)x.current.push(`typed-model-row-${S.current++}`);x.current.length>t.length&&(x.current.length=t.length);let C=(e,r)=>{n(t.map((t,n)=>n===e?{...t,...r}:t))},w=(e,n,r)=>{let i=t[e];if(!i)return;let a=[...i.fallbacks??[]];a[n]=r,C(e,{fallbacks:a})},T=e=>{let n=t[e];n&&C(e,{fallbacks:[...n.fallbacks??[],``]})},E=(e,n)=>{let r=t[e];r&&C(e,{fallbacks:(r.fallbacks??[]).filter((e,t)=>t!==n)})},D=e=>{x.current.splice(e,1),n(t.filter((t,n)=>n!==e))},O=e=>{x.current.push(`typed-model-row-${S.current++}`),n([...t,e])},k=t.find(e=>e.model.trim())?.model??``,A=t.map((e,t)=>({row:e,index:t})),j=v.map(e=>A.find(t=>t.row.id===e)).filter(e=>!!e),M=A.filter(e=>!y(e.row.id)),N=v.filter(e=>!t.some(t=>t.id===e)),P=(e,t)=>{let{row:n,index:a}=e,s=n.id===i,l=[n.model,...n.fallbacks??[]].some(e=>b.has(e.trim())),h=y(n.id)?m.roleNames[n.id]:m.id,g=y(n.id)?m.roleDescriptions[n.id]:``;return(0,_.jsxs)(`div`,{className:`grid gap-3 rounded-lg bg-surface-panel/70 p-3 shadow-surface lg:grid-cols-[minmax(0,11rem)_minmax(0,1fr)_auto] lg:items-start`,children:[t.recommended?(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,_.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:h}),s?(0,_.jsx)(`span`,{className:`shrink-0 rounded-full border border-accent/25 bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:m.defaultBadge}):null,l?(0,_.jsx)(`span`,{className:`shrink-0 rounded-full border border-accent/25 bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:m.visionBadge}):null]}),(0,_.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:n.id}),g?(0,_.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:g}):null]}):(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,_.jsx)(`span`,{children:m.id}),l?(0,_.jsx)(`span`,{className:`shrink-0 rounded-full border border-accent/25 bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:m.visionBadge}):null]}),(0,_.jsx)(`input`,{type:`text`,className:f(),value:n.id,disabled:r,placeholder:m.idPlaceholder,"aria-label":m.id,onChange:e=>C(a,{id:e.target.value.toLowerCase()})})]}),(0,_.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,_.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:m.primaryModel}),(0,_.jsx)(c,{value:n.model,disabled:r,placeholder:p.modelPlaceholder,searchPlaceholder:p.modelSearchPlaceholder,noMatches:p.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>C(a,{model:e})}),l?(0,_.jsx)(`div`,{className:`text-xs leading-relaxed text-fg-muted`,children:m.visionAutoHint}):null]}),(0,_.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:m.fallbackModels}),(0,_.jsxs)(d,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:r,onClick:()=>T(a),children:[(0,_.jsx)(u,{className:`size-3.5`,strokeWidth:1.75}),m.addFallback]})]}),(n.fallbacks??[]).length>0?(0,_.jsx)(`div`,{className:`grid gap-1.5`,children:(n.fallbacks??[]).map((e,t)=>(0,_.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,_.jsx)(c,{value:e,disabled:r,placeholder:m.fallbackPlaceholder,searchPlaceholder:p.modelSearchPlaceholder,noMatches:p.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>w(a,t,e)}),(0,_.jsx)(d,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:r,"aria-label":m.removeFallback,onClick:()=>E(a,t),children:(0,_.jsx)(o,{className:`size-4`,strokeWidth:1.75})})]},`${x.current[a]??a}-fallback-${t}`))}):(0,_.jsx)(`div`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-xs text-fg-muted shadow-surface`,children:m.fallbackEmptyHint})]}),(0,_.jsx)(`input`,{type:`text`,className:f(),value:n.description,disabled:r,placeholder:m.descriptionPlaceholder,"aria-label":m.description,onChange:e=>C(a,{description:e.target.value})})]}),(0,_.jsx)(d,{type:`button`,variant:`secondary`,className:`shrink-0 sm:mt-0`,disabled:r||s,"aria-label":m.remove,onClick:()=>D(a),children:(0,_.jsx)(o,{className:`size-4`,strokeWidth:1.75})})]},x.current[a]??`typed-model-row-${a}`)};return(0,_.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,_.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-fg-muted`,children:m.recommendedTitle}),j.map(e=>P(e,{recommended:!0})),N.length>0?(0,_.jsx)(`div`,{className:`flex flex-wrap gap-2 pt-1`,children:N.map(e=>(0,_.jsxs)(d,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 rounded-lg px-2.5 text-xs`,disabled:r,onClick:()=>O({id:e,description:m.roleDescriptions[e],model:k,fallbacks:[]}),children:[(0,_.jsx)(u,{className:`size-3.5 shrink-0`,strokeWidth:1.75}),m.addPurpose.replace(`{name}`,m.roleNames[e])]},e))}):null]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,_.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-fg-muted`,children:m.customTitle}),M.length>0?M.map(e=>P(e,{recommended:!1})):(0,_.jsx)(`div`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:m.noCustomRoles})]}),(0,_.jsxs)(d,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,disabled:r,onClick:()=>O({id:``,description:``,model:k,fallbacks:[]}),children:[(0,_.jsx)(u,{className:`size-4 shrink-0`,strokeWidth:1.75}),m.add]})]})}async function x(){let e=await i(r(`/api/capability-presets`));if(!Array.isArray(e.payload?.presets)||typeof e.payload.defaultPresetId!=`string`||!Array.isArray(e.payload.agents)||!Array.isArray(e.payload.builtinToolIds))throw Error(`Invalid /api/capability-presets response`);return e.payload}async function S(e){let t=await i(r(`/api/capability-presets`),{method:`POST`,body:JSON.stringify(e)}),n=t.payload?.presetId,a=t.payload?.presets;if(!n||!a||typeof a.defaultPresetId!=`string`||!Array.isArray(a.presets)||!Array.isArray(a.agents)||!Array.isArray(a.builtinToolIds))throw Error(`Invalid create capability preset response`);return{presetId:n,presets:a}}async function C(e,t){let n=await i(r(`/api/capability-presets/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)});if(!Array.isArray(n.payload?.presets)||typeof n.payload.defaultPresetId!=`string`||!Array.isArray(n.payload.agents)||!Array.isArray(n.payload.builtinToolIds))throw Error(`Invalid update capability preset response`);return n.payload}async function w(e){let t=await i(r(`/api/capability-presets/${encodeURIComponent(e)}`),{method:`DELETE`});if(!Array.isArray(t.payload?.presets)||typeof t.payload.defaultPresetId!=`string`||!Array.isArray(t.payload.agents)||!Array.isArray(t.payload.builtinToolIds))throw Error(`Invalid delete capability preset response`);return t.payload}export{b as a,C as i,w as n,p as o,x as r,h as s,S as t};
|
|
@@ -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,t as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-BwQ3WssU.js";import{l as c,n as l}from"./locale-store-0lpYdNDr.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Bo as d,Br as f,Bs as p,Ds as m,Eu as h,Ho as g,Il as _,Jc as v,Os as y,Ro as b,Uo as x,Vo as S,Wl as C,Wo as w,_s as T,as as E,cl as D,is as O,nc as k,os as A,pc as j,rs as M,ts as ee,wc as te,ws as N,wu as ne,xc as P,yu as re,zo as ie}from"./index-C8JkTS6d.js";import{n as ae,r as F}from"./settings-page-layout-D3srt5Bi.js";import{n as oe,r as I}from"./settings-loading-skeleton-DEwYqESe.js";import{n as L,t as R}from"./settings-form-section-CARTHCxH.js";import{a as se,i as ce,n as le,o as ue,r as de,s as fe,t as pe}from"./capability-presets-api-CNFl7dM3.js";import{a as me,i as he,o as z,t as ge}from"./typed-models-lib-Divbg_C4.js";var B=e(t(),1),V=n(),H=r();function _e(e){let t=(0,V.c)(34),{extendsIds:n,onExtendsChange:r,presetOptions:i,jsonFields:a,onJsonFieldsChange:o,disabled:s,labels:c}=e,l;t[0]===a?l=t[1]:(l=Object.keys(a),t[0]=a,t[1]=l);let u=l,d;t[2]===c.inheritanceTitle?d=t[3]:(d=(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[2]=c.inheritanceTitle,t[3]=d);let f;t[4]===c.inheritanceHint?f=t[5]:(f=(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[4]=c.inheritanceHint,t[5]=f);let p;t[6]!==s||t[7]!==n||t[8]!==c.inheritanceEmpty||t[9]!==r||t[10]!==i?(p=i.length>0?(0,H.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=n.includes(e.id);return(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 shrink-0 rounded border-edge`,checked:t,disabled:s,onChange:()=>r(t?n.filter(t=>t!==e.id):[...n,e.id])}),(0,H.jsxs)(`span`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,H.jsx)(`span`,{className:`mt-0.5 block font-mono text-[11px] text-fg-subtle`,children:e.id})]})]},e.id)})}):(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}),t[6]=s,t[7]=n,t[8]=c.inheritanceEmpty,t[9]=r,t[10]=i,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,H.jsxs)(`section`,{children:[d,f,p]}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===c.jsonTitle?h=t[17]:(h=(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[16]=c.jsonTitle,t[17]=h);let g;t[18]===c.jsonHint?g=t[19]:(g=(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[18]=c.jsonHint,t[19]=g);let _;t[20]!==s||t[21]!==u||t[22]!==a||t[23]!==c.fieldHints||t[24]!==c.fieldLabels||t[25]!==o?(_=(0,H.jsx)(`div`,{className:`mt-3 grid gap-4 lg:grid-cols-2`,children:u.map(e=>(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:c.fieldLabels[e]}),(0,H.jsx)(`span`,{className:`min-h-8 text-xs leading-relaxed text-fg-muted`,children:c.fieldHints[e]}),(0,H.jsx)(`textarea`,{className:`min-h-36 resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:a[e],disabled:s,spellCheck:!1,placeholder:`{}`,onChange:t=>o({...a,[e]:t.target.value})})]},e))}),t[20]=s,t[21]=u,t[22]=a,t[23]=c.fieldHints,t[24]=c.fieldLabels,t[25]=o,t[26]=_):_=t[26];let v;t[27]!==h||t[28]!==g||t[29]!==_?(v=(0,H.jsxs)(`section`,{children:[h,g,_]}),t[27]=h,t[28]=g,t[29]=_,t[30]=v):v=t[30];let y;return t[31]!==m||t[32]!==v?(y=(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[m,v]}),t[31]=m,t[32]=v,t[33]=y):y=t[33],y}function U(e){return e.name||e.directoryId}function ve(e){let t=(0,V.c)(56),{mode:n,selected:r,catalog:i,loading:a,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,f;t[0]===i?f=t[1]:(f=i.map(U).filter(Boolean),t[0]=i,t[1]=f);let p=f,m;bb0:{if(n===`inherit`){m=u.inheritSummary;break bb0}if(n===`all`){m=u.allSummary;break bb0}if(n===`off`){m=u.offSummary;break bb0}let e=n===`allowlist`?u.allowSummary:u.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],m=i}let h=m,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,H.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),t[5]=g):g=t[5];let _;t[6]===u.overrideSummaryTitle?_=t[7]:(_=(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[g,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=_);let v;t[8]===h?v=t[9]:(v=(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:h}),t[8]=h,t[9]=v);let y;t[10]!==_||t[11]!==v?(y=(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[_,v]}),t[10]=_,t[11]=v,t[12]=y):y=t[12];let b;t[13]===u.modeLabel?b=t[14]:(b=(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=b);let x;t[15]===u.modeInherit?x=t[16]:(x=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=x);let S;t[17]===u.modeAll?S=t[18]:(S=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=S);let C;t[19]===u.modeAllowlist?C=t[20]:(C=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=C);let w;t[21]===u.modeDenylist?w=t[22]:(w=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=w);let T;t[23]===u.modeOff?T=t[24]:(T=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=T);let E;t[25]!==w||t[26]!==T||t[27]!==x||t[28]!==S||t[29]!==C?(E=[x,S,C,w,T],t[25]=w,t[26]=T,t[27]=x,t[28]=S,t[29]=C,t[30]=E):E=t[30];let D=E,O;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==D?(O=(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:D.map(e=>{let[t,r]=e;return(0,H.jsx)(`button`,{type:`button`,className:o(`rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=D,t[35]=O):O=t[35];let k;t[36]!==O||t[37]!==b?(k=(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[b,O]}),t[36]=O,t[37]=b,t[38]=k):k=t[38];let A;t[39]!==i||t[40]!==p||t[41]!==s||t[42]!==u.emptyCatalog||t[43]!==u.noDescription||t[44]!==u.quickActionsLabel||t[45]!==u.quickClear||t[46]!==u.quickSelectAll||t[47]!==a||t[48]!==l||t[49]!==d||t[50]!==r?(A=d?(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(N,{type:`button`,variant:`secondary`,className:z,disabled:s||a||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,H.jsx)(N,{type:`button`,variant:`secondary`,className:z,disabled:s||a||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),a?(0,H.jsx)(I,{rows:3}):i.length===0?(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,H.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:i.map(e=>{let t=U(e),n=r.has(t),i=typeof e.description==`string`?e.description.trim():``,a=i||u.noDescription;return(0,H.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,H.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,H.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,H.jsx)(`p`,{className:o(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!i&&`italic text-fg-subtle`),title:a,children:a})]})]})},t)})})]}):null,t[39]=i,t[40]=p,t[41]=s,t[42]=u.emptyCatalog,t[43]=u.noDescription,t[44]=u.quickActionsLabel,t[45]=u.quickClear,t[46]=u.quickSelectAll,t[47]=a,t[48]=l,t[49]=d,t[50]=r,t[51]=A):A=t[51];let j;return t[52]!==k||t[53]!==A||t[54]!==y?(j=(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[y,k,A]}),t[52]=k,t[53]=A,t[54]=y,t[55]=j):j=t[55],j}var W=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],G=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],K=[`send_message`,`send_media`,`text_to_speech`,`create_share`],ye=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],q=[...W,...K],J=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],be=[`send_message`,`send_media`];function xe(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]={mode:i});return n}function Se(e){let t=(0,V.c)(105),{builtinToolIds:n,toolPolicies:r,onChange:i,disabled:a,getToolDescription:s,getGroupTitle:c,labels:l}=e,u;t[0]===n?u=t[1]:(u=new Set(n),t[0]=n,t[1]=u);let d=u,f;t[2]!==d||t[3]!==r?(f=Object.entries(r).filter(e=>{let[t]=e;return d.has(t)}).toSorted(Y),t[2]=d,t[3]=r,t[4]=f):f=t[4];let p=f,m;if(t[5]!==d||t[6]!==n){m=[];for(let e of ue){let t=e.toolIds.filter(e=>d.has(e));t.length>0&&m.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=fe(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),m.push(e)}t[5]=d,t[6]=n,t[7]=m}else m=t[7];let h=m,g;t[12]!==i||t[13]!==r?(g=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]={...n[e],mode:t},i(n)},t[12]=i,t[13]=r,t[14]=g):g=t[14];let _=g,v;t[15]!==i||t[16]!==r?(v=(e,t)=>{let n=r[e];n&&i({...r,[e]:t(n)})},t[15]=i,t[16]=r,t[17]=v):v=t[17];let y=v,b;t[18]!==d||t[19]!==i?(b=e=>{i(xe(d,e))},t[18]=d,t[19]=i,t[20]=b):b=t[20];let x=b;if(n.length===0){let e;return t[21]===l.emptyBuiltin?e=t[22]:(e=(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[21]=l.emptyBuiltin,t[22]=e),e}let S;t[23]===l.quickActionsLabel?S=t[24]:(S=(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[23]=l.quickActionsLabel,t[24]=S);let C;t[25]===i?C=t[26]:(C=()=>i({}),t[25]=i,t[26]=C);let w;t[27]!==a||t[28]!==l.quickClearOverrides||t[29]!==C?(w=(0,H.jsx)(N,{type:`button`,variant:`secondary`,className:z,disabled:a,onClick:C,children:l.quickClearOverrides}),t[27]=a,t[28]=l.quickClearOverrides,t[29]=C,t[30]=w):w=t[30];let T;t[31]===x?T=t[32]:(T=()=>x([[W,`deny`]]),t[31]=x,t[32]=T);let E;t[33]!==a||t[34]!==l.quickReadOnlyWorkspace||t[35]!==T?(E=(0,H.jsx)(N,{type:`button`,variant:`secondary`,className:z,disabled:a,onClick:T,children:l.quickReadOnlyWorkspace}),t[33]=a,t[34]=l.quickReadOnlyWorkspace,t[35]=T,t[36]=E):E=t[36];let D;t[37]===x?D=t[38]:(D=()=>x([[G,`deny`]]),t[37]=x,t[38]=D);let O;t[39]!==a||t[40]!==l.quickHighRiskOff||t[41]!==D?(O=(0,H.jsx)(N,{type:`button`,variant:`secondary`,className:z,disabled:a,onClick:D,children:l.quickHighRiskOff}),t[39]=a,t[40]=l.quickHighRiskOff,t[41]=D,t[42]=O):O=t[42];let k;t[43]===x?k=t[44]:(k=()=>x([[K,`deny`]]),t[43]=x,t[44]=k);let A;t[45]!==a||t[46]!==l.quickNoOutbound||t[47]!==k?(A=(0,H.jsx)(N,{type:`button`,variant:`secondary`,className:z,disabled:a,onClick:k,children:l.quickNoOutbound}),t[45]=a,t[46]=l.quickNoOutbound,t[47]=k,t[48]=A):A=t[48];let j;t[49]===x?j=t[50]:(j=()=>x([[ye,`allow`],[q,`deny`]]),t[49]=x,t[50]=j);let te;t[51]!==a||t[52]!==l.quickResearchMode||t[53]!==j?(te=(0,H.jsx)(N,{type:`button`,variant:`secondary`,className:z,disabled:a,onClick:j,children:l.quickResearchMode}),t[51]=a,t[52]=l.quickResearchMode,t[53]=j,t[54]=te):te=t[54];let ne;t[55]===x?ne=t[56]:(ne=()=>x([[J,`allow`],[be,`deny`]]),t[55]=x,t[56]=ne);let P;t[57]!==a||t[58]!==l.quickCodingMode||t[59]!==ne?(P=(0,H.jsx)(N,{type:`button`,variant:`secondary`,className:z,disabled:a,onClick:ne,children:l.quickCodingMode}),t[57]=a,t[58]=l.quickCodingMode,t[59]=ne,t[60]=P):P=t[60];let re;t[61]!==O||t[62]!==A||t[63]!==te||t[64]!==P||t[65]!==w||t[66]!==E?(re=(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[w,E,O,A,te,P]}),t[61]=O,t[62]=A,t[63]=te,t[64]=P,t[65]=w,t[66]=E,t[67]=re):re=t[67];let ie;t[68]!==re||t[69]!==S?(ie=(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[S,re]}),t[68]=re,t[69]=S,t[70]=ie):ie=t[70];let ae;t[71]===l.overrideSummaryTitle?ae=t[72]:(ae=(0,H.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[71]=l.overrideSummaryTitle,t[72]=ae);let F;t[73]!==l.modeAllow||t[74]!==l.modeConfirm||t[75]!==l.modeDeny||t[76]!==l.noOverrides||t[77]!==p?(F=p.length>0?(0,H.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:p.map(e=>{let[t,n]=e;return(0,H.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n.mode===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n.mode===`confirm`&&`border-amber-500/25 bg-amber-500/10 text-amber-700 dark:text-amber-300`,n.mode===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,H.jsx)(`span`,{className:`font-sans opacity-80`,children:n.mode===`allow`?l.modeAllow:n.mode===`confirm`?l.modeConfirm:l.modeDeny})]},t)})}):(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[73]=l.modeAllow,t[74]=l.modeConfirm,t[75]=l.modeDeny,t[76]=l.noOverrides,t[77]=p,t[78]=F):F=t[78];let oe;t[79]!==ae||t[80]!==F?(oe=(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[ae,F]}),t[79]=ae,t[80]=F,t[81]=oe):oe=t[81];let I;t[82]!==a||t[83]!==c||t[84]!==s||t[85]!==h||t[86]!==l.inheritedMode||t[87]!==l.maxCallsLabel||t[88]!==l.modeAllow||t[89]!==l.modeConfirm||t[90]!==l.modeDeny||t[91]!==l.scopeInherit||t[92]!==l.scopeLabel||t[93]!==l.scopeReadonly||t[94]!==l.scopeUnrestricted||t[95]!==l.scopeWorkspace||t[96]!==l.timeoutLabel||t[97]!==_||t[98]!==r||t[99]!==y?(I=(0,H.jsx)(`div`,{className:`flex flex-col gap-5`,children:h.map(e=>{let{key:t,ids:n}=e;return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,H.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=r[e],i=n?n.mode:`inherit`;return(0,H.jsxs)(`li`,{className:o(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,i===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:[(0,H.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,H.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`confirm`,`deny`].map(t=>(0,H.jsx)(`button`,{type:`button`,className:o(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,i===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:a,onClick:()=>_(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:t===`confirm`?l.modeConfirm:l.modeDeny},t))})]}),n?(0,H.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 sm:grid-cols-3 dark:border-edge`,children:[(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l.scopeLabel,(0,H.jsxs)(ee,{value:n.scope??``,disabled:a,onChange:t=>y(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,H.jsx)(M,{value:``,children:l.scopeInherit}),(0,H.jsx)(M,{value:`readonly`,children:l.scopeReadonly}),(0,H.jsx)(M,{value:`workspace`,children:l.scopeWorkspace}),(0,H.jsx)(M,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,H.jsx)(we,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:a,onChange:t=>y(e,e=>Ce(e,`maxCallsPerTurn`,t))}),(0,H.jsx)(we,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:a,onChange:t=>y(e,e=>Ce(e,`timeoutMs`,t))})]}):null]},e)})})]},t)})}),t[82]=a,t[83]=c,t[84]=s,t[85]=h,t[86]=l.inheritedMode,t[87]=l.maxCallsLabel,t[88]=l.modeAllow,t[89]=l.modeConfirm,t[90]=l.modeDeny,t[91]=l.scopeInherit,t[92]=l.scopeLabel,t[93]=l.scopeReadonly,t[94]=l.scopeUnrestricted,t[95]=l.scopeWorkspace,t[96]=l.timeoutLabel,t[97]=_,t[98]=r,t[99]=y,t[100]=I):I=t[100];let L;return t[101]!==ie||t[102]!==oe||t[103]!==I?(L=(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[ie,oe,I]}),t[101]=ie,t[102]=oe,t[103]=I,t[104]=L):L=t[104],L}function Y(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function Ce(e,t,n){let r={...e.limits};if(n===void 0?delete r[t]:r[t]=n,Object.keys(r).length===0){let{limits:t,...n}=e;return n}return{...e,limits:r}}function we(e){let t=(0,V.c)(9),n=e.value??``,r;t[0]===e?r=t[1]:(r=t=>{let n=t.target.value.trim();e.onChange(n?Number(n):void 0)},t[0]=e,t[1]=r);let i;t[2]!==e.disabled||t[3]!==n||t[4]!==r?(i=(0,H.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:border-edge-strong focus:outline-none`,value:n,disabled:e.disabled,onChange:r}),t[2]=e.disabled,t[3]=n,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e.label||t[7]!==i?(a=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[e.label,i]}),t[6]=e.label,t[7]=i,t[8]=a):a=t[8],a}var Te=[`blank`,`safe-coder`,`read-only`,`low-cost`],Ee=[{id:`overview`,icon:C},{id:`models`,icon:D},{id:`tools`,icon:y},{id:`skills`,icon:P},{id:`advanced`,icon:k},{id:`impact`,icon:_}];function De(e){return he(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function Oe(e){return structuredClone(e?.tools?.builtin??{})}function ke(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function Ae(){return{primary:``,fallbacks:``,timeoutMs:``,autoProviderFallback:``}}function je(e){return{primary:e?.primary??``,fallbacks:e?.fallbacks?.join(`
|
|
2
|
+
`)??``,timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function Me(){return{imageModel:Ae(),imageGenerationModel:Ae(),allowFallbacks:``,maxCostTier:``}}function Ne(e){return{imageModel:je(e?.models?.imageModel),imageGenerationModel:je(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function X(e){return e===void 0?``:JSON.stringify(e,null,2)}function Z(){return{mcp:``,workflows:``,boundaries:``,runtime:``,locks:``}}function Pe(e){return{mcp:X(e?.tools?.mcp),workflows:X(e?.workflows),boundaries:X(e?.boundaries),runtime:X(e?.runtime),locks:X(e?.locks)}}function Fe(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:De(e),modelAdvanced:Ne(e),toolPolicies:Oe(e),skillMode:e?.skills?.mode??`inherit`,skillPick:ke(e),extendsIds:[...e?.extends??[]],jsonFields:Pe(e)}}function Ie(e){let t=e.primary.trim();if(!t)return;let n=e.fallbacks.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean),r=e.timeoutMs.trim()?Number(e.timeoutMs):void 0,i=e.autoProviderFallback===``?void 0:e.autoProviderFallback===`true`;return{primary:t,...n.length>0?{fallbacks:n}:{},...r?{timeoutMs:r}:{},...i===void 0?{}:{autoProviderFallback:i}}}function Le(e,t){let n=ge(e.modelRows),r=Ie(e.modelAdvanced.imageModel),i=Ie(e.modelAdvanced.imageGenerationModel),a=e.modelAdvanced.allowFallbacks||e.modelAdvanced.maxCostTier?{...e.modelAdvanced.allowFallbacks?{allowFallbacks:e.modelAdvanced.allowFallbacks===`true`}:{},...e.modelAdvanced.maxCostTier?{maxCostTier:e.modelAdvanced.maxCostTier}:{}}:void 0,o={...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},...n?.roles?{roles:n.roles}:{},...r?{imageModel:r}:{},...i?{imageGenerationModel:i}:{},...a?{policy:a}:{}};return Object.keys(o).length>0?o:null}function Re(e){return e.trim()?JSON.parse(e):void 0}function Q(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e))}catch{return`!invalid:${e}`}}function $(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=Re(e.jsonFields.mcp);return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function ze(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function Be(e){if(e.skillMode===`inherit`)return null;let t=[...e.skillPick].toSorted((e,t)=>e.localeCompare(t));return e.skillMode===`allowlist`?{mode:`allowlist`,allow:t}:e.skillMode===`denylist`?{mode:`denylist`,deny:t}:{mode:e.skillMode}}function Ve(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:Le(e,t),tools:{builtin:ze(e.toolPolicies),mcp:Q(e.jsonFields.mcp)},skills:Be(e),extends:[...e.extendsIds].toSorted(),workflows:Q(e.jsonFields.workflows),boundaries:Q(e.jsonFields.boundaries),runtime:Q(e.jsonFields.runtime),locks:Q(e.jsonFields.locks)}}function He(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:ze(e.tools?.builtin),mcp:Q(X(e.tools?.mcp))},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:Q(X(e.workflows)),boundaries:Q(X(e.boundaries)),runtime:Q(X(e.runtime)),locks:Q(X(e.locks))}:null}function Ue(e,t){return[e.models?.roles?t.summaryModels.replace(`{{count}}`,String(Object.keys(e.models.roles).length)):``,e.tools?.builtin?t.summaryTools.replace(`{{count}}`,String(Object.keys(e.tools.builtin).length)):``,e.skills?t.summarySkills.replace(`{{mode}}`,t.skillModeLabels[e.skills.mode]):``].filter(Boolean).join(` · `)||t.summaryEmpty}function We(){return{modelAdvanced:Me(),extendsIds:[],jsonFields:Z()}}function Ge(e,t){return{extends:[...e.extendsIds],models:Le(e,t)??void 0,tools:$(e)??void 0,skills:Be(e)??void 0,workflows:Re(e.jsonFields.workflows),boundaries:Re(e.jsonFields.boundaries),runtime:Re(e.jsonFields.runtime),locks:Re(e.jsonFields.locks)}}function Ke(e,t){return e===`safe-coder`?{id:`safe-coder`,name:t.starters[`safe-coder`].title,description:t.starters[`safe-coder`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`code`,model:``,fallbacks:[],description:t.modelRoleDescriptions.code},{id:`review`,model:``,fallbacks:[],description:t.modelRoleDescriptions.review}],toolPolicies:{exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`]),...We()}:e===`read-only`?{id:`read-only-research`,name:t.starters[`read-only`].title,description:t.starters[`read-only`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast}],toolPolicies:{write_file:{mode:`deny`},apply_patch:{mode:`deny`},exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`all`,skillPick:new Set,...We()}:e===`low-cost`?{id:`low-cost-assistant`,name:t.starters[`low-cost`].title,description:t.starters[`low-cost`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast},{id:`cheap`,model:``,fallbacks:[],description:t.modelRoleDescriptions.cheap}],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...We()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...We()}}function qe(){let e=s(l(e=>e.language)),t=e.capabilityPresetsSettings,n=(0,H.jsx)(N,{asChild:!0,type:`button`,variant:`secondary`,children:(0,H.jsxs)(a,{to:`/agents`,children:[t.manageAgents,(0,H.jsx)(ne,{className:`size-4`,"aria-hidden":!0})]})}),r=!!c(e=>e.token),{data:M,error:ee,isLoading:re,mutate:I}=u(r?`settings-capability-presets`:null,de,{revalidateOnFocus:!1}),{data:ue=[],isLoading:fe}=u(r?`settings-capability-presets-skills-catalog`:null,f,{revalidateOnFocus:!1}),[he,z]=i(),[ge,V]=(0,B.useState)(``),[U,W]=(0,B.useState)(`overview`),[G,K]=(0,B.useState)(()=>Ke(`blank`,t)),[ye,q]=(0,B.useState)(null),[J,be]=(0,B.useState)(!1),[xe,Y]=(0,B.useState)(null),[Ce,we]=(0,B.useState)(!1),[De,Oe]=(0,B.useState)(null),[ke,Ae]=(0,B.useState)(null),je=M?.presets??[],Me=M?.defaultPresetId??`default`,Ne=je.find(e=>e.id===Me)??null,X=je.filter(e=>e.id!==Me),Z=(0,B.useMemo)(()=>je.find(e=>e.id===ge)??je[0]??null,[je,ge]),Pe=!Z||G.id.trim()!==Z.id,Ie=!!(Z&&Z.id===Me),Le=JSON.stringify(Ve(G,Z))!==JSON.stringify(He(Z)),Q=Ve(G,Z),$=He(Z),ze=[Q.id!==$?.id||Q.name!==$?.name||Q.description!==$?.description?t.tabs.overview:``,JSON.stringify(Q.models)===JSON.stringify($?.models)?``:t.tabs.models,JSON.stringify(Q.tools)===JSON.stringify($?.tools)?``:t.tabs.tools,JSON.stringify(Q.skills)===JSON.stringify($?.skills)?``:t.tabs.skills,JSON.stringify({extends:Q.extends,workflows:Q.workflows,boundaries:Q.boundaries,runtime:Q.runtime,locks:Q.locks})===JSON.stringify({extends:$?.extends,workflows:$?.workflows,boundaries:$?.boundaries,runtime:$?.runtime,locks:$?.locks})?``:t.tabs.advanced].filter(Boolean),Be=xe??(ee instanceof Error?ee.message:null),We=he.get(`action`)===`new`||!!he.get(`preset`),qe=he.get(`action`)===`new`&&ye===null,Xe=Pe?t.newPreset:Z?.name??t.editorTitle,Ze=t=>e.agentsSettings.toolsDisableGroups[t],Qe=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,B.useEffect)(()=>{if(!M||J)return;if(he.get(`action`)===`new`){V(``),K(Ke(`blank`,t)),W(`overview`);return}let e=he.get(`preset`)?.trim(),n=e?M.presets.find(t=>t.id===e):null;if(n){V(n.id),K(Fe(n)),W(he.get(`tab`)??`overview`);return}Z&&(V(Z.id),K(e=>e.id===Z.id?e:Fe(Z)))},[J,M,he,Z]);function $e(e){q(null),V(e.id),K(Fe(e)),z({preset:e.id},{replace:!0}),W(`overview`)}function et(){q(null),V(``),K(Ke(`blank`,t)),Y(null),z({action:`new`},{replace:!0}),W(`overview`)}function tt(e){q(e),K(Ke(e,t)),Y(null),W(`overview`)}function nt(){if(ye){let e=Ke(ye,t);if(JSON.stringify(Ve(G,null))!==JSON.stringify(Ve(e,null))&&!window.confirm(t.changeTemplateConfirm))return}q(null),Y(null)}function rt(){!qe&&Le&&!window.confirm(t.discardConfirm)||(we(!1),Oe(null),z({},{replace:!0}),q(null),Y(null),K(Fe(Z)),W(`overview`))}async function it(){let e=me(G.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){Y(e),W(`models`);return}for(let e of[G.modelAdvanced.imageModel,G.modelAdvanced.imageGenerationModel]){if([e.primary,...e.fallbacks.split(/\r?\n|,/)].map(e=>e.trim()).filter(Boolean).some(e=>!/^[^/\s]+\/.+/.test(e))){Y(t.invalidModelRef),W(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){Y(t.advancedPositiveIntegerError),W(`models`);return}}for(let e of Object.values(G.toolPolicies))if([e.limits?.maxCallsPerTurn,e.limits?.timeoutMs].filter(e=>e!==void 0).some(e=>!Number.isInteger(e)||e<=0)){Y(t.advancedPositiveIntegerError),W(`tools`);return}for(let e of Object.keys(G.jsonFields))try{Re(G.jsonFields[e])}catch{Y(t.advancedJsonError.replace(`{{field}}`,t.advancedFieldLabels[e])),W(`advanced`);return}be(!0),Y(null);try{let e=Ge(G,Z);if(Pe){let t=await pe({id:G.id.trim(),name:G.name.trim(),...G.description.trim()?{description:G.description.trim()}:{},...e});await I(t.presets,{revalidate:!1}),V(t.presetId),q(null),z({preset:t.presetId},{replace:!0})}else Z&&await I(await ce(Z.id,{name:G.name.trim(),description:G.description.trim()||null,extends:e.extends??null,models:e.models??null,tools:e.tools??null,skills:e.skills??null,workflows:e.workflows??null,boundaries:e.boundaries??null,runtime:e.runtime??null,locks:e.locks??null}),{revalidate:!1})}catch(e){Y(e instanceof Error?e.message:t.saveError)}finally{be(!1)}}async function at(){if(Z){be(!0),Y(null),Oe(null);try{await I(await le(Z.id),{revalidate:!1}),we(!1),V(``),q(null),K(Ke(`blank`,t)),W(`overview`),z({},{replace:!0})}catch(e){Oe(e instanceof Error?e.message:t.deleteError)}finally{be(!1)}}}return r?(0,H.jsxs)(F,{gap:`gap-5`,className:`pb-24`,children:[(0,H.jsx)(ae,{title:t.title,subtitle:t.subtitle,actions:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[n,(0,H.jsxs)(N,{type:`button`,onClick:et,disabled:J,children:[(0,H.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]})}),Be?(0,H.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Be}):null,re?(0,H.jsx)(oe,{sections:2}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[Ne?(0,H.jsxs)(R,{children:[(0,H.jsx)(L,{icon:D,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>$e(Ne),className:`group rounded-lg bg-accent/5 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Ne.name}),(0,H.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,H.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Ne.id})]}),(0,H.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),Ne.description?(0,H.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Ne.description}):null,(0,H.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:Ue(Ne,t)})]})]}):null,(0,H.jsxs)(R,{children:[(0,H.jsx)(L,{icon:D,title:t.listTitle,subtitle:t.listHint}),X.length===0?(0,H.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:[(0,H.jsx)(`p`,{children:t.empty}),(0,H.jsxs)(N,{type:`button`,variant:`secondary`,onClick:et,disabled:J,children:[(0,H.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]}):(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:X.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>$e(e),className:`group min-h-36 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,H.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,H.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,H.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:Ue(e,t)})]},e.id))})]})]}),(0,H.jsx)(b,{open:We,onOpenChange:e=>{e||rt()},children:(0,H.jsxs)(x,{children:[(0,H.jsx)(g,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,A)}),(0,H.jsx)(d,{ref:Ae,className:o(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,760px)] w-[min(100%-2rem,64rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,E),onOpenAutoFocus:e=>e.preventDefault(),children:(0,H.jsxs)(O,{layer:`modal`,portalContainer:ke,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[!qe&&Pe&&ye?(0,H.jsx)(`button`,{type:`button`,className:o(T,`shrink-0 p-1.5 hover:bg-surface-base`),onClick:nt,"aria-label":t.changeTemplate,title:t.changeTemplate,children:(0,H.jsx)(h,{className:`size-4`,"aria-hidden":!0})}):null,(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(w,{className:`truncate text-base font-semibold text-fg`,children:Xe}),(0,H.jsx)(S,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:qe?t.templatePickerSubtitle:Pe&&ye?`${t.editorHint} · ${t.basedOnTemplate.replace(`{{template}}`,t.starters[ye].title)}`:Pe?t.editorHint:G.id})]})]}),(0,H.jsx)(ie,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:o(T,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,H.jsx)(m,{className:`size-4`,"aria-hidden":!0})})})]}),qe?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 sm:p-5`,children:(0,H.jsx)(`div`,{className:`mx-auto grid max-w-3xl gap-3 sm:grid-cols-2`,children:Te.map(e=>(0,H.jsxs)(`button`,{type:`button`,className:`group min-h-32 rounded-xl border border-edge-subtle bg-surface-base px-4 py-4 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>tt(e),children:[(0,H.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),e===`blank`?(0,H.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.templateRecommended}):null]}),(0,H.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})}),(0,H.jsx)(`div`,{className:`flex shrink-0 justify-end border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:(0,H.jsx)(N,{type:`button`,variant:`secondary`,onClick:rt,children:t.cancel})})]}):(0,H.jsxs)(H.Fragment,{children:[Be?(0,H.jsx)(`div`,{className:`mx-4 mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Be}):null,(0,H.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2 border-b border-edge-subtle bg-surface-base px-4 py-2 dark:border-edge`,children:Ee.map(({id:e,icon:n})=>(0,H.jsxs)(`button`,{type:`button`,className:o(`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,U===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>W(e),children:[(0,H.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:(0,H.jsxs)(`div`,{className:`w-full`,children:[U===`overview`?(0,H.jsxs)(R,{children:[(0,H.jsx)(L,{icon:C,title:t.overviewTitle,subtitle:t.overviewHint}),(0,H.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,H.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:G.id,disabled:J||!Pe,onChange:e=>K(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),!Pe&&Z?(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,H.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg-muted`,children:t.versionAutomatic.replace(`{{version}}`,String(Z.version))})]}):null,(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,H.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:G.name,disabled:J,onChange:e=>K(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,H.jsx)(`textarea`,{className:`min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:G.description,disabled:J,onChange:e=>K(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,H.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,H.jsx)(Je,{icon:D,label:t.modelsTitle,value:String(G.modelRows.length)}),(0,H.jsx)(Je,{icon:y,label:t.toolsTitle,value:String(Object.keys(G.toolPolicies).length)}),(0,H.jsx)(Je,{icon:P,label:t.skillsTitle,value:t.skillModeLabels[G.skillMode]})]})]}):null,U===`models`?(0,H.jsxs)(R,{children:[(0,H.jsx)(L,{icon:D,title:t.modelsTitle,subtitle:t.modelsHint}),(0,H.jsx)(se,{rows:G.modelRows,onChange:e=>K(t=>({...t,modelRows:e})),disabled:J,defaultRole:Z?.models?.defaultRole,chat:e.chat,labels:{id:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,add:t.addModelRole,remove:t.removeModelRole,recommendedTitle:t.modelRecommendedTitle,customTitle:t.modelCustomTitle,defaultBadge:t.modelDefaultBadge,visionBadge:t.modelVisionBadge,visionAutoHint:t.modelVisionAutoHint,addPurpose:t.addModelPurpose,noCustomRoles:t.noCustomModelRoles,idPlaceholder:`deep`,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}}),(0,H.jsx)(Ye,{value:G.modelAdvanced,onChange:e=>K(t=>({...t,modelAdvanced:e})),disabled:J,cp:t})]}):null,U===`tools`?(0,H.jsxs)(R,{children:[(0,H.jsx)(L,{icon:y,title:t.toolsTitle,subtitle:t.toolsHint}),(0,H.jsx)(Se,{builtinToolIds:M?.builtinToolIds??[],toolPolicies:G.toolPolicies,onChange:e=>K(t=>({...t,toolPolicies:e})),disabled:J,getToolDescription:Qe,getGroupTitle:Ze,labels:{quickActionsLabel:t.toolsQuickActionsLabel,quickClearOverrides:t.toolsQuickClearOverrides,quickReadOnlyWorkspace:t.toolsQuickReadOnlyWorkspace,quickHighRiskOff:t.toolsQuickHighRiskOff,quickNoOutbound:t.toolsQuickNoOutbound,quickResearchMode:t.toolsQuickResearchMode,quickCodingMode:t.toolsQuickCodingMode,emptyBuiltin:t.toolsEmptyBuiltin,overrideSummaryTitle:t.toolsOverrideSummaryTitle,noOverrides:t.toolsNoOverrides,inheritedMode:t.toolModes.inherit,modeAllow:t.toolModes.allow,modeConfirm:t.toolModes.confirm,modeDeny:t.toolModes.deny,scopeLabel:t.toolScopeLabel,scopeInherit:t.toolScopeInherit,scopeReadonly:t.toolScopeReadonly,scopeWorkspace:t.toolScopeWorkspace,scopeUnrestricted:t.toolScopeUnrestricted,maxCallsLabel:t.toolMaxCallsLabel,timeoutLabel:t.toolTimeoutLabel}})]}):null,U===`skills`?(0,H.jsxs)(R,{children:[(0,H.jsx)(L,{icon:P,title:t.skillsTitle,subtitle:t.skillsHint}),(0,H.jsx)(ve,{mode:G.skillMode,selected:G.skillPick,catalog:ue,loading:fe,disabled:J,onModeChange:e=>K(t=>({...t,skillMode:e})),onSelectedChange:e=>K(t=>({...t,skillPick:e})),labels:{modeLabel:t.skillsModeLabel,modeInherit:t.skillsModeInherit,modeAll:t.skillsModeAll,modeAllowlist:t.skillsModeAllowlist,modeDenylist:t.skillsModeDenylist,modeOff:t.skillsModeOff,quickActionsLabel:t.skillsQuickActionsLabel,quickSelectAll:t.skillsQuickSelectAll,quickClear:t.skillsQuickClear,catalogLoading:t.skillsCatalogLoading,emptyCatalog:t.skillsEmptyCatalog,noDescription:t.skillsNoDescription,overrideSummaryTitle:t.skillsOverrideSummaryTitle,inheritSummary:t.skillsInheritSummary,allSummary:t.skillsAllSummary,offSummary:t.skillsOffSummary,allowSummary:t.skillsAllowSummary,denySummary:t.skillsDenySummary}})]}):null,U===`advanced`?(0,H.jsxs)(R,{children:[(0,H.jsx)(L,{icon:k,title:t.advancedTitle,subtitle:t.advancedHint}),(0,H.jsx)(_e,{extendsIds:G.extendsIds,onExtendsChange:e=>K(t=>({...t,extendsIds:e})),presetOptions:je.filter(e=>e.id!==Z?.id&&e.id!==Me),jsonFields:G.jsonFields,onJsonFieldsChange:e=>K(t=>({...t,jsonFields:e})),disabled:J,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,jsonTitle:t.advancedJsonTitle,jsonHint:t.advancedJsonHint,fieldLabels:t.advancedFieldLabels,fieldHints:t.advancedFieldHints}})]}):null,U===`impact`?(0,H.jsxs)(R,{children:[(0,H.jsx)(L,{icon:_,title:t.usageTitle,subtitle:t.usageHint}),(0,H.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.changePreviewTitle}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:ze.length>0?t.changePreviewSections.replace(`{{sections}}`,ze.join(`、`)):t.changePreviewEmpty})]}),Z?.usage.length?(0,H.jsx)(`div`,{className:`grid gap-2`,children:Z.usage.map(e=>(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,H.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId}),(0,H.jsx)(`div`,{className:`mt-1 text-[11px] text-fg-subtle`,children:e.direct?t.usageDirect:t.usageIndirect})]},e.agentId))}):(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,H.jsx)(`div`,{className:`font-medium text-fg`,children:Le?t.unsavedTitle:t.noUnsavedTitle}),(0,H.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Le?(Z?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String(Z?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Le?(0,H.jsx)(N,{type:`button`,variant:`secondary`,disabled:J,onClick:()=>K(Fe(Z)),children:t.discard}):null,Z&&!Ie?(0,H.jsxs)(N,{type:`button`,variant:`secondary`,disabled:J,onClick:()=>{Oe(null),we(!0)},children:[(0,H.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,H.jsxs)(N,{type:`button`,disabled:J||!G.id.trim()||!G.name.trim()||!Le,onClick:()=>void it(),children:[(0,H.jsx)(j,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})]})})]})}),(0,H.jsx)(b,{open:Ce,onOpenChange:e=>{J||(we(e),e||Oe(null))},children:(0,H.jsxs)(x,{children:[(0,H.jsx)(g,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,A)}),(0,H.jsxs)(d,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,E),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,H.jsxs)(`div`,{className:`border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,H.jsx)(w,{className:`text-base font-semibold text-fg`,children:t.deleteDialogTitle}),(0,H.jsx)(S,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:Z?t.deleteConfirm.replace(`{{name}}`,Z.name):t.deleteConfirmFallback})]}),De?(0,H.jsx)(`div`,{className:`mx-4 mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:De}):null,(0,H.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,children:[(0,H.jsx)(N,{type:`button`,variant:`secondary`,disabled:J,onClick:()=>we(!1),children:t.cancel}),(0,H.jsxs)(N,{type:`button`,disabled:J||!Z,className:`bg-red-600 text-white shadow-surface hover:bg-red-700 focus-visible:ring-red-600 dark:bg-red-500 dark:hover:bg-red-600`,onClick:()=>void at(),children:[J?(0,H.jsx)(v,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,H.jsx)(p,{className:`size-4`,"aria-hidden":!0}),J?t.deleting:t.delete]})]})]})]})})]}):(0,H.jsxs)(F,{gap:`gap-3`,children:[(0,H.jsx)(ae,{title:t.title,actions:n}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function Je(e){let t=(0,V.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,H.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==a?(o=(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[a,r]}),t[2]=r,t[3]=a,t[4]=o):o=t[4];let s;t[5]===i?s=t[6]:(s=(0,H.jsx)(`div`,{className:`mt-1 text-sm font-medium text-fg`,children:i}),t[5]=i,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function Ye(e){let t=(0,V.c)(77),{value:n,onChange:r,disabled:i,cp:a}=e,o;t[0]!==r||t[1]!==n?(o=(e,t)=>{r({...n,[e]:t})},t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;t[3]===a.modelAdvancedTitle?c=t[4]:(c=(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelAdvancedTitle}),t[3]=a.modelAdvancedTitle,t[4]=c);let l;t[5]===a.modelAdvancedHint?l=t[6]:(l=(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:a.modelAdvancedHint}),t[5]=a.modelAdvancedHint,t[6]=l);let u;t[7]===s?u=t[8]:(u=e=>s(`imageModel`,e),t[7]=s,t[8]=u);let d;t[9]!==a||t[10]!==i||t[11]!==u||t[12]!==n.imageModel?(d=(0,H.jsx)(Xe,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:u,disabled:i,cp:a}),t[9]=a,t[10]=i,t[11]=u,t[12]=n.imageModel,t[13]=d):d=t[13];let f;t[14]===s?f=t[15]:(f=e=>s(`imageGenerationModel`,e),t[14]=s,t[15]=f);let p;t[16]!==a||t[17]!==i||t[18]!==f||t[19]!==n.imageGenerationModel?(p=(0,H.jsx)(Xe,{title:a.imageGenerationTitle,value:n.imageGenerationModel,onChange:f,disabled:i,cp:a}),t[16]=a,t[17]=i,t[18]=f,t[19]=n.imageGenerationModel,t[20]=p):p=t[20];let m;t[21]!==d||t[22]!==p?(m=(0,H.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[d,p]}),t[21]=d,t[22]=p,t[23]=m):m=t[23];let h;t[24]===a.modelAllowFallbacksLabel?h=t[25]:(h=(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelAllowFallbacksLabel}),t[24]=a.modelAllowFallbacksLabel,t[25]=h);let g;t[26]!==r||t[27]!==n?(g=e=>r({...n,allowFallbacks:e.target.value}),t[26]=r,t[27]=n,t[28]=g):g=t[28];let _;t[29]===a.policyInherit?_=t[30]:(_=(0,H.jsx)(M,{value:``,children:a.policyInherit}),t[29]=a.policyInherit,t[30]=_);let v;t[31]===a.policyEnabled?v=t[32]:(v=(0,H.jsx)(M,{value:`true`,children:a.policyEnabled}),t[31]=a.policyEnabled,t[32]=v);let y;t[33]===a.policyDisabled?y=t[34]:(y=(0,H.jsx)(M,{value:`false`,children:a.policyDisabled}),t[33]=a.policyDisabled,t[34]=y);let b;t[35]!==i||t[36]!==_||t[37]!==v||t[38]!==y||t[39]!==g||t[40]!==n.allowFallbacks?(b=(0,H.jsxs)(ee,{value:n.allowFallbacks,disabled:i,onChange:g,children:[_,v,y]}),t[35]=i,t[36]=_,t[37]=v,t[38]=y,t[39]=g,t[40]=n.allowFallbacks,t[41]=b):b=t[41];let x;t[42]!==b||t[43]!==h?(x=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[h,b]}),t[42]=b,t[43]=h,t[44]=x):x=t[44];let S;t[45]===a.modelMaxCostTierLabel?S=t[46]:(S=(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[45]=a.modelMaxCostTierLabel,t[46]=S);let C;t[47]!==r||t[48]!==n?(C=e=>r({...n,maxCostTier:e.target.value}),t[47]=r,t[48]=n,t[49]=C):C=t[49];let w;t[50]===a.policyInherit?w=t[51]:(w=(0,H.jsx)(M,{value:``,children:a.policyInherit}),t[50]=a.policyInherit,t[51]=w);let T;t[52]===a.costTierLow?T=t[53]:(T=(0,H.jsx)(M,{value:`low`,children:a.costTierLow}),t[52]=a.costTierLow,t[53]=T);let E;t[54]===a.costTierMedium?E=t[55]:(E=(0,H.jsx)(M,{value:`medium`,children:a.costTierMedium}),t[54]=a.costTierMedium,t[55]=E);let D;t[56]===a.costTierHigh?D=t[57]:(D=(0,H.jsx)(M,{value:`high`,children:a.costTierHigh}),t[56]=a.costTierHigh,t[57]=D);let O;t[58]!==i||t[59]!==C||t[60]!==w||t[61]!==T||t[62]!==E||t[63]!==D||t[64]!==n.maxCostTier?(O=(0,H.jsxs)(ee,{value:n.maxCostTier,disabled:i,onChange:C,children:[w,T,E,D]}),t[58]=i,t[59]=C,t[60]=w,t[61]=T,t[62]=E,t[63]=D,t[64]=n.maxCostTier,t[65]=O):O=t[65];let k;t[66]!==S||t[67]!==O?(k=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[S,O]}),t[66]=S,t[67]=O,t[68]=k):k=t[68];let A;t[69]!==x||t[70]!==k?(A=(0,H.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-panel/70 p-3 shadow-surface sm:grid-cols-2`,children:[x,k]}),t[69]=x,t[70]=k,t[71]=A):A=t[71];let j;return t[72]!==c||t[73]!==l||t[74]!==A||t[75]!==m?(j=(0,H.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-5 dark:border-edge`,children:[c,l,m,A]}),t[72]=c,t[73]=l,t[74]=A,t[75]=m,t[76]=j):j=t[76],j}function Xe(e){let t=(0,V.c)(64),{title:n,value:r,onChange:i,disabled:a,cp:s}=e,c;t[0]===n?c=t[1]:(c=(0,H.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=c);let l=s.modelToolPrimaryLabel,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=o(`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,`font-mono text-xs`),t[2]=u):u=t[2];let d;t[3]!==i||t[4]!==r?(d=e=>i({...r,primary:e.target.value}),t[3]=i,t[4]=r,t[5]=d):d=t[5];let f;t[6]!==a||t[7]!==d||t[8]!==r.primary?(f=(0,H.jsx)(`input`,{className:u,value:r.primary,disabled:a,placeholder:`provider/model`,onChange:d}),t[6]=a,t[7]=d,t[8]=r.primary,t[9]=f):f=t[9];let p;t[10]!==s.modelToolPrimaryLabel||t[11]!==f?(p=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l,f]}),t[10]=s.modelToolPrimaryLabel,t[11]=f,t[12]=p):p=t[12];let m=s.modelToolFallbacksLabel,h;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(h=o(`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,`min-h-20 resize-y font-mono text-xs`),t[13]=h):h=t[13];let g;t[14]!==i||t[15]!==r?(g=e=>i({...r,fallbacks:e.target.value}),t[14]=i,t[15]=r,t[16]=g):g=t[16];let _;t[17]!==s.modelToolFallbacksPlaceholder||t[18]!==a||t[19]!==g||t[20]!==r.fallbacks?(_=(0,H.jsx)(`textarea`,{className:h,value:r.fallbacks,disabled:a,placeholder:s.modelToolFallbacksPlaceholder,onChange:g}),t[17]=s.modelToolFallbacksPlaceholder,t[18]=a,t[19]=g,t[20]=r.fallbacks,t[21]=_):_=t[21];let v;t[22]!==s.modelToolFallbacksLabel||t[23]!==_?(v=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[m,_]}),t[22]=s.modelToolFallbacksLabel,t[23]=_,t[24]=v):v=t[24];let y;t[25]!==i||t[26]!==r?(y=e=>i({...r,timeoutMs:e.target.value}),t[25]=i,t[26]=r,t[27]=y):y=t[27];let b;t[28]!==a||t[29]!==y||t[30]!==r.timeoutMs?(b=(0,H.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:r.timeoutMs,disabled:a,onChange:y}),t[28]=a,t[29]=y,t[30]=r.timeoutMs,t[31]=b):b=t[31];let x;t[32]!==s.toolTimeoutLabel||t[33]!==b?(x=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[s.toolTimeoutLabel,b]}),t[32]=s.toolTimeoutLabel,t[33]=b,t[34]=x):x=t[34];let S;t[35]!==i||t[36]!==r?(S=e=>i({...r,autoProviderFallback:e.target.value}),t[35]=i,t[36]=r,t[37]=S):S=t[37];let C;t[38]===s.policyInherit?C=t[39]:(C=(0,H.jsx)(M,{value:``,children:s.policyInherit}),t[38]=s.policyInherit,t[39]=C);let w;t[40]===s.policyEnabled?w=t[41]:(w=(0,H.jsx)(M,{value:`true`,children:s.policyEnabled}),t[40]=s.policyEnabled,t[41]=w);let T;t[42]===s.policyDisabled?T=t[43]:(T=(0,H.jsx)(M,{value:`false`,children:s.policyDisabled}),t[42]=s.policyDisabled,t[43]=T);let E;t[44]!==a||t[45]!==S||t[46]!==C||t[47]!==w||t[48]!==T||t[49]!==r.autoProviderFallback?(E=(0,H.jsxs)(ee,{value:r.autoProviderFallback,disabled:a,onChange:S,children:[C,w,T]}),t[44]=a,t[45]=S,t[46]=C,t[47]=w,t[48]=T,t[49]=r.autoProviderFallback,t[50]=E):E=t[50];let D;t[51]!==s.modelAutoProviderFallbackLabel||t[52]!==E?(D=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[s.modelAutoProviderFallbackLabel,E]}),t[51]=s.modelAutoProviderFallbackLabel,t[52]=E,t[53]=D):D=t[53];let O;t[54]!==x||t[55]!==D?(O=(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[x,D]}),t[54]=x,t[55]=D,t[56]=O):O=t[56];let k;t[57]!==v||t[58]!==O||t[59]!==p?(k=(0,H.jsxs)(`div`,{className:`mt-3 grid gap-3`,children:[p,v,O]}),t[57]=v,t[58]=O,t[59]=p,t[60]=k):k=t[60];let A;return t[61]!==c||t[62]!==k?(A=(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 p-3 shadow-surface`,children:[c,k]}),t[61]=c,t[62]=k,t[63]=A):A=t[63],A}export{qe as CapabilityPresetsSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,s as t}from"./locale-store-
|
|
1
|
+
import{r as e,s as t}from"./locale-store-0lpYdNDr.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 t(e(`/api/channels/status`))).payload?.channels||[]}async function a(n){return(await t(e(`/api/sessions/chat-ids${n?`?channel=${encodeURIComponent(n)}`:``}`))).payload?.chatIds||[]}export{i as n,a as r,r as t};
|
|
@@ -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{l as i,u as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-BwQ3WssU.js";import{l,n as u,o as d,r as f,s as p}from"./locale-store-0lpYdNDr.js";import{i as m}from"./vendor-swr-BIWyz7Rc.js";import{$a as h,$r as g,Bo as _,Ds as v,Ho as y,Ja as b,Jc as x,Ll as S,Mr as C,Qa as w,Qr as T,Ro as E,Uo as D,Vo as O,Wo as k,Ys as A,Zr as j,_s as M,as as N,bc as P,bo as F,ct as I,ea as L,es as ee,hc as R,is as z,os as B,ou as te,sc as ne,ws as V,zo as re,zs as ie}from"./index-C8JkTS6d.js";import{n as ae,r as oe}from"./settings-page-layout-D3srt5Bi.js";import{n as se}from"./settings-loading-skeleton-DEwYqESe.js";import{t as ce}from"./schema-form-D7oCARF7.js";import{t as le}from"./browser-BLJWD7WI.js";import{n as ue,t as de}from"./channels-status-swr-Drk110ve.js";import{t as fe}from"./use-channel-catalog-CP9a_rAf.js";var H=e(t(),1),U=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(le(),1),W=r();async function he(e){let t=await d(f(`/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 G(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function J(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,H.useMemo)(()=>pe(e),[e]),o=(0,H.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,H.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,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){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{let t=q(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,H.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:G(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),G(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=a?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,p=K(c.payload),m=q(c.payload,e.id),h=m?c.generatedQr:J(c.payload),g=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),_=c.payload?.type===`form`?c.payload:null,v=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,W.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:s(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,W.jsxs)(V,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,W.jsx)(x,{className:`size-4 animate-spin`}):(0,W.jsx)(P,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,W.jsx)(A,{className:`size-4`}),f]}):null]})]}),p?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,g?(0,W.jsxs)(`div`,{className:s(`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,W.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:h?(0,W.jsx)(`img`,{src:h,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,W.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,W.jsx)(w,{className:`size-48 rounded-md`})})}),(0,W.jsxs)(`div`,{className:s(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[h?(0,W.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,W.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,W.jsx)(w,{className:`h-4 w-48 max-w-full`}),(0,W.jsx)(w,{className:`h-4 w-36 max-w-full`})]}),m?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:m,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(S,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,W.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,W.jsx)(te,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,_?(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(ce,{schema:_.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:o}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(_.submitAction,c.formDraft),children:n.saveSetup})]}):null,v?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:v.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.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,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function Y(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===Y(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=Y(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`?s(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,N):s(`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)]`,N,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,U.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,h=p===void 0?!1:p,g=n===`drawer`,[b,x]=(0,H.useState)(null),S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,W.jsx)(y,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,B)}),t[0]=S):S=t[0];let C;t[1]!==n||t[2]!==h?(C=Se(n,h),t[1]=n,t[2]=h,t[3]=C):C=t[3];let w;t[4]===c?w=t[5]:(w=c?(0,W.jsx)(k,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=w);let T;t[6]===l?T=t[7]:(T=l?(0,W.jsx)(O,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=T);let A;t[8]!==u||t[9]!==o||t[10]!==m||t[11]!==g||t[12]!==a?(A=g?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,W.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,W.jsx)(re,{asChild:!0,children:(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,W.jsx)(v,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(re,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:s(M,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,W.jsx)(v,{className:`size-4`})})}),m]}),t[8]=u,t[9]=o,t[10]=m,t[11]=g,t[12]=a,t[13]=A):A=t[13];let j=g?`p-4`:`p-6`,N;t[14]===j?N=t[15]:(N=s(`min-h-0 flex-1 overflow-y-auto`,j),t[14]=j,t[15]=N);let P;t[16]!==d||t[17]!==N?(P=(0,W.jsx)(`div`,{className:N,children:d}),t[16]=d,t[17]=N,t[18]=P):P=t[18];let F;t[19]!==f||t[20]!==b||t[21]!==w||t[22]!==T||t[23]!==A||t[24]!==P?(F=(0,W.jsxs)(z,{layer:`modal`,portalContainer:b,children:[w,T,A,P,f]}),t[19]=f,t[20]=b,t[21]=w,t[22]=T,t[23]=A,t[24]=P,t[25]=F):F=t[25];let I;t[26]!==F||t[27]!==C?(I=(0,W.jsxs)(D,{children:[S,(0,W.jsx)(_,{ref:x,className:C,onOpenAutoFocus:we,children:F})]}),t[26]=F,t[27]=C,t[28]=I):I=t[28];let L;return t[29]!==i||t[30]!==r||t[31]!==I?(L=(0,W.jsx)(E,{open:r,onOpenChange:i,children:I}),t[29]=i,t[30]=r,t[31]=I,t[32]=L):L=t[32],L}function we(e){return e.preventDefault()}var Te=(0,H.memo)(function(e){let t=(0,U.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,W.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,W.jsx)(L,{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,W.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,U.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,W.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,W.jsx)(V,{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,W.jsx)(V,{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,W.jsx)(V,{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,W.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,W.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}var De=`channels-status`;function Oe(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function ke(e){let t=t=>e(t.detail);return window.addEventListener(De,t),()=>window.removeEventListener(De,t)}function Ae(e,t){let n=(0,U.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return ke(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,H.useEffect)(i,a)}function je(e){return e?f(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Me(e){return(await p(f(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ne=[`enabled`];async function Pe(){let e=await p(f(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Fe(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Ie(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(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 Le(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Re(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function ze(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 Be(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ne.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ne.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ve(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function He(e,t){let n={...Ve(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(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Ve(r[n]),properties:{}}),e===t.length-1){o[n]=Ve(r[n]);break}i=r[n],a=o[n]}}return n}function Ue(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ue(n)&&delete t[e];return Object.keys(t).length===0}function We(e,t){let n=Ve(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return Ue(n),n}function Ge(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Ke(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function qe(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Je(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 Ye(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push(Qe(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Je(e,Ke(t,e),n);i&&r.push(i)}let a=qe(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Q(e,t){let n=X(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 Xe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function Ze(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 Qe(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 $e({entry:e}){let t=l(e=>e.token),[n,r]=(0,H.useState)(!1),i=(0,H.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(f(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Fe(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,W.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,W.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,W.jsx)(h,{sourceChannel:e.id,className:`size-7`})})}function et(e){let t=(0,U.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 c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=s(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=s(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,W.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]!==u||t[14]!==p?(m=(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function tt(e){let t=(0,U.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=X(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ye(n,r,c),o=Ze(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,W.jsx)($e,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=s(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,ze(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Le(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,W.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]!==x?(T=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,W.jsx)(et,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=l,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,W.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(rt)}):null]}):(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Xe(n,c)}),o.length>0?(0,W.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(nt)}):null]}),t[2]=a,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let S;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(S=(0,W.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=S):S=t[52];let C=a||o,w;t[53]!==a||t[54]!==o?(w=a||o?(0,W.jsx)(x,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=w):w=t[55];let T;t[56]!==c||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?c.restartingChannel:i===`stopped`?c.restartChannel:Q(n,c),t[56]=c,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==w||t[63]!==T||t[64]!==C?(E=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(V,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:C,children:[w,T]})}),t[61]=m,t[62]=w,t[63]=T,t[64]=C,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==y||t[68]!==b||t[69]!==S?(D=(0,W.jsxs)(`article`,{className:y,children:[b,S,E]}),t[66]=E,t[67]=y,t[68]=b,t[69]=S,t[70]=D):D=t[70],D}function nt(e){return(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function rt(e){return(0,W.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function it(e){let t=(0,U.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:c,ch:l,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?te:n===`stopped`||n===`needs_setup`?o:x,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=s(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,W.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let S;t[9]===l.connectionStatus?S=t[10]:(S=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectionStatus}),t[9]=l.connectionStatus,t[10]=S);let C;t[11]!==l||t[12]!==n?(C=Re(n,l),t[11]=l,t[12]=n,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,W.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,W.jsxs)(`div`,{children:[S,w]}),t[16]=w,t[17]=S,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==b?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,T]}),t[19]=T,t[20]=b,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,W.jsx)(x,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let k=i?l.checkingConnection:l.checkConnection,A;t[24]!==d||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,W.jsxs)(V,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:d,children:[O,k]}),t[24]=d,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==l.restartChannel||t[30]!==l.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,W.jsxs)(V,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,W.jsx)(x,{className:`size-4 animate-spin`}):(0,W.jsx)(R,{className:`size-4`}),r?l.restartingChannel:l.restartChannel]}):null,t[29]=l.restartChannel,t[30]=l.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==c||t[37]!==l.connectionOptions||t[38]!==l.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==a?(M=c?(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:a?l.hideConnectionOptions:l.connectionOptions}):null,t[36]=c,t[37]=l.connectionOptions,t[38]=l.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=a,t[43]=M):M=t[43];let N;t[44]!==A||t[45]!==j||t[46]!==M?(N=(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,j,M]}),t[44]=A,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==E||t[49]!==N?(P=(0,W.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,N]})}),t[48]=E,t[49]=N,t[50]=P):P=t[50],P}function at(e){let t=(0,U.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=X(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 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,W.jsx)(ie,{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,W.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,W.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,W.jsx)(`li`,{children:Qe(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,W.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,W.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,W.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,W.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ot(){let e=u(e=>e.language),t=c(e),n=l(e=>!!e.token),r=i(),{channelId:o}=a(),p=g(o),h=fe(n,e),_=h.entries,{data:v,mutate:y,isValidating:x}=m(n?de():null,ue,{revalidateOnFocus:!0}),{data:w,mutate:E}=m(n?`channels-config-map`:null,Pe,{revalidateOnFocus:!1}),D=w?.channels??{},O=w?.bindings??[],{data:k}=m(n?`channel-routing-agents`:null,b,{revalidateOnFocus:!1}),A=F(e=>e.setPageHeader),M=F(e=>e.clearPageHeader),N=(0,H.useMemo)(()=>_.find(e=>e.id===p),[p,_]),P=N?Ie(N):null,{data:L,mutate:R}=m(n&&P?je(P):null,()=>Me(P)),[z,B]=(0,H.useState)(null),[te,V]=(0,H.useState)(!1),[re,ie]=(0,H.useState)(null),[le,U]=(0,H.useState)(null),[me,he]=(0,H.useState)(!1),[G,K]=(0,H.useState)(null),[q,J]=(0,H.useState)(null),_e=z??L??{},Y=t.channelsSettings,be=(0,H.useMemo)(()=>N?.configSchema??{type:`object`,properties:{}},[N?.configSchema]),Se=(0,H.useMemo)(()=>We(be,Ne),[be]),we=(0,H.useMemo)(()=>Be(N),[N]),De=(0,H.useMemo)(()=>He(Se,we),[we,Se]),ke=(0,H.useMemo)(()=>We(Se,we),[we,Se]),Fe=(0,H.useMemo)(()=>Ge(De),[De]),Re=N?q??ve(O,N.id):``,Z=(0,H.useMemo)(()=>(k?.items??[]).map(e=>{let n=C(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[k?.items,t.agentsSettings]),Ve=k?.items.find(e=>e.id===k.defaultId),Ue=Ve?C(Ve,t.agentsSettings):k?.defaultId??``,Ke=(0,H.useMemo)(()=>({defaultBooleanLabel:Y.schemaBooleanDefault,unsupportedArrayType:Y.schemaUnsupportedArrayType,arrayAddPlaceholder:Y.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>Y.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[Y]),qe=(0,H.useMemo)(()=>new Map((v??[]).map(e=>[e.name,e])),[v]),Je=v!==void 0,Ye=(0,H.useCallback)(e=>xe(e,qe.get(e.id),Je),[qe,Je]),Q=(0,H.useCallback)(async()=>{await Promise.all([h.mutate(),y()])},[h,y]);Ae((0,H.useCallback)(e=>{let t=Oe(e);t&&y(t,!1)},[y]),n);let Xe=(0,H.useMemo)(()=>n?(0,W.jsx)(Te,{ch:Y,refreshing:h.isValidating||x,saveOk:!1,onRefresh:()=>void Q()}):null,[h.isValidating,Y,n,x,Q]);(0,H.useLayoutEffect)(()=>(A({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>M()),[M,Xe,t.settingsSections.channels,A]);let Ze=(0,H.useCallback)(e=>{r(T(e)),B(null),J(null),K(null)},[r]),Qe=(0,H.useCallback)(()=>{r(j),B(null),J(null),K(null)},[r]),nt=(0,H.useCallback)(async e=>{U(e.id),K(null);try{let t=await d(f(`/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){K(e instanceof Error?e.message:String(e))}finally{U(null)}},[Q]);(0,H.useEffect)(()=>{J(null),he(!1)},[N?.id]);let rt=(0,H.useCallback)(async()=>{if(!N||!z&&q===null)return!1;let e=Ie(N);V(!0),K(null);try{let t=await d(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({...z?{channels:{[e]:z}}:{},...q===null?{}:{bindings:ye(O,N.id,q)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return z&&await R(z,!1),await E(),await h.mutate(),B(null),J(null),!0}catch(e){return K(e instanceof Error?e.message:String(e)),!1}finally{V(!1)}},[N,q,O,h,z,E,R]),ot=(0,H.useCallback)(async e=>{let t=X(e),n=Ie(e),r=N?.id===e.id?z:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ie(e.id),K(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await d(f(`/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 h.mutate(),await E(),await y(),N?.id===e.id&&(await R(),B(null))}catch(e){K(e instanceof Error?e.message:String(e))}finally{ie(null)}},[N?.id,h,z,E,R,y,Ze]),$=N?.ui?.modal,st=$?.placement!==`replace-config`,ct=N?Ye(N):`checking`,lt=N?!X(N).ready||me:!1;return n?(0,W.jsxs)(oe,{gap:`gap-4`,children:[h.isLoading?(0,W.jsx)(se,{sections:2}):h.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(h.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:_.map(e=>(0,W.jsx)(tt,{entry:e,config:D[Ie(e)]?.config,runtime:Ye(e),busy:re===e.id,restarting:le===e.id,ch:Y,onOpen:()=>Ze(e.id),onToggle:()=>void ot(e),onRestart:()=>void nt(e)},e.id))}),G?(0,W.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:G}):null,(0,W.jsx)(Ce,{presentation:`modal`,open:!!N,onOpenChange:e=>{e||Qe()},closeAriaLabel:Y.close,srTitle:N?.label??Y.selectChannel,srDescription:N?.description,wide:!0,footer:N?(0,W.jsx)(Ee,{ch:Y,dirty:!!z||q!==null,saving:te,onCancel:Qe,onDiscard:()=>{B(null),J(null)},onSave:rt}):null,children:N?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,W.jsx)($e,{entry:N}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:N.label}),(0,W.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,ze(ct)),children:Le(ct,Y)})]}),(0,W.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,W.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(N).ready&&pe(N)?.[1].result===`qr`?Y.scanLoginHint.replace(`{{channel}}`,N.label):N.description}),N.docsPath?(0,W.jsxs)(`a`,{href:N.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[Y.docs,(0,W.jsx)(S,{className:`size-3.5`})]}):null]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,W.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(N).enabled?Y.enabledLabel:Y.disabledLabel}),(0,W.jsx)(et,{checked:X(N).enabled,disabled:re===N.id,label:Y.toggleChannel.replace(`{{channel}}`,N.label),onToggle:()=>void ot(N)})]})]})}),(0,W.jsx)(it,{runtime:ct,restarting:le===N.id,checking:x,showConnectionOptions:me,canManageConnection:X(N).ready&&$?.placement!==`replace-config`,ch:Y,onRestart:()=>void nt(N),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,W.jsx)(at,{entry:N,ch:Y}),lt&&$?.placement!==`replace-config`?(0,W.jsx)(ge,{entry:N,locale:e,messages:Y,compact:!0,onChanged:async()=>{await R(),await Q(),await E()}},N.id):null,$?.entrypoint&&$.placement===`before-config`?(0,W.jsx)(I,{extensionId:N.extensionId,extensionName:N.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:N.id,entry:N,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,W.jsx)(I,{extensionId:N.extensionId,extensionName:N.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:N.id,entry:N,config:_e}}):null,st&&Fe?(0,W.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.basicConfiguration}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.basicConfigurationHint})]}),(0,W.jsx)(ce,{schema:De,values:_e,onChange:e=>B(e),disabled:te,labels:Ke})]}):null,(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.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,W.jsx)(ne,{className:`size-4 text-fg-muted`}),Y.messageHandling]}),(0,W.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.agentRouting}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.messageHandlingHint})]}),(0,W.jsx)(ee,{value:Re,options:Z,placeholder:Y.agentRoutingSelect,emptyLabel:Y.agentRoutingDefault.replace(`{{agent}}`,Ue||Y.agentRoutingSelect),ariaLabel:Y.agentRouting,disabled:te||!k,onChange:e=>J(e)})]})]}),st&&Ge(ke)?(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.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,W.jsx)(ne,{className:`size-4 text-fg-muted`}),Y.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,W.jsx)(ce,{schema:ke,values:_e,onChange:e=>B(e),disabled:te,labels:Ke})})]}):null,G?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:G}):null]}):null})]}):(0,W.jsxs)(oe,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,W.jsx)(ae,{title:t.settingsSections.channels}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Y.tokenRequired})]})}export{ot as ChannelsSettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./locale-store-0lpYdNDr.js";import{n as t}from"./channel-recipient-api-DYQyGDw4.js";function n(){return e(`/api/channels/status`)}var r=t;export{r as n,n as t};
|
package/dist/gateway/static/root/assets/{connector-logo-BbjzIs87.js → connector-logo-Bng6kxYF.js}
RENAMED
|
@@ -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"./cn-JdwAhgNB.js";import{
|
|
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"./cn-JdwAhgNB.js";import{Ic as a}from"./index-C8JkTS6d.js";var o=n(),s=e(t(),1),c=r(),l={sm:{frame:`size-9 rounded-lg`,image:`size-6`,fallback:`size-4`},md:{frame:`size-10 rounded-xl`,image:`size-7`,fallback:`size-5`},lg:{frame:`size-12 rounded-xl`,image:`size-8`,fallback:`size-5`}};function u(e){let t=(0,o.c)(18),{connector:n,size:r,className:u}=e,d=r===void 0?`md`:r,f=n?.branding?.logoUrl,[p,m]=(0,s.useState)(!1),h=l[d],g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{m(!1)},t[0]=g):g=t[0];let _;t[1]===f?_=t[2]:(_=[f],t[1]=f,t[2]=_),(0,s.useEffect)(g,_);let v;t[3]!==u||t[4]!==h.frame?(v=i(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-surface-base`,h.frame,u),t[3]=u,t[4]=h.frame,t[5]=v):v=t[5];let y;t[6]===n?y=t[7]:(y=n?.branding?.backgroundColor?{backgroundColor:n.branding.backgroundColor}:void 0,t[6]=n,t[7]=y);let b=n?.displayName,x;t[8]!==h.fallback||t[9]!==h.image||t[10]!==p||t[11]!==f?(x=f&&!p?(0,c.jsx)(`img`,{src:f,alt:``,loading:`lazy`,draggable:!1,className:i(`object-contain`,h.image),onError:()=>m(!0)}):(0,c.jsx)(a,{className:i(`text-fg-muted`,h.fallback),"aria-hidden":!0}),t[8]=h.fallback,t[9]=h.image,t[10]=p,t[11]=f,t[12]=x):x=t[12];let S;return t[13]!==v||t[14]!==y||t[15]!==b||t[16]!==x?(S=(0,c.jsx)(`span`,{className:v,style:y,title:b,children:x}),t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S):S=t[17],S}export{u as t};
|
|
@@ -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}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{n as c}from"./copy-to-clipboard-HOJ79TWv.js";import{t as l}from"./messages-BwQ3WssU.js";import{l as u,n as d,r as f,s as p}from"./locale-store-0lpYdNDr.js";import{Bo as m,Bs as h,Cs as g,Dc as _,Ds as v,Fi as y,Hl as b,Ho as x,Ic as S,Ii as C,Jc as w,Li as T,Ll as E,Ms as D,Os as O,Pi as k,Ri as A,Ro as j,Tc as M,Uo as N,Vo as P,Wo as F,Xa as I,Xl as L,Xs as R,Za as z,Zl as B,_c as ee,_i as V,as as H,bi as U,bo as te,cc as ne,ea as re,es as ie,gi as ae,hi as oe,hs as se,ic as ce,jl as le,ll as ue,os as de,ou as fe,pc as pe,qs as me,rs as W,sc as he,ts as ge,uc as _e,uu as ve,vi as ye,vs as G,wc as K,ws as q,zo as J}from"./index-C8JkTS6d.js";import{t as be}from"./page-tabs-Caj1-E_X.js";import{t as xe}from"./connector-logo-Bng6kxYF.js";var Y=e(t(),1),X=n(),Z=r();function Se(e){let t=(0,X.c)(74),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o.connect||t[5]!==o.connectedBadge||t[6]!==o.connectorBeta||t[7]!==o.connectorCapabilityLabels||t[8]!==o.connectorExperimental||t[9]!==o.connectorVerified){let e=n.capabilities.filter(Ce),v=e.slice(0,3),y=Math.max(0,e.length-v.length),b=o.connect,x=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,C;t[20]!==b||t[21]!==n||t[22]!==i?(C=e=>(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:s(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),i(n)},children:[(0,Z.jsx)(S,{className:`size-4`}),b]}),t[20]=b,t[21]=n,t[22]=i,t[23]=C):C=t[23],c=C;let w;t[24]!==n||t[25]!==a?(w=e=>{!a||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a(n))},t[24]=n,t[25]=a,t[26]=w):w=t[26];let T=w,E=a?`cursor-pointer`:null;t[27]===E?p=t[28]:(p=s(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,E),t[27]=E,t[28]=p),m=a?`button`:void 0,h=a?0:void 0,t[29]!==n||t[30]!==a?(g=()=>a?.(n),t[29]=n,t[30]=a,t[31]=g):g=t[31],_=T,l=`flex min-w-0 flex-1 flex-col`;let D;t[32]===n?D=t[33]:(D=(0,Z.jsx)(xe,{connector:n}),t[32]=n,t[33]=D);let O;t[34]===n.displayName?O=t[35]:(O=(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[34]=n.displayName,t[35]=O);let k;t[36]===x?k=t[37]:(k=x?(0,Z.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:x}):null,t[36]=x,t[37]=k);let A;t[38]!==O||t[39]!==k?(A=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[O,k]}),t[38]=O,t[39]=k,t[40]=A):A=t[40];let j;t[41]!==D||t[42]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[D,A]}),t[41]=D,t[42]=A,t[43]=j):j=t[43];let M;t[44]!==r||t[45]!==c?(M=r?null:(0,Z.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:c()}),t[44]=r,t[45]=c,t[46]=M):M=t[46];let N;t[47]!==r||t[48]!==o.connectedBadge?(N=r?(0,Z.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,Z.jsx)(fe,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[47]=r,t[48]=o.connectedBadge,t[49]=N):N=t[49];let P;t[50]!==M||t[51]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[M,N]}),t[50]=M,t[51]=N,t[52]=P):P=t[52],t[53]!==j||t[54]!==P?(u=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[j,P]}),t[53]=j,t[54]=P,t[55]=u):u=t[55],t[56]===n.description?d=t[57]:(d=(0,Z.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[56]=n.description,t[57]=d),f=v.length>0?(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[v.map(e=>(0,Z.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),y>0?(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,y]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o.connect,t[5]=o.connectedBadge,t[6]=o.connectorBeta,t[7]=o.connectorCapabilityLabels,t[8]=o.connectorExperimental,t[9]=o.connectorVerified,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=m,t[17]=h,t[18]=g,t[19]=_}else c=t[10],l=t[11],u=t[12],d=t[13],f=t[14],p=t[15],m=t[16],h=t[17],g=t[18],_=t[19];let v;t[58]!==l||t[59]!==u||t[60]!==d||t[61]!==f?(v=(0,Z.jsxs)(`div`,{className:l,children:[u,d,f]}),t[58]=l,t[59]=u,t[60]=d,t[61]=f,t[62]=v):v=t[62];let y;t[63]!==r||t[64]!==c?(y=r?null:(0,Z.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:c(`w-full`)}),t[63]=r,t[64]=c,t[65]=y):y=t[65];let b;return t[66]!==v||t[67]!==y||t[68]!==p||t[69]!==m||t[70]!==h||t[71]!==g||t[72]!==_?(b=(0,Z.jsxs)(`div`,{className:p,role:m,tabIndex:h,onClick:g,onKeyDown:_,children:[v,y]}),t[66]=v,t[67]=y,t[68]=p,t[69]=m,t[70]=h,t[71]=g,t[72]=_,t[73]=b):b=t[73],b}function Ce(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var we=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function Te(e,t){return t.some(t=>t.connectorId===e.id)}var Ee=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function De(){let e=(0,X.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:s(`size-10 shrink-0 rounded-xl`,Ee)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.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,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsx)(`div`,{className:s(`h-4 min-w-0 flex-1`,Ee)}),(0,Z.jsx)(`div`,{className:s(`h-8 w-[4.5rem] shrink-0 rounded-lg`,Ee)})]}),(0,Z.jsx)(`div`,{className:s(`h-3 w-full`,Ee)}),(0,Z.jsx)(`div`,{className:s(`h-3 w-[88%]`,Ee)})]})]})}),e[1]=n):n=e[1],n}var Oe=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ke(){let e=(0,X.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:s(`size-10 shrink-0 rounded-xl`,Oe)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,Z.jsx)(`div`,{className:s(`h-4 w-48 max-w-full`,Oe)}),(0,Z.jsx)(`div`,{className:s(`h-3 w-72 max-w-full`,Oe)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Z.jsx)(`div`,{className:s(`h-9 w-20 rounded-lg`,Oe)}),(0,Z.jsx)(`div`,{className:s(`h-9 w-20 rounded-lg`,Oe)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Z.jsx)(`div`,{className:s(`h-8 w-20 rounded-md`,Oe)}),(0,Z.jsx)(`div`,{className:s(`h-8 w-24 rounded-md`,Oe)}),(0,Z.jsx)(`div`,{className:s(`h-8 w-28 rounded-md`,Oe)})]}),(0,Z.jsx)(`div`,{className:s(`mt-3 h-20 rounded-xl`,Oe)})]}),e[3]=i):i=e[3],i}function Q(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function Ae(){return Q(await p(f(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function je(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.refresh&&t.set(`refresh`,`1`),e?.verification&&t.set(`verification`,e.verification),Q(await p(f(`/api/connectors/composio/catalog${t.size?`?${t.toString()}`:``}`)),`Could not load Composio catalog.`)}async function Me(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),Q(await p(f(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function Ne(e,t){return Q(await p(f(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function Pe(e,t,n){let r=await p(f(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return I(),Q(r,`Could not install Store connector.`).instance}async function Fe(){return Q(await p(f(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function Ie(e){return Q(await p(f(`/api/connectors/${encodeURIComponent(e)}/auth/start`),{method:`POST`}),`Could not start connector authorization.`).authorization}async function Le(){return Q(await p(f(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function Re(e){Q(await p(f(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:e})}),`Could not enable the connection service.`)}async function ze(e,t){let n=await p(f(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return I(),Q(n,`Could not install connector.`).instance}async function Be(e,t={}){return Q(await p(f(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function Ve(e,t){return Q(await p(f(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function He(e){await p(f(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),I()}async function Ue(e){return Q(await p(f(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function We(){return Q(await p(f(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function Ge(e,t){return Q(await p(f(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio connection.`).connection}async function Ke(e){return Q(await p(f(`/api/connectors/composio/${encodeURIComponent(e)}/health`)),`Could not check Composio connector health.`).health}async function qe(e){await p(f(`/api/connectors/composio/connections/${encodeURIComponent(e)}/refresh`),{method:`POST`})}async function Je(e){await p(f(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Ye(e){return Q(await p(f(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function Xe(e,t){let n=await p(f(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return I(),Q(n,`Could not update Composio scope.`).scope}async function Ze(e){return Q(await p(f(`/api/connectors/composio/${encodeURIComponent(e)}/policy`)),`Could not load Composio policy.`)}async function Qe(e,t){return Q(await p(f(`/api/connectors/composio/${encodeURIComponent(e)}/policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio policy.`).policy}async function $e(e){return Q(await p(f(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function et(e=50){return Q(await p(f(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}async function tt(e){return Q(await p(f(`/api/connectors/${encodeURIComponent(e.connectorId)}/memory-sync`),{method:`POST`,body:JSON.stringify(e)}),`Could not sync connector data to memory.`)}async function nt(e){return Q(await p(f(`/api/connectors/${encodeURIComponent(e)}/memory-sync-profile`)),`Could not load memory sync settings.`).profile}async function rt(e,t){return Q(await p(f(`/api/connectors/${encodeURIComponent(e)}/memory-sync-profile`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not save memory sync settings.`).profile}async function it(e){return Q(await p(f(`/api/connectors/${encodeURIComponent(e)}/memory-sync`),{method:`POST`,body:JSON.stringify({})}),`Could not sync connector data to memory.`)}async function at(e=``,t=100){return Q(await p(f(`/api/connectors/people?${new URLSearchParams({q:e,limit:String(t)}).toString()}`)),`Could not load the connected people graph.`)}async function ot(e=`pending`){return Q(await p(f(`/api/connectors/approvals?status=${encodeURIComponent(e)}`)),`Could not load connector approvals.`).approvals}async function st(e,t){return Q(await p(f(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:e,decision:t})}),`Could not update connector approval.`).approval}function ct(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function lt(e,t){return t.connectorCapabilityLabels[e]??e}function ut(e,t){if(e.runtime.type===`mcp`)return ct(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`channel`?e.runtime.channelId:e.runtime.type===`nativeTool`?e.runtime.toolsetId:e.runtime.sourceKind;return ct(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function dt(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function ft(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function pt(e){let t=(0,X.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(mt),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,Z.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function mt(e){return(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Z.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function ht({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,o]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),f=ft(e),p=e.capabilities.slice(0,8),h=Math.max(0,e.capabilities.length-p.length),g=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:i.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:i.connectorSetupConfig}))],y=async()=>{o(!0),d(null);try{l(await Be(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,Z.jsx)(j,{open:!0,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(N,{children:[(0,Z.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Z.jsxs)(m,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(xe,{connector:e,size:`lg`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[t?(0,Z.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md 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,Z.jsx)(fe,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]})}):null,(0,Z.jsx)(F,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Z.jsx)(P,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),"aria-label":i.modalClose,children:[(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Z.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),i.detailTools]}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?ct(i.connectorPreviewToolsCount,{count:c.toolCount}):i.connectorPreviewUnknown})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Z.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),i.detailPermissions]}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:dt(e,i)})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Z.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRequiredInputs]}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:ct(i.connectorRequiredInputsCount,{count:f})})]})]}),(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorCapabilitiesTitle}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[p.map(e=>(0,Z.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:lt(e,i)},e)),h>0?(0,Z.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,h]}):null]})]}),u?(0,Z.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorPreviewTitle}),(0,Z.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?i.healthStatusHealthy:i.healthStatusLabels[c.status]??c.status})]}),(0,Z.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,Z.jsx)(`div`,{className:`text-fg-muted`,children:i.toolsMetric})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,Z.jsx)(`div`,{className:`text-fg-muted`,children:i.resourcesMetric})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,Z.jsx)(`div`,{className:`text-fg-muted`,children:i.promptsMetric})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(pt,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Z.jsx)(pt,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Z.jsx)(pt,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??ct(i.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,Z.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,Z.jsxs)(`aside`,{className:`space-y-3`,children:[(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(ue,{className:`size-4 text-accent`,"aria-hidden":!0}),i.detailPermissions]}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:dt(e,i)})]}),(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(b,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorSetupTitle]}),g.length>0?(0,Z.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:g.map(e=>(0,Z.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,Z.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,Z.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:i.connectorSetupRequired}):null]}),e.description?(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:i.connectorSetupNone})]}),(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(ne,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,Z.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:ut(e,i)})]})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsx)(q,{variant:`secondary`,children:i.modalClose})}),(0,Z.jsxs)(q,{variant:`secondary`,disabled:a,onClick:()=>void y(),children:[a?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(O,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,Z.jsxs)(q,{variant:`secondary`,disabled:!0,children:[(0,Z.jsx)(_,{className:`size-4`}),i.connectedBadge]}):(0,Z.jsxs)(q,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,Z.jsx)(S,{className:`size-4`}),i.connect]})]})]})]})})}var gt=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g);function _t(e){let t=(0,X.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:o,onClose:c,t:l,mcp:u}=e,d;t[0]===c?d=t[1]:(d=e=>{e||c()},t[0]=c,t[1]=d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=s(`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-panel shadow-float dark:border-edge`),t[3]=p):p=t[3];let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,Z.jsx)(M,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=h):h=t[4];let g;t[5]===l.runtimeSettingsTitle?g=t[6]:(g=(0,Z.jsx)(F,{className:`text-base font-semibold text-fg`,children:l.runtimeSettingsTitle}),t[5]=l.runtimeSettingsTitle,t[6]=g);let _;t[7]===l.runtimeSettingsHint?_=t[8]:(_=(0,Z.jsx)(P,{className:`mt-1 text-sm text-fg-muted`,children:l.runtimeSettingsHint}),t[7]=l.runtimeSettingsHint,t[8]=_);let y;t[9]!==g||t[10]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[g,_]})]}),t[9]=g,t[10]=_,t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),t[12]=b):b=t[12];let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=S):S=t[13];let C;t[14]===l.modalClose?C=t[15]:(C=(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:b,"aria-label":l.modalClose,children:S})}),t[14]=l.modalClose,t[15]=C);let T;t[16]!==C||t[17]!==y?(T=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[y,C]}),t[16]=C,t[17]=y,t[18]=T):T=t[18];let E;t[19]===u.idleTtlLabel?E=t[20]:(E=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:u.idleTtlLabel}),t[19]=u.idleTtlLabel,t[20]=E);let D;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(D=s(gt,`w-40 flex-none`),t[21]=D):D=t[21];let O=r??``,k;t[22]===a?k=t[23]:(k=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=k);let A;t[24]!==u.idleTtlPlaceholder||t[25]!==O||t[26]!==k?(A=(0,Z.jsx)(`input`,{type:`number`,min:0,className:D,value:O,placeholder:u.idleTtlPlaceholder,onChange:k}),t[24]=u.idleTtlPlaceholder,t[25]=O,t[26]=k,t[27]=A):A=t[27];let I;t[28]===u.idleTtlHint?I=t[29]:(I=(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:u.idleTtlHint}),t[28]=u.idleTtlHint,t[29]=I);let L;t[30]!==E||t[31]!==A||t[32]!==I?(L=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Z.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[E,A,I]})}),t[30]=E,t[31]=A,t[32]=I,t[33]=L):L=t[33];let R;t[34]!==c||t[35]!==i||t[36]!==l.modalCancel?(R=(0,Z.jsx)(q,{type:`button`,variant:`secondary`,disabled:i,onClick:c,children:l.modalCancel}),t[34]=c,t[35]=i,t[36]=l.modalCancel,t[37]=R):R=t[37];let z;t[38]===o?z=t[39]:(z=()=>void o(),t[38]=o,t[39]=z);let B;t[40]===i?B=t[41]:(B=i?(0,Z.jsx)(w,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=B);let ee;t[42]!==u.save||t[43]!==i||t[44]!==z||t[45]!==B?(ee=(0,Z.jsxs)(q,{type:`button`,variant:`primary`,disabled:i,onClick:z,children:[B,u.save]}),t[42]=u.save,t[43]=i,t[44]=z,t[45]=B,t[46]=ee):ee=t[46];let V;t[47]!==R||t[48]!==ee?(V=(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[R,ee]}),t[47]=R,t[48]=ee,t[49]=V):V=t[49];let H;t[50]!==T||t[51]!==L||t[52]!==V?(H=(0,Z.jsxs)(N,{children:[f,(0,Z.jsxs)(m,{className:p,children:[T,L,V]})]}),t[50]=T,t[51]=L,t[52]=V,t[53]=H):H=t[53];let U;return t[54]!==n||t[55]!==d||t[56]!==H?(U=(0,Z.jsx)(j,{open:n,onOpenChange:d,children:H}),t[54]=n,t[55]=d,t[56]=H,t[57]=U):U=t[57],U}var vt=(0,Y.memo)(function(e){let t=(0,X.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,o;t[0]===a?o=t[1]:(o=s(`relative flex 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 shadow-surface`,a),t[0]=a,t[1]=o);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(_e,{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]=c):c=t[2];let l;t[3]===r?l=t[4]:(l=e=>r(e.currentTarget.value),t[3]=r,t[4]=l);let u;t[5]!==i||t[6]!==l||t[7]!==n?(u=(0,Z.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:n,onChange:l,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 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]=l,t[7]=n,t[8]=u):u=t[8];let d;return t[9]!==o||t[10]!==u?(d=(0,Z.jsxs)(`label`,{className:o,children:[c,u]}),t[9]=o,t[10]=u,t[11]=d):d=t[11],d}),yt=(0,Y.memo)(function(e){let t=(0,X.c)(30),{onBrowseCatalog:n,onAddCustomServer:r,onOpenRuntimeSettings:i,addLabel:a,browseLabel:o,customLabel:c,settingsLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(he,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:l}),t[1]=l,t[2]=d);let f;t[3]!==i||t[4]!==l||t[5]!==d?(f=(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,className:`shrink-0 gap-2`,"aria-label":l,title:l,onClick:i,children:[u,d]}),t[3]=i,t[4]=l,t[5]=d,t[6]=f):f=t[6];let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(K,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=p):p=t[7];let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(ve,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=m):m=t[8];let h;t[9]===a?h=t[10]:(h=(0,Z.jsx)(U,{asChild:!0,children:(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[p,a,m]})}),t[9]=a,t[10]=h);let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=s(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,G.transition),t[11]=g):g=t[11];let _;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(me,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=_):_=t[12];let v;t[13]!==o||t[14]!==n?(v=(0,Z.jsxs)(ae,{className:g,onSelect:n,children:[_,o]}),t[13]=o,t[14]=n,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=s(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,G.transition),t[16]=y):y=t[16];let b;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(O,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=b):b=t[17];let x;t[18]!==c||t[19]!==r?(x=(0,Z.jsxs)(ae,{className:y,onSelect:r,children:[b,c]}),t[18]=c,t[19]=r,t[20]=x):x=t[20];let S;t[21]!==x||t[22]!==v?(S=(0,Z.jsx)(V,{children:(0,Z.jsxs)(oe,{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[21]=x,t[22]=v,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==h?(C=(0,Z.jsxs)(ye,{children:[h,S]}),t[24]=S,t[25]=h,t[26]=C):C=t[26];let w;return t[27]!==C||t[28]!==f?(w=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[f,C]}),t[27]=C,t[28]=f,t[29]=w):w=t[29],w}),bt=/^([^:=]+)[:=](.*)$/;function xt(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=bt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function St(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 Ct(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 wt(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 Tt(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)||wt(t)&&(r[e]=t);return r}function Et(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function Dt(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 Ot(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=Et(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=Dt(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=St(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function kt(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;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:Ct(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function At(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function jt(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)||wt(t)?[]:[kt(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 Mt(e){return Ot(e)}async function Nt(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]=Ot(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 p(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),I()}function Pt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}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 Ft(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 It(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 Lt(e,t){let n=await p(f(`/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=Pt(n.payload.tools),i=Ft(n.payload.resources),a=It(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 Rt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function zt(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 Bt(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 $(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function Vt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),p=Bt(e),m=(0,Y.useCallback)(async()=>{o(!0),f(null);try{let t=await Lt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),g=(0,Y.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,Z.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]})]}),p?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,Z.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:$(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(q,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(_,{className:`size-4`}),t.testConnection]}),(0,Z.jsxs)(q,{variant:`ghost`,disabled:s,onClick:()=>void g(),children:[s?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(h,{className:`size-4`}),t.removeServer]})]})]})]})}function Ht(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Ut(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Ht(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
|
|
2
|
+
`).toLowerCase().includes(r)}function Wt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Gt(e){let t=(0,X.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,c]=(0,Y.useState)(``),l;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>Ut(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===o?d=t[8]:(d=o.trim(),t[7]=o,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(_e,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=s(`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=>c(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let _;t[12]!==o||t[13]!==i?(_=(0,Z.jsxs)(`div`,{className:`relative`,children:[p,(0,Z.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:m,onChange:h})]}),t[12]=o,t[13]=i,t[14]=_):_=t[14];let v;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(v=f?(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=v):v=t[18];let y;t[19]!==_||t[20]!==v?(y=(0,Z.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[_,v]}),t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;t[22]!==u||t[23]!==a||t[24]!==r?(b=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||Wt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,Z.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,Z.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=a,t[24]=r,t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[y,b]}),t[26]=y,t[27]=b,t[28]=x):x=t[28],x}function Kt(e){let t=(0,X.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:o,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:p}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(x,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,de)}),t[0]=h):h=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=s(`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`,H,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(O,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=_):_=t[2];let y;t[3]===a?y=t[4]:(y=(0,Z.jsxs)(F,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[_,a]}),t[3]=a,t[4]=y);let b;t[5]!==i||t[6]!==o||t[7]!==f.length?(b=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(f.length)),t[5]=i,t[6]=o,t[7]=f.length,t[8]=b):b=t[8];let S;t[9]===b?S=t[10]:(S=(0,Z.jsx)(P,{className:`mt-1 text-sm text-fg-muted`,children:b}),t[9]=b,t[10]=S);let C;t[11]!==y||t[12]!==S?(C=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[y,S]}),t[11]=y,t[12]=S,t[13]=C):C=t[13];let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t[14]=w):w=t[14];let T;t[15]===d?T=t[16]:(T=(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsx)(q,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:w})}),t[15]=d,t[16]=T);let E;t[17]!==C||t[18]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[C,T]}),t[17]=C,t[18]=T,t[19]=E):E=t[19];let D;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==i||t[25]!==p||t[26]!==f?(D=f.length>0?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(Gt,{tools:f,stripPrefix:p,searchPlaceholder:c,searchEmptyLabel:l},`${i}-${n?`open`:`closed`}`)}):(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=i,t[25]=p,t[26]=f,t[27]=D):D=t[27];let k;t[28]===d?k=t[29]:(k=(0,Z.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsx)(q,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=k);let A;t[30]!==E||t[31]!==D||t[32]!==k?(A=(0,Z.jsxs)(N,{children:[h,(0,Z.jsxs)(m,{className:g,children:[E,D,k]})]}),t[30]=E,t[31]=D,t[32]=k,t[33]=A):A=t[33];let M;return t[34]!==r||t[35]!==n||t[36]!==A?(M=(0,Z.jsx)(j,{open:n,onOpenChange:r,children:A}),t[34]=r,t[35]=n,t[36]=A,t[37]=M):M=t[37],M}var qt=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g);function Jt(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function Yt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function Xt(e,t){return e.errorCode===`missing_credential`?t.composioHealthMissingCredential:e.errorCode===`unauthorized`?t.composioHealthUnauthorized:e.errorCode===`forbidden`?t.composioHealthForbidden:e.errorCode===`network`?t.composioHealthNetwork:e.errorCode===`timeout`?t.composioHealthTimeout:t.composioHealthDegraded}function Zt({instance:e,t,onChanged:n}){let r=Jt(e),[i,o]=(0,Y.useState)([]),[c,l]=(0,Y.useState)([]),[u,d]=(0,Y.useState)([]),[f,p]=(0,Y.useState)([]),[m,g]=(0,Y.useState)(null),[_,y]=(0,Y.useState)([]),[x,S]=(0,Y.useState)(``),[C,T]=(0,Y.useState)(`{}`),[E,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(!0),[M,N]=(0,Y.useState)(`15`),[P,F]=(0,Y.useState)(null),[I,L]=(0,Y.useState)(`read`),[z,B]=(0,Y.useState)(!1),[V,H]=(0,Y.useState)(null),U=(0,Y.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){B(!0),H(null);try{let[t,n,i,a,s,c,u,f]=await Promise.all([We().catch(()=>[]),$e(r).catch(()=>[]),et(20).catch(()=>[]),Ye(r).catch(()=>`read`),ot().catch(()=>[]),Ze(r).catch(()=>null),Ke(r).catch(()=>null),nt(e.connectorId).catch(()=>null)]);o(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),l(n),d(i.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())),L(a),p(s.filter(t=>t.connectorId===e.connectorId)),g(c?.policy??null),y(c?.agents??[]),S(f?.actionId??n.find(e=>e.scope===`read`&&e.curated)?.slug??``),T(f?JSON.stringify(f.arguments):`{}`),k(f?.enabled??!1),j(f?.triggerSync??!0),N(String(f?.intervalMinutes??15)),F(u)}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(!1)}}},[e.connectorId,e.materialized,r]);(0,Y.useEffect)(()=>{U()},[U]);let te=(0,Y.useCallback)(async()=>{if(r){B(!0),H(null);try{let t=await Ie(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);window.open(t.authorizationUrl,`_blank`,`noopener,noreferrer`)}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(!1)}}},[e.connectorId,r]),ne=(0,Y.useCallback)(async e=>{if(r){L(e);try{await Xe(r,e),await U()}catch(e){H(e instanceof Error?e.message:String(e))}}},[U,r]),re=(0,Y.useCallback)(async(e,t)=>{B(!0),H(null);try{await st(e,t),await U()}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(!1)}},[U]),ie=(0,Y.useCallback)(async e=>{if(r){H(null);try{g(await Qe(r,e))}catch(e){H(e instanceof Error?e.message:String(e))}}},[e.connectorId,r]),ae=(0,Y.useCallback)(e=>{m&&ie({allowedAgentIds:m.allowedAgentIds.includes(e)?m.allowedAgentIds.filter(t=>t!==e):[...m.allowedAgentIds,e]})},[ie,m]),oe=(0,Y.useCallback)(async e=>{B(!0),H(null);try{await e(),await U()}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(!1)}},[U]),se=(0,Y.useCallback)(async()=>{if(!(!r||!x)){B(!0),H(null),D(null);try{let r=JSON.parse(C);if(!r||typeof r!=`object`||Array.isArray(r))throw Error(t.composioMemoryArgumentsObject);let a=m?.allowedAgentIds[0]??_[0]?.id;if(!a)throw Error(t.composioMemoryAgentMissing);D((await tt({connectorId:e.connectorId,actionId:x,agentId:a,connectionId:i.find(e=>e.isDefault)?.id,arguments:r})).recordId),await n?.()}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(!1)}}},[_,i,e.connectorId,x,C,n,m,t,r]),ce=(0,Y.useCallback)(async()=>{if(!(!r||!x)){B(!0),H(null);try{let r=JSON.parse(C);if(!r||typeof r!=`object`||Array.isArray(r))throw Error(t.composioMemoryArgumentsObject);let a=m?.allowedAgentIds[0]??_[0]?.id;if(!a)throw Error(t.composioMemoryAgentMissing);let o=await rt(e.connectorId,{enabled:O,actionId:x,arguments:r,agentId:a,connectionId:i.find(e=>e.isDefault)?.id,intervalMinutes:Number(M),triggerSync:A});N(String(o.intervalMinutes)),await n?.()}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(!1)}}},[_,i,e.connectorId,x,C,O,M,A,n,m,t,r]);return r?e.materialized.type===`composio`&&e.materialized.role===`credential`?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,Z.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:$(t.composioToolkitTitle,{toolkit:r})}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(q,{variant:`secondary`,disabled:z,onClick:()=>void te(),children:[z?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(ue,{className:`size-4`}),t.connectOAuth]}),(0,Z.jsx)(q,{variant:`ghost`,disabled:z,onClick:()=>void U(),children:t.refresh})]})]}),V?(0,Z.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:V}):null,P?(0,Z.jsxs)(`div`,{className:s(`mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border px-3 py-2 text-xs`,P.status===`connected`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700`:`border-amber-500/30 bg-amber-500/5 text-amber-700`),children:[(0,Z.jsx)(`span`,{children:P.status===`connected`?$(t.composioHealthConnected,{count:String(P.activeConnections)}):P.status===`reauthorization_required`?t.composioHealthReconnect:P.status===`degraded`?Xt(P,t):t.composioHealthDisconnected}),P.recovery===`none`?null:(0,Z.jsx)(q,{variant:`ghost`,disabled:z,onClick:()=>void(P.recovery===`retry`?U():te()),children:P.recovery===`retry`?t.composioRetry:t.connectOAuth}),P.status===`degraded`&&P.message?(0,Z.jsx)(`p`,{className:`basis-full break-words text-[11px] opacity-80`,children:P.message}):null]}):null,m?(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg border border-edge bg-surface-panel p-3 md:grid-cols-3`,children:[(0,Z.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioAccessTitle,(0,Z.jsxs)(ge,{className:s(qt,`mt-1 h-9 py-1`),value:I,onChange:e=>void ne(e.currentTarget.value),children:[(0,Z.jsx)(W,{value:`read`,children:t.composioAccessReadOnly}),(0,Z.jsx)(W,{value:`write`,children:t.composioAccessReadWrite}),I===`admin`?(0,Z.jsx)(W,{value:`admin`,children:t.composioAccessAdminCurrent}):null]}),(0,Z.jsx)(`span`,{className:`mt-1 block font-normal leading-4 text-fg-muted`,children:I===`read`?t.composioAccessReadHint:I===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,Z.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,Z.jsxs)(ge,{className:s(qt,`mt-1 h-9 py-1`),value:m.confirmationPolicy,onChange:e=>void ie({confirmationPolicy:e.currentTarget.value}),children:[(0,Z.jsx)(W,{value:`writes`,children:t.composioConfirmWrites}),(0,Z.jsx)(W,{value:`always`,children:t.composioConfirmAlways}),m.confirmationPolicy===`never`?(0,Z.jsx)(W,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.composioAllowedAgents}),(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:m.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_.map(e=>(0,Z.jsx)(`button`,{type:`button`,className:s(`rounded-full border px-2.5 py-1 text-xs transition-colors`,m.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge text-fg-muted hover:text-fg`),onClick:()=>ae(e.id),children:e.name},e.id))})]})]}):null,[`gmail`,`googlecalendar`,`googledrive`,`googledocs`,`googlesheets`,`notion`,`slack`,`github`,`linear`,`jira`,`outlook`,`microsoft_teams`,`one_drive`,`excel`].includes(r)&&c.some(e=>e.scope===`read`&&e.curated)?(0,Z.jsxs)(`div`,{className:`mt-4 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(b,{className:`mt-0.5 size-4 text-accent`}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioMemorySync}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioMemorySyncHint})]})]}),(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:(0,Z.jsxs)(q,{disabled:z||!x,onClick:()=>void se(),children:[z?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(b,{className:`size-4`}),t.composioSyncNow]})}),E?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-emerald-600`,children:t.composioMemorySyncedSimple}):null,(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-3 border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:O,onChange:e=>k(e.currentTarget.checked)}),t.composioMemoryAutoSync]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.currentTarget.checked)}),t.composioMemoryTriggerSync]}),(0,Z.jsxs)(q,{variant:`secondary`,disabled:z||!x,onClick:()=>void ce(),children:[z?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(b,{className:`size-4`}),t.composioMemorySaveSchedule]})]})]}):null,f.length?(0,Z.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioPendingApprovals}),f.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`truncate font-mono text-xs font-medium text-fg`,children:e.actionId}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-subtle`,children:JSON.stringify(e.argumentsPreview)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:$(t.composioApprovalExpires,{time:new Date(e.expiresAt).toLocaleTimeString()})})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Z.jsxs)(q,{variant:`secondary`,disabled:z,onClick:()=>void re(e.id,`denied`),children:[(0,Z.jsx)(v,{className:`size-4`}),t.composioDeny]}),(0,Z.jsxs)(q,{disabled:z,onClick:()=>void re(e.id,`approved`),children:[(0,Z.jsx)(a,{className:`size-4`}),t.approve]})]})]},e.id))]}):null,(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),i.length?i.map(e=>(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.providerConnectionId}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.status,e.isDefault?` · ${t.composioDefaultAccount}`:``]})]}),(0,Z.jsx)(`input`,{className:s(qt,`h-8 py-1 text-xs`),defaultValue:e.alias??``,placeholder:t.composioAccountAlias,onBlur:t=>{t.currentTarget.value!==(e.alias??``)&&oe(()=>Ge(e.id,{alias:t.currentTarget.value}))}}),(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Z.jsx)(q,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:z||e.isDefault,onClick:()=>void oe(async()=>{await Ge(e.id,{isDefault:!0}),r&&await Qe(r,{selectedConnectionIds:[e.id]})}),children:(0,Z.jsx)(R,{className:s(`size-4`,e.isDefault&&`fill-current`)})}),(0,Z.jsx)(q,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:z,onClick:()=>void oe(()=>qe(e.id)),children:(0,Z.jsx)(ee,{className:`size-4`})}),(0,Z.jsx)(q,{variant:`ghost`,className:`size-8 p-0`,title:t.composioRevoke,disabled:z,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&oe(()=>Je(e.id))},children:(0,Z.jsx)(h,{className:`size-4 text-red-500`})})]})]},e.id)):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]})}),(0,Z.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:t.composioAdvancedSettings}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioAdvancedScope,(0,Z.jsxs)(ge,{className:s(qt,`mt-1 h-9 py-1`),value:I,onChange:e=>void ne(e.currentTarget.value),children:[(0,Z.jsx)(W,{value:`read`,children:t.composioScopeRead}),(0,Z.jsx)(W,{value:`write`,children:t.composioScopeWrite}),(0,Z.jsx)(W,{value:`admin`,children:t.composioScopeAdmin})]})]}),(0,Z.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioMemoryReadAction,(0,Z.jsx)(ge,{className:s(qt,`mt-1 h-9 py-1`),value:x,onChange:e=>S(e.currentTarget.value),children:c.filter(e=>e.scope===`read`&&e.curated).map(e=>(0,Z.jsx)(W,{value:e.slug,children:e.name??e.slug},e.slug))})]}),(0,Z.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioMemoryArguments,(0,Z.jsx)(`input`,{className:s(qt,`mt-1 h-9 py-1 font-mono text-xs`),value:C,onChange:e=>T(e.currentTarget.value)})]}),(0,Z.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioMemoryInterval,(0,Z.jsx)(`input`,{type:`number`,min:5,max:1440,className:s(qt,`mt-1 h-9 w-28 py-1`),value:M,onChange:e=>N(e.currentTarget.value)})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),c.length?c.slice(0,8).map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Z.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[Yt(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),u.length?u.slice(0,5).map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]})]})]}):null}var Qt=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g);function $t(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function en(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function tn(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 nn(e){let t=(0,X.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,Z.jsx)(C,{delayDuration:300,skipDelayDuration:100,children:(0,Z.jsxs)(T,{children:[(0,Z.jsx)(A,{asChild:!0,children:(0,Z.jsx)(`p`,{tabIndex:0,title:r,className:s(`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,Z.jsx)(y,{children:(0,Z.jsx)(k,{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,Z.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let o=a,c;t[2]===n?c=t[3]:(c=(0,Z.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]=c);let l;t[4]===i?l=t[5]:(l=i?(0,Z.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]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==o||t[10]!==u?(d=(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,o]}),t[9]=o,t[10]=u,t[11]=d):d=t[11],d}function rn({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[o,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,g]=(0,Y.useState)(!1),[y,S]=(0,Y.useState)(null),[C,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(e.materialized.type===`mcp`?`health`:`permissions`),[k,A]=(0,Y.useState)(!1),[M,I]=(0,Y.useState)(()=>en(t,e)),[L,R]=(0,Y.useState)(null),z=t?.setup.config??[],B=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&z.length>0&&(t?.setup.secrets??[]).length===0,ee=C?C.toolCount:e.usage.lastToolCount,V=(0,Y.useMemo)(()=>{let t=e.materialized.type===`mcp`?[[`health`,ce,i.detailHealth],[`tools`,O,`${i.detailTools} ${C?C.toolCount:e.usage.lastToolCount??``}`],[`resources`,b,`${i.detailResources} ${C?C.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,le,`${i.detailPrompts} ${C?C.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,ue,i.detailPermissions]]:[[`permissions`,ue,i.detailPermissions]];return B?[...t,[`config`,b,i.connectorConfigLabel]]:t},[C,e.materialized.type,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,B,i]),H=(0,Y.useCallback)(async()=>{c(!0),R(null);try{let t=await Ue(e.instanceId);T(t),t.toolCount>0&&D(`tools`),r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),U=(0,Y.useCallback)(async()=>{u(!0),R(null);try{await He(e.instanceId),await r(),n()}catch(e){R(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),te=(0,Y.useCallback)(async()=>{if(!(!t||!B)){f(!0),R(null);try{let n={};for(let e of t.setup.config??[]){let t=tn(e.type,M[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ve(e.instanceId,{config:n}),await r(),D(`health`)}catch(e){R(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[M,t,e.instanceId,r,B]),ne=(0,Y.useCallback)(async()=>{g(!0),S(null),R(null);try{S((await it(e.connectorId)).recordIds.length),await r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{g(!1)}},[e.connectorId,r]);return(0,Z.jsxs)(j,{open:!0,onOpenChange:e=>{e||n()},children:[(0,Z.jsxs)(N,{children:[(0,Z.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Z.jsxs)(m,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(xe,{connector:t,size:`lg`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(F,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Z.jsx)(P,{className:`mt-1 text-sm text-fg-muted`,children:t?.description??(e.materialized.type===`mcp`?$(i.mcpServerRuntime,{serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),"aria-label":i.modalClose,children:[(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[L?(0,Z.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:L}):null,(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:V.map(([e,t,n])=>(0,Z.jsxs)(`button`,{type:`button`,className:s(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,E===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>D(e),children:[(0,Z.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,Z.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[E===`health`?(0,Z.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Z.jsxs)(`p`,{children:[i.statusLabel,` `,(0,Z.jsx)(`span`,{className:C?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:$t(C?.status??e.usage.lastHealthStatus,i)})]}),(0,Z.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),C?.action?(0,Z.jsx)(`p`,{children:C.action}):null]}):null,E===`tools`?C?.tools.length?(0,Z.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:$(i.toolsAvailable,{count:String(C.tools.length)})}),(0,Z.jsx)(q,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>A(!0),children:a.viewAllTools})]}),(0,Z.jsx)(`div`,{className:`grid gap-2`,children:C.tools.slice(0,8).map(e=>(0,Z.jsx)(nn,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:ee?$(i.toolsLastCheckSummary,{count:String(ee)}):i.toolsRunTestHint}),(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void H(),children:[o?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(_,{className:`size-4`}),i.test]})]}):null,E===`resources`?C?.resources.length?(0,Z.jsx)(`div`,{className:`grid gap-2`,children:C.resources.slice(0,8).map(e=>(0,Z.jsx)(nn,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,E===`prompts`?C?.prompts.length?(0,Z.jsx)(`div`,{className:`grid gap-2`,children:C.prompts.slice(0,8).map(e=>(0,Z.jsx)(nn,{title:e.title??e.name,description:e.description,meta:e.argumentCount?$(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,E===`permissions`?(0,Z.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Z.jsx)(`p`,{children:$(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,Z.jsx)(`p`,{children:e.materialized.type===`mcp`?$(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,Z.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,E===`config`&&B?(0,Z.jsx)(`div`,{className:`grid gap-3`,children:z.map(e=>(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,Z.jsx)(`input`,{className:Qt,value:M[e.key]??``,placeholder:e.placeholder,onChange:t=>I(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,Z.jsx)(Zt,{instance:e,t:i,onChanged:r}):null,e.materialized.type===`memorySource`?(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:i.memorySourceSync}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?.description}),y===null?null:(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:$(i.memorySourceSynced,{count:String(y)})})]}),(0,Z.jsxs)(q,{disabled:p,onClick:()=>void ne(),children:[p?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(b,{className:`size-4`}),i.composioSyncNow]})]}):null]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Z.jsx)(q,{variant:`secondary`,onClick:n,children:i.modalClose}),E===`config`&&B?(0,Z.jsxs)(q,{variant:`primary`,disabled:d,onClick:()=>void te(),children:[d?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(pe,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,Z.jsxs)(q,{variant:`secondary`,disabled:o,onClick:()=>void H(),children:[o?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(_,{className:`size-4`}),i.test]}):null,(0,Z.jsxs)(q,{variant:`ghost`,disabled:l,onClick:()=>void U(),children:[l?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(h,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,Z.jsx)(Kt,{open:k,onOpenChange:A,serverId:e.materialized.serverId,title:$(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:C?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}var an=[`understand`,`act`,`reach`];function on(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 sn(e){return on(e)[0]??`act`}function cn(e,t){let n=t?sn(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 ln({instance:e,definition:t,highlighted:n=!1,onOpenDetails:r,onChanged:i,t:a}){let[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),m=(0,Y.useCallback)(async()=>{l(!0),p(null);try{await Ue(e.instanceId),await i()}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}},[e.instanceId,i]),g=(0,Y.useCallback)(async()=>{d(!0),p(null);try{await He(e.instanceId),await i()}catch(e){p(e instanceof Error?e.message:String(e)),d(!1)}},[e.instanceId,i]),v=e.usage.lastHealthStatus?a.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:a.healthNotTested,y=e.usage.lastToolCount??0,b=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`),x=cn(e,t).state,S=x===`ready`?{label:a.connectionReady,Icon:fe,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`}:x===`needs_setup`?{label:a.connectionNeedsSetup,Icon:o,className:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`}:{label:a.connectionChecking,Icon:L,className:`border-edge bg-surface-base text-fg-muted`};return(0,Z.jsxs)(`div`,{className:s(`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,n&&`ring-2 ring-accent/45 ring-offset-2 ring-offset-surface-panel`),onClick:()=>r(e),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[(0,Z.jsx)(xe,{connector:t}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,Z.jsxs)(`span`,{className:s(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,S.className),children:[(0,Z.jsx)(S.Icon,{className:`size-3`,"aria-hidden":!0}),S.label]}),b?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:a.connectorConfigLabel}):null]}),t?.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-5 text-fg-muted`,children:t.description}):null,(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[a.statusLabel,` `,v]}),(0,Z.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:$(a.toolsAvailable,{count:String(y)})})]}),f?(0,Z.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:f}):null]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.connectorDetails}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[x===`needs_setup`?(0,Z.jsxs)(q,{variant:`primary`,onClick:()=>r(e),children:[(0,Z.jsx)(o,{className:`size-4`}),a.connectionResolveAction]}):null,e.materialized.type===`mcp`?(0,Z.jsxs)(q,{variant:`secondary`,disabled:c,onClick:()=>void m(),children:[c?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(_,{className:`size-4`}),a.test]}):null,(0,Z.jsxs)(q,{variant:`ghost`,disabled:u,onClick:()=>void g(),children:[u?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(h,{className:`size-4`}),a.remove]})]})]})]})}var un=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g),dn=s(un,`min-h-28 font-mono`);function fn(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function pn(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 mn(e){let t=(0,X.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(hn),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,Z.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function hn(e){return(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Z.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function gn({draft:e,onChange:t,onClose:n,onInstalled:r,t:i}){let{connector:a}=e,o=a.runtime.type===`composio`&&a.runtime.role===`toolkit`,c=a.runtime.type===`composio`&&a.runtime.role===`toolkit`?a.runtime.toolkit:null,[l,u]=(0,Y.useState)(!o),[d,f]=(0,Y.useState)(o),[p,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!o)return;let e=!1;return Le().then(({configured:t})=>{e||u(t)}).catch(t=>{e||_(t instanceof Error?t.message:String(t))}).finally(()=>{e||f(!1)}),()=>{e=!0}},[a.id,o]);let y=e.result?`complete`:e.installing?`health`:`configure`,b=[{id:`configure`,label:i.connectStepConfigure},{id:`health`,label:i.connectStepVerify},{id:`complete`,label:i.connectStepReady}],C=(0,Y.useCallback)(async()=>{let n=o?window.open(``,`_blank`):null;n&&(n.opener=null),_(null),t({...e,installing:!0,error:null,result:null,health:null});try{o&&!l&&(await Re(p),u(!0));let i={};for(let t of a.setup.config??[]){let n=pn(t.type,e.config[t.key]??``);n!==void 0&&(i[t.key]=n)}let s=e.store?await Pe(e.store.packageName,{secrets:e.secrets,config:i},e.store.version):await ze(a.id,{secrets:e.secrets,config:i,definition:a.source===`registry`?a:void 0}),d=null;try{if(o)if((c?await Ke(c).catch(()=>null):null)?.status===`connected`)n?.close();else{let e=await Ie(a.id);if(!e.authorizationUrl)throw Error(`The connection service did not return an authorization URL.`);n?n.location.href=e.authorizationUrl:window.open(e.authorizationUrl,`_blank`,`noopener,noreferrer`)}}catch(i){n?.close(),t({...e,installing:!1,result:s,health:null,error:i instanceof Error?i.message:String(i)}),await r(s);return}if(!o)try{d=await Ue(s.instanceId)}catch{d=null}t({...e,installing:!1,result:s,health:d}),await r(s)}catch(r){n?.close(),t({...e,installing:!1,error:r instanceof Error?r.message:String(r)})}},[p,l,c,a,e,o,t,r]);return(0,Z.jsx)(j,{open:!0,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(N,{children:[(0,Z.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Z.jsxs)(m,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex max-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-panel shadow-float dark:border-edge`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(xe,{connector:a,size:`lg`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(F,{className:`text-base font-semibold text-fg`,children:$(i.connectDialogTitle,{name:a.displayName})}),(0,Z.jsx)(P,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:a.description})]})]}),(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),"aria-label":i.modalClose,children:[(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,Z.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":i.connectProgressAria,children:b.map((e,t)=>{let n=b.findIndex(e=>e.id===y);return(0,Z.jsxs)(`div`,{className:s(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Z.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o&&!l?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/50 p-4`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.composioSetupTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.composioSetupHint}),(0,Z.jsxs)(`ol`,{className:`mt-3 list-inside list-decimal space-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`li`,{children:i.composioSetupStepProject}),(0,Z.jsx)(`li`,{children:i.composioSetupStepKey}),(0,Z.jsx)(`li`,{children:i.composioSetupStepPaste})]}),(0,Z.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:[i.composioSetupOpenDashboard,(0,Z.jsx)(E,{className:`size-3.5`,"aria-hidden":!0})]}),(0,Z.jsx)(se,{className:`mt-3`,value:p,onChange:h,labels:i.secretInputLabels,placeholder:i.composioSetupKeyPlaceholder}),(0,Z.jsx)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:i.composioSetupStorageHint})]}):null,e.store?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.detailPermissions}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,Z.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,Z.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,Z.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:i.storeLocalExecDenied})]})]}):null,(a.setup.secrets??[]).map(n=>(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,Z.jsx)(se,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:i.secretInputLabels,placeholder:n.required?i.requiredPlaceholder:i.optionalPlaceholder})]},n.key)),(a.setup.config??[]).map(n=>(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,Z.jsx)(`textarea`,{className:dn,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,Z.jsx)(`input`,{className:un,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,Z.jsx)(w,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),i.connectingTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i.connectingHint})]}):null,e.error?(0,Z.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,g?(0,Z.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:g}):null,e.result?(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedBadge})}),(0,Z.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?i.healthStatusHealthy:fn(e.health?.status,i)})]}),e.health?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,Z.jsx)(`div`,{children:i.toolsMetric})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,Z.jsx)(`div`,{children:i.resourcesMetric})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,Z.jsx)(`div`,{children:i.promptsMetric})]})]}),(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,Z.jsx)(mn,{title:i.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Z.jsx)(mn,{title:i.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Z.jsx)(mn,{title:i.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??$(i.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,Z.jsx)(`p`,{className:`mt-3`,children:i.installedWithoutHealth}),e.health?.action?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,Z.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,Z.jsxs)(q,{variant:`primary`,disabled:!!e.result||e.installing||d||o&&!l&&!p.trim(),onClick:()=>void C(),children:[e.installing?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):e.result?(0,Z.jsx)(fe,{className:`size-4`}):(0,Z.jsx)(S,{className:`size-4`}),e.result?i.connectedBadge:i.connect]})})]})]})})}function _n(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,...t?{store:t}:{}}}function vn(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 At(r)}function yn(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 bn(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g)}function xn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:l,headers:u,onChange:d}){let f=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},p=()=>{d([...u,{key:``,value:``}])},m=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[{key:``,value:``}])},g=async()=>{try{let e=await c();if(!e){window.alert(a);return}let t=xt(e);if(!t?.length){window.alert(a);return}d(t)}catch{window.alert(a)}};return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:e}),t?(0,Z.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void g(),children:[(0,Z.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{className:s(bn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>f(t,{key:e.target.value})}),(0,Z.jsx)(`input`,{className:s(bn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:l,onChange:e=>f(t,{value:e.target.value})}),(0,Z.jsx)(q,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>m(t),"aria-label":r,children:(0,Z.jsx)(h,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},yn(e,t,u)))}),(0,Z.jsxs)(`button`,{type:`button`,className:s(`self-start text-sm text-accent hover:underline`,G.press),onClick:p,children:[`+ `,n]})]})}var Sn=[`stdio`,`sse`,`streamable-http`];function Cn(e){let t=(0,X.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,Z.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,Z.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,Z.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,Z.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 wn(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g)}function Tn(e){let t=(0,X.c)(29),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:o}=e,c=o===void 0?`all`:o,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,d;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Cn,{label:r.transportLabel,required:!0,children:(0,Z.jsx)(ge,{className:wn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:Sn.map(e=>(0,Z.jsx)(W,{value:e,children:r.transportLabels[e]},e))})}),(0,Z.jsxs)(Cn,{label:r.serverIdLabel,required:!0,children:[(0,Z.jsx)(`input`,{className:wn(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,Z.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]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==i||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(f=n.transport===`stdio`?(0,Z.jsxs)(Z.Fragment,{children:[l?(0,Z.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,Z.jsx)(Cn,{label:r.commandLabel,required:!0,children:(0,Z.jsx)(`input`,{className:wn(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,u?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Cn,{label:r.argsLabel,description:r.argsHint,children:(0,Z.jsx)(`input`,{className:wn(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,Z.jsx)(Cn,{label:r.cwdLabel,children:(0,Z.jsx)(`input`,{className:wn(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,Z.jsx)(Cn,{label:r.envLabel,description:r.envHint,children:(0,Z.jsx)(`textarea`,{className:s(wn(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[l?(0,Z.jsx)(`div`,{className:`md:col-span-2`,children:(0,Z.jsx)(Cn,{label:r.urlLabel,required:!0,children:(0,Z.jsx)(`input`,{className:s(wn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u?(0,Z.jsx)(xn,{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:e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=f):f=t[19];let p;t[20]!==i||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,Z.jsx)(Cn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,Z.jsx)(`input`,{type:`number`,min:1,max:600,className:wn(),value:Rt(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:zt(e.target.value)})})}):null,t[20]=i,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;return t[25]!==d||t[26]!==f||t[27]!==p?(m=(0,Z.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m):m=t[28],m}function En(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 Dn(e){let t=(0,X.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=En(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o=n.name===a?a:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==a||t[6]!==o?(u=(0,Z.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]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,Z.jsx)(C,{delayDuration:300,skipDelayDuration:100,children:(0,Z.jsxs)(T,{children:[(0,Z.jsx)(A,{asChild:!0,children:(0,Z.jsx)(`p`,{tabIndex:0,title:l,className:s(`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:l})}),(0,Z.jsx)(y,{children:(0,Z.jsx)(k,{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,Z.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let f;return t[10]!==u||t[11]!==d?(f=(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function On({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:o,t:c,cs:l,onClose:u,onSaved:d}){let[f,p]=(0,Y.useState)(n),[h,g]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(null),[T,E]=(0,Y.useState)(!1),[D,k]=(0,Y.useState)({status:`idle`}),[A,M]=(0,Y.useState)(null),I=n.id.trim(),L=f.id.trim()!==I&&o.has(f.id.trim())||o.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,R=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,z=f.id.trim().length>0&&!L&&!R&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),B=Bt(f),ee=(0,Y.useCallback)(async()=>{if(f.id.trim()){b(!0),C(null),k({status:`loading`});try{k({status:`ok`,tools:(await Lt(f.id.trim(),Mt(f))).tools})}catch(e){k({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{b(!1)}}},[f]),V=(0,Y.useCallback)(async()=>{if(!(!z||h)){g(!0),C(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await Nt({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Tt(a)),await d(),u()}catch(e){C(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[z,a,r,n.clientKey,t,u,d,I,f,h,i]);return e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(j,{open:e,onOpenChange:e=>{e||u()},children:(0,Z.jsxs)(N,{children:[(0,Z.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Z.jsxs)(m,{className:s(`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-panel shadow-float dark:border-edge`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(F,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,Z.jsx)(P,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),"aria-label":l.modalClose,children:[(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(ne,{className:`size-4 text-accent`,"aria-hidden":!0}),f.id.trim()||c.cardUntitled]}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:B||(f.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[f.transport]})]})}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`mb-3`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,Z.jsx)(Tn,{row:f,t:c,variant:`basic`,onUpdate:e=>{p(t=>({...t,...e})),C(null)},idConflictMessage:L??R})]}),D.status===`ok`?(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(O,{className:`size-4 text-accent`,"aria-hidden":!0}),D.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(D.tools.length))]}),D.tools.length>0?(0,Z.jsx)(q,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>M(D.tools),children:c.viewAllTools}):null]}),D.tools.length>0?(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:D.tools.slice(0,6).map((e,t)=>(0,Z.jsx)(Dn,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,D.status===`error`?(0,Z.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D.message}):null,S?(0,Z.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S}):null,(0,Z.jsxs)(`details`,{open:T,onToggle:e=>E(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,Z.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,Z.jsx)(ve,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,Z.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,Z.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,Z.jsx)(Tn,{row:f,t:c,variant:`advanced`,onUpdate:e=>{p(t=>({...t,...e})),C(null)}})})]})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Z.jsxs)(q,{variant:`secondary`,disabled:!f.id.trim()||y,onClick:()=>void ee(),children:[y?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(_,{className:`size-4`}),c.testConnection]}),(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsx)(q,{variant:`secondary`,children:l.modalCancel})}),(0,Z.jsxs)(q,{variant:`primary`,disabled:!z||h,onClick:()=>void V(),children:[h?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(fe,{className:`size-4`}),h?c.saving:l.modalSave]})]})]})]})}),A?(0,Z.jsx)(Kt,{open:!0,onOpenChange:e=>{e||M(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:A,stripPrefix:`${f.id.trim()}__`}):null]}):null}function kn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function An(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=>An(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Mn(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 Nn(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}var Pn=`all`,Fn=`builtin`,In=`composio`,Ln=`xopc-store`;function Rn(e){let t=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(e.category??``)?e.category:`custom`;return{id:e.name,version:e.latestVersion??`store`,displayName:e.name,description:e.description,category:t,kind:`mcp`,source:`store`,capabilities:[`tools`,`runtime.mcp.streamableHttp`],tags:[`store`],auth:{mode:`none`},setup:{},runtime:{type:`mcp`,serverId:`store-${e.name}`.slice(0,64)}}}function zn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Bn(){let e=l(d(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=u(e=>e.token),a=!!r,[o,c]=i(),[f,p]=(0,Y.useState)(o.get(`tab`)===`connected`?`connected`:`discover`),m=(0,Y.useRef)(!1),[h,g]=(0,Y.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null,peopleGraph:null}),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(1),[C,T]=(0,Y.useState)(void 0),[E,O]=(0,Y.useState)(``),[k,A]=(0,Y.useState)(``),[j,M]=(0,Y.useState)(!1),[N,P]=(0,Y.useState)(``),[F,I]=(0,Y.useState)(Fn),[L,R]=(0,Y.useState)(`name`),[B,ee]=(0,Y.useState)(`all`),[V,H]=(0,Y.useState)(null),[U,ne]=(0,Y.useState)(null),[ae,oe]=(0,Y.useState)(null),[se,ce]=(0,Y.useState)(null),[le,ue]=(0,Y.useState)(null),[de,fe]=(0,Y.useState)(null),[pe,me]=(0,Y.useState)(!1),[W,he]=(0,Y.useState)(void 0),[ge,_e]=(0,Y.useState)(!1),{data:ve,mutate:ye}=z(a),G=ve?.payload?.config,K=(0,Y.useMemo)(()=>G===void 0?null:jt(G),[G]),J=K?.servers??[],xe=h.instances.length+J.length;(0,Y.useEffect)(()=>{K&&he(K.sessionIdleTtlMinutes)},[K]);let X=(0,Y.useCallback)(async()=>{if(!r){g({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null,peopleGraph:null});return}g(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Ae(),Fe(),at(``,12).catch(()=>null)]);g(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,loading:!1,error:null,peopleGraph:n}))}catch(e){g({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e),peopleGraph:null})}},[r]);(0,Y.useEffect)(()=>{X()},[X]),(0,Y.useEffect)(()=>{if(!a||f!==`connected`)return;let e=!1,t=window.setTimeout(()=>{M(!0),at(k,50).then(t=>{e||g(e=>({...e,peopleGraph:t}))}).catch(()=>{}).finally(()=>{e||M(!1)})},250);return()=>{e=!0,window.clearTimeout(t)}},[a,k,f]),(0,Y.useEffect)(()=>{m.current||h.loading||a&&!K||(p(xe>0?`connected`:`discover`),m.current=!0)},[a,xe,K,h.loading]);let Ce=(0,Y.useCallback)(e=>{m.current=!0,p(e)},[]),Ee=(0,Y.useMemo)(()=>[{id:In,displayName:t.composioSourceName},{id:Ln,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),Oe=(0,Y.useCallback)(async e=>{if(!a||F===Fn){g(e=>({...e,registryCatalog:[]})),S(1),T(void 0);return}let t=N.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=F===Pn?Ee:Ee.filter(e=>e.id===F);if(i.length!==0){v(!0),r?g(e=>({...e,error:null})):(S(1),T(void 0),g(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===In){let e=await je({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await Me({q:t||void 0,page:n,pageSize:24,sort:L===`source`?`newest`:`downloads`});return{connectors:r.items.map(Rn),totalPages:r.meta.totalPages}})),a=zn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));S(n),T(o),g(e=>({...e,registryCatalog:r?zn([...e.registryCatalog,...a]):a}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{v(!1)}}},[L,N,F,a,Ee]);(0,Y.useEffect)(()=>{if(f!==`discover`||h.loading)return;if(F===Fn){g(e=>({...e,registryCatalog:[]})),S(1),T(void 0);return}let e=window.setTimeout(()=>{Oe()},N.trim()?350:0);return()=>window.clearTimeout(e)},[N,F,Oe,h.loading,f]);let Q=(0,Y.useMemo)(()=>new Set(h.instances.map(e=>e.connectorId)),[h.instances]),Pe=(0,Y.useMemo)(()=>new Map([...h.catalog,...h.registryCatalog].map(e=>[e.id,e])),[h.catalog,h.registryCatalog]);(0,Y.useEffect)(()=>{if(h.loading)return;let e=o.get(`connector`),t=o.get(`instance`);if(!e&&!t)return;let n=h.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)m.current=!0,O(``),oe(n.instanceId),ce(n),p(`connected`);else if(e){let t=Pe.get(e);if(!t)return;m.current=!0,I(Fn),P(``),ne(t),p(`discover`)}let r=new URLSearchParams(o);r.delete(`connector`),r.delete(`instance`),r.delete(`personalContext`),r.set(`tab`,n?`connected`:`discover`),c(r,{replace:!0})},[Pe,o,c,h.instances,h.loading]);let Ie=(0,Y.useCallback)(async e=>{b(!0),g(e=>({...e,error:null}));try{let t=await Ne(e);H(_n(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{b(!1)}},[]),Le=(0,Y.useMemo)(()=>new Set(h.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[h.instances]),Re=(0,Y.useCallback)(async e=>{if(!K||G===void 0)return;let t=J.filter(t=>t.clientKey!==e.clientKey);await Nt({sessionIdleTtlMinutes:K.sessionIdleTtlMinutes,servers:t},Tt(G)),await ye(),await X()},[G,J,X,K,ye]),ze=(0,Y.useCallback)(()=>{fe({mode:`add`,row:vn(J,Le)})},[J,Le]),Be=(0,Y.useCallback)(async()=>{if(!(!K||G===void 0||ge)){_e(!0);try{await Nt({sessionIdleTtlMinutes:W,servers:J},Tt(G)),await ye(),me(!1)}finally{_e(!1)}}},[G,J,n.saved,K,ye,W,ge]),Ve=te(e=>e.setPageHeader),He=te(e=>e.clearPageHeader),Ue=(0,Y.useMemo)(()=>(0,Z.jsx)(yt,{onBrowseCatalog:()=>Ce(`discover`),onAddCustomServer:ze,onOpenRuntimeSettings:()=>me(!0),addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced,settingsLabel:t.runtimeSettings}),[t,ze,Ce]);(0,Y.useLayoutEffect)(()=>(Ve({startExtra:null,main:(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ue}),()=>He()),[He,t.title,Ue,Ve]);let We=(0,Y.useMemo)(()=>h.instances.map(e=>({instance:e,value:cn(e,Pe.get(e.connectorId))})),[Pe,h.instances]),Ge=(0,Y.useMemo)(()=>new Map(We.map(({instance:e,value:t})=>[e.instanceId,t])),[We]),Ke=(0,Y.useMemo)(()=>h.instances.filter(e=>Mn(e,E)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ge.get(e.instanceId)?.state??`checking`,i=Ge.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[E,Ge,h.instances]),qe=(0,Y.useMemo)(()=>J.filter(e=>Nn(e,E)),[E,J]),Je=Ke.length+qe.length,Ye=(0,Y.useMemo)(()=>h.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&kn(e)),[h.catalog]),Xe=(0,Y.useMemo)(()=>F===Fn?Ye:F===Pn?zn([...Ye,...h.registryCatalog]):h.registryCatalog,[Ye,F,h.registryCatalog]),Ze=(0,Y.useMemo)(()=>jn(B===`all`?Xe:Xe.filter(e=>on(e).includes(B)),N,L),[L,N,Xe,B]),Qe=(0,Y.useMemo)(()=>an.filter(e=>Xe.some(t=>on(t).includes(e))),[Xe]);(0,Y.useEffect)(()=>{B!==`all`&&!Qe.includes(B)&&ee(`all`)},[Qe,B]);let $e=f===`discover`&&F!==Fn&&!!(C&&x<C),et=(0,Y.useMemo)(()=>h.instances.find(e=>e.instanceId===ae)??se,[ae,se,h.instances]),tt=(0,Y.useMemo)(()=>[{value:Pn,label:t.discoverSourceAll},{value:Fn,label:t.discoverSourceBuiltin},...Ee.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Ee]),nt=[{id:`connected`,label:t.tabConnected,count:xe},{id:`discover`,label:t.tabDiscover}];return(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[a?null:(0,Z.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,Z.jsx)(be,{items:nt,activeTab:f,onChange:Ce,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),h.error?(0,Z.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h.error}):null,f===`connected`&&a?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsx)(vt,{value:E,onChange:O,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,Z.jsx)(re,{className:`size-9 shrink-0 p-0`,loading:h.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:X})]}),h.peopleGraph&&(h.peopleGraph.people.length>0||k)?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(`div`,{className:`rounded-lg bg-accent-soft p-2 text-accent-fg`,children:(0,Z.jsx)(D,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.peopleGraphTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.peopleGraphHint.replace(`{{people}}`,String(h.peopleGraph.people.length)).replace(`{{sources}}`,String(new Set(h.peopleGraph.sourceEdges.map(e=>e.sourceInstanceId)).size))})]})]}),(0,Z.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,Z.jsx)(vt,{value:k,onChange:A,placeholder:t.peopleGraphSearchPlaceholder}),j?(0,Z.jsx)(w,{className:`absolute right-3 top-2.5 size-4 animate-spin text-fg-subtle`,"aria-hidden":!0}):null]})]}),h.peopleGraph.people.length?(0,Z.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:h.peopleGraph.people.slice(0,10).map(e=>{let t=[...new Set(h.peopleGraph.sourceEdges.filter(t=>t.personId===e.id).map(e=>e.toolkit??e.connectorId??e.sourceInstanceId))];return(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.mentionCount})]}),(0,Z.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.emails[0]??e.usernames[0]??e.roles.join(` · `)}),(0,Z.jsx)(`p`,{className:`mt-1 truncate text-[11px] text-fg-subtle`,children:t.join(` · `)})]},e.id)})}):(0,Z.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.peopleGraphSearchEmpty})]}):null,h.loading?(0,Z.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:we.slice(0,3).map(e=>(0,Z.jsx)(ke,{},e))}):xe===0?(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,Z.jsx)(q,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Ce(`discover`),children:t.addFromCatalog})]}):Je===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[Ke.map(e=>(0,Z.jsx)(ln,{instance:e,definition:Pe.get(e.connectorId),highlighted:e.instanceId===le,onOpenDetails:e=>{ue(null),oe(e.instanceId),ce(e)},onChanged:X,t},e.instanceId)),qe.map(e=>(0,Z.jsx)(Vt,{row:e,t:n,cs:t,onEdit:()=>fe({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Re(e)},e.clientKey))]})]}):null,f===`discover`&&a?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.outcomeFilterAria,children:[`all`,...Qe].map(e=>(0,Z.jsx)(`button`,{type:`button`,className:s(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,B===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":B===e,onClick:()=>ee(e),children:e===`all`?t.outcomeAll:t.connectorBenefitHeadings[e]},e))}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,Z.jsx)(vt,{value:N,onChange:P,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2 lg:ml-auto lg:w-[26rem]`,children:[(0,Z.jsx)(ie,{value:F,options:tt,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:I}),(0,Z.jsx)(ie,{value:L,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=>R(e)})]})]}),(h.loading||_)&&Ze.length===0?(0,Z.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:we.map(e=>(0,Z.jsx)(De,{},e))}):Ze.length===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,Z.jsxs)(`div`,{className:`relative`,children:[_?(0,Z.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,Z.jsx)(w,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,Z.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Ze.map(e=>(0,Z.jsx)(Se,{connector:e,installed:Q.has(e.id)||Te(e,h.instances),onInstall:e=>{if(e.source===`store`){Ie(e.id);return}H(_n(e))},onOpenDetails:e.source===`store`?void 0:ne,t},e.id))}),$e?(0,Z.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,disabled:_||y,onClick:()=>void Oe({page:x+1,append:!0}),children:[_?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),V?(0,Z.jsx)(gn,{draft:V,onChange:H,onClose:()=>H(null),t,onInstalled:async e=>{await X(),await ye(),ue(e.instanceId),Ce(`connected`)}}):null,U?(0,Z.jsx)(ht,{connector:U,installed:Q.has(U.id)||Te(U,h.instances),onClose:()=>ne(null),onInstall:e=>H(_n(e)),t}):null,et?(0,Z.jsx)(rn,{instance:et,definition:Pe.get(et.connectorId),onClose:()=>{oe(null),ce(null)},onChanged:X,t,mcp:n}):null,de?(0,Z.jsx)(On,{open:!0,mode:de.mode,initialRow:de.row,existingCustomServers:J,sessionIdleTtlMinutes:W,config:G,managedServerIds:Le,t:n,cs:t,onClose:()=>fe(null),onSaved:async()=>{await ye(),await X(),Ce(`connected`)}},`${de.mode}-${de.row.clientKey}`):null,(0,Z.jsx)(_t,{open:pe,sessionIdleTtlMinutes:W,saving:ge,onChange:he,onSave:Be,onClose:()=>me(!1),t,mcp:n})]})})}export{Bn as ConnectorsPage};
|