@xopcai/xopc 0.0.307 → 0.0.308

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.
Files changed (165) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CZeQo09T.js → agent-avatar-dicebear-dUotwUO6.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C6LflMXr.js +1 -0
  5. package/dist/gateway/static/root/assets/{agents-BlrHMbRx.js → agents-VPDIGRSS.js} +1 -1
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-Bzw4fQP8.js → app-management-settings-panel-zPz0rOND.js} +1 -1
  7. package/dist/gateway/static/root/assets/{appearance-settings-8GZpUXva.js → appearance-settings-DhvhR43G.js} +1 -1
  8. package/dist/gateway/static/root/assets/{apps-page-BkQQtIxH.js → apps-page-Pmslbzzr.js} +1 -1
  9. package/dist/gateway/static/root/assets/{archive-plugin-CQ2NaoHb.js → archive-plugin-BQVZMreT.js} +1 -1
  10. package/dist/gateway/static/root/assets/{attachment-load-BFi1H7yJ.js → attachment-load-CPE-TMPf.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-page-CDBXcii_.js → automations-page-C4IAy_zF.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-workspace-Fx5VUJRu.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-D07eWmOx.js → binary-plugins-DgTl7diZ.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-CtVnjyYU.js → block-editor-CcOVA-Gw.js} +3 -3
  15. package/dist/gateway/static/root/assets/{browser-automations-page-DyrSbDdG.js → browser-automations-page--zKAgj1k.js} +1 -1
  16. package/dist/gateway/static/root/assets/browser-settings-page-DBms6d35.js +3 -0
  17. package/dist/gateway/static/root/assets/capabilities-settings-panel-epdDWIZy.js +8 -0
  18. package/dist/gateway/static/root/assets/{channels-settings-DAD9qE3J.js → channels-settings-B0bsDtmP.js} +1 -1
  19. package/dist/gateway/static/root/assets/{chat-terminal-dock-B62SZdAo.js → chat-terminal-dock-BfLd2rIJ.js} +1 -1
  20. package/dist/gateway/static/root/assets/{computer-settings-page-ClSresNq.js → computer-settings-page-Ckgc0Py-.js} +1 -1
  21. package/dist/gateway/static/root/assets/connector-service-page-BlC1OXX4.js +1 -0
  22. package/dist/gateway/static/root/assets/connectors-page-By33-bF1.js +2 -0
  23. package/dist/gateway/static/root/assets/{cron-expression-CTMi_tql.js → cron-expression-CqNE-nf6.js} +1 -1
  24. package/dist/gateway/static/root/assets/{date-picker-B71AJK50.js → date-picker-BS9ZjzYJ.js} +1 -1
  25. package/dist/gateway/static/root/assets/{dependency-picker-DlyGK-kA.js → dependency-picker-CF_zYzxX.js} +1 -1
  26. package/dist/gateway/static/root/assets/{desktop-pet-DGkbTE8_.js → desktop-pet-CDwtLR7Z.js} +1 -1
  27. package/dist/gateway/static/root/assets/{desktop-pet-settings-BY8r9j66.js → desktop-pet-settings-C0djIc1J.js} +1 -1
  28. package/dist/gateway/static/root/assets/{device-pairing-wizard-DzRrgd59.js → device-pairing-wizard-CDKj9LQj.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-debug-page-L8Mm1n3A.js → extension-debug-page-CX5OXxEU.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-page-CFc4vSNU.js → extension-page-BytR1PaY.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-settings-page-B5zWyHr3.js → extension-settings-page-CkaMJA5F.js} +1 -1
  32. package/dist/gateway/static/root/assets/{gateway-settings-D7qmTH4R.js → gateway-settings-_YU-1p0z.js} +1 -1
  33. package/dist/gateway/static/root/assets/{heartbeat-settings-Glsl3X5b.js → heartbeat-settings-CVIvvm4x.js} +1 -1
  34. package/dist/gateway/static/root/assets/home-page-COCHelcL.js +1 -0
  35. package/dist/gateway/static/root/assets/{imports-page-ByBX7ome.js → imports-page-DrtbjL8O.js} +1 -1
  36. package/dist/gateway/static/root/assets/index-CDfcPiPb.js +79 -0
  37. package/dist/gateway/static/root/assets/index-CRu1p38D.css +1 -0
  38. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C45RlO8a.js → keyboard-shortcuts-settings-BlZh41Xq.js} +1 -1
  39. package/dist/gateway/static/root/assets/{local-app-workbench-page-DP0x2jpR.js → local-app-workbench-page-D7_Raxjw.js} +2 -2
  40. package/dist/gateway/static/root/assets/{local-apps-page-C_AQc2bI.js → local-apps-page-DbP7wWuh.js} +1 -1
  41. package/dist/gateway/static/root/assets/{logs-page-DvM8Pyok.js → logs-page-C0n66FiO.js} +1 -1
  42. package/dist/gateway/static/root/assets/{management-settings-D1uwSutV.js → management-settings-i6GhxpGV.js} +1 -1
  43. package/dist/gateway/static/root/assets/{media-plugins-C4mhf13f.js → media-plugins-CnWChQ3Y.js} +1 -1
  44. package/dist/gateway/static/root/assets/note-detail-panel-C59d8vDW.js +5 -0
  45. package/dist/gateway/static/root/assets/notes-page-C1GBPrVI.js +8 -0
  46. package/dist/gateway/static/root/assets/{page-tabs-1go_BtX1.js → page-tabs-BWitjb3e.js} +1 -1
  47. package/dist/gateway/static/root/assets/{preview-open-alternatives-DmoSC0j1.js → preview-open-alternatives-UaCWCxZv.js} +1 -1
  48. package/dist/gateway/static/root/assets/{proactive-page-xAjKTIID.js → proactive-page-CtSFJxoM.js} +1 -1
  49. package/dist/gateway/static/root/assets/project-detail-page-ILTmQ1YN.js +1 -0
  50. package/dist/gateway/static/root/assets/projects-page-snl4rOQZ.js +1 -0
  51. package/dist/gateway/static/root/assets/remote-access-hub-BbaAcEN3.js +1 -0
  52. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-ClkOoxDl.js → runtime-tools-settings-panel-CtOjKGWg.js} +1 -1
  53. package/dist/gateway/static/root/assets/{schema-form-BuEmLiaU.js → schema-form-DkyyDcl2.js} +1 -1
  54. package/dist/gateway/static/root/assets/sessions-page-DrWL71O8.js +1 -0
  55. package/dist/gateway/static/root/assets/settings-advanced-gate-BG0kl4HT.js +1 -0
  56. package/dist/gateway/static/root/assets/{settings-form-section-Dor39QON.js → settings-form-section-C0JDGN_V.js} +1 -1
  57. package/dist/gateway/static/root/assets/{settings-page-Xj-yvIc8.js → settings-page-DiIyMQ52.js} +1 -1
  58. package/dist/gateway/static/root/assets/setup-status-panel-EPazhoZO.js +1 -0
  59. package/dist/gateway/static/root/assets/{share-preview-page-BFWZoXdm.js → share-preview-page-Bt1K657Y.js} +1 -1
  60. package/dist/gateway/static/root/assets/shares-settings-g2MdRXSZ.js +1 -0
  61. package/dist/gateway/static/root/assets/skill-reload-api-B1DPzu98.js +1 -0
  62. package/dist/gateway/static/root/assets/skills-page-Wd0uYSPG.js +2 -0
  63. package/dist/gateway/static/root/assets/{skills-page.utils-Ii8qeXhs.js → skills-page.utils-vq5Ujm03.js} +1 -1
  64. package/dist/gateway/static/root/assets/{system-settings-panel-Di6OSO-0.js → system-settings-panel-Cz1P-HDH.js} +1 -1
  65. package/dist/gateway/static/root/assets/task-detail-page-BG3A5gPZ.js +1 -0
  66. package/dist/gateway/static/root/assets/{tunnel-api-DDOlOYlj.js → tunnel-api-DQGoFuZO.js} +1 -1
  67. package/dist/gateway/static/root/assets/{use-autosave-CQ8uWNnB.js → use-autosave-DVDlBb95.js} +1 -1
  68. package/dist/gateway/static/root/assets/user-model-page-qM5UiTGx.js +2 -0
  69. package/dist/gateway/static/root/assets/{voice-api-key-field-COTzshjL.js → voice-api-key-field-B2pZCcxY.js} +1 -1
  70. package/dist/gateway/static/root/assets/{work-discovery-overlay-_URrXbi4.js → work-discovery-overlay-Bptv7bEY.js} +1 -1
  71. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CALs-1nd.js → workflow-run-setup-panel-BijCrNc4.js} +2 -2
  72. package/dist/gateway/static/root/assets/workflows-page-DRy1RAYH.js +6 -0
  73. package/dist/gateway/static/root/index.html +2 -2
  74. package/dist/package.js +1 -1
  75. package/dist/packages/gateway-contract/src/notifications.js +1 -1
  76. package/dist/src/agent/background-review/prompts.js +3 -1
  77. package/dist/src/agent/context/execution-context.js +4 -4
  78. package/dist/src/agent/memory/compaction-promotion.d.ts +1 -1
  79. package/dist/src/agent/memory/compaction-promotion.js +4 -3
  80. package/dist/src/agent/tools/knowledge-memory-tool.d.ts +1 -1
  81. package/dist/src/agent/tools/knowledge-memory-tool.js +3 -3
  82. package/dist/src/agent/tools/user-context-tool.js +17 -7
  83. package/dist/src/chat-commands/builtins/understanding.js +1 -1
  84. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  85. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  86. package/dist/src/config/schema.d.ts +2 -4
  87. package/dist/src/config/schema.js +2 -2
  88. package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
  89. package/dist/src/connectors/connected-source-understanding.js +1 -0
  90. package/dist/src/connectors/learning-coordinator.js +31 -9
  91. package/dist/src/gateway/hono/lib/config-payload.d.ts +2 -2
  92. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  93. package/dist/src/gateway/hono/routes/context-sources.js +0 -23
  94. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  95. package/dist/src/gateway/hono/routes/projects.js +8 -0
  96. package/dist/src/gateway/hono/routes/user-model-refresh.d.ts +5 -0
  97. package/dist/src/gateway/hono/routes/user-model-refresh.js +128 -0
  98. package/dist/src/gateway/hono/routes/user-model.js +12 -5
  99. package/dist/src/gateway/hono/routes/work-discovery.js +0 -30
  100. package/dist/src/gateway/service.js +6 -6
  101. package/dist/src/infra/update-restart.js +1 -1
  102. package/dist/src/knowledge/connected-knowledge-pipeline.js +1 -1
  103. package/dist/src/knowledge-memory/index.js +2 -2
  104. package/dist/src/knowledge-memory/repository.d.ts +7 -0
  105. package/dist/src/knowledge-memory/repository.js +58 -8
  106. package/dist/src/memory-maintenance/service.js +61 -31
  107. package/dist/src/migrations/memory-config.d.ts +2 -0
  108. package/dist/src/migrations/memory-config.js +77 -0
  109. package/dist/src/migrations/runner.js +2 -2
  110. package/dist/src/notifications/planner.js +5 -5
  111. package/dist/src/notifications/service.d.ts +2 -2
  112. package/dist/src/notifications/service.js +1 -1
  113. package/dist/src/storage/sqlite/migrations/184_memory_suppressions.sql +12 -0
  114. package/dist/src/storage/sqlite/migrations/185_understanding_refresh_batches.sql +6 -0
  115. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  116. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  117. package/dist/src/storage/sqlite/schema.js +1 -1
  118. package/dist/src/user-context/config.d.ts +4 -9
  119. package/dist/src/user-context/config.js +7 -27
  120. package/dist/src/user-context/memory-suppression.d.ts +7 -0
  121. package/dist/src/user-context/memory-suppression.js +23 -0
  122. package/dist/src/user-context/relationship-continuity.js +1 -1
  123. package/dist/src/user-context/sources/refresh-service.d.ts +48 -0
  124. package/dist/src/user-context/sources/refresh-service.js +221 -0
  125. package/dist/src/user-context/sources/repository.js +1 -1
  126. package/dist/src/user-model/bootstrap.js +27 -24
  127. package/dist/src/user-model/capture/executor.d.ts +1 -1
  128. package/dist/src/user-model/capture/executor.js +17 -11
  129. package/dist/src/user-model/capture/semantic.js +1 -1
  130. package/dist/src/user-model/domain.d.ts +6 -2
  131. package/dist/src/user-model/index.js +3 -3
  132. package/dist/src/user-model/profile.js +1 -1
  133. package/dist/src/user-model/repository.d.ts +4 -1
  134. package/dist/src/user-model/repository.js +96 -6
  135. package/dist/src/user-model/usage-policy.d.ts +2 -0
  136. package/dist/src/user-model/usage-policy.js +6 -2
  137. package/dist/src/work-discovery/project-understanding.js +2 -1
  138. package/dist/src/work-discovery/service.d.ts +8 -24
  139. package/dist/src/work-discovery/service.js +138 -180
  140. package/package.json +3 -3
  141. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BPsRb9Ck.js +0 -1
  142. package/dist/gateway/static/root/assets/automations-workspace-CUpiTTiY.js +0 -6
  143. package/dist/gateway/static/root/assets/browser-settings-page-CqTxLpil.js +0 -3
  144. package/dist/gateway/static/root/assets/capabilities-settings-panel-BZ_-pnS6.js +0 -8
  145. package/dist/gateway/static/root/assets/connector-service-page-CPqVmNvx.js +0 -1
  146. package/dist/gateway/static/root/assets/connectors-page-BUQyg3CW.js +0 -2
  147. package/dist/gateway/static/root/assets/home-page-s9hDQ8Hc.js +0 -1
  148. package/dist/gateway/static/root/assets/index-RBCkv8a_.js +0 -79
  149. package/dist/gateway/static/root/assets/index-cFU4S35z.css +0 -1
  150. package/dist/gateway/static/root/assets/note-detail-panel-D35sErp2.js +0 -5
  151. package/dist/gateway/static/root/assets/notes-page-8jCDklDn.js +0 -8
  152. package/dist/gateway/static/root/assets/project-detail-page-BUMQHy_N.js +0 -1
  153. package/dist/gateway/static/root/assets/projects-page-DT-Mt7XR.js +0 -1
  154. package/dist/gateway/static/root/assets/remote-access-hub-Clz3byir.js +0 -1
  155. package/dist/gateway/static/root/assets/sessions-page-tQRwktKm.js +0 -1
  156. package/dist/gateway/static/root/assets/settings-advanced-gate-DqWg9XS5.js +0 -1
  157. package/dist/gateway/static/root/assets/setup-status-panel-BB_sMB7P.js +0 -1
  158. package/dist/gateway/static/root/assets/shares-settings-oDALm4b6.js +0 -1
  159. package/dist/gateway/static/root/assets/skill-reload-api-DmwelnfK.js +0 -1
  160. package/dist/gateway/static/root/assets/skills-page-BE9JXz4U.js +0 -2
  161. package/dist/gateway/static/root/assets/task-detail-page-D1AWszc7.js +0 -1
  162. package/dist/gateway/static/root/assets/user-model-page-C00i4ea0.js +0 -2
  163. package/dist/gateway/static/root/assets/workflows-page-BUiBjz6m.js +0 -6
  164. package/dist/src/migrations/knowledge-memory-read-policy-config.d.ts +0 -2
  165. package/dist/src/migrations/knowledge-memory-read-policy-config.js +0 -48
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,h as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as o,r as s,t as c}from"./popover-select-9i-ZtHXL.js";import{t as l}from"./circle-check-C23XjkUj.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{t as d}from"./plus-Q2yW6OE7.js";import{t as f}from"./x-B_N4OPjy.js";import{t as p}from"./cn-JdwAhgNB.js";import{a as m,c as h,n as g,r as _}from"./locale-store-msTfRK8P.js";import{t as v}from"./messages-F74LVAiU.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as T}from"./dist-BGTk37IG.js";import{n as E}from"./copy-to-clipboard-HOJ79TWv.js";import{t as D}from"./button-CS04eWY9.js";import{n as O,r as k}from"./gateway-config-swr-B6wHa6ZI.js";import{t as A}from"./skeleton-BwbyijEw.js";import{i as j,o as M}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as N}from"./electron-env-Dit0bHgy.js";import{a as P,i as F,n as I,r as L,t as R}from"./dist-Che_jiQF.js";import{$l as ee,$o as z,$s as B,Al as V,Au as H,Bo as U,Dc as W,Eo as G,G as K,Go as te,H as ne,Ho as re,Jo as ie,Ko as ae,Ks as oe,Mc as se,Mu as ce,Qo as le,Sn as q,Tc as ue,U as de,Uo as fe,V as J,Vc as pe,Vo as me,W as Y,Wo as he,Xi as ge,Yi as _e,Yo as ve,Zc as ye,Zo as be,_n as xe,_s as Se,_u as Ce,bn as X,cc as we,cu as Te,do as Ee,ds as De,es as Oe,fs as ke,gs as Ae,gt as je,hs as Me,ht as Ne,is as Pe,kc as Fe,ku as Ie,ls as Le,ms as Re,mt as ze,nc as Be,ns as Ve,os as He,ps as Ue,qo as We,rs as Ge,ss as Ke,ts as qe,us as Je,vc as Ye,vn as Xe,vs as Ze,wc as Qe,xc as $e,xl as et,xs as tt,yn as nt,ys as rt,yu as it,zc as at}from"./index-CDfcPiPb.js";import{t as ot}from"./connector-service-page-BlC1OXX4.js";import{t as st}from"./page-tabs-BWitjb3e.js";var Z=e(t(),1),Q=n(),$=r();function ct(e){let t=(0,Q.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,u,d,f,m;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(lt),h=e.slice(0,2),g=Math.max(0,e.length-h.length),_=o.connect,v;t[11]!==n||t[12]!==o?(v=de(n,o),t[11]=n,t[12]=o,t[13]=v):v=t[13];let y=v,b=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,x;t[14]!==_||t[15]!==n||t[16]!==i?(x=e=>(0,$.jsxs)(D,{type:`button`,variant:`primary`,className:p(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(ye,{className:`size-4`}),_]}),t[14]=_,t[15]=n,t[16]=i,t[17]=x):x=t[17],s=x,m=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,c=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(K,{connector:n}),t[18]=n,t[19]=S);let C;t[20]!==n||t[21]!==a?(C=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=C):C=t[22];let w;t[23]===b?w=t[24]:(w=b?(0,$.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:b}):null,t[23]=b,t[24]=w);let T;t[25]!==w||t[26]!==C?(T=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[25]=w,t[26]=C,t[27]=T):T=t[27];let E;t[28]!==T||t[29]!==S?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,T]}),t[28]=T,t[29]=S,t[30]=E):E=t[30];let O;t[31]!==r||t[32]!==s?(O=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=O):O=t[33];let k;t[34]!==r||t[35]!==o.connectedBadge?(k=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(l,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=k):k=t[36];let A;t[37]!==O||t[38]!==k?(A=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[O,k]}),t[37]=O,t[38]=k,t[39]=A):A=t[39],t[40]!==E||t[41]!==A?(u=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[E,A]}),t[40]=E,t[41]=A,t[42]=u):u=t[42],t[43]===y?d=t[44]:(d=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:y,children:y}),t[43]=y,t[44]=d),f=h.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[h.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),g>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,g]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=u,t[8]=d,t[9]=f,t[10]=m}else s=t[5],c=t[6],u=t[7],d=t[8],f=t[9],m=t[10];let h;t[45]!==c||t[46]!==u||t[47]!==d||t[48]!==f?(h=(0,$.jsxs)(`div`,{className:c,children:[u,d,f]}),t[45]=c,t[46]=u,t[47]=d,t[48]=f,t[49]=h):h=t[49];let g;t[50]!==r||t[51]!==s?(g=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[50]=r,t[51]=s,t[52]=g):g=t[52];let _;return t[53]!==m||t[54]!==h||t[55]!==g?(_=(0,$.jsxs)(`div`,{className:m,children:[h,g]}),t[53]=m,t[54]=h,t[55]=g,t[56]=_):_=t[56],_}function lt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ut=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function dt(e,t){return t.some(t=>t.connectorId===e.id)}var ft=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function pt(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:p(`size-10 shrink-0 rounded-xl`,ft)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:p(`h-4 min-w-0 flex-1`,ft)}),(0,$.jsx)(`div`,{className:p(`h-8 w-[4.5rem] shrink-0 rounded-lg`,ft)})]}),(0,$.jsx)(`div`,{className:p(`h-3 w-full`,ft)}),(0,$.jsx)(`div`,{className:p(`h-3 w-[88%]`,ft)})]})]})}),e[1]=n):n=e[1],n}var mt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ht(){let e=(0,Q.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:p(`size-10 shrink-0 rounded-xl`,mt)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:p(`h-4 w-48 max-w-full`,mt)}),(0,$.jsx)(`div`,{className:p(`h-3 w-72 max-w-full`,mt)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsx)(`div`,{className:p(`h-9 w-20 rounded-lg`,mt)}),(0,$.jsx)(`div`,{className:p(`h-9 w-20 rounded-lg`,mt)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,$.jsx)(`div`,{className:p(`h-8 w-20 rounded-md`,mt)}),(0,$.jsx)(`div`,{className:p(`h-8 w-24 rounded-md`,mt)}),(0,$.jsx)(`div`,{className:p(`h-8 w-28 rounded-md`,mt)})]}),(0,$.jsx)(`div`,{className:p(`mt-3 h-20 rounded-xl`,mt)})]}),e[3]=i):i=e[3],i}var gt=[`understand`,`act`,`reach`];function _t(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function vt(e){return _t(e)[0]??`act`}function yt(e,t){let n=t?vt(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function bt(e,t){return t.connectorCapabilityLabels[e]??e}function xt(e,t){if(e.runtime.type===`mcp`)return Y(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.sourceKind;return Y(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function St(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Ct(e){let t=(0,Q.c)(9),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`h4`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(wt),t[2]=r,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:a}),t[4]=a,t[5]=o);let s;return t[6]!==i||t[7]!==o?(s=(0,$.jsxs)(`section`,{children:[i,o]}),t[6]=i,t[7]=o,t[8]=s):s=t[8],s}function wt(e){return(0,$.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,$.jsx)(`p`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Tt({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,o]=(0,Z.useState)(!1),s=de(e,i),[c,d]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),g=_t(e),_=[...(e.setup.secrets??[]).filter(e=>e.required),...(e.setup.config??[]).filter(e=>e.required)],v=e.capabilities.filter(e=>!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)),E=async()=>{o(!0),h(null);try{d(await Ge(e))}catch(e){d(null),h(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,$.jsx)(T,{open:!0,onOpenChange:e=>{e||n()},children:(0,$.jsxs)(S,{children:[(0,$.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(C,{className:p(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(K,{connector:e,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(w,{className:`text-base font-semibold text-fg`,children:e.displayName}),t?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(l,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]}):null]}),(0,$.jsx)(b,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:s})]})]}),(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,tt.focusRingPanel),"aria-label":i.modalClose,children:(0,$.jsx)(f,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,children:[g.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:g.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.connectorBenefitHints[e]})]},e))})]}):null,(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.detailPermissions}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:St(e,i)})]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.connectorSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:_.length?Y(i.connectorRequiredInputsCount,{count:String(_.length)}):i.connectorSetupNone})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:i.connectorTechnicalDetails}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:xt(e,i)})]}),v.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:v.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:bt(e,i)},e))}):null,(0,$.jsxs)(D,{variant:`secondary`,disabled:a,onClick:()=>void E(),children:[a?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(oe,{className:`size-4`}),i.connectorPreviewButton]}),m?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:m}):null,c?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Ct,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,$.jsx)(Ct,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description}))}),(0,$.jsx)(Ct,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description}))})]}):null]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(D,{variant:`secondary`,children:i.modalClose})}),t?null:(0,$.jsxs)(D,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,$.jsx)(ye,{className:`size-4`}),i.connect]})]})]})]})})}var Et=p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G);function Dt(e){let t=(0,Q.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:o,onClose:s,t:c,mcp:l}=e,d;t[0]===s?d=t[1]:(d=e=>{e||s()},t[0]=s,t[1]=d);let m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=m):m=t[2];let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=p(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(32rem,calc(100vh-2rem))] w-[min(100%-2rem,38rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float dark:border-edge`),t[3]=h):h=t[3];let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)(at,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=g):g=t[4];let _;t[5]===c.runtimeSettingsTitle?_=t[6]:(_=(0,$.jsx)(w,{className:`text-base font-semibold text-fg`,children:c.runtimeSettingsTitle}),t[5]=c.runtimeSettingsTitle,t[6]=_);let v;t[7]===c.runtimeSettingsHint?v=t[8]:(v=(0,$.jsx)(b,{className:`mt-1 text-sm text-fg-muted`,children:c.runtimeSettingsHint}),t[7]=c.runtimeSettingsHint,t[8]=v);let E;t[9]!==_||t[10]!==v?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[g,(0,$.jsxs)(`div`,{className:`min-w-0`,children:[_,v]})]}),t[9]=_,t[10]=v,t[11]=E):E=t[11];let O;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(O=p(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,tt.focusRingPanel),t[12]=O):O=t[12];let k;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(f,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=k):k=t[13];let A;t[14]===c.modalClose?A=t[15]:(A=(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O,"aria-label":c.modalClose,children:k})}),t[14]=c.modalClose,t[15]=A);let j;t[16]!==A||t[17]!==E?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[E,A]}),t[16]=A,t[17]=E,t[18]=j):j=t[18];let M;t[19]===l.idleTtlLabel?M=t[20]:(M=(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:l.idleTtlLabel}),t[19]=l.idleTtlLabel,t[20]=M);let N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=p(Et,`w-40 flex-none`),t[21]=N):N=t[21];let P=r??``,F;t[22]===a?F=t[23]:(F=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=F);let I;t[24]!==l.idleTtlPlaceholder||t[25]!==P||t[26]!==F?(I=(0,$.jsx)(`input`,{type:`number`,min:0,className:N,value:P,placeholder:l.idleTtlPlaceholder,onChange:F}),t[24]=l.idleTtlPlaceholder,t[25]=P,t[26]=F,t[27]=I):I=t[27];let L;t[28]===l.idleTtlHint?L=t[29]:(L=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:l.idleTtlHint}),t[28]=l.idleTtlHint,t[29]=L);let R;t[30]!==M||t[31]!==I||t[32]!==L?(R=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[M,I,L]})}),t[30]=M,t[31]=I,t[32]=L,t[33]=R):R=t[33];let ee;t[34]!==s||t[35]!==i||t[36]!==c.modalCancel?(ee=(0,$.jsx)(D,{type:`button`,variant:`secondary`,disabled:i,onClick:s,children:c.modalCancel}),t[34]=s,t[35]=i,t[36]=c.modalCancel,t[37]=ee):ee=t[37];let z;t[38]===o?z=t[39]:(z=()=>void o(),t[38]=o,t[39]=z);let B;t[40]===i?B=t[41]:(B=i?(0,$.jsx)(u,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=B);let V;t[42]!==l.save||t[43]!==i||t[44]!==z||t[45]!==B?(V=(0,$.jsxs)(D,{type:`button`,variant:`primary`,disabled:i,onClick:z,children:[B,l.save]}),t[42]=l.save,t[43]=i,t[44]=z,t[45]=B,t[46]=V):V=t[46];let H;t[47]!==ee||t[48]!==V?(H=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[ee,V]}),t[47]=ee,t[48]=V,t[49]=H):H=t[49];let U;t[50]!==j||t[51]!==R||t[52]!==H?(U=(0,$.jsxs)(S,{children:[m,(0,$.jsxs)(C,{className:h,children:[j,R,H]})]}),t[50]=j,t[51]=R,t[52]=H,t[53]=U):U=t[53];let W;return t[54]!==n||t[55]!==d||t[56]!==U?(W=(0,$.jsx)(T,{open:n,onOpenChange:d,children:U}),t[54]=n,t[55]=d,t[56]=U,t[57]=W):W=t[57],W}var Ot=(0,Z.memo)(function(e){let t=(0,Q.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,o;t[0]===a?o=t[1]:(o=p(`relative flex min-h-11 sm:min-h-9 min-w-0 flex-1 cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 focus-within:ring-2 focus-within:ring-accent`,a),t[0]=a,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(W,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=s):s=t[2];let c;t[3]===r?c=t[4]:(c=e=>r(e.currentTarget.value),t[3]=r,t[4]=c);let l;t[5]!==i||t[6]!==c||t[7]!==n?(l=(0,$.jsx)(`input`,{type:`search`,"aria-label":i,enterKeyHint:`search`,value:n,onChange:c,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-base sm:text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),t[5]=i,t[6]=c,t[7]=n,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,$.jsxs)(`label`,{className:o,children:[s,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}),kt=(0,Z.memo)(function(e){let t=(0,Q.c)(21),{onBrowseCatalog:n,onAddCustomServer:r,addLabel:i,browseLabel:a,customLabel:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(ot,{}),t[0]=s):s=t[0];let c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(d,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=c):c=t[1];let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(ce,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=l):l=t[2];let u;t[3]===i?u=t[4]:(u=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(D,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[c,i,l]})}),t[3]=i,t[4]=u);let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=p(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,tt.transition),t[5]=f):f=t[5];let m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(we,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[6]=m):m=t[6];let h;t[7]!==a||t[8]!==n?(h=(0,$.jsxs)(Xe,{className:f,onSelect:n,children:[m,a]}),t[7]=a,t[8]=n,t[9]=h):h=t[9];let g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=p(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,tt.transition),t[10]=g):g=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(oe,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=_):_=t[11];let v;t[12]!==o||t[13]!==r?(v=(0,$.jsxs)(Xe,{className:g,onSelect:r,children:[_,o]}),t[12]=o,t[13]=r,t[14]=v):v=t[14];let y;t[15]!==v||t[16]!==h?(y=(0,$.jsx)(nt,{children:(0,$.jsxs)(xe,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[h,v]})}),t[15]=v,t[16]=h,t[17]=y):y=t[17];let b;return t[18]!==y||t[19]!==u?(b=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[s,(0,$.jsxs)(X,{children:[u,y]})]}),t[18]=y,t[19]=u,t[20]=b):b=t[20],b}),At=/^([^:=]+)[:=](.*)$/;function jt(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=At.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function Mt(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 Nt(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 Pt(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 Ft(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)||Pt(t)&&(r[e]=t);return r}function It(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function Lt(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 Rt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=It(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=Lt(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=Mt(e.headers);return n&&(t.headers=n),e.transport===`streamable-http`&&e.auth===`oauth`&&(t.auth={type:`oauth`,...e.oauthClientId.trim()?{clientId:e.oauthClientId.trim()}:{}}),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}function zt(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0,o=t.auth&&typeof t.auth==`object`&&!Array.isArray(t.auth)?t.auth:void 0,s=o?.type===`oauth`?`oauth`:`none`;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:Nt(a),auth:s,oauthClientId:typeof o?.clientId==`string`?o.clientId:``,connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0,requestTimeoutMs:typeof t.requestTimeoutMs==`number`&&Number.isFinite(t.requestTimeoutMs)?t.requestTimeoutMs:void 0}}function Bt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],auth:`none`,oauthClientId:``,connectionTimeoutMs:void 0,requestTimeoutMs:void 0}}function Vt(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)||Pt(t)?[]:[zt(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 Rt(e)}async function Ut(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]=Rt(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 m(_(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),O()}async function Wt(e,t,n=``){let r=await m(_(`/api/mcp/servers/${encodeURIComponent(e)}/oauth${n}`),{method:t});if(!r.payload)throw Error(r.error??`MCP OAuth request failed`);return r.payload}function Gt(e){return Wt(e,`GET`)}function Kt(e){return Wt(e,`POST`,`/start`)}function qt(e){return Wt(e,`DELETE`)}function Jt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function 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.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 Xt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.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 Zt(e,t){let n=await m(_(`/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=Jt(n.payload.tools),i=Yt(n.payload.resources),a=Xt(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 Qt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function $t(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 en(e){return e.requestTimeoutMs==null||!Number.isFinite(e.requestTimeoutMs)?``:String(Math.round(e.requestTimeoutMs/1e3))}function tn(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>14400))return n*1e3}function nn(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 rn({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),b=nn(e),x=e.transport===`streamable-http`&&e.auth===`oauth`;(0,Z.useEffect)(()=>{if(!x){_(null);return}let t=!1,n=async()=>{try{let n=await Gt(e.id.trim());t||(_(n),n.status===`error`&&n.session?.error&&h(n.session.error),n.status===`connected`&&h(null))}catch(e){t||h(e instanceof Error?e.message:String(e))}};n();let r=window.setInterval(()=>{g?.status===`authorizing`&&n()},1e3);return()=>{t=!0,window.clearInterval(r)}},[g?.status,e.id,x]);let S=(0,Z.useCallback)(async()=>{y(!0),h(null);let n=je();try{let r=await Kt(e.id.trim());_(r),r.status===`error`&&r.session?.error&&h(r.session.error),r.status===`connected`&&h(null);let i=r.session?.authorizationUrl;i?await Ne(i,n)||h(t.oauthOpenFailed):ze(n)}catch(e){ze(n),h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.id,t.oauthOpenFailed]),C=(0,Z.useCallback)(async()=>{y(!0),h(null);try{_(await qt(e.id.trim()))}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.id]),w=(0,Z.useCallback)(async()=>{o(!0),h(null);try{let t=await Zt(e.id.trim());p({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){h(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),T=(0,Z.useCallback)(async()=>{c(!0),h(null);try{await i()}catch(e){h(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`px-4 py-3.5 hover:bg-surface-hover/50`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:r,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]}),x&&g?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.oauthStatus[g.status===`not_configured`?`disconnected`:g.status]}):null]}),b?(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:b,children:b}):null,m?(0,$.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:m}):null,f?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:Y(n.customCapabilitySummary,{tools:String(f.toolCount),resources:String(f.resourceCount),prompts:String(f.promptCount)})}):null]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[x&&g?.status!==`connected`?(0,$.jsxs)(D,{variant:`secondary`,disabled:v,onClick:()=>void S(),children:[v?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(et,{className:`size-4`}),g?.status===`authorizing`?t.oauthOpenAuthorization:t.oauthConnect]}):(0,$.jsxs)(D,{variant:`secondary`,disabled:a,onClick:()=>void w(),children:[a?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(pe,{className:`size-4`}),t.testConnection]}),x&&g?.status===`connected`?(0,$.jsxs)(D,{variant:`ghost`,disabled:v,onClick:()=>void C(),children:[v?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(B,{className:`size-4`}),t.oauthDisconnect]}):null,(0,$.jsxs)(D,{variant:`ghost`,disabled:s,onClick:()=>d(!0),children:[s?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(Be,{className:`size-4`}),t.removeServer]})]})]}),(0,$.jsx)(ge,{open:l,title:n.removeConfirmTitle.replace(`{{name}}`,e.id.trim()||t.cardUntitled),description:n.removeConfirmDescription,confirmLabel:t.removeServer,cancelLabel:n.modalCancel,destructive:!0,onConfirm:()=>{d(!1),T()},onCancel:()=>{s||d(!1)}})]})}function an(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function on(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||an(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
+ `).toLowerCase().includes(r)}function sn(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function cn(e){let t=(0,Q.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,s]=(0,Z.useState)(``),c;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>on(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],c=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=c}else c=t[3];let l=c,u;t[7]===o?u=t[8]:(u=o.trim(),t[7]=o,t[8]=u);let d=u.length>0,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(W,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=f):f=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=p(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,G),h=e=>s(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let g;t[12]!==o||t[13]!==i?(g=(0,$.jsxs)(`div`,{className:`relative`,children:[f,(0,$.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:m,onChange:h})]}),t[12]=o,t[13]=i,t[14]=g):g=t[14];let _;t[15]!==l.length||t[16]!==d||t[17]!==n.length?(_=d?(0,$.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[l.length,` / `,n.length]}):null,t[15]=l.length,t[16]=d,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,$.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[g,_]}),t[19]=g,t[20]=_,t[21]=v):v=t[21];let y;t[22]!==l||t[23]!==a||t[24]!==r?(y=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:l.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>{let n=e.shortName||sn(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,$.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=l,t[23]=a,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function ln(e){let t=(0,Q.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:o,searchPlaceholder:s,searchEmptyLabel:c,emptyLabel:l,closeLabel:u,tools:d,stripPrefix:m}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(y,{className:p(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,M)}),t[0]=h):h=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=p(`xopc-dialog-content fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,j,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(oe,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=_):_=t[2];let v;t[3]===a?v=t[4]:(v=(0,$.jsxs)(w,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[_,a]}),t[3]=a,t[4]=v);let E;t[5]!==i||t[6]!==o||t[7]!==d.length?(E=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(d.length)),t[5]=i,t[6]=o,t[7]=d.length,t[8]=E):E=t[8];let O;t[9]===E?O=t[10]:(O=(0,$.jsx)(b,{className:`mt-1 text-sm text-fg-muted`,children:E}),t[9]=E,t[10]=O);let k;t[11]!==v||t[12]!==O?(k=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[v,O]}),t[11]=v,t[12]=O,t[13]=k):k=t[13];let A;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(f,{className:`size-4`,"aria-hidden":!0}),t[14]=A):A=t[14];let N;t[15]===u?N=t[16]:(N=(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":u,children:A})}),t[15]=u,t[16]=N);let P;t[17]!==k||t[18]!==N?(P=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[k,N]}),t[17]=k,t[18]=N,t[19]=P):P=t[19];let F;t[20]!==l||t[21]!==n||t[22]!==c||t[23]!==s||t[24]!==i||t[25]!==m||t[26]!==d?(F=d.length>0?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,$.jsx)(cn,{tools:d,stripPrefix:m,searchPlaceholder:s,searchEmptyLabel:c},`${i}-${n?`open`:`closed`}`)}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l})}),t[20]=l,t[21]=n,t[22]=c,t[23]=s,t[24]=i,t[25]=m,t[26]=d,t[27]=F):F=t[27];let I;t[28]===u?I=t[29]:(I=(0,$.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(D,{type:`button`,variant:`secondary`,children:u})})}),t[28]=u,t[29]=I);let L;t[30]!==P||t[31]!==F||t[32]!==I?(L=(0,$.jsxs)(S,{children:[h,(0,$.jsxs)(C,{className:g,children:[P,F,I]})]}),t[30]=P,t[31]=F,t[32]=I,t[33]=L):L=t[33];let R;return t[34]!==r||t[35]!==n||t[36]!==L?(R=(0,$.jsx)(T,{open:n,onOpenChange:r,children:L}),t[34]=r,t[35]=n,t[36]=L,t[37]=R):R=t[37],R}function un(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function dn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?un(t)-un(e):e.isCurrentAuthorization?-1:1}function fn(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(dn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>dn(e.primary,t.primary))}var pn=p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G);function mn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function hn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function gn(e,t,n){return e.status===`connected`?Y(n.composioHealthConnected,{count:String(t)}):e.status===`reauthorization_required`?n.composioHealthReconnect:e.status===`disconnected`?n.composioHealthDisconnected:e.errorCode===`missing_credential`?n.composioHealthMissingCredential:e.errorCode===`unauthorized`?n.composioHealthUnauthorized:e.errorCode===`forbidden`?n.composioHealthForbidden:e.errorCode===`network`?n.composioHealthNetwork:e.errorCode===`timeout`?n.composioHealthTimeout:n.composioHealthDegraded}function _n(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function vn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function yn({instance:e,t,onChanged:n}){let r=mn(e),i=g(e=>e.language)===`zh`,[a,c]=(0,Z.useState)([]),[d,f]=(0,Z.useState)([]),[m,h]=(0,Z.useState)([]),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)([]),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)([]),[O,k]=(0,Z.useState)({}),[j,M]=(0,Z.useState)(`read`),[P,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(null),[R,ee]=(0,Z.useState)(!1),[B,H]=(0,Z.useState)(null),[W,G]=(0,Z.useState)(null),[K,te]=(0,Z.useState)(!1),[ne,re]=(0,Z.useState)(!1),[oe,ce]=(0,Z.useState)(!1),q=(0,Z.useRef)(0),ue=(0,Z.useRef)(0),de=(0,Z.useMemo)(()=>fn(a),[a]),fe=(0,Z.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),J=(0,Z.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;F(!0),L(null);let t=++q.current;try{let e=(await Promise.allSettled([fe(z()).then(e=>{t===q.current&&(c(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),te(!0))}),fe(ve(r)).then(e=>{t===q.current&&M(e)}),fe(ie(r)).then(e=>{t===q.current&&(v(e.policy),b(e.agents))})])).find(e=>e.status===`rejected`);t===q.current&&e?.status===`rejected`&&L(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===q.current&&F(!1)}},[e.materialized,r,fe]);(0,Z.useEffect)(()=>(J(),()=>{q.current++}),[J]);let pe=(0,Z.useCallback)(async()=>{if(!r)return;let e=++ue.current;ce(!0),ee(!1);let t=t=>n=>{e===ue.current&&t(n)},n=await Promise.allSettled([fe(Oe(r)).then(t(f)),fe(qe(20)).then(t(e=>h(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),fe(be(r)).then(t(w)),fe(We(r)).then(t(S))]);e===ue.current&&(ee(n.some(e=>e.status===`rejected`)),ce(!1))},[r,fe]);(0,Z.useEffect)(()=>(ne&&pe(),()=>{ue.current++}),[ne,pe]),(0,Z.useEffect)(()=>{let e=!1,t=fn(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return fe(Ve()).then(t=>{e||E(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await fe(le(e.accountId))])).then(t=>{e||k(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,fe]);let me=(0,Z.useCallback)(async t=>{if(!r)return;let i=N()?null:window.open(`about:blank`,`_blank`);i&&(i.opener=null),F(!0),L(null);try{if(!N()&&!i)throw Error(`Allow popups to open the authorization page.`);let a=await De(e.connectorId,t);if(!a.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(N()){let e=await window.electronAPI?.shell?.openExternalUrl(a.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else i.location.href=a.authorizationUrl;let o=await rt(r,a.connectionId,12e4,a.attemptId);if(t&&o.accountId!==t)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),J()])}catch(e){L(e instanceof Error?e.message:String(e))}finally{i?.close(),F(!1)}},[e.connectorId,J,n,r]),he=(0,Z.useCallback)(async t=>{F(!0),L(null);try{await Se(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),J()])}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}},[e.config,e.instanceId,J,n]),_e=async e=>{let t=N()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),L(null);try{let n=await ae(e.id);if(n.authorizationUrl)if(N())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await J()}catch(e){t?.close(),L(e instanceof Error?e.message:String(e))}},ye=(0,Z.useCallback)(async e=>{if(r){M(e),L(null);try{await Le(r,e)}catch(e){L(e instanceof Error?e.message:String(e)),await J()}}},[J,r]),xe=(0,Z.useCallback)(async e=>{if(r){L(null);try{v(await Ae(r,e))}catch(e){L(e instanceof Error?e.message:String(e))}}},[r]),Ce=(0,Z.useCallback)(e=>{if(!_)return;let t=_.allowedAgentIds.includes(e);t&&_.allowedAgentIds.length===1||xe({allowedAgentIds:t?_.allowedAgentIds.filter(t=>t!==e):[..._.allowedAgentIds,e]})},[xe,_]),X=(0,Z.useCallback)(async e=>{F(!0),L(null);try{await e(),await J()}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}},[J]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let we=de.filter(e=>e.primary.status===`active`).length,Te=we>0?t.composioAddAccount:t.composioConnectAccount,Ee=K&&we>0,ke=C?.requiresCustomAuthConfig===!0,je=C?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:p(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Ee?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Ee?(0,$.jsx)(l,{className:`size-3.5`}):(0,$.jsx)(Ie,{className:`size-3.5`}),Ee?t.connectionReady:K||I?t.connectionNeedsSetup:t.connectionChecking]}),K&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:Y(t.composioAccountCount,{count:String(de.length)})})]}),(0,$.jsxs)(D,{variant:`primary`,className:`shrink-0`,disabled:P,onClick:()=>void me(),children:[P?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(V,{className:`size-4`}),Te]})]}),I?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:I}),(0,$.jsx)(D,{variant:`secondary`,disabled:P,onClick:()=>void J(),children:t.composioRetry})]}):null,x&&!Ee?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:gn(x,we,t)}),x.recovery===`none`?null:(0,$.jsx)(D,{variant:`secondary`,disabled:P,onClick:()=>void(x.recovery===`retry`?J():me()),children:x.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,ke&&je.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,_?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:j===`read`?t.composioAccessReadHint:j===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(o,{value:j,onChange:e=>void ye(e.currentTarget.value),children:[(0,$.jsx)(s,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(s,{value:`write`,children:t.composioAccessReadWrite}),j===`admin`?(0,$.jsx)(s,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(o,{value:_.confirmationPolicy,onChange:e=>void xe({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(s,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(s,{value:`always`,children:t.composioConfirmAlways}),_.confirmationPolicy===`never`?(0,$.jsx)(s,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:_.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-2.5 py-1 text-xs transition-colors`,_.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void xe({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),y.map(e=>(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-2.5 py-1 text-xs transition-colors`,_.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>Ce(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:_.selectedAccountIds===null,disabled:P,onChange:e=>void xe({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),_.selectedAccountIds!==null&&de.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:P,checked:_.selectedAccountIds.includes(e.accountId),onChange:t=>void xe({selectedAccountIds:t.currentTarget.checked?[..._.selectedAccountIds,e.accountId]:_.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),_.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),K&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Y(t.composioAccountCount,{count:String(de.length)})})]}),(0,$.jsxs)(D,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:P,onClick:()=>void J(),children:[(0,$.jsx)(se,{className:p(`size-3.5`,P&&`animate-spin`)}),t.refresh]})]}),de.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:de.map(e=>{let r=e.primary,a=T.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),c=r.accountId?O[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:p(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:_n(r.status,t)}),a?(0,$.jsx)(`p`,{className:p(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:Y(t.connectorLearningStatus,{status:vn(a,c,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(D,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void _e(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(D,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:P,onClick:()=>G(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(D,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:P,onClick:()=>void me(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(D,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:P,onClick:()=>void X(()=>Re(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(D,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:P,onClick:()=>void X(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await Je(r.accountId),await n?.()}),children:[(0,$.jsx)(se,{className:`size-3.5`}),t.composioSyncNow]}):null]})]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[r.accountId&&(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 font-medium`,children:t.composioAllowedAgents}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:P,checked:r.allowedAgentIds==null,onChange:e=>void X(()=>Re(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&y.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:P,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;X(()=>Re(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&c?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:c.scanEnabled,disabled:P,onChange:e=>void X(()=>Ze(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:c.proactiveEnabled,disabled:P||!c.scanEnabled,onChange:e=>void X(()=>Ze(r.accountId,{proactiveEnabled:e.currentTarget.checked}))}),t.connectorProactiveUse]}),c.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(o,{className:`mt-1`,value:String(c.intervalMinutes??30),disabled:P,onChange:e=>void X(()=>Ze(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(s,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(s,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(s,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(s,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:p(pn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&X(()=>Me(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(D,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:P,onClick:()=>H(e.id),children:(0,$.jsx)(Be,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(D,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:P,onClick:()=>void X(()=>Pe(r.id)),children:(0,$.jsx)(se,{className:`size-4`})})})]})]})]},e.key)})}):P&&!K?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(A,{className:`h-16 w-full`}),(0,$.jsx)(A,{className:`h-16 w-full`})]}):K?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>re(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[oe?(0,$.jsx)(A,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,R?(0,$.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[t.composioDiagnosticsUnavailable,(0,$.jsx)(D,{variant:`ghost`,disabled:oe,onClick:()=>void pe(),children:t.composioRetry})]}):null,C?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:ke?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(o,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:P,onChange:e=>void he(e.currentTarget.value),children:[ke?null:(0,$.jsx)(s,{value:``,children:t.composioAuthConfigManaged}),ke&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(s,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,je.map(e=>(0,$.jsxs)(s,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children:d.length?d.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[hn(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:m.length?m.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})})]})]})]})]}),(0,$.jsx)(ge,{open:W!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=W;G(null),e&&X(()=>U(e))},onCancel:()=>G(null)}),(0,$.jsx)(ge,{open:B!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=B;H(null),e&&X(()=>Ke(e))},onCancel:()=>H(null)})]})}var bn=p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G);function xn(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function Sn(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 Cn(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 wn(e){let t=(0,Q.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,$.jsx)(L,{delayDuration:300,skipDelayDuration:100,children:(0,$.jsxs)(F,{children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(`p`,{tabIndex:0,title:r,className:p(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:r})}),(0,$.jsx)(I,{children:(0,$.jsx)(R,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=(0,$.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=s);let c;t[4]===i?c=t[5]:(c=i?(0,$.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:i}):null,t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,o]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}function Tn({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[d,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[E,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(`health`),[N,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(()=>Sn(t,e)),[L,R]=(0,Z.useState)(null),z=t?.setup.config??[],B=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&z.length>0&&(t?.setup.secrets??[]).length===0,H=k?k.toolCount:e.usage.lastToolCount,U=e.materialized.type===`mcp`,W=e.materialized.type===`composio`,G=e.materialized.type===`memorySource`,te=t?de(t,i):null,ne=(0,Z.useMemo)(()=>{let t=[[`health`,$e,i.detailHealth],[`tools`,oe,`${i.detailTools} ${k?k.toolCount:e.usage.lastToolCount??``}`],[`resources`,Te,`${i.detailResources} ${k?k.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,ee,`${i.detailPrompts} ${k?k.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,V,i.detailPermissions]];return B?[...t,[`config`,Te,i.connectorConfigLabel]]:t},[k,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,B,i]),re=(0,Z.useCallback)(async()=>{s(!0),R(null);try{let t=await Ue(e.instanceId);A(t),t.toolCount>0&&M(`tools`),r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e.instanceId,r]),ie=(0,Z.useCallback)(async()=>{l(!0),R(null);try{await He(e.instanceId),await r(),n()}catch(e){R(e instanceof Error?e.message:String(e)),l(!1)}},[e.instanceId,r,n]),ae=(0,Z.useCallback)(async()=>{if(!(!t||!B)){g(!0),R(null);try{let n={};for(let e of t.setup.config??[]){let t=Cn(e.type,F[e.key]??``);t!==void 0&&(n[e.key]=t)}await Se(e.instanceId,{config:n}),await r(),M(`health`)}catch(e){R(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[F,t,e.instanceId,r,B]),se=(0,Z.useCallback)(async()=>{v(!0),O(null),R(null);try{O((await ke(e.connectorId)).recordIds.length),await r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{v(!1)}},[e.connectorId,r]);return(0,$.jsxs)(T,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(S,{children:[(0,$.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(C,{className:p(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,W?`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,40rem)]`:`h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(K,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(w,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(b,{className:`mt-1 text-sm text-fg-muted`,children:te??(e.materialized.type===`mcp`?Y(i.mcpServerRuntime,{serverId:e.materialized.serverId}):Y(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(x,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:p(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,tt.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(f,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[L?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:L}):null,U?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ne.map(([e,t,n])=>(0,$.jsxs)(`button`,{type:`button`,className:p(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,j===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>M(e),children:[(0,$.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,$.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[j===`health`?(0,$.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,$.jsxs)(`p`,{children:[i.statusLabel,` `,(0,$.jsx)(`span`,{className:k?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:xn(k?.status??e.usage.lastHealthStatus,i)})]}),(0,$.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),k?.action?(0,$.jsx)(`p`,{children:k.action}):null]}):null,j===`tools`?k?.tools.length?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Y(i.toolsAvailable,{count:String(k.tools.length)})}),(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>P(!0),children:a.viewAllTools})]}),(0,$.jsx)(`div`,{className:`grid gap-2`,children:k.tools.slice(0,8).map(e=>(0,$.jsx)(wn,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:H?Y(i.toolsLastCheckSummary,{count:String(H)}):i.toolsRunTestHint}),(0,$.jsxs)(D,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void re(),children:[o?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(pe,{className:`size-4`}),i.test]})]}):null,j===`resources`?k?.resources.length?(0,$.jsx)(`div`,{className:`grid gap-2`,children:k.resources.slice(0,8).map(e=>(0,$.jsx)(wn,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,j===`prompts`?k?.prompts.length?(0,$.jsx)(`div`,{className:`grid gap-2`,children:k.prompts.slice(0,8).map(e=>(0,$.jsx)(wn,{title:e.title??e.name,description:e.description,meta:e.argumentCount?Y(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,j===`permissions`?(0,$.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,$.jsx)(`p`,{children:Y(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,$.jsx)(`p`,{children:e.materialized.type===`mcp`?Y(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):Y(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,$.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,j===`config`&&B?(0,$.jsx)(`div`,{className:`grid gap-3`,children:z.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:bn,value:F[e.key]??``,placeholder:e.placeholder,onChange:t=>I(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]})]}):null,W?(0,$.jsx)(yn,{instance:e,t:i,onChanged:r}):null,G?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),te?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:te}):null,E===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:Y(i.connectedSourceSynced,{count:String(E)})})]}),(0,$.jsxs)(D,{disabled:_,onClick:()=>void se(),children:[_?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(Te,{className:`size-4`}),i.composioSyncNow]})]}),B?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:z.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:bn,value:F[e.key]??``,placeholder:e.placeholder,onChange:t=>I(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!U&&!W&&!G?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:(0,$.jsx)(`p`,{children:i.connectorPolicyHint})}):null,(0,$.jsxs)(`details`,{className:`mt-5 rounded-xl border border-edge`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-danger`,children:i.dangerZone}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-danger/15 px-4 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i.removeConnectorHint}),(0,$.jsxs)(D,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:c,onClick:()=>m(!0),children:[c?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(Be,{className:`size-4`}),i.remove]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(D,{variant:`secondary`,onClick:n,children:i.modalClose}),(U&&j===`config`||G)&&B?(0,$.jsxs)(D,{variant:`primary`,disabled:h,onClick:()=>void ae(),children:[h?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(Fe,{className:`size-4`}),i.modalSave]}):null,U?(0,$.jsxs)(D,{variant:`secondary`,disabled:o,onClick:()=>void re(),children:[o?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(pe,{className:`size-4`}),i.test]}):null]})]})]}),e.materialized.type===`mcp`?(0,$.jsx)(ln,{open:N,onOpenChange:P,serverId:e.materialized.serverId,title:Y(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:k?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null,(0,$.jsx)(ge,{open:d,title:Y(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{m(!1),ie()},onCancel:()=>{c||m(!1)}})]})}function En(e){let t=(0,Q.c)(55),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i===void 0?!1:i,c;t[0]!==r||t[1]!==n?(c=yt(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let u=c.state,d;t[3]!==r||t[4]!==o?(d=r?de(r,o):null,t[3]=r,t[4]=o,t[5]=d):d=t[5];let f=d,m,h,g,_,v,y,b,x,S;if(t[6]!==u||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==a||t[11]!==o.connectionChecking||t[12]!==o.connectionNeedsSetup||t[13]!==o.connectionReady){m=u===`ready`?{label:o.connectionReady,Icon:l,className:`text-emerald-700 dark:text-emerald-300`}:u===`needs_setup`?{label:o.connectionNeedsSetup,Icon:Ie,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:Ce,className:`text-fg-muted`},x=`button`;let e=s&&`bg-accent-soft`;t[23]===e?S=t[24]:(S=p(`flex w-full items-center gap-3 px-4 py-3.5 text-left hover:bg-surface-hover/60`,`rounded-none first:rounded-t-[calc(var(--radius-xl)-1px)] last:rounded-b-[calc(var(--radius-xl)-1px)]`,tt.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e),t[23]=e,t[24]=S),t[25]!==n||t[26]!==a?(h=()=>a(n),t[25]=n,t[26]=a,t[27]=h):h=t[27],t[28]===r?g=t[29]:(g=(0,$.jsx)(K,{connector:r}),t[28]=r,t[29]=g),b=`min-w-0 flex-1`,v=`flex min-w-0 items-center gap-2`,t[30]===n.displayName?y=t[31]:(y=(0,$.jsx)(`h3`,{className:`truncate text-sm font-medium text-fg`,children:n.displayName}),t[30]=n.displayName,t[31]=y),_=p(`inline-flex shrink-0 items-center gap-1 text-xs font-medium`,m.className),t[6]=u,t[7]=r,t[8]=s,t[9]=n,t[10]=a,t[11]=o.connectionChecking,t[12]=o.connectionNeedsSetup,t[13]=o.connectionReady,t[14]=m,t[15]=h,t[16]=g,t[17]=_,t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S}else m=t[14],h=t[15],g=t[16],_=t[17],v=t[18],y=t[19],b=t[20],x=t[21],S=t[22];let C;t[32]===m.Icon?C=t[33]:(C=(0,$.jsx)(m.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[32]=m.Icon,t[33]=C);let w;t[34]!==m.label||t[35]!==C||t[36]!==_?(w=(0,$.jsxs)(`span`,{className:_,children:[C,m.label]}),t[34]=m.label,t[35]=C,t[36]=_,t[37]=w):w=t[37];let T;t[38]!==w||t[39]!==v||t[40]!==y?(T=(0,$.jsxs)(`div`,{className:v,children:[y,w]}),t[38]=w,t[39]=v,t[40]=y,t[41]=T):T=t[41];let E;t[42]===f?E=t[43]:(E=f?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:f}):null,t[42]=f,t[43]=E);let D;t[44]!==T||t[45]!==E||t[46]!==b?(D=(0,$.jsxs)(`div`,{className:b,children:[T,E]}),t[44]=T,t[45]=E,t[46]=b,t[47]=D):D=t[47];let O;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(H,{className:`size-4 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[48]=O):O=t[48];let k;return t[49]!==h||t[50]!==g||t[51]!==D||t[52]!==x||t[53]!==S?(k=(0,$.jsxs)(`button`,{type:x,className:S,onClick:h,children:[g,D,O]}),t[49]=h,t[50]=g,t[51]=D,t[52]=x,t[53]=S,t[54]=k):k=t[54],k}function Dn(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 Bt(r)}function On(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 kn(){return p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G)}function An({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:s,headers:c,onChange:l}){let u=(e,t)=>{l(c.map((n,r)=>r===e?{...n,...t}:n))},d=()=>{l([...c,{key:``,value:``}])},f=e=>{let t=c.filter((t,n)=>n!==e);l(t.length>0?t:[{key:``,value:``}])},m=async()=>{try{let e=await E();if(!e){window.alert(a);return}let t=jt(e);if(!t?.length){window.alert(a);return}l(t)}catch{window.alert(a)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,$.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void m(),children:[(0,$.jsx)(it,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{className:p(kn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>u(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:p(kn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:s,onChange:e=>u(t,{value:e.target.value})}),(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:c.length<=1&&!e.key&&!e.value,onClick:()=>f(t),"aria-label":r,children:(0,$.jsx)(Be,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},On(e,t,c)))}),(0,$.jsxs)(`button`,{type:`button`,className:p(`self-start text-sm text-accent hover:underline`,tt.press),onClick:d,children:[`+ `,n]})]})}var jn=[`stdio`,`sse`,`streamable-http`],Mn=[`none`,`oauth`];function Nn(e){let t=(0,Q.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,$.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,$.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function Pn(){return p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G)}function Fn(e){let t=(0,Q.c)(37),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:c}=e,l=c===void 0?`all`:c,u=l===`all`||l===`basic`,d=l===`all`||l===`advanced`,f;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==u||t[5]!==r?(f=u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Nn,{label:r.transportLabel,required:!0,children:(0,$.jsx)(o,{className:Pn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:jn.map(e=>(0,$.jsx)(s,{value:e,children:r.transportLabels[e]},e))})}),(0,$.jsxs)(Nn,{label:r.serverIdLabel,required:!0,children:[(0,$.jsx)(`input`,{className:Pn(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:a}):null]})]}):null,t[0]=a,t[1]=i,t[2]=n.id,t[3]=n.transport,t[4]=u,t[5]=r,t[6]=f):f=t[6];let m;t[7]!==i||t[8]!==n.argsText||t[9]!==n.auth||t[10]!==n.command||t[11]!==n.cwd||t[12]!==n.envJson||t[13]!==n.headers||t[14]!==n.oauthClientId||t[15]!==n.transport||t[16]!==n.url||t[17]!==d||t[18]!==u||t[19]!==r||t[20]!==l?(m=n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(`div`,{className:l===`basic`?`md:col-span-2`:void 0,children:(0,$.jsx)(Nn,{label:r.commandLabel,required:!0,children:(0,$.jsx)(`input`,{className:Pn(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Nn,{label:r.argsLabel,description:r.argsHint,children:(0,$.jsx)(`input`,{className:Pn(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,$.jsx)(Nn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Pn(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,$.jsx)(Nn,{label:r.envLabel,description:r.envHint,children:(0,$.jsx)(`textarea`,{className:p(Pn(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(`div`,{className:`md:col-span-2`,children:(0,$.jsx)(Nn,{label:r.urlLabel,required:!0,children:(0,$.jsx)(`input`,{className:p(Pn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u&&n.transport===`streamable-http`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Nn,{label:r.authLabel,description:r.authHint,children:(0,$.jsx)(o,{className:Pn(),value:n.auth,onChange:e=>{let t=e.target.value;i({auth:t,headers:t===`oauth`?n.headers.filter(Ln):n.headers})},children:Mn.map(e=>(0,$.jsx)(s,{value:e,children:r.authLabels[e]},e))})}),n.auth===`oauth`?(0,$.jsx)(Nn,{label:r.oauthClientIdLabel,description:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:p(Pn(),`font-mono text-xs`),value:n.oauthClientId,placeholder:r.oauthClientIdPlaceholder,onChange:e=>i({oauthClientId:e.target.value})})}):null]}):null,d?(0,$.jsx)(An,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>i({headers:n.auth===`oauth`?e.filter(In):e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.auth,t[10]=n.command,t[11]=n.cwd,t[12]=n.envJson,t[13]=n.headers,t[14]=n.oauthClientId,t[15]=n.transport,t[16]=n.url,t[17]=d,t[18]=u,t[19]=r,t[20]=l,t[21]=m):m=t[21];let h;t[22]!==i||t[23]!==n||t[24]!==d||t[25]!==r?(h=d?(0,$.jsx)(Nn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:600,className:Pn(),value:Qt(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:$t(e.target.value)})})}):null,t[22]=i,t[23]=n,t[24]=d,t[25]=r,t[26]=h):h=t[26];let g;t[27]!==i||t[28]!==n||t[29]!==d||t[30]!==r?(g=d?(0,$.jsx)(Nn,{label:r.requestTimeoutLabel,description:r.requestTimeoutHint,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:14400,className:Pn(),value:en(n),placeholder:r.requestTimeoutPlaceholder,onChange:e=>i({requestTimeoutMs:tn(e.target.value)})})}):null,t[27]=i,t[28]=n,t[29]=d,t[30]=r,t[31]=g):g=t[31];let _;return t[32]!==f||t[33]!==m||t[34]!==h||t[35]!==g?(_=(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[f,m,h,g]}),t[32]=f,t[33]=m,t[34]=h,t[35]=g,t[36]=_):_=t[36],_}function In(e){return e.key.trim().toLowerCase()!==`authorization`}function Ln(e){return e.key.trim().toLowerCase()!==`authorization`}function Rn(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 zn(e){let t=(0,Q.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=Rn(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o=n.name===a?a:n.name,s;t[3]===n.description?s=t[4]:(s=n.description?.trim(),t[3]=n.description,t[4]=s);let c=s,l;t[5]!==a||t[6]!==o?(l=(0,$.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:o,children:a}),t[5]=a,t[6]=o,t[7]=l):l=t[7];let u;t[8]===c?u=t[9]:(u=c?(0,$.jsx)(L,{delayDuration:300,skipDelayDuration:100,children:(0,$.jsxs)(F,{children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(`p`,{tabIndex:0,title:c,className:p(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:c})}),(0,$.jsx)(I,{children:(0,$.jsx)(R,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:c})})})]})}):null,t[8]=c,t[9]=u);let d;return t[10]!==l||t[11]!==u?(d=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Bn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:o,t:s,cs:c,onClose:d,onSaved:m}){let[h,g]=(0,Z.useState)(n),[_,v]=(0,Z.useState)(!1),[E,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)({status:`idle`}),[F,I]=(0,Z.useState)(null),L=n.id.trim(),R=h.id.trim()!==L&&o.has(h.id.trim())||o.has(h.id.trim())&&t===`add`?s.reservedServerId:void 0,ee=h.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===h.id.trim())?c.duplicateServerId:void 0,z=h.id.trim().length>0&&!R&&!ee&&(h.transport===`stdio`?h.command.trim().length>0:h.url.trim().length>0),B=!(h.transport===`streamable-http`&&h.auth===`oauth`),V=nn(h),H=(0,Z.useCallback)(async()=>{if(h.id.trim()){O(!0),A(null),P({status:`loading`});try{P({status:`ok`,tools:(await Zt(h.id.trim(),Ht(h))).tools})}catch(e){P({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{O(!1)}}},[h]),U=(0,Z.useCallback)(async()=>{if(!(!z||_)){v(!0),A(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(h),await Ut({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Ft(a)),await m(),d()}catch(e){A(e instanceof Error?e.message:String(e))}finally{v(!1)}}},[z,a,r,n.clientKey,t,d,m,L,h,_,i]);return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{open:e,onOpenChange:e=>{e||d()},children:(0,$.jsxs)(S,{children:[(0,$.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(C,{className:p(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(w,{className:`text-base font-semibold text-fg`,children:t===`add`?c.addCustomServerTitle:c.editCustomServerTitle}),(0,$.jsx)(b,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?c.addCustomServerHint:c.editCustomServerHint})]}),(0,$.jsx)(x,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:p(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,tt.focusRingPanel),"aria-label":c.modalClose,children:[(0,$.jsx)(f,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:c.modalClose})]})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(ue,{className:`size-4 text-accent`,"aria-hidden":!0}),h.id.trim()||s.cardUntitled]}),(0,$.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:V||(h.transport===`stdio`?s.commandLabel:s.urlLabel)})]}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:s.transportLabels[h.transport]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectorBasicConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.connectorBasicConfigHint})]}),(0,$.jsx)(Fn,{row:h,t:s,variant:`basic`,onUpdate:e=>{g(t=>({...t,...e})),A(null)},idConflictMessage:R??ee})]}),N.status===`ok`?(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(oe,{className:`size-4 text-accent`,"aria-hidden":!0}),N.tools.length===0?s.toolsEmpty:s.toolsTitle.replace(`{{count}}`,String(N.tools.length))]}),N.tools.length>0?(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>I(N.tools),children:s.viewAllTools}):null]}),N.tools.length>0?(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:N.tools.slice(0,6).map((e,t)=>(0,$.jsx)(zn,{tool:e,serverId:h.id},e.name||`tool-${t}`))}):null]}):null,N.status===`error`?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:N.message}):null,k?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:k}):null,(0,$.jsxs)(`details`,{open:j,onToggle:e=>M(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,$.jsx)(ce,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`group-open:hidden`,children:c.connectorShowAdvancedConfig}),(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:c.connectorHideAdvancedConfig})]}),(0,$.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,$.jsx)(Fn,{row:h,t:s,variant:`advanced`,onUpdate:e=>{g(t=>({...t,...e})),A(null)}})})]})]})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsxs)(D,{variant:`secondary`,disabled:!h.id.trim()||E||!B,title:B?void 0:s.oauthSaveBeforeTest,onClick:()=>void H(),children:[E?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(pe,{className:`size-4`}),s.testConnection]}),(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(D,{variant:`secondary`,children:c.modalCancel})}),(0,$.jsxs)(D,{variant:`primary`,disabled:!z||_,onClick:()=>void U(),children:[_?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(l,{className:`size-4`}),_?s.saving:c.modalSave]})]})]})]})}),F?(0,$.jsx)(ln,{open:!0,onOpenChange:e=>{e||I(null)},serverId:h.id,title:s.toolsDialogTitle,subtitle:s.toolsDialogSubtitle,searchPlaceholder:s.toolsDialogSearchPlaceholder,searchEmptyLabel:s.toolsDialogSearchEmpty,emptyLabel:s.toolsEmpty,closeLabel:s.toolsDialogClose,tools:F,stripPrefix:`${h.id.trim()}__`}):null]}):null}var Vn=`builtin`,Hn=`composio`,Un=`xopc-store`;function Wn(e){return Vn}function Gn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function Kn(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 qn(e,t,n){return e.filter(e=>Kn(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Jn(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 Yn(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 Xn(e){let t=e.connectorManifest;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;if(n.contractVersion!==1||n.id!==e.name)return null;let r=n.runtime,i=n.auth;if(!r||typeof r!=`object`||Array.isArray(r)||!i||typeof i!=`object`||Array.isArray(i))return null;let a=r,o=i;if(a.type!==`mcp`||typeof a.serverId!=`string`)return null;let s=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(n.category??``))?n.category:`custom`,c=o.mode===`oauth`?{mode:`oauth`,...typeof o.clientId==`string`?{clientId:o.clientId}:{}}:o.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`};return{id:e.name,version:e.latestVersion??`store`,displayName:typeof n.displayName==`string`?n.displayName:e.name,description:typeof n.description==`string`?n.description:e.description,category:s,kind:`mcp`,source:`store`,capabilities:Array.isArray(n.capabilities)?n.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(n.tags)?n.tags.filter(e=>typeof e==`string`):[`store`],auth:c,setup:n.setup&&typeof n.setup==`object`&&!Array.isArray(n.setup)?n.setup:{},runtime:{type:`mcp`,serverId:a.serverId}}}function Zn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Qn(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function $n(){let e=v(g(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=h(e=>e.conversationId),o=!!r,s=i(),[l,d]=a(),f=l.get(`understanding`)===`1`,m=Qn(l.get(`returnTo`)),_=l.get(`tab`),[y,b]=(0,Z.useState)(!f&&_===`connected`?`connected`:`discover`),x=(0,Z.useRef)(!1),[S,C]=(0,Z.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[w,T]=(0,Z.useState)(!1),[E,O]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(1),[M,N]=(0,Z.useState)(void 0),[P,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)(f?l.get(`connector`)??``:``),[R,ee]=(0,Z.useState)(Wn(f?`understanding`:`default`)),[z,B]=(0,Z.useState)(`name`),[V,H]=(0,Z.useState)(f?`understand`:`all`),[U,W]=(0,Z.useState)(null),[G,K]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(null),[oe,se]=(0,Z.useState)(null),[ce,le]=(0,Z.useState)(null),[q,ue]=(0,Z.useState)(null),[de,pe]=(0,Z.useState)(!1),[Y,ge]=(0,Z.useState)(void 0),[ve,ye]=(0,Z.useState)(!1),{data:be,mutate:xe}=k(o),Se=be?.payload?.config,Ce=(0,Z.useMemo)(()=>Se===void 0?null:Vt(Se),[Se]),X=Ce?.servers??[],we=S.instances.length+X.length;(0,Z.useEffect)(()=>{Ce&&ge(Ce.sessionIdleTtlMinutes)},[Ce]);let Te=(0,Z.useCallback)(async()=>{if(!r){C({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}C(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([re(),fe()]);C(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){C({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,Z.useEffect)(()=>{Te()},[Te]),(0,Z.useEffect)(()=>{x.current||S.loading||o&&!Ce||(b(f?`discover`:we>0?`connected`:`discover`),x.current=!0)},[o,we,Ce,f,S.loading]);let De=(0,Z.useCallback)(e=>{x.current=!0,b(e)},[]),Oe=(0,Z.useMemo)(()=>[{id:Hn,displayName:t.composioSourceName},{id:Un,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),ke=(0,Z.useCallback)(async e=>{if(!o||R===`builtin`){C(e=>({...e,registryCatalog:[]})),j(1),N(void 0);return}let t=I.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=R===`all`?Oe:Oe.filter(e=>e.id===R);if(i.length!==0){T(!0),r?C(e=>({...e,error:null})):(j(1),N(void 0),C(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await me({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await he({q:t||void 0,page:n,pageSize:24,sort:z===`source`?`newest`:`downloads`});return{connectors:r.items.flatMap(e=>{let t=Xn(e);return t?[t]:[]}),totalPages:r.meta.totalPages}})),a=Zn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));j(n),N(o),C(e=>({...e,registryCatalog:r?Zn([...e.registryCatalog,...a]):a}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{T(!1)}}},[z,I,R,o,Oe]);(0,Z.useEffect)(()=>{if(y!==`discover`||S.loading)return;if(R===`builtin`){C(e=>({...e,registryCatalog:[]})),j(1),N(void 0);return}let e=window.setTimeout(()=>{ke()},I.trim()?350:0);return()=>window.clearTimeout(e)},[I,R,ke,S.loading,y]);let Ae=(0,Z.useMemo)(()=>new Set(S.instances.map(e=>e.connectorId)),[S.instances]),je=(0,Z.useMemo)(()=>new Map([...S.catalog,...S.registryCatalog].map(e=>[e.id,e])),[S.catalog,S.registryCatalog]);(0,Z.useEffect)(()=>{if(S.loading)return;let e=l.get(`connector`),t=l.get(`instance`);if(!e&&!t)return;let n=S.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)x.current=!0,F(``),ae(n.instanceId),se(n),b(`connected`);else if(e){let t=je.get(e);if(!t)return;x.current=!0,ee(Wn(f?`understanding`:`default`)),L(``),K(t),b(`discover`)}let r=new URLSearchParams(l);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),d(r,{replace:!0})},[je,f,l,d,S.instances,S.loading]);let Me=(0,Z.useCallback)(async e=>{O(!0),C(e=>({...e,error:null}));try{let t=await te(e);W(J(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{O(!1)}},[]),Ne=(0,Z.useMemo)(()=>new Set(S.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[S.instances]),Pe=(0,Z.useCallback)(async e=>{if(!Ce||Se===void 0)return;let t=X.filter(t=>t.clientKey!==e.clientKey);await Ut({sessionIdleTtlMinutes:Ce.sessionIdleTtlMinutes,servers:t},Ft(Se)),await xe(),await Te()},[Se,X,Te,Ce,xe]),Fe=(0,Z.useCallback)(()=>{ue({mode:`add`,row:Dn(X,Ne)})},[X,Ne]),Ie=(0,Z.useCallback)(async()=>{if(!(!Ce||Se===void 0||ve)){ye(!0);try{await Ut({sessionIdleTtlMinutes:Y,servers:X},Ft(Se)),await xe(),pe(!1)}finally{ye(!1)}}},[Se,X,n.saved,Ce,xe,Y,ve]),Le=Ee(e=>e.setPageHeader),Re=Ee(e=>e.clearPageHeader),ze=(0,Z.useMemo)(()=>(0,$.jsx)(kt,{onBrowseCatalog:()=>De(`discover`),onAddCustomServer:Fe,addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced}),[t,Fe,De]);(0,Z.useLayoutEffect)(()=>(Le({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:ze}),()=>Re()),[Re,t.title,ze,Le]);let Be=(0,Z.useMemo)(()=>S.instances.map(e=>({instance:e,value:yt(e,je.get(e.connectorId))})),[je,S.instances]),Ve=(0,Z.useMemo)(()=>new Map(Be.map(({instance:e,value:t})=>[e.instanceId,t])),[Be]),He=(0,Z.useMemo)(()=>S.instances.filter(e=>Jn(e,P)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ve.get(e.instanceId)?.state??`checking`,i=Ve.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[P,Ve,S.instances]),Ue=(0,Z.useMemo)(()=>He.filter(e=>Ve.get(e.instanceId)?.state===`needs_setup`),[Ve,He]),We=(0,Z.useMemo)(()=>He.filter(e=>Ve.get(e.instanceId)?.state!==`needs_setup`),[Ve,He]),Ge=(0,Z.useMemo)(()=>X.filter(e=>Yn(e,P)),[P,X]),Ke=He.length+Ge.length,qe=(0,Z.useMemo)(()=>S.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Gn(e)),[S.catalog]),Je=(0,Z.useMemo)(()=>R===`builtin`?qe:R===`all`?Zn([...qe,...S.registryCatalog]):S.registryCatalog,[qe,R,S.registryCatalog]),Xe=(0,Z.useMemo)(()=>{let e=f?Je.filter(e=>e.understanding?.mode===`activity`):Je;return qn(V===`all`?e:e.filter(e=>_t(e).includes(V)),I,z)},[z,I,Je,f,V]),Ze=(0,Z.useMemo)(()=>gt.filter(e=>Je.some(t=>_t(t).includes(e))),[Je]);(0,Z.useEffect)(()=>{V!==`all`&&!Ze.includes(V)&&H(`all`)},[Ze,V]);let $e=y===`discover`&&R!==`builtin`&&!!(M&&A<M),et=(0,Z.useMemo)(()=>S.instances.find(e=>e.instanceId===ie)??oe,[ie,oe,S.instances]),tt=(0,Z.useMemo)(()=>[{value:`all`,label:t.discoverSourceAll},{value:Vn,label:t.discoverSourceBuiltin},...Oe.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Oe]),nt=[{id:`connected`,label:t.tabConnected,count:we},{id:`discover`,label:t.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[o?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),f?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:t.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.understandingSetupHint})]}),(0,$.jsx)(D,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>s(m),children:t.understandingSetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(st,{items:nt,activeTab:y,onChange:De,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),S.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S.error}):null,y===`connected`&&o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[we>5||P?(0,$.jsx)(Ot,{value:P,onChange:F,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}):(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(_e,{className:`size-9 shrink-0 p-0`,loading:S.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:Te})]}),S.loading?(0,$.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:ut.slice(0,3).map(e=>(0,$.jsx)(ht,{},e))}):we===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,$.jsx)(D,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>De(`discover`),children:t.addFromCatalog})]}):Ke===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[Ue.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:Ue.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-amber-500/25 bg-amber-500/5`,children:Ue.map(e=>(0,$.jsx)(En,{instance:e,definition:je.get(e.connectorId),highlighted:e.instanceId===ce,onOpenDetails:e=>{le(null),ae(e.instanceId),se(e)},t},e.instanceId))})]}):null,We.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.connectedServicesTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-fg-subtle`,children:We.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:We.map(e=>(0,$.jsx)(En,{instance:e,definition:je.get(e.connectorId),highlighted:e.instanceId===ce,onOpenDetails:e=>{le(null),ae(e.instanceId),se(e)},t},e.instanceId))})]}):null,Ge.length||!P.trim()?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.customIntegrationsTitle}),(0,$.jsx)(`span`,{className:`ml-2 text-xs tabular-nums text-fg-subtle`,children:Ge.length}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.customIntegrationsHint})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-3`,children:[(0,$.jsx)(D,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:Fe,children:t.addCustomServerAdvanced}),(0,$.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>pe(!0),children:[(0,$.jsx)(Qe,{className:`size-3.5`}),t.runtimeSettings]})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:Ge.map(e=>(0,$.jsx)(rn,{row:e,t:n,cs:t,onEdit:()=>ue({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Pe(e)},e.clientKey))})]})]}):null]})]}):null,y===`discover`&&o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f?null:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.taskFilterAria,children:[`all`,...Ze].map(e=>(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,V===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":V===e,onClick:()=>H(e),children:e===`all`?t.taskAll:t.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,$.jsx)(Ot,{value:I,onChange:L,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,$.jsxs)(`details`,{className:`relative shrink-0 lg:ml-auto`,children:[(0,$.jsxs)(`summary`,{className:`flex h-9 cursor-pointer list-none items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,$.jsx)(Ye,{className:`size-3.5`,"aria-hidden":!0}),t.filters]}),(0,$.jsxs)(`div`,{className:p(`mt-2 grid min-w-[15rem] grid-cols-1 gap-2 rounded-xl border border-edge bg-surface-panel p-3 shadow-popover sm:absolute sm:right-0 sm:z-10`,!f&&`sm:min-w-[24rem] sm:grid-cols-2`),children:[f?null:(0,$.jsx)(c,{value:R,options:tt,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ee}),(0,$.jsx)(c,{value:z,options:[{value:`name`,label:t.sortName},{value:`source`,label:t.sortSource}],placeholder:t.sortName,allowEmpty:!1,ariaLabel:t.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>B(e)})]})]})]}),(S.loading||w)&&Xe.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:ut.map(e=>(0,$.jsx)(pt,{},e))}):Xe.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[w?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":t.loading,children:(0,$.jsx)(u,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Xe.map(e=>(0,$.jsx)(ct,{connector:e,installed:Ae.has(e.id)||dt(e,S.instances),onInstall:e=>{if(e.source===`store`){Me(e.id);return}W(J(e))},onOpenDetails:e.source===`store`?void 0:K,t},e.id))}),$e?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(D,{type:`button`,variant:`secondary`,disabled:w||E,onClick:()=>void ke({page:A+1,append:!0}),children:[w?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),U?(0,$.jsx)(ne,{draft:U,onChange:W,onClose:()=>W(null),t,onInstalled:async e=>{await Te(),await xe(),le(e.instanceId),De(`connected`)}}):null,G?(0,$.jsx)(Tt,{connector:G,installed:Ae.has(G.id)||dt(G,S.instances),onClose:()=>K(null),onInstall:e=>W(J(e)),t}):null,et?(0,$.jsx)(Tn,{instance:et,definition:je.get(et.connectorId),onClose:()=>{ae(null),se(null)},onChanged:Te,t,mcp:n}):null,q?(0,$.jsx)(Bn,{open:!0,mode:q.mode,initialRow:q.row,existingCustomServers:X,sessionIdleTtlMinutes:Y,config:Se,managedServerIds:Ne,t:n,cs:t,onClose:()=>ue(null),onSaved:async()=>{await xe(),await Te(),De(`connected`)}},`${q.mode}-${q.row.clientKey}`):null,(0,$.jsx)(Dt,{open:de,sessionIdleTtlMinutes:Y,saving:ve,onChange:ge,onSave:Ie,onClose:()=>pe(!1),t,mcp:n})]})})}export{$n as ConnectorsPage};