@xopcai/xopc 0.0.131 → 0.0.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -26
- package/README.zh-CN.md +25 -28
- package/dist/browser-ext/icons/icon-128.png +0 -0
- package/dist/browser-ext/icons/icon-16.png +0 -0
- package/dist/browser-ext/icons/icon-32.png +0 -0
- package/dist/browser-ext/icons/icon-48.png +0 -0
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/messaging/process-message.js +5 -8
- package/dist/extensions/weixin/src/messaging/process-message.js.map +1 -1
- package/dist/extensions/weixin/src/plugin.js +11 -1
- package/dist/extensions/weixin/src/plugin.js.map +1 -1
- package/dist/extensions/weixin/src/routing-integration.d.ts +7 -0
- package/dist/extensions/weixin/src/routing-integration.js +17 -0
- package/dist/extensions/weixin/src/routing-integration.js.map +1 -0
- package/dist/gateway/static/root/apple-touch-icon.png +0 -0
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BJYeTxQ9.js → agent-avatar-dicebear-Ab81VpCx.js} +1 -1
- package/dist/gateway/static/root/assets/agents-HCGFJG8I.js +2 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Bj8iJ-7d.js → app-management-settings-panel-DMI_sbnc.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-6TjISbHB.js → appearance-settings-oQiCWQIQ.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DC4YwXLL.js → apps-page-CRYuPIdb.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-2G62raBg.js → archive-plugin-BaKuWJws.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-kLNJMEJh.js → attachment-load-DYCFtbAA.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-CpcZSSD8.js → automation-suggestion-card-C6ZIz_B1.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-DjbtV2VP.js +4 -0
- package/dist/gateway/static/root/assets/{binary-plugins-C_zSrWow.js → binary-plugins-Bdg1hfhV.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-D_PMrT-l.js → block-editor-CEgvbzpG.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-C89wKfPd.js → browser-settings-page-KcwlS_iE.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-api-CPFtajl7.js → capability-presets-api-CC3vmrm5.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DWw31-4v.js → capability-presets-settings-panel-Di4uiKbv.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-BUi8syv2.js → channel-recipient-api-RANYrzfa.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-DMa0BEWf.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-BG_j4Ci-.js +1 -0
- package/dist/gateway/static/root/assets/{connectors-page-DCE-PgQF.js → connectors-page-DIZKYaMj.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-BYV16wez.js → desktop-pet-CNnlqbkx.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DGIaFqPR.js → desktop-pet-settings-ukJCc0LA.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BEhDuShd.js → directory-picker-path-field-8hoieEyt.js} +1 -1
- package/dist/gateway/static/root/assets/dreaming-settings-BOrBSNLL.js +3 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-BIjLZMAQ.js → extension-debug-page-D6Jc0hYZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Cxv4Bgj5.js → extension-page-CJMhBASX.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DNd0tRFl.js → extension-settings-page-Dt-FWyMN.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-Bl7zMnmd.js → fetch-6HXXdO77.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-BiqKIkkp.js → gateway-config-api-CyYi-a3k.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-D_Cvasqi.js → gateway-settings-yJvCmOBC.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CPOgTcpv.js → gateway-startup-retry-BE1M9fH_.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-B3PLFUAl.js +1 -0
- package/dist/gateway/static/root/assets/{goal-detail-page-DF8QhTHH.js → goal-detail-page-BQXW29kk.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-config-api-h26_-2Vm.js → goals-config-api-FU_bdYvR.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-BzBKHZJg.js → goals-page-BmppU6mC.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-settings-BFG1uTI8.js → goals-settings-BsXWV6CN.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-BqwSCZLD.js +1 -0
- package/dist/gateway/static/root/assets/index-DXUkWmeK.css +1 -0
- package/dist/gateway/static/root/assets/{index-DOetFpTt.js → index-DqFBdoK-.js} +41 -41
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Dpx1ovO6.js → keyboard-shortcuts-settings-D8J0hkTt.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-3QO3elfx.js → logs-page-Cr5ptDtc.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-Ba4EsPkV.js → markdown-split-w-hIAZ9S.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-lA5rvtCq.js → media-plugins-DjFnDy3R.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-Bq4REfIj.js → messages-DR9ODkb8.js} +2 -2
- package/dist/gateway/static/root/assets/{models-hub-panel-BBG87CHZ.js → models-hub-panel-DEsMnITi.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-DrUGE-Hn.js → notes-page-D7bHXaeR.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-eAIE8iKV.js → notes-workbench-DiuG4Ov7.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-Cy7bX7Ce.js → page-tabs-smjfSAwc.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-B9_iql49.js → preview-open-alternatives-v02THugE.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-Us3zDRE6.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BcvW8R0Z.js +1 -0
- package/dist/gateway/static/root/assets/{remote-access-hub-C29EWM0P.js → remote-access-hub-Bun2k0V-.js} +1 -1
- package/dist/gateway/static/root/assets/{save-bar-controls-nMloZ0mp.js → save-bar-controls-CD7LPbLU.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-BuajpVNF.js → schedule-field-Cf3p_M0z.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-IeXV_yQk.js → schema-form-D8XdvcNH.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-DHHVDqsy.js → sessions-page-Bh44TVld.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BhyLZ0IW.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-ByixWwvu.js → settings-collapsible-section-BVpPSgMs.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-C-5-n-jM.js → settings-form-section-GAwBG9Vp.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-CTA5Gje4.js → settings-loading-skeleton-CGxa3aCb.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DzqxeemF.js → settings-page-bZKl6uRR.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-DgFTf6nM.js → settings-page-layout-DfbMLJgN.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-svpHcJ62.js → setup-status-panel-DBIruh16.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-IOjU69FC.js → share-preview-page-BglBMvA0.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-C0fR-Oto.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BG-FEo9B.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-DoonnYRs.js → skills-page-CwwZOoCH.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BMDD7FXg.js → system-settings-panel-CTT0BkbS.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-DayamJ56.js → typed-models-lib-Fa9PjI0-.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-ChYwFiqo.js → use-channel-catalog-BCBfSoHx.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-Dd0X3mPv.js → user-profile-settings-panel-pCK-aMqu.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-D9v9ZpK4.js → utils-aleluS3U.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-QXGvjTwa.js → voice-api-key-field-Fh4mqUIK.js} +1 -1
- package/dist/gateway/static/root/assets/{work-item-detail-page-CP-5OUYI.js → work-item-detail-page-C0_3nId3.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-IidqhbUI.js → workflow-run-setup-panel-r969H1r2.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-start-dialog-BQQkr8YD.js → workflow-start-dialog-C1GbcWN0.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DtVIjVSX.js → workflows-page-DsPM3HEI.js} +1 -1
- package/dist/gateway/static/root/favicon-16x16.png +0 -0
- package/dist/gateway/static/root/favicon-32x32.png +0 -0
- package/dist/gateway/static/root/favicon-icon.svg +179 -15
- package/dist/gateway/static/root/favicon.ico +0 -0
- package/dist/gateway/static/root/favicon.png +0 -0
- package/dist/gateway/static/root/favicon.svg +179 -15
- package/dist/gateway/static/root/index.html +5 -5
- package/dist/gateway/static/root/logo-dark.svg +179 -15
- package/dist/gateway/static/root/logo.svg +179 -15
- package/dist/gateway/static/root/pwa-192x192.png +0 -0
- package/dist/gateway/static/root/pwa-512x512.png +0 -0
- package/dist/package.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +5 -5
- package/dist/src/agent/image/tool-model-config.js.map +1 -1
- package/dist/src/agent/starter-agents.d.ts +1 -0
- package/dist/src/agent/starter-agents.js +38 -11
- package/dist/src/agent/starter-agents.js.map +1 -1
- package/dist/src/agent/transcript/thinking-types.js +2 -0
- package/dist/src/agent/transcript/thinking-types.js.map +1 -1
- package/dist/src/auth/oauth/google-oauth/google-gemini-cli.d.ts +1 -1
- package/dist/src/auth/oauth/google-oauth/google-gemini-cli.js.map +1 -1
- package/dist/src/chat-commands/builtins/model.js +3 -3
- package/dist/src/chat-commands/builtins/model.js.map +1 -1
- package/dist/src/cli/commands/models.js +9 -0
- package/dist/src/cli/commands/models.js.map +1 -1
- package/dist/src/commands/agents.config.d.ts +2 -0
- package/dist/src/commands/agents.config.js +1 -1
- package/dist/src/commands/agents.config.js.map +1 -1
- package/dist/src/config/schema.js +4 -2
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/gateway/hono/routes/status.js +2 -2
- package/dist/src/gateway/hono/routes/status.js.map +1 -1
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/gateway/hono/routes/voice.js.map +1 -1
- package/dist/src/providers/domestic-presets.d.ts +5 -15
- package/dist/src/providers/domestic-presets.js +31 -49
- package/dist/src/providers/domestic-presets.js.map +1 -1
- package/dist/src/providers/index.js +19 -5
- package/dist/src/providers/index.js.map +1 -1
- package/dist/src/providers/model-registry.js.map +1 -1
- package/dist/src/providers/model-supplements.d.ts +6 -0
- package/dist/src/providers/model-supplements.js +22 -0
- package/dist/src/providers/model-supplements.js.map +1 -0
- package/dist/src/providers/presentation.js +25 -26
- package/dist/src/providers/presentation.js.map +1 -1
- package/dist/src/voice/tts/summarize.js +1 -1
- package/dist/src/voice/tts/summarize.js.map +1 -1
- package/package.json +5 -5
- package/dist/gateway/static/root/assets/agents-kVsY4Iz_.js +0 -2
- package/dist/gateway/static/root/assets/automations-page-MZ8m4bYP.js +0 -4
- package/dist/gateway/static/root/assets/channels-settings-DOYzcMAE.js +0 -1
- package/dist/gateway/static/root/assets/dreaming-settings-BIkgLFDH.js +0 -3
- package/dist/gateway/static/root/assets/goal-create-dialog-DZ68qzpm.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-5vV8vTva.js +0 -1
- package/dist/gateway/static/root/assets/index-W4ogAiHt.css +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-Cwct6pCV.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BXZlzV8t.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-hDvmobsT.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-Ddg8gHPN.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DcNOEJsK.js +0 -1
|
@@ -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-BQ_8x0bT.js";import{t as a}from"./messages-Bq4REfIj.js";import{a as o}from"./fetch-Bl7zMnmd.js";import{n as s}from"./locale-store-Ba72bFmP.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Ba as l,Do as u,Ec as d,El as f,Ha as p,Nc as m,Oo as h,Ra as g,Ua as _,Va as v,Wa as y,_o as b,bs as x,ds as S,io as C,ll as w,no as T,ro as E,tc as D,tr as O,vs as k,wo as A,za as j,zo as M}from"./index-DOetFpTt.js";import{n as N,t as P}from"./settings-page-layout-DgFTf6nM.js";import{n as F,t as I}from"./settings-loading-skeleton-CTA5Gje4.js";import{n as L,t as R}from"./settings-form-section-C-5-n-jM.js";import{a as z,i as B,o as V,t as ee}from"./typed-models-lib-DayamJ56.js";import{a as H,i as te,n as ne,o as re,r as ie,s as ae,t as oe}from"./capability-presets-api-CPFtajl7.js";var se=n(),U=e(t(),1),W=r();function G(e){return e.name||e.directoryId}function ce(e){let t=(0,se.c)(56),{mode:n,selected:r,catalog:a,loading:o,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,f;t[0]===a?f=t[1]:(f=a.map(G).filter(Boolean),t[0]=a,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,W.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t[5]=g):g=t[5];let _;t[6]===u.overrideSummaryTitle?_=t[7]:(_=(0,W.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,W.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,W.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,W.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 T;t[21]===u.modeDenylist?T=t[22]:(T=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=T);let E;t[23]===u.modeOff?E=t[24]:(E=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=E);let D;t[25]!==T||t[26]!==E||t[27]!==x||t[28]!==S||t[29]!==C?(D=[x,S,C,T,E],t[25]=T,t[26]=E,t[27]=x,t[28]=S,t[29]=C,t[30]=D):D=t[30];let O=D,k;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==O?(k=(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:O.map(e=>{let[t,r]=e;return(0,W.jsx)(`button`,{type:`button`,className:i(`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]=O,t[35]=k):k=t[35];let j;t[36]!==k||t[37]!==b?(j=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[b,k]}),t[36]=k,t[37]=b,t[38]=j):j=t[38];let M;t[39]!==a||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]!==o||t[48]!==l||t[49]!==d||t[50]!==r?(M=d?(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:s||o||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:s||o||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),o?(0,W.jsx)(I,{rows:3}):a.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:a.map(e=>{let t=G(e),n=r.has(t),a=typeof e.description==`string`?e.description.trim():``,o=a||u.noDescription;return(0,W.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,W.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,W.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,W.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,W.jsx)(`p`,{className:i(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!a&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})]}):null,t[39]=a,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]=o,t[48]=l,t[49]=d,t[50]=r,t[51]=M):M=t[51];let N;return t[52]!==j||t[53]!==M||t[54]!==y?(N=(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[y,j,M]}),t[52]=j,t[53]=M,t[54]=y,t[55]=N):N=t[55],N}var K=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],q=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],J=[`send_message`,`send_media`,`text_to_speech`,`create_share`],Y=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],X=[...K,...J],le=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],ue=[`send_message`,`send_media`];function Z(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]=i);return n}function de(e){let t=(0,se.c)(92),{builtinToolIds:n,toolModes:r,onChange:a,disabled:o,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(fe),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 H){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=re(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]!==a||t[13]!==r?(g=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]=t,a(n)},t[12]=a,t[13]=r,t[14]=g):g=t[14];let _=g,v;t[15]!==d||t[16]!==a?(v=e=>{a(Z(d,e))},t[15]=d,t[16]=a,t[17]=v):v=t[17];let y=v;if(n.length===0){let e;return t[18]===l.emptyBuiltin?e=t[19]:(e=(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[18]=l.emptyBuiltin,t[19]=e),e}let b;t[20]===l.quickActionsLabel?b=t[21]:(b=(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[20]=l.quickActionsLabel,t[21]=b);let x;t[22]===a?x=t[23]:(x=()=>a({}),t[22]=a,t[23]=x);let S;t[24]!==o||t[25]!==l.quickClearOverrides||t[26]!==x?(S=(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:x,children:l.quickClearOverrides}),t[24]=o,t[25]=l.quickClearOverrides,t[26]=x,t[27]=S):S=t[27];let C;t[28]===y?C=t[29]:(C=()=>y([[K,`deny`]]),t[28]=y,t[29]=C);let w;t[30]!==o||t[31]!==l.quickReadOnlyWorkspace||t[32]!==C?(w=(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:C,children:l.quickReadOnlyWorkspace}),t[30]=o,t[31]=l.quickReadOnlyWorkspace,t[32]=C,t[33]=w):w=t[33];let T;t[34]===y?T=t[35]:(T=()=>y([[q,`deny`]]),t[34]=y,t[35]=T);let E;t[36]!==o||t[37]!==l.quickHighRiskOff||t[38]!==T?(E=(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:T,children:l.quickHighRiskOff}),t[36]=o,t[37]=l.quickHighRiskOff,t[38]=T,t[39]=E):E=t[39];let D;t[40]===y?D=t[41]:(D=()=>y([[J,`deny`]]),t[40]=y,t[41]=D);let O;t[42]!==o||t[43]!==l.quickNoOutbound||t[44]!==D?(O=(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:D,children:l.quickNoOutbound}),t[42]=o,t[43]=l.quickNoOutbound,t[44]=D,t[45]=O):O=t[45];let k;t[46]===y?k=t[47]:(k=()=>y([[Y,`allow`],[X,`deny`]]),t[46]=y,t[47]=k);let j;t[48]!==o||t[49]!==l.quickResearchMode||t[50]!==k?(j=(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:k,children:l.quickResearchMode}),t[48]=o,t[49]=l.quickResearchMode,t[50]=k,t[51]=j):j=t[51];let M;t[52]===y?M=t[53]:(M=()=>y([[le,`allow`],[ue,`deny`]]),t[52]=y,t[53]=M);let N;t[54]!==o||t[55]!==l.quickCodingMode||t[56]!==M?(N=(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:M,children:l.quickCodingMode}),t[54]=o,t[55]=l.quickCodingMode,t[56]=M,t[57]=N):N=t[57];let P;t[58]!==E||t[59]!==O||t[60]!==j||t[61]!==N||t[62]!==S||t[63]!==w?(P=(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[S,w,E,O,j,N]}),t[58]=E,t[59]=O,t[60]=j,t[61]=N,t[62]=S,t[63]=w,t[64]=P):P=t[64];let F;t[65]!==P||t[66]!==b?(F=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[b,P]}),t[65]=P,t[66]=b,t[67]=F):F=t[67];let I;t[68]===l.overrideSummaryTitle?I=t[69]:(I=(0,W.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[68]=l.overrideSummaryTitle,t[69]=I);let L;t[70]!==l.modeAllow||t[71]!==l.modeDeny||t[72]!==l.noOverrides||t[73]!==p?(L=p.length>0?(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:p.map(e=>{let[t,n]=e;return(0,W.jsxs)(`span`,{className:i(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,W.jsx)(`span`,{className:`font-sans opacity-80`,children:n===`allow`?l.modeAllow:l.modeDeny})]},t)})}):(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[70]=l.modeAllow,t[71]=l.modeDeny,t[72]=l.noOverrides,t[73]=p,t[74]=L):L=t[74];let R;t[75]!==I||t[76]!==L?(R=(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[I,L]}),t[75]=I,t[76]=L,t[77]=R):R=t[77];let z;t[78]!==o||t[79]!==c||t[80]!==s||t[81]!==h||t[82]!==l.inheritedMode||t[83]!==l.modeAllow||t[84]!==l.modeDeny||t[85]!==_||t[86]!==r?(z=(0,W.jsx)(`div`,{className:`flex flex-col gap-5`,children:h.map(e=>{let{key:t,ids:n}=e;return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=Object.prototype.hasOwnProperty.call(r,e)?r[e]:`inherit`;return(0,W.jsx)(`li`,{className:i(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,n===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:(0,W.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,W.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`deny`].map(t=>(0,W.jsx)(`button`,{type:`button`,className:i(`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`,n===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:o,onClick:()=>_(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:l.modeDeny},t))})]})},e)})})]},t)})}),t[78]=o,t[79]=c,t[80]=s,t[81]=h,t[82]=l.inheritedMode,t[83]=l.modeAllow,t[84]=l.modeDeny,t[85]=_,t[86]=r,t[87]=z):z=t[87];let B;return t[88]!==F||t[89]!==R||t[90]!==z?(B=(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[F,R,z]}),t[88]=F,t[89]=R,t[90]=z,t[91]=B):B=t[91],B}function fe(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}var pe=[{id:`overview`,icon:m},{id:`models`,icon:D},{id:`tools`,icon:h},{id:`skills`,icon:k},{id:`impact`,icon:d}];function me(e){return B(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function he(e){return Object.fromEntries(Object.entries(e?.tools?.builtin??{}).map(([e,t])=>[e,t.mode===`allow`?`allow`:`deny`]))}function ge(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function _e(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,version:String(e?.version??1),modelRows:me(e),toolModes:he(e),skillMode:e?.skills?.mode??`inherit`,skillPick:ge(e)}}function Q(e,t){let n=ee(e.modelRows);return n?.roles?{...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},roles:n.roles}:null}function ve(e){let t=Object.fromEntries(Object.entries(e.toolModes).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,{mode:t}]));return Object.keys(t).length>0?{builtin:t}:null}function $(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 ye(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),version:Number(e.version),models:Q(e,t),tools:ve(e),skills:$(e)}}function be(e){return e?{id:e.id,name:e.name,description:e.description??``,version:e.version,models:e.models?.roles?{...e.models.defaultRole?{defaultRole:e.models.defaultRole}:{},roles:e.models.roles}:null,tools:e.tools?.builtin&&Object.keys(e.tools.builtin).length>0?{builtin:e.tools.builtin}:null,skills:e.skills??{mode:`all`}}:null}function xe(e){return[e.models?.roles?`${Object.keys(e.models.roles).length} model roles`:``,e.tools?.builtin?`${Object.keys(e.tools.builtin).length} tool access settings`:``,e.skills?`skills: ${e.skills.mode}`:``].filter(Boolean).join(` · `)||`No shared settings yet`}function Se(e){return e===`safe-coder`?{id:`safe-coder`,name:`Safe Coder`,description:`Shared settings for coding agents: code-oriented model roles, careful command execution, and focused engineering skills.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Complex implementation and planning`},{id:`code`,model:``,fallbacks:[],description:`Code edits and tests`},{id:`review`,model:``,fallbacks:[],description:`Review and risk checks`}],toolModes:{exec_command:`deny`,send_message:`deny`,send_media:`deny`},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`])}:e===`read-only`?{id:`read-only-research`,name:`Read-only Research`,description:`Shared settings for reading, searching, and summarizing without modifying files or running commands.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Synthesis and long-context reading`},{id:`fast`,model:``,fallbacks:[],description:`Quick summaries`}],toolModes:{write_file:`deny`,apply_patch:`deny`,exec_command:`deny`,send_message:`deny`,send_media:`deny`},skillMode:`all`,skillPick:new Set}:e===`low-cost`?{id:`low-cost-assistant`,name:`Low-cost Assistant`,description:`Shared settings for lightweight agents that should prefer faster or cheaper model roles.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Default low-cost model`},{id:`fast`,model:``,fallbacks:[],description:`Low-latency replies`},{id:`cheap`,model:``,fallbacks:[],description:`Batch or summary work`}],toolModes:{},skillMode:`inherit`,skillPick:new Set}:{id:``,name:``,description:``,version:`1`,modelRows:[],toolModes:{},skillMode:`inherit`,skillPick:new Set}}function Ce(){let e=a(s(e=>e.language)),t=e.capabilityPresetsSettings,n=!!o(e=>e.token),{data:r,error:w,isLoading:I,mutate:B}=c(n?`settings-capability-presets`:null,ie,{revalidateOnFocus:!1}),{data:V=[],isLoading:ee}=c(n?`settings-capability-presets-skills-catalog`:null,O,{revalidateOnFocus:!1}),[H,re]=f(),[se,G]=(0,U.useState)(``),[K,q]=(0,U.useState)(`overview`),[J,Y]=(0,U.useState)(()=>Se(`blank`)),[X,le]=(0,U.useState)(!1),[ue,Z]=(0,U.useState)(null),[fe,me]=(0,U.useState)(null),he=r?.presets??[],ge=r?.defaultPresetId??`default`,Q=he.find(e=>e.id===ge)??null,ve=he.filter(e=>e.id!==ge),$=(0,U.useMemo)(()=>he.find(e=>e.id===se)??he[0]??null,[he,se]),Ce=!$||J.id.trim()!==$.id,Te=!!($&&$.id===ge),Ee=JSON.stringify(ye(J,$))!==JSON.stringify(be($)),De=ue??(w instanceof Error?w.message:null),Oe=H.get(`action`)===`new`||!!H.get(`preset`),ke=Ce?t.newPreset:$?.name??t.editorTitle,Ae=t=>e.agentsSettings.toolsDisableGroups[t],je=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,U.useEffect)(()=>{if(!r||X)return;if(H.get(`action`)===`new`){let e=H.get(`starter`);G(``),Y(Se(e===`safe-coder`||e===`read-only`||e===`low-cost`?e:`blank`)),q(`overview`);return}let e=H.get(`preset`)?.trim(),t=e?r.presets.find(t=>t.id===e):null;if(t){G(t.id),Y(_e(t)),q(H.get(`tab`)??`overview`);return}$&&(G($.id),Y(e=>e.id===$.id?e:_e($)))},[X,r,H,$]);function Me(e){G(e.id),Y(_e(e)),re({preset:e.id},{replace:!0}),q(`overview`)}function Ne(e){let t=Se(e);G(``),Y(t),Z(null),re(e===`blank`?{action:`new`}:{action:`new`,starter:e},{replace:!0}),q(`overview`)}function Pe(){re({},{replace:!0}),Z(null),Y(_e($)),q(`overview`)}async function Fe(){let e=z(J.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){Z(e),q(`models`);return}le(!0),Z(null);try{if(Ce){let e=await oe({id:J.id.trim(),name:J.name.trim(),...J.description.trim()?{description:J.description.trim()}:{}}),t=e.presets,n=ye(J,null);(n.models||n.tools||n.skills)&&(t=await te(e.presetId,{version:n.version,models:n.models,tools:n.tools,skills:n.skills})),await B(t,{revalidate:!1}),G(e.presetId),re({preset:e.presetId},{replace:!0})}else if($){let e=ye(J,$);await B(await te($.id,{name:e.name,description:e.description||null,version:e.version,models:e.models,tools:e.tools,skills:e.skills}),{revalidate:!1})}}catch(e){Z(e instanceof Error?e.message:t.saveError)}finally{le(!1)}}async function Ie(){if($){le(!0),Z(null);try{let e=await ne($.id);await B(e,{revalidate:!1});let t=e.presets[0]??null;G(t?.id??``),Y(_e(t)),re(t?{preset:t.id}:{},{replace:!0})}catch(e){Z(e instanceof Error?e.message:t.saveError)}finally{le(!1)}}}return n?(0,W.jsxs)(P,{gap:`gap-5`,className:`pb-24`,children:[(0,W.jsx)(N,{title:t.title,subtitle:t.subtitle,actions:(0,W.jsxs)(A,{type:`button`,onClick:()=>Ne(`blank`),disabled:X,children:[(0,W.jsx)(x,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})}),De?(0,W.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:De}):null,I?(0,W.jsx)(F,{sections:2}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:x,title:t.newPreset,subtitle:t.editorHint}),(0,W.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:[`blank`,`safe-coder`,`read-only`,`low-cost`].map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`min-h-28 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-sm text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>Ne(e),children:[(0,W.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),(0,W.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})]}),Q?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:D,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>Me(Q),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,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Q.name}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Q.id})]}),(0,W.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})]}),Q.description?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Q.description}):null,(0,W.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:xe(Q)})]})]}):null,(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:D,title:t.listTitle,subtitle:t.listHint}),ve.length===0?(0,W.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:t.empty}):(0,W.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:ve.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>Me(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,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,W.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,W.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,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,W.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:xe(e)})]},e.id))})]})]}),(0,W.jsx)(_,{open:Oe,onOpenChange:e=>{e||Pe()},children:(0,W.jsxs)(p,{children:[(0,W.jsx)(v,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,C)}),(0,W.jsx)(j,{ref:me,className:i(`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,W.jsxs)(T,{layer:`modal`,portalContainer:fe,children:[(0,W.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,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(y,{className:`truncate text-base font-semibold text-fg`,children:ke}),(0,W.jsx)(l,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Ce?t.editorHint:J.id})]}),(0,W.jsx)(g,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:i(b,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,W.jsx)(u,{className:`size-4`,"aria-hidden":!0})})})]}),De?(0,W.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:De}):null,(0,W.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:pe.map(({id:e,icon:n})=>(0,W.jsxs)(`button`,{type:`button`,className:i(`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`,K===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>q(e),children:[(0,W.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[K===`overview`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:m,title:t.overviewTitle,subtitle:t.overviewHint}),(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,W.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:J.id,disabled:X||!Ce,onChange:e=>Y(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,W.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:J.version,disabled:X,inputMode:`numeric`,onChange:e=>Y(t=>({...t,version:e.target.value}))})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,W.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:J.name,disabled:X,onChange:e=>Y(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,W.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:J.description,disabled:X,onChange:e=>Y(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,W.jsx)(we,{icon:D,label:t.modelsTitle,value:String(J.modelRows.length)}),(0,W.jsx)(we,{icon:h,label:t.toolsTitle,value:String(Object.keys(J.toolModes).length)}),(0,W.jsx)(we,{icon:k,label:t.skillsTitle,value:t.skillModeLabels[J.skillMode]})]})]}):null,K===`models`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:D,title:t.modelsTitle,subtitle:t.modelsHint}),(0,W.jsx)(ae,{rows:J.modelRows,onChange:e=>Y(t=>({...t,modelRows:e})),disabled:X,defaultRole:$?.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,addPurpose:t.addModelPurpose,noCustomRoles:t.noCustomModelRoles,idPlaceholder:`deep`,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}})]}):null,K===`tools`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:h,title:t.toolsTitle,subtitle:t.toolsHint}),(0,W.jsx)(de,{builtinToolIds:r?.builtinToolIds??[],toolModes:J.toolModes,onChange:e=>Y(t=>({...t,toolModes:e})),disabled:X,getToolDescription:je,getGroupTitle:Ae,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,modeDeny:t.toolModes.deny}})]}):null,K===`skills`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:k,title:t.skillsTitle,subtitle:t.skillsHint}),(0,W.jsx)(ce,{mode:J.skillMode,selected:J.skillPick,catalog:V,loading:ee,disabled:X,onModeChange:e=>Y(t=>({...t,skillMode:e})),onSelectedChange:e=>Y(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,K===`impact`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:d,title:t.usageTitle,subtitle:t.usageHint}),$?.usage.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:$.usage.map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId})]},e.agentId))}):(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,W.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,W.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,W.jsx)(`div`,{className:`font-medium text-fg`,children:Ee?t.unsavedTitle:t.noUnsavedTitle}),(0,W.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Ee?($?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String($?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ee?(0,W.jsx)(A,{type:`button`,variant:`secondary`,disabled:X,onClick:()=>Y(_e($)),children:t.discard}):null,$&&!Te?(0,W.jsxs)(A,{type:`button`,variant:`secondary`,disabled:X,onClick:()=>void Ie(),children:[(0,W.jsx)(M,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,W.jsxs)(A,{type:`button`,disabled:X||!J.id.trim()||!J.name.trim()||!Ee,onClick:()=>void Fe(),children:[(0,W.jsx)(S,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})})]})})]}):(0,W.jsxs)(P,{gap:`gap-3`,children:[(0,W.jsx)(N,{title:t.title}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function we(e){let t=(0,se.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,W.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,W.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,W.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,W.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}export{Ce as CapabilityPresetsSettingsPanel};
|
|
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-BQ_8x0bT.js";import{t as a}from"./messages-DR9ODkb8.js";import{a as o}from"./fetch-6HXXdO77.js";import{n as s}from"./locale-store-Ba72bFmP.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Ba as l,Do as u,Ec as d,El as f,Ha as p,Nc as m,Oo as h,Ra as g,Ua as _,Va as v,Wa as y,_o as b,bs as x,ds as S,io as C,ll as w,no as T,ro as E,tc as D,tr as O,vs as k,wo as A,za as j,zo as M}from"./index-DqFBdoK-.js";import{n as N,t as P}from"./settings-page-layout-DfbMLJgN.js";import{n as F,t as I}from"./settings-loading-skeleton-CGxa3aCb.js";import{n as L,t as R}from"./settings-form-section-GAwBG9Vp.js";import{a as z,i as B,o as V,t as ee}from"./typed-models-lib-Fa9PjI0-.js";import{a as H,i as te,n as ne,o as re,r as ie,s as ae,t as oe}from"./capability-presets-api-CC3vmrm5.js";var se=n(),U=e(t(),1),W=r();function G(e){return e.name||e.directoryId}function ce(e){let t=(0,se.c)(56),{mode:n,selected:r,catalog:a,loading:o,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,f;t[0]===a?f=t[1]:(f=a.map(G).filter(Boolean),t[0]=a,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,W.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t[5]=g):g=t[5];let _;t[6]===u.overrideSummaryTitle?_=t[7]:(_=(0,W.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,W.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,W.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,W.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 T;t[21]===u.modeDenylist?T=t[22]:(T=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=T);let E;t[23]===u.modeOff?E=t[24]:(E=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=E);let D;t[25]!==T||t[26]!==E||t[27]!==x||t[28]!==S||t[29]!==C?(D=[x,S,C,T,E],t[25]=T,t[26]=E,t[27]=x,t[28]=S,t[29]=C,t[30]=D):D=t[30];let O=D,k;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==O?(k=(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:O.map(e=>{let[t,r]=e;return(0,W.jsx)(`button`,{type:`button`,className:i(`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]=O,t[35]=k):k=t[35];let j;t[36]!==k||t[37]!==b?(j=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[b,k]}),t[36]=k,t[37]=b,t[38]=j):j=t[38];let M;t[39]!==a||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]!==o||t[48]!==l||t[49]!==d||t[50]!==r?(M=d?(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:s||o||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:s||o||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),o?(0,W.jsx)(I,{rows:3}):a.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:a.map(e=>{let t=G(e),n=r.has(t),a=typeof e.description==`string`?e.description.trim():``,o=a||u.noDescription;return(0,W.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,W.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,W.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,W.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,W.jsx)(`p`,{className:i(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!a&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})]}):null,t[39]=a,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]=o,t[48]=l,t[49]=d,t[50]=r,t[51]=M):M=t[51];let N;return t[52]!==j||t[53]!==M||t[54]!==y?(N=(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[y,j,M]}),t[52]=j,t[53]=M,t[54]=y,t[55]=N):N=t[55],N}var K=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],q=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],J=[`send_message`,`send_media`,`text_to_speech`,`create_share`],Y=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],X=[...K,...J],le=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],ue=[`send_message`,`send_media`];function Z(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]=i);return n}function de(e){let t=(0,se.c)(92),{builtinToolIds:n,toolModes:r,onChange:a,disabled:o,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(fe),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 H){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=re(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]!==a||t[13]!==r?(g=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]=t,a(n)},t[12]=a,t[13]=r,t[14]=g):g=t[14];let _=g,v;t[15]!==d||t[16]!==a?(v=e=>{a(Z(d,e))},t[15]=d,t[16]=a,t[17]=v):v=t[17];let y=v;if(n.length===0){let e;return t[18]===l.emptyBuiltin?e=t[19]:(e=(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[18]=l.emptyBuiltin,t[19]=e),e}let b;t[20]===l.quickActionsLabel?b=t[21]:(b=(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[20]=l.quickActionsLabel,t[21]=b);let x;t[22]===a?x=t[23]:(x=()=>a({}),t[22]=a,t[23]=x);let S;t[24]!==o||t[25]!==l.quickClearOverrides||t[26]!==x?(S=(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:x,children:l.quickClearOverrides}),t[24]=o,t[25]=l.quickClearOverrides,t[26]=x,t[27]=S):S=t[27];let C;t[28]===y?C=t[29]:(C=()=>y([[K,`deny`]]),t[28]=y,t[29]=C);let w;t[30]!==o||t[31]!==l.quickReadOnlyWorkspace||t[32]!==C?(w=(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:C,children:l.quickReadOnlyWorkspace}),t[30]=o,t[31]=l.quickReadOnlyWorkspace,t[32]=C,t[33]=w):w=t[33];let T;t[34]===y?T=t[35]:(T=()=>y([[q,`deny`]]),t[34]=y,t[35]=T);let E;t[36]!==o||t[37]!==l.quickHighRiskOff||t[38]!==T?(E=(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:T,children:l.quickHighRiskOff}),t[36]=o,t[37]=l.quickHighRiskOff,t[38]=T,t[39]=E):E=t[39];let D;t[40]===y?D=t[41]:(D=()=>y([[J,`deny`]]),t[40]=y,t[41]=D);let O;t[42]!==o||t[43]!==l.quickNoOutbound||t[44]!==D?(O=(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:D,children:l.quickNoOutbound}),t[42]=o,t[43]=l.quickNoOutbound,t[44]=D,t[45]=O):O=t[45];let k;t[46]===y?k=t[47]:(k=()=>y([[Y,`allow`],[X,`deny`]]),t[46]=y,t[47]=k);let j;t[48]!==o||t[49]!==l.quickResearchMode||t[50]!==k?(j=(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:k,children:l.quickResearchMode}),t[48]=o,t[49]=l.quickResearchMode,t[50]=k,t[51]=j):j=t[51];let M;t[52]===y?M=t[53]:(M=()=>y([[le,`allow`],[ue,`deny`]]),t[52]=y,t[53]=M);let N;t[54]!==o||t[55]!==l.quickCodingMode||t[56]!==M?(N=(0,W.jsx)(A,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:M,children:l.quickCodingMode}),t[54]=o,t[55]=l.quickCodingMode,t[56]=M,t[57]=N):N=t[57];let P;t[58]!==E||t[59]!==O||t[60]!==j||t[61]!==N||t[62]!==S||t[63]!==w?(P=(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[S,w,E,O,j,N]}),t[58]=E,t[59]=O,t[60]=j,t[61]=N,t[62]=S,t[63]=w,t[64]=P):P=t[64];let F;t[65]!==P||t[66]!==b?(F=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[b,P]}),t[65]=P,t[66]=b,t[67]=F):F=t[67];let I;t[68]===l.overrideSummaryTitle?I=t[69]:(I=(0,W.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[68]=l.overrideSummaryTitle,t[69]=I);let L;t[70]!==l.modeAllow||t[71]!==l.modeDeny||t[72]!==l.noOverrides||t[73]!==p?(L=p.length>0?(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:p.map(e=>{let[t,n]=e;return(0,W.jsxs)(`span`,{className:i(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,W.jsx)(`span`,{className:`font-sans opacity-80`,children:n===`allow`?l.modeAllow:l.modeDeny})]},t)})}):(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[70]=l.modeAllow,t[71]=l.modeDeny,t[72]=l.noOverrides,t[73]=p,t[74]=L):L=t[74];let R;t[75]!==I||t[76]!==L?(R=(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[I,L]}),t[75]=I,t[76]=L,t[77]=R):R=t[77];let z;t[78]!==o||t[79]!==c||t[80]!==s||t[81]!==h||t[82]!==l.inheritedMode||t[83]!==l.modeAllow||t[84]!==l.modeDeny||t[85]!==_||t[86]!==r?(z=(0,W.jsx)(`div`,{className:`flex flex-col gap-5`,children:h.map(e=>{let{key:t,ids:n}=e;return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=Object.prototype.hasOwnProperty.call(r,e)?r[e]:`inherit`;return(0,W.jsx)(`li`,{className:i(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,n===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:(0,W.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,W.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`deny`].map(t=>(0,W.jsx)(`button`,{type:`button`,className:i(`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`,n===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:o,onClick:()=>_(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:l.modeDeny},t))})]})},e)})})]},t)})}),t[78]=o,t[79]=c,t[80]=s,t[81]=h,t[82]=l.inheritedMode,t[83]=l.modeAllow,t[84]=l.modeDeny,t[85]=_,t[86]=r,t[87]=z):z=t[87];let B;return t[88]!==F||t[89]!==R||t[90]!==z?(B=(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[F,R,z]}),t[88]=F,t[89]=R,t[90]=z,t[91]=B):B=t[91],B}function fe(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}var pe=[{id:`overview`,icon:m},{id:`models`,icon:D},{id:`tools`,icon:h},{id:`skills`,icon:k},{id:`impact`,icon:d}];function me(e){return B(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function he(e){return Object.fromEntries(Object.entries(e?.tools?.builtin??{}).map(([e,t])=>[e,t.mode===`allow`?`allow`:`deny`]))}function ge(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function _e(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,version:String(e?.version??1),modelRows:me(e),toolModes:he(e),skillMode:e?.skills?.mode??`inherit`,skillPick:ge(e)}}function Q(e,t){let n=ee(e.modelRows);return n?.roles?{...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},roles:n.roles}:null}function ve(e){let t=Object.fromEntries(Object.entries(e.toolModes).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,{mode:t}]));return Object.keys(t).length>0?{builtin:t}:null}function $(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 ye(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),version:Number(e.version),models:Q(e,t),tools:ve(e),skills:$(e)}}function be(e){return e?{id:e.id,name:e.name,description:e.description??``,version:e.version,models:e.models?.roles?{...e.models.defaultRole?{defaultRole:e.models.defaultRole}:{},roles:e.models.roles}:null,tools:e.tools?.builtin&&Object.keys(e.tools.builtin).length>0?{builtin:e.tools.builtin}:null,skills:e.skills??{mode:`all`}}:null}function xe(e){return[e.models?.roles?`${Object.keys(e.models.roles).length} model roles`:``,e.tools?.builtin?`${Object.keys(e.tools.builtin).length} tool access settings`:``,e.skills?`skills: ${e.skills.mode}`:``].filter(Boolean).join(` · `)||`No shared settings yet`}function Se(e){return e===`safe-coder`?{id:`safe-coder`,name:`Safe Coder`,description:`Shared settings for coding agents: code-oriented model roles, careful command execution, and focused engineering skills.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Complex implementation and planning`},{id:`code`,model:``,fallbacks:[],description:`Code edits and tests`},{id:`review`,model:``,fallbacks:[],description:`Review and risk checks`}],toolModes:{exec_command:`deny`,send_message:`deny`,send_media:`deny`},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`])}:e===`read-only`?{id:`read-only-research`,name:`Read-only Research`,description:`Shared settings for reading, searching, and summarizing without modifying files or running commands.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Synthesis and long-context reading`},{id:`fast`,model:``,fallbacks:[],description:`Quick summaries`}],toolModes:{write_file:`deny`,apply_patch:`deny`,exec_command:`deny`,send_message:`deny`,send_media:`deny`},skillMode:`all`,skillPick:new Set}:e===`low-cost`?{id:`low-cost-assistant`,name:`Low-cost Assistant`,description:`Shared settings for lightweight agents that should prefer faster or cheaper model roles.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Default low-cost model`},{id:`fast`,model:``,fallbacks:[],description:`Low-latency replies`},{id:`cheap`,model:``,fallbacks:[],description:`Batch or summary work`}],toolModes:{},skillMode:`inherit`,skillPick:new Set}:{id:``,name:``,description:``,version:`1`,modelRows:[],toolModes:{},skillMode:`inherit`,skillPick:new Set}}function Ce(){let e=a(s(e=>e.language)),t=e.capabilityPresetsSettings,n=!!o(e=>e.token),{data:r,error:w,isLoading:I,mutate:B}=c(n?`settings-capability-presets`:null,ie,{revalidateOnFocus:!1}),{data:V=[],isLoading:ee}=c(n?`settings-capability-presets-skills-catalog`:null,O,{revalidateOnFocus:!1}),[H,re]=f(),[se,G]=(0,U.useState)(``),[K,q]=(0,U.useState)(`overview`),[J,Y]=(0,U.useState)(()=>Se(`blank`)),[X,le]=(0,U.useState)(!1),[ue,Z]=(0,U.useState)(null),[fe,me]=(0,U.useState)(null),he=r?.presets??[],ge=r?.defaultPresetId??`default`,Q=he.find(e=>e.id===ge)??null,ve=he.filter(e=>e.id!==ge),$=(0,U.useMemo)(()=>he.find(e=>e.id===se)??he[0]??null,[he,se]),Ce=!$||J.id.trim()!==$.id,Te=!!($&&$.id===ge),Ee=JSON.stringify(ye(J,$))!==JSON.stringify(be($)),De=ue??(w instanceof Error?w.message:null),Oe=H.get(`action`)===`new`||!!H.get(`preset`),ke=Ce?t.newPreset:$?.name??t.editorTitle,Ae=t=>e.agentsSettings.toolsDisableGroups[t],je=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,U.useEffect)(()=>{if(!r||X)return;if(H.get(`action`)===`new`){let e=H.get(`starter`);G(``),Y(Se(e===`safe-coder`||e===`read-only`||e===`low-cost`?e:`blank`)),q(`overview`);return}let e=H.get(`preset`)?.trim(),t=e?r.presets.find(t=>t.id===e):null;if(t){G(t.id),Y(_e(t)),q(H.get(`tab`)??`overview`);return}$&&(G($.id),Y(e=>e.id===$.id?e:_e($)))},[X,r,H,$]);function Me(e){G(e.id),Y(_e(e)),re({preset:e.id},{replace:!0}),q(`overview`)}function Ne(e){let t=Se(e);G(``),Y(t),Z(null),re(e===`blank`?{action:`new`}:{action:`new`,starter:e},{replace:!0}),q(`overview`)}function Pe(){re({},{replace:!0}),Z(null),Y(_e($)),q(`overview`)}async function Fe(){let e=z(J.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){Z(e),q(`models`);return}le(!0),Z(null);try{if(Ce){let e=await oe({id:J.id.trim(),name:J.name.trim(),...J.description.trim()?{description:J.description.trim()}:{}}),t=e.presets,n=ye(J,null);(n.models||n.tools||n.skills)&&(t=await te(e.presetId,{version:n.version,models:n.models,tools:n.tools,skills:n.skills})),await B(t,{revalidate:!1}),G(e.presetId),re({preset:e.presetId},{replace:!0})}else if($){let e=ye(J,$);await B(await te($.id,{name:e.name,description:e.description||null,version:e.version,models:e.models,tools:e.tools,skills:e.skills}),{revalidate:!1})}}catch(e){Z(e instanceof Error?e.message:t.saveError)}finally{le(!1)}}async function Ie(){if($){le(!0),Z(null);try{let e=await ne($.id);await B(e,{revalidate:!1});let t=e.presets[0]??null;G(t?.id??``),Y(_e(t)),re(t?{preset:t.id}:{},{replace:!0})}catch(e){Z(e instanceof Error?e.message:t.saveError)}finally{le(!1)}}}return n?(0,W.jsxs)(P,{gap:`gap-5`,className:`pb-24`,children:[(0,W.jsx)(N,{title:t.title,subtitle:t.subtitle,actions:(0,W.jsxs)(A,{type:`button`,onClick:()=>Ne(`blank`),disabled:X,children:[(0,W.jsx)(x,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})}),De?(0,W.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:De}):null,I?(0,W.jsx)(F,{sections:2}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:x,title:t.newPreset,subtitle:t.editorHint}),(0,W.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:[`blank`,`safe-coder`,`read-only`,`low-cost`].map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`min-h-28 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-sm text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>Ne(e),children:[(0,W.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),(0,W.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})]}),Q?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:D,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>Me(Q),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,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Q.name}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Q.id})]}),(0,W.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})]}),Q.description?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Q.description}):null,(0,W.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:xe(Q)})]})]}):null,(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:D,title:t.listTitle,subtitle:t.listHint}),ve.length===0?(0,W.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:t.empty}):(0,W.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:ve.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>Me(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,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,W.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,W.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,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,W.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:xe(e)})]},e.id))})]})]}),(0,W.jsx)(_,{open:Oe,onOpenChange:e=>{e||Pe()},children:(0,W.jsxs)(p,{children:[(0,W.jsx)(v,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,C)}),(0,W.jsx)(j,{ref:me,className:i(`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,W.jsxs)(T,{layer:`modal`,portalContainer:fe,children:[(0,W.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,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(y,{className:`truncate text-base font-semibold text-fg`,children:ke}),(0,W.jsx)(l,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Ce?t.editorHint:J.id})]}),(0,W.jsx)(g,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:i(b,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,W.jsx)(u,{className:`size-4`,"aria-hidden":!0})})})]}),De?(0,W.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:De}):null,(0,W.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:pe.map(({id:e,icon:n})=>(0,W.jsxs)(`button`,{type:`button`,className:i(`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`,K===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>q(e),children:[(0,W.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[K===`overview`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:m,title:t.overviewTitle,subtitle:t.overviewHint}),(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,W.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:J.id,disabled:X||!Ce,onChange:e=>Y(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,W.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:J.version,disabled:X,inputMode:`numeric`,onChange:e=>Y(t=>({...t,version:e.target.value}))})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,W.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:J.name,disabled:X,onChange:e=>Y(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,W.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:J.description,disabled:X,onChange:e=>Y(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,W.jsx)(we,{icon:D,label:t.modelsTitle,value:String(J.modelRows.length)}),(0,W.jsx)(we,{icon:h,label:t.toolsTitle,value:String(Object.keys(J.toolModes).length)}),(0,W.jsx)(we,{icon:k,label:t.skillsTitle,value:t.skillModeLabels[J.skillMode]})]})]}):null,K===`models`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:D,title:t.modelsTitle,subtitle:t.modelsHint}),(0,W.jsx)(ae,{rows:J.modelRows,onChange:e=>Y(t=>({...t,modelRows:e})),disabled:X,defaultRole:$?.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,addPurpose:t.addModelPurpose,noCustomRoles:t.noCustomModelRoles,idPlaceholder:`deep`,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}})]}):null,K===`tools`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:h,title:t.toolsTitle,subtitle:t.toolsHint}),(0,W.jsx)(de,{builtinToolIds:r?.builtinToolIds??[],toolModes:J.toolModes,onChange:e=>Y(t=>({...t,toolModes:e})),disabled:X,getToolDescription:je,getGroupTitle:Ae,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,modeDeny:t.toolModes.deny}})]}):null,K===`skills`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:k,title:t.skillsTitle,subtitle:t.skillsHint}),(0,W.jsx)(ce,{mode:J.skillMode,selected:J.skillPick,catalog:V,loading:ee,disabled:X,onModeChange:e=>Y(t=>({...t,skillMode:e})),onSelectedChange:e=>Y(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,K===`impact`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:d,title:t.usageTitle,subtitle:t.usageHint}),$?.usage.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:$.usage.map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId})]},e.agentId))}):(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,W.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,W.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,W.jsx)(`div`,{className:`font-medium text-fg`,children:Ee?t.unsavedTitle:t.noUnsavedTitle}),(0,W.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Ee?($?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String($?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ee?(0,W.jsx)(A,{type:`button`,variant:`secondary`,disabled:X,onClick:()=>Y(_e($)),children:t.discard}):null,$&&!Te?(0,W.jsxs)(A,{type:`button`,variant:`secondary`,disabled:X,onClick:()=>void Ie(),children:[(0,W.jsx)(M,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,W.jsxs)(A,{type:`button`,disabled:X||!J.id.trim()||!J.name.trim()||!Ee,onClick:()=>void Fe(),children:[(0,W.jsx)(S,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})})]})})]}):(0,W.jsxs)(P,{gap:`gap-3`,children:[(0,W.jsx)(N,{title:t.title}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function we(e){let t=(0,se.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,W.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,W.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,W.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,W.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}export{Ce as CapabilityPresetsSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t}from"./fetch-
|
|
1
|
+
import{n as e,o as t}from"./fetch-6HXXdO77.js";function n(e,t){let n=Date.now()-new Date(e).getTime();return n<6e4?t.justNow:n<36e5?t.minutesAgo.replace(`{{count}}`,String(Math.floor(n/6e4))):n<864e5?t.hoursAgo.replace(`{{count}}`,String(Math.floor(n/36e5))):n<6048e5?t.daysAgo.replace(`{{count}}`,String(Math.floor(n/864e5))):new Date(e).toLocaleDateString()}function r(e,t){let r=n(e.lastActive,t);return e.channel===`telegram`&&e.peerId?`${e.accountId??`default`} · ${e.peerKind??``} · ${e.peerId} · ${r}`:`${e.channel}: ${e.chatId} · ${r}`}async function i(){return(await e(t(`/api/channels/status`))).payload?.channels||[]}async function a(n){return(await e(t(`/api/sessions/chat-ids${n?`?channel=${encodeURIComponent(n)}`:``}`))).payload?.chatIds||[]}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{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DR9ODkb8.js";import{a as o,n as s,o as c,t as l}from"./fetch-6HXXdO77.js";import{n as u}from"./locale-store-Ba72bFmP.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Ba as f,Dc as p,Do as m,Ga as h,Ha as g,Qa as _,Qc as v,Ra as y,Ro as b,Tl as x,Ua as S,Us as C,Va as w,Wa as T,Xc as E,_i as D,_o as O,_s as k,as as A,da as j,ga as M,gr as N,ha as P,hr as F,io as I,mr as L,no as R,ps as z,qn as ee,qo as te,ro as ne,rt as re,wl as ie,wo as B,za as ae}from"./index-DqFBdoK-.js";import{n as oe,t as se}from"./settings-page-layout-DfbMLJgN.js";import{n as ce}from"./settings-loading-skeleton-CGxa3aCb.js";import{t as le}from"./schema-form-D8XdvcNH.js";import{t as ue}from"./browser-BLJWD7WI.js";import{n as de,t as fe}from"./channels-status-swr-BG_j4Ci-.js";import{t as pe}from"./use-channel-catalog-BCBfSoHx.js";var V=n(),me=e(ue(),1),H=e(t(),1),U=r();function he(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}async function ge(e){let t=await l(c(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function _e({entry:e,locale:t,messages:n,onChanged:r,compact:a=!1}){let o=(0,H.useMemo)(()=>he(e),[e]),s=(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 ge({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=K(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||ge({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||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=o?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,m=G(c.payload),h=K(c.payload,e.id),g=h?c.generatedQr:q(c.payload),_=o?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),v=c.payload?.type===`form`?c.payload:null,y=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:a?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:i(`flex flex-wrap items-start gap-3`,a?`justify-end`:`justify-between`),children:[a?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?(0,U.jsxs)(B,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(o[0]),children:[c.busy?(0,U.jsx)(C,{className:`size-4 animate-spin`}):(0,U.jsx)(k,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(B,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,U.jsx)(te,{className:`size-4`}),f]}):null]})]}),m?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:m}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,_?(0,U.jsxs)(`div`,{className:i(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base px-3 py-3 shadow-surface`,a?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:g?(0,U.jsx)(`img`,{src:g,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(P,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:i(`min-w-0 max-w-sm text-sm text-fg-muted`,a&&`w-full sm:w-auto`),children:[g?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(P,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(P,{className:`h-4 w-36 max-w-full`})]}),h?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:h,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(p,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(E,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.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,v?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(le,{schema:v.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:s}),(0,U.jsx)(B,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(v.submitAction,c.formDraft),children:n.saveSetup})]}):null,y?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:y.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var ve=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ye(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function be(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:ve,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function xe(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 Se(e,t,n){let r=xe(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Ce(e,t=!1){return e===`drawer`?i(`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`,ne):i(`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)]`,ne,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function we(e){let t=(0,V.c)(33),{presentation:n,open:r,onOpenChange:a,title:o,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:p,wide:h,headerExtra:_}=e,v=h===void 0?!1:h,b=n===`drawer`,[x,C]=(0,H.useState)(null),E;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,U.jsx)(w,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,I)}),t[0]=E):E=t[0];let D;t[1]!==n||t[2]!==v?(D=Ce(n,v),t[1]=n,t[2]=v,t[3]=D):D=t[3];let k;t[4]===c?k=t[5]:(k=c?(0,U.jsx)(T,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=k);let A;t[6]===l?A=t[7]:(A=l?(0,U.jsx)(f,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=A);let j;t[8]!==u||t[9]!==s||t[10]!==_||t[11]!==b||t[12]!==o?(j=b?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[o?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:o}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(y,{asChild:!0,children:(0,U.jsx)(B,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(m,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(y,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:i(O,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(m,{className:`size-4`})})}),_]}),t[8]=u,t[9]=s,t[10]=_,t[11]=b,t[12]=o,t[13]=j):j=t[13];let M=b?`px-4 py-4`:`p-6`,N;t[14]===M?N=t[15]:(N=i(`min-h-0 flex-1 overflow-y-auto`,M),t[14]=M,t[15]=N);let P;t[16]!==d||t[17]!==N?(P=(0,U.jsx)(`div`,{className:N,children:d}),t[16]=d,t[17]=N,t[18]=P):P=t[18];let F;t[19]!==p||t[20]!==x||t[21]!==k||t[22]!==A||t[23]!==j||t[24]!==P?(F=(0,U.jsxs)(R,{layer:`modal`,portalContainer:x,children:[k,A,j,P,p]}),t[19]=p,t[20]=x,t[21]=k,t[22]=A,t[23]=j,t[24]=P,t[25]=F):F=t[25];let L;t[26]!==F||t[27]!==D?(L=(0,U.jsxs)(g,{children:[E,(0,U.jsx)(ae,{ref:C,className:D,onOpenAutoFocus:Te,children:F})]}),t[26]=F,t[27]=D,t[28]=L):L=t[28];let z;return t[29]!==a||t[30]!==r||t[31]!==L?(z=(0,U.jsx)(S,{open:r,onOpenChange:a,children:L}),t[29]=a,t[30]=r,t[31]=L,t[32]=z):z=t[32],z}function Te(e){return e.preventDefault()}var Ee=(0,H.memo)(function(e){let t=(0,V.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(D,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function De(e){let t=(0,V.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(B,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(B,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(B,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}var Oe=`channels-status`;function ke(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Ae(e){let t=t=>e(t.detail);return window.addEventListener(Oe,t),()=>window.removeEventListener(Oe,t)}function je(e,t){let n=(0,V.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Ae(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 Me(e){return e?c(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Ne(e){return(await s(c(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Pe=[`enabled`];async function Fe(){let e=await s(c(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Ie(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Le(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Re(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function ze(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Be(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 Ve(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Pe.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Pe.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function He(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ue(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ue(n)&&delete t[e];return Object.keys(t).length===0}function We(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ue(n),n}function Ge(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Ke(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function qe(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(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=Y(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=Y(e),r=he(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=he(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=o(e=>e.token),[n,r]=(0,H.useState)(!1),i=(0,H.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(c(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Ie(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(M,{sourceChannel:e.id,className:`size-7`})})}function et(e){let t=(0,V.c)(16),{checked:n,disabled:r,onToggle:a,label:o}=e,s;t[0]===a?s=t[1]:(s=e=>{e.stopPropagation(),a()},t[0]=a,t[1]=s);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=i(`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=i(`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,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==o||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":o,disabled:r,onClick:s,className:u,children:p}),t[9]=n,t[10]=r,t[11]=o,t[12]=s,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function tt(e){let t=(0,V.c)(71),{entry:n,config:r,runtime:a,busy:o,restarting:s,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==o||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==a||t[10]!==p.enabled||t[11]!==p.ready){let e=Ye(n,r,c),s=Ze(n,c);m=!p.enabled&&p.ready?u:a===`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,U.jsx)($e,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===a?S=t[24]:(S=i(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Be(a)),t[23]=a,t[24]=S);let C;t[25]!==c||t[26]!==a?(C=Re(a,c),t[25]=c,t[26]=a,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,U.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,U.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]!==o||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,U.jsx)(et,{checked:D,disabled:o,label:O,onToggle:u}),t[40]=o,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,U.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,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(rt)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Xe(n,c)}),s.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:s.map(nt)}):null]}),t[2]=o,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=a,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 x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,U.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=o||s,w;t[53]!==o||t[54]!==s?(w=o||s?(0,U.jsx)(C,{className:`size-4 animate-spin`}):null,t[53]=o,t[54]=s,t[55]=w):w=t[55];let T;t[56]!==c||t[57]!==n||t[58]!==s||t[59]!==a?(T=s?c.restartingChannel:a===`stopped`?c.restartChannel:Q(n,c),t[56]=c,t[57]=n,t[58]=s,t[59]=a,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==w||t[63]!==T||t[64]!==S?(E=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(B,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[w,T]})}),t[61]=m,t[62]=w,t[63]=T,t[64]=S,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==y||t[68]!==b||t[69]!==x?(D=(0,U.jsxs)(`article`,{className:y,children:[b,x,E]}),t[66]=E,t[67]=y,t[68]=b,t[69]=x,t[70]=D):D=t[70],D}function nt(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function rt(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function it(e){let t=(0,V.c)(51),{runtime:n,restarting:r,checking:a,showConnectionOptions:o,canManageConnection:s,ch:c,onRestart:l,onCheck:u,onManageConnection:d}=e,f=n===`running`?E:n===`stopped`||n===`needs_setup`?v:C,p=n===`running`&&`text-emerald-600 dark:text-emerald-400`,m=n===`stopped`&&`text-red-600 dark:text-red-400`,h=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,g=n===`disabled`&&`text-fg-muted`,_=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==p||t[1]!==m||t[2]!==h||t[3]!==g||t[4]!==_?(y=i(`mt-0.5 size-5 shrink-0`,p,m,h,g,_),t[0]=p,t[1]=m,t[2]=h,t[3]=g,t[4]=_,t[5]=y):y=t[5];let b;t[6]!==f||t[7]!==y?(b=(0,U.jsx)(f,{className:y}),t[6]=f,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=ze(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let w;t[14]===S?w=t[15]:(w=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=w);let T;t[16]!==w||t[17]!==x?(T=(0,U.jsxs)(`div`,{children:[x,w]}),t[16]=w,t[17]=x,t[18]=T):T=t[18];let D;t[19]!==T||t[20]!==b?(D=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,T]}),t[19]=T,t[20]=b,t[21]=D):D=t[21];let O=a||r,k;t[22]===a?k=t[23]:(k=a?(0,U.jsx)(C,{className:`size-4 animate-spin`}):null,t[22]=a,t[23]=k);let A=a?c.checkingConnection:c.checkConnection,j;t[24]!==u||t[25]!==O||t[26]!==k||t[27]!==A?(j=(0,U.jsxs)(B,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:u,children:[k,A]}),t[24]=u,t[25]=O,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==a||t[32]!==l||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,U.jsxs)(B,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||a,onClick:l,children:[r?(0,U.jsx)(C,{className:`size-4 animate-spin`}):(0,U.jsx)(z,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=a,t[32]=l,t[33]=r,t[34]=n,t[35]=M):M=t[35];let N;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==a||t[40]!==d||t[41]!==r||t[42]!==o?(N=s?(0,U.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:a||r,onClick:d,children:o?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=a,t[40]=d,t[41]=r,t[42]=o,t[43]=N):N=t[43];let P;t[44]!==j||t[45]!==M||t[46]!==N?(P=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=P):P=t[47];let F;return t[48]!==D||t[49]!==P?(F=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[D,P]})}),t[48]=D,t[49]=P,t[50]=F):F=t[50],F}function at(e){let t=(0,V.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl 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,U.jsx)(b,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children: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,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ot(){let e=u(e=>e.language),t=a(e),n=o(e=>!!e.token),r=ie(),{channelId:s}=x(),f=N(s),m=pe(n,e),g=m.entries,{data:v,mutate:y,isValidating:b}=d(n?fe():null,de,{revalidateOnFocus:!0}),{data:S,mutate:C}=d(n?`channels-config-map`:null,Fe,{revalidateOnFocus:!1}),w=S?.channels??{},T=S?.bindings??[],{data:E}=d(n?`channel-routing-agents`:null,j,{revalidateOnFocus:!1}),D=h(e=>e.setPageHeader),O=h(e=>e.clearPageHeader),k=(0,H.useMemo)(()=>g.find(e=>e.id===f),[f,g]),M=k?Le(k):null,{data:P,mutate:I}=d(n&&M?Me(M):null,()=>Ne(M)),[R,z]=(0,H.useState)(null),[te,ne]=(0,H.useState)(!1),[B,ae]=(0,H.useState)(null),[ue,V]=(0,H.useState)(null),[me,ge]=(0,H.useState)(!1),[W,G]=(0,H.useState)(null),[K,q]=(0,H.useState)(null),ve=R??P??{},J=t.channelsSettings,xe=(0,H.useMemo)(()=>k?.configSchema??{type:`object`,properties:{}},[k?.configSchema]),Ce=(0,H.useMemo)(()=>We(xe,Pe),[xe]),Te=(0,H.useMemo)(()=>Ve(k),[k]),Oe=(0,H.useMemo)(()=>He(Ce,Te),[Te,Ce]),Ae=(0,H.useMemo)(()=>We(Ce,Te),[Te,Ce]),Ie=(0,H.useMemo)(()=>Ge(Oe),[Oe]),ze=k?K??ye(T,k.id):``,X=(0,H.useMemo)(()=>(E?.items??[]).map(e=>{let n=ee(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[E?.items,t.agentsSettings]),Z=E?.items.find(e=>e.id===E.defaultId),Ue=Z?ee(Z,t.agentsSettings):E?.defaultId??``,Ke=(0,H.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),qe=(0,H.useMemo)(()=>new Map((v??[]).map(e=>[e.name,e])),[v]),Je=v!==void 0,Ye=(0,H.useCallback)(e=>Se(e,qe.get(e.id),Je),[qe,Je]),Q=(0,H.useCallback)(async()=>{await Promise.all([m.mutate(),y()])},[m,y]);je((0,H.useCallback)(e=>{let t=ke(e);t&&y(t,!1)},[y]),n);let Xe=(0,H.useMemo)(()=>n?(0,U.jsx)(Ee,{ch:J,refreshing:m.isValidating||b,saveOk:!1,onRefresh:()=>void Q()}):null,[m.isValidating,J,n,b,Q]);(0,H.useLayoutEffect)(()=>(D({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>O()),[O,Xe,t.settingsSections.channels,D]);let Ze=(0,H.useCallback)(e=>{r(F(e)),z(null),q(null),G(null)},[r]),Qe=(0,H.useCallback)(()=>{r(L),z(null),q(null),G(null)},[r]),nt=(0,H.useCallback)(async e=>{V(e.id),G(null);try{let t=await l(c(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{V(null)}},[Q]);(0,H.useEffect)(()=>{q(null),ge(!1)},[k?.id]);let rt=(0,H.useCallback)(async()=>{if(!k||!R&&K===null)return!1;let e=Le(k);ne(!0),G(null);try{let t=await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({...R?{channels:{[e]:R}}:{},...K===null?{}:{bindings:be(T,k.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return R&&await I(R,!1),await C(),await m.mutate(),z(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[k,K,T,m,R,C,I]),ot=(0,H.useCallback)(async e=>{let t=Y(e),n=Le(e),r=k?.id===e.id?R:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ae(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await l(c(`/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 m.mutate(),await C(),await y(),k?.id===e.id&&(await I(),z(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(null)}},[k?.id,m,R,C,I,y,Ze]),$=k?.ui?.modal,st=$?.placement!==`replace-config`,ct=k?Ye(k):`checking`,lt=k?!Y(k).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,children:[m.isLoading?(0,U.jsx)(ce,{sections:2}):m.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(m.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,U.jsx)(tt,{entry:e,config:w[Le(e)]?.config,runtime:Ye(e),busy:B===e.id,restarting:ue===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void ot(e),onRestart:()=>void nt(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(we,{presentation:`modal`,open:!!k,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:k?.label??J.selectChannel,srDescription:k?.description,wide:!0,footer:k?(0,U.jsx)(De,{ch:J,dirty:!!R||K!==null,saving:te,onCancel:Qe,onDiscard:()=>{z(null),q(null)},onSave:rt}):null,children:k?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)($e,{entry:k}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:k.label}),(0,U.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Be(ct)),children:Re(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(k).ready&&he(k)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,k.label):k.description}),k.docsPath?(0,U.jsxs)(`a`,{href:k.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(p,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(k).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(et,{checked:Y(k).enabled,disabled:B===k.id,label:J.toggleChannel.replace(`{{channel}}`,k.label),onToggle:()=>void ot(k)})]})]})}),(0,U.jsx)(it,{runtime:ct,restarting:ue===k.id,checking:b,showConnectionOptions:me,canManageConnection:Y(k).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void nt(k),onCheck:()=>void Q(),onManageConnection:()=>ge(e=>!e)}),(0,U.jsx)(at,{entry:k,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(_e,{entry:k,locale:e,messages:J,compact:!0,onChanged:async()=>{await I(),await Q(),await C()}},k.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(re,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:ve}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(re,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:ve}}):null,st&&Ie?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(le,{schema:Oe,values:ve,onChange:e=>z(e),disabled:te,labels:Ke})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(A,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(_,{value:ze,options:X,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,Ue||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:te||!E,onChange:e=>q(e)})]})]}),st&&Ge(Ae)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(A,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(le,{schema:Ae,values:ve,onChange:e=>z(e),disabled:te,labels:Ke})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{ot as ChannelsSettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./fetch-6HXXdO77.js";import{n as t}from"./channel-recipient-api-RANYrzfa.js";function n(){return e(`/api/channels/status`)}var r=t;export{r as n,n as t};
|
package/dist/gateway/static/root/assets/{connectors-page-DCE-PgQF.js → connectors-page-DIZKYaMj.js}
RENAMED
|
@@ -1,2 +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{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-Bq4REfIj.js";import{a as o,n as s,o as c}from"./fetch-Bl7zMnmd.js";import{n as l}from"./locale-store-Ba72bFmP.js";import{r as u}from"./toast-z0toXu32.js";import{$a as d,$r as f,Ba as p,Cc as m,Co as h,Cs as g,Do as _,El as v,Fr as y,Ga as b,Ha as x,Lr as S,Mr as C,Ms as w,Nr as T,Oo as E,Pr as D,Qr as O,Ra as k,Ua as A,Us as j,Va as ee,Vc as M,Wa as te,Xc as N,Zr as P,_c as ne,_i as F,bs as re,cs as I,ds as L,ei as ie,ho as ae,io as oe,jc as se,ma as ce,nc as le,ns as ue,os as R,pa as z,po as de,ro as fe,ti as pe,tl as me,to as he,vo as B,wo as V,xs as ge,za as _e,zo as ve}from"./index-DOetFpTt.js";import{n as ye,t as be}from"./settings-form-section-C-5-n-jM.js";import{t as xe}from"./page-tabs-Cy7bX7Ce.js";var H=e(t(),1),U=n(),W=r(),G=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`,Se=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function Ce(e,t){return t.some(t=>t.connectorId===e.id)}function K(e,t){return t[e]??e}function q(e,t){return t.connectorCategoryTemplate.replace(`{{category}}`,K(e,t.connectorCategoryLabels))}function we(){let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.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,W.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-4 min-w-0 flex-1`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-[4.5rem] shrink-0 rounded-lg`,G)})]}),(0,W.jsx)(`div`,{className:i(`h-3 w-full`,G)}),(0,W.jsx)(`div`,{className:i(`h-3 w-[88%]`,G)})]})})}),e[0]=t):t=e[0],t}function Te(){let e=(0,U.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,W.jsx)(`div`,{className:i(`h-4 w-48 max-w-full`,G)}),(0,W.jsx)(`div`,{className:i(`h-3 w-72 max-w-full`,G)})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[t,(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,G)}),(0,W.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,G)})]})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,W.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[n,(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-8 w-20 rounded-md`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-24 rounded-md`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-28 rounded-md`,G)})]}),(0,W.jsx)(`div`,{className:i(`mt-3 h-20 rounded-xl`,G)})]}),e[2]=r):r=e[2],r}function Ee(e){let t=(0,U.c)(69),{connector:n,installed:r,onInstall:a,onOpenDetails:o,t:s}=e,c;t[0]!==n.category||t[1]!==s?(c=q(n.category,s),t[0]=n.category,t[1]=s,t[2]=c):c=t[2];let l=c,u,d,f,p,m,h,g,_,v,y;if(t[3]!==l||t[4]!==n||t[5]!==r||t[6]!==a||t[7]!==o||t[8]!==s.install||t[9]!==s.installedBadge){let e=n.capabilities.slice(0,4),c=Math.max(0,n.capabilities.length-e.length),b;t[20]!==n||t[21]!==a||t[22]!==s.install?(b=e=>(0,W.jsxs)(V,{type:`button`,variant:`primary`,className:i(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),a(n)},children:[(0,W.jsx)(w,{className:`size-4`}),s.install]}),t[20]=n,t[21]=a,t[22]=s.install,t[23]=b):b=t[23],u=b;let x;t[24]!==n||t[25]!==o?(x=e=>{!o||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o(n))},t[24]=n,t[25]=o,t[26]=x):x=t[26];let S=x,C=o?`cursor-pointer`:null;t[27]===C?g=t[28]:(g=i(`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`,C),t[27]=C,t[28]=g),_=o?`button`:void 0,v=o?0:void 0,t[29]!==n||t[30]!==o?(y=()=>o?.(n),t[29]=n,t[30]=o,t[31]=y):y=t[31],d=S,f=`flex min-w-0 flex-1 flex-col`;let T;t[32]===n.displayName?T=t[33]:(T=(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[32]=n.displayName,t[33]=T);let E;t[34]===l?E=t[35]:(E=(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:l}),t[34]=l,t[35]=E);let D;t[36]!==T||t[37]!==E?(D=(0,W.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[T,E]})}),t[36]=T,t[37]=E,t[38]=D):D=t[38];let O;t[39]!==r||t[40]!==u?(O=r?null:(0,W.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:u()}),t[39]=r,t[40]=u,t[41]=O):O=t[41];let k;t[42]!==r||t[43]!==s.installedBadge?(k=r?(0,W.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,W.jsx)(N,{className:`size-3`,"aria-hidden":!0}),s.installedBadge]}):null,t[42]=r,t[43]=s.installedBadge,t[44]=k):k=t[44];let A;t[45]!==O||t[46]!==k?(A=(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[O,k]}),t[45]=O,t[46]=k,t[47]=A):A=t[47],t[48]!==D||t[49]!==A?(p=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[D,A]}),t[48]=D,t[49]=A,t[50]=p):p=t[50],t[51]===n.description?m=t[52]:(m=(0,W.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[51]=n.description,t[52]=m),h=e.length>0?(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[e.map(J),c>0?(0,W.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,c]}):null]}):null,t[3]=l,t[4]=n,t[5]=r,t[6]=a,t[7]=o,t[8]=s.install,t[9]=s.installedBadge,t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g,t[17]=_,t[18]=v,t[19]=y}else u=t[10],d=t[11],f=t[12],p=t[13],m=t[14],h=t[15],g=t[16],_=t[17],v=t[18],y=t[19];let b;t[53]!==f||t[54]!==p||t[55]!==m||t[56]!==h?(b=(0,W.jsxs)(`div`,{className:f,children:[p,m,h]}),t[53]=f,t[54]=p,t[55]=m,t[56]=h,t[57]=b):b=t[57];let x;t[58]!==r||t[59]!==u?(x=r?null:(0,W.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:u(`w-full`)}),t[58]=r,t[59]=u,t[60]=x):x=t[60];let S;return t[61]!==d||t[62]!==b||t[63]!==x||t[64]!==g||t[65]!==_||t[66]!==v||t[67]!==y?(S=(0,W.jsxs)(`div`,{className:g,role:_,tabIndex:v,onClick:y,onKeyDown:d,children:[b,x]}),t[61]=d,t[62]=b,t[63]=x,t[64]=g,t[65]=_,t[66]=v,t[67]=y,t[68]=S):S=t[68],S}function J(e){return(0,W.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Y(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function De(){return Y(await s(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function Oe(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),Y(await s(c(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function ke(e,t){return Y(await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function Ae(e,t,n){let r=await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return z(),Y(r,`Could not install Store connector.`).instance}async function je(){return Y(await s(c(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function Me(){return Y(await s(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var Ne=new Map,Pe=300*1e3;async function Fe(e,t=`all`,n){let r=e.trim(),i=t.trim()||`all`,a=n?.browse??!1,o=Math.max(n?.page??1,1),l=Math.max(n?.pageSize??24,1),u=`${i}:${r}:${a?`browse`:`search`}:${o}:${l}`,d=Date.now(),f=Ne.get(u);if(f&&f.expiresAt>d)return f.promise;let p=new URLSearchParams;r&&p.set(`q`,r),i!==`all`&&p.set(`source`,i),a&&p.set(`browse`,`1`),p.set(`page`,String(o)),p.set(`pageSize`,String(l));let m=s(c(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Y(e,`Could not search connector registries.`),n=Math.max(0,...(t.results??[]).map(e=>e.totalPages??0))||void 0;return{connectors:t.connectors,totalPages:n}});Ne.set(u,{expiresAt:d+Pe,promise:m});try{return await m}catch(e){throw Ne.delete(u),e}}async function Ie(e){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Le(e,t){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Re(e,t){let n=await s(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return z(),Y(n,`Could not install connector.`).instance}async function ze(e,t={}){return Y(await s(c(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function Be(e,t){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function Ve(e){await s(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),z()}async function He(e){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function Ue(){return Y(await s(c(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function We(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/authorize`),{method:`POST`}),`Could not start Composio authorization.`).oauth}async function Ge(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function Ke(e,t){let n=await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return z(),Y(n,`Could not update Composio scope.`).scope}async function qe(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function Je(e=50){return Y(await s(c(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}function X(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function Ye(e,t){return t.connectorCapabilityLabels[e]??e}function Xe(e,t){if(e.runtime.type===`mcp`)return X(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.id??e.runtime.channelId??e.runtime.toolkit??e.runtime.toolsetId??e.runtime.sourceKind??e.runtime.type;return X(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n})}function Ze(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Qe(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function $e(e){let t=(0,U.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,W.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(et),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,W.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,W.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,W.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 et(e){return(0,W.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,W.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function tt({connector:e,installed:t,onClose:n,onInstall:r,t:a}){let[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),f=Qe(e),m=e.capabilities.slice(0,8),h=Math.max(0,e.capabilities.length-m.length),v=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:a.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:a.connectorSetupConfig}))],y=async()=>{s(!0),d(null);try{l(await ze(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,W.jsx)(A,{open:!0,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(x,{children:[(0,W.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(_e,{className:i(`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,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.source}),(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.kind}),t?(0,W.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,W.jsx)(N,{className:`size-3`,"aria-hidden":!0}),a.installedBadge]}):null]}),(0,W.jsx)(te,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,W.jsx)(p,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]}),(0,W.jsx)(k,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(_,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),a.detailTools]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?X(a.connectorPreviewToolsCount,{count:c.toolCount}):a.connectorPreviewUnknown})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(le,{className:`size-3.5`,"aria-hidden":!0}),a.detailPermissions]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:Ze(e,a)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),a.connectorRequiredInputs]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:X(a.connectorRequiredInputsCount,{count:f})})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorCapabilitiesTitle}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[m.map(e=>(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:Ye(e,a)},e)),h>0?(0,W.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,h]}):null]}),(0,W.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:a.connectorCapabilitiesHint})]}),u?(0,W.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorPreviewTitle}),(0,W.jsx)(`span`,{className:i(`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?a.healthStatusHealthy:a.healthStatusLabels[c.status]??c.status})]}),(0,W.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.toolsMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.resourcesMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.promptsMetric})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)($e,{title:a.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,W.jsx)($e,{title:a.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,W.jsx)($e,{title:a.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??X(a.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,W.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,W.jsxs)(`aside`,{className:`space-y-3`,children:[(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(le,{className:`size-4 text-accent`,"aria-hidden":!0}),a.detailPermissions]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:Ze(e,a)})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(se,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorSetupTitle]}),v.length>0?(0,W.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:v.map(e=>(0,W.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,W.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,W.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:a.connectorSetupRequired}):null]}),e.description?(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:a.connectorSetupNone})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(R,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorRuntimeTitle]}),(0,W.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:Xe(e,a)})]})]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsx)(k,{asChild:!0,children:(0,W.jsx)(V,{variant:`secondary`,children:a.modalClose})}),(0,W.jsxs)(V,{variant:`secondary`,disabled:o,onClick:()=>void y(),children:[o?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(E,{className:`size-4`}),a.connectorPreviewButton]}),t?(0,W.jsxs)(V,{variant:`secondary`,disabled:!0,children:[(0,W.jsx)(g,{className:`size-4`}),a.installedBadge]}):(0,W.jsxs)(V,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,W.jsx)(w,{className:`size-4`}),a.install]})]})]})]})})}var nt=(0,H.memo)(function(e){let t=(0,U.c)(19),{loading:n,searchQuery:r,setSearchQuery:i,onReloadClick:a,onAddCustomServer:o,searchPlaceholder:s,addLabel:c,reloadLabel:l}=e,u;t[0]!==n||t[1]!==a||t[2]!==l?(u=(0,W.jsx)(F,{className:`size-9 shrink-0 p-0`,loading:n,label:l,title:l,onClick:a}),t[0]=n,t[1]=a,t[2]=l,t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,W.jsx)(I,{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[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i(e.currentTarget.value),t[5]=i,t[6]=f);let p;t[7]!==s||t[8]!==r||t[9]!==f?(p=(0,W.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,W.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:r,onChange:f,placeholder:s,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[7]=s,t[8]=r,t[9]=f,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,W.jsx)(re,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=m):m=t[11];let h;t[12]!==c||t[13]!==o?(h=(0,W.jsxs)(V,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:o,children:[m,c]}),t[12]=c,t[13]=o,t[14]=h):h=t[14];let g;return t[15]!==u||t[16]!==p||t[17]!==h?(g=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,p,h]}),t[15]=u,t[16]=p,t[17]=h,t[18]=g):g=t[18],g}),rt=/^([^:=]+)[:=](.*)$/;function it(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=rt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function at(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 ot(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 st(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 ct(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)||st(t)&&(r[e]=t);return r}function lt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function ut(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 dt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=lt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=ut(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=at(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function ft(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:ot(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function pt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function mt(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)||st(t)?[]:[ft(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 ht(e){return dt(e)}async function gt(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]=dt(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 s(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),z()}function _t(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 vt(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 yt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();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 bt(e,t){let n=await s(c(`/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=_t(n.payload.tools),i=vt(n.payload.resources),a=yt(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 xt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function St(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 Ct(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 Z(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function wt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),p=Ct(e),m=(0,H.useCallback)(async()=>{o(!0),f(null);try{let t=await bt(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]),h=(0,H.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,W.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,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,W.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,W.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,W.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,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:Z(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(V,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),t.testConnection]}),(0,W.jsxs)(V,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(ve,{className:`size-4`}),t.removeServer]})]})]})]})}function Tt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Et(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Tt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
|
|
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-BQ_8x0bT.js";import{t as a}from"./messages-DR9ODkb8.js";import{a as o,n as s,o as c}from"./fetch-6HXXdO77.js";import{n as l}from"./locale-store-Ba72bFmP.js";import{r as u}from"./toast-z0toXu32.js";import{$a as d,$r as f,Ba as p,Cc as m,Co as h,Cs as g,Do as _,El as v,Fr as y,Ga as b,Ha as x,Lr as S,Mr as C,Ms as w,Nr as T,Oo as E,Pr as D,Qr as O,Ra as k,Ua as A,Us as j,Va as ee,Vc as M,Wa as te,Xc as N,Zr as P,_c as ne,_i as F,bs as re,cs as I,ds as L,ei as ie,ho as ae,io as oe,jc as se,ma as ce,nc as le,ns as ue,os as R,pa as z,po as de,ro as fe,ti as pe,tl as me,to as he,vo as B,wo as V,xs as ge,za as _e,zo as ve}from"./index-DqFBdoK-.js";import{n as ye,t as be}from"./settings-form-section-GAwBG9Vp.js";import{t as xe}from"./page-tabs-smjfSAwc.js";var H=e(t(),1),U=n(),W=r(),G=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`,Se=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function Ce(e,t){return t.some(t=>t.connectorId===e.id)}function K(e,t){return t[e]??e}function q(e,t){return t.connectorCategoryTemplate.replace(`{{category}}`,K(e,t.connectorCategoryLabels))}function we(){let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.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,W.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-4 min-w-0 flex-1`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-[4.5rem] shrink-0 rounded-lg`,G)})]}),(0,W.jsx)(`div`,{className:i(`h-3 w-full`,G)}),(0,W.jsx)(`div`,{className:i(`h-3 w-[88%]`,G)})]})})}),e[0]=t):t=e[0],t}function Te(){let e=(0,U.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,W.jsx)(`div`,{className:i(`h-4 w-48 max-w-full`,G)}),(0,W.jsx)(`div`,{className:i(`h-3 w-72 max-w-full`,G)})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[t,(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,G)}),(0,W.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,G)})]})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,W.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[n,(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-8 w-20 rounded-md`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-24 rounded-md`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-28 rounded-md`,G)})]}),(0,W.jsx)(`div`,{className:i(`mt-3 h-20 rounded-xl`,G)})]}),e[2]=r):r=e[2],r}function Ee(e){let t=(0,U.c)(69),{connector:n,installed:r,onInstall:a,onOpenDetails:o,t:s}=e,c;t[0]!==n.category||t[1]!==s?(c=q(n.category,s),t[0]=n.category,t[1]=s,t[2]=c):c=t[2];let l=c,u,d,f,p,m,h,g,_,v,y;if(t[3]!==l||t[4]!==n||t[5]!==r||t[6]!==a||t[7]!==o||t[8]!==s.install||t[9]!==s.installedBadge){let e=n.capabilities.slice(0,4),c=Math.max(0,n.capabilities.length-e.length),b;t[20]!==n||t[21]!==a||t[22]!==s.install?(b=e=>(0,W.jsxs)(V,{type:`button`,variant:`primary`,className:i(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),a(n)},children:[(0,W.jsx)(w,{className:`size-4`}),s.install]}),t[20]=n,t[21]=a,t[22]=s.install,t[23]=b):b=t[23],u=b;let x;t[24]!==n||t[25]!==o?(x=e=>{!o||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o(n))},t[24]=n,t[25]=o,t[26]=x):x=t[26];let S=x,C=o?`cursor-pointer`:null;t[27]===C?g=t[28]:(g=i(`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`,C),t[27]=C,t[28]=g),_=o?`button`:void 0,v=o?0:void 0,t[29]!==n||t[30]!==o?(y=()=>o?.(n),t[29]=n,t[30]=o,t[31]=y):y=t[31],d=S,f=`flex min-w-0 flex-1 flex-col`;let T;t[32]===n.displayName?T=t[33]:(T=(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[32]=n.displayName,t[33]=T);let E;t[34]===l?E=t[35]:(E=(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:l}),t[34]=l,t[35]=E);let D;t[36]!==T||t[37]!==E?(D=(0,W.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[T,E]})}),t[36]=T,t[37]=E,t[38]=D):D=t[38];let O;t[39]!==r||t[40]!==u?(O=r?null:(0,W.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:u()}),t[39]=r,t[40]=u,t[41]=O):O=t[41];let k;t[42]!==r||t[43]!==s.installedBadge?(k=r?(0,W.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,W.jsx)(N,{className:`size-3`,"aria-hidden":!0}),s.installedBadge]}):null,t[42]=r,t[43]=s.installedBadge,t[44]=k):k=t[44];let A;t[45]!==O||t[46]!==k?(A=(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[O,k]}),t[45]=O,t[46]=k,t[47]=A):A=t[47],t[48]!==D||t[49]!==A?(p=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[D,A]}),t[48]=D,t[49]=A,t[50]=p):p=t[50],t[51]===n.description?m=t[52]:(m=(0,W.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[51]=n.description,t[52]=m),h=e.length>0?(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[e.map(J),c>0?(0,W.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,c]}):null]}):null,t[3]=l,t[4]=n,t[5]=r,t[6]=a,t[7]=o,t[8]=s.install,t[9]=s.installedBadge,t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g,t[17]=_,t[18]=v,t[19]=y}else u=t[10],d=t[11],f=t[12],p=t[13],m=t[14],h=t[15],g=t[16],_=t[17],v=t[18],y=t[19];let b;t[53]!==f||t[54]!==p||t[55]!==m||t[56]!==h?(b=(0,W.jsxs)(`div`,{className:f,children:[p,m,h]}),t[53]=f,t[54]=p,t[55]=m,t[56]=h,t[57]=b):b=t[57];let x;t[58]!==r||t[59]!==u?(x=r?null:(0,W.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:u(`w-full`)}),t[58]=r,t[59]=u,t[60]=x):x=t[60];let S;return t[61]!==d||t[62]!==b||t[63]!==x||t[64]!==g||t[65]!==_||t[66]!==v||t[67]!==y?(S=(0,W.jsxs)(`div`,{className:g,role:_,tabIndex:v,onClick:y,onKeyDown:d,children:[b,x]}),t[61]=d,t[62]=b,t[63]=x,t[64]=g,t[65]=_,t[66]=v,t[67]=y,t[68]=S):S=t[68],S}function J(e){return(0,W.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Y(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function De(){return Y(await s(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function Oe(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),Y(await s(c(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function ke(e,t){return Y(await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function Ae(e,t,n){let r=await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return z(),Y(r,`Could not install Store connector.`).instance}async function je(){return Y(await s(c(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function Me(){return Y(await s(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var Ne=new Map,Pe=300*1e3;async function Fe(e,t=`all`,n){let r=e.trim(),i=t.trim()||`all`,a=n?.browse??!1,o=Math.max(n?.page??1,1),l=Math.max(n?.pageSize??24,1),u=`${i}:${r}:${a?`browse`:`search`}:${o}:${l}`,d=Date.now(),f=Ne.get(u);if(f&&f.expiresAt>d)return f.promise;let p=new URLSearchParams;r&&p.set(`q`,r),i!==`all`&&p.set(`source`,i),a&&p.set(`browse`,`1`),p.set(`page`,String(o)),p.set(`pageSize`,String(l));let m=s(c(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Y(e,`Could not search connector registries.`),n=Math.max(0,...(t.results??[]).map(e=>e.totalPages??0))||void 0;return{connectors:t.connectors,totalPages:n}});Ne.set(u,{expiresAt:d+Pe,promise:m});try{return await m}catch(e){throw Ne.delete(u),e}}async function Ie(e){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Le(e,t){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Re(e,t){let n=await s(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return z(),Y(n,`Could not install connector.`).instance}async function ze(e,t={}){return Y(await s(c(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function Be(e,t){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function Ve(e){await s(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),z()}async function He(e){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function Ue(){return Y(await s(c(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function We(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/authorize`),{method:`POST`}),`Could not start Composio authorization.`).oauth}async function Ge(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function Ke(e,t){let n=await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return z(),Y(n,`Could not update Composio scope.`).scope}async function qe(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function Je(e=50){return Y(await s(c(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}function X(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function Ye(e,t){return t.connectorCapabilityLabels[e]??e}function Xe(e,t){if(e.runtime.type===`mcp`)return X(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.id??e.runtime.channelId??e.runtime.toolkit??e.runtime.toolsetId??e.runtime.sourceKind??e.runtime.type;return X(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n})}function Ze(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Qe(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function $e(e){let t=(0,U.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,W.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(et),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,W.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,W.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,W.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 et(e){return(0,W.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,W.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function tt({connector:e,installed:t,onClose:n,onInstall:r,t:a}){let[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),f=Qe(e),m=e.capabilities.slice(0,8),h=Math.max(0,e.capabilities.length-m.length),v=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:a.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:a.connectorSetupConfig}))],y=async()=>{s(!0),d(null);try{l(await ze(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,W.jsx)(A,{open:!0,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(x,{children:[(0,W.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(_e,{className:i(`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,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.source}),(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.kind}),t?(0,W.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,W.jsx)(N,{className:`size-3`,"aria-hidden":!0}),a.installedBadge]}):null]}),(0,W.jsx)(te,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,W.jsx)(p,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]}),(0,W.jsx)(k,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(_,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),a.detailTools]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?X(a.connectorPreviewToolsCount,{count:c.toolCount}):a.connectorPreviewUnknown})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(le,{className:`size-3.5`,"aria-hidden":!0}),a.detailPermissions]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:Ze(e,a)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),a.connectorRequiredInputs]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:X(a.connectorRequiredInputsCount,{count:f})})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorCapabilitiesTitle}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[m.map(e=>(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:Ye(e,a)},e)),h>0?(0,W.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,h]}):null]}),(0,W.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:a.connectorCapabilitiesHint})]}),u?(0,W.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorPreviewTitle}),(0,W.jsx)(`span`,{className:i(`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?a.healthStatusHealthy:a.healthStatusLabels[c.status]??c.status})]}),(0,W.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.toolsMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.resourcesMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.promptsMetric})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)($e,{title:a.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,W.jsx)($e,{title:a.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,W.jsx)($e,{title:a.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??X(a.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,W.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,W.jsxs)(`aside`,{className:`space-y-3`,children:[(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(le,{className:`size-4 text-accent`,"aria-hidden":!0}),a.detailPermissions]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:Ze(e,a)})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(se,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorSetupTitle]}),v.length>0?(0,W.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:v.map(e=>(0,W.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,W.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,W.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:a.connectorSetupRequired}):null]}),e.description?(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:a.connectorSetupNone})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(R,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorRuntimeTitle]}),(0,W.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:Xe(e,a)})]})]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsx)(k,{asChild:!0,children:(0,W.jsx)(V,{variant:`secondary`,children:a.modalClose})}),(0,W.jsxs)(V,{variant:`secondary`,disabled:o,onClick:()=>void y(),children:[o?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(E,{className:`size-4`}),a.connectorPreviewButton]}),t?(0,W.jsxs)(V,{variant:`secondary`,disabled:!0,children:[(0,W.jsx)(g,{className:`size-4`}),a.installedBadge]}):(0,W.jsxs)(V,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,W.jsx)(w,{className:`size-4`}),a.install]})]})]})]})})}var nt=(0,H.memo)(function(e){let t=(0,U.c)(19),{loading:n,searchQuery:r,setSearchQuery:i,onReloadClick:a,onAddCustomServer:o,searchPlaceholder:s,addLabel:c,reloadLabel:l}=e,u;t[0]!==n||t[1]!==a||t[2]!==l?(u=(0,W.jsx)(F,{className:`size-9 shrink-0 p-0`,loading:n,label:l,title:l,onClick:a}),t[0]=n,t[1]=a,t[2]=l,t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,W.jsx)(I,{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[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i(e.currentTarget.value),t[5]=i,t[6]=f);let p;t[7]!==s||t[8]!==r||t[9]!==f?(p=(0,W.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,W.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:r,onChange:f,placeholder:s,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[7]=s,t[8]=r,t[9]=f,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,W.jsx)(re,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=m):m=t[11];let h;t[12]!==c||t[13]!==o?(h=(0,W.jsxs)(V,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:o,children:[m,c]}),t[12]=c,t[13]=o,t[14]=h):h=t[14];let g;return t[15]!==u||t[16]!==p||t[17]!==h?(g=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,p,h]}),t[15]=u,t[16]=p,t[17]=h,t[18]=g):g=t[18],g}),rt=/^([^:=]+)[:=](.*)$/;function it(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=rt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function at(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 ot(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 st(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 ct(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)||st(t)&&(r[e]=t);return r}function lt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function ut(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 dt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=lt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=ut(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=at(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function ft(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:ot(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function pt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function mt(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)||st(t)?[]:[ft(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 ht(e){return dt(e)}async function gt(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]=dt(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 s(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),z()}function _t(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 vt(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 yt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();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 bt(e,t){let n=await s(c(`/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=_t(n.payload.tools),i=vt(n.payload.resources),a=yt(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 xt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function St(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 Ct(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 Z(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function wt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),p=Ct(e),m=(0,H.useCallback)(async()=>{o(!0),f(null);try{let t=await bt(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]),h=(0,H.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,W.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,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,W.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,W.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,W.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,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:Z(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(V,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),t.testConnection]}),(0,W.jsxs)(V,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(ve,{className:`size-4`}),t.removeServer]})]})]})]})}function Tt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Et(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Tt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
|
|
2
2
|
`).toLowerCase().includes(r)}function Dt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Ot(e){let t=(0,U.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:a,searchEmptyLabel:o}=e,[s,c]=(0,H.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>Et(e,s,r),t[4]=s,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=s,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===s?d=t[8]:(d=s.trim(),t[7]=s,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,W.jsx)(I,{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,g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,h),g=e=>c(e.target.value),t[10]=m,t[11]=g):(m=t[10],g=t[11]);let _;t[12]!==s||t[13]!==a?(_=(0,W.jsxs)(`div`,{className:`relative`,children:[p,(0,W.jsx)(`input`,{type:`search`,value:s,placeholder:a,"aria-label":a,className:m,onChange:g})]}),t[12]=s,t[13]=a,t[14]=_):_=t[14];let v;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(v=f?(0,W.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,W.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]!==o||t[24]!==r?(b=(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||Dt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,W.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,W.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]=o,t[24]=r,t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==b?(x=(0,W.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,U.c)(38),{open:n,onOpenChange:r,serverId:a,title:o,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:m}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,W.jsx)(ee,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,oe)}),t[0]=h):h=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(`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`,fe,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,W.jsx)(E,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=v):v=t[2];let y;t[3]===o?y=t[4]:(y=(0,W.jsxs)(te,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[v,o]}),t[3]=o,t[4]=y);let b;t[5]!==a||t[6]!==s||t[7]!==f.length?(b=s.replace(`{{serverId}}`,a).replace(`{{count}}`,String(f.length)),t[5]=a,t[6]=s,t[7]=f.length,t[8]=b):b=t[8];let S;t[9]===b?S=t[10]:(S=(0,W.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,W.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,W.jsx)(_,{className:`size-4`,"aria-hidden":!0}),t[14]=w):w=t[14];let T;t[15]===d?T=t[16]:(T=(0,W.jsx)(k,{asChild:!0,children:(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:w})}),t[15]=d,t[16]=T);let D;t[17]!==C||t[18]!==T?(D=(0,W.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]=D):D=t[19];let O;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==a||t[25]!==m||t[26]!==f?(O=f.length>0?(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,W.jsx)(Ot,{tools:f,stripPrefix:m,searchPlaceholder:c,searchEmptyLabel:l},`${a}-${n?`open`:`closed`}`)}):(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=a,t[25]=m,t[26]=f,t[27]=O):O=t[27];let j;t[28]===d?j=t[29]:(j=(0,W.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,W.jsx)(k,{asChild:!0,children:(0,W.jsx)(V,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=j);let M;t[30]!==D||t[31]!==O||t[32]!==j?(M=(0,W.jsxs)(x,{children:[h,(0,W.jsxs)(_e,{className:g,children:[D,O,j]})]}),t[30]=D,t[31]=O,t[32]=j,t[33]=M):M=t[33];let N;return t[34]!==r||t[35]!==n||t[36]!==M?(N=(0,W.jsx)(A,{open:n,onOpenChange:r,children:M}),t[34]=r,t[35]=n,t[36]=M,t[37]=N):N=t[37],N}var At=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,h);function jt(e){return e.materialized.type===`composio`?e.connectorId.replace(/^composio-/,``):null}function Mt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function Nt({instance:e,t}){let n=jt(e),[r,a]=(0,H.useState)([]),[o,s]=(0,H.useState)([]),[c,l]=(0,H.useState)([]),[u,f]=(0,H.useState)(`read`),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(null),_=(0,H.useCallback)(async()=>{if(!(!n||n===`api-key`)){m(!0),g(null);try{let[e,t,r,i]=await Promise.all([Ue().catch(()=>[]),qe(n).catch(()=>[]),Je(20).catch(()=>[]),Ge(n).catch(()=>`read`)]);a(e.filter(e=>e.toolkit.toLowerCase()===n.toLowerCase())),s(t),l(r.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===n.toLowerCase())),f(i)}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}}},[n]);(0,H.useEffect)(()=>{_()},[_]);let v=(0,H.useCallback)(async()=>{if(n){m(!0),g(null);try{let e=await We(n);window.open(e.connectUrl,`_blank`,`noopener,noreferrer`)}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}}},[n]),y=(0,H.useCallback)(async e=>{if(n){f(e);try{await Ke(n,e),await _()}catch(e){g(e instanceof Error?e.message:String(e))}}},[_,n]);return n?n===`api-key`?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,W.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:Z(t.composioToolkitTitle,{toolkit:n})}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsxs)(d,{className:i(At,`h-9 w-28 py-1`),value:u,onChange:e=>void y(e.currentTarget.value),children:[(0,W.jsx)(he,{value:`read`,children:t.composioScopeRead}),(0,W.jsx)(he,{value:`write`,children:t.composioScopeWrite}),(0,W.jsx)(he,{value:`admin`,children:t.composioScopeAdmin})]}),(0,W.jsxs)(V,{variant:`secondary`,disabled:p,onClick:()=>void v(),children:[p?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(le,{className:`size-4`}),t.connectOAuth]}),(0,W.jsx)(V,{variant:`ghost`,disabled:p,onClick:()=>void _(),children:t.refresh})]})]}),h?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h}):null,(0,W.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),r.length?r.map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.id}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.status})]},e.id)):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),o.length?o.slice(0,8).map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,W.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[Mt(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),c.length?c.slice(0,5).map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,W.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]}):null}var Pt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,h);function Ft(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function It(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 Lt(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 Rt(e){let t=(0,U.c)(12),{title:n,description:r,meta:a}=e,o;t[0]===r?o=t[1]:(o=r?(0,W.jsx)(f,{delayDuration:300,skipDelayDuration:100,children:(0,W.jsxs)(ie,{children:[(0,W.jsx)(pe,{asChild:!0,children:(0,W.jsx)(`p`,{tabIndex:0,title:r,className:i(`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,W.jsx)(O,{children:(0,W.jsx)(P,{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,W.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=o);let s=o,c;t[2]===n?c=t[3]:(c=(0,W.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]===a?l=t[5]:(l=a?(0,W.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:a}):null,t[4]=a,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,W.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]!==s||t[10]!==u?(d=(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,s]}),t[9]=s,t[10]=u,t[11]=d):d=t[11],d}function zt({instance:e,definition:t,onClose:n,onChanged:r,t:a,mcp:o}){let[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[h,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(`health`),[S,C]=(0,H.useState)(!1),[w,T]=(0,H.useState)(()=>It(t,e)),[D,O]=(0,H.useState)(null),M=t?.setup.config??[],N=e.materialized.type===`mcp`&&M.length>0&&(t?.setup.secrets??[]).length===0,P=h?h.toolCount:e.usage.lastToolCount,ne=(0,H.useMemo)(()=>{let t=[[`health`,ue,a.detailHealth],[`tools`,E,`${a.detailTools} ${h?h.toolCount:e.usage.lastToolCount??``}`],[`resources`,se,`${a.detailResources} ${h?h.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,m,`${a.detailPrompts} ${h?h.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,le,a.detailPermissions]];return N?[...t,[`config`,se,a.tabConfig]]:t},[h,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,N,a]),F=(0,H.useCallback)(async()=>{c(!0),O(null);try{let t=await He(e.instanceId);v(t),t.toolCount>0&&b(`tools`),r()}catch(e){O(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),re=(0,H.useCallback)(async()=>{u(!0),O(null);try{await Ve(e.instanceId),await r(),n()}catch(e){O(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),I=(0,H.useCallback)(async()=>{if(!(!t||!N)){f(!0),O(null);try{let n={};for(let e of t.setup.config??[]){let t=Lt(e.type,w[e.key]??``);t!==void 0&&(n[e.key]=t)}await Be(e.instanceId,{config:n}),await r(),b(`health`)}catch(e){O(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[w,t,e.instanceId,r,N]);return(0,W.jsxs)(A,{open:!0,onOpenChange:e=>{e||n()},children:[(0,W.jsxs)(x,{children:[(0,W.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(_e,{className:i(`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,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(te,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,W.jsx)(p,{className:`mt-1 text-sm text-fg-muted`,children:e.materialized.type===`mcp`?Z(a.mcpServerRuntime,{serverId:e.materialized.serverId}):Z(a.runtimeLabel,{runtime:e.materialized.type})})]}),(0,W.jsx)(k,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(_,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[D?(0,W.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D}):null,(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ne.map(([e,t,n])=>(0,W.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,y===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>b(e),children:[(0,W.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,W.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[y===`health`?(0,W.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,W.jsxs)(`p`,{children:[a.statusLabel,` `,(0,W.jsx)(`span`,{className:h?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:Ft(h?.status??e.usage.lastHealthStatus,a)})]}),(0,W.jsxs)(`p`,{children:[a.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():a.never]}),h?.action?(0,W.jsx)(`p`,{children:h.action}):null]}):null,y===`tools`?h?.tools.length?(0,W.jsxs)(`div`,{className:`grid gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Z(a.toolsAvailable,{count:String(h.tools.length)})}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>C(!0),children:o.viewAllTools})]}),(0,W.jsx)(`div`,{className:`grid gap-2`,children:h.tools.slice(0,8).map(e=>(0,W.jsx)(Rt,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`p`,{className:`text-fg-muted`,children:P?Z(a.toolsLastCheckSummary,{count:String(P)}):a.toolsRunTestHint}),(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void F(),children:[s?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),a.test]})]}):null,y===`resources`?h?.resources.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:h.resources.slice(0,8).map(e=>(0,W.jsx)(Rt,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,W.jsx)(`p`,{className:`text-fg-muted`,children:a.resourcesRunTestHint}):null,y===`prompts`?h?.prompts.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:h.prompts.slice(0,8).map(e=>(0,W.jsx)(Rt,{title:e.title??e.name,description:e.description,meta:e.argumentCount?Z(a.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,W.jsx)(`p`,{className:`text-fg-muted`,children:a.promptsRunTestHint}):null,y===`permissions`?(0,W.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,W.jsx)(`p`,{children:Z(a.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,W.jsx)(`p`,{children:e.materialized.type===`mcp`?Z(a.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):Z(a.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,W.jsx)(`p`,{children:e.materialized.type===`mcp`?a.mcpPolicyHint:a.connectorPolicyHint})]}):null,y===`config`&&N?(0,W.jsx)(`div`,{className:`grid gap-3`,children:M.map(e=>(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,W.jsx)(`input`,{className:Pt,value:w[e.key]??``,placeholder:e.placeholder,onChange:t=>T(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,W.jsx)(Nt,{instance:e,t:a}):null]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsx)(V,{variant:`secondary`,onClick:n,children:a.modalClose}),y===`config`&&N?(0,W.jsxs)(V,{variant:`primary`,disabled:d,onClick:()=>void I(),children:[d?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(L,{className:`size-4`}),a.modalSave]}):null,e.materialized.type===`mcp`?(0,W.jsxs)(V,{variant:`secondary`,disabled:s,onClick:()=>void F(),children:[s?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),a.test]}):null,(0,W.jsxs)(V,{variant:`ghost`,disabled:l,onClick:()=>void re(),children:[l?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(ve,{className:`size-4`}),a.remove]})]})]})]}),e.materialized.type===`mcp`?(0,W.jsx)(kt,{open:S,onOpenChange:C,serverId:e.materialized.serverId,title:Z(a.installedToolsDialogTitle,{name:e.displayName}),subtitle:a.installedToolsDialogSubtitle,searchPlaceholder:o.toolsDialogSearchPlaceholder,searchEmptyLabel:o.toolsDialogSearchEmpty,emptyLabel:a.toolsRunTestHint,closeLabel:o.toolsDialogClose,tools:h?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}function Bt({instance:e,definition:t,onOpenDetails:n,onChanged:r,t:i}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),d=(0,H.useCallback)(async()=>{o(!0),u(null);try{await He(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.instanceId,r]),f=(0,H.useCallback)(async()=>{c(!0),u(null);try{await Ve(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e)),c(!1)}},[e.instanceId,r]),p=e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:i.healthNotTested,m=e.usage.lastToolCount??0,h=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`);return(0,W.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:()=>n(e),children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,W.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,W.jsx)(N,{className:`size-3`,"aria-hidden":!0}),i.installedBadge]}),h?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:i.tabConfig}):null]}),(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all text-sm leading-5 text-fg-muted`,children:e.materialized.type===`mcp`?Z(i.mcpServerRuntime,{serverId:e.materialized.serverId}):Z(i.runtimeLabel,{runtime:e.materialized.type})}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,W.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[i.statusLabel,` `,p]}),(0,W.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:Z(i.toolsAvailable,{count:String(m)})})]}),l?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:l}):null]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:i.connectorDetails}),(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[e.materialized.type===`mcp`?(0,W.jsxs)(V,{variant:`secondary`,disabled:a,onClick:()=>void d(),children:[a?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),i.test]}):null,(0,W.jsxs)(V,{variant:`ghost`,disabled:s,onClick:()=>void f(),children:[s?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(ve,{className:`size-4`}),i.remove]})]})]})]})}var Vt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,h),Ht=i(Vt,`min-h-28 font-mono`);function Ut(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function Wt(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 Gt(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,oauth:{flow:null,connected:e.auth.mode!==`oauth`},...t?{store:t}:{}}}function Kt(e){let t=(0,U.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,W.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(qt),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,W.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,W.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,W.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 qt(e){return(0,W.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,W.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,W.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Jt({draft:e,onChange:t,onClose:n,onInstalled:r,t:a}){let{connector:o}=e,s=e.result?`complete`:e.installing?`health`:`configure`,c=[{id:`configure`,label:a.installStepConfigure},{id:`health`,label:a.installStepHealth},{id:`complete`,label:a.installStepComplete}],l=(0,H.useCallback)(async()=>{t({...e,installing:!0,error:null});try{let n=await Ie(o.id);window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),t({...e,installing:!1,error:null,oauth:{flow:n,connected:!1}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o.id,e,t]),u=(0,H.useCallback)(async()=>{if(e.oauth.flow){t({...e,installing:!0,error:null});try{await Le(o.id,e.oauth.flow.deviceCode),t({...e,installing:!1,error:null,oauth:{...e.oauth,connected:!0}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}}},[o.id,e,t]),d=(0,H.useCallback)(async()=>{t({...e,installing:!0,error:null,result:null,health:null});try{if(o.auth.mode===`oauth`&&!e.oauth.connected)throw Error(a.oauthRequiredBeforeInstall);let n={};for(let t of o.setup.config??[]){let r=Wt(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let i=e.store?await Ae(e.store.packageName,{secrets:e.secrets,config:n},e.store.version):await Re(o.id,{secrets:e.secrets,config:n,definition:o.source===`registry`?o:void 0}),s=null;try{s=await He(i.instanceId)}catch{s=null}t({...e,installing:!1,result:i,health:s}),await r()}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o,e,t,r,a.oauthRequiredBeforeInstall]);return(0,W.jsx)(A,{open:!0,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(x,{children:[(0,W.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(_e,{className:i(`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,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(te,{className:`text-base font-semibold text-fg`,children:Z(a.installDialogTitle,{name:o.displayName})}),(0,W.jsx)(p,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:o.description})]}),(0,W.jsx)(k,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(_,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,W.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":a.installProgressAria,children:c.map((e,t)=>{let n=c.findIndex(e=>e.id===s);return(0,W.jsxs)(`div`,{className:i(`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,W.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.auth.mode===`oauth`?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:a.oauthTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.oauthHint}),e.oauth.flow?(0,W.jsxs)(`div`,{className:`mt-3 rounded-xl bg-surface-base p-3 text-sm text-fg-muted`,children:[(0,W.jsx)(`p`,{children:Z(a.oauthOpenCodePrefix,{url:e.oauth.flow.verificationUri})}),(0,W.jsx)(`p`,{className:`mt-2 font-mono text-lg font-semibold tracking-widest text-fg`,children:e.oauth.flow.userCode})]}):null,e.oauth.connected?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700`,children:a.oauthConnected}):null,(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,W.jsxs)(V,{variant:`secondary`,disabled:e.installing,onClick:()=>void l(),children:[e.installing&&!e.oauth.flow?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),a.oauthConnectButton]}),(0,W.jsxs)(V,{variant:`primary`,disabled:e.installing||!e.oauth.flow,onClick:()=>void u(),children:[e.installing&&e.oauth.flow?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(N,{className:`size-4`}),a.oauthAuthorizedButton]})]})]}):null,e.store?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailPermissions}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,W.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,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,W.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:a.storeLocalExecDenied})]})]}):null,(o.setup.secrets??[]).map(n=>(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,W.jsx)(de,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:a.secretInputLabels,placeholder:n.required?a.requiredPlaceholder:a.optionalPlaceholder})]},n.key)),(o.setup.config??[]).map(n=>(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,W.jsx)(`textarea`,{className:Ht,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,W.jsx)(`input`,{className:Vt,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,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,W.jsx)(j,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),a.installingTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.installingHint})]}):null,e.error?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,e.result?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:Z(a.installedAs,{target:e.result.materialized.type===`mcp`?e.result.materialized.serverId:e.result.instanceId})}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:Z(a.runtimeLabel,{runtime:e.result.materialized.type.toUpperCase()})})]}),(0,W.jsx)(`span`,{className:i(`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?a.healthStatusHealthy:Ut(e.health?.status,a)})]}),e.health?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,W.jsx)(`div`,{children:a.toolsMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,W.jsx)(`div`,{children:a.resourcesMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,W.jsx)(`div`,{children:a.promptsMetric})]})]}),(0,W.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,W.jsx)(Kt,{title:a.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,W.jsx)(Kt,{title:a.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,W.jsx)(Kt,{title:a.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??Z(a.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,W.jsx)(`p`,{className:`mt-3`,children:a.installedWithoutHealth}),e.health?.action?(0,W.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,W.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,W.jsxs)(V,{variant:`primary`,disabled:!!e.result||e.installing||o.auth.mode===`oauth`&&!e.oauth.connected,onClick:()=>void d(),children:[e.installing?(0,W.jsx)(j,{className:`size-4 animate-spin`}):e.result?(0,W.jsx)(N,{className:`size-4`}):(0,W.jsx)(w,{className:`size-4`}),e.result?a.installedBadge:a.install]})})]})]})})}function Yt(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 pt(r)}function Xt(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 Zt(e,t,n){return e.filter(e=>Xt(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Qt(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 $t(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function en(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 tn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,h)}function nn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:a,pasteFailed:o,keyPlaceholder:s,valuePlaceholder:c,headers:l,onChange:u}){let d=(e,t)=>{u(l.map((n,r)=>r===e?{...n,...t}:n))},f=()=>{u([...l,{key:``,value:``}])},p=e=>{let t=l.filter((t,n)=>n!==e);u(t.length>0?t:[{key:``,value:``}])},m=async()=>{try{let e=await ae();if(!e){window.alert(o);return}let t=it(e);if(!t?.length){window.alert(o);return}u(t)}catch{window.alert(o)}};return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,W.jsx)(`span`,{children:e}),t?(0,W.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void m(),children:[(0,W.jsx)(M,{className:`size-3.5`,"aria-hidden":!0}),a]})]}),(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{className:i(tn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:s,onChange:e=>d(t,{key:e.target.value})}),(0,W.jsx)(`input`,{className:i(tn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:c,onChange:e=>d(t,{value:e.target.value})}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:l.length<=1&&!e.key&&!e.value,onClick:()=>p(t),"aria-label":r,children:(0,W.jsx)(ve,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},en(e,t,l)))}),(0,W.jsxs)(`button`,{type:`button`,className:i(`self-start text-sm text-accent hover:underline`,B.press),onClick:f,children:[`+ `,n]})]})}var rn=[`stdio`,`sse`,`streamable-http`];function Q(e){let t=(0,U.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,W.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,W.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,W.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,W.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 $(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,h)}function an(e){let t=(0,U.c)(29),{row:n,t:r,onUpdate:a,idConflictMessage:o,variant:s}=e,c=s===void 0?`all`:s,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,f;t[0]!==o||t[1]!==a||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(f=l?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Q,{label:r.transportLabel,required:!0,children:(0,W.jsx)(d,{className:$(),value:n.transport,onChange:e=>a({transport:e.target.value}),children:rn.map(e=>(0,W.jsx)(he,{value:e,children:r.transportLabels[e]},e))})}),(0,W.jsxs)(Q,{label:r.serverIdLabel,required:!0,children:[(0,W.jsx)(`input`,{className:$(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>a({id:e.target.value})}),o?(0,W.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:o}):null]})]}):null,t[0]=o,t[1]=a,t[2]=n.id,t[3]=n.transport,t[4]=l,t[5]=r,t[6]=f):f=t[6];let p;t[7]!==a||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?(p=n.transport===`stdio`?(0,W.jsxs)(W.Fragment,{children:[l?(0,W.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,W.jsx)(Q,{label:r.commandLabel,required:!0,children:(0,W.jsx)(`input`,{className:$(),value:n.command,onChange:e=>a({command:e.target.value})})})}):null,u?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Q,{label:r.argsLabel,description:r.argsHint,children:(0,W.jsx)(`input`,{className:$(),value:n.argsText,onChange:e=>a({argsText:e.target.value})})}),(0,W.jsx)(Q,{label:r.cwdLabel,children:(0,W.jsx)(`input`,{className:$(),value:n.cwd,onChange:e=>a({cwd:e.target.value})})}),(0,W.jsx)(Q,{label:r.envLabel,description:r.envHint,children:(0,W.jsx)(`textarea`,{className:i($(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>a({envJson:e.target.value})})})]}):null]}):(0,W.jsxs)(W.Fragment,{children:[l?(0,W.jsx)(`div`,{className:`md:col-span-2`,children:(0,W.jsx)(Q,{label:r.urlLabel,required:!0,children:(0,W.jsx)(`input`,{className:i($(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>a({url:e.target.value})})})}):null,u?(0,W.jsx)(nn,{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=>a({headers:e})}):null]}),t[7]=a,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]=p):p=t[19];let m;t[20]!==a||t[21]!==n||t[22]!==u||t[23]!==r?(m=u?(0,W.jsx)(Q,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,W.jsx)(`input`,{type:`number`,min:1,max:600,className:$(),value:xt(n),placeholder:r.timeoutPlaceholder,onChange:e=>a({connectionTimeoutMs:St(e.target.value)})})}):null,t[20]=a,t[21]=n,t[22]=u,t[23]=r,t[24]=m):m=t[24];let h;return t[25]!==f||t[26]!==p||t[27]!==m?(h=(0,W.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[f,p,m]}),t[25]=f,t[26]=p,t[27]=m,t[28]=h):h=t[28],h}function on(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 sn(e){let t=(0,U.c)(13),{tool:n,serverId:r}=e,a;t[0]!==r||t[1]!==n?(a=on(n,r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s=n.name===o?o: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]!==o||t[6]!==s?(u=(0,W.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:s,children:o}),t[5]=o,t[6]=s,t[7]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,W.jsx)(f,{delayDuration:300,skipDelayDuration:100,children:(0,W.jsxs)(ie,{children:[(0,W.jsx)(pe,{asChild:!0,children:(0,W.jsx)(`p`,{tabIndex:0,title:l,className:i(`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,W.jsx)(O,{children:(0,W.jsx)(P,{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,W.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let p;return t[10]!==u||t[11]!==d?(p=(0,W.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]=p):p=t[12],p}function cn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:a,config:o,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:d}){let[f,m]=(0,H.useState)(n),[h,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(!1),[S,C]=(0,H.useState)(null),[w,T]=(0,H.useState)(!1),[D,O]=(0,H.useState)({status:`idle`}),[M,P]=(0,H.useState)(null),ne=n.id.trim(),F=f.id.trim()!==ne&&s.has(f.id.trim())||s.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,re=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,I=f.id.trim().length>0&&!F&&!re&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),L=Ct(f),ie=(0,H.useCallback)(async()=>{if(f.id.trim()){b(!0),C(null),O({status:`loading`});try{O({status:`ok`,tools:(await bt(f.id.trim(),ht(f))).tools})}catch(e){O({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{b(!1)}}},[f]),ae=(0,H.useCallback)(async()=>{if(!(!I||h)){v(!0),C(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await gt({sessionIdleTtlMinutes:a,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},ct(o)),await d(),u()}catch(e){C(e instanceof Error?e.message:String(e))}finally{v(!1)}}},[I,o,r,n.clientKey,t,u,d,ne,f,h,a]);return e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(A,{open:e,onOpenChange:e=>{e||u()},children:(0,W.jsxs)(x,{children:[(0,W.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(_e,{className:i(`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,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(te,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,W.jsx)(p,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,W.jsx)(k,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.focusRingPanel),"aria-label":l.modalClose,children:[(0,W.jsx)(_,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(R,{className:`size-4 text-accent`,"aria-hidden":!0}),f.id.trim()||c.cardUntitled]}),(0,W.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:L||(f.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,W.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,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,W.jsx)(an,{row:f,t:c,variant:`basic`,onUpdate:e=>{m(t=>({...t,...e})),C(null)},idConflictMessage:F??re})]}),D.status===`ok`?(0,W.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,W.jsx)(E,{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,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>P(D.tools),children:c.viewAllTools}):null]}),D.tools.length>0?(0,W.jsx)(`div`,{className:`mt-3 grid gap-2`,children:D.tools.slice(0,6).map((e,t)=>(0,W.jsx)(sn,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,D.status===`error`?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D.message}):null,S?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S}):null,(0,W.jsxs)(`details`,{open:w,onToggle:e=>T(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,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 hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(me,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,W.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,W.jsx)(`div`,{className:`border-t border-edge px-4 py-4`,children:(0,W.jsx)(an,{row:f,t:c,variant:`advanced`,onUpdate:e=>{m(t=>({...t,...e})),C(null)}})})]})]})}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsxs)(V,{variant:`secondary`,disabled:!f.id.trim()||y,onClick:()=>void ie(),children:[y?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),c.testConnection]}),(0,W.jsx)(k,{asChild:!0,children:(0,W.jsx)(V,{variant:`secondary`,children:l.modalCancel})}),(0,W.jsxs)(V,{variant:`primary`,disabled:!I||h,onClick:()=>void ae(),children:[h?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(N,{className:`size-4`}),h?c.saving:l.modalSave]})]})]})]})}),M?(0,W.jsx)(kt,{open:!0,onOpenChange:e=>{e||P(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:M,stripPrefix:`${f.id.trim()}__`}):null]}):null}var ln=`mprov`,un=`xopc-store`,dn=un,fn=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,h);function pn(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 mn(){let e=a(l(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=o(e=>e.token),s=!!r,[c,d]=v(),f=c.get(ln)?.trim()||dn,[p,m]=(0,H.useState)(`marketplace`),[h,g]=(0,H.useState)({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!0,error:null}),[_,x]=(0,H.useState)(!1),[w,E]=(0,H.useState)(!1),[O,k]=(0,H.useState)(1),[A,ee]=(0,H.useState)(void 0),[M,te]=(0,H.useState)(``),[N,P]=(0,H.useState)(f),[F,re]=(0,H.useState)(`name`),[I,L]=(0,H.useState)(null),[ie,ae]=(0,H.useState)(null),[oe,se]=(0,H.useState)(null),[le,ue]=(0,H.useState)(null),[R,z]=(0,H.useState)(null),[de,fe]=(0,H.useState)(void 0),[pe,he]=(0,H.useState)(!1),[_e,ve]=(0,H.useState)(!1),{data:U,mutate:G}=ce(s),K=U?.payload?.config,q=(0,H.useMemo)(()=>K===void 0?null:mt(K),[K]),J=q?.servers??[];(0,H.useEffect)(()=>{q&&fe(q.sessionIdleTtlMinutes)},[q]);let Y=(0,H.useCallback)(async()=>{if(!r){g({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:null});return}g(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([De(),Me(),je()]);g(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,registries:n,loading:!1,error:null}))}catch(e){g({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,H.useEffect)(()=>{Y()},[Y]);let Ae=c.toString(),Ne=(0,H.useRef)(Ae);(0,H.useEffect)(()=>{Ne.current!==Ae&&(Ne.current=Ae,P(c.get(ln)?.trim()||dn))},[c,Ae]);let Pe=(0,H.useMemo)(()=>[{id:un,displayName:t.storeSourceName},...h.registries],[t.storeSourceName,h.registries]);(0,H.useEffect)(()=>{if(Pe.length===0||Pe.some(e=>e.id===N))return;let e=Pe.some(e=>e.id===dn)?dn:Pe[0]?.id;e&&P(e)},[Pe,N]),(0,H.useEffect)(()=>{if(!N||N===c.get(ln))return;let e=new URLSearchParams(c);e.set(ln,N),Ne.current=e.toString(),d(e,{replace:!0})},[N,c,d]);let Ie=(0,H.useCallback)(async e=>{let t=M.trim(),n=e?.browse??!1,r=Math.max(e?.page??1,1),i=e?.append??!1;if(!(!s||N!==un&&!t&&!n)){x(!0),i?g(e=>({...e,error:null})):(k(1),ee(void 0),g(e=>({...e,registryCatalog:[],error:null})));try{let e=N===un?await Oe({q:t||void 0,page:r,pageSize:24,sort:F===`source`?`newest`:`downloads`}).then(e=>({connectors:e.items.map(pn),totalPages:e.meta.totalPages})):await Fe(t,N,{browse:n,page:r});k(r),ee(e.totalPages),g(t=>({...t,registryCatalog:i?[...t.registryCatalog,...e.connectors].filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t):e.connectors}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{x(!1)}}},[F,s,M,N]);(0,H.useEffect)(()=>{if(p!==`marketplace`)return;let e=window.setTimeout(()=>{M.trim()?Ie():N&&Ie({browse:!0})},M.trim()?350:0);return()=>window.clearTimeout(e)},[N,M,Ie,h.loading,p]);let Le=(0,H.useMemo)(()=>new Set(h.instances.map(e=>e.connectorId)),[h.instances]),Re=(0,H.useMemo)(()=>new Map([...h.catalog,...h.registryCatalog].map(e=>[e.id,e])),[h.catalog,h.registryCatalog]),ze=(0,H.useCallback)(async e=>{E(!0),g(e=>({...e,error:null}));try{let n=await ke(e);if(n.requiresOAuth&&n.definition.id!==`github`)throw Error(t.storeOAuthUnsupported);L(Gt(n.definition,{packageName:n.packageName,version:n.version,permissions:n.permissions}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{E(!1)}},[t.storeOAuthUnsupported]),Be=(0,H.useMemo)(()=>new Set(h.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[h.instances]),Ve=(0,H.useCallback)(async e=>{if(!q||K===void 0)return;let t=J.filter(t=>t.clientKey!==e.clientKey);await gt({sessionIdleTtlMinutes:q.sessionIdleTtlMinutes,servers:t},ct(K)),await G(),await Y()},[K,J,Y,q,G]),He=(0,H.useCallback)(()=>{z({mode:`add`,row:Yt(J,Be)})},[J,Be]),Ue=(0,H.useCallback)(async()=>{if(!(!q||K===void 0||pe)){he(!0),ve(!1);try{await gt({sessionIdleTtlMinutes:de,servers:J},ct(K)),await G(),ve(!0),u({type:`success`,title:n.saved})}finally{he(!1)}}},[K,J,q,G,de,pe]),We=b(e=>e.setPageHeader),Ge=b(e=>e.clearPageHeader),Ke=(0,H.useMemo)(()=>(0,W.jsx)(nt,{loading:h.loading||_||w,searchQuery:M,setSearchQuery:te,onReloadClick:Y,onAddCustomServer:He,searchPlaceholder:p===`marketplace`?t.marketplaceSearchPlaceholder:p===`builtin`?t.builtinSearchPlaceholder:p===`user`?t.userSearchPlaceholder:t.configSearchPlaceholder,addLabel:t.addCustomServer,reloadLabel:t.reload}),[t,Y,He,_,M,h.loading,w,p]);(0,H.useLayoutEffect)(()=>(We({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.title})}),end:Ke}),()=>Ge()),[Ge,t.title,Ke,We]);let qe=h.instances.length+J.length,Je=(0,H.useMemo)(()=>Zt(h.catalog.filter(e=>e.source===`builtin`),M,F),[F,M,h.catalog]),X=(0,H.useMemo)(()=>Zt(h.registryCatalog,M,F),[F,M,h.registryCatalog]),Ye=p===`marketplace`&&!!(A&&O<A),Xe=(0,H.useMemo)(()=>h.instances.filter(e=>Qt(e,M)),[M,h.instances]),Ze=(0,H.useMemo)(()=>J.filter(e=>$t(e,M)),[J,M]),Qe=(0,H.useMemo)(()=>h.instances.find(e=>e.instanceId===oe)??le,[oe,le,h.instances]),$e=Xe.length+Ze.length,et=[{id:`marketplace`,label:t.tabMarketplace},{id:`builtin`,label:t.tabBuiltin,count:Je.length},{id:`user`,label:t.tabUser,count:qe},{id:`config`,label:t.tabConfig}];return(0,W.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,W.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[s?null:(0,W.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,W.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,W.jsx)(xe,{items:et,activeTab:p,onChange:m,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`}),(0,W.jsxs)(`div`,{className:`flex min-h-9 min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[p===`marketplace`?(0,W.jsx)(`div`,{className:`inline-flex h-9 max-w-full shrink-0 overflow-x-auto rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,role:`group`,"aria-label":t.registrySourceAria,children:Pe.map(e=>(0,W.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,B.focusRingPanel,N===e.id?`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`:`text-fg-muted hover:text-fg`),"aria-pressed":N===e.id,onClick:()=>P(e.id),children:e.displayName},e.id))}):null,p!==`user`&&p!==`config`?(0,W.jsxs)(y,{children:[(0,W.jsx)(S,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,B.transition,B.focusRingPanel),children:[(0,W.jsx)(ne,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:F===`name`?t.sortName:t.sortSource}),(0,W.jsx)(me,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,W.jsx)(D,{children:(0,W.jsxs)(C,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,W.jsx)(T,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>re(`name`),children:t.sortName}),(0,W.jsx)(T,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>re(`source`),children:t.sortSource})]})})]}):null]})]}),h.error?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h.error}):null,p===`user`&&s?(0,W.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.installedTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.installedHint})]}),h.loading?(0,W.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:Se.slice(0,3).map(e=>(0,W.jsx)(Te,{},e))}):qe===0||$e===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:qe===0?t.installedEmpty:t.userEmpty}):(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[Xe.map(e=>(0,W.jsx)(Bt,{instance:e,definition:Re.get(e.connectorId),onOpenDetails:e=>{se(e.instanceId),ue(e)},onChanged:Y,t},e.instanceId)),Ze.map(e=>(0,W.jsx)(wt,{row:e,t:n,cs:t,onEdit:()=>z({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Ve(e)},e.clientKey))]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,p===`config`&&s?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,W.jsxs)(be,{children:[(0,W.jsx)(ye,{icon:ge,title:n.globalTitle,subtitle:n.globalHint}),(0,W.jsx)(`div`,{className:`max-w-xl`,children:(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.idleTtlLabel}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`number`,min:0,className:i(fn,`w-40 flex-none`),value:de??``,placeholder:n.idleTtlPlaceholder,onChange:e=>{let t=e.target.value.trim();fe(t===``?void 0:Number.parseInt(t,10)),ve(!1)}}),(0,W.jsxs)(V,{variant:`secondary`,disabled:pe,onClick:()=>void Ue(),children:[pe?(0,W.jsx)(j,{className:`size-4 animate-spin`}):null,n.save]})]}),(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.idleTtlHint})]})})]})}):null,p===`marketplace`&&s?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:_&&X.length===0?(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:Se.map(e=>(0,W.jsx)(we,{},e))}):M.trim()&&X.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}):!M.trim()&&X.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceStartHint}):(0,W.jsxs)(`div`,{className:`relative`,children:[_?(0,W.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,W.jsx)(j,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:X.map(e=>(0,W.jsx)(Ee,{connector:e,installed:Le.has(e.id)||Ce(e,h.instances),onInstall:e=>{if(e.source===`store`){ze(e.id);return}L(Gt(e))},onOpenDetails:e.source===`store`?void 0:ae,t},e.id))}),Ye?(0,W.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:_||w,onClick:()=>void Ie({browse:!M.trim(),page:O+1,append:!0}),children:[_?(0,W.jsx)(j,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})}):null,p===`builtin`&&s?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:h.loading?(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:Se.map(e=>(0,W.jsx)(we,{},e))}):Je.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.builtinEmpty}):(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Je.map(e=>(0,W.jsx)(Ee,{connector:e,installed:Le.has(e.id)||Ce(e,h.instances),onInstall:e=>L(Gt(e)),onOpenDetails:ae,t},e.id))})}):null]}),I?(0,W.jsx)(Jt,{draft:I,onChange:L,onClose:()=>L(null),t,onInstalled:async()=>{await Y(),await G(),m(`user`)}}):null,ie?(0,W.jsx)(tt,{connector:ie,installed:Le.has(ie.id)||Ce(ie,h.instances),onClose:()=>ae(null),onInstall:e=>L(Gt(e)),t}):null,Qe?(0,W.jsx)(zt,{instance:Qe,definition:Re.get(Qe.connectorId),onClose:()=>{se(null),ue(null)},onChanged:Y,t,mcp:n}):null,R?(0,W.jsx)(cn,{open:!0,mode:R.mode,initialRow:R.row,existingCustomServers:J,sessionIdleTtlMinutes:de,config:K,managedServerIds:Be,t:n,cs:t,onClose:()=>z(null),onSaved:async()=>{await G(),await Y(),m(`user`)}},`${R.mode}-${R.row.clientKey}`):null]})})}export{mn as ConnectorsPage};
|
|
@@ -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"./messages-
|
|
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"./messages-DR9ODkb8.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{Do as o,tl as s}from"./index-DqFBdoK-.js";import{t as c}from"./desktop-pet-sprite-DqZ6fbIj.js";var l=e(t(),1),u=n();function d(e){return e?`/chat/${e.sessionKey}`:void 0}var f=r(),p=8e3;function m(e){let t={error:0,waiting:1,running:2,success:3};return e.sort((e,n)=>t[e.state]-t[n.state]||n.timestamp-e.timestamp).slice(0,3)}function h(){return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`ember`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,feedbackLevel:`normal`,sizePercent:100,collapsed:!1},pets:[],visible:!0,customPetsDir:``,petIssues:[]}}function g(){let e=i(a(e=>e.language)).desktopPet,[t,n]=(0,l.useState)(h),[r,u]=(0,l.useState)({}),[g,_]=(0,l.useState)(()=>new Set),[v,y]=(0,l.useState)(Date.now()),b=(0,l.useRef)(null),x=(0,l.useRef)(!1),S=(0,l.useRef)(null),C=(0,l.useRef)(null),w=(0,l.useRef)(null),T=(0,l.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),E=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),D=(0,l.useMemo)(()=>m(Object.values(r).filter(e=>!e.expiresAt||e.expiresAt>v)),[r,v]),O=(0,l.useMemo)(()=>D.filter(e=>!g.has(e.sessionKey)),[D,g]),k=O[0],A=k?.state===`error`?`error`:k?.state===`success`?`success`:k?`typing`:`idle`;(0,l.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;e.getState().then(n).catch(()=>{});let t=e.onStateChanged(n),r=e.onEvent(e=>u(t=>{let n=t[e.sessionKey];return n&&e.sequence<=n.sequence?t:{...t,[e.sessionKey]:{...n,...e,outputLines:e.outputLines??n?.outputLines,expiresAt:e.state===`success`?Date.now()+p:void 0}}})),i=window.setInterval(()=>y(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,t(),r(),window.clearInterval(i)}},[]),(0,l.useLayoutEffect)(()=>{let e=S.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[C.current,w.current].filter(e=>e!==null).map(e=>e.getBoundingClientRect());if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom));t.setContentSize({width:Math.ceil(i-n),height:Math.ceil(a-r)})},r=new ResizeObserver(n);return r.observe(e),C.current&&r.observe(C.current),w.current&&r.observe(w.current),n(),()=>r.disconnect()},[O.length,t.prefs.collapsed,E]);let j=(e=k)=>{e?.state===`success`&&u(t=>{let{[e.sessionKey]:n,...r}=t;return r}),window.electronAPI?.pet?.openMainWindow(d(e))},M=async()=>{if(g.size>0&&(_(new Set),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},N=(0,l.useCallback)(e=>{e.button===0&&(b.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),P=(0,l.useCallback)(e=>{let t=b.current;!t||t.pointerId!==e.pointerId||Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4&&(t.moved=!0,window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),F=(0,l.useCallback)(e=>{let t=b.current;!t||t.pointerId!==e.pointerId||(b.current=null,window.electronAPI?.pet?.endDrag(),t.moved&&(x.current=!0,window.setTimeout(()=>{x.current=!1},0)))},[]);return T?(0,f.jsxs)(`div`,{ref:S,className:`desktop-pet-window`,style:{"--desktop-pet-stage-size":`${Math.round(132*E)}px`,"--desktop-pet-menu-size":`${Math.round(28*E)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*E)}px`},children:[!t.prefs.collapsed&&O.length>0?(0,f.jsx)(`div`,{ref:C,className:`desktop-pet-bubble desktop-pet-queue`,children:O.map(e=>(0,f.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${e.state}`,children:[(0,f.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>j(e),children:[(0,f.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,f.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,f.jsx)(`strong`,{children:e.sessionLabel}),(0,f.jsxs)(`span`,{children:[e.action,e.detail?`:${e.detail}`:e.progress?` · ${e.progress.completed}/${e.progress.total}`:e.outputLines?.length?`:${e.outputLines[Math.floor((v-e.timestamp)/1800)%e.outputLines.length]}`:e.outputTail?`:${e.outputTail}`:e.state===`running`?` · ${Math.max(1,Math.floor((v-e.timestamp)/1e3))}s`:``]})]})]}),(0,f.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":`收起会话`,onClick:()=>_(t=>new Set(t).add(e.sessionKey)),children:(0,f.jsx)(o,{size:12})})]},e.sessionKey))}):null,(0,f.jsxs)(`div`,{ref:w,className:`desktop-pet-stage`,children:[(0,f.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void M(),"aria-label":e.menu,children:(t.prefs.collapsed?D.length:g.size)>0?(0,f.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,t.prefs.collapsed?D.length:g.size)}):(0,f.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,f.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:()=>{x.current||j()},onPointerDown:N,onPointerMove:P,onPointerUp:F,onPointerCancel:F,title:e.openApp,children:(0,f.jsx)(c,{pet:T,action:A,displayHeight:Math.round(112*E)})})]})]}):null}function _(){let e=(0,u.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(g,{}),e[0]=t):t=e[0],t}export{_ as DesktopPetPage};
|